]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9-3.3.7-201205271953.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9-3.3.7-201205271953.patch
1 diff --git a/Documentation/dontdiff b/Documentation/dontdiff
2 index 0c083c5..bf13011 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,9 +51,11 @@
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 @@ -69,6 +74,7 @@ Image
38 Module.markers
39 Module.symvers
40 PENDING
41 +PERF*
42 SCCS
43 System.map*
44 TAGS
45 @@ -92,19 +98,24 @@ bounds.h
46 bsetup
47 btfixupprep
48 build
49 +builtin-policy.h
50 bvmlinux
51 bzImage*
52 capability_names.h
53 capflags.c
54 classlist.h*
55 +clut_vga16.c
56 +common-cmds.h
57 comp*.log
58 compile.h*
59 conf
60 config
61 config-*
62 config_data.h*
63 +config.c
64 config.mak
65 config.mak.autogen
66 +config.tmp
67 conmakehash
68 consolemap_deftbl.c*
69 cpustr.h
70 @@ -115,9 +126,11 @@ devlist.h*
71 dnotify_test
72 docproc
73 dslm
74 +dtc-lexer.lex.c
75 elf2ecoff
76 elfconfig.h*
77 evergreen_reg_safe.h
78 +exception_policy.conf
79 fixdep
80 flask.h
81 fore200e_mkfirm
82 @@ -125,12 +138,15 @@ fore200e_pca_fw.c*
83 gconf
84 gconf.glade.h
85 gen-devlist
86 +gen-kdb_cmds.c
87 gen_crc32table
88 gen_init_cpio
89 generated
90 genheaders
91 genksyms
92 *_gray256.c
93 +hash
94 +hid-example
95 hpet_example
96 hugepage-mmap
97 hugepage-shm
98 @@ -145,7 +161,7 @@ int32.c
99 int4.c
100 int8.c
101 kallsyms
102 -kconfig
103 +kern_constants.h
104 keywords.c
105 ksym.c*
106 ksym.h*
107 @@ -153,7 +169,7 @@ kxgettext
108 lkc_defs.h
109 lex.c
110 lex.*.c
111 -linux
112 +lib1funcs.S
113 logo_*.c
114 logo_*_clut224.c
115 logo_*_mono.c
116 @@ -165,14 +181,15 @@ machtypes.h
117 map
118 map_hugetlb
119 maui_boot.h
120 -media
121 mconf
122 +mdp
123 miboot*
124 mk_elfconfig
125 mkboot
126 mkbugboot
127 mkcpustr
128 mkdep
129 +mkpiggy
130 mkprep
131 mkregtable
132 mktables
133 @@ -208,6 +225,7 @@ r300_reg_safe.h
134 r420_reg_safe.h
135 r600_reg_safe.h
136 recordmcount
137 +regdb.c
138 relocs
139 rlim_names.h
140 rn50_reg_safe.h
141 @@ -218,6 +236,7 @@ setup
142 setup.bin
143 setup.elf
144 sImage
145 +slabinfo
146 sm_tbl*
147 split-include
148 syscalltab.h
149 @@ -228,6 +247,7 @@ tftpboot.img
150 timeconst.h
151 times.h*
152 trix_boot.h
153 +user_constants.h
154 utsrelease.h*
155 vdso-syms.lds
156 vdso.lds
157 @@ -245,7 +265,9 @@ vmlinux
158 vmlinux-*
159 vmlinux.aout
160 vmlinux.bin.all
161 +vmlinux.bin.bz2
162 vmlinux.lds
163 +vmlinux.relocs
164 vmlinuz
165 voffset.h
166 vsyscall.lds
167 @@ -253,9 +275,11 @@ vsyscall_32.lds
168 wanxlfw.inc
169 uImage
170 unifdef
171 +utsrelease.h
172 wakeup.bin
173 wakeup.elf
174 wakeup.lds
175 zImage*
176 zconf.hash.c
177 +zconf.lex.c
178 zoffset.h
179 diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
180 index d99fd9c..8689fef 100644
181 --- a/Documentation/kernel-parameters.txt
182 +++ b/Documentation/kernel-parameters.txt
183 @@ -1977,6 +1977,13 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
184 the specified number of seconds. This is to be used if
185 your oopses keep scrolling off the screen.
186
187 + pax_nouderef [X86] disables UDEREF. Most likely needed under certain
188 + virtualization environments that don't cope well with the
189 + expand down segment used by UDEREF on X86-32 or the frequent
190 + page table updates on X86-64.
191 +
192 + pax_softmode= 0/1 to disable/enable PaX softmode on boot already.
193 +
194 pcbit= [HW,ISDN]
195
196 pcd. [PARIDE]
197 diff --git a/Makefile b/Makefile
198 index 073f74f..a689ddf 100644
199 --- a/Makefile
200 +++ b/Makefile
201 @@ -245,8 +245,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
202
203 HOSTCC = gcc
204 HOSTCXX = g++
205 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
206 -HOSTCXXFLAGS = -O2
207 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
208 +HOSTCLFAGS += $(call cc-option, -Wno-empty-body)
209 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
210
211 # Decide whether to build built-in, modular, or both.
212 # Normally, just do built-in.
213 @@ -357,9 +358,9 @@ CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
214
215 # Use LINUXINCLUDE when you must reference the include/ directory.
216 # Needed to be compatible with the O= option
217 -LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include \
218 - -Iarch/$(hdr-arch)/include/generated -Iinclude \
219 - $(if $(KBUILD_SRC), -I$(srctree)/include) \
220 +LINUXINCLUDE := -isystem arch/$(hdr-arch)/include \
221 + -isystem arch/$(hdr-arch)/include/generated -isystem include \
222 + -isystem include/generated \
223 -include $(srctree)/include/linux/kconfig.h
224
225 KBUILD_CPPFLAGS := -D__KERNEL__
226 @@ -407,8 +408,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exc
227 # Rules shared between *config targets and build targets
228
229 # Basic helpers built in scripts/
230 -PHONY += scripts_basic
231 -scripts_basic:
232 +PHONY += scripts_basic gcc-plugins
233 +scripts_basic: gcc-plugins
234 $(Q)$(MAKE) $(build)=scripts/basic
235 $(Q)rm -f .tmp_quiet_recordmcount
236
237 @@ -442,7 +443,7 @@ asm-generic:
238
239 no-dot-config-targets := clean mrproper distclean \
240 cscope gtags TAGS tags help %docs check% coccicheck \
241 - include/linux/version.h headers_% archheaders \
242 + include/generated/linux/version.h headers_% archheaders \
243 kernelversion %src-pkg
244
245 config-targets := 0
246 @@ -485,11 +486,11 @@ include $(srctree)/arch/$(SRCARCH)/Makefile
247 export KBUILD_DEFCONFIG KBUILD_KCONFIG
248
249 config: scripts_basic outputmakefile FORCE
250 - $(Q)mkdir -p include/linux include/config
251 + $(Q)mkdir -p include/generated/linux include/config
252 $(Q)$(MAKE) $(build)=scripts/kconfig $@
253
254 %config: scripts_basic outputmakefile FORCE
255 - $(Q)mkdir -p include/linux include/config
256 + $(Q)mkdir -p include/generated/linux include/config
257 $(Q)$(MAKE) $(build)=scripts/kconfig $@
258
259 else
260 @@ -564,6 +565,55 @@ else
261 KBUILD_CFLAGS += -O2
262 endif
263
264 +ifndef DISABLE_PAX_PLUGINS
265 +ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(CC)"), y)
266 +ifndef DISABLE_PAX_CONSTIFY_PLUGIN
267 +ifndef CONFIG_UML
268 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
269 +endif
270 +endif
271 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
272 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
273 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
274 +endif
275 +ifdef CONFIG_KALLOCSTAT_PLUGIN
276 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
277 +endif
278 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
279 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
280 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
281 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
282 +endif
283 +ifdef CONFIG_CHECKER_PLUGIN
284 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
285 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
286 +endif
287 +endif
288 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
289 +ifdef CONFIG_PAX_SIZE_OVERFLOW
290 +SIZE_OVERFLOW_PLUGIN := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
291 +endif
292 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
293 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS) $(SIZE_OVERFLOW_PLUGIN)
294 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
295 +export CONSTIFY_PLUGIN STACKLEAK_PLUGIN KERNEXEC_PLUGIN CHECKER_PLUGIN SIZE_OVERFLOW_PLUGIN
296 +ifeq ($(KBUILD_EXTMOD),)
297 +gcc-plugins:
298 + $(Q)$(MAKE) $(build)=tools/gcc
299 +else
300 +gcc-plugins: ;
301 +endif
302 +else
303 +gcc-plugins:
304 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
305 + $(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.))
306 +else
307 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
308 +endif
309 + $(Q)echo "PAX_MEMORY_STACKLEAK and other features will be less secure"
310 +endif
311 +endif
312 +
313 include $(srctree)/arch/$(SRCARCH)/Makefile
314
315 ifneq ($(CONFIG_FRAME_WARN),0)
316 @@ -708,7 +758,7 @@ export mod_strip_cmd
317
318
319 ifeq ($(KBUILD_EXTMOD),)
320 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
321 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
322
323 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
324 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
325 @@ -932,6 +982,8 @@ vmlinux.o: $(modpost-init) $(vmlinux-main) FORCE
326
327 # The actual objects are generated when descending,
328 # make sure no implicit rule kicks in
329 +$(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
330 +$(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
331 $(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): $(vmlinux-dirs) ;
332
333 # Handle descending into subdirectories listed in $(vmlinux-dirs)
334 @@ -941,7 +993,7 @@ $(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): $(vmlinux-dirs) ;
335 # Error messages still appears in the original language
336
337 PHONY += $(vmlinux-dirs)
338 -$(vmlinux-dirs): prepare scripts
339 +$(vmlinux-dirs): gcc-plugins prepare scripts
340 $(Q)$(MAKE) $(build)=$@
341
342 # Store (new) KERNELRELASE string in include/config/kernel.release
343 @@ -970,12 +1022,14 @@ ifneq ($(KBUILD_SRC),)
344 echo " in the '$(srctree)' directory.";\
345 /bin/false; \
346 fi;
347 + $(Q)for dir in $(srctree)/include/* ; do ln -fsn $$dir include/`basename $$dir` ; done
348 + $(Q)ln -fsn $(srctree)/arch/$(SRCARCH)/include/asm arch/$(SRCARCH)/include;
349 endif
350
351 # prepare2 creates a makefile if using a separate output directory
352 prepare2: prepare3 outputmakefile asm-generic
353
354 -prepare1: prepare2 include/linux/version.h include/generated/utsrelease.h \
355 +prepare1: prepare2 include/generated/linux/version.h include/generated/utsrelease.h \
356 include/config/auto.conf
357 $(cmd_crmodverdir)
358
359 @@ -985,6 +1039,7 @@ prepare0: archprepare FORCE
360 $(Q)$(MAKE) $(build)=.
361
362 # All the preparing..
363 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
364 prepare: prepare0
365
366 # Generate some files
367 @@ -1008,7 +1063,7 @@ define filechk_version.h
368 echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';)
369 endef
370
371 -include/linux/version.h: $(srctree)/Makefile FORCE
372 +include/generated/linux/version.h: $(srctree)/Makefile FORCE
373 $(call filechk,version.h)
374
375 include/generated/utsrelease.h: include/config/kernel.release FORCE
376 @@ -1050,7 +1105,7 @@ PHONY += archheaders
377 archheaders:
378
379 PHONY += __headers
380 -__headers: include/linux/version.h scripts_basic asm-generic archheaders FORCE
381 +__headers: include/generated/linux/version.h scripts_basic asm-generic archheaders FORCE
382 $(Q)$(MAKE) $(build)=scripts build_unifdef
383
384 PHONY += headers_install_all
385 @@ -1089,6 +1144,8 @@ all: modules
386 # using awk while concatenating to the final file.
387
388 PHONY += modules
389 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
390 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
391 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
392 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
393 @$(kecho) ' Building modules, stage 2.';
394 @@ -1104,7 +1161,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
395
396 # Target to prepare building external modules
397 PHONY += modules_prepare
398 -modules_prepare: prepare scripts
399 +modules_prepare: gcc-plugins prepare scripts
400
401 # Target to install modules
402 PHONY += modules_install
403 @@ -1163,7 +1220,7 @@ CLEAN_FILES += vmlinux System.map \
404 MRPROPER_DIRS += include/config usr/include include/generated \
405 arch/*/include/generated
406 MRPROPER_FILES += .config .config.old .version .old_version \
407 - include/linux/version.h \
408 + include/generated/linux/version.h \
409 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS
410
411 # clean - Delete most, but leave enough to build external modules
412 @@ -1201,6 +1258,7 @@ distclean: mrproper
413 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
414 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
415 -o -name '.*.rej' \
416 + -o -name '.*.rej' -o -name '*.so' \
417 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
418 -type f -print | xargs rm -f
419
420 @@ -1361,6 +1419,8 @@ PHONY += $(module-dirs) modules
421 $(module-dirs): crmodverdir $(objtree)/Module.symvers
422 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
423
424 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
425 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
426 modules: $(module-dirs)
427 @$(kecho) ' Building modules, stage 2.';
428 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
429 @@ -1487,17 +1547,21 @@ else
430 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
431 endif
432
433 -%.s: %.c prepare scripts FORCE
434 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
435 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
436 +%.s: %.c gcc-plugins prepare scripts FORCE
437 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
438 %.i: %.c prepare scripts FORCE
439 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
440 -%.o: %.c prepare scripts FORCE
441 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
442 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
443 +%.o: %.c gcc-plugins prepare scripts FORCE
444 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
445 %.lst: %.c prepare scripts FORCE
446 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
447 -%.s: %.S prepare scripts FORCE
448 +%.s: %.S gcc-plugins prepare scripts FORCE
449 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
450 -%.o: %.S prepare scripts FORCE
451 +%.o: %.S gcc-plugins prepare scripts FORCE
452 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
453 %.symtypes: %.c prepare scripts FORCE
454 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
455 @@ -1507,11 +1571,15 @@ endif
456 $(cmd_crmodverdir)
457 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
458 $(build)=$(build-dir)
459 -%/: prepare scripts FORCE
460 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
461 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
462 +%/: gcc-plugins prepare scripts FORCE
463 $(cmd_crmodverdir)
464 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
465 $(build)=$(build-dir)
466 -%.ko: prepare scripts FORCE
467 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
468 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
469 +%.ko: gcc-plugins prepare scripts FORCE
470 $(cmd_crmodverdir)
471 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
472 $(build)=$(build-dir) $(@:.ko=.o)
473 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
474 index 640f909..48b6597 100644
475 --- a/arch/alpha/include/asm/atomic.h
476 +++ b/arch/alpha/include/asm/atomic.h
477 @@ -250,6 +250,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
478 #define atomic_dec(v) atomic_sub(1,(v))
479 #define atomic64_dec(v) atomic64_sub(1,(v))
480
481 +#define atomic64_read_unchecked(v) atomic64_read(v)
482 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
483 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
484 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
485 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
486 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
487 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
488 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
489 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
490 +
491 #define smp_mb__before_atomic_dec() smp_mb()
492 #define smp_mb__after_atomic_dec() smp_mb()
493 #define smp_mb__before_atomic_inc() smp_mb()
494 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
495 index ad368a9..fbe0f25 100644
496 --- a/arch/alpha/include/asm/cache.h
497 +++ b/arch/alpha/include/asm/cache.h
498 @@ -4,19 +4,19 @@
499 #ifndef __ARCH_ALPHA_CACHE_H
500 #define __ARCH_ALPHA_CACHE_H
501
502 +#include <linux/const.h>
503
504 /* Bytes per L1 (data) cache line. */
505 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
506 -# define L1_CACHE_BYTES 64
507 # define L1_CACHE_SHIFT 6
508 #else
509 /* Both EV4 and EV5 are write-through, read-allocate,
510 direct-mapped, physical.
511 */
512 -# define L1_CACHE_BYTES 32
513 # define L1_CACHE_SHIFT 5
514 #endif
515
516 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
517 #define SMP_CACHE_BYTES L1_CACHE_BYTES
518
519 #endif
520 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
521 index da5449e..7418343 100644
522 --- a/arch/alpha/include/asm/elf.h
523 +++ b/arch/alpha/include/asm/elf.h
524 @@ -90,6 +90,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
525
526 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
527
528 +#ifdef CONFIG_PAX_ASLR
529 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
530 +
531 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
532 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
533 +#endif
534 +
535 /* $0 is set by ld.so to a pointer to a function which might be
536 registered using atexit. This provides a mean for the dynamic
537 linker to call DT_FINI functions for shared libraries that have
538 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
539 index bc2a0da..8ad11ee 100644
540 --- a/arch/alpha/include/asm/pgalloc.h
541 +++ b/arch/alpha/include/asm/pgalloc.h
542 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
543 pgd_set(pgd, pmd);
544 }
545
546 +static inline void
547 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
548 +{
549 + pgd_populate(mm, pgd, pmd);
550 +}
551 +
552 extern pgd_t *pgd_alloc(struct mm_struct *mm);
553
554 static inline void
555 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
556 index de98a73..bd4f1f8 100644
557 --- a/arch/alpha/include/asm/pgtable.h
558 +++ b/arch/alpha/include/asm/pgtable.h
559 @@ -101,6 +101,17 @@ struct vm_area_struct;
560 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
561 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
562 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
563 +
564 +#ifdef CONFIG_PAX_PAGEEXEC
565 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
566 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
567 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
568 +#else
569 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
570 +# define PAGE_COPY_NOEXEC PAGE_COPY
571 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
572 +#endif
573 +
574 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
575
576 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
577 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
578 index 2fd00b7..cfd5069 100644
579 --- a/arch/alpha/kernel/module.c
580 +++ b/arch/alpha/kernel/module.c
581 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
582
583 /* The small sections were sorted to the end of the segment.
584 The following should definitely cover them. */
585 - gp = (u64)me->module_core + me->core_size - 0x8000;
586 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
587 got = sechdrs[me->arch.gotsecindex].sh_addr;
588
589 for (i = 0; i < n; i++) {
590 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
591 index 01e8715..be0e80f 100644
592 --- a/arch/alpha/kernel/osf_sys.c
593 +++ b/arch/alpha/kernel/osf_sys.c
594 @@ -1147,7 +1147,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
595 /* At this point: (!vma || addr < vma->vm_end). */
596 if (limit - len < addr)
597 return -ENOMEM;
598 - if (!vma || addr + len <= vma->vm_start)
599 + if (check_heap_stack_gap(vma, addr, len))
600 return addr;
601 addr = vma->vm_end;
602 vma = vma->vm_next;
603 @@ -1183,6 +1183,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
604 merely specific addresses, but regions of memory -- perhaps
605 this feature should be incorporated into all ports? */
606
607 +#ifdef CONFIG_PAX_RANDMMAP
608 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
609 +#endif
610 +
611 if (addr) {
612 addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
613 if (addr != (unsigned long) -ENOMEM)
614 @@ -1190,8 +1194,8 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
615 }
616
617 /* Next, try allocating at TASK_UNMAPPED_BASE. */
618 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
619 - len, limit);
620 + addr = arch_get_unmapped_area_1 (PAGE_ALIGN(current->mm->mmap_base), len, limit);
621 +
622 if (addr != (unsigned long) -ENOMEM)
623 return addr;
624
625 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
626 index fadd5f8..904e73a 100644
627 --- a/arch/alpha/mm/fault.c
628 +++ b/arch/alpha/mm/fault.c
629 @@ -54,6 +54,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
630 __reload_thread(pcb);
631 }
632
633 +#ifdef CONFIG_PAX_PAGEEXEC
634 +/*
635 + * PaX: decide what to do with offenders (regs->pc = fault address)
636 + *
637 + * returns 1 when task should be killed
638 + * 2 when patched PLT trampoline was detected
639 + * 3 when unpatched PLT trampoline was detected
640 + */
641 +static int pax_handle_fetch_fault(struct pt_regs *regs)
642 +{
643 +
644 +#ifdef CONFIG_PAX_EMUPLT
645 + int err;
646 +
647 + do { /* PaX: patched PLT emulation #1 */
648 + unsigned int ldah, ldq, jmp;
649 +
650 + err = get_user(ldah, (unsigned int *)regs->pc);
651 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
652 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
653 +
654 + if (err)
655 + break;
656 +
657 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
658 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
659 + jmp == 0x6BFB0000U)
660 + {
661 + unsigned long r27, addr;
662 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
663 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
664 +
665 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
666 + err = get_user(r27, (unsigned long *)addr);
667 + if (err)
668 + break;
669 +
670 + regs->r27 = r27;
671 + regs->pc = r27;
672 + return 2;
673 + }
674 + } while (0);
675 +
676 + do { /* PaX: patched PLT emulation #2 */
677 + unsigned int ldah, lda, br;
678 +
679 + err = get_user(ldah, (unsigned int *)regs->pc);
680 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
681 + err |= get_user(br, (unsigned int *)(regs->pc+8));
682 +
683 + if (err)
684 + break;
685 +
686 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
687 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
688 + (br & 0xFFE00000U) == 0xC3E00000U)
689 + {
690 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
691 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
692 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
693 +
694 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
695 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
696 + return 2;
697 + }
698 + } while (0);
699 +
700 + do { /* PaX: unpatched PLT emulation */
701 + unsigned int br;
702 +
703 + err = get_user(br, (unsigned int *)regs->pc);
704 +
705 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
706 + unsigned int br2, ldq, nop, jmp;
707 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
708 +
709 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
710 + err = get_user(br2, (unsigned int *)addr);
711 + err |= get_user(ldq, (unsigned int *)(addr+4));
712 + err |= get_user(nop, (unsigned int *)(addr+8));
713 + err |= get_user(jmp, (unsigned int *)(addr+12));
714 + err |= get_user(resolver, (unsigned long *)(addr+16));
715 +
716 + if (err)
717 + break;
718 +
719 + if (br2 == 0xC3600000U &&
720 + ldq == 0xA77B000CU &&
721 + nop == 0x47FF041FU &&
722 + jmp == 0x6B7B0000U)
723 + {
724 + regs->r28 = regs->pc+4;
725 + regs->r27 = addr+16;
726 + regs->pc = resolver;
727 + return 3;
728 + }
729 + }
730 + } while (0);
731 +#endif
732 +
733 + return 1;
734 +}
735 +
736 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
737 +{
738 + unsigned long i;
739 +
740 + printk(KERN_ERR "PAX: bytes at PC: ");
741 + for (i = 0; i < 5; i++) {
742 + unsigned int c;
743 + if (get_user(c, (unsigned int *)pc+i))
744 + printk(KERN_CONT "???????? ");
745 + else
746 + printk(KERN_CONT "%08x ", c);
747 + }
748 + printk("\n");
749 +}
750 +#endif
751
752 /*
753 * This routine handles page faults. It determines the address,
754 @@ -131,8 +249,29 @@ do_page_fault(unsigned long address, unsigned long mmcsr,
755 good_area:
756 si_code = SEGV_ACCERR;
757 if (cause < 0) {
758 - if (!(vma->vm_flags & VM_EXEC))
759 + if (!(vma->vm_flags & VM_EXEC)) {
760 +
761 +#ifdef CONFIG_PAX_PAGEEXEC
762 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
763 + goto bad_area;
764 +
765 + up_read(&mm->mmap_sem);
766 + switch (pax_handle_fetch_fault(regs)) {
767 +
768 +#ifdef CONFIG_PAX_EMUPLT
769 + case 2:
770 + case 3:
771 + return;
772 +#endif
773 +
774 + }
775 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
776 + do_group_exit(SIGKILL);
777 +#else
778 goto bad_area;
779 +#endif
780 +
781 + }
782 } else if (!cause) {
783 /* Allow reads even for write-only mappings */
784 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
785 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
786 index 86976d0..c63ea6b 100644
787 --- a/arch/arm/include/asm/atomic.h
788 +++ b/arch/arm/include/asm/atomic.h
789 @@ -15,6 +15,10 @@
790 #include <linux/types.h>
791 #include <asm/system.h>
792
793 +#ifdef CONFIG_GENERIC_ATOMIC64
794 +#include <asm-generic/atomic64.h>
795 +#endif
796 +
797 #define ATOMIC_INIT(i) { (i) }
798
799 #ifdef __KERNEL__
800 @@ -25,7 +29,15 @@
801 * atomic_set() is the clrex or dummy strex done on every exception return.
802 */
803 #define atomic_read(v) (*(volatile int *)&(v)->counter)
804 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
805 +{
806 + return v->counter;
807 +}
808 #define atomic_set(v,i) (((v)->counter) = (i))
809 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
810 +{
811 + v->counter = i;
812 +}
813
814 #if __LINUX_ARM_ARCH__ >= 6
815
816 @@ -40,6 +52,35 @@ static inline void atomic_add(int i, atomic_t *v)
817 int result;
818
819 __asm__ __volatile__("@ atomic_add\n"
820 +"1: ldrex %1, [%3]\n"
821 +" adds %0, %1, %4\n"
822 +
823 +#ifdef CONFIG_PAX_REFCOUNT
824 +" bvc 3f\n"
825 +"2: bkpt 0xf103\n"
826 +"3:\n"
827 +#endif
828 +
829 +" strex %1, %0, [%3]\n"
830 +" teq %1, #0\n"
831 +" bne 1b"
832 +
833 +#ifdef CONFIG_PAX_REFCOUNT
834 +"\n4:\n"
835 + _ASM_EXTABLE(2b, 4b)
836 +#endif
837 +
838 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
839 + : "r" (&v->counter), "Ir" (i)
840 + : "cc");
841 +}
842 +
843 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
844 +{
845 + unsigned long tmp;
846 + int result;
847 +
848 + __asm__ __volatile__("@ atomic_add_unchecked\n"
849 "1: ldrex %0, [%3]\n"
850 " add %0, %0, %4\n"
851 " strex %1, %0, [%3]\n"
852 @@ -58,6 +99,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
853 smp_mb();
854
855 __asm__ __volatile__("@ atomic_add_return\n"
856 +"1: ldrex %1, [%3]\n"
857 +" adds %0, %1, %4\n"
858 +
859 +#ifdef CONFIG_PAX_REFCOUNT
860 +" bvc 3f\n"
861 +" mov %0, %1\n"
862 +"2: bkpt 0xf103\n"
863 +"3:\n"
864 +#endif
865 +
866 +" strex %1, %0, [%3]\n"
867 +" teq %1, #0\n"
868 +" bne 1b"
869 +
870 +#ifdef CONFIG_PAX_REFCOUNT
871 +"\n4:\n"
872 + _ASM_EXTABLE(2b, 4b)
873 +#endif
874 +
875 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
876 + : "r" (&v->counter), "Ir" (i)
877 + : "cc");
878 +
879 + smp_mb();
880 +
881 + return result;
882 +}
883 +
884 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
885 +{
886 + unsigned long tmp;
887 + int result;
888 +
889 + smp_mb();
890 +
891 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
892 "1: ldrex %0, [%3]\n"
893 " add %0, %0, %4\n"
894 " strex %1, %0, [%3]\n"
895 @@ -78,6 +155,35 @@ static inline void atomic_sub(int i, atomic_t *v)
896 int result;
897
898 __asm__ __volatile__("@ atomic_sub\n"
899 +"1: ldrex %1, [%3]\n"
900 +" subs %0, %1, %4\n"
901 +
902 +#ifdef CONFIG_PAX_REFCOUNT
903 +" bvc 3f\n"
904 +"2: bkpt 0xf103\n"
905 +"3:\n"
906 +#endif
907 +
908 +" strex %1, %0, [%3]\n"
909 +" teq %1, #0\n"
910 +" bne 1b"
911 +
912 +#ifdef CONFIG_PAX_REFCOUNT
913 +"\n4:\n"
914 + _ASM_EXTABLE(2b, 4b)
915 +#endif
916 +
917 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
918 + : "r" (&v->counter), "Ir" (i)
919 + : "cc");
920 +}
921 +
922 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
923 +{
924 + unsigned long tmp;
925 + int result;
926 +
927 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
928 "1: ldrex %0, [%3]\n"
929 " sub %0, %0, %4\n"
930 " strex %1, %0, [%3]\n"
931 @@ -96,11 +202,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
932 smp_mb();
933
934 __asm__ __volatile__("@ atomic_sub_return\n"
935 -"1: ldrex %0, [%3]\n"
936 -" sub %0, %0, %4\n"
937 +"1: ldrex %1, [%3]\n"
938 +" sub %0, %1, %4\n"
939 +
940 +#ifdef CONFIG_PAX_REFCOUNT
941 +" bvc 3f\n"
942 +" mov %0, %1\n"
943 +"2: bkpt 0xf103\n"
944 +"3:\n"
945 +#endif
946 +
947 " strex %1, %0, [%3]\n"
948 " teq %1, #0\n"
949 " bne 1b"
950 +
951 +#ifdef CONFIG_PAX_REFCOUNT
952 +"\n4:\n"
953 + _ASM_EXTABLE(2b, 4b)
954 +#endif
955 +
956 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
957 : "r" (&v->counter), "Ir" (i)
958 : "cc");
959 @@ -132,6 +252,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
960 return oldval;
961 }
962
963 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
964 +{
965 + unsigned long oldval, res;
966 +
967 + smp_mb();
968 +
969 + do {
970 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
971 + "ldrex %1, [%3]\n"
972 + "mov %0, #0\n"
973 + "teq %1, %4\n"
974 + "strexeq %0, %5, [%3]\n"
975 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
976 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
977 + : "cc");
978 + } while (res);
979 +
980 + smp_mb();
981 +
982 + return oldval;
983 +}
984 +
985 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
986 {
987 unsigned long tmp, tmp2;
988 @@ -165,7 +307,9 @@ static inline int atomic_add_return(int i, atomic_t *v)
989
990 return val;
991 }
992 +#define atomic_add_return_unchecked(i, v) atomic_add_return(i, v)
993 #define atomic_add(i, v) (void) atomic_add_return(i, v)
994 +#define atomic_add_unchecked(i, v) (void) atomic_add_return_unchecked(i, v)
995
996 static inline int atomic_sub_return(int i, atomic_t *v)
997 {
998 @@ -179,7 +323,9 @@ static inline int atomic_sub_return(int i, atomic_t *v)
999
1000 return val;
1001 }
1002 +#define atomic_sub_return_unchecked(i, v) atomic_sub_return(i, v)
1003 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1004 +#define atomic_sub_unchecked(i, v) (void) atomic_sub_return_unchecked(i, v)
1005
1006 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1007 {
1008 @@ -194,6 +340,7 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1009
1010 return ret;
1011 }
1012 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg(v, o, n)
1013
1014 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1015 {
1016 @@ -207,6 +354,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1017 #endif /* __LINUX_ARM_ARCH__ */
1018
1019 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1020 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1021 +{
1022 + return xchg(&v->counter, new);
1023 +}
1024
1025 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1026 {
1027 @@ -219,11 +370,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1028 }
1029
1030 #define atomic_inc(v) atomic_add(1, v)
1031 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1032 +{
1033 + atomic_add_unchecked(1, v);
1034 +}
1035 #define atomic_dec(v) atomic_sub(1, v)
1036 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1037 +{
1038 + atomic_sub_unchecked(1, v);
1039 +}
1040
1041 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1042 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1043 +{
1044 + return atomic_add_return_unchecked(1, v) == 0;
1045 +}
1046 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1047 #define atomic_inc_return(v) (atomic_add_return(1, v))
1048 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1049 +{
1050 + return atomic_add_return_unchecked(1, v);
1051 +}
1052 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1053 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1054
1055 @@ -239,6 +406,14 @@ typedef struct {
1056 u64 __aligned(8) counter;
1057 } atomic64_t;
1058
1059 +#ifdef CONFIG_PAX_REFCOUNT
1060 +typedef struct {
1061 + u64 __aligned(8) counter;
1062 +} atomic64_unchecked_t;
1063 +#else
1064 +typedef atomic64_t atomic64_unchecked_t;
1065 +#endif
1066 +
1067 #define ATOMIC64_INIT(i) { (i) }
1068
1069 static inline u64 atomic64_read(atomic64_t *v)
1070 @@ -254,6 +429,19 @@ static inline u64 atomic64_read(atomic64_t *v)
1071 return result;
1072 }
1073
1074 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1075 +{
1076 + u64 result;
1077 +
1078 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1079 +" ldrexd %0, %H0, [%1]"
1080 + : "=&r" (result)
1081 + : "r" (&v->counter), "Qo" (v->counter)
1082 + );
1083 +
1084 + return result;
1085 +}
1086 +
1087 static inline void atomic64_set(atomic64_t *v, u64 i)
1088 {
1089 u64 tmp;
1090 @@ -268,6 +456,20 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1091 : "cc");
1092 }
1093
1094 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1095 +{
1096 + u64 tmp;
1097 +
1098 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1099 +"1: ldrexd %0, %H0, [%2]\n"
1100 +" strexd %0, %3, %H3, [%2]\n"
1101 +" teq %0, #0\n"
1102 +" bne 1b"
1103 + : "=&r" (tmp), "=Qo" (v->counter)
1104 + : "r" (&v->counter), "r" (i)
1105 + : "cc");
1106 +}
1107 +
1108 static inline void atomic64_add(u64 i, atomic64_t *v)
1109 {
1110 u64 result;
1111 @@ -276,6 +478,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1112 __asm__ __volatile__("@ atomic64_add\n"
1113 "1: ldrexd %0, %H0, [%3]\n"
1114 " adds %0, %0, %4\n"
1115 +" adcs %H0, %H0, %H4\n"
1116 +
1117 +#ifdef CONFIG_PAX_REFCOUNT
1118 +" bvc 3f\n"
1119 +"2: bkpt 0xf103\n"
1120 +"3:\n"
1121 +#endif
1122 +
1123 +" strexd %1, %0, %H0, [%3]\n"
1124 +" teq %1, #0\n"
1125 +" bne 1b"
1126 +
1127 +#ifdef CONFIG_PAX_REFCOUNT
1128 +"\n4:\n"
1129 + _ASM_EXTABLE(2b, 4b)
1130 +#endif
1131 +
1132 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1133 + : "r" (&v->counter), "r" (i)
1134 + : "cc");
1135 +}
1136 +
1137 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1138 +{
1139 + u64 result;
1140 + unsigned long tmp;
1141 +
1142 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1143 +"1: ldrexd %0, %H0, [%3]\n"
1144 +" adds %0, %0, %4\n"
1145 " adc %H0, %H0, %H4\n"
1146 " strexd %1, %0, %H0, [%3]\n"
1147 " teq %1, #0\n"
1148 @@ -287,12 +519,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1149
1150 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1151 {
1152 - u64 result;
1153 - unsigned long tmp;
1154 + u64 result, tmp;
1155
1156 smp_mb();
1157
1158 __asm__ __volatile__("@ atomic64_add_return\n"
1159 +"1: ldrexd %1, %H1, [%3]\n"
1160 +" adds %0, %1, %4\n"
1161 +" adcs %H0, %H1, %H4\n"
1162 +
1163 +#ifdef CONFIG_PAX_REFCOUNT
1164 +" bvc 3f\n"
1165 +" mov %0, %1\n"
1166 +" mov %H0, %H1\n"
1167 +"2: bkpt 0xf103\n"
1168 +"3:\n"
1169 +#endif
1170 +
1171 +" strexd %1, %0, %H0, [%3]\n"
1172 +" teq %1, #0\n"
1173 +" bne 1b"
1174 +
1175 +#ifdef CONFIG_PAX_REFCOUNT
1176 +"\n4:\n"
1177 + _ASM_EXTABLE(2b, 4b)
1178 +#endif
1179 +
1180 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1181 + : "r" (&v->counter), "r" (i)
1182 + : "cc");
1183 +
1184 + smp_mb();
1185 +
1186 + return result;
1187 +}
1188 +
1189 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1190 +{
1191 + u64 result;
1192 + unsigned long tmp;
1193 +
1194 + smp_mb();
1195 +
1196 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1197 "1: ldrexd %0, %H0, [%3]\n"
1198 " adds %0, %0, %4\n"
1199 " adc %H0, %H0, %H4\n"
1200 @@ -316,6 +585,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1201 __asm__ __volatile__("@ atomic64_sub\n"
1202 "1: ldrexd %0, %H0, [%3]\n"
1203 " subs %0, %0, %4\n"
1204 +" sbcs %H0, %H0, %H4\n"
1205 +
1206 +#ifdef CONFIG_PAX_REFCOUNT
1207 +" bvc 3f\n"
1208 +"2: bkpt 0xf103\n"
1209 +"3:\n"
1210 +#endif
1211 +
1212 +" strexd %1, %0, %H0, [%3]\n"
1213 +" teq %1, #0\n"
1214 +" bne 1b"
1215 +
1216 +#ifdef CONFIG_PAX_REFCOUNT
1217 +"\n4:\n"
1218 + _ASM_EXTABLE(2b, 4b)
1219 +#endif
1220 +
1221 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1222 + : "r" (&v->counter), "r" (i)
1223 + : "cc");
1224 +}
1225 +
1226 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1227 +{
1228 + u64 result;
1229 + unsigned long tmp;
1230 +
1231 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1232 +"1: ldrexd %0, %H0, [%3]\n"
1233 +" subs %0, %0, %4\n"
1234 " sbc %H0, %H0, %H4\n"
1235 " strexd %1, %0, %H0, [%3]\n"
1236 " teq %1, #0\n"
1237 @@ -327,18 +626,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1238
1239 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1240 {
1241 - u64 result;
1242 - unsigned long tmp;
1243 + u64 result, tmp;
1244
1245 smp_mb();
1246
1247 __asm__ __volatile__("@ atomic64_sub_return\n"
1248 -"1: ldrexd %0, %H0, [%3]\n"
1249 -" subs %0, %0, %4\n"
1250 -" sbc %H0, %H0, %H4\n"
1251 +"1: ldrexd %1, %H1, [%3]\n"
1252 +" subs %0, %1, %4\n"
1253 +" sbc %H0, %H1, %H4\n"
1254 +
1255 +#ifdef CONFIG_PAX_REFCOUNT
1256 +" bvc 3f\n"
1257 +" mov %0, %1\n"
1258 +" mov %H0, %H1\n"
1259 +"2: bkpt 0xf103\n"
1260 +"3:\n"
1261 +#endif
1262 +
1263 " strexd %1, %0, %H0, [%3]\n"
1264 " teq %1, #0\n"
1265 " bne 1b"
1266 +
1267 +#ifdef CONFIG_PAX_REFCOUNT
1268 +"\n4:\n"
1269 + _ASM_EXTABLE(2b, 4b)
1270 +#endif
1271 +
1272 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1273 : "r" (&v->counter), "r" (i)
1274 : "cc");
1275 @@ -372,6 +685,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1276 return oldval;
1277 }
1278
1279 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1280 +{
1281 + u64 oldval;
1282 + unsigned long res;
1283 +
1284 + smp_mb();
1285 +
1286 + do {
1287 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1288 + "ldrexd %1, %H1, [%3]\n"
1289 + "mov %0, #0\n"
1290 + "teq %1, %4\n"
1291 + "teqeq %H1, %H4\n"
1292 + "strexdeq %0, %5, %H5, [%3]"
1293 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1294 + : "r" (&ptr->counter), "r" (old), "r" (new)
1295 + : "cc");
1296 + } while (res);
1297 +
1298 + smp_mb();
1299 +
1300 + return oldval;
1301 +}
1302 +
1303 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1304 {
1305 u64 result;
1306 @@ -395,21 +732,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1307
1308 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1309 {
1310 - u64 result;
1311 - unsigned long tmp;
1312 + u64 result, tmp;
1313
1314 smp_mb();
1315
1316 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1317 -"1: ldrexd %0, %H0, [%3]\n"
1318 -" subs %0, %0, #1\n"
1319 -" sbc %H0, %H0, #0\n"
1320 +"1: ldrexd %1, %H1, [%3]\n"
1321 +" subs %0, %1, #1\n"
1322 +" sbc %H0, %H1, #0\n"
1323 +
1324 +#ifdef CONFIG_PAX_REFCOUNT
1325 +" bvc 3f\n"
1326 +" mov %0, %1\n"
1327 +" mov %H0, %H1\n"
1328 +"2: bkpt 0xf103\n"
1329 +"3:\n"
1330 +#endif
1331 +
1332 " teq %H0, #0\n"
1333 -" bmi 2f\n"
1334 +" bmi 4f\n"
1335 " strexd %1, %0, %H0, [%3]\n"
1336 " teq %1, #0\n"
1337 " bne 1b\n"
1338 -"2:"
1339 +"4:\n"
1340 +
1341 +#ifdef CONFIG_PAX_REFCOUNT
1342 + _ASM_EXTABLE(2b, 4b)
1343 +#endif
1344 +
1345 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1346 : "r" (&v->counter)
1347 : "cc");
1348 @@ -432,13 +782,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1349 " teq %0, %5\n"
1350 " teqeq %H0, %H5\n"
1351 " moveq %1, #0\n"
1352 -" beq 2f\n"
1353 +" beq 4f\n"
1354 " adds %0, %0, %6\n"
1355 " adc %H0, %H0, %H6\n"
1356 +
1357 +#ifdef CONFIG_PAX_REFCOUNT
1358 +" bvc 3f\n"
1359 +"2: bkpt 0xf103\n"
1360 +"3:\n"
1361 +#endif
1362 +
1363 " strexd %2, %0, %H0, [%4]\n"
1364 " teq %2, #0\n"
1365 " bne 1b\n"
1366 -"2:"
1367 +"4:\n"
1368 +
1369 +#ifdef CONFIG_PAX_REFCOUNT
1370 + _ASM_EXTABLE(2b, 4b)
1371 +#endif
1372 +
1373 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1374 : "r" (&v->counter), "r" (u), "r" (a)
1375 : "cc");
1376 @@ -451,10 +813,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1377
1378 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1379 #define atomic64_inc(v) atomic64_add(1LL, (v))
1380 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1381 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1382 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1383 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1384 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1385 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1386 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1387 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1388 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1389 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1390 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1391 index 75fe66b..2255c86 100644
1392 --- a/arch/arm/include/asm/cache.h
1393 +++ b/arch/arm/include/asm/cache.h
1394 @@ -4,8 +4,10 @@
1395 #ifndef __ASMARM_CACHE_H
1396 #define __ASMARM_CACHE_H
1397
1398 +#include <linux/const.h>
1399 +
1400 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1401 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1402 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1403
1404 /*
1405 * Memory returned by kmalloc() may be used for DMA, so we must make
1406 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1407 index d5d8d5c..ad92c96 100644
1408 --- a/arch/arm/include/asm/cacheflush.h
1409 +++ b/arch/arm/include/asm/cacheflush.h
1410 @@ -108,7 +108,7 @@ struct cpu_cache_fns {
1411 void (*dma_unmap_area)(const void *, size_t, int);
1412
1413 void (*dma_flush_range)(const void *, const void *);
1414 -};
1415 +} __no_const;
1416
1417 /*
1418 * Select the calling method
1419 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1420 index 0e9ce8d..6ef1e03 100644
1421 --- a/arch/arm/include/asm/elf.h
1422 +++ b/arch/arm/include/asm/elf.h
1423 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1424 the loader. We need to make sure that it is out of the way of the program
1425 that it will "exec", and that there is sufficient room for the brk. */
1426
1427 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1428 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1429 +
1430 +#ifdef CONFIG_PAX_ASLR
1431 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1432 +
1433 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1434 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1435 +#endif
1436
1437 /* When the program starts, a1 contains a pointer to a function to be
1438 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1439 @@ -126,10 +133,6 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1440 extern void elf_set_personality(const struct elf32_hdr *);
1441 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1442
1443 -struct mm_struct;
1444 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1445 -#define arch_randomize_brk arch_randomize_brk
1446 -
1447 extern int vectors_user_mapping(void);
1448 #define arch_setup_additional_pages(bprm, uses_interp) vectors_user_mapping()
1449 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES
1450 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1451 index e51b1e8..32a3113 100644
1452 --- a/arch/arm/include/asm/kmap_types.h
1453 +++ b/arch/arm/include/asm/kmap_types.h
1454 @@ -21,6 +21,7 @@ enum km_type {
1455 KM_L1_CACHE,
1456 KM_L2_CACHE,
1457 KM_KDB,
1458 + KM_CLEARPAGE,
1459 KM_TYPE_NR
1460 };
1461
1462 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1463 index 53426c6..c7baff3 100644
1464 --- a/arch/arm/include/asm/outercache.h
1465 +++ b/arch/arm/include/asm/outercache.h
1466 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1467 #endif
1468 void (*set_debug)(unsigned long);
1469 void (*resume)(void);
1470 -};
1471 +} __no_const;
1472
1473 #ifdef CONFIG_OUTER_CACHE
1474
1475 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1476 index 97b440c..b7ff179 100644
1477 --- a/arch/arm/include/asm/page.h
1478 +++ b/arch/arm/include/asm/page.h
1479 @@ -123,7 +123,7 @@ struct cpu_user_fns {
1480 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1481 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1482 unsigned long vaddr, struct vm_area_struct *vma);
1483 -};
1484 +} __no_const;
1485
1486 #ifdef MULTI_USER
1487 extern struct cpu_user_fns cpu_user;
1488 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1489 index 943504f..bf8d667 100644
1490 --- a/arch/arm/include/asm/pgalloc.h
1491 +++ b/arch/arm/include/asm/pgalloc.h
1492 @@ -43,6 +43,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1493 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1494 }
1495
1496 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1497 +{
1498 + pud_populate(mm, pud, pmd);
1499 +}
1500 +
1501 #else /* !CONFIG_ARM_LPAE */
1502
1503 /*
1504 @@ -51,6 +56,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1505 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1506 #define pmd_free(mm, pmd) do { } while (0)
1507 #define pud_populate(mm,pmd,pte) BUG()
1508 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1509
1510 #endif /* CONFIG_ARM_LPAE */
1511
1512 diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
1513 index e4c96cc..1145653 100644
1514 --- a/arch/arm/include/asm/system.h
1515 +++ b/arch/arm/include/asm/system.h
1516 @@ -98,6 +98,8 @@ void hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int,
1517
1518 #define xchg(ptr,x) \
1519 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1520 +#define xchg_unchecked(ptr,x) \
1521 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1522
1523 extern asmlinkage void c_backtrace(unsigned long fp, int pmode);
1524
1525 @@ -534,6 +536,13 @@ static inline unsigned long long __cmpxchg64_mb(volatile void *ptr,
1526
1527 #endif /* __LINUX_ARM_ARCH__ >= 6 */
1528
1529 +#define _ASM_EXTABLE(from, to) \
1530 +" .pushsection __ex_table,\"a\"\n"\
1531 +" .align 3\n" \
1532 +" .long " #from ", " #to"\n" \
1533 +" .popsection"
1534 +
1535 +
1536 #endif /* __ASSEMBLY__ */
1537
1538 #define arch_align_stack(x) (x)
1539 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
1540 index d4c24d4..4ac53e8 100644
1541 --- a/arch/arm/include/asm/thread_info.h
1542 +++ b/arch/arm/include/asm/thread_info.h
1543 @@ -141,6 +141,12 @@ extern void vfp_flush_hwstate(struct thread_info *);
1544 #define TIF_NOTIFY_RESUME 2 /* callback before returning to user */
1545 #define TIF_SYSCALL_TRACE 8
1546 #define TIF_SYSCALL_AUDIT 9
1547 +
1548 +/* within 8 bits of TIF_SYSCALL_TRACE
1549 + to meet flexible second operand requirements
1550 +*/
1551 +#define TIF_GRSEC_SETXID 10
1552 +
1553 #define TIF_POLLING_NRFLAG 16
1554 #define TIF_USING_IWMMXT 17
1555 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
1556 @@ -156,9 +162,11 @@ extern void vfp_flush_hwstate(struct thread_info *);
1557 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
1558 #define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
1559 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
1560 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
1561
1562 /* Checks for any syscall work in entry-common.S */
1563 -#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
1564 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
1565 + _TIF_GRSEC_SETXID)
1566
1567 /*
1568 * Change these and you break ASM code in entry-common.S
1569 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
1570 index 2958976..12ccac4 100644
1571 --- a/arch/arm/include/asm/uaccess.h
1572 +++ b/arch/arm/include/asm/uaccess.h
1573 @@ -22,6 +22,8 @@
1574 #define VERIFY_READ 0
1575 #define VERIFY_WRITE 1
1576
1577 +extern void check_object_size(const void *ptr, unsigned long n, bool to);
1578 +
1579 /*
1580 * The exception table consists of pairs of addresses: the first is the
1581 * address of an instruction that is allowed to fault, and the second is
1582 @@ -387,8 +389,23 @@ do { \
1583
1584
1585 #ifdef CONFIG_MMU
1586 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
1587 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
1588 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
1589 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
1590 +
1591 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
1592 +{
1593 + if (!__builtin_constant_p(n))
1594 + check_object_size(to, n, false);
1595 + return ___copy_from_user(to, from, n);
1596 +}
1597 +
1598 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
1599 +{
1600 + if (!__builtin_constant_p(n))
1601 + check_object_size(from, n, true);
1602 + return ___copy_to_user(to, from, n);
1603 +}
1604 +
1605 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
1606 extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
1607 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
1608 @@ -403,6 +420,9 @@ extern unsigned long __must_check __strnlen_user(const char __user *s, long n);
1609
1610 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
1611 {
1612 + if ((long)n < 0)
1613 + return n;
1614 +
1615 if (access_ok(VERIFY_READ, from, n))
1616 n = __copy_from_user(to, from, n);
1617 else /* security hole - plug it */
1618 @@ -412,6 +432,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
1619
1620 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
1621 {
1622 + if ((long)n < 0)
1623 + return n;
1624 +
1625 if (access_ok(VERIFY_WRITE, to, n))
1626 n = __copy_to_user(to, from, n);
1627 return n;
1628 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
1629 index 5b0bce6..becd81c 100644
1630 --- a/arch/arm/kernel/armksyms.c
1631 +++ b/arch/arm/kernel/armksyms.c
1632 @@ -95,8 +95,8 @@ EXPORT_SYMBOL(__strncpy_from_user);
1633 #ifdef CONFIG_MMU
1634 EXPORT_SYMBOL(copy_page);
1635
1636 -EXPORT_SYMBOL(__copy_from_user);
1637 -EXPORT_SYMBOL(__copy_to_user);
1638 +EXPORT_SYMBOL(___copy_from_user);
1639 +EXPORT_SYMBOL(___copy_to_user);
1640 EXPORT_SYMBOL(__clear_user);
1641
1642 EXPORT_SYMBOL(__get_user_1);
1643 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
1644 index 971d65c..cc936fb 100644
1645 --- a/arch/arm/kernel/process.c
1646 +++ b/arch/arm/kernel/process.c
1647 @@ -28,7 +28,6 @@
1648 #include <linux/tick.h>
1649 #include <linux/utsname.h>
1650 #include <linux/uaccess.h>
1651 -#include <linux/random.h>
1652 #include <linux/hw_breakpoint.h>
1653 #include <linux/cpuidle.h>
1654
1655 @@ -273,9 +272,10 @@ void machine_power_off(void)
1656 machine_shutdown();
1657 if (pm_power_off)
1658 pm_power_off();
1659 + BUG();
1660 }
1661
1662 -void machine_restart(char *cmd)
1663 +__noreturn void machine_restart(char *cmd)
1664 {
1665 machine_shutdown();
1666
1667 @@ -517,12 +517,6 @@ unsigned long get_wchan(struct task_struct *p)
1668 return 0;
1669 }
1670
1671 -unsigned long arch_randomize_brk(struct mm_struct *mm)
1672 -{
1673 - unsigned long range_end = mm->brk + 0x02000000;
1674 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
1675 -}
1676 -
1677 #ifdef CONFIG_MMU
1678 /*
1679 * The vectors page is always readable from user space for the
1680 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
1681 index f5ce8ab..4b73893 100644
1682 --- a/arch/arm/kernel/ptrace.c
1683 +++ b/arch/arm/kernel/ptrace.c
1684 @@ -905,10 +905,19 @@ long arch_ptrace(struct task_struct *child, long request,
1685 return ret;
1686 }
1687
1688 +#ifdef CONFIG_GRKERNSEC_SETXID
1689 +extern void gr_delayed_cred_worker(void);
1690 +#endif
1691 +
1692 asmlinkage int syscall_trace(int why, struct pt_regs *regs, int scno)
1693 {
1694 unsigned long ip;
1695
1696 +#ifdef CONFIG_GRKERNSEC_SETXID
1697 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
1698 + gr_delayed_cred_worker();
1699 +#endif
1700 +
1701 if (why)
1702 audit_syscall_exit(regs);
1703 else
1704 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
1705 index a255c39..4a19b25 100644
1706 --- a/arch/arm/kernel/setup.c
1707 +++ b/arch/arm/kernel/setup.c
1708 @@ -109,13 +109,13 @@ struct processor processor __read_mostly;
1709 struct cpu_tlb_fns cpu_tlb __read_mostly;
1710 #endif
1711 #ifdef MULTI_USER
1712 -struct cpu_user_fns cpu_user __read_mostly;
1713 +struct cpu_user_fns cpu_user __read_only;
1714 #endif
1715 #ifdef MULTI_CACHE
1716 -struct cpu_cache_fns cpu_cache __read_mostly;
1717 +struct cpu_cache_fns cpu_cache __read_only;
1718 #endif
1719 #ifdef CONFIG_OUTER_CACHE
1720 -struct outer_cache_fns outer_cache __read_mostly;
1721 +struct outer_cache_fns outer_cache __read_only;
1722 EXPORT_SYMBOL(outer_cache);
1723 #endif
1724
1725 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
1726 index f84dfe6..13e94f7 100644
1727 --- a/arch/arm/kernel/traps.c
1728 +++ b/arch/arm/kernel/traps.c
1729 @@ -259,6 +259,8 @@ static int __die(const char *str, int err, struct thread_info *thread, struct pt
1730
1731 static DEFINE_RAW_SPINLOCK(die_lock);
1732
1733 +extern void gr_handle_kernel_exploit(void);
1734 +
1735 /*
1736 * This function is protected against re-entrancy.
1737 */
1738 @@ -291,6 +293,9 @@ void die(const char *str, struct pt_regs *regs, int err)
1739 panic("Fatal exception in interrupt");
1740 if (panic_on_oops)
1741 panic("Fatal exception");
1742 +
1743 + gr_handle_kernel_exploit();
1744 +
1745 if (ret != NOTIFY_STOP)
1746 do_exit(SIGSEGV);
1747 }
1748 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
1749 index 66a477a..bee61d3 100644
1750 --- a/arch/arm/lib/copy_from_user.S
1751 +++ b/arch/arm/lib/copy_from_user.S
1752 @@ -16,7 +16,7 @@
1753 /*
1754 * Prototype:
1755 *
1756 - * size_t __copy_from_user(void *to, const void *from, size_t n)
1757 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
1758 *
1759 * Purpose:
1760 *
1761 @@ -84,11 +84,11 @@
1762
1763 .text
1764
1765 -ENTRY(__copy_from_user)
1766 +ENTRY(___copy_from_user)
1767
1768 #include "copy_template.S"
1769
1770 -ENDPROC(__copy_from_user)
1771 +ENDPROC(___copy_from_user)
1772
1773 .pushsection .fixup,"ax"
1774 .align 0
1775 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
1776 index 6ee2f67..d1cce76 100644
1777 --- a/arch/arm/lib/copy_page.S
1778 +++ b/arch/arm/lib/copy_page.S
1779 @@ -10,6 +10,7 @@
1780 * ASM optimised string functions
1781 */
1782 #include <linux/linkage.h>
1783 +#include <linux/const.h>
1784 #include <asm/assembler.h>
1785 #include <asm/asm-offsets.h>
1786 #include <asm/cache.h>
1787 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
1788 index d066df6..df28194 100644
1789 --- a/arch/arm/lib/copy_to_user.S
1790 +++ b/arch/arm/lib/copy_to_user.S
1791 @@ -16,7 +16,7 @@
1792 /*
1793 * Prototype:
1794 *
1795 - * size_t __copy_to_user(void *to, const void *from, size_t n)
1796 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
1797 *
1798 * Purpose:
1799 *
1800 @@ -88,11 +88,11 @@
1801 .text
1802
1803 ENTRY(__copy_to_user_std)
1804 -WEAK(__copy_to_user)
1805 +WEAK(___copy_to_user)
1806
1807 #include "copy_template.S"
1808
1809 -ENDPROC(__copy_to_user)
1810 +ENDPROC(___copy_to_user)
1811 ENDPROC(__copy_to_user_std)
1812
1813 .pushsection .fixup,"ax"
1814 diff --git a/arch/arm/lib/uaccess.S b/arch/arm/lib/uaccess.S
1815 index 5c908b1..e712687 100644
1816 --- a/arch/arm/lib/uaccess.S
1817 +++ b/arch/arm/lib/uaccess.S
1818 @@ -20,7 +20,7 @@
1819
1820 #define PAGE_SHIFT 12
1821
1822 -/* Prototype: int __copy_to_user(void *to, const char *from, size_t n)
1823 +/* Prototype: int ___copy_to_user(void *to, const char *from, size_t n)
1824 * Purpose : copy a block to user memory from kernel memory
1825 * Params : to - user memory
1826 * : from - kernel memory
1827 @@ -40,7 +40,7 @@ USER( TUSER( strgtb) r3, [r0], #1) @ May fault
1828 sub r2, r2, ip
1829 b .Lc2u_dest_aligned
1830
1831 -ENTRY(__copy_to_user)
1832 +ENTRY(___copy_to_user)
1833 stmfd sp!, {r2, r4 - r7, lr}
1834 cmp r2, #4
1835 blt .Lc2u_not_enough
1836 @@ -278,14 +278,14 @@ USER( TUSER( strgeb) r3, [r0], #1) @ May fault
1837 ldrgtb r3, [r1], #0
1838 USER( TUSER( strgtb) r3, [r0], #1) @ May fault
1839 b .Lc2u_finished
1840 -ENDPROC(__copy_to_user)
1841 +ENDPROC(___copy_to_user)
1842
1843 .pushsection .fixup,"ax"
1844 .align 0
1845 9001: ldmfd sp!, {r0, r4 - r7, pc}
1846 .popsection
1847
1848 -/* Prototype: unsigned long __copy_from_user(void *to,const void *from,unsigned long n);
1849 +/* Prototype: unsigned long ___copy_from_user(void *to,const void *from,unsigned long n);
1850 * Purpose : copy a block from user memory to kernel memory
1851 * Params : to - kernel memory
1852 * : from - user memory
1853 @@ -304,7 +304,7 @@ USER( TUSER( ldrgtb) r3, [r1], #1) @ May fault
1854 sub r2, r2, ip
1855 b .Lcfu_dest_aligned
1856
1857 -ENTRY(__copy_from_user)
1858 +ENTRY(___copy_from_user)
1859 stmfd sp!, {r0, r2, r4 - r7, lr}
1860 cmp r2, #4
1861 blt .Lcfu_not_enough
1862 @@ -544,7 +544,7 @@ USER( TUSER( ldrgeb) r3, [r1], #1) @ May fault
1863 USER( TUSER( ldrgtb) r3, [r1], #1) @ May fault
1864 strgtb r3, [r0], #1
1865 b .Lcfu_finished
1866 -ENDPROC(__copy_from_user)
1867 +ENDPROC(___copy_from_user)
1868
1869 .pushsection .fixup,"ax"
1870 .align 0
1871 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
1872 index 025f742..8432b08 100644
1873 --- a/arch/arm/lib/uaccess_with_memcpy.c
1874 +++ b/arch/arm/lib/uaccess_with_memcpy.c
1875 @@ -104,7 +104,7 @@ out:
1876 }
1877
1878 unsigned long
1879 -__copy_to_user(void __user *to, const void *from, unsigned long n)
1880 +___copy_to_user(void __user *to, const void *from, unsigned long n)
1881 {
1882 /*
1883 * This test is stubbed out of the main function above to keep
1884 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
1885 index 6722627..8f97548c 100644
1886 --- a/arch/arm/mach-omap2/board-n8x0.c
1887 +++ b/arch/arm/mach-omap2/board-n8x0.c
1888 @@ -597,7 +597,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
1889 }
1890 #endif
1891
1892 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
1893 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
1894 .late_init = n8x0_menelaus_late_init,
1895 };
1896
1897 diff --git a/arch/arm/mach-ux500/mbox-db5500.c b/arch/arm/mach-ux500/mbox-db5500.c
1898 index 2b2d51c..0127490 100644
1899 --- a/arch/arm/mach-ux500/mbox-db5500.c
1900 +++ b/arch/arm/mach-ux500/mbox-db5500.c
1901 @@ -168,7 +168,7 @@ static ssize_t mbox_read_fifo(struct device *dev,
1902 return sprintf(buf, "0x%X\n", mbox_value);
1903 }
1904
1905 -static DEVICE_ATTR(fifo, S_IWUGO | S_IRUGO, mbox_read_fifo, mbox_write_fifo);
1906 +static DEVICE_ATTR(fifo, S_IWUSR | S_IRUGO, mbox_read_fifo, mbox_write_fifo);
1907
1908 static int mbox_show(struct seq_file *s, void *data)
1909 {
1910 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
1911 index 90e366a..1b92505 100644
1912 --- a/arch/arm/mm/fault.c
1913 +++ b/arch/arm/mm/fault.c
1914 @@ -172,6 +172,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
1915 }
1916 #endif
1917
1918 +#ifdef CONFIG_PAX_PAGEEXEC
1919 + if (fsr & FSR_LNX_PF) {
1920 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
1921 + do_group_exit(SIGKILL);
1922 + }
1923 +#endif
1924 +
1925 tsk->thread.address = addr;
1926 tsk->thread.error_code = fsr;
1927 tsk->thread.trap_no = 14;
1928 @@ -395,6 +402,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
1929 }
1930 #endif /* CONFIG_MMU */
1931
1932 +#ifdef CONFIG_PAX_PAGEEXEC
1933 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
1934 +{
1935 + long i;
1936 +
1937 + printk(KERN_ERR "PAX: bytes at PC: ");
1938 + for (i = 0; i < 20; i++) {
1939 + unsigned char c;
1940 + if (get_user(c, (__force unsigned char __user *)pc+i))
1941 + printk(KERN_CONT "?? ");
1942 + else
1943 + printk(KERN_CONT "%02x ", c);
1944 + }
1945 + printk("\n");
1946 +
1947 + printk(KERN_ERR "PAX: bytes at SP-4: ");
1948 + for (i = -1; i < 20; i++) {
1949 + unsigned long c;
1950 + if (get_user(c, (__force unsigned long __user *)sp+i))
1951 + printk(KERN_CONT "???????? ");
1952 + else
1953 + printk(KERN_CONT "%08lx ", c);
1954 + }
1955 + printk("\n");
1956 +}
1957 +#endif
1958 +
1959 /*
1960 * First Level Translation Fault Handler
1961 *
1962 @@ -575,6 +609,20 @@ do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
1963 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
1964 struct siginfo info;
1965
1966 +#ifdef CONFIG_PAX_REFCOUNT
1967 + if (fsr_fs(ifsr) == 2) {
1968 + unsigned int bkpt;
1969 +
1970 + if (!probe_kernel_address((unsigned int *)addr, bkpt) && bkpt == 0xe12f1073) {
1971 + current->thread.error_code = ifsr;
1972 + current->thread.trap_no = 0;
1973 + pax_report_refcount_overflow(regs);
1974 + fixup_exception(regs);
1975 + return;
1976 + }
1977 + }
1978 +#endif
1979 +
1980 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
1981 return;
1982
1983 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
1984 index ce8cb19..3ec539d 100644
1985 --- a/arch/arm/mm/mmap.c
1986 +++ b/arch/arm/mm/mmap.c
1987 @@ -93,6 +93,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
1988 if (len > TASK_SIZE)
1989 return -ENOMEM;
1990
1991 +#ifdef CONFIG_PAX_RANDMMAP
1992 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
1993 +#endif
1994 +
1995 if (addr) {
1996 if (do_align)
1997 addr = COLOUR_ALIGN(addr, pgoff);
1998 @@ -100,15 +104,14 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
1999 addr = PAGE_ALIGN(addr);
2000
2001 vma = find_vma(mm, addr);
2002 - if (TASK_SIZE - len >= addr &&
2003 - (!vma || addr + len <= vma->vm_start))
2004 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len))
2005 return addr;
2006 }
2007 if (len > mm->cached_hole_size) {
2008 - start_addr = addr = mm->free_area_cache;
2009 + start_addr = addr = mm->free_area_cache;
2010 } else {
2011 - start_addr = addr = mm->mmap_base;
2012 - mm->cached_hole_size = 0;
2013 + start_addr = addr = mm->mmap_base;
2014 + mm->cached_hole_size = 0;
2015 }
2016
2017 full_search:
2018 @@ -124,14 +127,14 @@ full_search:
2019 * Start a new search - just in case we missed
2020 * some holes.
2021 */
2022 - if (start_addr != TASK_UNMAPPED_BASE) {
2023 - start_addr = addr = TASK_UNMAPPED_BASE;
2024 + if (start_addr != mm->mmap_base) {
2025 + start_addr = addr = mm->mmap_base;
2026 mm->cached_hole_size = 0;
2027 goto full_search;
2028 }
2029 return -ENOMEM;
2030 }
2031 - if (!vma || addr + len <= vma->vm_start) {
2032 + if (check_heap_stack_gap(vma, addr, len)) {
2033 /*
2034 * Remember the place where we stopped the search:
2035 */
2036 @@ -266,10 +269,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
2037
2038 if (mmap_is_legacy()) {
2039 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
2040 +
2041 +#ifdef CONFIG_PAX_RANDMMAP
2042 + if (mm->pax_flags & MF_PAX_RANDMMAP)
2043 + mm->mmap_base += mm->delta_mmap;
2044 +#endif
2045 +
2046 mm->get_unmapped_area = arch_get_unmapped_area;
2047 mm->unmap_area = arch_unmap_area;
2048 } else {
2049 mm->mmap_base = mmap_base(random_factor);
2050 +
2051 +#ifdef CONFIG_PAX_RANDMMAP
2052 + if (mm->pax_flags & MF_PAX_RANDMMAP)
2053 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
2054 +#endif
2055 +
2056 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
2057 mm->unmap_area = arch_unmap_area_topdown;
2058 }
2059 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
2060 index 71a6827..e7fbc23 100644
2061 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
2062 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
2063 @@ -43,7 +43,7 @@ struct samsung_dma_ops {
2064 int (*started)(unsigned ch);
2065 int (*flush)(unsigned ch);
2066 int (*stop)(unsigned ch);
2067 -};
2068 +} __no_const;
2069
2070 extern void *samsung_dmadev_get_ops(void);
2071 extern void *s3c_dma_get_ops(void);
2072 diff --git a/arch/arm/plat-samsung/include/plat/ehci.h b/arch/arm/plat-samsung/include/plat/ehci.h
2073 index 5f28cae..3d23723 100644
2074 --- a/arch/arm/plat-samsung/include/plat/ehci.h
2075 +++ b/arch/arm/plat-samsung/include/plat/ehci.h
2076 @@ -14,7 +14,7 @@
2077 struct s5p_ehci_platdata {
2078 int (*phy_init)(struct platform_device *pdev, int type);
2079 int (*phy_exit)(struct platform_device *pdev, int type);
2080 -};
2081 +} __no_const;
2082
2083 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
2084
2085 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
2086 index c3a58a1..78fbf54 100644
2087 --- a/arch/avr32/include/asm/cache.h
2088 +++ b/arch/avr32/include/asm/cache.h
2089 @@ -1,8 +1,10 @@
2090 #ifndef __ASM_AVR32_CACHE_H
2091 #define __ASM_AVR32_CACHE_H
2092
2093 +#include <linux/const.h>
2094 +
2095 #define L1_CACHE_SHIFT 5
2096 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
2097 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
2098
2099 /*
2100 * Memory returned by kmalloc() may be used for DMA, so we must make
2101 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
2102 index 3b3159b..425ea94 100644
2103 --- a/arch/avr32/include/asm/elf.h
2104 +++ b/arch/avr32/include/asm/elf.h
2105 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
2106 the loader. We need to make sure that it is out of the way of the program
2107 that it will "exec", and that there is sufficient room for the brk. */
2108
2109 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
2110 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
2111
2112 +#ifdef CONFIG_PAX_ASLR
2113 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
2114 +
2115 +#define PAX_DELTA_MMAP_LEN 15
2116 +#define PAX_DELTA_STACK_LEN 15
2117 +#endif
2118
2119 /* This yields a mask that user programs can use to figure out what
2120 instruction set this CPU supports. This could be done in user space,
2121 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
2122 index b7f5c68..556135c 100644
2123 --- a/arch/avr32/include/asm/kmap_types.h
2124 +++ b/arch/avr32/include/asm/kmap_types.h
2125 @@ -22,7 +22,8 @@ D(10) KM_IRQ0,
2126 D(11) KM_IRQ1,
2127 D(12) KM_SOFTIRQ0,
2128 D(13) KM_SOFTIRQ1,
2129 -D(14) KM_TYPE_NR
2130 +D(14) KM_CLEARPAGE,
2131 +D(15) KM_TYPE_NR
2132 };
2133
2134 #undef D
2135 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
2136 index f7040a1..db9f300 100644
2137 --- a/arch/avr32/mm/fault.c
2138 +++ b/arch/avr32/mm/fault.c
2139 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
2140
2141 int exception_trace = 1;
2142
2143 +#ifdef CONFIG_PAX_PAGEEXEC
2144 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
2145 +{
2146 + unsigned long i;
2147 +
2148 + printk(KERN_ERR "PAX: bytes at PC: ");
2149 + for (i = 0; i < 20; i++) {
2150 + unsigned char c;
2151 + if (get_user(c, (unsigned char *)pc+i))
2152 + printk(KERN_CONT "???????? ");
2153 + else
2154 + printk(KERN_CONT "%02x ", c);
2155 + }
2156 + printk("\n");
2157 +}
2158 +#endif
2159 +
2160 /*
2161 * This routine handles page faults. It determines the address and the
2162 * problem, and then passes it off to one of the appropriate routines.
2163 @@ -156,6 +173,16 @@ bad_area:
2164 up_read(&mm->mmap_sem);
2165
2166 if (user_mode(regs)) {
2167 +
2168 +#ifdef CONFIG_PAX_PAGEEXEC
2169 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
2170 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
2171 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
2172 + do_group_exit(SIGKILL);
2173 + }
2174 + }
2175 +#endif
2176 +
2177 if (exception_trace && printk_ratelimit())
2178 printk("%s%s[%d]: segfault at %08lx pc %08lx "
2179 "sp %08lx ecr %lu\n",
2180 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
2181 index 568885a..f8008df 100644
2182 --- a/arch/blackfin/include/asm/cache.h
2183 +++ b/arch/blackfin/include/asm/cache.h
2184 @@ -7,6 +7,7 @@
2185 #ifndef __ARCH_BLACKFIN_CACHE_H
2186 #define __ARCH_BLACKFIN_CACHE_H
2187
2188 +#include <linux/const.h>
2189 #include <linux/linkage.h> /* for asmlinkage */
2190
2191 /*
2192 @@ -14,7 +15,7 @@
2193 * Blackfin loads 32 bytes for cache
2194 */
2195 #define L1_CACHE_SHIFT 5
2196 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
2197 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
2198 #define SMP_CACHE_BYTES L1_CACHE_BYTES
2199
2200 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
2201 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
2202 index aea2718..3639a60 100644
2203 --- a/arch/cris/include/arch-v10/arch/cache.h
2204 +++ b/arch/cris/include/arch-v10/arch/cache.h
2205 @@ -1,8 +1,9 @@
2206 #ifndef _ASM_ARCH_CACHE_H
2207 #define _ASM_ARCH_CACHE_H
2208
2209 +#include <linux/const.h>
2210 /* Etrax 100LX have 32-byte cache-lines. */
2211 -#define L1_CACHE_BYTES 32
2212 #define L1_CACHE_SHIFT 5
2213 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
2214
2215 #endif /* _ASM_ARCH_CACHE_H */
2216 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
2217 index 1de779f..336fad3 100644
2218 --- a/arch/cris/include/arch-v32/arch/cache.h
2219 +++ b/arch/cris/include/arch-v32/arch/cache.h
2220 @@ -1,11 +1,12 @@
2221 #ifndef _ASM_CRIS_ARCH_CACHE_H
2222 #define _ASM_CRIS_ARCH_CACHE_H
2223
2224 +#include <linux/const.h>
2225 #include <arch/hwregs/dma.h>
2226
2227 /* A cache-line is 32 bytes. */
2228 -#define L1_CACHE_BYTES 32
2229 #define L1_CACHE_SHIFT 5
2230 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
2231
2232 #define __read_mostly __attribute__((__section__(".data.read_mostly")))
2233
2234 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
2235 index 0d8a7d6..d0c9ff5 100644
2236 --- a/arch/frv/include/asm/atomic.h
2237 +++ b/arch/frv/include/asm/atomic.h
2238 @@ -241,6 +241,16 @@ extern uint32_t __xchg_32(uint32_t i, volatile void *v);
2239 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
2240 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
2241
2242 +#define atomic64_read_unchecked(v) atomic64_read(v)
2243 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
2244 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
2245 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
2246 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
2247 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
2248 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
2249 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
2250 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
2251 +
2252 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
2253 {
2254 int c, old;
2255 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
2256 index 2797163..c2a401d 100644
2257 --- a/arch/frv/include/asm/cache.h
2258 +++ b/arch/frv/include/asm/cache.h
2259 @@ -12,10 +12,11 @@
2260 #ifndef __ASM_CACHE_H
2261 #define __ASM_CACHE_H
2262
2263 +#include <linux/const.h>
2264
2265 /* bytes per L1 cache line */
2266 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
2267 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
2268 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
2269
2270 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
2271 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
2272 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
2273 index f8e16b2..c73ff79 100644
2274 --- a/arch/frv/include/asm/kmap_types.h
2275 +++ b/arch/frv/include/asm/kmap_types.h
2276 @@ -23,6 +23,7 @@ enum km_type {
2277 KM_IRQ1,
2278 KM_SOFTIRQ0,
2279 KM_SOFTIRQ1,
2280 + KM_CLEARPAGE,
2281 KM_TYPE_NR
2282 };
2283
2284 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
2285 index 385fd30..6c3d97e 100644
2286 --- a/arch/frv/mm/elf-fdpic.c
2287 +++ b/arch/frv/mm/elf-fdpic.c
2288 @@ -73,8 +73,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
2289 if (addr) {
2290 addr = PAGE_ALIGN(addr);
2291 vma = find_vma(current->mm, addr);
2292 - if (TASK_SIZE - len >= addr &&
2293 - (!vma || addr + len <= vma->vm_start))
2294 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len))
2295 goto success;
2296 }
2297
2298 @@ -89,7 +88,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
2299 for (; vma; vma = vma->vm_next) {
2300 if (addr > limit)
2301 break;
2302 - if (addr + len <= vma->vm_start)
2303 + if (check_heap_stack_gap(vma, addr, len))
2304 goto success;
2305 addr = vma->vm_end;
2306 }
2307 @@ -104,7 +103,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
2308 for (; vma; vma = vma->vm_next) {
2309 if (addr > limit)
2310 break;
2311 - if (addr + len <= vma->vm_start)
2312 + if (check_heap_stack_gap(vma, addr, len))
2313 goto success;
2314 addr = vma->vm_end;
2315 }
2316 diff --git a/arch/h8300/include/asm/cache.h b/arch/h8300/include/asm/cache.h
2317 index c635028..6d9445a 100644
2318 --- a/arch/h8300/include/asm/cache.h
2319 +++ b/arch/h8300/include/asm/cache.h
2320 @@ -1,8 +1,10 @@
2321 #ifndef __ARCH_H8300_CACHE_H
2322 #define __ARCH_H8300_CACHE_H
2323
2324 +#include <linux/const.h>
2325 +
2326 /* bytes per L1 cache line */
2327 -#define L1_CACHE_BYTES 4
2328 +#define L1_CACHE_BYTES _AC(4,UL)
2329
2330 /* m68k-elf-gcc 2.95.2 doesn't like these */
2331
2332 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
2333 index 0f01de2..d37d309 100644
2334 --- a/arch/hexagon/include/asm/cache.h
2335 +++ b/arch/hexagon/include/asm/cache.h
2336 @@ -21,9 +21,11 @@
2337 #ifndef __ASM_CACHE_H
2338 #define __ASM_CACHE_H
2339
2340 +#include <linux/const.h>
2341 +
2342 /* Bytes per L1 cache line */
2343 -#define L1_CACHE_SHIFT (5)
2344 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
2345 +#define L1_CACHE_SHIFT 5
2346 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
2347
2348 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
2349 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
2350 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
2351 index 3fad89e..3047da5 100644
2352 --- a/arch/ia64/include/asm/atomic.h
2353 +++ b/arch/ia64/include/asm/atomic.h
2354 @@ -209,6 +209,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
2355 #define atomic64_inc(v) atomic64_add(1, (v))
2356 #define atomic64_dec(v) atomic64_sub(1, (v))
2357
2358 +#define atomic64_read_unchecked(v) atomic64_read(v)
2359 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
2360 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
2361 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
2362 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
2363 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
2364 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
2365 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
2366 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
2367 +
2368 /* Atomic operations are already serializing */
2369 #define smp_mb__before_atomic_dec() barrier()
2370 #define smp_mb__after_atomic_dec() barrier()
2371 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
2372 index 988254a..e1ee885 100644
2373 --- a/arch/ia64/include/asm/cache.h
2374 +++ b/arch/ia64/include/asm/cache.h
2375 @@ -1,6 +1,7 @@
2376 #ifndef _ASM_IA64_CACHE_H
2377 #define _ASM_IA64_CACHE_H
2378
2379 +#include <linux/const.h>
2380
2381 /*
2382 * Copyright (C) 1998-2000 Hewlett-Packard Co
2383 @@ -9,7 +10,7 @@
2384
2385 /* Bytes per L1 (data) cache line. */
2386 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
2387 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
2388 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
2389
2390 #ifdef CONFIG_SMP
2391 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
2392 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
2393 index b5298eb..67c6e62 100644
2394 --- a/arch/ia64/include/asm/elf.h
2395 +++ b/arch/ia64/include/asm/elf.h
2396 @@ -42,6 +42,13 @@
2397 */
2398 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
2399
2400 +#ifdef CONFIG_PAX_ASLR
2401 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
2402 +
2403 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
2404 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
2405 +#endif
2406 +
2407 #define PT_IA_64_UNWIND 0x70000001
2408
2409 /* IA-64 relocations: */
2410 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
2411 index 96a8d92..617a1cf 100644
2412 --- a/arch/ia64/include/asm/pgalloc.h
2413 +++ b/arch/ia64/include/asm/pgalloc.h
2414 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
2415 pgd_val(*pgd_entry) = __pa(pud);
2416 }
2417
2418 +static inline void
2419 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
2420 +{
2421 + pgd_populate(mm, pgd_entry, pud);
2422 +}
2423 +
2424 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
2425 {
2426 return quicklist_alloc(0, GFP_KERNEL, NULL);
2427 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
2428 pud_val(*pud_entry) = __pa(pmd);
2429 }
2430
2431 +static inline void
2432 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
2433 +{
2434 + pud_populate(mm, pud_entry, pmd);
2435 +}
2436 +
2437 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
2438 {
2439 return quicklist_alloc(0, GFP_KERNEL, NULL);
2440 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
2441 index 1a97af3..7529d31 100644
2442 --- a/arch/ia64/include/asm/pgtable.h
2443 +++ b/arch/ia64/include/asm/pgtable.h
2444 @@ -12,7 +12,7 @@
2445 * David Mosberger-Tang <davidm@hpl.hp.com>
2446 */
2447
2448 -
2449 +#include <linux/const.h>
2450 #include <asm/mman.h>
2451 #include <asm/page.h>
2452 #include <asm/processor.h>
2453 @@ -143,6 +143,17 @@
2454 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
2455 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
2456 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
2457 +
2458 +#ifdef CONFIG_PAX_PAGEEXEC
2459 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
2460 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
2461 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
2462 +#else
2463 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
2464 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
2465 +# define PAGE_COPY_NOEXEC PAGE_COPY
2466 +#endif
2467 +
2468 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
2469 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
2470 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
2471 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
2472 index b77768d..e0795eb 100644
2473 --- a/arch/ia64/include/asm/spinlock.h
2474 +++ b/arch/ia64/include/asm/spinlock.h
2475 @@ -72,7 +72,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
2476 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
2477
2478 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
2479 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
2480 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
2481 }
2482
2483 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
2484 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
2485 index 449c8c0..432a3d2 100644
2486 --- a/arch/ia64/include/asm/uaccess.h
2487 +++ b/arch/ia64/include/asm/uaccess.h
2488 @@ -257,7 +257,7 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
2489 const void *__cu_from = (from); \
2490 long __cu_len = (n); \
2491 \
2492 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
2493 + if (__cu_len > 0 && __cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) \
2494 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
2495 __cu_len; \
2496 })
2497 @@ -269,7 +269,7 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
2498 long __cu_len = (n); \
2499 \
2500 __chk_user_ptr(__cu_from); \
2501 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
2502 + if (__cu_len > 0 && __cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) \
2503 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
2504 __cu_len; \
2505 })
2506 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
2507 index 24603be..948052d 100644
2508 --- a/arch/ia64/kernel/module.c
2509 +++ b/arch/ia64/kernel/module.c
2510 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
2511 void
2512 module_free (struct module *mod, void *module_region)
2513 {
2514 - if (mod && mod->arch.init_unw_table &&
2515 - module_region == mod->module_init) {
2516 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
2517 unw_remove_unwind_table(mod->arch.init_unw_table);
2518 mod->arch.init_unw_table = NULL;
2519 }
2520 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
2521 }
2522
2523 static inline int
2524 +in_init_rx (const struct module *mod, uint64_t addr)
2525 +{
2526 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
2527 +}
2528 +
2529 +static inline int
2530 +in_init_rw (const struct module *mod, uint64_t addr)
2531 +{
2532 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
2533 +}
2534 +
2535 +static inline int
2536 in_init (const struct module *mod, uint64_t addr)
2537 {
2538 - return addr - (uint64_t) mod->module_init < mod->init_size;
2539 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
2540 +}
2541 +
2542 +static inline int
2543 +in_core_rx (const struct module *mod, uint64_t addr)
2544 +{
2545 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
2546 +}
2547 +
2548 +static inline int
2549 +in_core_rw (const struct module *mod, uint64_t addr)
2550 +{
2551 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
2552 }
2553
2554 static inline int
2555 in_core (const struct module *mod, uint64_t addr)
2556 {
2557 - return addr - (uint64_t) mod->module_core < mod->core_size;
2558 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
2559 }
2560
2561 static inline int
2562 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
2563 break;
2564
2565 case RV_BDREL:
2566 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
2567 + if (in_init_rx(mod, val))
2568 + val -= (uint64_t) mod->module_init_rx;
2569 + else if (in_init_rw(mod, val))
2570 + val -= (uint64_t) mod->module_init_rw;
2571 + else if (in_core_rx(mod, val))
2572 + val -= (uint64_t) mod->module_core_rx;
2573 + else if (in_core_rw(mod, val))
2574 + val -= (uint64_t) mod->module_core_rw;
2575 break;
2576
2577 case RV_LTV:
2578 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
2579 * addresses have been selected...
2580 */
2581 uint64_t gp;
2582 - if (mod->core_size > MAX_LTOFF)
2583 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
2584 /*
2585 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
2586 * at the end of the module.
2587 */
2588 - gp = mod->core_size - MAX_LTOFF / 2;
2589 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
2590 else
2591 - gp = mod->core_size / 2;
2592 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
2593 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
2594 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
2595 mod->arch.gp = gp;
2596 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
2597 }
2598 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
2599 index 609d500..7dde2a8 100644
2600 --- a/arch/ia64/kernel/sys_ia64.c
2601 +++ b/arch/ia64/kernel/sys_ia64.c
2602 @@ -43,6 +43,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
2603 if (REGION_NUMBER(addr) == RGN_HPAGE)
2604 addr = 0;
2605 #endif
2606 +
2607 +#ifdef CONFIG_PAX_RANDMMAP
2608 + if (mm->pax_flags & MF_PAX_RANDMMAP)
2609 + addr = mm->free_area_cache;
2610 + else
2611 +#endif
2612 +
2613 if (!addr)
2614 addr = mm->free_area_cache;
2615
2616 @@ -61,14 +68,14 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
2617 for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
2618 /* At this point: (!vma || addr < vma->vm_end). */
2619 if (TASK_SIZE - len < addr || RGN_MAP_LIMIT - len < REGION_OFFSET(addr)) {
2620 - if (start_addr != TASK_UNMAPPED_BASE) {
2621 + if (start_addr != mm->mmap_base) {
2622 /* Start a new search --- just in case we missed some holes. */
2623 - addr = TASK_UNMAPPED_BASE;
2624 + addr = mm->mmap_base;
2625 goto full_search;
2626 }
2627 return -ENOMEM;
2628 }
2629 - if (!vma || addr + len <= vma->vm_start) {
2630 + if (check_heap_stack_gap(vma, addr, len)) {
2631 /* Remember the address where we stopped this search: */
2632 mm->free_area_cache = addr + len;
2633 return addr;
2634 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
2635 index 53c0ba0..2accdde 100644
2636 --- a/arch/ia64/kernel/vmlinux.lds.S
2637 +++ b/arch/ia64/kernel/vmlinux.lds.S
2638 @@ -199,7 +199,7 @@ SECTIONS {
2639 /* Per-cpu data: */
2640 . = ALIGN(PERCPU_PAGE_SIZE);
2641 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
2642 - __phys_per_cpu_start = __per_cpu_load;
2643 + __phys_per_cpu_start = per_cpu_load;
2644 /*
2645 * ensure percpu data fits
2646 * into percpu page size
2647 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
2648 index 20b3593..1ce77f0 100644
2649 --- a/arch/ia64/mm/fault.c
2650 +++ b/arch/ia64/mm/fault.c
2651 @@ -73,6 +73,23 @@ mapped_kernel_page_is_present (unsigned long address)
2652 return pte_present(pte);
2653 }
2654
2655 +#ifdef CONFIG_PAX_PAGEEXEC
2656 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
2657 +{
2658 + unsigned long i;
2659 +
2660 + printk(KERN_ERR "PAX: bytes at PC: ");
2661 + for (i = 0; i < 8; i++) {
2662 + unsigned int c;
2663 + if (get_user(c, (unsigned int *)pc+i))
2664 + printk(KERN_CONT "???????? ");
2665 + else
2666 + printk(KERN_CONT "%08x ", c);
2667 + }
2668 + printk("\n");
2669 +}
2670 +#endif
2671 +
2672 void __kprobes
2673 ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *regs)
2674 {
2675 @@ -146,9 +163,23 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
2676 mask = ( (((isr >> IA64_ISR_X_BIT) & 1UL) << VM_EXEC_BIT)
2677 | (((isr >> IA64_ISR_W_BIT) & 1UL) << VM_WRITE_BIT));
2678
2679 - if ((vma->vm_flags & mask) != mask)
2680 + if ((vma->vm_flags & mask) != mask) {
2681 +
2682 +#ifdef CONFIG_PAX_PAGEEXEC
2683 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
2684 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
2685 + goto bad_area;
2686 +
2687 + up_read(&mm->mmap_sem);
2688 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
2689 + do_group_exit(SIGKILL);
2690 + }
2691 +#endif
2692 +
2693 goto bad_area;
2694
2695 + }
2696 +
2697 /*
2698 * If for any reason at all we couldn't handle the fault, make
2699 * sure we exit gracefully rather than endlessly redo the
2700 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
2701 index 5ca674b..e0e1b70 100644
2702 --- a/arch/ia64/mm/hugetlbpage.c
2703 +++ b/arch/ia64/mm/hugetlbpage.c
2704 @@ -171,7 +171,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
2705 /* At this point: (!vmm || addr < vmm->vm_end). */
2706 if (REGION_OFFSET(addr) + len > RGN_MAP_LIMIT)
2707 return -ENOMEM;
2708 - if (!vmm || (addr + len) <= vmm->vm_start)
2709 + if (check_heap_stack_gap(vmm, addr, len))
2710 return addr;
2711 addr = ALIGN(vmm->vm_end, HPAGE_SIZE);
2712 }
2713 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
2714 index 13df239d..cb52116 100644
2715 --- a/arch/ia64/mm/init.c
2716 +++ b/arch/ia64/mm/init.c
2717 @@ -121,6 +121,19 @@ ia64_init_addr_space (void)
2718 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
2719 vma->vm_end = vma->vm_start + PAGE_SIZE;
2720 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
2721 +
2722 +#ifdef CONFIG_PAX_PAGEEXEC
2723 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
2724 + vma->vm_flags &= ~VM_EXEC;
2725 +
2726 +#ifdef CONFIG_PAX_MPROTECT
2727 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
2728 + vma->vm_flags &= ~VM_MAYEXEC;
2729 +#endif
2730 +
2731 + }
2732 +#endif
2733 +
2734 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
2735 down_write(&current->mm->mmap_sem);
2736 if (insert_vm_struct(current->mm, vma)) {
2737 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
2738 index 40b3ee9..8c2c112 100644
2739 --- a/arch/m32r/include/asm/cache.h
2740 +++ b/arch/m32r/include/asm/cache.h
2741 @@ -1,8 +1,10 @@
2742 #ifndef _ASM_M32R_CACHE_H
2743 #define _ASM_M32R_CACHE_H
2744
2745 +#include <linux/const.h>
2746 +
2747 /* L1 cache line size */
2748 #define L1_CACHE_SHIFT 4
2749 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
2750 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
2751
2752 #endif /* _ASM_M32R_CACHE_H */
2753 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
2754 index 82abd15..d95ae5d 100644
2755 --- a/arch/m32r/lib/usercopy.c
2756 +++ b/arch/m32r/lib/usercopy.c
2757 @@ -14,6 +14,9 @@
2758 unsigned long
2759 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
2760 {
2761 + if ((long)n < 0)
2762 + return n;
2763 +
2764 prefetch(from);
2765 if (access_ok(VERIFY_WRITE, to, n))
2766 __copy_user(to,from,n);
2767 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
2768 unsigned long
2769 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
2770 {
2771 + if ((long)n < 0)
2772 + return n;
2773 +
2774 prefetchw(to);
2775 if (access_ok(VERIFY_READ, from, n))
2776 __copy_user_zeroing(to,from,n);
2777 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
2778 index 0395c51..5f26031 100644
2779 --- a/arch/m68k/include/asm/cache.h
2780 +++ b/arch/m68k/include/asm/cache.h
2781 @@ -4,9 +4,11 @@
2782 #ifndef __ARCH_M68K_CACHE_H
2783 #define __ARCH_M68K_CACHE_H
2784
2785 +#include <linux/const.h>
2786 +
2787 /* bytes per L1 cache line */
2788 #define L1_CACHE_SHIFT 4
2789 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
2790 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
2791
2792 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
2793
2794 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
2795 index 4efe96a..60e8699 100644
2796 --- a/arch/microblaze/include/asm/cache.h
2797 +++ b/arch/microblaze/include/asm/cache.h
2798 @@ -13,11 +13,12 @@
2799 #ifndef _ASM_MICROBLAZE_CACHE_H
2800 #define _ASM_MICROBLAZE_CACHE_H
2801
2802 +#include <linux/const.h>
2803 #include <asm/registers.h>
2804
2805 #define L1_CACHE_SHIFT 5
2806 /* word-granular cache in microblaze */
2807 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
2808 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
2809
2810 #define SMP_CACHE_BYTES L1_CACHE_BYTES
2811
2812 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
2813 index 1d93f81..67794d0 100644
2814 --- a/arch/mips/include/asm/atomic.h
2815 +++ b/arch/mips/include/asm/atomic.h
2816 @@ -21,6 +21,10 @@
2817 #include <asm/war.h>
2818 #include <asm/system.h>
2819
2820 +#ifdef CONFIG_GENERIC_ATOMIC64
2821 +#include <asm-generic/atomic64.h>
2822 +#endif
2823 +
2824 #define ATOMIC_INIT(i) { (i) }
2825
2826 /*
2827 @@ -765,6 +769,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
2828 */
2829 #define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
2830
2831 +#define atomic64_read_unchecked(v) atomic64_read(v)
2832 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
2833 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
2834 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
2835 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
2836 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
2837 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
2838 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
2839 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
2840 +
2841 #endif /* CONFIG_64BIT */
2842
2843 /*
2844 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
2845 index b4db69f..8f3b093 100644
2846 --- a/arch/mips/include/asm/cache.h
2847 +++ b/arch/mips/include/asm/cache.h
2848 @@ -9,10 +9,11 @@
2849 #ifndef _ASM_CACHE_H
2850 #define _ASM_CACHE_H
2851
2852 +#include <linux/const.h>
2853 #include <kmalloc.h>
2854
2855 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
2856 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
2857 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
2858
2859 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
2860 #define SMP_CACHE_BYTES L1_CACHE_BYTES
2861 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
2862 index 455c0ac..ad65fbe 100644
2863 --- a/arch/mips/include/asm/elf.h
2864 +++ b/arch/mips/include/asm/elf.h
2865 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
2866 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
2867 #endif
2868
2869 +#ifdef CONFIG_PAX_ASLR
2870 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
2871 +
2872 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
2873 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
2874 +#endif
2875 +
2876 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
2877 struct linux_binprm;
2878 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
2879 int uses_interp);
2880
2881 -struct mm_struct;
2882 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
2883 -#define arch_randomize_brk arch_randomize_brk
2884 -
2885 #endif /* _ASM_ELF_H */
2886 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
2887 index da9bd7d..91aa7ab 100644
2888 --- a/arch/mips/include/asm/page.h
2889 +++ b/arch/mips/include/asm/page.h
2890 @@ -98,7 +98,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
2891 #ifdef CONFIG_CPU_MIPS32
2892 typedef struct { unsigned long pte_low, pte_high; } pte_t;
2893 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
2894 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
2895 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
2896 #else
2897 typedef struct { unsigned long long pte; } pte_t;
2898 #define pte_val(x) ((x).pte)
2899 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
2900 index 881d18b..cea38bc 100644
2901 --- a/arch/mips/include/asm/pgalloc.h
2902 +++ b/arch/mips/include/asm/pgalloc.h
2903 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
2904 {
2905 set_pud(pud, __pud((unsigned long)pmd));
2906 }
2907 +
2908 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
2909 +{
2910 + pud_populate(mm, pud, pmd);
2911 +}
2912 #endif
2913
2914 /*
2915 diff --git a/arch/mips/include/asm/system.h b/arch/mips/include/asm/system.h
2916 index 6018c80..7c37203 100644
2917 --- a/arch/mips/include/asm/system.h
2918 +++ b/arch/mips/include/asm/system.h
2919 @@ -230,6 +230,6 @@ extern void per_cpu_trap_init(void);
2920 */
2921 #define __ARCH_WANT_UNLOCKED_CTXSW
2922
2923 -extern unsigned long arch_align_stack(unsigned long sp);
2924 +#define arch_align_stack(x) ((x) & ~0xfUL)
2925
2926 #endif /* _ASM_SYSTEM_H */
2927 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
2928 index 0d85d8e..ec71487 100644
2929 --- a/arch/mips/include/asm/thread_info.h
2930 +++ b/arch/mips/include/asm/thread_info.h
2931 @@ -123,6 +123,8 @@ register struct thread_info *__current_thread_info __asm__("$28");
2932 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
2933 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
2934 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
2935 +/* li takes a 32bit immediate */
2936 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
2937 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
2938
2939 #ifdef CONFIG_MIPS32_O32
2940 @@ -146,15 +148,18 @@ register struct thread_info *__current_thread_info __asm__("$28");
2941 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
2942 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
2943 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
2944 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
2945 +
2946 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
2947
2948 /* work to do in syscall_trace_leave() */
2949 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
2950 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
2951
2952 /* work to do on interrupt/exception return */
2953 #define _TIF_WORK_MASK (0x0000ffef & \
2954 ~(_TIF_SECCOMP | _TIF_SYSCALL_AUDIT))
2955 /* work to do on any return to u-space */
2956 -#define _TIF_ALLWORK_MASK (0x8000ffff & ~_TIF_SECCOMP)
2957 +#define _TIF_ALLWORK_MASK ((0x8000ffff & ~_TIF_SECCOMP) | _TIF_GRSEC_SETXID)
2958
2959 #endif /* __KERNEL__ */
2960
2961 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
2962 index 9fdd8bc..4bd7f1a 100644
2963 --- a/arch/mips/kernel/binfmt_elfn32.c
2964 +++ b/arch/mips/kernel/binfmt_elfn32.c
2965 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
2966 #undef ELF_ET_DYN_BASE
2967 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
2968
2969 +#ifdef CONFIG_PAX_ASLR
2970 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
2971 +
2972 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
2973 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
2974 +#endif
2975 +
2976 #include <asm/processor.h>
2977 #include <linux/module.h>
2978 #include <linux/elfcore.h>
2979 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
2980 index ff44823..97f8906 100644
2981 --- a/arch/mips/kernel/binfmt_elfo32.c
2982 +++ b/arch/mips/kernel/binfmt_elfo32.c
2983 @@ -52,6 +52,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
2984 #undef ELF_ET_DYN_BASE
2985 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
2986
2987 +#ifdef CONFIG_PAX_ASLR
2988 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
2989 +
2990 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
2991 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
2992 +#endif
2993 +
2994 #include <asm/processor.h>
2995
2996 /*
2997 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
2998 index 7955409..ceaea7c 100644
2999 --- a/arch/mips/kernel/process.c
3000 +++ b/arch/mips/kernel/process.c
3001 @@ -483,15 +483,3 @@ unsigned long get_wchan(struct task_struct *task)
3002 out:
3003 return pc;
3004 }
3005 -
3006 -/*
3007 - * Don't forget that the stack pointer must be aligned on a 8 bytes
3008 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
3009 - */
3010 -unsigned long arch_align_stack(unsigned long sp)
3011 -{
3012 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
3013 - sp -= get_random_int() & ~PAGE_MASK;
3014 -
3015 - return sp & ALMASK;
3016 -}
3017 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
3018 index 7786b60..3e38c72 100644
3019 --- a/arch/mips/kernel/ptrace.c
3020 +++ b/arch/mips/kernel/ptrace.c
3021 @@ -529,6 +529,10 @@ static inline int audit_arch(void)
3022 return arch;
3023 }
3024
3025 +#ifdef CONFIG_GRKERNSEC_SETXID
3026 +extern void gr_delayed_cred_worker(void);
3027 +#endif
3028 +
3029 /*
3030 * Notification of system call entry/exit
3031 * - triggered by current->work.syscall_trace
3032 @@ -538,6 +542,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
3033 /* do the secure computing check first */
3034 secure_computing(regs->regs[2]);
3035
3036 +#ifdef CONFIG_GRKERNSEC_SETXID
3037 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
3038 + gr_delayed_cred_worker();
3039 +#endif
3040 +
3041 if (!(current->ptrace & PT_PTRACED))
3042 goto out;
3043
3044 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
3045 index a632bc1..0b77c7c 100644
3046 --- a/arch/mips/kernel/scall32-o32.S
3047 +++ b/arch/mips/kernel/scall32-o32.S
3048 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
3049
3050 stack_done:
3051 lw t0, TI_FLAGS($28) # syscall tracing enabled?
3052 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
3053 + li t1, _TIF_SYSCALL_WORK
3054 and t0, t1
3055 bnez t0, syscall_trace_entry # -> yes
3056
3057 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
3058 index 3b5a5e9..e1ee86d 100644
3059 --- a/arch/mips/kernel/scall64-64.S
3060 +++ b/arch/mips/kernel/scall64-64.S
3061 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
3062
3063 sd a3, PT_R26(sp) # save a3 for syscall restarting
3064
3065 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
3066 + li t1, _TIF_SYSCALL_WORK
3067 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
3068 and t0, t1, t0
3069 bnez t0, syscall_trace_entry
3070 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
3071 index 6be6f70..1859577 100644
3072 --- a/arch/mips/kernel/scall64-n32.S
3073 +++ b/arch/mips/kernel/scall64-n32.S
3074 @@ -53,7 +53,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
3075
3076 sd a3, PT_R26(sp) # save a3 for syscall restarting
3077
3078 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
3079 + li t1, _TIF_SYSCALL_WORK
3080 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
3081 and t0, t1, t0
3082 bnez t0, n32_syscall_trace_entry
3083 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
3084 index 5422855..74e63a3 100644
3085 --- a/arch/mips/kernel/scall64-o32.S
3086 +++ b/arch/mips/kernel/scall64-o32.S
3087 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
3088 PTR 4b, bad_stack
3089 .previous
3090
3091 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
3092 + li t1, _TIF_SYSCALL_WORK
3093 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
3094 and t0, t1, t0
3095 bnez t0, trace_a_syscall
3096 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
3097 index 69ebd58..e4bff83 100644
3098 --- a/arch/mips/mm/fault.c
3099 +++ b/arch/mips/mm/fault.c
3100 @@ -28,6 +28,23 @@
3101 #include <asm/highmem.h> /* For VMALLOC_END */
3102 #include <linux/kdebug.h>
3103
3104 +#ifdef CONFIG_PAX_PAGEEXEC
3105 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3106 +{
3107 + unsigned long i;
3108 +
3109 + printk(KERN_ERR "PAX: bytes at PC: ");
3110 + for (i = 0; i < 5; i++) {
3111 + unsigned int c;
3112 + if (get_user(c, (unsigned int *)pc+i))
3113 + printk(KERN_CONT "???????? ");
3114 + else
3115 + printk(KERN_CONT "%08x ", c);
3116 + }
3117 + printk("\n");
3118 +}
3119 +#endif
3120 +
3121 /*
3122 * This routine handles page faults. It determines the address,
3123 * and the problem, and then passes it off to one of the appropriate
3124 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
3125 index 302d779..7d35bf8 100644
3126 --- a/arch/mips/mm/mmap.c
3127 +++ b/arch/mips/mm/mmap.c
3128 @@ -95,6 +95,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
3129 do_color_align = 1;
3130
3131 /* requesting a specific address */
3132 +
3133 +#ifdef CONFIG_PAX_RANDMMAP
3134 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
3135 +#endif
3136 +
3137 if (addr) {
3138 if (do_color_align)
3139 addr = COLOUR_ALIGN(addr, pgoff);
3140 @@ -102,8 +107,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
3141 addr = PAGE_ALIGN(addr);
3142
3143 vma = find_vma(mm, addr);
3144 - if (TASK_SIZE - len >= addr &&
3145 - (!vma || addr + len <= vma->vm_start))
3146 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len))
3147 return addr;
3148 }
3149
3150 @@ -118,7 +122,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
3151 /* At this point: (!vma || addr < vma->vm_end). */
3152 if (TASK_SIZE - len < addr)
3153 return -ENOMEM;
3154 - if (!vma || addr + len <= vma->vm_start)
3155 + if (check_heap_stack_gap(vmm, addr, len))
3156 return addr;
3157 addr = vma->vm_end;
3158 if (do_color_align)
3159 @@ -145,7 +149,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
3160 /* make sure it can fit in the remaining address space */
3161 if (likely(addr > len)) {
3162 vma = find_vma(mm, addr - len);
3163 - if (!vma || addr <= vma->vm_start) {
3164 + if (check_heap_stack_gap(vmm, addr - len, len))
3165 /* cache the address as a hint for next time */
3166 return mm->free_area_cache = addr - len;
3167 }
3168 @@ -165,7 +169,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
3169 * return with success:
3170 */
3171 vma = find_vma(mm, addr);
3172 - if (likely(!vma || addr + len <= vma->vm_start)) {
3173 + if (check_heap_stack_gap(vmm, addr, len)) {
3174 /* cache the address as a hint for next time */
3175 return mm->free_area_cache = addr;
3176 }
3177 @@ -242,30 +246,3 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3178 mm->unmap_area = arch_unmap_area_topdown;
3179 }
3180 }
3181 -
3182 -static inline unsigned long brk_rnd(void)
3183 -{
3184 - unsigned long rnd = get_random_int();
3185 -
3186 - rnd = rnd << PAGE_SHIFT;
3187 - /* 8MB for 32bit, 256MB for 64bit */
3188 - if (TASK_IS_32BIT_ADDR)
3189 - rnd = rnd & 0x7ffffful;
3190 - else
3191 - rnd = rnd & 0xffffffful;
3192 -
3193 - return rnd;
3194 -}
3195 -
3196 -unsigned long arch_randomize_brk(struct mm_struct *mm)
3197 -{
3198 - unsigned long base = mm->brk;
3199 - unsigned long ret;
3200 -
3201 - ret = PAGE_ALIGN(base + brk_rnd());
3202 -
3203 - if (ret < mm->brk)
3204 - return mm->brk;
3205 -
3206 - return ret;
3207 -}
3208 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
3209 index 967d144..db12197 100644
3210 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
3211 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
3212 @@ -11,12 +11,14 @@
3213 #ifndef _ASM_PROC_CACHE_H
3214 #define _ASM_PROC_CACHE_H
3215
3216 +#include <linux/const.h>
3217 +
3218 /* L1 cache */
3219
3220 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
3221 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
3222 -#define L1_CACHE_BYTES 16 /* bytes per entry */
3223 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
3224 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
3225 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
3226
3227 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
3228 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
3229 index bcb5df2..84fabd2 100644
3230 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
3231 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
3232 @@ -16,13 +16,15 @@
3233 #ifndef _ASM_PROC_CACHE_H
3234 #define _ASM_PROC_CACHE_H
3235
3236 +#include <linux/const.h>
3237 +
3238 /*
3239 * L1 cache
3240 */
3241 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
3242 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
3243 -#define L1_CACHE_BYTES 32 /* bytes per entry */
3244 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
3245 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
3246 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
3247
3248 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
3249 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
3250 index 4ce7a01..449202a 100644
3251 --- a/arch/openrisc/include/asm/cache.h
3252 +++ b/arch/openrisc/include/asm/cache.h
3253 @@ -19,11 +19,13 @@
3254 #ifndef __ASM_OPENRISC_CACHE_H
3255 #define __ASM_OPENRISC_CACHE_H
3256
3257 +#include <linux/const.h>
3258 +
3259 /* FIXME: How can we replace these with values from the CPU...
3260 * they shouldn't be hard-coded!
3261 */
3262
3263 -#define L1_CACHE_BYTES 16
3264 #define L1_CACHE_SHIFT 4
3265 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
3266
3267 #endif /* __ASM_OPENRISC_CACHE_H */
3268 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
3269 index 4054b31..a10c105 100644
3270 --- a/arch/parisc/include/asm/atomic.h
3271 +++ b/arch/parisc/include/asm/atomic.h
3272 @@ -335,6 +335,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
3273
3274 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
3275
3276 +#define atomic64_read_unchecked(v) atomic64_read(v)
3277 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
3278 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
3279 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
3280 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
3281 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
3282 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
3283 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
3284 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
3285 +
3286 #endif /* !CONFIG_64BIT */
3287
3288
3289 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
3290 index 47f11c7..3420df2 100644
3291 --- a/arch/parisc/include/asm/cache.h
3292 +++ b/arch/parisc/include/asm/cache.h
3293 @@ -5,6 +5,7 @@
3294 #ifndef __ARCH_PARISC_CACHE_H
3295 #define __ARCH_PARISC_CACHE_H
3296
3297 +#include <linux/const.h>
3298
3299 /*
3300 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
3301 @@ -15,13 +16,13 @@
3302 * just ruin performance.
3303 */
3304 #ifdef CONFIG_PA20
3305 -#define L1_CACHE_BYTES 64
3306 #define L1_CACHE_SHIFT 6
3307 #else
3308 -#define L1_CACHE_BYTES 32
3309 #define L1_CACHE_SHIFT 5
3310 #endif
3311
3312 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
3313 +
3314 #ifndef __ASSEMBLY__
3315
3316 #define SMP_CACHE_BYTES L1_CACHE_BYTES
3317 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
3318 index 19f6cb1..6c78cf2 100644
3319 --- a/arch/parisc/include/asm/elf.h
3320 +++ b/arch/parisc/include/asm/elf.h
3321 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
3322
3323 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
3324
3325 +#ifdef CONFIG_PAX_ASLR
3326 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
3327 +
3328 +#define PAX_DELTA_MMAP_LEN 16
3329 +#define PAX_DELTA_STACK_LEN 16
3330 +#endif
3331 +
3332 /* This yields a mask that user programs can use to figure out what
3333 instruction set this CPU supports. This could be done in user space,
3334 but it's not easy, and we've already done it here. */
3335 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
3336 index fc987a1..6e068ef 100644
3337 --- a/arch/parisc/include/asm/pgalloc.h
3338 +++ b/arch/parisc/include/asm/pgalloc.h
3339 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
3340 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
3341 }
3342
3343 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
3344 +{
3345 + pgd_populate(mm, pgd, pmd);
3346 +}
3347 +
3348 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
3349 {
3350 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
3351 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
3352 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
3353 #define pmd_free(mm, x) do { } while (0)
3354 #define pgd_populate(mm, pmd, pte) BUG()
3355 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
3356
3357 #endif
3358
3359 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
3360 index 22dadeb..f6c2be4 100644
3361 --- a/arch/parisc/include/asm/pgtable.h
3362 +++ b/arch/parisc/include/asm/pgtable.h
3363 @@ -210,6 +210,17 @@ struct vm_area_struct;
3364 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
3365 #define PAGE_COPY PAGE_EXECREAD
3366 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
3367 +
3368 +#ifdef CONFIG_PAX_PAGEEXEC
3369 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
3370 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
3371 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
3372 +#else
3373 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
3374 +# define PAGE_COPY_NOEXEC PAGE_COPY
3375 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
3376 +#endif
3377 +
3378 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
3379 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
3380 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
3381 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
3382 index 5e34ccf..672bc9c 100644
3383 --- a/arch/parisc/kernel/module.c
3384 +++ b/arch/parisc/kernel/module.c
3385 @@ -98,16 +98,38 @@
3386
3387 /* three functions to determine where in the module core
3388 * or init pieces the location is */
3389 +static inline int in_init_rx(struct module *me, void *loc)
3390 +{
3391 + return (loc >= me->module_init_rx &&
3392 + loc < (me->module_init_rx + me->init_size_rx));
3393 +}
3394 +
3395 +static inline int in_init_rw(struct module *me, void *loc)
3396 +{
3397 + return (loc >= me->module_init_rw &&
3398 + loc < (me->module_init_rw + me->init_size_rw));
3399 +}
3400 +
3401 static inline int in_init(struct module *me, void *loc)
3402 {
3403 - return (loc >= me->module_init &&
3404 - loc <= (me->module_init + me->init_size));
3405 + return in_init_rx(me, loc) || in_init_rw(me, loc);
3406 +}
3407 +
3408 +static inline int in_core_rx(struct module *me, void *loc)
3409 +{
3410 + return (loc >= me->module_core_rx &&
3411 + loc < (me->module_core_rx + me->core_size_rx));
3412 +}
3413 +
3414 +static inline int in_core_rw(struct module *me, void *loc)
3415 +{
3416 + return (loc >= me->module_core_rw &&
3417 + loc < (me->module_core_rw + me->core_size_rw));
3418 }
3419
3420 static inline int in_core(struct module *me, void *loc)
3421 {
3422 - return (loc >= me->module_core &&
3423 - loc <= (me->module_core + me->core_size));
3424 + return in_core_rx(me, loc) || in_core_rw(me, loc);
3425 }
3426
3427 static inline int in_local(struct module *me, void *loc)
3428 @@ -373,13 +395,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
3429 }
3430
3431 /* align things a bit */
3432 - me->core_size = ALIGN(me->core_size, 16);
3433 - me->arch.got_offset = me->core_size;
3434 - me->core_size += gots * sizeof(struct got_entry);
3435 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
3436 + me->arch.got_offset = me->core_size_rw;
3437 + me->core_size_rw += gots * sizeof(struct got_entry);
3438
3439 - me->core_size = ALIGN(me->core_size, 16);
3440 - me->arch.fdesc_offset = me->core_size;
3441 - me->core_size += fdescs * sizeof(Elf_Fdesc);
3442 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
3443 + me->arch.fdesc_offset = me->core_size_rw;
3444 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
3445
3446 me->arch.got_max = gots;
3447 me->arch.fdesc_max = fdescs;
3448 @@ -397,7 +419,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
3449
3450 BUG_ON(value == 0);
3451
3452 - got = me->module_core + me->arch.got_offset;
3453 + got = me->module_core_rw + me->arch.got_offset;
3454 for (i = 0; got[i].addr; i++)
3455 if (got[i].addr == value)
3456 goto out;
3457 @@ -415,7 +437,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
3458 #ifdef CONFIG_64BIT
3459 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
3460 {
3461 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
3462 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
3463
3464 if (!value) {
3465 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
3466 @@ -433,7 +455,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
3467
3468 /* Create new one */
3469 fdesc->addr = value;
3470 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
3471 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
3472 return (Elf_Addr)fdesc;
3473 }
3474 #endif /* CONFIG_64BIT */
3475 @@ -845,7 +867,7 @@ register_unwind_table(struct module *me,
3476
3477 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
3478 end = table + sechdrs[me->arch.unwind_section].sh_size;
3479 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
3480 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
3481
3482 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
3483 me->arch.unwind_section, table, end, gp);
3484 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
3485 index c9b9322..02d8940 100644
3486 --- a/arch/parisc/kernel/sys_parisc.c
3487 +++ b/arch/parisc/kernel/sys_parisc.c
3488 @@ -43,7 +43,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
3489 /* At this point: (!vma || addr < vma->vm_end). */
3490 if (TASK_SIZE - len < addr)
3491 return -ENOMEM;
3492 - if (!vma || addr + len <= vma->vm_start)
3493 + if (check_heap_stack_gap(vma, addr, len))
3494 return addr;
3495 addr = vma->vm_end;
3496 }
3497 @@ -79,7 +79,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
3498 /* At this point: (!vma || addr < vma->vm_end). */
3499 if (TASK_SIZE - len < addr)
3500 return -ENOMEM;
3501 - if (!vma || addr + len <= vma->vm_start)
3502 + if (check_heap_stack_gap(vma, addr, len))
3503 return addr;
3504 addr = DCACHE_ALIGN(vma->vm_end - offset) + offset;
3505 if (addr < vma->vm_end) /* handle wraparound */
3506 @@ -98,7 +98,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
3507 if (flags & MAP_FIXED)
3508 return addr;
3509 if (!addr)
3510 - addr = TASK_UNMAPPED_BASE;
3511 + addr = current->mm->mmap_base;
3512
3513 if (filp) {
3514 addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
3515 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
3516 index f19e660..414fe24 100644
3517 --- a/arch/parisc/kernel/traps.c
3518 +++ b/arch/parisc/kernel/traps.c
3519 @@ -733,9 +733,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
3520
3521 down_read(&current->mm->mmap_sem);
3522 vma = find_vma(current->mm,regs->iaoq[0]);
3523 - if (vma && (regs->iaoq[0] >= vma->vm_start)
3524 - && (vma->vm_flags & VM_EXEC)) {
3525 -
3526 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
3527 fault_address = regs->iaoq[0];
3528 fault_space = regs->iasq[0];
3529
3530 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
3531 index 18162ce..94de376 100644
3532 --- a/arch/parisc/mm/fault.c
3533 +++ b/arch/parisc/mm/fault.c
3534 @@ -15,6 +15,7 @@
3535 #include <linux/sched.h>
3536 #include <linux/interrupt.h>
3537 #include <linux/module.h>
3538 +#include <linux/unistd.h>
3539
3540 #include <asm/uaccess.h>
3541 #include <asm/traps.h>
3542 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
3543 static unsigned long
3544 parisc_acctyp(unsigned long code, unsigned int inst)
3545 {
3546 - if (code == 6 || code == 16)
3547 + if (code == 6 || code == 7 || code == 16)
3548 return VM_EXEC;
3549
3550 switch (inst & 0xf0000000) {
3551 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
3552 }
3553 #endif
3554
3555 +#ifdef CONFIG_PAX_PAGEEXEC
3556 +/*
3557 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
3558 + *
3559 + * returns 1 when task should be killed
3560 + * 2 when rt_sigreturn trampoline was detected
3561 + * 3 when unpatched PLT trampoline was detected
3562 + */
3563 +static int pax_handle_fetch_fault(struct pt_regs *regs)
3564 +{
3565 +
3566 +#ifdef CONFIG_PAX_EMUPLT
3567 + int err;
3568 +
3569 + do { /* PaX: unpatched PLT emulation */
3570 + unsigned int bl, depwi;
3571 +
3572 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
3573 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
3574 +
3575 + if (err)
3576 + break;
3577 +
3578 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
3579 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
3580 +
3581 + err = get_user(ldw, (unsigned int *)addr);
3582 + err |= get_user(bv, (unsigned int *)(addr+4));
3583 + err |= get_user(ldw2, (unsigned int *)(addr+8));
3584 +
3585 + if (err)
3586 + break;
3587 +
3588 + if (ldw == 0x0E801096U &&
3589 + bv == 0xEAC0C000U &&
3590 + ldw2 == 0x0E881095U)
3591 + {
3592 + unsigned int resolver, map;
3593 +
3594 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
3595 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
3596 + if (err)
3597 + break;
3598 +
3599 + regs->gr[20] = instruction_pointer(regs)+8;
3600 + regs->gr[21] = map;
3601 + regs->gr[22] = resolver;
3602 + regs->iaoq[0] = resolver | 3UL;
3603 + regs->iaoq[1] = regs->iaoq[0] + 4;
3604 + return 3;
3605 + }
3606 + }
3607 + } while (0);
3608 +#endif
3609 +
3610 +#ifdef CONFIG_PAX_EMUTRAMP
3611 +
3612 +#ifndef CONFIG_PAX_EMUSIGRT
3613 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
3614 + return 1;
3615 +#endif
3616 +
3617 + do { /* PaX: rt_sigreturn emulation */
3618 + unsigned int ldi1, ldi2, bel, nop;
3619 +
3620 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
3621 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
3622 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
3623 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
3624 +
3625 + if (err)
3626 + break;
3627 +
3628 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
3629 + ldi2 == 0x3414015AU &&
3630 + bel == 0xE4008200U &&
3631 + nop == 0x08000240U)
3632 + {
3633 + regs->gr[25] = (ldi1 & 2) >> 1;
3634 + regs->gr[20] = __NR_rt_sigreturn;
3635 + regs->gr[31] = regs->iaoq[1] + 16;
3636 + regs->sr[0] = regs->iasq[1];
3637 + regs->iaoq[0] = 0x100UL;
3638 + regs->iaoq[1] = regs->iaoq[0] + 4;
3639 + regs->iasq[0] = regs->sr[2];
3640 + regs->iasq[1] = regs->sr[2];
3641 + return 2;
3642 + }
3643 + } while (0);
3644 +#endif
3645 +
3646 + return 1;
3647 +}
3648 +
3649 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3650 +{
3651 + unsigned long i;
3652 +
3653 + printk(KERN_ERR "PAX: bytes at PC: ");
3654 + for (i = 0; i < 5; i++) {
3655 + unsigned int c;
3656 + if (get_user(c, (unsigned int *)pc+i))
3657 + printk(KERN_CONT "???????? ");
3658 + else
3659 + printk(KERN_CONT "%08x ", c);
3660 + }
3661 + printk("\n");
3662 +}
3663 +#endif
3664 +
3665 int fixup_exception(struct pt_regs *regs)
3666 {
3667 const struct exception_table_entry *fix;
3668 @@ -192,8 +303,33 @@ good_area:
3669
3670 acc_type = parisc_acctyp(code,regs->iir);
3671
3672 - if ((vma->vm_flags & acc_type) != acc_type)
3673 + if ((vma->vm_flags & acc_type) != acc_type) {
3674 +
3675 +#ifdef CONFIG_PAX_PAGEEXEC
3676 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
3677 + (address & ~3UL) == instruction_pointer(regs))
3678 + {
3679 + up_read(&mm->mmap_sem);
3680 + switch (pax_handle_fetch_fault(regs)) {
3681 +
3682 +#ifdef CONFIG_PAX_EMUPLT
3683 + case 3:
3684 + return;
3685 +#endif
3686 +
3687 +#ifdef CONFIG_PAX_EMUTRAMP
3688 + case 2:
3689 + return;
3690 +#endif
3691 +
3692 + }
3693 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
3694 + do_group_exit(SIGKILL);
3695 + }
3696 +#endif
3697 +
3698 goto bad_area;
3699 + }
3700
3701 /*
3702 * If for any reason at all we couldn't handle the fault, make
3703 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
3704 index 02e41b5..ec6e26c 100644
3705 --- a/arch/powerpc/include/asm/atomic.h
3706 +++ b/arch/powerpc/include/asm/atomic.h
3707 @@ -469,6 +469,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
3708
3709 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
3710
3711 +#define atomic64_read_unchecked(v) atomic64_read(v)
3712 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
3713 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
3714 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
3715 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
3716 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
3717 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
3718 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
3719 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
3720 +
3721 #endif /* __powerpc64__ */
3722
3723 #endif /* __KERNEL__ */
3724 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
3725 index 4b50941..5605819 100644
3726 --- a/arch/powerpc/include/asm/cache.h
3727 +++ b/arch/powerpc/include/asm/cache.h
3728 @@ -3,6 +3,7 @@
3729
3730 #ifdef __KERNEL__
3731
3732 +#include <linux/const.h>
3733
3734 /* bytes per L1 cache line */
3735 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
3736 @@ -22,7 +23,7 @@
3737 #define L1_CACHE_SHIFT 7
3738 #endif
3739
3740 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
3741 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
3742
3743 #define SMP_CACHE_BYTES L1_CACHE_BYTES
3744
3745 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
3746 index 3bf9cca..e7457d0 100644
3747 --- a/arch/powerpc/include/asm/elf.h
3748 +++ b/arch/powerpc/include/asm/elf.h
3749 @@ -178,8 +178,19 @@ typedef elf_fpreg_t elf_vsrreghalf_t32[ELF_NVSRHALFREG];
3750 the loader. We need to make sure that it is out of the way of the program
3751 that it will "exec", and that there is sufficient room for the brk. */
3752
3753 -extern unsigned long randomize_et_dyn(unsigned long base);
3754 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
3755 +#define ELF_ET_DYN_BASE (0x20000000)
3756 +
3757 +#ifdef CONFIG_PAX_ASLR
3758 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
3759 +
3760 +#ifdef __powerpc64__
3761 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
3762 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
3763 +#else
3764 +#define PAX_DELTA_MMAP_LEN 15
3765 +#define PAX_DELTA_STACK_LEN 15
3766 +#endif
3767 +#endif
3768
3769 /*
3770 * Our registers are always unsigned longs, whether we're a 32 bit
3771 @@ -274,9 +285,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
3772 (0x7ff >> (PAGE_SHIFT - 12)) : \
3773 (0x3ffff >> (PAGE_SHIFT - 12)))
3774
3775 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
3776 -#define arch_randomize_brk arch_randomize_brk
3777 -
3778 #endif /* __KERNEL__ */
3779
3780 /*
3781 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
3782 index bca8fdc..61e9580 100644
3783 --- a/arch/powerpc/include/asm/kmap_types.h
3784 +++ b/arch/powerpc/include/asm/kmap_types.h
3785 @@ -27,6 +27,7 @@ enum km_type {
3786 KM_PPC_SYNC_PAGE,
3787 KM_PPC_SYNC_ICACHE,
3788 KM_KDB,
3789 + KM_CLEARPAGE,
3790 KM_TYPE_NR
3791 };
3792
3793 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
3794 index d4a7f64..451de1c 100644
3795 --- a/arch/powerpc/include/asm/mman.h
3796 +++ b/arch/powerpc/include/asm/mman.h
3797 @@ -44,7 +44,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
3798 }
3799 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
3800
3801 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
3802 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
3803 {
3804 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
3805 }
3806 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
3807 index f072e97..b436dee 100644
3808 --- a/arch/powerpc/include/asm/page.h
3809 +++ b/arch/powerpc/include/asm/page.h
3810 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
3811 * and needs to be executable. This means the whole heap ends
3812 * up being executable.
3813 */
3814 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
3815 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
3816 +#define VM_DATA_DEFAULT_FLAGS32 \
3817 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
3818 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
3819
3820 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
3821 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
3822 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
3823 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
3824 #endif
3825
3826 +#define ktla_ktva(addr) (addr)
3827 +#define ktva_ktla(addr) (addr)
3828 +
3829 /*
3830 * Use the top bit of the higher-level page table entries to indicate whether
3831 * the entries we point to contain hugepages. This works because we know that
3832 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
3833 index fed85e6..da5c71b 100644
3834 --- a/arch/powerpc/include/asm/page_64.h
3835 +++ b/arch/powerpc/include/asm/page_64.h
3836 @@ -146,15 +146,18 @@ do { \
3837 * stack by default, so in the absence of a PT_GNU_STACK program header
3838 * we turn execute permission off.
3839 */
3840 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
3841 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
3842 +#define VM_STACK_DEFAULT_FLAGS32 \
3843 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
3844 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
3845
3846 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
3847 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
3848
3849 +#ifndef CONFIG_PAX_PAGEEXEC
3850 #define VM_STACK_DEFAULT_FLAGS \
3851 (is_32bit_task() ? \
3852 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
3853 +#endif
3854
3855 #include <asm-generic/getorder.h>
3856
3857 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
3858 index 292725c..f87ae14 100644
3859 --- a/arch/powerpc/include/asm/pgalloc-64.h
3860 +++ b/arch/powerpc/include/asm/pgalloc-64.h
3861 @@ -50,6 +50,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
3862 #ifndef CONFIG_PPC_64K_PAGES
3863
3864 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
3865 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
3866
3867 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
3868 {
3869 @@ -67,6 +68,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
3870 pud_set(pud, (unsigned long)pmd);
3871 }
3872
3873 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
3874 +{
3875 + pud_populate(mm, pud, pmd);
3876 +}
3877 +
3878 #define pmd_populate(mm, pmd, pte_page) \
3879 pmd_populate_kernel(mm, pmd, page_address(pte_page))
3880 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
3881 @@ -76,6 +82,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
3882 #else /* CONFIG_PPC_64K_PAGES */
3883
3884 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
3885 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
3886
3887 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
3888 pte_t *pte)
3889 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
3890 index 2e0e411..7899c68 100644
3891 --- a/arch/powerpc/include/asm/pgtable.h
3892 +++ b/arch/powerpc/include/asm/pgtable.h
3893 @@ -2,6 +2,7 @@
3894 #define _ASM_POWERPC_PGTABLE_H
3895 #ifdef __KERNEL__
3896
3897 +#include <linux/const.h>
3898 #ifndef __ASSEMBLY__
3899 #include <asm/processor.h> /* For TASK_SIZE */
3900 #include <asm/mmu.h>
3901 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
3902 index 4aad413..85d86bf 100644
3903 --- a/arch/powerpc/include/asm/pte-hash32.h
3904 +++ b/arch/powerpc/include/asm/pte-hash32.h
3905 @@ -21,6 +21,7 @@
3906 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
3907 #define _PAGE_USER 0x004 /* usermode access allowed */
3908 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
3909 +#define _PAGE_EXEC _PAGE_GUARDED
3910 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
3911 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
3912 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
3913 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
3914 index 7fdc2c0..e47a9b02d3 100644
3915 --- a/arch/powerpc/include/asm/reg.h
3916 +++ b/arch/powerpc/include/asm/reg.h
3917 @@ -212,6 +212,7 @@
3918 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
3919 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
3920 #define DSISR_NOHPTE 0x40000000 /* no translation found */
3921 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
3922 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
3923 #define DSISR_ISSTORE 0x02000000 /* access was a store */
3924 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
3925 diff --git a/arch/powerpc/include/asm/system.h b/arch/powerpc/include/asm/system.h
3926 index c377457..3c69fbc 100644
3927 --- a/arch/powerpc/include/asm/system.h
3928 +++ b/arch/powerpc/include/asm/system.h
3929 @@ -539,7 +539,7 @@ __cmpxchg_local(volatile void *ptr, unsigned long old, unsigned long new,
3930 #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
3931 #endif
3932
3933 -extern unsigned long arch_align_stack(unsigned long sp);
3934 +#define arch_align_stack(x) ((x) & ~0xfUL)
3935
3936 /* Used in very early kernel initialization. */
3937 extern unsigned long reloc_offset(void);
3938 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
3939 index 96471494..60ed5a2 100644
3940 --- a/arch/powerpc/include/asm/thread_info.h
3941 +++ b/arch/powerpc/include/asm/thread_info.h
3942 @@ -104,13 +104,15 @@ static inline struct thread_info *current_thread_info(void)
3943 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
3944 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
3945 #define TIF_SINGLESTEP 8 /* singlestepping active */
3946 -#define TIF_MEMDIE 9 /* is terminating due to OOM killer */
3947 #define TIF_SECCOMP 10 /* secure computing */
3948 #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
3949 #define TIF_NOERROR 12 /* Force successful syscall return */
3950 #define TIF_NOTIFY_RESUME 13 /* callback before returning to user */
3951 #define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */
3952 #define TIF_RUNLATCH 16 /* Is the runlatch enabled? */
3953 +#define TIF_MEMDIE 17 /* is terminating due to OOM killer */
3954 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
3955 +#define TIF_GRSEC_SETXID 9 /* update credentials on syscall entry/exit */
3956
3957 /* as above, but as bit values */
3958 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
3959 @@ -128,8 +130,11 @@ static inline struct thread_info *current_thread_info(void)
3960 #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
3961 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
3962 #define _TIF_RUNLATCH (1<<TIF_RUNLATCH)
3963 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
3964 +
3965 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
3966 - _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
3967 + _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT \
3968 + _TIF_GRSEC_SETXID)
3969
3970 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
3971 _TIF_NOTIFY_RESUME)
3972 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
3973 index bd0fb84..a42a14b 100644
3974 --- a/arch/powerpc/include/asm/uaccess.h
3975 +++ b/arch/powerpc/include/asm/uaccess.h
3976 @@ -13,6 +13,8 @@
3977 #define VERIFY_READ 0
3978 #define VERIFY_WRITE 1
3979
3980 +extern void check_object_size(const void *ptr, unsigned long n, bool to);
3981 +
3982 /*
3983 * The fs value determines whether argument validity checking should be
3984 * performed or not. If get_fs() == USER_DS, checking is performed, with
3985 @@ -327,52 +329,6 @@ do { \
3986 extern unsigned long __copy_tofrom_user(void __user *to,
3987 const void __user *from, unsigned long size);
3988
3989 -#ifndef __powerpc64__
3990 -
3991 -static inline unsigned long copy_from_user(void *to,
3992 - const void __user *from, unsigned long n)
3993 -{
3994 - unsigned long over;
3995 -
3996 - if (access_ok(VERIFY_READ, from, n))
3997 - return __copy_tofrom_user((__force void __user *)to, from, n);
3998 - if ((unsigned long)from < TASK_SIZE) {
3999 - over = (unsigned long)from + n - TASK_SIZE;
4000 - return __copy_tofrom_user((__force void __user *)to, from,
4001 - n - over) + over;
4002 - }
4003 - return n;
4004 -}
4005 -
4006 -static inline unsigned long copy_to_user(void __user *to,
4007 - const void *from, unsigned long n)
4008 -{
4009 - unsigned long over;
4010 -
4011 - if (access_ok(VERIFY_WRITE, to, n))
4012 - return __copy_tofrom_user(to, (__force void __user *)from, n);
4013 - if ((unsigned long)to < TASK_SIZE) {
4014 - over = (unsigned long)to + n - TASK_SIZE;
4015 - return __copy_tofrom_user(to, (__force void __user *)from,
4016 - n - over) + over;
4017 - }
4018 - return n;
4019 -}
4020 -
4021 -#else /* __powerpc64__ */
4022 -
4023 -#define __copy_in_user(to, from, size) \
4024 - __copy_tofrom_user((to), (from), (size))
4025 -
4026 -extern unsigned long copy_from_user(void *to, const void __user *from,
4027 - unsigned long n);
4028 -extern unsigned long copy_to_user(void __user *to, const void *from,
4029 - unsigned long n);
4030 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
4031 - unsigned long n);
4032 -
4033 -#endif /* __powerpc64__ */
4034 -
4035 static inline unsigned long __copy_from_user_inatomic(void *to,
4036 const void __user *from, unsigned long n)
4037 {
4038 @@ -396,6 +352,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
4039 if (ret == 0)
4040 return 0;
4041 }
4042 +
4043 + if (!__builtin_constant_p(n))
4044 + check_object_size(to, n, false);
4045 +
4046 return __copy_tofrom_user((__force void __user *)to, from, n);
4047 }
4048
4049 @@ -422,6 +382,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
4050 if (ret == 0)
4051 return 0;
4052 }
4053 +
4054 + if (!__builtin_constant_p(n))
4055 + check_object_size(from, n, true);
4056 +
4057 return __copy_tofrom_user(to, (__force const void __user *)from, n);
4058 }
4059
4060 @@ -439,6 +403,92 @@ static inline unsigned long __copy_to_user(void __user *to,
4061 return __copy_to_user_inatomic(to, from, size);
4062 }
4063
4064 +#ifndef __powerpc64__
4065 +
4066 +static inline unsigned long __must_check copy_from_user(void *to,
4067 + const void __user *from, unsigned long n)
4068 +{
4069 + unsigned long over;
4070 +
4071 + if ((long)n < 0)
4072 + return n;
4073 +
4074 + if (access_ok(VERIFY_READ, from, n)) {
4075 + if (!__builtin_constant_p(n))
4076 + check_object_size(to, n, false);
4077 + return __copy_tofrom_user((__force void __user *)to, from, n);
4078 + }
4079 + if ((unsigned long)from < TASK_SIZE) {
4080 + over = (unsigned long)from + n - TASK_SIZE;
4081 + if (!__builtin_constant_p(n - over))
4082 + check_object_size(to, n - over, false);
4083 + return __copy_tofrom_user((__force void __user *)to, from,
4084 + n - over) + over;
4085 + }
4086 + return n;
4087 +}
4088 +
4089 +static inline unsigned long __must_check copy_to_user(void __user *to,
4090 + const void *from, unsigned long n)
4091 +{
4092 + unsigned long over;
4093 +
4094 + if ((long)n < 0)
4095 + return n;
4096 +
4097 + if (access_ok(VERIFY_WRITE, to, n)) {
4098 + if (!__builtin_constant_p(n))
4099 + check_object_size(from, n, true);
4100 + return __copy_tofrom_user(to, (__force void __user *)from, n);
4101 + }
4102 + if ((unsigned long)to < TASK_SIZE) {
4103 + over = (unsigned long)to + n - TASK_SIZE;
4104 + if (!__builtin_constant_p(n))
4105 + check_object_size(from, n - over, true);
4106 + return __copy_tofrom_user(to, (__force void __user *)from,
4107 + n - over) + over;
4108 + }
4109 + return n;
4110 +}
4111 +
4112 +#else /* __powerpc64__ */
4113 +
4114 +#define __copy_in_user(to, from, size) \
4115 + __copy_tofrom_user((to), (from), (size))
4116 +
4117 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
4118 +{
4119 + if ((long)n < 0 || n > INT_MAX)
4120 + return n;
4121 +
4122 + if (!__builtin_constant_p(n))
4123 + check_object_size(to, n, false);
4124 +
4125 + if (likely(access_ok(VERIFY_READ, from, n)))
4126 + n = __copy_from_user(to, from, n);
4127 + else
4128 + memset(to, 0, n);
4129 + return n;
4130 +}
4131 +
4132 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
4133 +{
4134 + if ((long)n < 0 || n > INT_MAX)
4135 + return n;
4136 +
4137 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
4138 + if (!__builtin_constant_p(n))
4139 + check_object_size(from, n, true);
4140 + n = __copy_to_user(to, from, n);
4141 + }
4142 + return n;
4143 +}
4144 +
4145 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
4146 + unsigned long n);
4147 +
4148 +#endif /* __powerpc64__ */
4149 +
4150 extern unsigned long __clear_user(void __user *addr, unsigned long size);
4151
4152 static inline unsigned long clear_user(void __user *addr, unsigned long size)
4153 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
4154 index 429983c..7af363b 100644
4155 --- a/arch/powerpc/kernel/exceptions-64e.S
4156 +++ b/arch/powerpc/kernel/exceptions-64e.S
4157 @@ -587,6 +587,7 @@ storage_fault_common:
4158 std r14,_DAR(r1)
4159 std r15,_DSISR(r1)
4160 addi r3,r1,STACK_FRAME_OVERHEAD
4161 + bl .save_nvgprs
4162 mr r4,r14
4163 mr r5,r15
4164 ld r14,PACA_EXGEN+EX_R14(r13)
4165 @@ -596,8 +597,7 @@ storage_fault_common:
4166 cmpdi r3,0
4167 bne- 1f
4168 b .ret_from_except_lite
4169 -1: bl .save_nvgprs
4170 - mr r5,r3
4171 +1: mr r5,r3
4172 addi r3,r1,STACK_FRAME_OVERHEAD
4173 ld r4,_DAR(r1)
4174 bl .bad_page_fault
4175 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
4176 index 15c5a4f..22a4000 100644
4177 --- a/arch/powerpc/kernel/exceptions-64s.S
4178 +++ b/arch/powerpc/kernel/exceptions-64s.S
4179 @@ -1004,10 +1004,10 @@ handle_page_fault:
4180 11: ld r4,_DAR(r1)
4181 ld r5,_DSISR(r1)
4182 addi r3,r1,STACK_FRAME_OVERHEAD
4183 + bl .save_nvgprs
4184 bl .do_page_fault
4185 cmpdi r3,0
4186 beq+ 13f
4187 - bl .save_nvgprs
4188 mr r5,r3
4189 addi r3,r1,STACK_FRAME_OVERHEAD
4190 lwz r4,_DAR(r1)
4191 diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
4192 index 01e2877..a1ba360 100644
4193 --- a/arch/powerpc/kernel/irq.c
4194 +++ b/arch/powerpc/kernel/irq.c
4195 @@ -560,9 +560,6 @@ struct irq_host *irq_alloc_host(struct device_node *of_node,
4196 host->ops = ops;
4197 host->of_node = of_node_get(of_node);
4198
4199 - if (host->ops->match == NULL)
4200 - host->ops->match = default_irq_host_match;
4201 -
4202 raw_spin_lock_irqsave(&irq_big_lock, flags);
4203
4204 /* If it's a legacy controller, check for duplicates and
4205 @@ -635,7 +632,12 @@ struct irq_host *irq_find_host(struct device_node *node)
4206 */
4207 raw_spin_lock_irqsave(&irq_big_lock, flags);
4208 list_for_each_entry(h, &irq_hosts, link)
4209 - if (h->ops->match(h, node)) {
4210 + if (h->ops->match) {
4211 + if (h->ops->match(h, node)) {
4212 + found = h;
4213 + break;
4214 + }
4215 + } else if (default_irq_host_match(h, node)) {
4216 found = h;
4217 break;
4218 }
4219 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
4220 index 0b6d796..d760ddb 100644
4221 --- a/arch/powerpc/kernel/module_32.c
4222 +++ b/arch/powerpc/kernel/module_32.c
4223 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
4224 me->arch.core_plt_section = i;
4225 }
4226 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
4227 - printk("Module doesn't contain .plt or .init.plt sections.\n");
4228 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
4229 return -ENOEXEC;
4230 }
4231
4232 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
4233
4234 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
4235 /* Init, or core PLT? */
4236 - if (location >= mod->module_core
4237 - && location < mod->module_core + mod->core_size)
4238 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
4239 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
4240 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
4241 - else
4242 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
4243 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
4244 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
4245 + else {
4246 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
4247 + return ~0UL;
4248 + }
4249
4250 /* Find this entry, or if that fails, the next avail. entry */
4251 while (entry->jump[0]) {
4252 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
4253 index d817ab0..b23b18e 100644
4254 --- a/arch/powerpc/kernel/process.c
4255 +++ b/arch/powerpc/kernel/process.c
4256 @@ -676,8 +676,8 @@ void show_regs(struct pt_regs * regs)
4257 * Lookup NIP late so we have the best change of getting the
4258 * above info out without failing
4259 */
4260 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
4261 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
4262 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
4263 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
4264 #endif
4265 show_stack(current, (unsigned long *) regs->gpr[1]);
4266 if (!user_mode(regs))
4267 @@ -1181,10 +1181,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
4268 newsp = stack[0];
4269 ip = stack[STACK_FRAME_LR_SAVE];
4270 if (!firstframe || ip != lr) {
4271 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
4272 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
4273 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
4274 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
4275 - printk(" (%pS)",
4276 + printk(" (%pA)",
4277 (void *)current->ret_stack[curr_frame].ret);
4278 curr_frame--;
4279 }
4280 @@ -1204,7 +1204,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
4281 struct pt_regs *regs = (struct pt_regs *)
4282 (sp + STACK_FRAME_OVERHEAD);
4283 lr = regs->link;
4284 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
4285 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
4286 regs->trap, (void *)regs->nip, (void *)lr);
4287 firstframe = 1;
4288 }
4289 @@ -1279,58 +1279,3 @@ void thread_info_cache_init(void)
4290 }
4291
4292 #endif /* THREAD_SHIFT < PAGE_SHIFT */
4293 -
4294 -unsigned long arch_align_stack(unsigned long sp)
4295 -{
4296 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
4297 - sp -= get_random_int() & ~PAGE_MASK;
4298 - return sp & ~0xf;
4299 -}
4300 -
4301 -static inline unsigned long brk_rnd(void)
4302 -{
4303 - unsigned long rnd = 0;
4304 -
4305 - /* 8MB for 32bit, 1GB for 64bit */
4306 - if (is_32bit_task())
4307 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
4308 - else
4309 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
4310 -
4311 - return rnd << PAGE_SHIFT;
4312 -}
4313 -
4314 -unsigned long arch_randomize_brk(struct mm_struct *mm)
4315 -{
4316 - unsigned long base = mm->brk;
4317 - unsigned long ret;
4318 -
4319 -#ifdef CONFIG_PPC_STD_MMU_64
4320 - /*
4321 - * If we are using 1TB segments and we are allowed to randomise
4322 - * the heap, we can put it above 1TB so it is backed by a 1TB
4323 - * segment. Otherwise the heap will be in the bottom 1TB
4324 - * which always uses 256MB segments and this may result in a
4325 - * performance penalty.
4326 - */
4327 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
4328 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
4329 -#endif
4330 -
4331 - ret = PAGE_ALIGN(base + brk_rnd());
4332 -
4333 - if (ret < mm->brk)
4334 - return mm->brk;
4335 -
4336 - return ret;
4337 -}
4338 -
4339 -unsigned long randomize_et_dyn(unsigned long base)
4340 -{
4341 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
4342 -
4343 - if (ret < base)
4344 - return base;
4345 -
4346 - return ret;
4347 -}
4348 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
4349 index 5b43325..94a5bb4 100644
4350 --- a/arch/powerpc/kernel/ptrace.c
4351 +++ b/arch/powerpc/kernel/ptrace.c
4352 @@ -1702,6 +1702,10 @@ long arch_ptrace(struct task_struct *child, long request,
4353 return ret;
4354 }
4355
4356 +#ifdef CONFIG_GRKERNSEC_SETXID
4357 +extern void gr_delayed_cred_worker(void);
4358 +#endif
4359 +
4360 /*
4361 * We must return the syscall number to actually look up in the table.
4362 * This can be -1L to skip running any syscall at all.
4363 @@ -1712,6 +1716,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
4364
4365 secure_computing(regs->gpr[0]);
4366
4367 +#ifdef CONFIG_GRKERNSEC_SETXID
4368 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
4369 + gr_delayed_cred_worker();
4370 +#endif
4371 +
4372 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
4373 tracehook_report_syscall_entry(regs))
4374 /*
4375 @@ -1746,6 +1755,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
4376 {
4377 int step;
4378
4379 +#ifdef CONFIG_GRKERNSEC_SETXID
4380 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
4381 + gr_delayed_cred_worker();
4382 +#endif
4383 +
4384 audit_syscall_exit(regs);
4385
4386 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
4387 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
4388 index 836a5a1..27289a3 100644
4389 --- a/arch/powerpc/kernel/signal_32.c
4390 +++ b/arch/powerpc/kernel/signal_32.c
4391 @@ -859,7 +859,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
4392 /* Save user registers on the stack */
4393 frame = &rt_sf->uc.uc_mcontext;
4394 addr = frame;
4395 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
4396 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
4397 if (save_user_regs(regs, frame, 0, 1))
4398 goto badframe;
4399 regs->link = current->mm->context.vdso_base + vdso32_rt_sigtramp;
4400 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
4401 index a50b5ec..547078a 100644
4402 --- a/arch/powerpc/kernel/signal_64.c
4403 +++ b/arch/powerpc/kernel/signal_64.c
4404 @@ -429,7 +429,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
4405 current->thread.fpscr.val = 0;
4406
4407 /* Set up to return from userspace. */
4408 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
4409 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
4410 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
4411 } else {
4412 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
4413 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
4414 index c091527..5592625 100644
4415 --- a/arch/powerpc/kernel/traps.c
4416 +++ b/arch/powerpc/kernel/traps.c
4417 @@ -131,6 +131,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
4418 return flags;
4419 }
4420
4421 +extern void gr_handle_kernel_exploit(void);
4422 +
4423 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
4424 int signr)
4425 {
4426 @@ -178,6 +180,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
4427 panic("Fatal exception in interrupt");
4428 if (panic_on_oops)
4429 panic("Fatal exception");
4430 +
4431 + gr_handle_kernel_exploit();
4432 +
4433 do_exit(signr);
4434 }
4435
4436 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
4437 index 7d14bb6..1305601 100644
4438 --- a/arch/powerpc/kernel/vdso.c
4439 +++ b/arch/powerpc/kernel/vdso.c
4440 @@ -35,6 +35,7 @@
4441 #include <asm/firmware.h>
4442 #include <asm/vdso.h>
4443 #include <asm/vdso_datapage.h>
4444 +#include <asm/mman.h>
4445
4446 #include "setup.h"
4447
4448 @@ -219,7 +220,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
4449 vdso_base = VDSO32_MBASE;
4450 #endif
4451
4452 - current->mm->context.vdso_base = 0;
4453 + current->mm->context.vdso_base = ~0UL;
4454
4455 /* vDSO has a problem and was disabled, just don't "enable" it for the
4456 * process
4457 @@ -239,7 +240,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
4458 vdso_base = get_unmapped_area(NULL, vdso_base,
4459 (vdso_pages << PAGE_SHIFT) +
4460 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
4461 - 0, 0);
4462 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
4463 if (IS_ERR_VALUE(vdso_base)) {
4464 rc = vdso_base;
4465 goto fail_mmapsem;
4466 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
4467 index 5eea6f3..5d10396 100644
4468 --- a/arch/powerpc/lib/usercopy_64.c
4469 +++ b/arch/powerpc/lib/usercopy_64.c
4470 @@ -9,22 +9,6 @@
4471 #include <linux/module.h>
4472 #include <asm/uaccess.h>
4473
4474 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
4475 -{
4476 - if (likely(access_ok(VERIFY_READ, from, n)))
4477 - n = __copy_from_user(to, from, n);
4478 - else
4479 - memset(to, 0, n);
4480 - return n;
4481 -}
4482 -
4483 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
4484 -{
4485 - if (likely(access_ok(VERIFY_WRITE, to, n)))
4486 - n = __copy_to_user(to, from, n);
4487 - return n;
4488 -}
4489 -
4490 unsigned long copy_in_user(void __user *to, const void __user *from,
4491 unsigned long n)
4492 {
4493 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
4494 return n;
4495 }
4496
4497 -EXPORT_SYMBOL(copy_from_user);
4498 -EXPORT_SYMBOL(copy_to_user);
4499 EXPORT_SYMBOL(copy_in_user);
4500
4501 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
4502 index 2f0d1b0..36fb5cc 100644
4503 --- a/arch/powerpc/mm/fault.c
4504 +++ b/arch/powerpc/mm/fault.c
4505 @@ -32,6 +32,10 @@
4506 #include <linux/perf_event.h>
4507 #include <linux/magic.h>
4508 #include <linux/ratelimit.h>
4509 +#include <linux/slab.h>
4510 +#include <linux/pagemap.h>
4511 +#include <linux/compiler.h>
4512 +#include <linux/unistd.h>
4513
4514 #include <asm/firmware.h>
4515 #include <asm/page.h>
4516 @@ -43,6 +47,7 @@
4517 #include <asm/tlbflush.h>
4518 #include <asm/siginfo.h>
4519 #include <mm/mmu_decl.h>
4520 +#include <asm/ptrace.h>
4521
4522 #include "icswx.h"
4523
4524 @@ -68,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
4525 }
4526 #endif
4527
4528 +#ifdef CONFIG_PAX_PAGEEXEC
4529 +/*
4530 + * PaX: decide what to do with offenders (regs->nip = fault address)
4531 + *
4532 + * returns 1 when task should be killed
4533 + */
4534 +static int pax_handle_fetch_fault(struct pt_regs *regs)
4535 +{
4536 + return 1;
4537 +}
4538 +
4539 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4540 +{
4541 + unsigned long i;
4542 +
4543 + printk(KERN_ERR "PAX: bytes at PC: ");
4544 + for (i = 0; i < 5; i++) {
4545 + unsigned int c;
4546 + if (get_user(c, (unsigned int __user *)pc+i))
4547 + printk(KERN_CONT "???????? ");
4548 + else
4549 + printk(KERN_CONT "%08x ", c);
4550 + }
4551 + printk("\n");
4552 +}
4553 +#endif
4554 +
4555 /*
4556 * Check whether the instruction at regs->nip is a store using
4557 * an update addressing form which will update r1.
4558 @@ -138,7 +170,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
4559 * indicate errors in DSISR but can validly be set in SRR1.
4560 */
4561 if (trap == 0x400)
4562 - error_code &= 0x48200000;
4563 + error_code &= 0x58200000;
4564 else
4565 is_write = error_code & DSISR_ISSTORE;
4566 #else
4567 @@ -276,7 +308,7 @@ good_area:
4568 * "undefined". Of those that can be set, this is the only
4569 * one which seems bad.
4570 */
4571 - if (error_code & 0x10000000)
4572 + if (error_code & DSISR_GUARDED)
4573 /* Guarded storage error. */
4574 goto bad_area;
4575 #endif /* CONFIG_8xx */
4576 @@ -291,7 +323,7 @@ good_area:
4577 * processors use the same I/D cache coherency mechanism
4578 * as embedded.
4579 */
4580 - if (error_code & DSISR_PROTFAULT)
4581 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
4582 goto bad_area;
4583 #endif /* CONFIG_PPC_STD_MMU */
4584
4585 @@ -360,6 +392,23 @@ bad_area:
4586 bad_area_nosemaphore:
4587 /* User mode accesses cause a SIGSEGV */
4588 if (user_mode(regs)) {
4589 +
4590 +#ifdef CONFIG_PAX_PAGEEXEC
4591 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4592 +#ifdef CONFIG_PPC_STD_MMU
4593 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
4594 +#else
4595 + if (is_exec && regs->nip == address) {
4596 +#endif
4597 + switch (pax_handle_fetch_fault(regs)) {
4598 + }
4599 +
4600 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
4601 + do_group_exit(SIGKILL);
4602 + }
4603 + }
4604 +#endif
4605 +
4606 _exception(SIGSEGV, regs, code, address);
4607 return 0;
4608 }
4609 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
4610 index 67a42ed..1c7210c 100644
4611 --- a/arch/powerpc/mm/mmap_64.c
4612 +++ b/arch/powerpc/mm/mmap_64.c
4613 @@ -91,10 +91,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4614 */
4615 if (mmap_is_legacy()) {
4616 mm->mmap_base = TASK_UNMAPPED_BASE;
4617 +
4618 +#ifdef CONFIG_PAX_RANDMMAP
4619 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4620 + mm->mmap_base += mm->delta_mmap;
4621 +#endif
4622 +
4623 mm->get_unmapped_area = arch_get_unmapped_area;
4624 mm->unmap_area = arch_unmap_area;
4625 } else {
4626 mm->mmap_base = mmap_base();
4627 +
4628 +#ifdef CONFIG_PAX_RANDMMAP
4629 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4630 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4631 +#endif
4632 +
4633 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4634 mm->unmap_area = arch_unmap_area_topdown;
4635 }
4636 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
4637 index 73709f7..6b90313 100644
4638 --- a/arch/powerpc/mm/slice.c
4639 +++ b/arch/powerpc/mm/slice.c
4640 @@ -98,7 +98,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
4641 if ((mm->task_size - len) < addr)
4642 return 0;
4643 vma = find_vma(mm, addr);
4644 - return (!vma || (addr + len) <= vma->vm_start);
4645 + return check_heap_stack_gap(vma, addr, len);
4646 }
4647
4648 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
4649 @@ -256,7 +256,7 @@ full_search:
4650 addr = _ALIGN_UP(addr + 1, 1ul << SLICE_HIGH_SHIFT);
4651 continue;
4652 }
4653 - if (!vma || addr + len <= vma->vm_start) {
4654 + if (check_heap_stack_gap(vma, addr, len)) {
4655 /*
4656 * Remember the place where we stopped the search:
4657 */
4658 @@ -313,10 +313,14 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
4659 }
4660 }
4661
4662 - addr = mm->mmap_base;
4663 - while (addr > len) {
4664 + if (mm->mmap_base < len)
4665 + addr = -ENOMEM;
4666 + else
4667 + addr = mm->mmap_base - len;
4668 +
4669 + while (!IS_ERR_VALUE(addr)) {
4670 /* Go down by chunk size */
4671 - addr = _ALIGN_DOWN(addr - len, 1ul << pshift);
4672 + addr = _ALIGN_DOWN(addr, 1ul << pshift);
4673
4674 /* Check for hit with different page size */
4675 mask = slice_range_to_mask(addr, len);
4676 @@ -336,7 +340,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
4677 * return with success:
4678 */
4679 vma = find_vma(mm, addr);
4680 - if (!vma || (addr + len) <= vma->vm_start) {
4681 + if (check_heap_stack_gap(vma, addr, len)) {
4682 /* remember the address as a hint for next time */
4683 if (use_cache)
4684 mm->free_area_cache = addr;
4685 @@ -348,7 +352,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
4686 mm->cached_hole_size = vma->vm_start - addr;
4687
4688 /* try just below the current vma->vm_start */
4689 - addr = vma->vm_start;
4690 + addr = skip_heap_stack_gap(vma, len);
4691 }
4692
4693 /*
4694 @@ -426,6 +430,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
4695 if (fixed && addr > (mm->task_size - len))
4696 return -EINVAL;
4697
4698 +#ifdef CONFIG_PAX_RANDMMAP
4699 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
4700 + addr = 0;
4701 +#endif
4702 +
4703 /* If hint, make sure it matches our alignment restrictions */
4704 if (!fixed && addr) {
4705 addr = _ALIGN_UP(addr, 1ul << pshift);
4706 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
4707 index 8517d2a..d2738d4 100644
4708 --- a/arch/s390/include/asm/atomic.h
4709 +++ b/arch/s390/include/asm/atomic.h
4710 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
4711 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
4712 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
4713
4714 +#define atomic64_read_unchecked(v) atomic64_read(v)
4715 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4716 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4717 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4718 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4719 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4720 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4721 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4722 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4723 +
4724 #define smp_mb__before_atomic_dec() smp_mb()
4725 #define smp_mb__after_atomic_dec() smp_mb()
4726 #define smp_mb__before_atomic_inc() smp_mb()
4727 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
4728 index 2a30d5a..5e5586f 100644
4729 --- a/arch/s390/include/asm/cache.h
4730 +++ b/arch/s390/include/asm/cache.h
4731 @@ -11,8 +11,10 @@
4732 #ifndef __ARCH_S390_CACHE_H
4733 #define __ARCH_S390_CACHE_H
4734
4735 -#define L1_CACHE_BYTES 256
4736 +#include <linux/const.h>
4737 +
4738 #define L1_CACHE_SHIFT 8
4739 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4740 #define NET_SKB_PAD 32
4741
4742 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4743 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
4744 index 547f1a6..0b22b53 100644
4745 --- a/arch/s390/include/asm/elf.h
4746 +++ b/arch/s390/include/asm/elf.h
4747 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
4748 the loader. We need to make sure that it is out of the way of the program
4749 that it will "exec", and that there is sufficient room for the brk. */
4750
4751 -extern unsigned long randomize_et_dyn(unsigned long base);
4752 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
4753 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
4754 +
4755 +#ifdef CONFIG_PAX_ASLR
4756 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
4757 +
4758 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
4759 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
4760 +#endif
4761
4762 /* This yields a mask that user programs can use to figure out what
4763 instruction set this CPU supports. */
4764 @@ -211,7 +217,4 @@ struct linux_binprm;
4765 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
4766 int arch_setup_additional_pages(struct linux_binprm *, int);
4767
4768 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
4769 -#define arch_randomize_brk arch_randomize_brk
4770 -
4771 #endif
4772 diff --git a/arch/s390/include/asm/system.h b/arch/s390/include/asm/system.h
4773 index d73cc6b..1a296ad 100644
4774 --- a/arch/s390/include/asm/system.h
4775 +++ b/arch/s390/include/asm/system.h
4776 @@ -260,7 +260,7 @@ extern void (*_machine_restart)(char *command);
4777 extern void (*_machine_halt)(void);
4778 extern void (*_machine_power_off)(void);
4779
4780 -extern unsigned long arch_align_stack(unsigned long sp);
4781 +#define arch_align_stack(x) ((x) & ~0xfUL)
4782
4783 static inline int tprot(unsigned long addr)
4784 {
4785 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
4786 index 2b23885..e136e31 100644
4787 --- a/arch/s390/include/asm/uaccess.h
4788 +++ b/arch/s390/include/asm/uaccess.h
4789 @@ -235,6 +235,10 @@ static inline unsigned long __must_check
4790 copy_to_user(void __user *to, const void *from, unsigned long n)
4791 {
4792 might_fault();
4793 +
4794 + if ((long)n < 0)
4795 + return n;
4796 +
4797 if (access_ok(VERIFY_WRITE, to, n))
4798 n = __copy_to_user(to, from, n);
4799 return n;
4800 @@ -260,6 +264,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
4801 static inline unsigned long __must_check
4802 __copy_from_user(void *to, const void __user *from, unsigned long n)
4803 {
4804 + if ((long)n < 0)
4805 + return n;
4806 +
4807 if (__builtin_constant_p(n) && (n <= 256))
4808 return uaccess.copy_from_user_small(n, from, to);
4809 else
4810 @@ -294,6 +301,10 @@ copy_from_user(void *to, const void __user *from, unsigned long n)
4811 unsigned int sz = __compiletime_object_size(to);
4812
4813 might_fault();
4814 +
4815 + if ((long)n < 0)
4816 + return n;
4817 +
4818 if (unlikely(sz != -1 && sz < n)) {
4819 copy_from_user_overflow();
4820 return n;
4821 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
4822 index dfcb343..eda788a 100644
4823 --- a/arch/s390/kernel/module.c
4824 +++ b/arch/s390/kernel/module.c
4825 @@ -161,11 +161,11 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
4826
4827 /* Increase core size by size of got & plt and set start
4828 offsets for got and plt. */
4829 - me->core_size = ALIGN(me->core_size, 4);
4830 - me->arch.got_offset = me->core_size;
4831 - me->core_size += me->arch.got_size;
4832 - me->arch.plt_offset = me->core_size;
4833 - me->core_size += me->arch.plt_size;
4834 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
4835 + me->arch.got_offset = me->core_size_rw;
4836 + me->core_size_rw += me->arch.got_size;
4837 + me->arch.plt_offset = me->core_size_rx;
4838 + me->core_size_rx += me->arch.plt_size;
4839 return 0;
4840 }
4841
4842 @@ -242,7 +242,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
4843 if (info->got_initialized == 0) {
4844 Elf_Addr *gotent;
4845
4846 - gotent = me->module_core + me->arch.got_offset +
4847 + gotent = me->module_core_rw + me->arch.got_offset +
4848 info->got_offset;
4849 *gotent = val;
4850 info->got_initialized = 1;
4851 @@ -266,7 +266,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
4852 else if (r_type == R_390_GOTENT ||
4853 r_type == R_390_GOTPLTENT)
4854 *(unsigned int *) loc =
4855 - (val + (Elf_Addr) me->module_core - loc) >> 1;
4856 + (val + (Elf_Addr) me->module_core_rw - loc) >> 1;
4857 else if (r_type == R_390_GOT64 ||
4858 r_type == R_390_GOTPLT64)
4859 *(unsigned long *) loc = val;
4860 @@ -280,7 +280,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
4861 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
4862 if (info->plt_initialized == 0) {
4863 unsigned int *ip;
4864 - ip = me->module_core + me->arch.plt_offset +
4865 + ip = me->module_core_rx + me->arch.plt_offset +
4866 info->plt_offset;
4867 #ifndef CONFIG_64BIT
4868 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
4869 @@ -305,7 +305,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
4870 val - loc + 0xffffUL < 0x1ffffeUL) ||
4871 (r_type == R_390_PLT32DBL &&
4872 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
4873 - val = (Elf_Addr) me->module_core +
4874 + val = (Elf_Addr) me->module_core_rx +
4875 me->arch.plt_offset +
4876 info->plt_offset;
4877 val += rela->r_addend - loc;
4878 @@ -327,7 +327,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
4879 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
4880 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
4881 val = val + rela->r_addend -
4882 - ((Elf_Addr) me->module_core + me->arch.got_offset);
4883 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
4884 if (r_type == R_390_GOTOFF16)
4885 *(unsigned short *) loc = val;
4886 else if (r_type == R_390_GOTOFF32)
4887 @@ -337,7 +337,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
4888 break;
4889 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
4890 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
4891 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
4892 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
4893 rela->r_addend - loc;
4894 if (r_type == R_390_GOTPC)
4895 *(unsigned int *) loc = val;
4896 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
4897 index e795933..b32563c 100644
4898 --- a/arch/s390/kernel/process.c
4899 +++ b/arch/s390/kernel/process.c
4900 @@ -323,39 +323,3 @@ unsigned long get_wchan(struct task_struct *p)
4901 }
4902 return 0;
4903 }
4904 -
4905 -unsigned long arch_align_stack(unsigned long sp)
4906 -{
4907 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
4908 - sp -= get_random_int() & ~PAGE_MASK;
4909 - return sp & ~0xf;
4910 -}
4911 -
4912 -static inline unsigned long brk_rnd(void)
4913 -{
4914 - /* 8MB for 32bit, 1GB for 64bit */
4915 - if (is_32bit_task())
4916 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
4917 - else
4918 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
4919 -}
4920 -
4921 -unsigned long arch_randomize_brk(struct mm_struct *mm)
4922 -{
4923 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
4924 -
4925 - if (ret < mm->brk)
4926 - return mm->brk;
4927 - return ret;
4928 -}
4929 -
4930 -unsigned long randomize_et_dyn(unsigned long base)
4931 -{
4932 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
4933 -
4934 - if (!(current->flags & PF_RANDOMIZE))
4935 - return base;
4936 - if (ret < base)
4937 - return base;
4938 - return ret;
4939 -}
4940 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
4941 index a0155c0..34cc491 100644
4942 --- a/arch/s390/mm/mmap.c
4943 +++ b/arch/s390/mm/mmap.c
4944 @@ -92,10 +92,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4945 */
4946 if (mmap_is_legacy()) {
4947 mm->mmap_base = TASK_UNMAPPED_BASE;
4948 +
4949 +#ifdef CONFIG_PAX_RANDMMAP
4950 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4951 + mm->mmap_base += mm->delta_mmap;
4952 +#endif
4953 +
4954 mm->get_unmapped_area = arch_get_unmapped_area;
4955 mm->unmap_area = arch_unmap_area;
4956 } else {
4957 mm->mmap_base = mmap_base();
4958 +
4959 +#ifdef CONFIG_PAX_RANDMMAP
4960 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4961 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4962 +#endif
4963 +
4964 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4965 mm->unmap_area = arch_unmap_area_topdown;
4966 }
4967 @@ -167,10 +179,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4968 */
4969 if (mmap_is_legacy()) {
4970 mm->mmap_base = TASK_UNMAPPED_BASE;
4971 +
4972 +#ifdef CONFIG_PAX_RANDMMAP
4973 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4974 + mm->mmap_base += mm->delta_mmap;
4975 +#endif
4976 +
4977 mm->get_unmapped_area = s390_get_unmapped_area;
4978 mm->unmap_area = arch_unmap_area;
4979 } else {
4980 mm->mmap_base = mmap_base();
4981 +
4982 +#ifdef CONFIG_PAX_RANDMMAP
4983 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4984 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4985 +#endif
4986 +
4987 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
4988 mm->unmap_area = arch_unmap_area_topdown;
4989 }
4990 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
4991 index ae3d59f..f65f075 100644
4992 --- a/arch/score/include/asm/cache.h
4993 +++ b/arch/score/include/asm/cache.h
4994 @@ -1,7 +1,9 @@
4995 #ifndef _ASM_SCORE_CACHE_H
4996 #define _ASM_SCORE_CACHE_H
4997
4998 +#include <linux/const.h>
4999 +
5000 #define L1_CACHE_SHIFT 4
5001 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5002 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5003
5004 #endif /* _ASM_SCORE_CACHE_H */
5005 diff --git a/arch/score/include/asm/system.h b/arch/score/include/asm/system.h
5006 index 589d5c7..669e274 100644
5007 --- a/arch/score/include/asm/system.h
5008 +++ b/arch/score/include/asm/system.h
5009 @@ -17,7 +17,7 @@ do { \
5010 #define finish_arch_switch(prev) do {} while (0)
5011
5012 typedef void (*vi_handler_t)(void);
5013 -extern unsigned long arch_align_stack(unsigned long sp);
5014 +#define arch_align_stack(x) (x)
5015
5016 #define mb() barrier()
5017 #define rmb() barrier()
5018 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
5019 index 25d0803..d6c8e36 100644
5020 --- a/arch/score/kernel/process.c
5021 +++ b/arch/score/kernel/process.c
5022 @@ -161,8 +161,3 @@ unsigned long get_wchan(struct task_struct *task)
5023
5024 return task_pt_regs(task)->cp0_epc;
5025 }
5026 -
5027 -unsigned long arch_align_stack(unsigned long sp)
5028 -{
5029 - return sp;
5030 -}
5031 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
5032 index ef9e555..331bd29 100644
5033 --- a/arch/sh/include/asm/cache.h
5034 +++ b/arch/sh/include/asm/cache.h
5035 @@ -9,10 +9,11 @@
5036 #define __ASM_SH_CACHE_H
5037 #ifdef __KERNEL__
5038
5039 +#include <linux/const.h>
5040 #include <linux/init.h>
5041 #include <cpu/cache.h>
5042
5043 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5044 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5045
5046 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
5047
5048 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
5049 index afeb710..d1d1289 100644
5050 --- a/arch/sh/mm/mmap.c
5051 +++ b/arch/sh/mm/mmap.c
5052 @@ -74,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
5053 addr = PAGE_ALIGN(addr);
5054
5055 vma = find_vma(mm, addr);
5056 - if (TASK_SIZE - len >= addr &&
5057 - (!vma || addr + len <= vma->vm_start))
5058 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len))
5059 return addr;
5060 }
5061
5062 @@ -106,7 +105,7 @@ full_search:
5063 }
5064 return -ENOMEM;
5065 }
5066 - if (likely(!vma || addr + len <= vma->vm_start)) {
5067 + if (likely(check_heap_stack_gap(vma, addr, len))) {
5068 /*
5069 * Remember the place where we stopped the search:
5070 */
5071 @@ -157,8 +156,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
5072 addr = PAGE_ALIGN(addr);
5073
5074 vma = find_vma(mm, addr);
5075 - if (TASK_SIZE - len >= addr &&
5076 - (!vma || addr + len <= vma->vm_start))
5077 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len))
5078 return addr;
5079 }
5080
5081 @@ -179,7 +177,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
5082 /* make sure it can fit in the remaining address space */
5083 if (likely(addr > len)) {
5084 vma = find_vma(mm, addr-len);
5085 - if (!vma || addr <= vma->vm_start) {
5086 + if (check_heap_stack_gap(vma, addr - len, len)) {
5087 /* remember the address as a hint for next time */
5088 return (mm->free_area_cache = addr-len);
5089 }
5090 @@ -188,18 +186,18 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
5091 if (unlikely(mm->mmap_base < len))
5092 goto bottomup;
5093
5094 - addr = mm->mmap_base-len;
5095 - if (do_colour_align)
5096 - addr = COLOUR_ALIGN_DOWN(addr, pgoff);
5097 + addr = mm->mmap_base - len;
5098
5099 do {
5100 + if (do_colour_align)
5101 + addr = COLOUR_ALIGN_DOWN(addr, pgoff);
5102 /*
5103 * Lookup failure means no vma is above this address,
5104 * else if new region fits below vma->vm_start,
5105 * return with success:
5106 */
5107 vma = find_vma(mm, addr);
5108 - if (likely(!vma || addr+len <= vma->vm_start)) {
5109 + if (likely(check_heap_stack_gap(vma, addr, len))) {
5110 /* remember the address as a hint for next time */
5111 return (mm->free_area_cache = addr);
5112 }
5113 @@ -209,10 +207,8 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
5114 mm->cached_hole_size = vma->vm_start - addr;
5115
5116 /* try just below the current vma->vm_start */
5117 - addr = vma->vm_start-len;
5118 - if (do_colour_align)
5119 - addr = COLOUR_ALIGN_DOWN(addr, pgoff);
5120 - } while (likely(len < vma->vm_start));
5121 + addr = skip_heap_stack_gap(vma, len);
5122 + } while (!IS_ERR_VALUE(addr));
5123
5124 bottomup:
5125 /*
5126 diff --git a/arch/sparc/Makefile b/arch/sparc/Makefile
5127 index eddcfb3..b117d90 100644
5128 --- a/arch/sparc/Makefile
5129 +++ b/arch/sparc/Makefile
5130 @@ -75,7 +75,7 @@ drivers-$(CONFIG_OPROFILE) += arch/sparc/oprofile/
5131 # Export what is needed by arch/sparc/boot/Makefile
5132 export VMLINUX_INIT VMLINUX_MAIN
5133 VMLINUX_INIT := $(head-y) $(init-y)
5134 -VMLINUX_MAIN := $(core-y) kernel/ mm/ fs/ ipc/ security/ crypto/ block/
5135 +VMLINUX_MAIN := $(core-y) kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
5136 VMLINUX_MAIN += $(patsubst %/, %/lib.a, $(libs-y)) $(libs-y)
5137 VMLINUX_MAIN += $(drivers-y) $(net-y)
5138
5139 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
5140 index 9f421df..b81fc12 100644
5141 --- a/arch/sparc/include/asm/atomic_64.h
5142 +++ b/arch/sparc/include/asm/atomic_64.h
5143 @@ -14,18 +14,40 @@
5144 #define ATOMIC64_INIT(i) { (i) }
5145
5146 #define atomic_read(v) (*(volatile int *)&(v)->counter)
5147 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
5148 +{
5149 + return v->counter;
5150 +}
5151 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
5152 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
5153 +{
5154 + return v->counter;
5155 +}
5156
5157 #define atomic_set(v, i) (((v)->counter) = i)
5158 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
5159 +{
5160 + v->counter = i;
5161 +}
5162 #define atomic64_set(v, i) (((v)->counter) = i)
5163 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
5164 +{
5165 + v->counter = i;
5166 +}
5167
5168 extern void atomic_add(int, atomic_t *);
5169 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
5170 extern void atomic64_add(long, atomic64_t *);
5171 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
5172 extern void atomic_sub(int, atomic_t *);
5173 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
5174 extern void atomic64_sub(long, atomic64_t *);
5175 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
5176
5177 extern int atomic_add_ret(int, atomic_t *);
5178 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
5179 extern long atomic64_add_ret(long, atomic64_t *);
5180 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
5181 extern int atomic_sub_ret(int, atomic_t *);
5182 extern long atomic64_sub_ret(long, atomic64_t *);
5183
5184 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
5185 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
5186
5187 #define atomic_inc_return(v) atomic_add_ret(1, v)
5188 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
5189 +{
5190 + return atomic_add_ret_unchecked(1, v);
5191 +}
5192 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
5193 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
5194 +{
5195 + return atomic64_add_ret_unchecked(1, v);
5196 +}
5197
5198 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
5199 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
5200
5201 #define atomic_add_return(i, v) atomic_add_ret(i, v)
5202 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
5203 +{
5204 + return atomic_add_ret_unchecked(i, v);
5205 +}
5206 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
5207 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
5208 +{
5209 + return atomic64_add_ret_unchecked(i, v);
5210 +}
5211
5212 /*
5213 * atomic_inc_and_test - increment and test
5214 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
5215 * other cases.
5216 */
5217 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
5218 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
5219 +{
5220 + return atomic_inc_return_unchecked(v) == 0;
5221 +}
5222 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
5223
5224 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
5225 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
5226 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
5227
5228 #define atomic_inc(v) atomic_add(1, v)
5229 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
5230 +{
5231 + atomic_add_unchecked(1, v);
5232 +}
5233 #define atomic64_inc(v) atomic64_add(1, v)
5234 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
5235 +{
5236 + atomic64_add_unchecked(1, v);
5237 +}
5238
5239 #define atomic_dec(v) atomic_sub(1, v)
5240 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
5241 +{
5242 + atomic_sub_unchecked(1, v);
5243 +}
5244 #define atomic64_dec(v) atomic64_sub(1, v)
5245 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
5246 +{
5247 + atomic64_sub_unchecked(1, v);
5248 +}
5249
5250 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
5251 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
5252
5253 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
5254 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
5255 +{
5256 + return cmpxchg(&v->counter, old, new);
5257 +}
5258 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
5259 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
5260 +{
5261 + return xchg(&v->counter, new);
5262 +}
5263
5264 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
5265 {
5266 - int c, old;
5267 + int c, old, new;
5268 c = atomic_read(v);
5269 for (;;) {
5270 - if (unlikely(c == (u)))
5271 + if (unlikely(c == u))
5272 break;
5273 - old = atomic_cmpxchg((v), c, c + (a));
5274 +
5275 + asm volatile("addcc %2, %0, %0\n"
5276 +
5277 +#ifdef CONFIG_PAX_REFCOUNT
5278 + "tvs %%icc, 6\n"
5279 +#endif
5280 +
5281 + : "=r" (new)
5282 + : "0" (c), "ir" (a)
5283 + : "cc");
5284 +
5285 + old = atomic_cmpxchg(v, c, new);
5286 if (likely(old == c))
5287 break;
5288 c = old;
5289 @@ -89,20 +166,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
5290 #define atomic64_cmpxchg(v, o, n) \
5291 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
5292 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
5293 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
5294 +{
5295 + return xchg(&v->counter, new);
5296 +}
5297
5298 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
5299 {
5300 - long c, old;
5301 + long c, old, new;
5302 c = atomic64_read(v);
5303 for (;;) {
5304 - if (unlikely(c == (u)))
5305 + if (unlikely(c == u))
5306 break;
5307 - old = atomic64_cmpxchg((v), c, c + (a));
5308 +
5309 + asm volatile("addcc %2, %0, %0\n"
5310 +
5311 +#ifdef CONFIG_PAX_REFCOUNT
5312 + "tvs %%xcc, 6\n"
5313 +#endif
5314 +
5315 + : "=r" (new)
5316 + : "0" (c), "ir" (a)
5317 + : "cc");
5318 +
5319 + old = atomic64_cmpxchg(v, c, new);
5320 if (likely(old == c))
5321 break;
5322 c = old;
5323 }
5324 - return c != (u);
5325 + return c != u;
5326 }
5327
5328 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
5329 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
5330 index 69358b5..9d0d492 100644
5331 --- a/arch/sparc/include/asm/cache.h
5332 +++ b/arch/sparc/include/asm/cache.h
5333 @@ -7,10 +7,12 @@
5334 #ifndef _SPARC_CACHE_H
5335 #define _SPARC_CACHE_H
5336
5337 +#include <linux/const.h>
5338 +
5339 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
5340
5341 #define L1_CACHE_SHIFT 5
5342 -#define L1_CACHE_BYTES 32
5343 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5344
5345 #ifdef CONFIG_SPARC32
5346 #define SMP_CACHE_BYTES_SHIFT 5
5347 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
5348 index 4269ca6..e3da77f 100644
5349 --- a/arch/sparc/include/asm/elf_32.h
5350 +++ b/arch/sparc/include/asm/elf_32.h
5351 @@ -114,6 +114,13 @@ typedef struct {
5352
5353 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
5354
5355 +#ifdef CONFIG_PAX_ASLR
5356 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
5357 +
5358 +#define PAX_DELTA_MMAP_LEN 16
5359 +#define PAX_DELTA_STACK_LEN 16
5360 +#endif
5361 +
5362 /* This yields a mask that user programs can use to figure out what
5363 instruction set this cpu supports. This can NOT be done in userspace
5364 on Sparc. */
5365 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
5366 index 7df8b7f..4946269 100644
5367 --- a/arch/sparc/include/asm/elf_64.h
5368 +++ b/arch/sparc/include/asm/elf_64.h
5369 @@ -180,6 +180,13 @@ typedef struct {
5370 #define ELF_ET_DYN_BASE 0x0000010000000000UL
5371 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
5372
5373 +#ifdef CONFIG_PAX_ASLR
5374 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
5375 +
5376 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
5377 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
5378 +#endif
5379 +
5380 extern unsigned long sparc64_elf_hwcap;
5381 #define ELF_HWCAP sparc64_elf_hwcap
5382
5383 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
5384 index ca2b344..c6084f89 100644
5385 --- a/arch/sparc/include/asm/pgalloc_32.h
5386 +++ b/arch/sparc/include/asm/pgalloc_32.h
5387 @@ -37,6 +37,7 @@ BTFIXUPDEF_CALL(void, free_pgd_fast, pgd_t *)
5388 BTFIXUPDEF_CALL(void, pgd_set, pgd_t *, pmd_t *)
5389 #define pgd_set(pgdp,pmdp) BTFIXUP_CALL(pgd_set)(pgdp,pmdp)
5390 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
5391 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
5392
5393 BTFIXUPDEF_CALL(pmd_t *, pmd_alloc_one, struct mm_struct *, unsigned long)
5394 #define pmd_alloc_one(mm, address) BTFIXUP_CALL(pmd_alloc_one)(mm, address)
5395 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
5396 index 40b2d7a..22a665b 100644
5397 --- a/arch/sparc/include/asm/pgalloc_64.h
5398 +++ b/arch/sparc/include/asm/pgalloc_64.h
5399 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
5400 }
5401
5402 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
5403 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
5404
5405 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
5406 {
5407 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
5408 index a790cc6..091ed94 100644
5409 --- a/arch/sparc/include/asm/pgtable_32.h
5410 +++ b/arch/sparc/include/asm/pgtable_32.h
5411 @@ -45,6 +45,13 @@ BTFIXUPDEF_SIMM13(user_ptrs_per_pgd)
5412 BTFIXUPDEF_INT(page_none)
5413 BTFIXUPDEF_INT(page_copy)
5414 BTFIXUPDEF_INT(page_readonly)
5415 +
5416 +#ifdef CONFIG_PAX_PAGEEXEC
5417 +BTFIXUPDEF_INT(page_shared_noexec)
5418 +BTFIXUPDEF_INT(page_copy_noexec)
5419 +BTFIXUPDEF_INT(page_readonly_noexec)
5420 +#endif
5421 +
5422 BTFIXUPDEF_INT(page_kernel)
5423
5424 #define PMD_SHIFT SUN4C_PMD_SHIFT
5425 @@ -66,6 +73,16 @@ extern pgprot_t PAGE_SHARED;
5426 #define PAGE_COPY __pgprot(BTFIXUP_INT(page_copy))
5427 #define PAGE_READONLY __pgprot(BTFIXUP_INT(page_readonly))
5428
5429 +#ifdef CONFIG_PAX_PAGEEXEC
5430 +extern pgprot_t PAGE_SHARED_NOEXEC;
5431 +# define PAGE_COPY_NOEXEC __pgprot(BTFIXUP_INT(page_copy_noexec))
5432 +# define PAGE_READONLY_NOEXEC __pgprot(BTFIXUP_INT(page_readonly_noexec))
5433 +#else
5434 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
5435 +# define PAGE_COPY_NOEXEC PAGE_COPY
5436 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
5437 +#endif
5438 +
5439 extern unsigned long page_kernel;
5440
5441 #ifdef MODULE
5442 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
5443 index f6ae2b2..b03ffc7 100644
5444 --- a/arch/sparc/include/asm/pgtsrmmu.h
5445 +++ b/arch/sparc/include/asm/pgtsrmmu.h
5446 @@ -115,6 +115,13 @@
5447 SRMMU_EXEC | SRMMU_REF)
5448 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
5449 SRMMU_EXEC | SRMMU_REF)
5450 +
5451 +#ifdef CONFIG_PAX_PAGEEXEC
5452 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
5453 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
5454 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
5455 +#endif
5456 +
5457 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
5458 SRMMU_DIRTY | SRMMU_REF)
5459
5460 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
5461 index 9689176..63c18ea 100644
5462 --- a/arch/sparc/include/asm/spinlock_64.h
5463 +++ b/arch/sparc/include/asm/spinlock_64.h
5464 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
5465
5466 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
5467
5468 -static void inline arch_read_lock(arch_rwlock_t *lock)
5469 +static inline void arch_read_lock(arch_rwlock_t *lock)
5470 {
5471 unsigned long tmp1, tmp2;
5472
5473 __asm__ __volatile__ (
5474 "1: ldsw [%2], %0\n"
5475 " brlz,pn %0, 2f\n"
5476 -"4: add %0, 1, %1\n"
5477 +"4: addcc %0, 1, %1\n"
5478 +
5479 +#ifdef CONFIG_PAX_REFCOUNT
5480 +" tvs %%icc, 6\n"
5481 +#endif
5482 +
5483 " cas [%2], %0, %1\n"
5484 " cmp %0, %1\n"
5485 " bne,pn %%icc, 1b\n"
5486 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
5487 " .previous"
5488 : "=&r" (tmp1), "=&r" (tmp2)
5489 : "r" (lock)
5490 - : "memory");
5491 + : "memory", "cc");
5492 }
5493
5494 -static int inline arch_read_trylock(arch_rwlock_t *lock)
5495 +static inline int arch_read_trylock(arch_rwlock_t *lock)
5496 {
5497 int tmp1, tmp2;
5498
5499 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
5500 "1: ldsw [%2], %0\n"
5501 " brlz,a,pn %0, 2f\n"
5502 " mov 0, %0\n"
5503 -" add %0, 1, %1\n"
5504 +" addcc %0, 1, %1\n"
5505 +
5506 +#ifdef CONFIG_PAX_REFCOUNT
5507 +" tvs %%icc, 6\n"
5508 +#endif
5509 +
5510 " cas [%2], %0, %1\n"
5511 " cmp %0, %1\n"
5512 " bne,pn %%icc, 1b\n"
5513 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
5514 return tmp1;
5515 }
5516
5517 -static void inline arch_read_unlock(arch_rwlock_t *lock)
5518 +static inline void arch_read_unlock(arch_rwlock_t *lock)
5519 {
5520 unsigned long tmp1, tmp2;
5521
5522 __asm__ __volatile__(
5523 "1: lduw [%2], %0\n"
5524 -" sub %0, 1, %1\n"
5525 +" subcc %0, 1, %1\n"
5526 +
5527 +#ifdef CONFIG_PAX_REFCOUNT
5528 +" tvs %%icc, 6\n"
5529 +#endif
5530 +
5531 " cas [%2], %0, %1\n"
5532 " cmp %0, %1\n"
5533 " bne,pn %%xcc, 1b\n"
5534 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
5535 : "memory");
5536 }
5537
5538 -static void inline arch_write_lock(arch_rwlock_t *lock)
5539 +static inline void arch_write_lock(arch_rwlock_t *lock)
5540 {
5541 unsigned long mask, tmp1, tmp2;
5542
5543 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
5544 : "memory");
5545 }
5546
5547 -static void inline arch_write_unlock(arch_rwlock_t *lock)
5548 +static inline void arch_write_unlock(arch_rwlock_t *lock)
5549 {
5550 __asm__ __volatile__(
5551 " stw %%g0, [%0]"
5552 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
5553 : "memory");
5554 }
5555
5556 -static int inline arch_write_trylock(arch_rwlock_t *lock)
5557 +static inline int arch_write_trylock(arch_rwlock_t *lock)
5558 {
5559 unsigned long mask, tmp1, tmp2, result;
5560
5561 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
5562 index c2a1080..21ed218 100644
5563 --- a/arch/sparc/include/asm/thread_info_32.h
5564 +++ b/arch/sparc/include/asm/thread_info_32.h
5565 @@ -50,6 +50,8 @@ struct thread_info {
5566 unsigned long w_saved;
5567
5568 struct restart_block restart_block;
5569 +
5570 + unsigned long lowest_stack;
5571 };
5572
5573 /*
5574 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
5575 index 01d057f..13a7d2f 100644
5576 --- a/arch/sparc/include/asm/thread_info_64.h
5577 +++ b/arch/sparc/include/asm/thread_info_64.h
5578 @@ -63,6 +63,8 @@ struct thread_info {
5579 struct pt_regs *kern_una_regs;
5580 unsigned int kern_una_insn;
5581
5582 + unsigned long lowest_stack;
5583 +
5584 unsigned long fpregs[0] __attribute__ ((aligned(64)));
5585 };
5586
5587 @@ -214,10 +216,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
5588 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
5589 /* flag bit 6 is available */
5590 #define TIF_32BIT 7 /* 32-bit binary */
5591 -/* flag bit 8 is available */
5592 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
5593 #define TIF_SECCOMP 9 /* secure computing */
5594 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
5595 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
5596 +
5597 /* NOTE: Thread flags >= 12 should be ones we have no interest
5598 * in using in assembly, else we can't use the mask as
5599 * an immediate value in instructions such as andcc.
5600 @@ -236,12 +239,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
5601 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
5602 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
5603 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
5604 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
5605
5606 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
5607 _TIF_DO_NOTIFY_RESUME_MASK | \
5608 _TIF_NEED_RESCHED)
5609 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
5610
5611 +#define _TIF_WORK_SYSCALL \
5612 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
5613 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
5614 +
5615 +
5616 /*
5617 * Thread-synchronous status.
5618 *
5619 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
5620 index e88fbe5..96b0ce5 100644
5621 --- a/arch/sparc/include/asm/uaccess.h
5622 +++ b/arch/sparc/include/asm/uaccess.h
5623 @@ -1,5 +1,13 @@
5624 #ifndef ___ASM_SPARC_UACCESS_H
5625 #define ___ASM_SPARC_UACCESS_H
5626 +
5627 +#ifdef __KERNEL__
5628 +#ifndef __ASSEMBLY__
5629 +#include <linux/types.h>
5630 +extern void check_object_size(const void *ptr, unsigned long n, bool to);
5631 +#endif
5632 +#endif
5633 +
5634 #if defined(__sparc__) && defined(__arch64__)
5635 #include <asm/uaccess_64.h>
5636 #else
5637 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
5638 index 8303ac4..07f333d 100644
5639 --- a/arch/sparc/include/asm/uaccess_32.h
5640 +++ b/arch/sparc/include/asm/uaccess_32.h
5641 @@ -249,27 +249,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
5642
5643 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
5644 {
5645 - if (n && __access_ok((unsigned long) to, n))
5646 + if ((long)n < 0)
5647 + return n;
5648 +
5649 + if (n && __access_ok((unsigned long) to, n)) {
5650 + if (!__builtin_constant_p(n))
5651 + check_object_size(from, n, true);
5652 return __copy_user(to, (__force void __user *) from, n);
5653 - else
5654 + } else
5655 return n;
5656 }
5657
5658 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
5659 {
5660 + if ((long)n < 0)
5661 + return n;
5662 +
5663 + if (!__builtin_constant_p(n))
5664 + check_object_size(from, n, true);
5665 +
5666 return __copy_user(to, (__force void __user *) from, n);
5667 }
5668
5669 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
5670 {
5671 - if (n && __access_ok((unsigned long) from, n))
5672 + if ((long)n < 0)
5673 + return n;
5674 +
5675 + if (n && __access_ok((unsigned long) from, n)) {
5676 + if (!__builtin_constant_p(n))
5677 + check_object_size(to, n, false);
5678 return __copy_user((__force void __user *) to, from, n);
5679 - else
5680 + } else
5681 return n;
5682 }
5683
5684 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
5685 {
5686 + if ((long)n < 0)
5687 + return n;
5688 +
5689 return __copy_user((__force void __user *) to, from, n);
5690 }
5691
5692 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
5693 index 3e1449f..5293a0e 100644
5694 --- a/arch/sparc/include/asm/uaccess_64.h
5695 +++ b/arch/sparc/include/asm/uaccess_64.h
5696 @@ -10,6 +10,7 @@
5697 #include <linux/compiler.h>
5698 #include <linux/string.h>
5699 #include <linux/thread_info.h>
5700 +#include <linux/kernel.h>
5701 #include <asm/asi.h>
5702 #include <asm/system.h>
5703 #include <asm/spitfire.h>
5704 @@ -213,8 +214,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
5705 static inline unsigned long __must_check
5706 copy_from_user(void *to, const void __user *from, unsigned long size)
5707 {
5708 - unsigned long ret = ___copy_from_user(to, from, size);
5709 + unsigned long ret;
5710
5711 + if ((long)size < 0 || size > INT_MAX)
5712 + return size;
5713 +
5714 + if (!__builtin_constant_p(size))
5715 + check_object_size(to, size, false);
5716 +
5717 + ret = ___copy_from_user(to, from, size);
5718 if (unlikely(ret))
5719 ret = copy_from_user_fixup(to, from, size);
5720
5721 @@ -230,8 +238,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
5722 static inline unsigned long __must_check
5723 copy_to_user(void __user *to, const void *from, unsigned long size)
5724 {
5725 - unsigned long ret = ___copy_to_user(to, from, size);
5726 + unsigned long ret;
5727
5728 + if ((long)size < 0 || size > INT_MAX)
5729 + return size;
5730 +
5731 + if (!__builtin_constant_p(size))
5732 + check_object_size(from, size, true);
5733 +
5734 + ret = ___copy_to_user(to, from, size);
5735 if (unlikely(ret))
5736 ret = copy_to_user_fixup(to, from, size);
5737 return ret;
5738 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
5739 index cb85458..e063f17 100644
5740 --- a/arch/sparc/kernel/Makefile
5741 +++ b/arch/sparc/kernel/Makefile
5742 @@ -3,7 +3,7 @@
5743 #
5744
5745 asflags-y := -ansi
5746 -ccflags-y := -Werror
5747 +#ccflags-y := -Werror
5748
5749 extra-y := head_$(BITS).o
5750 extra-y += init_task.o
5751 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
5752 index f793742..4d880af 100644
5753 --- a/arch/sparc/kernel/process_32.c
5754 +++ b/arch/sparc/kernel/process_32.c
5755 @@ -204,7 +204,7 @@ void __show_backtrace(unsigned long fp)
5756 rw->ins[4], rw->ins[5],
5757 rw->ins[6],
5758 rw->ins[7]);
5759 - printk("%pS\n", (void *) rw->ins[7]);
5760 + printk("%pA\n", (void *) rw->ins[7]);
5761 rw = (struct reg_window32 *) rw->ins[6];
5762 }
5763 spin_unlock_irqrestore(&sparc_backtrace_lock, flags);
5764 @@ -271,14 +271,14 @@ void show_regs(struct pt_regs *r)
5765
5766 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
5767 r->psr, r->pc, r->npc, r->y, print_tainted());
5768 - printk("PC: <%pS>\n", (void *) r->pc);
5769 + printk("PC: <%pA>\n", (void *) r->pc);
5770 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
5771 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
5772 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
5773 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
5774 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
5775 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
5776 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
5777 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
5778
5779 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
5780 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
5781 @@ -313,7 +313,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
5782 rw = (struct reg_window32 *) fp;
5783 pc = rw->ins[7];
5784 printk("[%08lx : ", pc);
5785 - printk("%pS ] ", (void *) pc);
5786 + printk("%pA ] ", (void *) pc);
5787 fp = rw->ins[6];
5788 } while (++count < 16);
5789 printk("\n");
5790 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
5791 index 39d8b05..d1a7d90 100644
5792 --- a/arch/sparc/kernel/process_64.c
5793 +++ b/arch/sparc/kernel/process_64.c
5794 @@ -182,14 +182,14 @@ static void show_regwindow(struct pt_regs *regs)
5795 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
5796 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
5797 if (regs->tstate & TSTATE_PRIV)
5798 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
5799 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
5800 }
5801
5802 void show_regs(struct pt_regs *regs)
5803 {
5804 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
5805 regs->tpc, regs->tnpc, regs->y, print_tainted());
5806 - printk("TPC: <%pS>\n", (void *) regs->tpc);
5807 + printk("TPC: <%pA>\n", (void *) regs->tpc);
5808 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
5809 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
5810 regs->u_regs[3]);
5811 @@ -202,7 +202,7 @@ void show_regs(struct pt_regs *regs)
5812 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
5813 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
5814 regs->u_regs[15]);
5815 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
5816 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
5817 show_regwindow(regs);
5818 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
5819 }
5820 @@ -287,7 +287,7 @@ void arch_trigger_all_cpu_backtrace(void)
5821 ((tp && tp->task) ? tp->task->pid : -1));
5822
5823 if (gp->tstate & TSTATE_PRIV) {
5824 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
5825 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
5826 (void *) gp->tpc,
5827 (void *) gp->o7,
5828 (void *) gp->i7,
5829 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
5830 index 9388844..0075fd2 100644
5831 --- a/arch/sparc/kernel/ptrace_64.c
5832 +++ b/arch/sparc/kernel/ptrace_64.c
5833 @@ -1058,6 +1058,10 @@ long arch_ptrace(struct task_struct *child, long request,
5834 return ret;
5835 }
5836
5837 +#ifdef CONFIG_GRKERNSEC_SETXID
5838 +extern void gr_delayed_cred_worker(void);
5839 +#endif
5840 +
5841 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
5842 {
5843 int ret = 0;
5844 @@ -1065,6 +1069,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
5845 /* do the secure computing check first */
5846 secure_computing(regs->u_regs[UREG_G1]);
5847
5848 +#ifdef CONFIG_GRKERNSEC_SETXID
5849 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5850 + gr_delayed_cred_worker();
5851 +#endif
5852 +
5853 if (test_thread_flag(TIF_SYSCALL_TRACE))
5854 ret = tracehook_report_syscall_entry(regs);
5855
5856 @@ -1085,6 +1094,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
5857
5858 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
5859 {
5860 +#ifdef CONFIG_GRKERNSEC_SETXID
5861 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5862 + gr_delayed_cred_worker();
5863 +#endif
5864 +
5865 audit_syscall_exit(regs);
5866
5867 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
5868 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
5869 index 42b282f..28ce9f2 100644
5870 --- a/arch/sparc/kernel/sys_sparc_32.c
5871 +++ b/arch/sparc/kernel/sys_sparc_32.c
5872 @@ -56,7 +56,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
5873 if (ARCH_SUN4C && len > 0x20000000)
5874 return -ENOMEM;
5875 if (!addr)
5876 - addr = TASK_UNMAPPED_BASE;
5877 + addr = current->mm->mmap_base;
5878
5879 if (flags & MAP_SHARED)
5880 addr = COLOUR_ALIGN(addr);
5881 @@ -71,7 +71,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
5882 }
5883 if (TASK_SIZE - PAGE_SIZE - len < addr)
5884 return -ENOMEM;
5885 - if (!vmm || addr + len <= vmm->vm_start)
5886 + if (check_heap_stack_gap(vmm, addr, len))
5887 return addr;
5888 addr = vmm->vm_end;
5889 if (flags & MAP_SHARED)
5890 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
5891 index 232df99..cee1f9c 100644
5892 --- a/arch/sparc/kernel/sys_sparc_64.c
5893 +++ b/arch/sparc/kernel/sys_sparc_64.c
5894 @@ -124,7 +124,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
5895 /* We do not accept a shared mapping if it would violate
5896 * cache aliasing constraints.
5897 */
5898 - if ((flags & MAP_SHARED) &&
5899 + if ((filp || (flags & MAP_SHARED)) &&
5900 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
5901 return -EINVAL;
5902 return addr;
5903 @@ -139,6 +139,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
5904 if (filp || (flags & MAP_SHARED))
5905 do_color_align = 1;
5906
5907 +#ifdef CONFIG_PAX_RANDMMAP
5908 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
5909 +#endif
5910 +
5911 if (addr) {
5912 if (do_color_align)
5913 addr = COLOUR_ALIGN(addr, pgoff);
5914 @@ -146,15 +150,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
5915 addr = PAGE_ALIGN(addr);
5916
5917 vma = find_vma(mm, addr);
5918 - if (task_size - len >= addr &&
5919 - (!vma || addr + len <= vma->vm_start))
5920 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len))
5921 return addr;
5922 }
5923
5924 if (len > mm->cached_hole_size) {
5925 - start_addr = addr = mm->free_area_cache;
5926 + start_addr = addr = mm->free_area_cache;
5927 } else {
5928 - start_addr = addr = TASK_UNMAPPED_BASE;
5929 + start_addr = addr = mm->mmap_base;
5930 mm->cached_hole_size = 0;
5931 }
5932
5933 @@ -174,14 +177,14 @@ full_search:
5934 vma = find_vma(mm, VA_EXCLUDE_END);
5935 }
5936 if (unlikely(task_size < addr)) {
5937 - if (start_addr != TASK_UNMAPPED_BASE) {
5938 - start_addr = addr = TASK_UNMAPPED_BASE;
5939 + if (start_addr != mm->mmap_base) {
5940 + start_addr = addr = mm->mmap_base;
5941 mm->cached_hole_size = 0;
5942 goto full_search;
5943 }
5944 return -ENOMEM;
5945 }
5946 - if (likely(!vma || addr + len <= vma->vm_start)) {
5947 + if (likely(check_heap_stack_gap(vma, addr, len))) {
5948 /*
5949 * Remember the place where we stopped the search:
5950 */
5951 @@ -215,7 +218,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
5952 /* We do not accept a shared mapping if it would violate
5953 * cache aliasing constraints.
5954 */
5955 - if ((flags & MAP_SHARED) &&
5956 + if ((filp || (flags & MAP_SHARED)) &&
5957 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
5958 return -EINVAL;
5959 return addr;
5960 @@ -236,8 +239,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
5961 addr = PAGE_ALIGN(addr);
5962
5963 vma = find_vma(mm, addr);
5964 - if (task_size - len >= addr &&
5965 - (!vma || addr + len <= vma->vm_start))
5966 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len))
5967 return addr;
5968 }
5969
5970 @@ -258,7 +260,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
5971 /* make sure it can fit in the remaining address space */
5972 if (likely(addr > len)) {
5973 vma = find_vma(mm, addr-len);
5974 - if (!vma || addr <= vma->vm_start) {
5975 + if (check_heap_stack_gap(vma, addr - len, len)) {
5976 /* remember the address as a hint for next time */
5977 return (mm->free_area_cache = addr-len);
5978 }
5979 @@ -267,18 +269,18 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
5980 if (unlikely(mm->mmap_base < len))
5981 goto bottomup;
5982
5983 - addr = mm->mmap_base-len;
5984 - if (do_color_align)
5985 - addr = COLOUR_ALIGN_DOWN(addr, pgoff);
5986 + addr = mm->mmap_base - len;
5987
5988 do {
5989 + if (do_color_align)
5990 + addr = COLOUR_ALIGN_DOWN(addr, pgoff);
5991 /*
5992 * Lookup failure means no vma is above this address,
5993 * else if new region fits below vma->vm_start,
5994 * return with success:
5995 */
5996 vma = find_vma(mm, addr);
5997 - if (likely(!vma || addr+len <= vma->vm_start)) {
5998 + if (likely(check_heap_stack_gap(vma, addr, len))) {
5999 /* remember the address as a hint for next time */
6000 return (mm->free_area_cache = addr);
6001 }
6002 @@ -288,10 +290,8 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
6003 mm->cached_hole_size = vma->vm_start - addr;
6004
6005 /* try just below the current vma->vm_start */
6006 - addr = vma->vm_start-len;
6007 - if (do_color_align)
6008 - addr = COLOUR_ALIGN_DOWN(addr, pgoff);
6009 - } while (likely(len < vma->vm_start));
6010 + addr = skip_heap_stack_gap(vma, len);
6011 + } while (!IS_ERR_VALUE(addr));
6012
6013 bottomup:
6014 /*
6015 @@ -390,6 +390,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6016 gap == RLIM_INFINITY ||
6017 sysctl_legacy_va_layout) {
6018 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
6019 +
6020 +#ifdef CONFIG_PAX_RANDMMAP
6021 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6022 + mm->mmap_base += mm->delta_mmap;
6023 +#endif
6024 +
6025 mm->get_unmapped_area = arch_get_unmapped_area;
6026 mm->unmap_area = arch_unmap_area;
6027 } else {
6028 @@ -402,6 +408,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6029 gap = (task_size / 6 * 5);
6030
6031 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
6032 +
6033 +#ifdef CONFIG_PAX_RANDMMAP
6034 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6035 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
6036 +#endif
6037 +
6038 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
6039 mm->unmap_area = arch_unmap_area_topdown;
6040 }
6041 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
6042 index 1d7e274..b39c527 100644
6043 --- a/arch/sparc/kernel/syscalls.S
6044 +++ b/arch/sparc/kernel/syscalls.S
6045 @@ -62,7 +62,7 @@ sys32_rt_sigreturn:
6046 #endif
6047 .align 32
6048 1: ldx [%g6 + TI_FLAGS], %l5
6049 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
6050 + andcc %l5, _TIF_WORK_SYSCALL, %g0
6051 be,pt %icc, rtrap
6052 nop
6053 call syscall_trace_leave
6054 @@ -179,7 +179,7 @@ linux_sparc_syscall32:
6055
6056 srl %i5, 0, %o5 ! IEU1
6057 srl %i2, 0, %o2 ! IEU0 Group
6058 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
6059 + andcc %l0, _TIF_WORK_SYSCALL, %g0
6060 bne,pn %icc, linux_syscall_trace32 ! CTI
6061 mov %i0, %l5 ! IEU1
6062 call %l7 ! CTI Group brk forced
6063 @@ -202,7 +202,7 @@ linux_sparc_syscall:
6064
6065 mov %i3, %o3 ! IEU1
6066 mov %i4, %o4 ! IEU0 Group
6067 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
6068 + andcc %l0, _TIF_WORK_SYSCALL, %g0
6069 bne,pn %icc, linux_syscall_trace ! CTI Group
6070 mov %i0, %l5 ! IEU0
6071 2: call %l7 ! CTI Group brk forced
6072 @@ -226,7 +226,7 @@ ret_sys_call:
6073
6074 cmp %o0, -ERESTART_RESTARTBLOCK
6075 bgeu,pn %xcc, 1f
6076 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %l6
6077 + andcc %l0, _TIF_WORK_SYSCALL, %l6
6078 80:
6079 /* System call success, clear Carry condition code. */
6080 andn %g3, %g2, %g3
6081 @@ -241,7 +241,7 @@ ret_sys_call:
6082 /* System call failure, set Carry condition code.
6083 * Also, get abs(errno) to return to the process.
6084 */
6085 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %l6
6086 + andcc %l0, _TIF_WORK_SYSCALL, %l6
6087 sub %g0, %o0, %o0
6088 or %g3, %g2, %g3
6089 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
6090 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
6091 index 591f20c..0f1b925 100644
6092 --- a/arch/sparc/kernel/traps_32.c
6093 +++ b/arch/sparc/kernel/traps_32.c
6094 @@ -45,6 +45,8 @@ static void instruction_dump(unsigned long *pc)
6095 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
6096 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
6097
6098 +extern void gr_handle_kernel_exploit(void);
6099 +
6100 void die_if_kernel(char *str, struct pt_regs *regs)
6101 {
6102 static int die_counter;
6103 @@ -77,15 +79,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
6104 count++ < 30 &&
6105 (((unsigned long) rw) >= PAGE_OFFSET) &&
6106 !(((unsigned long) rw) & 0x7)) {
6107 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
6108 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
6109 (void *) rw->ins[7]);
6110 rw = (struct reg_window32 *)rw->ins[6];
6111 }
6112 }
6113 printk("Instruction DUMP:");
6114 instruction_dump ((unsigned long *) regs->pc);
6115 - if(regs->psr & PSR_PS)
6116 + if(regs->psr & PSR_PS) {
6117 + gr_handle_kernel_exploit();
6118 do_exit(SIGKILL);
6119 + }
6120 do_exit(SIGSEGV);
6121 }
6122
6123 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
6124 index 0cbdaa4..438e4c9 100644
6125 --- a/arch/sparc/kernel/traps_64.c
6126 +++ b/arch/sparc/kernel/traps_64.c
6127 @@ -75,7 +75,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
6128 i + 1,
6129 p->trapstack[i].tstate, p->trapstack[i].tpc,
6130 p->trapstack[i].tnpc, p->trapstack[i].tt);
6131 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
6132 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
6133 }
6134 }
6135
6136 @@ -95,6 +95,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
6137
6138 lvl -= 0x100;
6139 if (regs->tstate & TSTATE_PRIV) {
6140 +
6141 +#ifdef CONFIG_PAX_REFCOUNT
6142 + if (lvl == 6)
6143 + pax_report_refcount_overflow(regs);
6144 +#endif
6145 +
6146 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
6147 die_if_kernel(buffer, regs);
6148 }
6149 @@ -113,11 +119,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
6150 void bad_trap_tl1(struct pt_regs *regs, long lvl)
6151 {
6152 char buffer[32];
6153 -
6154 +
6155 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
6156 0, lvl, SIGTRAP) == NOTIFY_STOP)
6157 return;
6158
6159 +#ifdef CONFIG_PAX_REFCOUNT
6160 + if (lvl == 6)
6161 + pax_report_refcount_overflow(regs);
6162 +#endif
6163 +
6164 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
6165
6166 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
6167 @@ -1141,7 +1152,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
6168 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
6169 printk("%s" "ERROR(%d): ",
6170 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
6171 - printk("TPC<%pS>\n", (void *) regs->tpc);
6172 + printk("TPC<%pA>\n", (void *) regs->tpc);
6173 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
6174 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
6175 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
6176 @@ -1748,7 +1759,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
6177 smp_processor_id(),
6178 (type & 0x1) ? 'I' : 'D',
6179 regs->tpc);
6180 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
6181 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
6182 panic("Irrecoverable Cheetah+ parity error.");
6183 }
6184
6185 @@ -1756,7 +1767,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
6186 smp_processor_id(),
6187 (type & 0x1) ? 'I' : 'D',
6188 regs->tpc);
6189 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
6190 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
6191 }
6192
6193 struct sun4v_error_entry {
6194 @@ -1963,9 +1974,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
6195
6196 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
6197 regs->tpc, tl);
6198 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
6199 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
6200 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
6201 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
6202 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
6203 (void *) regs->u_regs[UREG_I7]);
6204 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
6205 "pte[%lx] error[%lx]\n",
6206 @@ -1987,9 +1998,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
6207
6208 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
6209 regs->tpc, tl);
6210 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
6211 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
6212 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
6213 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
6214 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
6215 (void *) regs->u_regs[UREG_I7]);
6216 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
6217 "pte[%lx] error[%lx]\n",
6218 @@ -2195,13 +2206,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
6219 fp = (unsigned long)sf->fp + STACK_BIAS;
6220 }
6221
6222 - printk(" [%016lx] %pS\n", pc, (void *) pc);
6223 + printk(" [%016lx] %pA\n", pc, (void *) pc);
6224 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
6225 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
6226 int index = tsk->curr_ret_stack;
6227 if (tsk->ret_stack && index >= graph) {
6228 pc = tsk->ret_stack[index - graph].ret;
6229 - printk(" [%016lx] %pS\n", pc, (void *) pc);
6230 + printk(" [%016lx] %pA\n", pc, (void *) pc);
6231 graph++;
6232 }
6233 }
6234 @@ -2226,6 +2237,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
6235 return (struct reg_window *) (fp + STACK_BIAS);
6236 }
6237
6238 +extern void gr_handle_kernel_exploit(void);
6239 +
6240 void die_if_kernel(char *str, struct pt_regs *regs)
6241 {
6242 static int die_counter;
6243 @@ -2254,7 +2267,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
6244 while (rw &&
6245 count++ < 30 &&
6246 kstack_valid(tp, (unsigned long) rw)) {
6247 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
6248 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
6249 (void *) rw->ins[7]);
6250
6251 rw = kernel_stack_up(rw);
6252 @@ -2267,8 +2280,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
6253 }
6254 user_instruction_dump ((unsigned int __user *) regs->tpc);
6255 }
6256 - if (regs->tstate & TSTATE_PRIV)
6257 + if (regs->tstate & TSTATE_PRIV) {
6258 + gr_handle_kernel_exploit();
6259 do_exit(SIGKILL);
6260 + }
6261 do_exit(SIGSEGV);
6262 }
6263 EXPORT_SYMBOL(die_if_kernel);
6264 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
6265 index 76e4ac1..78f8bb1 100644
6266 --- a/arch/sparc/kernel/unaligned_64.c
6267 +++ b/arch/sparc/kernel/unaligned_64.c
6268 @@ -279,7 +279,7 @@ static void log_unaligned(struct pt_regs *regs)
6269 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
6270
6271 if (__ratelimit(&ratelimit)) {
6272 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
6273 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
6274 regs->tpc, (void *) regs->tpc);
6275 }
6276 }
6277 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
6278 index a3fc437..fea9957 100644
6279 --- a/arch/sparc/lib/Makefile
6280 +++ b/arch/sparc/lib/Makefile
6281 @@ -2,7 +2,7 @@
6282 #
6283
6284 asflags-y := -ansi -DST_DIV0=0x02
6285 -ccflags-y := -Werror
6286 +#ccflags-y := -Werror
6287
6288 lib-$(CONFIG_SPARC32) += mul.o rem.o sdiv.o udiv.o umul.o urem.o ashrdi3.o
6289 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
6290 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
6291 index 59186e0..f747d7a 100644
6292 --- a/arch/sparc/lib/atomic_64.S
6293 +++ b/arch/sparc/lib/atomic_64.S
6294 @@ -18,7 +18,12 @@
6295 atomic_add: /* %o0 = increment, %o1 = atomic_ptr */
6296 BACKOFF_SETUP(%o2)
6297 1: lduw [%o1], %g1
6298 - add %g1, %o0, %g7
6299 + addcc %g1, %o0, %g7
6300 +
6301 +#ifdef CONFIG_PAX_REFCOUNT
6302 + tvs %icc, 6
6303 +#endif
6304 +
6305 cas [%o1], %g1, %g7
6306 cmp %g1, %g7
6307 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
6308 @@ -28,12 +33,32 @@ atomic_add: /* %o0 = increment, %o1 = atomic_ptr */
6309 2: BACKOFF_SPIN(%o2, %o3, 1b)
6310 .size atomic_add, .-atomic_add
6311
6312 + .globl atomic_add_unchecked
6313 + .type atomic_add_unchecked,#function
6314 +atomic_add_unchecked: /* %o0 = increment, %o1 = atomic_ptr */
6315 + BACKOFF_SETUP(%o2)
6316 +1: lduw [%o1], %g1
6317 + add %g1, %o0, %g7
6318 + cas [%o1], %g1, %g7
6319 + cmp %g1, %g7
6320 + bne,pn %icc, 2f
6321 + nop
6322 + retl
6323 + nop
6324 +2: BACKOFF_SPIN(%o2, %o3, 1b)
6325 + .size atomic_add_unchecked, .-atomic_add_unchecked
6326 +
6327 .globl atomic_sub
6328 .type atomic_sub,#function
6329 atomic_sub: /* %o0 = decrement, %o1 = atomic_ptr */
6330 BACKOFF_SETUP(%o2)
6331 1: lduw [%o1], %g1
6332 - sub %g1, %o0, %g7
6333 + subcc %g1, %o0, %g7
6334 +
6335 +#ifdef CONFIG_PAX_REFCOUNT
6336 + tvs %icc, 6
6337 +#endif
6338 +
6339 cas [%o1], %g1, %g7
6340 cmp %g1, %g7
6341 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
6342 @@ -43,12 +68,32 @@ atomic_sub: /* %o0 = decrement, %o1 = atomic_ptr */
6343 2: BACKOFF_SPIN(%o2, %o3, 1b)
6344 .size atomic_sub, .-atomic_sub
6345
6346 + .globl atomic_sub_unchecked
6347 + .type atomic_sub_unchecked,#function
6348 +atomic_sub_unchecked: /* %o0 = decrement, %o1 = atomic_ptr */
6349 + BACKOFF_SETUP(%o2)
6350 +1: lduw [%o1], %g1
6351 + sub %g1, %o0, %g7
6352 + cas [%o1], %g1, %g7
6353 + cmp %g1, %g7
6354 + bne,pn %icc, 2f
6355 + nop
6356 + retl
6357 + nop
6358 +2: BACKOFF_SPIN(%o2, %o3, 1b)
6359 + .size atomic_sub_unchecked, .-atomic_sub_unchecked
6360 +
6361 .globl atomic_add_ret
6362 .type atomic_add_ret,#function
6363 atomic_add_ret: /* %o0 = increment, %o1 = atomic_ptr */
6364 BACKOFF_SETUP(%o2)
6365 1: lduw [%o1], %g1
6366 - add %g1, %o0, %g7
6367 + addcc %g1, %o0, %g7
6368 +
6369 +#ifdef CONFIG_PAX_REFCOUNT
6370 + tvs %icc, 6
6371 +#endif
6372 +
6373 cas [%o1], %g1, %g7
6374 cmp %g1, %g7
6375 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
6376 @@ -58,12 +103,33 @@ atomic_add_ret: /* %o0 = increment, %o1 = atomic_ptr */
6377 2: BACKOFF_SPIN(%o2, %o3, 1b)
6378 .size atomic_add_ret, .-atomic_add_ret
6379
6380 + .globl atomic_add_ret_unchecked
6381 + .type atomic_add_ret_unchecked,#function
6382 +atomic_add_ret_unchecked: /* %o0 = increment, %o1 = atomic_ptr */
6383 + BACKOFF_SETUP(%o2)
6384 +1: lduw [%o1], %g1
6385 + addcc %g1, %o0, %g7
6386 + cas [%o1], %g1, %g7
6387 + cmp %g1, %g7
6388 + bne,pn %icc, 2f
6389 + add %g7, %o0, %g7
6390 + sra %g7, 0, %o0
6391 + retl
6392 + nop
6393 +2: BACKOFF_SPIN(%o2, %o3, 1b)
6394 + .size atomic_add_ret_unchecked, .-atomic_add_ret_unchecked
6395 +
6396 .globl atomic_sub_ret
6397 .type atomic_sub_ret,#function
6398 atomic_sub_ret: /* %o0 = decrement, %o1 = atomic_ptr */
6399 BACKOFF_SETUP(%o2)
6400 1: lduw [%o1], %g1
6401 - sub %g1, %o0, %g7
6402 + subcc %g1, %o0, %g7
6403 +
6404 +#ifdef CONFIG_PAX_REFCOUNT
6405 + tvs %icc, 6
6406 +#endif
6407 +
6408 cas [%o1], %g1, %g7
6409 cmp %g1, %g7
6410 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
6411 @@ -78,7 +144,12 @@ atomic_sub_ret: /* %o0 = decrement, %o1 = atomic_ptr */
6412 atomic64_add: /* %o0 = increment, %o1 = atomic_ptr */
6413 BACKOFF_SETUP(%o2)
6414 1: ldx [%o1], %g1
6415 - add %g1, %o0, %g7
6416 + addcc %g1, %o0, %g7
6417 +
6418 +#ifdef CONFIG_PAX_REFCOUNT
6419 + tvs %xcc, 6
6420 +#endif
6421 +
6422 casx [%o1], %g1, %g7
6423 cmp %g1, %g7
6424 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
6425 @@ -88,12 +159,32 @@ atomic64_add: /* %o0 = increment, %o1 = atomic_ptr */
6426 2: BACKOFF_SPIN(%o2, %o3, 1b)
6427 .size atomic64_add, .-atomic64_add
6428
6429 + .globl atomic64_add_unchecked
6430 + .type atomic64_add_unchecked,#function
6431 +atomic64_add_unchecked: /* %o0 = increment, %o1 = atomic_ptr */
6432 + BACKOFF_SETUP(%o2)
6433 +1: ldx [%o1], %g1
6434 + addcc %g1, %o0, %g7
6435 + casx [%o1], %g1, %g7
6436 + cmp %g1, %g7
6437 + bne,pn %xcc, 2f
6438 + nop
6439 + retl
6440 + nop
6441 +2: BACKOFF_SPIN(%o2, %o3, 1b)
6442 + .size atomic64_add_unchecked, .-atomic64_add_unchecked
6443 +
6444 .globl atomic64_sub
6445 .type atomic64_sub,#function
6446 atomic64_sub: /* %o0 = decrement, %o1 = atomic_ptr */
6447 BACKOFF_SETUP(%o2)
6448 1: ldx [%o1], %g1
6449 - sub %g1, %o0, %g7
6450 + subcc %g1, %o0, %g7
6451 +
6452 +#ifdef CONFIG_PAX_REFCOUNT
6453 + tvs %xcc, 6
6454 +#endif
6455 +
6456 casx [%o1], %g1, %g7
6457 cmp %g1, %g7
6458 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
6459 @@ -103,12 +194,32 @@ atomic64_sub: /* %o0 = decrement, %o1 = atomic_ptr */
6460 2: BACKOFF_SPIN(%o2, %o3, 1b)
6461 .size atomic64_sub, .-atomic64_sub
6462
6463 + .globl atomic64_sub_unchecked
6464 + .type atomic64_sub_unchecked,#function
6465 +atomic64_sub_unchecked: /* %o0 = decrement, %o1 = atomic_ptr */
6466 + BACKOFF_SETUP(%o2)
6467 +1: ldx [%o1], %g1
6468 + subcc %g1, %o0, %g7
6469 + casx [%o1], %g1, %g7
6470 + cmp %g1, %g7
6471 + bne,pn %xcc, 2f
6472 + nop
6473 + retl
6474 + nop
6475 +2: BACKOFF_SPIN(%o2, %o3, 1b)
6476 + .size atomic64_sub_unchecked, .-atomic64_sub_unchecked
6477 +
6478 .globl atomic64_add_ret
6479 .type atomic64_add_ret,#function
6480 atomic64_add_ret: /* %o0 = increment, %o1 = atomic_ptr */
6481 BACKOFF_SETUP(%o2)
6482 1: ldx [%o1], %g1
6483 - add %g1, %o0, %g7
6484 + addcc %g1, %o0, %g7
6485 +
6486 +#ifdef CONFIG_PAX_REFCOUNT
6487 + tvs %xcc, 6
6488 +#endif
6489 +
6490 casx [%o1], %g1, %g7
6491 cmp %g1, %g7
6492 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
6493 @@ -118,12 +229,33 @@ atomic64_add_ret: /* %o0 = increment, %o1 = atomic_ptr */
6494 2: BACKOFF_SPIN(%o2, %o3, 1b)
6495 .size atomic64_add_ret, .-atomic64_add_ret
6496
6497 + .globl atomic64_add_ret_unchecked
6498 + .type atomic64_add_ret_unchecked,#function
6499 +atomic64_add_ret_unchecked: /* %o0 = increment, %o1 = atomic_ptr */
6500 + BACKOFF_SETUP(%o2)
6501 +1: ldx [%o1], %g1
6502 + addcc %g1, %o0, %g7
6503 + casx [%o1], %g1, %g7
6504 + cmp %g1, %g7
6505 + bne,pn %xcc, 2f
6506 + add %g7, %o0, %g7
6507 + mov %g7, %o0
6508 + retl
6509 + nop
6510 +2: BACKOFF_SPIN(%o2, %o3, 1b)
6511 + .size atomic64_add_ret_unchecked, .-atomic64_add_ret_unchecked
6512 +
6513 .globl atomic64_sub_ret
6514 .type atomic64_sub_ret,#function
6515 atomic64_sub_ret: /* %o0 = decrement, %o1 = atomic_ptr */
6516 BACKOFF_SETUP(%o2)
6517 1: ldx [%o1], %g1
6518 - sub %g1, %o0, %g7
6519 + subcc %g1, %o0, %g7
6520 +
6521 +#ifdef CONFIG_PAX_REFCOUNT
6522 + tvs %xcc, 6
6523 +#endif
6524 +
6525 casx [%o1], %g1, %g7
6526 cmp %g1, %g7
6527 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
6528 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
6529 index f73c224..662af10 100644
6530 --- a/arch/sparc/lib/ksyms.c
6531 +++ b/arch/sparc/lib/ksyms.c
6532 @@ -136,12 +136,18 @@ EXPORT_SYMBOL(__downgrade_write);
6533
6534 /* Atomic counter implementation. */
6535 EXPORT_SYMBOL(atomic_add);
6536 +EXPORT_SYMBOL(atomic_add_unchecked);
6537 EXPORT_SYMBOL(atomic_add_ret);
6538 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
6539 EXPORT_SYMBOL(atomic_sub);
6540 +EXPORT_SYMBOL(atomic_sub_unchecked);
6541 EXPORT_SYMBOL(atomic_sub_ret);
6542 EXPORT_SYMBOL(atomic64_add);
6543 +EXPORT_SYMBOL(atomic64_add_unchecked);
6544 EXPORT_SYMBOL(atomic64_add_ret);
6545 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
6546 EXPORT_SYMBOL(atomic64_sub);
6547 +EXPORT_SYMBOL(atomic64_sub_unchecked);
6548 EXPORT_SYMBOL(atomic64_sub_ret);
6549
6550 /* Atomic bit operations. */
6551 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
6552 index 301421c..e2535d1 100644
6553 --- a/arch/sparc/mm/Makefile
6554 +++ b/arch/sparc/mm/Makefile
6555 @@ -2,7 +2,7 @@
6556 #
6557
6558 asflags-y := -ansi
6559 -ccflags-y := -Werror
6560 +#ccflags-y := -Werror
6561
6562 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
6563 obj-y += fault_$(BITS).o
6564 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
6565 index 8023fd7..c8e89e9 100644
6566 --- a/arch/sparc/mm/fault_32.c
6567 +++ b/arch/sparc/mm/fault_32.c
6568 @@ -21,6 +21,9 @@
6569 #include <linux/perf_event.h>
6570 #include <linux/interrupt.h>
6571 #include <linux/kdebug.h>
6572 +#include <linux/slab.h>
6573 +#include <linux/pagemap.h>
6574 +#include <linux/compiler.h>
6575
6576 #include <asm/system.h>
6577 #include <asm/page.h>
6578 @@ -208,6 +211,268 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
6579 return safe_compute_effective_address(regs, insn);
6580 }
6581
6582 +#ifdef CONFIG_PAX_PAGEEXEC
6583 +#ifdef CONFIG_PAX_DLRESOLVE
6584 +static void pax_emuplt_close(struct vm_area_struct *vma)
6585 +{
6586 + vma->vm_mm->call_dl_resolve = 0UL;
6587 +}
6588 +
6589 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
6590 +{
6591 + unsigned int *kaddr;
6592 +
6593 + vmf->page = alloc_page(GFP_HIGHUSER);
6594 + if (!vmf->page)
6595 + return VM_FAULT_OOM;
6596 +
6597 + kaddr = kmap(vmf->page);
6598 + memset(kaddr, 0, PAGE_SIZE);
6599 + kaddr[0] = 0x9DE3BFA8U; /* save */
6600 + flush_dcache_page(vmf->page);
6601 + kunmap(vmf->page);
6602 + return VM_FAULT_MAJOR;
6603 +}
6604 +
6605 +static const struct vm_operations_struct pax_vm_ops = {
6606 + .close = pax_emuplt_close,
6607 + .fault = pax_emuplt_fault
6608 +};
6609 +
6610 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
6611 +{
6612 + int ret;
6613 +
6614 + INIT_LIST_HEAD(&vma->anon_vma_chain);
6615 + vma->vm_mm = current->mm;
6616 + vma->vm_start = addr;
6617 + vma->vm_end = addr + PAGE_SIZE;
6618 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
6619 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
6620 + vma->vm_ops = &pax_vm_ops;
6621 +
6622 + ret = insert_vm_struct(current->mm, vma);
6623 + if (ret)
6624 + return ret;
6625 +
6626 + ++current->mm->total_vm;
6627 + return 0;
6628 +}
6629 +#endif
6630 +
6631 +/*
6632 + * PaX: decide what to do with offenders (regs->pc = fault address)
6633 + *
6634 + * returns 1 when task should be killed
6635 + * 2 when patched PLT trampoline was detected
6636 + * 3 when unpatched PLT trampoline was detected
6637 + */
6638 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6639 +{
6640 +
6641 +#ifdef CONFIG_PAX_EMUPLT
6642 + int err;
6643 +
6644 + do { /* PaX: patched PLT emulation #1 */
6645 + unsigned int sethi1, sethi2, jmpl;
6646 +
6647 + err = get_user(sethi1, (unsigned int *)regs->pc);
6648 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
6649 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
6650 +
6651 + if (err)
6652 + break;
6653 +
6654 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
6655 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
6656 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
6657 + {
6658 + unsigned int addr;
6659 +
6660 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
6661 + addr = regs->u_regs[UREG_G1];
6662 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
6663 + regs->pc = addr;
6664 + regs->npc = addr+4;
6665 + return 2;
6666 + }
6667 + } while (0);
6668 +
6669 + { /* PaX: patched PLT emulation #2 */
6670 + unsigned int ba;
6671 +
6672 + err = get_user(ba, (unsigned int *)regs->pc);
6673 +
6674 + if (!err && (ba & 0xFFC00000U) == 0x30800000U) {
6675 + unsigned int addr;
6676 +
6677 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
6678 + regs->pc = addr;
6679 + regs->npc = addr+4;
6680 + return 2;
6681 + }
6682 + }
6683 +
6684 + do { /* PaX: patched PLT emulation #3 */
6685 + unsigned int sethi, jmpl, nop;
6686 +
6687 + err = get_user(sethi, (unsigned int *)regs->pc);
6688 + err |= get_user(jmpl, (unsigned int *)(regs->pc+4));
6689 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
6690 +
6691 + if (err)
6692 + break;
6693 +
6694 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
6695 + (jmpl & 0xFFFFE000U) == 0x81C06000U &&
6696 + nop == 0x01000000U)
6697 + {
6698 + unsigned int addr;
6699 +
6700 + addr = (sethi & 0x003FFFFFU) << 10;
6701 + regs->u_regs[UREG_G1] = addr;
6702 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
6703 + regs->pc = addr;
6704 + regs->npc = addr+4;
6705 + return 2;
6706 + }
6707 + } while (0);
6708 +
6709 + do { /* PaX: unpatched PLT emulation step 1 */
6710 + unsigned int sethi, ba, nop;
6711 +
6712 + err = get_user(sethi, (unsigned int *)regs->pc);
6713 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
6714 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
6715 +
6716 + if (err)
6717 + break;
6718 +
6719 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
6720 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
6721 + nop == 0x01000000U)
6722 + {
6723 + unsigned int addr, save, call;
6724 +
6725 + if ((ba & 0xFFC00000U) == 0x30800000U)
6726 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
6727 + else
6728 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
6729 +
6730 + err = get_user(save, (unsigned int *)addr);
6731 + err |= get_user(call, (unsigned int *)(addr+4));
6732 + err |= get_user(nop, (unsigned int *)(addr+8));
6733 + if (err)
6734 + break;
6735 +
6736 +#ifdef CONFIG_PAX_DLRESOLVE
6737 + if (save == 0x9DE3BFA8U &&
6738 + (call & 0xC0000000U) == 0x40000000U &&
6739 + nop == 0x01000000U)
6740 + {
6741 + struct vm_area_struct *vma;
6742 + unsigned long call_dl_resolve;
6743 +
6744 + down_read(&current->mm->mmap_sem);
6745 + call_dl_resolve = current->mm->call_dl_resolve;
6746 + up_read(&current->mm->mmap_sem);
6747 + if (likely(call_dl_resolve))
6748 + goto emulate;
6749 +
6750 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
6751 +
6752 + down_write(&current->mm->mmap_sem);
6753 + if (current->mm->call_dl_resolve) {
6754 + call_dl_resolve = current->mm->call_dl_resolve;
6755 + up_write(&current->mm->mmap_sem);
6756 + if (vma)
6757 + kmem_cache_free(vm_area_cachep, vma);
6758 + goto emulate;
6759 + }
6760 +
6761 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
6762 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
6763 + up_write(&current->mm->mmap_sem);
6764 + if (vma)
6765 + kmem_cache_free(vm_area_cachep, vma);
6766 + return 1;
6767 + }
6768 +
6769 + if (pax_insert_vma(vma, call_dl_resolve)) {
6770 + up_write(&current->mm->mmap_sem);
6771 + kmem_cache_free(vm_area_cachep, vma);
6772 + return 1;
6773 + }
6774 +
6775 + current->mm->call_dl_resolve = call_dl_resolve;
6776 + up_write(&current->mm->mmap_sem);
6777 +
6778 +emulate:
6779 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
6780 + regs->pc = call_dl_resolve;
6781 + regs->npc = addr+4;
6782 + return 3;
6783 + }
6784 +#endif
6785 +
6786 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
6787 + if ((save & 0xFFC00000U) == 0x05000000U &&
6788 + (call & 0xFFFFE000U) == 0x85C0A000U &&
6789 + nop == 0x01000000U)
6790 + {
6791 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
6792 + regs->u_regs[UREG_G2] = addr + 4;
6793 + addr = (save & 0x003FFFFFU) << 10;
6794 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
6795 + regs->pc = addr;
6796 + regs->npc = addr+4;
6797 + return 3;
6798 + }
6799 + }
6800 + } while (0);
6801 +
6802 + do { /* PaX: unpatched PLT emulation step 2 */
6803 + unsigned int save, call, nop;
6804 +
6805 + err = get_user(save, (unsigned int *)(regs->pc-4));
6806 + err |= get_user(call, (unsigned int *)regs->pc);
6807 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
6808 + if (err)
6809 + break;
6810 +
6811 + if (save == 0x9DE3BFA8U &&
6812 + (call & 0xC0000000U) == 0x40000000U &&
6813 + nop == 0x01000000U)
6814 + {
6815 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
6816 +
6817 + regs->u_regs[UREG_RETPC] = regs->pc;
6818 + regs->pc = dl_resolve;
6819 + regs->npc = dl_resolve+4;
6820 + return 3;
6821 + }
6822 + } while (0);
6823 +#endif
6824 +
6825 + return 1;
6826 +}
6827 +
6828 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6829 +{
6830 + unsigned long i;
6831 +
6832 + printk(KERN_ERR "PAX: bytes at PC: ");
6833 + for (i = 0; i < 8; i++) {
6834 + unsigned int c;
6835 + if (get_user(c, (unsigned int *)pc+i))
6836 + printk(KERN_CONT "???????? ");
6837 + else
6838 + printk(KERN_CONT "%08x ", c);
6839 + }
6840 + printk("\n");
6841 +}
6842 +#endif
6843 +
6844 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
6845 int text_fault)
6846 {
6847 @@ -280,6 +545,24 @@ good_area:
6848 if(!(vma->vm_flags & VM_WRITE))
6849 goto bad_area;
6850 } else {
6851 +
6852 +#ifdef CONFIG_PAX_PAGEEXEC
6853 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
6854 + up_read(&mm->mmap_sem);
6855 + switch (pax_handle_fetch_fault(regs)) {
6856 +
6857 +#ifdef CONFIG_PAX_EMUPLT
6858 + case 2:
6859 + case 3:
6860 + return;
6861 +#endif
6862 +
6863 + }
6864 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
6865 + do_group_exit(SIGKILL);
6866 + }
6867 +#endif
6868 +
6869 /* Allow reads even for write-only mappings */
6870 if(!(vma->vm_flags & (VM_READ | VM_EXEC)))
6871 goto bad_area;
6872 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
6873 index 504c062..6fcb9c6 100644
6874 --- a/arch/sparc/mm/fault_64.c
6875 +++ b/arch/sparc/mm/fault_64.c
6876 @@ -21,6 +21,9 @@
6877 #include <linux/kprobes.h>
6878 #include <linux/kdebug.h>
6879 #include <linux/percpu.h>
6880 +#include <linux/slab.h>
6881 +#include <linux/pagemap.h>
6882 +#include <linux/compiler.h>
6883
6884 #include <asm/page.h>
6885 #include <asm/pgtable.h>
6886 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
6887 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
6888 regs->tpc);
6889 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
6890 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
6891 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
6892 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
6893 dump_stack();
6894 unhandled_fault(regs->tpc, current, regs);
6895 @@ -272,6 +275,457 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
6896 show_regs(regs);
6897 }
6898
6899 +#ifdef CONFIG_PAX_PAGEEXEC
6900 +#ifdef CONFIG_PAX_DLRESOLVE
6901 +static void pax_emuplt_close(struct vm_area_struct *vma)
6902 +{
6903 + vma->vm_mm->call_dl_resolve = 0UL;
6904 +}
6905 +
6906 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
6907 +{
6908 + unsigned int *kaddr;
6909 +
6910 + vmf->page = alloc_page(GFP_HIGHUSER);
6911 + if (!vmf->page)
6912 + return VM_FAULT_OOM;
6913 +
6914 + kaddr = kmap(vmf->page);
6915 + memset(kaddr, 0, PAGE_SIZE);
6916 + kaddr[0] = 0x9DE3BFA8U; /* save */
6917 + flush_dcache_page(vmf->page);
6918 + kunmap(vmf->page);
6919 + return VM_FAULT_MAJOR;
6920 +}
6921 +
6922 +static const struct vm_operations_struct pax_vm_ops = {
6923 + .close = pax_emuplt_close,
6924 + .fault = pax_emuplt_fault
6925 +};
6926 +
6927 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
6928 +{
6929 + int ret;
6930 +
6931 + INIT_LIST_HEAD(&vma->anon_vma_chain);
6932 + vma->vm_mm = current->mm;
6933 + vma->vm_start = addr;
6934 + vma->vm_end = addr + PAGE_SIZE;
6935 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
6936 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
6937 + vma->vm_ops = &pax_vm_ops;
6938 +
6939 + ret = insert_vm_struct(current->mm, vma);
6940 + if (ret)
6941 + return ret;
6942 +
6943 + ++current->mm->total_vm;
6944 + return 0;
6945 +}
6946 +#endif
6947 +
6948 +/*
6949 + * PaX: decide what to do with offenders (regs->tpc = fault address)
6950 + *
6951 + * returns 1 when task should be killed
6952 + * 2 when patched PLT trampoline was detected
6953 + * 3 when unpatched PLT trampoline was detected
6954 + */
6955 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6956 +{
6957 +
6958 +#ifdef CONFIG_PAX_EMUPLT
6959 + int err;
6960 +
6961 + do { /* PaX: patched PLT emulation #1 */
6962 + unsigned int sethi1, sethi2, jmpl;
6963 +
6964 + err = get_user(sethi1, (unsigned int *)regs->tpc);
6965 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
6966 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
6967 +
6968 + if (err)
6969 + break;
6970 +
6971 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
6972 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
6973 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
6974 + {
6975 + unsigned long addr;
6976 +
6977 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
6978 + addr = regs->u_regs[UREG_G1];
6979 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
6980 +
6981 + if (test_thread_flag(TIF_32BIT))
6982 + addr &= 0xFFFFFFFFUL;
6983 +
6984 + regs->tpc = addr;
6985 + regs->tnpc = addr+4;
6986 + return 2;
6987 + }
6988 + } while (0);
6989 +
6990 + { /* PaX: patched PLT emulation #2 */
6991 + unsigned int ba;
6992 +
6993 + err = get_user(ba, (unsigned int *)regs->tpc);
6994 +
6995 + if (!err && (ba & 0xFFC00000U) == 0x30800000U) {
6996 + unsigned long addr;
6997 +
6998 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
6999 +
7000 + if (test_thread_flag(TIF_32BIT))
7001 + addr &= 0xFFFFFFFFUL;
7002 +
7003 + regs->tpc = addr;
7004 + regs->tnpc = addr+4;
7005 + return 2;
7006 + }
7007 + }
7008 +
7009 + do { /* PaX: patched PLT emulation #3 */
7010 + unsigned int sethi, jmpl, nop;
7011 +
7012 + err = get_user(sethi, (unsigned int *)regs->tpc);
7013 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+4));
7014 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
7015 +
7016 + if (err)
7017 + break;
7018 +
7019 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
7020 + (jmpl & 0xFFFFE000U) == 0x81C06000U &&
7021 + nop == 0x01000000U)
7022 + {
7023 + unsigned long addr;
7024 +
7025 + addr = (sethi & 0x003FFFFFU) << 10;
7026 + regs->u_regs[UREG_G1] = addr;
7027 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
7028 +
7029 + if (test_thread_flag(TIF_32BIT))
7030 + addr &= 0xFFFFFFFFUL;
7031 +
7032 + regs->tpc = addr;
7033 + regs->tnpc = addr+4;
7034 + return 2;
7035 + }
7036 + } while (0);
7037 +
7038 + do { /* PaX: patched PLT emulation #4 */
7039 + unsigned int sethi, mov1, call, mov2;
7040 +
7041 + err = get_user(sethi, (unsigned int *)regs->tpc);
7042 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
7043 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
7044 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
7045 +
7046 + if (err)
7047 + break;
7048 +
7049 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
7050 + mov1 == 0x8210000FU &&
7051 + (call & 0xC0000000U) == 0x40000000U &&
7052 + mov2 == 0x9E100001U)
7053 + {
7054 + unsigned long addr;
7055 +
7056 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
7057 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
7058 +
7059 + if (test_thread_flag(TIF_32BIT))
7060 + addr &= 0xFFFFFFFFUL;
7061 +
7062 + regs->tpc = addr;
7063 + regs->tnpc = addr+4;
7064 + return 2;
7065 + }
7066 + } while (0);
7067 +
7068 + do { /* PaX: patched PLT emulation #5 */
7069 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
7070 +
7071 + err = get_user(sethi, (unsigned int *)regs->tpc);
7072 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
7073 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
7074 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
7075 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
7076 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
7077 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
7078 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
7079 +
7080 + if (err)
7081 + break;
7082 +
7083 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
7084 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
7085 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
7086 + (or1 & 0xFFFFE000U) == 0x82106000U &&
7087 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
7088 + sllx == 0x83287020U &&
7089 + jmpl == 0x81C04005U &&
7090 + nop == 0x01000000U)
7091 + {
7092 + unsigned long addr;
7093 +
7094 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
7095 + regs->u_regs[UREG_G1] <<= 32;
7096 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
7097 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
7098 + regs->tpc = addr;
7099 + regs->tnpc = addr+4;
7100 + return 2;
7101 + }
7102 + } while (0);
7103 +
7104 + do { /* PaX: patched PLT emulation #6 */
7105 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
7106 +
7107 + err = get_user(sethi, (unsigned int *)regs->tpc);
7108 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
7109 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
7110 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
7111 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
7112 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
7113 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
7114 +
7115 + if (err)
7116 + break;
7117 +
7118 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
7119 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
7120 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
7121 + sllx == 0x83287020U &&
7122 + (or & 0xFFFFE000U) == 0x8A116000U &&
7123 + jmpl == 0x81C04005U &&
7124 + nop == 0x01000000U)
7125 + {
7126 + unsigned long addr;
7127 +
7128 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
7129 + regs->u_regs[UREG_G1] <<= 32;
7130 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
7131 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
7132 + regs->tpc = addr;
7133 + regs->tnpc = addr+4;
7134 + return 2;
7135 + }
7136 + } while (0);
7137 +
7138 + do { /* PaX: unpatched PLT emulation step 1 */
7139 + unsigned int sethi, ba, nop;
7140 +
7141 + err = get_user(sethi, (unsigned int *)regs->tpc);
7142 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
7143 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
7144 +
7145 + if (err)
7146 + break;
7147 +
7148 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
7149 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
7150 + nop == 0x01000000U)
7151 + {
7152 + unsigned long addr;
7153 + unsigned int save, call;
7154 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
7155 +
7156 + if ((ba & 0xFFC00000U) == 0x30800000U)
7157 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
7158 + else
7159 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
7160 +
7161 + if (test_thread_flag(TIF_32BIT))
7162 + addr &= 0xFFFFFFFFUL;
7163 +
7164 + err = get_user(save, (unsigned int *)addr);
7165 + err |= get_user(call, (unsigned int *)(addr+4));
7166 + err |= get_user(nop, (unsigned int *)(addr+8));
7167 + if (err)
7168 + break;
7169 +
7170 +#ifdef CONFIG_PAX_DLRESOLVE
7171 + if (save == 0x9DE3BFA8U &&
7172 + (call & 0xC0000000U) == 0x40000000U &&
7173 + nop == 0x01000000U)
7174 + {
7175 + struct vm_area_struct *vma;
7176 + unsigned long call_dl_resolve;
7177 +
7178 + down_read(&current->mm->mmap_sem);
7179 + call_dl_resolve = current->mm->call_dl_resolve;
7180 + up_read(&current->mm->mmap_sem);
7181 + if (likely(call_dl_resolve))
7182 + goto emulate;
7183 +
7184 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
7185 +
7186 + down_write(&current->mm->mmap_sem);
7187 + if (current->mm->call_dl_resolve) {
7188 + call_dl_resolve = current->mm->call_dl_resolve;
7189 + up_write(&current->mm->mmap_sem);
7190 + if (vma)
7191 + kmem_cache_free(vm_area_cachep, vma);
7192 + goto emulate;
7193 + }
7194 +
7195 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
7196 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
7197 + up_write(&current->mm->mmap_sem);
7198 + if (vma)
7199 + kmem_cache_free(vm_area_cachep, vma);
7200 + return 1;
7201 + }
7202 +
7203 + if (pax_insert_vma(vma, call_dl_resolve)) {
7204 + up_write(&current->mm->mmap_sem);
7205 + kmem_cache_free(vm_area_cachep, vma);
7206 + return 1;
7207 + }
7208 +
7209 + current->mm->call_dl_resolve = call_dl_resolve;
7210 + up_write(&current->mm->mmap_sem);
7211 +
7212 +emulate:
7213 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
7214 + regs->tpc = call_dl_resolve;
7215 + regs->tnpc = addr+4;
7216 + return 3;
7217 + }
7218 +#endif
7219 +
7220 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
7221 + if ((save & 0xFFC00000U) == 0x05000000U &&
7222 + (call & 0xFFFFE000U) == 0x85C0A000U &&
7223 + nop == 0x01000000U)
7224 + {
7225 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
7226 + regs->u_regs[UREG_G2] = addr + 4;
7227 + addr = (save & 0x003FFFFFU) << 10;
7228 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
7229 +
7230 + if (test_thread_flag(TIF_32BIT))
7231 + addr &= 0xFFFFFFFFUL;
7232 +
7233 + regs->tpc = addr;
7234 + regs->tnpc = addr+4;
7235 + return 3;
7236 + }
7237 +
7238 + /* PaX: 64-bit PLT stub */
7239 + err = get_user(sethi1, (unsigned int *)addr);
7240 + err |= get_user(sethi2, (unsigned int *)(addr+4));
7241 + err |= get_user(or1, (unsigned int *)(addr+8));
7242 + err |= get_user(or2, (unsigned int *)(addr+12));
7243 + err |= get_user(sllx, (unsigned int *)(addr+16));
7244 + err |= get_user(add, (unsigned int *)(addr+20));
7245 + err |= get_user(jmpl, (unsigned int *)(addr+24));
7246 + err |= get_user(nop, (unsigned int *)(addr+28));
7247 + if (err)
7248 + break;
7249 +
7250 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
7251 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
7252 + (or1 & 0xFFFFE000U) == 0x88112000U &&
7253 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
7254 + sllx == 0x89293020U &&
7255 + add == 0x8A010005U &&
7256 + jmpl == 0x89C14000U &&
7257 + nop == 0x01000000U)
7258 + {
7259 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
7260 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
7261 + regs->u_regs[UREG_G4] <<= 32;
7262 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
7263 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
7264 + regs->u_regs[UREG_G4] = addr + 24;
7265 + addr = regs->u_regs[UREG_G5];
7266 + regs->tpc = addr;
7267 + regs->tnpc = addr+4;
7268 + return 3;
7269 + }
7270 + }
7271 + } while (0);
7272 +
7273 +#ifdef CONFIG_PAX_DLRESOLVE
7274 + do { /* PaX: unpatched PLT emulation step 2 */
7275 + unsigned int save, call, nop;
7276 +
7277 + err = get_user(save, (unsigned int *)(regs->tpc-4));
7278 + err |= get_user(call, (unsigned int *)regs->tpc);
7279 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
7280 + if (err)
7281 + break;
7282 +
7283 + if (save == 0x9DE3BFA8U &&
7284 + (call & 0xC0000000U) == 0x40000000U &&
7285 + nop == 0x01000000U)
7286 + {
7287 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
7288 +
7289 + if (test_thread_flag(TIF_32BIT))
7290 + dl_resolve &= 0xFFFFFFFFUL;
7291 +
7292 + regs->u_regs[UREG_RETPC] = regs->tpc;
7293 + regs->tpc = dl_resolve;
7294 + regs->tnpc = dl_resolve+4;
7295 + return 3;
7296 + }
7297 + } while (0);
7298 +#endif
7299 +
7300 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
7301 + unsigned int sethi, ba, nop;
7302 +
7303 + err = get_user(sethi, (unsigned int *)regs->tpc);
7304 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
7305 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
7306 +
7307 + if (err)
7308 + break;
7309 +
7310 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
7311 + (ba & 0xFFF00000U) == 0x30600000U &&
7312 + nop == 0x01000000U)
7313 + {
7314 + unsigned long addr;
7315 +
7316 + addr = (sethi & 0x003FFFFFU) << 10;
7317 + regs->u_regs[UREG_G1] = addr;
7318 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
7319 +
7320 + if (test_thread_flag(TIF_32BIT))
7321 + addr &= 0xFFFFFFFFUL;
7322 +
7323 + regs->tpc = addr;
7324 + regs->tnpc = addr+4;
7325 + return 2;
7326 + }
7327 + } while (0);
7328 +
7329 +#endif
7330 +
7331 + return 1;
7332 +}
7333 +
7334 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7335 +{
7336 + unsigned long i;
7337 +
7338 + printk(KERN_ERR "PAX: bytes at PC: ");
7339 + for (i = 0; i < 8; i++) {
7340 + unsigned int c;
7341 + if (get_user(c, (unsigned int *)pc+i))
7342 + printk(KERN_CONT "???????? ");
7343 + else
7344 + printk(KERN_CONT "%08x ", c);
7345 + }
7346 + printk("\n");
7347 +}
7348 +#endif
7349 +
7350 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
7351 {
7352 struct mm_struct *mm = current->mm;
7353 @@ -340,6 +794,29 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
7354 if (!vma)
7355 goto bad_area;
7356
7357 +#ifdef CONFIG_PAX_PAGEEXEC
7358 + /* PaX: detect ITLB misses on non-exec pages */
7359 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
7360 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
7361 + {
7362 + if (address != regs->tpc)
7363 + goto good_area;
7364 +
7365 + up_read(&mm->mmap_sem);
7366 + switch (pax_handle_fetch_fault(regs)) {
7367 +
7368 +#ifdef CONFIG_PAX_EMUPLT
7369 + case 2:
7370 + case 3:
7371 + return;
7372 +#endif
7373 +
7374 + }
7375 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
7376 + do_group_exit(SIGKILL);
7377 + }
7378 +#endif
7379 +
7380 /* Pure DTLB misses do not tell us whether the fault causing
7381 * load/store/atomic was a write or not, it only says that there
7382 * was no match. So in such a case we (carefully) read the
7383 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
7384 index 07e1453..0a7d9e9 100644
7385 --- a/arch/sparc/mm/hugetlbpage.c
7386 +++ b/arch/sparc/mm/hugetlbpage.c
7387 @@ -67,7 +67,7 @@ full_search:
7388 }
7389 return -ENOMEM;
7390 }
7391 - if (likely(!vma || addr + len <= vma->vm_start)) {
7392 + if (likely(check_heap_stack_gap(vma, addr, len))) {
7393 /*
7394 * Remember the place where we stopped the search:
7395 */
7396 @@ -106,7 +106,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7397 /* make sure it can fit in the remaining address space */
7398 if (likely(addr > len)) {
7399 vma = find_vma(mm, addr-len);
7400 - if (!vma || addr <= vma->vm_start) {
7401 + if (check_heap_stack_gap(vma, addr - len, len)) {
7402 /* remember the address as a hint for next time */
7403 return (mm->free_area_cache = addr-len);
7404 }
7405 @@ -115,16 +115,17 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7406 if (unlikely(mm->mmap_base < len))
7407 goto bottomup;
7408
7409 - addr = (mm->mmap_base-len) & HPAGE_MASK;
7410 + addr = mm->mmap_base - len;
7411
7412 do {
7413 + addr &= HPAGE_MASK;
7414 /*
7415 * Lookup failure means no vma is above this address,
7416 * else if new region fits below vma->vm_start,
7417 * return with success:
7418 */
7419 vma = find_vma(mm, addr);
7420 - if (likely(!vma || addr+len <= vma->vm_start)) {
7421 + if (likely(check_heap_stack_gap(vma, addr, len))) {
7422 /* remember the address as a hint for next time */
7423 return (mm->free_area_cache = addr);
7424 }
7425 @@ -134,8 +135,8 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7426 mm->cached_hole_size = vma->vm_start - addr;
7427
7428 /* try just below the current vma->vm_start */
7429 - addr = (vma->vm_start-len) & HPAGE_MASK;
7430 - } while (likely(len < vma->vm_start));
7431 + addr = skip_heap_stack_gap(vma, len);
7432 + } while (!IS_ERR_VALUE(addr));
7433
7434 bottomup:
7435 /*
7436 @@ -181,8 +182,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
7437 if (addr) {
7438 addr = ALIGN(addr, HPAGE_SIZE);
7439 vma = find_vma(mm, addr);
7440 - if (task_size - len >= addr &&
7441 - (!vma || addr + len <= vma->vm_start))
7442 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len))
7443 return addr;
7444 }
7445 if (mm->get_unmapped_area == arch_get_unmapped_area)
7446 diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c
7447 index 7b00de6..78239f4 100644
7448 --- a/arch/sparc/mm/init_32.c
7449 +++ b/arch/sparc/mm/init_32.c
7450 @@ -316,6 +316,9 @@ extern void device_scan(void);
7451 pgprot_t PAGE_SHARED __read_mostly;
7452 EXPORT_SYMBOL(PAGE_SHARED);
7453
7454 +pgprot_t PAGE_SHARED_NOEXEC __read_mostly;
7455 +EXPORT_SYMBOL(PAGE_SHARED_NOEXEC);
7456 +
7457 void __init paging_init(void)
7458 {
7459 switch(sparc_cpu_model) {
7460 @@ -344,17 +347,17 @@ void __init paging_init(void)
7461
7462 /* Initialize the protection map with non-constant, MMU dependent values. */
7463 protection_map[0] = PAGE_NONE;
7464 - protection_map[1] = PAGE_READONLY;
7465 - protection_map[2] = PAGE_COPY;
7466 - protection_map[3] = PAGE_COPY;
7467 + protection_map[1] = PAGE_READONLY_NOEXEC;
7468 + protection_map[2] = PAGE_COPY_NOEXEC;
7469 + protection_map[3] = PAGE_COPY_NOEXEC;
7470 protection_map[4] = PAGE_READONLY;
7471 protection_map[5] = PAGE_READONLY;
7472 protection_map[6] = PAGE_COPY;
7473 protection_map[7] = PAGE_COPY;
7474 protection_map[8] = PAGE_NONE;
7475 - protection_map[9] = PAGE_READONLY;
7476 - protection_map[10] = PAGE_SHARED;
7477 - protection_map[11] = PAGE_SHARED;
7478 + protection_map[9] = PAGE_READONLY_NOEXEC;
7479 + protection_map[10] = PAGE_SHARED_NOEXEC;
7480 + protection_map[11] = PAGE_SHARED_NOEXEC;
7481 protection_map[12] = PAGE_READONLY;
7482 protection_map[13] = PAGE_READONLY;
7483 protection_map[14] = PAGE_SHARED;
7484 diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
7485 index cbef74e..c38fead 100644
7486 --- a/arch/sparc/mm/srmmu.c
7487 +++ b/arch/sparc/mm/srmmu.c
7488 @@ -2200,6 +2200,13 @@ void __init ld_mmu_srmmu(void)
7489 PAGE_SHARED = pgprot_val(SRMMU_PAGE_SHARED);
7490 BTFIXUPSET_INT(page_copy, pgprot_val(SRMMU_PAGE_COPY));
7491 BTFIXUPSET_INT(page_readonly, pgprot_val(SRMMU_PAGE_RDONLY));
7492 +
7493 +#ifdef CONFIG_PAX_PAGEEXEC
7494 + PAGE_SHARED_NOEXEC = pgprot_val(SRMMU_PAGE_SHARED_NOEXEC);
7495 + BTFIXUPSET_INT(page_copy_noexec, pgprot_val(SRMMU_PAGE_COPY_NOEXEC));
7496 + BTFIXUPSET_INT(page_readonly_noexec, pgprot_val(SRMMU_PAGE_RDONLY_NOEXEC));
7497 +#endif
7498 +
7499 BTFIXUPSET_INT(page_kernel, pgprot_val(SRMMU_PAGE_KERNEL));
7500 page_kernel = pgprot_val(SRMMU_PAGE_KERNEL);
7501
7502 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
7503 index 27fe667..36d474c 100644
7504 --- a/arch/tile/include/asm/atomic_64.h
7505 +++ b/arch/tile/include/asm/atomic_64.h
7506 @@ -142,6 +142,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
7507
7508 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7509
7510 +#define atomic64_read_unchecked(v) atomic64_read(v)
7511 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7512 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7513 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7514 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7515 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7516 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7517 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7518 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7519 +
7520 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
7521 #define smp_mb__before_atomic_dec() smp_mb()
7522 #define smp_mb__after_atomic_dec() smp_mb()
7523 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
7524 index 392e533..536b092 100644
7525 --- a/arch/tile/include/asm/cache.h
7526 +++ b/arch/tile/include/asm/cache.h
7527 @@ -15,11 +15,12 @@
7528 #ifndef _ASM_TILE_CACHE_H
7529 #define _ASM_TILE_CACHE_H
7530
7531 +#include <linux/const.h>
7532 #include <arch/chip.h>
7533
7534 /* bytes per L1 data cache line */
7535 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
7536 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7537 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7538
7539 /* bytes per L2 cache line */
7540 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
7541 diff --git a/arch/um/Makefile b/arch/um/Makefile
7542 index 28688e6..4c0aa1c 100644
7543 --- a/arch/um/Makefile
7544 +++ b/arch/um/Makefile
7545 @@ -61,6 +61,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
7546 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
7547 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
7548
7549 +ifdef CONSTIFY_PLUGIN
7550 +USER_CFLAGS += $(CONSTIFY_PLUGIN) -fplugin-arg-constify_plugin-no-constify
7551 +endif
7552 +
7553 #This will adjust *FLAGS accordingly to the platform.
7554 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
7555
7556 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
7557 index 19e1bdd..3665b77 100644
7558 --- a/arch/um/include/asm/cache.h
7559 +++ b/arch/um/include/asm/cache.h
7560 @@ -1,6 +1,7 @@
7561 #ifndef __UM_CACHE_H
7562 #define __UM_CACHE_H
7563
7564 +#include <linux/const.h>
7565
7566 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
7567 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
7568 @@ -12,6 +13,6 @@
7569 # define L1_CACHE_SHIFT 5
7570 #endif
7571
7572 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7573 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7574
7575 #endif
7576 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
7577 index 6c03acd..a5e0215 100644
7578 --- a/arch/um/include/asm/kmap_types.h
7579 +++ b/arch/um/include/asm/kmap_types.h
7580 @@ -23,6 +23,7 @@ enum km_type {
7581 KM_IRQ1,
7582 KM_SOFTIRQ0,
7583 KM_SOFTIRQ1,
7584 + KM_CLEARPAGE,
7585 KM_TYPE_NR
7586 };
7587
7588 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
7589 index 7cfc3ce..cbd1a58 100644
7590 --- a/arch/um/include/asm/page.h
7591 +++ b/arch/um/include/asm/page.h
7592 @@ -14,6 +14,9 @@
7593 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
7594 #define PAGE_MASK (~(PAGE_SIZE-1))
7595
7596 +#define ktla_ktva(addr) (addr)
7597 +#define ktva_ktla(addr) (addr)
7598 +
7599 #ifndef __ASSEMBLY__
7600
7601 struct page;
7602 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
7603 index 0032f92..cd151e0 100644
7604 --- a/arch/um/include/asm/pgtable-3level.h
7605 +++ b/arch/um/include/asm/pgtable-3level.h
7606 @@ -58,6 +58,7 @@
7607 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
7608 #define pud_populate(mm, pud, pmd) \
7609 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
7610 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
7611
7612 #ifdef CONFIG_64BIT
7613 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
7614 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
7615 index 69f2490..2634831 100644
7616 --- a/arch/um/kernel/process.c
7617 +++ b/arch/um/kernel/process.c
7618 @@ -408,22 +408,6 @@ int singlestepping(void * t)
7619 return 2;
7620 }
7621
7622 -/*
7623 - * Only x86 and x86_64 have an arch_align_stack().
7624 - * All other arches have "#define arch_align_stack(x) (x)"
7625 - * in their asm/system.h
7626 - * As this is included in UML from asm-um/system-generic.h,
7627 - * we can use it to behave as the subarch does.
7628 - */
7629 -#ifndef arch_align_stack
7630 -unsigned long arch_align_stack(unsigned long sp)
7631 -{
7632 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7633 - sp -= get_random_int() % 8192;
7634 - return sp & ~0xf;
7635 -}
7636 -#endif
7637 -
7638 unsigned long get_wchan(struct task_struct *p)
7639 {
7640 unsigned long stack_page, sp, ip;
7641 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
7642 index ad8f795..2c7eec6 100644
7643 --- a/arch/unicore32/include/asm/cache.h
7644 +++ b/arch/unicore32/include/asm/cache.h
7645 @@ -12,8 +12,10 @@
7646 #ifndef __UNICORE_CACHE_H__
7647 #define __UNICORE_CACHE_H__
7648
7649 -#define L1_CACHE_SHIFT (5)
7650 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7651 +#include <linux/const.h>
7652 +
7653 +#define L1_CACHE_SHIFT 5
7654 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7655
7656 /*
7657 * Memory returned by kmalloc() may be used for DMA, so we must make
7658 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
7659 index 5bed94e..fbcf200 100644
7660 --- a/arch/x86/Kconfig
7661 +++ b/arch/x86/Kconfig
7662 @@ -226,7 +226,7 @@ config X86_HT
7663
7664 config X86_32_LAZY_GS
7665 def_bool y
7666 - depends on X86_32 && !CC_STACKPROTECTOR
7667 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
7668
7669 config ARCH_HWEIGHT_CFLAGS
7670 string
7671 @@ -1058,7 +1058,7 @@ choice
7672
7673 config NOHIGHMEM
7674 bool "off"
7675 - depends on !X86_NUMAQ
7676 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
7677 ---help---
7678 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
7679 However, the address space of 32-bit x86 processors is only 4
7680 @@ -1095,7 +1095,7 @@ config NOHIGHMEM
7681
7682 config HIGHMEM4G
7683 bool "4GB"
7684 - depends on !X86_NUMAQ
7685 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
7686 ---help---
7687 Select this if you have a 32-bit processor and between 1 and 4
7688 gigabytes of physical RAM.
7689 @@ -1149,7 +1149,7 @@ config PAGE_OFFSET
7690 hex
7691 default 0xB0000000 if VMSPLIT_3G_OPT
7692 default 0x80000000 if VMSPLIT_2G
7693 - default 0x78000000 if VMSPLIT_2G_OPT
7694 + default 0x70000000 if VMSPLIT_2G_OPT
7695 default 0x40000000 if VMSPLIT_1G
7696 default 0xC0000000
7697 depends on X86_32
7698 @@ -1539,6 +1539,7 @@ config SECCOMP
7699
7700 config CC_STACKPROTECTOR
7701 bool "Enable -fstack-protector buffer overflow detection (EXPERIMENTAL)"
7702 + depends on X86_64 || !PAX_MEMORY_UDEREF
7703 ---help---
7704 This option turns on the -fstack-protector GCC feature. This
7705 feature puts, at the beginning of functions, a canary value on
7706 @@ -1596,6 +1597,7 @@ config KEXEC_JUMP
7707 config PHYSICAL_START
7708 hex "Physical address where the kernel is loaded" if (EXPERT || CRASH_DUMP)
7709 default "0x1000000"
7710 + range 0x400000 0x40000000
7711 ---help---
7712 This gives the physical address where the kernel is loaded.
7713
7714 @@ -1659,6 +1661,7 @@ config X86_NEED_RELOCS
7715 config PHYSICAL_ALIGN
7716 hex "Alignment value to which kernel should be aligned" if X86_32
7717 default "0x1000000"
7718 + range 0x400000 0x1000000 if PAX_KERNEXEC
7719 range 0x2000 0x1000000
7720 ---help---
7721 This value puts the alignment restrictions on physical address
7722 @@ -1690,9 +1693,10 @@ config HOTPLUG_CPU
7723 Say N if you want to disable CPU hotplug.
7724
7725 config COMPAT_VDSO
7726 - def_bool y
7727 + def_bool n
7728 prompt "Compat VDSO support"
7729 depends on X86_32 || IA32_EMULATION
7730 + depends on !PAX_NOEXEC && !PAX_MEMORY_UDEREF
7731 ---help---
7732 Map the 32-bit VDSO to the predictable old-style address too.
7733
7734 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
7735 index 3c57033..22d44aa 100644
7736 --- a/arch/x86/Kconfig.cpu
7737 +++ b/arch/x86/Kconfig.cpu
7738 @@ -335,7 +335,7 @@ config X86_PPRO_FENCE
7739
7740 config X86_F00F_BUG
7741 def_bool y
7742 - depends on M586MMX || M586TSC || M586 || M486 || M386
7743 + depends on (M586MMX || M586TSC || M586 || M486 || M386) && !PAX_KERNEXEC
7744
7745 config X86_INVD_BUG
7746 def_bool y
7747 @@ -359,7 +359,7 @@ config X86_POPAD_OK
7748
7749 config X86_ALIGNMENT_16
7750 def_bool y
7751 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
7752 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
7753
7754 config X86_INTEL_USERCOPY
7755 def_bool y
7756 @@ -405,7 +405,7 @@ config X86_CMPXCHG64
7757 # generates cmov.
7758 config X86_CMOV
7759 def_bool y
7760 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
7761 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
7762
7763 config X86_MINIMUM_CPU_FAMILY
7764 int
7765 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
7766 index e46c214..7c72b55 100644
7767 --- a/arch/x86/Kconfig.debug
7768 +++ b/arch/x86/Kconfig.debug
7769 @@ -84,7 +84,7 @@ config X86_PTDUMP
7770 config DEBUG_RODATA
7771 bool "Write protect kernel read-only data structures"
7772 default y
7773 - depends on DEBUG_KERNEL
7774 + depends on DEBUG_KERNEL && BROKEN
7775 ---help---
7776 Mark the kernel read-only data as write-protected in the pagetables,
7777 in order to catch accidental (and incorrect) writes to such const
7778 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
7779
7780 config DEBUG_SET_MODULE_RONX
7781 bool "Set loadable kernel module data as NX and text as RO"
7782 - depends on MODULES
7783 + depends on MODULES && BROKEN
7784 ---help---
7785 This option helps catch unintended modifications to loadable
7786 kernel module's text and read-only data. It also prevents execution
7787 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
7788 index 209ba12..15140db 100644
7789 --- a/arch/x86/Makefile
7790 +++ b/arch/x86/Makefile
7791 @@ -46,6 +46,7 @@ else
7792 UTS_MACHINE := x86_64
7793 CHECKFLAGS += -D__x86_64__ -m64
7794
7795 + biarch := $(call cc-option,-m64)
7796 KBUILD_AFLAGS += -m64
7797 KBUILD_CFLAGS += -m64
7798
7799 @@ -201,3 +202,12 @@ define archhelp
7800 echo ' FDARGS="..." arguments for the booted kernel'
7801 echo ' FDINITRD=file initrd for the booted kernel'
7802 endef
7803 +
7804 +define OLD_LD
7805 +
7806 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
7807 +*** Please upgrade your binutils to 2.18 or newer
7808 +endef
7809 +
7810 +archprepare:
7811 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
7812 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
7813 index 5a747dd..ff7b12c 100644
7814 --- a/arch/x86/boot/Makefile
7815 +++ b/arch/x86/boot/Makefile
7816 @@ -64,6 +64,9 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
7817 $(call cc-option, -fno-stack-protector) \
7818 $(call cc-option, -mpreferred-stack-boundary=2)
7819 KBUILD_CFLAGS += $(call cc-option, -m32)
7820 +ifdef CONSTIFY_PLUGIN
7821 +KBUILD_CFLAGS += $(CONSTIFY_PLUGIN) -fplugin-arg-constify_plugin-no-constify
7822 +endif
7823 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
7824 GCOV_PROFILE := n
7825
7826 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
7827 index 878e4b9..20537ab 100644
7828 --- a/arch/x86/boot/bitops.h
7829 +++ b/arch/x86/boot/bitops.h
7830 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
7831 u8 v;
7832 const u32 *p = (const u32 *)addr;
7833
7834 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
7835 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
7836 return v;
7837 }
7838
7839 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
7840
7841 static inline void set_bit(int nr, void *addr)
7842 {
7843 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
7844 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
7845 }
7846
7847 #endif /* BOOT_BITOPS_H */
7848 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
7849 index c7093bd..d4247ffe0 100644
7850 --- a/arch/x86/boot/boot.h
7851 +++ b/arch/x86/boot/boot.h
7852 @@ -85,7 +85,7 @@ static inline void io_delay(void)
7853 static inline u16 ds(void)
7854 {
7855 u16 seg;
7856 - asm("movw %%ds,%0" : "=rm" (seg));
7857 + asm volatile("movw %%ds,%0" : "=rm" (seg));
7858 return seg;
7859 }
7860
7861 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
7862 static inline int memcmp(const void *s1, const void *s2, size_t len)
7863 {
7864 u8 diff;
7865 - asm("repe; cmpsb; setnz %0"
7866 + asm volatile("repe; cmpsb; setnz %0"
7867 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
7868 return diff;
7869 }
7870 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
7871 index fd55a2f..217b501 100644
7872 --- a/arch/x86/boot/compressed/Makefile
7873 +++ b/arch/x86/boot/compressed/Makefile
7874 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
7875 KBUILD_CFLAGS += $(cflags-y)
7876 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
7877 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
7878 +ifdef CONSTIFY_PLUGIN
7879 +KBUILD_CFLAGS += $(CONSTIFY_PLUGIN) -fplugin-arg-constify_plugin-no-constify
7880 +endif
7881
7882 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
7883 GCOV_PROFILE := n
7884 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
7885 index 0cdfc0d..6e79437 100644
7886 --- a/arch/x86/boot/compressed/eboot.c
7887 +++ b/arch/x86/boot/compressed/eboot.c
7888 @@ -122,7 +122,6 @@ again:
7889 *addr = max_addr;
7890 }
7891
7892 -free_pool:
7893 efi_call_phys1(sys_table->boottime->free_pool, map);
7894
7895 fail:
7896 @@ -186,7 +185,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
7897 if (i == map_size / desc_size)
7898 status = EFI_NOT_FOUND;
7899
7900 -free_pool:
7901 efi_call_phys1(sys_table->boottime->free_pool, map);
7902 fail:
7903 return status;
7904 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
7905 index c85e3ac..6f5aa80 100644
7906 --- a/arch/x86/boot/compressed/head_32.S
7907 +++ b/arch/x86/boot/compressed/head_32.S
7908 @@ -106,7 +106,7 @@ preferred_addr:
7909 notl %eax
7910 andl %eax, %ebx
7911 #else
7912 - movl $LOAD_PHYSICAL_ADDR, %ebx
7913 + movl $____LOAD_PHYSICAL_ADDR, %ebx
7914 #endif
7915
7916 /* Target address to relocate to for decompression */
7917 @@ -192,7 +192,7 @@ relocated:
7918 * and where it was actually loaded.
7919 */
7920 movl %ebp, %ebx
7921 - subl $LOAD_PHYSICAL_ADDR, %ebx
7922 + subl $____LOAD_PHYSICAL_ADDR, %ebx
7923 jz 2f /* Nothing to be done if loaded at compiled addr. */
7924 /*
7925 * Process relocations.
7926 @@ -200,8 +200,7 @@ relocated:
7927
7928 1: subl $4, %edi
7929 movl (%edi), %ecx
7930 - testl %ecx, %ecx
7931 - jz 2f
7932 + jecxz 2f
7933 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
7934 jmp 1b
7935 2:
7936 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
7937 index 87e03a1..0d94c76 100644
7938 --- a/arch/x86/boot/compressed/head_64.S
7939 +++ b/arch/x86/boot/compressed/head_64.S
7940 @@ -91,7 +91,7 @@ ENTRY(startup_32)
7941 notl %eax
7942 andl %eax, %ebx
7943 #else
7944 - movl $LOAD_PHYSICAL_ADDR, %ebx
7945 + movl $____LOAD_PHYSICAL_ADDR, %ebx
7946 #endif
7947
7948 /* Target address to relocate to for decompression */
7949 @@ -263,7 +263,7 @@ preferred_addr:
7950 notq %rax
7951 andq %rax, %rbp
7952 #else
7953 - movq $LOAD_PHYSICAL_ADDR, %rbp
7954 + movq $____LOAD_PHYSICAL_ADDR, %rbp
7955 #endif
7956
7957 /* Target address to relocate to for decompression */
7958 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
7959 index 7116dcb..d9ae1d7 100644
7960 --- a/arch/x86/boot/compressed/misc.c
7961 +++ b/arch/x86/boot/compressed/misc.c
7962 @@ -310,7 +310,7 @@ static void parse_elf(void *output)
7963 case PT_LOAD:
7964 #ifdef CONFIG_RELOCATABLE
7965 dest = output;
7966 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
7967 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
7968 #else
7969 dest = (void *)(phdr->p_paddr);
7970 #endif
7971 @@ -365,7 +365,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
7972 error("Destination address too large");
7973 #endif
7974 #ifndef CONFIG_RELOCATABLE
7975 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
7976 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
7977 error("Wrong destination address");
7978 #endif
7979
7980 diff --git a/arch/x86/boot/compressed/relocs.c b/arch/x86/boot/compressed/relocs.c
7981 index e77f4e4..17e511f 100644
7982 --- a/arch/x86/boot/compressed/relocs.c
7983 +++ b/arch/x86/boot/compressed/relocs.c
7984 @@ -13,8 +13,11 @@
7985
7986 static void die(char *fmt, ...);
7987
7988 +#include "../../../../include/generated/autoconf.h"
7989 +
7990 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
7991 static Elf32_Ehdr ehdr;
7992 +static Elf32_Phdr *phdr;
7993 static unsigned long reloc_count, reloc_idx;
7994 static unsigned long *relocs;
7995
7996 @@ -270,9 +273,39 @@ static void read_ehdr(FILE *fp)
7997 }
7998 }
7999
8000 +static void read_phdrs(FILE *fp)
8001 +{
8002 + unsigned int i;
8003 +
8004 + phdr = calloc(ehdr.e_phnum, sizeof(Elf32_Phdr));
8005 + if (!phdr) {
8006 + die("Unable to allocate %d program headers\n",
8007 + ehdr.e_phnum);
8008 + }
8009 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
8010 + die("Seek to %d failed: %s\n",
8011 + ehdr.e_phoff, strerror(errno));
8012 + }
8013 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
8014 + die("Cannot read ELF program headers: %s\n",
8015 + strerror(errno));
8016 + }
8017 + for(i = 0; i < ehdr.e_phnum; i++) {
8018 + phdr[i].p_type = elf32_to_cpu(phdr[i].p_type);
8019 + phdr[i].p_offset = elf32_to_cpu(phdr[i].p_offset);
8020 + phdr[i].p_vaddr = elf32_to_cpu(phdr[i].p_vaddr);
8021 + phdr[i].p_paddr = elf32_to_cpu(phdr[i].p_paddr);
8022 + phdr[i].p_filesz = elf32_to_cpu(phdr[i].p_filesz);
8023 + phdr[i].p_memsz = elf32_to_cpu(phdr[i].p_memsz);
8024 + phdr[i].p_flags = elf32_to_cpu(phdr[i].p_flags);
8025 + phdr[i].p_align = elf32_to_cpu(phdr[i].p_align);
8026 + }
8027 +
8028 +}
8029 +
8030 static void read_shdrs(FILE *fp)
8031 {
8032 - int i;
8033 + unsigned int i;
8034 Elf32_Shdr shdr;
8035
8036 secs = calloc(ehdr.e_shnum, sizeof(struct section));
8037 @@ -307,7 +340,7 @@ static void read_shdrs(FILE *fp)
8038
8039 static void read_strtabs(FILE *fp)
8040 {
8041 - int i;
8042 + unsigned int i;
8043 for (i = 0; i < ehdr.e_shnum; i++) {
8044 struct section *sec = &secs[i];
8045 if (sec->shdr.sh_type != SHT_STRTAB) {
8046 @@ -332,7 +365,7 @@ static void read_strtabs(FILE *fp)
8047
8048 static void read_symtabs(FILE *fp)
8049 {
8050 - int i,j;
8051 + unsigned int i,j;
8052 for (i = 0; i < ehdr.e_shnum; i++) {
8053 struct section *sec = &secs[i];
8054 if (sec->shdr.sh_type != SHT_SYMTAB) {
8055 @@ -365,7 +398,9 @@ static void read_symtabs(FILE *fp)
8056
8057 static void read_relocs(FILE *fp)
8058 {
8059 - int i,j;
8060 + unsigned int i,j;
8061 + uint32_t base;
8062 +
8063 for (i = 0; i < ehdr.e_shnum; i++) {
8064 struct section *sec = &secs[i];
8065 if (sec->shdr.sh_type != SHT_REL) {
8066 @@ -385,9 +420,18 @@ static void read_relocs(FILE *fp)
8067 die("Cannot read symbol table: %s\n",
8068 strerror(errno));
8069 }
8070 + base = 0;
8071 + for (j = 0; j < ehdr.e_phnum; j++) {
8072 + if (phdr[j].p_type != PT_LOAD )
8073 + continue;
8074 + 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)
8075 + continue;
8076 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
8077 + break;
8078 + }
8079 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
8080 Elf32_Rel *rel = &sec->reltab[j];
8081 - rel->r_offset = elf32_to_cpu(rel->r_offset);
8082 + rel->r_offset = elf32_to_cpu(rel->r_offset) + base;
8083 rel->r_info = elf32_to_cpu(rel->r_info);
8084 }
8085 }
8086 @@ -396,13 +440,13 @@ static void read_relocs(FILE *fp)
8087
8088 static void print_absolute_symbols(void)
8089 {
8090 - int i;
8091 + unsigned int i;
8092 printf("Absolute symbols\n");
8093 printf(" Num: Value Size Type Bind Visibility Name\n");
8094 for (i = 0; i < ehdr.e_shnum; i++) {
8095 struct section *sec = &secs[i];
8096 char *sym_strtab;
8097 - int j;
8098 + unsigned int j;
8099
8100 if (sec->shdr.sh_type != SHT_SYMTAB) {
8101 continue;
8102 @@ -429,14 +473,14 @@ static void print_absolute_symbols(void)
8103
8104 static void print_absolute_relocs(void)
8105 {
8106 - int i, printed = 0;
8107 + unsigned int i, printed = 0;
8108
8109 for (i = 0; i < ehdr.e_shnum; i++) {
8110 struct section *sec = &secs[i];
8111 struct section *sec_applies, *sec_symtab;
8112 char *sym_strtab;
8113 Elf32_Sym *sh_symtab;
8114 - int j;
8115 + unsigned int j;
8116 if (sec->shdr.sh_type != SHT_REL) {
8117 continue;
8118 }
8119 @@ -497,13 +541,13 @@ static void print_absolute_relocs(void)
8120
8121 static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym))
8122 {
8123 - int i;
8124 + unsigned int i;
8125 /* Walk through the relocations */
8126 for (i = 0; i < ehdr.e_shnum; i++) {
8127 char *sym_strtab;
8128 Elf32_Sym *sh_symtab;
8129 struct section *sec_applies, *sec_symtab;
8130 - int j;
8131 + unsigned int j;
8132 struct section *sec = &secs[i];
8133
8134 if (sec->shdr.sh_type != SHT_REL) {
8135 @@ -528,6 +572,22 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym))
8136 !is_rel_reloc(sym_name(sym_strtab, sym))) {
8137 continue;
8138 }
8139 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
8140 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
8141 + continue;
8142 +
8143 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_X86_32)
8144 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
8145 + if (!strcmp(sec_name(sym->st_shndx), ".module.text") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
8146 + continue;
8147 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
8148 + continue;
8149 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
8150 + continue;
8151 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
8152 + continue;
8153 +#endif
8154 +
8155 switch (r_type) {
8156 case R_386_NONE:
8157 case R_386_PC32:
8158 @@ -569,7 +629,7 @@ static int cmp_relocs(const void *va, const void *vb)
8159
8160 static void emit_relocs(int as_text)
8161 {
8162 - int i;
8163 + unsigned int i;
8164 /* Count how many relocations I have and allocate space for them. */
8165 reloc_count = 0;
8166 walk_relocs(count_reloc);
8167 @@ -663,6 +723,7 @@ int main(int argc, char **argv)
8168 fname, strerror(errno));
8169 }
8170 read_ehdr(fp);
8171 + read_phdrs(fp);
8172 read_shdrs(fp);
8173 read_strtabs(fp);
8174 read_symtabs(fp);
8175 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
8176 index 4d3ff03..e4972ff 100644
8177 --- a/arch/x86/boot/cpucheck.c
8178 +++ b/arch/x86/boot/cpucheck.c
8179 @@ -74,7 +74,7 @@ static int has_fpu(void)
8180 u16 fcw = -1, fsw = -1;
8181 u32 cr0;
8182
8183 - asm("movl %%cr0,%0" : "=r" (cr0));
8184 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
8185 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
8186 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
8187 asm volatile("movl %0,%%cr0" : : "r" (cr0));
8188 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
8189 {
8190 u32 f0, f1;
8191
8192 - asm("pushfl ; "
8193 + asm volatile("pushfl ; "
8194 "pushfl ; "
8195 "popl %0 ; "
8196 "movl %0,%1 ; "
8197 @@ -115,7 +115,7 @@ static void get_flags(void)
8198 set_bit(X86_FEATURE_FPU, cpu.flags);
8199
8200 if (has_eflag(X86_EFLAGS_ID)) {
8201 - asm("cpuid"
8202 + asm volatile("cpuid"
8203 : "=a" (max_intel_level),
8204 "=b" (cpu_vendor[0]),
8205 "=d" (cpu_vendor[1]),
8206 @@ -124,7 +124,7 @@ static void get_flags(void)
8207
8208 if (max_intel_level >= 0x00000001 &&
8209 max_intel_level <= 0x0000ffff) {
8210 - asm("cpuid"
8211 + asm volatile("cpuid"
8212 : "=a" (tfms),
8213 "=c" (cpu.flags[4]),
8214 "=d" (cpu.flags[0])
8215 @@ -136,7 +136,7 @@ static void get_flags(void)
8216 cpu.model += ((tfms >> 16) & 0xf) << 4;
8217 }
8218
8219 - asm("cpuid"
8220 + asm volatile("cpuid"
8221 : "=a" (max_amd_level)
8222 : "a" (0x80000000)
8223 : "ebx", "ecx", "edx");
8224 @@ -144,7 +144,7 @@ static void get_flags(void)
8225 if (max_amd_level >= 0x80000001 &&
8226 max_amd_level <= 0x8000ffff) {
8227 u32 eax = 0x80000001;
8228 - asm("cpuid"
8229 + asm volatile("cpuid"
8230 : "+a" (eax),
8231 "=c" (cpu.flags[6]),
8232 "=d" (cpu.flags[1])
8233 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
8234 u32 ecx = MSR_K7_HWCR;
8235 u32 eax, edx;
8236
8237 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
8238 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
8239 eax &= ~(1 << 15);
8240 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
8241 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
8242
8243 get_flags(); /* Make sure it really did something */
8244 err = check_flags();
8245 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
8246 u32 ecx = MSR_VIA_FCR;
8247 u32 eax, edx;
8248
8249 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
8250 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
8251 eax |= (1<<1)|(1<<7);
8252 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
8253 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
8254
8255 set_bit(X86_FEATURE_CX8, cpu.flags);
8256 err = check_flags();
8257 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
8258 u32 eax, edx;
8259 u32 level = 1;
8260
8261 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
8262 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
8263 - asm("cpuid"
8264 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
8265 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
8266 + asm volatile("cpuid"
8267 : "+a" (level), "=d" (cpu.flags[0])
8268 : : "ecx", "ebx");
8269 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
8270 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
8271
8272 err = check_flags();
8273 }
8274 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
8275 index f1bbeeb..aff09cb 100644
8276 --- a/arch/x86/boot/header.S
8277 +++ b/arch/x86/boot/header.S
8278 @@ -372,7 +372,7 @@ setup_data: .quad 0 # 64-bit physical pointer to
8279 # single linked list of
8280 # struct setup_data
8281
8282 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
8283 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
8284
8285 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
8286 #define VO_INIT_SIZE (VO__end - VO__text)
8287 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
8288 index db75d07..8e6d0af 100644
8289 --- a/arch/x86/boot/memory.c
8290 +++ b/arch/x86/boot/memory.c
8291 @@ -19,7 +19,7 @@
8292
8293 static int detect_memory_e820(void)
8294 {
8295 - int count = 0;
8296 + unsigned int count = 0;
8297 struct biosregs ireg, oreg;
8298 struct e820entry *desc = boot_params.e820_map;
8299 static struct e820entry buf; /* static so it is zeroed */
8300 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
8301 index 11e8c6e..fdbb1ed 100644
8302 --- a/arch/x86/boot/video-vesa.c
8303 +++ b/arch/x86/boot/video-vesa.c
8304 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
8305
8306 boot_params.screen_info.vesapm_seg = oreg.es;
8307 boot_params.screen_info.vesapm_off = oreg.di;
8308 + boot_params.screen_info.vesapm_size = oreg.cx;
8309 }
8310
8311 /*
8312 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
8313 index 43eda28..5ab5fdb 100644
8314 --- a/arch/x86/boot/video.c
8315 +++ b/arch/x86/boot/video.c
8316 @@ -96,7 +96,7 @@ static void store_mode_params(void)
8317 static unsigned int get_entry(void)
8318 {
8319 char entry_buf[4];
8320 - int i, len = 0;
8321 + unsigned int i, len = 0;
8322 int key;
8323 unsigned int v;
8324
8325 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
8326 index 5b577d5..3c1fed4 100644
8327 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
8328 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
8329 @@ -8,6 +8,8 @@
8330 * including this sentence is retained in full.
8331 */
8332
8333 +#include <asm/alternative-asm.h>
8334 +
8335 .extern crypto_ft_tab
8336 .extern crypto_it_tab
8337 .extern crypto_fl_tab
8338 @@ -71,6 +73,8 @@ FUNC: movq r1,r2; \
8339 je B192; \
8340 leaq 32(r9),r9;
8341
8342 +#define ret pax_force_retaddr 0, 1; ret
8343 +
8344 #define epilogue(r1,r2,r3,r4,r5,r6,r7,r8,r9) \
8345 movq r1,r2; \
8346 movq r3,r4; \
8347 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
8348 index be6d9e3..21fbbca 100644
8349 --- a/arch/x86/crypto/aesni-intel_asm.S
8350 +++ b/arch/x86/crypto/aesni-intel_asm.S
8351 @@ -31,6 +31,7 @@
8352
8353 #include <linux/linkage.h>
8354 #include <asm/inst.h>
8355 +#include <asm/alternative-asm.h>
8356
8357 #ifdef __x86_64__
8358 .data
8359 @@ -1436,7 +1437,9 @@ _return_T_done_decrypt:
8360 pop %r14
8361 pop %r13
8362 pop %r12
8363 + pax_force_retaddr 0, 1
8364 ret
8365 +ENDPROC(aesni_gcm_dec)
8366
8367
8368 /*****************************************************************************
8369 @@ -1699,7 +1702,9 @@ _return_T_done_encrypt:
8370 pop %r14
8371 pop %r13
8372 pop %r12
8373 + pax_force_retaddr 0, 1
8374 ret
8375 +ENDPROC(aesni_gcm_enc)
8376
8377 #endif
8378
8379 @@ -1714,6 +1719,7 @@ _key_expansion_256a:
8380 pxor %xmm1, %xmm0
8381 movaps %xmm0, (TKEYP)
8382 add $0x10, TKEYP
8383 + pax_force_retaddr_bts
8384 ret
8385
8386 .align 4
8387 @@ -1738,6 +1744,7 @@ _key_expansion_192a:
8388 shufps $0b01001110, %xmm2, %xmm1
8389 movaps %xmm1, 0x10(TKEYP)
8390 add $0x20, TKEYP
8391 + pax_force_retaddr_bts
8392 ret
8393
8394 .align 4
8395 @@ -1757,6 +1764,7 @@ _key_expansion_192b:
8396
8397 movaps %xmm0, (TKEYP)
8398 add $0x10, TKEYP
8399 + pax_force_retaddr_bts
8400 ret
8401
8402 .align 4
8403 @@ -1769,6 +1777,7 @@ _key_expansion_256b:
8404 pxor %xmm1, %xmm2
8405 movaps %xmm2, (TKEYP)
8406 add $0x10, TKEYP
8407 + pax_force_retaddr_bts
8408 ret
8409
8410 /*
8411 @@ -1881,7 +1890,9 @@ ENTRY(aesni_set_key)
8412 #ifndef __x86_64__
8413 popl KEYP
8414 #endif
8415 + pax_force_retaddr 0, 1
8416 ret
8417 +ENDPROC(aesni_set_key)
8418
8419 /*
8420 * void aesni_enc(struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src)
8421 @@ -1902,7 +1913,9 @@ ENTRY(aesni_enc)
8422 popl KLEN
8423 popl KEYP
8424 #endif
8425 + pax_force_retaddr 0, 1
8426 ret
8427 +ENDPROC(aesni_enc)
8428
8429 /*
8430 * _aesni_enc1: internal ABI
8431 @@ -1959,6 +1972,7 @@ _aesni_enc1:
8432 AESENC KEY STATE
8433 movaps 0x70(TKEYP), KEY
8434 AESENCLAST KEY STATE
8435 + pax_force_retaddr_bts
8436 ret
8437
8438 /*
8439 @@ -2067,6 +2081,7 @@ _aesni_enc4:
8440 AESENCLAST KEY STATE2
8441 AESENCLAST KEY STATE3
8442 AESENCLAST KEY STATE4
8443 + pax_force_retaddr_bts
8444 ret
8445
8446 /*
8447 @@ -2089,7 +2104,9 @@ ENTRY(aesni_dec)
8448 popl KLEN
8449 popl KEYP
8450 #endif
8451 + pax_force_retaddr 0, 1
8452 ret
8453 +ENDPROC(aesni_dec)
8454
8455 /*
8456 * _aesni_dec1: internal ABI
8457 @@ -2146,6 +2163,7 @@ _aesni_dec1:
8458 AESDEC KEY STATE
8459 movaps 0x70(TKEYP), KEY
8460 AESDECLAST KEY STATE
8461 + pax_force_retaddr_bts
8462 ret
8463
8464 /*
8465 @@ -2254,6 +2272,7 @@ _aesni_dec4:
8466 AESDECLAST KEY STATE2
8467 AESDECLAST KEY STATE3
8468 AESDECLAST KEY STATE4
8469 + pax_force_retaddr_bts
8470 ret
8471
8472 /*
8473 @@ -2311,7 +2330,9 @@ ENTRY(aesni_ecb_enc)
8474 popl KEYP
8475 popl LEN
8476 #endif
8477 + pax_force_retaddr 0, 1
8478 ret
8479 +ENDPROC(aesni_ecb_enc)
8480
8481 /*
8482 * void aesni_ecb_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
8483 @@ -2369,7 +2390,9 @@ ENTRY(aesni_ecb_dec)
8484 popl KEYP
8485 popl LEN
8486 #endif
8487 + pax_force_retaddr 0, 1
8488 ret
8489 +ENDPROC(aesni_ecb_dec)
8490
8491 /*
8492 * void aesni_cbc_enc(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
8493 @@ -2410,7 +2433,9 @@ ENTRY(aesni_cbc_enc)
8494 popl LEN
8495 popl IVP
8496 #endif
8497 + pax_force_retaddr 0, 1
8498 ret
8499 +ENDPROC(aesni_cbc_enc)
8500
8501 /*
8502 * void aesni_cbc_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
8503 @@ -2498,7 +2523,9 @@ ENTRY(aesni_cbc_dec)
8504 popl LEN
8505 popl IVP
8506 #endif
8507 + pax_force_retaddr 0, 1
8508 ret
8509 +ENDPROC(aesni_cbc_dec)
8510
8511 #ifdef __x86_64__
8512 .align 16
8513 @@ -2524,6 +2551,7 @@ _aesni_inc_init:
8514 mov $1, TCTR_LOW
8515 MOVQ_R64_XMM TCTR_LOW INC
8516 MOVQ_R64_XMM CTR TCTR_LOW
8517 + pax_force_retaddr_bts
8518 ret
8519
8520 /*
8521 @@ -2552,6 +2580,7 @@ _aesni_inc:
8522 .Linc_low:
8523 movaps CTR, IV
8524 PSHUFB_XMM BSWAP_MASK IV
8525 + pax_force_retaddr_bts
8526 ret
8527
8528 /*
8529 @@ -2612,5 +2641,7 @@ ENTRY(aesni_ctr_enc)
8530 .Lctr_enc_ret:
8531 movups IV, (IVP)
8532 .Lctr_enc_just_ret:
8533 + pax_force_retaddr 0, 1
8534 ret
8535 +ENDPROC(aesni_ctr_enc)
8536 #endif
8537 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
8538 index 391d245..67f35c2 100644
8539 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
8540 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
8541 @@ -20,6 +20,8 @@
8542 *
8543 */
8544
8545 +#include <asm/alternative-asm.h>
8546 +
8547 .file "blowfish-x86_64-asm.S"
8548 .text
8549
8550 @@ -151,9 +153,11 @@ __blowfish_enc_blk:
8551 jnz __enc_xor;
8552
8553 write_block();
8554 + pax_force_retaddr 0, 1
8555 ret;
8556 __enc_xor:
8557 xor_block();
8558 + pax_force_retaddr 0, 1
8559 ret;
8560
8561 .align 8
8562 @@ -188,6 +192,7 @@ blowfish_dec_blk:
8563
8564 movq %r11, %rbp;
8565
8566 + pax_force_retaddr 0, 1
8567 ret;
8568
8569 /**********************************************************************
8570 @@ -342,6 +347,7 @@ __blowfish_enc_blk_4way:
8571
8572 popq %rbx;
8573 popq %rbp;
8574 + pax_force_retaddr 0, 1
8575 ret;
8576
8577 __enc_xor4:
8578 @@ -349,6 +355,7 @@ __enc_xor4:
8579
8580 popq %rbx;
8581 popq %rbp;
8582 + pax_force_retaddr 0, 1
8583 ret;
8584
8585 .align 8
8586 @@ -386,5 +393,6 @@ blowfish_dec_blk_4way:
8587 popq %rbx;
8588 popq %rbp;
8589
8590 + pax_force_retaddr 0, 1
8591 ret;
8592
8593 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
8594 index 6214a9b..1f4fc9a 100644
8595 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
8596 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
8597 @@ -1,3 +1,5 @@
8598 +#include <asm/alternative-asm.h>
8599 +
8600 # enter ECRYPT_encrypt_bytes
8601 .text
8602 .p2align 5
8603 @@ -790,6 +792,7 @@ ECRYPT_encrypt_bytes:
8604 add %r11,%rsp
8605 mov %rdi,%rax
8606 mov %rsi,%rdx
8607 + pax_force_retaddr 0, 1
8608 ret
8609 # bytesatleast65:
8610 ._bytesatleast65:
8611 @@ -891,6 +894,7 @@ ECRYPT_keysetup:
8612 add %r11,%rsp
8613 mov %rdi,%rax
8614 mov %rsi,%rdx
8615 + pax_force_retaddr
8616 ret
8617 # enter ECRYPT_ivsetup
8618 .text
8619 @@ -917,4 +921,5 @@ ECRYPT_ivsetup:
8620 add %r11,%rsp
8621 mov %rdi,%rax
8622 mov %rsi,%rdx
8623 + pax_force_retaddr
8624 ret
8625 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
8626 index 7f24a15..9cd3ffe 100644
8627 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
8628 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
8629 @@ -24,6 +24,8 @@
8630 *
8631 */
8632
8633 +#include <asm/alternative-asm.h>
8634 +
8635 .file "serpent-sse2-x86_64-asm_64.S"
8636 .text
8637
8638 @@ -695,12 +697,14 @@ __serpent_enc_blk_8way:
8639 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
8640 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
8641
8642 + pax_force_retaddr
8643 ret;
8644
8645 __enc_xor8:
8646 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
8647 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
8648
8649 + pax_force_retaddr
8650 ret;
8651
8652 .align 8
8653 @@ -758,4 +762,5 @@ serpent_dec_blk_8way:
8654 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
8655 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
8656
8657 + pax_force_retaddr
8658 ret;
8659 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
8660 index b2c2f57..8470cab 100644
8661 --- a/arch/x86/crypto/sha1_ssse3_asm.S
8662 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
8663 @@ -28,6 +28,8 @@
8664 * (at your option) any later version.
8665 */
8666
8667 +#include <asm/alternative-asm.h>
8668 +
8669 #define CTX %rdi // arg1
8670 #define BUF %rsi // arg2
8671 #define CNT %rdx // arg3
8672 @@ -104,6 +106,7 @@
8673 pop %r12
8674 pop %rbp
8675 pop %rbx
8676 + pax_force_retaddr 0, 1
8677 ret
8678
8679 .size \name, .-\name
8680 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
8681 index 5b012a2..36d5364 100644
8682 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
8683 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
8684 @@ -20,6 +20,8 @@
8685 *
8686 */
8687
8688 +#include <asm/alternative-asm.h>
8689 +
8690 .file "twofish-x86_64-asm-3way.S"
8691 .text
8692
8693 @@ -260,6 +262,7 @@ __twofish_enc_blk_3way:
8694 popq %r13;
8695 popq %r14;
8696 popq %r15;
8697 + pax_force_retaddr 0, 1
8698 ret;
8699
8700 __enc_xor3:
8701 @@ -271,6 +274,7 @@ __enc_xor3:
8702 popq %r13;
8703 popq %r14;
8704 popq %r15;
8705 + pax_force_retaddr 0, 1
8706 ret;
8707
8708 .global twofish_dec_blk_3way
8709 @@ -312,5 +316,6 @@ twofish_dec_blk_3way:
8710 popq %r13;
8711 popq %r14;
8712 popq %r15;
8713 + pax_force_retaddr 0, 1
8714 ret;
8715
8716 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
8717 index 7bcf3fc..f53832f 100644
8718 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
8719 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
8720 @@ -21,6 +21,7 @@
8721 .text
8722
8723 #include <asm/asm-offsets.h>
8724 +#include <asm/alternative-asm.h>
8725
8726 #define a_offset 0
8727 #define b_offset 4
8728 @@ -268,6 +269,7 @@ twofish_enc_blk:
8729
8730 popq R1
8731 movq $1,%rax
8732 + pax_force_retaddr 0, 1
8733 ret
8734
8735 twofish_dec_blk:
8736 @@ -319,4 +321,5 @@ twofish_dec_blk:
8737
8738 popq R1
8739 movq $1,%rax
8740 + pax_force_retaddr 0, 1
8741 ret
8742 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
8743 index 39e4909..887aa7e 100644
8744 --- a/arch/x86/ia32/ia32_aout.c
8745 +++ b/arch/x86/ia32/ia32_aout.c
8746 @@ -162,6 +162,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
8747 unsigned long dump_start, dump_size;
8748 struct user32 dump;
8749
8750 + memset(&dump, 0, sizeof(dump));
8751 +
8752 fs = get_fs();
8753 set_fs(KERNEL_DS);
8754 has_dumped = 1;
8755 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
8756 index 6557769..ef6ae89 100644
8757 --- a/arch/x86/ia32/ia32_signal.c
8758 +++ b/arch/x86/ia32/ia32_signal.c
8759 @@ -169,7 +169,7 @@ asmlinkage long sys32_sigaltstack(const stack_ia32_t __user *uss_ptr,
8760 }
8761 seg = get_fs();
8762 set_fs(KERNEL_DS);
8763 - ret = do_sigaltstack(uss_ptr ? &uss : NULL, &uoss, regs->sp);
8764 + ret = do_sigaltstack(uss_ptr ? (const stack_t __force_user *)&uss : NULL, (stack_t __force_user *)&uoss, regs->sp);
8765 set_fs(seg);
8766 if (ret >= 0 && uoss_ptr) {
8767 if (!access_ok(VERIFY_WRITE, uoss_ptr, sizeof(stack_ia32_t)))
8768 @@ -370,7 +370,7 @@ static int ia32_setup_sigcontext(struct sigcontext_ia32 __user *sc,
8769 */
8770 static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
8771 size_t frame_size,
8772 - void **fpstate)
8773 + void __user **fpstate)
8774 {
8775 unsigned long sp;
8776
8777 @@ -391,7 +391,7 @@ static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
8778
8779 if (used_math()) {
8780 sp = sp - sig_xstate_ia32_size;
8781 - *fpstate = (struct _fpstate_ia32 *) sp;
8782 + *fpstate = (struct _fpstate_ia32 __user *) sp;
8783 if (save_i387_xstate_ia32(*fpstate) < 0)
8784 return (void __user *) -1L;
8785 }
8786 @@ -399,7 +399,7 @@ static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
8787 sp -= frame_size;
8788 /* Align the stack pointer according to the i386 ABI,
8789 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
8790 - sp = ((sp + 4) & -16ul) - 4;
8791 + sp = ((sp - 12) & -16ul) - 4;
8792 return (void __user *) sp;
8793 }
8794
8795 @@ -457,7 +457,7 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
8796 * These are actually not used anymore, but left because some
8797 * gdb versions depend on them as a marker.
8798 */
8799 - put_user_ex(*((u64 *)&code), (u64 *)frame->retcode);
8800 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
8801 } put_user_catch(err);
8802
8803 if (err)
8804 @@ -499,7 +499,7 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
8805 0xb8,
8806 __NR_ia32_rt_sigreturn,
8807 0x80cd,
8808 - 0,
8809 + 0
8810 };
8811
8812 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
8813 @@ -529,16 +529,18 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
8814
8815 if (ka->sa.sa_flags & SA_RESTORER)
8816 restorer = ka->sa.sa_restorer;
8817 + else if (current->mm->context.vdso)
8818 + /* Return stub is in 32bit vsyscall page */
8819 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
8820 else
8821 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
8822 - rt_sigreturn);
8823 + restorer = &frame->retcode;
8824 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
8825
8826 /*
8827 * Not actually used anymore, but left because some gdb
8828 * versions need it.
8829 */
8830 - put_user_ex(*((u64 *)&code), (u64 *)frame->retcode);
8831 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
8832 } put_user_catch(err);
8833
8834 if (err)
8835 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
8836 index e3e7340..05ed805 100644
8837 --- a/arch/x86/ia32/ia32entry.S
8838 +++ b/arch/x86/ia32/ia32entry.S
8839 @@ -13,8 +13,10 @@
8840 #include <asm/thread_info.h>
8841 #include <asm/segment.h>
8842 #include <asm/irqflags.h>
8843 +#include <asm/pgtable.h>
8844 #include <linux/linkage.h>
8845 #include <linux/err.h>
8846 +#include <asm/alternative-asm.h>
8847
8848 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
8849 #include <linux/elf-em.h>
8850 @@ -94,6 +96,32 @@ ENTRY(native_irq_enable_sysexit)
8851 ENDPROC(native_irq_enable_sysexit)
8852 #endif
8853
8854 + .macro pax_enter_kernel_user
8855 + pax_set_fptr_mask
8856 +#ifdef CONFIG_PAX_MEMORY_UDEREF
8857 + call pax_enter_kernel_user
8858 +#endif
8859 + .endm
8860 +
8861 + .macro pax_exit_kernel_user
8862 +#ifdef CONFIG_PAX_MEMORY_UDEREF
8863 + call pax_exit_kernel_user
8864 +#endif
8865 +#ifdef CONFIG_PAX_RANDKSTACK
8866 + pushq %rax
8867 + pushq %r11
8868 + call pax_randomize_kstack
8869 + popq %r11
8870 + popq %rax
8871 +#endif
8872 + .endm
8873 +
8874 +.macro pax_erase_kstack
8875 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
8876 + call pax_erase_kstack
8877 +#endif
8878 +.endm
8879 +
8880 /*
8881 * 32bit SYSENTER instruction entry.
8882 *
8883 @@ -120,12 +148,6 @@ ENTRY(ia32_sysenter_target)
8884 CFI_REGISTER rsp,rbp
8885 SWAPGS_UNSAFE_STACK
8886 movq PER_CPU_VAR(kernel_stack), %rsp
8887 - addq $(KERNEL_STACK_OFFSET),%rsp
8888 - /*
8889 - * No need to follow this irqs on/off section: the syscall
8890 - * disabled irqs, here we enable it straight after entry:
8891 - */
8892 - ENABLE_INTERRUPTS(CLBR_NONE)
8893 movl %ebp,%ebp /* zero extension */
8894 pushq_cfi $__USER32_DS
8895 /*CFI_REL_OFFSET ss,0*/
8896 @@ -133,24 +155,39 @@ ENTRY(ia32_sysenter_target)
8897 CFI_REL_OFFSET rsp,0
8898 pushfq_cfi
8899 /*CFI_REL_OFFSET rflags,0*/
8900 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
8901 - CFI_REGISTER rip,r10
8902 + orl $X86_EFLAGS_IF,(%rsp)
8903 + GET_THREAD_INFO(%r11)
8904 + movl TI_sysenter_return(%r11), %r11d
8905 + CFI_REGISTER rip,r11
8906 pushq_cfi $__USER32_CS
8907 /*CFI_REL_OFFSET cs,0*/
8908 movl %eax, %eax
8909 - pushq_cfi %r10
8910 + pushq_cfi %r11
8911 CFI_REL_OFFSET rip,0
8912 pushq_cfi %rax
8913 cld
8914 SAVE_ARGS 0,1,0
8915 + pax_enter_kernel_user
8916 + /*
8917 + * No need to follow this irqs on/off section: the syscall
8918 + * disabled irqs, here we enable it straight after entry:
8919 + */
8920 + ENABLE_INTERRUPTS(CLBR_NONE)
8921 /* no need to do an access_ok check here because rbp has been
8922 32bit zero extended */
8923 +
8924 +#ifdef CONFIG_PAX_MEMORY_UDEREF
8925 + mov $PAX_USER_SHADOW_BASE,%r11
8926 + add %r11,%rbp
8927 +#endif
8928 +
8929 1: movl (%rbp),%ebp
8930 .section __ex_table,"a"
8931 .quad 1b,ia32_badarg
8932 .previous
8933 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
8934 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
8935 + GET_THREAD_INFO(%r11)
8936 + orl $TS_COMPAT,TI_status(%r11)
8937 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
8938 CFI_REMEMBER_STATE
8939 jnz sysenter_tracesys
8940 cmpq $(IA32_NR_syscalls-1),%rax
8941 @@ -160,12 +197,15 @@ sysenter_do_call:
8942 sysenter_dispatch:
8943 call *ia32_sys_call_table(,%rax,8)
8944 movq %rax,RAX-ARGOFFSET(%rsp)
8945 + GET_THREAD_INFO(%r11)
8946 DISABLE_INTERRUPTS(CLBR_NONE)
8947 TRACE_IRQS_OFF
8948 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
8949 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
8950 jnz sysexit_audit
8951 sysexit_from_sys_call:
8952 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
8953 + pax_exit_kernel_user
8954 + pax_erase_kstack
8955 + andl $~TS_COMPAT,TI_status(%r11)
8956 /* clear IF, that popfq doesn't enable interrupts early */
8957 andl $~0x200,EFLAGS-R11(%rsp)
8958 movl RIP-R11(%rsp),%edx /* User %eip */
8959 @@ -191,6 +231,9 @@ sysexit_from_sys_call:
8960 movl %eax,%esi /* 2nd arg: syscall number */
8961 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
8962 call __audit_syscall_entry
8963 +
8964 + pax_erase_kstack
8965 +
8966 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
8967 cmpq $(IA32_NR_syscalls-1),%rax
8968 ja ia32_badsys
8969 @@ -202,7 +245,7 @@ sysexit_from_sys_call:
8970 .endm
8971
8972 .macro auditsys_exit exit
8973 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
8974 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
8975 jnz ia32_ret_from_sys_call
8976 TRACE_IRQS_ON
8977 sti
8978 @@ -213,11 +256,12 @@ sysexit_from_sys_call:
8979 1: setbe %al /* 1 if error, 0 if not */
8980 movzbl %al,%edi /* zero-extend that into %edi */
8981 call __audit_syscall_exit
8982 + GET_THREAD_INFO(%r11)
8983 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
8984 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
8985 cli
8986 TRACE_IRQS_OFF
8987 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
8988 + testl %edi,TI_flags(%r11)
8989 jz \exit
8990 CLEAR_RREGS -ARGOFFSET
8991 jmp int_with_check
8992 @@ -235,7 +279,7 @@ sysexit_audit:
8993
8994 sysenter_tracesys:
8995 #ifdef CONFIG_AUDITSYSCALL
8996 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
8997 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
8998 jz sysenter_auditsys
8999 #endif
9000 SAVE_REST
9001 @@ -243,6 +287,9 @@ sysenter_tracesys:
9002 movq $-ENOSYS,RAX(%rsp)/* ptrace can change this for a bad syscall */
9003 movq %rsp,%rdi /* &pt_regs -> arg1 */
9004 call syscall_trace_enter
9005 +
9006 + pax_erase_kstack
9007 +
9008 LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */
9009 RESTORE_REST
9010 cmpq $(IA32_NR_syscalls-1),%rax
9011 @@ -274,19 +321,20 @@ ENDPROC(ia32_sysenter_target)
9012 ENTRY(ia32_cstar_target)
9013 CFI_STARTPROC32 simple
9014 CFI_SIGNAL_FRAME
9015 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
9016 + CFI_DEF_CFA rsp,0
9017 CFI_REGISTER rip,rcx
9018 /*CFI_REGISTER rflags,r11*/
9019 SWAPGS_UNSAFE_STACK
9020 movl %esp,%r8d
9021 CFI_REGISTER rsp,r8
9022 movq PER_CPU_VAR(kernel_stack),%rsp
9023 + SAVE_ARGS 8*6,0,0
9024 + pax_enter_kernel_user
9025 /*
9026 * No need to follow this irqs on/off section: the syscall
9027 * disabled irqs and here we enable it straight after entry:
9028 */
9029 ENABLE_INTERRUPTS(CLBR_NONE)
9030 - SAVE_ARGS 8,0,0
9031 movl %eax,%eax /* zero extension */
9032 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
9033 movq %rcx,RIP-ARGOFFSET(%rsp)
9034 @@ -302,12 +350,19 @@ ENTRY(ia32_cstar_target)
9035 /* no need to do an access_ok check here because r8 has been
9036 32bit zero extended */
9037 /* hardware stack frame is complete now */
9038 +
9039 +#ifdef CONFIG_PAX_MEMORY_UDEREF
9040 + mov $PAX_USER_SHADOW_BASE,%r11
9041 + add %r11,%r8
9042 +#endif
9043 +
9044 1: movl (%r8),%r9d
9045 .section __ex_table,"a"
9046 .quad 1b,ia32_badarg
9047 .previous
9048 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
9049 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
9050 + GET_THREAD_INFO(%r11)
9051 + orl $TS_COMPAT,TI_status(%r11)
9052 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
9053 CFI_REMEMBER_STATE
9054 jnz cstar_tracesys
9055 cmpq $IA32_NR_syscalls-1,%rax
9056 @@ -317,12 +372,15 @@ cstar_do_call:
9057 cstar_dispatch:
9058 call *ia32_sys_call_table(,%rax,8)
9059 movq %rax,RAX-ARGOFFSET(%rsp)
9060 + GET_THREAD_INFO(%r11)
9061 DISABLE_INTERRUPTS(CLBR_NONE)
9062 TRACE_IRQS_OFF
9063 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
9064 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
9065 jnz sysretl_audit
9066 sysretl_from_sys_call:
9067 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
9068 + pax_exit_kernel_user
9069 + pax_erase_kstack
9070 + andl $~TS_COMPAT,TI_status(%r11)
9071 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
9072 movl RIP-ARGOFFSET(%rsp),%ecx
9073 CFI_REGISTER rip,rcx
9074 @@ -350,7 +408,7 @@ sysretl_audit:
9075
9076 cstar_tracesys:
9077 #ifdef CONFIG_AUDITSYSCALL
9078 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
9079 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
9080 jz cstar_auditsys
9081 #endif
9082 xchgl %r9d,%ebp
9083 @@ -359,6 +417,9 @@ cstar_tracesys:
9084 movq $-ENOSYS,RAX(%rsp) /* ptrace can change this for a bad syscall */
9085 movq %rsp,%rdi /* &pt_regs -> arg1 */
9086 call syscall_trace_enter
9087 +
9088 + pax_erase_kstack
9089 +
9090 LOAD_ARGS32 ARGOFFSET, 1 /* reload args from stack in case ptrace changed it */
9091 RESTORE_REST
9092 xchgl %ebp,%r9d
9093 @@ -404,19 +465,21 @@ ENTRY(ia32_syscall)
9094 CFI_REL_OFFSET rip,RIP-RIP
9095 PARAVIRT_ADJUST_EXCEPTION_FRAME
9096 SWAPGS
9097 - /*
9098 - * No need to follow this irqs on/off section: the syscall
9099 - * disabled irqs and here we enable it straight after entry:
9100 - */
9101 - ENABLE_INTERRUPTS(CLBR_NONE)
9102 movl %eax,%eax
9103 pushq_cfi %rax
9104 cld
9105 /* note the registers are not zero extended to the sf.
9106 this could be a problem. */
9107 SAVE_ARGS 0,1,0
9108 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
9109 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
9110 + pax_enter_kernel_user
9111 + /*
9112 + * No need to follow this irqs on/off section: the syscall
9113 + * disabled irqs and here we enable it straight after entry:
9114 + */
9115 + ENABLE_INTERRUPTS(CLBR_NONE)
9116 + GET_THREAD_INFO(%r11)
9117 + orl $TS_COMPAT,TI_status(%r11)
9118 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
9119 jnz ia32_tracesys
9120 cmpq $(IA32_NR_syscalls-1),%rax
9121 ja ia32_badsys
9122 @@ -435,6 +498,9 @@ ia32_tracesys:
9123 movq $-ENOSYS,RAX(%rsp) /* ptrace can change this for a bad syscall */
9124 movq %rsp,%rdi /* &pt_regs -> arg1 */
9125 call syscall_trace_enter
9126 +
9127 + pax_erase_kstack
9128 +
9129 LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */
9130 RESTORE_REST
9131 cmpq $(IA32_NR_syscalls-1),%rax
9132 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
9133 index f6f5c53..b358b28 100644
9134 --- a/arch/x86/ia32/sys_ia32.c
9135 +++ b/arch/x86/ia32/sys_ia32.c
9136 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
9137 */
9138 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
9139 {
9140 - typeof(ubuf->st_uid) uid = 0;
9141 - typeof(ubuf->st_gid) gid = 0;
9142 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
9143 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
9144 SET_UID(uid, stat->uid);
9145 SET_GID(gid, stat->gid);
9146 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
9147 @@ -308,8 +308,8 @@ asmlinkage long sys32_rt_sigprocmask(int how, compat_sigset_t __user *set,
9148 }
9149 set_fs(KERNEL_DS);
9150 ret = sys_rt_sigprocmask(how,
9151 - set ? (sigset_t __user *)&s : NULL,
9152 - oset ? (sigset_t __user *)&s : NULL,
9153 + set ? (sigset_t __force_user *)&s : NULL,
9154 + oset ? (sigset_t __force_user *)&s : NULL,
9155 sigsetsize);
9156 set_fs(old_fs);
9157 if (ret)
9158 @@ -332,7 +332,7 @@ asmlinkage long sys32_alarm(unsigned int seconds)
9159 return alarm_setitimer(seconds);
9160 }
9161
9162 -asmlinkage long sys32_waitpid(compat_pid_t pid, unsigned int *stat_addr,
9163 +asmlinkage long sys32_waitpid(compat_pid_t pid, unsigned int __user *stat_addr,
9164 int options)
9165 {
9166 return compat_sys_wait4(pid, stat_addr, options, NULL);
9167 @@ -353,7 +353,7 @@ asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
9168 mm_segment_t old_fs = get_fs();
9169
9170 set_fs(KERNEL_DS);
9171 - ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
9172 + ret = sys_sched_rr_get_interval(pid, (struct timespec __force_user *)&t);
9173 set_fs(old_fs);
9174 if (put_compat_timespec(&t, interval))
9175 return -EFAULT;
9176 @@ -369,7 +369,7 @@ asmlinkage long sys32_rt_sigpending(compat_sigset_t __user *set,
9177 mm_segment_t old_fs = get_fs();
9178
9179 set_fs(KERNEL_DS);
9180 - ret = sys_rt_sigpending((sigset_t __user *)&s, sigsetsize);
9181 + ret = sys_rt_sigpending((sigset_t __force_user *)&s, sigsetsize);
9182 set_fs(old_fs);
9183 if (!ret) {
9184 switch (_NSIG_WORDS) {
9185 @@ -394,7 +394,7 @@ asmlinkage long sys32_rt_sigqueueinfo(int pid, int sig,
9186 if (copy_siginfo_from_user32(&info, uinfo))
9187 return -EFAULT;
9188 set_fs(KERNEL_DS);
9189 - ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *)&info);
9190 + ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __force_user *)&info);
9191 set_fs(old_fs);
9192 return ret;
9193 }
9194 @@ -439,7 +439,7 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd,
9195 return -EFAULT;
9196
9197 set_fs(KERNEL_DS);
9198 - ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL,
9199 + ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __force_user *)&of : NULL,
9200 count);
9201 set_fs(old_fs);
9202
9203 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
9204 index 952bd01..7692c6f 100644
9205 --- a/arch/x86/include/asm/alternative-asm.h
9206 +++ b/arch/x86/include/asm/alternative-asm.h
9207 @@ -15,6 +15,45 @@
9208 .endm
9209 #endif
9210
9211 +#ifdef KERNEXEC_PLUGIN
9212 + .macro pax_force_retaddr_bts rip=0
9213 + btsq $63,\rip(%rsp)
9214 + .endm
9215 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
9216 + .macro pax_force_retaddr rip=0, reload=0
9217 + btsq $63,\rip(%rsp)
9218 + .endm
9219 + .macro pax_force_fptr ptr
9220 + btsq $63,\ptr
9221 + .endm
9222 + .macro pax_set_fptr_mask
9223 + .endm
9224 +#endif
9225 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
9226 + .macro pax_force_retaddr rip=0, reload=0
9227 + .if \reload
9228 + pax_set_fptr_mask
9229 + .endif
9230 + orq %r10,\rip(%rsp)
9231 + .endm
9232 + .macro pax_force_fptr ptr
9233 + orq %r10,\ptr
9234 + .endm
9235 + .macro pax_set_fptr_mask
9236 + movabs $0x8000000000000000,%r10
9237 + .endm
9238 +#endif
9239 +#else
9240 + .macro pax_force_retaddr rip=0, reload=0
9241 + .endm
9242 + .macro pax_force_fptr ptr
9243 + .endm
9244 + .macro pax_force_retaddr_bts rip=0
9245 + .endm
9246 + .macro pax_set_fptr_mask
9247 + .endm
9248 +#endif
9249 +
9250 .macro altinstruction_entry orig alt feature orig_len alt_len
9251 .long \orig - .
9252 .long \alt - .
9253 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
9254 index 37ad100..7d47faa 100644
9255 --- a/arch/x86/include/asm/alternative.h
9256 +++ b/arch/x86/include/asm/alternative.h
9257 @@ -89,7 +89,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
9258 ".section .discard,\"aw\",@progbits\n" \
9259 " .byte 0xff + (664f-663f) - (662b-661b)\n" /* rlen <= slen */ \
9260 ".previous\n" \
9261 - ".section .altinstr_replacement, \"ax\"\n" \
9262 + ".section .altinstr_replacement, \"a\"\n" \
9263 "663:\n\t" newinstr "\n664:\n" /* replacement */ \
9264 ".previous"
9265
9266 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
9267 index 3ab9bdd..238033e 100644
9268 --- a/arch/x86/include/asm/apic.h
9269 +++ b/arch/x86/include/asm/apic.h
9270 @@ -45,7 +45,7 @@ static inline void generic_apic_probe(void)
9271
9272 #ifdef CONFIG_X86_LOCAL_APIC
9273
9274 -extern unsigned int apic_verbosity;
9275 +extern int apic_verbosity;
9276 extern int local_apic_timer_c2_ok;
9277
9278 extern int disable_apic;
9279 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
9280 index 20370c6..a2eb9b0 100644
9281 --- a/arch/x86/include/asm/apm.h
9282 +++ b/arch/x86/include/asm/apm.h
9283 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
9284 __asm__ __volatile__(APM_DO_ZERO_SEGS
9285 "pushl %%edi\n\t"
9286 "pushl %%ebp\n\t"
9287 - "lcall *%%cs:apm_bios_entry\n\t"
9288 + "lcall *%%ss:apm_bios_entry\n\t"
9289 "setc %%al\n\t"
9290 "popl %%ebp\n\t"
9291 "popl %%edi\n\t"
9292 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
9293 __asm__ __volatile__(APM_DO_ZERO_SEGS
9294 "pushl %%edi\n\t"
9295 "pushl %%ebp\n\t"
9296 - "lcall *%%cs:apm_bios_entry\n\t"
9297 + "lcall *%%ss:apm_bios_entry\n\t"
9298 "setc %%bl\n\t"
9299 "popl %%ebp\n\t"
9300 "popl %%edi\n\t"
9301 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
9302 index 58cb6d4..ca9010d 100644
9303 --- a/arch/x86/include/asm/atomic.h
9304 +++ b/arch/x86/include/asm/atomic.h
9305 @@ -22,7 +22,18 @@
9306 */
9307 static inline int atomic_read(const atomic_t *v)
9308 {
9309 - return (*(volatile int *)&(v)->counter);
9310 + return (*(volatile const int *)&(v)->counter);
9311 +}
9312 +
9313 +/**
9314 + * atomic_read_unchecked - read atomic variable
9315 + * @v: pointer of type atomic_unchecked_t
9316 + *
9317 + * Atomically reads the value of @v.
9318 + */
9319 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
9320 +{
9321 + return (*(volatile const int *)&(v)->counter);
9322 }
9323
9324 /**
9325 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
9326 }
9327
9328 /**
9329 + * atomic_set_unchecked - set atomic variable
9330 + * @v: pointer of type atomic_unchecked_t
9331 + * @i: required value
9332 + *
9333 + * Atomically sets the value of @v to @i.
9334 + */
9335 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
9336 +{
9337 + v->counter = i;
9338 +}
9339 +
9340 +/**
9341 * atomic_add - add integer to atomic variable
9342 * @i: integer value to add
9343 * @v: pointer of type atomic_t
9344 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
9345 */
9346 static inline void atomic_add(int i, atomic_t *v)
9347 {
9348 - asm volatile(LOCK_PREFIX "addl %1,%0"
9349 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
9350 +
9351 +#ifdef CONFIG_PAX_REFCOUNT
9352 + "jno 0f\n"
9353 + LOCK_PREFIX "subl %1,%0\n"
9354 + "int $4\n0:\n"
9355 + _ASM_EXTABLE(0b, 0b)
9356 +#endif
9357 +
9358 + : "+m" (v->counter)
9359 + : "ir" (i));
9360 +}
9361 +
9362 +/**
9363 + * atomic_add_unchecked - add integer to atomic variable
9364 + * @i: integer value to add
9365 + * @v: pointer of type atomic_unchecked_t
9366 + *
9367 + * Atomically adds @i to @v.
9368 + */
9369 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
9370 +{
9371 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
9372 : "+m" (v->counter)
9373 : "ir" (i));
9374 }
9375 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
9376 */
9377 static inline void atomic_sub(int i, atomic_t *v)
9378 {
9379 - asm volatile(LOCK_PREFIX "subl %1,%0"
9380 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
9381 +
9382 +#ifdef CONFIG_PAX_REFCOUNT
9383 + "jno 0f\n"
9384 + LOCK_PREFIX "addl %1,%0\n"
9385 + "int $4\n0:\n"
9386 + _ASM_EXTABLE(0b, 0b)
9387 +#endif
9388 +
9389 + : "+m" (v->counter)
9390 + : "ir" (i));
9391 +}
9392 +
9393 +/**
9394 + * atomic_sub_unchecked - subtract integer from atomic variable
9395 + * @i: integer value to subtract
9396 + * @v: pointer of type atomic_unchecked_t
9397 + *
9398 + * Atomically subtracts @i from @v.
9399 + */
9400 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
9401 +{
9402 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
9403 : "+m" (v->counter)
9404 : "ir" (i));
9405 }
9406 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
9407 {
9408 unsigned char c;
9409
9410 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
9411 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
9412 +
9413 +#ifdef CONFIG_PAX_REFCOUNT
9414 + "jno 0f\n"
9415 + LOCK_PREFIX "addl %2,%0\n"
9416 + "int $4\n0:\n"
9417 + _ASM_EXTABLE(0b, 0b)
9418 +#endif
9419 +
9420 + "sete %1\n"
9421 : "+m" (v->counter), "=qm" (c)
9422 : "ir" (i) : "memory");
9423 return c;
9424 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
9425 */
9426 static inline void atomic_inc(atomic_t *v)
9427 {
9428 - asm volatile(LOCK_PREFIX "incl %0"
9429 + asm volatile(LOCK_PREFIX "incl %0\n"
9430 +
9431 +#ifdef CONFIG_PAX_REFCOUNT
9432 + "jno 0f\n"
9433 + LOCK_PREFIX "decl %0\n"
9434 + "int $4\n0:\n"
9435 + _ASM_EXTABLE(0b, 0b)
9436 +#endif
9437 +
9438 + : "+m" (v->counter));
9439 +}
9440 +
9441 +/**
9442 + * atomic_inc_unchecked - increment atomic variable
9443 + * @v: pointer of type atomic_unchecked_t
9444 + *
9445 + * Atomically increments @v by 1.
9446 + */
9447 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
9448 +{
9449 + asm volatile(LOCK_PREFIX "incl %0\n"
9450 : "+m" (v->counter));
9451 }
9452
9453 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
9454 */
9455 static inline void atomic_dec(atomic_t *v)
9456 {
9457 - asm volatile(LOCK_PREFIX "decl %0"
9458 + asm volatile(LOCK_PREFIX "decl %0\n"
9459 +
9460 +#ifdef CONFIG_PAX_REFCOUNT
9461 + "jno 0f\n"
9462 + LOCK_PREFIX "incl %0\n"
9463 + "int $4\n0:\n"
9464 + _ASM_EXTABLE(0b, 0b)
9465 +#endif
9466 +
9467 + : "+m" (v->counter));
9468 +}
9469 +
9470 +/**
9471 + * atomic_dec_unchecked - decrement atomic variable
9472 + * @v: pointer of type atomic_unchecked_t
9473 + *
9474 + * Atomically decrements @v by 1.
9475 + */
9476 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
9477 +{
9478 + asm volatile(LOCK_PREFIX "decl %0\n"
9479 : "+m" (v->counter));
9480 }
9481
9482 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
9483 {
9484 unsigned char c;
9485
9486 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
9487 + asm volatile(LOCK_PREFIX "decl %0\n"
9488 +
9489 +#ifdef CONFIG_PAX_REFCOUNT
9490 + "jno 0f\n"
9491 + LOCK_PREFIX "incl %0\n"
9492 + "int $4\n0:\n"
9493 + _ASM_EXTABLE(0b, 0b)
9494 +#endif
9495 +
9496 + "sete %1\n"
9497 : "+m" (v->counter), "=qm" (c)
9498 : : "memory");
9499 return c != 0;
9500 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
9501 {
9502 unsigned char c;
9503
9504 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
9505 + asm volatile(LOCK_PREFIX "incl %0\n"
9506 +
9507 +#ifdef CONFIG_PAX_REFCOUNT
9508 + "jno 0f\n"
9509 + LOCK_PREFIX "decl %0\n"
9510 + "int $4\n0:\n"
9511 + _ASM_EXTABLE(0b, 0b)
9512 +#endif
9513 +
9514 + "sete %1\n"
9515 + : "+m" (v->counter), "=qm" (c)
9516 + : : "memory");
9517 + return c != 0;
9518 +}
9519 +
9520 +/**
9521 + * atomic_inc_and_test_unchecked - increment and test
9522 + * @v: pointer of type atomic_unchecked_t
9523 + *
9524 + * Atomically increments @v by 1
9525 + * and returns true if the result is zero, or false for all
9526 + * other cases.
9527 + */
9528 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
9529 +{
9530 + unsigned char c;
9531 +
9532 + asm volatile(LOCK_PREFIX "incl %0\n"
9533 + "sete %1\n"
9534 : "+m" (v->counter), "=qm" (c)
9535 : : "memory");
9536 return c != 0;
9537 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
9538 {
9539 unsigned char c;
9540
9541 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
9542 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
9543 +
9544 +#ifdef CONFIG_PAX_REFCOUNT
9545 + "jno 0f\n"
9546 + LOCK_PREFIX "subl %2,%0\n"
9547 + "int $4\n0:\n"
9548 + _ASM_EXTABLE(0b, 0b)
9549 +#endif
9550 +
9551 + "sets %1\n"
9552 : "+m" (v->counter), "=qm" (c)
9553 : "ir" (i) : "memory");
9554 return c;
9555 @@ -179,7 +341,7 @@ static inline int atomic_add_return(int i, atomic_t *v)
9556 goto no_xadd;
9557 #endif
9558 /* Modern 486+ processor */
9559 - return i + xadd(&v->counter, i);
9560 + return i + xadd_check_overflow(&v->counter, i);
9561
9562 #ifdef CONFIG_M386
9563 no_xadd: /* Legacy 386 processor */
9564 @@ -192,6 +354,34 @@ no_xadd: /* Legacy 386 processor */
9565 }
9566
9567 /**
9568 + * atomic_add_return_unchecked - add integer and return
9569 + * @i: integer value to add
9570 + * @v: pointer of type atomic_unchecked_t
9571 + *
9572 + * Atomically adds @i to @v and returns @i + @v
9573 + */
9574 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
9575 +{
9576 +#ifdef CONFIG_M386
9577 + int __i;
9578 + unsigned long flags;
9579 + if (unlikely(boot_cpu_data.x86 <= 3))
9580 + goto no_xadd;
9581 +#endif
9582 + /* Modern 486+ processor */
9583 + return i + xadd(&v->counter, i);
9584 +
9585 +#ifdef CONFIG_M386
9586 +no_xadd: /* Legacy 386 processor */
9587 + raw_local_irq_save(flags);
9588 + __i = atomic_read_unchecked(v);
9589 + atomic_set_unchecked(v, i + __i);
9590 + raw_local_irq_restore(flags);
9591 + return i + __i;
9592 +#endif
9593 +}
9594 +
9595 +/**
9596 * atomic_sub_return - subtract integer and return
9597 * @v: pointer of type atomic_t
9598 * @i: integer value to subtract
9599 @@ -204,6 +394,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
9600 }
9601
9602 #define atomic_inc_return(v) (atomic_add_return(1, v))
9603 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
9604 +{
9605 + return atomic_add_return_unchecked(1, v);
9606 +}
9607 #define atomic_dec_return(v) (atomic_sub_return(1, v))
9608
9609 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
9610 @@ -211,11 +405,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
9611 return cmpxchg(&v->counter, old, new);
9612 }
9613
9614 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
9615 +{
9616 + return cmpxchg(&v->counter, old, new);
9617 +}
9618 +
9619 static inline int atomic_xchg(atomic_t *v, int new)
9620 {
9621 return xchg(&v->counter, new);
9622 }
9623
9624 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
9625 +{
9626 + return xchg(&v->counter, new);
9627 +}
9628 +
9629 /**
9630 * __atomic_add_unless - add unless the number is already a given value
9631 * @v: pointer of type atomic_t
9632 @@ -227,12 +431,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
9633 */
9634 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9635 {
9636 - int c, old;
9637 + int c, old, new;
9638 c = atomic_read(v);
9639 for (;;) {
9640 - if (unlikely(c == (u)))
9641 + if (unlikely(c == u))
9642 break;
9643 - old = atomic_cmpxchg((v), c, c + (a));
9644 +
9645 + asm volatile("addl %2,%0\n"
9646 +
9647 +#ifdef CONFIG_PAX_REFCOUNT
9648 + "jno 0f\n"
9649 + "subl %2,%0\n"
9650 + "int $4\n0:\n"
9651 + _ASM_EXTABLE(0b, 0b)
9652 +#endif
9653 +
9654 + : "=r" (new)
9655 + : "0" (c), "ir" (a));
9656 +
9657 + old = atomic_cmpxchg(v, c, new);
9658 if (likely(old == c))
9659 break;
9660 c = old;
9661 @@ -240,6 +457,48 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9662 return c;
9663 }
9664
9665 +/**
9666 + * atomic_inc_not_zero_hint - increment if not null
9667 + * @v: pointer of type atomic_t
9668 + * @hint: probable value of the atomic before the increment
9669 + *
9670 + * This version of atomic_inc_not_zero() gives a hint of probable
9671 + * value of the atomic. This helps processor to not read the memory
9672 + * before doing the atomic read/modify/write cycle, lowering
9673 + * number of bus transactions on some arches.
9674 + *
9675 + * Returns: 0 if increment was not done, 1 otherwise.
9676 + */
9677 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
9678 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
9679 +{
9680 + int val, c = hint, new;
9681 +
9682 + /* sanity test, should be removed by compiler if hint is a constant */
9683 + if (!hint)
9684 + return __atomic_add_unless(v, 1, 0);
9685 +
9686 + do {
9687 + asm volatile("incl %0\n"
9688 +
9689 +#ifdef CONFIG_PAX_REFCOUNT
9690 + "jno 0f\n"
9691 + "decl %0\n"
9692 + "int $4\n0:\n"
9693 + _ASM_EXTABLE(0b, 0b)
9694 +#endif
9695 +
9696 + : "=r" (new)
9697 + : "0" (c));
9698 +
9699 + val = atomic_cmpxchg(v, c, new);
9700 + if (val == c)
9701 + return 1;
9702 + c = val;
9703 + } while (c);
9704 +
9705 + return 0;
9706 +}
9707
9708 /*
9709 * atomic_dec_if_positive - decrement by 1 if old value positive
9710 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
9711 index fa13f0e..27c2e08 100644
9712 --- a/arch/x86/include/asm/atomic64_32.h
9713 +++ b/arch/x86/include/asm/atomic64_32.h
9714 @@ -12,6 +12,14 @@ typedef struct {
9715 u64 __aligned(8) counter;
9716 } atomic64_t;
9717
9718 +#ifdef CONFIG_PAX_REFCOUNT
9719 +typedef struct {
9720 + u64 __aligned(8) counter;
9721 +} atomic64_unchecked_t;
9722 +#else
9723 +typedef atomic64_t atomic64_unchecked_t;
9724 +#endif
9725 +
9726 #define ATOMIC64_INIT(val) { (val) }
9727
9728 #ifdef CONFIG_X86_CMPXCHG64
9729 @@ -38,6 +46,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
9730 }
9731
9732 /**
9733 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
9734 + * @p: pointer to type atomic64_unchecked_t
9735 + * @o: expected value
9736 + * @n: new value
9737 + *
9738 + * Atomically sets @v to @n if it was equal to @o and returns
9739 + * the old value.
9740 + */
9741 +
9742 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
9743 +{
9744 + return cmpxchg64(&v->counter, o, n);
9745 +}
9746 +
9747 +/**
9748 * atomic64_xchg - xchg atomic64 variable
9749 * @v: pointer to type atomic64_t
9750 * @n: value to assign
9751 @@ -77,6 +100,24 @@ static inline void atomic64_set(atomic64_t *v, long long i)
9752 }
9753
9754 /**
9755 + * atomic64_set_unchecked - set atomic64 variable
9756 + * @v: pointer to type atomic64_unchecked_t
9757 + * @n: value to assign
9758 + *
9759 + * Atomically sets the value of @v to @n.
9760 + */
9761 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
9762 +{
9763 + unsigned high = (unsigned)(i >> 32);
9764 + unsigned low = (unsigned)i;
9765 + asm volatile(ATOMIC64_ALTERNATIVE(set)
9766 + : "+b" (low), "+c" (high)
9767 + : "S" (v)
9768 + : "eax", "edx", "memory"
9769 + );
9770 +}
9771 +
9772 +/**
9773 * atomic64_read - read atomic64 variable
9774 * @v: pointer to type atomic64_t
9775 *
9776 @@ -93,6 +134,22 @@ static inline long long atomic64_read(const atomic64_t *v)
9777 }
9778
9779 /**
9780 + * atomic64_read_unchecked - read atomic64 variable
9781 + * @v: pointer to type atomic64_unchecked_t
9782 + *
9783 + * Atomically reads the value of @v and returns it.
9784 + */
9785 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
9786 +{
9787 + long long r;
9788 + asm volatile(ATOMIC64_ALTERNATIVE(read_unchecked)
9789 + : "=A" (r), "+c" (v)
9790 + : : "memory"
9791 + );
9792 + return r;
9793 + }
9794 +
9795 +/**
9796 * atomic64_add_return - add and return
9797 * @i: integer value to add
9798 * @v: pointer to type atomic64_t
9799 @@ -108,6 +165,22 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
9800 return i;
9801 }
9802
9803 +/**
9804 + * atomic64_add_return_unchecked - add and return
9805 + * @i: integer value to add
9806 + * @v: pointer to type atomic64_unchecked_t
9807 + *
9808 + * Atomically adds @i to @v and returns @i + *@v
9809 + */
9810 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
9811 +{
9812 + asm volatile(ATOMIC64_ALTERNATIVE(add_return_unchecked)
9813 + : "+A" (i), "+c" (v)
9814 + : : "memory"
9815 + );
9816 + return i;
9817 +}
9818 +
9819 /*
9820 * Other variants with different arithmetic operators:
9821 */
9822 @@ -131,6 +204,17 @@ static inline long long atomic64_inc_return(atomic64_t *v)
9823 return a;
9824 }
9825
9826 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
9827 +{
9828 + long long a;
9829 + asm volatile(ATOMIC64_ALTERNATIVE(inc_return_unchecked)
9830 + : "=A" (a)
9831 + : "S" (v)
9832 + : "memory", "ecx"
9833 + );
9834 + return a;
9835 +}
9836 +
9837 static inline long long atomic64_dec_return(atomic64_t *v)
9838 {
9839 long long a;
9840 @@ -159,6 +243,22 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
9841 }
9842
9843 /**
9844 + * atomic64_add_unchecked - add integer to atomic64 variable
9845 + * @i: integer value to add
9846 + * @v: pointer to type atomic64_unchecked_t
9847 + *
9848 + * Atomically adds @i to @v.
9849 + */
9850 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
9851 +{
9852 + asm volatile(ATOMIC64_ALTERNATIVE_(add_unchecked, add_return_unchecked)
9853 + : "+A" (i), "+c" (v)
9854 + : : "memory"
9855 + );
9856 + return i;
9857 +}
9858 +
9859 +/**
9860 * atomic64_sub - subtract the atomic64 variable
9861 * @i: integer value to subtract
9862 * @v: pointer to type atomic64_t
9863 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
9864 index 0e1cbfc..5623683 100644
9865 --- a/arch/x86/include/asm/atomic64_64.h
9866 +++ b/arch/x86/include/asm/atomic64_64.h
9867 @@ -18,7 +18,19 @@
9868 */
9869 static inline long atomic64_read(const atomic64_t *v)
9870 {
9871 - return (*(volatile long *)&(v)->counter);
9872 + return (*(volatile const long *)&(v)->counter);
9873 +}
9874 +
9875 +/**
9876 + * atomic64_read_unchecked - read atomic64 variable
9877 + * @v: pointer of type atomic64_unchecked_t
9878 + *
9879 + * Atomically reads the value of @v.
9880 + * Doesn't imply a read memory barrier.
9881 + */
9882 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
9883 +{
9884 + return (*(volatile const long *)&(v)->counter);
9885 }
9886
9887 /**
9888 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
9889 }
9890
9891 /**
9892 + * atomic64_set_unchecked - set atomic64 variable
9893 + * @v: pointer to type atomic64_unchecked_t
9894 + * @i: required value
9895 + *
9896 + * Atomically sets the value of @v to @i.
9897 + */
9898 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
9899 +{
9900 + v->counter = i;
9901 +}
9902 +
9903 +/**
9904 * atomic64_add - add integer to atomic64 variable
9905 * @i: integer value to add
9906 * @v: pointer to type atomic64_t
9907 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
9908 */
9909 static inline void atomic64_add(long i, atomic64_t *v)
9910 {
9911 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
9912 +
9913 +#ifdef CONFIG_PAX_REFCOUNT
9914 + "jno 0f\n"
9915 + LOCK_PREFIX "subq %1,%0\n"
9916 + "int $4\n0:\n"
9917 + _ASM_EXTABLE(0b, 0b)
9918 +#endif
9919 +
9920 + : "=m" (v->counter)
9921 + : "er" (i), "m" (v->counter));
9922 +}
9923 +
9924 +/**
9925 + * atomic64_add_unchecked - add integer to atomic64 variable
9926 + * @i: integer value to add
9927 + * @v: pointer to type atomic64_unchecked_t
9928 + *
9929 + * Atomically adds @i to @v.
9930 + */
9931 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
9932 +{
9933 asm volatile(LOCK_PREFIX "addq %1,%0"
9934 : "=m" (v->counter)
9935 : "er" (i), "m" (v->counter));
9936 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
9937 */
9938 static inline void atomic64_sub(long i, atomic64_t *v)
9939 {
9940 - asm volatile(LOCK_PREFIX "subq %1,%0"
9941 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
9942 +
9943 +#ifdef CONFIG_PAX_REFCOUNT
9944 + "jno 0f\n"
9945 + LOCK_PREFIX "addq %1,%0\n"
9946 + "int $4\n0:\n"
9947 + _ASM_EXTABLE(0b, 0b)
9948 +#endif
9949 +
9950 + : "=m" (v->counter)
9951 + : "er" (i), "m" (v->counter));
9952 +}
9953 +
9954 +/**
9955 + * atomic64_sub_unchecked - subtract the atomic64 variable
9956 + * @i: integer value to subtract
9957 + * @v: pointer to type atomic64_unchecked_t
9958 + *
9959 + * Atomically subtracts @i from @v.
9960 + */
9961 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
9962 +{
9963 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
9964 : "=m" (v->counter)
9965 : "er" (i), "m" (v->counter));
9966 }
9967 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
9968 {
9969 unsigned char c;
9970
9971 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
9972 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
9973 +
9974 +#ifdef CONFIG_PAX_REFCOUNT
9975 + "jno 0f\n"
9976 + LOCK_PREFIX "addq %2,%0\n"
9977 + "int $4\n0:\n"
9978 + _ASM_EXTABLE(0b, 0b)
9979 +#endif
9980 +
9981 + "sete %1\n"
9982 : "=m" (v->counter), "=qm" (c)
9983 : "er" (i), "m" (v->counter) : "memory");
9984 return c;
9985 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
9986 */
9987 static inline void atomic64_inc(atomic64_t *v)
9988 {
9989 + asm volatile(LOCK_PREFIX "incq %0\n"
9990 +
9991 +#ifdef CONFIG_PAX_REFCOUNT
9992 + "jno 0f\n"
9993 + LOCK_PREFIX "decq %0\n"
9994 + "int $4\n0:\n"
9995 + _ASM_EXTABLE(0b, 0b)
9996 +#endif
9997 +
9998 + : "=m" (v->counter)
9999 + : "m" (v->counter));
10000 +}
10001 +
10002 +/**
10003 + * atomic64_inc_unchecked - increment atomic64 variable
10004 + * @v: pointer to type atomic64_unchecked_t
10005 + *
10006 + * Atomically increments @v by 1.
10007 + */
10008 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
10009 +{
10010 asm volatile(LOCK_PREFIX "incq %0"
10011 : "=m" (v->counter)
10012 : "m" (v->counter));
10013 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
10014 */
10015 static inline void atomic64_dec(atomic64_t *v)
10016 {
10017 - asm volatile(LOCK_PREFIX "decq %0"
10018 + asm volatile(LOCK_PREFIX "decq %0\n"
10019 +
10020 +#ifdef CONFIG_PAX_REFCOUNT
10021 + "jno 0f\n"
10022 + LOCK_PREFIX "incq %0\n"
10023 + "int $4\n0:\n"
10024 + _ASM_EXTABLE(0b, 0b)
10025 +#endif
10026 +
10027 + : "=m" (v->counter)
10028 + : "m" (v->counter));
10029 +}
10030 +
10031 +/**
10032 + * atomic64_dec_unchecked - decrement atomic64 variable
10033 + * @v: pointer to type atomic64_t
10034 + *
10035 + * Atomically decrements @v by 1.
10036 + */
10037 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
10038 +{
10039 + asm volatile(LOCK_PREFIX "decq %0\n"
10040 : "=m" (v->counter)
10041 : "m" (v->counter));
10042 }
10043 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
10044 {
10045 unsigned char c;
10046
10047 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
10048 + asm volatile(LOCK_PREFIX "decq %0\n"
10049 +
10050 +#ifdef CONFIG_PAX_REFCOUNT
10051 + "jno 0f\n"
10052 + LOCK_PREFIX "incq %0\n"
10053 + "int $4\n0:\n"
10054 + _ASM_EXTABLE(0b, 0b)
10055 +#endif
10056 +
10057 + "sete %1\n"
10058 : "=m" (v->counter), "=qm" (c)
10059 : "m" (v->counter) : "memory");
10060 return c != 0;
10061 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
10062 {
10063 unsigned char c;
10064
10065 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
10066 + asm volatile(LOCK_PREFIX "incq %0\n"
10067 +
10068 +#ifdef CONFIG_PAX_REFCOUNT
10069 + "jno 0f\n"
10070 + LOCK_PREFIX "decq %0\n"
10071 + "int $4\n0:\n"
10072 + _ASM_EXTABLE(0b, 0b)
10073 +#endif
10074 +
10075 + "sete %1\n"
10076 : "=m" (v->counter), "=qm" (c)
10077 : "m" (v->counter) : "memory");
10078 return c != 0;
10079 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
10080 {
10081 unsigned char c;
10082
10083 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
10084 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
10085 +
10086 +#ifdef CONFIG_PAX_REFCOUNT
10087 + "jno 0f\n"
10088 + LOCK_PREFIX "subq %2,%0\n"
10089 + "int $4\n0:\n"
10090 + _ASM_EXTABLE(0b, 0b)
10091 +#endif
10092 +
10093 + "sets %1\n"
10094 : "=m" (v->counter), "=qm" (c)
10095 : "er" (i), "m" (v->counter) : "memory");
10096 return c;
10097 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
10098 */
10099 static inline long atomic64_add_return(long i, atomic64_t *v)
10100 {
10101 + return i + xadd_check_overflow(&v->counter, i);
10102 +}
10103 +
10104 +/**
10105 + * atomic64_add_return_unchecked - add and return
10106 + * @i: integer value to add
10107 + * @v: pointer to type atomic64_unchecked_t
10108 + *
10109 + * Atomically adds @i to @v and returns @i + @v
10110 + */
10111 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
10112 +{
10113 return i + xadd(&v->counter, i);
10114 }
10115
10116 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
10117 }
10118
10119 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
10120 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
10121 +{
10122 + return atomic64_add_return_unchecked(1, v);
10123 +}
10124 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
10125
10126 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
10127 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
10128 return cmpxchg(&v->counter, old, new);
10129 }
10130
10131 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
10132 +{
10133 + return cmpxchg(&v->counter, old, new);
10134 +}
10135 +
10136 static inline long atomic64_xchg(atomic64_t *v, long new)
10137 {
10138 return xchg(&v->counter, new);
10139 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
10140 */
10141 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
10142 {
10143 - long c, old;
10144 + long c, old, new;
10145 c = atomic64_read(v);
10146 for (;;) {
10147 - if (unlikely(c == (u)))
10148 + if (unlikely(c == u))
10149 break;
10150 - old = atomic64_cmpxchg((v), c, c + (a));
10151 +
10152 + asm volatile("add %2,%0\n"
10153 +
10154 +#ifdef CONFIG_PAX_REFCOUNT
10155 + "jno 0f\n"
10156 + "sub %2,%0\n"
10157 + "int $4\n0:\n"
10158 + _ASM_EXTABLE(0b, 0b)
10159 +#endif
10160 +
10161 + : "=r" (new)
10162 + : "0" (c), "ir" (a));
10163 +
10164 + old = atomic64_cmpxchg(v, c, new);
10165 if (likely(old == c))
10166 break;
10167 c = old;
10168 }
10169 - return c != (u);
10170 + return c != u;
10171 }
10172
10173 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
10174 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
10175 index b97596e..9bd48b06 100644
10176 --- a/arch/x86/include/asm/bitops.h
10177 +++ b/arch/x86/include/asm/bitops.h
10178 @@ -38,7 +38,7 @@
10179 * a mask operation on a byte.
10180 */
10181 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
10182 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
10183 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
10184 #define CONST_MASK(nr) (1 << ((nr) & 7))
10185
10186 /**
10187 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
10188 index 5e1a2ee..c9f9533 100644
10189 --- a/arch/x86/include/asm/boot.h
10190 +++ b/arch/x86/include/asm/boot.h
10191 @@ -11,10 +11,15 @@
10192 #include <asm/pgtable_types.h>
10193
10194 /* Physical address where kernel should be loaded. */
10195 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
10196 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
10197 + (CONFIG_PHYSICAL_ALIGN - 1)) \
10198 & ~(CONFIG_PHYSICAL_ALIGN - 1))
10199
10200 +#ifndef __ASSEMBLY__
10201 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
10202 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
10203 +#endif
10204 +
10205 /* Minimum kernel alignment, as a power of two */
10206 #ifdef CONFIG_X86_64
10207 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
10208 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
10209 index 48f99f1..d78ebf9 100644
10210 --- a/arch/x86/include/asm/cache.h
10211 +++ b/arch/x86/include/asm/cache.h
10212 @@ -5,12 +5,13 @@
10213
10214 /* L1 cache line size */
10215 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10216 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10217 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10218
10219 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
10220 +#define __read_only __attribute__((__section__(".data..read_only")))
10221
10222 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
10223 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
10224 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
10225
10226 #ifdef CONFIG_X86_VSMP
10227 #ifdef CONFIG_SMP
10228 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
10229 index 4e12668..501d239 100644
10230 --- a/arch/x86/include/asm/cacheflush.h
10231 +++ b/arch/x86/include/asm/cacheflush.h
10232 @@ -26,7 +26,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
10233 unsigned long pg_flags = pg->flags & _PGMT_MASK;
10234
10235 if (pg_flags == _PGMT_DEFAULT)
10236 - return -1;
10237 + return ~0UL;
10238 else if (pg_flags == _PGMT_WC)
10239 return _PAGE_CACHE_WC;
10240 else if (pg_flags == _PGMT_UC_MINUS)
10241 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
10242 index 46fc474..b02b0f9 100644
10243 --- a/arch/x86/include/asm/checksum_32.h
10244 +++ b/arch/x86/include/asm/checksum_32.h
10245 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
10246 int len, __wsum sum,
10247 int *src_err_ptr, int *dst_err_ptr);
10248
10249 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
10250 + int len, __wsum sum,
10251 + int *src_err_ptr, int *dst_err_ptr);
10252 +
10253 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
10254 + int len, __wsum sum,
10255 + int *src_err_ptr, int *dst_err_ptr);
10256 +
10257 /*
10258 * Note: when you get a NULL pointer exception here this means someone
10259 * passed in an incorrect kernel address to one of these functions.
10260 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
10261 int *err_ptr)
10262 {
10263 might_sleep();
10264 - return csum_partial_copy_generic((__force void *)src, dst,
10265 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
10266 len, sum, err_ptr, NULL);
10267 }
10268
10269 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
10270 {
10271 might_sleep();
10272 if (access_ok(VERIFY_WRITE, dst, len))
10273 - return csum_partial_copy_generic(src, (__force void *)dst,
10274 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
10275 len, sum, NULL, err_ptr);
10276
10277 if (len)
10278 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
10279 index 99480e5..d81165b 100644
10280 --- a/arch/x86/include/asm/cmpxchg.h
10281 +++ b/arch/x86/include/asm/cmpxchg.h
10282 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
10283 __compiletime_error("Bad argument size for cmpxchg");
10284 extern void __xadd_wrong_size(void)
10285 __compiletime_error("Bad argument size for xadd");
10286 +extern void __xadd_check_overflow_wrong_size(void)
10287 + __compiletime_error("Bad argument size for xadd_check_overflow");
10288 extern void __add_wrong_size(void)
10289 __compiletime_error("Bad argument size for add");
10290 +extern void __add_check_overflow_wrong_size(void)
10291 + __compiletime_error("Bad argument size for add_check_overflow");
10292
10293 /*
10294 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
10295 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
10296 __ret; \
10297 })
10298
10299 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
10300 + ({ \
10301 + __typeof__ (*(ptr)) __ret = (arg); \
10302 + switch (sizeof(*(ptr))) { \
10303 + case __X86_CASE_L: \
10304 + asm volatile (lock #op "l %0, %1\n" \
10305 + "jno 0f\n" \
10306 + "mov %0,%1\n" \
10307 + "int $4\n0:\n" \
10308 + _ASM_EXTABLE(0b, 0b) \
10309 + : "+r" (__ret), "+m" (*(ptr)) \
10310 + : : "memory", "cc"); \
10311 + break; \
10312 + case __X86_CASE_Q: \
10313 + asm volatile (lock #op "q %q0, %1\n" \
10314 + "jno 0f\n" \
10315 + "mov %0,%1\n" \
10316 + "int $4\n0:\n" \
10317 + _ASM_EXTABLE(0b, 0b) \
10318 + : "+r" (__ret), "+m" (*(ptr)) \
10319 + : : "memory", "cc"); \
10320 + break; \
10321 + default: \
10322 + __ ## op ## _check_overflow_wrong_size(); \
10323 + } \
10324 + __ret; \
10325 + })
10326 +
10327 /*
10328 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
10329 * Since this is generally used to protect other memory information, we
10330 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
10331 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
10332 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
10333
10334 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
10335 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
10336 +
10337 #define __add(ptr, inc, lock) \
10338 ({ \
10339 __typeof__ (*(ptr)) __ret = (inc); \
10340 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
10341 index 8d67d42..183d0eb 100644
10342 --- a/arch/x86/include/asm/cpufeature.h
10343 +++ b/arch/x86/include/asm/cpufeature.h
10344 @@ -367,7 +367,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
10345 ".section .discard,\"aw\",@progbits\n"
10346 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
10347 ".previous\n"
10348 - ".section .altinstr_replacement,\"ax\"\n"
10349 + ".section .altinstr_replacement,\"a\"\n"
10350 "3: movb $1,%0\n"
10351 "4:\n"
10352 ".previous\n"
10353 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
10354 index e95822d..a90010e 100644
10355 --- a/arch/x86/include/asm/desc.h
10356 +++ b/arch/x86/include/asm/desc.h
10357 @@ -4,6 +4,7 @@
10358 #include <asm/desc_defs.h>
10359 #include <asm/ldt.h>
10360 #include <asm/mmu.h>
10361 +#include <asm/pgtable.h>
10362
10363 #include <linux/smp.h>
10364
10365 @@ -16,6 +17,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
10366
10367 desc->type = (info->read_exec_only ^ 1) << 1;
10368 desc->type |= info->contents << 2;
10369 + desc->type |= info->seg_not_present ^ 1;
10370
10371 desc->s = 1;
10372 desc->dpl = 0x3;
10373 @@ -34,19 +36,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
10374 }
10375
10376 extern struct desc_ptr idt_descr;
10377 -extern gate_desc idt_table[];
10378 extern struct desc_ptr nmi_idt_descr;
10379 -extern gate_desc nmi_idt_table[];
10380 -
10381 -struct gdt_page {
10382 - struct desc_struct gdt[GDT_ENTRIES];
10383 -} __attribute__((aligned(PAGE_SIZE)));
10384 -
10385 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
10386 +extern gate_desc idt_table[256];
10387 +extern gate_desc nmi_idt_table[256];
10388
10389 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
10390 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
10391 {
10392 - return per_cpu(gdt_page, cpu).gdt;
10393 + return cpu_gdt_table[cpu];
10394 }
10395
10396 #ifdef CONFIG_X86_64
10397 @@ -71,8 +68,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
10398 unsigned long base, unsigned dpl, unsigned flags,
10399 unsigned short seg)
10400 {
10401 - gate->a = (seg << 16) | (base & 0xffff);
10402 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
10403 + gate->gate.offset_low = base;
10404 + gate->gate.seg = seg;
10405 + gate->gate.reserved = 0;
10406 + gate->gate.type = type;
10407 + gate->gate.s = 0;
10408 + gate->gate.dpl = dpl;
10409 + gate->gate.p = 1;
10410 + gate->gate.offset_high = base >> 16;
10411 }
10412
10413 #endif
10414 @@ -117,12 +120,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
10415
10416 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
10417 {
10418 + pax_open_kernel();
10419 memcpy(&idt[entry], gate, sizeof(*gate));
10420 + pax_close_kernel();
10421 }
10422
10423 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
10424 {
10425 + pax_open_kernel();
10426 memcpy(&ldt[entry], desc, 8);
10427 + pax_close_kernel();
10428 }
10429
10430 static inline void
10431 @@ -136,7 +143,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
10432 default: size = sizeof(*gdt); break;
10433 }
10434
10435 + pax_open_kernel();
10436 memcpy(&gdt[entry], desc, size);
10437 + pax_close_kernel();
10438 }
10439
10440 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
10441 @@ -209,7 +218,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
10442
10443 static inline void native_load_tr_desc(void)
10444 {
10445 + pax_open_kernel();
10446 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
10447 + pax_close_kernel();
10448 }
10449
10450 static inline void native_load_gdt(const struct desc_ptr *dtr)
10451 @@ -246,8 +257,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
10452 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
10453 unsigned int i;
10454
10455 + pax_open_kernel();
10456 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
10457 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
10458 + pax_close_kernel();
10459 }
10460
10461 #define _LDT_empty(info) \
10462 @@ -310,7 +323,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
10463 }
10464
10465 #ifdef CONFIG_X86_64
10466 -static inline void set_nmi_gate(int gate, void *addr)
10467 +static inline void set_nmi_gate(int gate, const void *addr)
10468 {
10469 gate_desc s;
10470
10471 @@ -319,7 +332,7 @@ static inline void set_nmi_gate(int gate, void *addr)
10472 }
10473 #endif
10474
10475 -static inline void _set_gate(int gate, unsigned type, void *addr,
10476 +static inline void _set_gate(int gate, unsigned type, const void *addr,
10477 unsigned dpl, unsigned ist, unsigned seg)
10478 {
10479 gate_desc s;
10480 @@ -338,7 +351,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
10481 * Pentium F0 0F bugfix can have resulted in the mapped
10482 * IDT being write-protected.
10483 */
10484 -static inline void set_intr_gate(unsigned int n, void *addr)
10485 +static inline void set_intr_gate(unsigned int n, const void *addr)
10486 {
10487 BUG_ON((unsigned)n > 0xFF);
10488 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
10489 @@ -368,19 +381,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
10490 /*
10491 * This routine sets up an interrupt gate at directory privilege level 3.
10492 */
10493 -static inline void set_system_intr_gate(unsigned int n, void *addr)
10494 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
10495 {
10496 BUG_ON((unsigned)n > 0xFF);
10497 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
10498 }
10499
10500 -static inline void set_system_trap_gate(unsigned int n, void *addr)
10501 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
10502 {
10503 BUG_ON((unsigned)n > 0xFF);
10504 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
10505 }
10506
10507 -static inline void set_trap_gate(unsigned int n, void *addr)
10508 +static inline void set_trap_gate(unsigned int n, const void *addr)
10509 {
10510 BUG_ON((unsigned)n > 0xFF);
10511 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
10512 @@ -389,19 +402,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
10513 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
10514 {
10515 BUG_ON((unsigned)n > 0xFF);
10516 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
10517 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
10518 }
10519
10520 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
10521 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
10522 {
10523 BUG_ON((unsigned)n > 0xFF);
10524 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
10525 }
10526
10527 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
10528 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
10529 {
10530 BUG_ON((unsigned)n > 0xFF);
10531 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
10532 }
10533
10534 +#ifdef CONFIG_X86_32
10535 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
10536 +{
10537 + struct desc_struct d;
10538 +
10539 + if (likely(limit))
10540 + limit = (limit - 1UL) >> PAGE_SHIFT;
10541 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
10542 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
10543 +}
10544 +#endif
10545 +
10546 #endif /* _ASM_X86_DESC_H */
10547 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
10548 index 278441f..b95a174 100644
10549 --- a/arch/x86/include/asm/desc_defs.h
10550 +++ b/arch/x86/include/asm/desc_defs.h
10551 @@ -31,6 +31,12 @@ struct desc_struct {
10552 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
10553 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
10554 };
10555 + struct {
10556 + u16 offset_low;
10557 + u16 seg;
10558 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
10559 + unsigned offset_high: 16;
10560 + } gate;
10561 };
10562 } __attribute__((packed));
10563
10564 diff --git a/arch/x86/include/asm/e820.h b/arch/x86/include/asm/e820.h
10565 index 3778256..c5d4fce 100644
10566 --- a/arch/x86/include/asm/e820.h
10567 +++ b/arch/x86/include/asm/e820.h
10568 @@ -69,7 +69,7 @@ struct e820map {
10569 #define ISA_START_ADDRESS 0xa0000
10570 #define ISA_END_ADDRESS 0x100000
10571
10572 -#define BIOS_BEGIN 0x000a0000
10573 +#define BIOS_BEGIN 0x000c0000
10574 #define BIOS_END 0x00100000
10575
10576 #define BIOS_ROM_BASE 0xffe00000
10577 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
10578 index 5f962df..7289f09 100644
10579 --- a/arch/x86/include/asm/elf.h
10580 +++ b/arch/x86/include/asm/elf.h
10581 @@ -238,7 +238,25 @@ extern int force_personality32;
10582 the loader. We need to make sure that it is out of the way of the program
10583 that it will "exec", and that there is sufficient room for the brk. */
10584
10585 +#ifdef CONFIG_PAX_SEGMEXEC
10586 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
10587 +#else
10588 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
10589 +#endif
10590 +
10591 +#ifdef CONFIG_PAX_ASLR
10592 +#ifdef CONFIG_X86_32
10593 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
10594 +
10595 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
10596 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
10597 +#else
10598 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
10599 +
10600 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_IA32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
10601 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_IA32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
10602 +#endif
10603 +#endif
10604
10605 /* This yields a mask that user programs can use to figure out what
10606 instruction set this CPU supports. This could be done in user space,
10607 @@ -291,9 +309,7 @@ do { \
10608
10609 #define ARCH_DLINFO \
10610 do { \
10611 - if (vdso_enabled) \
10612 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
10613 - (unsigned long)current->mm->context.vdso); \
10614 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
10615 } while (0)
10616
10617 #define AT_SYSINFO 32
10618 @@ -304,7 +320,7 @@ do { \
10619
10620 #endif /* !CONFIG_X86_32 */
10621
10622 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
10623 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
10624
10625 #define VDSO_ENTRY \
10626 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
10627 @@ -318,9 +334,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
10628 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
10629 #define compat_arch_setup_additional_pages syscall32_setup_pages
10630
10631 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
10632 -#define arch_randomize_brk arch_randomize_brk
10633 -
10634 /*
10635 * True on X86_32 or when emulating IA32 on X86_64
10636 */
10637 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
10638 index cc70c1c..d96d011 100644
10639 --- a/arch/x86/include/asm/emergency-restart.h
10640 +++ b/arch/x86/include/asm/emergency-restart.h
10641 @@ -15,6 +15,6 @@ enum reboot_type {
10642
10643 extern enum reboot_type reboot_type;
10644
10645 -extern void machine_emergency_restart(void);
10646 +extern void machine_emergency_restart(void) __noreturn;
10647
10648 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
10649 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
10650 index d09bb03..4ea4194 100644
10651 --- a/arch/x86/include/asm/futex.h
10652 +++ b/arch/x86/include/asm/futex.h
10653 @@ -12,16 +12,18 @@
10654 #include <asm/system.h>
10655
10656 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
10657 + typecheck(u32 __user *, uaddr); \
10658 asm volatile("1:\t" insn "\n" \
10659 "2:\t.section .fixup,\"ax\"\n" \
10660 "3:\tmov\t%3, %1\n" \
10661 "\tjmp\t2b\n" \
10662 "\t.previous\n" \
10663 _ASM_EXTABLE(1b, 3b) \
10664 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
10665 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr))\
10666 : "i" (-EFAULT), "0" (oparg), "1" (0))
10667
10668 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
10669 + typecheck(u32 __user *, uaddr); \
10670 asm volatile("1:\tmovl %2, %0\n" \
10671 "\tmovl\t%0, %3\n" \
10672 "\t" insn "\n" \
10673 @@ -34,7 +36,7 @@
10674 _ASM_EXTABLE(1b, 4b) \
10675 _ASM_EXTABLE(2b, 4b) \
10676 : "=&a" (oldval), "=&r" (ret), \
10677 - "+m" (*uaddr), "=&r" (tem) \
10678 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
10679 : "r" (oparg), "i" (-EFAULT), "1" (0))
10680
10681 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
10682 @@ -61,10 +63,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
10683
10684 switch (op) {
10685 case FUTEX_OP_SET:
10686 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
10687 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
10688 break;
10689 case FUTEX_OP_ADD:
10690 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
10691 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
10692 uaddr, oparg);
10693 break;
10694 case FUTEX_OP_OR:
10695 @@ -123,13 +125,13 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
10696 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
10697 return -EFAULT;
10698
10699 - asm volatile("1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
10700 + asm volatile("1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
10701 "2:\t.section .fixup, \"ax\"\n"
10702 "3:\tmov %3, %0\n"
10703 "\tjmp 2b\n"
10704 "\t.previous\n"
10705 _ASM_EXTABLE(1b, 3b)
10706 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
10707 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
10708 : "i" (-EFAULT), "r" (newval), "1" (oldval)
10709 : "memory"
10710 );
10711 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
10712 index eb92a6e..b98b2f4 100644
10713 --- a/arch/x86/include/asm/hw_irq.h
10714 +++ b/arch/x86/include/asm/hw_irq.h
10715 @@ -136,8 +136,8 @@ extern void setup_ioapic_dest(void);
10716 extern void enable_IO_APIC(void);
10717
10718 /* Statistics */
10719 -extern atomic_t irq_err_count;
10720 -extern atomic_t irq_mis_count;
10721 +extern atomic_unchecked_t irq_err_count;
10722 +extern atomic_unchecked_t irq_mis_count;
10723
10724 /* EISA */
10725 extern void eisa_set_level_irq(unsigned int irq);
10726 diff --git a/arch/x86/include/asm/i387.h b/arch/x86/include/asm/i387.h
10727 index 2479049..3fb9795 100644
10728 --- a/arch/x86/include/asm/i387.h
10729 +++ b/arch/x86/include/asm/i387.h
10730 @@ -93,6 +93,11 @@ static inline int fxrstor_checking(struct i387_fxsave_struct *fx)
10731 {
10732 int err;
10733
10734 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
10735 + if ((unsigned long)fx < PAX_USER_SHADOW_BASE)
10736 + fx = (struct i387_fxsave_struct __user *)((void *)fx + PAX_USER_SHADOW_BASE);
10737 +#endif
10738 +
10739 /* See comment in fxsave() below. */
10740 #ifdef CONFIG_AS_FXSAVEQ
10741 asm volatile("1: fxrstorq %[fx]\n\t"
10742 @@ -122,6 +127,11 @@ static inline int fxsave_user(struct i387_fxsave_struct __user *fx)
10743 {
10744 int err;
10745
10746 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
10747 + if ((unsigned long)fx < PAX_USER_SHADOW_BASE)
10748 + fx = (struct i387_fxsave_struct __user *)((void __user *)fx + PAX_USER_SHADOW_BASE);
10749 +#endif
10750 +
10751 /*
10752 * Clear the bytes not touched by the fxsave and reserved
10753 * for the SW usage.
10754 @@ -278,7 +288,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
10755 "emms\n\t" /* clear stack tags */
10756 "fildl %P[addr]", /* set F?P to defined value */
10757 X86_FEATURE_FXSAVE_LEAK,
10758 - [addr] "m" (tsk->thread.fpu.has_fpu));
10759 + [addr] "m" (init_tss[smp_processor_id()].x86_tss.sp0));
10760
10761 return fpu_restore_checking(&tsk->thread.fpu);
10762 }
10763 @@ -445,7 +455,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
10764 static inline bool interrupted_user_mode(void)
10765 {
10766 struct pt_regs *regs = get_irq_regs();
10767 - return regs && user_mode_vm(regs);
10768 + return regs && user_mode(regs);
10769 }
10770
10771 /*
10772 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
10773 index d8e8eef..99f81ae 100644
10774 --- a/arch/x86/include/asm/io.h
10775 +++ b/arch/x86/include/asm/io.h
10776 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
10777
10778 #include <linux/vmalloc.h>
10779
10780 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
10781 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
10782 +{
10783 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
10784 +}
10785 +
10786 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
10787 +{
10788 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
10789 +}
10790 +
10791 /*
10792 * Convert a virtual cached pointer to an uncached pointer
10793 */
10794 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
10795 index bba3cf8..06bc8da 100644
10796 --- a/arch/x86/include/asm/irqflags.h
10797 +++ b/arch/x86/include/asm/irqflags.h
10798 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
10799 sti; \
10800 sysexit
10801
10802 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
10803 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
10804 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
10805 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
10806 +
10807 #else
10808 #define INTERRUPT_RETURN iret
10809 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
10810 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
10811 index 5478825..839e88c 100644
10812 --- a/arch/x86/include/asm/kprobes.h
10813 +++ b/arch/x86/include/asm/kprobes.h
10814 @@ -37,13 +37,8 @@ typedef u8 kprobe_opcode_t;
10815 #define RELATIVEJUMP_SIZE 5
10816 #define RELATIVECALL_OPCODE 0xe8
10817 #define RELATIVE_ADDR_SIZE 4
10818 -#define MAX_STACK_SIZE 64
10819 -#define MIN_STACK_SIZE(ADDR) \
10820 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
10821 - THREAD_SIZE - (unsigned long)(ADDR))) \
10822 - ? (MAX_STACK_SIZE) \
10823 - : (((unsigned long)current_thread_info()) + \
10824 - THREAD_SIZE - (unsigned long)(ADDR)))
10825 +#define MAX_STACK_SIZE 64UL
10826 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
10827
10828 #define flush_insn_slot(p) do { } while (0)
10829
10830 diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
10831 index 52d6640..a013b87 100644
10832 --- a/arch/x86/include/asm/kvm_host.h
10833 +++ b/arch/x86/include/asm/kvm_host.h
10834 @@ -663,7 +663,7 @@ struct kvm_x86_ops {
10835 int (*check_intercept)(struct kvm_vcpu *vcpu,
10836 struct x86_instruction_info *info,
10837 enum x86_intercept_stage stage);
10838 -};
10839 +} __do_const;
10840
10841 struct kvm_arch_async_pf {
10842 u32 token;
10843 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
10844 index 9cdae5d..300d20f 100644
10845 --- a/arch/x86/include/asm/local.h
10846 +++ b/arch/x86/include/asm/local.h
10847 @@ -18,26 +18,58 @@ typedef struct {
10848
10849 static inline void local_inc(local_t *l)
10850 {
10851 - asm volatile(_ASM_INC "%0"
10852 + asm volatile(_ASM_INC "%0\n"
10853 +
10854 +#ifdef CONFIG_PAX_REFCOUNT
10855 + "jno 0f\n"
10856 + _ASM_DEC "%0\n"
10857 + "int $4\n0:\n"
10858 + _ASM_EXTABLE(0b, 0b)
10859 +#endif
10860 +
10861 : "+m" (l->a.counter));
10862 }
10863
10864 static inline void local_dec(local_t *l)
10865 {
10866 - asm volatile(_ASM_DEC "%0"
10867 + asm volatile(_ASM_DEC "%0\n"
10868 +
10869 +#ifdef CONFIG_PAX_REFCOUNT
10870 + "jno 0f\n"
10871 + _ASM_INC "%0\n"
10872 + "int $4\n0:\n"
10873 + _ASM_EXTABLE(0b, 0b)
10874 +#endif
10875 +
10876 : "+m" (l->a.counter));
10877 }
10878
10879 static inline void local_add(long i, local_t *l)
10880 {
10881 - asm volatile(_ASM_ADD "%1,%0"
10882 + asm volatile(_ASM_ADD "%1,%0\n"
10883 +
10884 +#ifdef CONFIG_PAX_REFCOUNT
10885 + "jno 0f\n"
10886 + _ASM_SUB "%1,%0\n"
10887 + "int $4\n0:\n"
10888 + _ASM_EXTABLE(0b, 0b)
10889 +#endif
10890 +
10891 : "+m" (l->a.counter)
10892 : "ir" (i));
10893 }
10894
10895 static inline void local_sub(long i, local_t *l)
10896 {
10897 - asm volatile(_ASM_SUB "%1,%0"
10898 + asm volatile(_ASM_SUB "%1,%0\n"
10899 +
10900 +#ifdef CONFIG_PAX_REFCOUNT
10901 + "jno 0f\n"
10902 + _ASM_ADD "%1,%0\n"
10903 + "int $4\n0:\n"
10904 + _ASM_EXTABLE(0b, 0b)
10905 +#endif
10906 +
10907 : "+m" (l->a.counter)
10908 : "ir" (i));
10909 }
10910 @@ -55,7 +87,16 @@ static inline int local_sub_and_test(long i, local_t *l)
10911 {
10912 unsigned char c;
10913
10914 - asm volatile(_ASM_SUB "%2,%0; sete %1"
10915 + asm volatile(_ASM_SUB "%2,%0\n"
10916 +
10917 +#ifdef CONFIG_PAX_REFCOUNT
10918 + "jno 0f\n"
10919 + _ASM_ADD "%2,%0\n"
10920 + "int $4\n0:\n"
10921 + _ASM_EXTABLE(0b, 0b)
10922 +#endif
10923 +
10924 + "sete %1\n"
10925 : "+m" (l->a.counter), "=qm" (c)
10926 : "ir" (i) : "memory");
10927 return c;
10928 @@ -73,7 +114,16 @@ static inline int local_dec_and_test(local_t *l)
10929 {
10930 unsigned char c;
10931
10932 - asm volatile(_ASM_DEC "%0; sete %1"
10933 + asm volatile(_ASM_DEC "%0\n"
10934 +
10935 +#ifdef CONFIG_PAX_REFCOUNT
10936 + "jno 0f\n"
10937 + _ASM_INC "%0\n"
10938 + "int $4\n0:\n"
10939 + _ASM_EXTABLE(0b, 0b)
10940 +#endif
10941 +
10942 + "sete %1\n"
10943 : "+m" (l->a.counter), "=qm" (c)
10944 : : "memory");
10945 return c != 0;
10946 @@ -91,7 +141,16 @@ static inline int local_inc_and_test(local_t *l)
10947 {
10948 unsigned char c;
10949
10950 - asm volatile(_ASM_INC "%0; sete %1"
10951 + asm volatile(_ASM_INC "%0\n"
10952 +
10953 +#ifdef CONFIG_PAX_REFCOUNT
10954 + "jno 0f\n"
10955 + _ASM_DEC "%0\n"
10956 + "int $4\n0:\n"
10957 + _ASM_EXTABLE(0b, 0b)
10958 +#endif
10959 +
10960 + "sete %1\n"
10961 : "+m" (l->a.counter), "=qm" (c)
10962 : : "memory");
10963 return c != 0;
10964 @@ -110,7 +169,16 @@ static inline int local_add_negative(long i, local_t *l)
10965 {
10966 unsigned char c;
10967
10968 - asm volatile(_ASM_ADD "%2,%0; sets %1"
10969 + asm volatile(_ASM_ADD "%2,%0\n"
10970 +
10971 +#ifdef CONFIG_PAX_REFCOUNT
10972 + "jno 0f\n"
10973 + _ASM_SUB "%2,%0\n"
10974 + "int $4\n0:\n"
10975 + _ASM_EXTABLE(0b, 0b)
10976 +#endif
10977 +
10978 + "sets %1\n"
10979 : "+m" (l->a.counter), "=qm" (c)
10980 : "ir" (i) : "memory");
10981 return c;
10982 @@ -133,7 +201,15 @@ static inline long local_add_return(long i, local_t *l)
10983 #endif
10984 /* Modern 486+ processor */
10985 __i = i;
10986 - asm volatile(_ASM_XADD "%0, %1;"
10987 + asm volatile(_ASM_XADD "%0, %1\n"
10988 +
10989 +#ifdef CONFIG_PAX_REFCOUNT
10990 + "jno 0f\n"
10991 + _ASM_MOV "%0,%1\n"
10992 + "int $4\n0:\n"
10993 + _ASM_EXTABLE(0b, 0b)
10994 +#endif
10995 +
10996 : "+r" (i), "+m" (l->a.counter)
10997 : : "memory");
10998 return i + __i;
10999 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
11000 index 593e51d..fa69c9a 100644
11001 --- a/arch/x86/include/asm/mman.h
11002 +++ b/arch/x86/include/asm/mman.h
11003 @@ -5,4 +5,14 @@
11004
11005 #include <asm-generic/mman.h>
11006
11007 +#ifdef __KERNEL__
11008 +#ifndef __ASSEMBLY__
11009 +#ifdef CONFIG_X86_32
11010 +#define arch_mmap_check i386_mmap_check
11011 +int i386_mmap_check(unsigned long addr, unsigned long len,
11012 + unsigned long flags);
11013 +#endif
11014 +#endif
11015 +#endif
11016 +
11017 #endif /* _ASM_X86_MMAN_H */
11018 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
11019 index 5f55e69..e20bfb1 100644
11020 --- a/arch/x86/include/asm/mmu.h
11021 +++ b/arch/x86/include/asm/mmu.h
11022 @@ -9,7 +9,7 @@
11023 * we put the segment information here.
11024 */
11025 typedef struct {
11026 - void *ldt;
11027 + struct desc_struct *ldt;
11028 int size;
11029
11030 #ifdef CONFIG_X86_64
11031 @@ -18,7 +18,19 @@ typedef struct {
11032 #endif
11033
11034 struct mutex lock;
11035 - void *vdso;
11036 + unsigned long vdso;
11037 +
11038 +#ifdef CONFIG_X86_32
11039 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
11040 + unsigned long user_cs_base;
11041 + unsigned long user_cs_limit;
11042 +
11043 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
11044 + cpumask_t cpu_user_cs_mask;
11045 +#endif
11046 +
11047 +#endif
11048 +#endif
11049 } mm_context_t;
11050
11051 #ifdef CONFIG_SMP
11052 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
11053 index 6902152..da4283a 100644
11054 --- a/arch/x86/include/asm/mmu_context.h
11055 +++ b/arch/x86/include/asm/mmu_context.h
11056 @@ -24,6 +24,18 @@ void destroy_context(struct mm_struct *mm);
11057
11058 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
11059 {
11060 +
11061 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
11062 + unsigned int i;
11063 + pgd_t *pgd;
11064 +
11065 + pax_open_kernel();
11066 + pgd = get_cpu_pgd(smp_processor_id());
11067 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
11068 + set_pgd_batched(pgd+i, native_make_pgd(0));
11069 + pax_close_kernel();
11070 +#endif
11071 +
11072 #ifdef CONFIG_SMP
11073 if (percpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
11074 percpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
11075 @@ -34,16 +46,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
11076 struct task_struct *tsk)
11077 {
11078 unsigned cpu = smp_processor_id();
11079 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
11080 + int tlbstate = TLBSTATE_OK;
11081 +#endif
11082
11083 if (likely(prev != next)) {
11084 #ifdef CONFIG_SMP
11085 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
11086 + tlbstate = percpu_read(cpu_tlbstate.state);
11087 +#endif
11088 percpu_write(cpu_tlbstate.state, TLBSTATE_OK);
11089 percpu_write(cpu_tlbstate.active_mm, next);
11090 #endif
11091 cpumask_set_cpu(cpu, mm_cpumask(next));
11092
11093 /* Re-load page tables */
11094 +#ifdef CONFIG_PAX_PER_CPU_PGD
11095 + pax_open_kernel();
11096 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
11097 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
11098 + pax_close_kernel();
11099 + load_cr3(get_cpu_pgd(cpu));
11100 +#else
11101 load_cr3(next->pgd);
11102 +#endif
11103
11104 /* stop flush ipis for the previous mm */
11105 cpumask_clear_cpu(cpu, mm_cpumask(prev));
11106 @@ -53,9 +79,38 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
11107 */
11108 if (unlikely(prev->context.ldt != next->context.ldt))
11109 load_LDT_nolock(&next->context);
11110 - }
11111 +
11112 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
11113 + if (!(__supported_pte_mask & _PAGE_NX)) {
11114 + smp_mb__before_clear_bit();
11115 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
11116 + smp_mb__after_clear_bit();
11117 + cpu_set(cpu, next->context.cpu_user_cs_mask);
11118 + }
11119 +#endif
11120 +
11121 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
11122 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
11123 + prev->context.user_cs_limit != next->context.user_cs_limit))
11124 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
11125 #ifdef CONFIG_SMP
11126 + else if (unlikely(tlbstate != TLBSTATE_OK))
11127 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
11128 +#endif
11129 +#endif
11130 +
11131 + }
11132 else {
11133 +
11134 +#ifdef CONFIG_PAX_PER_CPU_PGD
11135 + pax_open_kernel();
11136 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
11137 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
11138 + pax_close_kernel();
11139 + load_cr3(get_cpu_pgd(cpu));
11140 +#endif
11141 +
11142 +#ifdef CONFIG_SMP
11143 percpu_write(cpu_tlbstate.state, TLBSTATE_OK);
11144 BUG_ON(percpu_read(cpu_tlbstate.active_mm) != next);
11145
11146 @@ -64,11 +119,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
11147 * tlb flush IPI delivery. We must reload CR3
11148 * to make sure to use no freed page tables.
11149 */
11150 +
11151 +#ifndef CONFIG_PAX_PER_CPU_PGD
11152 load_cr3(next->pgd);
11153 +#endif
11154 +
11155 load_LDT_nolock(&next->context);
11156 +
11157 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
11158 + if (!(__supported_pte_mask & _PAGE_NX))
11159 + cpu_set(cpu, next->context.cpu_user_cs_mask);
11160 +#endif
11161 +
11162 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
11163 +#ifdef CONFIG_PAX_PAGEEXEC
11164 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
11165 +#endif
11166 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
11167 +#endif
11168 +
11169 }
11170 +#endif
11171 }
11172 -#endif
11173 }
11174
11175 #define activate_mm(prev, next) \
11176 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
11177 index 9eae775..c914fea 100644
11178 --- a/arch/x86/include/asm/module.h
11179 +++ b/arch/x86/include/asm/module.h
11180 @@ -5,6 +5,7 @@
11181
11182 #ifdef CONFIG_X86_64
11183 /* X86_64 does not define MODULE_PROC_FAMILY */
11184 +#define MODULE_PROC_FAMILY ""
11185 #elif defined CONFIG_M386
11186 #define MODULE_PROC_FAMILY "386 "
11187 #elif defined CONFIG_M486
11188 @@ -59,8 +60,20 @@
11189 #error unknown processor family
11190 #endif
11191
11192 -#ifdef CONFIG_X86_32
11193 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
11194 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
11195 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
11196 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
11197 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
11198 +#else
11199 +#define MODULE_PAX_KERNEXEC ""
11200 #endif
11201
11202 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11203 +#define MODULE_PAX_UDEREF "UDEREF "
11204 +#else
11205 +#define MODULE_PAX_UDEREF ""
11206 +#endif
11207 +
11208 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
11209 +
11210 #endif /* _ASM_X86_MODULE_H */
11211 diff --git a/arch/x86/include/asm/page_64_types.h b/arch/x86/include/asm/page_64_types.h
11212 index 7639dbf..e08a58c 100644
11213 --- a/arch/x86/include/asm/page_64_types.h
11214 +++ b/arch/x86/include/asm/page_64_types.h
11215 @@ -56,7 +56,7 @@ void copy_page(void *to, void *from);
11216
11217 /* duplicated to the one in bootmem.h */
11218 extern unsigned long max_pfn;
11219 -extern unsigned long phys_base;
11220 +extern const unsigned long phys_base;
11221
11222 extern unsigned long __phys_addr(unsigned long);
11223 #define __phys_reloc_hide(x) (x)
11224 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
11225 index a7d2db9..edb023e 100644
11226 --- a/arch/x86/include/asm/paravirt.h
11227 +++ b/arch/x86/include/asm/paravirt.h
11228 @@ -667,6 +667,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
11229 val);
11230 }
11231
11232 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
11233 +{
11234 + pgdval_t val = native_pgd_val(pgd);
11235 +
11236 + if (sizeof(pgdval_t) > sizeof(long))
11237 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
11238 + val, (u64)val >> 32);
11239 + else
11240 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
11241 + val);
11242 +}
11243 +
11244 static inline void pgd_clear(pgd_t *pgdp)
11245 {
11246 set_pgd(pgdp, __pgd(0));
11247 @@ -748,6 +760,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
11248 pv_mmu_ops.set_fixmap(idx, phys, flags);
11249 }
11250
11251 +#ifdef CONFIG_PAX_KERNEXEC
11252 +static inline unsigned long pax_open_kernel(void)
11253 +{
11254 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
11255 +}
11256 +
11257 +static inline unsigned long pax_close_kernel(void)
11258 +{
11259 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
11260 +}
11261 +#else
11262 +static inline unsigned long pax_open_kernel(void) { return 0; }
11263 +static inline unsigned long pax_close_kernel(void) { return 0; }
11264 +#endif
11265 +
11266 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
11267
11268 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
11269 @@ -964,7 +991,7 @@ extern void default_banner(void);
11270
11271 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
11272 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
11273 -#define PARA_INDIRECT(addr) *%cs:addr
11274 +#define PARA_INDIRECT(addr) *%ss:addr
11275 #endif
11276
11277 #define INTERRUPT_RETURN \
11278 @@ -1041,6 +1068,21 @@ extern void default_banner(void);
11279 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
11280 CLBR_NONE, \
11281 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
11282 +
11283 +#define GET_CR0_INTO_RDI \
11284 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
11285 + mov %rax,%rdi
11286 +
11287 +#define SET_RDI_INTO_CR0 \
11288 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
11289 +
11290 +#define GET_CR3_INTO_RDI \
11291 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
11292 + mov %rax,%rdi
11293 +
11294 +#define SET_RDI_INTO_CR3 \
11295 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
11296 +
11297 #endif /* CONFIG_X86_32 */
11298
11299 #endif /* __ASSEMBLY__ */
11300 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
11301 index 8e8b9a4..f07d725 100644
11302 --- a/arch/x86/include/asm/paravirt_types.h
11303 +++ b/arch/x86/include/asm/paravirt_types.h
11304 @@ -84,20 +84,20 @@ struct pv_init_ops {
11305 */
11306 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
11307 unsigned long addr, unsigned len);
11308 -};
11309 +} __no_const;
11310
11311
11312 struct pv_lazy_ops {
11313 /* Set deferred update mode, used for batching operations. */
11314 void (*enter)(void);
11315 void (*leave)(void);
11316 -};
11317 +} __no_const;
11318
11319 struct pv_time_ops {
11320 unsigned long long (*sched_clock)(void);
11321 unsigned long long (*steal_clock)(int cpu);
11322 unsigned long (*get_tsc_khz)(void);
11323 -};
11324 +} __no_const;
11325
11326 struct pv_cpu_ops {
11327 /* hooks for various privileged instructions */
11328 @@ -193,7 +193,7 @@ struct pv_cpu_ops {
11329
11330 void (*start_context_switch)(struct task_struct *prev);
11331 void (*end_context_switch)(struct task_struct *next);
11332 -};
11333 +} __no_const;
11334
11335 struct pv_irq_ops {
11336 /*
11337 @@ -224,7 +224,7 @@ struct pv_apic_ops {
11338 unsigned long start_eip,
11339 unsigned long start_esp);
11340 #endif
11341 -};
11342 +} __no_const;
11343
11344 struct pv_mmu_ops {
11345 unsigned long (*read_cr2)(void);
11346 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
11347 struct paravirt_callee_save make_pud;
11348
11349 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
11350 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
11351 #endif /* PAGETABLE_LEVELS == 4 */
11352 #endif /* PAGETABLE_LEVELS >= 3 */
11353
11354 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
11355 an mfn. We can tell which is which from the index. */
11356 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
11357 phys_addr_t phys, pgprot_t flags);
11358 +
11359 +#ifdef CONFIG_PAX_KERNEXEC
11360 + unsigned long (*pax_open_kernel)(void);
11361 + unsigned long (*pax_close_kernel)(void);
11362 +#endif
11363 +
11364 };
11365
11366 struct arch_spinlock;
11367 @@ -334,7 +341,7 @@ struct pv_lock_ops {
11368 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
11369 int (*spin_trylock)(struct arch_spinlock *lock);
11370 void (*spin_unlock)(struct arch_spinlock *lock);
11371 -};
11372 +} __no_const;
11373
11374 /* This contains all the paravirt structures: we get a convenient
11375 * number for each function using the offset which we use to indicate
11376 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
11377 index b4389a4..7024269 100644
11378 --- a/arch/x86/include/asm/pgalloc.h
11379 +++ b/arch/x86/include/asm/pgalloc.h
11380 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
11381 pmd_t *pmd, pte_t *pte)
11382 {
11383 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
11384 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
11385 +}
11386 +
11387 +static inline void pmd_populate_user(struct mm_struct *mm,
11388 + pmd_t *pmd, pte_t *pte)
11389 +{
11390 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
11391 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
11392 }
11393
11394 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
11395
11396 #ifdef CONFIG_X86_PAE
11397 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
11398 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
11399 +{
11400 + pud_populate(mm, pudp, pmd);
11401 +}
11402 #else /* !CONFIG_X86_PAE */
11403 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
11404 {
11405 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
11406 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
11407 }
11408 +
11409 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
11410 +{
11411 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
11412 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
11413 +}
11414 #endif /* CONFIG_X86_PAE */
11415
11416 #if PAGETABLE_LEVELS > 3
11417 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
11418 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
11419 }
11420
11421 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
11422 +{
11423 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
11424 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
11425 +}
11426 +
11427 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
11428 {
11429 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
11430 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
11431 index 98391db..8f6984e 100644
11432 --- a/arch/x86/include/asm/pgtable-2level.h
11433 +++ b/arch/x86/include/asm/pgtable-2level.h
11434 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
11435
11436 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
11437 {
11438 + pax_open_kernel();
11439 *pmdp = pmd;
11440 + pax_close_kernel();
11441 }
11442
11443 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
11444 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
11445 index effff47..bbb8295 100644
11446 --- a/arch/x86/include/asm/pgtable-3level.h
11447 +++ b/arch/x86/include/asm/pgtable-3level.h
11448 @@ -31,6 +31,56 @@ static inline void native_set_pte(pte_t *ptep, pte_t pte)
11449 ptep->pte_low = pte.pte_low;
11450 }
11451
11452 +#define __HAVE_ARCH_READ_PMD_ATOMIC
11453 +/*
11454 + * pte_offset_map_lock on 32bit PAE kernels was reading the pmd_t with
11455 + * a "*pmdp" dereference done by gcc. Problem is, in certain places
11456 + * where pte_offset_map_lock is called, concurrent page faults are
11457 + * allowed, if the mmap_sem is hold for reading. An example is mincore
11458 + * vs page faults vs MADV_DONTNEED. On the page fault side
11459 + * pmd_populate rightfully does a set_64bit, but if we're reading the
11460 + * pmd_t with a "*pmdp" on the mincore side, a SMP race can happen
11461 + * because gcc will not read the 64bit of the pmd atomically. To fix
11462 + * this all places running pmd_offset_map_lock() while holding the
11463 + * mmap_sem in read mode, shall read the pmdp pointer using this
11464 + * function to know if the pmd is null nor not, and in turn to know if
11465 + * they can run pmd_offset_map_lock or pmd_trans_huge or other pmd
11466 + * operations.
11467 + *
11468 + * Without THP if the mmap_sem is hold for reading, the
11469 + * pmd can only transition from null to not null while read_pmd_atomic runs.
11470 + * So there's no need of literally reading it atomically.
11471 + *
11472 + * With THP if the mmap_sem is hold for reading, the pmd can become
11473 + * THP or null or point to a pte (and in turn become "stable") at any
11474 + * time under read_pmd_atomic, so it's mandatory to read it atomically
11475 + * with cmpxchg8b.
11476 + */
11477 +#ifndef CONFIG_TRANSPARENT_HUGEPAGE
11478 +static inline pmd_t read_pmd_atomic(pmd_t *pmdp)
11479 +{
11480 + pmdval_t ret;
11481 + u32 *tmp = (u32 *)pmdp;
11482 +
11483 + ret = (pmdval_t) (*tmp);
11484 + if (ret) {
11485 + /*
11486 + * If the low part is null, we must not read the high part
11487 + * or we can end up with a partial pmd.
11488 + */
11489 + smp_rmb();
11490 + ret |= ((pmdval_t)*(tmp + 1)) << 32;
11491 + }
11492 +
11493 + return __pmd(ret);
11494 +}
11495 +#else /* CONFIG_TRANSPARENT_HUGEPAGE */
11496 +static inline pmd_t read_pmd_atomic(pmd_t *pmdp)
11497 +{
11498 + return __pmd(atomic64_read((atomic64_t *)pmdp));
11499 +}
11500 +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
11501 +
11502 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
11503 {
11504 set_64bit((unsigned long long *)(ptep), native_pte_val(pte));
11505 @@ -38,12 +88,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
11506
11507 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
11508 {
11509 + pax_open_kernel();
11510 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
11511 + pax_close_kernel();
11512 }
11513
11514 static inline void native_set_pud(pud_t *pudp, pud_t pud)
11515 {
11516 + pax_open_kernel();
11517 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
11518 + pax_close_kernel();
11519 }
11520
11521 /*
11522 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
11523 index 49afb3f..91a8c63 100644
11524 --- a/arch/x86/include/asm/pgtable.h
11525 +++ b/arch/x86/include/asm/pgtable.h
11526 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
11527
11528 #ifndef __PAGETABLE_PUD_FOLDED
11529 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
11530 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
11531 #define pgd_clear(pgd) native_pgd_clear(pgd)
11532 #endif
11533
11534 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
11535
11536 #define arch_end_context_switch(prev) do {} while(0)
11537
11538 +#define pax_open_kernel() native_pax_open_kernel()
11539 +#define pax_close_kernel() native_pax_close_kernel()
11540 #endif /* CONFIG_PARAVIRT */
11541
11542 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
11543 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
11544 +
11545 +#ifdef CONFIG_PAX_KERNEXEC
11546 +static inline unsigned long native_pax_open_kernel(void)
11547 +{
11548 + unsigned long cr0;
11549 +
11550 + preempt_disable();
11551 + barrier();
11552 + cr0 = read_cr0() ^ X86_CR0_WP;
11553 + BUG_ON(unlikely(cr0 & X86_CR0_WP));
11554 + write_cr0(cr0);
11555 + return cr0 ^ X86_CR0_WP;
11556 +}
11557 +
11558 +static inline unsigned long native_pax_close_kernel(void)
11559 +{
11560 + unsigned long cr0;
11561 +
11562 + cr0 = read_cr0() ^ X86_CR0_WP;
11563 + BUG_ON(unlikely(!(cr0 & X86_CR0_WP)));
11564 + write_cr0(cr0);
11565 + barrier();
11566 + preempt_enable_no_resched();
11567 + return cr0 ^ X86_CR0_WP;
11568 +}
11569 +#else
11570 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
11571 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
11572 +#endif
11573 +
11574 /*
11575 * The following only work if pte_present() is true.
11576 * Undefined behaviour if not..
11577 */
11578 +static inline int pte_user(pte_t pte)
11579 +{
11580 + return pte_val(pte) & _PAGE_USER;
11581 +}
11582 +
11583 static inline int pte_dirty(pte_t pte)
11584 {
11585 return pte_flags(pte) & _PAGE_DIRTY;
11586 @@ -196,9 +236,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
11587 return pte_clear_flags(pte, _PAGE_RW);
11588 }
11589
11590 +static inline pte_t pte_mkread(pte_t pte)
11591 +{
11592 + return __pte(pte_val(pte) | _PAGE_USER);
11593 +}
11594 +
11595 static inline pte_t pte_mkexec(pte_t pte)
11596 {
11597 - return pte_clear_flags(pte, _PAGE_NX);
11598 +#ifdef CONFIG_X86_PAE
11599 + if (__supported_pte_mask & _PAGE_NX)
11600 + return pte_clear_flags(pte, _PAGE_NX);
11601 + else
11602 +#endif
11603 + return pte_set_flags(pte, _PAGE_USER);
11604 +}
11605 +
11606 +static inline pte_t pte_exprotect(pte_t pte)
11607 +{
11608 +#ifdef CONFIG_X86_PAE
11609 + if (__supported_pte_mask & _PAGE_NX)
11610 + return pte_set_flags(pte, _PAGE_NX);
11611 + else
11612 +#endif
11613 + return pte_clear_flags(pte, _PAGE_USER);
11614 }
11615
11616 static inline pte_t pte_mkdirty(pte_t pte)
11617 @@ -390,6 +450,15 @@ pte_t *populate_extra_pte(unsigned long vaddr);
11618 #endif
11619
11620 #ifndef __ASSEMBLY__
11621 +
11622 +#ifdef CONFIG_PAX_PER_CPU_PGD
11623 +extern pgd_t cpu_pgd[NR_CPUS][PTRS_PER_PGD];
11624 +static inline pgd_t *get_cpu_pgd(unsigned int cpu)
11625 +{
11626 + return cpu_pgd[cpu];
11627 +}
11628 +#endif
11629 +
11630 #include <linux/mm_types.h>
11631
11632 static inline int pte_none(pte_t pte)
11633 @@ -560,7 +629,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
11634
11635 static inline int pgd_bad(pgd_t pgd)
11636 {
11637 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
11638 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
11639 }
11640
11641 static inline int pgd_none(pgd_t pgd)
11642 @@ -583,7 +652,12 @@ static inline int pgd_none(pgd_t pgd)
11643 * pgd_offset() returns a (pgd_t *)
11644 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
11645 */
11646 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
11647 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
11648 +
11649 +#ifdef CONFIG_PAX_PER_CPU_PGD
11650 +#define pgd_offset_cpu(cpu, address) (get_cpu_pgd(cpu) + pgd_index(address))
11651 +#endif
11652 +
11653 /*
11654 * a shortcut which implies the use of the kernel's pgd, instead
11655 * of a process's
11656 @@ -594,6 +668,20 @@ static inline int pgd_none(pgd_t pgd)
11657 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
11658 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
11659
11660 +#ifdef CONFIG_X86_32
11661 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
11662 +#else
11663 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
11664 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
11665 +
11666 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11667 +#define PAX_USER_SHADOW_BASE (_AC(1,UL) << TASK_SIZE_MAX_SHIFT)
11668 +#else
11669 +#define PAX_USER_SHADOW_BASE (_AC(0,UL))
11670 +#endif
11671 +
11672 +#endif
11673 +
11674 #ifndef __ASSEMBLY__
11675
11676 extern int direct_gbpages;
11677 @@ -758,11 +846,23 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
11678 * dst and src can be on the same page, but the range must not overlap,
11679 * and must not cross a page boundary.
11680 */
11681 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
11682 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
11683 {
11684 - memcpy(dst, src, count * sizeof(pgd_t));
11685 + pax_open_kernel();
11686 + while (count--)
11687 + *dst++ = *src++;
11688 + pax_close_kernel();
11689 }
11690
11691 +#ifdef CONFIG_PAX_PER_CPU_PGD
11692 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
11693 +#endif
11694 +
11695 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
11696 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
11697 +#else
11698 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
11699 +#endif
11700
11701 #include <asm-generic/pgtable.h>
11702 #endif /* __ASSEMBLY__ */
11703 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
11704 index 0c92113..34a77c6 100644
11705 --- a/arch/x86/include/asm/pgtable_32.h
11706 +++ b/arch/x86/include/asm/pgtable_32.h
11707 @@ -25,9 +25,6 @@
11708 struct mm_struct;
11709 struct vm_area_struct;
11710
11711 -extern pgd_t swapper_pg_dir[1024];
11712 -extern pgd_t initial_page_table[1024];
11713 -
11714 static inline void pgtable_cache_init(void) { }
11715 static inline void check_pgt_cache(void) { }
11716 void paging_init(void);
11717 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
11718 # include <asm/pgtable-2level.h>
11719 #endif
11720
11721 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
11722 +extern pgd_t initial_page_table[PTRS_PER_PGD];
11723 +#ifdef CONFIG_X86_PAE
11724 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
11725 +#endif
11726 +
11727 #if defined(CONFIG_HIGHPTE)
11728 #define pte_offset_map(dir, address) \
11729 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
11730 @@ -62,7 +65,9 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
11731 /* Clear a kernel PTE and flush it from the TLB */
11732 #define kpte_clear_flush(ptep, vaddr) \
11733 do { \
11734 + pax_open_kernel(); \
11735 pte_clear(&init_mm, (vaddr), (ptep)); \
11736 + pax_close_kernel(); \
11737 __flush_tlb_one((vaddr)); \
11738 } while (0)
11739
11740 @@ -74,6 +79,9 @@ do { \
11741
11742 #endif /* !__ASSEMBLY__ */
11743
11744 +#define HAVE_ARCH_UNMAPPED_AREA
11745 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
11746 +
11747 /*
11748 * kern_addr_valid() is (1) for FLATMEM and (0) for
11749 * SPARSEMEM and DISCONTIGMEM
11750 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
11751 index ed5903b..c7fe163 100644
11752 --- a/arch/x86/include/asm/pgtable_32_types.h
11753 +++ b/arch/x86/include/asm/pgtable_32_types.h
11754 @@ -8,7 +8,7 @@
11755 */
11756 #ifdef CONFIG_X86_PAE
11757 # include <asm/pgtable-3level_types.h>
11758 -# define PMD_SIZE (1UL << PMD_SHIFT)
11759 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
11760 # define PMD_MASK (~(PMD_SIZE - 1))
11761 #else
11762 # include <asm/pgtable-2level_types.h>
11763 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
11764 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
11765 #endif
11766
11767 +#ifdef CONFIG_PAX_KERNEXEC
11768 +#ifndef __ASSEMBLY__
11769 +extern unsigned char MODULES_EXEC_VADDR[];
11770 +extern unsigned char MODULES_EXEC_END[];
11771 +#endif
11772 +#include <asm/boot.h>
11773 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
11774 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
11775 +#else
11776 +#define ktla_ktva(addr) (addr)
11777 +#define ktva_ktla(addr) (addr)
11778 +#endif
11779 +
11780 #define MODULES_VADDR VMALLOC_START
11781 #define MODULES_END VMALLOC_END
11782 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
11783 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
11784 index 975f709..9f779c9 100644
11785 --- a/arch/x86/include/asm/pgtable_64.h
11786 +++ b/arch/x86/include/asm/pgtable_64.h
11787 @@ -16,10 +16,14 @@
11788
11789 extern pud_t level3_kernel_pgt[512];
11790 extern pud_t level3_ident_pgt[512];
11791 +extern pud_t level3_vmalloc_start_pgt[512];
11792 +extern pud_t level3_vmalloc_end_pgt[512];
11793 +extern pud_t level3_vmemmap_pgt[512];
11794 +extern pud_t level2_vmemmap_pgt[512];
11795 extern pmd_t level2_kernel_pgt[512];
11796 extern pmd_t level2_fixmap_pgt[512];
11797 -extern pmd_t level2_ident_pgt[512];
11798 -extern pgd_t init_level4_pgt[];
11799 +extern pmd_t level2_ident_pgt[512*2];
11800 +extern pgd_t init_level4_pgt[512];
11801
11802 #define swapper_pg_dir init_level4_pgt
11803
11804 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
11805
11806 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
11807 {
11808 + pax_open_kernel();
11809 *pmdp = pmd;
11810 + pax_close_kernel();
11811 }
11812
11813 static inline void native_pmd_clear(pmd_t *pmd)
11814 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
11815
11816 static inline void native_set_pud(pud_t *pudp, pud_t pud)
11817 {
11818 + pax_open_kernel();
11819 *pudp = pud;
11820 + pax_close_kernel();
11821 }
11822
11823 static inline void native_pud_clear(pud_t *pud)
11824 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
11825
11826 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
11827 {
11828 + pax_open_kernel();
11829 + *pgdp = pgd;
11830 + pax_close_kernel();
11831 +}
11832 +
11833 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
11834 +{
11835 *pgdp = pgd;
11836 }
11837
11838 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
11839 index 766ea16..5b96cb3 100644
11840 --- a/arch/x86/include/asm/pgtable_64_types.h
11841 +++ b/arch/x86/include/asm/pgtable_64_types.h
11842 @@ -59,5 +59,10 @@ typedef struct { pteval_t pte; } pte_t;
11843 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
11844 #define MODULES_END _AC(0xffffffffff000000, UL)
11845 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
11846 +#define MODULES_EXEC_VADDR MODULES_VADDR
11847 +#define MODULES_EXEC_END MODULES_END
11848 +
11849 +#define ktla_ktva(addr) (addr)
11850 +#define ktva_ktla(addr) (addr)
11851
11852 #endif /* _ASM_X86_PGTABLE_64_DEFS_H */
11853 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
11854 index 013286a..8b42f4f 100644
11855 --- a/arch/x86/include/asm/pgtable_types.h
11856 +++ b/arch/x86/include/asm/pgtable_types.h
11857 @@ -16,13 +16,12 @@
11858 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
11859 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
11860 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
11861 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
11862 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
11863 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
11864 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
11865 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
11866 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
11867 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
11868 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
11869 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
11870 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
11871 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
11872
11873 /* If _PAGE_BIT_PRESENT is clear, we use these: */
11874 @@ -40,7 +39,6 @@
11875 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
11876 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
11877 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
11878 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
11879 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
11880 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
11881 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
11882 @@ -57,8 +55,10 @@
11883
11884 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
11885 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
11886 -#else
11887 +#elif defined(CONFIG_KMEMCHECK)
11888 #define _PAGE_NX (_AT(pteval_t, 0))
11889 +#else
11890 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
11891 #endif
11892
11893 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
11894 @@ -96,6 +96,9 @@
11895 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
11896 _PAGE_ACCESSED)
11897
11898 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
11899 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
11900 +
11901 #define __PAGE_KERNEL_EXEC \
11902 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
11903 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
11904 @@ -106,7 +109,7 @@
11905 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
11906 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
11907 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
11908 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
11909 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
11910 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
11911 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
11912 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
11913 @@ -168,8 +171,8 @@
11914 * bits are combined, this will alow user to access the high address mapped
11915 * VDSO in the presence of CONFIG_COMPAT_VDSO
11916 */
11917 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
11918 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
11919 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
11920 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
11921 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
11922 #endif
11923
11924 @@ -207,7 +210,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
11925 {
11926 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
11927 }
11928 +#endif
11929
11930 +#if PAGETABLE_LEVELS == 3
11931 +#include <asm-generic/pgtable-nopud.h>
11932 +#endif
11933 +
11934 +#if PAGETABLE_LEVELS == 2
11935 +#include <asm-generic/pgtable-nopmd.h>
11936 +#endif
11937 +
11938 +#ifndef __ASSEMBLY__
11939 #if PAGETABLE_LEVELS > 3
11940 typedef struct { pudval_t pud; } pud_t;
11941
11942 @@ -221,8 +234,6 @@ static inline pudval_t native_pud_val(pud_t pud)
11943 return pud.pud;
11944 }
11945 #else
11946 -#include <asm-generic/pgtable-nopud.h>
11947 -
11948 static inline pudval_t native_pud_val(pud_t pud)
11949 {
11950 return native_pgd_val(pud.pgd);
11951 @@ -242,8 +253,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
11952 return pmd.pmd;
11953 }
11954 #else
11955 -#include <asm-generic/pgtable-nopmd.h>
11956 -
11957 static inline pmdval_t native_pmd_val(pmd_t pmd)
11958 {
11959 return native_pgd_val(pmd.pud.pgd);
11960 @@ -283,7 +292,6 @@ typedef struct page *pgtable_t;
11961
11962 extern pteval_t __supported_pte_mask;
11963 extern void set_nx(void);
11964 -extern int nx_enabled;
11965
11966 #define pgprot_writecombine pgprot_writecombine
11967 extern pgprot_t pgprot_writecombine(pgprot_t prot);
11968 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
11969 index 58545c9..fe6fc38e 100644
11970 --- a/arch/x86/include/asm/processor.h
11971 +++ b/arch/x86/include/asm/processor.h
11972 @@ -266,7 +266,7 @@ struct tss_struct {
11973
11974 } ____cacheline_aligned;
11975
11976 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
11977 +extern struct tss_struct init_tss[NR_CPUS];
11978
11979 /*
11980 * Save the original ist values for checking stack pointers during debugging
11981 @@ -860,11 +860,18 @@ static inline void spin_lock_prefetch(const void *x)
11982 */
11983 #define TASK_SIZE PAGE_OFFSET
11984 #define TASK_SIZE_MAX TASK_SIZE
11985 +
11986 +#ifdef CONFIG_PAX_SEGMEXEC
11987 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
11988 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
11989 +#else
11990 #define STACK_TOP TASK_SIZE
11991 -#define STACK_TOP_MAX STACK_TOP
11992 +#endif
11993 +
11994 +#define STACK_TOP_MAX TASK_SIZE
11995
11996 #define INIT_THREAD { \
11997 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
11998 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
11999 .vm86_info = NULL, \
12000 .sysenter_cs = __KERNEL_CS, \
12001 .io_bitmap_ptr = NULL, \
12002 @@ -878,7 +885,7 @@ static inline void spin_lock_prefetch(const void *x)
12003 */
12004 #define INIT_TSS { \
12005 .x86_tss = { \
12006 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
12007 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
12008 .ss0 = __KERNEL_DS, \
12009 .ss1 = __KERNEL_CS, \
12010 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
12011 @@ -889,11 +896,7 @@ static inline void spin_lock_prefetch(const void *x)
12012 extern unsigned long thread_saved_pc(struct task_struct *tsk);
12013
12014 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
12015 -#define KSTK_TOP(info) \
12016 -({ \
12017 - unsigned long *__ptr = (unsigned long *)(info); \
12018 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
12019 -})
12020 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
12021
12022 /*
12023 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
12024 @@ -908,7 +911,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
12025 #define task_pt_regs(task) \
12026 ({ \
12027 struct pt_regs *__regs__; \
12028 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
12029 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
12030 __regs__ - 1; \
12031 })
12032
12033 @@ -918,13 +921,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
12034 /*
12035 * User space process size. 47bits minus one guard page.
12036 */
12037 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
12038 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
12039
12040 /* This decides where the kernel will search for a free chunk of vm
12041 * space during mmap's.
12042 */
12043 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
12044 - 0xc0000000 : 0xFFFFe000)
12045 + 0xc0000000 : 0xFFFFf000)
12046
12047 #define TASK_SIZE (test_thread_flag(TIF_IA32) ? \
12048 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
12049 @@ -935,11 +938,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
12050 #define STACK_TOP_MAX TASK_SIZE_MAX
12051
12052 #define INIT_THREAD { \
12053 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
12054 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
12055 }
12056
12057 #define INIT_TSS { \
12058 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
12059 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
12060 }
12061
12062 /*
12063 @@ -961,6 +964,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
12064 */
12065 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
12066
12067 +#ifdef CONFIG_PAX_SEGMEXEC
12068 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
12069 +#endif
12070 +
12071 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
12072
12073 /* Get/set a process' ability to use the timestamp counter instruction */
12074 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
12075 index 3566454..4bdfb8c 100644
12076 --- a/arch/x86/include/asm/ptrace.h
12077 +++ b/arch/x86/include/asm/ptrace.h
12078 @@ -156,28 +156,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
12079 }
12080
12081 /*
12082 - * user_mode_vm(regs) determines whether a register set came from user mode.
12083 + * user_mode(regs) determines whether a register set came from user mode.
12084 * This is true if V8086 mode was enabled OR if the register set was from
12085 * protected mode with RPL-3 CS value. This tricky test checks that with
12086 * one comparison. Many places in the kernel can bypass this full check
12087 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
12088 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
12089 + * be used.
12090 */
12091 -static inline int user_mode(struct pt_regs *regs)
12092 +static inline int user_mode_novm(struct pt_regs *regs)
12093 {
12094 #ifdef CONFIG_X86_32
12095 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
12096 #else
12097 - return !!(regs->cs & 3);
12098 + return !!(regs->cs & SEGMENT_RPL_MASK);
12099 #endif
12100 }
12101
12102 -static inline int user_mode_vm(struct pt_regs *regs)
12103 +static inline int user_mode(struct pt_regs *regs)
12104 {
12105 #ifdef CONFIG_X86_32
12106 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
12107 USER_RPL;
12108 #else
12109 - return user_mode(regs);
12110 + return user_mode_novm(regs);
12111 #endif
12112 }
12113
12114 @@ -193,15 +194,16 @@ static inline int v8086_mode(struct pt_regs *regs)
12115 #ifdef CONFIG_X86_64
12116 static inline bool user_64bit_mode(struct pt_regs *regs)
12117 {
12118 + unsigned long cs = regs->cs & 0xffff;
12119 #ifndef CONFIG_PARAVIRT
12120 /*
12121 * On non-paravirt systems, this is the only long mode CPL 3
12122 * selector. We do not allow long mode selectors in the LDT.
12123 */
12124 - return regs->cs == __USER_CS;
12125 + return cs == __USER_CS;
12126 #else
12127 /* Headers are too twisted for this to go in paravirt.h. */
12128 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
12129 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
12130 #endif
12131 }
12132 #endif
12133 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
12134 index 92f29706..a79cbbb 100644
12135 --- a/arch/x86/include/asm/reboot.h
12136 +++ b/arch/x86/include/asm/reboot.h
12137 @@ -6,19 +6,19 @@
12138 struct pt_regs;
12139
12140 struct machine_ops {
12141 - void (*restart)(char *cmd);
12142 - void (*halt)(void);
12143 - void (*power_off)(void);
12144 + void (* __noreturn restart)(char *cmd);
12145 + void (* __noreturn halt)(void);
12146 + void (* __noreturn power_off)(void);
12147 void (*shutdown)(void);
12148 void (*crash_shutdown)(struct pt_regs *);
12149 - void (*emergency_restart)(void);
12150 -};
12151 + void (* __noreturn emergency_restart)(void);
12152 +} __no_const;
12153
12154 extern struct machine_ops machine_ops;
12155
12156 void native_machine_crash_shutdown(struct pt_regs *regs);
12157 void native_machine_shutdown(void);
12158 -void machine_real_restart(unsigned int type);
12159 +void machine_real_restart(unsigned int type) __noreturn;
12160 /* These must match dispatch_table in reboot_32.S */
12161 #define MRR_BIOS 0
12162 #define MRR_APM 1
12163 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
12164 index 2dbe4a7..ce1db00 100644
12165 --- a/arch/x86/include/asm/rwsem.h
12166 +++ b/arch/x86/include/asm/rwsem.h
12167 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
12168 {
12169 asm volatile("# beginning down_read\n\t"
12170 LOCK_PREFIX _ASM_INC "(%1)\n\t"
12171 +
12172 +#ifdef CONFIG_PAX_REFCOUNT
12173 + "jno 0f\n"
12174 + LOCK_PREFIX _ASM_DEC "(%1)\n"
12175 + "int $4\n0:\n"
12176 + _ASM_EXTABLE(0b, 0b)
12177 +#endif
12178 +
12179 /* adds 0x00000001 */
12180 " jns 1f\n"
12181 " call call_rwsem_down_read_failed\n"
12182 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
12183 "1:\n\t"
12184 " mov %1,%2\n\t"
12185 " add %3,%2\n\t"
12186 +
12187 +#ifdef CONFIG_PAX_REFCOUNT
12188 + "jno 0f\n"
12189 + "sub %3,%2\n"
12190 + "int $4\n0:\n"
12191 + _ASM_EXTABLE(0b, 0b)
12192 +#endif
12193 +
12194 " jle 2f\n\t"
12195 LOCK_PREFIX " cmpxchg %2,%0\n\t"
12196 " jnz 1b\n\t"
12197 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
12198 long tmp;
12199 asm volatile("# beginning down_write\n\t"
12200 LOCK_PREFIX " xadd %1,(%2)\n\t"
12201 +
12202 +#ifdef CONFIG_PAX_REFCOUNT
12203 + "jno 0f\n"
12204 + "mov %1,(%2)\n"
12205 + "int $4\n0:\n"
12206 + _ASM_EXTABLE(0b, 0b)
12207 +#endif
12208 +
12209 /* adds 0xffff0001, returns the old value */
12210 " test %1,%1\n\t"
12211 /* was the count 0 before? */
12212 @@ -141,6 +165,14 @@ static inline void __up_read(struct rw_semaphore *sem)
12213 long tmp;
12214 asm volatile("# beginning __up_read\n\t"
12215 LOCK_PREFIX " xadd %1,(%2)\n\t"
12216 +
12217 +#ifdef CONFIG_PAX_REFCOUNT
12218 + "jno 0f\n"
12219 + "mov %1,(%2)\n"
12220 + "int $4\n0:\n"
12221 + _ASM_EXTABLE(0b, 0b)
12222 +#endif
12223 +
12224 /* subtracts 1, returns the old value */
12225 " jns 1f\n\t"
12226 " call call_rwsem_wake\n" /* expects old value in %edx */
12227 @@ -159,6 +191,14 @@ static inline void __up_write(struct rw_semaphore *sem)
12228 long tmp;
12229 asm volatile("# beginning __up_write\n\t"
12230 LOCK_PREFIX " xadd %1,(%2)\n\t"
12231 +
12232 +#ifdef CONFIG_PAX_REFCOUNT
12233 + "jno 0f\n"
12234 + "mov %1,(%2)\n"
12235 + "int $4\n0:\n"
12236 + _ASM_EXTABLE(0b, 0b)
12237 +#endif
12238 +
12239 /* subtracts 0xffff0001, returns the old value */
12240 " jns 1f\n\t"
12241 " call call_rwsem_wake\n" /* expects old value in %edx */
12242 @@ -176,6 +216,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
12243 {
12244 asm volatile("# beginning __downgrade_write\n\t"
12245 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
12246 +
12247 +#ifdef CONFIG_PAX_REFCOUNT
12248 + "jno 0f\n"
12249 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
12250 + "int $4\n0:\n"
12251 + _ASM_EXTABLE(0b, 0b)
12252 +#endif
12253 +
12254 /*
12255 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
12256 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
12257 @@ -194,7 +242,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
12258 */
12259 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
12260 {
12261 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
12262 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
12263 +
12264 +#ifdef CONFIG_PAX_REFCOUNT
12265 + "jno 0f\n"
12266 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
12267 + "int $4\n0:\n"
12268 + _ASM_EXTABLE(0b, 0b)
12269 +#endif
12270 +
12271 : "+m" (sem->count)
12272 : "er" (delta));
12273 }
12274 @@ -204,7 +260,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
12275 */
12276 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
12277 {
12278 - return delta + xadd(&sem->count, delta);
12279 + return delta + xadd_check_overflow(&sem->count, delta);
12280 }
12281
12282 #endif /* __KERNEL__ */
12283 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
12284 index 5e64171..f58957e 100644
12285 --- a/arch/x86/include/asm/segment.h
12286 +++ b/arch/x86/include/asm/segment.h
12287 @@ -64,10 +64,15 @@
12288 * 26 - ESPFIX small SS
12289 * 27 - per-cpu [ offset to per-cpu data area ]
12290 * 28 - stack_canary-20 [ for stack protector ]
12291 - * 29 - unused
12292 - * 30 - unused
12293 + * 29 - PCI BIOS CS
12294 + * 30 - PCI BIOS DS
12295 * 31 - TSS for double fault handler
12296 */
12297 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
12298 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
12299 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
12300 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
12301 +
12302 #define GDT_ENTRY_TLS_MIN 6
12303 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
12304
12305 @@ -79,6 +84,8 @@
12306
12307 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
12308
12309 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
12310 +
12311 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
12312
12313 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
12314 @@ -104,6 +111,12 @@
12315 #define __KERNEL_STACK_CANARY 0
12316 #endif
12317
12318 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
12319 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
12320 +
12321 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
12322 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
12323 +
12324 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
12325
12326 /*
12327 @@ -141,7 +154,7 @@
12328 */
12329
12330 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
12331 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
12332 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
12333
12334
12335 #else
12336 @@ -165,6 +178,8 @@
12337 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
12338 #define __USER32_DS __USER_DS
12339
12340 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
12341 +
12342 #define GDT_ENTRY_TSS 8 /* needs two entries */
12343 #define GDT_ENTRY_LDT 10 /* needs two entries */
12344 #define GDT_ENTRY_TLS_MIN 12
12345 @@ -185,6 +200,7 @@
12346 #endif
12347
12348 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
12349 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
12350 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
12351 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
12352 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
12353 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
12354 index 0434c40..1714bf0 100644
12355 --- a/arch/x86/include/asm/smp.h
12356 +++ b/arch/x86/include/asm/smp.h
12357 @@ -36,7 +36,7 @@ DECLARE_PER_CPU(cpumask_var_t, cpu_core_map);
12358 /* cpus sharing the last level cache: */
12359 DECLARE_PER_CPU(cpumask_var_t, cpu_llc_shared_map);
12360 DECLARE_PER_CPU(u16, cpu_llc_id);
12361 -DECLARE_PER_CPU(int, cpu_number);
12362 +DECLARE_PER_CPU(unsigned int, cpu_number);
12363
12364 static inline struct cpumask *cpu_sibling_mask(int cpu)
12365 {
12366 @@ -77,7 +77,7 @@ struct smp_ops {
12367
12368 void (*send_call_func_ipi)(const struct cpumask *mask);
12369 void (*send_call_func_single_ipi)(int cpu);
12370 -};
12371 +} __no_const;
12372
12373 /* Globals due to paravirt */
12374 extern void set_cpu_sibling_map(int cpu);
12375 @@ -192,14 +192,8 @@ extern unsigned disabled_cpus __cpuinitdata;
12376 extern int safe_smp_processor_id(void);
12377
12378 #elif defined(CONFIG_X86_64_SMP)
12379 -#define raw_smp_processor_id() (percpu_read(cpu_number))
12380 -
12381 -#define stack_smp_processor_id() \
12382 -({ \
12383 - struct thread_info *ti; \
12384 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
12385 - ti->cpu; \
12386 -})
12387 +#define raw_smp_processor_id() (percpu_read(cpu_number))
12388 +#define stack_smp_processor_id() raw_smp_processor_id()
12389 #define safe_smp_processor_id() smp_processor_id()
12390
12391 #endif
12392 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
12393 index a82c2bf..2198f61 100644
12394 --- a/arch/x86/include/asm/spinlock.h
12395 +++ b/arch/x86/include/asm/spinlock.h
12396 @@ -175,6 +175,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
12397 static inline void arch_read_lock(arch_rwlock_t *rw)
12398 {
12399 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
12400 +
12401 +#ifdef CONFIG_PAX_REFCOUNT
12402 + "jno 0f\n"
12403 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
12404 + "int $4\n0:\n"
12405 + _ASM_EXTABLE(0b, 0b)
12406 +#endif
12407 +
12408 "jns 1f\n"
12409 "call __read_lock_failed\n\t"
12410 "1:\n"
12411 @@ -184,6 +192,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
12412 static inline void arch_write_lock(arch_rwlock_t *rw)
12413 {
12414 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
12415 +
12416 +#ifdef CONFIG_PAX_REFCOUNT
12417 + "jno 0f\n"
12418 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
12419 + "int $4\n0:\n"
12420 + _ASM_EXTABLE(0b, 0b)
12421 +#endif
12422 +
12423 "jz 1f\n"
12424 "call __write_lock_failed\n\t"
12425 "1:\n"
12426 @@ -213,13 +229,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
12427
12428 static inline void arch_read_unlock(arch_rwlock_t *rw)
12429 {
12430 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
12431 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
12432 +
12433 +#ifdef CONFIG_PAX_REFCOUNT
12434 + "jno 0f\n"
12435 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
12436 + "int $4\n0:\n"
12437 + _ASM_EXTABLE(0b, 0b)
12438 +#endif
12439 +
12440 :"+m" (rw->lock) : : "memory");
12441 }
12442
12443 static inline void arch_write_unlock(arch_rwlock_t *rw)
12444 {
12445 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
12446 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
12447 +
12448 +#ifdef CONFIG_PAX_REFCOUNT
12449 + "jno 0f\n"
12450 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
12451 + "int $4\n0:\n"
12452 + _ASM_EXTABLE(0b, 0b)
12453 +#endif
12454 +
12455 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
12456 }
12457
12458 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
12459 index 1575177..cb23f52 100644
12460 --- a/arch/x86/include/asm/stackprotector.h
12461 +++ b/arch/x86/include/asm/stackprotector.h
12462 @@ -48,7 +48,7 @@
12463 * head_32 for boot CPU and setup_per_cpu_areas() for others.
12464 */
12465 #define GDT_STACK_CANARY_INIT \
12466 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
12467 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
12468
12469 /*
12470 * Initialize the stackprotector canary value.
12471 @@ -113,7 +113,7 @@ static inline void setup_stack_canary_segment(int cpu)
12472
12473 static inline void load_stack_canary_segment(void)
12474 {
12475 -#ifdef CONFIG_X86_32
12476 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
12477 asm volatile ("mov %0, %%gs" : : "r" (0));
12478 #endif
12479 }
12480 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
12481 index 70bbe39..4ae2bd4 100644
12482 --- a/arch/x86/include/asm/stacktrace.h
12483 +++ b/arch/x86/include/asm/stacktrace.h
12484 @@ -11,28 +11,20 @@
12485
12486 extern int kstack_depth_to_print;
12487
12488 -struct thread_info;
12489 +struct task_struct;
12490 struct stacktrace_ops;
12491
12492 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
12493 - unsigned long *stack,
12494 - unsigned long bp,
12495 - const struct stacktrace_ops *ops,
12496 - void *data,
12497 - unsigned long *end,
12498 - int *graph);
12499 +typedef unsigned long walk_stack_t(struct task_struct *task,
12500 + void *stack_start,
12501 + unsigned long *stack,
12502 + unsigned long bp,
12503 + const struct stacktrace_ops *ops,
12504 + void *data,
12505 + unsigned long *end,
12506 + int *graph);
12507
12508 -extern unsigned long
12509 -print_context_stack(struct thread_info *tinfo,
12510 - unsigned long *stack, unsigned long bp,
12511 - const struct stacktrace_ops *ops, void *data,
12512 - unsigned long *end, int *graph);
12513 -
12514 -extern unsigned long
12515 -print_context_stack_bp(struct thread_info *tinfo,
12516 - unsigned long *stack, unsigned long bp,
12517 - const struct stacktrace_ops *ops, void *data,
12518 - unsigned long *end, int *graph);
12519 +extern walk_stack_t print_context_stack;
12520 +extern walk_stack_t print_context_stack_bp;
12521
12522 /* Generic stack tracer with callbacks */
12523
12524 @@ -40,7 +32,7 @@ struct stacktrace_ops {
12525 void (*address)(void *data, unsigned long address, int reliable);
12526 /* On negative return stop dumping */
12527 int (*stack)(void *data, char *name);
12528 - walk_stack_t walk_stack;
12529 + walk_stack_t *walk_stack;
12530 };
12531
12532 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
12533 diff --git a/arch/x86/include/asm/sys_ia32.h b/arch/x86/include/asm/sys_ia32.h
12534 index cb23852..2dde194 100644
12535 --- a/arch/x86/include/asm/sys_ia32.h
12536 +++ b/arch/x86/include/asm/sys_ia32.h
12537 @@ -40,7 +40,7 @@ asmlinkage long sys32_rt_sigprocmask(int, compat_sigset_t __user *,
12538 compat_sigset_t __user *, unsigned int);
12539 asmlinkage long sys32_alarm(unsigned int);
12540
12541 -asmlinkage long sys32_waitpid(compat_pid_t, unsigned int *, int);
12542 +asmlinkage long sys32_waitpid(compat_pid_t, unsigned int __user *, int);
12543 asmlinkage long sys32_sysfs(int, u32, u32);
12544
12545 asmlinkage long sys32_sched_rr_get_interval(compat_pid_t,
12546 diff --git a/arch/x86/include/asm/system.h b/arch/x86/include/asm/system.h
12547 index 2d2f01c..f985723 100644
12548 --- a/arch/x86/include/asm/system.h
12549 +++ b/arch/x86/include/asm/system.h
12550 @@ -129,7 +129,7 @@ do { \
12551 "call __switch_to\n\t" \
12552 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
12553 __switch_canary \
12554 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
12555 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
12556 "movq %%rax,%%rdi\n\t" \
12557 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
12558 "jnz ret_from_fork\n\t" \
12559 @@ -140,7 +140,7 @@ do { \
12560 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
12561 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
12562 [_tif_fork] "i" (_TIF_FORK), \
12563 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
12564 + [thread_info] "m" (current_tinfo), \
12565 [current_task] "m" (current_task) \
12566 __switch_canary_iparam \
12567 : "memory", "cc" __EXTRA_CLOBBER)
12568 @@ -200,7 +200,7 @@ static inline unsigned long get_limit(unsigned long segment)
12569 {
12570 unsigned long __limit;
12571 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
12572 - return __limit + 1;
12573 + return __limit;
12574 }
12575
12576 static inline void native_clts(void)
12577 @@ -397,13 +397,13 @@ void enable_hlt(void);
12578
12579 void cpu_idle_wait(void);
12580
12581 -extern unsigned long arch_align_stack(unsigned long sp);
12582 +#define arch_align_stack(x) ((x) & ~0xfUL)
12583 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
12584
12585 void default_idle(void);
12586 bool set_pm_idle_to_default(void);
12587
12588 -void stop_this_cpu(void *dummy);
12589 +void stop_this_cpu(void *dummy) __noreturn;
12590
12591 /*
12592 * Force strict CPU ordering.
12593 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
12594 index cfd8144..664ac89 100644
12595 --- a/arch/x86/include/asm/thread_info.h
12596 +++ b/arch/x86/include/asm/thread_info.h
12597 @@ -10,6 +10,7 @@
12598 #include <linux/compiler.h>
12599 #include <asm/page.h>
12600 #include <asm/types.h>
12601 +#include <asm/percpu.h>
12602
12603 /*
12604 * low level task data that entry.S needs immediate access to
12605 @@ -24,7 +25,6 @@ struct exec_domain;
12606 #include <linux/atomic.h>
12607
12608 struct thread_info {
12609 - struct task_struct *task; /* main task structure */
12610 struct exec_domain *exec_domain; /* execution domain */
12611 __u32 flags; /* low level flags */
12612 __u32 status; /* thread synchronous flags */
12613 @@ -34,19 +34,13 @@ struct thread_info {
12614 mm_segment_t addr_limit;
12615 struct restart_block restart_block;
12616 void __user *sysenter_return;
12617 -#ifdef CONFIG_X86_32
12618 - unsigned long previous_esp; /* ESP of the previous stack in
12619 - case of nested (IRQ) stacks
12620 - */
12621 - __u8 supervisor_stack[0];
12622 -#endif
12623 + unsigned long lowest_stack;
12624 unsigned int sig_on_uaccess_error:1;
12625 unsigned int uaccess_err:1; /* uaccess failed */
12626 };
12627
12628 -#define INIT_THREAD_INFO(tsk) \
12629 +#define INIT_THREAD_INFO \
12630 { \
12631 - .task = &tsk, \
12632 .exec_domain = &default_exec_domain, \
12633 .flags = 0, \
12634 .cpu = 0, \
12635 @@ -57,7 +51,7 @@ struct thread_info {
12636 }, \
12637 }
12638
12639 -#define init_thread_info (init_thread_union.thread_info)
12640 +#define init_thread_info (init_thread_union.stack)
12641 #define init_stack (init_thread_union.stack)
12642
12643 #else /* !__ASSEMBLY__ */
12644 @@ -95,6 +89,7 @@ struct thread_info {
12645 #define TIF_BLOCKSTEP 25 /* set when we want DEBUGCTLMSR_BTF */
12646 #define TIF_LAZY_MMU_UPDATES 27 /* task is updating the mmu lazily */
12647 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
12648 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
12649
12650 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
12651 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
12652 @@ -116,16 +111,17 @@ struct thread_info {
12653 #define _TIF_BLOCKSTEP (1 << TIF_BLOCKSTEP)
12654 #define _TIF_LAZY_MMU_UPDATES (1 << TIF_LAZY_MMU_UPDATES)
12655 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
12656 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
12657
12658 /* work to do in syscall_trace_enter() */
12659 #define _TIF_WORK_SYSCALL_ENTRY \
12660 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
12661 - _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT)
12662 + _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
12663
12664 /* work to do in syscall_trace_leave() */
12665 #define _TIF_WORK_SYSCALL_EXIT \
12666 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
12667 - _TIF_SYSCALL_TRACEPOINT)
12668 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
12669
12670 /* work to do on interrupt/exception return */
12671 #define _TIF_WORK_MASK \
12672 @@ -135,7 +131,8 @@ struct thread_info {
12673
12674 /* work to do on any return to user space */
12675 #define _TIF_ALLWORK_MASK \
12676 - ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT)
12677 + ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
12678 + _TIF_GRSEC_SETXID)
12679
12680 /* Only used for 64 bit */
12681 #define _TIF_DO_NOTIFY_MASK \
12682 @@ -169,45 +166,40 @@ struct thread_info {
12683 ret; \
12684 })
12685
12686 -#ifdef CONFIG_X86_32
12687 -
12688 -#define STACK_WARN (THREAD_SIZE/8)
12689 -/*
12690 - * macros/functions for gaining access to the thread information structure
12691 - *
12692 - * preempt_count needs to be 1 initially, until the scheduler is functional.
12693 - */
12694 -#ifndef __ASSEMBLY__
12695 -
12696 -
12697 -/* how to get the current stack pointer from C */
12698 -register unsigned long current_stack_pointer asm("esp") __used;
12699 -
12700 -/* how to get the thread information struct from C */
12701 -static inline struct thread_info *current_thread_info(void)
12702 -{
12703 - return (struct thread_info *)
12704 - (current_stack_pointer & ~(THREAD_SIZE - 1));
12705 -}
12706 -
12707 -#else /* !__ASSEMBLY__ */
12708 -
12709 +#ifdef __ASSEMBLY__
12710 /* how to get the thread information struct from ASM */
12711 #define GET_THREAD_INFO(reg) \
12712 - movl $-THREAD_SIZE, reg; \
12713 - andl %esp, reg
12714 + mov PER_CPU_VAR(current_tinfo), reg
12715
12716 /* use this one if reg already contains %esp */
12717 -#define GET_THREAD_INFO_WITH_ESP(reg) \
12718 - andl $-THREAD_SIZE, reg
12719 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
12720 +#else
12721 +/* how to get the thread information struct from C */
12722 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
12723 +
12724 +static __always_inline struct thread_info *current_thread_info(void)
12725 +{
12726 + return percpu_read_stable(current_tinfo);
12727 +}
12728 +#endif
12729 +
12730 +#ifdef CONFIG_X86_32
12731 +
12732 +#define STACK_WARN (THREAD_SIZE/8)
12733 +/*
12734 + * macros/functions for gaining access to the thread information structure
12735 + *
12736 + * preempt_count needs to be 1 initially, until the scheduler is functional.
12737 + */
12738 +#ifndef __ASSEMBLY__
12739 +
12740 +/* how to get the current stack pointer from C */
12741 +register unsigned long current_stack_pointer asm("esp") __used;
12742
12743 #endif
12744
12745 #else /* X86_32 */
12746
12747 -#include <asm/percpu.h>
12748 -#define KERNEL_STACK_OFFSET (5*8)
12749 -
12750 /*
12751 * macros/functions for gaining access to the thread information structure
12752 * preempt_count needs to be 1 initially, until the scheduler is functional.
12753 @@ -215,27 +207,8 @@ static inline struct thread_info *current_thread_info(void)
12754 #ifndef __ASSEMBLY__
12755 DECLARE_PER_CPU(unsigned long, kernel_stack);
12756
12757 -static inline struct thread_info *current_thread_info(void)
12758 -{
12759 - struct thread_info *ti;
12760 - ti = (void *)(percpu_read_stable(kernel_stack) +
12761 - KERNEL_STACK_OFFSET - THREAD_SIZE);
12762 - return ti;
12763 -}
12764 -
12765 -#else /* !__ASSEMBLY__ */
12766 -
12767 -/* how to get the thread information struct from ASM */
12768 -#define GET_THREAD_INFO(reg) \
12769 - movq PER_CPU_VAR(kernel_stack),reg ; \
12770 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
12771 -
12772 -/*
12773 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
12774 - * a certain register (to be used in assembler memory operands).
12775 - */
12776 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
12777 -
12778 +/* how to get the current stack pointer from C */
12779 +register unsigned long current_stack_pointer asm("rsp") __used;
12780 #endif
12781
12782 #endif /* !X86_32 */
12783 @@ -269,5 +242,16 @@ extern void arch_task_cache_init(void);
12784 extern void free_thread_info(struct thread_info *ti);
12785 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
12786 #define arch_task_cache_init arch_task_cache_init
12787 +
12788 +#define __HAVE_THREAD_FUNCTIONS
12789 +#define task_thread_info(task) (&(task)->tinfo)
12790 +#define task_stack_page(task) ((task)->stack)
12791 +#define setup_thread_stack(p, org) do {} while (0)
12792 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
12793 +
12794 +#define __HAVE_ARCH_TASK_STRUCT_ALLOCATOR
12795 +extern struct task_struct *alloc_task_struct_node(int node);
12796 +extern void free_task_struct(struct task_struct *);
12797 +
12798 #endif
12799 #endif /* _ASM_X86_THREAD_INFO_H */
12800 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
12801 index 8be5f54..7ae826d 100644
12802 --- a/arch/x86/include/asm/uaccess.h
12803 +++ b/arch/x86/include/asm/uaccess.h
12804 @@ -7,12 +7,15 @@
12805 #include <linux/compiler.h>
12806 #include <linux/thread_info.h>
12807 #include <linux/string.h>
12808 +#include <linux/sched.h>
12809 #include <asm/asm.h>
12810 #include <asm/page.h>
12811
12812 #define VERIFY_READ 0
12813 #define VERIFY_WRITE 1
12814
12815 +extern void check_object_size(const void *ptr, unsigned long n, bool to);
12816 +
12817 /*
12818 * The fs value determines whether argument validity checking should be
12819 * performed or not. If get_fs() == USER_DS, checking is performed, with
12820 @@ -28,7 +31,12 @@
12821
12822 #define get_ds() (KERNEL_DS)
12823 #define get_fs() (current_thread_info()->addr_limit)
12824 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
12825 +void __set_fs(mm_segment_t x);
12826 +void set_fs(mm_segment_t x);
12827 +#else
12828 #define set_fs(x) (current_thread_info()->addr_limit = (x))
12829 +#endif
12830
12831 #define segment_eq(a, b) ((a).seg == (b).seg)
12832
12833 @@ -76,7 +84,33 @@
12834 * checks that the pointer is in the user space range - after calling
12835 * this function, memory access functions may still return -EFAULT.
12836 */
12837 -#define access_ok(type, addr, size) (likely(__range_not_ok(addr, size) == 0))
12838 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size) == 0))
12839 +#define access_ok(type, addr, size) \
12840 +({ \
12841 + long __size = size; \
12842 + unsigned long __addr = (unsigned long)addr; \
12843 + unsigned long __addr_ao = __addr & PAGE_MASK; \
12844 + unsigned long __end_ao = __addr + __size - 1; \
12845 + bool __ret_ao = __range_not_ok(__addr, __size) == 0; \
12846 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
12847 + while(__addr_ao <= __end_ao) { \
12848 + char __c_ao; \
12849 + __addr_ao += PAGE_SIZE; \
12850 + if (__size > PAGE_SIZE) \
12851 + cond_resched(); \
12852 + if (__get_user(__c_ao, (char __user *)__addr)) \
12853 + break; \
12854 + if (type != VERIFY_WRITE) { \
12855 + __addr = __addr_ao; \
12856 + continue; \
12857 + } \
12858 + if (__put_user(__c_ao, (char __user *)__addr)) \
12859 + break; \
12860 + __addr = __addr_ao; \
12861 + } \
12862 + } \
12863 + __ret_ao; \
12864 +})
12865
12866 /*
12867 * The exception table consists of pairs of addresses: the first is the
12868 @@ -182,12 +216,20 @@ extern int __get_user_bad(void);
12869 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
12870 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
12871
12872 -
12873 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
12874 +#define __copyuser_seg "gs;"
12875 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
12876 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
12877 +#else
12878 +#define __copyuser_seg
12879 +#define __COPYUSER_SET_ES
12880 +#define __COPYUSER_RESTORE_ES
12881 +#endif
12882
12883 #ifdef CONFIG_X86_32
12884 #define __put_user_asm_u64(x, addr, err, errret) \
12885 - asm volatile("1: movl %%eax,0(%2)\n" \
12886 - "2: movl %%edx,4(%2)\n" \
12887 + asm volatile("1: "__copyuser_seg"movl %%eax,0(%2)\n" \
12888 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
12889 "3:\n" \
12890 ".section .fixup,\"ax\"\n" \
12891 "4: movl %3,%0\n" \
12892 @@ -199,8 +241,8 @@ extern int __get_user_bad(void);
12893 : "A" (x), "r" (addr), "i" (errret), "0" (err))
12894
12895 #define __put_user_asm_ex_u64(x, addr) \
12896 - asm volatile("1: movl %%eax,0(%1)\n" \
12897 - "2: movl %%edx,4(%1)\n" \
12898 + asm volatile("1: "__copyuser_seg"movl %%eax,0(%1)\n" \
12899 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
12900 "3:\n" \
12901 _ASM_EXTABLE(1b, 2b - 1b) \
12902 _ASM_EXTABLE(2b, 3b - 2b) \
12903 @@ -252,7 +294,7 @@ extern void __put_user_8(void);
12904 __typeof__(*(ptr)) __pu_val; \
12905 __chk_user_ptr(ptr); \
12906 might_fault(); \
12907 - __pu_val = x; \
12908 + __pu_val = (x); \
12909 switch (sizeof(*(ptr))) { \
12910 case 1: \
12911 __put_user_x(1, __pu_val, ptr, __ret_pu); \
12912 @@ -373,7 +415,7 @@ do { \
12913 } while (0)
12914
12915 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
12916 - asm volatile("1: mov"itype" %2,%"rtype"1\n" \
12917 + asm volatile("1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
12918 "2:\n" \
12919 ".section .fixup,\"ax\"\n" \
12920 "3: mov %3,%0\n" \
12921 @@ -381,7 +423,7 @@ do { \
12922 " jmp 2b\n" \
12923 ".previous\n" \
12924 _ASM_EXTABLE(1b, 3b) \
12925 - : "=r" (err), ltype(x) \
12926 + : "=r" (err), ltype (x) \
12927 : "m" (__m(addr)), "i" (errret), "0" (err))
12928
12929 #define __get_user_size_ex(x, ptr, size) \
12930 @@ -406,7 +448,7 @@ do { \
12931 } while (0)
12932
12933 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
12934 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
12935 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
12936 "2:\n" \
12937 _ASM_EXTABLE(1b, 2b - 1b) \
12938 : ltype(x) : "m" (__m(addr)))
12939 @@ -423,13 +465,24 @@ do { \
12940 int __gu_err; \
12941 unsigned long __gu_val; \
12942 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
12943 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
12944 + (x) = (__typeof__(*(ptr)))__gu_val; \
12945 __gu_err; \
12946 })
12947
12948 /* FIXME: this hack is definitely wrong -AK */
12949 struct __large_struct { unsigned long buf[100]; };
12950 -#define __m(x) (*(struct __large_struct __user *)(x))
12951 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
12952 +#define ____m(x) \
12953 +({ \
12954 + unsigned long ____x = (unsigned long)(x); \
12955 + if (____x < PAX_USER_SHADOW_BASE) \
12956 + ____x += PAX_USER_SHADOW_BASE; \
12957 + (void __user *)____x; \
12958 +})
12959 +#else
12960 +#define ____m(x) (x)
12961 +#endif
12962 +#define __m(x) (*(struct __large_struct __user *)____m(x))
12963
12964 /*
12965 * Tell gcc we read from memory instead of writing: this is because
12966 @@ -437,7 +490,7 @@ struct __large_struct { unsigned long buf[100]; };
12967 * aliasing issues.
12968 */
12969 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
12970 - asm volatile("1: mov"itype" %"rtype"1,%2\n" \
12971 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
12972 "2:\n" \
12973 ".section .fixup,\"ax\"\n" \
12974 "3: mov %3,%0\n" \
12975 @@ -445,10 +498,10 @@ struct __large_struct { unsigned long buf[100]; };
12976 ".previous\n" \
12977 _ASM_EXTABLE(1b, 3b) \
12978 : "=r"(err) \
12979 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
12980 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
12981
12982 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
12983 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
12984 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
12985 "2:\n" \
12986 _ASM_EXTABLE(1b, 2b - 1b) \
12987 : : ltype(x), "m" (__m(addr)))
12988 @@ -487,8 +540,12 @@ struct __large_struct { unsigned long buf[100]; };
12989 * On error, the variable @x is set to zero.
12990 */
12991
12992 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
12993 +#define __get_user(x, ptr) get_user((x), (ptr))
12994 +#else
12995 #define __get_user(x, ptr) \
12996 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
12997 +#endif
12998
12999 /**
13000 * __put_user: - Write a simple value into user space, with less checking.
13001 @@ -510,8 +567,12 @@ struct __large_struct { unsigned long buf[100]; };
13002 * Returns zero on success, or -EFAULT on error.
13003 */
13004
13005 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
13006 +#define __put_user(x, ptr) put_user((x), (ptr))
13007 +#else
13008 #define __put_user(x, ptr) \
13009 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
13010 +#endif
13011
13012 #define __get_user_unaligned __get_user
13013 #define __put_user_unaligned __put_user
13014 @@ -529,7 +590,7 @@ struct __large_struct { unsigned long buf[100]; };
13015 #define get_user_ex(x, ptr) do { \
13016 unsigned long __gue_val; \
13017 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
13018 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
13019 + (x) = (__typeof__(*(ptr)))__gue_val; \
13020 } while (0)
13021
13022 #ifdef CONFIG_X86_WP_WORKS_OK
13023 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
13024 index 566e803..1230707 100644
13025 --- a/arch/x86/include/asm/uaccess_32.h
13026 +++ b/arch/x86/include/asm/uaccess_32.h
13027 @@ -11,15 +11,15 @@
13028 #include <asm/page.h>
13029
13030 unsigned long __must_check __copy_to_user_ll
13031 - (void __user *to, const void *from, unsigned long n);
13032 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
13033 unsigned long __must_check __copy_from_user_ll
13034 - (void *to, const void __user *from, unsigned long n);
13035 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
13036 unsigned long __must_check __copy_from_user_ll_nozero
13037 - (void *to, const void __user *from, unsigned long n);
13038 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
13039 unsigned long __must_check __copy_from_user_ll_nocache
13040 - (void *to, const void __user *from, unsigned long n);
13041 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
13042 unsigned long __must_check __copy_from_user_ll_nocache_nozero
13043 - (void *to, const void __user *from, unsigned long n);
13044 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
13045
13046 /**
13047 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
13048 @@ -43,6 +43,9 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
13049 static __always_inline unsigned long __must_check
13050 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
13051 {
13052 + if ((long)n < 0)
13053 + return n;
13054 +
13055 if (__builtin_constant_p(n)) {
13056 unsigned long ret;
13057
13058 @@ -61,6 +64,8 @@ __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
13059 return ret;
13060 }
13061 }
13062 + if (!__builtin_constant_p(n))
13063 + check_object_size(from, n, true);
13064 return __copy_to_user_ll(to, from, n);
13065 }
13066
13067 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
13068 __copy_to_user(void __user *to, const void *from, unsigned long n)
13069 {
13070 might_fault();
13071 +
13072 return __copy_to_user_inatomic(to, from, n);
13073 }
13074
13075 static __always_inline unsigned long
13076 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
13077 {
13078 + if ((long)n < 0)
13079 + return n;
13080 +
13081 /* Avoid zeroing the tail if the copy fails..
13082 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
13083 * but as the zeroing behaviour is only significant when n is not
13084 @@ -137,6 +146,10 @@ static __always_inline unsigned long
13085 __copy_from_user(void *to, const void __user *from, unsigned long n)
13086 {
13087 might_fault();
13088 +
13089 + if ((long)n < 0)
13090 + return n;
13091 +
13092 if (__builtin_constant_p(n)) {
13093 unsigned long ret;
13094
13095 @@ -152,6 +165,8 @@ __copy_from_user(void *to, const void __user *from, unsigned long n)
13096 return ret;
13097 }
13098 }
13099 + if (!__builtin_constant_p(n))
13100 + check_object_size(to, n, false);
13101 return __copy_from_user_ll(to, from, n);
13102 }
13103
13104 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
13105 const void __user *from, unsigned long n)
13106 {
13107 might_fault();
13108 +
13109 + if ((long)n < 0)
13110 + return n;
13111 +
13112 if (__builtin_constant_p(n)) {
13113 unsigned long ret;
13114
13115 @@ -181,15 +200,19 @@ static __always_inline unsigned long
13116 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
13117 unsigned long n)
13118 {
13119 - return __copy_from_user_ll_nocache_nozero(to, from, n);
13120 + if ((long)n < 0)
13121 + return n;
13122 +
13123 + return __copy_from_user_ll_nocache_nozero(to, from, n);
13124 }
13125
13126 -unsigned long __must_check copy_to_user(void __user *to,
13127 - const void *from, unsigned long n);
13128 -unsigned long __must_check _copy_from_user(void *to,
13129 - const void __user *from,
13130 - unsigned long n);
13131 -
13132 +extern void copy_to_user_overflow(void)
13133 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
13134 + __compiletime_error("copy_to_user() buffer size is not provably correct")
13135 +#else
13136 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
13137 +#endif
13138 +;
13139
13140 extern void copy_from_user_overflow(void)
13141 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
13142 @@ -199,17 +222,61 @@ extern void copy_from_user_overflow(void)
13143 #endif
13144 ;
13145
13146 -static inline unsigned long __must_check copy_from_user(void *to,
13147 - const void __user *from,
13148 - unsigned long n)
13149 +/**
13150 + * copy_to_user: - Copy a block of data into user space.
13151 + * @to: Destination address, in user space.
13152 + * @from: Source address, in kernel space.
13153 + * @n: Number of bytes to copy.
13154 + *
13155 + * Context: User context only. This function may sleep.
13156 + *
13157 + * Copy data from kernel space to user space.
13158 + *
13159 + * Returns number of bytes that could not be copied.
13160 + * On success, this will be zero.
13161 + */
13162 +static inline unsigned long __must_check
13163 +copy_to_user(void __user *to, const void *from, unsigned long n)
13164 +{
13165 + int sz = __compiletime_object_size(from);
13166 +
13167 + if (unlikely(sz != -1 && sz < n))
13168 + copy_to_user_overflow();
13169 + else if (access_ok(VERIFY_WRITE, to, n))
13170 + n = __copy_to_user(to, from, n);
13171 + return n;
13172 +}
13173 +
13174 +/**
13175 + * copy_from_user: - Copy a block of data from user space.
13176 + * @to: Destination address, in kernel space.
13177 + * @from: Source address, in user space.
13178 + * @n: Number of bytes to copy.
13179 + *
13180 + * Context: User context only. This function may sleep.
13181 + *
13182 + * Copy data from user space to kernel space.
13183 + *
13184 + * Returns number of bytes that could not be copied.
13185 + * On success, this will be zero.
13186 + *
13187 + * If some data could not be copied, this function will pad the copied
13188 + * data to the requested size using zero bytes.
13189 + */
13190 +static inline unsigned long __must_check
13191 +copy_from_user(void *to, const void __user *from, unsigned long n)
13192 {
13193 int sz = __compiletime_object_size(to);
13194
13195 - if (likely(sz == -1 || sz >= n))
13196 - n = _copy_from_user(to, from, n);
13197 - else
13198 + if (unlikely(sz != -1 && sz < n))
13199 copy_from_user_overflow();
13200 -
13201 + else if (access_ok(VERIFY_READ, from, n))
13202 + n = __copy_from_user(to, from, n);
13203 + else if ((long)n > 0) {
13204 + if (!__builtin_constant_p(n))
13205 + check_object_size(to, n, false);
13206 + memset(to, 0, n);
13207 + }
13208 return n;
13209 }
13210
13211 @@ -235,7 +302,7 @@ long __must_check __strncpy_from_user(char *dst,
13212 #define strlen_user(str) strnlen_user(str, LONG_MAX)
13213
13214 long strnlen_user(const char __user *str, long n);
13215 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
13216 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
13217 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
13218 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
13219
13220 #endif /* _ASM_X86_UACCESS_32_H */
13221 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
13222 index 1c66d30..bf1a2cc 100644
13223 --- a/arch/x86/include/asm/uaccess_64.h
13224 +++ b/arch/x86/include/asm/uaccess_64.h
13225 @@ -10,6 +10,9 @@
13226 #include <asm/alternative.h>
13227 #include <asm/cpufeature.h>
13228 #include <asm/page.h>
13229 +#include <asm/pgtable.h>
13230 +
13231 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
13232
13233 /*
13234 * Copy To/From Userspace
13235 @@ -17,12 +20,14 @@
13236
13237 /* Handles exceptions in both to and from, but doesn't do access_ok */
13238 __must_check unsigned long
13239 -copy_user_generic_string(void *to, const void *from, unsigned len);
13240 +copy_user_generic_string(void *to, const void *from, unsigned long len) __size_overflow(3);
13241 __must_check unsigned long
13242 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
13243 +copy_user_generic_unrolled(void *to, const void *from, unsigned long len) __size_overflow(3);
13244
13245 static __always_inline __must_check unsigned long
13246 -copy_user_generic(void *to, const void *from, unsigned len)
13247 +copy_user_generic(void *to, const void *from, unsigned long len) __size_overflow(3);
13248 +static __always_inline __must_check unsigned long
13249 +copy_user_generic(void *to, const void *from, unsigned long len)
13250 {
13251 unsigned ret;
13252
13253 @@ -32,142 +37,226 @@ copy_user_generic(void *to, const void *from, unsigned len)
13254 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
13255 "=d" (len)),
13256 "1" (to), "2" (from), "3" (len)
13257 - : "memory", "rcx", "r8", "r9", "r10", "r11");
13258 + : "memory", "rcx", "r8", "r9", "r11");
13259 return ret;
13260 }
13261
13262 +static __always_inline __must_check unsigned long
13263 +__copy_to_user(void __user *to, const void *from, unsigned long len) __size_overflow(3);
13264 +static __always_inline __must_check unsigned long
13265 +__copy_from_user(void *to, const void __user *from, unsigned long len) __size_overflow(3);
13266 __must_check unsigned long
13267 -_copy_to_user(void __user *to, const void *from, unsigned len);
13268 -__must_check unsigned long
13269 -_copy_from_user(void *to, const void __user *from, unsigned len);
13270 -__must_check unsigned long
13271 -copy_in_user(void __user *to, const void __user *from, unsigned len);
13272 +copy_in_user(void __user *to, const void __user *from, unsigned long len) __size_overflow(3);
13273
13274 static inline unsigned long __must_check copy_from_user(void *to,
13275 const void __user *from,
13276 unsigned long n)
13277 {
13278 - int sz = __compiletime_object_size(to);
13279 -
13280 might_fault();
13281 - if (likely(sz == -1 || sz >= n))
13282 - n = _copy_from_user(to, from, n);
13283 -#ifdef CONFIG_DEBUG_VM
13284 - else
13285 - WARN(1, "Buffer overflow detected!\n");
13286 -#endif
13287 +
13288 + if (access_ok(VERIFY_READ, from, n))
13289 + n = __copy_from_user(to, from, n);
13290 + else if (n < INT_MAX) {
13291 + if (!__builtin_constant_p(n))
13292 + check_object_size(to, n, false);
13293 + memset(to, 0, n);
13294 + }
13295 return n;
13296 }
13297
13298 static __always_inline __must_check
13299 -int copy_to_user(void __user *dst, const void *src, unsigned size)
13300 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
13301 {
13302 might_fault();
13303
13304 - return _copy_to_user(dst, src, size);
13305 + if (access_ok(VERIFY_WRITE, dst, size))
13306 + size = __copy_to_user(dst, src, size);
13307 + return size;
13308 }
13309
13310 static __always_inline __must_check
13311 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
13312 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
13313 {
13314 - int ret = 0;
13315 + int sz = __compiletime_object_size(dst);
13316 + unsigned ret = 0;
13317
13318 might_fault();
13319 - if (!__builtin_constant_p(size))
13320 - return copy_user_generic(dst, (__force void *)src, size);
13321 +
13322 + if (size > INT_MAX)
13323 + return size;
13324 +
13325 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13326 + if (!__access_ok(VERIFY_READ, src, size))
13327 + return size;
13328 +#endif
13329 +
13330 + if (unlikely(sz != -1 && sz < size)) {
13331 +#ifdef CONFIG_DEBUG_VM
13332 + WARN(1, "Buffer overflow detected!\n");
13333 +#endif
13334 + return size;
13335 + }
13336 +
13337 + if (!__builtin_constant_p(size)) {
13338 + check_object_size(dst, size, false);
13339 +
13340 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13341 + if ((unsigned long)src < PAX_USER_SHADOW_BASE)
13342 + src += PAX_USER_SHADOW_BASE;
13343 +#endif
13344 +
13345 + return copy_user_generic(dst, (__force_kernel const void *)src, size);
13346 + }
13347 switch (size) {
13348 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
13349 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
13350 ret, "b", "b", "=q", 1);
13351 return ret;
13352 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
13353 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
13354 ret, "w", "w", "=r", 2);
13355 return ret;
13356 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
13357 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
13358 ret, "l", "k", "=r", 4);
13359 return ret;
13360 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
13361 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
13362 ret, "q", "", "=r", 8);
13363 return ret;
13364 case 10:
13365 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
13366 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
13367 ret, "q", "", "=r", 10);
13368 if (unlikely(ret))
13369 return ret;
13370 __get_user_asm(*(u16 *)(8 + (char *)dst),
13371 - (u16 __user *)(8 + (char __user *)src),
13372 + (const u16 __user *)(8 + (const char __user *)src),
13373 ret, "w", "w", "=r", 2);
13374 return ret;
13375 case 16:
13376 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
13377 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
13378 ret, "q", "", "=r", 16);
13379 if (unlikely(ret))
13380 return ret;
13381 __get_user_asm(*(u64 *)(8 + (char *)dst),
13382 - (u64 __user *)(8 + (char __user *)src),
13383 + (const u64 __user *)(8 + (const char __user *)src),
13384 ret, "q", "", "=r", 8);
13385 return ret;
13386 default:
13387 - return copy_user_generic(dst, (__force void *)src, size);
13388 +
13389 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13390 + if ((unsigned long)src < PAX_USER_SHADOW_BASE)
13391 + src += PAX_USER_SHADOW_BASE;
13392 +#endif
13393 +
13394 + return copy_user_generic(dst, (__force_kernel const void *)src, size);
13395 }
13396 }
13397
13398 static __always_inline __must_check
13399 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
13400 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
13401 {
13402 - int ret = 0;
13403 + int sz = __compiletime_object_size(src);
13404 + unsigned ret = 0;
13405
13406 might_fault();
13407 - if (!__builtin_constant_p(size))
13408 - return copy_user_generic((__force void *)dst, src, size);
13409 +
13410 + if (size > INT_MAX)
13411 + return size;
13412 +
13413 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13414 + if (!__access_ok(VERIFY_WRITE, dst, size))
13415 + return size;
13416 +#endif
13417 +
13418 + if (unlikely(sz != -1 && sz < size)) {
13419 +#ifdef CONFIG_DEBUG_VM
13420 + WARN(1, "Buffer overflow detected!\n");
13421 +#endif
13422 + return size;
13423 + }
13424 +
13425 + if (!__builtin_constant_p(size)) {
13426 + check_object_size(src, size, true);
13427 +
13428 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13429 + if ((unsigned long)dst < PAX_USER_SHADOW_BASE)
13430 + dst += PAX_USER_SHADOW_BASE;
13431 +#endif
13432 +
13433 + return copy_user_generic((__force_kernel void *)dst, src, size);
13434 + }
13435 switch (size) {
13436 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
13437 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
13438 ret, "b", "b", "iq", 1);
13439 return ret;
13440 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
13441 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
13442 ret, "w", "w", "ir", 2);
13443 return ret;
13444 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
13445 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
13446 ret, "l", "k", "ir", 4);
13447 return ret;
13448 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
13449 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
13450 ret, "q", "", "er", 8);
13451 return ret;
13452 case 10:
13453 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
13454 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
13455 ret, "q", "", "er", 10);
13456 if (unlikely(ret))
13457 return ret;
13458 asm("":::"memory");
13459 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
13460 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
13461 ret, "w", "w", "ir", 2);
13462 return ret;
13463 case 16:
13464 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
13465 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
13466 ret, "q", "", "er", 16);
13467 if (unlikely(ret))
13468 return ret;
13469 asm("":::"memory");
13470 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
13471 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
13472 ret, "q", "", "er", 8);
13473 return ret;
13474 default:
13475 - return copy_user_generic((__force void *)dst, src, size);
13476 +
13477 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13478 + if ((unsigned long)dst < PAX_USER_SHADOW_BASE)
13479 + dst += PAX_USER_SHADOW_BASE;
13480 +#endif
13481 +
13482 + return copy_user_generic((__force_kernel void *)dst, src, size);
13483 }
13484 }
13485
13486 static __always_inline __must_check
13487 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
13488 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
13489 {
13490 - int ret = 0;
13491 + unsigned ret = 0;
13492
13493 might_fault();
13494 - if (!__builtin_constant_p(size))
13495 - return copy_user_generic((__force void *)dst,
13496 - (__force void *)src, size);
13497 +
13498 + if (size > INT_MAX)
13499 + return size;
13500 +
13501 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13502 + if (!__access_ok(VERIFY_READ, src, size))
13503 + return size;
13504 + if (!__access_ok(VERIFY_WRITE, dst, size))
13505 + return size;
13506 +#endif
13507 +
13508 + if (!__builtin_constant_p(size)) {
13509 +
13510 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13511 + if ((unsigned long)src < PAX_USER_SHADOW_BASE)
13512 + src += PAX_USER_SHADOW_BASE;
13513 + if ((unsigned long)dst < PAX_USER_SHADOW_BASE)
13514 + dst += PAX_USER_SHADOW_BASE;
13515 +#endif
13516 +
13517 + return copy_user_generic((__force_kernel void *)dst,
13518 + (__force_kernel const void *)src, size);
13519 + }
13520 switch (size) {
13521 case 1: {
13522 u8 tmp;
13523 - __get_user_asm(tmp, (u8 __user *)src,
13524 + __get_user_asm(tmp, (const u8 __user *)src,
13525 ret, "b", "b", "=q", 1);
13526 if (likely(!ret))
13527 __put_user_asm(tmp, (u8 __user *)dst,
13528 @@ -176,7 +265,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
13529 }
13530 case 2: {
13531 u16 tmp;
13532 - __get_user_asm(tmp, (u16 __user *)src,
13533 + __get_user_asm(tmp, (const u16 __user *)src,
13534 ret, "w", "w", "=r", 2);
13535 if (likely(!ret))
13536 __put_user_asm(tmp, (u16 __user *)dst,
13537 @@ -186,7 +275,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
13538
13539 case 4: {
13540 u32 tmp;
13541 - __get_user_asm(tmp, (u32 __user *)src,
13542 + __get_user_asm(tmp, (const u32 __user *)src,
13543 ret, "l", "k", "=r", 4);
13544 if (likely(!ret))
13545 __put_user_asm(tmp, (u32 __user *)dst,
13546 @@ -195,7 +284,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
13547 }
13548 case 8: {
13549 u64 tmp;
13550 - __get_user_asm(tmp, (u64 __user *)src,
13551 + __get_user_asm(tmp, (const u64 __user *)src,
13552 ret, "q", "", "=r", 8);
13553 if (likely(!ret))
13554 __put_user_asm(tmp, (u64 __user *)dst,
13555 @@ -203,8 +292,16 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
13556 return ret;
13557 }
13558 default:
13559 - return copy_user_generic((__force void *)dst,
13560 - (__force void *)src, size);
13561 +
13562 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13563 + if ((unsigned long)src < PAX_USER_SHADOW_BASE)
13564 + src += PAX_USER_SHADOW_BASE;
13565 + if ((unsigned long)dst < PAX_USER_SHADOW_BASE)
13566 + dst += PAX_USER_SHADOW_BASE;
13567 +#endif
13568 +
13569 + return copy_user_generic((__force_kernel void *)dst,
13570 + (__force_kernel const void *)src, size);
13571 }
13572 }
13573
13574 @@ -215,39 +312,76 @@ __strncpy_from_user(char *dst, const char __user *src, long count);
13575 __must_check long strnlen_user(const char __user *str, long n);
13576 __must_check long __strnlen_user(const char __user *str, long n);
13577 __must_check long strlen_user(const char __user *str);
13578 -__must_check unsigned long clear_user(void __user *mem, unsigned long len);
13579 -__must_check unsigned long __clear_user(void __user *mem, unsigned long len);
13580 +__must_check unsigned long clear_user(void __user *mem, unsigned long len) __size_overflow(2);
13581 +__must_check unsigned long __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
13582
13583 static __must_check __always_inline int
13584 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
13585 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
13586 {
13587 - return copy_user_generic(dst, (__force const void *)src, size);
13588 + if (size > INT_MAX)
13589 + return size;
13590 +
13591 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13592 + if (!__access_ok(VERIFY_READ, src, size))
13593 + return size;
13594 +
13595 + if ((unsigned long)src < PAX_USER_SHADOW_BASE)
13596 + src += PAX_USER_SHADOW_BASE;
13597 +#endif
13598 +
13599 + return copy_user_generic(dst, (__force_kernel const void *)src, size);
13600 }
13601
13602 -static __must_check __always_inline int
13603 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
13604 +static __must_check __always_inline unsigned long
13605 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
13606 {
13607 - return copy_user_generic((__force void *)dst, src, size);
13608 + if (size > INT_MAX)
13609 + return size;
13610 +
13611 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13612 + if (!__access_ok(VERIFY_WRITE, dst, size))
13613 + return size;
13614 +
13615 + if ((unsigned long)dst < PAX_USER_SHADOW_BASE)
13616 + dst += PAX_USER_SHADOW_BASE;
13617 +#endif
13618 +
13619 + return copy_user_generic((__force_kernel void *)dst, src, size);
13620 }
13621
13622 -extern long __copy_user_nocache(void *dst, const void __user *src,
13623 - unsigned size, int zerorest);
13624 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
13625 + unsigned long size, int zerorest) __size_overflow(3);
13626
13627 -static inline int
13628 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
13629 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
13630 {
13631 might_sleep();
13632 +
13633 + if (size > INT_MAX)
13634 + return size;
13635 +
13636 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13637 + if (!__access_ok(VERIFY_READ, src, size))
13638 + return size;
13639 +#endif
13640 +
13641 return __copy_user_nocache(dst, src, size, 1);
13642 }
13643
13644 -static inline int
13645 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
13646 - unsigned size)
13647 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
13648 + unsigned long size)
13649 {
13650 + if (size > INT_MAX)
13651 + return size;
13652 +
13653 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13654 + if (!__access_ok(VERIFY_READ, src, size))
13655 + return size;
13656 +#endif
13657 +
13658 return __copy_user_nocache(dst, src, size, 0);
13659 }
13660
13661 -unsigned long
13662 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
13663 +extern unsigned long
13664 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
13665
13666 #endif /* _ASM_X86_UACCESS_64_H */
13667 diff --git a/arch/x86/include/asm/vdso.h b/arch/x86/include/asm/vdso.h
13668 index bb05228..d763d5b 100644
13669 --- a/arch/x86/include/asm/vdso.h
13670 +++ b/arch/x86/include/asm/vdso.h
13671 @@ -11,7 +11,7 @@ extern const char VDSO32_PRELINK[];
13672 #define VDSO32_SYMBOL(base, name) \
13673 ({ \
13674 extern const char VDSO32_##name[]; \
13675 - (void *)(VDSO32_##name - VDSO32_PRELINK + (unsigned long)(base)); \
13676 + (void __user *)(VDSO32_##name - VDSO32_PRELINK + (unsigned long)(base)); \
13677 })
13678 #endif
13679
13680 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
13681 index a609c39..7a68dc7 100644
13682 --- a/arch/x86/include/asm/x86_init.h
13683 +++ b/arch/x86/include/asm/x86_init.h
13684 @@ -29,7 +29,7 @@ struct x86_init_mpparse {
13685 void (*mpc_oem_bus_info)(struct mpc_bus *m, char *name);
13686 void (*find_smp_config)(void);
13687 void (*get_smp_config)(unsigned int early);
13688 -};
13689 +} __no_const;
13690
13691 /**
13692 * struct x86_init_resources - platform specific resource related ops
13693 @@ -43,7 +43,7 @@ struct x86_init_resources {
13694 void (*probe_roms)(void);
13695 void (*reserve_resources)(void);
13696 char *(*memory_setup)(void);
13697 -};
13698 +} __no_const;
13699
13700 /**
13701 * struct x86_init_irqs - platform specific interrupt setup
13702 @@ -56,7 +56,7 @@ struct x86_init_irqs {
13703 void (*pre_vector_init)(void);
13704 void (*intr_init)(void);
13705 void (*trap_init)(void);
13706 -};
13707 +} __no_const;
13708
13709 /**
13710 * struct x86_init_oem - oem platform specific customizing functions
13711 @@ -66,7 +66,7 @@ struct x86_init_irqs {
13712 struct x86_init_oem {
13713 void (*arch_setup)(void);
13714 void (*banner)(void);
13715 -};
13716 +} __no_const;
13717
13718 /**
13719 * struct x86_init_mapping - platform specific initial kernel pagetable setup
13720 @@ -77,7 +77,7 @@ struct x86_init_oem {
13721 */
13722 struct x86_init_mapping {
13723 void (*pagetable_reserve)(u64 start, u64 end);
13724 -};
13725 +} __no_const;
13726
13727 /**
13728 * struct x86_init_paging - platform specific paging functions
13729 @@ -87,7 +87,7 @@ struct x86_init_mapping {
13730 struct x86_init_paging {
13731 void (*pagetable_setup_start)(pgd_t *base);
13732 void (*pagetable_setup_done)(pgd_t *base);
13733 -};
13734 +} __no_const;
13735
13736 /**
13737 * struct x86_init_timers - platform specific timer setup
13738 @@ -102,7 +102,7 @@ struct x86_init_timers {
13739 void (*tsc_pre_init)(void);
13740 void (*timer_init)(void);
13741 void (*wallclock_init)(void);
13742 -};
13743 +} __no_const;
13744
13745 /**
13746 * struct x86_init_iommu - platform specific iommu setup
13747 @@ -110,7 +110,7 @@ struct x86_init_timers {
13748 */
13749 struct x86_init_iommu {
13750 int (*iommu_init)(void);
13751 -};
13752 +} __no_const;
13753
13754 /**
13755 * struct x86_init_pci - platform specific pci init functions
13756 @@ -124,7 +124,7 @@ struct x86_init_pci {
13757 int (*init)(void);
13758 void (*init_irq)(void);
13759 void (*fixup_irqs)(void);
13760 -};
13761 +} __no_const;
13762
13763 /**
13764 * struct x86_init_ops - functions for platform specific setup
13765 @@ -140,7 +140,7 @@ struct x86_init_ops {
13766 struct x86_init_timers timers;
13767 struct x86_init_iommu iommu;
13768 struct x86_init_pci pci;
13769 -};
13770 +} __no_const;
13771
13772 /**
13773 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
13774 @@ -149,7 +149,7 @@ struct x86_init_ops {
13775 struct x86_cpuinit_ops {
13776 void (*setup_percpu_clockev)(void);
13777 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
13778 -};
13779 +} __no_const;
13780
13781 /**
13782 * struct x86_platform_ops - platform specific runtime functions
13783 @@ -171,7 +171,7 @@ struct x86_platform_ops {
13784 void (*nmi_init)(void);
13785 unsigned char (*get_nmi_reason)(void);
13786 int (*i8042_detect)(void);
13787 -};
13788 +} __no_const;
13789
13790 struct pci_dev;
13791
13792 @@ -180,7 +180,7 @@ struct x86_msi_ops {
13793 void (*teardown_msi_irq)(unsigned int irq);
13794 void (*teardown_msi_irqs)(struct pci_dev *dev);
13795 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
13796 -};
13797 +} __no_const;
13798
13799 extern struct x86_init_ops x86_init;
13800 extern struct x86_cpuinit_ops x86_cpuinit;
13801 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
13802 index c6ce245..ffbdab7 100644
13803 --- a/arch/x86/include/asm/xsave.h
13804 +++ b/arch/x86/include/asm/xsave.h
13805 @@ -65,6 +65,11 @@ static inline int xsave_user(struct xsave_struct __user *buf)
13806 {
13807 int err;
13808
13809 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
13810 + if ((unsigned long)buf < PAX_USER_SHADOW_BASE)
13811 + buf = (struct xsave_struct __user *)((void __user*)buf + PAX_USER_SHADOW_BASE);
13812 +#endif
13813 +
13814 /*
13815 * Clear the xsave header first, so that reserved fields are
13816 * initialized to zero.
13817 @@ -96,10 +101,15 @@ static inline int xsave_user(struct xsave_struct __user *buf)
13818 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
13819 {
13820 int err;
13821 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
13822 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
13823 u32 lmask = mask;
13824 u32 hmask = mask >> 32;
13825
13826 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
13827 + if ((unsigned long)xstate < PAX_USER_SHADOW_BASE)
13828 + xstate = (struct xsave_struct *)((void *)xstate + PAX_USER_SHADOW_BASE);
13829 +#endif
13830 +
13831 __asm__ __volatile__("1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
13832 "2:\n"
13833 ".section .fixup,\"ax\"\n"
13834 diff --git a/arch/x86/kernel/acpi/realmode/Makefile b/arch/x86/kernel/acpi/realmode/Makefile
13835 index 6a564ac..9b1340c 100644
13836 --- a/arch/x86/kernel/acpi/realmode/Makefile
13837 +++ b/arch/x86/kernel/acpi/realmode/Makefile
13838 @@ -41,6 +41,9 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -g -Os -D_SETUP -D_WAKEUP -D__KERNEL__ \
13839 $(call cc-option, -fno-stack-protector) \
13840 $(call cc-option, -mpreferred-stack-boundary=2)
13841 KBUILD_CFLAGS += $(call cc-option, -m32)
13842 +ifdef CONSTIFY_PLUGIN
13843 +KBUILD_CFLAGS += $(CONSTIFY_PLUGIN) -fplugin-arg-constify_plugin-no-constify
13844 +endif
13845 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
13846 GCOV_PROFILE := n
13847
13848 diff --git a/arch/x86/kernel/acpi/realmode/wakeup.S b/arch/x86/kernel/acpi/realmode/wakeup.S
13849 index b4fd836..4358fe3 100644
13850 --- a/arch/x86/kernel/acpi/realmode/wakeup.S
13851 +++ b/arch/x86/kernel/acpi/realmode/wakeup.S
13852 @@ -108,6 +108,9 @@ wakeup_code:
13853 /* Do any other stuff... */
13854
13855 #ifndef CONFIG_64BIT
13856 + /* Recheck NX bit overrides (64bit path does this in trampoline */
13857 + call verify_cpu
13858 +
13859 /* This could also be done in C code... */
13860 movl pmode_cr3, %eax
13861 movl %eax, %cr3
13862 @@ -131,6 +134,7 @@ wakeup_code:
13863 movl pmode_cr0, %eax
13864 movl %eax, %cr0
13865 jmp pmode_return
13866 +# include "../../verify_cpu.S"
13867 #else
13868 pushw $0
13869 pushw trampoline_segment
13870 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
13871 index 103b6ab..2004d0a 100644
13872 --- a/arch/x86/kernel/acpi/sleep.c
13873 +++ b/arch/x86/kernel/acpi/sleep.c
13874 @@ -94,8 +94,12 @@ int acpi_suspend_lowlevel(void)
13875 header->trampoline_segment = trampoline_address() >> 4;
13876 #ifdef CONFIG_SMP
13877 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
13878 +
13879 + pax_open_kernel();
13880 early_gdt_descr.address =
13881 (unsigned long)get_cpu_gdt_table(smp_processor_id());
13882 + pax_close_kernel();
13883 +
13884 initial_gs = per_cpu_offset(smp_processor_id());
13885 #endif
13886 initial_code = (unsigned long)wakeup_long64;
13887 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
13888 index 13ab720..95d5442 100644
13889 --- a/arch/x86/kernel/acpi/wakeup_32.S
13890 +++ b/arch/x86/kernel/acpi/wakeup_32.S
13891 @@ -30,13 +30,11 @@ wakeup_pmode_return:
13892 # and restore the stack ... but you need gdt for this to work
13893 movl saved_context_esp, %esp
13894
13895 - movl %cs:saved_magic, %eax
13896 - cmpl $0x12345678, %eax
13897 + cmpl $0x12345678, saved_magic
13898 jne bogus_magic
13899
13900 # jump to place where we left off
13901 - movl saved_eip, %eax
13902 - jmp *%eax
13903 + jmp *(saved_eip)
13904
13905 bogus_magic:
13906 jmp bogus_magic
13907 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
13908 index 1f84794..e23f862 100644
13909 --- a/arch/x86/kernel/alternative.c
13910 +++ b/arch/x86/kernel/alternative.c
13911 @@ -276,6 +276,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
13912 */
13913 for (a = start; a < end; a++) {
13914 instr = (u8 *)&a->instr_offset + a->instr_offset;
13915 +
13916 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
13917 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
13918 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
13919 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
13920 +#endif
13921 +
13922 replacement = (u8 *)&a->repl_offset + a->repl_offset;
13923 BUG_ON(a->replacementlen > a->instrlen);
13924 BUG_ON(a->instrlen > sizeof(insnbuf));
13925 @@ -307,10 +314,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
13926 for (poff = start; poff < end; poff++) {
13927 u8 *ptr = (u8 *)poff + *poff;
13928
13929 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
13930 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
13931 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
13932 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
13933 +#endif
13934 +
13935 if (!*poff || ptr < text || ptr >= text_end)
13936 continue;
13937 /* turn DS segment override prefix into lock prefix */
13938 - if (*ptr == 0x3e)
13939 + if (*ktla_ktva(ptr) == 0x3e)
13940 text_poke(ptr, ((unsigned char []){0xf0}), 1);
13941 };
13942 mutex_unlock(&text_mutex);
13943 @@ -328,10 +341,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
13944 for (poff = start; poff < end; poff++) {
13945 u8 *ptr = (u8 *)poff + *poff;
13946
13947 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
13948 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
13949 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
13950 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
13951 +#endif
13952 +
13953 if (!*poff || ptr < text || ptr >= text_end)
13954 continue;
13955 /* turn lock prefix into DS segment override prefix */
13956 - if (*ptr == 0xf0)
13957 + if (*ktla_ktva(ptr) == 0xf0)
13958 text_poke(ptr, ((unsigned char []){0x3E}), 1);
13959 };
13960 mutex_unlock(&text_mutex);
13961 @@ -500,7 +519,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
13962
13963 BUG_ON(p->len > MAX_PATCH_LEN);
13964 /* prep the buffer with the original instructions */
13965 - memcpy(insnbuf, p->instr, p->len);
13966 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
13967 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
13968 (unsigned long)p->instr, p->len);
13969
13970 @@ -568,7 +587,7 @@ void __init alternative_instructions(void)
13971 if (smp_alt_once)
13972 free_init_pages("SMP alternatives",
13973 (unsigned long)__smp_locks,
13974 - (unsigned long)__smp_locks_end);
13975 + PAGE_ALIGN((unsigned long)__smp_locks_end));
13976
13977 restart_nmi();
13978 }
13979 @@ -585,13 +604,17 @@ void __init alternative_instructions(void)
13980 * instructions. And on the local CPU you need to be protected again NMI or MCE
13981 * handlers seeing an inconsistent instruction while you patch.
13982 */
13983 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
13984 +void *__kprobes text_poke_early(void *addr, const void *opcode,
13985 size_t len)
13986 {
13987 unsigned long flags;
13988 local_irq_save(flags);
13989 - memcpy(addr, opcode, len);
13990 +
13991 + pax_open_kernel();
13992 + memcpy(ktla_ktva(addr), opcode, len);
13993 sync_core();
13994 + pax_close_kernel();
13995 +
13996 local_irq_restore(flags);
13997 /* Could also do a CLFLUSH here to speed up CPU recovery; but
13998 that causes hangs on some VIA CPUs. */
13999 @@ -613,36 +636,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
14000 */
14001 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
14002 {
14003 - unsigned long flags;
14004 - char *vaddr;
14005 + unsigned char *vaddr = ktla_ktva(addr);
14006 struct page *pages[2];
14007 - int i;
14008 + size_t i;
14009
14010 if (!core_kernel_text((unsigned long)addr)) {
14011 - pages[0] = vmalloc_to_page(addr);
14012 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
14013 + pages[0] = vmalloc_to_page(vaddr);
14014 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
14015 } else {
14016 - pages[0] = virt_to_page(addr);
14017 + pages[0] = virt_to_page(vaddr);
14018 WARN_ON(!PageReserved(pages[0]));
14019 - pages[1] = virt_to_page(addr + PAGE_SIZE);
14020 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
14021 }
14022 BUG_ON(!pages[0]);
14023 - local_irq_save(flags);
14024 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
14025 - if (pages[1])
14026 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
14027 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
14028 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
14029 - clear_fixmap(FIX_TEXT_POKE0);
14030 - if (pages[1])
14031 - clear_fixmap(FIX_TEXT_POKE1);
14032 - local_flush_tlb();
14033 - sync_core();
14034 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
14035 - that causes hangs on some VIA CPUs. */
14036 + text_poke_early(addr, opcode, len);
14037 for (i = 0; i < len; i++)
14038 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
14039 - local_irq_restore(flags);
14040 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
14041 return addr;
14042 }
14043
14044 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
14045 index 5b3f88e..61232b4 100644
14046 --- a/arch/x86/kernel/apic/apic.c
14047 +++ b/arch/x86/kernel/apic/apic.c
14048 @@ -184,7 +184,7 @@ int first_system_vector = 0xfe;
14049 /*
14050 * Debug level, exported for io_apic.c
14051 */
14052 -unsigned int apic_verbosity;
14053 +int apic_verbosity;
14054
14055 int pic_mode;
14056
14057 @@ -1912,7 +1912,7 @@ void smp_error_interrupt(struct pt_regs *regs)
14058 apic_write(APIC_ESR, 0);
14059 v1 = apic_read(APIC_ESR);
14060 ack_APIC_irq();
14061 - atomic_inc(&irq_err_count);
14062 + atomic_inc_unchecked(&irq_err_count);
14063
14064 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
14065 smp_processor_id(), v0 , v1);
14066 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
14067 index fb07275..e06bb59 100644
14068 --- a/arch/x86/kernel/apic/io_apic.c
14069 +++ b/arch/x86/kernel/apic/io_apic.c
14070 @@ -1096,7 +1096,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
14071 }
14072 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
14073
14074 -void lock_vector_lock(void)
14075 +void lock_vector_lock(void) __acquires(vector_lock)
14076 {
14077 /* Used to the online set of cpus does not change
14078 * during assign_irq_vector.
14079 @@ -1104,7 +1104,7 @@ void lock_vector_lock(void)
14080 raw_spin_lock(&vector_lock);
14081 }
14082
14083 -void unlock_vector_lock(void)
14084 +void unlock_vector_lock(void) __releases(vector_lock)
14085 {
14086 raw_spin_unlock(&vector_lock);
14087 }
14088 @@ -2510,7 +2510,7 @@ static void ack_apic_edge(struct irq_data *data)
14089 ack_APIC_irq();
14090 }
14091
14092 -atomic_t irq_mis_count;
14093 +atomic_unchecked_t irq_mis_count;
14094
14095 static void ack_apic_level(struct irq_data *data)
14096 {
14097 @@ -2576,7 +2576,7 @@ static void ack_apic_level(struct irq_data *data)
14098 * at the cpu.
14099 */
14100 if (!(v & (1 << (i & 0x1f)))) {
14101 - atomic_inc(&irq_mis_count);
14102 + atomic_inc_unchecked(&irq_mis_count);
14103
14104 eoi_ioapic_irq(irq, cfg);
14105 }
14106 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
14107 index f76623c..aab694f 100644
14108 --- a/arch/x86/kernel/apm_32.c
14109 +++ b/arch/x86/kernel/apm_32.c
14110 @@ -411,7 +411,7 @@ static DEFINE_MUTEX(apm_mutex);
14111 * This is for buggy BIOS's that refer to (real mode) segment 0x40
14112 * even though they are called in protected mode.
14113 */
14114 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
14115 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
14116 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
14117
14118 static const char driver_version[] = "1.16ac"; /* no spaces */
14119 @@ -589,7 +589,10 @@ static long __apm_bios_call(void *_call)
14120 BUG_ON(cpu != 0);
14121 gdt = get_cpu_gdt_table(cpu);
14122 save_desc_40 = gdt[0x40 / 8];
14123 +
14124 + pax_open_kernel();
14125 gdt[0x40 / 8] = bad_bios_desc;
14126 + pax_close_kernel();
14127
14128 apm_irq_save(flags);
14129 APM_DO_SAVE_SEGS;
14130 @@ -598,7 +601,11 @@ static long __apm_bios_call(void *_call)
14131 &call->esi);
14132 APM_DO_RESTORE_SEGS;
14133 apm_irq_restore(flags);
14134 +
14135 + pax_open_kernel();
14136 gdt[0x40 / 8] = save_desc_40;
14137 + pax_close_kernel();
14138 +
14139 put_cpu();
14140
14141 return call->eax & 0xff;
14142 @@ -665,7 +672,10 @@ static long __apm_bios_call_simple(void *_call)
14143 BUG_ON(cpu != 0);
14144 gdt = get_cpu_gdt_table(cpu);
14145 save_desc_40 = gdt[0x40 / 8];
14146 +
14147 + pax_open_kernel();
14148 gdt[0x40 / 8] = bad_bios_desc;
14149 + pax_close_kernel();
14150
14151 apm_irq_save(flags);
14152 APM_DO_SAVE_SEGS;
14153 @@ -673,7 +683,11 @@ static long __apm_bios_call_simple(void *_call)
14154 &call->eax);
14155 APM_DO_RESTORE_SEGS;
14156 apm_irq_restore(flags);
14157 +
14158 + pax_open_kernel();
14159 gdt[0x40 / 8] = save_desc_40;
14160 + pax_close_kernel();
14161 +
14162 put_cpu();
14163 return error;
14164 }
14165 @@ -2347,12 +2361,15 @@ static int __init apm_init(void)
14166 * code to that CPU.
14167 */
14168 gdt = get_cpu_gdt_table(0);
14169 +
14170 + pax_open_kernel();
14171 set_desc_base(&gdt[APM_CS >> 3],
14172 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
14173 set_desc_base(&gdt[APM_CS_16 >> 3],
14174 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
14175 set_desc_base(&gdt[APM_DS >> 3],
14176 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
14177 + pax_close_kernel();
14178
14179 proc_create("apm", 0, NULL, &apm_file_ops);
14180
14181 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
14182 index 68de2dc..1f3c720 100644
14183 --- a/arch/x86/kernel/asm-offsets.c
14184 +++ b/arch/x86/kernel/asm-offsets.c
14185 @@ -33,6 +33,8 @@ void common(void) {
14186 OFFSET(TI_status, thread_info, status);
14187 OFFSET(TI_addr_limit, thread_info, addr_limit);
14188 OFFSET(TI_preempt_count, thread_info, preempt_count);
14189 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
14190 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
14191
14192 BLANK();
14193 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
14194 @@ -53,8 +55,26 @@ void common(void) {
14195 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
14196 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
14197 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
14198 +
14199 +#ifdef CONFIG_PAX_KERNEXEC
14200 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
14201 #endif
14202
14203 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14204 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
14205 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
14206 +#ifdef CONFIG_X86_64
14207 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
14208 +#endif
14209 +#endif
14210 +
14211 +#endif
14212 +
14213 + BLANK();
14214 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
14215 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
14216 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
14217 +
14218 #ifdef CONFIG_XEN
14219 BLANK();
14220 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
14221 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
14222 index 834e897..dacddc8 100644
14223 --- a/arch/x86/kernel/asm-offsets_64.c
14224 +++ b/arch/x86/kernel/asm-offsets_64.c
14225 @@ -70,6 +70,7 @@ int main(void)
14226 BLANK();
14227 #undef ENTRY
14228
14229 + DEFINE(TSS_size, sizeof(struct tss_struct));
14230 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
14231 BLANK();
14232
14233 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
14234 index 25f24dc..4094a7f 100644
14235 --- a/arch/x86/kernel/cpu/Makefile
14236 +++ b/arch/x86/kernel/cpu/Makefile
14237 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
14238 CFLAGS_REMOVE_perf_event.o = -pg
14239 endif
14240
14241 -# Make sure load_percpu_segment has no stackprotector
14242 -nostackp := $(call cc-option, -fno-stack-protector)
14243 -CFLAGS_common.o := $(nostackp)
14244 -
14245 obj-y := intel_cacheinfo.o scattered.o topology.o
14246 obj-y += proc.o capflags.o powerflags.o common.o
14247 obj-y += vmware.o hypervisor.o sched.o mshyperv.o
14248 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
14249 index 80ab83d..0a7b34e 100644
14250 --- a/arch/x86/kernel/cpu/amd.c
14251 +++ b/arch/x86/kernel/cpu/amd.c
14252 @@ -670,7 +670,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
14253 unsigned int size)
14254 {
14255 /* AMD errata T13 (order #21922) */
14256 - if ((c->x86 == 6)) {
14257 + if (c->x86 == 6) {
14258 /* Duron Rev A0 */
14259 if (c->x86_model == 3 && c->x86_mask == 0)
14260 size = 64;
14261 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
14262 index 1a810e4..9fa8201 100644
14263 --- a/arch/x86/kernel/cpu/common.c
14264 +++ b/arch/x86/kernel/cpu/common.c
14265 @@ -84,60 +84,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
14266
14267 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
14268
14269 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
14270 -#ifdef CONFIG_X86_64
14271 - /*
14272 - * We need valid kernel segments for data and code in long mode too
14273 - * IRET will check the segment types kkeil 2000/10/28
14274 - * Also sysret mandates a special GDT layout
14275 - *
14276 - * TLS descriptors are currently at a different place compared to i386.
14277 - * Hopefully nobody expects them at a fixed place (Wine?)
14278 - */
14279 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
14280 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
14281 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
14282 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
14283 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
14284 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
14285 -#else
14286 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
14287 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
14288 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
14289 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
14290 - /*
14291 - * Segments used for calling PnP BIOS have byte granularity.
14292 - * They code segments and data segments have fixed 64k limits,
14293 - * the transfer segment sizes are set at run time.
14294 - */
14295 - /* 32-bit code */
14296 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
14297 - /* 16-bit code */
14298 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
14299 - /* 16-bit data */
14300 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
14301 - /* 16-bit data */
14302 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
14303 - /* 16-bit data */
14304 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
14305 - /*
14306 - * The APM segments have byte granularity and their bases
14307 - * are set at run time. All have 64k limits.
14308 - */
14309 - /* 32-bit code */
14310 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
14311 - /* 16-bit code */
14312 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
14313 - /* data */
14314 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
14315 -
14316 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
14317 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
14318 - GDT_STACK_CANARY_INIT
14319 -#endif
14320 -} };
14321 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
14322 -
14323 static int __init x86_xsave_setup(char *s)
14324 {
14325 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
14326 @@ -372,7 +318,7 @@ void switch_to_new_gdt(int cpu)
14327 {
14328 struct desc_ptr gdt_descr;
14329
14330 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
14331 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
14332 gdt_descr.size = GDT_SIZE - 1;
14333 load_gdt(&gdt_descr);
14334 /* Reload the per-cpu base */
14335 @@ -839,6 +785,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
14336 /* Filter out anything that depends on CPUID levels we don't have */
14337 filter_cpuid_features(c, true);
14338
14339 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
14340 + setup_clear_cpu_cap(X86_FEATURE_SEP);
14341 +#endif
14342 +
14343 /* If the model name is still unset, do table lookup. */
14344 if (!c->x86_model_id[0]) {
14345 const char *p;
14346 @@ -1019,10 +969,12 @@ static __init int setup_disablecpuid(char *arg)
14347 }
14348 __setup("clearcpuid=", setup_disablecpuid);
14349
14350 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
14351 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
14352 +
14353 #ifdef CONFIG_X86_64
14354 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
14355 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
14356 - (unsigned long) nmi_idt_table };
14357 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
14358
14359 DEFINE_PER_CPU_FIRST(union irq_stack_union,
14360 irq_stack_union) __aligned(PAGE_SIZE);
14361 @@ -1036,7 +988,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
14362 EXPORT_PER_CPU_SYMBOL(current_task);
14363
14364 DEFINE_PER_CPU(unsigned long, kernel_stack) =
14365 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
14366 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
14367 EXPORT_PER_CPU_SYMBOL(kernel_stack);
14368
14369 DEFINE_PER_CPU(char *, irq_stack_ptr) =
14370 @@ -1126,7 +1078,7 @@ struct pt_regs * __cpuinit idle_regs(struct pt_regs *regs)
14371 {
14372 memset(regs, 0, sizeof(struct pt_regs));
14373 regs->fs = __KERNEL_PERCPU;
14374 - regs->gs = __KERNEL_STACK_CANARY;
14375 + savesegment(gs, regs->gs);
14376
14377 return regs;
14378 }
14379 @@ -1181,7 +1133,7 @@ void __cpuinit cpu_init(void)
14380 int i;
14381
14382 cpu = stack_smp_processor_id();
14383 - t = &per_cpu(init_tss, cpu);
14384 + t = init_tss + cpu;
14385 oist = &per_cpu(orig_ist, cpu);
14386
14387 #ifdef CONFIG_NUMA
14388 @@ -1207,7 +1159,7 @@ void __cpuinit cpu_init(void)
14389 switch_to_new_gdt(cpu);
14390 loadsegment(fs, 0);
14391
14392 - load_idt((const struct desc_ptr *)&idt_descr);
14393 + load_idt(&idt_descr);
14394
14395 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
14396 syscall_init();
14397 @@ -1216,7 +1168,6 @@ void __cpuinit cpu_init(void)
14398 wrmsrl(MSR_KERNEL_GS_BASE, 0);
14399 barrier();
14400
14401 - x86_configure_nx();
14402 if (cpu != 0)
14403 enable_x2apic();
14404
14405 @@ -1272,7 +1223,7 @@ void __cpuinit cpu_init(void)
14406 {
14407 int cpu = smp_processor_id();
14408 struct task_struct *curr = current;
14409 - struct tss_struct *t = &per_cpu(init_tss, cpu);
14410 + struct tss_struct *t = init_tss + cpu;
14411 struct thread_struct *thread = &curr->thread;
14412
14413 if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) {
14414 diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
14415 index 3e6ff6c..54b4992 100644
14416 --- a/arch/x86/kernel/cpu/intel.c
14417 +++ b/arch/x86/kernel/cpu/intel.c
14418 @@ -174,7 +174,7 @@ static void __cpuinit trap_init_f00f_bug(void)
14419 * Update the IDT descriptor and reload the IDT so that
14420 * it uses the read-only mapped virtual address.
14421 */
14422 - idt_descr.address = fix_to_virt(FIX_F00F_IDT);
14423 + idt_descr.address = (struct desc_struct *)fix_to_virt(FIX_F00F_IDT);
14424 load_idt(&idt_descr);
14425 }
14426 #endif
14427 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
14428 index 5a11ae2..a1a1c8a 100644
14429 --- a/arch/x86/kernel/cpu/mcheck/mce.c
14430 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
14431 @@ -42,6 +42,7 @@
14432 #include <asm/processor.h>
14433 #include <asm/mce.h>
14434 #include <asm/msr.h>
14435 +#include <asm/local.h>
14436
14437 #include "mce-internal.h"
14438
14439 @@ -250,7 +251,7 @@ static void print_mce(struct mce *m)
14440 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
14441 m->cs, m->ip);
14442
14443 - if (m->cs == __KERNEL_CS)
14444 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
14445 print_symbol("{%s}", m->ip);
14446 pr_cont("\n");
14447 }
14448 @@ -283,10 +284,10 @@ static void print_mce(struct mce *m)
14449
14450 #define PANIC_TIMEOUT 5 /* 5 seconds */
14451
14452 -static atomic_t mce_paniced;
14453 +static atomic_unchecked_t mce_paniced;
14454
14455 static int fake_panic;
14456 -static atomic_t mce_fake_paniced;
14457 +static atomic_unchecked_t mce_fake_paniced;
14458
14459 /* Panic in progress. Enable interrupts and wait for final IPI */
14460 static void wait_for_panic(void)
14461 @@ -310,7 +311,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
14462 /*
14463 * Make sure only one CPU runs in machine check panic
14464 */
14465 - if (atomic_inc_return(&mce_paniced) > 1)
14466 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
14467 wait_for_panic();
14468 barrier();
14469
14470 @@ -318,7 +319,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
14471 console_verbose();
14472 } else {
14473 /* Don't log too much for fake panic */
14474 - if (atomic_inc_return(&mce_fake_paniced) > 1)
14475 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
14476 return;
14477 }
14478 /* First print corrected ones that are still unlogged */
14479 @@ -658,7 +659,7 @@ static int mce_timed_out(u64 *t)
14480 * might have been modified by someone else.
14481 */
14482 rmb();
14483 - if (atomic_read(&mce_paniced))
14484 + if (atomic_read_unchecked(&mce_paniced))
14485 wait_for_panic();
14486 if (!monarch_timeout)
14487 goto out;
14488 @@ -1446,7 +1447,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
14489 }
14490
14491 /* Call the installed machine check handler for this CPU setup. */
14492 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
14493 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
14494 unexpected_machine_check;
14495
14496 /*
14497 @@ -1469,7 +1470,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
14498 return;
14499 }
14500
14501 + pax_open_kernel();
14502 machine_check_vector = do_machine_check;
14503 + pax_close_kernel();
14504
14505 __mcheck_cpu_init_generic();
14506 __mcheck_cpu_init_vendor(c);
14507 @@ -1483,7 +1486,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
14508 */
14509
14510 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
14511 -static int mce_chrdev_open_count; /* #times opened */
14512 +static local_t mce_chrdev_open_count; /* #times opened */
14513 static int mce_chrdev_open_exclu; /* already open exclusive? */
14514
14515 static int mce_chrdev_open(struct inode *inode, struct file *file)
14516 @@ -1491,7 +1494,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
14517 spin_lock(&mce_chrdev_state_lock);
14518
14519 if (mce_chrdev_open_exclu ||
14520 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
14521 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
14522 spin_unlock(&mce_chrdev_state_lock);
14523
14524 return -EBUSY;
14525 @@ -1499,7 +1502,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
14526
14527 if (file->f_flags & O_EXCL)
14528 mce_chrdev_open_exclu = 1;
14529 - mce_chrdev_open_count++;
14530 + local_inc(&mce_chrdev_open_count);
14531
14532 spin_unlock(&mce_chrdev_state_lock);
14533
14534 @@ -1510,7 +1513,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
14535 {
14536 spin_lock(&mce_chrdev_state_lock);
14537
14538 - mce_chrdev_open_count--;
14539 + local_dec(&mce_chrdev_open_count);
14540 mce_chrdev_open_exclu = 0;
14541
14542 spin_unlock(&mce_chrdev_state_lock);
14543 @@ -2229,7 +2232,7 @@ struct dentry *mce_get_debugfs_dir(void)
14544 static void mce_reset(void)
14545 {
14546 cpu_missing = 0;
14547 - atomic_set(&mce_fake_paniced, 0);
14548 + atomic_set_unchecked(&mce_fake_paniced, 0);
14549 atomic_set(&mce_executing, 0);
14550 atomic_set(&mce_callin, 0);
14551 atomic_set(&global_nwo, 0);
14552 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
14553 index 5c0e653..0882b0a 100644
14554 --- a/arch/x86/kernel/cpu/mcheck/p5.c
14555 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
14556 @@ -12,6 +12,7 @@
14557 #include <asm/system.h>
14558 #include <asm/mce.h>
14559 #include <asm/msr.h>
14560 +#include <asm/pgtable.h>
14561
14562 /* By default disabled */
14563 int mce_p5_enabled __read_mostly;
14564 @@ -50,7 +51,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
14565 if (!cpu_has(c, X86_FEATURE_MCE))
14566 return;
14567
14568 + pax_open_kernel();
14569 machine_check_vector = pentium_machine_check;
14570 + pax_close_kernel();
14571 /* Make sure the vector pointer is visible before we enable MCEs: */
14572 wmb();
14573
14574 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
14575 index 54060f5..c1a7577 100644
14576 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
14577 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
14578 @@ -11,6 +11,7 @@
14579 #include <asm/system.h>
14580 #include <asm/mce.h>
14581 #include <asm/msr.h>
14582 +#include <asm/pgtable.h>
14583
14584 /* Machine check handler for WinChip C6: */
14585 static void winchip_machine_check(struct pt_regs *regs, long error_code)
14586 @@ -24,7 +25,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
14587 {
14588 u32 lo, hi;
14589
14590 + pax_open_kernel();
14591 machine_check_vector = winchip_machine_check;
14592 + pax_close_kernel();
14593 /* Make sure the vector pointer is visible before we enable MCEs: */
14594 wmb();
14595
14596 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
14597 index 6b96110..0da73eb 100644
14598 --- a/arch/x86/kernel/cpu/mtrr/main.c
14599 +++ b/arch/x86/kernel/cpu/mtrr/main.c
14600 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
14601 u64 size_or_mask, size_and_mask;
14602 static bool mtrr_aps_delayed_init;
14603
14604 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
14605 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
14606
14607 const struct mtrr_ops *mtrr_if;
14608
14609 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
14610 index df5e41f..816c719 100644
14611 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
14612 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
14613 @@ -25,7 +25,7 @@ struct mtrr_ops {
14614 int (*validate_add_page)(unsigned long base, unsigned long size,
14615 unsigned int type);
14616 int (*have_wrcomb)(void);
14617 -};
14618 +} __do_const;
14619
14620 extern int generic_get_free_region(unsigned long base, unsigned long size,
14621 int replace_reg);
14622 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
14623 index 5adce10..99284ec 100644
14624 --- a/arch/x86/kernel/cpu/perf_event.c
14625 +++ b/arch/x86/kernel/cpu/perf_event.c
14626 @@ -1665,7 +1665,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
14627 break;
14628
14629 perf_callchain_store(entry, frame.return_address);
14630 - fp = frame.next_frame;
14631 + fp = (const void __force_user *)frame.next_frame;
14632 }
14633 }
14634
14635 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
14636 index 13ad899..f642b9a 100644
14637 --- a/arch/x86/kernel/crash.c
14638 +++ b/arch/x86/kernel/crash.c
14639 @@ -36,10 +36,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
14640 {
14641 #ifdef CONFIG_X86_32
14642 struct pt_regs fixed_regs;
14643 -#endif
14644
14645 -#ifdef CONFIG_X86_32
14646 - if (!user_mode_vm(regs)) {
14647 + if (!user_mode(regs)) {
14648 crash_fixup_ss_esp(&fixed_regs, regs);
14649 regs = &fixed_regs;
14650 }
14651 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
14652 index 37250fe..bf2ec74 100644
14653 --- a/arch/x86/kernel/doublefault_32.c
14654 +++ b/arch/x86/kernel/doublefault_32.c
14655 @@ -11,7 +11,7 @@
14656
14657 #define DOUBLEFAULT_STACKSIZE (1024)
14658 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
14659 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
14660 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
14661
14662 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
14663
14664 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
14665 unsigned long gdt, tss;
14666
14667 store_gdt(&gdt_desc);
14668 - gdt = gdt_desc.address;
14669 + gdt = (unsigned long)gdt_desc.address;
14670
14671 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
14672
14673 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
14674 /* 0x2 bit is always set */
14675 .flags = X86_EFLAGS_SF | 0x2,
14676 .sp = STACK_START,
14677 - .es = __USER_DS,
14678 + .es = __KERNEL_DS,
14679 .cs = __KERNEL_CS,
14680 .ss = __KERNEL_DS,
14681 - .ds = __USER_DS,
14682 + .ds = __KERNEL_DS,
14683 .fs = __KERNEL_PERCPU,
14684
14685 .__cr3 = __pa_nodebug(swapper_pg_dir),
14686 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
14687 index 4025fe4..d8451c6 100644
14688 --- a/arch/x86/kernel/dumpstack.c
14689 +++ b/arch/x86/kernel/dumpstack.c
14690 @@ -2,6 +2,9 @@
14691 * Copyright (C) 1991, 1992 Linus Torvalds
14692 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
14693 */
14694 +#ifdef CONFIG_GRKERNSEC_HIDESYM
14695 +#define __INCLUDED_BY_HIDESYM 1
14696 +#endif
14697 #include <linux/kallsyms.h>
14698 #include <linux/kprobes.h>
14699 #include <linux/uaccess.h>
14700 @@ -35,9 +38,8 @@ void printk_address(unsigned long address, int reliable)
14701 static void
14702 print_ftrace_graph_addr(unsigned long addr, void *data,
14703 const struct stacktrace_ops *ops,
14704 - struct thread_info *tinfo, int *graph)
14705 + struct task_struct *task, int *graph)
14706 {
14707 - struct task_struct *task = tinfo->task;
14708 unsigned long ret_addr;
14709 int index = task->curr_ret_stack;
14710
14711 @@ -58,7 +60,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
14712 static inline void
14713 print_ftrace_graph_addr(unsigned long addr, void *data,
14714 const struct stacktrace_ops *ops,
14715 - struct thread_info *tinfo, int *graph)
14716 + struct task_struct *task, int *graph)
14717 { }
14718 #endif
14719
14720 @@ -69,10 +71,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
14721 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
14722 */
14723
14724 -static inline int valid_stack_ptr(struct thread_info *tinfo,
14725 - void *p, unsigned int size, void *end)
14726 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
14727 {
14728 - void *t = tinfo;
14729 if (end) {
14730 if (p < end && p >= (end-THREAD_SIZE))
14731 return 1;
14732 @@ -83,14 +83,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
14733 }
14734
14735 unsigned long
14736 -print_context_stack(struct thread_info *tinfo,
14737 +print_context_stack(struct task_struct *task, void *stack_start,
14738 unsigned long *stack, unsigned long bp,
14739 const struct stacktrace_ops *ops, void *data,
14740 unsigned long *end, int *graph)
14741 {
14742 struct stack_frame *frame = (struct stack_frame *)bp;
14743
14744 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
14745 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
14746 unsigned long addr;
14747
14748 addr = *stack;
14749 @@ -102,7 +102,7 @@ print_context_stack(struct thread_info *tinfo,
14750 } else {
14751 ops->address(data, addr, 0);
14752 }
14753 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
14754 + print_ftrace_graph_addr(addr, data, ops, task, graph);
14755 }
14756 stack++;
14757 }
14758 @@ -111,7 +111,7 @@ print_context_stack(struct thread_info *tinfo,
14759 EXPORT_SYMBOL_GPL(print_context_stack);
14760
14761 unsigned long
14762 -print_context_stack_bp(struct thread_info *tinfo,
14763 +print_context_stack_bp(struct task_struct *task, void *stack_start,
14764 unsigned long *stack, unsigned long bp,
14765 const struct stacktrace_ops *ops, void *data,
14766 unsigned long *end, int *graph)
14767 @@ -119,7 +119,7 @@ print_context_stack_bp(struct thread_info *tinfo,
14768 struct stack_frame *frame = (struct stack_frame *)bp;
14769 unsigned long *ret_addr = &frame->return_address;
14770
14771 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
14772 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
14773 unsigned long addr = *ret_addr;
14774
14775 if (!__kernel_text_address(addr))
14776 @@ -128,7 +128,7 @@ print_context_stack_bp(struct thread_info *tinfo,
14777 ops->address(data, addr, 1);
14778 frame = frame->next_frame;
14779 ret_addr = &frame->return_address;
14780 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
14781 + print_ftrace_graph_addr(addr, data, ops, task, graph);
14782 }
14783
14784 return (unsigned long)frame;
14785 @@ -186,7 +186,7 @@ void dump_stack(void)
14786
14787 bp = stack_frame(current, NULL);
14788 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
14789 - current->pid, current->comm, print_tainted(),
14790 + task_pid_nr(current), current->comm, print_tainted(),
14791 init_utsname()->release,
14792 (int)strcspn(init_utsname()->version, " "),
14793 init_utsname()->version);
14794 @@ -222,6 +222,8 @@ unsigned __kprobes long oops_begin(void)
14795 }
14796 EXPORT_SYMBOL_GPL(oops_begin);
14797
14798 +extern void gr_handle_kernel_exploit(void);
14799 +
14800 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
14801 {
14802 if (regs && kexec_should_crash(current))
14803 @@ -243,7 +245,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
14804 panic("Fatal exception in interrupt");
14805 if (panic_on_oops)
14806 panic("Fatal exception");
14807 - do_exit(signr);
14808 +
14809 + gr_handle_kernel_exploit();
14810 +
14811 + do_group_exit(signr);
14812 }
14813
14814 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
14815 @@ -270,7 +275,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
14816
14817 show_registers(regs);
14818 #ifdef CONFIG_X86_32
14819 - if (user_mode_vm(regs)) {
14820 + if (user_mode(regs)) {
14821 sp = regs->sp;
14822 ss = regs->ss & 0xffff;
14823 } else {
14824 @@ -298,7 +303,7 @@ void die(const char *str, struct pt_regs *regs, long err)
14825 unsigned long flags = oops_begin();
14826 int sig = SIGSEGV;
14827
14828 - if (!user_mode_vm(regs))
14829 + if (!user_mode(regs))
14830 report_bug(regs->ip, regs);
14831
14832 if (__die(str, regs, err))
14833 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
14834 index c99f9ed..2a15d80 100644
14835 --- a/arch/x86/kernel/dumpstack_32.c
14836 +++ b/arch/x86/kernel/dumpstack_32.c
14837 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
14838 bp = stack_frame(task, regs);
14839
14840 for (;;) {
14841 - struct thread_info *context;
14842 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
14843
14844 - context = (struct thread_info *)
14845 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
14846 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
14847 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
14848
14849 - stack = (unsigned long *)context->previous_esp;
14850 - if (!stack)
14851 + if (stack_start == task_stack_page(task))
14852 break;
14853 + stack = *(unsigned long **)stack_start;
14854 if (ops->stack(data, "IRQ") < 0)
14855 break;
14856 touch_nmi_watchdog();
14857 @@ -96,21 +94,22 @@ void show_registers(struct pt_regs *regs)
14858 * When in-kernel, we also print out the stack and code at the
14859 * time of the fault..
14860 */
14861 - if (!user_mode_vm(regs)) {
14862 + if (!user_mode(regs)) {
14863 unsigned int code_prologue = code_bytes * 43 / 64;
14864 unsigned int code_len = code_bytes;
14865 unsigned char c;
14866 u8 *ip;
14867 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(smp_processor_id())[(0xffff & regs->cs) >> 3]);
14868
14869 printk(KERN_EMERG "Stack:\n");
14870 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
14871
14872 printk(KERN_EMERG "Code: ");
14873
14874 - ip = (u8 *)regs->ip - code_prologue;
14875 + ip = (u8 *)regs->ip - code_prologue + cs_base;
14876 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
14877 /* try starting at IP */
14878 - ip = (u8 *)regs->ip;
14879 + ip = (u8 *)regs->ip + cs_base;
14880 code_len = code_len - code_prologue + 1;
14881 }
14882 for (i = 0; i < code_len; i++, ip++) {
14883 @@ -119,7 +118,7 @@ void show_registers(struct pt_regs *regs)
14884 printk(KERN_CONT " Bad EIP value.");
14885 break;
14886 }
14887 - if (ip == (u8 *)regs->ip)
14888 + if (ip == (u8 *)regs->ip + cs_base)
14889 printk(KERN_CONT "<%02x> ", c);
14890 else
14891 printk(KERN_CONT "%02x ", c);
14892 @@ -132,6 +131,7 @@ int is_valid_bugaddr(unsigned long ip)
14893 {
14894 unsigned short ud2;
14895
14896 + ip = ktla_ktva(ip);
14897 if (ip < PAGE_OFFSET)
14898 return 0;
14899 if (probe_kernel_address((unsigned short *)ip, ud2))
14900 @@ -139,3 +139,15 @@ int is_valid_bugaddr(unsigned long ip)
14901
14902 return ud2 == 0x0b0f;
14903 }
14904 +
14905 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
14906 +void pax_check_alloca(unsigned long size)
14907 +{
14908 + unsigned long sp = (unsigned long)&sp, stack_left;
14909 +
14910 + /* all kernel stacks are of the same size */
14911 + stack_left = sp & (THREAD_SIZE - 1);
14912 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
14913 +}
14914 +EXPORT_SYMBOL(pax_check_alloca);
14915 +#endif
14916 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
14917 index 17107bd..9623722 100644
14918 --- a/arch/x86/kernel/dumpstack_64.c
14919 +++ b/arch/x86/kernel/dumpstack_64.c
14920 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
14921 unsigned long *irq_stack_end =
14922 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
14923 unsigned used = 0;
14924 - struct thread_info *tinfo;
14925 int graph = 0;
14926 unsigned long dummy;
14927 + void *stack_start;
14928
14929 if (!task)
14930 task = current;
14931 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
14932 * current stack address. If the stacks consist of nested
14933 * exceptions
14934 */
14935 - tinfo = task_thread_info(task);
14936 for (;;) {
14937 char *id;
14938 unsigned long *estack_end;
14939 +
14940 estack_end = in_exception_stack(cpu, (unsigned long)stack,
14941 &used, &id);
14942
14943 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
14944 if (ops->stack(data, id) < 0)
14945 break;
14946
14947 - bp = ops->walk_stack(tinfo, stack, bp, ops,
14948 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
14949 data, estack_end, &graph);
14950 ops->stack(data, "<EOE>");
14951 /*
14952 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
14953 * second-to-last pointer (index -2 to end) in the
14954 * exception stack:
14955 */
14956 + if ((u16)estack_end[-1] != __KERNEL_DS)
14957 + goto out;
14958 stack = (unsigned long *) estack_end[-2];
14959 continue;
14960 }
14961 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
14962 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
14963 if (ops->stack(data, "IRQ") < 0)
14964 break;
14965 - bp = ops->walk_stack(tinfo, stack, bp,
14966 + bp = ops->walk_stack(task, irq_stack, stack, bp,
14967 ops, data, irq_stack_end, &graph);
14968 /*
14969 * We link to the next stack (which would be
14970 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
14971 /*
14972 * This handles the process stack:
14973 */
14974 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
14975 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
14976 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
14977 +out:
14978 put_cpu();
14979 }
14980 EXPORT_SYMBOL(dump_trace);
14981 @@ -305,3 +309,50 @@ int is_valid_bugaddr(unsigned long ip)
14982
14983 return ud2 == 0x0b0f;
14984 }
14985 +
14986 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
14987 +void pax_check_alloca(unsigned long size)
14988 +{
14989 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
14990 + unsigned cpu, used;
14991 + char *id;
14992 +
14993 + /* check the process stack first */
14994 + stack_start = (unsigned long)task_stack_page(current);
14995 + stack_end = stack_start + THREAD_SIZE;
14996 + if (likely(stack_start <= sp && sp < stack_end)) {
14997 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
14998 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
14999 + return;
15000 + }
15001 +
15002 + cpu = get_cpu();
15003 +
15004 + /* check the irq stacks */
15005 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
15006 + stack_start = stack_end - IRQ_STACK_SIZE;
15007 + if (stack_start <= sp && sp < stack_end) {
15008 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
15009 + put_cpu();
15010 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
15011 + return;
15012 + }
15013 +
15014 + /* check the exception stacks */
15015 + used = 0;
15016 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
15017 + stack_start = stack_end - EXCEPTION_STKSZ;
15018 + if (stack_end && stack_start <= sp && sp < stack_end) {
15019 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
15020 + put_cpu();
15021 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
15022 + return;
15023 + }
15024 +
15025 + put_cpu();
15026 +
15027 + /* unknown stack */
15028 + BUG();
15029 +}
15030 +EXPORT_SYMBOL(pax_check_alloca);
15031 +#endif
15032 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
15033 index 9b9f18b..9fcaa04 100644
15034 --- a/arch/x86/kernel/early_printk.c
15035 +++ b/arch/x86/kernel/early_printk.c
15036 @@ -7,6 +7,7 @@
15037 #include <linux/pci_regs.h>
15038 #include <linux/pci_ids.h>
15039 #include <linux/errno.h>
15040 +#include <linux/sched.h>
15041 #include <asm/io.h>
15042 #include <asm/processor.h>
15043 #include <asm/fcntl.h>
15044 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
15045 index 7b784f4..db6b628 100644
15046 --- a/arch/x86/kernel/entry_32.S
15047 +++ b/arch/x86/kernel/entry_32.S
15048 @@ -179,13 +179,146 @@
15049 /*CFI_REL_OFFSET gs, PT_GS*/
15050 .endm
15051 .macro SET_KERNEL_GS reg
15052 +
15053 +#ifdef CONFIG_CC_STACKPROTECTOR
15054 movl $(__KERNEL_STACK_CANARY), \reg
15055 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
15056 + movl $(__USER_DS), \reg
15057 +#else
15058 + xorl \reg, \reg
15059 +#endif
15060 +
15061 movl \reg, %gs
15062 .endm
15063
15064 #endif /* CONFIG_X86_32_LAZY_GS */
15065
15066 -.macro SAVE_ALL
15067 +.macro pax_enter_kernel
15068 +#ifdef CONFIG_PAX_KERNEXEC
15069 + call pax_enter_kernel
15070 +#endif
15071 +.endm
15072 +
15073 +.macro pax_exit_kernel
15074 +#ifdef CONFIG_PAX_KERNEXEC
15075 + call pax_exit_kernel
15076 +#endif
15077 +.endm
15078 +
15079 +#ifdef CONFIG_PAX_KERNEXEC
15080 +ENTRY(pax_enter_kernel)
15081 +#ifdef CONFIG_PARAVIRT
15082 + pushl %eax
15083 + pushl %ecx
15084 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
15085 + mov %eax, %esi
15086 +#else
15087 + mov %cr0, %esi
15088 +#endif
15089 + bts $16, %esi
15090 + jnc 1f
15091 + mov %cs, %esi
15092 + cmp $__KERNEL_CS, %esi
15093 + jz 3f
15094 + ljmp $__KERNEL_CS, $3f
15095 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
15096 +2:
15097 +#ifdef CONFIG_PARAVIRT
15098 + mov %esi, %eax
15099 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
15100 +#else
15101 + mov %esi, %cr0
15102 +#endif
15103 +3:
15104 +#ifdef CONFIG_PARAVIRT
15105 + popl %ecx
15106 + popl %eax
15107 +#endif
15108 + ret
15109 +ENDPROC(pax_enter_kernel)
15110 +
15111 +ENTRY(pax_exit_kernel)
15112 +#ifdef CONFIG_PARAVIRT
15113 + pushl %eax
15114 + pushl %ecx
15115 +#endif
15116 + mov %cs, %esi
15117 + cmp $__KERNEXEC_KERNEL_CS, %esi
15118 + jnz 2f
15119 +#ifdef CONFIG_PARAVIRT
15120 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
15121 + mov %eax, %esi
15122 +#else
15123 + mov %cr0, %esi
15124 +#endif
15125 + btr $16, %esi
15126 + ljmp $__KERNEL_CS, $1f
15127 +1:
15128 +#ifdef CONFIG_PARAVIRT
15129 + mov %esi, %eax
15130 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
15131 +#else
15132 + mov %esi, %cr0
15133 +#endif
15134 +2:
15135 +#ifdef CONFIG_PARAVIRT
15136 + popl %ecx
15137 + popl %eax
15138 +#endif
15139 + ret
15140 +ENDPROC(pax_exit_kernel)
15141 +#endif
15142 +
15143 +.macro pax_erase_kstack
15144 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
15145 + call pax_erase_kstack
15146 +#endif
15147 +.endm
15148 +
15149 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
15150 +/*
15151 + * ebp: thread_info
15152 + * ecx, edx: can be clobbered
15153 + */
15154 +ENTRY(pax_erase_kstack)
15155 + pushl %edi
15156 + pushl %eax
15157 +
15158 + mov TI_lowest_stack(%ebp), %edi
15159 + mov $-0xBEEF, %eax
15160 + std
15161 +
15162 +1: mov %edi, %ecx
15163 + and $THREAD_SIZE_asm - 1, %ecx
15164 + shr $2, %ecx
15165 + repne scasl
15166 + jecxz 2f
15167 +
15168 + cmp $2*16, %ecx
15169 + jc 2f
15170 +
15171 + mov $2*16, %ecx
15172 + repe scasl
15173 + jecxz 2f
15174 + jne 1b
15175 +
15176 +2: cld
15177 + mov %esp, %ecx
15178 + sub %edi, %ecx
15179 + shr $2, %ecx
15180 + rep stosl
15181 +
15182 + mov TI_task_thread_sp0(%ebp), %edi
15183 + sub $128, %edi
15184 + mov %edi, TI_lowest_stack(%ebp)
15185 +
15186 + popl %eax
15187 + popl %edi
15188 + ret
15189 +ENDPROC(pax_erase_kstack)
15190 +#endif
15191 +
15192 +.macro __SAVE_ALL _DS
15193 cld
15194 PUSH_GS
15195 pushl_cfi %fs
15196 @@ -208,7 +341,7 @@
15197 CFI_REL_OFFSET ecx, 0
15198 pushl_cfi %ebx
15199 CFI_REL_OFFSET ebx, 0
15200 - movl $(__USER_DS), %edx
15201 + movl $\_DS, %edx
15202 movl %edx, %ds
15203 movl %edx, %es
15204 movl $(__KERNEL_PERCPU), %edx
15205 @@ -216,6 +349,15 @@
15206 SET_KERNEL_GS %edx
15207 .endm
15208
15209 +.macro SAVE_ALL
15210 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
15211 + __SAVE_ALL __KERNEL_DS
15212 + pax_enter_kernel
15213 +#else
15214 + __SAVE_ALL __USER_DS
15215 +#endif
15216 +.endm
15217 +
15218 .macro RESTORE_INT_REGS
15219 popl_cfi %ebx
15220 CFI_RESTORE ebx
15221 @@ -301,7 +443,7 @@ ENTRY(ret_from_fork)
15222 popfl_cfi
15223 jmp syscall_exit
15224 CFI_ENDPROC
15225 -END(ret_from_fork)
15226 +ENDPROC(ret_from_fork)
15227
15228 /*
15229 * Interrupt exit functions should be protected against kprobes
15230 @@ -335,7 +477,15 @@ resume_userspace_sig:
15231 andl $SEGMENT_RPL_MASK, %eax
15232 #endif
15233 cmpl $USER_RPL, %eax
15234 +
15235 +#ifdef CONFIG_PAX_KERNEXEC
15236 + jae resume_userspace
15237 +
15238 + pax_exit_kernel
15239 + jmp resume_kernel
15240 +#else
15241 jb resume_kernel # not returning to v8086 or userspace
15242 +#endif
15243
15244 ENTRY(resume_userspace)
15245 LOCKDEP_SYS_EXIT
15246 @@ -347,8 +497,8 @@ ENTRY(resume_userspace)
15247 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
15248 # int/exception return?
15249 jne work_pending
15250 - jmp restore_all
15251 -END(ret_from_exception)
15252 + jmp restore_all_pax
15253 +ENDPROC(ret_from_exception)
15254
15255 #ifdef CONFIG_PREEMPT
15256 ENTRY(resume_kernel)
15257 @@ -363,7 +513,7 @@ need_resched:
15258 jz restore_all
15259 call preempt_schedule_irq
15260 jmp need_resched
15261 -END(resume_kernel)
15262 +ENDPROC(resume_kernel)
15263 #endif
15264 CFI_ENDPROC
15265 /*
15266 @@ -397,23 +547,34 @@ sysenter_past_esp:
15267 /*CFI_REL_OFFSET cs, 0*/
15268 /*
15269 * Push current_thread_info()->sysenter_return to the stack.
15270 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
15271 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
15272 */
15273 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
15274 + pushl_cfi $0
15275 CFI_REL_OFFSET eip, 0
15276
15277 pushl_cfi %eax
15278 SAVE_ALL
15279 + GET_THREAD_INFO(%ebp)
15280 + movl TI_sysenter_return(%ebp),%ebp
15281 + movl %ebp,PT_EIP(%esp)
15282 ENABLE_INTERRUPTS(CLBR_NONE)
15283
15284 /*
15285 * Load the potential sixth argument from user stack.
15286 * Careful about security.
15287 */
15288 + movl PT_OLDESP(%esp),%ebp
15289 +
15290 +#ifdef CONFIG_PAX_MEMORY_UDEREF
15291 + mov PT_OLDSS(%esp),%ds
15292 +1: movl %ds:(%ebp),%ebp
15293 + push %ss
15294 + pop %ds
15295 +#else
15296 cmpl $__PAGE_OFFSET-3,%ebp
15297 jae syscall_fault
15298 1: movl (%ebp),%ebp
15299 +#endif
15300 +
15301 movl %ebp,PT_EBP(%esp)
15302 .section __ex_table,"a"
15303 .align 4
15304 @@ -436,12 +597,24 @@ sysenter_do_call:
15305 testl $_TIF_ALLWORK_MASK, %ecx
15306 jne sysexit_audit
15307 sysenter_exit:
15308 +
15309 +#ifdef CONFIG_PAX_RANDKSTACK
15310 + pushl_cfi %eax
15311 + movl %esp, %eax
15312 + call pax_randomize_kstack
15313 + popl_cfi %eax
15314 +#endif
15315 +
15316 + pax_erase_kstack
15317 +
15318 /* if something modifies registers it must also disable sysexit */
15319 movl PT_EIP(%esp), %edx
15320 movl PT_OLDESP(%esp), %ecx
15321 xorl %ebp,%ebp
15322 TRACE_IRQS_ON
15323 1: mov PT_FS(%esp), %fs
15324 +2: mov PT_DS(%esp), %ds
15325 +3: mov PT_ES(%esp), %es
15326 PTGS_TO_GS
15327 ENABLE_INTERRUPTS_SYSEXIT
15328
15329 @@ -458,6 +631,9 @@ sysenter_audit:
15330 movl %eax,%edx /* 2nd arg: syscall number */
15331 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
15332 call __audit_syscall_entry
15333 +
15334 + pax_erase_kstack
15335 +
15336 pushl_cfi %ebx
15337 movl PT_EAX(%esp),%eax /* reload syscall number */
15338 jmp sysenter_do_call
15339 @@ -483,11 +659,17 @@ sysexit_audit:
15340
15341 CFI_ENDPROC
15342 .pushsection .fixup,"ax"
15343 -2: movl $0,PT_FS(%esp)
15344 +4: movl $0,PT_FS(%esp)
15345 + jmp 1b
15346 +5: movl $0,PT_DS(%esp)
15347 + jmp 1b
15348 +6: movl $0,PT_ES(%esp)
15349 jmp 1b
15350 .section __ex_table,"a"
15351 .align 4
15352 - .long 1b,2b
15353 + .long 1b,4b
15354 + .long 2b,5b
15355 + .long 3b,6b
15356 .popsection
15357 PTGS_TO_GS_EX
15358 ENDPROC(ia32_sysenter_target)
15359 @@ -520,6 +702,15 @@ syscall_exit:
15360 testl $_TIF_ALLWORK_MASK, %ecx # current->work
15361 jne syscall_exit_work
15362
15363 +restore_all_pax:
15364 +
15365 +#ifdef CONFIG_PAX_RANDKSTACK
15366 + movl %esp, %eax
15367 + call pax_randomize_kstack
15368 +#endif
15369 +
15370 + pax_erase_kstack
15371 +
15372 restore_all:
15373 TRACE_IRQS_IRET
15374 restore_all_notrace:
15375 @@ -579,14 +770,34 @@ ldt_ss:
15376 * compensating for the offset by changing to the ESPFIX segment with
15377 * a base address that matches for the difference.
15378 */
15379 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
15380 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
15381 mov %esp, %edx /* load kernel esp */
15382 mov PT_OLDESP(%esp), %eax /* load userspace esp */
15383 mov %dx, %ax /* eax: new kernel esp */
15384 sub %eax, %edx /* offset (low word is 0) */
15385 +#ifdef CONFIG_SMP
15386 + movl PER_CPU_VAR(cpu_number), %ebx
15387 + shll $PAGE_SHIFT_asm, %ebx
15388 + addl $cpu_gdt_table, %ebx
15389 +#else
15390 + movl $cpu_gdt_table, %ebx
15391 +#endif
15392 shr $16, %edx
15393 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
15394 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
15395 +
15396 +#ifdef CONFIG_PAX_KERNEXEC
15397 + mov %cr0, %esi
15398 + btr $16, %esi
15399 + mov %esi, %cr0
15400 +#endif
15401 +
15402 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
15403 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
15404 +
15405 +#ifdef CONFIG_PAX_KERNEXEC
15406 + bts $16, %esi
15407 + mov %esi, %cr0
15408 +#endif
15409 +
15410 pushl_cfi $__ESPFIX_SS
15411 pushl_cfi %eax /* new kernel esp */
15412 /* Disable interrupts, but do not irqtrace this section: we
15413 @@ -615,38 +826,30 @@ work_resched:
15414 movl TI_flags(%ebp), %ecx
15415 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
15416 # than syscall tracing?
15417 - jz restore_all
15418 + jz restore_all_pax
15419 testb $_TIF_NEED_RESCHED, %cl
15420 jnz work_resched
15421
15422 work_notifysig: # deal with pending signals and
15423 # notify-resume requests
15424 + movl %esp, %eax
15425 #ifdef CONFIG_VM86
15426 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
15427 - movl %esp, %eax
15428 - jne work_notifysig_v86 # returning to kernel-space or
15429 + jz 1f # returning to kernel-space or
15430 # vm86-space
15431 - TRACE_IRQS_ON
15432 - ENABLE_INTERRUPTS(CLBR_NONE)
15433 - xorl %edx, %edx
15434 - call do_notify_resume
15435 - jmp resume_userspace_sig
15436
15437 - ALIGN
15438 -work_notifysig_v86:
15439 pushl_cfi %ecx # save ti_flags for do_notify_resume
15440 call save_v86_state # %eax contains pt_regs pointer
15441 popl_cfi %ecx
15442 movl %eax, %esp
15443 -#else
15444 - movl %esp, %eax
15445 +1:
15446 #endif
15447 TRACE_IRQS_ON
15448 ENABLE_INTERRUPTS(CLBR_NONE)
15449 xorl %edx, %edx
15450 call do_notify_resume
15451 jmp resume_userspace_sig
15452 -END(work_pending)
15453 +ENDPROC(work_pending)
15454
15455 # perform syscall exit tracing
15456 ALIGN
15457 @@ -654,11 +857,14 @@ syscall_trace_entry:
15458 movl $-ENOSYS,PT_EAX(%esp)
15459 movl %esp, %eax
15460 call syscall_trace_enter
15461 +
15462 + pax_erase_kstack
15463 +
15464 /* What it returned is what we'll actually use. */
15465 cmpl $(NR_syscalls), %eax
15466 jnae syscall_call
15467 jmp syscall_exit
15468 -END(syscall_trace_entry)
15469 +ENDPROC(syscall_trace_entry)
15470
15471 # perform syscall exit tracing
15472 ALIGN
15473 @@ -671,20 +877,24 @@ syscall_exit_work:
15474 movl %esp, %eax
15475 call syscall_trace_leave
15476 jmp resume_userspace
15477 -END(syscall_exit_work)
15478 +ENDPROC(syscall_exit_work)
15479 CFI_ENDPROC
15480
15481 RING0_INT_FRAME # can't unwind into user space anyway
15482 syscall_fault:
15483 +#ifdef CONFIG_PAX_MEMORY_UDEREF
15484 + push %ss
15485 + pop %ds
15486 +#endif
15487 GET_THREAD_INFO(%ebp)
15488 movl $-EFAULT,PT_EAX(%esp)
15489 jmp resume_userspace
15490 -END(syscall_fault)
15491 +ENDPROC(syscall_fault)
15492
15493 syscall_badsys:
15494 movl $-ENOSYS,PT_EAX(%esp)
15495 jmp resume_userspace
15496 -END(syscall_badsys)
15497 +ENDPROC(syscall_badsys)
15498 CFI_ENDPROC
15499 /*
15500 * End of kprobes section
15501 @@ -756,6 +966,36 @@ ENTRY(ptregs_clone)
15502 CFI_ENDPROC
15503 ENDPROC(ptregs_clone)
15504
15505 + ALIGN;
15506 +ENTRY(kernel_execve)
15507 + CFI_STARTPROC
15508 + pushl_cfi %ebp
15509 + sub $PT_OLDSS+4,%esp
15510 + pushl_cfi %edi
15511 + pushl_cfi %ecx
15512 + pushl_cfi %eax
15513 + lea 3*4(%esp),%edi
15514 + mov $PT_OLDSS/4+1,%ecx
15515 + xorl %eax,%eax
15516 + rep stosl
15517 + popl_cfi %eax
15518 + popl_cfi %ecx
15519 + popl_cfi %edi
15520 + movl $X86_EFLAGS_IF,PT_EFLAGS(%esp)
15521 + pushl_cfi %esp
15522 + call sys_execve
15523 + add $4,%esp
15524 + CFI_ADJUST_CFA_OFFSET -4
15525 + GET_THREAD_INFO(%ebp)
15526 + test %eax,%eax
15527 + jz syscall_exit
15528 + add $PT_OLDSS+4,%esp
15529 + CFI_ADJUST_CFA_OFFSET -PT_OLDSS-4
15530 + popl_cfi %ebp
15531 + ret
15532 + CFI_ENDPROC
15533 +ENDPROC(kernel_execve)
15534 +
15535 .macro FIXUP_ESPFIX_STACK
15536 /*
15537 * Switch back for ESPFIX stack to the normal zerobased stack
15538 @@ -765,8 +1005,15 @@ ENDPROC(ptregs_clone)
15539 * normal stack and adjusts ESP with the matching offset.
15540 */
15541 /* fixup the stack */
15542 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
15543 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
15544 +#ifdef CONFIG_SMP
15545 + movl PER_CPU_VAR(cpu_number), %ebx
15546 + shll $PAGE_SHIFT_asm, %ebx
15547 + addl $cpu_gdt_table, %ebx
15548 +#else
15549 + movl $cpu_gdt_table, %ebx
15550 +#endif
15551 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
15552 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
15553 shl $16, %eax
15554 addl %esp, %eax /* the adjusted stack pointer */
15555 pushl_cfi $__KERNEL_DS
15556 @@ -819,7 +1066,7 @@ vector=vector+1
15557 .endr
15558 2: jmp common_interrupt
15559 .endr
15560 -END(irq_entries_start)
15561 +ENDPROC(irq_entries_start)
15562
15563 .previous
15564 END(interrupt)
15565 @@ -867,7 +1114,7 @@ ENTRY(coprocessor_error)
15566 pushl_cfi $do_coprocessor_error
15567 jmp error_code
15568 CFI_ENDPROC
15569 -END(coprocessor_error)
15570 +ENDPROC(coprocessor_error)
15571
15572 ENTRY(simd_coprocessor_error)
15573 RING0_INT_FRAME
15574 @@ -888,7 +1135,7 @@ ENTRY(simd_coprocessor_error)
15575 #endif
15576 jmp error_code
15577 CFI_ENDPROC
15578 -END(simd_coprocessor_error)
15579 +ENDPROC(simd_coprocessor_error)
15580
15581 ENTRY(device_not_available)
15582 RING0_INT_FRAME
15583 @@ -896,7 +1143,7 @@ ENTRY(device_not_available)
15584 pushl_cfi $do_device_not_available
15585 jmp error_code
15586 CFI_ENDPROC
15587 -END(device_not_available)
15588 +ENDPROC(device_not_available)
15589
15590 #ifdef CONFIG_PARAVIRT
15591 ENTRY(native_iret)
15592 @@ -905,12 +1152,12 @@ ENTRY(native_iret)
15593 .align 4
15594 .long native_iret, iret_exc
15595 .previous
15596 -END(native_iret)
15597 +ENDPROC(native_iret)
15598
15599 ENTRY(native_irq_enable_sysexit)
15600 sti
15601 sysexit
15602 -END(native_irq_enable_sysexit)
15603 +ENDPROC(native_irq_enable_sysexit)
15604 #endif
15605
15606 ENTRY(overflow)
15607 @@ -919,7 +1166,7 @@ ENTRY(overflow)
15608 pushl_cfi $do_overflow
15609 jmp error_code
15610 CFI_ENDPROC
15611 -END(overflow)
15612 +ENDPROC(overflow)
15613
15614 ENTRY(bounds)
15615 RING0_INT_FRAME
15616 @@ -927,7 +1174,7 @@ ENTRY(bounds)
15617 pushl_cfi $do_bounds
15618 jmp error_code
15619 CFI_ENDPROC
15620 -END(bounds)
15621 +ENDPROC(bounds)
15622
15623 ENTRY(invalid_op)
15624 RING0_INT_FRAME
15625 @@ -935,7 +1182,7 @@ ENTRY(invalid_op)
15626 pushl_cfi $do_invalid_op
15627 jmp error_code
15628 CFI_ENDPROC
15629 -END(invalid_op)
15630 +ENDPROC(invalid_op)
15631
15632 ENTRY(coprocessor_segment_overrun)
15633 RING0_INT_FRAME
15634 @@ -943,35 +1190,35 @@ ENTRY(coprocessor_segment_overrun)
15635 pushl_cfi $do_coprocessor_segment_overrun
15636 jmp error_code
15637 CFI_ENDPROC
15638 -END(coprocessor_segment_overrun)
15639 +ENDPROC(coprocessor_segment_overrun)
15640
15641 ENTRY(invalid_TSS)
15642 RING0_EC_FRAME
15643 pushl_cfi $do_invalid_TSS
15644 jmp error_code
15645 CFI_ENDPROC
15646 -END(invalid_TSS)
15647 +ENDPROC(invalid_TSS)
15648
15649 ENTRY(segment_not_present)
15650 RING0_EC_FRAME
15651 pushl_cfi $do_segment_not_present
15652 jmp error_code
15653 CFI_ENDPROC
15654 -END(segment_not_present)
15655 +ENDPROC(segment_not_present)
15656
15657 ENTRY(stack_segment)
15658 RING0_EC_FRAME
15659 pushl_cfi $do_stack_segment
15660 jmp error_code
15661 CFI_ENDPROC
15662 -END(stack_segment)
15663 +ENDPROC(stack_segment)
15664
15665 ENTRY(alignment_check)
15666 RING0_EC_FRAME
15667 pushl_cfi $do_alignment_check
15668 jmp error_code
15669 CFI_ENDPROC
15670 -END(alignment_check)
15671 +ENDPROC(alignment_check)
15672
15673 ENTRY(divide_error)
15674 RING0_INT_FRAME
15675 @@ -979,7 +1226,7 @@ ENTRY(divide_error)
15676 pushl_cfi $do_divide_error
15677 jmp error_code
15678 CFI_ENDPROC
15679 -END(divide_error)
15680 +ENDPROC(divide_error)
15681
15682 #ifdef CONFIG_X86_MCE
15683 ENTRY(machine_check)
15684 @@ -988,7 +1235,7 @@ ENTRY(machine_check)
15685 pushl_cfi machine_check_vector
15686 jmp error_code
15687 CFI_ENDPROC
15688 -END(machine_check)
15689 +ENDPROC(machine_check)
15690 #endif
15691
15692 ENTRY(spurious_interrupt_bug)
15693 @@ -997,7 +1244,7 @@ ENTRY(spurious_interrupt_bug)
15694 pushl_cfi $do_spurious_interrupt_bug
15695 jmp error_code
15696 CFI_ENDPROC
15697 -END(spurious_interrupt_bug)
15698 +ENDPROC(spurious_interrupt_bug)
15699 /*
15700 * End of kprobes section
15701 */
15702 @@ -1112,7 +1359,7 @@ BUILD_INTERRUPT3(xen_hvm_callback_vector, XEN_HVM_EVTCHN_CALLBACK,
15703
15704 ENTRY(mcount)
15705 ret
15706 -END(mcount)
15707 +ENDPROC(mcount)
15708
15709 ENTRY(ftrace_caller)
15710 cmpl $0, function_trace_stop
15711 @@ -1141,7 +1388,7 @@ ftrace_graph_call:
15712 .globl ftrace_stub
15713 ftrace_stub:
15714 ret
15715 -END(ftrace_caller)
15716 +ENDPROC(ftrace_caller)
15717
15718 #else /* ! CONFIG_DYNAMIC_FTRACE */
15719
15720 @@ -1177,7 +1424,7 @@ trace:
15721 popl %ecx
15722 popl %eax
15723 jmp ftrace_stub
15724 -END(mcount)
15725 +ENDPROC(mcount)
15726 #endif /* CONFIG_DYNAMIC_FTRACE */
15727 #endif /* CONFIG_FUNCTION_TRACER */
15728
15729 @@ -1198,7 +1445,7 @@ ENTRY(ftrace_graph_caller)
15730 popl %ecx
15731 popl %eax
15732 ret
15733 -END(ftrace_graph_caller)
15734 +ENDPROC(ftrace_graph_caller)
15735
15736 .globl return_to_handler
15737 return_to_handler:
15738 @@ -1253,15 +1500,18 @@ error_code:
15739 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
15740 REG_TO_PTGS %ecx
15741 SET_KERNEL_GS %ecx
15742 - movl $(__USER_DS), %ecx
15743 + movl $(__KERNEL_DS), %ecx
15744 movl %ecx, %ds
15745 movl %ecx, %es
15746 +
15747 + pax_enter_kernel
15748 +
15749 TRACE_IRQS_OFF
15750 movl %esp,%eax # pt_regs pointer
15751 call *%edi
15752 jmp ret_from_exception
15753 CFI_ENDPROC
15754 -END(page_fault)
15755 +ENDPROC(page_fault)
15756
15757 /*
15758 * Debug traps and NMI can happen at the one SYSENTER instruction
15759 @@ -1303,7 +1553,7 @@ debug_stack_correct:
15760 call do_debug
15761 jmp ret_from_exception
15762 CFI_ENDPROC
15763 -END(debug)
15764 +ENDPROC(debug)
15765
15766 /*
15767 * NMI is doubly nasty. It can happen _while_ we're handling
15768 @@ -1340,6 +1590,9 @@ nmi_stack_correct:
15769 xorl %edx,%edx # zero error code
15770 movl %esp,%eax # pt_regs pointer
15771 call do_nmi
15772 +
15773 + pax_exit_kernel
15774 +
15775 jmp restore_all_notrace
15776 CFI_ENDPROC
15777
15778 @@ -1376,12 +1629,15 @@ nmi_espfix_stack:
15779 FIXUP_ESPFIX_STACK # %eax == %esp
15780 xorl %edx,%edx # zero error code
15781 call do_nmi
15782 +
15783 + pax_exit_kernel
15784 +
15785 RESTORE_REGS
15786 lss 12+4(%esp), %esp # back to espfix stack
15787 CFI_ADJUST_CFA_OFFSET -24
15788 jmp irq_return
15789 CFI_ENDPROC
15790 -END(nmi)
15791 +ENDPROC(nmi)
15792
15793 ENTRY(int3)
15794 RING0_INT_FRAME
15795 @@ -1393,14 +1649,14 @@ ENTRY(int3)
15796 call do_int3
15797 jmp ret_from_exception
15798 CFI_ENDPROC
15799 -END(int3)
15800 +ENDPROC(int3)
15801
15802 ENTRY(general_protection)
15803 RING0_EC_FRAME
15804 pushl_cfi $do_general_protection
15805 jmp error_code
15806 CFI_ENDPROC
15807 -END(general_protection)
15808 +ENDPROC(general_protection)
15809
15810 #ifdef CONFIG_KVM_GUEST
15811 ENTRY(async_page_fault)
15812 @@ -1408,7 +1664,7 @@ ENTRY(async_page_fault)
15813 pushl_cfi $do_async_page_fault
15814 jmp error_code
15815 CFI_ENDPROC
15816 -END(async_page_fault)
15817 +ENDPROC(async_page_fault)
15818 #endif
15819
15820 /*
15821 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
15822 index 1333d98..b340ca2 100644
15823 --- a/arch/x86/kernel/entry_64.S
15824 +++ b/arch/x86/kernel/entry_64.S
15825 @@ -56,6 +56,8 @@
15826 #include <asm/ftrace.h>
15827 #include <asm/percpu.h>
15828 #include <linux/err.h>
15829 +#include <asm/pgtable.h>
15830 +#include <asm/alternative-asm.h>
15831
15832 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
15833 #include <linux/elf-em.h>
15834 @@ -69,8 +71,9 @@
15835 #ifdef CONFIG_FUNCTION_TRACER
15836 #ifdef CONFIG_DYNAMIC_FTRACE
15837 ENTRY(mcount)
15838 + pax_force_retaddr
15839 retq
15840 -END(mcount)
15841 +ENDPROC(mcount)
15842
15843 ENTRY(ftrace_caller)
15844 cmpl $0, function_trace_stop
15845 @@ -93,8 +96,9 @@ GLOBAL(ftrace_graph_call)
15846 #endif
15847
15848 GLOBAL(ftrace_stub)
15849 + pax_force_retaddr
15850 retq
15851 -END(ftrace_caller)
15852 +ENDPROC(ftrace_caller)
15853
15854 #else /* ! CONFIG_DYNAMIC_FTRACE */
15855 ENTRY(mcount)
15856 @@ -113,6 +117,7 @@ ENTRY(mcount)
15857 #endif
15858
15859 GLOBAL(ftrace_stub)
15860 + pax_force_retaddr
15861 retq
15862
15863 trace:
15864 @@ -122,12 +127,13 @@ trace:
15865 movq 8(%rbp), %rsi
15866 subq $MCOUNT_INSN_SIZE, %rdi
15867
15868 + pax_force_fptr ftrace_trace_function
15869 call *ftrace_trace_function
15870
15871 MCOUNT_RESTORE_FRAME
15872
15873 jmp ftrace_stub
15874 -END(mcount)
15875 +ENDPROC(mcount)
15876 #endif /* CONFIG_DYNAMIC_FTRACE */
15877 #endif /* CONFIG_FUNCTION_TRACER */
15878
15879 @@ -147,8 +153,9 @@ ENTRY(ftrace_graph_caller)
15880
15881 MCOUNT_RESTORE_FRAME
15882
15883 + pax_force_retaddr
15884 retq
15885 -END(ftrace_graph_caller)
15886 +ENDPROC(ftrace_graph_caller)
15887
15888 GLOBAL(return_to_handler)
15889 subq $24, %rsp
15890 @@ -164,6 +171,7 @@ GLOBAL(return_to_handler)
15891 movq 8(%rsp), %rdx
15892 movq (%rsp), %rax
15893 addq $24, %rsp
15894 + pax_force_fptr %rdi
15895 jmp *%rdi
15896 #endif
15897
15898 @@ -179,6 +187,282 @@ ENTRY(native_usergs_sysret64)
15899 ENDPROC(native_usergs_sysret64)
15900 #endif /* CONFIG_PARAVIRT */
15901
15902 + .macro ljmpq sel, off
15903 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
15904 + .byte 0x48; ljmp *1234f(%rip)
15905 + .pushsection .rodata
15906 + .align 16
15907 + 1234: .quad \off; .word \sel
15908 + .popsection
15909 +#else
15910 + pushq $\sel
15911 + pushq $\off
15912 + lretq
15913 +#endif
15914 + .endm
15915 +
15916 + .macro pax_enter_kernel
15917 + pax_set_fptr_mask
15918 +#ifdef CONFIG_PAX_KERNEXEC
15919 + call pax_enter_kernel
15920 +#endif
15921 + .endm
15922 +
15923 + .macro pax_exit_kernel
15924 +#ifdef CONFIG_PAX_KERNEXEC
15925 + call pax_exit_kernel
15926 +#endif
15927 + .endm
15928 +
15929 +#ifdef CONFIG_PAX_KERNEXEC
15930 +ENTRY(pax_enter_kernel)
15931 + pushq %rdi
15932 +
15933 +#ifdef CONFIG_PARAVIRT
15934 + PV_SAVE_REGS(CLBR_RDI)
15935 +#endif
15936 +
15937 + GET_CR0_INTO_RDI
15938 + bts $16,%rdi
15939 + jnc 3f
15940 + mov %cs,%edi
15941 + cmp $__KERNEL_CS,%edi
15942 + jnz 2f
15943 +1:
15944 +
15945 +#ifdef CONFIG_PARAVIRT
15946 + PV_RESTORE_REGS(CLBR_RDI)
15947 +#endif
15948 +
15949 + popq %rdi
15950 + pax_force_retaddr
15951 + retq
15952 +
15953 +2: ljmpq __KERNEL_CS,1f
15954 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
15955 +4: SET_RDI_INTO_CR0
15956 + jmp 1b
15957 +ENDPROC(pax_enter_kernel)
15958 +
15959 +ENTRY(pax_exit_kernel)
15960 + pushq %rdi
15961 +
15962 +#ifdef CONFIG_PARAVIRT
15963 + PV_SAVE_REGS(CLBR_RDI)
15964 +#endif
15965 +
15966 + mov %cs,%rdi
15967 + cmp $__KERNEXEC_KERNEL_CS,%edi
15968 + jz 2f
15969 +1:
15970 +
15971 +#ifdef CONFIG_PARAVIRT
15972 + PV_RESTORE_REGS(CLBR_RDI);
15973 +#endif
15974 +
15975 + popq %rdi
15976 + pax_force_retaddr
15977 + retq
15978 +
15979 +2: GET_CR0_INTO_RDI
15980 + btr $16,%rdi
15981 + ljmpq __KERNEL_CS,3f
15982 +3: SET_RDI_INTO_CR0
15983 + jmp 1b
15984 +#ifdef CONFIG_PARAVIRT
15985 + PV_RESTORE_REGS(CLBR_RDI);
15986 +#endif
15987 +
15988 + popq %rdi
15989 + pax_force_retaddr
15990 + retq
15991 +ENDPROC(pax_exit_kernel)
15992 +#endif
15993 +
15994 + .macro pax_enter_kernel_user
15995 + pax_set_fptr_mask
15996 +#ifdef CONFIG_PAX_MEMORY_UDEREF
15997 + call pax_enter_kernel_user
15998 +#endif
15999 + .endm
16000 +
16001 + .macro pax_exit_kernel_user
16002 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16003 + call pax_exit_kernel_user
16004 +#endif
16005 +#ifdef CONFIG_PAX_RANDKSTACK
16006 + pushq %rax
16007 + call pax_randomize_kstack
16008 + popq %rax
16009 +#endif
16010 + .endm
16011 +
16012 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16013 +ENTRY(pax_enter_kernel_user)
16014 + pushq %rdi
16015 + pushq %rbx
16016 +
16017 +#ifdef CONFIG_PARAVIRT
16018 + PV_SAVE_REGS(CLBR_RDI)
16019 +#endif
16020 +
16021 + GET_CR3_INTO_RDI
16022 + mov %rdi,%rbx
16023 + add $__START_KERNEL_map,%rbx
16024 + sub phys_base(%rip),%rbx
16025 +
16026 +#ifdef CONFIG_PARAVIRT
16027 + pushq %rdi
16028 + cmpl $0, pv_info+PARAVIRT_enabled
16029 + jz 1f
16030 + i = 0
16031 + .rept USER_PGD_PTRS
16032 + mov i*8(%rbx),%rsi
16033 + mov $0,%sil
16034 + lea i*8(%rbx),%rdi
16035 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
16036 + i = i + 1
16037 + .endr
16038 + jmp 2f
16039 +1:
16040 +#endif
16041 +
16042 + i = 0
16043 + .rept USER_PGD_PTRS
16044 + movb $0,i*8(%rbx)
16045 + i = i + 1
16046 + .endr
16047 +
16048 +#ifdef CONFIG_PARAVIRT
16049 +2: popq %rdi
16050 +#endif
16051 + SET_RDI_INTO_CR3
16052 +
16053 +#ifdef CONFIG_PAX_KERNEXEC
16054 + GET_CR0_INTO_RDI
16055 + bts $16,%rdi
16056 + SET_RDI_INTO_CR0
16057 +#endif
16058 +
16059 +#ifdef CONFIG_PARAVIRT
16060 + PV_RESTORE_REGS(CLBR_RDI)
16061 +#endif
16062 +
16063 + popq %rbx
16064 + popq %rdi
16065 + pax_force_retaddr
16066 + retq
16067 +ENDPROC(pax_enter_kernel_user)
16068 +
16069 +ENTRY(pax_exit_kernel_user)
16070 + push %rdi
16071 +
16072 +#ifdef CONFIG_PARAVIRT
16073 + pushq %rbx
16074 + PV_SAVE_REGS(CLBR_RDI)
16075 +#endif
16076 +
16077 +#ifdef CONFIG_PAX_KERNEXEC
16078 + GET_CR0_INTO_RDI
16079 + btr $16,%rdi
16080 + SET_RDI_INTO_CR0
16081 +#endif
16082 +
16083 + GET_CR3_INTO_RDI
16084 + add $__START_KERNEL_map,%rdi
16085 + sub phys_base(%rip),%rdi
16086 +
16087 +#ifdef CONFIG_PARAVIRT
16088 + cmpl $0, pv_info+PARAVIRT_enabled
16089 + jz 1f
16090 + mov %rdi,%rbx
16091 + i = 0
16092 + .rept USER_PGD_PTRS
16093 + mov i*8(%rbx),%rsi
16094 + mov $0x67,%sil
16095 + lea i*8(%rbx),%rdi
16096 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
16097 + i = i + 1
16098 + .endr
16099 + jmp 2f
16100 +1:
16101 +#endif
16102 +
16103 + i = 0
16104 + .rept USER_PGD_PTRS
16105 + movb $0x67,i*8(%rdi)
16106 + i = i + 1
16107 + .endr
16108 +
16109 +#ifdef CONFIG_PARAVIRT
16110 +2: PV_RESTORE_REGS(CLBR_RDI)
16111 + popq %rbx
16112 +#endif
16113 +
16114 + popq %rdi
16115 + pax_force_retaddr
16116 + retq
16117 +ENDPROC(pax_exit_kernel_user)
16118 +#endif
16119 +
16120 +.macro pax_erase_kstack
16121 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
16122 + call pax_erase_kstack
16123 +#endif
16124 +.endm
16125 +
16126 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
16127 +/*
16128 + * r11: thread_info
16129 + * rcx, rdx: can be clobbered
16130 + */
16131 +ENTRY(pax_erase_kstack)
16132 + pushq %rdi
16133 + pushq %rax
16134 + pushq %r11
16135 +
16136 + GET_THREAD_INFO(%r11)
16137 + mov TI_lowest_stack(%r11), %rdi
16138 + mov $-0xBEEF, %rax
16139 + std
16140 +
16141 +1: mov %edi, %ecx
16142 + and $THREAD_SIZE_asm - 1, %ecx
16143 + shr $3, %ecx
16144 + repne scasq
16145 + jecxz 2f
16146 +
16147 + cmp $2*8, %ecx
16148 + jc 2f
16149 +
16150 + mov $2*8, %ecx
16151 + repe scasq
16152 + jecxz 2f
16153 + jne 1b
16154 +
16155 +2: cld
16156 + mov %esp, %ecx
16157 + sub %edi, %ecx
16158 +
16159 + cmp $THREAD_SIZE_asm, %rcx
16160 + jb 3f
16161 + ud2
16162 +3:
16163 +
16164 + shr $3, %ecx
16165 + rep stosq
16166 +
16167 + mov TI_task_thread_sp0(%r11), %rdi
16168 + sub $256, %rdi
16169 + mov %rdi, TI_lowest_stack(%r11)
16170 +
16171 + popq %r11
16172 + popq %rax
16173 + popq %rdi
16174 + pax_force_retaddr
16175 + ret
16176 +ENDPROC(pax_erase_kstack)
16177 +#endif
16178
16179 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
16180 #ifdef CONFIG_TRACE_IRQFLAGS
16181 @@ -232,8 +516,8 @@ ENDPROC(native_usergs_sysret64)
16182 .endm
16183
16184 .macro UNFAKE_STACK_FRAME
16185 - addq $8*6, %rsp
16186 - CFI_ADJUST_CFA_OFFSET -(6*8)
16187 + addq $8*6 + ARG_SKIP, %rsp
16188 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
16189 .endm
16190
16191 /*
16192 @@ -320,7 +604,7 @@ ENDPROC(native_usergs_sysret64)
16193 movq %rsp, %rsi
16194
16195 leaq -RBP(%rsp),%rdi /* arg1 for handler */
16196 - testl $3, CS(%rdi)
16197 + testb $3, CS(%rdi)
16198 je 1f
16199 SWAPGS
16200 /*
16201 @@ -356,9 +640,10 @@ ENTRY(save_rest)
16202 movq_cfi r15, R15+16
16203 movq %r11, 8(%rsp) /* return address */
16204 FIXUP_TOP_OF_STACK %r11, 16
16205 + pax_force_retaddr
16206 ret
16207 CFI_ENDPROC
16208 -END(save_rest)
16209 +ENDPROC(save_rest)
16210
16211 /* save complete stack frame */
16212 .pushsection .kprobes.text, "ax"
16213 @@ -387,9 +672,10 @@ ENTRY(save_paranoid)
16214 js 1f /* negative -> in kernel */
16215 SWAPGS
16216 xorl %ebx,%ebx
16217 -1: ret
16218 +1: pax_force_retaddr_bts
16219 + ret
16220 CFI_ENDPROC
16221 -END(save_paranoid)
16222 +ENDPROC(save_paranoid)
16223 .popsection
16224
16225 /*
16226 @@ -411,7 +697,7 @@ ENTRY(ret_from_fork)
16227
16228 RESTORE_REST
16229
16230 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
16231 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
16232 jz retint_restore_args
16233
16234 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
16235 @@ -421,7 +707,7 @@ ENTRY(ret_from_fork)
16236 jmp ret_from_sys_call # go to the SYSRET fastpath
16237
16238 CFI_ENDPROC
16239 -END(ret_from_fork)
16240 +ENDPROC(ret_from_fork)
16241
16242 /*
16243 * System call entry. Up to 6 arguments in registers are supported.
16244 @@ -457,7 +743,7 @@ END(ret_from_fork)
16245 ENTRY(system_call)
16246 CFI_STARTPROC simple
16247 CFI_SIGNAL_FRAME
16248 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
16249 + CFI_DEF_CFA rsp,0
16250 CFI_REGISTER rip,rcx
16251 /*CFI_REGISTER rflags,r11*/
16252 SWAPGS_UNSAFE_STACK
16253 @@ -470,21 +756,23 @@ GLOBAL(system_call_after_swapgs)
16254
16255 movq %rsp,PER_CPU_VAR(old_rsp)
16256 movq PER_CPU_VAR(kernel_stack),%rsp
16257 + SAVE_ARGS 8*6,0
16258 + pax_enter_kernel_user
16259 /*
16260 * No need to follow this irqs off/on section - it's straight
16261 * and short:
16262 */
16263 ENABLE_INTERRUPTS(CLBR_NONE)
16264 - SAVE_ARGS 8,0
16265 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
16266 movq %rcx,RIP-ARGOFFSET(%rsp)
16267 CFI_REL_OFFSET rip,RIP-ARGOFFSET
16268 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
16269 + GET_THREAD_INFO(%rcx)
16270 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
16271 jnz tracesys
16272 system_call_fastpath:
16273 cmpq $__NR_syscall_max,%rax
16274 ja badsys
16275 - movq %r10,%rcx
16276 + movq R10-ARGOFFSET(%rsp),%rcx
16277 call *sys_call_table(,%rax,8) # XXX: rip relative
16278 movq %rax,RAX-ARGOFFSET(%rsp)
16279 /*
16280 @@ -498,10 +786,13 @@ sysret_check:
16281 LOCKDEP_SYS_EXIT
16282 DISABLE_INTERRUPTS(CLBR_NONE)
16283 TRACE_IRQS_OFF
16284 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
16285 + GET_THREAD_INFO(%rcx)
16286 + movl TI_flags(%rcx),%edx
16287 andl %edi,%edx
16288 jnz sysret_careful
16289 CFI_REMEMBER_STATE
16290 + pax_exit_kernel_user
16291 + pax_erase_kstack
16292 /*
16293 * sysretq will re-enable interrupts:
16294 */
16295 @@ -553,14 +844,18 @@ badsys:
16296 * jump back to the normal fast path.
16297 */
16298 auditsys:
16299 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
16300 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
16301 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
16302 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
16303 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
16304 movq %rax,%rsi /* 2nd arg: syscall number */
16305 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
16306 call __audit_syscall_entry
16307 +
16308 + pax_erase_kstack
16309 +
16310 LOAD_ARGS 0 /* reload call-clobbered registers */
16311 + pax_set_fptr_mask
16312 jmp system_call_fastpath
16313
16314 /*
16315 @@ -581,7 +876,7 @@ sysret_audit:
16316 /* Do syscall tracing */
16317 tracesys:
16318 #ifdef CONFIG_AUDITSYSCALL
16319 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
16320 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
16321 jz auditsys
16322 #endif
16323 SAVE_REST
16324 @@ -589,16 +884,20 @@ tracesys:
16325 FIXUP_TOP_OF_STACK %rdi
16326 movq %rsp,%rdi
16327 call syscall_trace_enter
16328 +
16329 + pax_erase_kstack
16330 +
16331 /*
16332 * Reload arg registers from stack in case ptrace changed them.
16333 * We don't reload %rax because syscall_trace_enter() returned
16334 * the value it wants us to use in the table lookup.
16335 */
16336 LOAD_ARGS ARGOFFSET, 1
16337 + pax_set_fptr_mask
16338 RESTORE_REST
16339 cmpq $__NR_syscall_max,%rax
16340 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
16341 - movq %r10,%rcx /* fixup for C */
16342 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
16343 call *sys_call_table(,%rax,8)
16344 movq %rax,RAX-ARGOFFSET(%rsp)
16345 /* Use IRET because user could have changed frame */
16346 @@ -619,6 +918,7 @@ GLOBAL(int_with_check)
16347 andl %edi,%edx
16348 jnz int_careful
16349 andl $~TS_COMPAT,TI_status(%rcx)
16350 + pax_erase_kstack
16351 jmp retint_swapgs
16352
16353 /* Either reschedule or signal or syscall exit tracking needed. */
16354 @@ -665,7 +965,7 @@ int_restore_rest:
16355 TRACE_IRQS_OFF
16356 jmp int_with_check
16357 CFI_ENDPROC
16358 -END(system_call)
16359 +ENDPROC(system_call)
16360
16361 /*
16362 * Certain special system calls that need to save a complete full stack frame.
16363 @@ -681,7 +981,7 @@ ENTRY(\label)
16364 call \func
16365 jmp ptregscall_common
16366 CFI_ENDPROC
16367 -END(\label)
16368 +ENDPROC(\label)
16369 .endm
16370
16371 PTREGSCALL stub_clone, sys_clone, %r8
16372 @@ -699,9 +999,10 @@ ENTRY(ptregscall_common)
16373 movq_cfi_restore R12+8, r12
16374 movq_cfi_restore RBP+8, rbp
16375 movq_cfi_restore RBX+8, rbx
16376 + pax_force_retaddr
16377 ret $REST_SKIP /* pop extended registers */
16378 CFI_ENDPROC
16379 -END(ptregscall_common)
16380 +ENDPROC(ptregscall_common)
16381
16382 ENTRY(stub_execve)
16383 CFI_STARTPROC
16384 @@ -716,7 +1017,7 @@ ENTRY(stub_execve)
16385 RESTORE_REST
16386 jmp int_ret_from_sys_call
16387 CFI_ENDPROC
16388 -END(stub_execve)
16389 +ENDPROC(stub_execve)
16390
16391 /*
16392 * sigreturn is special because it needs to restore all registers on return.
16393 @@ -734,7 +1035,7 @@ ENTRY(stub_rt_sigreturn)
16394 RESTORE_REST
16395 jmp int_ret_from_sys_call
16396 CFI_ENDPROC
16397 -END(stub_rt_sigreturn)
16398 +ENDPROC(stub_rt_sigreturn)
16399
16400 /*
16401 * Build the entry stubs and pointer table with some assembler magic.
16402 @@ -769,7 +1070,7 @@ vector=vector+1
16403 2: jmp common_interrupt
16404 .endr
16405 CFI_ENDPROC
16406 -END(irq_entries_start)
16407 +ENDPROC(irq_entries_start)
16408
16409 .previous
16410 END(interrupt)
16411 @@ -789,6 +1090,16 @@ END(interrupt)
16412 subq $ORIG_RAX-RBP, %rsp
16413 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
16414 SAVE_ARGS_IRQ
16415 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16416 + testb $3, CS(%rdi)
16417 + jnz 1f
16418 + pax_enter_kernel
16419 + jmp 2f
16420 +1: pax_enter_kernel_user
16421 +2:
16422 +#else
16423 + pax_enter_kernel
16424 +#endif
16425 call \func
16426 .endm
16427
16428 @@ -820,7 +1131,7 @@ ret_from_intr:
16429
16430 exit_intr:
16431 GET_THREAD_INFO(%rcx)
16432 - testl $3,CS-ARGOFFSET(%rsp)
16433 + testb $3,CS-ARGOFFSET(%rsp)
16434 je retint_kernel
16435
16436 /* Interrupt came from user space */
16437 @@ -842,12 +1153,15 @@ retint_swapgs: /* return to user-space */
16438 * The iretq could re-enable interrupts:
16439 */
16440 DISABLE_INTERRUPTS(CLBR_ANY)
16441 + pax_exit_kernel_user
16442 TRACE_IRQS_IRETQ
16443 SWAPGS
16444 jmp restore_args
16445
16446 retint_restore_args: /* return to kernel space */
16447 DISABLE_INTERRUPTS(CLBR_ANY)
16448 + pax_exit_kernel
16449 + pax_force_retaddr RIP-ARGOFFSET
16450 /*
16451 * The iretq could re-enable interrupts:
16452 */
16453 @@ -936,7 +1250,7 @@ ENTRY(retint_kernel)
16454 #endif
16455
16456 CFI_ENDPROC
16457 -END(common_interrupt)
16458 +ENDPROC(common_interrupt)
16459 /*
16460 * End of kprobes section
16461 */
16462 @@ -953,7 +1267,7 @@ ENTRY(\sym)
16463 interrupt \do_sym
16464 jmp ret_from_intr
16465 CFI_ENDPROC
16466 -END(\sym)
16467 +ENDPROC(\sym)
16468 .endm
16469
16470 #ifdef CONFIG_SMP
16471 @@ -1026,12 +1340,22 @@ ENTRY(\sym)
16472 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
16473 call error_entry
16474 DEFAULT_FRAME 0
16475 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16476 + testb $3, CS(%rsp)
16477 + jnz 1f
16478 + pax_enter_kernel
16479 + jmp 2f
16480 +1: pax_enter_kernel_user
16481 +2:
16482 +#else
16483 + pax_enter_kernel
16484 +#endif
16485 movq %rsp,%rdi /* pt_regs pointer */
16486 xorl %esi,%esi /* no error code */
16487 call \do_sym
16488 jmp error_exit /* %ebx: no swapgs flag */
16489 CFI_ENDPROC
16490 -END(\sym)
16491 +ENDPROC(\sym)
16492 .endm
16493
16494 .macro paranoidzeroentry sym do_sym
16495 @@ -1043,15 +1367,25 @@ ENTRY(\sym)
16496 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
16497 call save_paranoid
16498 TRACE_IRQS_OFF
16499 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16500 + testb $3, CS(%rsp)
16501 + jnz 1f
16502 + pax_enter_kernel
16503 + jmp 2f
16504 +1: pax_enter_kernel_user
16505 +2:
16506 +#else
16507 + pax_enter_kernel
16508 +#endif
16509 movq %rsp,%rdi /* pt_regs pointer */
16510 xorl %esi,%esi /* no error code */
16511 call \do_sym
16512 jmp paranoid_exit /* %ebx: no swapgs flag */
16513 CFI_ENDPROC
16514 -END(\sym)
16515 +ENDPROC(\sym)
16516 .endm
16517
16518 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
16519 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
16520 .macro paranoidzeroentry_ist sym do_sym ist
16521 ENTRY(\sym)
16522 INTR_FRAME
16523 @@ -1061,14 +1395,30 @@ ENTRY(\sym)
16524 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
16525 call save_paranoid
16526 TRACE_IRQS_OFF
16527 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16528 + testb $3, CS(%rsp)
16529 + jnz 1f
16530 + pax_enter_kernel
16531 + jmp 2f
16532 +1: pax_enter_kernel_user
16533 +2:
16534 +#else
16535 + pax_enter_kernel
16536 +#endif
16537 movq %rsp,%rdi /* pt_regs pointer */
16538 xorl %esi,%esi /* no error code */
16539 +#ifdef CONFIG_SMP
16540 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
16541 + lea init_tss(%r12), %r12
16542 +#else
16543 + lea init_tss(%rip), %r12
16544 +#endif
16545 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
16546 call \do_sym
16547 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
16548 jmp paranoid_exit /* %ebx: no swapgs flag */
16549 CFI_ENDPROC
16550 -END(\sym)
16551 +ENDPROC(\sym)
16552 .endm
16553
16554 .macro errorentry sym do_sym
16555 @@ -1079,13 +1429,23 @@ ENTRY(\sym)
16556 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
16557 call error_entry
16558 DEFAULT_FRAME 0
16559 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16560 + testb $3, CS(%rsp)
16561 + jnz 1f
16562 + pax_enter_kernel
16563 + jmp 2f
16564 +1: pax_enter_kernel_user
16565 +2:
16566 +#else
16567 + pax_enter_kernel
16568 +#endif
16569 movq %rsp,%rdi /* pt_regs pointer */
16570 movq ORIG_RAX(%rsp),%rsi /* get error code */
16571 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
16572 call \do_sym
16573 jmp error_exit /* %ebx: no swapgs flag */
16574 CFI_ENDPROC
16575 -END(\sym)
16576 +ENDPROC(\sym)
16577 .endm
16578
16579 /* error code is on the stack already */
16580 @@ -1098,13 +1458,23 @@ ENTRY(\sym)
16581 call save_paranoid
16582 DEFAULT_FRAME 0
16583 TRACE_IRQS_OFF
16584 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16585 + testb $3, CS(%rsp)
16586 + jnz 1f
16587 + pax_enter_kernel
16588 + jmp 2f
16589 +1: pax_enter_kernel_user
16590 +2:
16591 +#else
16592 + pax_enter_kernel
16593 +#endif
16594 movq %rsp,%rdi /* pt_regs pointer */
16595 movq ORIG_RAX(%rsp),%rsi /* get error code */
16596 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
16597 call \do_sym
16598 jmp paranoid_exit /* %ebx: no swapgs flag */
16599 CFI_ENDPROC
16600 -END(\sym)
16601 +ENDPROC(\sym)
16602 .endm
16603
16604 zeroentry divide_error do_divide_error
16605 @@ -1134,9 +1504,10 @@ gs_change:
16606 2: mfence /* workaround */
16607 SWAPGS
16608 popfq_cfi
16609 + pax_force_retaddr
16610 ret
16611 CFI_ENDPROC
16612 -END(native_load_gs_index)
16613 +ENDPROC(native_load_gs_index)
16614
16615 .section __ex_table,"a"
16616 .align 8
16617 @@ -1158,13 +1529,14 @@ ENTRY(kernel_thread_helper)
16618 * Here we are in the child and the registers are set as they were
16619 * at kernel_thread() invocation in the parent.
16620 */
16621 + pax_force_fptr %rsi
16622 call *%rsi
16623 # exit
16624 mov %eax, %edi
16625 call do_exit
16626 ud2 # padding for call trace
16627 CFI_ENDPROC
16628 -END(kernel_thread_helper)
16629 +ENDPROC(kernel_thread_helper)
16630
16631 /*
16632 * execve(). This function needs to use IRET, not SYSRET, to set up all state properly.
16633 @@ -1191,11 +1563,11 @@ ENTRY(kernel_execve)
16634 RESTORE_REST
16635 testq %rax,%rax
16636 je int_ret_from_sys_call
16637 - RESTORE_ARGS
16638 UNFAKE_STACK_FRAME
16639 + pax_force_retaddr
16640 ret
16641 CFI_ENDPROC
16642 -END(kernel_execve)
16643 +ENDPROC(kernel_execve)
16644
16645 /* Call softirq on interrupt stack. Interrupts are off. */
16646 ENTRY(call_softirq)
16647 @@ -1213,9 +1585,10 @@ ENTRY(call_softirq)
16648 CFI_DEF_CFA_REGISTER rsp
16649 CFI_ADJUST_CFA_OFFSET -8
16650 decl PER_CPU_VAR(irq_count)
16651 + pax_force_retaddr
16652 ret
16653 CFI_ENDPROC
16654 -END(call_softirq)
16655 +ENDPROC(call_softirq)
16656
16657 #ifdef CONFIG_XEN
16658 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
16659 @@ -1253,7 +1626,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
16660 decl PER_CPU_VAR(irq_count)
16661 jmp error_exit
16662 CFI_ENDPROC
16663 -END(xen_do_hypervisor_callback)
16664 +ENDPROC(xen_do_hypervisor_callback)
16665
16666 /*
16667 * Hypervisor uses this for application faults while it executes.
16668 @@ -1312,7 +1685,7 @@ ENTRY(xen_failsafe_callback)
16669 SAVE_ALL
16670 jmp error_exit
16671 CFI_ENDPROC
16672 -END(xen_failsafe_callback)
16673 +ENDPROC(xen_failsafe_callback)
16674
16675 apicinterrupt XEN_HVM_EVTCHN_CALLBACK \
16676 xen_hvm_callback_vector xen_evtchn_do_upcall
16677 @@ -1361,16 +1734,31 @@ ENTRY(paranoid_exit)
16678 TRACE_IRQS_OFF
16679 testl %ebx,%ebx /* swapgs needed? */
16680 jnz paranoid_restore
16681 - testl $3,CS(%rsp)
16682 + testb $3,CS(%rsp)
16683 jnz paranoid_userspace
16684 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16685 + pax_exit_kernel
16686 + TRACE_IRQS_IRETQ 0
16687 + SWAPGS_UNSAFE_STACK
16688 + RESTORE_ALL 8
16689 + pax_force_retaddr_bts
16690 + jmp irq_return
16691 +#endif
16692 paranoid_swapgs:
16693 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16694 + pax_exit_kernel_user
16695 +#else
16696 + pax_exit_kernel
16697 +#endif
16698 TRACE_IRQS_IRETQ 0
16699 SWAPGS_UNSAFE_STACK
16700 RESTORE_ALL 8
16701 jmp irq_return
16702 paranoid_restore:
16703 + pax_exit_kernel
16704 TRACE_IRQS_IRETQ 0
16705 RESTORE_ALL 8
16706 + pax_force_retaddr_bts
16707 jmp irq_return
16708 paranoid_userspace:
16709 GET_THREAD_INFO(%rcx)
16710 @@ -1399,7 +1787,7 @@ paranoid_schedule:
16711 TRACE_IRQS_OFF
16712 jmp paranoid_userspace
16713 CFI_ENDPROC
16714 -END(paranoid_exit)
16715 +ENDPROC(paranoid_exit)
16716
16717 /*
16718 * Exception entry point. This expects an error code/orig_rax on the stack.
16719 @@ -1426,12 +1814,13 @@ ENTRY(error_entry)
16720 movq_cfi r14, R14+8
16721 movq_cfi r15, R15+8
16722 xorl %ebx,%ebx
16723 - testl $3,CS+8(%rsp)
16724 + testb $3,CS+8(%rsp)
16725 je error_kernelspace
16726 error_swapgs:
16727 SWAPGS
16728 error_sti:
16729 TRACE_IRQS_OFF
16730 + pax_force_retaddr_bts
16731 ret
16732
16733 /*
16734 @@ -1458,7 +1847,7 @@ bstep_iret:
16735 movq %rcx,RIP+8(%rsp)
16736 jmp error_swapgs
16737 CFI_ENDPROC
16738 -END(error_entry)
16739 +ENDPROC(error_entry)
16740
16741
16742 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
16743 @@ -1478,7 +1867,7 @@ ENTRY(error_exit)
16744 jnz retint_careful
16745 jmp retint_swapgs
16746 CFI_ENDPROC
16747 -END(error_exit)
16748 +ENDPROC(error_exit)
16749
16750 /*
16751 * Test if a given stack is an NMI stack or not.
16752 @@ -1535,9 +1924,11 @@ ENTRY(nmi)
16753 * If %cs was not the kernel segment, then the NMI triggered in user
16754 * space, which means it is definitely not nested.
16755 */
16756 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
16757 + je 1f
16758 cmpl $__KERNEL_CS, 16(%rsp)
16759 jne first_nmi
16760 -
16761 +1:
16762 /*
16763 * Check the special variable on the stack to see if NMIs are
16764 * executing.
16765 @@ -1659,6 +2050,16 @@ restart_nmi:
16766 */
16767 call save_paranoid
16768 DEFAULT_FRAME 0
16769 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16770 + testb $3, CS(%rsp)
16771 + jnz 1f
16772 + pax_enter_kernel
16773 + jmp 2f
16774 +1: pax_enter_kernel_user
16775 +2:
16776 +#else
16777 + pax_enter_kernel
16778 +#endif
16779 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
16780 movq %rsp,%rdi
16781 movq $-1,%rsi
16782 @@ -1666,14 +2067,25 @@ restart_nmi:
16783 testl %ebx,%ebx /* swapgs needed? */
16784 jnz nmi_restore
16785 nmi_swapgs:
16786 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16787 + pax_exit_kernel_user
16788 +#else
16789 + pax_exit_kernel
16790 +#endif
16791 SWAPGS_UNSAFE_STACK
16792 + RESTORE_ALL 8
16793 + /* Clear the NMI executing stack variable */
16794 + movq $0, 10*8(%rsp)
16795 + jmp irq_return
16796 nmi_restore:
16797 + pax_exit_kernel
16798 RESTORE_ALL 8
16799 + pax_force_retaddr_bts
16800 /* Clear the NMI executing stack variable */
16801 movq $0, 10*8(%rsp)
16802 jmp irq_return
16803 CFI_ENDPROC
16804 -END(nmi)
16805 +ENDPROC(nmi)
16806
16807 /*
16808 * If an NMI hit an iret because of an exception or breakpoint,
16809 @@ -1700,7 +2112,7 @@ ENTRY(ignore_sysret)
16810 mov $-ENOSYS,%eax
16811 sysret
16812 CFI_ENDPROC
16813 -END(ignore_sysret)
16814 +ENDPROC(ignore_sysret)
16815
16816 /*
16817 * End of kprobes section
16818 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
16819 index c9a281f..ce2f317 100644
16820 --- a/arch/x86/kernel/ftrace.c
16821 +++ b/arch/x86/kernel/ftrace.c
16822 @@ -126,7 +126,7 @@ static void *mod_code_ip; /* holds the IP to write to */
16823 static const void *mod_code_newcode; /* holds the text to write to the IP */
16824
16825 static unsigned nmi_wait_count;
16826 -static atomic_t nmi_update_count = ATOMIC_INIT(0);
16827 +static atomic_unchecked_t nmi_update_count = ATOMIC_INIT(0);
16828
16829 int ftrace_arch_read_dyn_info(char *buf, int size)
16830 {
16831 @@ -134,7 +134,7 @@ int ftrace_arch_read_dyn_info(char *buf, int size)
16832
16833 r = snprintf(buf, size, "%u %u",
16834 nmi_wait_count,
16835 - atomic_read(&nmi_update_count));
16836 + atomic_read_unchecked(&nmi_update_count));
16837 return r;
16838 }
16839
16840 @@ -177,8 +177,10 @@ void ftrace_nmi_enter(void)
16841
16842 if (atomic_inc_return(&nmi_running) & MOD_CODE_WRITE_FLAG) {
16843 smp_rmb();
16844 + pax_open_kernel();
16845 ftrace_mod_code();
16846 - atomic_inc(&nmi_update_count);
16847 + pax_close_kernel();
16848 + atomic_inc_unchecked(&nmi_update_count);
16849 }
16850 /* Must have previous changes seen before executions */
16851 smp_mb();
16852 @@ -271,6 +273,8 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
16853 {
16854 unsigned char replaced[MCOUNT_INSN_SIZE];
16855
16856 + ip = ktla_ktva(ip);
16857 +
16858 /*
16859 * Note: Due to modules and __init, code can
16860 * disappear and change, we need to protect against faulting
16861 @@ -327,7 +331,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
16862 unsigned char old[MCOUNT_INSN_SIZE], *new;
16863 int ret;
16864
16865 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
16866 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
16867 new = ftrace_call_replace(ip, (unsigned long)func);
16868 ret = ftrace_modify_code(ip, old, new);
16869
16870 @@ -353,6 +357,8 @@ static int ftrace_mod_jmp(unsigned long ip,
16871 {
16872 unsigned char code[MCOUNT_INSN_SIZE];
16873
16874 + ip = ktla_ktva(ip);
16875 +
16876 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
16877 return -EFAULT;
16878
16879 diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c
16880 index 51ff186..9e77418 100644
16881 --- a/arch/x86/kernel/head32.c
16882 +++ b/arch/x86/kernel/head32.c
16883 @@ -19,6 +19,7 @@
16884 #include <asm/io_apic.h>
16885 #include <asm/bios_ebda.h>
16886 #include <asm/tlbflush.h>
16887 +#include <asm/boot.h>
16888
16889 static void __init i386_default_early_setup(void)
16890 {
16891 @@ -31,8 +32,7 @@ static void __init i386_default_early_setup(void)
16892
16893 void __init i386_start_kernel(void)
16894 {
16895 - memblock_reserve(__pa_symbol(&_text),
16896 - __pa_symbol(&__bss_stop) - __pa_symbol(&_text));
16897 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(&__bss_stop) - LOAD_PHYSICAL_ADDR);
16898
16899 #ifdef CONFIG_BLK_DEV_INITRD
16900 /* Reserve INITRD */
16901 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
16902 index ce0be7c..c41476e 100644
16903 --- a/arch/x86/kernel/head_32.S
16904 +++ b/arch/x86/kernel/head_32.S
16905 @@ -25,6 +25,12 @@
16906 /* Physical address */
16907 #define pa(X) ((X) - __PAGE_OFFSET)
16908
16909 +#ifdef CONFIG_PAX_KERNEXEC
16910 +#define ta(X) (X)
16911 +#else
16912 +#define ta(X) ((X) - __PAGE_OFFSET)
16913 +#endif
16914 +
16915 /*
16916 * References to members of the new_cpu_data structure.
16917 */
16918 @@ -54,11 +60,7 @@
16919 * and small than max_low_pfn, otherwise will waste some page table entries
16920 */
16921
16922 -#if PTRS_PER_PMD > 1
16923 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
16924 -#else
16925 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
16926 -#endif
16927 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
16928
16929 /* Number of possible pages in the lowmem region */
16930 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
16931 @@ -77,6 +79,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
16932 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
16933
16934 /*
16935 + * Real beginning of normal "text" segment
16936 + */
16937 +ENTRY(stext)
16938 +ENTRY(_stext)
16939 +
16940 +/*
16941 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
16942 * %esi points to the real-mode code as a 32-bit pointer.
16943 * CS and DS must be 4 GB flat segments, but we don't depend on
16944 @@ -84,6 +92,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
16945 * can.
16946 */
16947 __HEAD
16948 +
16949 +#ifdef CONFIG_PAX_KERNEXEC
16950 + jmp startup_32
16951 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
16952 +.fill PAGE_SIZE-5,1,0xcc
16953 +#endif
16954 +
16955 ENTRY(startup_32)
16956 movl pa(stack_start),%ecx
16957
16958 @@ -105,6 +120,57 @@ ENTRY(startup_32)
16959 2:
16960 leal -__PAGE_OFFSET(%ecx),%esp
16961
16962 +#ifdef CONFIG_SMP
16963 + movl $pa(cpu_gdt_table),%edi
16964 + movl $__per_cpu_load,%eax
16965 + movw %ax,__KERNEL_PERCPU + 2(%edi)
16966 + rorl $16,%eax
16967 + movb %al,__KERNEL_PERCPU + 4(%edi)
16968 + movb %ah,__KERNEL_PERCPU + 7(%edi)
16969 + movl $__per_cpu_end - 1,%eax
16970 + subl $__per_cpu_start,%eax
16971 + movw %ax,__KERNEL_PERCPU + 0(%edi)
16972 +#endif
16973 +
16974 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16975 + movl $NR_CPUS,%ecx
16976 + movl $pa(cpu_gdt_table),%edi
16977 +1:
16978 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
16979 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
16980 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
16981 + addl $PAGE_SIZE_asm,%edi
16982 + loop 1b
16983 +#endif
16984 +
16985 +#ifdef CONFIG_PAX_KERNEXEC
16986 + movl $pa(boot_gdt),%edi
16987 + movl $__LOAD_PHYSICAL_ADDR,%eax
16988 + movw %ax,__BOOT_CS + 2(%edi)
16989 + rorl $16,%eax
16990 + movb %al,__BOOT_CS + 4(%edi)
16991 + movb %ah,__BOOT_CS + 7(%edi)
16992 + rorl $16,%eax
16993 +
16994 + ljmp $(__BOOT_CS),$1f
16995 +1:
16996 +
16997 + movl $NR_CPUS,%ecx
16998 + movl $pa(cpu_gdt_table),%edi
16999 + addl $__PAGE_OFFSET,%eax
17000 +1:
17001 + movw %ax,__KERNEL_CS + 2(%edi)
17002 + movw %ax,__KERNEXEC_KERNEL_CS + 2(%edi)
17003 + rorl $16,%eax
17004 + movb %al,__KERNEL_CS + 4(%edi)
17005 + movb %al,__KERNEXEC_KERNEL_CS + 4(%edi)
17006 + movb %ah,__KERNEL_CS + 7(%edi)
17007 + movb %ah,__KERNEXEC_KERNEL_CS + 7(%edi)
17008 + rorl $16,%eax
17009 + addl $PAGE_SIZE_asm,%edi
17010 + loop 1b
17011 +#endif
17012 +
17013 /*
17014 * Clear BSS first so that there are no surprises...
17015 */
17016 @@ -195,8 +261,11 @@ ENTRY(startup_32)
17017 movl %eax, pa(max_pfn_mapped)
17018
17019 /* Do early initialization of the fixmap area */
17020 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
17021 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
17022 +#ifdef CONFIG_COMPAT_VDSO
17023 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
17024 +#else
17025 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
17026 +#endif
17027 #else /* Not PAE */
17028
17029 page_pde_offset = (__PAGE_OFFSET >> 20);
17030 @@ -226,8 +295,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
17031 movl %eax, pa(max_pfn_mapped)
17032
17033 /* Do early initialization of the fixmap area */
17034 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
17035 - movl %eax,pa(initial_page_table+0xffc)
17036 +#ifdef CONFIG_COMPAT_VDSO
17037 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
17038 +#else
17039 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
17040 +#endif
17041 #endif
17042
17043 #ifdef CONFIG_PARAVIRT
17044 @@ -241,9 +313,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
17045 cmpl $num_subarch_entries, %eax
17046 jae bad_subarch
17047
17048 - movl pa(subarch_entries)(,%eax,4), %eax
17049 - subl $__PAGE_OFFSET, %eax
17050 - jmp *%eax
17051 + jmp *pa(subarch_entries)(,%eax,4)
17052
17053 bad_subarch:
17054 WEAK(lguest_entry)
17055 @@ -255,10 +325,10 @@ WEAK(xen_entry)
17056 __INITDATA
17057
17058 subarch_entries:
17059 - .long default_entry /* normal x86/PC */
17060 - .long lguest_entry /* lguest hypervisor */
17061 - .long xen_entry /* Xen hypervisor */
17062 - .long default_entry /* Moorestown MID */
17063 + .long ta(default_entry) /* normal x86/PC */
17064 + .long ta(lguest_entry) /* lguest hypervisor */
17065 + .long ta(xen_entry) /* Xen hypervisor */
17066 + .long ta(default_entry) /* Moorestown MID */
17067 num_subarch_entries = (. - subarch_entries) / 4
17068 .previous
17069 #else
17070 @@ -312,6 +382,7 @@ default_entry:
17071 orl %edx,%eax
17072 movl %eax,%cr4
17073
17074 +#ifdef CONFIG_X86_PAE
17075 testb $X86_CR4_PAE, %al # check if PAE is enabled
17076 jz 6f
17077
17078 @@ -340,6 +411,9 @@ default_entry:
17079 /* Make changes effective */
17080 wrmsr
17081
17082 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
17083 +#endif
17084 +
17085 6:
17086
17087 /*
17088 @@ -443,7 +517,7 @@ is386: movl $2,%ecx # set MP
17089 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
17090 movl %eax,%ss # after changing gdt.
17091
17092 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
17093 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
17094 movl %eax,%ds
17095 movl %eax,%es
17096
17097 @@ -457,15 +531,22 @@ is386: movl $2,%ecx # set MP
17098 */
17099 cmpb $0,ready
17100 jne 1f
17101 - movl $gdt_page,%eax
17102 + movl $cpu_gdt_table,%eax
17103 movl $stack_canary,%ecx
17104 +#ifdef CONFIG_SMP
17105 + addl $__per_cpu_load,%ecx
17106 +#endif
17107 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
17108 shrl $16, %ecx
17109 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
17110 movb %ch, 8 * GDT_ENTRY_STACK_CANARY + 7(%eax)
17111 1:
17112 -#endif
17113 movl $(__KERNEL_STACK_CANARY),%eax
17114 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
17115 + movl $(__USER_DS),%eax
17116 +#else
17117 + xorl %eax,%eax
17118 +#endif
17119 movl %eax,%gs
17120
17121 xorl %eax,%eax # Clear LDT
17122 @@ -558,22 +639,22 @@ early_page_fault:
17123 jmp early_fault
17124
17125 early_fault:
17126 - cld
17127 #ifdef CONFIG_PRINTK
17128 + cmpl $1,%ss:early_recursion_flag
17129 + je hlt_loop
17130 + incl %ss:early_recursion_flag
17131 + cld
17132 pusha
17133 movl $(__KERNEL_DS),%eax
17134 movl %eax,%ds
17135 movl %eax,%es
17136 - cmpl $2,early_recursion_flag
17137 - je hlt_loop
17138 - incl early_recursion_flag
17139 movl %cr2,%eax
17140 pushl %eax
17141 pushl %edx /* trapno */
17142 pushl $fault_msg
17143 call printk
17144 +; call dump_stack
17145 #endif
17146 - call dump_stack
17147 hlt_loop:
17148 hlt
17149 jmp hlt_loop
17150 @@ -581,8 +662,11 @@ hlt_loop:
17151 /* This is the default interrupt "handler" :-) */
17152 ALIGN
17153 ignore_int:
17154 - cld
17155 #ifdef CONFIG_PRINTK
17156 + cmpl $2,%ss:early_recursion_flag
17157 + je hlt_loop
17158 + incl %ss:early_recursion_flag
17159 + cld
17160 pushl %eax
17161 pushl %ecx
17162 pushl %edx
17163 @@ -591,9 +675,6 @@ ignore_int:
17164 movl $(__KERNEL_DS),%eax
17165 movl %eax,%ds
17166 movl %eax,%es
17167 - cmpl $2,early_recursion_flag
17168 - je hlt_loop
17169 - incl early_recursion_flag
17170 pushl 16(%esp)
17171 pushl 24(%esp)
17172 pushl 32(%esp)
17173 @@ -622,29 +703,43 @@ ENTRY(initial_code)
17174 /*
17175 * BSS section
17176 */
17177 -__PAGE_ALIGNED_BSS
17178 - .align PAGE_SIZE
17179 #ifdef CONFIG_X86_PAE
17180 +.section .initial_pg_pmd,"a",@progbits
17181 initial_pg_pmd:
17182 .fill 1024*KPMDS,4,0
17183 #else
17184 +.section .initial_page_table,"a",@progbits
17185 ENTRY(initial_page_table)
17186 .fill 1024,4,0
17187 #endif
17188 +.section .initial_pg_fixmap,"a",@progbits
17189 initial_pg_fixmap:
17190 .fill 1024,4,0
17191 +.section .empty_zero_page,"a",@progbits
17192 ENTRY(empty_zero_page)
17193 .fill 4096,1,0
17194 +.section .swapper_pg_dir,"a",@progbits
17195 ENTRY(swapper_pg_dir)
17196 +#ifdef CONFIG_X86_PAE
17197 + .fill 4,8,0
17198 +#else
17199 .fill 1024,4,0
17200 +#endif
17201 +
17202 +/*
17203 + * The IDT has to be page-aligned to simplify the Pentium
17204 + * F0 0F bug workaround.. We have a special link segment
17205 + * for this.
17206 + */
17207 +.section .idt,"a",@progbits
17208 +ENTRY(idt_table)
17209 + .fill 256,8,0
17210
17211 /*
17212 * This starts the data section.
17213 */
17214 #ifdef CONFIG_X86_PAE
17215 -__PAGE_ALIGNED_DATA
17216 - /* Page-aligned for the benefit of paravirt? */
17217 - .align PAGE_SIZE
17218 +.section .initial_page_table,"a",@progbits
17219 ENTRY(initial_page_table)
17220 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
17221 # if KPMDS == 3
17222 @@ -663,18 +758,27 @@ ENTRY(initial_page_table)
17223 # error "Kernel PMDs should be 1, 2 or 3"
17224 # endif
17225 .align PAGE_SIZE /* needs to be page-sized too */
17226 +
17227 +#ifdef CONFIG_PAX_PER_CPU_PGD
17228 +ENTRY(cpu_pgd)
17229 + .rept NR_CPUS
17230 + .fill 4,8,0
17231 + .endr
17232 +#endif
17233 +
17234 #endif
17235
17236 .data
17237 .balign 4
17238 ENTRY(stack_start)
17239 - .long init_thread_union+THREAD_SIZE
17240 + .long init_thread_union+THREAD_SIZE-8
17241
17242 +ready: .byte 0
17243 +
17244 +.section .rodata,"a",@progbits
17245 early_recursion_flag:
17246 .long 0
17247
17248 -ready: .byte 0
17249 -
17250 int_msg:
17251 .asciz "Unknown interrupt or fault at: %p %p %p\n"
17252
17253 @@ -707,7 +811,7 @@ fault_msg:
17254 .word 0 # 32 bit align gdt_desc.address
17255 boot_gdt_descr:
17256 .word __BOOT_DS+7
17257 - .long boot_gdt - __PAGE_OFFSET
17258 + .long pa(boot_gdt)
17259
17260 .word 0 # 32-bit align idt_desc.address
17261 idt_descr:
17262 @@ -718,7 +822,7 @@ idt_descr:
17263 .word 0 # 32 bit align gdt_desc.address
17264 ENTRY(early_gdt_descr)
17265 .word GDT_ENTRIES*8-1
17266 - .long gdt_page /* Overwritten for secondary CPUs */
17267 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
17268
17269 /*
17270 * The boot_gdt must mirror the equivalent in setup.S and is
17271 @@ -727,5 +831,65 @@ ENTRY(early_gdt_descr)
17272 .align L1_CACHE_BYTES
17273 ENTRY(boot_gdt)
17274 .fill GDT_ENTRY_BOOT_CS,8,0
17275 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
17276 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
17277 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
17278 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
17279 +
17280 + .align PAGE_SIZE_asm
17281 +ENTRY(cpu_gdt_table)
17282 + .rept NR_CPUS
17283 + .quad 0x0000000000000000 /* NULL descriptor */
17284 + .quad 0x0000000000000000 /* 0x0b reserved */
17285 + .quad 0x0000000000000000 /* 0x13 reserved */
17286 + .quad 0x0000000000000000 /* 0x1b reserved */
17287 +
17288 +#ifdef CONFIG_PAX_KERNEXEC
17289 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
17290 +#else
17291 + .quad 0x0000000000000000 /* 0x20 unused */
17292 +#endif
17293 +
17294 + .quad 0x0000000000000000 /* 0x28 unused */
17295 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
17296 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
17297 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
17298 + .quad 0x0000000000000000 /* 0x4b reserved */
17299 + .quad 0x0000000000000000 /* 0x53 reserved */
17300 + .quad 0x0000000000000000 /* 0x5b reserved */
17301 +
17302 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
17303 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
17304 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
17305 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
17306 +
17307 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
17308 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
17309 +
17310 + /*
17311 + * Segments used for calling PnP BIOS have byte granularity.
17312 + * The code segments and data segments have fixed 64k limits,
17313 + * the transfer segment sizes are set at run time.
17314 + */
17315 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
17316 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
17317 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
17318 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
17319 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
17320 +
17321 + /*
17322 + * The APM segments have byte granularity and their bases
17323 + * are set at run time. All have 64k limits.
17324 + */
17325 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
17326 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
17327 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
17328 +
17329 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
17330 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
17331 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
17332 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
17333 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
17334 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
17335 +
17336 + /* Be sure this is zeroed to avoid false validations in Xen */
17337 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
17338 + .endr
17339 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
17340 index 40f4eb3..6d24d9d 100644
17341 --- a/arch/x86/kernel/head_64.S
17342 +++ b/arch/x86/kernel/head_64.S
17343 @@ -19,6 +19,8 @@
17344 #include <asm/cache.h>
17345 #include <asm/processor-flags.h>
17346 #include <asm/percpu.h>
17347 +#include <asm/cpufeature.h>
17348 +#include <asm/alternative-asm.h>
17349
17350 #ifdef CONFIG_PARAVIRT
17351 #include <asm/asm-offsets.h>
17352 @@ -38,6 +40,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
17353 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
17354 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
17355 L3_START_KERNEL = pud_index(__START_KERNEL_map)
17356 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
17357 +L3_VMALLOC_START = pud_index(VMALLOC_START)
17358 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
17359 +L3_VMALLOC_END = pud_index(VMALLOC_END)
17360 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
17361 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
17362
17363 .text
17364 __HEAD
17365 @@ -85,35 +93,23 @@ startup_64:
17366 */
17367 addq %rbp, init_level4_pgt + 0(%rip)
17368 addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
17369 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
17370 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
17371 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
17372 addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
17373
17374 addq %rbp, level3_ident_pgt + 0(%rip)
17375 +#ifndef CONFIG_XEN
17376 + addq %rbp, level3_ident_pgt + 8(%rip)
17377 +#endif
17378
17379 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
17380 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
17381 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
17382 +
17383 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
17384 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8+8)(%rip)
17385
17386 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
17387 -
17388 - /* Add an Identity mapping if I am above 1G */
17389 - leaq _text(%rip), %rdi
17390 - andq $PMD_PAGE_MASK, %rdi
17391 -
17392 - movq %rdi, %rax
17393 - shrq $PUD_SHIFT, %rax
17394 - andq $(PTRS_PER_PUD - 1), %rax
17395 - jz ident_complete
17396 -
17397 - leaq (level2_spare_pgt - __START_KERNEL_map + _KERNPG_TABLE)(%rbp), %rdx
17398 - leaq level3_ident_pgt(%rip), %rbx
17399 - movq %rdx, 0(%rbx, %rax, 8)
17400 -
17401 - movq %rdi, %rax
17402 - shrq $PMD_SHIFT, %rax
17403 - andq $(PTRS_PER_PMD - 1), %rax
17404 - leaq __PAGE_KERNEL_IDENT_LARGE_EXEC(%rdi), %rdx
17405 - leaq level2_spare_pgt(%rip), %rbx
17406 - movq %rdx, 0(%rbx, %rax, 8)
17407 -ident_complete:
17408 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
17409
17410 /*
17411 * Fixup the kernel text+data virtual addresses. Note that
17412 @@ -160,8 +156,8 @@ ENTRY(secondary_startup_64)
17413 * after the boot processor executes this code.
17414 */
17415
17416 - /* Enable PAE mode and PGE */
17417 - movl $(X86_CR4_PAE | X86_CR4_PGE), %eax
17418 + /* Enable PAE mode and PSE/PGE */
17419 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %eax
17420 movq %rax, %cr4
17421
17422 /* Setup early boot stage 4 level pagetables. */
17423 @@ -183,9 +179,17 @@ ENTRY(secondary_startup_64)
17424 movl $MSR_EFER, %ecx
17425 rdmsr
17426 btsl $_EFER_SCE, %eax /* Enable System Call */
17427 - btl $20,%edi /* No Execute supported? */
17428 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
17429 jnc 1f
17430 btsl $_EFER_NX, %eax
17431 + leaq init_level4_pgt(%rip), %rdi
17432 +#ifndef CONFIG_EFI
17433 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
17434 +#endif
17435 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
17436 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
17437 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
17438 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
17439 1: wrmsr /* Make changes effective */
17440
17441 /* Setup cr0 */
17442 @@ -247,6 +251,7 @@ ENTRY(secondary_startup_64)
17443 * jump. In addition we need to ensure %cs is set so we make this
17444 * a far return.
17445 */
17446 + pax_set_fptr_mask
17447 movq initial_code(%rip),%rax
17448 pushq $0 # fake return address to stop unwinder
17449 pushq $__KERNEL_CS # set correct cs
17450 @@ -269,7 +274,7 @@ ENTRY(secondary_startup_64)
17451 bad_address:
17452 jmp bad_address
17453
17454 - .section ".init.text","ax"
17455 + __INIT
17456 #ifdef CONFIG_EARLY_PRINTK
17457 .globl early_idt_handlers
17458 early_idt_handlers:
17459 @@ -314,18 +319,23 @@ ENTRY(early_idt_handler)
17460 #endif /* EARLY_PRINTK */
17461 1: hlt
17462 jmp 1b
17463 + .previous
17464
17465 #ifdef CONFIG_EARLY_PRINTK
17466 + __INITDATA
17467 early_recursion_flag:
17468 .long 0
17469 + .previous
17470
17471 + .section .rodata,"a",@progbits
17472 early_idt_msg:
17473 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
17474 early_idt_ripmsg:
17475 .asciz "RIP %s\n"
17476 + .previous
17477 #endif /* CONFIG_EARLY_PRINTK */
17478 - .previous
17479
17480 + .section .rodata,"a",@progbits
17481 #define NEXT_PAGE(name) \
17482 .balign PAGE_SIZE; \
17483 ENTRY(name)
17484 @@ -338,7 +348,6 @@ ENTRY(name)
17485 i = i + 1 ; \
17486 .endr
17487
17488 - .data
17489 /*
17490 * This default setting generates an ident mapping at address 0x100000
17491 * and a mapping for the kernel that precisely maps virtual address
17492 @@ -349,13 +358,41 @@ NEXT_PAGE(init_level4_pgt)
17493 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
17494 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
17495 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
17496 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
17497 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
17498 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
17499 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
17500 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
17501 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
17502 .org init_level4_pgt + L4_START_KERNEL*8, 0
17503 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
17504 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
17505
17506 +#ifdef CONFIG_PAX_PER_CPU_PGD
17507 +NEXT_PAGE(cpu_pgd)
17508 + .rept NR_CPUS
17509 + .fill 512,8,0
17510 + .endr
17511 +#endif
17512 +
17513 NEXT_PAGE(level3_ident_pgt)
17514 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
17515 +#ifdef CONFIG_XEN
17516 .fill 511,8,0
17517 +#else
17518 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
17519 + .fill 510,8,0
17520 +#endif
17521 +
17522 +NEXT_PAGE(level3_vmalloc_start_pgt)
17523 + .fill 512,8,0
17524 +
17525 +NEXT_PAGE(level3_vmalloc_end_pgt)
17526 + .fill 512,8,0
17527 +
17528 +NEXT_PAGE(level3_vmemmap_pgt)
17529 + .fill L3_VMEMMAP_START,8,0
17530 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
17531
17532 NEXT_PAGE(level3_kernel_pgt)
17533 .fill L3_START_KERNEL,8,0
17534 @@ -363,20 +400,23 @@ NEXT_PAGE(level3_kernel_pgt)
17535 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
17536 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
17537
17538 +NEXT_PAGE(level2_vmemmap_pgt)
17539 + .fill 512,8,0
17540 +
17541 NEXT_PAGE(level2_fixmap_pgt)
17542 - .fill 506,8,0
17543 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
17544 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
17545 - .fill 5,8,0
17546 + .fill 507,8,0
17547 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
17548 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
17549 + .fill 4,8,0
17550
17551 -NEXT_PAGE(level1_fixmap_pgt)
17552 +NEXT_PAGE(level1_vsyscall_pgt)
17553 .fill 512,8,0
17554
17555 -NEXT_PAGE(level2_ident_pgt)
17556 - /* Since I easily can, map the first 1G.
17557 + /* Since I easily can, map the first 2G.
17558 * Don't set NX because code runs from these pages.
17559 */
17560 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
17561 +NEXT_PAGE(level2_ident_pgt)
17562 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
17563
17564 NEXT_PAGE(level2_kernel_pgt)
17565 /*
17566 @@ -389,37 +429,59 @@ NEXT_PAGE(level2_kernel_pgt)
17567 * If you want to increase this then increase MODULES_VADDR
17568 * too.)
17569 */
17570 - PMDS(0, __PAGE_KERNEL_LARGE_EXEC,
17571 - KERNEL_IMAGE_SIZE/PMD_SIZE)
17572 -
17573 -NEXT_PAGE(level2_spare_pgt)
17574 - .fill 512, 8, 0
17575 + PMDS(0, __PAGE_KERNEL_LARGE_EXEC, KERNEL_IMAGE_SIZE/PMD_SIZE)
17576
17577 #undef PMDS
17578 #undef NEXT_PAGE
17579
17580 - .data
17581 + .align PAGE_SIZE
17582 +ENTRY(cpu_gdt_table)
17583 + .rept NR_CPUS
17584 + .quad 0x0000000000000000 /* NULL descriptor */
17585 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
17586 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
17587 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
17588 + .quad 0x00cffb000000ffff /* __USER32_CS */
17589 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
17590 + .quad 0x00affb000000ffff /* __USER_CS */
17591 +
17592 +#ifdef CONFIG_PAX_KERNEXEC
17593 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
17594 +#else
17595 + .quad 0x0 /* unused */
17596 +#endif
17597 +
17598 + .quad 0,0 /* TSS */
17599 + .quad 0,0 /* LDT */
17600 + .quad 0,0,0 /* three TLS descriptors */
17601 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
17602 + /* asm/segment.h:GDT_ENTRIES must match this */
17603 +
17604 + /* zero the remaining page */
17605 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
17606 + .endr
17607 +
17608 .align 16
17609 .globl early_gdt_descr
17610 early_gdt_descr:
17611 .word GDT_ENTRIES*8-1
17612 early_gdt_descr_base:
17613 - .quad INIT_PER_CPU_VAR(gdt_page)
17614 + .quad cpu_gdt_table
17615
17616 ENTRY(phys_base)
17617 /* This must match the first entry in level2_kernel_pgt */
17618 .quad 0x0000000000000000
17619
17620 #include "../../x86/xen/xen-head.S"
17621 -
17622 - .section .bss, "aw", @nobits
17623 +
17624 + .section .rodata,"a",@progbits
17625 .align L1_CACHE_BYTES
17626 ENTRY(idt_table)
17627 - .skip IDT_ENTRIES * 16
17628 + .fill 512,8,0
17629
17630 .align L1_CACHE_BYTES
17631 ENTRY(nmi_idt_table)
17632 - .skip IDT_ENTRIES * 16
17633 + .fill 512,8,0
17634
17635 __PAGE_ALIGNED_BSS
17636 .align PAGE_SIZE
17637 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
17638 index 9c3bd4a..e1d9b35 100644
17639 --- a/arch/x86/kernel/i386_ksyms_32.c
17640 +++ b/arch/x86/kernel/i386_ksyms_32.c
17641 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
17642 EXPORT_SYMBOL(cmpxchg8b_emu);
17643 #endif
17644
17645 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
17646 +
17647 /* Networking helper routines. */
17648 EXPORT_SYMBOL(csum_partial_copy_generic);
17649 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
17650 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
17651
17652 EXPORT_SYMBOL(__get_user_1);
17653 EXPORT_SYMBOL(__get_user_2);
17654 @@ -36,3 +40,7 @@ EXPORT_SYMBOL(strstr);
17655
17656 EXPORT_SYMBOL(csum_partial);
17657 EXPORT_SYMBOL(empty_zero_page);
17658 +
17659 +#ifdef CONFIG_PAX_KERNEXEC
17660 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
17661 +#endif
17662 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
17663 index 6104852..6114160 100644
17664 --- a/arch/x86/kernel/i8259.c
17665 +++ b/arch/x86/kernel/i8259.c
17666 @@ -210,7 +210,7 @@ spurious_8259A_irq:
17667 "spurious 8259A interrupt: IRQ%d.\n", irq);
17668 spurious_irq_mask |= irqmask;
17669 }
17670 - atomic_inc(&irq_err_count);
17671 + atomic_inc_unchecked(&irq_err_count);
17672 /*
17673 * Theoretically we do not have to handle this IRQ,
17674 * but in Linux this does not cause problems and is
17675 diff --git a/arch/x86/kernel/init_task.c b/arch/x86/kernel/init_task.c
17676 index 43e9ccf..44ccf6f 100644
17677 --- a/arch/x86/kernel/init_task.c
17678 +++ b/arch/x86/kernel/init_task.c
17679 @@ -20,8 +20,7 @@ static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
17680 * way process stacks are handled. This is done by having a special
17681 * "init_task" linker map entry..
17682 */
17683 -union thread_union init_thread_union __init_task_data =
17684 - { INIT_THREAD_INFO(init_task) };
17685 +union thread_union init_thread_union __init_task_data;
17686
17687 /*
17688 * Initial task structure.
17689 @@ -38,5 +37,5 @@ EXPORT_SYMBOL(init_task);
17690 * section. Since TSS's are completely CPU-local, we want them
17691 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
17692 */
17693 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
17694 -
17695 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
17696 +EXPORT_SYMBOL(init_tss);
17697 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
17698 index 8c96897..be66bfa 100644
17699 --- a/arch/x86/kernel/ioport.c
17700 +++ b/arch/x86/kernel/ioport.c
17701 @@ -6,6 +6,7 @@
17702 #include <linux/sched.h>
17703 #include <linux/kernel.h>
17704 #include <linux/capability.h>
17705 +#include <linux/security.h>
17706 #include <linux/errno.h>
17707 #include <linux/types.h>
17708 #include <linux/ioport.h>
17709 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
17710
17711 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
17712 return -EINVAL;
17713 +#ifdef CONFIG_GRKERNSEC_IO
17714 + if (turn_on && grsec_disable_privio) {
17715 + gr_handle_ioperm();
17716 + return -EPERM;
17717 + }
17718 +#endif
17719 if (turn_on && !capable(CAP_SYS_RAWIO))
17720 return -EPERM;
17721
17722 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
17723 * because the ->io_bitmap_max value must match the bitmap
17724 * contents:
17725 */
17726 - tss = &per_cpu(init_tss, get_cpu());
17727 + tss = init_tss + get_cpu();
17728
17729 if (turn_on)
17730 bitmap_clear(t->io_bitmap_ptr, from, num);
17731 @@ -102,6 +109,12 @@ long sys_iopl(unsigned int level, struct pt_regs *regs)
17732 return -EINVAL;
17733 /* Trying to gain more privileges? */
17734 if (level > old) {
17735 +#ifdef CONFIG_GRKERNSEC_IO
17736 + if (grsec_disable_privio) {
17737 + gr_handle_iopl();
17738 + return -EPERM;
17739 + }
17740 +#endif
17741 if (!capable(CAP_SYS_RAWIO))
17742 return -EPERM;
17743 }
17744 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
17745 index 7943e0c..dd32c5c 100644
17746 --- a/arch/x86/kernel/irq.c
17747 +++ b/arch/x86/kernel/irq.c
17748 @@ -18,7 +18,7 @@
17749 #include <asm/mce.h>
17750 #include <asm/hw_irq.h>
17751
17752 -atomic_t irq_err_count;
17753 +atomic_unchecked_t irq_err_count;
17754
17755 /* Function pointer for generic interrupt vector handling */
17756 void (*x86_platform_ipi_callback)(void) = NULL;
17757 @@ -121,9 +121,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
17758 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
17759 seq_printf(p, " Machine check polls\n");
17760 #endif
17761 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
17762 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
17763 #if defined(CONFIG_X86_IO_APIC)
17764 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
17765 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
17766 #endif
17767 return 0;
17768 }
17769 @@ -164,10 +164,10 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
17770
17771 u64 arch_irq_stat(void)
17772 {
17773 - u64 sum = atomic_read(&irq_err_count);
17774 + u64 sum = atomic_read_unchecked(&irq_err_count);
17775
17776 #ifdef CONFIG_X86_IO_APIC
17777 - sum += atomic_read(&irq_mis_count);
17778 + sum += atomic_read_unchecked(&irq_mis_count);
17779 #endif
17780 return sum;
17781 }
17782 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
17783 index 40fc861..9b8739b 100644
17784 --- a/arch/x86/kernel/irq_32.c
17785 +++ b/arch/x86/kernel/irq_32.c
17786 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
17787 __asm__ __volatile__("andl %%esp,%0" :
17788 "=r" (sp) : "0" (THREAD_SIZE - 1));
17789
17790 - return sp < (sizeof(struct thread_info) + STACK_WARN);
17791 + return sp < STACK_WARN;
17792 }
17793
17794 static void print_stack_overflow(void)
17795 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
17796 * per-CPU IRQ handling contexts (thread information and stack)
17797 */
17798 union irq_ctx {
17799 - struct thread_info tinfo;
17800 - u32 stack[THREAD_SIZE/sizeof(u32)];
17801 + unsigned long previous_esp;
17802 + u32 stack[THREAD_SIZE/sizeof(u32)];
17803 } __attribute__((aligned(THREAD_SIZE)));
17804
17805 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
17806 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
17807 static inline int
17808 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
17809 {
17810 - union irq_ctx *curctx, *irqctx;
17811 + union irq_ctx *irqctx;
17812 u32 *isp, arg1, arg2;
17813
17814 - curctx = (union irq_ctx *) current_thread_info();
17815 irqctx = __this_cpu_read(hardirq_ctx);
17816
17817 /*
17818 @@ -92,21 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
17819 * handler) we can't do that and just have to keep using the
17820 * current stack (which is the irq stack already after all)
17821 */
17822 - if (unlikely(curctx == irqctx))
17823 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
17824 return 0;
17825
17826 /* build the stack frame on the IRQ stack */
17827 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
17828 - irqctx->tinfo.task = curctx->tinfo.task;
17829 - irqctx->tinfo.previous_esp = current_stack_pointer;
17830 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
17831 + irqctx->previous_esp = current_stack_pointer;
17832
17833 - /*
17834 - * Copy the softirq bits in preempt_count so that the
17835 - * softirq checks work in the hardirq context.
17836 - */
17837 - irqctx->tinfo.preempt_count =
17838 - (irqctx->tinfo.preempt_count & ~SOFTIRQ_MASK) |
17839 - (curctx->tinfo.preempt_count & SOFTIRQ_MASK);
17840 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17841 + __set_fs(MAKE_MM_SEG(0));
17842 +#endif
17843
17844 if (unlikely(overflow))
17845 call_on_stack(print_stack_overflow, isp);
17846 @@ -118,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
17847 : "0" (irq), "1" (desc), "2" (isp),
17848 "D" (desc->handle_irq)
17849 : "memory", "cc", "ecx");
17850 +
17851 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17852 + __set_fs(current_thread_info()->addr_limit);
17853 +#endif
17854 +
17855 return 1;
17856 }
17857
17858 @@ -126,29 +125,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
17859 */
17860 void __cpuinit irq_ctx_init(int cpu)
17861 {
17862 - union irq_ctx *irqctx;
17863 -
17864 if (per_cpu(hardirq_ctx, cpu))
17865 return;
17866
17867 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
17868 - THREAD_FLAGS,
17869 - THREAD_ORDER));
17870 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
17871 - irqctx->tinfo.cpu = cpu;
17872 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
17873 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
17874 -
17875 - per_cpu(hardirq_ctx, cpu) = irqctx;
17876 -
17877 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
17878 - THREAD_FLAGS,
17879 - THREAD_ORDER));
17880 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
17881 - irqctx->tinfo.cpu = cpu;
17882 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
17883 -
17884 - per_cpu(softirq_ctx, cpu) = irqctx;
17885 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREAD_FLAGS, THREAD_ORDER));
17886 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREAD_FLAGS, THREAD_ORDER));
17887
17888 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
17889 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
17890 @@ -157,7 +138,6 @@ void __cpuinit irq_ctx_init(int cpu)
17891 asmlinkage void do_softirq(void)
17892 {
17893 unsigned long flags;
17894 - struct thread_info *curctx;
17895 union irq_ctx *irqctx;
17896 u32 *isp;
17897
17898 @@ -167,15 +147,22 @@ asmlinkage void do_softirq(void)
17899 local_irq_save(flags);
17900
17901 if (local_softirq_pending()) {
17902 - curctx = current_thread_info();
17903 irqctx = __this_cpu_read(softirq_ctx);
17904 - irqctx->tinfo.task = curctx->task;
17905 - irqctx->tinfo.previous_esp = current_stack_pointer;
17906 + irqctx->previous_esp = current_stack_pointer;
17907
17908 /* build the stack frame on the softirq stack */
17909 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
17910 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
17911 +
17912 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17913 + __set_fs(MAKE_MM_SEG(0));
17914 +#endif
17915
17916 call_on_stack(__do_softirq, isp);
17917 +
17918 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17919 + __set_fs(current_thread_info()->addr_limit);
17920 +#endif
17921 +
17922 /*
17923 * Shouldn't happen, we returned above if in_interrupt():
17924 */
17925 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
17926 index d04d3ec..ea4b374 100644
17927 --- a/arch/x86/kernel/irq_64.c
17928 +++ b/arch/x86/kernel/irq_64.c
17929 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
17930 u64 estack_top, estack_bottom;
17931 u64 curbase = (u64)task_stack_page(current);
17932
17933 - if (user_mode_vm(regs))
17934 + if (user_mode(regs))
17935 return;
17936
17937 if (regs->sp >= curbase + sizeof(struct thread_info) +
17938 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
17939 index 90fcf62..e682cdd 100644
17940 --- a/arch/x86/kernel/kdebugfs.c
17941 +++ b/arch/x86/kernel/kdebugfs.c
17942 @@ -28,6 +28,8 @@ struct setup_data_node {
17943 };
17944
17945 static ssize_t setup_data_read(struct file *file, char __user *user_buf,
17946 + size_t count, loff_t *ppos) __size_overflow(3);
17947 +static ssize_t setup_data_read(struct file *file, char __user *user_buf,
17948 size_t count, loff_t *ppos)
17949 {
17950 struct setup_data_node *node = file->private_data;
17951 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
17952 index 2f45c4c..d95504f 100644
17953 --- a/arch/x86/kernel/kgdb.c
17954 +++ b/arch/x86/kernel/kgdb.c
17955 @@ -126,11 +126,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
17956 #ifdef CONFIG_X86_32
17957 switch (regno) {
17958 case GDB_SS:
17959 - if (!user_mode_vm(regs))
17960 + if (!user_mode(regs))
17961 *(unsigned long *)mem = __KERNEL_DS;
17962 break;
17963 case GDB_SP:
17964 - if (!user_mode_vm(regs))
17965 + if (!user_mode(regs))
17966 *(unsigned long *)mem = kernel_stack_pointer(regs);
17967 break;
17968 case GDB_GS:
17969 @@ -475,12 +475,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
17970 case 'k':
17971 /* clear the trace bit */
17972 linux_regs->flags &= ~X86_EFLAGS_TF;
17973 - atomic_set(&kgdb_cpu_doing_single_step, -1);
17974 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
17975
17976 /* set the trace bit if we're stepping */
17977 if (remcomInBuffer[0] == 's') {
17978 linux_regs->flags |= X86_EFLAGS_TF;
17979 - atomic_set(&kgdb_cpu_doing_single_step,
17980 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
17981 raw_smp_processor_id());
17982 }
17983
17984 @@ -545,7 +545,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
17985
17986 switch (cmd) {
17987 case DIE_DEBUG:
17988 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
17989 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
17990 if (user_mode(regs))
17991 return single_step_cont(regs, args);
17992 break;
17993 diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
17994 index 7da647d..56fe348 100644
17995 --- a/arch/x86/kernel/kprobes.c
17996 +++ b/arch/x86/kernel/kprobes.c
17997 @@ -118,8 +118,11 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
17998 } __attribute__((packed)) *insn;
17999
18000 insn = (struct __arch_relative_insn *)from;
18001 +
18002 + pax_open_kernel();
18003 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
18004 insn->op = op;
18005 + pax_close_kernel();
18006 }
18007
18008 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
18009 @@ -156,7 +159,7 @@ static int __kprobes can_boost(kprobe_opcode_t *opcodes)
18010 kprobe_opcode_t opcode;
18011 kprobe_opcode_t *orig_opcodes = opcodes;
18012
18013 - if (search_exception_tables((unsigned long)opcodes))
18014 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
18015 return 0; /* Page fault may occur on this address. */
18016
18017 retry:
18018 @@ -317,7 +320,9 @@ static int __kprobes __copy_instruction(u8 *dest, u8 *src, int recover)
18019 }
18020 }
18021 insn_get_length(&insn);
18022 + pax_open_kernel();
18023 memcpy(dest, insn.kaddr, insn.length);
18024 + pax_close_kernel();
18025
18026 #ifdef CONFIG_X86_64
18027 if (insn_rip_relative(&insn)) {
18028 @@ -341,7 +346,9 @@ static int __kprobes __copy_instruction(u8 *dest, u8 *src, int recover)
18029 (u8 *) dest;
18030 BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */
18031 disp = (u8 *) dest + insn_offset_displacement(&insn);
18032 + pax_open_kernel();
18033 *(s32 *) disp = (s32) newdisp;
18034 + pax_close_kernel();
18035 }
18036 #endif
18037 return insn.length;
18038 @@ -355,12 +362,12 @@ static void __kprobes arch_copy_kprobe(struct kprobe *p)
18039 */
18040 __copy_instruction(p->ainsn.insn, p->addr, 0);
18041
18042 - if (can_boost(p->addr))
18043 + if (can_boost(ktla_ktva(p->addr)))
18044 p->ainsn.boostable = 0;
18045 else
18046 p->ainsn.boostable = -1;
18047
18048 - p->opcode = *p->addr;
18049 + p->opcode = *(ktla_ktva(p->addr));
18050 }
18051
18052 int __kprobes arch_prepare_kprobe(struct kprobe *p)
18053 @@ -477,7 +484,7 @@ static void __kprobes setup_singlestep(struct kprobe *p, struct pt_regs *regs,
18054 * nor set current_kprobe, because it doesn't use single
18055 * stepping.
18056 */
18057 - regs->ip = (unsigned long)p->ainsn.insn;
18058 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
18059 preempt_enable_no_resched();
18060 return;
18061 }
18062 @@ -496,7 +503,7 @@ static void __kprobes setup_singlestep(struct kprobe *p, struct pt_regs *regs,
18063 if (p->opcode == BREAKPOINT_INSTRUCTION)
18064 regs->ip = (unsigned long)p->addr;
18065 else
18066 - regs->ip = (unsigned long)p->ainsn.insn;
18067 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
18068 }
18069
18070 /*
18071 @@ -575,7 +582,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
18072 setup_singlestep(p, regs, kcb, 0);
18073 return 1;
18074 }
18075 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
18076 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
18077 /*
18078 * The breakpoint instruction was removed right
18079 * after we hit it. Another cpu has removed
18080 @@ -683,6 +690,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
18081 " movq %rax, 152(%rsp)\n"
18082 RESTORE_REGS_STRING
18083 " popfq\n"
18084 +#ifdef KERNEXEC_PLUGIN
18085 + " btsq $63,(%rsp)\n"
18086 +#endif
18087 #else
18088 " pushf\n"
18089 SAVE_REGS_STRING
18090 @@ -820,7 +830,7 @@ static void __kprobes resume_execution(struct kprobe *p,
18091 struct pt_regs *regs, struct kprobe_ctlblk *kcb)
18092 {
18093 unsigned long *tos = stack_addr(regs);
18094 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
18095 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
18096 unsigned long orig_ip = (unsigned long)p->addr;
18097 kprobe_opcode_t *insn = p->ainsn.insn;
18098
18099 @@ -1002,7 +1012,7 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
18100 struct die_args *args = data;
18101 int ret = NOTIFY_DONE;
18102
18103 - if (args->regs && user_mode_vm(args->regs))
18104 + if (args->regs && user_mode(args->regs))
18105 return ret;
18106
18107 switch (val) {
18108 @@ -1384,7 +1394,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
18109 * Verify if the address gap is in 2GB range, because this uses
18110 * a relative jump.
18111 */
18112 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
18113 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
18114 if (abs(rel) > 0x7fffffff)
18115 return -ERANGE;
18116
18117 @@ -1405,11 +1415,11 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
18118 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
18119
18120 /* Set probe function call */
18121 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
18122 + synthesize_relcall(buf + TMPL_CALL_IDX, ktla_ktva(optimized_callback));
18123
18124 /* Set returning jmp instruction at the tail of out-of-line buffer */
18125 synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
18126 - (u8 *)op->kp.addr + op->optinsn.size);
18127 + (u8 *)ktla_ktva(op->kp.addr) + op->optinsn.size);
18128
18129 flush_icache_range((unsigned long) buf,
18130 (unsigned long) buf + TMPL_END_IDX +
18131 @@ -1431,7 +1441,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
18132 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
18133
18134 /* Backup instructions which will be replaced by jump address */
18135 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
18136 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
18137 RELATIVE_ADDR_SIZE);
18138
18139 insn_buf[0] = RELATIVEJUMP_OPCODE;
18140 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
18141 index ea69726..604d066 100644
18142 --- a/arch/x86/kernel/ldt.c
18143 +++ b/arch/x86/kernel/ldt.c
18144 @@ -67,13 +67,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
18145 if (reload) {
18146 #ifdef CONFIG_SMP
18147 preempt_disable();
18148 - load_LDT(pc);
18149 + load_LDT_nolock(pc);
18150 if (!cpumask_equal(mm_cpumask(current->mm),
18151 cpumask_of(smp_processor_id())))
18152 smp_call_function(flush_ldt, current->mm, 1);
18153 preempt_enable();
18154 #else
18155 - load_LDT(pc);
18156 + load_LDT_nolock(pc);
18157 #endif
18158 }
18159 if (oldsize) {
18160 @@ -95,7 +95,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
18161 return err;
18162
18163 for (i = 0; i < old->size; i++)
18164 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
18165 + write_ldt_entry(new->ldt, i, old->ldt + i);
18166 return 0;
18167 }
18168
18169 @@ -116,6 +116,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
18170 retval = copy_ldt(&mm->context, &old_mm->context);
18171 mutex_unlock(&old_mm->context.lock);
18172 }
18173 +
18174 + if (tsk == current) {
18175 + mm->context.vdso = 0;
18176 +
18177 +#ifdef CONFIG_X86_32
18178 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
18179 + mm->context.user_cs_base = 0UL;
18180 + mm->context.user_cs_limit = ~0UL;
18181 +
18182 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
18183 + cpus_clear(mm->context.cpu_user_cs_mask);
18184 +#endif
18185 +
18186 +#endif
18187 +#endif
18188 +
18189 + }
18190 +
18191 return retval;
18192 }
18193
18194 @@ -230,6 +248,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
18195 }
18196 }
18197
18198 +#ifdef CONFIG_PAX_SEGMEXEC
18199 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
18200 + error = -EINVAL;
18201 + goto out_unlock;
18202 + }
18203 +#endif
18204 +
18205 fill_ldt(&ldt, &ldt_info);
18206 if (oldmode)
18207 ldt.avl = 0;
18208 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
18209 index a3fa43b..8966f4c 100644
18210 --- a/arch/x86/kernel/machine_kexec_32.c
18211 +++ b/arch/x86/kernel/machine_kexec_32.c
18212 @@ -27,7 +27,7 @@
18213 #include <asm/cacheflush.h>
18214 #include <asm/debugreg.h>
18215
18216 -static void set_idt(void *newidt, __u16 limit)
18217 +static void set_idt(struct desc_struct *newidt, __u16 limit)
18218 {
18219 struct desc_ptr curidt;
18220
18221 @@ -39,7 +39,7 @@ static void set_idt(void *newidt, __u16 limit)
18222 }
18223
18224
18225 -static void set_gdt(void *newgdt, __u16 limit)
18226 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
18227 {
18228 struct desc_ptr curgdt;
18229
18230 @@ -217,7 +217,7 @@ void machine_kexec(struct kimage *image)
18231 }
18232
18233 control_page = page_address(image->control_code_page);
18234 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
18235 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
18236
18237 relocate_kernel_ptr = control_page;
18238 page_list[PA_CONTROL_PAGE] = __pa(control_page);
18239 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
18240 index 3ca42d0..7cff8cc 100644
18241 --- a/arch/x86/kernel/microcode_intel.c
18242 +++ b/arch/x86/kernel/microcode_intel.c
18243 @@ -436,13 +436,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device)
18244
18245 static int get_ucode_user(void *to, const void *from, size_t n)
18246 {
18247 - return copy_from_user(to, from, n);
18248 + return copy_from_user(to, (const void __force_user *)from, n);
18249 }
18250
18251 static enum ucode_state
18252 request_microcode_user(int cpu, const void __user *buf, size_t size)
18253 {
18254 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
18255 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
18256 }
18257
18258 static void microcode_fini_cpu(int cpu)
18259 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
18260 index 925179f..267ac7a 100644
18261 --- a/arch/x86/kernel/module.c
18262 +++ b/arch/x86/kernel/module.c
18263 @@ -36,15 +36,60 @@
18264 #define DEBUGP(fmt...)
18265 #endif
18266
18267 -void *module_alloc(unsigned long size)
18268 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
18269 {
18270 - if (PAGE_ALIGN(size) > MODULES_LEN)
18271 + if (size == 0 || PAGE_ALIGN(size) > MODULES_LEN)
18272 return NULL;
18273 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
18274 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
18275 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
18276 -1, __builtin_return_address(0));
18277 }
18278
18279 +void *module_alloc(unsigned long size)
18280 +{
18281 +
18282 +#ifdef CONFIG_PAX_KERNEXEC
18283 + return __module_alloc(size, PAGE_KERNEL);
18284 +#else
18285 + return __module_alloc(size, PAGE_KERNEL_EXEC);
18286 +#endif
18287 +
18288 +}
18289 +
18290 +#ifdef CONFIG_PAX_KERNEXEC
18291 +#ifdef CONFIG_X86_32
18292 +void *module_alloc_exec(unsigned long size)
18293 +{
18294 + struct vm_struct *area;
18295 +
18296 + if (size == 0)
18297 + return NULL;
18298 +
18299 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
18300 + return area ? area->addr : NULL;
18301 +}
18302 +EXPORT_SYMBOL(module_alloc_exec);
18303 +
18304 +void module_free_exec(struct module *mod, void *module_region)
18305 +{
18306 + vunmap(module_region);
18307 +}
18308 +EXPORT_SYMBOL(module_free_exec);
18309 +#else
18310 +void module_free_exec(struct module *mod, void *module_region)
18311 +{
18312 + module_free(mod, module_region);
18313 +}
18314 +EXPORT_SYMBOL(module_free_exec);
18315 +
18316 +void *module_alloc_exec(unsigned long size)
18317 +{
18318 + return __module_alloc(size, PAGE_KERNEL_RX);
18319 +}
18320 +EXPORT_SYMBOL(module_alloc_exec);
18321 +#endif
18322 +#endif
18323 +
18324 #ifdef CONFIG_X86_32
18325 int apply_relocate(Elf32_Shdr *sechdrs,
18326 const char *strtab,
18327 @@ -55,14 +100,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
18328 unsigned int i;
18329 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
18330 Elf32_Sym *sym;
18331 - uint32_t *location;
18332 + uint32_t *plocation, location;
18333
18334 DEBUGP("Applying relocate section %u to %u\n", relsec,
18335 sechdrs[relsec].sh_info);
18336 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
18337 /* This is where to make the change */
18338 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
18339 - + rel[i].r_offset;
18340 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
18341 + location = (uint32_t)plocation;
18342 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
18343 + plocation = ktla_ktva((void *)plocation);
18344 /* This is the symbol it is referring to. Note that all
18345 undefined symbols have been resolved. */
18346 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
18347 @@ -71,11 +118,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
18348 switch (ELF32_R_TYPE(rel[i].r_info)) {
18349 case R_386_32:
18350 /* We add the value into the location given */
18351 - *location += sym->st_value;
18352 + pax_open_kernel();
18353 + *plocation += sym->st_value;
18354 + pax_close_kernel();
18355 break;
18356 case R_386_PC32:
18357 /* Add the value, subtract its postition */
18358 - *location += sym->st_value - (uint32_t)location;
18359 + pax_open_kernel();
18360 + *plocation += sym->st_value - location;
18361 + pax_close_kernel();
18362 break;
18363 default:
18364 printk(KERN_ERR "module %s: Unknown relocation: %u\n",
18365 @@ -120,21 +171,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
18366 case R_X86_64_NONE:
18367 break;
18368 case R_X86_64_64:
18369 + pax_open_kernel();
18370 *(u64 *)loc = val;
18371 + pax_close_kernel();
18372 break;
18373 case R_X86_64_32:
18374 + pax_open_kernel();
18375 *(u32 *)loc = val;
18376 + pax_close_kernel();
18377 if (val != *(u32 *)loc)
18378 goto overflow;
18379 break;
18380 case R_X86_64_32S:
18381 + pax_open_kernel();
18382 *(s32 *)loc = val;
18383 + pax_close_kernel();
18384 if ((s64)val != *(s32 *)loc)
18385 goto overflow;
18386 break;
18387 case R_X86_64_PC32:
18388 val -= (u64)loc;
18389 + pax_open_kernel();
18390 *(u32 *)loc = val;
18391 + pax_close_kernel();
18392 +
18393 #if 0
18394 if ((s64)val != *(s32 *)loc)
18395 goto overflow;
18396 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
18397 index 47acaf3..ec48ab6 100644
18398 --- a/arch/x86/kernel/nmi.c
18399 +++ b/arch/x86/kernel/nmi.c
18400 @@ -505,6 +505,17 @@ static inline void nmi_nesting_postprocess(void)
18401 dotraplinkage notrace __kprobes void
18402 do_nmi(struct pt_regs *regs, long error_code)
18403 {
18404 +
18405 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18406 + if (!user_mode(regs)) {
18407 + unsigned long cs = regs->cs & 0xFFFF;
18408 + unsigned long ip = ktva_ktla(regs->ip);
18409 +
18410 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
18411 + regs->ip = ip;
18412 + }
18413 +#endif
18414 +
18415 nmi_nesting_preprocess(regs);
18416
18417 nmi_enter();
18418 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
18419 index 676b8c7..870ba04 100644
18420 --- a/arch/x86/kernel/paravirt-spinlocks.c
18421 +++ b/arch/x86/kernel/paravirt-spinlocks.c
18422 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
18423 arch_spin_lock(lock);
18424 }
18425
18426 -struct pv_lock_ops pv_lock_ops = {
18427 +struct pv_lock_ops pv_lock_ops __read_only = {
18428 #ifdef CONFIG_SMP
18429 .spin_is_locked = __ticket_spin_is_locked,
18430 .spin_is_contended = __ticket_spin_is_contended,
18431 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
18432 index d90272e..6bb013b 100644
18433 --- a/arch/x86/kernel/paravirt.c
18434 +++ b/arch/x86/kernel/paravirt.c
18435 @@ -53,6 +53,9 @@ u64 _paravirt_ident_64(u64 x)
18436 {
18437 return x;
18438 }
18439 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
18440 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
18441 +#endif
18442
18443 void __init default_banner(void)
18444 {
18445 @@ -145,15 +148,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
18446 if (opfunc == NULL)
18447 /* If there's no function, patch it with a ud2a (BUG) */
18448 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
18449 - else if (opfunc == _paravirt_nop)
18450 + else if (opfunc == (void *)_paravirt_nop)
18451 /* If the operation is a nop, then nop the callsite */
18452 ret = paravirt_patch_nop();
18453
18454 /* identity functions just return their single argument */
18455 - else if (opfunc == _paravirt_ident_32)
18456 + else if (opfunc == (void *)_paravirt_ident_32)
18457 ret = paravirt_patch_ident_32(insnbuf, len);
18458 - else if (opfunc == _paravirt_ident_64)
18459 + else if (opfunc == (void *)_paravirt_ident_64)
18460 ret = paravirt_patch_ident_64(insnbuf, len);
18461 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
18462 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
18463 + ret = paravirt_patch_ident_64(insnbuf, len);
18464 +#endif
18465
18466 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
18467 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
18468 @@ -178,7 +185,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
18469 if (insn_len > len || start == NULL)
18470 insn_len = len;
18471 else
18472 - memcpy(insnbuf, start, insn_len);
18473 + memcpy(insnbuf, ktla_ktva(start), insn_len);
18474
18475 return insn_len;
18476 }
18477 @@ -302,7 +309,7 @@ void arch_flush_lazy_mmu_mode(void)
18478 preempt_enable();
18479 }
18480
18481 -struct pv_info pv_info = {
18482 +struct pv_info pv_info __read_only = {
18483 .name = "bare hardware",
18484 .paravirt_enabled = 0,
18485 .kernel_rpl = 0,
18486 @@ -313,16 +320,16 @@ struct pv_info pv_info = {
18487 #endif
18488 };
18489
18490 -struct pv_init_ops pv_init_ops = {
18491 +struct pv_init_ops pv_init_ops __read_only = {
18492 .patch = native_patch,
18493 };
18494
18495 -struct pv_time_ops pv_time_ops = {
18496 +struct pv_time_ops pv_time_ops __read_only = {
18497 .sched_clock = native_sched_clock,
18498 .steal_clock = native_steal_clock,
18499 };
18500
18501 -struct pv_irq_ops pv_irq_ops = {
18502 +struct pv_irq_ops pv_irq_ops __read_only = {
18503 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
18504 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
18505 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
18506 @@ -334,7 +341,7 @@ struct pv_irq_ops pv_irq_ops = {
18507 #endif
18508 };
18509
18510 -struct pv_cpu_ops pv_cpu_ops = {
18511 +struct pv_cpu_ops pv_cpu_ops __read_only = {
18512 .cpuid = native_cpuid,
18513 .get_debugreg = native_get_debugreg,
18514 .set_debugreg = native_set_debugreg,
18515 @@ -395,21 +402,26 @@ struct pv_cpu_ops pv_cpu_ops = {
18516 .end_context_switch = paravirt_nop,
18517 };
18518
18519 -struct pv_apic_ops pv_apic_ops = {
18520 +struct pv_apic_ops pv_apic_ops __read_only = {
18521 #ifdef CONFIG_X86_LOCAL_APIC
18522 .startup_ipi_hook = paravirt_nop,
18523 #endif
18524 };
18525
18526 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
18527 +#ifdef CONFIG_X86_32
18528 +#ifdef CONFIG_X86_PAE
18529 +/* 64-bit pagetable entries */
18530 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
18531 +#else
18532 /* 32-bit pagetable entries */
18533 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
18534 +#endif
18535 #else
18536 /* 64-bit pagetable entries */
18537 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
18538 #endif
18539
18540 -struct pv_mmu_ops pv_mmu_ops = {
18541 +struct pv_mmu_ops pv_mmu_ops __read_only = {
18542
18543 .read_cr2 = native_read_cr2,
18544 .write_cr2 = native_write_cr2,
18545 @@ -459,6 +471,7 @@ struct pv_mmu_ops pv_mmu_ops = {
18546 .make_pud = PTE_IDENT,
18547
18548 .set_pgd = native_set_pgd,
18549 + .set_pgd_batched = native_set_pgd_batched,
18550 #endif
18551 #endif /* PAGETABLE_LEVELS >= 3 */
18552
18553 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
18554 },
18555
18556 .set_fixmap = native_set_fixmap,
18557 +
18558 +#ifdef CONFIG_PAX_KERNEXEC
18559 + .pax_open_kernel = native_pax_open_kernel,
18560 + .pax_close_kernel = native_pax_close_kernel,
18561 +#endif
18562 +
18563 };
18564
18565 EXPORT_SYMBOL_GPL(pv_time_ops);
18566 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
18567 index 35ccf75..7a15747 100644
18568 --- a/arch/x86/kernel/pci-iommu_table.c
18569 +++ b/arch/x86/kernel/pci-iommu_table.c
18570 @@ -2,7 +2,7 @@
18571 #include <asm/iommu_table.h>
18572 #include <linux/string.h>
18573 #include <linux/kallsyms.h>
18574 -
18575 +#include <linux/sched.h>
18576
18577 #define DEBUG 1
18578
18579 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
18580 index 15763af..da59ada 100644
18581 --- a/arch/x86/kernel/process.c
18582 +++ b/arch/x86/kernel/process.c
18583 @@ -48,16 +48,33 @@ void free_thread_xstate(struct task_struct *tsk)
18584
18585 void free_thread_info(struct thread_info *ti)
18586 {
18587 - free_thread_xstate(ti->task);
18588 free_pages((unsigned long)ti, THREAD_ORDER);
18589 }
18590
18591 +static struct kmem_cache *task_struct_cachep;
18592 +
18593 void arch_task_cache_init(void)
18594 {
18595 - task_xstate_cachep =
18596 - kmem_cache_create("task_xstate", xstate_size,
18597 + /* create a slab on which task_structs can be allocated */
18598 + task_struct_cachep =
18599 + kmem_cache_create("task_struct", sizeof(struct task_struct),
18600 + ARCH_MIN_TASKALIGN, SLAB_PANIC | SLAB_NOTRACK, NULL);
18601 +
18602 + task_xstate_cachep =
18603 + kmem_cache_create("task_xstate", xstate_size,
18604 __alignof__(union thread_xstate),
18605 - SLAB_PANIC | SLAB_NOTRACK, NULL);
18606 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
18607 +}
18608 +
18609 +struct task_struct *alloc_task_struct_node(int node)
18610 +{
18611 + return kmem_cache_alloc_node(task_struct_cachep, GFP_KERNEL, node);
18612 +}
18613 +
18614 +void free_task_struct(struct task_struct *task)
18615 +{
18616 + free_thread_xstate(task);
18617 + kmem_cache_free(task_struct_cachep, task);
18618 }
18619
18620 /*
18621 @@ -70,7 +87,7 @@ void exit_thread(void)
18622 unsigned long *bp = t->io_bitmap_ptr;
18623
18624 if (bp) {
18625 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
18626 + struct tss_struct *tss = init_tss + get_cpu();
18627
18628 t->io_bitmap_ptr = NULL;
18629 clear_thread_flag(TIF_IO_BITMAP);
18630 @@ -106,7 +123,7 @@ void show_regs_common(void)
18631
18632 printk(KERN_CONT "\n");
18633 printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s",
18634 - current->pid, current->comm, print_tainted(),
18635 + task_pid_nr(current), current->comm, print_tainted(),
18636 init_utsname()->release,
18637 (int)strcspn(init_utsname()->version, " "),
18638 init_utsname()->version);
18639 @@ -120,6 +137,9 @@ void flush_thread(void)
18640 {
18641 struct task_struct *tsk = current;
18642
18643 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
18644 + loadsegment(gs, 0);
18645 +#endif
18646 flush_ptrace_hw_breakpoint(tsk);
18647 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
18648 /*
18649 @@ -282,10 +302,10 @@ int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
18650 regs.di = (unsigned long) arg;
18651
18652 #ifdef CONFIG_X86_32
18653 - regs.ds = __USER_DS;
18654 - regs.es = __USER_DS;
18655 + regs.ds = __KERNEL_DS;
18656 + regs.es = __KERNEL_DS;
18657 regs.fs = __KERNEL_PERCPU;
18658 - regs.gs = __KERNEL_STACK_CANARY;
18659 + savesegment(gs, regs.gs);
18660 #else
18661 regs.ss = __KERNEL_DS;
18662 #endif
18663 @@ -411,7 +431,7 @@ bool set_pm_idle_to_default(void)
18664
18665 return ret;
18666 }
18667 -void stop_this_cpu(void *dummy)
18668 +__noreturn void stop_this_cpu(void *dummy)
18669 {
18670 local_irq_disable();
18671 /*
18672 @@ -653,16 +673,37 @@ static int __init idle_setup(char *str)
18673 }
18674 early_param("idle", idle_setup);
18675
18676 -unsigned long arch_align_stack(unsigned long sp)
18677 +#ifdef CONFIG_PAX_RANDKSTACK
18678 +void pax_randomize_kstack(struct pt_regs *regs)
18679 {
18680 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
18681 - sp -= get_random_int() % 8192;
18682 - return sp & ~0xf;
18683 -}
18684 + struct thread_struct *thread = &current->thread;
18685 + unsigned long time;
18686
18687 -unsigned long arch_randomize_brk(struct mm_struct *mm)
18688 -{
18689 - unsigned long range_end = mm->brk + 0x02000000;
18690 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
18691 -}
18692 + if (!randomize_va_space)
18693 + return;
18694 +
18695 + if (v8086_mode(regs))
18696 + return;
18697
18698 + rdtscl(time);
18699 +
18700 + /* P4 seems to return a 0 LSB, ignore it */
18701 +#ifdef CONFIG_MPENTIUM4
18702 + time &= 0x3EUL;
18703 + time <<= 2;
18704 +#elif defined(CONFIG_X86_64)
18705 + time &= 0xFUL;
18706 + time <<= 4;
18707 +#else
18708 + time &= 0x1FUL;
18709 + time <<= 3;
18710 +#endif
18711 +
18712 + thread->sp0 ^= time;
18713 + load_sp0(init_tss + smp_processor_id(), thread);
18714 +
18715 +#ifdef CONFIG_X86_64
18716 + percpu_write(kernel_stack, thread->sp0);
18717 +#endif
18718 +}
18719 +#endif
18720 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
18721 index c08d1ff..6ae1c81 100644
18722 --- a/arch/x86/kernel/process_32.c
18723 +++ b/arch/x86/kernel/process_32.c
18724 @@ -67,6 +67,7 @@ asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
18725 unsigned long thread_saved_pc(struct task_struct *tsk)
18726 {
18727 return ((unsigned long *)tsk->thread.sp)[3];
18728 +//XXX return tsk->thread.eip;
18729 }
18730
18731 #ifndef CONFIG_SMP
18732 @@ -132,15 +133,14 @@ void __show_regs(struct pt_regs *regs, int all)
18733 unsigned long sp;
18734 unsigned short ss, gs;
18735
18736 - if (user_mode_vm(regs)) {
18737 + if (user_mode(regs)) {
18738 sp = regs->sp;
18739 ss = regs->ss & 0xffff;
18740 - gs = get_user_gs(regs);
18741 } else {
18742 sp = kernel_stack_pointer(regs);
18743 savesegment(ss, ss);
18744 - savesegment(gs, gs);
18745 }
18746 + gs = get_user_gs(regs);
18747
18748 show_regs_common();
18749
18750 @@ -202,13 +202,14 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
18751 struct task_struct *tsk;
18752 int err;
18753
18754 - childregs = task_pt_regs(p);
18755 + childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
18756 *childregs = *regs;
18757 childregs->ax = 0;
18758 childregs->sp = sp;
18759
18760 p->thread.sp = (unsigned long) childregs;
18761 p->thread.sp0 = (unsigned long) (childregs+1);
18762 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
18763
18764 p->thread.ip = (unsigned long) ret_from_fork;
18765
18766 @@ -299,7 +300,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
18767 struct thread_struct *prev = &prev_p->thread,
18768 *next = &next_p->thread;
18769 int cpu = smp_processor_id();
18770 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
18771 + struct tss_struct *tss = init_tss + cpu;
18772 fpu_switch_t fpu;
18773
18774 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
18775 @@ -323,6 +324,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
18776 */
18777 lazy_save_gs(prev->gs);
18778
18779 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18780 + __set_fs(task_thread_info(next_p)->addr_limit);
18781 +#endif
18782 +
18783 /*
18784 * Load the per-thread Thread-Local Storage descriptor.
18785 */
18786 @@ -353,6 +358,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
18787 */
18788 arch_end_context_switch(next_p);
18789
18790 + percpu_write(current_task, next_p);
18791 + percpu_write(current_tinfo, &next_p->tinfo);
18792 +
18793 /*
18794 * Restore %gs if needed (which is common)
18795 */
18796 @@ -361,8 +369,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
18797
18798 switch_fpu_finish(next_p, fpu);
18799
18800 - percpu_write(current_task, next_p);
18801 -
18802 return prev_p;
18803 }
18804
18805 @@ -392,4 +398,3 @@ unsigned long get_wchan(struct task_struct *p)
18806 } while (count++ < 16);
18807 return 0;
18808 }
18809 -
18810 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
18811 index cfa5c90..4facd28 100644
18812 --- a/arch/x86/kernel/process_64.c
18813 +++ b/arch/x86/kernel/process_64.c
18814 @@ -89,7 +89,7 @@ static void __exit_idle(void)
18815 void exit_idle(void)
18816 {
18817 /* idle loop has pid 0 */
18818 - if (current->pid)
18819 + if (task_pid_nr(current))
18820 return;
18821 __exit_idle();
18822 }
18823 @@ -270,8 +270,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
18824 struct pt_regs *childregs;
18825 struct task_struct *me = current;
18826
18827 - childregs = ((struct pt_regs *)
18828 - (THREAD_SIZE + task_stack_page(p))) - 1;
18829 + childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 16;
18830 *childregs = *regs;
18831
18832 childregs->ax = 0;
18833 @@ -283,6 +282,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
18834 p->thread.sp = (unsigned long) childregs;
18835 p->thread.sp0 = (unsigned long) (childregs+1);
18836 p->thread.usersp = me->thread.usersp;
18837 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
18838
18839 set_tsk_thread_flag(p, TIF_FORK);
18840
18841 @@ -385,7 +385,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
18842 struct thread_struct *prev = &prev_p->thread;
18843 struct thread_struct *next = &next_p->thread;
18844 int cpu = smp_processor_id();
18845 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
18846 + struct tss_struct *tss = init_tss + cpu;
18847 unsigned fsindex, gsindex;
18848 fpu_switch_t fpu;
18849
18850 @@ -467,10 +467,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
18851 prev->usersp = percpu_read(old_rsp);
18852 percpu_write(old_rsp, next->usersp);
18853 percpu_write(current_task, next_p);
18854 + percpu_write(current_tinfo, &next_p->tinfo);
18855
18856 - percpu_write(kernel_stack,
18857 - (unsigned long)task_stack_page(next_p) +
18858 - THREAD_SIZE - KERNEL_STACK_OFFSET);
18859 + percpu_write(kernel_stack, next->sp0);
18860
18861 /*
18862 * Now maybe reload the debug registers and handle I/O bitmaps
18863 @@ -525,12 +524,11 @@ unsigned long get_wchan(struct task_struct *p)
18864 if (!p || p == current || p->state == TASK_RUNNING)
18865 return 0;
18866 stack = (unsigned long)task_stack_page(p);
18867 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
18868 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
18869 return 0;
18870 fp = *(u64 *)(p->thread.sp);
18871 do {
18872 - if (fp < (unsigned long)stack ||
18873 - fp >= (unsigned long)stack+THREAD_SIZE)
18874 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
18875 return 0;
18876 ip = *(u64 *)(fp+8);
18877 if (!in_sched_functions(ip))
18878 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
18879 index 5026738..c5925c0 100644
18880 --- a/arch/x86/kernel/ptrace.c
18881 +++ b/arch/x86/kernel/ptrace.c
18882 @@ -823,7 +823,7 @@ long arch_ptrace(struct task_struct *child, long request,
18883 unsigned long addr, unsigned long data)
18884 {
18885 int ret;
18886 - unsigned long __user *datap = (unsigned long __user *)data;
18887 + unsigned long __user *datap = (__force unsigned long __user *)data;
18888
18889 switch (request) {
18890 /* read the word at location addr in the USER area. */
18891 @@ -908,14 +908,14 @@ long arch_ptrace(struct task_struct *child, long request,
18892 if ((int) addr < 0)
18893 return -EIO;
18894 ret = do_get_thread_area(child, addr,
18895 - (struct user_desc __user *)data);
18896 + (__force struct user_desc __user *) data);
18897 break;
18898
18899 case PTRACE_SET_THREAD_AREA:
18900 if ((int) addr < 0)
18901 return -EIO;
18902 ret = do_set_thread_area(child, addr,
18903 - (struct user_desc __user *)data, 0);
18904 + (__force struct user_desc __user *) data, 0);
18905 break;
18906 #endif
18907
18908 @@ -1332,7 +1332,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
18909 memset(info, 0, sizeof(*info));
18910 info->si_signo = SIGTRAP;
18911 info->si_code = si_code;
18912 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
18913 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
18914 }
18915
18916 void user_single_step_siginfo(struct task_struct *tsk,
18917 @@ -1361,6 +1361,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
18918 # define IS_IA32 0
18919 #endif
18920
18921 +#ifdef CONFIG_GRKERNSEC_SETXID
18922 +extern void gr_delayed_cred_worker(void);
18923 +#endif
18924 +
18925 /*
18926 * We must return the syscall number to actually look up in the table.
18927 * This can be -1L to skip running any syscall at all.
18928 @@ -1369,6 +1373,11 @@ long syscall_trace_enter(struct pt_regs *regs)
18929 {
18930 long ret = 0;
18931
18932 +#ifdef CONFIG_GRKERNSEC_SETXID
18933 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
18934 + gr_delayed_cred_worker();
18935 +#endif
18936 +
18937 /*
18938 * If we stepped into a sysenter/syscall insn, it trapped in
18939 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
18940 @@ -1412,6 +1421,11 @@ void syscall_trace_leave(struct pt_regs *regs)
18941 {
18942 bool step;
18943
18944 +#ifdef CONFIG_GRKERNSEC_SETXID
18945 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
18946 + gr_delayed_cred_worker();
18947 +#endif
18948 +
18949 audit_syscall_exit(regs);
18950
18951 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
18952 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
18953 index 42eb330..139955c 100644
18954 --- a/arch/x86/kernel/pvclock.c
18955 +++ b/arch/x86/kernel/pvclock.c
18956 @@ -81,11 +81,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
18957 return pv_tsc_khz;
18958 }
18959
18960 -static atomic64_t last_value = ATOMIC64_INIT(0);
18961 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
18962
18963 void pvclock_resume(void)
18964 {
18965 - atomic64_set(&last_value, 0);
18966 + atomic64_set_unchecked(&last_value, 0);
18967 }
18968
18969 cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
18970 @@ -121,11 +121,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
18971 * updating at the same time, and one of them could be slightly behind,
18972 * making the assumption that last_value always go forward fail to hold.
18973 */
18974 - last = atomic64_read(&last_value);
18975 + last = atomic64_read_unchecked(&last_value);
18976 do {
18977 if (ret < last)
18978 return last;
18979 - last = atomic64_cmpxchg(&last_value, last, ret);
18980 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
18981 } while (unlikely(last != ret));
18982
18983 return ret;
18984 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
18985 index d840e69..98e9581 100644
18986 --- a/arch/x86/kernel/reboot.c
18987 +++ b/arch/x86/kernel/reboot.c
18988 @@ -35,7 +35,7 @@ void (*pm_power_off)(void);
18989 EXPORT_SYMBOL(pm_power_off);
18990
18991 static const struct desc_ptr no_idt = {};
18992 -static int reboot_mode;
18993 +static unsigned short reboot_mode;
18994 enum reboot_type reboot_type = BOOT_ACPI;
18995 int reboot_force;
18996
18997 @@ -335,13 +335,17 @@ core_initcall(reboot_init);
18998 extern const unsigned char machine_real_restart_asm[];
18999 extern const u64 machine_real_restart_gdt[3];
19000
19001 -void machine_real_restart(unsigned int type)
19002 +__noreturn void machine_real_restart(unsigned int type)
19003 {
19004 void *restart_va;
19005 unsigned long restart_pa;
19006 - void (*restart_lowmem)(unsigned int);
19007 + void (* __noreturn restart_lowmem)(unsigned int);
19008 u64 *lowmem_gdt;
19009
19010 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
19011 + struct desc_struct *gdt;
19012 +#endif
19013 +
19014 local_irq_disable();
19015
19016 /* Write zero to CMOS register number 0x0f, which the BIOS POST
19017 @@ -367,14 +371,14 @@ void machine_real_restart(unsigned int type)
19018 boot)". This seems like a fairly standard thing that gets set by
19019 REBOOT.COM programs, and the previous reset routine did this
19020 too. */
19021 - *((unsigned short *)0x472) = reboot_mode;
19022 + *(unsigned short *)(__va(0x472)) = reboot_mode;
19023
19024 /* Patch the GDT in the low memory trampoline */
19025 lowmem_gdt = TRAMPOLINE_SYM(machine_real_restart_gdt);
19026
19027 restart_va = TRAMPOLINE_SYM(machine_real_restart_asm);
19028 restart_pa = virt_to_phys(restart_va);
19029 - restart_lowmem = (void (*)(unsigned int))restart_pa;
19030 + restart_lowmem = (void *)restart_pa;
19031
19032 /* GDT[0]: GDT self-pointer */
19033 lowmem_gdt[0] =
19034 @@ -385,7 +389,33 @@ void machine_real_restart(unsigned int type)
19035 GDT_ENTRY(0x009b, restart_pa, 0xffff);
19036
19037 /* Jump to the identity-mapped low memory code */
19038 +
19039 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
19040 + gdt = get_cpu_gdt_table(smp_processor_id());
19041 + pax_open_kernel();
19042 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19043 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
19044 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
19045 + asm("mov %0, %%ds; mov %0, %%es; mov %0, %%ss" : : "r" (__KERNEL_DS) : "memory");
19046 +#endif
19047 +#ifdef CONFIG_PAX_KERNEXEC
19048 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
19049 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
19050 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
19051 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
19052 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
19053 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
19054 +#endif
19055 + pax_close_kernel();
19056 +#endif
19057 +
19058 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
19059 + asm volatile("push %0; push %1; lret\n" : : "i" (__KERNEL_CS), "rm" (restart_lowmem), "a" (type));
19060 + unreachable();
19061 +#else
19062 restart_lowmem(type);
19063 +#endif
19064 +
19065 }
19066 #ifdef CONFIG_APM_MODULE
19067 EXPORT_SYMBOL(machine_real_restart);
19068 @@ -556,7 +586,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
19069 * try to force a triple fault and then cycle between hitting the keyboard
19070 * controller and doing that
19071 */
19072 -static void native_machine_emergency_restart(void)
19073 +__noreturn static void native_machine_emergency_restart(void)
19074 {
19075 int i;
19076 int attempt = 0;
19077 @@ -680,13 +710,13 @@ void native_machine_shutdown(void)
19078 #endif
19079 }
19080
19081 -static void __machine_emergency_restart(int emergency)
19082 +static __noreturn void __machine_emergency_restart(int emergency)
19083 {
19084 reboot_emergency = emergency;
19085 machine_ops.emergency_restart();
19086 }
19087
19088 -static void native_machine_restart(char *__unused)
19089 +static __noreturn void native_machine_restart(char *__unused)
19090 {
19091 printk("machine restart\n");
19092
19093 @@ -695,7 +725,7 @@ static void native_machine_restart(char *__unused)
19094 __machine_emergency_restart(0);
19095 }
19096
19097 -static void native_machine_halt(void)
19098 +static __noreturn void native_machine_halt(void)
19099 {
19100 /* stop other cpus and apics */
19101 machine_shutdown();
19102 @@ -706,7 +736,7 @@ static void native_machine_halt(void)
19103 stop_this_cpu(NULL);
19104 }
19105
19106 -static void native_machine_power_off(void)
19107 +__noreturn static void native_machine_power_off(void)
19108 {
19109 if (pm_power_off) {
19110 if (!reboot_force)
19111 @@ -715,6 +745,7 @@ static void native_machine_power_off(void)
19112 }
19113 /* a fallback in case there is no PM info available */
19114 tboot_shutdown(TB_SHUTDOWN_HALT);
19115 + unreachable();
19116 }
19117
19118 struct machine_ops machine_ops = {
19119 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
19120 index 7a6f3b3..bed145d7 100644
19121 --- a/arch/x86/kernel/relocate_kernel_64.S
19122 +++ b/arch/x86/kernel/relocate_kernel_64.S
19123 @@ -11,6 +11,7 @@
19124 #include <asm/kexec.h>
19125 #include <asm/processor-flags.h>
19126 #include <asm/pgtable_types.h>
19127 +#include <asm/alternative-asm.h>
19128
19129 /*
19130 * Must be relocatable PIC code callable as a C function
19131 @@ -160,13 +161,14 @@ identity_mapped:
19132 xorq %rbp, %rbp
19133 xorq %r8, %r8
19134 xorq %r9, %r9
19135 - xorq %r10, %r9
19136 + xorq %r10, %r10
19137 xorq %r11, %r11
19138 xorq %r12, %r12
19139 xorq %r13, %r13
19140 xorq %r14, %r14
19141 xorq %r15, %r15
19142
19143 + pax_force_retaddr 0, 1
19144 ret
19145
19146 1:
19147 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
19148 index d7d5099..28555d0 100644
19149 --- a/arch/x86/kernel/setup.c
19150 +++ b/arch/x86/kernel/setup.c
19151 @@ -448,7 +448,7 @@ static void __init parse_setup_data(void)
19152
19153 switch (data->type) {
19154 case SETUP_E820_EXT:
19155 - parse_e820_ext(data);
19156 + parse_e820_ext((struct setup_data __force_kernel *)data);
19157 break;
19158 case SETUP_DTB:
19159 add_dtb(pa_data);
19160 @@ -649,7 +649,7 @@ static void __init trim_bios_range(void)
19161 * area (640->1Mb) as ram even though it is not.
19162 * take them out.
19163 */
19164 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
19165 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
19166 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
19167 }
19168
19169 @@ -767,14 +767,14 @@ void __init setup_arch(char **cmdline_p)
19170
19171 if (!boot_params.hdr.root_flags)
19172 root_mountflags &= ~MS_RDONLY;
19173 - init_mm.start_code = (unsigned long) _text;
19174 - init_mm.end_code = (unsigned long) _etext;
19175 + init_mm.start_code = ktla_ktva((unsigned long) _text);
19176 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
19177 init_mm.end_data = (unsigned long) _edata;
19178 init_mm.brk = _brk_end;
19179
19180 - code_resource.start = virt_to_phys(_text);
19181 - code_resource.end = virt_to_phys(_etext)-1;
19182 - data_resource.start = virt_to_phys(_etext);
19183 + code_resource.start = virt_to_phys(ktla_ktva(_text));
19184 + code_resource.end = virt_to_phys(ktla_ktva(_etext))-1;
19185 + data_resource.start = virt_to_phys(_sdata);
19186 data_resource.end = virt_to_phys(_edata)-1;
19187 bss_resource.start = virt_to_phys(&__bss_start);
19188 bss_resource.end = virt_to_phys(&__bss_stop)-1;
19189 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
19190 index 5a98aa2..2f9288d 100644
19191 --- a/arch/x86/kernel/setup_percpu.c
19192 +++ b/arch/x86/kernel/setup_percpu.c
19193 @@ -21,19 +21,17 @@
19194 #include <asm/cpu.h>
19195 #include <asm/stackprotector.h>
19196
19197 -DEFINE_PER_CPU(int, cpu_number);
19198 +#ifdef CONFIG_SMP
19199 +DEFINE_PER_CPU(unsigned int, cpu_number);
19200 EXPORT_PER_CPU_SYMBOL(cpu_number);
19201 +#endif
19202
19203 -#ifdef CONFIG_X86_64
19204 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
19205 -#else
19206 -#define BOOT_PERCPU_OFFSET 0
19207 -#endif
19208
19209 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
19210 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
19211
19212 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
19213 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
19214 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
19215 };
19216 EXPORT_SYMBOL(__per_cpu_offset);
19217 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
19218 {
19219 #ifdef CONFIG_X86_32
19220 struct desc_struct gdt;
19221 + unsigned long base = per_cpu_offset(cpu);
19222
19223 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
19224 - 0x2 | DESCTYPE_S, 0x8);
19225 - gdt.s = 1;
19226 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
19227 + 0x83 | DESCTYPE_S, 0xC);
19228 write_gdt_entry(get_cpu_gdt_table(cpu),
19229 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
19230 #endif
19231 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
19232 /* alrighty, percpu areas up and running */
19233 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
19234 for_each_possible_cpu(cpu) {
19235 +#ifdef CONFIG_CC_STACKPROTECTOR
19236 +#ifdef CONFIG_X86_32
19237 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
19238 +#endif
19239 +#endif
19240 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
19241 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
19242 per_cpu(cpu_number, cpu) = cpu;
19243 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
19244 */
19245 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
19246 #endif
19247 +#ifdef CONFIG_CC_STACKPROTECTOR
19248 +#ifdef CONFIG_X86_32
19249 + if (!cpu)
19250 + per_cpu(stack_canary.canary, cpu) = canary;
19251 +#endif
19252 +#endif
19253 /*
19254 * Up to this point, the boot CPU has been using .init.data
19255 * area. Reload any changed state for the boot CPU.
19256 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
19257 index 46a01bd..2e88e6d 100644
19258 --- a/arch/x86/kernel/signal.c
19259 +++ b/arch/x86/kernel/signal.c
19260 @@ -198,7 +198,7 @@ static unsigned long align_sigframe(unsigned long sp)
19261 * Align the stack pointer according to the i386 ABI,
19262 * i.e. so that on function entry ((sp + 4) & 15) == 0.
19263 */
19264 - sp = ((sp + 4) & -16ul) - 4;
19265 + sp = ((sp - 12) & -16ul) - 4;
19266 #else /* !CONFIG_X86_32 */
19267 sp = round_down(sp, 16) - 8;
19268 #endif
19269 @@ -249,11 +249,11 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size,
19270 * Return an always-bogus address instead so we will die with SIGSEGV.
19271 */
19272 if (onsigstack && !likely(on_sig_stack(sp)))
19273 - return (void __user *)-1L;
19274 + return (__force void __user *)-1L;
19275
19276 /* save i387 state */
19277 if (used_math() && save_i387_xstate(*fpstate) < 0)
19278 - return (void __user *)-1L;
19279 + return (__force void __user *)-1L;
19280
19281 return (void __user *)sp;
19282 }
19283 @@ -308,9 +308,9 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
19284 }
19285
19286 if (current->mm->context.vdso)
19287 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
19288 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
19289 else
19290 - restorer = &frame->retcode;
19291 + restorer = (void __user *)&frame->retcode;
19292 if (ka->sa.sa_flags & SA_RESTORER)
19293 restorer = ka->sa.sa_restorer;
19294
19295 @@ -324,7 +324,7 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
19296 * reasons and because gdb uses it as a signature to notice
19297 * signal handler stack frames.
19298 */
19299 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
19300 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
19301
19302 if (err)
19303 return -EFAULT;
19304 @@ -378,7 +378,10 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
19305 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
19306
19307 /* Set up to return from userspace. */
19308 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
19309 + if (current->mm->context.vdso)
19310 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
19311 + else
19312 + restorer = (void __user *)&frame->retcode;
19313 if (ka->sa.sa_flags & SA_RESTORER)
19314 restorer = ka->sa.sa_restorer;
19315 put_user_ex(restorer, &frame->pretcode);
19316 @@ -390,7 +393,7 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
19317 * reasons and because gdb uses it as a signature to notice
19318 * signal handler stack frames.
19319 */
19320 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
19321 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
19322 } put_user_catch(err);
19323
19324 if (err)
19325 @@ -765,7 +768,7 @@ static void do_signal(struct pt_regs *regs)
19326 * X86_32: vm86 regs switched out by assembly code before reaching
19327 * here, so testing against kernel CS suffices.
19328 */
19329 - if (!user_mode(regs))
19330 + if (!user_mode_novm(regs))
19331 return;
19332
19333 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
19334 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
19335 index 66d250c..f1b10bd 100644
19336 --- a/arch/x86/kernel/smpboot.c
19337 +++ b/arch/x86/kernel/smpboot.c
19338 @@ -715,17 +715,20 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu)
19339 set_idle_for_cpu(cpu, c_idle.idle);
19340 do_rest:
19341 per_cpu(current_task, cpu) = c_idle.idle;
19342 + per_cpu(current_tinfo, cpu) = &c_idle.idle->tinfo;
19343 #ifdef CONFIG_X86_32
19344 /* Stack for startup_32 can be just as for start_secondary onwards */
19345 irq_ctx_init(cpu);
19346 #else
19347 clear_tsk_thread_flag(c_idle.idle, TIF_FORK);
19348 initial_gs = per_cpu_offset(cpu);
19349 - per_cpu(kernel_stack, cpu) =
19350 - (unsigned long)task_stack_page(c_idle.idle) -
19351 - KERNEL_STACK_OFFSET + THREAD_SIZE;
19352 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(c_idle.idle) - 16 + THREAD_SIZE;
19353 #endif
19354 +
19355 + pax_open_kernel();
19356 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
19357 + pax_close_kernel();
19358 +
19359 initial_code = (unsigned long)start_secondary;
19360 stack_start = c_idle.idle->thread.sp;
19361
19362 @@ -868,6 +871,12 @@ int __cpuinit native_cpu_up(unsigned int cpu)
19363
19364 per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
19365
19366 +#ifdef CONFIG_PAX_PER_CPU_PGD
19367 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
19368 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
19369 + KERNEL_PGD_PTRS);
19370 +#endif
19371 +
19372 err = do_boot_cpu(apicid, cpu);
19373 if (err) {
19374 pr_debug("do_boot_cpu failed %d\n", err);
19375 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
19376 index c346d11..d43b163 100644
19377 --- a/arch/x86/kernel/step.c
19378 +++ b/arch/x86/kernel/step.c
19379 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
19380 struct desc_struct *desc;
19381 unsigned long base;
19382
19383 - seg &= ~7UL;
19384 + seg >>= 3;
19385
19386 mutex_lock(&child->mm->context.lock);
19387 - if (unlikely((seg >> 3) >= child->mm->context.size))
19388 + if (unlikely(seg >= child->mm->context.size))
19389 addr = -1L; /* bogus selector, access would fault */
19390 else {
19391 desc = child->mm->context.ldt + seg;
19392 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
19393 addr += base;
19394 }
19395 mutex_unlock(&child->mm->context.lock);
19396 - }
19397 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
19398 + addr = ktla_ktva(addr);
19399
19400 return addr;
19401 }
19402 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
19403 unsigned char opcode[15];
19404 unsigned long addr = convert_ip_to_linear(child, regs);
19405
19406 + if (addr == -EINVAL)
19407 + return 0;
19408 +
19409 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
19410 for (i = 0; i < copied; i++) {
19411 switch (opcode[i]) {
19412 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
19413 index 0b0cb5f..db6b9ed 100644
19414 --- a/arch/x86/kernel/sys_i386_32.c
19415 +++ b/arch/x86/kernel/sys_i386_32.c
19416 @@ -24,17 +24,224 @@
19417
19418 #include <asm/syscalls.h>
19419
19420 -/*
19421 - * Do a system call from kernel instead of calling sys_execve so we
19422 - * end up with proper pt_regs.
19423 - */
19424 -int kernel_execve(const char *filename,
19425 - const char *const argv[],
19426 - const char *const envp[])
19427 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
19428 {
19429 - long __res;
19430 - asm volatile ("int $0x80"
19431 - : "=a" (__res)
19432 - : "0" (__NR_execve), "b" (filename), "c" (argv), "d" (envp) : "memory");
19433 - return __res;
19434 + unsigned long pax_task_size = TASK_SIZE;
19435 +
19436 +#ifdef CONFIG_PAX_SEGMEXEC
19437 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
19438 + pax_task_size = SEGMEXEC_TASK_SIZE;
19439 +#endif
19440 +
19441 + if (len > pax_task_size || addr > pax_task_size - len)
19442 + return -EINVAL;
19443 +
19444 + return 0;
19445 +}
19446 +
19447 +unsigned long
19448 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
19449 + unsigned long len, unsigned long pgoff, unsigned long flags)
19450 +{
19451 + struct mm_struct *mm = current->mm;
19452 + struct vm_area_struct *vma;
19453 + unsigned long start_addr, pax_task_size = TASK_SIZE;
19454 +
19455 +#ifdef CONFIG_PAX_SEGMEXEC
19456 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
19457 + pax_task_size = SEGMEXEC_TASK_SIZE;
19458 +#endif
19459 +
19460 + pax_task_size -= PAGE_SIZE;
19461 +
19462 + if (len > pax_task_size)
19463 + return -ENOMEM;
19464 +
19465 + if (flags & MAP_FIXED)
19466 + return addr;
19467 +
19468 +#ifdef CONFIG_PAX_RANDMMAP
19469 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
19470 +#endif
19471 +
19472 + if (addr) {
19473 + addr = PAGE_ALIGN(addr);
19474 + if (pax_task_size - len >= addr) {
19475 + vma = find_vma(mm, addr);
19476 + if (check_heap_stack_gap(vma, addr, len))
19477 + return addr;
19478 + }
19479 + }
19480 + if (len > mm->cached_hole_size) {
19481 + start_addr = addr = mm->free_area_cache;
19482 + } else {
19483 + start_addr = addr = mm->mmap_base;
19484 + mm->cached_hole_size = 0;
19485 + }
19486 +
19487 +#ifdef CONFIG_PAX_PAGEEXEC
19488 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE) && start_addr >= mm->mmap_base) {
19489 + start_addr = 0x00110000UL;
19490 +
19491 +#ifdef CONFIG_PAX_RANDMMAP
19492 + if (mm->pax_flags & MF_PAX_RANDMMAP)
19493 + start_addr += mm->delta_mmap & 0x03FFF000UL;
19494 +#endif
19495 +
19496 + if (mm->start_brk <= start_addr && start_addr < mm->mmap_base)
19497 + start_addr = addr = mm->mmap_base;
19498 + else
19499 + addr = start_addr;
19500 + }
19501 +#endif
19502 +
19503 +full_search:
19504 + for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
19505 + /* At this point: (!vma || addr < vma->vm_end). */
19506 + if (pax_task_size - len < addr) {
19507 + /*
19508 + * Start a new search - just in case we missed
19509 + * some holes.
19510 + */
19511 + if (start_addr != mm->mmap_base) {
19512 + start_addr = addr = mm->mmap_base;
19513 + mm->cached_hole_size = 0;
19514 + goto full_search;
19515 + }
19516 + return -ENOMEM;
19517 + }
19518 + if (check_heap_stack_gap(vma, addr, len))
19519 + break;
19520 + if (addr + mm->cached_hole_size < vma->vm_start)
19521 + mm->cached_hole_size = vma->vm_start - addr;
19522 + addr = vma->vm_end;
19523 + if (mm->start_brk <= addr && addr < mm->mmap_base) {
19524 + start_addr = addr = mm->mmap_base;
19525 + mm->cached_hole_size = 0;
19526 + goto full_search;
19527 + }
19528 + }
19529 +
19530 + /*
19531 + * Remember the place where we stopped the search:
19532 + */
19533 + mm->free_area_cache = addr + len;
19534 + return addr;
19535 +}
19536 +
19537 +unsigned long
19538 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
19539 + const unsigned long len, const unsigned long pgoff,
19540 + const unsigned long flags)
19541 +{
19542 + struct vm_area_struct *vma;
19543 + struct mm_struct *mm = current->mm;
19544 + unsigned long base = mm->mmap_base, addr = addr0, pax_task_size = TASK_SIZE;
19545 +
19546 +#ifdef CONFIG_PAX_SEGMEXEC
19547 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
19548 + pax_task_size = SEGMEXEC_TASK_SIZE;
19549 +#endif
19550 +
19551 + pax_task_size -= PAGE_SIZE;
19552 +
19553 + /* requested length too big for entire address space */
19554 + if (len > pax_task_size)
19555 + return -ENOMEM;
19556 +
19557 + if (flags & MAP_FIXED)
19558 + return addr;
19559 +
19560 +#ifdef CONFIG_PAX_PAGEEXEC
19561 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
19562 + goto bottomup;
19563 +#endif
19564 +
19565 +#ifdef CONFIG_PAX_RANDMMAP
19566 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
19567 +#endif
19568 +
19569 + /* requesting a specific address */
19570 + if (addr) {
19571 + addr = PAGE_ALIGN(addr);
19572 + if (pax_task_size - len >= addr) {
19573 + vma = find_vma(mm, addr);
19574 + if (check_heap_stack_gap(vma, addr, len))
19575 + return addr;
19576 + }
19577 + }
19578 +
19579 + /* check if free_area_cache is useful for us */
19580 + if (len <= mm->cached_hole_size) {
19581 + mm->cached_hole_size = 0;
19582 + mm->free_area_cache = mm->mmap_base;
19583 + }
19584 +
19585 + /* either no address requested or can't fit in requested address hole */
19586 + addr = mm->free_area_cache;
19587 +
19588 + /* make sure it can fit in the remaining address space */
19589 + if (addr > len) {
19590 + vma = find_vma(mm, addr-len);
19591 + if (check_heap_stack_gap(vma, addr - len, len))
19592 + /* remember the address as a hint for next time */
19593 + return (mm->free_area_cache = addr-len);
19594 + }
19595 +
19596 + if (mm->mmap_base < len)
19597 + goto bottomup;
19598 +
19599 + addr = mm->mmap_base-len;
19600 +
19601 + do {
19602 + /*
19603 + * Lookup failure means no vma is above this address,
19604 + * else if new region fits below vma->vm_start,
19605 + * return with success:
19606 + */
19607 + vma = find_vma(mm, addr);
19608 + if (check_heap_stack_gap(vma, addr, len))
19609 + /* remember the address as a hint for next time */
19610 + return (mm->free_area_cache = addr);
19611 +
19612 + /* remember the largest hole we saw so far */
19613 + if (addr + mm->cached_hole_size < vma->vm_start)
19614 + mm->cached_hole_size = vma->vm_start - addr;
19615 +
19616 + /* try just below the current vma->vm_start */
19617 + addr = skip_heap_stack_gap(vma, len);
19618 + } while (!IS_ERR_VALUE(addr));
19619 +
19620 +bottomup:
19621 + /*
19622 + * A failed mmap() very likely causes application failure,
19623 + * so fall back to the bottom-up function here. This scenario
19624 + * can happen with large stack limits and large mmap()
19625 + * allocations.
19626 + */
19627 +
19628 +#ifdef CONFIG_PAX_SEGMEXEC
19629 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
19630 + mm->mmap_base = SEGMEXEC_TASK_UNMAPPED_BASE;
19631 + else
19632 +#endif
19633 +
19634 + mm->mmap_base = TASK_UNMAPPED_BASE;
19635 +
19636 +#ifdef CONFIG_PAX_RANDMMAP
19637 + if (mm->pax_flags & MF_PAX_RANDMMAP)
19638 + mm->mmap_base += mm->delta_mmap;
19639 +#endif
19640 +
19641 + mm->free_area_cache = mm->mmap_base;
19642 + mm->cached_hole_size = ~0UL;
19643 + addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
19644 + /*
19645 + * Restore the topdown base:
19646 + */
19647 + mm->mmap_base = base;
19648 + mm->free_area_cache = base;
19649 + mm->cached_hole_size = ~0UL;
19650 +
19651 + return addr;
19652 }
19653 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
19654 index 0514890..3dbebce 100644
19655 --- a/arch/x86/kernel/sys_x86_64.c
19656 +++ b/arch/x86/kernel/sys_x86_64.c
19657 @@ -95,8 +95,8 @@ out:
19658 return error;
19659 }
19660
19661 -static void find_start_end(unsigned long flags, unsigned long *begin,
19662 - unsigned long *end)
19663 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
19664 + unsigned long *begin, unsigned long *end)
19665 {
19666 if (!test_thread_flag(TIF_IA32) && (flags & MAP_32BIT)) {
19667 unsigned long new_begin;
19668 @@ -115,7 +115,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
19669 *begin = new_begin;
19670 }
19671 } else {
19672 - *begin = TASK_UNMAPPED_BASE;
19673 + *begin = mm->mmap_base;
19674 *end = TASK_SIZE;
19675 }
19676 }
19677 @@ -132,16 +132,19 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
19678 if (flags & MAP_FIXED)
19679 return addr;
19680
19681 - find_start_end(flags, &begin, &end);
19682 + find_start_end(mm, flags, &begin, &end);
19683
19684 if (len > end)
19685 return -ENOMEM;
19686
19687 +#ifdef CONFIG_PAX_RANDMMAP
19688 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
19689 +#endif
19690 +
19691 if (addr) {
19692 addr = PAGE_ALIGN(addr);
19693 vma = find_vma(mm, addr);
19694 - if (end - len >= addr &&
19695 - (!vma || addr + len <= vma->vm_start))
19696 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len))
19697 return addr;
19698 }
19699 if (((flags & MAP_32BIT) || test_thread_flag(TIF_IA32))
19700 @@ -172,7 +175,7 @@ full_search:
19701 }
19702 return -ENOMEM;
19703 }
19704 - if (!vma || addr + len <= vma->vm_start) {
19705 + if (check_heap_stack_gap(vma, addr, len)) {
19706 /*
19707 * Remember the place where we stopped the search:
19708 */
19709 @@ -195,7 +198,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
19710 {
19711 struct vm_area_struct *vma;
19712 struct mm_struct *mm = current->mm;
19713 - unsigned long addr = addr0;
19714 + unsigned long base = mm->mmap_base, addr = addr0;
19715
19716 /* requested length too big for entire address space */
19717 if (len > TASK_SIZE)
19718 @@ -208,13 +211,18 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
19719 if (!test_thread_flag(TIF_IA32) && (flags & MAP_32BIT))
19720 goto bottomup;
19721
19722 +#ifdef CONFIG_PAX_RANDMMAP
19723 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
19724 +#endif
19725 +
19726 /* requesting a specific address */
19727 if (addr) {
19728 addr = PAGE_ALIGN(addr);
19729 - vma = find_vma(mm, addr);
19730 - if (TASK_SIZE - len >= addr &&
19731 - (!vma || addr + len <= vma->vm_start))
19732 - return addr;
19733 + if (TASK_SIZE - len >= addr) {
19734 + vma = find_vma(mm, addr);
19735 + if (check_heap_stack_gap(vma, addr, len))
19736 + return addr;
19737 + }
19738 }
19739
19740 /* check if free_area_cache is useful for us */
19741 @@ -232,7 +240,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
19742 ALIGN_TOPDOWN);
19743
19744 vma = find_vma(mm, tmp_addr);
19745 - if (!vma || tmp_addr + len <= vma->vm_start)
19746 + if (check_heap_stack_gap(vma, tmp_addr, len))
19747 /* remember the address as a hint for next time */
19748 return mm->free_area_cache = tmp_addr;
19749 }
19750 @@ -251,7 +259,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
19751 * return with success:
19752 */
19753 vma = find_vma(mm, addr);
19754 - if (!vma || addr+len <= vma->vm_start)
19755 + if (check_heap_stack_gap(vma, addr, len))
19756 /* remember the address as a hint for next time */
19757 return mm->free_area_cache = addr;
19758
19759 @@ -260,8 +268,8 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
19760 mm->cached_hole_size = vma->vm_start - addr;
19761
19762 /* try just below the current vma->vm_start */
19763 - addr = vma->vm_start-len;
19764 - } while (len < vma->vm_start);
19765 + addr = skip_heap_stack_gap(vma, len);
19766 + } while (!IS_ERR_VALUE(addr));
19767
19768 bottomup:
19769 /*
19770 @@ -270,13 +278,21 @@ bottomup:
19771 * can happen with large stack limits and large mmap()
19772 * allocations.
19773 */
19774 + mm->mmap_base = TASK_UNMAPPED_BASE;
19775 +
19776 +#ifdef CONFIG_PAX_RANDMMAP
19777 + if (mm->pax_flags & MF_PAX_RANDMMAP)
19778 + mm->mmap_base += mm->delta_mmap;
19779 +#endif
19780 +
19781 + mm->free_area_cache = mm->mmap_base;
19782 mm->cached_hole_size = ~0UL;
19783 - mm->free_area_cache = TASK_UNMAPPED_BASE;
19784 addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
19785 /*
19786 * Restore the topdown base:
19787 */
19788 - mm->free_area_cache = mm->mmap_base;
19789 + mm->mmap_base = base;
19790 + mm->free_area_cache = base;
19791 mm->cached_hole_size = ~0UL;
19792
19793 return addr;
19794 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
19795 index e2410e2..4fe3fbc 100644
19796 --- a/arch/x86/kernel/tboot.c
19797 +++ b/arch/x86/kernel/tboot.c
19798 @@ -219,7 +219,7 @@ static int tboot_setup_sleep(void)
19799
19800 void tboot_shutdown(u32 shutdown_type)
19801 {
19802 - void (*shutdown)(void);
19803 + void (* __noreturn shutdown)(void);
19804
19805 if (!tboot_enabled())
19806 return;
19807 @@ -241,7 +241,7 @@ void tboot_shutdown(u32 shutdown_type)
19808
19809 switch_to_tboot_pt();
19810
19811 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
19812 + shutdown = (void *)tboot->shutdown_entry;
19813 shutdown();
19814
19815 /* should not reach here */
19816 @@ -298,7 +298,7 @@ void tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
19817 tboot_shutdown(acpi_shutdown_map[sleep_state]);
19818 }
19819
19820 -static atomic_t ap_wfs_count;
19821 +static atomic_unchecked_t ap_wfs_count;
19822
19823 static int tboot_wait_for_aps(int num_aps)
19824 {
19825 @@ -322,9 +322,9 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
19826 {
19827 switch (action) {
19828 case CPU_DYING:
19829 - atomic_inc(&ap_wfs_count);
19830 + atomic_inc_unchecked(&ap_wfs_count);
19831 if (num_online_cpus() == 1)
19832 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
19833 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
19834 return NOTIFY_BAD;
19835 break;
19836 }
19837 @@ -343,7 +343,7 @@ static __init int tboot_late_init(void)
19838
19839 tboot_create_trampoline();
19840
19841 - atomic_set(&ap_wfs_count, 0);
19842 + atomic_set_unchecked(&ap_wfs_count, 0);
19843 register_hotcpu_notifier(&tboot_cpu_notifier);
19844 return 0;
19845 }
19846 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
19847 index dd5fbf4..b7f2232 100644
19848 --- a/arch/x86/kernel/time.c
19849 +++ b/arch/x86/kernel/time.c
19850 @@ -31,9 +31,9 @@ unsigned long profile_pc(struct pt_regs *regs)
19851 {
19852 unsigned long pc = instruction_pointer(regs);
19853
19854 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
19855 + if (!user_mode(regs) && in_lock_functions(pc)) {
19856 #ifdef CONFIG_FRAME_POINTER
19857 - return *(unsigned long *)(regs->bp + sizeof(long));
19858 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
19859 #else
19860 unsigned long *sp =
19861 (unsigned long *)kernel_stack_pointer(regs);
19862 @@ -42,11 +42,17 @@ unsigned long profile_pc(struct pt_regs *regs)
19863 * or above a saved flags. Eflags has bits 22-31 zero,
19864 * kernel addresses don't.
19865 */
19866 +
19867 +#ifdef CONFIG_PAX_KERNEXEC
19868 + return ktla_ktva(sp[0]);
19869 +#else
19870 if (sp[0] >> 22)
19871 return sp[0];
19872 if (sp[1] >> 22)
19873 return sp[1];
19874 #endif
19875 +
19876 +#endif
19877 }
19878 return pc;
19879 }
19880 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
19881 index bcfec2d..8f88b4a 100644
19882 --- a/arch/x86/kernel/tls.c
19883 +++ b/arch/x86/kernel/tls.c
19884 @@ -85,6 +85,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
19885 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
19886 return -EINVAL;
19887
19888 +#ifdef CONFIG_PAX_SEGMEXEC
19889 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
19890 + return -EINVAL;
19891 +#endif
19892 +
19893 set_tls_desc(p, idx, &info, 1);
19894
19895 return 0;
19896 diff --git a/arch/x86/kernel/trampoline_32.S b/arch/x86/kernel/trampoline_32.S
19897 index 451c0a7..e57f551 100644
19898 --- a/arch/x86/kernel/trampoline_32.S
19899 +++ b/arch/x86/kernel/trampoline_32.S
19900 @@ -32,6 +32,12 @@
19901 #include <asm/segment.h>
19902 #include <asm/page_types.h>
19903
19904 +#ifdef CONFIG_PAX_KERNEXEC
19905 +#define ta(X) (X)
19906 +#else
19907 +#define ta(X) ((X) - __PAGE_OFFSET)
19908 +#endif
19909 +
19910 #ifdef CONFIG_SMP
19911
19912 .section ".x86_trampoline","a"
19913 @@ -62,7 +68,7 @@ r_base = .
19914 inc %ax # protected mode (PE) bit
19915 lmsw %ax # into protected mode
19916 # flush prefetch and jump to startup_32_smp in arch/i386/kernel/head.S
19917 - ljmpl $__BOOT_CS, $(startup_32_smp-__PAGE_OFFSET)
19918 + ljmpl $__BOOT_CS, $ta(startup_32_smp)
19919
19920 # These need to be in the same 64K segment as the above;
19921 # hence we don't use the boot_gdt_descr defined in head.S
19922 diff --git a/arch/x86/kernel/trampoline_64.S b/arch/x86/kernel/trampoline_64.S
19923 index 09ff517..df19fbff 100644
19924 --- a/arch/x86/kernel/trampoline_64.S
19925 +++ b/arch/x86/kernel/trampoline_64.S
19926 @@ -90,7 +90,7 @@ startup_32:
19927 movl $__KERNEL_DS, %eax # Initialize the %ds segment register
19928 movl %eax, %ds
19929
19930 - movl $X86_CR4_PAE, %eax
19931 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %eax
19932 movl %eax, %cr4 # Enable PAE mode
19933
19934 # Setup trampoline 4 level pagetables
19935 @@ -138,7 +138,7 @@ tidt:
19936 # so the kernel can live anywhere
19937 .balign 4
19938 tgdt:
19939 - .short tgdt_end - tgdt # gdt limit
19940 + .short tgdt_end - tgdt - 1 # gdt limit
19941 .long tgdt - r_base
19942 .short 0
19943 .quad 0x00cf9b000000ffff # __KERNEL32_CS
19944 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
19945 index 4bbe04d..41d0943 100644
19946 --- a/arch/x86/kernel/traps.c
19947 +++ b/arch/x86/kernel/traps.c
19948 @@ -70,12 +70,6 @@ asmlinkage int system_call(void);
19949
19950 /* Do we ignore FPU interrupts ? */
19951 char ignore_fpu_irq;
19952 -
19953 -/*
19954 - * The IDT has to be page-aligned to simplify the Pentium
19955 - * F0 0F bug workaround.
19956 - */
19957 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
19958 #endif
19959
19960 DECLARE_BITMAP(used_vectors, NR_VECTORS);
19961 @@ -108,13 +102,13 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
19962 }
19963
19964 static void __kprobes
19965 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
19966 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
19967 long error_code, siginfo_t *info)
19968 {
19969 struct task_struct *tsk = current;
19970
19971 #ifdef CONFIG_X86_32
19972 - if (regs->flags & X86_VM_MASK) {
19973 + if (v8086_mode(regs)) {
19974 /*
19975 * traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
19976 * On nmi (interrupt 2), do_trap should not be called.
19977 @@ -125,7 +119,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
19978 }
19979 #endif
19980
19981 - if (!user_mode(regs))
19982 + if (!user_mode_novm(regs))
19983 goto kernel_trap;
19984
19985 #ifdef CONFIG_X86_32
19986 @@ -148,7 +142,7 @@ trap_signal:
19987 printk_ratelimit()) {
19988 printk(KERN_INFO
19989 "%s[%d] trap %s ip:%lx sp:%lx error:%lx",
19990 - tsk->comm, tsk->pid, str,
19991 + tsk->comm, task_pid_nr(tsk), str,
19992 regs->ip, regs->sp, error_code);
19993 print_vma_addr(" in ", regs->ip);
19994 printk("\n");
19995 @@ -165,8 +159,20 @@ kernel_trap:
19996 if (!fixup_exception(regs)) {
19997 tsk->thread.error_code = error_code;
19998 tsk->thread.trap_no = trapnr;
19999 +
20000 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
20001 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
20002 + str = "PAX: suspicious stack segment fault";
20003 +#endif
20004 +
20005 die(str, regs, error_code);
20006 }
20007 +
20008 +#ifdef CONFIG_PAX_REFCOUNT
20009 + if (trapnr == 4)
20010 + pax_report_refcount_overflow(regs);
20011 +#endif
20012 +
20013 return;
20014
20015 #ifdef CONFIG_X86_32
20016 @@ -255,14 +261,30 @@ do_general_protection(struct pt_regs *regs, long error_code)
20017 conditional_sti(regs);
20018
20019 #ifdef CONFIG_X86_32
20020 - if (regs->flags & X86_VM_MASK)
20021 + if (v8086_mode(regs))
20022 goto gp_in_vm86;
20023 #endif
20024
20025 tsk = current;
20026 - if (!user_mode(regs))
20027 + if (!user_mode_novm(regs))
20028 goto gp_in_kernel;
20029
20030 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
20031 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
20032 + struct mm_struct *mm = tsk->mm;
20033 + unsigned long limit;
20034 +
20035 + down_write(&mm->mmap_sem);
20036 + limit = mm->context.user_cs_limit;
20037 + if (limit < TASK_SIZE) {
20038 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
20039 + up_write(&mm->mmap_sem);
20040 + return;
20041 + }
20042 + up_write(&mm->mmap_sem);
20043 + }
20044 +#endif
20045 +
20046 tsk->thread.error_code = error_code;
20047 tsk->thread.trap_no = 13;
20048
20049 @@ -295,6 +317,13 @@ gp_in_kernel:
20050 if (notify_die(DIE_GPF, "general protection fault", regs,
20051 error_code, 13, SIGSEGV) == NOTIFY_STOP)
20052 return;
20053 +
20054 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
20055 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
20056 + die("PAX: suspicious general protection fault", regs, error_code);
20057 + else
20058 +#endif
20059 +
20060 die("general protection fault", regs, error_code);
20061 }
20062
20063 @@ -421,7 +450,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
20064 /* It's safe to allow irq's after DR6 has been saved */
20065 preempt_conditional_sti(regs);
20066
20067 - if (regs->flags & X86_VM_MASK) {
20068 + if (v8086_mode(regs)) {
20069 handle_vm86_trap((struct kernel_vm86_regs *) regs,
20070 error_code, 1);
20071 preempt_conditional_cli(regs);
20072 @@ -436,7 +465,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
20073 * We already checked v86 mode above, so we can check for kernel mode
20074 * by just checking the CPL of CS.
20075 */
20076 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
20077 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
20078 tsk->thread.debugreg6 &= ~DR_STEP;
20079 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
20080 regs->flags &= ~X86_EFLAGS_TF;
20081 @@ -466,7 +495,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
20082 return;
20083 conditional_sti(regs);
20084
20085 - if (!user_mode_vm(regs))
20086 + if (!user_mode(regs))
20087 {
20088 if (!fixup_exception(regs)) {
20089 task->thread.error_code = error_code;
20090 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
20091 index b9242ba..50c5edd 100644
20092 --- a/arch/x86/kernel/verify_cpu.S
20093 +++ b/arch/x86/kernel/verify_cpu.S
20094 @@ -20,6 +20,7 @@
20095 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
20096 * arch/x86/kernel/trampoline_64.S: secondary processor verification
20097 * arch/x86/kernel/head_32.S: processor startup
20098 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
20099 *
20100 * verify_cpu, returns the status of longmode and SSE in register %eax.
20101 * 0: Success 1: Failure
20102 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
20103 index 328cb37..56556b4 100644
20104 --- a/arch/x86/kernel/vm86_32.c
20105 +++ b/arch/x86/kernel/vm86_32.c
20106 @@ -41,6 +41,7 @@
20107 #include <linux/ptrace.h>
20108 #include <linux/audit.h>
20109 #include <linux/stddef.h>
20110 +#include <linux/grsecurity.h>
20111
20112 #include <asm/uaccess.h>
20113 #include <asm/io.h>
20114 @@ -148,7 +149,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
20115 do_exit(SIGSEGV);
20116 }
20117
20118 - tss = &per_cpu(init_tss, get_cpu());
20119 + tss = init_tss + get_cpu();
20120 current->thread.sp0 = current->thread.saved_sp0;
20121 current->thread.sysenter_cs = __KERNEL_CS;
20122 load_sp0(tss, &current->thread);
20123 @@ -210,6 +211,13 @@ int sys_vm86old(struct vm86_struct __user *v86, struct pt_regs *regs)
20124 struct task_struct *tsk;
20125 int tmp, ret = -EPERM;
20126
20127 +#ifdef CONFIG_GRKERNSEC_VM86
20128 + if (!capable(CAP_SYS_RAWIO)) {
20129 + gr_handle_vm86();
20130 + goto out;
20131 + }
20132 +#endif
20133 +
20134 tsk = current;
20135 if (tsk->thread.saved_sp0)
20136 goto out;
20137 @@ -240,6 +248,14 @@ int sys_vm86(unsigned long cmd, unsigned long arg, struct pt_regs *regs)
20138 int tmp, ret;
20139 struct vm86plus_struct __user *v86;
20140
20141 +#ifdef CONFIG_GRKERNSEC_VM86
20142 + if (!capable(CAP_SYS_RAWIO)) {
20143 + gr_handle_vm86();
20144 + ret = -EPERM;
20145 + goto out;
20146 + }
20147 +#endif
20148 +
20149 tsk = current;
20150 switch (cmd) {
20151 case VM86_REQUEST_IRQ:
20152 @@ -326,7 +342,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
20153 tsk->thread.saved_fs = info->regs32->fs;
20154 tsk->thread.saved_gs = get_user_gs(info->regs32);
20155
20156 - tss = &per_cpu(init_tss, get_cpu());
20157 + tss = init_tss + get_cpu();
20158 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
20159 if (cpu_has_sep)
20160 tsk->thread.sysenter_cs = 0;
20161 @@ -533,7 +549,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
20162 goto cannot_handle;
20163 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
20164 goto cannot_handle;
20165 - intr_ptr = (unsigned long __user *) (i << 2);
20166 + intr_ptr = (__force unsigned long __user *) (i << 2);
20167 if (get_user(segoffs, intr_ptr))
20168 goto cannot_handle;
20169 if ((segoffs >> 16) == BIOSSEG)
20170 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
20171 index 0f703f1..9e15f64 100644
20172 --- a/arch/x86/kernel/vmlinux.lds.S
20173 +++ b/arch/x86/kernel/vmlinux.lds.S
20174 @@ -26,6 +26,13 @@
20175 #include <asm/page_types.h>
20176 #include <asm/cache.h>
20177 #include <asm/boot.h>
20178 +#include <asm/segment.h>
20179 +
20180 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
20181 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
20182 +#else
20183 +#define __KERNEL_TEXT_OFFSET 0
20184 +#endif
20185
20186 #undef i386 /* in case the preprocessor is a 32bit one */
20187
20188 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
20189
20190 PHDRS {
20191 text PT_LOAD FLAGS(5); /* R_E */
20192 +#ifdef CONFIG_X86_32
20193 + module PT_LOAD FLAGS(5); /* R_E */
20194 +#endif
20195 +#ifdef CONFIG_XEN
20196 + rodata PT_LOAD FLAGS(5); /* R_E */
20197 +#else
20198 + rodata PT_LOAD FLAGS(4); /* R__ */
20199 +#endif
20200 data PT_LOAD FLAGS(6); /* RW_ */
20201 -#ifdef CONFIG_X86_64
20202 + init.begin PT_LOAD FLAGS(6); /* RW_ */
20203 #ifdef CONFIG_SMP
20204 percpu PT_LOAD FLAGS(6); /* RW_ */
20205 #endif
20206 + text.init PT_LOAD FLAGS(5); /* R_E */
20207 + text.exit PT_LOAD FLAGS(5); /* R_E */
20208 init PT_LOAD FLAGS(7); /* RWE */
20209 -#endif
20210 note PT_NOTE FLAGS(0); /* ___ */
20211 }
20212
20213 SECTIONS
20214 {
20215 #ifdef CONFIG_X86_32
20216 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
20217 - phys_startup_32 = startup_32 - LOAD_OFFSET;
20218 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
20219 #else
20220 - . = __START_KERNEL;
20221 - phys_startup_64 = startup_64 - LOAD_OFFSET;
20222 + . = __START_KERNEL;
20223 #endif
20224
20225 /* Text and read-only data */
20226 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
20227 - _text = .;
20228 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
20229 /* bootstrapping code */
20230 +#ifdef CONFIG_X86_32
20231 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
20232 +#else
20233 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
20234 +#endif
20235 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
20236 + _text = .;
20237 HEAD_TEXT
20238 #ifdef CONFIG_X86_32
20239 . = ALIGN(PAGE_SIZE);
20240 @@ -108,13 +128,47 @@ SECTIONS
20241 IRQENTRY_TEXT
20242 *(.fixup)
20243 *(.gnu.warning)
20244 - /* End of text section */
20245 - _etext = .;
20246 } :text = 0x9090
20247
20248 - NOTES :text :note
20249 + . += __KERNEL_TEXT_OFFSET;
20250
20251 - EXCEPTION_TABLE(16) :text = 0x9090
20252 +#ifdef CONFIG_X86_32
20253 + . = ALIGN(PAGE_SIZE);
20254 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
20255 +
20256 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_MODULES)
20257 + MODULES_EXEC_VADDR = .;
20258 + BYTE(0)
20259 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
20260 + . = ALIGN(HPAGE_SIZE);
20261 + MODULES_EXEC_END = . - 1;
20262 +#endif
20263 +
20264 + } :module
20265 +#endif
20266 +
20267 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
20268 + /* End of text section */
20269 + _etext = . - __KERNEL_TEXT_OFFSET;
20270 + }
20271 +
20272 +#ifdef CONFIG_X86_32
20273 + . = ALIGN(PAGE_SIZE);
20274 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
20275 + *(.idt)
20276 + . = ALIGN(PAGE_SIZE);
20277 + *(.empty_zero_page)
20278 + *(.initial_pg_fixmap)
20279 + *(.initial_pg_pmd)
20280 + *(.initial_page_table)
20281 + *(.swapper_pg_dir)
20282 + } :rodata
20283 +#endif
20284 +
20285 + . = ALIGN(PAGE_SIZE);
20286 + NOTES :rodata :note
20287 +
20288 + EXCEPTION_TABLE(16) :rodata
20289
20290 #if defined(CONFIG_DEBUG_RODATA)
20291 /* .text should occupy whole number of pages */
20292 @@ -126,16 +180,20 @@ SECTIONS
20293
20294 /* Data */
20295 .data : AT(ADDR(.data) - LOAD_OFFSET) {
20296 +
20297 +#ifdef CONFIG_PAX_KERNEXEC
20298 + . = ALIGN(HPAGE_SIZE);
20299 +#else
20300 + . = ALIGN(PAGE_SIZE);
20301 +#endif
20302 +
20303 /* Start of data section */
20304 _sdata = .;
20305
20306 /* init_task */
20307 INIT_TASK_DATA(THREAD_SIZE)
20308
20309 -#ifdef CONFIG_X86_32
20310 - /* 32 bit has nosave before _edata */
20311 NOSAVE_DATA
20312 -#endif
20313
20314 PAGE_ALIGNED_DATA(PAGE_SIZE)
20315
20316 @@ -176,12 +234,19 @@ SECTIONS
20317 #endif /* CONFIG_X86_64 */
20318
20319 /* Init code and data - will be freed after init */
20320 - . = ALIGN(PAGE_SIZE);
20321 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
20322 + BYTE(0)
20323 +
20324 +#ifdef CONFIG_PAX_KERNEXEC
20325 + . = ALIGN(HPAGE_SIZE);
20326 +#else
20327 + . = ALIGN(PAGE_SIZE);
20328 +#endif
20329 +
20330 __init_begin = .; /* paired with __init_end */
20331 - }
20332 + } :init.begin
20333
20334 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
20335 +#ifdef CONFIG_SMP
20336 /*
20337 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
20338 * output PHDR, so the next output section - .init.text - should
20339 @@ -190,12 +255,27 @@ SECTIONS
20340 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
20341 #endif
20342
20343 - INIT_TEXT_SECTION(PAGE_SIZE)
20344 -#ifdef CONFIG_X86_64
20345 - :init
20346 -#endif
20347 + . = ALIGN(PAGE_SIZE);
20348 + init_begin = .;
20349 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
20350 + VMLINUX_SYMBOL(_sinittext) = .;
20351 + INIT_TEXT
20352 + VMLINUX_SYMBOL(_einittext) = .;
20353 + . = ALIGN(PAGE_SIZE);
20354 + } :text.init
20355
20356 - INIT_DATA_SECTION(16)
20357 + /*
20358 + * .exit.text is discard at runtime, not link time, to deal with
20359 + * references from .altinstructions and .eh_frame
20360 + */
20361 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
20362 + EXIT_TEXT
20363 + . = ALIGN(16);
20364 + } :text.exit
20365 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
20366 +
20367 + . = ALIGN(PAGE_SIZE);
20368 + INIT_DATA_SECTION(16) :init
20369
20370 /*
20371 * Code and data for a variety of lowlevel trampolines, to be
20372 @@ -269,19 +349,12 @@ SECTIONS
20373 }
20374
20375 . = ALIGN(8);
20376 - /*
20377 - * .exit.text is discard at runtime, not link time, to deal with
20378 - * references from .altinstructions and .eh_frame
20379 - */
20380 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
20381 - EXIT_TEXT
20382 - }
20383
20384 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
20385 EXIT_DATA
20386 }
20387
20388 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
20389 +#ifndef CONFIG_SMP
20390 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
20391 #endif
20392
20393 @@ -300,16 +373,10 @@ SECTIONS
20394 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
20395 __smp_locks = .;
20396 *(.smp_locks)
20397 - . = ALIGN(PAGE_SIZE);
20398 __smp_locks_end = .;
20399 + . = ALIGN(PAGE_SIZE);
20400 }
20401
20402 -#ifdef CONFIG_X86_64
20403 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
20404 - NOSAVE_DATA
20405 - }
20406 -#endif
20407 -
20408 /* BSS */
20409 . = ALIGN(PAGE_SIZE);
20410 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
20411 @@ -325,6 +392,7 @@ SECTIONS
20412 __brk_base = .;
20413 . += 64 * 1024; /* 64k alignment slop space */
20414 *(.brk_reservation) /* areas brk users have reserved */
20415 + . = ALIGN(HPAGE_SIZE);
20416 __brk_limit = .;
20417 }
20418
20419 @@ -351,13 +419,12 @@ SECTIONS
20420 * for the boot processor.
20421 */
20422 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
20423 -INIT_PER_CPU(gdt_page);
20424 INIT_PER_CPU(irq_stack_union);
20425
20426 /*
20427 * Build-time check on the image size:
20428 */
20429 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
20430 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
20431 "kernel image bigger than KERNEL_IMAGE_SIZE");
20432
20433 #ifdef CONFIG_SMP
20434 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
20435 index b07ba93..a212969 100644
20436 --- a/arch/x86/kernel/vsyscall_64.c
20437 +++ b/arch/x86/kernel/vsyscall_64.c
20438 @@ -57,15 +57,13 @@ DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data) =
20439 .lock = __SEQLOCK_UNLOCKED(__vsyscall_gtod_data.lock),
20440 };
20441
20442 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
20443 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
20444
20445 static int __init vsyscall_setup(char *str)
20446 {
20447 if (str) {
20448 if (!strcmp("emulate", str))
20449 vsyscall_mode = EMULATE;
20450 - else if (!strcmp("native", str))
20451 - vsyscall_mode = NATIVE;
20452 else if (!strcmp("none", str))
20453 vsyscall_mode = NONE;
20454 else
20455 @@ -207,7 +205,7 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
20456
20457 tsk = current;
20458 if (seccomp_mode(&tsk->seccomp))
20459 - do_exit(SIGKILL);
20460 + do_group_exit(SIGKILL);
20461
20462 /*
20463 * With a real vsyscall, page faults cause SIGSEGV. We want to
20464 @@ -279,8 +277,7 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
20465 return true;
20466
20467 sigsegv:
20468 - force_sig(SIGSEGV, current);
20469 - return true;
20470 + do_group_exit(SIGKILL);
20471 }
20472
20473 /*
20474 @@ -333,10 +330,7 @@ void __init map_vsyscall(void)
20475 extern char __vvar_page;
20476 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
20477
20478 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
20479 - vsyscall_mode == NATIVE
20480 - ? PAGE_KERNEL_VSYSCALL
20481 - : PAGE_KERNEL_VVAR);
20482 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
20483 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
20484 (unsigned long)VSYSCALL_START);
20485
20486 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
20487 index 9796c2f..f686fbf 100644
20488 --- a/arch/x86/kernel/x8664_ksyms_64.c
20489 +++ b/arch/x86/kernel/x8664_ksyms_64.c
20490 @@ -29,8 +29,6 @@ EXPORT_SYMBOL(__put_user_8);
20491 EXPORT_SYMBOL(copy_user_generic_string);
20492 EXPORT_SYMBOL(copy_user_generic_unrolled);
20493 EXPORT_SYMBOL(__copy_user_nocache);
20494 -EXPORT_SYMBOL(_copy_from_user);
20495 -EXPORT_SYMBOL(_copy_to_user);
20496
20497 EXPORT_SYMBOL(copy_page);
20498 EXPORT_SYMBOL(clear_page);
20499 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
20500 index 7110911..e8cdee5 100644
20501 --- a/arch/x86/kernel/xsave.c
20502 +++ b/arch/x86/kernel/xsave.c
20503 @@ -130,7 +130,7 @@ int check_for_xstate(struct i387_fxsave_struct __user *buf,
20504 fx_sw_user->xstate_size > fx_sw_user->extended_size)
20505 return -EINVAL;
20506
20507 - err = __get_user(magic2, (__u32 *) (((void *)fpstate) +
20508 + err = __get_user(magic2, (__u32 __user *) (((void __user *)fpstate) +
20509 fx_sw_user->extended_size -
20510 FP_XSTATE_MAGIC2_SIZE));
20511 if (err)
20512 @@ -266,7 +266,7 @@ fx_only:
20513 * the other extended state.
20514 */
20515 xrstor_state(init_xstate_buf, pcntxt_mask & ~XSTATE_FPSSE);
20516 - return fxrstor_checking((__force struct i387_fxsave_struct *)buf);
20517 + return fxrstor_checking((struct i387_fxsave_struct __force_kernel *)buf);
20518 }
20519
20520 /*
20521 @@ -295,7 +295,7 @@ int restore_i387_xstate(void __user *buf)
20522 if (use_xsave())
20523 err = restore_user_xstate(buf);
20524 else
20525 - err = fxrstor_checking((__force struct i387_fxsave_struct *)
20526 + err = fxrstor_checking((struct i387_fxsave_struct __force_kernel *)
20527 buf);
20528 if (unlikely(err)) {
20529 /*
20530 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
20531 index 89b02bf..0f6511d 100644
20532 --- a/arch/x86/kvm/cpuid.c
20533 +++ b/arch/x86/kvm/cpuid.c
20534 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
20535 struct kvm_cpuid2 *cpuid,
20536 struct kvm_cpuid_entry2 __user *entries)
20537 {
20538 - int r;
20539 + int r, i;
20540
20541 r = -E2BIG;
20542 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
20543 goto out;
20544 r = -EFAULT;
20545 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
20546 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
20547 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
20548 goto out;
20549 + for (i = 0; i < cpuid->nent; ++i) {
20550 + struct kvm_cpuid_entry2 cpuid_entry;
20551 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
20552 + goto out;
20553 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
20554 + }
20555 vcpu->arch.cpuid_nent = cpuid->nent;
20556 kvm_apic_set_version(vcpu);
20557 kvm_x86_ops->cpuid_update(vcpu);
20558 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
20559 struct kvm_cpuid2 *cpuid,
20560 struct kvm_cpuid_entry2 __user *entries)
20561 {
20562 - int r;
20563 + int r, i;
20564
20565 r = -E2BIG;
20566 if (cpuid->nent < vcpu->arch.cpuid_nent)
20567 goto out;
20568 r = -EFAULT;
20569 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
20570 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
20571 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
20572 goto out;
20573 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
20574 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
20575 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
20576 + goto out;
20577 + }
20578 return 0;
20579
20580 out:
20581 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
20582 index 0982507..7f6d72f 100644
20583 --- a/arch/x86/kvm/emulate.c
20584 +++ b/arch/x86/kvm/emulate.c
20585 @@ -250,6 +250,7 @@ struct gprefix {
20586
20587 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
20588 do { \
20589 + unsigned long _tmp; \
20590 __asm__ __volatile__ ( \
20591 _PRE_EFLAGS("0", "4", "2") \
20592 _op _suffix " %"_x"3,%1; " \
20593 @@ -264,8 +265,6 @@ struct gprefix {
20594 /* Raw emulation: instruction has two explicit operands. */
20595 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
20596 do { \
20597 - unsigned long _tmp; \
20598 - \
20599 switch ((ctxt)->dst.bytes) { \
20600 case 2: \
20601 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
20602 @@ -281,7 +280,6 @@ struct gprefix {
20603
20604 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
20605 do { \
20606 - unsigned long _tmp; \
20607 switch ((ctxt)->dst.bytes) { \
20608 case 1: \
20609 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
20610 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
20611 index cfdc6e0..ab92e84 100644
20612 --- a/arch/x86/kvm/lapic.c
20613 +++ b/arch/x86/kvm/lapic.c
20614 @@ -54,7 +54,7 @@
20615 #define APIC_BUS_CYCLE_NS 1
20616
20617 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
20618 -#define apic_debug(fmt, arg...)
20619 +#define apic_debug(fmt, arg...) do {} while (0)
20620
20621 #define APIC_LVT_NUM 6
20622 /* 14 is the version for Xeon and Pentium 8.4.8*/
20623 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
20624 index 1561028..0ed7f14 100644
20625 --- a/arch/x86/kvm/paging_tmpl.h
20626 +++ b/arch/x86/kvm/paging_tmpl.h
20627 @@ -197,7 +197,7 @@ retry_walk:
20628 if (unlikely(kvm_is_error_hva(host_addr)))
20629 goto error;
20630
20631 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
20632 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
20633 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
20634 goto error;
20635
20636 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
20637 index e385214..f8df033 100644
20638 --- a/arch/x86/kvm/svm.c
20639 +++ b/arch/x86/kvm/svm.c
20640 @@ -3420,7 +3420,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
20641 int cpu = raw_smp_processor_id();
20642
20643 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
20644 +
20645 + pax_open_kernel();
20646 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
20647 + pax_close_kernel();
20648 +
20649 load_TR_desc();
20650 }
20651
20652 @@ -3798,6 +3802,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
20653 #endif
20654 #endif
20655
20656 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
20657 + __set_fs(current_thread_info()->addr_limit);
20658 +#endif
20659 +
20660 reload_tss(vcpu);
20661
20662 local_irq_disable();
20663 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
20664 index a7a6f60..04b745a 100644
20665 --- a/arch/x86/kvm/vmx.c
20666 +++ b/arch/x86/kvm/vmx.c
20667 @@ -1306,7 +1306,11 @@ static void reload_tss(void)
20668 struct desc_struct *descs;
20669
20670 descs = (void *)gdt->address;
20671 +
20672 + pax_open_kernel();
20673 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
20674 + pax_close_kernel();
20675 +
20676 load_TR_desc();
20677 }
20678
20679 @@ -2637,8 +2641,11 @@ static __init int hardware_setup(void)
20680 if (!cpu_has_vmx_flexpriority())
20681 flexpriority_enabled = 0;
20682
20683 - if (!cpu_has_vmx_tpr_shadow())
20684 - kvm_x86_ops->update_cr8_intercept = NULL;
20685 + if (!cpu_has_vmx_tpr_shadow()) {
20686 + pax_open_kernel();
20687 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
20688 + pax_close_kernel();
20689 + }
20690
20691 if (enable_ept && !cpu_has_vmx_ept_2m_page())
20692 kvm_disable_largepages();
20693 @@ -3654,7 +3661,7 @@ static void vmx_set_constant_host_state(void)
20694 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
20695
20696 asm("mov $.Lkvm_vmx_return, %0" : "=r"(tmpl));
20697 - vmcs_writel(HOST_RIP, tmpl); /* 22.2.5 */
20698 + vmcs_writel(HOST_RIP, ktla_ktva(tmpl)); /* 22.2.5 */
20699
20700 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
20701 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
20702 @@ -6192,6 +6199,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
20703 "jmp .Lkvm_vmx_return \n\t"
20704 ".Llaunched: " __ex(ASM_VMX_VMRESUME) "\n\t"
20705 ".Lkvm_vmx_return: "
20706 +
20707 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
20708 + "ljmp %[cs],$.Lkvm_vmx_return2\n\t"
20709 + ".Lkvm_vmx_return2: "
20710 +#endif
20711 +
20712 /* Save guest registers, load host registers, keep flags */
20713 "mov %0, %c[wordsize](%%"R"sp) \n\t"
20714 "pop %0 \n\t"
20715 @@ -6240,6 +6253,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
20716 #endif
20717 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
20718 [wordsize]"i"(sizeof(ulong))
20719 +
20720 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
20721 + ,[cs]"i"(__KERNEL_CS)
20722 +#endif
20723 +
20724 : "cc", "memory"
20725 , R"ax", R"bx", R"di", R"si"
20726 #ifdef CONFIG_X86_64
20727 @@ -6268,7 +6286,16 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
20728 }
20729 }
20730
20731 - asm("mov %0, %%ds; mov %0, %%es" : : "r"(__USER_DS));
20732 + asm("mov %0, %%ds; mov %0, %%es; mov %0, %%ss" : : "r"(__KERNEL_DS));
20733 +
20734 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
20735 + loadsegment(fs, __KERNEL_PERCPU);
20736 +#endif
20737 +
20738 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
20739 + __set_fs(current_thread_info()->addr_limit);
20740 +#endif
20741 +
20742 vmx->loaded_vmcs->launched = 1;
20743
20744 vmx->exit_reason = vmcs_read32(VM_EXIT_REASON);
20745 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
20746 index 8d1c6c6..99c2d5f 100644
20747 --- a/arch/x86/kvm/x86.c
20748 +++ b/arch/x86/kvm/x86.c
20749 @@ -1311,8 +1311,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
20750 {
20751 struct kvm *kvm = vcpu->kvm;
20752 int lm = is_long_mode(vcpu);
20753 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
20754 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
20755 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
20756 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
20757 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
20758 : kvm->arch.xen_hvm_config.blob_size_32;
20759 u32 page_num = data & ~PAGE_MASK;
20760 @@ -2145,6 +2145,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
20761 if (n < msr_list.nmsrs)
20762 goto out;
20763 r = -EFAULT;
20764 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
20765 + goto out;
20766 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
20767 num_msrs_to_save * sizeof(u32)))
20768 goto out;
20769 @@ -2266,7 +2268,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu,
20770 static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
20771 struct kvm_interrupt *irq)
20772 {
20773 - if (irq->irq < 0 || irq->irq >= 256)
20774 + if (irq->irq >= 256)
20775 return -EINVAL;
20776 if (irqchip_in_kernel(vcpu->kvm))
20777 return -ENXIO;
20778 @@ -4782,7 +4784,7 @@ static void kvm_set_mmio_spte_mask(void)
20779 kvm_mmu_set_mmio_spte_mask(mask);
20780 }
20781
20782 -int kvm_arch_init(void *opaque)
20783 +int kvm_arch_init(const void *opaque)
20784 {
20785 int r;
20786 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
20787 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
20788 index 642d880..44e0f3f 100644
20789 --- a/arch/x86/lguest/boot.c
20790 +++ b/arch/x86/lguest/boot.c
20791 @@ -1200,9 +1200,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
20792 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
20793 * Launcher to reboot us.
20794 */
20795 -static void lguest_restart(char *reason)
20796 +static __noreturn void lguest_restart(char *reason)
20797 {
20798 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
20799 + BUG();
20800 }
20801
20802 /*G:050
20803 diff --git a/arch/x86/lib/atomic64_32.c b/arch/x86/lib/atomic64_32.c
20804 index 042f682..c92afb6 100644
20805 --- a/arch/x86/lib/atomic64_32.c
20806 +++ b/arch/x86/lib/atomic64_32.c
20807 @@ -8,18 +8,30 @@
20808
20809 long long atomic64_read_cx8(long long, const atomic64_t *v);
20810 EXPORT_SYMBOL(atomic64_read_cx8);
20811 +long long atomic64_read_unchecked_cx8(long long, const atomic64_unchecked_t *v);
20812 +EXPORT_SYMBOL(atomic64_read_unchecked_cx8);
20813 long long atomic64_set_cx8(long long, const atomic64_t *v);
20814 EXPORT_SYMBOL(atomic64_set_cx8);
20815 +long long atomic64_set_unchecked_cx8(long long, const atomic64_unchecked_t *v);
20816 +EXPORT_SYMBOL(atomic64_set_unchecked_cx8);
20817 long long atomic64_xchg_cx8(long long, unsigned high);
20818 EXPORT_SYMBOL(atomic64_xchg_cx8);
20819 long long atomic64_add_return_cx8(long long a, atomic64_t *v);
20820 EXPORT_SYMBOL(atomic64_add_return_cx8);
20821 +long long atomic64_add_return_unchecked_cx8(long long a, atomic64_unchecked_t *v);
20822 +EXPORT_SYMBOL(atomic64_add_return_unchecked_cx8);
20823 long long atomic64_sub_return_cx8(long long a, atomic64_t *v);
20824 EXPORT_SYMBOL(atomic64_sub_return_cx8);
20825 +long long atomic64_sub_return_unchecked_cx8(long long a, atomic64_unchecked_t *v);
20826 +EXPORT_SYMBOL(atomic64_sub_return_unchecked_cx8);
20827 long long atomic64_inc_return_cx8(long long a, atomic64_t *v);
20828 EXPORT_SYMBOL(atomic64_inc_return_cx8);
20829 +long long atomic64_inc_return_unchecked_cx8(long long a, atomic64_unchecked_t *v);
20830 +EXPORT_SYMBOL(atomic64_inc_return_unchecked_cx8);
20831 long long atomic64_dec_return_cx8(long long a, atomic64_t *v);
20832 EXPORT_SYMBOL(atomic64_dec_return_cx8);
20833 +long long atomic64_dec_return_unchecked_cx8(long long a, atomic64_unchecked_t *v);
20834 +EXPORT_SYMBOL(atomic64_dec_return_unchecked_cx8);
20835 long long atomic64_dec_if_positive_cx8(atomic64_t *v);
20836 EXPORT_SYMBOL(atomic64_dec_if_positive_cx8);
20837 int atomic64_inc_not_zero_cx8(atomic64_t *v);
20838 @@ -30,26 +42,46 @@ EXPORT_SYMBOL(atomic64_add_unless_cx8);
20839 #ifndef CONFIG_X86_CMPXCHG64
20840 long long atomic64_read_386(long long, const atomic64_t *v);
20841 EXPORT_SYMBOL(atomic64_read_386);
20842 +long long atomic64_read_unchecked_386(long long, const atomic64_unchecked_t *v);
20843 +EXPORT_SYMBOL(atomic64_read_unchecked_386);
20844 long long atomic64_set_386(long long, const atomic64_t *v);
20845 EXPORT_SYMBOL(atomic64_set_386);
20846 +long long atomic64_set_unchecked_386(long long, const atomic64_unchecked_t *v);
20847 +EXPORT_SYMBOL(atomic64_set_unchecked_386);
20848 long long atomic64_xchg_386(long long, unsigned high);
20849 EXPORT_SYMBOL(atomic64_xchg_386);
20850 long long atomic64_add_return_386(long long a, atomic64_t *v);
20851 EXPORT_SYMBOL(atomic64_add_return_386);
20852 +long long atomic64_add_return_unchecked_386(long long a, atomic64_unchecked_t *v);
20853 +EXPORT_SYMBOL(atomic64_add_return_unchecked_386);
20854 long long atomic64_sub_return_386(long long a, atomic64_t *v);
20855 EXPORT_SYMBOL(atomic64_sub_return_386);
20856 +long long atomic64_sub_return_unchecked_386(long long a, atomic64_unchecked_t *v);
20857 +EXPORT_SYMBOL(atomic64_sub_return_unchecked_386);
20858 long long atomic64_inc_return_386(long long a, atomic64_t *v);
20859 EXPORT_SYMBOL(atomic64_inc_return_386);
20860 +long long atomic64_inc_return_unchecked_386(long long a, atomic64_unchecked_t *v);
20861 +EXPORT_SYMBOL(atomic64_inc_return_unchecked_386);
20862 long long atomic64_dec_return_386(long long a, atomic64_t *v);
20863 EXPORT_SYMBOL(atomic64_dec_return_386);
20864 +long long atomic64_dec_return_unchecked_386(long long a, atomic64_unchecked_t *v);
20865 +EXPORT_SYMBOL(atomic64_dec_return_unchecked_386);
20866 long long atomic64_add_386(long long a, atomic64_t *v);
20867 EXPORT_SYMBOL(atomic64_add_386);
20868 +long long atomic64_add_unchecked_386(long long a, atomic64_unchecked_t *v);
20869 +EXPORT_SYMBOL(atomic64_add_unchecked_386);
20870 long long atomic64_sub_386(long long a, atomic64_t *v);
20871 EXPORT_SYMBOL(atomic64_sub_386);
20872 +long long atomic64_sub_unchecked_386(long long a, atomic64_unchecked_t *v);
20873 +EXPORT_SYMBOL(atomic64_sub_unchecked_386);
20874 long long atomic64_inc_386(long long a, atomic64_t *v);
20875 EXPORT_SYMBOL(atomic64_inc_386);
20876 +long long atomic64_inc_unchecked_386(long long a, atomic64_unchecked_t *v);
20877 +EXPORT_SYMBOL(atomic64_inc_unchecked_386);
20878 long long atomic64_dec_386(long long a, atomic64_t *v);
20879 EXPORT_SYMBOL(atomic64_dec_386);
20880 +long long atomic64_dec_unchecked_386(long long a, atomic64_unchecked_t *v);
20881 +EXPORT_SYMBOL(atomic64_dec_unchecked_386);
20882 long long atomic64_dec_if_positive_386(atomic64_t *v);
20883 EXPORT_SYMBOL(atomic64_dec_if_positive_386);
20884 int atomic64_inc_not_zero_386(atomic64_t *v);
20885 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
20886 index e8e7e0d..56fd1b0 100644
20887 --- a/arch/x86/lib/atomic64_386_32.S
20888 +++ b/arch/x86/lib/atomic64_386_32.S
20889 @@ -48,6 +48,10 @@ BEGIN(read)
20890 movl (v), %eax
20891 movl 4(v), %edx
20892 RET_ENDP
20893 +BEGIN(read_unchecked)
20894 + movl (v), %eax
20895 + movl 4(v), %edx
20896 +RET_ENDP
20897 #undef v
20898
20899 #define v %esi
20900 @@ -55,6 +59,10 @@ BEGIN(set)
20901 movl %ebx, (v)
20902 movl %ecx, 4(v)
20903 RET_ENDP
20904 +BEGIN(set_unchecked)
20905 + movl %ebx, (v)
20906 + movl %ecx, 4(v)
20907 +RET_ENDP
20908 #undef v
20909
20910 #define v %esi
20911 @@ -70,6 +78,20 @@ RET_ENDP
20912 BEGIN(add)
20913 addl %eax, (v)
20914 adcl %edx, 4(v)
20915 +
20916 +#ifdef CONFIG_PAX_REFCOUNT
20917 + jno 0f
20918 + subl %eax, (v)
20919 + sbbl %edx, 4(v)
20920 + int $4
20921 +0:
20922 + _ASM_EXTABLE(0b, 0b)
20923 +#endif
20924 +
20925 +RET_ENDP
20926 +BEGIN(add_unchecked)
20927 + addl %eax, (v)
20928 + adcl %edx, 4(v)
20929 RET_ENDP
20930 #undef v
20931
20932 @@ -77,6 +99,24 @@ RET_ENDP
20933 BEGIN(add_return)
20934 addl (v), %eax
20935 adcl 4(v), %edx
20936 +
20937 +#ifdef CONFIG_PAX_REFCOUNT
20938 + into
20939 +1234:
20940 + _ASM_EXTABLE(1234b, 2f)
20941 +#endif
20942 +
20943 + movl %eax, (v)
20944 + movl %edx, 4(v)
20945 +
20946 +#ifdef CONFIG_PAX_REFCOUNT
20947 +2:
20948 +#endif
20949 +
20950 +RET_ENDP
20951 +BEGIN(add_return_unchecked)
20952 + addl (v), %eax
20953 + adcl 4(v), %edx
20954 movl %eax, (v)
20955 movl %edx, 4(v)
20956 RET_ENDP
20957 @@ -86,6 +126,20 @@ RET_ENDP
20958 BEGIN(sub)
20959 subl %eax, (v)
20960 sbbl %edx, 4(v)
20961 +
20962 +#ifdef CONFIG_PAX_REFCOUNT
20963 + jno 0f
20964 + addl %eax, (v)
20965 + adcl %edx, 4(v)
20966 + int $4
20967 +0:
20968 + _ASM_EXTABLE(0b, 0b)
20969 +#endif
20970 +
20971 +RET_ENDP
20972 +BEGIN(sub_unchecked)
20973 + subl %eax, (v)
20974 + sbbl %edx, 4(v)
20975 RET_ENDP
20976 #undef v
20977
20978 @@ -96,6 +150,27 @@ BEGIN(sub_return)
20979 sbbl $0, %edx
20980 addl (v), %eax
20981 adcl 4(v), %edx
20982 +
20983 +#ifdef CONFIG_PAX_REFCOUNT
20984 + into
20985 +1234:
20986 + _ASM_EXTABLE(1234b, 2f)
20987 +#endif
20988 +
20989 + movl %eax, (v)
20990 + movl %edx, 4(v)
20991 +
20992 +#ifdef CONFIG_PAX_REFCOUNT
20993 +2:
20994 +#endif
20995 +
20996 +RET_ENDP
20997 +BEGIN(sub_return_unchecked)
20998 + negl %edx
20999 + negl %eax
21000 + sbbl $0, %edx
21001 + addl (v), %eax
21002 + adcl 4(v), %edx
21003 movl %eax, (v)
21004 movl %edx, 4(v)
21005 RET_ENDP
21006 @@ -105,6 +180,20 @@ RET_ENDP
21007 BEGIN(inc)
21008 addl $1, (v)
21009 adcl $0, 4(v)
21010 +
21011 +#ifdef CONFIG_PAX_REFCOUNT
21012 + jno 0f
21013 + subl $1, (v)
21014 + sbbl $0, 4(v)
21015 + int $4
21016 +0:
21017 + _ASM_EXTABLE(0b, 0b)
21018 +#endif
21019 +
21020 +RET_ENDP
21021 +BEGIN(inc_unchecked)
21022 + addl $1, (v)
21023 + adcl $0, 4(v)
21024 RET_ENDP
21025 #undef v
21026
21027 @@ -114,6 +203,26 @@ BEGIN(inc_return)
21028 movl 4(v), %edx
21029 addl $1, %eax
21030 adcl $0, %edx
21031 +
21032 +#ifdef CONFIG_PAX_REFCOUNT
21033 + into
21034 +1234:
21035 + _ASM_EXTABLE(1234b, 2f)
21036 +#endif
21037 +
21038 + movl %eax, (v)
21039 + movl %edx, 4(v)
21040 +
21041 +#ifdef CONFIG_PAX_REFCOUNT
21042 +2:
21043 +#endif
21044 +
21045 +RET_ENDP
21046 +BEGIN(inc_return_unchecked)
21047 + movl (v), %eax
21048 + movl 4(v), %edx
21049 + addl $1, %eax
21050 + adcl $0, %edx
21051 movl %eax, (v)
21052 movl %edx, 4(v)
21053 RET_ENDP
21054 @@ -123,6 +232,20 @@ RET_ENDP
21055 BEGIN(dec)
21056 subl $1, (v)
21057 sbbl $0, 4(v)
21058 +
21059 +#ifdef CONFIG_PAX_REFCOUNT
21060 + jno 0f
21061 + addl $1, (v)
21062 + adcl $0, 4(v)
21063 + int $4
21064 +0:
21065 + _ASM_EXTABLE(0b, 0b)
21066 +#endif
21067 +
21068 +RET_ENDP
21069 +BEGIN(dec_unchecked)
21070 + subl $1, (v)
21071 + sbbl $0, 4(v)
21072 RET_ENDP
21073 #undef v
21074
21075 @@ -132,6 +255,26 @@ BEGIN(dec_return)
21076 movl 4(v), %edx
21077 subl $1, %eax
21078 sbbl $0, %edx
21079 +
21080 +#ifdef CONFIG_PAX_REFCOUNT
21081 + into
21082 +1234:
21083 + _ASM_EXTABLE(1234b, 2f)
21084 +#endif
21085 +
21086 + movl %eax, (v)
21087 + movl %edx, 4(v)
21088 +
21089 +#ifdef CONFIG_PAX_REFCOUNT
21090 +2:
21091 +#endif
21092 +
21093 +RET_ENDP
21094 +BEGIN(dec_return_unchecked)
21095 + movl (v), %eax
21096 + movl 4(v), %edx
21097 + subl $1, %eax
21098 + sbbl $0, %edx
21099 movl %eax, (v)
21100 movl %edx, 4(v)
21101 RET_ENDP
21102 @@ -143,6 +286,13 @@ BEGIN(add_unless)
21103 adcl %edx, %edi
21104 addl (v), %eax
21105 adcl 4(v), %edx
21106 +
21107 +#ifdef CONFIG_PAX_REFCOUNT
21108 + into
21109 +1234:
21110 + _ASM_EXTABLE(1234b, 2f)
21111 +#endif
21112 +
21113 cmpl %eax, %esi
21114 je 3f
21115 1:
21116 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
21117 1:
21118 addl $1, %eax
21119 adcl $0, %edx
21120 +
21121 +#ifdef CONFIG_PAX_REFCOUNT
21122 + into
21123 +1234:
21124 + _ASM_EXTABLE(1234b, 2f)
21125 +#endif
21126 +
21127 movl %eax, (v)
21128 movl %edx, 4(v)
21129 movl $1, %eax
21130 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
21131 movl 4(v), %edx
21132 subl $1, %eax
21133 sbbl $0, %edx
21134 +
21135 +#ifdef CONFIG_PAX_REFCOUNT
21136 + into
21137 +1234:
21138 + _ASM_EXTABLE(1234b, 1f)
21139 +#endif
21140 +
21141 js 1f
21142 movl %eax, (v)
21143 movl %edx, 4(v)
21144 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
21145 index 391a083..3a2cf39 100644
21146 --- a/arch/x86/lib/atomic64_cx8_32.S
21147 +++ b/arch/x86/lib/atomic64_cx8_32.S
21148 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
21149 CFI_STARTPROC
21150
21151 read64 %ecx
21152 + pax_force_retaddr
21153 ret
21154 CFI_ENDPROC
21155 ENDPROC(atomic64_read_cx8)
21156
21157 +ENTRY(atomic64_read_unchecked_cx8)
21158 + CFI_STARTPROC
21159 +
21160 + read64 %ecx
21161 + pax_force_retaddr
21162 + ret
21163 + CFI_ENDPROC
21164 +ENDPROC(atomic64_read_unchecked_cx8)
21165 +
21166 ENTRY(atomic64_set_cx8)
21167 CFI_STARTPROC
21168
21169 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
21170 cmpxchg8b (%esi)
21171 jne 1b
21172
21173 + pax_force_retaddr
21174 ret
21175 CFI_ENDPROC
21176 ENDPROC(atomic64_set_cx8)
21177
21178 +ENTRY(atomic64_set_unchecked_cx8)
21179 + CFI_STARTPROC
21180 +
21181 +1:
21182 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
21183 + * are atomic on 586 and newer */
21184 + cmpxchg8b (%esi)
21185 + jne 1b
21186 +
21187 + pax_force_retaddr
21188 + ret
21189 + CFI_ENDPROC
21190 +ENDPROC(atomic64_set_unchecked_cx8)
21191 +
21192 ENTRY(atomic64_xchg_cx8)
21193 CFI_STARTPROC
21194
21195 @@ -62,12 +87,13 @@ ENTRY(atomic64_xchg_cx8)
21196 cmpxchg8b (%esi)
21197 jne 1b
21198
21199 + pax_force_retaddr
21200 ret
21201 CFI_ENDPROC
21202 ENDPROC(atomic64_xchg_cx8)
21203
21204 -.macro addsub_return func ins insc
21205 -ENTRY(atomic64_\func\()_return_cx8)
21206 +.macro addsub_return func ins insc unchecked=""
21207 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
21208 CFI_STARTPROC
21209 SAVE ebp
21210 SAVE ebx
21211 @@ -84,27 +110,44 @@ ENTRY(atomic64_\func\()_return_cx8)
21212 movl %edx, %ecx
21213 \ins\()l %esi, %ebx
21214 \insc\()l %edi, %ecx
21215 +
21216 +.ifb \unchecked
21217 +#ifdef CONFIG_PAX_REFCOUNT
21218 + into
21219 +2:
21220 + _ASM_EXTABLE(2b, 3f)
21221 +#endif
21222 +.endif
21223 +
21224 LOCK_PREFIX
21225 cmpxchg8b (%ebp)
21226 jne 1b
21227 -
21228 -10:
21229 movl %ebx, %eax
21230 movl %ecx, %edx
21231 +
21232 +.ifb \unchecked
21233 +#ifdef CONFIG_PAX_REFCOUNT
21234 +3:
21235 +#endif
21236 +.endif
21237 +
21238 RESTORE edi
21239 RESTORE esi
21240 RESTORE ebx
21241 RESTORE ebp
21242 + pax_force_retaddr
21243 ret
21244 CFI_ENDPROC
21245 -ENDPROC(atomic64_\func\()_return_cx8)
21246 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
21247 .endm
21248
21249 addsub_return add add adc
21250 addsub_return sub sub sbb
21251 +addsub_return add add adc _unchecked
21252 +addsub_return sub sub sbb _unchecked
21253
21254 -.macro incdec_return func ins insc
21255 -ENTRY(atomic64_\func\()_return_cx8)
21256 +.macro incdec_return func ins insc unchecked=""
21257 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
21258 CFI_STARTPROC
21259 SAVE ebx
21260
21261 @@ -114,21 +157,39 @@ ENTRY(atomic64_\func\()_return_cx8)
21262 movl %edx, %ecx
21263 \ins\()l $1, %ebx
21264 \insc\()l $0, %ecx
21265 +
21266 +.ifb \unchecked
21267 +#ifdef CONFIG_PAX_REFCOUNT
21268 + into
21269 +2:
21270 + _ASM_EXTABLE(2b, 3f)
21271 +#endif
21272 +.endif
21273 +
21274 LOCK_PREFIX
21275 cmpxchg8b (%esi)
21276 jne 1b
21277
21278 -10:
21279 movl %ebx, %eax
21280 movl %ecx, %edx
21281 +
21282 +.ifb \unchecked
21283 +#ifdef CONFIG_PAX_REFCOUNT
21284 +3:
21285 +#endif
21286 +.endif
21287 +
21288 RESTORE ebx
21289 + pax_force_retaddr
21290 ret
21291 CFI_ENDPROC
21292 -ENDPROC(atomic64_\func\()_return_cx8)
21293 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
21294 .endm
21295
21296 incdec_return inc add adc
21297 incdec_return dec sub sbb
21298 +incdec_return inc add adc _unchecked
21299 +incdec_return dec sub sbb _unchecked
21300
21301 ENTRY(atomic64_dec_if_positive_cx8)
21302 CFI_STARTPROC
21303 @@ -140,6 +201,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
21304 movl %edx, %ecx
21305 subl $1, %ebx
21306 sbb $0, %ecx
21307 +
21308 +#ifdef CONFIG_PAX_REFCOUNT
21309 + into
21310 +1234:
21311 + _ASM_EXTABLE(1234b, 2f)
21312 +#endif
21313 +
21314 js 2f
21315 LOCK_PREFIX
21316 cmpxchg8b (%esi)
21317 @@ -149,6 +217,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
21318 movl %ebx, %eax
21319 movl %ecx, %edx
21320 RESTORE ebx
21321 + pax_force_retaddr
21322 ret
21323 CFI_ENDPROC
21324 ENDPROC(atomic64_dec_if_positive_cx8)
21325 @@ -174,6 +243,13 @@ ENTRY(atomic64_add_unless_cx8)
21326 movl %edx, %ecx
21327 addl %esi, %ebx
21328 adcl %edi, %ecx
21329 +
21330 +#ifdef CONFIG_PAX_REFCOUNT
21331 + into
21332 +1234:
21333 + _ASM_EXTABLE(1234b, 3f)
21334 +#endif
21335 +
21336 LOCK_PREFIX
21337 cmpxchg8b (%ebp)
21338 jne 1b
21339 @@ -184,6 +260,7 @@ ENTRY(atomic64_add_unless_cx8)
21340 CFI_ADJUST_CFA_OFFSET -8
21341 RESTORE ebx
21342 RESTORE ebp
21343 + pax_force_retaddr
21344 ret
21345 4:
21346 cmpl %edx, 4(%esp)
21347 @@ -206,6 +283,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
21348 movl %edx, %ecx
21349 addl $1, %ebx
21350 adcl $0, %ecx
21351 +
21352 +#ifdef CONFIG_PAX_REFCOUNT
21353 + into
21354 +1234:
21355 + _ASM_EXTABLE(1234b, 3f)
21356 +#endif
21357 +
21358 LOCK_PREFIX
21359 cmpxchg8b (%esi)
21360 jne 1b
21361 @@ -213,6 +297,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
21362 movl $1, %eax
21363 3:
21364 RESTORE ebx
21365 + pax_force_retaddr
21366 ret
21367 4:
21368 testl %edx, %edx
21369 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
21370 index 78d16a5..fbcf666 100644
21371 --- a/arch/x86/lib/checksum_32.S
21372 +++ b/arch/x86/lib/checksum_32.S
21373 @@ -28,7 +28,8 @@
21374 #include <linux/linkage.h>
21375 #include <asm/dwarf2.h>
21376 #include <asm/errno.h>
21377 -
21378 +#include <asm/segment.h>
21379 +
21380 /*
21381 * computes a partial checksum, e.g. for TCP/UDP fragments
21382 */
21383 @@ -296,9 +297,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
21384
21385 #define ARGBASE 16
21386 #define FP 12
21387 -
21388 -ENTRY(csum_partial_copy_generic)
21389 +
21390 +ENTRY(csum_partial_copy_generic_to_user)
21391 CFI_STARTPROC
21392 +
21393 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21394 + pushl_cfi %gs
21395 + popl_cfi %es
21396 + jmp csum_partial_copy_generic
21397 +#endif
21398 +
21399 +ENTRY(csum_partial_copy_generic_from_user)
21400 +
21401 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21402 + pushl_cfi %gs
21403 + popl_cfi %ds
21404 +#endif
21405 +
21406 +ENTRY(csum_partial_copy_generic)
21407 subl $4,%esp
21408 CFI_ADJUST_CFA_OFFSET 4
21409 pushl_cfi %edi
21410 @@ -320,7 +336,7 @@ ENTRY(csum_partial_copy_generic)
21411 jmp 4f
21412 SRC(1: movw (%esi), %bx )
21413 addl $2, %esi
21414 -DST( movw %bx, (%edi) )
21415 +DST( movw %bx, %es:(%edi) )
21416 addl $2, %edi
21417 addw %bx, %ax
21418 adcl $0, %eax
21419 @@ -332,30 +348,30 @@ DST( movw %bx, (%edi) )
21420 SRC(1: movl (%esi), %ebx )
21421 SRC( movl 4(%esi), %edx )
21422 adcl %ebx, %eax
21423 -DST( movl %ebx, (%edi) )
21424 +DST( movl %ebx, %es:(%edi) )
21425 adcl %edx, %eax
21426 -DST( movl %edx, 4(%edi) )
21427 +DST( movl %edx, %es:4(%edi) )
21428
21429 SRC( movl 8(%esi), %ebx )
21430 SRC( movl 12(%esi), %edx )
21431 adcl %ebx, %eax
21432 -DST( movl %ebx, 8(%edi) )
21433 +DST( movl %ebx, %es:8(%edi) )
21434 adcl %edx, %eax
21435 -DST( movl %edx, 12(%edi) )
21436 +DST( movl %edx, %es:12(%edi) )
21437
21438 SRC( movl 16(%esi), %ebx )
21439 SRC( movl 20(%esi), %edx )
21440 adcl %ebx, %eax
21441 -DST( movl %ebx, 16(%edi) )
21442 +DST( movl %ebx, %es:16(%edi) )
21443 adcl %edx, %eax
21444 -DST( movl %edx, 20(%edi) )
21445 +DST( movl %edx, %es:20(%edi) )
21446
21447 SRC( movl 24(%esi), %ebx )
21448 SRC( movl 28(%esi), %edx )
21449 adcl %ebx, %eax
21450 -DST( movl %ebx, 24(%edi) )
21451 +DST( movl %ebx, %es:24(%edi) )
21452 adcl %edx, %eax
21453 -DST( movl %edx, 28(%edi) )
21454 +DST( movl %edx, %es:28(%edi) )
21455
21456 lea 32(%esi), %esi
21457 lea 32(%edi), %edi
21458 @@ -369,7 +385,7 @@ DST( movl %edx, 28(%edi) )
21459 shrl $2, %edx # This clears CF
21460 SRC(3: movl (%esi), %ebx )
21461 adcl %ebx, %eax
21462 -DST( movl %ebx, (%edi) )
21463 +DST( movl %ebx, %es:(%edi) )
21464 lea 4(%esi), %esi
21465 lea 4(%edi), %edi
21466 dec %edx
21467 @@ -381,12 +397,12 @@ DST( movl %ebx, (%edi) )
21468 jb 5f
21469 SRC( movw (%esi), %cx )
21470 leal 2(%esi), %esi
21471 -DST( movw %cx, (%edi) )
21472 +DST( movw %cx, %es:(%edi) )
21473 leal 2(%edi), %edi
21474 je 6f
21475 shll $16,%ecx
21476 SRC(5: movb (%esi), %cl )
21477 -DST( movb %cl, (%edi) )
21478 +DST( movb %cl, %es:(%edi) )
21479 6: addl %ecx, %eax
21480 adcl $0, %eax
21481 7:
21482 @@ -397,7 +413,7 @@ DST( movb %cl, (%edi) )
21483
21484 6001:
21485 movl ARGBASE+20(%esp), %ebx # src_err_ptr
21486 - movl $-EFAULT, (%ebx)
21487 + movl $-EFAULT, %ss:(%ebx)
21488
21489 # zero the complete destination - computing the rest
21490 # is too much work
21491 @@ -410,11 +426,15 @@ DST( movb %cl, (%edi) )
21492
21493 6002:
21494 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
21495 - movl $-EFAULT,(%ebx)
21496 + movl $-EFAULT,%ss:(%ebx)
21497 jmp 5000b
21498
21499 .previous
21500
21501 + pushl_cfi %ss
21502 + popl_cfi %ds
21503 + pushl_cfi %ss
21504 + popl_cfi %es
21505 popl_cfi %ebx
21506 CFI_RESTORE ebx
21507 popl_cfi %esi
21508 @@ -424,26 +444,43 @@ DST( movb %cl, (%edi) )
21509 popl_cfi %ecx # equivalent to addl $4,%esp
21510 ret
21511 CFI_ENDPROC
21512 -ENDPROC(csum_partial_copy_generic)
21513 +ENDPROC(csum_partial_copy_generic_to_user)
21514
21515 #else
21516
21517 /* Version for PentiumII/PPro */
21518
21519 #define ROUND1(x) \
21520 + nop; nop; nop; \
21521 SRC(movl x(%esi), %ebx ) ; \
21522 addl %ebx, %eax ; \
21523 - DST(movl %ebx, x(%edi) ) ;
21524 + DST(movl %ebx, %es:x(%edi)) ;
21525
21526 #define ROUND(x) \
21527 + nop; nop; nop; \
21528 SRC(movl x(%esi), %ebx ) ; \
21529 adcl %ebx, %eax ; \
21530 - DST(movl %ebx, x(%edi) ) ;
21531 + DST(movl %ebx, %es:x(%edi)) ;
21532
21533 #define ARGBASE 12
21534 -
21535 -ENTRY(csum_partial_copy_generic)
21536 +
21537 +ENTRY(csum_partial_copy_generic_to_user)
21538 CFI_STARTPROC
21539 +
21540 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21541 + pushl_cfi %gs
21542 + popl_cfi %es
21543 + jmp csum_partial_copy_generic
21544 +#endif
21545 +
21546 +ENTRY(csum_partial_copy_generic_from_user)
21547 +
21548 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21549 + pushl_cfi %gs
21550 + popl_cfi %ds
21551 +#endif
21552 +
21553 +ENTRY(csum_partial_copy_generic)
21554 pushl_cfi %ebx
21555 CFI_REL_OFFSET ebx, 0
21556 pushl_cfi %edi
21557 @@ -464,7 +501,7 @@ ENTRY(csum_partial_copy_generic)
21558 subl %ebx, %edi
21559 lea -1(%esi),%edx
21560 andl $-32,%edx
21561 - lea 3f(%ebx,%ebx), %ebx
21562 + lea 3f(%ebx,%ebx,2), %ebx
21563 testl %esi, %esi
21564 jmp *%ebx
21565 1: addl $64,%esi
21566 @@ -485,19 +522,19 @@ ENTRY(csum_partial_copy_generic)
21567 jb 5f
21568 SRC( movw (%esi), %dx )
21569 leal 2(%esi), %esi
21570 -DST( movw %dx, (%edi) )
21571 +DST( movw %dx, %es:(%edi) )
21572 leal 2(%edi), %edi
21573 je 6f
21574 shll $16,%edx
21575 5:
21576 SRC( movb (%esi), %dl )
21577 -DST( movb %dl, (%edi) )
21578 +DST( movb %dl, %es:(%edi) )
21579 6: addl %edx, %eax
21580 adcl $0, %eax
21581 7:
21582 .section .fixup, "ax"
21583 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
21584 - movl $-EFAULT, (%ebx)
21585 + movl $-EFAULT, %ss:(%ebx)
21586 # zero the complete destination (computing the rest is too much work)
21587 movl ARGBASE+8(%esp),%edi # dst
21588 movl ARGBASE+12(%esp),%ecx # len
21589 @@ -505,10 +542,17 @@ DST( movb %dl, (%edi) )
21590 rep; stosb
21591 jmp 7b
21592 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
21593 - movl $-EFAULT, (%ebx)
21594 + movl $-EFAULT, %ss:(%ebx)
21595 jmp 7b
21596 .previous
21597
21598 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21599 + pushl_cfi %ss
21600 + popl_cfi %ds
21601 + pushl_cfi %ss
21602 + popl_cfi %es
21603 +#endif
21604 +
21605 popl_cfi %esi
21606 CFI_RESTORE esi
21607 popl_cfi %edi
21608 @@ -517,7 +561,7 @@ DST( movb %dl, (%edi) )
21609 CFI_RESTORE ebx
21610 ret
21611 CFI_ENDPROC
21612 -ENDPROC(csum_partial_copy_generic)
21613 +ENDPROC(csum_partial_copy_generic_to_user)
21614
21615 #undef ROUND
21616 #undef ROUND1
21617 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
21618 index f2145cf..cea889d 100644
21619 --- a/arch/x86/lib/clear_page_64.S
21620 +++ b/arch/x86/lib/clear_page_64.S
21621 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
21622 movl $4096/8,%ecx
21623 xorl %eax,%eax
21624 rep stosq
21625 + pax_force_retaddr
21626 ret
21627 CFI_ENDPROC
21628 ENDPROC(clear_page_c)
21629 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
21630 movl $4096,%ecx
21631 xorl %eax,%eax
21632 rep stosb
21633 + pax_force_retaddr
21634 ret
21635 CFI_ENDPROC
21636 ENDPROC(clear_page_c_e)
21637 @@ -43,6 +45,7 @@ ENTRY(clear_page)
21638 leaq 64(%rdi),%rdi
21639 jnz .Lloop
21640 nop
21641 + pax_force_retaddr
21642 ret
21643 CFI_ENDPROC
21644 .Lclear_page_end:
21645 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
21646
21647 #include <asm/cpufeature.h>
21648
21649 - .section .altinstr_replacement,"ax"
21650 + .section .altinstr_replacement,"a"
21651 1: .byte 0xeb /* jmp <disp8> */
21652 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
21653 2: .byte 0xeb /* jmp <disp8> */
21654 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
21655 index 1e572c5..2a162cd 100644
21656 --- a/arch/x86/lib/cmpxchg16b_emu.S
21657 +++ b/arch/x86/lib/cmpxchg16b_emu.S
21658 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
21659
21660 popf
21661 mov $1, %al
21662 + pax_force_retaddr
21663 ret
21664
21665 not_same:
21666 popf
21667 xor %al,%al
21668 + pax_force_retaddr
21669 ret
21670
21671 CFI_ENDPROC
21672 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
21673 index 01c805b..dccb07f 100644
21674 --- a/arch/x86/lib/copy_page_64.S
21675 +++ b/arch/x86/lib/copy_page_64.S
21676 @@ -9,6 +9,7 @@ copy_page_c:
21677 CFI_STARTPROC
21678 movl $4096/8,%ecx
21679 rep movsq
21680 + pax_force_retaddr
21681 ret
21682 CFI_ENDPROC
21683 ENDPROC(copy_page_c)
21684 @@ -39,7 +40,7 @@ ENTRY(copy_page)
21685 movq 16 (%rsi), %rdx
21686 movq 24 (%rsi), %r8
21687 movq 32 (%rsi), %r9
21688 - movq 40 (%rsi), %r10
21689 + movq 40 (%rsi), %r13
21690 movq 48 (%rsi), %r11
21691 movq 56 (%rsi), %r12
21692
21693 @@ -50,7 +51,7 @@ ENTRY(copy_page)
21694 movq %rdx, 16 (%rdi)
21695 movq %r8, 24 (%rdi)
21696 movq %r9, 32 (%rdi)
21697 - movq %r10, 40 (%rdi)
21698 + movq %r13, 40 (%rdi)
21699 movq %r11, 48 (%rdi)
21700 movq %r12, 56 (%rdi)
21701
21702 @@ -69,7 +70,7 @@ ENTRY(copy_page)
21703 movq 16 (%rsi), %rdx
21704 movq 24 (%rsi), %r8
21705 movq 32 (%rsi), %r9
21706 - movq 40 (%rsi), %r10
21707 + movq 40 (%rsi), %r13
21708 movq 48 (%rsi), %r11
21709 movq 56 (%rsi), %r12
21710
21711 @@ -78,7 +79,7 @@ ENTRY(copy_page)
21712 movq %rdx, 16 (%rdi)
21713 movq %r8, 24 (%rdi)
21714 movq %r9, 32 (%rdi)
21715 - movq %r10, 40 (%rdi)
21716 + movq %r13, 40 (%rdi)
21717 movq %r11, 48 (%rdi)
21718 movq %r12, 56 (%rdi)
21719
21720 @@ -95,6 +96,7 @@ ENTRY(copy_page)
21721 CFI_RESTORE r13
21722 addq $3*8,%rsp
21723 CFI_ADJUST_CFA_OFFSET -3*8
21724 + pax_force_retaddr
21725 ret
21726 .Lcopy_page_end:
21727 CFI_ENDPROC
21728 @@ -105,7 +107,7 @@ ENDPROC(copy_page)
21729
21730 #include <asm/cpufeature.h>
21731
21732 - .section .altinstr_replacement,"ax"
21733 + .section .altinstr_replacement,"a"
21734 1: .byte 0xeb /* jmp <disp8> */
21735 .byte (copy_page_c - copy_page) - (2f - 1b) /* offset */
21736 2:
21737 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
21738 index 0248402..821c786 100644
21739 --- a/arch/x86/lib/copy_user_64.S
21740 +++ b/arch/x86/lib/copy_user_64.S
21741 @@ -16,6 +16,7 @@
21742 #include <asm/thread_info.h>
21743 #include <asm/cpufeature.h>
21744 #include <asm/alternative-asm.h>
21745 +#include <asm/pgtable.h>
21746
21747 /*
21748 * By placing feature2 after feature1 in altinstructions section, we logically
21749 @@ -29,7 +30,7 @@
21750 .byte 0xe9 /* 32bit jump */
21751 .long \orig-1f /* by default jump to orig */
21752 1:
21753 - .section .altinstr_replacement,"ax"
21754 + .section .altinstr_replacement,"a"
21755 2: .byte 0xe9 /* near jump with 32bit immediate */
21756 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
21757 3: .byte 0xe9 /* near jump with 32bit immediate */
21758 @@ -71,47 +72,20 @@
21759 #endif
21760 .endm
21761
21762 -/* Standard copy_to_user with segment limit checking */
21763 -ENTRY(_copy_to_user)
21764 - CFI_STARTPROC
21765 - GET_THREAD_INFO(%rax)
21766 - movq %rdi,%rcx
21767 - addq %rdx,%rcx
21768 - jc bad_to_user
21769 - cmpq TI_addr_limit(%rax),%rcx
21770 - ja bad_to_user
21771 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
21772 - copy_user_generic_unrolled,copy_user_generic_string, \
21773 - copy_user_enhanced_fast_string
21774 - CFI_ENDPROC
21775 -ENDPROC(_copy_to_user)
21776 -
21777 -/* Standard copy_from_user with segment limit checking */
21778 -ENTRY(_copy_from_user)
21779 - CFI_STARTPROC
21780 - GET_THREAD_INFO(%rax)
21781 - movq %rsi,%rcx
21782 - addq %rdx,%rcx
21783 - jc bad_from_user
21784 - cmpq TI_addr_limit(%rax),%rcx
21785 - ja bad_from_user
21786 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
21787 - copy_user_generic_unrolled,copy_user_generic_string, \
21788 - copy_user_enhanced_fast_string
21789 - CFI_ENDPROC
21790 -ENDPROC(_copy_from_user)
21791 -
21792 .section .fixup,"ax"
21793 /* must zero dest */
21794 ENTRY(bad_from_user)
21795 bad_from_user:
21796 CFI_STARTPROC
21797 + testl %edx,%edx
21798 + js bad_to_user
21799 movl %edx,%ecx
21800 xorl %eax,%eax
21801 rep
21802 stosb
21803 bad_to_user:
21804 movl %edx,%eax
21805 + pax_force_retaddr
21806 ret
21807 CFI_ENDPROC
21808 ENDPROC(bad_from_user)
21809 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
21810 jz 17f
21811 1: movq (%rsi),%r8
21812 2: movq 1*8(%rsi),%r9
21813 -3: movq 2*8(%rsi),%r10
21814 +3: movq 2*8(%rsi),%rax
21815 4: movq 3*8(%rsi),%r11
21816 5: movq %r8,(%rdi)
21817 6: movq %r9,1*8(%rdi)
21818 -7: movq %r10,2*8(%rdi)
21819 +7: movq %rax,2*8(%rdi)
21820 8: movq %r11,3*8(%rdi)
21821 9: movq 4*8(%rsi),%r8
21822 10: movq 5*8(%rsi),%r9
21823 -11: movq 6*8(%rsi),%r10
21824 +11: movq 6*8(%rsi),%rax
21825 12: movq 7*8(%rsi),%r11
21826 13: movq %r8,4*8(%rdi)
21827 14: movq %r9,5*8(%rdi)
21828 -15: movq %r10,6*8(%rdi)
21829 +15: movq %rax,6*8(%rdi)
21830 16: movq %r11,7*8(%rdi)
21831 leaq 64(%rsi),%rsi
21832 leaq 64(%rdi),%rdi
21833 @@ -179,6 +153,7 @@ ENTRY(copy_user_generic_unrolled)
21834 decl %ecx
21835 jnz 21b
21836 23: xor %eax,%eax
21837 + pax_force_retaddr
21838 ret
21839
21840 .section .fixup,"ax"
21841 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
21842 3: rep
21843 movsb
21844 4: xorl %eax,%eax
21845 + pax_force_retaddr
21846 ret
21847
21848 .section .fixup,"ax"
21849 @@ -287,6 +263,7 @@ ENTRY(copy_user_enhanced_fast_string)
21850 1: rep
21851 movsb
21852 2: xorl %eax,%eax
21853 + pax_force_retaddr
21854 ret
21855
21856 .section .fixup,"ax"
21857 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
21858 index cb0c112..e3a6895 100644
21859 --- a/arch/x86/lib/copy_user_nocache_64.S
21860 +++ b/arch/x86/lib/copy_user_nocache_64.S
21861 @@ -8,12 +8,14 @@
21862
21863 #include <linux/linkage.h>
21864 #include <asm/dwarf2.h>
21865 +#include <asm/alternative-asm.h>
21866
21867 #define FIX_ALIGNMENT 1
21868
21869 #include <asm/current.h>
21870 #include <asm/asm-offsets.h>
21871 #include <asm/thread_info.h>
21872 +#include <asm/pgtable.h>
21873
21874 .macro ALIGN_DESTINATION
21875 #ifdef FIX_ALIGNMENT
21876 @@ -50,6 +52,15 @@
21877 */
21878 ENTRY(__copy_user_nocache)
21879 CFI_STARTPROC
21880 +
21881 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21882 + mov $PAX_USER_SHADOW_BASE,%rcx
21883 + cmp %rcx,%rsi
21884 + jae 1f
21885 + add %rcx,%rsi
21886 +1:
21887 +#endif
21888 +
21889 cmpl $8,%edx
21890 jb 20f /* less then 8 bytes, go to byte copy loop */
21891 ALIGN_DESTINATION
21892 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
21893 jz 17f
21894 1: movq (%rsi),%r8
21895 2: movq 1*8(%rsi),%r9
21896 -3: movq 2*8(%rsi),%r10
21897 +3: movq 2*8(%rsi),%rax
21898 4: movq 3*8(%rsi),%r11
21899 5: movnti %r8,(%rdi)
21900 6: movnti %r9,1*8(%rdi)
21901 -7: movnti %r10,2*8(%rdi)
21902 +7: movnti %rax,2*8(%rdi)
21903 8: movnti %r11,3*8(%rdi)
21904 9: movq 4*8(%rsi),%r8
21905 10: movq 5*8(%rsi),%r9
21906 -11: movq 6*8(%rsi),%r10
21907 +11: movq 6*8(%rsi),%rax
21908 12: movq 7*8(%rsi),%r11
21909 13: movnti %r8,4*8(%rdi)
21910 14: movnti %r9,5*8(%rdi)
21911 -15: movnti %r10,6*8(%rdi)
21912 +15: movnti %rax,6*8(%rdi)
21913 16: movnti %r11,7*8(%rdi)
21914 leaq 64(%rsi),%rsi
21915 leaq 64(%rdi),%rdi
21916 @@ -98,6 +109,7 @@ ENTRY(__copy_user_nocache)
21917 jnz 21b
21918 23: xorl %eax,%eax
21919 sfence
21920 + pax_force_retaddr
21921 ret
21922
21923 .section .fixup,"ax"
21924 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
21925 index fb903b7..c92b7f7 100644
21926 --- a/arch/x86/lib/csum-copy_64.S
21927 +++ b/arch/x86/lib/csum-copy_64.S
21928 @@ -8,6 +8,7 @@
21929 #include <linux/linkage.h>
21930 #include <asm/dwarf2.h>
21931 #include <asm/errno.h>
21932 +#include <asm/alternative-asm.h>
21933
21934 /*
21935 * Checksum copy with exception handling.
21936 @@ -228,6 +229,7 @@ ENTRY(csum_partial_copy_generic)
21937 CFI_RESTORE rbp
21938 addq $7*8, %rsp
21939 CFI_ADJUST_CFA_OFFSET -7*8
21940 + pax_force_retaddr 0, 1
21941 ret
21942 CFI_RESTORE_STATE
21943
21944 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
21945 index 459b58a..9570bc7 100644
21946 --- a/arch/x86/lib/csum-wrappers_64.c
21947 +++ b/arch/x86/lib/csum-wrappers_64.c
21948 @@ -52,7 +52,13 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
21949 len -= 2;
21950 }
21951 }
21952 - isum = csum_partial_copy_generic((__force const void *)src,
21953 +
21954 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21955 + if ((unsigned long)src < PAX_USER_SHADOW_BASE)
21956 + src += PAX_USER_SHADOW_BASE;
21957 +#endif
21958 +
21959 + isum = csum_partial_copy_generic((const void __force_kernel *)src,
21960 dst, len, isum, errp, NULL);
21961 if (unlikely(*errp))
21962 goto out_err;
21963 @@ -105,7 +111,13 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
21964 }
21965
21966 *errp = 0;
21967 - return csum_partial_copy_generic(src, (void __force *)dst,
21968 +
21969 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21970 + if ((unsigned long)dst < PAX_USER_SHADOW_BASE)
21971 + dst += PAX_USER_SHADOW_BASE;
21972 +#endif
21973 +
21974 + return csum_partial_copy_generic(src, (void __force_kernel *)dst,
21975 len, isum, NULL, errp);
21976 }
21977 EXPORT_SYMBOL(csum_partial_copy_to_user);
21978 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
21979 index 51f1504..ddac4c1 100644
21980 --- a/arch/x86/lib/getuser.S
21981 +++ b/arch/x86/lib/getuser.S
21982 @@ -33,15 +33,38 @@
21983 #include <asm/asm-offsets.h>
21984 #include <asm/thread_info.h>
21985 #include <asm/asm.h>
21986 +#include <asm/segment.h>
21987 +#include <asm/pgtable.h>
21988 +#include <asm/alternative-asm.h>
21989 +
21990 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
21991 +#define __copyuser_seg gs;
21992 +#else
21993 +#define __copyuser_seg
21994 +#endif
21995
21996 .text
21997 ENTRY(__get_user_1)
21998 CFI_STARTPROC
21999 +
22000 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
22001 GET_THREAD_INFO(%_ASM_DX)
22002 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
22003 jae bad_get_user
22004 -1: movzb (%_ASM_AX),%edx
22005 +
22006 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
22007 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
22008 + cmp %_ASM_DX,%_ASM_AX
22009 + jae 1234f
22010 + add %_ASM_DX,%_ASM_AX
22011 +1234:
22012 +#endif
22013 +
22014 +#endif
22015 +
22016 +1: __copyuser_seg movzb (%_ASM_AX),%edx
22017 xor %eax,%eax
22018 + pax_force_retaddr
22019 ret
22020 CFI_ENDPROC
22021 ENDPROC(__get_user_1)
22022 @@ -49,12 +72,26 @@ ENDPROC(__get_user_1)
22023 ENTRY(__get_user_2)
22024 CFI_STARTPROC
22025 add $1,%_ASM_AX
22026 +
22027 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
22028 jc bad_get_user
22029 GET_THREAD_INFO(%_ASM_DX)
22030 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
22031 jae bad_get_user
22032 -2: movzwl -1(%_ASM_AX),%edx
22033 +
22034 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
22035 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
22036 + cmp %_ASM_DX,%_ASM_AX
22037 + jae 1234f
22038 + add %_ASM_DX,%_ASM_AX
22039 +1234:
22040 +#endif
22041 +
22042 +#endif
22043 +
22044 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
22045 xor %eax,%eax
22046 + pax_force_retaddr
22047 ret
22048 CFI_ENDPROC
22049 ENDPROC(__get_user_2)
22050 @@ -62,12 +99,26 @@ ENDPROC(__get_user_2)
22051 ENTRY(__get_user_4)
22052 CFI_STARTPROC
22053 add $3,%_ASM_AX
22054 +
22055 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
22056 jc bad_get_user
22057 GET_THREAD_INFO(%_ASM_DX)
22058 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
22059 jae bad_get_user
22060 -3: mov -3(%_ASM_AX),%edx
22061 +
22062 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
22063 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
22064 + cmp %_ASM_DX,%_ASM_AX
22065 + jae 1234f
22066 + add %_ASM_DX,%_ASM_AX
22067 +1234:
22068 +#endif
22069 +
22070 +#endif
22071 +
22072 +3: __copyuser_seg mov -3(%_ASM_AX),%edx
22073 xor %eax,%eax
22074 + pax_force_retaddr
22075 ret
22076 CFI_ENDPROC
22077 ENDPROC(__get_user_4)
22078 @@ -80,8 +131,18 @@ ENTRY(__get_user_8)
22079 GET_THREAD_INFO(%_ASM_DX)
22080 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
22081 jae bad_get_user
22082 +
22083 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22084 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
22085 + cmp %_ASM_DX,%_ASM_AX
22086 + jae 1234f
22087 + add %_ASM_DX,%_ASM_AX
22088 +1234:
22089 +#endif
22090 +
22091 4: movq -7(%_ASM_AX),%_ASM_DX
22092 xor %eax,%eax
22093 + pax_force_retaddr
22094 ret
22095 CFI_ENDPROC
22096 ENDPROC(__get_user_8)
22097 @@ -91,6 +152,7 @@ bad_get_user:
22098 CFI_STARTPROC
22099 xor %edx,%edx
22100 mov $(-EFAULT),%_ASM_AX
22101 + pax_force_retaddr
22102 ret
22103 CFI_ENDPROC
22104 END(bad_get_user)
22105 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
22106 index 5a1f9f3..ba9f577 100644
22107 --- a/arch/x86/lib/insn.c
22108 +++ b/arch/x86/lib/insn.c
22109 @@ -21,6 +21,11 @@
22110 #include <linux/string.h>
22111 #include <asm/inat.h>
22112 #include <asm/insn.h>
22113 +#ifdef __KERNEL__
22114 +#include <asm/pgtable_types.h>
22115 +#else
22116 +#define ktla_ktva(addr) addr
22117 +#endif
22118
22119 /* Verify next sizeof(t) bytes can be on the same instruction */
22120 #define validate_next(t, insn, n) \
22121 @@ -49,8 +54,8 @@
22122 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
22123 {
22124 memset(insn, 0, sizeof(*insn));
22125 - insn->kaddr = kaddr;
22126 - insn->next_byte = kaddr;
22127 + insn->kaddr = ktla_ktva(kaddr);
22128 + insn->next_byte = ktla_ktva(kaddr);
22129 insn->x86_64 = x86_64 ? 1 : 0;
22130 insn->opnd_bytes = 4;
22131 if (x86_64)
22132 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
22133 index 05a95e7..326f2fa 100644
22134 --- a/arch/x86/lib/iomap_copy_64.S
22135 +++ b/arch/x86/lib/iomap_copy_64.S
22136 @@ -17,6 +17,7 @@
22137
22138 #include <linux/linkage.h>
22139 #include <asm/dwarf2.h>
22140 +#include <asm/alternative-asm.h>
22141
22142 /*
22143 * override generic version in lib/iomap_copy.c
22144 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
22145 CFI_STARTPROC
22146 movl %edx,%ecx
22147 rep movsd
22148 + pax_force_retaddr
22149 ret
22150 CFI_ENDPROC
22151 ENDPROC(__iowrite32_copy)
22152 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
22153 index efbf2a0..8893637 100644
22154 --- a/arch/x86/lib/memcpy_64.S
22155 +++ b/arch/x86/lib/memcpy_64.S
22156 @@ -34,6 +34,7 @@
22157 rep movsq
22158 movl %edx, %ecx
22159 rep movsb
22160 + pax_force_retaddr
22161 ret
22162 .Lmemcpy_e:
22163 .previous
22164 @@ -51,6 +52,7 @@
22165
22166 movl %edx, %ecx
22167 rep movsb
22168 + pax_force_retaddr
22169 ret
22170 .Lmemcpy_e_e:
22171 .previous
22172 @@ -81,13 +83,13 @@ ENTRY(memcpy)
22173 */
22174 movq 0*8(%rsi), %r8
22175 movq 1*8(%rsi), %r9
22176 - movq 2*8(%rsi), %r10
22177 + movq 2*8(%rsi), %rcx
22178 movq 3*8(%rsi), %r11
22179 leaq 4*8(%rsi), %rsi
22180
22181 movq %r8, 0*8(%rdi)
22182 movq %r9, 1*8(%rdi)
22183 - movq %r10, 2*8(%rdi)
22184 + movq %rcx, 2*8(%rdi)
22185 movq %r11, 3*8(%rdi)
22186 leaq 4*8(%rdi), %rdi
22187 jae .Lcopy_forward_loop
22188 @@ -110,12 +112,12 @@ ENTRY(memcpy)
22189 subq $0x20, %rdx
22190 movq -1*8(%rsi), %r8
22191 movq -2*8(%rsi), %r9
22192 - movq -3*8(%rsi), %r10
22193 + movq -3*8(%rsi), %rcx
22194 movq -4*8(%rsi), %r11
22195 leaq -4*8(%rsi), %rsi
22196 movq %r8, -1*8(%rdi)
22197 movq %r9, -2*8(%rdi)
22198 - movq %r10, -3*8(%rdi)
22199 + movq %rcx, -3*8(%rdi)
22200 movq %r11, -4*8(%rdi)
22201 leaq -4*8(%rdi), %rdi
22202 jae .Lcopy_backward_loop
22203 @@ -135,12 +137,13 @@ ENTRY(memcpy)
22204 */
22205 movq 0*8(%rsi), %r8
22206 movq 1*8(%rsi), %r9
22207 - movq -2*8(%rsi, %rdx), %r10
22208 + movq -2*8(%rsi, %rdx), %rcx
22209 movq -1*8(%rsi, %rdx), %r11
22210 movq %r8, 0*8(%rdi)
22211 movq %r9, 1*8(%rdi)
22212 - movq %r10, -2*8(%rdi, %rdx)
22213 + movq %rcx, -2*8(%rdi, %rdx)
22214 movq %r11, -1*8(%rdi, %rdx)
22215 + pax_force_retaddr
22216 retq
22217 .p2align 4
22218 .Lless_16bytes:
22219 @@ -153,6 +156,7 @@ ENTRY(memcpy)
22220 movq -1*8(%rsi, %rdx), %r9
22221 movq %r8, 0*8(%rdi)
22222 movq %r9, -1*8(%rdi, %rdx)
22223 + pax_force_retaddr
22224 retq
22225 .p2align 4
22226 .Lless_8bytes:
22227 @@ -166,6 +170,7 @@ ENTRY(memcpy)
22228 movl -4(%rsi, %rdx), %r8d
22229 movl %ecx, (%rdi)
22230 movl %r8d, -4(%rdi, %rdx)
22231 + pax_force_retaddr
22232 retq
22233 .p2align 4
22234 .Lless_3bytes:
22235 @@ -183,6 +188,7 @@ ENTRY(memcpy)
22236 jnz .Lloop_1
22237
22238 .Lend:
22239 + pax_force_retaddr
22240 retq
22241 CFI_ENDPROC
22242 ENDPROC(memcpy)
22243 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
22244 index ee16461..c39c199 100644
22245 --- a/arch/x86/lib/memmove_64.S
22246 +++ b/arch/x86/lib/memmove_64.S
22247 @@ -61,13 +61,13 @@ ENTRY(memmove)
22248 5:
22249 sub $0x20, %rdx
22250 movq 0*8(%rsi), %r11
22251 - movq 1*8(%rsi), %r10
22252 + movq 1*8(%rsi), %rcx
22253 movq 2*8(%rsi), %r9
22254 movq 3*8(%rsi), %r8
22255 leaq 4*8(%rsi), %rsi
22256
22257 movq %r11, 0*8(%rdi)
22258 - movq %r10, 1*8(%rdi)
22259 + movq %rcx, 1*8(%rdi)
22260 movq %r9, 2*8(%rdi)
22261 movq %r8, 3*8(%rdi)
22262 leaq 4*8(%rdi), %rdi
22263 @@ -81,10 +81,10 @@ ENTRY(memmove)
22264 4:
22265 movq %rdx, %rcx
22266 movq -8(%rsi, %rdx), %r11
22267 - lea -8(%rdi, %rdx), %r10
22268 + lea -8(%rdi, %rdx), %r9
22269 shrq $3, %rcx
22270 rep movsq
22271 - movq %r11, (%r10)
22272 + movq %r11, (%r9)
22273 jmp 13f
22274 .Lmemmove_end_forward:
22275
22276 @@ -95,14 +95,14 @@ ENTRY(memmove)
22277 7:
22278 movq %rdx, %rcx
22279 movq (%rsi), %r11
22280 - movq %rdi, %r10
22281 + movq %rdi, %r9
22282 leaq -8(%rsi, %rdx), %rsi
22283 leaq -8(%rdi, %rdx), %rdi
22284 shrq $3, %rcx
22285 std
22286 rep movsq
22287 cld
22288 - movq %r11, (%r10)
22289 + movq %r11, (%r9)
22290 jmp 13f
22291
22292 /*
22293 @@ -127,13 +127,13 @@ ENTRY(memmove)
22294 8:
22295 subq $0x20, %rdx
22296 movq -1*8(%rsi), %r11
22297 - movq -2*8(%rsi), %r10
22298 + movq -2*8(%rsi), %rcx
22299 movq -3*8(%rsi), %r9
22300 movq -4*8(%rsi), %r8
22301 leaq -4*8(%rsi), %rsi
22302
22303 movq %r11, -1*8(%rdi)
22304 - movq %r10, -2*8(%rdi)
22305 + movq %rcx, -2*8(%rdi)
22306 movq %r9, -3*8(%rdi)
22307 movq %r8, -4*8(%rdi)
22308 leaq -4*8(%rdi), %rdi
22309 @@ -151,11 +151,11 @@ ENTRY(memmove)
22310 * Move data from 16 bytes to 31 bytes.
22311 */
22312 movq 0*8(%rsi), %r11
22313 - movq 1*8(%rsi), %r10
22314 + movq 1*8(%rsi), %rcx
22315 movq -2*8(%rsi, %rdx), %r9
22316 movq -1*8(%rsi, %rdx), %r8
22317 movq %r11, 0*8(%rdi)
22318 - movq %r10, 1*8(%rdi)
22319 + movq %rcx, 1*8(%rdi)
22320 movq %r9, -2*8(%rdi, %rdx)
22321 movq %r8, -1*8(%rdi, %rdx)
22322 jmp 13f
22323 @@ -167,9 +167,9 @@ ENTRY(memmove)
22324 * Move data from 8 bytes to 15 bytes.
22325 */
22326 movq 0*8(%rsi), %r11
22327 - movq -1*8(%rsi, %rdx), %r10
22328 + movq -1*8(%rsi, %rdx), %r9
22329 movq %r11, 0*8(%rdi)
22330 - movq %r10, -1*8(%rdi, %rdx)
22331 + movq %r9, -1*8(%rdi, %rdx)
22332 jmp 13f
22333 10:
22334 cmpq $4, %rdx
22335 @@ -178,9 +178,9 @@ ENTRY(memmove)
22336 * Move data from 4 bytes to 7 bytes.
22337 */
22338 movl (%rsi), %r11d
22339 - movl -4(%rsi, %rdx), %r10d
22340 + movl -4(%rsi, %rdx), %r9d
22341 movl %r11d, (%rdi)
22342 - movl %r10d, -4(%rdi, %rdx)
22343 + movl %r9d, -4(%rdi, %rdx)
22344 jmp 13f
22345 11:
22346 cmp $2, %rdx
22347 @@ -189,9 +189,9 @@ ENTRY(memmove)
22348 * Move data from 2 bytes to 3 bytes.
22349 */
22350 movw (%rsi), %r11w
22351 - movw -2(%rsi, %rdx), %r10w
22352 + movw -2(%rsi, %rdx), %r9w
22353 movw %r11w, (%rdi)
22354 - movw %r10w, -2(%rdi, %rdx)
22355 + movw %r9w, -2(%rdi, %rdx)
22356 jmp 13f
22357 12:
22358 cmp $1, %rdx
22359 @@ -202,6 +202,7 @@ ENTRY(memmove)
22360 movb (%rsi), %r11b
22361 movb %r11b, (%rdi)
22362 13:
22363 + pax_force_retaddr
22364 retq
22365 CFI_ENDPROC
22366
22367 @@ -210,6 +211,7 @@ ENTRY(memmove)
22368 /* Forward moving data. */
22369 movq %rdx, %rcx
22370 rep movsb
22371 + pax_force_retaddr
22372 retq
22373 .Lmemmove_end_forward_efs:
22374 .previous
22375 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
22376 index 79bd454..dff325a 100644
22377 --- a/arch/x86/lib/memset_64.S
22378 +++ b/arch/x86/lib/memset_64.S
22379 @@ -31,6 +31,7 @@
22380 movl %r8d,%ecx
22381 rep stosb
22382 movq %r9,%rax
22383 + pax_force_retaddr
22384 ret
22385 .Lmemset_e:
22386 .previous
22387 @@ -53,6 +54,7 @@
22388 movl %edx,%ecx
22389 rep stosb
22390 movq %r9,%rax
22391 + pax_force_retaddr
22392 ret
22393 .Lmemset_e_e:
22394 .previous
22395 @@ -60,13 +62,13 @@
22396 ENTRY(memset)
22397 ENTRY(__memset)
22398 CFI_STARTPROC
22399 - movq %rdi,%r10
22400 movq %rdx,%r11
22401
22402 /* expand byte value */
22403 movzbl %sil,%ecx
22404 movabs $0x0101010101010101,%rax
22405 mul %rcx /* with rax, clobbers rdx */
22406 + movq %rdi,%rdx
22407
22408 /* align dst */
22409 movl %edi,%r9d
22410 @@ -120,7 +122,8 @@ ENTRY(__memset)
22411 jnz .Lloop_1
22412
22413 .Lende:
22414 - movq %r10,%rax
22415 + movq %rdx,%rax
22416 + pax_force_retaddr
22417 ret
22418
22419 CFI_RESTORE_STATE
22420 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
22421 index c9f2d9b..e7fd2c0 100644
22422 --- a/arch/x86/lib/mmx_32.c
22423 +++ b/arch/x86/lib/mmx_32.c
22424 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
22425 {
22426 void *p;
22427 int i;
22428 + unsigned long cr0;
22429
22430 if (unlikely(in_interrupt()))
22431 return __memcpy(to, from, len);
22432 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
22433 kernel_fpu_begin();
22434
22435 __asm__ __volatile__ (
22436 - "1: prefetch (%0)\n" /* This set is 28 bytes */
22437 - " prefetch 64(%0)\n"
22438 - " prefetch 128(%0)\n"
22439 - " prefetch 192(%0)\n"
22440 - " prefetch 256(%0)\n"
22441 + "1: prefetch (%1)\n" /* This set is 28 bytes */
22442 + " prefetch 64(%1)\n"
22443 + " prefetch 128(%1)\n"
22444 + " prefetch 192(%1)\n"
22445 + " prefetch 256(%1)\n"
22446 "2: \n"
22447 ".section .fixup, \"ax\"\n"
22448 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
22449 + "3: \n"
22450 +
22451 +#ifdef CONFIG_PAX_KERNEXEC
22452 + " movl %%cr0, %0\n"
22453 + " movl %0, %%eax\n"
22454 + " andl $0xFFFEFFFF, %%eax\n"
22455 + " movl %%eax, %%cr0\n"
22456 +#endif
22457 +
22458 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
22459 +
22460 +#ifdef CONFIG_PAX_KERNEXEC
22461 + " movl %0, %%cr0\n"
22462 +#endif
22463 +
22464 " jmp 2b\n"
22465 ".previous\n"
22466 _ASM_EXTABLE(1b, 3b)
22467 - : : "r" (from));
22468 + : "=&r" (cr0) : "r" (from) : "ax");
22469
22470 for ( ; i > 5; i--) {
22471 __asm__ __volatile__ (
22472 - "1: prefetch 320(%0)\n"
22473 - "2: movq (%0), %%mm0\n"
22474 - " movq 8(%0), %%mm1\n"
22475 - " movq 16(%0), %%mm2\n"
22476 - " movq 24(%0), %%mm3\n"
22477 - " movq %%mm0, (%1)\n"
22478 - " movq %%mm1, 8(%1)\n"
22479 - " movq %%mm2, 16(%1)\n"
22480 - " movq %%mm3, 24(%1)\n"
22481 - " movq 32(%0), %%mm0\n"
22482 - " movq 40(%0), %%mm1\n"
22483 - " movq 48(%0), %%mm2\n"
22484 - " movq 56(%0), %%mm3\n"
22485 - " movq %%mm0, 32(%1)\n"
22486 - " movq %%mm1, 40(%1)\n"
22487 - " movq %%mm2, 48(%1)\n"
22488 - " movq %%mm3, 56(%1)\n"
22489 + "1: prefetch 320(%1)\n"
22490 + "2: movq (%1), %%mm0\n"
22491 + " movq 8(%1), %%mm1\n"
22492 + " movq 16(%1), %%mm2\n"
22493 + " movq 24(%1), %%mm3\n"
22494 + " movq %%mm0, (%2)\n"
22495 + " movq %%mm1, 8(%2)\n"
22496 + " movq %%mm2, 16(%2)\n"
22497 + " movq %%mm3, 24(%2)\n"
22498 + " movq 32(%1), %%mm0\n"
22499 + " movq 40(%1), %%mm1\n"
22500 + " movq 48(%1), %%mm2\n"
22501 + " movq 56(%1), %%mm3\n"
22502 + " movq %%mm0, 32(%2)\n"
22503 + " movq %%mm1, 40(%2)\n"
22504 + " movq %%mm2, 48(%2)\n"
22505 + " movq %%mm3, 56(%2)\n"
22506 ".section .fixup, \"ax\"\n"
22507 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
22508 + "3:\n"
22509 +
22510 +#ifdef CONFIG_PAX_KERNEXEC
22511 + " movl %%cr0, %0\n"
22512 + " movl %0, %%eax\n"
22513 + " andl $0xFFFEFFFF, %%eax\n"
22514 + " movl %%eax, %%cr0\n"
22515 +#endif
22516 +
22517 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
22518 +
22519 +#ifdef CONFIG_PAX_KERNEXEC
22520 + " movl %0, %%cr0\n"
22521 +#endif
22522 +
22523 " jmp 2b\n"
22524 ".previous\n"
22525 _ASM_EXTABLE(1b, 3b)
22526 - : : "r" (from), "r" (to) : "memory");
22527 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
22528
22529 from += 64;
22530 to += 64;
22531 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
22532 static void fast_copy_page(void *to, void *from)
22533 {
22534 int i;
22535 + unsigned long cr0;
22536
22537 kernel_fpu_begin();
22538
22539 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
22540 * but that is for later. -AV
22541 */
22542 __asm__ __volatile__(
22543 - "1: prefetch (%0)\n"
22544 - " prefetch 64(%0)\n"
22545 - " prefetch 128(%0)\n"
22546 - " prefetch 192(%0)\n"
22547 - " prefetch 256(%0)\n"
22548 + "1: prefetch (%1)\n"
22549 + " prefetch 64(%1)\n"
22550 + " prefetch 128(%1)\n"
22551 + " prefetch 192(%1)\n"
22552 + " prefetch 256(%1)\n"
22553 "2: \n"
22554 ".section .fixup, \"ax\"\n"
22555 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
22556 + "3: \n"
22557 +
22558 +#ifdef CONFIG_PAX_KERNEXEC
22559 + " movl %%cr0, %0\n"
22560 + " movl %0, %%eax\n"
22561 + " andl $0xFFFEFFFF, %%eax\n"
22562 + " movl %%eax, %%cr0\n"
22563 +#endif
22564 +
22565 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
22566 +
22567 +#ifdef CONFIG_PAX_KERNEXEC
22568 + " movl %0, %%cr0\n"
22569 +#endif
22570 +
22571 " jmp 2b\n"
22572 ".previous\n"
22573 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
22574 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
22575
22576 for (i = 0; i < (4096-320)/64; i++) {
22577 __asm__ __volatile__ (
22578 - "1: prefetch 320(%0)\n"
22579 - "2: movq (%0), %%mm0\n"
22580 - " movntq %%mm0, (%1)\n"
22581 - " movq 8(%0), %%mm1\n"
22582 - " movntq %%mm1, 8(%1)\n"
22583 - " movq 16(%0), %%mm2\n"
22584 - " movntq %%mm2, 16(%1)\n"
22585 - " movq 24(%0), %%mm3\n"
22586 - " movntq %%mm3, 24(%1)\n"
22587 - " movq 32(%0), %%mm4\n"
22588 - " movntq %%mm4, 32(%1)\n"
22589 - " movq 40(%0), %%mm5\n"
22590 - " movntq %%mm5, 40(%1)\n"
22591 - " movq 48(%0), %%mm6\n"
22592 - " movntq %%mm6, 48(%1)\n"
22593 - " movq 56(%0), %%mm7\n"
22594 - " movntq %%mm7, 56(%1)\n"
22595 + "1: prefetch 320(%1)\n"
22596 + "2: movq (%1), %%mm0\n"
22597 + " movntq %%mm0, (%2)\n"
22598 + " movq 8(%1), %%mm1\n"
22599 + " movntq %%mm1, 8(%2)\n"
22600 + " movq 16(%1), %%mm2\n"
22601 + " movntq %%mm2, 16(%2)\n"
22602 + " movq 24(%1), %%mm3\n"
22603 + " movntq %%mm3, 24(%2)\n"
22604 + " movq 32(%1), %%mm4\n"
22605 + " movntq %%mm4, 32(%2)\n"
22606 + " movq 40(%1), %%mm5\n"
22607 + " movntq %%mm5, 40(%2)\n"
22608 + " movq 48(%1), %%mm6\n"
22609 + " movntq %%mm6, 48(%2)\n"
22610 + " movq 56(%1), %%mm7\n"
22611 + " movntq %%mm7, 56(%2)\n"
22612 ".section .fixup, \"ax\"\n"
22613 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
22614 + "3:\n"
22615 +
22616 +#ifdef CONFIG_PAX_KERNEXEC
22617 + " movl %%cr0, %0\n"
22618 + " movl %0, %%eax\n"
22619 + " andl $0xFFFEFFFF, %%eax\n"
22620 + " movl %%eax, %%cr0\n"
22621 +#endif
22622 +
22623 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
22624 +
22625 +#ifdef CONFIG_PAX_KERNEXEC
22626 + " movl %0, %%cr0\n"
22627 +#endif
22628 +
22629 " jmp 2b\n"
22630 ".previous\n"
22631 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
22632 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
22633
22634 from += 64;
22635 to += 64;
22636 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
22637 static void fast_copy_page(void *to, void *from)
22638 {
22639 int i;
22640 + unsigned long cr0;
22641
22642 kernel_fpu_begin();
22643
22644 __asm__ __volatile__ (
22645 - "1: prefetch (%0)\n"
22646 - " prefetch 64(%0)\n"
22647 - " prefetch 128(%0)\n"
22648 - " prefetch 192(%0)\n"
22649 - " prefetch 256(%0)\n"
22650 + "1: prefetch (%1)\n"
22651 + " prefetch 64(%1)\n"
22652 + " prefetch 128(%1)\n"
22653 + " prefetch 192(%1)\n"
22654 + " prefetch 256(%1)\n"
22655 "2: \n"
22656 ".section .fixup, \"ax\"\n"
22657 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
22658 + "3: \n"
22659 +
22660 +#ifdef CONFIG_PAX_KERNEXEC
22661 + " movl %%cr0, %0\n"
22662 + " movl %0, %%eax\n"
22663 + " andl $0xFFFEFFFF, %%eax\n"
22664 + " movl %%eax, %%cr0\n"
22665 +#endif
22666 +
22667 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
22668 +
22669 +#ifdef CONFIG_PAX_KERNEXEC
22670 + " movl %0, %%cr0\n"
22671 +#endif
22672 +
22673 " jmp 2b\n"
22674 ".previous\n"
22675 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
22676 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
22677
22678 for (i = 0; i < 4096/64; i++) {
22679 __asm__ __volatile__ (
22680 - "1: prefetch 320(%0)\n"
22681 - "2: movq (%0), %%mm0\n"
22682 - " movq 8(%0), %%mm1\n"
22683 - " movq 16(%0), %%mm2\n"
22684 - " movq 24(%0), %%mm3\n"
22685 - " movq %%mm0, (%1)\n"
22686 - " movq %%mm1, 8(%1)\n"
22687 - " movq %%mm2, 16(%1)\n"
22688 - " movq %%mm3, 24(%1)\n"
22689 - " movq 32(%0), %%mm0\n"
22690 - " movq 40(%0), %%mm1\n"
22691 - " movq 48(%0), %%mm2\n"
22692 - " movq 56(%0), %%mm3\n"
22693 - " movq %%mm0, 32(%1)\n"
22694 - " movq %%mm1, 40(%1)\n"
22695 - " movq %%mm2, 48(%1)\n"
22696 - " movq %%mm3, 56(%1)\n"
22697 + "1: prefetch 320(%1)\n"
22698 + "2: movq (%1), %%mm0\n"
22699 + " movq 8(%1), %%mm1\n"
22700 + " movq 16(%1), %%mm2\n"
22701 + " movq 24(%1), %%mm3\n"
22702 + " movq %%mm0, (%2)\n"
22703 + " movq %%mm1, 8(%2)\n"
22704 + " movq %%mm2, 16(%2)\n"
22705 + " movq %%mm3, 24(%2)\n"
22706 + " movq 32(%1), %%mm0\n"
22707 + " movq 40(%1), %%mm1\n"
22708 + " movq 48(%1), %%mm2\n"
22709 + " movq 56(%1), %%mm3\n"
22710 + " movq %%mm0, 32(%2)\n"
22711 + " movq %%mm1, 40(%2)\n"
22712 + " movq %%mm2, 48(%2)\n"
22713 + " movq %%mm3, 56(%2)\n"
22714 ".section .fixup, \"ax\"\n"
22715 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
22716 + "3:\n"
22717 +
22718 +#ifdef CONFIG_PAX_KERNEXEC
22719 + " movl %%cr0, %0\n"
22720 + " movl %0, %%eax\n"
22721 + " andl $0xFFFEFFFF, %%eax\n"
22722 + " movl %%eax, %%cr0\n"
22723 +#endif
22724 +
22725 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
22726 +
22727 +#ifdef CONFIG_PAX_KERNEXEC
22728 + " movl %0, %%cr0\n"
22729 +#endif
22730 +
22731 " jmp 2b\n"
22732 ".previous\n"
22733 _ASM_EXTABLE(1b, 3b)
22734 - : : "r" (from), "r" (to) : "memory");
22735 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
22736
22737 from += 64;
22738 to += 64;
22739 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
22740 index 69fa106..adda88b 100644
22741 --- a/arch/x86/lib/msr-reg.S
22742 +++ b/arch/x86/lib/msr-reg.S
22743 @@ -3,6 +3,7 @@
22744 #include <asm/dwarf2.h>
22745 #include <asm/asm.h>
22746 #include <asm/msr.h>
22747 +#include <asm/alternative-asm.h>
22748
22749 #ifdef CONFIG_X86_64
22750 /*
22751 @@ -16,7 +17,7 @@ ENTRY(native_\op\()_safe_regs)
22752 CFI_STARTPROC
22753 pushq_cfi %rbx
22754 pushq_cfi %rbp
22755 - movq %rdi, %r10 /* Save pointer */
22756 + movq %rdi, %r9 /* Save pointer */
22757 xorl %r11d, %r11d /* Return value */
22758 movl (%rdi), %eax
22759 movl 4(%rdi), %ecx
22760 @@ -27,16 +28,17 @@ ENTRY(native_\op\()_safe_regs)
22761 movl 28(%rdi), %edi
22762 CFI_REMEMBER_STATE
22763 1: \op
22764 -2: movl %eax, (%r10)
22765 +2: movl %eax, (%r9)
22766 movl %r11d, %eax /* Return value */
22767 - movl %ecx, 4(%r10)
22768 - movl %edx, 8(%r10)
22769 - movl %ebx, 12(%r10)
22770 - movl %ebp, 20(%r10)
22771 - movl %esi, 24(%r10)
22772 - movl %edi, 28(%r10)
22773 + movl %ecx, 4(%r9)
22774 + movl %edx, 8(%r9)
22775 + movl %ebx, 12(%r9)
22776 + movl %ebp, 20(%r9)
22777 + movl %esi, 24(%r9)
22778 + movl %edi, 28(%r9)
22779 popq_cfi %rbp
22780 popq_cfi %rbx
22781 + pax_force_retaddr
22782 ret
22783 3:
22784 CFI_RESTORE_STATE
22785 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
22786 index 36b0d15..d381858 100644
22787 --- a/arch/x86/lib/putuser.S
22788 +++ b/arch/x86/lib/putuser.S
22789 @@ -15,7 +15,9 @@
22790 #include <asm/thread_info.h>
22791 #include <asm/errno.h>
22792 #include <asm/asm.h>
22793 -
22794 +#include <asm/segment.h>
22795 +#include <asm/pgtable.h>
22796 +#include <asm/alternative-asm.h>
22797
22798 /*
22799 * __put_user_X
22800 @@ -29,52 +31,119 @@
22801 * as they get called from within inline assembly.
22802 */
22803
22804 -#define ENTER CFI_STARTPROC ; \
22805 - GET_THREAD_INFO(%_ASM_BX)
22806 -#define EXIT ret ; \
22807 +#define ENTER CFI_STARTPROC
22808 +#define EXIT pax_force_retaddr; ret ; \
22809 CFI_ENDPROC
22810
22811 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
22812 +#define _DEST %_ASM_CX,%_ASM_BX
22813 +#else
22814 +#define _DEST %_ASM_CX
22815 +#endif
22816 +
22817 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
22818 +#define __copyuser_seg gs;
22819 +#else
22820 +#define __copyuser_seg
22821 +#endif
22822 +
22823 .text
22824 ENTRY(__put_user_1)
22825 ENTER
22826 +
22827 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
22828 + GET_THREAD_INFO(%_ASM_BX)
22829 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
22830 jae bad_put_user
22831 -1: movb %al,(%_ASM_CX)
22832 +
22833 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
22834 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
22835 + cmp %_ASM_BX,%_ASM_CX
22836 + jb 1234f
22837 + xor %ebx,%ebx
22838 +1234:
22839 +#endif
22840 +
22841 +#endif
22842 +
22843 +1: __copyuser_seg movb %al,(_DEST)
22844 xor %eax,%eax
22845 EXIT
22846 ENDPROC(__put_user_1)
22847
22848 ENTRY(__put_user_2)
22849 ENTER
22850 +
22851 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
22852 + GET_THREAD_INFO(%_ASM_BX)
22853 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
22854 sub $1,%_ASM_BX
22855 cmp %_ASM_BX,%_ASM_CX
22856 jae bad_put_user
22857 -2: movw %ax,(%_ASM_CX)
22858 +
22859 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
22860 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
22861 + cmp %_ASM_BX,%_ASM_CX
22862 + jb 1234f
22863 + xor %ebx,%ebx
22864 +1234:
22865 +#endif
22866 +
22867 +#endif
22868 +
22869 +2: __copyuser_seg movw %ax,(_DEST)
22870 xor %eax,%eax
22871 EXIT
22872 ENDPROC(__put_user_2)
22873
22874 ENTRY(__put_user_4)
22875 ENTER
22876 +
22877 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
22878 + GET_THREAD_INFO(%_ASM_BX)
22879 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
22880 sub $3,%_ASM_BX
22881 cmp %_ASM_BX,%_ASM_CX
22882 jae bad_put_user
22883 -3: movl %eax,(%_ASM_CX)
22884 +
22885 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
22886 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
22887 + cmp %_ASM_BX,%_ASM_CX
22888 + jb 1234f
22889 + xor %ebx,%ebx
22890 +1234:
22891 +#endif
22892 +
22893 +#endif
22894 +
22895 +3: __copyuser_seg movl %eax,(_DEST)
22896 xor %eax,%eax
22897 EXIT
22898 ENDPROC(__put_user_4)
22899
22900 ENTRY(__put_user_8)
22901 ENTER
22902 +
22903 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
22904 + GET_THREAD_INFO(%_ASM_BX)
22905 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
22906 sub $7,%_ASM_BX
22907 cmp %_ASM_BX,%_ASM_CX
22908 jae bad_put_user
22909 -4: mov %_ASM_AX,(%_ASM_CX)
22910 +
22911 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
22912 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
22913 + cmp %_ASM_BX,%_ASM_CX
22914 + jb 1234f
22915 + xor %ebx,%ebx
22916 +1234:
22917 +#endif
22918 +
22919 +#endif
22920 +
22921 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
22922 #ifdef CONFIG_X86_32
22923 -5: movl %edx,4(%_ASM_CX)
22924 +5: __copyuser_seg movl %edx,4(_DEST)
22925 #endif
22926 xor %eax,%eax
22927 EXIT
22928 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
22929 index 1cad221..de671ee 100644
22930 --- a/arch/x86/lib/rwlock.S
22931 +++ b/arch/x86/lib/rwlock.S
22932 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
22933 FRAME
22934 0: LOCK_PREFIX
22935 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
22936 +
22937 +#ifdef CONFIG_PAX_REFCOUNT
22938 + jno 1234f
22939 + LOCK_PREFIX
22940 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
22941 + int $4
22942 +1234:
22943 + _ASM_EXTABLE(1234b, 1234b)
22944 +#endif
22945 +
22946 1: rep; nop
22947 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
22948 jne 1b
22949 LOCK_PREFIX
22950 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
22951 +
22952 +#ifdef CONFIG_PAX_REFCOUNT
22953 + jno 1234f
22954 + LOCK_PREFIX
22955 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
22956 + int $4
22957 +1234:
22958 + _ASM_EXTABLE(1234b, 1234b)
22959 +#endif
22960 +
22961 jnz 0b
22962 ENDFRAME
22963 + pax_force_retaddr
22964 ret
22965 CFI_ENDPROC
22966 END(__write_lock_failed)
22967 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
22968 FRAME
22969 0: LOCK_PREFIX
22970 READ_LOCK_SIZE(inc) (%__lock_ptr)
22971 +
22972 +#ifdef CONFIG_PAX_REFCOUNT
22973 + jno 1234f
22974 + LOCK_PREFIX
22975 + READ_LOCK_SIZE(dec) (%__lock_ptr)
22976 + int $4
22977 +1234:
22978 + _ASM_EXTABLE(1234b, 1234b)
22979 +#endif
22980 +
22981 1: rep; nop
22982 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
22983 js 1b
22984 LOCK_PREFIX
22985 READ_LOCK_SIZE(dec) (%__lock_ptr)
22986 +
22987 +#ifdef CONFIG_PAX_REFCOUNT
22988 + jno 1234f
22989 + LOCK_PREFIX
22990 + READ_LOCK_SIZE(inc) (%__lock_ptr)
22991 + int $4
22992 +1234:
22993 + _ASM_EXTABLE(1234b, 1234b)
22994 +#endif
22995 +
22996 js 0b
22997 ENDFRAME
22998 + pax_force_retaddr
22999 ret
23000 CFI_ENDPROC
23001 END(__read_lock_failed)
23002 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
23003 index 5dff5f0..cadebf4 100644
23004 --- a/arch/x86/lib/rwsem.S
23005 +++ b/arch/x86/lib/rwsem.S
23006 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
23007 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
23008 CFI_RESTORE __ASM_REG(dx)
23009 restore_common_regs
23010 + pax_force_retaddr
23011 ret
23012 CFI_ENDPROC
23013 ENDPROC(call_rwsem_down_read_failed)
23014 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
23015 movq %rax,%rdi
23016 call rwsem_down_write_failed
23017 restore_common_regs
23018 + pax_force_retaddr
23019 ret
23020 CFI_ENDPROC
23021 ENDPROC(call_rwsem_down_write_failed)
23022 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
23023 movq %rax,%rdi
23024 call rwsem_wake
23025 restore_common_regs
23026 -1: ret
23027 +1: pax_force_retaddr
23028 + ret
23029 CFI_ENDPROC
23030 ENDPROC(call_rwsem_wake)
23031
23032 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
23033 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
23034 CFI_RESTORE __ASM_REG(dx)
23035 restore_common_regs
23036 + pax_force_retaddr
23037 ret
23038 CFI_ENDPROC
23039 ENDPROC(call_rwsem_downgrade_wake)
23040 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
23041 index a63efd6..ccecad8 100644
23042 --- a/arch/x86/lib/thunk_64.S
23043 +++ b/arch/x86/lib/thunk_64.S
23044 @@ -8,6 +8,7 @@
23045 #include <linux/linkage.h>
23046 #include <asm/dwarf2.h>
23047 #include <asm/calling.h>
23048 +#include <asm/alternative-asm.h>
23049
23050 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
23051 .macro THUNK name, func, put_ret_addr_in_rdi=0
23052 @@ -41,5 +42,6 @@
23053 SAVE_ARGS
23054 restore:
23055 RESTORE_ARGS
23056 + pax_force_retaddr
23057 ret
23058 CFI_ENDPROC
23059 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
23060 index e218d5d..a99a1eb 100644
23061 --- a/arch/x86/lib/usercopy_32.c
23062 +++ b/arch/x86/lib/usercopy_32.c
23063 @@ -43,7 +43,7 @@ do { \
23064 __asm__ __volatile__( \
23065 " testl %1,%1\n" \
23066 " jz 2f\n" \
23067 - "0: lodsb\n" \
23068 + "0: "__copyuser_seg"lodsb\n" \
23069 " stosb\n" \
23070 " testb %%al,%%al\n" \
23071 " jz 1f\n" \
23072 @@ -128,10 +128,12 @@ do { \
23073 int __d0; \
23074 might_fault(); \
23075 __asm__ __volatile__( \
23076 + __COPYUSER_SET_ES \
23077 "0: rep; stosl\n" \
23078 " movl %2,%0\n" \
23079 "1: rep; stosb\n" \
23080 "2:\n" \
23081 + __COPYUSER_RESTORE_ES \
23082 ".section .fixup,\"ax\"\n" \
23083 "3: lea 0(%2,%0,4),%0\n" \
23084 " jmp 2b\n" \
23085 @@ -200,6 +202,7 @@ long strnlen_user(const char __user *s, long n)
23086 might_fault();
23087
23088 __asm__ __volatile__(
23089 + __COPYUSER_SET_ES
23090 " testl %0, %0\n"
23091 " jz 3f\n"
23092 " andl %0,%%ecx\n"
23093 @@ -208,6 +211,7 @@ long strnlen_user(const char __user *s, long n)
23094 " subl %%ecx,%0\n"
23095 " addl %0,%%eax\n"
23096 "1:\n"
23097 + __COPYUSER_RESTORE_ES
23098 ".section .fixup,\"ax\"\n"
23099 "2: xorl %%eax,%%eax\n"
23100 " jmp 1b\n"
23101 @@ -227,7 +231,7 @@ EXPORT_SYMBOL(strnlen_user);
23102
23103 #ifdef CONFIG_X86_INTEL_USERCOPY
23104 static unsigned long
23105 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
23106 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
23107 {
23108 int d0, d1;
23109 __asm__ __volatile__(
23110 @@ -239,36 +243,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
23111 " .align 2,0x90\n"
23112 "3: movl 0(%4), %%eax\n"
23113 "4: movl 4(%4), %%edx\n"
23114 - "5: movl %%eax, 0(%3)\n"
23115 - "6: movl %%edx, 4(%3)\n"
23116 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
23117 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
23118 "7: movl 8(%4), %%eax\n"
23119 "8: movl 12(%4),%%edx\n"
23120 - "9: movl %%eax, 8(%3)\n"
23121 - "10: movl %%edx, 12(%3)\n"
23122 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
23123 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
23124 "11: movl 16(%4), %%eax\n"
23125 "12: movl 20(%4), %%edx\n"
23126 - "13: movl %%eax, 16(%3)\n"
23127 - "14: movl %%edx, 20(%3)\n"
23128 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
23129 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
23130 "15: movl 24(%4), %%eax\n"
23131 "16: movl 28(%4), %%edx\n"
23132 - "17: movl %%eax, 24(%3)\n"
23133 - "18: movl %%edx, 28(%3)\n"
23134 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
23135 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
23136 "19: movl 32(%4), %%eax\n"
23137 "20: movl 36(%4), %%edx\n"
23138 - "21: movl %%eax, 32(%3)\n"
23139 - "22: movl %%edx, 36(%3)\n"
23140 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
23141 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
23142 "23: movl 40(%4), %%eax\n"
23143 "24: movl 44(%4), %%edx\n"
23144 - "25: movl %%eax, 40(%3)\n"
23145 - "26: movl %%edx, 44(%3)\n"
23146 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
23147 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
23148 "27: movl 48(%4), %%eax\n"
23149 "28: movl 52(%4), %%edx\n"
23150 - "29: movl %%eax, 48(%3)\n"
23151 - "30: movl %%edx, 52(%3)\n"
23152 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
23153 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
23154 "31: movl 56(%4), %%eax\n"
23155 "32: movl 60(%4), %%edx\n"
23156 - "33: movl %%eax, 56(%3)\n"
23157 - "34: movl %%edx, 60(%3)\n"
23158 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
23159 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
23160 " addl $-64, %0\n"
23161 " addl $64, %4\n"
23162 " addl $64, %3\n"
23163 @@ -278,10 +282,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
23164 " shrl $2, %0\n"
23165 " andl $3, %%eax\n"
23166 " cld\n"
23167 + __COPYUSER_SET_ES
23168 "99: rep; movsl\n"
23169 "36: movl %%eax, %0\n"
23170 "37: rep; movsb\n"
23171 "100:\n"
23172 + __COPYUSER_RESTORE_ES
23173 ".section .fixup,\"ax\"\n"
23174 "101: lea 0(%%eax,%0,4),%0\n"
23175 " jmp 100b\n"
23176 @@ -334,46 +340,155 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
23177 }
23178
23179 static unsigned long
23180 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
23181 +{
23182 + int d0, d1;
23183 + __asm__ __volatile__(
23184 + " .align 2,0x90\n"
23185 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
23186 + " cmpl $67, %0\n"
23187 + " jbe 3f\n"
23188 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
23189 + " .align 2,0x90\n"
23190 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
23191 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
23192 + "5: movl %%eax, 0(%3)\n"
23193 + "6: movl %%edx, 4(%3)\n"
23194 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
23195 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
23196 + "9: movl %%eax, 8(%3)\n"
23197 + "10: movl %%edx, 12(%3)\n"
23198 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
23199 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
23200 + "13: movl %%eax, 16(%3)\n"
23201 + "14: movl %%edx, 20(%3)\n"
23202 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
23203 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
23204 + "17: movl %%eax, 24(%3)\n"
23205 + "18: movl %%edx, 28(%3)\n"
23206 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
23207 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
23208 + "21: movl %%eax, 32(%3)\n"
23209 + "22: movl %%edx, 36(%3)\n"
23210 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
23211 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
23212 + "25: movl %%eax, 40(%3)\n"
23213 + "26: movl %%edx, 44(%3)\n"
23214 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
23215 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
23216 + "29: movl %%eax, 48(%3)\n"
23217 + "30: movl %%edx, 52(%3)\n"
23218 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
23219 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
23220 + "33: movl %%eax, 56(%3)\n"
23221 + "34: movl %%edx, 60(%3)\n"
23222 + " addl $-64, %0\n"
23223 + " addl $64, %4\n"
23224 + " addl $64, %3\n"
23225 + " cmpl $63, %0\n"
23226 + " ja 1b\n"
23227 + "35: movl %0, %%eax\n"
23228 + " shrl $2, %0\n"
23229 + " andl $3, %%eax\n"
23230 + " cld\n"
23231 + "99: rep; "__copyuser_seg" movsl\n"
23232 + "36: movl %%eax, %0\n"
23233 + "37: rep; "__copyuser_seg" movsb\n"
23234 + "100:\n"
23235 + ".section .fixup,\"ax\"\n"
23236 + "101: lea 0(%%eax,%0,4),%0\n"
23237 + " jmp 100b\n"
23238 + ".previous\n"
23239 + ".section __ex_table,\"a\"\n"
23240 + " .align 4\n"
23241 + " .long 1b,100b\n"
23242 + " .long 2b,100b\n"
23243 + " .long 3b,100b\n"
23244 + " .long 4b,100b\n"
23245 + " .long 5b,100b\n"
23246 + " .long 6b,100b\n"
23247 + " .long 7b,100b\n"
23248 + " .long 8b,100b\n"
23249 + " .long 9b,100b\n"
23250 + " .long 10b,100b\n"
23251 + " .long 11b,100b\n"
23252 + " .long 12b,100b\n"
23253 + " .long 13b,100b\n"
23254 + " .long 14b,100b\n"
23255 + " .long 15b,100b\n"
23256 + " .long 16b,100b\n"
23257 + " .long 17b,100b\n"
23258 + " .long 18b,100b\n"
23259 + " .long 19b,100b\n"
23260 + " .long 20b,100b\n"
23261 + " .long 21b,100b\n"
23262 + " .long 22b,100b\n"
23263 + " .long 23b,100b\n"
23264 + " .long 24b,100b\n"
23265 + " .long 25b,100b\n"
23266 + " .long 26b,100b\n"
23267 + " .long 27b,100b\n"
23268 + " .long 28b,100b\n"
23269 + " .long 29b,100b\n"
23270 + " .long 30b,100b\n"
23271 + " .long 31b,100b\n"
23272 + " .long 32b,100b\n"
23273 + " .long 33b,100b\n"
23274 + " .long 34b,100b\n"
23275 + " .long 35b,100b\n"
23276 + " .long 36b,100b\n"
23277 + " .long 37b,100b\n"
23278 + " .long 99b,101b\n"
23279 + ".previous"
23280 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
23281 + : "1"(to), "2"(from), "0"(size)
23282 + : "eax", "edx", "memory");
23283 + return size;
23284 +}
23285 +
23286 +static unsigned long
23287 +__copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size) __size_overflow(3);
23288 +static unsigned long
23289 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
23290 {
23291 int d0, d1;
23292 __asm__ __volatile__(
23293 " .align 2,0x90\n"
23294 - "0: movl 32(%4), %%eax\n"
23295 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
23296 " cmpl $67, %0\n"
23297 " jbe 2f\n"
23298 - "1: movl 64(%4), %%eax\n"
23299 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
23300 " .align 2,0x90\n"
23301 - "2: movl 0(%4), %%eax\n"
23302 - "21: movl 4(%4), %%edx\n"
23303 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
23304 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
23305 " movl %%eax, 0(%3)\n"
23306 " movl %%edx, 4(%3)\n"
23307 - "3: movl 8(%4), %%eax\n"
23308 - "31: movl 12(%4),%%edx\n"
23309 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
23310 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
23311 " movl %%eax, 8(%3)\n"
23312 " movl %%edx, 12(%3)\n"
23313 - "4: movl 16(%4), %%eax\n"
23314 - "41: movl 20(%4), %%edx\n"
23315 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
23316 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
23317 " movl %%eax, 16(%3)\n"
23318 " movl %%edx, 20(%3)\n"
23319 - "10: movl 24(%4), %%eax\n"
23320 - "51: movl 28(%4), %%edx\n"
23321 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
23322 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
23323 " movl %%eax, 24(%3)\n"
23324 " movl %%edx, 28(%3)\n"
23325 - "11: movl 32(%4), %%eax\n"
23326 - "61: movl 36(%4), %%edx\n"
23327 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
23328 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
23329 " movl %%eax, 32(%3)\n"
23330 " movl %%edx, 36(%3)\n"
23331 - "12: movl 40(%4), %%eax\n"
23332 - "71: movl 44(%4), %%edx\n"
23333 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
23334 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
23335 " movl %%eax, 40(%3)\n"
23336 " movl %%edx, 44(%3)\n"
23337 - "13: movl 48(%4), %%eax\n"
23338 - "81: movl 52(%4), %%edx\n"
23339 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
23340 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
23341 " movl %%eax, 48(%3)\n"
23342 " movl %%edx, 52(%3)\n"
23343 - "14: movl 56(%4), %%eax\n"
23344 - "91: movl 60(%4), %%edx\n"
23345 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
23346 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
23347 " movl %%eax, 56(%3)\n"
23348 " movl %%edx, 60(%3)\n"
23349 " addl $-64, %0\n"
23350 @@ -385,9 +500,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
23351 " shrl $2, %0\n"
23352 " andl $3, %%eax\n"
23353 " cld\n"
23354 - "6: rep; movsl\n"
23355 + "6: rep; "__copyuser_seg" movsl\n"
23356 " movl %%eax,%0\n"
23357 - "7: rep; movsb\n"
23358 + "7: rep; "__copyuser_seg" movsb\n"
23359 "8:\n"
23360 ".section .fixup,\"ax\"\n"
23361 "9: lea 0(%%eax,%0,4),%0\n"
23362 @@ -434,47 +549,49 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
23363 */
23364
23365 static unsigned long __copy_user_zeroing_intel_nocache(void *to,
23366 + const void __user *from, unsigned long size) __size_overflow(3);
23367 +static unsigned long __copy_user_zeroing_intel_nocache(void *to,
23368 const void __user *from, unsigned long size)
23369 {
23370 int d0, d1;
23371
23372 __asm__ __volatile__(
23373 " .align 2,0x90\n"
23374 - "0: movl 32(%4), %%eax\n"
23375 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
23376 " cmpl $67, %0\n"
23377 " jbe 2f\n"
23378 - "1: movl 64(%4), %%eax\n"
23379 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
23380 " .align 2,0x90\n"
23381 - "2: movl 0(%4), %%eax\n"
23382 - "21: movl 4(%4), %%edx\n"
23383 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
23384 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
23385 " movnti %%eax, 0(%3)\n"
23386 " movnti %%edx, 4(%3)\n"
23387 - "3: movl 8(%4), %%eax\n"
23388 - "31: movl 12(%4),%%edx\n"
23389 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
23390 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
23391 " movnti %%eax, 8(%3)\n"
23392 " movnti %%edx, 12(%3)\n"
23393 - "4: movl 16(%4), %%eax\n"
23394 - "41: movl 20(%4), %%edx\n"
23395 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
23396 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
23397 " movnti %%eax, 16(%3)\n"
23398 " movnti %%edx, 20(%3)\n"
23399 - "10: movl 24(%4), %%eax\n"
23400 - "51: movl 28(%4), %%edx\n"
23401 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
23402 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
23403 " movnti %%eax, 24(%3)\n"
23404 " movnti %%edx, 28(%3)\n"
23405 - "11: movl 32(%4), %%eax\n"
23406 - "61: movl 36(%4), %%edx\n"
23407 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
23408 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
23409 " movnti %%eax, 32(%3)\n"
23410 " movnti %%edx, 36(%3)\n"
23411 - "12: movl 40(%4), %%eax\n"
23412 - "71: movl 44(%4), %%edx\n"
23413 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
23414 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
23415 " movnti %%eax, 40(%3)\n"
23416 " movnti %%edx, 44(%3)\n"
23417 - "13: movl 48(%4), %%eax\n"
23418 - "81: movl 52(%4), %%edx\n"
23419 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
23420 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
23421 " movnti %%eax, 48(%3)\n"
23422 " movnti %%edx, 52(%3)\n"
23423 - "14: movl 56(%4), %%eax\n"
23424 - "91: movl 60(%4), %%edx\n"
23425 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
23426 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
23427 " movnti %%eax, 56(%3)\n"
23428 " movnti %%edx, 60(%3)\n"
23429 " addl $-64, %0\n"
23430 @@ -487,9 +604,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
23431 " shrl $2, %0\n"
23432 " andl $3, %%eax\n"
23433 " cld\n"
23434 - "6: rep; movsl\n"
23435 + "6: rep; "__copyuser_seg" movsl\n"
23436 " movl %%eax,%0\n"
23437 - "7: rep; movsb\n"
23438 + "7: rep; "__copyuser_seg" movsb\n"
23439 "8:\n"
23440 ".section .fixup,\"ax\"\n"
23441 "9: lea 0(%%eax,%0,4),%0\n"
23442 @@ -531,47 +648,49 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
23443 }
23444
23445 static unsigned long __copy_user_intel_nocache(void *to,
23446 + const void __user *from, unsigned long size) __size_overflow(3);
23447 +static unsigned long __copy_user_intel_nocache(void *to,
23448 const void __user *from, unsigned long size)
23449 {
23450 int d0, d1;
23451
23452 __asm__ __volatile__(
23453 " .align 2,0x90\n"
23454 - "0: movl 32(%4), %%eax\n"
23455 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
23456 " cmpl $67, %0\n"
23457 " jbe 2f\n"
23458 - "1: movl 64(%4), %%eax\n"
23459 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
23460 " .align 2,0x90\n"
23461 - "2: movl 0(%4), %%eax\n"
23462 - "21: movl 4(%4), %%edx\n"
23463 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
23464 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
23465 " movnti %%eax, 0(%3)\n"
23466 " movnti %%edx, 4(%3)\n"
23467 - "3: movl 8(%4), %%eax\n"
23468 - "31: movl 12(%4),%%edx\n"
23469 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
23470 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
23471 " movnti %%eax, 8(%3)\n"
23472 " movnti %%edx, 12(%3)\n"
23473 - "4: movl 16(%4), %%eax\n"
23474 - "41: movl 20(%4), %%edx\n"
23475 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
23476 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
23477 " movnti %%eax, 16(%3)\n"
23478 " movnti %%edx, 20(%3)\n"
23479 - "10: movl 24(%4), %%eax\n"
23480 - "51: movl 28(%4), %%edx\n"
23481 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
23482 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
23483 " movnti %%eax, 24(%3)\n"
23484 " movnti %%edx, 28(%3)\n"
23485 - "11: movl 32(%4), %%eax\n"
23486 - "61: movl 36(%4), %%edx\n"
23487 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
23488 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
23489 " movnti %%eax, 32(%3)\n"
23490 " movnti %%edx, 36(%3)\n"
23491 - "12: movl 40(%4), %%eax\n"
23492 - "71: movl 44(%4), %%edx\n"
23493 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
23494 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
23495 " movnti %%eax, 40(%3)\n"
23496 " movnti %%edx, 44(%3)\n"
23497 - "13: movl 48(%4), %%eax\n"
23498 - "81: movl 52(%4), %%edx\n"
23499 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
23500 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
23501 " movnti %%eax, 48(%3)\n"
23502 " movnti %%edx, 52(%3)\n"
23503 - "14: movl 56(%4), %%eax\n"
23504 - "91: movl 60(%4), %%edx\n"
23505 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
23506 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
23507 " movnti %%eax, 56(%3)\n"
23508 " movnti %%edx, 60(%3)\n"
23509 " addl $-64, %0\n"
23510 @@ -584,9 +703,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
23511 " shrl $2, %0\n"
23512 " andl $3, %%eax\n"
23513 " cld\n"
23514 - "6: rep; movsl\n"
23515 + "6: rep; "__copyuser_seg" movsl\n"
23516 " movl %%eax,%0\n"
23517 - "7: rep; movsb\n"
23518 + "7: rep; "__copyuser_seg" movsb\n"
23519 "8:\n"
23520 ".section .fixup,\"ax\"\n"
23521 "9: lea 0(%%eax,%0,4),%0\n"
23522 @@ -629,32 +748,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
23523 */
23524 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
23525 unsigned long size);
23526 -unsigned long __copy_user_intel(void __user *to, const void *from,
23527 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
23528 + unsigned long size);
23529 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
23530 unsigned long size);
23531 unsigned long __copy_user_zeroing_intel_nocache(void *to,
23532 const void __user *from, unsigned long size);
23533 #endif /* CONFIG_X86_INTEL_USERCOPY */
23534
23535 /* Generic arbitrary sized copy. */
23536 -#define __copy_user(to, from, size) \
23537 +#define __copy_user(to, from, size, prefix, set, restore) \
23538 do { \
23539 int __d0, __d1, __d2; \
23540 __asm__ __volatile__( \
23541 + set \
23542 " cmp $7,%0\n" \
23543 " jbe 1f\n" \
23544 " movl %1,%0\n" \
23545 " negl %0\n" \
23546 " andl $7,%0\n" \
23547 " subl %0,%3\n" \
23548 - "4: rep; movsb\n" \
23549 + "4: rep; "prefix"movsb\n" \
23550 " movl %3,%0\n" \
23551 " shrl $2,%0\n" \
23552 " andl $3,%3\n" \
23553 " .align 2,0x90\n" \
23554 - "0: rep; movsl\n" \
23555 + "0: rep; "prefix"movsl\n" \
23556 " movl %3,%0\n" \
23557 - "1: rep; movsb\n" \
23558 + "1: rep; "prefix"movsb\n" \
23559 "2:\n" \
23560 + restore \
23561 ".section .fixup,\"ax\"\n" \
23562 "5: addl %3,%0\n" \
23563 " jmp 2b\n" \
23564 @@ -682,14 +805,14 @@ do { \
23565 " negl %0\n" \
23566 " andl $7,%0\n" \
23567 " subl %0,%3\n" \
23568 - "4: rep; movsb\n" \
23569 + "4: rep; "__copyuser_seg"movsb\n" \
23570 " movl %3,%0\n" \
23571 " shrl $2,%0\n" \
23572 " andl $3,%3\n" \
23573 " .align 2,0x90\n" \
23574 - "0: rep; movsl\n" \
23575 + "0: rep; "__copyuser_seg"movsl\n" \
23576 " movl %3,%0\n" \
23577 - "1: rep; movsb\n" \
23578 + "1: rep; "__copyuser_seg"movsb\n" \
23579 "2:\n" \
23580 ".section .fixup,\"ax\"\n" \
23581 "5: addl %3,%0\n" \
23582 @@ -775,9 +898,9 @@ survive:
23583 }
23584 #endif
23585 if (movsl_is_ok(to, from, n))
23586 - __copy_user(to, from, n);
23587 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
23588 else
23589 - n = __copy_user_intel(to, from, n);
23590 + n = __generic_copy_to_user_intel(to, from, n);
23591 return n;
23592 }
23593 EXPORT_SYMBOL(__copy_to_user_ll);
23594 @@ -797,10 +920,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
23595 unsigned long n)
23596 {
23597 if (movsl_is_ok(to, from, n))
23598 - __copy_user(to, from, n);
23599 + __copy_user(to, from, n, __copyuser_seg, "", "");
23600 else
23601 - n = __copy_user_intel((void __user *)to,
23602 - (const void *)from, n);
23603 + n = __generic_copy_from_user_intel(to, from, n);
23604 return n;
23605 }
23606 EXPORT_SYMBOL(__copy_from_user_ll_nozero);
23607 @@ -827,65 +949,50 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
23608 if (n > 64 && cpu_has_xmm2)
23609 n = __copy_user_intel_nocache(to, from, n);
23610 else
23611 - __copy_user(to, from, n);
23612 + __copy_user(to, from, n, __copyuser_seg, "", "");
23613 #else
23614 - __copy_user(to, from, n);
23615 + __copy_user(to, from, n, __copyuser_seg, "", "");
23616 #endif
23617 return n;
23618 }
23619 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
23620
23621 -/**
23622 - * copy_to_user: - Copy a block of data into user space.
23623 - * @to: Destination address, in user space.
23624 - * @from: Source address, in kernel space.
23625 - * @n: Number of bytes to copy.
23626 - *
23627 - * Context: User context only. This function may sleep.
23628 - *
23629 - * Copy data from kernel space to user space.
23630 - *
23631 - * Returns number of bytes that could not be copied.
23632 - * On success, this will be zero.
23633 - */
23634 -unsigned long
23635 -copy_to_user(void __user *to, const void *from, unsigned long n)
23636 -{
23637 - if (access_ok(VERIFY_WRITE, to, n))
23638 - n = __copy_to_user(to, from, n);
23639 - return n;
23640 -}
23641 -EXPORT_SYMBOL(copy_to_user);
23642 -
23643 -/**
23644 - * copy_from_user: - Copy a block of data from user space.
23645 - * @to: Destination address, in kernel space.
23646 - * @from: Source address, in user space.
23647 - * @n: Number of bytes to copy.
23648 - *
23649 - * Context: User context only. This function may sleep.
23650 - *
23651 - * Copy data from user space to kernel space.
23652 - *
23653 - * Returns number of bytes that could not be copied.
23654 - * On success, this will be zero.
23655 - *
23656 - * If some data could not be copied, this function will pad the copied
23657 - * data to the requested size using zero bytes.
23658 - */
23659 -unsigned long
23660 -_copy_from_user(void *to, const void __user *from, unsigned long n)
23661 -{
23662 - if (access_ok(VERIFY_READ, from, n))
23663 - n = __copy_from_user(to, from, n);
23664 - else
23665 - memset(to, 0, n);
23666 - return n;
23667 -}
23668 -EXPORT_SYMBOL(_copy_from_user);
23669 -
23670 void copy_from_user_overflow(void)
23671 {
23672 WARN(1, "Buffer overflow detected!\n");
23673 }
23674 EXPORT_SYMBOL(copy_from_user_overflow);
23675 +
23676 +void copy_to_user_overflow(void)
23677 +{
23678 + WARN(1, "Buffer overflow detected!\n");
23679 +}
23680 +EXPORT_SYMBOL(copy_to_user_overflow);
23681 +
23682 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23683 +void __set_fs(mm_segment_t x)
23684 +{
23685 + switch (x.seg) {
23686 + case 0:
23687 + loadsegment(gs, 0);
23688 + break;
23689 + case TASK_SIZE_MAX:
23690 + loadsegment(gs, __USER_DS);
23691 + break;
23692 + case -1UL:
23693 + loadsegment(gs, __KERNEL_DS);
23694 + break;
23695 + default:
23696 + BUG();
23697 + }
23698 + return;
23699 +}
23700 +EXPORT_SYMBOL(__set_fs);
23701 +
23702 +void set_fs(mm_segment_t x)
23703 +{
23704 + current_thread_info()->addr_limit = x;
23705 + __set_fs(x);
23706 +}
23707 +EXPORT_SYMBOL(set_fs);
23708 +#endif
23709 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
23710 index b7c2849..8633ad8 100644
23711 --- a/arch/x86/lib/usercopy_64.c
23712 +++ b/arch/x86/lib/usercopy_64.c
23713 @@ -42,6 +42,12 @@ long
23714 __strncpy_from_user(char *dst, const char __user *src, long count)
23715 {
23716 long res;
23717 +
23718 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23719 + if ((unsigned long)src < PAX_USER_SHADOW_BASE)
23720 + src += PAX_USER_SHADOW_BASE;
23721 +#endif
23722 +
23723 __do_strncpy_from_user(dst, src, count, res);
23724 return res;
23725 }
23726 @@ -65,6 +71,12 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
23727 {
23728 long __d0;
23729 might_fault();
23730 +
23731 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23732 + if ((unsigned long)addr < PAX_USER_SHADOW_BASE)
23733 + addr += PAX_USER_SHADOW_BASE;
23734 +#endif
23735 +
23736 /* no memory constraint because it doesn't change any memory gcc knows
23737 about */
23738 asm volatile(
23739 @@ -149,12 +161,20 @@ long strlen_user(const char __user *s)
23740 }
23741 EXPORT_SYMBOL(strlen_user);
23742
23743 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
23744 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
23745 {
23746 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
23747 - return copy_user_generic((__force void *)to, (__force void *)from, len);
23748 - }
23749 - return len;
23750 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
23751 +
23752 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23753 + if ((unsigned long)to < PAX_USER_SHADOW_BASE)
23754 + to += PAX_USER_SHADOW_BASE;
23755 + if ((unsigned long)from < PAX_USER_SHADOW_BASE)
23756 + from += PAX_USER_SHADOW_BASE;
23757 +#endif
23758 +
23759 + return copy_user_generic((void __force_kernel *)to, (void __force_kernel *)from, len);
23760 + }
23761 + return len;
23762 }
23763 EXPORT_SYMBOL(copy_in_user);
23764
23765 @@ -164,7 +184,7 @@ EXPORT_SYMBOL(copy_in_user);
23766 * it is not necessary to optimize tail handling.
23767 */
23768 unsigned long
23769 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
23770 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
23771 {
23772 char c;
23773 unsigned zero_len;
23774 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
23775 index 1fb85db..8b3540b 100644
23776 --- a/arch/x86/mm/extable.c
23777 +++ b/arch/x86/mm/extable.c
23778 @@ -8,7 +8,7 @@ int fixup_exception(struct pt_regs *regs)
23779 const struct exception_table_entry *fixup;
23780
23781 #ifdef CONFIG_PNPBIOS
23782 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
23783 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
23784 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
23785 extern u32 pnp_bios_is_utter_crap;
23786 pnp_bios_is_utter_crap = 1;
23787 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
23788 index f0b4caf..d92fd42 100644
23789 --- a/arch/x86/mm/fault.c
23790 +++ b/arch/x86/mm/fault.c
23791 @@ -13,11 +13,18 @@
23792 #include <linux/perf_event.h> /* perf_sw_event */
23793 #include <linux/hugetlb.h> /* hstate_index_to_shift */
23794 #include <linux/prefetch.h> /* prefetchw */
23795 +#include <linux/unistd.h>
23796 +#include <linux/compiler.h>
23797
23798 #include <asm/traps.h> /* dotraplinkage, ... */
23799 #include <asm/pgalloc.h> /* pgd_*(), ... */
23800 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
23801 #include <asm/fixmap.h> /* VSYSCALL_START */
23802 +#include <asm/tlbflush.h>
23803 +
23804 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
23805 +#include <asm/stacktrace.h>
23806 +#endif
23807
23808 /*
23809 * Page fault error code bits:
23810 @@ -55,7 +62,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
23811 int ret = 0;
23812
23813 /* kprobe_running() needs smp_processor_id() */
23814 - if (kprobes_built_in() && !user_mode_vm(regs)) {
23815 + if (kprobes_built_in() && !user_mode(regs)) {
23816 preempt_disable();
23817 if (kprobe_running() && kprobe_fault_handler(regs, 14))
23818 ret = 1;
23819 @@ -116,7 +123,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
23820 return !instr_lo || (instr_lo>>1) == 1;
23821 case 0x00:
23822 /* Prefetch instruction is 0x0F0D or 0x0F18 */
23823 - if (probe_kernel_address(instr, opcode))
23824 + if (user_mode(regs)) {
23825 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
23826 + return 0;
23827 + } else if (probe_kernel_address(instr, opcode))
23828 return 0;
23829
23830 *prefetch = (instr_lo == 0xF) &&
23831 @@ -150,7 +160,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
23832 while (instr < max_instr) {
23833 unsigned char opcode;
23834
23835 - if (probe_kernel_address(instr, opcode))
23836 + if (user_mode(regs)) {
23837 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
23838 + break;
23839 + } else if (probe_kernel_address(instr, opcode))
23840 break;
23841
23842 instr++;
23843 @@ -181,6 +194,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
23844 force_sig_info(si_signo, &info, tsk);
23845 }
23846
23847 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
23848 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
23849 +#endif
23850 +
23851 +#ifdef CONFIG_PAX_EMUTRAMP
23852 +static int pax_handle_fetch_fault(struct pt_regs *regs);
23853 +#endif
23854 +
23855 +#ifdef CONFIG_PAX_PAGEEXEC
23856 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
23857 +{
23858 + pgd_t *pgd;
23859 + pud_t *pud;
23860 + pmd_t *pmd;
23861 +
23862 + pgd = pgd_offset(mm, address);
23863 + if (!pgd_present(*pgd))
23864 + return NULL;
23865 + pud = pud_offset(pgd, address);
23866 + if (!pud_present(*pud))
23867 + return NULL;
23868 + pmd = pmd_offset(pud, address);
23869 + if (!pmd_present(*pmd))
23870 + return NULL;
23871 + return pmd;
23872 +}
23873 +#endif
23874 +
23875 DEFINE_SPINLOCK(pgd_lock);
23876 LIST_HEAD(pgd_list);
23877
23878 @@ -231,10 +272,22 @@ void vmalloc_sync_all(void)
23879 for (address = VMALLOC_START & PMD_MASK;
23880 address >= TASK_SIZE && address < FIXADDR_TOP;
23881 address += PMD_SIZE) {
23882 +
23883 +#ifdef CONFIG_PAX_PER_CPU_PGD
23884 + unsigned long cpu;
23885 +#else
23886 struct page *page;
23887 +#endif
23888
23889 spin_lock(&pgd_lock);
23890 +
23891 +#ifdef CONFIG_PAX_PER_CPU_PGD
23892 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
23893 + pgd_t *pgd = get_cpu_pgd(cpu);
23894 + pmd_t *ret;
23895 +#else
23896 list_for_each_entry(page, &pgd_list, lru) {
23897 + pgd_t *pgd = page_address(page);
23898 spinlock_t *pgt_lock;
23899 pmd_t *ret;
23900
23901 @@ -242,8 +295,13 @@ void vmalloc_sync_all(void)
23902 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
23903
23904 spin_lock(pgt_lock);
23905 - ret = vmalloc_sync_one(page_address(page), address);
23906 +#endif
23907 +
23908 + ret = vmalloc_sync_one(pgd, address);
23909 +
23910 +#ifndef CONFIG_PAX_PER_CPU_PGD
23911 spin_unlock(pgt_lock);
23912 +#endif
23913
23914 if (!ret)
23915 break;
23916 @@ -277,6 +335,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
23917 * an interrupt in the middle of a task switch..
23918 */
23919 pgd_paddr = read_cr3();
23920 +
23921 +#ifdef CONFIG_PAX_PER_CPU_PGD
23922 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
23923 +#endif
23924 +
23925 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
23926 if (!pmd_k)
23927 return -1;
23928 @@ -372,7 +435,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
23929 * happen within a race in page table update. In the later
23930 * case just flush:
23931 */
23932 +
23933 +#ifdef CONFIG_PAX_PER_CPU_PGD
23934 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
23935 + pgd = pgd_offset_cpu(smp_processor_id(), address);
23936 +#else
23937 pgd = pgd_offset(current->active_mm, address);
23938 +#endif
23939 +
23940 pgd_ref = pgd_offset_k(address);
23941 if (pgd_none(*pgd_ref))
23942 return -1;
23943 @@ -540,7 +610,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
23944 static int is_errata100(struct pt_regs *regs, unsigned long address)
23945 {
23946 #ifdef CONFIG_X86_64
23947 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
23948 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
23949 return 1;
23950 #endif
23951 return 0;
23952 @@ -567,7 +637,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
23953 }
23954
23955 static const char nx_warning[] = KERN_CRIT
23956 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
23957 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
23958
23959 static void
23960 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
23961 @@ -576,15 +646,26 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
23962 if (!oops_may_print())
23963 return;
23964
23965 - if (error_code & PF_INSTR) {
23966 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
23967 unsigned int level;
23968
23969 pte_t *pte = lookup_address(address, &level);
23970
23971 if (pte && pte_present(*pte) && !pte_exec(*pte))
23972 - printk(nx_warning, current_uid());
23973 + printk(nx_warning, current_uid(), current->comm, task_pid_nr(current));
23974 }
23975
23976 +#ifdef CONFIG_PAX_KERNEXEC
23977 + if (init_mm.start_code <= address && address < init_mm.end_code) {
23978 + if (current->signal->curr_ip)
23979 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
23980 + &current->signal->curr_ip, current->comm, task_pid_nr(current), current_uid(), current_euid());
23981 + else
23982 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
23983 + current->comm, task_pid_nr(current), current_uid(), current_euid());
23984 + }
23985 +#endif
23986 +
23987 printk(KERN_ALERT "BUG: unable to handle kernel ");
23988 if (address < PAGE_SIZE)
23989 printk(KERN_CONT "NULL pointer dereference");
23990 @@ -748,6 +829,21 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
23991 }
23992 #endif
23993
23994 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
23995 + if (pax_is_fetch_fault(regs, error_code, address)) {
23996 +
23997 +#ifdef CONFIG_PAX_EMUTRAMP
23998 + switch (pax_handle_fetch_fault(regs)) {
23999 + case 2:
24000 + return;
24001 + }
24002 +#endif
24003 +
24004 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
24005 + do_group_exit(SIGKILL);
24006 + }
24007 +#endif
24008 +
24009 if (unlikely(show_unhandled_signals))
24010 show_signal_msg(regs, error_code, address, tsk);
24011
24012 @@ -844,7 +940,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
24013 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
24014 printk(KERN_ERR
24015 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
24016 - tsk->comm, tsk->pid, address);
24017 + tsk->comm, task_pid_nr(tsk), address);
24018 code = BUS_MCEERR_AR;
24019 }
24020 #endif
24021 @@ -900,6 +996,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
24022 return 1;
24023 }
24024
24025 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
24026 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
24027 +{
24028 + pte_t *pte;
24029 + pmd_t *pmd;
24030 + spinlock_t *ptl;
24031 + unsigned char pte_mask;
24032 +
24033 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
24034 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
24035 + return 0;
24036 +
24037 + /* PaX: it's our fault, let's handle it if we can */
24038 +
24039 + /* PaX: take a look at read faults before acquiring any locks */
24040 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
24041 + /* instruction fetch attempt from a protected page in user mode */
24042 + up_read(&mm->mmap_sem);
24043 +
24044 +#ifdef CONFIG_PAX_EMUTRAMP
24045 + switch (pax_handle_fetch_fault(regs)) {
24046 + case 2:
24047 + return 1;
24048 + }
24049 +#endif
24050 +
24051 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
24052 + do_group_exit(SIGKILL);
24053 + }
24054 +
24055 + pmd = pax_get_pmd(mm, address);
24056 + if (unlikely(!pmd))
24057 + return 0;
24058 +
24059 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
24060 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
24061 + pte_unmap_unlock(pte, ptl);
24062 + return 0;
24063 + }
24064 +
24065 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
24066 + /* write attempt to a protected page in user mode */
24067 + pte_unmap_unlock(pte, ptl);
24068 + return 0;
24069 + }
24070 +
24071 +#ifdef CONFIG_SMP
24072 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
24073 +#else
24074 + if (likely(address > get_limit(regs->cs)))
24075 +#endif
24076 + {
24077 + set_pte(pte, pte_mkread(*pte));
24078 + __flush_tlb_one(address);
24079 + pte_unmap_unlock(pte, ptl);
24080 + up_read(&mm->mmap_sem);
24081 + return 1;
24082 + }
24083 +
24084 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
24085 +
24086 + /*
24087 + * PaX: fill DTLB with user rights and retry
24088 + */
24089 + __asm__ __volatile__ (
24090 + "orb %2,(%1)\n"
24091 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
24092 +/*
24093 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
24094 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
24095 + * page fault when examined during a TLB load attempt. this is true not only
24096 + * for PTEs holding a non-present entry but also present entries that will
24097 + * raise a page fault (such as those set up by PaX, or the copy-on-write
24098 + * mechanism). in effect it means that we do *not* need to flush the TLBs
24099 + * for our target pages since their PTEs are simply not in the TLBs at all.
24100 +
24101 + * the best thing in omitting it is that we gain around 15-20% speed in the
24102 + * fast path of the page fault handler and can get rid of tracing since we
24103 + * can no longer flush unintended entries.
24104 + */
24105 + "invlpg (%0)\n"
24106 +#endif
24107 + __copyuser_seg"testb $0,(%0)\n"
24108 + "xorb %3,(%1)\n"
24109 + :
24110 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
24111 + : "memory", "cc");
24112 + pte_unmap_unlock(pte, ptl);
24113 + up_read(&mm->mmap_sem);
24114 + return 1;
24115 +}
24116 +#endif
24117 +
24118 /*
24119 * Handle a spurious fault caused by a stale TLB entry.
24120 *
24121 @@ -972,6 +1161,9 @@ int show_unhandled_signals = 1;
24122 static inline int
24123 access_error(unsigned long error_code, struct vm_area_struct *vma)
24124 {
24125 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
24126 + return 1;
24127 +
24128 if (error_code & PF_WRITE) {
24129 /* write, present and write, not present: */
24130 if (unlikely(!(vma->vm_flags & VM_WRITE)))
24131 @@ -1005,18 +1197,32 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
24132 {
24133 struct vm_area_struct *vma;
24134 struct task_struct *tsk;
24135 - unsigned long address;
24136 struct mm_struct *mm;
24137 int fault;
24138 int write = error_code & PF_WRITE;
24139 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
24140 (write ? FAULT_FLAG_WRITE : 0);
24141
24142 - tsk = current;
24143 - mm = tsk->mm;
24144 -
24145 /* Get the faulting address: */
24146 - address = read_cr2();
24147 + unsigned long address = read_cr2();
24148 +
24149 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
24150 + if (!user_mode(regs) && address < 2 * PAX_USER_SHADOW_BASE) {
24151 + if (!search_exception_tables(regs->ip)) {
24152 + bad_area_nosemaphore(regs, error_code, address);
24153 + return;
24154 + }
24155 + if (address < PAX_USER_SHADOW_BASE) {
24156 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
24157 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
24158 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
24159 + } else
24160 + address -= PAX_USER_SHADOW_BASE;
24161 + }
24162 +#endif
24163 +
24164 + tsk = current;
24165 + mm = tsk->mm;
24166
24167 /*
24168 * Detect and handle instructions that would cause a page fault for
24169 @@ -1077,7 +1283,7 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
24170 * User-mode registers count as a user access even for any
24171 * potential system fault or CPU buglet:
24172 */
24173 - if (user_mode_vm(regs)) {
24174 + if (user_mode(regs)) {
24175 local_irq_enable();
24176 error_code |= PF_USER;
24177 } else {
24178 @@ -1132,6 +1338,11 @@ retry:
24179 might_sleep();
24180 }
24181
24182 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
24183 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
24184 + return;
24185 +#endif
24186 +
24187 vma = find_vma(mm, address);
24188 if (unlikely(!vma)) {
24189 bad_area(regs, error_code, address);
24190 @@ -1143,18 +1354,24 @@ retry:
24191 bad_area(regs, error_code, address);
24192 return;
24193 }
24194 - if (error_code & PF_USER) {
24195 - /*
24196 - * Accessing the stack below %sp is always a bug.
24197 - * The large cushion allows instructions like enter
24198 - * and pusha to work. ("enter $65535, $31" pushes
24199 - * 32 pointers and then decrements %sp by 65535.)
24200 - */
24201 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
24202 - bad_area(regs, error_code, address);
24203 - return;
24204 - }
24205 + /*
24206 + * Accessing the stack below %sp is always a bug.
24207 + * The large cushion allows instructions like enter
24208 + * and pusha to work. ("enter $65535, $31" pushes
24209 + * 32 pointers and then decrements %sp by 65535.)
24210 + */
24211 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
24212 + bad_area(regs, error_code, address);
24213 + return;
24214 }
24215 +
24216 +#ifdef CONFIG_PAX_SEGMEXEC
24217 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
24218 + bad_area(regs, error_code, address);
24219 + return;
24220 + }
24221 +#endif
24222 +
24223 if (unlikely(expand_stack(vma, address))) {
24224 bad_area(regs, error_code, address);
24225 return;
24226 @@ -1209,3 +1426,292 @@ good_area:
24227
24228 up_read(&mm->mmap_sem);
24229 }
24230 +
24231 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
24232 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
24233 +{
24234 + struct mm_struct *mm = current->mm;
24235 + unsigned long ip = regs->ip;
24236 +
24237 + if (v8086_mode(regs))
24238 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
24239 +
24240 +#ifdef CONFIG_PAX_PAGEEXEC
24241 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
24242 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
24243 + return true;
24244 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
24245 + return true;
24246 + return false;
24247 + }
24248 +#endif
24249 +
24250 +#ifdef CONFIG_PAX_SEGMEXEC
24251 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
24252 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
24253 + return true;
24254 + return false;
24255 + }
24256 +#endif
24257 +
24258 + return false;
24259 +}
24260 +#endif
24261 +
24262 +#ifdef CONFIG_PAX_EMUTRAMP
24263 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
24264 +{
24265 + int err;
24266 +
24267 + do { /* PaX: libffi trampoline emulation */
24268 + unsigned char mov, jmp;
24269 + unsigned int addr1, addr2;
24270 +
24271 +#ifdef CONFIG_X86_64
24272 + if ((regs->ip + 9) >> 32)
24273 + break;
24274 +#endif
24275 +
24276 + err = get_user(mov, (unsigned char __user *)regs->ip);
24277 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
24278 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
24279 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
24280 +
24281 + if (err)
24282 + break;
24283 +
24284 + if (mov == 0xB8 && jmp == 0xE9) {
24285 + regs->ax = addr1;
24286 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
24287 + return 2;
24288 + }
24289 + } while (0);
24290 +
24291 + do { /* PaX: gcc trampoline emulation #1 */
24292 + unsigned char mov1, mov2;
24293 + unsigned short jmp;
24294 + unsigned int addr1, addr2;
24295 +
24296 +#ifdef CONFIG_X86_64
24297 + if ((regs->ip + 11) >> 32)
24298 + break;
24299 +#endif
24300 +
24301 + err = get_user(mov1, (unsigned char __user *)regs->ip);
24302 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
24303 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
24304 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
24305 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
24306 +
24307 + if (err)
24308 + break;
24309 +
24310 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
24311 + regs->cx = addr1;
24312 + regs->ax = addr2;
24313 + regs->ip = addr2;
24314 + return 2;
24315 + }
24316 + } while (0);
24317 +
24318 + do { /* PaX: gcc trampoline emulation #2 */
24319 + unsigned char mov, jmp;
24320 + unsigned int addr1, addr2;
24321 +
24322 +#ifdef CONFIG_X86_64
24323 + if ((regs->ip + 9) >> 32)
24324 + break;
24325 +#endif
24326 +
24327 + err = get_user(mov, (unsigned char __user *)regs->ip);
24328 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
24329 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
24330 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
24331 +
24332 + if (err)
24333 + break;
24334 +
24335 + if (mov == 0xB9 && jmp == 0xE9) {
24336 + regs->cx = addr1;
24337 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
24338 + return 2;
24339 + }
24340 + } while (0);
24341 +
24342 + return 1; /* PaX in action */
24343 +}
24344 +
24345 +#ifdef CONFIG_X86_64
24346 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
24347 +{
24348 + int err;
24349 +
24350 + do { /* PaX: libffi trampoline emulation */
24351 + unsigned short mov1, mov2, jmp1;
24352 + unsigned char stcclc, jmp2;
24353 + unsigned long addr1, addr2;
24354 +
24355 + err = get_user(mov1, (unsigned short __user *)regs->ip);
24356 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
24357 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
24358 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
24359 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
24360 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
24361 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
24362 +
24363 + if (err)
24364 + break;
24365 +
24366 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
24367 + regs->r11 = addr1;
24368 + regs->r10 = addr2;
24369 + if (stcclc == 0xF8)
24370 + regs->flags &= ~X86_EFLAGS_CF;
24371 + else
24372 + regs->flags |= X86_EFLAGS_CF;
24373 + regs->ip = addr1;
24374 + return 2;
24375 + }
24376 + } while (0);
24377 +
24378 + do { /* PaX: gcc trampoline emulation #1 */
24379 + unsigned short mov1, mov2, jmp1;
24380 + unsigned char jmp2;
24381 + unsigned int addr1;
24382 + unsigned long addr2;
24383 +
24384 + err = get_user(mov1, (unsigned short __user *)regs->ip);
24385 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
24386 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
24387 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
24388 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
24389 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
24390 +
24391 + if (err)
24392 + break;
24393 +
24394 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
24395 + regs->r11 = addr1;
24396 + regs->r10 = addr2;
24397 + regs->ip = addr1;
24398 + return 2;
24399 + }
24400 + } while (0);
24401 +
24402 + do { /* PaX: gcc trampoline emulation #2 */
24403 + unsigned short mov1, mov2, jmp1;
24404 + unsigned char jmp2;
24405 + unsigned long addr1, addr2;
24406 +
24407 + err = get_user(mov1, (unsigned short __user *)regs->ip);
24408 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
24409 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
24410 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
24411 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
24412 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
24413 +
24414 + if (err)
24415 + break;
24416 +
24417 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
24418 + regs->r11 = addr1;
24419 + regs->r10 = addr2;
24420 + regs->ip = addr1;
24421 + return 2;
24422 + }
24423 + } while (0);
24424 +
24425 + return 1; /* PaX in action */
24426 +}
24427 +#endif
24428 +
24429 +/*
24430 + * PaX: decide what to do with offenders (regs->ip = fault address)
24431 + *
24432 + * returns 1 when task should be killed
24433 + * 2 when gcc trampoline was detected
24434 + */
24435 +static int pax_handle_fetch_fault(struct pt_regs *regs)
24436 +{
24437 + if (v8086_mode(regs))
24438 + return 1;
24439 +
24440 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
24441 + return 1;
24442 +
24443 +#ifdef CONFIG_X86_32
24444 + return pax_handle_fetch_fault_32(regs);
24445 +#else
24446 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
24447 + return pax_handle_fetch_fault_32(regs);
24448 + else
24449 + return pax_handle_fetch_fault_64(regs);
24450 +#endif
24451 +}
24452 +#endif
24453 +
24454 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
24455 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
24456 +{
24457 + long i;
24458 +
24459 + printk(KERN_ERR "PAX: bytes at PC: ");
24460 + for (i = 0; i < 20; i++) {
24461 + unsigned char c;
24462 + if (get_user(c, (unsigned char __force_user *)pc+i))
24463 + printk(KERN_CONT "?? ");
24464 + else
24465 + printk(KERN_CONT "%02x ", c);
24466 + }
24467 + printk("\n");
24468 +
24469 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
24470 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
24471 + unsigned long c;
24472 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
24473 +#ifdef CONFIG_X86_32
24474 + printk(KERN_CONT "???????? ");
24475 +#else
24476 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
24477 + printk(KERN_CONT "???????? ???????? ");
24478 + else
24479 + printk(KERN_CONT "???????????????? ");
24480 +#endif
24481 + } else {
24482 +#ifdef CONFIG_X86_64
24483 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
24484 + printk(KERN_CONT "%08x ", (unsigned int)c);
24485 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
24486 + } else
24487 +#endif
24488 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
24489 + }
24490 + }
24491 + printk("\n");
24492 +}
24493 +#endif
24494 +
24495 +/**
24496 + * probe_kernel_write(): safely attempt to write to a location
24497 + * @dst: address to write to
24498 + * @src: pointer to the data that shall be written
24499 + * @size: size of the data chunk
24500 + *
24501 + * Safely write to address @dst from the buffer at @src. If a kernel fault
24502 + * happens, handle that and return -EFAULT.
24503 + */
24504 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
24505 +{
24506 + long ret;
24507 + mm_segment_t old_fs = get_fs();
24508 +
24509 + set_fs(KERNEL_DS);
24510 + pagefault_disable();
24511 + pax_open_kernel();
24512 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
24513 + pax_close_kernel();
24514 + pagefault_enable();
24515 + set_fs(old_fs);
24516 +
24517 + return ret ? -EFAULT : 0;
24518 +}
24519 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
24520 index dd74e46..7d26398 100644
24521 --- a/arch/x86/mm/gup.c
24522 +++ b/arch/x86/mm/gup.c
24523 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
24524 addr = start;
24525 len = (unsigned long) nr_pages << PAGE_SHIFT;
24526 end = start + len;
24527 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
24528 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
24529 (void __user *)start, len)))
24530 return 0;
24531
24532 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
24533 index f4f29b1..5cac4fb 100644
24534 --- a/arch/x86/mm/highmem_32.c
24535 +++ b/arch/x86/mm/highmem_32.c
24536 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
24537 idx = type + KM_TYPE_NR*smp_processor_id();
24538 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
24539 BUG_ON(!pte_none(*(kmap_pte-idx)));
24540 +
24541 + pax_open_kernel();
24542 set_pte(kmap_pte-idx, mk_pte(page, prot));
24543 + pax_close_kernel();
24544 +
24545 arch_flush_lazy_mmu_mode();
24546
24547 return (void *)vaddr;
24548 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
24549 index 8ecbb4b..a269cab 100644
24550 --- a/arch/x86/mm/hugetlbpage.c
24551 +++ b/arch/x86/mm/hugetlbpage.c
24552 @@ -266,13 +266,20 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
24553 struct hstate *h = hstate_file(file);
24554 struct mm_struct *mm = current->mm;
24555 struct vm_area_struct *vma;
24556 - unsigned long start_addr;
24557 + unsigned long start_addr, pax_task_size = TASK_SIZE;
24558 +
24559 +#ifdef CONFIG_PAX_SEGMEXEC
24560 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
24561 + pax_task_size = SEGMEXEC_TASK_SIZE;
24562 +#endif
24563 +
24564 + pax_task_size -= PAGE_SIZE;
24565
24566 if (len > mm->cached_hole_size) {
24567 - start_addr = mm->free_area_cache;
24568 + start_addr = mm->free_area_cache;
24569 } else {
24570 - start_addr = TASK_UNMAPPED_BASE;
24571 - mm->cached_hole_size = 0;
24572 + start_addr = mm->mmap_base;
24573 + mm->cached_hole_size = 0;
24574 }
24575
24576 full_search:
24577 @@ -280,26 +287,27 @@ full_search:
24578
24579 for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
24580 /* At this point: (!vma || addr < vma->vm_end). */
24581 - if (TASK_SIZE - len < addr) {
24582 + if (pax_task_size - len < addr) {
24583 /*
24584 * Start a new search - just in case we missed
24585 * some holes.
24586 */
24587 - if (start_addr != TASK_UNMAPPED_BASE) {
24588 - start_addr = TASK_UNMAPPED_BASE;
24589 + if (start_addr != mm->mmap_base) {
24590 + start_addr = mm->mmap_base;
24591 mm->cached_hole_size = 0;
24592 goto full_search;
24593 }
24594 return -ENOMEM;
24595 }
24596 - if (!vma || addr + len <= vma->vm_start) {
24597 - mm->free_area_cache = addr + len;
24598 - return addr;
24599 - }
24600 + if (check_heap_stack_gap(vma, addr, len))
24601 + break;
24602 if (addr + mm->cached_hole_size < vma->vm_start)
24603 mm->cached_hole_size = vma->vm_start - addr;
24604 addr = ALIGN(vma->vm_end, huge_page_size(h));
24605 }
24606 +
24607 + mm->free_area_cache = addr + len;
24608 + return addr;
24609 }
24610
24611 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
24612 @@ -308,10 +316,9 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
24613 {
24614 struct hstate *h = hstate_file(file);
24615 struct mm_struct *mm = current->mm;
24616 - struct vm_area_struct *vma, *prev_vma;
24617 - unsigned long base = mm->mmap_base, addr = addr0;
24618 + struct vm_area_struct *vma;
24619 + unsigned long base = mm->mmap_base, addr;
24620 unsigned long largest_hole = mm->cached_hole_size;
24621 - int first_time = 1;
24622
24623 /* don't allow allocations above current base */
24624 if (mm->free_area_cache > base)
24625 @@ -321,14 +328,15 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
24626 largest_hole = 0;
24627 mm->free_area_cache = base;
24628 }
24629 -try_again:
24630 +
24631 /* make sure it can fit in the remaining address space */
24632 if (mm->free_area_cache < len)
24633 goto fail;
24634
24635 /* either no address requested or can't fit in requested address hole */
24636 - addr = (mm->free_area_cache - len) & huge_page_mask(h);
24637 + addr = (mm->free_area_cache - len);
24638 do {
24639 + addr &= huge_page_mask(h);
24640 /*
24641 * Lookup failure means no vma is above this address,
24642 * i.e. return with success:
24643 @@ -341,46 +349,47 @@ try_again:
24644 * new region fits between prev_vma->vm_end and
24645 * vma->vm_start, use it:
24646 */
24647 - prev_vma = vma->vm_prev;
24648 - if (addr + len <= vma->vm_start &&
24649 - (!prev_vma || (addr >= prev_vma->vm_end))) {
24650 + if (check_heap_stack_gap(vma, addr, len)) {
24651 /* remember the address as a hint for next time */
24652 - mm->cached_hole_size = largest_hole;
24653 - return (mm->free_area_cache = addr);
24654 - } else {
24655 - /* pull free_area_cache down to the first hole */
24656 - if (mm->free_area_cache == vma->vm_end) {
24657 - mm->free_area_cache = vma->vm_start;
24658 - mm->cached_hole_size = largest_hole;
24659 - }
24660 + mm->cached_hole_size = largest_hole;
24661 + return (mm->free_area_cache = addr);
24662 + }
24663 + /* pull free_area_cache down to the first hole */
24664 + if (mm->free_area_cache == vma->vm_end) {
24665 + mm->free_area_cache = vma->vm_start;
24666 + mm->cached_hole_size = largest_hole;
24667 }
24668
24669 /* remember the largest hole we saw so far */
24670 if (addr + largest_hole < vma->vm_start)
24671 - largest_hole = vma->vm_start - addr;
24672 + largest_hole = vma->vm_start - addr;
24673
24674 /* try just below the current vma->vm_start */
24675 - addr = (vma->vm_start - len) & huge_page_mask(h);
24676 - } while (len <= vma->vm_start);
24677 + addr = skip_heap_stack_gap(vma, len);
24678 + } while (!IS_ERR_VALUE(addr));
24679
24680 fail:
24681 /*
24682 - * if hint left us with no space for the requested
24683 - * mapping then try again:
24684 - */
24685 - if (first_time) {
24686 - mm->free_area_cache = base;
24687 - largest_hole = 0;
24688 - first_time = 0;
24689 - goto try_again;
24690 - }
24691 - /*
24692 * A failed mmap() very likely causes application failure,
24693 * so fall back to the bottom-up function here. This scenario
24694 * can happen with large stack limits and large mmap()
24695 * allocations.
24696 */
24697 - mm->free_area_cache = TASK_UNMAPPED_BASE;
24698 +
24699 +#ifdef CONFIG_PAX_SEGMEXEC
24700 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
24701 + mm->mmap_base = SEGMEXEC_TASK_UNMAPPED_BASE;
24702 + else
24703 +#endif
24704 +
24705 + mm->mmap_base = TASK_UNMAPPED_BASE;
24706 +
24707 +#ifdef CONFIG_PAX_RANDMMAP
24708 + if (mm->pax_flags & MF_PAX_RANDMMAP)
24709 + mm->mmap_base += mm->delta_mmap;
24710 +#endif
24711 +
24712 + mm->free_area_cache = mm->mmap_base;
24713 mm->cached_hole_size = ~0UL;
24714 addr = hugetlb_get_unmapped_area_bottomup(file, addr0,
24715 len, pgoff, flags);
24716 @@ -388,6 +397,7 @@ fail:
24717 /*
24718 * Restore the topdown base:
24719 */
24720 + mm->mmap_base = base;
24721 mm->free_area_cache = base;
24722 mm->cached_hole_size = ~0UL;
24723
24724 @@ -401,10 +411,19 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
24725 struct hstate *h = hstate_file(file);
24726 struct mm_struct *mm = current->mm;
24727 struct vm_area_struct *vma;
24728 + unsigned long pax_task_size = TASK_SIZE;
24729
24730 if (len & ~huge_page_mask(h))
24731 return -EINVAL;
24732 - if (len > TASK_SIZE)
24733 +
24734 +#ifdef CONFIG_PAX_SEGMEXEC
24735 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
24736 + pax_task_size = SEGMEXEC_TASK_SIZE;
24737 +#endif
24738 +
24739 + pax_task_size -= PAGE_SIZE;
24740 +
24741 + if (len > pax_task_size)
24742 return -ENOMEM;
24743
24744 if (flags & MAP_FIXED) {
24745 @@ -416,8 +435,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
24746 if (addr) {
24747 addr = ALIGN(addr, huge_page_size(h));
24748 vma = find_vma(mm, addr);
24749 - if (TASK_SIZE - len >= addr &&
24750 - (!vma || addr + len <= vma->vm_start))
24751 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len))
24752 return addr;
24753 }
24754 if (mm->get_unmapped_area == arch_get_unmapped_area)
24755 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
24756 index 6cabf65..00139c4 100644
24757 --- a/arch/x86/mm/init.c
24758 +++ b/arch/x86/mm/init.c
24759 @@ -17,6 +17,8 @@
24760 #include <asm/tlb.h>
24761 #include <asm/proto.h>
24762 #include <asm/dma.h> /* for MAX_DMA_PFN */
24763 +#include <asm/desc.h>
24764 +#include <asm/bios_ebda.h>
24765
24766 unsigned long __initdata pgt_buf_start;
24767 unsigned long __meminitdata pgt_buf_end;
24768 @@ -33,7 +35,7 @@ int direct_gbpages
24769 static void __init find_early_table_space(unsigned long end, int use_pse,
24770 int use_gbpages)
24771 {
24772 - unsigned long puds, pmds, ptes, tables, start = 0, good_end = end;
24773 + unsigned long puds, pmds, ptes, tables, start = 0x100000, good_end = end;
24774 phys_addr_t base;
24775
24776 puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
24777 @@ -312,10 +314,37 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
24778 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
24779 * mmio resources as well as potential bios/acpi data regions.
24780 */
24781 +
24782 +#ifdef CONFIG_GRKERNSEC_KMEM
24783 +static unsigned int ebda_start __read_only;
24784 +static unsigned int ebda_end __read_only;
24785 +#endif
24786 +
24787 int devmem_is_allowed(unsigned long pagenr)
24788 {
24789 +#ifdef CONFIG_GRKERNSEC_KMEM
24790 + /* allow BDA */
24791 + if (!pagenr)
24792 + return 1;
24793 + /* allow EBDA */
24794 + if (pagenr >= ebda_start && pagenr < ebda_end)
24795 + return 1;
24796 +#else
24797 + if (!pagenr)
24798 + return 1;
24799 +#ifdef CONFIG_VM86
24800 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
24801 + return 1;
24802 +#endif
24803 +#endif
24804 +
24805 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
24806 + return 1;
24807 +#ifdef CONFIG_GRKERNSEC_KMEM
24808 + /* throw out everything else below 1MB */
24809 if (pagenr <= 256)
24810 - return 1;
24811 + return 0;
24812 +#endif
24813 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
24814 return 0;
24815 if (!page_is_ram(pagenr))
24816 @@ -372,8 +401,116 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
24817 #endif
24818 }
24819
24820 +#ifdef CONFIG_GRKERNSEC_KMEM
24821 +static inline void gr_init_ebda(void)
24822 +{
24823 + unsigned int ebda_addr;
24824 + unsigned int ebda_size = 0;
24825 +
24826 + ebda_addr = get_bios_ebda();
24827 + if (ebda_addr) {
24828 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
24829 + ebda_size <<= 10;
24830 + }
24831 + if (ebda_addr && ebda_size) {
24832 + ebda_start = ebda_addr >> PAGE_SHIFT;
24833 + ebda_end = min(PAGE_ALIGN(ebda_addr + ebda_size), 0xa0000) >> PAGE_SHIFT;
24834 + } else {
24835 + ebda_start = 0x9f000 >> PAGE_SHIFT;
24836 + ebda_end = 0xa0000 >> PAGE_SHIFT;
24837 + }
24838 +}
24839 +#else
24840 +static inline void gr_init_ebda(void) { }
24841 +#endif
24842 +
24843 void free_initmem(void)
24844 {
24845 +#ifdef CONFIG_PAX_KERNEXEC
24846 +#ifdef CONFIG_X86_32
24847 + /* PaX: limit KERNEL_CS to actual size */
24848 + unsigned long addr, limit;
24849 + struct desc_struct d;
24850 + int cpu;
24851 +#endif
24852 +#endif
24853 +
24854 + gr_init_ebda();
24855 +
24856 +#ifdef CONFIG_PAX_KERNEXEC
24857 +#ifdef CONFIG_X86_32
24858 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
24859 + limit = (limit - 1UL) >> PAGE_SHIFT;
24860 +
24861 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
24862 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
24863 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
24864 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
24865 + }
24866 +
24867 + /* PaX: make KERNEL_CS read-only */
24868 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
24869 + if (!paravirt_enabled())
24870 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
24871 +/*
24872 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
24873 + pgd = pgd_offset_k(addr);
24874 + pud = pud_offset(pgd, addr);
24875 + pmd = pmd_offset(pud, addr);
24876 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
24877 + }
24878 +*/
24879 +#ifdef CONFIG_X86_PAE
24880 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
24881 +/*
24882 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
24883 + pgd = pgd_offset_k(addr);
24884 + pud = pud_offset(pgd, addr);
24885 + pmd = pmd_offset(pud, addr);
24886 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
24887 + }
24888 +*/
24889 +#endif
24890 +
24891 +#ifdef CONFIG_MODULES
24892 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
24893 +#endif
24894 +
24895 +#else
24896 + pgd_t *pgd;
24897 + pud_t *pud;
24898 + pmd_t *pmd;
24899 + unsigned long addr, end;
24900 +
24901 + /* PaX: make kernel code/rodata read-only, rest non-executable */
24902 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
24903 + pgd = pgd_offset_k(addr);
24904 + pud = pud_offset(pgd, addr);
24905 + pmd = pmd_offset(pud, addr);
24906 + if (!pmd_present(*pmd))
24907 + continue;
24908 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
24909 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
24910 + else
24911 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
24912 + }
24913 +
24914 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
24915 + end = addr + KERNEL_IMAGE_SIZE;
24916 + for (; addr < end; addr += PMD_SIZE) {
24917 + pgd = pgd_offset_k(addr);
24918 + pud = pud_offset(pgd, addr);
24919 + pmd = pmd_offset(pud, addr);
24920 + if (!pmd_present(*pmd))
24921 + continue;
24922 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
24923 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
24924 + }
24925 +#endif
24926 +
24927 + flush_tlb_all();
24928 +#endif
24929 +
24930 free_init_pages("unused kernel memory",
24931 (unsigned long)(&__init_begin),
24932 (unsigned long)(&__init_end));
24933 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
24934 index 8663f6c..829ae76 100644
24935 --- a/arch/x86/mm/init_32.c
24936 +++ b/arch/x86/mm/init_32.c
24937 @@ -74,36 +74,6 @@ static __init void *alloc_low_page(void)
24938 }
24939
24940 /*
24941 - * Creates a middle page table and puts a pointer to it in the
24942 - * given global directory entry. This only returns the gd entry
24943 - * in non-PAE compilation mode, since the middle layer is folded.
24944 - */
24945 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
24946 -{
24947 - pud_t *pud;
24948 - pmd_t *pmd_table;
24949 -
24950 -#ifdef CONFIG_X86_PAE
24951 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
24952 - if (after_bootmem)
24953 - pmd_table = (pmd_t *)alloc_bootmem_pages(PAGE_SIZE);
24954 - else
24955 - pmd_table = (pmd_t *)alloc_low_page();
24956 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
24957 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
24958 - pud = pud_offset(pgd, 0);
24959 - BUG_ON(pmd_table != pmd_offset(pud, 0));
24960 -
24961 - return pmd_table;
24962 - }
24963 -#endif
24964 - pud = pud_offset(pgd, 0);
24965 - pmd_table = pmd_offset(pud, 0);
24966 -
24967 - return pmd_table;
24968 -}
24969 -
24970 -/*
24971 * Create a page table and place a pointer to it in a middle page
24972 * directory entry:
24973 */
24974 @@ -123,13 +93,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
24975 page_table = (pte_t *)alloc_low_page();
24976
24977 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
24978 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
24979 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
24980 +#else
24981 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
24982 +#endif
24983 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
24984 }
24985
24986 return pte_offset_kernel(pmd, 0);
24987 }
24988
24989 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
24990 +{
24991 + pud_t *pud;
24992 + pmd_t *pmd_table;
24993 +
24994 + pud = pud_offset(pgd, 0);
24995 + pmd_table = pmd_offset(pud, 0);
24996 +
24997 + return pmd_table;
24998 +}
24999 +
25000 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
25001 {
25002 int pgd_idx = pgd_index(vaddr);
25003 @@ -203,6 +188,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
25004 int pgd_idx, pmd_idx;
25005 unsigned long vaddr;
25006 pgd_t *pgd;
25007 + pud_t *pud;
25008 pmd_t *pmd;
25009 pte_t *pte = NULL;
25010
25011 @@ -212,8 +198,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
25012 pgd = pgd_base + pgd_idx;
25013
25014 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
25015 - pmd = one_md_table_init(pgd);
25016 - pmd = pmd + pmd_index(vaddr);
25017 + pud = pud_offset(pgd, vaddr);
25018 + pmd = pmd_offset(pud, vaddr);
25019 +
25020 +#ifdef CONFIG_X86_PAE
25021 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
25022 +#endif
25023 +
25024 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
25025 pmd++, pmd_idx++) {
25026 pte = page_table_kmap_check(one_page_table_init(pmd),
25027 @@ -225,11 +216,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
25028 }
25029 }
25030
25031 -static inline int is_kernel_text(unsigned long addr)
25032 +static inline int is_kernel_text(unsigned long start, unsigned long end)
25033 {
25034 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
25035 - return 1;
25036 - return 0;
25037 + if ((start > ktla_ktva((unsigned long)_etext) ||
25038 + end <= ktla_ktva((unsigned long)_stext)) &&
25039 + (start > ktla_ktva((unsigned long)_einittext) ||
25040 + end <= ktla_ktva((unsigned long)_sinittext)) &&
25041 +
25042 +#ifdef CONFIG_ACPI_SLEEP
25043 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
25044 +#endif
25045 +
25046 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
25047 + return 0;
25048 + return 1;
25049 }
25050
25051 /*
25052 @@ -246,9 +246,10 @@ kernel_physical_mapping_init(unsigned long start,
25053 unsigned long last_map_addr = end;
25054 unsigned long start_pfn, end_pfn;
25055 pgd_t *pgd_base = swapper_pg_dir;
25056 - int pgd_idx, pmd_idx, pte_ofs;
25057 + unsigned int pgd_idx, pmd_idx, pte_ofs;
25058 unsigned long pfn;
25059 pgd_t *pgd;
25060 + pud_t *pud;
25061 pmd_t *pmd;
25062 pte_t *pte;
25063 unsigned pages_2m, pages_4k;
25064 @@ -281,8 +282,13 @@ repeat:
25065 pfn = start_pfn;
25066 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
25067 pgd = pgd_base + pgd_idx;
25068 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
25069 - pmd = one_md_table_init(pgd);
25070 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
25071 + pud = pud_offset(pgd, 0);
25072 + pmd = pmd_offset(pud, 0);
25073 +
25074 +#ifdef CONFIG_X86_PAE
25075 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
25076 +#endif
25077
25078 if (pfn >= end_pfn)
25079 continue;
25080 @@ -294,14 +300,13 @@ repeat:
25081 #endif
25082 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
25083 pmd++, pmd_idx++) {
25084 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
25085 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
25086
25087 /*
25088 * Map with big pages if possible, otherwise
25089 * create normal page tables:
25090 */
25091 if (use_pse) {
25092 - unsigned int addr2;
25093 pgprot_t prot = PAGE_KERNEL_LARGE;
25094 /*
25095 * first pass will use the same initial
25096 @@ -311,11 +316,7 @@ repeat:
25097 __pgprot(PTE_IDENT_ATTR |
25098 _PAGE_PSE);
25099
25100 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
25101 - PAGE_OFFSET + PAGE_SIZE-1;
25102 -
25103 - if (is_kernel_text(addr) ||
25104 - is_kernel_text(addr2))
25105 + if (is_kernel_text(address, address + PMD_SIZE))
25106 prot = PAGE_KERNEL_LARGE_EXEC;
25107
25108 pages_2m++;
25109 @@ -332,7 +333,7 @@ repeat:
25110 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
25111 pte += pte_ofs;
25112 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
25113 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
25114 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
25115 pgprot_t prot = PAGE_KERNEL;
25116 /*
25117 * first pass will use the same initial
25118 @@ -340,7 +341,7 @@ repeat:
25119 */
25120 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
25121
25122 - if (is_kernel_text(addr))
25123 + if (is_kernel_text(address, address + PAGE_SIZE))
25124 prot = PAGE_KERNEL_EXEC;
25125
25126 pages_4k++;
25127 @@ -466,7 +467,7 @@ void __init native_pagetable_setup_start(pgd_t *base)
25128
25129 pud = pud_offset(pgd, va);
25130 pmd = pmd_offset(pud, va);
25131 - if (!pmd_present(*pmd))
25132 + if (!pmd_present(*pmd) || pmd_huge(*pmd))
25133 break;
25134
25135 pte = pte_offset_kernel(pmd, va);
25136 @@ -518,12 +519,10 @@ void __init early_ioremap_page_table_range_init(void)
25137
25138 static void __init pagetable_init(void)
25139 {
25140 - pgd_t *pgd_base = swapper_pg_dir;
25141 -
25142 - permanent_kmaps_init(pgd_base);
25143 + permanent_kmaps_init(swapper_pg_dir);
25144 }
25145
25146 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
25147 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
25148 EXPORT_SYMBOL_GPL(__supported_pte_mask);
25149
25150 /* user-defined highmem size */
25151 @@ -735,6 +734,12 @@ void __init mem_init(void)
25152
25153 pci_iommu_alloc();
25154
25155 +#ifdef CONFIG_PAX_PER_CPU_PGD
25156 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
25157 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25158 + KERNEL_PGD_PTRS);
25159 +#endif
25160 +
25161 #ifdef CONFIG_FLATMEM
25162 BUG_ON(!mem_map);
25163 #endif
25164 @@ -761,7 +766,7 @@ void __init mem_init(void)
25165 reservedpages++;
25166
25167 codesize = (unsigned long) &_etext - (unsigned long) &_text;
25168 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
25169 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
25170 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
25171
25172 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
25173 @@ -802,10 +807,10 @@ void __init mem_init(void)
25174 ((unsigned long)&__init_end -
25175 (unsigned long)&__init_begin) >> 10,
25176
25177 - (unsigned long)&_etext, (unsigned long)&_edata,
25178 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
25179 + (unsigned long)&_sdata, (unsigned long)&_edata,
25180 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
25181
25182 - (unsigned long)&_text, (unsigned long)&_etext,
25183 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
25184 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
25185
25186 /*
25187 @@ -883,6 +888,7 @@ void set_kernel_text_rw(void)
25188 if (!kernel_set_to_readonly)
25189 return;
25190
25191 + start = ktla_ktva(start);
25192 pr_debug("Set kernel text: %lx - %lx for read write\n",
25193 start, start+size);
25194
25195 @@ -897,6 +903,7 @@ void set_kernel_text_ro(void)
25196 if (!kernel_set_to_readonly)
25197 return;
25198
25199 + start = ktla_ktva(start);
25200 pr_debug("Set kernel text: %lx - %lx for read only\n",
25201 start, start+size);
25202
25203 @@ -925,6 +932,7 @@ void mark_rodata_ro(void)
25204 unsigned long start = PFN_ALIGN(_text);
25205 unsigned long size = PFN_ALIGN(_etext) - start;
25206
25207 + start = ktla_ktva(start);
25208 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
25209 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
25210 size >> 10);
25211 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
25212 index 436a030..4f97ffc 100644
25213 --- a/arch/x86/mm/init_64.c
25214 +++ b/arch/x86/mm/init_64.c
25215 @@ -75,7 +75,7 @@ early_param("gbpages", parse_direct_gbpages_on);
25216 * around without checking the pgd every time.
25217 */
25218
25219 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
25220 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
25221 EXPORT_SYMBOL_GPL(__supported_pte_mask);
25222
25223 int force_personality32;
25224 @@ -108,12 +108,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
25225
25226 for (address = start; address <= end; address += PGDIR_SIZE) {
25227 const pgd_t *pgd_ref = pgd_offset_k(address);
25228 +
25229 +#ifdef CONFIG_PAX_PER_CPU_PGD
25230 + unsigned long cpu;
25231 +#else
25232 struct page *page;
25233 +#endif
25234
25235 if (pgd_none(*pgd_ref))
25236 continue;
25237
25238 spin_lock(&pgd_lock);
25239 +
25240 +#ifdef CONFIG_PAX_PER_CPU_PGD
25241 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
25242 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
25243 +#else
25244 list_for_each_entry(page, &pgd_list, lru) {
25245 pgd_t *pgd;
25246 spinlock_t *pgt_lock;
25247 @@ -122,6 +132,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
25248 /* the pgt_lock only for Xen */
25249 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
25250 spin_lock(pgt_lock);
25251 +#endif
25252
25253 if (pgd_none(*pgd))
25254 set_pgd(pgd, *pgd_ref);
25255 @@ -129,7 +140,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
25256 BUG_ON(pgd_page_vaddr(*pgd)
25257 != pgd_page_vaddr(*pgd_ref));
25258
25259 +#ifndef CONFIG_PAX_PER_CPU_PGD
25260 spin_unlock(pgt_lock);
25261 +#endif
25262 +
25263 }
25264 spin_unlock(&pgd_lock);
25265 }
25266 @@ -162,7 +176,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
25267 {
25268 if (pgd_none(*pgd)) {
25269 pud_t *pud = (pud_t *)spp_getpage();
25270 - pgd_populate(&init_mm, pgd, pud);
25271 + pgd_populate_kernel(&init_mm, pgd, pud);
25272 if (pud != pud_offset(pgd, 0))
25273 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
25274 pud, pud_offset(pgd, 0));
25275 @@ -174,7 +188,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
25276 {
25277 if (pud_none(*pud)) {
25278 pmd_t *pmd = (pmd_t *) spp_getpage();
25279 - pud_populate(&init_mm, pud, pmd);
25280 + pud_populate_kernel(&init_mm, pud, pmd);
25281 if (pmd != pmd_offset(pud, 0))
25282 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
25283 pmd, pmd_offset(pud, 0));
25284 @@ -203,7 +217,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
25285 pmd = fill_pmd(pud, vaddr);
25286 pte = fill_pte(pmd, vaddr);
25287
25288 + pax_open_kernel();
25289 set_pte(pte, new_pte);
25290 + pax_close_kernel();
25291
25292 /*
25293 * It's enough to flush this one mapping.
25294 @@ -262,14 +278,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
25295 pgd = pgd_offset_k((unsigned long)__va(phys));
25296 if (pgd_none(*pgd)) {
25297 pud = (pud_t *) spp_getpage();
25298 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
25299 - _PAGE_USER));
25300 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
25301 }
25302 pud = pud_offset(pgd, (unsigned long)__va(phys));
25303 if (pud_none(*pud)) {
25304 pmd = (pmd_t *) spp_getpage();
25305 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
25306 - _PAGE_USER));
25307 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
25308 }
25309 pmd = pmd_offset(pud, phys);
25310 BUG_ON(!pmd_none(*pmd));
25311 @@ -330,7 +344,7 @@ static __ref void *alloc_low_page(unsigned long *phys)
25312 if (pfn >= pgt_buf_top)
25313 panic("alloc_low_page: ran out of memory");
25314
25315 - adr = early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
25316 + adr = (void __force_kernel *)early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
25317 clear_page(adr);
25318 *phys = pfn * PAGE_SIZE;
25319 return adr;
25320 @@ -346,7 +360,7 @@ static __ref void *map_low_page(void *virt)
25321
25322 phys = __pa(virt);
25323 left = phys & (PAGE_SIZE - 1);
25324 - adr = early_memremap(phys & PAGE_MASK, PAGE_SIZE);
25325 + adr = (void __force_kernel *)early_memremap(phys & PAGE_MASK, PAGE_SIZE);
25326 adr = (void *)(((unsigned long)adr) | left);
25327
25328 return adr;
25329 @@ -546,7 +560,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
25330 unmap_low_page(pmd);
25331
25332 spin_lock(&init_mm.page_table_lock);
25333 - pud_populate(&init_mm, pud, __va(pmd_phys));
25334 + pud_populate_kernel(&init_mm, pud, __va(pmd_phys));
25335 spin_unlock(&init_mm.page_table_lock);
25336 }
25337 __flush_tlb_all();
25338 @@ -592,7 +606,7 @@ kernel_physical_mapping_init(unsigned long start,
25339 unmap_low_page(pud);
25340
25341 spin_lock(&init_mm.page_table_lock);
25342 - pgd_populate(&init_mm, pgd, __va(pud_phys));
25343 + pgd_populate_kernel(&init_mm, pgd, __va(pud_phys));
25344 spin_unlock(&init_mm.page_table_lock);
25345 pgd_changed = true;
25346 }
25347 @@ -684,6 +698,12 @@ void __init mem_init(void)
25348
25349 pci_iommu_alloc();
25350
25351 +#ifdef CONFIG_PAX_PER_CPU_PGD
25352 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
25353 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25354 + KERNEL_PGD_PTRS);
25355 +#endif
25356 +
25357 /* clear_bss() already clear the empty_zero_page */
25358
25359 reservedpages = 0;
25360 @@ -844,8 +864,8 @@ int kern_addr_valid(unsigned long addr)
25361 static struct vm_area_struct gate_vma = {
25362 .vm_start = VSYSCALL_START,
25363 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
25364 - .vm_page_prot = PAGE_READONLY_EXEC,
25365 - .vm_flags = VM_READ | VM_EXEC
25366 + .vm_page_prot = PAGE_READONLY,
25367 + .vm_flags = VM_READ
25368 };
25369
25370 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
25371 @@ -879,7 +899,7 @@ int in_gate_area_no_mm(unsigned long addr)
25372
25373 const char *arch_vma_name(struct vm_area_struct *vma)
25374 {
25375 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
25376 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
25377 return "[vdso]";
25378 if (vma == &gate_vma)
25379 return "[vsyscall]";
25380 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
25381 index 7b179b4..6bd1777 100644
25382 --- a/arch/x86/mm/iomap_32.c
25383 +++ b/arch/x86/mm/iomap_32.c
25384 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
25385 type = kmap_atomic_idx_push();
25386 idx = type + KM_TYPE_NR * smp_processor_id();
25387 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
25388 +
25389 + pax_open_kernel();
25390 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
25391 + pax_close_kernel();
25392 +
25393 arch_flush_lazy_mmu_mode();
25394
25395 return (void *)vaddr;
25396 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
25397 index be1ef57..55f0160 100644
25398 --- a/arch/x86/mm/ioremap.c
25399 +++ b/arch/x86/mm/ioremap.c
25400 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
25401 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
25402 int is_ram = page_is_ram(pfn);
25403
25404 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
25405 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
25406 return NULL;
25407 WARN_ON_ONCE(is_ram);
25408 }
25409 @@ -315,6 +315,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
25410
25411 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
25412 if (page_is_ram(start >> PAGE_SHIFT))
25413 +#ifdef CONFIG_HIGHMEM
25414 + if ((start >> PAGE_SHIFT) < max_low_pfn)
25415 +#endif
25416 return __va(phys);
25417
25418 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
25419 @@ -344,7 +347,7 @@ static int __init early_ioremap_debug_setup(char *str)
25420 early_param("early_ioremap_debug", early_ioremap_debug_setup);
25421
25422 static __initdata int after_paging_init;
25423 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
25424 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
25425
25426 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
25427 {
25428 @@ -381,8 +384,7 @@ void __init early_ioremap_init(void)
25429 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
25430
25431 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
25432 - memset(bm_pte, 0, sizeof(bm_pte));
25433 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
25434 + pmd_populate_user(&init_mm, pmd, bm_pte);
25435
25436 /*
25437 * The boot-ioremap range spans multiple pmds, for which
25438 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
25439 index d87dd6d..bf3fa66 100644
25440 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
25441 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
25442 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
25443 * memory (e.g. tracked pages)? For now, we need this to avoid
25444 * invoking kmemcheck for PnP BIOS calls.
25445 */
25446 - if (regs->flags & X86_VM_MASK)
25447 + if (v8086_mode(regs))
25448 return false;
25449 - if (regs->cs != __KERNEL_CS)
25450 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
25451 return false;
25452
25453 pte = kmemcheck_pte_lookup(address);
25454 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
25455 index 845df68..1d8d29f 100644
25456 --- a/arch/x86/mm/mmap.c
25457 +++ b/arch/x86/mm/mmap.c
25458 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
25459 * Leave an at least ~128 MB hole with possible stack randomization.
25460 */
25461 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
25462 -#define MAX_GAP (TASK_SIZE/6*5)
25463 +#define MAX_GAP (pax_task_size/6*5)
25464
25465 static int mmap_is_legacy(void)
25466 {
25467 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
25468 return rnd << PAGE_SHIFT;
25469 }
25470
25471 -static unsigned long mmap_base(void)
25472 +static unsigned long mmap_base(struct mm_struct *mm)
25473 {
25474 unsigned long gap = rlimit(RLIMIT_STACK);
25475 + unsigned long pax_task_size = TASK_SIZE;
25476 +
25477 +#ifdef CONFIG_PAX_SEGMEXEC
25478 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25479 + pax_task_size = SEGMEXEC_TASK_SIZE;
25480 +#endif
25481
25482 if (gap < MIN_GAP)
25483 gap = MIN_GAP;
25484 else if (gap > MAX_GAP)
25485 gap = MAX_GAP;
25486
25487 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
25488 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
25489 }
25490
25491 /*
25492 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
25493 * does, but not when emulating X86_32
25494 */
25495 -static unsigned long mmap_legacy_base(void)
25496 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
25497 {
25498 - if (mmap_is_ia32())
25499 + if (mmap_is_ia32()) {
25500 +
25501 +#ifdef CONFIG_PAX_SEGMEXEC
25502 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25503 + return SEGMEXEC_TASK_UNMAPPED_BASE;
25504 + else
25505 +#endif
25506 +
25507 return TASK_UNMAPPED_BASE;
25508 - else
25509 + } else
25510 return TASK_UNMAPPED_BASE + mmap_rnd();
25511 }
25512
25513 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
25514 void arch_pick_mmap_layout(struct mm_struct *mm)
25515 {
25516 if (mmap_is_legacy()) {
25517 - mm->mmap_base = mmap_legacy_base();
25518 + mm->mmap_base = mmap_legacy_base(mm);
25519 +
25520 +#ifdef CONFIG_PAX_RANDMMAP
25521 + if (mm->pax_flags & MF_PAX_RANDMMAP)
25522 + mm->mmap_base += mm->delta_mmap;
25523 +#endif
25524 +
25525 mm->get_unmapped_area = arch_get_unmapped_area;
25526 mm->unmap_area = arch_unmap_area;
25527 } else {
25528 - mm->mmap_base = mmap_base();
25529 + mm->mmap_base = mmap_base(mm);
25530 +
25531 +#ifdef CONFIG_PAX_RANDMMAP
25532 + if (mm->pax_flags & MF_PAX_RANDMMAP)
25533 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
25534 +#endif
25535 +
25536 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
25537 mm->unmap_area = arch_unmap_area_topdown;
25538 }
25539 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
25540 index dc0b727..dc9d71a 100644
25541 --- a/arch/x86/mm/mmio-mod.c
25542 +++ b/arch/x86/mm/mmio-mod.c
25543 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
25544 break;
25545 default:
25546 {
25547 - unsigned char *ip = (unsigned char *)instptr;
25548 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
25549 my_trace->opcode = MMIO_UNKNOWN_OP;
25550 my_trace->width = 0;
25551 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
25552 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
25553 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
25554 void __iomem *addr)
25555 {
25556 - static atomic_t next_id;
25557 + static atomic_unchecked_t next_id;
25558 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
25559 /* These are page-unaligned. */
25560 struct mmiotrace_map map = {
25561 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
25562 .private = trace
25563 },
25564 .phys = offset,
25565 - .id = atomic_inc_return(&next_id)
25566 + .id = atomic_inc_return_unchecked(&next_id)
25567 };
25568 map.map_id = trace->id;
25569
25570 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
25571 index b008656..773eac2 100644
25572 --- a/arch/x86/mm/pageattr-test.c
25573 +++ b/arch/x86/mm/pageattr-test.c
25574 @@ -36,7 +36,7 @@ enum {
25575
25576 static int pte_testbit(pte_t pte)
25577 {
25578 - return pte_flags(pte) & _PAGE_UNUSED1;
25579 + return pte_flags(pte) & _PAGE_CPA_TEST;
25580 }
25581
25582 struct split_state {
25583 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
25584 index e1ebde3..b1e1db38 100644
25585 --- a/arch/x86/mm/pageattr.c
25586 +++ b/arch/x86/mm/pageattr.c
25587 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
25588 */
25589 #ifdef CONFIG_PCI_BIOS
25590 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
25591 - pgprot_val(forbidden) |= _PAGE_NX;
25592 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
25593 #endif
25594
25595 /*
25596 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
25597 * Does not cover __inittext since that is gone later on. On
25598 * 64bit we do not enforce !NX on the low mapping
25599 */
25600 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
25601 - pgprot_val(forbidden) |= _PAGE_NX;
25602 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
25603 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
25604
25605 +#ifdef CONFIG_DEBUG_RODATA
25606 /*
25607 * The .rodata section needs to be read-only. Using the pfn
25608 * catches all aliases.
25609 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
25610 if (within(pfn, __pa((unsigned long)__start_rodata) >> PAGE_SHIFT,
25611 __pa((unsigned long)__end_rodata) >> PAGE_SHIFT))
25612 pgprot_val(forbidden) |= _PAGE_RW;
25613 +#endif
25614
25615 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
25616 /*
25617 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
25618 }
25619 #endif
25620
25621 +#ifdef CONFIG_PAX_KERNEXEC
25622 + if (within(pfn, __pa((unsigned long)&_text), __pa((unsigned long)&_sdata))) {
25623 + pgprot_val(forbidden) |= _PAGE_RW;
25624 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
25625 + }
25626 +#endif
25627 +
25628 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
25629
25630 return prot;
25631 @@ -369,23 +378,37 @@ EXPORT_SYMBOL_GPL(lookup_address);
25632 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
25633 {
25634 /* change init_mm */
25635 + pax_open_kernel();
25636 set_pte_atomic(kpte, pte);
25637 +
25638 #ifdef CONFIG_X86_32
25639 if (!SHARED_KERNEL_PMD) {
25640 +
25641 +#ifdef CONFIG_PAX_PER_CPU_PGD
25642 + unsigned long cpu;
25643 +#else
25644 struct page *page;
25645 +#endif
25646
25647 +#ifdef CONFIG_PAX_PER_CPU_PGD
25648 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
25649 + pgd_t *pgd = get_cpu_pgd(cpu);
25650 +#else
25651 list_for_each_entry(page, &pgd_list, lru) {
25652 - pgd_t *pgd;
25653 + pgd_t *pgd = (pgd_t *)page_address(page);
25654 +#endif
25655 +
25656 pud_t *pud;
25657 pmd_t *pmd;
25658
25659 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
25660 + pgd += pgd_index(address);
25661 pud = pud_offset(pgd, address);
25662 pmd = pmd_offset(pud, address);
25663 set_pte_atomic((pte_t *)pmd, pte);
25664 }
25665 }
25666 #endif
25667 + pax_close_kernel();
25668 }
25669
25670 static int
25671 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
25672 index f6ff57b..481690f 100644
25673 --- a/arch/x86/mm/pat.c
25674 +++ b/arch/x86/mm/pat.c
25675 @@ -361,7 +361,7 @@ int free_memtype(u64 start, u64 end)
25676
25677 if (!entry) {
25678 printk(KERN_INFO "%s:%d freeing invalid memtype %Lx-%Lx\n",
25679 - current->comm, current->pid, start, end);
25680 + current->comm, task_pid_nr(current), start, end);
25681 return -EINVAL;
25682 }
25683
25684 @@ -492,8 +492,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
25685 while (cursor < to) {
25686 if (!devmem_is_allowed(pfn)) {
25687 printk(KERN_INFO
25688 - "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
25689 - current->comm, from, to);
25690 + "Program %s tried to access /dev/mem between %Lx->%Lx (%Lx).\n",
25691 + current->comm, from, to, cursor);
25692 return 0;
25693 }
25694 cursor += PAGE_SIZE;
25695 @@ -557,7 +557,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
25696 printk(KERN_INFO
25697 "%s:%d ioremap_change_attr failed %s "
25698 "for %Lx-%Lx\n",
25699 - current->comm, current->pid,
25700 + current->comm, task_pid_nr(current),
25701 cattr_name(flags),
25702 base, (unsigned long long)(base + size));
25703 return -EINVAL;
25704 @@ -593,7 +593,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
25705 if (want_flags != flags) {
25706 printk(KERN_WARNING
25707 "%s:%d map pfn RAM range req %s for %Lx-%Lx, got %s\n",
25708 - current->comm, current->pid,
25709 + current->comm, task_pid_nr(current),
25710 cattr_name(want_flags),
25711 (unsigned long long)paddr,
25712 (unsigned long long)(paddr + size),
25713 @@ -615,7 +615,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
25714 free_memtype(paddr, paddr + size);
25715 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
25716 " for %Lx-%Lx, got %s\n",
25717 - current->comm, current->pid,
25718 + current->comm, task_pid_nr(current),
25719 cattr_name(want_flags),
25720 (unsigned long long)paddr,
25721 (unsigned long long)(paddr + size),
25722 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
25723 index 9f0614d..92ae64a 100644
25724 --- a/arch/x86/mm/pf_in.c
25725 +++ b/arch/x86/mm/pf_in.c
25726 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
25727 int i;
25728 enum reason_type rv = OTHERS;
25729
25730 - p = (unsigned char *)ins_addr;
25731 + p = (unsigned char *)ktla_ktva(ins_addr);
25732 p += skip_prefix(p, &prf);
25733 p += get_opcode(p, &opcode);
25734
25735 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
25736 struct prefix_bits prf;
25737 int i;
25738
25739 - p = (unsigned char *)ins_addr;
25740 + p = (unsigned char *)ktla_ktva(ins_addr);
25741 p += skip_prefix(p, &prf);
25742 p += get_opcode(p, &opcode);
25743
25744 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
25745 struct prefix_bits prf;
25746 int i;
25747
25748 - p = (unsigned char *)ins_addr;
25749 + p = (unsigned char *)ktla_ktva(ins_addr);
25750 p += skip_prefix(p, &prf);
25751 p += get_opcode(p, &opcode);
25752
25753 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
25754 struct prefix_bits prf;
25755 int i;
25756
25757 - p = (unsigned char *)ins_addr;
25758 + p = (unsigned char *)ktla_ktva(ins_addr);
25759 p += skip_prefix(p, &prf);
25760 p += get_opcode(p, &opcode);
25761 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
25762 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
25763 struct prefix_bits prf;
25764 int i;
25765
25766 - p = (unsigned char *)ins_addr;
25767 + p = (unsigned char *)ktla_ktva(ins_addr);
25768 p += skip_prefix(p, &prf);
25769 p += get_opcode(p, &opcode);
25770 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
25771 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
25772 index 8573b83..4f3ed7e 100644
25773 --- a/arch/x86/mm/pgtable.c
25774 +++ b/arch/x86/mm/pgtable.c
25775 @@ -84,10 +84,64 @@ static inline void pgd_list_del(pgd_t *pgd)
25776 list_del(&page->lru);
25777 }
25778
25779 -#define UNSHARED_PTRS_PER_PGD \
25780 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
25781 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25782 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
25783
25784 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
25785 +{
25786 + unsigned int count = USER_PGD_PTRS;
25787
25788 + while (count--)
25789 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
25790 +}
25791 +#endif
25792 +
25793 +#ifdef CONFIG_PAX_PER_CPU_PGD
25794 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
25795 +{
25796 + unsigned int count = USER_PGD_PTRS;
25797 +
25798 + while (count--) {
25799 + pgd_t pgd;
25800 +
25801 +#ifdef CONFIG_X86_64
25802 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
25803 +#else
25804 + pgd = *src++;
25805 +#endif
25806 +
25807 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25808 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
25809 +#endif
25810 +
25811 + *dst++ = pgd;
25812 + }
25813 +
25814 +}
25815 +#endif
25816 +
25817 +#ifdef CONFIG_X86_64
25818 +#define pxd_t pud_t
25819 +#define pyd_t pgd_t
25820 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
25821 +#define pxd_free(mm, pud) pud_free((mm), (pud))
25822 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
25823 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
25824 +#define PYD_SIZE PGDIR_SIZE
25825 +#else
25826 +#define pxd_t pmd_t
25827 +#define pyd_t pud_t
25828 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
25829 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
25830 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
25831 +#define pyd_offset(mm, address) pud_offset((mm), (address))
25832 +#define PYD_SIZE PUD_SIZE
25833 +#endif
25834 +
25835 +#ifdef CONFIG_PAX_PER_CPU_PGD
25836 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
25837 +static inline void pgd_dtor(pgd_t *pgd) {}
25838 +#else
25839 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
25840 {
25841 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
25842 @@ -128,6 +182,7 @@ static void pgd_dtor(pgd_t *pgd)
25843 pgd_list_del(pgd);
25844 spin_unlock(&pgd_lock);
25845 }
25846 +#endif
25847
25848 /*
25849 * List of all pgd's needed for non-PAE so it can invalidate entries
25850 @@ -140,7 +195,7 @@ static void pgd_dtor(pgd_t *pgd)
25851 * -- wli
25852 */
25853
25854 -#ifdef CONFIG_X86_PAE
25855 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
25856 /*
25857 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
25858 * updating the top-level pagetable entries to guarantee the
25859 @@ -152,7 +207,7 @@ static void pgd_dtor(pgd_t *pgd)
25860 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
25861 * and initialize the kernel pmds here.
25862 */
25863 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
25864 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
25865
25866 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
25867 {
25868 @@ -170,36 +225,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
25869 */
25870 flush_tlb_mm(mm);
25871 }
25872 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
25873 +#define PREALLOCATED_PXDS USER_PGD_PTRS
25874 #else /* !CONFIG_X86_PAE */
25875
25876 /* No need to prepopulate any pagetable entries in non-PAE modes. */
25877 -#define PREALLOCATED_PMDS 0
25878 +#define PREALLOCATED_PXDS 0
25879
25880 #endif /* CONFIG_X86_PAE */
25881
25882 -static void free_pmds(pmd_t *pmds[])
25883 +static void free_pxds(pxd_t *pxds[])
25884 {
25885 int i;
25886
25887 - for(i = 0; i < PREALLOCATED_PMDS; i++)
25888 - if (pmds[i])
25889 - free_page((unsigned long)pmds[i]);
25890 + for(i = 0; i < PREALLOCATED_PXDS; i++)
25891 + if (pxds[i])
25892 + free_page((unsigned long)pxds[i]);
25893 }
25894
25895 -static int preallocate_pmds(pmd_t *pmds[])
25896 +static int preallocate_pxds(pxd_t *pxds[])
25897 {
25898 int i;
25899 bool failed = false;
25900
25901 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
25902 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
25903 - if (pmd == NULL)
25904 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
25905 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
25906 + if (pxd == NULL)
25907 failed = true;
25908 - pmds[i] = pmd;
25909 + pxds[i] = pxd;
25910 }
25911
25912 if (failed) {
25913 - free_pmds(pmds);
25914 + free_pxds(pxds);
25915 return -ENOMEM;
25916 }
25917
25918 @@ -212,51 +269,55 @@ static int preallocate_pmds(pmd_t *pmds[])
25919 * preallocate which never got a corresponding vma will need to be
25920 * freed manually.
25921 */
25922 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
25923 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
25924 {
25925 int i;
25926
25927 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
25928 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
25929 pgd_t pgd = pgdp[i];
25930
25931 if (pgd_val(pgd) != 0) {
25932 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
25933 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
25934
25935 - pgdp[i] = native_make_pgd(0);
25936 + set_pgd(pgdp + i, native_make_pgd(0));
25937
25938 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
25939 - pmd_free(mm, pmd);
25940 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
25941 + pxd_free(mm, pxd);
25942 }
25943 }
25944 }
25945
25946 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
25947 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
25948 {
25949 - pud_t *pud;
25950 + pyd_t *pyd;
25951 unsigned long addr;
25952 int i;
25953
25954 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
25955 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
25956 return;
25957
25958 - pud = pud_offset(pgd, 0);
25959 +#ifdef CONFIG_X86_64
25960 + pyd = pyd_offset(mm, 0L);
25961 +#else
25962 + pyd = pyd_offset(pgd, 0L);
25963 +#endif
25964
25965 - for (addr = i = 0; i < PREALLOCATED_PMDS;
25966 - i++, pud++, addr += PUD_SIZE) {
25967 - pmd_t *pmd = pmds[i];
25968 + for (addr = i = 0; i < PREALLOCATED_PXDS;
25969 + i++, pyd++, addr += PYD_SIZE) {
25970 + pxd_t *pxd = pxds[i];
25971
25972 if (i >= KERNEL_PGD_BOUNDARY)
25973 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
25974 - sizeof(pmd_t) * PTRS_PER_PMD);
25975 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
25976 + sizeof(pxd_t) * PTRS_PER_PMD);
25977
25978 - pud_populate(mm, pud, pmd);
25979 + pyd_populate(mm, pyd, pxd);
25980 }
25981 }
25982
25983 pgd_t *pgd_alloc(struct mm_struct *mm)
25984 {
25985 pgd_t *pgd;
25986 - pmd_t *pmds[PREALLOCATED_PMDS];
25987 + pxd_t *pxds[PREALLOCATED_PXDS];
25988
25989 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
25990
25991 @@ -265,11 +326,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
25992
25993 mm->pgd = pgd;
25994
25995 - if (preallocate_pmds(pmds) != 0)
25996 + if (preallocate_pxds(pxds) != 0)
25997 goto out_free_pgd;
25998
25999 if (paravirt_pgd_alloc(mm) != 0)
26000 - goto out_free_pmds;
26001 + goto out_free_pxds;
26002
26003 /*
26004 * Make sure that pre-populating the pmds is atomic with
26005 @@ -279,14 +340,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
26006 spin_lock(&pgd_lock);
26007
26008 pgd_ctor(mm, pgd);
26009 - pgd_prepopulate_pmd(mm, pgd, pmds);
26010 + pgd_prepopulate_pxd(mm, pgd, pxds);
26011
26012 spin_unlock(&pgd_lock);
26013
26014 return pgd;
26015
26016 -out_free_pmds:
26017 - free_pmds(pmds);
26018 +out_free_pxds:
26019 + free_pxds(pxds);
26020 out_free_pgd:
26021 free_page((unsigned long)pgd);
26022 out:
26023 @@ -295,7 +356,7 @@ out:
26024
26025 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
26026 {
26027 - pgd_mop_up_pmds(mm, pgd);
26028 + pgd_mop_up_pxds(mm, pgd);
26029 pgd_dtor(pgd);
26030 paravirt_pgd_free(mm, pgd);
26031 free_page((unsigned long)pgd);
26032 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
26033 index cac7184..09a39fa 100644
26034 --- a/arch/x86/mm/pgtable_32.c
26035 +++ b/arch/x86/mm/pgtable_32.c
26036 @@ -48,10 +48,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
26037 return;
26038 }
26039 pte = pte_offset_kernel(pmd, vaddr);
26040 +
26041 + pax_open_kernel();
26042 if (pte_val(pteval))
26043 set_pte_at(&init_mm, vaddr, pte, pteval);
26044 else
26045 pte_clear(&init_mm, vaddr, pte);
26046 + pax_close_kernel();
26047
26048 /*
26049 * It's enough to flush this one mapping.
26050 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
26051 index 410531d..0f16030 100644
26052 --- a/arch/x86/mm/setup_nx.c
26053 +++ b/arch/x86/mm/setup_nx.c
26054 @@ -5,8 +5,10 @@
26055 #include <asm/pgtable.h>
26056 #include <asm/proto.h>
26057
26058 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
26059 static int disable_nx __cpuinitdata;
26060
26061 +#ifndef CONFIG_PAX_PAGEEXEC
26062 /*
26063 * noexec = on|off
26064 *
26065 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
26066 return 0;
26067 }
26068 early_param("noexec", noexec_setup);
26069 +#endif
26070 +
26071 +#endif
26072
26073 void __cpuinit x86_configure_nx(void)
26074 {
26075 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
26076 if (cpu_has_nx && !disable_nx)
26077 __supported_pte_mask |= _PAGE_NX;
26078 else
26079 +#endif
26080 __supported_pte_mask &= ~_PAGE_NX;
26081 }
26082
26083 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
26084 index d6c0418..06a0ad5 100644
26085 --- a/arch/x86/mm/tlb.c
26086 +++ b/arch/x86/mm/tlb.c
26087 @@ -65,7 +65,11 @@ void leave_mm(int cpu)
26088 BUG();
26089 cpumask_clear_cpu(cpu,
26090 mm_cpumask(percpu_read(cpu_tlbstate.active_mm)));
26091 +
26092 +#ifndef CONFIG_PAX_PER_CPU_PGD
26093 load_cr3(swapper_pg_dir);
26094 +#endif
26095 +
26096 }
26097 EXPORT_SYMBOL_GPL(leave_mm);
26098
26099 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
26100 index 6687022..ceabcfa 100644
26101 --- a/arch/x86/net/bpf_jit.S
26102 +++ b/arch/x86/net/bpf_jit.S
26103 @@ -9,6 +9,7 @@
26104 */
26105 #include <linux/linkage.h>
26106 #include <asm/dwarf2.h>
26107 +#include <asm/alternative-asm.h>
26108
26109 /*
26110 * Calling convention :
26111 @@ -35,6 +36,7 @@ sk_load_word:
26112 jle bpf_slow_path_word
26113 mov (SKBDATA,%rsi),%eax
26114 bswap %eax /* ntohl() */
26115 + pax_force_retaddr
26116 ret
26117
26118
26119 @@ -53,6 +55,7 @@ sk_load_half:
26120 jle bpf_slow_path_half
26121 movzwl (SKBDATA,%rsi),%eax
26122 rol $8,%ax # ntohs()
26123 + pax_force_retaddr
26124 ret
26125
26126 sk_load_byte_ind:
26127 @@ -66,6 +69,7 @@ sk_load_byte:
26128 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
26129 jle bpf_slow_path_byte
26130 movzbl (SKBDATA,%rsi),%eax
26131 + pax_force_retaddr
26132 ret
26133
26134 /**
26135 @@ -82,6 +86,7 @@ ENTRY(sk_load_byte_msh)
26136 movzbl (SKBDATA,%rsi),%ebx
26137 and $15,%bl
26138 shl $2,%bl
26139 + pax_force_retaddr
26140 ret
26141 CFI_ENDPROC
26142 ENDPROC(sk_load_byte_msh)
26143 @@ -91,6 +96,7 @@ bpf_error:
26144 xor %eax,%eax
26145 mov -8(%rbp),%rbx
26146 leaveq
26147 + pax_force_retaddr
26148 ret
26149
26150 /* rsi contains offset and can be scratched */
26151 @@ -113,6 +119,7 @@ bpf_slow_path_word:
26152 js bpf_error
26153 mov -12(%rbp),%eax
26154 bswap %eax
26155 + pax_force_retaddr
26156 ret
26157
26158 bpf_slow_path_half:
26159 @@ -121,12 +128,14 @@ bpf_slow_path_half:
26160 mov -12(%rbp),%ax
26161 rol $8,%ax
26162 movzwl %ax,%eax
26163 + pax_force_retaddr
26164 ret
26165
26166 bpf_slow_path_byte:
26167 bpf_slow_path_common(1)
26168 js bpf_error
26169 movzbl -12(%rbp),%eax
26170 + pax_force_retaddr
26171 ret
26172
26173 bpf_slow_path_byte_msh:
26174 @@ -137,4 +146,5 @@ bpf_slow_path_byte_msh:
26175 and $15,%al
26176 shl $2,%al
26177 xchg %eax,%ebx
26178 + pax_force_retaddr
26179 ret
26180 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
26181 index 5a5b6e4..201d42e 100644
26182 --- a/arch/x86/net/bpf_jit_comp.c
26183 +++ b/arch/x86/net/bpf_jit_comp.c
26184 @@ -117,6 +117,10 @@ static inline void bpf_flush_icache(void *start, void *end)
26185 set_fs(old_fs);
26186 }
26187
26188 +struct bpf_jit_work {
26189 + struct work_struct work;
26190 + void *image;
26191 +};
26192
26193 void bpf_jit_compile(struct sk_filter *fp)
26194 {
26195 @@ -141,6 +145,10 @@ void bpf_jit_compile(struct sk_filter *fp)
26196 if (addrs == NULL)
26197 return;
26198
26199 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
26200 + if (!fp->work)
26201 + goto out;
26202 +
26203 /* Before first pass, make a rough estimation of addrs[]
26204 * each bpf instruction is translated to less than 64 bytes
26205 */
26206 @@ -477,7 +485,7 @@ void bpf_jit_compile(struct sk_filter *fp)
26207 common_load: seen |= SEEN_DATAREF;
26208 if ((int)K < 0) {
26209 /* Abort the JIT because __load_pointer() is needed. */
26210 - goto out;
26211 + goto error;
26212 }
26213 t_offset = func - (image + addrs[i]);
26214 EMIT1_off32(0xbe, K); /* mov imm32,%esi */
26215 @@ -492,7 +500,7 @@ common_load: seen |= SEEN_DATAREF;
26216 case BPF_S_LDX_B_MSH:
26217 if ((int)K < 0) {
26218 /* Abort the JIT because __load_pointer() is needed. */
26219 - goto out;
26220 + goto error;
26221 }
26222 seen |= SEEN_DATAREF | SEEN_XREG;
26223 t_offset = sk_load_byte_msh - (image + addrs[i]);
26224 @@ -582,17 +590,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
26225 break;
26226 default:
26227 /* hmm, too complex filter, give up with jit compiler */
26228 - goto out;
26229 + goto error;
26230 }
26231 ilen = prog - temp;
26232 if (image) {
26233 if (unlikely(proglen + ilen > oldproglen)) {
26234 pr_err("bpb_jit_compile fatal error\n");
26235 - kfree(addrs);
26236 - module_free(NULL, image);
26237 - return;
26238 + module_free_exec(NULL, image);
26239 + goto error;
26240 }
26241 + pax_open_kernel();
26242 memcpy(image + proglen, temp, ilen);
26243 + pax_close_kernel();
26244 }
26245 proglen += ilen;
26246 addrs[i] = proglen;
26247 @@ -613,11 +622,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
26248 break;
26249 }
26250 if (proglen == oldproglen) {
26251 - image = module_alloc(max_t(unsigned int,
26252 - proglen,
26253 - sizeof(struct work_struct)));
26254 + image = module_alloc_exec(proglen);
26255 if (!image)
26256 - goto out;
26257 + goto error;
26258 }
26259 oldproglen = proglen;
26260 }
26261 @@ -633,7 +640,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
26262 bpf_flush_icache(image, image + proglen);
26263
26264 fp->bpf_func = (void *)image;
26265 - }
26266 + } else
26267 +error:
26268 + kfree(fp->work);
26269 +
26270 out:
26271 kfree(addrs);
26272 return;
26273 @@ -641,18 +651,20 @@ out:
26274
26275 static void jit_free_defer(struct work_struct *arg)
26276 {
26277 - module_free(NULL, arg);
26278 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
26279 + kfree(arg);
26280 }
26281
26282 /* run from softirq, we must use a work_struct to call
26283 - * module_free() from process context
26284 + * module_free_exec() from process context
26285 */
26286 void bpf_jit_free(struct sk_filter *fp)
26287 {
26288 if (fp->bpf_func != sk_run_filter) {
26289 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
26290 + struct work_struct *work = &fp->work->work;
26291
26292 INIT_WORK(work, jit_free_defer);
26293 + fp->work->image = fp->bpf_func;
26294 schedule_work(work);
26295 }
26296 }
26297 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
26298 index bff89df..377758a 100644
26299 --- a/arch/x86/oprofile/backtrace.c
26300 +++ b/arch/x86/oprofile/backtrace.c
26301 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
26302 struct stack_frame_ia32 *fp;
26303 unsigned long bytes;
26304
26305 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
26306 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
26307 if (bytes != sizeof(bufhead))
26308 return NULL;
26309
26310 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
26311 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
26312
26313 oprofile_add_trace(bufhead[0].return_address);
26314
26315 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
26316 struct stack_frame bufhead[2];
26317 unsigned long bytes;
26318
26319 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
26320 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
26321 if (bytes != sizeof(bufhead))
26322 return NULL;
26323
26324 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
26325 {
26326 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
26327
26328 - if (!user_mode_vm(regs)) {
26329 + if (!user_mode(regs)) {
26330 unsigned long stack = kernel_stack_pointer(regs);
26331 if (depth)
26332 dump_trace(NULL, regs, (unsigned long *)stack, 0,
26333 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
26334 index cb29191..036766d 100644
26335 --- a/arch/x86/pci/mrst.c
26336 +++ b/arch/x86/pci/mrst.c
26337 @@ -234,7 +234,9 @@ int __init pci_mrst_init(void)
26338 printk(KERN_INFO "Moorestown platform detected, using MRST PCI ops\n");
26339 pci_mmcfg_late_init();
26340 pcibios_enable_irq = mrst_pci_irq_enable;
26341 - pci_root_ops = pci_mrst_ops;
26342 + pax_open_kernel();
26343 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
26344 + pax_close_kernel();
26345 /* Continue with standard init */
26346 return 1;
26347 }
26348 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
26349 index da8fe05..7ee6704 100644
26350 --- a/arch/x86/pci/pcbios.c
26351 +++ b/arch/x86/pci/pcbios.c
26352 @@ -79,50 +79,93 @@ union bios32 {
26353 static struct {
26354 unsigned long address;
26355 unsigned short segment;
26356 -} bios32_indirect = { 0, __KERNEL_CS };
26357 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
26358
26359 /*
26360 * Returns the entry point for the given service, NULL on error
26361 */
26362
26363 -static unsigned long bios32_service(unsigned long service)
26364 +static unsigned long __devinit bios32_service(unsigned long service)
26365 {
26366 unsigned char return_code; /* %al */
26367 unsigned long address; /* %ebx */
26368 unsigned long length; /* %ecx */
26369 unsigned long entry; /* %edx */
26370 unsigned long flags;
26371 + struct desc_struct d, *gdt;
26372
26373 local_irq_save(flags);
26374 - __asm__("lcall *(%%edi); cld"
26375 +
26376 + gdt = get_cpu_gdt_table(smp_processor_id());
26377 +
26378 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
26379 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
26380 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
26381 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
26382 +
26383 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
26384 : "=a" (return_code),
26385 "=b" (address),
26386 "=c" (length),
26387 "=d" (entry)
26388 : "0" (service),
26389 "1" (0),
26390 - "D" (&bios32_indirect));
26391 + "D" (&bios32_indirect),
26392 + "r"(__PCIBIOS_DS)
26393 + : "memory");
26394 +
26395 + pax_open_kernel();
26396 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
26397 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
26398 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
26399 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
26400 + pax_close_kernel();
26401 +
26402 local_irq_restore(flags);
26403
26404 switch (return_code) {
26405 - case 0:
26406 - return address + entry;
26407 - case 0x80: /* Not present */
26408 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
26409 - return 0;
26410 - default: /* Shouldn't happen */
26411 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
26412 - service, return_code);
26413 + case 0: {
26414 + int cpu;
26415 + unsigned char flags;
26416 +
26417 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
26418 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
26419 + printk(KERN_WARNING "bios32_service: not valid\n");
26420 return 0;
26421 + }
26422 + address = address + PAGE_OFFSET;
26423 + length += 16UL; /* some BIOSs underreport this... */
26424 + flags = 4;
26425 + if (length >= 64*1024*1024) {
26426 + length >>= PAGE_SHIFT;
26427 + flags |= 8;
26428 + }
26429 +
26430 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
26431 + gdt = get_cpu_gdt_table(cpu);
26432 + pack_descriptor(&d, address, length, 0x9b, flags);
26433 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
26434 + pack_descriptor(&d, address, length, 0x93, flags);
26435 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
26436 + }
26437 + return entry;
26438 + }
26439 + case 0x80: /* Not present */
26440 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
26441 + return 0;
26442 + default: /* Shouldn't happen */
26443 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
26444 + service, return_code);
26445 + return 0;
26446 }
26447 }
26448
26449 static struct {
26450 unsigned long address;
26451 unsigned short segment;
26452 -} pci_indirect = { 0, __KERNEL_CS };
26453 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
26454
26455 -static int pci_bios_present;
26456 +static int pci_bios_present __read_only;
26457
26458 static int __devinit check_pcibios(void)
26459 {
26460 @@ -131,11 +174,13 @@ static int __devinit check_pcibios(void)
26461 unsigned long flags, pcibios_entry;
26462
26463 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
26464 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
26465 + pci_indirect.address = pcibios_entry;
26466
26467 local_irq_save(flags);
26468 - __asm__(
26469 - "lcall *(%%edi); cld\n\t"
26470 + __asm__("movw %w6, %%ds\n\t"
26471 + "lcall *%%ss:(%%edi); cld\n\t"
26472 + "push %%ss\n\t"
26473 + "pop %%ds\n\t"
26474 "jc 1f\n\t"
26475 "xor %%ah, %%ah\n"
26476 "1:"
26477 @@ -144,7 +189,8 @@ static int __devinit check_pcibios(void)
26478 "=b" (ebx),
26479 "=c" (ecx)
26480 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
26481 - "D" (&pci_indirect)
26482 + "D" (&pci_indirect),
26483 + "r" (__PCIBIOS_DS)
26484 : "memory");
26485 local_irq_restore(flags);
26486
26487 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
26488
26489 switch (len) {
26490 case 1:
26491 - __asm__("lcall *(%%esi); cld\n\t"
26492 + __asm__("movw %w6, %%ds\n\t"
26493 + "lcall *%%ss:(%%esi); cld\n\t"
26494 + "push %%ss\n\t"
26495 + "pop %%ds\n\t"
26496 "jc 1f\n\t"
26497 "xor %%ah, %%ah\n"
26498 "1:"
26499 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
26500 : "1" (PCIBIOS_READ_CONFIG_BYTE),
26501 "b" (bx),
26502 "D" ((long)reg),
26503 - "S" (&pci_indirect));
26504 + "S" (&pci_indirect),
26505 + "r" (__PCIBIOS_DS));
26506 /*
26507 * Zero-extend the result beyond 8 bits, do not trust the
26508 * BIOS having done it:
26509 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
26510 *value &= 0xff;
26511 break;
26512 case 2:
26513 - __asm__("lcall *(%%esi); cld\n\t"
26514 + __asm__("movw %w6, %%ds\n\t"
26515 + "lcall *%%ss:(%%esi); cld\n\t"
26516 + "push %%ss\n\t"
26517 + "pop %%ds\n\t"
26518 "jc 1f\n\t"
26519 "xor %%ah, %%ah\n"
26520 "1:"
26521 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
26522 : "1" (PCIBIOS_READ_CONFIG_WORD),
26523 "b" (bx),
26524 "D" ((long)reg),
26525 - "S" (&pci_indirect));
26526 + "S" (&pci_indirect),
26527 + "r" (__PCIBIOS_DS));
26528 /*
26529 * Zero-extend the result beyond 16 bits, do not trust the
26530 * BIOS having done it:
26531 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
26532 *value &= 0xffff;
26533 break;
26534 case 4:
26535 - __asm__("lcall *(%%esi); cld\n\t"
26536 + __asm__("movw %w6, %%ds\n\t"
26537 + "lcall *%%ss:(%%esi); cld\n\t"
26538 + "push %%ss\n\t"
26539 + "pop %%ds\n\t"
26540 "jc 1f\n\t"
26541 "xor %%ah, %%ah\n"
26542 "1:"
26543 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
26544 : "1" (PCIBIOS_READ_CONFIG_DWORD),
26545 "b" (bx),
26546 "D" ((long)reg),
26547 - "S" (&pci_indirect));
26548 + "S" (&pci_indirect),
26549 + "r" (__PCIBIOS_DS));
26550 break;
26551 }
26552
26553 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
26554
26555 switch (len) {
26556 case 1:
26557 - __asm__("lcall *(%%esi); cld\n\t"
26558 + __asm__("movw %w6, %%ds\n\t"
26559 + "lcall *%%ss:(%%esi); cld\n\t"
26560 + "push %%ss\n\t"
26561 + "pop %%ds\n\t"
26562 "jc 1f\n\t"
26563 "xor %%ah, %%ah\n"
26564 "1:"
26565 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
26566 "c" (value),
26567 "b" (bx),
26568 "D" ((long)reg),
26569 - "S" (&pci_indirect));
26570 + "S" (&pci_indirect),
26571 + "r" (__PCIBIOS_DS));
26572 break;
26573 case 2:
26574 - __asm__("lcall *(%%esi); cld\n\t"
26575 + __asm__("movw %w6, %%ds\n\t"
26576 + "lcall *%%ss:(%%esi); cld\n\t"
26577 + "push %%ss\n\t"
26578 + "pop %%ds\n\t"
26579 "jc 1f\n\t"
26580 "xor %%ah, %%ah\n"
26581 "1:"
26582 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
26583 "c" (value),
26584 "b" (bx),
26585 "D" ((long)reg),
26586 - "S" (&pci_indirect));
26587 + "S" (&pci_indirect),
26588 + "r" (__PCIBIOS_DS));
26589 break;
26590 case 4:
26591 - __asm__("lcall *(%%esi); cld\n\t"
26592 + __asm__("movw %w6, %%ds\n\t"
26593 + "lcall *%%ss:(%%esi); cld\n\t"
26594 + "push %%ss\n\t"
26595 + "pop %%ds\n\t"
26596 "jc 1f\n\t"
26597 "xor %%ah, %%ah\n"
26598 "1:"
26599 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
26600 "c" (value),
26601 "b" (bx),
26602 "D" ((long)reg),
26603 - "S" (&pci_indirect));
26604 + "S" (&pci_indirect),
26605 + "r" (__PCIBIOS_DS));
26606 break;
26607 }
26608
26609 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
26610
26611 DBG("PCI: Fetching IRQ routing table... ");
26612 __asm__("push %%es\n\t"
26613 + "movw %w8, %%ds\n\t"
26614 "push %%ds\n\t"
26615 "pop %%es\n\t"
26616 - "lcall *(%%esi); cld\n\t"
26617 + "lcall *%%ss:(%%esi); cld\n\t"
26618 "pop %%es\n\t"
26619 + "push %%ss\n\t"
26620 + "pop %%ds\n"
26621 "jc 1f\n\t"
26622 "xor %%ah, %%ah\n"
26623 "1:"
26624 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
26625 "1" (0),
26626 "D" ((long) &opt),
26627 "S" (&pci_indirect),
26628 - "m" (opt)
26629 + "m" (opt),
26630 + "r" (__PCIBIOS_DS)
26631 : "memory");
26632 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
26633 if (ret & 0xff00)
26634 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
26635 {
26636 int ret;
26637
26638 - __asm__("lcall *(%%esi); cld\n\t"
26639 + __asm__("movw %w5, %%ds\n\t"
26640 + "lcall *%%ss:(%%esi); cld\n\t"
26641 + "push %%ss\n\t"
26642 + "pop %%ds\n"
26643 "jc 1f\n\t"
26644 "xor %%ah, %%ah\n"
26645 "1:"
26646 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
26647 : "0" (PCIBIOS_SET_PCI_HW_INT),
26648 "b" ((dev->bus->number << 8) | dev->devfn),
26649 "c" ((irq << 8) | (pin + 10)),
26650 - "S" (&pci_indirect));
26651 + "S" (&pci_indirect),
26652 + "r" (__PCIBIOS_DS));
26653 return !(ret & 0xff00);
26654 }
26655 EXPORT_SYMBOL(pcibios_set_irq_routing);
26656 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
26657 index 40e4469..1ab536e 100644
26658 --- a/arch/x86/platform/efi/efi_32.c
26659 +++ b/arch/x86/platform/efi/efi_32.c
26660 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
26661 {
26662 struct desc_ptr gdt_descr;
26663
26664 +#ifdef CONFIG_PAX_KERNEXEC
26665 + struct desc_struct d;
26666 +#endif
26667 +
26668 local_irq_save(efi_rt_eflags);
26669
26670 load_cr3(initial_page_table);
26671 __flush_tlb_all();
26672
26673 +#ifdef CONFIG_PAX_KERNEXEC
26674 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
26675 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
26676 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
26677 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
26678 +#endif
26679 +
26680 gdt_descr.address = __pa(get_cpu_gdt_table(0));
26681 gdt_descr.size = GDT_SIZE - 1;
26682 load_gdt(&gdt_descr);
26683 @@ -58,6 +69,14 @@ void efi_call_phys_epilog(void)
26684 {
26685 struct desc_ptr gdt_descr;
26686
26687 +#ifdef CONFIG_PAX_KERNEXEC
26688 + struct desc_struct d;
26689 +
26690 + memset(&d, 0, sizeof d);
26691 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
26692 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
26693 +#endif
26694 +
26695 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
26696 gdt_descr.size = GDT_SIZE - 1;
26697 load_gdt(&gdt_descr);
26698 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
26699 index fbe66e6..c5c0dd2 100644
26700 --- a/arch/x86/platform/efi/efi_stub_32.S
26701 +++ b/arch/x86/platform/efi/efi_stub_32.S
26702 @@ -6,7 +6,9 @@
26703 */
26704
26705 #include <linux/linkage.h>
26706 +#include <linux/init.h>
26707 #include <asm/page_types.h>
26708 +#include <asm/segment.h>
26709
26710 /*
26711 * efi_call_phys(void *, ...) is a function with variable parameters.
26712 @@ -20,7 +22,7 @@
26713 * service functions will comply with gcc calling convention, too.
26714 */
26715
26716 -.text
26717 +__INIT
26718 ENTRY(efi_call_phys)
26719 /*
26720 * 0. The function can only be called in Linux kernel. So CS has been
26721 @@ -36,9 +38,11 @@ ENTRY(efi_call_phys)
26722 * The mapping of lower virtual memory has been created in prelog and
26723 * epilog.
26724 */
26725 - movl $1f, %edx
26726 - subl $__PAGE_OFFSET, %edx
26727 - jmp *%edx
26728 + movl $(__KERNEXEC_EFI_DS), %edx
26729 + mov %edx, %ds
26730 + mov %edx, %es
26731 + mov %edx, %ss
26732 + ljmp $(__KERNEXEC_EFI_CS),$1f-__PAGE_OFFSET
26733 1:
26734
26735 /*
26736 @@ -47,14 +51,8 @@ ENTRY(efi_call_phys)
26737 * parameter 2, ..., param n. To make things easy, we save the return
26738 * address of efi_call_phys in a global variable.
26739 */
26740 - popl %edx
26741 - movl %edx, saved_return_addr
26742 - /* get the function pointer into ECX*/
26743 - popl %ecx
26744 - movl %ecx, efi_rt_function_ptr
26745 - movl $2f, %edx
26746 - subl $__PAGE_OFFSET, %edx
26747 - pushl %edx
26748 + popl (saved_return_addr)
26749 + popl (efi_rt_function_ptr)
26750
26751 /*
26752 * 3. Clear PG bit in %CR0.
26753 @@ -73,9 +71,8 @@ ENTRY(efi_call_phys)
26754 /*
26755 * 5. Call the physical function.
26756 */
26757 - jmp *%ecx
26758 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
26759
26760 -2:
26761 /*
26762 * 6. After EFI runtime service returns, control will return to
26763 * following instruction. We'd better readjust stack pointer first.
26764 @@ -88,35 +85,32 @@ ENTRY(efi_call_phys)
26765 movl %cr0, %edx
26766 orl $0x80000000, %edx
26767 movl %edx, %cr0
26768 - jmp 1f
26769 -1:
26770 +
26771 /*
26772 * 8. Now restore the virtual mode from flat mode by
26773 * adding EIP with PAGE_OFFSET.
26774 */
26775 - movl $1f, %edx
26776 - jmp *%edx
26777 + ljmp $(__KERNEL_CS),$1f+__PAGE_OFFSET
26778 1:
26779 + movl $(__KERNEL_DS), %edx
26780 + mov %edx, %ds
26781 + mov %edx, %es
26782 + mov %edx, %ss
26783
26784 /*
26785 * 9. Balance the stack. And because EAX contain the return value,
26786 * we'd better not clobber it.
26787 */
26788 - leal efi_rt_function_ptr, %edx
26789 - movl (%edx), %ecx
26790 - pushl %ecx
26791 + pushl (efi_rt_function_ptr)
26792
26793 /*
26794 - * 10. Push the saved return address onto the stack and return.
26795 + * 10. Return to the saved return address.
26796 */
26797 - leal saved_return_addr, %edx
26798 - movl (%edx), %ecx
26799 - pushl %ecx
26800 - ret
26801 + jmpl *(saved_return_addr)
26802 ENDPROC(efi_call_phys)
26803 .previous
26804
26805 -.data
26806 +__INITDATA
26807 saved_return_addr:
26808 .long 0
26809 efi_rt_function_ptr:
26810 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
26811 index 4c07cca..2c8427d 100644
26812 --- a/arch/x86/platform/efi/efi_stub_64.S
26813 +++ b/arch/x86/platform/efi/efi_stub_64.S
26814 @@ -7,6 +7,7 @@
26815 */
26816
26817 #include <linux/linkage.h>
26818 +#include <asm/alternative-asm.h>
26819
26820 #define SAVE_XMM \
26821 mov %rsp, %rax; \
26822 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
26823 call *%rdi
26824 addq $32, %rsp
26825 RESTORE_XMM
26826 + pax_force_retaddr 0, 1
26827 ret
26828 ENDPROC(efi_call0)
26829
26830 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
26831 call *%rdi
26832 addq $32, %rsp
26833 RESTORE_XMM
26834 + pax_force_retaddr 0, 1
26835 ret
26836 ENDPROC(efi_call1)
26837
26838 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
26839 call *%rdi
26840 addq $32, %rsp
26841 RESTORE_XMM
26842 + pax_force_retaddr 0, 1
26843 ret
26844 ENDPROC(efi_call2)
26845
26846 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
26847 call *%rdi
26848 addq $32, %rsp
26849 RESTORE_XMM
26850 + pax_force_retaddr 0, 1
26851 ret
26852 ENDPROC(efi_call3)
26853
26854 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
26855 call *%rdi
26856 addq $32, %rsp
26857 RESTORE_XMM
26858 + pax_force_retaddr 0, 1
26859 ret
26860 ENDPROC(efi_call4)
26861
26862 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
26863 call *%rdi
26864 addq $48, %rsp
26865 RESTORE_XMM
26866 + pax_force_retaddr 0, 1
26867 ret
26868 ENDPROC(efi_call5)
26869
26870 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
26871 call *%rdi
26872 addq $48, %rsp
26873 RESTORE_XMM
26874 + pax_force_retaddr 0, 1
26875 ret
26876 ENDPROC(efi_call6)
26877 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
26878 index 475e2cd..1b8e708 100644
26879 --- a/arch/x86/platform/mrst/mrst.c
26880 +++ b/arch/x86/platform/mrst/mrst.c
26881 @@ -76,18 +76,20 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
26882 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
26883 int sfi_mrtc_num;
26884
26885 -static void mrst_power_off(void)
26886 +static __noreturn void mrst_power_off(void)
26887 {
26888 if (__mrst_cpu_chip == MRST_CPU_CHIP_LINCROFT)
26889 intel_scu_ipc_simple_command(IPCMSG_COLD_RESET, 1);
26890 + BUG();
26891 }
26892
26893 -static void mrst_reboot(void)
26894 +static __noreturn void mrst_reboot(void)
26895 {
26896 if (__mrst_cpu_chip == MRST_CPU_CHIP_LINCROFT)
26897 intel_scu_ipc_simple_command(IPCMSG_COLD_RESET, 0);
26898 else
26899 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
26900 + BUG();
26901 }
26902
26903 /* parse all the mtimer info to a static mtimer array */
26904 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
26905 index f10c0af..3ec1f95 100644
26906 --- a/arch/x86/power/cpu.c
26907 +++ b/arch/x86/power/cpu.c
26908 @@ -131,7 +131,7 @@ static void do_fpu_end(void)
26909 static void fix_processor_context(void)
26910 {
26911 int cpu = smp_processor_id();
26912 - struct tss_struct *t = &per_cpu(init_tss, cpu);
26913 + struct tss_struct *t = init_tss + cpu;
26914
26915 set_tss_desc(cpu, t); /*
26916 * This just modifies memory; should not be
26917 @@ -141,7 +141,9 @@ static void fix_processor_context(void)
26918 */
26919
26920 #ifdef CONFIG_X86_64
26921 + pax_open_kernel();
26922 get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9;
26923 + pax_close_kernel();
26924
26925 syscall_init(); /* This sets MSR_*STAR and related */
26926 #endif
26927 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
26928 index 5d17950..2253fc9 100644
26929 --- a/arch/x86/vdso/Makefile
26930 +++ b/arch/x86/vdso/Makefile
26931 @@ -137,7 +137,7 @@ quiet_cmd_vdso = VDSO $@
26932 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
26933 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
26934
26935 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
26936 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
26937 GCOV_PROFILE := n
26938
26939 #
26940 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
26941 index 468d591..8e80a0a 100644
26942 --- a/arch/x86/vdso/vdso32-setup.c
26943 +++ b/arch/x86/vdso/vdso32-setup.c
26944 @@ -25,6 +25,7 @@
26945 #include <asm/tlbflush.h>
26946 #include <asm/vdso.h>
26947 #include <asm/proto.h>
26948 +#include <asm/mman.h>
26949
26950 enum {
26951 VDSO_DISABLED = 0,
26952 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
26953 void enable_sep_cpu(void)
26954 {
26955 int cpu = get_cpu();
26956 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
26957 + struct tss_struct *tss = init_tss + cpu;
26958
26959 if (!boot_cpu_has(X86_FEATURE_SEP)) {
26960 put_cpu();
26961 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
26962 gate_vma.vm_start = FIXADDR_USER_START;
26963 gate_vma.vm_end = FIXADDR_USER_END;
26964 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
26965 - gate_vma.vm_page_prot = __P101;
26966 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
26967 /*
26968 * Make sure the vDSO gets into every core dump.
26969 * Dumping its contents makes post-mortem fully interpretable later
26970 @@ -331,14 +332,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
26971 if (compat)
26972 addr = VDSO_HIGH_BASE;
26973 else {
26974 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
26975 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
26976 if (IS_ERR_VALUE(addr)) {
26977 ret = addr;
26978 goto up_fail;
26979 }
26980 }
26981
26982 - current->mm->context.vdso = (void *)addr;
26983 + current->mm->context.vdso = addr;
26984
26985 if (compat_uses_vma || !compat) {
26986 /*
26987 @@ -361,11 +362,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
26988 }
26989
26990 current_thread_info()->sysenter_return =
26991 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
26992 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
26993
26994 up_fail:
26995 if (ret)
26996 - current->mm->context.vdso = NULL;
26997 + current->mm->context.vdso = 0;
26998
26999 up_write(&mm->mmap_sem);
27000
27001 @@ -412,8 +413,14 @@ __initcall(ia32_binfmt_init);
27002
27003 const char *arch_vma_name(struct vm_area_struct *vma)
27004 {
27005 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
27006 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
27007 return "[vdso]";
27008 +
27009 +#ifdef CONFIG_PAX_SEGMEXEC
27010 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
27011 + return "[vdso]";
27012 +#endif
27013 +
27014 return NULL;
27015 }
27016
27017 @@ -423,7 +430,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
27018 * Check to see if the corresponding task was created in compat vdso
27019 * mode.
27020 */
27021 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
27022 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
27023 return &gate_vma;
27024 return NULL;
27025 }
27026 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
27027 index 153407c..611cba9 100644
27028 --- a/arch/x86/vdso/vma.c
27029 +++ b/arch/x86/vdso/vma.c
27030 @@ -16,8 +16,6 @@
27031 #include <asm/vdso.h>
27032 #include <asm/page.h>
27033
27034 -unsigned int __read_mostly vdso_enabled = 1;
27035 -
27036 extern char vdso_start[], vdso_end[];
27037 extern unsigned short vdso_sync_cpuid;
27038
27039 @@ -96,7 +94,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
27040 * unaligned here as a result of stack start randomization.
27041 */
27042 addr = PAGE_ALIGN(addr);
27043 - addr = align_addr(addr, NULL, ALIGN_VDSO);
27044
27045 return addr;
27046 }
27047 @@ -106,40 +103,35 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
27048 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
27049 {
27050 struct mm_struct *mm = current->mm;
27051 - unsigned long addr;
27052 + unsigned long addr = 0;
27053 int ret;
27054
27055 - if (!vdso_enabled)
27056 - return 0;
27057 -
27058 down_write(&mm->mmap_sem);
27059 +
27060 +#ifdef CONFIG_PAX_RANDMMAP
27061 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
27062 +#endif
27063 +
27064 addr = vdso_addr(mm->start_stack, vdso_size);
27065 + addr = align_addr(addr, NULL, ALIGN_VDSO);
27066 addr = get_unmapped_area(NULL, addr, vdso_size, 0, 0);
27067 if (IS_ERR_VALUE(addr)) {
27068 ret = addr;
27069 goto up_fail;
27070 }
27071
27072 - current->mm->context.vdso = (void *)addr;
27073 + mm->context.vdso = addr;
27074
27075 ret = install_special_mapping(mm, addr, vdso_size,
27076 VM_READ|VM_EXEC|
27077 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC|
27078 VM_ALWAYSDUMP,
27079 vdso_pages);
27080 - if (ret) {
27081 - current->mm->context.vdso = NULL;
27082 - goto up_fail;
27083 - }
27084 +
27085 + if (ret)
27086 + mm->context.vdso = 0;
27087
27088 up_fail:
27089 up_write(&mm->mmap_sem);
27090 return ret;
27091 }
27092 -
27093 -static __init int vdso_setup(char *s)
27094 -{
27095 - vdso_enabled = simple_strtoul(s, NULL, 0);
27096 - return 0;
27097 -}
27098 -__setup("vdso=", vdso_setup);
27099 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
27100 index 4e517d4..68a48f5 100644
27101 --- a/arch/x86/xen/enlighten.c
27102 +++ b/arch/x86/xen/enlighten.c
27103 @@ -86,8 +86,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
27104
27105 struct shared_info xen_dummy_shared_info;
27106
27107 -void *xen_initial_gdt;
27108 -
27109 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
27110 __read_mostly int xen_have_vector_callback;
27111 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
27112 @@ -1030,30 +1028,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
27113 #endif
27114 };
27115
27116 -static void xen_reboot(int reason)
27117 +static __noreturn void xen_reboot(int reason)
27118 {
27119 struct sched_shutdown r = { .reason = reason };
27120
27121 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
27122 - BUG();
27123 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
27124 + BUG();
27125 }
27126
27127 -static void xen_restart(char *msg)
27128 +static __noreturn void xen_restart(char *msg)
27129 {
27130 xen_reboot(SHUTDOWN_reboot);
27131 }
27132
27133 -static void xen_emergency_restart(void)
27134 +static __noreturn void xen_emergency_restart(void)
27135 {
27136 xen_reboot(SHUTDOWN_reboot);
27137 }
27138
27139 -static void xen_machine_halt(void)
27140 +static __noreturn void xen_machine_halt(void)
27141 {
27142 xen_reboot(SHUTDOWN_poweroff);
27143 }
27144
27145 -static void xen_machine_power_off(void)
27146 +static __noreturn void xen_machine_power_off(void)
27147 {
27148 if (pm_power_off)
27149 pm_power_off();
27150 @@ -1156,7 +1154,17 @@ asmlinkage void __init xen_start_kernel(void)
27151 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
27152
27153 /* Work out if we support NX */
27154 - x86_configure_nx();
27155 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
27156 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
27157 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
27158 + unsigned l, h;
27159 +
27160 + __supported_pte_mask |= _PAGE_NX;
27161 + rdmsr(MSR_EFER, l, h);
27162 + l |= EFER_NX;
27163 + wrmsr(MSR_EFER, l, h);
27164 + }
27165 +#endif
27166
27167 xen_setup_features();
27168
27169 @@ -1187,13 +1195,6 @@ asmlinkage void __init xen_start_kernel(void)
27170
27171 machine_ops = xen_machine_ops;
27172
27173 - /*
27174 - * The only reliable way to retain the initial address of the
27175 - * percpu gdt_page is to remember it here, so we can go and
27176 - * mark it RW later, when the initial percpu area is freed.
27177 - */
27178 - xen_initial_gdt = &per_cpu(gdt_page, 0);
27179 -
27180 xen_smp_init();
27181
27182 #ifdef CONFIG_ACPI_NUMA
27183 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
27184 index dc19347..1b07a2c 100644
27185 --- a/arch/x86/xen/mmu.c
27186 +++ b/arch/x86/xen/mmu.c
27187 @@ -1738,6 +1738,9 @@ pgd_t * __init xen_setup_kernel_pagetable(pgd_t *pgd,
27188 convert_pfn_mfn(init_level4_pgt);
27189 convert_pfn_mfn(level3_ident_pgt);
27190 convert_pfn_mfn(level3_kernel_pgt);
27191 + convert_pfn_mfn(level3_vmalloc_start_pgt);
27192 + convert_pfn_mfn(level3_vmalloc_end_pgt);
27193 + convert_pfn_mfn(level3_vmemmap_pgt);
27194
27195 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
27196 l2 = m2v(l3[pud_index(__START_KERNEL_map)].pud);
27197 @@ -1756,7 +1759,11 @@ pgd_t * __init xen_setup_kernel_pagetable(pgd_t *pgd,
27198 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
27199 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
27200 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
27201 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
27202 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
27203 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
27204 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
27205 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
27206 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
27207 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
27208
27209 @@ -1963,6 +1970,7 @@ static void __init xen_post_allocator_init(void)
27210 pv_mmu_ops.set_pud = xen_set_pud;
27211 #if PAGETABLE_LEVELS == 4
27212 pv_mmu_ops.set_pgd = xen_set_pgd;
27213 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
27214 #endif
27215
27216 /* This will work as long as patching hasn't happened yet
27217 @@ -2044,6 +2052,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
27218 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
27219 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
27220 .set_pgd = xen_set_pgd_hyper,
27221 + .set_pgd_batched = xen_set_pgd_hyper,
27222
27223 .alloc_pud = xen_alloc_pmd_init,
27224 .release_pud = xen_release_pmd_init,
27225 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
27226 index f2ce60a..14e08dc 100644
27227 --- a/arch/x86/xen/smp.c
27228 +++ b/arch/x86/xen/smp.c
27229 @@ -209,11 +209,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
27230 {
27231 BUG_ON(smp_processor_id() != 0);
27232 native_smp_prepare_boot_cpu();
27233 -
27234 - /* We've switched to the "real" per-cpu gdt, so make sure the
27235 - old memory can be recycled */
27236 - make_lowmem_page_readwrite(xen_initial_gdt);
27237 -
27238 xen_filter_cpu_maps();
27239 xen_setup_vcpu_info_placement();
27240 }
27241 @@ -290,12 +285,12 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
27242 gdt = get_cpu_gdt_table(cpu);
27243
27244 ctxt->flags = VGCF_IN_KERNEL;
27245 - ctxt->user_regs.ds = __USER_DS;
27246 - ctxt->user_regs.es = __USER_DS;
27247 + ctxt->user_regs.ds = __KERNEL_DS;
27248 + ctxt->user_regs.es = __KERNEL_DS;
27249 ctxt->user_regs.ss = __KERNEL_DS;
27250 #ifdef CONFIG_X86_32
27251 ctxt->user_regs.fs = __KERNEL_PERCPU;
27252 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
27253 + savesegment(gs, ctxt->user_regs.gs);
27254 #else
27255 ctxt->gs_base_kernel = per_cpu_offset(cpu);
27256 #endif
27257 @@ -346,13 +341,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu)
27258 int rc;
27259
27260 per_cpu(current_task, cpu) = idle;
27261 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
27262 #ifdef CONFIG_X86_32
27263 irq_ctx_init(cpu);
27264 #else
27265 clear_tsk_thread_flag(idle, TIF_FORK);
27266 - per_cpu(kernel_stack, cpu) =
27267 - (unsigned long)task_stack_page(idle) -
27268 - KERNEL_STACK_OFFSET + THREAD_SIZE;
27269 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
27270 #endif
27271 xen_setup_runstate_info(cpu);
27272 xen_setup_timer(cpu);
27273 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
27274 index b040b0e..8cc4fe0 100644
27275 --- a/arch/x86/xen/xen-asm_32.S
27276 +++ b/arch/x86/xen/xen-asm_32.S
27277 @@ -83,14 +83,14 @@ ENTRY(xen_iret)
27278 ESP_OFFSET=4 # bytes pushed onto stack
27279
27280 /*
27281 - * Store vcpu_info pointer for easy access. Do it this way to
27282 - * avoid having to reload %fs
27283 + * Store vcpu_info pointer for easy access.
27284 */
27285 #ifdef CONFIG_SMP
27286 - GET_THREAD_INFO(%eax)
27287 - movl TI_cpu(%eax), %eax
27288 - movl __per_cpu_offset(,%eax,4), %eax
27289 - mov xen_vcpu(%eax), %eax
27290 + push %fs
27291 + mov $(__KERNEL_PERCPU), %eax
27292 + mov %eax, %fs
27293 + mov PER_CPU_VAR(xen_vcpu), %eax
27294 + pop %fs
27295 #else
27296 movl xen_vcpu, %eax
27297 #endif
27298 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
27299 index aaa7291..3f77960 100644
27300 --- a/arch/x86/xen/xen-head.S
27301 +++ b/arch/x86/xen/xen-head.S
27302 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
27303 #ifdef CONFIG_X86_32
27304 mov %esi,xen_start_info
27305 mov $init_thread_union+THREAD_SIZE,%esp
27306 +#ifdef CONFIG_SMP
27307 + movl $cpu_gdt_table,%edi
27308 + movl $__per_cpu_load,%eax
27309 + movw %ax,__KERNEL_PERCPU + 2(%edi)
27310 + rorl $16,%eax
27311 + movb %al,__KERNEL_PERCPU + 4(%edi)
27312 + movb %ah,__KERNEL_PERCPU + 7(%edi)
27313 + movl $__per_cpu_end - 1,%eax
27314 + subl $__per_cpu_start,%eax
27315 + movw %ax,__KERNEL_PERCPU + 0(%edi)
27316 +#endif
27317 #else
27318 mov %rsi,xen_start_info
27319 mov $init_thread_union+THREAD_SIZE,%rsp
27320 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
27321 index b095739..8c17bcd 100644
27322 --- a/arch/x86/xen/xen-ops.h
27323 +++ b/arch/x86/xen/xen-ops.h
27324 @@ -10,8 +10,6 @@
27325 extern const char xen_hypervisor_callback[];
27326 extern const char xen_failsafe_callback[];
27327
27328 -extern void *xen_initial_gdt;
27329 -
27330 struct trap_info;
27331 void xen_copy_trap_info(struct trap_info *traps);
27332
27333 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
27334 index 525bd3d..ef888b1 100644
27335 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
27336 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
27337 @@ -119,9 +119,9 @@
27338 ----------------------------------------------------------------------*/
27339
27340 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
27341 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
27342 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
27343 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
27344 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
27345
27346 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
27347 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
27348 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
27349 index 2f33760..835e50a 100644
27350 --- a/arch/xtensa/variants/fsf/include/variant/core.h
27351 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
27352 @@ -11,6 +11,7 @@
27353 #ifndef _XTENSA_CORE_H
27354 #define _XTENSA_CORE_H
27355
27356 +#include <linux/const.h>
27357
27358 /****************************************************************************
27359 Parameters Useful for Any Code, USER or PRIVILEGED
27360 @@ -112,9 +113,9 @@
27361 ----------------------------------------------------------------------*/
27362
27363 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
27364 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
27365 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
27366 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
27367 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
27368
27369 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
27370 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
27371 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
27372 index af00795..2bb8105 100644
27373 --- a/arch/xtensa/variants/s6000/include/variant/core.h
27374 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
27375 @@ -11,6 +11,7 @@
27376 #ifndef _XTENSA_CORE_CONFIGURATION_H
27377 #define _XTENSA_CORE_CONFIGURATION_H
27378
27379 +#include <linux/const.h>
27380
27381 /****************************************************************************
27382 Parameters Useful for Any Code, USER or PRIVILEGED
27383 @@ -118,9 +119,9 @@
27384 ----------------------------------------------------------------------*/
27385
27386 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
27387 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
27388 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
27389 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
27390 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
27391
27392 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
27393 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
27394 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
27395 index 58916af..9cb880b 100644
27396 --- a/block/blk-iopoll.c
27397 +++ b/block/blk-iopoll.c
27398 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
27399 }
27400 EXPORT_SYMBOL(blk_iopoll_complete);
27401
27402 -static void blk_iopoll_softirq(struct softirq_action *h)
27403 +static void blk_iopoll_softirq(void)
27404 {
27405 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
27406 int rearm = 0, budget = blk_iopoll_budget;
27407 diff --git a/block/blk-map.c b/block/blk-map.c
27408 index 623e1cd..ca1e109 100644
27409 --- a/block/blk-map.c
27410 +++ b/block/blk-map.c
27411 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
27412 if (!len || !kbuf)
27413 return -EINVAL;
27414
27415 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
27416 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
27417 if (do_copy)
27418 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
27419 else
27420 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
27421 index 1366a89..e17f54b 100644
27422 --- a/block/blk-softirq.c
27423 +++ b/block/blk-softirq.c
27424 @@ -17,7 +17,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
27425 * Softirq action handler - move entries to local list and loop over them
27426 * while passing them to the queue registered handler.
27427 */
27428 -static void blk_done_softirq(struct softirq_action *h)
27429 +static void blk_done_softirq(void)
27430 {
27431 struct list_head *cpu_list, local_list;
27432
27433 diff --git a/block/bsg.c b/block/bsg.c
27434 index ff64ae3..593560c 100644
27435 --- a/block/bsg.c
27436 +++ b/block/bsg.c
27437 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
27438 struct sg_io_v4 *hdr, struct bsg_device *bd,
27439 fmode_t has_write_perm)
27440 {
27441 + unsigned char tmpcmd[sizeof(rq->__cmd)];
27442 + unsigned char *cmdptr;
27443 +
27444 if (hdr->request_len > BLK_MAX_CDB) {
27445 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
27446 if (!rq->cmd)
27447 return -ENOMEM;
27448 - }
27449 + cmdptr = rq->cmd;
27450 + } else
27451 + cmdptr = tmpcmd;
27452
27453 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
27454 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
27455 hdr->request_len))
27456 return -EFAULT;
27457
27458 + if (cmdptr != rq->cmd)
27459 + memcpy(rq->cmd, cmdptr, hdr->request_len);
27460 +
27461 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
27462 if (blk_verify_command(rq->cmd, has_write_perm))
27463 return -EPERM;
27464 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
27465 index 7c668c8..db3521c 100644
27466 --- a/block/compat_ioctl.c
27467 +++ b/block/compat_ioctl.c
27468 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
27469 err |= __get_user(f->spec1, &uf->spec1);
27470 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
27471 err |= __get_user(name, &uf->name);
27472 - f->name = compat_ptr(name);
27473 + f->name = (void __force_kernel *)compat_ptr(name);
27474 if (err) {
27475 err = -EFAULT;
27476 goto out;
27477 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
27478 index 6296b40..417c00f 100644
27479 --- a/block/partitions/efi.c
27480 +++ b/block/partitions/efi.c
27481 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
27482 if (!gpt)
27483 return NULL;
27484
27485 + if (!le32_to_cpu(gpt->num_partition_entries))
27486 + return NULL;
27487 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
27488 + if (!pte)
27489 + return NULL;
27490 +
27491 count = le32_to_cpu(gpt->num_partition_entries) *
27492 le32_to_cpu(gpt->sizeof_partition_entry);
27493 - if (!count)
27494 - return NULL;
27495 - pte = kzalloc(count, GFP_KERNEL);
27496 - if (!pte)
27497 - return NULL;
27498 -
27499 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
27500 (u8 *) pte,
27501 count) < count) {
27502 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
27503 index 260fa80..e8f3caf 100644
27504 --- a/block/scsi_ioctl.c
27505 +++ b/block/scsi_ioctl.c
27506 @@ -223,8 +223,20 @@ EXPORT_SYMBOL(blk_verify_command);
27507 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
27508 struct sg_io_hdr *hdr, fmode_t mode)
27509 {
27510 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
27511 + unsigned char tmpcmd[sizeof(rq->__cmd)];
27512 + unsigned char *cmdptr;
27513 +
27514 + if (rq->cmd != rq->__cmd)
27515 + cmdptr = rq->cmd;
27516 + else
27517 + cmdptr = tmpcmd;
27518 +
27519 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
27520 return -EFAULT;
27521 +
27522 + if (cmdptr != rq->cmd)
27523 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
27524 +
27525 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
27526 return -EPERM;
27527
27528 @@ -433,6 +445,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
27529 int err;
27530 unsigned int in_len, out_len, bytes, opcode, cmdlen;
27531 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
27532 + unsigned char tmpcmd[sizeof(rq->__cmd)];
27533 + unsigned char *cmdptr;
27534
27535 if (!sic)
27536 return -EINVAL;
27537 @@ -466,9 +480,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
27538 */
27539 err = -EFAULT;
27540 rq->cmd_len = cmdlen;
27541 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
27542 +
27543 + if (rq->cmd != rq->__cmd)
27544 + cmdptr = rq->cmd;
27545 + else
27546 + cmdptr = tmpcmd;
27547 +
27548 + if (copy_from_user(cmdptr, sic->data, cmdlen))
27549 goto error;
27550
27551 + if (rq->cmd != cmdptr)
27552 + memcpy(rq->cmd, cmdptr, cmdlen);
27553 +
27554 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
27555 goto error;
27556
27557 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
27558 index 671d4d6..5f24030 100644
27559 --- a/crypto/cryptd.c
27560 +++ b/crypto/cryptd.c
27561 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
27562
27563 struct cryptd_blkcipher_request_ctx {
27564 crypto_completion_t complete;
27565 -};
27566 +} __no_const;
27567
27568 struct cryptd_hash_ctx {
27569 struct crypto_shash *child;
27570 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
27571
27572 struct cryptd_aead_request_ctx {
27573 crypto_completion_t complete;
27574 -};
27575 +} __no_const;
27576
27577 static void cryptd_queue_worker(struct work_struct *work);
27578
27579 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
27580 index 5d41894..22021e4 100644
27581 --- a/drivers/acpi/apei/cper.c
27582 +++ b/drivers/acpi/apei/cper.c
27583 @@ -38,12 +38,12 @@
27584 */
27585 u64 cper_next_record_id(void)
27586 {
27587 - static atomic64_t seq;
27588 + static atomic64_unchecked_t seq;
27589
27590 - if (!atomic64_read(&seq))
27591 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
27592 + if (!atomic64_read_unchecked(&seq))
27593 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
27594
27595 - return atomic64_inc_return(&seq);
27596 + return atomic64_inc_return_unchecked(&seq);
27597 }
27598 EXPORT_SYMBOL_GPL(cper_next_record_id);
27599
27600 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
27601 index b258cab..3fb7da7 100644
27602 --- a/drivers/acpi/ec_sys.c
27603 +++ b/drivers/acpi/ec_sys.c
27604 @@ -12,6 +12,7 @@
27605 #include <linux/acpi.h>
27606 #include <linux/debugfs.h>
27607 #include <linux/module.h>
27608 +#include <linux/uaccess.h>
27609 #include "internal.h"
27610
27611 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
27612 @@ -40,7 +41,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
27613 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
27614 */
27615 unsigned int size = EC_SPACE_SIZE;
27616 - u8 *data = (u8 *) buf;
27617 + u8 data;
27618 loff_t init_off = *off;
27619 int err = 0;
27620
27621 @@ -53,9 +54,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
27622 size = count;
27623
27624 while (size) {
27625 - err = ec_read(*off, &data[*off - init_off]);
27626 + err = ec_read(*off, &data);
27627 if (err)
27628 return err;
27629 + if (put_user(data, &buf[*off - init_off]))
27630 + return -EFAULT;
27631 *off += 1;
27632 size--;
27633 }
27634 @@ -71,7 +74,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
27635
27636 unsigned int size = count;
27637 loff_t init_off = *off;
27638 - u8 *data = (u8 *) buf;
27639 int err = 0;
27640
27641 if (*off >= EC_SPACE_SIZE)
27642 @@ -82,7 +84,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
27643 }
27644
27645 while (size) {
27646 - u8 byte_write = data[*off - init_off];
27647 + u8 byte_write;
27648 + if (get_user(byte_write, &buf[*off - init_off]))
27649 + return -EFAULT;
27650 err = ec_write(*off, byte_write);
27651 if (err)
27652 return err;
27653 diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c
27654 index 251c7b62..000462d 100644
27655 --- a/drivers/acpi/proc.c
27656 +++ b/drivers/acpi/proc.c
27657 @@ -343,19 +343,13 @@ acpi_system_write_wakeup_device(struct file *file,
27658 size_t count, loff_t * ppos)
27659 {
27660 struct list_head *node, *next;
27661 - char strbuf[5];
27662 - char str[5] = "";
27663 - unsigned int len = count;
27664 + char strbuf[5] = {0};
27665
27666 - if (len > 4)
27667 - len = 4;
27668 - if (len < 0)
27669 + if (count > 4)
27670 + count = 4;
27671 + if (copy_from_user(strbuf, buffer, count))
27672 return -EFAULT;
27673 -
27674 - if (copy_from_user(strbuf, buffer, len))
27675 - return -EFAULT;
27676 - strbuf[len] = '\0';
27677 - sscanf(strbuf, "%s", str);
27678 + strbuf[count] = '\0';
27679
27680 mutex_lock(&acpi_device_lock);
27681 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
27682 @@ -364,7 +358,7 @@ acpi_system_write_wakeup_device(struct file *file,
27683 if (!dev->wakeup.flags.valid)
27684 continue;
27685
27686 - if (!strncmp(dev->pnp.bus_id, str, 4)) {
27687 + if (!strncmp(dev->pnp.bus_id, strbuf, 4)) {
27688 if (device_can_wakeup(&dev->dev)) {
27689 bool enable = !device_may_wakeup(&dev->dev);
27690 device_set_wakeup_enable(&dev->dev, enable);
27691 diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
27692 index 8ae05ce..7dbbed9 100644
27693 --- a/drivers/acpi/processor_driver.c
27694 +++ b/drivers/acpi/processor_driver.c
27695 @@ -555,7 +555,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
27696 return 0;
27697 #endif
27698
27699 - BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0));
27700 + BUG_ON(pr->id >= nr_cpu_ids);
27701
27702 /*
27703 * Buggy BIOS check
27704 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
27705 index c06e0ec..a2c06ba 100644
27706 --- a/drivers/ata/libata-core.c
27707 +++ b/drivers/ata/libata-core.c
27708 @@ -4736,7 +4736,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
27709 struct ata_port *ap;
27710 unsigned int tag;
27711
27712 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
27713 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
27714 ap = qc->ap;
27715
27716 qc->flags = 0;
27717 @@ -4752,7 +4752,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
27718 struct ata_port *ap;
27719 struct ata_link *link;
27720
27721 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
27722 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
27723 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
27724 ap = qc->ap;
27725 link = qc->dev->link;
27726 @@ -5816,6 +5816,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
27727 return;
27728
27729 spin_lock(&lock);
27730 + pax_open_kernel();
27731
27732 for (cur = ops->inherits; cur; cur = cur->inherits) {
27733 void **inherit = (void **)cur;
27734 @@ -5829,8 +5830,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
27735 if (IS_ERR(*pp))
27736 *pp = NULL;
27737
27738 - ops->inherits = NULL;
27739 + *(struct ata_port_operations **)&ops->inherits = NULL;
27740
27741 + pax_close_kernel();
27742 spin_unlock(&lock);
27743 }
27744
27745 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
27746 index 048589f..4002b98 100644
27747 --- a/drivers/ata/pata_arasan_cf.c
27748 +++ b/drivers/ata/pata_arasan_cf.c
27749 @@ -862,7 +862,9 @@ static int __devinit arasan_cf_probe(struct platform_device *pdev)
27750 /* Handle platform specific quirks */
27751 if (pdata->quirk) {
27752 if (pdata->quirk & CF_BROKEN_PIO) {
27753 - ap->ops->set_piomode = NULL;
27754 + pax_open_kernel();
27755 + *(void **)&ap->ops->set_piomode = NULL;
27756 + pax_close_kernel();
27757 ap->pio_mask = 0;
27758 }
27759 if (pdata->quirk & CF_BROKEN_MWDMA)
27760 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
27761 index f9b983a..887b9d8 100644
27762 --- a/drivers/atm/adummy.c
27763 +++ b/drivers/atm/adummy.c
27764 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
27765 vcc->pop(vcc, skb);
27766 else
27767 dev_kfree_skb_any(skb);
27768 - atomic_inc(&vcc->stats->tx);
27769 + atomic_inc_unchecked(&vcc->stats->tx);
27770
27771 return 0;
27772 }
27773 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
27774 index f8f41e0..1f987dd 100644
27775 --- a/drivers/atm/ambassador.c
27776 +++ b/drivers/atm/ambassador.c
27777 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
27778 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
27779
27780 // VC layer stats
27781 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
27782 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
27783
27784 // free the descriptor
27785 kfree (tx_descr);
27786 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
27787 dump_skb ("<<<", vc, skb);
27788
27789 // VC layer stats
27790 - atomic_inc(&atm_vcc->stats->rx);
27791 + atomic_inc_unchecked(&atm_vcc->stats->rx);
27792 __net_timestamp(skb);
27793 // end of our responsibility
27794 atm_vcc->push (atm_vcc, skb);
27795 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
27796 } else {
27797 PRINTK (KERN_INFO, "dropped over-size frame");
27798 // should we count this?
27799 - atomic_inc(&atm_vcc->stats->rx_drop);
27800 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
27801 }
27802
27803 } else {
27804 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
27805 }
27806
27807 if (check_area (skb->data, skb->len)) {
27808 - atomic_inc(&atm_vcc->stats->tx_err);
27809 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
27810 return -ENOMEM; // ?
27811 }
27812
27813 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
27814 index b22d71c..d6e1049 100644
27815 --- a/drivers/atm/atmtcp.c
27816 +++ b/drivers/atm/atmtcp.c
27817 @@ -207,7 +207,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
27818 if (vcc->pop) vcc->pop(vcc,skb);
27819 else dev_kfree_skb(skb);
27820 if (dev_data) return 0;
27821 - atomic_inc(&vcc->stats->tx_err);
27822 + atomic_inc_unchecked(&vcc->stats->tx_err);
27823 return -ENOLINK;
27824 }
27825 size = skb->len+sizeof(struct atmtcp_hdr);
27826 @@ -215,7 +215,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
27827 if (!new_skb) {
27828 if (vcc->pop) vcc->pop(vcc,skb);
27829 else dev_kfree_skb(skb);
27830 - atomic_inc(&vcc->stats->tx_err);
27831 + atomic_inc_unchecked(&vcc->stats->tx_err);
27832 return -ENOBUFS;
27833 }
27834 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
27835 @@ -226,8 +226,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
27836 if (vcc->pop) vcc->pop(vcc,skb);
27837 else dev_kfree_skb(skb);
27838 out_vcc->push(out_vcc,new_skb);
27839 - atomic_inc(&vcc->stats->tx);
27840 - atomic_inc(&out_vcc->stats->rx);
27841 + atomic_inc_unchecked(&vcc->stats->tx);
27842 + atomic_inc_unchecked(&out_vcc->stats->rx);
27843 return 0;
27844 }
27845
27846 @@ -301,7 +301,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
27847 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
27848 read_unlock(&vcc_sklist_lock);
27849 if (!out_vcc) {
27850 - atomic_inc(&vcc->stats->tx_err);
27851 + atomic_inc_unchecked(&vcc->stats->tx_err);
27852 goto done;
27853 }
27854 skb_pull(skb,sizeof(struct atmtcp_hdr));
27855 @@ -313,8 +313,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
27856 __net_timestamp(new_skb);
27857 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
27858 out_vcc->push(out_vcc,new_skb);
27859 - atomic_inc(&vcc->stats->tx);
27860 - atomic_inc(&out_vcc->stats->rx);
27861 + atomic_inc_unchecked(&vcc->stats->tx);
27862 + atomic_inc_unchecked(&out_vcc->stats->rx);
27863 done:
27864 if (vcc->pop) vcc->pop(vcc,skb);
27865 else dev_kfree_skb(skb);
27866 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
27867 index 956e9ac..133516d 100644
27868 --- a/drivers/atm/eni.c
27869 +++ b/drivers/atm/eni.c
27870 @@ -526,7 +526,7 @@ static int rx_aal0(struct atm_vcc *vcc)
27871 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
27872 vcc->dev->number);
27873 length = 0;
27874 - atomic_inc(&vcc->stats->rx_err);
27875 + atomic_inc_unchecked(&vcc->stats->rx_err);
27876 }
27877 else {
27878 length = ATM_CELL_SIZE-1; /* no HEC */
27879 @@ -581,7 +581,7 @@ static int rx_aal5(struct atm_vcc *vcc)
27880 size);
27881 }
27882 eff = length = 0;
27883 - atomic_inc(&vcc->stats->rx_err);
27884 + atomic_inc_unchecked(&vcc->stats->rx_err);
27885 }
27886 else {
27887 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
27888 @@ -598,7 +598,7 @@ static int rx_aal5(struct atm_vcc *vcc)
27889 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
27890 vcc->dev->number,vcc->vci,length,size << 2,descr);
27891 length = eff = 0;
27892 - atomic_inc(&vcc->stats->rx_err);
27893 + atomic_inc_unchecked(&vcc->stats->rx_err);
27894 }
27895 }
27896 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
27897 @@ -771,7 +771,7 @@ rx_dequeued++;
27898 vcc->push(vcc,skb);
27899 pushed++;
27900 }
27901 - atomic_inc(&vcc->stats->rx);
27902 + atomic_inc_unchecked(&vcc->stats->rx);
27903 }
27904 wake_up(&eni_dev->rx_wait);
27905 }
27906 @@ -1229,7 +1229,7 @@ static void dequeue_tx(struct atm_dev *dev)
27907 PCI_DMA_TODEVICE);
27908 if (vcc->pop) vcc->pop(vcc,skb);
27909 else dev_kfree_skb_irq(skb);
27910 - atomic_inc(&vcc->stats->tx);
27911 + atomic_inc_unchecked(&vcc->stats->tx);
27912 wake_up(&eni_dev->tx_wait);
27913 dma_complete++;
27914 }
27915 @@ -1569,7 +1569,7 @@ tx_complete++;
27916 /*--------------------------------- entries ---------------------------------*/
27917
27918
27919 -static const char *media_name[] __devinitdata = {
27920 +static const char *media_name[] __devinitconst = {
27921 "MMF", "SMF", "MMF", "03?", /* 0- 3 */
27922 "UTP", "05?", "06?", "07?", /* 4- 7 */
27923 "TAXI","09?", "10?", "11?", /* 8-11 */
27924 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
27925 index 5072f8a..fa52520d 100644
27926 --- a/drivers/atm/firestream.c
27927 +++ b/drivers/atm/firestream.c
27928 @@ -750,7 +750,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
27929 }
27930 }
27931
27932 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
27933 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
27934
27935 fs_dprintk (FS_DEBUG_TXMEM, "i");
27936 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
27937 @@ -817,7 +817,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
27938 #endif
27939 skb_put (skb, qe->p1 & 0xffff);
27940 ATM_SKB(skb)->vcc = atm_vcc;
27941 - atomic_inc(&atm_vcc->stats->rx);
27942 + atomic_inc_unchecked(&atm_vcc->stats->rx);
27943 __net_timestamp(skb);
27944 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
27945 atm_vcc->push (atm_vcc, skb);
27946 @@ -838,12 +838,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
27947 kfree (pe);
27948 }
27949 if (atm_vcc)
27950 - atomic_inc(&atm_vcc->stats->rx_drop);
27951 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
27952 break;
27953 case 0x1f: /* Reassembly abort: no buffers. */
27954 /* Silently increment error counter. */
27955 if (atm_vcc)
27956 - atomic_inc(&atm_vcc->stats->rx_drop);
27957 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
27958 break;
27959 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
27960 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
27961 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
27962 index 361f5ae..7fc552d 100644
27963 --- a/drivers/atm/fore200e.c
27964 +++ b/drivers/atm/fore200e.c
27965 @@ -933,9 +933,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
27966 #endif
27967 /* check error condition */
27968 if (*entry->status & STATUS_ERROR)
27969 - atomic_inc(&vcc->stats->tx_err);
27970 + atomic_inc_unchecked(&vcc->stats->tx_err);
27971 else
27972 - atomic_inc(&vcc->stats->tx);
27973 + atomic_inc_unchecked(&vcc->stats->tx);
27974 }
27975 }
27976
27977 @@ -1084,7 +1084,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
27978 if (skb == NULL) {
27979 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
27980
27981 - atomic_inc(&vcc->stats->rx_drop);
27982 + atomic_inc_unchecked(&vcc->stats->rx_drop);
27983 return -ENOMEM;
27984 }
27985
27986 @@ -1127,14 +1127,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
27987
27988 dev_kfree_skb_any(skb);
27989
27990 - atomic_inc(&vcc->stats->rx_drop);
27991 + atomic_inc_unchecked(&vcc->stats->rx_drop);
27992 return -ENOMEM;
27993 }
27994
27995 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
27996
27997 vcc->push(vcc, skb);
27998 - atomic_inc(&vcc->stats->rx);
27999 + atomic_inc_unchecked(&vcc->stats->rx);
28000
28001 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
28002
28003 @@ -1212,7 +1212,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
28004 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
28005 fore200e->atm_dev->number,
28006 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
28007 - atomic_inc(&vcc->stats->rx_err);
28008 + atomic_inc_unchecked(&vcc->stats->rx_err);
28009 }
28010 }
28011
28012 @@ -1657,7 +1657,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
28013 goto retry_here;
28014 }
28015
28016 - atomic_inc(&vcc->stats->tx_err);
28017 + atomic_inc_unchecked(&vcc->stats->tx_err);
28018
28019 fore200e->tx_sat++;
28020 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
28021 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
28022 index b182c2f..1c6fa8a 100644
28023 --- a/drivers/atm/he.c
28024 +++ b/drivers/atm/he.c
28025 @@ -1709,7 +1709,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
28026
28027 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
28028 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
28029 - atomic_inc(&vcc->stats->rx_drop);
28030 + atomic_inc_unchecked(&vcc->stats->rx_drop);
28031 goto return_host_buffers;
28032 }
28033
28034 @@ -1736,7 +1736,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
28035 RBRQ_LEN_ERR(he_dev->rbrq_head)
28036 ? "LEN_ERR" : "",
28037 vcc->vpi, vcc->vci);
28038 - atomic_inc(&vcc->stats->rx_err);
28039 + atomic_inc_unchecked(&vcc->stats->rx_err);
28040 goto return_host_buffers;
28041 }
28042
28043 @@ -1788,7 +1788,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
28044 vcc->push(vcc, skb);
28045 spin_lock(&he_dev->global_lock);
28046
28047 - atomic_inc(&vcc->stats->rx);
28048 + atomic_inc_unchecked(&vcc->stats->rx);
28049
28050 return_host_buffers:
28051 ++pdus_assembled;
28052 @@ -2114,7 +2114,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
28053 tpd->vcc->pop(tpd->vcc, tpd->skb);
28054 else
28055 dev_kfree_skb_any(tpd->skb);
28056 - atomic_inc(&tpd->vcc->stats->tx_err);
28057 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
28058 }
28059 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
28060 return;
28061 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
28062 vcc->pop(vcc, skb);
28063 else
28064 dev_kfree_skb_any(skb);
28065 - atomic_inc(&vcc->stats->tx_err);
28066 + atomic_inc_unchecked(&vcc->stats->tx_err);
28067 return -EINVAL;
28068 }
28069
28070 @@ -2537,7 +2537,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
28071 vcc->pop(vcc, skb);
28072 else
28073 dev_kfree_skb_any(skb);
28074 - atomic_inc(&vcc->stats->tx_err);
28075 + atomic_inc_unchecked(&vcc->stats->tx_err);
28076 return -EINVAL;
28077 }
28078 #endif
28079 @@ -2549,7 +2549,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
28080 vcc->pop(vcc, skb);
28081 else
28082 dev_kfree_skb_any(skb);
28083 - atomic_inc(&vcc->stats->tx_err);
28084 + atomic_inc_unchecked(&vcc->stats->tx_err);
28085 spin_unlock_irqrestore(&he_dev->global_lock, flags);
28086 return -ENOMEM;
28087 }
28088 @@ -2591,7 +2591,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
28089 vcc->pop(vcc, skb);
28090 else
28091 dev_kfree_skb_any(skb);
28092 - atomic_inc(&vcc->stats->tx_err);
28093 + atomic_inc_unchecked(&vcc->stats->tx_err);
28094 spin_unlock_irqrestore(&he_dev->global_lock, flags);
28095 return -ENOMEM;
28096 }
28097 @@ -2622,7 +2622,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
28098 __enqueue_tpd(he_dev, tpd, cid);
28099 spin_unlock_irqrestore(&he_dev->global_lock, flags);
28100
28101 - atomic_inc(&vcc->stats->tx);
28102 + atomic_inc_unchecked(&vcc->stats->tx);
28103
28104 return 0;
28105 }
28106 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
28107 index b812103..e391a49 100644
28108 --- a/drivers/atm/horizon.c
28109 +++ b/drivers/atm/horizon.c
28110 @@ -1035,7 +1035,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
28111 {
28112 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
28113 // VC layer stats
28114 - atomic_inc(&vcc->stats->rx);
28115 + atomic_inc_unchecked(&vcc->stats->rx);
28116 __net_timestamp(skb);
28117 // end of our responsibility
28118 vcc->push (vcc, skb);
28119 @@ -1187,7 +1187,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
28120 dev->tx_iovec = NULL;
28121
28122 // VC layer stats
28123 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
28124 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
28125
28126 // free the skb
28127 hrz_kfree_skb (skb);
28128 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
28129 index 1c05212..c28e200 100644
28130 --- a/drivers/atm/idt77252.c
28131 +++ b/drivers/atm/idt77252.c
28132 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
28133 else
28134 dev_kfree_skb(skb);
28135
28136 - atomic_inc(&vcc->stats->tx);
28137 + atomic_inc_unchecked(&vcc->stats->tx);
28138 }
28139
28140 atomic_dec(&scq->used);
28141 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
28142 if ((sb = dev_alloc_skb(64)) == NULL) {
28143 printk("%s: Can't allocate buffers for aal0.\n",
28144 card->name);
28145 - atomic_add(i, &vcc->stats->rx_drop);
28146 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
28147 break;
28148 }
28149 if (!atm_charge(vcc, sb->truesize)) {
28150 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
28151 card->name);
28152 - atomic_add(i - 1, &vcc->stats->rx_drop);
28153 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
28154 dev_kfree_skb(sb);
28155 break;
28156 }
28157 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
28158 ATM_SKB(sb)->vcc = vcc;
28159 __net_timestamp(sb);
28160 vcc->push(vcc, sb);
28161 - atomic_inc(&vcc->stats->rx);
28162 + atomic_inc_unchecked(&vcc->stats->rx);
28163
28164 cell += ATM_CELL_PAYLOAD;
28165 }
28166 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
28167 "(CDC: %08x)\n",
28168 card->name, len, rpp->len, readl(SAR_REG_CDC));
28169 recycle_rx_pool_skb(card, rpp);
28170 - atomic_inc(&vcc->stats->rx_err);
28171 + atomic_inc_unchecked(&vcc->stats->rx_err);
28172 return;
28173 }
28174 if (stat & SAR_RSQE_CRC) {
28175 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
28176 recycle_rx_pool_skb(card, rpp);
28177 - atomic_inc(&vcc->stats->rx_err);
28178 + atomic_inc_unchecked(&vcc->stats->rx_err);
28179 return;
28180 }
28181 if (skb_queue_len(&rpp->queue) > 1) {
28182 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
28183 RXPRINTK("%s: Can't alloc RX skb.\n",
28184 card->name);
28185 recycle_rx_pool_skb(card, rpp);
28186 - atomic_inc(&vcc->stats->rx_err);
28187 + atomic_inc_unchecked(&vcc->stats->rx_err);
28188 return;
28189 }
28190 if (!atm_charge(vcc, skb->truesize)) {
28191 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
28192 __net_timestamp(skb);
28193
28194 vcc->push(vcc, skb);
28195 - atomic_inc(&vcc->stats->rx);
28196 + atomic_inc_unchecked(&vcc->stats->rx);
28197
28198 return;
28199 }
28200 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
28201 __net_timestamp(skb);
28202
28203 vcc->push(vcc, skb);
28204 - atomic_inc(&vcc->stats->rx);
28205 + atomic_inc_unchecked(&vcc->stats->rx);
28206
28207 if (skb->truesize > SAR_FB_SIZE_3)
28208 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
28209 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
28210 if (vcc->qos.aal != ATM_AAL0) {
28211 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
28212 card->name, vpi, vci);
28213 - atomic_inc(&vcc->stats->rx_drop);
28214 + atomic_inc_unchecked(&vcc->stats->rx_drop);
28215 goto drop;
28216 }
28217
28218 if ((sb = dev_alloc_skb(64)) == NULL) {
28219 printk("%s: Can't allocate buffers for AAL0.\n",
28220 card->name);
28221 - atomic_inc(&vcc->stats->rx_err);
28222 + atomic_inc_unchecked(&vcc->stats->rx_err);
28223 goto drop;
28224 }
28225
28226 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
28227 ATM_SKB(sb)->vcc = vcc;
28228 __net_timestamp(sb);
28229 vcc->push(vcc, sb);
28230 - atomic_inc(&vcc->stats->rx);
28231 + atomic_inc_unchecked(&vcc->stats->rx);
28232
28233 drop:
28234 skb_pull(queue, 64);
28235 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
28236
28237 if (vc == NULL) {
28238 printk("%s: NULL connection in send().\n", card->name);
28239 - atomic_inc(&vcc->stats->tx_err);
28240 + atomic_inc_unchecked(&vcc->stats->tx_err);
28241 dev_kfree_skb(skb);
28242 return -EINVAL;
28243 }
28244 if (!test_bit(VCF_TX, &vc->flags)) {
28245 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
28246 - atomic_inc(&vcc->stats->tx_err);
28247 + atomic_inc_unchecked(&vcc->stats->tx_err);
28248 dev_kfree_skb(skb);
28249 return -EINVAL;
28250 }
28251 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
28252 break;
28253 default:
28254 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
28255 - atomic_inc(&vcc->stats->tx_err);
28256 + atomic_inc_unchecked(&vcc->stats->tx_err);
28257 dev_kfree_skb(skb);
28258 return -EINVAL;
28259 }
28260
28261 if (skb_shinfo(skb)->nr_frags != 0) {
28262 printk("%s: No scatter-gather yet.\n", card->name);
28263 - atomic_inc(&vcc->stats->tx_err);
28264 + atomic_inc_unchecked(&vcc->stats->tx_err);
28265 dev_kfree_skb(skb);
28266 return -EINVAL;
28267 }
28268 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
28269
28270 err = queue_skb(card, vc, skb, oam);
28271 if (err) {
28272 - atomic_inc(&vcc->stats->tx_err);
28273 + atomic_inc_unchecked(&vcc->stats->tx_err);
28274 dev_kfree_skb(skb);
28275 return err;
28276 }
28277 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
28278 skb = dev_alloc_skb(64);
28279 if (!skb) {
28280 printk("%s: Out of memory in send_oam().\n", card->name);
28281 - atomic_inc(&vcc->stats->tx_err);
28282 + atomic_inc_unchecked(&vcc->stats->tx_err);
28283 return -ENOMEM;
28284 }
28285 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
28286 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
28287 index 9e373ba..cf93727 100644
28288 --- a/drivers/atm/iphase.c
28289 +++ b/drivers/atm/iphase.c
28290 @@ -1146,7 +1146,7 @@ static int rx_pkt(struct atm_dev *dev)
28291 status = (u_short) (buf_desc_ptr->desc_mode);
28292 if (status & (RX_CER | RX_PTE | RX_OFL))
28293 {
28294 - atomic_inc(&vcc->stats->rx_err);
28295 + atomic_inc_unchecked(&vcc->stats->rx_err);
28296 IF_ERR(printk("IA: bad packet, dropping it");)
28297 if (status & RX_CER) {
28298 IF_ERR(printk(" cause: packet CRC error\n");)
28299 @@ -1169,7 +1169,7 @@ static int rx_pkt(struct atm_dev *dev)
28300 len = dma_addr - buf_addr;
28301 if (len > iadev->rx_buf_sz) {
28302 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
28303 - atomic_inc(&vcc->stats->rx_err);
28304 + atomic_inc_unchecked(&vcc->stats->rx_err);
28305 goto out_free_desc;
28306 }
28307
28308 @@ -1319,7 +1319,7 @@ static void rx_dle_intr(struct atm_dev *dev)
28309 ia_vcc = INPH_IA_VCC(vcc);
28310 if (ia_vcc == NULL)
28311 {
28312 - atomic_inc(&vcc->stats->rx_err);
28313 + atomic_inc_unchecked(&vcc->stats->rx_err);
28314 atm_return(vcc, skb->truesize);
28315 dev_kfree_skb_any(skb);
28316 goto INCR_DLE;
28317 @@ -1331,7 +1331,7 @@ static void rx_dle_intr(struct atm_dev *dev)
28318 if ((length > iadev->rx_buf_sz) || (length >
28319 (skb->len - sizeof(struct cpcs_trailer))))
28320 {
28321 - atomic_inc(&vcc->stats->rx_err);
28322 + atomic_inc_unchecked(&vcc->stats->rx_err);
28323 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
28324 length, skb->len);)
28325 atm_return(vcc, skb->truesize);
28326 @@ -1347,7 +1347,7 @@ static void rx_dle_intr(struct atm_dev *dev)
28327
28328 IF_RX(printk("rx_dle_intr: skb push");)
28329 vcc->push(vcc,skb);
28330 - atomic_inc(&vcc->stats->rx);
28331 + atomic_inc_unchecked(&vcc->stats->rx);
28332 iadev->rx_pkt_cnt++;
28333 }
28334 INCR_DLE:
28335 @@ -2827,15 +2827,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
28336 {
28337 struct k_sonet_stats *stats;
28338 stats = &PRIV(_ia_dev[board])->sonet_stats;
28339 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
28340 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
28341 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
28342 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
28343 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
28344 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
28345 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
28346 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
28347 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
28348 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
28349 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
28350 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
28351 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
28352 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
28353 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
28354 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
28355 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
28356 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
28357 }
28358 ia_cmds.status = 0;
28359 break;
28360 @@ -2940,7 +2940,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
28361 if ((desc == 0) || (desc > iadev->num_tx_desc))
28362 {
28363 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
28364 - atomic_inc(&vcc->stats->tx);
28365 + atomic_inc_unchecked(&vcc->stats->tx);
28366 if (vcc->pop)
28367 vcc->pop(vcc, skb);
28368 else
28369 @@ -3045,14 +3045,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
28370 ATM_DESC(skb) = vcc->vci;
28371 skb_queue_tail(&iadev->tx_dma_q, skb);
28372
28373 - atomic_inc(&vcc->stats->tx);
28374 + atomic_inc_unchecked(&vcc->stats->tx);
28375 iadev->tx_pkt_cnt++;
28376 /* Increment transaction counter */
28377 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
28378
28379 #if 0
28380 /* add flow control logic */
28381 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
28382 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
28383 if (iavcc->vc_desc_cnt > 10) {
28384 vcc->tx_quota = vcc->tx_quota * 3 / 4;
28385 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
28386 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
28387 index f556969..0da15eb 100644
28388 --- a/drivers/atm/lanai.c
28389 +++ b/drivers/atm/lanai.c
28390 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
28391 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
28392 lanai_endtx(lanai, lvcc);
28393 lanai_free_skb(lvcc->tx.atmvcc, skb);
28394 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
28395 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
28396 }
28397
28398 /* Try to fill the buffer - don't call unless there is backlog */
28399 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
28400 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
28401 __net_timestamp(skb);
28402 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
28403 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
28404 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
28405 out:
28406 lvcc->rx.buf.ptr = end;
28407 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
28408 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
28409 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
28410 "vcc %d\n", lanai->number, (unsigned int) s, vci);
28411 lanai->stats.service_rxnotaal5++;
28412 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
28413 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
28414 return 0;
28415 }
28416 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
28417 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
28418 int bytes;
28419 read_unlock(&vcc_sklist_lock);
28420 DPRINTK("got trashed rx pdu on vci %d\n", vci);
28421 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
28422 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
28423 lvcc->stats.x.aal5.service_trash++;
28424 bytes = (SERVICE_GET_END(s) * 16) -
28425 (((unsigned long) lvcc->rx.buf.ptr) -
28426 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
28427 }
28428 if (s & SERVICE_STREAM) {
28429 read_unlock(&vcc_sklist_lock);
28430 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
28431 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
28432 lvcc->stats.x.aal5.service_stream++;
28433 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
28434 "PDU on VCI %d!\n", lanai->number, vci);
28435 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
28436 return 0;
28437 }
28438 DPRINTK("got rx crc error on vci %d\n", vci);
28439 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
28440 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
28441 lvcc->stats.x.aal5.service_rxcrc++;
28442 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
28443 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
28444 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
28445 index 1c70c45..300718d 100644
28446 --- a/drivers/atm/nicstar.c
28447 +++ b/drivers/atm/nicstar.c
28448 @@ -1654,7 +1654,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
28449 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
28450 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
28451 card->index);
28452 - atomic_inc(&vcc->stats->tx_err);
28453 + atomic_inc_unchecked(&vcc->stats->tx_err);
28454 dev_kfree_skb_any(skb);
28455 return -EINVAL;
28456 }
28457 @@ -1662,7 +1662,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
28458 if (!vc->tx) {
28459 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
28460 card->index);
28461 - atomic_inc(&vcc->stats->tx_err);
28462 + atomic_inc_unchecked(&vcc->stats->tx_err);
28463 dev_kfree_skb_any(skb);
28464 return -EINVAL;
28465 }
28466 @@ -1670,14 +1670,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
28467 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
28468 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
28469 card->index);
28470 - atomic_inc(&vcc->stats->tx_err);
28471 + atomic_inc_unchecked(&vcc->stats->tx_err);
28472 dev_kfree_skb_any(skb);
28473 return -EINVAL;
28474 }
28475
28476 if (skb_shinfo(skb)->nr_frags != 0) {
28477 printk("nicstar%d: No scatter-gather yet.\n", card->index);
28478 - atomic_inc(&vcc->stats->tx_err);
28479 + atomic_inc_unchecked(&vcc->stats->tx_err);
28480 dev_kfree_skb_any(skb);
28481 return -EINVAL;
28482 }
28483 @@ -1725,11 +1725,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
28484 }
28485
28486 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
28487 - atomic_inc(&vcc->stats->tx_err);
28488 + atomic_inc_unchecked(&vcc->stats->tx_err);
28489 dev_kfree_skb_any(skb);
28490 return -EIO;
28491 }
28492 - atomic_inc(&vcc->stats->tx);
28493 + atomic_inc_unchecked(&vcc->stats->tx);
28494
28495 return 0;
28496 }
28497 @@ -2046,14 +2046,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28498 printk
28499 ("nicstar%d: Can't allocate buffers for aal0.\n",
28500 card->index);
28501 - atomic_add(i, &vcc->stats->rx_drop);
28502 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
28503 break;
28504 }
28505 if (!atm_charge(vcc, sb->truesize)) {
28506 RXPRINTK
28507 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
28508 card->index);
28509 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
28510 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
28511 dev_kfree_skb_any(sb);
28512 break;
28513 }
28514 @@ -2068,7 +2068,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28515 ATM_SKB(sb)->vcc = vcc;
28516 __net_timestamp(sb);
28517 vcc->push(vcc, sb);
28518 - atomic_inc(&vcc->stats->rx);
28519 + atomic_inc_unchecked(&vcc->stats->rx);
28520 cell += ATM_CELL_PAYLOAD;
28521 }
28522
28523 @@ -2085,7 +2085,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28524 if (iovb == NULL) {
28525 printk("nicstar%d: Out of iovec buffers.\n",
28526 card->index);
28527 - atomic_inc(&vcc->stats->rx_drop);
28528 + atomic_inc_unchecked(&vcc->stats->rx_drop);
28529 recycle_rx_buf(card, skb);
28530 return;
28531 }
28532 @@ -2109,7 +2109,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28533 small or large buffer itself. */
28534 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
28535 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
28536 - atomic_inc(&vcc->stats->rx_err);
28537 + atomic_inc_unchecked(&vcc->stats->rx_err);
28538 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
28539 NS_MAX_IOVECS);
28540 NS_PRV_IOVCNT(iovb) = 0;
28541 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28542 ("nicstar%d: Expected a small buffer, and this is not one.\n",
28543 card->index);
28544 which_list(card, skb);
28545 - atomic_inc(&vcc->stats->rx_err);
28546 + atomic_inc_unchecked(&vcc->stats->rx_err);
28547 recycle_rx_buf(card, skb);
28548 vc->rx_iov = NULL;
28549 recycle_iov_buf(card, iovb);
28550 @@ -2142,7 +2142,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28551 ("nicstar%d: Expected a large buffer, and this is not one.\n",
28552 card->index);
28553 which_list(card, skb);
28554 - atomic_inc(&vcc->stats->rx_err);
28555 + atomic_inc_unchecked(&vcc->stats->rx_err);
28556 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
28557 NS_PRV_IOVCNT(iovb));
28558 vc->rx_iov = NULL;
28559 @@ -2165,7 +2165,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28560 printk(" - PDU size mismatch.\n");
28561 else
28562 printk(".\n");
28563 - atomic_inc(&vcc->stats->rx_err);
28564 + atomic_inc_unchecked(&vcc->stats->rx_err);
28565 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
28566 NS_PRV_IOVCNT(iovb));
28567 vc->rx_iov = NULL;
28568 @@ -2179,7 +2179,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28569 /* skb points to a small buffer */
28570 if (!atm_charge(vcc, skb->truesize)) {
28571 push_rxbufs(card, skb);
28572 - atomic_inc(&vcc->stats->rx_drop);
28573 + atomic_inc_unchecked(&vcc->stats->rx_drop);
28574 } else {
28575 skb_put(skb, len);
28576 dequeue_sm_buf(card, skb);
28577 @@ -2189,7 +2189,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28578 ATM_SKB(skb)->vcc = vcc;
28579 __net_timestamp(skb);
28580 vcc->push(vcc, skb);
28581 - atomic_inc(&vcc->stats->rx);
28582 + atomic_inc_unchecked(&vcc->stats->rx);
28583 }
28584 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
28585 struct sk_buff *sb;
28586 @@ -2200,7 +2200,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28587 if (len <= NS_SMBUFSIZE) {
28588 if (!atm_charge(vcc, sb->truesize)) {
28589 push_rxbufs(card, sb);
28590 - atomic_inc(&vcc->stats->rx_drop);
28591 + atomic_inc_unchecked(&vcc->stats->rx_drop);
28592 } else {
28593 skb_put(sb, len);
28594 dequeue_sm_buf(card, sb);
28595 @@ -2210,7 +2210,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28596 ATM_SKB(sb)->vcc = vcc;
28597 __net_timestamp(sb);
28598 vcc->push(vcc, sb);
28599 - atomic_inc(&vcc->stats->rx);
28600 + atomic_inc_unchecked(&vcc->stats->rx);
28601 }
28602
28603 push_rxbufs(card, skb);
28604 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28605
28606 if (!atm_charge(vcc, skb->truesize)) {
28607 push_rxbufs(card, skb);
28608 - atomic_inc(&vcc->stats->rx_drop);
28609 + atomic_inc_unchecked(&vcc->stats->rx_drop);
28610 } else {
28611 dequeue_lg_buf(card, skb);
28612 #ifdef NS_USE_DESTRUCTORS
28613 @@ -2232,7 +2232,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28614 ATM_SKB(skb)->vcc = vcc;
28615 __net_timestamp(skb);
28616 vcc->push(vcc, skb);
28617 - atomic_inc(&vcc->stats->rx);
28618 + atomic_inc_unchecked(&vcc->stats->rx);
28619 }
28620
28621 push_rxbufs(card, sb);
28622 @@ -2253,7 +2253,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28623 printk
28624 ("nicstar%d: Out of huge buffers.\n",
28625 card->index);
28626 - atomic_inc(&vcc->stats->rx_drop);
28627 + atomic_inc_unchecked(&vcc->stats->rx_drop);
28628 recycle_iovec_rx_bufs(card,
28629 (struct iovec *)
28630 iovb->data,
28631 @@ -2304,7 +2304,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28632 card->hbpool.count++;
28633 } else
28634 dev_kfree_skb_any(hb);
28635 - atomic_inc(&vcc->stats->rx_drop);
28636 + atomic_inc_unchecked(&vcc->stats->rx_drop);
28637 } else {
28638 /* Copy the small buffer to the huge buffer */
28639 sb = (struct sk_buff *)iov->iov_base;
28640 @@ -2341,7 +2341,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28641 #endif /* NS_USE_DESTRUCTORS */
28642 __net_timestamp(hb);
28643 vcc->push(vcc, hb);
28644 - atomic_inc(&vcc->stats->rx);
28645 + atomic_inc_unchecked(&vcc->stats->rx);
28646 }
28647 }
28648
28649 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
28650 index e8cd652..bbbd1fc 100644
28651 --- a/drivers/atm/solos-pci.c
28652 +++ b/drivers/atm/solos-pci.c
28653 @@ -714,7 +714,7 @@ void solos_bh(unsigned long card_arg)
28654 }
28655 atm_charge(vcc, skb->truesize);
28656 vcc->push(vcc, skb);
28657 - atomic_inc(&vcc->stats->rx);
28658 + atomic_inc_unchecked(&vcc->stats->rx);
28659 break;
28660
28661 case PKT_STATUS:
28662 @@ -1008,7 +1008,7 @@ static uint32_t fpga_tx(struct solos_card *card)
28663 vcc = SKB_CB(oldskb)->vcc;
28664
28665 if (vcc) {
28666 - atomic_inc(&vcc->stats->tx);
28667 + atomic_inc_unchecked(&vcc->stats->tx);
28668 solos_pop(vcc, oldskb);
28669 } else
28670 dev_kfree_skb_irq(oldskb);
28671 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
28672 index 90f1ccc..04c4a1e 100644
28673 --- a/drivers/atm/suni.c
28674 +++ b/drivers/atm/suni.c
28675 @@ -50,8 +50,8 @@ static DEFINE_SPINLOCK(sunis_lock);
28676
28677
28678 #define ADD_LIMITED(s,v) \
28679 - atomic_add((v),&stats->s); \
28680 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
28681 + atomic_add_unchecked((v),&stats->s); \
28682 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
28683
28684
28685 static void suni_hz(unsigned long from_timer)
28686 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
28687 index 5120a96..e2572bd 100644
28688 --- a/drivers/atm/uPD98402.c
28689 +++ b/drivers/atm/uPD98402.c
28690 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
28691 struct sonet_stats tmp;
28692 int error = 0;
28693
28694 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
28695 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
28696 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
28697 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
28698 if (zero && !error) {
28699 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
28700
28701
28702 #define ADD_LIMITED(s,v) \
28703 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
28704 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
28705 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
28706 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
28707 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
28708 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
28709
28710
28711 static void stat_event(struct atm_dev *dev)
28712 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
28713 if (reason & uPD98402_INT_PFM) stat_event(dev);
28714 if (reason & uPD98402_INT_PCO) {
28715 (void) GET(PCOCR); /* clear interrupt cause */
28716 - atomic_add(GET(HECCT),
28717 + atomic_add_unchecked(GET(HECCT),
28718 &PRIV(dev)->sonet_stats.uncorr_hcs);
28719 }
28720 if ((reason & uPD98402_INT_RFO) &&
28721 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
28722 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
28723 uPD98402_INT_LOS),PIMR); /* enable them */
28724 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
28725 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
28726 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
28727 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
28728 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
28729 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
28730 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
28731 return 0;
28732 }
28733
28734 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
28735 index d889f56..17eb71e 100644
28736 --- a/drivers/atm/zatm.c
28737 +++ b/drivers/atm/zatm.c
28738 @@ -460,7 +460,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
28739 }
28740 if (!size) {
28741 dev_kfree_skb_irq(skb);
28742 - if (vcc) atomic_inc(&vcc->stats->rx_err);
28743 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
28744 continue;
28745 }
28746 if (!atm_charge(vcc,skb->truesize)) {
28747 @@ -470,7 +470,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
28748 skb->len = size;
28749 ATM_SKB(skb)->vcc = vcc;
28750 vcc->push(vcc,skb);
28751 - atomic_inc(&vcc->stats->rx);
28752 + atomic_inc_unchecked(&vcc->stats->rx);
28753 }
28754 zout(pos & 0xffff,MTA(mbx));
28755 #if 0 /* probably a stupid idea */
28756 @@ -734,7 +734,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
28757 skb_queue_head(&zatm_vcc->backlog,skb);
28758 break;
28759 }
28760 - atomic_inc(&vcc->stats->tx);
28761 + atomic_inc_unchecked(&vcc->stats->tx);
28762 wake_up(&zatm_vcc->tx_wait);
28763 }
28764
28765 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
28766 index 8493536..31adee0 100644
28767 --- a/drivers/base/devtmpfs.c
28768 +++ b/drivers/base/devtmpfs.c
28769 @@ -368,7 +368,7 @@ int devtmpfs_mount(const char *mntdir)
28770 if (!thread)
28771 return 0;
28772
28773 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
28774 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
28775 if (err)
28776 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
28777 else
28778 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
28779 index caf995f..6f76697 100644
28780 --- a/drivers/base/power/wakeup.c
28781 +++ b/drivers/base/power/wakeup.c
28782 @@ -30,14 +30,14 @@ bool events_check_enabled;
28783 * They need to be modified together atomically, so it's better to use one
28784 * atomic variable to hold them both.
28785 */
28786 -static atomic_t combined_event_count = ATOMIC_INIT(0);
28787 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
28788
28789 #define IN_PROGRESS_BITS (sizeof(int) * 4)
28790 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
28791
28792 static void split_counters(unsigned int *cnt, unsigned int *inpr)
28793 {
28794 - unsigned int comb = atomic_read(&combined_event_count);
28795 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
28796
28797 *cnt = (comb >> IN_PROGRESS_BITS);
28798 *inpr = comb & MAX_IN_PROGRESS;
28799 @@ -353,7 +353,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
28800 ws->last_time = ktime_get();
28801
28802 /* Increment the counter of events in progress. */
28803 - atomic_inc(&combined_event_count);
28804 + atomic_inc_unchecked(&combined_event_count);
28805 }
28806
28807 /**
28808 @@ -443,7 +443,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
28809 * Increment the counter of registered wakeup events and decrement the
28810 * couter of wakeup events in progress simultaneously.
28811 */
28812 - atomic_add(MAX_IN_PROGRESS, &combined_event_count);
28813 + atomic_add_unchecked(MAX_IN_PROGRESS, &combined_event_count);
28814 }
28815
28816 /**
28817 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
28818 index b0f553b..77b928b 100644
28819 --- a/drivers/block/cciss.c
28820 +++ b/drivers/block/cciss.c
28821 @@ -1198,6 +1198,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
28822 int err;
28823 u32 cp;
28824
28825 + memset(&arg64, 0, sizeof(arg64));
28826 +
28827 err = 0;
28828 err |=
28829 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
28830 @@ -3007,7 +3009,7 @@ static void start_io(ctlr_info_t *h)
28831 while (!list_empty(&h->reqQ)) {
28832 c = list_entry(h->reqQ.next, CommandList_struct, list);
28833 /* can't do anything if fifo is full */
28834 - if ((h->access.fifo_full(h))) {
28835 + if ((h->access->fifo_full(h))) {
28836 dev_warn(&h->pdev->dev, "fifo full\n");
28837 break;
28838 }
28839 @@ -3017,7 +3019,7 @@ static void start_io(ctlr_info_t *h)
28840 h->Qdepth--;
28841
28842 /* Tell the controller execute command */
28843 - h->access.submit_command(h, c);
28844 + h->access->submit_command(h, c);
28845
28846 /* Put job onto the completed Q */
28847 addQ(&h->cmpQ, c);
28848 @@ -3443,17 +3445,17 @@ startio:
28849
28850 static inline unsigned long get_next_completion(ctlr_info_t *h)
28851 {
28852 - return h->access.command_completed(h);
28853 + return h->access->command_completed(h);
28854 }
28855
28856 static inline int interrupt_pending(ctlr_info_t *h)
28857 {
28858 - return h->access.intr_pending(h);
28859 + return h->access->intr_pending(h);
28860 }
28861
28862 static inline long interrupt_not_for_us(ctlr_info_t *h)
28863 {
28864 - return ((h->access.intr_pending(h) == 0) ||
28865 + return ((h->access->intr_pending(h) == 0) ||
28866 (h->interrupts_enabled == 0));
28867 }
28868
28869 @@ -3486,7 +3488,7 @@ static inline u32 next_command(ctlr_info_t *h)
28870 u32 a;
28871
28872 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
28873 - return h->access.command_completed(h);
28874 + return h->access->command_completed(h);
28875
28876 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
28877 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
28878 @@ -4044,7 +4046,7 @@ static void __devinit cciss_put_controller_into_performant_mode(ctlr_info_t *h)
28879 trans_support & CFGTBL_Trans_use_short_tags);
28880
28881 /* Change the access methods to the performant access methods */
28882 - h->access = SA5_performant_access;
28883 + h->access = &SA5_performant_access;
28884 h->transMethod = CFGTBL_Trans_Performant;
28885
28886 return;
28887 @@ -4316,7 +4318,7 @@ static int __devinit cciss_pci_init(ctlr_info_t *h)
28888 if (prod_index < 0)
28889 return -ENODEV;
28890 h->product_name = products[prod_index].product_name;
28891 - h->access = *(products[prod_index].access);
28892 + h->access = products[prod_index].access;
28893
28894 if (cciss_board_disabled(h)) {
28895 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
28896 @@ -5041,7 +5043,7 @@ reinit_after_soft_reset:
28897 }
28898
28899 /* make sure the board interrupts are off */
28900 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
28901 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
28902 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
28903 if (rc)
28904 goto clean2;
28905 @@ -5093,7 +5095,7 @@ reinit_after_soft_reset:
28906 * fake ones to scoop up any residual completions.
28907 */
28908 spin_lock_irqsave(&h->lock, flags);
28909 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
28910 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
28911 spin_unlock_irqrestore(&h->lock, flags);
28912 free_irq(h->intr[h->intr_mode], h);
28913 rc = cciss_request_irq(h, cciss_msix_discard_completions,
28914 @@ -5113,9 +5115,9 @@ reinit_after_soft_reset:
28915 dev_info(&h->pdev->dev, "Board READY.\n");
28916 dev_info(&h->pdev->dev,
28917 "Waiting for stale completions to drain.\n");
28918 - h->access.set_intr_mask(h, CCISS_INTR_ON);
28919 + h->access->set_intr_mask(h, CCISS_INTR_ON);
28920 msleep(10000);
28921 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
28922 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
28923
28924 rc = controller_reset_failed(h->cfgtable);
28925 if (rc)
28926 @@ -5138,7 +5140,7 @@ reinit_after_soft_reset:
28927 cciss_scsi_setup(h);
28928
28929 /* Turn the interrupts on so we can service requests */
28930 - h->access.set_intr_mask(h, CCISS_INTR_ON);
28931 + h->access->set_intr_mask(h, CCISS_INTR_ON);
28932
28933 /* Get the firmware version */
28934 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
28935 @@ -5211,7 +5213,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
28936 kfree(flush_buf);
28937 if (return_code != IO_OK)
28938 dev_warn(&h->pdev->dev, "Error flushing cache\n");
28939 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
28940 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
28941 free_irq(h->intr[h->intr_mode], h);
28942 }
28943
28944 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
28945 index 7fda30e..eb5dfe0 100644
28946 --- a/drivers/block/cciss.h
28947 +++ b/drivers/block/cciss.h
28948 @@ -101,7 +101,7 @@ struct ctlr_info
28949 /* information about each logical volume */
28950 drive_info_struct *drv[CISS_MAX_LUN];
28951
28952 - struct access_method access;
28953 + struct access_method *access;
28954
28955 /* queue and queue Info */
28956 struct list_head reqQ;
28957 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
28958 index 9125bbe..eede5c8 100644
28959 --- a/drivers/block/cpqarray.c
28960 +++ b/drivers/block/cpqarray.c
28961 @@ -404,7 +404,7 @@ static int __devinit cpqarray_register_ctlr( int i, struct pci_dev *pdev)
28962 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
28963 goto Enomem4;
28964 }
28965 - hba[i]->access.set_intr_mask(hba[i], 0);
28966 + hba[i]->access->set_intr_mask(hba[i], 0);
28967 if (request_irq(hba[i]->intr, do_ida_intr,
28968 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
28969 {
28970 @@ -459,7 +459,7 @@ static int __devinit cpqarray_register_ctlr( int i, struct pci_dev *pdev)
28971 add_timer(&hba[i]->timer);
28972
28973 /* Enable IRQ now that spinlock and rate limit timer are set up */
28974 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
28975 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
28976
28977 for(j=0; j<NWD; j++) {
28978 struct gendisk *disk = ida_gendisk[i][j];
28979 @@ -694,7 +694,7 @@ DBGINFO(
28980 for(i=0; i<NR_PRODUCTS; i++) {
28981 if (board_id == products[i].board_id) {
28982 c->product_name = products[i].product_name;
28983 - c->access = *(products[i].access);
28984 + c->access = products[i].access;
28985 break;
28986 }
28987 }
28988 @@ -792,7 +792,7 @@ static int __devinit cpqarray_eisa_detect(void)
28989 hba[ctlr]->intr = intr;
28990 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
28991 hba[ctlr]->product_name = products[j].product_name;
28992 - hba[ctlr]->access = *(products[j].access);
28993 + hba[ctlr]->access = products[j].access;
28994 hba[ctlr]->ctlr = ctlr;
28995 hba[ctlr]->board_id = board_id;
28996 hba[ctlr]->pci_dev = NULL; /* not PCI */
28997 @@ -980,7 +980,7 @@ static void start_io(ctlr_info_t *h)
28998
28999 while((c = h->reqQ) != NULL) {
29000 /* Can't do anything if we're busy */
29001 - if (h->access.fifo_full(h) == 0)
29002 + if (h->access->fifo_full(h) == 0)
29003 return;
29004
29005 /* Get the first entry from the request Q */
29006 @@ -988,7 +988,7 @@ static void start_io(ctlr_info_t *h)
29007 h->Qdepth--;
29008
29009 /* Tell the controller to do our bidding */
29010 - h->access.submit_command(h, c);
29011 + h->access->submit_command(h, c);
29012
29013 /* Get onto the completion Q */
29014 addQ(&h->cmpQ, c);
29015 @@ -1050,7 +1050,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
29016 unsigned long flags;
29017 __u32 a,a1;
29018
29019 - istat = h->access.intr_pending(h);
29020 + istat = h->access->intr_pending(h);
29021 /* Is this interrupt for us? */
29022 if (istat == 0)
29023 return IRQ_NONE;
29024 @@ -1061,7 +1061,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
29025 */
29026 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
29027 if (istat & FIFO_NOT_EMPTY) {
29028 - while((a = h->access.command_completed(h))) {
29029 + while((a = h->access->command_completed(h))) {
29030 a1 = a; a &= ~3;
29031 if ((c = h->cmpQ) == NULL)
29032 {
29033 @@ -1449,11 +1449,11 @@ static int sendcmd(
29034 /*
29035 * Disable interrupt
29036 */
29037 - info_p->access.set_intr_mask(info_p, 0);
29038 + info_p->access->set_intr_mask(info_p, 0);
29039 /* Make sure there is room in the command FIFO */
29040 /* Actually it should be completely empty at this time. */
29041 for (i = 200000; i > 0; i--) {
29042 - temp = info_p->access.fifo_full(info_p);
29043 + temp = info_p->access->fifo_full(info_p);
29044 if (temp != 0) {
29045 break;
29046 }
29047 @@ -1466,7 +1466,7 @@ DBG(
29048 /*
29049 * Send the cmd
29050 */
29051 - info_p->access.submit_command(info_p, c);
29052 + info_p->access->submit_command(info_p, c);
29053 complete = pollcomplete(ctlr);
29054
29055 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
29056 @@ -1549,9 +1549,9 @@ static int revalidate_allvol(ctlr_info_t *host)
29057 * we check the new geometry. Then turn interrupts back on when
29058 * we're done.
29059 */
29060 - host->access.set_intr_mask(host, 0);
29061 + host->access->set_intr_mask(host, 0);
29062 getgeometry(ctlr);
29063 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
29064 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
29065
29066 for(i=0; i<NWD; i++) {
29067 struct gendisk *disk = ida_gendisk[ctlr][i];
29068 @@ -1591,7 +1591,7 @@ static int pollcomplete(int ctlr)
29069 /* Wait (up to 2 seconds) for a command to complete */
29070
29071 for (i = 200000; i > 0; i--) {
29072 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
29073 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
29074 if (done == 0) {
29075 udelay(10); /* a short fixed delay */
29076 } else
29077 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
29078 index be73e9d..7fbf140 100644
29079 --- a/drivers/block/cpqarray.h
29080 +++ b/drivers/block/cpqarray.h
29081 @@ -99,7 +99,7 @@ struct ctlr_info {
29082 drv_info_t drv[NWD];
29083 struct proc_dir_entry *proc;
29084
29085 - struct access_method access;
29086 + struct access_method *access;
29087
29088 cmdlist_t *reqQ;
29089 cmdlist_t *cmpQ;
29090 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
29091 index 8d68056..e67050f 100644
29092 --- a/drivers/block/drbd/drbd_int.h
29093 +++ b/drivers/block/drbd/drbd_int.h
29094 @@ -736,7 +736,7 @@ struct drbd_request;
29095 struct drbd_epoch {
29096 struct list_head list;
29097 unsigned int barrier_nr;
29098 - atomic_t epoch_size; /* increased on every request added. */
29099 + atomic_unchecked_t epoch_size; /* increased on every request added. */
29100 atomic_t active; /* increased on every req. added, and dec on every finished. */
29101 unsigned long flags;
29102 };
29103 @@ -1108,7 +1108,7 @@ struct drbd_conf {
29104 void *int_dig_in;
29105 void *int_dig_vv;
29106 wait_queue_head_t seq_wait;
29107 - atomic_t packet_seq;
29108 + atomic_unchecked_t packet_seq;
29109 unsigned int peer_seq;
29110 spinlock_t peer_seq_lock;
29111 unsigned int minor;
29112 @@ -1617,30 +1617,30 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
29113
29114 static inline void drbd_tcp_cork(struct socket *sock)
29115 {
29116 - int __user val = 1;
29117 + int val = 1;
29118 (void) drbd_setsockopt(sock, SOL_TCP, TCP_CORK,
29119 - (char __user *)&val, sizeof(val));
29120 + (char __force_user *)&val, sizeof(val));
29121 }
29122
29123 static inline void drbd_tcp_uncork(struct socket *sock)
29124 {
29125 - int __user val = 0;
29126 + int val = 0;
29127 (void) drbd_setsockopt(sock, SOL_TCP, TCP_CORK,
29128 - (char __user *)&val, sizeof(val));
29129 + (char __force_user *)&val, sizeof(val));
29130 }
29131
29132 static inline void drbd_tcp_nodelay(struct socket *sock)
29133 {
29134 - int __user val = 1;
29135 + int val = 1;
29136 (void) drbd_setsockopt(sock, SOL_TCP, TCP_NODELAY,
29137 - (char __user *)&val, sizeof(val));
29138 + (char __force_user *)&val, sizeof(val));
29139 }
29140
29141 static inline void drbd_tcp_quickack(struct socket *sock)
29142 {
29143 - int __user val = 2;
29144 + int val = 2;
29145 (void) drbd_setsockopt(sock, SOL_TCP, TCP_QUICKACK,
29146 - (char __user *)&val, sizeof(val));
29147 + (char __force_user *)&val, sizeof(val));
29148 }
29149
29150 void drbd_bump_write_ordering(struct drbd_conf *mdev, enum write_ordering_e wo);
29151 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
29152 index 211fc44..c5116f1 100644
29153 --- a/drivers/block/drbd/drbd_main.c
29154 +++ b/drivers/block/drbd/drbd_main.c
29155 @@ -2397,7 +2397,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packets cmd,
29156 p.sector = sector;
29157 p.block_id = block_id;
29158 p.blksize = blksize;
29159 - p.seq_num = cpu_to_be32(atomic_add_return(1, &mdev->packet_seq));
29160 + p.seq_num = cpu_to_be32(atomic_add_return_unchecked(1, &mdev->packet_seq));
29161
29162 if (!mdev->meta.socket || mdev->state.conn < C_CONNECTED)
29163 return false;
29164 @@ -2696,7 +2696,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
29165 p.sector = cpu_to_be64(req->sector);
29166 p.block_id = (unsigned long)req;
29167 p.seq_num = cpu_to_be32(req->seq_num =
29168 - atomic_add_return(1, &mdev->packet_seq));
29169 + atomic_add_return_unchecked(1, &mdev->packet_seq));
29170
29171 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
29172
29173 @@ -2981,7 +2981,7 @@ void drbd_init_set_defaults(struct drbd_conf *mdev)
29174 atomic_set(&mdev->unacked_cnt, 0);
29175 atomic_set(&mdev->local_cnt, 0);
29176 atomic_set(&mdev->net_cnt, 0);
29177 - atomic_set(&mdev->packet_seq, 0);
29178 + atomic_set_unchecked(&mdev->packet_seq, 0);
29179 atomic_set(&mdev->pp_in_use, 0);
29180 atomic_set(&mdev->pp_in_use_by_net, 0);
29181 atomic_set(&mdev->rs_sect_in, 0);
29182 @@ -3063,8 +3063,8 @@ void drbd_mdev_cleanup(struct drbd_conf *mdev)
29183 mdev->receiver.t_state);
29184
29185 /* no need to lock it, I'm the only thread alive */
29186 - if (atomic_read(&mdev->current_epoch->epoch_size) != 0)
29187 - dev_err(DEV, "epoch_size:%d\n", atomic_read(&mdev->current_epoch->epoch_size));
29188 + if (atomic_read_unchecked(&mdev->current_epoch->epoch_size) != 0)
29189 + dev_err(DEV, "epoch_size:%d\n", atomic_read_unchecked(&mdev->current_epoch->epoch_size));
29190 mdev->al_writ_cnt =
29191 mdev->bm_writ_cnt =
29192 mdev->read_cnt =
29193 diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
29194 index af2a250..0fdeb75 100644
29195 --- a/drivers/block/drbd/drbd_nl.c
29196 +++ b/drivers/block/drbd/drbd_nl.c
29197 @@ -2297,7 +2297,7 @@ static void drbd_connector_callback(struct cn_msg *req, struct netlink_skb_parms
29198 return;
29199 }
29200
29201 - if (!cap_raised(current_cap(), CAP_SYS_ADMIN)) {
29202 + if (!capable(CAP_SYS_ADMIN)) {
29203 retcode = ERR_PERM;
29204 goto fail;
29205 }
29206 @@ -2359,7 +2359,7 @@ static void drbd_connector_callback(struct cn_msg *req, struct netlink_skb_parms
29207 module_put(THIS_MODULE);
29208 }
29209
29210 -static atomic_t drbd_nl_seq = ATOMIC_INIT(2); /* two. */
29211 +static atomic_unchecked_t drbd_nl_seq = ATOMIC_INIT(2); /* two. */
29212
29213 static unsigned short *
29214 __tl_add_blob(unsigned short *tl, enum drbd_tags tag, const void *data,
29215 @@ -2430,7 +2430,7 @@ void drbd_bcast_state(struct drbd_conf *mdev, union drbd_state state)
29216 cn_reply->id.idx = CN_IDX_DRBD;
29217 cn_reply->id.val = CN_VAL_DRBD;
29218
29219 - cn_reply->seq = atomic_add_return(1, &drbd_nl_seq);
29220 + cn_reply->seq = atomic_add_return_unchecked(1, &drbd_nl_seq);
29221 cn_reply->ack = 0; /* not used here. */
29222 cn_reply->len = sizeof(struct drbd_nl_cfg_reply) +
29223 (int)((char *)tl - (char *)reply->tag_list);
29224 @@ -2462,7 +2462,7 @@ void drbd_bcast_ev_helper(struct drbd_conf *mdev, char *helper_name)
29225 cn_reply->id.idx = CN_IDX_DRBD;
29226 cn_reply->id.val = CN_VAL_DRBD;
29227
29228 - cn_reply->seq = atomic_add_return(1, &drbd_nl_seq);
29229 + cn_reply->seq = atomic_add_return_unchecked(1, &drbd_nl_seq);
29230 cn_reply->ack = 0; /* not used here. */
29231 cn_reply->len = sizeof(struct drbd_nl_cfg_reply) +
29232 (int)((char *)tl - (char *)reply->tag_list);
29233 @@ -2540,7 +2540,7 @@ void drbd_bcast_ee(struct drbd_conf *mdev,
29234 cn_reply->id.idx = CN_IDX_DRBD;
29235 cn_reply->id.val = CN_VAL_DRBD;
29236
29237 - cn_reply->seq = atomic_add_return(1,&drbd_nl_seq);
29238 + cn_reply->seq = atomic_add_return_unchecked(1,&drbd_nl_seq);
29239 cn_reply->ack = 0; // not used here.
29240 cn_reply->len = sizeof(struct drbd_nl_cfg_reply) +
29241 (int)((char*)tl - (char*)reply->tag_list);
29242 @@ -2579,7 +2579,7 @@ void drbd_bcast_sync_progress(struct drbd_conf *mdev)
29243 cn_reply->id.idx = CN_IDX_DRBD;
29244 cn_reply->id.val = CN_VAL_DRBD;
29245
29246 - cn_reply->seq = atomic_add_return(1, &drbd_nl_seq);
29247 + cn_reply->seq = atomic_add_return_unchecked(1, &drbd_nl_seq);
29248 cn_reply->ack = 0; /* not used here. */
29249 cn_reply->len = sizeof(struct drbd_nl_cfg_reply) +
29250 (int)((char *)tl - (char *)reply->tag_list);
29251 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
29252 index 43beaca..4a5b1dd 100644
29253 --- a/drivers/block/drbd/drbd_receiver.c
29254 +++ b/drivers/block/drbd/drbd_receiver.c
29255 @@ -894,7 +894,7 @@ retry:
29256 sock->sk->sk_sndtimeo = mdev->net_conf->timeout*HZ/10;
29257 sock->sk->sk_rcvtimeo = MAX_SCHEDULE_TIMEOUT;
29258
29259 - atomic_set(&mdev->packet_seq, 0);
29260 + atomic_set_unchecked(&mdev->packet_seq, 0);
29261 mdev->peer_seq = 0;
29262
29263 drbd_thread_start(&mdev->asender);
29264 @@ -985,7 +985,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_conf *mdev,
29265 do {
29266 next_epoch = NULL;
29267
29268 - epoch_size = atomic_read(&epoch->epoch_size);
29269 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
29270
29271 switch (ev & ~EV_CLEANUP) {
29272 case EV_PUT:
29273 @@ -1020,7 +1020,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_conf *mdev,
29274 rv = FE_DESTROYED;
29275 } else {
29276 epoch->flags = 0;
29277 - atomic_set(&epoch->epoch_size, 0);
29278 + atomic_set_unchecked(&epoch->epoch_size, 0);
29279 /* atomic_set(&epoch->active, 0); is already zero */
29280 if (rv == FE_STILL_LIVE)
29281 rv = FE_RECYCLED;
29282 @@ -1191,14 +1191,14 @@ static int receive_Barrier(struct drbd_conf *mdev, enum drbd_packets cmd, unsign
29283 drbd_wait_ee_list_empty(mdev, &mdev->active_ee);
29284 drbd_flush(mdev);
29285
29286 - if (atomic_read(&mdev->current_epoch->epoch_size)) {
29287 + if (atomic_read_unchecked(&mdev->current_epoch->epoch_size)) {
29288 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
29289 if (epoch)
29290 break;
29291 }
29292
29293 epoch = mdev->current_epoch;
29294 - wait_event(mdev->ee_wait, atomic_read(&epoch->epoch_size) == 0);
29295 + wait_event(mdev->ee_wait, atomic_read_unchecked(&epoch->epoch_size) == 0);
29296
29297 D_ASSERT(atomic_read(&epoch->active) == 0);
29298 D_ASSERT(epoch->flags == 0);
29299 @@ -1210,11 +1210,11 @@ static int receive_Barrier(struct drbd_conf *mdev, enum drbd_packets cmd, unsign
29300 }
29301
29302 epoch->flags = 0;
29303 - atomic_set(&epoch->epoch_size, 0);
29304 + atomic_set_unchecked(&epoch->epoch_size, 0);
29305 atomic_set(&epoch->active, 0);
29306
29307 spin_lock(&mdev->epoch_lock);
29308 - if (atomic_read(&mdev->current_epoch->epoch_size)) {
29309 + if (atomic_read_unchecked(&mdev->current_epoch->epoch_size)) {
29310 list_add(&epoch->list, &mdev->current_epoch->list);
29311 mdev->current_epoch = epoch;
29312 mdev->epochs++;
29313 @@ -1663,7 +1663,7 @@ static int receive_Data(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned
29314 spin_unlock(&mdev->peer_seq_lock);
29315
29316 drbd_send_ack_dp(mdev, P_NEG_ACK, p, data_size);
29317 - atomic_inc(&mdev->current_epoch->epoch_size);
29318 + atomic_inc_unchecked(&mdev->current_epoch->epoch_size);
29319 return drbd_drain_block(mdev, data_size);
29320 }
29321
29322 @@ -1689,7 +1689,7 @@ static int receive_Data(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned
29323
29324 spin_lock(&mdev->epoch_lock);
29325 e->epoch = mdev->current_epoch;
29326 - atomic_inc(&e->epoch->epoch_size);
29327 + atomic_inc_unchecked(&e->epoch->epoch_size);
29328 atomic_inc(&e->epoch->active);
29329 spin_unlock(&mdev->epoch_lock);
29330
29331 @@ -3885,7 +3885,7 @@ static void drbd_disconnect(struct drbd_conf *mdev)
29332 D_ASSERT(list_empty(&mdev->done_ee));
29333
29334 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
29335 - atomic_set(&mdev->current_epoch->epoch_size, 0);
29336 + atomic_set_unchecked(&mdev->current_epoch->epoch_size, 0);
29337 D_ASSERT(list_empty(&mdev->current_epoch->list));
29338 }
29339
29340 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
29341 index cd50435..ba1ffb5 100644
29342 --- a/drivers/block/loop.c
29343 +++ b/drivers/block/loop.c
29344 @@ -226,7 +226,7 @@ static int __do_lo_send_write(struct file *file,
29345 mm_segment_t old_fs = get_fs();
29346
29347 set_fs(get_ds());
29348 - bw = file->f_op->write(file, buf, len, &pos);
29349 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
29350 set_fs(old_fs);
29351 if (likely(bw == len))
29352 return 0;
29353 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
29354 index 4364303..9adf4ee 100644
29355 --- a/drivers/char/Kconfig
29356 +++ b/drivers/char/Kconfig
29357 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
29358
29359 config DEVKMEM
29360 bool "/dev/kmem virtual device support"
29361 - default y
29362 + default n
29363 + depends on !GRKERNSEC_KMEM
29364 help
29365 Say Y here if you want to support the /dev/kmem device. The
29366 /dev/kmem device is rarely used, but can be used for certain
29367 @@ -596,6 +597,7 @@ config DEVPORT
29368 bool
29369 depends on !M68K
29370 depends on ISA || PCI
29371 + depends on !GRKERNSEC_KMEM
29372 default y
29373
29374 source "drivers/s390/char/Kconfig"
29375 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
29376 index 2e04433..22afc64 100644
29377 --- a/drivers/char/agp/frontend.c
29378 +++ b/drivers/char/agp/frontend.c
29379 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
29380 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
29381 return -EFAULT;
29382
29383 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
29384 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
29385 return -EFAULT;
29386
29387 client = agp_find_client_by_pid(reserve.pid);
29388 diff --git a/drivers/char/briq_panel.c b/drivers/char/briq_panel.c
29389 index 095ab90..afad0a4 100644
29390 --- a/drivers/char/briq_panel.c
29391 +++ b/drivers/char/briq_panel.c
29392 @@ -9,6 +9,7 @@
29393 #include <linux/types.h>
29394 #include <linux/errno.h>
29395 #include <linux/tty.h>
29396 +#include <linux/mutex.h>
29397 #include <linux/timer.h>
29398 #include <linux/kernel.h>
29399 #include <linux/wait.h>
29400 @@ -34,6 +35,7 @@ static int vfd_is_open;
29401 static unsigned char vfd[40];
29402 static int vfd_cursor;
29403 static unsigned char ledpb, led;
29404 +static DEFINE_MUTEX(vfd_mutex);
29405
29406 static void update_vfd(void)
29407 {
29408 @@ -140,12 +142,15 @@ static ssize_t briq_panel_write(struct file *file, const char __user *buf, size_
29409 if (!vfd_is_open)
29410 return -EBUSY;
29411
29412 + mutex_lock(&vfd_mutex);
29413 for (;;) {
29414 char c;
29415 if (!indx)
29416 break;
29417 - if (get_user(c, buf))
29418 + if (get_user(c, buf)) {
29419 + mutex_unlock(&vfd_mutex);
29420 return -EFAULT;
29421 + }
29422 if (esc) {
29423 set_led(c);
29424 esc = 0;
29425 @@ -175,6 +180,7 @@ static ssize_t briq_panel_write(struct file *file, const char __user *buf, size_
29426 buf++;
29427 }
29428 update_vfd();
29429 + mutex_unlock(&vfd_mutex);
29430
29431 return len;
29432 }
29433 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
29434 index f773a9d..65cd683 100644
29435 --- a/drivers/char/genrtc.c
29436 +++ b/drivers/char/genrtc.c
29437 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
29438 switch (cmd) {
29439
29440 case RTC_PLL_GET:
29441 + memset(&pll, 0, sizeof(pll));
29442 if (get_rtc_pll(&pll))
29443 return -EINVAL;
29444 else
29445 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
29446 index 0833896..cccce52 100644
29447 --- a/drivers/char/hpet.c
29448 +++ b/drivers/char/hpet.c
29449 @@ -572,7 +572,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
29450 }
29451
29452 static int
29453 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
29454 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
29455 struct hpet_info *info)
29456 {
29457 struct hpet_timer __iomem *timer;
29458 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
29459 index 58c0e63..46c16bf 100644
29460 --- a/drivers/char/ipmi/ipmi_msghandler.c
29461 +++ b/drivers/char/ipmi/ipmi_msghandler.c
29462 @@ -415,7 +415,7 @@ struct ipmi_smi {
29463 struct proc_dir_entry *proc_dir;
29464 char proc_dir_name[10];
29465
29466 - atomic_t stats[IPMI_NUM_STATS];
29467 + atomic_unchecked_t stats[IPMI_NUM_STATS];
29468
29469 /*
29470 * run_to_completion duplicate of smb_info, smi_info
29471 @@ -448,9 +448,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
29472
29473
29474 #define ipmi_inc_stat(intf, stat) \
29475 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
29476 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
29477 #define ipmi_get_stat(intf, stat) \
29478 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
29479 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
29480
29481 static int is_lan_addr(struct ipmi_addr *addr)
29482 {
29483 @@ -2868,7 +2868,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
29484 INIT_LIST_HEAD(&intf->cmd_rcvrs);
29485 init_waitqueue_head(&intf->waitq);
29486 for (i = 0; i < IPMI_NUM_STATS; i++)
29487 - atomic_set(&intf->stats[i], 0);
29488 + atomic_set_unchecked(&intf->stats[i], 0);
29489
29490 intf->proc_dir = NULL;
29491
29492 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
29493 index 50fcf9c..91b5528 100644
29494 --- a/drivers/char/ipmi/ipmi_si_intf.c
29495 +++ b/drivers/char/ipmi/ipmi_si_intf.c
29496 @@ -277,7 +277,7 @@ struct smi_info {
29497 unsigned char slave_addr;
29498
29499 /* Counters and things for the proc filesystem. */
29500 - atomic_t stats[SI_NUM_STATS];
29501 + atomic_unchecked_t stats[SI_NUM_STATS];
29502
29503 struct task_struct *thread;
29504
29505 @@ -286,9 +286,9 @@ struct smi_info {
29506 };
29507
29508 #define smi_inc_stat(smi, stat) \
29509 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
29510 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
29511 #define smi_get_stat(smi, stat) \
29512 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
29513 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
29514
29515 #define SI_MAX_PARMS 4
29516
29517 @@ -3230,7 +3230,7 @@ static int try_smi_init(struct smi_info *new_smi)
29518 atomic_set(&new_smi->req_events, 0);
29519 new_smi->run_to_completion = 0;
29520 for (i = 0; i < SI_NUM_STATS; i++)
29521 - atomic_set(&new_smi->stats[i], 0);
29522 + atomic_set_unchecked(&new_smi->stats[i], 0);
29523
29524 new_smi->interrupt_disabled = 1;
29525 atomic_set(&new_smi->stop_operation, 0);
29526 diff --git a/drivers/char/mbcs.c b/drivers/char/mbcs.c
29527 index 1aeaaba..e018570 100644
29528 --- a/drivers/char/mbcs.c
29529 +++ b/drivers/char/mbcs.c
29530 @@ -800,7 +800,7 @@ static int mbcs_remove(struct cx_dev *dev)
29531 return 0;
29532 }
29533
29534 -static const struct cx_device_id __devinitdata mbcs_id_table[] = {
29535 +static const struct cx_device_id __devinitconst mbcs_id_table[] = {
29536 {
29537 .part_num = MBCS_PART_NUM,
29538 .mfg_num = MBCS_MFG_NUM,
29539 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
29540 index d6e9d08..4493e89 100644
29541 --- a/drivers/char/mem.c
29542 +++ b/drivers/char/mem.c
29543 @@ -18,6 +18,7 @@
29544 #include <linux/raw.h>
29545 #include <linux/tty.h>
29546 #include <linux/capability.h>
29547 +#include <linux/security.h>
29548 #include <linux/ptrace.h>
29549 #include <linux/device.h>
29550 #include <linux/highmem.h>
29551 @@ -35,6 +36,10 @@
29552 # include <linux/efi.h>
29553 #endif
29554
29555 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
29556 +extern const struct file_operations grsec_fops;
29557 +#endif
29558 +
29559 static inline unsigned long size_inside_page(unsigned long start,
29560 unsigned long size)
29561 {
29562 @@ -66,9 +71,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29563
29564 while (cursor < to) {
29565 if (!devmem_is_allowed(pfn)) {
29566 +#ifdef CONFIG_GRKERNSEC_KMEM
29567 + gr_handle_mem_readwrite(from, to);
29568 +#else
29569 printk(KERN_INFO
29570 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
29571 current->comm, from, to);
29572 +#endif
29573 return 0;
29574 }
29575 cursor += PAGE_SIZE;
29576 @@ -76,6 +85,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29577 }
29578 return 1;
29579 }
29580 +#elif defined(CONFIG_GRKERNSEC_KMEM)
29581 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29582 +{
29583 + return 0;
29584 +}
29585 #else
29586 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29587 {
29588 @@ -118,6 +132,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
29589
29590 while (count > 0) {
29591 unsigned long remaining;
29592 + char *temp;
29593
29594 sz = size_inside_page(p, count);
29595
29596 @@ -133,7 +148,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
29597 if (!ptr)
29598 return -EFAULT;
29599
29600 - remaining = copy_to_user(buf, ptr, sz);
29601 +#ifdef CONFIG_PAX_USERCOPY
29602 + temp = kmalloc(sz, GFP_KERNEL);
29603 + if (!temp) {
29604 + unxlate_dev_mem_ptr(p, ptr);
29605 + return -ENOMEM;
29606 + }
29607 + memcpy(temp, ptr, sz);
29608 +#else
29609 + temp = ptr;
29610 +#endif
29611 +
29612 + remaining = copy_to_user(buf, temp, sz);
29613 +
29614 +#ifdef CONFIG_PAX_USERCOPY
29615 + kfree(temp);
29616 +#endif
29617 +
29618 unxlate_dev_mem_ptr(p, ptr);
29619 if (remaining)
29620 return -EFAULT;
29621 @@ -396,9 +427,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
29622 size_t count, loff_t *ppos)
29623 {
29624 unsigned long p = *ppos;
29625 - ssize_t low_count, read, sz;
29626 + ssize_t low_count, read, sz, err = 0;
29627 char * kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
29628 - int err = 0;
29629
29630 read = 0;
29631 if (p < (unsigned long) high_memory) {
29632 @@ -420,6 +450,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
29633 }
29634 #endif
29635 while (low_count > 0) {
29636 + char *temp;
29637 +
29638 sz = size_inside_page(p, low_count);
29639
29640 /*
29641 @@ -429,7 +461,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
29642 */
29643 kbuf = xlate_dev_kmem_ptr((char *)p);
29644
29645 - if (copy_to_user(buf, kbuf, sz))
29646 +#ifdef CONFIG_PAX_USERCOPY
29647 + temp = kmalloc(sz, GFP_KERNEL);
29648 + if (!temp)
29649 + return -ENOMEM;
29650 + memcpy(temp, kbuf, sz);
29651 +#else
29652 + temp = kbuf;
29653 +#endif
29654 +
29655 + err = copy_to_user(buf, temp, sz);
29656 +
29657 +#ifdef CONFIG_PAX_USERCOPY
29658 + kfree(temp);
29659 +#endif
29660 +
29661 + if (err)
29662 return -EFAULT;
29663 buf += sz;
29664 p += sz;
29665 @@ -867,6 +914,9 @@ static const struct memdev {
29666 #ifdef CONFIG_CRASH_DUMP
29667 [12] = { "oldmem", 0, &oldmem_fops, NULL },
29668 #endif
29669 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
29670 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
29671 +#endif
29672 };
29673
29674 static int memory_open(struct inode *inode, struct file *filp)
29675 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
29676 index da3cfee..a5a6606 100644
29677 --- a/drivers/char/nvram.c
29678 +++ b/drivers/char/nvram.c
29679 @@ -248,7 +248,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
29680
29681 spin_unlock_irq(&rtc_lock);
29682
29683 - if (copy_to_user(buf, contents, tmp - contents))
29684 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
29685 return -EFAULT;
29686
29687 *ppos = i;
29688 diff --git a/drivers/char/random.c b/drivers/char/random.c
29689 index 54ca8b2..4a092ed 100644
29690 --- a/drivers/char/random.c
29691 +++ b/drivers/char/random.c
29692 @@ -261,8 +261,13 @@
29693 /*
29694 * Configuration information
29695 */
29696 +#ifdef CONFIG_GRKERNSEC_RANDNET
29697 +#define INPUT_POOL_WORDS 512
29698 +#define OUTPUT_POOL_WORDS 128
29699 +#else
29700 #define INPUT_POOL_WORDS 128
29701 #define OUTPUT_POOL_WORDS 32
29702 +#endif
29703 #define SEC_XFER_SIZE 512
29704 #define EXTRACT_SIZE 10
29705
29706 @@ -300,10 +305,17 @@ static struct poolinfo {
29707 int poolwords;
29708 int tap1, tap2, tap3, tap4, tap5;
29709 } poolinfo_table[] = {
29710 +#ifdef CONFIG_GRKERNSEC_RANDNET
29711 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
29712 + { 512, 411, 308, 208, 104, 1 },
29713 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
29714 + { 128, 103, 76, 51, 25, 1 },
29715 +#else
29716 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
29717 { 128, 103, 76, 51, 25, 1 },
29718 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
29719 { 32, 26, 20, 14, 7, 1 },
29720 +#endif
29721 #if 0
29722 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
29723 { 2048, 1638, 1231, 819, 411, 1 },
29724 @@ -913,7 +925,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
29725
29726 extract_buf(r, tmp);
29727 i = min_t(int, nbytes, EXTRACT_SIZE);
29728 - if (copy_to_user(buf, tmp, i)) {
29729 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
29730 ret = -EFAULT;
29731 break;
29732 }
29733 @@ -1238,7 +1250,7 @@ EXPORT_SYMBOL(generate_random_uuid);
29734 #include <linux/sysctl.h>
29735
29736 static int min_read_thresh = 8, min_write_thresh;
29737 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
29738 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
29739 static int max_write_thresh = INPUT_POOL_WORDS * 32;
29740 static char sysctl_bootid[16];
29741
29742 @@ -1260,10 +1272,15 @@ static int proc_do_uuid(ctl_table *table, int write,
29743 uuid = table->data;
29744 if (!uuid) {
29745 uuid = tmp_uuid;
29746 - uuid[8] = 0;
29747 - }
29748 - if (uuid[8] == 0)
29749 generate_random_uuid(uuid);
29750 + } else {
29751 + static DEFINE_SPINLOCK(bootid_spinlock);
29752 +
29753 + spin_lock(&bootid_spinlock);
29754 + if (!uuid[8])
29755 + generate_random_uuid(uuid);
29756 + spin_unlock(&bootid_spinlock);
29757 + }
29758
29759 sprintf(buf, "%pU", uuid);
29760
29761 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
29762 index 1ee8ce7..b778bef 100644
29763 --- a/drivers/char/sonypi.c
29764 +++ b/drivers/char/sonypi.c
29765 @@ -55,6 +55,7 @@
29766 #include <asm/uaccess.h>
29767 #include <asm/io.h>
29768 #include <asm/system.h>
29769 +#include <asm/local.h>
29770
29771 #include <linux/sonypi.h>
29772
29773 @@ -491,7 +492,7 @@ static struct sonypi_device {
29774 spinlock_t fifo_lock;
29775 wait_queue_head_t fifo_proc_list;
29776 struct fasync_struct *fifo_async;
29777 - int open_count;
29778 + local_t open_count;
29779 int model;
29780 struct input_dev *input_jog_dev;
29781 struct input_dev *input_key_dev;
29782 @@ -898,7 +899,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
29783 static int sonypi_misc_release(struct inode *inode, struct file *file)
29784 {
29785 mutex_lock(&sonypi_device.lock);
29786 - sonypi_device.open_count--;
29787 + local_dec(&sonypi_device.open_count);
29788 mutex_unlock(&sonypi_device.lock);
29789 return 0;
29790 }
29791 @@ -907,9 +908,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
29792 {
29793 mutex_lock(&sonypi_device.lock);
29794 /* Flush input queue on first open */
29795 - if (!sonypi_device.open_count)
29796 + if (!local_read(&sonypi_device.open_count))
29797 kfifo_reset(&sonypi_device.fifo);
29798 - sonypi_device.open_count++;
29799 + local_inc(&sonypi_device.open_count);
29800 mutex_unlock(&sonypi_device.lock);
29801
29802 return 0;
29803 diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
29804 index ad7c732..5aa8054 100644
29805 --- a/drivers/char/tpm/tpm.c
29806 +++ b/drivers/char/tpm/tpm.c
29807 @@ -415,7 +415,7 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
29808 chip->vendor.req_complete_val)
29809 goto out_recv;
29810
29811 - if ((status == chip->vendor.req_canceled)) {
29812 + if (status == chip->vendor.req_canceled) {
29813 dev_err(chip->dev, "Operation Canceled\n");
29814 rc = -ECANCELED;
29815 goto out;
29816 diff --git a/drivers/char/tpm/tpm_bios.c b/drivers/char/tpm/tpm_bios.c
29817 index 0636520..169c1d0 100644
29818 --- a/drivers/char/tpm/tpm_bios.c
29819 +++ b/drivers/char/tpm/tpm_bios.c
29820 @@ -173,7 +173,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
29821 event = addr;
29822
29823 if ((event->event_type == 0 && event->event_size == 0) ||
29824 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
29825 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
29826 return NULL;
29827
29828 return addr;
29829 @@ -198,7 +198,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
29830 return NULL;
29831
29832 if ((event->event_type == 0 && event->event_size == 0) ||
29833 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
29834 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
29835 return NULL;
29836
29837 (*pos)++;
29838 @@ -291,7 +291,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
29839 int i;
29840
29841 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
29842 - seq_putc(m, data[i]);
29843 + if (!seq_putc(m, data[i]))
29844 + return -EFAULT;
29845
29846 return 0;
29847 }
29848 @@ -410,8 +411,13 @@ static int read_log(struct tpm_bios_log *log)
29849 log->bios_event_log_end = log->bios_event_log + len;
29850
29851 virt = acpi_os_map_memory(start, len);
29852 + if (!virt) {
29853 + kfree(log->bios_event_log);
29854 + log->bios_event_log = NULL;
29855 + return -EFAULT;
29856 + }
29857
29858 - memcpy(log->bios_event_log, virt, len);
29859 + memcpy(log->bios_event_log, (const char __force_kernel *)virt, len);
29860
29861 acpi_os_unmap_memory(virt, len);
29862 return 0;
29863 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
29864 index 41fc148..0dba6dd 100644
29865 --- a/drivers/char/virtio_console.c
29866 +++ b/drivers/char/virtio_console.c
29867 @@ -563,7 +563,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
29868 if (to_user) {
29869 ssize_t ret;
29870
29871 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
29872 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
29873 if (ret)
29874 return -EFAULT;
29875 } else {
29876 @@ -662,7 +662,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
29877 if (!port_has_data(port) && !port->host_connected)
29878 return 0;
29879
29880 - return fill_readbuf(port, ubuf, count, true);
29881 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
29882 }
29883
29884 static ssize_t port_fops_write(struct file *filp, const char __user *ubuf,
29885 diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
29886 index c9eee6d..f9d5280 100644
29887 --- a/drivers/edac/amd64_edac.c
29888 +++ b/drivers/edac/amd64_edac.c
29889 @@ -2685,7 +2685,7 @@ static void __devexit amd64_remove_one_instance(struct pci_dev *pdev)
29890 * PCI core identifies what devices are on a system during boot, and then
29891 * inquiry this table to see if this driver is for a given device found.
29892 */
29893 -static const struct pci_device_id amd64_pci_table[] __devinitdata = {
29894 +static const struct pci_device_id amd64_pci_table[] __devinitconst = {
29895 {
29896 .vendor = PCI_VENDOR_ID_AMD,
29897 .device = PCI_DEVICE_ID_AMD_K8_NB_MEMCTL,
29898 diff --git a/drivers/edac/amd76x_edac.c b/drivers/edac/amd76x_edac.c
29899 index e47e73b..348e0bd 100644
29900 --- a/drivers/edac/amd76x_edac.c
29901 +++ b/drivers/edac/amd76x_edac.c
29902 @@ -321,7 +321,7 @@ static void __devexit amd76x_remove_one(struct pci_dev *pdev)
29903 edac_mc_free(mci);
29904 }
29905
29906 -static const struct pci_device_id amd76x_pci_tbl[] __devinitdata = {
29907 +static const struct pci_device_id amd76x_pci_tbl[] __devinitconst = {
29908 {
29909 PCI_VEND_DEV(AMD, FE_GATE_700C), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
29910 AMD762},
29911 diff --git a/drivers/edac/e752x_edac.c b/drivers/edac/e752x_edac.c
29912 index 1af531a..3a8ff27 100644
29913 --- a/drivers/edac/e752x_edac.c
29914 +++ b/drivers/edac/e752x_edac.c
29915 @@ -1380,7 +1380,7 @@ static void __devexit e752x_remove_one(struct pci_dev *pdev)
29916 edac_mc_free(mci);
29917 }
29918
29919 -static const struct pci_device_id e752x_pci_tbl[] __devinitdata = {
29920 +static const struct pci_device_id e752x_pci_tbl[] __devinitconst = {
29921 {
29922 PCI_VEND_DEV(INTEL, 7520_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
29923 E7520},
29924 diff --git a/drivers/edac/e7xxx_edac.c b/drivers/edac/e7xxx_edac.c
29925 index 6ffb6d2..383d8d7 100644
29926 --- a/drivers/edac/e7xxx_edac.c
29927 +++ b/drivers/edac/e7xxx_edac.c
29928 @@ -525,7 +525,7 @@ static void __devexit e7xxx_remove_one(struct pci_dev *pdev)
29929 edac_mc_free(mci);
29930 }
29931
29932 -static const struct pci_device_id e7xxx_pci_tbl[] __devinitdata = {
29933 +static const struct pci_device_id e7xxx_pci_tbl[] __devinitconst = {
29934 {
29935 PCI_VEND_DEV(INTEL, 7205_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
29936 E7205},
29937 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
29938 index 97f5064..202b6e6 100644
29939 --- a/drivers/edac/edac_pci_sysfs.c
29940 +++ b/drivers/edac/edac_pci_sysfs.c
29941 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
29942 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
29943 static int edac_pci_poll_msec = 1000; /* one second workq period */
29944
29945 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
29946 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
29947 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
29948 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
29949
29950 static struct kobject *edac_pci_top_main_kobj;
29951 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
29952 @@ -582,7 +582,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
29953 edac_printk(KERN_CRIT, EDAC_PCI,
29954 "Signaled System Error on %s\n",
29955 pci_name(dev));
29956 - atomic_inc(&pci_nonparity_count);
29957 + atomic_inc_unchecked(&pci_nonparity_count);
29958 }
29959
29960 if (status & (PCI_STATUS_PARITY)) {
29961 @@ -590,7 +590,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
29962 "Master Data Parity Error on %s\n",
29963 pci_name(dev));
29964
29965 - atomic_inc(&pci_parity_count);
29966 + atomic_inc_unchecked(&pci_parity_count);
29967 }
29968
29969 if (status & (PCI_STATUS_DETECTED_PARITY)) {
29970 @@ -598,7 +598,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
29971 "Detected Parity Error on %s\n",
29972 pci_name(dev));
29973
29974 - atomic_inc(&pci_parity_count);
29975 + atomic_inc_unchecked(&pci_parity_count);
29976 }
29977 }
29978
29979 @@ -619,7 +619,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
29980 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
29981 "Signaled System Error on %s\n",
29982 pci_name(dev));
29983 - atomic_inc(&pci_nonparity_count);
29984 + atomic_inc_unchecked(&pci_nonparity_count);
29985 }
29986
29987 if (status & (PCI_STATUS_PARITY)) {
29988 @@ -627,7 +627,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
29989 "Master Data Parity Error on "
29990 "%s\n", pci_name(dev));
29991
29992 - atomic_inc(&pci_parity_count);
29993 + atomic_inc_unchecked(&pci_parity_count);
29994 }
29995
29996 if (status & (PCI_STATUS_DETECTED_PARITY)) {
29997 @@ -635,7 +635,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
29998 "Detected Parity Error on %s\n",
29999 pci_name(dev));
30000
30001 - atomic_inc(&pci_parity_count);
30002 + atomic_inc_unchecked(&pci_parity_count);
30003 }
30004 }
30005 }
30006 @@ -677,7 +677,7 @@ void edac_pci_do_parity_check(void)
30007 if (!check_pci_errors)
30008 return;
30009
30010 - before_count = atomic_read(&pci_parity_count);
30011 + before_count = atomic_read_unchecked(&pci_parity_count);
30012
30013 /* scan all PCI devices looking for a Parity Error on devices and
30014 * bridges.
30015 @@ -689,7 +689,7 @@ void edac_pci_do_parity_check(void)
30016 /* Only if operator has selected panic on PCI Error */
30017 if (edac_pci_get_panic_on_pe()) {
30018 /* If the count is different 'after' from 'before' */
30019 - if (before_count != atomic_read(&pci_parity_count))
30020 + if (before_count != atomic_read_unchecked(&pci_parity_count))
30021 panic("EDAC: PCI Parity Error");
30022 }
30023 }
30024 diff --git a/drivers/edac/i3000_edac.c b/drivers/edac/i3000_edac.c
30025 index c0510b3..6e2a954 100644
30026 --- a/drivers/edac/i3000_edac.c
30027 +++ b/drivers/edac/i3000_edac.c
30028 @@ -470,7 +470,7 @@ static void __devexit i3000_remove_one(struct pci_dev *pdev)
30029 edac_mc_free(mci);
30030 }
30031
30032 -static const struct pci_device_id i3000_pci_tbl[] __devinitdata = {
30033 +static const struct pci_device_id i3000_pci_tbl[] __devinitconst = {
30034 {
30035 PCI_VEND_DEV(INTEL, 3000_HB), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
30036 I3000},
30037 diff --git a/drivers/edac/i3200_edac.c b/drivers/edac/i3200_edac.c
30038 index 73f55e200..5faaf59 100644
30039 --- a/drivers/edac/i3200_edac.c
30040 +++ b/drivers/edac/i3200_edac.c
30041 @@ -445,7 +445,7 @@ static void __devexit i3200_remove_one(struct pci_dev *pdev)
30042 edac_mc_free(mci);
30043 }
30044
30045 -static const struct pci_device_id i3200_pci_tbl[] __devinitdata = {
30046 +static const struct pci_device_id i3200_pci_tbl[] __devinitconst = {
30047 {
30048 PCI_VEND_DEV(INTEL, 3200_HB), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
30049 I3200},
30050 diff --git a/drivers/edac/i5000_edac.c b/drivers/edac/i5000_edac.c
30051 index 4dc3ac2..67d05a6 100644
30052 --- a/drivers/edac/i5000_edac.c
30053 +++ b/drivers/edac/i5000_edac.c
30054 @@ -1516,7 +1516,7 @@ static void __devexit i5000_remove_one(struct pci_dev *pdev)
30055 *
30056 * The "E500P" device is the first device supported.
30057 */
30058 -static const struct pci_device_id i5000_pci_tbl[] __devinitdata = {
30059 +static const struct pci_device_id i5000_pci_tbl[] __devinitconst = {
30060 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_I5000_DEV16),
30061 .driver_data = I5000P},
30062
30063 diff --git a/drivers/edac/i5100_edac.c b/drivers/edac/i5100_edac.c
30064 index bcbdeec..9886d16 100644
30065 --- a/drivers/edac/i5100_edac.c
30066 +++ b/drivers/edac/i5100_edac.c
30067 @@ -1051,7 +1051,7 @@ static void __devexit i5100_remove_one(struct pci_dev *pdev)
30068 edac_mc_free(mci);
30069 }
30070
30071 -static const struct pci_device_id i5100_pci_tbl[] __devinitdata = {
30072 +static const struct pci_device_id i5100_pci_tbl[] __devinitconst = {
30073 /* Device 16, Function 0, Channel 0 Memory Map, Error Flag/Mask, ... */
30074 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5100_16) },
30075 { 0, }
30076 diff --git a/drivers/edac/i5400_edac.c b/drivers/edac/i5400_edac.c
30077 index 74d6ec34..baff517 100644
30078 --- a/drivers/edac/i5400_edac.c
30079 +++ b/drivers/edac/i5400_edac.c
30080 @@ -1383,7 +1383,7 @@ static void __devexit i5400_remove_one(struct pci_dev *pdev)
30081 *
30082 * The "E500P" device is the first device supported.
30083 */
30084 -static const struct pci_device_id i5400_pci_tbl[] __devinitdata = {
30085 +static const struct pci_device_id i5400_pci_tbl[] __devinitconst = {
30086 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5400_ERR)},
30087 {0,} /* 0 terminated list. */
30088 };
30089 diff --git a/drivers/edac/i7300_edac.c b/drivers/edac/i7300_edac.c
30090 index 6104dba..e7ea8e1 100644
30091 --- a/drivers/edac/i7300_edac.c
30092 +++ b/drivers/edac/i7300_edac.c
30093 @@ -1192,7 +1192,7 @@ static void __devexit i7300_remove_one(struct pci_dev *pdev)
30094 *
30095 * Has only 8086:360c PCI ID
30096 */
30097 -static const struct pci_device_id i7300_pci_tbl[] __devinitdata = {
30098 +static const struct pci_device_id i7300_pci_tbl[] __devinitconst = {
30099 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_I7300_MCH_ERR)},
30100 {0,} /* 0 terminated list. */
30101 };
30102 diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
30103 index 8568d9b..42b2fa8 100644
30104 --- a/drivers/edac/i7core_edac.c
30105 +++ b/drivers/edac/i7core_edac.c
30106 @@ -391,7 +391,7 @@ static const struct pci_id_table pci_dev_table[] = {
30107 /*
30108 * pci_device_id table for which devices we are looking for
30109 */
30110 -static const struct pci_device_id i7core_pci_tbl[] __devinitdata = {
30111 +static const struct pci_device_id i7core_pci_tbl[] __devinitconst = {
30112 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_X58_HUB_MGMT)},
30113 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_LYNNFIELD_QPI_LINK0)},
30114 {0,} /* 0 terminated list. */
30115 diff --git a/drivers/edac/i82443bxgx_edac.c b/drivers/edac/i82443bxgx_edac.c
30116 index 4329d39..f3022ef 100644
30117 --- a/drivers/edac/i82443bxgx_edac.c
30118 +++ b/drivers/edac/i82443bxgx_edac.c
30119 @@ -380,7 +380,7 @@ static void __devexit i82443bxgx_edacmc_remove_one(struct pci_dev *pdev)
30120
30121 EXPORT_SYMBOL_GPL(i82443bxgx_edacmc_remove_one);
30122
30123 -static const struct pci_device_id i82443bxgx_pci_tbl[] __devinitdata = {
30124 +static const struct pci_device_id i82443bxgx_pci_tbl[] __devinitconst = {
30125 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443BX_0)},
30126 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443BX_2)},
30127 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443GX_0)},
30128 diff --git a/drivers/edac/i82860_edac.c b/drivers/edac/i82860_edac.c
30129 index 931a057..fd28340 100644
30130 --- a/drivers/edac/i82860_edac.c
30131 +++ b/drivers/edac/i82860_edac.c
30132 @@ -270,7 +270,7 @@ static void __devexit i82860_remove_one(struct pci_dev *pdev)
30133 edac_mc_free(mci);
30134 }
30135
30136 -static const struct pci_device_id i82860_pci_tbl[] __devinitdata = {
30137 +static const struct pci_device_id i82860_pci_tbl[] __devinitconst = {
30138 {
30139 PCI_VEND_DEV(INTEL, 82860_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
30140 I82860},
30141 diff --git a/drivers/edac/i82875p_edac.c b/drivers/edac/i82875p_edac.c
30142 index 33864c6..01edc61 100644
30143 --- a/drivers/edac/i82875p_edac.c
30144 +++ b/drivers/edac/i82875p_edac.c
30145 @@ -511,7 +511,7 @@ static void __devexit i82875p_remove_one(struct pci_dev *pdev)
30146 edac_mc_free(mci);
30147 }
30148
30149 -static const struct pci_device_id i82875p_pci_tbl[] __devinitdata = {
30150 +static const struct pci_device_id i82875p_pci_tbl[] __devinitconst = {
30151 {
30152 PCI_VEND_DEV(INTEL, 82875_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
30153 I82875P},
30154 diff --git a/drivers/edac/i82975x_edac.c b/drivers/edac/i82975x_edac.c
30155 index 4184e01..dcb2cd3 100644
30156 --- a/drivers/edac/i82975x_edac.c
30157 +++ b/drivers/edac/i82975x_edac.c
30158 @@ -612,7 +612,7 @@ static void __devexit i82975x_remove_one(struct pci_dev *pdev)
30159 edac_mc_free(mci);
30160 }
30161
30162 -static const struct pci_device_id i82975x_pci_tbl[] __devinitdata = {
30163 +static const struct pci_device_id i82975x_pci_tbl[] __devinitconst = {
30164 {
30165 PCI_VEND_DEV(INTEL, 82975_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
30166 I82975X
30167 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
30168 index 0106747..0b40417 100644
30169 --- a/drivers/edac/mce_amd.h
30170 +++ b/drivers/edac/mce_amd.h
30171 @@ -83,7 +83,7 @@ struct amd_decoder_ops {
30172 bool (*dc_mce)(u16, u8);
30173 bool (*ic_mce)(u16, u8);
30174 bool (*nb_mce)(u16, u8);
30175 -};
30176 +} __no_const;
30177
30178 void amd_report_gart_errors(bool);
30179 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
30180 diff --git a/drivers/edac/r82600_edac.c b/drivers/edac/r82600_edac.c
30181 index e294e1b..a41b05b 100644
30182 --- a/drivers/edac/r82600_edac.c
30183 +++ b/drivers/edac/r82600_edac.c
30184 @@ -373,7 +373,7 @@ static void __devexit r82600_remove_one(struct pci_dev *pdev)
30185 edac_mc_free(mci);
30186 }
30187
30188 -static const struct pci_device_id r82600_pci_tbl[] __devinitdata = {
30189 +static const struct pci_device_id r82600_pci_tbl[] __devinitconst = {
30190 {
30191 PCI_DEVICE(PCI_VENDOR_ID_RADISYS, R82600_BRIDGE_ID)
30192 },
30193 diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
30194 index 1dc118d..8c68af9 100644
30195 --- a/drivers/edac/sb_edac.c
30196 +++ b/drivers/edac/sb_edac.c
30197 @@ -367,7 +367,7 @@ static const struct pci_id_table pci_dev_descr_sbridge_table[] = {
30198 /*
30199 * pci_device_id table for which devices we are looking for
30200 */
30201 -static const struct pci_device_id sbridge_pci_tbl[] __devinitdata = {
30202 +static const struct pci_device_id sbridge_pci_tbl[] __devinitconst = {
30203 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TA)},
30204 {0,} /* 0 terminated list. */
30205 };
30206 diff --git a/drivers/edac/x38_edac.c b/drivers/edac/x38_edac.c
30207 index b6f47de..c5acf3a 100644
30208 --- a/drivers/edac/x38_edac.c
30209 +++ b/drivers/edac/x38_edac.c
30210 @@ -440,7 +440,7 @@ static void __devexit x38_remove_one(struct pci_dev *pdev)
30211 edac_mc_free(mci);
30212 }
30213
30214 -static const struct pci_device_id x38_pci_tbl[] __devinitdata = {
30215 +static const struct pci_device_id x38_pci_tbl[] __devinitconst = {
30216 {
30217 PCI_VEND_DEV(INTEL, X38_HB), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
30218 X38},
30219 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
30220 index 85661b0..c784559a 100644
30221 --- a/drivers/firewire/core-card.c
30222 +++ b/drivers/firewire/core-card.c
30223 @@ -657,7 +657,7 @@ void fw_card_release(struct kref *kref)
30224
30225 void fw_core_remove_card(struct fw_card *card)
30226 {
30227 - struct fw_card_driver dummy_driver = dummy_driver_template;
30228 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
30229
30230 card->driver->update_phy_reg(card, 4,
30231 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
30232 diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
30233 index 4799393..37bd3ab 100644
30234 --- a/drivers/firewire/core-cdev.c
30235 +++ b/drivers/firewire/core-cdev.c
30236 @@ -1331,8 +1331,7 @@ static int init_iso_resource(struct client *client,
30237 int ret;
30238
30239 if ((request->channels == 0 && request->bandwidth == 0) ||
30240 - request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL ||
30241 - request->bandwidth < 0)
30242 + request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL)
30243 return -EINVAL;
30244
30245 r = kmalloc(sizeof(*r), GFP_KERNEL);
30246 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
30247 index 855ab3f..11f4bbd 100644
30248 --- a/drivers/firewire/core-transaction.c
30249 +++ b/drivers/firewire/core-transaction.c
30250 @@ -37,6 +37,7 @@
30251 #include <linux/timer.h>
30252 #include <linux/types.h>
30253 #include <linux/workqueue.h>
30254 +#include <linux/sched.h>
30255
30256 #include <asm/byteorder.h>
30257
30258 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
30259 index b45be57..5fad18b 100644
30260 --- a/drivers/firewire/core.h
30261 +++ b/drivers/firewire/core.h
30262 @@ -101,6 +101,7 @@ struct fw_card_driver {
30263
30264 int (*stop_iso)(struct fw_iso_context *ctx);
30265 };
30266 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
30267
30268 void fw_card_initialize(struct fw_card *card,
30269 const struct fw_card_driver *driver, struct device *device);
30270 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
30271 index 153980b..4b4d046 100644
30272 --- a/drivers/firmware/dmi_scan.c
30273 +++ b/drivers/firmware/dmi_scan.c
30274 @@ -449,11 +449,6 @@ void __init dmi_scan_machine(void)
30275 }
30276 }
30277 else {
30278 - /*
30279 - * no iounmap() for that ioremap(); it would be a no-op, but
30280 - * it's so early in setup that sucker gets confused into doing
30281 - * what it shouldn't if we actually call it.
30282 - */
30283 p = dmi_ioremap(0xF0000, 0x10000);
30284 if (p == NULL)
30285 goto error;
30286 @@ -723,7 +718,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
30287 if (buf == NULL)
30288 return -1;
30289
30290 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
30291 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
30292
30293 iounmap(buf);
30294 return 0;
30295 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
30296 index 82d5c20..44a7177 100644
30297 --- a/drivers/gpio/gpio-vr41xx.c
30298 +++ b/drivers/gpio/gpio-vr41xx.c
30299 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
30300 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
30301 maskl, pendl, maskh, pendh);
30302
30303 - atomic_inc(&irq_err_count);
30304 + atomic_inc_unchecked(&irq_err_count);
30305
30306 return -EINVAL;
30307 }
30308 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
30309 index 84a4a80..ce0306e 100644
30310 --- a/drivers/gpu/drm/drm_crtc_helper.c
30311 +++ b/drivers/gpu/drm/drm_crtc_helper.c
30312 @@ -280,7 +280,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
30313 struct drm_crtc *tmp;
30314 int crtc_mask = 1;
30315
30316 - WARN(!crtc, "checking null crtc?\n");
30317 + BUG_ON(!crtc);
30318
30319 dev = crtc->dev;
30320
30321 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
30322 index ebf7d3f..d64c436 100644
30323 --- a/drivers/gpu/drm/drm_drv.c
30324 +++ b/drivers/gpu/drm/drm_drv.c
30325 @@ -312,7 +312,7 @@ module_exit(drm_core_exit);
30326 /**
30327 * Copy and IOCTL return string to user space
30328 */
30329 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
30330 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
30331 {
30332 int len;
30333
30334 @@ -391,7 +391,7 @@ long drm_ioctl(struct file *filp,
30335
30336 dev = file_priv->minor->dev;
30337 atomic_inc(&dev->ioctl_count);
30338 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
30339 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
30340 ++file_priv->ioctl_count;
30341
30342 DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
30343 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
30344 index 6263b01..7987f55 100644
30345 --- a/drivers/gpu/drm/drm_fops.c
30346 +++ b/drivers/gpu/drm/drm_fops.c
30347 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
30348 }
30349
30350 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
30351 - atomic_set(&dev->counts[i], 0);
30352 + atomic_set_unchecked(&dev->counts[i], 0);
30353
30354 dev->sigdata.lock = NULL;
30355
30356 @@ -135,8 +135,8 @@ int drm_open(struct inode *inode, struct file *filp)
30357
30358 retcode = drm_open_helper(inode, filp, dev);
30359 if (!retcode) {
30360 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
30361 - if (!dev->open_count++)
30362 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
30363 + if (local_inc_return(&dev->open_count) == 1)
30364 retcode = drm_setup(dev);
30365 }
30366 if (!retcode) {
30367 @@ -473,7 +473,7 @@ int drm_release(struct inode *inode, struct file *filp)
30368
30369 mutex_lock(&drm_global_mutex);
30370
30371 - DRM_DEBUG("open_count = %d\n", dev->open_count);
30372 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
30373
30374 if (dev->driver->preclose)
30375 dev->driver->preclose(dev, file_priv);
30376 @@ -482,10 +482,10 @@ int drm_release(struct inode *inode, struct file *filp)
30377 * Begin inline drm_release
30378 */
30379
30380 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
30381 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
30382 task_pid_nr(current),
30383 (long)old_encode_dev(file_priv->minor->device),
30384 - dev->open_count);
30385 + local_read(&dev->open_count));
30386
30387 /* Release any auth tokens that might point to this file_priv,
30388 (do that under the drm_global_mutex) */
30389 @@ -571,8 +571,8 @@ int drm_release(struct inode *inode, struct file *filp)
30390 * End inline drm_release
30391 */
30392
30393 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
30394 - if (!--dev->open_count) {
30395 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
30396 + if (local_dec_and_test(&dev->open_count)) {
30397 if (atomic_read(&dev->ioctl_count)) {
30398 DRM_ERROR("Device busy: %d\n",
30399 atomic_read(&dev->ioctl_count));
30400 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
30401 index c87dc96..326055d 100644
30402 --- a/drivers/gpu/drm/drm_global.c
30403 +++ b/drivers/gpu/drm/drm_global.c
30404 @@ -36,7 +36,7 @@
30405 struct drm_global_item {
30406 struct mutex mutex;
30407 void *object;
30408 - int refcount;
30409 + atomic_t refcount;
30410 };
30411
30412 static struct drm_global_item glob[DRM_GLOBAL_NUM];
30413 @@ -49,7 +49,7 @@ void drm_global_init(void)
30414 struct drm_global_item *item = &glob[i];
30415 mutex_init(&item->mutex);
30416 item->object = NULL;
30417 - item->refcount = 0;
30418 + atomic_set(&item->refcount, 0);
30419 }
30420 }
30421
30422 @@ -59,7 +59,7 @@ void drm_global_release(void)
30423 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
30424 struct drm_global_item *item = &glob[i];
30425 BUG_ON(item->object != NULL);
30426 - BUG_ON(item->refcount != 0);
30427 + BUG_ON(atomic_read(&item->refcount) != 0);
30428 }
30429 }
30430
30431 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
30432 void *object;
30433
30434 mutex_lock(&item->mutex);
30435 - if (item->refcount == 0) {
30436 + if (atomic_read(&item->refcount) == 0) {
30437 item->object = kzalloc(ref->size, GFP_KERNEL);
30438 if (unlikely(item->object == NULL)) {
30439 ret = -ENOMEM;
30440 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
30441 goto out_err;
30442
30443 }
30444 - ++item->refcount;
30445 + atomic_inc(&item->refcount);
30446 ref->object = item->object;
30447 object = item->object;
30448 mutex_unlock(&item->mutex);
30449 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
30450 struct drm_global_item *item = &glob[ref->global_type];
30451
30452 mutex_lock(&item->mutex);
30453 - BUG_ON(item->refcount == 0);
30454 + BUG_ON(atomic_read(&item->refcount) == 0);
30455 BUG_ON(ref->object != item->object);
30456 - if (--item->refcount == 0) {
30457 + if (atomic_dec_and_test(&item->refcount)) {
30458 ref->release(ref);
30459 item->object = NULL;
30460 }
30461 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
30462 index ab1162d..42587b2 100644
30463 --- a/drivers/gpu/drm/drm_info.c
30464 +++ b/drivers/gpu/drm/drm_info.c
30465 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
30466 struct drm_local_map *map;
30467 struct drm_map_list *r_list;
30468
30469 - /* Hardcoded from _DRM_FRAME_BUFFER,
30470 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
30471 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
30472 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
30473 + static const char * const types[] = {
30474 + [_DRM_FRAME_BUFFER] = "FB",
30475 + [_DRM_REGISTERS] = "REG",
30476 + [_DRM_SHM] = "SHM",
30477 + [_DRM_AGP] = "AGP",
30478 + [_DRM_SCATTER_GATHER] = "SG",
30479 + [_DRM_CONSISTENT] = "PCI",
30480 + [_DRM_GEM] = "GEM" };
30481 const char *type;
30482 int i;
30483
30484 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
30485 map = r_list->map;
30486 if (!map)
30487 continue;
30488 - if (map->type < 0 || map->type > 5)
30489 + if (map->type >= ARRAY_SIZE(types))
30490 type = "??";
30491 else
30492 type = types[map->type];
30493 @@ -290,7 +294,11 @@ int drm_vma_info(struct seq_file *m, void *data)
30494 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
30495 vma->vm_flags & VM_LOCKED ? 'l' : '-',
30496 vma->vm_flags & VM_IO ? 'i' : '-',
30497 +#ifdef CONFIG_GRKERNSEC_HIDESYM
30498 + 0);
30499 +#else
30500 vma->vm_pgoff);
30501 +#endif
30502
30503 #if defined(__i386__)
30504 pgprot = pgprot_val(vma->vm_page_prot);
30505 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
30506 index 637fcc3..e890b33 100644
30507 --- a/drivers/gpu/drm/drm_ioc32.c
30508 +++ b/drivers/gpu/drm/drm_ioc32.c
30509 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
30510 request = compat_alloc_user_space(nbytes);
30511 if (!access_ok(VERIFY_WRITE, request, nbytes))
30512 return -EFAULT;
30513 - list = (struct drm_buf_desc *) (request + 1);
30514 + list = (struct drm_buf_desc __user *) (request + 1);
30515
30516 if (__put_user(count, &request->count)
30517 || __put_user(list, &request->list))
30518 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
30519 request = compat_alloc_user_space(nbytes);
30520 if (!access_ok(VERIFY_WRITE, request, nbytes))
30521 return -EFAULT;
30522 - list = (struct drm_buf_pub *) (request + 1);
30523 + list = (struct drm_buf_pub __user *) (request + 1);
30524
30525 if (__put_user(count, &request->count)
30526 || __put_user(list, &request->list))
30527 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
30528 index 956fd38..e52167a 100644
30529 --- a/drivers/gpu/drm/drm_ioctl.c
30530 +++ b/drivers/gpu/drm/drm_ioctl.c
30531 @@ -251,7 +251,7 @@ int drm_getstats(struct drm_device *dev, void *data,
30532 stats->data[i].value =
30533 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
30534 else
30535 - stats->data[i].value = atomic_read(&dev->counts[i]);
30536 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
30537 stats->data[i].type = dev->types[i];
30538 }
30539
30540 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
30541 index c79c713..2048588 100644
30542 --- a/drivers/gpu/drm/drm_lock.c
30543 +++ b/drivers/gpu/drm/drm_lock.c
30544 @@ -90,7 +90,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
30545 if (drm_lock_take(&master->lock, lock->context)) {
30546 master->lock.file_priv = file_priv;
30547 master->lock.lock_time = jiffies;
30548 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
30549 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
30550 break; /* Got lock */
30551 }
30552
30553 @@ -161,7 +161,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
30554 return -EINVAL;
30555 }
30556
30557 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
30558 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
30559
30560 if (drm_lock_free(&master->lock, lock->context)) {
30561 /* FIXME: Should really bail out here. */
30562 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
30563 index 7f4b4e1..bf4def2 100644
30564 --- a/drivers/gpu/drm/i810/i810_dma.c
30565 +++ b/drivers/gpu/drm/i810/i810_dma.c
30566 @@ -948,8 +948,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
30567 dma->buflist[vertex->idx],
30568 vertex->discard, vertex->used);
30569
30570 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
30571 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
30572 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
30573 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
30574 sarea_priv->last_enqueue = dev_priv->counter - 1;
30575 sarea_priv->last_dispatch = (int)hw_status[5];
30576
30577 @@ -1109,8 +1109,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
30578 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
30579 mc->last_render);
30580
30581 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
30582 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
30583 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
30584 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
30585 sarea_priv->last_enqueue = dev_priv->counter - 1;
30586 sarea_priv->last_dispatch = (int)hw_status[5];
30587
30588 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
30589 index c9339f4..f5e1b9d 100644
30590 --- a/drivers/gpu/drm/i810/i810_drv.h
30591 +++ b/drivers/gpu/drm/i810/i810_drv.h
30592 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
30593 int page_flipping;
30594
30595 wait_queue_head_t irq_queue;
30596 - atomic_t irq_received;
30597 - atomic_t irq_emitted;
30598 + atomic_unchecked_t irq_received;
30599 + atomic_unchecked_t irq_emitted;
30600
30601 int front_offset;
30602 } drm_i810_private_t;
30603 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
30604 index deaa657..e0fd296 100644
30605 --- a/drivers/gpu/drm/i915/i915_debugfs.c
30606 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
30607 @@ -499,7 +499,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
30608 I915_READ(GTIMR));
30609 }
30610 seq_printf(m, "Interrupts received: %d\n",
30611 - atomic_read(&dev_priv->irq_received));
30612 + atomic_read_unchecked(&dev_priv->irq_received));
30613 for (i = 0; i < I915_NUM_RINGS; i++) {
30614 if (IS_GEN6(dev) || IS_GEN7(dev)) {
30615 seq_printf(m, "Graphics Interrupt mask (%s): %08x\n",
30616 @@ -1321,7 +1321,7 @@ static int i915_opregion(struct seq_file *m, void *unused)
30617 return ret;
30618
30619 if (opregion->header)
30620 - seq_write(m, opregion->header, OPREGION_SIZE);
30621 + seq_write(m, (const void __force_kernel *)opregion->header, OPREGION_SIZE);
30622
30623 mutex_unlock(&dev->struct_mutex);
30624
30625 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
30626 index ddfe3d9..f6e6b21 100644
30627 --- a/drivers/gpu/drm/i915/i915_dma.c
30628 +++ b/drivers/gpu/drm/i915/i915_dma.c
30629 @@ -1175,7 +1175,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
30630 bool can_switch;
30631
30632 spin_lock(&dev->count_lock);
30633 - can_switch = (dev->open_count == 0);
30634 + can_switch = (local_read(&dev->open_count) == 0);
30635 spin_unlock(&dev->count_lock);
30636 return can_switch;
30637 }
30638 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
30639 index 9689ca3..294f9c1 100644
30640 --- a/drivers/gpu/drm/i915/i915_drv.h
30641 +++ b/drivers/gpu/drm/i915/i915_drv.h
30642 @@ -231,7 +231,7 @@ struct drm_i915_display_funcs {
30643 /* render clock increase/decrease */
30644 /* display clock increase/decrease */
30645 /* pll clock increase/decrease */
30646 -};
30647 +} __no_const;
30648
30649 struct intel_device_info {
30650 u8 gen;
30651 @@ -320,7 +320,7 @@ typedef struct drm_i915_private {
30652 int current_page;
30653 int page_flipping;
30654
30655 - atomic_t irq_received;
30656 + atomic_unchecked_t irq_received;
30657
30658 /* protects the irq masks */
30659 spinlock_t irq_lock;
30660 @@ -896,7 +896,7 @@ struct drm_i915_gem_object {
30661 * will be page flipped away on the next vblank. When it
30662 * reaches 0, dev_priv->pending_flip_queue will be woken up.
30663 */
30664 - atomic_t pending_flip;
30665 + atomic_unchecked_t pending_flip;
30666 };
30667
30668 #define to_intel_bo(x) container_of(x, struct drm_i915_gem_object, base)
30669 @@ -1276,7 +1276,7 @@ extern int intel_setup_gmbus(struct drm_device *dev);
30670 extern void intel_teardown_gmbus(struct drm_device *dev);
30671 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
30672 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
30673 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
30674 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
30675 {
30676 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
30677 }
30678 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
30679 index e159e33..cdcc663 100644
30680 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
30681 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
30682 @@ -189,7 +189,7 @@ i915_gem_object_set_to_gpu_domain(struct drm_i915_gem_object *obj,
30683 i915_gem_clflush_object(obj);
30684
30685 if (obj->base.pending_write_domain)
30686 - cd->flips |= atomic_read(&obj->pending_flip);
30687 + cd->flips |= atomic_read_unchecked(&obj->pending_flip);
30688
30689 /* The actual obj->write_domain will be updated with
30690 * pending_write_domain after we emit the accumulated flush for all
30691 @@ -882,9 +882,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
30692
30693 static int
30694 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
30695 - int count)
30696 + unsigned int count)
30697 {
30698 - int i;
30699 + unsigned int i;
30700
30701 for (i = 0; i < count; i++) {
30702 char __user *ptr = (char __user *)(uintptr_t)exec[i].relocs_ptr;
30703 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
30704 index 5bd4361..0241a42 100644
30705 --- a/drivers/gpu/drm/i915/i915_irq.c
30706 +++ b/drivers/gpu/drm/i915/i915_irq.c
30707 @@ -475,7 +475,7 @@ static irqreturn_t ivybridge_irq_handler(DRM_IRQ_ARGS)
30708 u32 de_iir, gt_iir, de_ier, pch_iir, pm_iir;
30709 struct drm_i915_master_private *master_priv;
30710
30711 - atomic_inc(&dev_priv->irq_received);
30712 + atomic_inc_unchecked(&dev_priv->irq_received);
30713
30714 /* disable master interrupt before clearing iir */
30715 de_ier = I915_READ(DEIER);
30716 @@ -566,7 +566,7 @@ static irqreturn_t ironlake_irq_handler(DRM_IRQ_ARGS)
30717 struct drm_i915_master_private *master_priv;
30718 u32 bsd_usr_interrupt = GT_BSD_USER_INTERRUPT;
30719
30720 - atomic_inc(&dev_priv->irq_received);
30721 + atomic_inc_unchecked(&dev_priv->irq_received);
30722
30723 if (IS_GEN6(dev))
30724 bsd_usr_interrupt = GT_GEN6_BSD_USER_INTERRUPT;
30725 @@ -1231,7 +1231,7 @@ static irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
30726 int ret = IRQ_NONE, pipe;
30727 bool blc_event = false;
30728
30729 - atomic_inc(&dev_priv->irq_received);
30730 + atomic_inc_unchecked(&dev_priv->irq_received);
30731
30732 iir = I915_READ(IIR);
30733
30734 @@ -1743,7 +1743,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
30735 {
30736 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
30737
30738 - atomic_set(&dev_priv->irq_received, 0);
30739 + atomic_set_unchecked(&dev_priv->irq_received, 0);
30740
30741 INIT_WORK(&dev_priv->hotplug_work, i915_hotplug_work_func);
30742 INIT_WORK(&dev_priv->error_work, i915_error_work_func);
30743 @@ -1932,7 +1932,7 @@ static void i915_driver_irq_preinstall(struct drm_device * dev)
30744 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
30745 int pipe;
30746
30747 - atomic_set(&dev_priv->irq_received, 0);
30748 + atomic_set_unchecked(&dev_priv->irq_received, 0);
30749
30750 INIT_WORK(&dev_priv->hotplug_work, i915_hotplug_work_func);
30751 INIT_WORK(&dev_priv->error_work, i915_error_work_func);
30752 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
30753 index 2163818..cede019 100644
30754 --- a/drivers/gpu/drm/i915/intel_display.c
30755 +++ b/drivers/gpu/drm/i915/intel_display.c
30756 @@ -2238,7 +2238,7 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
30757
30758 wait_event(dev_priv->pending_flip_queue,
30759 atomic_read(&dev_priv->mm.wedged) ||
30760 - atomic_read(&obj->pending_flip) == 0);
30761 + atomic_read_unchecked(&obj->pending_flip) == 0);
30762
30763 /* Big Hammer, we also need to ensure that any pending
30764 * MI_WAIT_FOR_EVENT inside a user batch buffer on the
30765 @@ -2859,7 +2859,7 @@ static void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc)
30766 obj = to_intel_framebuffer(crtc->fb)->obj;
30767 dev_priv = crtc->dev->dev_private;
30768 wait_event(dev_priv->pending_flip_queue,
30769 - atomic_read(&obj->pending_flip) == 0);
30770 + atomic_read_unchecked(&obj->pending_flip) == 0);
30771 }
30772
30773 static bool intel_crtc_driving_pch(struct drm_crtc *crtc)
30774 @@ -7171,7 +7171,7 @@ static void do_intel_finish_page_flip(struct drm_device *dev,
30775
30776 atomic_clear_mask(1 << intel_crtc->plane,
30777 &obj->pending_flip.counter);
30778 - if (atomic_read(&obj->pending_flip) == 0)
30779 + if (atomic_read_unchecked(&obj->pending_flip) == 0)
30780 wake_up(&dev_priv->pending_flip_queue);
30781
30782 schedule_work(&work->work);
30783 @@ -7354,7 +7354,13 @@ static int intel_gen6_queue_flip(struct drm_device *dev,
30784 OUT_RING(fb->pitches[0] | obj->tiling_mode);
30785 OUT_RING(obj->gtt_offset);
30786
30787 - pf = I915_READ(PF_CTL(intel_crtc->pipe)) & PF_ENABLE;
30788 + /* Contrary to the suggestions in the documentation,
30789 + * "Enable Panel Fitter" does not seem to be required when page
30790 + * flipping with a non-native mode, and worse causes a normal
30791 + * modeset to fail.
30792 + * pf = I915_READ(PF_CTL(intel_crtc->pipe)) & PF_ENABLE;
30793 + */
30794 + pf = 0;
30795 pipesrc = I915_READ(PIPESRC(intel_crtc->pipe)) & 0x0fff0fff;
30796 OUT_RING(pf | pipesrc);
30797 ADVANCE_LP_RING();
30798 @@ -7461,7 +7467,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
30799 /* Block clients from rendering to the new back buffer until
30800 * the flip occurs and the object is no longer visible.
30801 */
30802 - atomic_add(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
30803 + atomic_add_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
30804
30805 ret = dev_priv->display.queue_flip(dev, crtc, fb, obj);
30806 if (ret)
30807 @@ -7475,7 +7481,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
30808 return 0;
30809
30810 cleanup_pending:
30811 - atomic_sub(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
30812 + atomic_sub_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
30813 drm_gem_object_unreference(&work->old_fb_obj->base);
30814 drm_gem_object_unreference(&obj->base);
30815 mutex_unlock(&dev->struct_mutex);
30816 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
30817 index 54558a0..2d97005 100644
30818 --- a/drivers/gpu/drm/mga/mga_drv.h
30819 +++ b/drivers/gpu/drm/mga/mga_drv.h
30820 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
30821 u32 clear_cmd;
30822 u32 maccess;
30823
30824 - atomic_t vbl_received; /**< Number of vblanks received. */
30825 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
30826 wait_queue_head_t fence_queue;
30827 - atomic_t last_fence_retired;
30828 + atomic_unchecked_t last_fence_retired;
30829 u32 next_fence_to_post;
30830
30831 unsigned int fb_cpp;
30832 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
30833 index 2581202..f230a8d9 100644
30834 --- a/drivers/gpu/drm/mga/mga_irq.c
30835 +++ b/drivers/gpu/drm/mga/mga_irq.c
30836 @@ -44,7 +44,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
30837 if (crtc != 0)
30838 return 0;
30839
30840 - return atomic_read(&dev_priv->vbl_received);
30841 + return atomic_read_unchecked(&dev_priv->vbl_received);
30842 }
30843
30844
30845 @@ -60,7 +60,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
30846 /* VBLANK interrupt */
30847 if (status & MGA_VLINEPEN) {
30848 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
30849 - atomic_inc(&dev_priv->vbl_received);
30850 + atomic_inc_unchecked(&dev_priv->vbl_received);
30851 drm_handle_vblank(dev, 0);
30852 handled = 1;
30853 }
30854 @@ -79,7 +79,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
30855 if ((prim_start & ~0x03) != (prim_end & ~0x03))
30856 MGA_WRITE(MGA_PRIMEND, prim_end);
30857
30858 - atomic_inc(&dev_priv->last_fence_retired);
30859 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
30860 DRM_WAKEUP(&dev_priv->fence_queue);
30861 handled = 1;
30862 }
30863 @@ -130,7 +130,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
30864 * using fences.
30865 */
30866 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
30867 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
30868 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
30869 - *sequence) <= (1 << 23)));
30870
30871 *sequence = cur_fence;
30872 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
30873 index e5cbead..6c354a3 100644
30874 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
30875 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
30876 @@ -199,7 +199,7 @@ struct methods {
30877 const char desc[8];
30878 void (*loadbios)(struct drm_device *, uint8_t *);
30879 const bool rw;
30880 -};
30881 +} __do_const;
30882
30883 static struct methods shadow_methods[] = {
30884 { "PRAMIN", load_vbios_pramin, true },
30885 @@ -5290,7 +5290,7 @@ parse_bit_U_tbl_entry(struct drm_device *dev, struct nvbios *bios,
30886 struct bit_table {
30887 const char id;
30888 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
30889 -};
30890 +} __no_const;
30891
30892 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
30893
30894 diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
30895 index b827098..c31a797 100644
30896 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h
30897 +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
30898 @@ -242,7 +242,7 @@ struct nouveau_channel {
30899 struct list_head pending;
30900 uint32_t sequence;
30901 uint32_t sequence_ack;
30902 - atomic_t last_sequence_irq;
30903 + atomic_unchecked_t last_sequence_irq;
30904 struct nouveau_vma vma;
30905 } fence;
30906
30907 @@ -323,7 +323,7 @@ struct nouveau_exec_engine {
30908 u32 handle, u16 class);
30909 void (*set_tile_region)(struct drm_device *dev, int i);
30910 void (*tlb_flush)(struct drm_device *, int engine);
30911 -};
30912 +} __no_const;
30913
30914 struct nouveau_instmem_engine {
30915 void *priv;
30916 @@ -345,13 +345,13 @@ struct nouveau_instmem_engine {
30917 struct nouveau_mc_engine {
30918 int (*init)(struct drm_device *dev);
30919 void (*takedown)(struct drm_device *dev);
30920 -};
30921 +} __no_const;
30922
30923 struct nouveau_timer_engine {
30924 int (*init)(struct drm_device *dev);
30925 void (*takedown)(struct drm_device *dev);
30926 uint64_t (*read)(struct drm_device *dev);
30927 -};
30928 +} __no_const;
30929
30930 struct nouveau_fb_engine {
30931 int num_tiles;
30932 @@ -566,7 +566,7 @@ struct nouveau_vram_engine {
30933 void (*put)(struct drm_device *, struct nouveau_mem **);
30934
30935 bool (*flags_valid)(struct drm_device *, u32 tile_flags);
30936 -};
30937 +} __no_const;
30938
30939 struct nouveau_engine {
30940 struct nouveau_instmem_engine instmem;
30941 @@ -714,7 +714,7 @@ struct drm_nouveau_private {
30942 struct drm_global_reference mem_global_ref;
30943 struct ttm_bo_global_ref bo_global_ref;
30944 struct ttm_bo_device bdev;
30945 - atomic_t validate_sequence;
30946 + atomic_unchecked_t validate_sequence;
30947 } ttm;
30948
30949 struct {
30950 diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
30951 index 2f6daae..c9d7b9e 100644
30952 --- a/drivers/gpu/drm/nouveau/nouveau_fence.c
30953 +++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
30954 @@ -85,7 +85,7 @@ nouveau_fence_update(struct nouveau_channel *chan)
30955 if (USE_REFCNT(dev))
30956 sequence = nvchan_rd32(chan, 0x48);
30957 else
30958 - sequence = atomic_read(&chan->fence.last_sequence_irq);
30959 + sequence = atomic_read_unchecked(&chan->fence.last_sequence_irq);
30960
30961 if (chan->fence.sequence_ack == sequence)
30962 goto out;
30963 @@ -539,7 +539,7 @@ nouveau_fence_channel_init(struct nouveau_channel *chan)
30964 return ret;
30965 }
30966
30967 - atomic_set(&chan->fence.last_sequence_irq, 0);
30968 + atomic_set_unchecked(&chan->fence.last_sequence_irq, 0);
30969 return 0;
30970 }
30971
30972 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
30973 index 7ce3fde..cb3ea04 100644
30974 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
30975 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
30976 @@ -314,7 +314,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
30977 int trycnt = 0;
30978 int ret, i;
30979
30980 - sequence = atomic_add_return(1, &dev_priv->ttm.validate_sequence);
30981 + sequence = atomic_add_return_unchecked(1, &dev_priv->ttm.validate_sequence);
30982 retry:
30983 if (++trycnt > 100000) {
30984 NV_ERROR(dev, "%s failed and gave up.\n", __func__);
30985 diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c
30986 index f80c5e0..936baa7 100644
30987 --- a/drivers/gpu/drm/nouveau/nouveau_state.c
30988 +++ b/drivers/gpu/drm/nouveau/nouveau_state.c
30989 @@ -543,7 +543,7 @@ static bool nouveau_switcheroo_can_switch(struct pci_dev *pdev)
30990 bool can_switch;
30991
30992 spin_lock(&dev->count_lock);
30993 - can_switch = (dev->open_count == 0);
30994 + can_switch = (local_read(&dev->open_count) == 0);
30995 spin_unlock(&dev->count_lock);
30996 return can_switch;
30997 }
30998 diff --git a/drivers/gpu/drm/nouveau/nv04_graph.c b/drivers/gpu/drm/nouveau/nv04_graph.c
30999 index dbdea8e..cd6eeeb 100644
31000 --- a/drivers/gpu/drm/nouveau/nv04_graph.c
31001 +++ b/drivers/gpu/drm/nouveau/nv04_graph.c
31002 @@ -554,7 +554,7 @@ static int
31003 nv04_graph_mthd_set_ref(struct nouveau_channel *chan,
31004 u32 class, u32 mthd, u32 data)
31005 {
31006 - atomic_set(&chan->fence.last_sequence_irq, data);
31007 + atomic_set_unchecked(&chan->fence.last_sequence_irq, data);
31008 return 0;
31009 }
31010
31011 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
31012 index bcac90b..53bfc76 100644
31013 --- a/drivers/gpu/drm/r128/r128_cce.c
31014 +++ b/drivers/gpu/drm/r128/r128_cce.c
31015 @@ -378,7 +378,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
31016
31017 /* GH: Simple idle check.
31018 */
31019 - atomic_set(&dev_priv->idle_count, 0);
31020 + atomic_set_unchecked(&dev_priv->idle_count, 0);
31021
31022 /* We don't support anything other than bus-mastering ring mode,
31023 * but the ring can be in either AGP or PCI space for the ring
31024 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
31025 index 930c71b..499aded 100644
31026 --- a/drivers/gpu/drm/r128/r128_drv.h
31027 +++ b/drivers/gpu/drm/r128/r128_drv.h
31028 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
31029 int is_pci;
31030 unsigned long cce_buffers_offset;
31031
31032 - atomic_t idle_count;
31033 + atomic_unchecked_t idle_count;
31034
31035 int page_flipping;
31036 int current_page;
31037 u32 crtc_offset;
31038 u32 crtc_offset_cntl;
31039
31040 - atomic_t vbl_received;
31041 + atomic_unchecked_t vbl_received;
31042
31043 u32 color_fmt;
31044 unsigned int front_offset;
31045 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
31046 index 429d5a0..7e899ed 100644
31047 --- a/drivers/gpu/drm/r128/r128_irq.c
31048 +++ b/drivers/gpu/drm/r128/r128_irq.c
31049 @@ -42,7 +42,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
31050 if (crtc != 0)
31051 return 0;
31052
31053 - return atomic_read(&dev_priv->vbl_received);
31054 + return atomic_read_unchecked(&dev_priv->vbl_received);
31055 }
31056
31057 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
31058 @@ -56,7 +56,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
31059 /* VBLANK interrupt */
31060 if (status & R128_CRTC_VBLANK_INT) {
31061 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
31062 - atomic_inc(&dev_priv->vbl_received);
31063 + atomic_inc_unchecked(&dev_priv->vbl_received);
31064 drm_handle_vblank(dev, 0);
31065 return IRQ_HANDLED;
31066 }
31067 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
31068 index a9e33ce..09edd4b 100644
31069 --- a/drivers/gpu/drm/r128/r128_state.c
31070 +++ b/drivers/gpu/drm/r128/r128_state.c
31071 @@ -321,10 +321,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
31072
31073 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
31074 {
31075 - if (atomic_read(&dev_priv->idle_count) == 0)
31076 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
31077 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
31078 else
31079 - atomic_set(&dev_priv->idle_count, 0);
31080 + atomic_set_unchecked(&dev_priv->idle_count, 0);
31081 }
31082
31083 #endif
31084 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
31085 index 5a82b6b..9e69c73 100644
31086 --- a/drivers/gpu/drm/radeon/mkregtable.c
31087 +++ b/drivers/gpu/drm/radeon/mkregtable.c
31088 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
31089 regex_t mask_rex;
31090 regmatch_t match[4];
31091 char buf[1024];
31092 - size_t end;
31093 + long end;
31094 int len;
31095 int done = 0;
31096 int r;
31097 unsigned o;
31098 struct offset *offset;
31099 char last_reg_s[10];
31100 - int last_reg;
31101 + unsigned long last_reg;
31102
31103 if (regcomp
31104 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
31105 diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
31106 index 1668ec1..30ebdab 100644
31107 --- a/drivers/gpu/drm/radeon/radeon.h
31108 +++ b/drivers/gpu/drm/radeon/radeon.h
31109 @@ -250,7 +250,7 @@ struct radeon_fence_driver {
31110 uint32_t scratch_reg;
31111 uint64_t gpu_addr;
31112 volatile uint32_t *cpu_addr;
31113 - atomic_t seq;
31114 + atomic_unchecked_t seq;
31115 uint32_t last_seq;
31116 unsigned long last_jiffies;
31117 unsigned long last_timeout;
31118 @@ -752,7 +752,7 @@ struct r600_blit_cp_primitives {
31119 int x2, int y2);
31120 void (*draw_auto)(struct radeon_device *rdev);
31121 void (*set_default_state)(struct radeon_device *rdev);
31122 -};
31123 +} __no_const;
31124
31125 struct r600_blit {
31126 struct mutex mutex;
31127 @@ -1201,7 +1201,7 @@ struct radeon_asic {
31128 void (*pre_page_flip)(struct radeon_device *rdev, int crtc);
31129 u32 (*page_flip)(struct radeon_device *rdev, int crtc, u64 crtc_base);
31130 void (*post_page_flip)(struct radeon_device *rdev, int crtc);
31131 -};
31132 +} __no_const;
31133
31134 /*
31135 * Asic structures
31136 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
31137 index 49f7cb7..2fcb48f 100644
31138 --- a/drivers/gpu/drm/radeon/radeon_device.c
31139 +++ b/drivers/gpu/drm/radeon/radeon_device.c
31140 @@ -687,7 +687,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
31141 bool can_switch;
31142
31143 spin_lock(&dev->count_lock);
31144 - can_switch = (dev->open_count == 0);
31145 + can_switch = (local_read(&dev->open_count) == 0);
31146 spin_unlock(&dev->count_lock);
31147 return can_switch;
31148 }
31149 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
31150 index a1b59ca..86f2d44 100644
31151 --- a/drivers/gpu/drm/radeon/radeon_drv.h
31152 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
31153 @@ -255,7 +255,7 @@ typedef struct drm_radeon_private {
31154
31155 /* SW interrupt */
31156 wait_queue_head_t swi_queue;
31157 - atomic_t swi_emitted;
31158 + atomic_unchecked_t swi_emitted;
31159 int vblank_crtc;
31160 uint32_t irq_enable_reg;
31161 uint32_t r500_disp_irq_reg;
31162 diff --git a/drivers/gpu/drm/radeon/radeon_fence.c b/drivers/gpu/drm/radeon/radeon_fence.c
31163 index 4bd36a3..e66fe9c 100644
31164 --- a/drivers/gpu/drm/radeon/radeon_fence.c
31165 +++ b/drivers/gpu/drm/radeon/radeon_fence.c
31166 @@ -70,7 +70,7 @@ int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence *fence)
31167 write_unlock_irqrestore(&rdev->fence_lock, irq_flags);
31168 return 0;
31169 }
31170 - fence->seq = atomic_add_return(1, &rdev->fence_drv[fence->ring].seq);
31171 + fence->seq = atomic_add_return_unchecked(1, &rdev->fence_drv[fence->ring].seq);
31172 if (!rdev->ring[fence->ring].ready)
31173 /* FIXME: cp is not running assume everythings is done right
31174 * away
31175 @@ -405,7 +405,7 @@ int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring)
31176 }
31177 rdev->fence_drv[ring].cpu_addr = &rdev->wb.wb[index/4];
31178 rdev->fence_drv[ring].gpu_addr = rdev->wb.gpu_addr + index;
31179 - radeon_fence_write(rdev, atomic_read(&rdev->fence_drv[ring].seq), ring);
31180 + radeon_fence_write(rdev, atomic_read_unchecked(&rdev->fence_drv[ring].seq), ring);
31181 rdev->fence_drv[ring].initialized = true;
31182 DRM_INFO("fence driver on ring %d use gpu addr 0x%08Lx and cpu addr 0x%p\n",
31183 ring, rdev->fence_drv[ring].gpu_addr, rdev->fence_drv[ring].cpu_addr);
31184 @@ -418,7 +418,7 @@ static void radeon_fence_driver_init_ring(struct radeon_device *rdev, int ring)
31185 rdev->fence_drv[ring].scratch_reg = -1;
31186 rdev->fence_drv[ring].cpu_addr = NULL;
31187 rdev->fence_drv[ring].gpu_addr = 0;
31188 - atomic_set(&rdev->fence_drv[ring].seq, 0);
31189 + atomic_set_unchecked(&rdev->fence_drv[ring].seq, 0);
31190 INIT_LIST_HEAD(&rdev->fence_drv[ring].created);
31191 INIT_LIST_HEAD(&rdev->fence_drv[ring].emitted);
31192 INIT_LIST_HEAD(&rdev->fence_drv[ring].signaled);
31193 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
31194 index 48b7cea..342236f 100644
31195 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
31196 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
31197 @@ -359,7 +359,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
31198 request = compat_alloc_user_space(sizeof(*request));
31199 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
31200 || __put_user(req32.param, &request->param)
31201 - || __put_user((void __user *)(unsigned long)req32.value,
31202 + || __put_user((unsigned long)req32.value,
31203 &request->value))
31204 return -EFAULT;
31205
31206 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
31207 index 00da384..32f972d 100644
31208 --- a/drivers/gpu/drm/radeon/radeon_irq.c
31209 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
31210 @@ -225,8 +225,8 @@ static int radeon_emit_irq(struct drm_device * dev)
31211 unsigned int ret;
31212 RING_LOCALS;
31213
31214 - atomic_inc(&dev_priv->swi_emitted);
31215 - ret = atomic_read(&dev_priv->swi_emitted);
31216 + atomic_inc_unchecked(&dev_priv->swi_emitted);
31217 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
31218
31219 BEGIN_RING(4);
31220 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
31221 @@ -352,7 +352,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
31222 drm_radeon_private_t *dev_priv =
31223 (drm_radeon_private_t *) dev->dev_private;
31224
31225 - atomic_set(&dev_priv->swi_emitted, 0);
31226 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
31227 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
31228
31229 dev->max_vblank_count = 0x001fffff;
31230 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
31231 index e8422ae..d22d4a8 100644
31232 --- a/drivers/gpu/drm/radeon/radeon_state.c
31233 +++ b/drivers/gpu/drm/radeon/radeon_state.c
31234 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
31235 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
31236 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
31237
31238 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
31239 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
31240 sarea_priv->nbox * sizeof(depth_boxes[0])))
31241 return -EFAULT;
31242
31243 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
31244 {
31245 drm_radeon_private_t *dev_priv = dev->dev_private;
31246 drm_radeon_getparam_t *param = data;
31247 - int value;
31248 + int value = 0;
31249
31250 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
31251
31252 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
31253 index c421e77..e6bf2e8 100644
31254 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
31255 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
31256 @@ -842,8 +842,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
31257 }
31258 if (unlikely(ttm_vm_ops == NULL)) {
31259 ttm_vm_ops = vma->vm_ops;
31260 - radeon_ttm_vm_ops = *ttm_vm_ops;
31261 - radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
31262 + pax_open_kernel();
31263 + memcpy((void *)&radeon_ttm_vm_ops, ttm_vm_ops, sizeof(radeon_ttm_vm_ops));
31264 + *(void **)&radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
31265 + pax_close_kernel();
31266 }
31267 vma->vm_ops = &radeon_ttm_vm_ops;
31268 return 0;
31269 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
31270 index f68dff2..8df955c 100644
31271 --- a/drivers/gpu/drm/radeon/rs690.c
31272 +++ b/drivers/gpu/drm/radeon/rs690.c
31273 @@ -304,9 +304,11 @@ void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
31274 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
31275 rdev->pm.sideport_bandwidth.full)
31276 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
31277 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
31278 + read_delay_latency.full = dfixed_const(800 * 1000);
31279 read_delay_latency.full = dfixed_div(read_delay_latency,
31280 rdev->pm.igp_sideport_mclk);
31281 + a.full = dfixed_const(370);
31282 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
31283 } else {
31284 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
31285 rdev->pm.k8_bandwidth.full)
31286 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
31287 index 499debd..66fce72 100644
31288 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
31289 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
31290 @@ -398,9 +398,9 @@ static int ttm_pool_get_num_unused_pages(void)
31291 static int ttm_pool_mm_shrink(struct shrinker *shrink,
31292 struct shrink_control *sc)
31293 {
31294 - static atomic_t start_pool = ATOMIC_INIT(0);
31295 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
31296 unsigned i;
31297 - unsigned pool_offset = atomic_add_return(1, &start_pool);
31298 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
31299 struct ttm_page_pool *pool;
31300 int shrink_pages = sc->nr_to_scan;
31301
31302 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
31303 index 88edacc..1e5412b 100644
31304 --- a/drivers/gpu/drm/via/via_drv.h
31305 +++ b/drivers/gpu/drm/via/via_drv.h
31306 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
31307 typedef uint32_t maskarray_t[5];
31308
31309 typedef struct drm_via_irq {
31310 - atomic_t irq_received;
31311 + atomic_unchecked_t irq_received;
31312 uint32_t pending_mask;
31313 uint32_t enable_mask;
31314 wait_queue_head_t irq_queue;
31315 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
31316 struct timeval last_vblank;
31317 int last_vblank_valid;
31318 unsigned usec_per_vblank;
31319 - atomic_t vbl_received;
31320 + atomic_unchecked_t vbl_received;
31321 drm_via_state_t hc_state;
31322 char pci_buf[VIA_PCI_BUF_SIZE];
31323 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
31324 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
31325 index d391f48..10c8ca3 100644
31326 --- a/drivers/gpu/drm/via/via_irq.c
31327 +++ b/drivers/gpu/drm/via/via_irq.c
31328 @@ -102,7 +102,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
31329 if (crtc != 0)
31330 return 0;
31331
31332 - return atomic_read(&dev_priv->vbl_received);
31333 + return atomic_read_unchecked(&dev_priv->vbl_received);
31334 }
31335
31336 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
31337 @@ -117,8 +117,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
31338
31339 status = VIA_READ(VIA_REG_INTERRUPT);
31340 if (status & VIA_IRQ_VBLANK_PENDING) {
31341 - atomic_inc(&dev_priv->vbl_received);
31342 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
31343 + atomic_inc_unchecked(&dev_priv->vbl_received);
31344 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
31345 do_gettimeofday(&cur_vblank);
31346 if (dev_priv->last_vblank_valid) {
31347 dev_priv->usec_per_vblank =
31348 @@ -128,7 +128,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
31349 dev_priv->last_vblank = cur_vblank;
31350 dev_priv->last_vblank_valid = 1;
31351 }
31352 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
31353 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
31354 DRM_DEBUG("US per vblank is: %u\n",
31355 dev_priv->usec_per_vblank);
31356 }
31357 @@ -138,7 +138,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
31358
31359 for (i = 0; i < dev_priv->num_irqs; ++i) {
31360 if (status & cur_irq->pending_mask) {
31361 - atomic_inc(&cur_irq->irq_received);
31362 + atomic_inc_unchecked(&cur_irq->irq_received);
31363 DRM_WAKEUP(&cur_irq->irq_queue);
31364 handled = 1;
31365 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
31366 @@ -243,11 +243,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
31367 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
31368 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
31369 masks[irq][4]));
31370 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
31371 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
31372 } else {
31373 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
31374 (((cur_irq_sequence =
31375 - atomic_read(&cur_irq->irq_received)) -
31376 + atomic_read_unchecked(&cur_irq->irq_received)) -
31377 *sequence) <= (1 << 23)));
31378 }
31379 *sequence = cur_irq_sequence;
31380 @@ -285,7 +285,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
31381 }
31382
31383 for (i = 0; i < dev_priv->num_irqs; ++i) {
31384 - atomic_set(&cur_irq->irq_received, 0);
31385 + atomic_set_unchecked(&cur_irq->irq_received, 0);
31386 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
31387 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
31388 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
31389 @@ -367,7 +367,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
31390 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
31391 case VIA_IRQ_RELATIVE:
31392 irqwait->request.sequence +=
31393 - atomic_read(&cur_irq->irq_received);
31394 + atomic_read_unchecked(&cur_irq->irq_received);
31395 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
31396 case VIA_IRQ_ABSOLUTE:
31397 break;
31398 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
31399 index dc27970..f18b008 100644
31400 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
31401 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
31402 @@ -260,7 +260,7 @@ struct vmw_private {
31403 * Fencing and IRQs.
31404 */
31405
31406 - atomic_t marker_seq;
31407 + atomic_unchecked_t marker_seq;
31408 wait_queue_head_t fence_queue;
31409 wait_queue_head_t fifo_queue;
31410 int fence_queue_waiters; /* Protected by hw_mutex */
31411 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
31412 index a0c2f12..68ae6cb 100644
31413 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
31414 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
31415 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
31416 (unsigned int) min,
31417 (unsigned int) fifo->capabilities);
31418
31419 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
31420 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
31421 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
31422 vmw_marker_queue_init(&fifo->marker_queue);
31423 return vmw_fifo_send_fence(dev_priv, &dummy);
31424 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
31425 if (reserveable)
31426 iowrite32(bytes, fifo_mem +
31427 SVGA_FIFO_RESERVED);
31428 - return fifo_mem + (next_cmd >> 2);
31429 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
31430 } else {
31431 need_bounce = true;
31432 }
31433 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
31434
31435 fm = vmw_fifo_reserve(dev_priv, bytes);
31436 if (unlikely(fm == NULL)) {
31437 - *seqno = atomic_read(&dev_priv->marker_seq);
31438 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
31439 ret = -ENOMEM;
31440 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
31441 false, 3*HZ);
31442 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
31443 }
31444
31445 do {
31446 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
31447 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
31448 } while (*seqno == 0);
31449
31450 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
31451 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
31452 index cabc95f..14b3d77 100644
31453 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
31454 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
31455 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
31456 * emitted. Then the fence is stale and signaled.
31457 */
31458
31459 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
31460 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
31461 > VMW_FENCE_WRAP);
31462
31463 return ret;
31464 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
31465
31466 if (fifo_idle)
31467 down_read(&fifo_state->rwsem);
31468 - signal_seq = atomic_read(&dev_priv->marker_seq);
31469 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
31470 ret = 0;
31471
31472 for (;;) {
31473 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
31474 index 8a8725c..afed796 100644
31475 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
31476 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
31477 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
31478 while (!vmw_lag_lt(queue, us)) {
31479 spin_lock(&queue->lock);
31480 if (list_empty(&queue->head))
31481 - seqno = atomic_read(&dev_priv->marker_seq);
31482 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
31483 else {
31484 marker = list_first_entry(&queue->head,
31485 struct vmw_marker, head);
31486 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
31487 index 75dbe34..f9204a8 100644
31488 --- a/drivers/hid/hid-core.c
31489 +++ b/drivers/hid/hid-core.c
31490 @@ -2021,7 +2021,7 @@ static bool hid_ignore(struct hid_device *hdev)
31491
31492 int hid_add_device(struct hid_device *hdev)
31493 {
31494 - static atomic_t id = ATOMIC_INIT(0);
31495 + static atomic_unchecked_t id = ATOMIC_INIT(0);
31496 int ret;
31497
31498 if (WARN_ON(hdev->status & HID_STAT_ADDED))
31499 @@ -2036,7 +2036,7 @@ int hid_add_device(struct hid_device *hdev)
31500 /* XXX hack, any other cleaner solution after the driver core
31501 * is converted to allow more than 20 bytes as the device name? */
31502 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
31503 - hdev->vendor, hdev->product, atomic_inc_return(&id));
31504 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
31505
31506 hid_debug_register(hdev, dev_name(&hdev->dev));
31507 ret = device_add(&hdev->dev);
31508 diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
31509 index b1ec0e2..c295a61 100644
31510 --- a/drivers/hid/usbhid/hiddev.c
31511 +++ b/drivers/hid/usbhid/hiddev.c
31512 @@ -624,7 +624,7 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
31513 break;
31514
31515 case HIDIOCAPPLICATION:
31516 - if (arg < 0 || arg >= hid->maxapplication)
31517 + if (arg >= hid->maxapplication)
31518 break;
31519
31520 for (i = 0; i < hid->maxcollection; i++)
31521 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
31522 index 4065374..10ed7dc 100644
31523 --- a/drivers/hv/channel.c
31524 +++ b/drivers/hv/channel.c
31525 @@ -400,8 +400,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
31526 int ret = 0;
31527 int t;
31528
31529 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
31530 - atomic_inc(&vmbus_connection.next_gpadl_handle);
31531 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
31532 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
31533
31534 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
31535 if (ret)
31536 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
31537 index 12aa97f..c0679f7 100644
31538 --- a/drivers/hv/hv.c
31539 +++ b/drivers/hv/hv.c
31540 @@ -132,7 +132,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
31541 u64 output_address = (output) ? virt_to_phys(output) : 0;
31542 u32 output_address_hi = output_address >> 32;
31543 u32 output_address_lo = output_address & 0xFFFFFFFF;
31544 - void *hypercall_page = hv_context.hypercall_page;
31545 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
31546
31547 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
31548 "=a"(hv_status_lo) : "d" (control_hi),
31549 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
31550 index 6d7d286..92b0873 100644
31551 --- a/drivers/hv/hyperv_vmbus.h
31552 +++ b/drivers/hv/hyperv_vmbus.h
31553 @@ -556,7 +556,7 @@ enum vmbus_connect_state {
31554 struct vmbus_connection {
31555 enum vmbus_connect_state conn_state;
31556
31557 - atomic_t next_gpadl_handle;
31558 + atomic_unchecked_t next_gpadl_handle;
31559
31560 /*
31561 * Represents channel interrupts. Each bit position represents a
31562 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
31563 index a220e57..428f54d 100644
31564 --- a/drivers/hv/vmbus_drv.c
31565 +++ b/drivers/hv/vmbus_drv.c
31566 @@ -663,10 +663,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
31567 {
31568 int ret = 0;
31569
31570 - static atomic_t device_num = ATOMIC_INIT(0);
31571 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
31572
31573 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
31574 - atomic_inc_return(&device_num));
31575 + atomic_inc_return_unchecked(&device_num));
31576
31577 child_device_obj->device.bus = &hv_bus;
31578 child_device_obj->device.parent = &hv_acpi_dev->dev;
31579 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
31580 index 554f046..f8b4729 100644
31581 --- a/drivers/hwmon/acpi_power_meter.c
31582 +++ b/drivers/hwmon/acpi_power_meter.c
31583 @@ -316,8 +316,6 @@ static ssize_t set_trip(struct device *dev, struct device_attribute *devattr,
31584 return res;
31585
31586 temp /= 1000;
31587 - if (temp < 0)
31588 - return -EINVAL;
31589
31590 mutex_lock(&resource->lock);
31591 resource->trip[attr->index - 7] = temp;
31592 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
31593 index 91fdd1f..b66a686 100644
31594 --- a/drivers/hwmon/sht15.c
31595 +++ b/drivers/hwmon/sht15.c
31596 @@ -166,7 +166,7 @@ struct sht15_data {
31597 int supply_uV;
31598 bool supply_uV_valid;
31599 struct work_struct update_supply_work;
31600 - atomic_t interrupt_handled;
31601 + atomic_unchecked_t interrupt_handled;
31602 };
31603
31604 /**
31605 @@ -509,13 +509,13 @@ static int sht15_measurement(struct sht15_data *data,
31606 return ret;
31607
31608 gpio_direction_input(data->pdata->gpio_data);
31609 - atomic_set(&data->interrupt_handled, 0);
31610 + atomic_set_unchecked(&data->interrupt_handled, 0);
31611
31612 enable_irq(gpio_to_irq(data->pdata->gpio_data));
31613 if (gpio_get_value(data->pdata->gpio_data) == 0) {
31614 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
31615 /* Only relevant if the interrupt hasn't occurred. */
31616 - if (!atomic_read(&data->interrupt_handled))
31617 + if (!atomic_read_unchecked(&data->interrupt_handled))
31618 schedule_work(&data->read_work);
31619 }
31620 ret = wait_event_timeout(data->wait_queue,
31621 @@ -782,7 +782,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
31622
31623 /* First disable the interrupt */
31624 disable_irq_nosync(irq);
31625 - atomic_inc(&data->interrupt_handled);
31626 + atomic_inc_unchecked(&data->interrupt_handled);
31627 /* Then schedule a reading work struct */
31628 if (data->state != SHT15_READING_NOTHING)
31629 schedule_work(&data->read_work);
31630 @@ -804,11 +804,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
31631 * If not, then start the interrupt again - care here as could
31632 * have gone low in meantime so verify it hasn't!
31633 */
31634 - atomic_set(&data->interrupt_handled, 0);
31635 + atomic_set_unchecked(&data->interrupt_handled, 0);
31636 enable_irq(gpio_to_irq(data->pdata->gpio_data));
31637 /* If still not occurred or another handler has been scheduled */
31638 if (gpio_get_value(data->pdata->gpio_data)
31639 - || atomic_read(&data->interrupt_handled))
31640 + || atomic_read_unchecked(&data->interrupt_handled))
31641 return;
31642 }
31643
31644 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
31645 index 378fcb5..5e91fa8 100644
31646 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
31647 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
31648 @@ -43,7 +43,7 @@
31649 extern struct i2c_adapter amd756_smbus;
31650
31651 static struct i2c_adapter *s4882_adapter;
31652 -static struct i2c_algorithm *s4882_algo;
31653 +static i2c_algorithm_no_const *s4882_algo;
31654
31655 /* Wrapper access functions for multiplexed SMBus */
31656 static DEFINE_MUTEX(amd756_lock);
31657 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
31658 index 29015eb..af2d8e9 100644
31659 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
31660 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
31661 @@ -41,7 +41,7 @@
31662 extern struct i2c_adapter *nforce2_smbus;
31663
31664 static struct i2c_adapter *s4985_adapter;
31665 -static struct i2c_algorithm *s4985_algo;
31666 +static i2c_algorithm_no_const *s4985_algo;
31667
31668 /* Wrapper access functions for multiplexed SMBus */
31669 static DEFINE_MUTEX(nforce2_lock);
31670 diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c
31671 index d7a4833..7fae376 100644
31672 --- a/drivers/i2c/i2c-mux.c
31673 +++ b/drivers/i2c/i2c-mux.c
31674 @@ -28,7 +28,7 @@
31675 /* multiplexer per channel data */
31676 struct i2c_mux_priv {
31677 struct i2c_adapter adap;
31678 - struct i2c_algorithm algo;
31679 + i2c_algorithm_no_const algo;
31680
31681 struct i2c_adapter *parent;
31682 void *mux_dev; /* the mux chip/device */
31683 diff --git a/drivers/ide/aec62xx.c b/drivers/ide/aec62xx.c
31684 index 57d00ca..0145194 100644
31685 --- a/drivers/ide/aec62xx.c
31686 +++ b/drivers/ide/aec62xx.c
31687 @@ -181,7 +181,7 @@ static const struct ide_port_ops atp86x_port_ops = {
31688 .cable_detect = atp86x_cable_detect,
31689 };
31690
31691 -static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
31692 +static const struct ide_port_info aec62xx_chipsets[] __devinitconst = {
31693 { /* 0: AEC6210 */
31694 .name = DRV_NAME,
31695 .init_chipset = init_chipset_aec62xx,
31696 diff --git a/drivers/ide/alim15x3.c b/drivers/ide/alim15x3.c
31697 index 2c8016a..911a27c 100644
31698 --- a/drivers/ide/alim15x3.c
31699 +++ b/drivers/ide/alim15x3.c
31700 @@ -512,7 +512,7 @@ static const struct ide_dma_ops ali_dma_ops = {
31701 .dma_sff_read_status = ide_dma_sff_read_status,
31702 };
31703
31704 -static const struct ide_port_info ali15x3_chipset __devinitdata = {
31705 +static const struct ide_port_info ali15x3_chipset __devinitconst = {
31706 .name = DRV_NAME,
31707 .init_chipset = init_chipset_ali15x3,
31708 .init_hwif = init_hwif_ali15x3,
31709 diff --git a/drivers/ide/amd74xx.c b/drivers/ide/amd74xx.c
31710 index 3747b25..56fc995 100644
31711 --- a/drivers/ide/amd74xx.c
31712 +++ b/drivers/ide/amd74xx.c
31713 @@ -223,7 +223,7 @@ static const struct ide_port_ops amd_port_ops = {
31714 .udma_mask = udma, \
31715 }
31716
31717 -static const struct ide_port_info amd74xx_chipsets[] __devinitdata = {
31718 +static const struct ide_port_info amd74xx_chipsets[] __devinitconst = {
31719 /* 0: AMD7401 */ DECLARE_AMD_DEV(0x00, ATA_UDMA2),
31720 /* 1: AMD7409 */ DECLARE_AMD_DEV(ATA_SWDMA2, ATA_UDMA4),
31721 /* 2: AMD7411/7441 */ DECLARE_AMD_DEV(ATA_SWDMA2, ATA_UDMA5),
31722 diff --git a/drivers/ide/atiixp.c b/drivers/ide/atiixp.c
31723 index 15f0ead..cb43480 100644
31724 --- a/drivers/ide/atiixp.c
31725 +++ b/drivers/ide/atiixp.c
31726 @@ -139,7 +139,7 @@ static const struct ide_port_ops atiixp_port_ops = {
31727 .cable_detect = atiixp_cable_detect,
31728 };
31729
31730 -static const struct ide_port_info atiixp_pci_info[] __devinitdata = {
31731 +static const struct ide_port_info atiixp_pci_info[] __devinitconst = {
31732 { /* 0: IXP200/300/400/700 */
31733 .name = DRV_NAME,
31734 .enablebits = {{0x48,0x01,0x00}, {0x48,0x08,0x00}},
31735 diff --git a/drivers/ide/cmd64x.c b/drivers/ide/cmd64x.c
31736 index 5f80312..d1fc438 100644
31737 --- a/drivers/ide/cmd64x.c
31738 +++ b/drivers/ide/cmd64x.c
31739 @@ -327,7 +327,7 @@ static const struct ide_dma_ops cmd646_rev1_dma_ops = {
31740 .dma_sff_read_status = ide_dma_sff_read_status,
31741 };
31742
31743 -static const struct ide_port_info cmd64x_chipsets[] __devinitdata = {
31744 +static const struct ide_port_info cmd64x_chipsets[] __devinitconst = {
31745 { /* 0: CMD643 */
31746 .name = DRV_NAME,
31747 .init_chipset = init_chipset_cmd64x,
31748 diff --git a/drivers/ide/cs5520.c b/drivers/ide/cs5520.c
31749 index 2c1e5f7..1444762 100644
31750 --- a/drivers/ide/cs5520.c
31751 +++ b/drivers/ide/cs5520.c
31752 @@ -94,7 +94,7 @@ static const struct ide_port_ops cs5520_port_ops = {
31753 .set_dma_mode = cs5520_set_dma_mode,
31754 };
31755
31756 -static const struct ide_port_info cyrix_chipset __devinitdata = {
31757 +static const struct ide_port_info cyrix_chipset __devinitconst = {
31758 .name = DRV_NAME,
31759 .enablebits = { { 0x60, 0x01, 0x01 }, { 0x60, 0x02, 0x02 } },
31760 .port_ops = &cs5520_port_ops,
31761 diff --git a/drivers/ide/cs5530.c b/drivers/ide/cs5530.c
31762 index 4dc4eb9..49b40ad 100644
31763 --- a/drivers/ide/cs5530.c
31764 +++ b/drivers/ide/cs5530.c
31765 @@ -245,7 +245,7 @@ static const struct ide_port_ops cs5530_port_ops = {
31766 .udma_filter = cs5530_udma_filter,
31767 };
31768
31769 -static const struct ide_port_info cs5530_chipset __devinitdata = {
31770 +static const struct ide_port_info cs5530_chipset __devinitconst = {
31771 .name = DRV_NAME,
31772 .init_chipset = init_chipset_cs5530,
31773 .init_hwif = init_hwif_cs5530,
31774 diff --git a/drivers/ide/cs5535.c b/drivers/ide/cs5535.c
31775 index 5059faf..18d4c85 100644
31776 --- a/drivers/ide/cs5535.c
31777 +++ b/drivers/ide/cs5535.c
31778 @@ -170,7 +170,7 @@ static const struct ide_port_ops cs5535_port_ops = {
31779 .cable_detect = cs5535_cable_detect,
31780 };
31781
31782 -static const struct ide_port_info cs5535_chipset __devinitdata = {
31783 +static const struct ide_port_info cs5535_chipset __devinitconst = {
31784 .name = DRV_NAME,
31785 .port_ops = &cs5535_port_ops,
31786 .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_POST_SET_MODE,
31787 diff --git a/drivers/ide/cy82c693.c b/drivers/ide/cy82c693.c
31788 index 847553f..3ffb49d 100644
31789 --- a/drivers/ide/cy82c693.c
31790 +++ b/drivers/ide/cy82c693.c
31791 @@ -163,7 +163,7 @@ static const struct ide_port_ops cy82c693_port_ops = {
31792 .set_dma_mode = cy82c693_set_dma_mode,
31793 };
31794
31795 -static const struct ide_port_info cy82c693_chipset __devinitdata = {
31796 +static const struct ide_port_info cy82c693_chipset __devinitconst = {
31797 .name = DRV_NAME,
31798 .init_iops = init_iops_cy82c693,
31799 .port_ops = &cy82c693_port_ops,
31800 diff --git a/drivers/ide/hpt366.c b/drivers/ide/hpt366.c
31801 index 58c51cd..4aec3b8 100644
31802 --- a/drivers/ide/hpt366.c
31803 +++ b/drivers/ide/hpt366.c
31804 @@ -443,7 +443,7 @@ static struct hpt_timings hpt37x_timings = {
31805 }
31806 };
31807
31808 -static const struct hpt_info hpt36x __devinitdata = {
31809 +static const struct hpt_info hpt36x __devinitconst = {
31810 .chip_name = "HPT36x",
31811 .chip_type = HPT36x,
31812 .udma_mask = HPT366_ALLOW_ATA66_3 ? (HPT366_ALLOW_ATA66_4 ? ATA_UDMA4 : ATA_UDMA3) : ATA_UDMA2,
31813 @@ -451,7 +451,7 @@ static const struct hpt_info hpt36x __devinitdata = {
31814 .timings = &hpt36x_timings
31815 };
31816
31817 -static const struct hpt_info hpt370 __devinitdata = {
31818 +static const struct hpt_info hpt370 __devinitconst = {
31819 .chip_name = "HPT370",
31820 .chip_type = HPT370,
31821 .udma_mask = HPT370_ALLOW_ATA100_5 ? ATA_UDMA5 : ATA_UDMA4,
31822 @@ -459,7 +459,7 @@ static const struct hpt_info hpt370 __devinitdata = {
31823 .timings = &hpt37x_timings
31824 };
31825
31826 -static const struct hpt_info hpt370a __devinitdata = {
31827 +static const struct hpt_info hpt370a __devinitconst = {
31828 .chip_name = "HPT370A",
31829 .chip_type = HPT370A,
31830 .udma_mask = HPT370_ALLOW_ATA100_5 ? ATA_UDMA5 : ATA_UDMA4,
31831 @@ -467,7 +467,7 @@ static const struct hpt_info hpt370a __devinitdata = {
31832 .timings = &hpt37x_timings
31833 };
31834
31835 -static const struct hpt_info hpt374 __devinitdata = {
31836 +static const struct hpt_info hpt374 __devinitconst = {
31837 .chip_name = "HPT374",
31838 .chip_type = HPT374,
31839 .udma_mask = ATA_UDMA5,
31840 @@ -475,7 +475,7 @@ static const struct hpt_info hpt374 __devinitdata = {
31841 .timings = &hpt37x_timings
31842 };
31843
31844 -static const struct hpt_info hpt372 __devinitdata = {
31845 +static const struct hpt_info hpt372 __devinitconst = {
31846 .chip_name = "HPT372",
31847 .chip_type = HPT372,
31848 .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5,
31849 @@ -483,7 +483,7 @@ static const struct hpt_info hpt372 __devinitdata = {
31850 .timings = &hpt37x_timings
31851 };
31852
31853 -static const struct hpt_info hpt372a __devinitdata = {
31854 +static const struct hpt_info hpt372a __devinitconst = {
31855 .chip_name = "HPT372A",
31856 .chip_type = HPT372A,
31857 .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5,
31858 @@ -491,7 +491,7 @@ static const struct hpt_info hpt372a __devinitdata = {
31859 .timings = &hpt37x_timings
31860 };
31861
31862 -static const struct hpt_info hpt302 __devinitdata = {
31863 +static const struct hpt_info hpt302 __devinitconst = {
31864 .chip_name = "HPT302",
31865 .chip_type = HPT302,
31866 .udma_mask = HPT302_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5,
31867 @@ -499,7 +499,7 @@ static const struct hpt_info hpt302 __devinitdata = {
31868 .timings = &hpt37x_timings
31869 };
31870
31871 -static const struct hpt_info hpt371 __devinitdata = {
31872 +static const struct hpt_info hpt371 __devinitconst = {
31873 .chip_name = "HPT371",
31874 .chip_type = HPT371,
31875 .udma_mask = HPT371_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5,
31876 @@ -507,7 +507,7 @@ static const struct hpt_info hpt371 __devinitdata = {
31877 .timings = &hpt37x_timings
31878 };
31879
31880 -static const struct hpt_info hpt372n __devinitdata = {
31881 +static const struct hpt_info hpt372n __devinitconst = {
31882 .chip_name = "HPT372N",
31883 .chip_type = HPT372N,
31884 .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5,
31885 @@ -515,7 +515,7 @@ static const struct hpt_info hpt372n __devinitdata = {
31886 .timings = &hpt37x_timings
31887 };
31888
31889 -static const struct hpt_info hpt302n __devinitdata = {
31890 +static const struct hpt_info hpt302n __devinitconst = {
31891 .chip_name = "HPT302N",
31892 .chip_type = HPT302N,
31893 .udma_mask = HPT302_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5,
31894 @@ -523,7 +523,7 @@ static const struct hpt_info hpt302n __devinitdata = {
31895 .timings = &hpt37x_timings
31896 };
31897
31898 -static const struct hpt_info hpt371n __devinitdata = {
31899 +static const struct hpt_info hpt371n __devinitconst = {
31900 .chip_name = "HPT371N",
31901 .chip_type = HPT371N,
31902 .udma_mask = HPT371_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5,
31903 @@ -1361,7 +1361,7 @@ static const struct ide_dma_ops hpt36x_dma_ops = {
31904 .dma_sff_read_status = ide_dma_sff_read_status,
31905 };
31906
31907 -static const struct ide_port_info hpt366_chipsets[] __devinitdata = {
31908 +static const struct ide_port_info hpt366_chipsets[] __devinitconst = {
31909 { /* 0: HPT36x */
31910 .name = DRV_NAME,
31911 .init_chipset = init_chipset_hpt366,
31912 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
31913 index 8126824..55a2798 100644
31914 --- a/drivers/ide/ide-cd.c
31915 +++ b/drivers/ide/ide-cd.c
31916 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
31917 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
31918 if ((unsigned long)buf & alignment
31919 || blk_rq_bytes(rq) & q->dma_pad_mask
31920 - || object_is_on_stack(buf))
31921 + || object_starts_on_stack(buf))
31922 drive->dma = 0;
31923 }
31924 }
31925 diff --git a/drivers/ide/ide-pci-generic.c b/drivers/ide/ide-pci-generic.c
31926 index 7f56b73..dab5b67 100644
31927 --- a/drivers/ide/ide-pci-generic.c
31928 +++ b/drivers/ide/ide-pci-generic.c
31929 @@ -53,7 +53,7 @@ static const struct ide_port_ops netcell_port_ops = {
31930 .udma_mask = ATA_UDMA6, \
31931 }
31932
31933 -static const struct ide_port_info generic_chipsets[] __devinitdata = {
31934 +static const struct ide_port_info generic_chipsets[] __devinitconst = {
31935 /* 0: Unknown */
31936 DECLARE_GENERIC_PCI_DEV(0),
31937
31938 diff --git a/drivers/ide/it8172.c b/drivers/ide/it8172.c
31939 index 560e66d..d5dd180 100644
31940 --- a/drivers/ide/it8172.c
31941 +++ b/drivers/ide/it8172.c
31942 @@ -115,7 +115,7 @@ static const struct ide_port_ops it8172_port_ops = {
31943 .set_dma_mode = it8172_set_dma_mode,
31944 };
31945
31946 -static const struct ide_port_info it8172_port_info __devinitdata = {
31947 +static const struct ide_port_info it8172_port_info __devinitconst = {
31948 .name = DRV_NAME,
31949 .port_ops = &it8172_port_ops,
31950 .enablebits = { {0x41, 0x80, 0x80}, {0x00, 0x00, 0x00} },
31951 diff --git a/drivers/ide/it8213.c b/drivers/ide/it8213.c
31952 index 46816ba..1847aeb 100644
31953 --- a/drivers/ide/it8213.c
31954 +++ b/drivers/ide/it8213.c
31955 @@ -156,7 +156,7 @@ static const struct ide_port_ops it8213_port_ops = {
31956 .cable_detect = it8213_cable_detect,
31957 };
31958
31959 -static const struct ide_port_info it8213_chipset __devinitdata = {
31960 +static const struct ide_port_info it8213_chipset __devinitconst = {
31961 .name = DRV_NAME,
31962 .enablebits = { {0x41, 0x80, 0x80} },
31963 .port_ops = &it8213_port_ops,
31964 diff --git a/drivers/ide/it821x.c b/drivers/ide/it821x.c
31965 index 2e3169f..c5611db 100644
31966 --- a/drivers/ide/it821x.c
31967 +++ b/drivers/ide/it821x.c
31968 @@ -630,7 +630,7 @@ static const struct ide_port_ops it821x_port_ops = {
31969 .cable_detect = it821x_cable_detect,
31970 };
31971
31972 -static const struct ide_port_info it821x_chipset __devinitdata = {
31973 +static const struct ide_port_info it821x_chipset __devinitconst = {
31974 .name = DRV_NAME,
31975 .init_chipset = init_chipset_it821x,
31976 .init_hwif = init_hwif_it821x,
31977 diff --git a/drivers/ide/jmicron.c b/drivers/ide/jmicron.c
31978 index 74c2c4a..efddd7d 100644
31979 --- a/drivers/ide/jmicron.c
31980 +++ b/drivers/ide/jmicron.c
31981 @@ -102,7 +102,7 @@ static const struct ide_port_ops jmicron_port_ops = {
31982 .cable_detect = jmicron_cable_detect,
31983 };
31984
31985 -static const struct ide_port_info jmicron_chipset __devinitdata = {
31986 +static const struct ide_port_info jmicron_chipset __devinitconst = {
31987 .name = DRV_NAME,
31988 .enablebits = { { 0x40, 0x01, 0x01 }, { 0x40, 0x10, 0x10 } },
31989 .port_ops = &jmicron_port_ops,
31990 diff --git a/drivers/ide/ns87415.c b/drivers/ide/ns87415.c
31991 index 95327a2..73f78d8 100644
31992 --- a/drivers/ide/ns87415.c
31993 +++ b/drivers/ide/ns87415.c
31994 @@ -293,7 +293,7 @@ static const struct ide_dma_ops ns87415_dma_ops = {
31995 .dma_sff_read_status = superio_dma_sff_read_status,
31996 };
31997
31998 -static const struct ide_port_info ns87415_chipset __devinitdata = {
31999 +static const struct ide_port_info ns87415_chipset __devinitconst = {
32000 .name = DRV_NAME,
32001 .init_hwif = init_hwif_ns87415,
32002 .tp_ops = &ns87415_tp_ops,
32003 diff --git a/drivers/ide/opti621.c b/drivers/ide/opti621.c
32004 index 1a53a4c..39edc66 100644
32005 --- a/drivers/ide/opti621.c
32006 +++ b/drivers/ide/opti621.c
32007 @@ -131,7 +131,7 @@ static const struct ide_port_ops opti621_port_ops = {
32008 .set_pio_mode = opti621_set_pio_mode,
32009 };
32010
32011 -static const struct ide_port_info opti621_chipset __devinitdata = {
32012 +static const struct ide_port_info opti621_chipset __devinitconst = {
32013 .name = DRV_NAME,
32014 .enablebits = { {0x45, 0x80, 0x00}, {0x40, 0x08, 0x00} },
32015 .port_ops = &opti621_port_ops,
32016 diff --git a/drivers/ide/pdc202xx_new.c b/drivers/ide/pdc202xx_new.c
32017 index 9546fe2..2e5ceb6 100644
32018 --- a/drivers/ide/pdc202xx_new.c
32019 +++ b/drivers/ide/pdc202xx_new.c
32020 @@ -465,7 +465,7 @@ static const struct ide_port_ops pdcnew_port_ops = {
32021 .udma_mask = udma, \
32022 }
32023
32024 -static const struct ide_port_info pdcnew_chipsets[] __devinitdata = {
32025 +static const struct ide_port_info pdcnew_chipsets[] __devinitconst = {
32026 /* 0: PDC202{68,70} */ DECLARE_PDCNEW_DEV(ATA_UDMA5),
32027 /* 1: PDC202{69,71,75,76,77} */ DECLARE_PDCNEW_DEV(ATA_UDMA6),
32028 };
32029 diff --git a/drivers/ide/pdc202xx_old.c b/drivers/ide/pdc202xx_old.c
32030 index 3a35ec6..5634510 100644
32031 --- a/drivers/ide/pdc202xx_old.c
32032 +++ b/drivers/ide/pdc202xx_old.c
32033 @@ -270,7 +270,7 @@ static const struct ide_dma_ops pdc2026x_dma_ops = {
32034 .max_sectors = sectors, \
32035 }
32036
32037 -static const struct ide_port_info pdc202xx_chipsets[] __devinitdata = {
32038 +static const struct ide_port_info pdc202xx_chipsets[] __devinitconst = {
32039 { /* 0: PDC20246 */
32040 .name = DRV_NAME,
32041 .init_chipset = init_chipset_pdc202xx,
32042 diff --git a/drivers/ide/piix.c b/drivers/ide/piix.c
32043 index 1892e81..fe0fd60 100644
32044 --- a/drivers/ide/piix.c
32045 +++ b/drivers/ide/piix.c
32046 @@ -344,7 +344,7 @@ static const struct ide_port_ops ich_port_ops = {
32047 .udma_mask = udma, \
32048 }
32049
32050 -static const struct ide_port_info piix_pci_info[] __devinitdata = {
32051 +static const struct ide_port_info piix_pci_info[] __devinitconst = {
32052 /* 0: MPIIX */
32053 { /*
32054 * MPIIX actually has only a single IDE channel mapped to
32055 diff --git a/drivers/ide/rz1000.c b/drivers/ide/rz1000.c
32056 index a6414a8..c04173e 100644
32057 --- a/drivers/ide/rz1000.c
32058 +++ b/drivers/ide/rz1000.c
32059 @@ -38,7 +38,7 @@ static int __devinit rz1000_disable_readahead(struct pci_dev *dev)
32060 }
32061 }
32062
32063 -static const struct ide_port_info rz1000_chipset __devinitdata = {
32064 +static const struct ide_port_info rz1000_chipset __devinitconst = {
32065 .name = DRV_NAME,
32066 .host_flags = IDE_HFLAG_NO_DMA,
32067 };
32068 diff --git a/drivers/ide/sc1200.c b/drivers/ide/sc1200.c
32069 index 356b9b5..d4758eb 100644
32070 --- a/drivers/ide/sc1200.c
32071 +++ b/drivers/ide/sc1200.c
32072 @@ -291,7 +291,7 @@ static const struct ide_dma_ops sc1200_dma_ops = {
32073 .dma_sff_read_status = ide_dma_sff_read_status,
32074 };
32075
32076 -static const struct ide_port_info sc1200_chipset __devinitdata = {
32077 +static const struct ide_port_info sc1200_chipset __devinitconst = {
32078 .name = DRV_NAME,
32079 .port_ops = &sc1200_port_ops,
32080 .dma_ops = &sc1200_dma_ops,
32081 diff --git a/drivers/ide/scc_pata.c b/drivers/ide/scc_pata.c
32082 index b7f5b0c..9701038 100644
32083 --- a/drivers/ide/scc_pata.c
32084 +++ b/drivers/ide/scc_pata.c
32085 @@ -811,7 +811,7 @@ static const struct ide_dma_ops scc_dma_ops = {
32086 .dma_sff_read_status = scc_dma_sff_read_status,
32087 };
32088
32089 -static const struct ide_port_info scc_chipset __devinitdata = {
32090 +static const struct ide_port_info scc_chipset __devinitconst = {
32091 .name = "sccIDE",
32092 .init_iops = init_iops_scc,
32093 .init_dma = scc_init_dma,
32094 diff --git a/drivers/ide/serverworks.c b/drivers/ide/serverworks.c
32095 index 35fb8da..24d72ef 100644
32096 --- a/drivers/ide/serverworks.c
32097 +++ b/drivers/ide/serverworks.c
32098 @@ -337,7 +337,7 @@ static const struct ide_port_ops svwks_port_ops = {
32099 .cable_detect = svwks_cable_detect,
32100 };
32101
32102 -static const struct ide_port_info serverworks_chipsets[] __devinitdata = {
32103 +static const struct ide_port_info serverworks_chipsets[] __devinitconst = {
32104 { /* 0: OSB4 */
32105 .name = DRV_NAME,
32106 .init_chipset = init_chipset_svwks,
32107 diff --git a/drivers/ide/siimage.c b/drivers/ide/siimage.c
32108 index ddeda44..46f7e30 100644
32109 --- a/drivers/ide/siimage.c
32110 +++ b/drivers/ide/siimage.c
32111 @@ -719,7 +719,7 @@ static const struct ide_dma_ops sil_dma_ops = {
32112 .udma_mask = ATA_UDMA6, \
32113 }
32114
32115 -static const struct ide_port_info siimage_chipsets[] __devinitdata = {
32116 +static const struct ide_port_info siimage_chipsets[] __devinitconst = {
32117 /* 0: SiI680 */ DECLARE_SII_DEV(&sil_pata_port_ops),
32118 /* 1: SiI3112 */ DECLARE_SII_DEV(&sil_sata_port_ops)
32119 };
32120 diff --git a/drivers/ide/sis5513.c b/drivers/ide/sis5513.c
32121 index 4a00225..09e61b4 100644
32122 --- a/drivers/ide/sis5513.c
32123 +++ b/drivers/ide/sis5513.c
32124 @@ -563,7 +563,7 @@ static const struct ide_port_ops sis_ata133_port_ops = {
32125 .cable_detect = sis_cable_detect,
32126 };
32127
32128 -static const struct ide_port_info sis5513_chipset __devinitdata = {
32129 +static const struct ide_port_info sis5513_chipset __devinitconst = {
32130 .name = DRV_NAME,
32131 .init_chipset = init_chipset_sis5513,
32132 .enablebits = { {0x4a, 0x02, 0x02}, {0x4a, 0x04, 0x04} },
32133 diff --git a/drivers/ide/sl82c105.c b/drivers/ide/sl82c105.c
32134 index f21dc2a..d051cd2 100644
32135 --- a/drivers/ide/sl82c105.c
32136 +++ b/drivers/ide/sl82c105.c
32137 @@ -299,7 +299,7 @@ static const struct ide_dma_ops sl82c105_dma_ops = {
32138 .dma_sff_read_status = ide_dma_sff_read_status,
32139 };
32140
32141 -static const struct ide_port_info sl82c105_chipset __devinitdata = {
32142 +static const struct ide_port_info sl82c105_chipset __devinitconst = {
32143 .name = DRV_NAME,
32144 .init_chipset = init_chipset_sl82c105,
32145 .enablebits = {{0x40,0x01,0x01}, {0x40,0x10,0x10}},
32146 diff --git a/drivers/ide/slc90e66.c b/drivers/ide/slc90e66.c
32147 index 864ffe0..863a5e9 100644
32148 --- a/drivers/ide/slc90e66.c
32149 +++ b/drivers/ide/slc90e66.c
32150 @@ -132,7 +132,7 @@ static const struct ide_port_ops slc90e66_port_ops = {
32151 .cable_detect = slc90e66_cable_detect,
32152 };
32153
32154 -static const struct ide_port_info slc90e66_chipset __devinitdata = {
32155 +static const struct ide_port_info slc90e66_chipset __devinitconst = {
32156 .name = DRV_NAME,
32157 .enablebits = { {0x41, 0x80, 0x80}, {0x43, 0x80, 0x80} },
32158 .port_ops = &slc90e66_port_ops,
32159 diff --git a/drivers/ide/tc86c001.c b/drivers/ide/tc86c001.c
32160 index 4799d5c..1794678 100644
32161 --- a/drivers/ide/tc86c001.c
32162 +++ b/drivers/ide/tc86c001.c
32163 @@ -192,7 +192,7 @@ static const struct ide_dma_ops tc86c001_dma_ops = {
32164 .dma_sff_read_status = ide_dma_sff_read_status,
32165 };
32166
32167 -static const struct ide_port_info tc86c001_chipset __devinitdata = {
32168 +static const struct ide_port_info tc86c001_chipset __devinitconst = {
32169 .name = DRV_NAME,
32170 .init_hwif = init_hwif_tc86c001,
32171 .port_ops = &tc86c001_port_ops,
32172 diff --git a/drivers/ide/triflex.c b/drivers/ide/triflex.c
32173 index 281c914..55ce1b8 100644
32174 --- a/drivers/ide/triflex.c
32175 +++ b/drivers/ide/triflex.c
32176 @@ -92,7 +92,7 @@ static const struct ide_port_ops triflex_port_ops = {
32177 .set_dma_mode = triflex_set_mode,
32178 };
32179
32180 -static const struct ide_port_info triflex_device __devinitdata = {
32181 +static const struct ide_port_info triflex_device __devinitconst = {
32182 .name = DRV_NAME,
32183 .enablebits = {{0x80, 0x01, 0x01}, {0x80, 0x02, 0x02}},
32184 .port_ops = &triflex_port_ops,
32185 diff --git a/drivers/ide/trm290.c b/drivers/ide/trm290.c
32186 index 4b42ca0..e494a98 100644
32187 --- a/drivers/ide/trm290.c
32188 +++ b/drivers/ide/trm290.c
32189 @@ -324,7 +324,7 @@ static struct ide_dma_ops trm290_dma_ops = {
32190 .dma_check = trm290_dma_check,
32191 };
32192
32193 -static const struct ide_port_info trm290_chipset __devinitdata = {
32194 +static const struct ide_port_info trm290_chipset __devinitconst = {
32195 .name = DRV_NAME,
32196 .init_hwif = init_hwif_trm290,
32197 .tp_ops = &trm290_tp_ops,
32198 diff --git a/drivers/ide/via82cxxx.c b/drivers/ide/via82cxxx.c
32199 index f46f49c..eb77678 100644
32200 --- a/drivers/ide/via82cxxx.c
32201 +++ b/drivers/ide/via82cxxx.c
32202 @@ -403,7 +403,7 @@ static const struct ide_port_ops via_port_ops = {
32203 .cable_detect = via82cxxx_cable_detect,
32204 };
32205
32206 -static const struct ide_port_info via82cxxx_chipset __devinitdata = {
32207 +static const struct ide_port_info via82cxxx_chipset __devinitconst = {
32208 .name = DRV_NAME,
32209 .init_chipset = init_chipset_via82cxxx,
32210 .enablebits = { { 0x40, 0x02, 0x02 }, { 0x40, 0x01, 0x01 } },
32211 diff --git a/drivers/ieee802154/fakehard.c b/drivers/ieee802154/fakehard.c
32212 index 73d4531..c90cd2d 100644
32213 --- a/drivers/ieee802154/fakehard.c
32214 +++ b/drivers/ieee802154/fakehard.c
32215 @@ -386,7 +386,7 @@ static int __devinit ieee802154fake_probe(struct platform_device *pdev)
32216 phy->transmit_power = 0xbf;
32217
32218 dev->netdev_ops = &fake_ops;
32219 - dev->ml_priv = &fake_mlme;
32220 + dev->ml_priv = (void *)&fake_mlme;
32221
32222 priv = netdev_priv(dev);
32223 priv->phy = phy;
32224 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
32225 index c889aae..6cf5aa7 100644
32226 --- a/drivers/infiniband/core/cm.c
32227 +++ b/drivers/infiniband/core/cm.c
32228 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
32229
32230 struct cm_counter_group {
32231 struct kobject obj;
32232 - atomic_long_t counter[CM_ATTR_COUNT];
32233 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
32234 };
32235
32236 struct cm_counter_attribute {
32237 @@ -1394,7 +1394,7 @@ static void cm_dup_req_handler(struct cm_work *work,
32238 struct ib_mad_send_buf *msg = NULL;
32239 int ret;
32240
32241 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
32242 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
32243 counter[CM_REQ_COUNTER]);
32244
32245 /* Quick state check to discard duplicate REQs. */
32246 @@ -1778,7 +1778,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
32247 if (!cm_id_priv)
32248 return;
32249
32250 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
32251 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
32252 counter[CM_REP_COUNTER]);
32253 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
32254 if (ret)
32255 @@ -1945,7 +1945,7 @@ static int cm_rtu_handler(struct cm_work *work)
32256 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
32257 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
32258 spin_unlock_irq(&cm_id_priv->lock);
32259 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
32260 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
32261 counter[CM_RTU_COUNTER]);
32262 goto out;
32263 }
32264 @@ -2128,7 +2128,7 @@ static int cm_dreq_handler(struct cm_work *work)
32265 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
32266 dreq_msg->local_comm_id);
32267 if (!cm_id_priv) {
32268 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
32269 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
32270 counter[CM_DREQ_COUNTER]);
32271 cm_issue_drep(work->port, work->mad_recv_wc);
32272 return -EINVAL;
32273 @@ -2153,7 +2153,7 @@ static int cm_dreq_handler(struct cm_work *work)
32274 case IB_CM_MRA_REP_RCVD:
32275 break;
32276 case IB_CM_TIMEWAIT:
32277 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
32278 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
32279 counter[CM_DREQ_COUNTER]);
32280 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
32281 goto unlock;
32282 @@ -2167,7 +2167,7 @@ static int cm_dreq_handler(struct cm_work *work)
32283 cm_free_msg(msg);
32284 goto deref;
32285 case IB_CM_DREQ_RCVD:
32286 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
32287 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
32288 counter[CM_DREQ_COUNTER]);
32289 goto unlock;
32290 default:
32291 @@ -2534,7 +2534,7 @@ static int cm_mra_handler(struct cm_work *work)
32292 ib_modify_mad(cm_id_priv->av.port->mad_agent,
32293 cm_id_priv->msg, timeout)) {
32294 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
32295 - atomic_long_inc(&work->port->
32296 + atomic_long_inc_unchecked(&work->port->
32297 counter_group[CM_RECV_DUPLICATES].
32298 counter[CM_MRA_COUNTER]);
32299 goto out;
32300 @@ -2543,7 +2543,7 @@ static int cm_mra_handler(struct cm_work *work)
32301 break;
32302 case IB_CM_MRA_REQ_RCVD:
32303 case IB_CM_MRA_REP_RCVD:
32304 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
32305 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
32306 counter[CM_MRA_COUNTER]);
32307 /* fall through */
32308 default:
32309 @@ -2705,7 +2705,7 @@ static int cm_lap_handler(struct cm_work *work)
32310 case IB_CM_LAP_IDLE:
32311 break;
32312 case IB_CM_MRA_LAP_SENT:
32313 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
32314 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
32315 counter[CM_LAP_COUNTER]);
32316 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
32317 goto unlock;
32318 @@ -2721,7 +2721,7 @@ static int cm_lap_handler(struct cm_work *work)
32319 cm_free_msg(msg);
32320 goto deref;
32321 case IB_CM_LAP_RCVD:
32322 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
32323 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
32324 counter[CM_LAP_COUNTER]);
32325 goto unlock;
32326 default:
32327 @@ -3005,7 +3005,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
32328 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
32329 if (cur_cm_id_priv) {
32330 spin_unlock_irq(&cm.lock);
32331 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
32332 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
32333 counter[CM_SIDR_REQ_COUNTER]);
32334 goto out; /* Duplicate message. */
32335 }
32336 @@ -3217,10 +3217,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
32337 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
32338 msg->retries = 1;
32339
32340 - atomic_long_add(1 + msg->retries,
32341 + atomic_long_add_unchecked(1 + msg->retries,
32342 &port->counter_group[CM_XMIT].counter[attr_index]);
32343 if (msg->retries)
32344 - atomic_long_add(msg->retries,
32345 + atomic_long_add_unchecked(msg->retries,
32346 &port->counter_group[CM_XMIT_RETRIES].
32347 counter[attr_index]);
32348
32349 @@ -3430,7 +3430,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
32350 }
32351
32352 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
32353 - atomic_long_inc(&port->counter_group[CM_RECV].
32354 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
32355 counter[attr_id - CM_ATTR_ID_OFFSET]);
32356
32357 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
32358 @@ -3635,7 +3635,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
32359 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
32360
32361 return sprintf(buf, "%ld\n",
32362 - atomic_long_read(&group->counter[cm_attr->index]));
32363 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
32364 }
32365
32366 static const struct sysfs_ops cm_counter_ops = {
32367 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
32368 index 176c8f9..2627b62 100644
32369 --- a/drivers/infiniband/core/fmr_pool.c
32370 +++ b/drivers/infiniband/core/fmr_pool.c
32371 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
32372
32373 struct task_struct *thread;
32374
32375 - atomic_t req_ser;
32376 - atomic_t flush_ser;
32377 + atomic_unchecked_t req_ser;
32378 + atomic_unchecked_t flush_ser;
32379
32380 wait_queue_head_t force_wait;
32381 };
32382 @@ -180,10 +180,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
32383 struct ib_fmr_pool *pool = pool_ptr;
32384
32385 do {
32386 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
32387 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
32388 ib_fmr_batch_release(pool);
32389
32390 - atomic_inc(&pool->flush_ser);
32391 + atomic_inc_unchecked(&pool->flush_ser);
32392 wake_up_interruptible(&pool->force_wait);
32393
32394 if (pool->flush_function)
32395 @@ -191,7 +191,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
32396 }
32397
32398 set_current_state(TASK_INTERRUPTIBLE);
32399 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
32400 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
32401 !kthread_should_stop())
32402 schedule();
32403 __set_current_state(TASK_RUNNING);
32404 @@ -283,8 +283,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
32405 pool->dirty_watermark = params->dirty_watermark;
32406 pool->dirty_len = 0;
32407 spin_lock_init(&pool->pool_lock);
32408 - atomic_set(&pool->req_ser, 0);
32409 - atomic_set(&pool->flush_ser, 0);
32410 + atomic_set_unchecked(&pool->req_ser, 0);
32411 + atomic_set_unchecked(&pool->flush_ser, 0);
32412 init_waitqueue_head(&pool->force_wait);
32413
32414 pool->thread = kthread_run(ib_fmr_cleanup_thread,
32415 @@ -412,11 +412,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
32416 }
32417 spin_unlock_irq(&pool->pool_lock);
32418
32419 - serial = atomic_inc_return(&pool->req_ser);
32420 + serial = atomic_inc_return_unchecked(&pool->req_ser);
32421 wake_up_process(pool->thread);
32422
32423 if (wait_event_interruptible(pool->force_wait,
32424 - atomic_read(&pool->flush_ser) - serial >= 0))
32425 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
32426 return -EINTR;
32427
32428 return 0;
32429 @@ -526,7 +526,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
32430 } else {
32431 list_add_tail(&fmr->list, &pool->dirty_list);
32432 if (++pool->dirty_len >= pool->dirty_watermark) {
32433 - atomic_inc(&pool->req_ser);
32434 + atomic_inc_unchecked(&pool->req_ser);
32435 wake_up_process(pool->thread);
32436 }
32437 }
32438 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
32439 index 40c8353..946b0e4 100644
32440 --- a/drivers/infiniband/hw/cxgb4/mem.c
32441 +++ b/drivers/infiniband/hw/cxgb4/mem.c
32442 @@ -122,7 +122,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
32443 int err;
32444 struct fw_ri_tpte tpt;
32445 u32 stag_idx;
32446 - static atomic_t key;
32447 + static atomic_unchecked_t key;
32448
32449 if (c4iw_fatal_error(rdev))
32450 return -EIO;
32451 @@ -135,7 +135,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
32452 &rdev->resource.tpt_fifo_lock);
32453 if (!stag_idx)
32454 return -ENOMEM;
32455 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
32456 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
32457 }
32458 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
32459 __func__, stag_state, type, pdid, stag_idx);
32460 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
32461 index 79b3dbc..96e5fcc 100644
32462 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
32463 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
32464 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
32465 struct ib_atomic_eth *ateth;
32466 struct ipath_ack_entry *e;
32467 u64 vaddr;
32468 - atomic64_t *maddr;
32469 + atomic64_unchecked_t *maddr;
32470 u64 sdata;
32471 u32 rkey;
32472 u8 next;
32473 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
32474 IB_ACCESS_REMOTE_ATOMIC)))
32475 goto nack_acc_unlck;
32476 /* Perform atomic OP and save result. */
32477 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
32478 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
32479 sdata = be64_to_cpu(ateth->swap_data);
32480 e = &qp->s_ack_queue[qp->r_head_ack_queue];
32481 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
32482 - (u64) atomic64_add_return(sdata, maddr) - sdata :
32483 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
32484 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
32485 be64_to_cpu(ateth->compare_data),
32486 sdata);
32487 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
32488 index 1f95bba..9530f87 100644
32489 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
32490 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
32491 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
32492 unsigned long flags;
32493 struct ib_wc wc;
32494 u64 sdata;
32495 - atomic64_t *maddr;
32496 + atomic64_unchecked_t *maddr;
32497 enum ib_wc_status send_status;
32498
32499 /*
32500 @@ -382,11 +382,11 @@ again:
32501 IB_ACCESS_REMOTE_ATOMIC)))
32502 goto acc_err;
32503 /* Perform atomic OP and save result. */
32504 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
32505 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
32506 sdata = wqe->wr.wr.atomic.compare_add;
32507 *(u64 *) sqp->s_sge.sge.vaddr =
32508 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
32509 - (u64) atomic64_add_return(sdata, maddr) - sdata :
32510 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
32511 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
32512 sdata, wqe->wr.wr.atomic.swap);
32513 goto send_comp;
32514 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
32515 index 7140199..da60063 100644
32516 --- a/drivers/infiniband/hw/nes/nes.c
32517 +++ b/drivers/infiniband/hw/nes/nes.c
32518 @@ -103,7 +103,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
32519 LIST_HEAD(nes_adapter_list);
32520 static LIST_HEAD(nes_dev_list);
32521
32522 -atomic_t qps_destroyed;
32523 +atomic_unchecked_t qps_destroyed;
32524
32525 static unsigned int ee_flsh_adapter;
32526 static unsigned int sysfs_nonidx_addr;
32527 @@ -272,7 +272,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
32528 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
32529 struct nes_adapter *nesadapter = nesdev->nesadapter;
32530
32531 - atomic_inc(&qps_destroyed);
32532 + atomic_inc_unchecked(&qps_destroyed);
32533
32534 /* Free the control structures */
32535
32536 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
32537 index c438e46..ca30356 100644
32538 --- a/drivers/infiniband/hw/nes/nes.h
32539 +++ b/drivers/infiniband/hw/nes/nes.h
32540 @@ -178,17 +178,17 @@ extern unsigned int nes_debug_level;
32541 extern unsigned int wqm_quanta;
32542 extern struct list_head nes_adapter_list;
32543
32544 -extern atomic_t cm_connects;
32545 -extern atomic_t cm_accepts;
32546 -extern atomic_t cm_disconnects;
32547 -extern atomic_t cm_closes;
32548 -extern atomic_t cm_connecteds;
32549 -extern atomic_t cm_connect_reqs;
32550 -extern atomic_t cm_rejects;
32551 -extern atomic_t mod_qp_timouts;
32552 -extern atomic_t qps_created;
32553 -extern atomic_t qps_destroyed;
32554 -extern atomic_t sw_qps_destroyed;
32555 +extern atomic_unchecked_t cm_connects;
32556 +extern atomic_unchecked_t cm_accepts;
32557 +extern atomic_unchecked_t cm_disconnects;
32558 +extern atomic_unchecked_t cm_closes;
32559 +extern atomic_unchecked_t cm_connecteds;
32560 +extern atomic_unchecked_t cm_connect_reqs;
32561 +extern atomic_unchecked_t cm_rejects;
32562 +extern atomic_unchecked_t mod_qp_timouts;
32563 +extern atomic_unchecked_t qps_created;
32564 +extern atomic_unchecked_t qps_destroyed;
32565 +extern atomic_unchecked_t sw_qps_destroyed;
32566 extern u32 mh_detected;
32567 extern u32 mh_pauses_sent;
32568 extern u32 cm_packets_sent;
32569 @@ -197,16 +197,16 @@ extern u32 cm_packets_created;
32570 extern u32 cm_packets_received;
32571 extern u32 cm_packets_dropped;
32572 extern u32 cm_packets_retrans;
32573 -extern atomic_t cm_listens_created;
32574 -extern atomic_t cm_listens_destroyed;
32575 +extern atomic_unchecked_t cm_listens_created;
32576 +extern atomic_unchecked_t cm_listens_destroyed;
32577 extern u32 cm_backlog_drops;
32578 -extern atomic_t cm_loopbacks;
32579 -extern atomic_t cm_nodes_created;
32580 -extern atomic_t cm_nodes_destroyed;
32581 -extern atomic_t cm_accel_dropped_pkts;
32582 -extern atomic_t cm_resets_recvd;
32583 -extern atomic_t pau_qps_created;
32584 -extern atomic_t pau_qps_destroyed;
32585 +extern atomic_unchecked_t cm_loopbacks;
32586 +extern atomic_unchecked_t cm_nodes_created;
32587 +extern atomic_unchecked_t cm_nodes_destroyed;
32588 +extern atomic_unchecked_t cm_accel_dropped_pkts;
32589 +extern atomic_unchecked_t cm_resets_recvd;
32590 +extern atomic_unchecked_t pau_qps_created;
32591 +extern atomic_unchecked_t pau_qps_destroyed;
32592
32593 extern u32 int_mod_timer_init;
32594 extern u32 int_mod_cq_depth_256;
32595 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
32596 index a4972ab..1bcfc31 100644
32597 --- a/drivers/infiniband/hw/nes/nes_cm.c
32598 +++ b/drivers/infiniband/hw/nes/nes_cm.c
32599 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
32600 u32 cm_packets_retrans;
32601 u32 cm_packets_created;
32602 u32 cm_packets_received;
32603 -atomic_t cm_listens_created;
32604 -atomic_t cm_listens_destroyed;
32605 +atomic_unchecked_t cm_listens_created;
32606 +atomic_unchecked_t cm_listens_destroyed;
32607 u32 cm_backlog_drops;
32608 -atomic_t cm_loopbacks;
32609 -atomic_t cm_nodes_created;
32610 -atomic_t cm_nodes_destroyed;
32611 -atomic_t cm_accel_dropped_pkts;
32612 -atomic_t cm_resets_recvd;
32613 +atomic_unchecked_t cm_loopbacks;
32614 +atomic_unchecked_t cm_nodes_created;
32615 +atomic_unchecked_t cm_nodes_destroyed;
32616 +atomic_unchecked_t cm_accel_dropped_pkts;
32617 +atomic_unchecked_t cm_resets_recvd;
32618
32619 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
32620 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
32621 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
32622
32623 static struct nes_cm_core *g_cm_core;
32624
32625 -atomic_t cm_connects;
32626 -atomic_t cm_accepts;
32627 -atomic_t cm_disconnects;
32628 -atomic_t cm_closes;
32629 -atomic_t cm_connecteds;
32630 -atomic_t cm_connect_reqs;
32631 -atomic_t cm_rejects;
32632 +atomic_unchecked_t cm_connects;
32633 +atomic_unchecked_t cm_accepts;
32634 +atomic_unchecked_t cm_disconnects;
32635 +atomic_unchecked_t cm_closes;
32636 +atomic_unchecked_t cm_connecteds;
32637 +atomic_unchecked_t cm_connect_reqs;
32638 +atomic_unchecked_t cm_rejects;
32639
32640 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
32641 {
32642 @@ -1274,7 +1274,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
32643 kfree(listener);
32644 listener = NULL;
32645 ret = 0;
32646 - atomic_inc(&cm_listens_destroyed);
32647 + atomic_inc_unchecked(&cm_listens_destroyed);
32648 } else {
32649 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
32650 }
32651 @@ -1473,7 +1473,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
32652 cm_node->rem_mac);
32653
32654 add_hte_node(cm_core, cm_node);
32655 - atomic_inc(&cm_nodes_created);
32656 + atomic_inc_unchecked(&cm_nodes_created);
32657
32658 return cm_node;
32659 }
32660 @@ -1531,7 +1531,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
32661 }
32662
32663 atomic_dec(&cm_core->node_cnt);
32664 - atomic_inc(&cm_nodes_destroyed);
32665 + atomic_inc_unchecked(&cm_nodes_destroyed);
32666 nesqp = cm_node->nesqp;
32667 if (nesqp) {
32668 nesqp->cm_node = NULL;
32669 @@ -1595,7 +1595,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
32670
32671 static void drop_packet(struct sk_buff *skb)
32672 {
32673 - atomic_inc(&cm_accel_dropped_pkts);
32674 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
32675 dev_kfree_skb_any(skb);
32676 }
32677
32678 @@ -1658,7 +1658,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
32679 {
32680
32681 int reset = 0; /* whether to send reset in case of err.. */
32682 - atomic_inc(&cm_resets_recvd);
32683 + atomic_inc_unchecked(&cm_resets_recvd);
32684 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
32685 " refcnt=%d\n", cm_node, cm_node->state,
32686 atomic_read(&cm_node->ref_count));
32687 @@ -2299,7 +2299,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
32688 rem_ref_cm_node(cm_node->cm_core, cm_node);
32689 return NULL;
32690 }
32691 - atomic_inc(&cm_loopbacks);
32692 + atomic_inc_unchecked(&cm_loopbacks);
32693 loopbackremotenode->loopbackpartner = cm_node;
32694 loopbackremotenode->tcp_cntxt.rcv_wscale =
32695 NES_CM_DEFAULT_RCV_WND_SCALE;
32696 @@ -2574,7 +2574,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
32697 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
32698 else {
32699 rem_ref_cm_node(cm_core, cm_node);
32700 - atomic_inc(&cm_accel_dropped_pkts);
32701 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
32702 dev_kfree_skb_any(skb);
32703 }
32704 break;
32705 @@ -2881,7 +2881,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
32706
32707 if ((cm_id) && (cm_id->event_handler)) {
32708 if (issue_disconn) {
32709 - atomic_inc(&cm_disconnects);
32710 + atomic_inc_unchecked(&cm_disconnects);
32711 cm_event.event = IW_CM_EVENT_DISCONNECT;
32712 cm_event.status = disconn_status;
32713 cm_event.local_addr = cm_id->local_addr;
32714 @@ -2903,7 +2903,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
32715 }
32716
32717 if (issue_close) {
32718 - atomic_inc(&cm_closes);
32719 + atomic_inc_unchecked(&cm_closes);
32720 nes_disconnect(nesqp, 1);
32721
32722 cm_id->provider_data = nesqp;
32723 @@ -3039,7 +3039,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
32724
32725 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
32726 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
32727 - atomic_inc(&cm_accepts);
32728 + atomic_inc_unchecked(&cm_accepts);
32729
32730 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
32731 netdev_refcnt_read(nesvnic->netdev));
32732 @@ -3241,7 +3241,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
32733 struct nes_cm_core *cm_core;
32734 u8 *start_buff;
32735
32736 - atomic_inc(&cm_rejects);
32737 + atomic_inc_unchecked(&cm_rejects);
32738 cm_node = (struct nes_cm_node *)cm_id->provider_data;
32739 loopback = cm_node->loopbackpartner;
32740 cm_core = cm_node->cm_core;
32741 @@ -3301,7 +3301,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
32742 ntohl(cm_id->local_addr.sin_addr.s_addr),
32743 ntohs(cm_id->local_addr.sin_port));
32744
32745 - atomic_inc(&cm_connects);
32746 + atomic_inc_unchecked(&cm_connects);
32747 nesqp->active_conn = 1;
32748
32749 /* cache the cm_id in the qp */
32750 @@ -3407,7 +3407,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
32751 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
32752 return err;
32753 }
32754 - atomic_inc(&cm_listens_created);
32755 + atomic_inc_unchecked(&cm_listens_created);
32756 }
32757
32758 cm_id->add_ref(cm_id);
32759 @@ -3508,7 +3508,7 @@ static void cm_event_connected(struct nes_cm_event *event)
32760
32761 if (nesqp->destroyed)
32762 return;
32763 - atomic_inc(&cm_connecteds);
32764 + atomic_inc_unchecked(&cm_connecteds);
32765 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
32766 " local port 0x%04X. jiffies = %lu.\n",
32767 nesqp->hwqp.qp_id,
32768 @@ -3695,7 +3695,7 @@ static void cm_event_reset(struct nes_cm_event *event)
32769
32770 cm_id->add_ref(cm_id);
32771 ret = cm_id->event_handler(cm_id, &cm_event);
32772 - atomic_inc(&cm_closes);
32773 + atomic_inc_unchecked(&cm_closes);
32774 cm_event.event = IW_CM_EVENT_CLOSE;
32775 cm_event.status = 0;
32776 cm_event.provider_data = cm_id->provider_data;
32777 @@ -3731,7 +3731,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
32778 return;
32779 cm_id = cm_node->cm_id;
32780
32781 - atomic_inc(&cm_connect_reqs);
32782 + atomic_inc_unchecked(&cm_connect_reqs);
32783 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
32784 cm_node, cm_id, jiffies);
32785
32786 @@ -3771,7 +3771,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
32787 return;
32788 cm_id = cm_node->cm_id;
32789
32790 - atomic_inc(&cm_connect_reqs);
32791 + atomic_inc_unchecked(&cm_connect_reqs);
32792 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
32793 cm_node, cm_id, jiffies);
32794
32795 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
32796 index 3ba7be3..c81f6ff 100644
32797 --- a/drivers/infiniband/hw/nes/nes_mgt.c
32798 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
32799 @@ -40,8 +40,8 @@
32800 #include "nes.h"
32801 #include "nes_mgt.h"
32802
32803 -atomic_t pau_qps_created;
32804 -atomic_t pau_qps_destroyed;
32805 +atomic_unchecked_t pau_qps_created;
32806 +atomic_unchecked_t pau_qps_destroyed;
32807
32808 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
32809 {
32810 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
32811 {
32812 struct sk_buff *skb;
32813 unsigned long flags;
32814 - atomic_inc(&pau_qps_destroyed);
32815 + atomic_inc_unchecked(&pau_qps_destroyed);
32816
32817 /* Free packets that have not yet been forwarded */
32818 /* Lock is acquired by skb_dequeue when removing the skb */
32819 @@ -812,7 +812,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
32820 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
32821 skb_queue_head_init(&nesqp->pau_list);
32822 spin_lock_init(&nesqp->pau_lock);
32823 - atomic_inc(&pau_qps_created);
32824 + atomic_inc_unchecked(&pau_qps_created);
32825 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
32826 }
32827
32828 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
32829 index f3a3ecf..57d311d 100644
32830 --- a/drivers/infiniband/hw/nes/nes_nic.c
32831 +++ b/drivers/infiniband/hw/nes/nes_nic.c
32832 @@ -1277,39 +1277,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
32833 target_stat_values[++index] = mh_detected;
32834 target_stat_values[++index] = mh_pauses_sent;
32835 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
32836 - target_stat_values[++index] = atomic_read(&cm_connects);
32837 - target_stat_values[++index] = atomic_read(&cm_accepts);
32838 - target_stat_values[++index] = atomic_read(&cm_disconnects);
32839 - target_stat_values[++index] = atomic_read(&cm_connecteds);
32840 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
32841 - target_stat_values[++index] = atomic_read(&cm_rejects);
32842 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
32843 - target_stat_values[++index] = atomic_read(&qps_created);
32844 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
32845 - target_stat_values[++index] = atomic_read(&qps_destroyed);
32846 - target_stat_values[++index] = atomic_read(&cm_closes);
32847 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
32848 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
32849 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
32850 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
32851 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
32852 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
32853 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
32854 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
32855 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
32856 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
32857 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
32858 target_stat_values[++index] = cm_packets_sent;
32859 target_stat_values[++index] = cm_packets_bounced;
32860 target_stat_values[++index] = cm_packets_created;
32861 target_stat_values[++index] = cm_packets_received;
32862 target_stat_values[++index] = cm_packets_dropped;
32863 target_stat_values[++index] = cm_packets_retrans;
32864 - target_stat_values[++index] = atomic_read(&cm_listens_created);
32865 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
32866 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
32867 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
32868 target_stat_values[++index] = cm_backlog_drops;
32869 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
32870 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
32871 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
32872 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
32873 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
32874 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
32875 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
32876 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
32877 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
32878 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
32879 target_stat_values[++index] = nesadapter->free_4kpbl;
32880 target_stat_values[++index] = nesadapter->free_256pbl;
32881 target_stat_values[++index] = int_mod_timer_init;
32882 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
32883 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
32884 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
32885 - target_stat_values[++index] = atomic_read(&pau_qps_created);
32886 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
32887 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
32888 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
32889 }
32890
32891 /**
32892 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
32893 index 0927b5c..ed67986 100644
32894 --- a/drivers/infiniband/hw/nes/nes_verbs.c
32895 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
32896 @@ -46,9 +46,9 @@
32897
32898 #include <rdma/ib_umem.h>
32899
32900 -atomic_t mod_qp_timouts;
32901 -atomic_t qps_created;
32902 -atomic_t sw_qps_destroyed;
32903 +atomic_unchecked_t mod_qp_timouts;
32904 +atomic_unchecked_t qps_created;
32905 +atomic_unchecked_t sw_qps_destroyed;
32906
32907 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
32908
32909 @@ -1131,7 +1131,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
32910 if (init_attr->create_flags)
32911 return ERR_PTR(-EINVAL);
32912
32913 - atomic_inc(&qps_created);
32914 + atomic_inc_unchecked(&qps_created);
32915 switch (init_attr->qp_type) {
32916 case IB_QPT_RC:
32917 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
32918 @@ -1460,7 +1460,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
32919 struct iw_cm_event cm_event;
32920 int ret = 0;
32921
32922 - atomic_inc(&sw_qps_destroyed);
32923 + atomic_inc_unchecked(&sw_qps_destroyed);
32924 nesqp->destroyed = 1;
32925
32926 /* Blow away the connection if it exists. */
32927 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
32928 index b881bdc..c2e360c 100644
32929 --- a/drivers/infiniband/hw/qib/qib.h
32930 +++ b/drivers/infiniband/hw/qib/qib.h
32931 @@ -51,6 +51,7 @@
32932 #include <linux/completion.h>
32933 #include <linux/kref.h>
32934 #include <linux/sched.h>
32935 +#include <linux/slab.h>
32936
32937 #include "qib_common.h"
32938 #include "qib_verbs.h"
32939 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
32940 index c351aa4..e6967c2 100644
32941 --- a/drivers/input/gameport/gameport.c
32942 +++ b/drivers/input/gameport/gameport.c
32943 @@ -488,14 +488,14 @@ EXPORT_SYMBOL(gameport_set_phys);
32944 */
32945 static void gameport_init_port(struct gameport *gameport)
32946 {
32947 - static atomic_t gameport_no = ATOMIC_INIT(0);
32948 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
32949
32950 __module_get(THIS_MODULE);
32951
32952 mutex_init(&gameport->drv_mutex);
32953 device_initialize(&gameport->dev);
32954 dev_set_name(&gameport->dev, "gameport%lu",
32955 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
32956 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
32957 gameport->dev.bus = &gameport_bus;
32958 gameport->dev.release = gameport_release_port;
32959 if (gameport->parent)
32960 diff --git a/drivers/input/input.c b/drivers/input/input.c
32961 index 1f78c95..3cddc6c 100644
32962 --- a/drivers/input/input.c
32963 +++ b/drivers/input/input.c
32964 @@ -1814,7 +1814,7 @@ static void input_cleanse_bitmasks(struct input_dev *dev)
32965 */
32966 int input_register_device(struct input_dev *dev)
32967 {
32968 - static atomic_t input_no = ATOMIC_INIT(0);
32969 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
32970 struct input_handler *handler;
32971 const char *path;
32972 int error;
32973 @@ -1851,7 +1851,7 @@ int input_register_device(struct input_dev *dev)
32974 dev->setkeycode = input_default_setkeycode;
32975
32976 dev_set_name(&dev->dev, "input%ld",
32977 - (unsigned long) atomic_inc_return(&input_no) - 1);
32978 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
32979
32980 error = device_add(&dev->dev);
32981 if (error)
32982 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
32983 index b8d8611..7a4a04b 100644
32984 --- a/drivers/input/joystick/sidewinder.c
32985 +++ b/drivers/input/joystick/sidewinder.c
32986 @@ -30,6 +30,7 @@
32987 #include <linux/kernel.h>
32988 #include <linux/module.h>
32989 #include <linux/slab.h>
32990 +#include <linux/sched.h>
32991 #include <linux/init.h>
32992 #include <linux/input.h>
32993 #include <linux/gameport.h>
32994 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
32995 index fd7a0d5..a4af10c 100644
32996 --- a/drivers/input/joystick/xpad.c
32997 +++ b/drivers/input/joystick/xpad.c
32998 @@ -710,7 +710,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
32999
33000 static int xpad_led_probe(struct usb_xpad *xpad)
33001 {
33002 - static atomic_t led_seq = ATOMIC_INIT(0);
33003 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
33004 long led_no;
33005 struct xpad_led *led;
33006 struct led_classdev *led_cdev;
33007 @@ -723,7 +723,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
33008 if (!led)
33009 return -ENOMEM;
33010
33011 - led_no = (long)atomic_inc_return(&led_seq) - 1;
33012 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
33013
33014 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
33015 led->xpad = xpad;
33016 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
33017 index 0110b5a..d3ad144 100644
33018 --- a/drivers/input/mousedev.c
33019 +++ b/drivers/input/mousedev.c
33020 @@ -763,7 +763,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
33021
33022 spin_unlock_irq(&client->packet_lock);
33023
33024 - if (copy_to_user(buffer, data, count))
33025 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
33026 return -EFAULT;
33027
33028 return count;
33029 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
33030 index ba70058..571d25d 100644
33031 --- a/drivers/input/serio/serio.c
33032 +++ b/drivers/input/serio/serio.c
33033 @@ -497,7 +497,7 @@ static void serio_release_port(struct device *dev)
33034 */
33035 static void serio_init_port(struct serio *serio)
33036 {
33037 - static atomic_t serio_no = ATOMIC_INIT(0);
33038 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
33039
33040 __module_get(THIS_MODULE);
33041
33042 @@ -508,7 +508,7 @@ static void serio_init_port(struct serio *serio)
33043 mutex_init(&serio->drv_mutex);
33044 device_initialize(&serio->dev);
33045 dev_set_name(&serio->dev, "serio%ld",
33046 - (long)atomic_inc_return(&serio_no) - 1);
33047 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
33048 serio->dev.bus = &serio_bus;
33049 serio->dev.release = serio_release_port;
33050 serio->dev.groups = serio_device_attr_groups;
33051 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
33052 index e44933d..9ba484a 100644
33053 --- a/drivers/isdn/capi/capi.c
33054 +++ b/drivers/isdn/capi/capi.c
33055 @@ -83,8 +83,8 @@ struct capiminor {
33056
33057 struct capi20_appl *ap;
33058 u32 ncci;
33059 - atomic_t datahandle;
33060 - atomic_t msgid;
33061 + atomic_unchecked_t datahandle;
33062 + atomic_unchecked_t msgid;
33063
33064 struct tty_port port;
33065 int ttyinstop;
33066 @@ -397,7 +397,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
33067 capimsg_setu16(s, 2, mp->ap->applid);
33068 capimsg_setu8 (s, 4, CAPI_DATA_B3);
33069 capimsg_setu8 (s, 5, CAPI_RESP);
33070 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
33071 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
33072 capimsg_setu32(s, 8, mp->ncci);
33073 capimsg_setu16(s, 12, datahandle);
33074 }
33075 @@ -518,14 +518,14 @@ static void handle_minor_send(struct capiminor *mp)
33076 mp->outbytes -= len;
33077 spin_unlock_bh(&mp->outlock);
33078
33079 - datahandle = atomic_inc_return(&mp->datahandle);
33080 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
33081 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
33082 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
33083 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
33084 capimsg_setu16(skb->data, 2, mp->ap->applid);
33085 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
33086 capimsg_setu8 (skb->data, 5, CAPI_REQ);
33087 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
33088 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
33089 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
33090 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
33091 capimsg_setu16(skb->data, 16, len); /* Data length */
33092 diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c
33093 index db621db..825ea1a 100644
33094 --- a/drivers/isdn/gigaset/common.c
33095 +++ b/drivers/isdn/gigaset/common.c
33096 @@ -723,7 +723,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
33097 cs->commands_pending = 0;
33098 cs->cur_at_seq = 0;
33099 cs->gotfwver = -1;
33100 - cs->open_count = 0;
33101 + local_set(&cs->open_count, 0);
33102 cs->dev = NULL;
33103 cs->tty = NULL;
33104 cs->tty_dev = NULL;
33105 diff --git a/drivers/isdn/gigaset/gigaset.h b/drivers/isdn/gigaset/gigaset.h
33106 index 212efaf..f187c6b 100644
33107 --- a/drivers/isdn/gigaset/gigaset.h
33108 +++ b/drivers/isdn/gigaset/gigaset.h
33109 @@ -35,6 +35,7 @@
33110 #include <linux/tty_driver.h>
33111 #include <linux/list.h>
33112 #include <linux/atomic.h>
33113 +#include <asm/local.h>
33114
33115 #define GIG_VERSION {0, 5, 0, 0}
33116 #define GIG_COMPAT {0, 4, 0, 0}
33117 @@ -433,7 +434,7 @@ struct cardstate {
33118 spinlock_t cmdlock;
33119 unsigned curlen, cmdbytes;
33120
33121 - unsigned open_count;
33122 + local_t open_count;
33123 struct tty_struct *tty;
33124 struct tasklet_struct if_wake_tasklet;
33125 unsigned control_state;
33126 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
33127 index ee0a549..a7c9798 100644
33128 --- a/drivers/isdn/gigaset/interface.c
33129 +++ b/drivers/isdn/gigaset/interface.c
33130 @@ -163,9 +163,7 @@ static int if_open(struct tty_struct *tty, struct file *filp)
33131 }
33132 tty->driver_data = cs;
33133
33134 - ++cs->open_count;
33135 -
33136 - if (cs->open_count == 1) {
33137 + if (local_inc_return(&cs->open_count) == 1) {
33138 spin_lock_irqsave(&cs->lock, flags);
33139 cs->tty = tty;
33140 spin_unlock_irqrestore(&cs->lock, flags);
33141 @@ -193,10 +191,10 @@ static void if_close(struct tty_struct *tty, struct file *filp)
33142
33143 if (!cs->connected)
33144 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
33145 - else if (!cs->open_count)
33146 + else if (!local_read(&cs->open_count))
33147 dev_warn(cs->dev, "%s: device not opened\n", __func__);
33148 else {
33149 - if (!--cs->open_count) {
33150 + if (!local_dec_return(&cs->open_count)) {
33151 spin_lock_irqsave(&cs->lock, flags);
33152 cs->tty = NULL;
33153 spin_unlock_irqrestore(&cs->lock, flags);
33154 @@ -231,7 +229,7 @@ static int if_ioctl(struct tty_struct *tty,
33155 if (!cs->connected) {
33156 gig_dbg(DEBUG_IF, "not connected");
33157 retval = -ENODEV;
33158 - } else if (!cs->open_count)
33159 + } else if (!local_read(&cs->open_count))
33160 dev_warn(cs->dev, "%s: device not opened\n", __func__);
33161 else {
33162 retval = 0;
33163 @@ -361,7 +359,7 @@ static int if_write(struct tty_struct *tty, const unsigned char *buf, int count)
33164 retval = -ENODEV;
33165 goto done;
33166 }
33167 - if (!cs->open_count) {
33168 + if (!local_read(&cs->open_count)) {
33169 dev_warn(cs->dev, "%s: device not opened\n", __func__);
33170 retval = -ENODEV;
33171 goto done;
33172 @@ -414,7 +412,7 @@ static int if_write_room(struct tty_struct *tty)
33173 if (!cs->connected) {
33174 gig_dbg(DEBUG_IF, "not connected");
33175 retval = -ENODEV;
33176 - } else if (!cs->open_count)
33177 + } else if (!local_read(&cs->open_count))
33178 dev_warn(cs->dev, "%s: device not opened\n", __func__);
33179 else if (cs->mstate != MS_LOCKED) {
33180 dev_warn(cs->dev, "can't write to unlocked device\n");
33181 @@ -444,7 +442,7 @@ static int if_chars_in_buffer(struct tty_struct *tty)
33182
33183 if (!cs->connected)
33184 gig_dbg(DEBUG_IF, "not connected");
33185 - else if (!cs->open_count)
33186 + else if (!local_read(&cs->open_count))
33187 dev_warn(cs->dev, "%s: device not opened\n", __func__);
33188 else if (cs->mstate != MS_LOCKED)
33189 dev_warn(cs->dev, "can't write to unlocked device\n");
33190 @@ -472,7 +470,7 @@ static void if_throttle(struct tty_struct *tty)
33191
33192 if (!cs->connected)
33193 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
33194 - else if (!cs->open_count)
33195 + else if (!local_read(&cs->open_count))
33196 dev_warn(cs->dev, "%s: device not opened\n", __func__);
33197 else
33198 gig_dbg(DEBUG_IF, "%s: not implemented\n", __func__);
33199 @@ -496,7 +494,7 @@ static void if_unthrottle(struct tty_struct *tty)
33200
33201 if (!cs->connected)
33202 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
33203 - else if (!cs->open_count)
33204 + else if (!local_read(&cs->open_count))
33205 dev_warn(cs->dev, "%s: device not opened\n", __func__);
33206 else
33207 gig_dbg(DEBUG_IF, "%s: not implemented\n", __func__);
33208 @@ -527,7 +525,7 @@ static void if_set_termios(struct tty_struct *tty, struct ktermios *old)
33209 goto out;
33210 }
33211
33212 - if (!cs->open_count) {
33213 + if (!local_read(&cs->open_count)) {
33214 dev_warn(cs->dev, "%s: device not opened\n", __func__);
33215 goto out;
33216 }
33217 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
33218 index 2a57da59..e7a12ed 100644
33219 --- a/drivers/isdn/hardware/avm/b1.c
33220 +++ b/drivers/isdn/hardware/avm/b1.c
33221 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart * t4file)
33222 }
33223 if (left) {
33224 if (t4file->user) {
33225 - if (copy_from_user(buf, dp, left))
33226 + if (left > sizeof buf || copy_from_user(buf, dp, left))
33227 return -EFAULT;
33228 } else {
33229 memcpy(buf, dp, left);
33230 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart * config)
33231 }
33232 if (left) {
33233 if (config->user) {
33234 - if (copy_from_user(buf, dp, left))
33235 + if (left > sizeof buf || copy_from_user(buf, dp, left))
33236 return -EFAULT;
33237 } else {
33238 memcpy(buf, dp, left);
33239 diff --git a/drivers/isdn/hardware/eicon/divasync.h b/drivers/isdn/hardware/eicon/divasync.h
33240 index 85784a7..a19ca98 100644
33241 --- a/drivers/isdn/hardware/eicon/divasync.h
33242 +++ b/drivers/isdn/hardware/eicon/divasync.h
33243 @@ -146,7 +146,7 @@ typedef struct _diva_didd_add_adapter {
33244 } diva_didd_add_adapter_t;
33245 typedef struct _diva_didd_remove_adapter {
33246 IDI_CALL p_request;
33247 -} diva_didd_remove_adapter_t;
33248 +} __no_const diva_didd_remove_adapter_t;
33249 typedef struct _diva_didd_read_adapter_array {
33250 void * buffer;
33251 dword length;
33252 diff --git a/drivers/isdn/hardware/eicon/xdi_adapter.h b/drivers/isdn/hardware/eicon/xdi_adapter.h
33253 index a3bd163..8956575 100644
33254 --- a/drivers/isdn/hardware/eicon/xdi_adapter.h
33255 +++ b/drivers/isdn/hardware/eicon/xdi_adapter.h
33256 @@ -44,7 +44,7 @@ typedef struct _xdi_mbox_t {
33257 typedef struct _diva_os_idi_adapter_interface {
33258 diva_init_card_proc_t cleanup_adapter_proc;
33259 diva_cmd_card_proc_t cmd_proc;
33260 -} diva_os_idi_adapter_interface_t;
33261 +} __no_const diva_os_idi_adapter_interface_t;
33262
33263 typedef struct _diva_os_xdi_adapter {
33264 struct list_head link;
33265 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
33266 index 1f355bb..43f1fea 100644
33267 --- a/drivers/isdn/icn/icn.c
33268 +++ b/drivers/isdn/icn/icn.c
33269 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char * buf, int len, int user, icn_card * card)
33270 if (count > len)
33271 count = len;
33272 if (user) {
33273 - if (copy_from_user(msg, buf, count))
33274 + if (count > sizeof msg || copy_from_user(msg, buf, count))
33275 return -EFAULT;
33276 } else
33277 memcpy(msg, buf, count);
33278 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
33279 index b5fdcb7..5b6c59f 100644
33280 --- a/drivers/lguest/core.c
33281 +++ b/drivers/lguest/core.c
33282 @@ -92,9 +92,17 @@ static __init int map_switcher(void)
33283 * it's worked so far. The end address needs +1 because __get_vm_area
33284 * allocates an extra guard page, so we need space for that.
33285 */
33286 +
33287 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
33288 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
33289 + VM_ALLOC | VM_KERNEXEC, SWITCHER_ADDR, SWITCHER_ADDR
33290 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
33291 +#else
33292 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
33293 VM_ALLOC, SWITCHER_ADDR, SWITCHER_ADDR
33294 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
33295 +#endif
33296 +
33297 if (!switcher_vma) {
33298 err = -ENOMEM;
33299 printk("lguest: could not map switcher pages high\n");
33300 @@ -119,7 +127,7 @@ static __init int map_switcher(void)
33301 * Now the Switcher is mapped at the right address, we can't fail!
33302 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
33303 */
33304 - memcpy(switcher_vma->addr, start_switcher_text,
33305 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
33306 end_switcher_text - start_switcher_text);
33307
33308 printk(KERN_INFO "lguest: mapped switcher at %p\n",
33309 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
33310 index 3980903..ce25c5e 100644
33311 --- a/drivers/lguest/x86/core.c
33312 +++ b/drivers/lguest/x86/core.c
33313 @@ -59,7 +59,7 @@ static struct {
33314 /* Offset from where switcher.S was compiled to where we've copied it */
33315 static unsigned long switcher_offset(void)
33316 {
33317 - return SWITCHER_ADDR - (unsigned long)start_switcher_text;
33318 + return SWITCHER_ADDR - (unsigned long)ktla_ktva(start_switcher_text);
33319 }
33320
33321 /* This cpu's struct lguest_pages. */
33322 @@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
33323 * These copies are pretty cheap, so we do them unconditionally: */
33324 /* Save the current Host top-level page directory.
33325 */
33326 +
33327 +#ifdef CONFIG_PAX_PER_CPU_PGD
33328 + pages->state.host_cr3 = read_cr3();
33329 +#else
33330 pages->state.host_cr3 = __pa(current->mm->pgd);
33331 +#endif
33332 +
33333 /*
33334 * Set up the Guest's page tables to see this CPU's pages (and no
33335 * other CPU's pages).
33336 @@ -472,7 +478,7 @@ void __init lguest_arch_host_init(void)
33337 * compiled-in switcher code and the high-mapped copy we just made.
33338 */
33339 for (i = 0; i < IDT_ENTRIES; i++)
33340 - default_idt_entries[i] += switcher_offset();
33341 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
33342
33343 /*
33344 * Set up the Switcher's per-cpu areas.
33345 @@ -555,7 +561,7 @@ void __init lguest_arch_host_init(void)
33346 * it will be undisturbed when we switch. To change %cs and jump we
33347 * need this structure to feed to Intel's "lcall" instruction.
33348 */
33349 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
33350 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
33351 lguest_entry.segment = LGUEST_CS;
33352
33353 /*
33354 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
33355 index 40634b0..4f5855e 100644
33356 --- a/drivers/lguest/x86/switcher_32.S
33357 +++ b/drivers/lguest/x86/switcher_32.S
33358 @@ -87,6 +87,7 @@
33359 #include <asm/page.h>
33360 #include <asm/segment.h>
33361 #include <asm/lguest.h>
33362 +#include <asm/processor-flags.h>
33363
33364 // We mark the start of the code to copy
33365 // It's placed in .text tho it's never run here
33366 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
33367 // Changes type when we load it: damn Intel!
33368 // For after we switch over our page tables
33369 // That entry will be read-only: we'd crash.
33370 +
33371 +#ifdef CONFIG_PAX_KERNEXEC
33372 + mov %cr0, %edx
33373 + xor $X86_CR0_WP, %edx
33374 + mov %edx, %cr0
33375 +#endif
33376 +
33377 movl $(GDT_ENTRY_TSS*8), %edx
33378 ltr %dx
33379
33380 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
33381 // Let's clear it again for our return.
33382 // The GDT descriptor of the Host
33383 // Points to the table after two "size" bytes
33384 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
33385 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
33386 // Clear "used" from type field (byte 5, bit 2)
33387 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
33388 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
33389 +
33390 +#ifdef CONFIG_PAX_KERNEXEC
33391 + mov %cr0, %eax
33392 + xor $X86_CR0_WP, %eax
33393 + mov %eax, %cr0
33394 +#endif
33395
33396 // Once our page table's switched, the Guest is live!
33397 // The Host fades as we run this final step.
33398 @@ -295,13 +309,12 @@ deliver_to_host:
33399 // I consulted gcc, and it gave
33400 // These instructions, which I gladly credit:
33401 leal (%edx,%ebx,8), %eax
33402 - movzwl (%eax),%edx
33403 - movl 4(%eax), %eax
33404 - xorw %ax, %ax
33405 - orl %eax, %edx
33406 + movl 4(%eax), %edx
33407 + movw (%eax), %dx
33408 // Now the address of the handler's in %edx
33409 // We call it now: its "iret" drops us home.
33410 - jmp *%edx
33411 + ljmp $__KERNEL_CS, $1f
33412 +1: jmp *%edx
33413
33414 // Every interrupt can come to us here
33415 // But we must truly tell each apart.
33416 diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
33417 index 4daf9e5..b8d1d0f 100644
33418 --- a/drivers/macintosh/macio_asic.c
33419 +++ b/drivers/macintosh/macio_asic.c
33420 @@ -748,7 +748,7 @@ static void __devexit macio_pci_remove(struct pci_dev* pdev)
33421 * MacIO is matched against any Apple ID, it's probe() function
33422 * will then decide wether it applies or not
33423 */
33424 -static const struct pci_device_id __devinitdata pci_ids [] = { {
33425 +static const struct pci_device_id __devinitconst pci_ids [] = { {
33426 .vendor = PCI_VENDOR_ID_APPLE,
33427 .device = PCI_ANY_ID,
33428 .subvendor = PCI_ANY_ID,
33429 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
33430 index 1ce84ed..0fdd40a 100644
33431 --- a/drivers/md/dm-ioctl.c
33432 +++ b/drivers/md/dm-ioctl.c
33433 @@ -1589,7 +1589,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
33434 cmd == DM_LIST_VERSIONS_CMD)
33435 return 0;
33436
33437 - if ((cmd == DM_DEV_CREATE_CMD)) {
33438 + if (cmd == DM_DEV_CREATE_CMD) {
33439 if (!*param->name) {
33440 DMWARN("name not supplied when creating device");
33441 return -EINVAL;
33442 diff --git a/drivers/md/dm-log-userspace-transfer.c b/drivers/md/dm-log-userspace-transfer.c
33443 index 1f23e04..08d9a20 100644
33444 --- a/drivers/md/dm-log-userspace-transfer.c
33445 +++ b/drivers/md/dm-log-userspace-transfer.c
33446 @@ -134,7 +134,7 @@ static void cn_ulog_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp)
33447 {
33448 struct dm_ulog_request *tfr = (struct dm_ulog_request *)(msg + 1);
33449
33450 - if (!cap_raised(current_cap(), CAP_SYS_ADMIN))
33451 + if (!capable(CAP_SYS_ADMIN))
33452 return;
33453
33454 spin_lock(&receiving_list_lock);
33455 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
33456 index 9bfd057..01180bc 100644
33457 --- a/drivers/md/dm-raid1.c
33458 +++ b/drivers/md/dm-raid1.c
33459 @@ -40,7 +40,7 @@ enum dm_raid1_error {
33460
33461 struct mirror {
33462 struct mirror_set *ms;
33463 - atomic_t error_count;
33464 + atomic_unchecked_t error_count;
33465 unsigned long error_type;
33466 struct dm_dev *dev;
33467 sector_t offset;
33468 @@ -185,7 +185,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
33469 struct mirror *m;
33470
33471 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
33472 - if (!atomic_read(&m->error_count))
33473 + if (!atomic_read_unchecked(&m->error_count))
33474 return m;
33475
33476 return NULL;
33477 @@ -217,7 +217,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
33478 * simple way to tell if a device has encountered
33479 * errors.
33480 */
33481 - atomic_inc(&m->error_count);
33482 + atomic_inc_unchecked(&m->error_count);
33483
33484 if (test_and_set_bit(error_type, &m->error_type))
33485 return;
33486 @@ -408,7 +408,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
33487 struct mirror *m = get_default_mirror(ms);
33488
33489 do {
33490 - if (likely(!atomic_read(&m->error_count)))
33491 + if (likely(!atomic_read_unchecked(&m->error_count)))
33492 return m;
33493
33494 if (m-- == ms->mirror)
33495 @@ -422,7 +422,7 @@ static int default_ok(struct mirror *m)
33496 {
33497 struct mirror *default_mirror = get_default_mirror(m->ms);
33498
33499 - return !atomic_read(&default_mirror->error_count);
33500 + return !atomic_read_unchecked(&default_mirror->error_count);
33501 }
33502
33503 static int mirror_available(struct mirror_set *ms, struct bio *bio)
33504 @@ -559,7 +559,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
33505 */
33506 if (likely(region_in_sync(ms, region, 1)))
33507 m = choose_mirror(ms, bio->bi_sector);
33508 - else if (m && atomic_read(&m->error_count))
33509 + else if (m && atomic_read_unchecked(&m->error_count))
33510 m = NULL;
33511
33512 if (likely(m))
33513 @@ -937,7 +937,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
33514 }
33515
33516 ms->mirror[mirror].ms = ms;
33517 - atomic_set(&(ms->mirror[mirror].error_count), 0);
33518 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
33519 ms->mirror[mirror].error_type = 0;
33520 ms->mirror[mirror].offset = offset;
33521
33522 @@ -1347,7 +1347,7 @@ static void mirror_resume(struct dm_target *ti)
33523 */
33524 static char device_status_char(struct mirror *m)
33525 {
33526 - if (!atomic_read(&(m->error_count)))
33527 + if (!atomic_read_unchecked(&(m->error_count)))
33528 return 'A';
33529
33530 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
33531 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
33532 index 3d80cf0..b77cc47 100644
33533 --- a/drivers/md/dm-stripe.c
33534 +++ b/drivers/md/dm-stripe.c
33535 @@ -20,7 +20,7 @@ struct stripe {
33536 struct dm_dev *dev;
33537 sector_t physical_start;
33538
33539 - atomic_t error_count;
33540 + atomic_unchecked_t error_count;
33541 };
33542
33543 struct stripe_c {
33544 @@ -192,7 +192,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
33545 kfree(sc);
33546 return r;
33547 }
33548 - atomic_set(&(sc->stripe[i].error_count), 0);
33549 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
33550 }
33551
33552 ti->private = sc;
33553 @@ -314,7 +314,7 @@ static int stripe_status(struct dm_target *ti,
33554 DMEMIT("%d ", sc->stripes);
33555 for (i = 0; i < sc->stripes; i++) {
33556 DMEMIT("%s ", sc->stripe[i].dev->name);
33557 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
33558 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
33559 'D' : 'A';
33560 }
33561 buffer[i] = '\0';
33562 @@ -361,8 +361,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio,
33563 */
33564 for (i = 0; i < sc->stripes; i++)
33565 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
33566 - atomic_inc(&(sc->stripe[i].error_count));
33567 - if (atomic_read(&(sc->stripe[i].error_count)) <
33568 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
33569 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
33570 DM_IO_ERROR_THRESHOLD)
33571 schedule_work(&sc->trigger_event);
33572 }
33573 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
33574 index 63cc542..8d45caf3 100644
33575 --- a/drivers/md/dm-table.c
33576 +++ b/drivers/md/dm-table.c
33577 @@ -391,7 +391,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
33578 if (!dev_size)
33579 return 0;
33580
33581 - if ((start >= dev_size) || (start + len > dev_size)) {
33582 + if ((start >= dev_size) || (len > dev_size - start)) {
33583 DMWARN("%s: %s too small for target: "
33584 "start=%llu, len=%llu, dev_size=%llu",
33585 dm_device_name(ti->table->md), bdevname(bdev, b),
33586 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
33587 index 237571a..fb6d19b 100644
33588 --- a/drivers/md/dm-thin-metadata.c
33589 +++ b/drivers/md/dm-thin-metadata.c
33590 @@ -432,7 +432,7 @@ static int init_pmd(struct dm_pool_metadata *pmd,
33591
33592 pmd->info.tm = tm;
33593 pmd->info.levels = 2;
33594 - pmd->info.value_type.context = pmd->data_sm;
33595 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
33596 pmd->info.value_type.size = sizeof(__le64);
33597 pmd->info.value_type.inc = data_block_inc;
33598 pmd->info.value_type.dec = data_block_dec;
33599 @@ -451,7 +451,7 @@ static int init_pmd(struct dm_pool_metadata *pmd,
33600
33601 pmd->bl_info.tm = tm;
33602 pmd->bl_info.levels = 1;
33603 - pmd->bl_info.value_type.context = pmd->data_sm;
33604 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
33605 pmd->bl_info.value_type.size = sizeof(__le64);
33606 pmd->bl_info.value_type.inc = data_block_inc;
33607 pmd->bl_info.value_type.dec = data_block_dec;
33608 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
33609 index b89c548..2af3ce4 100644
33610 --- a/drivers/md/dm.c
33611 +++ b/drivers/md/dm.c
33612 @@ -176,9 +176,9 @@ struct mapped_device {
33613 /*
33614 * Event handling.
33615 */
33616 - atomic_t event_nr;
33617 + atomic_unchecked_t event_nr;
33618 wait_queue_head_t eventq;
33619 - atomic_t uevent_seq;
33620 + atomic_unchecked_t uevent_seq;
33621 struct list_head uevent_list;
33622 spinlock_t uevent_lock; /* Protect access to uevent_list */
33623
33624 @@ -1844,8 +1844,8 @@ static struct mapped_device *alloc_dev(int minor)
33625 rwlock_init(&md->map_lock);
33626 atomic_set(&md->holders, 1);
33627 atomic_set(&md->open_count, 0);
33628 - atomic_set(&md->event_nr, 0);
33629 - atomic_set(&md->uevent_seq, 0);
33630 + atomic_set_unchecked(&md->event_nr, 0);
33631 + atomic_set_unchecked(&md->uevent_seq, 0);
33632 INIT_LIST_HEAD(&md->uevent_list);
33633 spin_lock_init(&md->uevent_lock);
33634
33635 @@ -1979,7 +1979,7 @@ static void event_callback(void *context)
33636
33637 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
33638
33639 - atomic_inc(&md->event_nr);
33640 + atomic_inc_unchecked(&md->event_nr);
33641 wake_up(&md->eventq);
33642 }
33643
33644 @@ -2621,18 +2621,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
33645
33646 uint32_t dm_next_uevent_seq(struct mapped_device *md)
33647 {
33648 - return atomic_add_return(1, &md->uevent_seq);
33649 + return atomic_add_return_unchecked(1, &md->uevent_seq);
33650 }
33651
33652 uint32_t dm_get_event_nr(struct mapped_device *md)
33653 {
33654 - return atomic_read(&md->event_nr);
33655 + return atomic_read_unchecked(&md->event_nr);
33656 }
33657
33658 int dm_wait_event(struct mapped_device *md, int event_nr)
33659 {
33660 return wait_event_interruptible(md->eventq,
33661 - (event_nr != atomic_read(&md->event_nr)));
33662 + (event_nr != atomic_read_unchecked(&md->event_nr)));
33663 }
33664
33665 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
33666 diff --git a/drivers/md/md.c b/drivers/md/md.c
33667 index 363aaf4..d875264 100644
33668 --- a/drivers/md/md.c
33669 +++ b/drivers/md/md.c
33670 @@ -277,10 +277,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
33671 * start build, activate spare
33672 */
33673 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
33674 -static atomic_t md_event_count;
33675 +static atomic_unchecked_t md_event_count;
33676 void md_new_event(struct mddev *mddev)
33677 {
33678 - atomic_inc(&md_event_count);
33679 + atomic_inc_unchecked(&md_event_count);
33680 wake_up(&md_event_waiters);
33681 }
33682 EXPORT_SYMBOL_GPL(md_new_event);
33683 @@ -290,7 +290,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
33684 */
33685 static void md_new_event_inintr(struct mddev *mddev)
33686 {
33687 - atomic_inc(&md_event_count);
33688 + atomic_inc_unchecked(&md_event_count);
33689 wake_up(&md_event_waiters);
33690 }
33691
33692 @@ -1526,7 +1526,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
33693
33694 rdev->preferred_minor = 0xffff;
33695 rdev->data_offset = le64_to_cpu(sb->data_offset);
33696 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
33697 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
33698
33699 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
33700 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
33701 @@ -1745,7 +1745,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
33702 else
33703 sb->resync_offset = cpu_to_le64(0);
33704
33705 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
33706 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
33707
33708 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
33709 sb->size = cpu_to_le64(mddev->dev_sectors);
33710 @@ -2691,7 +2691,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
33711 static ssize_t
33712 errors_show(struct md_rdev *rdev, char *page)
33713 {
33714 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
33715 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
33716 }
33717
33718 static ssize_t
33719 @@ -2700,7 +2700,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
33720 char *e;
33721 unsigned long n = simple_strtoul(buf, &e, 10);
33722 if (*buf && (*e == 0 || *e == '\n')) {
33723 - atomic_set(&rdev->corrected_errors, n);
33724 + atomic_set_unchecked(&rdev->corrected_errors, n);
33725 return len;
33726 }
33727 return -EINVAL;
33728 @@ -3086,8 +3086,8 @@ int md_rdev_init(struct md_rdev *rdev)
33729 rdev->sb_loaded = 0;
33730 rdev->bb_page = NULL;
33731 atomic_set(&rdev->nr_pending, 0);
33732 - atomic_set(&rdev->read_errors, 0);
33733 - atomic_set(&rdev->corrected_errors, 0);
33734 + atomic_set_unchecked(&rdev->read_errors, 0);
33735 + atomic_set_unchecked(&rdev->corrected_errors, 0);
33736
33737 INIT_LIST_HEAD(&rdev->same_set);
33738 init_waitqueue_head(&rdev->blocked_wait);
33739 @@ -6738,7 +6738,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
33740
33741 spin_unlock(&pers_lock);
33742 seq_printf(seq, "\n");
33743 - seq->poll_event = atomic_read(&md_event_count);
33744 + seq->poll_event = atomic_read_unchecked(&md_event_count);
33745 return 0;
33746 }
33747 if (v == (void*)2) {
33748 @@ -6830,7 +6830,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
33749 chunk_kb ? "KB" : "B");
33750 if (bitmap->file) {
33751 seq_printf(seq, ", file: ");
33752 - seq_path(seq, &bitmap->file->f_path, " \t\n");
33753 + seq_path(seq, &bitmap->file->f_path, " \t\n\\");
33754 }
33755
33756 seq_printf(seq, "\n");
33757 @@ -6861,7 +6861,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
33758 return error;
33759
33760 seq = file->private_data;
33761 - seq->poll_event = atomic_read(&md_event_count);
33762 + seq->poll_event = atomic_read_unchecked(&md_event_count);
33763 return error;
33764 }
33765
33766 @@ -6875,7 +6875,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
33767 /* always allow read */
33768 mask = POLLIN | POLLRDNORM;
33769
33770 - if (seq->poll_event != atomic_read(&md_event_count))
33771 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
33772 mask |= POLLERR | POLLPRI;
33773 return mask;
33774 }
33775 @@ -6919,7 +6919,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
33776 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
33777 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
33778 (int)part_stat_read(&disk->part0, sectors[1]) -
33779 - atomic_read(&disk->sync_io);
33780 + atomic_read_unchecked(&disk->sync_io);
33781 /* sync IO will cause sync_io to increase before the disk_stats
33782 * as sync_io is counted when a request starts, and
33783 * disk_stats is counted when it completes.
33784 diff --git a/drivers/md/md.h b/drivers/md/md.h
33785 index 44c63df..b795d1a 100644
33786 --- a/drivers/md/md.h
33787 +++ b/drivers/md/md.h
33788 @@ -93,13 +93,13 @@ struct md_rdev {
33789 * only maintained for arrays that
33790 * support hot removal
33791 */
33792 - atomic_t read_errors; /* number of consecutive read errors that
33793 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
33794 * we have tried to ignore.
33795 */
33796 struct timespec last_read_error; /* monotonic time since our
33797 * last read error
33798 */
33799 - atomic_t corrected_errors; /* number of corrected read errors,
33800 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
33801 * for reporting to userspace and storing
33802 * in superblock.
33803 */
33804 @@ -421,7 +421,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
33805
33806 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
33807 {
33808 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
33809 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
33810 }
33811
33812 struct md_personality
33813 diff --git a/drivers/md/persistent-data/dm-space-map-checker.c b/drivers/md/persistent-data/dm-space-map-checker.c
33814 index 50ed53b..4f29d7d 100644
33815 --- a/drivers/md/persistent-data/dm-space-map-checker.c
33816 +++ b/drivers/md/persistent-data/dm-space-map-checker.c
33817 @@ -159,7 +159,7 @@ static void ca_destroy(struct count_array *ca)
33818 /*----------------------------------------------------------------*/
33819
33820 struct sm_checker {
33821 - struct dm_space_map sm;
33822 + dm_space_map_no_const sm;
33823
33824 struct count_array old_counts;
33825 struct count_array counts;
33826 diff --git a/drivers/md/persistent-data/dm-space-map-disk.c b/drivers/md/persistent-data/dm-space-map-disk.c
33827 index fc469ba..2d91555 100644
33828 --- a/drivers/md/persistent-data/dm-space-map-disk.c
33829 +++ b/drivers/md/persistent-data/dm-space-map-disk.c
33830 @@ -23,7 +23,7 @@
33831 * Space map interface.
33832 */
33833 struct sm_disk {
33834 - struct dm_space_map sm;
33835 + dm_space_map_no_const sm;
33836
33837 struct ll_disk ll;
33838 struct ll_disk old_ll;
33839 diff --git a/drivers/md/persistent-data/dm-space-map-metadata.c b/drivers/md/persistent-data/dm-space-map-metadata.c
33840 index e89ae5e..062e4c2 100644
33841 --- a/drivers/md/persistent-data/dm-space-map-metadata.c
33842 +++ b/drivers/md/persistent-data/dm-space-map-metadata.c
33843 @@ -43,7 +43,7 @@ struct block_op {
33844 };
33845
33846 struct sm_metadata {
33847 - struct dm_space_map sm;
33848 + dm_space_map_no_const sm;
33849
33850 struct ll_disk ll;
33851 struct ll_disk old_ll;
33852 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
33853 index 1cbfc6b..56e1dbb 100644
33854 --- a/drivers/md/persistent-data/dm-space-map.h
33855 +++ b/drivers/md/persistent-data/dm-space-map.h
33856 @@ -60,6 +60,7 @@ struct dm_space_map {
33857 int (*root_size)(struct dm_space_map *sm, size_t *result);
33858 int (*copy_root)(struct dm_space_map *sm, void *copy_to_here_le, size_t len);
33859 };
33860 +typedef struct dm_space_map __no_const dm_space_map_no_const;
33861
33862 /*----------------------------------------------------------------*/
33863
33864 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
33865 index edc735a..e9b97f1 100644
33866 --- a/drivers/md/raid1.c
33867 +++ b/drivers/md/raid1.c
33868 @@ -1645,7 +1645,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
33869 if (r1_sync_page_io(rdev, sect, s,
33870 bio->bi_io_vec[idx].bv_page,
33871 READ) != 0)
33872 - atomic_add(s, &rdev->corrected_errors);
33873 + atomic_add_unchecked(s, &rdev->corrected_errors);
33874 }
33875 sectors -= s;
33876 sect += s;
33877 @@ -1859,7 +1859,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
33878 test_bit(In_sync, &rdev->flags)) {
33879 if (r1_sync_page_io(rdev, sect, s,
33880 conf->tmppage, READ)) {
33881 - atomic_add(s, &rdev->corrected_errors);
33882 + atomic_add_unchecked(s, &rdev->corrected_errors);
33883 printk(KERN_INFO
33884 "md/raid1:%s: read error corrected "
33885 "(%d sectors at %llu on %s)\n",
33886 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
33887 index 1898389..a3aa617 100644
33888 --- a/drivers/md/raid10.c
33889 +++ b/drivers/md/raid10.c
33890 @@ -1636,7 +1636,7 @@ static void end_sync_read(struct bio *bio, int error)
33891 /* The write handler will notice the lack of
33892 * R10BIO_Uptodate and record any errors etc
33893 */
33894 - atomic_add(r10_bio->sectors,
33895 + atomic_add_unchecked(r10_bio->sectors,
33896 &conf->mirrors[d].rdev->corrected_errors);
33897
33898 /* for reconstruct, we always reschedule after a read.
33899 @@ -1987,7 +1987,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
33900 {
33901 struct timespec cur_time_mon;
33902 unsigned long hours_since_last;
33903 - unsigned int read_errors = atomic_read(&rdev->read_errors);
33904 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
33905
33906 ktime_get_ts(&cur_time_mon);
33907
33908 @@ -2009,9 +2009,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
33909 * overflowing the shift of read_errors by hours_since_last.
33910 */
33911 if (hours_since_last >= 8 * sizeof(read_errors))
33912 - atomic_set(&rdev->read_errors, 0);
33913 + atomic_set_unchecked(&rdev->read_errors, 0);
33914 else
33915 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
33916 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
33917 }
33918
33919 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
33920 @@ -2065,8 +2065,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
33921 return;
33922
33923 check_decay_read_errors(mddev, rdev);
33924 - atomic_inc(&rdev->read_errors);
33925 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
33926 + atomic_inc_unchecked(&rdev->read_errors);
33927 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
33928 char b[BDEVNAME_SIZE];
33929 bdevname(rdev->bdev, b);
33930
33931 @@ -2074,7 +2074,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
33932 "md/raid10:%s: %s: Raid device exceeded "
33933 "read_error threshold [cur %d:max %d]\n",
33934 mdname(mddev), b,
33935 - atomic_read(&rdev->read_errors), max_read_errors);
33936 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
33937 printk(KERN_NOTICE
33938 "md/raid10:%s: %s: Failing raid device\n",
33939 mdname(mddev), b);
33940 @@ -2223,7 +2223,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
33941 (unsigned long long)(
33942 sect + rdev->data_offset),
33943 bdevname(rdev->bdev, b));
33944 - atomic_add(s, &rdev->corrected_errors);
33945 + atomic_add_unchecked(s, &rdev->corrected_errors);
33946 }
33947
33948 rdev_dec_pending(rdev, mddev);
33949 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
33950 index d1162e5..c7cd902 100644
33951 --- a/drivers/md/raid5.c
33952 +++ b/drivers/md/raid5.c
33953 @@ -1687,18 +1687,18 @@ static void raid5_end_read_request(struct bio * bi, int error)
33954 (unsigned long long)(sh->sector
33955 + rdev->data_offset),
33956 bdevname(rdev->bdev, b));
33957 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
33958 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
33959 clear_bit(R5_ReadError, &sh->dev[i].flags);
33960 clear_bit(R5_ReWrite, &sh->dev[i].flags);
33961 }
33962 - if (atomic_read(&rdev->read_errors))
33963 - atomic_set(&rdev->read_errors, 0);
33964 + if (atomic_read_unchecked(&rdev->read_errors))
33965 + atomic_set_unchecked(&rdev->read_errors, 0);
33966 } else {
33967 const char *bdn = bdevname(rdev->bdev, b);
33968 int retry = 0;
33969
33970 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
33971 - atomic_inc(&rdev->read_errors);
33972 + atomic_inc_unchecked(&rdev->read_errors);
33973 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
33974 printk_ratelimited(
33975 KERN_WARNING
33976 @@ -1727,7 +1727,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
33977 (unsigned long long)(sh->sector
33978 + rdev->data_offset),
33979 bdn);
33980 - else if (atomic_read(&rdev->read_errors)
33981 + else if (atomic_read_unchecked(&rdev->read_errors)
33982 > conf->max_nr_stripes)
33983 printk(KERN_WARNING
33984 "md/raid:%s: Too many read errors, failing device %s.\n",
33985 diff --git a/drivers/media/dvb/ddbridge/ddbridge-core.c b/drivers/media/dvb/ddbridge/ddbridge-core.c
33986 index ce4f858..7bcfb46 100644
33987 --- a/drivers/media/dvb/ddbridge/ddbridge-core.c
33988 +++ b/drivers/media/dvb/ddbridge/ddbridge-core.c
33989 @@ -1678,7 +1678,7 @@ static struct ddb_info ddb_v6 = {
33990 .subvendor = _subvend, .subdevice = _subdev, \
33991 .driver_data = (unsigned long)&_driverdata }
33992
33993 -static const struct pci_device_id ddb_id_tbl[] __devinitdata = {
33994 +static const struct pci_device_id ddb_id_tbl[] __devinitconst = {
33995 DDB_ID(DDVID, 0x0002, DDVID, 0x0001, ddb_octopus),
33996 DDB_ID(DDVID, 0x0003, DDVID, 0x0001, ddb_octopus),
33997 DDB_ID(DDVID, 0x0003, DDVID, 0x0002, ddb_octopus_le),
33998 diff --git a/drivers/media/dvb/dvb-core/dvb_demux.h b/drivers/media/dvb/dvb-core/dvb_demux.h
33999 index a7d876f..8c21b61 100644
34000 --- a/drivers/media/dvb/dvb-core/dvb_demux.h
34001 +++ b/drivers/media/dvb/dvb-core/dvb_demux.h
34002 @@ -73,7 +73,7 @@ struct dvb_demux_feed {
34003 union {
34004 dmx_ts_cb ts;
34005 dmx_section_cb sec;
34006 - } cb;
34007 + } __no_const cb;
34008
34009 struct dvb_demux *demux;
34010 void *priv;
34011 diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
34012 index 00a6732..70a682e 100644
34013 --- a/drivers/media/dvb/dvb-core/dvbdev.c
34014 +++ b/drivers/media/dvb/dvb-core/dvbdev.c
34015 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
34016 const struct dvb_device *template, void *priv, int type)
34017 {
34018 struct dvb_device *dvbdev;
34019 - struct file_operations *dvbdevfops;
34020 + file_operations_no_const *dvbdevfops;
34021 struct device *clsdev;
34022 int minor;
34023 int id;
34024 diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c
34025 index 3940bb0..fb3952a 100644
34026 --- a/drivers/media/dvb/dvb-usb/cxusb.c
34027 +++ b/drivers/media/dvb/dvb-usb/cxusb.c
34028 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
34029
34030 struct dib0700_adapter_state {
34031 int (*set_param_save) (struct dvb_frontend *);
34032 -};
34033 +} __no_const;
34034
34035 static int dib7070_set_param_override(struct dvb_frontend *fe)
34036 {
34037 diff --git a/drivers/media/dvb/dvb-usb/dw2102.c b/drivers/media/dvb/dvb-usb/dw2102.c
34038 index 451c5a7..649f711 100644
34039 --- a/drivers/media/dvb/dvb-usb/dw2102.c
34040 +++ b/drivers/media/dvb/dvb-usb/dw2102.c
34041 @@ -95,7 +95,7 @@ struct su3000_state {
34042
34043 struct s6x0_state {
34044 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
34045 -};
34046 +} __no_const;
34047
34048 /* debug */
34049 static int dvb_usb_dw2102_debug;
34050 diff --git a/drivers/media/dvb/frontends/dib3000.h b/drivers/media/dvb/frontends/dib3000.h
34051 index 404f63a..4796533 100644
34052 --- a/drivers/media/dvb/frontends/dib3000.h
34053 +++ b/drivers/media/dvb/frontends/dib3000.h
34054 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
34055 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
34056 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
34057 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
34058 -};
34059 +} __no_const;
34060
34061 #if defined(CONFIG_DVB_DIB3000MB) || (defined(CONFIG_DVB_DIB3000MB_MODULE) && defined(MODULE))
34062 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
34063 diff --git a/drivers/media/dvb/ngene/ngene-cards.c b/drivers/media/dvb/ngene/ngene-cards.c
34064 index 8418c02..8555013 100644
34065 --- a/drivers/media/dvb/ngene/ngene-cards.c
34066 +++ b/drivers/media/dvb/ngene/ngene-cards.c
34067 @@ -477,7 +477,7 @@ static struct ngene_info ngene_info_m780 = {
34068
34069 /****************************************************************************/
34070
34071 -static const struct pci_device_id ngene_id_tbl[] __devinitdata = {
34072 +static const struct pci_device_id ngene_id_tbl[] __devinitconst = {
34073 NGENE_ID(0x18c3, 0xabc3, ngene_info_cineS2),
34074 NGENE_ID(0x18c3, 0xabc4, ngene_info_cineS2),
34075 NGENE_ID(0x18c3, 0xdb01, ngene_info_satixS2),
34076 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
34077 index 16a089f..ab1667d 100644
34078 --- a/drivers/media/radio/radio-cadet.c
34079 +++ b/drivers/media/radio/radio-cadet.c
34080 @@ -326,6 +326,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
34081 unsigned char readbuf[RDS_BUFFER];
34082 int i = 0;
34083
34084 + if (count > RDS_BUFFER)
34085 + return -EFAULT;
34086 mutex_lock(&dev->lock);
34087 if (dev->rdsstat == 0) {
34088 dev->rdsstat = 1;
34089 diff --git a/drivers/media/video/au0828/au0828.h b/drivers/media/video/au0828/au0828.h
34090 index 9cde353..8c6a1c3 100644
34091 --- a/drivers/media/video/au0828/au0828.h
34092 +++ b/drivers/media/video/au0828/au0828.h
34093 @@ -191,7 +191,7 @@ struct au0828_dev {
34094
34095 /* I2C */
34096 struct i2c_adapter i2c_adap;
34097 - struct i2c_algorithm i2c_algo;
34098 + i2c_algorithm_no_const i2c_algo;
34099 struct i2c_client i2c_client;
34100 u32 i2c_rc;
34101
34102 diff --git a/drivers/media/video/cx88/cx88-alsa.c b/drivers/media/video/cx88/cx88-alsa.c
34103 index 04bf662..e0ac026 100644
34104 --- a/drivers/media/video/cx88/cx88-alsa.c
34105 +++ b/drivers/media/video/cx88/cx88-alsa.c
34106 @@ -766,7 +766,7 @@ static struct snd_kcontrol_new snd_cx88_alc_switch = {
34107 * Only boards with eeprom and byte 1 at eeprom=1 have it
34108 */
34109
34110 -static const struct pci_device_id const cx88_audio_pci_tbl[] __devinitdata = {
34111 +static const struct pci_device_id const cx88_audio_pci_tbl[] __devinitconst = {
34112 {0x14f1,0x8801,PCI_ANY_ID,PCI_ANY_ID,0,0,0},
34113 {0x14f1,0x8811,PCI_ANY_ID,PCI_ANY_ID,0,0,0},
34114 {0, }
34115 diff --git a/drivers/media/video/omap/omap_vout.c b/drivers/media/video/omap/omap_vout.c
34116 index 1fb7d5b..3901e77 100644
34117 --- a/drivers/media/video/omap/omap_vout.c
34118 +++ b/drivers/media/video/omap/omap_vout.c
34119 @@ -64,7 +64,6 @@ enum omap_vout_channels {
34120 OMAP_VIDEO2,
34121 };
34122
34123 -static struct videobuf_queue_ops video_vbq_ops;
34124 /* Variables configurable through module params*/
34125 static u32 video1_numbuffers = 3;
34126 static u32 video2_numbuffers = 3;
34127 @@ -1000,6 +999,12 @@ static int omap_vout_open(struct file *file)
34128 {
34129 struct videobuf_queue *q;
34130 struct omap_vout_device *vout = NULL;
34131 + static struct videobuf_queue_ops video_vbq_ops = {
34132 + .buf_setup = omap_vout_buffer_setup,
34133 + .buf_prepare = omap_vout_buffer_prepare,
34134 + .buf_release = omap_vout_buffer_release,
34135 + .buf_queue = omap_vout_buffer_queue,
34136 + };
34137
34138 vout = video_drvdata(file);
34139 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
34140 @@ -1017,10 +1022,6 @@ static int omap_vout_open(struct file *file)
34141 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
34142
34143 q = &vout->vbq;
34144 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
34145 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
34146 - video_vbq_ops.buf_release = omap_vout_buffer_release;
34147 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
34148 spin_lock_init(&vout->vbq_lock);
34149
34150 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
34151 diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
34152 index 305e6aa..0143317 100644
34153 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
34154 +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
34155 @@ -196,7 +196,7 @@ struct pvr2_hdw {
34156
34157 /* I2C stuff */
34158 struct i2c_adapter i2c_adap;
34159 - struct i2c_algorithm i2c_algo;
34160 + i2c_algorithm_no_const i2c_algo;
34161 pvr2_i2c_func i2c_func[PVR2_I2C_FUNC_CNT];
34162 int i2c_cx25840_hack_state;
34163 int i2c_linked;
34164 diff --git a/drivers/media/video/timblogiw.c b/drivers/media/video/timblogiw.c
34165 index 4ed1c7c2..8f15e13 100644
34166 --- a/drivers/media/video/timblogiw.c
34167 +++ b/drivers/media/video/timblogiw.c
34168 @@ -745,7 +745,7 @@ static int timblogiw_mmap(struct file *file, struct vm_area_struct *vma)
34169
34170 /* Platform device functions */
34171
34172 -static __devinitconst struct v4l2_ioctl_ops timblogiw_ioctl_ops = {
34173 +static __devinitconst v4l2_ioctl_ops_no_const timblogiw_ioctl_ops = {
34174 .vidioc_querycap = timblogiw_querycap,
34175 .vidioc_enum_fmt_vid_cap = timblogiw_enum_fmt,
34176 .vidioc_g_fmt_vid_cap = timblogiw_g_fmt,
34177 @@ -767,7 +767,7 @@ static __devinitconst struct v4l2_ioctl_ops timblogiw_ioctl_ops = {
34178 .vidioc_enum_framesizes = timblogiw_enum_framesizes,
34179 };
34180
34181 -static __devinitconst struct v4l2_file_operations timblogiw_fops = {
34182 +static __devinitconst v4l2_file_operations_no_const timblogiw_fops = {
34183 .owner = THIS_MODULE,
34184 .open = timblogiw_open,
34185 .release = timblogiw_close,
34186 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
34187 index a7dc467..a55c423 100644
34188 --- a/drivers/message/fusion/mptbase.c
34189 +++ b/drivers/message/fusion/mptbase.c
34190 @@ -6754,8 +6754,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
34191 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
34192 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
34193
34194 +#ifdef CONFIG_GRKERNSEC_HIDESYM
34195 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
34196 +#else
34197 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
34198 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
34199 +#endif
34200 +
34201 /*
34202 * Rounding UP to nearest 4-kB boundary here...
34203 */
34204 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
34205 index 551262e..7551198 100644
34206 --- a/drivers/message/fusion/mptsas.c
34207 +++ b/drivers/message/fusion/mptsas.c
34208 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
34209 return 0;
34210 }
34211
34212 +static inline void
34213 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
34214 +{
34215 + if (phy_info->port_details) {
34216 + phy_info->port_details->rphy = rphy;
34217 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
34218 + ioc->name, rphy));
34219 + }
34220 +
34221 + if (rphy) {
34222 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
34223 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
34224 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
34225 + ioc->name, rphy, rphy->dev.release));
34226 + }
34227 +}
34228 +
34229 /* no mutex */
34230 static void
34231 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
34232 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
34233 return NULL;
34234 }
34235
34236 -static inline void
34237 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
34238 -{
34239 - if (phy_info->port_details) {
34240 - phy_info->port_details->rphy = rphy;
34241 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
34242 - ioc->name, rphy));
34243 - }
34244 -
34245 - if (rphy) {
34246 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
34247 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
34248 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
34249 - ioc->name, rphy, rphy->dev.release));
34250 - }
34251 -}
34252 -
34253 static inline struct sas_port *
34254 mptsas_get_port(struct mptsas_phyinfo *phy_info)
34255 {
34256 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
34257 index 0c3ced7..1fe34ec 100644
34258 --- a/drivers/message/fusion/mptscsih.c
34259 +++ b/drivers/message/fusion/mptscsih.c
34260 @@ -1270,15 +1270,16 @@ mptscsih_info(struct Scsi_Host *SChost)
34261
34262 h = shost_priv(SChost);
34263
34264 - if (h) {
34265 - if (h->info_kbuf == NULL)
34266 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
34267 - return h->info_kbuf;
34268 - h->info_kbuf[0] = '\0';
34269 + if (!h)
34270 + return NULL;
34271
34272 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
34273 - h->info_kbuf[size-1] = '\0';
34274 - }
34275 + if (h->info_kbuf == NULL)
34276 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
34277 + return h->info_kbuf;
34278 + h->info_kbuf[0] = '\0';
34279 +
34280 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
34281 + h->info_kbuf[size-1] = '\0';
34282
34283 return h->info_kbuf;
34284 }
34285 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
34286 index 6d115c7..58ff7fd 100644
34287 --- a/drivers/message/i2o/i2o_proc.c
34288 +++ b/drivers/message/i2o/i2o_proc.c
34289 @@ -255,13 +255,6 @@ static char *scsi_devices[] = {
34290 "Array Controller Device"
34291 };
34292
34293 -static char *chtostr(u8 * chars, int n)
34294 -{
34295 - char tmp[256];
34296 - tmp[0] = 0;
34297 - return strncat(tmp, (char *)chars, n);
34298 -}
34299 -
34300 static int i2o_report_query_status(struct seq_file *seq, int block_status,
34301 char *group)
34302 {
34303 @@ -838,8 +831,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
34304
34305 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
34306 seq_printf(seq, "%-#8x", ddm_table.module_id);
34307 - seq_printf(seq, "%-29s",
34308 - chtostr(ddm_table.module_name_version, 28));
34309 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
34310 seq_printf(seq, "%9d ", ddm_table.data_size);
34311 seq_printf(seq, "%8d", ddm_table.code_size);
34312
34313 @@ -940,8 +932,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
34314
34315 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
34316 seq_printf(seq, "%-#8x", dst->module_id);
34317 - seq_printf(seq, "%-29s", chtostr(dst->module_name_version, 28));
34318 - seq_printf(seq, "%-9s", chtostr(dst->date, 8));
34319 + seq_printf(seq, "%-.28s", dst->module_name_version);
34320 + seq_printf(seq, "%-.8s", dst->date);
34321 seq_printf(seq, "%8d ", dst->module_size);
34322 seq_printf(seq, "%8d ", dst->mpb_size);
34323 seq_printf(seq, "0x%04x", dst->module_flags);
34324 @@ -1272,14 +1264,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
34325 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
34326 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
34327 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
34328 - seq_printf(seq, "Vendor info : %s\n",
34329 - chtostr((u8 *) (work32 + 2), 16));
34330 - seq_printf(seq, "Product info : %s\n",
34331 - chtostr((u8 *) (work32 + 6), 16));
34332 - seq_printf(seq, "Description : %s\n",
34333 - chtostr((u8 *) (work32 + 10), 16));
34334 - seq_printf(seq, "Product rev. : %s\n",
34335 - chtostr((u8 *) (work32 + 14), 8));
34336 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
34337 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
34338 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
34339 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
34340
34341 seq_printf(seq, "Serial number : ");
34342 print_serial_number(seq, (u8 *) (work32 + 16),
34343 @@ -1324,10 +1312,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
34344 }
34345
34346 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
34347 - seq_printf(seq, "Module name : %s\n",
34348 - chtostr(result.module_name, 24));
34349 - seq_printf(seq, "Module revision : %s\n",
34350 - chtostr(result.module_rev, 8));
34351 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
34352 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
34353
34354 seq_printf(seq, "Serial number : ");
34355 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
34356 @@ -1358,14 +1344,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
34357 return 0;
34358 }
34359
34360 - seq_printf(seq, "Device name : %s\n",
34361 - chtostr(result.device_name, 64));
34362 - seq_printf(seq, "Service name : %s\n",
34363 - chtostr(result.service_name, 64));
34364 - seq_printf(seq, "Physical name : %s\n",
34365 - chtostr(result.physical_location, 64));
34366 - seq_printf(seq, "Instance number : %s\n",
34367 - chtostr(result.instance_number, 4));
34368 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
34369 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
34370 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
34371 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
34372
34373 return 0;
34374 }
34375 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
34376 index a8c08f3..155fe3d 100644
34377 --- a/drivers/message/i2o/iop.c
34378 +++ b/drivers/message/i2o/iop.c
34379 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
34380
34381 spin_lock_irqsave(&c->context_list_lock, flags);
34382
34383 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
34384 - atomic_inc(&c->context_list_counter);
34385 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
34386 + atomic_inc_unchecked(&c->context_list_counter);
34387
34388 - entry->context = atomic_read(&c->context_list_counter);
34389 + entry->context = atomic_read_unchecked(&c->context_list_counter);
34390
34391 list_add(&entry->list, &c->context_list);
34392
34393 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
34394
34395 #if BITS_PER_LONG == 64
34396 spin_lock_init(&c->context_list_lock);
34397 - atomic_set(&c->context_list_counter, 0);
34398 + atomic_set_unchecked(&c->context_list_counter, 0);
34399 INIT_LIST_HEAD(&c->context_list);
34400 #endif
34401
34402 diff --git a/drivers/mfd/abx500-core.c b/drivers/mfd/abx500-core.c
34403 index 7ce65f4..e66e9bc 100644
34404 --- a/drivers/mfd/abx500-core.c
34405 +++ b/drivers/mfd/abx500-core.c
34406 @@ -15,7 +15,7 @@ static LIST_HEAD(abx500_list);
34407
34408 struct abx500_device_entry {
34409 struct list_head list;
34410 - struct abx500_ops ops;
34411 + abx500_ops_no_const ops;
34412 struct device *dev;
34413 };
34414
34415 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
34416 index a9223ed..4127b13 100644
34417 --- a/drivers/mfd/janz-cmodio.c
34418 +++ b/drivers/mfd/janz-cmodio.c
34419 @@ -13,6 +13,7 @@
34420
34421 #include <linux/kernel.h>
34422 #include <linux/module.h>
34423 +#include <linux/slab.h>
34424 #include <linux/init.h>
34425 #include <linux/pci.h>
34426 #include <linux/interrupt.h>
34427 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
34428 index a981e2a..5ca0c8b 100644
34429 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
34430 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
34431 @@ -466,7 +466,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
34432 * the lid is closed. This leads to interrupts as soon as a little move
34433 * is done.
34434 */
34435 - atomic_inc(&lis3->count);
34436 + atomic_inc_unchecked(&lis3->count);
34437
34438 wake_up_interruptible(&lis3->misc_wait);
34439 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
34440 @@ -552,7 +552,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
34441 if (lis3->pm_dev)
34442 pm_runtime_get_sync(lis3->pm_dev);
34443
34444 - atomic_set(&lis3->count, 0);
34445 + atomic_set_unchecked(&lis3->count, 0);
34446 return 0;
34447 }
34448
34449 @@ -585,7 +585,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
34450 add_wait_queue(&lis3->misc_wait, &wait);
34451 while (true) {
34452 set_current_state(TASK_INTERRUPTIBLE);
34453 - data = atomic_xchg(&lis3->count, 0);
34454 + data = atomic_xchg_unchecked(&lis3->count, 0);
34455 if (data)
34456 break;
34457
34458 @@ -626,7 +626,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
34459 struct lis3lv02d, miscdev);
34460
34461 poll_wait(file, &lis3->misc_wait, wait);
34462 - if (atomic_read(&lis3->count))
34463 + if (atomic_read_unchecked(&lis3->count))
34464 return POLLIN | POLLRDNORM;
34465 return 0;
34466 }
34467 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
34468 index 2b1482a..5d33616 100644
34469 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
34470 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
34471 @@ -266,7 +266,7 @@ struct lis3lv02d {
34472 struct input_polled_dev *idev; /* input device */
34473 struct platform_device *pdev; /* platform device */
34474 struct regulator_bulk_data regulators[2];
34475 - atomic_t count; /* interrupt count after last read */
34476 + atomic_unchecked_t count; /* interrupt count after last read */
34477 union axis_conversion ac; /* hw -> logical axis */
34478 int mapped_btns[3];
34479
34480 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
34481 index 2f30bad..c4c13d0 100644
34482 --- a/drivers/misc/sgi-gru/gruhandles.c
34483 +++ b/drivers/misc/sgi-gru/gruhandles.c
34484 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
34485 unsigned long nsec;
34486
34487 nsec = CLKS2NSEC(clks);
34488 - atomic_long_inc(&mcs_op_statistics[op].count);
34489 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
34490 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
34491 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
34492 if (mcs_op_statistics[op].max < nsec)
34493 mcs_op_statistics[op].max = nsec;
34494 }
34495 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
34496 index 950dbe9..eeef0f8 100644
34497 --- a/drivers/misc/sgi-gru/gruprocfs.c
34498 +++ b/drivers/misc/sgi-gru/gruprocfs.c
34499 @@ -32,9 +32,9 @@
34500
34501 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
34502
34503 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
34504 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
34505 {
34506 - unsigned long val = atomic_long_read(v);
34507 + unsigned long val = atomic_long_read_unchecked(v);
34508
34509 seq_printf(s, "%16lu %s\n", val, id);
34510 }
34511 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
34512
34513 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
34514 for (op = 0; op < mcsop_last; op++) {
34515 - count = atomic_long_read(&mcs_op_statistics[op].count);
34516 - total = atomic_long_read(&mcs_op_statistics[op].total);
34517 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
34518 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
34519 max = mcs_op_statistics[op].max;
34520 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
34521 count ? total / count : 0, max);
34522 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
34523 index 5c3ce24..4915ccb 100644
34524 --- a/drivers/misc/sgi-gru/grutables.h
34525 +++ b/drivers/misc/sgi-gru/grutables.h
34526 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
34527 * GRU statistics.
34528 */
34529 struct gru_stats_s {
34530 - atomic_long_t vdata_alloc;
34531 - atomic_long_t vdata_free;
34532 - atomic_long_t gts_alloc;
34533 - atomic_long_t gts_free;
34534 - atomic_long_t gms_alloc;
34535 - atomic_long_t gms_free;
34536 - atomic_long_t gts_double_allocate;
34537 - atomic_long_t assign_context;
34538 - atomic_long_t assign_context_failed;
34539 - atomic_long_t free_context;
34540 - atomic_long_t load_user_context;
34541 - atomic_long_t load_kernel_context;
34542 - atomic_long_t lock_kernel_context;
34543 - atomic_long_t unlock_kernel_context;
34544 - atomic_long_t steal_user_context;
34545 - atomic_long_t steal_kernel_context;
34546 - atomic_long_t steal_context_failed;
34547 - atomic_long_t nopfn;
34548 - atomic_long_t asid_new;
34549 - atomic_long_t asid_next;
34550 - atomic_long_t asid_wrap;
34551 - atomic_long_t asid_reuse;
34552 - atomic_long_t intr;
34553 - atomic_long_t intr_cbr;
34554 - atomic_long_t intr_tfh;
34555 - atomic_long_t intr_spurious;
34556 - atomic_long_t intr_mm_lock_failed;
34557 - atomic_long_t call_os;
34558 - atomic_long_t call_os_wait_queue;
34559 - atomic_long_t user_flush_tlb;
34560 - atomic_long_t user_unload_context;
34561 - atomic_long_t user_exception;
34562 - atomic_long_t set_context_option;
34563 - atomic_long_t check_context_retarget_intr;
34564 - atomic_long_t check_context_unload;
34565 - atomic_long_t tlb_dropin;
34566 - atomic_long_t tlb_preload_page;
34567 - atomic_long_t tlb_dropin_fail_no_asid;
34568 - atomic_long_t tlb_dropin_fail_upm;
34569 - atomic_long_t tlb_dropin_fail_invalid;
34570 - atomic_long_t tlb_dropin_fail_range_active;
34571 - atomic_long_t tlb_dropin_fail_idle;
34572 - atomic_long_t tlb_dropin_fail_fmm;
34573 - atomic_long_t tlb_dropin_fail_no_exception;
34574 - atomic_long_t tfh_stale_on_fault;
34575 - atomic_long_t mmu_invalidate_range;
34576 - atomic_long_t mmu_invalidate_page;
34577 - atomic_long_t flush_tlb;
34578 - atomic_long_t flush_tlb_gru;
34579 - atomic_long_t flush_tlb_gru_tgh;
34580 - atomic_long_t flush_tlb_gru_zero_asid;
34581 + atomic_long_unchecked_t vdata_alloc;
34582 + atomic_long_unchecked_t vdata_free;
34583 + atomic_long_unchecked_t gts_alloc;
34584 + atomic_long_unchecked_t gts_free;
34585 + atomic_long_unchecked_t gms_alloc;
34586 + atomic_long_unchecked_t gms_free;
34587 + atomic_long_unchecked_t gts_double_allocate;
34588 + atomic_long_unchecked_t assign_context;
34589 + atomic_long_unchecked_t assign_context_failed;
34590 + atomic_long_unchecked_t free_context;
34591 + atomic_long_unchecked_t load_user_context;
34592 + atomic_long_unchecked_t load_kernel_context;
34593 + atomic_long_unchecked_t lock_kernel_context;
34594 + atomic_long_unchecked_t unlock_kernel_context;
34595 + atomic_long_unchecked_t steal_user_context;
34596 + atomic_long_unchecked_t steal_kernel_context;
34597 + atomic_long_unchecked_t steal_context_failed;
34598 + atomic_long_unchecked_t nopfn;
34599 + atomic_long_unchecked_t asid_new;
34600 + atomic_long_unchecked_t asid_next;
34601 + atomic_long_unchecked_t asid_wrap;
34602 + atomic_long_unchecked_t asid_reuse;
34603 + atomic_long_unchecked_t intr;
34604 + atomic_long_unchecked_t intr_cbr;
34605 + atomic_long_unchecked_t intr_tfh;
34606 + atomic_long_unchecked_t intr_spurious;
34607 + atomic_long_unchecked_t intr_mm_lock_failed;
34608 + atomic_long_unchecked_t call_os;
34609 + atomic_long_unchecked_t call_os_wait_queue;
34610 + atomic_long_unchecked_t user_flush_tlb;
34611 + atomic_long_unchecked_t user_unload_context;
34612 + atomic_long_unchecked_t user_exception;
34613 + atomic_long_unchecked_t set_context_option;
34614 + atomic_long_unchecked_t check_context_retarget_intr;
34615 + atomic_long_unchecked_t check_context_unload;
34616 + atomic_long_unchecked_t tlb_dropin;
34617 + atomic_long_unchecked_t tlb_preload_page;
34618 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
34619 + atomic_long_unchecked_t tlb_dropin_fail_upm;
34620 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
34621 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
34622 + atomic_long_unchecked_t tlb_dropin_fail_idle;
34623 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
34624 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
34625 + atomic_long_unchecked_t tfh_stale_on_fault;
34626 + atomic_long_unchecked_t mmu_invalidate_range;
34627 + atomic_long_unchecked_t mmu_invalidate_page;
34628 + atomic_long_unchecked_t flush_tlb;
34629 + atomic_long_unchecked_t flush_tlb_gru;
34630 + atomic_long_unchecked_t flush_tlb_gru_tgh;
34631 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
34632
34633 - atomic_long_t copy_gpa;
34634 - atomic_long_t read_gpa;
34635 + atomic_long_unchecked_t copy_gpa;
34636 + atomic_long_unchecked_t read_gpa;
34637
34638 - atomic_long_t mesq_receive;
34639 - atomic_long_t mesq_receive_none;
34640 - atomic_long_t mesq_send;
34641 - atomic_long_t mesq_send_failed;
34642 - atomic_long_t mesq_noop;
34643 - atomic_long_t mesq_send_unexpected_error;
34644 - atomic_long_t mesq_send_lb_overflow;
34645 - atomic_long_t mesq_send_qlimit_reached;
34646 - atomic_long_t mesq_send_amo_nacked;
34647 - atomic_long_t mesq_send_put_nacked;
34648 - atomic_long_t mesq_page_overflow;
34649 - atomic_long_t mesq_qf_locked;
34650 - atomic_long_t mesq_qf_noop_not_full;
34651 - atomic_long_t mesq_qf_switch_head_failed;
34652 - atomic_long_t mesq_qf_unexpected_error;
34653 - atomic_long_t mesq_noop_unexpected_error;
34654 - atomic_long_t mesq_noop_lb_overflow;
34655 - atomic_long_t mesq_noop_qlimit_reached;
34656 - atomic_long_t mesq_noop_amo_nacked;
34657 - atomic_long_t mesq_noop_put_nacked;
34658 - atomic_long_t mesq_noop_page_overflow;
34659 + atomic_long_unchecked_t mesq_receive;
34660 + atomic_long_unchecked_t mesq_receive_none;
34661 + atomic_long_unchecked_t mesq_send;
34662 + atomic_long_unchecked_t mesq_send_failed;
34663 + atomic_long_unchecked_t mesq_noop;
34664 + atomic_long_unchecked_t mesq_send_unexpected_error;
34665 + atomic_long_unchecked_t mesq_send_lb_overflow;
34666 + atomic_long_unchecked_t mesq_send_qlimit_reached;
34667 + atomic_long_unchecked_t mesq_send_amo_nacked;
34668 + atomic_long_unchecked_t mesq_send_put_nacked;
34669 + atomic_long_unchecked_t mesq_page_overflow;
34670 + atomic_long_unchecked_t mesq_qf_locked;
34671 + atomic_long_unchecked_t mesq_qf_noop_not_full;
34672 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
34673 + atomic_long_unchecked_t mesq_qf_unexpected_error;
34674 + atomic_long_unchecked_t mesq_noop_unexpected_error;
34675 + atomic_long_unchecked_t mesq_noop_lb_overflow;
34676 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
34677 + atomic_long_unchecked_t mesq_noop_amo_nacked;
34678 + atomic_long_unchecked_t mesq_noop_put_nacked;
34679 + atomic_long_unchecked_t mesq_noop_page_overflow;
34680
34681 };
34682
34683 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
34684 tghop_invalidate, mcsop_last};
34685
34686 struct mcs_op_statistic {
34687 - atomic_long_t count;
34688 - atomic_long_t total;
34689 + atomic_long_unchecked_t count;
34690 + atomic_long_unchecked_t total;
34691 unsigned long max;
34692 };
34693
34694 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
34695
34696 #define STAT(id) do { \
34697 if (gru_options & OPT_STATS) \
34698 - atomic_long_inc(&gru_stats.id); \
34699 + atomic_long_inc_unchecked(&gru_stats.id); \
34700 } while (0)
34701
34702 #ifdef CONFIG_SGI_GRU_DEBUG
34703 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
34704 index 851b2f2..a4ec097 100644
34705 --- a/drivers/misc/sgi-xp/xp.h
34706 +++ b/drivers/misc/sgi-xp/xp.h
34707 @@ -289,7 +289,7 @@ struct xpc_interface {
34708 xpc_notify_func, void *);
34709 void (*received) (short, int, void *);
34710 enum xp_retval (*partid_to_nasids) (short, void *);
34711 -};
34712 +} __no_const;
34713
34714 extern struct xpc_interface xpc_interface;
34715
34716 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
34717 index b94d5f7..7f494c5 100644
34718 --- a/drivers/misc/sgi-xp/xpc.h
34719 +++ b/drivers/misc/sgi-xp/xpc.h
34720 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
34721 void (*received_payload) (struct xpc_channel *, void *);
34722 void (*notify_senders_of_disconnect) (struct xpc_channel *);
34723 };
34724 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
34725
34726 /* struct xpc_partition act_state values (for XPC HB) */
34727
34728 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
34729 /* found in xpc_main.c */
34730 extern struct device *xpc_part;
34731 extern struct device *xpc_chan;
34732 -extern struct xpc_arch_operations xpc_arch_ops;
34733 +extern xpc_arch_operations_no_const xpc_arch_ops;
34734 extern int xpc_disengage_timelimit;
34735 extern int xpc_disengage_timedout;
34736 extern int xpc_activate_IRQ_rcvd;
34737 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
34738 index 8d082b4..aa749ae 100644
34739 --- a/drivers/misc/sgi-xp/xpc_main.c
34740 +++ b/drivers/misc/sgi-xp/xpc_main.c
34741 @@ -162,7 +162,7 @@ static struct notifier_block xpc_die_notifier = {
34742 .notifier_call = xpc_system_die,
34743 };
34744
34745 -struct xpc_arch_operations xpc_arch_ops;
34746 +xpc_arch_operations_no_const xpc_arch_ops;
34747
34748 /*
34749 * Timer function to enforce the timelimit on the partition disengage.
34750 diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
34751 index 6ebdc40..9edf5d8 100644
34752 --- a/drivers/mmc/host/sdhci-pci.c
34753 +++ b/drivers/mmc/host/sdhci-pci.c
34754 @@ -631,7 +631,7 @@ static const struct sdhci_pci_fixes sdhci_via = {
34755 .probe = via_probe,
34756 };
34757
34758 -static const struct pci_device_id pci_ids[] __devinitdata = {
34759 +static const struct pci_device_id pci_ids[] __devinitconst = {
34760 {
34761 .vendor = PCI_VENDOR_ID_RICOH,
34762 .device = PCI_DEVICE_ID_RICOH_R5C822,
34763 diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
34764 index 87a431c..4959b43 100644
34765 --- a/drivers/mtd/devices/doc2000.c
34766 +++ b/drivers/mtd/devices/doc2000.c
34767 @@ -764,7 +764,7 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
34768
34769 /* The ECC will not be calculated correctly if less than 512 is written */
34770 /* DBB-
34771 - if (len != 0x200 && eccbuf)
34772 + if (len != 0x200)
34773 printk(KERN_WARNING
34774 "ECC needs a full sector write (adr: %lx size %lx)\n",
34775 (long) to, (long) len);
34776 diff --git a/drivers/mtd/devices/doc2001.c b/drivers/mtd/devices/doc2001.c
34777 index 9eacf67..4534b5b 100644
34778 --- a/drivers/mtd/devices/doc2001.c
34779 +++ b/drivers/mtd/devices/doc2001.c
34780 @@ -384,7 +384,7 @@ static int doc_read (struct mtd_info *mtd, loff_t from, size_t len,
34781 struct Nand *mychip = &this->chips[from >> (this->chipshift)];
34782
34783 /* Don't allow read past end of device */
34784 - if (from >= this->totlen)
34785 + if (from >= this->totlen || !len)
34786 return -EINVAL;
34787
34788 /* Don't allow a single read to cross a 512-byte block boundary */
34789 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
34790 index 3984d48..28aa897 100644
34791 --- a/drivers/mtd/nand/denali.c
34792 +++ b/drivers/mtd/nand/denali.c
34793 @@ -26,6 +26,7 @@
34794 #include <linux/pci.h>
34795 #include <linux/mtd/mtd.h>
34796 #include <linux/module.h>
34797 +#include <linux/slab.h>
34798
34799 #include "denali.h"
34800
34801 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
34802 index 51b9d6a..52af9a7 100644
34803 --- a/drivers/mtd/nftlmount.c
34804 +++ b/drivers/mtd/nftlmount.c
34805 @@ -24,6 +24,7 @@
34806 #include <asm/errno.h>
34807 #include <linux/delay.h>
34808 #include <linux/slab.h>
34809 +#include <linux/sched.h>
34810 #include <linux/mtd/mtd.h>
34811 #include <linux/mtd/nand.h>
34812 #include <linux/mtd/nftl.h>
34813 diff --git a/drivers/net/ethernet/atheros/atlx/atl2.c b/drivers/net/ethernet/atheros/atlx/atl2.c
34814 index 071f4c8..440862e 100644
34815 --- a/drivers/net/ethernet/atheros/atlx/atl2.c
34816 +++ b/drivers/net/ethernet/atheros/atlx/atl2.c
34817 @@ -2862,7 +2862,7 @@ static void atl2_force_ps(struct atl2_hw *hw)
34818 */
34819
34820 #define ATL2_PARAM(X, desc) \
34821 - static const int __devinitdata X[ATL2_MAX_NIC + 1] = ATL2_PARAM_INIT; \
34822 + static const int __devinitconst X[ATL2_MAX_NIC + 1] = ATL2_PARAM_INIT; \
34823 MODULE_PARM(X, "1-" __MODULE_STRING(ATL2_MAX_NIC) "i"); \
34824 MODULE_PARM_DESC(X, desc);
34825 #else
34826 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
34827 index 66da39f..5dc436d 100644
34828 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
34829 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
34830 @@ -473,7 +473,7 @@ struct bnx2x_rx_mode_obj {
34831
34832 int (*wait_comp)(struct bnx2x *bp,
34833 struct bnx2x_rx_mode_ramrod_params *p);
34834 -};
34835 +} __no_const;
34836
34837 /********************** Set multicast group ***********************************/
34838
34839 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
34840 index aea8f72..fcebf75 100644
34841 --- a/drivers/net/ethernet/broadcom/tg3.h
34842 +++ b/drivers/net/ethernet/broadcom/tg3.h
34843 @@ -140,6 +140,7 @@
34844 #define CHIPREV_ID_5750_A0 0x4000
34845 #define CHIPREV_ID_5750_A1 0x4001
34846 #define CHIPREV_ID_5750_A3 0x4003
34847 +#define CHIPREV_ID_5750_C1 0x4201
34848 #define CHIPREV_ID_5750_C2 0x4202
34849 #define CHIPREV_ID_5752_A0_HW 0x5000
34850 #define CHIPREV_ID_5752_A0 0x6000
34851 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
34852 index c4e8643..0979484 100644
34853 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
34854 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
34855 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
34856 */
34857 struct l2t_skb_cb {
34858 arp_failure_handler_func arp_failure_handler;
34859 -};
34860 +} __no_const;
34861
34862 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
34863
34864 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
34865 index 4d71f5a..8004440 100644
34866 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
34867 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
34868 @@ -5392,7 +5392,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
34869 for (i=0; i<ETH_ALEN; i++) {
34870 tmp.addr[i] = dev->dev_addr[i];
34871 }
34872 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
34873 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
34874 break;
34875
34876 case DE4X5_SET_HWADDR: /* Set the hardware address */
34877 @@ -5432,7 +5432,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
34878 spin_lock_irqsave(&lp->lock, flags);
34879 memcpy(&statbuf, &lp->pktStats, ioc->len);
34880 spin_unlock_irqrestore(&lp->lock, flags);
34881 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
34882 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
34883 return -EFAULT;
34884 break;
34885 }
34886 diff --git a/drivers/net/ethernet/dec/tulip/eeprom.c b/drivers/net/ethernet/dec/tulip/eeprom.c
34887 index 14d5b61..1398636 100644
34888 --- a/drivers/net/ethernet/dec/tulip/eeprom.c
34889 +++ b/drivers/net/ethernet/dec/tulip/eeprom.c
34890 @@ -79,7 +79,7 @@ static struct eeprom_fixup eeprom_fixups[] __devinitdata = {
34891 {NULL}};
34892
34893
34894 -static const char *block_name[] __devinitdata = {
34895 +static const char *block_name[] __devinitconst = {
34896 "21140 non-MII",
34897 "21140 MII PHY",
34898 "21142 Serial PHY",
34899 diff --git a/drivers/net/ethernet/dec/tulip/winbond-840.c b/drivers/net/ethernet/dec/tulip/winbond-840.c
34900 index 52da7b2..4ddfe1c 100644
34901 --- a/drivers/net/ethernet/dec/tulip/winbond-840.c
34902 +++ b/drivers/net/ethernet/dec/tulip/winbond-840.c
34903 @@ -236,7 +236,7 @@ struct pci_id_info {
34904 int drv_flags; /* Driver use, intended as capability flags. */
34905 };
34906
34907 -static const struct pci_id_info pci_id_tbl[] __devinitdata = {
34908 +static const struct pci_id_info pci_id_tbl[] __devinitconst = {
34909 { /* Sometime a Level-One switch card. */
34910 "Winbond W89c840", CanHaveMII | HasBrokenTx | FDXOnNoMII},
34911 { "Winbond W89c840", CanHaveMII | HasBrokenTx},
34912 diff --git a/drivers/net/ethernet/dlink/sundance.c b/drivers/net/ethernet/dlink/sundance.c
34913 index 28a3a9b..d96cb63 100644
34914 --- a/drivers/net/ethernet/dlink/sundance.c
34915 +++ b/drivers/net/ethernet/dlink/sundance.c
34916 @@ -218,7 +218,7 @@ enum {
34917 struct pci_id_info {
34918 const char *name;
34919 };
34920 -static const struct pci_id_info pci_id_tbl[] __devinitdata = {
34921 +static const struct pci_id_info pci_id_tbl[] __devinitconst = {
34922 {"D-Link DFE-550TX FAST Ethernet Adapter"},
34923 {"D-Link DFE-550FX 100Mbps Fiber-optics Adapter"},
34924 {"D-Link DFE-580TX 4 port Server Adapter"},
34925 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
34926 index e703d64..d62ecf9 100644
34927 --- a/drivers/net/ethernet/emulex/benet/be_main.c
34928 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
34929 @@ -402,7 +402,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
34930
34931 if (wrapped)
34932 newacc += 65536;
34933 - ACCESS_ONCE(*acc) = newacc;
34934 + ACCESS_ONCE_RW(*acc) = newacc;
34935 }
34936
34937 void be_parse_stats(struct be_adapter *adapter)
34938 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
34939 index 47f85c3..82ab6c4 100644
34940 --- a/drivers/net/ethernet/faraday/ftgmac100.c
34941 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
34942 @@ -31,6 +31,8 @@
34943 #include <linux/netdevice.h>
34944 #include <linux/phy.h>
34945 #include <linux/platform_device.h>
34946 +#include <linux/interrupt.h>
34947 +#include <linux/irqreturn.h>
34948 #include <net/ip.h>
34949
34950 #include "ftgmac100.h"
34951 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
34952 index bb336a0..4b472da 100644
34953 --- a/drivers/net/ethernet/faraday/ftmac100.c
34954 +++ b/drivers/net/ethernet/faraday/ftmac100.c
34955 @@ -31,6 +31,8 @@
34956 #include <linux/module.h>
34957 #include <linux/netdevice.h>
34958 #include <linux/platform_device.h>
34959 +#include <linux/interrupt.h>
34960 +#include <linux/irqreturn.h>
34961
34962 #include "ftmac100.h"
34963
34964 diff --git a/drivers/net/ethernet/fealnx.c b/drivers/net/ethernet/fealnx.c
34965 index c82d444..0007fb4 100644
34966 --- a/drivers/net/ethernet/fealnx.c
34967 +++ b/drivers/net/ethernet/fealnx.c
34968 @@ -150,7 +150,7 @@ struct chip_info {
34969 int flags;
34970 };
34971
34972 -static const struct chip_info skel_netdrv_tbl[] __devinitdata = {
34973 +static const struct chip_info skel_netdrv_tbl[] __devinitconst = {
34974 { "100/10M Ethernet PCI Adapter", HAS_MII_XCVR },
34975 { "100/10M Ethernet PCI Adapter", HAS_CHIP_XCVR },
34976 { "1000/100/10M Ethernet PCI Adapter", HAS_MII_XCVR },
34977 diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.c b/drivers/net/ethernet/intel/e1000e/80003es2lan.c
34978 index e1159e5..e18684d 100644
34979 --- a/drivers/net/ethernet/intel/e1000e/80003es2lan.c
34980 +++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.c
34981 @@ -205,7 +205,7 @@ static s32 e1000_init_mac_params_80003es2lan(struct e1000_adapter *adapter)
34982 {
34983 struct e1000_hw *hw = &adapter->hw;
34984 struct e1000_mac_info *mac = &hw->mac;
34985 - struct e1000_mac_operations *func = &mac->ops;
34986 + e1000_mac_operations_no_const *func = &mac->ops;
34987
34988 /* Set media type */
34989 switch (adapter->pdev->device) {
34990 diff --git a/drivers/net/ethernet/intel/e1000e/82571.c b/drivers/net/ethernet/intel/e1000e/82571.c
34991 index a3e65fd..f451444 100644
34992 --- a/drivers/net/ethernet/intel/e1000e/82571.c
34993 +++ b/drivers/net/ethernet/intel/e1000e/82571.c
34994 @@ -239,7 +239,7 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter)
34995 {
34996 struct e1000_hw *hw = &adapter->hw;
34997 struct e1000_mac_info *mac = &hw->mac;
34998 - struct e1000_mac_operations *func = &mac->ops;
34999 + e1000_mac_operations_no_const *func = &mac->ops;
35000 u32 swsm = 0;
35001 u32 swsm2 = 0;
35002 bool force_clear_smbi = false;
35003 diff --git a/drivers/net/ethernet/intel/e1000e/hw.h b/drivers/net/ethernet/intel/e1000e/hw.h
35004 index 2967039..ca8c40c 100644
35005 --- a/drivers/net/ethernet/intel/e1000e/hw.h
35006 +++ b/drivers/net/ethernet/intel/e1000e/hw.h
35007 @@ -778,6 +778,7 @@ struct e1000_mac_operations {
35008 void (*write_vfta)(struct e1000_hw *, u32, u32);
35009 s32 (*read_mac_addr)(struct e1000_hw *);
35010 };
35011 +typedef struct e1000_mac_operations __no_const e1000_mac_operations_no_const;
35012
35013 /*
35014 * When to use various PHY register access functions:
35015 @@ -818,6 +819,7 @@ struct e1000_phy_operations {
35016 void (*power_up)(struct e1000_hw *);
35017 void (*power_down)(struct e1000_hw *);
35018 };
35019 +typedef struct e1000_phy_operations __no_const e1000_phy_operations_no_const;
35020
35021 /* Function pointers for the NVM. */
35022 struct e1000_nvm_operations {
35023 @@ -829,9 +831,10 @@ struct e1000_nvm_operations {
35024 s32 (*validate)(struct e1000_hw *);
35025 s32 (*write)(struct e1000_hw *, u16, u16, u16 *);
35026 };
35027 +typedef struct e1000_nvm_operations __no_const e1000_nvm_operations_no_const;
35028
35029 struct e1000_mac_info {
35030 - struct e1000_mac_operations ops;
35031 + e1000_mac_operations_no_const ops;
35032 u8 addr[ETH_ALEN];
35033 u8 perm_addr[ETH_ALEN];
35034
35035 @@ -872,7 +875,7 @@ struct e1000_mac_info {
35036 };
35037
35038 struct e1000_phy_info {
35039 - struct e1000_phy_operations ops;
35040 + e1000_phy_operations_no_const ops;
35041
35042 enum e1000_phy_type type;
35043
35044 @@ -906,7 +909,7 @@ struct e1000_phy_info {
35045 };
35046
35047 struct e1000_nvm_info {
35048 - struct e1000_nvm_operations ops;
35049 + e1000_nvm_operations_no_const ops;
35050
35051 enum e1000_nvm_type type;
35052 enum e1000_nvm_override override;
35053 diff --git a/drivers/net/ethernet/intel/igb/e1000_hw.h b/drivers/net/ethernet/intel/igb/e1000_hw.h
35054 index f67cbd3..cef9e3d 100644
35055 --- a/drivers/net/ethernet/intel/igb/e1000_hw.h
35056 +++ b/drivers/net/ethernet/intel/igb/e1000_hw.h
35057 @@ -314,6 +314,7 @@ struct e1000_mac_operations {
35058 s32 (*read_mac_addr)(struct e1000_hw *);
35059 s32 (*get_speed_and_duplex)(struct e1000_hw *, u16 *, u16 *);
35060 };
35061 +typedef struct e1000_mac_operations __no_const e1000_mac_operations_no_const;
35062
35063 struct e1000_phy_operations {
35064 s32 (*acquire)(struct e1000_hw *);
35065 @@ -330,6 +331,7 @@ struct e1000_phy_operations {
35066 s32 (*set_d3_lplu_state)(struct e1000_hw *, bool);
35067 s32 (*write_reg)(struct e1000_hw *, u32, u16);
35068 };
35069 +typedef struct e1000_phy_operations __no_const e1000_phy_operations_no_const;
35070
35071 struct e1000_nvm_operations {
35072 s32 (*acquire)(struct e1000_hw *);
35073 @@ -339,6 +341,7 @@ struct e1000_nvm_operations {
35074 s32 (*update)(struct e1000_hw *);
35075 s32 (*validate)(struct e1000_hw *);
35076 };
35077 +typedef struct e1000_nvm_operations __no_const e1000_nvm_operations_no_const;
35078
35079 struct e1000_info {
35080 s32 (*get_invariants)(struct e1000_hw *);
35081 @@ -350,7 +353,7 @@ struct e1000_info {
35082 extern const struct e1000_info e1000_82575_info;
35083
35084 struct e1000_mac_info {
35085 - struct e1000_mac_operations ops;
35086 + e1000_mac_operations_no_const ops;
35087
35088 u8 addr[6];
35089 u8 perm_addr[6];
35090 @@ -388,7 +391,7 @@ struct e1000_mac_info {
35091 };
35092
35093 struct e1000_phy_info {
35094 - struct e1000_phy_operations ops;
35095 + e1000_phy_operations_no_const ops;
35096
35097 enum e1000_phy_type type;
35098
35099 @@ -423,7 +426,7 @@ struct e1000_phy_info {
35100 };
35101
35102 struct e1000_nvm_info {
35103 - struct e1000_nvm_operations ops;
35104 + e1000_nvm_operations_no_const ops;
35105 enum e1000_nvm_type type;
35106 enum e1000_nvm_override override;
35107
35108 @@ -468,6 +471,7 @@ struct e1000_mbx_operations {
35109 s32 (*check_for_ack)(struct e1000_hw *, u16);
35110 s32 (*check_for_rst)(struct e1000_hw *, u16);
35111 };
35112 +typedef struct e1000_mbx_operations __no_const e1000_mbx_operations_no_const;
35113
35114 struct e1000_mbx_stats {
35115 u32 msgs_tx;
35116 @@ -479,7 +483,7 @@ struct e1000_mbx_stats {
35117 };
35118
35119 struct e1000_mbx_info {
35120 - struct e1000_mbx_operations ops;
35121 + e1000_mbx_operations_no_const ops;
35122 struct e1000_mbx_stats stats;
35123 u32 timeout;
35124 u32 usec_delay;
35125 diff --git a/drivers/net/ethernet/intel/igbvf/vf.h b/drivers/net/ethernet/intel/igbvf/vf.h
35126 index 57db3c6..aa825fc 100644
35127 --- a/drivers/net/ethernet/intel/igbvf/vf.h
35128 +++ b/drivers/net/ethernet/intel/igbvf/vf.h
35129 @@ -189,9 +189,10 @@ struct e1000_mac_operations {
35130 s32 (*read_mac_addr)(struct e1000_hw *);
35131 s32 (*set_vfta)(struct e1000_hw *, u16, bool);
35132 };
35133 +typedef struct e1000_mac_operations __no_const e1000_mac_operations_no_const;
35134
35135 struct e1000_mac_info {
35136 - struct e1000_mac_operations ops;
35137 + e1000_mac_operations_no_const ops;
35138 u8 addr[6];
35139 u8 perm_addr[6];
35140
35141 @@ -213,6 +214,7 @@ struct e1000_mbx_operations {
35142 s32 (*check_for_ack)(struct e1000_hw *);
35143 s32 (*check_for_rst)(struct e1000_hw *);
35144 };
35145 +typedef struct e1000_mbx_operations __no_const e1000_mbx_operations_no_const;
35146
35147 struct e1000_mbx_stats {
35148 u32 msgs_tx;
35149 @@ -224,7 +226,7 @@ struct e1000_mbx_stats {
35150 };
35151
35152 struct e1000_mbx_info {
35153 - struct e1000_mbx_operations ops;
35154 + e1000_mbx_operations_no_const ops;
35155 struct e1000_mbx_stats stats;
35156 u32 timeout;
35157 u32 usec_delay;
35158 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
35159 index 9b95bef..7e254ee 100644
35160 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
35161 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
35162 @@ -2708,6 +2708,7 @@ struct ixgbe_eeprom_operations {
35163 s32 (*update_checksum)(struct ixgbe_hw *);
35164 u16 (*calc_checksum)(struct ixgbe_hw *);
35165 };
35166 +typedef struct ixgbe_eeprom_operations __no_const ixgbe_eeprom_operations_no_const;
35167
35168 struct ixgbe_mac_operations {
35169 s32 (*init_hw)(struct ixgbe_hw *);
35170 @@ -2769,6 +2770,7 @@ struct ixgbe_mac_operations {
35171 /* Manageability interface */
35172 s32 (*set_fw_drv_ver)(struct ixgbe_hw *, u8, u8, u8, u8);
35173 };
35174 +typedef struct ixgbe_mac_operations __no_const ixgbe_mac_operations_no_const;
35175
35176 struct ixgbe_phy_operations {
35177 s32 (*identify)(struct ixgbe_hw *);
35178 @@ -2788,9 +2790,10 @@ struct ixgbe_phy_operations {
35179 s32 (*write_i2c_eeprom)(struct ixgbe_hw *, u8, u8);
35180 s32 (*check_overtemp)(struct ixgbe_hw *);
35181 };
35182 +typedef struct ixgbe_phy_operations __no_const ixgbe_phy_operations_no_const;
35183
35184 struct ixgbe_eeprom_info {
35185 - struct ixgbe_eeprom_operations ops;
35186 + ixgbe_eeprom_operations_no_const ops;
35187 enum ixgbe_eeprom_type type;
35188 u32 semaphore_delay;
35189 u16 word_size;
35190 @@ -2800,7 +2803,7 @@ struct ixgbe_eeprom_info {
35191
35192 #define IXGBE_FLAGS_DOUBLE_RESET_REQUIRED 0x01
35193 struct ixgbe_mac_info {
35194 - struct ixgbe_mac_operations ops;
35195 + ixgbe_mac_operations_no_const ops;
35196 enum ixgbe_mac_type type;
35197 u8 addr[ETH_ALEN];
35198 u8 perm_addr[ETH_ALEN];
35199 @@ -2828,7 +2831,7 @@ struct ixgbe_mac_info {
35200 };
35201
35202 struct ixgbe_phy_info {
35203 - struct ixgbe_phy_operations ops;
35204 + ixgbe_phy_operations_no_const ops;
35205 struct mdio_if_info mdio;
35206 enum ixgbe_phy_type type;
35207 u32 id;
35208 @@ -2856,6 +2859,7 @@ struct ixgbe_mbx_operations {
35209 s32 (*check_for_ack)(struct ixgbe_hw *, u16);
35210 s32 (*check_for_rst)(struct ixgbe_hw *, u16);
35211 };
35212 +typedef struct ixgbe_mbx_operations __no_const ixgbe_mbx_operations_no_const;
35213
35214 struct ixgbe_mbx_stats {
35215 u32 msgs_tx;
35216 @@ -2867,7 +2871,7 @@ struct ixgbe_mbx_stats {
35217 };
35218
35219 struct ixgbe_mbx_info {
35220 - struct ixgbe_mbx_operations ops;
35221 + ixgbe_mbx_operations_no_const ops;
35222 struct ixgbe_mbx_stats stats;
35223 u32 timeout;
35224 u32 usec_delay;
35225 diff --git a/drivers/net/ethernet/intel/ixgbevf/vf.h b/drivers/net/ethernet/intel/ixgbevf/vf.h
35226 index 25c951d..cc7cf33 100644
35227 --- a/drivers/net/ethernet/intel/ixgbevf/vf.h
35228 +++ b/drivers/net/ethernet/intel/ixgbevf/vf.h
35229 @@ -70,6 +70,7 @@ struct ixgbe_mac_operations {
35230 s32 (*clear_vfta)(struct ixgbe_hw *);
35231 s32 (*set_vfta)(struct ixgbe_hw *, u32, u32, bool);
35232 };
35233 +typedef struct ixgbe_mac_operations __no_const ixgbe_mac_operations_no_const;
35234
35235 enum ixgbe_mac_type {
35236 ixgbe_mac_unknown = 0,
35237 @@ -79,7 +80,7 @@ enum ixgbe_mac_type {
35238 };
35239
35240 struct ixgbe_mac_info {
35241 - struct ixgbe_mac_operations ops;
35242 + ixgbe_mac_operations_no_const ops;
35243 u8 addr[6];
35244 u8 perm_addr[6];
35245
35246 @@ -103,6 +104,7 @@ struct ixgbe_mbx_operations {
35247 s32 (*check_for_ack)(struct ixgbe_hw *);
35248 s32 (*check_for_rst)(struct ixgbe_hw *);
35249 };
35250 +typedef struct ixgbe_mbx_operations __no_const ixgbe_mbx_operations_no_const;
35251
35252 struct ixgbe_mbx_stats {
35253 u32 msgs_tx;
35254 @@ -114,7 +116,7 @@ struct ixgbe_mbx_stats {
35255 };
35256
35257 struct ixgbe_mbx_info {
35258 - struct ixgbe_mbx_operations ops;
35259 + ixgbe_mbx_operations_no_const ops;
35260 struct ixgbe_mbx_stats stats;
35261 u32 timeout;
35262 u32 udelay;
35263 diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
35264 index 8bf22b6..7f5baaa 100644
35265 --- a/drivers/net/ethernet/mellanox/mlx4/main.c
35266 +++ b/drivers/net/ethernet/mellanox/mlx4/main.c
35267 @@ -41,6 +41,7 @@
35268 #include <linux/slab.h>
35269 #include <linux/io-mapping.h>
35270 #include <linux/delay.h>
35271 +#include <linux/sched.h>
35272
35273 #include <linux/mlx4/device.h>
35274 #include <linux/mlx4/doorbell.h>
35275 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.h b/drivers/net/ethernet/neterion/vxge/vxge-config.h
35276 index 5046a64..71ca936 100644
35277 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.h
35278 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.h
35279 @@ -514,7 +514,7 @@ struct vxge_hw_uld_cbs {
35280 void (*link_down)(struct __vxge_hw_device *devh);
35281 void (*crit_err)(struct __vxge_hw_device *devh,
35282 enum vxge_hw_event type, u64 ext_data);
35283 -};
35284 +} __no_const;
35285
35286 /*
35287 * struct __vxge_hw_blockpool_entry - Block private data structure
35288 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-traffic.h b/drivers/net/ethernet/neterion/vxge/vxge-traffic.h
35289 index 4a518a3..936b334 100644
35290 --- a/drivers/net/ethernet/neterion/vxge/vxge-traffic.h
35291 +++ b/drivers/net/ethernet/neterion/vxge/vxge-traffic.h
35292 @@ -2088,7 +2088,7 @@ struct vxge_hw_mempool_cbs {
35293 struct vxge_hw_mempool_dma *dma_object,
35294 u32 index,
35295 u32 is_last);
35296 -};
35297 +} __no_const;
35298
35299 #define VXGE_HW_VIRTUAL_PATH_HANDLE(vpath) \
35300 ((struct __vxge_hw_vpath_handle *)(vpath)->vpath_handles.next)
35301 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
35302 index bbacb37..d60887d 100644
35303 --- a/drivers/net/ethernet/realtek/r8169.c
35304 +++ b/drivers/net/ethernet/realtek/r8169.c
35305 @@ -695,17 +695,17 @@ struct rtl8169_private {
35306 struct mdio_ops {
35307 void (*write)(void __iomem *, int, int);
35308 int (*read)(void __iomem *, int);
35309 - } mdio_ops;
35310 + } __no_const mdio_ops;
35311
35312 struct pll_power_ops {
35313 void (*down)(struct rtl8169_private *);
35314 void (*up)(struct rtl8169_private *);
35315 - } pll_power_ops;
35316 + } __no_const pll_power_ops;
35317
35318 struct jumbo_ops {
35319 void (*enable)(struct rtl8169_private *);
35320 void (*disable)(struct rtl8169_private *);
35321 - } jumbo_ops;
35322 + } __no_const jumbo_ops;
35323
35324 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
35325 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
35326 diff --git a/drivers/net/ethernet/sis/sis190.c b/drivers/net/ethernet/sis/sis190.c
35327 index 5b118cd..858b523 100644
35328 --- a/drivers/net/ethernet/sis/sis190.c
35329 +++ b/drivers/net/ethernet/sis/sis190.c
35330 @@ -1622,7 +1622,7 @@ static int __devinit sis190_get_mac_addr_from_eeprom(struct pci_dev *pdev,
35331 static int __devinit sis190_get_mac_addr_from_apc(struct pci_dev *pdev,
35332 struct net_device *dev)
35333 {
35334 - static const u16 __devinitdata ids[] = { 0x0965, 0x0966, 0x0968 };
35335 + static const u16 __devinitconst ids[] = { 0x0965, 0x0966, 0x0968 };
35336 struct sis190_private *tp = netdev_priv(dev);
35337 struct pci_dev *isa_bridge;
35338 u8 reg, tmp8;
35339 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
35340 index c07cfe9..81cbf7e 100644
35341 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
35342 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
35343 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
35344
35345 writel(value, ioaddr + MMC_CNTRL);
35346
35347 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
35348 - MMC_CNTRL, value);
35349 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
35350 +// MMC_CNTRL, value);
35351 }
35352
35353 /* To mask all all interrupts.*/
35354 diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
35355 index 6ee593a..3f513b1 100644
35356 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
35357 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
35358 @@ -1585,7 +1585,7 @@ static const struct file_operations stmmac_rings_status_fops = {
35359 .open = stmmac_sysfs_ring_open,
35360 .read = seq_read,
35361 .llseek = seq_lseek,
35362 - .release = seq_release,
35363 + .release = single_release,
35364 };
35365
35366 static int stmmac_sysfs_dma_cap_read(struct seq_file *seq, void *v)
35367 @@ -1657,7 +1657,7 @@ static const struct file_operations stmmac_dma_cap_fops = {
35368 .open = stmmac_sysfs_dma_cap_open,
35369 .read = seq_read,
35370 .llseek = seq_lseek,
35371 - .release = seq_release,
35372 + .release = single_release,
35373 };
35374
35375 static int stmmac_init_fs(struct net_device *dev)
35376 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
35377 index dec5836..6d4db7d 100644
35378 --- a/drivers/net/hyperv/hyperv_net.h
35379 +++ b/drivers/net/hyperv/hyperv_net.h
35380 @@ -97,7 +97,7 @@ struct rndis_device {
35381
35382 enum rndis_device_state state;
35383 bool link_state;
35384 - atomic_t new_req_id;
35385 + atomic_unchecked_t new_req_id;
35386
35387 spinlock_t request_lock;
35388 struct list_head req_list;
35389 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
35390 index 133b7fb..d58c559 100644
35391 --- a/drivers/net/hyperv/rndis_filter.c
35392 +++ b/drivers/net/hyperv/rndis_filter.c
35393 @@ -96,7 +96,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
35394 * template
35395 */
35396 set = &rndis_msg->msg.set_req;
35397 - set->req_id = atomic_inc_return(&dev->new_req_id);
35398 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
35399
35400 /* Add to the request list */
35401 spin_lock_irqsave(&dev->request_lock, flags);
35402 @@ -627,7 +627,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
35403
35404 /* Setup the rndis set */
35405 halt = &request->request_msg.msg.halt_req;
35406 - halt->req_id = atomic_inc_return(&dev->new_req_id);
35407 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
35408
35409 /* Ignore return since this msg is optional. */
35410 rndis_filter_send_request(dev, request);
35411 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
35412 index 58dc117..f140c77 100644
35413 --- a/drivers/net/macvtap.c
35414 +++ b/drivers/net/macvtap.c
35415 @@ -526,6 +526,8 @@ static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from,
35416 }
35417 base = (unsigned long)from->iov_base + offset1;
35418 size = ((base & ~PAGE_MASK) + len + ~PAGE_MASK) >> PAGE_SHIFT;
35419 + if (i + size >= MAX_SKB_FRAGS)
35420 + return -EFAULT;
35421 num_pages = get_user_pages_fast(base, size, 0, &page[i]);
35422 if ((num_pages != size) ||
35423 (num_pages > MAX_SKB_FRAGS - skb_shinfo(skb)->nr_frags))
35424 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
35425 index 3ed983c..a1bb418 100644
35426 --- a/drivers/net/ppp/ppp_generic.c
35427 +++ b/drivers/net/ppp/ppp_generic.c
35428 @@ -986,7 +986,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
35429 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
35430 struct ppp_stats stats;
35431 struct ppp_comp_stats cstats;
35432 - char *vers;
35433
35434 switch (cmd) {
35435 case SIOCGPPPSTATS:
35436 @@ -1008,8 +1007,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
35437 break;
35438
35439 case SIOCGPPPVER:
35440 - vers = PPP_VERSION;
35441 - if (copy_to_user(addr, vers, strlen(vers) + 1))
35442 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
35443 break;
35444 err = 0;
35445 break;
35446 diff --git a/drivers/net/tokenring/abyss.c b/drivers/net/tokenring/abyss.c
35447 index 515f122..41dd273 100644
35448 --- a/drivers/net/tokenring/abyss.c
35449 +++ b/drivers/net/tokenring/abyss.c
35450 @@ -451,10 +451,12 @@ static struct pci_driver abyss_driver = {
35451
35452 static int __init abyss_init (void)
35453 {
35454 - abyss_netdev_ops = tms380tr_netdev_ops;
35455 + pax_open_kernel();
35456 + memcpy((void *)&abyss_netdev_ops, &tms380tr_netdev_ops, sizeof(tms380tr_netdev_ops));
35457
35458 - abyss_netdev_ops.ndo_open = abyss_open;
35459 - abyss_netdev_ops.ndo_stop = abyss_close;
35460 + *(void **)&abyss_netdev_ops.ndo_open = abyss_open;
35461 + *(void **)&abyss_netdev_ops.ndo_stop = abyss_close;
35462 + pax_close_kernel();
35463
35464 return pci_register_driver(&abyss_driver);
35465 }
35466 diff --git a/drivers/net/tokenring/madgemc.c b/drivers/net/tokenring/madgemc.c
35467 index 6153cfd..cf69c1c 100644
35468 --- a/drivers/net/tokenring/madgemc.c
35469 +++ b/drivers/net/tokenring/madgemc.c
35470 @@ -744,9 +744,11 @@ static struct mca_driver madgemc_driver = {
35471
35472 static int __init madgemc_init (void)
35473 {
35474 - madgemc_netdev_ops = tms380tr_netdev_ops;
35475 - madgemc_netdev_ops.ndo_open = madgemc_open;
35476 - madgemc_netdev_ops.ndo_stop = madgemc_close;
35477 + pax_open_kernel();
35478 + memcpy((void *)&madgemc_netdev_ops, &tms380tr_netdev_ops, sizeof(tms380tr_netdev_ops));
35479 + *(void **)&madgemc_netdev_ops.ndo_open = madgemc_open;
35480 + *(void **)&madgemc_netdev_ops.ndo_stop = madgemc_close;
35481 + pax_close_kernel();
35482
35483 return mca_register_driver (&madgemc_driver);
35484 }
35485 diff --git a/drivers/net/tokenring/proteon.c b/drivers/net/tokenring/proteon.c
35486 index 8d362e6..f91cc52 100644
35487 --- a/drivers/net/tokenring/proteon.c
35488 +++ b/drivers/net/tokenring/proteon.c
35489 @@ -353,9 +353,11 @@ static int __init proteon_init(void)
35490 struct platform_device *pdev;
35491 int i, num = 0, err = 0;
35492
35493 - proteon_netdev_ops = tms380tr_netdev_ops;
35494 - proteon_netdev_ops.ndo_open = proteon_open;
35495 - proteon_netdev_ops.ndo_stop = tms380tr_close;
35496 + pax_open_kernel();
35497 + memcpy((void *)&proteon_netdev_ops, &tms380tr_netdev_ops, sizeof(tms380tr_netdev_ops));
35498 + *(void **)&proteon_netdev_ops.ndo_open = proteon_open;
35499 + *(void **)&proteon_netdev_ops.ndo_stop = tms380tr_close;
35500 + pax_close_kernel();
35501
35502 err = platform_driver_register(&proteon_driver);
35503 if (err)
35504 diff --git a/drivers/net/tokenring/skisa.c b/drivers/net/tokenring/skisa.c
35505 index 46db5c5..37c1536 100644
35506 --- a/drivers/net/tokenring/skisa.c
35507 +++ b/drivers/net/tokenring/skisa.c
35508 @@ -363,9 +363,11 @@ static int __init sk_isa_init(void)
35509 struct platform_device *pdev;
35510 int i, num = 0, err = 0;
35511
35512 - sk_isa_netdev_ops = tms380tr_netdev_ops;
35513 - sk_isa_netdev_ops.ndo_open = sk_isa_open;
35514 - sk_isa_netdev_ops.ndo_stop = tms380tr_close;
35515 + pax_open_kernel();
35516 + memcpy((void *)&sk_isa_netdev_ops, &tms380tr_netdev_ops, sizeof(tms380tr_netdev_ops));
35517 + *(void **)&sk_isa_netdev_ops.ndo_open = sk_isa_open;
35518 + *(void **)&sk_isa_netdev_ops.ndo_stop = tms380tr_close;
35519 + pax_close_kernel();
35520
35521 err = platform_driver_register(&sk_isa_driver);
35522 if (err)
35523 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
35524 index e1324b4..e1b0041 100644
35525 --- a/drivers/net/usb/hso.c
35526 +++ b/drivers/net/usb/hso.c
35527 @@ -71,7 +71,7 @@
35528 #include <asm/byteorder.h>
35529 #include <linux/serial_core.h>
35530 #include <linux/serial.h>
35531 -
35532 +#include <asm/local.h>
35533
35534 #define MOD_AUTHOR "Option Wireless"
35535 #define MOD_DESCRIPTION "USB High Speed Option driver"
35536 @@ -257,7 +257,7 @@ struct hso_serial {
35537
35538 /* from usb_serial_port */
35539 struct tty_struct *tty;
35540 - int open_count;
35541 + local_t open_count;
35542 spinlock_t serial_lock;
35543
35544 int (*write_data) (struct hso_serial *serial);
35545 @@ -1190,7 +1190,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
35546 struct urb *urb;
35547
35548 urb = serial->rx_urb[0];
35549 - if (serial->open_count > 0) {
35550 + if (local_read(&serial->open_count) > 0) {
35551 count = put_rxbuf_data(urb, serial);
35552 if (count == -1)
35553 return;
35554 @@ -1226,7 +1226,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
35555 DUMP1(urb->transfer_buffer, urb->actual_length);
35556
35557 /* Anyone listening? */
35558 - if (serial->open_count == 0)
35559 + if (local_read(&serial->open_count) == 0)
35560 return;
35561
35562 if (status == 0) {
35563 @@ -1311,8 +1311,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
35564 spin_unlock_irq(&serial->serial_lock);
35565
35566 /* check for port already opened, if not set the termios */
35567 - serial->open_count++;
35568 - if (serial->open_count == 1) {
35569 + if (local_inc_return(&serial->open_count) == 1) {
35570 serial->rx_state = RX_IDLE;
35571 /* Force default termio settings */
35572 _hso_serial_set_termios(tty, NULL);
35573 @@ -1324,7 +1323,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
35574 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
35575 if (result) {
35576 hso_stop_serial_device(serial->parent);
35577 - serial->open_count--;
35578 + local_dec(&serial->open_count);
35579 kref_put(&serial->parent->ref, hso_serial_ref_free);
35580 }
35581 } else {
35582 @@ -1361,10 +1360,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
35583
35584 /* reset the rts and dtr */
35585 /* do the actual close */
35586 - serial->open_count--;
35587 + local_dec(&serial->open_count);
35588
35589 - if (serial->open_count <= 0) {
35590 - serial->open_count = 0;
35591 + if (local_read(&serial->open_count) <= 0) {
35592 + local_set(&serial->open_count, 0);
35593 spin_lock_irq(&serial->serial_lock);
35594 if (serial->tty == tty) {
35595 serial->tty->driver_data = NULL;
35596 @@ -1446,7 +1445,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
35597
35598 /* the actual setup */
35599 spin_lock_irqsave(&serial->serial_lock, flags);
35600 - if (serial->open_count)
35601 + if (local_read(&serial->open_count))
35602 _hso_serial_set_termios(tty, old);
35603 else
35604 tty->termios = old;
35605 @@ -1905,7 +1904,7 @@ static void intr_callback(struct urb *urb)
35606 D1("Pending read interrupt on port %d\n", i);
35607 spin_lock(&serial->serial_lock);
35608 if (serial->rx_state == RX_IDLE &&
35609 - serial->open_count > 0) {
35610 + local_read(&serial->open_count) > 0) {
35611 /* Setup and send a ctrl req read on
35612 * port i */
35613 if (!serial->rx_urb_filled[0]) {
35614 @@ -3098,7 +3097,7 @@ static int hso_resume(struct usb_interface *iface)
35615 /* Start all serial ports */
35616 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
35617 if (serial_table[i] && (serial_table[i]->interface == iface)) {
35618 - if (dev2ser(serial_table[i])->open_count) {
35619 + if (local_read(&dev2ser(serial_table[i])->open_count)) {
35620 result =
35621 hso_start_serial_device(serial_table[i], GFP_NOIO);
35622 hso_kick_transmit(dev2ser(serial_table[i]));
35623 diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h
35624 index efc0111..79c8f5b 100644
35625 --- a/drivers/net/wireless/ath/ath.h
35626 +++ b/drivers/net/wireless/ath/ath.h
35627 @@ -119,6 +119,7 @@ struct ath_ops {
35628 void (*write_flush) (void *);
35629 u32 (*rmw)(void *, u32 reg_offset, u32 set, u32 clr);
35630 };
35631 +typedef struct ath_ops __no_const ath_ops_no_const;
35632
35633 struct ath_common;
35634 struct ath_bus_ops;
35635 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
35636 index 7b6417b..ab5db98 100644
35637 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
35638 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
35639 @@ -183,8 +183,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
35640 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
35641 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
35642
35643 - ACCESS_ONCE(ads->ds_link) = i->link;
35644 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
35645 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
35646 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
35647
35648 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
35649 ctl6 = SM(i->keytype, AR_EncrType);
35650 @@ -198,26 +198,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
35651
35652 if ((i->is_first || i->is_last) &&
35653 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
35654 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
35655 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
35656 | set11nTries(i->rates, 1)
35657 | set11nTries(i->rates, 2)
35658 | set11nTries(i->rates, 3)
35659 | (i->dur_update ? AR_DurUpdateEna : 0)
35660 | SM(0, AR_BurstDur);
35661
35662 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
35663 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
35664 | set11nRate(i->rates, 1)
35665 | set11nRate(i->rates, 2)
35666 | set11nRate(i->rates, 3);
35667 } else {
35668 - ACCESS_ONCE(ads->ds_ctl2) = 0;
35669 - ACCESS_ONCE(ads->ds_ctl3) = 0;
35670 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
35671 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
35672 }
35673
35674 if (!i->is_first) {
35675 - ACCESS_ONCE(ads->ds_ctl0) = 0;
35676 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
35677 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
35678 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
35679 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
35680 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
35681 return;
35682 }
35683
35684 @@ -242,7 +242,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
35685 break;
35686 }
35687
35688 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
35689 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
35690 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
35691 | SM(i->txpower, AR_XmitPower)
35692 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
35693 @@ -252,19 +252,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
35694 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
35695 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
35696
35697 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
35698 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
35699 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
35700 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
35701
35702 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
35703 return;
35704
35705 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
35706 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
35707 | set11nPktDurRTSCTS(i->rates, 1);
35708
35709 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
35710 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
35711 | set11nPktDurRTSCTS(i->rates, 3);
35712
35713 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
35714 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
35715 | set11nRateFlags(i->rates, 1)
35716 | set11nRateFlags(i->rates, 2)
35717 | set11nRateFlags(i->rates, 3)
35718 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
35719 index 09b8c9d..905339e 100644
35720 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
35721 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
35722 @@ -35,47 +35,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
35723 (i->qcu << AR_TxQcuNum_S) | 0x17;
35724
35725 checksum += val;
35726 - ACCESS_ONCE(ads->info) = val;
35727 + ACCESS_ONCE_RW(ads->info) = val;
35728
35729 checksum += i->link;
35730 - ACCESS_ONCE(ads->link) = i->link;
35731 + ACCESS_ONCE_RW(ads->link) = i->link;
35732
35733 checksum += i->buf_addr[0];
35734 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
35735 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
35736 checksum += i->buf_addr[1];
35737 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
35738 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
35739 checksum += i->buf_addr[2];
35740 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
35741 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
35742 checksum += i->buf_addr[3];
35743 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
35744 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
35745
35746 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
35747 - ACCESS_ONCE(ads->ctl3) = val;
35748 + ACCESS_ONCE_RW(ads->ctl3) = val;
35749 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
35750 - ACCESS_ONCE(ads->ctl5) = val;
35751 + ACCESS_ONCE_RW(ads->ctl5) = val;
35752 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
35753 - ACCESS_ONCE(ads->ctl7) = val;
35754 + ACCESS_ONCE_RW(ads->ctl7) = val;
35755 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
35756 - ACCESS_ONCE(ads->ctl9) = val;
35757 + ACCESS_ONCE_RW(ads->ctl9) = val;
35758
35759 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
35760 - ACCESS_ONCE(ads->ctl10) = checksum;
35761 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
35762
35763 if (i->is_first || i->is_last) {
35764 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
35765 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
35766 | set11nTries(i->rates, 1)
35767 | set11nTries(i->rates, 2)
35768 | set11nTries(i->rates, 3)
35769 | (i->dur_update ? AR_DurUpdateEna : 0)
35770 | SM(0, AR_BurstDur);
35771
35772 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
35773 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
35774 | set11nRate(i->rates, 1)
35775 | set11nRate(i->rates, 2)
35776 | set11nRate(i->rates, 3);
35777 } else {
35778 - ACCESS_ONCE(ads->ctl13) = 0;
35779 - ACCESS_ONCE(ads->ctl14) = 0;
35780 + ACCESS_ONCE_RW(ads->ctl13) = 0;
35781 + ACCESS_ONCE_RW(ads->ctl14) = 0;
35782 }
35783
35784 ads->ctl20 = 0;
35785 @@ -84,17 +84,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
35786
35787 ctl17 = SM(i->keytype, AR_EncrType);
35788 if (!i->is_first) {
35789 - ACCESS_ONCE(ads->ctl11) = 0;
35790 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
35791 - ACCESS_ONCE(ads->ctl15) = 0;
35792 - ACCESS_ONCE(ads->ctl16) = 0;
35793 - ACCESS_ONCE(ads->ctl17) = ctl17;
35794 - ACCESS_ONCE(ads->ctl18) = 0;
35795 - ACCESS_ONCE(ads->ctl19) = 0;
35796 + ACCESS_ONCE_RW(ads->ctl11) = 0;
35797 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
35798 + ACCESS_ONCE_RW(ads->ctl15) = 0;
35799 + ACCESS_ONCE_RW(ads->ctl16) = 0;
35800 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
35801 + ACCESS_ONCE_RW(ads->ctl18) = 0;
35802 + ACCESS_ONCE_RW(ads->ctl19) = 0;
35803 return;
35804 }
35805
35806 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
35807 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
35808 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
35809 | SM(i->txpower, AR_XmitPower)
35810 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
35811 @@ -130,22 +130,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
35812 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
35813 ctl12 |= SM(val, AR_PAPRDChainMask);
35814
35815 - ACCESS_ONCE(ads->ctl12) = ctl12;
35816 - ACCESS_ONCE(ads->ctl17) = ctl17;
35817 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
35818 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
35819
35820 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
35821 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
35822 | set11nPktDurRTSCTS(i->rates, 1);
35823
35824 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
35825 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
35826 | set11nPktDurRTSCTS(i->rates, 3);
35827
35828 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
35829 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
35830 | set11nRateFlags(i->rates, 1)
35831 | set11nRateFlags(i->rates, 2)
35832 | set11nRateFlags(i->rates, 3)
35833 | SM(i->rtscts_rate, AR_RTSCTSRate);
35834
35835 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
35836 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
35837 }
35838
35839 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
35840 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
35841 index c8261d4..8d88929 100644
35842 --- a/drivers/net/wireless/ath/ath9k/hw.h
35843 +++ b/drivers/net/wireless/ath/ath9k/hw.h
35844 @@ -773,7 +773,7 @@ struct ath_hw_private_ops {
35845
35846 /* ANI */
35847 void (*ani_cache_ini_regs)(struct ath_hw *ah);
35848 -};
35849 +} __no_const;
35850
35851 /**
35852 * struct ath_hw_ops - callbacks used by hardware code and driver code
35853 @@ -803,7 +803,7 @@ struct ath_hw_ops {
35854 void (*antdiv_comb_conf_set)(struct ath_hw *ah,
35855 struct ath_hw_antcomb_conf *antconf);
35856
35857 -};
35858 +} __no_const;
35859
35860 struct ath_nf_limits {
35861 s16 max;
35862 @@ -823,7 +823,7 @@ enum ath_cal_list {
35863 #define AH_FASTCC 0x4
35864
35865 struct ath_hw {
35866 - struct ath_ops reg_ops;
35867 + ath_ops_no_const reg_ops;
35868
35869 struct ieee80211_hw *hw;
35870 struct ath_common common;
35871 diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h
35872 index af00e2c..ab04d34 100644
35873 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h
35874 +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h
35875 @@ -545,7 +545,7 @@ struct phy_func_ptr {
35876 void (*carrsuppr)(struct brcms_phy *);
35877 s32 (*rxsigpwr)(struct brcms_phy *, s32);
35878 void (*detach)(struct brcms_phy *);
35879 -};
35880 +} __no_const;
35881
35882 struct brcms_phy {
35883 struct brcms_phy_pub pubpi_ro;
35884 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
35885 index a2ec369..36fdf14 100644
35886 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
35887 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
35888 @@ -3646,7 +3646,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
35889 */
35890 if (il3945_mod_params.disable_hw_scan) {
35891 D_INFO("Disabling hw_scan\n");
35892 - il3945_hw_ops.hw_scan = NULL;
35893 + pax_open_kernel();
35894 + *(void **)&il3945_hw_ops.hw_scan = NULL;
35895 + pax_close_kernel();
35896 }
35897
35898 D_INFO("*** LOAD DRIVER ***\n");
35899 diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h
35900 index f8fc239..8cade22 100644
35901 --- a/drivers/net/wireless/iwlwifi/iwl-debug.h
35902 +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h
35903 @@ -86,8 +86,8 @@ do { \
35904 } while (0)
35905
35906 #else
35907 -#define IWL_DEBUG(m, level, fmt, args...)
35908 -#define IWL_DEBUG_LIMIT(m, level, fmt, args...)
35909 +#define IWL_DEBUG(m, level, fmt, args...) do {} while (0)
35910 +#define IWL_DEBUG_LIMIT(m, level, fmt, args...) do {} while (0)
35911 #define iwl_print_hex_dump(m, level, p, len)
35912 #define IWL_DEBUG_QUIET_RFKILL(p, fmt, args...) \
35913 do { \
35914 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
35915 index 4b9e730..7603659 100644
35916 --- a/drivers/net/wireless/mac80211_hwsim.c
35917 +++ b/drivers/net/wireless/mac80211_hwsim.c
35918 @@ -1677,9 +1677,11 @@ static int __init init_mac80211_hwsim(void)
35919 return -EINVAL;
35920
35921 if (fake_hw_scan) {
35922 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
35923 - mac80211_hwsim_ops.sw_scan_start = NULL;
35924 - mac80211_hwsim_ops.sw_scan_complete = NULL;
35925 + pax_open_kernel();
35926 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
35927 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
35928 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
35929 + pax_close_kernel();
35930 }
35931
35932 spin_lock_init(&hwsim_radio_lock);
35933 diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h
35934 index 3186aa4..b35b09f 100644
35935 --- a/drivers/net/wireless/mwifiex/main.h
35936 +++ b/drivers/net/wireless/mwifiex/main.h
35937 @@ -536,7 +536,7 @@ struct mwifiex_if_ops {
35938 void (*cleanup_mpa_buf) (struct mwifiex_adapter *);
35939 int (*cmdrsp_complete) (struct mwifiex_adapter *, struct sk_buff *);
35940 int (*event_complete) (struct mwifiex_adapter *, struct sk_buff *);
35941 -};
35942 +} __no_const;
35943
35944 struct mwifiex_adapter {
35945 u8 iface_type;
35946 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
35947 index a330c69..a81540f 100644
35948 --- a/drivers/net/wireless/rndis_wlan.c
35949 +++ b/drivers/net/wireless/rndis_wlan.c
35950 @@ -1278,7 +1278,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
35951
35952 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
35953
35954 - if (rts_threshold < 0 || rts_threshold > 2347)
35955 + if (rts_threshold > 2347)
35956 rts_threshold = 2347;
35957
35958 tmp = cpu_to_le32(rts_threshold);
35959 diff --git a/drivers/net/wireless/wl1251/wl1251.h b/drivers/net/wireless/wl1251/wl1251.h
35960 index a77f1bb..c608b2b 100644
35961 --- a/drivers/net/wireless/wl1251/wl1251.h
35962 +++ b/drivers/net/wireless/wl1251/wl1251.h
35963 @@ -266,7 +266,7 @@ struct wl1251_if_operations {
35964 void (*reset)(struct wl1251 *wl);
35965 void (*enable_irq)(struct wl1251 *wl);
35966 void (*disable_irq)(struct wl1251 *wl);
35967 -};
35968 +} __no_const;
35969
35970 struct wl1251 {
35971 struct ieee80211_hw *hw;
35972 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
35973 index f34b5b2..b5abb9f 100644
35974 --- a/drivers/oprofile/buffer_sync.c
35975 +++ b/drivers/oprofile/buffer_sync.c
35976 @@ -343,7 +343,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
35977 if (cookie == NO_COOKIE)
35978 offset = pc;
35979 if (cookie == INVALID_COOKIE) {
35980 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
35981 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
35982 offset = pc;
35983 }
35984 if (cookie != last_cookie) {
35985 @@ -387,14 +387,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
35986 /* add userspace sample */
35987
35988 if (!mm) {
35989 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
35990 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
35991 return 0;
35992 }
35993
35994 cookie = lookup_dcookie(mm, s->eip, &offset);
35995
35996 if (cookie == INVALID_COOKIE) {
35997 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
35998 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
35999 return 0;
36000 }
36001
36002 @@ -563,7 +563,7 @@ void sync_buffer(int cpu)
36003 /* ignore backtraces if failed to add a sample */
36004 if (state == sb_bt_start) {
36005 state = sb_bt_ignore;
36006 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
36007 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
36008 }
36009 }
36010 release_mm(mm);
36011 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
36012 index c0cc4e7..44d4e54 100644
36013 --- a/drivers/oprofile/event_buffer.c
36014 +++ b/drivers/oprofile/event_buffer.c
36015 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
36016 }
36017
36018 if (buffer_pos == buffer_size) {
36019 - atomic_inc(&oprofile_stats.event_lost_overflow);
36020 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
36021 return;
36022 }
36023
36024 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
36025 index ed2c3ec..deda85a 100644
36026 --- a/drivers/oprofile/oprof.c
36027 +++ b/drivers/oprofile/oprof.c
36028 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
36029 if (oprofile_ops.switch_events())
36030 return;
36031
36032 - atomic_inc(&oprofile_stats.multiplex_counter);
36033 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
36034 start_switch_worker();
36035 }
36036
36037 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
36038 index 917d28e..d62d981 100644
36039 --- a/drivers/oprofile/oprofile_stats.c
36040 +++ b/drivers/oprofile/oprofile_stats.c
36041 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
36042 cpu_buf->sample_invalid_eip = 0;
36043 }
36044
36045 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
36046 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
36047 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
36048 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
36049 - atomic_set(&oprofile_stats.multiplex_counter, 0);
36050 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
36051 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
36052 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
36053 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
36054 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
36055 }
36056
36057
36058 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
36059 index 38b6fc0..b5cbfce 100644
36060 --- a/drivers/oprofile/oprofile_stats.h
36061 +++ b/drivers/oprofile/oprofile_stats.h
36062 @@ -13,11 +13,11 @@
36063 #include <linux/atomic.h>
36064
36065 struct oprofile_stat_struct {
36066 - atomic_t sample_lost_no_mm;
36067 - atomic_t sample_lost_no_mapping;
36068 - atomic_t bt_lost_no_mapping;
36069 - atomic_t event_lost_overflow;
36070 - atomic_t multiplex_counter;
36071 + atomic_unchecked_t sample_lost_no_mm;
36072 + atomic_unchecked_t sample_lost_no_mapping;
36073 + atomic_unchecked_t bt_lost_no_mapping;
36074 + atomic_unchecked_t event_lost_overflow;
36075 + atomic_unchecked_t multiplex_counter;
36076 };
36077
36078 extern struct oprofile_stat_struct oprofile_stats;
36079 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
36080 index 2f0aa0f..90fab02 100644
36081 --- a/drivers/oprofile/oprofilefs.c
36082 +++ b/drivers/oprofile/oprofilefs.c
36083 @@ -193,7 +193,7 @@ static const struct file_operations atomic_ro_fops = {
36084
36085
36086 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
36087 - char const *name, atomic_t *val)
36088 + char const *name, atomic_unchecked_t *val)
36089 {
36090 return __oprofilefs_create_file(sb, root, name,
36091 &atomic_ro_fops, 0444, val);
36092 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
36093 index 3f56bc0..707d642 100644
36094 --- a/drivers/parport/procfs.c
36095 +++ b/drivers/parport/procfs.c
36096 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
36097
36098 *ppos += len;
36099
36100 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
36101 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
36102 }
36103
36104 #ifdef CONFIG_PARPORT_1284
36105 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
36106
36107 *ppos += len;
36108
36109 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
36110 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
36111 }
36112 #endif /* IEEE1284.3 support. */
36113
36114 diff --git a/drivers/pci/hotplug/cpci_hotplug.h b/drivers/pci/hotplug/cpci_hotplug.h
36115 index 9fff878..ad0ad53 100644
36116 --- a/drivers/pci/hotplug/cpci_hotplug.h
36117 +++ b/drivers/pci/hotplug/cpci_hotplug.h
36118 @@ -59,7 +59,7 @@ struct cpci_hp_controller_ops {
36119 int (*hardware_test) (struct slot* slot, u32 value);
36120 u8 (*get_power) (struct slot* slot);
36121 int (*set_power) (struct slot* slot, int value);
36122 -};
36123 +} __no_const;
36124
36125 struct cpci_hp_controller {
36126 unsigned int irq;
36127 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
36128 index 76ba8a1..20ca857 100644
36129 --- a/drivers/pci/hotplug/cpqphp_nvram.c
36130 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
36131 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
36132
36133 void compaq_nvram_init (void __iomem *rom_start)
36134 {
36135 +
36136 +#ifndef CONFIG_PAX_KERNEXEC
36137 if (rom_start) {
36138 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
36139 }
36140 +#endif
36141 +
36142 dbg("int15 entry = %p\n", compaq_int15_entry_point);
36143
36144 /* initialize our int15 lock */
36145 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
36146 index 2275162..95f1a92 100644
36147 --- a/drivers/pci/pcie/aspm.c
36148 +++ b/drivers/pci/pcie/aspm.c
36149 @@ -27,9 +27,9 @@
36150 #define MODULE_PARAM_PREFIX "pcie_aspm."
36151
36152 /* Note: those are not register definitions */
36153 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
36154 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
36155 -#define ASPM_STATE_L1 (4) /* L1 state */
36156 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
36157 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
36158 +#define ASPM_STATE_L1 (4U) /* L1 state */
36159 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
36160 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
36161
36162 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
36163 index 71eac9c..2de27ef 100644
36164 --- a/drivers/pci/probe.c
36165 +++ b/drivers/pci/probe.c
36166 @@ -136,7 +136,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
36167 u32 l, sz, mask;
36168 u16 orig_cmd;
36169
36170 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
36171 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
36172
36173 if (!dev->mmio_always_on) {
36174 pci_read_config_word(dev, PCI_COMMAND, &orig_cmd);
36175 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
36176 index 27911b5..5b6db88 100644
36177 --- a/drivers/pci/proc.c
36178 +++ b/drivers/pci/proc.c
36179 @@ -476,7 +476,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
36180 static int __init pci_proc_init(void)
36181 {
36182 struct pci_dev *dev = NULL;
36183 +
36184 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
36185 +#ifdef CONFIG_GRKERNSEC_PROC_USER
36186 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
36187 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
36188 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
36189 +#endif
36190 +#else
36191 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
36192 +#endif
36193 proc_create("devices", 0, proc_bus_pci_dir,
36194 &proc_bus_pci_dev_operations);
36195 proc_initialized = 1;
36196 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
36197 index ea0c607..58c4628 100644
36198 --- a/drivers/platform/x86/thinkpad_acpi.c
36199 +++ b/drivers/platform/x86/thinkpad_acpi.c
36200 @@ -2094,7 +2094,7 @@ static int hotkey_mask_get(void)
36201 return 0;
36202 }
36203
36204 -void static hotkey_mask_warn_incomplete_mask(void)
36205 +static void hotkey_mask_warn_incomplete_mask(void)
36206 {
36207 /* log only what the user can fix... */
36208 const u32 wantedmask = hotkey_driver_mask &
36209 @@ -2325,11 +2325,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
36210 }
36211 }
36212
36213 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
36214 - struct tp_nvram_state *newn,
36215 - const u32 event_mask)
36216 -{
36217 -
36218 #define TPACPI_COMPARE_KEY(__scancode, __member) \
36219 do { \
36220 if ((event_mask & (1 << __scancode)) && \
36221 @@ -2343,36 +2338,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
36222 tpacpi_hotkey_send_key(__scancode); \
36223 } while (0)
36224
36225 - void issue_volchange(const unsigned int oldvol,
36226 - const unsigned int newvol)
36227 - {
36228 - unsigned int i = oldvol;
36229 +static void issue_volchange(const unsigned int oldvol,
36230 + const unsigned int newvol,
36231 + const u32 event_mask)
36232 +{
36233 + unsigned int i = oldvol;
36234
36235 - while (i > newvol) {
36236 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
36237 - i--;
36238 - }
36239 - while (i < newvol) {
36240 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
36241 - i++;
36242 - }
36243 + while (i > newvol) {
36244 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
36245 + i--;
36246 }
36247 + while (i < newvol) {
36248 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
36249 + i++;
36250 + }
36251 +}
36252
36253 - void issue_brightnesschange(const unsigned int oldbrt,
36254 - const unsigned int newbrt)
36255 - {
36256 - unsigned int i = oldbrt;
36257 +static void issue_brightnesschange(const unsigned int oldbrt,
36258 + const unsigned int newbrt,
36259 + const u32 event_mask)
36260 +{
36261 + unsigned int i = oldbrt;
36262
36263 - while (i > newbrt) {
36264 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
36265 - i--;
36266 - }
36267 - while (i < newbrt) {
36268 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
36269 - i++;
36270 - }
36271 + while (i > newbrt) {
36272 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
36273 + i--;
36274 + }
36275 + while (i < newbrt) {
36276 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
36277 + i++;
36278 }
36279 +}
36280
36281 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
36282 + struct tp_nvram_state *newn,
36283 + const u32 event_mask)
36284 +{
36285 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
36286 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
36287 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
36288 @@ -2406,7 +2407,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
36289 oldn->volume_level != newn->volume_level) {
36290 /* recently muted, or repeated mute keypress, or
36291 * multiple presses ending in mute */
36292 - issue_volchange(oldn->volume_level, newn->volume_level);
36293 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
36294 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
36295 }
36296 } else {
36297 @@ -2416,7 +2417,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
36298 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
36299 }
36300 if (oldn->volume_level != newn->volume_level) {
36301 - issue_volchange(oldn->volume_level, newn->volume_level);
36302 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
36303 } else if (oldn->volume_toggle != newn->volume_toggle) {
36304 /* repeated vol up/down keypress at end of scale ? */
36305 if (newn->volume_level == 0)
36306 @@ -2429,7 +2430,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
36307 /* handle brightness */
36308 if (oldn->brightness_level != newn->brightness_level) {
36309 issue_brightnesschange(oldn->brightness_level,
36310 - newn->brightness_level);
36311 + newn->brightness_level,
36312 + event_mask);
36313 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
36314 /* repeated key presses that didn't change state */
36315 if (newn->brightness_level == 0)
36316 @@ -2438,10 +2440,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
36317 && !tp_features.bright_unkfw)
36318 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
36319 }
36320 +}
36321
36322 #undef TPACPI_COMPARE_KEY
36323 #undef TPACPI_MAY_SEND_KEY
36324 -}
36325
36326 /*
36327 * Polling driver
36328 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
36329 index b859d16..5cc6b1a 100644
36330 --- a/drivers/pnp/pnpbios/bioscalls.c
36331 +++ b/drivers/pnp/pnpbios/bioscalls.c
36332 @@ -59,7 +59,7 @@ do { \
36333 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
36334 } while(0)
36335
36336 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
36337 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
36338 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
36339
36340 /*
36341 @@ -96,7 +96,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
36342
36343 cpu = get_cpu();
36344 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
36345 +
36346 + pax_open_kernel();
36347 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
36348 + pax_close_kernel();
36349
36350 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
36351 spin_lock_irqsave(&pnp_bios_lock, flags);
36352 @@ -134,7 +137,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
36353 :"memory");
36354 spin_unlock_irqrestore(&pnp_bios_lock, flags);
36355
36356 + pax_open_kernel();
36357 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
36358 + pax_close_kernel();
36359 +
36360 put_cpu();
36361
36362 /* If we get here and this is set then the PnP BIOS faulted on us. */
36363 @@ -468,7 +474,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
36364 return status;
36365 }
36366
36367 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
36368 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
36369 {
36370 int i;
36371
36372 @@ -476,6 +482,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
36373 pnp_bios_callpoint.offset = header->fields.pm16offset;
36374 pnp_bios_callpoint.segment = PNP_CS16;
36375
36376 + pax_open_kernel();
36377 +
36378 for_each_possible_cpu(i) {
36379 struct desc_struct *gdt = get_cpu_gdt_table(i);
36380 if (!gdt)
36381 @@ -487,4 +495,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
36382 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
36383 (unsigned long)__va(header->fields.pm16dseg));
36384 }
36385 +
36386 + pax_close_kernel();
36387 }
36388 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
36389 index b0ecacb..7c9da2e 100644
36390 --- a/drivers/pnp/resource.c
36391 +++ b/drivers/pnp/resource.c
36392 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
36393 return 1;
36394
36395 /* check if the resource is valid */
36396 - if (*irq < 0 || *irq > 15)
36397 + if (*irq > 15)
36398 return 0;
36399
36400 /* check if the resource is reserved */
36401 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
36402 return 1;
36403
36404 /* check if the resource is valid */
36405 - if (*dma < 0 || *dma == 4 || *dma > 7)
36406 + if (*dma == 4 || *dma > 7)
36407 return 0;
36408
36409 /* check if the resource is reserved */
36410 diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c
36411 index 1ed6ea0..77c0bd2 100644
36412 --- a/drivers/power/bq27x00_battery.c
36413 +++ b/drivers/power/bq27x00_battery.c
36414 @@ -72,7 +72,7 @@
36415 struct bq27x00_device_info;
36416 struct bq27x00_access_methods {
36417 int (*read)(struct bq27x00_device_info *di, u8 reg, bool single);
36418 -};
36419 +} __no_const;
36420
36421 enum bq27x00_chip { BQ27000, BQ27500 };
36422
36423 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
36424 index a838e66..a9e1665 100644
36425 --- a/drivers/regulator/max8660.c
36426 +++ b/drivers/regulator/max8660.c
36427 @@ -383,8 +383,10 @@ static int __devinit max8660_probe(struct i2c_client *client,
36428 max8660->shadow_regs[MAX8660_OVER1] = 5;
36429 } else {
36430 /* Otherwise devices can be toggled via software */
36431 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
36432 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
36433 + pax_open_kernel();
36434 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
36435 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
36436 + pax_close_kernel();
36437 }
36438
36439 /*
36440 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
36441 index e8cfc99..072aee2 100644
36442 --- a/drivers/regulator/mc13892-regulator.c
36443 +++ b/drivers/regulator/mc13892-regulator.c
36444 @@ -574,10 +574,12 @@ static int __devinit mc13892_regulator_probe(struct platform_device *pdev)
36445 }
36446 mc13xxx_unlock(mc13892);
36447
36448 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
36449 + pax_open_kernel();
36450 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
36451 = mc13892_vcam_set_mode;
36452 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
36453 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
36454 = mc13892_vcam_get_mode;
36455 + pax_close_kernel();
36456
36457 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
36458 ARRAY_SIZE(mc13892_regulators));
36459 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
36460 index cace6d3..f623fda 100644
36461 --- a/drivers/rtc/rtc-dev.c
36462 +++ b/drivers/rtc/rtc-dev.c
36463 @@ -14,6 +14,7 @@
36464 #include <linux/module.h>
36465 #include <linux/rtc.h>
36466 #include <linux/sched.h>
36467 +#include <linux/grsecurity.h>
36468 #include "rtc-core.h"
36469
36470 static dev_t rtc_devt;
36471 @@ -345,6 +346,8 @@ static long rtc_dev_ioctl(struct file *file,
36472 if (copy_from_user(&tm, uarg, sizeof(tm)))
36473 return -EFAULT;
36474
36475 + gr_log_timechange();
36476 +
36477 return rtc_set_time(rtc, &tm);
36478
36479 case RTC_PIE_ON:
36480 diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
36481 index ffb5878..e6d785c 100644
36482 --- a/drivers/scsi/aacraid/aacraid.h
36483 +++ b/drivers/scsi/aacraid/aacraid.h
36484 @@ -492,7 +492,7 @@ struct adapter_ops
36485 int (*adapter_scsi)(struct fib * fib, struct scsi_cmnd * cmd);
36486 /* Administrative operations */
36487 int (*adapter_comm)(struct aac_dev * dev, int comm);
36488 -};
36489 +} __no_const;
36490
36491 /*
36492 * Define which interrupt handler needs to be installed
36493 diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
36494 index 705e13e..91c873c 100644
36495 --- a/drivers/scsi/aacraid/linit.c
36496 +++ b/drivers/scsi/aacraid/linit.c
36497 @@ -93,7 +93,7 @@ static DECLARE_PCI_DEVICE_TABLE(aac_pci_tbl) = {
36498 #elif defined(__devinitconst)
36499 static const struct pci_device_id aac_pci_tbl[] __devinitconst = {
36500 #else
36501 -static const struct pci_device_id aac_pci_tbl[] __devinitdata = {
36502 +static const struct pci_device_id aac_pci_tbl[] __devinitconst = {
36503 #endif
36504 { 0x1028, 0x0001, 0x1028, 0x0001, 0, 0, 0 }, /* PERC 2/Si (Iguana/PERC2Si) */
36505 { 0x1028, 0x0002, 0x1028, 0x0002, 0, 0, 1 }, /* PERC 3/Di (Opal/PERC3Di) */
36506 diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c
36507 index d5ff142..49c0ebb 100644
36508 --- a/drivers/scsi/aic94xx/aic94xx_init.c
36509 +++ b/drivers/scsi/aic94xx/aic94xx_init.c
36510 @@ -1012,7 +1012,7 @@ static struct sas_domain_function_template aic94xx_transport_functions = {
36511 .lldd_control_phy = asd_control_phy,
36512 };
36513
36514 -static const struct pci_device_id aic94xx_pci_table[] __devinitdata = {
36515 +static const struct pci_device_id aic94xx_pci_table[] __devinitconst = {
36516 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, 0x410),0, 0, 1},
36517 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, 0x412),0, 0, 1},
36518 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, 0x416),0, 0, 1},
36519 diff --git a/drivers/scsi/bfa/bfa.h b/drivers/scsi/bfa/bfa.h
36520 index a796de9..1ef20e1 100644
36521 --- a/drivers/scsi/bfa/bfa.h
36522 +++ b/drivers/scsi/bfa/bfa.h
36523 @@ -196,7 +196,7 @@ struct bfa_hwif_s {
36524 u32 *end);
36525 int cpe_vec_q0;
36526 int rme_vec_q0;
36527 -};
36528 +} __no_const;
36529 typedef void (*bfa_cb_iocfc_t) (void *cbarg, enum bfa_status status);
36530
36531 struct bfa_faa_cbfn_s {
36532 diff --git a/drivers/scsi/bfa/bfa_fcpim.c b/drivers/scsi/bfa/bfa_fcpim.c
36533 index f0f80e2..8ec946b 100644
36534 --- a/drivers/scsi/bfa/bfa_fcpim.c
36535 +++ b/drivers/scsi/bfa/bfa_fcpim.c
36536 @@ -3715,7 +3715,7 @@ bfa_fcp_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
36537
36538 bfa_iotag_attach(fcp);
36539
36540 - fcp->itn_arr = (struct bfa_itn_s *) bfa_mem_kva_curp(fcp);
36541 + fcp->itn_arr = (bfa_itn_s_no_const *) bfa_mem_kva_curp(fcp);
36542 bfa_mem_kva_curp(fcp) = (u8 *)fcp->itn_arr +
36543 (fcp->num_itns * sizeof(struct bfa_itn_s));
36544 memset(fcp->itn_arr, 0,
36545 @@ -3773,7 +3773,7 @@ bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
36546 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m))
36547 {
36548 struct bfa_fcp_mod_s *fcp = BFA_FCP_MOD(bfa);
36549 - struct bfa_itn_s *itn;
36550 + bfa_itn_s_no_const *itn;
36551
36552 itn = BFA_ITN_FROM_TAG(fcp, rport->rport_tag);
36553 itn->isr = isr;
36554 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
36555 index 36f26da..38a34a8 100644
36556 --- a/drivers/scsi/bfa/bfa_fcpim.h
36557 +++ b/drivers/scsi/bfa/bfa_fcpim.h
36558 @@ -37,6 +37,7 @@ struct bfa_iotag_s {
36559 struct bfa_itn_s {
36560 bfa_isr_func_t isr;
36561 };
36562 +typedef struct bfa_itn_s __no_const bfa_itn_s_no_const;
36563
36564 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
36565 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
36566 @@ -147,7 +148,7 @@ struct bfa_fcp_mod_s {
36567 struct list_head iotag_tio_free_q; /* free IO resources */
36568 struct list_head iotag_unused_q; /* unused IO resources*/
36569 struct bfa_iotag_s *iotag_arr;
36570 - struct bfa_itn_s *itn_arr;
36571 + bfa_itn_s_no_const *itn_arr;
36572 int num_ioim_reqs;
36573 int num_fwtio_reqs;
36574 int num_itns;
36575 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
36576 index 546d46b..642fa5b 100644
36577 --- a/drivers/scsi/bfa/bfa_ioc.h
36578 +++ b/drivers/scsi/bfa/bfa_ioc.h
36579 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
36580 bfa_ioc_disable_cbfn_t disable_cbfn;
36581 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
36582 bfa_ioc_reset_cbfn_t reset_cbfn;
36583 -};
36584 +} __no_const;
36585
36586 /*
36587 * IOC event notification mechanism.
36588 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
36589 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
36590 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
36591 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
36592 -};
36593 +} __no_const;
36594
36595 /*
36596 * Queue element to wait for room in request queue. FIFO order is
36597 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
36598 index 351dc0b..951dc32 100644
36599 --- a/drivers/scsi/hosts.c
36600 +++ b/drivers/scsi/hosts.c
36601 @@ -42,7 +42,7 @@
36602 #include "scsi_logging.h"
36603
36604
36605 -static atomic_t scsi_host_next_hn; /* host_no for next new host */
36606 +static atomic_unchecked_t scsi_host_next_hn; /* host_no for next new host */
36607
36608
36609 static void scsi_host_cls_release(struct device *dev)
36610 @@ -357,7 +357,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
36611 * subtract one because we increment first then return, but we need to
36612 * know what the next host number was before increment
36613 */
36614 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
36615 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
36616 shost->dma_channel = 0xff;
36617
36618 /* These three are default values which can be overridden */
36619 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
36620 index b96962c..0c82ec2 100644
36621 --- a/drivers/scsi/hpsa.c
36622 +++ b/drivers/scsi/hpsa.c
36623 @@ -507,7 +507,7 @@ static inline u32 next_command(struct ctlr_info *h)
36624 u32 a;
36625
36626 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
36627 - return h->access.command_completed(h);
36628 + return h->access->command_completed(h);
36629
36630 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
36631 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
36632 @@ -2991,7 +2991,7 @@ static void start_io(struct ctlr_info *h)
36633 while (!list_empty(&h->reqQ)) {
36634 c = list_entry(h->reqQ.next, struct CommandList, list);
36635 /* can't do anything if fifo is full */
36636 - if ((h->access.fifo_full(h))) {
36637 + if ((h->access->fifo_full(h))) {
36638 dev_warn(&h->pdev->dev, "fifo full\n");
36639 break;
36640 }
36641 @@ -3001,7 +3001,7 @@ static void start_io(struct ctlr_info *h)
36642 h->Qdepth--;
36643
36644 /* Tell the controller execute command */
36645 - h->access.submit_command(h, c);
36646 + h->access->submit_command(h, c);
36647
36648 /* Put job onto the completed Q */
36649 addQ(&h->cmpQ, c);
36650 @@ -3010,17 +3010,17 @@ static void start_io(struct ctlr_info *h)
36651
36652 static inline unsigned long get_next_completion(struct ctlr_info *h)
36653 {
36654 - return h->access.command_completed(h);
36655 + return h->access->command_completed(h);
36656 }
36657
36658 static inline bool interrupt_pending(struct ctlr_info *h)
36659 {
36660 - return h->access.intr_pending(h);
36661 + return h->access->intr_pending(h);
36662 }
36663
36664 static inline long interrupt_not_for_us(struct ctlr_info *h)
36665 {
36666 - return (h->access.intr_pending(h) == 0) ||
36667 + return (h->access->intr_pending(h) == 0) ||
36668 (h->interrupts_enabled == 0);
36669 }
36670
36671 @@ -3919,7 +3919,7 @@ static int __devinit hpsa_pci_init(struct ctlr_info *h)
36672 if (prod_index < 0)
36673 return -ENODEV;
36674 h->product_name = products[prod_index].product_name;
36675 - h->access = *(products[prod_index].access);
36676 + h->access = products[prod_index].access;
36677
36678 if (hpsa_board_disabled(h->pdev)) {
36679 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
36680 @@ -4164,7 +4164,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
36681
36682 assert_spin_locked(&lockup_detector_lock);
36683 remove_ctlr_from_lockup_detector_list(h);
36684 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
36685 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
36686 spin_lock_irqsave(&h->lock, flags);
36687 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
36688 spin_unlock_irqrestore(&h->lock, flags);
36689 @@ -4344,7 +4344,7 @@ reinit_after_soft_reset:
36690 }
36691
36692 /* make sure the board interrupts are off */
36693 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
36694 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
36695
36696 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
36697 goto clean2;
36698 @@ -4378,7 +4378,7 @@ reinit_after_soft_reset:
36699 * fake ones to scoop up any residual completions.
36700 */
36701 spin_lock_irqsave(&h->lock, flags);
36702 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
36703 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
36704 spin_unlock_irqrestore(&h->lock, flags);
36705 free_irq(h->intr[h->intr_mode], h);
36706 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
36707 @@ -4397,9 +4397,9 @@ reinit_after_soft_reset:
36708 dev_info(&h->pdev->dev, "Board READY.\n");
36709 dev_info(&h->pdev->dev,
36710 "Waiting for stale completions to drain.\n");
36711 - h->access.set_intr_mask(h, HPSA_INTR_ON);
36712 + h->access->set_intr_mask(h, HPSA_INTR_ON);
36713 msleep(10000);
36714 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
36715 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
36716
36717 rc = controller_reset_failed(h->cfgtable);
36718 if (rc)
36719 @@ -4420,7 +4420,7 @@ reinit_after_soft_reset:
36720 }
36721
36722 /* Turn the interrupts on so we can service requests */
36723 - h->access.set_intr_mask(h, HPSA_INTR_ON);
36724 + h->access->set_intr_mask(h, HPSA_INTR_ON);
36725
36726 hpsa_hba_inquiry(h);
36727 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
36728 @@ -4472,7 +4472,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
36729 * To write all data in the battery backed cache to disks
36730 */
36731 hpsa_flush_cache(h);
36732 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
36733 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
36734 free_irq(h->intr[h->intr_mode], h);
36735 #ifdef CONFIG_PCI_MSI
36736 if (h->msix_vector)
36737 @@ -4636,7 +4636,7 @@ static __devinit void hpsa_enter_performant_mode(struct ctlr_info *h,
36738 return;
36739 }
36740 /* Change the access methods to the performant access methods */
36741 - h->access = SA5_performant_access;
36742 + h->access = &SA5_performant_access;
36743 h->transMethod = CFGTBL_Trans_Performant;
36744 }
36745
36746 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
36747 index 91edafb..a9b88ec 100644
36748 --- a/drivers/scsi/hpsa.h
36749 +++ b/drivers/scsi/hpsa.h
36750 @@ -73,7 +73,7 @@ struct ctlr_info {
36751 unsigned int msix_vector;
36752 unsigned int msi_vector;
36753 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
36754 - struct access_method access;
36755 + struct access_method *access;
36756
36757 /* queue and queue Info */
36758 struct list_head reqQ;
36759 diff --git a/drivers/scsi/ips.h b/drivers/scsi/ips.h
36760 index f2df059..a3a9930 100644
36761 --- a/drivers/scsi/ips.h
36762 +++ b/drivers/scsi/ips.h
36763 @@ -1027,7 +1027,7 @@ typedef struct {
36764 int (*intr)(struct ips_ha *);
36765 void (*enableint)(struct ips_ha *);
36766 uint32_t (*statupd)(struct ips_ha *);
36767 -} ips_hw_func_t;
36768 +} __no_const ips_hw_func_t;
36769
36770 typedef struct ips_ha {
36771 uint8_t ha_id[IPS_MAX_CHANNELS+1];
36772 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
36773 index 4d70d96..84d0573 100644
36774 --- a/drivers/scsi/libfc/fc_exch.c
36775 +++ b/drivers/scsi/libfc/fc_exch.c
36776 @@ -105,12 +105,12 @@ struct fc_exch_mgr {
36777 * all together if not used XXX
36778 */
36779 struct {
36780 - atomic_t no_free_exch;
36781 - atomic_t no_free_exch_xid;
36782 - atomic_t xid_not_found;
36783 - atomic_t xid_busy;
36784 - atomic_t seq_not_found;
36785 - atomic_t non_bls_resp;
36786 + atomic_unchecked_t no_free_exch;
36787 + atomic_unchecked_t no_free_exch_xid;
36788 + atomic_unchecked_t xid_not_found;
36789 + atomic_unchecked_t xid_busy;
36790 + atomic_unchecked_t seq_not_found;
36791 + atomic_unchecked_t non_bls_resp;
36792 } stats;
36793 };
36794
36795 @@ -719,7 +719,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
36796 /* allocate memory for exchange */
36797 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
36798 if (!ep) {
36799 - atomic_inc(&mp->stats.no_free_exch);
36800 + atomic_inc_unchecked(&mp->stats.no_free_exch);
36801 goto out;
36802 }
36803 memset(ep, 0, sizeof(*ep));
36804 @@ -780,7 +780,7 @@ out:
36805 return ep;
36806 err:
36807 spin_unlock_bh(&pool->lock);
36808 - atomic_inc(&mp->stats.no_free_exch_xid);
36809 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
36810 mempool_free(ep, mp->ep_pool);
36811 return NULL;
36812 }
36813 @@ -923,7 +923,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
36814 xid = ntohs(fh->fh_ox_id); /* we originated exch */
36815 ep = fc_exch_find(mp, xid);
36816 if (!ep) {
36817 - atomic_inc(&mp->stats.xid_not_found);
36818 + atomic_inc_unchecked(&mp->stats.xid_not_found);
36819 reject = FC_RJT_OX_ID;
36820 goto out;
36821 }
36822 @@ -953,7 +953,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
36823 ep = fc_exch_find(mp, xid);
36824 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
36825 if (ep) {
36826 - atomic_inc(&mp->stats.xid_busy);
36827 + atomic_inc_unchecked(&mp->stats.xid_busy);
36828 reject = FC_RJT_RX_ID;
36829 goto rel;
36830 }
36831 @@ -964,7 +964,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
36832 }
36833 xid = ep->xid; /* get our XID */
36834 } else if (!ep) {
36835 - atomic_inc(&mp->stats.xid_not_found);
36836 + atomic_inc_unchecked(&mp->stats.xid_not_found);
36837 reject = FC_RJT_RX_ID; /* XID not found */
36838 goto out;
36839 }
36840 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
36841 } else {
36842 sp = &ep->seq;
36843 if (sp->id != fh->fh_seq_id) {
36844 - atomic_inc(&mp->stats.seq_not_found);
36845 + atomic_inc_unchecked(&mp->stats.seq_not_found);
36846 if (f_ctl & FC_FC_END_SEQ) {
36847 /*
36848 * Update sequence_id based on incoming last
36849 @@ -1431,22 +1431,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
36850
36851 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
36852 if (!ep) {
36853 - atomic_inc(&mp->stats.xid_not_found);
36854 + atomic_inc_unchecked(&mp->stats.xid_not_found);
36855 goto out;
36856 }
36857 if (ep->esb_stat & ESB_ST_COMPLETE) {
36858 - atomic_inc(&mp->stats.xid_not_found);
36859 + atomic_inc_unchecked(&mp->stats.xid_not_found);
36860 goto rel;
36861 }
36862 if (ep->rxid == FC_XID_UNKNOWN)
36863 ep->rxid = ntohs(fh->fh_rx_id);
36864 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
36865 - atomic_inc(&mp->stats.xid_not_found);
36866 + atomic_inc_unchecked(&mp->stats.xid_not_found);
36867 goto rel;
36868 }
36869 if (ep->did != ntoh24(fh->fh_s_id) &&
36870 ep->did != FC_FID_FLOGI) {
36871 - atomic_inc(&mp->stats.xid_not_found);
36872 + atomic_inc_unchecked(&mp->stats.xid_not_found);
36873 goto rel;
36874 }
36875 sof = fr_sof(fp);
36876 @@ -1455,7 +1455,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
36877 sp->ssb_stat |= SSB_ST_RESP;
36878 sp->id = fh->fh_seq_id;
36879 } else if (sp->id != fh->fh_seq_id) {
36880 - atomic_inc(&mp->stats.seq_not_found);
36881 + atomic_inc_unchecked(&mp->stats.seq_not_found);
36882 goto rel;
36883 }
36884
36885 @@ -1519,9 +1519,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
36886 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
36887
36888 if (!sp)
36889 - atomic_inc(&mp->stats.xid_not_found);
36890 + atomic_inc_unchecked(&mp->stats.xid_not_found);
36891 else
36892 - atomic_inc(&mp->stats.non_bls_resp);
36893 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
36894
36895 fc_frame_free(fp);
36896 }
36897 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
36898 index db9238f..4378ed2 100644
36899 --- a/drivers/scsi/libsas/sas_ata.c
36900 +++ b/drivers/scsi/libsas/sas_ata.c
36901 @@ -368,7 +368,7 @@ static struct ata_port_operations sas_sata_ops = {
36902 .postreset = ata_std_postreset,
36903 .error_handler = ata_std_error_handler,
36904 .post_internal_cmd = sas_ata_post_internal,
36905 - .qc_defer = ata_std_qc_defer,
36906 + .qc_defer = ata_std_qc_defer,
36907 .qc_prep = ata_noop_qc_prep,
36908 .qc_issue = sas_ata_qc_issue,
36909 .qc_fill_rtf = sas_ata_qc_fill_rtf,
36910 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
36911 index 825f930..ce42672 100644
36912 --- a/drivers/scsi/lpfc/lpfc.h
36913 +++ b/drivers/scsi/lpfc/lpfc.h
36914 @@ -413,7 +413,7 @@ struct lpfc_vport {
36915 struct dentry *debug_nodelist;
36916 struct dentry *vport_debugfs_root;
36917 struct lpfc_debugfs_trc *disc_trc;
36918 - atomic_t disc_trc_cnt;
36919 + atomic_unchecked_t disc_trc_cnt;
36920 #endif
36921 uint8_t stat_data_enabled;
36922 uint8_t stat_data_blocked;
36923 @@ -821,8 +821,8 @@ struct lpfc_hba {
36924 struct timer_list fabric_block_timer;
36925 unsigned long bit_flags;
36926 #define FABRIC_COMANDS_BLOCKED 0
36927 - atomic_t num_rsrc_err;
36928 - atomic_t num_cmd_success;
36929 + atomic_unchecked_t num_rsrc_err;
36930 + atomic_unchecked_t num_cmd_success;
36931 unsigned long last_rsrc_error_time;
36932 unsigned long last_ramp_down_time;
36933 unsigned long last_ramp_up_time;
36934 @@ -852,7 +852,7 @@ struct lpfc_hba {
36935
36936 struct dentry *debug_slow_ring_trc;
36937 struct lpfc_debugfs_trc *slow_ring_trc;
36938 - atomic_t slow_ring_trc_cnt;
36939 + atomic_unchecked_t slow_ring_trc_cnt;
36940 /* iDiag debugfs sub-directory */
36941 struct dentry *idiag_root;
36942 struct dentry *idiag_pci_cfg;
36943 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
36944 index 3587a3f..d45b81b 100644
36945 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
36946 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
36947 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
36948
36949 #include <linux/debugfs.h>
36950
36951 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
36952 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
36953 static unsigned long lpfc_debugfs_start_time = 0L;
36954
36955 /* iDiag */
36956 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
36957 lpfc_debugfs_enable = 0;
36958
36959 len = 0;
36960 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
36961 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
36962 (lpfc_debugfs_max_disc_trc - 1);
36963 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
36964 dtp = vport->disc_trc + i;
36965 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
36966 lpfc_debugfs_enable = 0;
36967
36968 len = 0;
36969 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
36970 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
36971 (lpfc_debugfs_max_slow_ring_trc - 1);
36972 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
36973 dtp = phba->slow_ring_trc + i;
36974 @@ -636,14 +636,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
36975 !vport || !vport->disc_trc)
36976 return;
36977
36978 - index = atomic_inc_return(&vport->disc_trc_cnt) &
36979 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
36980 (lpfc_debugfs_max_disc_trc - 1);
36981 dtp = vport->disc_trc + index;
36982 dtp->fmt = fmt;
36983 dtp->data1 = data1;
36984 dtp->data2 = data2;
36985 dtp->data3 = data3;
36986 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
36987 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
36988 dtp->jif = jiffies;
36989 #endif
36990 return;
36991 @@ -674,14 +674,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
36992 !phba || !phba->slow_ring_trc)
36993 return;
36994
36995 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
36996 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
36997 (lpfc_debugfs_max_slow_ring_trc - 1);
36998 dtp = phba->slow_ring_trc + index;
36999 dtp->fmt = fmt;
37000 dtp->data1 = data1;
37001 dtp->data2 = data2;
37002 dtp->data3 = data3;
37003 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
37004 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
37005 dtp->jif = jiffies;
37006 #endif
37007 return;
37008 @@ -4040,7 +4040,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
37009 "slow_ring buffer\n");
37010 goto debug_failed;
37011 }
37012 - atomic_set(&phba->slow_ring_trc_cnt, 0);
37013 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
37014 memset(phba->slow_ring_trc, 0,
37015 (sizeof(struct lpfc_debugfs_trc) *
37016 lpfc_debugfs_max_slow_ring_trc));
37017 @@ -4086,7 +4086,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
37018 "buffer\n");
37019 goto debug_failed;
37020 }
37021 - atomic_set(&vport->disc_trc_cnt, 0);
37022 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
37023
37024 snprintf(name, sizeof(name), "discovery_trace");
37025 vport->debug_disc_trc =
37026 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
37027 index dfea2da..8e17227 100644
37028 --- a/drivers/scsi/lpfc/lpfc_init.c
37029 +++ b/drivers/scsi/lpfc/lpfc_init.c
37030 @@ -10145,8 +10145,10 @@ lpfc_init(void)
37031 printk(LPFC_COPYRIGHT "\n");
37032
37033 if (lpfc_enable_npiv) {
37034 - lpfc_transport_functions.vport_create = lpfc_vport_create;
37035 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
37036 + pax_open_kernel();
37037 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
37038 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
37039 + pax_close_kernel();
37040 }
37041 lpfc_transport_template =
37042 fc_attach_transport(&lpfc_transport_functions);
37043 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
37044 index c60f5d0..751535c 100644
37045 --- a/drivers/scsi/lpfc/lpfc_scsi.c
37046 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
37047 @@ -305,7 +305,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
37048 uint32_t evt_posted;
37049
37050 spin_lock_irqsave(&phba->hbalock, flags);
37051 - atomic_inc(&phba->num_rsrc_err);
37052 + atomic_inc_unchecked(&phba->num_rsrc_err);
37053 phba->last_rsrc_error_time = jiffies;
37054
37055 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
37056 @@ -346,7 +346,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
37057 unsigned long flags;
37058 struct lpfc_hba *phba = vport->phba;
37059 uint32_t evt_posted;
37060 - atomic_inc(&phba->num_cmd_success);
37061 + atomic_inc_unchecked(&phba->num_cmd_success);
37062
37063 if (vport->cfg_lun_queue_depth <= queue_depth)
37064 return;
37065 @@ -390,8 +390,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
37066 unsigned long num_rsrc_err, num_cmd_success;
37067 int i;
37068
37069 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
37070 - num_cmd_success = atomic_read(&phba->num_cmd_success);
37071 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
37072 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
37073
37074 vports = lpfc_create_vport_work_array(phba);
37075 if (vports != NULL)
37076 @@ -411,8 +411,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
37077 }
37078 }
37079 lpfc_destroy_vport_work_array(phba, vports);
37080 - atomic_set(&phba->num_rsrc_err, 0);
37081 - atomic_set(&phba->num_cmd_success, 0);
37082 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
37083 + atomic_set_unchecked(&phba->num_cmd_success, 0);
37084 }
37085
37086 /**
37087 @@ -446,8 +446,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
37088 }
37089 }
37090 lpfc_destroy_vport_work_array(phba, vports);
37091 - atomic_set(&phba->num_rsrc_err, 0);
37092 - atomic_set(&phba->num_cmd_success, 0);
37093 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
37094 + atomic_set_unchecked(&phba->num_cmd_success, 0);
37095 }
37096
37097 /**
37098 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
37099 index ea8a0b4..812a124 100644
37100 --- a/drivers/scsi/pmcraid.c
37101 +++ b/drivers/scsi/pmcraid.c
37102 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
37103 res->scsi_dev = scsi_dev;
37104 scsi_dev->hostdata = res;
37105 res->change_detected = 0;
37106 - atomic_set(&res->read_failures, 0);
37107 - atomic_set(&res->write_failures, 0);
37108 + atomic_set_unchecked(&res->read_failures, 0);
37109 + atomic_set_unchecked(&res->write_failures, 0);
37110 rc = 0;
37111 }
37112 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
37113 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
37114
37115 /* If this was a SCSI read/write command keep count of errors */
37116 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
37117 - atomic_inc(&res->read_failures);
37118 + atomic_inc_unchecked(&res->read_failures);
37119 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
37120 - atomic_inc(&res->write_failures);
37121 + atomic_inc_unchecked(&res->write_failures);
37122
37123 if (!RES_IS_GSCSI(res->cfg_entry) &&
37124 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
37125 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
37126 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
37127 * hrrq_id assigned here in queuecommand
37128 */
37129 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
37130 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
37131 pinstance->num_hrrq;
37132 cmd->cmd_done = pmcraid_io_done;
37133
37134 @@ -3859,7 +3859,7 @@ static long pmcraid_ioctl_passthrough(
37135 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
37136 * hrrq_id assigned here in queuecommand
37137 */
37138 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
37139 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
37140 pinstance->num_hrrq;
37141
37142 if (request_size) {
37143 @@ -4497,7 +4497,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
37144
37145 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
37146 /* add resources only after host is added into system */
37147 - if (!atomic_read(&pinstance->expose_resources))
37148 + if (!atomic_read_unchecked(&pinstance->expose_resources))
37149 return;
37150
37151 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
37152 @@ -5331,8 +5331,8 @@ static int __devinit pmcraid_init_instance(
37153 init_waitqueue_head(&pinstance->reset_wait_q);
37154
37155 atomic_set(&pinstance->outstanding_cmds, 0);
37156 - atomic_set(&pinstance->last_message_id, 0);
37157 - atomic_set(&pinstance->expose_resources, 0);
37158 + atomic_set_unchecked(&pinstance->last_message_id, 0);
37159 + atomic_set_unchecked(&pinstance->expose_resources, 0);
37160
37161 INIT_LIST_HEAD(&pinstance->free_res_q);
37162 INIT_LIST_HEAD(&pinstance->used_res_q);
37163 @@ -6047,7 +6047,7 @@ static int __devinit pmcraid_probe(
37164 /* Schedule worker thread to handle CCN and take care of adding and
37165 * removing devices to OS
37166 */
37167 - atomic_set(&pinstance->expose_resources, 1);
37168 + atomic_set_unchecked(&pinstance->expose_resources, 1);
37169 schedule_work(&pinstance->worker_q);
37170 return rc;
37171
37172 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
37173 index ca496c7..9c791d5 100644
37174 --- a/drivers/scsi/pmcraid.h
37175 +++ b/drivers/scsi/pmcraid.h
37176 @@ -748,7 +748,7 @@ struct pmcraid_instance {
37177 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
37178
37179 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
37180 - atomic_t last_message_id;
37181 + atomic_unchecked_t last_message_id;
37182
37183 /* configuration table */
37184 struct pmcraid_config_table *cfg_table;
37185 @@ -777,7 +777,7 @@ struct pmcraid_instance {
37186 atomic_t outstanding_cmds;
37187
37188 /* should add/delete resources to mid-layer now ?*/
37189 - atomic_t expose_resources;
37190 + atomic_unchecked_t expose_resources;
37191
37192
37193
37194 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
37195 struct pmcraid_config_table_entry_ext cfg_entry_ext;
37196 };
37197 struct scsi_device *scsi_dev; /* Link scsi_device structure */
37198 - atomic_t read_failures; /* count of failed READ commands */
37199 - atomic_t write_failures; /* count of failed WRITE commands */
37200 + atomic_unchecked_t read_failures; /* count of failed READ commands */
37201 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
37202
37203 /* To indicate add/delete/modify during CCN */
37204 u8 change_detected;
37205 diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
37206 index af1003f..be55a75 100644
37207 --- a/drivers/scsi/qla2xxx/qla_def.h
37208 +++ b/drivers/scsi/qla2xxx/qla_def.h
37209 @@ -2247,7 +2247,7 @@ struct isp_operations {
37210 int (*start_scsi) (srb_t *);
37211 int (*abort_isp) (struct scsi_qla_host *);
37212 int (*iospace_config)(struct qla_hw_data*);
37213 -};
37214 +} __no_const;
37215
37216 /* MSI-X Support *************************************************************/
37217
37218 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
37219 index bfe6854..ceac088 100644
37220 --- a/drivers/scsi/qla4xxx/ql4_def.h
37221 +++ b/drivers/scsi/qla4xxx/ql4_def.h
37222 @@ -261,7 +261,7 @@ struct ddb_entry {
37223 * (4000 only) */
37224 atomic_t relogin_timer; /* Max Time to wait for
37225 * relogin to complete */
37226 - atomic_t relogin_retry_count; /* Num of times relogin has been
37227 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
37228 * retried */
37229 uint32_t default_time2wait; /* Default Min time between
37230 * relogins (+aens) */
37231 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
37232 index ce6d3b7..73fac54 100644
37233 --- a/drivers/scsi/qla4xxx/ql4_os.c
37234 +++ b/drivers/scsi/qla4xxx/ql4_os.c
37235 @@ -2178,12 +2178,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
37236 */
37237 if (!iscsi_is_session_online(cls_sess)) {
37238 /* Reset retry relogin timer */
37239 - atomic_inc(&ddb_entry->relogin_retry_count);
37240 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
37241 DEBUG2(ql4_printk(KERN_INFO, ha,
37242 "%s: index[%d] relogin timed out-retrying"
37243 " relogin (%d), retry (%d)\n", __func__,
37244 ddb_entry->fw_ddb_index,
37245 - atomic_read(&ddb_entry->relogin_retry_count),
37246 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
37247 ddb_entry->default_time2wait + 4));
37248 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
37249 atomic_set(&ddb_entry->retry_relogin_timer,
37250 @@ -3953,7 +3953,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
37251
37252 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
37253 atomic_set(&ddb_entry->relogin_timer, 0);
37254 - atomic_set(&ddb_entry->relogin_retry_count, 0);
37255 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
37256 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
37257 ddb_entry->default_relogin_timeout =
37258 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
37259 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
37260 index 2aeb2e9..46e3925 100644
37261 --- a/drivers/scsi/scsi.c
37262 +++ b/drivers/scsi/scsi.c
37263 @@ -655,7 +655,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
37264 unsigned long timeout;
37265 int rtn = 0;
37266
37267 - atomic_inc(&cmd->device->iorequest_cnt);
37268 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
37269
37270 /* check if the device is still usable */
37271 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
37272 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
37273 index b2c95db..227d74e 100644
37274 --- a/drivers/scsi/scsi_lib.c
37275 +++ b/drivers/scsi/scsi_lib.c
37276 @@ -1411,7 +1411,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
37277 shost = sdev->host;
37278 scsi_init_cmd_errh(cmd);
37279 cmd->result = DID_NO_CONNECT << 16;
37280 - atomic_inc(&cmd->device->iorequest_cnt);
37281 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
37282
37283 /*
37284 * SCSI request completion path will do scsi_device_unbusy(),
37285 @@ -1437,9 +1437,9 @@ static void scsi_softirq_done(struct request *rq)
37286
37287 INIT_LIST_HEAD(&cmd->eh_entry);
37288
37289 - atomic_inc(&cmd->device->iodone_cnt);
37290 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
37291 if (cmd->result)
37292 - atomic_inc(&cmd->device->ioerr_cnt);
37293 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
37294
37295 disposition = scsi_decide_disposition(cmd);
37296 if (disposition != SUCCESS &&
37297 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
37298 index 04c2a27..9d8bd66 100644
37299 --- a/drivers/scsi/scsi_sysfs.c
37300 +++ b/drivers/scsi/scsi_sysfs.c
37301 @@ -660,7 +660,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
37302 char *buf) \
37303 { \
37304 struct scsi_device *sdev = to_scsi_device(dev); \
37305 - unsigned long long count = atomic_read(&sdev->field); \
37306 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
37307 return snprintf(buf, 20, "0x%llx\n", count); \
37308 } \
37309 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
37310 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
37311 index 84a1fdf..693b0d6 100644
37312 --- a/drivers/scsi/scsi_tgt_lib.c
37313 +++ b/drivers/scsi/scsi_tgt_lib.c
37314 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
37315 int err;
37316
37317 dprintk("%lx %u\n", uaddr, len);
37318 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
37319 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
37320 if (err) {
37321 /*
37322 * TODO: need to fixup sg_tablesize, max_segment_size,
37323 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
37324 index f59d4a0..1d89407 100644
37325 --- a/drivers/scsi/scsi_transport_fc.c
37326 +++ b/drivers/scsi/scsi_transport_fc.c
37327 @@ -484,7 +484,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
37328 * Netlink Infrastructure
37329 */
37330
37331 -static atomic_t fc_event_seq;
37332 +static atomic_unchecked_t fc_event_seq;
37333
37334 /**
37335 * fc_get_event_number - Obtain the next sequential FC event number
37336 @@ -497,7 +497,7 @@ static atomic_t fc_event_seq;
37337 u32
37338 fc_get_event_number(void)
37339 {
37340 - return atomic_add_return(1, &fc_event_seq);
37341 + return atomic_add_return_unchecked(1, &fc_event_seq);
37342 }
37343 EXPORT_SYMBOL(fc_get_event_number);
37344
37345 @@ -645,7 +645,7 @@ static __init int fc_transport_init(void)
37346 {
37347 int error;
37348
37349 - atomic_set(&fc_event_seq, 0);
37350 + atomic_set_unchecked(&fc_event_seq, 0);
37351
37352 error = transport_class_register(&fc_host_class);
37353 if (error)
37354 @@ -835,7 +835,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
37355 char *cp;
37356
37357 *val = simple_strtoul(buf, &cp, 0);
37358 - if ((*cp && (*cp != '\n')) || (*val < 0))
37359 + if (*cp && (*cp != '\n'))
37360 return -EINVAL;
37361 /*
37362 * Check for overflow; dev_loss_tmo is u32
37363 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
37364 index e3e3c7d..ebdab62 100644
37365 --- a/drivers/scsi/scsi_transport_iscsi.c
37366 +++ b/drivers/scsi/scsi_transport_iscsi.c
37367 @@ -79,7 +79,7 @@ struct iscsi_internal {
37368 struct transport_container session_cont;
37369 };
37370
37371 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
37372 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
37373 static struct workqueue_struct *iscsi_eh_timer_workq;
37374
37375 static DEFINE_IDA(iscsi_sess_ida);
37376 @@ -1063,7 +1063,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
37377 int err;
37378
37379 ihost = shost->shost_data;
37380 - session->sid = atomic_add_return(1, &iscsi_session_nr);
37381 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
37382
37383 if (target_id == ISCSI_MAX_TARGET) {
37384 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
37385 @@ -2680,7 +2680,7 @@ static __init int iscsi_transport_init(void)
37386 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
37387 ISCSI_TRANSPORT_VERSION);
37388
37389 - atomic_set(&iscsi_session_nr, 0);
37390 + atomic_set_unchecked(&iscsi_session_nr, 0);
37391
37392 err = class_register(&iscsi_transport_class);
37393 if (err)
37394 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
37395 index 21a045e..ec89e03 100644
37396 --- a/drivers/scsi/scsi_transport_srp.c
37397 +++ b/drivers/scsi/scsi_transport_srp.c
37398 @@ -33,7 +33,7 @@
37399 #include "scsi_transport_srp_internal.h"
37400
37401 struct srp_host_attrs {
37402 - atomic_t next_port_id;
37403 + atomic_unchecked_t next_port_id;
37404 };
37405 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
37406
37407 @@ -62,7 +62,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
37408 struct Scsi_Host *shost = dev_to_shost(dev);
37409 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
37410
37411 - atomic_set(&srp_host->next_port_id, 0);
37412 + atomic_set_unchecked(&srp_host->next_port_id, 0);
37413 return 0;
37414 }
37415
37416 @@ -211,7 +211,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
37417 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
37418 rport->roles = ids->roles;
37419
37420 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
37421 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
37422 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
37423
37424 transport_setup_device(&rport->dev);
37425 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
37426 index eacd46b..e3f4d62 100644
37427 --- a/drivers/scsi/sg.c
37428 +++ b/drivers/scsi/sg.c
37429 @@ -1077,7 +1077,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
37430 sdp->disk->disk_name,
37431 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
37432 NULL,
37433 - (char *)arg);
37434 + (char __user *)arg);
37435 case BLKTRACESTART:
37436 return blk_trace_startstop(sdp->device->request_queue, 1);
37437 case BLKTRACESTOP:
37438 @@ -2312,7 +2312,7 @@ struct sg_proc_leaf {
37439 const struct file_operations * fops;
37440 };
37441
37442 -static struct sg_proc_leaf sg_proc_leaf_arr[] = {
37443 +static const struct sg_proc_leaf sg_proc_leaf_arr[] = {
37444 {"allow_dio", &adio_fops},
37445 {"debug", &debug_fops},
37446 {"def_reserved_size", &dressz_fops},
37447 @@ -2332,7 +2332,7 @@ sg_proc_init(void)
37448 if (!sg_proc_sgp)
37449 return 1;
37450 for (k = 0; k < num_leaves; ++k) {
37451 - struct sg_proc_leaf *leaf = &sg_proc_leaf_arr[k];
37452 + const struct sg_proc_leaf *leaf = &sg_proc_leaf_arr[k];
37453 umode_t mask = leaf->fops->write ? S_IRUGO | S_IWUSR : S_IRUGO;
37454 proc_create(leaf->name, mask, sg_proc_sgp, leaf->fops);
37455 }
37456 diff --git a/drivers/spi/spi-dw-pci.c b/drivers/spi/spi-dw-pci.c
37457 index f64250e..1ee3049 100644
37458 --- a/drivers/spi/spi-dw-pci.c
37459 +++ b/drivers/spi/spi-dw-pci.c
37460 @@ -149,7 +149,7 @@ static int spi_resume(struct pci_dev *pdev)
37461 #define spi_resume NULL
37462 #endif
37463
37464 -static const struct pci_device_id pci_ids[] __devinitdata = {
37465 +static const struct pci_device_id pci_ids[] __devinitconst = {
37466 /* Intel MID platform SPI controller 0 */
37467 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0800) },
37468 {},
37469 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
37470 index b2ccdea..84cde75 100644
37471 --- a/drivers/spi/spi.c
37472 +++ b/drivers/spi/spi.c
37473 @@ -1024,7 +1024,7 @@ int spi_bus_unlock(struct spi_master *master)
37474 EXPORT_SYMBOL_GPL(spi_bus_unlock);
37475
37476 /* portable code must never pass more than 32 bytes */
37477 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
37478 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
37479
37480 static u8 *buf;
37481
37482 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
37483 index 400df8c..065d4f4 100644
37484 --- a/drivers/staging/octeon/ethernet-rx.c
37485 +++ b/drivers/staging/octeon/ethernet-rx.c
37486 @@ -420,11 +420,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
37487 /* Increment RX stats for virtual ports */
37488 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
37489 #ifdef CONFIG_64BIT
37490 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
37491 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
37492 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
37493 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
37494 #else
37495 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
37496 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
37497 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
37498 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
37499 #endif
37500 }
37501 netif_receive_skb(skb);
37502 @@ -436,9 +436,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
37503 dev->name);
37504 */
37505 #ifdef CONFIG_64BIT
37506 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
37507 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
37508 #else
37509 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
37510 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
37511 #endif
37512 dev_kfree_skb_irq(skb);
37513 }
37514 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
37515 index 9112cd8..92f8d51 100644
37516 --- a/drivers/staging/octeon/ethernet.c
37517 +++ b/drivers/staging/octeon/ethernet.c
37518 @@ -258,11 +258,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
37519 * since the RX tasklet also increments it.
37520 */
37521 #ifdef CONFIG_64BIT
37522 - atomic64_add(rx_status.dropped_packets,
37523 - (atomic64_t *)&priv->stats.rx_dropped);
37524 + atomic64_add_unchecked(rx_status.dropped_packets,
37525 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
37526 #else
37527 - atomic_add(rx_status.dropped_packets,
37528 - (atomic_t *)&priv->stats.rx_dropped);
37529 + atomic_add_unchecked(rx_status.dropped_packets,
37530 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
37531 #endif
37532 }
37533
37534 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
37535 index 86308a0..feaa925 100644
37536 --- a/drivers/staging/rtl8712/rtl871x_io.h
37537 +++ b/drivers/staging/rtl8712/rtl871x_io.h
37538 @@ -108,7 +108,7 @@ struct _io_ops {
37539 u8 *pmem);
37540 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
37541 u8 *pmem);
37542 -};
37543 +} __no_const;
37544
37545 struct io_req {
37546 struct list_head list;
37547 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
37548 index c7b5e8b..783d6cb 100644
37549 --- a/drivers/staging/sbe-2t3e3/netdev.c
37550 +++ b/drivers/staging/sbe-2t3e3/netdev.c
37551 @@ -51,7 +51,7 @@ int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
37552 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
37553
37554 if (rlen)
37555 - if (copy_to_user(data, &resp, rlen))
37556 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
37557 return -EFAULT;
37558
37559 return 0;
37560 diff --git a/drivers/staging/speakup/speakup_soft.c b/drivers/staging/speakup/speakup_soft.c
37561 index 42cdafe..2769103 100644
37562 --- a/drivers/staging/speakup/speakup_soft.c
37563 +++ b/drivers/staging/speakup/speakup_soft.c
37564 @@ -241,11 +241,11 @@ static ssize_t softsynth_read(struct file *fp, char *buf, size_t count,
37565 break;
37566 } else if (!initialized) {
37567 if (*init) {
37568 - ch = *init;
37569 init++;
37570 } else {
37571 initialized = 1;
37572 }
37573 + ch = *init;
37574 } else {
37575 ch = synth_buffer_getc();
37576 }
37577 diff --git a/drivers/staging/usbip/usbip_common.h b/drivers/staging/usbip/usbip_common.h
37578 index b8f8c48..1fc5025 100644
37579 --- a/drivers/staging/usbip/usbip_common.h
37580 +++ b/drivers/staging/usbip/usbip_common.h
37581 @@ -289,7 +289,7 @@ struct usbip_device {
37582 void (*shutdown)(struct usbip_device *);
37583 void (*reset)(struct usbip_device *);
37584 void (*unusable)(struct usbip_device *);
37585 - } eh_ops;
37586 + } __no_const eh_ops;
37587 };
37588
37589 /* usbip_common.c */
37590 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
37591 index 88b3298..3783eee 100644
37592 --- a/drivers/staging/usbip/vhci.h
37593 +++ b/drivers/staging/usbip/vhci.h
37594 @@ -88,7 +88,7 @@ struct vhci_hcd {
37595 unsigned resuming:1;
37596 unsigned long re_timeout;
37597
37598 - atomic_t seqnum;
37599 + atomic_unchecked_t seqnum;
37600
37601 /*
37602 * NOTE:
37603 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
37604 index 2ee97e2..0420b86 100644
37605 --- a/drivers/staging/usbip/vhci_hcd.c
37606 +++ b/drivers/staging/usbip/vhci_hcd.c
37607 @@ -527,7 +527,7 @@ static void vhci_tx_urb(struct urb *urb)
37608 return;
37609 }
37610
37611 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
37612 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
37613 if (priv->seqnum == 0xffff)
37614 dev_info(&urb->dev->dev, "seqnum max\n");
37615
37616 @@ -779,7 +779,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
37617 return -ENOMEM;
37618 }
37619
37620 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
37621 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
37622 if (unlink->seqnum == 0xffff)
37623 pr_info("seqnum max\n");
37624
37625 @@ -969,7 +969,7 @@ static int vhci_start(struct usb_hcd *hcd)
37626 vdev->rhport = rhport;
37627 }
37628
37629 - atomic_set(&vhci->seqnum, 0);
37630 + atomic_set_unchecked(&vhci->seqnum, 0);
37631 spin_lock_init(&vhci->lock);
37632
37633 hcd->power_budget = 0; /* no limit */
37634 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
37635 index 3f511b4..d3dbc1e 100644
37636 --- a/drivers/staging/usbip/vhci_rx.c
37637 +++ b/drivers/staging/usbip/vhci_rx.c
37638 @@ -77,7 +77,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
37639 if (!urb) {
37640 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
37641 pr_info("max seqnum %d\n",
37642 - atomic_read(&the_controller->seqnum));
37643 + atomic_read_unchecked(&the_controller->seqnum));
37644 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
37645 return;
37646 }
37647 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
37648 index 7735027..30eed13 100644
37649 --- a/drivers/staging/vt6655/hostap.c
37650 +++ b/drivers/staging/vt6655/hostap.c
37651 @@ -79,14 +79,13 @@ static int msglevel =MSG_LEVEL_INFO;
37652 *
37653 */
37654
37655 +static net_device_ops_no_const apdev_netdev_ops;
37656 +
37657 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
37658 {
37659 PSDevice apdev_priv;
37660 struct net_device *dev = pDevice->dev;
37661 int ret;
37662 - const struct net_device_ops apdev_netdev_ops = {
37663 - .ndo_start_xmit = pDevice->tx_80211,
37664 - };
37665
37666 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
37667
37668 @@ -98,6 +97,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
37669 *apdev_priv = *pDevice;
37670 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
37671
37672 + /* only half broken now */
37673 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
37674 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
37675
37676 pDevice->apdev->type = ARPHRD_IEEE80211;
37677 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
37678 index 51b5adf..098e320 100644
37679 --- a/drivers/staging/vt6656/hostap.c
37680 +++ b/drivers/staging/vt6656/hostap.c
37681 @@ -80,14 +80,13 @@ static int msglevel =MSG_LEVEL_INFO;
37682 *
37683 */
37684
37685 +static net_device_ops_no_const apdev_netdev_ops;
37686 +
37687 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
37688 {
37689 PSDevice apdev_priv;
37690 struct net_device *dev = pDevice->dev;
37691 int ret;
37692 - const struct net_device_ops apdev_netdev_ops = {
37693 - .ndo_start_xmit = pDevice->tx_80211,
37694 - };
37695
37696 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
37697
37698 @@ -99,6 +98,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
37699 *apdev_priv = *pDevice;
37700 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
37701
37702 + /* only half broken now */
37703 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
37704 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
37705
37706 pDevice->apdev->type = ARPHRD_IEEE80211;
37707 diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c
37708 index 7843dfd..3db105f 100644
37709 --- a/drivers/staging/wlan-ng/hfa384x_usb.c
37710 +++ b/drivers/staging/wlan-ng/hfa384x_usb.c
37711 @@ -204,7 +204,7 @@ static void unlocked_usbctlx_complete(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx);
37712
37713 struct usbctlx_completor {
37714 int (*complete) (struct usbctlx_completor *);
37715 -};
37716 +} __no_const;
37717
37718 static int
37719 hfa384x_usbctlx_complete_sync(hfa384x_t *hw,
37720 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
37721 index 1ca66ea..76f1343 100644
37722 --- a/drivers/staging/zcache/tmem.c
37723 +++ b/drivers/staging/zcache/tmem.c
37724 @@ -39,7 +39,7 @@
37725 * A tmem host implementation must use this function to register callbacks
37726 * for memory allocation.
37727 */
37728 -static struct tmem_hostops tmem_hostops;
37729 +static tmem_hostops_no_const tmem_hostops;
37730
37731 static void tmem_objnode_tree_init(void);
37732
37733 @@ -53,7 +53,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
37734 * A tmem host implementation must use this function to register
37735 * callbacks for a page-accessible memory (PAM) implementation
37736 */
37737 -static struct tmem_pamops tmem_pamops;
37738 +static tmem_pamops_no_const tmem_pamops;
37739
37740 void tmem_register_pamops(struct tmem_pamops *m)
37741 {
37742 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
37743 index ed147c4..94fc3c6 100644
37744 --- a/drivers/staging/zcache/tmem.h
37745 +++ b/drivers/staging/zcache/tmem.h
37746 @@ -180,6 +180,7 @@ struct tmem_pamops {
37747 void (*new_obj)(struct tmem_obj *);
37748 int (*replace_in_obj)(void *, struct tmem_obj *);
37749 };
37750 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
37751 extern void tmem_register_pamops(struct tmem_pamops *m);
37752
37753 /* memory allocation methods provided by the host implementation */
37754 @@ -189,6 +190,7 @@ struct tmem_hostops {
37755 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
37756 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
37757 };
37758 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
37759 extern void tmem_register_hostops(struct tmem_hostops *m);
37760
37761 /* core tmem accessor functions */
37762 diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
37763 index 97c74ee..7f6d77d 100644
37764 --- a/drivers/target/iscsi/iscsi_target.c
37765 +++ b/drivers/target/iscsi/iscsi_target.c
37766 @@ -1361,7 +1361,7 @@ static int iscsit_handle_data_out(struct iscsi_conn *conn, unsigned char *buf)
37767 * outstanding_r2ts reaches zero, go ahead and send the delayed
37768 * TASK_ABORTED status.
37769 */
37770 - if (atomic_read(&se_cmd->t_transport_aborted) != 0) {
37771 + if (atomic_read_unchecked(&se_cmd->t_transport_aborted) != 0) {
37772 if (hdr->flags & ISCSI_FLAG_CMD_FINAL)
37773 if (--cmd->outstanding_r2ts < 1) {
37774 iscsit_stop_dataout_timer(cmd);
37775 diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c
37776 index dcb0618..97e3d85 100644
37777 --- a/drivers/target/target_core_tmr.c
37778 +++ b/drivers/target/target_core_tmr.c
37779 @@ -260,7 +260,7 @@ static void core_tmr_drain_task_list(
37780 cmd->se_tfo->get_task_tag(cmd), cmd->pr_res_key,
37781 cmd->t_task_list_num,
37782 atomic_read(&cmd->t_task_cdbs_left),
37783 - atomic_read(&cmd->t_task_cdbs_sent),
37784 + atomic_read_unchecked(&cmd->t_task_cdbs_sent),
37785 atomic_read(&cmd->t_transport_active),
37786 atomic_read(&cmd->t_transport_stop),
37787 atomic_read(&cmd->t_transport_sent));
37788 @@ -291,7 +291,7 @@ static void core_tmr_drain_task_list(
37789 pr_debug("LUN_RESET: got t_transport_active = 1 for"
37790 " task: %p, t_fe_count: %d dev: %p\n", task,
37791 fe_count, dev);
37792 - atomic_set(&cmd->t_transport_aborted, 1);
37793 + atomic_set_unchecked(&cmd->t_transport_aborted, 1);
37794 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
37795
37796 core_tmr_handle_tas_abort(tmr_nacl, cmd, tas, fe_count);
37797 @@ -299,7 +299,7 @@ static void core_tmr_drain_task_list(
37798 }
37799 pr_debug("LUN_RESET: Got t_transport_active = 0 for task: %p,"
37800 " t_fe_count: %d dev: %p\n", task, fe_count, dev);
37801 - atomic_set(&cmd->t_transport_aborted, 1);
37802 + atomic_set_unchecked(&cmd->t_transport_aborted, 1);
37803 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
37804
37805 core_tmr_handle_tas_abort(tmr_nacl, cmd, tas, fe_count);
37806 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
37807 index cd5cd95..5249d30 100644
37808 --- a/drivers/target/target_core_transport.c
37809 +++ b/drivers/target/target_core_transport.c
37810 @@ -1330,7 +1330,7 @@ struct se_device *transport_add_device_to_core_hba(
37811 spin_lock_init(&dev->se_port_lock);
37812 spin_lock_init(&dev->se_tmr_lock);
37813 spin_lock_init(&dev->qf_cmd_lock);
37814 - atomic_set(&dev->dev_ordered_id, 0);
37815 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
37816
37817 se_dev_set_default_attribs(dev, dev_limits);
37818
37819 @@ -1517,7 +1517,7 @@ static int transport_check_alloc_task_attr(struct se_cmd *cmd)
37820 * Used to determine when ORDERED commands should go from
37821 * Dormant to Active status.
37822 */
37823 - cmd->se_ordered_id = atomic_inc_return(&cmd->se_dev->dev_ordered_id);
37824 + cmd->se_ordered_id = atomic_inc_return_unchecked(&cmd->se_dev->dev_ordered_id);
37825 smp_mb__after_atomic_inc();
37826 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
37827 cmd->se_ordered_id, cmd->sam_task_attr,
37828 @@ -1862,7 +1862,7 @@ static void transport_generic_request_failure(struct se_cmd *cmd)
37829 " t_transport_active: %d t_transport_stop: %d"
37830 " t_transport_sent: %d\n", cmd->t_task_list_num,
37831 atomic_read(&cmd->t_task_cdbs_left),
37832 - atomic_read(&cmd->t_task_cdbs_sent),
37833 + atomic_read_unchecked(&cmd->t_task_cdbs_sent),
37834 atomic_read(&cmd->t_task_cdbs_ex_left),
37835 atomic_read(&cmd->t_transport_active),
37836 atomic_read(&cmd->t_transport_stop),
37837 @@ -2121,9 +2121,9 @@ check_depth:
37838 cmd = task->task_se_cmd;
37839 spin_lock_irqsave(&cmd->t_state_lock, flags);
37840 task->task_flags |= (TF_ACTIVE | TF_SENT);
37841 - atomic_inc(&cmd->t_task_cdbs_sent);
37842 + atomic_inc_unchecked(&cmd->t_task_cdbs_sent);
37843
37844 - if (atomic_read(&cmd->t_task_cdbs_sent) ==
37845 + if (atomic_read_unchecked(&cmd->t_task_cdbs_sent) ==
37846 cmd->t_task_list_num)
37847 atomic_set(&cmd->t_transport_sent, 1);
37848
37849 @@ -4348,7 +4348,7 @@ bool transport_wait_for_tasks(struct se_cmd *cmd)
37850 atomic_set(&cmd->transport_lun_stop, 0);
37851 }
37852 if (!atomic_read(&cmd->t_transport_active) ||
37853 - atomic_read(&cmd->t_transport_aborted)) {
37854 + atomic_read_unchecked(&cmd->t_transport_aborted)) {
37855 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
37856 return false;
37857 }
37858 @@ -4597,7 +4597,7 @@ int transport_check_aborted_status(struct se_cmd *cmd, int send_status)
37859 {
37860 int ret = 0;
37861
37862 - if (atomic_read(&cmd->t_transport_aborted) != 0) {
37863 + if (atomic_read_unchecked(&cmd->t_transport_aborted) != 0) {
37864 if (!send_status ||
37865 (cmd->se_cmd_flags & SCF_SENT_DELAYED_TAS))
37866 return 1;
37867 @@ -4634,7 +4634,7 @@ void transport_send_task_abort(struct se_cmd *cmd)
37868 */
37869 if (cmd->data_direction == DMA_TO_DEVICE) {
37870 if (cmd->se_tfo->write_pending_status(cmd) != 0) {
37871 - atomic_inc(&cmd->t_transport_aborted);
37872 + atomic_inc_unchecked(&cmd->t_transport_aborted);
37873 smp_mb__after_atomic_inc();
37874 }
37875 }
37876 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
37877 index b9040be..e3f5aab 100644
37878 --- a/drivers/tty/hvc/hvcs.c
37879 +++ b/drivers/tty/hvc/hvcs.c
37880 @@ -83,6 +83,7 @@
37881 #include <asm/hvcserver.h>
37882 #include <asm/uaccess.h>
37883 #include <asm/vio.h>
37884 +#include <asm/local.h>
37885
37886 /*
37887 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
37888 @@ -270,7 +271,7 @@ struct hvcs_struct {
37889 unsigned int index;
37890
37891 struct tty_struct *tty;
37892 - int open_count;
37893 + local_t open_count;
37894
37895 /*
37896 * Used to tell the driver kernel_thread what operations need to take
37897 @@ -422,7 +423,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
37898
37899 spin_lock_irqsave(&hvcsd->lock, flags);
37900
37901 - if (hvcsd->open_count > 0) {
37902 + if (local_read(&hvcsd->open_count) > 0) {
37903 spin_unlock_irqrestore(&hvcsd->lock, flags);
37904 printk(KERN_INFO "HVCS: vterm state unchanged. "
37905 "The hvcs device node is still in use.\n");
37906 @@ -1145,7 +1146,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
37907 if ((retval = hvcs_partner_connect(hvcsd)))
37908 goto error_release;
37909
37910 - hvcsd->open_count = 1;
37911 + local_set(&hvcsd->open_count, 1);
37912 hvcsd->tty = tty;
37913 tty->driver_data = hvcsd;
37914
37915 @@ -1179,7 +1180,7 @@ fast_open:
37916
37917 spin_lock_irqsave(&hvcsd->lock, flags);
37918 kref_get(&hvcsd->kref);
37919 - hvcsd->open_count++;
37920 + local_inc(&hvcsd->open_count);
37921 hvcsd->todo_mask |= HVCS_SCHED_READ;
37922 spin_unlock_irqrestore(&hvcsd->lock, flags);
37923
37924 @@ -1223,7 +1224,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
37925 hvcsd = tty->driver_data;
37926
37927 spin_lock_irqsave(&hvcsd->lock, flags);
37928 - if (--hvcsd->open_count == 0) {
37929 + if (local_dec_and_test(&hvcsd->open_count)) {
37930
37931 vio_disable_interrupts(hvcsd->vdev);
37932
37933 @@ -1249,10 +1250,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
37934 free_irq(irq, hvcsd);
37935 kref_put(&hvcsd->kref, destroy_hvcs_struct);
37936 return;
37937 - } else if (hvcsd->open_count < 0) {
37938 + } else if (local_read(&hvcsd->open_count) < 0) {
37939 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
37940 " is missmanaged.\n",
37941 - hvcsd->vdev->unit_address, hvcsd->open_count);
37942 + hvcsd->vdev->unit_address, local_read(&hvcsd->open_count));
37943 }
37944
37945 spin_unlock_irqrestore(&hvcsd->lock, flags);
37946 @@ -1268,7 +1269,7 @@ static void hvcs_hangup(struct tty_struct * tty)
37947
37948 spin_lock_irqsave(&hvcsd->lock, flags);
37949 /* Preserve this so that we know how many kref refs to put */
37950 - temp_open_count = hvcsd->open_count;
37951 + temp_open_count = local_read(&hvcsd->open_count);
37952
37953 /*
37954 * Don't kref put inside the spinlock because the destruction
37955 @@ -1283,7 +1284,7 @@ static void hvcs_hangup(struct tty_struct * tty)
37956 hvcsd->tty->driver_data = NULL;
37957 hvcsd->tty = NULL;
37958
37959 - hvcsd->open_count = 0;
37960 + local_set(&hvcsd->open_count, 0);
37961
37962 /* This will drop any buffered data on the floor which is OK in a hangup
37963 * scenario. */
37964 @@ -1354,7 +1355,7 @@ static int hvcs_write(struct tty_struct *tty,
37965 * the middle of a write operation? This is a crummy place to do this
37966 * but we want to keep it all in the spinlock.
37967 */
37968 - if (hvcsd->open_count <= 0) {
37969 + if (local_read(&hvcsd->open_count) <= 0) {
37970 spin_unlock_irqrestore(&hvcsd->lock, flags);
37971 return -ENODEV;
37972 }
37973 @@ -1428,7 +1429,7 @@ static int hvcs_write_room(struct tty_struct *tty)
37974 {
37975 struct hvcs_struct *hvcsd = tty->driver_data;
37976
37977 - if (!hvcsd || hvcsd->open_count <= 0)
37978 + if (!hvcsd || local_read(&hvcsd->open_count) <= 0)
37979 return 0;
37980
37981 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
37982 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
37983 index ef92869..f4ebd88 100644
37984 --- a/drivers/tty/ipwireless/tty.c
37985 +++ b/drivers/tty/ipwireless/tty.c
37986 @@ -29,6 +29,7 @@
37987 #include <linux/tty_driver.h>
37988 #include <linux/tty_flip.h>
37989 #include <linux/uaccess.h>
37990 +#include <asm/local.h>
37991
37992 #include "tty.h"
37993 #include "network.h"
37994 @@ -51,7 +52,7 @@ struct ipw_tty {
37995 int tty_type;
37996 struct ipw_network *network;
37997 struct tty_struct *linux_tty;
37998 - int open_count;
37999 + local_t open_count;
38000 unsigned int control_lines;
38001 struct mutex ipw_tty_mutex;
38002 int tx_bytes_queued;
38003 @@ -127,10 +128,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
38004 mutex_unlock(&tty->ipw_tty_mutex);
38005 return -ENODEV;
38006 }
38007 - if (tty->open_count == 0)
38008 + if (local_read(&tty->open_count) == 0)
38009 tty->tx_bytes_queued = 0;
38010
38011 - tty->open_count++;
38012 + local_inc(&tty->open_count);
38013
38014 tty->linux_tty = linux_tty;
38015 linux_tty->driver_data = tty;
38016 @@ -146,9 +147,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
38017
38018 static void do_ipw_close(struct ipw_tty *tty)
38019 {
38020 - tty->open_count--;
38021 -
38022 - if (tty->open_count == 0) {
38023 + if (local_dec_return(&tty->open_count) == 0) {
38024 struct tty_struct *linux_tty = tty->linux_tty;
38025
38026 if (linux_tty != NULL) {
38027 @@ -169,7 +168,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
38028 return;
38029
38030 mutex_lock(&tty->ipw_tty_mutex);
38031 - if (tty->open_count == 0) {
38032 + if (local_read(&tty->open_count) == 0) {
38033 mutex_unlock(&tty->ipw_tty_mutex);
38034 return;
38035 }
38036 @@ -198,7 +197,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
38037 return;
38038 }
38039
38040 - if (!tty->open_count) {
38041 + if (!local_read(&tty->open_count)) {
38042 mutex_unlock(&tty->ipw_tty_mutex);
38043 return;
38044 }
38045 @@ -240,7 +239,7 @@ static int ipw_write(struct tty_struct *linux_tty,
38046 return -ENODEV;
38047
38048 mutex_lock(&tty->ipw_tty_mutex);
38049 - if (!tty->open_count) {
38050 + if (!local_read(&tty->open_count)) {
38051 mutex_unlock(&tty->ipw_tty_mutex);
38052 return -EINVAL;
38053 }
38054 @@ -280,7 +279,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
38055 if (!tty)
38056 return -ENODEV;
38057
38058 - if (!tty->open_count)
38059 + if (!local_read(&tty->open_count))
38060 return -EINVAL;
38061
38062 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
38063 @@ -322,7 +321,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
38064 if (!tty)
38065 return 0;
38066
38067 - if (!tty->open_count)
38068 + if (!local_read(&tty->open_count))
38069 return 0;
38070
38071 return tty->tx_bytes_queued;
38072 @@ -403,7 +402,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
38073 if (!tty)
38074 return -ENODEV;
38075
38076 - if (!tty->open_count)
38077 + if (!local_read(&tty->open_count))
38078 return -EINVAL;
38079
38080 return get_control_lines(tty);
38081 @@ -419,7 +418,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
38082 if (!tty)
38083 return -ENODEV;
38084
38085 - if (!tty->open_count)
38086 + if (!local_read(&tty->open_count))
38087 return -EINVAL;
38088
38089 return set_control_lines(tty, set, clear);
38090 @@ -433,7 +432,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
38091 if (!tty)
38092 return -ENODEV;
38093
38094 - if (!tty->open_count)
38095 + if (!local_read(&tty->open_count))
38096 return -EINVAL;
38097
38098 /* FIXME: Exactly how is the tty object locked here .. */
38099 @@ -582,7 +581,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
38100 against a parallel ioctl etc */
38101 mutex_lock(&ttyj->ipw_tty_mutex);
38102 }
38103 - while (ttyj->open_count)
38104 + while (local_read(&ttyj->open_count))
38105 do_ipw_close(ttyj);
38106 ipwireless_disassociate_network_ttys(network,
38107 ttyj->channel_idx);
38108 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
38109 index fc7bbba..9527e93 100644
38110 --- a/drivers/tty/n_gsm.c
38111 +++ b/drivers/tty/n_gsm.c
38112 @@ -1629,7 +1629,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
38113 kref_init(&dlci->ref);
38114 mutex_init(&dlci->mutex);
38115 dlci->fifo = &dlci->_fifo;
38116 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
38117 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
38118 kfree(dlci);
38119 return NULL;
38120 }
38121 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
38122 index d2256d0..97476fa 100644
38123 --- a/drivers/tty/n_tty.c
38124 +++ b/drivers/tty/n_tty.c
38125 @@ -2123,6 +2123,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
38126 {
38127 *ops = tty_ldisc_N_TTY;
38128 ops->owner = NULL;
38129 - ops->refcount = ops->flags = 0;
38130 + atomic_set(&ops->refcount, 0);
38131 + ops->flags = 0;
38132 }
38133 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
38134 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
38135 index d8653ab..f8afd9d 100644
38136 --- a/drivers/tty/pty.c
38137 +++ b/drivers/tty/pty.c
38138 @@ -765,8 +765,10 @@ static void __init unix98_pty_init(void)
38139 register_sysctl_table(pty_root_table);
38140
38141 /* Now create the /dev/ptmx special device */
38142 + pax_open_kernel();
38143 tty_default_fops(&ptmx_fops);
38144 - ptmx_fops.open = ptmx_open;
38145 + *(void **)&ptmx_fops.open = ptmx_open;
38146 + pax_close_kernel();
38147
38148 cdev_init(&ptmx_cdev, &ptmx_fops);
38149 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
38150 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
38151 index 2b42a01..32a2ed3 100644
38152 --- a/drivers/tty/serial/kgdboc.c
38153 +++ b/drivers/tty/serial/kgdboc.c
38154 @@ -24,8 +24,9 @@
38155 #define MAX_CONFIG_LEN 40
38156
38157 static struct kgdb_io kgdboc_io_ops;
38158 +static struct kgdb_io kgdboc_io_ops_console;
38159
38160 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
38161 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
38162 static int configured = -1;
38163
38164 static char config[MAX_CONFIG_LEN];
38165 @@ -148,6 +149,8 @@ static void cleanup_kgdboc(void)
38166 kgdboc_unregister_kbd();
38167 if (configured == 1)
38168 kgdb_unregister_io_module(&kgdboc_io_ops);
38169 + else if (configured == 2)
38170 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
38171 }
38172
38173 static int configure_kgdboc(void)
38174 @@ -157,13 +160,13 @@ static int configure_kgdboc(void)
38175 int err;
38176 char *cptr = config;
38177 struct console *cons;
38178 + int is_console = 0;
38179
38180 err = kgdboc_option_setup(config);
38181 if (err || !strlen(config) || isspace(config[0]))
38182 goto noconfig;
38183
38184 err = -ENODEV;
38185 - kgdboc_io_ops.is_console = 0;
38186 kgdb_tty_driver = NULL;
38187
38188 kgdboc_use_kms = 0;
38189 @@ -184,7 +187,7 @@ static int configure_kgdboc(void)
38190 int idx;
38191 if (cons->device && cons->device(cons, &idx) == p &&
38192 idx == tty_line) {
38193 - kgdboc_io_ops.is_console = 1;
38194 + is_console = 1;
38195 break;
38196 }
38197 cons = cons->next;
38198 @@ -194,12 +197,16 @@ static int configure_kgdboc(void)
38199 kgdb_tty_line = tty_line;
38200
38201 do_register:
38202 - err = kgdb_register_io_module(&kgdboc_io_ops);
38203 + if (is_console) {
38204 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
38205 + configured = 2;
38206 + } else {
38207 + err = kgdb_register_io_module(&kgdboc_io_ops);
38208 + configured = 1;
38209 + }
38210 if (err)
38211 goto noconfig;
38212
38213 - configured = 1;
38214 -
38215 return 0;
38216
38217 noconfig:
38218 @@ -213,7 +220,7 @@ noconfig:
38219 static int __init init_kgdboc(void)
38220 {
38221 /* Already configured? */
38222 - if (configured == 1)
38223 + if (configured >= 1)
38224 return 0;
38225
38226 return configure_kgdboc();
38227 @@ -262,7 +269,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
38228 if (config[len - 1] == '\n')
38229 config[len - 1] = '\0';
38230
38231 - if (configured == 1)
38232 + if (configured >= 1)
38233 cleanup_kgdboc();
38234
38235 /* Go and configure with the new params. */
38236 @@ -302,6 +309,15 @@ static struct kgdb_io kgdboc_io_ops = {
38237 .post_exception = kgdboc_post_exp_handler,
38238 };
38239
38240 +static struct kgdb_io kgdboc_io_ops_console = {
38241 + .name = "kgdboc",
38242 + .read_char = kgdboc_get_char,
38243 + .write_char = kgdboc_put_char,
38244 + .pre_exception = kgdboc_pre_exp_handler,
38245 + .post_exception = kgdboc_post_exp_handler,
38246 + .is_console = 1
38247 +};
38248 +
38249 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
38250 /* This is only available if kgdboc is a built in for early debugging */
38251 static int __init kgdboc_early_init(char *opt)
38252 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
38253 index 7867b7c..b3c119d 100644
38254 --- a/drivers/tty/sysrq.c
38255 +++ b/drivers/tty/sysrq.c
38256 @@ -862,7 +862,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
38257 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
38258 size_t count, loff_t *ppos)
38259 {
38260 - if (count) {
38261 + if (count && capable(CAP_SYS_ADMIN)) {
38262 char c;
38263
38264 if (get_user(c, buf))
38265 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
38266 index e41b9bb..84002fb 100644
38267 --- a/drivers/tty/tty_io.c
38268 +++ b/drivers/tty/tty_io.c
38269 @@ -3291,7 +3291,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
38270
38271 void tty_default_fops(struct file_operations *fops)
38272 {
38273 - *fops = tty_fops;
38274 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
38275 }
38276
38277 /*
38278 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
38279 index 24b95db..9c078d0 100644
38280 --- a/drivers/tty/tty_ldisc.c
38281 +++ b/drivers/tty/tty_ldisc.c
38282 @@ -57,7 +57,7 @@ static void put_ldisc(struct tty_ldisc *ld)
38283 if (atomic_dec_and_lock(&ld->users, &tty_ldisc_lock)) {
38284 struct tty_ldisc_ops *ldo = ld->ops;
38285
38286 - ldo->refcount--;
38287 + atomic_dec(&ldo->refcount);
38288 module_put(ldo->owner);
38289 spin_unlock_irqrestore(&tty_ldisc_lock, flags);
38290
38291 @@ -92,7 +92,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
38292 spin_lock_irqsave(&tty_ldisc_lock, flags);
38293 tty_ldiscs[disc] = new_ldisc;
38294 new_ldisc->num = disc;
38295 - new_ldisc->refcount = 0;
38296 + atomic_set(&new_ldisc->refcount, 0);
38297 spin_unlock_irqrestore(&tty_ldisc_lock, flags);
38298
38299 return ret;
38300 @@ -120,7 +120,7 @@ int tty_unregister_ldisc(int disc)
38301 return -EINVAL;
38302
38303 spin_lock_irqsave(&tty_ldisc_lock, flags);
38304 - if (tty_ldiscs[disc]->refcount)
38305 + if (atomic_read(&tty_ldiscs[disc]->refcount))
38306 ret = -EBUSY;
38307 else
38308 tty_ldiscs[disc] = NULL;
38309 @@ -141,7 +141,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
38310 if (ldops) {
38311 ret = ERR_PTR(-EAGAIN);
38312 if (try_module_get(ldops->owner)) {
38313 - ldops->refcount++;
38314 + atomic_inc(&ldops->refcount);
38315 ret = ldops;
38316 }
38317 }
38318 @@ -154,7 +154,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
38319 unsigned long flags;
38320
38321 spin_lock_irqsave(&tty_ldisc_lock, flags);
38322 - ldops->refcount--;
38323 + atomic_dec(&ldops->refcount);
38324 module_put(ldops->owner);
38325 spin_unlock_irqrestore(&tty_ldisc_lock, flags);
38326 }
38327 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
38328 index a605549..6bd3c96 100644
38329 --- a/drivers/tty/vt/keyboard.c
38330 +++ b/drivers/tty/vt/keyboard.c
38331 @@ -657,6 +657,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
38332 kbd->kbdmode == VC_OFF) &&
38333 value != KVAL(K_SAK))
38334 return; /* SAK is allowed even in raw mode */
38335 +
38336 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
38337 + {
38338 + void *func = fn_handler[value];
38339 + if (func == fn_show_state || func == fn_show_ptregs ||
38340 + func == fn_show_mem)
38341 + return;
38342 + }
38343 +#endif
38344 +
38345 fn_handler[value](vc);
38346 }
38347
38348 diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c
38349 index 65447c5..0526f0a 100644
38350 --- a/drivers/tty/vt/vt_ioctl.c
38351 +++ b/drivers/tty/vt/vt_ioctl.c
38352 @@ -207,9 +207,6 @@ do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm, struct kbd_str
38353 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
38354 return -EFAULT;
38355
38356 - if (!capable(CAP_SYS_TTY_CONFIG))
38357 - perm = 0;
38358 -
38359 switch (cmd) {
38360 case KDGKBENT:
38361 key_map = key_maps[s];
38362 @@ -221,6 +218,9 @@ do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm, struct kbd_str
38363 val = (i ? K_HOLE : K_NOSUCHMAP);
38364 return put_user(val, &user_kbe->kb_value);
38365 case KDSKBENT:
38366 + if (!capable(CAP_SYS_TTY_CONFIG))
38367 + perm = 0;
38368 +
38369 if (!perm)
38370 return -EPERM;
38371 if (!i && v == K_NOSUCHMAP) {
38372 @@ -322,9 +322,6 @@ do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
38373 int i, j, k;
38374 int ret;
38375
38376 - if (!capable(CAP_SYS_TTY_CONFIG))
38377 - perm = 0;
38378 -
38379 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
38380 if (!kbs) {
38381 ret = -ENOMEM;
38382 @@ -358,6 +355,9 @@ do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
38383 kfree(kbs);
38384 return ((p && *p) ? -EOVERFLOW : 0);
38385 case KDSKBSENT:
38386 + if (!capable(CAP_SYS_TTY_CONFIG))
38387 + perm = 0;
38388 +
38389 if (!perm) {
38390 ret = -EPERM;
38391 goto reterr;
38392 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
38393 index a783d53..cb30d94 100644
38394 --- a/drivers/uio/uio.c
38395 +++ b/drivers/uio/uio.c
38396 @@ -25,6 +25,7 @@
38397 #include <linux/kobject.h>
38398 #include <linux/cdev.h>
38399 #include <linux/uio_driver.h>
38400 +#include <asm/local.h>
38401
38402 #define UIO_MAX_DEVICES (1U << MINORBITS)
38403
38404 @@ -32,10 +33,10 @@ struct uio_device {
38405 struct module *owner;
38406 struct device *dev;
38407 int minor;
38408 - atomic_t event;
38409 + atomic_unchecked_t event;
38410 struct fasync_struct *async_queue;
38411 wait_queue_head_t wait;
38412 - int vma_count;
38413 + local_t vma_count;
38414 struct uio_info *info;
38415 struct kobject *map_dir;
38416 struct kobject *portio_dir;
38417 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
38418 struct device_attribute *attr, char *buf)
38419 {
38420 struct uio_device *idev = dev_get_drvdata(dev);
38421 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
38422 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
38423 }
38424
38425 static struct device_attribute uio_class_attributes[] = {
38426 @@ -408,7 +409,7 @@ void uio_event_notify(struct uio_info *info)
38427 {
38428 struct uio_device *idev = info->uio_dev;
38429
38430 - atomic_inc(&idev->event);
38431 + atomic_inc_unchecked(&idev->event);
38432 wake_up_interruptible(&idev->wait);
38433 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
38434 }
38435 @@ -461,7 +462,7 @@ static int uio_open(struct inode *inode, struct file *filep)
38436 }
38437
38438 listener->dev = idev;
38439 - listener->event_count = atomic_read(&idev->event);
38440 + listener->event_count = atomic_read_unchecked(&idev->event);
38441 filep->private_data = listener;
38442
38443 if (idev->info->open) {
38444 @@ -512,7 +513,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
38445 return -EIO;
38446
38447 poll_wait(filep, &idev->wait, wait);
38448 - if (listener->event_count != atomic_read(&idev->event))
38449 + if (listener->event_count != atomic_read_unchecked(&idev->event))
38450 return POLLIN | POLLRDNORM;
38451 return 0;
38452 }
38453 @@ -537,7 +538,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
38454 do {
38455 set_current_state(TASK_INTERRUPTIBLE);
38456
38457 - event_count = atomic_read(&idev->event);
38458 + event_count = atomic_read_unchecked(&idev->event);
38459 if (event_count != listener->event_count) {
38460 if (copy_to_user(buf, &event_count, count))
38461 retval = -EFAULT;
38462 @@ -606,13 +607,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
38463 static void uio_vma_open(struct vm_area_struct *vma)
38464 {
38465 struct uio_device *idev = vma->vm_private_data;
38466 - idev->vma_count++;
38467 + local_inc(&idev->vma_count);
38468 }
38469
38470 static void uio_vma_close(struct vm_area_struct *vma)
38471 {
38472 struct uio_device *idev = vma->vm_private_data;
38473 - idev->vma_count--;
38474 + local_dec(&idev->vma_count);
38475 }
38476
38477 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
38478 @@ -821,7 +822,7 @@ int __uio_register_device(struct module *owner,
38479 idev->owner = owner;
38480 idev->info = info;
38481 init_waitqueue_head(&idev->wait);
38482 - atomic_set(&idev->event, 0);
38483 + atomic_set_unchecked(&idev->event, 0);
38484
38485 ret = uio_get_minor(idev);
38486 if (ret)
38487 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
38488 index 98b89fe..aff824e 100644
38489 --- a/drivers/usb/atm/cxacru.c
38490 +++ b/drivers/usb/atm/cxacru.c
38491 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
38492 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
38493 if (ret < 2)
38494 return -EINVAL;
38495 - if (index < 0 || index > 0x7f)
38496 + if (index > 0x7f)
38497 return -EINVAL;
38498 pos += tmp;
38499
38500 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
38501 index d3448ca..d2864ca 100644
38502 --- a/drivers/usb/atm/usbatm.c
38503 +++ b/drivers/usb/atm/usbatm.c
38504 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
38505 if (printk_ratelimit())
38506 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
38507 __func__, vpi, vci);
38508 - atomic_inc(&vcc->stats->rx_err);
38509 + atomic_inc_unchecked(&vcc->stats->rx_err);
38510 return;
38511 }
38512
38513 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
38514 if (length > ATM_MAX_AAL5_PDU) {
38515 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
38516 __func__, length, vcc);
38517 - atomic_inc(&vcc->stats->rx_err);
38518 + atomic_inc_unchecked(&vcc->stats->rx_err);
38519 goto out;
38520 }
38521
38522 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
38523 if (sarb->len < pdu_length) {
38524 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
38525 __func__, pdu_length, sarb->len, vcc);
38526 - atomic_inc(&vcc->stats->rx_err);
38527 + atomic_inc_unchecked(&vcc->stats->rx_err);
38528 goto out;
38529 }
38530
38531 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
38532 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
38533 __func__, vcc);
38534 - atomic_inc(&vcc->stats->rx_err);
38535 + atomic_inc_unchecked(&vcc->stats->rx_err);
38536 goto out;
38537 }
38538
38539 @@ -387,7 +387,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
38540 if (printk_ratelimit())
38541 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
38542 __func__, length);
38543 - atomic_inc(&vcc->stats->rx_drop);
38544 + atomic_inc_unchecked(&vcc->stats->rx_drop);
38545 goto out;
38546 }
38547
38548 @@ -412,7 +412,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
38549
38550 vcc->push(vcc, skb);
38551
38552 - atomic_inc(&vcc->stats->rx);
38553 + atomic_inc_unchecked(&vcc->stats->rx);
38554 out:
38555 skb_trim(sarb, 0);
38556 }
38557 @@ -615,7 +615,7 @@ static void usbatm_tx_process(unsigned long data)
38558 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
38559
38560 usbatm_pop(vcc, skb);
38561 - atomic_inc(&vcc->stats->tx);
38562 + atomic_inc_unchecked(&vcc->stats->tx);
38563
38564 skb = skb_dequeue(&instance->sndqueue);
38565 }
38566 @@ -773,11 +773,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
38567 if (!left--)
38568 return sprintf(page,
38569 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
38570 - atomic_read(&atm_dev->stats.aal5.tx),
38571 - atomic_read(&atm_dev->stats.aal5.tx_err),
38572 - atomic_read(&atm_dev->stats.aal5.rx),
38573 - atomic_read(&atm_dev->stats.aal5.rx_err),
38574 - atomic_read(&atm_dev->stats.aal5.rx_drop));
38575 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
38576 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
38577 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
38578 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
38579 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
38580
38581 if (!left--) {
38582 if (instance->disconnected)
38583 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
38584 index d956965..4179a77 100644
38585 --- a/drivers/usb/core/devices.c
38586 +++ b/drivers/usb/core/devices.c
38587 @@ -126,7 +126,7 @@ static const char format_endpt[] =
38588 * time it gets called.
38589 */
38590 static struct device_connect_event {
38591 - atomic_t count;
38592 + atomic_unchecked_t count;
38593 wait_queue_head_t wait;
38594 } device_event = {
38595 .count = ATOMIC_INIT(1),
38596 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
38597
38598 void usbfs_conn_disc_event(void)
38599 {
38600 - atomic_add(2, &device_event.count);
38601 + atomic_add_unchecked(2, &device_event.count);
38602 wake_up(&device_event.wait);
38603 }
38604
38605 @@ -648,7 +648,7 @@ static unsigned int usb_device_poll(struct file *file,
38606
38607 poll_wait(file, &device_event.wait, wait);
38608
38609 - event_count = atomic_read(&device_event.count);
38610 + event_count = atomic_read_unchecked(&device_event.count);
38611 if (file->f_version != event_count) {
38612 file->f_version = event_count;
38613 return POLLIN | POLLRDNORM;
38614 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
38615 index 1fc8f12..20647c1 100644
38616 --- a/drivers/usb/early/ehci-dbgp.c
38617 +++ b/drivers/usb/early/ehci-dbgp.c
38618 @@ -97,7 +97,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
38619
38620 #ifdef CONFIG_KGDB
38621 static struct kgdb_io kgdbdbgp_io_ops;
38622 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
38623 +static struct kgdb_io kgdbdbgp_io_ops_console;
38624 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
38625 #else
38626 #define dbgp_kgdb_mode (0)
38627 #endif
38628 @@ -1035,6 +1036,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
38629 .write_char = kgdbdbgp_write_char,
38630 };
38631
38632 +static struct kgdb_io kgdbdbgp_io_ops_console = {
38633 + .name = "kgdbdbgp",
38634 + .read_char = kgdbdbgp_read_char,
38635 + .write_char = kgdbdbgp_write_char,
38636 + .is_console = 1
38637 +};
38638 +
38639 static int kgdbdbgp_wait_time;
38640
38641 static int __init kgdbdbgp_parse_config(char *str)
38642 @@ -1050,8 +1058,10 @@ static int __init kgdbdbgp_parse_config(char *str)
38643 ptr++;
38644 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
38645 }
38646 - kgdb_register_io_module(&kgdbdbgp_io_ops);
38647 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
38648 + if (early_dbgp_console.index != -1)
38649 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
38650 + else
38651 + kgdb_register_io_module(&kgdbdbgp_io_ops);
38652
38653 return 0;
38654 }
38655 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
38656 index d6bea3e..60b250e 100644
38657 --- a/drivers/usb/wusbcore/wa-hc.h
38658 +++ b/drivers/usb/wusbcore/wa-hc.h
38659 @@ -192,7 +192,7 @@ struct wahc {
38660 struct list_head xfer_delayed_list;
38661 spinlock_t xfer_list_lock;
38662 struct work_struct xfer_work;
38663 - atomic_t xfer_id_count;
38664 + atomic_unchecked_t xfer_id_count;
38665 };
38666
38667
38668 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
38669 INIT_LIST_HEAD(&wa->xfer_delayed_list);
38670 spin_lock_init(&wa->xfer_list_lock);
38671 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
38672 - atomic_set(&wa->xfer_id_count, 1);
38673 + atomic_set_unchecked(&wa->xfer_id_count, 1);
38674 }
38675
38676 /**
38677 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
38678 index 57c01ab..8a05959 100644
38679 --- a/drivers/usb/wusbcore/wa-xfer.c
38680 +++ b/drivers/usb/wusbcore/wa-xfer.c
38681 @@ -296,7 +296,7 @@ out:
38682 */
38683 static void wa_xfer_id_init(struct wa_xfer *xfer)
38684 {
38685 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
38686 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
38687 }
38688
38689 /*
38690 diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
38691 index c14c42b..f955cc2 100644
38692 --- a/drivers/vhost/vhost.c
38693 +++ b/drivers/vhost/vhost.c
38694 @@ -629,7 +629,7 @@ static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m)
38695 return 0;
38696 }
38697
38698 -static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
38699 +static long vhost_set_vring(struct vhost_dev *d, unsigned int ioctl, void __user *argp)
38700 {
38701 struct file *eventfp, *filep = NULL,
38702 *pollstart = NULL, *pollstop = NULL;
38703 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
38704 index b0b2ac3..89a4399 100644
38705 --- a/drivers/video/aty/aty128fb.c
38706 +++ b/drivers/video/aty/aty128fb.c
38707 @@ -148,7 +148,7 @@ enum {
38708 };
38709
38710 /* Must match above enum */
38711 -static const char *r128_family[] __devinitdata = {
38712 +static const char *r128_family[] __devinitconst = {
38713 "AGP",
38714 "PCI",
38715 "PRO AGP",
38716 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
38717 index 5c3960d..15cf8fc 100644
38718 --- a/drivers/video/fbcmap.c
38719 +++ b/drivers/video/fbcmap.c
38720 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
38721 rc = -ENODEV;
38722 goto out;
38723 }
38724 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
38725 - !info->fbops->fb_setcmap)) {
38726 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
38727 rc = -EINVAL;
38728 goto out1;
38729 }
38730 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
38731 index c6ce416..3b9b642 100644
38732 --- a/drivers/video/fbmem.c
38733 +++ b/drivers/video/fbmem.c
38734 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
38735 image->dx += image->width + 8;
38736 }
38737 } else if (rotate == FB_ROTATE_UD) {
38738 - for (x = 0; x < num && image->dx >= 0; x++) {
38739 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
38740 info->fbops->fb_imageblit(info, image);
38741 image->dx -= image->width + 8;
38742 }
38743 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
38744 image->dy += image->height + 8;
38745 }
38746 } else if (rotate == FB_ROTATE_CCW) {
38747 - for (x = 0; x < num && image->dy >= 0; x++) {
38748 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
38749 info->fbops->fb_imageblit(info, image);
38750 image->dy -= image->height + 8;
38751 }
38752 @@ -1157,7 +1157,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
38753 return -EFAULT;
38754 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
38755 return -EINVAL;
38756 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
38757 + if (con2fb.framebuffer >= FB_MAX)
38758 return -EINVAL;
38759 if (!registered_fb[con2fb.framebuffer])
38760 request_module("fb%d", con2fb.framebuffer);
38761 diff --git a/drivers/video/geode/gx1fb_core.c b/drivers/video/geode/gx1fb_core.c
38762 index 5a5d092..265c5ed 100644
38763 --- a/drivers/video/geode/gx1fb_core.c
38764 +++ b/drivers/video/geode/gx1fb_core.c
38765 @@ -29,7 +29,7 @@ static int crt_option = 1;
38766 static char panel_option[32] = "";
38767
38768 /* Modes relevant to the GX1 (taken from modedb.c) */
38769 -static const struct fb_videomode __devinitdata gx1_modedb[] = {
38770 +static const struct fb_videomode __devinitconst gx1_modedb[] = {
38771 /* 640x480-60 VESA */
38772 { NULL, 60, 640, 480, 39682, 48, 16, 33, 10, 96, 2,
38773 0, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
38774 diff --git a/drivers/video/gxt4500.c b/drivers/video/gxt4500.c
38775 index 0fad23f..0e9afa4 100644
38776 --- a/drivers/video/gxt4500.c
38777 +++ b/drivers/video/gxt4500.c
38778 @@ -156,7 +156,7 @@ struct gxt4500_par {
38779 static char *mode_option;
38780
38781 /* default mode: 1280x1024 @ 60 Hz, 8 bpp */
38782 -static const struct fb_videomode defaultmode __devinitdata = {
38783 +static const struct fb_videomode defaultmode __devinitconst = {
38784 .refresh = 60,
38785 .xres = 1280,
38786 .yres = 1024,
38787 @@ -581,7 +581,7 @@ static int gxt4500_blank(int blank, struct fb_info *info)
38788 return 0;
38789 }
38790
38791 -static const struct fb_fix_screeninfo gxt4500_fix __devinitdata = {
38792 +static const struct fb_fix_screeninfo gxt4500_fix __devinitconst = {
38793 .id = "IBM GXT4500P",
38794 .type = FB_TYPE_PACKED_PIXELS,
38795 .visual = FB_VISUAL_PSEUDOCOLOR,
38796 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
38797 index 7672d2e..b56437f 100644
38798 --- a/drivers/video/i810/i810_accel.c
38799 +++ b/drivers/video/i810/i810_accel.c
38800 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
38801 }
38802 }
38803 printk("ringbuffer lockup!!!\n");
38804 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
38805 i810_report_error(mmio);
38806 par->dev_flags |= LOCKUP;
38807 info->pixmap.scan_align = 1;
38808 diff --git a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c
38809 index b83f361..2b05a91 100644
38810 --- a/drivers/video/i810/i810_main.c
38811 +++ b/drivers/video/i810/i810_main.c
38812 @@ -97,7 +97,7 @@ static int i810fb_blank (int blank_mode, struct fb_info *info);
38813 static void i810fb_release_resource (struct fb_info *info, struct i810fb_par *par);
38814
38815 /* PCI */
38816 -static const char *i810_pci_list[] __devinitdata = {
38817 +static const char *i810_pci_list[] __devinitconst = {
38818 "Intel(R) 810 Framebuffer Device" ,
38819 "Intel(R) 810-DC100 Framebuffer Device" ,
38820 "Intel(R) 810E Framebuffer Device" ,
38821 diff --git a/drivers/video/jz4740_fb.c b/drivers/video/jz4740_fb.c
38822 index de36693..3c63fc2 100644
38823 --- a/drivers/video/jz4740_fb.c
38824 +++ b/drivers/video/jz4740_fb.c
38825 @@ -136,7 +136,7 @@ struct jzfb {
38826 uint32_t pseudo_palette[16];
38827 };
38828
38829 -static const struct fb_fix_screeninfo jzfb_fix __devinitdata = {
38830 +static const struct fb_fix_screeninfo jzfb_fix __devinitconst = {
38831 .id = "JZ4740 FB",
38832 .type = FB_TYPE_PACKED_PIXELS,
38833 .visual = FB_VISUAL_TRUECOLOR,
38834 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
38835 index 3c14e43..eafa544 100644
38836 --- a/drivers/video/logo/logo_linux_clut224.ppm
38837 +++ b/drivers/video/logo/logo_linux_clut224.ppm
38838 @@ -1,1604 +1,1123 @@
38839 P3
38840 -# Standard 224-color Linux logo
38841 80 80
38842 255
38843 - 0 0 0 0 0 0 0 0 0 0 0 0
38844 - 0 0 0 0 0 0 0 0 0 0 0 0
38845 - 0 0 0 0 0 0 0 0 0 0 0 0
38846 - 0 0 0 0 0 0 0 0 0 0 0 0
38847 - 0 0 0 0 0 0 0 0 0 0 0 0
38848 - 0 0 0 0 0 0 0 0 0 0 0 0
38849 - 0 0 0 0 0 0 0 0 0 0 0 0
38850 - 0 0 0 0 0 0 0 0 0 0 0 0
38851 - 0 0 0 0 0 0 0 0 0 0 0 0
38852 - 6 6 6 6 6 6 10 10 10 10 10 10
38853 - 10 10 10 6 6 6 6 6 6 6 6 6
38854 - 0 0 0 0 0 0 0 0 0 0 0 0
38855 - 0 0 0 0 0 0 0 0 0 0 0 0
38856 - 0 0 0 0 0 0 0 0 0 0 0 0
38857 - 0 0 0 0 0 0 0 0 0 0 0 0
38858 - 0 0 0 0 0 0 0 0 0 0 0 0
38859 - 0 0 0 0 0 0 0 0 0 0 0 0
38860 - 0 0 0 0 0 0 0 0 0 0 0 0
38861 - 0 0 0 0 0 0 0 0 0 0 0 0
38862 - 0 0 0 0 0 0 0 0 0 0 0 0
38863 - 0 0 0 0 0 0 0 0 0 0 0 0
38864 - 0 0 0 0 0 0 0 0 0 0 0 0
38865 - 0 0 0 0 0 0 0 0 0 0 0 0
38866 - 0 0 0 0 0 0 0 0 0 0 0 0
38867 - 0 0 0 0 0 0 0 0 0 0 0 0
38868 - 0 0 0 0 0 0 0 0 0 0 0 0
38869 - 0 0 0 0 0 0 0 0 0 0 0 0
38870 - 0 0 0 0 0 0 0 0 0 0 0 0
38871 - 0 0 0 6 6 6 10 10 10 14 14 14
38872 - 22 22 22 26 26 26 30 30 30 34 34 34
38873 - 30 30 30 30 30 30 26 26 26 18 18 18
38874 - 14 14 14 10 10 10 6 6 6 0 0 0
38875 - 0 0 0 0 0 0 0 0 0 0 0 0
38876 - 0 0 0 0 0 0 0 0 0 0 0 0
38877 - 0 0 0 0 0 0 0 0 0 0 0 0
38878 - 0 0 0 0 0 0 0 0 0 0 0 0
38879 - 0 0 0 0 0 0 0 0 0 0 0 0
38880 - 0 0 0 0 0 0 0 0 0 0 0 0
38881 - 0 0 0 0 0 0 0 0 0 0 0 0
38882 - 0 0 0 0 0 0 0 0 0 0 0 0
38883 - 0 0 0 0 0 0 0 0 0 0 0 0
38884 - 0 0 0 0 0 1 0 0 1 0 0 0
38885 - 0 0 0 0 0 0 0 0 0 0 0 0
38886 - 0 0 0 0 0 0 0 0 0 0 0 0
38887 - 0 0 0 0 0 0 0 0 0 0 0 0
38888 - 0 0 0 0 0 0 0 0 0 0 0 0
38889 - 0 0 0 0 0 0 0 0 0 0 0 0
38890 - 0 0 0 0 0 0 0 0 0 0 0 0
38891 - 6 6 6 14 14 14 26 26 26 42 42 42
38892 - 54 54 54 66 66 66 78 78 78 78 78 78
38893 - 78 78 78 74 74 74 66 66 66 54 54 54
38894 - 42 42 42 26 26 26 18 18 18 10 10 10
38895 - 6 6 6 0 0 0 0 0 0 0 0 0
38896 - 0 0 0 0 0 0 0 0 0 0 0 0
38897 - 0 0 0 0 0 0 0 0 0 0 0 0
38898 - 0 0 0 0 0 0 0 0 0 0 0 0
38899 - 0 0 0 0 0 0 0 0 0 0 0 0
38900 - 0 0 0 0 0 0 0 0 0 0 0 0
38901 - 0 0 0 0 0 0 0 0 0 0 0 0
38902 - 0 0 0 0 0 0 0 0 0 0 0 0
38903 - 0 0 0 0 0 0 0 0 0 0 0 0
38904 - 0 0 1 0 0 0 0 0 0 0 0 0
38905 - 0 0 0 0 0 0 0 0 0 0 0 0
38906 - 0 0 0 0 0 0 0 0 0 0 0 0
38907 - 0 0 0 0 0 0 0 0 0 0 0 0
38908 - 0 0 0 0 0 0 0 0 0 0 0 0
38909 - 0 0 0 0 0 0 0 0 0 0 0 0
38910 - 0 0 0 0 0 0 0 0 0 10 10 10
38911 - 22 22 22 42 42 42 66 66 66 86 86 86
38912 - 66 66 66 38 38 38 38 38 38 22 22 22
38913 - 26 26 26 34 34 34 54 54 54 66 66 66
38914 - 86 86 86 70 70 70 46 46 46 26 26 26
38915 - 14 14 14 6 6 6 0 0 0 0 0 0
38916 - 0 0 0 0 0 0 0 0 0 0 0 0
38917 - 0 0 0 0 0 0 0 0 0 0 0 0
38918 - 0 0 0 0 0 0 0 0 0 0 0 0
38919 - 0 0 0 0 0 0 0 0 0 0 0 0
38920 - 0 0 0 0 0 0 0 0 0 0 0 0
38921 - 0 0 0 0 0 0 0 0 0 0 0 0
38922 - 0 0 0 0 0 0 0 0 0 0 0 0
38923 - 0 0 0 0 0 0 0 0 0 0 0 0
38924 - 0 0 1 0 0 1 0 0 1 0 0 0
38925 - 0 0 0 0 0 0 0 0 0 0 0 0
38926 - 0 0 0 0 0 0 0 0 0 0 0 0
38927 - 0 0 0 0 0 0 0 0 0 0 0 0
38928 - 0 0 0 0 0 0 0 0 0 0 0 0
38929 - 0 0 0 0 0 0 0 0 0 0 0 0
38930 - 0 0 0 0 0 0 10 10 10 26 26 26
38931 - 50 50 50 82 82 82 58 58 58 6 6 6
38932 - 2 2 6 2 2 6 2 2 6 2 2 6
38933 - 2 2 6 2 2 6 2 2 6 2 2 6
38934 - 6 6 6 54 54 54 86 86 86 66 66 66
38935 - 38 38 38 18 18 18 6 6 6 0 0 0
38936 - 0 0 0 0 0 0 0 0 0 0 0 0
38937 - 0 0 0 0 0 0 0 0 0 0 0 0
38938 - 0 0 0 0 0 0 0 0 0 0 0 0
38939 - 0 0 0 0 0 0 0 0 0 0 0 0
38940 - 0 0 0 0 0 0 0 0 0 0 0 0
38941 - 0 0 0 0 0 0 0 0 0 0 0 0
38942 - 0 0 0 0 0 0 0 0 0 0 0 0
38943 - 0 0 0 0 0 0 0 0 0 0 0 0
38944 - 0 0 0 0 0 0 0 0 0 0 0 0
38945 - 0 0 0 0 0 0 0 0 0 0 0 0
38946 - 0 0 0 0 0 0 0 0 0 0 0 0
38947 - 0 0 0 0 0 0 0 0 0 0 0 0
38948 - 0 0 0 0 0 0 0 0 0 0 0 0
38949 - 0 0 0 0 0 0 0 0 0 0 0 0
38950 - 0 0 0 6 6 6 22 22 22 50 50 50
38951 - 78 78 78 34 34 34 2 2 6 2 2 6
38952 - 2 2 6 2 2 6 2 2 6 2 2 6
38953 - 2 2 6 2 2 6 2 2 6 2 2 6
38954 - 2 2 6 2 2 6 6 6 6 70 70 70
38955 - 78 78 78 46 46 46 22 22 22 6 6 6
38956 - 0 0 0 0 0 0 0 0 0 0 0 0
38957 - 0 0 0 0 0 0 0 0 0 0 0 0
38958 - 0 0 0 0 0 0 0 0 0 0 0 0
38959 - 0 0 0 0 0 0 0 0 0 0 0 0
38960 - 0 0 0 0 0 0 0 0 0 0 0 0
38961 - 0 0 0 0 0 0 0 0 0 0 0 0
38962 - 0 0 0 0 0 0 0 0 0 0 0 0
38963 - 0 0 0 0 0 0 0 0 0 0 0 0
38964 - 0 0 1 0 0 1 0 0 1 0 0 0
38965 - 0 0 0 0 0 0 0 0 0 0 0 0
38966 - 0 0 0 0 0 0 0 0 0 0 0 0
38967 - 0 0 0 0 0 0 0 0 0 0 0 0
38968 - 0 0 0 0 0 0 0 0 0 0 0 0
38969 - 0 0 0 0 0 0 0 0 0 0 0 0
38970 - 6 6 6 18 18 18 42 42 42 82 82 82
38971 - 26 26 26 2 2 6 2 2 6 2 2 6
38972 - 2 2 6 2 2 6 2 2 6 2 2 6
38973 - 2 2 6 2 2 6 2 2 6 14 14 14
38974 - 46 46 46 34 34 34 6 6 6 2 2 6
38975 - 42 42 42 78 78 78 42 42 42 18 18 18
38976 - 6 6 6 0 0 0 0 0 0 0 0 0
38977 - 0 0 0 0 0 0 0 0 0 0 0 0
38978 - 0 0 0 0 0 0 0 0 0 0 0 0
38979 - 0 0 0 0 0 0 0 0 0 0 0 0
38980 - 0 0 0 0 0 0 0 0 0 0 0 0
38981 - 0 0 0 0 0 0 0 0 0 0 0 0
38982 - 0 0 0 0 0 0 0 0 0 0 0 0
38983 - 0 0 0 0 0 0 0 0 0 0 0 0
38984 - 0 0 1 0 0 0 0 0 1 0 0 0
38985 - 0 0 0 0 0 0 0 0 0 0 0 0
38986 - 0 0 0 0 0 0 0 0 0 0 0 0
38987 - 0 0 0 0 0 0 0 0 0 0 0 0
38988 - 0 0 0 0 0 0 0 0 0 0 0 0
38989 - 0 0 0 0 0 0 0 0 0 0 0 0
38990 - 10 10 10 30 30 30 66 66 66 58 58 58
38991 - 2 2 6 2 2 6 2 2 6 2 2 6
38992 - 2 2 6 2 2 6 2 2 6 2 2 6
38993 - 2 2 6 2 2 6 2 2 6 26 26 26
38994 - 86 86 86 101 101 101 46 46 46 10 10 10
38995 - 2 2 6 58 58 58 70 70 70 34 34 34
38996 - 10 10 10 0 0 0 0 0 0 0 0 0
38997 - 0 0 0 0 0 0 0 0 0 0 0 0
38998 - 0 0 0 0 0 0 0 0 0 0 0 0
38999 - 0 0 0 0 0 0 0 0 0 0 0 0
39000 - 0 0 0 0 0 0 0 0 0 0 0 0
39001 - 0 0 0 0 0 0 0 0 0 0 0 0
39002 - 0 0 0 0 0 0 0 0 0 0 0 0
39003 - 0 0 0 0 0 0 0 0 0 0 0 0
39004 - 0 0 1 0 0 1 0 0 1 0 0 0
39005 - 0 0 0 0 0 0 0 0 0 0 0 0
39006 - 0 0 0 0 0 0 0 0 0 0 0 0
39007 - 0 0 0 0 0 0 0 0 0 0 0 0
39008 - 0 0 0 0 0 0 0 0 0 0 0 0
39009 - 0 0 0 0 0 0 0 0 0 0 0 0
39010 - 14 14 14 42 42 42 86 86 86 10 10 10
39011 - 2 2 6 2 2 6 2 2 6 2 2 6
39012 - 2 2 6 2 2 6 2 2 6 2 2 6
39013 - 2 2 6 2 2 6 2 2 6 30 30 30
39014 - 94 94 94 94 94 94 58 58 58 26 26 26
39015 - 2 2 6 6 6 6 78 78 78 54 54 54
39016 - 22 22 22 6 6 6 0 0 0 0 0 0
39017 - 0 0 0 0 0 0 0 0 0 0 0 0
39018 - 0 0 0 0 0 0 0 0 0 0 0 0
39019 - 0 0 0 0 0 0 0 0 0 0 0 0
39020 - 0 0 0 0 0 0 0 0 0 0 0 0
39021 - 0 0 0 0 0 0 0 0 0 0 0 0
39022 - 0 0 0 0 0 0 0 0 0 0 0 0
39023 - 0 0 0 0 0 0 0 0 0 0 0 0
39024 - 0 0 0 0 0 0 0 0 0 0 0 0
39025 - 0 0 0 0 0 0 0 0 0 0 0 0
39026 - 0 0 0 0 0 0 0 0 0 0 0 0
39027 - 0 0 0 0 0 0 0 0 0 0 0 0
39028 - 0 0 0 0 0 0 0 0 0 0 0 0
39029 - 0 0 0 0 0 0 0 0 0 6 6 6
39030 - 22 22 22 62 62 62 62 62 62 2 2 6
39031 - 2 2 6 2 2 6 2 2 6 2 2 6
39032 - 2 2 6 2 2 6 2 2 6 2 2 6
39033 - 2 2 6 2 2 6 2 2 6 26 26 26
39034 - 54 54 54 38 38 38 18 18 18 10 10 10
39035 - 2 2 6 2 2 6 34 34 34 82 82 82
39036 - 38 38 38 14 14 14 0 0 0 0 0 0
39037 - 0 0 0 0 0 0 0 0 0 0 0 0
39038 - 0 0 0 0 0 0 0 0 0 0 0 0
39039 - 0 0 0 0 0 0 0 0 0 0 0 0
39040 - 0 0 0 0 0 0 0 0 0 0 0 0
39041 - 0 0 0 0 0 0 0 0 0 0 0 0
39042 - 0 0 0 0 0 0 0 0 0 0 0 0
39043 - 0 0 0 0 0 0 0 0 0 0 0 0
39044 - 0 0 0 0 0 1 0 0 1 0 0 0
39045 - 0 0 0 0 0 0 0 0 0 0 0 0
39046 - 0 0 0 0 0 0 0 0 0 0 0 0
39047 - 0 0 0 0 0 0 0 0 0 0 0 0
39048 - 0 0 0 0 0 0 0 0 0 0 0 0
39049 - 0 0 0 0 0 0 0 0 0 6 6 6
39050 - 30 30 30 78 78 78 30 30 30 2 2 6
39051 - 2 2 6 2 2 6 2 2 6 2 2 6
39052 - 2 2 6 2 2 6 2 2 6 2 2 6
39053 - 2 2 6 2 2 6 2 2 6 10 10 10
39054 - 10 10 10 2 2 6 2 2 6 2 2 6
39055 - 2 2 6 2 2 6 2 2 6 78 78 78
39056 - 50 50 50 18 18 18 6 6 6 0 0 0
39057 - 0 0 0 0 0 0 0 0 0 0 0 0
39058 - 0 0 0 0 0 0 0 0 0 0 0 0
39059 - 0 0 0 0 0 0 0 0 0 0 0 0
39060 - 0 0 0 0 0 0 0 0 0 0 0 0
39061 - 0 0 0 0 0 0 0 0 0 0 0 0
39062 - 0 0 0 0 0 0 0 0 0 0 0 0
39063 - 0 0 0 0 0 0 0 0 0 0 0 0
39064 - 0 0 1 0 0 0 0 0 0 0 0 0
39065 - 0 0 0 0 0 0 0 0 0 0 0 0
39066 - 0 0 0 0 0 0 0 0 0 0 0 0
39067 - 0 0 0 0 0 0 0 0 0 0 0 0
39068 - 0 0 0 0 0 0 0 0 0 0 0 0
39069 - 0 0 0 0 0 0 0 0 0 10 10 10
39070 - 38 38 38 86 86 86 14 14 14 2 2 6
39071 - 2 2 6 2 2 6 2 2 6 2 2 6
39072 - 2 2 6 2 2 6 2 2 6 2 2 6
39073 - 2 2 6 2 2 6 2 2 6 2 2 6
39074 - 2 2 6 2 2 6 2 2 6 2 2 6
39075 - 2 2 6 2 2 6 2 2 6 54 54 54
39076 - 66 66 66 26 26 26 6 6 6 0 0 0
39077 - 0 0 0 0 0 0 0 0 0 0 0 0
39078 - 0 0 0 0 0 0 0 0 0 0 0 0
39079 - 0 0 0 0 0 0 0 0 0 0 0 0
39080 - 0 0 0 0 0 0 0 0 0 0 0 0
39081 - 0 0 0 0 0 0 0 0 0 0 0 0
39082 - 0 0 0 0 0 0 0 0 0 0 0 0
39083 - 0 0 0 0 0 0 0 0 0 0 0 0
39084 - 0 0 0 0 0 1 0 0 1 0 0 0
39085 - 0 0 0 0 0 0 0 0 0 0 0 0
39086 - 0 0 0 0 0 0 0 0 0 0 0 0
39087 - 0 0 0 0 0 0 0 0 0 0 0 0
39088 - 0 0 0 0 0 0 0 0 0 0 0 0
39089 - 0 0 0 0 0 0 0 0 0 14 14 14
39090 - 42 42 42 82 82 82 2 2 6 2 2 6
39091 - 2 2 6 6 6 6 10 10 10 2 2 6
39092 - 2 2 6 2 2 6 2 2 6 2 2 6
39093 - 2 2 6 2 2 6 2 2 6 6 6 6
39094 - 14 14 14 10 10 10 2 2 6 2 2 6
39095 - 2 2 6 2 2 6 2 2 6 18 18 18
39096 - 82 82 82 34 34 34 10 10 10 0 0 0
39097 - 0 0 0 0 0 0 0 0 0 0 0 0
39098 - 0 0 0 0 0 0 0 0 0 0 0 0
39099 - 0 0 0 0 0 0 0 0 0 0 0 0
39100 - 0 0 0 0 0 0 0 0 0 0 0 0
39101 - 0 0 0 0 0 0 0 0 0 0 0 0
39102 - 0 0 0 0 0 0 0 0 0 0 0 0
39103 - 0 0 0 0 0 0 0 0 0 0 0 0
39104 - 0 0 1 0 0 0 0 0 0 0 0 0
39105 - 0 0 0 0 0 0 0 0 0 0 0 0
39106 - 0 0 0 0 0 0 0 0 0 0 0 0
39107 - 0 0 0 0 0 0 0 0 0 0 0 0
39108 - 0 0 0 0 0 0 0 0 0 0 0 0
39109 - 0 0 0 0 0 0 0 0 0 14 14 14
39110 - 46 46 46 86 86 86 2 2 6 2 2 6
39111 - 6 6 6 6 6 6 22 22 22 34 34 34
39112 - 6 6 6 2 2 6 2 2 6 2 2 6
39113 - 2 2 6 2 2 6 18 18 18 34 34 34
39114 - 10 10 10 50 50 50 22 22 22 2 2 6
39115 - 2 2 6 2 2 6 2 2 6 10 10 10
39116 - 86 86 86 42 42 42 14 14 14 0 0 0
39117 - 0 0 0 0 0 0 0 0 0 0 0 0
39118 - 0 0 0 0 0 0 0 0 0 0 0 0
39119 - 0 0 0 0 0 0 0 0 0 0 0 0
39120 - 0 0 0 0 0 0 0 0 0 0 0 0
39121 - 0 0 0 0 0 0 0 0 0 0 0 0
39122 - 0 0 0 0 0 0 0 0 0 0 0 0
39123 - 0 0 0 0 0 0 0 0 0 0 0 0
39124 - 0 0 1 0 0 1 0 0 1 0 0 0
39125 - 0 0 0 0 0 0 0 0 0 0 0 0
39126 - 0 0 0 0 0 0 0 0 0 0 0 0
39127 - 0 0 0 0 0 0 0 0 0 0 0 0
39128 - 0 0 0 0 0 0 0 0 0 0 0 0
39129 - 0 0 0 0 0 0 0 0 0 14 14 14
39130 - 46 46 46 86 86 86 2 2 6 2 2 6
39131 - 38 38 38 116 116 116 94 94 94 22 22 22
39132 - 22 22 22 2 2 6 2 2 6 2 2 6
39133 - 14 14 14 86 86 86 138 138 138 162 162 162
39134 -154 154 154 38 38 38 26 26 26 6 6 6
39135 - 2 2 6 2 2 6 2 2 6 2 2 6
39136 - 86 86 86 46 46 46 14 14 14 0 0 0
39137 - 0 0 0 0 0 0 0 0 0 0 0 0
39138 - 0 0 0 0 0 0 0 0 0 0 0 0
39139 - 0 0 0 0 0 0 0 0 0 0 0 0
39140 - 0 0 0 0 0 0 0 0 0 0 0 0
39141 - 0 0 0 0 0 0 0 0 0 0 0 0
39142 - 0 0 0 0 0 0 0 0 0 0 0 0
39143 - 0 0 0 0 0 0 0 0 0 0 0 0
39144 - 0 0 0 0 0 0 0 0 0 0 0 0
39145 - 0 0 0 0 0 0 0 0 0 0 0 0
39146 - 0 0 0 0 0 0 0 0 0 0 0 0
39147 - 0 0 0 0 0 0 0 0 0 0 0 0
39148 - 0 0 0 0 0 0 0 0 0 0 0 0
39149 - 0 0 0 0 0 0 0 0 0 14 14 14
39150 - 46 46 46 86 86 86 2 2 6 14 14 14
39151 -134 134 134 198 198 198 195 195 195 116 116 116
39152 - 10 10 10 2 2 6 2 2 6 6 6 6
39153 -101 98 89 187 187 187 210 210 210 218 218 218
39154 -214 214 214 134 134 134 14 14 14 6 6 6
39155 - 2 2 6 2 2 6 2 2 6 2 2 6
39156 - 86 86 86 50 50 50 18 18 18 6 6 6
39157 - 0 0 0 0 0 0 0 0 0 0 0 0
39158 - 0 0 0 0 0 0 0 0 0 0 0 0
39159 - 0 0 0 0 0 0 0 0 0 0 0 0
39160 - 0 0 0 0 0 0 0 0 0 0 0 0
39161 - 0 0 0 0 0 0 0 0 0 0 0 0
39162 - 0 0 0 0 0 0 0 0 0 0 0 0
39163 - 0 0 0 0 0 0 0 0 1 0 0 0
39164 - 0 0 1 0 0 1 0 0 1 0 0 0
39165 - 0 0 0 0 0 0 0 0 0 0 0 0
39166 - 0 0 0 0 0 0 0 0 0 0 0 0
39167 - 0 0 0 0 0 0 0 0 0 0 0 0
39168 - 0 0 0 0 0 0 0 0 0 0 0 0
39169 - 0 0 0 0 0 0 0 0 0 14 14 14
39170 - 46 46 46 86 86 86 2 2 6 54 54 54
39171 -218 218 218 195 195 195 226 226 226 246 246 246
39172 - 58 58 58 2 2 6 2 2 6 30 30 30
39173 -210 210 210 253 253 253 174 174 174 123 123 123
39174 -221 221 221 234 234 234 74 74 74 2 2 6
39175 - 2 2 6 2 2 6 2 2 6 2 2 6
39176 - 70 70 70 58 58 58 22 22 22 6 6 6
39177 - 0 0 0 0 0 0 0 0 0 0 0 0
39178 - 0 0 0 0 0 0 0 0 0 0 0 0
39179 - 0 0 0 0 0 0 0 0 0 0 0 0
39180 - 0 0 0 0 0 0 0 0 0 0 0 0
39181 - 0 0 0 0 0 0 0 0 0 0 0 0
39182 - 0 0 0 0 0 0 0 0 0 0 0 0
39183 - 0 0 0 0 0 0 0 0 0 0 0 0
39184 - 0 0 0 0 0 0 0 0 0 0 0 0
39185 - 0 0 0 0 0 0 0 0 0 0 0 0
39186 - 0 0 0 0 0 0 0 0 0 0 0 0
39187 - 0 0 0 0 0 0 0 0 0 0 0 0
39188 - 0 0 0 0 0 0 0 0 0 0 0 0
39189 - 0 0 0 0 0 0 0 0 0 14 14 14
39190 - 46 46 46 82 82 82 2 2 6 106 106 106
39191 -170 170 170 26 26 26 86 86 86 226 226 226
39192 -123 123 123 10 10 10 14 14 14 46 46 46
39193 -231 231 231 190 190 190 6 6 6 70 70 70
39194 - 90 90 90 238 238 238 158 158 158 2 2 6
39195 - 2 2 6 2 2 6 2 2 6 2 2 6
39196 - 70 70 70 58 58 58 22 22 22 6 6 6
39197 - 0 0 0 0 0 0 0 0 0 0 0 0
39198 - 0 0 0 0 0 0 0 0 0 0 0 0
39199 - 0 0 0 0 0 0 0 0 0 0 0 0
39200 - 0 0 0 0 0 0 0 0 0 0 0 0
39201 - 0 0 0 0 0 0 0 0 0 0 0 0
39202 - 0 0 0 0 0 0 0 0 0 0 0 0
39203 - 0 0 0 0 0 0 0 0 1 0 0 0
39204 - 0 0 1 0 0 1 0 0 1 0 0 0
39205 - 0 0 0 0 0 0 0 0 0 0 0 0
39206 - 0 0 0 0 0 0 0 0 0 0 0 0
39207 - 0 0 0 0 0 0 0 0 0 0 0 0
39208 - 0 0 0 0 0 0 0 0 0 0 0 0
39209 - 0 0 0 0 0 0 0 0 0 14 14 14
39210 - 42 42 42 86 86 86 6 6 6 116 116 116
39211 -106 106 106 6 6 6 70 70 70 149 149 149
39212 -128 128 128 18 18 18 38 38 38 54 54 54
39213 -221 221 221 106 106 106 2 2 6 14 14 14
39214 - 46 46 46 190 190 190 198 198 198 2 2 6
39215 - 2 2 6 2 2 6 2 2 6 2 2 6
39216 - 74 74 74 62 62 62 22 22 22 6 6 6
39217 - 0 0 0 0 0 0 0 0 0 0 0 0
39218 - 0 0 0 0 0 0 0 0 0 0 0 0
39219 - 0 0 0 0 0 0 0 0 0 0 0 0
39220 - 0 0 0 0 0 0 0 0 0 0 0 0
39221 - 0 0 0 0 0 0 0 0 0 0 0 0
39222 - 0 0 0 0 0 0 0 0 0 0 0 0
39223 - 0 0 0 0 0 0 0 0 1 0 0 0
39224 - 0 0 1 0 0 0 0 0 1 0 0 0
39225 - 0 0 0 0 0 0 0 0 0 0 0 0
39226 - 0 0 0 0 0 0 0 0 0 0 0 0
39227 - 0 0 0 0 0 0 0 0 0 0 0 0
39228 - 0 0 0 0 0 0 0 0 0 0 0 0
39229 - 0 0 0 0 0 0 0 0 0 14 14 14
39230 - 42 42 42 94 94 94 14 14 14 101 101 101
39231 -128 128 128 2 2 6 18 18 18 116 116 116
39232 -118 98 46 121 92 8 121 92 8 98 78 10
39233 -162 162 162 106 106 106 2 2 6 2 2 6
39234 - 2 2 6 195 195 195 195 195 195 6 6 6
39235 - 2 2 6 2 2 6 2 2 6 2 2 6
39236 - 74 74 74 62 62 62 22 22 22 6 6 6
39237 - 0 0 0 0 0 0 0 0 0 0 0 0
39238 - 0 0 0 0 0 0 0 0 0 0 0 0
39239 - 0 0 0 0 0 0 0 0 0 0 0 0
39240 - 0 0 0 0 0 0 0 0 0 0 0 0
39241 - 0 0 0 0 0 0 0 0 0 0 0 0
39242 - 0 0 0 0 0 0 0 0 0 0 0 0
39243 - 0 0 0 0 0 0 0 0 1 0 0 1
39244 - 0 0 1 0 0 0 0 0 1 0 0 0
39245 - 0 0 0 0 0 0 0 0 0 0 0 0
39246 - 0 0 0 0 0 0 0 0 0 0 0 0
39247 - 0 0 0 0 0 0 0 0 0 0 0 0
39248 - 0 0 0 0 0 0 0 0 0 0 0 0
39249 - 0 0 0 0 0 0 0 0 0 10 10 10
39250 - 38 38 38 90 90 90 14 14 14 58 58 58
39251 -210 210 210 26 26 26 54 38 6 154 114 10
39252 -226 170 11 236 186 11 225 175 15 184 144 12
39253 -215 174 15 175 146 61 37 26 9 2 2 6
39254 - 70 70 70 246 246 246 138 138 138 2 2 6
39255 - 2 2 6 2 2 6 2 2 6 2 2 6
39256 - 70 70 70 66 66 66 26 26 26 6 6 6
39257 - 0 0 0 0 0 0 0 0 0 0 0 0
39258 - 0 0 0 0 0 0 0 0 0 0 0 0
39259 - 0 0 0 0 0 0 0 0 0 0 0 0
39260 - 0 0 0 0 0 0 0 0 0 0 0 0
39261 - 0 0 0 0 0 0 0 0 0 0 0 0
39262 - 0 0 0 0 0 0 0 0 0 0 0 0
39263 - 0 0 0 0 0 0 0 0 0 0 0 0
39264 - 0 0 0 0 0 0 0 0 0 0 0 0
39265 - 0 0 0 0 0 0 0 0 0 0 0 0
39266 - 0 0 0 0 0 0 0 0 0 0 0 0
39267 - 0 0 0 0 0 0 0 0 0 0 0 0
39268 - 0 0 0 0 0 0 0 0 0 0 0 0
39269 - 0 0 0 0 0 0 0 0 0 10 10 10
39270 - 38 38 38 86 86 86 14 14 14 10 10 10
39271 -195 195 195 188 164 115 192 133 9 225 175 15
39272 -239 182 13 234 190 10 232 195 16 232 200 30
39273 -245 207 45 241 208 19 232 195 16 184 144 12
39274 -218 194 134 211 206 186 42 42 42 2 2 6
39275 - 2 2 6 2 2 6 2 2 6 2 2 6
39276 - 50 50 50 74 74 74 30 30 30 6 6 6
39277 - 0 0 0 0 0 0 0 0 0 0 0 0
39278 - 0 0 0 0 0 0 0 0 0 0 0 0
39279 - 0 0 0 0 0 0 0 0 0 0 0 0
39280 - 0 0 0 0 0 0 0 0 0 0 0 0
39281 - 0 0 0 0 0 0 0 0 0 0 0 0
39282 - 0 0 0 0 0 0 0 0 0 0 0 0
39283 - 0 0 0 0 0 0 0 0 0 0 0 0
39284 - 0 0 0 0 0 0 0 0 0 0 0 0
39285 - 0 0 0 0 0 0 0 0 0 0 0 0
39286 - 0 0 0 0 0 0 0 0 0 0 0 0
39287 - 0 0 0 0 0 0 0 0 0 0 0 0
39288 - 0 0 0 0 0 0 0 0 0 0 0 0
39289 - 0 0 0 0 0 0 0 0 0 10 10 10
39290 - 34 34 34 86 86 86 14 14 14 2 2 6
39291 -121 87 25 192 133 9 219 162 10 239 182 13
39292 -236 186 11 232 195 16 241 208 19 244 214 54
39293 -246 218 60 246 218 38 246 215 20 241 208 19
39294 -241 208 19 226 184 13 121 87 25 2 2 6
39295 - 2 2 6 2 2 6 2 2 6 2 2 6
39296 - 50 50 50 82 82 82 34 34 34 10 10 10
39297 - 0 0 0 0 0 0 0 0 0 0 0 0
39298 - 0 0 0 0 0 0 0 0 0 0 0 0
39299 - 0 0 0 0 0 0 0 0 0 0 0 0
39300 - 0 0 0 0 0 0 0 0 0 0 0 0
39301 - 0 0 0 0 0 0 0 0 0 0 0 0
39302 - 0 0 0 0 0 0 0 0 0 0 0 0
39303 - 0 0 0 0 0 0 0 0 0 0 0 0
39304 - 0 0 0 0 0 0 0 0 0 0 0 0
39305 - 0 0 0 0 0 0 0 0 0 0 0 0
39306 - 0 0 0 0 0 0 0 0 0 0 0 0
39307 - 0 0 0 0 0 0 0 0 0 0 0 0
39308 - 0 0 0 0 0 0 0 0 0 0 0 0
39309 - 0 0 0 0 0 0 0 0 0 10 10 10
39310 - 34 34 34 82 82 82 30 30 30 61 42 6
39311 -180 123 7 206 145 10 230 174 11 239 182 13
39312 -234 190 10 238 202 15 241 208 19 246 218 74
39313 -246 218 38 246 215 20 246 215 20 246 215 20
39314 -226 184 13 215 174 15 184 144 12 6 6 6
39315 - 2 2 6 2 2 6 2 2 6 2 2 6
39316 - 26 26 26 94 94 94 42 42 42 14 14 14
39317 - 0 0 0 0 0 0 0 0 0 0 0 0
39318 - 0 0 0 0 0 0 0 0 0 0 0 0
39319 - 0 0 0 0 0 0 0 0 0 0 0 0
39320 - 0 0 0 0 0 0 0 0 0 0 0 0
39321 - 0 0 0 0 0 0 0 0 0 0 0 0
39322 - 0 0 0 0 0 0 0 0 0 0 0 0
39323 - 0 0 0 0 0 0 0 0 0 0 0 0
39324 - 0 0 0 0 0 0 0 0 0 0 0 0
39325 - 0 0 0 0 0 0 0 0 0 0 0 0
39326 - 0 0 0 0 0 0 0 0 0 0 0 0
39327 - 0 0 0 0 0 0 0 0 0 0 0 0
39328 - 0 0 0 0 0 0 0 0 0 0 0 0
39329 - 0 0 0 0 0 0 0 0 0 10 10 10
39330 - 30 30 30 78 78 78 50 50 50 104 69 6
39331 -192 133 9 216 158 10 236 178 12 236 186 11
39332 -232 195 16 241 208 19 244 214 54 245 215 43
39333 -246 215 20 246 215 20 241 208 19 198 155 10
39334 -200 144 11 216 158 10 156 118 10 2 2 6
39335 - 2 2 6 2 2 6 2 2 6 2 2 6
39336 - 6 6 6 90 90 90 54 54 54 18 18 18
39337 - 6 6 6 0 0 0 0 0 0 0 0 0
39338 - 0 0 0 0 0 0 0 0 0 0 0 0
39339 - 0 0 0 0 0 0 0 0 0 0 0 0
39340 - 0 0 0 0 0 0 0 0 0 0 0 0
39341 - 0 0 0 0 0 0 0 0 0 0 0 0
39342 - 0 0 0 0 0 0 0 0 0 0 0 0
39343 - 0 0 0 0 0 0 0 0 0 0 0 0
39344 - 0 0 0 0 0 0 0 0 0 0 0 0
39345 - 0 0 0 0 0 0 0 0 0 0 0 0
39346 - 0 0 0 0 0 0 0 0 0 0 0 0
39347 - 0 0 0 0 0 0 0 0 0 0 0 0
39348 - 0 0 0 0 0 0 0 0 0 0 0 0
39349 - 0 0 0 0 0 0 0 0 0 10 10 10
39350 - 30 30 30 78 78 78 46 46 46 22 22 22
39351 -137 92 6 210 162 10 239 182 13 238 190 10
39352 -238 202 15 241 208 19 246 215 20 246 215 20
39353 -241 208 19 203 166 17 185 133 11 210 150 10
39354 -216 158 10 210 150 10 102 78 10 2 2 6
39355 - 6 6 6 54 54 54 14 14 14 2 2 6
39356 - 2 2 6 62 62 62 74 74 74 30 30 30
39357 - 10 10 10 0 0 0 0 0 0 0 0 0
39358 - 0 0 0 0 0 0 0 0 0 0 0 0
39359 - 0 0 0 0 0 0 0 0 0 0 0 0
39360 - 0 0 0 0 0 0 0 0 0 0 0 0
39361 - 0 0 0 0 0 0 0 0 0 0 0 0
39362 - 0 0 0 0 0 0 0 0 0 0 0 0
39363 - 0 0 0 0 0 0 0 0 0 0 0 0
39364 - 0 0 0 0 0 0 0 0 0 0 0 0
39365 - 0 0 0 0 0 0 0 0 0 0 0 0
39366 - 0 0 0 0 0 0 0 0 0 0 0 0
39367 - 0 0 0 0 0 0 0 0 0 0 0 0
39368 - 0 0 0 0 0 0 0 0 0 0 0 0
39369 - 0 0 0 0 0 0 0 0 0 10 10 10
39370 - 34 34 34 78 78 78 50 50 50 6 6 6
39371 - 94 70 30 139 102 15 190 146 13 226 184 13
39372 -232 200 30 232 195 16 215 174 15 190 146 13
39373 -168 122 10 192 133 9 210 150 10 213 154 11
39374 -202 150 34 182 157 106 101 98 89 2 2 6
39375 - 2 2 6 78 78 78 116 116 116 58 58 58
39376 - 2 2 6 22 22 22 90 90 90 46 46 46
39377 - 18 18 18 6 6 6 0 0 0 0 0 0
39378 - 0 0 0 0 0 0 0 0 0 0 0 0
39379 - 0 0 0 0 0 0 0 0 0 0 0 0
39380 - 0 0 0 0 0 0 0 0 0 0 0 0
39381 - 0 0 0 0 0 0 0 0 0 0 0 0
39382 - 0 0 0 0 0 0 0 0 0 0 0 0
39383 - 0 0 0 0 0 0 0 0 0 0 0 0
39384 - 0 0 0 0 0 0 0 0 0 0 0 0
39385 - 0 0 0 0 0 0 0 0 0 0 0 0
39386 - 0 0 0 0 0 0 0 0 0 0 0 0
39387 - 0 0 0 0 0 0 0 0 0 0 0 0
39388 - 0 0 0 0 0 0 0 0 0 0 0 0
39389 - 0 0 0 0 0 0 0 0 0 10 10 10
39390 - 38 38 38 86 86 86 50 50 50 6 6 6
39391 -128 128 128 174 154 114 156 107 11 168 122 10
39392 -198 155 10 184 144 12 197 138 11 200 144 11
39393 -206 145 10 206 145 10 197 138 11 188 164 115
39394 -195 195 195 198 198 198 174 174 174 14 14 14
39395 - 2 2 6 22 22 22 116 116 116 116 116 116
39396 - 22 22 22 2 2 6 74 74 74 70 70 70
39397 - 30 30 30 10 10 10 0 0 0 0 0 0
39398 - 0 0 0 0 0 0 0 0 0 0 0 0
39399 - 0 0 0 0 0 0 0 0 0 0 0 0
39400 - 0 0 0 0 0 0 0 0 0 0 0 0
39401 - 0 0 0 0 0 0 0 0 0 0 0 0
39402 - 0 0 0 0 0 0 0 0 0 0 0 0
39403 - 0 0 0 0 0 0 0 0 0 0 0 0
39404 - 0 0 0 0 0 0 0 0 0 0 0 0
39405 - 0 0 0 0 0 0 0 0 0 0 0 0
39406 - 0 0 0 0 0 0 0 0 0 0 0 0
39407 - 0 0 0 0 0 0 0 0 0 0 0 0
39408 - 0 0 0 0 0 0 0 0 0 0 0 0
39409 - 0 0 0 0 0 0 6 6 6 18 18 18
39410 - 50 50 50 101 101 101 26 26 26 10 10 10
39411 -138 138 138 190 190 190 174 154 114 156 107 11
39412 -197 138 11 200 144 11 197 138 11 192 133 9
39413 -180 123 7 190 142 34 190 178 144 187 187 187
39414 -202 202 202 221 221 221 214 214 214 66 66 66
39415 - 2 2 6 2 2 6 50 50 50 62 62 62
39416 - 6 6 6 2 2 6 10 10 10 90 90 90
39417 - 50 50 50 18 18 18 6 6 6 0 0 0
39418 - 0 0 0 0 0 0 0 0 0 0 0 0
39419 - 0 0 0 0 0 0 0 0 0 0 0 0
39420 - 0 0 0 0 0 0 0 0 0 0 0 0
39421 - 0 0 0 0 0 0 0 0 0 0 0 0
39422 - 0 0 0 0 0 0 0 0 0 0 0 0
39423 - 0 0 0 0 0 0 0 0 0 0 0 0
39424 - 0 0 0 0 0 0 0 0 0 0 0 0
39425 - 0 0 0 0 0 0 0 0 0 0 0 0
39426 - 0 0 0 0 0 0 0 0 0 0 0 0
39427 - 0 0 0 0 0 0 0 0 0 0 0 0
39428 - 0 0 0 0 0 0 0 0 0 0 0 0
39429 - 0 0 0 0 0 0 10 10 10 34 34 34
39430 - 74 74 74 74 74 74 2 2 6 6 6 6
39431 -144 144 144 198 198 198 190 190 190 178 166 146
39432 -154 121 60 156 107 11 156 107 11 168 124 44
39433 -174 154 114 187 187 187 190 190 190 210 210 210
39434 -246 246 246 253 253 253 253 253 253 182 182 182
39435 - 6 6 6 2 2 6 2 2 6 2 2 6
39436 - 2 2 6 2 2 6 2 2 6 62 62 62
39437 - 74 74 74 34 34 34 14 14 14 0 0 0
39438 - 0 0 0 0 0 0 0 0 0 0 0 0
39439 - 0 0 0 0 0 0 0 0 0 0 0 0
39440 - 0 0 0 0 0 0 0 0 0 0 0 0
39441 - 0 0 0 0 0 0 0 0 0 0 0 0
39442 - 0 0 0 0 0 0 0 0 0 0 0 0
39443 - 0 0 0 0 0 0 0 0 0 0 0 0
39444 - 0 0 0 0 0 0 0 0 0 0 0 0
39445 - 0 0 0 0 0 0 0 0 0 0 0 0
39446 - 0 0 0 0 0 0 0 0 0 0 0 0
39447 - 0 0 0 0 0 0 0 0 0 0 0 0
39448 - 0 0 0 0 0 0 0 0 0 0 0 0
39449 - 0 0 0 10 10 10 22 22 22 54 54 54
39450 - 94 94 94 18 18 18 2 2 6 46 46 46
39451 -234 234 234 221 221 221 190 190 190 190 190 190
39452 -190 190 190 187 187 187 187 187 187 190 190 190
39453 -190 190 190 195 195 195 214 214 214 242 242 242
39454 -253 253 253 253 253 253 253 253 253 253 253 253
39455 - 82 82 82 2 2 6 2 2 6 2 2 6
39456 - 2 2 6 2 2 6 2 2 6 14 14 14
39457 - 86 86 86 54 54 54 22 22 22 6 6 6
39458 - 0 0 0 0 0 0 0 0 0 0 0 0
39459 - 0 0 0 0 0 0 0 0 0 0 0 0
39460 - 0 0 0 0 0 0 0 0 0 0 0 0
39461 - 0 0 0 0 0 0 0 0 0 0 0 0
39462 - 0 0 0 0 0 0 0 0 0 0 0 0
39463 - 0 0 0 0 0 0 0 0 0 0 0 0
39464 - 0 0 0 0 0 0 0 0 0 0 0 0
39465 - 0 0 0 0 0 0 0 0 0 0 0 0
39466 - 0 0 0 0 0 0 0 0 0 0 0 0
39467 - 0 0 0 0 0 0 0 0 0 0 0 0
39468 - 0 0 0 0 0 0 0 0 0 0 0 0
39469 - 6 6 6 18 18 18 46 46 46 90 90 90
39470 - 46 46 46 18 18 18 6 6 6 182 182 182
39471 -253 253 253 246 246 246 206 206 206 190 190 190
39472 -190 190 190 190 190 190 190 190 190 190 190 190
39473 -206 206 206 231 231 231 250 250 250 253 253 253
39474 -253 253 253 253 253 253 253 253 253 253 253 253
39475 -202 202 202 14 14 14 2 2 6 2 2 6
39476 - 2 2 6 2 2 6 2 2 6 2 2 6
39477 - 42 42 42 86 86 86 42 42 42 18 18 18
39478 - 6 6 6 0 0 0 0 0 0 0 0 0
39479 - 0 0 0 0 0 0 0 0 0 0 0 0
39480 - 0 0 0 0 0 0 0 0 0 0 0 0
39481 - 0 0 0 0 0 0 0 0 0 0 0 0
39482 - 0 0 0 0 0 0 0 0 0 0 0 0
39483 - 0 0 0 0 0 0 0 0 0 0 0 0
39484 - 0 0 0 0 0 0 0 0 0 0 0 0
39485 - 0 0 0 0 0 0 0 0 0 0 0 0
39486 - 0 0 0 0 0 0 0 0 0 0 0 0
39487 - 0 0 0 0 0 0 0 0 0 0 0 0
39488 - 0 0 0 0 0 0 0 0 0 6 6 6
39489 - 14 14 14 38 38 38 74 74 74 66 66 66
39490 - 2 2 6 6 6 6 90 90 90 250 250 250
39491 -253 253 253 253 253 253 238 238 238 198 198 198
39492 -190 190 190 190 190 190 195 195 195 221 221 221
39493 -246 246 246 253 253 253 253 253 253 253 253 253
39494 -253 253 253 253 253 253 253 253 253 253 253 253
39495 -253 253 253 82 82 82 2 2 6 2 2 6
39496 - 2 2 6 2 2 6 2 2 6 2 2 6
39497 - 2 2 6 78 78 78 70 70 70 34 34 34
39498 - 14 14 14 6 6 6 0 0 0 0 0 0
39499 - 0 0 0 0 0 0 0 0 0 0 0 0
39500 - 0 0 0 0 0 0 0 0 0 0 0 0
39501 - 0 0 0 0 0 0 0 0 0 0 0 0
39502 - 0 0 0 0 0 0 0 0 0 0 0 0
39503 - 0 0 0 0 0 0 0 0 0 0 0 0
39504 - 0 0 0 0 0 0 0 0 0 0 0 0
39505 - 0 0 0 0 0 0 0 0 0 0 0 0
39506 - 0 0 0 0 0 0 0 0 0 0 0 0
39507 - 0 0 0 0 0 0 0 0 0 0 0 0
39508 - 0 0 0 0 0 0 0 0 0 14 14 14
39509 - 34 34 34 66 66 66 78 78 78 6 6 6
39510 - 2 2 6 18 18 18 218 218 218 253 253 253
39511 -253 253 253 253 253 253 253 253 253 246 246 246
39512 -226 226 226 231 231 231 246 246 246 253 253 253
39513 -253 253 253 253 253 253 253 253 253 253 253 253
39514 -253 253 253 253 253 253 253 253 253 253 253 253
39515 -253 253 253 178 178 178 2 2 6 2 2 6
39516 - 2 2 6 2 2 6 2 2 6 2 2 6
39517 - 2 2 6 18 18 18 90 90 90 62 62 62
39518 - 30 30 30 10 10 10 0 0 0 0 0 0
39519 - 0 0 0 0 0 0 0 0 0 0 0 0
39520 - 0 0 0 0 0 0 0 0 0 0 0 0
39521 - 0 0 0 0 0 0 0 0 0 0 0 0
39522 - 0 0 0 0 0 0 0 0 0 0 0 0
39523 - 0 0 0 0 0 0 0 0 0 0 0 0
39524 - 0 0 0 0 0 0 0 0 0 0 0 0
39525 - 0 0 0 0 0 0 0 0 0 0 0 0
39526 - 0 0 0 0 0 0 0 0 0 0 0 0
39527 - 0 0 0 0 0 0 0 0 0 0 0 0
39528 - 0 0 0 0 0 0 10 10 10 26 26 26
39529 - 58 58 58 90 90 90 18 18 18 2 2 6
39530 - 2 2 6 110 110 110 253 253 253 253 253 253
39531 -253 253 253 253 253 253 253 253 253 253 253 253
39532 -250 250 250 253 253 253 253 253 253 253 253 253
39533 -253 253 253 253 253 253 253 253 253 253 253 253
39534 -253 253 253 253 253 253 253 253 253 253 253 253
39535 -253 253 253 231 231 231 18 18 18 2 2 6
39536 - 2 2 6 2 2 6 2 2 6 2 2 6
39537 - 2 2 6 2 2 6 18 18 18 94 94 94
39538 - 54 54 54 26 26 26 10 10 10 0 0 0
39539 - 0 0 0 0 0 0 0 0 0 0 0 0
39540 - 0 0 0 0 0 0 0 0 0 0 0 0
39541 - 0 0 0 0 0 0 0 0 0 0 0 0
39542 - 0 0 0 0 0 0 0 0 0 0 0 0
39543 - 0 0 0 0 0 0 0 0 0 0 0 0
39544 - 0 0 0 0 0 0 0 0 0 0 0 0
39545 - 0 0 0 0 0 0 0 0 0 0 0 0
39546 - 0 0 0 0 0 0 0 0 0 0 0 0
39547 - 0 0 0 0 0 0 0 0 0 0 0 0
39548 - 0 0 0 6 6 6 22 22 22 50 50 50
39549 - 90 90 90 26 26 26 2 2 6 2 2 6
39550 - 14 14 14 195 195 195 250 250 250 253 253 253
39551 -253 253 253 253 253 253 253 253 253 253 253 253
39552 -253 253 253 253 253 253 253 253 253 253 253 253
39553 -253 253 253 253 253 253 253 253 253 253 253 253
39554 -253 253 253 253 253 253 253 253 253 253 253 253
39555 -250 250 250 242 242 242 54 54 54 2 2 6
39556 - 2 2 6 2 2 6 2 2 6 2 2 6
39557 - 2 2 6 2 2 6 2 2 6 38 38 38
39558 - 86 86 86 50 50 50 22 22 22 6 6 6
39559 - 0 0 0 0 0 0 0 0 0 0 0 0
39560 - 0 0 0 0 0 0 0 0 0 0 0 0
39561 - 0 0 0 0 0 0 0 0 0 0 0 0
39562 - 0 0 0 0 0 0 0 0 0 0 0 0
39563 - 0 0 0 0 0 0 0 0 0 0 0 0
39564 - 0 0 0 0 0 0 0 0 0 0 0 0
39565 - 0 0 0 0 0 0 0 0 0 0 0 0
39566 - 0 0 0 0 0 0 0 0 0 0 0 0
39567 - 0 0 0 0 0 0 0 0 0 0 0 0
39568 - 6 6 6 14 14 14 38 38 38 82 82 82
39569 - 34 34 34 2 2 6 2 2 6 2 2 6
39570 - 42 42 42 195 195 195 246 246 246 253 253 253
39571 -253 253 253 253 253 253 253 253 253 250 250 250
39572 -242 242 242 242 242 242 250 250 250 253 253 253
39573 -253 253 253 253 253 253 253 253 253 253 253 253
39574 -253 253 253 250 250 250 246 246 246 238 238 238
39575 -226 226 226 231 231 231 101 101 101 6 6 6
39576 - 2 2 6 2 2 6 2 2 6 2 2 6
39577 - 2 2 6 2 2 6 2 2 6 2 2 6
39578 - 38 38 38 82 82 82 42 42 42 14 14 14
39579 - 6 6 6 0 0 0 0 0 0 0 0 0
39580 - 0 0 0 0 0 0 0 0 0 0 0 0
39581 - 0 0 0 0 0 0 0 0 0 0 0 0
39582 - 0 0 0 0 0 0 0 0 0 0 0 0
39583 - 0 0 0 0 0 0 0 0 0 0 0 0
39584 - 0 0 0 0 0 0 0 0 0 0 0 0
39585 - 0 0 0 0 0 0 0 0 0 0 0 0
39586 - 0 0 0 0 0 0 0 0 0 0 0 0
39587 - 0 0 0 0 0 0 0 0 0 0 0 0
39588 - 10 10 10 26 26 26 62 62 62 66 66 66
39589 - 2 2 6 2 2 6 2 2 6 6 6 6
39590 - 70 70 70 170 170 170 206 206 206 234 234 234
39591 -246 246 246 250 250 250 250 250 250 238 238 238
39592 -226 226 226 231 231 231 238 238 238 250 250 250
39593 -250 250 250 250 250 250 246 246 246 231 231 231
39594 -214 214 214 206 206 206 202 202 202 202 202 202
39595 -198 198 198 202 202 202 182 182 182 18 18 18
39596 - 2 2 6 2 2 6 2 2 6 2 2 6
39597 - 2 2 6 2 2 6 2 2 6 2 2 6
39598 - 2 2 6 62 62 62 66 66 66 30 30 30
39599 - 10 10 10 0 0 0 0 0 0 0 0 0
39600 - 0 0 0 0 0 0 0 0 0 0 0 0
39601 - 0 0 0 0 0 0 0 0 0 0 0 0
39602 - 0 0 0 0 0 0 0 0 0 0 0 0
39603 - 0 0 0 0 0 0 0 0 0 0 0 0
39604 - 0 0 0 0 0 0 0 0 0 0 0 0
39605 - 0 0 0 0 0 0 0 0 0 0 0 0
39606 - 0 0 0 0 0 0 0 0 0 0 0 0
39607 - 0 0 0 0 0 0 0 0 0 0 0 0
39608 - 14 14 14 42 42 42 82 82 82 18 18 18
39609 - 2 2 6 2 2 6 2 2 6 10 10 10
39610 - 94 94 94 182 182 182 218 218 218 242 242 242
39611 -250 250 250 253 253 253 253 253 253 250 250 250
39612 -234 234 234 253 253 253 253 253 253 253 253 253
39613 -253 253 253 253 253 253 253 253 253 246 246 246
39614 -238 238 238 226 226 226 210 210 210 202 202 202
39615 -195 195 195 195 195 195 210 210 210 158 158 158
39616 - 6 6 6 14 14 14 50 50 50 14 14 14
39617 - 2 2 6 2 2 6 2 2 6 2 2 6
39618 - 2 2 6 6 6 6 86 86 86 46 46 46
39619 - 18 18 18 6 6 6 0 0 0 0 0 0
39620 - 0 0 0 0 0 0 0 0 0 0 0 0
39621 - 0 0 0 0 0 0 0 0 0 0 0 0
39622 - 0 0 0 0 0 0 0 0 0 0 0 0
39623 - 0 0 0 0 0 0 0 0 0 0 0 0
39624 - 0 0 0 0 0 0 0 0 0 0 0 0
39625 - 0 0 0 0 0 0 0 0 0 0 0 0
39626 - 0 0 0 0 0 0 0 0 0 0 0 0
39627 - 0 0 0 0 0 0 0 0 0 6 6 6
39628 - 22 22 22 54 54 54 70 70 70 2 2 6
39629 - 2 2 6 10 10 10 2 2 6 22 22 22
39630 -166 166 166 231 231 231 250 250 250 253 253 253
39631 -253 253 253 253 253 253 253 253 253 250 250 250
39632 -242 242 242 253 253 253 253 253 253 253 253 253
39633 -253 253 253 253 253 253 253 253 253 253 253 253
39634 -253 253 253 253 253 253 253 253 253 246 246 246
39635 -231 231 231 206 206 206 198 198 198 226 226 226
39636 - 94 94 94 2 2 6 6 6 6 38 38 38
39637 - 30 30 30 2 2 6 2 2 6 2 2 6
39638 - 2 2 6 2 2 6 62 62 62 66 66 66
39639 - 26 26 26 10 10 10 0 0 0 0 0 0
39640 - 0 0 0 0 0 0 0 0 0 0 0 0
39641 - 0 0 0 0 0 0 0 0 0 0 0 0
39642 - 0 0 0 0 0 0 0 0 0 0 0 0
39643 - 0 0 0 0 0 0 0 0 0 0 0 0
39644 - 0 0 0 0 0 0 0 0 0 0 0 0
39645 - 0 0 0 0 0 0 0 0 0 0 0 0
39646 - 0 0 0 0 0 0 0 0 0 0 0 0
39647 - 0 0 0 0 0 0 0 0 0 10 10 10
39648 - 30 30 30 74 74 74 50 50 50 2 2 6
39649 - 26 26 26 26 26 26 2 2 6 106 106 106
39650 -238 238 238 253 253 253 253 253 253 253 253 253
39651 -253 253 253 253 253 253 253 253 253 253 253 253
39652 -253 253 253 253 253 253 253 253 253 253 253 253
39653 -253 253 253 253 253 253 253 253 253 253 253 253
39654 -253 253 253 253 253 253 253 253 253 253 253 253
39655 -253 253 253 246 246 246 218 218 218 202 202 202
39656 -210 210 210 14 14 14 2 2 6 2 2 6
39657 - 30 30 30 22 22 22 2 2 6 2 2 6
39658 - 2 2 6 2 2 6 18 18 18 86 86 86
39659 - 42 42 42 14 14 14 0 0 0 0 0 0
39660 - 0 0 0 0 0 0 0 0 0 0 0 0
39661 - 0 0 0 0 0 0 0 0 0 0 0 0
39662 - 0 0 0 0 0 0 0 0 0 0 0 0
39663 - 0 0 0 0 0 0 0 0 0 0 0 0
39664 - 0 0 0 0 0 0 0 0 0 0 0 0
39665 - 0 0 0 0 0 0 0 0 0 0 0 0
39666 - 0 0 0 0 0 0 0 0 0 0 0 0
39667 - 0 0 0 0 0 0 0 0 0 14 14 14
39668 - 42 42 42 90 90 90 22 22 22 2 2 6
39669 - 42 42 42 2 2 6 18 18 18 218 218 218
39670 -253 253 253 253 253 253 253 253 253 253 253 253
39671 -253 253 253 253 253 253 253 253 253 253 253 253
39672 -253 253 253 253 253 253 253 253 253 253 253 253
39673 -253 253 253 253 253 253 253 253 253 253 253 253
39674 -253 253 253 253 253 253 253 253 253 253 253 253
39675 -253 253 253 253 253 253 250 250 250 221 221 221
39676 -218 218 218 101 101 101 2 2 6 14 14 14
39677 - 18 18 18 38 38 38 10 10 10 2 2 6
39678 - 2 2 6 2 2 6 2 2 6 78 78 78
39679 - 58 58 58 22 22 22 6 6 6 0 0 0
39680 - 0 0 0 0 0 0 0 0 0 0 0 0
39681 - 0 0 0 0 0 0 0 0 0 0 0 0
39682 - 0 0 0 0 0 0 0 0 0 0 0 0
39683 - 0 0 0 0 0 0 0 0 0 0 0 0
39684 - 0 0 0 0 0 0 0 0 0 0 0 0
39685 - 0 0 0 0 0 0 0 0 0 0 0 0
39686 - 0 0 0 0 0 0 0 0 0 0 0 0
39687 - 0 0 0 0 0 0 6 6 6 18 18 18
39688 - 54 54 54 82 82 82 2 2 6 26 26 26
39689 - 22 22 22 2 2 6 123 123 123 253 253 253
39690 -253 253 253 253 253 253 253 253 253 253 253 253
39691 -253 253 253 253 253 253 253 253 253 253 253 253
39692 -253 253 253 253 253 253 253 253 253 253 253 253
39693 -253 253 253 253 253 253 253 253 253 253 253 253
39694 -253 253 253 253 253 253 253 253 253 253 253 253
39695 -253 253 253 253 253 253 253 253 253 250 250 250
39696 -238 238 238 198 198 198 6 6 6 38 38 38
39697 - 58 58 58 26 26 26 38 38 38 2 2 6
39698 - 2 2 6 2 2 6 2 2 6 46 46 46
39699 - 78 78 78 30 30 30 10 10 10 0 0 0
39700 - 0 0 0 0 0 0 0 0 0 0 0 0
39701 - 0 0 0 0 0 0 0 0 0 0 0 0
39702 - 0 0 0 0 0 0 0 0 0 0 0 0
39703 - 0 0 0 0 0 0 0 0 0 0 0 0
39704 - 0 0 0 0 0 0 0 0 0 0 0 0
39705 - 0 0 0 0 0 0 0 0 0 0 0 0
39706 - 0 0 0 0 0 0 0 0 0 0 0 0
39707 - 0 0 0 0 0 0 10 10 10 30 30 30
39708 - 74 74 74 58 58 58 2 2 6 42 42 42
39709 - 2 2 6 22 22 22 231 231 231 253 253 253
39710 -253 253 253 253 253 253 253 253 253 253 253 253
39711 -253 253 253 253 253 253 253 253 253 250 250 250
39712 -253 253 253 253 253 253 253 253 253 253 253 253
39713 -253 253 253 253 253 253 253 253 253 253 253 253
39714 -253 253 253 253 253 253 253 253 253 253 253 253
39715 -253 253 253 253 253 253 253 253 253 253 253 253
39716 -253 253 253 246 246 246 46 46 46 38 38 38
39717 - 42 42 42 14 14 14 38 38 38 14 14 14
39718 - 2 2 6 2 2 6 2 2 6 6 6 6
39719 - 86 86 86 46 46 46 14 14 14 0 0 0
39720 - 0 0 0 0 0 0 0 0 0 0 0 0
39721 - 0 0 0 0 0 0 0 0 0 0 0 0
39722 - 0 0 0 0 0 0 0 0 0 0 0 0
39723 - 0 0 0 0 0 0 0 0 0 0 0 0
39724 - 0 0 0 0 0 0 0 0 0 0 0 0
39725 - 0 0 0 0 0 0 0 0 0 0 0 0
39726 - 0 0 0 0 0 0 0 0 0 0 0 0
39727 - 0 0 0 6 6 6 14 14 14 42 42 42
39728 - 90 90 90 18 18 18 18 18 18 26 26 26
39729 - 2 2 6 116 116 116 253 253 253 253 253 253
39730 -253 253 253 253 253 253 253 253 253 253 253 253
39731 -253 253 253 253 253 253 250 250 250 238 238 238
39732 -253 253 253 253 253 253 253 253 253 253 253 253
39733 -253 253 253 253 253 253 253 253 253 253 253 253
39734 -253 253 253 253 253 253 253 253 253 253 253 253
39735 -253 253 253 253 253 253 253 253 253 253 253 253
39736 -253 253 253 253 253 253 94 94 94 6 6 6
39737 - 2 2 6 2 2 6 10 10 10 34 34 34
39738 - 2 2 6 2 2 6 2 2 6 2 2 6
39739 - 74 74 74 58 58 58 22 22 22 6 6 6
39740 - 0 0 0 0 0 0 0 0 0 0 0 0
39741 - 0 0 0 0 0 0 0 0 0 0 0 0
39742 - 0 0 0 0 0 0 0 0 0 0 0 0
39743 - 0 0 0 0 0 0 0 0 0 0 0 0
39744 - 0 0 0 0 0 0 0 0 0 0 0 0
39745 - 0 0 0 0 0 0 0 0 0 0 0 0
39746 - 0 0 0 0 0 0 0 0 0 0 0 0
39747 - 0 0 0 10 10 10 26 26 26 66 66 66
39748 - 82 82 82 2 2 6 38 38 38 6 6 6
39749 - 14 14 14 210 210 210 253 253 253 253 253 253
39750 -253 253 253 253 253 253 253 253 253 253 253 253
39751 -253 253 253 253 253 253 246 246 246 242 242 242
39752 -253 253 253 253 253 253 253 253 253 253 253 253
39753 -253 253 253 253 253 253 253 253 253 253 253 253
39754 -253 253 253 253 253 253 253 253 253 253 253 253
39755 -253 253 253 253 253 253 253 253 253 253 253 253
39756 -253 253 253 253 253 253 144 144 144 2 2 6
39757 - 2 2 6 2 2 6 2 2 6 46 46 46
39758 - 2 2 6 2 2 6 2 2 6 2 2 6
39759 - 42 42 42 74 74 74 30 30 30 10 10 10
39760 - 0 0 0 0 0 0 0 0 0 0 0 0
39761 - 0 0 0 0 0 0 0 0 0 0 0 0
39762 - 0 0 0 0 0 0 0 0 0 0 0 0
39763 - 0 0 0 0 0 0 0 0 0 0 0 0
39764 - 0 0 0 0 0 0 0 0 0 0 0 0
39765 - 0 0 0 0 0 0 0 0 0 0 0 0
39766 - 0 0 0 0 0 0 0 0 0 0 0 0
39767 - 6 6 6 14 14 14 42 42 42 90 90 90
39768 - 26 26 26 6 6 6 42 42 42 2 2 6
39769 - 74 74 74 250 250 250 253 253 253 253 253 253
39770 -253 253 253 253 253 253 253 253 253 253 253 253
39771 -253 253 253 253 253 253 242 242 242 242 242 242
39772 -253 253 253 253 253 253 253 253 253 253 253 253
39773 -253 253 253 253 253 253 253 253 253 253 253 253
39774 -253 253 253 253 253 253 253 253 253 253 253 253
39775 -253 253 253 253 253 253 253 253 253 253 253 253
39776 -253 253 253 253 253 253 182 182 182 2 2 6
39777 - 2 2 6 2 2 6 2 2 6 46 46 46
39778 - 2 2 6 2 2 6 2 2 6 2 2 6
39779 - 10 10 10 86 86 86 38 38 38 10 10 10
39780 - 0 0 0 0 0 0 0 0 0 0 0 0
39781 - 0 0 0 0 0 0 0 0 0 0 0 0
39782 - 0 0 0 0 0 0 0 0 0 0 0 0
39783 - 0 0 0 0 0 0 0 0 0 0 0 0
39784 - 0 0 0 0 0 0 0 0 0 0 0 0
39785 - 0 0 0 0 0 0 0 0 0 0 0 0
39786 - 0 0 0 0 0 0 0 0 0 0 0 0
39787 - 10 10 10 26 26 26 66 66 66 82 82 82
39788 - 2 2 6 22 22 22 18 18 18 2 2 6
39789 -149 149 149 253 253 253 253 253 253 253 253 253
39790 -253 253 253 253 253 253 253 253 253 253 253 253
39791 -253 253 253 253 253 253 234 234 234 242 242 242
39792 -253 253 253 253 253 253 253 253 253 253 253 253
39793 -253 253 253 253 253 253 253 253 253 253 253 253
39794 -253 253 253 253 253 253 253 253 253 253 253 253
39795 -253 253 253 253 253 253 253 253 253 253 253 253
39796 -253 253 253 253 253 253 206 206 206 2 2 6
39797 - 2 2 6 2 2 6 2 2 6 38 38 38
39798 - 2 2 6 2 2 6 2 2 6 2 2 6
39799 - 6 6 6 86 86 86 46 46 46 14 14 14
39800 - 0 0 0 0 0 0 0 0 0 0 0 0
39801 - 0 0 0 0 0 0 0 0 0 0 0 0
39802 - 0 0 0 0 0 0 0 0 0 0 0 0
39803 - 0 0 0 0 0 0 0 0 0 0 0 0
39804 - 0 0 0 0 0 0 0 0 0 0 0 0
39805 - 0 0 0 0 0 0 0 0 0 0 0 0
39806 - 0 0 0 0 0 0 0 0 0 6 6 6
39807 - 18 18 18 46 46 46 86 86 86 18 18 18
39808 - 2 2 6 34 34 34 10 10 10 6 6 6
39809 -210 210 210 253 253 253 253 253 253 253 253 253
39810 -253 253 253 253 253 253 253 253 253 253 253 253
39811 -253 253 253 253 253 253 234 234 234 242 242 242
39812 -253 253 253 253 253 253 253 253 253 253 253 253
39813 -253 253 253 253 253 253 253 253 253 253 253 253
39814 -253 253 253 253 253 253 253 253 253 253 253 253
39815 -253 253 253 253 253 253 253 253 253 253 253 253
39816 -253 253 253 253 253 253 221 221 221 6 6 6
39817 - 2 2 6 2 2 6 6 6 6 30 30 30
39818 - 2 2 6 2 2 6 2 2 6 2 2 6
39819 - 2 2 6 82 82 82 54 54 54 18 18 18
39820 - 6 6 6 0 0 0 0 0 0 0 0 0
39821 - 0 0 0 0 0 0 0 0 0 0 0 0
39822 - 0 0 0 0 0 0 0 0 0 0 0 0
39823 - 0 0 0 0 0 0 0 0 0 0 0 0
39824 - 0 0 0 0 0 0 0 0 0 0 0 0
39825 - 0 0 0 0 0 0 0 0 0 0 0 0
39826 - 0 0 0 0 0 0 0 0 0 10 10 10
39827 - 26 26 26 66 66 66 62 62 62 2 2 6
39828 - 2 2 6 38 38 38 10 10 10 26 26 26
39829 -238 238 238 253 253 253 253 253 253 253 253 253
39830 -253 253 253 253 253 253 253 253 253 253 253 253
39831 -253 253 253 253 253 253 231 231 231 238 238 238
39832 -253 253 253 253 253 253 253 253 253 253 253 253
39833 -253 253 253 253 253 253 253 253 253 253 253 253
39834 -253 253 253 253 253 253 253 253 253 253 253 253
39835 -253 253 253 253 253 253 253 253 253 253 253 253
39836 -253 253 253 253 253 253 231 231 231 6 6 6
39837 - 2 2 6 2 2 6 10 10 10 30 30 30
39838 - 2 2 6 2 2 6 2 2 6 2 2 6
39839 - 2 2 6 66 66 66 58 58 58 22 22 22
39840 - 6 6 6 0 0 0 0 0 0 0 0 0
39841 - 0 0 0 0 0 0 0 0 0 0 0 0
39842 - 0 0 0 0 0 0 0 0 0 0 0 0
39843 - 0 0 0 0 0 0 0 0 0 0 0 0
39844 - 0 0 0 0 0 0 0 0 0 0 0 0
39845 - 0 0 0 0 0 0 0 0 0 0 0 0
39846 - 0 0 0 0 0 0 0 0 0 10 10 10
39847 - 38 38 38 78 78 78 6 6 6 2 2 6
39848 - 2 2 6 46 46 46 14 14 14 42 42 42
39849 -246 246 246 253 253 253 253 253 253 253 253 253
39850 -253 253 253 253 253 253 253 253 253 253 253 253
39851 -253 253 253 253 253 253 231 231 231 242 242 242
39852 -253 253 253 253 253 253 253 253 253 253 253 253
39853 -253 253 253 253 253 253 253 253 253 253 253 253
39854 -253 253 253 253 253 253 253 253 253 253 253 253
39855 -253 253 253 253 253 253 253 253 253 253 253 253
39856 -253 253 253 253 253 253 234 234 234 10 10 10
39857 - 2 2 6 2 2 6 22 22 22 14 14 14
39858 - 2 2 6 2 2 6 2 2 6 2 2 6
39859 - 2 2 6 66 66 66 62 62 62 22 22 22
39860 - 6 6 6 0 0 0 0 0 0 0 0 0
39861 - 0 0 0 0 0 0 0 0 0 0 0 0
39862 - 0 0 0 0 0 0 0 0 0 0 0 0
39863 - 0 0 0 0 0 0 0 0 0 0 0 0
39864 - 0 0 0 0 0 0 0 0 0 0 0 0
39865 - 0 0 0 0 0 0 0 0 0 0 0 0
39866 - 0 0 0 0 0 0 6 6 6 18 18 18
39867 - 50 50 50 74 74 74 2 2 6 2 2 6
39868 - 14 14 14 70 70 70 34 34 34 62 62 62
39869 -250 250 250 253 253 253 253 253 253 253 253 253
39870 -253 253 253 253 253 253 253 253 253 253 253 253
39871 -253 253 253 253 253 253 231 231 231 246 246 246
39872 -253 253 253 253 253 253 253 253 253 253 253 253
39873 -253 253 253 253 253 253 253 253 253 253 253 253
39874 -253 253 253 253 253 253 253 253 253 253 253 253
39875 -253 253 253 253 253 253 253 253 253 253 253 253
39876 -253 253 253 253 253 253 234 234 234 14 14 14
39877 - 2 2 6 2 2 6 30 30 30 2 2 6
39878 - 2 2 6 2 2 6 2 2 6 2 2 6
39879 - 2 2 6 66 66 66 62 62 62 22 22 22
39880 - 6 6 6 0 0 0 0 0 0 0 0 0
39881 - 0 0 0 0 0 0 0 0 0 0 0 0
39882 - 0 0 0 0 0 0 0 0 0 0 0 0
39883 - 0 0 0 0 0 0 0 0 0 0 0 0
39884 - 0 0 0 0 0 0 0 0 0 0 0 0
39885 - 0 0 0 0 0 0 0 0 0 0 0 0
39886 - 0 0 0 0 0 0 6 6 6 18 18 18
39887 - 54 54 54 62 62 62 2 2 6 2 2 6
39888 - 2 2 6 30 30 30 46 46 46 70 70 70
39889 -250 250 250 253 253 253 253 253 253 253 253 253
39890 -253 253 253 253 253 253 253 253 253 253 253 253
39891 -253 253 253 253 253 253 231 231 231 246 246 246
39892 -253 253 253 253 253 253 253 253 253 253 253 253
39893 -253 253 253 253 253 253 253 253 253 253 253 253
39894 -253 253 253 253 253 253 253 253 253 253 253 253
39895 -253 253 253 253 253 253 253 253 253 253 253 253
39896 -253 253 253 253 253 253 226 226 226 10 10 10
39897 - 2 2 6 6 6 6 30 30 30 2 2 6
39898 - 2 2 6 2 2 6 2 2 6 2 2 6
39899 - 2 2 6 66 66 66 58 58 58 22 22 22
39900 - 6 6 6 0 0 0 0 0 0 0 0 0
39901 - 0 0 0 0 0 0 0 0 0 0 0 0
39902 - 0 0 0 0 0 0 0 0 0 0 0 0
39903 - 0 0 0 0 0 0 0 0 0 0 0 0
39904 - 0 0 0 0 0 0 0 0 0 0 0 0
39905 - 0 0 0 0 0 0 0 0 0 0 0 0
39906 - 0 0 0 0 0 0 6 6 6 22 22 22
39907 - 58 58 58 62 62 62 2 2 6 2 2 6
39908 - 2 2 6 2 2 6 30 30 30 78 78 78
39909 -250 250 250 253 253 253 253 253 253 253 253 253
39910 -253 253 253 253 253 253 253 253 253 253 253 253
39911 -253 253 253 253 253 253 231 231 231 246 246 246
39912 -253 253 253 253 253 253 253 253 253 253 253 253
39913 -253 253 253 253 253 253 253 253 253 253 253 253
39914 -253 253 253 253 253 253 253 253 253 253 253 253
39915 -253 253 253 253 253 253 253 253 253 253 253 253
39916 -253 253 253 253 253 253 206 206 206 2 2 6
39917 - 22 22 22 34 34 34 18 14 6 22 22 22
39918 - 26 26 26 18 18 18 6 6 6 2 2 6
39919 - 2 2 6 82 82 82 54 54 54 18 18 18
39920 - 6 6 6 0 0 0 0 0 0 0 0 0
39921 - 0 0 0 0 0 0 0 0 0 0 0 0
39922 - 0 0 0 0 0 0 0 0 0 0 0 0
39923 - 0 0 0 0 0 0 0 0 0 0 0 0
39924 - 0 0 0 0 0 0 0 0 0 0 0 0
39925 - 0 0 0 0 0 0 0 0 0 0 0 0
39926 - 0 0 0 0 0 0 6 6 6 26 26 26
39927 - 62 62 62 106 106 106 74 54 14 185 133 11
39928 -210 162 10 121 92 8 6 6 6 62 62 62
39929 -238 238 238 253 253 253 253 253 253 253 253 253
39930 -253 253 253 253 253 253 253 253 253 253 253 253
39931 -253 253 253 253 253 253 231 231 231 246 246 246
39932 -253 253 253 253 253 253 253 253 253 253 253 253
39933 -253 253 253 253 253 253 253 253 253 253 253 253
39934 -253 253 253 253 253 253 253 253 253 253 253 253
39935 -253 253 253 253 253 253 253 253 253 253 253 253
39936 -253 253 253 253 253 253 158 158 158 18 18 18
39937 - 14 14 14 2 2 6 2 2 6 2 2 6
39938 - 6 6 6 18 18 18 66 66 66 38 38 38
39939 - 6 6 6 94 94 94 50 50 50 18 18 18
39940 - 6 6 6 0 0 0 0 0 0 0 0 0
39941 - 0 0 0 0 0 0 0 0 0 0 0 0
39942 - 0 0 0 0 0 0 0 0 0 0 0 0
39943 - 0 0 0 0 0 0 0 0 0 0 0 0
39944 - 0 0 0 0 0 0 0 0 0 0 0 0
39945 - 0 0 0 0 0 0 0 0 0 6 6 6
39946 - 10 10 10 10 10 10 18 18 18 38 38 38
39947 - 78 78 78 142 134 106 216 158 10 242 186 14
39948 -246 190 14 246 190 14 156 118 10 10 10 10
39949 - 90 90 90 238 238 238 253 253 253 253 253 253
39950 -253 253 253 253 253 253 253 253 253 253 253 253
39951 -253 253 253 253 253 253 231 231 231 250 250 250
39952 -253 253 253 253 253 253 253 253 253 253 253 253
39953 -253 253 253 253 253 253 253 253 253 253 253 253
39954 -253 253 253 253 253 253 253 253 253 253 253 253
39955 -253 253 253 253 253 253 253 253 253 246 230 190
39956 -238 204 91 238 204 91 181 142 44 37 26 9
39957 - 2 2 6 2 2 6 2 2 6 2 2 6
39958 - 2 2 6 2 2 6 38 38 38 46 46 46
39959 - 26 26 26 106 106 106 54 54 54 18 18 18
39960 - 6 6 6 0 0 0 0 0 0 0 0 0
39961 - 0 0 0 0 0 0 0 0 0 0 0 0
39962 - 0 0 0 0 0 0 0 0 0 0 0 0
39963 - 0 0 0 0 0 0 0 0 0 0 0 0
39964 - 0 0 0 0 0 0 0 0 0 0 0 0
39965 - 0 0 0 6 6 6 14 14 14 22 22 22
39966 - 30 30 30 38 38 38 50 50 50 70 70 70
39967 -106 106 106 190 142 34 226 170 11 242 186 14
39968 -246 190 14 246 190 14 246 190 14 154 114 10
39969 - 6 6 6 74 74 74 226 226 226 253 253 253
39970 -253 253 253 253 253 253 253 253 253 253 253 253
39971 -253 253 253 253 253 253 231 231 231 250 250 250
39972 -253 253 253 253 253 253 253 253 253 253 253 253
39973 -253 253 253 253 253 253 253 253 253 253 253 253
39974 -253 253 253 253 253 253 253 253 253 253 253 253
39975 -253 253 253 253 253 253 253 253 253 228 184 62
39976 -241 196 14 241 208 19 232 195 16 38 30 10
39977 - 2 2 6 2 2 6 2 2 6 2 2 6
39978 - 2 2 6 6 6 6 30 30 30 26 26 26
39979 -203 166 17 154 142 90 66 66 66 26 26 26
39980 - 6 6 6 0 0 0 0 0 0 0 0 0
39981 - 0 0 0 0 0 0 0 0 0 0 0 0
39982 - 0 0 0 0 0 0 0 0 0 0 0 0
39983 - 0 0 0 0 0 0 0 0 0 0 0 0
39984 - 0 0 0 0 0 0 0 0 0 0 0 0
39985 - 6 6 6 18 18 18 38 38 38 58 58 58
39986 - 78 78 78 86 86 86 101 101 101 123 123 123
39987 -175 146 61 210 150 10 234 174 13 246 186 14
39988 -246 190 14 246 190 14 246 190 14 238 190 10
39989 -102 78 10 2 2 6 46 46 46 198 198 198
39990 -253 253 253 253 253 253 253 253 253 253 253 253
39991 -253 253 253 253 253 253 234 234 234 242 242 242
39992 -253 253 253 253 253 253 253 253 253 253 253 253
39993 -253 253 253 253 253 253 253 253 253 253 253 253
39994 -253 253 253 253 253 253 253 253 253 253 253 253
39995 -253 253 253 253 253 253 253 253 253 224 178 62
39996 -242 186 14 241 196 14 210 166 10 22 18 6
39997 - 2 2 6 2 2 6 2 2 6 2 2 6
39998 - 2 2 6 2 2 6 6 6 6 121 92 8
39999 -238 202 15 232 195 16 82 82 82 34 34 34
40000 - 10 10 10 0 0 0 0 0 0 0 0 0
40001 - 0 0 0 0 0 0 0 0 0 0 0 0
40002 - 0 0 0 0 0 0 0 0 0 0 0 0
40003 - 0 0 0 0 0 0 0 0 0 0 0 0
40004 - 0 0 0 0 0 0 0 0 0 0 0 0
40005 - 14 14 14 38 38 38 70 70 70 154 122 46
40006 -190 142 34 200 144 11 197 138 11 197 138 11
40007 -213 154 11 226 170 11 242 186 14 246 190 14
40008 -246 190 14 246 190 14 246 190 14 246 190 14
40009 -225 175 15 46 32 6 2 2 6 22 22 22
40010 -158 158 158 250 250 250 253 253 253 253 253 253
40011 -253 253 253 253 253 253 253 253 253 253 253 253
40012 -253 253 253 253 253 253 253 253 253 253 253 253
40013 -253 253 253 253 253 253 253 253 253 253 253 253
40014 -253 253 253 253 253 253 253 253 253 253 253 253
40015 -253 253 253 250 250 250 242 242 242 224 178 62
40016 -239 182 13 236 186 11 213 154 11 46 32 6
40017 - 2 2 6 2 2 6 2 2 6 2 2 6
40018 - 2 2 6 2 2 6 61 42 6 225 175 15
40019 -238 190 10 236 186 11 112 100 78 42 42 42
40020 - 14 14 14 0 0 0 0 0 0 0 0 0
40021 - 0 0 0 0 0 0 0 0 0 0 0 0
40022 - 0 0 0 0 0 0 0 0 0 0 0 0
40023 - 0 0 0 0 0 0 0 0 0 0 0 0
40024 - 0 0 0 0 0 0 0 0 0 6 6 6
40025 - 22 22 22 54 54 54 154 122 46 213 154 11
40026 -226 170 11 230 174 11 226 170 11 226 170 11
40027 -236 178 12 242 186 14 246 190 14 246 190 14
40028 -246 190 14 246 190 14 246 190 14 246 190 14
40029 -241 196 14 184 144 12 10 10 10 2 2 6
40030 - 6 6 6 116 116 116 242 242 242 253 253 253
40031 -253 253 253 253 253 253 253 253 253 253 253 253
40032 -253 253 253 253 253 253 253 253 253 253 253 253
40033 -253 253 253 253 253 253 253 253 253 253 253 253
40034 -253 253 253 253 253 253 253 253 253 253 253 253
40035 -253 253 253 231 231 231 198 198 198 214 170 54
40036 -236 178 12 236 178 12 210 150 10 137 92 6
40037 - 18 14 6 2 2 6 2 2 6 2 2 6
40038 - 6 6 6 70 47 6 200 144 11 236 178 12
40039 -239 182 13 239 182 13 124 112 88 58 58 58
40040 - 22 22 22 6 6 6 0 0 0 0 0 0
40041 - 0 0 0 0 0 0 0 0 0 0 0 0
40042 - 0 0 0 0 0 0 0 0 0 0 0 0
40043 - 0 0 0 0 0 0 0 0 0 0 0 0
40044 - 0 0 0 0 0 0 0 0 0 10 10 10
40045 - 30 30 30 70 70 70 180 133 36 226 170 11
40046 -239 182 13 242 186 14 242 186 14 246 186 14
40047 -246 190 14 246 190 14 246 190 14 246 190 14
40048 -246 190 14 246 190 14 246 190 14 246 190 14
40049 -246 190 14 232 195 16 98 70 6 2 2 6
40050 - 2 2 6 2 2 6 66 66 66 221 221 221
40051 -253 253 253 253 253 253 253 253 253 253 253 253
40052 -253 253 253 253 253 253 253 253 253 253 253 253
40053 -253 253 253 253 253 253 253 253 253 253 253 253
40054 -253 253 253 253 253 253 253 253 253 253 253 253
40055 -253 253 253 206 206 206 198 198 198 214 166 58
40056 -230 174 11 230 174 11 216 158 10 192 133 9
40057 -163 110 8 116 81 8 102 78 10 116 81 8
40058 -167 114 7 197 138 11 226 170 11 239 182 13
40059 -242 186 14 242 186 14 162 146 94 78 78 78
40060 - 34 34 34 14 14 14 6 6 6 0 0 0
40061 - 0 0 0 0 0 0 0 0 0 0 0 0
40062 - 0 0 0 0 0 0 0 0 0 0 0 0
40063 - 0 0 0 0 0 0 0 0 0 0 0 0
40064 - 0 0 0 0 0 0 0 0 0 6 6 6
40065 - 30 30 30 78 78 78 190 142 34 226 170 11
40066 -239 182 13 246 190 14 246 190 14 246 190 14
40067 -246 190 14 246 190 14 246 190 14 246 190 14
40068 -246 190 14 246 190 14 246 190 14 246 190 14
40069 -246 190 14 241 196 14 203 166 17 22 18 6
40070 - 2 2 6 2 2 6 2 2 6 38 38 38
40071 -218 218 218 253 253 253 253 253 253 253 253 253
40072 -253 253 253 253 253 253 253 253 253 253 253 253
40073 -253 253 253 253 253 253 253 253 253 253 253 253
40074 -253 253 253 253 253 253 253 253 253 253 253 253
40075 -250 250 250 206 206 206 198 198 198 202 162 69
40076 -226 170 11 236 178 12 224 166 10 210 150 10
40077 -200 144 11 197 138 11 192 133 9 197 138 11
40078 -210 150 10 226 170 11 242 186 14 246 190 14
40079 -246 190 14 246 186 14 225 175 15 124 112 88
40080 - 62 62 62 30 30 30 14 14 14 6 6 6
40081 - 0 0 0 0 0 0 0 0 0 0 0 0
40082 - 0 0 0 0 0 0 0 0 0 0 0 0
40083 - 0 0 0 0 0 0 0 0 0 0 0 0
40084 - 0 0 0 0 0 0 0 0 0 10 10 10
40085 - 30 30 30 78 78 78 174 135 50 224 166 10
40086 -239 182 13 246 190 14 246 190 14 246 190 14
40087 -246 190 14 246 190 14 246 190 14 246 190 14
40088 -246 190 14 246 190 14 246 190 14 246 190 14
40089 -246 190 14 246 190 14 241 196 14 139 102 15
40090 - 2 2 6 2 2 6 2 2 6 2 2 6
40091 - 78 78 78 250 250 250 253 253 253 253 253 253
40092 -253 253 253 253 253 253 253 253 253 253 253 253
40093 -253 253 253 253 253 253 253 253 253 253 253 253
40094 -253 253 253 253 253 253 253 253 253 253 253 253
40095 -250 250 250 214 214 214 198 198 198 190 150 46
40096 -219 162 10 236 178 12 234 174 13 224 166 10
40097 -216 158 10 213 154 11 213 154 11 216 158 10
40098 -226 170 11 239 182 13 246 190 14 246 190 14
40099 -246 190 14 246 190 14 242 186 14 206 162 42
40100 -101 101 101 58 58 58 30 30 30 14 14 14
40101 - 6 6 6 0 0 0 0 0 0 0 0 0
40102 - 0 0 0 0 0 0 0 0 0 0 0 0
40103 - 0 0 0 0 0 0 0 0 0 0 0 0
40104 - 0 0 0 0 0 0 0 0 0 10 10 10
40105 - 30 30 30 74 74 74 174 135 50 216 158 10
40106 -236 178 12 246 190 14 246 190 14 246 190 14
40107 -246 190 14 246 190 14 246 190 14 246 190 14
40108 -246 190 14 246 190 14 246 190 14 246 190 14
40109 -246 190 14 246 190 14 241 196 14 226 184 13
40110 - 61 42 6 2 2 6 2 2 6 2 2 6
40111 - 22 22 22 238 238 238 253 253 253 253 253 253
40112 -253 253 253 253 253 253 253 253 253 253 253 253
40113 -253 253 253 253 253 253 253 253 253 253 253 253
40114 -253 253 253 253 253 253 253 253 253 253 253 253
40115 -253 253 253 226 226 226 187 187 187 180 133 36
40116 -216 158 10 236 178 12 239 182 13 236 178 12
40117 -230 174 11 226 170 11 226 170 11 230 174 11
40118 -236 178 12 242 186 14 246 190 14 246 190 14
40119 -246 190 14 246 190 14 246 186 14 239 182 13
40120 -206 162 42 106 106 106 66 66 66 34 34 34
40121 - 14 14 14 6 6 6 0 0 0 0 0 0
40122 - 0 0 0 0 0 0 0 0 0 0 0 0
40123 - 0 0 0 0 0 0 0 0 0 0 0 0
40124 - 0 0 0 0 0 0 0 0 0 6 6 6
40125 - 26 26 26 70 70 70 163 133 67 213 154 11
40126 -236 178 12 246 190 14 246 190 14 246 190 14
40127 -246 190 14 246 190 14 246 190 14 246 190 14
40128 -246 190 14 246 190 14 246 190 14 246 190 14
40129 -246 190 14 246 190 14 246 190 14 241 196 14
40130 -190 146 13 18 14 6 2 2 6 2 2 6
40131 - 46 46 46 246 246 246 253 253 253 253 253 253
40132 -253 253 253 253 253 253 253 253 253 253 253 253
40133 -253 253 253 253 253 253 253 253 253 253 253 253
40134 -253 253 253 253 253 253 253 253 253 253 253 253
40135 -253 253 253 221 221 221 86 86 86 156 107 11
40136 -216 158 10 236 178 12 242 186 14 246 186 14
40137 -242 186 14 239 182 13 239 182 13 242 186 14
40138 -242 186 14 246 186 14 246 190 14 246 190 14
40139 -246 190 14 246 190 14 246 190 14 246 190 14
40140 -242 186 14 225 175 15 142 122 72 66 66 66
40141 - 30 30 30 10 10 10 0 0 0 0 0 0
40142 - 0 0 0 0 0 0 0 0 0 0 0 0
40143 - 0 0 0 0 0 0 0 0 0 0 0 0
40144 - 0 0 0 0 0 0 0 0 0 6 6 6
40145 - 26 26 26 70 70 70 163 133 67 210 150 10
40146 -236 178 12 246 190 14 246 190 14 246 190 14
40147 -246 190 14 246 190 14 246 190 14 246 190 14
40148 -246 190 14 246 190 14 246 190 14 246 190 14
40149 -246 190 14 246 190 14 246 190 14 246 190 14
40150 -232 195 16 121 92 8 34 34 34 106 106 106
40151 -221 221 221 253 253 253 253 253 253 253 253 253
40152 -253 253 253 253 253 253 253 253 253 253 253 253
40153 -253 253 253 253 253 253 253 253 253 253 253 253
40154 -253 253 253 253 253 253 253 253 253 253 253 253
40155 -242 242 242 82 82 82 18 14 6 163 110 8
40156 -216 158 10 236 178 12 242 186 14 246 190 14
40157 -246 190 14 246 190 14 246 190 14 246 190 14
40158 -246 190 14 246 190 14 246 190 14 246 190 14
40159 -246 190 14 246 190 14 246 190 14 246 190 14
40160 -246 190 14 246 190 14 242 186 14 163 133 67
40161 - 46 46 46 18 18 18 6 6 6 0 0 0
40162 - 0 0 0 0 0 0 0 0 0 0 0 0
40163 - 0 0 0 0 0 0 0 0 0 0 0 0
40164 - 0 0 0 0 0 0 0 0 0 10 10 10
40165 - 30 30 30 78 78 78 163 133 67 210 150 10
40166 -236 178 12 246 186 14 246 190 14 246 190 14
40167 -246 190 14 246 190 14 246 190 14 246 190 14
40168 -246 190 14 246 190 14 246 190 14 246 190 14
40169 -246 190 14 246 190 14 246 190 14 246 190 14
40170 -241 196 14 215 174 15 190 178 144 253 253 253
40171 -253 253 253 253 253 253 253 253 253 253 253 253
40172 -253 253 253 253 253 253 253 253 253 253 253 253
40173 -253 253 253 253 253 253 253 253 253 253 253 253
40174 -253 253 253 253 253 253 253 253 253 218 218 218
40175 - 58 58 58 2 2 6 22 18 6 167 114 7
40176 -216 158 10 236 178 12 246 186 14 246 190 14
40177 -246 190 14 246 190 14 246 190 14 246 190 14
40178 -246 190 14 246 190 14 246 190 14 246 190 14
40179 -246 190 14 246 190 14 246 190 14 246 190 14
40180 -246 190 14 246 186 14 242 186 14 190 150 46
40181 - 54 54 54 22 22 22 6 6 6 0 0 0
40182 - 0 0 0 0 0 0 0 0 0 0 0 0
40183 - 0 0 0 0 0 0 0 0 0 0 0 0
40184 - 0 0 0 0 0 0 0 0 0 14 14 14
40185 - 38 38 38 86 86 86 180 133 36 213 154 11
40186 -236 178 12 246 186 14 246 190 14 246 190 14
40187 -246 190 14 246 190 14 246 190 14 246 190 14
40188 -246 190 14 246 190 14 246 190 14 246 190 14
40189 -246 190 14 246 190 14 246 190 14 246 190 14
40190 -246 190 14 232 195 16 190 146 13 214 214 214
40191 -253 253 253 253 253 253 253 253 253 253 253 253
40192 -253 253 253 253 253 253 253 253 253 253 253 253
40193 -253 253 253 253 253 253 253 253 253 253 253 253
40194 -253 253 253 250 250 250 170 170 170 26 26 26
40195 - 2 2 6 2 2 6 37 26 9 163 110 8
40196 -219 162 10 239 182 13 246 186 14 246 190 14
40197 -246 190 14 246 190 14 246 190 14 246 190 14
40198 -246 190 14 246 190 14 246 190 14 246 190 14
40199 -246 190 14 246 190 14 246 190 14 246 190 14
40200 -246 186 14 236 178 12 224 166 10 142 122 72
40201 - 46 46 46 18 18 18 6 6 6 0 0 0
40202 - 0 0 0 0 0 0 0 0 0 0 0 0
40203 - 0 0 0 0 0 0 0 0 0 0 0 0
40204 - 0 0 0 0 0 0 6 6 6 18 18 18
40205 - 50 50 50 109 106 95 192 133 9 224 166 10
40206 -242 186 14 246 190 14 246 190 14 246 190 14
40207 -246 190 14 246 190 14 246 190 14 246 190 14
40208 -246 190 14 246 190 14 246 190 14 246 190 14
40209 -246 190 14 246 190 14 246 190 14 246 190 14
40210 -242 186 14 226 184 13 210 162 10 142 110 46
40211 -226 226 226 253 253 253 253 253 253 253 253 253
40212 -253 253 253 253 253 253 253 253 253 253 253 253
40213 -253 253 253 253 253 253 253 253 253 253 253 253
40214 -198 198 198 66 66 66 2 2 6 2 2 6
40215 - 2 2 6 2 2 6 50 34 6 156 107 11
40216 -219 162 10 239 182 13 246 186 14 246 190 14
40217 -246 190 14 246 190 14 246 190 14 246 190 14
40218 -246 190 14 246 190 14 246 190 14 246 190 14
40219 -246 190 14 246 190 14 246 190 14 242 186 14
40220 -234 174 13 213 154 11 154 122 46 66 66 66
40221 - 30 30 30 10 10 10 0 0 0 0 0 0
40222 - 0 0 0 0 0 0 0 0 0 0 0 0
40223 - 0 0 0 0 0 0 0 0 0 0 0 0
40224 - 0 0 0 0 0 0 6 6 6 22 22 22
40225 - 58 58 58 154 121 60 206 145 10 234 174 13
40226 -242 186 14 246 186 14 246 190 14 246 190 14
40227 -246 190 14 246 190 14 246 190 14 246 190 14
40228 -246 190 14 246 190 14 246 190 14 246 190 14
40229 -246 190 14 246 190 14 246 190 14 246 190 14
40230 -246 186 14 236 178 12 210 162 10 163 110 8
40231 - 61 42 6 138 138 138 218 218 218 250 250 250
40232 -253 253 253 253 253 253 253 253 253 250 250 250
40233 -242 242 242 210 210 210 144 144 144 66 66 66
40234 - 6 6 6 2 2 6 2 2 6 2 2 6
40235 - 2 2 6 2 2 6 61 42 6 163 110 8
40236 -216 158 10 236 178 12 246 190 14 246 190 14
40237 -246 190 14 246 190 14 246 190 14 246 190 14
40238 -246 190 14 246 190 14 246 190 14 246 190 14
40239 -246 190 14 239 182 13 230 174 11 216 158 10
40240 -190 142 34 124 112 88 70 70 70 38 38 38
40241 - 18 18 18 6 6 6 0 0 0 0 0 0
40242 - 0 0 0 0 0 0 0 0 0 0 0 0
40243 - 0 0 0 0 0 0 0 0 0 0 0 0
40244 - 0 0 0 0 0 0 6 6 6 22 22 22
40245 - 62 62 62 168 124 44 206 145 10 224 166 10
40246 -236 178 12 239 182 13 242 186 14 242 186 14
40247 -246 186 14 246 190 14 246 190 14 246 190 14
40248 -246 190 14 246 190 14 246 190 14 246 190 14
40249 -246 190 14 246 190 14 246 190 14 246 190 14
40250 -246 190 14 236 178 12 216 158 10 175 118 6
40251 - 80 54 7 2 2 6 6 6 6 30 30 30
40252 - 54 54 54 62 62 62 50 50 50 38 38 38
40253 - 14 14 14 2 2 6 2 2 6 2 2 6
40254 - 2 2 6 2 2 6 2 2 6 2 2 6
40255 - 2 2 6 6 6 6 80 54 7 167 114 7
40256 -213 154 11 236 178 12 246 190 14 246 190 14
40257 -246 190 14 246 190 14 246 190 14 246 190 14
40258 -246 190 14 242 186 14 239 182 13 239 182 13
40259 -230 174 11 210 150 10 174 135 50 124 112 88
40260 - 82 82 82 54 54 54 34 34 34 18 18 18
40261 - 6 6 6 0 0 0 0 0 0 0 0 0
40262 - 0 0 0 0 0 0 0 0 0 0 0 0
40263 - 0 0 0 0 0 0 0 0 0 0 0 0
40264 - 0 0 0 0 0 0 6 6 6 18 18 18
40265 - 50 50 50 158 118 36 192 133 9 200 144 11
40266 -216 158 10 219 162 10 224 166 10 226 170 11
40267 -230 174 11 236 178 12 239 182 13 239 182 13
40268 -242 186 14 246 186 14 246 190 14 246 190 14
40269 -246 190 14 246 190 14 246 190 14 246 190 14
40270 -246 186 14 230 174 11 210 150 10 163 110 8
40271 -104 69 6 10 10 10 2 2 6 2 2 6
40272 - 2 2 6 2 2 6 2 2 6 2 2 6
40273 - 2 2 6 2 2 6 2 2 6 2 2 6
40274 - 2 2 6 2 2 6 2 2 6 2 2 6
40275 - 2 2 6 6 6 6 91 60 6 167 114 7
40276 -206 145 10 230 174 11 242 186 14 246 190 14
40277 -246 190 14 246 190 14 246 186 14 242 186 14
40278 -239 182 13 230 174 11 224 166 10 213 154 11
40279 -180 133 36 124 112 88 86 86 86 58 58 58
40280 - 38 38 38 22 22 22 10 10 10 6 6 6
40281 - 0 0 0 0 0 0 0 0 0 0 0 0
40282 - 0 0 0 0 0 0 0 0 0 0 0 0
40283 - 0 0 0 0 0 0 0 0 0 0 0 0
40284 - 0 0 0 0 0 0 0 0 0 14 14 14
40285 - 34 34 34 70 70 70 138 110 50 158 118 36
40286 -167 114 7 180 123 7 192 133 9 197 138 11
40287 -200 144 11 206 145 10 213 154 11 219 162 10
40288 -224 166 10 230 174 11 239 182 13 242 186 14
40289 -246 186 14 246 186 14 246 186 14 246 186 14
40290 -239 182 13 216 158 10 185 133 11 152 99 6
40291 -104 69 6 18 14 6 2 2 6 2 2 6
40292 - 2 2 6 2 2 6 2 2 6 2 2 6
40293 - 2 2 6 2 2 6 2 2 6 2 2 6
40294 - 2 2 6 2 2 6 2 2 6 2 2 6
40295 - 2 2 6 6 6 6 80 54 7 152 99 6
40296 -192 133 9 219 162 10 236 178 12 239 182 13
40297 -246 186 14 242 186 14 239 182 13 236 178 12
40298 -224 166 10 206 145 10 192 133 9 154 121 60
40299 - 94 94 94 62 62 62 42 42 42 22 22 22
40300 - 14 14 14 6 6 6 0 0 0 0 0 0
40301 - 0 0 0 0 0 0 0 0 0 0 0 0
40302 - 0 0 0 0 0 0 0 0 0 0 0 0
40303 - 0 0 0 0 0 0 0 0 0 0 0 0
40304 - 0 0 0 0 0 0 0 0 0 6 6 6
40305 - 18 18 18 34 34 34 58 58 58 78 78 78
40306 -101 98 89 124 112 88 142 110 46 156 107 11
40307 -163 110 8 167 114 7 175 118 6 180 123 7
40308 -185 133 11 197 138 11 210 150 10 219 162 10
40309 -226 170 11 236 178 12 236 178 12 234 174 13
40310 -219 162 10 197 138 11 163 110 8 130 83 6
40311 - 91 60 6 10 10 10 2 2 6 2 2 6
40312 - 18 18 18 38 38 38 38 38 38 38 38 38
40313 - 38 38 38 38 38 38 38 38 38 38 38 38
40314 - 38 38 38 38 38 38 26 26 26 2 2 6
40315 - 2 2 6 6 6 6 70 47 6 137 92 6
40316 -175 118 6 200 144 11 219 162 10 230 174 11
40317 -234 174 13 230 174 11 219 162 10 210 150 10
40318 -192 133 9 163 110 8 124 112 88 82 82 82
40319 - 50 50 50 30 30 30 14 14 14 6 6 6
40320 - 0 0 0 0 0 0 0 0 0 0 0 0
40321 - 0 0 0 0 0 0 0 0 0 0 0 0
40322 - 0 0 0 0 0 0 0 0 0 0 0 0
40323 - 0 0 0 0 0 0 0 0 0 0 0 0
40324 - 0 0 0 0 0 0 0 0 0 0 0 0
40325 - 6 6 6 14 14 14 22 22 22 34 34 34
40326 - 42 42 42 58 58 58 74 74 74 86 86 86
40327 -101 98 89 122 102 70 130 98 46 121 87 25
40328 -137 92 6 152 99 6 163 110 8 180 123 7
40329 -185 133 11 197 138 11 206 145 10 200 144 11
40330 -180 123 7 156 107 11 130 83 6 104 69 6
40331 - 50 34 6 54 54 54 110 110 110 101 98 89
40332 - 86 86 86 82 82 82 78 78 78 78 78 78
40333 - 78 78 78 78 78 78 78 78 78 78 78 78
40334 - 78 78 78 82 82 82 86 86 86 94 94 94
40335 -106 106 106 101 101 101 86 66 34 124 80 6
40336 -156 107 11 180 123 7 192 133 9 200 144 11
40337 -206 145 10 200 144 11 192 133 9 175 118 6
40338 -139 102 15 109 106 95 70 70 70 42 42 42
40339 - 22 22 22 10 10 10 0 0 0 0 0 0
40340 - 0 0 0 0 0 0 0 0 0 0 0 0
40341 - 0 0 0 0 0 0 0 0 0 0 0 0
40342 - 0 0 0 0 0 0 0 0 0 0 0 0
40343 - 0 0 0 0 0 0 0 0 0 0 0 0
40344 - 0 0 0 0 0 0 0 0 0 0 0 0
40345 - 0 0 0 0 0 0 6 6 6 10 10 10
40346 - 14 14 14 22 22 22 30 30 30 38 38 38
40347 - 50 50 50 62 62 62 74 74 74 90 90 90
40348 -101 98 89 112 100 78 121 87 25 124 80 6
40349 -137 92 6 152 99 6 152 99 6 152 99 6
40350 -138 86 6 124 80 6 98 70 6 86 66 30
40351 -101 98 89 82 82 82 58 58 58 46 46 46
40352 - 38 38 38 34 34 34 34 34 34 34 34 34
40353 - 34 34 34 34 34 34 34 34 34 34 34 34
40354 - 34 34 34 34 34 34 38 38 38 42 42 42
40355 - 54 54 54 82 82 82 94 86 76 91 60 6
40356 -134 86 6 156 107 11 167 114 7 175 118 6
40357 -175 118 6 167 114 7 152 99 6 121 87 25
40358 -101 98 89 62 62 62 34 34 34 18 18 18
40359 - 6 6 6 0 0 0 0 0 0 0 0 0
40360 - 0 0 0 0 0 0 0 0 0 0 0 0
40361 - 0 0 0 0 0 0 0 0 0 0 0 0
40362 - 0 0 0 0 0 0 0 0 0 0 0 0
40363 - 0 0 0 0 0 0 0 0 0 0 0 0
40364 - 0 0 0 0 0 0 0 0 0 0 0 0
40365 - 0 0 0 0 0 0 0 0 0 0 0 0
40366 - 0 0 0 6 6 6 6 6 6 10 10 10
40367 - 18 18 18 22 22 22 30 30 30 42 42 42
40368 - 50 50 50 66 66 66 86 86 86 101 98 89
40369 -106 86 58 98 70 6 104 69 6 104 69 6
40370 -104 69 6 91 60 6 82 62 34 90 90 90
40371 - 62 62 62 38 38 38 22 22 22 14 14 14
40372 - 10 10 10 10 10 10 10 10 10 10 10 10
40373 - 10 10 10 10 10 10 6 6 6 10 10 10
40374 - 10 10 10 10 10 10 10 10 10 14 14 14
40375 - 22 22 22 42 42 42 70 70 70 89 81 66
40376 - 80 54 7 104 69 6 124 80 6 137 92 6
40377 -134 86 6 116 81 8 100 82 52 86 86 86
40378 - 58 58 58 30 30 30 14 14 14 6 6 6
40379 - 0 0 0 0 0 0 0 0 0 0 0 0
40380 - 0 0 0 0 0 0 0 0 0 0 0 0
40381 - 0 0 0 0 0 0 0 0 0 0 0 0
40382 - 0 0 0 0 0 0 0 0 0 0 0 0
40383 - 0 0 0 0 0 0 0 0 0 0 0 0
40384 - 0 0 0 0 0 0 0 0 0 0 0 0
40385 - 0 0 0 0 0 0 0 0 0 0 0 0
40386 - 0 0 0 0 0 0 0 0 0 0 0 0
40387 - 0 0 0 6 6 6 10 10 10 14 14 14
40388 - 18 18 18 26 26 26 38 38 38 54 54 54
40389 - 70 70 70 86 86 86 94 86 76 89 81 66
40390 - 89 81 66 86 86 86 74 74 74 50 50 50
40391 - 30 30 30 14 14 14 6 6 6 0 0 0
40392 - 0 0 0 0 0 0 0 0 0 0 0 0
40393 - 0 0 0 0 0 0 0 0 0 0 0 0
40394 - 0 0 0 0 0 0 0 0 0 0 0 0
40395 - 6 6 6 18 18 18 34 34 34 58 58 58
40396 - 82 82 82 89 81 66 89 81 66 89 81 66
40397 - 94 86 66 94 86 76 74 74 74 50 50 50
40398 - 26 26 26 14 14 14 6 6 6 0 0 0
40399 - 0 0 0 0 0 0 0 0 0 0 0 0
40400 - 0 0 0 0 0 0 0 0 0 0 0 0
40401 - 0 0 0 0 0 0 0 0 0 0 0 0
40402 - 0 0 0 0 0 0 0 0 0 0 0 0
40403 - 0 0 0 0 0 0 0 0 0 0 0 0
40404 - 0 0 0 0 0 0 0 0 0 0 0 0
40405 - 0 0 0 0 0 0 0 0 0 0 0 0
40406 - 0 0 0 0 0 0 0 0 0 0 0 0
40407 - 0 0 0 0 0 0 0 0 0 0 0 0
40408 - 6 6 6 6 6 6 14 14 14 18 18 18
40409 - 30 30 30 38 38 38 46 46 46 54 54 54
40410 - 50 50 50 42 42 42 30 30 30 18 18 18
40411 - 10 10 10 0 0 0 0 0 0 0 0 0
40412 - 0 0 0 0 0 0 0 0 0 0 0 0
40413 - 0 0 0 0 0 0 0 0 0 0 0 0
40414 - 0 0 0 0 0 0 0 0 0 0 0 0
40415 - 0 0 0 6 6 6 14 14 14 26 26 26
40416 - 38 38 38 50 50 50 58 58 58 58 58 58
40417 - 54 54 54 42 42 42 30 30 30 18 18 18
40418 - 10 10 10 0 0 0 0 0 0 0 0 0
40419 - 0 0 0 0 0 0 0 0 0 0 0 0
40420 - 0 0 0 0 0 0 0 0 0 0 0 0
40421 - 0 0 0 0 0 0 0 0 0 0 0 0
40422 - 0 0 0 0 0 0 0 0 0 0 0 0
40423 - 0 0 0 0 0 0 0 0 0 0 0 0
40424 - 0 0 0 0 0 0 0 0 0 0 0 0
40425 - 0 0 0 0 0 0 0 0 0 0 0 0
40426 - 0 0 0 0 0 0 0 0 0 0 0 0
40427 - 0 0 0 0 0 0 0 0 0 0 0 0
40428 - 0 0 0 0 0 0 0 0 0 6 6 6
40429 - 6 6 6 10 10 10 14 14 14 18 18 18
40430 - 18 18 18 14 14 14 10 10 10 6 6 6
40431 - 0 0 0 0 0 0 0 0 0 0 0 0
40432 - 0 0 0 0 0 0 0 0 0 0 0 0
40433 - 0 0 0 0 0 0 0 0 0 0 0 0
40434 - 0 0 0 0 0 0 0 0 0 0 0 0
40435 - 0 0 0 0 0 0 0 0 0 6 6 6
40436 - 14 14 14 18 18 18 22 22 22 22 22 22
40437 - 18 18 18 14 14 14 10 10 10 6 6 6
40438 - 0 0 0 0 0 0 0 0 0 0 0 0
40439 - 0 0 0 0 0 0 0 0 0 0 0 0
40440 - 0 0 0 0 0 0 0 0 0 0 0 0
40441 - 0 0 0 0 0 0 0 0 0 0 0 0
40442 - 0 0 0 0 0 0 0 0 0 0 0 0
40443 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40444 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40445 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40446 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40447 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40448 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40449 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40450 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40451 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40452 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40453 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40454 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40455 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40456 +4 4 4 4 4 4
40457 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40458 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40459 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40460 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40461 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40462 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40463 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40464 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40465 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40466 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40467 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40468 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40469 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40470 +4 4 4 4 4 4
40471 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40472 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40473 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40474 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40475 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40476 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40477 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40478 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40479 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40480 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40481 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40482 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40483 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40484 +4 4 4 4 4 4
40485 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40486 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40487 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40488 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40489 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40490 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40491 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40492 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40493 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40494 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40495 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40496 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40497 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40498 +4 4 4 4 4 4
40499 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40500 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40501 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40502 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40503 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40504 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40505 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40506 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40507 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40508 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40509 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40510 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40511 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40512 +4 4 4 4 4 4
40513 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40514 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40515 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40516 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40517 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40518 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40519 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40520 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40521 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40522 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40523 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40524 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40525 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40526 +4 4 4 4 4 4
40527 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40528 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40529 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40530 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40531 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
40532 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
40533 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40534 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40535 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40536 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
40537 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
40538 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
40539 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40540 +4 4 4 4 4 4
40541 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40542 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40543 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40544 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40545 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
40546 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
40547 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40548 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40549 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40550 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
40551 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
40552 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
40553 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40554 +4 4 4 4 4 4
40555 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40556 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40557 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40558 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40559 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
40560 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
40561 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
40562 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40563 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40564 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
40565 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
40566 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
40567 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
40568 +4 4 4 4 4 4
40569 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40570 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40571 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40572 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
40573 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
40574 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
40575 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
40576 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40577 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
40578 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
40579 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
40580 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
40581 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
40582 +4 4 4 4 4 4
40583 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40584 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40585 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40586 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
40587 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
40588 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
40589 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
40590 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
40591 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
40592 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
40593 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
40594 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
40595 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
40596 +4 4 4 4 4 4
40597 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40598 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40599 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
40600 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
40601 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
40602 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
40603 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
40604 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
40605 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
40606 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
40607 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
40608 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
40609 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
40610 +4 4 4 4 4 4
40611 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40612 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40613 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
40614 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
40615 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
40616 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
40617 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
40618 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
40619 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
40620 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
40621 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
40622 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
40623 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
40624 +4 4 4 4 4 4
40625 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40626 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40627 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
40628 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
40629 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
40630 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
40631 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
40632 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
40633 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
40634 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
40635 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
40636 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
40637 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
40638 +4 4 4 4 4 4
40639 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40640 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40641 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
40642 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
40643 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
40644 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
40645 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
40646 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
40647 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
40648 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
40649 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
40650 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
40651 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
40652 +4 4 4 4 4 4
40653 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40654 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40655 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
40656 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
40657 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
40658 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
40659 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
40660 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
40661 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
40662 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
40663 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
40664 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
40665 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
40666 +4 4 4 4 4 4
40667 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40668 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
40669 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
40670 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
40671 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
40672 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
40673 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
40674 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
40675 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
40676 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
40677 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
40678 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
40679 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
40680 +4 4 4 4 4 4
40681 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40682 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
40683 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
40684 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
40685 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
40686 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
40687 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
40688 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
40689 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
40690 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
40691 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
40692 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
40693 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
40694 +0 0 0 4 4 4
40695 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
40696 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
40697 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
40698 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
40699 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
40700 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
40701 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
40702 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
40703 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
40704 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
40705 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
40706 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
40707 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
40708 +2 0 0 0 0 0
40709 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
40710 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
40711 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
40712 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
40713 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
40714 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
40715 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
40716 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
40717 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
40718 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
40719 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
40720 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
40721 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
40722 +37 38 37 0 0 0
40723 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
40724 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
40725 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
40726 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
40727 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
40728 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
40729 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
40730 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
40731 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
40732 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
40733 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
40734 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
40735 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
40736 +85 115 134 4 0 0
40737 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
40738 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
40739 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
40740 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
40741 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
40742 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
40743 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
40744 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
40745 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
40746 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
40747 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
40748 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
40749 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
40750 +60 73 81 4 0 0
40751 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
40752 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
40753 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
40754 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
40755 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
40756 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
40757 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
40758 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
40759 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
40760 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
40761 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
40762 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
40763 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
40764 +16 19 21 4 0 0
40765 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
40766 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
40767 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
40768 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
40769 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
40770 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
40771 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
40772 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
40773 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
40774 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
40775 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
40776 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
40777 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
40778 +4 0 0 4 3 3
40779 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
40780 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
40781 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
40782 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
40783 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
40784 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
40785 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
40786 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
40787 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
40788 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
40789 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
40790 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
40791 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
40792 +3 2 2 4 4 4
40793 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
40794 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
40795 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
40796 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
40797 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
40798 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
40799 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
40800 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
40801 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
40802 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
40803 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
40804 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
40805 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
40806 +4 4 4 4 4 4
40807 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
40808 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
40809 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
40810 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
40811 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
40812 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
40813 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
40814 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
40815 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
40816 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
40817 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
40818 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
40819 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
40820 +4 4 4 4 4 4
40821 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
40822 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
40823 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
40824 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
40825 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
40826 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
40827 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
40828 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
40829 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
40830 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
40831 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
40832 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
40833 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
40834 +5 5 5 5 5 5
40835 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
40836 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
40837 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
40838 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
40839 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
40840 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
40841 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
40842 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
40843 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
40844 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
40845 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
40846 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
40847 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
40848 +5 5 5 4 4 4
40849 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
40850 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
40851 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
40852 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
40853 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
40854 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
40855 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
40856 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
40857 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
40858 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
40859 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
40860 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
40861 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40862 +4 4 4 4 4 4
40863 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
40864 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
40865 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
40866 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
40867 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
40868 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
40869 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
40870 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
40871 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
40872 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
40873 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
40874 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
40875 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40876 +4 4 4 4 4 4
40877 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
40878 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
40879 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
40880 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
40881 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
40882 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
40883 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
40884 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
40885 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
40886 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
40887 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
40888 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40889 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40890 +4 4 4 4 4 4
40891 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
40892 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
40893 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
40894 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
40895 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
40896 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
40897 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
40898 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
40899 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
40900 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
40901 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
40902 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40903 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40904 +4 4 4 4 4 4
40905 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
40906 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
40907 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
40908 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
40909 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
40910 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
40911 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
40912 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
40913 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
40914 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
40915 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
40916 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40917 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40918 +4 4 4 4 4 4
40919 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
40920 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
40921 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
40922 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
40923 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
40924 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
40925 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
40926 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
40927 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
40928 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
40929 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
40930 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40931 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40932 +4 4 4 4 4 4
40933 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
40934 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
40935 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
40936 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
40937 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
40938 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
40939 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
40940 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
40941 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
40942 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
40943 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
40944 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40945 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40946 +4 4 4 4 4 4
40947 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
40948 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
40949 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
40950 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
40951 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
40952 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
40953 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
40954 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
40955 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
40956 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
40957 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
40958 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40959 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40960 +4 4 4 4 4 4
40961 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
40962 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
40963 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
40964 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
40965 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
40966 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
40967 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
40968 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
40969 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
40970 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
40971 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
40972 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40973 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40974 +4 4 4 4 4 4
40975 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
40976 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
40977 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
40978 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
40979 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
40980 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
40981 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
40982 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
40983 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
40984 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
40985 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
40986 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40987 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40988 +4 4 4 4 4 4
40989 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
40990 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
40991 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
40992 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
40993 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
40994 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
40995 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
40996 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
40997 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
40998 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
40999 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41000 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41001 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41002 +4 4 4 4 4 4
41003 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
41004 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
41005 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
41006 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
41007 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
41008 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
41009 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
41010 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
41011 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
41012 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
41013 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41014 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41015 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41016 +4 4 4 4 4 4
41017 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
41018 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
41019 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
41020 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
41021 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
41022 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
41023 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
41024 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
41025 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
41026 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
41027 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41028 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41029 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41030 +4 4 4 4 4 4
41031 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
41032 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
41033 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
41034 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
41035 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
41036 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
41037 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
41038 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
41039 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
41040 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
41041 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41042 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41043 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41044 +4 4 4 4 4 4
41045 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
41046 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
41047 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
41048 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
41049 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
41050 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
41051 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
41052 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
41053 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
41054 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
41055 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41056 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41057 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41058 +4 4 4 4 4 4
41059 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
41060 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
41061 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
41062 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
41063 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
41064 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
41065 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
41066 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
41067 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
41068 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
41069 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41070 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41071 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41072 +4 4 4 4 4 4
41073 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
41074 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
41075 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
41076 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
41077 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
41078 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
41079 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
41080 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
41081 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
41082 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
41083 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41084 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41085 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41086 +4 4 4 4 4 4
41087 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
41088 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
41089 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
41090 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
41091 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
41092 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
41093 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
41094 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
41095 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
41096 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
41097 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41098 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41099 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41100 +4 4 4 4 4 4
41101 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
41102 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
41103 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
41104 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
41105 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
41106 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
41107 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
41108 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
41109 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
41110 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
41111 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41112 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41113 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41114 +4 4 4 4 4 4
41115 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
41116 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
41117 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
41118 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
41119 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
41120 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
41121 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
41122 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
41123 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
41124 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
41125 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41126 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41127 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41128 +4 4 4 4 4 4
41129 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
41130 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
41131 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
41132 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
41133 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
41134 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
41135 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
41136 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
41137 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
41138 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
41139 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41140 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41141 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41142 +4 4 4 4 4 4
41143 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
41144 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
41145 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
41146 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
41147 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
41148 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
41149 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
41150 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
41151 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
41152 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
41153 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41154 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41155 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41156 +4 4 4 4 4 4
41157 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
41158 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
41159 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
41160 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
41161 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
41162 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
41163 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
41164 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
41165 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
41166 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
41167 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41168 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41169 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41170 +4 4 4 4 4 4
41171 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
41172 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
41173 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
41174 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
41175 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
41176 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
41177 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
41178 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
41179 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
41180 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
41181 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41182 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41183 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41184 +4 4 4 4 4 4
41185 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
41186 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
41187 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
41188 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
41189 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
41190 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
41191 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
41192 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
41193 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
41194 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
41195 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41196 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41197 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41198 +4 4 4 4 4 4
41199 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
41200 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
41201 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
41202 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
41203 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
41204 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
41205 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
41206 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
41207 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
41208 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
41209 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41210 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41211 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41212 +4 4 4 4 4 4
41213 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
41214 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
41215 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
41216 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
41217 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
41218 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
41219 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
41220 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
41221 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
41222 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
41223 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41224 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41225 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41226 +4 4 4 4 4 4
41227 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
41228 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
41229 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
41230 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
41231 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
41232 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
41233 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41234 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
41235 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
41236 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
41237 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
41238 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41239 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41240 +4 4 4 4 4 4
41241 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
41242 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
41243 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
41244 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
41245 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
41246 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
41247 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
41248 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
41249 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
41250 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
41251 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41252 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41253 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41254 +4 4 4 4 4 4
41255 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
41256 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
41257 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
41258 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
41259 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
41260 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
41261 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
41262 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
41263 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
41264 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
41265 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41266 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41267 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41268 +4 4 4 4 4 4
41269 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
41270 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
41271 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
41272 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
41273 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
41274 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
41275 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
41276 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
41277 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
41278 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
41279 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41280 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41281 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41282 +4 4 4 4 4 4
41283 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
41284 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
41285 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
41286 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
41287 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
41288 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
41289 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
41290 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
41291 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
41292 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
41293 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41294 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41295 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41296 +4 4 4 4 4 4
41297 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
41298 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
41299 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
41300 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
41301 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
41302 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
41303 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
41304 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
41305 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
41306 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
41307 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41308 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41309 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41310 +4 4 4 4 4 4
41311 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
41312 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
41313 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
41314 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
41315 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
41316 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
41317 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
41318 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
41319 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
41320 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41321 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41322 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41323 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41324 +4 4 4 4 4 4
41325 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
41326 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
41327 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
41328 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
41329 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
41330 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
41331 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
41332 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
41333 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
41334 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41335 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41336 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41337 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41338 +4 4 4 4 4 4
41339 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
41340 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
41341 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
41342 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
41343 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
41344 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
41345 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
41346 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
41347 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41348 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41349 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41350 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41351 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41352 +4 4 4 4 4 4
41353 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
41354 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
41355 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
41356 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
41357 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
41358 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
41359 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
41360 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
41361 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41362 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41363 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41364 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41365 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41366 +4 4 4 4 4 4
41367 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
41368 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
41369 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
41370 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
41371 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
41372 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
41373 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
41374 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
41375 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41376 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41377 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41378 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41379 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41380 +4 4 4 4 4 4
41381 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
41382 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
41383 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
41384 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
41385 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
41386 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
41387 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
41388 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
41389 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41390 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41391 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41392 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41393 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41394 +4 4 4 4 4 4
41395 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41396 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
41397 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
41398 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
41399 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
41400 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
41401 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
41402 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
41403 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41404 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41405 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41406 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41407 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41408 +4 4 4 4 4 4
41409 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41410 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
41411 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
41412 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
41413 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
41414 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
41415 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
41416 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
41417 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41418 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41419 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41420 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41421 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41422 +4 4 4 4 4 4
41423 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41424 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41425 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
41426 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
41427 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
41428 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
41429 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
41430 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
41431 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41432 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41433 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41434 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41435 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41436 +4 4 4 4 4 4
41437 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41438 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41439 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
41440 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
41441 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
41442 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
41443 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
41444 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41445 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41446 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41447 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41448 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41449 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41450 +4 4 4 4 4 4
41451 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41452 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41453 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41454 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
41455 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
41456 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
41457 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
41458 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41459 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41460 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41461 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41462 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41463 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41464 +4 4 4 4 4 4
41465 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41466 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41467 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41468 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
41469 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
41470 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
41471 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
41472 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41473 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41474 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41475 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41476 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41477 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41478 +4 4 4 4 4 4
41479 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41480 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41481 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41482 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
41483 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
41484 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
41485 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
41486 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41487 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41488 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41489 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41490 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41491 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41492 +4 4 4 4 4 4
41493 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41494 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41495 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41496 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
41497 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
41498 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
41499 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41500 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41501 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41502 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41503 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41504 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41505 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41506 +4 4 4 4 4 4
41507 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41508 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41509 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41510 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41511 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
41512 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
41513 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
41514 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41515 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41516 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41517 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41518 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41519 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41520 +4 4 4 4 4 4
41521 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41522 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41523 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41524 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41525 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
41526 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
41527 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41528 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41529 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41530 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41531 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41532 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41533 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41534 +4 4 4 4 4 4
41535 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41536 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41537 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41538 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41539 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
41540 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
41541 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41542 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41543 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41544 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41545 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41546 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41547 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41548 +4 4 4 4 4 4
41549 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41550 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41551 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41552 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41553 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
41554 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
41555 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41556 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41557 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41558 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41559 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41560 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41561 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41562 +4 4 4 4 4 4
41563 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
41564 index a40c05e..785c583 100644
41565 --- a/drivers/video/udlfb.c
41566 +++ b/drivers/video/udlfb.c
41567 @@ -619,11 +619,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
41568 dlfb_urb_completion(urb);
41569
41570 error:
41571 - atomic_add(bytes_sent, &dev->bytes_sent);
41572 - atomic_add(bytes_identical, &dev->bytes_identical);
41573 - atomic_add(width*height*2, &dev->bytes_rendered);
41574 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
41575 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
41576 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
41577 end_cycles = get_cycles();
41578 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
41579 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
41580 >> 10)), /* Kcycles */
41581 &dev->cpu_kcycles_used);
41582
41583 @@ -744,11 +744,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
41584 dlfb_urb_completion(urb);
41585
41586 error:
41587 - atomic_add(bytes_sent, &dev->bytes_sent);
41588 - atomic_add(bytes_identical, &dev->bytes_identical);
41589 - atomic_add(bytes_rendered, &dev->bytes_rendered);
41590 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
41591 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
41592 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
41593 end_cycles = get_cycles();
41594 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
41595 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
41596 >> 10)), /* Kcycles */
41597 &dev->cpu_kcycles_used);
41598 }
41599 @@ -1368,7 +1368,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
41600 struct fb_info *fb_info = dev_get_drvdata(fbdev);
41601 struct dlfb_data *dev = fb_info->par;
41602 return snprintf(buf, PAGE_SIZE, "%u\n",
41603 - atomic_read(&dev->bytes_rendered));
41604 + atomic_read_unchecked(&dev->bytes_rendered));
41605 }
41606
41607 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
41608 @@ -1376,7 +1376,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
41609 struct fb_info *fb_info = dev_get_drvdata(fbdev);
41610 struct dlfb_data *dev = fb_info->par;
41611 return snprintf(buf, PAGE_SIZE, "%u\n",
41612 - atomic_read(&dev->bytes_identical));
41613 + atomic_read_unchecked(&dev->bytes_identical));
41614 }
41615
41616 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
41617 @@ -1384,7 +1384,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
41618 struct fb_info *fb_info = dev_get_drvdata(fbdev);
41619 struct dlfb_data *dev = fb_info->par;
41620 return snprintf(buf, PAGE_SIZE, "%u\n",
41621 - atomic_read(&dev->bytes_sent));
41622 + atomic_read_unchecked(&dev->bytes_sent));
41623 }
41624
41625 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
41626 @@ -1392,7 +1392,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
41627 struct fb_info *fb_info = dev_get_drvdata(fbdev);
41628 struct dlfb_data *dev = fb_info->par;
41629 return snprintf(buf, PAGE_SIZE, "%u\n",
41630 - atomic_read(&dev->cpu_kcycles_used));
41631 + atomic_read_unchecked(&dev->cpu_kcycles_used));
41632 }
41633
41634 static ssize_t edid_show(
41635 @@ -1449,10 +1449,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
41636 struct fb_info *fb_info = dev_get_drvdata(fbdev);
41637 struct dlfb_data *dev = fb_info->par;
41638
41639 - atomic_set(&dev->bytes_rendered, 0);
41640 - atomic_set(&dev->bytes_identical, 0);
41641 - atomic_set(&dev->bytes_sent, 0);
41642 - atomic_set(&dev->cpu_kcycles_used, 0);
41643 + atomic_set_unchecked(&dev->bytes_rendered, 0);
41644 + atomic_set_unchecked(&dev->bytes_identical, 0);
41645 + atomic_set_unchecked(&dev->bytes_sent, 0);
41646 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
41647
41648 return count;
41649 }
41650 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
41651 index 8408543..d6f20f1 100644
41652 --- a/drivers/video/uvesafb.c
41653 +++ b/drivers/video/uvesafb.c
41654 @@ -19,6 +19,7 @@
41655 #include <linux/io.h>
41656 #include <linux/mutex.h>
41657 #include <linux/slab.h>
41658 +#include <linux/moduleloader.h>
41659 #include <video/edid.h>
41660 #include <video/uvesafb.h>
41661 #ifdef CONFIG_X86
41662 @@ -73,7 +74,7 @@ static void uvesafb_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *ns
41663 struct uvesafb_task *utask;
41664 struct uvesafb_ktask *task;
41665
41666 - if (!cap_raised(current_cap(), CAP_SYS_ADMIN))
41667 + if (!capable(CAP_SYS_ADMIN))
41668 return;
41669
41670 if (msg->seq >= UVESAFB_TASKS_MAX)
41671 @@ -121,7 +122,7 @@ static int uvesafb_helper_start(void)
41672 NULL,
41673 };
41674
41675 - return call_usermodehelper(v86d_path, argv, envp, 1);
41676 + return call_usermodehelper(v86d_path, argv, envp, UMH_WAIT_PROC);
41677 }
41678
41679 /*
41680 @@ -569,10 +570,32 @@ static int __devinit uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
41681 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
41682 par->pmi_setpal = par->ypan = 0;
41683 } else {
41684 +
41685 +#ifdef CONFIG_PAX_KERNEXEC
41686 +#ifdef CONFIG_MODULES
41687 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
41688 +#endif
41689 + if (!par->pmi_code) {
41690 + par->pmi_setpal = par->ypan = 0;
41691 + return 0;
41692 + }
41693 +#endif
41694 +
41695 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
41696 + task->t.regs.edi);
41697 +
41698 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
41699 + pax_open_kernel();
41700 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
41701 + pax_close_kernel();
41702 +
41703 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
41704 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
41705 +#else
41706 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
41707 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
41708 +#endif
41709 +
41710 printk(KERN_INFO "uvesafb: protected mode interface info at "
41711 "%04x:%04x\n",
41712 (u16)task->t.regs.es, (u16)task->t.regs.edi);
41713 @@ -816,13 +839,14 @@ static int __devinit uvesafb_vbe_init(struct fb_info *info)
41714 par->ypan = ypan;
41715
41716 if (par->pmi_setpal || par->ypan) {
41717 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
41718 if (__supported_pte_mask & _PAGE_NX) {
41719 par->pmi_setpal = par->ypan = 0;
41720 printk(KERN_WARNING "uvesafb: NX protection is actively."
41721 "We have better not to use the PMI.\n");
41722 - } else {
41723 + } else
41724 +#endif
41725 uvesafb_vbe_getpmi(task, par);
41726 - }
41727 }
41728 #else
41729 /* The protected mode interface is not available on non-x86. */
41730 @@ -1828,6 +1852,11 @@ out:
41731 if (par->vbe_modes)
41732 kfree(par->vbe_modes);
41733
41734 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
41735 + if (par->pmi_code)
41736 + module_free_exec(NULL, par->pmi_code);
41737 +#endif
41738 +
41739 framebuffer_release(info);
41740 return err;
41741 }
41742 @@ -1854,6 +1883,12 @@ static int uvesafb_remove(struct platform_device *dev)
41743 kfree(par->vbe_state_orig);
41744 if (par->vbe_state_saved)
41745 kfree(par->vbe_state_saved);
41746 +
41747 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
41748 + if (par->pmi_code)
41749 + module_free_exec(NULL, par->pmi_code);
41750 +#endif
41751 +
41752 }
41753
41754 framebuffer_release(info);
41755 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
41756 index 501b340..86bd4cf 100644
41757 --- a/drivers/video/vesafb.c
41758 +++ b/drivers/video/vesafb.c
41759 @@ -9,6 +9,7 @@
41760 */
41761
41762 #include <linux/module.h>
41763 +#include <linux/moduleloader.h>
41764 #include <linux/kernel.h>
41765 #include <linux/errno.h>
41766 #include <linux/string.h>
41767 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
41768 static int vram_total __initdata; /* Set total amount of memory */
41769 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
41770 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
41771 -static void (*pmi_start)(void) __read_mostly;
41772 -static void (*pmi_pal) (void) __read_mostly;
41773 +static void (*pmi_start)(void) __read_only;
41774 +static void (*pmi_pal) (void) __read_only;
41775 static int depth __read_mostly;
41776 static int vga_compat __read_mostly;
41777 /* --------------------------------------------------------------------- */
41778 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
41779 unsigned int size_vmode;
41780 unsigned int size_remap;
41781 unsigned int size_total;
41782 + void *pmi_code = NULL;
41783
41784 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
41785 return -ENODEV;
41786 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
41787 size_remap = size_total;
41788 vesafb_fix.smem_len = size_remap;
41789
41790 -#ifndef __i386__
41791 - screen_info.vesapm_seg = 0;
41792 -#endif
41793 -
41794 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
41795 printk(KERN_WARNING
41796 "vesafb: cannot reserve video memory at 0x%lx\n",
41797 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
41798 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
41799 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
41800
41801 +#ifdef __i386__
41802 +
41803 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
41804 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
41805 + if (!pmi_code)
41806 +#elif !defined(CONFIG_PAX_KERNEXEC)
41807 + if (0)
41808 +#endif
41809 +
41810 +#endif
41811 + screen_info.vesapm_seg = 0;
41812 +
41813 if (screen_info.vesapm_seg) {
41814 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
41815 - screen_info.vesapm_seg,screen_info.vesapm_off);
41816 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
41817 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
41818 }
41819
41820 if (screen_info.vesapm_seg < 0xc000)
41821 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
41822
41823 if (ypan || pmi_setpal) {
41824 unsigned short *pmi_base;
41825 +
41826 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
41827 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
41828 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
41829 +
41830 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
41831 + pax_open_kernel();
41832 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
41833 +#else
41834 + pmi_code = pmi_base;
41835 +#endif
41836 +
41837 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
41838 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
41839 +
41840 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
41841 + pmi_start = ktva_ktla(pmi_start);
41842 + pmi_pal = ktva_ktla(pmi_pal);
41843 + pax_close_kernel();
41844 +#endif
41845 +
41846 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
41847 if (pmi_base[3]) {
41848 printk(KERN_INFO "vesafb: pmi: ports = ");
41849 @@ -488,6 +514,11 @@ static int __init vesafb_probe(struct platform_device *dev)
41850 info->node, info->fix.id);
41851 return 0;
41852 err:
41853 +
41854 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
41855 + module_free_exec(NULL, pmi_code);
41856 +#endif
41857 +
41858 if (info->screen_base)
41859 iounmap(info->screen_base);
41860 framebuffer_release(info);
41861 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
41862 index 88714ae..16c2e11 100644
41863 --- a/drivers/video/via/via_clock.h
41864 +++ b/drivers/video/via/via_clock.h
41865 @@ -56,7 +56,7 @@ struct via_clock {
41866
41867 void (*set_engine_pll_state)(u8 state);
41868 void (*set_engine_pll)(struct via_pll_config config);
41869 -};
41870 +} __no_const;
41871
41872
41873 static inline u32 get_pll_internal_frequency(u32 ref_freq,
41874 diff --git a/drivers/xen/xen-pciback/conf_space.h b/drivers/xen/xen-pciback/conf_space.h
41875 index e56c934..fc22f4b 100644
41876 --- a/drivers/xen/xen-pciback/conf_space.h
41877 +++ b/drivers/xen/xen-pciback/conf_space.h
41878 @@ -44,15 +44,15 @@ struct config_field {
41879 struct {
41880 conf_dword_write write;
41881 conf_dword_read read;
41882 - } dw;
41883 + } __no_const dw;
41884 struct {
41885 conf_word_write write;
41886 conf_word_read read;
41887 - } w;
41888 + } __no_const w;
41889 struct {
41890 conf_byte_write write;
41891 conf_byte_read read;
41892 - } b;
41893 + } __no_const b;
41894 } u;
41895 struct list_head list;
41896 };
41897 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
41898 index 014c8dd..6f3dfe6 100644
41899 --- a/fs/9p/vfs_inode.c
41900 +++ b/fs/9p/vfs_inode.c
41901 @@ -1303,7 +1303,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
41902 void
41903 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
41904 {
41905 - char *s = nd_get_link(nd);
41906 + const char *s = nd_get_link(nd);
41907
41908 p9_debug(P9_DEBUG_VFS, " %s %s\n",
41909 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
41910 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
41911 index e95d1b6..3454244 100644
41912 --- a/fs/Kconfig.binfmt
41913 +++ b/fs/Kconfig.binfmt
41914 @@ -89,7 +89,7 @@ config HAVE_AOUT
41915
41916 config BINFMT_AOUT
41917 tristate "Kernel support for a.out and ECOFF binaries"
41918 - depends on HAVE_AOUT
41919 + depends on HAVE_AOUT && BROKEN
41920 ---help---
41921 A.out (Assembler.OUTput) is a set of formats for libraries and
41922 executables used in the earliest versions of UNIX. Linux used
41923 diff --git a/fs/aio.c b/fs/aio.c
41924 index b9d64d8..86cb1d5 100644
41925 --- a/fs/aio.c
41926 +++ b/fs/aio.c
41927 @@ -119,7 +119,7 @@ static int aio_setup_ring(struct kioctx *ctx)
41928 size += sizeof(struct io_event) * nr_events;
41929 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
41930
41931 - if (nr_pages < 0)
41932 + if (nr_pages <= 0)
41933 return -EINVAL;
41934
41935 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
41936 @@ -1461,22 +1461,27 @@ static ssize_t aio_fsync(struct kiocb *iocb)
41937 static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
41938 {
41939 ssize_t ret;
41940 + struct iovec iovstack;
41941
41942 #ifdef CONFIG_COMPAT
41943 if (compat)
41944 ret = compat_rw_copy_check_uvector(type,
41945 (struct compat_iovec __user *)kiocb->ki_buf,
41946 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
41947 + kiocb->ki_nbytes, 1, &iovstack,
41948 &kiocb->ki_iovec, 1);
41949 else
41950 #endif
41951 ret = rw_copy_check_uvector(type,
41952 (struct iovec __user *)kiocb->ki_buf,
41953 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
41954 + kiocb->ki_nbytes, 1, &iovstack,
41955 &kiocb->ki_iovec, 1);
41956 if (ret < 0)
41957 goto out;
41958
41959 + if (kiocb->ki_iovec == &iovstack) {
41960 + kiocb->ki_inline_vec = iovstack;
41961 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
41962 + }
41963 kiocb->ki_nr_segs = kiocb->ki_nbytes;
41964 kiocb->ki_cur_seg = 0;
41965 /* ki_nbytes/left now reflect bytes instead of segs */
41966 diff --git a/fs/attr.c b/fs/attr.c
41967 index 95053ad..2cc93ca 100644
41968 --- a/fs/attr.c
41969 +++ b/fs/attr.c
41970 @@ -99,6 +99,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
41971 unsigned long limit;
41972
41973 limit = rlimit(RLIMIT_FSIZE);
41974 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
41975 if (limit != RLIM_INFINITY && offset > limit)
41976 goto out_sig;
41977 if (offset > inode->i_sb->s_maxbytes)
41978 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
41979 index f624cd0..3d9a559 100644
41980 --- a/fs/autofs4/waitq.c
41981 +++ b/fs/autofs4/waitq.c
41982 @@ -61,7 +61,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
41983 {
41984 unsigned long sigpipe, flags;
41985 mm_segment_t fs;
41986 - const char *data = (const char *)addr;
41987 + const char __user *data = (const char __force_user *)addr;
41988 ssize_t wr = 0;
41989
41990 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
41991 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
41992 index 6e6d536..457113a 100644
41993 --- a/fs/befs/linuxvfs.c
41994 +++ b/fs/befs/linuxvfs.c
41995 @@ -502,7 +502,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
41996 {
41997 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
41998 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
41999 - char *link = nd_get_link(nd);
42000 + const char *link = nd_get_link(nd);
42001 if (!IS_ERR(link))
42002 kfree(link);
42003 }
42004 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
42005 index 1ff9405..f1e376a 100644
42006 --- a/fs/binfmt_aout.c
42007 +++ b/fs/binfmt_aout.c
42008 @@ -16,6 +16,7 @@
42009 #include <linux/string.h>
42010 #include <linux/fs.h>
42011 #include <linux/file.h>
42012 +#include <linux/security.h>
42013 #include <linux/stat.h>
42014 #include <linux/fcntl.h>
42015 #include <linux/ptrace.h>
42016 @@ -86,6 +87,8 @@ static int aout_core_dump(struct coredump_params *cprm)
42017 #endif
42018 # define START_STACK(u) ((void __user *)u.start_stack)
42019
42020 + memset(&dump, 0, sizeof(dump));
42021 +
42022 fs = get_fs();
42023 set_fs(KERNEL_DS);
42024 has_dumped = 1;
42025 @@ -97,10 +100,12 @@ static int aout_core_dump(struct coredump_params *cprm)
42026
42027 /* If the size of the dump file exceeds the rlimit, then see what would happen
42028 if we wrote the stack, but not the data area. */
42029 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
42030 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
42031 dump.u_dsize = 0;
42032
42033 /* Make sure we have enough room to write the stack and data areas. */
42034 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
42035 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
42036 dump.u_ssize = 0;
42037
42038 @@ -234,6 +239,8 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
42039 rlim = rlimit(RLIMIT_DATA);
42040 if (rlim >= RLIM_INFINITY)
42041 rlim = ~0;
42042 +
42043 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
42044 if (ex.a_data + ex.a_bss > rlim)
42045 return -ENOMEM;
42046
42047 @@ -269,6 +276,27 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
42048 install_exec_creds(bprm);
42049 current->flags &= ~PF_FORKNOEXEC;
42050
42051 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
42052 + current->mm->pax_flags = 0UL;
42053 +#endif
42054 +
42055 +#ifdef CONFIG_PAX_PAGEEXEC
42056 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
42057 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
42058 +
42059 +#ifdef CONFIG_PAX_EMUTRAMP
42060 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
42061 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
42062 +#endif
42063 +
42064 +#ifdef CONFIG_PAX_MPROTECT
42065 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
42066 + current->mm->pax_flags |= MF_PAX_MPROTECT;
42067 +#endif
42068 +
42069 + }
42070 +#endif
42071 +
42072 if (N_MAGIC(ex) == OMAGIC) {
42073 unsigned long text_addr, map_size;
42074 loff_t pos;
42075 @@ -341,7 +369,7 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
42076
42077 down_write(&current->mm->mmap_sem);
42078 error = do_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
42079 - PROT_READ | PROT_WRITE | PROT_EXEC,
42080 + PROT_READ | PROT_WRITE,
42081 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
42082 fd_offset + ex.a_text);
42083 up_write(&current->mm->mmap_sem);
42084 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
42085 index 07d096c..25762af 100644
42086 --- a/fs/binfmt_elf.c
42087 +++ b/fs/binfmt_elf.c
42088 @@ -32,6 +32,7 @@
42089 #include <linux/elf.h>
42090 #include <linux/utsname.h>
42091 #include <linux/coredump.h>
42092 +#include <linux/xattr.h>
42093 #include <asm/uaccess.h>
42094 #include <asm/param.h>
42095 #include <asm/page.h>
42096 @@ -51,6 +52,10 @@ static int elf_core_dump(struct coredump_params *cprm);
42097 #define elf_core_dump NULL
42098 #endif
42099
42100 +#ifdef CONFIG_PAX_MPROTECT
42101 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
42102 +#endif
42103 +
42104 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
42105 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
42106 #else
42107 @@ -70,6 +75,11 @@ static struct linux_binfmt elf_format = {
42108 .load_binary = load_elf_binary,
42109 .load_shlib = load_elf_library,
42110 .core_dump = elf_core_dump,
42111 +
42112 +#ifdef CONFIG_PAX_MPROTECT
42113 + .handle_mprotect= elf_handle_mprotect,
42114 +#endif
42115 +
42116 .min_coredump = ELF_EXEC_PAGESIZE,
42117 };
42118
42119 @@ -77,6 +87,8 @@ static struct linux_binfmt elf_format = {
42120
42121 static int set_brk(unsigned long start, unsigned long end)
42122 {
42123 + unsigned long e = end;
42124 +
42125 start = ELF_PAGEALIGN(start);
42126 end = ELF_PAGEALIGN(end);
42127 if (end > start) {
42128 @@ -87,7 +99,7 @@ static int set_brk(unsigned long start, unsigned long end)
42129 if (BAD_ADDR(addr))
42130 return addr;
42131 }
42132 - current->mm->start_brk = current->mm->brk = end;
42133 + current->mm->start_brk = current->mm->brk = e;
42134 return 0;
42135 }
42136
42137 @@ -148,12 +160,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
42138 elf_addr_t __user *u_rand_bytes;
42139 const char *k_platform = ELF_PLATFORM;
42140 const char *k_base_platform = ELF_BASE_PLATFORM;
42141 - unsigned char k_rand_bytes[16];
42142 + u32 k_rand_bytes[4];
42143 int items;
42144 elf_addr_t *elf_info;
42145 int ei_index = 0;
42146 const struct cred *cred = current_cred();
42147 struct vm_area_struct *vma;
42148 + unsigned long saved_auxv[AT_VECTOR_SIZE];
42149
42150 /*
42151 * In some cases (e.g. Hyper-Threading), we want to avoid L1
42152 @@ -195,8 +208,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
42153 * Generate 16 random bytes for userspace PRNG seeding.
42154 */
42155 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
42156 - u_rand_bytes = (elf_addr_t __user *)
42157 - STACK_ALLOC(p, sizeof(k_rand_bytes));
42158 + srandom32(k_rand_bytes[0] ^ random32());
42159 + srandom32(k_rand_bytes[1] ^ random32());
42160 + srandom32(k_rand_bytes[2] ^ random32());
42161 + srandom32(k_rand_bytes[3] ^ random32());
42162 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
42163 + u_rand_bytes = (elf_addr_t __user *) p;
42164 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
42165 return -EFAULT;
42166
42167 @@ -308,9 +325,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
42168 return -EFAULT;
42169 current->mm->env_end = p;
42170
42171 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
42172 +
42173 /* Put the elf_info on the stack in the right place. */
42174 sp = (elf_addr_t __user *)envp + 1;
42175 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
42176 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
42177 return -EFAULT;
42178 return 0;
42179 }
42180 @@ -381,10 +400,10 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
42181 {
42182 struct elf_phdr *elf_phdata;
42183 struct elf_phdr *eppnt;
42184 - unsigned long load_addr = 0;
42185 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
42186 int load_addr_set = 0;
42187 unsigned long last_bss = 0, elf_bss = 0;
42188 - unsigned long error = ~0UL;
42189 + unsigned long error = -EINVAL;
42190 unsigned long total_size;
42191 int retval, i, size;
42192
42193 @@ -430,6 +449,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
42194 goto out_close;
42195 }
42196
42197 +#ifdef CONFIG_PAX_SEGMEXEC
42198 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
42199 + pax_task_size = SEGMEXEC_TASK_SIZE;
42200 +#endif
42201 +
42202 eppnt = elf_phdata;
42203 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
42204 if (eppnt->p_type == PT_LOAD) {
42205 @@ -473,8 +497,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
42206 k = load_addr + eppnt->p_vaddr;
42207 if (BAD_ADDR(k) ||
42208 eppnt->p_filesz > eppnt->p_memsz ||
42209 - eppnt->p_memsz > TASK_SIZE ||
42210 - TASK_SIZE - eppnt->p_memsz < k) {
42211 + eppnt->p_memsz > pax_task_size ||
42212 + pax_task_size - eppnt->p_memsz < k) {
42213 error = -ENOMEM;
42214 goto out_close;
42215 }
42216 @@ -528,6 +552,351 @@ out:
42217 return error;
42218 }
42219
42220 +#if defined(CONFIG_PAX_EI_PAX) || defined(CONFIG_PAX_PT_PAX_FLAGS) || defined(CONFIG_PAX_XATTR_PAX_FLAGS)
42221 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
42222 +{
42223 + unsigned long pax_flags = 0UL;
42224 +
42225 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
42226 +
42227 +#ifdef CONFIG_PAX_PAGEEXEC
42228 + if (elf_phdata->p_flags & PF_PAGEEXEC)
42229 + pax_flags |= MF_PAX_PAGEEXEC;
42230 +#endif
42231 +
42232 +#ifdef CONFIG_PAX_SEGMEXEC
42233 + if (elf_phdata->p_flags & PF_SEGMEXEC)
42234 + pax_flags |= MF_PAX_SEGMEXEC;
42235 +#endif
42236 +
42237 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
42238 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
42239 + if ((__supported_pte_mask & _PAGE_NX))
42240 + pax_flags &= ~MF_PAX_SEGMEXEC;
42241 + else
42242 + pax_flags &= ~MF_PAX_PAGEEXEC;
42243 + }
42244 +#endif
42245 +
42246 +#ifdef CONFIG_PAX_EMUTRAMP
42247 + if (elf_phdata->p_flags & PF_EMUTRAMP)
42248 + pax_flags |= MF_PAX_EMUTRAMP;
42249 +#endif
42250 +
42251 +#ifdef CONFIG_PAX_MPROTECT
42252 + if (elf_phdata->p_flags & PF_MPROTECT)
42253 + pax_flags |= MF_PAX_MPROTECT;
42254 +#endif
42255 +
42256 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
42257 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
42258 + pax_flags |= MF_PAX_RANDMMAP;
42259 +#endif
42260 +
42261 +#endif
42262 +
42263 + return pax_flags;
42264 +}
42265 +
42266 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
42267 +{
42268 + unsigned long pax_flags = 0UL;
42269 +
42270 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
42271 +
42272 +#ifdef CONFIG_PAX_PAGEEXEC
42273 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
42274 + pax_flags |= MF_PAX_PAGEEXEC;
42275 +#endif
42276 +
42277 +#ifdef CONFIG_PAX_SEGMEXEC
42278 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
42279 + pax_flags |= MF_PAX_SEGMEXEC;
42280 +#endif
42281 +
42282 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
42283 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
42284 + if ((__supported_pte_mask & _PAGE_NX))
42285 + pax_flags &= ~MF_PAX_SEGMEXEC;
42286 + else
42287 + pax_flags &= ~MF_PAX_PAGEEXEC;
42288 + }
42289 +#endif
42290 +
42291 +#ifdef CONFIG_PAX_EMUTRAMP
42292 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
42293 + pax_flags |= MF_PAX_EMUTRAMP;
42294 +#endif
42295 +
42296 +#ifdef CONFIG_PAX_MPROTECT
42297 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
42298 + pax_flags |= MF_PAX_MPROTECT;
42299 +#endif
42300 +
42301 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
42302 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
42303 + pax_flags |= MF_PAX_RANDMMAP;
42304 +#endif
42305 +
42306 +#endif
42307 +
42308 + return pax_flags;
42309 +}
42310 +
42311 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
42312 +{
42313 + unsigned long pax_flags = 0UL;
42314 +
42315 +#ifdef CONFIG_PAX_EI_PAX
42316 +
42317 +#ifdef CONFIG_PAX_PAGEEXEC
42318 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
42319 + pax_flags |= MF_PAX_PAGEEXEC;
42320 +#endif
42321 +
42322 +#ifdef CONFIG_PAX_SEGMEXEC
42323 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
42324 + pax_flags |= MF_PAX_SEGMEXEC;
42325 +#endif
42326 +
42327 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
42328 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
42329 + if ((__supported_pte_mask & _PAGE_NX))
42330 + pax_flags &= ~MF_PAX_SEGMEXEC;
42331 + else
42332 + pax_flags &= ~MF_PAX_PAGEEXEC;
42333 + }
42334 +#endif
42335 +
42336 +#ifdef CONFIG_PAX_EMUTRAMP
42337 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
42338 + pax_flags |= MF_PAX_EMUTRAMP;
42339 +#endif
42340 +
42341 +#ifdef CONFIG_PAX_MPROTECT
42342 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
42343 + pax_flags |= MF_PAX_MPROTECT;
42344 +#endif
42345 +
42346 +#ifdef CONFIG_PAX_ASLR
42347 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
42348 + pax_flags |= MF_PAX_RANDMMAP;
42349 +#endif
42350 +
42351 +#else
42352 +
42353 +#ifdef CONFIG_PAX_PAGEEXEC
42354 + pax_flags |= MF_PAX_PAGEEXEC;
42355 +#endif
42356 +
42357 +#ifdef CONFIG_PAX_MPROTECT
42358 + pax_flags |= MF_PAX_MPROTECT;
42359 +#endif
42360 +
42361 +#ifdef CONFIG_PAX_RANDMMAP
42362 + pax_flags |= MF_PAX_RANDMMAP;
42363 +#endif
42364 +
42365 +#ifdef CONFIG_PAX_SEGMEXEC
42366 + if (!(pax_flags & MF_PAX_PAGEEXEC) || !(__supported_pte_mask & _PAGE_NX)) {
42367 + pax_flags &= ~MF_PAX_PAGEEXEC;
42368 + pax_flags |= MF_PAX_SEGMEXEC;
42369 + }
42370 +#endif
42371 +
42372 +#endif
42373 +
42374 + return pax_flags;
42375 +}
42376 +
42377 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
42378 +{
42379 +
42380 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
42381 + unsigned long i;
42382 +
42383 + for (i = 0UL; i < elf_ex->e_phnum; i++)
42384 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
42385 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
42386 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
42387 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
42388 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
42389 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
42390 + return ~0UL;
42391 +
42392 +#ifdef CONFIG_PAX_SOFTMODE
42393 + if (pax_softmode)
42394 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
42395 + else
42396 +#endif
42397 +
42398 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
42399 + break;
42400 + }
42401 +#endif
42402 +
42403 + return ~0UL;
42404 +}
42405 +
42406 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
42407 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
42408 +{
42409 + unsigned long pax_flags = 0UL;
42410 +
42411 +#ifdef CONFIG_PAX_PAGEEXEC
42412 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
42413 + pax_flags |= MF_PAX_PAGEEXEC;
42414 +#endif
42415 +
42416 +#ifdef CONFIG_PAX_SEGMEXEC
42417 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
42418 + pax_flags |= MF_PAX_SEGMEXEC;
42419 +#endif
42420 +
42421 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
42422 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
42423 + if ((__supported_pte_mask & _PAGE_NX))
42424 + pax_flags &= ~MF_PAX_SEGMEXEC;
42425 + else
42426 + pax_flags &= ~MF_PAX_PAGEEXEC;
42427 + }
42428 +#endif
42429 +
42430 +#ifdef CONFIG_PAX_EMUTRAMP
42431 + if (pax_flags_softmode & MF_PAX_EMUTRAMP)
42432 + pax_flags |= MF_PAX_EMUTRAMP;
42433 +#endif
42434 +
42435 +#ifdef CONFIG_PAX_MPROTECT
42436 + if (pax_flags_softmode & MF_PAX_MPROTECT)
42437 + pax_flags |= MF_PAX_MPROTECT;
42438 +#endif
42439 +
42440 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
42441 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
42442 + pax_flags |= MF_PAX_RANDMMAP;
42443 +#endif
42444 +
42445 + return pax_flags;
42446 +}
42447 +
42448 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
42449 +{
42450 + unsigned long pax_flags = 0UL;
42451 +
42452 +#ifdef CONFIG_PAX_PAGEEXEC
42453 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
42454 + pax_flags |= MF_PAX_PAGEEXEC;
42455 +#endif
42456 +
42457 +#ifdef CONFIG_PAX_SEGMEXEC
42458 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
42459 + pax_flags |= MF_PAX_SEGMEXEC;
42460 +#endif
42461 +
42462 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
42463 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
42464 + if ((__supported_pte_mask & _PAGE_NX))
42465 + pax_flags &= ~MF_PAX_SEGMEXEC;
42466 + else
42467 + pax_flags &= ~MF_PAX_PAGEEXEC;
42468 + }
42469 +#endif
42470 +
42471 +#ifdef CONFIG_PAX_EMUTRAMP
42472 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
42473 + pax_flags |= MF_PAX_EMUTRAMP;
42474 +#endif
42475 +
42476 +#ifdef CONFIG_PAX_MPROTECT
42477 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
42478 + pax_flags |= MF_PAX_MPROTECT;
42479 +#endif
42480 +
42481 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
42482 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
42483 + pax_flags |= MF_PAX_RANDMMAP;
42484 +#endif
42485 +
42486 + return pax_flags;
42487 +}
42488 +#endif
42489 +
42490 +static unsigned long pax_parse_xattr_pax(struct file * const file)
42491 +{
42492 +
42493 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
42494 + ssize_t xattr_size, i;
42495 + unsigned char xattr_value[5];
42496 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
42497 +
42498 + xattr_size = vfs_getxattr(file->f_path.dentry, XATTR_NAME_PAX_FLAGS, xattr_value, sizeof xattr_value);
42499 + if (xattr_size <= 0)
42500 + return ~0UL;
42501 +
42502 + for (i = 0; i < xattr_size; i++)
42503 + switch (xattr_value[i]) {
42504 + default:
42505 + return ~0UL;
42506 +
42507 +#define parse_flag(option1, option2, flag) \
42508 + case option1: \
42509 + pax_flags_hardmode |= MF_PAX_##flag; \
42510 + break; \
42511 + case option2: \
42512 + pax_flags_softmode |= MF_PAX_##flag; \
42513 + break;
42514 +
42515 + parse_flag('p', 'P', PAGEEXEC);
42516 + parse_flag('e', 'E', EMUTRAMP);
42517 + parse_flag('m', 'M', MPROTECT);
42518 + parse_flag('r', 'R', RANDMMAP);
42519 + parse_flag('s', 'S', SEGMEXEC);
42520 +
42521 +#undef parse_flag
42522 + }
42523 +
42524 + if (pax_flags_hardmode & pax_flags_softmode)
42525 + return ~0UL;
42526 +
42527 +#ifdef CONFIG_PAX_SOFTMODE
42528 + if (pax_softmode)
42529 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
42530 + else
42531 +#endif
42532 +
42533 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
42534 +#else
42535 + return ~0UL;
42536 +#endif
42537 +
42538 +}
42539 +
42540 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
42541 +{
42542 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
42543 +
42544 + pax_flags = pax_parse_ei_pax(elf_ex);
42545 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
42546 + xattr_pax_flags = pax_parse_xattr_pax(file);
42547 +
42548 + if (pt_pax_flags == ~0UL)
42549 + pt_pax_flags = xattr_pax_flags;
42550 + else if (xattr_pax_flags == ~0UL)
42551 + xattr_pax_flags = pt_pax_flags;
42552 + if (pt_pax_flags != xattr_pax_flags)
42553 + return -EINVAL;
42554 + if (pt_pax_flags != ~0UL)
42555 + pax_flags = pt_pax_flags;
42556 +
42557 + if (0 > pax_check_flags(&pax_flags))
42558 + return -EINVAL;
42559 +
42560 + current->mm->pax_flags = pax_flags;
42561 + return 0;
42562 +}
42563 +#endif
42564 +
42565 /*
42566 * These are the functions used to load ELF style executables and shared
42567 * libraries. There is no binary dependent code anywhere else.
42568 @@ -544,6 +913,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
42569 {
42570 unsigned int random_variable = 0;
42571
42572 +#ifdef CONFIG_PAX_RANDUSTACK
42573 + if (randomize_va_space)
42574 + return stack_top - current->mm->delta_stack;
42575 +#endif
42576 +
42577 if ((current->flags & PF_RANDOMIZE) &&
42578 !(current->personality & ADDR_NO_RANDOMIZE)) {
42579 random_variable = get_random_int() & STACK_RND_MASK;
42580 @@ -562,7 +936,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
42581 unsigned long load_addr = 0, load_bias = 0;
42582 int load_addr_set = 0;
42583 char * elf_interpreter = NULL;
42584 - unsigned long error;
42585 + unsigned long error = 0;
42586 struct elf_phdr *elf_ppnt, *elf_phdata;
42587 unsigned long elf_bss, elf_brk;
42588 int retval, i;
42589 @@ -572,11 +946,11 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
42590 unsigned long start_code, end_code, start_data, end_data;
42591 unsigned long reloc_func_desc __maybe_unused = 0;
42592 int executable_stack = EXSTACK_DEFAULT;
42593 - unsigned long def_flags = 0;
42594 struct {
42595 struct elfhdr elf_ex;
42596 struct elfhdr interp_elf_ex;
42597 } *loc;
42598 + unsigned long pax_task_size = TASK_SIZE;
42599
42600 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
42601 if (!loc) {
42602 @@ -713,11 +1087,81 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
42603
42604 /* OK, This is the point of no return */
42605 current->flags &= ~PF_FORKNOEXEC;
42606 - current->mm->def_flags = def_flags;
42607 +
42608 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
42609 + current->mm->pax_flags = 0UL;
42610 +#endif
42611 +
42612 +#ifdef CONFIG_PAX_DLRESOLVE
42613 + current->mm->call_dl_resolve = 0UL;
42614 +#endif
42615 +
42616 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
42617 + current->mm->call_syscall = 0UL;
42618 +#endif
42619 +
42620 +#ifdef CONFIG_PAX_ASLR
42621 + current->mm->delta_mmap = 0UL;
42622 + current->mm->delta_stack = 0UL;
42623 +#endif
42624 +
42625 + current->mm->def_flags = 0;
42626 +
42627 +#if defined(CONFIG_PAX_EI_PAX) || defined(CONFIG_PAX_PT_PAX_FLAGS) || defined(CONFIG_PAX_XATTR_PAX_FLAGS)
42628 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
42629 + send_sig(SIGKILL, current, 0);
42630 + goto out_free_dentry;
42631 + }
42632 +#endif
42633 +
42634 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
42635 + pax_set_initial_flags(bprm);
42636 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
42637 + if (pax_set_initial_flags_func)
42638 + (pax_set_initial_flags_func)(bprm);
42639 +#endif
42640 +
42641 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
42642 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
42643 + current->mm->context.user_cs_limit = PAGE_SIZE;
42644 + current->mm->def_flags |= VM_PAGEEXEC;
42645 + }
42646 +#endif
42647 +
42648 +#ifdef CONFIG_PAX_SEGMEXEC
42649 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
42650 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
42651 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
42652 + pax_task_size = SEGMEXEC_TASK_SIZE;
42653 + current->mm->def_flags |= VM_NOHUGEPAGE;
42654 + }
42655 +#endif
42656 +
42657 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
42658 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
42659 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
42660 + put_cpu();
42661 + }
42662 +#endif
42663
42664 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
42665 may depend on the personality. */
42666 SET_PERSONALITY(loc->elf_ex);
42667 +
42668 +#ifdef CONFIG_PAX_ASLR
42669 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
42670 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
42671 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
42672 + }
42673 +#endif
42674 +
42675 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
42676 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
42677 + executable_stack = EXSTACK_DISABLE_X;
42678 + current->personality &= ~READ_IMPLIES_EXEC;
42679 + } else
42680 +#endif
42681 +
42682 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
42683 current->personality |= READ_IMPLIES_EXEC;
42684
42685 @@ -808,6 +1252,20 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
42686 #else
42687 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
42688 #endif
42689 +
42690 +#ifdef CONFIG_PAX_RANDMMAP
42691 + /* PaX: randomize base address at the default exe base if requested */
42692 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
42693 +#ifdef CONFIG_SPARC64
42694 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
42695 +#else
42696 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
42697 +#endif
42698 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
42699 + elf_flags |= MAP_FIXED;
42700 + }
42701 +#endif
42702 +
42703 }
42704
42705 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
42706 @@ -840,9 +1298,9 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
42707 * allowed task size. Note that p_filesz must always be
42708 * <= p_memsz so it is only necessary to check p_memsz.
42709 */
42710 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
42711 - elf_ppnt->p_memsz > TASK_SIZE ||
42712 - TASK_SIZE - elf_ppnt->p_memsz < k) {
42713 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
42714 + elf_ppnt->p_memsz > pax_task_size ||
42715 + pax_task_size - elf_ppnt->p_memsz < k) {
42716 /* set_brk can never work. Avoid overflows. */
42717 send_sig(SIGKILL, current, 0);
42718 retval = -EINVAL;
42719 @@ -881,11 +1339,40 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
42720 goto out_free_dentry;
42721 }
42722 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
42723 - send_sig(SIGSEGV, current, 0);
42724 - retval = -EFAULT; /* Nobody gets to see this, but.. */
42725 - goto out_free_dentry;
42726 + /*
42727 + * This bss-zeroing can fail if the ELF
42728 + * file specifies odd protections. So
42729 + * we don't check the return value
42730 + */
42731 }
42732
42733 +#ifdef CONFIG_PAX_RANDMMAP
42734 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
42735 + unsigned long start, size;
42736 +
42737 + start = ELF_PAGEALIGN(elf_brk);
42738 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
42739 + down_write(&current->mm->mmap_sem);
42740 + retval = -ENOMEM;
42741 + if (!find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
42742 + unsigned long prot = PROT_NONE;
42743 +
42744 + current->mm->brk_gap = PAGE_ALIGN(size) >> PAGE_SHIFT;
42745 +// if (current->personality & ADDR_NO_RANDOMIZE)
42746 +// prot = PROT_READ;
42747 + start = do_mmap(NULL, start, size, prot, MAP_ANONYMOUS | MAP_FIXED | MAP_PRIVATE, 0);
42748 + retval = IS_ERR_VALUE(start) ? start : 0;
42749 + }
42750 + up_write(&current->mm->mmap_sem);
42751 + if (retval == 0)
42752 + retval = set_brk(start + size, start + size + PAGE_SIZE);
42753 + if (retval < 0) {
42754 + send_sig(SIGKILL, current, 0);
42755 + goto out_free_dentry;
42756 + }
42757 + }
42758 +#endif
42759 +
42760 if (elf_interpreter) {
42761 unsigned long uninitialized_var(interp_map_addr);
42762
42763 @@ -1098,7 +1585,7 @@ out:
42764 * Decide what to dump of a segment, part, all or none.
42765 */
42766 static unsigned long vma_dump_size(struct vm_area_struct *vma,
42767 - unsigned long mm_flags)
42768 + unsigned long mm_flags, long signr)
42769 {
42770 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
42771
42772 @@ -1132,7 +1619,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
42773 if (vma->vm_file == NULL)
42774 return 0;
42775
42776 - if (FILTER(MAPPED_PRIVATE))
42777 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
42778 goto whole;
42779
42780 /*
42781 @@ -1354,9 +1841,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
42782 {
42783 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
42784 int i = 0;
42785 - do
42786 + do {
42787 i += 2;
42788 - while (auxv[i - 2] != AT_NULL);
42789 + } while (auxv[i - 2] != AT_NULL);
42790 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
42791 }
42792
42793 @@ -1862,14 +2349,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
42794 }
42795
42796 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
42797 - unsigned long mm_flags)
42798 + struct coredump_params *cprm)
42799 {
42800 struct vm_area_struct *vma;
42801 size_t size = 0;
42802
42803 for (vma = first_vma(current, gate_vma); vma != NULL;
42804 vma = next_vma(vma, gate_vma))
42805 - size += vma_dump_size(vma, mm_flags);
42806 + size += vma_dump_size(vma, cprm->mm_flags, cprm->signr);
42807 return size;
42808 }
42809
42810 @@ -1963,7 +2450,7 @@ static int elf_core_dump(struct coredump_params *cprm)
42811
42812 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
42813
42814 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
42815 + offset += elf_core_vma_data_size(gate_vma, cprm);
42816 offset += elf_core_extra_data_size();
42817 e_shoff = offset;
42818
42819 @@ -1977,10 +2464,12 @@ static int elf_core_dump(struct coredump_params *cprm)
42820 offset = dataoff;
42821
42822 size += sizeof(*elf);
42823 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
42824 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
42825 goto end_coredump;
42826
42827 size += sizeof(*phdr4note);
42828 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
42829 if (size > cprm->limit
42830 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
42831 goto end_coredump;
42832 @@ -1994,7 +2483,7 @@ static int elf_core_dump(struct coredump_params *cprm)
42833 phdr.p_offset = offset;
42834 phdr.p_vaddr = vma->vm_start;
42835 phdr.p_paddr = 0;
42836 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
42837 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->signr);
42838 phdr.p_memsz = vma->vm_end - vma->vm_start;
42839 offset += phdr.p_filesz;
42840 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
42841 @@ -2005,6 +2494,7 @@ static int elf_core_dump(struct coredump_params *cprm)
42842 phdr.p_align = ELF_EXEC_PAGESIZE;
42843
42844 size += sizeof(phdr);
42845 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
42846 if (size > cprm->limit
42847 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
42848 goto end_coredump;
42849 @@ -2029,7 +2519,7 @@ static int elf_core_dump(struct coredump_params *cprm)
42850 unsigned long addr;
42851 unsigned long end;
42852
42853 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
42854 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->signr);
42855
42856 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
42857 struct page *page;
42858 @@ -2038,6 +2528,7 @@ static int elf_core_dump(struct coredump_params *cprm)
42859 page = get_dump_page(addr);
42860 if (page) {
42861 void *kaddr = kmap(page);
42862 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
42863 stop = ((size += PAGE_SIZE) > cprm->limit) ||
42864 !dump_write(cprm->file, kaddr,
42865 PAGE_SIZE);
42866 @@ -2055,6 +2546,7 @@ static int elf_core_dump(struct coredump_params *cprm)
42867
42868 if (e_phnum == PN_XNUM) {
42869 size += sizeof(*shdr4extnum);
42870 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
42871 if (size > cprm->limit
42872 || !dump_write(cprm->file, shdr4extnum,
42873 sizeof(*shdr4extnum)))
42874 @@ -2075,6 +2567,97 @@ out:
42875
42876 #endif /* CONFIG_ELF_CORE */
42877
42878 +#ifdef CONFIG_PAX_MPROTECT
42879 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
42880 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
42881 + * we'll remove VM_MAYWRITE for good on RELRO segments.
42882 + *
42883 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
42884 + * basis because we want to allow the common case and not the special ones.
42885 + */
42886 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
42887 +{
42888 + struct elfhdr elf_h;
42889 + struct elf_phdr elf_p;
42890 + unsigned long i;
42891 + unsigned long oldflags;
42892 + bool is_textrel_rw, is_textrel_rx, is_relro;
42893 +
42894 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
42895 + return;
42896 +
42897 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
42898 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
42899 +
42900 +#ifdef CONFIG_PAX_ELFRELOCS
42901 + /* possible TEXTREL */
42902 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
42903 + 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);
42904 +#else
42905 + is_textrel_rw = false;
42906 + is_textrel_rx = false;
42907 +#endif
42908 +
42909 + /* possible RELRO */
42910 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
42911 +
42912 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
42913 + return;
42914 +
42915 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
42916 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
42917 +
42918 +#ifdef CONFIG_PAX_ETEXECRELOCS
42919 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
42920 +#else
42921 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
42922 +#endif
42923 +
42924 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
42925 + !elf_check_arch(&elf_h) ||
42926 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
42927 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
42928 + return;
42929 +
42930 + for (i = 0UL; i < elf_h.e_phnum; i++) {
42931 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
42932 + return;
42933 + switch (elf_p.p_type) {
42934 + case PT_DYNAMIC:
42935 + if (!is_textrel_rw && !is_textrel_rx)
42936 + continue;
42937 + i = 0UL;
42938 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
42939 + elf_dyn dyn;
42940 +
42941 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
42942 + return;
42943 + if (dyn.d_tag == DT_NULL)
42944 + return;
42945 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
42946 + gr_log_textrel(vma);
42947 + if (is_textrel_rw)
42948 + vma->vm_flags |= VM_MAYWRITE;
42949 + else
42950 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
42951 + vma->vm_flags &= ~VM_MAYWRITE;
42952 + return;
42953 + }
42954 + i++;
42955 + }
42956 + return;
42957 +
42958 + case PT_GNU_RELRO:
42959 + if (!is_relro)
42960 + continue;
42961 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
42962 + vma->vm_flags &= ~VM_MAYWRITE;
42963 + return;
42964 + }
42965 + }
42966 +}
42967 +#endif
42968 +
42969 static int __init init_elf_binfmt(void)
42970 {
42971 return register_binfmt(&elf_format);
42972 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
42973 index 1bffbe0..c8c283e 100644
42974 --- a/fs/binfmt_flat.c
42975 +++ b/fs/binfmt_flat.c
42976 @@ -567,7 +567,9 @@ static int load_flat_file(struct linux_binprm * bprm,
42977 realdatastart = (unsigned long) -ENOMEM;
42978 printk("Unable to allocate RAM for process data, errno %d\n",
42979 (int)-realdatastart);
42980 + down_write(&current->mm->mmap_sem);
42981 do_munmap(current->mm, textpos, text_len);
42982 + up_write(&current->mm->mmap_sem);
42983 ret = realdatastart;
42984 goto err;
42985 }
42986 @@ -591,8 +593,10 @@ static int load_flat_file(struct linux_binprm * bprm,
42987 }
42988 if (IS_ERR_VALUE(result)) {
42989 printk("Unable to read data+bss, errno %d\n", (int)-result);
42990 + down_write(&current->mm->mmap_sem);
42991 do_munmap(current->mm, textpos, text_len);
42992 do_munmap(current->mm, realdatastart, len);
42993 + up_write(&current->mm->mmap_sem);
42994 ret = result;
42995 goto err;
42996 }
42997 @@ -661,8 +665,10 @@ static int load_flat_file(struct linux_binprm * bprm,
42998 }
42999 if (IS_ERR_VALUE(result)) {
43000 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
43001 + down_write(&current->mm->mmap_sem);
43002 do_munmap(current->mm, textpos, text_len + data_len + extra +
43003 MAX_SHARED_LIBS * sizeof(unsigned long));
43004 + up_write(&current->mm->mmap_sem);
43005 ret = result;
43006 goto err;
43007 }
43008 diff --git a/fs/bio.c b/fs/bio.c
43009 index b980ecd..74800bf 100644
43010 --- a/fs/bio.c
43011 +++ b/fs/bio.c
43012 @@ -833,7 +833,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
43013 /*
43014 * Overflow, abort
43015 */
43016 - if (end < start)
43017 + if (end < start || end - start > INT_MAX - nr_pages)
43018 return ERR_PTR(-EINVAL);
43019
43020 nr_pages += end - start;
43021 @@ -1229,7 +1229,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
43022 const int read = bio_data_dir(bio) == READ;
43023 struct bio_map_data *bmd = bio->bi_private;
43024 int i;
43025 - char *p = bmd->sgvecs[0].iov_base;
43026 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
43027
43028 __bio_for_each_segment(bvec, bio, i, 0) {
43029 char *addr = page_address(bvec->bv_page);
43030 diff --git a/fs/block_dev.c b/fs/block_dev.c
43031 index 5e9f198..6bf9b1c 100644
43032 --- a/fs/block_dev.c
43033 +++ b/fs/block_dev.c
43034 @@ -703,7 +703,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
43035 else if (bdev->bd_contains == bdev)
43036 return true; /* is a whole device which isn't held */
43037
43038 - else if (whole->bd_holder == bd_may_claim)
43039 + else if (whole->bd_holder == (void *)bd_may_claim)
43040 return true; /* is a partition of a device that is being partitioned */
43041 else if (whole->bd_holder != NULL)
43042 return false; /* is a partition of a held device */
43043 diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
43044 index d986824..af1befd 100644
43045 --- a/fs/btrfs/check-integrity.c
43046 +++ b/fs/btrfs/check-integrity.c
43047 @@ -157,7 +157,7 @@ struct btrfsic_block {
43048 union {
43049 bio_end_io_t *bio;
43050 bh_end_io_t *bh;
43051 - } orig_bio_bh_end_io;
43052 + } __no_const orig_bio_bh_end_io;
43053 int submit_bio_bh_rw;
43054 u64 flush_gen; /* only valid if !never_written */
43055 };
43056 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
43057 index 0639a55..7d9e07f 100644
43058 --- a/fs/btrfs/ctree.c
43059 +++ b/fs/btrfs/ctree.c
43060 @@ -488,9 +488,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
43061 free_extent_buffer(buf);
43062 add_root_to_dirty_list(root);
43063 } else {
43064 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
43065 - parent_start = parent->start;
43066 - else
43067 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
43068 + if (parent)
43069 + parent_start = parent->start;
43070 + else
43071 + parent_start = 0;
43072 + } else
43073 parent_start = 0;
43074
43075 WARN_ON(trans->transid != btrfs_header_generation(parent));
43076 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
43077 index 892b347..b3db246 100644
43078 --- a/fs/btrfs/inode.c
43079 +++ b/fs/btrfs/inode.c
43080 @@ -6930,7 +6930,7 @@ fail:
43081 return -ENOMEM;
43082 }
43083
43084 -static int btrfs_getattr(struct vfsmount *mnt,
43085 +int btrfs_getattr(struct vfsmount *mnt,
43086 struct dentry *dentry, struct kstat *stat)
43087 {
43088 struct inode *inode = dentry->d_inode;
43089 @@ -6944,6 +6944,14 @@ static int btrfs_getattr(struct vfsmount *mnt,
43090 return 0;
43091 }
43092
43093 +EXPORT_SYMBOL(btrfs_getattr);
43094 +
43095 +dev_t get_btrfs_dev_from_inode(struct inode *inode)
43096 +{
43097 + return BTRFS_I(inode)->root->anon_dev;
43098 +}
43099 +EXPORT_SYMBOL(get_btrfs_dev_from_inode);
43100 +
43101 /*
43102 * If a file is moved, it will inherit the cow and compression flags of the new
43103 * directory.
43104 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
43105 index 1b36f19..5ac7360 100644
43106 --- a/fs/btrfs/ioctl.c
43107 +++ b/fs/btrfs/ioctl.c
43108 @@ -2783,9 +2783,12 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
43109 for (i = 0; i < num_types; i++) {
43110 struct btrfs_space_info *tmp;
43111
43112 + /* Don't copy in more than we allocated */
43113 if (!slot_count)
43114 break;
43115
43116 + slot_count--;
43117 +
43118 info = NULL;
43119 rcu_read_lock();
43120 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
43121 @@ -2807,15 +2810,12 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
43122 memcpy(dest, &space, sizeof(space));
43123 dest++;
43124 space_args.total_spaces++;
43125 - slot_count--;
43126 }
43127 - if (!slot_count)
43128 - break;
43129 }
43130 up_read(&info->groups_sem);
43131 }
43132
43133 - user_dest = (struct btrfs_ioctl_space_info *)
43134 + user_dest = (struct btrfs_ioctl_space_info __user *)
43135 (arg + sizeof(struct btrfs_ioctl_space_args));
43136
43137 if (copy_to_user(user_dest, dest_orig, alloc_size))
43138 diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
43139 index 8c1aae2..1e46446 100644
43140 --- a/fs/btrfs/relocation.c
43141 +++ b/fs/btrfs/relocation.c
43142 @@ -1244,7 +1244,7 @@ static int __update_reloc_root(struct btrfs_root *root, int del)
43143 }
43144 spin_unlock(&rc->reloc_root_tree.lock);
43145
43146 - BUG_ON((struct btrfs_root *)node->data != root);
43147 + BUG_ON(!node || (struct btrfs_root *)node->data != root);
43148
43149 if (!del) {
43150 spin_lock(&rc->reloc_root_tree.lock);
43151 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
43152 index 622f469..e8d2d55 100644
43153 --- a/fs/cachefiles/bind.c
43154 +++ b/fs/cachefiles/bind.c
43155 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
43156 args);
43157
43158 /* start by checking things over */
43159 - ASSERT(cache->fstop_percent >= 0 &&
43160 - cache->fstop_percent < cache->fcull_percent &&
43161 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
43162 cache->fcull_percent < cache->frun_percent &&
43163 cache->frun_percent < 100);
43164
43165 - ASSERT(cache->bstop_percent >= 0 &&
43166 - cache->bstop_percent < cache->bcull_percent &&
43167 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
43168 cache->bcull_percent < cache->brun_percent &&
43169 cache->brun_percent < 100);
43170
43171 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
43172 index 0a1467b..6a53245 100644
43173 --- a/fs/cachefiles/daemon.c
43174 +++ b/fs/cachefiles/daemon.c
43175 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
43176 if (n > buflen)
43177 return -EMSGSIZE;
43178
43179 - if (copy_to_user(_buffer, buffer, n) != 0)
43180 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
43181 return -EFAULT;
43182
43183 return n;
43184 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
43185 if (test_bit(CACHEFILES_DEAD, &cache->flags))
43186 return -EIO;
43187
43188 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
43189 + if (datalen > PAGE_SIZE - 1)
43190 return -EOPNOTSUPP;
43191
43192 /* drag the command string into the kernel so we can parse it */
43193 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
43194 if (args[0] != '%' || args[1] != '\0')
43195 return -EINVAL;
43196
43197 - if (fstop < 0 || fstop >= cache->fcull_percent)
43198 + if (fstop >= cache->fcull_percent)
43199 return cachefiles_daemon_range_error(cache, args);
43200
43201 cache->fstop_percent = fstop;
43202 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
43203 if (args[0] != '%' || args[1] != '\0')
43204 return -EINVAL;
43205
43206 - if (bstop < 0 || bstop >= cache->bcull_percent)
43207 + if (bstop >= cache->bcull_percent)
43208 return cachefiles_daemon_range_error(cache, args);
43209
43210 cache->bstop_percent = bstop;
43211 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
43212 index bd6bc1b..b627b53 100644
43213 --- a/fs/cachefiles/internal.h
43214 +++ b/fs/cachefiles/internal.h
43215 @@ -57,7 +57,7 @@ struct cachefiles_cache {
43216 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
43217 struct rb_root active_nodes; /* active nodes (can't be culled) */
43218 rwlock_t active_lock; /* lock for active_nodes */
43219 - atomic_t gravecounter; /* graveyard uniquifier */
43220 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
43221 unsigned frun_percent; /* when to stop culling (% files) */
43222 unsigned fcull_percent; /* when to start culling (% files) */
43223 unsigned fstop_percent; /* when to stop allocating (% files) */
43224 @@ -169,19 +169,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
43225 * proc.c
43226 */
43227 #ifdef CONFIG_CACHEFILES_HISTOGRAM
43228 -extern atomic_t cachefiles_lookup_histogram[HZ];
43229 -extern atomic_t cachefiles_mkdir_histogram[HZ];
43230 -extern atomic_t cachefiles_create_histogram[HZ];
43231 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
43232 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
43233 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
43234
43235 extern int __init cachefiles_proc_init(void);
43236 extern void cachefiles_proc_cleanup(void);
43237 static inline
43238 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
43239 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
43240 {
43241 unsigned long jif = jiffies - start_jif;
43242 if (jif >= HZ)
43243 jif = HZ - 1;
43244 - atomic_inc(&histogram[jif]);
43245 + atomic_inc_unchecked(&histogram[jif]);
43246 }
43247
43248 #else
43249 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
43250 index a0358c2..d6137f2 100644
43251 --- a/fs/cachefiles/namei.c
43252 +++ b/fs/cachefiles/namei.c
43253 @@ -318,7 +318,7 @@ try_again:
43254 /* first step is to make up a grave dentry in the graveyard */
43255 sprintf(nbuffer, "%08x%08x",
43256 (uint32_t) get_seconds(),
43257 - (uint32_t) atomic_inc_return(&cache->gravecounter));
43258 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
43259
43260 /* do the multiway lock magic */
43261 trap = lock_rename(cache->graveyard, dir);
43262 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
43263 index eccd339..4c1d995 100644
43264 --- a/fs/cachefiles/proc.c
43265 +++ b/fs/cachefiles/proc.c
43266 @@ -14,9 +14,9 @@
43267 #include <linux/seq_file.h>
43268 #include "internal.h"
43269
43270 -atomic_t cachefiles_lookup_histogram[HZ];
43271 -atomic_t cachefiles_mkdir_histogram[HZ];
43272 -atomic_t cachefiles_create_histogram[HZ];
43273 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
43274 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
43275 +atomic_unchecked_t cachefiles_create_histogram[HZ];
43276
43277 /*
43278 * display the latency histogram
43279 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
43280 return 0;
43281 default:
43282 index = (unsigned long) v - 3;
43283 - x = atomic_read(&cachefiles_lookup_histogram[index]);
43284 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
43285 - z = atomic_read(&cachefiles_create_histogram[index]);
43286 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
43287 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
43288 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
43289 if (x == 0 && y == 0 && z == 0)
43290 return 0;
43291
43292 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
43293 index 0e3c092..818480e 100644
43294 --- a/fs/cachefiles/rdwr.c
43295 +++ b/fs/cachefiles/rdwr.c
43296 @@ -945,7 +945,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
43297 old_fs = get_fs();
43298 set_fs(KERNEL_DS);
43299 ret = file->f_op->write(
43300 - file, (const void __user *) data, len, &pos);
43301 + file, (const void __force_user *) data, len, &pos);
43302 set_fs(old_fs);
43303 kunmap(page);
43304 if (ret != len)
43305 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
43306 index 3e8094b..cb3ff3d 100644
43307 --- a/fs/ceph/dir.c
43308 +++ b/fs/ceph/dir.c
43309 @@ -244,7 +244,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
43310 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
43311 struct ceph_mds_client *mdsc = fsc->mdsc;
43312 unsigned frag = fpos_frag(filp->f_pos);
43313 - int off = fpos_off(filp->f_pos);
43314 + unsigned int off = fpos_off(filp->f_pos);
43315 int err;
43316 u32 ftype;
43317 struct ceph_mds_reply_info_parsed *rinfo;
43318 @@ -598,7 +598,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
43319 if (nd &&
43320 (nd->flags & LOOKUP_OPEN) &&
43321 !(nd->intent.open.flags & O_CREAT)) {
43322 - int mode = nd->intent.open.create_mode & ~current->fs->umask;
43323 + int mode = nd->intent.open.create_mode & ~current_umask();
43324 return ceph_lookup_open(dir, dentry, nd, mode, 1);
43325 }
43326
43327 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
43328 index 24b3dfc..3cd5454 100644
43329 --- a/fs/cifs/cifs_debug.c
43330 +++ b/fs/cifs/cifs_debug.c
43331 @@ -265,8 +265,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
43332
43333 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
43334 #ifdef CONFIG_CIFS_STATS2
43335 - atomic_set(&totBufAllocCount, 0);
43336 - atomic_set(&totSmBufAllocCount, 0);
43337 + atomic_set_unchecked(&totBufAllocCount, 0);
43338 + atomic_set_unchecked(&totSmBufAllocCount, 0);
43339 #endif /* CONFIG_CIFS_STATS2 */
43340 spin_lock(&cifs_tcp_ses_lock);
43341 list_for_each(tmp1, &cifs_tcp_ses_list) {
43342 @@ -279,25 +279,25 @@ static ssize_t cifs_stats_proc_write(struct file *file,
43343 tcon = list_entry(tmp3,
43344 struct cifs_tcon,
43345 tcon_list);
43346 - atomic_set(&tcon->num_smbs_sent, 0);
43347 - atomic_set(&tcon->num_writes, 0);
43348 - atomic_set(&tcon->num_reads, 0);
43349 - atomic_set(&tcon->num_oplock_brks, 0);
43350 - atomic_set(&tcon->num_opens, 0);
43351 - atomic_set(&tcon->num_posixopens, 0);
43352 - atomic_set(&tcon->num_posixmkdirs, 0);
43353 - atomic_set(&tcon->num_closes, 0);
43354 - atomic_set(&tcon->num_deletes, 0);
43355 - atomic_set(&tcon->num_mkdirs, 0);
43356 - atomic_set(&tcon->num_rmdirs, 0);
43357 - atomic_set(&tcon->num_renames, 0);
43358 - atomic_set(&tcon->num_t2renames, 0);
43359 - atomic_set(&tcon->num_ffirst, 0);
43360 - atomic_set(&tcon->num_fnext, 0);
43361 - atomic_set(&tcon->num_fclose, 0);
43362 - atomic_set(&tcon->num_hardlinks, 0);
43363 - atomic_set(&tcon->num_symlinks, 0);
43364 - atomic_set(&tcon->num_locks, 0);
43365 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
43366 + atomic_set_unchecked(&tcon->num_writes, 0);
43367 + atomic_set_unchecked(&tcon->num_reads, 0);
43368 + atomic_set_unchecked(&tcon->num_oplock_brks, 0);
43369 + atomic_set_unchecked(&tcon->num_opens, 0);
43370 + atomic_set_unchecked(&tcon->num_posixopens, 0);
43371 + atomic_set_unchecked(&tcon->num_posixmkdirs, 0);
43372 + atomic_set_unchecked(&tcon->num_closes, 0);
43373 + atomic_set_unchecked(&tcon->num_deletes, 0);
43374 + atomic_set_unchecked(&tcon->num_mkdirs, 0);
43375 + atomic_set_unchecked(&tcon->num_rmdirs, 0);
43376 + atomic_set_unchecked(&tcon->num_renames, 0);
43377 + atomic_set_unchecked(&tcon->num_t2renames, 0);
43378 + atomic_set_unchecked(&tcon->num_ffirst, 0);
43379 + atomic_set_unchecked(&tcon->num_fnext, 0);
43380 + atomic_set_unchecked(&tcon->num_fclose, 0);
43381 + atomic_set_unchecked(&tcon->num_hardlinks, 0);
43382 + atomic_set_unchecked(&tcon->num_symlinks, 0);
43383 + atomic_set_unchecked(&tcon->num_locks, 0);
43384 }
43385 }
43386 }
43387 @@ -327,8 +327,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
43388 smBufAllocCount.counter, cifs_min_small);
43389 #ifdef CONFIG_CIFS_STATS2
43390 seq_printf(m, "Total Large %d Small %d Allocations\n",
43391 - atomic_read(&totBufAllocCount),
43392 - atomic_read(&totSmBufAllocCount));
43393 + atomic_read_unchecked(&totBufAllocCount),
43394 + atomic_read_unchecked(&totSmBufAllocCount));
43395 #endif /* CONFIG_CIFS_STATS2 */
43396
43397 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
43398 @@ -357,41 +357,41 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
43399 if (tcon->need_reconnect)
43400 seq_puts(m, "\tDISCONNECTED ");
43401 seq_printf(m, "\nSMBs: %d Oplock Breaks: %d",
43402 - atomic_read(&tcon->num_smbs_sent),
43403 - atomic_read(&tcon->num_oplock_brks));
43404 + atomic_read_unchecked(&tcon->num_smbs_sent),
43405 + atomic_read_unchecked(&tcon->num_oplock_brks));
43406 seq_printf(m, "\nReads: %d Bytes: %lld",
43407 - atomic_read(&tcon->num_reads),
43408 + atomic_read_unchecked(&tcon->num_reads),
43409 (long long)(tcon->bytes_read));
43410 seq_printf(m, "\nWrites: %d Bytes: %lld",
43411 - atomic_read(&tcon->num_writes),
43412 + atomic_read_unchecked(&tcon->num_writes),
43413 (long long)(tcon->bytes_written));
43414 seq_printf(m, "\nFlushes: %d",
43415 - atomic_read(&tcon->num_flushes));
43416 + atomic_read_unchecked(&tcon->num_flushes));
43417 seq_printf(m, "\nLocks: %d HardLinks: %d "
43418 "Symlinks: %d",
43419 - atomic_read(&tcon->num_locks),
43420 - atomic_read(&tcon->num_hardlinks),
43421 - atomic_read(&tcon->num_symlinks));
43422 + atomic_read_unchecked(&tcon->num_locks),
43423 + atomic_read_unchecked(&tcon->num_hardlinks),
43424 + atomic_read_unchecked(&tcon->num_symlinks));
43425 seq_printf(m, "\nOpens: %d Closes: %d "
43426 "Deletes: %d",
43427 - atomic_read(&tcon->num_opens),
43428 - atomic_read(&tcon->num_closes),
43429 - atomic_read(&tcon->num_deletes));
43430 + atomic_read_unchecked(&tcon->num_opens),
43431 + atomic_read_unchecked(&tcon->num_closes),
43432 + atomic_read_unchecked(&tcon->num_deletes));
43433 seq_printf(m, "\nPosix Opens: %d "
43434 "Posix Mkdirs: %d",
43435 - atomic_read(&tcon->num_posixopens),
43436 - atomic_read(&tcon->num_posixmkdirs));
43437 + atomic_read_unchecked(&tcon->num_posixopens),
43438 + atomic_read_unchecked(&tcon->num_posixmkdirs));
43439 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
43440 - atomic_read(&tcon->num_mkdirs),
43441 - atomic_read(&tcon->num_rmdirs));
43442 + atomic_read_unchecked(&tcon->num_mkdirs),
43443 + atomic_read_unchecked(&tcon->num_rmdirs));
43444 seq_printf(m, "\nRenames: %d T2 Renames %d",
43445 - atomic_read(&tcon->num_renames),
43446 - atomic_read(&tcon->num_t2renames));
43447 + atomic_read_unchecked(&tcon->num_renames),
43448 + atomic_read_unchecked(&tcon->num_t2renames));
43449 seq_printf(m, "\nFindFirst: %d FNext %d "
43450 "FClose %d",
43451 - atomic_read(&tcon->num_ffirst),
43452 - atomic_read(&tcon->num_fnext),
43453 - atomic_read(&tcon->num_fclose));
43454 + atomic_read_unchecked(&tcon->num_ffirst),
43455 + atomic_read_unchecked(&tcon->num_fnext),
43456 + atomic_read_unchecked(&tcon->num_fclose));
43457 }
43458 }
43459 }
43460 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
43461 index 70dd381..b8ce03b 100644
43462 --- a/fs/cifs/cifsfs.c
43463 +++ b/fs/cifs/cifsfs.c
43464 @@ -989,7 +989,7 @@ cifs_init_request_bufs(void)
43465 cifs_req_cachep = kmem_cache_create("cifs_request",
43466 CIFSMaxBufSize +
43467 MAX_CIFS_HDR_SIZE, 0,
43468 - SLAB_HWCACHE_ALIGN, NULL);
43469 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
43470 if (cifs_req_cachep == NULL)
43471 return -ENOMEM;
43472
43473 @@ -1016,7 +1016,7 @@ cifs_init_request_bufs(void)
43474 efficient to alloc 1 per page off the slab compared to 17K (5page)
43475 alloc of large cifs buffers even when page debugging is on */
43476 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
43477 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
43478 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
43479 NULL);
43480 if (cifs_sm_req_cachep == NULL) {
43481 mempool_destroy(cifs_req_poolp);
43482 @@ -1101,8 +1101,8 @@ init_cifs(void)
43483 atomic_set(&bufAllocCount, 0);
43484 atomic_set(&smBufAllocCount, 0);
43485 #ifdef CONFIG_CIFS_STATS2
43486 - atomic_set(&totBufAllocCount, 0);
43487 - atomic_set(&totSmBufAllocCount, 0);
43488 + atomic_set_unchecked(&totBufAllocCount, 0);
43489 + atomic_set_unchecked(&totSmBufAllocCount, 0);
43490 #endif /* CONFIG_CIFS_STATS2 */
43491
43492 atomic_set(&midCount, 0);
43493 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
43494 index d47d20a..77e8b33 100644
43495 --- a/fs/cifs/cifsglob.h
43496 +++ b/fs/cifs/cifsglob.h
43497 @@ -388,28 +388,28 @@ struct cifs_tcon {
43498 __u16 Flags; /* optional support bits */
43499 enum statusEnum tidStatus;
43500 #ifdef CONFIG_CIFS_STATS
43501 - atomic_t num_smbs_sent;
43502 - atomic_t num_writes;
43503 - atomic_t num_reads;
43504 - atomic_t num_flushes;
43505 - atomic_t num_oplock_brks;
43506 - atomic_t num_opens;
43507 - atomic_t num_closes;
43508 - atomic_t num_deletes;
43509 - atomic_t num_mkdirs;
43510 - atomic_t num_posixopens;
43511 - atomic_t num_posixmkdirs;
43512 - atomic_t num_rmdirs;
43513 - atomic_t num_renames;
43514 - atomic_t num_t2renames;
43515 - atomic_t num_ffirst;
43516 - atomic_t num_fnext;
43517 - atomic_t num_fclose;
43518 - atomic_t num_hardlinks;
43519 - atomic_t num_symlinks;
43520 - atomic_t num_locks;
43521 - atomic_t num_acl_get;
43522 - atomic_t num_acl_set;
43523 + atomic_unchecked_t num_smbs_sent;
43524 + atomic_unchecked_t num_writes;
43525 + atomic_unchecked_t num_reads;
43526 + atomic_unchecked_t num_flushes;
43527 + atomic_unchecked_t num_oplock_brks;
43528 + atomic_unchecked_t num_opens;
43529 + atomic_unchecked_t num_closes;
43530 + atomic_unchecked_t num_deletes;
43531 + atomic_unchecked_t num_mkdirs;
43532 + atomic_unchecked_t num_posixopens;
43533 + atomic_unchecked_t num_posixmkdirs;
43534 + atomic_unchecked_t num_rmdirs;
43535 + atomic_unchecked_t num_renames;
43536 + atomic_unchecked_t num_t2renames;
43537 + atomic_unchecked_t num_ffirst;
43538 + atomic_unchecked_t num_fnext;
43539 + atomic_unchecked_t num_fclose;
43540 + atomic_unchecked_t num_hardlinks;
43541 + atomic_unchecked_t num_symlinks;
43542 + atomic_unchecked_t num_locks;
43543 + atomic_unchecked_t num_acl_get;
43544 + atomic_unchecked_t num_acl_set;
43545 #ifdef CONFIG_CIFS_STATS2
43546 unsigned long long time_writes;
43547 unsigned long long time_reads;
43548 @@ -624,7 +624,7 @@ convert_delimiter(char *path, char delim)
43549 }
43550
43551 #ifdef CONFIG_CIFS_STATS
43552 -#define cifs_stats_inc atomic_inc
43553 +#define cifs_stats_inc atomic_inc_unchecked
43554
43555 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
43556 unsigned int bytes)
43557 @@ -983,8 +983,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
43558 /* Various Debug counters */
43559 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
43560 #ifdef CONFIG_CIFS_STATS2
43561 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
43562 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
43563 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
43564 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
43565 #endif
43566 GLOBAL_EXTERN atomic_t smBufAllocCount;
43567 GLOBAL_EXTERN atomic_t midCount;
43568 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
43569 index 6b0e064..94e6c3c 100644
43570 --- a/fs/cifs/link.c
43571 +++ b/fs/cifs/link.c
43572 @@ -600,7 +600,7 @@ symlink_exit:
43573
43574 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
43575 {
43576 - char *p = nd_get_link(nd);
43577 + const char *p = nd_get_link(nd);
43578 if (!IS_ERR(p))
43579 kfree(p);
43580 }
43581 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
43582 index 703ef5c..2a44ed5 100644
43583 --- a/fs/cifs/misc.c
43584 +++ b/fs/cifs/misc.c
43585 @@ -156,7 +156,7 @@ cifs_buf_get(void)
43586 memset(ret_buf, 0, sizeof(struct smb_hdr) + 3);
43587 atomic_inc(&bufAllocCount);
43588 #ifdef CONFIG_CIFS_STATS2
43589 - atomic_inc(&totBufAllocCount);
43590 + atomic_inc_unchecked(&totBufAllocCount);
43591 #endif /* CONFIG_CIFS_STATS2 */
43592 }
43593
43594 @@ -191,7 +191,7 @@ cifs_small_buf_get(void)
43595 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
43596 atomic_inc(&smBufAllocCount);
43597 #ifdef CONFIG_CIFS_STATS2
43598 - atomic_inc(&totSmBufAllocCount);
43599 + atomic_inc_unchecked(&totSmBufAllocCount);
43600 #endif /* CONFIG_CIFS_STATS2 */
43601
43602 }
43603 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
43604 index 6901578..d402eb5 100644
43605 --- a/fs/coda/cache.c
43606 +++ b/fs/coda/cache.c
43607 @@ -24,7 +24,7 @@
43608 #include "coda_linux.h"
43609 #include "coda_cache.h"
43610
43611 -static atomic_t permission_epoch = ATOMIC_INIT(0);
43612 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
43613
43614 /* replace or extend an acl cache hit */
43615 void coda_cache_enter(struct inode *inode, int mask)
43616 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
43617 struct coda_inode_info *cii = ITOC(inode);
43618
43619 spin_lock(&cii->c_lock);
43620 - cii->c_cached_epoch = atomic_read(&permission_epoch);
43621 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
43622 if (cii->c_uid != current_fsuid()) {
43623 cii->c_uid = current_fsuid();
43624 cii->c_cached_perm = mask;
43625 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
43626 {
43627 struct coda_inode_info *cii = ITOC(inode);
43628 spin_lock(&cii->c_lock);
43629 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
43630 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
43631 spin_unlock(&cii->c_lock);
43632 }
43633
43634 /* remove all acl caches */
43635 void coda_cache_clear_all(struct super_block *sb)
43636 {
43637 - atomic_inc(&permission_epoch);
43638 + atomic_inc_unchecked(&permission_epoch);
43639 }
43640
43641
43642 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
43643 spin_lock(&cii->c_lock);
43644 hit = (mask & cii->c_cached_perm) == mask &&
43645 cii->c_uid == current_fsuid() &&
43646 - cii->c_cached_epoch == atomic_read(&permission_epoch);
43647 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
43648 spin_unlock(&cii->c_lock);
43649
43650 return hit;
43651 diff --git a/fs/compat.c b/fs/compat.c
43652 index 07880ba..3fb2862 100644
43653 --- a/fs/compat.c
43654 +++ b/fs/compat.c
43655 @@ -491,7 +491,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
43656
43657 set_fs(KERNEL_DS);
43658 /* The __user pointer cast is valid because of the set_fs() */
43659 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
43660 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
43661 set_fs(oldfs);
43662 /* truncating is ok because it's a user address */
43663 if (!ret)
43664 @@ -549,7 +549,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
43665 goto out;
43666
43667 ret = -EINVAL;
43668 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
43669 + if (nr_segs > UIO_MAXIOV)
43670 goto out;
43671 if (nr_segs > fast_segs) {
43672 ret = -ENOMEM;
43673 @@ -832,6 +832,7 @@ struct compat_old_linux_dirent {
43674
43675 struct compat_readdir_callback {
43676 struct compat_old_linux_dirent __user *dirent;
43677 + struct file * file;
43678 int result;
43679 };
43680
43681 @@ -849,6 +850,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
43682 buf->result = -EOVERFLOW;
43683 return -EOVERFLOW;
43684 }
43685 +
43686 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
43687 + return 0;
43688 +
43689 buf->result++;
43690 dirent = buf->dirent;
43691 if (!access_ok(VERIFY_WRITE, dirent,
43692 @@ -881,6 +886,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
43693
43694 buf.result = 0;
43695 buf.dirent = dirent;
43696 + buf.file = file;
43697
43698 error = vfs_readdir(file, compat_fillonedir, &buf);
43699 if (buf.result)
43700 @@ -901,6 +907,7 @@ struct compat_linux_dirent {
43701 struct compat_getdents_callback {
43702 struct compat_linux_dirent __user *current_dir;
43703 struct compat_linux_dirent __user *previous;
43704 + struct file * file;
43705 int count;
43706 int error;
43707 };
43708 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
43709 buf->error = -EOVERFLOW;
43710 return -EOVERFLOW;
43711 }
43712 +
43713 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
43714 + return 0;
43715 +
43716 dirent = buf->previous;
43717 if (dirent) {
43718 if (__put_user(offset, &dirent->d_off))
43719 @@ -969,6 +980,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
43720 buf.previous = NULL;
43721 buf.count = count;
43722 buf.error = 0;
43723 + buf.file = file;
43724
43725 error = vfs_readdir(file, compat_filldir, &buf);
43726 if (error >= 0)
43727 @@ -990,6 +1002,7 @@ out:
43728 struct compat_getdents_callback64 {
43729 struct linux_dirent64 __user *current_dir;
43730 struct linux_dirent64 __user *previous;
43731 + struct file * file;
43732 int count;
43733 int error;
43734 };
43735 @@ -1006,6 +1019,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
43736 buf->error = -EINVAL; /* only used if we fail.. */
43737 if (reclen > buf->count)
43738 return -EINVAL;
43739 +
43740 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
43741 + return 0;
43742 +
43743 dirent = buf->previous;
43744
43745 if (dirent) {
43746 @@ -1057,13 +1074,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
43747 buf.previous = NULL;
43748 buf.count = count;
43749 buf.error = 0;
43750 + buf.file = file;
43751
43752 error = vfs_readdir(file, compat_filldir64, &buf);
43753 if (error >= 0)
43754 error = buf.error;
43755 lastdirent = buf.previous;
43756 if (lastdirent) {
43757 - typeof(lastdirent->d_off) d_off = file->f_pos;
43758 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = file->f_pos;
43759 if (__put_user_unaligned(d_off, &lastdirent->d_off))
43760 error = -EFAULT;
43761 else
43762 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
43763 index 112e45a..b59845b 100644
43764 --- a/fs/compat_binfmt_elf.c
43765 +++ b/fs/compat_binfmt_elf.c
43766 @@ -30,11 +30,13 @@
43767 #undef elf_phdr
43768 #undef elf_shdr
43769 #undef elf_note
43770 +#undef elf_dyn
43771 #undef elf_addr_t
43772 #define elfhdr elf32_hdr
43773 #define elf_phdr elf32_phdr
43774 #define elf_shdr elf32_shdr
43775 #define elf_note elf32_note
43776 +#define elf_dyn Elf32_Dyn
43777 #define elf_addr_t Elf32_Addr
43778
43779 /*
43780 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
43781 index a26bea1..ae23e72 100644
43782 --- a/fs/compat_ioctl.c
43783 +++ b/fs/compat_ioctl.c
43784 @@ -211,6 +211,8 @@ static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd,
43785
43786 err = get_user(palp, &up->palette);
43787 err |= get_user(length, &up->length);
43788 + if (err)
43789 + return -EFAULT;
43790
43791 up_native = compat_alloc_user_space(sizeof(struct video_spu_palette));
43792 err = put_user(compat_ptr(palp), &up_native->palette);
43793 @@ -622,7 +624,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
43794 return -EFAULT;
43795 if (__get_user(udata, &ss32->iomem_base))
43796 return -EFAULT;
43797 - ss.iomem_base = compat_ptr(udata);
43798 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
43799 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
43800 __get_user(ss.port_high, &ss32->port_high))
43801 return -EFAULT;
43802 @@ -797,7 +799,7 @@ static int compat_ioctl_preallocate(struct file *file,
43803 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
43804 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
43805 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
43806 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
43807 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
43808 return -EFAULT;
43809
43810 return ioctl_preallocate(file, p);
43811 @@ -1611,8 +1613,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
43812 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
43813 {
43814 unsigned int a, b;
43815 - a = *(unsigned int *)p;
43816 - b = *(unsigned int *)q;
43817 + a = *(const unsigned int *)p;
43818 + b = *(const unsigned int *)q;
43819 if (a > b)
43820 return 1;
43821 if (a < b)
43822 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
43823 index 5ddd7eb..c18bf04 100644
43824 --- a/fs/configfs/dir.c
43825 +++ b/fs/configfs/dir.c
43826 @@ -1575,7 +1575,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
43827 }
43828 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
43829 struct configfs_dirent *next;
43830 - const char * name;
43831 + const unsigned char * name;
43832 + char d_name[sizeof(next->s_dentry->d_iname)];
43833 int len;
43834 struct inode *inode = NULL;
43835
43836 @@ -1585,7 +1586,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
43837 continue;
43838
43839 name = configfs_get_name(next);
43840 - len = strlen(name);
43841 + if (next->s_dentry && name == next->s_dentry->d_iname) {
43842 + len = next->s_dentry->d_name.len;
43843 + memcpy(d_name, name, len);
43844 + name = d_name;
43845 + } else
43846 + len = strlen(name);
43847
43848 /*
43849 * We'll have a dentry and an inode for
43850 diff --git a/fs/dcache.c b/fs/dcache.c
43851 index 2576d14..0cec38d 100644
43852 --- a/fs/dcache.c
43853 +++ b/fs/dcache.c
43854 @@ -105,10 +105,10 @@ static unsigned int d_hash_shift __read_mostly;
43855 static struct hlist_bl_head *dentry_hashtable __read_mostly;
43856
43857 static inline struct hlist_bl_head *d_hash(const struct dentry *parent,
43858 - unsigned long hash)
43859 + unsigned int hash)
43860 {
43861 - hash += ((unsigned long) parent ^ GOLDEN_RATIO_PRIME) / L1_CACHE_BYTES;
43862 - hash = hash ^ ((hash ^ GOLDEN_RATIO_PRIME) >> D_HASHBITS);
43863 + hash += (unsigned long) parent / L1_CACHE_BYTES;
43864 + hash = hash + (hash >> D_HASHBITS);
43865 return dentry_hashtable + (hash & D_HASHMASK);
43866 }
43867
43868 @@ -3067,7 +3067,7 @@ void __init vfs_caches_init(unsigned long mempages)
43869 mempages -= reserve;
43870
43871 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
43872 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
43873 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY, NULL);
43874
43875 dcache_init();
43876 inode_init();
43877 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
43878 index 956d5dd..e755e04 100644
43879 --- a/fs/debugfs/inode.c
43880 +++ b/fs/debugfs/inode.c
43881 @@ -261,7 +261,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
43882 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
43883 {
43884 return debugfs_create_file(name,
43885 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
43886 + S_IFDIR | S_IRWXU,
43887 +#else
43888 S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
43889 +#endif
43890 parent, NULL, NULL);
43891 }
43892 EXPORT_SYMBOL_GPL(debugfs_create_dir);
43893 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
43894 index ab35b11..b30af66 100644
43895 --- a/fs/ecryptfs/inode.c
43896 +++ b/fs/ecryptfs/inode.c
43897 @@ -672,7 +672,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
43898 old_fs = get_fs();
43899 set_fs(get_ds());
43900 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
43901 - (char __user *)lower_buf,
43902 + (char __force_user *)lower_buf,
43903 lower_bufsiz);
43904 set_fs(old_fs);
43905 if (rc < 0)
43906 @@ -718,7 +718,7 @@ static void *ecryptfs_follow_link(struct dentry *dentry, struct nameidata *nd)
43907 }
43908 old_fs = get_fs();
43909 set_fs(get_ds());
43910 - rc = dentry->d_inode->i_op->readlink(dentry, (char __user *)buf, len);
43911 + rc = dentry->d_inode->i_op->readlink(dentry, (char __force_user *)buf, len);
43912 set_fs(old_fs);
43913 if (rc < 0) {
43914 kfree(buf);
43915 @@ -733,7 +733,7 @@ out:
43916 static void
43917 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
43918 {
43919 - char *buf = nd_get_link(nd);
43920 + const char *buf = nd_get_link(nd);
43921 if (!IS_ERR(buf)) {
43922 /* Free the char* */
43923 kfree(buf);
43924 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
43925 index 3a06f40..f7af544 100644
43926 --- a/fs/ecryptfs/miscdev.c
43927 +++ b/fs/ecryptfs/miscdev.c
43928 @@ -345,7 +345,7 @@ check_list:
43929 goto out_unlock_msg_ctx;
43930 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
43931 if (msg_ctx->msg) {
43932 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
43933 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
43934 goto out_unlock_msg_ctx;
43935 i += packet_length_size;
43936 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
43937 diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
43938 index b2a34a1..162fa69 100644
43939 --- a/fs/ecryptfs/read_write.c
43940 +++ b/fs/ecryptfs/read_write.c
43941 @@ -48,7 +48,7 @@ int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data,
43942 return -EIO;
43943 fs_save = get_fs();
43944 set_fs(get_ds());
43945 - rc = vfs_write(lower_file, data, size, &offset);
43946 + rc = vfs_write(lower_file, (const char __force_user *)data, size, &offset);
43947 set_fs(fs_save);
43948 mark_inode_dirty_sync(ecryptfs_inode);
43949 return rc;
43950 @@ -244,7 +244,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
43951 return -EIO;
43952 fs_save = get_fs();
43953 set_fs(get_ds());
43954 - rc = vfs_read(lower_file, data, size, &offset);
43955 + rc = vfs_read(lower_file, (char __force_user *)data, size, &offset);
43956 set_fs(fs_save);
43957 return rc;
43958 }
43959 diff --git a/fs/exec.c b/fs/exec.c
43960 index ae42277..32c9035 100644
43961 --- a/fs/exec.c
43962 +++ b/fs/exec.c
43963 @@ -55,6 +55,13 @@
43964 #include <linux/pipe_fs_i.h>
43965 #include <linux/oom.h>
43966 #include <linux/compat.h>
43967 +#include <linux/random.h>
43968 +#include <linux/seq_file.h>
43969 +
43970 +#ifdef CONFIG_PAX_REFCOUNT
43971 +#include <linux/kallsyms.h>
43972 +#include <linux/kdebug.h>
43973 +#endif
43974
43975 #include <asm/uaccess.h>
43976 #include <asm/mmu_context.h>
43977 @@ -63,6 +70,15 @@
43978 #include <trace/events/task.h>
43979 #include "internal.h"
43980
43981 +#ifndef CONFIG_PAX_HAVE_ACL_FLAGS
43982 +void __weak pax_set_initial_flags(struct linux_binprm *bprm) {}
43983 +#endif
43984 +
43985 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
43986 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
43987 +EXPORT_SYMBOL(pax_set_initial_flags_func);
43988 +#endif
43989 +
43990 int core_uses_pid;
43991 char core_pattern[CORENAME_MAX_SIZE] = "core";
43992 unsigned int core_pipe_limit;
43993 @@ -72,7 +88,7 @@ struct core_name {
43994 char *corename;
43995 int used, size;
43996 };
43997 -static atomic_t call_count = ATOMIC_INIT(1);
43998 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
43999
44000 /* The maximal length of core_pattern is also specified in sysctl.c */
44001
44002 @@ -190,18 +206,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
44003 int write)
44004 {
44005 struct page *page;
44006 - int ret;
44007
44008 -#ifdef CONFIG_STACK_GROWSUP
44009 - if (write) {
44010 - ret = expand_downwards(bprm->vma, pos);
44011 - if (ret < 0)
44012 - return NULL;
44013 - }
44014 -#endif
44015 - ret = get_user_pages(current, bprm->mm, pos,
44016 - 1, write, 1, &page, NULL);
44017 - if (ret <= 0)
44018 + if (0 > expand_downwards(bprm->vma, pos))
44019 + return NULL;
44020 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
44021 return NULL;
44022
44023 if (write) {
44024 @@ -217,6 +225,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
44025 if (size <= ARG_MAX)
44026 return page;
44027
44028 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
44029 + // only allow 512KB for argv+env on suid/sgid binaries
44030 + // to prevent easy ASLR exhaustion
44031 + if (((bprm->cred->euid != current_euid()) ||
44032 + (bprm->cred->egid != current_egid())) &&
44033 + (size > (512 * 1024))) {
44034 + put_page(page);
44035 + return NULL;
44036 + }
44037 +#endif
44038 +
44039 /*
44040 * Limit to 1/4-th the stack size for the argv+env strings.
44041 * This ensures that:
44042 @@ -276,6 +295,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
44043 vma->vm_end = STACK_TOP_MAX;
44044 vma->vm_start = vma->vm_end - PAGE_SIZE;
44045 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
44046 +
44047 +#ifdef CONFIG_PAX_SEGMEXEC
44048 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
44049 +#endif
44050 +
44051 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
44052 INIT_LIST_HEAD(&vma->anon_vma_chain);
44053
44054 @@ -290,6 +314,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
44055 mm->stack_vm = mm->total_vm = 1;
44056 up_write(&mm->mmap_sem);
44057 bprm->p = vma->vm_end - sizeof(void *);
44058 +
44059 +#ifdef CONFIG_PAX_RANDUSTACK
44060 + if (randomize_va_space)
44061 + bprm->p ^= random32() & ~PAGE_MASK;
44062 +#endif
44063 +
44064 return 0;
44065 err:
44066 up_write(&mm->mmap_sem);
44067 @@ -398,19 +428,7 @@ err:
44068 return err;
44069 }
44070
44071 -struct user_arg_ptr {
44072 -#ifdef CONFIG_COMPAT
44073 - bool is_compat;
44074 -#endif
44075 - union {
44076 - const char __user *const __user *native;
44077 -#ifdef CONFIG_COMPAT
44078 - compat_uptr_t __user *compat;
44079 -#endif
44080 - } ptr;
44081 -};
44082 -
44083 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
44084 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
44085 {
44086 const char __user *native;
44087
44088 @@ -419,14 +437,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
44089 compat_uptr_t compat;
44090
44091 if (get_user(compat, argv.ptr.compat + nr))
44092 - return ERR_PTR(-EFAULT);
44093 + return (const char __force_user *)ERR_PTR(-EFAULT);
44094
44095 return compat_ptr(compat);
44096 }
44097 #endif
44098
44099 if (get_user(native, argv.ptr.native + nr))
44100 - return ERR_PTR(-EFAULT);
44101 + return (const char __force_user *)ERR_PTR(-EFAULT);
44102
44103 return native;
44104 }
44105 @@ -445,7 +463,7 @@ static int count(struct user_arg_ptr argv, int max)
44106 if (!p)
44107 break;
44108
44109 - if (IS_ERR(p))
44110 + if (IS_ERR((const char __force_kernel *)p))
44111 return -EFAULT;
44112
44113 if (i++ >= max)
44114 @@ -479,7 +497,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
44115
44116 ret = -EFAULT;
44117 str = get_user_arg_ptr(argv, argc);
44118 - if (IS_ERR(str))
44119 + if (IS_ERR((const char __force_kernel *)str))
44120 goto out;
44121
44122 len = strnlen_user(str, MAX_ARG_STRLEN);
44123 @@ -561,7 +579,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
44124 int r;
44125 mm_segment_t oldfs = get_fs();
44126 struct user_arg_ptr argv = {
44127 - .ptr.native = (const char __user *const __user *)__argv,
44128 + .ptr.native = (const char __force_user *const __force_user *)__argv,
44129 };
44130
44131 set_fs(KERNEL_DS);
44132 @@ -596,7 +614,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
44133 unsigned long new_end = old_end - shift;
44134 struct mmu_gather tlb;
44135
44136 - BUG_ON(new_start > new_end);
44137 + if (new_start >= new_end || new_start < mmap_min_addr)
44138 + return -ENOMEM;
44139
44140 /*
44141 * ensure there are no vmas between where we want to go
44142 @@ -605,6 +624,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
44143 if (vma != find_vma(mm, new_start))
44144 return -EFAULT;
44145
44146 +#ifdef CONFIG_PAX_SEGMEXEC
44147 + BUG_ON(pax_find_mirror_vma(vma));
44148 +#endif
44149 +
44150 /*
44151 * cover the whole range: [new_start, old_end)
44152 */
44153 @@ -685,10 +708,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
44154 stack_top = arch_align_stack(stack_top);
44155 stack_top = PAGE_ALIGN(stack_top);
44156
44157 - if (unlikely(stack_top < mmap_min_addr) ||
44158 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
44159 - return -ENOMEM;
44160 -
44161 stack_shift = vma->vm_end - stack_top;
44162
44163 bprm->p -= stack_shift;
44164 @@ -700,8 +719,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
44165 bprm->exec -= stack_shift;
44166
44167 down_write(&mm->mmap_sem);
44168 +
44169 + /* Move stack pages down in memory. */
44170 + if (stack_shift) {
44171 + ret = shift_arg_pages(vma, stack_shift);
44172 + if (ret)
44173 + goto out_unlock;
44174 + }
44175 +
44176 vm_flags = VM_STACK_FLAGS;
44177
44178 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
44179 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
44180 + vm_flags &= ~VM_EXEC;
44181 +
44182 +#ifdef CONFIG_PAX_MPROTECT
44183 + if (mm->pax_flags & MF_PAX_MPROTECT)
44184 + vm_flags &= ~VM_MAYEXEC;
44185 +#endif
44186 +
44187 + }
44188 +#endif
44189 +
44190 /*
44191 * Adjust stack execute permissions; explicitly enable for
44192 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
44193 @@ -720,13 +759,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
44194 goto out_unlock;
44195 BUG_ON(prev != vma);
44196
44197 - /* Move stack pages down in memory. */
44198 - if (stack_shift) {
44199 - ret = shift_arg_pages(vma, stack_shift);
44200 - if (ret)
44201 - goto out_unlock;
44202 - }
44203 -
44204 /* mprotect_fixup is overkill to remove the temporary stack flags */
44205 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
44206
44207 @@ -807,7 +839,7 @@ int kernel_read(struct file *file, loff_t offset,
44208 old_fs = get_fs();
44209 set_fs(get_ds());
44210 /* The cast to a user pointer is valid due to the set_fs() */
44211 - result = vfs_read(file, (void __user *)addr, count, &pos);
44212 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
44213 set_fs(old_fs);
44214 return result;
44215 }
44216 @@ -1255,7 +1287,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
44217 }
44218 rcu_read_unlock();
44219
44220 - if (p->fs->users > n_fs) {
44221 + if (atomic_read(&p->fs->users) > n_fs) {
44222 bprm->unsafe |= LSM_UNSAFE_SHARE;
44223 } else {
44224 res = -EAGAIN;
44225 @@ -1450,6 +1482,28 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
44226
44227 EXPORT_SYMBOL(search_binary_handler);
44228
44229 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
44230 +static DEFINE_PER_CPU(u64, exec_counter);
44231 +static int __init init_exec_counters(void)
44232 +{
44233 + unsigned int cpu;
44234 +
44235 + for_each_possible_cpu(cpu) {
44236 + per_cpu(exec_counter, cpu) = (u64)cpu;
44237 + }
44238 +
44239 + return 0;
44240 +}
44241 +early_initcall(init_exec_counters);
44242 +static inline void increment_exec_counter(void)
44243 +{
44244 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
44245 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
44246 +}
44247 +#else
44248 +static inline void increment_exec_counter(void) {}
44249 +#endif
44250 +
44251 /*
44252 * sys_execve() executes a new program.
44253 */
44254 @@ -1458,6 +1512,11 @@ static int do_execve_common(const char *filename,
44255 struct user_arg_ptr envp,
44256 struct pt_regs *regs)
44257 {
44258 +#ifdef CONFIG_GRKERNSEC
44259 + struct file *old_exec_file;
44260 + struct acl_subject_label *old_acl;
44261 + struct rlimit old_rlim[RLIM_NLIMITS];
44262 +#endif
44263 struct linux_binprm *bprm;
44264 struct file *file;
44265 struct files_struct *displaced;
44266 @@ -1465,6 +1524,8 @@ static int do_execve_common(const char *filename,
44267 int retval;
44268 const struct cred *cred = current_cred();
44269
44270 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current->cred->user->processes), 1);
44271 +
44272 /*
44273 * We move the actual failure in case of RLIMIT_NPROC excess from
44274 * set*uid() to execve() because too many poorly written programs
44275 @@ -1505,12 +1566,27 @@ static int do_execve_common(const char *filename,
44276 if (IS_ERR(file))
44277 goto out_unmark;
44278
44279 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
44280 + retval = -EPERM;
44281 + goto out_file;
44282 + }
44283 +
44284 sched_exec();
44285
44286 bprm->file = file;
44287 bprm->filename = filename;
44288 bprm->interp = filename;
44289
44290 + if (gr_process_user_ban()) {
44291 + retval = -EPERM;
44292 + goto out_file;
44293 + }
44294 +
44295 + if (!gr_acl_handle_execve(file->f_dentry, file->f_vfsmnt)) {
44296 + retval = -EACCES;
44297 + goto out_file;
44298 + }
44299 +
44300 retval = bprm_mm_init(bprm);
44301 if (retval)
44302 goto out_file;
44303 @@ -1527,24 +1603,65 @@ static int do_execve_common(const char *filename,
44304 if (retval < 0)
44305 goto out;
44306
44307 +#ifdef CONFIG_GRKERNSEC
44308 + old_acl = current->acl;
44309 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
44310 + old_exec_file = current->exec_file;
44311 + get_file(file);
44312 + current->exec_file = file;
44313 +#endif
44314 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
44315 + /* limit suid stack to 8MB
44316 + we saved the old limits above and will restore them if this exec fails
44317 + */
44318 + if (((bprm->cred->euid != current_euid()) || (bprm->cred->egid != current_egid())) &&
44319 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
44320 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
44321 +#endif
44322 +
44323 + if (!gr_tpe_allow(file)) {
44324 + retval = -EACCES;
44325 + goto out_fail;
44326 + }
44327 +
44328 + if (gr_check_crash_exec(file)) {
44329 + retval = -EACCES;
44330 + goto out_fail;
44331 + }
44332 +
44333 + retval = gr_set_proc_label(file->f_dentry, file->f_vfsmnt,
44334 + bprm->unsafe);
44335 + if (retval < 0)
44336 + goto out_fail;
44337 +
44338 retval = copy_strings_kernel(1, &bprm->filename, bprm);
44339 if (retval < 0)
44340 - goto out;
44341 + goto out_fail;
44342
44343 bprm->exec = bprm->p;
44344 retval = copy_strings(bprm->envc, envp, bprm);
44345 if (retval < 0)
44346 - goto out;
44347 + goto out_fail;
44348
44349 retval = copy_strings(bprm->argc, argv, bprm);
44350 if (retval < 0)
44351 - goto out;
44352 + goto out_fail;
44353 +
44354 + gr_log_chroot_exec(file->f_dentry, file->f_vfsmnt);
44355 +
44356 + gr_handle_exec_args(bprm, argv);
44357
44358 retval = search_binary_handler(bprm,regs);
44359 if (retval < 0)
44360 - goto out;
44361 + goto out_fail;
44362 +#ifdef CONFIG_GRKERNSEC
44363 + if (old_exec_file)
44364 + fput(old_exec_file);
44365 +#endif
44366
44367 /* execve succeeded */
44368 +
44369 + increment_exec_counter();
44370 current->fs->in_exec = 0;
44371 current->in_execve = 0;
44372 acct_update_integrals(current);
44373 @@ -1553,6 +1670,14 @@ static int do_execve_common(const char *filename,
44374 put_files_struct(displaced);
44375 return retval;
44376
44377 +out_fail:
44378 +#ifdef CONFIG_GRKERNSEC
44379 + current->acl = old_acl;
44380 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
44381 + fput(current->exec_file);
44382 + current->exec_file = old_exec_file;
44383 +#endif
44384 +
44385 out:
44386 if (bprm->mm) {
44387 acct_arg_size(bprm, 0);
44388 @@ -1626,7 +1751,7 @@ static int expand_corename(struct core_name *cn)
44389 {
44390 char *old_corename = cn->corename;
44391
44392 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
44393 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
44394 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
44395
44396 if (!cn->corename) {
44397 @@ -1723,7 +1848,7 @@ static int format_corename(struct core_name *cn, long signr)
44398 int pid_in_pattern = 0;
44399 int err = 0;
44400
44401 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
44402 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
44403 cn->corename = kmalloc(cn->size, GFP_KERNEL);
44404 cn->used = 0;
44405
44406 @@ -1820,6 +1945,228 @@ out:
44407 return ispipe;
44408 }
44409
44410 +int pax_check_flags(unsigned long *flags)
44411 +{
44412 + int retval = 0;
44413 +
44414 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
44415 + if (*flags & MF_PAX_SEGMEXEC)
44416 + {
44417 + *flags &= ~MF_PAX_SEGMEXEC;
44418 + retval = -EINVAL;
44419 + }
44420 +#endif
44421 +
44422 + if ((*flags & MF_PAX_PAGEEXEC)
44423 +
44424 +#ifdef CONFIG_PAX_PAGEEXEC
44425 + && (*flags & MF_PAX_SEGMEXEC)
44426 +#endif
44427 +
44428 + )
44429 + {
44430 + *flags &= ~MF_PAX_PAGEEXEC;
44431 + retval = -EINVAL;
44432 + }
44433 +
44434 + if ((*flags & MF_PAX_MPROTECT)
44435 +
44436 +#ifdef CONFIG_PAX_MPROTECT
44437 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
44438 +#endif
44439 +
44440 + )
44441 + {
44442 + *flags &= ~MF_PAX_MPROTECT;
44443 + retval = -EINVAL;
44444 + }
44445 +
44446 + if ((*flags & MF_PAX_EMUTRAMP)
44447 +
44448 +#ifdef CONFIG_PAX_EMUTRAMP
44449 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
44450 +#endif
44451 +
44452 + )
44453 + {
44454 + *flags &= ~MF_PAX_EMUTRAMP;
44455 + retval = -EINVAL;
44456 + }
44457 +
44458 + return retval;
44459 +}
44460 +
44461 +EXPORT_SYMBOL(pax_check_flags);
44462 +
44463 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
44464 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
44465 +{
44466 + struct task_struct *tsk = current;
44467 + struct mm_struct *mm = current->mm;
44468 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
44469 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
44470 + char *path_exec = NULL;
44471 + char *path_fault = NULL;
44472 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
44473 +
44474 + if (buffer_exec && buffer_fault) {
44475 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
44476 +
44477 + down_read(&mm->mmap_sem);
44478 + vma = mm->mmap;
44479 + while (vma && (!vma_exec || !vma_fault)) {
44480 + if ((vma->vm_flags & VM_EXECUTABLE) && vma->vm_file)
44481 + vma_exec = vma;
44482 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
44483 + vma_fault = vma;
44484 + vma = vma->vm_next;
44485 + }
44486 + if (vma_exec) {
44487 + path_exec = d_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
44488 + if (IS_ERR(path_exec))
44489 + path_exec = "<path too long>";
44490 + else {
44491 + path_exec = mangle_path(buffer_exec, path_exec, "\t\n\\");
44492 + if (path_exec) {
44493 + *path_exec = 0;
44494 + path_exec = buffer_exec;
44495 + } else
44496 + path_exec = "<path too long>";
44497 + }
44498 + }
44499 + if (vma_fault) {
44500 + start = vma_fault->vm_start;
44501 + end = vma_fault->vm_end;
44502 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
44503 + if (vma_fault->vm_file) {
44504 + path_fault = d_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
44505 + if (IS_ERR(path_fault))
44506 + path_fault = "<path too long>";
44507 + else {
44508 + path_fault = mangle_path(buffer_fault, path_fault, "\t\n\\");
44509 + if (path_fault) {
44510 + *path_fault = 0;
44511 + path_fault = buffer_fault;
44512 + } else
44513 + path_fault = "<path too long>";
44514 + }
44515 + } else
44516 + path_fault = "<anonymous mapping>";
44517 + }
44518 + up_read(&mm->mmap_sem);
44519 + }
44520 + if (tsk->signal->curr_ip)
44521 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
44522 + else
44523 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
44524 + printk(KERN_ERR "PAX: terminating task: %s(%s):%d, uid/euid: %u/%u, "
44525 + "PC: %p, SP: %p\n", path_exec, tsk->comm, task_pid_nr(tsk),
44526 + task_uid(tsk), task_euid(tsk), pc, sp);
44527 + free_page((unsigned long)buffer_exec);
44528 + free_page((unsigned long)buffer_fault);
44529 + pax_report_insns(regs, pc, sp);
44530 + do_coredump(SIGKILL, SIGKILL, regs);
44531 +}
44532 +#endif
44533 +
44534 +#ifdef CONFIG_PAX_REFCOUNT
44535 +void pax_report_refcount_overflow(struct pt_regs *regs)
44536 +{
44537 + if (current->signal->curr_ip)
44538 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
44539 + &current->signal->curr_ip, current->comm, task_pid_nr(current), current_uid(), current_euid());
44540 + else
44541 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
44542 + current->comm, task_pid_nr(current), current_uid(), current_euid());
44543 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
44544 + show_regs(regs);
44545 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
44546 +}
44547 +#endif
44548 +
44549 +#ifdef CONFIG_PAX_USERCOPY
44550 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
44551 +int object_is_on_stack(const void *obj, unsigned long len)
44552 +{
44553 + const void * const stack = task_stack_page(current);
44554 + const void * const stackend = stack + THREAD_SIZE;
44555 +
44556 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
44557 + const void *frame = NULL;
44558 + const void *oldframe;
44559 +#endif
44560 +
44561 + if (obj + len < obj)
44562 + return -1;
44563 +
44564 + if (obj + len <= stack || stackend <= obj)
44565 + return 0;
44566 +
44567 + if (obj < stack || stackend < obj + len)
44568 + return -1;
44569 +
44570 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
44571 + oldframe = __builtin_frame_address(1);
44572 + if (oldframe)
44573 + frame = __builtin_frame_address(2);
44574 + /*
44575 + low ----------------------------------------------> high
44576 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
44577 + ^----------------^
44578 + allow copies only within here
44579 + */
44580 + while (stack <= frame && frame < stackend) {
44581 + /* if obj + len extends past the last frame, this
44582 + check won't pass and the next frame will be 0,
44583 + causing us to bail out and correctly report
44584 + the copy as invalid
44585 + */
44586 + if (obj + len <= frame)
44587 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
44588 + oldframe = frame;
44589 + frame = *(const void * const *)frame;
44590 + }
44591 + return -1;
44592 +#else
44593 + return 1;
44594 +#endif
44595 +}
44596 +
44597 +__noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to, const char *type)
44598 +{
44599 + if (current->signal->curr_ip)
44600 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
44601 + &current->signal->curr_ip, to ? "leak" : "overwrite", to ? "from" : "to", ptr, type ? : "unknown", len);
44602 + else
44603 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
44604 + to ? "leak" : "overwrite", to ? "from" : "to", ptr, type ? : "unknown", len);
44605 + dump_stack();
44606 + gr_handle_kernel_exploit();
44607 + do_group_exit(SIGKILL);
44608 +}
44609 +#endif
44610 +
44611 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
44612 +void pax_track_stack(void)
44613 +{
44614 + unsigned long sp = (unsigned long)&sp;
44615 + if (sp < current_thread_info()->lowest_stack &&
44616 + sp > (unsigned long)task_stack_page(current))
44617 + current_thread_info()->lowest_stack = sp;
44618 +}
44619 +EXPORT_SYMBOL(pax_track_stack);
44620 +#endif
44621 +
44622 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
44623 +void report_size_overflow(const char *file, unsigned int line, const char *func)
44624 +{
44625 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u\n", func, file, line);
44626 + dump_stack();
44627 + do_group_exit(SIGKILL);
44628 +}
44629 +EXPORT_SYMBOL(report_size_overflow);
44630 +#endif
44631 +
44632 static int zap_process(struct task_struct *start, int exit_code)
44633 {
44634 struct task_struct *t;
44635 @@ -2017,17 +2364,17 @@ static void wait_for_dump_helpers(struct file *file)
44636 pipe = file->f_path.dentry->d_inode->i_pipe;
44637
44638 pipe_lock(pipe);
44639 - pipe->readers++;
44640 - pipe->writers--;
44641 + atomic_inc(&pipe->readers);
44642 + atomic_dec(&pipe->writers);
44643
44644 - while ((pipe->readers > 1) && (!signal_pending(current))) {
44645 + while ((atomic_read(&pipe->readers) > 1) && (!signal_pending(current))) {
44646 wake_up_interruptible_sync(&pipe->wait);
44647 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
44648 pipe_wait(pipe);
44649 }
44650
44651 - pipe->readers--;
44652 - pipe->writers++;
44653 + atomic_dec(&pipe->readers);
44654 + atomic_inc(&pipe->writers);
44655 pipe_unlock(pipe);
44656
44657 }
44658 @@ -2088,7 +2435,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
44659 int retval = 0;
44660 int flag = 0;
44661 int ispipe;
44662 - static atomic_t core_dump_count = ATOMIC_INIT(0);
44663 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
44664 struct coredump_params cprm = {
44665 .signr = signr,
44666 .regs = regs,
44667 @@ -2103,6 +2450,9 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
44668
44669 audit_core_dumps(signr);
44670
44671 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
44672 + gr_handle_brute_attach(current, cprm.mm_flags);
44673 +
44674 binfmt = mm->binfmt;
44675 if (!binfmt || !binfmt->core_dump)
44676 goto fail;
44677 @@ -2170,7 +2520,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
44678 }
44679 cprm.limit = RLIM_INFINITY;
44680
44681 - dump_count = atomic_inc_return(&core_dump_count);
44682 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
44683 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
44684 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
44685 task_tgid_vnr(current), current->comm);
44686 @@ -2197,6 +2547,8 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
44687 } else {
44688 struct inode *inode;
44689
44690 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
44691 +
44692 if (cprm.limit < binfmt->min_coredump)
44693 goto fail_unlock;
44694
44695 @@ -2240,7 +2592,7 @@ close_fail:
44696 filp_close(cprm.file, NULL);
44697 fail_dropcount:
44698 if (ispipe)
44699 - atomic_dec(&core_dump_count);
44700 + atomic_dec_unchecked(&core_dump_count);
44701 fail_unlock:
44702 kfree(cn.corename);
44703 fail_corename:
44704 @@ -2259,7 +2611,7 @@ fail:
44705 */
44706 int dump_write(struct file *file, const void *addr, int nr)
44707 {
44708 - return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
44709 + return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
44710 }
44711 EXPORT_SYMBOL(dump_write);
44712
44713 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
44714 index a8cbe1b..fed04cb 100644
44715 --- a/fs/ext2/balloc.c
44716 +++ b/fs/ext2/balloc.c
44717 @@ -1192,7 +1192,7 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
44718
44719 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
44720 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
44721 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
44722 + if (free_blocks < root_blocks + 1 && !capable_nolog(CAP_SYS_RESOURCE) &&
44723 sbi->s_resuid != current_fsuid() &&
44724 (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
44725 return 0;
44726 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
44727 index a203892..4e64db5 100644
44728 --- a/fs/ext3/balloc.c
44729 +++ b/fs/ext3/balloc.c
44730 @@ -1446,9 +1446,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
44731
44732 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
44733 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
44734 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
44735 + if (free_blocks < root_blocks + 1 &&
44736 !use_reservation && sbi->s_resuid != current_fsuid() &&
44737 - (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
44738 + (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid)) &&
44739 + !capable_nolog(CAP_SYS_RESOURCE)) {
44740 return 0;
44741 }
44742 return 1;
44743 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
44744 index f9e2cd8..bfdc476 100644
44745 --- a/fs/ext4/balloc.c
44746 +++ b/fs/ext4/balloc.c
44747 @@ -438,8 +438,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
44748 /* Hm, nope. Are (enough) root reserved clusters available? */
44749 if (sbi->s_resuid == current_fsuid() ||
44750 ((sbi->s_resgid != 0) && in_group_p(sbi->s_resgid)) ||
44751 - capable(CAP_SYS_RESOURCE) ||
44752 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
44753 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
44754 + capable_nolog(CAP_SYS_RESOURCE)) {
44755
44756 if (free_clusters >= (nclusters + dirty_clusters))
44757 return 1;
44758 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
44759 index 9983ba8..2a5272c 100644
44760 --- a/fs/ext4/ext4.h
44761 +++ b/fs/ext4/ext4.h
44762 @@ -1217,19 +1217,19 @@ struct ext4_sb_info {
44763 unsigned long s_mb_last_start;
44764
44765 /* stats for buddy allocator */
44766 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
44767 - atomic_t s_bal_success; /* we found long enough chunks */
44768 - atomic_t s_bal_allocated; /* in blocks */
44769 - atomic_t s_bal_ex_scanned; /* total extents scanned */
44770 - atomic_t s_bal_goals; /* goal hits */
44771 - atomic_t s_bal_breaks; /* too long searches */
44772 - atomic_t s_bal_2orders; /* 2^order hits */
44773 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
44774 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
44775 + atomic_unchecked_t s_bal_allocated; /* in blocks */
44776 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
44777 + atomic_unchecked_t s_bal_goals; /* goal hits */
44778 + atomic_unchecked_t s_bal_breaks; /* too long searches */
44779 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
44780 spinlock_t s_bal_lock;
44781 unsigned long s_mb_buddies_generated;
44782 unsigned long long s_mb_generation_time;
44783 - atomic_t s_mb_lost_chunks;
44784 - atomic_t s_mb_preallocated;
44785 - atomic_t s_mb_discarded;
44786 + atomic_unchecked_t s_mb_lost_chunks;
44787 + atomic_unchecked_t s_mb_preallocated;
44788 + atomic_unchecked_t s_mb_discarded;
44789 atomic_t s_lock_busy;
44790
44791 /* locality groups */
44792 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
44793 index cb990b2..4820141 100644
44794 --- a/fs/ext4/mballoc.c
44795 +++ b/fs/ext4/mballoc.c
44796 @@ -1794,7 +1794,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
44797 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
44798
44799 if (EXT4_SB(sb)->s_mb_stats)
44800 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
44801 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
44802
44803 break;
44804 }
44805 @@ -2088,7 +2088,7 @@ repeat:
44806 ac->ac_status = AC_STATUS_CONTINUE;
44807 ac->ac_flags |= EXT4_MB_HINT_FIRST;
44808 cr = 3;
44809 - atomic_inc(&sbi->s_mb_lost_chunks);
44810 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
44811 goto repeat;
44812 }
44813 }
44814 @@ -2592,25 +2592,25 @@ int ext4_mb_release(struct super_block *sb)
44815 if (sbi->s_mb_stats) {
44816 ext4_msg(sb, KERN_INFO,
44817 "mballoc: %u blocks %u reqs (%u success)",
44818 - atomic_read(&sbi->s_bal_allocated),
44819 - atomic_read(&sbi->s_bal_reqs),
44820 - atomic_read(&sbi->s_bal_success));
44821 + atomic_read_unchecked(&sbi->s_bal_allocated),
44822 + atomic_read_unchecked(&sbi->s_bal_reqs),
44823 + atomic_read_unchecked(&sbi->s_bal_success));
44824 ext4_msg(sb, KERN_INFO,
44825 "mballoc: %u extents scanned, %u goal hits, "
44826 "%u 2^N hits, %u breaks, %u lost",
44827 - atomic_read(&sbi->s_bal_ex_scanned),
44828 - atomic_read(&sbi->s_bal_goals),
44829 - atomic_read(&sbi->s_bal_2orders),
44830 - atomic_read(&sbi->s_bal_breaks),
44831 - atomic_read(&sbi->s_mb_lost_chunks));
44832 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
44833 + atomic_read_unchecked(&sbi->s_bal_goals),
44834 + atomic_read_unchecked(&sbi->s_bal_2orders),
44835 + atomic_read_unchecked(&sbi->s_bal_breaks),
44836 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
44837 ext4_msg(sb, KERN_INFO,
44838 "mballoc: %lu generated and it took %Lu",
44839 sbi->s_mb_buddies_generated,
44840 sbi->s_mb_generation_time);
44841 ext4_msg(sb, KERN_INFO,
44842 "mballoc: %u preallocated, %u discarded",
44843 - atomic_read(&sbi->s_mb_preallocated),
44844 - atomic_read(&sbi->s_mb_discarded));
44845 + atomic_read_unchecked(&sbi->s_mb_preallocated),
44846 + atomic_read_unchecked(&sbi->s_mb_discarded));
44847 }
44848
44849 free_percpu(sbi->s_locality_groups);
44850 @@ -3096,16 +3096,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
44851 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
44852
44853 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
44854 - atomic_inc(&sbi->s_bal_reqs);
44855 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
44856 + atomic_inc_unchecked(&sbi->s_bal_reqs);
44857 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
44858 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
44859 - atomic_inc(&sbi->s_bal_success);
44860 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
44861 + atomic_inc_unchecked(&sbi->s_bal_success);
44862 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
44863 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
44864 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
44865 - atomic_inc(&sbi->s_bal_goals);
44866 + atomic_inc_unchecked(&sbi->s_bal_goals);
44867 if (ac->ac_found > sbi->s_mb_max_to_scan)
44868 - atomic_inc(&sbi->s_bal_breaks);
44869 + atomic_inc_unchecked(&sbi->s_bal_breaks);
44870 }
44871
44872 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
44873 @@ -3509,7 +3509,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
44874 trace_ext4_mb_new_inode_pa(ac, pa);
44875
44876 ext4_mb_use_inode_pa(ac, pa);
44877 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
44878 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
44879
44880 ei = EXT4_I(ac->ac_inode);
44881 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
44882 @@ -3569,7 +3569,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
44883 trace_ext4_mb_new_group_pa(ac, pa);
44884
44885 ext4_mb_use_group_pa(ac, pa);
44886 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
44887 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
44888
44889 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
44890 lg = ac->ac_lg;
44891 @@ -3658,7 +3658,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
44892 * from the bitmap and continue.
44893 */
44894 }
44895 - atomic_add(free, &sbi->s_mb_discarded);
44896 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
44897
44898 return err;
44899 }
44900 @@ -3676,7 +3676,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
44901 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
44902 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
44903 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
44904 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
44905 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
44906 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
44907
44908 return 0;
44909 diff --git a/fs/fcntl.c b/fs/fcntl.c
44910 index 22764c7..86372c9 100644
44911 --- a/fs/fcntl.c
44912 +++ b/fs/fcntl.c
44913 @@ -224,6 +224,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
44914 if (err)
44915 return err;
44916
44917 + if (gr_handle_chroot_fowner(pid, type))
44918 + return -ENOENT;
44919 + if (gr_check_protected_task_fowner(pid, type))
44920 + return -EACCES;
44921 +
44922 f_modown(filp, pid, type, force);
44923 return 0;
44924 }
44925 @@ -266,7 +271,7 @@ pid_t f_getown(struct file *filp)
44926
44927 static int f_setown_ex(struct file *filp, unsigned long arg)
44928 {
44929 - struct f_owner_ex * __user owner_p = (void * __user)arg;
44930 + struct f_owner_ex __user *owner_p = (void __user *)arg;
44931 struct f_owner_ex owner;
44932 struct pid *pid;
44933 int type;
44934 @@ -306,7 +311,7 @@ static int f_setown_ex(struct file *filp, unsigned long arg)
44935
44936 static int f_getown_ex(struct file *filp, unsigned long arg)
44937 {
44938 - struct f_owner_ex * __user owner_p = (void * __user)arg;
44939 + struct f_owner_ex __user *owner_p = (void __user *)arg;
44940 struct f_owner_ex owner;
44941 int ret = 0;
44942
44943 @@ -348,6 +353,7 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
44944 switch (cmd) {
44945 case F_DUPFD:
44946 case F_DUPFD_CLOEXEC:
44947 + gr_learn_resource(current, RLIMIT_NOFILE, arg, 0);
44948 if (arg >= rlimit(RLIMIT_NOFILE))
44949 break;
44950 err = alloc_fd(arg, cmd == F_DUPFD_CLOEXEC ? O_CLOEXEC : 0);
44951 diff --git a/fs/fifo.c b/fs/fifo.c
44952 index b1a524d..4ee270e 100644
44953 --- a/fs/fifo.c
44954 +++ b/fs/fifo.c
44955 @@ -58,10 +58,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
44956 */
44957 filp->f_op = &read_pipefifo_fops;
44958 pipe->r_counter++;
44959 - if (pipe->readers++ == 0)
44960 + if (atomic_inc_return(&pipe->readers) == 1)
44961 wake_up_partner(inode);
44962
44963 - if (!pipe->writers) {
44964 + if (!atomic_read(&pipe->writers)) {
44965 if ((filp->f_flags & O_NONBLOCK)) {
44966 /* suppress POLLHUP until we have
44967 * seen a writer */
44968 @@ -81,15 +81,15 @@ static int fifo_open(struct inode *inode, struct file *filp)
44969 * errno=ENXIO when there is no process reading the FIFO.
44970 */
44971 ret = -ENXIO;
44972 - if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
44973 + if ((filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
44974 goto err;
44975
44976 filp->f_op = &write_pipefifo_fops;
44977 pipe->w_counter++;
44978 - if (!pipe->writers++)
44979 + if (atomic_inc_return(&pipe->writers) == 1)
44980 wake_up_partner(inode);
44981
44982 - if (!pipe->readers) {
44983 + if (!atomic_read(&pipe->readers)) {
44984 wait_for_partner(inode, &pipe->r_counter);
44985 if (signal_pending(current))
44986 goto err_wr;
44987 @@ -105,11 +105,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
44988 */
44989 filp->f_op = &rdwr_pipefifo_fops;
44990
44991 - pipe->readers++;
44992 - pipe->writers++;
44993 + atomic_inc(&pipe->readers);
44994 + atomic_inc(&pipe->writers);
44995 pipe->r_counter++;
44996 pipe->w_counter++;
44997 - if (pipe->readers == 1 || pipe->writers == 1)
44998 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
44999 wake_up_partner(inode);
45000 break;
45001
45002 @@ -123,19 +123,19 @@ static int fifo_open(struct inode *inode, struct file *filp)
45003 return 0;
45004
45005 err_rd:
45006 - if (!--pipe->readers)
45007 + if (atomic_dec_and_test(&pipe->readers))
45008 wake_up_interruptible(&pipe->wait);
45009 ret = -ERESTARTSYS;
45010 goto err;
45011
45012 err_wr:
45013 - if (!--pipe->writers)
45014 + if (atomic_dec_and_test(&pipe->writers))
45015 wake_up_interruptible(&pipe->wait);
45016 ret = -ERESTARTSYS;
45017 goto err;
45018
45019 err:
45020 - if (!pipe->readers && !pipe->writers)
45021 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers))
45022 free_pipe_info(inode);
45023
45024 err_nocleanup:
45025 diff --git a/fs/file.c b/fs/file.c
45026 index 4c6992d..104cdea 100644
45027 --- a/fs/file.c
45028 +++ b/fs/file.c
45029 @@ -15,6 +15,7 @@
45030 #include <linux/slab.h>
45031 #include <linux/vmalloc.h>
45032 #include <linux/file.h>
45033 +#include <linux/security.h>
45034 #include <linux/fdtable.h>
45035 #include <linux/bitops.h>
45036 #include <linux/interrupt.h>
45037 @@ -254,6 +255,7 @@ int expand_files(struct files_struct *files, int nr)
45038 * N.B. For clone tasks sharing a files structure, this test
45039 * will limit the total number of files that can be opened.
45040 */
45041 + gr_learn_resource(current, RLIMIT_NOFILE, nr, 0);
45042 if (nr >= rlimit(RLIMIT_NOFILE))
45043 return -EMFILE;
45044
45045 diff --git a/fs/filesystems.c b/fs/filesystems.c
45046 index 96f2428..f5eeb8e 100644
45047 --- a/fs/filesystems.c
45048 +++ b/fs/filesystems.c
45049 @@ -273,7 +273,12 @@ struct file_system_type *get_fs_type(const char *name)
45050 int len = dot ? dot - name : strlen(name);
45051
45052 fs = __get_fs_type(name, len);
45053 +
45054 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
45055 + if (!fs && (___request_module(true, "grsec_modharden_fs", "%.*s", len, name) == 0))
45056 +#else
45057 if (!fs && (request_module("%.*s", len, name) == 0))
45058 +#endif
45059 fs = __get_fs_type(name, len);
45060
45061 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
45062 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
45063 index 78b519c..a8b4979 100644
45064 --- a/fs/fs_struct.c
45065 +++ b/fs/fs_struct.c
45066 @@ -4,6 +4,7 @@
45067 #include <linux/path.h>
45068 #include <linux/slab.h>
45069 #include <linux/fs_struct.h>
45070 +#include <linux/grsecurity.h>
45071 #include "internal.h"
45072
45073 static inline void path_get_longterm(struct path *path)
45074 @@ -31,6 +32,7 @@ void set_fs_root(struct fs_struct *fs, struct path *path)
45075 old_root = fs->root;
45076 fs->root = *path;
45077 path_get_longterm(path);
45078 + gr_set_chroot_entries(current, path);
45079 write_seqcount_end(&fs->seq);
45080 spin_unlock(&fs->lock);
45081 if (old_root.dentry)
45082 @@ -74,6 +76,7 @@ void chroot_fs_refs(struct path *old_root, struct path *new_root)
45083 && fs->root.mnt == old_root->mnt) {
45084 path_get_longterm(new_root);
45085 fs->root = *new_root;
45086 + gr_set_chroot_entries(p, new_root);
45087 count++;
45088 }
45089 if (fs->pwd.dentry == old_root->dentry
45090 @@ -109,7 +112,8 @@ void exit_fs(struct task_struct *tsk)
45091 spin_lock(&fs->lock);
45092 write_seqcount_begin(&fs->seq);
45093 tsk->fs = NULL;
45094 - kill = !--fs->users;
45095 + gr_clear_chroot_entries(tsk);
45096 + kill = !atomic_dec_return(&fs->users);
45097 write_seqcount_end(&fs->seq);
45098 spin_unlock(&fs->lock);
45099 task_unlock(tsk);
45100 @@ -123,7 +127,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
45101 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
45102 /* We don't need to lock fs - think why ;-) */
45103 if (fs) {
45104 - fs->users = 1;
45105 + atomic_set(&fs->users, 1);
45106 fs->in_exec = 0;
45107 spin_lock_init(&fs->lock);
45108 seqcount_init(&fs->seq);
45109 @@ -132,6 +136,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
45110 spin_lock(&old->lock);
45111 fs->root = old->root;
45112 path_get_longterm(&fs->root);
45113 + /* instead of calling gr_set_chroot_entries here,
45114 + we call it from every caller of this function
45115 + */
45116 fs->pwd = old->pwd;
45117 path_get_longterm(&fs->pwd);
45118 spin_unlock(&old->lock);
45119 @@ -150,8 +157,9 @@ int unshare_fs_struct(void)
45120
45121 task_lock(current);
45122 spin_lock(&fs->lock);
45123 - kill = !--fs->users;
45124 + kill = !atomic_dec_return(&fs->users);
45125 current->fs = new_fs;
45126 + gr_set_chroot_entries(current, &new_fs->root);
45127 spin_unlock(&fs->lock);
45128 task_unlock(current);
45129
45130 @@ -164,13 +172,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
45131
45132 int current_umask(void)
45133 {
45134 - return current->fs->umask;
45135 + return current->fs->umask | gr_acl_umask();
45136 }
45137 EXPORT_SYMBOL(current_umask);
45138
45139 /* to be mentioned only in INIT_TASK */
45140 struct fs_struct init_fs = {
45141 - .users = 1,
45142 + .users = ATOMIC_INIT(1),
45143 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
45144 .seq = SEQCNT_ZERO,
45145 .umask = 0022,
45146 @@ -186,12 +194,13 @@ void daemonize_fs_struct(void)
45147 task_lock(current);
45148
45149 spin_lock(&init_fs.lock);
45150 - init_fs.users++;
45151 + atomic_inc(&init_fs.users);
45152 spin_unlock(&init_fs.lock);
45153
45154 spin_lock(&fs->lock);
45155 current->fs = &init_fs;
45156 - kill = !--fs->users;
45157 + gr_set_chroot_entries(current, &current->fs->root);
45158 + kill = !atomic_dec_return(&fs->users);
45159 spin_unlock(&fs->lock);
45160
45161 task_unlock(current);
45162 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
45163 index 9905350..02eaec4 100644
45164 --- a/fs/fscache/cookie.c
45165 +++ b/fs/fscache/cookie.c
45166 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
45167 parent ? (char *) parent->def->name : "<no-parent>",
45168 def->name, netfs_data);
45169
45170 - fscache_stat(&fscache_n_acquires);
45171 + fscache_stat_unchecked(&fscache_n_acquires);
45172
45173 /* if there's no parent cookie, then we don't create one here either */
45174 if (!parent) {
45175 - fscache_stat(&fscache_n_acquires_null);
45176 + fscache_stat_unchecked(&fscache_n_acquires_null);
45177 _leave(" [no parent]");
45178 return NULL;
45179 }
45180 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
45181 /* allocate and initialise a cookie */
45182 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
45183 if (!cookie) {
45184 - fscache_stat(&fscache_n_acquires_oom);
45185 + fscache_stat_unchecked(&fscache_n_acquires_oom);
45186 _leave(" [ENOMEM]");
45187 return NULL;
45188 }
45189 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
45190
45191 switch (cookie->def->type) {
45192 case FSCACHE_COOKIE_TYPE_INDEX:
45193 - fscache_stat(&fscache_n_cookie_index);
45194 + fscache_stat_unchecked(&fscache_n_cookie_index);
45195 break;
45196 case FSCACHE_COOKIE_TYPE_DATAFILE:
45197 - fscache_stat(&fscache_n_cookie_data);
45198 + fscache_stat_unchecked(&fscache_n_cookie_data);
45199 break;
45200 default:
45201 - fscache_stat(&fscache_n_cookie_special);
45202 + fscache_stat_unchecked(&fscache_n_cookie_special);
45203 break;
45204 }
45205
45206 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
45207 if (fscache_acquire_non_index_cookie(cookie) < 0) {
45208 atomic_dec(&parent->n_children);
45209 __fscache_cookie_put(cookie);
45210 - fscache_stat(&fscache_n_acquires_nobufs);
45211 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
45212 _leave(" = NULL");
45213 return NULL;
45214 }
45215 }
45216
45217 - fscache_stat(&fscache_n_acquires_ok);
45218 + fscache_stat_unchecked(&fscache_n_acquires_ok);
45219 _leave(" = %p", cookie);
45220 return cookie;
45221 }
45222 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
45223 cache = fscache_select_cache_for_object(cookie->parent);
45224 if (!cache) {
45225 up_read(&fscache_addremove_sem);
45226 - fscache_stat(&fscache_n_acquires_no_cache);
45227 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
45228 _leave(" = -ENOMEDIUM [no cache]");
45229 return -ENOMEDIUM;
45230 }
45231 @@ -256,12 +256,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
45232 object = cache->ops->alloc_object(cache, cookie);
45233 fscache_stat_d(&fscache_n_cop_alloc_object);
45234 if (IS_ERR(object)) {
45235 - fscache_stat(&fscache_n_object_no_alloc);
45236 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
45237 ret = PTR_ERR(object);
45238 goto error;
45239 }
45240
45241 - fscache_stat(&fscache_n_object_alloc);
45242 + fscache_stat_unchecked(&fscache_n_object_alloc);
45243
45244 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
45245
45246 @@ -377,10 +377,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
45247 struct fscache_object *object;
45248 struct hlist_node *_p;
45249
45250 - fscache_stat(&fscache_n_updates);
45251 + fscache_stat_unchecked(&fscache_n_updates);
45252
45253 if (!cookie) {
45254 - fscache_stat(&fscache_n_updates_null);
45255 + fscache_stat_unchecked(&fscache_n_updates_null);
45256 _leave(" [no cookie]");
45257 return;
45258 }
45259 @@ -414,12 +414,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
45260 struct fscache_object *object;
45261 unsigned long event;
45262
45263 - fscache_stat(&fscache_n_relinquishes);
45264 + fscache_stat_unchecked(&fscache_n_relinquishes);
45265 if (retire)
45266 - fscache_stat(&fscache_n_relinquishes_retire);
45267 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
45268
45269 if (!cookie) {
45270 - fscache_stat(&fscache_n_relinquishes_null);
45271 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
45272 _leave(" [no cookie]");
45273 return;
45274 }
45275 @@ -435,7 +435,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
45276
45277 /* wait for the cookie to finish being instantiated (or to fail) */
45278 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
45279 - fscache_stat(&fscache_n_relinquishes_waitcrt);
45280 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
45281 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
45282 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
45283 }
45284 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
45285 index f6aad48..88dcf26 100644
45286 --- a/fs/fscache/internal.h
45287 +++ b/fs/fscache/internal.h
45288 @@ -144,94 +144,94 @@ extern void fscache_proc_cleanup(void);
45289 extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
45290 extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
45291
45292 -extern atomic_t fscache_n_op_pend;
45293 -extern atomic_t fscache_n_op_run;
45294 -extern atomic_t fscache_n_op_enqueue;
45295 -extern atomic_t fscache_n_op_deferred_release;
45296 -extern atomic_t fscache_n_op_release;
45297 -extern atomic_t fscache_n_op_gc;
45298 -extern atomic_t fscache_n_op_cancelled;
45299 -extern atomic_t fscache_n_op_rejected;
45300 +extern atomic_unchecked_t fscache_n_op_pend;
45301 +extern atomic_unchecked_t fscache_n_op_run;
45302 +extern atomic_unchecked_t fscache_n_op_enqueue;
45303 +extern atomic_unchecked_t fscache_n_op_deferred_release;
45304 +extern atomic_unchecked_t fscache_n_op_release;
45305 +extern atomic_unchecked_t fscache_n_op_gc;
45306 +extern atomic_unchecked_t fscache_n_op_cancelled;
45307 +extern atomic_unchecked_t fscache_n_op_rejected;
45308
45309 -extern atomic_t fscache_n_attr_changed;
45310 -extern atomic_t fscache_n_attr_changed_ok;
45311 -extern atomic_t fscache_n_attr_changed_nobufs;
45312 -extern atomic_t fscache_n_attr_changed_nomem;
45313 -extern atomic_t fscache_n_attr_changed_calls;
45314 +extern atomic_unchecked_t fscache_n_attr_changed;
45315 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
45316 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
45317 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
45318 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
45319
45320 -extern atomic_t fscache_n_allocs;
45321 -extern atomic_t fscache_n_allocs_ok;
45322 -extern atomic_t fscache_n_allocs_wait;
45323 -extern atomic_t fscache_n_allocs_nobufs;
45324 -extern atomic_t fscache_n_allocs_intr;
45325 -extern atomic_t fscache_n_allocs_object_dead;
45326 -extern atomic_t fscache_n_alloc_ops;
45327 -extern atomic_t fscache_n_alloc_op_waits;
45328 +extern atomic_unchecked_t fscache_n_allocs;
45329 +extern atomic_unchecked_t fscache_n_allocs_ok;
45330 +extern atomic_unchecked_t fscache_n_allocs_wait;
45331 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
45332 +extern atomic_unchecked_t fscache_n_allocs_intr;
45333 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
45334 +extern atomic_unchecked_t fscache_n_alloc_ops;
45335 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
45336
45337 -extern atomic_t fscache_n_retrievals;
45338 -extern atomic_t fscache_n_retrievals_ok;
45339 -extern atomic_t fscache_n_retrievals_wait;
45340 -extern atomic_t fscache_n_retrievals_nodata;
45341 -extern atomic_t fscache_n_retrievals_nobufs;
45342 -extern atomic_t fscache_n_retrievals_intr;
45343 -extern atomic_t fscache_n_retrievals_nomem;
45344 -extern atomic_t fscache_n_retrievals_object_dead;
45345 -extern atomic_t fscache_n_retrieval_ops;
45346 -extern atomic_t fscache_n_retrieval_op_waits;
45347 +extern atomic_unchecked_t fscache_n_retrievals;
45348 +extern atomic_unchecked_t fscache_n_retrievals_ok;
45349 +extern atomic_unchecked_t fscache_n_retrievals_wait;
45350 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
45351 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
45352 +extern atomic_unchecked_t fscache_n_retrievals_intr;
45353 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
45354 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
45355 +extern atomic_unchecked_t fscache_n_retrieval_ops;
45356 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
45357
45358 -extern atomic_t fscache_n_stores;
45359 -extern atomic_t fscache_n_stores_ok;
45360 -extern atomic_t fscache_n_stores_again;
45361 -extern atomic_t fscache_n_stores_nobufs;
45362 -extern atomic_t fscache_n_stores_oom;
45363 -extern atomic_t fscache_n_store_ops;
45364 -extern atomic_t fscache_n_store_calls;
45365 -extern atomic_t fscache_n_store_pages;
45366 -extern atomic_t fscache_n_store_radix_deletes;
45367 -extern atomic_t fscache_n_store_pages_over_limit;
45368 +extern atomic_unchecked_t fscache_n_stores;
45369 +extern atomic_unchecked_t fscache_n_stores_ok;
45370 +extern atomic_unchecked_t fscache_n_stores_again;
45371 +extern atomic_unchecked_t fscache_n_stores_nobufs;
45372 +extern atomic_unchecked_t fscache_n_stores_oom;
45373 +extern atomic_unchecked_t fscache_n_store_ops;
45374 +extern atomic_unchecked_t fscache_n_store_calls;
45375 +extern atomic_unchecked_t fscache_n_store_pages;
45376 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
45377 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
45378
45379 -extern atomic_t fscache_n_store_vmscan_not_storing;
45380 -extern atomic_t fscache_n_store_vmscan_gone;
45381 -extern atomic_t fscache_n_store_vmscan_busy;
45382 -extern atomic_t fscache_n_store_vmscan_cancelled;
45383 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
45384 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
45385 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
45386 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
45387
45388 -extern atomic_t fscache_n_marks;
45389 -extern atomic_t fscache_n_uncaches;
45390 +extern atomic_unchecked_t fscache_n_marks;
45391 +extern atomic_unchecked_t fscache_n_uncaches;
45392
45393 -extern atomic_t fscache_n_acquires;
45394 -extern atomic_t fscache_n_acquires_null;
45395 -extern atomic_t fscache_n_acquires_no_cache;
45396 -extern atomic_t fscache_n_acquires_ok;
45397 -extern atomic_t fscache_n_acquires_nobufs;
45398 -extern atomic_t fscache_n_acquires_oom;
45399 +extern atomic_unchecked_t fscache_n_acquires;
45400 +extern atomic_unchecked_t fscache_n_acquires_null;
45401 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
45402 +extern atomic_unchecked_t fscache_n_acquires_ok;
45403 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
45404 +extern atomic_unchecked_t fscache_n_acquires_oom;
45405
45406 -extern atomic_t fscache_n_updates;
45407 -extern atomic_t fscache_n_updates_null;
45408 -extern atomic_t fscache_n_updates_run;
45409 +extern atomic_unchecked_t fscache_n_updates;
45410 +extern atomic_unchecked_t fscache_n_updates_null;
45411 +extern atomic_unchecked_t fscache_n_updates_run;
45412
45413 -extern atomic_t fscache_n_relinquishes;
45414 -extern atomic_t fscache_n_relinquishes_null;
45415 -extern atomic_t fscache_n_relinquishes_waitcrt;
45416 -extern atomic_t fscache_n_relinquishes_retire;
45417 +extern atomic_unchecked_t fscache_n_relinquishes;
45418 +extern atomic_unchecked_t fscache_n_relinquishes_null;
45419 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
45420 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
45421
45422 -extern atomic_t fscache_n_cookie_index;
45423 -extern atomic_t fscache_n_cookie_data;
45424 -extern atomic_t fscache_n_cookie_special;
45425 +extern atomic_unchecked_t fscache_n_cookie_index;
45426 +extern atomic_unchecked_t fscache_n_cookie_data;
45427 +extern atomic_unchecked_t fscache_n_cookie_special;
45428
45429 -extern atomic_t fscache_n_object_alloc;
45430 -extern atomic_t fscache_n_object_no_alloc;
45431 -extern atomic_t fscache_n_object_lookups;
45432 -extern atomic_t fscache_n_object_lookups_negative;
45433 -extern atomic_t fscache_n_object_lookups_positive;
45434 -extern atomic_t fscache_n_object_lookups_timed_out;
45435 -extern atomic_t fscache_n_object_created;
45436 -extern atomic_t fscache_n_object_avail;
45437 -extern atomic_t fscache_n_object_dead;
45438 +extern atomic_unchecked_t fscache_n_object_alloc;
45439 +extern atomic_unchecked_t fscache_n_object_no_alloc;
45440 +extern atomic_unchecked_t fscache_n_object_lookups;
45441 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
45442 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
45443 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
45444 +extern atomic_unchecked_t fscache_n_object_created;
45445 +extern atomic_unchecked_t fscache_n_object_avail;
45446 +extern atomic_unchecked_t fscache_n_object_dead;
45447
45448 -extern atomic_t fscache_n_checkaux_none;
45449 -extern atomic_t fscache_n_checkaux_okay;
45450 -extern atomic_t fscache_n_checkaux_update;
45451 -extern atomic_t fscache_n_checkaux_obsolete;
45452 +extern atomic_unchecked_t fscache_n_checkaux_none;
45453 +extern atomic_unchecked_t fscache_n_checkaux_okay;
45454 +extern atomic_unchecked_t fscache_n_checkaux_update;
45455 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
45456
45457 extern atomic_t fscache_n_cop_alloc_object;
45458 extern atomic_t fscache_n_cop_lookup_object;
45459 @@ -255,6 +255,11 @@ static inline void fscache_stat(atomic_t *stat)
45460 atomic_inc(stat);
45461 }
45462
45463 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
45464 +{
45465 + atomic_inc_unchecked(stat);
45466 +}
45467 +
45468 static inline void fscache_stat_d(atomic_t *stat)
45469 {
45470 atomic_dec(stat);
45471 @@ -267,6 +272,7 @@ extern const struct file_operations fscache_stats_fops;
45472
45473 #define __fscache_stat(stat) (NULL)
45474 #define fscache_stat(stat) do {} while (0)
45475 +#define fscache_stat_unchecked(stat) do {} while (0)
45476 #define fscache_stat_d(stat) do {} while (0)
45477 #endif
45478
45479 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
45480 index b6b897c..0ffff9c 100644
45481 --- a/fs/fscache/object.c
45482 +++ b/fs/fscache/object.c
45483 @@ -128,7 +128,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
45484 /* update the object metadata on disk */
45485 case FSCACHE_OBJECT_UPDATING:
45486 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
45487 - fscache_stat(&fscache_n_updates_run);
45488 + fscache_stat_unchecked(&fscache_n_updates_run);
45489 fscache_stat(&fscache_n_cop_update_object);
45490 object->cache->ops->update_object(object);
45491 fscache_stat_d(&fscache_n_cop_update_object);
45492 @@ -217,7 +217,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
45493 spin_lock(&object->lock);
45494 object->state = FSCACHE_OBJECT_DEAD;
45495 spin_unlock(&object->lock);
45496 - fscache_stat(&fscache_n_object_dead);
45497 + fscache_stat_unchecked(&fscache_n_object_dead);
45498 goto terminal_transit;
45499
45500 /* handle the parent cache of this object being withdrawn from
45501 @@ -232,7 +232,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
45502 spin_lock(&object->lock);
45503 object->state = FSCACHE_OBJECT_DEAD;
45504 spin_unlock(&object->lock);
45505 - fscache_stat(&fscache_n_object_dead);
45506 + fscache_stat_unchecked(&fscache_n_object_dead);
45507 goto terminal_transit;
45508
45509 /* complain about the object being woken up once it is
45510 @@ -461,7 +461,7 @@ static void fscache_lookup_object(struct fscache_object *object)
45511 parent->cookie->def->name, cookie->def->name,
45512 object->cache->tag->name);
45513
45514 - fscache_stat(&fscache_n_object_lookups);
45515 + fscache_stat_unchecked(&fscache_n_object_lookups);
45516 fscache_stat(&fscache_n_cop_lookup_object);
45517 ret = object->cache->ops->lookup_object(object);
45518 fscache_stat_d(&fscache_n_cop_lookup_object);
45519 @@ -472,7 +472,7 @@ static void fscache_lookup_object(struct fscache_object *object)
45520 if (ret == -ETIMEDOUT) {
45521 /* probably stuck behind another object, so move this one to
45522 * the back of the queue */
45523 - fscache_stat(&fscache_n_object_lookups_timed_out);
45524 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
45525 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
45526 }
45527
45528 @@ -495,7 +495,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
45529
45530 spin_lock(&object->lock);
45531 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
45532 - fscache_stat(&fscache_n_object_lookups_negative);
45533 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
45534
45535 /* transit here to allow write requests to begin stacking up
45536 * and read requests to begin returning ENODATA */
45537 @@ -541,7 +541,7 @@ void fscache_obtained_object(struct fscache_object *object)
45538 * result, in which case there may be data available */
45539 spin_lock(&object->lock);
45540 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
45541 - fscache_stat(&fscache_n_object_lookups_positive);
45542 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
45543
45544 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
45545
45546 @@ -555,7 +555,7 @@ void fscache_obtained_object(struct fscache_object *object)
45547 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
45548 } else {
45549 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
45550 - fscache_stat(&fscache_n_object_created);
45551 + fscache_stat_unchecked(&fscache_n_object_created);
45552
45553 object->state = FSCACHE_OBJECT_AVAILABLE;
45554 spin_unlock(&object->lock);
45555 @@ -602,7 +602,7 @@ static void fscache_object_available(struct fscache_object *object)
45556 fscache_enqueue_dependents(object);
45557
45558 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
45559 - fscache_stat(&fscache_n_object_avail);
45560 + fscache_stat_unchecked(&fscache_n_object_avail);
45561
45562 _leave("");
45563 }
45564 @@ -861,7 +861,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
45565 enum fscache_checkaux result;
45566
45567 if (!object->cookie->def->check_aux) {
45568 - fscache_stat(&fscache_n_checkaux_none);
45569 + fscache_stat_unchecked(&fscache_n_checkaux_none);
45570 return FSCACHE_CHECKAUX_OKAY;
45571 }
45572
45573 @@ -870,17 +870,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
45574 switch (result) {
45575 /* entry okay as is */
45576 case FSCACHE_CHECKAUX_OKAY:
45577 - fscache_stat(&fscache_n_checkaux_okay);
45578 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
45579 break;
45580
45581 /* entry requires update */
45582 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
45583 - fscache_stat(&fscache_n_checkaux_update);
45584 + fscache_stat_unchecked(&fscache_n_checkaux_update);
45585 break;
45586
45587 /* entry requires deletion */
45588 case FSCACHE_CHECKAUX_OBSOLETE:
45589 - fscache_stat(&fscache_n_checkaux_obsolete);
45590 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
45591 break;
45592
45593 default:
45594 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
45595 index 30afdfa..2256596 100644
45596 --- a/fs/fscache/operation.c
45597 +++ b/fs/fscache/operation.c
45598 @@ -17,7 +17,7 @@
45599 #include <linux/slab.h>
45600 #include "internal.h"
45601
45602 -atomic_t fscache_op_debug_id;
45603 +atomic_unchecked_t fscache_op_debug_id;
45604 EXPORT_SYMBOL(fscache_op_debug_id);
45605
45606 /**
45607 @@ -38,7 +38,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
45608 ASSERTCMP(op->object->state, >=, FSCACHE_OBJECT_AVAILABLE);
45609 ASSERTCMP(atomic_read(&op->usage), >, 0);
45610
45611 - fscache_stat(&fscache_n_op_enqueue);
45612 + fscache_stat_unchecked(&fscache_n_op_enqueue);
45613 switch (op->flags & FSCACHE_OP_TYPE) {
45614 case FSCACHE_OP_ASYNC:
45615 _debug("queue async");
45616 @@ -69,7 +69,7 @@ static void fscache_run_op(struct fscache_object *object,
45617 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
45618 if (op->processor)
45619 fscache_enqueue_operation(op);
45620 - fscache_stat(&fscache_n_op_run);
45621 + fscache_stat_unchecked(&fscache_n_op_run);
45622 }
45623
45624 /*
45625 @@ -98,11 +98,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
45626 if (object->n_ops > 1) {
45627 atomic_inc(&op->usage);
45628 list_add_tail(&op->pend_link, &object->pending_ops);
45629 - fscache_stat(&fscache_n_op_pend);
45630 + fscache_stat_unchecked(&fscache_n_op_pend);
45631 } else if (!list_empty(&object->pending_ops)) {
45632 atomic_inc(&op->usage);
45633 list_add_tail(&op->pend_link, &object->pending_ops);
45634 - fscache_stat(&fscache_n_op_pend);
45635 + fscache_stat_unchecked(&fscache_n_op_pend);
45636 fscache_start_operations(object);
45637 } else {
45638 ASSERTCMP(object->n_in_progress, ==, 0);
45639 @@ -118,7 +118,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
45640 object->n_exclusive++; /* reads and writes must wait */
45641 atomic_inc(&op->usage);
45642 list_add_tail(&op->pend_link, &object->pending_ops);
45643 - fscache_stat(&fscache_n_op_pend);
45644 + fscache_stat_unchecked(&fscache_n_op_pend);
45645 ret = 0;
45646 } else {
45647 /* not allowed to submit ops in any other state */
45648 @@ -203,11 +203,11 @@ int fscache_submit_op(struct fscache_object *object,
45649 if (object->n_exclusive > 0) {
45650 atomic_inc(&op->usage);
45651 list_add_tail(&op->pend_link, &object->pending_ops);
45652 - fscache_stat(&fscache_n_op_pend);
45653 + fscache_stat_unchecked(&fscache_n_op_pend);
45654 } else if (!list_empty(&object->pending_ops)) {
45655 atomic_inc(&op->usage);
45656 list_add_tail(&op->pend_link, &object->pending_ops);
45657 - fscache_stat(&fscache_n_op_pend);
45658 + fscache_stat_unchecked(&fscache_n_op_pend);
45659 fscache_start_operations(object);
45660 } else {
45661 ASSERTCMP(object->n_exclusive, ==, 0);
45662 @@ -219,12 +219,12 @@ int fscache_submit_op(struct fscache_object *object,
45663 object->n_ops++;
45664 atomic_inc(&op->usage);
45665 list_add_tail(&op->pend_link, &object->pending_ops);
45666 - fscache_stat(&fscache_n_op_pend);
45667 + fscache_stat_unchecked(&fscache_n_op_pend);
45668 ret = 0;
45669 } else if (object->state == FSCACHE_OBJECT_DYING ||
45670 object->state == FSCACHE_OBJECT_LC_DYING ||
45671 object->state == FSCACHE_OBJECT_WITHDRAWING) {
45672 - fscache_stat(&fscache_n_op_rejected);
45673 + fscache_stat_unchecked(&fscache_n_op_rejected);
45674 ret = -ENOBUFS;
45675 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
45676 fscache_report_unexpected_submission(object, op, ostate);
45677 @@ -294,7 +294,7 @@ int fscache_cancel_op(struct fscache_operation *op)
45678
45679 ret = -EBUSY;
45680 if (!list_empty(&op->pend_link)) {
45681 - fscache_stat(&fscache_n_op_cancelled);
45682 + fscache_stat_unchecked(&fscache_n_op_cancelled);
45683 list_del_init(&op->pend_link);
45684 object->n_ops--;
45685 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags))
45686 @@ -331,7 +331,7 @@ void fscache_put_operation(struct fscache_operation *op)
45687 if (test_and_set_bit(FSCACHE_OP_DEAD, &op->flags))
45688 BUG();
45689
45690 - fscache_stat(&fscache_n_op_release);
45691 + fscache_stat_unchecked(&fscache_n_op_release);
45692
45693 if (op->release) {
45694 op->release(op);
45695 @@ -348,7 +348,7 @@ void fscache_put_operation(struct fscache_operation *op)
45696 * lock, and defer it otherwise */
45697 if (!spin_trylock(&object->lock)) {
45698 _debug("defer put");
45699 - fscache_stat(&fscache_n_op_deferred_release);
45700 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
45701
45702 cache = object->cache;
45703 spin_lock(&cache->op_gc_list_lock);
45704 @@ -410,7 +410,7 @@ void fscache_operation_gc(struct work_struct *work)
45705
45706 _debug("GC DEFERRED REL OBJ%x OP%x",
45707 object->debug_id, op->debug_id);
45708 - fscache_stat(&fscache_n_op_gc);
45709 + fscache_stat_unchecked(&fscache_n_op_gc);
45710
45711 ASSERTCMP(atomic_read(&op->usage), ==, 0);
45712
45713 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
45714 index 3f7a59b..cf196cc 100644
45715 --- a/fs/fscache/page.c
45716 +++ b/fs/fscache/page.c
45717 @@ -60,7 +60,7 @@ bool __fscache_maybe_release_page(struct fscache_cookie *cookie,
45718 val = radix_tree_lookup(&cookie->stores, page->index);
45719 if (!val) {
45720 rcu_read_unlock();
45721 - fscache_stat(&fscache_n_store_vmscan_not_storing);
45722 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
45723 __fscache_uncache_page(cookie, page);
45724 return true;
45725 }
45726 @@ -90,11 +90,11 @@ bool __fscache_maybe_release_page(struct fscache_cookie *cookie,
45727 spin_unlock(&cookie->stores_lock);
45728
45729 if (xpage) {
45730 - fscache_stat(&fscache_n_store_vmscan_cancelled);
45731 - fscache_stat(&fscache_n_store_radix_deletes);
45732 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
45733 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
45734 ASSERTCMP(xpage, ==, page);
45735 } else {
45736 - fscache_stat(&fscache_n_store_vmscan_gone);
45737 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
45738 }
45739
45740 wake_up_bit(&cookie->flags, 0);
45741 @@ -107,7 +107,7 @@ page_busy:
45742 /* we might want to wait here, but that could deadlock the allocator as
45743 * the work threads writing to the cache may all end up sleeping
45744 * on memory allocation */
45745 - fscache_stat(&fscache_n_store_vmscan_busy);
45746 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
45747 return false;
45748 }
45749 EXPORT_SYMBOL(__fscache_maybe_release_page);
45750 @@ -131,7 +131,7 @@ static void fscache_end_page_write(struct fscache_object *object,
45751 FSCACHE_COOKIE_STORING_TAG);
45752 if (!radix_tree_tag_get(&cookie->stores, page->index,
45753 FSCACHE_COOKIE_PENDING_TAG)) {
45754 - fscache_stat(&fscache_n_store_radix_deletes);
45755 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
45756 xpage = radix_tree_delete(&cookie->stores, page->index);
45757 }
45758 spin_unlock(&cookie->stores_lock);
45759 @@ -152,7 +152,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
45760
45761 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
45762
45763 - fscache_stat(&fscache_n_attr_changed_calls);
45764 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
45765
45766 if (fscache_object_is_active(object)) {
45767 fscache_stat(&fscache_n_cop_attr_changed);
45768 @@ -177,11 +177,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
45769
45770 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
45771
45772 - fscache_stat(&fscache_n_attr_changed);
45773 + fscache_stat_unchecked(&fscache_n_attr_changed);
45774
45775 op = kzalloc(sizeof(*op), GFP_KERNEL);
45776 if (!op) {
45777 - fscache_stat(&fscache_n_attr_changed_nomem);
45778 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
45779 _leave(" = -ENOMEM");
45780 return -ENOMEM;
45781 }
45782 @@ -199,7 +199,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
45783 if (fscache_submit_exclusive_op(object, op) < 0)
45784 goto nobufs;
45785 spin_unlock(&cookie->lock);
45786 - fscache_stat(&fscache_n_attr_changed_ok);
45787 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
45788 fscache_put_operation(op);
45789 _leave(" = 0");
45790 return 0;
45791 @@ -207,7 +207,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
45792 nobufs:
45793 spin_unlock(&cookie->lock);
45794 kfree(op);
45795 - fscache_stat(&fscache_n_attr_changed_nobufs);
45796 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
45797 _leave(" = %d", -ENOBUFS);
45798 return -ENOBUFS;
45799 }
45800 @@ -243,7 +243,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
45801 /* allocate a retrieval operation and attempt to submit it */
45802 op = kzalloc(sizeof(*op), GFP_NOIO);
45803 if (!op) {
45804 - fscache_stat(&fscache_n_retrievals_nomem);
45805 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
45806 return NULL;
45807 }
45808
45809 @@ -271,13 +271,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
45810 return 0;
45811 }
45812
45813 - fscache_stat(&fscache_n_retrievals_wait);
45814 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
45815
45816 jif = jiffies;
45817 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
45818 fscache_wait_bit_interruptible,
45819 TASK_INTERRUPTIBLE) != 0) {
45820 - fscache_stat(&fscache_n_retrievals_intr);
45821 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
45822 _leave(" = -ERESTARTSYS");
45823 return -ERESTARTSYS;
45824 }
45825 @@ -295,8 +295,8 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
45826 */
45827 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
45828 struct fscache_retrieval *op,
45829 - atomic_t *stat_op_waits,
45830 - atomic_t *stat_object_dead)
45831 + atomic_unchecked_t *stat_op_waits,
45832 + atomic_unchecked_t *stat_object_dead)
45833 {
45834 int ret;
45835
45836 @@ -304,7 +304,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
45837 goto check_if_dead;
45838
45839 _debug(">>> WT");
45840 - fscache_stat(stat_op_waits);
45841 + fscache_stat_unchecked(stat_op_waits);
45842 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
45843 fscache_wait_bit_interruptible,
45844 TASK_INTERRUPTIBLE) < 0) {
45845 @@ -321,7 +321,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
45846
45847 check_if_dead:
45848 if (unlikely(fscache_object_is_dead(object))) {
45849 - fscache_stat(stat_object_dead);
45850 + fscache_stat_unchecked(stat_object_dead);
45851 return -ENOBUFS;
45852 }
45853 return 0;
45854 @@ -348,7 +348,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
45855
45856 _enter("%p,%p,,,", cookie, page);
45857
45858 - fscache_stat(&fscache_n_retrievals);
45859 + fscache_stat_unchecked(&fscache_n_retrievals);
45860
45861 if (hlist_empty(&cookie->backing_objects))
45862 goto nobufs;
45863 @@ -381,7 +381,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
45864 goto nobufs_unlock;
45865 spin_unlock(&cookie->lock);
45866
45867 - fscache_stat(&fscache_n_retrieval_ops);
45868 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
45869
45870 /* pin the netfs read context in case we need to do the actual netfs
45871 * read because we've encountered a cache read failure */
45872 @@ -411,15 +411,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
45873
45874 error:
45875 if (ret == -ENOMEM)
45876 - fscache_stat(&fscache_n_retrievals_nomem);
45877 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
45878 else if (ret == -ERESTARTSYS)
45879 - fscache_stat(&fscache_n_retrievals_intr);
45880 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
45881 else if (ret == -ENODATA)
45882 - fscache_stat(&fscache_n_retrievals_nodata);
45883 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
45884 else if (ret < 0)
45885 - fscache_stat(&fscache_n_retrievals_nobufs);
45886 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
45887 else
45888 - fscache_stat(&fscache_n_retrievals_ok);
45889 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
45890
45891 fscache_put_retrieval(op);
45892 _leave(" = %d", ret);
45893 @@ -429,7 +429,7 @@ nobufs_unlock:
45894 spin_unlock(&cookie->lock);
45895 kfree(op);
45896 nobufs:
45897 - fscache_stat(&fscache_n_retrievals_nobufs);
45898 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
45899 _leave(" = -ENOBUFS");
45900 return -ENOBUFS;
45901 }
45902 @@ -467,7 +467,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
45903
45904 _enter("%p,,%d,,,", cookie, *nr_pages);
45905
45906 - fscache_stat(&fscache_n_retrievals);
45907 + fscache_stat_unchecked(&fscache_n_retrievals);
45908
45909 if (hlist_empty(&cookie->backing_objects))
45910 goto nobufs;
45911 @@ -497,7 +497,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
45912 goto nobufs_unlock;
45913 spin_unlock(&cookie->lock);
45914
45915 - fscache_stat(&fscache_n_retrieval_ops);
45916 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
45917
45918 /* pin the netfs read context in case we need to do the actual netfs
45919 * read because we've encountered a cache read failure */
45920 @@ -527,15 +527,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
45921
45922 error:
45923 if (ret == -ENOMEM)
45924 - fscache_stat(&fscache_n_retrievals_nomem);
45925 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
45926 else if (ret == -ERESTARTSYS)
45927 - fscache_stat(&fscache_n_retrievals_intr);
45928 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
45929 else if (ret == -ENODATA)
45930 - fscache_stat(&fscache_n_retrievals_nodata);
45931 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
45932 else if (ret < 0)
45933 - fscache_stat(&fscache_n_retrievals_nobufs);
45934 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
45935 else
45936 - fscache_stat(&fscache_n_retrievals_ok);
45937 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
45938
45939 fscache_put_retrieval(op);
45940 _leave(" = %d", ret);
45941 @@ -545,7 +545,7 @@ nobufs_unlock:
45942 spin_unlock(&cookie->lock);
45943 kfree(op);
45944 nobufs:
45945 - fscache_stat(&fscache_n_retrievals_nobufs);
45946 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
45947 _leave(" = -ENOBUFS");
45948 return -ENOBUFS;
45949 }
45950 @@ -569,7 +569,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
45951
45952 _enter("%p,%p,,,", cookie, page);
45953
45954 - fscache_stat(&fscache_n_allocs);
45955 + fscache_stat_unchecked(&fscache_n_allocs);
45956
45957 if (hlist_empty(&cookie->backing_objects))
45958 goto nobufs;
45959 @@ -595,7 +595,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
45960 goto nobufs_unlock;
45961 spin_unlock(&cookie->lock);
45962
45963 - fscache_stat(&fscache_n_alloc_ops);
45964 + fscache_stat_unchecked(&fscache_n_alloc_ops);
45965
45966 ret = fscache_wait_for_retrieval_activation(
45967 object, op,
45968 @@ -611,11 +611,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
45969
45970 error:
45971 if (ret == -ERESTARTSYS)
45972 - fscache_stat(&fscache_n_allocs_intr);
45973 + fscache_stat_unchecked(&fscache_n_allocs_intr);
45974 else if (ret < 0)
45975 - fscache_stat(&fscache_n_allocs_nobufs);
45976 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
45977 else
45978 - fscache_stat(&fscache_n_allocs_ok);
45979 + fscache_stat_unchecked(&fscache_n_allocs_ok);
45980
45981 fscache_put_retrieval(op);
45982 _leave(" = %d", ret);
45983 @@ -625,7 +625,7 @@ nobufs_unlock:
45984 spin_unlock(&cookie->lock);
45985 kfree(op);
45986 nobufs:
45987 - fscache_stat(&fscache_n_allocs_nobufs);
45988 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
45989 _leave(" = -ENOBUFS");
45990 return -ENOBUFS;
45991 }
45992 @@ -666,7 +666,7 @@ static void fscache_write_op(struct fscache_operation *_op)
45993
45994 spin_lock(&cookie->stores_lock);
45995
45996 - fscache_stat(&fscache_n_store_calls);
45997 + fscache_stat_unchecked(&fscache_n_store_calls);
45998
45999 /* find a page to store */
46000 page = NULL;
46001 @@ -677,7 +677,7 @@ static void fscache_write_op(struct fscache_operation *_op)
46002 page = results[0];
46003 _debug("gang %d [%lx]", n, page->index);
46004 if (page->index > op->store_limit) {
46005 - fscache_stat(&fscache_n_store_pages_over_limit);
46006 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
46007 goto superseded;
46008 }
46009
46010 @@ -689,7 +689,7 @@ static void fscache_write_op(struct fscache_operation *_op)
46011 spin_unlock(&cookie->stores_lock);
46012 spin_unlock(&object->lock);
46013
46014 - fscache_stat(&fscache_n_store_pages);
46015 + fscache_stat_unchecked(&fscache_n_store_pages);
46016 fscache_stat(&fscache_n_cop_write_page);
46017 ret = object->cache->ops->write_page(op, page);
46018 fscache_stat_d(&fscache_n_cop_write_page);
46019 @@ -757,7 +757,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
46020 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
46021 ASSERT(PageFsCache(page));
46022
46023 - fscache_stat(&fscache_n_stores);
46024 + fscache_stat_unchecked(&fscache_n_stores);
46025
46026 op = kzalloc(sizeof(*op), GFP_NOIO);
46027 if (!op)
46028 @@ -808,7 +808,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
46029 spin_unlock(&cookie->stores_lock);
46030 spin_unlock(&object->lock);
46031
46032 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
46033 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
46034 op->store_limit = object->store_limit;
46035
46036 if (fscache_submit_op(object, &op->op) < 0)
46037 @@ -816,8 +816,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
46038
46039 spin_unlock(&cookie->lock);
46040 radix_tree_preload_end();
46041 - fscache_stat(&fscache_n_store_ops);
46042 - fscache_stat(&fscache_n_stores_ok);
46043 + fscache_stat_unchecked(&fscache_n_store_ops);
46044 + fscache_stat_unchecked(&fscache_n_stores_ok);
46045
46046 /* the work queue now carries its own ref on the object */
46047 fscache_put_operation(&op->op);
46048 @@ -825,14 +825,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
46049 return 0;
46050
46051 already_queued:
46052 - fscache_stat(&fscache_n_stores_again);
46053 + fscache_stat_unchecked(&fscache_n_stores_again);
46054 already_pending:
46055 spin_unlock(&cookie->stores_lock);
46056 spin_unlock(&object->lock);
46057 spin_unlock(&cookie->lock);
46058 radix_tree_preload_end();
46059 kfree(op);
46060 - fscache_stat(&fscache_n_stores_ok);
46061 + fscache_stat_unchecked(&fscache_n_stores_ok);
46062 _leave(" = 0");
46063 return 0;
46064
46065 @@ -851,14 +851,14 @@ nobufs:
46066 spin_unlock(&cookie->lock);
46067 radix_tree_preload_end();
46068 kfree(op);
46069 - fscache_stat(&fscache_n_stores_nobufs);
46070 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
46071 _leave(" = -ENOBUFS");
46072 return -ENOBUFS;
46073
46074 nomem_free:
46075 kfree(op);
46076 nomem:
46077 - fscache_stat(&fscache_n_stores_oom);
46078 + fscache_stat_unchecked(&fscache_n_stores_oom);
46079 _leave(" = -ENOMEM");
46080 return -ENOMEM;
46081 }
46082 @@ -876,7 +876,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
46083 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
46084 ASSERTCMP(page, !=, NULL);
46085
46086 - fscache_stat(&fscache_n_uncaches);
46087 + fscache_stat_unchecked(&fscache_n_uncaches);
46088
46089 /* cache withdrawal may beat us to it */
46090 if (!PageFsCache(page))
46091 @@ -929,7 +929,7 @@ void fscache_mark_pages_cached(struct fscache_retrieval *op,
46092 unsigned long loop;
46093
46094 #ifdef CONFIG_FSCACHE_STATS
46095 - atomic_add(pagevec->nr, &fscache_n_marks);
46096 + atomic_add_unchecked(pagevec->nr, &fscache_n_marks);
46097 #endif
46098
46099 for (loop = 0; loop < pagevec->nr; loop++) {
46100 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
46101 index 4765190..2a067f2 100644
46102 --- a/fs/fscache/stats.c
46103 +++ b/fs/fscache/stats.c
46104 @@ -18,95 +18,95 @@
46105 /*
46106 * operation counters
46107 */
46108 -atomic_t fscache_n_op_pend;
46109 -atomic_t fscache_n_op_run;
46110 -atomic_t fscache_n_op_enqueue;
46111 -atomic_t fscache_n_op_requeue;
46112 -atomic_t fscache_n_op_deferred_release;
46113 -atomic_t fscache_n_op_release;
46114 -atomic_t fscache_n_op_gc;
46115 -atomic_t fscache_n_op_cancelled;
46116 -atomic_t fscache_n_op_rejected;
46117 +atomic_unchecked_t fscache_n_op_pend;
46118 +atomic_unchecked_t fscache_n_op_run;
46119 +atomic_unchecked_t fscache_n_op_enqueue;
46120 +atomic_unchecked_t fscache_n_op_requeue;
46121 +atomic_unchecked_t fscache_n_op_deferred_release;
46122 +atomic_unchecked_t fscache_n_op_release;
46123 +atomic_unchecked_t fscache_n_op_gc;
46124 +atomic_unchecked_t fscache_n_op_cancelled;
46125 +atomic_unchecked_t fscache_n_op_rejected;
46126
46127 -atomic_t fscache_n_attr_changed;
46128 -atomic_t fscache_n_attr_changed_ok;
46129 -atomic_t fscache_n_attr_changed_nobufs;
46130 -atomic_t fscache_n_attr_changed_nomem;
46131 -atomic_t fscache_n_attr_changed_calls;
46132 +atomic_unchecked_t fscache_n_attr_changed;
46133 +atomic_unchecked_t fscache_n_attr_changed_ok;
46134 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
46135 +atomic_unchecked_t fscache_n_attr_changed_nomem;
46136 +atomic_unchecked_t fscache_n_attr_changed_calls;
46137
46138 -atomic_t fscache_n_allocs;
46139 -atomic_t fscache_n_allocs_ok;
46140 -atomic_t fscache_n_allocs_wait;
46141 -atomic_t fscache_n_allocs_nobufs;
46142 -atomic_t fscache_n_allocs_intr;
46143 -atomic_t fscache_n_allocs_object_dead;
46144 -atomic_t fscache_n_alloc_ops;
46145 -atomic_t fscache_n_alloc_op_waits;
46146 +atomic_unchecked_t fscache_n_allocs;
46147 +atomic_unchecked_t fscache_n_allocs_ok;
46148 +atomic_unchecked_t fscache_n_allocs_wait;
46149 +atomic_unchecked_t fscache_n_allocs_nobufs;
46150 +atomic_unchecked_t fscache_n_allocs_intr;
46151 +atomic_unchecked_t fscache_n_allocs_object_dead;
46152 +atomic_unchecked_t fscache_n_alloc_ops;
46153 +atomic_unchecked_t fscache_n_alloc_op_waits;
46154
46155 -atomic_t fscache_n_retrievals;
46156 -atomic_t fscache_n_retrievals_ok;
46157 -atomic_t fscache_n_retrievals_wait;
46158 -atomic_t fscache_n_retrievals_nodata;
46159 -atomic_t fscache_n_retrievals_nobufs;
46160 -atomic_t fscache_n_retrievals_intr;
46161 -atomic_t fscache_n_retrievals_nomem;
46162 -atomic_t fscache_n_retrievals_object_dead;
46163 -atomic_t fscache_n_retrieval_ops;
46164 -atomic_t fscache_n_retrieval_op_waits;
46165 +atomic_unchecked_t fscache_n_retrievals;
46166 +atomic_unchecked_t fscache_n_retrievals_ok;
46167 +atomic_unchecked_t fscache_n_retrievals_wait;
46168 +atomic_unchecked_t fscache_n_retrievals_nodata;
46169 +atomic_unchecked_t fscache_n_retrievals_nobufs;
46170 +atomic_unchecked_t fscache_n_retrievals_intr;
46171 +atomic_unchecked_t fscache_n_retrievals_nomem;
46172 +atomic_unchecked_t fscache_n_retrievals_object_dead;
46173 +atomic_unchecked_t fscache_n_retrieval_ops;
46174 +atomic_unchecked_t fscache_n_retrieval_op_waits;
46175
46176 -atomic_t fscache_n_stores;
46177 -atomic_t fscache_n_stores_ok;
46178 -atomic_t fscache_n_stores_again;
46179 -atomic_t fscache_n_stores_nobufs;
46180 -atomic_t fscache_n_stores_oom;
46181 -atomic_t fscache_n_store_ops;
46182 -atomic_t fscache_n_store_calls;
46183 -atomic_t fscache_n_store_pages;
46184 -atomic_t fscache_n_store_radix_deletes;
46185 -atomic_t fscache_n_store_pages_over_limit;
46186 +atomic_unchecked_t fscache_n_stores;
46187 +atomic_unchecked_t fscache_n_stores_ok;
46188 +atomic_unchecked_t fscache_n_stores_again;
46189 +atomic_unchecked_t fscache_n_stores_nobufs;
46190 +atomic_unchecked_t fscache_n_stores_oom;
46191 +atomic_unchecked_t fscache_n_store_ops;
46192 +atomic_unchecked_t fscache_n_store_calls;
46193 +atomic_unchecked_t fscache_n_store_pages;
46194 +atomic_unchecked_t fscache_n_store_radix_deletes;
46195 +atomic_unchecked_t fscache_n_store_pages_over_limit;
46196
46197 -atomic_t fscache_n_store_vmscan_not_storing;
46198 -atomic_t fscache_n_store_vmscan_gone;
46199 -atomic_t fscache_n_store_vmscan_busy;
46200 -atomic_t fscache_n_store_vmscan_cancelled;
46201 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
46202 +atomic_unchecked_t fscache_n_store_vmscan_gone;
46203 +atomic_unchecked_t fscache_n_store_vmscan_busy;
46204 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
46205
46206 -atomic_t fscache_n_marks;
46207 -atomic_t fscache_n_uncaches;
46208 +atomic_unchecked_t fscache_n_marks;
46209 +atomic_unchecked_t fscache_n_uncaches;
46210
46211 -atomic_t fscache_n_acquires;
46212 -atomic_t fscache_n_acquires_null;
46213 -atomic_t fscache_n_acquires_no_cache;
46214 -atomic_t fscache_n_acquires_ok;
46215 -atomic_t fscache_n_acquires_nobufs;
46216 -atomic_t fscache_n_acquires_oom;
46217 +atomic_unchecked_t fscache_n_acquires;
46218 +atomic_unchecked_t fscache_n_acquires_null;
46219 +atomic_unchecked_t fscache_n_acquires_no_cache;
46220 +atomic_unchecked_t fscache_n_acquires_ok;
46221 +atomic_unchecked_t fscache_n_acquires_nobufs;
46222 +atomic_unchecked_t fscache_n_acquires_oom;
46223
46224 -atomic_t fscache_n_updates;
46225 -atomic_t fscache_n_updates_null;
46226 -atomic_t fscache_n_updates_run;
46227 +atomic_unchecked_t fscache_n_updates;
46228 +atomic_unchecked_t fscache_n_updates_null;
46229 +atomic_unchecked_t fscache_n_updates_run;
46230
46231 -atomic_t fscache_n_relinquishes;
46232 -atomic_t fscache_n_relinquishes_null;
46233 -atomic_t fscache_n_relinquishes_waitcrt;
46234 -atomic_t fscache_n_relinquishes_retire;
46235 +atomic_unchecked_t fscache_n_relinquishes;
46236 +atomic_unchecked_t fscache_n_relinquishes_null;
46237 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
46238 +atomic_unchecked_t fscache_n_relinquishes_retire;
46239
46240 -atomic_t fscache_n_cookie_index;
46241 -atomic_t fscache_n_cookie_data;
46242 -atomic_t fscache_n_cookie_special;
46243 +atomic_unchecked_t fscache_n_cookie_index;
46244 +atomic_unchecked_t fscache_n_cookie_data;
46245 +atomic_unchecked_t fscache_n_cookie_special;
46246
46247 -atomic_t fscache_n_object_alloc;
46248 -atomic_t fscache_n_object_no_alloc;
46249 -atomic_t fscache_n_object_lookups;
46250 -atomic_t fscache_n_object_lookups_negative;
46251 -atomic_t fscache_n_object_lookups_positive;
46252 -atomic_t fscache_n_object_lookups_timed_out;
46253 -atomic_t fscache_n_object_created;
46254 -atomic_t fscache_n_object_avail;
46255 -atomic_t fscache_n_object_dead;
46256 +atomic_unchecked_t fscache_n_object_alloc;
46257 +atomic_unchecked_t fscache_n_object_no_alloc;
46258 +atomic_unchecked_t fscache_n_object_lookups;
46259 +atomic_unchecked_t fscache_n_object_lookups_negative;
46260 +atomic_unchecked_t fscache_n_object_lookups_positive;
46261 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
46262 +atomic_unchecked_t fscache_n_object_created;
46263 +atomic_unchecked_t fscache_n_object_avail;
46264 +atomic_unchecked_t fscache_n_object_dead;
46265
46266 -atomic_t fscache_n_checkaux_none;
46267 -atomic_t fscache_n_checkaux_okay;
46268 -atomic_t fscache_n_checkaux_update;
46269 -atomic_t fscache_n_checkaux_obsolete;
46270 +atomic_unchecked_t fscache_n_checkaux_none;
46271 +atomic_unchecked_t fscache_n_checkaux_okay;
46272 +atomic_unchecked_t fscache_n_checkaux_update;
46273 +atomic_unchecked_t fscache_n_checkaux_obsolete;
46274
46275 atomic_t fscache_n_cop_alloc_object;
46276 atomic_t fscache_n_cop_lookup_object;
46277 @@ -133,113 +133,113 @@ static int fscache_stats_show(struct seq_file *m, void *v)
46278 seq_puts(m, "FS-Cache statistics\n");
46279
46280 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
46281 - atomic_read(&fscache_n_cookie_index),
46282 - atomic_read(&fscache_n_cookie_data),
46283 - atomic_read(&fscache_n_cookie_special));
46284 + atomic_read_unchecked(&fscache_n_cookie_index),
46285 + atomic_read_unchecked(&fscache_n_cookie_data),
46286 + atomic_read_unchecked(&fscache_n_cookie_special));
46287
46288 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
46289 - atomic_read(&fscache_n_object_alloc),
46290 - atomic_read(&fscache_n_object_no_alloc),
46291 - atomic_read(&fscache_n_object_avail),
46292 - atomic_read(&fscache_n_object_dead));
46293 + atomic_read_unchecked(&fscache_n_object_alloc),
46294 + atomic_read_unchecked(&fscache_n_object_no_alloc),
46295 + atomic_read_unchecked(&fscache_n_object_avail),
46296 + atomic_read_unchecked(&fscache_n_object_dead));
46297 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
46298 - atomic_read(&fscache_n_checkaux_none),
46299 - atomic_read(&fscache_n_checkaux_okay),
46300 - atomic_read(&fscache_n_checkaux_update),
46301 - atomic_read(&fscache_n_checkaux_obsolete));
46302 + atomic_read_unchecked(&fscache_n_checkaux_none),
46303 + atomic_read_unchecked(&fscache_n_checkaux_okay),
46304 + atomic_read_unchecked(&fscache_n_checkaux_update),
46305 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
46306
46307 seq_printf(m, "Pages : mrk=%u unc=%u\n",
46308 - atomic_read(&fscache_n_marks),
46309 - atomic_read(&fscache_n_uncaches));
46310 + atomic_read_unchecked(&fscache_n_marks),
46311 + atomic_read_unchecked(&fscache_n_uncaches));
46312
46313 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
46314 " oom=%u\n",
46315 - atomic_read(&fscache_n_acquires),
46316 - atomic_read(&fscache_n_acquires_null),
46317 - atomic_read(&fscache_n_acquires_no_cache),
46318 - atomic_read(&fscache_n_acquires_ok),
46319 - atomic_read(&fscache_n_acquires_nobufs),
46320 - atomic_read(&fscache_n_acquires_oom));
46321 + atomic_read_unchecked(&fscache_n_acquires),
46322 + atomic_read_unchecked(&fscache_n_acquires_null),
46323 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
46324 + atomic_read_unchecked(&fscache_n_acquires_ok),
46325 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
46326 + atomic_read_unchecked(&fscache_n_acquires_oom));
46327
46328 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
46329 - atomic_read(&fscache_n_object_lookups),
46330 - atomic_read(&fscache_n_object_lookups_negative),
46331 - atomic_read(&fscache_n_object_lookups_positive),
46332 - atomic_read(&fscache_n_object_created),
46333 - atomic_read(&fscache_n_object_lookups_timed_out));
46334 + atomic_read_unchecked(&fscache_n_object_lookups),
46335 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
46336 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
46337 + atomic_read_unchecked(&fscache_n_object_created),
46338 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
46339
46340 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
46341 - atomic_read(&fscache_n_updates),
46342 - atomic_read(&fscache_n_updates_null),
46343 - atomic_read(&fscache_n_updates_run));
46344 + atomic_read_unchecked(&fscache_n_updates),
46345 + atomic_read_unchecked(&fscache_n_updates_null),
46346 + atomic_read_unchecked(&fscache_n_updates_run));
46347
46348 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
46349 - atomic_read(&fscache_n_relinquishes),
46350 - atomic_read(&fscache_n_relinquishes_null),
46351 - atomic_read(&fscache_n_relinquishes_waitcrt),
46352 - atomic_read(&fscache_n_relinquishes_retire));
46353 + atomic_read_unchecked(&fscache_n_relinquishes),
46354 + atomic_read_unchecked(&fscache_n_relinquishes_null),
46355 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
46356 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
46357
46358 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
46359 - atomic_read(&fscache_n_attr_changed),
46360 - atomic_read(&fscache_n_attr_changed_ok),
46361 - atomic_read(&fscache_n_attr_changed_nobufs),
46362 - atomic_read(&fscache_n_attr_changed_nomem),
46363 - atomic_read(&fscache_n_attr_changed_calls));
46364 + atomic_read_unchecked(&fscache_n_attr_changed),
46365 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
46366 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
46367 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
46368 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
46369
46370 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
46371 - atomic_read(&fscache_n_allocs),
46372 - atomic_read(&fscache_n_allocs_ok),
46373 - atomic_read(&fscache_n_allocs_wait),
46374 - atomic_read(&fscache_n_allocs_nobufs),
46375 - atomic_read(&fscache_n_allocs_intr));
46376 + atomic_read_unchecked(&fscache_n_allocs),
46377 + atomic_read_unchecked(&fscache_n_allocs_ok),
46378 + atomic_read_unchecked(&fscache_n_allocs_wait),
46379 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
46380 + atomic_read_unchecked(&fscache_n_allocs_intr));
46381 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
46382 - atomic_read(&fscache_n_alloc_ops),
46383 - atomic_read(&fscache_n_alloc_op_waits),
46384 - atomic_read(&fscache_n_allocs_object_dead));
46385 + atomic_read_unchecked(&fscache_n_alloc_ops),
46386 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
46387 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
46388
46389 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
46390 " int=%u oom=%u\n",
46391 - atomic_read(&fscache_n_retrievals),
46392 - atomic_read(&fscache_n_retrievals_ok),
46393 - atomic_read(&fscache_n_retrievals_wait),
46394 - atomic_read(&fscache_n_retrievals_nodata),
46395 - atomic_read(&fscache_n_retrievals_nobufs),
46396 - atomic_read(&fscache_n_retrievals_intr),
46397 - atomic_read(&fscache_n_retrievals_nomem));
46398 + atomic_read_unchecked(&fscache_n_retrievals),
46399 + atomic_read_unchecked(&fscache_n_retrievals_ok),
46400 + atomic_read_unchecked(&fscache_n_retrievals_wait),
46401 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
46402 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
46403 + atomic_read_unchecked(&fscache_n_retrievals_intr),
46404 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
46405 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
46406 - atomic_read(&fscache_n_retrieval_ops),
46407 - atomic_read(&fscache_n_retrieval_op_waits),
46408 - atomic_read(&fscache_n_retrievals_object_dead));
46409 + atomic_read_unchecked(&fscache_n_retrieval_ops),
46410 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
46411 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
46412
46413 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
46414 - atomic_read(&fscache_n_stores),
46415 - atomic_read(&fscache_n_stores_ok),
46416 - atomic_read(&fscache_n_stores_again),
46417 - atomic_read(&fscache_n_stores_nobufs),
46418 - atomic_read(&fscache_n_stores_oom));
46419 + atomic_read_unchecked(&fscache_n_stores),
46420 + atomic_read_unchecked(&fscache_n_stores_ok),
46421 + atomic_read_unchecked(&fscache_n_stores_again),
46422 + atomic_read_unchecked(&fscache_n_stores_nobufs),
46423 + atomic_read_unchecked(&fscache_n_stores_oom));
46424 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
46425 - atomic_read(&fscache_n_store_ops),
46426 - atomic_read(&fscache_n_store_calls),
46427 - atomic_read(&fscache_n_store_pages),
46428 - atomic_read(&fscache_n_store_radix_deletes),
46429 - atomic_read(&fscache_n_store_pages_over_limit));
46430 + atomic_read_unchecked(&fscache_n_store_ops),
46431 + atomic_read_unchecked(&fscache_n_store_calls),
46432 + atomic_read_unchecked(&fscache_n_store_pages),
46433 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
46434 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
46435
46436 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u\n",
46437 - atomic_read(&fscache_n_store_vmscan_not_storing),
46438 - atomic_read(&fscache_n_store_vmscan_gone),
46439 - atomic_read(&fscache_n_store_vmscan_busy),
46440 - atomic_read(&fscache_n_store_vmscan_cancelled));
46441 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
46442 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
46443 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
46444 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled));
46445
46446 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
46447 - atomic_read(&fscache_n_op_pend),
46448 - atomic_read(&fscache_n_op_run),
46449 - atomic_read(&fscache_n_op_enqueue),
46450 - atomic_read(&fscache_n_op_cancelled),
46451 - atomic_read(&fscache_n_op_rejected));
46452 + atomic_read_unchecked(&fscache_n_op_pend),
46453 + atomic_read_unchecked(&fscache_n_op_run),
46454 + atomic_read_unchecked(&fscache_n_op_enqueue),
46455 + atomic_read_unchecked(&fscache_n_op_cancelled),
46456 + atomic_read_unchecked(&fscache_n_op_rejected));
46457 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
46458 - atomic_read(&fscache_n_op_deferred_release),
46459 - atomic_read(&fscache_n_op_release),
46460 - atomic_read(&fscache_n_op_gc));
46461 + atomic_read_unchecked(&fscache_n_op_deferred_release),
46462 + atomic_read_unchecked(&fscache_n_op_release),
46463 + atomic_read_unchecked(&fscache_n_op_gc));
46464
46465 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
46466 atomic_read(&fscache_n_cop_alloc_object),
46467 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
46468 index 3426521..3b75162 100644
46469 --- a/fs/fuse/cuse.c
46470 +++ b/fs/fuse/cuse.c
46471 @@ -587,10 +587,12 @@ static int __init cuse_init(void)
46472 INIT_LIST_HEAD(&cuse_conntbl[i]);
46473
46474 /* inherit and extend fuse_dev_operations */
46475 - cuse_channel_fops = fuse_dev_operations;
46476 - cuse_channel_fops.owner = THIS_MODULE;
46477 - cuse_channel_fops.open = cuse_channel_open;
46478 - cuse_channel_fops.release = cuse_channel_release;
46479 + pax_open_kernel();
46480 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
46481 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
46482 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
46483 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
46484 + pax_close_kernel();
46485
46486 cuse_class = class_create(THIS_MODULE, "cuse");
46487 if (IS_ERR(cuse_class))
46488 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
46489 index 5f3368a..8306426 100644
46490 --- a/fs/fuse/dev.c
46491 +++ b/fs/fuse/dev.c
46492 @@ -1242,7 +1242,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
46493 ret = 0;
46494 pipe_lock(pipe);
46495
46496 - if (!pipe->readers) {
46497 + if (!atomic_read(&pipe->readers)) {
46498 send_sig(SIGPIPE, current, 0);
46499 if (!ret)
46500 ret = -EPIPE;
46501 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
46502 index 2066328..f5add3b 100644
46503 --- a/fs/fuse/dir.c
46504 +++ b/fs/fuse/dir.c
46505 @@ -1175,7 +1175,7 @@ static char *read_link(struct dentry *dentry)
46506 return link;
46507 }
46508
46509 -static void free_link(char *link)
46510 +static void free_link(const char *link)
46511 {
46512 if (!IS_ERR(link))
46513 free_page((unsigned long) link);
46514 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
46515 index 5698746..6086012 100644
46516 --- a/fs/gfs2/inode.c
46517 +++ b/fs/gfs2/inode.c
46518 @@ -1487,7 +1487,7 @@ out:
46519
46520 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
46521 {
46522 - char *s = nd_get_link(nd);
46523 + const char *s = nd_get_link(nd);
46524 if (!IS_ERR(s))
46525 kfree(s);
46526 }
46527 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
46528 index c60267e..193d9e4 100644
46529 --- a/fs/hugetlbfs/inode.c
46530 +++ b/fs/hugetlbfs/inode.c
46531 @@ -902,7 +902,7 @@ static struct file_system_type hugetlbfs_fs_type = {
46532 .kill_sb = kill_litter_super,
46533 };
46534
46535 -static struct vfsmount *hugetlbfs_vfsmount;
46536 +struct vfsmount *hugetlbfs_vfsmount;
46537
46538 static int can_do_hugetlb_shm(void)
46539 {
46540 diff --git a/fs/inode.c b/fs/inode.c
46541 index 83ab215..8842101 100644
46542 --- a/fs/inode.c
46543 +++ b/fs/inode.c
46544 @@ -870,8 +870,8 @@ unsigned int get_next_ino(void)
46545
46546 #ifdef CONFIG_SMP
46547 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
46548 - static atomic_t shared_last_ino;
46549 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
46550 + static atomic_unchecked_t shared_last_ino;
46551 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
46552
46553 res = next - LAST_INO_BATCH;
46554 }
46555 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
46556 index eafb8d3..f423d37 100644
46557 --- a/fs/jffs2/erase.c
46558 +++ b/fs/jffs2/erase.c
46559 @@ -438,7 +438,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
46560 struct jffs2_unknown_node marker = {
46561 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
46562 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
46563 - .totlen = cpu_to_je32(c->cleanmarker_size)
46564 + .totlen = cpu_to_je32(c->cleanmarker_size),
46565 + .hdr_crc = cpu_to_je32(0)
46566 };
46567
46568 jffs2_prealloc_raw_node_refs(c, jeb, 1);
46569 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
46570 index 30e8f47..21f600c 100644
46571 --- a/fs/jffs2/wbuf.c
46572 +++ b/fs/jffs2/wbuf.c
46573 @@ -1012,7 +1012,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
46574 {
46575 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
46576 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
46577 - .totlen = constant_cpu_to_je32(8)
46578 + .totlen = constant_cpu_to_je32(8),
46579 + .hdr_crc = constant_cpu_to_je32(0)
46580 };
46581
46582 /*
46583 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
46584 index 682bca6..86b8e6e 100644
46585 --- a/fs/jfs/super.c
46586 +++ b/fs/jfs/super.c
46587 @@ -801,7 +801,7 @@ static int __init init_jfs_fs(void)
46588
46589 jfs_inode_cachep =
46590 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
46591 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
46592 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
46593 init_once);
46594 if (jfs_inode_cachep == NULL)
46595 return -ENOMEM;
46596 diff --git a/fs/libfs.c b/fs/libfs.c
46597 index 5b2dbb3..7442d54 100644
46598 --- a/fs/libfs.c
46599 +++ b/fs/libfs.c
46600 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
46601
46602 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
46603 struct dentry *next;
46604 + char d_name[sizeof(next->d_iname)];
46605 + const unsigned char *name;
46606 +
46607 next = list_entry(p, struct dentry, d_u.d_child);
46608 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
46609 if (!simple_positive(next)) {
46610 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
46611
46612 spin_unlock(&next->d_lock);
46613 spin_unlock(&dentry->d_lock);
46614 - if (filldir(dirent, next->d_name.name,
46615 + name = next->d_name.name;
46616 + if (name == next->d_iname) {
46617 + memcpy(d_name, name, next->d_name.len);
46618 + name = d_name;
46619 + }
46620 + if (filldir(dirent, name,
46621 next->d_name.len, filp->f_pos,
46622 next->d_inode->i_ino,
46623 dt_type(next->d_inode)) < 0)
46624 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
46625 index 8392cb8..80d6193 100644
46626 --- a/fs/lockd/clntproc.c
46627 +++ b/fs/lockd/clntproc.c
46628 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
46629 /*
46630 * Cookie counter for NLM requests
46631 */
46632 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
46633 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
46634
46635 void nlmclnt_next_cookie(struct nlm_cookie *c)
46636 {
46637 - u32 cookie = atomic_inc_return(&nlm_cookie);
46638 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
46639
46640 memcpy(c->data, &cookie, 4);
46641 c->len=4;
46642 diff --git a/fs/locks.c b/fs/locks.c
46643 index 0d68f1f..f216b79 100644
46644 --- a/fs/locks.c
46645 +++ b/fs/locks.c
46646 @@ -2075,16 +2075,16 @@ void locks_remove_flock(struct file *filp)
46647 return;
46648
46649 if (filp->f_op && filp->f_op->flock) {
46650 - struct file_lock fl = {
46651 + struct file_lock flock = {
46652 .fl_pid = current->tgid,
46653 .fl_file = filp,
46654 .fl_flags = FL_FLOCK,
46655 .fl_type = F_UNLCK,
46656 .fl_end = OFFSET_MAX,
46657 };
46658 - filp->f_op->flock(filp, F_SETLKW, &fl);
46659 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
46660 - fl.fl_ops->fl_release_private(&fl);
46661 + filp->f_op->flock(filp, F_SETLKW, &flock);
46662 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
46663 + flock.fl_ops->fl_release_private(&flock);
46664 }
46665
46666 lock_flocks();
46667 diff --git a/fs/namei.c b/fs/namei.c
46668 index 46ea9cc..c7cf3a3 100644
46669 --- a/fs/namei.c
46670 +++ b/fs/namei.c
46671 @@ -278,16 +278,32 @@ int generic_permission(struct inode *inode, int mask)
46672 if (ret != -EACCES)
46673 return ret;
46674
46675 +#ifdef CONFIG_GRKERNSEC
46676 + /* we'll block if we have to log due to a denied capability use */
46677 + if (mask & MAY_NOT_BLOCK)
46678 + return -ECHILD;
46679 +#endif
46680 +
46681 if (S_ISDIR(inode->i_mode)) {
46682 /* DACs are overridable for directories */
46683 - if (ns_capable(inode_userns(inode), CAP_DAC_OVERRIDE))
46684 - return 0;
46685 if (!(mask & MAY_WRITE))
46686 - if (ns_capable(inode_userns(inode), CAP_DAC_READ_SEARCH))
46687 + if (ns_capable_nolog(inode_userns(inode), CAP_DAC_OVERRIDE) ||
46688 + ns_capable(inode_userns(inode), CAP_DAC_READ_SEARCH))
46689 return 0;
46690 + if (ns_capable(inode_userns(inode), CAP_DAC_OVERRIDE))
46691 + return 0;
46692 return -EACCES;
46693 }
46694 /*
46695 + * Searching includes executable on directories, else just read.
46696 + */
46697 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
46698 + if (mask == MAY_READ)
46699 + if (ns_capable_nolog(inode_userns(inode), CAP_DAC_OVERRIDE) ||
46700 + ns_capable(inode_userns(inode), CAP_DAC_READ_SEARCH))
46701 + return 0;
46702 +
46703 + /*
46704 * Read/write DACs are always overridable.
46705 * Executable DACs are overridable when there is
46706 * at least one exec bit set.
46707 @@ -296,14 +312,6 @@ int generic_permission(struct inode *inode, int mask)
46708 if (ns_capable(inode_userns(inode), CAP_DAC_OVERRIDE))
46709 return 0;
46710
46711 - /*
46712 - * Searching includes executable on directories, else just read.
46713 - */
46714 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
46715 - if (mask == MAY_READ)
46716 - if (ns_capable(inode_userns(inode), CAP_DAC_READ_SEARCH))
46717 - return 0;
46718 -
46719 return -EACCES;
46720 }
46721
46722 @@ -652,11 +660,19 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
46723 return error;
46724 }
46725
46726 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
46727 + dentry->d_inode, dentry, nd->path.mnt)) {
46728 + error = -EACCES;
46729 + *p = ERR_PTR(error); /* no ->put_link(), please */
46730 + path_put(&nd->path);
46731 + return error;
46732 + }
46733 +
46734 nd->last_type = LAST_BIND;
46735 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
46736 error = PTR_ERR(*p);
46737 if (!IS_ERR(*p)) {
46738 - char *s = nd_get_link(nd);
46739 + const char *s = nd_get_link(nd);
46740 error = 0;
46741 if (s)
46742 error = __vfs_follow_link(nd, s);
46743 @@ -1650,6 +1666,21 @@ static int path_lookupat(int dfd, const char *name,
46744 if (!err)
46745 err = complete_walk(nd);
46746
46747 + if (!(nd->flags & LOOKUP_PARENT)) {
46748 +#ifdef CONFIG_GRKERNSEC
46749 + if (flags & LOOKUP_RCU) {
46750 + if (!err)
46751 + path_put(&nd->path);
46752 + err = -ECHILD;
46753 + } else
46754 +#endif
46755 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
46756 + if (!err)
46757 + path_put(&nd->path);
46758 + err = -ENOENT;
46759 + }
46760 + }
46761 +
46762 if (!err && nd->flags & LOOKUP_DIRECTORY) {
46763 if (!nd->inode->i_op->lookup) {
46764 path_put(&nd->path);
46765 @@ -1677,6 +1708,15 @@ static int do_path_lookup(int dfd, const char *name,
46766 retval = path_lookupat(dfd, name, flags | LOOKUP_REVAL, nd);
46767
46768 if (likely(!retval)) {
46769 + if (*name != '/' && nd->path.dentry && nd->inode) {
46770 +#ifdef CONFIG_GRKERNSEC
46771 + if (flags & LOOKUP_RCU)
46772 + return -ECHILD;
46773 +#endif
46774 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt))
46775 + return -ENOENT;
46776 + }
46777 +
46778 if (unlikely(!audit_dummy_context())) {
46779 if (nd->path.dentry && nd->inode)
46780 audit_inode(name, nd->path.dentry);
46781 @@ -2071,6 +2111,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
46782 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
46783 return -EPERM;
46784
46785 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
46786 + return -EPERM;
46787 + if (gr_handle_rawio(inode))
46788 + return -EPERM;
46789 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
46790 + return -EACCES;
46791 +
46792 return 0;
46793 }
46794
46795 @@ -2132,6 +2179,16 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
46796 error = complete_walk(nd);
46797 if (error)
46798 return ERR_PTR(error);
46799 +#ifdef CONFIG_GRKERNSEC
46800 + if (nd->flags & LOOKUP_RCU) {
46801 + error = -ECHILD;
46802 + goto exit;
46803 + }
46804 +#endif
46805 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
46806 + error = -ENOENT;
46807 + goto exit;
46808 + }
46809 audit_inode(pathname, nd->path.dentry);
46810 if (open_flag & O_CREAT) {
46811 error = -EISDIR;
46812 @@ -2142,6 +2199,16 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
46813 error = complete_walk(nd);
46814 if (error)
46815 return ERR_PTR(error);
46816 +#ifdef CONFIG_GRKERNSEC
46817 + if (nd->flags & LOOKUP_RCU) {
46818 + error = -ECHILD;
46819 + goto exit;
46820 + }
46821 +#endif
46822 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
46823 + error = -ENOENT;
46824 + goto exit;
46825 + }
46826 audit_inode(pathname, dir);
46827 goto ok;
46828 }
46829 @@ -2163,6 +2230,16 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
46830 error = complete_walk(nd);
46831 if (error)
46832 return ERR_PTR(error);
46833 +#ifdef CONFIG_GRKERNSEC
46834 + if (nd->flags & LOOKUP_RCU) {
46835 + error = -ECHILD;
46836 + goto exit;
46837 + }
46838 +#endif
46839 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
46840 + error = -ENOENT;
46841 + goto exit;
46842 + }
46843
46844 error = -ENOTDIR;
46845 if (nd->flags & LOOKUP_DIRECTORY) {
46846 @@ -2203,6 +2280,12 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
46847 /* Negative dentry, just create the file */
46848 if (!dentry->d_inode) {
46849 umode_t mode = op->mode;
46850 +
46851 + if (!gr_acl_handle_creat(path->dentry, nd->path.dentry, path->mnt, open_flag, acc_mode, mode)) {
46852 + error = -EACCES;
46853 + goto exit_mutex_unlock;
46854 + }
46855 +
46856 if (!IS_POSIXACL(dir->d_inode))
46857 mode &= ~current_umask();
46858 /*
46859 @@ -2226,6 +2309,8 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
46860 error = vfs_create(dir->d_inode, dentry, mode, nd);
46861 if (error)
46862 goto exit_mutex_unlock;
46863 + else
46864 + gr_handle_create(path->dentry, path->mnt);
46865 mutex_unlock(&dir->d_inode->i_mutex);
46866 dput(nd->path.dentry);
46867 nd->path.dentry = dentry;
46868 @@ -2235,6 +2320,19 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
46869 /*
46870 * It already exists.
46871 */
46872 +
46873 + if (!gr_acl_handle_hidden_file(dentry, nd->path.mnt)) {
46874 + error = -ENOENT;
46875 + goto exit_mutex_unlock;
46876 + }
46877 +
46878 + /* only check if O_CREAT is specified, all other checks need to go
46879 + into may_open */
46880 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
46881 + error = -EACCES;
46882 + goto exit_mutex_unlock;
46883 + }
46884 +
46885 mutex_unlock(&dir->d_inode->i_mutex);
46886 audit_inode(pathname, path->dentry);
46887
46888 @@ -2447,6 +2545,11 @@ struct dentry *kern_path_create(int dfd, const char *pathname, struct path *path
46889 *path = nd.path;
46890 return dentry;
46891 eexist:
46892 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
46893 + dput(dentry);
46894 + dentry = ERR_PTR(-ENOENT);
46895 + goto fail;
46896 + }
46897 dput(dentry);
46898 dentry = ERR_PTR(-EEXIST);
46899 fail:
46900 @@ -2469,6 +2572,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname, struct pat
46901 }
46902 EXPORT_SYMBOL(user_path_create);
46903
46904 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, char **to, int is_dir)
46905 +{
46906 + char *tmp = getname(pathname);
46907 + struct dentry *res;
46908 + if (IS_ERR(tmp))
46909 + return ERR_CAST(tmp);
46910 + res = kern_path_create(dfd, tmp, path, is_dir);
46911 + if (IS_ERR(res))
46912 + putname(tmp);
46913 + else
46914 + *to = tmp;
46915 + return res;
46916 +}
46917 +
46918 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
46919 {
46920 int error = may_create(dir, dentry);
46921 @@ -2536,6 +2653,17 @@ SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, filename, umode_t, mode,
46922 error = mnt_want_write(path.mnt);
46923 if (error)
46924 goto out_dput;
46925 +
46926 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
46927 + error = -EPERM;
46928 + goto out_drop_write;
46929 + }
46930 +
46931 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
46932 + error = -EACCES;
46933 + goto out_drop_write;
46934 + }
46935 +
46936 error = security_path_mknod(&path, dentry, mode, dev);
46937 if (error)
46938 goto out_drop_write;
46939 @@ -2553,6 +2681,9 @@ SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, filename, umode_t, mode,
46940 }
46941 out_drop_write:
46942 mnt_drop_write(path.mnt);
46943 +
46944 + if (!error)
46945 + gr_handle_create(dentry, path.mnt);
46946 out_dput:
46947 dput(dentry);
46948 mutex_unlock(&path.dentry->d_inode->i_mutex);
46949 @@ -2602,12 +2733,21 @@ SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, umode_t, mode)
46950 error = mnt_want_write(path.mnt);
46951 if (error)
46952 goto out_dput;
46953 +
46954 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
46955 + error = -EACCES;
46956 + goto out_drop_write;
46957 + }
46958 +
46959 error = security_path_mkdir(&path, dentry, mode);
46960 if (error)
46961 goto out_drop_write;
46962 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
46963 out_drop_write:
46964 mnt_drop_write(path.mnt);
46965 +
46966 + if (!error)
46967 + gr_handle_create(dentry, path.mnt);
46968 out_dput:
46969 dput(dentry);
46970 mutex_unlock(&path.dentry->d_inode->i_mutex);
46971 @@ -2687,6 +2827,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
46972 char * name;
46973 struct dentry *dentry;
46974 struct nameidata nd;
46975 + ino_t saved_ino = 0;
46976 + dev_t saved_dev = 0;
46977
46978 error = user_path_parent(dfd, pathname, &nd, &name);
46979 if (error)
46980 @@ -2715,6 +2857,15 @@ static long do_rmdir(int dfd, const char __user *pathname)
46981 error = -ENOENT;
46982 goto exit3;
46983 }
46984 +
46985 + saved_ino = dentry->d_inode->i_ino;
46986 + saved_dev = gr_get_dev_from_dentry(dentry);
46987 +
46988 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
46989 + error = -EACCES;
46990 + goto exit3;
46991 + }
46992 +
46993 error = mnt_want_write(nd.path.mnt);
46994 if (error)
46995 goto exit3;
46996 @@ -2722,6 +2873,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
46997 if (error)
46998 goto exit4;
46999 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
47000 + if (!error && (saved_dev || saved_ino))
47001 + gr_handle_delete(saved_ino, saved_dev);
47002 exit4:
47003 mnt_drop_write(nd.path.mnt);
47004 exit3:
47005 @@ -2784,6 +2937,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
47006 struct dentry *dentry;
47007 struct nameidata nd;
47008 struct inode *inode = NULL;
47009 + ino_t saved_ino = 0;
47010 + dev_t saved_dev = 0;
47011
47012 error = user_path_parent(dfd, pathname, &nd, &name);
47013 if (error)
47014 @@ -2806,6 +2961,16 @@ static long do_unlinkat(int dfd, const char __user *pathname)
47015 if (!inode)
47016 goto slashes;
47017 ihold(inode);
47018 +
47019 + if (inode->i_nlink <= 1) {
47020 + saved_ino = inode->i_ino;
47021 + saved_dev = gr_get_dev_from_dentry(dentry);
47022 + }
47023 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
47024 + error = -EACCES;
47025 + goto exit2;
47026 + }
47027 +
47028 error = mnt_want_write(nd.path.mnt);
47029 if (error)
47030 goto exit2;
47031 @@ -2813,6 +2978,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
47032 if (error)
47033 goto exit3;
47034 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
47035 + if (!error && (saved_ino || saved_dev))
47036 + gr_handle_delete(saved_ino, saved_dev);
47037 exit3:
47038 mnt_drop_write(nd.path.mnt);
47039 exit2:
47040 @@ -2888,10 +3055,18 @@ SYSCALL_DEFINE3(symlinkat, const char __user *, oldname,
47041 error = mnt_want_write(path.mnt);
47042 if (error)
47043 goto out_dput;
47044 +
47045 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
47046 + error = -EACCES;
47047 + goto out_drop_write;
47048 + }
47049 +
47050 error = security_path_symlink(&path, dentry, from);
47051 if (error)
47052 goto out_drop_write;
47053 error = vfs_symlink(path.dentry->d_inode, dentry, from);
47054 + if (!error)
47055 + gr_handle_create(dentry, path.mnt);
47056 out_drop_write:
47057 mnt_drop_write(path.mnt);
47058 out_dput:
47059 @@ -2963,6 +3138,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
47060 {
47061 struct dentry *new_dentry;
47062 struct path old_path, new_path;
47063 + char *to = NULL;
47064 int how = 0;
47065 int error;
47066
47067 @@ -2986,7 +3162,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
47068 if (error)
47069 return error;
47070
47071 - new_dentry = user_path_create(newdfd, newname, &new_path, 0);
47072 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to, 0);
47073 error = PTR_ERR(new_dentry);
47074 if (IS_ERR(new_dentry))
47075 goto out;
47076 @@ -2997,13 +3173,30 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
47077 error = mnt_want_write(new_path.mnt);
47078 if (error)
47079 goto out_dput;
47080 +
47081 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
47082 + old_path.dentry->d_inode,
47083 + old_path.dentry->d_inode->i_mode, to)) {
47084 + error = -EACCES;
47085 + goto out_drop_write;
47086 + }
47087 +
47088 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
47089 + old_path.dentry, old_path.mnt, to)) {
47090 + error = -EACCES;
47091 + goto out_drop_write;
47092 + }
47093 +
47094 error = security_path_link(old_path.dentry, &new_path, new_dentry);
47095 if (error)
47096 goto out_drop_write;
47097 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
47098 + if (!error)
47099 + gr_handle_create(new_dentry, new_path.mnt);
47100 out_drop_write:
47101 mnt_drop_write(new_path.mnt);
47102 out_dput:
47103 + putname(to);
47104 dput(new_dentry);
47105 mutex_unlock(&new_path.dentry->d_inode->i_mutex);
47106 path_put(&new_path);
47107 @@ -3231,6 +3424,12 @@ SYSCALL_DEFINE4(renameat, int, olddfd, const char __user *, oldname,
47108 if (new_dentry == trap)
47109 goto exit5;
47110
47111 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
47112 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
47113 + to);
47114 + if (error)
47115 + goto exit5;
47116 +
47117 error = mnt_want_write(oldnd.path.mnt);
47118 if (error)
47119 goto exit5;
47120 @@ -3240,6 +3439,9 @@ SYSCALL_DEFINE4(renameat, int, olddfd, const char __user *, oldname,
47121 goto exit6;
47122 error = vfs_rename(old_dir->d_inode, old_dentry,
47123 new_dir->d_inode, new_dentry);
47124 + if (!error)
47125 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
47126 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
47127 exit6:
47128 mnt_drop_write(oldnd.path.mnt);
47129 exit5:
47130 @@ -3265,6 +3467,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
47131
47132 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
47133 {
47134 + char tmpbuf[64];
47135 + const char *newlink;
47136 int len;
47137
47138 len = PTR_ERR(link);
47139 @@ -3274,7 +3478,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
47140 len = strlen(link);
47141 if (len > (unsigned) buflen)
47142 len = buflen;
47143 - if (copy_to_user(buffer, link, len))
47144 +
47145 + if (len < sizeof(tmpbuf)) {
47146 + memcpy(tmpbuf, link, len);
47147 + newlink = tmpbuf;
47148 + } else
47149 + newlink = link;
47150 +
47151 + if (copy_to_user(buffer, newlink, len))
47152 len = -EFAULT;
47153 out:
47154 return len;
47155 diff --git a/fs/namespace.c b/fs/namespace.c
47156 index e608199..9609cb9 100644
47157 --- a/fs/namespace.c
47158 +++ b/fs/namespace.c
47159 @@ -1155,6 +1155,9 @@ static int do_umount(struct mount *mnt, int flags)
47160 if (!(sb->s_flags & MS_RDONLY))
47161 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
47162 up_write(&sb->s_umount);
47163 +
47164 + gr_log_remount(mnt->mnt_devname, retval);
47165 +
47166 return retval;
47167 }
47168
47169 @@ -1174,6 +1177,9 @@ static int do_umount(struct mount *mnt, int flags)
47170 br_write_unlock(vfsmount_lock);
47171 up_write(&namespace_sem);
47172 release_mounts(&umount_list);
47173 +
47174 + gr_log_unmount(mnt->mnt_devname, retval);
47175 +
47176 return retval;
47177 }
47178
47179 @@ -2175,6 +2181,16 @@ long do_mount(char *dev_name, char *dir_name, char *type_page,
47180 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
47181 MS_STRICTATIME);
47182
47183 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
47184 + retval = -EPERM;
47185 + goto dput_out;
47186 + }
47187 +
47188 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
47189 + retval = -EPERM;
47190 + goto dput_out;
47191 + }
47192 +
47193 if (flags & MS_REMOUNT)
47194 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
47195 data_page);
47196 @@ -2189,6 +2205,9 @@ long do_mount(char *dev_name, char *dir_name, char *type_page,
47197 dev_name, data_page);
47198 dput_out:
47199 path_put(&path);
47200 +
47201 + gr_log_mount(dev_name, dir_name, retval);
47202 +
47203 return retval;
47204 }
47205
47206 @@ -2470,6 +2489,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
47207 if (error)
47208 goto out2;
47209
47210 + if (gr_handle_chroot_pivot()) {
47211 + error = -EPERM;
47212 + goto out2;
47213 + }
47214 +
47215 get_fs_root(current->fs, &root);
47216 error = lock_mount(&old);
47217 if (error)
47218 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
47219 index f649fba..236bf92 100644
47220 --- a/fs/nfs/inode.c
47221 +++ b/fs/nfs/inode.c
47222 @@ -151,7 +151,7 @@ static void nfs_zap_caches_locked(struct inode *inode)
47223 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
47224 nfsi->attrtimeo_timestamp = jiffies;
47225
47226 - memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode)));
47227 + memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_I(inode)->cookieverf));
47228 if (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode))
47229 nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL|NFS_INO_REVAL_PAGECACHE;
47230 else
47231 @@ -1003,16 +1003,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
47232 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
47233 }
47234
47235 -static atomic_long_t nfs_attr_generation_counter;
47236 +static atomic_long_unchecked_t nfs_attr_generation_counter;
47237
47238 static unsigned long nfs_read_attr_generation_counter(void)
47239 {
47240 - return atomic_long_read(&nfs_attr_generation_counter);
47241 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
47242 }
47243
47244 unsigned long nfs_inc_attr_generation_counter(void)
47245 {
47246 - return atomic_long_inc_return(&nfs_attr_generation_counter);
47247 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
47248 }
47249
47250 void nfs_fattr_init(struct nfs_fattr *fattr)
47251 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
47252 index b96fe94..a4dbece 100644
47253 --- a/fs/nfsd/vfs.c
47254 +++ b/fs/nfsd/vfs.c
47255 @@ -925,7 +925,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
47256 } else {
47257 oldfs = get_fs();
47258 set_fs(KERNEL_DS);
47259 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
47260 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
47261 set_fs(oldfs);
47262 }
47263
47264 @@ -1029,7 +1029,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
47265
47266 /* Write the data. */
47267 oldfs = get_fs(); set_fs(KERNEL_DS);
47268 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &offset);
47269 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &offset);
47270 set_fs(oldfs);
47271 if (host_err < 0)
47272 goto out_nfserr;
47273 @@ -1564,7 +1564,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
47274 */
47275
47276 oldfs = get_fs(); set_fs(KERNEL_DS);
47277 - host_err = inode->i_op->readlink(dentry, buf, *lenp);
47278 + host_err = inode->i_op->readlink(dentry, (char __force_user *)buf, *lenp);
47279 set_fs(oldfs);
47280
47281 if (host_err < 0)
47282 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
47283 index 3568c8a..e0240d8 100644
47284 --- a/fs/notify/fanotify/fanotify_user.c
47285 +++ b/fs/notify/fanotify/fanotify_user.c
47286 @@ -278,7 +278,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
47287 goto out_close_fd;
47288
47289 ret = -EFAULT;
47290 - if (copy_to_user(buf, &fanotify_event_metadata,
47291 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
47292 + copy_to_user(buf, &fanotify_event_metadata,
47293 fanotify_event_metadata.event_len))
47294 goto out_kill_access_response;
47295
47296 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
47297 index ee18815..7aa5d01 100644
47298 --- a/fs/notify/notification.c
47299 +++ b/fs/notify/notification.c
47300 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
47301 * get set to 0 so it will never get 'freed'
47302 */
47303 static struct fsnotify_event *q_overflow_event;
47304 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
47305 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
47306
47307 /**
47308 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
47309 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
47310 */
47311 u32 fsnotify_get_cookie(void)
47312 {
47313 - return atomic_inc_return(&fsnotify_sync_cookie);
47314 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
47315 }
47316 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
47317
47318 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
47319 index 99e3610..02c1068 100644
47320 --- a/fs/ntfs/dir.c
47321 +++ b/fs/ntfs/dir.c
47322 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
47323 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
47324 ~(s64)(ndir->itype.index.block_size - 1)));
47325 /* Bounds checks. */
47326 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
47327 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
47328 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
47329 "inode 0x%lx or driver bug.", vdir->i_ino);
47330 goto err_out;
47331 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
47332 index c587e2d..3641eaa 100644
47333 --- a/fs/ntfs/file.c
47334 +++ b/fs/ntfs/file.c
47335 @@ -2229,6 +2229,6 @@ const struct inode_operations ntfs_file_inode_ops = {
47336 #endif /* NTFS_RW */
47337 };
47338
47339 -const struct file_operations ntfs_empty_file_ops = {};
47340 +const struct file_operations ntfs_empty_file_ops __read_only;
47341
47342 -const struct inode_operations ntfs_empty_inode_ops = {};
47343 +const struct inode_operations ntfs_empty_inode_ops __read_only;
47344 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
47345 index 210c352..a174f83 100644
47346 --- a/fs/ocfs2/localalloc.c
47347 +++ b/fs/ocfs2/localalloc.c
47348 @@ -1283,7 +1283,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
47349 goto bail;
47350 }
47351
47352 - atomic_inc(&osb->alloc_stats.moves);
47353 + atomic_inc_unchecked(&osb->alloc_stats.moves);
47354
47355 bail:
47356 if (handle)
47357 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
47358 index d355e6e..578d905 100644
47359 --- a/fs/ocfs2/ocfs2.h
47360 +++ b/fs/ocfs2/ocfs2.h
47361 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
47362
47363 struct ocfs2_alloc_stats
47364 {
47365 - atomic_t moves;
47366 - atomic_t local_data;
47367 - atomic_t bitmap_data;
47368 - atomic_t bg_allocs;
47369 - atomic_t bg_extends;
47370 + atomic_unchecked_t moves;
47371 + atomic_unchecked_t local_data;
47372 + atomic_unchecked_t bitmap_data;
47373 + atomic_unchecked_t bg_allocs;
47374 + atomic_unchecked_t bg_extends;
47375 };
47376
47377 enum ocfs2_local_alloc_state
47378 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
47379 index f169da4..9112253 100644
47380 --- a/fs/ocfs2/suballoc.c
47381 +++ b/fs/ocfs2/suballoc.c
47382 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
47383 mlog_errno(status);
47384 goto bail;
47385 }
47386 - atomic_inc(&osb->alloc_stats.bg_extends);
47387 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
47388
47389 /* You should never ask for this much metadata */
47390 BUG_ON(bits_wanted >
47391 @@ -2008,7 +2008,7 @@ int ocfs2_claim_metadata(handle_t *handle,
47392 mlog_errno(status);
47393 goto bail;
47394 }
47395 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
47396 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
47397
47398 *suballoc_loc = res.sr_bg_blkno;
47399 *suballoc_bit_start = res.sr_bit_offset;
47400 @@ -2172,7 +2172,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
47401 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
47402 res->sr_bits);
47403
47404 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
47405 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
47406
47407 BUG_ON(res->sr_bits != 1);
47408
47409 @@ -2214,7 +2214,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
47410 mlog_errno(status);
47411 goto bail;
47412 }
47413 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
47414 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
47415
47416 BUG_ON(res.sr_bits != 1);
47417
47418 @@ -2318,7 +2318,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
47419 cluster_start,
47420 num_clusters);
47421 if (!status)
47422 - atomic_inc(&osb->alloc_stats.local_data);
47423 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
47424 } else {
47425 if (min_clusters > (osb->bitmap_cpg - 1)) {
47426 /* The only paths asking for contiguousness
47427 @@ -2344,7 +2344,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
47428 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
47429 res.sr_bg_blkno,
47430 res.sr_bit_offset);
47431 - atomic_inc(&osb->alloc_stats.bitmap_data);
47432 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
47433 *num_clusters = res.sr_bits;
47434 }
47435 }
47436 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
47437 index 604e12c..8426483 100644
47438 --- a/fs/ocfs2/super.c
47439 +++ b/fs/ocfs2/super.c
47440 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
47441 "%10s => GlobalAllocs: %d LocalAllocs: %d "
47442 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
47443 "Stats",
47444 - atomic_read(&osb->alloc_stats.bitmap_data),
47445 - atomic_read(&osb->alloc_stats.local_data),
47446 - atomic_read(&osb->alloc_stats.bg_allocs),
47447 - atomic_read(&osb->alloc_stats.moves),
47448 - atomic_read(&osb->alloc_stats.bg_extends));
47449 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
47450 + atomic_read_unchecked(&osb->alloc_stats.local_data),
47451 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
47452 + atomic_read_unchecked(&osb->alloc_stats.moves),
47453 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
47454
47455 out += snprintf(buf + out, len - out,
47456 "%10s => State: %u Descriptor: %llu Size: %u bits "
47457 @@ -2117,11 +2117,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
47458 spin_lock_init(&osb->osb_xattr_lock);
47459 ocfs2_init_steal_slots(osb);
47460
47461 - atomic_set(&osb->alloc_stats.moves, 0);
47462 - atomic_set(&osb->alloc_stats.local_data, 0);
47463 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
47464 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
47465 - atomic_set(&osb->alloc_stats.bg_extends, 0);
47466 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
47467 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
47468 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
47469 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
47470 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
47471
47472 /* Copy the blockcheck stats from the superblock probe */
47473 osb->osb_ecc_stats = *stats;
47474 diff --git a/fs/ocfs2/symlink.c b/fs/ocfs2/symlink.c
47475 index 5d22872..523db20 100644
47476 --- a/fs/ocfs2/symlink.c
47477 +++ b/fs/ocfs2/symlink.c
47478 @@ -142,7 +142,7 @@ bail:
47479
47480 static void ocfs2_fast_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
47481 {
47482 - char *link = nd_get_link(nd);
47483 + const char *link = nd_get_link(nd);
47484 if (!IS_ERR(link))
47485 kfree(link);
47486 }
47487 diff --git a/fs/open.c b/fs/open.c
47488 index 77becc0..aad7bd9 100644
47489 --- a/fs/open.c
47490 +++ b/fs/open.c
47491 @@ -112,6 +112,10 @@ static long do_sys_truncate(const char __user *pathname, loff_t length)
47492 error = locks_verify_truncate(inode, NULL, length);
47493 if (!error)
47494 error = security_path_truncate(&path);
47495 +
47496 + if (!error && !gr_acl_handle_truncate(path.dentry, path.mnt))
47497 + error = -EACCES;
47498 +
47499 if (!error)
47500 error = do_truncate(path.dentry, length, 0, NULL);
47501
47502 @@ -358,6 +362,9 @@ SYSCALL_DEFINE3(faccessat, int, dfd, const char __user *, filename, int, mode)
47503 if (__mnt_is_readonly(path.mnt))
47504 res = -EROFS;
47505
47506 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
47507 + res = -EACCES;
47508 +
47509 out_path_release:
47510 path_put(&path);
47511 out:
47512 @@ -384,6 +391,8 @@ SYSCALL_DEFINE1(chdir, const char __user *, filename)
47513 if (error)
47514 goto dput_and_out;
47515
47516 + gr_log_chdir(path.dentry, path.mnt);
47517 +
47518 set_fs_pwd(current->fs, &path);
47519
47520 dput_and_out:
47521 @@ -410,6 +419,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
47522 goto out_putf;
47523
47524 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
47525 +
47526 + if (!error && !gr_chroot_fchdir(file->f_path.dentry, file->f_path.mnt))
47527 + error = -EPERM;
47528 +
47529 + if (!error)
47530 + gr_log_chdir(file->f_path.dentry, file->f_path.mnt);
47531 +
47532 if (!error)
47533 set_fs_pwd(current->fs, &file->f_path);
47534 out_putf:
47535 @@ -438,7 +454,13 @@ SYSCALL_DEFINE1(chroot, const char __user *, filename)
47536 if (error)
47537 goto dput_and_out;
47538
47539 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
47540 + goto dput_and_out;
47541 +
47542 set_fs_root(current->fs, &path);
47543 +
47544 + gr_handle_chroot_chdir(&path);
47545 +
47546 error = 0;
47547 dput_and_out:
47548 path_put(&path);
47549 @@ -456,6 +478,16 @@ static int chmod_common(struct path *path, umode_t mode)
47550 if (error)
47551 return error;
47552 mutex_lock(&inode->i_mutex);
47553 +
47554 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
47555 + error = -EACCES;
47556 + goto out_unlock;
47557 + }
47558 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
47559 + error = -EACCES;
47560 + goto out_unlock;
47561 + }
47562 +
47563 error = security_path_chmod(path, mode);
47564 if (error)
47565 goto out_unlock;
47566 @@ -506,6 +538,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
47567 int error;
47568 struct iattr newattrs;
47569
47570 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
47571 + return -EACCES;
47572 +
47573 newattrs.ia_valid = ATTR_CTIME;
47574 if (user != (uid_t) -1) {
47575 newattrs.ia_valid |= ATTR_UID;
47576 diff --git a/fs/pipe.c b/fs/pipe.c
47577 index 82e651b..8a68573 100644
47578 --- a/fs/pipe.c
47579 +++ b/fs/pipe.c
47580 @@ -437,9 +437,9 @@ redo:
47581 }
47582 if (bufs) /* More to do? */
47583 continue;
47584 - if (!pipe->writers)
47585 + if (!atomic_read(&pipe->writers))
47586 break;
47587 - if (!pipe->waiting_writers) {
47588 + if (!atomic_read(&pipe->waiting_writers)) {
47589 /* syscall merging: Usually we must not sleep
47590 * if O_NONBLOCK is set, or if we got some data.
47591 * But if a writer sleeps in kernel space, then
47592 @@ -503,7 +503,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
47593 mutex_lock(&inode->i_mutex);
47594 pipe = inode->i_pipe;
47595
47596 - if (!pipe->readers) {
47597 + if (!atomic_read(&pipe->readers)) {
47598 send_sig(SIGPIPE, current, 0);
47599 ret = -EPIPE;
47600 goto out;
47601 @@ -552,7 +552,7 @@ redo1:
47602 for (;;) {
47603 int bufs;
47604
47605 - if (!pipe->readers) {
47606 + if (!atomic_read(&pipe->readers)) {
47607 send_sig(SIGPIPE, current, 0);
47608 if (!ret)
47609 ret = -EPIPE;
47610 @@ -643,9 +643,9 @@ redo2:
47611 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
47612 do_wakeup = 0;
47613 }
47614 - pipe->waiting_writers++;
47615 + atomic_inc(&pipe->waiting_writers);
47616 pipe_wait(pipe);
47617 - pipe->waiting_writers--;
47618 + atomic_dec(&pipe->waiting_writers);
47619 }
47620 out:
47621 mutex_unlock(&inode->i_mutex);
47622 @@ -712,7 +712,7 @@ pipe_poll(struct file *filp, poll_table *wait)
47623 mask = 0;
47624 if (filp->f_mode & FMODE_READ) {
47625 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
47626 - if (!pipe->writers && filp->f_version != pipe->w_counter)
47627 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
47628 mask |= POLLHUP;
47629 }
47630
47631 @@ -722,7 +722,7 @@ pipe_poll(struct file *filp, poll_table *wait)
47632 * Most Unices do not set POLLERR for FIFOs but on Linux they
47633 * behave exactly like pipes for poll().
47634 */
47635 - if (!pipe->readers)
47636 + if (!atomic_read(&pipe->readers))
47637 mask |= POLLERR;
47638 }
47639
47640 @@ -736,10 +736,10 @@ pipe_release(struct inode *inode, int decr, int decw)
47641
47642 mutex_lock(&inode->i_mutex);
47643 pipe = inode->i_pipe;
47644 - pipe->readers -= decr;
47645 - pipe->writers -= decw;
47646 + atomic_sub(decr, &pipe->readers);
47647 + atomic_sub(decw, &pipe->writers);
47648
47649 - if (!pipe->readers && !pipe->writers) {
47650 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers)) {
47651 free_pipe_info(inode);
47652 } else {
47653 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
47654 @@ -829,7 +829,7 @@ pipe_read_open(struct inode *inode, struct file *filp)
47655
47656 if (inode->i_pipe) {
47657 ret = 0;
47658 - inode->i_pipe->readers++;
47659 + atomic_inc(&inode->i_pipe->readers);
47660 }
47661
47662 mutex_unlock(&inode->i_mutex);
47663 @@ -846,7 +846,7 @@ pipe_write_open(struct inode *inode, struct file *filp)
47664
47665 if (inode->i_pipe) {
47666 ret = 0;
47667 - inode->i_pipe->writers++;
47668 + atomic_inc(&inode->i_pipe->writers);
47669 }
47670
47671 mutex_unlock(&inode->i_mutex);
47672 @@ -864,9 +864,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
47673 if (inode->i_pipe) {
47674 ret = 0;
47675 if (filp->f_mode & FMODE_READ)
47676 - inode->i_pipe->readers++;
47677 + atomic_inc(&inode->i_pipe->readers);
47678 if (filp->f_mode & FMODE_WRITE)
47679 - inode->i_pipe->writers++;
47680 + atomic_inc(&inode->i_pipe->writers);
47681 }
47682
47683 mutex_unlock(&inode->i_mutex);
47684 @@ -958,7 +958,7 @@ void free_pipe_info(struct inode *inode)
47685 inode->i_pipe = NULL;
47686 }
47687
47688 -static struct vfsmount *pipe_mnt __read_mostly;
47689 +struct vfsmount *pipe_mnt __read_mostly;
47690
47691 /*
47692 * pipefs_dname() is called from d_path().
47693 @@ -988,7 +988,8 @@ static struct inode * get_pipe_inode(void)
47694 goto fail_iput;
47695 inode->i_pipe = pipe;
47696
47697 - pipe->readers = pipe->writers = 1;
47698 + atomic_set(&pipe->readers, 1);
47699 + atomic_set(&pipe->writers, 1);
47700 inode->i_fop = &rdwr_pipefifo_fops;
47701
47702 /*
47703 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
47704 index 15af622..0e9f4467 100644
47705 --- a/fs/proc/Kconfig
47706 +++ b/fs/proc/Kconfig
47707 @@ -30,12 +30,12 @@ config PROC_FS
47708
47709 config PROC_KCORE
47710 bool "/proc/kcore support" if !ARM
47711 - depends on PROC_FS && MMU
47712 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
47713
47714 config PROC_VMCORE
47715 bool "/proc/vmcore support"
47716 - depends on PROC_FS && CRASH_DUMP
47717 - default y
47718 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
47719 + default n
47720 help
47721 Exports the dump image of crashed kernel in ELF format.
47722
47723 @@ -59,8 +59,8 @@ config PROC_SYSCTL
47724 limited in memory.
47725
47726 config PROC_PAGE_MONITOR
47727 - default y
47728 - depends on PROC_FS && MMU
47729 + default n
47730 + depends on PROC_FS && MMU && !GRKERNSEC
47731 bool "Enable /proc page monitoring" if EXPERT
47732 help
47733 Various /proc files exist to monitor process memory utilization:
47734 diff --git a/fs/proc/array.c b/fs/proc/array.c
47735 index c602b8d..a7de642 100644
47736 --- a/fs/proc/array.c
47737 +++ b/fs/proc/array.c
47738 @@ -60,6 +60,7 @@
47739 #include <linux/tty.h>
47740 #include <linux/string.h>
47741 #include <linux/mman.h>
47742 +#include <linux/grsecurity.h>
47743 #include <linux/proc_fs.h>
47744 #include <linux/ioport.h>
47745 #include <linux/uaccess.h>
47746 @@ -337,6 +338,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
47747 seq_putc(m, '\n');
47748 }
47749
47750 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
47751 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
47752 +{
47753 + if (p->mm)
47754 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
47755 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
47756 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
47757 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
47758 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
47759 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
47760 + else
47761 + seq_printf(m, "PaX:\t-----\n");
47762 +}
47763 +#endif
47764 +
47765 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
47766 struct pid *pid, struct task_struct *task)
47767 {
47768 @@ -354,9 +370,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
47769 task_cpus_allowed(m, task);
47770 cpuset_task_status_allowed(m, task);
47771 task_context_switch_counts(m, task);
47772 +
47773 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
47774 + task_pax(m, task);
47775 +#endif
47776 +
47777 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
47778 + task_grsec_rbac(m, task);
47779 +#endif
47780 +
47781 return 0;
47782 }
47783
47784 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
47785 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
47786 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
47787 + _mm->pax_flags & MF_PAX_SEGMEXEC))
47788 +#endif
47789 +
47790 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
47791 struct pid *pid, struct task_struct *task, int whole)
47792 {
47793 @@ -378,6 +409,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
47794 char tcomm[sizeof(task->comm)];
47795 unsigned long flags;
47796
47797 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
47798 + if (current->exec_id != m->exec_id) {
47799 + gr_log_badprocpid("stat");
47800 + return 0;
47801 + }
47802 +#endif
47803 +
47804 state = *get_task_state(task);
47805 vsize = eip = esp = 0;
47806 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
47807 @@ -449,6 +487,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
47808 gtime = task->gtime;
47809 }
47810
47811 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
47812 + if (PAX_RAND_FLAGS(mm)) {
47813 + eip = 0;
47814 + esp = 0;
47815 + wchan = 0;
47816 + }
47817 +#endif
47818 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47819 + wchan = 0;
47820 + eip =0;
47821 + esp =0;
47822 +#endif
47823 +
47824 /* scale priority and nice values from timeslices to -20..20 */
47825 /* to make it look like a "normal" Unix priority/nice value */
47826 priority = task_prio(task);
47827 @@ -489,9 +540,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
47828 vsize,
47829 mm ? get_mm_rss(mm) : 0,
47830 rsslim,
47831 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
47832 + PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0),
47833 + PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0),
47834 + PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0),
47835 +#else
47836 mm ? (permitted ? mm->start_code : 1) : 0,
47837 mm ? (permitted ? mm->end_code : 1) : 0,
47838 (permitted && mm) ? mm->start_stack : 0,
47839 +#endif
47840 esp,
47841 eip,
47842 /* The signal information here is obsolete.
47843 @@ -536,8 +593,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
47844 struct pid *pid, struct task_struct *task)
47845 {
47846 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
47847 - struct mm_struct *mm = get_task_mm(task);
47848 + struct mm_struct *mm;
47849
47850 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
47851 + if (current->exec_id != m->exec_id) {
47852 + gr_log_badprocpid("statm");
47853 + return 0;
47854 + }
47855 +#endif
47856 + mm = get_task_mm(task);
47857 if (mm) {
47858 size = task_statm(mm, &shared, &text, &data, &resident);
47859 mmput(mm);
47860 @@ -547,3 +611,18 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
47861
47862 return 0;
47863 }
47864 +
47865 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
47866 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
47867 +{
47868 + u32 curr_ip = 0;
47869 + unsigned long flags;
47870 +
47871 + if (lock_task_sighand(task, &flags)) {
47872 + curr_ip = task->signal->curr_ip;
47873 + unlock_task_sighand(task, &flags);
47874 + }
47875 +
47876 + return sprintf(buffer, "%pI4\n", &curr_ip);
47877 +}
47878 +#endif
47879 diff --git a/fs/proc/base.c b/fs/proc/base.c
47880 index d4548dd..d101f84 100644
47881 --- a/fs/proc/base.c
47882 +++ b/fs/proc/base.c
47883 @@ -109,6 +109,14 @@ struct pid_entry {
47884 union proc_op op;
47885 };
47886
47887 +struct getdents_callback {
47888 + struct linux_dirent __user * current_dir;
47889 + struct linux_dirent __user * previous;
47890 + struct file * file;
47891 + int count;
47892 + int error;
47893 +};
47894 +
47895 #define NOD(NAME, MODE, IOP, FOP, OP) { \
47896 .name = (NAME), \
47897 .len = sizeof(NAME) - 1, \
47898 @@ -213,6 +221,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
47899 if (!mm->arg_end)
47900 goto out_mm; /* Shh! No looking before we're done */
47901
47902 + if (gr_acl_handle_procpidmem(task))
47903 + goto out_mm;
47904 +
47905 len = mm->arg_end - mm->arg_start;
47906
47907 if (len > PAGE_SIZE)
47908 @@ -240,12 +251,28 @@ out:
47909 return res;
47910 }
47911
47912 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
47913 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
47914 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
47915 + _mm->pax_flags & MF_PAX_SEGMEXEC))
47916 +#endif
47917 +
47918 static int proc_pid_auxv(struct task_struct *task, char *buffer)
47919 {
47920 struct mm_struct *mm = mm_for_maps(task);
47921 int res = PTR_ERR(mm);
47922 if (mm && !IS_ERR(mm)) {
47923 unsigned int nwords = 0;
47924 +
47925 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
47926 + /* allow if we're currently ptracing this task */
47927 + if (PAX_RAND_FLAGS(mm) &&
47928 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
47929 + mmput(mm);
47930 + return 0;
47931 + }
47932 +#endif
47933 +
47934 do {
47935 nwords += 2;
47936 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
47937 @@ -259,7 +286,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
47938 }
47939
47940
47941 -#ifdef CONFIG_KALLSYMS
47942 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
47943 /*
47944 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
47945 * Returns the resolved symbol. If that fails, simply return the address.
47946 @@ -298,7 +325,7 @@ static void unlock_trace(struct task_struct *task)
47947 mutex_unlock(&task->signal->cred_guard_mutex);
47948 }
47949
47950 -#ifdef CONFIG_STACKTRACE
47951 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
47952
47953 #define MAX_STACK_TRACE_DEPTH 64
47954
47955 @@ -489,7 +516,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
47956 return count;
47957 }
47958
47959 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
47960 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
47961 static int proc_pid_syscall(struct task_struct *task, char *buffer)
47962 {
47963 long nr;
47964 @@ -518,7 +545,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
47965 /************************************************************************/
47966
47967 /* permission checks */
47968 -static int proc_fd_access_allowed(struct inode *inode)
47969 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
47970 {
47971 struct task_struct *task;
47972 int allowed = 0;
47973 @@ -528,7 +555,10 @@ static int proc_fd_access_allowed(struct inode *inode)
47974 */
47975 task = get_proc_task(inode);
47976 if (task) {
47977 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
47978 + if (log)
47979 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
47980 + else
47981 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
47982 put_task_struct(task);
47983 }
47984 return allowed;
47985 @@ -566,10 +596,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
47986 struct task_struct *task,
47987 int hide_pid_min)
47988 {
47989 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
47990 + return false;
47991 +
47992 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
47993 + rcu_read_lock();
47994 + {
47995 + const struct cred *tmpcred = current_cred();
47996 + const struct cred *cred = __task_cred(task);
47997 +
47998 + if (!tmpcred->uid || (tmpcred->uid == cred->uid)
47999 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
48000 + || in_group_p(CONFIG_GRKERNSEC_PROC_GID)
48001 +#endif
48002 + ) {
48003 + rcu_read_unlock();
48004 + return true;
48005 + }
48006 + }
48007 + rcu_read_unlock();
48008 +
48009 + if (!pid->hide_pid)
48010 + return false;
48011 +#endif
48012 +
48013 if (pid->hide_pid < hide_pid_min)
48014 return true;
48015 if (in_group_p(pid->pid_gid))
48016 return true;
48017 +
48018 return ptrace_may_access(task, PTRACE_MODE_READ);
48019 }
48020
48021 @@ -587,7 +642,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
48022 put_task_struct(task);
48023
48024 if (!has_perms) {
48025 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
48026 + {
48027 +#else
48028 if (pid->hide_pid == 2) {
48029 +#endif
48030 /*
48031 * Let's make getdents(), stat(), and open()
48032 * consistent with each other. If a process
48033 @@ -702,6 +761,10 @@ static int mem_open(struct inode* inode, struct file* file)
48034 file->f_mode |= FMODE_UNSIGNED_OFFSET;
48035 file->private_data = mm;
48036
48037 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
48038 + file->f_version = current->exec_id;
48039 +#endif
48040 +
48041 return 0;
48042 }
48043
48044 @@ -713,6 +776,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
48045 ssize_t copied;
48046 char *page;
48047
48048 +#ifdef CONFIG_GRKERNSEC
48049 + if (write)
48050 + return -EPERM;
48051 +#endif
48052 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
48053 + if (file->f_version != current->exec_id) {
48054 + gr_log_badprocpid("mem");
48055 + return 0;
48056 + }
48057 +#endif
48058 +
48059 if (!mm)
48060 return 0;
48061
48062 @@ -813,6 +887,9 @@ static ssize_t environ_read(struct file *file, char __user *buf,
48063 if (!task)
48064 goto out_no_task;
48065
48066 + if (gr_acl_handle_procpidmem(task))
48067 + goto out;
48068 +
48069 ret = -ENOMEM;
48070 page = (char *)__get_free_page(GFP_TEMPORARY);
48071 if (!page)
48072 @@ -1434,7 +1511,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
48073 path_put(&nd->path);
48074
48075 /* Are we allowed to snoop on the tasks file descriptors? */
48076 - if (!proc_fd_access_allowed(inode))
48077 + if (!proc_fd_access_allowed(inode, 0))
48078 goto out;
48079
48080 error = PROC_I(inode)->op.proc_get_link(dentry, &nd->path);
48081 @@ -1473,8 +1550,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
48082 struct path path;
48083
48084 /* Are we allowed to snoop on the tasks file descriptors? */
48085 - if (!proc_fd_access_allowed(inode))
48086 - goto out;
48087 + /* logging this is needed for learning on chromium to work properly,
48088 + but we don't want to flood the logs from 'ps' which does a readlink
48089 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
48090 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
48091 + */
48092 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
48093 + if (!proc_fd_access_allowed(inode,0))
48094 + goto out;
48095 + } else {
48096 + if (!proc_fd_access_allowed(inode,1))
48097 + goto out;
48098 + }
48099
48100 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
48101 if (error)
48102 @@ -1539,7 +1626,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
48103 rcu_read_lock();
48104 cred = __task_cred(task);
48105 inode->i_uid = cred->euid;
48106 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
48107 + inode->i_gid = CONFIG_GRKERNSEC_PROC_GID;
48108 +#else
48109 inode->i_gid = cred->egid;
48110 +#endif
48111 rcu_read_unlock();
48112 }
48113 security_task_to_inode(task, inode);
48114 @@ -1575,10 +1666,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
48115 return -ENOENT;
48116 }
48117 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
48118 +#ifdef CONFIG_GRKERNSEC_PROC_USER
48119 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
48120 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
48121 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
48122 +#endif
48123 task_dumpable(task)) {
48124 cred = __task_cred(task);
48125 stat->uid = cred->euid;
48126 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
48127 + stat->gid = CONFIG_GRKERNSEC_PROC_GID;
48128 +#else
48129 stat->gid = cred->egid;
48130 +#endif
48131 }
48132 }
48133 rcu_read_unlock();
48134 @@ -1616,11 +1716,20 @@ int pid_revalidate(struct dentry *dentry, struct nameidata *nd)
48135
48136 if (task) {
48137 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
48138 +#ifdef CONFIG_GRKERNSEC_PROC_USER
48139 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
48140 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
48141 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
48142 +#endif
48143 task_dumpable(task)) {
48144 rcu_read_lock();
48145 cred = __task_cred(task);
48146 inode->i_uid = cred->euid;
48147 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
48148 + inode->i_gid = CONFIG_GRKERNSEC_PROC_GID;
48149 +#else
48150 inode->i_gid = cred->egid;
48151 +#endif
48152 rcu_read_unlock();
48153 } else {
48154 inode->i_uid = 0;
48155 @@ -1738,7 +1847,8 @@ static int proc_fd_info(struct inode *inode, struct path *path, char *info)
48156 int fd = proc_fd(inode);
48157
48158 if (task) {
48159 - files = get_files_struct(task);
48160 + if (!gr_acl_handle_procpidmem(task))
48161 + files = get_files_struct(task);
48162 put_task_struct(task);
48163 }
48164 if (files) {
48165 @@ -2355,11 +2465,21 @@ static const struct file_operations proc_map_files_operations = {
48166 */
48167 static int proc_fd_permission(struct inode *inode, int mask)
48168 {
48169 + struct task_struct *task;
48170 int rv = generic_permission(inode, mask);
48171 - if (rv == 0)
48172 - return 0;
48173 +
48174 if (task_pid(current) == proc_pid(inode))
48175 rv = 0;
48176 +
48177 + task = get_proc_task(inode);
48178 + if (task == NULL)
48179 + return rv;
48180 +
48181 + if (gr_acl_handle_procpidmem(task))
48182 + rv = -EACCES;
48183 +
48184 + put_task_struct(task);
48185 +
48186 return rv;
48187 }
48188
48189 @@ -2469,6 +2589,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
48190 if (!task)
48191 goto out_no_task;
48192
48193 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
48194 + goto out;
48195 +
48196 /*
48197 * Yes, it does not scale. And it should not. Don't add
48198 * new entries into /proc/<tgid>/ without very good reasons.
48199 @@ -2513,6 +2636,9 @@ static int proc_pident_readdir(struct file *filp,
48200 if (!task)
48201 goto out_no_task;
48202
48203 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
48204 + goto out;
48205 +
48206 ret = 0;
48207 i = filp->f_pos;
48208 switch (i) {
48209 @@ -2783,7 +2909,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
48210 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
48211 void *cookie)
48212 {
48213 - char *s = nd_get_link(nd);
48214 + const char *s = nd_get_link(nd);
48215 if (!IS_ERR(s))
48216 __putname(s);
48217 }
48218 @@ -2984,7 +3110,7 @@ static const struct pid_entry tgid_base_stuff[] = {
48219 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
48220 #endif
48221 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
48222 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
48223 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
48224 INF("syscall", S_IRUGO, proc_pid_syscall),
48225 #endif
48226 INF("cmdline", S_IRUGO, proc_pid_cmdline),
48227 @@ -3009,10 +3135,10 @@ static const struct pid_entry tgid_base_stuff[] = {
48228 #ifdef CONFIG_SECURITY
48229 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
48230 #endif
48231 -#ifdef CONFIG_KALLSYMS
48232 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
48233 INF("wchan", S_IRUGO, proc_pid_wchan),
48234 #endif
48235 -#ifdef CONFIG_STACKTRACE
48236 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
48237 ONE("stack", S_IRUGO, proc_pid_stack),
48238 #endif
48239 #ifdef CONFIG_SCHEDSTATS
48240 @@ -3046,6 +3172,9 @@ static const struct pid_entry tgid_base_stuff[] = {
48241 #ifdef CONFIG_HARDWALL
48242 INF("hardwall", S_IRUGO, proc_pid_hardwall),
48243 #endif
48244 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
48245 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
48246 +#endif
48247 };
48248
48249 static int proc_tgid_base_readdir(struct file * filp,
48250 @@ -3172,7 +3301,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
48251 if (!inode)
48252 goto out;
48253
48254 +#ifdef CONFIG_GRKERNSEC_PROC_USER
48255 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
48256 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
48257 + inode->i_gid = CONFIG_GRKERNSEC_PROC_GID;
48258 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
48259 +#else
48260 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
48261 +#endif
48262 inode->i_op = &proc_tgid_base_inode_operations;
48263 inode->i_fop = &proc_tgid_base_operations;
48264 inode->i_flags|=S_IMMUTABLE;
48265 @@ -3214,7 +3350,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct
48266 if (!task)
48267 goto out;
48268
48269 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
48270 + goto out_put_task;
48271 +
48272 result = proc_pid_instantiate(dir, dentry, task, NULL);
48273 +out_put_task:
48274 put_task_struct(task);
48275 out:
48276 return result;
48277 @@ -3277,6 +3417,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
48278 static int fake_filldir(void *buf, const char *name, int namelen,
48279 loff_t offset, u64 ino, unsigned d_type)
48280 {
48281 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
48282 + __buf->error = -EINVAL;
48283 return 0;
48284 }
48285
48286 @@ -3343,7 +3485,7 @@ static const struct pid_entry tid_base_stuff[] = {
48287 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
48288 #endif
48289 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
48290 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
48291 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
48292 INF("syscall", S_IRUGO, proc_pid_syscall),
48293 #endif
48294 INF("cmdline", S_IRUGO, proc_pid_cmdline),
48295 @@ -3367,10 +3509,10 @@ static const struct pid_entry tid_base_stuff[] = {
48296 #ifdef CONFIG_SECURITY
48297 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
48298 #endif
48299 -#ifdef CONFIG_KALLSYMS
48300 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
48301 INF("wchan", S_IRUGO, proc_pid_wchan),
48302 #endif
48303 -#ifdef CONFIG_STACKTRACE
48304 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
48305 ONE("stack", S_IRUGO, proc_pid_stack),
48306 #endif
48307 #ifdef CONFIG_SCHEDSTATS
48308 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
48309 index 82676e3..5f8518a 100644
48310 --- a/fs/proc/cmdline.c
48311 +++ b/fs/proc/cmdline.c
48312 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
48313
48314 static int __init proc_cmdline_init(void)
48315 {
48316 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
48317 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
48318 +#else
48319 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
48320 +#endif
48321 return 0;
48322 }
48323 module_init(proc_cmdline_init);
48324 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
48325 index b143471..bb105e5 100644
48326 --- a/fs/proc/devices.c
48327 +++ b/fs/proc/devices.c
48328 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
48329
48330 static int __init proc_devices_init(void)
48331 {
48332 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
48333 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
48334 +#else
48335 proc_create("devices", 0, NULL, &proc_devinfo_operations);
48336 +#endif
48337 return 0;
48338 }
48339 module_init(proc_devices_init);
48340 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
48341 index 84fd323..f698a32 100644
48342 --- a/fs/proc/inode.c
48343 +++ b/fs/proc/inode.c
48344 @@ -21,12 +21,18 @@
48345 #include <linux/seq_file.h>
48346 #include <linux/slab.h>
48347 #include <linux/mount.h>
48348 +#include <linux/grsecurity.h>
48349
48350 #include <asm/system.h>
48351 #include <asm/uaccess.h>
48352
48353 #include "internal.h"
48354
48355 +#ifdef CONFIG_PROC_SYSCTL
48356 +extern const struct inode_operations proc_sys_inode_operations;
48357 +extern const struct inode_operations proc_sys_dir_operations;
48358 +#endif
48359 +
48360 static void proc_evict_inode(struct inode *inode)
48361 {
48362 struct proc_dir_entry *de;
48363 @@ -52,6 +58,13 @@ static void proc_evict_inode(struct inode *inode)
48364 ns_ops = PROC_I(inode)->ns_ops;
48365 if (ns_ops && ns_ops->put)
48366 ns_ops->put(PROC_I(inode)->ns);
48367 +
48368 +#ifdef CONFIG_PROC_SYSCTL
48369 + if (inode->i_op == &proc_sys_inode_operations ||
48370 + inode->i_op == &proc_sys_dir_operations)
48371 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
48372 +#endif
48373 +
48374 }
48375
48376 static struct kmem_cache * proc_inode_cachep;
48377 @@ -457,7 +470,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
48378 if (de->mode) {
48379 inode->i_mode = de->mode;
48380 inode->i_uid = de->uid;
48381 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
48382 + inode->i_gid = CONFIG_GRKERNSEC_PROC_GID;
48383 +#else
48384 inode->i_gid = de->gid;
48385 +#endif
48386 }
48387 if (de->size)
48388 inode->i_size = de->size;
48389 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
48390 index 2925775..4f08fae 100644
48391 --- a/fs/proc/internal.h
48392 +++ b/fs/proc/internal.h
48393 @@ -51,6 +51,9 @@ extern int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
48394 struct pid *pid, struct task_struct *task);
48395 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
48396 struct pid *pid, struct task_struct *task);
48397 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
48398 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
48399 +#endif
48400 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
48401
48402 extern const struct file_operations proc_maps_operations;
48403 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
48404 index d245cb2..f4e8498 100644
48405 --- a/fs/proc/kcore.c
48406 +++ b/fs/proc/kcore.c
48407 @@ -478,9 +478,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
48408 * the addresses in the elf_phdr on our list.
48409 */
48410 start = kc_offset_to_vaddr(*fpos - elf_buflen);
48411 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
48412 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
48413 + if (tsz > buflen)
48414 tsz = buflen;
48415 -
48416 +
48417 while (buflen) {
48418 struct kcore_list *m;
48419
48420 @@ -509,20 +510,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
48421 kfree(elf_buf);
48422 } else {
48423 if (kern_addr_valid(start)) {
48424 - unsigned long n;
48425 + char *elf_buf;
48426 + mm_segment_t oldfs;
48427
48428 - n = copy_to_user(buffer, (char *)start, tsz);
48429 - /*
48430 - * We cannot distingush between fault on source
48431 - * and fault on destination. When this happens
48432 - * we clear too and hope it will trigger the
48433 - * EFAULT again.
48434 - */
48435 - if (n) {
48436 - if (clear_user(buffer + tsz - n,
48437 - n))
48438 + elf_buf = kmalloc(tsz, GFP_KERNEL);
48439 + if (!elf_buf)
48440 + return -ENOMEM;
48441 + oldfs = get_fs();
48442 + set_fs(KERNEL_DS);
48443 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
48444 + set_fs(oldfs);
48445 + if (copy_to_user(buffer, elf_buf, tsz)) {
48446 + kfree(elf_buf);
48447 return -EFAULT;
48448 + }
48449 }
48450 + set_fs(oldfs);
48451 + kfree(elf_buf);
48452 } else {
48453 if (clear_user(buffer, tsz))
48454 return -EFAULT;
48455 @@ -542,6 +546,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
48456
48457 static int open_kcore(struct inode *inode, struct file *filp)
48458 {
48459 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
48460 + return -EPERM;
48461 +#endif
48462 if (!capable(CAP_SYS_RAWIO))
48463 return -EPERM;
48464 if (kcore_need_update)
48465 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
48466 index 80e4645..53e5fcf 100644
48467 --- a/fs/proc/meminfo.c
48468 +++ b/fs/proc/meminfo.c
48469 @@ -158,7 +158,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
48470 vmi.used >> 10,
48471 vmi.largest_chunk >> 10
48472 #ifdef CONFIG_MEMORY_FAILURE
48473 - ,atomic_long_read(&mce_bad_pages) << (PAGE_SHIFT - 10)
48474 + ,atomic_long_read_unchecked(&mce_bad_pages) << (PAGE_SHIFT - 10)
48475 #endif
48476 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
48477 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
48478 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
48479 index b1822dd..df622cb 100644
48480 --- a/fs/proc/nommu.c
48481 +++ b/fs/proc/nommu.c
48482 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
48483 if (len < 1)
48484 len = 1;
48485 seq_printf(m, "%*c", len, ' ');
48486 - seq_path(m, &file->f_path, "");
48487 + seq_path(m, &file->f_path, "\n\\");
48488 }
48489
48490 seq_putc(m, '\n');
48491 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
48492 index 06e1cc1..177cd98 100644
48493 --- a/fs/proc/proc_net.c
48494 +++ b/fs/proc/proc_net.c
48495 @@ -105,6 +105,17 @@ static struct net *get_proc_task_net(struct inode *dir)
48496 struct task_struct *task;
48497 struct nsproxy *ns;
48498 struct net *net = NULL;
48499 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
48500 + const struct cred *cred = current_cred();
48501 +#endif
48502 +
48503 +#ifdef CONFIG_GRKERNSEC_PROC_USER
48504 + if (cred->fsuid)
48505 + return net;
48506 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
48507 + if (cred->fsuid && !in_group_p(CONFIG_GRKERNSEC_PROC_GID))
48508 + return net;
48509 +#endif
48510
48511 rcu_read_lock();
48512 task = pid_task(proc_pid(dir), PIDTYPE_PID);
48513 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
48514 index 53c3bce..10ad159 100644
48515 --- a/fs/proc/proc_sysctl.c
48516 +++ b/fs/proc/proc_sysctl.c
48517 @@ -9,11 +9,13 @@
48518 #include <linux/namei.h>
48519 #include "internal.h"
48520
48521 +extern __u32 gr_handle_sysctl(const struct ctl_table *table, const int op);
48522 +
48523 static const struct dentry_operations proc_sys_dentry_operations;
48524 static const struct file_operations proc_sys_file_operations;
48525 -static const struct inode_operations proc_sys_inode_operations;
48526 +const struct inode_operations proc_sys_inode_operations;
48527 static const struct file_operations proc_sys_dir_file_operations;
48528 -static const struct inode_operations proc_sys_dir_operations;
48529 +const struct inode_operations proc_sys_dir_operations;
48530
48531 void proc_sys_poll_notify(struct ctl_table_poll *poll)
48532 {
48533 @@ -131,8 +133,14 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
48534
48535 err = NULL;
48536 d_set_d_op(dentry, &proc_sys_dentry_operations);
48537 +
48538 + gr_handle_proc_create(dentry, inode);
48539 +
48540 d_add(dentry, inode);
48541
48542 + if (gr_handle_sysctl(p, MAY_EXEC))
48543 + err = ERR_PTR(-ENOENT);
48544 +
48545 out:
48546 sysctl_head_finish(head);
48547 return err;
48548 @@ -163,6 +171,12 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
48549 if (!table->proc_handler)
48550 goto out;
48551
48552 +#ifdef CONFIG_GRKERNSEC
48553 + error = -EPERM;
48554 + if (write && !capable(CAP_SYS_ADMIN))
48555 + goto out;
48556 +#endif
48557 +
48558 /* careful: calling conventions are nasty here */
48559 res = count;
48560 error = table->proc_handler(table, write, buf, &res, ppos);
48561 @@ -260,6 +274,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
48562 return -ENOMEM;
48563 } else {
48564 d_set_d_op(child, &proc_sys_dentry_operations);
48565 +
48566 + gr_handle_proc_create(child, inode);
48567 +
48568 d_add(child, inode);
48569 }
48570 } else {
48571 @@ -288,6 +305,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
48572 if (*pos < file->f_pos)
48573 continue;
48574
48575 + if (gr_handle_sysctl(table, 0))
48576 + continue;
48577 +
48578 res = proc_sys_fill_cache(file, dirent, filldir, head, table);
48579 if (res)
48580 return res;
48581 @@ -413,6 +433,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
48582 if (IS_ERR(head))
48583 return PTR_ERR(head);
48584
48585 + if (table && gr_handle_sysctl(table, MAY_EXEC))
48586 + return -ENOENT;
48587 +
48588 generic_fillattr(inode, stat);
48589 if (table)
48590 stat->mode = (stat->mode & S_IFMT) | table->mode;
48591 @@ -435,13 +458,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
48592 .llseek = generic_file_llseek,
48593 };
48594
48595 -static const struct inode_operations proc_sys_inode_operations = {
48596 +const struct inode_operations proc_sys_inode_operations = {
48597 .permission = proc_sys_permission,
48598 .setattr = proc_sys_setattr,
48599 .getattr = proc_sys_getattr,
48600 };
48601
48602 -static const struct inode_operations proc_sys_dir_operations = {
48603 +const struct inode_operations proc_sys_dir_operations = {
48604 .lookup = proc_sys_lookup,
48605 .permission = proc_sys_permission,
48606 .setattr = proc_sys_setattr,
48607 diff --git a/fs/proc/root.c b/fs/proc/root.c
48608 index 46a15d8..335631a 100644
48609 --- a/fs/proc/root.c
48610 +++ b/fs/proc/root.c
48611 @@ -187,7 +187,15 @@ void __init proc_root_init(void)
48612 #ifdef CONFIG_PROC_DEVICETREE
48613 proc_device_tree_init();
48614 #endif
48615 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
48616 +#ifdef CONFIG_GRKERNSEC_PROC_USER
48617 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
48618 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
48619 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
48620 +#endif
48621 +#else
48622 proc_mkdir("bus", NULL);
48623 +#endif
48624 proc_sys_init();
48625 }
48626
48627 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
48628 index 3efa725..23c925b 100644
48629 --- a/fs/proc/task_mmu.c
48630 +++ b/fs/proc/task_mmu.c
48631 @@ -11,6 +11,7 @@
48632 #include <linux/rmap.h>
48633 #include <linux/swap.h>
48634 #include <linux/swapops.h>
48635 +#include <linux/grsecurity.h>
48636
48637 #include <asm/elf.h>
48638 #include <asm/uaccess.h>
48639 @@ -52,8 +53,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
48640 "VmExe:\t%8lu kB\n"
48641 "VmLib:\t%8lu kB\n"
48642 "VmPTE:\t%8lu kB\n"
48643 - "VmSwap:\t%8lu kB\n",
48644 - hiwater_vm << (PAGE_SHIFT-10),
48645 + "VmSwap:\t%8lu kB\n"
48646 +
48647 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
48648 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
48649 +#endif
48650 +
48651 + ,hiwater_vm << (PAGE_SHIFT-10),
48652 (total_vm - mm->reserved_vm) << (PAGE_SHIFT-10),
48653 mm->locked_vm << (PAGE_SHIFT-10),
48654 mm->pinned_vm << (PAGE_SHIFT-10),
48655 @@ -62,7 +68,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
48656 data << (PAGE_SHIFT-10),
48657 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
48658 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
48659 - swap << (PAGE_SHIFT-10));
48660 + swap << (PAGE_SHIFT-10)
48661 +
48662 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
48663 + , mm->context.user_cs_base, mm->context.user_cs_limit
48664 +#endif
48665 +
48666 + );
48667 }
48668
48669 unsigned long task_vsize(struct mm_struct *mm)
48670 @@ -209,6 +221,12 @@ static int do_maps_open(struct inode *inode, struct file *file,
48671 return ret;
48672 }
48673
48674 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
48675 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
48676 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
48677 + _mm->pax_flags & MF_PAX_SEGMEXEC))
48678 +#endif
48679 +
48680 static void show_map_vma(struct seq_file *m, struct vm_area_struct *vma)
48681 {
48682 struct mm_struct *mm = vma->vm_mm;
48683 @@ -227,13 +245,13 @@ static void show_map_vma(struct seq_file *m, struct vm_area_struct *vma)
48684 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
48685 }
48686
48687 - /* We don't show the stack guard page in /proc/maps */
48688 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
48689 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
48690 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
48691 +#else
48692 start = vma->vm_start;
48693 - if (stack_guard_page_start(vma, start))
48694 - start += PAGE_SIZE;
48695 end = vma->vm_end;
48696 - if (stack_guard_page_end(vma, end))
48697 - end -= PAGE_SIZE;
48698 +#endif
48699
48700 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
48701 start,
48702 @@ -242,7 +260,11 @@ static void show_map_vma(struct seq_file *m, struct vm_area_struct *vma)
48703 flags & VM_WRITE ? 'w' : '-',
48704 flags & VM_EXEC ? 'x' : '-',
48705 flags & VM_MAYSHARE ? 's' : 'p',
48706 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
48707 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
48708 +#else
48709 pgoff,
48710 +#endif
48711 MAJOR(dev), MINOR(dev), ino, &len);
48712
48713 /*
48714 @@ -251,7 +273,7 @@ static void show_map_vma(struct seq_file *m, struct vm_area_struct *vma)
48715 */
48716 if (file) {
48717 pad_len_spaces(m, len);
48718 - seq_path(m, &file->f_path, "\n");
48719 + seq_path(m, &file->f_path, "\n\\");
48720 } else {
48721 const char *name = arch_vma_name(vma);
48722 if (!name) {
48723 @@ -259,8 +281,9 @@ static void show_map_vma(struct seq_file *m, struct vm_area_struct *vma)
48724 if (vma->vm_start <= mm->brk &&
48725 vma->vm_end >= mm->start_brk) {
48726 name = "[heap]";
48727 - } else if (vma->vm_start <= mm->start_stack &&
48728 - vma->vm_end >= mm->start_stack) {
48729 + } else if ((vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
48730 + (vma->vm_start <= mm->start_stack &&
48731 + vma->vm_end >= mm->start_stack)) {
48732 name = "[stack]";
48733 }
48734 } else {
48735 @@ -281,6 +304,13 @@ static int show_map(struct seq_file *m, void *v)
48736 struct proc_maps_private *priv = m->private;
48737 struct task_struct *task = priv->task;
48738
48739 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
48740 + if (current->exec_id != m->exec_id) {
48741 + gr_log_badprocpid("maps");
48742 + return 0;
48743 + }
48744 +#endif
48745 +
48746 show_map_vma(m, vma);
48747
48748 if (m->count < m->size) /* vma is copied successfully */
48749 @@ -437,12 +467,23 @@ static int show_smap(struct seq_file *m, void *v)
48750 .private = &mss,
48751 };
48752
48753 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
48754 + if (current->exec_id != m->exec_id) {
48755 + gr_log_badprocpid("smaps");
48756 + return 0;
48757 + }
48758 +#endif
48759 memset(&mss, 0, sizeof mss);
48760 - mss.vma = vma;
48761 - /* mmap_sem is held in m_start */
48762 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
48763 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
48764 -
48765 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
48766 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
48767 +#endif
48768 + mss.vma = vma;
48769 + /* mmap_sem is held in m_start */
48770 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
48771 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
48772 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
48773 + }
48774 +#endif
48775 show_map_vma(m, vma);
48776
48777 seq_printf(m,
48778 @@ -460,7 +501,11 @@ static int show_smap(struct seq_file *m, void *v)
48779 "KernelPageSize: %8lu kB\n"
48780 "MMUPageSize: %8lu kB\n"
48781 "Locked: %8lu kB\n",
48782 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
48783 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
48784 +#else
48785 (vma->vm_end - vma->vm_start) >> 10,
48786 +#endif
48787 mss.resident >> 10,
48788 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
48789 mss.shared_clean >> 10,
48790 @@ -1024,6 +1069,13 @@ static int show_numa_map(struct seq_file *m, void *v)
48791 int n;
48792 char buffer[50];
48793
48794 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
48795 + if (current->exec_id != m->exec_id) {
48796 + gr_log_badprocpid("numa_maps");
48797 + return 0;
48798 + }
48799 +#endif
48800 +
48801 if (!mm)
48802 return 0;
48803
48804 @@ -1041,11 +1093,15 @@ static int show_numa_map(struct seq_file *m, void *v)
48805 mpol_to_str(buffer, sizeof(buffer), pol, 0);
48806 mpol_cond_put(pol);
48807
48808 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
48809 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
48810 +#else
48811 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
48812 +#endif
48813
48814 if (file) {
48815 seq_printf(m, " file=");
48816 - seq_path(m, &file->f_path, "\n\t= ");
48817 + seq_path(m, &file->f_path, "\n\t\\= ");
48818 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
48819 seq_printf(m, " heap");
48820 } else if (vma->vm_start <= mm->start_stack &&
48821 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
48822 index 980de54..2a4db5f 100644
48823 --- a/fs/proc/task_nommu.c
48824 +++ b/fs/proc/task_nommu.c
48825 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
48826 else
48827 bytes += kobjsize(mm);
48828
48829 - if (current->fs && current->fs->users > 1)
48830 + if (current->fs && atomic_read(&current->fs->users) > 1)
48831 sbytes += kobjsize(current->fs);
48832 else
48833 bytes += kobjsize(current->fs);
48834 @@ -166,7 +166,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma)
48835
48836 if (file) {
48837 pad_len_spaces(m, len);
48838 - seq_path(m, &file->f_path, "");
48839 + seq_path(m, &file->f_path, "\n\\");
48840 } else if (mm) {
48841 if (vma->vm_start <= mm->start_stack &&
48842 vma->vm_end >= mm->start_stack) {
48843 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
48844 index d67908b..d13f6a6 100644
48845 --- a/fs/quota/netlink.c
48846 +++ b/fs/quota/netlink.c
48847 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
48848 void quota_send_warning(short type, unsigned int id, dev_t dev,
48849 const char warntype)
48850 {
48851 - static atomic_t seq;
48852 + static atomic_unchecked_t seq;
48853 struct sk_buff *skb;
48854 void *msg_head;
48855 int ret;
48856 @@ -49,7 +49,7 @@ void quota_send_warning(short type, unsigned int id, dev_t dev,
48857 "VFS: Not enough memory to send quota warning.\n");
48858 return;
48859 }
48860 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
48861 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
48862 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
48863 if (!msg_head) {
48864 printk(KERN_ERR
48865 diff --git a/fs/readdir.c b/fs/readdir.c
48866 index 356f715..c918d38 100644
48867 --- a/fs/readdir.c
48868 +++ b/fs/readdir.c
48869 @@ -17,6 +17,7 @@
48870 #include <linux/security.h>
48871 #include <linux/syscalls.h>
48872 #include <linux/unistd.h>
48873 +#include <linux/namei.h>
48874
48875 #include <asm/uaccess.h>
48876
48877 @@ -67,6 +68,7 @@ struct old_linux_dirent {
48878
48879 struct readdir_callback {
48880 struct old_linux_dirent __user * dirent;
48881 + struct file * file;
48882 int result;
48883 };
48884
48885 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
48886 buf->result = -EOVERFLOW;
48887 return -EOVERFLOW;
48888 }
48889 +
48890 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
48891 + return 0;
48892 +
48893 buf->result++;
48894 dirent = buf->dirent;
48895 if (!access_ok(VERIFY_WRITE, dirent,
48896 @@ -116,6 +122,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
48897
48898 buf.result = 0;
48899 buf.dirent = dirent;
48900 + buf.file = file;
48901
48902 error = vfs_readdir(file, fillonedir, &buf);
48903 if (buf.result)
48904 @@ -142,6 +149,7 @@ struct linux_dirent {
48905 struct getdents_callback {
48906 struct linux_dirent __user * current_dir;
48907 struct linux_dirent __user * previous;
48908 + struct file * file;
48909 int count;
48910 int error;
48911 };
48912 @@ -163,6 +171,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
48913 buf->error = -EOVERFLOW;
48914 return -EOVERFLOW;
48915 }
48916 +
48917 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
48918 + return 0;
48919 +
48920 dirent = buf->previous;
48921 if (dirent) {
48922 if (__put_user(offset, &dirent->d_off))
48923 @@ -210,6 +222,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
48924 buf.previous = NULL;
48925 buf.count = count;
48926 buf.error = 0;
48927 + buf.file = file;
48928
48929 error = vfs_readdir(file, filldir, &buf);
48930 if (error >= 0)
48931 @@ -229,6 +242,7 @@ out:
48932 struct getdents_callback64 {
48933 struct linux_dirent64 __user * current_dir;
48934 struct linux_dirent64 __user * previous;
48935 + struct file *file;
48936 int count;
48937 int error;
48938 };
48939 @@ -244,6 +258,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
48940 buf->error = -EINVAL; /* only used if we fail.. */
48941 if (reclen > buf->count)
48942 return -EINVAL;
48943 +
48944 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
48945 + return 0;
48946 +
48947 dirent = buf->previous;
48948 if (dirent) {
48949 if (__put_user(offset, &dirent->d_off))
48950 @@ -291,6 +309,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
48951
48952 buf.current_dir = dirent;
48953 buf.previous = NULL;
48954 + buf.file = file;
48955 buf.count = count;
48956 buf.error = 0;
48957
48958 @@ -299,7 +318,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
48959 error = buf.error;
48960 lastdirent = buf.previous;
48961 if (lastdirent) {
48962 - typeof(lastdirent->d_off) d_off = file->f_pos;
48963 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = file->f_pos;
48964 if (__put_user(d_off, &lastdirent->d_off))
48965 error = -EFAULT;
48966 else
48967 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
48968 index 60c0804..d814f98 100644
48969 --- a/fs/reiserfs/do_balan.c
48970 +++ b/fs/reiserfs/do_balan.c
48971 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
48972 return;
48973 }
48974
48975 - atomic_inc(&(fs_generation(tb->tb_sb)));
48976 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
48977 do_balance_starts(tb);
48978
48979 /* balance leaf returns 0 except if combining L R and S into
48980 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
48981 index 7a99811..a7c96c4 100644
48982 --- a/fs/reiserfs/procfs.c
48983 +++ b/fs/reiserfs/procfs.c
48984 @@ -113,7 +113,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
48985 "SMALL_TAILS " : "NO_TAILS ",
48986 replay_only(sb) ? "REPLAY_ONLY " : "",
48987 convert_reiserfs(sb) ? "CONV " : "",
48988 - atomic_read(&r->s_generation_counter),
48989 + atomic_read_unchecked(&r->s_generation_counter),
48990 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
48991 SF(s_do_balance), SF(s_unneeded_left_neighbor),
48992 SF(s_good_search_by_key_reada), SF(s_bmaps),
48993 diff --git a/fs/select.c b/fs/select.c
48994 index e782258..3b4b44c 100644
48995 --- a/fs/select.c
48996 +++ b/fs/select.c
48997 @@ -20,6 +20,7 @@
48998 #include <linux/module.h>
48999 #include <linux/slab.h>
49000 #include <linux/poll.h>
49001 +#include <linux/security.h>
49002 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
49003 #include <linux/file.h>
49004 #include <linux/fdtable.h>
49005 @@ -837,6 +838,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
49006 struct poll_list *walk = head;
49007 unsigned long todo = nfds;
49008
49009 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
49010 if (nfds > rlimit(RLIMIT_NOFILE))
49011 return -EINVAL;
49012
49013 diff --git a/fs/seq_file.c b/fs/seq_file.c
49014 index 4023d6b..ab46c6a 100644
49015 --- a/fs/seq_file.c
49016 +++ b/fs/seq_file.c
49017 @@ -9,6 +9,7 @@
49018 #include <linux/module.h>
49019 #include <linux/seq_file.h>
49020 #include <linux/slab.h>
49021 +#include <linux/sched.h>
49022
49023 #include <asm/uaccess.h>
49024 #include <asm/page.h>
49025 @@ -40,6 +41,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
49026 memset(p, 0, sizeof(*p));
49027 mutex_init(&p->lock);
49028 p->op = op;
49029 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
49030 + p->exec_id = current->exec_id;
49031 +#endif
49032
49033 /*
49034 * Wrappers around seq_open(e.g. swaps_open) need to be
49035 @@ -549,7 +553,7 @@ static void single_stop(struct seq_file *p, void *v)
49036 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
49037 void *data)
49038 {
49039 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
49040 + seq_operations_no_const *op = kmalloc(sizeof(*op), GFP_KERNEL);
49041 int res = -ENOMEM;
49042
49043 if (op) {
49044 diff --git a/fs/splice.c b/fs/splice.c
49045 index 96d7b28..fd465ac 100644
49046 --- a/fs/splice.c
49047 +++ b/fs/splice.c
49048 @@ -194,7 +194,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
49049 pipe_lock(pipe);
49050
49051 for (;;) {
49052 - if (!pipe->readers) {
49053 + if (!atomic_read(&pipe->readers)) {
49054 send_sig(SIGPIPE, current, 0);
49055 if (!ret)
49056 ret = -EPIPE;
49057 @@ -248,9 +248,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
49058 do_wakeup = 0;
49059 }
49060
49061 - pipe->waiting_writers++;
49062 + atomic_inc(&pipe->waiting_writers);
49063 pipe_wait(pipe);
49064 - pipe->waiting_writers--;
49065 + atomic_dec(&pipe->waiting_writers);
49066 }
49067
49068 pipe_unlock(pipe);
49069 @@ -560,7 +560,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
49070 old_fs = get_fs();
49071 set_fs(get_ds());
49072 /* The cast to a user pointer is valid due to the set_fs() */
49073 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
49074 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
49075 set_fs(old_fs);
49076
49077 return res;
49078 @@ -575,7 +575,7 @@ static ssize_t kernel_write(struct file *file, const char *buf, size_t count,
49079 old_fs = get_fs();
49080 set_fs(get_ds());
49081 /* The cast to a user pointer is valid due to the set_fs() */
49082 - res = vfs_write(file, (const char __user *)buf, count, &pos);
49083 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
49084 set_fs(old_fs);
49085
49086 return res;
49087 @@ -626,7 +626,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
49088 goto err;
49089
49090 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
49091 - vec[i].iov_base = (void __user *) page_address(page);
49092 + vec[i].iov_base = (void __force_user *) page_address(page);
49093 vec[i].iov_len = this_len;
49094 spd.pages[i] = page;
49095 spd.nr_pages++;
49096 @@ -848,10 +848,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
49097 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
49098 {
49099 while (!pipe->nrbufs) {
49100 - if (!pipe->writers)
49101 + if (!atomic_read(&pipe->writers))
49102 return 0;
49103
49104 - if (!pipe->waiting_writers && sd->num_spliced)
49105 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
49106 return 0;
49107
49108 if (sd->flags & SPLICE_F_NONBLOCK)
49109 @@ -1184,7 +1184,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
49110 * out of the pipe right after the splice_to_pipe(). So set
49111 * PIPE_READERS appropriately.
49112 */
49113 - pipe->readers = 1;
49114 + atomic_set(&pipe->readers, 1);
49115
49116 current->splice_pipe = pipe;
49117 }
49118 @@ -1736,9 +1736,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
49119 ret = -ERESTARTSYS;
49120 break;
49121 }
49122 - if (!pipe->writers)
49123 + if (!atomic_read(&pipe->writers))
49124 break;
49125 - if (!pipe->waiting_writers) {
49126 + if (!atomic_read(&pipe->waiting_writers)) {
49127 if (flags & SPLICE_F_NONBLOCK) {
49128 ret = -EAGAIN;
49129 break;
49130 @@ -1770,7 +1770,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
49131 pipe_lock(pipe);
49132
49133 while (pipe->nrbufs >= pipe->buffers) {
49134 - if (!pipe->readers) {
49135 + if (!atomic_read(&pipe->readers)) {
49136 send_sig(SIGPIPE, current, 0);
49137 ret = -EPIPE;
49138 break;
49139 @@ -1783,9 +1783,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
49140 ret = -ERESTARTSYS;
49141 break;
49142 }
49143 - pipe->waiting_writers++;
49144 + atomic_inc(&pipe->waiting_writers);
49145 pipe_wait(pipe);
49146 - pipe->waiting_writers--;
49147 + atomic_dec(&pipe->waiting_writers);
49148 }
49149
49150 pipe_unlock(pipe);
49151 @@ -1821,14 +1821,14 @@ retry:
49152 pipe_double_lock(ipipe, opipe);
49153
49154 do {
49155 - if (!opipe->readers) {
49156 + if (!atomic_read(&opipe->readers)) {
49157 send_sig(SIGPIPE, current, 0);
49158 if (!ret)
49159 ret = -EPIPE;
49160 break;
49161 }
49162
49163 - if (!ipipe->nrbufs && !ipipe->writers)
49164 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
49165 break;
49166
49167 /*
49168 @@ -1925,7 +1925,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
49169 pipe_double_lock(ipipe, opipe);
49170
49171 do {
49172 - if (!opipe->readers) {
49173 + if (!atomic_read(&opipe->readers)) {
49174 send_sig(SIGPIPE, current, 0);
49175 if (!ret)
49176 ret = -EPIPE;
49177 @@ -1970,7 +1970,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
49178 * return EAGAIN if we have the potential of some data in the
49179 * future, otherwise just return 0
49180 */
49181 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
49182 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
49183 ret = -EAGAIN;
49184
49185 pipe_unlock(ipipe);
49186 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
49187 index 7fdf6a7..e6cd8ad 100644
49188 --- a/fs/sysfs/dir.c
49189 +++ b/fs/sysfs/dir.c
49190 @@ -642,6 +642,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
49191 struct sysfs_dirent *sd;
49192 int rc;
49193
49194 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
49195 + const char *parent_name = parent_sd->s_name;
49196 +
49197 + mode = S_IFDIR | S_IRWXU;
49198 +
49199 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
49200 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
49201 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse"))) ||
49202 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
49203 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
49204 +#endif
49205 +
49206 /* allocate */
49207 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
49208 if (!sd)
49209 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
49210 index 00012e3..8392349 100644
49211 --- a/fs/sysfs/file.c
49212 +++ b/fs/sysfs/file.c
49213 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
49214
49215 struct sysfs_open_dirent {
49216 atomic_t refcnt;
49217 - atomic_t event;
49218 + atomic_unchecked_t event;
49219 wait_queue_head_t poll;
49220 struct list_head buffers; /* goes through sysfs_buffer.list */
49221 };
49222 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
49223 if (!sysfs_get_active(attr_sd))
49224 return -ENODEV;
49225
49226 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
49227 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
49228 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
49229
49230 sysfs_put_active(attr_sd);
49231 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
49232 return -ENOMEM;
49233
49234 atomic_set(&new_od->refcnt, 0);
49235 - atomic_set(&new_od->event, 1);
49236 + atomic_set_unchecked(&new_od->event, 1);
49237 init_waitqueue_head(&new_od->poll);
49238 INIT_LIST_HEAD(&new_od->buffers);
49239 goto retry;
49240 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
49241
49242 sysfs_put_active(attr_sd);
49243
49244 - if (buffer->event != atomic_read(&od->event))
49245 + if (buffer->event != atomic_read_unchecked(&od->event))
49246 goto trigger;
49247
49248 return DEFAULT_POLLMASK;
49249 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
49250
49251 od = sd->s_attr.open;
49252 if (od) {
49253 - atomic_inc(&od->event);
49254 + atomic_inc_unchecked(&od->event);
49255 wake_up_interruptible(&od->poll);
49256 }
49257
49258 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
49259 index a7ac78f..02158e1 100644
49260 --- a/fs/sysfs/symlink.c
49261 +++ b/fs/sysfs/symlink.c
49262 @@ -286,7 +286,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
49263
49264 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
49265 {
49266 - char *page = nd_get_link(nd);
49267 + const char *page = nd_get_link(nd);
49268 if (!IS_ERR(page))
49269 free_page((unsigned long)page);
49270 }
49271 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
49272 index c175b4d..8f36a16 100644
49273 --- a/fs/udf/misc.c
49274 +++ b/fs/udf/misc.c
49275 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
49276
49277 u8 udf_tag_checksum(const struct tag *t)
49278 {
49279 - u8 *data = (u8 *)t;
49280 + const u8 *data = (const u8 *)t;
49281 u8 checksum = 0;
49282 int i;
49283 for (i = 0; i < sizeof(struct tag); ++i)
49284 diff --git a/fs/utimes.c b/fs/utimes.c
49285 index ba653f3..06ea4b1 100644
49286 --- a/fs/utimes.c
49287 +++ b/fs/utimes.c
49288 @@ -1,6 +1,7 @@
49289 #include <linux/compiler.h>
49290 #include <linux/file.h>
49291 #include <linux/fs.h>
49292 +#include <linux/security.h>
49293 #include <linux/linkage.h>
49294 #include <linux/mount.h>
49295 #include <linux/namei.h>
49296 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
49297 goto mnt_drop_write_and_out;
49298 }
49299 }
49300 +
49301 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
49302 + error = -EACCES;
49303 + goto mnt_drop_write_and_out;
49304 + }
49305 +
49306 mutex_lock(&inode->i_mutex);
49307 error = notify_change(path->dentry, &newattrs);
49308 mutex_unlock(&inode->i_mutex);
49309 diff --git a/fs/xattr.c b/fs/xattr.c
49310 index 82f4337..236473c 100644
49311 --- a/fs/xattr.c
49312 +++ b/fs/xattr.c
49313 @@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
49314 * Extended attribute SET operations
49315 */
49316 static long
49317 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
49318 +setxattr(struct path *path, const char __user *name, const void __user *value,
49319 size_t size, int flags)
49320 {
49321 int error;
49322 @@ -339,7 +339,13 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
49323 return PTR_ERR(kvalue);
49324 }
49325
49326 - error = vfs_setxattr(d, kname, kvalue, size, flags);
49327 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
49328 + error = -EACCES;
49329 + goto out;
49330 + }
49331 +
49332 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
49333 +out:
49334 kfree(kvalue);
49335 return error;
49336 }
49337 @@ -356,7 +362,7 @@ SYSCALL_DEFINE5(setxattr, const char __user *, pathname,
49338 return error;
49339 error = mnt_want_write(path.mnt);
49340 if (!error) {
49341 - error = setxattr(path.dentry, name, value, size, flags);
49342 + error = setxattr(&path, name, value, size, flags);
49343 mnt_drop_write(path.mnt);
49344 }
49345 path_put(&path);
49346 @@ -375,7 +381,7 @@ SYSCALL_DEFINE5(lsetxattr, const char __user *, pathname,
49347 return error;
49348 error = mnt_want_write(path.mnt);
49349 if (!error) {
49350 - error = setxattr(path.dentry, name, value, size, flags);
49351 + error = setxattr(&path, name, value, size, flags);
49352 mnt_drop_write(path.mnt);
49353 }
49354 path_put(&path);
49355 @@ -386,17 +392,15 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
49356 const void __user *,value, size_t, size, int, flags)
49357 {
49358 struct file *f;
49359 - struct dentry *dentry;
49360 int error = -EBADF;
49361
49362 f = fget(fd);
49363 if (!f)
49364 return error;
49365 - dentry = f->f_path.dentry;
49366 - audit_inode(NULL, dentry);
49367 + audit_inode(NULL, f->f_path.dentry);
49368 error = mnt_want_write_file(f);
49369 if (!error) {
49370 - error = setxattr(dentry, name, value, size, flags);
49371 + error = setxattr(&f->f_path, name, value, size, flags);
49372 mnt_drop_write_file(f);
49373 }
49374 fput(f);
49375 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
49376 index 8d5a506..7f62712 100644
49377 --- a/fs/xattr_acl.c
49378 +++ b/fs/xattr_acl.c
49379 @@ -17,8 +17,8 @@
49380 struct posix_acl *
49381 posix_acl_from_xattr(const void *value, size_t size)
49382 {
49383 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
49384 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
49385 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
49386 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
49387 int count;
49388 struct posix_acl *acl;
49389 struct posix_acl_entry *acl_e;
49390 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
49391 index 188ef2f..adcf864 100644
49392 --- a/fs/xfs/xfs_bmap.c
49393 +++ b/fs/xfs/xfs_bmap.c
49394 @@ -190,7 +190,7 @@ xfs_bmap_validate_ret(
49395 int nmap,
49396 int ret_nmap);
49397 #else
49398 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
49399 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do {} while (0)
49400 #endif /* DEBUG */
49401
49402 STATIC int
49403 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
49404 index 79d05e8..e3e5861 100644
49405 --- a/fs/xfs/xfs_dir2_sf.c
49406 +++ b/fs/xfs/xfs_dir2_sf.c
49407 @@ -852,7 +852,15 @@ xfs_dir2_sf_getdents(
49408 }
49409
49410 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
49411 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
49412 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
49413 + char name[sfep->namelen];
49414 + memcpy(name, sfep->name, sfep->namelen);
49415 + if (filldir(dirent, name, sfep->namelen,
49416 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
49417 + *offset = off & 0x7fffffff;
49418 + return 0;
49419 + }
49420 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
49421 off & 0x7fffffff, ino, DT_UNKNOWN)) {
49422 *offset = off & 0x7fffffff;
49423 return 0;
49424 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
49425 index 76f3ca5..f57f712 100644
49426 --- a/fs/xfs/xfs_ioctl.c
49427 +++ b/fs/xfs/xfs_ioctl.c
49428 @@ -128,7 +128,7 @@ xfs_find_handle(
49429 }
49430
49431 error = -EFAULT;
49432 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
49433 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
49434 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
49435 goto out_put;
49436
49437 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
49438 index ab30253..4d86958 100644
49439 --- a/fs/xfs/xfs_iops.c
49440 +++ b/fs/xfs/xfs_iops.c
49441 @@ -447,7 +447,7 @@ xfs_vn_put_link(
49442 struct nameidata *nd,
49443 void *p)
49444 {
49445 - char *s = nd_get_link(nd);
49446 + const char *s = nd_get_link(nd);
49447
49448 if (!IS_ERR(s))
49449 kfree(s);
49450 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
49451 new file mode 100644
49452 index 0000000..2645296
49453 --- /dev/null
49454 +++ b/grsecurity/Kconfig
49455 @@ -0,0 +1,1079 @@
49456 +#
49457 +# grecurity configuration
49458 +#
49459 +
49460 +menu "Grsecurity"
49461 +
49462 +config GRKERNSEC
49463 + bool "Grsecurity"
49464 + select CRYPTO
49465 + select CRYPTO_SHA256
49466 + help
49467 + If you say Y here, you will be able to configure many features
49468 + that will enhance the security of your system. It is highly
49469 + recommended that you say Y here and read through the help
49470 + for each option so that you fully understand the features and
49471 + can evaluate their usefulness for your machine.
49472 +
49473 +choice
49474 + prompt "Security Level"
49475 + depends on GRKERNSEC
49476 + default GRKERNSEC_CUSTOM
49477 +
49478 +config GRKERNSEC_LOW
49479 + bool "Low"
49480 + select GRKERNSEC_LINK
49481 + select GRKERNSEC_FIFO
49482 + select GRKERNSEC_RANDNET
49483 + select GRKERNSEC_DMESG
49484 + select GRKERNSEC_CHROOT
49485 + select GRKERNSEC_CHROOT_CHDIR
49486 +
49487 + help
49488 + If you choose this option, several of the grsecurity options will
49489 + be enabled that will give you greater protection against a number
49490 + of attacks, while assuring that none of your software will have any
49491 + conflicts with the additional security measures. If you run a lot
49492 + of unusual software, or you are having problems with the higher
49493 + security levels, you should say Y here. With this option, the
49494 + following features are enabled:
49495 +
49496 + - Linking restrictions
49497 + - FIFO restrictions
49498 + - Restricted dmesg
49499 + - Enforced chdir("/") on chroot
49500 + - Runtime module disabling
49501 +
49502 +config GRKERNSEC_MEDIUM
49503 + bool "Medium"
49504 + select PAX
49505 + select PAX_EI_PAX
49506 + select PAX_PT_PAX_FLAGS
49507 + select PAX_HAVE_ACL_FLAGS
49508 + select GRKERNSEC_PROC_MEMMAP if (PAX_NOEXEC || PAX_ASLR)
49509 + select GRKERNSEC_CHROOT
49510 + select GRKERNSEC_CHROOT_SYSCTL
49511 + select GRKERNSEC_LINK
49512 + select GRKERNSEC_FIFO
49513 + select GRKERNSEC_DMESG
49514 + select GRKERNSEC_RANDNET
49515 + select GRKERNSEC_FORKFAIL
49516 + select GRKERNSEC_TIME
49517 + select GRKERNSEC_SIGNAL
49518 + select GRKERNSEC_CHROOT
49519 + select GRKERNSEC_CHROOT_UNIX
49520 + select GRKERNSEC_CHROOT_MOUNT
49521 + select GRKERNSEC_CHROOT_PIVOT
49522 + select GRKERNSEC_CHROOT_DOUBLE
49523 + select GRKERNSEC_CHROOT_CHDIR
49524 + select GRKERNSEC_CHROOT_MKNOD
49525 + select GRKERNSEC_PROC
49526 + select GRKERNSEC_PROC_USERGROUP
49527 + select PAX_RANDUSTACK
49528 + select PAX_ASLR
49529 + select PAX_RANDMMAP
49530 + select PAX_REFCOUNT if (X86 || SPARC64)
49531 + select PAX_USERCOPY if ((X86 || SPARC || PPC || ARM) && (SLAB || SLUB || SLOB))
49532 +
49533 + help
49534 + If you say Y here, several features in addition to those included
49535 + in the low additional security level will be enabled. These
49536 + features provide even more security to your system, though in rare
49537 + cases they may be incompatible with very old or poorly written
49538 + software. If you enable this option, make sure that your auth
49539 + service (identd) is running as gid 1001. With this option,
49540 + the following features (in addition to those provided in the
49541 + low additional security level) will be enabled:
49542 +
49543 + - Failed fork logging
49544 + - Time change logging
49545 + - Signal logging
49546 + - Deny mounts in chroot
49547 + - Deny double chrooting
49548 + - Deny sysctl writes in chroot
49549 + - Deny mknod in chroot
49550 + - Deny access to abstract AF_UNIX sockets out of chroot
49551 + - Deny pivot_root in chroot
49552 + - Denied reads/writes of /dev/kmem, /dev/mem, and /dev/port
49553 + - /proc restrictions with special GID set to 10 (usually wheel)
49554 + - Address Space Layout Randomization (ASLR)
49555 + - Prevent exploitation of most refcount overflows
49556 + - Bounds checking of copying between the kernel and userland
49557 +
49558 +config GRKERNSEC_HIGH
49559 + bool "High"
49560 + select GRKERNSEC_LINK
49561 + select GRKERNSEC_FIFO
49562 + select GRKERNSEC_DMESG
49563 + select GRKERNSEC_FORKFAIL
49564 + select GRKERNSEC_TIME
49565 + select GRKERNSEC_SIGNAL
49566 + select GRKERNSEC_CHROOT
49567 + select GRKERNSEC_CHROOT_SHMAT
49568 + select GRKERNSEC_CHROOT_UNIX
49569 + select GRKERNSEC_CHROOT_MOUNT
49570 + select GRKERNSEC_CHROOT_FCHDIR
49571 + select GRKERNSEC_CHROOT_PIVOT
49572 + select GRKERNSEC_CHROOT_DOUBLE
49573 + select GRKERNSEC_CHROOT_CHDIR
49574 + select GRKERNSEC_CHROOT_MKNOD
49575 + select GRKERNSEC_CHROOT_CAPS
49576 + select GRKERNSEC_CHROOT_SYSCTL
49577 + select GRKERNSEC_CHROOT_FINDTASK
49578 + select GRKERNSEC_SYSFS_RESTRICT
49579 + select GRKERNSEC_PROC
49580 + select GRKERNSEC_PROC_MEMMAP if (PAX_NOEXEC || PAX_ASLR)
49581 + select GRKERNSEC_HIDESYM
49582 + select GRKERNSEC_BRUTE
49583 + select GRKERNSEC_PROC_USERGROUP
49584 + select GRKERNSEC_KMEM
49585 + select GRKERNSEC_RESLOG
49586 + select GRKERNSEC_RANDNET
49587 + select GRKERNSEC_PROC_ADD
49588 + select GRKERNSEC_CHROOT_CHMOD
49589 + select GRKERNSEC_CHROOT_NICE
49590 + select GRKERNSEC_SETXID if (X86 || SPARC64 || PPC || ARM || MIPS)
49591 + select GRKERNSEC_AUDIT_MOUNT
49592 + select GRKERNSEC_MODHARDEN if (MODULES)
49593 + select GRKERNSEC_HARDEN_PTRACE
49594 + select GRKERNSEC_PTRACE_READEXEC
49595 + select GRKERNSEC_VM86 if (X86_32)
49596 + select GRKERNSEC_KERN_LOCKOUT if (X86 || ARM || PPC || SPARC)
49597 + select PAX
49598 + select PAX_RANDUSTACK
49599 + select PAX_ASLR
49600 + select PAX_RANDMMAP
49601 + select PAX_NOEXEC
49602 + select PAX_MPROTECT
49603 + select PAX_EI_PAX
49604 + select PAX_PT_PAX_FLAGS
49605 + select PAX_HAVE_ACL_FLAGS
49606 + select PAX_KERNEXEC if ((PPC || X86) && (!X86_32 || X86_WP_WORKS_OK) && !XEN)
49607 + select PAX_MEMORY_UDEREF if (X86 && !XEN)
49608 + select PAX_RANDKSTACK if (X86_TSC && X86)
49609 + select PAX_SEGMEXEC if (X86_32)
49610 + select PAX_PAGEEXEC
49611 + select PAX_EMUPLT if (ALPHA || PARISC || SPARC)
49612 + select PAX_EMUTRAMP if (PARISC)
49613 + select PAX_EMUSIGRT if (PARISC)
49614 + select PAX_ETEXECRELOCS if (ALPHA || IA64 || PARISC)
49615 + select PAX_ELFRELOCS if (PAX_ETEXECRELOCS || (IA64 || PPC || X86))
49616 + select PAX_REFCOUNT if (X86 || SPARC64)
49617 + select PAX_USERCOPY if ((X86 || PPC || SPARC || ARM) && (SLAB || SLUB || SLOB))
49618 + help
49619 + If you say Y here, many of the features of grsecurity will be
49620 + enabled, which will protect you against many kinds of attacks
49621 + against your system. The heightened security comes at a cost
49622 + of an increased chance of incompatibilities with rare software
49623 + on your machine. Since this security level enables PaX, you should
49624 + view <http://pax.grsecurity.net> and read about the PaX
49625 + project. While you are there, download chpax and run it on
49626 + binaries that cause problems with PaX. Also remember that
49627 + since the /proc restrictions are enabled, you must run your
49628 + identd as gid 1001. This security level enables the following
49629 + features in addition to those listed in the low and medium
49630 + security levels:
49631 +
49632 + - Additional /proc restrictions
49633 + - Chmod restrictions in chroot
49634 + - No signals, ptrace, or viewing of processes outside of chroot
49635 + - Capability restrictions in chroot
49636 + - Deny fchdir out of chroot
49637 + - Priority restrictions in chroot
49638 + - Segmentation-based implementation of PaX
49639 + - Mprotect restrictions
49640 + - Removal of addresses from /proc/<pid>/[smaps|maps|stat]
49641 + - Kernel stack randomization
49642 + - Mount/unmount/remount logging
49643 + - Kernel symbol hiding
49644 + - Hardening of module auto-loading
49645 + - Ptrace restrictions
49646 + - Restricted vm86 mode
49647 + - Restricted sysfs/debugfs
49648 + - Active kernel exploit response
49649 +
49650 +config GRKERNSEC_CUSTOM
49651 + bool "Custom"
49652 + help
49653 + If you say Y here, you will be able to configure every grsecurity
49654 + option, which allows you to enable many more features that aren't
49655 + covered in the basic security levels. These additional features
49656 + include TPE, socket restrictions, and the sysctl system for
49657 + grsecurity. It is advised that you read through the help for
49658 + each option to determine its usefulness in your situation.
49659 +
49660 +endchoice
49661 +
49662 +menu "Memory Protections"
49663 +depends on GRKERNSEC
49664 +
49665 +config GRKERNSEC_KMEM
49666 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
49667 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
49668 + help
49669 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
49670 + be written to or read from to modify or leak the contents of the running
49671 + kernel. /dev/port will also not be allowed to be opened. If you have module
49672 + support disabled, enabling this will close up four ways that are
49673 + currently used to insert malicious code into the running kernel.
49674 + Even with all these features enabled, we still highly recommend that
49675 + you use the RBAC system, as it is still possible for an attacker to
49676 + modify the running kernel through privileged I/O granted by ioperm/iopl.
49677 + If you are not using XFree86, you may be able to stop this additional
49678 + case by enabling the 'Disable privileged I/O' option. Though nothing
49679 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
49680 + but only to video memory, which is the only writing we allow in this
49681 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
49682 + not be allowed to mprotect it with PROT_WRITE later.
49683 + It is highly recommended that you say Y here if you meet all the
49684 + conditions above.
49685 +
49686 +config GRKERNSEC_VM86
49687 + bool "Restrict VM86 mode"
49688 + depends on X86_32
49689 +
49690 + help
49691 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
49692 + make use of a special execution mode on 32bit x86 processors called
49693 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
49694 + video cards and will still work with this option enabled. The purpose
49695 + of the option is to prevent exploitation of emulation errors in
49696 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
49697 + Nearly all users should be able to enable this option.
49698 +
49699 +config GRKERNSEC_IO
49700 + bool "Disable privileged I/O"
49701 + depends on X86
49702 + select RTC_CLASS
49703 + select RTC_INTF_DEV
49704 + select RTC_DRV_CMOS
49705 +
49706 + help
49707 + If you say Y here, all ioperm and iopl calls will return an error.
49708 + Ioperm and iopl can be used to modify the running kernel.
49709 + Unfortunately, some programs need this access to operate properly,
49710 + the most notable of which are XFree86 and hwclock. hwclock can be
49711 + remedied by having RTC support in the kernel, so real-time
49712 + clock support is enabled if this option is enabled, to ensure
49713 + that hwclock operates correctly. XFree86 still will not
49714 + operate correctly with this option enabled, so DO NOT CHOOSE Y
49715 + IF YOU USE XFree86. If you use XFree86 and you still want to
49716 + protect your kernel against modification, use the RBAC system.
49717 +
49718 +config GRKERNSEC_PROC_MEMMAP
49719 + bool "Harden ASLR against information leaks and entropy reduction"
49720 + default y if (PAX_NOEXEC || PAX_ASLR)
49721 + depends on PAX_NOEXEC || PAX_ASLR
49722 + help
49723 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
49724 + give no information about the addresses of its mappings if
49725 + PaX features that rely on random addresses are enabled on the task.
49726 + In addition to sanitizing this information and disabling other
49727 + dangerous sources of information, this option causes reads of sensitive
49728 + /proc/<pid> entries where the file descriptor was opened in a different
49729 + task than the one performing the read. Such attempts are logged.
49730 + This option also limits argv/env strings for suid/sgid binaries
49731 + to 512KB to prevent a complete exhaustion of the stack entropy provided
49732 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
49733 + binaries to prevent alternative mmap layouts from being abused.
49734 +
49735 + If you use PaX it is essential that you say Y here as it closes up
49736 + several holes that make full ASLR useless locally.
49737 +
49738 +config GRKERNSEC_BRUTE
49739 + bool "Deter exploit bruteforcing"
49740 + help
49741 + If you say Y here, attempts to bruteforce exploits against forking
49742 + daemons such as apache or sshd, as well as against suid/sgid binaries
49743 + will be deterred. When a child of a forking daemon is killed by PaX
49744 + or crashes due to an illegal instruction or other suspicious signal,
49745 + the parent process will be delayed 30 seconds upon every subsequent
49746 + fork until the administrator is able to assess the situation and
49747 + restart the daemon.
49748 + In the suid/sgid case, the attempt is logged, the user has all their
49749 + processes terminated, and they are prevented from executing any further
49750 + processes for 15 minutes.
49751 + It is recommended that you also enable signal logging in the auditing
49752 + section so that logs are generated when a process triggers a suspicious
49753 + signal.
49754 + If the sysctl option is enabled, a sysctl option with name
49755 + "deter_bruteforce" is created.
49756 +
49757 +
49758 +config GRKERNSEC_MODHARDEN
49759 + bool "Harden module auto-loading"
49760 + depends on MODULES
49761 + help
49762 + If you say Y here, module auto-loading in response to use of some
49763 + feature implemented by an unloaded module will be restricted to
49764 + root users. Enabling this option helps defend against attacks
49765 + by unprivileged users who abuse the auto-loading behavior to
49766 + cause a vulnerable module to load that is then exploited.
49767 +
49768 + If this option prevents a legitimate use of auto-loading for a
49769 + non-root user, the administrator can execute modprobe manually
49770 + with the exact name of the module mentioned in the alert log.
49771 + Alternatively, the administrator can add the module to the list
49772 + of modules loaded at boot by modifying init scripts.
49773 +
49774 + Modification of init scripts will most likely be needed on
49775 + Ubuntu servers with encrypted home directory support enabled,
49776 + as the first non-root user logging in will cause the ecb(aes),
49777 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
49778 +
49779 +config GRKERNSEC_HIDESYM
49780 + bool "Hide kernel symbols"
49781 + help
49782 + If you say Y here, getting information on loaded modules, and
49783 + displaying all kernel symbols through a syscall will be restricted
49784 + to users with CAP_SYS_MODULE. For software compatibility reasons,
49785 + /proc/kallsyms will be restricted to the root user. The RBAC
49786 + system can hide that entry even from root.
49787 +
49788 + This option also prevents leaking of kernel addresses through
49789 + several /proc entries.
49790 +
49791 + Note that this option is only effective provided the following
49792 + conditions are met:
49793 + 1) The kernel using grsecurity is not precompiled by some distribution
49794 + 2) You have also enabled GRKERNSEC_DMESG
49795 + 3) You are using the RBAC system and hiding other files such as your
49796 + kernel image and System.map. Alternatively, enabling this option
49797 + causes the permissions on /boot, /lib/modules, and the kernel
49798 + source directory to change at compile time to prevent
49799 + reading by non-root users.
49800 + If the above conditions are met, this option will aid in providing a
49801 + useful protection against local kernel exploitation of overflows
49802 + and arbitrary read/write vulnerabilities.
49803 +
49804 +config GRKERNSEC_KERN_LOCKOUT
49805 + bool "Active kernel exploit response"
49806 + depends on X86 || ARM || PPC || SPARC
49807 + help
49808 + If you say Y here, when a PaX alert is triggered due to suspicious
49809 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
49810 + or an OOPs occurs due to bad memory accesses, instead of just
49811 + terminating the offending process (and potentially allowing
49812 + a subsequent exploit from the same user), we will take one of two
49813 + actions:
49814 + If the user was root, we will panic the system
49815 + If the user was non-root, we will log the attempt, terminate
49816 + all processes owned by the user, then prevent them from creating
49817 + any new processes until the system is restarted
49818 + This deters repeated kernel exploitation/bruteforcing attempts
49819 + and is useful for later forensics.
49820 +
49821 +endmenu
49822 +menu "Role Based Access Control Options"
49823 +depends on GRKERNSEC
49824 +
49825 +config GRKERNSEC_RBAC_DEBUG
49826 + bool
49827 +
49828 +config GRKERNSEC_NO_RBAC
49829 + bool "Disable RBAC system"
49830 + help
49831 + If you say Y here, the /dev/grsec device will be removed from the kernel,
49832 + preventing the RBAC system from being enabled. You should only say Y
49833 + here if you have no intention of using the RBAC system, so as to prevent
49834 + an attacker with root access from misusing the RBAC system to hide files
49835 + and processes when loadable module support and /dev/[k]mem have been
49836 + locked down.
49837 +
49838 +config GRKERNSEC_ACL_HIDEKERN
49839 + bool "Hide kernel processes"
49840 + help
49841 + If you say Y here, all kernel threads will be hidden to all
49842 + processes but those whose subject has the "view hidden processes"
49843 + flag.
49844 +
49845 +config GRKERNSEC_ACL_MAXTRIES
49846 + int "Maximum tries before password lockout"
49847 + default 3
49848 + help
49849 + This option enforces the maximum number of times a user can attempt
49850 + to authorize themselves with the grsecurity RBAC system before being
49851 + denied the ability to attempt authorization again for a specified time.
49852 + The lower the number, the harder it will be to brute-force a password.
49853 +
49854 +config GRKERNSEC_ACL_TIMEOUT
49855 + int "Time to wait after max password tries, in seconds"
49856 + default 30
49857 + help
49858 + This option specifies the time the user must wait after attempting to
49859 + authorize to the RBAC system with the maximum number of invalid
49860 + passwords. The higher the number, the harder it will be to brute-force
49861 + a password.
49862 +
49863 +endmenu
49864 +menu "Filesystem Protections"
49865 +depends on GRKERNSEC
49866 +
49867 +config GRKERNSEC_PROC
49868 + bool "Proc restrictions"
49869 + help
49870 + If you say Y here, the permissions of the /proc filesystem
49871 + will be altered to enhance system security and privacy. You MUST
49872 + choose either a user only restriction or a user and group restriction.
49873 + Depending upon the option you choose, you can either restrict users to
49874 + see only the processes they themselves run, or choose a group that can
49875 + view all processes and files normally restricted to root if you choose
49876 + the "restrict to user only" option. NOTE: If you're running identd or
49877 + ntpd as a non-root user, you will have to run it as the group you
49878 + specify here.
49879 +
49880 +config GRKERNSEC_PROC_USER
49881 + bool "Restrict /proc to user only"
49882 + depends on GRKERNSEC_PROC
49883 + help
49884 + If you say Y here, non-root users will only be able to view their own
49885 + processes, and restricts them from viewing network-related information,
49886 + and viewing kernel symbol and module information.
49887 +
49888 +config GRKERNSEC_PROC_USERGROUP
49889 + bool "Allow special group"
49890 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
49891 + help
49892 + If you say Y here, you will be able to select a group that will be
49893 + able to view all processes and network-related information. If you've
49894 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
49895 + remain hidden. This option is useful if you want to run identd as
49896 + a non-root user.
49897 +
49898 +config GRKERNSEC_PROC_GID
49899 + int "GID for special group"
49900 + depends on GRKERNSEC_PROC_USERGROUP
49901 + default 1001
49902 +
49903 +config GRKERNSEC_PROC_ADD
49904 + bool "Additional restrictions"
49905 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
49906 + help
49907 + If you say Y here, additional restrictions will be placed on
49908 + /proc that keep normal users from viewing device information and
49909 + slabinfo information that could be useful for exploits.
49910 +
49911 +config GRKERNSEC_LINK
49912 + bool "Linking restrictions"
49913 + help
49914 + If you say Y here, /tmp race exploits will be prevented, since users
49915 + will no longer be able to follow symlinks owned by other users in
49916 + world-writable +t directories (e.g. /tmp), unless the owner of the
49917 + symlink is the owner of the directory. users will also not be
49918 + able to hardlink to files they do not own. If the sysctl option is
49919 + enabled, a sysctl option with name "linking_restrictions" is created.
49920 +
49921 +config GRKERNSEC_FIFO
49922 + bool "FIFO restrictions"
49923 + help
49924 + If you say Y here, users will not be able to write to FIFOs they don't
49925 + own in world-writable +t directories (e.g. /tmp), unless the owner of
49926 + the FIFO is the same owner of the directory it's held in. If the sysctl
49927 + option is enabled, a sysctl option with name "fifo_restrictions" is
49928 + created.
49929 +
49930 +config GRKERNSEC_SYSFS_RESTRICT
49931 + bool "Sysfs/debugfs restriction"
49932 + depends on SYSFS
49933 + help
49934 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
49935 + any filesystem normally mounted under it (e.g. debugfs) will be
49936 + mostly accessible only by root. These filesystems generally provide access
49937 + to hardware and debug information that isn't appropriate for unprivileged
49938 + users of the system. Sysfs and debugfs have also become a large source
49939 + of new vulnerabilities, ranging from infoleaks to local compromise.
49940 + There has been very little oversight with an eye toward security involved
49941 + in adding new exporters of information to these filesystems, so their
49942 + use is discouraged.
49943 + For reasons of compatibility, a few directories have been whitelisted
49944 + for access by non-root users:
49945 + /sys/fs/selinux
49946 + /sys/fs/fuse
49947 + /sys/devices/system/cpu
49948 +
49949 +config GRKERNSEC_ROFS
49950 + bool "Runtime read-only mount protection"
49951 + help
49952 + If you say Y here, a sysctl option with name "romount_protect" will
49953 + be created. By setting this option to 1 at runtime, filesystems
49954 + will be protected in the following ways:
49955 + * No new writable mounts will be allowed
49956 + * Existing read-only mounts won't be able to be remounted read/write
49957 + * Write operations will be denied on all block devices
49958 + This option acts independently of grsec_lock: once it is set to 1,
49959 + it cannot be turned off. Therefore, please be mindful of the resulting
49960 + behavior if this option is enabled in an init script on a read-only
49961 + filesystem. This feature is mainly intended for secure embedded systems.
49962 +
49963 +config GRKERNSEC_CHROOT
49964 + bool "Chroot jail restrictions"
49965 + help
49966 + If you say Y here, you will be able to choose several options that will
49967 + make breaking out of a chrooted jail much more difficult. If you
49968 + encounter no software incompatibilities with the following options, it
49969 + is recommended that you enable each one.
49970 +
49971 +config GRKERNSEC_CHROOT_MOUNT
49972 + bool "Deny mounts"
49973 + depends on GRKERNSEC_CHROOT
49974 + help
49975 + If you say Y here, processes inside a chroot will not be able to
49976 + mount or remount filesystems. If the sysctl option is enabled, a
49977 + sysctl option with name "chroot_deny_mount" is created.
49978 +
49979 +config GRKERNSEC_CHROOT_DOUBLE
49980 + bool "Deny double-chroots"
49981 + depends on GRKERNSEC_CHROOT
49982 + help
49983 + If you say Y here, processes inside a chroot will not be able to chroot
49984 + again outside the chroot. This is a widely used method of breaking
49985 + out of a chroot jail and should not be allowed. If the sysctl
49986 + option is enabled, a sysctl option with name
49987 + "chroot_deny_chroot" is created.
49988 +
49989 +config GRKERNSEC_CHROOT_PIVOT
49990 + bool "Deny pivot_root in chroot"
49991 + depends on GRKERNSEC_CHROOT
49992 + help
49993 + If you say Y here, processes inside a chroot will not be able to use
49994 + a function called pivot_root() that was introduced in Linux 2.3.41. It
49995 + works similar to chroot in that it changes the root filesystem. This
49996 + function could be misused in a chrooted process to attempt to break out
49997 + of the chroot, and therefore should not be allowed. If the sysctl
49998 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
49999 + created.
50000 +
50001 +config GRKERNSEC_CHROOT_CHDIR
50002 + bool "Enforce chdir(\"/\") on all chroots"
50003 + depends on GRKERNSEC_CHROOT
50004 + help
50005 + If you say Y here, the current working directory of all newly-chrooted
50006 + applications will be set to the the root directory of the chroot.
50007 + The man page on chroot(2) states:
50008 + Note that this call does not change the current working
50009 + directory, so that `.' can be outside the tree rooted at
50010 + `/'. In particular, the super-user can escape from a
50011 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
50012 +
50013 + It is recommended that you say Y here, since it's not known to break
50014 + any software. If the sysctl option is enabled, a sysctl option with
50015 + name "chroot_enforce_chdir" is created.
50016 +
50017 +config GRKERNSEC_CHROOT_CHMOD
50018 + bool "Deny (f)chmod +s"
50019 + depends on GRKERNSEC_CHROOT
50020 + help
50021 + If you say Y here, processes inside a chroot will not be able to chmod
50022 + or fchmod files to make them have suid or sgid bits. This protects
50023 + against another published method of breaking a chroot. If the sysctl
50024 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
50025 + created.
50026 +
50027 +config GRKERNSEC_CHROOT_FCHDIR
50028 + bool "Deny fchdir out of chroot"
50029 + depends on GRKERNSEC_CHROOT
50030 + help
50031 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
50032 + to a file descriptor of the chrooting process that points to a directory
50033 + outside the filesystem will be stopped. If the sysctl option
50034 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
50035 +
50036 +config GRKERNSEC_CHROOT_MKNOD
50037 + bool "Deny mknod"
50038 + depends on GRKERNSEC_CHROOT
50039 + help
50040 + If you say Y here, processes inside a chroot will not be allowed to
50041 + mknod. The problem with using mknod inside a chroot is that it
50042 + would allow an attacker to create a device entry that is the same
50043 + as one on the physical root of your system, which could range from
50044 + anything from the console device to a device for your harddrive (which
50045 + they could then use to wipe the drive or steal data). It is recommended
50046 + that you say Y here, unless you run into software incompatibilities.
50047 + If the sysctl option is enabled, a sysctl option with name
50048 + "chroot_deny_mknod" is created.
50049 +
50050 +config GRKERNSEC_CHROOT_SHMAT
50051 + bool "Deny shmat() out of chroot"
50052 + depends on GRKERNSEC_CHROOT
50053 + help
50054 + If you say Y here, processes inside a chroot will not be able to attach
50055 + to shared memory segments that were created outside of the chroot jail.
50056 + It is recommended that you say Y here. If the sysctl option is enabled,
50057 + a sysctl option with name "chroot_deny_shmat" is created.
50058 +
50059 +config GRKERNSEC_CHROOT_UNIX
50060 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
50061 + depends on GRKERNSEC_CHROOT
50062 + help
50063 + If you say Y here, processes inside a chroot will not be able to
50064 + connect to abstract (meaning not belonging to a filesystem) Unix
50065 + domain sockets that were bound outside of a chroot. It is recommended
50066 + that you say Y here. If the sysctl option is enabled, a sysctl option
50067 + with name "chroot_deny_unix" is created.
50068 +
50069 +config GRKERNSEC_CHROOT_FINDTASK
50070 + bool "Protect outside processes"
50071 + depends on GRKERNSEC_CHROOT
50072 + help
50073 + If you say Y here, processes inside a chroot will not be able to
50074 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
50075 + getsid, or view any process outside of the chroot. If the sysctl
50076 + option is enabled, a sysctl option with name "chroot_findtask" is
50077 + created.
50078 +
50079 +config GRKERNSEC_CHROOT_NICE
50080 + bool "Restrict priority changes"
50081 + depends on GRKERNSEC_CHROOT
50082 + help
50083 + If you say Y here, processes inside a chroot will not be able to raise
50084 + the priority of processes in the chroot, or alter the priority of
50085 + processes outside the chroot. This provides more security than simply
50086 + removing CAP_SYS_NICE from the process' capability set. If the
50087 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
50088 + is created.
50089 +
50090 +config GRKERNSEC_CHROOT_SYSCTL
50091 + bool "Deny sysctl writes"
50092 + depends on GRKERNSEC_CHROOT
50093 + help
50094 + If you say Y here, an attacker in a chroot will not be able to
50095 + write to sysctl entries, either by sysctl(2) or through a /proc
50096 + interface. It is strongly recommended that you say Y here. If the
50097 + sysctl option is enabled, a sysctl option with name
50098 + "chroot_deny_sysctl" is created.
50099 +
50100 +config GRKERNSEC_CHROOT_CAPS
50101 + bool "Capability restrictions"
50102 + depends on GRKERNSEC_CHROOT
50103 + help
50104 + If you say Y here, the capabilities on all processes within a
50105 + chroot jail will be lowered to stop module insertion, raw i/o,
50106 + system and net admin tasks, rebooting the system, modifying immutable
50107 + files, modifying IPC owned by another, and changing the system time.
50108 + This is left an option because it can break some apps. Disable this
50109 + if your chrooted apps are having problems performing those kinds of
50110 + tasks. If the sysctl option is enabled, a sysctl option with
50111 + name "chroot_caps" is created.
50112 +
50113 +endmenu
50114 +menu "Kernel Auditing"
50115 +depends on GRKERNSEC
50116 +
50117 +config GRKERNSEC_AUDIT_GROUP
50118 + bool "Single group for auditing"
50119 + help
50120 + If you say Y here, the exec, chdir, and (un)mount logging features
50121 + will only operate on a group you specify. This option is recommended
50122 + if you only want to watch certain users instead of having a large
50123 + amount of logs from the entire system. If the sysctl option is enabled,
50124 + a sysctl option with name "audit_group" is created.
50125 +
50126 +config GRKERNSEC_AUDIT_GID
50127 + int "GID for auditing"
50128 + depends on GRKERNSEC_AUDIT_GROUP
50129 + default 1007
50130 +
50131 +config GRKERNSEC_EXECLOG
50132 + bool "Exec logging"
50133 + help
50134 + If you say Y here, all execve() calls will be logged (since the
50135 + other exec*() calls are frontends to execve(), all execution
50136 + will be logged). Useful for shell-servers that like to keep track
50137 + of their users. If the sysctl option is enabled, a sysctl option with
50138 + name "exec_logging" is created.
50139 + WARNING: This option when enabled will produce a LOT of logs, especially
50140 + on an active system.
50141 +
50142 +config GRKERNSEC_RESLOG
50143 + bool "Resource logging"
50144 + help
50145 + If you say Y here, all attempts to overstep resource limits will
50146 + be logged with the resource name, the requested size, and the current
50147 + limit. It is highly recommended that you say Y here. If the sysctl
50148 + option is enabled, a sysctl option with name "resource_logging" is
50149 + created. If the RBAC system is enabled, the sysctl value is ignored.
50150 +
50151 +config GRKERNSEC_CHROOT_EXECLOG
50152 + bool "Log execs within chroot"
50153 + help
50154 + If you say Y here, all executions inside a chroot jail will be logged
50155 + to syslog. This can cause a large amount of logs if certain
50156 + applications (eg. djb's daemontools) are installed on the system, and
50157 + is therefore left as an option. If the sysctl option is enabled, a
50158 + sysctl option with name "chroot_execlog" is created.
50159 +
50160 +config GRKERNSEC_AUDIT_PTRACE
50161 + bool "Ptrace logging"
50162 + help
50163 + If you say Y here, all attempts to attach to a process via ptrace
50164 + will be logged. If the sysctl option is enabled, a sysctl option
50165 + with name "audit_ptrace" is created.
50166 +
50167 +config GRKERNSEC_AUDIT_CHDIR
50168 + bool "Chdir logging"
50169 + help
50170 + If you say Y here, all chdir() calls will be logged. If the sysctl
50171 + option is enabled, a sysctl option with name "audit_chdir" is created.
50172 +
50173 +config GRKERNSEC_AUDIT_MOUNT
50174 + bool "(Un)Mount logging"
50175 + help
50176 + If you say Y here, all mounts and unmounts will be logged. If the
50177 + sysctl option is enabled, a sysctl option with name "audit_mount" is
50178 + created.
50179 +
50180 +config GRKERNSEC_SIGNAL
50181 + bool "Signal logging"
50182 + help
50183 + If you say Y here, certain important signals will be logged, such as
50184 + SIGSEGV, which will as a result inform you of when a error in a program
50185 + occurred, which in some cases could mean a possible exploit attempt.
50186 + If the sysctl option is enabled, a sysctl option with name
50187 + "signal_logging" is created.
50188 +
50189 +config GRKERNSEC_FORKFAIL
50190 + bool "Fork failure logging"
50191 + help
50192 + If you say Y here, all failed fork() attempts will be logged.
50193 + This could suggest a fork bomb, or someone attempting to overstep
50194 + their process limit. If the sysctl option is enabled, a sysctl option
50195 + with name "forkfail_logging" is created.
50196 +
50197 +config GRKERNSEC_TIME
50198 + bool "Time change logging"
50199 + help
50200 + If you say Y here, any changes of the system clock will be logged.
50201 + If the sysctl option is enabled, a sysctl option with name
50202 + "timechange_logging" is created.
50203 +
50204 +config GRKERNSEC_PROC_IPADDR
50205 + bool "/proc/<pid>/ipaddr support"
50206 + help
50207 + If you say Y here, a new entry will be added to each /proc/<pid>
50208 + directory that contains the IP address of the person using the task.
50209 + The IP is carried across local TCP and AF_UNIX stream sockets.
50210 + This information can be useful for IDS/IPSes to perform remote response
50211 + to a local attack. The entry is readable by only the owner of the
50212 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
50213 + the RBAC system), and thus does not create privacy concerns.
50214 +
50215 +config GRKERNSEC_RWXMAP_LOG
50216 + bool 'Denied RWX mmap/mprotect logging'
50217 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
50218 + help
50219 + If you say Y here, calls to mmap() and mprotect() with explicit
50220 + usage of PROT_WRITE and PROT_EXEC together will be logged when
50221 + denied by the PAX_MPROTECT feature. If the sysctl option is
50222 + enabled, a sysctl option with name "rwxmap_logging" is created.
50223 +
50224 +config GRKERNSEC_AUDIT_TEXTREL
50225 + bool 'ELF text relocations logging (READ HELP)'
50226 + depends on PAX_MPROTECT
50227 + help
50228 + If you say Y here, text relocations will be logged with the filename
50229 + of the offending library or binary. The purpose of the feature is
50230 + to help Linux distribution developers get rid of libraries and
50231 + binaries that need text relocations which hinder the future progress
50232 + of PaX. Only Linux distribution developers should say Y here, and
50233 + never on a production machine, as this option creates an information
50234 + leak that could aid an attacker in defeating the randomization of
50235 + a single memory region. If the sysctl option is enabled, a sysctl
50236 + option with name "audit_textrel" is created.
50237 +
50238 +endmenu
50239 +
50240 +menu "Executable Protections"
50241 +depends on GRKERNSEC
50242 +
50243 +config GRKERNSEC_DMESG
50244 + bool "Dmesg(8) restriction"
50245 + help
50246 + If you say Y here, non-root users will not be able to use dmesg(8)
50247 + to view up to the last 4kb of messages in the kernel's log buffer.
50248 + The kernel's log buffer often contains kernel addresses and other
50249 + identifying information useful to an attacker in fingerprinting a
50250 + system for a targeted exploit.
50251 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
50252 + created.
50253 +
50254 +config GRKERNSEC_HARDEN_PTRACE
50255 + bool "Deter ptrace-based process snooping"
50256 + help
50257 + If you say Y here, TTY sniffers and other malicious monitoring
50258 + programs implemented through ptrace will be defeated. If you
50259 + have been using the RBAC system, this option has already been
50260 + enabled for several years for all users, with the ability to make
50261 + fine-grained exceptions.
50262 +
50263 + This option only affects the ability of non-root users to ptrace
50264 + processes that are not a descendent of the ptracing process.
50265 + This means that strace ./binary and gdb ./binary will still work,
50266 + but attaching to arbitrary processes will not. If the sysctl
50267 + option is enabled, a sysctl option with name "harden_ptrace" is
50268 + created.
50269 +
50270 +config GRKERNSEC_PTRACE_READEXEC
50271 + bool "Require read access to ptrace sensitive binaries"
50272 + help
50273 + If you say Y here, unprivileged users will not be able to ptrace unreadable
50274 + binaries. This option is useful in environments that
50275 + remove the read bits (e.g. file mode 4711) from suid binaries to
50276 + prevent infoleaking of their contents. This option adds
50277 + consistency to the use of that file mode, as the binary could normally
50278 + be read out when run without privileges while ptracing.
50279 +
50280 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
50281 + is created.
50282 +
50283 +config GRKERNSEC_SETXID
50284 + bool "Enforce consistent multithreaded privileges"
50285 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
50286 + help
50287 + If you say Y here, a change from a root uid to a non-root uid
50288 + in a multithreaded application will cause the resulting uids,
50289 + gids, supplementary groups, and capabilities in that thread
50290 + to be propagated to the other threads of the process. In most
50291 + cases this is unnecessary, as glibc will emulate this behavior
50292 + on behalf of the application. Other libcs do not act in the
50293 + same way, allowing the other threads of the process to continue
50294 + running with root privileges. If the sysctl option is enabled,
50295 + a sysctl option with name "consistent_setxid" is created.
50296 +
50297 +config GRKERNSEC_TPE
50298 + bool "Trusted Path Execution (TPE)"
50299 + help
50300 + If you say Y here, you will be able to choose a gid to add to the
50301 + supplementary groups of users you want to mark as "untrusted."
50302 + These users will not be able to execute any files that are not in
50303 + root-owned directories writable only by root. If the sysctl option
50304 + is enabled, a sysctl option with name "tpe" is created.
50305 +
50306 +config GRKERNSEC_TPE_ALL
50307 + bool "Partially restrict all non-root users"
50308 + depends on GRKERNSEC_TPE
50309 + help
50310 + If you say Y here, all non-root users will be covered under
50311 + a weaker TPE restriction. This is separate from, and in addition to,
50312 + the main TPE options that you have selected elsewhere. Thus, if a
50313 + "trusted" GID is chosen, this restriction applies to even that GID.
50314 + Under this restriction, all non-root users will only be allowed to
50315 + execute files in directories they own that are not group or
50316 + world-writable, or in directories owned by root and writable only by
50317 + root. If the sysctl option is enabled, a sysctl option with name
50318 + "tpe_restrict_all" is created.
50319 +
50320 +config GRKERNSEC_TPE_INVERT
50321 + bool "Invert GID option"
50322 + depends on GRKERNSEC_TPE
50323 + help
50324 + If you say Y here, the group you specify in the TPE configuration will
50325 + decide what group TPE restrictions will be *disabled* for. This
50326 + option is useful if you want TPE restrictions to be applied to most
50327 + users on the system. If the sysctl option is enabled, a sysctl option
50328 + with name "tpe_invert" is created. Unlike other sysctl options, this
50329 + entry will default to on for backward-compatibility.
50330 +
50331 +config GRKERNSEC_TPE_GID
50332 + int "GID for untrusted users"
50333 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
50334 + default 1005
50335 + help
50336 + Setting this GID determines what group TPE restrictions will be
50337 + *enabled* for. If the sysctl option is enabled, a sysctl option
50338 + with name "tpe_gid" is created.
50339 +
50340 +config GRKERNSEC_TPE_GID
50341 + int "GID for trusted users"
50342 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
50343 + default 1005
50344 + help
50345 + Setting this GID determines what group TPE restrictions will be
50346 + *disabled* for. If the sysctl option is enabled, a sysctl option
50347 + with name "tpe_gid" is created.
50348 +
50349 +endmenu
50350 +menu "Network Protections"
50351 +depends on GRKERNSEC
50352 +
50353 +config GRKERNSEC_RANDNET
50354 + bool "Larger entropy pools"
50355 + help
50356 + If you say Y here, the entropy pools used for many features of Linux
50357 + and grsecurity will be doubled in size. Since several grsecurity
50358 + features use additional randomness, it is recommended that you say Y
50359 + here. Saying Y here has a similar effect as modifying
50360 + /proc/sys/kernel/random/poolsize.
50361 +
50362 +config GRKERNSEC_BLACKHOLE
50363 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
50364 + depends on NET
50365 + help
50366 + If you say Y here, neither TCP resets nor ICMP
50367 + destination-unreachable packets will be sent in response to packets
50368 + sent to ports for which no associated listening process exists.
50369 + This feature supports both IPV4 and IPV6 and exempts the
50370 + loopback interface from blackholing. Enabling this feature
50371 + makes a host more resilient to DoS attacks and reduces network
50372 + visibility against scanners.
50373 +
50374 + The blackhole feature as-implemented is equivalent to the FreeBSD
50375 + blackhole feature, as it prevents RST responses to all packets, not
50376 + just SYNs. Under most application behavior this causes no
50377 + problems, but applications (like haproxy) may not close certain
50378 + connections in a way that cleanly terminates them on the remote
50379 + end, leaving the remote host in LAST_ACK state. Because of this
50380 + side-effect and to prevent intentional LAST_ACK DoSes, this
50381 + feature also adds automatic mitigation against such attacks.
50382 + The mitigation drastically reduces the amount of time a socket
50383 + can spend in LAST_ACK state. If you're using haproxy and not
50384 + all servers it connects to have this option enabled, consider
50385 + disabling this feature on the haproxy host.
50386 +
50387 + If the sysctl option is enabled, two sysctl options with names
50388 + "ip_blackhole" and "lastack_retries" will be created.
50389 + While "ip_blackhole" takes the standard zero/non-zero on/off
50390 + toggle, "lastack_retries" uses the same kinds of values as
50391 + "tcp_retries1" and "tcp_retries2". The default value of 4
50392 + prevents a socket from lasting more than 45 seconds in LAST_ACK
50393 + state.
50394 +
50395 +config GRKERNSEC_SOCKET
50396 + bool "Socket restrictions"
50397 + depends on NET
50398 + help
50399 + If you say Y here, you will be able to choose from several options.
50400 + If you assign a GID on your system and add it to the supplementary
50401 + groups of users you want to restrict socket access to, this patch
50402 + will perform up to three things, based on the option(s) you choose.
50403 +
50404 +config GRKERNSEC_SOCKET_ALL
50405 + bool "Deny any sockets to group"
50406 + depends on GRKERNSEC_SOCKET
50407 + help
50408 + If you say Y here, you will be able to choose a GID of whose users will
50409 + be unable to connect to other hosts from your machine or run server
50410 + applications from your machine. If the sysctl option is enabled, a
50411 + sysctl option with name "socket_all" is created.
50412 +
50413 +config GRKERNSEC_SOCKET_ALL_GID
50414 + int "GID to deny all sockets for"
50415 + depends on GRKERNSEC_SOCKET_ALL
50416 + default 1004
50417 + help
50418 + Here you can choose the GID to disable socket access for. Remember to
50419 + add the users you want socket access disabled for to the GID
50420 + specified here. If the sysctl option is enabled, a sysctl option
50421 + with name "socket_all_gid" is created.
50422 +
50423 +config GRKERNSEC_SOCKET_CLIENT
50424 + bool "Deny client sockets to group"
50425 + depends on GRKERNSEC_SOCKET
50426 + help
50427 + If you say Y here, you will be able to choose a GID of whose users will
50428 + be unable to connect to other hosts from your machine, but will be
50429 + able to run servers. If this option is enabled, all users in the group
50430 + you specify will have to use passive mode when initiating ftp transfers
50431 + from the shell on your machine. If the sysctl option is enabled, a
50432 + sysctl option with name "socket_client" is created.
50433 +
50434 +config GRKERNSEC_SOCKET_CLIENT_GID
50435 + int "GID to deny client sockets for"
50436 + depends on GRKERNSEC_SOCKET_CLIENT
50437 + default 1003
50438 + help
50439 + Here you can choose the GID to disable client socket access for.
50440 + Remember to add the users you want client socket access disabled for to
50441 + the GID specified here. If the sysctl option is enabled, a sysctl
50442 + option with name "socket_client_gid" is created.
50443 +
50444 +config GRKERNSEC_SOCKET_SERVER
50445 + bool "Deny server sockets to group"
50446 + depends on GRKERNSEC_SOCKET
50447 + help
50448 + If you say Y here, you will be able to choose a GID of whose users will
50449 + be unable to run server applications from your machine. If the sysctl
50450 + option is enabled, a sysctl option with name "socket_server" is created.
50451 +
50452 +config GRKERNSEC_SOCKET_SERVER_GID
50453 + int "GID to deny server sockets for"
50454 + depends on GRKERNSEC_SOCKET_SERVER
50455 + default 1002
50456 + help
50457 + Here you can choose the GID to disable server socket access for.
50458 + Remember to add the users you want server socket access disabled for to
50459 + the GID specified here. If the sysctl option is enabled, a sysctl
50460 + option with name "socket_server_gid" is created.
50461 +
50462 +endmenu
50463 +menu "Sysctl support"
50464 +depends on GRKERNSEC && SYSCTL
50465 +
50466 +config GRKERNSEC_SYSCTL
50467 + bool "Sysctl support"
50468 + help
50469 + If you say Y here, you will be able to change the options that
50470 + grsecurity runs with at bootup, without having to recompile your
50471 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
50472 + to enable (1) or disable (0) various features. All the sysctl entries
50473 + are mutable until the "grsec_lock" entry is set to a non-zero value.
50474 + All features enabled in the kernel configuration are disabled at boot
50475 + if you do not say Y to the "Turn on features by default" option.
50476 + All options should be set at startup, and the grsec_lock entry should
50477 + be set to a non-zero value after all the options are set.
50478 + *THIS IS EXTREMELY IMPORTANT*
50479 +
50480 +config GRKERNSEC_SYSCTL_DISTRO
50481 + bool "Extra sysctl support for distro makers (READ HELP)"
50482 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
50483 + help
50484 + If you say Y here, additional sysctl options will be created
50485 + for features that affect processes running as root. Therefore,
50486 + it is critical when using this option that the grsec_lock entry be
50487 + enabled after boot. Only distros with prebuilt kernel packages
50488 + with this option enabled that can ensure grsec_lock is enabled
50489 + after boot should use this option.
50490 + *Failure to set grsec_lock after boot makes all grsec features
50491 + this option covers useless*
50492 +
50493 + Currently this option creates the following sysctl entries:
50494 + "Disable Privileged I/O": "disable_priv_io"
50495 +
50496 +config GRKERNSEC_SYSCTL_ON
50497 + bool "Turn on features by default"
50498 + depends on GRKERNSEC_SYSCTL
50499 + help
50500 + If you say Y here, instead of having all features enabled in the
50501 + kernel configuration disabled at boot time, the features will be
50502 + enabled at boot time. It is recommended you say Y here unless
50503 + there is some reason you would want all sysctl-tunable features to
50504 + be disabled by default. As mentioned elsewhere, it is important
50505 + to enable the grsec_lock entry once you have finished modifying
50506 + the sysctl entries.
50507 +
50508 +endmenu
50509 +menu "Logging Options"
50510 +depends on GRKERNSEC
50511 +
50512 +config GRKERNSEC_FLOODTIME
50513 + int "Seconds in between log messages (minimum)"
50514 + default 10
50515 + help
50516 + This option allows you to enforce the number of seconds between
50517 + grsecurity log messages. The default should be suitable for most
50518 + people, however, if you choose to change it, choose a value small enough
50519 + to allow informative logs to be produced, but large enough to
50520 + prevent flooding.
50521 +
50522 +config GRKERNSEC_FLOODBURST
50523 + int "Number of messages in a burst (maximum)"
50524 + default 6
50525 + help
50526 + This option allows you to choose the maximum number of messages allowed
50527 + within the flood time interval you chose in a separate option. The
50528 + default should be suitable for most people, however if you find that
50529 + many of your logs are being interpreted as flooding, you may want to
50530 + raise this value.
50531 +
50532 +endmenu
50533 +
50534 +endmenu
50535 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
50536 new file mode 100644
50537 index 0000000..1b9afa9
50538 --- /dev/null
50539 +++ b/grsecurity/Makefile
50540 @@ -0,0 +1,38 @@
50541 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
50542 +# during 2001-2009 it has been completely redesigned by Brad Spengler
50543 +# into an RBAC system
50544 +#
50545 +# All code in this directory and various hooks inserted throughout the kernel
50546 +# are copyright Brad Spengler - Open Source Security, Inc., and released
50547 +# under the GPL v2 or higher
50548 +
50549 +KBUILD_CFLAGS += -Werror
50550 +
50551 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
50552 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
50553 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
50554 +
50555 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
50556 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
50557 + gracl_learn.o grsec_log.o
50558 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
50559 +
50560 +ifdef CONFIG_NET
50561 +obj-y += grsec_sock.o
50562 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
50563 +endif
50564 +
50565 +ifndef CONFIG_GRKERNSEC
50566 +obj-y += grsec_disabled.o
50567 +endif
50568 +
50569 +ifdef CONFIG_GRKERNSEC_HIDESYM
50570 +extra-y := grsec_hidesym.o
50571 +$(obj)/grsec_hidesym.o:
50572 + @-chmod -f 500 /boot
50573 + @-chmod -f 500 /lib/modules
50574 + @-chmod -f 500 /lib64/modules
50575 + @-chmod -f 500 /lib32/modules
50576 + @-chmod -f 700 .
50577 + @echo ' grsec: protected kernel image paths'
50578 +endif
50579 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
50580 new file mode 100644
50581 index 0000000..a6d83f0
50582 --- /dev/null
50583 +++ b/grsecurity/gracl.c
50584 @@ -0,0 +1,4193 @@
50585 +#include <linux/kernel.h>
50586 +#include <linux/module.h>
50587 +#include <linux/sched.h>
50588 +#include <linux/mm.h>
50589 +#include <linux/file.h>
50590 +#include <linux/fs.h>
50591 +#include <linux/namei.h>
50592 +#include <linux/mount.h>
50593 +#include <linux/tty.h>
50594 +#include <linux/proc_fs.h>
50595 +#include <linux/lglock.h>
50596 +#include <linux/slab.h>
50597 +#include <linux/vmalloc.h>
50598 +#include <linux/types.h>
50599 +#include <linux/sysctl.h>
50600 +#include <linux/netdevice.h>
50601 +#include <linux/ptrace.h>
50602 +#include <linux/gracl.h>
50603 +#include <linux/gralloc.h>
50604 +#include <linux/security.h>
50605 +#include <linux/grinternal.h>
50606 +#include <linux/pid_namespace.h>
50607 +#include <linux/fdtable.h>
50608 +#include <linux/percpu.h>
50609 +#include "../fs/mount.h"
50610 +
50611 +#include <asm/uaccess.h>
50612 +#include <asm/errno.h>
50613 +#include <asm/mman.h>
50614 +
50615 +static struct acl_role_db acl_role_set;
50616 +static struct name_db name_set;
50617 +static struct inodev_db inodev_set;
50618 +
50619 +/* for keeping track of userspace pointers used for subjects, so we
50620 + can share references in the kernel as well
50621 +*/
50622 +
50623 +static struct path real_root;
50624 +
50625 +static struct acl_subj_map_db subj_map_set;
50626 +
50627 +static struct acl_role_label *default_role;
50628 +
50629 +static struct acl_role_label *role_list;
50630 +
50631 +static u16 acl_sp_role_value;
50632 +
50633 +extern char *gr_shared_page[4];
50634 +static DEFINE_MUTEX(gr_dev_mutex);
50635 +DEFINE_RWLOCK(gr_inode_lock);
50636 +
50637 +struct gr_arg *gr_usermode;
50638 +
50639 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
50640 +
50641 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
50642 +extern void gr_clear_learn_entries(void);
50643 +
50644 +#ifdef CONFIG_GRKERNSEC_RESLOG
50645 +extern void gr_log_resource(const struct task_struct *task,
50646 + const int res, const unsigned long wanted, const int gt);
50647 +#endif
50648 +
50649 +unsigned char *gr_system_salt;
50650 +unsigned char *gr_system_sum;
50651 +
50652 +static struct sprole_pw **acl_special_roles = NULL;
50653 +static __u16 num_sprole_pws = 0;
50654 +
50655 +static struct acl_role_label *kernel_role = NULL;
50656 +
50657 +static unsigned int gr_auth_attempts = 0;
50658 +static unsigned long gr_auth_expires = 0UL;
50659 +
50660 +#ifdef CONFIG_NET
50661 +extern struct vfsmount *sock_mnt;
50662 +#endif
50663 +
50664 +extern struct vfsmount *pipe_mnt;
50665 +extern struct vfsmount *shm_mnt;
50666 +#ifdef CONFIG_HUGETLBFS
50667 +extern struct vfsmount *hugetlbfs_vfsmount;
50668 +#endif
50669 +
50670 +static struct acl_object_label *fakefs_obj_rw;
50671 +static struct acl_object_label *fakefs_obj_rwx;
50672 +
50673 +extern int gr_init_uidset(void);
50674 +extern void gr_free_uidset(void);
50675 +extern void gr_remove_uid(uid_t uid);
50676 +extern int gr_find_uid(uid_t uid);
50677 +
50678 +DECLARE_BRLOCK(vfsmount_lock);
50679 +
50680 +__inline__ int
50681 +gr_acl_is_enabled(void)
50682 +{
50683 + return (gr_status & GR_READY);
50684 +}
50685 +
50686 +#ifdef CONFIG_BTRFS_FS
50687 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
50688 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
50689 +#endif
50690 +
50691 +static inline dev_t __get_dev(const struct dentry *dentry)
50692 +{
50693 +#ifdef CONFIG_BTRFS_FS
50694 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
50695 + return get_btrfs_dev_from_inode(dentry->d_inode);
50696 + else
50697 +#endif
50698 + return dentry->d_inode->i_sb->s_dev;
50699 +}
50700 +
50701 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
50702 +{
50703 + return __get_dev(dentry);
50704 +}
50705 +
50706 +static char gr_task_roletype_to_char(struct task_struct *task)
50707 +{
50708 + switch (task->role->roletype &
50709 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
50710 + GR_ROLE_SPECIAL)) {
50711 + case GR_ROLE_DEFAULT:
50712 + return 'D';
50713 + case GR_ROLE_USER:
50714 + return 'U';
50715 + case GR_ROLE_GROUP:
50716 + return 'G';
50717 + case GR_ROLE_SPECIAL:
50718 + return 'S';
50719 + }
50720 +
50721 + return 'X';
50722 +}
50723 +
50724 +char gr_roletype_to_char(void)
50725 +{
50726 + return gr_task_roletype_to_char(current);
50727 +}
50728 +
50729 +__inline__ int
50730 +gr_acl_tpe_check(void)
50731 +{
50732 + if (unlikely(!(gr_status & GR_READY)))
50733 + return 0;
50734 + if (current->role->roletype & GR_ROLE_TPE)
50735 + return 1;
50736 + else
50737 + return 0;
50738 +}
50739 +
50740 +int
50741 +gr_handle_rawio(const struct inode *inode)
50742 +{
50743 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
50744 + if (inode && S_ISBLK(inode->i_mode) &&
50745 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
50746 + !capable(CAP_SYS_RAWIO))
50747 + return 1;
50748 +#endif
50749 + return 0;
50750 +}
50751 +
50752 +static int
50753 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
50754 +{
50755 + if (likely(lena != lenb))
50756 + return 0;
50757 +
50758 + return !memcmp(a, b, lena);
50759 +}
50760 +
50761 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
50762 +{
50763 + *buflen -= namelen;
50764 + if (*buflen < 0)
50765 + return -ENAMETOOLONG;
50766 + *buffer -= namelen;
50767 + memcpy(*buffer, str, namelen);
50768 + return 0;
50769 +}
50770 +
50771 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
50772 +{
50773 + return prepend(buffer, buflen, name->name, name->len);
50774 +}
50775 +
50776 +static int prepend_path(const struct path *path, struct path *root,
50777 + char **buffer, int *buflen)
50778 +{
50779 + struct dentry *dentry = path->dentry;
50780 + struct vfsmount *vfsmnt = path->mnt;
50781 + struct mount *mnt = real_mount(vfsmnt);
50782 + bool slash = false;
50783 + int error = 0;
50784 +
50785 + while (dentry != root->dentry || vfsmnt != root->mnt) {
50786 + struct dentry * parent;
50787 +
50788 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
50789 + /* Global root? */
50790 + if (!mnt_has_parent(mnt)) {
50791 + goto out;
50792 + }
50793 + dentry = mnt->mnt_mountpoint;
50794 + mnt = mnt->mnt_parent;
50795 + vfsmnt = &mnt->mnt;
50796 + continue;
50797 + }
50798 + parent = dentry->d_parent;
50799 + prefetch(parent);
50800 + spin_lock(&dentry->d_lock);
50801 + error = prepend_name(buffer, buflen, &dentry->d_name);
50802 + spin_unlock(&dentry->d_lock);
50803 + if (!error)
50804 + error = prepend(buffer, buflen, "/", 1);
50805 + if (error)
50806 + break;
50807 +
50808 + slash = true;
50809 + dentry = parent;
50810 + }
50811 +
50812 +out:
50813 + if (!error && !slash)
50814 + error = prepend(buffer, buflen, "/", 1);
50815 +
50816 + return error;
50817 +}
50818 +
50819 +/* this must be called with vfsmount_lock and rename_lock held */
50820 +
50821 +static char *__our_d_path(const struct path *path, struct path *root,
50822 + char *buf, int buflen)
50823 +{
50824 + char *res = buf + buflen;
50825 + int error;
50826 +
50827 + prepend(&res, &buflen, "\0", 1);
50828 + error = prepend_path(path, root, &res, &buflen);
50829 + if (error)
50830 + return ERR_PTR(error);
50831 +
50832 + return res;
50833 +}
50834 +
50835 +static char *
50836 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
50837 +{
50838 + char *retval;
50839 +
50840 + retval = __our_d_path(path, root, buf, buflen);
50841 + if (unlikely(IS_ERR(retval)))
50842 + retval = strcpy(buf, "<path too long>");
50843 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
50844 + retval[1] = '\0';
50845 +
50846 + return retval;
50847 +}
50848 +
50849 +static char *
50850 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
50851 + char *buf, int buflen)
50852 +{
50853 + struct path path;
50854 + char *res;
50855 +
50856 + path.dentry = (struct dentry *)dentry;
50857 + path.mnt = (struct vfsmount *)vfsmnt;
50858 +
50859 + /* we can use real_root.dentry, real_root.mnt, because this is only called
50860 + by the RBAC system */
50861 + res = gen_full_path(&path, &real_root, buf, buflen);
50862 +
50863 + return res;
50864 +}
50865 +
50866 +static char *
50867 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
50868 + char *buf, int buflen)
50869 +{
50870 + char *res;
50871 + struct path path;
50872 + struct path root;
50873 + struct task_struct *reaper = &init_task;
50874 +
50875 + path.dentry = (struct dentry *)dentry;
50876 + path.mnt = (struct vfsmount *)vfsmnt;
50877 +
50878 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
50879 + get_fs_root(reaper->fs, &root);
50880 +
50881 + write_seqlock(&rename_lock);
50882 + br_read_lock(vfsmount_lock);
50883 + res = gen_full_path(&path, &root, buf, buflen);
50884 + br_read_unlock(vfsmount_lock);
50885 + write_sequnlock(&rename_lock);
50886 +
50887 + path_put(&root);
50888 + return res;
50889 +}
50890 +
50891 +static char *
50892 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
50893 +{
50894 + char *ret;
50895 + write_seqlock(&rename_lock);
50896 + br_read_lock(vfsmount_lock);
50897 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
50898 + PAGE_SIZE);
50899 + br_read_unlock(vfsmount_lock);
50900 + write_sequnlock(&rename_lock);
50901 + return ret;
50902 +}
50903 +
50904 +static char *
50905 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
50906 +{
50907 + char *ret;
50908 + char *buf;
50909 + int buflen;
50910 +
50911 + write_seqlock(&rename_lock);
50912 + br_read_lock(vfsmount_lock);
50913 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
50914 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
50915 + buflen = (int)(ret - buf);
50916 + if (buflen >= 5)
50917 + prepend(&ret, &buflen, "/proc", 5);
50918 + else
50919 + ret = strcpy(buf, "<path too long>");
50920 + br_read_unlock(vfsmount_lock);
50921 + write_sequnlock(&rename_lock);
50922 + return ret;
50923 +}
50924 +
50925 +char *
50926 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
50927 +{
50928 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
50929 + PAGE_SIZE);
50930 +}
50931 +
50932 +char *
50933 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
50934 +{
50935 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
50936 + PAGE_SIZE);
50937 +}
50938 +
50939 +char *
50940 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
50941 +{
50942 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
50943 + PAGE_SIZE);
50944 +}
50945 +
50946 +char *
50947 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
50948 +{
50949 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
50950 + PAGE_SIZE);
50951 +}
50952 +
50953 +char *
50954 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
50955 +{
50956 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
50957 + PAGE_SIZE);
50958 +}
50959 +
50960 +__inline__ __u32
50961 +to_gr_audit(const __u32 reqmode)
50962 +{
50963 + /* masks off auditable permission flags, then shifts them to create
50964 + auditing flags, and adds the special case of append auditing if
50965 + we're requesting write */
50966 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
50967 +}
50968 +
50969 +struct acl_subject_label *
50970 +lookup_subject_map(const struct acl_subject_label *userp)
50971 +{
50972 + unsigned int index = shash(userp, subj_map_set.s_size);
50973 + struct subject_map *match;
50974 +
50975 + match = subj_map_set.s_hash[index];
50976 +
50977 + while (match && match->user != userp)
50978 + match = match->next;
50979 +
50980 + if (match != NULL)
50981 + return match->kernel;
50982 + else
50983 + return NULL;
50984 +}
50985 +
50986 +static void
50987 +insert_subj_map_entry(struct subject_map *subjmap)
50988 +{
50989 + unsigned int index = shash(subjmap->user, subj_map_set.s_size);
50990 + struct subject_map **curr;
50991 +
50992 + subjmap->prev = NULL;
50993 +
50994 + curr = &subj_map_set.s_hash[index];
50995 + if (*curr != NULL)
50996 + (*curr)->prev = subjmap;
50997 +
50998 + subjmap->next = *curr;
50999 + *curr = subjmap;
51000 +
51001 + return;
51002 +}
51003 +
51004 +static struct acl_role_label *
51005 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
51006 + const gid_t gid)
51007 +{
51008 + unsigned int index = rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
51009 + struct acl_role_label *match;
51010 + struct role_allowed_ip *ipp;
51011 + unsigned int x;
51012 + u32 curr_ip = task->signal->curr_ip;
51013 +
51014 + task->signal->saved_ip = curr_ip;
51015 +
51016 + match = acl_role_set.r_hash[index];
51017 +
51018 + while (match) {
51019 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
51020 + for (x = 0; x < match->domain_child_num; x++) {
51021 + if (match->domain_children[x] == uid)
51022 + goto found;
51023 + }
51024 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
51025 + break;
51026 + match = match->next;
51027 + }
51028 +found:
51029 + if (match == NULL) {
51030 + try_group:
51031 + index = rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
51032 + match = acl_role_set.r_hash[index];
51033 +
51034 + while (match) {
51035 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
51036 + for (x = 0; x < match->domain_child_num; x++) {
51037 + if (match->domain_children[x] == gid)
51038 + goto found2;
51039 + }
51040 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
51041 + break;
51042 + match = match->next;
51043 + }
51044 +found2:
51045 + if (match == NULL)
51046 + match = default_role;
51047 + if (match->allowed_ips == NULL)
51048 + return match;
51049 + else {
51050 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
51051 + if (likely
51052 + ((ntohl(curr_ip) & ipp->netmask) ==
51053 + (ntohl(ipp->addr) & ipp->netmask)))
51054 + return match;
51055 + }
51056 + match = default_role;
51057 + }
51058 + } else if (match->allowed_ips == NULL) {
51059 + return match;
51060 + } else {
51061 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
51062 + if (likely
51063 + ((ntohl(curr_ip) & ipp->netmask) ==
51064 + (ntohl(ipp->addr) & ipp->netmask)))
51065 + return match;
51066 + }
51067 + goto try_group;
51068 + }
51069 +
51070 + return match;
51071 +}
51072 +
51073 +struct acl_subject_label *
51074 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
51075 + const struct acl_role_label *role)
51076 +{
51077 + unsigned int index = fhash(ino, dev, role->subj_hash_size);
51078 + struct acl_subject_label *match;
51079 +
51080 + match = role->subj_hash[index];
51081 +
51082 + while (match && (match->inode != ino || match->device != dev ||
51083 + (match->mode & GR_DELETED))) {
51084 + match = match->next;
51085 + }
51086 +
51087 + if (match && !(match->mode & GR_DELETED))
51088 + return match;
51089 + else
51090 + return NULL;
51091 +}
51092 +
51093 +struct acl_subject_label *
51094 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
51095 + const struct acl_role_label *role)
51096 +{
51097 + unsigned int index = fhash(ino, dev, role->subj_hash_size);
51098 + struct acl_subject_label *match;
51099 +
51100 + match = role->subj_hash[index];
51101 +
51102 + while (match && (match->inode != ino || match->device != dev ||
51103 + !(match->mode & GR_DELETED))) {
51104 + match = match->next;
51105 + }
51106 +
51107 + if (match && (match->mode & GR_DELETED))
51108 + return match;
51109 + else
51110 + return NULL;
51111 +}
51112 +
51113 +static struct acl_object_label *
51114 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
51115 + const struct acl_subject_label *subj)
51116 +{
51117 + unsigned int index = fhash(ino, dev, subj->obj_hash_size);
51118 + struct acl_object_label *match;
51119 +
51120 + match = subj->obj_hash[index];
51121 +
51122 + while (match && (match->inode != ino || match->device != dev ||
51123 + (match->mode & GR_DELETED))) {
51124 + match = match->next;
51125 + }
51126 +
51127 + if (match && !(match->mode & GR_DELETED))
51128 + return match;
51129 + else
51130 + return NULL;
51131 +}
51132 +
51133 +static struct acl_object_label *
51134 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
51135 + const struct acl_subject_label *subj)
51136 +{
51137 + unsigned int index = fhash(ino, dev, subj->obj_hash_size);
51138 + struct acl_object_label *match;
51139 +
51140 + match = subj->obj_hash[index];
51141 +
51142 + while (match && (match->inode != ino || match->device != dev ||
51143 + !(match->mode & GR_DELETED))) {
51144 + match = match->next;
51145 + }
51146 +
51147 + if (match && (match->mode & GR_DELETED))
51148 + return match;
51149 +
51150 + match = subj->obj_hash[index];
51151 +
51152 + while (match && (match->inode != ino || match->device != dev ||
51153 + (match->mode & GR_DELETED))) {
51154 + match = match->next;
51155 + }
51156 +
51157 + if (match && !(match->mode & GR_DELETED))
51158 + return match;
51159 + else
51160 + return NULL;
51161 +}
51162 +
51163 +static struct name_entry *
51164 +lookup_name_entry(const char *name)
51165 +{
51166 + unsigned int len = strlen(name);
51167 + unsigned int key = full_name_hash(name, len);
51168 + unsigned int index = key % name_set.n_size;
51169 + struct name_entry *match;
51170 +
51171 + match = name_set.n_hash[index];
51172 +
51173 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
51174 + match = match->next;
51175 +
51176 + return match;
51177 +}
51178 +
51179 +static struct name_entry *
51180 +lookup_name_entry_create(const char *name)
51181 +{
51182 + unsigned int len = strlen(name);
51183 + unsigned int key = full_name_hash(name, len);
51184 + unsigned int index = key % name_set.n_size;
51185 + struct name_entry *match;
51186 +
51187 + match = name_set.n_hash[index];
51188 +
51189 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
51190 + !match->deleted))
51191 + match = match->next;
51192 +
51193 + if (match && match->deleted)
51194 + return match;
51195 +
51196 + match = name_set.n_hash[index];
51197 +
51198 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
51199 + match->deleted))
51200 + match = match->next;
51201 +
51202 + if (match && !match->deleted)
51203 + return match;
51204 + else
51205 + return NULL;
51206 +}
51207 +
51208 +static struct inodev_entry *
51209 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
51210 +{
51211 + unsigned int index = fhash(ino, dev, inodev_set.i_size);
51212 + struct inodev_entry *match;
51213 +
51214 + match = inodev_set.i_hash[index];
51215 +
51216 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
51217 + match = match->next;
51218 +
51219 + return match;
51220 +}
51221 +
51222 +static void
51223 +insert_inodev_entry(struct inodev_entry *entry)
51224 +{
51225 + unsigned int index = fhash(entry->nentry->inode, entry->nentry->device,
51226 + inodev_set.i_size);
51227 + struct inodev_entry **curr;
51228 +
51229 + entry->prev = NULL;
51230 +
51231 + curr = &inodev_set.i_hash[index];
51232 + if (*curr != NULL)
51233 + (*curr)->prev = entry;
51234 +
51235 + entry->next = *curr;
51236 + *curr = entry;
51237 +
51238 + return;
51239 +}
51240 +
51241 +static void
51242 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
51243 +{
51244 + unsigned int index =
51245 + rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
51246 + struct acl_role_label **curr;
51247 + struct acl_role_label *tmp, *tmp2;
51248 +
51249 + curr = &acl_role_set.r_hash[index];
51250 +
51251 + /* simple case, slot is empty, just set it to our role */
51252 + if (*curr == NULL) {
51253 + *curr = role;
51254 + } else {
51255 + /* example:
51256 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
51257 + 2 -> 3
51258 + */
51259 + /* first check to see if we can already be reached via this slot */
51260 + tmp = *curr;
51261 + while (tmp && tmp != role)
51262 + tmp = tmp->next;
51263 + if (tmp == role) {
51264 + /* we don't need to add ourselves to this slot's chain */
51265 + return;
51266 + }
51267 + /* we need to add ourselves to this chain, two cases */
51268 + if (role->next == NULL) {
51269 + /* simple case, append the current chain to our role */
51270 + role->next = *curr;
51271 + *curr = role;
51272 + } else {
51273 + /* 1 -> 2 -> 3 -> 4
51274 + 2 -> 3 -> 4
51275 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
51276 + */
51277 + /* trickier case: walk our role's chain until we find
51278 + the role for the start of the current slot's chain */
51279 + tmp = role;
51280 + tmp2 = *curr;
51281 + while (tmp->next && tmp->next != tmp2)
51282 + tmp = tmp->next;
51283 + if (tmp->next == tmp2) {
51284 + /* from example above, we found 3, so just
51285 + replace this slot's chain with ours */
51286 + *curr = role;
51287 + } else {
51288 + /* we didn't find a subset of our role's chain
51289 + in the current slot's chain, so append their
51290 + chain to ours, and set us as the first role in
51291 + the slot's chain
51292 +
51293 + we could fold this case with the case above,
51294 + but making it explicit for clarity
51295 + */
51296 + tmp->next = tmp2;
51297 + *curr = role;
51298 + }
51299 + }
51300 + }
51301 +
51302 + return;
51303 +}
51304 +
51305 +static void
51306 +insert_acl_role_label(struct acl_role_label *role)
51307 +{
51308 + int i;
51309 +
51310 + if (role_list == NULL) {
51311 + role_list = role;
51312 + role->prev = NULL;
51313 + } else {
51314 + role->prev = role_list;
51315 + role_list = role;
51316 + }
51317 +
51318 + /* used for hash chains */
51319 + role->next = NULL;
51320 +
51321 + if (role->roletype & GR_ROLE_DOMAIN) {
51322 + for (i = 0; i < role->domain_child_num; i++)
51323 + __insert_acl_role_label(role, role->domain_children[i]);
51324 + } else
51325 + __insert_acl_role_label(role, role->uidgid);
51326 +}
51327 +
51328 +static int
51329 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
51330 +{
51331 + struct name_entry **curr, *nentry;
51332 + struct inodev_entry *ientry;
51333 + unsigned int len = strlen(name);
51334 + unsigned int key = full_name_hash(name, len);
51335 + unsigned int index = key % name_set.n_size;
51336 +
51337 + curr = &name_set.n_hash[index];
51338 +
51339 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
51340 + curr = &((*curr)->next);
51341 +
51342 + if (*curr != NULL)
51343 + return 1;
51344 +
51345 + nentry = acl_alloc(sizeof (struct name_entry));
51346 + if (nentry == NULL)
51347 + return 0;
51348 + ientry = acl_alloc(sizeof (struct inodev_entry));
51349 + if (ientry == NULL)
51350 + return 0;
51351 + ientry->nentry = nentry;
51352 +
51353 + nentry->key = key;
51354 + nentry->name = name;
51355 + nentry->inode = inode;
51356 + nentry->device = device;
51357 + nentry->len = len;
51358 + nentry->deleted = deleted;
51359 +
51360 + nentry->prev = NULL;
51361 + curr = &name_set.n_hash[index];
51362 + if (*curr != NULL)
51363 + (*curr)->prev = nentry;
51364 + nentry->next = *curr;
51365 + *curr = nentry;
51366 +
51367 + /* insert us into the table searchable by inode/dev */
51368 + insert_inodev_entry(ientry);
51369 +
51370 + return 1;
51371 +}
51372 +
51373 +static void
51374 +insert_acl_obj_label(struct acl_object_label *obj,
51375 + struct acl_subject_label *subj)
51376 +{
51377 + unsigned int index =
51378 + fhash(obj->inode, obj->device, subj->obj_hash_size);
51379 + struct acl_object_label **curr;
51380 +
51381 +
51382 + obj->prev = NULL;
51383 +
51384 + curr = &subj->obj_hash[index];
51385 + if (*curr != NULL)
51386 + (*curr)->prev = obj;
51387 +
51388 + obj->next = *curr;
51389 + *curr = obj;
51390 +
51391 + return;
51392 +}
51393 +
51394 +static void
51395 +insert_acl_subj_label(struct acl_subject_label *obj,
51396 + struct acl_role_label *role)
51397 +{
51398 + unsigned int index = fhash(obj->inode, obj->device, role->subj_hash_size);
51399 + struct acl_subject_label **curr;
51400 +
51401 + obj->prev = NULL;
51402 +
51403 + curr = &role->subj_hash[index];
51404 + if (*curr != NULL)
51405 + (*curr)->prev = obj;
51406 +
51407 + obj->next = *curr;
51408 + *curr = obj;
51409 +
51410 + return;
51411 +}
51412 +
51413 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
51414 +
51415 +static void *
51416 +create_table(__u32 * len, int elementsize)
51417 +{
51418 + unsigned int table_sizes[] = {
51419 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
51420 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
51421 + 4194301, 8388593, 16777213, 33554393, 67108859
51422 + };
51423 + void *newtable = NULL;
51424 + unsigned int pwr = 0;
51425 +
51426 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
51427 + table_sizes[pwr] <= *len)
51428 + pwr++;
51429 +
51430 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
51431 + return newtable;
51432 +
51433 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
51434 + newtable =
51435 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
51436 + else
51437 + newtable = vmalloc(table_sizes[pwr] * elementsize);
51438 +
51439 + *len = table_sizes[pwr];
51440 +
51441 + return newtable;
51442 +}
51443 +
51444 +static int
51445 +init_variables(const struct gr_arg *arg)
51446 +{
51447 + struct task_struct *reaper = &init_task;
51448 + unsigned int stacksize;
51449 +
51450 + subj_map_set.s_size = arg->role_db.num_subjects;
51451 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
51452 + name_set.n_size = arg->role_db.num_objects;
51453 + inodev_set.i_size = arg->role_db.num_objects;
51454 +
51455 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
51456 + !name_set.n_size || !inodev_set.i_size)
51457 + return 1;
51458 +
51459 + if (!gr_init_uidset())
51460 + return 1;
51461 +
51462 + /* set up the stack that holds allocation info */
51463 +
51464 + stacksize = arg->role_db.num_pointers + 5;
51465 +
51466 + if (!acl_alloc_stack_init(stacksize))
51467 + return 1;
51468 +
51469 + /* grab reference for the real root dentry and vfsmount */
51470 + get_fs_root(reaper->fs, &real_root);
51471 +
51472 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
51473 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
51474 +#endif
51475 +
51476 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
51477 + if (fakefs_obj_rw == NULL)
51478 + return 1;
51479 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
51480 +
51481 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
51482 + if (fakefs_obj_rwx == NULL)
51483 + return 1;
51484 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
51485 +
51486 + subj_map_set.s_hash =
51487 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
51488 + acl_role_set.r_hash =
51489 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
51490 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
51491 + inodev_set.i_hash =
51492 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
51493 +
51494 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
51495 + !name_set.n_hash || !inodev_set.i_hash)
51496 + return 1;
51497 +
51498 + memset(subj_map_set.s_hash, 0,
51499 + sizeof(struct subject_map *) * subj_map_set.s_size);
51500 + memset(acl_role_set.r_hash, 0,
51501 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
51502 + memset(name_set.n_hash, 0,
51503 + sizeof (struct name_entry *) * name_set.n_size);
51504 + memset(inodev_set.i_hash, 0,
51505 + sizeof (struct inodev_entry *) * inodev_set.i_size);
51506 +
51507 + return 0;
51508 +}
51509 +
51510 +/* free information not needed after startup
51511 + currently contains user->kernel pointer mappings for subjects
51512 +*/
51513 +
51514 +static void
51515 +free_init_variables(void)
51516 +{
51517 + __u32 i;
51518 +
51519 + if (subj_map_set.s_hash) {
51520 + for (i = 0; i < subj_map_set.s_size; i++) {
51521 + if (subj_map_set.s_hash[i]) {
51522 + kfree(subj_map_set.s_hash[i]);
51523 + subj_map_set.s_hash[i] = NULL;
51524 + }
51525 + }
51526 +
51527 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
51528 + PAGE_SIZE)
51529 + kfree(subj_map_set.s_hash);
51530 + else
51531 + vfree(subj_map_set.s_hash);
51532 + }
51533 +
51534 + return;
51535 +}
51536 +
51537 +static void
51538 +free_variables(void)
51539 +{
51540 + struct acl_subject_label *s;
51541 + struct acl_role_label *r;
51542 + struct task_struct *task, *task2;
51543 + unsigned int x;
51544 +
51545 + gr_clear_learn_entries();
51546 +
51547 + read_lock(&tasklist_lock);
51548 + do_each_thread(task2, task) {
51549 + task->acl_sp_role = 0;
51550 + task->acl_role_id = 0;
51551 + task->acl = NULL;
51552 + task->role = NULL;
51553 + } while_each_thread(task2, task);
51554 + read_unlock(&tasklist_lock);
51555 +
51556 + /* release the reference to the real root dentry and vfsmount */
51557 + path_put(&real_root);
51558 + memset(&real_root, 0, sizeof(real_root));
51559 +
51560 + /* free all object hash tables */
51561 +
51562 + FOR_EACH_ROLE_START(r)
51563 + if (r->subj_hash == NULL)
51564 + goto next_role;
51565 + FOR_EACH_SUBJECT_START(r, s, x)
51566 + if (s->obj_hash == NULL)
51567 + break;
51568 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
51569 + kfree(s->obj_hash);
51570 + else
51571 + vfree(s->obj_hash);
51572 + FOR_EACH_SUBJECT_END(s, x)
51573 + FOR_EACH_NESTED_SUBJECT_START(r, s)
51574 + if (s->obj_hash == NULL)
51575 + break;
51576 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
51577 + kfree(s->obj_hash);
51578 + else
51579 + vfree(s->obj_hash);
51580 + FOR_EACH_NESTED_SUBJECT_END(s)
51581 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
51582 + kfree(r->subj_hash);
51583 + else
51584 + vfree(r->subj_hash);
51585 + r->subj_hash = NULL;
51586 +next_role:
51587 + FOR_EACH_ROLE_END(r)
51588 +
51589 + acl_free_all();
51590 +
51591 + if (acl_role_set.r_hash) {
51592 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
51593 + PAGE_SIZE)
51594 + kfree(acl_role_set.r_hash);
51595 + else
51596 + vfree(acl_role_set.r_hash);
51597 + }
51598 + if (name_set.n_hash) {
51599 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
51600 + PAGE_SIZE)
51601 + kfree(name_set.n_hash);
51602 + else
51603 + vfree(name_set.n_hash);
51604 + }
51605 +
51606 + if (inodev_set.i_hash) {
51607 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
51608 + PAGE_SIZE)
51609 + kfree(inodev_set.i_hash);
51610 + else
51611 + vfree(inodev_set.i_hash);
51612 + }
51613 +
51614 + gr_free_uidset();
51615 +
51616 + memset(&name_set, 0, sizeof (struct name_db));
51617 + memset(&inodev_set, 0, sizeof (struct inodev_db));
51618 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
51619 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
51620 +
51621 + default_role = NULL;
51622 + kernel_role = NULL;
51623 + role_list = NULL;
51624 +
51625 + return;
51626 +}
51627 +
51628 +static __u32
51629 +count_user_objs(struct acl_object_label *userp)
51630 +{
51631 + struct acl_object_label o_tmp;
51632 + __u32 num = 0;
51633 +
51634 + while (userp) {
51635 + if (copy_from_user(&o_tmp, userp,
51636 + sizeof (struct acl_object_label)))
51637 + break;
51638 +
51639 + userp = o_tmp.prev;
51640 + num++;
51641 + }
51642 +
51643 + return num;
51644 +}
51645 +
51646 +static struct acl_subject_label *
51647 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role);
51648 +
51649 +static int
51650 +copy_user_glob(struct acl_object_label *obj)
51651 +{
51652 + struct acl_object_label *g_tmp, **guser;
51653 + unsigned int len;
51654 + char *tmp;
51655 +
51656 + if (obj->globbed == NULL)
51657 + return 0;
51658 +
51659 + guser = &obj->globbed;
51660 + while (*guser) {
51661 + g_tmp = (struct acl_object_label *)
51662 + acl_alloc(sizeof (struct acl_object_label));
51663 + if (g_tmp == NULL)
51664 + return -ENOMEM;
51665 +
51666 + if (copy_from_user(g_tmp, *guser,
51667 + sizeof (struct acl_object_label)))
51668 + return -EFAULT;
51669 +
51670 + len = strnlen_user(g_tmp->filename, PATH_MAX);
51671 +
51672 + if (!len || len >= PATH_MAX)
51673 + return -EINVAL;
51674 +
51675 + if ((tmp = (char *) acl_alloc(len)) == NULL)
51676 + return -ENOMEM;
51677 +
51678 + if (copy_from_user(tmp, g_tmp->filename, len))
51679 + return -EFAULT;
51680 + tmp[len-1] = '\0';
51681 + g_tmp->filename = tmp;
51682 +
51683 + *guser = g_tmp;
51684 + guser = &(g_tmp->next);
51685 + }
51686 +
51687 + return 0;
51688 +}
51689 +
51690 +static int
51691 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
51692 + struct acl_role_label *role)
51693 +{
51694 + struct acl_object_label *o_tmp;
51695 + unsigned int len;
51696 + int ret;
51697 + char *tmp;
51698 +
51699 + while (userp) {
51700 + if ((o_tmp = (struct acl_object_label *)
51701 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
51702 + return -ENOMEM;
51703 +
51704 + if (copy_from_user(o_tmp, userp,
51705 + sizeof (struct acl_object_label)))
51706 + return -EFAULT;
51707 +
51708 + userp = o_tmp->prev;
51709 +
51710 + len = strnlen_user(o_tmp->filename, PATH_MAX);
51711 +
51712 + if (!len || len >= PATH_MAX)
51713 + return -EINVAL;
51714 +
51715 + if ((tmp = (char *) acl_alloc(len)) == NULL)
51716 + return -ENOMEM;
51717 +
51718 + if (copy_from_user(tmp, o_tmp->filename, len))
51719 + return -EFAULT;
51720 + tmp[len-1] = '\0';
51721 + o_tmp->filename = tmp;
51722 +
51723 + insert_acl_obj_label(o_tmp, subj);
51724 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
51725 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
51726 + return -ENOMEM;
51727 +
51728 + ret = copy_user_glob(o_tmp);
51729 + if (ret)
51730 + return ret;
51731 +
51732 + if (o_tmp->nested) {
51733 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role);
51734 + if (IS_ERR(o_tmp->nested))
51735 + return PTR_ERR(o_tmp->nested);
51736 +
51737 + /* insert into nested subject list */
51738 + o_tmp->nested->next = role->hash->first;
51739 + role->hash->first = o_tmp->nested;
51740 + }
51741 + }
51742 +
51743 + return 0;
51744 +}
51745 +
51746 +static __u32
51747 +count_user_subjs(struct acl_subject_label *userp)
51748 +{
51749 + struct acl_subject_label s_tmp;
51750 + __u32 num = 0;
51751 +
51752 + while (userp) {
51753 + if (copy_from_user(&s_tmp, userp,
51754 + sizeof (struct acl_subject_label)))
51755 + break;
51756 +
51757 + userp = s_tmp.prev;
51758 + /* do not count nested subjects against this count, since
51759 + they are not included in the hash table, but are
51760 + attached to objects. We have already counted
51761 + the subjects in userspace for the allocation
51762 + stack
51763 + */
51764 + if (!(s_tmp.mode & GR_NESTED))
51765 + num++;
51766 + }
51767 +
51768 + return num;
51769 +}
51770 +
51771 +static int
51772 +copy_user_allowedips(struct acl_role_label *rolep)
51773 +{
51774 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
51775 +
51776 + ruserip = rolep->allowed_ips;
51777 +
51778 + while (ruserip) {
51779 + rlast = rtmp;
51780 +
51781 + if ((rtmp = (struct role_allowed_ip *)
51782 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
51783 + return -ENOMEM;
51784 +
51785 + if (copy_from_user(rtmp, ruserip,
51786 + sizeof (struct role_allowed_ip)))
51787 + return -EFAULT;
51788 +
51789 + ruserip = rtmp->prev;
51790 +
51791 + if (!rlast) {
51792 + rtmp->prev = NULL;
51793 + rolep->allowed_ips = rtmp;
51794 + } else {
51795 + rlast->next = rtmp;
51796 + rtmp->prev = rlast;
51797 + }
51798 +
51799 + if (!ruserip)
51800 + rtmp->next = NULL;
51801 + }
51802 +
51803 + return 0;
51804 +}
51805 +
51806 +static int
51807 +copy_user_transitions(struct acl_role_label *rolep)
51808 +{
51809 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
51810 +
51811 + unsigned int len;
51812 + char *tmp;
51813 +
51814 + rusertp = rolep->transitions;
51815 +
51816 + while (rusertp) {
51817 + rlast = rtmp;
51818 +
51819 + if ((rtmp = (struct role_transition *)
51820 + acl_alloc(sizeof (struct role_transition))) == NULL)
51821 + return -ENOMEM;
51822 +
51823 + if (copy_from_user(rtmp, rusertp,
51824 + sizeof (struct role_transition)))
51825 + return -EFAULT;
51826 +
51827 + rusertp = rtmp->prev;
51828 +
51829 + len = strnlen_user(rtmp->rolename, GR_SPROLE_LEN);
51830 +
51831 + if (!len || len >= GR_SPROLE_LEN)
51832 + return -EINVAL;
51833 +
51834 + if ((tmp = (char *) acl_alloc(len)) == NULL)
51835 + return -ENOMEM;
51836 +
51837 + if (copy_from_user(tmp, rtmp->rolename, len))
51838 + return -EFAULT;
51839 + tmp[len-1] = '\0';
51840 + rtmp->rolename = tmp;
51841 +
51842 + if (!rlast) {
51843 + rtmp->prev = NULL;
51844 + rolep->transitions = rtmp;
51845 + } else {
51846 + rlast->next = rtmp;
51847 + rtmp->prev = rlast;
51848 + }
51849 +
51850 + if (!rusertp)
51851 + rtmp->next = NULL;
51852 + }
51853 +
51854 + return 0;
51855 +}
51856 +
51857 +static struct acl_subject_label *
51858 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role)
51859 +{
51860 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
51861 + unsigned int len;
51862 + char *tmp;
51863 + __u32 num_objs;
51864 + struct acl_ip_label **i_tmp, *i_utmp2;
51865 + struct gr_hash_struct ghash;
51866 + struct subject_map *subjmap;
51867 + unsigned int i_num;
51868 + int err;
51869 +
51870 + s_tmp = lookup_subject_map(userp);
51871 +
51872 + /* we've already copied this subject into the kernel, just return
51873 + the reference to it, and don't copy it over again
51874 + */
51875 + if (s_tmp)
51876 + return(s_tmp);
51877 +
51878 + if ((s_tmp = (struct acl_subject_label *)
51879 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
51880 + return ERR_PTR(-ENOMEM);
51881 +
51882 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
51883 + if (subjmap == NULL)
51884 + return ERR_PTR(-ENOMEM);
51885 +
51886 + subjmap->user = userp;
51887 + subjmap->kernel = s_tmp;
51888 + insert_subj_map_entry(subjmap);
51889 +
51890 + if (copy_from_user(s_tmp, userp,
51891 + sizeof (struct acl_subject_label)))
51892 + return ERR_PTR(-EFAULT);
51893 +
51894 + len = strnlen_user(s_tmp->filename, PATH_MAX);
51895 +
51896 + if (!len || len >= PATH_MAX)
51897 + return ERR_PTR(-EINVAL);
51898 +
51899 + if ((tmp = (char *) acl_alloc(len)) == NULL)
51900 + return ERR_PTR(-ENOMEM);
51901 +
51902 + if (copy_from_user(tmp, s_tmp->filename, len))
51903 + return ERR_PTR(-EFAULT);
51904 + tmp[len-1] = '\0';
51905 + s_tmp->filename = tmp;
51906 +
51907 + if (!strcmp(s_tmp->filename, "/"))
51908 + role->root_label = s_tmp;
51909 +
51910 + if (copy_from_user(&ghash, s_tmp->hash, sizeof(struct gr_hash_struct)))
51911 + return ERR_PTR(-EFAULT);
51912 +
51913 + /* copy user and group transition tables */
51914 +
51915 + if (s_tmp->user_trans_num) {
51916 + uid_t *uidlist;
51917 +
51918 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
51919 + if (uidlist == NULL)
51920 + return ERR_PTR(-ENOMEM);
51921 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
51922 + return ERR_PTR(-EFAULT);
51923 +
51924 + s_tmp->user_transitions = uidlist;
51925 + }
51926 +
51927 + if (s_tmp->group_trans_num) {
51928 + gid_t *gidlist;
51929 +
51930 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
51931 + if (gidlist == NULL)
51932 + return ERR_PTR(-ENOMEM);
51933 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
51934 + return ERR_PTR(-EFAULT);
51935 +
51936 + s_tmp->group_transitions = gidlist;
51937 + }
51938 +
51939 + /* set up object hash table */
51940 + num_objs = count_user_objs(ghash.first);
51941 +
51942 + s_tmp->obj_hash_size = num_objs;
51943 + s_tmp->obj_hash =
51944 + (struct acl_object_label **)
51945 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
51946 +
51947 + if (!s_tmp->obj_hash)
51948 + return ERR_PTR(-ENOMEM);
51949 +
51950 + memset(s_tmp->obj_hash, 0,
51951 + s_tmp->obj_hash_size *
51952 + sizeof (struct acl_object_label *));
51953 +
51954 + /* add in objects */
51955 + err = copy_user_objs(ghash.first, s_tmp, role);
51956 +
51957 + if (err)
51958 + return ERR_PTR(err);
51959 +
51960 + /* set pointer for parent subject */
51961 + if (s_tmp->parent_subject) {
51962 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role);
51963 +
51964 + if (IS_ERR(s_tmp2))
51965 + return s_tmp2;
51966 +
51967 + s_tmp->parent_subject = s_tmp2;
51968 + }
51969 +
51970 + /* add in ip acls */
51971 +
51972 + if (!s_tmp->ip_num) {
51973 + s_tmp->ips = NULL;
51974 + goto insert;
51975 + }
51976 +
51977 + i_tmp =
51978 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
51979 + sizeof (struct acl_ip_label *));
51980 +
51981 + if (!i_tmp)
51982 + return ERR_PTR(-ENOMEM);
51983 +
51984 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
51985 + *(i_tmp + i_num) =
51986 + (struct acl_ip_label *)
51987 + acl_alloc(sizeof (struct acl_ip_label));
51988 + if (!*(i_tmp + i_num))
51989 + return ERR_PTR(-ENOMEM);
51990 +
51991 + if (copy_from_user
51992 + (&i_utmp2, s_tmp->ips + i_num,
51993 + sizeof (struct acl_ip_label *)))
51994 + return ERR_PTR(-EFAULT);
51995 +
51996 + if (copy_from_user
51997 + (*(i_tmp + i_num), i_utmp2,
51998 + sizeof (struct acl_ip_label)))
51999 + return ERR_PTR(-EFAULT);
52000 +
52001 + if ((*(i_tmp + i_num))->iface == NULL)
52002 + continue;
52003 +
52004 + len = strnlen_user((*(i_tmp + i_num))->iface, IFNAMSIZ);
52005 + if (!len || len >= IFNAMSIZ)
52006 + return ERR_PTR(-EINVAL);
52007 + tmp = acl_alloc(len);
52008 + if (tmp == NULL)
52009 + return ERR_PTR(-ENOMEM);
52010 + if (copy_from_user(tmp, (*(i_tmp + i_num))->iface, len))
52011 + return ERR_PTR(-EFAULT);
52012 + (*(i_tmp + i_num))->iface = tmp;
52013 + }
52014 +
52015 + s_tmp->ips = i_tmp;
52016 +
52017 +insert:
52018 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
52019 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
52020 + return ERR_PTR(-ENOMEM);
52021 +
52022 + return s_tmp;
52023 +}
52024 +
52025 +static int
52026 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
52027 +{
52028 + struct acl_subject_label s_pre;
52029 + struct acl_subject_label * ret;
52030 + int err;
52031 +
52032 + while (userp) {
52033 + if (copy_from_user(&s_pre, userp,
52034 + sizeof (struct acl_subject_label)))
52035 + return -EFAULT;
52036 +
52037 + /* do not add nested subjects here, add
52038 + while parsing objects
52039 + */
52040 +
52041 + if (s_pre.mode & GR_NESTED) {
52042 + userp = s_pre.prev;
52043 + continue;
52044 + }
52045 +
52046 + ret = do_copy_user_subj(userp, role);
52047 +
52048 + err = PTR_ERR(ret);
52049 + if (IS_ERR(ret))
52050 + return err;
52051 +
52052 + insert_acl_subj_label(ret, role);
52053 +
52054 + userp = s_pre.prev;
52055 + }
52056 +
52057 + return 0;
52058 +}
52059 +
52060 +static int
52061 +copy_user_acl(struct gr_arg *arg)
52062 +{
52063 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
52064 + struct sprole_pw *sptmp;
52065 + struct gr_hash_struct *ghash;
52066 + uid_t *domainlist;
52067 + unsigned int r_num;
52068 + unsigned int len;
52069 + char *tmp;
52070 + int err = 0;
52071 + __u16 i;
52072 + __u32 num_subjs;
52073 +
52074 + /* we need a default and kernel role */
52075 + if (arg->role_db.num_roles < 2)
52076 + return -EINVAL;
52077 +
52078 + /* copy special role authentication info from userspace */
52079 +
52080 + num_sprole_pws = arg->num_sprole_pws;
52081 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
52082 +
52083 + if (!acl_special_roles && num_sprole_pws)
52084 + return -ENOMEM;
52085 +
52086 + for (i = 0; i < num_sprole_pws; i++) {
52087 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
52088 + if (!sptmp)
52089 + return -ENOMEM;
52090 + if (copy_from_user(sptmp, arg->sprole_pws + i,
52091 + sizeof (struct sprole_pw)))
52092 + return -EFAULT;
52093 +
52094 + len = strnlen_user(sptmp->rolename, GR_SPROLE_LEN);
52095 +
52096 + if (!len || len >= GR_SPROLE_LEN)
52097 + return -EINVAL;
52098 +
52099 + if ((tmp = (char *) acl_alloc(len)) == NULL)
52100 + return -ENOMEM;
52101 +
52102 + if (copy_from_user(tmp, sptmp->rolename, len))
52103 + return -EFAULT;
52104 +
52105 + tmp[len-1] = '\0';
52106 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
52107 + printk(KERN_ALERT "Copying special role %s\n", tmp);
52108 +#endif
52109 + sptmp->rolename = tmp;
52110 + acl_special_roles[i] = sptmp;
52111 + }
52112 +
52113 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
52114 +
52115 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
52116 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
52117 +
52118 + if (!r_tmp)
52119 + return -ENOMEM;
52120 +
52121 + if (copy_from_user(&r_utmp2, r_utmp + r_num,
52122 + sizeof (struct acl_role_label *)))
52123 + return -EFAULT;
52124 +
52125 + if (copy_from_user(r_tmp, r_utmp2,
52126 + sizeof (struct acl_role_label)))
52127 + return -EFAULT;
52128 +
52129 + len = strnlen_user(r_tmp->rolename, GR_SPROLE_LEN);
52130 +
52131 + if (!len || len >= PATH_MAX)
52132 + return -EINVAL;
52133 +
52134 + if ((tmp = (char *) acl_alloc(len)) == NULL)
52135 + return -ENOMEM;
52136 +
52137 + if (copy_from_user(tmp, r_tmp->rolename, len))
52138 + return -EFAULT;
52139 +
52140 + tmp[len-1] = '\0';
52141 + r_tmp->rolename = tmp;
52142 +
52143 + if (!strcmp(r_tmp->rolename, "default")
52144 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
52145 + default_role = r_tmp;
52146 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
52147 + kernel_role = r_tmp;
52148 + }
52149 +
52150 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
52151 + return -ENOMEM;
52152 +
52153 + if (copy_from_user(ghash, r_tmp->hash, sizeof(struct gr_hash_struct)))
52154 + return -EFAULT;
52155 +
52156 + r_tmp->hash = ghash;
52157 +
52158 + num_subjs = count_user_subjs(r_tmp->hash->first);
52159 +
52160 + r_tmp->subj_hash_size = num_subjs;
52161 + r_tmp->subj_hash =
52162 + (struct acl_subject_label **)
52163 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
52164 +
52165 + if (!r_tmp->subj_hash)
52166 + return -ENOMEM;
52167 +
52168 + err = copy_user_allowedips(r_tmp);
52169 + if (err)
52170 + return err;
52171 +
52172 + /* copy domain info */
52173 + if (r_tmp->domain_children != NULL) {
52174 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
52175 + if (domainlist == NULL)
52176 + return -ENOMEM;
52177 +
52178 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
52179 + return -EFAULT;
52180 +
52181 + r_tmp->domain_children = domainlist;
52182 + }
52183 +
52184 + err = copy_user_transitions(r_tmp);
52185 + if (err)
52186 + return err;
52187 +
52188 + memset(r_tmp->subj_hash, 0,
52189 + r_tmp->subj_hash_size *
52190 + sizeof (struct acl_subject_label *));
52191 +
52192 + err = copy_user_subjs(r_tmp->hash->first, r_tmp);
52193 +
52194 + if (err)
52195 + return err;
52196 +
52197 + /* set nested subject list to null */
52198 + r_tmp->hash->first = NULL;
52199 +
52200 + insert_acl_role_label(r_tmp);
52201 + }
52202 +
52203 + if (default_role == NULL || kernel_role == NULL)
52204 + return -EINVAL;
52205 +
52206 + return err;
52207 +}
52208 +
52209 +static int
52210 +gracl_init(struct gr_arg *args)
52211 +{
52212 + int error = 0;
52213 +
52214 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
52215 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
52216 +
52217 + if (init_variables(args)) {
52218 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
52219 + error = -ENOMEM;
52220 + free_variables();
52221 + goto out;
52222 + }
52223 +
52224 + error = copy_user_acl(args);
52225 + free_init_variables();
52226 + if (error) {
52227 + free_variables();
52228 + goto out;
52229 + }
52230 +
52231 + if ((error = gr_set_acls(0))) {
52232 + free_variables();
52233 + goto out;
52234 + }
52235 +
52236 + pax_open_kernel();
52237 + gr_status |= GR_READY;
52238 + pax_close_kernel();
52239 +
52240 + out:
52241 + return error;
52242 +}
52243 +
52244 +/* derived from glibc fnmatch() 0: match, 1: no match*/
52245 +
52246 +static int
52247 +glob_match(const char *p, const char *n)
52248 +{
52249 + char c;
52250 +
52251 + while ((c = *p++) != '\0') {
52252 + switch (c) {
52253 + case '?':
52254 + if (*n == '\0')
52255 + return 1;
52256 + else if (*n == '/')
52257 + return 1;
52258 + break;
52259 + case '\\':
52260 + if (*n != c)
52261 + return 1;
52262 + break;
52263 + case '*':
52264 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
52265 + if (*n == '/')
52266 + return 1;
52267 + else if (c == '?') {
52268 + if (*n == '\0')
52269 + return 1;
52270 + else
52271 + ++n;
52272 + }
52273 + }
52274 + if (c == '\0') {
52275 + return 0;
52276 + } else {
52277 + const char *endp;
52278 +
52279 + if ((endp = strchr(n, '/')) == NULL)
52280 + endp = n + strlen(n);
52281 +
52282 + if (c == '[') {
52283 + for (--p; n < endp; ++n)
52284 + if (!glob_match(p, n))
52285 + return 0;
52286 + } else if (c == '/') {
52287 + while (*n != '\0' && *n != '/')
52288 + ++n;
52289 + if (*n == '/' && !glob_match(p, n + 1))
52290 + return 0;
52291 + } else {
52292 + for (--p; n < endp; ++n)
52293 + if (*n == c && !glob_match(p, n))
52294 + return 0;
52295 + }
52296 +
52297 + return 1;
52298 + }
52299 + case '[':
52300 + {
52301 + int not;
52302 + char cold;
52303 +
52304 + if (*n == '\0' || *n == '/')
52305 + return 1;
52306 +
52307 + not = (*p == '!' || *p == '^');
52308 + if (not)
52309 + ++p;
52310 +
52311 + c = *p++;
52312 + for (;;) {
52313 + unsigned char fn = (unsigned char)*n;
52314 +
52315 + if (c == '\0')
52316 + return 1;
52317 + else {
52318 + if (c == fn)
52319 + goto matched;
52320 + cold = c;
52321 + c = *p++;
52322 +
52323 + if (c == '-' && *p != ']') {
52324 + unsigned char cend = *p++;
52325 +
52326 + if (cend == '\0')
52327 + return 1;
52328 +
52329 + if (cold <= fn && fn <= cend)
52330 + goto matched;
52331 +
52332 + c = *p++;
52333 + }
52334 + }
52335 +
52336 + if (c == ']')
52337 + break;
52338 + }
52339 + if (!not)
52340 + return 1;
52341 + break;
52342 + matched:
52343 + while (c != ']') {
52344 + if (c == '\0')
52345 + return 1;
52346 +
52347 + c = *p++;
52348 + }
52349 + if (not)
52350 + return 1;
52351 + }
52352 + break;
52353 + default:
52354 + if (c != *n)
52355 + return 1;
52356 + }
52357 +
52358 + ++n;
52359 + }
52360 +
52361 + if (*n == '\0')
52362 + return 0;
52363 +
52364 + if (*n == '/')
52365 + return 0;
52366 +
52367 + return 1;
52368 +}
52369 +
52370 +static struct acl_object_label *
52371 +chk_glob_label(struct acl_object_label *globbed,
52372 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
52373 +{
52374 + struct acl_object_label *tmp;
52375 +
52376 + if (*path == NULL)
52377 + *path = gr_to_filename_nolock(dentry, mnt);
52378 +
52379 + tmp = globbed;
52380 +
52381 + while (tmp) {
52382 + if (!glob_match(tmp->filename, *path))
52383 + return tmp;
52384 + tmp = tmp->next;
52385 + }
52386 +
52387 + return NULL;
52388 +}
52389 +
52390 +static struct acl_object_label *
52391 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
52392 + const ino_t curr_ino, const dev_t curr_dev,
52393 + const struct acl_subject_label *subj, char **path, const int checkglob)
52394 +{
52395 + struct acl_subject_label *tmpsubj;
52396 + struct acl_object_label *retval;
52397 + struct acl_object_label *retval2;
52398 +
52399 + tmpsubj = (struct acl_subject_label *) subj;
52400 + read_lock(&gr_inode_lock);
52401 + do {
52402 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
52403 + if (retval) {
52404 + if (checkglob && retval->globbed) {
52405 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
52406 + if (retval2)
52407 + retval = retval2;
52408 + }
52409 + break;
52410 + }
52411 + } while ((tmpsubj = tmpsubj->parent_subject));
52412 + read_unlock(&gr_inode_lock);
52413 +
52414 + return retval;
52415 +}
52416 +
52417 +static __inline__ struct acl_object_label *
52418 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
52419 + struct dentry *curr_dentry,
52420 + const struct acl_subject_label *subj, char **path, const int checkglob)
52421 +{
52422 + int newglob = checkglob;
52423 + ino_t inode;
52424 + dev_t device;
52425 +
52426 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
52427 + as we don't want a / * rule to match instead of the / object
52428 + don't do this for create lookups that call this function though, since they're looking up
52429 + on the parent and thus need globbing checks on all paths
52430 + */
52431 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
52432 + newglob = GR_NO_GLOB;
52433 +
52434 + spin_lock(&curr_dentry->d_lock);
52435 + inode = curr_dentry->d_inode->i_ino;
52436 + device = __get_dev(curr_dentry);
52437 + spin_unlock(&curr_dentry->d_lock);
52438 +
52439 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
52440 +}
52441 +
52442 +static struct acl_object_label *
52443 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
52444 + const struct acl_subject_label *subj, char *path, const int checkglob)
52445 +{
52446 + struct dentry *dentry = (struct dentry *) l_dentry;
52447 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
52448 + struct mount *real_mnt = real_mount(mnt);
52449 + struct acl_object_label *retval;
52450 + struct dentry *parent;
52451 +
52452 + write_seqlock(&rename_lock);
52453 + br_read_lock(vfsmount_lock);
52454 +
52455 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
52456 +#ifdef CONFIG_NET
52457 + mnt == sock_mnt ||
52458 +#endif
52459 +#ifdef CONFIG_HUGETLBFS
52460 + (mnt == hugetlbfs_vfsmount && dentry->d_inode->i_nlink == 0) ||
52461 +#endif
52462 + /* ignore Eric Biederman */
52463 + IS_PRIVATE(l_dentry->d_inode))) {
52464 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
52465 + goto out;
52466 + }
52467 +
52468 + for (;;) {
52469 + if (dentry == real_root.dentry && mnt == real_root.mnt)
52470 + break;
52471 +
52472 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
52473 + if (!mnt_has_parent(real_mnt))
52474 + break;
52475 +
52476 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
52477 + if (retval != NULL)
52478 + goto out;
52479 +
52480 + dentry = real_mnt->mnt_mountpoint;
52481 + real_mnt = real_mnt->mnt_parent;
52482 + mnt = &real_mnt->mnt;
52483 + continue;
52484 + }
52485 +
52486 + parent = dentry->d_parent;
52487 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
52488 + if (retval != NULL)
52489 + goto out;
52490 +
52491 + dentry = parent;
52492 + }
52493 +
52494 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
52495 +
52496 + /* real_root is pinned so we don't have to hold a reference */
52497 + if (retval == NULL)
52498 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
52499 +out:
52500 + br_read_unlock(vfsmount_lock);
52501 + write_sequnlock(&rename_lock);
52502 +
52503 + BUG_ON(retval == NULL);
52504 +
52505 + return retval;
52506 +}
52507 +
52508 +static __inline__ struct acl_object_label *
52509 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
52510 + const struct acl_subject_label *subj)
52511 +{
52512 + char *path = NULL;
52513 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
52514 +}
52515 +
52516 +static __inline__ struct acl_object_label *
52517 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
52518 + const struct acl_subject_label *subj)
52519 +{
52520 + char *path = NULL;
52521 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
52522 +}
52523 +
52524 +static __inline__ struct acl_object_label *
52525 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
52526 + const struct acl_subject_label *subj, char *path)
52527 +{
52528 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
52529 +}
52530 +
52531 +static struct acl_subject_label *
52532 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
52533 + const struct acl_role_label *role)
52534 +{
52535 + struct dentry *dentry = (struct dentry *) l_dentry;
52536 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
52537 + struct mount *real_mnt = real_mount(mnt);
52538 + struct acl_subject_label *retval;
52539 + struct dentry *parent;
52540 +
52541 + write_seqlock(&rename_lock);
52542 + br_read_lock(vfsmount_lock);
52543 +
52544 + for (;;) {
52545 + if (dentry == real_root.dentry && mnt == real_root.mnt)
52546 + break;
52547 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
52548 + if (!mnt_has_parent(real_mnt))
52549 + break;
52550 +
52551 + spin_lock(&dentry->d_lock);
52552 + read_lock(&gr_inode_lock);
52553 + retval =
52554 + lookup_acl_subj_label(dentry->d_inode->i_ino,
52555 + __get_dev(dentry), role);
52556 + read_unlock(&gr_inode_lock);
52557 + spin_unlock(&dentry->d_lock);
52558 + if (retval != NULL)
52559 + goto out;
52560 +
52561 + dentry = real_mnt->mnt_mountpoint;
52562 + real_mnt = real_mnt->mnt_parent;
52563 + mnt = &real_mnt->mnt;
52564 + continue;
52565 + }
52566 +
52567 + spin_lock(&dentry->d_lock);
52568 + read_lock(&gr_inode_lock);
52569 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
52570 + __get_dev(dentry), role);
52571 + read_unlock(&gr_inode_lock);
52572 + parent = dentry->d_parent;
52573 + spin_unlock(&dentry->d_lock);
52574 +
52575 + if (retval != NULL)
52576 + goto out;
52577 +
52578 + dentry = parent;
52579 + }
52580 +
52581 + spin_lock(&dentry->d_lock);
52582 + read_lock(&gr_inode_lock);
52583 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
52584 + __get_dev(dentry), role);
52585 + read_unlock(&gr_inode_lock);
52586 + spin_unlock(&dentry->d_lock);
52587 +
52588 + if (unlikely(retval == NULL)) {
52589 + /* real_root is pinned, we don't need to hold a reference */
52590 + read_lock(&gr_inode_lock);
52591 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
52592 + __get_dev(real_root.dentry), role);
52593 + read_unlock(&gr_inode_lock);
52594 + }
52595 +out:
52596 + br_read_unlock(vfsmount_lock);
52597 + write_sequnlock(&rename_lock);
52598 +
52599 + BUG_ON(retval == NULL);
52600 +
52601 + return retval;
52602 +}
52603 +
52604 +static void
52605 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
52606 +{
52607 + struct task_struct *task = current;
52608 + const struct cred *cred = current_cred();
52609 +
52610 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
52611 + cred->uid, cred->gid, task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
52612 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
52613 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
52614 +
52615 + return;
52616 +}
52617 +
52618 +static void
52619 +gr_log_learn_sysctl(const char *path, const __u32 mode)
52620 +{
52621 + struct task_struct *task = current;
52622 + const struct cred *cred = current_cred();
52623 +
52624 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
52625 + cred->uid, cred->gid, task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
52626 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
52627 + 1UL, 1UL, path, (unsigned long) mode, &task->signal->saved_ip);
52628 +
52629 + return;
52630 +}
52631 +
52632 +static void
52633 +gr_log_learn_id_change(const char type, const unsigned int real,
52634 + const unsigned int effective, const unsigned int fs)
52635 +{
52636 + struct task_struct *task = current;
52637 + const struct cred *cred = current_cred();
52638 +
52639 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
52640 + cred->uid, cred->gid, task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
52641 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
52642 + type, real, effective, fs, &task->signal->saved_ip);
52643 +
52644 + return;
52645 +}
52646 +
52647 +__u32
52648 +gr_search_file(const struct dentry * dentry, const __u32 mode,
52649 + const struct vfsmount * mnt)
52650 +{
52651 + __u32 retval = mode;
52652 + struct acl_subject_label *curracl;
52653 + struct acl_object_label *currobj;
52654 +
52655 + if (unlikely(!(gr_status & GR_READY)))
52656 + return (mode & ~GR_AUDITS);
52657 +
52658 + curracl = current->acl;
52659 +
52660 + currobj = chk_obj_label(dentry, mnt, curracl);
52661 + retval = currobj->mode & mode;
52662 +
52663 + /* if we're opening a specified transfer file for writing
52664 + (e.g. /dev/initctl), then transfer our role to init
52665 + */
52666 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
52667 + current->role->roletype & GR_ROLE_PERSIST)) {
52668 + struct task_struct *task = init_pid_ns.child_reaper;
52669 +
52670 + if (task->role != current->role) {
52671 + task->acl_sp_role = 0;
52672 + task->acl_role_id = current->acl_role_id;
52673 + task->role = current->role;
52674 + rcu_read_lock();
52675 + read_lock(&grsec_exec_file_lock);
52676 + gr_apply_subject_to_task(task);
52677 + read_unlock(&grsec_exec_file_lock);
52678 + rcu_read_unlock();
52679 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
52680 + }
52681 + }
52682 +
52683 + if (unlikely
52684 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
52685 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
52686 + __u32 new_mode = mode;
52687 +
52688 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
52689 +
52690 + retval = new_mode;
52691 +
52692 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
52693 + new_mode |= GR_INHERIT;
52694 +
52695 + if (!(mode & GR_NOLEARN))
52696 + gr_log_learn(dentry, mnt, new_mode);
52697 + }
52698 +
52699 + return retval;
52700 +}
52701 +
52702 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
52703 + const struct dentry *parent,
52704 + const struct vfsmount *mnt)
52705 +{
52706 + struct name_entry *match;
52707 + struct acl_object_label *matchpo;
52708 + struct acl_subject_label *curracl;
52709 + char *path;
52710 +
52711 + if (unlikely(!(gr_status & GR_READY)))
52712 + return NULL;
52713 +
52714 + preempt_disable();
52715 + path = gr_to_filename_rbac(new_dentry, mnt);
52716 + match = lookup_name_entry_create(path);
52717 +
52718 + curracl = current->acl;
52719 +
52720 + if (match) {
52721 + read_lock(&gr_inode_lock);
52722 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
52723 + read_unlock(&gr_inode_lock);
52724 +
52725 + if (matchpo) {
52726 + preempt_enable();
52727 + return matchpo;
52728 + }
52729 + }
52730 +
52731 + // lookup parent
52732 +
52733 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
52734 +
52735 + preempt_enable();
52736 + return matchpo;
52737 +}
52738 +
52739 +__u32
52740 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
52741 + const struct vfsmount * mnt, const __u32 mode)
52742 +{
52743 + struct acl_object_label *matchpo;
52744 + __u32 retval;
52745 +
52746 + if (unlikely(!(gr_status & GR_READY)))
52747 + return (mode & ~GR_AUDITS);
52748 +
52749 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
52750 +
52751 + retval = matchpo->mode & mode;
52752 +
52753 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
52754 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
52755 + __u32 new_mode = mode;
52756 +
52757 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
52758 +
52759 + gr_log_learn(new_dentry, mnt, new_mode);
52760 + return new_mode;
52761 + }
52762 +
52763 + return retval;
52764 +}
52765 +
52766 +__u32
52767 +gr_check_link(const struct dentry * new_dentry,
52768 + const struct dentry * parent_dentry,
52769 + const struct vfsmount * parent_mnt,
52770 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
52771 +{
52772 + struct acl_object_label *obj;
52773 + __u32 oldmode, newmode;
52774 + __u32 needmode;
52775 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
52776 + GR_DELETE | GR_INHERIT;
52777 +
52778 + if (unlikely(!(gr_status & GR_READY)))
52779 + return (GR_CREATE | GR_LINK);
52780 +
52781 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
52782 + oldmode = obj->mode;
52783 +
52784 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
52785 + newmode = obj->mode;
52786 +
52787 + needmode = newmode & checkmodes;
52788 +
52789 + // old name for hardlink must have at least the permissions of the new name
52790 + if ((oldmode & needmode) != needmode)
52791 + goto bad;
52792 +
52793 + // if old name had restrictions/auditing, make sure the new name does as well
52794 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
52795 +
52796 + // don't allow hardlinking of suid/sgid files without permission
52797 + if (old_dentry->d_inode->i_mode & (S_ISUID | S_ISGID))
52798 + needmode |= GR_SETID;
52799 +
52800 + if ((newmode & needmode) != needmode)
52801 + goto bad;
52802 +
52803 + // enforce minimum permissions
52804 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
52805 + return newmode;
52806 +bad:
52807 + needmode = oldmode;
52808 + if (old_dentry->d_inode->i_mode & (S_ISUID | S_ISGID))
52809 + needmode |= GR_SETID;
52810 +
52811 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
52812 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
52813 + return (GR_CREATE | GR_LINK);
52814 + } else if (newmode & GR_SUPPRESS)
52815 + return GR_SUPPRESS;
52816 + else
52817 + return 0;
52818 +}
52819 +
52820 +int
52821 +gr_check_hidden_task(const struct task_struct *task)
52822 +{
52823 + if (unlikely(!(gr_status & GR_READY)))
52824 + return 0;
52825 +
52826 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
52827 + return 1;
52828 +
52829 + return 0;
52830 +}
52831 +
52832 +int
52833 +gr_check_protected_task(const struct task_struct *task)
52834 +{
52835 + if (unlikely(!(gr_status & GR_READY) || !task))
52836 + return 0;
52837 +
52838 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
52839 + task->acl != current->acl)
52840 + return 1;
52841 +
52842 + return 0;
52843 +}
52844 +
52845 +int
52846 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
52847 +{
52848 + struct task_struct *p;
52849 + int ret = 0;
52850 +
52851 + if (unlikely(!(gr_status & GR_READY) || !pid))
52852 + return ret;
52853 +
52854 + read_lock(&tasklist_lock);
52855 + do_each_pid_task(pid, type, p) {
52856 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
52857 + p->acl != current->acl) {
52858 + ret = 1;
52859 + goto out;
52860 + }
52861 + } while_each_pid_task(pid, type, p);
52862 +out:
52863 + read_unlock(&tasklist_lock);
52864 +
52865 + return ret;
52866 +}
52867 +
52868 +void
52869 +gr_copy_label(struct task_struct *tsk)
52870 +{
52871 + /* plain copying of fields is already done by dup_task_struct */
52872 + tsk->signal->used_accept = 0;
52873 + tsk->acl_sp_role = 0;
52874 + //tsk->acl_role_id = current->acl_role_id;
52875 + //tsk->acl = current->acl;
52876 + //tsk->role = current->role;
52877 + tsk->signal->curr_ip = current->signal->curr_ip;
52878 + tsk->signal->saved_ip = current->signal->saved_ip;
52879 + if (current->exec_file)
52880 + get_file(current->exec_file);
52881 + //tsk->exec_file = current->exec_file;
52882 + //tsk->is_writable = current->is_writable;
52883 + if (unlikely(current->signal->used_accept)) {
52884 + current->signal->curr_ip = 0;
52885 + current->signal->saved_ip = 0;
52886 + }
52887 +
52888 + return;
52889 +}
52890 +
52891 +static void
52892 +gr_set_proc_res(struct task_struct *task)
52893 +{
52894 + struct acl_subject_label *proc;
52895 + unsigned short i;
52896 +
52897 + proc = task->acl;
52898 +
52899 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
52900 + return;
52901 +
52902 + for (i = 0; i < RLIM_NLIMITS; i++) {
52903 + if (!(proc->resmask & (1 << i)))
52904 + continue;
52905 +
52906 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
52907 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
52908 + }
52909 +
52910 + return;
52911 +}
52912 +
52913 +extern int __gr_process_user_ban(struct user_struct *user);
52914 +
52915 +int
52916 +gr_check_user_change(int real, int effective, int fs)
52917 +{
52918 + unsigned int i;
52919 + __u16 num;
52920 + uid_t *uidlist;
52921 + int curuid;
52922 + int realok = 0;
52923 + int effectiveok = 0;
52924 + int fsok = 0;
52925 +
52926 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
52927 + struct user_struct *user;
52928 +
52929 + if (real == -1)
52930 + goto skipit;
52931 +
52932 + user = find_user(real);
52933 + if (user == NULL)
52934 + goto skipit;
52935 +
52936 + if (__gr_process_user_ban(user)) {
52937 + /* for find_user */
52938 + free_uid(user);
52939 + return 1;
52940 + }
52941 +
52942 + /* for find_user */
52943 + free_uid(user);
52944 +
52945 +skipit:
52946 +#endif
52947 +
52948 + if (unlikely(!(gr_status & GR_READY)))
52949 + return 0;
52950 +
52951 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
52952 + gr_log_learn_id_change('u', real, effective, fs);
52953 +
52954 + num = current->acl->user_trans_num;
52955 + uidlist = current->acl->user_transitions;
52956 +
52957 + if (uidlist == NULL)
52958 + return 0;
52959 +
52960 + if (real == -1)
52961 + realok = 1;
52962 + if (effective == -1)
52963 + effectiveok = 1;
52964 + if (fs == -1)
52965 + fsok = 1;
52966 +
52967 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
52968 + for (i = 0; i < num; i++) {
52969 + curuid = (int)uidlist[i];
52970 + if (real == curuid)
52971 + realok = 1;
52972 + if (effective == curuid)
52973 + effectiveok = 1;
52974 + if (fs == curuid)
52975 + fsok = 1;
52976 + }
52977 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
52978 + for (i = 0; i < num; i++) {
52979 + curuid = (int)uidlist[i];
52980 + if (real == curuid)
52981 + break;
52982 + if (effective == curuid)
52983 + break;
52984 + if (fs == curuid)
52985 + break;
52986 + }
52987 + /* not in deny list */
52988 + if (i == num) {
52989 + realok = 1;
52990 + effectiveok = 1;
52991 + fsok = 1;
52992 + }
52993 + }
52994 +
52995 + if (realok && effectiveok && fsok)
52996 + return 0;
52997 + else {
52998 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : fs) : effective) : real);
52999 + return 1;
53000 + }
53001 +}
53002 +
53003 +int
53004 +gr_check_group_change(int real, int effective, int fs)
53005 +{
53006 + unsigned int i;
53007 + __u16 num;
53008 + gid_t *gidlist;
53009 + int curgid;
53010 + int realok = 0;
53011 + int effectiveok = 0;
53012 + int fsok = 0;
53013 +
53014 + if (unlikely(!(gr_status & GR_READY)))
53015 + return 0;
53016 +
53017 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
53018 + gr_log_learn_id_change('g', real, effective, fs);
53019 +
53020 + num = current->acl->group_trans_num;
53021 + gidlist = current->acl->group_transitions;
53022 +
53023 + if (gidlist == NULL)
53024 + return 0;
53025 +
53026 + if (real == -1)
53027 + realok = 1;
53028 + if (effective == -1)
53029 + effectiveok = 1;
53030 + if (fs == -1)
53031 + fsok = 1;
53032 +
53033 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
53034 + for (i = 0; i < num; i++) {
53035 + curgid = (int)gidlist[i];
53036 + if (real == curgid)
53037 + realok = 1;
53038 + if (effective == curgid)
53039 + effectiveok = 1;
53040 + if (fs == curgid)
53041 + fsok = 1;
53042 + }
53043 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
53044 + for (i = 0; i < num; i++) {
53045 + curgid = (int)gidlist[i];
53046 + if (real == curgid)
53047 + break;
53048 + if (effective == curgid)
53049 + break;
53050 + if (fs == curgid)
53051 + break;
53052 + }
53053 + /* not in deny list */
53054 + if (i == num) {
53055 + realok = 1;
53056 + effectiveok = 1;
53057 + fsok = 1;
53058 + }
53059 + }
53060 +
53061 + if (realok && effectiveok && fsok)
53062 + return 0;
53063 + else {
53064 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : fs) : effective) : real);
53065 + return 1;
53066 + }
53067 +}
53068 +
53069 +extern int gr_acl_is_capable(const int cap);
53070 +
53071 +void
53072 +gr_set_role_label(struct task_struct *task, const uid_t uid, const uid_t gid)
53073 +{
53074 + struct acl_role_label *role = task->role;
53075 + struct acl_subject_label *subj = NULL;
53076 + struct acl_object_label *obj;
53077 + struct file *filp;
53078 +
53079 + if (unlikely(!(gr_status & GR_READY)))
53080 + return;
53081 +
53082 + filp = task->exec_file;
53083 +
53084 + /* kernel process, we'll give them the kernel role */
53085 + if (unlikely(!filp)) {
53086 + task->role = kernel_role;
53087 + task->acl = kernel_role->root_label;
53088 + return;
53089 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
53090 + role = lookup_acl_role_label(task, uid, gid);
53091 +
53092 + /* don't change the role if we're not a privileged process */
53093 + if (role && task->role != role &&
53094 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
53095 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
53096 + return;
53097 +
53098 + /* perform subject lookup in possibly new role
53099 + we can use this result below in the case where role == task->role
53100 + */
53101 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
53102 +
53103 + /* if we changed uid/gid, but result in the same role
53104 + and are using inheritance, don't lose the inherited subject
53105 + if current subject is other than what normal lookup
53106 + would result in, we arrived via inheritance, don't
53107 + lose subject
53108 + */
53109 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
53110 + (subj == task->acl)))
53111 + task->acl = subj;
53112 +
53113 + task->role = role;
53114 +
53115 + task->is_writable = 0;
53116 +
53117 + /* ignore additional mmap checks for processes that are writable
53118 + by the default ACL */
53119 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
53120 + if (unlikely(obj->mode & GR_WRITE))
53121 + task->is_writable = 1;
53122 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
53123 + if (unlikely(obj->mode & GR_WRITE))
53124 + task->is_writable = 1;
53125 +
53126 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
53127 + printk(KERN_ALERT "Set role label for (%s:%d): role:%s, subject:%s\n", task->comm, task->pid, task->role->rolename, task->acl->filename);
53128 +#endif
53129 +
53130 + gr_set_proc_res(task);
53131 +
53132 + return;
53133 +}
53134 +
53135 +int
53136 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
53137 + const int unsafe_flags)
53138 +{
53139 + struct task_struct *task = current;
53140 + struct acl_subject_label *newacl;
53141 + struct acl_object_label *obj;
53142 + __u32 retmode;
53143 +
53144 + if (unlikely(!(gr_status & GR_READY)))
53145 + return 0;
53146 +
53147 + newacl = chk_subj_label(dentry, mnt, task->role);
53148 +
53149 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
53150 + did an exec
53151 + */
53152 + rcu_read_lock();
53153 + read_lock(&tasklist_lock);
53154 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
53155 + (task->parent->acl->mode & GR_POVERRIDE))) {
53156 + read_unlock(&tasklist_lock);
53157 + rcu_read_unlock();
53158 + goto skip_check;
53159 + }
53160 + read_unlock(&tasklist_lock);
53161 + rcu_read_unlock();
53162 +
53163 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
53164 + !(task->role->roletype & GR_ROLE_GOD) &&
53165 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
53166 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
53167 + if (unsafe_flags & LSM_UNSAFE_SHARE)
53168 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
53169 + else
53170 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
53171 + return -EACCES;
53172 + }
53173 +
53174 +skip_check:
53175 +
53176 + obj = chk_obj_label(dentry, mnt, task->acl);
53177 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
53178 +
53179 + if (!(task->acl->mode & GR_INHERITLEARN) &&
53180 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
53181 + if (obj->nested)
53182 + task->acl = obj->nested;
53183 + else
53184 + task->acl = newacl;
53185 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
53186 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
53187 +
53188 + task->is_writable = 0;
53189 +
53190 + /* ignore additional mmap checks for processes that are writable
53191 + by the default ACL */
53192 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
53193 + if (unlikely(obj->mode & GR_WRITE))
53194 + task->is_writable = 1;
53195 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
53196 + if (unlikely(obj->mode & GR_WRITE))
53197 + task->is_writable = 1;
53198 +
53199 + gr_set_proc_res(task);
53200 +
53201 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
53202 + printk(KERN_ALERT "Set subject label for (%s:%d): role:%s, subject:%s\n", task->comm, task->pid, task->role->rolename, task->acl->filename);
53203 +#endif
53204 + return 0;
53205 +}
53206 +
53207 +/* always called with valid inodev ptr */
53208 +static void
53209 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
53210 +{
53211 + struct acl_object_label *matchpo;
53212 + struct acl_subject_label *matchps;
53213 + struct acl_subject_label *subj;
53214 + struct acl_role_label *role;
53215 + unsigned int x;
53216 +
53217 + FOR_EACH_ROLE_START(role)
53218 + FOR_EACH_SUBJECT_START(role, subj, x)
53219 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
53220 + matchpo->mode |= GR_DELETED;
53221 + FOR_EACH_SUBJECT_END(subj,x)
53222 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
53223 + if (subj->inode == ino && subj->device == dev)
53224 + subj->mode |= GR_DELETED;
53225 + FOR_EACH_NESTED_SUBJECT_END(subj)
53226 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
53227 + matchps->mode |= GR_DELETED;
53228 + FOR_EACH_ROLE_END(role)
53229 +
53230 + inodev->nentry->deleted = 1;
53231 +
53232 + return;
53233 +}
53234 +
53235 +void
53236 +gr_handle_delete(const ino_t ino, const dev_t dev)
53237 +{
53238 + struct inodev_entry *inodev;
53239 +
53240 + if (unlikely(!(gr_status & GR_READY)))
53241 + return;
53242 +
53243 + write_lock(&gr_inode_lock);
53244 + inodev = lookup_inodev_entry(ino, dev);
53245 + if (inodev != NULL)
53246 + do_handle_delete(inodev, ino, dev);
53247 + write_unlock(&gr_inode_lock);
53248 +
53249 + return;
53250 +}
53251 +
53252 +static void
53253 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
53254 + const ino_t newinode, const dev_t newdevice,
53255 + struct acl_subject_label *subj)
53256 +{
53257 + unsigned int index = fhash(oldinode, olddevice, subj->obj_hash_size);
53258 + struct acl_object_label *match;
53259 +
53260 + match = subj->obj_hash[index];
53261 +
53262 + while (match && (match->inode != oldinode ||
53263 + match->device != olddevice ||
53264 + !(match->mode & GR_DELETED)))
53265 + match = match->next;
53266 +
53267 + if (match && (match->inode == oldinode)
53268 + && (match->device == olddevice)
53269 + && (match->mode & GR_DELETED)) {
53270 + if (match->prev == NULL) {
53271 + subj->obj_hash[index] = match->next;
53272 + if (match->next != NULL)
53273 + match->next->prev = NULL;
53274 + } else {
53275 + match->prev->next = match->next;
53276 + if (match->next != NULL)
53277 + match->next->prev = match->prev;
53278 + }
53279 + match->prev = NULL;
53280 + match->next = NULL;
53281 + match->inode = newinode;
53282 + match->device = newdevice;
53283 + match->mode &= ~GR_DELETED;
53284 +
53285 + insert_acl_obj_label(match, subj);
53286 + }
53287 +
53288 + return;
53289 +}
53290 +
53291 +static void
53292 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
53293 + const ino_t newinode, const dev_t newdevice,
53294 + struct acl_role_label *role)
53295 +{
53296 + unsigned int index = fhash(oldinode, olddevice, role->subj_hash_size);
53297 + struct acl_subject_label *match;
53298 +
53299 + match = role->subj_hash[index];
53300 +
53301 + while (match && (match->inode != oldinode ||
53302 + match->device != olddevice ||
53303 + !(match->mode & GR_DELETED)))
53304 + match = match->next;
53305 +
53306 + if (match && (match->inode == oldinode)
53307 + && (match->device == olddevice)
53308 + && (match->mode & GR_DELETED)) {
53309 + if (match->prev == NULL) {
53310 + role->subj_hash[index] = match->next;
53311 + if (match->next != NULL)
53312 + match->next->prev = NULL;
53313 + } else {
53314 + match->prev->next = match->next;
53315 + if (match->next != NULL)
53316 + match->next->prev = match->prev;
53317 + }
53318 + match->prev = NULL;
53319 + match->next = NULL;
53320 + match->inode = newinode;
53321 + match->device = newdevice;
53322 + match->mode &= ~GR_DELETED;
53323 +
53324 + insert_acl_subj_label(match, role);
53325 + }
53326 +
53327 + return;
53328 +}
53329 +
53330 +static void
53331 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
53332 + const ino_t newinode, const dev_t newdevice)
53333 +{
53334 + unsigned int index = fhash(oldinode, olddevice, inodev_set.i_size);
53335 + struct inodev_entry *match;
53336 +
53337 + match = inodev_set.i_hash[index];
53338 +
53339 + while (match && (match->nentry->inode != oldinode ||
53340 + match->nentry->device != olddevice || !match->nentry->deleted))
53341 + match = match->next;
53342 +
53343 + if (match && (match->nentry->inode == oldinode)
53344 + && (match->nentry->device == olddevice) &&
53345 + match->nentry->deleted) {
53346 + if (match->prev == NULL) {
53347 + inodev_set.i_hash[index] = match->next;
53348 + if (match->next != NULL)
53349 + match->next->prev = NULL;
53350 + } else {
53351 + match->prev->next = match->next;
53352 + if (match->next != NULL)
53353 + match->next->prev = match->prev;
53354 + }
53355 + match->prev = NULL;
53356 + match->next = NULL;
53357 + match->nentry->inode = newinode;
53358 + match->nentry->device = newdevice;
53359 + match->nentry->deleted = 0;
53360 +
53361 + insert_inodev_entry(match);
53362 + }
53363 +
53364 + return;
53365 +}
53366 +
53367 +static void
53368 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
53369 +{
53370 + struct acl_subject_label *subj;
53371 + struct acl_role_label *role;
53372 + unsigned int x;
53373 +
53374 + FOR_EACH_ROLE_START(role)
53375 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
53376 +
53377 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
53378 + if ((subj->inode == ino) && (subj->device == dev)) {
53379 + subj->inode = ino;
53380 + subj->device = dev;
53381 + }
53382 + FOR_EACH_NESTED_SUBJECT_END(subj)
53383 + FOR_EACH_SUBJECT_START(role, subj, x)
53384 + update_acl_obj_label(matchn->inode, matchn->device,
53385 + ino, dev, subj);
53386 + FOR_EACH_SUBJECT_END(subj,x)
53387 + FOR_EACH_ROLE_END(role)
53388 +
53389 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
53390 +
53391 + return;
53392 +}
53393 +
53394 +static void
53395 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
53396 + const struct vfsmount *mnt)
53397 +{
53398 + ino_t ino = dentry->d_inode->i_ino;
53399 + dev_t dev = __get_dev(dentry);
53400 +
53401 + __do_handle_create(matchn, ino, dev);
53402 +
53403 + return;
53404 +}
53405 +
53406 +void
53407 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
53408 +{
53409 + struct name_entry *matchn;
53410 +
53411 + if (unlikely(!(gr_status & GR_READY)))
53412 + return;
53413 +
53414 + preempt_disable();
53415 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
53416 +
53417 + if (unlikely((unsigned long)matchn)) {
53418 + write_lock(&gr_inode_lock);
53419 + do_handle_create(matchn, dentry, mnt);
53420 + write_unlock(&gr_inode_lock);
53421 + }
53422 + preempt_enable();
53423 +
53424 + return;
53425 +}
53426 +
53427 +void
53428 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
53429 +{
53430 + struct name_entry *matchn;
53431 +
53432 + if (unlikely(!(gr_status & GR_READY)))
53433 + return;
53434 +
53435 + preempt_disable();
53436 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
53437 +
53438 + if (unlikely((unsigned long)matchn)) {
53439 + write_lock(&gr_inode_lock);
53440 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
53441 + write_unlock(&gr_inode_lock);
53442 + }
53443 + preempt_enable();
53444 +
53445 + return;
53446 +}
53447 +
53448 +void
53449 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
53450 + struct dentry *old_dentry,
53451 + struct dentry *new_dentry,
53452 + struct vfsmount *mnt, const __u8 replace)
53453 +{
53454 + struct name_entry *matchn;
53455 + struct inodev_entry *inodev;
53456 + struct inode *inode = new_dentry->d_inode;
53457 + ino_t old_ino = old_dentry->d_inode->i_ino;
53458 + dev_t old_dev = __get_dev(old_dentry);
53459 +
53460 + /* vfs_rename swaps the name and parent link for old_dentry and
53461 + new_dentry
53462 + at this point, old_dentry has the new name, parent link, and inode
53463 + for the renamed file
53464 + if a file is being replaced by a rename, new_dentry has the inode
53465 + and name for the replaced file
53466 + */
53467 +
53468 + if (unlikely(!(gr_status & GR_READY)))
53469 + return;
53470 +
53471 + preempt_disable();
53472 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
53473 +
53474 + /* we wouldn't have to check d_inode if it weren't for
53475 + NFS silly-renaming
53476 + */
53477 +
53478 + write_lock(&gr_inode_lock);
53479 + if (unlikely(replace && inode)) {
53480 + ino_t new_ino = inode->i_ino;
53481 + dev_t new_dev = __get_dev(new_dentry);
53482 +
53483 + inodev = lookup_inodev_entry(new_ino, new_dev);
53484 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
53485 + do_handle_delete(inodev, new_ino, new_dev);
53486 + }
53487 +
53488 + inodev = lookup_inodev_entry(old_ino, old_dev);
53489 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
53490 + do_handle_delete(inodev, old_ino, old_dev);
53491 +
53492 + if (unlikely((unsigned long)matchn))
53493 + do_handle_create(matchn, old_dentry, mnt);
53494 +
53495 + write_unlock(&gr_inode_lock);
53496 + preempt_enable();
53497 +
53498 + return;
53499 +}
53500 +
53501 +static int
53502 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
53503 + unsigned char **sum)
53504 +{
53505 + struct acl_role_label *r;
53506 + struct role_allowed_ip *ipp;
53507 + struct role_transition *trans;
53508 + unsigned int i;
53509 + int found = 0;
53510 + u32 curr_ip = current->signal->curr_ip;
53511 +
53512 + current->signal->saved_ip = curr_ip;
53513 +
53514 + /* check transition table */
53515 +
53516 + for (trans = current->role->transitions; trans; trans = trans->next) {
53517 + if (!strcmp(rolename, trans->rolename)) {
53518 + found = 1;
53519 + break;
53520 + }
53521 + }
53522 +
53523 + if (!found)
53524 + return 0;
53525 +
53526 + /* handle special roles that do not require authentication
53527 + and check ip */
53528 +
53529 + FOR_EACH_ROLE_START(r)
53530 + if (!strcmp(rolename, r->rolename) &&
53531 + (r->roletype & GR_ROLE_SPECIAL)) {
53532 + found = 0;
53533 + if (r->allowed_ips != NULL) {
53534 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
53535 + if ((ntohl(curr_ip) & ipp->netmask) ==
53536 + (ntohl(ipp->addr) & ipp->netmask))
53537 + found = 1;
53538 + }
53539 + } else
53540 + found = 2;
53541 + if (!found)
53542 + return 0;
53543 +
53544 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
53545 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
53546 + *salt = NULL;
53547 + *sum = NULL;
53548 + return 1;
53549 + }
53550 + }
53551 + FOR_EACH_ROLE_END(r)
53552 +
53553 + for (i = 0; i < num_sprole_pws; i++) {
53554 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
53555 + *salt = acl_special_roles[i]->salt;
53556 + *sum = acl_special_roles[i]->sum;
53557 + return 1;
53558 + }
53559 + }
53560 +
53561 + return 0;
53562 +}
53563 +
53564 +static void
53565 +assign_special_role(char *rolename)
53566 +{
53567 + struct acl_object_label *obj;
53568 + struct acl_role_label *r;
53569 + struct acl_role_label *assigned = NULL;
53570 + struct task_struct *tsk;
53571 + struct file *filp;
53572 +
53573 + FOR_EACH_ROLE_START(r)
53574 + if (!strcmp(rolename, r->rolename) &&
53575 + (r->roletype & GR_ROLE_SPECIAL)) {
53576 + assigned = r;
53577 + break;
53578 + }
53579 + FOR_EACH_ROLE_END(r)
53580 +
53581 + if (!assigned)
53582 + return;
53583 +
53584 + read_lock(&tasklist_lock);
53585 + read_lock(&grsec_exec_file_lock);
53586 +
53587 + tsk = current->real_parent;
53588 + if (tsk == NULL)
53589 + goto out_unlock;
53590 +
53591 + filp = tsk->exec_file;
53592 + if (filp == NULL)
53593 + goto out_unlock;
53594 +
53595 + tsk->is_writable = 0;
53596 +
53597 + tsk->acl_sp_role = 1;
53598 + tsk->acl_role_id = ++acl_sp_role_value;
53599 + tsk->role = assigned;
53600 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
53601 +
53602 + /* ignore additional mmap checks for processes that are writable
53603 + by the default ACL */
53604 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
53605 + if (unlikely(obj->mode & GR_WRITE))
53606 + tsk->is_writable = 1;
53607 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
53608 + if (unlikely(obj->mode & GR_WRITE))
53609 + tsk->is_writable = 1;
53610 +
53611 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
53612 + printk(KERN_ALERT "Assigning special role:%s subject:%s to process (%s:%d)\n", tsk->role->rolename, tsk->acl->filename, tsk->comm, tsk->pid);
53613 +#endif
53614 +
53615 +out_unlock:
53616 + read_unlock(&grsec_exec_file_lock);
53617 + read_unlock(&tasklist_lock);
53618 + return;
53619 +}
53620 +
53621 +int gr_check_secure_terminal(struct task_struct *task)
53622 +{
53623 + struct task_struct *p, *p2, *p3;
53624 + struct files_struct *files;
53625 + struct fdtable *fdt;
53626 + struct file *our_file = NULL, *file;
53627 + int i;
53628 +
53629 + if (task->signal->tty == NULL)
53630 + return 1;
53631 +
53632 + files = get_files_struct(task);
53633 + if (files != NULL) {
53634 + rcu_read_lock();
53635 + fdt = files_fdtable(files);
53636 + for (i=0; i < fdt->max_fds; i++) {
53637 + file = fcheck_files(files, i);
53638 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
53639 + get_file(file);
53640 + our_file = file;
53641 + }
53642 + }
53643 + rcu_read_unlock();
53644 + put_files_struct(files);
53645 + }
53646 +
53647 + if (our_file == NULL)
53648 + return 1;
53649 +
53650 + read_lock(&tasklist_lock);
53651 + do_each_thread(p2, p) {
53652 + files = get_files_struct(p);
53653 + if (files == NULL ||
53654 + (p->signal && p->signal->tty == task->signal->tty)) {
53655 + if (files != NULL)
53656 + put_files_struct(files);
53657 + continue;
53658 + }
53659 + rcu_read_lock();
53660 + fdt = files_fdtable(files);
53661 + for (i=0; i < fdt->max_fds; i++) {
53662 + file = fcheck_files(files, i);
53663 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
53664 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
53665 + p3 = task;
53666 + while (p3->pid > 0) {
53667 + if (p3 == p)
53668 + break;
53669 + p3 = p3->real_parent;
53670 + }
53671 + if (p3 == p)
53672 + break;
53673 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
53674 + gr_handle_alertkill(p);
53675 + rcu_read_unlock();
53676 + put_files_struct(files);
53677 + read_unlock(&tasklist_lock);
53678 + fput(our_file);
53679 + return 0;
53680 + }
53681 + }
53682 + rcu_read_unlock();
53683 + put_files_struct(files);
53684 + } while_each_thread(p2, p);
53685 + read_unlock(&tasklist_lock);
53686 +
53687 + fput(our_file);
53688 + return 1;
53689 +}
53690 +
53691 +ssize_t
53692 +write_grsec_handler(struct file *file, const char * buf, size_t count, loff_t *ppos)
53693 +{
53694 + struct gr_arg_wrapper uwrap;
53695 + unsigned char *sprole_salt = NULL;
53696 + unsigned char *sprole_sum = NULL;
53697 + int error = sizeof (struct gr_arg_wrapper);
53698 + int error2 = 0;
53699 +
53700 + mutex_lock(&gr_dev_mutex);
53701 +
53702 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
53703 + error = -EPERM;
53704 + goto out;
53705 + }
53706 +
53707 + if (count != sizeof (struct gr_arg_wrapper)) {
53708 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)sizeof(struct gr_arg_wrapper));
53709 + error = -EINVAL;
53710 + goto out;
53711 + }
53712 +
53713 +
53714 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
53715 + gr_auth_expires = 0;
53716 + gr_auth_attempts = 0;
53717 + }
53718 +
53719 + if (copy_from_user(&uwrap, buf, sizeof (struct gr_arg_wrapper))) {
53720 + error = -EFAULT;
53721 + goto out;
53722 + }
53723 +
53724 + if ((uwrap.version != GRSECURITY_VERSION) || (uwrap.size != sizeof(struct gr_arg))) {
53725 + error = -EINVAL;
53726 + goto out;
53727 + }
53728 +
53729 + if (copy_from_user(gr_usermode, uwrap.arg, sizeof (struct gr_arg))) {
53730 + error = -EFAULT;
53731 + goto out;
53732 + }
53733 +
53734 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
53735 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
53736 + time_after(gr_auth_expires, get_seconds())) {
53737 + error = -EBUSY;
53738 + goto out;
53739 + }
53740 +
53741 + /* if non-root trying to do anything other than use a special role,
53742 + do not attempt authentication, do not count towards authentication
53743 + locking
53744 + */
53745 +
53746 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
53747 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
53748 + current_uid()) {
53749 + error = -EPERM;
53750 + goto out;
53751 + }
53752 +
53753 + /* ensure pw and special role name are null terminated */
53754 +
53755 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
53756 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
53757 +
53758 + /* Okay.
53759 + * We have our enough of the argument structure..(we have yet
53760 + * to copy_from_user the tables themselves) . Copy the tables
53761 + * only if we need them, i.e. for loading operations. */
53762 +
53763 + switch (gr_usermode->mode) {
53764 + case GR_STATUS:
53765 + if (gr_status & GR_READY) {
53766 + error = 1;
53767 + if (!gr_check_secure_terminal(current))
53768 + error = 3;
53769 + } else
53770 + error = 2;
53771 + goto out;
53772 + case GR_SHUTDOWN:
53773 + if ((gr_status & GR_READY)
53774 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
53775 + pax_open_kernel();
53776 + gr_status &= ~GR_READY;
53777 + pax_close_kernel();
53778 +
53779 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
53780 + free_variables();
53781 + memset(gr_usermode, 0, sizeof (struct gr_arg));
53782 + memset(gr_system_salt, 0, GR_SALT_LEN);
53783 + memset(gr_system_sum, 0, GR_SHA_LEN);
53784 + } else if (gr_status & GR_READY) {
53785 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
53786 + error = -EPERM;
53787 + } else {
53788 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
53789 + error = -EAGAIN;
53790 + }
53791 + break;
53792 + case GR_ENABLE:
53793 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
53794 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
53795 + else {
53796 + if (gr_status & GR_READY)
53797 + error = -EAGAIN;
53798 + else
53799 + error = error2;
53800 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
53801 + }
53802 + break;
53803 + case GR_RELOAD:
53804 + if (!(gr_status & GR_READY)) {
53805 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
53806 + error = -EAGAIN;
53807 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
53808 + preempt_disable();
53809 +
53810 + pax_open_kernel();
53811 + gr_status &= ~GR_READY;
53812 + pax_close_kernel();
53813 +
53814 + free_variables();
53815 + if (!(error2 = gracl_init(gr_usermode))) {
53816 + preempt_enable();
53817 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
53818 + } else {
53819 + preempt_enable();
53820 + error = error2;
53821 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
53822 + }
53823 + } else {
53824 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
53825 + error = -EPERM;
53826 + }
53827 + break;
53828 + case GR_SEGVMOD:
53829 + if (unlikely(!(gr_status & GR_READY))) {
53830 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
53831 + error = -EAGAIN;
53832 + break;
53833 + }
53834 +
53835 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
53836 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
53837 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
53838 + struct acl_subject_label *segvacl;
53839 + segvacl =
53840 + lookup_acl_subj_label(gr_usermode->segv_inode,
53841 + gr_usermode->segv_device,
53842 + current->role);
53843 + if (segvacl) {
53844 + segvacl->crashes = 0;
53845 + segvacl->expires = 0;
53846 + }
53847 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
53848 + gr_remove_uid(gr_usermode->segv_uid);
53849 + }
53850 + } else {
53851 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
53852 + error = -EPERM;
53853 + }
53854 + break;
53855 + case GR_SPROLE:
53856 + case GR_SPROLEPAM:
53857 + if (unlikely(!(gr_status & GR_READY))) {
53858 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
53859 + error = -EAGAIN;
53860 + break;
53861 + }
53862 +
53863 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
53864 + current->role->expires = 0;
53865 + current->role->auth_attempts = 0;
53866 + }
53867 +
53868 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
53869 + time_after(current->role->expires, get_seconds())) {
53870 + error = -EBUSY;
53871 + goto out;
53872 + }
53873 +
53874 + if (lookup_special_role_auth
53875 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
53876 + && ((!sprole_salt && !sprole_sum)
53877 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
53878 + char *p = "";
53879 + assign_special_role(gr_usermode->sp_role);
53880 + read_lock(&tasklist_lock);
53881 + if (current->real_parent)
53882 + p = current->real_parent->role->rolename;
53883 + read_unlock(&tasklist_lock);
53884 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
53885 + p, acl_sp_role_value);
53886 + } else {
53887 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
53888 + error = -EPERM;
53889 + if(!(current->role->auth_attempts++))
53890 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
53891 +
53892 + goto out;
53893 + }
53894 + break;
53895 + case GR_UNSPROLE:
53896 + if (unlikely(!(gr_status & GR_READY))) {
53897 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
53898 + error = -EAGAIN;
53899 + break;
53900 + }
53901 +
53902 + if (current->role->roletype & GR_ROLE_SPECIAL) {
53903 + char *p = "";
53904 + int i = 0;
53905 +
53906 + read_lock(&tasklist_lock);
53907 + if (current->real_parent) {
53908 + p = current->real_parent->role->rolename;
53909 + i = current->real_parent->acl_role_id;
53910 + }
53911 + read_unlock(&tasklist_lock);
53912 +
53913 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
53914 + gr_set_acls(1);
53915 + } else {
53916 + error = -EPERM;
53917 + goto out;
53918 + }
53919 + break;
53920 + default:
53921 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
53922 + error = -EINVAL;
53923 + break;
53924 + }
53925 +
53926 + if (error != -EPERM)
53927 + goto out;
53928 +
53929 + if(!(gr_auth_attempts++))
53930 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
53931 +
53932 + out:
53933 + mutex_unlock(&gr_dev_mutex);
53934 + return error;
53935 +}
53936 +
53937 +/* must be called with
53938 + rcu_read_lock();
53939 + read_lock(&tasklist_lock);
53940 + read_lock(&grsec_exec_file_lock);
53941 +*/
53942 +int gr_apply_subject_to_task(struct task_struct *task)
53943 +{
53944 + struct acl_object_label *obj;
53945 + char *tmpname;
53946 + struct acl_subject_label *tmpsubj;
53947 + struct file *filp;
53948 + struct name_entry *nmatch;
53949 +
53950 + filp = task->exec_file;
53951 + if (filp == NULL)
53952 + return 0;
53953 +
53954 + /* the following is to apply the correct subject
53955 + on binaries running when the RBAC system
53956 + is enabled, when the binaries have been
53957 + replaced or deleted since their execution
53958 + -----
53959 + when the RBAC system starts, the inode/dev
53960 + from exec_file will be one the RBAC system
53961 + is unaware of. It only knows the inode/dev
53962 + of the present file on disk, or the absence
53963 + of it.
53964 + */
53965 + preempt_disable();
53966 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
53967 +
53968 + nmatch = lookup_name_entry(tmpname);
53969 + preempt_enable();
53970 + tmpsubj = NULL;
53971 + if (nmatch) {
53972 + if (nmatch->deleted)
53973 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
53974 + else
53975 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
53976 + if (tmpsubj != NULL)
53977 + task->acl = tmpsubj;
53978 + }
53979 + if (tmpsubj == NULL)
53980 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
53981 + task->role);
53982 + if (task->acl) {
53983 + task->is_writable = 0;
53984 + /* ignore additional mmap checks for processes that are writable
53985 + by the default ACL */
53986 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
53987 + if (unlikely(obj->mode & GR_WRITE))
53988 + task->is_writable = 1;
53989 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
53990 + if (unlikely(obj->mode & GR_WRITE))
53991 + task->is_writable = 1;
53992 +
53993 + gr_set_proc_res(task);
53994 +
53995 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
53996 + printk(KERN_ALERT "gr_set_acls for (%s:%d): role:%s, subject:%s\n", task->comm, task->pid, task->role->rolename, task->acl->filename);
53997 +#endif
53998 + } else {
53999 + return 1;
54000 + }
54001 +
54002 + return 0;
54003 +}
54004 +
54005 +int
54006 +gr_set_acls(const int type)
54007 +{
54008 + struct task_struct *task, *task2;
54009 + struct acl_role_label *role = current->role;
54010 + __u16 acl_role_id = current->acl_role_id;
54011 + const struct cred *cred;
54012 + int ret;
54013 +
54014 + rcu_read_lock();
54015 + read_lock(&tasklist_lock);
54016 + read_lock(&grsec_exec_file_lock);
54017 + do_each_thread(task2, task) {
54018 + /* check to see if we're called from the exit handler,
54019 + if so, only replace ACLs that have inherited the admin
54020 + ACL */
54021 +
54022 + if (type && (task->role != role ||
54023 + task->acl_role_id != acl_role_id))
54024 + continue;
54025 +
54026 + task->acl_role_id = 0;
54027 + task->acl_sp_role = 0;
54028 +
54029 + if (task->exec_file) {
54030 + cred = __task_cred(task);
54031 + task->role = lookup_acl_role_label(task, cred->uid, cred->gid);
54032 + ret = gr_apply_subject_to_task(task);
54033 + if (ret) {
54034 + read_unlock(&grsec_exec_file_lock);
54035 + read_unlock(&tasklist_lock);
54036 + rcu_read_unlock();
54037 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task->pid);
54038 + return ret;
54039 + }
54040 + } else {
54041 + // it's a kernel process
54042 + task->role = kernel_role;
54043 + task->acl = kernel_role->root_label;
54044 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
54045 + task->acl->mode &= ~GR_PROCFIND;
54046 +#endif
54047 + }
54048 + } while_each_thread(task2, task);
54049 + read_unlock(&grsec_exec_file_lock);
54050 + read_unlock(&tasklist_lock);
54051 + rcu_read_unlock();
54052 +
54053 + return 0;
54054 +}
54055 +
54056 +void
54057 +gr_learn_resource(const struct task_struct *task,
54058 + const int res, const unsigned long wanted, const int gt)
54059 +{
54060 + struct acl_subject_label *acl;
54061 + const struct cred *cred;
54062 +
54063 + if (unlikely((gr_status & GR_READY) &&
54064 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
54065 + goto skip_reslog;
54066 +
54067 +#ifdef CONFIG_GRKERNSEC_RESLOG
54068 + gr_log_resource(task, res, wanted, gt);
54069 +#endif
54070 + skip_reslog:
54071 +
54072 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
54073 + return;
54074 +
54075 + acl = task->acl;
54076 +
54077 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
54078 + !(acl->resmask & (1 << (unsigned short) res))))
54079 + return;
54080 +
54081 + if (wanted >= acl->res[res].rlim_cur) {
54082 + unsigned long res_add;
54083 +
54084 + res_add = wanted;
54085 + switch (res) {
54086 + case RLIMIT_CPU:
54087 + res_add += GR_RLIM_CPU_BUMP;
54088 + break;
54089 + case RLIMIT_FSIZE:
54090 + res_add += GR_RLIM_FSIZE_BUMP;
54091 + break;
54092 + case RLIMIT_DATA:
54093 + res_add += GR_RLIM_DATA_BUMP;
54094 + break;
54095 + case RLIMIT_STACK:
54096 + res_add += GR_RLIM_STACK_BUMP;
54097 + break;
54098 + case RLIMIT_CORE:
54099 + res_add += GR_RLIM_CORE_BUMP;
54100 + break;
54101 + case RLIMIT_RSS:
54102 + res_add += GR_RLIM_RSS_BUMP;
54103 + break;
54104 + case RLIMIT_NPROC:
54105 + res_add += GR_RLIM_NPROC_BUMP;
54106 + break;
54107 + case RLIMIT_NOFILE:
54108 + res_add += GR_RLIM_NOFILE_BUMP;
54109 + break;
54110 + case RLIMIT_MEMLOCK:
54111 + res_add += GR_RLIM_MEMLOCK_BUMP;
54112 + break;
54113 + case RLIMIT_AS:
54114 + res_add += GR_RLIM_AS_BUMP;
54115 + break;
54116 + case RLIMIT_LOCKS:
54117 + res_add += GR_RLIM_LOCKS_BUMP;
54118 + break;
54119 + case RLIMIT_SIGPENDING:
54120 + res_add += GR_RLIM_SIGPENDING_BUMP;
54121 + break;
54122 + case RLIMIT_MSGQUEUE:
54123 + res_add += GR_RLIM_MSGQUEUE_BUMP;
54124 + break;
54125 + case RLIMIT_NICE:
54126 + res_add += GR_RLIM_NICE_BUMP;
54127 + break;
54128 + case RLIMIT_RTPRIO:
54129 + res_add += GR_RLIM_RTPRIO_BUMP;
54130 + break;
54131 + case RLIMIT_RTTIME:
54132 + res_add += GR_RLIM_RTTIME_BUMP;
54133 + break;
54134 + }
54135 +
54136 + acl->res[res].rlim_cur = res_add;
54137 +
54138 + if (wanted > acl->res[res].rlim_max)
54139 + acl->res[res].rlim_max = res_add;
54140 +
54141 + /* only log the subject filename, since resource logging is supported for
54142 + single-subject learning only */
54143 + rcu_read_lock();
54144 + cred = __task_cred(task);
54145 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
54146 + task->role->roletype, cred->uid, cred->gid, acl->filename,
54147 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
54148 + "", (unsigned long) res, &task->signal->saved_ip);
54149 + rcu_read_unlock();
54150 + }
54151 +
54152 + return;
54153 +}
54154 +
54155 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
54156 +void
54157 +pax_set_initial_flags(struct linux_binprm *bprm)
54158 +{
54159 + struct task_struct *task = current;
54160 + struct acl_subject_label *proc;
54161 + unsigned long flags;
54162 +
54163 + if (unlikely(!(gr_status & GR_READY)))
54164 + return;
54165 +
54166 + flags = pax_get_flags(task);
54167 +
54168 + proc = task->acl;
54169 +
54170 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
54171 + flags &= ~MF_PAX_PAGEEXEC;
54172 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
54173 + flags &= ~MF_PAX_SEGMEXEC;
54174 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
54175 + flags &= ~MF_PAX_RANDMMAP;
54176 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
54177 + flags &= ~MF_PAX_EMUTRAMP;
54178 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
54179 + flags &= ~MF_PAX_MPROTECT;
54180 +
54181 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
54182 + flags |= MF_PAX_PAGEEXEC;
54183 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
54184 + flags |= MF_PAX_SEGMEXEC;
54185 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
54186 + flags |= MF_PAX_RANDMMAP;
54187 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
54188 + flags |= MF_PAX_EMUTRAMP;
54189 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
54190 + flags |= MF_PAX_MPROTECT;
54191 +
54192 + pax_set_flags(task, flags);
54193 +
54194 + return;
54195 +}
54196 +#endif
54197 +
54198 +#ifdef CONFIG_SYSCTL
54199 +/* Eric Biederman likes breaking userland ABI and every inode-based security
54200 + system to save 35kb of memory */
54201 +
54202 +/* we modify the passed in filename, but adjust it back before returning */
54203 +static struct acl_object_label *gr_lookup_by_name(char *name, unsigned int len)
54204 +{
54205 + struct name_entry *nmatch;
54206 + char *p, *lastp = NULL;
54207 + struct acl_object_label *obj = NULL, *tmp;
54208 + struct acl_subject_label *tmpsubj;
54209 + char c = '\0';
54210 +
54211 + read_lock(&gr_inode_lock);
54212 +
54213 + p = name + len - 1;
54214 + do {
54215 + nmatch = lookup_name_entry(name);
54216 + if (lastp != NULL)
54217 + *lastp = c;
54218 +
54219 + if (nmatch == NULL)
54220 + goto next_component;
54221 + tmpsubj = current->acl;
54222 + do {
54223 + obj = lookup_acl_obj_label(nmatch->inode, nmatch->device, tmpsubj);
54224 + if (obj != NULL) {
54225 + tmp = obj->globbed;
54226 + while (tmp) {
54227 + if (!glob_match(tmp->filename, name)) {
54228 + obj = tmp;
54229 + goto found_obj;
54230 + }
54231 + tmp = tmp->next;
54232 + }
54233 + goto found_obj;
54234 + }
54235 + } while ((tmpsubj = tmpsubj->parent_subject));
54236 +next_component:
54237 + /* end case */
54238 + if (p == name)
54239 + break;
54240 +
54241 + while (*p != '/')
54242 + p--;
54243 + if (p == name)
54244 + lastp = p + 1;
54245 + else {
54246 + lastp = p;
54247 + p--;
54248 + }
54249 + c = *lastp;
54250 + *lastp = '\0';
54251 + } while (1);
54252 +found_obj:
54253 + read_unlock(&gr_inode_lock);
54254 + /* obj returned will always be non-null */
54255 + return obj;
54256 +}
54257 +
54258 +/* returns 0 when allowing, non-zero on error
54259 + op of 0 is used for readdir, so we don't log the names of hidden files
54260 +*/
54261 +__u32
54262 +gr_handle_sysctl(const struct ctl_table *table, const int op)
54263 +{
54264 + struct ctl_table *tmp;
54265 + const char *proc_sys = "/proc/sys";
54266 + char *path;
54267 + struct acl_object_label *obj;
54268 + unsigned short len = 0, pos = 0, depth = 0, i;
54269 + __u32 err = 0;
54270 + __u32 mode = 0;
54271 +
54272 + if (unlikely(!(gr_status & GR_READY)))
54273 + return 0;
54274 +
54275 + /* for now, ignore operations on non-sysctl entries if it's not a
54276 + readdir*/
54277 + if (table->child != NULL && op != 0)
54278 + return 0;
54279 +
54280 + mode |= GR_FIND;
54281 + /* it's only a read if it's an entry, read on dirs is for readdir */
54282 + if (op & MAY_READ)
54283 + mode |= GR_READ;
54284 + if (op & MAY_WRITE)
54285 + mode |= GR_WRITE;
54286 +
54287 + preempt_disable();
54288 +
54289 + path = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
54290 +
54291 + /* it's only a read/write if it's an actual entry, not a dir
54292 + (which are opened for readdir)
54293 + */
54294 +
54295 + /* convert the requested sysctl entry into a pathname */
54296 +
54297 + for (tmp = (struct ctl_table *)table; tmp != NULL; tmp = tmp->parent) {
54298 + len += strlen(tmp->procname);
54299 + len++;
54300 + depth++;
54301 + }
54302 +
54303 + if ((len + depth + strlen(proc_sys) + 1) > PAGE_SIZE) {
54304 + /* deny */
54305 + goto out;
54306 + }
54307 +
54308 + memset(path, 0, PAGE_SIZE);
54309 +
54310 + memcpy(path, proc_sys, strlen(proc_sys));
54311 +
54312 + pos += strlen(proc_sys);
54313 +
54314 + for (; depth > 0; depth--) {
54315 + path[pos] = '/';
54316 + pos++;
54317 + for (i = 1, tmp = (struct ctl_table *)table; tmp != NULL; tmp = tmp->parent) {
54318 + if (depth == i) {
54319 + memcpy(path + pos, tmp->procname,
54320 + strlen(tmp->procname));
54321 + pos += strlen(tmp->procname);
54322 + }
54323 + i++;
54324 + }
54325 + }
54326 +
54327 + obj = gr_lookup_by_name(path, pos);
54328 + err = obj->mode & (mode | to_gr_audit(mode) | GR_SUPPRESS);
54329 +
54330 + if (unlikely((current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) &&
54331 + ((err & mode) != mode))) {
54332 + __u32 new_mode = mode;
54333 +
54334 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
54335 +
54336 + err = 0;
54337 + gr_log_learn_sysctl(path, new_mode);
54338 + } else if (!(err & GR_FIND) && !(err & GR_SUPPRESS) && op != 0) {
54339 + gr_log_hidden_sysctl(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, path);
54340 + err = -ENOENT;
54341 + } else if (!(err & GR_FIND)) {
54342 + err = -ENOENT;
54343 + } else if (((err & mode) & ~GR_FIND) != (mode & ~GR_FIND) && !(err & GR_SUPPRESS)) {
54344 + gr_log_str4(GR_DONT_AUDIT, GR_SYSCTL_ACL_MSG, "denied",
54345 + path, (mode & GR_READ) ? " reading" : "",
54346 + (mode & GR_WRITE) ? " writing" : "");
54347 + err = -EACCES;
54348 + } else if ((err & mode) != mode) {
54349 + err = -EACCES;
54350 + } else if ((((err & mode) & ~GR_FIND) == (mode & ~GR_FIND)) && (err & GR_AUDITS)) {
54351 + gr_log_str4(GR_DO_AUDIT, GR_SYSCTL_ACL_MSG, "successful",
54352 + path, (mode & GR_READ) ? " reading" : "",
54353 + (mode & GR_WRITE) ? " writing" : "");
54354 + err = 0;
54355 + } else
54356 + err = 0;
54357 +
54358 + out:
54359 + preempt_enable();
54360 +
54361 + return err;
54362 +}
54363 +#endif
54364 +
54365 +int
54366 +gr_handle_proc_ptrace(struct task_struct *task)
54367 +{
54368 + struct file *filp;
54369 + struct task_struct *tmp = task;
54370 + struct task_struct *curtemp = current;
54371 + __u32 retmode;
54372 +
54373 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
54374 + if (unlikely(!(gr_status & GR_READY)))
54375 + return 0;
54376 +#endif
54377 +
54378 + read_lock(&tasklist_lock);
54379 + read_lock(&grsec_exec_file_lock);
54380 + filp = task->exec_file;
54381 +
54382 + while (tmp->pid > 0) {
54383 + if (tmp == curtemp)
54384 + break;
54385 + tmp = tmp->real_parent;
54386 + }
54387 +
54388 + if (!filp || (tmp->pid == 0 && ((grsec_enable_harden_ptrace && current_uid() && !(gr_status & GR_READY)) ||
54389 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
54390 + read_unlock(&grsec_exec_file_lock);
54391 + read_unlock(&tasklist_lock);
54392 + return 1;
54393 + }
54394 +
54395 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
54396 + if (!(gr_status & GR_READY)) {
54397 + read_unlock(&grsec_exec_file_lock);
54398 + read_unlock(&tasklist_lock);
54399 + return 0;
54400 + }
54401 +#endif
54402 +
54403 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
54404 + read_unlock(&grsec_exec_file_lock);
54405 + read_unlock(&tasklist_lock);
54406 +
54407 + if (retmode & GR_NOPTRACE)
54408 + return 1;
54409 +
54410 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
54411 + && (current->acl != task->acl || (current->acl != current->role->root_label
54412 + && current->pid != task->pid)))
54413 + return 1;
54414 +
54415 + return 0;
54416 +}
54417 +
54418 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
54419 +{
54420 + if (unlikely(!(gr_status & GR_READY)))
54421 + return;
54422 +
54423 + if (!(current->role->roletype & GR_ROLE_GOD))
54424 + return;
54425 +
54426 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
54427 + p->role->rolename, gr_task_roletype_to_char(p),
54428 + p->acl->filename);
54429 +}
54430 +
54431 +int
54432 +gr_handle_ptrace(struct task_struct *task, const long request)
54433 +{
54434 + struct task_struct *tmp = task;
54435 + struct task_struct *curtemp = current;
54436 + __u32 retmode;
54437 +
54438 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
54439 + if (unlikely(!(gr_status & GR_READY)))
54440 + return 0;
54441 +#endif
54442 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
54443 + read_lock(&tasklist_lock);
54444 + while (tmp->pid > 0) {
54445 + if (tmp == curtemp)
54446 + break;
54447 + tmp = tmp->real_parent;
54448 + }
54449 +
54450 + if (tmp->pid == 0 && ((grsec_enable_harden_ptrace && current_uid() && !(gr_status & GR_READY)) ||
54451 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
54452 + read_unlock(&tasklist_lock);
54453 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
54454 + return 1;
54455 + }
54456 + read_unlock(&tasklist_lock);
54457 + }
54458 +
54459 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
54460 + if (!(gr_status & GR_READY))
54461 + return 0;
54462 +#endif
54463 +
54464 + read_lock(&grsec_exec_file_lock);
54465 + if (unlikely(!task->exec_file)) {
54466 + read_unlock(&grsec_exec_file_lock);
54467 + return 0;
54468 + }
54469 +
54470 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
54471 + read_unlock(&grsec_exec_file_lock);
54472 +
54473 + if (retmode & GR_NOPTRACE) {
54474 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
54475 + return 1;
54476 + }
54477 +
54478 + if (retmode & GR_PTRACERD) {
54479 + switch (request) {
54480 + case PTRACE_SEIZE:
54481 + case PTRACE_POKETEXT:
54482 + case PTRACE_POKEDATA:
54483 + case PTRACE_POKEUSR:
54484 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
54485 + case PTRACE_SETREGS:
54486 + case PTRACE_SETFPREGS:
54487 +#endif
54488 +#ifdef CONFIG_X86
54489 + case PTRACE_SETFPXREGS:
54490 +#endif
54491 +#ifdef CONFIG_ALTIVEC
54492 + case PTRACE_SETVRREGS:
54493 +#endif
54494 + return 1;
54495 + default:
54496 + return 0;
54497 + }
54498 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
54499 + !(current->role->roletype & GR_ROLE_GOD) &&
54500 + (current->acl != task->acl)) {
54501 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
54502 + return 1;
54503 + }
54504 +
54505 + return 0;
54506 +}
54507 +
54508 +static int is_writable_mmap(const struct file *filp)
54509 +{
54510 + struct task_struct *task = current;
54511 + struct acl_object_label *obj, *obj2;
54512 +
54513 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
54514 + !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))) {
54515 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
54516 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
54517 + task->role->root_label);
54518 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
54519 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
54520 + return 1;
54521 + }
54522 + }
54523 + return 0;
54524 +}
54525 +
54526 +int
54527 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
54528 +{
54529 + __u32 mode;
54530 +
54531 + if (unlikely(!file || !(prot & PROT_EXEC)))
54532 + return 1;
54533 +
54534 + if (is_writable_mmap(file))
54535 + return 0;
54536 +
54537 + mode =
54538 + gr_search_file(file->f_path.dentry,
54539 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
54540 + file->f_path.mnt);
54541 +
54542 + if (!gr_tpe_allow(file))
54543 + return 0;
54544 +
54545 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
54546 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
54547 + return 0;
54548 + } else if (unlikely(!(mode & GR_EXEC))) {
54549 + return 0;
54550 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
54551 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
54552 + return 1;
54553 + }
54554 +
54555 + return 1;
54556 +}
54557 +
54558 +int
54559 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
54560 +{
54561 + __u32 mode;
54562 +
54563 + if (unlikely(!file || !(prot & PROT_EXEC)))
54564 + return 1;
54565 +
54566 + if (is_writable_mmap(file))
54567 + return 0;
54568 +
54569 + mode =
54570 + gr_search_file(file->f_path.dentry,
54571 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
54572 + file->f_path.mnt);
54573 +
54574 + if (!gr_tpe_allow(file))
54575 + return 0;
54576 +
54577 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
54578 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
54579 + return 0;
54580 + } else if (unlikely(!(mode & GR_EXEC))) {
54581 + return 0;
54582 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
54583 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
54584 + return 1;
54585 + }
54586 +
54587 + return 1;
54588 +}
54589 +
54590 +void
54591 +gr_acl_handle_psacct(struct task_struct *task, const long code)
54592 +{
54593 + unsigned long runtime;
54594 + unsigned long cputime;
54595 + unsigned int wday, cday;
54596 + __u8 whr, chr;
54597 + __u8 wmin, cmin;
54598 + __u8 wsec, csec;
54599 + struct timespec timeval;
54600 +
54601 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
54602 + !(task->acl->mode & GR_PROCACCT)))
54603 + return;
54604 +
54605 + do_posix_clock_monotonic_gettime(&timeval);
54606 + runtime = timeval.tv_sec - task->start_time.tv_sec;
54607 + wday = runtime / (3600 * 24);
54608 + runtime -= wday * (3600 * 24);
54609 + whr = runtime / 3600;
54610 + runtime -= whr * 3600;
54611 + wmin = runtime / 60;
54612 + runtime -= wmin * 60;
54613 + wsec = runtime;
54614 +
54615 + cputime = (task->utime + task->stime) / HZ;
54616 + cday = cputime / (3600 * 24);
54617 + cputime -= cday * (3600 * 24);
54618 + chr = cputime / 3600;
54619 + cputime -= chr * 3600;
54620 + cmin = cputime / 60;
54621 + cputime -= cmin * 60;
54622 + csec = cputime;
54623 +
54624 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
54625 +
54626 + return;
54627 +}
54628 +
54629 +void gr_set_kernel_label(struct task_struct *task)
54630 +{
54631 + if (gr_status & GR_READY) {
54632 + task->role = kernel_role;
54633 + task->acl = kernel_role->root_label;
54634 + }
54635 + return;
54636 +}
54637 +
54638 +#ifdef CONFIG_TASKSTATS
54639 +int gr_is_taskstats_denied(int pid)
54640 +{
54641 + struct task_struct *task;
54642 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54643 + const struct cred *cred;
54644 +#endif
54645 + int ret = 0;
54646 +
54647 + /* restrict taskstats viewing to un-chrooted root users
54648 + who have the 'view' subject flag if the RBAC system is enabled
54649 + */
54650 +
54651 + rcu_read_lock();
54652 + read_lock(&tasklist_lock);
54653 + task = find_task_by_vpid(pid);
54654 + if (task) {
54655 +#ifdef CONFIG_GRKERNSEC_CHROOT
54656 + if (proc_is_chrooted(task))
54657 + ret = -EACCES;
54658 +#endif
54659 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54660 + cred = __task_cred(task);
54661 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54662 + if (cred->uid != 0)
54663 + ret = -EACCES;
54664 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54665 + if (cred->uid != 0 && !groups_search(cred->group_info, CONFIG_GRKERNSEC_PROC_GID))
54666 + ret = -EACCES;
54667 +#endif
54668 +#endif
54669 + if (gr_status & GR_READY) {
54670 + if (!(task->acl->mode & GR_VIEW))
54671 + ret = -EACCES;
54672 + }
54673 + } else
54674 + ret = -ENOENT;
54675 +
54676 + read_unlock(&tasklist_lock);
54677 + rcu_read_unlock();
54678 +
54679 + return ret;
54680 +}
54681 +#endif
54682 +
54683 +/* AUXV entries are filled via a descendant of search_binary_handler
54684 + after we've already applied the subject for the target
54685 +*/
54686 +int gr_acl_enable_at_secure(void)
54687 +{
54688 + if (unlikely(!(gr_status & GR_READY)))
54689 + return 0;
54690 +
54691 + if (current->acl->mode & GR_ATSECURE)
54692 + return 1;
54693 +
54694 + return 0;
54695 +}
54696 +
54697 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
54698 +{
54699 + struct task_struct *task = current;
54700 + struct dentry *dentry = file->f_path.dentry;
54701 + struct vfsmount *mnt = file->f_path.mnt;
54702 + struct acl_object_label *obj, *tmp;
54703 + struct acl_subject_label *subj;
54704 + unsigned int bufsize;
54705 + int is_not_root;
54706 + char *path;
54707 + dev_t dev = __get_dev(dentry);
54708 +
54709 + if (unlikely(!(gr_status & GR_READY)))
54710 + return 1;
54711 +
54712 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
54713 + return 1;
54714 +
54715 + /* ignore Eric Biederman */
54716 + if (IS_PRIVATE(dentry->d_inode))
54717 + return 1;
54718 +
54719 + subj = task->acl;
54720 + do {
54721 + obj = lookup_acl_obj_label(ino, dev, subj);
54722 + if (obj != NULL)
54723 + return (obj->mode & GR_FIND) ? 1 : 0;
54724 + } while ((subj = subj->parent_subject));
54725 +
54726 + /* this is purely an optimization since we're looking for an object
54727 + for the directory we're doing a readdir on
54728 + if it's possible for any globbed object to match the entry we're
54729 + filling into the directory, then the object we find here will be
54730 + an anchor point with attached globbed objects
54731 + */
54732 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
54733 + if (obj->globbed == NULL)
54734 + return (obj->mode & GR_FIND) ? 1 : 0;
54735 +
54736 + is_not_root = ((obj->filename[0] == '/') &&
54737 + (obj->filename[1] == '\0')) ? 0 : 1;
54738 + bufsize = PAGE_SIZE - namelen - is_not_root;
54739 +
54740 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
54741 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
54742 + return 1;
54743 +
54744 + preempt_disable();
54745 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
54746 + bufsize);
54747 +
54748 + bufsize = strlen(path);
54749 +
54750 + /* if base is "/", don't append an additional slash */
54751 + if (is_not_root)
54752 + *(path + bufsize) = '/';
54753 + memcpy(path + bufsize + is_not_root, name, namelen);
54754 + *(path + bufsize + namelen + is_not_root) = '\0';
54755 +
54756 + tmp = obj->globbed;
54757 + while (tmp) {
54758 + if (!glob_match(tmp->filename, path)) {
54759 + preempt_enable();
54760 + return (tmp->mode & GR_FIND) ? 1 : 0;
54761 + }
54762 + tmp = tmp->next;
54763 + }
54764 + preempt_enable();
54765 + return (obj->mode & GR_FIND) ? 1 : 0;
54766 +}
54767 +
54768 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
54769 +EXPORT_SYMBOL(gr_acl_is_enabled);
54770 +#endif
54771 +EXPORT_SYMBOL(gr_learn_resource);
54772 +EXPORT_SYMBOL(gr_set_kernel_label);
54773 +#ifdef CONFIG_SECURITY
54774 +EXPORT_SYMBOL(gr_check_user_change);
54775 +EXPORT_SYMBOL(gr_check_group_change);
54776 +#endif
54777 +
54778 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
54779 new file mode 100644
54780 index 0000000..34fefda
54781 --- /dev/null
54782 +++ b/grsecurity/gracl_alloc.c
54783 @@ -0,0 +1,105 @@
54784 +#include <linux/kernel.h>
54785 +#include <linux/mm.h>
54786 +#include <linux/slab.h>
54787 +#include <linux/vmalloc.h>
54788 +#include <linux/gracl.h>
54789 +#include <linux/grsecurity.h>
54790 +
54791 +static unsigned long alloc_stack_next = 1;
54792 +static unsigned long alloc_stack_size = 1;
54793 +static void **alloc_stack;
54794 +
54795 +static __inline__ int
54796 +alloc_pop(void)
54797 +{
54798 + if (alloc_stack_next == 1)
54799 + return 0;
54800 +
54801 + kfree(alloc_stack[alloc_stack_next - 2]);
54802 +
54803 + alloc_stack_next--;
54804 +
54805 + return 1;
54806 +}
54807 +
54808 +static __inline__ int
54809 +alloc_push(void *buf)
54810 +{
54811 + if (alloc_stack_next >= alloc_stack_size)
54812 + return 1;
54813 +
54814 + alloc_stack[alloc_stack_next - 1] = buf;
54815 +
54816 + alloc_stack_next++;
54817 +
54818 + return 0;
54819 +}
54820 +
54821 +void *
54822 +acl_alloc(unsigned long len)
54823 +{
54824 + void *ret = NULL;
54825 +
54826 + if (!len || len > PAGE_SIZE)
54827 + goto out;
54828 +
54829 + ret = kmalloc(len, GFP_KERNEL);
54830 +
54831 + if (ret) {
54832 + if (alloc_push(ret)) {
54833 + kfree(ret);
54834 + ret = NULL;
54835 + }
54836 + }
54837 +
54838 +out:
54839 + return ret;
54840 +}
54841 +
54842 +void *
54843 +acl_alloc_num(unsigned long num, unsigned long len)
54844 +{
54845 + if (!len || (num > (PAGE_SIZE / len)))
54846 + return NULL;
54847 +
54848 + return acl_alloc(num * len);
54849 +}
54850 +
54851 +void
54852 +acl_free_all(void)
54853 +{
54854 + if (gr_acl_is_enabled() || !alloc_stack)
54855 + return;
54856 +
54857 + while (alloc_pop()) ;
54858 +
54859 + if (alloc_stack) {
54860 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
54861 + kfree(alloc_stack);
54862 + else
54863 + vfree(alloc_stack);
54864 + }
54865 +
54866 + alloc_stack = NULL;
54867 + alloc_stack_size = 1;
54868 + alloc_stack_next = 1;
54869 +
54870 + return;
54871 +}
54872 +
54873 +int
54874 +acl_alloc_stack_init(unsigned long size)
54875 +{
54876 + if ((size * sizeof (void *)) <= PAGE_SIZE)
54877 + alloc_stack =
54878 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
54879 + else
54880 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
54881 +
54882 + alloc_stack_size = size;
54883 +
54884 + if (!alloc_stack)
54885 + return 0;
54886 + else
54887 + return 1;
54888 +}
54889 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
54890 new file mode 100644
54891 index 0000000..6d21049
54892 --- /dev/null
54893 +++ b/grsecurity/gracl_cap.c
54894 @@ -0,0 +1,110 @@
54895 +#include <linux/kernel.h>
54896 +#include <linux/module.h>
54897 +#include <linux/sched.h>
54898 +#include <linux/gracl.h>
54899 +#include <linux/grsecurity.h>
54900 +#include <linux/grinternal.h>
54901 +
54902 +extern const char *captab_log[];
54903 +extern int captab_log_entries;
54904 +
54905 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
54906 +{
54907 + struct acl_subject_label *curracl;
54908 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
54909 + kernel_cap_t cap_audit = __cap_empty_set;
54910 +
54911 + if (!gr_acl_is_enabled())
54912 + return 1;
54913 +
54914 + curracl = task->acl;
54915 +
54916 + cap_drop = curracl->cap_lower;
54917 + cap_mask = curracl->cap_mask;
54918 + cap_audit = curracl->cap_invert_audit;
54919 +
54920 + while ((curracl = curracl->parent_subject)) {
54921 + /* if the cap isn't specified in the current computed mask but is specified in the
54922 + current level subject, and is lowered in the current level subject, then add
54923 + it to the set of dropped capabilities
54924 + otherwise, add the current level subject's mask to the current computed mask
54925 + */
54926 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
54927 + cap_raise(cap_mask, cap);
54928 + if (cap_raised(curracl->cap_lower, cap))
54929 + cap_raise(cap_drop, cap);
54930 + if (cap_raised(curracl->cap_invert_audit, cap))
54931 + cap_raise(cap_audit, cap);
54932 + }
54933 + }
54934 +
54935 + if (!cap_raised(cap_drop, cap)) {
54936 + if (cap_raised(cap_audit, cap))
54937 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
54938 + return 1;
54939 + }
54940 +
54941 + curracl = task->acl;
54942 +
54943 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
54944 + && cap_raised(cred->cap_effective, cap)) {
54945 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
54946 + task->role->roletype, cred->uid,
54947 + cred->gid, task->exec_file ?
54948 + gr_to_filename(task->exec_file->f_path.dentry,
54949 + task->exec_file->f_path.mnt) : curracl->filename,
54950 + curracl->filename, 0UL,
54951 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
54952 + return 1;
54953 + }
54954 +
54955 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
54956 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
54957 +
54958 + return 0;
54959 +}
54960 +
54961 +int
54962 +gr_acl_is_capable(const int cap)
54963 +{
54964 + return gr_task_acl_is_capable(current, current_cred(), cap);
54965 +}
54966 +
54967 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
54968 +{
54969 + struct acl_subject_label *curracl;
54970 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
54971 +
54972 + if (!gr_acl_is_enabled())
54973 + return 1;
54974 +
54975 + curracl = task->acl;
54976 +
54977 + cap_drop = curracl->cap_lower;
54978 + cap_mask = curracl->cap_mask;
54979 +
54980 + while ((curracl = curracl->parent_subject)) {
54981 + /* if the cap isn't specified in the current computed mask but is specified in the
54982 + current level subject, and is lowered in the current level subject, then add
54983 + it to the set of dropped capabilities
54984 + otherwise, add the current level subject's mask to the current computed mask
54985 + */
54986 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
54987 + cap_raise(cap_mask, cap);
54988 + if (cap_raised(curracl->cap_lower, cap))
54989 + cap_raise(cap_drop, cap);
54990 + }
54991 + }
54992 +
54993 + if (!cap_raised(cap_drop, cap))
54994 + return 1;
54995 +
54996 + return 0;
54997 +}
54998 +
54999 +int
55000 +gr_acl_is_capable_nolog(const int cap)
55001 +{
55002 + return gr_task_acl_is_capable_nolog(current, cap);
55003 +}
55004 +
55005 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
55006 new file mode 100644
55007 index 0000000..88d0e87
55008 --- /dev/null
55009 +++ b/grsecurity/gracl_fs.c
55010 @@ -0,0 +1,435 @@
55011 +#include <linux/kernel.h>
55012 +#include <linux/sched.h>
55013 +#include <linux/types.h>
55014 +#include <linux/fs.h>
55015 +#include <linux/file.h>
55016 +#include <linux/stat.h>
55017 +#include <linux/grsecurity.h>
55018 +#include <linux/grinternal.h>
55019 +#include <linux/gracl.h>
55020 +
55021 +umode_t
55022 +gr_acl_umask(void)
55023 +{
55024 + if (unlikely(!gr_acl_is_enabled()))
55025 + return 0;
55026 +
55027 + return current->role->umask;
55028 +}
55029 +
55030 +__u32
55031 +gr_acl_handle_hidden_file(const struct dentry * dentry,
55032 + const struct vfsmount * mnt)
55033 +{
55034 + __u32 mode;
55035 +
55036 + if (unlikely(!dentry->d_inode))
55037 + return GR_FIND;
55038 +
55039 + mode =
55040 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
55041 +
55042 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
55043 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
55044 + return mode;
55045 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
55046 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
55047 + return 0;
55048 + } else if (unlikely(!(mode & GR_FIND)))
55049 + return 0;
55050 +
55051 + return GR_FIND;
55052 +}
55053 +
55054 +__u32
55055 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
55056 + int acc_mode)
55057 +{
55058 + __u32 reqmode = GR_FIND;
55059 + __u32 mode;
55060 +
55061 + if (unlikely(!dentry->d_inode))
55062 + return reqmode;
55063 +
55064 + if (acc_mode & MAY_APPEND)
55065 + reqmode |= GR_APPEND;
55066 + else if (acc_mode & MAY_WRITE)
55067 + reqmode |= GR_WRITE;
55068 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
55069 + reqmode |= GR_READ;
55070 +
55071 + mode =
55072 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
55073 + mnt);
55074 +
55075 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
55076 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
55077 + reqmode & GR_READ ? " reading" : "",
55078 + reqmode & GR_WRITE ? " writing" : reqmode &
55079 + GR_APPEND ? " appending" : "");
55080 + return reqmode;
55081 + } else
55082 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
55083 + {
55084 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
55085 + reqmode & GR_READ ? " reading" : "",
55086 + reqmode & GR_WRITE ? " writing" : reqmode &
55087 + GR_APPEND ? " appending" : "");
55088 + return 0;
55089 + } else if (unlikely((mode & reqmode) != reqmode))
55090 + return 0;
55091 +
55092 + return reqmode;
55093 +}
55094 +
55095 +__u32
55096 +gr_acl_handle_creat(const struct dentry * dentry,
55097 + const struct dentry * p_dentry,
55098 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
55099 + const int imode)
55100 +{
55101 + __u32 reqmode = GR_WRITE | GR_CREATE;
55102 + __u32 mode;
55103 +
55104 + if (acc_mode & MAY_APPEND)
55105 + reqmode |= GR_APPEND;
55106 + // if a directory was required or the directory already exists, then
55107 + // don't count this open as a read
55108 + if ((acc_mode & MAY_READ) &&
55109 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
55110 + reqmode |= GR_READ;
55111 + if ((open_flags & O_CREAT) && (imode & (S_ISUID | S_ISGID)))
55112 + reqmode |= GR_SETID;
55113 +
55114 + mode =
55115 + gr_check_create(dentry, p_dentry, p_mnt,
55116 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
55117 +
55118 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
55119 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
55120 + reqmode & GR_READ ? " reading" : "",
55121 + reqmode & GR_WRITE ? " writing" : reqmode &
55122 + GR_APPEND ? " appending" : "");
55123 + return reqmode;
55124 + } else
55125 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
55126 + {
55127 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
55128 + reqmode & GR_READ ? " reading" : "",
55129 + reqmode & GR_WRITE ? " writing" : reqmode &
55130 + GR_APPEND ? " appending" : "");
55131 + return 0;
55132 + } else if (unlikely((mode & reqmode) != reqmode))
55133 + return 0;
55134 +
55135 + return reqmode;
55136 +}
55137 +
55138 +__u32
55139 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
55140 + const int fmode)
55141 +{
55142 + __u32 mode, reqmode = GR_FIND;
55143 +
55144 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
55145 + reqmode |= GR_EXEC;
55146 + if (fmode & S_IWOTH)
55147 + reqmode |= GR_WRITE;
55148 + if (fmode & S_IROTH)
55149 + reqmode |= GR_READ;
55150 +
55151 + mode =
55152 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
55153 + mnt);
55154 +
55155 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
55156 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
55157 + reqmode & GR_READ ? " reading" : "",
55158 + reqmode & GR_WRITE ? " writing" : "",
55159 + reqmode & GR_EXEC ? " executing" : "");
55160 + return reqmode;
55161 + } else
55162 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
55163 + {
55164 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
55165 + reqmode & GR_READ ? " reading" : "",
55166 + reqmode & GR_WRITE ? " writing" : "",
55167 + reqmode & GR_EXEC ? " executing" : "");
55168 + return 0;
55169 + } else if (unlikely((mode & reqmode) != reqmode))
55170 + return 0;
55171 +
55172 + return reqmode;
55173 +}
55174 +
55175 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
55176 +{
55177 + __u32 mode;
55178 +
55179 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
55180 +
55181 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
55182 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
55183 + return mode;
55184 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
55185 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
55186 + return 0;
55187 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
55188 + return 0;
55189 +
55190 + return (reqmode);
55191 +}
55192 +
55193 +__u32
55194 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
55195 +{
55196 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
55197 +}
55198 +
55199 +__u32
55200 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
55201 +{
55202 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
55203 +}
55204 +
55205 +__u32
55206 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
55207 +{
55208 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
55209 +}
55210 +
55211 +__u32
55212 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
55213 +{
55214 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
55215 +}
55216 +
55217 +__u32
55218 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
55219 + umode_t *modeptr)
55220 +{
55221 + umode_t mode;
55222 +
55223 + *modeptr &= ~gr_acl_umask();
55224 + mode = *modeptr;
55225 +
55226 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
55227 + return 1;
55228 +
55229 + if (unlikely(mode & (S_ISUID | S_ISGID))) {
55230 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
55231 + GR_CHMOD_ACL_MSG);
55232 + } else {
55233 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
55234 + }
55235 +}
55236 +
55237 +__u32
55238 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
55239 +{
55240 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
55241 +}
55242 +
55243 +__u32
55244 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
55245 +{
55246 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
55247 +}
55248 +
55249 +__u32
55250 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
55251 +{
55252 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
55253 +}
55254 +
55255 +__u32
55256 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
55257 +{
55258 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
55259 + GR_UNIXCONNECT_ACL_MSG);
55260 +}
55261 +
55262 +/* hardlinks require at minimum create and link permission,
55263 + any additional privilege required is based on the
55264 + privilege of the file being linked to
55265 +*/
55266 +__u32
55267 +gr_acl_handle_link(const struct dentry * new_dentry,
55268 + const struct dentry * parent_dentry,
55269 + const struct vfsmount * parent_mnt,
55270 + const struct dentry * old_dentry,
55271 + const struct vfsmount * old_mnt, const char *to)
55272 +{
55273 + __u32 mode;
55274 + __u32 needmode = GR_CREATE | GR_LINK;
55275 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
55276 +
55277 + mode =
55278 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
55279 + old_mnt);
55280 +
55281 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
55282 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to);
55283 + return mode;
55284 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
55285 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to);
55286 + return 0;
55287 + } else if (unlikely((mode & needmode) != needmode))
55288 + return 0;
55289 +
55290 + return 1;
55291 +}
55292 +
55293 +__u32
55294 +gr_acl_handle_symlink(const struct dentry * new_dentry,
55295 + const struct dentry * parent_dentry,
55296 + const struct vfsmount * parent_mnt, const char *from)
55297 +{
55298 + __u32 needmode = GR_WRITE | GR_CREATE;
55299 + __u32 mode;
55300 +
55301 + mode =
55302 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
55303 + GR_CREATE | GR_AUDIT_CREATE |
55304 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
55305 +
55306 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
55307 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from, new_dentry, parent_mnt);
55308 + return mode;
55309 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
55310 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from, new_dentry, parent_mnt);
55311 + return 0;
55312 + } else if (unlikely((mode & needmode) != needmode))
55313 + return 0;
55314 +
55315 + return (GR_WRITE | GR_CREATE);
55316 +}
55317 +
55318 +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)
55319 +{
55320 + __u32 mode;
55321 +
55322 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
55323 +
55324 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
55325 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
55326 + return mode;
55327 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
55328 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
55329 + return 0;
55330 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
55331 + return 0;
55332 +
55333 + return (reqmode);
55334 +}
55335 +
55336 +__u32
55337 +gr_acl_handle_mknod(const struct dentry * new_dentry,
55338 + const struct dentry * parent_dentry,
55339 + const struct vfsmount * parent_mnt,
55340 + const int mode)
55341 +{
55342 + __u32 reqmode = GR_WRITE | GR_CREATE;
55343 + if (unlikely(mode & (S_ISUID | S_ISGID)))
55344 + reqmode |= GR_SETID;
55345 +
55346 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
55347 + reqmode, GR_MKNOD_ACL_MSG);
55348 +}
55349 +
55350 +__u32
55351 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
55352 + const struct dentry *parent_dentry,
55353 + const struct vfsmount *parent_mnt)
55354 +{
55355 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
55356 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
55357 +}
55358 +
55359 +#define RENAME_CHECK_SUCCESS(old, new) \
55360 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
55361 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
55362 +
55363 +int
55364 +gr_acl_handle_rename(struct dentry *new_dentry,
55365 + struct dentry *parent_dentry,
55366 + const struct vfsmount *parent_mnt,
55367 + struct dentry *old_dentry,
55368 + struct inode *old_parent_inode,
55369 + struct vfsmount *old_mnt, const char *newname)
55370 +{
55371 + __u32 comp1, comp2;
55372 + int error = 0;
55373 +
55374 + if (unlikely(!gr_acl_is_enabled()))
55375 + return 0;
55376 +
55377 + if (!new_dentry->d_inode) {
55378 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
55379 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
55380 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
55381 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
55382 + GR_DELETE | GR_AUDIT_DELETE |
55383 + GR_AUDIT_READ | GR_AUDIT_WRITE |
55384 + GR_SUPPRESS, old_mnt);
55385 + } else {
55386 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
55387 + GR_CREATE | GR_DELETE |
55388 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
55389 + GR_AUDIT_READ | GR_AUDIT_WRITE |
55390 + GR_SUPPRESS, parent_mnt);
55391 + comp2 =
55392 + gr_search_file(old_dentry,
55393 + GR_READ | GR_WRITE | GR_AUDIT_READ |
55394 + GR_DELETE | GR_AUDIT_DELETE |
55395 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
55396 + }
55397 +
55398 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
55399 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
55400 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname);
55401 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
55402 + && !(comp2 & GR_SUPPRESS)) {
55403 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname);
55404 + error = -EACCES;
55405 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
55406 + error = -EACCES;
55407 +
55408 + return error;
55409 +}
55410 +
55411 +void
55412 +gr_acl_handle_exit(void)
55413 +{
55414 + u16 id;
55415 + char *rolename;
55416 + struct file *exec_file;
55417 +
55418 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
55419 + !(current->role->roletype & GR_ROLE_PERSIST))) {
55420 + id = current->acl_role_id;
55421 + rolename = current->role->rolename;
55422 + gr_set_acls(1);
55423 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
55424 + }
55425 +
55426 + write_lock(&grsec_exec_file_lock);
55427 + exec_file = current->exec_file;
55428 + current->exec_file = NULL;
55429 + write_unlock(&grsec_exec_file_lock);
55430 +
55431 + if (exec_file)
55432 + fput(exec_file);
55433 +}
55434 +
55435 +int
55436 +gr_acl_handle_procpidmem(const struct task_struct *task)
55437 +{
55438 + if (unlikely(!gr_acl_is_enabled()))
55439 + return 0;
55440 +
55441 + if (task != current && task->acl->mode & GR_PROTPROCFD)
55442 + return -EACCES;
55443 +
55444 + return 0;
55445 +}
55446 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
55447 new file mode 100644
55448 index 0000000..58800a7
55449 --- /dev/null
55450 +++ b/grsecurity/gracl_ip.c
55451 @@ -0,0 +1,384 @@
55452 +#include <linux/kernel.h>
55453 +#include <asm/uaccess.h>
55454 +#include <asm/errno.h>
55455 +#include <net/sock.h>
55456 +#include <linux/file.h>
55457 +#include <linux/fs.h>
55458 +#include <linux/net.h>
55459 +#include <linux/in.h>
55460 +#include <linux/skbuff.h>
55461 +#include <linux/ip.h>
55462 +#include <linux/udp.h>
55463 +#include <linux/types.h>
55464 +#include <linux/sched.h>
55465 +#include <linux/netdevice.h>
55466 +#include <linux/inetdevice.h>
55467 +#include <linux/gracl.h>
55468 +#include <linux/grsecurity.h>
55469 +#include <linux/grinternal.h>
55470 +
55471 +#define GR_BIND 0x01
55472 +#define GR_CONNECT 0x02
55473 +#define GR_INVERT 0x04
55474 +#define GR_BINDOVERRIDE 0x08
55475 +#define GR_CONNECTOVERRIDE 0x10
55476 +#define GR_SOCK_FAMILY 0x20
55477 +
55478 +static const char * gr_protocols[IPPROTO_MAX] = {
55479 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
55480 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
55481 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
55482 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
55483 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
55484 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
55485 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
55486 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
55487 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
55488 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
55489 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
55490 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
55491 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
55492 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
55493 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
55494 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
55495 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
55496 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
55497 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
55498 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
55499 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
55500 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
55501 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
55502 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
55503 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
55504 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
55505 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
55506 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
55507 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
55508 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
55509 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
55510 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
55511 + };
55512 +
55513 +static const char * gr_socktypes[SOCK_MAX] = {
55514 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
55515 + "unknown:7", "unknown:8", "unknown:9", "packet"
55516 + };
55517 +
55518 +static const char * gr_sockfamilies[AF_MAX+1] = {
55519 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
55520 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
55521 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
55522 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
55523 + };
55524 +
55525 +const char *
55526 +gr_proto_to_name(unsigned char proto)
55527 +{
55528 + return gr_protocols[proto];
55529 +}
55530 +
55531 +const char *
55532 +gr_socktype_to_name(unsigned char type)
55533 +{
55534 + return gr_socktypes[type];
55535 +}
55536 +
55537 +const char *
55538 +gr_sockfamily_to_name(unsigned char family)
55539 +{
55540 + return gr_sockfamilies[family];
55541 +}
55542 +
55543 +int
55544 +gr_search_socket(const int domain, const int type, const int protocol)
55545 +{
55546 + struct acl_subject_label *curr;
55547 + const struct cred *cred = current_cred();
55548 +
55549 + if (unlikely(!gr_acl_is_enabled()))
55550 + goto exit;
55551 +
55552 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
55553 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
55554 + goto exit; // let the kernel handle it
55555 +
55556 + curr = current->acl;
55557 +
55558 + if (curr->sock_families[domain / 32] & (1 << (domain % 32))) {
55559 + /* the family is allowed, if this is PF_INET allow it only if
55560 + the extra sock type/protocol checks pass */
55561 + if (domain == PF_INET)
55562 + goto inet_check;
55563 + goto exit;
55564 + } else {
55565 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
55566 + __u32 fakeip = 0;
55567 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
55568 + current->role->roletype, cred->uid,
55569 + cred->gid, current->exec_file ?
55570 + gr_to_filename(current->exec_file->f_path.dentry,
55571 + current->exec_file->f_path.mnt) :
55572 + curr->filename, curr->filename,
55573 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
55574 + &current->signal->saved_ip);
55575 + goto exit;
55576 + }
55577 + goto exit_fail;
55578 + }
55579 +
55580 +inet_check:
55581 + /* the rest of this checking is for IPv4 only */
55582 + if (!curr->ips)
55583 + goto exit;
55584 +
55585 + if ((curr->ip_type & (1 << type)) &&
55586 + (curr->ip_proto[protocol / 32] & (1 << (protocol % 32))))
55587 + goto exit;
55588 +
55589 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
55590 + /* we don't place acls on raw sockets , and sometimes
55591 + dgram/ip sockets are opened for ioctl and not
55592 + bind/connect, so we'll fake a bind learn log */
55593 + if (type == SOCK_RAW || type == SOCK_PACKET) {
55594 + __u32 fakeip = 0;
55595 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
55596 + current->role->roletype, cred->uid,
55597 + cred->gid, current->exec_file ?
55598 + gr_to_filename(current->exec_file->f_path.dentry,
55599 + current->exec_file->f_path.mnt) :
55600 + curr->filename, curr->filename,
55601 + &fakeip, 0, type,
55602 + protocol, GR_CONNECT, &current->signal->saved_ip);
55603 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
55604 + __u32 fakeip = 0;
55605 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
55606 + current->role->roletype, cred->uid,
55607 + cred->gid, current->exec_file ?
55608 + gr_to_filename(current->exec_file->f_path.dentry,
55609 + current->exec_file->f_path.mnt) :
55610 + curr->filename, curr->filename,
55611 + &fakeip, 0, type,
55612 + protocol, GR_BIND, &current->signal->saved_ip);
55613 + }
55614 + /* we'll log when they use connect or bind */
55615 + goto exit;
55616 + }
55617 +
55618 +exit_fail:
55619 + if (domain == PF_INET)
55620 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
55621 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
55622 + else
55623 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
55624 + gr_socktype_to_name(type), protocol);
55625 +
55626 + return 0;
55627 +exit:
55628 + return 1;
55629 +}
55630 +
55631 +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)
55632 +{
55633 + if ((ip->mode & mode) &&
55634 + (ip_port >= ip->low) &&
55635 + (ip_port <= ip->high) &&
55636 + ((ntohl(ip_addr) & our_netmask) ==
55637 + (ntohl(our_addr) & our_netmask))
55638 + && (ip->proto[protocol / 32] & (1 << (protocol % 32)))
55639 + && (ip->type & (1 << type))) {
55640 + if (ip->mode & GR_INVERT)
55641 + return 2; // specifically denied
55642 + else
55643 + return 1; // allowed
55644 + }
55645 +
55646 + return 0; // not specifically allowed, may continue parsing
55647 +}
55648 +
55649 +static int
55650 +gr_search_connectbind(const int full_mode, struct sock *sk,
55651 + struct sockaddr_in *addr, const int type)
55652 +{
55653 + char iface[IFNAMSIZ] = {0};
55654 + struct acl_subject_label *curr;
55655 + struct acl_ip_label *ip;
55656 + struct inet_sock *isk;
55657 + struct net_device *dev;
55658 + struct in_device *idev;
55659 + unsigned long i;
55660 + int ret;
55661 + int mode = full_mode & (GR_BIND | GR_CONNECT);
55662 + __u32 ip_addr = 0;
55663 + __u32 our_addr;
55664 + __u32 our_netmask;
55665 + char *p;
55666 + __u16 ip_port = 0;
55667 + const struct cred *cred = current_cred();
55668 +
55669 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
55670 + return 0;
55671 +
55672 + curr = current->acl;
55673 + isk = inet_sk(sk);
55674 +
55675 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
55676 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
55677 + addr->sin_addr.s_addr = curr->inaddr_any_override;
55678 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
55679 + struct sockaddr_in saddr;
55680 + int err;
55681 +
55682 + saddr.sin_family = AF_INET;
55683 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
55684 + saddr.sin_port = isk->inet_sport;
55685 +
55686 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
55687 + if (err)
55688 + return err;
55689 +
55690 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
55691 + if (err)
55692 + return err;
55693 + }
55694 +
55695 + if (!curr->ips)
55696 + return 0;
55697 +
55698 + ip_addr = addr->sin_addr.s_addr;
55699 + ip_port = ntohs(addr->sin_port);
55700 +
55701 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
55702 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
55703 + current->role->roletype, cred->uid,
55704 + cred->gid, current->exec_file ?
55705 + gr_to_filename(current->exec_file->f_path.dentry,
55706 + current->exec_file->f_path.mnt) :
55707 + curr->filename, curr->filename,
55708 + &ip_addr, ip_port, type,
55709 + sk->sk_protocol, mode, &current->signal->saved_ip);
55710 + return 0;
55711 + }
55712 +
55713 + for (i = 0; i < curr->ip_num; i++) {
55714 + ip = *(curr->ips + i);
55715 + if (ip->iface != NULL) {
55716 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
55717 + p = strchr(iface, ':');
55718 + if (p != NULL)
55719 + *p = '\0';
55720 + dev = dev_get_by_name(sock_net(sk), iface);
55721 + if (dev == NULL)
55722 + continue;
55723 + idev = in_dev_get(dev);
55724 + if (idev == NULL) {
55725 + dev_put(dev);
55726 + continue;
55727 + }
55728 + rcu_read_lock();
55729 + for_ifa(idev) {
55730 + if (!strcmp(ip->iface, ifa->ifa_label)) {
55731 + our_addr = ifa->ifa_address;
55732 + our_netmask = 0xffffffff;
55733 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
55734 + if (ret == 1) {
55735 + rcu_read_unlock();
55736 + in_dev_put(idev);
55737 + dev_put(dev);
55738 + return 0;
55739 + } else if (ret == 2) {
55740 + rcu_read_unlock();
55741 + in_dev_put(idev);
55742 + dev_put(dev);
55743 + goto denied;
55744 + }
55745 + }
55746 + } endfor_ifa(idev);
55747 + rcu_read_unlock();
55748 + in_dev_put(idev);
55749 + dev_put(dev);
55750 + } else {
55751 + our_addr = ip->addr;
55752 + our_netmask = ip->netmask;
55753 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
55754 + if (ret == 1)
55755 + return 0;
55756 + else if (ret == 2)
55757 + goto denied;
55758 + }
55759 + }
55760 +
55761 +denied:
55762 + if (mode == GR_BIND)
55763 + 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));
55764 + else if (mode == GR_CONNECT)
55765 + 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));
55766 +
55767 + return -EACCES;
55768 +}
55769 +
55770 +int
55771 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
55772 +{
55773 + /* always allow disconnection of dgram sockets with connect */
55774 + if (addr->sin_family == AF_UNSPEC)
55775 + return 0;
55776 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
55777 +}
55778 +
55779 +int
55780 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
55781 +{
55782 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
55783 +}
55784 +
55785 +int gr_search_listen(struct socket *sock)
55786 +{
55787 + struct sock *sk = sock->sk;
55788 + struct sockaddr_in addr;
55789 +
55790 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
55791 + addr.sin_port = inet_sk(sk)->inet_sport;
55792 +
55793 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
55794 +}
55795 +
55796 +int gr_search_accept(struct socket *sock)
55797 +{
55798 + struct sock *sk = sock->sk;
55799 + struct sockaddr_in addr;
55800 +
55801 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
55802 + addr.sin_port = inet_sk(sk)->inet_sport;
55803 +
55804 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
55805 +}
55806 +
55807 +int
55808 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
55809 +{
55810 + if (addr)
55811 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
55812 + else {
55813 + struct sockaddr_in sin;
55814 + const struct inet_sock *inet = inet_sk(sk);
55815 +
55816 + sin.sin_addr.s_addr = inet->inet_daddr;
55817 + sin.sin_port = inet->inet_dport;
55818 +
55819 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
55820 + }
55821 +}
55822 +
55823 +int
55824 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
55825 +{
55826 + struct sockaddr_in sin;
55827 +
55828 + if (unlikely(skb->len < sizeof (struct udphdr)))
55829 + return 0; // skip this packet
55830 +
55831 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
55832 + sin.sin_port = udp_hdr(skb)->source;
55833 +
55834 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
55835 +}
55836 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
55837 new file mode 100644
55838 index 0000000..25f54ef
55839 --- /dev/null
55840 +++ b/grsecurity/gracl_learn.c
55841 @@ -0,0 +1,207 @@
55842 +#include <linux/kernel.h>
55843 +#include <linux/mm.h>
55844 +#include <linux/sched.h>
55845 +#include <linux/poll.h>
55846 +#include <linux/string.h>
55847 +#include <linux/file.h>
55848 +#include <linux/types.h>
55849 +#include <linux/vmalloc.h>
55850 +#include <linux/grinternal.h>
55851 +
55852 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
55853 + size_t count, loff_t *ppos);
55854 +extern int gr_acl_is_enabled(void);
55855 +
55856 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
55857 +static int gr_learn_attached;
55858 +
55859 +/* use a 512k buffer */
55860 +#define LEARN_BUFFER_SIZE (512 * 1024)
55861 +
55862 +static DEFINE_SPINLOCK(gr_learn_lock);
55863 +static DEFINE_MUTEX(gr_learn_user_mutex);
55864 +
55865 +/* we need to maintain two buffers, so that the kernel context of grlearn
55866 + uses a semaphore around the userspace copying, and the other kernel contexts
55867 + use a spinlock when copying into the buffer, since they cannot sleep
55868 +*/
55869 +static char *learn_buffer;
55870 +static char *learn_buffer_user;
55871 +static int learn_buffer_len;
55872 +static int learn_buffer_user_len;
55873 +
55874 +static ssize_t
55875 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
55876 +{
55877 + DECLARE_WAITQUEUE(wait, current);
55878 + ssize_t retval = 0;
55879 +
55880 + add_wait_queue(&learn_wait, &wait);
55881 + set_current_state(TASK_INTERRUPTIBLE);
55882 + do {
55883 + mutex_lock(&gr_learn_user_mutex);
55884 + spin_lock(&gr_learn_lock);
55885 + if (learn_buffer_len)
55886 + break;
55887 + spin_unlock(&gr_learn_lock);
55888 + mutex_unlock(&gr_learn_user_mutex);
55889 + if (file->f_flags & O_NONBLOCK) {
55890 + retval = -EAGAIN;
55891 + goto out;
55892 + }
55893 + if (signal_pending(current)) {
55894 + retval = -ERESTARTSYS;
55895 + goto out;
55896 + }
55897 +
55898 + schedule();
55899 + } while (1);
55900 +
55901 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
55902 + learn_buffer_user_len = learn_buffer_len;
55903 + retval = learn_buffer_len;
55904 + learn_buffer_len = 0;
55905 +
55906 + spin_unlock(&gr_learn_lock);
55907 +
55908 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
55909 + retval = -EFAULT;
55910 +
55911 + mutex_unlock(&gr_learn_user_mutex);
55912 +out:
55913 + set_current_state(TASK_RUNNING);
55914 + remove_wait_queue(&learn_wait, &wait);
55915 + return retval;
55916 +}
55917 +
55918 +static unsigned int
55919 +poll_learn(struct file * file, poll_table * wait)
55920 +{
55921 + poll_wait(file, &learn_wait, wait);
55922 +
55923 + if (learn_buffer_len)
55924 + return (POLLIN | POLLRDNORM);
55925 +
55926 + return 0;
55927 +}
55928 +
55929 +void
55930 +gr_clear_learn_entries(void)
55931 +{
55932 + char *tmp;
55933 +
55934 + mutex_lock(&gr_learn_user_mutex);
55935 + spin_lock(&gr_learn_lock);
55936 + tmp = learn_buffer;
55937 + learn_buffer = NULL;
55938 + spin_unlock(&gr_learn_lock);
55939 + if (tmp)
55940 + vfree(tmp);
55941 + if (learn_buffer_user != NULL) {
55942 + vfree(learn_buffer_user);
55943 + learn_buffer_user = NULL;
55944 + }
55945 + learn_buffer_len = 0;
55946 + mutex_unlock(&gr_learn_user_mutex);
55947 +
55948 + return;
55949 +}
55950 +
55951 +void
55952 +gr_add_learn_entry(const char *fmt, ...)
55953 +{
55954 + va_list args;
55955 + unsigned int len;
55956 +
55957 + if (!gr_learn_attached)
55958 + return;
55959 +
55960 + spin_lock(&gr_learn_lock);
55961 +
55962 + /* leave a gap at the end so we know when it's "full" but don't have to
55963 + compute the exact length of the string we're trying to append
55964 + */
55965 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
55966 + spin_unlock(&gr_learn_lock);
55967 + wake_up_interruptible(&learn_wait);
55968 + return;
55969 + }
55970 + if (learn_buffer == NULL) {
55971 + spin_unlock(&gr_learn_lock);
55972 + return;
55973 + }
55974 +
55975 + va_start(args, fmt);
55976 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
55977 + va_end(args);
55978 +
55979 + learn_buffer_len += len + 1;
55980 +
55981 + spin_unlock(&gr_learn_lock);
55982 + wake_up_interruptible(&learn_wait);
55983 +
55984 + return;
55985 +}
55986 +
55987 +static int
55988 +open_learn(struct inode *inode, struct file *file)
55989 +{
55990 + if (file->f_mode & FMODE_READ && gr_learn_attached)
55991 + return -EBUSY;
55992 + if (file->f_mode & FMODE_READ) {
55993 + int retval = 0;
55994 + mutex_lock(&gr_learn_user_mutex);
55995 + if (learn_buffer == NULL)
55996 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
55997 + if (learn_buffer_user == NULL)
55998 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
55999 + if (learn_buffer == NULL) {
56000 + retval = -ENOMEM;
56001 + goto out_error;
56002 + }
56003 + if (learn_buffer_user == NULL) {
56004 + retval = -ENOMEM;
56005 + goto out_error;
56006 + }
56007 + learn_buffer_len = 0;
56008 + learn_buffer_user_len = 0;
56009 + gr_learn_attached = 1;
56010 +out_error:
56011 + mutex_unlock(&gr_learn_user_mutex);
56012 + return retval;
56013 + }
56014 + return 0;
56015 +}
56016 +
56017 +static int
56018 +close_learn(struct inode *inode, struct file *file)
56019 +{
56020 + if (file->f_mode & FMODE_READ) {
56021 + char *tmp = NULL;
56022 + mutex_lock(&gr_learn_user_mutex);
56023 + spin_lock(&gr_learn_lock);
56024 + tmp = learn_buffer;
56025 + learn_buffer = NULL;
56026 + spin_unlock(&gr_learn_lock);
56027 + if (tmp)
56028 + vfree(tmp);
56029 + if (learn_buffer_user != NULL) {
56030 + vfree(learn_buffer_user);
56031 + learn_buffer_user = NULL;
56032 + }
56033 + learn_buffer_len = 0;
56034 + learn_buffer_user_len = 0;
56035 + gr_learn_attached = 0;
56036 + mutex_unlock(&gr_learn_user_mutex);
56037 + }
56038 +
56039 + return 0;
56040 +}
56041 +
56042 +const struct file_operations grsec_fops = {
56043 + .read = read_learn,
56044 + .write = write_grsec_handler,
56045 + .open = open_learn,
56046 + .release = close_learn,
56047 + .poll = poll_learn,
56048 +};
56049 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
56050 new file mode 100644
56051 index 0000000..39645c9
56052 --- /dev/null
56053 +++ b/grsecurity/gracl_res.c
56054 @@ -0,0 +1,68 @@
56055 +#include <linux/kernel.h>
56056 +#include <linux/sched.h>
56057 +#include <linux/gracl.h>
56058 +#include <linux/grinternal.h>
56059 +
56060 +static const char *restab_log[] = {
56061 + [RLIMIT_CPU] = "RLIMIT_CPU",
56062 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
56063 + [RLIMIT_DATA] = "RLIMIT_DATA",
56064 + [RLIMIT_STACK] = "RLIMIT_STACK",
56065 + [RLIMIT_CORE] = "RLIMIT_CORE",
56066 + [RLIMIT_RSS] = "RLIMIT_RSS",
56067 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
56068 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
56069 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
56070 + [RLIMIT_AS] = "RLIMIT_AS",
56071 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
56072 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
56073 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
56074 + [RLIMIT_NICE] = "RLIMIT_NICE",
56075 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
56076 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
56077 + [GR_CRASH_RES] = "RLIMIT_CRASH"
56078 +};
56079 +
56080 +void
56081 +gr_log_resource(const struct task_struct *task,
56082 + const int res, const unsigned long wanted, const int gt)
56083 +{
56084 + const struct cred *cred;
56085 + unsigned long rlim;
56086 +
56087 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
56088 + return;
56089 +
56090 + // not yet supported resource
56091 + if (unlikely(!restab_log[res]))
56092 + return;
56093 +
56094 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
56095 + rlim = task_rlimit_max(task, res);
56096 + else
56097 + rlim = task_rlimit(task, res);
56098 +
56099 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
56100 + return;
56101 +
56102 + rcu_read_lock();
56103 + cred = __task_cred(task);
56104 +
56105 + if (res == RLIMIT_NPROC &&
56106 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
56107 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
56108 + goto out_rcu_unlock;
56109 + else if (res == RLIMIT_MEMLOCK &&
56110 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
56111 + goto out_rcu_unlock;
56112 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
56113 + goto out_rcu_unlock;
56114 + rcu_read_unlock();
56115 +
56116 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
56117 +
56118 + return;
56119 +out_rcu_unlock:
56120 + rcu_read_unlock();
56121 + return;
56122 +}
56123 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
56124 new file mode 100644
56125 index 0000000..5556be3
56126 --- /dev/null
56127 +++ b/grsecurity/gracl_segv.c
56128 @@ -0,0 +1,299 @@
56129 +#include <linux/kernel.h>
56130 +#include <linux/mm.h>
56131 +#include <asm/uaccess.h>
56132 +#include <asm/errno.h>
56133 +#include <asm/mman.h>
56134 +#include <net/sock.h>
56135 +#include <linux/file.h>
56136 +#include <linux/fs.h>
56137 +#include <linux/net.h>
56138 +#include <linux/in.h>
56139 +#include <linux/slab.h>
56140 +#include <linux/types.h>
56141 +#include <linux/sched.h>
56142 +#include <linux/timer.h>
56143 +#include <linux/gracl.h>
56144 +#include <linux/grsecurity.h>
56145 +#include <linux/grinternal.h>
56146 +
56147 +static struct crash_uid *uid_set;
56148 +static unsigned short uid_used;
56149 +static DEFINE_SPINLOCK(gr_uid_lock);
56150 +extern rwlock_t gr_inode_lock;
56151 +extern struct acl_subject_label *
56152 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
56153 + struct acl_role_label *role);
56154 +
56155 +#ifdef CONFIG_BTRFS_FS
56156 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
56157 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
56158 +#endif
56159 +
56160 +static inline dev_t __get_dev(const struct dentry *dentry)
56161 +{
56162 +#ifdef CONFIG_BTRFS_FS
56163 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
56164 + return get_btrfs_dev_from_inode(dentry->d_inode);
56165 + else
56166 +#endif
56167 + return dentry->d_inode->i_sb->s_dev;
56168 +}
56169 +
56170 +int
56171 +gr_init_uidset(void)
56172 +{
56173 + uid_set =
56174 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
56175 + uid_used = 0;
56176 +
56177 + return uid_set ? 1 : 0;
56178 +}
56179 +
56180 +void
56181 +gr_free_uidset(void)
56182 +{
56183 + if (uid_set)
56184 + kfree(uid_set);
56185 +
56186 + return;
56187 +}
56188 +
56189 +int
56190 +gr_find_uid(const uid_t uid)
56191 +{
56192 + struct crash_uid *tmp = uid_set;
56193 + uid_t buid;
56194 + int low = 0, high = uid_used - 1, mid;
56195 +
56196 + while (high >= low) {
56197 + mid = (low + high) >> 1;
56198 + buid = tmp[mid].uid;
56199 + if (buid == uid)
56200 + return mid;
56201 + if (buid > uid)
56202 + high = mid - 1;
56203 + if (buid < uid)
56204 + low = mid + 1;
56205 + }
56206 +
56207 + return -1;
56208 +}
56209 +
56210 +static __inline__ void
56211 +gr_insertsort(void)
56212 +{
56213 + unsigned short i, j;
56214 + struct crash_uid index;
56215 +
56216 + for (i = 1; i < uid_used; i++) {
56217 + index = uid_set[i];
56218 + j = i;
56219 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
56220 + uid_set[j] = uid_set[j - 1];
56221 + j--;
56222 + }
56223 + uid_set[j] = index;
56224 + }
56225 +
56226 + return;
56227 +}
56228 +
56229 +static __inline__ void
56230 +gr_insert_uid(const uid_t uid, const unsigned long expires)
56231 +{
56232 + int loc;
56233 +
56234 + if (uid_used == GR_UIDTABLE_MAX)
56235 + return;
56236 +
56237 + loc = gr_find_uid(uid);
56238 +
56239 + if (loc >= 0) {
56240 + uid_set[loc].expires = expires;
56241 + return;
56242 + }
56243 +
56244 + uid_set[uid_used].uid = uid;
56245 + uid_set[uid_used].expires = expires;
56246 + uid_used++;
56247 +
56248 + gr_insertsort();
56249 +
56250 + return;
56251 +}
56252 +
56253 +void
56254 +gr_remove_uid(const unsigned short loc)
56255 +{
56256 + unsigned short i;
56257 +
56258 + for (i = loc + 1; i < uid_used; i++)
56259 + uid_set[i - 1] = uid_set[i];
56260 +
56261 + uid_used--;
56262 +
56263 + return;
56264 +}
56265 +
56266 +int
56267 +gr_check_crash_uid(const uid_t uid)
56268 +{
56269 + int loc;
56270 + int ret = 0;
56271 +
56272 + if (unlikely(!gr_acl_is_enabled()))
56273 + return 0;
56274 +
56275 + spin_lock(&gr_uid_lock);
56276 + loc = gr_find_uid(uid);
56277 +
56278 + if (loc < 0)
56279 + goto out_unlock;
56280 +
56281 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
56282 + gr_remove_uid(loc);
56283 + else
56284 + ret = 1;
56285 +
56286 +out_unlock:
56287 + spin_unlock(&gr_uid_lock);
56288 + return ret;
56289 +}
56290 +
56291 +static __inline__ int
56292 +proc_is_setxid(const struct cred *cred)
56293 +{
56294 + if (cred->uid != cred->euid || cred->uid != cred->suid ||
56295 + cred->uid != cred->fsuid)
56296 + return 1;
56297 + if (cred->gid != cred->egid || cred->gid != cred->sgid ||
56298 + cred->gid != cred->fsgid)
56299 + return 1;
56300 +
56301 + return 0;
56302 +}
56303 +
56304 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
56305 +
56306 +void
56307 +gr_handle_crash(struct task_struct *task, const int sig)
56308 +{
56309 + struct acl_subject_label *curr;
56310 + struct task_struct *tsk, *tsk2;
56311 + const struct cred *cred;
56312 + const struct cred *cred2;
56313 +
56314 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
56315 + return;
56316 +
56317 + if (unlikely(!gr_acl_is_enabled()))
56318 + return;
56319 +
56320 + curr = task->acl;
56321 +
56322 + if (!(curr->resmask & (1 << GR_CRASH_RES)))
56323 + return;
56324 +
56325 + if (time_before_eq(curr->expires, get_seconds())) {
56326 + curr->expires = 0;
56327 + curr->crashes = 0;
56328 + }
56329 +
56330 + curr->crashes++;
56331 +
56332 + if (!curr->expires)
56333 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
56334 +
56335 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
56336 + time_after(curr->expires, get_seconds())) {
56337 + rcu_read_lock();
56338 + cred = __task_cred(task);
56339 + if (cred->uid && proc_is_setxid(cred)) {
56340 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
56341 + spin_lock(&gr_uid_lock);
56342 + gr_insert_uid(cred->uid, curr->expires);
56343 + spin_unlock(&gr_uid_lock);
56344 + curr->expires = 0;
56345 + curr->crashes = 0;
56346 + read_lock(&tasklist_lock);
56347 + do_each_thread(tsk2, tsk) {
56348 + cred2 = __task_cred(tsk);
56349 + if (tsk != task && cred2->uid == cred->uid)
56350 + gr_fake_force_sig(SIGKILL, tsk);
56351 + } while_each_thread(tsk2, tsk);
56352 + read_unlock(&tasklist_lock);
56353 + } else {
56354 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
56355 + read_lock(&tasklist_lock);
56356 + read_lock(&grsec_exec_file_lock);
56357 + do_each_thread(tsk2, tsk) {
56358 + if (likely(tsk != task)) {
56359 + // if this thread has the same subject as the one that triggered
56360 + // RES_CRASH and it's the same binary, kill it
56361 + if (tsk->acl == task->acl && tsk->exec_file == task->exec_file)
56362 + gr_fake_force_sig(SIGKILL, tsk);
56363 + }
56364 + } while_each_thread(tsk2, tsk);
56365 + read_unlock(&grsec_exec_file_lock);
56366 + read_unlock(&tasklist_lock);
56367 + }
56368 + rcu_read_unlock();
56369 + }
56370 +
56371 + return;
56372 +}
56373 +
56374 +int
56375 +gr_check_crash_exec(const struct file *filp)
56376 +{
56377 + struct acl_subject_label *curr;
56378 +
56379 + if (unlikely(!gr_acl_is_enabled()))
56380 + return 0;
56381 +
56382 + read_lock(&gr_inode_lock);
56383 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
56384 + __get_dev(filp->f_path.dentry),
56385 + current->role);
56386 + read_unlock(&gr_inode_lock);
56387 +
56388 + if (!curr || !(curr->resmask & (1 << GR_CRASH_RES)) ||
56389 + (!curr->crashes && !curr->expires))
56390 + return 0;
56391 +
56392 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
56393 + time_after(curr->expires, get_seconds()))
56394 + return 1;
56395 + else if (time_before_eq(curr->expires, get_seconds())) {
56396 + curr->crashes = 0;
56397 + curr->expires = 0;
56398 + }
56399 +
56400 + return 0;
56401 +}
56402 +
56403 +void
56404 +gr_handle_alertkill(struct task_struct *task)
56405 +{
56406 + struct acl_subject_label *curracl;
56407 + __u32 curr_ip;
56408 + struct task_struct *p, *p2;
56409 +
56410 + if (unlikely(!gr_acl_is_enabled()))
56411 + return;
56412 +
56413 + curracl = task->acl;
56414 + curr_ip = task->signal->curr_ip;
56415 +
56416 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
56417 + read_lock(&tasklist_lock);
56418 + do_each_thread(p2, p) {
56419 + if (p->signal->curr_ip == curr_ip)
56420 + gr_fake_force_sig(SIGKILL, p);
56421 + } while_each_thread(p2, p);
56422 + read_unlock(&tasklist_lock);
56423 + } else if (curracl->mode & GR_KILLPROC)
56424 + gr_fake_force_sig(SIGKILL, task);
56425 +
56426 + return;
56427 +}
56428 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
56429 new file mode 100644
56430 index 0000000..9d83a69
56431 --- /dev/null
56432 +++ b/grsecurity/gracl_shm.c
56433 @@ -0,0 +1,40 @@
56434 +#include <linux/kernel.h>
56435 +#include <linux/mm.h>
56436 +#include <linux/sched.h>
56437 +#include <linux/file.h>
56438 +#include <linux/ipc.h>
56439 +#include <linux/gracl.h>
56440 +#include <linux/grsecurity.h>
56441 +#include <linux/grinternal.h>
56442 +
56443 +int
56444 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
56445 + const time_t shm_createtime, const uid_t cuid, const int shmid)
56446 +{
56447 + struct task_struct *task;
56448 +
56449 + if (!gr_acl_is_enabled())
56450 + return 1;
56451 +
56452 + rcu_read_lock();
56453 + read_lock(&tasklist_lock);
56454 +
56455 + task = find_task_by_vpid(shm_cprid);
56456 +
56457 + if (unlikely(!task))
56458 + task = find_task_by_vpid(shm_lapid);
56459 +
56460 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
56461 + (task->pid == shm_lapid)) &&
56462 + (task->acl->mode & GR_PROTSHM) &&
56463 + (task->acl != current->acl))) {
56464 + read_unlock(&tasklist_lock);
56465 + rcu_read_unlock();
56466 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, cuid, shm_cprid, shmid);
56467 + return 0;
56468 + }
56469 + read_unlock(&tasklist_lock);
56470 + rcu_read_unlock();
56471 +
56472 + return 1;
56473 +}
56474 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
56475 new file mode 100644
56476 index 0000000..bc0be01
56477 --- /dev/null
56478 +++ b/grsecurity/grsec_chdir.c
56479 @@ -0,0 +1,19 @@
56480 +#include <linux/kernel.h>
56481 +#include <linux/sched.h>
56482 +#include <linux/fs.h>
56483 +#include <linux/file.h>
56484 +#include <linux/grsecurity.h>
56485 +#include <linux/grinternal.h>
56486 +
56487 +void
56488 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
56489 +{
56490 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
56491 + if ((grsec_enable_chdir && grsec_enable_group &&
56492 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
56493 + !grsec_enable_group)) {
56494 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
56495 + }
56496 +#endif
56497 + return;
56498 +}
56499 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
56500 new file mode 100644
56501 index 0000000..9807ee2
56502 --- /dev/null
56503 +++ b/grsecurity/grsec_chroot.c
56504 @@ -0,0 +1,368 @@
56505 +#include <linux/kernel.h>
56506 +#include <linux/module.h>
56507 +#include <linux/sched.h>
56508 +#include <linux/file.h>
56509 +#include <linux/fs.h>
56510 +#include <linux/mount.h>
56511 +#include <linux/types.h>
56512 +#include "../fs/mount.h"
56513 +#include <linux/grsecurity.h>
56514 +#include <linux/grinternal.h>
56515 +
56516 +void gr_set_chroot_entries(struct task_struct *task, struct path *path)
56517 +{
56518 +#ifdef CONFIG_GRKERNSEC
56519 + if (task->pid > 1 && path->dentry != init_task.fs->root.dentry &&
56520 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root)
56521 + task->gr_is_chrooted = 1;
56522 + else
56523 + task->gr_is_chrooted = 0;
56524 +
56525 + task->gr_chroot_dentry = path->dentry;
56526 +#endif
56527 + return;
56528 +}
56529 +
56530 +void gr_clear_chroot_entries(struct task_struct *task)
56531 +{
56532 +#ifdef CONFIG_GRKERNSEC
56533 + task->gr_is_chrooted = 0;
56534 + task->gr_chroot_dentry = NULL;
56535 +#endif
56536 + return;
56537 +}
56538 +
56539 +int
56540 +gr_handle_chroot_unix(const pid_t pid)
56541 +{
56542 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
56543 + struct task_struct *p;
56544 +
56545 + if (unlikely(!grsec_enable_chroot_unix))
56546 + return 1;
56547 +
56548 + if (likely(!proc_is_chrooted(current)))
56549 + return 1;
56550 +
56551 + rcu_read_lock();
56552 + read_lock(&tasklist_lock);
56553 + p = find_task_by_vpid_unrestricted(pid);
56554 + if (unlikely(p && !have_same_root(current, p))) {
56555 + read_unlock(&tasklist_lock);
56556 + rcu_read_unlock();
56557 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
56558 + return 0;
56559 + }
56560 + read_unlock(&tasklist_lock);
56561 + rcu_read_unlock();
56562 +#endif
56563 + return 1;
56564 +}
56565 +
56566 +int
56567 +gr_handle_chroot_nice(void)
56568 +{
56569 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
56570 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
56571 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
56572 + return -EPERM;
56573 + }
56574 +#endif
56575 + return 0;
56576 +}
56577 +
56578 +int
56579 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
56580 +{
56581 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
56582 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
56583 + && proc_is_chrooted(current)) {
56584 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, p->pid);
56585 + return -EACCES;
56586 + }
56587 +#endif
56588 + return 0;
56589 +}
56590 +
56591 +int
56592 +gr_handle_chroot_rawio(const struct inode *inode)
56593 +{
56594 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
56595 + if (grsec_enable_chroot_caps && proc_is_chrooted(current) &&
56596 + inode && S_ISBLK(inode->i_mode) && !capable(CAP_SYS_RAWIO))
56597 + return 1;
56598 +#endif
56599 + return 0;
56600 +}
56601 +
56602 +int
56603 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
56604 +{
56605 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
56606 + struct task_struct *p;
56607 + int ret = 0;
56608 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
56609 + return ret;
56610 +
56611 + read_lock(&tasklist_lock);
56612 + do_each_pid_task(pid, type, p) {
56613 + if (!have_same_root(current, p)) {
56614 + ret = 1;
56615 + goto out;
56616 + }
56617 + } while_each_pid_task(pid, type, p);
56618 +out:
56619 + read_unlock(&tasklist_lock);
56620 + return ret;
56621 +#endif
56622 + return 0;
56623 +}
56624 +
56625 +int
56626 +gr_pid_is_chrooted(struct task_struct *p)
56627 +{
56628 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
56629 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
56630 + return 0;
56631 +
56632 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
56633 + !have_same_root(current, p)) {
56634 + return 1;
56635 + }
56636 +#endif
56637 + return 0;
56638 +}
56639 +
56640 +EXPORT_SYMBOL(gr_pid_is_chrooted);
56641 +
56642 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
56643 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
56644 +{
56645 + struct path path, currentroot;
56646 + int ret = 0;
56647 +
56648 + path.dentry = (struct dentry *)u_dentry;
56649 + path.mnt = (struct vfsmount *)u_mnt;
56650 + get_fs_root(current->fs, &currentroot);
56651 + if (path_is_under(&path, &currentroot))
56652 + ret = 1;
56653 + path_put(&currentroot);
56654 +
56655 + return ret;
56656 +}
56657 +#endif
56658 +
56659 +int
56660 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
56661 +{
56662 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
56663 + if (!grsec_enable_chroot_fchdir)
56664 + return 1;
56665 +
56666 + if (!proc_is_chrooted(current))
56667 + return 1;
56668 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
56669 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
56670 + return 0;
56671 + }
56672 +#endif
56673 + return 1;
56674 +}
56675 +
56676 +int
56677 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
56678 + const time_t shm_createtime)
56679 +{
56680 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
56681 + struct task_struct *p;
56682 + time_t starttime;
56683 +
56684 + if (unlikely(!grsec_enable_chroot_shmat))
56685 + return 1;
56686 +
56687 + if (likely(!proc_is_chrooted(current)))
56688 + return 1;
56689 +
56690 + rcu_read_lock();
56691 + read_lock(&tasklist_lock);
56692 +
56693 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
56694 + starttime = p->start_time.tv_sec;
56695 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
56696 + if (have_same_root(current, p)) {
56697 + goto allow;
56698 + } else {
56699 + read_unlock(&tasklist_lock);
56700 + rcu_read_unlock();
56701 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
56702 + return 0;
56703 + }
56704 + }
56705 + /* creator exited, pid reuse, fall through to next check */
56706 + }
56707 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
56708 + if (unlikely(!have_same_root(current, p))) {
56709 + read_unlock(&tasklist_lock);
56710 + rcu_read_unlock();
56711 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
56712 + return 0;
56713 + }
56714 + }
56715 +
56716 +allow:
56717 + read_unlock(&tasklist_lock);
56718 + rcu_read_unlock();
56719 +#endif
56720 + return 1;
56721 +}
56722 +
56723 +void
56724 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
56725 +{
56726 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
56727 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
56728 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
56729 +#endif
56730 + return;
56731 +}
56732 +
56733 +int
56734 +gr_handle_chroot_mknod(const struct dentry *dentry,
56735 + const struct vfsmount *mnt, const int mode)
56736 +{
56737 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
56738 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
56739 + proc_is_chrooted(current)) {
56740 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
56741 + return -EPERM;
56742 + }
56743 +#endif
56744 + return 0;
56745 +}
56746 +
56747 +int
56748 +gr_handle_chroot_mount(const struct dentry *dentry,
56749 + const struct vfsmount *mnt, const char *dev_name)
56750 +{
56751 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
56752 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
56753 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
56754 + return -EPERM;
56755 + }
56756 +#endif
56757 + return 0;
56758 +}
56759 +
56760 +int
56761 +gr_handle_chroot_pivot(void)
56762 +{
56763 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
56764 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
56765 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
56766 + return -EPERM;
56767 + }
56768 +#endif
56769 + return 0;
56770 +}
56771 +
56772 +int
56773 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
56774 +{
56775 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
56776 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
56777 + !gr_is_outside_chroot(dentry, mnt)) {
56778 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
56779 + return -EPERM;
56780 + }
56781 +#endif
56782 + return 0;
56783 +}
56784 +
56785 +extern const char *captab_log[];
56786 +extern int captab_log_entries;
56787 +
56788 +int
56789 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
56790 +{
56791 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
56792 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
56793 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
56794 + if (cap_raised(chroot_caps, cap)) {
56795 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
56796 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
56797 + }
56798 + return 0;
56799 + }
56800 + }
56801 +#endif
56802 + return 1;
56803 +}
56804 +
56805 +int
56806 +gr_chroot_is_capable(const int cap)
56807 +{
56808 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
56809 + return gr_task_chroot_is_capable(current, current_cred(), cap);
56810 +#endif
56811 + return 1;
56812 +}
56813 +
56814 +int
56815 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
56816 +{
56817 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
56818 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
56819 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
56820 + if (cap_raised(chroot_caps, cap)) {
56821 + return 0;
56822 + }
56823 + }
56824 +#endif
56825 + return 1;
56826 +}
56827 +
56828 +int
56829 +gr_chroot_is_capable_nolog(const int cap)
56830 +{
56831 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
56832 + return gr_task_chroot_is_capable_nolog(current, cap);
56833 +#endif
56834 + return 1;
56835 +}
56836 +
56837 +int
56838 +gr_handle_chroot_sysctl(const int op)
56839 +{
56840 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
56841 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
56842 + proc_is_chrooted(current))
56843 + return -EACCES;
56844 +#endif
56845 + return 0;
56846 +}
56847 +
56848 +void
56849 +gr_handle_chroot_chdir(struct path *path)
56850 +{
56851 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
56852 + if (grsec_enable_chroot_chdir)
56853 + set_fs_pwd(current->fs, path);
56854 +#endif
56855 + return;
56856 +}
56857 +
56858 +int
56859 +gr_handle_chroot_chmod(const struct dentry *dentry,
56860 + const struct vfsmount *mnt, const int mode)
56861 +{
56862 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
56863 + /* allow chmod +s on directories, but not files */
56864 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
56865 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
56866 + proc_is_chrooted(current)) {
56867 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
56868 + return -EPERM;
56869 + }
56870 +#endif
56871 + return 0;
56872 +}
56873 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
56874 new file mode 100644
56875 index 0000000..213ad8b
56876 --- /dev/null
56877 +++ b/grsecurity/grsec_disabled.c
56878 @@ -0,0 +1,437 @@
56879 +#include <linux/kernel.h>
56880 +#include <linux/module.h>
56881 +#include <linux/sched.h>
56882 +#include <linux/file.h>
56883 +#include <linux/fs.h>
56884 +#include <linux/kdev_t.h>
56885 +#include <linux/net.h>
56886 +#include <linux/in.h>
56887 +#include <linux/ip.h>
56888 +#include <linux/skbuff.h>
56889 +#include <linux/sysctl.h>
56890 +
56891 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
56892 +void
56893 +pax_set_initial_flags(struct linux_binprm *bprm)
56894 +{
56895 + return;
56896 +}
56897 +#endif
56898 +
56899 +#ifdef CONFIG_SYSCTL
56900 +__u32
56901 +gr_handle_sysctl(const struct ctl_table * table, const int op)
56902 +{
56903 + return 0;
56904 +}
56905 +#endif
56906 +
56907 +#ifdef CONFIG_TASKSTATS
56908 +int gr_is_taskstats_denied(int pid)
56909 +{
56910 + return 0;
56911 +}
56912 +#endif
56913 +
56914 +int
56915 +gr_acl_is_enabled(void)
56916 +{
56917 + return 0;
56918 +}
56919 +
56920 +void
56921 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
56922 +{
56923 + return;
56924 +}
56925 +
56926 +int
56927 +gr_handle_rawio(const struct inode *inode)
56928 +{
56929 + return 0;
56930 +}
56931 +
56932 +void
56933 +gr_acl_handle_psacct(struct task_struct *task, const long code)
56934 +{
56935 + return;
56936 +}
56937 +
56938 +int
56939 +gr_handle_ptrace(struct task_struct *task, const long request)
56940 +{
56941 + return 0;
56942 +}
56943 +
56944 +int
56945 +gr_handle_proc_ptrace(struct task_struct *task)
56946 +{
56947 + return 0;
56948 +}
56949 +
56950 +void
56951 +gr_learn_resource(const struct task_struct *task,
56952 + const int res, const unsigned long wanted, const int gt)
56953 +{
56954 + return;
56955 +}
56956 +
56957 +int
56958 +gr_set_acls(const int type)
56959 +{
56960 + return 0;
56961 +}
56962 +
56963 +int
56964 +gr_check_hidden_task(const struct task_struct *tsk)
56965 +{
56966 + return 0;
56967 +}
56968 +
56969 +int
56970 +gr_check_protected_task(const struct task_struct *task)
56971 +{
56972 + return 0;
56973 +}
56974 +
56975 +int
56976 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
56977 +{
56978 + return 0;
56979 +}
56980 +
56981 +void
56982 +gr_copy_label(struct task_struct *tsk)
56983 +{
56984 + return;
56985 +}
56986 +
56987 +void
56988 +gr_set_pax_flags(struct task_struct *task)
56989 +{
56990 + return;
56991 +}
56992 +
56993 +int
56994 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
56995 + const int unsafe_share)
56996 +{
56997 + return 0;
56998 +}
56999 +
57000 +void
57001 +gr_handle_delete(const ino_t ino, const dev_t dev)
57002 +{
57003 + return;
57004 +}
57005 +
57006 +void
57007 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
57008 +{
57009 + return;
57010 +}
57011 +
57012 +void
57013 +gr_handle_crash(struct task_struct *task, const int sig)
57014 +{
57015 + return;
57016 +}
57017 +
57018 +int
57019 +gr_check_crash_exec(const struct file *filp)
57020 +{
57021 + return 0;
57022 +}
57023 +
57024 +int
57025 +gr_check_crash_uid(const uid_t uid)
57026 +{
57027 + return 0;
57028 +}
57029 +
57030 +void
57031 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
57032 + struct dentry *old_dentry,
57033 + struct dentry *new_dentry,
57034 + struct vfsmount *mnt, const __u8 replace)
57035 +{
57036 + return;
57037 +}
57038 +
57039 +int
57040 +gr_search_socket(const int family, const int type, const int protocol)
57041 +{
57042 + return 1;
57043 +}
57044 +
57045 +int
57046 +gr_search_connectbind(const int mode, const struct socket *sock,
57047 + const struct sockaddr_in *addr)
57048 +{
57049 + return 0;
57050 +}
57051 +
57052 +void
57053 +gr_handle_alertkill(struct task_struct *task)
57054 +{
57055 + return;
57056 +}
57057 +
57058 +__u32
57059 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
57060 +{
57061 + return 1;
57062 +}
57063 +
57064 +__u32
57065 +gr_acl_handle_hidden_file(const struct dentry * dentry,
57066 + const struct vfsmount * mnt)
57067 +{
57068 + return 1;
57069 +}
57070 +
57071 +__u32
57072 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
57073 + int acc_mode)
57074 +{
57075 + return 1;
57076 +}
57077 +
57078 +__u32
57079 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
57080 +{
57081 + return 1;
57082 +}
57083 +
57084 +__u32
57085 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
57086 +{
57087 + return 1;
57088 +}
57089 +
57090 +int
57091 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
57092 + unsigned int *vm_flags)
57093 +{
57094 + return 1;
57095 +}
57096 +
57097 +__u32
57098 +gr_acl_handle_truncate(const struct dentry * dentry,
57099 + const struct vfsmount * mnt)
57100 +{
57101 + return 1;
57102 +}
57103 +
57104 +__u32
57105 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
57106 +{
57107 + return 1;
57108 +}
57109 +
57110 +__u32
57111 +gr_acl_handle_access(const struct dentry * dentry,
57112 + const struct vfsmount * mnt, const int fmode)
57113 +{
57114 + return 1;
57115 +}
57116 +
57117 +__u32
57118 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
57119 + umode_t *mode)
57120 +{
57121 + return 1;
57122 +}
57123 +
57124 +__u32
57125 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
57126 +{
57127 + return 1;
57128 +}
57129 +
57130 +__u32
57131 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
57132 +{
57133 + return 1;
57134 +}
57135 +
57136 +void
57137 +grsecurity_init(void)
57138 +{
57139 + return;
57140 +}
57141 +
57142 +umode_t gr_acl_umask(void)
57143 +{
57144 + return 0;
57145 +}
57146 +
57147 +__u32
57148 +gr_acl_handle_mknod(const struct dentry * new_dentry,
57149 + const struct dentry * parent_dentry,
57150 + const struct vfsmount * parent_mnt,
57151 + const int mode)
57152 +{
57153 + return 1;
57154 +}
57155 +
57156 +__u32
57157 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
57158 + const struct dentry * parent_dentry,
57159 + const struct vfsmount * parent_mnt)
57160 +{
57161 + return 1;
57162 +}
57163 +
57164 +__u32
57165 +gr_acl_handle_symlink(const struct dentry * new_dentry,
57166 + const struct dentry * parent_dentry,
57167 + const struct vfsmount * parent_mnt, const char *from)
57168 +{
57169 + return 1;
57170 +}
57171 +
57172 +__u32
57173 +gr_acl_handle_link(const struct dentry * new_dentry,
57174 + const struct dentry * parent_dentry,
57175 + const struct vfsmount * parent_mnt,
57176 + const struct dentry * old_dentry,
57177 + const struct vfsmount * old_mnt, const char *to)
57178 +{
57179 + return 1;
57180 +}
57181 +
57182 +int
57183 +gr_acl_handle_rename(const struct dentry *new_dentry,
57184 + const struct dentry *parent_dentry,
57185 + const struct vfsmount *parent_mnt,
57186 + const struct dentry *old_dentry,
57187 + const struct inode *old_parent_inode,
57188 + const struct vfsmount *old_mnt, const char *newname)
57189 +{
57190 + return 0;
57191 +}
57192 +
57193 +int
57194 +gr_acl_handle_filldir(const struct file *file, const char *name,
57195 + const int namelen, const ino_t ino)
57196 +{
57197 + return 1;
57198 +}
57199 +
57200 +int
57201 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
57202 + const time_t shm_createtime, const uid_t cuid, const int shmid)
57203 +{
57204 + return 1;
57205 +}
57206 +
57207 +int
57208 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
57209 +{
57210 + return 0;
57211 +}
57212 +
57213 +int
57214 +gr_search_accept(const struct socket *sock)
57215 +{
57216 + return 0;
57217 +}
57218 +
57219 +int
57220 +gr_search_listen(const struct socket *sock)
57221 +{
57222 + return 0;
57223 +}
57224 +
57225 +int
57226 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
57227 +{
57228 + return 0;
57229 +}
57230 +
57231 +__u32
57232 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
57233 +{
57234 + return 1;
57235 +}
57236 +
57237 +__u32
57238 +gr_acl_handle_creat(const struct dentry * dentry,
57239 + const struct dentry * p_dentry,
57240 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
57241 + const int imode)
57242 +{
57243 + return 1;
57244 +}
57245 +
57246 +void
57247 +gr_acl_handle_exit(void)
57248 +{
57249 + return;
57250 +}
57251 +
57252 +int
57253 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
57254 +{
57255 + return 1;
57256 +}
57257 +
57258 +void
57259 +gr_set_role_label(const uid_t uid, const gid_t gid)
57260 +{
57261 + return;
57262 +}
57263 +
57264 +int
57265 +gr_acl_handle_procpidmem(const struct task_struct *task)
57266 +{
57267 + return 0;
57268 +}
57269 +
57270 +int
57271 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
57272 +{
57273 + return 0;
57274 +}
57275 +
57276 +int
57277 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
57278 +{
57279 + return 0;
57280 +}
57281 +
57282 +void
57283 +gr_set_kernel_label(struct task_struct *task)
57284 +{
57285 + return;
57286 +}
57287 +
57288 +int
57289 +gr_check_user_change(int real, int effective, int fs)
57290 +{
57291 + return 0;
57292 +}
57293 +
57294 +int
57295 +gr_check_group_change(int real, int effective, int fs)
57296 +{
57297 + return 0;
57298 +}
57299 +
57300 +int gr_acl_enable_at_secure(void)
57301 +{
57302 + return 0;
57303 +}
57304 +
57305 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
57306 +{
57307 + return dentry->d_inode->i_sb->s_dev;
57308 +}
57309 +
57310 +EXPORT_SYMBOL(gr_learn_resource);
57311 +EXPORT_SYMBOL(gr_set_kernel_label);
57312 +#ifdef CONFIG_SECURITY
57313 +EXPORT_SYMBOL(gr_check_user_change);
57314 +EXPORT_SYMBOL(gr_check_group_change);
57315 +#endif
57316 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
57317 new file mode 100644
57318 index 0000000..abfa971
57319 --- /dev/null
57320 +++ b/grsecurity/grsec_exec.c
57321 @@ -0,0 +1,174 @@
57322 +#include <linux/kernel.h>
57323 +#include <linux/sched.h>
57324 +#include <linux/file.h>
57325 +#include <linux/binfmts.h>
57326 +#include <linux/fs.h>
57327 +#include <linux/types.h>
57328 +#include <linux/grdefs.h>
57329 +#include <linux/grsecurity.h>
57330 +#include <linux/grinternal.h>
57331 +#include <linux/capability.h>
57332 +#include <linux/module.h>
57333 +
57334 +#include <asm/uaccess.h>
57335 +
57336 +#ifdef CONFIG_GRKERNSEC_EXECLOG
57337 +static char gr_exec_arg_buf[132];
57338 +static DEFINE_MUTEX(gr_exec_arg_mutex);
57339 +#endif
57340 +
57341 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
57342 +
57343 +void
57344 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
57345 +{
57346 +#ifdef CONFIG_GRKERNSEC_EXECLOG
57347 + char *grarg = gr_exec_arg_buf;
57348 + unsigned int i, x, execlen = 0;
57349 + char c;
57350 +
57351 + if (!((grsec_enable_execlog && grsec_enable_group &&
57352 + in_group_p(grsec_audit_gid))
57353 + || (grsec_enable_execlog && !grsec_enable_group)))
57354 + return;
57355 +
57356 + mutex_lock(&gr_exec_arg_mutex);
57357 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
57358 +
57359 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
57360 + const char __user *p;
57361 + unsigned int len;
57362 +
57363 + p = get_user_arg_ptr(argv, i);
57364 + if (IS_ERR(p))
57365 + goto log;
57366 +
57367 + len = strnlen_user(p, 128 - execlen);
57368 + if (len > 128 - execlen)
57369 + len = 128 - execlen;
57370 + else if (len > 0)
57371 + len--;
57372 + if (copy_from_user(grarg + execlen, p, len))
57373 + goto log;
57374 +
57375 + /* rewrite unprintable characters */
57376 + for (x = 0; x < len; x++) {
57377 + c = *(grarg + execlen + x);
57378 + if (c < 32 || c > 126)
57379 + *(grarg + execlen + x) = ' ';
57380 + }
57381 +
57382 + execlen += len;
57383 + *(grarg + execlen) = ' ';
57384 + *(grarg + execlen + 1) = '\0';
57385 + execlen++;
57386 + }
57387 +
57388 + log:
57389 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
57390 + bprm->file->f_path.mnt, grarg);
57391 + mutex_unlock(&gr_exec_arg_mutex);
57392 +#endif
57393 + return;
57394 +}
57395 +
57396 +#ifdef CONFIG_GRKERNSEC
57397 +extern int gr_acl_is_capable(const int cap);
57398 +extern int gr_acl_is_capable_nolog(const int cap);
57399 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
57400 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
57401 +extern int gr_chroot_is_capable(const int cap);
57402 +extern int gr_chroot_is_capable_nolog(const int cap);
57403 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
57404 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
57405 +#endif
57406 +
57407 +const char *captab_log[] = {
57408 + "CAP_CHOWN",
57409 + "CAP_DAC_OVERRIDE",
57410 + "CAP_DAC_READ_SEARCH",
57411 + "CAP_FOWNER",
57412 + "CAP_FSETID",
57413 + "CAP_KILL",
57414 + "CAP_SETGID",
57415 + "CAP_SETUID",
57416 + "CAP_SETPCAP",
57417 + "CAP_LINUX_IMMUTABLE",
57418 + "CAP_NET_BIND_SERVICE",
57419 + "CAP_NET_BROADCAST",
57420 + "CAP_NET_ADMIN",
57421 + "CAP_NET_RAW",
57422 + "CAP_IPC_LOCK",
57423 + "CAP_IPC_OWNER",
57424 + "CAP_SYS_MODULE",
57425 + "CAP_SYS_RAWIO",
57426 + "CAP_SYS_CHROOT",
57427 + "CAP_SYS_PTRACE",
57428 + "CAP_SYS_PACCT",
57429 + "CAP_SYS_ADMIN",
57430 + "CAP_SYS_BOOT",
57431 + "CAP_SYS_NICE",
57432 + "CAP_SYS_RESOURCE",
57433 + "CAP_SYS_TIME",
57434 + "CAP_SYS_TTY_CONFIG",
57435 + "CAP_MKNOD",
57436 + "CAP_LEASE",
57437 + "CAP_AUDIT_WRITE",
57438 + "CAP_AUDIT_CONTROL",
57439 + "CAP_SETFCAP",
57440 + "CAP_MAC_OVERRIDE",
57441 + "CAP_MAC_ADMIN",
57442 + "CAP_SYSLOG",
57443 + "CAP_WAKE_ALARM"
57444 +};
57445 +
57446 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
57447 +
57448 +int gr_is_capable(const int cap)
57449 +{
57450 +#ifdef CONFIG_GRKERNSEC
57451 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
57452 + return 1;
57453 + return 0;
57454 +#else
57455 + return 1;
57456 +#endif
57457 +}
57458 +
57459 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
57460 +{
57461 +#ifdef CONFIG_GRKERNSEC
57462 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
57463 + return 1;
57464 + return 0;
57465 +#else
57466 + return 1;
57467 +#endif
57468 +}
57469 +
57470 +int gr_is_capable_nolog(const int cap)
57471 +{
57472 +#ifdef CONFIG_GRKERNSEC
57473 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
57474 + return 1;
57475 + return 0;
57476 +#else
57477 + return 1;
57478 +#endif
57479 +}
57480 +
57481 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
57482 +{
57483 +#ifdef CONFIG_GRKERNSEC
57484 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
57485 + return 1;
57486 + return 0;
57487 +#else
57488 + return 1;
57489 +#endif
57490 +}
57491 +
57492 +EXPORT_SYMBOL(gr_is_capable);
57493 +EXPORT_SYMBOL(gr_is_capable_nolog);
57494 +EXPORT_SYMBOL(gr_task_is_capable);
57495 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
57496 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
57497 new file mode 100644
57498 index 0000000..d3ee748
57499 --- /dev/null
57500 +++ b/grsecurity/grsec_fifo.c
57501 @@ -0,0 +1,24 @@
57502 +#include <linux/kernel.h>
57503 +#include <linux/sched.h>
57504 +#include <linux/fs.h>
57505 +#include <linux/file.h>
57506 +#include <linux/grinternal.h>
57507 +
57508 +int
57509 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
57510 + const struct dentry *dir, const int flag, const int acc_mode)
57511 +{
57512 +#ifdef CONFIG_GRKERNSEC_FIFO
57513 + const struct cred *cred = current_cred();
57514 +
57515 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
57516 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
57517 + (dentry->d_inode->i_uid != dir->d_inode->i_uid) &&
57518 + (cred->fsuid != dentry->d_inode->i_uid)) {
57519 + if (!inode_permission(dentry->d_inode, acc_mode))
57520 + gr_log_fs_int2(GR_DONT_AUDIT, GR_FIFO_MSG, dentry, mnt, dentry->d_inode->i_uid, dentry->d_inode->i_gid);
57521 + return -EACCES;
57522 + }
57523 +#endif
57524 + return 0;
57525 +}
57526 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
57527 new file mode 100644
57528 index 0000000..8ca18bf
57529 --- /dev/null
57530 +++ b/grsecurity/grsec_fork.c
57531 @@ -0,0 +1,23 @@
57532 +#include <linux/kernel.h>
57533 +#include <linux/sched.h>
57534 +#include <linux/grsecurity.h>
57535 +#include <linux/grinternal.h>
57536 +#include <linux/errno.h>
57537 +
57538 +void
57539 +gr_log_forkfail(const int retval)
57540 +{
57541 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
57542 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
57543 + switch (retval) {
57544 + case -EAGAIN:
57545 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
57546 + break;
57547 + case -ENOMEM:
57548 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
57549 + break;
57550 + }
57551 + }
57552 +#endif
57553 + return;
57554 +}
57555 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
57556 new file mode 100644
57557 index 0000000..01ddde4
57558 --- /dev/null
57559 +++ b/grsecurity/grsec_init.c
57560 @@ -0,0 +1,277 @@
57561 +#include <linux/kernel.h>
57562 +#include <linux/sched.h>
57563 +#include <linux/mm.h>
57564 +#include <linux/gracl.h>
57565 +#include <linux/slab.h>
57566 +#include <linux/vmalloc.h>
57567 +#include <linux/percpu.h>
57568 +#include <linux/module.h>
57569 +
57570 +int grsec_enable_ptrace_readexec;
57571 +int grsec_enable_setxid;
57572 +int grsec_enable_brute;
57573 +int grsec_enable_link;
57574 +int grsec_enable_dmesg;
57575 +int grsec_enable_harden_ptrace;
57576 +int grsec_enable_fifo;
57577 +int grsec_enable_execlog;
57578 +int grsec_enable_signal;
57579 +int grsec_enable_forkfail;
57580 +int grsec_enable_audit_ptrace;
57581 +int grsec_enable_time;
57582 +int grsec_enable_audit_textrel;
57583 +int grsec_enable_group;
57584 +int grsec_audit_gid;
57585 +int grsec_enable_chdir;
57586 +int grsec_enable_mount;
57587 +int grsec_enable_rofs;
57588 +int grsec_enable_chroot_findtask;
57589 +int grsec_enable_chroot_mount;
57590 +int grsec_enable_chroot_shmat;
57591 +int grsec_enable_chroot_fchdir;
57592 +int grsec_enable_chroot_double;
57593 +int grsec_enable_chroot_pivot;
57594 +int grsec_enable_chroot_chdir;
57595 +int grsec_enable_chroot_chmod;
57596 +int grsec_enable_chroot_mknod;
57597 +int grsec_enable_chroot_nice;
57598 +int grsec_enable_chroot_execlog;
57599 +int grsec_enable_chroot_caps;
57600 +int grsec_enable_chroot_sysctl;
57601 +int grsec_enable_chroot_unix;
57602 +int grsec_enable_tpe;
57603 +int grsec_tpe_gid;
57604 +int grsec_enable_blackhole;
57605 +#ifdef CONFIG_IPV6_MODULE
57606 +EXPORT_SYMBOL(grsec_enable_blackhole);
57607 +#endif
57608 +int grsec_lastack_retries;
57609 +int grsec_enable_tpe_all;
57610 +int grsec_enable_tpe_invert;
57611 +int grsec_enable_socket_all;
57612 +int grsec_socket_all_gid;
57613 +int grsec_enable_socket_client;
57614 +int grsec_socket_client_gid;
57615 +int grsec_enable_socket_server;
57616 +int grsec_socket_server_gid;
57617 +int grsec_resource_logging;
57618 +int grsec_disable_privio;
57619 +int grsec_enable_log_rwxmaps;
57620 +int grsec_lock;
57621 +
57622 +DEFINE_SPINLOCK(grsec_alert_lock);
57623 +unsigned long grsec_alert_wtime = 0;
57624 +unsigned long grsec_alert_fyet = 0;
57625 +
57626 +DEFINE_SPINLOCK(grsec_audit_lock);
57627 +
57628 +DEFINE_RWLOCK(grsec_exec_file_lock);
57629 +
57630 +char *gr_shared_page[4];
57631 +
57632 +char *gr_alert_log_fmt;
57633 +char *gr_audit_log_fmt;
57634 +char *gr_alert_log_buf;
57635 +char *gr_audit_log_buf;
57636 +
57637 +extern struct gr_arg *gr_usermode;
57638 +extern unsigned char *gr_system_salt;
57639 +extern unsigned char *gr_system_sum;
57640 +
57641 +void __init
57642 +grsecurity_init(void)
57643 +{
57644 + int j;
57645 + /* create the per-cpu shared pages */
57646 +
57647 +#ifdef CONFIG_X86
57648 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
57649 +#endif
57650 +
57651 + for (j = 0; j < 4; j++) {
57652 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
57653 + if (gr_shared_page[j] == NULL) {
57654 + panic("Unable to allocate grsecurity shared page");
57655 + return;
57656 + }
57657 + }
57658 +
57659 + /* allocate log buffers */
57660 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
57661 + if (!gr_alert_log_fmt) {
57662 + panic("Unable to allocate grsecurity alert log format buffer");
57663 + return;
57664 + }
57665 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
57666 + if (!gr_audit_log_fmt) {
57667 + panic("Unable to allocate grsecurity audit log format buffer");
57668 + return;
57669 + }
57670 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
57671 + if (!gr_alert_log_buf) {
57672 + panic("Unable to allocate grsecurity alert log buffer");
57673 + return;
57674 + }
57675 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
57676 + if (!gr_audit_log_buf) {
57677 + panic("Unable to allocate grsecurity audit log buffer");
57678 + return;
57679 + }
57680 +
57681 + /* allocate memory for authentication structure */
57682 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
57683 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
57684 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
57685 +
57686 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
57687 + panic("Unable to allocate grsecurity authentication structure");
57688 + return;
57689 + }
57690 +
57691 +
57692 +#ifdef CONFIG_GRKERNSEC_IO
57693 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
57694 + grsec_disable_privio = 1;
57695 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
57696 + grsec_disable_privio = 1;
57697 +#else
57698 + grsec_disable_privio = 0;
57699 +#endif
57700 +#endif
57701 +
57702 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
57703 + /* for backward compatibility, tpe_invert always defaults to on if
57704 + enabled in the kernel
57705 + */
57706 + grsec_enable_tpe_invert = 1;
57707 +#endif
57708 +
57709 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
57710 +#ifndef CONFIG_GRKERNSEC_SYSCTL
57711 + grsec_lock = 1;
57712 +#endif
57713 +
57714 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
57715 + grsec_enable_audit_textrel = 1;
57716 +#endif
57717 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
57718 + grsec_enable_log_rwxmaps = 1;
57719 +#endif
57720 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
57721 + grsec_enable_group = 1;
57722 + grsec_audit_gid = CONFIG_GRKERNSEC_AUDIT_GID;
57723 +#endif
57724 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
57725 + grsec_enable_ptrace_readexec = 1;
57726 +#endif
57727 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
57728 + grsec_enable_chdir = 1;
57729 +#endif
57730 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
57731 + grsec_enable_harden_ptrace = 1;
57732 +#endif
57733 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
57734 + grsec_enable_mount = 1;
57735 +#endif
57736 +#ifdef CONFIG_GRKERNSEC_LINK
57737 + grsec_enable_link = 1;
57738 +#endif
57739 +#ifdef CONFIG_GRKERNSEC_BRUTE
57740 + grsec_enable_brute = 1;
57741 +#endif
57742 +#ifdef CONFIG_GRKERNSEC_DMESG
57743 + grsec_enable_dmesg = 1;
57744 +#endif
57745 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
57746 + grsec_enable_blackhole = 1;
57747 + grsec_lastack_retries = 4;
57748 +#endif
57749 +#ifdef CONFIG_GRKERNSEC_FIFO
57750 + grsec_enable_fifo = 1;
57751 +#endif
57752 +#ifdef CONFIG_GRKERNSEC_EXECLOG
57753 + grsec_enable_execlog = 1;
57754 +#endif
57755 +#ifdef CONFIG_GRKERNSEC_SETXID
57756 + grsec_enable_setxid = 1;
57757 +#endif
57758 +#ifdef CONFIG_GRKERNSEC_SIGNAL
57759 + grsec_enable_signal = 1;
57760 +#endif
57761 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
57762 + grsec_enable_forkfail = 1;
57763 +#endif
57764 +#ifdef CONFIG_GRKERNSEC_TIME
57765 + grsec_enable_time = 1;
57766 +#endif
57767 +#ifdef CONFIG_GRKERNSEC_RESLOG
57768 + grsec_resource_logging = 1;
57769 +#endif
57770 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
57771 + grsec_enable_chroot_findtask = 1;
57772 +#endif
57773 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
57774 + grsec_enable_chroot_unix = 1;
57775 +#endif
57776 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
57777 + grsec_enable_chroot_mount = 1;
57778 +#endif
57779 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
57780 + grsec_enable_chroot_fchdir = 1;
57781 +#endif
57782 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
57783 + grsec_enable_chroot_shmat = 1;
57784 +#endif
57785 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
57786 + grsec_enable_audit_ptrace = 1;
57787 +#endif
57788 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
57789 + grsec_enable_chroot_double = 1;
57790 +#endif
57791 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
57792 + grsec_enable_chroot_pivot = 1;
57793 +#endif
57794 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
57795 + grsec_enable_chroot_chdir = 1;
57796 +#endif
57797 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
57798 + grsec_enable_chroot_chmod = 1;
57799 +#endif
57800 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
57801 + grsec_enable_chroot_mknod = 1;
57802 +#endif
57803 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
57804 + grsec_enable_chroot_nice = 1;
57805 +#endif
57806 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
57807 + grsec_enable_chroot_execlog = 1;
57808 +#endif
57809 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
57810 + grsec_enable_chroot_caps = 1;
57811 +#endif
57812 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
57813 + grsec_enable_chroot_sysctl = 1;
57814 +#endif
57815 +#ifdef CONFIG_GRKERNSEC_TPE
57816 + grsec_enable_tpe = 1;
57817 + grsec_tpe_gid = CONFIG_GRKERNSEC_TPE_GID;
57818 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
57819 + grsec_enable_tpe_all = 1;
57820 +#endif
57821 +#endif
57822 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
57823 + grsec_enable_socket_all = 1;
57824 + grsec_socket_all_gid = CONFIG_GRKERNSEC_SOCKET_ALL_GID;
57825 +#endif
57826 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
57827 + grsec_enable_socket_client = 1;
57828 + grsec_socket_client_gid = CONFIG_GRKERNSEC_SOCKET_CLIENT_GID;
57829 +#endif
57830 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
57831 + grsec_enable_socket_server = 1;
57832 + grsec_socket_server_gid = CONFIG_GRKERNSEC_SOCKET_SERVER_GID;
57833 +#endif
57834 +#endif
57835 +
57836 + return;
57837 +}
57838 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
57839 new file mode 100644
57840 index 0000000..3efe141
57841 --- /dev/null
57842 +++ b/grsecurity/grsec_link.c
57843 @@ -0,0 +1,43 @@
57844 +#include <linux/kernel.h>
57845 +#include <linux/sched.h>
57846 +#include <linux/fs.h>
57847 +#include <linux/file.h>
57848 +#include <linux/grinternal.h>
57849 +
57850 +int
57851 +gr_handle_follow_link(const struct inode *parent,
57852 + const struct inode *inode,
57853 + const struct dentry *dentry, const struct vfsmount *mnt)
57854 +{
57855 +#ifdef CONFIG_GRKERNSEC_LINK
57856 + const struct cred *cred = current_cred();
57857 +
57858 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
57859 + (parent->i_mode & S_ISVTX) && (parent->i_uid != inode->i_uid) &&
57860 + (parent->i_mode & S_IWOTH) && (cred->fsuid != inode->i_uid)) {
57861 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
57862 + return -EACCES;
57863 + }
57864 +#endif
57865 + return 0;
57866 +}
57867 +
57868 +int
57869 +gr_handle_hardlink(const struct dentry *dentry,
57870 + const struct vfsmount *mnt,
57871 + struct inode *inode, const int mode, const char *to)
57872 +{
57873 +#ifdef CONFIG_GRKERNSEC_LINK
57874 + const struct cred *cred = current_cred();
57875 +
57876 + if (grsec_enable_link && cred->fsuid != inode->i_uid &&
57877 + (!S_ISREG(mode) || (mode & S_ISUID) ||
57878 + ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) ||
57879 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
57880 + !capable(CAP_FOWNER) && cred->uid) {
57881 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to);
57882 + return -EPERM;
57883 + }
57884 +#endif
57885 + return 0;
57886 +}
57887 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
57888 new file mode 100644
57889 index 0000000..a45d2e9
57890 --- /dev/null
57891 +++ b/grsecurity/grsec_log.c
57892 @@ -0,0 +1,322 @@
57893 +#include <linux/kernel.h>
57894 +#include <linux/sched.h>
57895 +#include <linux/file.h>
57896 +#include <linux/tty.h>
57897 +#include <linux/fs.h>
57898 +#include <linux/grinternal.h>
57899 +
57900 +#ifdef CONFIG_TREE_PREEMPT_RCU
57901 +#define DISABLE_PREEMPT() preempt_disable()
57902 +#define ENABLE_PREEMPT() preempt_enable()
57903 +#else
57904 +#define DISABLE_PREEMPT()
57905 +#define ENABLE_PREEMPT()
57906 +#endif
57907 +
57908 +#define BEGIN_LOCKS(x) \
57909 + DISABLE_PREEMPT(); \
57910 + rcu_read_lock(); \
57911 + read_lock(&tasklist_lock); \
57912 + read_lock(&grsec_exec_file_lock); \
57913 + if (x != GR_DO_AUDIT) \
57914 + spin_lock(&grsec_alert_lock); \
57915 + else \
57916 + spin_lock(&grsec_audit_lock)
57917 +
57918 +#define END_LOCKS(x) \
57919 + if (x != GR_DO_AUDIT) \
57920 + spin_unlock(&grsec_alert_lock); \
57921 + else \
57922 + spin_unlock(&grsec_audit_lock); \
57923 + read_unlock(&grsec_exec_file_lock); \
57924 + read_unlock(&tasklist_lock); \
57925 + rcu_read_unlock(); \
57926 + ENABLE_PREEMPT(); \
57927 + if (x == GR_DONT_AUDIT) \
57928 + gr_handle_alertkill(current)
57929 +
57930 +enum {
57931 + FLOODING,
57932 + NO_FLOODING
57933 +};
57934 +
57935 +extern char *gr_alert_log_fmt;
57936 +extern char *gr_audit_log_fmt;
57937 +extern char *gr_alert_log_buf;
57938 +extern char *gr_audit_log_buf;
57939 +
57940 +static int gr_log_start(int audit)
57941 +{
57942 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
57943 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
57944 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
57945 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
57946 + unsigned long curr_secs = get_seconds();
57947 +
57948 + if (audit == GR_DO_AUDIT)
57949 + goto set_fmt;
57950 +
57951 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
57952 + grsec_alert_wtime = curr_secs;
57953 + grsec_alert_fyet = 0;
57954 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
57955 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
57956 + grsec_alert_fyet++;
57957 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
57958 + grsec_alert_wtime = curr_secs;
57959 + grsec_alert_fyet++;
57960 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
57961 + return FLOODING;
57962 + }
57963 + else return FLOODING;
57964 +
57965 +set_fmt:
57966 +#endif
57967 + memset(buf, 0, PAGE_SIZE);
57968 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
57969 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
57970 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
57971 + } else if (current->signal->curr_ip) {
57972 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
57973 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
57974 + } else if (gr_acl_is_enabled()) {
57975 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
57976 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
57977 + } else {
57978 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
57979 + strcpy(buf, fmt);
57980 + }
57981 +
57982 + return NO_FLOODING;
57983 +}
57984 +
57985 +static void gr_log_middle(int audit, const char *msg, va_list ap)
57986 + __attribute__ ((format (printf, 2, 0)));
57987 +
57988 +static void gr_log_middle(int audit, const char *msg, va_list ap)
57989 +{
57990 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
57991 + unsigned int len = strlen(buf);
57992 +
57993 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
57994 +
57995 + return;
57996 +}
57997 +
57998 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
57999 + __attribute__ ((format (printf, 2, 3)));
58000 +
58001 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
58002 +{
58003 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
58004 + unsigned int len = strlen(buf);
58005 + va_list ap;
58006 +
58007 + va_start(ap, msg);
58008 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
58009 + va_end(ap);
58010 +
58011 + return;
58012 +}
58013 +
58014 +static void gr_log_end(int audit, int append_default)
58015 +{
58016 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
58017 +
58018 + if (append_default) {
58019 + unsigned int len = strlen(buf);
58020 + snprintf(buf + len, PAGE_SIZE - len - 1, DEFAULTSECMSG, DEFAULTSECARGS(current, current_cred(), __task_cred(current->real_parent)));
58021 + }
58022 +
58023 + printk("%s\n", buf);
58024 +
58025 + return;
58026 +}
58027 +
58028 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
58029 +{
58030 + int logtype;
58031 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
58032 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
58033 + void *voidptr = NULL;
58034 + int num1 = 0, num2 = 0;
58035 + unsigned long ulong1 = 0, ulong2 = 0;
58036 + struct dentry *dentry = NULL;
58037 + struct vfsmount *mnt = NULL;
58038 + struct file *file = NULL;
58039 + struct task_struct *task = NULL;
58040 + const struct cred *cred, *pcred;
58041 + va_list ap;
58042 +
58043 + BEGIN_LOCKS(audit);
58044 + logtype = gr_log_start(audit);
58045 + if (logtype == FLOODING) {
58046 + END_LOCKS(audit);
58047 + return;
58048 + }
58049 + va_start(ap, argtypes);
58050 + switch (argtypes) {
58051 + case GR_TTYSNIFF:
58052 + task = va_arg(ap, struct task_struct *);
58053 + gr_log_middle_varargs(audit, msg, &task->signal->curr_ip, gr_task_fullpath0(task), task->comm, task->pid, gr_parent_task_fullpath0(task), task->real_parent->comm, task->real_parent->pid);
58054 + break;
58055 + case GR_SYSCTL_HIDDEN:
58056 + str1 = va_arg(ap, char *);
58057 + gr_log_middle_varargs(audit, msg, result, str1);
58058 + break;
58059 + case GR_RBAC:
58060 + dentry = va_arg(ap, struct dentry *);
58061 + mnt = va_arg(ap, struct vfsmount *);
58062 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
58063 + break;
58064 + case GR_RBAC_STR:
58065 + dentry = va_arg(ap, struct dentry *);
58066 + mnt = va_arg(ap, struct vfsmount *);
58067 + str1 = va_arg(ap, char *);
58068 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
58069 + break;
58070 + case GR_STR_RBAC:
58071 + str1 = va_arg(ap, char *);
58072 + dentry = va_arg(ap, struct dentry *);
58073 + mnt = va_arg(ap, struct vfsmount *);
58074 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
58075 + break;
58076 + case GR_RBAC_MODE2:
58077 + dentry = va_arg(ap, struct dentry *);
58078 + mnt = va_arg(ap, struct vfsmount *);
58079 + str1 = va_arg(ap, char *);
58080 + str2 = va_arg(ap, char *);
58081 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
58082 + break;
58083 + case GR_RBAC_MODE3:
58084 + dentry = va_arg(ap, struct dentry *);
58085 + mnt = va_arg(ap, struct vfsmount *);
58086 + str1 = va_arg(ap, char *);
58087 + str2 = va_arg(ap, char *);
58088 + str3 = va_arg(ap, char *);
58089 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
58090 + break;
58091 + case GR_FILENAME:
58092 + dentry = va_arg(ap, struct dentry *);
58093 + mnt = va_arg(ap, struct vfsmount *);
58094 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
58095 + break;
58096 + case GR_STR_FILENAME:
58097 + str1 = va_arg(ap, char *);
58098 + dentry = va_arg(ap, struct dentry *);
58099 + mnt = va_arg(ap, struct vfsmount *);
58100 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
58101 + break;
58102 + case GR_FILENAME_STR:
58103 + dentry = va_arg(ap, struct dentry *);
58104 + mnt = va_arg(ap, struct vfsmount *);
58105 + str1 = va_arg(ap, char *);
58106 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
58107 + break;
58108 + case GR_FILENAME_TWO_INT:
58109 + dentry = va_arg(ap, struct dentry *);
58110 + mnt = va_arg(ap, struct vfsmount *);
58111 + num1 = va_arg(ap, int);
58112 + num2 = va_arg(ap, int);
58113 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
58114 + break;
58115 + case GR_FILENAME_TWO_INT_STR:
58116 + dentry = va_arg(ap, struct dentry *);
58117 + mnt = va_arg(ap, struct vfsmount *);
58118 + num1 = va_arg(ap, int);
58119 + num2 = va_arg(ap, int);
58120 + str1 = va_arg(ap, char *);
58121 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
58122 + break;
58123 + case GR_TEXTREL:
58124 + file = va_arg(ap, struct file *);
58125 + ulong1 = va_arg(ap, unsigned long);
58126 + ulong2 = va_arg(ap, unsigned long);
58127 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
58128 + break;
58129 + case GR_PTRACE:
58130 + task = va_arg(ap, struct task_struct *);
58131 + 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);
58132 + break;
58133 + case GR_RESOURCE:
58134 + task = va_arg(ap, struct task_struct *);
58135 + cred = __task_cred(task);
58136 + pcred = __task_cred(task->real_parent);
58137 + ulong1 = va_arg(ap, unsigned long);
58138 + str1 = va_arg(ap, char *);
58139 + ulong2 = va_arg(ap, unsigned long);
58140 + gr_log_middle_varargs(audit, msg, ulong1, str1, ulong2, gr_task_fullpath(task), task->comm, task->pid, cred->uid, cred->euid, cred->gid, cred->egid, gr_parent_task_fullpath(task), task->real_parent->comm, task->real_parent->pid, pcred->uid, pcred->euid, pcred->gid, pcred->egid);
58141 + break;
58142 + case GR_CAP:
58143 + task = va_arg(ap, struct task_struct *);
58144 + cred = __task_cred(task);
58145 + pcred = __task_cred(task->real_parent);
58146 + str1 = va_arg(ap, char *);
58147 + gr_log_middle_varargs(audit, msg, str1, gr_task_fullpath(task), task->comm, task->pid, cred->uid, cred->euid, cred->gid, cred->egid, gr_parent_task_fullpath(task), task->real_parent->comm, task->real_parent->pid, pcred->uid, pcred->euid, pcred->gid, pcred->egid);
58148 + break;
58149 + case GR_SIG:
58150 + str1 = va_arg(ap, char *);
58151 + voidptr = va_arg(ap, void *);
58152 + gr_log_middle_varargs(audit, msg, str1, voidptr);
58153 + break;
58154 + case GR_SIG2:
58155 + task = va_arg(ap, struct task_struct *);
58156 + cred = __task_cred(task);
58157 + pcred = __task_cred(task->real_parent);
58158 + num1 = va_arg(ap, int);
58159 + gr_log_middle_varargs(audit, msg, num1, gr_task_fullpath0(task), task->comm, task->pid, cred->uid, cred->euid, cred->gid, cred->egid, gr_parent_task_fullpath0(task), task->real_parent->comm, task->real_parent->pid, pcred->uid, pcred->euid, pcred->gid, pcred->egid);
58160 + break;
58161 + case GR_CRASH1:
58162 + task = va_arg(ap, struct task_struct *);
58163 + cred = __task_cred(task);
58164 + pcred = __task_cred(task->real_parent);
58165 + ulong1 = va_arg(ap, unsigned long);
58166 + gr_log_middle_varargs(audit, msg, gr_task_fullpath(task), task->comm, task->pid, cred->uid, cred->euid, cred->gid, cred->egid, gr_parent_task_fullpath(task), task->real_parent->comm, task->real_parent->pid, pcred->uid, pcred->euid, pcred->gid, pcred->egid, cred->uid, ulong1);
58167 + break;
58168 + case GR_CRASH2:
58169 + task = va_arg(ap, struct task_struct *);
58170 + cred = __task_cred(task);
58171 + pcred = __task_cred(task->real_parent);
58172 + ulong1 = va_arg(ap, unsigned long);
58173 + gr_log_middle_varargs(audit, msg, gr_task_fullpath(task), task->comm, task->pid, cred->uid, cred->euid, cred->gid, cred->egid, gr_parent_task_fullpath(task), task->real_parent->comm, task->real_parent->pid, pcred->uid, pcred->euid, pcred->gid, pcred->egid, ulong1);
58174 + break;
58175 + case GR_RWXMAP:
58176 + file = va_arg(ap, struct file *);
58177 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
58178 + break;
58179 + case GR_PSACCT:
58180 + {
58181 + unsigned int wday, cday;
58182 + __u8 whr, chr;
58183 + __u8 wmin, cmin;
58184 + __u8 wsec, csec;
58185 + char cur_tty[64] = { 0 };
58186 + char parent_tty[64] = { 0 };
58187 +
58188 + task = va_arg(ap, struct task_struct *);
58189 + wday = va_arg(ap, unsigned int);
58190 + cday = va_arg(ap, unsigned int);
58191 + whr = va_arg(ap, int);
58192 + chr = va_arg(ap, int);
58193 + wmin = va_arg(ap, int);
58194 + cmin = va_arg(ap, int);
58195 + wsec = va_arg(ap, int);
58196 + csec = va_arg(ap, int);
58197 + ulong1 = va_arg(ap, unsigned long);
58198 + cred = __task_cred(task);
58199 + pcred = __task_cred(task->real_parent);
58200 +
58201 + gr_log_middle_varargs(audit, msg, gr_task_fullpath(task), task->comm, task->pid, &task->signal->curr_ip, tty_name(task->signal->tty, cur_tty), cred->uid, cred->euid, cred->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->real_parent->pid, &task->real_parent->signal->curr_ip, tty_name(task->real_parent->signal->tty, parent_tty), pcred->uid, pcred->euid, pcred->gid, pcred->egid);
58202 + }
58203 + break;
58204 + default:
58205 + gr_log_middle(audit, msg, ap);
58206 + }
58207 + va_end(ap);
58208 + // these don't need DEFAULTSECARGS printed on the end
58209 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
58210 + gr_log_end(audit, 0);
58211 + else
58212 + gr_log_end(audit, 1);
58213 + END_LOCKS(audit);
58214 +}
58215 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
58216 new file mode 100644
58217 index 0000000..f536303
58218 --- /dev/null
58219 +++ b/grsecurity/grsec_mem.c
58220 @@ -0,0 +1,40 @@
58221 +#include <linux/kernel.h>
58222 +#include <linux/sched.h>
58223 +#include <linux/mm.h>
58224 +#include <linux/mman.h>
58225 +#include <linux/grinternal.h>
58226 +
58227 +void
58228 +gr_handle_ioperm(void)
58229 +{
58230 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
58231 + return;
58232 +}
58233 +
58234 +void
58235 +gr_handle_iopl(void)
58236 +{
58237 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
58238 + return;
58239 +}
58240 +
58241 +void
58242 +gr_handle_mem_readwrite(u64 from, u64 to)
58243 +{
58244 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
58245 + return;
58246 +}
58247 +
58248 +void
58249 +gr_handle_vm86(void)
58250 +{
58251 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
58252 + return;
58253 +}
58254 +
58255 +void
58256 +gr_log_badprocpid(const char *entry)
58257 +{
58258 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
58259 + return;
58260 +}
58261 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
58262 new file mode 100644
58263 index 0000000..2131422
58264 --- /dev/null
58265 +++ b/grsecurity/grsec_mount.c
58266 @@ -0,0 +1,62 @@
58267 +#include <linux/kernel.h>
58268 +#include <linux/sched.h>
58269 +#include <linux/mount.h>
58270 +#include <linux/grsecurity.h>
58271 +#include <linux/grinternal.h>
58272 +
58273 +void
58274 +gr_log_remount(const char *devname, const int retval)
58275 +{
58276 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
58277 + if (grsec_enable_mount && (retval >= 0))
58278 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
58279 +#endif
58280 + return;
58281 +}
58282 +
58283 +void
58284 +gr_log_unmount(const char *devname, const int retval)
58285 +{
58286 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
58287 + if (grsec_enable_mount && (retval >= 0))
58288 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
58289 +#endif
58290 + return;
58291 +}
58292 +
58293 +void
58294 +gr_log_mount(const char *from, const char *to, const int retval)
58295 +{
58296 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
58297 + if (grsec_enable_mount && (retval >= 0))
58298 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
58299 +#endif
58300 + return;
58301 +}
58302 +
58303 +int
58304 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
58305 +{
58306 +#ifdef CONFIG_GRKERNSEC_ROFS
58307 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
58308 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
58309 + return -EPERM;
58310 + } else
58311 + return 0;
58312 +#endif
58313 + return 0;
58314 +}
58315 +
58316 +int
58317 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
58318 +{
58319 +#ifdef CONFIG_GRKERNSEC_ROFS
58320 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
58321 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
58322 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
58323 + return -EPERM;
58324 + } else
58325 + return 0;
58326 +#endif
58327 + return 0;
58328 +}
58329 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
58330 new file mode 100644
58331 index 0000000..a3b12a0
58332 --- /dev/null
58333 +++ b/grsecurity/grsec_pax.c
58334 @@ -0,0 +1,36 @@
58335 +#include <linux/kernel.h>
58336 +#include <linux/sched.h>
58337 +#include <linux/mm.h>
58338 +#include <linux/file.h>
58339 +#include <linux/grinternal.h>
58340 +#include <linux/grsecurity.h>
58341 +
58342 +void
58343 +gr_log_textrel(struct vm_area_struct * vma)
58344 +{
58345 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
58346 + if (grsec_enable_audit_textrel)
58347 + gr_log_textrel_ulong_ulong(GR_DO_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
58348 +#endif
58349 + return;
58350 +}
58351 +
58352 +void
58353 +gr_log_rwxmmap(struct file *file)
58354 +{
58355 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
58356 + if (grsec_enable_log_rwxmaps)
58357 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
58358 +#endif
58359 + return;
58360 +}
58361 +
58362 +void
58363 +gr_log_rwxmprotect(struct file *file)
58364 +{
58365 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
58366 + if (grsec_enable_log_rwxmaps)
58367 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, file);
58368 +#endif
58369 + return;
58370 +}
58371 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
58372 new file mode 100644
58373 index 0000000..f7f29aa
58374 --- /dev/null
58375 +++ b/grsecurity/grsec_ptrace.c
58376 @@ -0,0 +1,30 @@
58377 +#include <linux/kernel.h>
58378 +#include <linux/sched.h>
58379 +#include <linux/grinternal.h>
58380 +#include <linux/security.h>
58381 +
58382 +void
58383 +gr_audit_ptrace(struct task_struct *task)
58384 +{
58385 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
58386 + if (grsec_enable_audit_ptrace)
58387 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
58388 +#endif
58389 + return;
58390 +}
58391 +
58392 +int
58393 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
58394 +{
58395 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
58396 + const struct dentry *dentry = file->f_path.dentry;
58397 + const struct vfsmount *mnt = file->f_path.mnt;
58398 +
58399 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
58400 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
58401 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
58402 + return -EACCES;
58403 + }
58404 +#endif
58405 + return 0;
58406 +}
58407 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
58408 new file mode 100644
58409 index 0000000..7a5b2de
58410 --- /dev/null
58411 +++ b/grsecurity/grsec_sig.c
58412 @@ -0,0 +1,207 @@
58413 +#include <linux/kernel.h>
58414 +#include <linux/sched.h>
58415 +#include <linux/delay.h>
58416 +#include <linux/grsecurity.h>
58417 +#include <linux/grinternal.h>
58418 +#include <linux/hardirq.h>
58419 +
58420 +char *signames[] = {
58421 + [SIGSEGV] = "Segmentation fault",
58422 + [SIGILL] = "Illegal instruction",
58423 + [SIGABRT] = "Abort",
58424 + [SIGBUS] = "Invalid alignment/Bus error"
58425 +};
58426 +
58427 +void
58428 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
58429 +{
58430 +#ifdef CONFIG_GRKERNSEC_SIGNAL
58431 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
58432 + (sig == SIGABRT) || (sig == SIGBUS))) {
58433 + if (t->pid == current->pid) {
58434 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
58435 + } else {
58436 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
58437 + }
58438 + }
58439 +#endif
58440 + return;
58441 +}
58442 +
58443 +int
58444 +gr_handle_signal(const struct task_struct *p, const int sig)
58445 +{
58446 +#ifdef CONFIG_GRKERNSEC
58447 + /* ignore the 0 signal for protected task checks */
58448 + if (current->pid > 1 && sig && gr_check_protected_task(p)) {
58449 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
58450 + return -EPERM;
58451 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
58452 + return -EPERM;
58453 + }
58454 +#endif
58455 + return 0;
58456 +}
58457 +
58458 +#ifdef CONFIG_GRKERNSEC
58459 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
58460 +
58461 +int gr_fake_force_sig(int sig, struct task_struct *t)
58462 +{
58463 + unsigned long int flags;
58464 + int ret, blocked, ignored;
58465 + struct k_sigaction *action;
58466 +
58467 + spin_lock_irqsave(&t->sighand->siglock, flags);
58468 + action = &t->sighand->action[sig-1];
58469 + ignored = action->sa.sa_handler == SIG_IGN;
58470 + blocked = sigismember(&t->blocked, sig);
58471 + if (blocked || ignored) {
58472 + action->sa.sa_handler = SIG_DFL;
58473 + if (blocked) {
58474 + sigdelset(&t->blocked, sig);
58475 + recalc_sigpending_and_wake(t);
58476 + }
58477 + }
58478 + if (action->sa.sa_handler == SIG_DFL)
58479 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
58480 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
58481 +
58482 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
58483 +
58484 + return ret;
58485 +}
58486 +#endif
58487 +
58488 +#ifdef CONFIG_GRKERNSEC_BRUTE
58489 +#define GR_USER_BAN_TIME (15 * 60)
58490 +
58491 +static int __get_dumpable(unsigned long mm_flags)
58492 +{
58493 + int ret;
58494 +
58495 + ret = mm_flags & MMF_DUMPABLE_MASK;
58496 + return (ret >= 2) ? 2 : ret;
58497 +}
58498 +#endif
58499 +
58500 +void gr_handle_brute_attach(struct task_struct *p, unsigned long mm_flags)
58501 +{
58502 +#ifdef CONFIG_GRKERNSEC_BRUTE
58503 + uid_t uid = 0;
58504 +
58505 + if (!grsec_enable_brute)
58506 + return;
58507 +
58508 + rcu_read_lock();
58509 + read_lock(&tasklist_lock);
58510 + read_lock(&grsec_exec_file_lock);
58511 + if (p->real_parent && p->real_parent->exec_file == p->exec_file)
58512 + p->real_parent->brute = 1;
58513 + else {
58514 + const struct cred *cred = __task_cred(p), *cred2;
58515 + struct task_struct *tsk, *tsk2;
58516 +
58517 + if (!__get_dumpable(mm_flags) && cred->uid) {
58518 + struct user_struct *user;
58519 +
58520 + uid = cred->uid;
58521 +
58522 + /* this is put upon execution past expiration */
58523 + user = find_user(uid);
58524 + if (user == NULL)
58525 + goto unlock;
58526 + user->banned = 1;
58527 + user->ban_expires = get_seconds() + GR_USER_BAN_TIME;
58528 + if (user->ban_expires == ~0UL)
58529 + user->ban_expires--;
58530 +
58531 + do_each_thread(tsk2, tsk) {
58532 + cred2 = __task_cred(tsk);
58533 + if (tsk != p && cred2->uid == uid)
58534 + gr_fake_force_sig(SIGKILL, tsk);
58535 + } while_each_thread(tsk2, tsk);
58536 + }
58537 + }
58538 +unlock:
58539 + read_unlock(&grsec_exec_file_lock);
58540 + read_unlock(&tasklist_lock);
58541 + rcu_read_unlock();
58542 +
58543 + if (uid)
58544 + printk(KERN_ALERT "grsec: bruteforce prevention initiated against uid %u, banning for %d minutes\n", uid, GR_USER_BAN_TIME / 60);
58545 +
58546 +#endif
58547 + return;
58548 +}
58549 +
58550 +void gr_handle_brute_check(void)
58551 +{
58552 +#ifdef CONFIG_GRKERNSEC_BRUTE
58553 + if (current->brute)
58554 + msleep(30 * 1000);
58555 +#endif
58556 + return;
58557 +}
58558 +
58559 +void gr_handle_kernel_exploit(void)
58560 +{
58561 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
58562 + const struct cred *cred;
58563 + struct task_struct *tsk, *tsk2;
58564 + struct user_struct *user;
58565 + uid_t uid;
58566 +
58567 + if (in_irq() || in_serving_softirq() || in_nmi())
58568 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
58569 +
58570 + uid = current_uid();
58571 +
58572 + if (uid == 0)
58573 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
58574 + else {
58575 + /* kill all the processes of this user, hold a reference
58576 + to their creds struct, and prevent them from creating
58577 + another process until system reset
58578 + */
58579 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n", uid);
58580 + /* we intentionally leak this ref */
58581 + user = get_uid(current->cred->user);
58582 + if (user) {
58583 + user->banned = 1;
58584 + user->ban_expires = ~0UL;
58585 + }
58586 +
58587 + read_lock(&tasklist_lock);
58588 + do_each_thread(tsk2, tsk) {
58589 + cred = __task_cred(tsk);
58590 + if (cred->uid == uid)
58591 + gr_fake_force_sig(SIGKILL, tsk);
58592 + } while_each_thread(tsk2, tsk);
58593 + read_unlock(&tasklist_lock);
58594 + }
58595 +#endif
58596 +}
58597 +
58598 +int __gr_process_user_ban(struct user_struct *user)
58599 +{
58600 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
58601 + if (unlikely(user->banned)) {
58602 + if (user->ban_expires != ~0UL && time_after_eq(get_seconds(), user->ban_expires)) {
58603 + user->banned = 0;
58604 + user->ban_expires = 0;
58605 + free_uid(user);
58606 + } else
58607 + return -EPERM;
58608 + }
58609 +#endif
58610 + return 0;
58611 +}
58612 +
58613 +int gr_process_user_ban(void)
58614 +{
58615 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
58616 + return __gr_process_user_ban(current->cred->user);
58617 +#endif
58618 + return 0;
58619 +}
58620 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
58621 new file mode 100644
58622 index 0000000..4030d57
58623 --- /dev/null
58624 +++ b/grsecurity/grsec_sock.c
58625 @@ -0,0 +1,244 @@
58626 +#include <linux/kernel.h>
58627 +#include <linux/module.h>
58628 +#include <linux/sched.h>
58629 +#include <linux/file.h>
58630 +#include <linux/net.h>
58631 +#include <linux/in.h>
58632 +#include <linux/ip.h>
58633 +#include <net/sock.h>
58634 +#include <net/inet_sock.h>
58635 +#include <linux/grsecurity.h>
58636 +#include <linux/grinternal.h>
58637 +#include <linux/gracl.h>
58638 +
58639 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
58640 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
58641 +
58642 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
58643 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
58644 +
58645 +#ifdef CONFIG_UNIX_MODULE
58646 +EXPORT_SYMBOL(gr_acl_handle_unix);
58647 +EXPORT_SYMBOL(gr_acl_handle_mknod);
58648 +EXPORT_SYMBOL(gr_handle_chroot_unix);
58649 +EXPORT_SYMBOL(gr_handle_create);
58650 +#endif
58651 +
58652 +#ifdef CONFIG_GRKERNSEC
58653 +#define gr_conn_table_size 32749
58654 +struct conn_table_entry {
58655 + struct conn_table_entry *next;
58656 + struct signal_struct *sig;
58657 +};
58658 +
58659 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
58660 +DEFINE_SPINLOCK(gr_conn_table_lock);
58661 +
58662 +extern const char * gr_socktype_to_name(unsigned char type);
58663 +extern const char * gr_proto_to_name(unsigned char proto);
58664 +extern const char * gr_sockfamily_to_name(unsigned char family);
58665 +
58666 +static __inline__ int
58667 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
58668 +{
58669 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
58670 +}
58671 +
58672 +static __inline__ int
58673 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
58674 + __u16 sport, __u16 dport)
58675 +{
58676 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
58677 + sig->gr_sport == sport && sig->gr_dport == dport))
58678 + return 1;
58679 + else
58680 + return 0;
58681 +}
58682 +
58683 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
58684 +{
58685 + struct conn_table_entry **match;
58686 + unsigned int index;
58687 +
58688 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
58689 + sig->gr_sport, sig->gr_dport,
58690 + gr_conn_table_size);
58691 +
58692 + newent->sig = sig;
58693 +
58694 + match = &gr_conn_table[index];
58695 + newent->next = *match;
58696 + *match = newent;
58697 +
58698 + return;
58699 +}
58700 +
58701 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
58702 +{
58703 + struct conn_table_entry *match, *last = NULL;
58704 + unsigned int index;
58705 +
58706 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
58707 + sig->gr_sport, sig->gr_dport,
58708 + gr_conn_table_size);
58709 +
58710 + match = gr_conn_table[index];
58711 + while (match && !conn_match(match->sig,
58712 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
58713 + sig->gr_dport)) {
58714 + last = match;
58715 + match = match->next;
58716 + }
58717 +
58718 + if (match) {
58719 + if (last)
58720 + last->next = match->next;
58721 + else
58722 + gr_conn_table[index] = NULL;
58723 + kfree(match);
58724 + }
58725 +
58726 + return;
58727 +}
58728 +
58729 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
58730 + __u16 sport, __u16 dport)
58731 +{
58732 + struct conn_table_entry *match;
58733 + unsigned int index;
58734 +
58735 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
58736 +
58737 + match = gr_conn_table[index];
58738 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
58739 + match = match->next;
58740 +
58741 + if (match)
58742 + return match->sig;
58743 + else
58744 + return NULL;
58745 +}
58746 +
58747 +#endif
58748 +
58749 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
58750 +{
58751 +#ifdef CONFIG_GRKERNSEC
58752 + struct signal_struct *sig = task->signal;
58753 + struct conn_table_entry *newent;
58754 +
58755 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
58756 + if (newent == NULL)
58757 + return;
58758 + /* no bh lock needed since we are called with bh disabled */
58759 + spin_lock(&gr_conn_table_lock);
58760 + gr_del_task_from_ip_table_nolock(sig);
58761 + sig->gr_saddr = inet->inet_rcv_saddr;
58762 + sig->gr_daddr = inet->inet_daddr;
58763 + sig->gr_sport = inet->inet_sport;
58764 + sig->gr_dport = inet->inet_dport;
58765 + gr_add_to_task_ip_table_nolock(sig, newent);
58766 + spin_unlock(&gr_conn_table_lock);
58767 +#endif
58768 + return;
58769 +}
58770 +
58771 +void gr_del_task_from_ip_table(struct task_struct *task)
58772 +{
58773 +#ifdef CONFIG_GRKERNSEC
58774 + spin_lock_bh(&gr_conn_table_lock);
58775 + gr_del_task_from_ip_table_nolock(task->signal);
58776 + spin_unlock_bh(&gr_conn_table_lock);
58777 +#endif
58778 + return;
58779 +}
58780 +
58781 +void
58782 +gr_attach_curr_ip(const struct sock *sk)
58783 +{
58784 +#ifdef CONFIG_GRKERNSEC
58785 + struct signal_struct *p, *set;
58786 + const struct inet_sock *inet = inet_sk(sk);
58787 +
58788 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
58789 + return;
58790 +
58791 + set = current->signal;
58792 +
58793 + spin_lock_bh(&gr_conn_table_lock);
58794 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
58795 + inet->inet_dport, inet->inet_sport);
58796 + if (unlikely(p != NULL)) {
58797 + set->curr_ip = p->curr_ip;
58798 + set->used_accept = 1;
58799 + gr_del_task_from_ip_table_nolock(p);
58800 + spin_unlock_bh(&gr_conn_table_lock);
58801 + return;
58802 + }
58803 + spin_unlock_bh(&gr_conn_table_lock);
58804 +
58805 + set->curr_ip = inet->inet_daddr;
58806 + set->used_accept = 1;
58807 +#endif
58808 + return;
58809 +}
58810 +
58811 +int
58812 +gr_handle_sock_all(const int family, const int type, const int protocol)
58813 +{
58814 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
58815 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
58816 + (family != AF_UNIX)) {
58817 + if (family == AF_INET)
58818 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
58819 + else
58820 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
58821 + return -EACCES;
58822 + }
58823 +#endif
58824 + return 0;
58825 +}
58826 +
58827 +int
58828 +gr_handle_sock_server(const struct sockaddr *sck)
58829 +{
58830 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
58831 + if (grsec_enable_socket_server &&
58832 + in_group_p(grsec_socket_server_gid) &&
58833 + sck && (sck->sa_family != AF_UNIX) &&
58834 + (sck->sa_family != AF_LOCAL)) {
58835 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
58836 + return -EACCES;
58837 + }
58838 +#endif
58839 + return 0;
58840 +}
58841 +
58842 +int
58843 +gr_handle_sock_server_other(const struct sock *sck)
58844 +{
58845 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
58846 + if (grsec_enable_socket_server &&
58847 + in_group_p(grsec_socket_server_gid) &&
58848 + sck && (sck->sk_family != AF_UNIX) &&
58849 + (sck->sk_family != AF_LOCAL)) {
58850 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
58851 + return -EACCES;
58852 + }
58853 +#endif
58854 + return 0;
58855 +}
58856 +
58857 +int
58858 +gr_handle_sock_client(const struct sockaddr *sck)
58859 +{
58860 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
58861 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
58862 + sck && (sck->sa_family != AF_UNIX) &&
58863 + (sck->sa_family != AF_LOCAL)) {
58864 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
58865 + return -EACCES;
58866 + }
58867 +#endif
58868 + return 0;
58869 +}
58870 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
58871 new file mode 100644
58872 index 0000000..a1aedd7
58873 --- /dev/null
58874 +++ b/grsecurity/grsec_sysctl.c
58875 @@ -0,0 +1,451 @@
58876 +#include <linux/kernel.h>
58877 +#include <linux/sched.h>
58878 +#include <linux/sysctl.h>
58879 +#include <linux/grsecurity.h>
58880 +#include <linux/grinternal.h>
58881 +
58882 +int
58883 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
58884 +{
58885 +#ifdef CONFIG_GRKERNSEC_SYSCTL
58886 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
58887 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
58888 + return -EACCES;
58889 + }
58890 +#endif
58891 + return 0;
58892 +}
58893 +
58894 +#ifdef CONFIG_GRKERNSEC_ROFS
58895 +static int __maybe_unused one = 1;
58896 +#endif
58897 +
58898 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
58899 +struct ctl_table grsecurity_table[] = {
58900 +#ifdef CONFIG_GRKERNSEC_SYSCTL
58901 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
58902 +#ifdef CONFIG_GRKERNSEC_IO
58903 + {
58904 + .procname = "disable_priv_io",
58905 + .data = &grsec_disable_privio,
58906 + .maxlen = sizeof(int),
58907 + .mode = 0600,
58908 + .proc_handler = &proc_dointvec,
58909 + },
58910 +#endif
58911 +#endif
58912 +#ifdef CONFIG_GRKERNSEC_LINK
58913 + {
58914 + .procname = "linking_restrictions",
58915 + .data = &grsec_enable_link,
58916 + .maxlen = sizeof(int),
58917 + .mode = 0600,
58918 + .proc_handler = &proc_dointvec,
58919 + },
58920 +#endif
58921 +#ifdef CONFIG_GRKERNSEC_BRUTE
58922 + {
58923 + .procname = "deter_bruteforce",
58924 + .data = &grsec_enable_brute,
58925 + .maxlen = sizeof(int),
58926 + .mode = 0600,
58927 + .proc_handler = &proc_dointvec,
58928 + },
58929 +#endif
58930 +#ifdef CONFIG_GRKERNSEC_FIFO
58931 + {
58932 + .procname = "fifo_restrictions",
58933 + .data = &grsec_enable_fifo,
58934 + .maxlen = sizeof(int),
58935 + .mode = 0600,
58936 + .proc_handler = &proc_dointvec,
58937 + },
58938 +#endif
58939 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
58940 + {
58941 + .procname = "ptrace_readexec",
58942 + .data = &grsec_enable_ptrace_readexec,
58943 + .maxlen = sizeof(int),
58944 + .mode = 0600,
58945 + .proc_handler = &proc_dointvec,
58946 + },
58947 +#endif
58948 +#ifdef CONFIG_GRKERNSEC_SETXID
58949 + {
58950 + .procname = "consistent_setxid",
58951 + .data = &grsec_enable_setxid,
58952 + .maxlen = sizeof(int),
58953 + .mode = 0600,
58954 + .proc_handler = &proc_dointvec,
58955 + },
58956 +#endif
58957 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
58958 + {
58959 + .procname = "ip_blackhole",
58960 + .data = &grsec_enable_blackhole,
58961 + .maxlen = sizeof(int),
58962 + .mode = 0600,
58963 + .proc_handler = &proc_dointvec,
58964 + },
58965 + {
58966 + .procname = "lastack_retries",
58967 + .data = &grsec_lastack_retries,
58968 + .maxlen = sizeof(int),
58969 + .mode = 0600,
58970 + .proc_handler = &proc_dointvec,
58971 + },
58972 +#endif
58973 +#ifdef CONFIG_GRKERNSEC_EXECLOG
58974 + {
58975 + .procname = "exec_logging",
58976 + .data = &grsec_enable_execlog,
58977 + .maxlen = sizeof(int),
58978 + .mode = 0600,
58979 + .proc_handler = &proc_dointvec,
58980 + },
58981 +#endif
58982 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
58983 + {
58984 + .procname = "rwxmap_logging",
58985 + .data = &grsec_enable_log_rwxmaps,
58986 + .maxlen = sizeof(int),
58987 + .mode = 0600,
58988 + .proc_handler = &proc_dointvec,
58989 + },
58990 +#endif
58991 +#ifdef CONFIG_GRKERNSEC_SIGNAL
58992 + {
58993 + .procname = "signal_logging",
58994 + .data = &grsec_enable_signal,
58995 + .maxlen = sizeof(int),
58996 + .mode = 0600,
58997 + .proc_handler = &proc_dointvec,
58998 + },
58999 +#endif
59000 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
59001 + {
59002 + .procname = "forkfail_logging",
59003 + .data = &grsec_enable_forkfail,
59004 + .maxlen = sizeof(int),
59005 + .mode = 0600,
59006 + .proc_handler = &proc_dointvec,
59007 + },
59008 +#endif
59009 +#ifdef CONFIG_GRKERNSEC_TIME
59010 + {
59011 + .procname = "timechange_logging",
59012 + .data = &grsec_enable_time,
59013 + .maxlen = sizeof(int),
59014 + .mode = 0600,
59015 + .proc_handler = &proc_dointvec,
59016 + },
59017 +#endif
59018 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
59019 + {
59020 + .procname = "chroot_deny_shmat",
59021 + .data = &grsec_enable_chroot_shmat,
59022 + .maxlen = sizeof(int),
59023 + .mode = 0600,
59024 + .proc_handler = &proc_dointvec,
59025 + },
59026 +#endif
59027 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
59028 + {
59029 + .procname = "chroot_deny_unix",
59030 + .data = &grsec_enable_chroot_unix,
59031 + .maxlen = sizeof(int),
59032 + .mode = 0600,
59033 + .proc_handler = &proc_dointvec,
59034 + },
59035 +#endif
59036 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
59037 + {
59038 + .procname = "chroot_deny_mount",
59039 + .data = &grsec_enable_chroot_mount,
59040 + .maxlen = sizeof(int),
59041 + .mode = 0600,
59042 + .proc_handler = &proc_dointvec,
59043 + },
59044 +#endif
59045 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
59046 + {
59047 + .procname = "chroot_deny_fchdir",
59048 + .data = &grsec_enable_chroot_fchdir,
59049 + .maxlen = sizeof(int),
59050 + .mode = 0600,
59051 + .proc_handler = &proc_dointvec,
59052 + },
59053 +#endif
59054 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
59055 + {
59056 + .procname = "chroot_deny_chroot",
59057 + .data = &grsec_enable_chroot_double,
59058 + .maxlen = sizeof(int),
59059 + .mode = 0600,
59060 + .proc_handler = &proc_dointvec,
59061 + },
59062 +#endif
59063 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
59064 + {
59065 + .procname = "chroot_deny_pivot",
59066 + .data = &grsec_enable_chroot_pivot,
59067 + .maxlen = sizeof(int),
59068 + .mode = 0600,
59069 + .proc_handler = &proc_dointvec,
59070 + },
59071 +#endif
59072 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
59073 + {
59074 + .procname = "chroot_enforce_chdir",
59075 + .data = &grsec_enable_chroot_chdir,
59076 + .maxlen = sizeof(int),
59077 + .mode = 0600,
59078 + .proc_handler = &proc_dointvec,
59079 + },
59080 +#endif
59081 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
59082 + {
59083 + .procname = "chroot_deny_chmod",
59084 + .data = &grsec_enable_chroot_chmod,
59085 + .maxlen = sizeof(int),
59086 + .mode = 0600,
59087 + .proc_handler = &proc_dointvec,
59088 + },
59089 +#endif
59090 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
59091 + {
59092 + .procname = "chroot_deny_mknod",
59093 + .data = &grsec_enable_chroot_mknod,
59094 + .maxlen = sizeof(int),
59095 + .mode = 0600,
59096 + .proc_handler = &proc_dointvec,
59097 + },
59098 +#endif
59099 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
59100 + {
59101 + .procname = "chroot_restrict_nice",
59102 + .data = &grsec_enable_chroot_nice,
59103 + .maxlen = sizeof(int),
59104 + .mode = 0600,
59105 + .proc_handler = &proc_dointvec,
59106 + },
59107 +#endif
59108 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
59109 + {
59110 + .procname = "chroot_execlog",
59111 + .data = &grsec_enable_chroot_execlog,
59112 + .maxlen = sizeof(int),
59113 + .mode = 0600,
59114 + .proc_handler = &proc_dointvec,
59115 + },
59116 +#endif
59117 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
59118 + {
59119 + .procname = "chroot_caps",
59120 + .data = &grsec_enable_chroot_caps,
59121 + .maxlen = sizeof(int),
59122 + .mode = 0600,
59123 + .proc_handler = &proc_dointvec,
59124 + },
59125 +#endif
59126 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
59127 + {
59128 + .procname = "chroot_deny_sysctl",
59129 + .data = &grsec_enable_chroot_sysctl,
59130 + .maxlen = sizeof(int),
59131 + .mode = 0600,
59132 + .proc_handler = &proc_dointvec,
59133 + },
59134 +#endif
59135 +#ifdef CONFIG_GRKERNSEC_TPE
59136 + {
59137 + .procname = "tpe",
59138 + .data = &grsec_enable_tpe,
59139 + .maxlen = sizeof(int),
59140 + .mode = 0600,
59141 + .proc_handler = &proc_dointvec,
59142 + },
59143 + {
59144 + .procname = "tpe_gid",
59145 + .data = &grsec_tpe_gid,
59146 + .maxlen = sizeof(int),
59147 + .mode = 0600,
59148 + .proc_handler = &proc_dointvec,
59149 + },
59150 +#endif
59151 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
59152 + {
59153 + .procname = "tpe_invert",
59154 + .data = &grsec_enable_tpe_invert,
59155 + .maxlen = sizeof(int),
59156 + .mode = 0600,
59157 + .proc_handler = &proc_dointvec,
59158 + },
59159 +#endif
59160 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
59161 + {
59162 + .procname = "tpe_restrict_all",
59163 + .data = &grsec_enable_tpe_all,
59164 + .maxlen = sizeof(int),
59165 + .mode = 0600,
59166 + .proc_handler = &proc_dointvec,
59167 + },
59168 +#endif
59169 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
59170 + {
59171 + .procname = "socket_all",
59172 + .data = &grsec_enable_socket_all,
59173 + .maxlen = sizeof(int),
59174 + .mode = 0600,
59175 + .proc_handler = &proc_dointvec,
59176 + },
59177 + {
59178 + .procname = "socket_all_gid",
59179 + .data = &grsec_socket_all_gid,
59180 + .maxlen = sizeof(int),
59181 + .mode = 0600,
59182 + .proc_handler = &proc_dointvec,
59183 + },
59184 +#endif
59185 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
59186 + {
59187 + .procname = "socket_client",
59188 + .data = &grsec_enable_socket_client,
59189 + .maxlen = sizeof(int),
59190 + .mode = 0600,
59191 + .proc_handler = &proc_dointvec,
59192 + },
59193 + {
59194 + .procname = "socket_client_gid",
59195 + .data = &grsec_socket_client_gid,
59196 + .maxlen = sizeof(int),
59197 + .mode = 0600,
59198 + .proc_handler = &proc_dointvec,
59199 + },
59200 +#endif
59201 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
59202 + {
59203 + .procname = "socket_server",
59204 + .data = &grsec_enable_socket_server,
59205 + .maxlen = sizeof(int),
59206 + .mode = 0600,
59207 + .proc_handler = &proc_dointvec,
59208 + },
59209 + {
59210 + .procname = "socket_server_gid",
59211 + .data = &grsec_socket_server_gid,
59212 + .maxlen = sizeof(int),
59213 + .mode = 0600,
59214 + .proc_handler = &proc_dointvec,
59215 + },
59216 +#endif
59217 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
59218 + {
59219 + .procname = "audit_group",
59220 + .data = &grsec_enable_group,
59221 + .maxlen = sizeof(int),
59222 + .mode = 0600,
59223 + .proc_handler = &proc_dointvec,
59224 + },
59225 + {
59226 + .procname = "audit_gid",
59227 + .data = &grsec_audit_gid,
59228 + .maxlen = sizeof(int),
59229 + .mode = 0600,
59230 + .proc_handler = &proc_dointvec,
59231 + },
59232 +#endif
59233 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
59234 + {
59235 + .procname = "audit_chdir",
59236 + .data = &grsec_enable_chdir,
59237 + .maxlen = sizeof(int),
59238 + .mode = 0600,
59239 + .proc_handler = &proc_dointvec,
59240 + },
59241 +#endif
59242 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
59243 + {
59244 + .procname = "audit_mount",
59245 + .data = &grsec_enable_mount,
59246 + .maxlen = sizeof(int),
59247 + .mode = 0600,
59248 + .proc_handler = &proc_dointvec,
59249 + },
59250 +#endif
59251 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
59252 + {
59253 + .procname = "audit_textrel",
59254 + .data = &grsec_enable_audit_textrel,
59255 + .maxlen = sizeof(int),
59256 + .mode = 0600,
59257 + .proc_handler = &proc_dointvec,
59258 + },
59259 +#endif
59260 +#ifdef CONFIG_GRKERNSEC_DMESG
59261 + {
59262 + .procname = "dmesg",
59263 + .data = &grsec_enable_dmesg,
59264 + .maxlen = sizeof(int),
59265 + .mode = 0600,
59266 + .proc_handler = &proc_dointvec,
59267 + },
59268 +#endif
59269 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
59270 + {
59271 + .procname = "chroot_findtask",
59272 + .data = &grsec_enable_chroot_findtask,
59273 + .maxlen = sizeof(int),
59274 + .mode = 0600,
59275 + .proc_handler = &proc_dointvec,
59276 + },
59277 +#endif
59278 +#ifdef CONFIG_GRKERNSEC_RESLOG
59279 + {
59280 + .procname = "resource_logging",
59281 + .data = &grsec_resource_logging,
59282 + .maxlen = sizeof(int),
59283 + .mode = 0600,
59284 + .proc_handler = &proc_dointvec,
59285 + },
59286 +#endif
59287 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
59288 + {
59289 + .procname = "audit_ptrace",
59290 + .data = &grsec_enable_audit_ptrace,
59291 + .maxlen = sizeof(int),
59292 + .mode = 0600,
59293 + .proc_handler = &proc_dointvec,
59294 + },
59295 +#endif
59296 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
59297 + {
59298 + .procname = "harden_ptrace",
59299 + .data = &grsec_enable_harden_ptrace,
59300 + .maxlen = sizeof(int),
59301 + .mode = 0600,
59302 + .proc_handler = &proc_dointvec,
59303 + },
59304 +#endif
59305 + {
59306 + .procname = "grsec_lock",
59307 + .data = &grsec_lock,
59308 + .maxlen = sizeof(int),
59309 + .mode = 0600,
59310 + .proc_handler = &proc_dointvec,
59311 + },
59312 +#endif
59313 +#ifdef CONFIG_GRKERNSEC_ROFS
59314 + {
59315 + .procname = "romount_protect",
59316 + .data = &grsec_enable_rofs,
59317 + .maxlen = sizeof(int),
59318 + .mode = 0600,
59319 + .proc_handler = &proc_dointvec_minmax,
59320 + .extra1 = &one,
59321 + .extra2 = &one,
59322 + },
59323 +#endif
59324 + { }
59325 +};
59326 +#endif
59327 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
59328 new file mode 100644
59329 index 0000000..0dc13c3
59330 --- /dev/null
59331 +++ b/grsecurity/grsec_time.c
59332 @@ -0,0 +1,16 @@
59333 +#include <linux/kernel.h>
59334 +#include <linux/sched.h>
59335 +#include <linux/grinternal.h>
59336 +#include <linux/module.h>
59337 +
59338 +void
59339 +gr_log_timechange(void)
59340 +{
59341 +#ifdef CONFIG_GRKERNSEC_TIME
59342 + if (grsec_enable_time)
59343 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
59344 +#endif
59345 + return;
59346 +}
59347 +
59348 +EXPORT_SYMBOL(gr_log_timechange);
59349 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
59350 new file mode 100644
59351 index 0000000..07e0dc0
59352 --- /dev/null
59353 +++ b/grsecurity/grsec_tpe.c
59354 @@ -0,0 +1,73 @@
59355 +#include <linux/kernel.h>
59356 +#include <linux/sched.h>
59357 +#include <linux/file.h>
59358 +#include <linux/fs.h>
59359 +#include <linux/grinternal.h>
59360 +
59361 +extern int gr_acl_tpe_check(void);
59362 +
59363 +int
59364 +gr_tpe_allow(const struct file *file)
59365 +{
59366 +#ifdef CONFIG_GRKERNSEC
59367 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
59368 + const struct cred *cred = current_cred();
59369 + char *msg = NULL;
59370 + char *msg2 = NULL;
59371 +
59372 + // never restrict root
59373 + if (!cred->uid)
59374 + return 1;
59375 +
59376 + if (grsec_enable_tpe) {
59377 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
59378 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
59379 + msg = "not being in trusted group";
59380 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
59381 + msg = "being in untrusted group";
59382 +#else
59383 + if (in_group_p(grsec_tpe_gid))
59384 + msg = "being in untrusted group";
59385 +#endif
59386 + }
59387 + if (!msg && gr_acl_tpe_check())
59388 + msg = "being in untrusted role";
59389 +
59390 + // not in any affected group/role
59391 + if (!msg)
59392 + goto next_check;
59393 +
59394 + if (inode->i_uid)
59395 + msg2 = "file in non-root-owned directory";
59396 + else if (inode->i_mode & S_IWOTH)
59397 + msg2 = "file in world-writable directory";
59398 + else if (inode->i_mode & S_IWGRP)
59399 + msg2 = "file in group-writable directory";
59400 +
59401 + if (msg && msg2) {
59402 + char fullmsg[70] = {0};
59403 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
59404 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
59405 + return 0;
59406 + }
59407 + msg = NULL;
59408 +next_check:
59409 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
59410 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
59411 + return 1;
59412 +
59413 + if (inode->i_uid && (inode->i_uid != cred->uid))
59414 + msg = "directory not owned by user";
59415 + else if (inode->i_mode & S_IWOTH)
59416 + msg = "file in world-writable directory";
59417 + else if (inode->i_mode & S_IWGRP)
59418 + msg = "file in group-writable directory";
59419 +
59420 + if (msg) {
59421 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
59422 + return 0;
59423 + }
59424 +#endif
59425 +#endif
59426 + return 1;
59427 +}
59428 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
59429 new file mode 100644
59430 index 0000000..9f7b1ac
59431 --- /dev/null
59432 +++ b/grsecurity/grsum.c
59433 @@ -0,0 +1,61 @@
59434 +#include <linux/err.h>
59435 +#include <linux/kernel.h>
59436 +#include <linux/sched.h>
59437 +#include <linux/mm.h>
59438 +#include <linux/scatterlist.h>
59439 +#include <linux/crypto.h>
59440 +#include <linux/gracl.h>
59441 +
59442 +
59443 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
59444 +#error "crypto and sha256 must be built into the kernel"
59445 +#endif
59446 +
59447 +int
59448 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
59449 +{
59450 + char *p;
59451 + struct crypto_hash *tfm;
59452 + struct hash_desc desc;
59453 + struct scatterlist sg;
59454 + unsigned char temp_sum[GR_SHA_LEN];
59455 + volatile int retval = 0;
59456 + volatile int dummy = 0;
59457 + unsigned int i;
59458 +
59459 + sg_init_table(&sg, 1);
59460 +
59461 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
59462 + if (IS_ERR(tfm)) {
59463 + /* should never happen, since sha256 should be built in */
59464 + return 1;
59465 + }
59466 +
59467 + desc.tfm = tfm;
59468 + desc.flags = 0;
59469 +
59470 + crypto_hash_init(&desc);
59471 +
59472 + p = salt;
59473 + sg_set_buf(&sg, p, GR_SALT_LEN);
59474 + crypto_hash_update(&desc, &sg, sg.length);
59475 +
59476 + p = entry->pw;
59477 + sg_set_buf(&sg, p, strlen(p));
59478 +
59479 + crypto_hash_update(&desc, &sg, sg.length);
59480 +
59481 + crypto_hash_final(&desc, temp_sum);
59482 +
59483 + memset(entry->pw, 0, GR_PW_LEN);
59484 +
59485 + for (i = 0; i < GR_SHA_LEN; i++)
59486 + if (sum[i] != temp_sum[i])
59487 + retval = 1;
59488 + else
59489 + dummy = 1; // waste a cycle
59490 +
59491 + crypto_free_hash(tfm);
59492 +
59493 + return retval;
59494 +}
59495 diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
59496 index 6cd5b64..f620d2d 100644
59497 --- a/include/acpi/acpi_bus.h
59498 +++ b/include/acpi/acpi_bus.h
59499 @@ -107,7 +107,7 @@ struct acpi_device_ops {
59500 acpi_op_bind bind;
59501 acpi_op_unbind unbind;
59502 acpi_op_notify notify;
59503 -};
59504 +} __no_const;
59505
59506 #define ACPI_DRIVER_ALL_NOTIFY_EVENTS 0x1 /* system AND device events */
59507
59508 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
59509 index b7babf0..71e4e74 100644
59510 --- a/include/asm-generic/atomic-long.h
59511 +++ b/include/asm-generic/atomic-long.h
59512 @@ -22,6 +22,12 @@
59513
59514 typedef atomic64_t atomic_long_t;
59515
59516 +#ifdef CONFIG_PAX_REFCOUNT
59517 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
59518 +#else
59519 +typedef atomic64_t atomic_long_unchecked_t;
59520 +#endif
59521 +
59522 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
59523
59524 static inline long atomic_long_read(atomic_long_t *l)
59525 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
59526 return (long)atomic64_read(v);
59527 }
59528
59529 +#ifdef CONFIG_PAX_REFCOUNT
59530 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
59531 +{
59532 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
59533 +
59534 + return (long)atomic64_read_unchecked(v);
59535 +}
59536 +#endif
59537 +
59538 static inline void atomic_long_set(atomic_long_t *l, long i)
59539 {
59540 atomic64_t *v = (atomic64_t *)l;
59541 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
59542 atomic64_set(v, i);
59543 }
59544
59545 +#ifdef CONFIG_PAX_REFCOUNT
59546 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
59547 +{
59548 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
59549 +
59550 + atomic64_set_unchecked(v, i);
59551 +}
59552 +#endif
59553 +
59554 static inline void atomic_long_inc(atomic_long_t *l)
59555 {
59556 atomic64_t *v = (atomic64_t *)l;
59557 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
59558 atomic64_inc(v);
59559 }
59560
59561 +#ifdef CONFIG_PAX_REFCOUNT
59562 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
59563 +{
59564 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
59565 +
59566 + atomic64_inc_unchecked(v);
59567 +}
59568 +#endif
59569 +
59570 static inline void atomic_long_dec(atomic_long_t *l)
59571 {
59572 atomic64_t *v = (atomic64_t *)l;
59573 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
59574 atomic64_dec(v);
59575 }
59576
59577 +#ifdef CONFIG_PAX_REFCOUNT
59578 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
59579 +{
59580 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
59581 +
59582 + atomic64_dec_unchecked(v);
59583 +}
59584 +#endif
59585 +
59586 static inline void atomic_long_add(long i, atomic_long_t *l)
59587 {
59588 atomic64_t *v = (atomic64_t *)l;
59589 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
59590 atomic64_add(i, v);
59591 }
59592
59593 +#ifdef CONFIG_PAX_REFCOUNT
59594 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
59595 +{
59596 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
59597 +
59598 + atomic64_add_unchecked(i, v);
59599 +}
59600 +#endif
59601 +
59602 static inline void atomic_long_sub(long i, atomic_long_t *l)
59603 {
59604 atomic64_t *v = (atomic64_t *)l;
59605 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
59606 atomic64_sub(i, v);
59607 }
59608
59609 +#ifdef CONFIG_PAX_REFCOUNT
59610 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
59611 +{
59612 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
59613 +
59614 + atomic64_sub_unchecked(i, v);
59615 +}
59616 +#endif
59617 +
59618 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
59619 {
59620 atomic64_t *v = (atomic64_t *)l;
59621 @@ -115,6 +175,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
59622 return (long)atomic64_inc_return(v);
59623 }
59624
59625 +#ifdef CONFIG_PAX_REFCOUNT
59626 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
59627 +{
59628 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
59629 +
59630 + return (long)atomic64_inc_return_unchecked(v);
59631 +}
59632 +#endif
59633 +
59634 static inline long atomic_long_dec_return(atomic_long_t *l)
59635 {
59636 atomic64_t *v = (atomic64_t *)l;
59637 @@ -140,6 +209,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
59638
59639 typedef atomic_t atomic_long_t;
59640
59641 +#ifdef CONFIG_PAX_REFCOUNT
59642 +typedef atomic_unchecked_t atomic_long_unchecked_t;
59643 +#else
59644 +typedef atomic_t atomic_long_unchecked_t;
59645 +#endif
59646 +
59647 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
59648 static inline long atomic_long_read(atomic_long_t *l)
59649 {
59650 @@ -148,6 +223,15 @@ static inline long atomic_long_read(atomic_long_t *l)
59651 return (long)atomic_read(v);
59652 }
59653
59654 +#ifdef CONFIG_PAX_REFCOUNT
59655 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
59656 +{
59657 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
59658 +
59659 + return (long)atomic_read_unchecked(v);
59660 +}
59661 +#endif
59662 +
59663 static inline void atomic_long_set(atomic_long_t *l, long i)
59664 {
59665 atomic_t *v = (atomic_t *)l;
59666 @@ -155,6 +239,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
59667 atomic_set(v, i);
59668 }
59669
59670 +#ifdef CONFIG_PAX_REFCOUNT
59671 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
59672 +{
59673 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
59674 +
59675 + atomic_set_unchecked(v, i);
59676 +}
59677 +#endif
59678 +
59679 static inline void atomic_long_inc(atomic_long_t *l)
59680 {
59681 atomic_t *v = (atomic_t *)l;
59682 @@ -162,6 +255,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
59683 atomic_inc(v);
59684 }
59685
59686 +#ifdef CONFIG_PAX_REFCOUNT
59687 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
59688 +{
59689 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
59690 +
59691 + atomic_inc_unchecked(v);
59692 +}
59693 +#endif
59694 +
59695 static inline void atomic_long_dec(atomic_long_t *l)
59696 {
59697 atomic_t *v = (atomic_t *)l;
59698 @@ -169,6 +271,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
59699 atomic_dec(v);
59700 }
59701
59702 +#ifdef CONFIG_PAX_REFCOUNT
59703 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
59704 +{
59705 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
59706 +
59707 + atomic_dec_unchecked(v);
59708 +}
59709 +#endif
59710 +
59711 static inline void atomic_long_add(long i, atomic_long_t *l)
59712 {
59713 atomic_t *v = (atomic_t *)l;
59714 @@ -176,6 +287,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
59715 atomic_add(i, v);
59716 }
59717
59718 +#ifdef CONFIG_PAX_REFCOUNT
59719 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
59720 +{
59721 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
59722 +
59723 + atomic_add_unchecked(i, v);
59724 +}
59725 +#endif
59726 +
59727 static inline void atomic_long_sub(long i, atomic_long_t *l)
59728 {
59729 atomic_t *v = (atomic_t *)l;
59730 @@ -183,6 +303,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
59731 atomic_sub(i, v);
59732 }
59733
59734 +#ifdef CONFIG_PAX_REFCOUNT
59735 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
59736 +{
59737 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
59738 +
59739 + atomic_sub_unchecked(i, v);
59740 +}
59741 +#endif
59742 +
59743 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
59744 {
59745 atomic_t *v = (atomic_t *)l;
59746 @@ -232,6 +361,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
59747 return (long)atomic_inc_return(v);
59748 }
59749
59750 +#ifdef CONFIG_PAX_REFCOUNT
59751 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
59752 +{
59753 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
59754 +
59755 + return (long)atomic_inc_return_unchecked(v);
59756 +}
59757 +#endif
59758 +
59759 static inline long atomic_long_dec_return(atomic_long_t *l)
59760 {
59761 atomic_t *v = (atomic_t *)l;
59762 @@ -255,4 +393,49 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
59763
59764 #endif /* BITS_PER_LONG == 64 */
59765
59766 +#ifdef CONFIG_PAX_REFCOUNT
59767 +static inline void pax_refcount_needs_these_functions(void)
59768 +{
59769 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
59770 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
59771 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
59772 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
59773 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
59774 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
59775 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
59776 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
59777 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
59778 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
59779 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
59780 +
59781 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
59782 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
59783 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
59784 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
59785 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
59786 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
59787 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
59788 +}
59789 +#else
59790 +#define atomic_read_unchecked(v) atomic_read(v)
59791 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
59792 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
59793 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
59794 +#define atomic_inc_unchecked(v) atomic_inc(v)
59795 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
59796 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
59797 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
59798 +#define atomic_dec_unchecked(v) atomic_dec(v)
59799 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
59800 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
59801 +
59802 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
59803 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
59804 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
59805 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
59806 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
59807 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
59808 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
59809 +#endif
59810 +
59811 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
59812 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
59813 index b18ce4f..2ee2843 100644
59814 --- a/include/asm-generic/atomic64.h
59815 +++ b/include/asm-generic/atomic64.h
59816 @@ -16,6 +16,8 @@ typedef struct {
59817 long long counter;
59818 } atomic64_t;
59819
59820 +typedef atomic64_t atomic64_unchecked_t;
59821 +
59822 #define ATOMIC64_INIT(i) { (i) }
59823
59824 extern long long atomic64_read(const atomic64_t *v);
59825 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
59826 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
59827 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
59828
59829 +#define atomic64_read_unchecked(v) atomic64_read(v)
59830 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
59831 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
59832 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
59833 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
59834 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
59835 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
59836 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
59837 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
59838 +
59839 #endif /* _ASM_GENERIC_ATOMIC64_H */
59840 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
59841 index 1bfcfe5..e04c5c9 100644
59842 --- a/include/asm-generic/cache.h
59843 +++ b/include/asm-generic/cache.h
59844 @@ -6,7 +6,7 @@
59845 * cache lines need to provide their own cache.h.
59846 */
59847
59848 -#define L1_CACHE_SHIFT 5
59849 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
59850 +#define L1_CACHE_SHIFT 5UL
59851 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
59852
59853 #endif /* __ASM_GENERIC_CACHE_H */
59854 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
59855 index 0d68a1e..b74a761 100644
59856 --- a/include/asm-generic/emergency-restart.h
59857 +++ b/include/asm-generic/emergency-restart.h
59858 @@ -1,7 +1,7 @@
59859 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
59860 #define _ASM_GENERIC_EMERGENCY_RESTART_H
59861
59862 -static inline void machine_emergency_restart(void)
59863 +static inline __noreturn void machine_emergency_restart(void)
59864 {
59865 machine_restart(NULL);
59866 }
59867 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
59868 index 0232ccb..13d9165 100644
59869 --- a/include/asm-generic/kmap_types.h
59870 +++ b/include/asm-generic/kmap_types.h
59871 @@ -29,10 +29,11 @@ KMAP_D(16) KM_IRQ_PTE,
59872 KMAP_D(17) KM_NMI,
59873 KMAP_D(18) KM_NMI_PTE,
59874 KMAP_D(19) KM_KDB,
59875 +KMAP_D(20) KM_CLEARPAGE,
59876 /*
59877 * Remember to update debug_kmap_atomic() when adding new kmap types!
59878 */
59879 -KMAP_D(20) KM_TYPE_NR
59880 +KMAP_D(21) KM_TYPE_NR
59881 };
59882
59883 #undef KMAP_D
59884 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
59885 index 9ceb03b..2efbcbd 100644
59886 --- a/include/asm-generic/local.h
59887 +++ b/include/asm-generic/local.h
59888 @@ -39,6 +39,7 @@ typedef struct
59889 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
59890 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
59891 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
59892 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
59893
59894 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
59895 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
59896 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
59897 index 725612b..9cc513a 100644
59898 --- a/include/asm-generic/pgtable-nopmd.h
59899 +++ b/include/asm-generic/pgtable-nopmd.h
59900 @@ -1,14 +1,19 @@
59901 #ifndef _PGTABLE_NOPMD_H
59902 #define _PGTABLE_NOPMD_H
59903
59904 -#ifndef __ASSEMBLY__
59905 -
59906 #include <asm-generic/pgtable-nopud.h>
59907
59908 -struct mm_struct;
59909 -
59910 #define __PAGETABLE_PMD_FOLDED
59911
59912 +#define PMD_SHIFT PUD_SHIFT
59913 +#define PTRS_PER_PMD 1
59914 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
59915 +#define PMD_MASK (~(PMD_SIZE-1))
59916 +
59917 +#ifndef __ASSEMBLY__
59918 +
59919 +struct mm_struct;
59920 +
59921 /*
59922 * Having the pmd type consist of a pud gets the size right, and allows
59923 * us to conceptually access the pud entry that this pmd is folded into
59924 @@ -16,11 +21,6 @@ struct mm_struct;
59925 */
59926 typedef struct { pud_t pud; } pmd_t;
59927
59928 -#define PMD_SHIFT PUD_SHIFT
59929 -#define PTRS_PER_PMD 1
59930 -#define PMD_SIZE (1UL << PMD_SHIFT)
59931 -#define PMD_MASK (~(PMD_SIZE-1))
59932 -
59933 /*
59934 * The "pud_xxx()" functions here are trivial for a folded two-level
59935 * setup: the pmd is never bad, and a pmd always exists (as it's folded
59936 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
59937 index 810431d..0ec4804f 100644
59938 --- a/include/asm-generic/pgtable-nopud.h
59939 +++ b/include/asm-generic/pgtable-nopud.h
59940 @@ -1,10 +1,15 @@
59941 #ifndef _PGTABLE_NOPUD_H
59942 #define _PGTABLE_NOPUD_H
59943
59944 -#ifndef __ASSEMBLY__
59945 -
59946 #define __PAGETABLE_PUD_FOLDED
59947
59948 +#define PUD_SHIFT PGDIR_SHIFT
59949 +#define PTRS_PER_PUD 1
59950 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
59951 +#define PUD_MASK (~(PUD_SIZE-1))
59952 +
59953 +#ifndef __ASSEMBLY__
59954 +
59955 /*
59956 * Having the pud type consist of a pgd gets the size right, and allows
59957 * us to conceptually access the pgd entry that this pud is folded into
59958 @@ -12,11 +17,6 @@
59959 */
59960 typedef struct { pgd_t pgd; } pud_t;
59961
59962 -#define PUD_SHIFT PGDIR_SHIFT
59963 -#define PTRS_PER_PUD 1
59964 -#define PUD_SIZE (1UL << PUD_SHIFT)
59965 -#define PUD_MASK (~(PUD_SIZE-1))
59966 -
59967 /*
59968 * The "pgd_xxx()" functions here are trivial for a folded two-level
59969 * setup: the pud is never bad, and a pud always exists (as it's folded
59970 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
59971 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
59972
59973 #define pgd_populate(mm, pgd, pud) do { } while (0)
59974 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
59975 /*
59976 * (puds are folded into pgds so this doesn't get actually called,
59977 * but the define is needed for a generic inline function.)
59978 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
59979 index a03c098..19751cf 100644
59980 --- a/include/asm-generic/pgtable.h
59981 +++ b/include/asm-generic/pgtable.h
59982 @@ -445,6 +445,18 @@ static inline int pmd_write(pmd_t pmd)
59983 #endif /* __HAVE_ARCH_PMD_WRITE */
59984 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
59985
59986 +#ifndef __HAVE_ARCH_READ_PMD_ATOMIC
59987 +static inline pmd_t read_pmd_atomic(pmd_t *pmdp)
59988 +{
59989 + /*
59990 + * Depend on compiler for an atomic pmd read. NOTE: this is
59991 + * only going to work, if the pmdval_t isn't larger than
59992 + * an unsigned long.
59993 + */
59994 + return *pmdp;
59995 +}
59996 +#endif /* __HAVE_ARCH_READ_PMD_ATOMIC */
59997 +
59998 /*
59999 * This function is meant to be used by sites walking pagetables with
60000 * the mmap_sem hold in read mode to protect against MADV_DONTNEED and
60001 @@ -458,11 +470,17 @@ static inline int pmd_write(pmd_t pmd)
60002 * undefined so behaving like if the pmd was none is safe (because it
60003 * can return none anyway). The compiler level barrier() is critically
60004 * important to compute the two checks atomically on the same pmdval.
60005 + *
60006 + * For 32bit kernels with a 64bit large pmd_t this automatically takes
60007 + * care of reading the pmd atomically to avoid SMP race conditions
60008 + * against pmd_populate() when the mmap_sem is hold for reading by the
60009 + * caller (a special atomic read not done by "gcc" as in the generic
60010 + * version above, is also needed when THP is disabled because the page
60011 + * fault can populate the pmd from under us).
60012 */
60013 static inline int pmd_none_or_trans_huge_or_clear_bad(pmd_t *pmd)
60014 {
60015 - /* depend on compiler for an atomic pmd read */
60016 - pmd_t pmdval = *pmd;
60017 + pmd_t pmdval = read_pmd_atomic(pmd);
60018 /*
60019 * The barrier will stabilize the pmdval in a register or on
60020 * the stack so that it will stop changing under the code.
60021 @@ -502,6 +520,14 @@ static inline int pmd_trans_unstable(pmd_t *pmd)
60022 #endif
60023 }
60024
60025 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
60026 +static inline unsigned long pax_open_kernel(void) { return 0; }
60027 +#endif
60028 +
60029 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
60030 +static inline unsigned long pax_close_kernel(void) { return 0; }
60031 +#endif
60032 +
60033 #endif /* CONFIG_MMU */
60034
60035 #endif /* !__ASSEMBLY__ */
60036 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
60037 index b5e2e4c..6a5373e 100644
60038 --- a/include/asm-generic/vmlinux.lds.h
60039 +++ b/include/asm-generic/vmlinux.lds.h
60040 @@ -217,6 +217,7 @@
60041 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
60042 VMLINUX_SYMBOL(__start_rodata) = .; \
60043 *(.rodata) *(.rodata.*) \
60044 + *(.data..read_only) \
60045 *(__vermagic) /* Kernel version magic */ \
60046 . = ALIGN(8); \
60047 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
60048 @@ -722,17 +723,18 @@
60049 * section in the linker script will go there too. @phdr should have
60050 * a leading colon.
60051 *
60052 - * Note that this macros defines __per_cpu_load as an absolute symbol.
60053 + * Note that this macros defines per_cpu_load as an absolute symbol.
60054 * If there is no need to put the percpu section at a predetermined
60055 * address, use PERCPU_SECTION.
60056 */
60057 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
60058 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
60059 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
60060 + per_cpu_load = .; \
60061 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
60062 - LOAD_OFFSET) { \
60063 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
60064 PERCPU_INPUT(cacheline) \
60065 } phdr \
60066 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
60067 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
60068
60069 /**
60070 * PERCPU_SECTION - define output section for percpu area, simple version
60071 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
60072 index 92f0981..d44a37c 100644
60073 --- a/include/drm/drmP.h
60074 +++ b/include/drm/drmP.h
60075 @@ -72,6 +72,7 @@
60076 #include <linux/workqueue.h>
60077 #include <linux/poll.h>
60078 #include <asm/pgalloc.h>
60079 +#include <asm/local.h>
60080 #include "drm.h"
60081
60082 #include <linux/idr.h>
60083 @@ -1038,7 +1039,7 @@ struct drm_device {
60084
60085 /** \name Usage Counters */
60086 /*@{ */
60087 - int open_count; /**< Outstanding files open */
60088 + local_t open_count; /**< Outstanding files open */
60089 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
60090 atomic_t vma_count; /**< Outstanding vma areas open */
60091 int buf_use; /**< Buffers in use -- cannot alloc */
60092 @@ -1049,7 +1050,7 @@ struct drm_device {
60093 /*@{ */
60094 unsigned long counters;
60095 enum drm_stat_type types[15];
60096 - atomic_t counts[15];
60097 + atomic_unchecked_t counts[15];
60098 /*@} */
60099
60100 struct list_head filelist;
60101 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
60102 index 37515d1..34fa8b0 100644
60103 --- a/include/drm/drm_crtc_helper.h
60104 +++ b/include/drm/drm_crtc_helper.h
60105 @@ -74,7 +74,7 @@ struct drm_crtc_helper_funcs {
60106
60107 /* disable crtc when not in use - more explicit than dpms off */
60108 void (*disable)(struct drm_crtc *crtc);
60109 -};
60110 +} __no_const;
60111
60112 struct drm_encoder_helper_funcs {
60113 void (*dpms)(struct drm_encoder *encoder, int mode);
60114 @@ -95,7 +95,7 @@ struct drm_encoder_helper_funcs {
60115 struct drm_connector *connector);
60116 /* disable encoder when not in use - more explicit than dpms off */
60117 void (*disable)(struct drm_encoder *encoder);
60118 -};
60119 +} __no_const;
60120
60121 struct drm_connector_helper_funcs {
60122 int (*get_modes)(struct drm_connector *connector);
60123 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
60124 index 26c1f78..6722682 100644
60125 --- a/include/drm/ttm/ttm_memory.h
60126 +++ b/include/drm/ttm/ttm_memory.h
60127 @@ -47,7 +47,7 @@
60128
60129 struct ttm_mem_shrink {
60130 int (*do_shrink) (struct ttm_mem_shrink *);
60131 -};
60132 +} __no_const;
60133
60134 /**
60135 * struct ttm_mem_global - Global memory accounting structure.
60136 diff --git a/include/linux/a.out.h b/include/linux/a.out.h
60137 index e86dfca..40cc55f 100644
60138 --- a/include/linux/a.out.h
60139 +++ b/include/linux/a.out.h
60140 @@ -39,6 +39,14 @@ enum machine_type {
60141 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
60142 };
60143
60144 +/* Constants for the N_FLAGS field */
60145 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
60146 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
60147 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
60148 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
60149 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
60150 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
60151 +
60152 #if !defined (N_MAGIC)
60153 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
60154 #endif
60155 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
60156 index f4ff882..84b53a6 100644
60157 --- a/include/linux/atmdev.h
60158 +++ b/include/linux/atmdev.h
60159 @@ -237,7 +237,7 @@ struct compat_atm_iobuf {
60160 #endif
60161
60162 struct k_atm_aal_stats {
60163 -#define __HANDLE_ITEM(i) atomic_t i
60164 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
60165 __AAL_STAT_ITEMS
60166 #undef __HANDLE_ITEM
60167 };
60168 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
60169 index 0092102..8a801b4 100644
60170 --- a/include/linux/binfmts.h
60171 +++ b/include/linux/binfmts.h
60172 @@ -89,6 +89,7 @@ struct linux_binfmt {
60173 int (*load_binary)(struct linux_binprm *, struct pt_regs * regs);
60174 int (*load_shlib)(struct file *);
60175 int (*core_dump)(struct coredump_params *cprm);
60176 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
60177 unsigned long min_coredump; /* minimal dump size */
60178 };
60179
60180 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
60181 index 606cf33..b72c577 100644
60182 --- a/include/linux/blkdev.h
60183 +++ b/include/linux/blkdev.h
60184 @@ -1379,7 +1379,7 @@ struct block_device_operations {
60185 /* this callback is with swap_lock and sometimes page table lock held */
60186 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
60187 struct module *owner;
60188 -};
60189 +} __do_const;
60190
60191 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
60192 unsigned long);
60193 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
60194 index 4d1a074..88f929a 100644
60195 --- a/include/linux/blktrace_api.h
60196 +++ b/include/linux/blktrace_api.h
60197 @@ -162,7 +162,7 @@ struct blk_trace {
60198 struct dentry *dir;
60199 struct dentry *dropped_file;
60200 struct dentry *msg_file;
60201 - atomic_t dropped;
60202 + atomic_unchecked_t dropped;
60203 };
60204
60205 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
60206 diff --git a/include/linux/byteorder/little_endian.h b/include/linux/byteorder/little_endian.h
60207 index 83195fb..0b0f77d 100644
60208 --- a/include/linux/byteorder/little_endian.h
60209 +++ b/include/linux/byteorder/little_endian.h
60210 @@ -42,51 +42,51 @@
60211
60212 static inline __le64 __cpu_to_le64p(const __u64 *p)
60213 {
60214 - return (__force __le64)*p;
60215 + return (__force const __le64)*p;
60216 }
60217 static inline __u64 __le64_to_cpup(const __le64 *p)
60218 {
60219 - return (__force __u64)*p;
60220 + return (__force const __u64)*p;
60221 }
60222 static inline __le32 __cpu_to_le32p(const __u32 *p)
60223 {
60224 - return (__force __le32)*p;
60225 + return (__force const __le32)*p;
60226 }
60227 static inline __u32 __le32_to_cpup(const __le32 *p)
60228 {
60229 - return (__force __u32)*p;
60230 + return (__force const __u32)*p;
60231 }
60232 static inline __le16 __cpu_to_le16p(const __u16 *p)
60233 {
60234 - return (__force __le16)*p;
60235 + return (__force const __le16)*p;
60236 }
60237 static inline __u16 __le16_to_cpup(const __le16 *p)
60238 {
60239 - return (__force __u16)*p;
60240 + return (__force const __u16)*p;
60241 }
60242 static inline __be64 __cpu_to_be64p(const __u64 *p)
60243 {
60244 - return (__force __be64)__swab64p(p);
60245 + return (__force const __be64)__swab64p(p);
60246 }
60247 static inline __u64 __be64_to_cpup(const __be64 *p)
60248 {
60249 - return __swab64p((__u64 *)p);
60250 + return __swab64p((const __u64 *)p);
60251 }
60252 static inline __be32 __cpu_to_be32p(const __u32 *p)
60253 {
60254 - return (__force __be32)__swab32p(p);
60255 + return (__force const __be32)__swab32p(p);
60256 }
60257 static inline __u32 __be32_to_cpup(const __be32 *p)
60258 {
60259 - return __swab32p((__u32 *)p);
60260 + return __swab32p((const __u32 *)p);
60261 }
60262 static inline __be16 __cpu_to_be16p(const __u16 *p)
60263 {
60264 - return (__force __be16)__swab16p(p);
60265 + return (__force const __be16)__swab16p(p);
60266 }
60267 static inline __u16 __be16_to_cpup(const __be16 *p)
60268 {
60269 - return __swab16p((__u16 *)p);
60270 + return __swab16p((const __u16 *)p);
60271 }
60272 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
60273 #define __le64_to_cpus(x) do { (void)(x); } while (0)
60274 diff --git a/include/linux/cache.h b/include/linux/cache.h
60275 index 4c57065..4307975 100644
60276 --- a/include/linux/cache.h
60277 +++ b/include/linux/cache.h
60278 @@ -16,6 +16,10 @@
60279 #define __read_mostly
60280 #endif
60281
60282 +#ifndef __read_only
60283 +#define __read_only __read_mostly
60284 +#endif
60285 +
60286 #ifndef ____cacheline_aligned
60287 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
60288 #endif
60289 diff --git a/include/linux/capability.h b/include/linux/capability.h
60290 index 12d52de..b5f7fa7 100644
60291 --- a/include/linux/capability.h
60292 +++ b/include/linux/capability.h
60293 @@ -548,6 +548,8 @@ extern bool has_ns_capability_noaudit(struct task_struct *t,
60294 extern bool capable(int cap);
60295 extern bool ns_capable(struct user_namespace *ns, int cap);
60296 extern bool nsown_capable(int cap);
60297 +extern bool capable_nolog(int cap);
60298 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
60299
60300 /* audit system wants to get cap info from files as well */
60301 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
60302 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
60303 index 04ffb2e..6799180 100644
60304 --- a/include/linux/cleancache.h
60305 +++ b/include/linux/cleancache.h
60306 @@ -31,7 +31,7 @@ struct cleancache_ops {
60307 void (*flush_page)(int, struct cleancache_filekey, pgoff_t);
60308 void (*flush_inode)(int, struct cleancache_filekey);
60309 void (*flush_fs)(int);
60310 -};
60311 +} __no_const;
60312
60313 extern struct cleancache_ops
60314 cleancache_register_ops(struct cleancache_ops *ops);
60315 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
60316 index 2f40791..a62d196 100644
60317 --- a/include/linux/compiler-gcc4.h
60318 +++ b/include/linux/compiler-gcc4.h
60319 @@ -32,6 +32,16 @@
60320 #define __linktime_error(message) __attribute__((__error__(message)))
60321
60322 #if __GNUC_MINOR__ >= 5
60323 +
60324 +#ifdef CONSTIFY_PLUGIN
60325 +#define __no_const __attribute__((no_const))
60326 +#define __do_const __attribute__((do_const))
60327 +#endif
60328 +
60329 +#ifdef SIZE_OVERFLOW_PLUGIN
60330 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
60331 +#endif
60332 +
60333 /*
60334 * Mark a position in code as unreachable. This can be used to
60335 * suppress control flow warnings after asm blocks that transfer
60336 @@ -47,6 +57,11 @@
60337 #define __noclone __attribute__((__noclone__))
60338
60339 #endif
60340 +
60341 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
60342 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
60343 +#define __bos0(ptr) __bos((ptr), 0)
60344 +#define __bos1(ptr) __bos((ptr), 1)
60345 #endif
60346
60347 #if __GNUC_MINOR__ > 0
60348 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
60349 index 4a24354..7149ac2 100644
60350 --- a/include/linux/compiler.h
60351 +++ b/include/linux/compiler.h
60352 @@ -5,31 +5,62 @@
60353
60354 #ifdef __CHECKER__
60355 # define __user __attribute__((noderef, address_space(1)))
60356 +# define __force_user __force __user
60357 # define __kernel __attribute__((address_space(0)))
60358 +# define __force_kernel __force __kernel
60359 # define __safe __attribute__((safe))
60360 # define __force __attribute__((force))
60361 # define __nocast __attribute__((nocast))
60362 # define __iomem __attribute__((noderef, address_space(2)))
60363 +# define __force_iomem __force __iomem
60364 # define __acquires(x) __attribute__((context(x,0,1)))
60365 # define __releases(x) __attribute__((context(x,1,0)))
60366 # define __acquire(x) __context__(x,1)
60367 # define __release(x) __context__(x,-1)
60368 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
60369 # define __percpu __attribute__((noderef, address_space(3)))
60370 +# define __force_percpu __force __percpu
60371 #ifdef CONFIG_SPARSE_RCU_POINTER
60372 # define __rcu __attribute__((noderef, address_space(4)))
60373 +# define __force_rcu __force __rcu
60374 #else
60375 # define __rcu
60376 +# define __force_rcu
60377 #endif
60378 extern void __chk_user_ptr(const volatile void __user *);
60379 extern void __chk_io_ptr(const volatile void __iomem *);
60380 +#elif defined(CHECKER_PLUGIN)
60381 +//# define __user
60382 +//# define __force_user
60383 +//# define __kernel
60384 +//# define __force_kernel
60385 +# define __safe
60386 +# define __force
60387 +# define __nocast
60388 +# define __iomem
60389 +# define __force_iomem
60390 +# define __chk_user_ptr(x) (void)0
60391 +# define __chk_io_ptr(x) (void)0
60392 +# define __builtin_warning(x, y...) (1)
60393 +# define __acquires(x)
60394 +# define __releases(x)
60395 +# define __acquire(x) (void)0
60396 +# define __release(x) (void)0
60397 +# define __cond_lock(x,c) (c)
60398 +# define __percpu
60399 +# define __force_percpu
60400 +# define __rcu
60401 +# define __force_rcu
60402 #else
60403 # define __user
60404 +# define __force_user
60405 # define __kernel
60406 +# define __force_kernel
60407 # define __safe
60408 # define __force
60409 # define __nocast
60410 # define __iomem
60411 +# define __force_iomem
60412 # define __chk_user_ptr(x) (void)0
60413 # define __chk_io_ptr(x) (void)0
60414 # define __builtin_warning(x, y...) (1)
60415 @@ -39,7 +70,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
60416 # define __release(x) (void)0
60417 # define __cond_lock(x,c) (c)
60418 # define __percpu
60419 +# define __force_percpu
60420 # define __rcu
60421 +# define __force_rcu
60422 #endif
60423
60424 #ifdef __KERNEL__
60425 @@ -264,6 +297,18 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
60426 # define __attribute_const__ /* unimplemented */
60427 #endif
60428
60429 +#ifndef __no_const
60430 +# define __no_const
60431 +#endif
60432 +
60433 +#ifndef __do_const
60434 +# define __do_const
60435 +#endif
60436 +
60437 +#ifndef __size_overflow
60438 +# define __size_overflow(...)
60439 +#endif
60440 +
60441 /*
60442 * Tell gcc if a function is cold. The compiler will assume any path
60443 * directly leading to the call is unlikely.
60444 @@ -273,6 +318,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
60445 #define __cold
60446 #endif
60447
60448 +#ifndef __alloc_size
60449 +#define __alloc_size(...)
60450 +#endif
60451 +
60452 +#ifndef __bos
60453 +#define __bos(ptr, arg)
60454 +#endif
60455 +
60456 +#ifndef __bos0
60457 +#define __bos0(ptr)
60458 +#endif
60459 +
60460 +#ifndef __bos1
60461 +#define __bos1(ptr)
60462 +#endif
60463 +
60464 /* Simple shorthand for a section definition */
60465 #ifndef __section
60466 # define __section(S) __attribute__ ((__section__(#S)))
60467 @@ -308,6 +369,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
60468 * use is to mediate communication between process-level code and irq/NMI
60469 * handlers, all running on the same CPU.
60470 */
60471 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
60472 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
60473 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
60474
60475 #endif /* __LINUX_COMPILER_H */
60476 diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
60477 index e9eaec5..bfeb9bb 100644
60478 --- a/include/linux/cpuset.h
60479 +++ b/include/linux/cpuset.h
60480 @@ -118,7 +118,7 @@ static inline void put_mems_allowed(void)
60481 * nodemask.
60482 */
60483 smp_mb();
60484 - --ACCESS_ONCE(current->mems_allowed_change_disable);
60485 + --ACCESS_ONCE_RW(current->mems_allowed_change_disable);
60486 }
60487
60488 static inline void set_mems_allowed(nodemask_t nodemask)
60489 diff --git a/include/linux/cred.h b/include/linux/cred.h
60490 index adadf71..6af5560 100644
60491 --- a/include/linux/cred.h
60492 +++ b/include/linux/cred.h
60493 @@ -207,6 +207,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
60494 static inline void validate_process_creds(void)
60495 {
60496 }
60497 +static inline void validate_task_creds(struct task_struct *task)
60498 +{
60499 +}
60500 #endif
60501
60502 /**
60503 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
60504 index 8a94217..15d49e3 100644
60505 --- a/include/linux/crypto.h
60506 +++ b/include/linux/crypto.h
60507 @@ -365,7 +365,7 @@ struct cipher_tfm {
60508 const u8 *key, unsigned int keylen);
60509 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
60510 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
60511 -};
60512 +} __no_const;
60513
60514 struct hash_tfm {
60515 int (*init)(struct hash_desc *desc);
60516 @@ -386,13 +386,13 @@ struct compress_tfm {
60517 int (*cot_decompress)(struct crypto_tfm *tfm,
60518 const u8 *src, unsigned int slen,
60519 u8 *dst, unsigned int *dlen);
60520 -};
60521 +} __no_const;
60522
60523 struct rng_tfm {
60524 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
60525 unsigned int dlen);
60526 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
60527 -};
60528 +} __no_const;
60529
60530 #define crt_ablkcipher crt_u.ablkcipher
60531 #define crt_aead crt_u.aead
60532 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
60533 index 7925bf0..d5143d2 100644
60534 --- a/include/linux/decompress/mm.h
60535 +++ b/include/linux/decompress/mm.h
60536 @@ -77,7 +77,7 @@ static void free(void *where)
60537 * warnings when not needed (indeed large_malloc / large_free are not
60538 * needed by inflate */
60539
60540 -#define malloc(a) kmalloc(a, GFP_KERNEL)
60541 +#define malloc(a) kmalloc((a), GFP_KERNEL)
60542 #define free(a) kfree(a)
60543
60544 #define large_malloc(a) vmalloc(a)
60545 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
60546 index e13117c..e9fc938 100644
60547 --- a/include/linux/dma-mapping.h
60548 +++ b/include/linux/dma-mapping.h
60549 @@ -46,7 +46,7 @@ struct dma_map_ops {
60550 u64 (*get_required_mask)(struct device *dev);
60551 #endif
60552 int is_phys;
60553 -};
60554 +} __do_const;
60555
60556 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
60557
60558 diff --git a/include/linux/efi.h b/include/linux/efi.h
60559 index 7cce0ea..c2085e4 100644
60560 --- a/include/linux/efi.h
60561 +++ b/include/linux/efi.h
60562 @@ -591,7 +591,7 @@ struct efivar_operations {
60563 efi_get_variable_t *get_variable;
60564 efi_get_next_variable_t *get_next_variable;
60565 efi_set_variable_t *set_variable;
60566 -};
60567 +} __no_const;
60568
60569 struct efivars {
60570 /*
60571 diff --git a/include/linux/elf.h b/include/linux/elf.h
60572 index 999b4f5..57753b4 100644
60573 --- a/include/linux/elf.h
60574 +++ b/include/linux/elf.h
60575 @@ -40,6 +40,17 @@ typedef __s64 Elf64_Sxword;
60576 #define PT_GNU_EH_FRAME 0x6474e550
60577
60578 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
60579 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
60580 +
60581 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
60582 +
60583 +/* Constants for the e_flags field */
60584 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
60585 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
60586 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
60587 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
60588 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
60589 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
60590
60591 /*
60592 * Extended Numbering
60593 @@ -97,6 +108,8 @@ typedef __s64 Elf64_Sxword;
60594 #define DT_DEBUG 21
60595 #define DT_TEXTREL 22
60596 #define DT_JMPREL 23
60597 +#define DT_FLAGS 30
60598 + #define DF_TEXTREL 0x00000004
60599 #define DT_ENCODING 32
60600 #define OLD_DT_LOOS 0x60000000
60601 #define DT_LOOS 0x6000000d
60602 @@ -243,6 +256,19 @@ typedef struct elf64_hdr {
60603 #define PF_W 0x2
60604 #define PF_X 0x1
60605
60606 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
60607 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
60608 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
60609 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
60610 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
60611 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
60612 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
60613 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
60614 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
60615 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
60616 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
60617 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
60618 +
60619 typedef struct elf32_phdr{
60620 Elf32_Word p_type;
60621 Elf32_Off p_offset;
60622 @@ -335,6 +361,8 @@ typedef struct elf64_shdr {
60623 #define EI_OSABI 7
60624 #define EI_PAD 8
60625
60626 +#define EI_PAX 14
60627 +
60628 #define ELFMAG0 0x7f /* EI_MAG */
60629 #define ELFMAG1 'E'
60630 #define ELFMAG2 'L'
60631 @@ -421,6 +449,7 @@ extern Elf32_Dyn _DYNAMIC [];
60632 #define elf_note elf32_note
60633 #define elf_addr_t Elf32_Off
60634 #define Elf_Half Elf32_Half
60635 +#define elf_dyn Elf32_Dyn
60636
60637 #else
60638
60639 @@ -431,6 +460,7 @@ extern Elf64_Dyn _DYNAMIC [];
60640 #define elf_note elf64_note
60641 #define elf_addr_t Elf64_Off
60642 #define Elf_Half Elf64_Half
60643 +#define elf_dyn Elf64_Dyn
60644
60645 #endif
60646
60647 diff --git a/include/linux/filter.h b/include/linux/filter.h
60648 index 8eeb205..d59bfa2 100644
60649 --- a/include/linux/filter.h
60650 +++ b/include/linux/filter.h
60651 @@ -134,6 +134,7 @@ struct sock_fprog { /* Required for SO_ATTACH_FILTER. */
60652
60653 struct sk_buff;
60654 struct sock;
60655 +struct bpf_jit_work;
60656
60657 struct sk_filter
60658 {
60659 @@ -141,6 +142,9 @@ struct sk_filter
60660 unsigned int len; /* Number of filter blocks */
60661 unsigned int (*bpf_func)(const struct sk_buff *skb,
60662 const struct sock_filter *filter);
60663 +#ifdef CONFIG_BPF_JIT
60664 + struct bpf_jit_work *work;
60665 +#endif
60666 struct rcu_head rcu;
60667 struct sock_filter insns[0];
60668 };
60669 diff --git a/include/linux/firewire.h b/include/linux/firewire.h
60670 index 84ccf8e..2e9b14c 100644
60671 --- a/include/linux/firewire.h
60672 +++ b/include/linux/firewire.h
60673 @@ -428,7 +428,7 @@ struct fw_iso_context {
60674 union {
60675 fw_iso_callback_t sc;
60676 fw_iso_mc_callback_t mc;
60677 - } callback;
60678 + } __no_const callback;
60679 void *callback_data;
60680 };
60681
60682 diff --git a/include/linux/fs.h b/include/linux/fs.h
60683 index f4b6e06..d6ba573 100644
60684 --- a/include/linux/fs.h
60685 +++ b/include/linux/fs.h
60686 @@ -1628,7 +1628,8 @@ struct file_operations {
60687 int (*setlease)(struct file *, long, struct file_lock **);
60688 long (*fallocate)(struct file *file, int mode, loff_t offset,
60689 loff_t len);
60690 -};
60691 +} __do_const;
60692 +typedef struct file_operations __no_const file_operations_no_const;
60693
60694 struct inode_operations {
60695 struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *);
60696 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
60697 index 003dc0f..3c4ea97 100644
60698 --- a/include/linux/fs_struct.h
60699 +++ b/include/linux/fs_struct.h
60700 @@ -6,7 +6,7 @@
60701 #include <linux/seqlock.h>
60702
60703 struct fs_struct {
60704 - int users;
60705 + atomic_t users;
60706 spinlock_t lock;
60707 seqcount_t seq;
60708 int umask;
60709 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
60710 index ce31408..b1ad003 100644
60711 --- a/include/linux/fscache-cache.h
60712 +++ b/include/linux/fscache-cache.h
60713 @@ -102,7 +102,7 @@ struct fscache_operation {
60714 fscache_operation_release_t release;
60715 };
60716
60717 -extern atomic_t fscache_op_debug_id;
60718 +extern atomic_unchecked_t fscache_op_debug_id;
60719 extern void fscache_op_work_func(struct work_struct *work);
60720
60721 extern void fscache_enqueue_operation(struct fscache_operation *);
60722 @@ -122,7 +122,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
60723 {
60724 INIT_WORK(&op->work, fscache_op_work_func);
60725 atomic_set(&op->usage, 1);
60726 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
60727 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
60728 op->processor = processor;
60729 op->release = release;
60730 INIT_LIST_HEAD(&op->pend_link);
60731 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
60732 index 2a53f10..0187fdf 100644
60733 --- a/include/linux/fsnotify.h
60734 +++ b/include/linux/fsnotify.h
60735 @@ -314,7 +314,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
60736 */
60737 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
60738 {
60739 - return kstrdup(name, GFP_KERNEL);
60740 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
60741 }
60742
60743 /*
60744 diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
60745 index 91d0e0a3..035666b 100644
60746 --- a/include/linux/fsnotify_backend.h
60747 +++ b/include/linux/fsnotify_backend.h
60748 @@ -105,6 +105,7 @@ struct fsnotify_ops {
60749 void (*freeing_mark)(struct fsnotify_mark *mark, struct fsnotify_group *group);
60750 void (*free_event_priv)(struct fsnotify_event_private_data *priv);
60751 };
60752 +typedef struct fsnotify_ops __no_const fsnotify_ops_no_const;
60753
60754 /*
60755 * A group is a "thing" that wants to receive notification about filesystem
60756 diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
60757 index c3da42d..c70e0df 100644
60758 --- a/include/linux/ftrace_event.h
60759 +++ b/include/linux/ftrace_event.h
60760 @@ -97,7 +97,7 @@ struct trace_event_functions {
60761 trace_print_func raw;
60762 trace_print_func hex;
60763 trace_print_func binary;
60764 -};
60765 +} __no_const;
60766
60767 struct trace_event {
60768 struct hlist_node node;
60769 @@ -254,7 +254,7 @@ extern int trace_define_field(struct ftrace_event_call *call, const char *type,
60770 extern int trace_add_event_call(struct ftrace_event_call *call);
60771 extern void trace_remove_event_call(struct ftrace_event_call *call);
60772
60773 -#define is_signed_type(type) (((type)(-1)) < 0)
60774 +#define is_signed_type(type) (((type)(-1)) < (type)1)
60775
60776 int trace_set_clr_event(const char *system, const char *event, int set);
60777
60778 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
60779 index e61d319..0da8505 100644
60780 --- a/include/linux/genhd.h
60781 +++ b/include/linux/genhd.h
60782 @@ -185,7 +185,7 @@ struct gendisk {
60783 struct kobject *slave_dir;
60784
60785 struct timer_rand_state *random;
60786 - atomic_t sync_io; /* RAID */
60787 + atomic_unchecked_t sync_io; /* RAID */
60788 struct disk_events *ev;
60789 #ifdef CONFIG_BLK_DEV_INTEGRITY
60790 struct blk_integrity *integrity;
60791 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
60792 new file mode 100644
60793 index 0000000..8a130b6
60794 --- /dev/null
60795 +++ b/include/linux/gracl.h
60796 @@ -0,0 +1,319 @@
60797 +#ifndef GR_ACL_H
60798 +#define GR_ACL_H
60799 +
60800 +#include <linux/grdefs.h>
60801 +#include <linux/resource.h>
60802 +#include <linux/capability.h>
60803 +#include <linux/dcache.h>
60804 +#include <asm/resource.h>
60805 +
60806 +/* Major status information */
60807 +
60808 +#define GR_VERSION "grsecurity 2.9"
60809 +#define GRSECURITY_VERSION 0x2900
60810 +
60811 +enum {
60812 + GR_SHUTDOWN = 0,
60813 + GR_ENABLE = 1,
60814 + GR_SPROLE = 2,
60815 + GR_RELOAD = 3,
60816 + GR_SEGVMOD = 4,
60817 + GR_STATUS = 5,
60818 + GR_UNSPROLE = 6,
60819 + GR_PASSSET = 7,
60820 + GR_SPROLEPAM = 8,
60821 +};
60822 +
60823 +/* Password setup definitions
60824 + * kernel/grhash.c */
60825 +enum {
60826 + GR_PW_LEN = 128,
60827 + GR_SALT_LEN = 16,
60828 + GR_SHA_LEN = 32,
60829 +};
60830 +
60831 +enum {
60832 + GR_SPROLE_LEN = 64,
60833 +};
60834 +
60835 +enum {
60836 + GR_NO_GLOB = 0,
60837 + GR_REG_GLOB,
60838 + GR_CREATE_GLOB
60839 +};
60840 +
60841 +#define GR_NLIMITS 32
60842 +
60843 +/* Begin Data Structures */
60844 +
60845 +struct sprole_pw {
60846 + unsigned char *rolename;
60847 + unsigned char salt[GR_SALT_LEN];
60848 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
60849 +};
60850 +
60851 +struct name_entry {
60852 + __u32 key;
60853 + ino_t inode;
60854 + dev_t device;
60855 + char *name;
60856 + __u16 len;
60857 + __u8 deleted;
60858 + struct name_entry *prev;
60859 + struct name_entry *next;
60860 +};
60861 +
60862 +struct inodev_entry {
60863 + struct name_entry *nentry;
60864 + struct inodev_entry *prev;
60865 + struct inodev_entry *next;
60866 +};
60867 +
60868 +struct acl_role_db {
60869 + struct acl_role_label **r_hash;
60870 + __u32 r_size;
60871 +};
60872 +
60873 +struct inodev_db {
60874 + struct inodev_entry **i_hash;
60875 + __u32 i_size;
60876 +};
60877 +
60878 +struct name_db {
60879 + struct name_entry **n_hash;
60880 + __u32 n_size;
60881 +};
60882 +
60883 +struct crash_uid {
60884 + uid_t uid;
60885 + unsigned long expires;
60886 +};
60887 +
60888 +struct gr_hash_struct {
60889 + void **table;
60890 + void **nametable;
60891 + void *first;
60892 + __u32 table_size;
60893 + __u32 used_size;
60894 + int type;
60895 +};
60896 +
60897 +/* Userspace Grsecurity ACL data structures */
60898 +
60899 +struct acl_subject_label {
60900 + char *filename;
60901 + ino_t inode;
60902 + dev_t device;
60903 + __u32 mode;
60904 + kernel_cap_t cap_mask;
60905 + kernel_cap_t cap_lower;
60906 + kernel_cap_t cap_invert_audit;
60907 +
60908 + struct rlimit res[GR_NLIMITS];
60909 + __u32 resmask;
60910 +
60911 + __u8 user_trans_type;
60912 + __u8 group_trans_type;
60913 + uid_t *user_transitions;
60914 + gid_t *group_transitions;
60915 + __u16 user_trans_num;
60916 + __u16 group_trans_num;
60917 +
60918 + __u32 sock_families[2];
60919 + __u32 ip_proto[8];
60920 + __u32 ip_type;
60921 + struct acl_ip_label **ips;
60922 + __u32 ip_num;
60923 + __u32 inaddr_any_override;
60924 +
60925 + __u32 crashes;
60926 + unsigned long expires;
60927 +
60928 + struct acl_subject_label *parent_subject;
60929 + struct gr_hash_struct *hash;
60930 + struct acl_subject_label *prev;
60931 + struct acl_subject_label *next;
60932 +
60933 + struct acl_object_label **obj_hash;
60934 + __u32 obj_hash_size;
60935 + __u16 pax_flags;
60936 +};
60937 +
60938 +struct role_allowed_ip {
60939 + __u32 addr;
60940 + __u32 netmask;
60941 +
60942 + struct role_allowed_ip *prev;
60943 + struct role_allowed_ip *next;
60944 +};
60945 +
60946 +struct role_transition {
60947 + char *rolename;
60948 +
60949 + struct role_transition *prev;
60950 + struct role_transition *next;
60951 +};
60952 +
60953 +struct acl_role_label {
60954 + char *rolename;
60955 + uid_t uidgid;
60956 + __u16 roletype;
60957 +
60958 + __u16 auth_attempts;
60959 + unsigned long expires;
60960 +
60961 + struct acl_subject_label *root_label;
60962 + struct gr_hash_struct *hash;
60963 +
60964 + struct acl_role_label *prev;
60965 + struct acl_role_label *next;
60966 +
60967 + struct role_transition *transitions;
60968 + struct role_allowed_ip *allowed_ips;
60969 + uid_t *domain_children;
60970 + __u16 domain_child_num;
60971 +
60972 + umode_t umask;
60973 +
60974 + struct acl_subject_label **subj_hash;
60975 + __u32 subj_hash_size;
60976 +};
60977 +
60978 +struct user_acl_role_db {
60979 + struct acl_role_label **r_table;
60980 + __u32 num_pointers; /* Number of allocations to track */
60981 + __u32 num_roles; /* Number of roles */
60982 + __u32 num_domain_children; /* Number of domain children */
60983 + __u32 num_subjects; /* Number of subjects */
60984 + __u32 num_objects; /* Number of objects */
60985 +};
60986 +
60987 +struct acl_object_label {
60988 + char *filename;
60989 + ino_t inode;
60990 + dev_t device;
60991 + __u32 mode;
60992 +
60993 + struct acl_subject_label *nested;
60994 + struct acl_object_label *globbed;
60995 +
60996 + /* next two structures not used */
60997 +
60998 + struct acl_object_label *prev;
60999 + struct acl_object_label *next;
61000 +};
61001 +
61002 +struct acl_ip_label {
61003 + char *iface;
61004 + __u32 addr;
61005 + __u32 netmask;
61006 + __u16 low, high;
61007 + __u8 mode;
61008 + __u32 type;
61009 + __u32 proto[8];
61010 +
61011 + /* next two structures not used */
61012 +
61013 + struct acl_ip_label *prev;
61014 + struct acl_ip_label *next;
61015 +};
61016 +
61017 +struct gr_arg {
61018 + struct user_acl_role_db role_db;
61019 + unsigned char pw[GR_PW_LEN];
61020 + unsigned char salt[GR_SALT_LEN];
61021 + unsigned char sum[GR_SHA_LEN];
61022 + unsigned char sp_role[GR_SPROLE_LEN];
61023 + struct sprole_pw *sprole_pws;
61024 + dev_t segv_device;
61025 + ino_t segv_inode;
61026 + uid_t segv_uid;
61027 + __u16 num_sprole_pws;
61028 + __u16 mode;
61029 +};
61030 +
61031 +struct gr_arg_wrapper {
61032 + struct gr_arg *arg;
61033 + __u32 version;
61034 + __u32 size;
61035 +};
61036 +
61037 +struct subject_map {
61038 + struct acl_subject_label *user;
61039 + struct acl_subject_label *kernel;
61040 + struct subject_map *prev;
61041 + struct subject_map *next;
61042 +};
61043 +
61044 +struct acl_subj_map_db {
61045 + struct subject_map **s_hash;
61046 + __u32 s_size;
61047 +};
61048 +
61049 +/* End Data Structures Section */
61050 +
61051 +/* Hash functions generated by empirical testing by Brad Spengler
61052 + Makes good use of the low bits of the inode. Generally 0-1 times
61053 + in loop for successful match. 0-3 for unsuccessful match.
61054 + Shift/add algorithm with modulus of table size and an XOR*/
61055 +
61056 +static __inline__ unsigned int
61057 +rhash(const uid_t uid, const __u16 type, const unsigned int sz)
61058 +{
61059 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
61060 +}
61061 +
61062 + static __inline__ unsigned int
61063 +shash(const struct acl_subject_label *userp, const unsigned int sz)
61064 +{
61065 + return ((const unsigned long)userp % sz);
61066 +}
61067 +
61068 +static __inline__ unsigned int
61069 +fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
61070 +{
61071 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
61072 +}
61073 +
61074 +static __inline__ unsigned int
61075 +nhash(const char *name, const __u16 len, const unsigned int sz)
61076 +{
61077 + return full_name_hash((const unsigned char *)name, len) % sz;
61078 +}
61079 +
61080 +#define FOR_EACH_ROLE_START(role) \
61081 + role = role_list; \
61082 + while (role) {
61083 +
61084 +#define FOR_EACH_ROLE_END(role) \
61085 + role = role->prev; \
61086 + }
61087 +
61088 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
61089 + subj = NULL; \
61090 + iter = 0; \
61091 + while (iter < role->subj_hash_size) { \
61092 + if (subj == NULL) \
61093 + subj = role->subj_hash[iter]; \
61094 + if (subj == NULL) { \
61095 + iter++; \
61096 + continue; \
61097 + }
61098 +
61099 +#define FOR_EACH_SUBJECT_END(subj,iter) \
61100 + subj = subj->next; \
61101 + if (subj == NULL) \
61102 + iter++; \
61103 + }
61104 +
61105 +
61106 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
61107 + subj = role->hash->first; \
61108 + while (subj != NULL) {
61109 +
61110 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
61111 + subj = subj->next; \
61112 + }
61113 +
61114 +#endif
61115 +
61116 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
61117 new file mode 100644
61118 index 0000000..323ecf2
61119 --- /dev/null
61120 +++ b/include/linux/gralloc.h
61121 @@ -0,0 +1,9 @@
61122 +#ifndef __GRALLOC_H
61123 +#define __GRALLOC_H
61124 +
61125 +void acl_free_all(void);
61126 +int acl_alloc_stack_init(unsigned long size);
61127 +void *acl_alloc(unsigned long len);
61128 +void *acl_alloc_num(unsigned long num, unsigned long len);
61129 +
61130 +#endif
61131 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
61132 new file mode 100644
61133 index 0000000..b30e9bc
61134 --- /dev/null
61135 +++ b/include/linux/grdefs.h
61136 @@ -0,0 +1,140 @@
61137 +#ifndef GRDEFS_H
61138 +#define GRDEFS_H
61139 +
61140 +/* Begin grsecurity status declarations */
61141 +
61142 +enum {
61143 + GR_READY = 0x01,
61144 + GR_STATUS_INIT = 0x00 // disabled state
61145 +};
61146 +
61147 +/* Begin ACL declarations */
61148 +
61149 +/* Role flags */
61150 +
61151 +enum {
61152 + GR_ROLE_USER = 0x0001,
61153 + GR_ROLE_GROUP = 0x0002,
61154 + GR_ROLE_DEFAULT = 0x0004,
61155 + GR_ROLE_SPECIAL = 0x0008,
61156 + GR_ROLE_AUTH = 0x0010,
61157 + GR_ROLE_NOPW = 0x0020,
61158 + GR_ROLE_GOD = 0x0040,
61159 + GR_ROLE_LEARN = 0x0080,
61160 + GR_ROLE_TPE = 0x0100,
61161 + GR_ROLE_DOMAIN = 0x0200,
61162 + GR_ROLE_PAM = 0x0400,
61163 + GR_ROLE_PERSIST = 0x0800
61164 +};
61165 +
61166 +/* ACL Subject and Object mode flags */
61167 +enum {
61168 + GR_DELETED = 0x80000000
61169 +};
61170 +
61171 +/* ACL Object-only mode flags */
61172 +enum {
61173 + GR_READ = 0x00000001,
61174 + GR_APPEND = 0x00000002,
61175 + GR_WRITE = 0x00000004,
61176 + GR_EXEC = 0x00000008,
61177 + GR_FIND = 0x00000010,
61178 + GR_INHERIT = 0x00000020,
61179 + GR_SETID = 0x00000040,
61180 + GR_CREATE = 0x00000080,
61181 + GR_DELETE = 0x00000100,
61182 + GR_LINK = 0x00000200,
61183 + GR_AUDIT_READ = 0x00000400,
61184 + GR_AUDIT_APPEND = 0x00000800,
61185 + GR_AUDIT_WRITE = 0x00001000,
61186 + GR_AUDIT_EXEC = 0x00002000,
61187 + GR_AUDIT_FIND = 0x00004000,
61188 + GR_AUDIT_INHERIT= 0x00008000,
61189 + GR_AUDIT_SETID = 0x00010000,
61190 + GR_AUDIT_CREATE = 0x00020000,
61191 + GR_AUDIT_DELETE = 0x00040000,
61192 + GR_AUDIT_LINK = 0x00080000,
61193 + GR_PTRACERD = 0x00100000,
61194 + GR_NOPTRACE = 0x00200000,
61195 + GR_SUPPRESS = 0x00400000,
61196 + GR_NOLEARN = 0x00800000,
61197 + GR_INIT_TRANSFER= 0x01000000
61198 +};
61199 +
61200 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
61201 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
61202 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
61203 +
61204 +/* ACL subject-only mode flags */
61205 +enum {
61206 + GR_KILL = 0x00000001,
61207 + GR_VIEW = 0x00000002,
61208 + GR_PROTECTED = 0x00000004,
61209 + GR_LEARN = 0x00000008,
61210 + GR_OVERRIDE = 0x00000010,
61211 + /* just a placeholder, this mode is only used in userspace */
61212 + GR_DUMMY = 0x00000020,
61213 + GR_PROTSHM = 0x00000040,
61214 + GR_KILLPROC = 0x00000080,
61215 + GR_KILLIPPROC = 0x00000100,
61216 + /* just a placeholder, this mode is only used in userspace */
61217 + GR_NOTROJAN = 0x00000200,
61218 + GR_PROTPROCFD = 0x00000400,
61219 + GR_PROCACCT = 0x00000800,
61220 + GR_RELAXPTRACE = 0x00001000,
61221 + GR_NESTED = 0x00002000,
61222 + GR_INHERITLEARN = 0x00004000,
61223 + GR_PROCFIND = 0x00008000,
61224 + GR_POVERRIDE = 0x00010000,
61225 + GR_KERNELAUTH = 0x00020000,
61226 + GR_ATSECURE = 0x00040000,
61227 + GR_SHMEXEC = 0x00080000
61228 +};
61229 +
61230 +enum {
61231 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
61232 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
61233 + GR_PAX_ENABLE_MPROTECT = 0x0004,
61234 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
61235 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
61236 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
61237 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
61238 + GR_PAX_DISABLE_MPROTECT = 0x0400,
61239 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
61240 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
61241 +};
61242 +
61243 +enum {
61244 + GR_ID_USER = 0x01,
61245 + GR_ID_GROUP = 0x02,
61246 +};
61247 +
61248 +enum {
61249 + GR_ID_ALLOW = 0x01,
61250 + GR_ID_DENY = 0x02,
61251 +};
61252 +
61253 +#define GR_CRASH_RES 31
61254 +#define GR_UIDTABLE_MAX 500
61255 +
61256 +/* begin resource learning section */
61257 +enum {
61258 + GR_RLIM_CPU_BUMP = 60,
61259 + GR_RLIM_FSIZE_BUMP = 50000,
61260 + GR_RLIM_DATA_BUMP = 10000,
61261 + GR_RLIM_STACK_BUMP = 1000,
61262 + GR_RLIM_CORE_BUMP = 10000,
61263 + GR_RLIM_RSS_BUMP = 500000,
61264 + GR_RLIM_NPROC_BUMP = 1,
61265 + GR_RLIM_NOFILE_BUMP = 5,
61266 + GR_RLIM_MEMLOCK_BUMP = 50000,
61267 + GR_RLIM_AS_BUMP = 500000,
61268 + GR_RLIM_LOCKS_BUMP = 2,
61269 + GR_RLIM_SIGPENDING_BUMP = 5,
61270 + GR_RLIM_MSGQUEUE_BUMP = 10000,
61271 + GR_RLIM_NICE_BUMP = 1,
61272 + GR_RLIM_RTPRIO_BUMP = 1,
61273 + GR_RLIM_RTTIME_BUMP = 1000000
61274 +};
61275 +
61276 +#endif
61277 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
61278 new file mode 100644
61279 index 0000000..da390f1
61280 --- /dev/null
61281 +++ b/include/linux/grinternal.h
61282 @@ -0,0 +1,221 @@
61283 +#ifndef __GRINTERNAL_H
61284 +#define __GRINTERNAL_H
61285 +
61286 +#ifdef CONFIG_GRKERNSEC
61287 +
61288 +#include <linux/fs.h>
61289 +#include <linux/mnt_namespace.h>
61290 +#include <linux/nsproxy.h>
61291 +#include <linux/gracl.h>
61292 +#include <linux/grdefs.h>
61293 +#include <linux/grmsg.h>
61294 +
61295 +void gr_add_learn_entry(const char *fmt, ...)
61296 + __attribute__ ((format (printf, 1, 2)));
61297 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
61298 + const struct vfsmount *mnt);
61299 +__u32 gr_check_create(const struct dentry *new_dentry,
61300 + const struct dentry *parent,
61301 + const struct vfsmount *mnt, const __u32 mode);
61302 +int gr_check_protected_task(const struct task_struct *task);
61303 +__u32 to_gr_audit(const __u32 reqmode);
61304 +int gr_set_acls(const int type);
61305 +int gr_apply_subject_to_task(struct task_struct *task);
61306 +int gr_acl_is_enabled(void);
61307 +char gr_roletype_to_char(void);
61308 +
61309 +void gr_handle_alertkill(struct task_struct *task);
61310 +char *gr_to_filename(const struct dentry *dentry,
61311 + const struct vfsmount *mnt);
61312 +char *gr_to_filename1(const struct dentry *dentry,
61313 + const struct vfsmount *mnt);
61314 +char *gr_to_filename2(const struct dentry *dentry,
61315 + const struct vfsmount *mnt);
61316 +char *gr_to_filename3(const struct dentry *dentry,
61317 + const struct vfsmount *mnt);
61318 +
61319 +extern int grsec_enable_ptrace_readexec;
61320 +extern int grsec_enable_harden_ptrace;
61321 +extern int grsec_enable_link;
61322 +extern int grsec_enable_fifo;
61323 +extern int grsec_enable_execve;
61324 +extern int grsec_enable_shm;
61325 +extern int grsec_enable_execlog;
61326 +extern int grsec_enable_signal;
61327 +extern int grsec_enable_audit_ptrace;
61328 +extern int grsec_enable_forkfail;
61329 +extern int grsec_enable_time;
61330 +extern int grsec_enable_rofs;
61331 +extern int grsec_enable_chroot_shmat;
61332 +extern int grsec_enable_chroot_mount;
61333 +extern int grsec_enable_chroot_double;
61334 +extern int grsec_enable_chroot_pivot;
61335 +extern int grsec_enable_chroot_chdir;
61336 +extern int grsec_enable_chroot_chmod;
61337 +extern int grsec_enable_chroot_mknod;
61338 +extern int grsec_enable_chroot_fchdir;
61339 +extern int grsec_enable_chroot_nice;
61340 +extern int grsec_enable_chroot_execlog;
61341 +extern int grsec_enable_chroot_caps;
61342 +extern int grsec_enable_chroot_sysctl;
61343 +extern int grsec_enable_chroot_unix;
61344 +extern int grsec_enable_tpe;
61345 +extern int grsec_tpe_gid;
61346 +extern int grsec_enable_tpe_all;
61347 +extern int grsec_enable_tpe_invert;
61348 +extern int grsec_enable_socket_all;
61349 +extern int grsec_socket_all_gid;
61350 +extern int grsec_enable_socket_client;
61351 +extern int grsec_socket_client_gid;
61352 +extern int grsec_enable_socket_server;
61353 +extern int grsec_socket_server_gid;
61354 +extern int grsec_audit_gid;
61355 +extern int grsec_enable_group;
61356 +extern int grsec_enable_audit_textrel;
61357 +extern int grsec_enable_log_rwxmaps;
61358 +extern int grsec_enable_mount;
61359 +extern int grsec_enable_chdir;
61360 +extern int grsec_resource_logging;
61361 +extern int grsec_enable_blackhole;
61362 +extern int grsec_lastack_retries;
61363 +extern int grsec_enable_brute;
61364 +extern int grsec_lock;
61365 +
61366 +extern spinlock_t grsec_alert_lock;
61367 +extern unsigned long grsec_alert_wtime;
61368 +extern unsigned long grsec_alert_fyet;
61369 +
61370 +extern spinlock_t grsec_audit_lock;
61371 +
61372 +extern rwlock_t grsec_exec_file_lock;
61373 +
61374 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
61375 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
61376 + (tsk)->exec_file->f_vfsmnt) : "/")
61377 +
61378 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
61379 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
61380 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
61381 +
61382 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
61383 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
61384 + (tsk)->exec_file->f_vfsmnt) : "/")
61385 +
61386 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
61387 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
61388 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
61389 +
61390 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
61391 +
61392 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
61393 +
61394 +#define DEFAULTSECARGS(task, cred, pcred) gr_task_fullpath(task), (task)->comm, \
61395 + (task)->pid, (cred)->uid, \
61396 + (cred)->euid, (cred)->gid, (cred)->egid, \
61397 + gr_parent_task_fullpath(task), \
61398 + (task)->real_parent->comm, (task)->real_parent->pid, \
61399 + (pcred)->uid, (pcred)->euid, \
61400 + (pcred)->gid, (pcred)->egid
61401 +
61402 +#define GR_CHROOT_CAPS {{ \
61403 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
61404 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
61405 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
61406 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
61407 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
61408 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
61409 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
61410 +
61411 +#define security_learn(normal_msg,args...) \
61412 +({ \
61413 + read_lock(&grsec_exec_file_lock); \
61414 + gr_add_learn_entry(normal_msg "\n", ## args); \
61415 + read_unlock(&grsec_exec_file_lock); \
61416 +})
61417 +
61418 +enum {
61419 + GR_DO_AUDIT,
61420 + GR_DONT_AUDIT,
61421 + /* used for non-audit messages that we shouldn't kill the task on */
61422 + GR_DONT_AUDIT_GOOD
61423 +};
61424 +
61425 +enum {
61426 + GR_TTYSNIFF,
61427 + GR_RBAC,
61428 + GR_RBAC_STR,
61429 + GR_STR_RBAC,
61430 + GR_RBAC_MODE2,
61431 + GR_RBAC_MODE3,
61432 + GR_FILENAME,
61433 + GR_SYSCTL_HIDDEN,
61434 + GR_NOARGS,
61435 + GR_ONE_INT,
61436 + GR_ONE_INT_TWO_STR,
61437 + GR_ONE_STR,
61438 + GR_STR_INT,
61439 + GR_TWO_STR_INT,
61440 + GR_TWO_INT,
61441 + GR_TWO_U64,
61442 + GR_THREE_INT,
61443 + GR_FIVE_INT_TWO_STR,
61444 + GR_TWO_STR,
61445 + GR_THREE_STR,
61446 + GR_FOUR_STR,
61447 + GR_STR_FILENAME,
61448 + GR_FILENAME_STR,
61449 + GR_FILENAME_TWO_INT,
61450 + GR_FILENAME_TWO_INT_STR,
61451 + GR_TEXTREL,
61452 + GR_PTRACE,
61453 + GR_RESOURCE,
61454 + GR_CAP,
61455 + GR_SIG,
61456 + GR_SIG2,
61457 + GR_CRASH1,
61458 + GR_CRASH2,
61459 + GR_PSACCT,
61460 + GR_RWXMAP
61461 +};
61462 +
61463 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
61464 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
61465 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
61466 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
61467 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
61468 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
61469 +#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)
61470 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
61471 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
61472 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
61473 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
61474 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
61475 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
61476 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
61477 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
61478 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
61479 +#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)
61480 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
61481 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
61482 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
61483 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
61484 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
61485 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
61486 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
61487 +#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)
61488 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
61489 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
61490 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
61491 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
61492 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
61493 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
61494 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
61495 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
61496 +#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)
61497 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
61498 +
61499 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
61500 +
61501 +#endif
61502 +
61503 +#endif
61504 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
61505 new file mode 100644
61506 index 0000000..ae576a1
61507 --- /dev/null
61508 +++ b/include/linux/grmsg.h
61509 @@ -0,0 +1,109 @@
61510 +#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"
61511 +#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"
61512 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
61513 +#define GR_STOPMOD_MSG "denied modification of module state by "
61514 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
61515 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
61516 +#define GR_IOPERM_MSG "denied use of ioperm() by "
61517 +#define GR_IOPL_MSG "denied use of iopl() by "
61518 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
61519 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
61520 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
61521 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
61522 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
61523 +#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"
61524 +#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"
61525 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
61526 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
61527 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
61528 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
61529 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
61530 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
61531 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
61532 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
61533 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
61534 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
61535 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
61536 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
61537 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
61538 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
61539 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
61540 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
61541 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
61542 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
61543 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
61544 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
61545 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
61546 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
61547 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
61548 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
61549 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
61550 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
61551 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
61552 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
61553 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
61554 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
61555 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
61556 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
61557 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
61558 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
61559 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
61560 +#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"
61561 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
61562 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
61563 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
61564 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
61565 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
61566 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
61567 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
61568 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
61569 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
61570 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
61571 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
61572 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
61573 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
61574 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
61575 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
61576 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
61577 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
61578 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
61579 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
61580 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
61581 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
61582 +#define GR_NICE_CHROOT_MSG "denied priority change by "
61583 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
61584 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
61585 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
61586 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
61587 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
61588 +#define GR_TIME_MSG "time set by "
61589 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
61590 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
61591 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
61592 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
61593 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
61594 +#define GR_BIND_MSG "denied bind() by "
61595 +#define GR_CONNECT_MSG "denied connect() by "
61596 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
61597 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
61598 +#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"
61599 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
61600 +#define GR_CAP_ACL_MSG "use of %s denied for "
61601 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
61602 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
61603 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
61604 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
61605 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
61606 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
61607 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
61608 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
61609 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
61610 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
61611 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
61612 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
61613 +#define GR_TEXTREL_AUDIT_MSG "text relocation in %s, VMA:0x%08lx 0x%08lx by "
61614 +#define GR_VM86_MSG "denied use of vm86 by "
61615 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
61616 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
61617 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
61618 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
61619 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
61620 new file mode 100644
61621 index 0000000..acd05db
61622 --- /dev/null
61623 +++ b/include/linux/grsecurity.h
61624 @@ -0,0 +1,232 @@
61625 +#ifndef GR_SECURITY_H
61626 +#define GR_SECURITY_H
61627 +#include <linux/fs.h>
61628 +#include <linux/fs_struct.h>
61629 +#include <linux/binfmts.h>
61630 +#include <linux/gracl.h>
61631 +
61632 +/* notify of brain-dead configs */
61633 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61634 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
61635 +#endif
61636 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
61637 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
61638 +#endif
61639 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
61640 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
61641 +#endif
61642 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
61643 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
61644 +#endif
61645 +
61646 +#include <linux/compat.h>
61647 +
61648 +struct user_arg_ptr {
61649 +#ifdef CONFIG_COMPAT
61650 + bool is_compat;
61651 +#endif
61652 + union {
61653 + const char __user *const __user *native;
61654 +#ifdef CONFIG_COMPAT
61655 + compat_uptr_t __user *compat;
61656 +#endif
61657 + } ptr;
61658 +};
61659 +
61660 +void gr_handle_brute_attach(struct task_struct *p, unsigned long mm_flags);
61661 +void gr_handle_brute_check(void);
61662 +void gr_handle_kernel_exploit(void);
61663 +int gr_process_user_ban(void);
61664 +
61665 +char gr_roletype_to_char(void);
61666 +
61667 +int gr_acl_enable_at_secure(void);
61668 +
61669 +int gr_check_user_change(int real, int effective, int fs);
61670 +int gr_check_group_change(int real, int effective, int fs);
61671 +
61672 +void gr_del_task_from_ip_table(struct task_struct *p);
61673 +
61674 +int gr_pid_is_chrooted(struct task_struct *p);
61675 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
61676 +int gr_handle_chroot_nice(void);
61677 +int gr_handle_chroot_sysctl(const int op);
61678 +int gr_handle_chroot_setpriority(struct task_struct *p,
61679 + const int niceval);
61680 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
61681 +int gr_handle_chroot_chroot(const struct dentry *dentry,
61682 + const struct vfsmount *mnt);
61683 +void gr_handle_chroot_chdir(struct path *path);
61684 +int gr_handle_chroot_chmod(const struct dentry *dentry,
61685 + const struct vfsmount *mnt, const int mode);
61686 +int gr_handle_chroot_mknod(const struct dentry *dentry,
61687 + const struct vfsmount *mnt, const int mode);
61688 +int gr_handle_chroot_mount(const struct dentry *dentry,
61689 + const struct vfsmount *mnt,
61690 + const char *dev_name);
61691 +int gr_handle_chroot_pivot(void);
61692 +int gr_handle_chroot_unix(const pid_t pid);
61693 +
61694 +int gr_handle_rawio(const struct inode *inode);
61695 +
61696 +void gr_handle_ioperm(void);
61697 +void gr_handle_iopl(void);
61698 +
61699 +umode_t gr_acl_umask(void);
61700 +
61701 +int gr_tpe_allow(const struct file *file);
61702 +
61703 +void gr_set_chroot_entries(struct task_struct *task, struct path *path);
61704 +void gr_clear_chroot_entries(struct task_struct *task);
61705 +
61706 +void gr_log_forkfail(const int retval);
61707 +void gr_log_timechange(void);
61708 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
61709 +void gr_log_chdir(const struct dentry *dentry,
61710 + const struct vfsmount *mnt);
61711 +void gr_log_chroot_exec(const struct dentry *dentry,
61712 + const struct vfsmount *mnt);
61713 +void gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv);
61714 +void gr_log_remount(const char *devname, const int retval);
61715 +void gr_log_unmount(const char *devname, const int retval);
61716 +void gr_log_mount(const char *from, const char *to, const int retval);
61717 +void gr_log_textrel(struct vm_area_struct *vma);
61718 +void gr_log_rwxmmap(struct file *file);
61719 +void gr_log_rwxmprotect(struct file *file);
61720 +
61721 +int gr_handle_follow_link(const struct inode *parent,
61722 + const struct inode *inode,
61723 + const struct dentry *dentry,
61724 + const struct vfsmount *mnt);
61725 +int gr_handle_fifo(const struct dentry *dentry,
61726 + const struct vfsmount *mnt,
61727 + const struct dentry *dir, const int flag,
61728 + const int acc_mode);
61729 +int gr_handle_hardlink(const struct dentry *dentry,
61730 + const struct vfsmount *mnt,
61731 + struct inode *inode,
61732 + const int mode, const char *to);
61733 +
61734 +int gr_is_capable(const int cap);
61735 +int gr_is_capable_nolog(const int cap);
61736 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
61737 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
61738 +
61739 +void gr_learn_resource(const struct task_struct *task, const int limit,
61740 + const unsigned long wanted, const int gt);
61741 +void gr_copy_label(struct task_struct *tsk);
61742 +void gr_handle_crash(struct task_struct *task, const int sig);
61743 +int gr_handle_signal(const struct task_struct *p, const int sig);
61744 +int gr_check_crash_uid(const uid_t uid);
61745 +int gr_check_protected_task(const struct task_struct *task);
61746 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
61747 +int gr_acl_handle_mmap(const struct file *file,
61748 + const unsigned long prot);
61749 +int gr_acl_handle_mprotect(const struct file *file,
61750 + const unsigned long prot);
61751 +int gr_check_hidden_task(const struct task_struct *tsk);
61752 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
61753 + const struct vfsmount *mnt);
61754 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
61755 + const struct vfsmount *mnt);
61756 +__u32 gr_acl_handle_access(const struct dentry *dentry,
61757 + const struct vfsmount *mnt, const int fmode);
61758 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
61759 + const struct vfsmount *mnt, umode_t *mode);
61760 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
61761 + const struct vfsmount *mnt);
61762 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
61763 + const struct vfsmount *mnt);
61764 +int gr_handle_ptrace(struct task_struct *task, const long request);
61765 +int gr_handle_proc_ptrace(struct task_struct *task);
61766 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
61767 + const struct vfsmount *mnt);
61768 +int gr_check_crash_exec(const struct file *filp);
61769 +int gr_acl_is_enabled(void);
61770 +void gr_set_kernel_label(struct task_struct *task);
61771 +void gr_set_role_label(struct task_struct *task, const uid_t uid,
61772 + const gid_t gid);
61773 +int gr_set_proc_label(const struct dentry *dentry,
61774 + const struct vfsmount *mnt,
61775 + const int unsafe_flags);
61776 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
61777 + const struct vfsmount *mnt);
61778 +__u32 gr_acl_handle_open(const struct dentry *dentry,
61779 + const struct vfsmount *mnt, int acc_mode);
61780 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
61781 + const struct dentry *p_dentry,
61782 + const struct vfsmount *p_mnt,
61783 + int open_flags, int acc_mode, const int imode);
61784 +void gr_handle_create(const struct dentry *dentry,
61785 + const struct vfsmount *mnt);
61786 +void gr_handle_proc_create(const struct dentry *dentry,
61787 + const struct inode *inode);
61788 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
61789 + const struct dentry *parent_dentry,
61790 + const struct vfsmount *parent_mnt,
61791 + const int mode);
61792 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
61793 + const struct dentry *parent_dentry,
61794 + const struct vfsmount *parent_mnt);
61795 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
61796 + const struct vfsmount *mnt);
61797 +void gr_handle_delete(const ino_t ino, const dev_t dev);
61798 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
61799 + const struct vfsmount *mnt);
61800 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
61801 + const struct dentry *parent_dentry,
61802 + const struct vfsmount *parent_mnt,
61803 + const char *from);
61804 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
61805 + const struct dentry *parent_dentry,
61806 + const struct vfsmount *parent_mnt,
61807 + const struct dentry *old_dentry,
61808 + const struct vfsmount *old_mnt, const char *to);
61809 +int gr_acl_handle_rename(struct dentry *new_dentry,
61810 + struct dentry *parent_dentry,
61811 + const struct vfsmount *parent_mnt,
61812 + struct dentry *old_dentry,
61813 + struct inode *old_parent_inode,
61814 + struct vfsmount *old_mnt, const char *newname);
61815 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
61816 + struct dentry *old_dentry,
61817 + struct dentry *new_dentry,
61818 + struct vfsmount *mnt, const __u8 replace);
61819 +__u32 gr_check_link(const struct dentry *new_dentry,
61820 + const struct dentry *parent_dentry,
61821 + const struct vfsmount *parent_mnt,
61822 + const struct dentry *old_dentry,
61823 + const struct vfsmount *old_mnt);
61824 +int gr_acl_handle_filldir(const struct file *file, const char *name,
61825 + const unsigned int namelen, const ino_t ino);
61826 +
61827 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
61828 + const struct vfsmount *mnt);
61829 +void gr_acl_handle_exit(void);
61830 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
61831 +int gr_acl_handle_procpidmem(const struct task_struct *task);
61832 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
61833 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
61834 +void gr_audit_ptrace(struct task_struct *task);
61835 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
61836 +
61837 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
61838 +
61839 +#ifdef CONFIG_GRKERNSEC
61840 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
61841 +void gr_handle_vm86(void);
61842 +void gr_handle_mem_readwrite(u64 from, u64 to);
61843 +
61844 +void gr_log_badprocpid(const char *entry);
61845 +
61846 +extern int grsec_enable_dmesg;
61847 +extern int grsec_disable_privio;
61848 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
61849 +extern int grsec_enable_chroot_findtask;
61850 +#endif
61851 +#ifdef CONFIG_GRKERNSEC_SETXID
61852 +extern int grsec_enable_setxid;
61853 +#endif
61854 +#endif
61855 +
61856 +#endif
61857 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
61858 new file mode 100644
61859 index 0000000..e7ffaaf
61860 --- /dev/null
61861 +++ b/include/linux/grsock.h
61862 @@ -0,0 +1,19 @@
61863 +#ifndef __GRSOCK_H
61864 +#define __GRSOCK_H
61865 +
61866 +extern void gr_attach_curr_ip(const struct sock *sk);
61867 +extern int gr_handle_sock_all(const int family, const int type,
61868 + const int protocol);
61869 +extern int gr_handle_sock_server(const struct sockaddr *sck);
61870 +extern int gr_handle_sock_server_other(const struct sock *sck);
61871 +extern int gr_handle_sock_client(const struct sockaddr *sck);
61872 +extern int gr_search_connect(struct socket * sock,
61873 + struct sockaddr_in * addr);
61874 +extern int gr_search_bind(struct socket * sock,
61875 + struct sockaddr_in * addr);
61876 +extern int gr_search_listen(struct socket * sock);
61877 +extern int gr_search_accept(struct socket * sock);
61878 +extern int gr_search_socket(const int domain, const int type,
61879 + const int protocol);
61880 +
61881 +#endif
61882 diff --git a/include/linux/hid.h b/include/linux/hid.h
61883 index 3a95da6..51986f1 100644
61884 --- a/include/linux/hid.h
61885 +++ b/include/linux/hid.h
61886 @@ -696,7 +696,7 @@ struct hid_ll_driver {
61887 unsigned int code, int value);
61888
61889 int (*parse)(struct hid_device *hdev);
61890 -};
61891 +} __no_const;
61892
61893 #define PM_HINT_FULLON 1<<5
61894 #define PM_HINT_NORMAL 1<<1
61895 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
61896 index 3a93f73..b19d0b3 100644
61897 --- a/include/linux/highmem.h
61898 +++ b/include/linux/highmem.h
61899 @@ -185,6 +185,18 @@ static inline void clear_highpage(struct page *page)
61900 kunmap_atomic(kaddr, KM_USER0);
61901 }
61902
61903 +static inline void sanitize_highpage(struct page *page)
61904 +{
61905 + void *kaddr;
61906 + unsigned long flags;
61907 +
61908 + local_irq_save(flags);
61909 + kaddr = kmap_atomic(page, KM_CLEARPAGE);
61910 + clear_page(kaddr);
61911 + kunmap_atomic(kaddr, KM_CLEARPAGE);
61912 + local_irq_restore(flags);
61913 +}
61914 +
61915 static inline void zero_user_segments(struct page *page,
61916 unsigned start1, unsigned end1,
61917 unsigned start2, unsigned end2)
61918 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
61919 index 8e25a91..551b161 100644
61920 --- a/include/linux/i2c.h
61921 +++ b/include/linux/i2c.h
61922 @@ -364,6 +364,7 @@ struct i2c_algorithm {
61923 /* To determine what the adapter supports */
61924 u32 (*functionality) (struct i2c_adapter *);
61925 };
61926 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
61927
61928 /*
61929 * i2c_adapter is the structure used to identify a physical i2c bus along
61930 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
61931 index a6deef4..c56a7f2 100644
61932 --- a/include/linux/i2o.h
61933 +++ b/include/linux/i2o.h
61934 @@ -564,7 +564,7 @@ struct i2o_controller {
61935 struct i2o_device *exec; /* Executive */
61936 #if BITS_PER_LONG == 64
61937 spinlock_t context_list_lock; /* lock for context_list */
61938 - atomic_t context_list_counter; /* needed for unique contexts */
61939 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
61940 struct list_head context_list; /* list of context id's
61941 and pointers */
61942 #endif
61943 diff --git a/include/linux/if_team.h b/include/linux/if_team.h
61944 index 58404b0..439ed95 100644
61945 --- a/include/linux/if_team.h
61946 +++ b/include/linux/if_team.h
61947 @@ -64,6 +64,7 @@ struct team_mode_ops {
61948 void (*port_leave)(struct team *team, struct team_port *port);
61949 void (*port_change_mac)(struct team *team, struct team_port *port);
61950 };
61951 +typedef struct team_mode_ops __no_const team_mode_ops_no_const;
61952
61953 enum team_option_type {
61954 TEAM_OPTION_TYPE_U32,
61955 @@ -112,7 +113,7 @@ struct team {
61956 struct list_head option_list;
61957
61958 const struct team_mode *mode;
61959 - struct team_mode_ops ops;
61960 + team_mode_ops_no_const ops;
61961 long mode_priv[TEAM_MODE_PRIV_LONGS];
61962 };
61963
61964 diff --git a/include/linux/init.h b/include/linux/init.h
61965 index 6b95109..4aca62c 100644
61966 --- a/include/linux/init.h
61967 +++ b/include/linux/init.h
61968 @@ -294,13 +294,13 @@ void __init parse_early_options(char *cmdline);
61969
61970 /* Each module must use one module_init(). */
61971 #define module_init(initfn) \
61972 - static inline initcall_t __inittest(void) \
61973 + static inline __used initcall_t __inittest(void) \
61974 { return initfn; } \
61975 int init_module(void) __attribute__((alias(#initfn)));
61976
61977 /* This is only required if you want to be unloadable. */
61978 #define module_exit(exitfn) \
61979 - static inline exitcall_t __exittest(void) \
61980 + static inline __used exitcall_t __exittest(void) \
61981 { return exitfn; } \
61982 void cleanup_module(void) __attribute__((alias(#exitfn)));
61983
61984 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
61985 index 9c66b1a..a3fdded 100644
61986 --- a/include/linux/init_task.h
61987 +++ b/include/linux/init_task.h
61988 @@ -127,6 +127,12 @@ extern struct cred init_cred;
61989
61990 #define INIT_TASK_COMM "swapper"
61991
61992 +#ifdef CONFIG_X86
61993 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
61994 +#else
61995 +#define INIT_TASK_THREAD_INFO
61996 +#endif
61997 +
61998 /*
61999 * INIT_TASK is used to set up the first task table, touch at
62000 * your own risk!. Base=0, limit=0x1fffff (=2MB)
62001 @@ -165,6 +171,7 @@ extern struct cred init_cred;
62002 RCU_INIT_POINTER(.cred, &init_cred), \
62003 .comm = INIT_TASK_COMM, \
62004 .thread = INIT_THREAD, \
62005 + INIT_TASK_THREAD_INFO \
62006 .fs = &init_fs, \
62007 .files = &init_files, \
62008 .signal = &init_signals, \
62009 diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h
62010 index e6ca56d..8583707 100644
62011 --- a/include/linux/intel-iommu.h
62012 +++ b/include/linux/intel-iommu.h
62013 @@ -296,7 +296,7 @@ struct iommu_flush {
62014 u8 fm, u64 type);
62015 void (*flush_iotlb)(struct intel_iommu *iommu, u16 did, u64 addr,
62016 unsigned int size_order, u64 type);
62017 -};
62018 +} __no_const;
62019
62020 enum {
62021 SR_DMAR_FECTL_REG,
62022 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
62023 index a64b00e..464d8bc 100644
62024 --- a/include/linux/interrupt.h
62025 +++ b/include/linux/interrupt.h
62026 @@ -441,7 +441,7 @@ enum
62027 /* map softirq index to softirq name. update 'softirq_to_name' in
62028 * kernel/softirq.c when adding a new softirq.
62029 */
62030 -extern char *softirq_to_name[NR_SOFTIRQS];
62031 +extern const char * const softirq_to_name[NR_SOFTIRQS];
62032
62033 /* softirq mask and active fields moved to irq_cpustat_t in
62034 * asm/hardirq.h to get better cache usage. KAO
62035 @@ -449,12 +449,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
62036
62037 struct softirq_action
62038 {
62039 - void (*action)(struct softirq_action *);
62040 + void (*action)(void);
62041 };
62042
62043 asmlinkage void do_softirq(void);
62044 asmlinkage void __do_softirq(void);
62045 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
62046 +extern void open_softirq(int nr, void (*action)(void));
62047 extern void softirq_init(void);
62048 static inline void __raise_softirq_irqoff(unsigned int nr)
62049 {
62050 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
62051 index 3875719..4cd454c 100644
62052 --- a/include/linux/kallsyms.h
62053 +++ b/include/linux/kallsyms.h
62054 @@ -15,7 +15,8 @@
62055
62056 struct module;
62057
62058 -#ifdef CONFIG_KALLSYMS
62059 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
62060 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
62061 /* Lookup the address for a symbol. Returns 0 if not found. */
62062 unsigned long kallsyms_lookup_name(const char *name);
62063
62064 @@ -99,6 +100,16 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
62065 /* Stupid that this does nothing, but I didn't create this mess. */
62066 #define __print_symbol(fmt, addr)
62067 #endif /*CONFIG_KALLSYMS*/
62068 +#else /* when included by kallsyms.c, vsnprintf.c, or
62069 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
62070 +extern void __print_symbol(const char *fmt, unsigned long address);
62071 +extern int sprint_backtrace(char *buffer, unsigned long address);
62072 +extern int sprint_symbol(char *buffer, unsigned long address);
62073 +const char *kallsyms_lookup(unsigned long addr,
62074 + unsigned long *symbolsize,
62075 + unsigned long *offset,
62076 + char **modname, char *namebuf);
62077 +#endif
62078
62079 /* This macro allows us to keep printk typechecking */
62080 static __printf(1, 2)
62081 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
62082 index c4d2fc1..5df9c19 100644
62083 --- a/include/linux/kgdb.h
62084 +++ b/include/linux/kgdb.h
62085 @@ -53,7 +53,7 @@ extern int kgdb_connected;
62086 extern int kgdb_io_module_registered;
62087
62088 extern atomic_t kgdb_setting_breakpoint;
62089 -extern atomic_t kgdb_cpu_doing_single_step;
62090 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
62091
62092 extern struct task_struct *kgdb_usethread;
62093 extern struct task_struct *kgdb_contthread;
62094 @@ -252,7 +252,7 @@ struct kgdb_arch {
62095 void (*disable_hw_break)(struct pt_regs *regs);
62096 void (*remove_all_hw_break)(void);
62097 void (*correct_hw_break)(void);
62098 -};
62099 +} __do_const;
62100
62101 /**
62102 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
62103 @@ -277,7 +277,7 @@ struct kgdb_io {
62104 void (*pre_exception) (void);
62105 void (*post_exception) (void);
62106 int is_console;
62107 -};
62108 +} __do_const;
62109
62110 extern struct kgdb_arch arch_kgdb_ops;
62111
62112 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
62113 index 0fb48ef..1b680b2 100644
62114 --- a/include/linux/kmod.h
62115 +++ b/include/linux/kmod.h
62116 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
62117 * usually useless though. */
62118 extern __printf(2, 3)
62119 int __request_module(bool wait, const char *name, ...);
62120 +extern __printf(3, 4)
62121 +int ___request_module(bool wait, char *param_name, const char *name, ...);
62122 #define request_module(mod...) __request_module(true, mod)
62123 #define request_module_nowait(mod...) __request_module(false, mod)
62124 #define try_then_request_module(x, mod...) \
62125 diff --git a/include/linux/kref.h b/include/linux/kref.h
62126 index 9c07dce..a92fa71 100644
62127 --- a/include/linux/kref.h
62128 +++ b/include/linux/kref.h
62129 @@ -63,7 +63,7 @@ static inline void kref_get(struct kref *kref)
62130 static inline int kref_sub(struct kref *kref, unsigned int count,
62131 void (*release)(struct kref *kref))
62132 {
62133 - WARN_ON(release == NULL);
62134 + BUG_ON(release == NULL);
62135
62136 if (atomic_sub_and_test((int) count, &kref->refcount)) {
62137 release(kref);
62138 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
62139 index 4c4e83d..695674f 100644
62140 --- a/include/linux/kvm_host.h
62141 +++ b/include/linux/kvm_host.h
62142 @@ -326,7 +326,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
62143 void vcpu_load(struct kvm_vcpu *vcpu);
62144 void vcpu_put(struct kvm_vcpu *vcpu);
62145
62146 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
62147 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
62148 struct module *module);
62149 void kvm_exit(void);
62150
62151 @@ -485,7 +485,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
62152 struct kvm_guest_debug *dbg);
62153 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
62154
62155 -int kvm_arch_init(void *opaque);
62156 +int kvm_arch_init(const void *opaque);
62157 void kvm_arch_exit(void);
62158
62159 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
62160 diff --git a/include/linux/libata.h b/include/linux/libata.h
62161 index cafc09a..d7e7829 100644
62162 --- a/include/linux/libata.h
62163 +++ b/include/linux/libata.h
62164 @@ -909,7 +909,7 @@ struct ata_port_operations {
62165 * fields must be pointers.
62166 */
62167 const struct ata_port_operations *inherits;
62168 -};
62169 +} __do_const;
62170
62171 struct ata_port_info {
62172 unsigned long flags;
62173 diff --git a/include/linux/mca.h b/include/linux/mca.h
62174 index 3797270..7765ede 100644
62175 --- a/include/linux/mca.h
62176 +++ b/include/linux/mca.h
62177 @@ -80,7 +80,7 @@ struct mca_bus_accessor_functions {
62178 int region);
62179 void * (*mca_transform_memory)(struct mca_device *,
62180 void *memory);
62181 -};
62182 +} __no_const;
62183
62184 struct mca_bus {
62185 u64 default_dma_mask;
62186 diff --git a/include/linux/memory.h b/include/linux/memory.h
62187 index 1ac7f6e..a5794d0 100644
62188 --- a/include/linux/memory.h
62189 +++ b/include/linux/memory.h
62190 @@ -143,7 +143,7 @@ struct memory_accessor {
62191 size_t count);
62192 ssize_t (*write)(struct memory_accessor *, const char *buf,
62193 off_t offset, size_t count);
62194 -};
62195 +} __no_const;
62196
62197 /*
62198 * Kernel text modification mutex, used for code patching. Users of this lock
62199 diff --git a/include/linux/mfd/abx500.h b/include/linux/mfd/abx500.h
62200 index 9970337..9444122 100644
62201 --- a/include/linux/mfd/abx500.h
62202 +++ b/include/linux/mfd/abx500.h
62203 @@ -188,6 +188,7 @@ struct abx500_ops {
62204 int (*event_registers_startup_state_get) (struct device *, u8 *);
62205 int (*startup_irq_enabled) (struct device *, unsigned int);
62206 };
62207 +typedef struct abx500_ops __no_const abx500_ops_no_const;
62208
62209 int abx500_register_ops(struct device *core_dev, struct abx500_ops *ops);
62210 void abx500_remove_ops(struct device *dev);
62211 diff --git a/include/linux/mm.h b/include/linux/mm.h
62212 index 17b27cd..baea141 100644
62213 --- a/include/linux/mm.h
62214 +++ b/include/linux/mm.h
62215 @@ -115,7 +115,14 @@ extern unsigned int kobjsize(const void *objp);
62216
62217 #define VM_CAN_NONLINEAR 0x08000000 /* Has ->fault & does nonlinear pages */
62218 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
62219 +
62220 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
62221 +#define VM_SAO 0x00000000 /* Strong Access Ordering (powerpc) */
62222 +#define VM_PAGEEXEC 0x20000000 /* vma->vm_page_prot needs special handling */
62223 +#else
62224 #define VM_SAO 0x20000000 /* Strong Access Ordering (powerpc) */
62225 +#endif
62226 +
62227 #define VM_PFN_AT_MMAP 0x40000000 /* PFNMAP vma that is fully mapped at mmap time */
62228 #define VM_MERGEABLE 0x80000000 /* KSM may merge identical pages */
62229
62230 @@ -1012,34 +1019,6 @@ int set_page_dirty(struct page *page);
62231 int set_page_dirty_lock(struct page *page);
62232 int clear_page_dirty_for_io(struct page *page);
62233
62234 -/* Is the vma a continuation of the stack vma above it? */
62235 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
62236 -{
62237 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
62238 -}
62239 -
62240 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
62241 - unsigned long addr)
62242 -{
62243 - return (vma->vm_flags & VM_GROWSDOWN) &&
62244 - (vma->vm_start == addr) &&
62245 - !vma_growsdown(vma->vm_prev, addr);
62246 -}
62247 -
62248 -/* Is the vma a continuation of the stack vma below it? */
62249 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
62250 -{
62251 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
62252 -}
62253 -
62254 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
62255 - unsigned long addr)
62256 -{
62257 - return (vma->vm_flags & VM_GROWSUP) &&
62258 - (vma->vm_end == addr) &&
62259 - !vma_growsup(vma->vm_next, addr);
62260 -}
62261 -
62262 extern unsigned long move_page_tables(struct vm_area_struct *vma,
62263 unsigned long old_addr, struct vm_area_struct *new_vma,
62264 unsigned long new_addr, unsigned long len);
62265 @@ -1134,6 +1113,15 @@ static inline void sync_mm_rss(struct task_struct *task, struct mm_struct *mm)
62266 }
62267 #endif
62268
62269 +#ifdef CONFIG_MMU
62270 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
62271 +#else
62272 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
62273 +{
62274 + return __pgprot(0);
62275 +}
62276 +#endif
62277 +
62278 int vma_wants_writenotify(struct vm_area_struct *vma);
62279
62280 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
62281 @@ -1152,8 +1140,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
62282 {
62283 return 0;
62284 }
62285 +
62286 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
62287 + unsigned long address)
62288 +{
62289 + return 0;
62290 +}
62291 #else
62292 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
62293 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
62294 #endif
62295
62296 #ifdef __PAGETABLE_PMD_FOLDED
62297 @@ -1162,8 +1157,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
62298 {
62299 return 0;
62300 }
62301 +
62302 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
62303 + unsigned long address)
62304 +{
62305 + return 0;
62306 +}
62307 #else
62308 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
62309 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
62310 #endif
62311
62312 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
62313 @@ -1181,11 +1183,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
62314 NULL: pud_offset(pgd, address);
62315 }
62316
62317 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
62318 +{
62319 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
62320 + NULL: pud_offset(pgd, address);
62321 +}
62322 +
62323 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
62324 {
62325 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
62326 NULL: pmd_offset(pud, address);
62327 }
62328 +
62329 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
62330 +{
62331 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
62332 + NULL: pmd_offset(pud, address);
62333 +}
62334 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
62335
62336 #if USE_SPLIT_PTLOCKS
62337 @@ -1409,6 +1423,7 @@ out:
62338 }
62339
62340 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
62341 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
62342
62343 extern unsigned long do_brk(unsigned long, unsigned long);
62344
62345 @@ -1466,6 +1481,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
62346 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
62347 struct vm_area_struct **pprev);
62348
62349 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
62350 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
62351 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
62352 +
62353 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
62354 NULL if none. Assume start_addr < end_addr. */
62355 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
62356 @@ -1494,15 +1513,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
62357 return vma;
62358 }
62359
62360 -#ifdef CONFIG_MMU
62361 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
62362 -#else
62363 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
62364 -{
62365 - return __pgprot(0);
62366 -}
62367 -#endif
62368 -
62369 struct vm_area_struct *find_extend_vma(struct mm_struct *, unsigned long addr);
62370 int remap_pfn_range(struct vm_area_struct *, unsigned long addr,
62371 unsigned long pfn, unsigned long size, pgprot_t);
62372 @@ -1606,7 +1616,7 @@ extern int unpoison_memory(unsigned long pfn);
62373 extern int sysctl_memory_failure_early_kill;
62374 extern int sysctl_memory_failure_recovery;
62375 extern void shake_page(struct page *p, int access);
62376 -extern atomic_long_t mce_bad_pages;
62377 +extern atomic_long_unchecked_t mce_bad_pages;
62378 extern int soft_offline_page(struct page *page, int flags);
62379
62380 extern void dump_page(struct page *page);
62381 @@ -1637,5 +1647,11 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
62382 static inline bool page_is_guard(struct page *page) { return false; }
62383 #endif /* CONFIG_DEBUG_PAGEALLOC */
62384
62385 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
62386 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
62387 +#else
62388 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
62389 +#endif
62390 +
62391 #endif /* __KERNEL__ */
62392 #endif /* _LINUX_MM_H */
62393 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
62394 index 3cc3062..efeaeb7 100644
62395 --- a/include/linux/mm_types.h
62396 +++ b/include/linux/mm_types.h
62397 @@ -252,6 +252,8 @@ struct vm_area_struct {
62398 #ifdef CONFIG_NUMA
62399 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
62400 #endif
62401 +
62402 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
62403 };
62404
62405 struct core_thread {
62406 @@ -326,7 +328,7 @@ struct mm_struct {
62407 unsigned long def_flags;
62408 unsigned long nr_ptes; /* Page table pages */
62409 unsigned long start_code, end_code, start_data, end_data;
62410 - unsigned long start_brk, brk, start_stack;
62411 + unsigned long brk_gap, start_brk, brk, start_stack;
62412 unsigned long arg_start, arg_end, env_start, env_end;
62413
62414 unsigned long saved_auxv[AT_VECTOR_SIZE]; /* for /proc/PID/auxv */
62415 @@ -388,6 +390,24 @@ struct mm_struct {
62416 #ifdef CONFIG_CPUMASK_OFFSTACK
62417 struct cpumask cpumask_allocation;
62418 #endif
62419 +
62420 +#if defined(CONFIG_PAX_EI_PAX) || defined(CONFIG_PAX_PT_PAX_FLAGS) || defined(CONFIG_PAX_XATTR_PAX_FLAGS) || defined(CONFIG_PAX_HAVE_ACL_FLAGS) || defined(CONFIG_PAX_HOOK_ACL_FLAGS)
62421 + unsigned long pax_flags;
62422 +#endif
62423 +
62424 +#ifdef CONFIG_PAX_DLRESOLVE
62425 + unsigned long call_dl_resolve;
62426 +#endif
62427 +
62428 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
62429 + unsigned long call_syscall;
62430 +#endif
62431 +
62432 +#ifdef CONFIG_PAX_ASLR
62433 + unsigned long delta_mmap; /* randomized offset */
62434 + unsigned long delta_stack; /* randomized offset */
62435 +#endif
62436 +
62437 };
62438
62439 static inline void mm_init_cpumask(struct mm_struct *mm)
62440 diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h
62441 index 1d1b1e1..2a13c78 100644
62442 --- a/include/linux/mmu_notifier.h
62443 +++ b/include/linux/mmu_notifier.h
62444 @@ -255,12 +255,12 @@ static inline void mmu_notifier_mm_destroy(struct mm_struct *mm)
62445 */
62446 #define ptep_clear_flush_notify(__vma, __address, __ptep) \
62447 ({ \
62448 - pte_t __pte; \
62449 + pte_t ___pte; \
62450 struct vm_area_struct *___vma = __vma; \
62451 unsigned long ___address = __address; \
62452 - __pte = ptep_clear_flush(___vma, ___address, __ptep); \
62453 + ___pte = ptep_clear_flush(___vma, ___address, __ptep); \
62454 mmu_notifier_invalidate_page(___vma->vm_mm, ___address); \
62455 - __pte; \
62456 + ___pte; \
62457 })
62458
62459 #define pmdp_clear_flush_notify(__vma, __address, __pmdp) \
62460 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
62461 index 650ba2f..af0a58c 100644
62462 --- a/include/linux/mmzone.h
62463 +++ b/include/linux/mmzone.h
62464 @@ -379,7 +379,7 @@ struct zone {
62465 unsigned long flags; /* zone flags, see below */
62466
62467 /* Zone statistics */
62468 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
62469 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
62470
62471 /*
62472 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
62473 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
62474 index 83ac071..2656e0e 100644
62475 --- a/include/linux/mod_devicetable.h
62476 +++ b/include/linux/mod_devicetable.h
62477 @@ -12,7 +12,7 @@
62478 typedef unsigned long kernel_ulong_t;
62479 #endif
62480
62481 -#define PCI_ANY_ID (~0)
62482 +#define PCI_ANY_ID ((__u16)~0)
62483
62484 struct pci_device_id {
62485 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
62486 @@ -131,7 +131,7 @@ struct usb_device_id {
62487 #define USB_DEVICE_ID_MATCH_INT_SUBCLASS 0x0100
62488 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
62489
62490 -#define HID_ANY_ID (~0)
62491 +#define HID_ANY_ID (~0U)
62492
62493 struct hid_device_id {
62494 __u16 bus;
62495 diff --git a/include/linux/module.h b/include/linux/module.h
62496 index 4598bf0..e069d7f 100644
62497 --- a/include/linux/module.h
62498 +++ b/include/linux/module.h
62499 @@ -17,6 +17,7 @@
62500 #include <linux/moduleparam.h>
62501 #include <linux/tracepoint.h>
62502 #include <linux/export.h>
62503 +#include <linux/fs.h>
62504
62505 #include <linux/percpu.h>
62506 #include <asm/module.h>
62507 @@ -275,19 +276,16 @@ struct module
62508 int (*init)(void);
62509
62510 /* If this is non-NULL, vfree after init() returns */
62511 - void *module_init;
62512 + void *module_init_rx, *module_init_rw;
62513
62514 /* Here is the actual code + data, vfree'd on unload. */
62515 - void *module_core;
62516 + void *module_core_rx, *module_core_rw;
62517
62518 /* Here are the sizes of the init and core sections */
62519 - unsigned int init_size, core_size;
62520 + unsigned int init_size_rw, core_size_rw;
62521
62522 /* The size of the executable code in each section. */
62523 - unsigned int init_text_size, core_text_size;
62524 -
62525 - /* Size of RO sections of the module (text+rodata) */
62526 - unsigned int init_ro_size, core_ro_size;
62527 + unsigned int init_size_rx, core_size_rx;
62528
62529 /* Arch-specific module values */
62530 struct mod_arch_specific arch;
62531 @@ -343,6 +341,10 @@ struct module
62532 #ifdef CONFIG_EVENT_TRACING
62533 struct ftrace_event_call **trace_events;
62534 unsigned int num_trace_events;
62535 + struct file_operations trace_id;
62536 + struct file_operations trace_enable;
62537 + struct file_operations trace_format;
62538 + struct file_operations trace_filter;
62539 #endif
62540 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
62541 unsigned int num_ftrace_callsites;
62542 @@ -390,16 +392,46 @@ bool is_module_address(unsigned long addr);
62543 bool is_module_percpu_address(unsigned long addr);
62544 bool is_module_text_address(unsigned long addr);
62545
62546 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
62547 +{
62548 +
62549 +#ifdef CONFIG_PAX_KERNEXEC
62550 + if (ktla_ktva(addr) >= (unsigned long)start &&
62551 + ktla_ktva(addr) < (unsigned long)start + size)
62552 + return 1;
62553 +#endif
62554 +
62555 + return ((void *)addr >= start && (void *)addr < start + size);
62556 +}
62557 +
62558 +static inline int within_module_core_rx(unsigned long addr, struct module *mod)
62559 +{
62560 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
62561 +}
62562 +
62563 +static inline int within_module_core_rw(unsigned long addr, struct module *mod)
62564 +{
62565 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
62566 +}
62567 +
62568 +static inline int within_module_init_rx(unsigned long addr, struct module *mod)
62569 +{
62570 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
62571 +}
62572 +
62573 +static inline int within_module_init_rw(unsigned long addr, struct module *mod)
62574 +{
62575 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
62576 +}
62577 +
62578 static inline int within_module_core(unsigned long addr, struct module *mod)
62579 {
62580 - return (unsigned long)mod->module_core <= addr &&
62581 - addr < (unsigned long)mod->module_core + mod->core_size;
62582 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
62583 }
62584
62585 static inline int within_module_init(unsigned long addr, struct module *mod)
62586 {
62587 - return (unsigned long)mod->module_init <= addr &&
62588 - addr < (unsigned long)mod->module_init + mod->init_size;
62589 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
62590 }
62591
62592 /* Search for module by name: must hold module_mutex. */
62593 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
62594 index b2be02e..0a61daa 100644
62595 --- a/include/linux/moduleloader.h
62596 +++ b/include/linux/moduleloader.h
62597 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
62598 sections. Returns NULL on failure. */
62599 void *module_alloc(unsigned long size);
62600
62601 +#ifdef CONFIG_PAX_KERNEXEC
62602 +void *module_alloc_exec(unsigned long size) __size_overflow(1);
62603 +#else
62604 +#define module_alloc_exec(x) module_alloc(x)
62605 +#endif
62606 +
62607 /* Free memory returned from module_alloc. */
62608 void module_free(struct module *mod, void *module_region);
62609
62610 +#ifdef CONFIG_PAX_KERNEXEC
62611 +void module_free_exec(struct module *mod, void *module_region);
62612 +#else
62613 +#define module_free_exec(x, y) module_free((x), (y))
62614 +#endif
62615 +
62616 /* Apply the given relocation to the (simplified) ELF. Return -error
62617 or 0. */
62618 int apply_relocate(Elf_Shdr *sechdrs,
62619 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
62620 index c47f4d6..23f9bdb 100644
62621 --- a/include/linux/moduleparam.h
62622 +++ b/include/linux/moduleparam.h
62623 @@ -260,7 +260,7 @@ static inline void __kernel_param_unlock(void)
62624 * @len is usually just sizeof(string).
62625 */
62626 #define module_param_string(name, string, len, perm) \
62627 - static const struct kparam_string __param_string_##name \
62628 + static const struct kparam_string __param_string_##name __used \
62629 = { len, string }; \
62630 __module_param_call(MODULE_PARAM_PREFIX, name, \
62631 &param_ops_string, \
62632 @@ -396,7 +396,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
62633 */
62634 #define module_param_array_named(name, array, type, nump, perm) \
62635 param_check_##type(name, &(array)[0]); \
62636 - static const struct kparam_array __param_arr_##name \
62637 + static const struct kparam_array __param_arr_##name __used \
62638 = { .max = ARRAY_SIZE(array), .num = nump, \
62639 .ops = &param_ops_##type, \
62640 .elemsize = sizeof(array[0]), .elem = array }; \
62641 diff --git a/include/linux/namei.h b/include/linux/namei.h
62642 index ffc0213..2c1f2cb 100644
62643 --- a/include/linux/namei.h
62644 +++ b/include/linux/namei.h
62645 @@ -24,7 +24,7 @@ struct nameidata {
62646 unsigned seq;
62647 int last_type;
62648 unsigned depth;
62649 - char *saved_names[MAX_NESTED_LINKS + 1];
62650 + const char *saved_names[MAX_NESTED_LINKS + 1];
62651
62652 /* Intent data */
62653 union {
62654 @@ -94,12 +94,12 @@ extern int follow_up(struct path *);
62655 extern struct dentry *lock_rename(struct dentry *, struct dentry *);
62656 extern void unlock_rename(struct dentry *, struct dentry *);
62657
62658 -static inline void nd_set_link(struct nameidata *nd, char *path)
62659 +static inline void nd_set_link(struct nameidata *nd, const char *path)
62660 {
62661 nd->saved_names[nd->depth] = path;
62662 }
62663
62664 -static inline char *nd_get_link(struct nameidata *nd)
62665 +static inline const char *nd_get_link(const struct nameidata *nd)
62666 {
62667 return nd->saved_names[nd->depth];
62668 }
62669 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
62670 index 7e472b7..212d381 100644
62671 --- a/include/linux/netdevice.h
62672 +++ b/include/linux/netdevice.h
62673 @@ -1002,6 +1002,7 @@ struct net_device_ops {
62674 int (*ndo_neigh_construct)(struct neighbour *n);
62675 void (*ndo_neigh_destroy)(struct neighbour *n);
62676 };
62677 +typedef struct net_device_ops __no_const net_device_ops_no_const;
62678
62679 /*
62680 * The DEVICE structure.
62681 @@ -1063,7 +1064,7 @@ struct net_device {
62682 int iflink;
62683
62684 struct net_device_stats stats;
62685 - atomic_long_t rx_dropped; /* dropped packets by core network
62686 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
62687 * Do not use this in drivers.
62688 */
62689
62690 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
62691 new file mode 100644
62692 index 0000000..33f4af8
62693 --- /dev/null
62694 +++ b/include/linux/netfilter/xt_gradm.h
62695 @@ -0,0 +1,9 @@
62696 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
62697 +#define _LINUX_NETFILTER_XT_GRADM_H 1
62698 +
62699 +struct xt_gradm_mtinfo {
62700 + __u16 flags;
62701 + __u16 invflags;
62702 +};
62703 +
62704 +#endif
62705 diff --git a/include/linux/of_pdt.h b/include/linux/of_pdt.h
62706 index c65a18a..0c05f3a 100644
62707 --- a/include/linux/of_pdt.h
62708 +++ b/include/linux/of_pdt.h
62709 @@ -32,7 +32,7 @@ struct of_pdt_ops {
62710
62711 /* return 0 on success; fill in 'len' with number of bytes in path */
62712 int (*pkg2path)(phandle node, char *buf, const int buflen, int *len);
62713 -};
62714 +} __no_const;
62715
62716 extern void *prom_early_alloc(unsigned long size);
62717
62718 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
62719 index a4c5624..79d6d88 100644
62720 --- a/include/linux/oprofile.h
62721 +++ b/include/linux/oprofile.h
62722 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
62723 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
62724 char const * name, ulong * val);
62725
62726 -/** Create a file for read-only access to an atomic_t. */
62727 +/** Create a file for read-only access to an atomic_unchecked_t. */
62728 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
62729 - char const * name, atomic_t * val);
62730 + char const * name, atomic_unchecked_t * val);
62731
62732 /** create a directory */
62733 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
62734 diff --git a/include/linux/padata.h b/include/linux/padata.h
62735 index 4633b2f..988bc08 100644
62736 --- a/include/linux/padata.h
62737 +++ b/include/linux/padata.h
62738 @@ -129,7 +129,7 @@ struct parallel_data {
62739 struct padata_instance *pinst;
62740 struct padata_parallel_queue __percpu *pqueue;
62741 struct padata_serial_queue __percpu *squeue;
62742 - atomic_t seq_nr;
62743 + atomic_unchecked_t seq_nr;
62744 atomic_t reorder_objects;
62745 atomic_t refcnt;
62746 unsigned int max_seq_nr;
62747 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
62748 index abb2776..d8b8e15 100644
62749 --- a/include/linux/perf_event.h
62750 +++ b/include/linux/perf_event.h
62751 @@ -750,8 +750,8 @@ struct perf_event {
62752
62753 enum perf_event_active_state state;
62754 unsigned int attach_state;
62755 - local64_t count;
62756 - atomic64_t child_count;
62757 + local64_t count; /* PaX: fix it one day */
62758 + atomic64_unchecked_t child_count;
62759
62760 /*
62761 * These are the total time in nanoseconds that the event
62762 @@ -802,8 +802,8 @@ struct perf_event {
62763 * These accumulate total time (in nanoseconds) that children
62764 * events have been enabled and running, respectively.
62765 */
62766 - atomic64_t child_total_time_enabled;
62767 - atomic64_t child_total_time_running;
62768 + atomic64_unchecked_t child_total_time_enabled;
62769 + atomic64_unchecked_t child_total_time_running;
62770
62771 /*
62772 * Protect attach/detach and child_list:
62773 diff --git a/include/linux/personality.h b/include/linux/personality.h
62774 index 8fc7dd1a..c19d89e 100644
62775 --- a/include/linux/personality.h
62776 +++ b/include/linux/personality.h
62777 @@ -44,6 +44,7 @@ enum {
62778 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
62779 ADDR_NO_RANDOMIZE | \
62780 ADDR_COMPAT_LAYOUT | \
62781 + ADDR_LIMIT_3GB | \
62782 MMAP_PAGE_ZERO)
62783
62784 /*
62785 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
62786 index 0072a53..c5dcca5 100644
62787 --- a/include/linux/pipe_fs_i.h
62788 +++ b/include/linux/pipe_fs_i.h
62789 @@ -47,9 +47,9 @@ struct pipe_buffer {
62790 struct pipe_inode_info {
62791 wait_queue_head_t wait;
62792 unsigned int nrbufs, curbuf, buffers;
62793 - unsigned int readers;
62794 - unsigned int writers;
62795 - unsigned int waiting_writers;
62796 + atomic_t readers;
62797 + atomic_t writers;
62798 + atomic_t waiting_writers;
62799 unsigned int r_counter;
62800 unsigned int w_counter;
62801 struct page *tmp_page;
62802 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
62803 index 609daae..5392427 100644
62804 --- a/include/linux/pm_runtime.h
62805 +++ b/include/linux/pm_runtime.h
62806 @@ -97,7 +97,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
62807
62808 static inline void pm_runtime_mark_last_busy(struct device *dev)
62809 {
62810 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
62811 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
62812 }
62813
62814 #else /* !CONFIG_PM_RUNTIME */
62815 diff --git a/include/linux/poison.h b/include/linux/poison.h
62816 index 2110a81..13a11bb 100644
62817 --- a/include/linux/poison.h
62818 +++ b/include/linux/poison.h
62819 @@ -19,8 +19,8 @@
62820 * under normal circumstances, used to verify that nobody uses
62821 * non-initialized list entries.
62822 */
62823 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
62824 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
62825 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
62826 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
62827
62828 /********** include/linux/timer.h **********/
62829 /*
62830 diff --git a/include/linux/preempt.h b/include/linux/preempt.h
62831 index 58969b2..ead129b 100644
62832 --- a/include/linux/preempt.h
62833 +++ b/include/linux/preempt.h
62834 @@ -123,7 +123,7 @@ struct preempt_ops {
62835 void (*sched_in)(struct preempt_notifier *notifier, int cpu);
62836 void (*sched_out)(struct preempt_notifier *notifier,
62837 struct task_struct *next);
62838 -};
62839 +} __no_const;
62840
62841 /**
62842 * preempt_notifier - key for installing preemption notifiers
62843 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
62844 index 85c5073..51fac8b 100644
62845 --- a/include/linux/proc_fs.h
62846 +++ b/include/linux/proc_fs.h
62847 @@ -155,6 +155,18 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
62848 return proc_create_data(name, mode, parent, proc_fops, NULL);
62849 }
62850
62851 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
62852 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
62853 +{
62854 +#ifdef CONFIG_GRKERNSEC_PROC_USER
62855 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
62856 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62857 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
62858 +#else
62859 + return proc_create_data(name, mode, parent, proc_fops, NULL);
62860 +#endif
62861 +}
62862 +
62863 static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
62864 umode_t mode, struct proc_dir_entry *base,
62865 read_proc_t *read_proc, void * data)
62866 @@ -258,7 +270,7 @@ union proc_op {
62867 int (*proc_show)(struct seq_file *m,
62868 struct pid_namespace *ns, struct pid *pid,
62869 struct task_struct *task);
62870 -};
62871 +} __no_const;
62872
62873 struct ctl_table_header;
62874 struct ctl_table;
62875 diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
62876 index c2f1f6a..6fdb196 100644
62877 --- a/include/linux/ptrace.h
62878 +++ b/include/linux/ptrace.h
62879 @@ -199,9 +199,10 @@ static inline void ptrace_event(int event, unsigned long message)
62880 if (unlikely(ptrace_event_enabled(current, event))) {
62881 current->ptrace_message = message;
62882 ptrace_notify((event << 8) | SIGTRAP);
62883 - } else if (event == PTRACE_EVENT_EXEC && unlikely(current->ptrace)) {
62884 + } else if (event == PTRACE_EVENT_EXEC) {
62885 /* legacy EXEC report via SIGTRAP */
62886 - send_sig(SIGTRAP, current, 0);
62887 + if ((current->ptrace & (PT_PTRACED|PT_SEIZED)) == PT_PTRACED)
62888 + send_sig(SIGTRAP, current, 0);
62889 }
62890 }
62891
62892 diff --git a/include/linux/random.h b/include/linux/random.h
62893 index 8f74538..02a1012 100644
62894 --- a/include/linux/random.h
62895 +++ b/include/linux/random.h
62896 @@ -69,12 +69,17 @@ void srandom32(u32 seed);
62897
62898 u32 prandom32(struct rnd_state *);
62899
62900 +static inline unsigned long pax_get_random_long(void)
62901 +{
62902 + return random32() + (sizeof(long) > 4 ? (unsigned long)random32() << 32 : 0);
62903 +}
62904 +
62905 /*
62906 * Handle minimum values for seeds
62907 */
62908 static inline u32 __seed(u32 x, u32 m)
62909 {
62910 - return (x < m) ? x + m : x;
62911 + return (x <= m) ? x + m + 1 : x;
62912 }
62913
62914 /**
62915 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
62916 index e0879a7..a12f962 100644
62917 --- a/include/linux/reboot.h
62918 +++ b/include/linux/reboot.h
62919 @@ -52,9 +52,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
62920 * Architecture-specific implementations of sys_reboot commands.
62921 */
62922
62923 -extern void machine_restart(char *cmd);
62924 -extern void machine_halt(void);
62925 -extern void machine_power_off(void);
62926 +extern void machine_restart(char *cmd) __noreturn;
62927 +extern void machine_halt(void) __noreturn;
62928 +extern void machine_power_off(void) __noreturn;
62929
62930 extern void machine_shutdown(void);
62931 struct pt_regs;
62932 @@ -65,9 +65,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
62933 */
62934
62935 extern void kernel_restart_prepare(char *cmd);
62936 -extern void kernel_restart(char *cmd);
62937 -extern void kernel_halt(void);
62938 -extern void kernel_power_off(void);
62939 +extern void kernel_restart(char *cmd) __noreturn;
62940 +extern void kernel_halt(void) __noreturn;
62941 +extern void kernel_power_off(void) __noreturn;
62942
62943 extern int C_A_D; /* for sysctl */
62944 void ctrl_alt_del(void);
62945 @@ -81,7 +81,7 @@ extern int orderly_poweroff(bool force);
62946 * Emergency restart, callable from an interrupt handler.
62947 */
62948
62949 -extern void emergency_restart(void);
62950 +extern void emergency_restart(void) __noreturn;
62951 #include <asm/emergency-restart.h>
62952
62953 #endif
62954 diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
62955 index 2213ddc..650212a 100644
62956 --- a/include/linux/reiserfs_fs.h
62957 +++ b/include/linux/reiserfs_fs.h
62958 @@ -1406,7 +1406,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
62959 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
62960
62961 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
62962 -#define get_generation(s) atomic_read (&fs_generation(s))
62963 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
62964 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
62965 #define __fs_changed(gen,s) (gen != get_generation (s))
62966 #define fs_changed(gen,s) \
62967 diff --git a/include/linux/reiserfs_fs_sb.h b/include/linux/reiserfs_fs_sb.h
62968 index 8c9e85c..1698e9a 100644
62969 --- a/include/linux/reiserfs_fs_sb.h
62970 +++ b/include/linux/reiserfs_fs_sb.h
62971 @@ -386,7 +386,7 @@ struct reiserfs_sb_info {
62972 /* Comment? -Hans */
62973 wait_queue_head_t s_wait;
62974 /* To be obsoleted soon by per buffer seals.. -Hans */
62975 - atomic_t s_generation_counter; // increased by one every time the
62976 + atomic_unchecked_t s_generation_counter; // increased by one every time the
62977 // tree gets re-balanced
62978 unsigned long s_properties; /* File system properties. Currently holds
62979 on-disk FS format */
62980 diff --git a/include/linux/relay.h b/include/linux/relay.h
62981 index a822fd7..62b70f6 100644
62982 --- a/include/linux/relay.h
62983 +++ b/include/linux/relay.h
62984 @@ -159,7 +159,7 @@ struct rchan_callbacks
62985 * The callback should return 0 if successful, negative if not.
62986 */
62987 int (*remove_buf_file)(struct dentry *dentry);
62988 -};
62989 +} __no_const;
62990
62991 /*
62992 * CONFIG_RELAY kernel API, kernel/relay.c
62993 diff --git a/include/linux/rfkill.h b/include/linux/rfkill.h
62994 index c6c6084..5bf1212 100644
62995 --- a/include/linux/rfkill.h
62996 +++ b/include/linux/rfkill.h
62997 @@ -147,6 +147,7 @@ struct rfkill_ops {
62998 void (*query)(struct rfkill *rfkill, void *data);
62999 int (*set_block)(void *data, bool blocked);
63000 };
63001 +typedef struct rfkill_ops __no_const rfkill_ops_no_const;
63002
63003 #if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)
63004 /**
63005 diff --git a/include/linux/rio.h b/include/linux/rio.h
63006 index 4d50611..c6858a2 100644
63007 --- a/include/linux/rio.h
63008 +++ b/include/linux/rio.h
63009 @@ -315,7 +315,7 @@ struct rio_ops {
63010 int mbox, void *buffer, size_t len);
63011 int (*add_inb_buffer)(struct rio_mport *mport, int mbox, void *buf);
63012 void *(*get_inb_message)(struct rio_mport *mport, int mbox);
63013 -};
63014 +} __no_const;
63015
63016 #define RIO_RESOURCE_MEM 0x00000100
63017 #define RIO_RESOURCE_DOORBELL 0x00000200
63018 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
63019 index 1cdd62a..e399f0d 100644
63020 --- a/include/linux/rmap.h
63021 +++ b/include/linux/rmap.h
63022 @@ -119,9 +119,9 @@ static inline void anon_vma_unlock(struct anon_vma *anon_vma)
63023 void anon_vma_init(void); /* create anon_vma_cachep */
63024 int anon_vma_prepare(struct vm_area_struct *);
63025 void unlink_anon_vmas(struct vm_area_struct *);
63026 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
63027 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
63028 void anon_vma_moveto_tail(struct vm_area_struct *);
63029 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
63030 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
63031 void __anon_vma_link(struct vm_area_struct *);
63032
63033 static inline void anon_vma_merge(struct vm_area_struct *vma,
63034 diff --git a/include/linux/sched.h b/include/linux/sched.h
63035 index 0657368..765f70f 100644
63036 --- a/include/linux/sched.h
63037 +++ b/include/linux/sched.h
63038 @@ -101,6 +101,7 @@ struct bio_list;
63039 struct fs_struct;
63040 struct perf_event_context;
63041 struct blk_plug;
63042 +struct linux_binprm;
63043
63044 /*
63045 * List of flags we want to share for kernel threads,
63046 @@ -382,10 +383,13 @@ struct user_namespace;
63047 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
63048
63049 extern int sysctl_max_map_count;
63050 +extern unsigned long sysctl_heap_stack_gap;
63051
63052 #include <linux/aio.h>
63053
63054 #ifdef CONFIG_MMU
63055 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len);
63056 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len);
63057 extern void arch_pick_mmap_layout(struct mm_struct *mm);
63058 extern unsigned long
63059 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
63060 @@ -631,6 +635,17 @@ struct signal_struct {
63061 #ifdef CONFIG_TASKSTATS
63062 struct taskstats *stats;
63063 #endif
63064 +
63065 +#ifdef CONFIG_GRKERNSEC
63066 + u32 curr_ip;
63067 + u32 saved_ip;
63068 + u32 gr_saddr;
63069 + u32 gr_daddr;
63070 + u16 gr_sport;
63071 + u16 gr_dport;
63072 + u8 used_accept:1;
63073 +#endif
63074 +
63075 #ifdef CONFIG_AUDIT
63076 unsigned audit_tty;
63077 struct tty_audit_buf *tty_audit_buf;
63078 @@ -714,6 +729,11 @@ struct user_struct {
63079 struct key *session_keyring; /* UID's default session keyring */
63080 #endif
63081
63082 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
63083 + unsigned int banned;
63084 + unsigned long ban_expires;
63085 +#endif
63086 +
63087 /* Hash table maintenance information */
63088 struct hlist_node uidhash_node;
63089 uid_t uid;
63090 @@ -1354,8 +1374,8 @@ struct task_struct {
63091 struct list_head thread_group;
63092
63093 struct completion *vfork_done; /* for vfork() */
63094 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
63095 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
63096 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
63097 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
63098
63099 cputime_t utime, stime, utimescaled, stimescaled;
63100 cputime_t gtime;
63101 @@ -1371,13 +1391,6 @@ struct task_struct {
63102 struct task_cputime cputime_expires;
63103 struct list_head cpu_timers[3];
63104
63105 -/* process credentials */
63106 - const struct cred __rcu *real_cred; /* objective and real subjective task
63107 - * credentials (COW) */
63108 - const struct cred __rcu *cred; /* effective (overridable) subjective task
63109 - * credentials (COW) */
63110 - struct cred *replacement_session_keyring; /* for KEYCTL_SESSION_TO_PARENT */
63111 -
63112 char comm[TASK_COMM_LEN]; /* executable name excluding path
63113 - access with [gs]et_task_comm (which lock
63114 it with task_lock())
63115 @@ -1394,8 +1407,16 @@ struct task_struct {
63116 #endif
63117 /* CPU-specific state of this task */
63118 struct thread_struct thread;
63119 +/* thread_info moved to task_struct */
63120 +#ifdef CONFIG_X86
63121 + struct thread_info tinfo;
63122 +#endif
63123 /* filesystem information */
63124 struct fs_struct *fs;
63125 +
63126 + const struct cred __rcu *cred; /* effective (overridable) subjective task
63127 + * credentials (COW) */
63128 +
63129 /* open file information */
63130 struct files_struct *files;
63131 /* namespaces */
63132 @@ -1442,6 +1463,11 @@ struct task_struct {
63133 struct rt_mutex_waiter *pi_blocked_on;
63134 #endif
63135
63136 +/* process credentials */
63137 + const struct cred __rcu *real_cred; /* objective and real subjective task
63138 + * credentials (COW) */
63139 + struct cred *replacement_session_keyring; /* for KEYCTL_SESSION_TO_PARENT */
63140 +
63141 #ifdef CONFIG_DEBUG_MUTEXES
63142 /* mutex deadlock detection */
63143 struct mutex_waiter *blocked_on;
63144 @@ -1558,6 +1584,27 @@ struct task_struct {
63145 unsigned long default_timer_slack_ns;
63146
63147 struct list_head *scm_work_list;
63148 +
63149 +#ifdef CONFIG_GRKERNSEC
63150 + /* grsecurity */
63151 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
63152 + u64 exec_id;
63153 +#endif
63154 +#ifdef CONFIG_GRKERNSEC_SETXID
63155 + const struct cred *delayed_cred;
63156 +#endif
63157 + struct dentry *gr_chroot_dentry;
63158 + struct acl_subject_label *acl;
63159 + struct acl_role_label *role;
63160 + struct file *exec_file;
63161 + u16 acl_role_id;
63162 + /* is this the task that authenticated to the special role */
63163 + u8 acl_sp_role;
63164 + u8 is_writable;
63165 + u8 brute;
63166 + u8 gr_is_chrooted;
63167 +#endif
63168 +
63169 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
63170 /* Index of current stored address in ret_stack */
63171 int curr_ret_stack;
63172 @@ -1592,6 +1639,51 @@ struct task_struct {
63173 #endif
63174 };
63175
63176 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
63177 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
63178 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
63179 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
63180 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
63181 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
63182 +
63183 +#ifdef CONFIG_PAX_SOFTMODE
63184 +extern int pax_softmode;
63185 +#endif
63186 +
63187 +extern int pax_check_flags(unsigned long *);
63188 +
63189 +/* if tsk != current then task_lock must be held on it */
63190 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
63191 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
63192 +{
63193 + if (likely(tsk->mm))
63194 + return tsk->mm->pax_flags;
63195 + else
63196 + return 0UL;
63197 +}
63198 +
63199 +/* if tsk != current then task_lock must be held on it */
63200 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
63201 +{
63202 + if (likely(tsk->mm)) {
63203 + tsk->mm->pax_flags = flags;
63204 + return 0;
63205 + }
63206 + return -EINVAL;
63207 +}
63208 +#endif
63209 +
63210 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
63211 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
63212 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
63213 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
63214 +#endif
63215 +
63216 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
63217 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
63218 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
63219 +extern __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to, const char *type);
63220 +
63221 /* Future-safe accessor for struct task_struct's cpus_allowed. */
63222 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
63223
63224 @@ -2104,7 +2196,9 @@ void yield(void);
63225 extern struct exec_domain default_exec_domain;
63226
63227 union thread_union {
63228 +#ifndef CONFIG_X86
63229 struct thread_info thread_info;
63230 +#endif
63231 unsigned long stack[THREAD_SIZE/sizeof(long)];
63232 };
63233
63234 @@ -2137,6 +2231,7 @@ extern struct pid_namespace init_pid_ns;
63235 */
63236
63237 extern struct task_struct *find_task_by_vpid(pid_t nr);
63238 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
63239 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
63240 struct pid_namespace *ns);
63241
63242 @@ -2280,7 +2375,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
63243 extern void exit_itimers(struct signal_struct *);
63244 extern void flush_itimer_signals(void);
63245
63246 -extern void do_group_exit(int);
63247 +extern __noreturn void do_group_exit(int);
63248
63249 extern void daemonize(const char *, ...);
63250 extern int allow_signal(int);
63251 @@ -2478,13 +2573,17 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
63252
63253 #endif
63254
63255 -static inline int object_is_on_stack(void *obj)
63256 +static inline int object_starts_on_stack(void *obj)
63257 {
63258 - void *stack = task_stack_page(current);
63259 + const void *stack = task_stack_page(current);
63260
63261 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
63262 }
63263
63264 +#ifdef CONFIG_PAX_USERCOPY
63265 +extern int object_is_on_stack(const void *obj, unsigned long len);
63266 +#endif
63267 +
63268 extern void thread_info_cache_init(void);
63269
63270 #ifdef CONFIG_DEBUG_STACK_USAGE
63271 diff --git a/include/linux/screen_info.h b/include/linux/screen_info.h
63272 index 899fbb4..1cb4138 100644
63273 --- a/include/linux/screen_info.h
63274 +++ b/include/linux/screen_info.h
63275 @@ -43,7 +43,8 @@ struct screen_info {
63276 __u16 pages; /* 0x32 */
63277 __u16 vesa_attributes; /* 0x34 */
63278 __u32 capabilities; /* 0x36 */
63279 - __u8 _reserved[6]; /* 0x3a */
63280 + __u16 vesapm_size; /* 0x3a */
63281 + __u8 _reserved[4]; /* 0x3c */
63282 } __attribute__((packed));
63283
63284 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
63285 diff --git a/include/linux/security.h b/include/linux/security.h
63286 index 83c18e8..2d98860 100644
63287 --- a/include/linux/security.h
63288 +++ b/include/linux/security.h
63289 @@ -37,6 +37,7 @@
63290 #include <linux/xfrm.h>
63291 #include <linux/slab.h>
63292 #include <linux/xattr.h>
63293 +#include <linux/grsecurity.h>
63294 #include <net/flow.h>
63295
63296 /* Maximum number of letters for an LSM name string */
63297 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
63298 index 44f1514..2bbf6c1 100644
63299 --- a/include/linux/seq_file.h
63300 +++ b/include/linux/seq_file.h
63301 @@ -24,6 +24,9 @@ struct seq_file {
63302 struct mutex lock;
63303 const struct seq_operations *op;
63304 int poll_event;
63305 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
63306 + u64 exec_id;
63307 +#endif
63308 void *private;
63309 };
63310
63311 @@ -33,6 +36,7 @@ struct seq_operations {
63312 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
63313 int (*show) (struct seq_file *m, void *v);
63314 };
63315 +typedef struct seq_operations __no_const seq_operations_no_const;
63316
63317 #define SEQ_SKIP 1
63318
63319 diff --git a/include/linux/shm.h b/include/linux/shm.h
63320 index 92808b8..c28cac4 100644
63321 --- a/include/linux/shm.h
63322 +++ b/include/linux/shm.h
63323 @@ -98,6 +98,10 @@ struct shmid_kernel /* private to the kernel */
63324
63325 /* The task created the shm object. NULL if the task is dead. */
63326 struct task_struct *shm_creator;
63327 +#ifdef CONFIG_GRKERNSEC
63328 + time_t shm_createtime;
63329 + pid_t shm_lapid;
63330 +#endif
63331 };
63332
63333 /* shm_mode upper byte flags */
63334 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
63335 index 42854ce..3b7d3c8 100644
63336 --- a/include/linux/skbuff.h
63337 +++ b/include/linux/skbuff.h
63338 @@ -655,7 +655,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
63339 */
63340 static inline int skb_queue_empty(const struct sk_buff_head *list)
63341 {
63342 - return list->next == (struct sk_buff *)list;
63343 + return list->next == (const struct sk_buff *)list;
63344 }
63345
63346 /**
63347 @@ -668,7 +668,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
63348 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
63349 const struct sk_buff *skb)
63350 {
63351 - return skb->next == (struct sk_buff *)list;
63352 + return skb->next == (const struct sk_buff *)list;
63353 }
63354
63355 /**
63356 @@ -681,7 +681,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
63357 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
63358 const struct sk_buff *skb)
63359 {
63360 - return skb->prev == (struct sk_buff *)list;
63361 + return skb->prev == (const struct sk_buff *)list;
63362 }
63363
63364 /**
63365 @@ -1558,7 +1558,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
63366 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
63367 */
63368 #ifndef NET_SKB_PAD
63369 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
63370 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
63371 #endif
63372
63373 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
63374 diff --git a/include/linux/slab.h b/include/linux/slab.h
63375 index 573c809..eaaf6ea 100644
63376 --- a/include/linux/slab.h
63377 +++ b/include/linux/slab.h
63378 @@ -11,12 +11,20 @@
63379
63380 #include <linux/gfp.h>
63381 #include <linux/types.h>
63382 +#include <linux/err.h>
63383
63384 /*
63385 * Flags to pass to kmem_cache_create().
63386 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
63387 */
63388 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
63389 +
63390 +#ifdef CONFIG_PAX_USERCOPY
63391 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
63392 +#else
63393 +#define SLAB_USERCOPY 0x00000000UL
63394 +#endif
63395 +
63396 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
63397 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
63398 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
63399 @@ -87,10 +95,13 @@
63400 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
63401 * Both make kfree a no-op.
63402 */
63403 -#define ZERO_SIZE_PTR ((void *)16)
63404 +#define ZERO_SIZE_PTR \
63405 +({ \
63406 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
63407 + (void *)(-MAX_ERRNO-1L); \
63408 +})
63409
63410 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
63411 - (unsigned long)ZERO_SIZE_PTR)
63412 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
63413
63414 /*
63415 * struct kmem_cache related prototypes
63416 @@ -161,6 +172,7 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
63417 void kfree(const void *);
63418 void kzfree(const void *);
63419 size_t ksize(const void *);
63420 +void check_object_size(const void *ptr, unsigned long n, bool to);
63421
63422 /*
63423 * Allocator specific definitions. These are mainly used to establish optimized
63424 @@ -287,7 +299,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
63425 */
63426 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
63427 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING))
63428 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
63429 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
63430 #define kmalloc_track_caller(size, flags) \
63431 __kmalloc_track_caller(size, flags, _RET_IP_)
63432 #else
63433 @@ -306,7 +318,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
63434 */
63435 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
63436 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING))
63437 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
63438 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
63439 #define kmalloc_node_track_caller(size, flags, node) \
63440 __kmalloc_node_track_caller(size, flags, node, \
63441 _RET_IP_)
63442 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
63443 index fbd1117..d4d8ef8 100644
63444 --- a/include/linux/slab_def.h
63445 +++ b/include/linux/slab_def.h
63446 @@ -66,10 +66,10 @@ struct kmem_cache {
63447 unsigned long node_allocs;
63448 unsigned long node_frees;
63449 unsigned long node_overflow;
63450 - atomic_t allochit;
63451 - atomic_t allocmiss;
63452 - atomic_t freehit;
63453 - atomic_t freemiss;
63454 + atomic_unchecked_t allochit;
63455 + atomic_unchecked_t allocmiss;
63456 + atomic_unchecked_t freehit;
63457 + atomic_unchecked_t freemiss;
63458
63459 /*
63460 * If debugging is enabled, then the allocator can add additional
63461 @@ -107,7 +107,7 @@ struct cache_sizes {
63462 extern struct cache_sizes malloc_sizes[];
63463
63464 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
63465 -void *__kmalloc(size_t size, gfp_t flags);
63466 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
63467
63468 #ifdef CONFIG_TRACING
63469 extern void *kmem_cache_alloc_trace(size_t size,
63470 @@ -160,7 +160,7 @@ found:
63471 }
63472
63473 #ifdef CONFIG_NUMA
63474 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
63475 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
63476 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
63477
63478 #ifdef CONFIG_TRACING
63479 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
63480 index 0ec00b3..39cb7fc 100644
63481 --- a/include/linux/slob_def.h
63482 +++ b/include/linux/slob_def.h
63483 @@ -9,7 +9,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
63484 return kmem_cache_alloc_node(cachep, flags, -1);
63485 }
63486
63487 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
63488 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
63489
63490 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
63491 {
63492 @@ -29,6 +29,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
63493 return __kmalloc_node(size, flags, -1);
63494 }
63495
63496 +static __always_inline void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
63497 static __always_inline void *__kmalloc(size_t size, gfp_t flags)
63498 {
63499 return kmalloc(size, flags);
63500 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
63501 index a32bcfd..a80ed70 100644
63502 --- a/include/linux/slub_def.h
63503 +++ b/include/linux/slub_def.h
63504 @@ -89,7 +89,7 @@ struct kmem_cache {
63505 struct kmem_cache_order_objects max;
63506 struct kmem_cache_order_objects min;
63507 gfp_t allocflags; /* gfp flags to use on each alloc */
63508 - int refcount; /* Refcount for slab cache destroy */
63509 + atomic_t refcount; /* Refcount for slab cache destroy */
63510 void (*ctor)(void *);
63511 int inuse; /* Offset to metadata */
63512 int align; /* Alignment */
63513 @@ -150,6 +150,7 @@ extern struct kmem_cache *kmalloc_caches[SLUB_PAGE_SHIFT];
63514 * Sorry that the following has to be that ugly but some versions of GCC
63515 * have trouble with constant propagation and loops.
63516 */
63517 +static __always_inline int kmalloc_index(size_t size) __size_overflow(1);
63518 static __always_inline int kmalloc_index(size_t size)
63519 {
63520 if (!size)
63521 @@ -215,7 +216,7 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
63522 }
63523
63524 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
63525 -void *__kmalloc(size_t size, gfp_t flags);
63526 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
63527
63528 static __always_inline void *
63529 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
63530 @@ -256,6 +257,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
63531 }
63532 #endif
63533
63534 +static __always_inline void *kmalloc_large(size_t size, gfp_t flags) __size_overflow(1);
63535 static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
63536 {
63537 unsigned int order = get_order(size);
63538 @@ -281,7 +283,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
63539 }
63540
63541 #ifdef CONFIG_NUMA
63542 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
63543 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
63544 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
63545
63546 #ifdef CONFIG_TRACING
63547 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
63548 index de8832d..0147b46 100644
63549 --- a/include/linux/sonet.h
63550 +++ b/include/linux/sonet.h
63551 @@ -61,7 +61,7 @@ struct sonet_stats {
63552 #include <linux/atomic.h>
63553
63554 struct k_sonet_stats {
63555 -#define __HANDLE_ITEM(i) atomic_t i
63556 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
63557 __SONET_ITEMS
63558 #undef __HANDLE_ITEM
63559 };
63560 diff --git a/include/linux/stddef.h b/include/linux/stddef.h
63561 index 6a40c76..1747b67 100644
63562 --- a/include/linux/stddef.h
63563 +++ b/include/linux/stddef.h
63564 @@ -3,14 +3,10 @@
63565
63566 #include <linux/compiler.h>
63567
63568 +#ifdef __KERNEL__
63569 +
63570 #undef NULL
63571 -#if defined(__cplusplus)
63572 -#define NULL 0
63573 -#else
63574 #define NULL ((void *)0)
63575 -#endif
63576 -
63577 -#ifdef __KERNEL__
63578
63579 enum {
63580 false = 0,
63581 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
63582 index 2c5993a..b0e79f0 100644
63583 --- a/include/linux/sunrpc/clnt.h
63584 +++ b/include/linux/sunrpc/clnt.h
63585 @@ -172,9 +172,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
63586 {
63587 switch (sap->sa_family) {
63588 case AF_INET:
63589 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
63590 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
63591 case AF_INET6:
63592 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
63593 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
63594 }
63595 return 0;
63596 }
63597 @@ -207,7 +207,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
63598 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
63599 const struct sockaddr *src)
63600 {
63601 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
63602 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
63603 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
63604
63605 dsin->sin_family = ssin->sin_family;
63606 @@ -310,7 +310,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
63607 if (sa->sa_family != AF_INET6)
63608 return 0;
63609
63610 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
63611 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
63612 }
63613
63614 #endif /* __KERNEL__ */
63615 diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h
63616 index e775689..9e206d9 100644
63617 --- a/include/linux/sunrpc/sched.h
63618 +++ b/include/linux/sunrpc/sched.h
63619 @@ -105,6 +105,7 @@ struct rpc_call_ops {
63620 void (*rpc_call_done)(struct rpc_task *, void *);
63621 void (*rpc_release)(void *);
63622 };
63623 +typedef struct rpc_call_ops __no_const rpc_call_ops_no_const;
63624
63625 struct rpc_task_setup {
63626 struct rpc_task *task;
63627 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
63628 index c14fe86..393245e 100644
63629 --- a/include/linux/sunrpc/svc_rdma.h
63630 +++ b/include/linux/sunrpc/svc_rdma.h
63631 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
63632 extern unsigned int svcrdma_max_requests;
63633 extern unsigned int svcrdma_max_req_size;
63634
63635 -extern atomic_t rdma_stat_recv;
63636 -extern atomic_t rdma_stat_read;
63637 -extern atomic_t rdma_stat_write;
63638 -extern atomic_t rdma_stat_sq_starve;
63639 -extern atomic_t rdma_stat_rq_starve;
63640 -extern atomic_t rdma_stat_rq_poll;
63641 -extern atomic_t rdma_stat_rq_prod;
63642 -extern atomic_t rdma_stat_sq_poll;
63643 -extern atomic_t rdma_stat_sq_prod;
63644 +extern atomic_unchecked_t rdma_stat_recv;
63645 +extern atomic_unchecked_t rdma_stat_read;
63646 +extern atomic_unchecked_t rdma_stat_write;
63647 +extern atomic_unchecked_t rdma_stat_sq_starve;
63648 +extern atomic_unchecked_t rdma_stat_rq_starve;
63649 +extern atomic_unchecked_t rdma_stat_rq_poll;
63650 +extern atomic_unchecked_t rdma_stat_rq_prod;
63651 +extern atomic_unchecked_t rdma_stat_sq_poll;
63652 +extern atomic_unchecked_t rdma_stat_sq_prod;
63653
63654 #define RPCRDMA_VERSION 1
63655
63656 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
63657 index bb9127d..34ab358 100644
63658 --- a/include/linux/sysctl.h
63659 +++ b/include/linux/sysctl.h
63660 @@ -155,7 +155,11 @@ enum
63661 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
63662 };
63663
63664 -
63665 +#ifdef CONFIG_PAX_SOFTMODE
63666 +enum {
63667 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
63668 +};
63669 +#endif
63670
63671 /* CTL_VM names: */
63672 enum
63673 @@ -968,6 +972,8 @@ typedef int proc_handler (struct ctl_table *ctl, int write,
63674
63675 extern int proc_dostring(struct ctl_table *, int,
63676 void __user *, size_t *, loff_t *);
63677 +extern int proc_dostring_modpriv(struct ctl_table *, int,
63678 + void __user *, size_t *, loff_t *);
63679 extern int proc_dointvec(struct ctl_table *, int,
63680 void __user *, size_t *, loff_t *);
63681 extern int proc_dointvec_minmax(struct ctl_table *, int,
63682 diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h
63683 index a71a292..51bd91d 100644
63684 --- a/include/linux/tracehook.h
63685 +++ b/include/linux/tracehook.h
63686 @@ -54,12 +54,12 @@ struct linux_binprm;
63687 /*
63688 * ptrace report for syscall entry and exit looks identical.
63689 */
63690 -static inline void ptrace_report_syscall(struct pt_regs *regs)
63691 +static inline int ptrace_report_syscall(struct pt_regs *regs)
63692 {
63693 int ptrace = current->ptrace;
63694
63695 if (!(ptrace & PT_PTRACED))
63696 - return;
63697 + return 0;
63698
63699 ptrace_notify(SIGTRAP | ((ptrace & PT_TRACESYSGOOD) ? 0x80 : 0));
63700
63701 @@ -72,6 +72,8 @@ static inline void ptrace_report_syscall(struct pt_regs *regs)
63702 send_sig(current->exit_code, current, 1);
63703 current->exit_code = 0;
63704 }
63705 +
63706 + return fatal_signal_pending(current);
63707 }
63708
63709 /**
63710 @@ -96,8 +98,7 @@ static inline void ptrace_report_syscall(struct pt_regs *regs)
63711 static inline __must_check int tracehook_report_syscall_entry(
63712 struct pt_regs *regs)
63713 {
63714 - ptrace_report_syscall(regs);
63715 - return 0;
63716 + return ptrace_report_syscall(regs);
63717 }
63718
63719 /**
63720 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
63721 index ff7dc08..893e1bd 100644
63722 --- a/include/linux/tty_ldisc.h
63723 +++ b/include/linux/tty_ldisc.h
63724 @@ -148,7 +148,7 @@ struct tty_ldisc_ops {
63725
63726 struct module *owner;
63727
63728 - int refcount;
63729 + atomic_t refcount;
63730 };
63731
63732 struct tty_ldisc {
63733 diff --git a/include/linux/types.h b/include/linux/types.h
63734 index e5fa503..df6e8a4 100644
63735 --- a/include/linux/types.h
63736 +++ b/include/linux/types.h
63737 @@ -214,10 +214,26 @@ typedef struct {
63738 int counter;
63739 } atomic_t;
63740
63741 +#ifdef CONFIG_PAX_REFCOUNT
63742 +typedef struct {
63743 + int counter;
63744 +} atomic_unchecked_t;
63745 +#else
63746 +typedef atomic_t atomic_unchecked_t;
63747 +#endif
63748 +
63749 #ifdef CONFIG_64BIT
63750 typedef struct {
63751 long counter;
63752 } atomic64_t;
63753 +
63754 +#ifdef CONFIG_PAX_REFCOUNT
63755 +typedef struct {
63756 + long counter;
63757 +} atomic64_unchecked_t;
63758 +#else
63759 +typedef atomic64_t atomic64_unchecked_t;
63760 +#endif
63761 #endif
63762
63763 struct list_head {
63764 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
63765 index 5ca0951..ab496a5 100644
63766 --- a/include/linux/uaccess.h
63767 +++ b/include/linux/uaccess.h
63768 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
63769 long ret; \
63770 mm_segment_t old_fs = get_fs(); \
63771 \
63772 - set_fs(KERNEL_DS); \
63773 pagefault_disable(); \
63774 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
63775 - pagefault_enable(); \
63776 + set_fs(KERNEL_DS); \
63777 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
63778 set_fs(old_fs); \
63779 + pagefault_enable(); \
63780 ret; \
63781 })
63782
63783 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
63784 index 99c1b4d..bb94261 100644
63785 --- a/include/linux/unaligned/access_ok.h
63786 +++ b/include/linux/unaligned/access_ok.h
63787 @@ -6,32 +6,32 @@
63788
63789 static inline u16 get_unaligned_le16(const void *p)
63790 {
63791 - return le16_to_cpup((__le16 *)p);
63792 + return le16_to_cpup((const __le16 *)p);
63793 }
63794
63795 static inline u32 get_unaligned_le32(const void *p)
63796 {
63797 - return le32_to_cpup((__le32 *)p);
63798 + return le32_to_cpup((const __le32 *)p);
63799 }
63800
63801 static inline u64 get_unaligned_le64(const void *p)
63802 {
63803 - return le64_to_cpup((__le64 *)p);
63804 + return le64_to_cpup((const __le64 *)p);
63805 }
63806
63807 static inline u16 get_unaligned_be16(const void *p)
63808 {
63809 - return be16_to_cpup((__be16 *)p);
63810 + return be16_to_cpup((const __be16 *)p);
63811 }
63812
63813 static inline u32 get_unaligned_be32(const void *p)
63814 {
63815 - return be32_to_cpup((__be32 *)p);
63816 + return be32_to_cpup((const __be32 *)p);
63817 }
63818
63819 static inline u64 get_unaligned_be64(const void *p)
63820 {
63821 - return be64_to_cpup((__be64 *)p);
63822 + return be64_to_cpup((const __be64 *)p);
63823 }
63824
63825 static inline void put_unaligned_le16(u16 val, void *p)
63826 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
63827 index 0d3f988..000f101 100644
63828 --- a/include/linux/usb/renesas_usbhs.h
63829 +++ b/include/linux/usb/renesas_usbhs.h
63830 @@ -39,7 +39,7 @@ enum {
63831 */
63832 struct renesas_usbhs_driver_callback {
63833 int (*notify_hotplug)(struct platform_device *pdev);
63834 -};
63835 +} __no_const;
63836
63837 /*
63838 * callback functions for platform
63839 @@ -97,7 +97,7 @@ struct renesas_usbhs_platform_callback {
63840 * VBUS control is needed for Host
63841 */
63842 int (*set_vbus)(struct platform_device *pdev, int enable);
63843 -};
63844 +} __no_const;
63845
63846 /*
63847 * parameters for renesas usbhs
63848 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
63849 index 6f8fbcf..8259001 100644
63850 --- a/include/linux/vermagic.h
63851 +++ b/include/linux/vermagic.h
63852 @@ -25,9 +25,35 @@
63853 #define MODULE_ARCH_VERMAGIC ""
63854 #endif
63855
63856 +#ifdef CONFIG_PAX_REFCOUNT
63857 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
63858 +#else
63859 +#define MODULE_PAX_REFCOUNT ""
63860 +#endif
63861 +
63862 +#ifdef CONSTIFY_PLUGIN
63863 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
63864 +#else
63865 +#define MODULE_CONSTIFY_PLUGIN ""
63866 +#endif
63867 +
63868 +#ifdef STACKLEAK_PLUGIN
63869 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
63870 +#else
63871 +#define MODULE_STACKLEAK_PLUGIN ""
63872 +#endif
63873 +
63874 +#ifdef CONFIG_GRKERNSEC
63875 +#define MODULE_GRSEC "GRSEC "
63876 +#else
63877 +#define MODULE_GRSEC ""
63878 +#endif
63879 +
63880 #define VERMAGIC_STRING \
63881 UTS_RELEASE " " \
63882 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
63883 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
63884 - MODULE_ARCH_VERMAGIC
63885 + MODULE_ARCH_VERMAGIC \
63886 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
63887 + MODULE_GRSEC
63888
63889 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
63890 index dcdfc2b..ec79ab5 100644
63891 --- a/include/linux/vmalloc.h
63892 +++ b/include/linux/vmalloc.h
63893 @@ -14,6 +14,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
63894 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
63895 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
63896 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
63897 +
63898 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
63899 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
63900 +#endif
63901 +
63902 /* bits [20..32] reserved for arch specific ioremap internals */
63903
63904 /*
63905 @@ -62,7 +67,7 @@ extern void *vmalloc_32_user(unsigned long size);
63906 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
63907 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
63908 unsigned long start, unsigned long end, gfp_t gfp_mask,
63909 - pgprot_t prot, int node, void *caller);
63910 + pgprot_t prot, int node, void *caller) __size_overflow(1);
63911 extern void vfree(const void *addr);
63912
63913 extern void *vmap(struct page **pages, unsigned int count,
63914 @@ -123,8 +128,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
63915 extern void free_vm_area(struct vm_struct *area);
63916
63917 /* for /dev/kmem */
63918 -extern long vread(char *buf, char *addr, unsigned long count);
63919 -extern long vwrite(char *buf, char *addr, unsigned long count);
63920 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
63921 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
63922
63923 /*
63924 * Internals. Dont't use..
63925 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
63926 index 65efb92..137adbb 100644
63927 --- a/include/linux/vmstat.h
63928 +++ b/include/linux/vmstat.h
63929 @@ -87,18 +87,18 @@ static inline void vm_events_fold_cpu(int cpu)
63930 /*
63931 * Zone based page accounting with per cpu differentials.
63932 */
63933 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
63934 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
63935
63936 static inline void zone_page_state_add(long x, struct zone *zone,
63937 enum zone_stat_item item)
63938 {
63939 - atomic_long_add(x, &zone->vm_stat[item]);
63940 - atomic_long_add(x, &vm_stat[item]);
63941 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
63942 + atomic_long_add_unchecked(x, &vm_stat[item]);
63943 }
63944
63945 static inline unsigned long global_page_state(enum zone_stat_item item)
63946 {
63947 - long x = atomic_long_read(&vm_stat[item]);
63948 + long x = atomic_long_read_unchecked(&vm_stat[item]);
63949 #ifdef CONFIG_SMP
63950 if (x < 0)
63951 x = 0;
63952 @@ -109,7 +109,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
63953 static inline unsigned long zone_page_state(struct zone *zone,
63954 enum zone_stat_item item)
63955 {
63956 - long x = atomic_long_read(&zone->vm_stat[item]);
63957 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
63958 #ifdef CONFIG_SMP
63959 if (x < 0)
63960 x = 0;
63961 @@ -126,7 +126,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
63962 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
63963 enum zone_stat_item item)
63964 {
63965 - long x = atomic_long_read(&zone->vm_stat[item]);
63966 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
63967
63968 #ifdef CONFIG_SMP
63969 int cpu;
63970 @@ -221,8 +221,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
63971
63972 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
63973 {
63974 - atomic_long_inc(&zone->vm_stat[item]);
63975 - atomic_long_inc(&vm_stat[item]);
63976 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
63977 + atomic_long_inc_unchecked(&vm_stat[item]);
63978 }
63979
63980 static inline void __inc_zone_page_state(struct page *page,
63981 @@ -233,8 +233,8 @@ static inline void __inc_zone_page_state(struct page *page,
63982
63983 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
63984 {
63985 - atomic_long_dec(&zone->vm_stat[item]);
63986 - atomic_long_dec(&vm_stat[item]);
63987 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
63988 + atomic_long_dec_unchecked(&vm_stat[item]);
63989 }
63990
63991 static inline void __dec_zone_page_state(struct page *page,
63992 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
63993 index e5d1220..ef6e406 100644
63994 --- a/include/linux/xattr.h
63995 +++ b/include/linux/xattr.h
63996 @@ -57,6 +57,11 @@
63997 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
63998 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
63999
64000 +/* User namespace */
64001 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
64002 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
64003 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
64004 +
64005 #ifdef __KERNEL__
64006
64007 #include <linux/types.h>
64008 diff --git a/include/media/saa7146_vv.h b/include/media/saa7146_vv.h
64009 index 4aeff96..b378cdc 100644
64010 --- a/include/media/saa7146_vv.h
64011 +++ b/include/media/saa7146_vv.h
64012 @@ -163,7 +163,7 @@ struct saa7146_ext_vv
64013 int (*std_callback)(struct saa7146_dev*, struct saa7146_standard *);
64014
64015 /* the extension can override this */
64016 - struct v4l2_ioctl_ops ops;
64017 + v4l2_ioctl_ops_no_const ops;
64018 /* pointer to the saa7146 core ops */
64019 const struct v4l2_ioctl_ops *core_ops;
64020
64021 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
64022 index c7c40f1..4f01585 100644
64023 --- a/include/media/v4l2-dev.h
64024 +++ b/include/media/v4l2-dev.h
64025 @@ -56,7 +56,7 @@ int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority local);
64026
64027
64028 struct v4l2_file_operations {
64029 - struct module *owner;
64030 + struct module * const owner;
64031 ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
64032 ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
64033 unsigned int (*poll) (struct file *, struct poll_table_struct *);
64034 @@ -68,6 +68,7 @@ struct v4l2_file_operations {
64035 int (*open) (struct file *);
64036 int (*release) (struct file *);
64037 };
64038 +typedef struct v4l2_file_operations __no_const v4l2_file_operations_no_const;
64039
64040 /*
64041 * Newer version of video_device, handled by videodev2.c
64042 diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
64043 index 3f5d60f..44210ed 100644
64044 --- a/include/media/v4l2-ioctl.h
64045 +++ b/include/media/v4l2-ioctl.h
64046 @@ -278,7 +278,7 @@ struct v4l2_ioctl_ops {
64047 long (*vidioc_default) (struct file *file, void *fh,
64048 bool valid_prio, int cmd, void *arg);
64049 };
64050 -
64051 +typedef struct v4l2_ioctl_ops __no_const v4l2_ioctl_ops_no_const;
64052
64053 /* v4l debugging and diagnostics */
64054
64055 diff --git a/include/net/caif/caif_hsi.h b/include/net/caif/caif_hsi.h
64056 index 8d55251..dfe5b0a 100644
64057 --- a/include/net/caif/caif_hsi.h
64058 +++ b/include/net/caif/caif_hsi.h
64059 @@ -98,7 +98,7 @@ struct cfhsi_drv {
64060 void (*rx_done_cb) (struct cfhsi_drv *drv);
64061 void (*wake_up_cb) (struct cfhsi_drv *drv);
64062 void (*wake_down_cb) (struct cfhsi_drv *drv);
64063 -};
64064 +} __no_const;
64065
64066 /* Structure implemented by HSI device. */
64067 struct cfhsi_dev {
64068 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
64069 index 9e5425b..8136ffc 100644
64070 --- a/include/net/caif/cfctrl.h
64071 +++ b/include/net/caif/cfctrl.h
64072 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
64073 void (*radioset_rsp)(void);
64074 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
64075 struct cflayer *client_layer);
64076 -};
64077 +} __no_const;
64078
64079 /* Link Setup Parameters for CAIF-Links. */
64080 struct cfctrl_link_param {
64081 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
64082 struct cfctrl {
64083 struct cfsrvl serv;
64084 struct cfctrl_rsp res;
64085 - atomic_t req_seq_no;
64086 - atomic_t rsp_seq_no;
64087 + atomic_unchecked_t req_seq_no;
64088 + atomic_unchecked_t rsp_seq_no;
64089 struct list_head list;
64090 /* Protects from simultaneous access to first_req list */
64091 spinlock_t info_list_lock;
64092 diff --git a/include/net/flow.h b/include/net/flow.h
64093 index 6c469db..7743b8e 100644
64094 --- a/include/net/flow.h
64095 +++ b/include/net/flow.h
64096 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
64097
64098 extern void flow_cache_flush(void);
64099 extern void flow_cache_flush_deferred(void);
64100 -extern atomic_t flow_cache_genid;
64101 +extern atomic_unchecked_t flow_cache_genid;
64102
64103 #endif
64104 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
64105 index b94765e..053f68b 100644
64106 --- a/include/net/inetpeer.h
64107 +++ b/include/net/inetpeer.h
64108 @@ -48,8 +48,8 @@ struct inet_peer {
64109 */
64110 union {
64111 struct {
64112 - atomic_t rid; /* Frag reception counter */
64113 - atomic_t ip_id_count; /* IP ID for the next packet */
64114 + atomic_unchecked_t rid; /* Frag reception counter */
64115 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
64116 __u32 tcp_ts;
64117 __u32 tcp_ts_stamp;
64118 };
64119 @@ -115,11 +115,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
64120 more++;
64121 inet_peer_refcheck(p);
64122 do {
64123 - old = atomic_read(&p->ip_id_count);
64124 + old = atomic_read_unchecked(&p->ip_id_count);
64125 new = old + more;
64126 if (!new)
64127 new = 1;
64128 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
64129 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
64130 return new;
64131 }
64132
64133 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
64134 index 10422ef..662570f 100644
64135 --- a/include/net/ip_fib.h
64136 +++ b/include/net/ip_fib.h
64137 @@ -146,7 +146,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
64138
64139 #define FIB_RES_SADDR(net, res) \
64140 ((FIB_RES_NH(res).nh_saddr_genid == \
64141 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
64142 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
64143 FIB_RES_NH(res).nh_saddr : \
64144 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
64145 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
64146 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
64147 index ebe517f..1bd286b 100644
64148 --- a/include/net/ip_vs.h
64149 +++ b/include/net/ip_vs.h
64150 @@ -509,7 +509,7 @@ struct ip_vs_conn {
64151 struct ip_vs_conn *control; /* Master control connection */
64152 atomic_t n_control; /* Number of controlled ones */
64153 struct ip_vs_dest *dest; /* real server */
64154 - atomic_t in_pkts; /* incoming packet counter */
64155 + atomic_unchecked_t in_pkts; /* incoming packet counter */
64156
64157 /* packet transmitter for different forwarding methods. If it
64158 mangles the packet, it must return NF_DROP or better NF_STOLEN,
64159 @@ -647,7 +647,7 @@ struct ip_vs_dest {
64160 __be16 port; /* port number of the server */
64161 union nf_inet_addr addr; /* IP address of the server */
64162 volatile unsigned flags; /* dest status flags */
64163 - atomic_t conn_flags; /* flags to copy to conn */
64164 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
64165 atomic_t weight; /* server weight */
64166
64167 atomic_t refcnt; /* reference counter */
64168 diff --git a/include/net/irda/ircomm_core.h b/include/net/irda/ircomm_core.h
64169 index 69b610a..fe3962c 100644
64170 --- a/include/net/irda/ircomm_core.h
64171 +++ b/include/net/irda/ircomm_core.h
64172 @@ -51,7 +51,7 @@ typedef struct {
64173 int (*connect_response)(struct ircomm_cb *, struct sk_buff *);
64174 int (*disconnect_request)(struct ircomm_cb *, struct sk_buff *,
64175 struct ircomm_info *);
64176 -} call_t;
64177 +} __no_const call_t;
64178
64179 struct ircomm_cb {
64180 irda_queue_t queue;
64181 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
64182 index 59ba38bc..d515662 100644
64183 --- a/include/net/irda/ircomm_tty.h
64184 +++ b/include/net/irda/ircomm_tty.h
64185 @@ -35,6 +35,7 @@
64186 #include <linux/termios.h>
64187 #include <linux/timer.h>
64188 #include <linux/tty.h> /* struct tty_struct */
64189 +#include <asm/local.h>
64190
64191 #include <net/irda/irias_object.h>
64192 #include <net/irda/ircomm_core.h>
64193 @@ -105,8 +106,8 @@ struct ircomm_tty_cb {
64194 unsigned short close_delay;
64195 unsigned short closing_wait; /* time to wait before closing */
64196
64197 - int open_count;
64198 - int blocked_open; /* # of blocked opens */
64199 + local_t open_count;
64200 + local_t blocked_open; /* # of blocked opens */
64201
64202 /* Protect concurent access to :
64203 * o self->open_count
64204 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
64205 index 0954ec9..7413562 100644
64206 --- a/include/net/iucv/af_iucv.h
64207 +++ b/include/net/iucv/af_iucv.h
64208 @@ -138,7 +138,7 @@ struct iucv_sock {
64209 struct iucv_sock_list {
64210 struct hlist_head head;
64211 rwlock_t lock;
64212 - atomic_t autobind_name;
64213 + atomic_unchecked_t autobind_name;
64214 };
64215
64216 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
64217 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
64218 index 34c996f..bb3b4d4 100644
64219 --- a/include/net/neighbour.h
64220 +++ b/include/net/neighbour.h
64221 @@ -123,7 +123,7 @@ struct neigh_ops {
64222 void (*error_report)(struct neighbour *, struct sk_buff *);
64223 int (*output)(struct neighbour *, struct sk_buff *);
64224 int (*connected_output)(struct neighbour *, struct sk_buff *);
64225 -};
64226 +} __do_const;
64227
64228 struct pneigh_entry {
64229 struct pneigh_entry *next;
64230 diff --git a/include/net/netlink.h b/include/net/netlink.h
64231 index cb1f350..3279d2c 100644
64232 --- a/include/net/netlink.h
64233 +++ b/include/net/netlink.h
64234 @@ -569,7 +569,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
64235 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
64236 {
64237 if (mark)
64238 - skb_trim(skb, (unsigned char *) mark - skb->data);
64239 + skb_trim(skb, (const unsigned char *) mark - skb->data);
64240 }
64241
64242 /**
64243 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
64244 index bbd023a..97c6d0d 100644
64245 --- a/include/net/netns/ipv4.h
64246 +++ b/include/net/netns/ipv4.h
64247 @@ -57,8 +57,8 @@ struct netns_ipv4 {
64248 unsigned int sysctl_ping_group_range[2];
64249 long sysctl_tcp_mem[3];
64250
64251 - atomic_t rt_genid;
64252 - atomic_t dev_addr_genid;
64253 + atomic_unchecked_t rt_genid;
64254 + atomic_unchecked_t dev_addr_genid;
64255
64256 #ifdef CONFIG_IP_MROUTE
64257 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
64258 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
64259 index d368561..96aaa17 100644
64260 --- a/include/net/sctp/sctp.h
64261 +++ b/include/net/sctp/sctp.h
64262 @@ -318,9 +318,9 @@ do { \
64263
64264 #else /* SCTP_DEBUG */
64265
64266 -#define SCTP_DEBUG_PRINTK(whatever...)
64267 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
64268 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
64269 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
64270 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
64271 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
64272 #define SCTP_ENABLE_DEBUG
64273 #define SCTP_DISABLE_DEBUG
64274 #define SCTP_ASSERT(expr, str, func)
64275 diff --git a/include/net/sock.h b/include/net/sock.h
64276 index 91c1c8b..15ae923 100644
64277 --- a/include/net/sock.h
64278 +++ b/include/net/sock.h
64279 @@ -299,7 +299,7 @@ struct sock {
64280 #ifdef CONFIG_RPS
64281 __u32 sk_rxhash;
64282 #endif
64283 - atomic_t sk_drops;
64284 + atomic_unchecked_t sk_drops;
64285 int sk_rcvbuf;
64286
64287 struct sk_filter __rcu *sk_filter;
64288 @@ -1660,7 +1660,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
64289 }
64290
64291 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
64292 - char __user *from, char *to,
64293 + char __user *from, unsigned char *to,
64294 int copy, int offset)
64295 {
64296 if (skb->ip_summed == CHECKSUM_NONE) {
64297 diff --git a/include/net/tcp.h b/include/net/tcp.h
64298 index 2d80c29..aa07caf 100644
64299 --- a/include/net/tcp.h
64300 +++ b/include/net/tcp.h
64301 @@ -1426,7 +1426,7 @@ struct tcp_seq_afinfo {
64302 char *name;
64303 sa_family_t family;
64304 const struct file_operations *seq_fops;
64305 - struct seq_operations seq_ops;
64306 + seq_operations_no_const seq_ops;
64307 };
64308
64309 struct tcp_iter_state {
64310 diff --git a/include/net/udp.h b/include/net/udp.h
64311 index e39592f..fef9680 100644
64312 --- a/include/net/udp.h
64313 +++ b/include/net/udp.h
64314 @@ -243,7 +243,7 @@ struct udp_seq_afinfo {
64315 sa_family_t family;
64316 struct udp_table *udp_table;
64317 const struct file_operations *seq_fops;
64318 - struct seq_operations seq_ops;
64319 + seq_operations_no_const seq_ops;
64320 };
64321
64322 struct udp_iter_state {
64323 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
64324 index 89174e2..1f82598 100644
64325 --- a/include/net/xfrm.h
64326 +++ b/include/net/xfrm.h
64327 @@ -505,7 +505,7 @@ struct xfrm_policy {
64328 struct timer_list timer;
64329
64330 struct flow_cache_object flo;
64331 - atomic_t genid;
64332 + atomic_unchecked_t genid;
64333 u32 priority;
64334 u32 index;
64335 struct xfrm_mark mark;
64336 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
64337 index 1a046b1..ee0bef0 100644
64338 --- a/include/rdma/iw_cm.h
64339 +++ b/include/rdma/iw_cm.h
64340 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
64341 int backlog);
64342
64343 int (*destroy_listen)(struct iw_cm_id *cm_id);
64344 -};
64345 +} __no_const;
64346
64347 /**
64348 * iw_create_cm_id - Create an IW CM identifier.
64349 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
64350 index 6a3922f..0b73022 100644
64351 --- a/include/scsi/libfc.h
64352 +++ b/include/scsi/libfc.h
64353 @@ -748,6 +748,7 @@ struct libfc_function_template {
64354 */
64355 void (*disc_stop_final) (struct fc_lport *);
64356 };
64357 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
64358
64359 /**
64360 * struct fc_disc - Discovery context
64361 @@ -851,7 +852,7 @@ struct fc_lport {
64362 struct fc_vport *vport;
64363
64364 /* Operational Information */
64365 - struct libfc_function_template tt;
64366 + libfc_function_template_no_const tt;
64367 u8 link_up;
64368 u8 qfull;
64369 enum fc_lport_state state;
64370 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
64371 index 77273f2..dd4031f 100644
64372 --- a/include/scsi/scsi_device.h
64373 +++ b/include/scsi/scsi_device.h
64374 @@ -161,9 +161,9 @@ struct scsi_device {
64375 unsigned int max_device_blocked; /* what device_blocked counts down from */
64376 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
64377
64378 - atomic_t iorequest_cnt;
64379 - atomic_t iodone_cnt;
64380 - atomic_t ioerr_cnt;
64381 + atomic_unchecked_t iorequest_cnt;
64382 + atomic_unchecked_t iodone_cnt;
64383 + atomic_unchecked_t ioerr_cnt;
64384
64385 struct device sdev_gendev,
64386 sdev_dev;
64387 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
64388 index 2a65167..91e01f8 100644
64389 --- a/include/scsi/scsi_transport_fc.h
64390 +++ b/include/scsi/scsi_transport_fc.h
64391 @@ -711,7 +711,7 @@ struct fc_function_template {
64392 unsigned long show_host_system_hostname:1;
64393
64394 unsigned long disable_target_scan:1;
64395 -};
64396 +} __do_const;
64397
64398
64399 /**
64400 diff --git a/include/sound/ak4xxx-adda.h b/include/sound/ak4xxx-adda.h
64401 index 030b87c..98a6954 100644
64402 --- a/include/sound/ak4xxx-adda.h
64403 +++ b/include/sound/ak4xxx-adda.h
64404 @@ -35,7 +35,7 @@ struct snd_ak4xxx_ops {
64405 void (*write)(struct snd_akm4xxx *ak, int chip, unsigned char reg,
64406 unsigned char val);
64407 void (*set_rate_val)(struct snd_akm4xxx *ak, unsigned int rate);
64408 -};
64409 +} __no_const;
64410
64411 #define AK4XXX_IMAGE_SIZE (AK4XXX_MAX_CHIPS * 16) /* 64 bytes */
64412
64413 diff --git a/include/sound/hwdep.h b/include/sound/hwdep.h
64414 index 8c05e47..2b5df97 100644
64415 --- a/include/sound/hwdep.h
64416 +++ b/include/sound/hwdep.h
64417 @@ -49,7 +49,7 @@ struct snd_hwdep_ops {
64418 struct snd_hwdep_dsp_status *status);
64419 int (*dsp_load)(struct snd_hwdep *hw,
64420 struct snd_hwdep_dsp_image *image);
64421 -};
64422 +} __no_const;
64423
64424 struct snd_hwdep {
64425 struct snd_card *card;
64426 diff --git a/include/sound/info.h b/include/sound/info.h
64427 index 9ca1a49..aba1728 100644
64428 --- a/include/sound/info.h
64429 +++ b/include/sound/info.h
64430 @@ -44,7 +44,7 @@ struct snd_info_entry_text {
64431 struct snd_info_buffer *buffer);
64432 void (*write)(struct snd_info_entry *entry,
64433 struct snd_info_buffer *buffer);
64434 -};
64435 +} __no_const;
64436
64437 struct snd_info_entry_ops {
64438 int (*open)(struct snd_info_entry *entry,
64439 diff --git a/include/sound/pcm.h b/include/sound/pcm.h
64440 index 0cf91b2..b70cae4 100644
64441 --- a/include/sound/pcm.h
64442 +++ b/include/sound/pcm.h
64443 @@ -81,6 +81,7 @@ struct snd_pcm_ops {
64444 int (*mmap)(struct snd_pcm_substream *substream, struct vm_area_struct *vma);
64445 int (*ack)(struct snd_pcm_substream *substream);
64446 };
64447 +typedef struct snd_pcm_ops __no_const snd_pcm_ops_no_const;
64448
64449 /*
64450 *
64451 diff --git a/include/sound/sb16_csp.h b/include/sound/sb16_csp.h
64452 index af1b49e..a5d55a5 100644
64453 --- a/include/sound/sb16_csp.h
64454 +++ b/include/sound/sb16_csp.h
64455 @@ -146,7 +146,7 @@ struct snd_sb_csp_ops {
64456 int (*csp_start) (struct snd_sb_csp * p, int sample_width, int channels);
64457 int (*csp_stop) (struct snd_sb_csp * p);
64458 int (*csp_qsound_transfer) (struct snd_sb_csp * p);
64459 -};
64460 +} __no_const;
64461
64462 /*
64463 * CSP private data
64464 diff --git a/include/sound/soc.h b/include/sound/soc.h
64465 index 0992dff..bb366fe 100644
64466 --- a/include/sound/soc.h
64467 +++ b/include/sound/soc.h
64468 @@ -682,7 +682,7 @@ struct snd_soc_platform_driver {
64469 /* platform IO - used for platform DAPM */
64470 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
64471 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
64472 -};
64473 +} __do_const;
64474
64475 struct snd_soc_platform {
64476 const char *name;
64477 @@ -852,7 +852,7 @@ struct snd_soc_pcm_runtime {
64478 struct snd_soc_dai_link *dai_link;
64479 struct mutex pcm_mutex;
64480 enum snd_soc_pcm_subclass pcm_subclass;
64481 - struct snd_pcm_ops ops;
64482 + snd_pcm_ops_no_const ops;
64483
64484 unsigned int complete:1;
64485 unsigned int dev_registered:1;
64486 diff --git a/include/sound/ymfpci.h b/include/sound/ymfpci.h
64487 index 444cd6b..3327cc5 100644
64488 --- a/include/sound/ymfpci.h
64489 +++ b/include/sound/ymfpci.h
64490 @@ -358,7 +358,7 @@ struct snd_ymfpci {
64491 spinlock_t reg_lock;
64492 spinlock_t voice_lock;
64493 wait_queue_head_t interrupt_sleep;
64494 - atomic_t interrupt_sleep_count;
64495 + atomic_unchecked_t interrupt_sleep_count;
64496 struct snd_info_entry *proc_entry;
64497 const struct firmware *dsp_microcode;
64498 const struct firmware *controller_microcode;
64499 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
64500 index fe73eb8..56388b1 100644
64501 --- a/include/target/target_core_base.h
64502 +++ b/include/target/target_core_base.h
64503 @@ -443,7 +443,7 @@ struct t10_reservation_ops {
64504 int (*t10_seq_non_holder)(struct se_cmd *, unsigned char *, u32);
64505 int (*t10_pr_register)(struct se_cmd *);
64506 int (*t10_pr_clear)(struct se_cmd *);
64507 -};
64508 +} __no_const;
64509
64510 struct t10_reservation {
64511 /* Reservation effects all target ports */
64512 @@ -561,8 +561,8 @@ struct se_cmd {
64513 atomic_t t_se_count;
64514 atomic_t t_task_cdbs_left;
64515 atomic_t t_task_cdbs_ex_left;
64516 - atomic_t t_task_cdbs_sent;
64517 - atomic_t t_transport_aborted;
64518 + atomic_unchecked_t t_task_cdbs_sent;
64519 + atomic_unchecked_t t_transport_aborted;
64520 atomic_t t_transport_active;
64521 atomic_t t_transport_complete;
64522 atomic_t t_transport_queue_active;
64523 @@ -799,7 +799,7 @@ struct se_device {
64524 spinlock_t stats_lock;
64525 /* Active commands on this virtual SE device */
64526 atomic_t simple_cmds;
64527 - atomic_t dev_ordered_id;
64528 + atomic_unchecked_t dev_ordered_id;
64529 atomic_t execute_tasks;
64530 atomic_t dev_ordered_sync;
64531 atomic_t dev_qf_count;
64532 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
64533 index 1c09820..7f5ec79 100644
64534 --- a/include/trace/events/irq.h
64535 +++ b/include/trace/events/irq.h
64536 @@ -36,7 +36,7 @@ struct softirq_action;
64537 */
64538 TRACE_EVENT(irq_handler_entry,
64539
64540 - TP_PROTO(int irq, struct irqaction *action),
64541 + TP_PROTO(int irq, const struct irqaction *action),
64542
64543 TP_ARGS(irq, action),
64544
64545 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
64546 */
64547 TRACE_EVENT(irq_handler_exit,
64548
64549 - TP_PROTO(int irq, struct irqaction *action, int ret),
64550 + TP_PROTO(int irq, const struct irqaction *action, int ret),
64551
64552 TP_ARGS(irq, action, ret),
64553
64554 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
64555 index c41f308..6918de3 100644
64556 --- a/include/video/udlfb.h
64557 +++ b/include/video/udlfb.h
64558 @@ -52,10 +52,10 @@ struct dlfb_data {
64559 u32 pseudo_palette[256];
64560 int blank_mode; /*one of FB_BLANK_ */
64561 /* blit-only rendering path metrics, exposed through sysfs */
64562 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
64563 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
64564 - atomic_t bytes_sent; /* to usb, after compression including overhead */
64565 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
64566 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
64567 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
64568 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
64569 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
64570 };
64571
64572 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
64573 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
64574 index 0993a22..32ba2fe 100644
64575 --- a/include/video/uvesafb.h
64576 +++ b/include/video/uvesafb.h
64577 @@ -177,6 +177,7 @@ struct uvesafb_par {
64578 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
64579 u8 pmi_setpal; /* PMI for palette changes */
64580 u16 *pmi_base; /* protected mode interface location */
64581 + u8 *pmi_code; /* protected mode code location */
64582 void *pmi_start;
64583 void *pmi_pal;
64584 u8 *vbe_state_orig; /*
64585 diff --git a/init/Kconfig b/init/Kconfig
64586 index 3f42cd6..613f41d 100644
64587 --- a/init/Kconfig
64588 +++ b/init/Kconfig
64589 @@ -799,6 +799,7 @@ endif # CGROUPS
64590
64591 config CHECKPOINT_RESTORE
64592 bool "Checkpoint/restore support" if EXPERT
64593 + depends on !GRKERNSEC
64594 default n
64595 help
64596 Enables additional kernel features in a sake of checkpoint/restore.
64597 @@ -1249,7 +1250,7 @@ config SLUB_DEBUG
64598
64599 config COMPAT_BRK
64600 bool "Disable heap randomization"
64601 - default y
64602 + default n
64603 help
64604 Randomizing heap placement makes heap exploits harder, but it
64605 also breaks ancient binaries (including anything libc5 based).
64606 diff --git a/init/do_mounts.c b/init/do_mounts.c
64607 index bf6edbf..4e5809c 100644
64608 --- a/init/do_mounts.c
64609 +++ b/init/do_mounts.c
64610 @@ -326,11 +326,11 @@ static void __init get_fs_names(char *page)
64611 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
64612 {
64613 struct super_block *s;
64614 - int err = sys_mount(name, "/root", fs, flags, data);
64615 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
64616 if (err)
64617 return err;
64618
64619 - sys_chdir((const char __user __force *)"/root");
64620 + sys_chdir((const char __force_user *)"/root");
64621 s = current->fs->pwd.dentry->d_sb;
64622 ROOT_DEV = s->s_dev;
64623 printk(KERN_INFO
64624 @@ -450,18 +450,18 @@ void __init change_floppy(char *fmt, ...)
64625 va_start(args, fmt);
64626 vsprintf(buf, fmt, args);
64627 va_end(args);
64628 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
64629 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
64630 if (fd >= 0) {
64631 sys_ioctl(fd, FDEJECT, 0);
64632 sys_close(fd);
64633 }
64634 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
64635 - fd = sys_open("/dev/console", O_RDWR, 0);
64636 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
64637 if (fd >= 0) {
64638 sys_ioctl(fd, TCGETS, (long)&termios);
64639 termios.c_lflag &= ~ICANON;
64640 sys_ioctl(fd, TCSETSF, (long)&termios);
64641 - sys_read(fd, &c, 1);
64642 + sys_read(fd, (char __user *)&c, 1);
64643 termios.c_lflag |= ICANON;
64644 sys_ioctl(fd, TCSETSF, (long)&termios);
64645 sys_close(fd);
64646 @@ -555,6 +555,6 @@ void __init prepare_namespace(void)
64647 mount_root();
64648 out:
64649 devtmpfs_mount("dev");
64650 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
64651 - sys_chroot((const char __user __force *)".");
64652 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
64653 + sys_chroot((const char __force_user *)".");
64654 }
64655 diff --git a/init/do_mounts.h b/init/do_mounts.h
64656 index f5b978a..69dbfe8 100644
64657 --- a/init/do_mounts.h
64658 +++ b/init/do_mounts.h
64659 @@ -15,15 +15,15 @@ extern int root_mountflags;
64660
64661 static inline int create_dev(char *name, dev_t dev)
64662 {
64663 - sys_unlink(name);
64664 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
64665 + sys_unlink((char __force_user *)name);
64666 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
64667 }
64668
64669 #if BITS_PER_LONG == 32
64670 static inline u32 bstat(char *name)
64671 {
64672 struct stat64 stat;
64673 - if (sys_stat64(name, &stat) != 0)
64674 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
64675 return 0;
64676 if (!S_ISBLK(stat.st_mode))
64677 return 0;
64678 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
64679 static inline u32 bstat(char *name)
64680 {
64681 struct stat stat;
64682 - if (sys_newstat(name, &stat) != 0)
64683 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
64684 return 0;
64685 if (!S_ISBLK(stat.st_mode))
64686 return 0;
64687 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
64688 index 3098a38..253064e 100644
64689 --- a/init/do_mounts_initrd.c
64690 +++ b/init/do_mounts_initrd.c
64691 @@ -44,13 +44,13 @@ static void __init handle_initrd(void)
64692 create_dev("/dev/root.old", Root_RAM0);
64693 /* mount initrd on rootfs' /root */
64694 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
64695 - sys_mkdir("/old", 0700);
64696 - root_fd = sys_open("/", 0, 0);
64697 - old_fd = sys_open("/old", 0, 0);
64698 + sys_mkdir((const char __force_user *)"/old", 0700);
64699 + root_fd = sys_open((const char __force_user *)"/", 0, 0);
64700 + old_fd = sys_open((const char __force_user *)"/old", 0, 0);
64701 /* move initrd over / and chdir/chroot in initrd root */
64702 - sys_chdir("/root");
64703 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
64704 - sys_chroot(".");
64705 + sys_chdir((const char __force_user *)"/root");
64706 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
64707 + sys_chroot((const char __force_user *)".");
64708
64709 /*
64710 * In case that a resume from disk is carried out by linuxrc or one of
64711 @@ -67,15 +67,15 @@ static void __init handle_initrd(void)
64712
64713 /* move initrd to rootfs' /old */
64714 sys_fchdir(old_fd);
64715 - sys_mount("/", ".", NULL, MS_MOVE, NULL);
64716 + sys_mount((char __force_user *)"/", (char __force_user *)".", NULL, MS_MOVE, NULL);
64717 /* switch root and cwd back to / of rootfs */
64718 sys_fchdir(root_fd);
64719 - sys_chroot(".");
64720 + sys_chroot((const char __force_user *)".");
64721 sys_close(old_fd);
64722 sys_close(root_fd);
64723
64724 if (new_decode_dev(real_root_dev) == Root_RAM0) {
64725 - sys_chdir("/old");
64726 + sys_chdir((const char __force_user *)"/old");
64727 return;
64728 }
64729
64730 @@ -83,17 +83,17 @@ static void __init handle_initrd(void)
64731 mount_root();
64732
64733 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
64734 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
64735 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
64736 if (!error)
64737 printk("okay\n");
64738 else {
64739 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
64740 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
64741 if (error == -ENOENT)
64742 printk("/initrd does not exist. Ignored.\n");
64743 else
64744 printk("failed\n");
64745 printk(KERN_NOTICE "Unmounting old root\n");
64746 - sys_umount("/old", MNT_DETACH);
64747 + sys_umount((char __force_user *)"/old", MNT_DETACH);
64748 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
64749 if (fd < 0) {
64750 error = fd;
64751 @@ -116,11 +116,11 @@ int __init initrd_load(void)
64752 * mounted in the normal path.
64753 */
64754 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
64755 - sys_unlink("/initrd.image");
64756 + sys_unlink((const char __force_user *)"/initrd.image");
64757 handle_initrd();
64758 return 1;
64759 }
64760 }
64761 - sys_unlink("/initrd.image");
64762 + sys_unlink((const char __force_user *)"/initrd.image");
64763 return 0;
64764 }
64765 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
64766 index 32c4799..c27ee74 100644
64767 --- a/init/do_mounts_md.c
64768 +++ b/init/do_mounts_md.c
64769 @@ -170,7 +170,7 @@ static void __init md_setup_drive(void)
64770 partitioned ? "_d" : "", minor,
64771 md_setup_args[ent].device_names);
64772
64773 - fd = sys_open(name, 0, 0);
64774 + fd = sys_open((char __force_user *)name, 0, 0);
64775 if (fd < 0) {
64776 printk(KERN_ERR "md: open failed - cannot start "
64777 "array %s\n", name);
64778 @@ -233,7 +233,7 @@ static void __init md_setup_drive(void)
64779 * array without it
64780 */
64781 sys_close(fd);
64782 - fd = sys_open(name, 0, 0);
64783 + fd = sys_open((char __force_user *)name, 0, 0);
64784 sys_ioctl(fd, BLKRRPART, 0);
64785 }
64786 sys_close(fd);
64787 @@ -283,7 +283,7 @@ static void __init autodetect_raid(void)
64788
64789 wait_for_device_probe();
64790
64791 - fd = sys_open((const char __user __force *) "/dev/md0", 0, 0);
64792 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
64793 if (fd >= 0) {
64794 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
64795 sys_close(fd);
64796 diff --git a/init/initramfs.c b/init/initramfs.c
64797 index 8216c30..25e8e32 100644
64798 --- a/init/initramfs.c
64799 +++ b/init/initramfs.c
64800 @@ -74,7 +74,7 @@ static void __init free_hash(void)
64801 }
64802 }
64803
64804 -static long __init do_utime(char __user *filename, time_t mtime)
64805 +static long __init do_utime(__force char __user *filename, time_t mtime)
64806 {
64807 struct timespec t[2];
64808
64809 @@ -109,7 +109,7 @@ static void __init dir_utime(void)
64810 struct dir_entry *de, *tmp;
64811 list_for_each_entry_safe(de, tmp, &dir_list, list) {
64812 list_del(&de->list);
64813 - do_utime(de->name, de->mtime);
64814 + do_utime((char __force_user *)de->name, de->mtime);
64815 kfree(de->name);
64816 kfree(de);
64817 }
64818 @@ -271,7 +271,7 @@ static int __init maybe_link(void)
64819 if (nlink >= 2) {
64820 char *old = find_link(major, minor, ino, mode, collected);
64821 if (old)
64822 - return (sys_link(old, collected) < 0) ? -1 : 1;
64823 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
64824 }
64825 return 0;
64826 }
64827 @@ -280,11 +280,11 @@ static void __init clean_path(char *path, umode_t mode)
64828 {
64829 struct stat st;
64830
64831 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
64832 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
64833 if (S_ISDIR(st.st_mode))
64834 - sys_rmdir(path);
64835 + sys_rmdir((char __force_user *)path);
64836 else
64837 - sys_unlink(path);
64838 + sys_unlink((char __force_user *)path);
64839 }
64840 }
64841
64842 @@ -305,7 +305,7 @@ static int __init do_name(void)
64843 int openflags = O_WRONLY|O_CREAT;
64844 if (ml != 1)
64845 openflags |= O_TRUNC;
64846 - wfd = sys_open(collected, openflags, mode);
64847 + wfd = sys_open((char __force_user *)collected, openflags, mode);
64848
64849 if (wfd >= 0) {
64850 sys_fchown(wfd, uid, gid);
64851 @@ -317,17 +317,17 @@ static int __init do_name(void)
64852 }
64853 }
64854 } else if (S_ISDIR(mode)) {
64855 - sys_mkdir(collected, mode);
64856 - sys_chown(collected, uid, gid);
64857 - sys_chmod(collected, mode);
64858 + sys_mkdir((char __force_user *)collected, mode);
64859 + sys_chown((char __force_user *)collected, uid, gid);
64860 + sys_chmod((char __force_user *)collected, mode);
64861 dir_add(collected, mtime);
64862 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
64863 S_ISFIFO(mode) || S_ISSOCK(mode)) {
64864 if (maybe_link() == 0) {
64865 - sys_mknod(collected, mode, rdev);
64866 - sys_chown(collected, uid, gid);
64867 - sys_chmod(collected, mode);
64868 - do_utime(collected, mtime);
64869 + sys_mknod((char __force_user *)collected, mode, rdev);
64870 + sys_chown((char __force_user *)collected, uid, gid);
64871 + sys_chmod((char __force_user *)collected, mode);
64872 + do_utime((char __force_user *)collected, mtime);
64873 }
64874 }
64875 return 0;
64876 @@ -336,15 +336,15 @@ static int __init do_name(void)
64877 static int __init do_copy(void)
64878 {
64879 if (count >= body_len) {
64880 - sys_write(wfd, victim, body_len);
64881 + sys_write(wfd, (char __force_user *)victim, body_len);
64882 sys_close(wfd);
64883 - do_utime(vcollected, mtime);
64884 + do_utime((char __force_user *)vcollected, mtime);
64885 kfree(vcollected);
64886 eat(body_len);
64887 state = SkipIt;
64888 return 0;
64889 } else {
64890 - sys_write(wfd, victim, count);
64891 + sys_write(wfd, (char __force_user *)victim, count);
64892 body_len -= count;
64893 eat(count);
64894 return 1;
64895 @@ -355,9 +355,9 @@ static int __init do_symlink(void)
64896 {
64897 collected[N_ALIGN(name_len) + body_len] = '\0';
64898 clean_path(collected, 0);
64899 - sys_symlink(collected + N_ALIGN(name_len), collected);
64900 - sys_lchown(collected, uid, gid);
64901 - do_utime(collected, mtime);
64902 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
64903 + sys_lchown((char __force_user *)collected, uid, gid);
64904 + do_utime((char __force_user *)collected, mtime);
64905 state = SkipIt;
64906 next_state = Reset;
64907 return 0;
64908 diff --git a/init/main.c b/init/main.c
64909 index ff49a6d..5fa0429 100644
64910 --- a/init/main.c
64911 +++ b/init/main.c
64912 @@ -96,6 +96,8 @@ static inline void mark_rodata_ro(void) { }
64913 extern void tc_init(void);
64914 #endif
64915
64916 +extern void grsecurity_init(void);
64917 +
64918 /*
64919 * Debug helper: via this flag we know that we are in 'early bootup code'
64920 * where only the boot processor is running with IRQ disabled. This means
64921 @@ -149,6 +151,49 @@ static int __init set_reset_devices(char *str)
64922
64923 __setup("reset_devices", set_reset_devices);
64924
64925 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
64926 +extern char pax_enter_kernel_user[];
64927 +extern char pax_exit_kernel_user[];
64928 +extern pgdval_t clone_pgd_mask;
64929 +#endif
64930 +
64931 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
64932 +static int __init setup_pax_nouderef(char *str)
64933 +{
64934 +#ifdef CONFIG_X86_32
64935 + unsigned int cpu;
64936 + struct desc_struct *gdt;
64937 +
64938 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
64939 + gdt = get_cpu_gdt_table(cpu);
64940 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
64941 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
64942 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
64943 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
64944 + }
64945 + asm("mov %0, %%ds; mov %0, %%es; mov %0, %%ss" : : "r" (__KERNEL_DS) : "memory");
64946 +#else
64947 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
64948 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
64949 + clone_pgd_mask = ~(pgdval_t)0UL;
64950 +#endif
64951 +
64952 + return 0;
64953 +}
64954 +early_param("pax_nouderef", setup_pax_nouderef);
64955 +#endif
64956 +
64957 +#ifdef CONFIG_PAX_SOFTMODE
64958 +int pax_softmode;
64959 +
64960 +static int __init setup_pax_softmode(char *str)
64961 +{
64962 + get_option(&str, &pax_softmode);
64963 + return 1;
64964 +}
64965 +__setup("pax_softmode=", setup_pax_softmode);
64966 +#endif
64967 +
64968 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
64969 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
64970 static const char *panic_later, *panic_param;
64971 @@ -675,6 +720,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
64972 {
64973 int count = preempt_count();
64974 int ret;
64975 + const char *msg1 = "", *msg2 = "";
64976
64977 if (initcall_debug)
64978 ret = do_one_initcall_debug(fn);
64979 @@ -687,15 +733,15 @@ int __init_or_module do_one_initcall(initcall_t fn)
64980 sprintf(msgbuf, "error code %d ", ret);
64981
64982 if (preempt_count() != count) {
64983 - strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
64984 + msg1 = " preemption imbalance";
64985 preempt_count() = count;
64986 }
64987 if (irqs_disabled()) {
64988 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
64989 + msg2 = " disabled interrupts";
64990 local_irq_enable();
64991 }
64992 - if (msgbuf[0]) {
64993 - printk("initcall %pF returned with %s\n", fn, msgbuf);
64994 + if (msgbuf[0] || *msg1 || *msg2) {
64995 + printk("initcall %pF returned with %s%s%s\n", fn, msgbuf, msg1, msg2);
64996 }
64997
64998 return ret;
64999 @@ -814,7 +860,7 @@ static int __init kernel_init(void * unused)
65000 do_basic_setup();
65001
65002 /* Open the /dev/console on the rootfs, this should never fail */
65003 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
65004 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
65005 printk(KERN_WARNING "Warning: unable to open an initial console.\n");
65006
65007 (void) sys_dup(0);
65008 @@ -827,11 +873,13 @@ static int __init kernel_init(void * unused)
65009 if (!ramdisk_execute_command)
65010 ramdisk_execute_command = "/init";
65011
65012 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
65013 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
65014 ramdisk_execute_command = NULL;
65015 prepare_namespace();
65016 }
65017
65018 + grsecurity_init();
65019 +
65020 /*
65021 * Ok, we have completed the initial bootup, and
65022 * we're essentially up and running. Get rid of the
65023 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
65024 index 86ee272..773d937 100644
65025 --- a/ipc/mqueue.c
65026 +++ b/ipc/mqueue.c
65027 @@ -156,6 +156,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
65028 mq_bytes = (mq_msg_tblsz +
65029 (info->attr.mq_maxmsg * info->attr.mq_msgsize));
65030
65031 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
65032 spin_lock(&mq_lock);
65033 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
65034 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
65035 diff --git a/ipc/msg.c b/ipc/msg.c
65036 index 7385de2..a8180e08 100644
65037 --- a/ipc/msg.c
65038 +++ b/ipc/msg.c
65039 @@ -309,18 +309,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
65040 return security_msg_queue_associate(msq, msgflg);
65041 }
65042
65043 +static struct ipc_ops msg_ops = {
65044 + .getnew = newque,
65045 + .associate = msg_security,
65046 + .more_checks = NULL
65047 +};
65048 +
65049 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
65050 {
65051 struct ipc_namespace *ns;
65052 - struct ipc_ops msg_ops;
65053 struct ipc_params msg_params;
65054
65055 ns = current->nsproxy->ipc_ns;
65056
65057 - msg_ops.getnew = newque;
65058 - msg_ops.associate = msg_security;
65059 - msg_ops.more_checks = NULL;
65060 -
65061 msg_params.key = key;
65062 msg_params.flg = msgflg;
65063
65064 diff --git a/ipc/sem.c b/ipc/sem.c
65065 index 5215a81..cfc0cac 100644
65066 --- a/ipc/sem.c
65067 +++ b/ipc/sem.c
65068 @@ -364,10 +364,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
65069 return 0;
65070 }
65071
65072 +static struct ipc_ops sem_ops = {
65073 + .getnew = newary,
65074 + .associate = sem_security,
65075 + .more_checks = sem_more_checks
65076 +};
65077 +
65078 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
65079 {
65080 struct ipc_namespace *ns;
65081 - struct ipc_ops sem_ops;
65082 struct ipc_params sem_params;
65083
65084 ns = current->nsproxy->ipc_ns;
65085 @@ -375,10 +380,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
65086 if (nsems < 0 || nsems > ns->sc_semmsl)
65087 return -EINVAL;
65088
65089 - sem_ops.getnew = newary;
65090 - sem_ops.associate = sem_security;
65091 - sem_ops.more_checks = sem_more_checks;
65092 -
65093 sem_params.key = key;
65094 sem_params.flg = semflg;
65095 sem_params.u.nsems = nsems;
65096 diff --git a/ipc/shm.c b/ipc/shm.c
65097 index b76be5b..859e750 100644
65098 --- a/ipc/shm.c
65099 +++ b/ipc/shm.c
65100 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
65101 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
65102 #endif
65103
65104 +#ifdef CONFIG_GRKERNSEC
65105 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
65106 + const time_t shm_createtime, const uid_t cuid,
65107 + const int shmid);
65108 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
65109 + const time_t shm_createtime);
65110 +#endif
65111 +
65112 void shm_init_ns(struct ipc_namespace *ns)
65113 {
65114 ns->shm_ctlmax = SHMMAX;
65115 @@ -508,6 +516,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
65116 shp->shm_lprid = 0;
65117 shp->shm_atim = shp->shm_dtim = 0;
65118 shp->shm_ctim = get_seconds();
65119 +#ifdef CONFIG_GRKERNSEC
65120 + {
65121 + struct timespec timeval;
65122 + do_posix_clock_monotonic_gettime(&timeval);
65123 +
65124 + shp->shm_createtime = timeval.tv_sec;
65125 + }
65126 +#endif
65127 shp->shm_segsz = size;
65128 shp->shm_nattch = 0;
65129 shp->shm_file = file;
65130 @@ -559,18 +575,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
65131 return 0;
65132 }
65133
65134 +static struct ipc_ops shm_ops = {
65135 + .getnew = newseg,
65136 + .associate = shm_security,
65137 + .more_checks = shm_more_checks
65138 +};
65139 +
65140 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
65141 {
65142 struct ipc_namespace *ns;
65143 - struct ipc_ops shm_ops;
65144 struct ipc_params shm_params;
65145
65146 ns = current->nsproxy->ipc_ns;
65147
65148 - shm_ops.getnew = newseg;
65149 - shm_ops.associate = shm_security;
65150 - shm_ops.more_checks = shm_more_checks;
65151 -
65152 shm_params.key = key;
65153 shm_params.flg = shmflg;
65154 shm_params.u.size = size;
65155 @@ -988,6 +1005,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr)
65156 f_mode = FMODE_READ | FMODE_WRITE;
65157 }
65158 if (shmflg & SHM_EXEC) {
65159 +
65160 +#ifdef CONFIG_PAX_MPROTECT
65161 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
65162 + goto out;
65163 +#endif
65164 +
65165 prot |= PROT_EXEC;
65166 acc_mode |= S_IXUGO;
65167 }
65168 @@ -1011,9 +1034,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr)
65169 if (err)
65170 goto out_unlock;
65171
65172 +#ifdef CONFIG_GRKERNSEC
65173 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
65174 + shp->shm_perm.cuid, shmid) ||
65175 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
65176 + err = -EACCES;
65177 + goto out_unlock;
65178 + }
65179 +#endif
65180 +
65181 path = shp->shm_file->f_path;
65182 path_get(&path);
65183 shp->shm_nattch++;
65184 +#ifdef CONFIG_GRKERNSEC
65185 + shp->shm_lapid = current->pid;
65186 +#endif
65187 size = i_size_read(path.dentry->d_inode);
65188 shm_unlock(shp);
65189
65190 diff --git a/kernel/acct.c b/kernel/acct.c
65191 index 02e6167..54824f7 100644
65192 --- a/kernel/acct.c
65193 +++ b/kernel/acct.c
65194 @@ -550,7 +550,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
65195 */
65196 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
65197 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
65198 - file->f_op->write(file, (char *)&ac,
65199 + file->f_op->write(file, (char __force_user *)&ac,
65200 sizeof(acct_t), &file->f_pos);
65201 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
65202 set_fs(fs);
65203 diff --git a/kernel/audit.c b/kernel/audit.c
65204 index bb0eb5b..cf2a03a 100644
65205 --- a/kernel/audit.c
65206 +++ b/kernel/audit.c
65207 @@ -115,7 +115,7 @@ u32 audit_sig_sid = 0;
65208 3) suppressed due to audit_rate_limit
65209 4) suppressed due to audit_backlog_limit
65210 */
65211 -static atomic_t audit_lost = ATOMIC_INIT(0);
65212 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
65213
65214 /* The netlink socket. */
65215 static struct sock *audit_sock;
65216 @@ -237,7 +237,7 @@ void audit_log_lost(const char *message)
65217 unsigned long now;
65218 int print;
65219
65220 - atomic_inc(&audit_lost);
65221 + atomic_inc_unchecked(&audit_lost);
65222
65223 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
65224
65225 @@ -256,7 +256,7 @@ void audit_log_lost(const char *message)
65226 printk(KERN_WARNING
65227 "audit: audit_lost=%d audit_rate_limit=%d "
65228 "audit_backlog_limit=%d\n",
65229 - atomic_read(&audit_lost),
65230 + atomic_read_unchecked(&audit_lost),
65231 audit_rate_limit,
65232 audit_backlog_limit);
65233 audit_panic(message);
65234 @@ -689,7 +689,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
65235 status_set.pid = audit_pid;
65236 status_set.rate_limit = audit_rate_limit;
65237 status_set.backlog_limit = audit_backlog_limit;
65238 - status_set.lost = atomic_read(&audit_lost);
65239 + status_set.lost = atomic_read_unchecked(&audit_lost);
65240 status_set.backlog = skb_queue_len(&audit_skb_queue);
65241 audit_send_reply(NETLINK_CB(skb).pid, seq, AUDIT_GET, 0, 0,
65242 &status_set, sizeof(status_set));
65243 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
65244 index af1de0f..06dfe57 100644
65245 --- a/kernel/auditsc.c
65246 +++ b/kernel/auditsc.c
65247 @@ -2288,7 +2288,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
65248 }
65249
65250 /* global counter which is incremented every time something logs in */
65251 -static atomic_t session_id = ATOMIC_INIT(0);
65252 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
65253
65254 /**
65255 * audit_set_loginuid - set current task's audit_context loginuid
65256 @@ -2312,7 +2312,7 @@ int audit_set_loginuid(uid_t loginuid)
65257 return -EPERM;
65258 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
65259
65260 - sessionid = atomic_inc_return(&session_id);
65261 + sessionid = atomic_inc_return_unchecked(&session_id);
65262 if (context && context->in_syscall) {
65263 struct audit_buffer *ab;
65264
65265 diff --git a/kernel/capability.c b/kernel/capability.c
65266 index 3f1adb6..c564db0 100644
65267 --- a/kernel/capability.c
65268 +++ b/kernel/capability.c
65269 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
65270 * before modification is attempted and the application
65271 * fails.
65272 */
65273 + if (tocopy > ARRAY_SIZE(kdata))
65274 + return -EFAULT;
65275 +
65276 if (copy_to_user(dataptr, kdata, tocopy
65277 * sizeof(struct __user_cap_data_struct))) {
65278 return -EFAULT;
65279 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
65280 int ret;
65281
65282 rcu_read_lock();
65283 - ret = security_capable(__task_cred(t), ns, cap);
65284 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
65285 + gr_task_is_capable(t, __task_cred(t), cap);
65286 rcu_read_unlock();
65287
65288 - return (ret == 0);
65289 + return ret;
65290 }
65291
65292 /**
65293 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
65294 int ret;
65295
65296 rcu_read_lock();
65297 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
65298 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
65299 rcu_read_unlock();
65300
65301 - return (ret == 0);
65302 + return ret;
65303 }
65304
65305 /**
65306 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
65307 BUG();
65308 }
65309
65310 - if (security_capable(current_cred(), ns, cap) == 0) {
65311 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
65312 current->flags |= PF_SUPERPRIV;
65313 return true;
65314 }
65315 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
65316 }
65317 EXPORT_SYMBOL(ns_capable);
65318
65319 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
65320 +{
65321 + if (unlikely(!cap_valid(cap))) {
65322 + printk(KERN_CRIT "capable() called with invalid cap=%u\n", cap);
65323 + BUG();
65324 + }
65325 +
65326 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
65327 + current->flags |= PF_SUPERPRIV;
65328 + return true;
65329 + }
65330 + return false;
65331 +}
65332 +EXPORT_SYMBOL(ns_capable_nolog);
65333 +
65334 /**
65335 * capable - Determine if the current task has a superior capability in effect
65336 * @cap: The capability to be tested for
65337 @@ -408,6 +427,12 @@ bool capable(int cap)
65338 }
65339 EXPORT_SYMBOL(capable);
65340
65341 +bool capable_nolog(int cap)
65342 +{
65343 + return ns_capable_nolog(&init_user_ns, cap);
65344 +}
65345 +EXPORT_SYMBOL(capable_nolog);
65346 +
65347 /**
65348 * nsown_capable - Check superior capability to one's own user_ns
65349 * @cap: The capability in question
65350 diff --git a/kernel/compat.c b/kernel/compat.c
65351 index a6d0649..f44fb27 100644
65352 --- a/kernel/compat.c
65353 +++ b/kernel/compat.c
65354 @@ -13,6 +13,7 @@
65355
65356 #include <linux/linkage.h>
65357 #include <linux/compat.h>
65358 +#include <linux/module.h>
65359 #include <linux/errno.h>
65360 #include <linux/time.h>
65361 #include <linux/signal.h>
65362 @@ -168,7 +169,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
65363 mm_segment_t oldfs;
65364 long ret;
65365
65366 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
65367 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
65368 oldfs = get_fs();
65369 set_fs(KERNEL_DS);
65370 ret = hrtimer_nanosleep_restart(restart);
65371 @@ -200,7 +201,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
65372 oldfs = get_fs();
65373 set_fs(KERNEL_DS);
65374 ret = hrtimer_nanosleep(&tu,
65375 - rmtp ? (struct timespec __user *)&rmt : NULL,
65376 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
65377 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
65378 set_fs(oldfs);
65379
65380 @@ -309,7 +310,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
65381 mm_segment_t old_fs = get_fs();
65382
65383 set_fs(KERNEL_DS);
65384 - ret = sys_sigpending((old_sigset_t __user *) &s);
65385 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
65386 set_fs(old_fs);
65387 if (ret == 0)
65388 ret = put_user(s, set);
65389 @@ -399,7 +400,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
65390 mm_segment_t old_fs = get_fs();
65391
65392 set_fs(KERNEL_DS);
65393 - ret = sys_old_getrlimit(resource, &r);
65394 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
65395 set_fs(old_fs);
65396
65397 if (!ret) {
65398 @@ -471,7 +472,7 @@ asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)
65399 mm_segment_t old_fs = get_fs();
65400
65401 set_fs(KERNEL_DS);
65402 - ret = sys_getrusage(who, (struct rusage __user *) &r);
65403 + ret = sys_getrusage(who, (struct rusage __force_user *) &r);
65404 set_fs(old_fs);
65405
65406 if (ret)
65407 @@ -498,8 +499,8 @@ compat_sys_wait4(compat_pid_t pid, compat_uint_t __user *stat_addr, int options,
65408 set_fs (KERNEL_DS);
65409 ret = sys_wait4(pid,
65410 (stat_addr ?
65411 - (unsigned int __user *) &status : NULL),
65412 - options, (struct rusage __user *) &r);
65413 + (unsigned int __force_user *) &status : NULL),
65414 + options, (struct rusage __force_user *) &r);
65415 set_fs (old_fs);
65416
65417 if (ret > 0) {
65418 @@ -524,8 +525,8 @@ asmlinkage long compat_sys_waitid(int which, compat_pid_t pid,
65419 memset(&info, 0, sizeof(info));
65420
65421 set_fs(KERNEL_DS);
65422 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
65423 - uru ? (struct rusage __user *)&ru : NULL);
65424 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
65425 + uru ? (struct rusage __force_user *)&ru : NULL);
65426 set_fs(old_fs);
65427
65428 if ((ret < 0) || (info.si_signo == 0))
65429 @@ -655,8 +656,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
65430 oldfs = get_fs();
65431 set_fs(KERNEL_DS);
65432 err = sys_timer_settime(timer_id, flags,
65433 - (struct itimerspec __user *) &newts,
65434 - (struct itimerspec __user *) &oldts);
65435 + (struct itimerspec __force_user *) &newts,
65436 + (struct itimerspec __force_user *) &oldts);
65437 set_fs(oldfs);
65438 if (!err && old && put_compat_itimerspec(old, &oldts))
65439 return -EFAULT;
65440 @@ -673,7 +674,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
65441 oldfs = get_fs();
65442 set_fs(KERNEL_DS);
65443 err = sys_timer_gettime(timer_id,
65444 - (struct itimerspec __user *) &ts);
65445 + (struct itimerspec __force_user *) &ts);
65446 set_fs(oldfs);
65447 if (!err && put_compat_itimerspec(setting, &ts))
65448 return -EFAULT;
65449 @@ -692,7 +693,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
65450 oldfs = get_fs();
65451 set_fs(KERNEL_DS);
65452 err = sys_clock_settime(which_clock,
65453 - (struct timespec __user *) &ts);
65454 + (struct timespec __force_user *) &ts);
65455 set_fs(oldfs);
65456 return err;
65457 }
65458 @@ -707,7 +708,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
65459 oldfs = get_fs();
65460 set_fs(KERNEL_DS);
65461 err = sys_clock_gettime(which_clock,
65462 - (struct timespec __user *) &ts);
65463 + (struct timespec __force_user *) &ts);
65464 set_fs(oldfs);
65465 if (!err && put_compat_timespec(&ts, tp))
65466 return -EFAULT;
65467 @@ -727,7 +728,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
65468
65469 oldfs = get_fs();
65470 set_fs(KERNEL_DS);
65471 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
65472 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
65473 set_fs(oldfs);
65474
65475 err = compat_put_timex(utp, &txc);
65476 @@ -747,7 +748,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
65477 oldfs = get_fs();
65478 set_fs(KERNEL_DS);
65479 err = sys_clock_getres(which_clock,
65480 - (struct timespec __user *) &ts);
65481 + (struct timespec __force_user *) &ts);
65482 set_fs(oldfs);
65483 if (!err && tp && put_compat_timespec(&ts, tp))
65484 return -EFAULT;
65485 @@ -759,9 +760,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
65486 long err;
65487 mm_segment_t oldfs;
65488 struct timespec tu;
65489 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
65490 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
65491
65492 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
65493 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
65494 oldfs = get_fs();
65495 set_fs(KERNEL_DS);
65496 err = clock_nanosleep_restart(restart);
65497 @@ -793,8 +794,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
65498 oldfs = get_fs();
65499 set_fs(KERNEL_DS);
65500 err = sys_clock_nanosleep(which_clock, flags,
65501 - (struct timespec __user *) &in,
65502 - (struct timespec __user *) &out);
65503 + (struct timespec __force_user *) &in,
65504 + (struct timespec __force_user *) &out);
65505 set_fs(oldfs);
65506
65507 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
65508 diff --git a/kernel/configs.c b/kernel/configs.c
65509 index 42e8fa0..9e7406b 100644
65510 --- a/kernel/configs.c
65511 +++ b/kernel/configs.c
65512 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
65513 struct proc_dir_entry *entry;
65514
65515 /* create the current config file */
65516 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
65517 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
65518 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
65519 + &ikconfig_file_ops);
65520 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
65521 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
65522 + &ikconfig_file_ops);
65523 +#endif
65524 +#else
65525 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
65526 &ikconfig_file_ops);
65527 +#endif
65528 +
65529 if (!entry)
65530 return -ENOMEM;
65531
65532 diff --git a/kernel/cred.c b/kernel/cred.c
65533 index 48c6fd3..8398912 100644
65534 --- a/kernel/cred.c
65535 +++ b/kernel/cred.c
65536 @@ -204,6 +204,15 @@ void exit_creds(struct task_struct *tsk)
65537 validate_creds(cred);
65538 put_cred(cred);
65539 }
65540 +
65541 +#ifdef CONFIG_GRKERNSEC_SETXID
65542 + cred = (struct cred *) tsk->delayed_cred;
65543 + if (cred) {
65544 + tsk->delayed_cred = NULL;
65545 + validate_creds(cred);
65546 + put_cred(cred);
65547 + }
65548 +#endif
65549 }
65550
65551 /**
65552 @@ -472,7 +481,7 @@ error_put:
65553 * Always returns 0 thus allowing this function to be tail-called at the end
65554 * of, say, sys_setgid().
65555 */
65556 -int commit_creds(struct cred *new)
65557 +static int __commit_creds(struct cred *new)
65558 {
65559 struct task_struct *task = current;
65560 const struct cred *old = task->real_cred;
65561 @@ -491,6 +500,8 @@ int commit_creds(struct cred *new)
65562
65563 get_cred(new); /* we will require a ref for the subj creds too */
65564
65565 + gr_set_role_label(task, new->uid, new->gid);
65566 +
65567 /* dumpability changes */
65568 if (old->euid != new->euid ||
65569 old->egid != new->egid ||
65570 @@ -540,6 +551,101 @@ int commit_creds(struct cred *new)
65571 put_cred(old);
65572 return 0;
65573 }
65574 +#ifdef CONFIG_GRKERNSEC_SETXID
65575 +extern int set_user(struct cred *new);
65576 +
65577 +void gr_delayed_cred_worker(void)
65578 +{
65579 + const struct cred *new = current->delayed_cred;
65580 + struct cred *ncred;
65581 +
65582 + current->delayed_cred = NULL;
65583 +
65584 + if (current_uid() && new != NULL) {
65585 + // from doing get_cred on it when queueing this
65586 + put_cred(new);
65587 + return;
65588 + } else if (new == NULL)
65589 + return;
65590 +
65591 + ncred = prepare_creds();
65592 + if (!ncred)
65593 + goto die;
65594 + // uids
65595 + ncred->uid = new->uid;
65596 + ncred->euid = new->euid;
65597 + ncred->suid = new->suid;
65598 + ncred->fsuid = new->fsuid;
65599 + // gids
65600 + ncred->gid = new->gid;
65601 + ncred->egid = new->egid;
65602 + ncred->sgid = new->sgid;
65603 + ncred->fsgid = new->fsgid;
65604 + // groups
65605 + if (set_groups(ncred, new->group_info) < 0) {
65606 + abort_creds(ncred);
65607 + goto die;
65608 + }
65609 + // caps
65610 + ncred->securebits = new->securebits;
65611 + ncred->cap_inheritable = new->cap_inheritable;
65612 + ncred->cap_permitted = new->cap_permitted;
65613 + ncred->cap_effective = new->cap_effective;
65614 + ncred->cap_bset = new->cap_bset;
65615 +
65616 + if (set_user(ncred)) {
65617 + abort_creds(ncred);
65618 + goto die;
65619 + }
65620 +
65621 + // from doing get_cred on it when queueing this
65622 + put_cred(new);
65623 +
65624 + __commit_creds(ncred);
65625 + return;
65626 +die:
65627 + // from doing get_cred on it when queueing this
65628 + put_cred(new);
65629 + do_group_exit(SIGKILL);
65630 +}
65631 +#endif
65632 +
65633 +int commit_creds(struct cred *new)
65634 +{
65635 +#ifdef CONFIG_GRKERNSEC_SETXID
65636 + int ret;
65637 + int schedule_it = 0;
65638 + struct task_struct *t;
65639 +
65640 + /* we won't get called with tasklist_lock held for writing
65641 + and interrupts disabled as the cred struct in that case is
65642 + init_cred
65643 + */
65644 + if (grsec_enable_setxid && !current_is_single_threaded() &&
65645 + !current_uid() && new->uid) {
65646 + schedule_it = 1;
65647 + }
65648 + ret = __commit_creds(new);
65649 + if (schedule_it) {
65650 + rcu_read_lock();
65651 + read_lock(&tasklist_lock);
65652 + for (t = next_thread(current); t != current;
65653 + t = next_thread(t)) {
65654 + if (t->delayed_cred == NULL) {
65655 + t->delayed_cred = get_cred(new);
65656 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
65657 + set_tsk_need_resched(t);
65658 + }
65659 + }
65660 + read_unlock(&tasklist_lock);
65661 + rcu_read_unlock();
65662 + }
65663 + return ret;
65664 +#else
65665 + return __commit_creds(new);
65666 +#endif
65667 +}
65668 +
65669 EXPORT_SYMBOL(commit_creds);
65670
65671 /**
65672 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
65673 index 7fda904..59f620c 100644
65674 --- a/kernel/debug/debug_core.c
65675 +++ b/kernel/debug/debug_core.c
65676 @@ -119,7 +119,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
65677 */
65678 static atomic_t masters_in_kgdb;
65679 static atomic_t slaves_in_kgdb;
65680 -static atomic_t kgdb_break_tasklet_var;
65681 +static atomic_unchecked_t kgdb_break_tasklet_var;
65682 atomic_t kgdb_setting_breakpoint;
65683
65684 struct task_struct *kgdb_usethread;
65685 @@ -129,7 +129,7 @@ int kgdb_single_step;
65686 static pid_t kgdb_sstep_pid;
65687
65688 /* to keep track of the CPU which is doing the single stepping*/
65689 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
65690 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
65691
65692 /*
65693 * If you are debugging a problem where roundup (the collection of
65694 @@ -537,7 +537,7 @@ return_normal:
65695 * kernel will only try for the value of sstep_tries before
65696 * giving up and continuing on.
65697 */
65698 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
65699 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
65700 (kgdb_info[cpu].task &&
65701 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
65702 atomic_set(&kgdb_active, -1);
65703 @@ -631,8 +631,8 @@ cpu_master_loop:
65704 }
65705
65706 kgdb_restore:
65707 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
65708 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
65709 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
65710 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
65711 if (kgdb_info[sstep_cpu].task)
65712 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
65713 else
65714 @@ -829,18 +829,18 @@ static void kgdb_unregister_callbacks(void)
65715 static void kgdb_tasklet_bpt(unsigned long ing)
65716 {
65717 kgdb_breakpoint();
65718 - atomic_set(&kgdb_break_tasklet_var, 0);
65719 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
65720 }
65721
65722 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
65723
65724 void kgdb_schedule_breakpoint(void)
65725 {
65726 - if (atomic_read(&kgdb_break_tasklet_var) ||
65727 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
65728 atomic_read(&kgdb_active) != -1 ||
65729 atomic_read(&kgdb_setting_breakpoint))
65730 return;
65731 - atomic_inc(&kgdb_break_tasklet_var);
65732 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
65733 tasklet_schedule(&kgdb_tasklet_breakpoint);
65734 }
65735 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
65736 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
65737 index e2ae734..08a4c5c 100644
65738 --- a/kernel/debug/kdb/kdb_main.c
65739 +++ b/kernel/debug/kdb/kdb_main.c
65740 @@ -1980,7 +1980,7 @@ static int kdb_lsmod(int argc, const char **argv)
65741 list_for_each_entry(mod, kdb_modules, list) {
65742
65743 kdb_printf("%-20s%8u 0x%p ", mod->name,
65744 - mod->core_size, (void *)mod);
65745 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
65746 #ifdef CONFIG_MODULE_UNLOAD
65747 kdb_printf("%4ld ", module_refcount(mod));
65748 #endif
65749 @@ -1990,7 +1990,7 @@ static int kdb_lsmod(int argc, const char **argv)
65750 kdb_printf(" (Loading)");
65751 else
65752 kdb_printf(" (Live)");
65753 - kdb_printf(" 0x%p", mod->module_core);
65754 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
65755
65756 #ifdef CONFIG_MODULE_UNLOAD
65757 {
65758 diff --git a/kernel/events/core.c b/kernel/events/core.c
65759 index 1b5c081..c375f83 100644
65760 --- a/kernel/events/core.c
65761 +++ b/kernel/events/core.c
65762 @@ -173,7 +173,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
65763 return 0;
65764 }
65765
65766 -static atomic64_t perf_event_id;
65767 +static atomic64_unchecked_t perf_event_id;
65768
65769 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
65770 enum event_type_t event_type);
65771 @@ -2581,7 +2581,7 @@ static void __perf_event_read(void *info)
65772
65773 static inline u64 perf_event_count(struct perf_event *event)
65774 {
65775 - return local64_read(&event->count) + atomic64_read(&event->child_count);
65776 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
65777 }
65778
65779 static u64 perf_event_read(struct perf_event *event)
65780 @@ -2897,9 +2897,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
65781 mutex_lock(&event->child_mutex);
65782 total += perf_event_read(event);
65783 *enabled += event->total_time_enabled +
65784 - atomic64_read(&event->child_total_time_enabled);
65785 + atomic64_read_unchecked(&event->child_total_time_enabled);
65786 *running += event->total_time_running +
65787 - atomic64_read(&event->child_total_time_running);
65788 + atomic64_read_unchecked(&event->child_total_time_running);
65789
65790 list_for_each_entry(child, &event->child_list, child_list) {
65791 total += perf_event_read(child);
65792 @@ -3306,10 +3306,10 @@ void perf_event_update_userpage(struct perf_event *event)
65793 userpg->offset -= local64_read(&event->hw.prev_count);
65794
65795 userpg->time_enabled = enabled +
65796 - atomic64_read(&event->child_total_time_enabled);
65797 + atomic64_read_unchecked(&event->child_total_time_enabled);
65798
65799 userpg->time_running = running +
65800 - atomic64_read(&event->child_total_time_running);
65801 + atomic64_read_unchecked(&event->child_total_time_running);
65802
65803 barrier();
65804 ++userpg->lock;
65805 @@ -3738,11 +3738,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
65806 values[n++] = perf_event_count(event);
65807 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
65808 values[n++] = enabled +
65809 - atomic64_read(&event->child_total_time_enabled);
65810 + atomic64_read_unchecked(&event->child_total_time_enabled);
65811 }
65812 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
65813 values[n++] = running +
65814 - atomic64_read(&event->child_total_time_running);
65815 + atomic64_read_unchecked(&event->child_total_time_running);
65816 }
65817 if (read_format & PERF_FORMAT_ID)
65818 values[n++] = primary_event_id(event);
65819 @@ -4393,12 +4393,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
65820 * need to add enough zero bytes after the string to handle
65821 * the 64bit alignment we do later.
65822 */
65823 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
65824 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
65825 if (!buf) {
65826 name = strncpy(tmp, "//enomem", sizeof(tmp));
65827 goto got_name;
65828 }
65829 - name = d_path(&file->f_path, buf, PATH_MAX);
65830 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
65831 if (IS_ERR(name)) {
65832 name = strncpy(tmp, "//toolong", sizeof(tmp));
65833 goto got_name;
65834 @@ -5765,7 +5765,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
65835 event->parent = parent_event;
65836
65837 event->ns = get_pid_ns(current->nsproxy->pid_ns);
65838 - event->id = atomic64_inc_return(&perf_event_id);
65839 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
65840
65841 event->state = PERF_EVENT_STATE_INACTIVE;
65842
65843 @@ -6287,10 +6287,10 @@ static void sync_child_event(struct perf_event *child_event,
65844 /*
65845 * Add back the child's count to the parent's count:
65846 */
65847 - atomic64_add(child_val, &parent_event->child_count);
65848 - atomic64_add(child_event->total_time_enabled,
65849 + atomic64_add_unchecked(child_val, &parent_event->child_count);
65850 + atomic64_add_unchecked(child_event->total_time_enabled,
65851 &parent_event->child_total_time_enabled);
65852 - atomic64_add(child_event->total_time_running,
65853 + atomic64_add_unchecked(child_event->total_time_running,
65854 &parent_event->child_total_time_running);
65855
65856 /*
65857 diff --git a/kernel/exit.c b/kernel/exit.c
65858 index 46c8b14..d868958 100644
65859 --- a/kernel/exit.c
65860 +++ b/kernel/exit.c
65861 @@ -58,6 +58,10 @@
65862 #include <asm/pgtable.h>
65863 #include <asm/mmu_context.h>
65864
65865 +#ifdef CONFIG_GRKERNSEC
65866 +extern rwlock_t grsec_exec_file_lock;
65867 +#endif
65868 +
65869 static void exit_mm(struct task_struct * tsk);
65870
65871 static void __unhash_process(struct task_struct *p, bool group_dead)
65872 @@ -169,6 +173,10 @@ void release_task(struct task_struct * p)
65873 struct task_struct *leader;
65874 int zap_leader;
65875 repeat:
65876 +#ifdef CONFIG_NET
65877 + gr_del_task_from_ip_table(p);
65878 +#endif
65879 +
65880 /* don't need to get the RCU readlock here - the process is dead and
65881 * can't be modifying its own credentials. But shut RCU-lockdep up */
65882 rcu_read_lock();
65883 @@ -381,7 +389,7 @@ int allow_signal(int sig)
65884 * know it'll be handled, so that they don't get converted to
65885 * SIGKILL or just silently dropped.
65886 */
65887 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
65888 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
65889 recalc_sigpending();
65890 spin_unlock_irq(&current->sighand->siglock);
65891 return 0;
65892 @@ -417,6 +425,17 @@ void daemonize(const char *name, ...)
65893 vsnprintf(current->comm, sizeof(current->comm), name, args);
65894 va_end(args);
65895
65896 +#ifdef CONFIG_GRKERNSEC
65897 + write_lock(&grsec_exec_file_lock);
65898 + if (current->exec_file) {
65899 + fput(current->exec_file);
65900 + current->exec_file = NULL;
65901 + }
65902 + write_unlock(&grsec_exec_file_lock);
65903 +#endif
65904 +
65905 + gr_set_kernel_label(current);
65906 +
65907 /*
65908 * If we were started as result of loading a module, close all of the
65909 * user space pages. We don't need them, and if we didn't close them
65910 @@ -873,6 +892,8 @@ void do_exit(long code)
65911 struct task_struct *tsk = current;
65912 int group_dead;
65913
65914 + set_fs(USER_DS);
65915 +
65916 profile_task_exit(tsk);
65917
65918 WARN_ON(blk_needs_flush_plug(tsk));
65919 @@ -889,7 +910,6 @@ void do_exit(long code)
65920 * mm_release()->clear_child_tid() from writing to a user-controlled
65921 * kernel address.
65922 */
65923 - set_fs(USER_DS);
65924
65925 ptrace_event(PTRACE_EVENT_EXIT, code);
65926
65927 @@ -950,6 +970,9 @@ void do_exit(long code)
65928 tsk->exit_code = code;
65929 taskstats_exit(tsk, group_dead);
65930
65931 + gr_acl_handle_psacct(tsk, code);
65932 + gr_acl_handle_exit();
65933 +
65934 exit_mm(tsk);
65935
65936 if (group_dead)
65937 @@ -1066,7 +1089,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
65938 * Take down every thread in the group. This is called by fatal signals
65939 * as well as by sys_exit_group (below).
65940 */
65941 -void
65942 +__noreturn void
65943 do_group_exit(int exit_code)
65944 {
65945 struct signal_struct *sig = current->signal;
65946 diff --git a/kernel/fork.c b/kernel/fork.c
65947 index 423d5a4..4608ecf 100644
65948 --- a/kernel/fork.c
65949 +++ b/kernel/fork.c
65950 @@ -285,7 +285,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
65951 *stackend = STACK_END_MAGIC; /* for overflow detection */
65952
65953 #ifdef CONFIG_CC_STACKPROTECTOR
65954 - tsk->stack_canary = get_random_int();
65955 + tsk->stack_canary = pax_get_random_long();
65956 #endif
65957
65958 /*
65959 @@ -309,13 +309,77 @@ out:
65960 }
65961
65962 #ifdef CONFIG_MMU
65963 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct vm_area_struct *mpnt)
65964 +{
65965 + struct vm_area_struct *tmp;
65966 + unsigned long charge;
65967 + struct mempolicy *pol;
65968 + struct file *file;
65969 +
65970 + charge = 0;
65971 + if (mpnt->vm_flags & VM_ACCOUNT) {
65972 + unsigned int len = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT;
65973 + if (security_vm_enough_memory(len))
65974 + goto fail_nomem;
65975 + charge = len;
65976 + }
65977 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
65978 + if (!tmp)
65979 + goto fail_nomem;
65980 + *tmp = *mpnt;
65981 + tmp->vm_mm = mm;
65982 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
65983 + pol = mpol_dup(vma_policy(mpnt));
65984 + if (IS_ERR(pol))
65985 + goto fail_nomem_policy;
65986 + vma_set_policy(tmp, pol);
65987 + if (anon_vma_fork(tmp, mpnt))
65988 + goto fail_nomem_anon_vma_fork;
65989 + tmp->vm_flags &= ~VM_LOCKED;
65990 + tmp->vm_next = tmp->vm_prev = NULL;
65991 + tmp->vm_mirror = NULL;
65992 + file = tmp->vm_file;
65993 + if (file) {
65994 + struct inode *inode = file->f_path.dentry->d_inode;
65995 + struct address_space *mapping = file->f_mapping;
65996 +
65997 + get_file(file);
65998 + if (tmp->vm_flags & VM_DENYWRITE)
65999 + atomic_dec(&inode->i_writecount);
66000 + mutex_lock(&mapping->i_mmap_mutex);
66001 + if (tmp->vm_flags & VM_SHARED)
66002 + mapping->i_mmap_writable++;
66003 + flush_dcache_mmap_lock(mapping);
66004 + /* insert tmp into the share list, just after mpnt */
66005 + vma_prio_tree_add(tmp, mpnt);
66006 + flush_dcache_mmap_unlock(mapping);
66007 + mutex_unlock(&mapping->i_mmap_mutex);
66008 + }
66009 +
66010 + /*
66011 + * Clear hugetlb-related page reserves for children. This only
66012 + * affects MAP_PRIVATE mappings. Faults generated by the child
66013 + * are not guaranteed to succeed, even if read-only
66014 + */
66015 + if (is_vm_hugetlb_page(tmp))
66016 + reset_vma_resv_huge_pages(tmp);
66017 +
66018 + return tmp;
66019 +
66020 +fail_nomem_anon_vma_fork:
66021 + mpol_put(pol);
66022 +fail_nomem_policy:
66023 + kmem_cache_free(vm_area_cachep, tmp);
66024 +fail_nomem:
66025 + vm_unacct_memory(charge);
66026 + return NULL;
66027 +}
66028 +
66029 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
66030 {
66031 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
66032 struct rb_node **rb_link, *rb_parent;
66033 int retval;
66034 - unsigned long charge;
66035 - struct mempolicy *pol;
66036
66037 down_write(&oldmm->mmap_sem);
66038 flush_cache_dup_mm(oldmm);
66039 @@ -327,8 +391,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
66040 mm->locked_vm = 0;
66041 mm->mmap = NULL;
66042 mm->mmap_cache = NULL;
66043 - mm->free_area_cache = oldmm->mmap_base;
66044 - mm->cached_hole_size = ~0UL;
66045 + mm->free_area_cache = oldmm->free_area_cache;
66046 + mm->cached_hole_size = oldmm->cached_hole_size;
66047 mm->map_count = 0;
66048 cpumask_clear(mm_cpumask(mm));
66049 mm->mm_rb = RB_ROOT;
66050 @@ -344,8 +408,6 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
66051
66052 prev = NULL;
66053 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
66054 - struct file *file;
66055 -
66056 if (mpnt->vm_flags & VM_DONTCOPY) {
66057 long pages = vma_pages(mpnt);
66058 mm->total_vm -= pages;
66059 @@ -353,53 +415,11 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
66060 -pages);
66061 continue;
66062 }
66063 - charge = 0;
66064 - if (mpnt->vm_flags & VM_ACCOUNT) {
66065 - unsigned int len = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT;
66066 - if (security_vm_enough_memory(len))
66067 - goto fail_nomem;
66068 - charge = len;
66069 + tmp = dup_vma(mm, mpnt);
66070 + if (!tmp) {
66071 + retval = -ENOMEM;
66072 + goto out;
66073 }
66074 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
66075 - if (!tmp)
66076 - goto fail_nomem;
66077 - *tmp = *mpnt;
66078 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
66079 - pol = mpol_dup(vma_policy(mpnt));
66080 - retval = PTR_ERR(pol);
66081 - if (IS_ERR(pol))
66082 - goto fail_nomem_policy;
66083 - vma_set_policy(tmp, pol);
66084 - tmp->vm_mm = mm;
66085 - if (anon_vma_fork(tmp, mpnt))
66086 - goto fail_nomem_anon_vma_fork;
66087 - tmp->vm_flags &= ~VM_LOCKED;
66088 - tmp->vm_next = tmp->vm_prev = NULL;
66089 - file = tmp->vm_file;
66090 - if (file) {
66091 - struct inode *inode = file->f_path.dentry->d_inode;
66092 - struct address_space *mapping = file->f_mapping;
66093 -
66094 - get_file(file);
66095 - if (tmp->vm_flags & VM_DENYWRITE)
66096 - atomic_dec(&inode->i_writecount);
66097 - mutex_lock(&mapping->i_mmap_mutex);
66098 - if (tmp->vm_flags & VM_SHARED)
66099 - mapping->i_mmap_writable++;
66100 - flush_dcache_mmap_lock(mapping);
66101 - /* insert tmp into the share list, just after mpnt */
66102 - vma_prio_tree_add(tmp, mpnt);
66103 - flush_dcache_mmap_unlock(mapping);
66104 - mutex_unlock(&mapping->i_mmap_mutex);
66105 - }
66106 -
66107 - /*
66108 - * Clear hugetlb-related page reserves for children. This only
66109 - * affects MAP_PRIVATE mappings. Faults generated by the child
66110 - * are not guaranteed to succeed, even if read-only
66111 - */
66112 - if (is_vm_hugetlb_page(tmp))
66113 - reset_vma_resv_huge_pages(tmp);
66114
66115 /*
66116 * Link in the new vma and copy the page table entries.
66117 @@ -422,6 +442,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
66118 if (retval)
66119 goto out;
66120 }
66121 +
66122 +#ifdef CONFIG_PAX_SEGMEXEC
66123 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
66124 + struct vm_area_struct *mpnt_m;
66125 +
66126 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
66127 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
66128 +
66129 + if (!mpnt->vm_mirror)
66130 + continue;
66131 +
66132 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
66133 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
66134 + mpnt->vm_mirror = mpnt_m;
66135 + } else {
66136 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
66137 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
66138 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
66139 + mpnt->vm_mirror->vm_mirror = mpnt;
66140 + }
66141 + }
66142 + BUG_ON(mpnt_m);
66143 + }
66144 +#endif
66145 +
66146 /* a new mm has just been created */
66147 arch_dup_mmap(oldmm, mm);
66148 retval = 0;
66149 @@ -430,14 +475,6 @@ out:
66150 flush_tlb_mm(oldmm);
66151 up_write(&oldmm->mmap_sem);
66152 return retval;
66153 -fail_nomem_anon_vma_fork:
66154 - mpol_put(pol);
66155 -fail_nomem_policy:
66156 - kmem_cache_free(vm_area_cachep, tmp);
66157 -fail_nomem:
66158 - retval = -ENOMEM;
66159 - vm_unacct_memory(charge);
66160 - goto out;
66161 }
66162
66163 static inline int mm_alloc_pgd(struct mm_struct *mm)
66164 @@ -659,8 +696,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
66165 return ERR_PTR(err);
66166
66167 mm = get_task_mm(task);
66168 - if (mm && mm != current->mm &&
66169 - !ptrace_may_access(task, mode)) {
66170 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
66171 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
66172 mmput(mm);
66173 mm = ERR_PTR(-EACCES);
66174 }
66175 @@ -882,13 +919,14 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
66176 spin_unlock(&fs->lock);
66177 return -EAGAIN;
66178 }
66179 - fs->users++;
66180 + atomic_inc(&fs->users);
66181 spin_unlock(&fs->lock);
66182 return 0;
66183 }
66184 tsk->fs = copy_fs_struct(fs);
66185 if (!tsk->fs)
66186 return -ENOMEM;
66187 + gr_set_chroot_entries(tsk, &tsk->fs->root);
66188 return 0;
66189 }
66190
66191 @@ -1152,6 +1190,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
66192 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
66193 #endif
66194 retval = -EAGAIN;
66195 +
66196 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
66197 +
66198 if (atomic_read(&p->real_cred->user->processes) >=
66199 task_rlimit(p, RLIMIT_NPROC)) {
66200 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
66201 @@ -1307,6 +1348,8 @@ static struct task_struct *copy_process(unsigned long clone_flags,
66202 if (clone_flags & CLONE_THREAD)
66203 p->tgid = current->tgid;
66204
66205 + gr_copy_label(p);
66206 +
66207 p->set_child_tid = (clone_flags & CLONE_CHILD_SETTID) ? child_tidptr : NULL;
66208 /*
66209 * Clear TID on mm_release()?
66210 @@ -1475,6 +1518,8 @@ bad_fork_cleanup_count:
66211 bad_fork_free:
66212 free_task(p);
66213 fork_out:
66214 + gr_log_forkfail(retval);
66215 +
66216 return ERR_PTR(retval);
66217 }
66218
66219 @@ -1575,6 +1620,8 @@ long do_fork(unsigned long clone_flags,
66220 if (clone_flags & CLONE_PARENT_SETTID)
66221 put_user(nr, parent_tidptr);
66222
66223 + gr_handle_brute_check();
66224 +
66225 if (clone_flags & CLONE_VFORK) {
66226 p->vfork_done = &vfork;
66227 init_completion(&vfork);
66228 @@ -1673,7 +1720,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
66229 return 0;
66230
66231 /* don't need lock here; in the worst case we'll do useless copy */
66232 - if (fs->users == 1)
66233 + if (atomic_read(&fs->users) == 1)
66234 return 0;
66235
66236 *new_fsp = copy_fs_struct(fs);
66237 @@ -1762,7 +1809,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
66238 fs = current->fs;
66239 spin_lock(&fs->lock);
66240 current->fs = new_fs;
66241 - if (--fs->users)
66242 + gr_set_chroot_entries(current, &current->fs->root);
66243 + if (atomic_dec_return(&fs->users))
66244 new_fs = NULL;
66245 else
66246 new_fs = fs;
66247 diff --git a/kernel/futex.c b/kernel/futex.c
66248 index 866c9d5..5c5f828 100644
66249 --- a/kernel/futex.c
66250 +++ b/kernel/futex.c
66251 @@ -54,6 +54,7 @@
66252 #include <linux/mount.h>
66253 #include <linux/pagemap.h>
66254 #include <linux/syscalls.h>
66255 +#include <linux/ptrace.h>
66256 #include <linux/signal.h>
66257 #include <linux/export.h>
66258 #include <linux/magic.h>
66259 @@ -239,6 +240,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
66260 struct page *page, *page_head;
66261 int err, ro = 0;
66262
66263 +#ifdef CONFIG_PAX_SEGMEXEC
66264 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
66265 + return -EFAULT;
66266 +#endif
66267 +
66268 /*
66269 * The futex address must be "naturally" aligned.
66270 */
66271 @@ -2721,6 +2727,7 @@ static int __init futex_init(void)
66272 {
66273 u32 curval;
66274 int i;
66275 + mm_segment_t oldfs;
66276
66277 /*
66278 * This will fail and we want it. Some arch implementations do
66279 @@ -2732,8 +2739,11 @@ static int __init futex_init(void)
66280 * implementation, the non-functional ones will return
66281 * -ENOSYS.
66282 */
66283 + oldfs = get_fs();
66284 + set_fs(USER_DS);
66285 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
66286 futex_cmpxchg_enabled = 1;
66287 + set_fs(oldfs);
66288
66289 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
66290 plist_head_init(&futex_queues[i].chain);
66291 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
66292 index 9b22d03..6295b62 100644
66293 --- a/kernel/gcov/base.c
66294 +++ b/kernel/gcov/base.c
66295 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
66296 }
66297
66298 #ifdef CONFIG_MODULES
66299 -static inline int within(void *addr, void *start, unsigned long size)
66300 -{
66301 - return ((addr >= start) && (addr < start + size));
66302 -}
66303 -
66304 /* Update list and generate events when modules are unloaded. */
66305 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
66306 void *data)
66307 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
66308 prev = NULL;
66309 /* Remove entries located in module from linked list. */
66310 for (info = gcov_info_head; info; info = info->next) {
66311 - if (within(info, mod->module_core, mod->core_size)) {
66312 + if (within_module_core_rw((unsigned long)info, mod)) {
66313 if (prev)
66314 prev->next = info->next;
66315 else
66316 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
66317 index ae34bf5..4e2f3d0 100644
66318 --- a/kernel/hrtimer.c
66319 +++ b/kernel/hrtimer.c
66320 @@ -1393,7 +1393,7 @@ void hrtimer_peek_ahead_timers(void)
66321 local_irq_restore(flags);
66322 }
66323
66324 -static void run_hrtimer_softirq(struct softirq_action *h)
66325 +static void run_hrtimer_softirq(void)
66326 {
66327 hrtimer_peek_ahead_timers();
66328 }
66329 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
66330 index 01d3b70..9e4d098 100644
66331 --- a/kernel/jump_label.c
66332 +++ b/kernel/jump_label.c
66333 @@ -55,7 +55,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
66334
66335 size = (((unsigned long)stop - (unsigned long)start)
66336 / sizeof(struct jump_entry));
66337 + pax_open_kernel();
66338 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
66339 + pax_close_kernel();
66340 }
66341
66342 static void jump_label_update(struct jump_label_key *key, int enable);
66343 @@ -340,10 +342,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
66344 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
66345 struct jump_entry *iter;
66346
66347 + pax_open_kernel();
66348 for (iter = iter_start; iter < iter_stop; iter++) {
66349 if (within_module_init(iter->code, mod))
66350 iter->code = 0;
66351 }
66352 + pax_close_kernel();
66353 }
66354
66355 static int
66356 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
66357 index 079f1d3..a407562 100644
66358 --- a/kernel/kallsyms.c
66359 +++ b/kernel/kallsyms.c
66360 @@ -11,6 +11,9 @@
66361 * Changed the compression method from stem compression to "table lookup"
66362 * compression (see scripts/kallsyms.c for a more complete description)
66363 */
66364 +#ifdef CONFIG_GRKERNSEC_HIDESYM
66365 +#define __INCLUDED_BY_HIDESYM 1
66366 +#endif
66367 #include <linux/kallsyms.h>
66368 #include <linux/module.h>
66369 #include <linux/init.h>
66370 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
66371
66372 static inline int is_kernel_inittext(unsigned long addr)
66373 {
66374 + if (system_state != SYSTEM_BOOTING)
66375 + return 0;
66376 +
66377 if (addr >= (unsigned long)_sinittext
66378 && addr <= (unsigned long)_einittext)
66379 return 1;
66380 return 0;
66381 }
66382
66383 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
66384 +#ifdef CONFIG_MODULES
66385 +static inline int is_module_text(unsigned long addr)
66386 +{
66387 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
66388 + return 1;
66389 +
66390 + addr = ktla_ktva(addr);
66391 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
66392 +}
66393 +#else
66394 +static inline int is_module_text(unsigned long addr)
66395 +{
66396 + return 0;
66397 +}
66398 +#endif
66399 +#endif
66400 +
66401 static inline int is_kernel_text(unsigned long addr)
66402 {
66403 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
66404 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
66405
66406 static inline int is_kernel(unsigned long addr)
66407 {
66408 +
66409 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
66410 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
66411 + return 1;
66412 +
66413 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
66414 +#else
66415 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
66416 +#endif
66417 +
66418 return 1;
66419 return in_gate_area_no_mm(addr);
66420 }
66421
66422 static int is_ksym_addr(unsigned long addr)
66423 {
66424 +
66425 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
66426 + if (is_module_text(addr))
66427 + return 0;
66428 +#endif
66429 +
66430 if (all_var)
66431 return is_kernel(addr);
66432
66433 @@ -454,7 +493,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
66434
66435 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
66436 {
66437 - iter->name[0] = '\0';
66438 iter->nameoff = get_symbol_offset(new_pos);
66439 iter->pos = new_pos;
66440 }
66441 @@ -502,6 +540,11 @@ static int s_show(struct seq_file *m, void *p)
66442 {
66443 struct kallsym_iter *iter = m->private;
66444
66445 +#ifdef CONFIG_GRKERNSEC_HIDESYM
66446 + if (current_uid())
66447 + return 0;
66448 +#endif
66449 +
66450 /* Some debugging symbols have no name. Ignore them. */
66451 if (!iter->name[0])
66452 return 0;
66453 @@ -540,7 +583,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
66454 struct kallsym_iter *iter;
66455 int ret;
66456
66457 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
66458 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
66459 if (!iter)
66460 return -ENOMEM;
66461 reset_iter(iter, 0);
66462 diff --git a/kernel/kexec.c b/kernel/kexec.c
66463 index 7b08867..3bac516 100644
66464 --- a/kernel/kexec.c
66465 +++ b/kernel/kexec.c
66466 @@ -1047,7 +1047,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
66467 unsigned long flags)
66468 {
66469 struct compat_kexec_segment in;
66470 - struct kexec_segment out, __user *ksegments;
66471 + struct kexec_segment out;
66472 + struct kexec_segment __user *ksegments;
66473 unsigned long i, result;
66474
66475 /* Don't allow clients that don't understand the native
66476 diff --git a/kernel/kmod.c b/kernel/kmod.c
66477 index a3a46cb..f2e42f8 100644
66478 --- a/kernel/kmod.c
66479 +++ b/kernel/kmod.c
66480 @@ -75,13 +75,12 @@ char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe";
66481 * If module auto-loading support is disabled then this function
66482 * becomes a no-operation.
66483 */
66484 -int __request_module(bool wait, const char *fmt, ...)
66485 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
66486 {
66487 - va_list args;
66488 char module_name[MODULE_NAME_LEN];
66489 unsigned int max_modprobes;
66490 int ret;
66491 - char *argv[] = { modprobe_path, "-q", "--", module_name, NULL };
66492 + char *argv[] = { modprobe_path, "-q", "--", module_name, module_param, NULL };
66493 static char *envp[] = { "HOME=/",
66494 "TERM=linux",
66495 "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
66496 @@ -90,9 +89,7 @@ int __request_module(bool wait, const char *fmt, ...)
66497 #define MAX_KMOD_CONCURRENT 50 /* Completely arbitrary value - KAO */
66498 static int kmod_loop_msg;
66499
66500 - va_start(args, fmt);
66501 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
66502 - va_end(args);
66503 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
66504 if (ret >= MODULE_NAME_LEN)
66505 return -ENAMETOOLONG;
66506
66507 @@ -100,6 +97,20 @@ int __request_module(bool wait, const char *fmt, ...)
66508 if (ret)
66509 return ret;
66510
66511 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
66512 + if (!current_uid()) {
66513 + /* hack to workaround consolekit/udisks stupidity */
66514 + read_lock(&tasklist_lock);
66515 + if (!strcmp(current->comm, "mount") &&
66516 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
66517 + read_unlock(&tasklist_lock);
66518 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
66519 + return -EPERM;
66520 + }
66521 + read_unlock(&tasklist_lock);
66522 + }
66523 +#endif
66524 +
66525 /* If modprobe needs a service that is in a module, we get a recursive
66526 * loop. Limit the number of running kmod threads to max_threads/2 or
66527 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
66528 @@ -135,6 +146,47 @@ int __request_module(bool wait, const char *fmt, ...)
66529 atomic_dec(&kmod_concurrent);
66530 return ret;
66531 }
66532 +
66533 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
66534 +{
66535 + va_list args;
66536 + int ret;
66537 +
66538 + va_start(args, fmt);
66539 + ret = ____request_module(wait, module_param, fmt, args);
66540 + va_end(args);
66541 +
66542 + return ret;
66543 +}
66544 +
66545 +int __request_module(bool wait, const char *fmt, ...)
66546 +{
66547 + va_list args;
66548 + int ret;
66549 +
66550 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
66551 + if (current_uid()) {
66552 + char module_param[MODULE_NAME_LEN];
66553 +
66554 + memset(module_param, 0, sizeof(module_param));
66555 +
66556 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", current_uid());
66557 +
66558 + va_start(args, fmt);
66559 + ret = ____request_module(wait, module_param, fmt, args);
66560 + va_end(args);
66561 +
66562 + return ret;
66563 + }
66564 +#endif
66565 +
66566 + va_start(args, fmt);
66567 + ret = ____request_module(wait, NULL, fmt, args);
66568 + va_end(args);
66569 +
66570 + return ret;
66571 +}
66572 +
66573 EXPORT_SYMBOL(__request_module);
66574 #endif /* CONFIG_MODULES */
66575
66576 @@ -224,7 +276,7 @@ static int wait_for_helper(void *data)
66577 *
66578 * Thus the __user pointer cast is valid here.
66579 */
66580 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
66581 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
66582
66583 /*
66584 * If ret is 0, either ____call_usermodehelper failed and the
66585 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
66586 index c62b854..cb67968 100644
66587 --- a/kernel/kprobes.c
66588 +++ b/kernel/kprobes.c
66589 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
66590 * kernel image and loaded module images reside. This is required
66591 * so x86_64 can correctly handle the %rip-relative fixups.
66592 */
66593 - kip->insns = module_alloc(PAGE_SIZE);
66594 + kip->insns = module_alloc_exec(PAGE_SIZE);
66595 if (!kip->insns) {
66596 kfree(kip);
66597 return NULL;
66598 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
66599 */
66600 if (!list_is_singular(&kip->list)) {
66601 list_del(&kip->list);
66602 - module_free(NULL, kip->insns);
66603 + module_free_exec(NULL, kip->insns);
66604 kfree(kip);
66605 }
66606 return 1;
66607 @@ -1955,7 +1955,7 @@ static int __init init_kprobes(void)
66608 {
66609 int i, err = 0;
66610 unsigned long offset = 0, size = 0;
66611 - char *modname, namebuf[128];
66612 + char *modname, namebuf[KSYM_NAME_LEN];
66613 const char *symbol_name;
66614 void *addr;
66615 struct kprobe_blackpoint *kb;
66616 @@ -2081,7 +2081,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
66617 const char *sym = NULL;
66618 unsigned int i = *(loff_t *) v;
66619 unsigned long offset = 0;
66620 - char *modname, namebuf[128];
66621 + char *modname, namebuf[KSYM_NAME_LEN];
66622
66623 head = &kprobe_table[i];
66624 preempt_disable();
66625 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
66626 index 4e316e1..5501eef 100644
66627 --- a/kernel/ksysfs.c
66628 +++ b/kernel/ksysfs.c
66629 @@ -47,6 +47,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
66630 {
66631 if (count+1 > UEVENT_HELPER_PATH_LEN)
66632 return -ENOENT;
66633 + if (!capable(CAP_SYS_ADMIN))
66634 + return -EPERM;
66635 memcpy(uevent_helper, buf, count);
66636 uevent_helper[count] = '\0';
66637 if (count && uevent_helper[count-1] == '\n')
66638 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
66639 index 8889f7d..95319b7 100644
66640 --- a/kernel/lockdep.c
66641 +++ b/kernel/lockdep.c
66642 @@ -590,6 +590,10 @@ static int static_obj(void *obj)
66643 end = (unsigned long) &_end,
66644 addr = (unsigned long) obj;
66645
66646 +#ifdef CONFIG_PAX_KERNEXEC
66647 + start = ktla_ktva(start);
66648 +#endif
66649 +
66650 /*
66651 * static variable?
66652 */
66653 @@ -730,6 +734,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
66654 if (!static_obj(lock->key)) {
66655 debug_locks_off();
66656 printk("INFO: trying to register non-static key.\n");
66657 + printk("lock:%pS key:%pS.\n", lock, lock->key);
66658 printk("the code is fine but needs lockdep annotation.\n");
66659 printk("turning off the locking correctness validator.\n");
66660 dump_stack();
66661 @@ -3042,7 +3047,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
66662 if (!class)
66663 return 0;
66664 }
66665 - atomic_inc((atomic_t *)&class->ops);
66666 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
66667 if (very_verbose(class)) {
66668 printk("\nacquire class [%p] %s", class->key, class->name);
66669 if (class->name_version > 1)
66670 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
66671 index 91c32a0..b2c71c5 100644
66672 --- a/kernel/lockdep_proc.c
66673 +++ b/kernel/lockdep_proc.c
66674 @@ -39,7 +39,7 @@ static void l_stop(struct seq_file *m, void *v)
66675
66676 static void print_name(struct seq_file *m, struct lock_class *class)
66677 {
66678 - char str[128];
66679 + char str[KSYM_NAME_LEN];
66680 const char *name = class->name;
66681
66682 if (!name) {
66683 diff --git a/kernel/module.c b/kernel/module.c
66684 index 3d56b6f..2a22bd0 100644
66685 --- a/kernel/module.c
66686 +++ b/kernel/module.c
66687 @@ -58,6 +58,7 @@
66688 #include <linux/jump_label.h>
66689 #include <linux/pfn.h>
66690 #include <linux/bsearch.h>
66691 +#include <linux/grsecurity.h>
66692
66693 #define CREATE_TRACE_POINTS
66694 #include <trace/events/module.h>
66695 @@ -113,7 +114,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
66696
66697 /* Bounds of module allocation, for speeding __module_address.
66698 * Protected by module_mutex. */
66699 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
66700 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
66701 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
66702
66703 int register_module_notifier(struct notifier_block * nb)
66704 {
66705 @@ -277,7 +279,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
66706 return true;
66707
66708 list_for_each_entry_rcu(mod, &modules, list) {
66709 - struct symsearch arr[] = {
66710 + struct symsearch modarr[] = {
66711 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
66712 NOT_GPL_ONLY, false },
66713 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
66714 @@ -299,7 +301,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
66715 #endif
66716 };
66717
66718 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
66719 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
66720 return true;
66721 }
66722 return false;
66723 @@ -431,7 +433,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
66724 static int percpu_modalloc(struct module *mod,
66725 unsigned long size, unsigned long align)
66726 {
66727 - if (align > PAGE_SIZE) {
66728 + if (align-1 >= PAGE_SIZE) {
66729 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
66730 mod->name, align, PAGE_SIZE);
66731 align = PAGE_SIZE;
66732 @@ -1001,7 +1003,7 @@ struct module_attribute module_uevent =
66733 static ssize_t show_coresize(struct module_attribute *mattr,
66734 struct module_kobject *mk, char *buffer)
66735 {
66736 - return sprintf(buffer, "%u\n", mk->mod->core_size);
66737 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
66738 }
66739
66740 static struct module_attribute modinfo_coresize =
66741 @@ -1010,7 +1012,7 @@ static struct module_attribute modinfo_coresize =
66742 static ssize_t show_initsize(struct module_attribute *mattr,
66743 struct module_kobject *mk, char *buffer)
66744 {
66745 - return sprintf(buffer, "%u\n", mk->mod->init_size);
66746 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
66747 }
66748
66749 static struct module_attribute modinfo_initsize =
66750 @@ -1224,7 +1226,7 @@ resolve_symbol_wait(struct module *mod,
66751 */
66752 #ifdef CONFIG_SYSFS
66753
66754 -#ifdef CONFIG_KALLSYMS
66755 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
66756 static inline bool sect_empty(const Elf_Shdr *sect)
66757 {
66758 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
66759 @@ -1690,21 +1692,21 @@ static void set_section_ro_nx(void *base,
66760
66761 static void unset_module_core_ro_nx(struct module *mod)
66762 {
66763 - set_page_attributes(mod->module_core + mod->core_text_size,
66764 - mod->module_core + mod->core_size,
66765 + set_page_attributes(mod->module_core_rw,
66766 + mod->module_core_rw + mod->core_size_rw,
66767 set_memory_x);
66768 - set_page_attributes(mod->module_core,
66769 - mod->module_core + mod->core_ro_size,
66770 + set_page_attributes(mod->module_core_rx,
66771 + mod->module_core_rx + mod->core_size_rx,
66772 set_memory_rw);
66773 }
66774
66775 static void unset_module_init_ro_nx(struct module *mod)
66776 {
66777 - set_page_attributes(mod->module_init + mod->init_text_size,
66778 - mod->module_init + mod->init_size,
66779 + set_page_attributes(mod->module_init_rw,
66780 + mod->module_init_rw + mod->init_size_rw,
66781 set_memory_x);
66782 - set_page_attributes(mod->module_init,
66783 - mod->module_init + mod->init_ro_size,
66784 + set_page_attributes(mod->module_init_rx,
66785 + mod->module_init_rx + mod->init_size_rx,
66786 set_memory_rw);
66787 }
66788
66789 @@ -1715,14 +1717,14 @@ void set_all_modules_text_rw(void)
66790
66791 mutex_lock(&module_mutex);
66792 list_for_each_entry_rcu(mod, &modules, list) {
66793 - if ((mod->module_core) && (mod->core_text_size)) {
66794 - set_page_attributes(mod->module_core,
66795 - mod->module_core + mod->core_text_size,
66796 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
66797 + set_page_attributes(mod->module_core_rx,
66798 + mod->module_core_rx + mod->core_size_rx,
66799 set_memory_rw);
66800 }
66801 - if ((mod->module_init) && (mod->init_text_size)) {
66802 - set_page_attributes(mod->module_init,
66803 - mod->module_init + mod->init_text_size,
66804 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
66805 + set_page_attributes(mod->module_init_rx,
66806 + mod->module_init_rx + mod->init_size_rx,
66807 set_memory_rw);
66808 }
66809 }
66810 @@ -1736,14 +1738,14 @@ void set_all_modules_text_ro(void)
66811
66812 mutex_lock(&module_mutex);
66813 list_for_each_entry_rcu(mod, &modules, list) {
66814 - if ((mod->module_core) && (mod->core_text_size)) {
66815 - set_page_attributes(mod->module_core,
66816 - mod->module_core + mod->core_text_size,
66817 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
66818 + set_page_attributes(mod->module_core_rx,
66819 + mod->module_core_rx + mod->core_size_rx,
66820 set_memory_ro);
66821 }
66822 - if ((mod->module_init) && (mod->init_text_size)) {
66823 - set_page_attributes(mod->module_init,
66824 - mod->module_init + mod->init_text_size,
66825 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
66826 + set_page_attributes(mod->module_init_rx,
66827 + mod->module_init_rx + mod->init_size_rx,
66828 set_memory_ro);
66829 }
66830 }
66831 @@ -1789,16 +1791,19 @@ static void free_module(struct module *mod)
66832
66833 /* This may be NULL, but that's OK */
66834 unset_module_init_ro_nx(mod);
66835 - module_free(mod, mod->module_init);
66836 + module_free(mod, mod->module_init_rw);
66837 + module_free_exec(mod, mod->module_init_rx);
66838 kfree(mod->args);
66839 percpu_modfree(mod);
66840
66841 /* Free lock-classes: */
66842 - lockdep_free_key_range(mod->module_core, mod->core_size);
66843 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
66844 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
66845
66846 /* Finally, free the core (containing the module structure) */
66847 unset_module_core_ro_nx(mod);
66848 - module_free(mod, mod->module_core);
66849 + module_free_exec(mod, mod->module_core_rx);
66850 + module_free(mod, mod->module_core_rw);
66851
66852 #ifdef CONFIG_MPU
66853 update_protections(current->mm);
66854 @@ -1867,10 +1872,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
66855 unsigned int i;
66856 int ret = 0;
66857 const struct kernel_symbol *ksym;
66858 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
66859 + int is_fs_load = 0;
66860 + int register_filesystem_found = 0;
66861 + char *p;
66862 +
66863 + p = strstr(mod->args, "grsec_modharden_fs");
66864 + if (p) {
66865 + char *endptr = p + strlen("grsec_modharden_fs");
66866 + /* copy \0 as well */
66867 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
66868 + is_fs_load = 1;
66869 + }
66870 +#endif
66871
66872 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
66873 const char *name = info->strtab + sym[i].st_name;
66874
66875 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
66876 + /* it's a real shame this will never get ripped and copied
66877 + upstream! ;(
66878 + */
66879 + if (is_fs_load && !strcmp(name, "register_filesystem"))
66880 + register_filesystem_found = 1;
66881 +#endif
66882 +
66883 switch (sym[i].st_shndx) {
66884 case SHN_COMMON:
66885 /* We compiled with -fno-common. These are not
66886 @@ -1891,7 +1917,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
66887 ksym = resolve_symbol_wait(mod, info, name);
66888 /* Ok if resolved. */
66889 if (ksym && !IS_ERR(ksym)) {
66890 + pax_open_kernel();
66891 sym[i].st_value = ksym->value;
66892 + pax_close_kernel();
66893 break;
66894 }
66895
66896 @@ -1910,11 +1938,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
66897 secbase = (unsigned long)mod_percpu(mod);
66898 else
66899 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
66900 + pax_open_kernel();
66901 sym[i].st_value += secbase;
66902 + pax_close_kernel();
66903 break;
66904 }
66905 }
66906
66907 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
66908 + if (is_fs_load && !register_filesystem_found) {
66909 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
66910 + ret = -EPERM;
66911 + }
66912 +#endif
66913 +
66914 return ret;
66915 }
66916
66917 @@ -2018,22 +2055,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
66918 || s->sh_entsize != ~0UL
66919 || strstarts(sname, ".init"))
66920 continue;
66921 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
66922 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
66923 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
66924 + else
66925 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
66926 pr_debug("\t%s\n", sname);
66927 }
66928 - switch (m) {
66929 - case 0: /* executable */
66930 - mod->core_size = debug_align(mod->core_size);
66931 - mod->core_text_size = mod->core_size;
66932 - break;
66933 - case 1: /* RO: text and ro-data */
66934 - mod->core_size = debug_align(mod->core_size);
66935 - mod->core_ro_size = mod->core_size;
66936 - break;
66937 - case 3: /* whole core */
66938 - mod->core_size = debug_align(mod->core_size);
66939 - break;
66940 - }
66941 }
66942
66943 pr_debug("Init section allocation order:\n");
66944 @@ -2047,23 +2074,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
66945 || s->sh_entsize != ~0UL
66946 || !strstarts(sname, ".init"))
66947 continue;
66948 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
66949 - | INIT_OFFSET_MASK);
66950 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
66951 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
66952 + else
66953 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
66954 + s->sh_entsize |= INIT_OFFSET_MASK;
66955 pr_debug("\t%s\n", sname);
66956 }
66957 - switch (m) {
66958 - case 0: /* executable */
66959 - mod->init_size = debug_align(mod->init_size);
66960 - mod->init_text_size = mod->init_size;
66961 - break;
66962 - case 1: /* RO: text and ro-data */
66963 - mod->init_size = debug_align(mod->init_size);
66964 - mod->init_ro_size = mod->init_size;
66965 - break;
66966 - case 3: /* whole init */
66967 - mod->init_size = debug_align(mod->init_size);
66968 - break;
66969 - }
66970 }
66971 }
66972
66973 @@ -2235,7 +2252,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
66974
66975 /* Put symbol section at end of init part of module. */
66976 symsect->sh_flags |= SHF_ALLOC;
66977 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
66978 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
66979 info->index.sym) | INIT_OFFSET_MASK;
66980 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
66981
66982 @@ -2250,13 +2267,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
66983 }
66984
66985 /* Append room for core symbols at end of core part. */
66986 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
66987 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
66988 - mod->core_size += strtab_size;
66989 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
66990 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
66991 + mod->core_size_rx += strtab_size;
66992
66993 /* Put string table section at end of init part of module. */
66994 strsect->sh_flags |= SHF_ALLOC;
66995 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
66996 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
66997 info->index.str) | INIT_OFFSET_MASK;
66998 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
66999 }
67000 @@ -2274,12 +2291,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
67001 /* Make sure we get permanent strtab: don't use info->strtab. */
67002 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
67003
67004 + pax_open_kernel();
67005 +
67006 /* Set types up while we still have access to sections. */
67007 for (i = 0; i < mod->num_symtab; i++)
67008 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
67009
67010 - mod->core_symtab = dst = mod->module_core + info->symoffs;
67011 - mod->core_strtab = s = mod->module_core + info->stroffs;
67012 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
67013 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
67014 src = mod->symtab;
67015 *dst = *src;
67016 *s++ = 0;
67017 @@ -2292,6 +2311,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
67018 s += strlcpy(s, &mod->strtab[src->st_name], KSYM_NAME_LEN) + 1;
67019 }
67020 mod->core_num_syms = ndst;
67021 +
67022 + pax_close_kernel();
67023 }
67024 #else
67025 static inline void layout_symtab(struct module *mod, struct load_info *info)
67026 @@ -2325,17 +2346,33 @@ void * __weak module_alloc(unsigned long size)
67027 return size == 0 ? NULL : vmalloc_exec(size);
67028 }
67029
67030 -static void *module_alloc_update_bounds(unsigned long size)
67031 +static void *module_alloc_update_bounds_rw(unsigned long size)
67032 {
67033 void *ret = module_alloc(size);
67034
67035 if (ret) {
67036 mutex_lock(&module_mutex);
67037 /* Update module bounds. */
67038 - if ((unsigned long)ret < module_addr_min)
67039 - module_addr_min = (unsigned long)ret;
67040 - if ((unsigned long)ret + size > module_addr_max)
67041 - module_addr_max = (unsigned long)ret + size;
67042 + if ((unsigned long)ret < module_addr_min_rw)
67043 + module_addr_min_rw = (unsigned long)ret;
67044 + if ((unsigned long)ret + size > module_addr_max_rw)
67045 + module_addr_max_rw = (unsigned long)ret + size;
67046 + mutex_unlock(&module_mutex);
67047 + }
67048 + return ret;
67049 +}
67050 +
67051 +static void *module_alloc_update_bounds_rx(unsigned long size)
67052 +{
67053 + void *ret = module_alloc_exec(size);
67054 +
67055 + if (ret) {
67056 + mutex_lock(&module_mutex);
67057 + /* Update module bounds. */
67058 + if ((unsigned long)ret < module_addr_min_rx)
67059 + module_addr_min_rx = (unsigned long)ret;
67060 + if ((unsigned long)ret + size > module_addr_max_rx)
67061 + module_addr_max_rx = (unsigned long)ret + size;
67062 mutex_unlock(&module_mutex);
67063 }
67064 return ret;
67065 @@ -2512,8 +2549,14 @@ static struct module *setup_load_info(struct load_info *info)
67066 static int check_modinfo(struct module *mod, struct load_info *info)
67067 {
67068 const char *modmagic = get_modinfo(info, "vermagic");
67069 + const char *license = get_modinfo(info, "license");
67070 int err;
67071
67072 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
67073 + if (!license || !license_is_gpl_compatible(license))
67074 + return -ENOEXEC;
67075 +#endif
67076 +
67077 /* This is allowed: modprobe --force will invalidate it. */
67078 if (!modmagic) {
67079 err = try_to_force_load(mod, "bad vermagic");
67080 @@ -2536,7 +2579,7 @@ static int check_modinfo(struct module *mod, struct load_info *info)
67081 }
67082
67083 /* Set up license info based on the info section */
67084 - set_license(mod, get_modinfo(info, "license"));
67085 + set_license(mod, license);
67086
67087 return 0;
67088 }
67089 @@ -2630,7 +2673,7 @@ static int move_module(struct module *mod, struct load_info *info)
67090 void *ptr;
67091
67092 /* Do the allocs. */
67093 - ptr = module_alloc_update_bounds(mod->core_size);
67094 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
67095 /*
67096 * The pointer to this block is stored in the module structure
67097 * which is inside the block. Just mark it as not being a
67098 @@ -2640,23 +2683,50 @@ static int move_module(struct module *mod, struct load_info *info)
67099 if (!ptr)
67100 return -ENOMEM;
67101
67102 - memset(ptr, 0, mod->core_size);
67103 - mod->module_core = ptr;
67104 + memset(ptr, 0, mod->core_size_rw);
67105 + mod->module_core_rw = ptr;
67106
67107 - ptr = module_alloc_update_bounds(mod->init_size);
67108 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
67109 /*
67110 * The pointer to this block is stored in the module structure
67111 * which is inside the block. This block doesn't need to be
67112 * scanned as it contains data and code that will be freed
67113 * after the module is initialized.
67114 */
67115 - kmemleak_ignore(ptr);
67116 - if (!ptr && mod->init_size) {
67117 - module_free(mod, mod->module_core);
67118 + kmemleak_not_leak(ptr);
67119 + if (!ptr && mod->init_size_rw) {
67120 + module_free(mod, mod->module_core_rw);
67121 return -ENOMEM;
67122 }
67123 - memset(ptr, 0, mod->init_size);
67124 - mod->module_init = ptr;
67125 + memset(ptr, 0, mod->init_size_rw);
67126 + mod->module_init_rw = ptr;
67127 +
67128 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
67129 + kmemleak_not_leak(ptr);
67130 + if (!ptr) {
67131 + module_free(mod, mod->module_init_rw);
67132 + module_free(mod, mod->module_core_rw);
67133 + return -ENOMEM;
67134 + }
67135 +
67136 + pax_open_kernel();
67137 + memset(ptr, 0, mod->core_size_rx);
67138 + pax_close_kernel();
67139 + mod->module_core_rx = ptr;
67140 +
67141 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
67142 + kmemleak_not_leak(ptr);
67143 + if (!ptr && mod->init_size_rx) {
67144 + module_free_exec(mod, mod->module_core_rx);
67145 + module_free(mod, mod->module_init_rw);
67146 + module_free(mod, mod->module_core_rw);
67147 + return -ENOMEM;
67148 + }
67149 +
67150 + pax_open_kernel();
67151 + memset(ptr, 0, mod->init_size_rx);
67152 + pax_close_kernel();
67153 + mod->module_init_rx = ptr;
67154
67155 /* Transfer each section which specifies SHF_ALLOC */
67156 pr_debug("final section addresses:\n");
67157 @@ -2667,16 +2737,45 @@ static int move_module(struct module *mod, struct load_info *info)
67158 if (!(shdr->sh_flags & SHF_ALLOC))
67159 continue;
67160
67161 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
67162 - dest = mod->module_init
67163 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
67164 - else
67165 - dest = mod->module_core + shdr->sh_entsize;
67166 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
67167 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
67168 + dest = mod->module_init_rw
67169 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
67170 + else
67171 + dest = mod->module_init_rx
67172 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
67173 + } else {
67174 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
67175 + dest = mod->module_core_rw + shdr->sh_entsize;
67176 + else
67177 + dest = mod->module_core_rx + shdr->sh_entsize;
67178 + }
67179 +
67180 + if (shdr->sh_type != SHT_NOBITS) {
67181 +
67182 +#ifdef CONFIG_PAX_KERNEXEC
67183 +#ifdef CONFIG_X86_64
67184 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
67185 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
67186 +#endif
67187 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
67188 + pax_open_kernel();
67189 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
67190 + pax_close_kernel();
67191 + } else
67192 +#endif
67193
67194 - if (shdr->sh_type != SHT_NOBITS)
67195 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
67196 + }
67197 /* Update sh_addr to point to copy in image. */
67198 - shdr->sh_addr = (unsigned long)dest;
67199 +
67200 +#ifdef CONFIG_PAX_KERNEXEC
67201 + if (shdr->sh_flags & SHF_EXECINSTR)
67202 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
67203 + else
67204 +#endif
67205 +
67206 + shdr->sh_addr = (unsigned long)dest;
67207 pr_debug("\t0x%lx %s\n",
67208 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
67209 }
67210 @@ -2727,12 +2826,12 @@ static void flush_module_icache(const struct module *mod)
67211 * Do it before processing of module parameters, so the module
67212 * can provide parameter accessor functions of its own.
67213 */
67214 - if (mod->module_init)
67215 - flush_icache_range((unsigned long)mod->module_init,
67216 - (unsigned long)mod->module_init
67217 - + mod->init_size);
67218 - flush_icache_range((unsigned long)mod->module_core,
67219 - (unsigned long)mod->module_core + mod->core_size);
67220 + if (mod->module_init_rx)
67221 + flush_icache_range((unsigned long)mod->module_init_rx,
67222 + (unsigned long)mod->module_init_rx
67223 + + mod->init_size_rx);
67224 + flush_icache_range((unsigned long)mod->module_core_rx,
67225 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
67226
67227 set_fs(old_fs);
67228 }
67229 @@ -2802,8 +2901,10 @@ out:
67230 static void module_deallocate(struct module *mod, struct load_info *info)
67231 {
67232 percpu_modfree(mod);
67233 - module_free(mod, mod->module_init);
67234 - module_free(mod, mod->module_core);
67235 + module_free_exec(mod, mod->module_init_rx);
67236 + module_free_exec(mod, mod->module_core_rx);
67237 + module_free(mod, mod->module_init_rw);
67238 + module_free(mod, mod->module_core_rw);
67239 }
67240
67241 int __weak module_finalize(const Elf_Ehdr *hdr,
67242 @@ -2867,9 +2968,38 @@ static struct module *load_module(void __user *umod,
67243 if (err)
67244 goto free_unload;
67245
67246 + /* Now copy in args */
67247 + mod->args = strndup_user(uargs, ~0UL >> 1);
67248 + if (IS_ERR(mod->args)) {
67249 + err = PTR_ERR(mod->args);
67250 + goto free_unload;
67251 + }
67252 +
67253 /* Set up MODINFO_ATTR fields */
67254 setup_modinfo(mod, &info);
67255
67256 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
67257 + {
67258 + char *p, *p2;
67259 +
67260 + if (strstr(mod->args, "grsec_modharden_netdev")) {
67261 + 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);
67262 + err = -EPERM;
67263 + goto free_modinfo;
67264 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
67265 + p += strlen("grsec_modharden_normal");
67266 + p2 = strstr(p, "_");
67267 + if (p2) {
67268 + *p2 = '\0';
67269 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
67270 + *p2 = '_';
67271 + }
67272 + err = -EPERM;
67273 + goto free_modinfo;
67274 + }
67275 + }
67276 +#endif
67277 +
67278 /* Fix up syms, so that st_value is a pointer to location. */
67279 err = simplify_symbols(mod, &info);
67280 if (err < 0)
67281 @@ -2885,13 +3015,6 @@ static struct module *load_module(void __user *umod,
67282
67283 flush_module_icache(mod);
67284
67285 - /* Now copy in args */
67286 - mod->args = strndup_user(uargs, ~0UL >> 1);
67287 - if (IS_ERR(mod->args)) {
67288 - err = PTR_ERR(mod->args);
67289 - goto free_arch_cleanup;
67290 - }
67291 -
67292 /* Mark state as coming so strong_try_module_get() ignores us. */
67293 mod->state = MODULE_STATE_COMING;
67294
67295 @@ -2948,11 +3071,10 @@ static struct module *load_module(void __user *umod,
67296 unlock:
67297 mutex_unlock(&module_mutex);
67298 synchronize_sched();
67299 - kfree(mod->args);
67300 - free_arch_cleanup:
67301 module_arch_cleanup(mod);
67302 free_modinfo:
67303 free_modinfo(mod);
67304 + kfree(mod->args);
67305 free_unload:
67306 module_unload_free(mod);
67307 free_module:
67308 @@ -2993,16 +3115,16 @@ SYSCALL_DEFINE3(init_module, void __user *, umod,
67309 MODULE_STATE_COMING, mod);
67310
67311 /* Set RO and NX regions for core */
67312 - set_section_ro_nx(mod->module_core,
67313 - mod->core_text_size,
67314 - mod->core_ro_size,
67315 - mod->core_size);
67316 + set_section_ro_nx(mod->module_core_rx,
67317 + mod->core_size_rx,
67318 + mod->core_size_rx,
67319 + mod->core_size_rx);
67320
67321 /* Set RO and NX regions for init */
67322 - set_section_ro_nx(mod->module_init,
67323 - mod->init_text_size,
67324 - mod->init_ro_size,
67325 - mod->init_size);
67326 + set_section_ro_nx(mod->module_init_rx,
67327 + mod->init_size_rx,
67328 + mod->init_size_rx,
67329 + mod->init_size_rx);
67330
67331 do_mod_ctors(mod);
67332 /* Start the module */
67333 @@ -3048,11 +3170,12 @@ SYSCALL_DEFINE3(init_module, void __user *, umod,
67334 mod->strtab = mod->core_strtab;
67335 #endif
67336 unset_module_init_ro_nx(mod);
67337 - module_free(mod, mod->module_init);
67338 - mod->module_init = NULL;
67339 - mod->init_size = 0;
67340 - mod->init_ro_size = 0;
67341 - mod->init_text_size = 0;
67342 + module_free(mod, mod->module_init_rw);
67343 + module_free_exec(mod, mod->module_init_rx);
67344 + mod->module_init_rw = NULL;
67345 + mod->module_init_rx = NULL;
67346 + mod->init_size_rw = 0;
67347 + mod->init_size_rx = 0;
67348 mutex_unlock(&module_mutex);
67349
67350 return 0;
67351 @@ -3083,10 +3206,16 @@ static const char *get_ksymbol(struct module *mod,
67352 unsigned long nextval;
67353
67354 /* At worse, next value is at end of module */
67355 - if (within_module_init(addr, mod))
67356 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
67357 + if (within_module_init_rx(addr, mod))
67358 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
67359 + else if (within_module_init_rw(addr, mod))
67360 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
67361 + else if (within_module_core_rx(addr, mod))
67362 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
67363 + else if (within_module_core_rw(addr, mod))
67364 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
67365 else
67366 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
67367 + return NULL;
67368
67369 /* Scan for closest preceding symbol, and next symbol. (ELF
67370 starts real symbols at 1). */
67371 @@ -3321,7 +3450,7 @@ static int m_show(struct seq_file *m, void *p)
67372 char buf[8];
67373
67374 seq_printf(m, "%s %u",
67375 - mod->name, mod->init_size + mod->core_size);
67376 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
67377 print_unload_info(m, mod);
67378
67379 /* Informative for users. */
67380 @@ -3330,7 +3459,7 @@ static int m_show(struct seq_file *m, void *p)
67381 mod->state == MODULE_STATE_COMING ? "Loading":
67382 "Live");
67383 /* Used by oprofile and other similar tools. */
67384 - seq_printf(m, " 0x%pK", mod->module_core);
67385 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
67386
67387 /* Taints info */
67388 if (mod->taints)
67389 @@ -3366,7 +3495,17 @@ static const struct file_operations proc_modules_operations = {
67390
67391 static int __init proc_modules_init(void)
67392 {
67393 +#ifndef CONFIG_GRKERNSEC_HIDESYM
67394 +#ifdef CONFIG_GRKERNSEC_PROC_USER
67395 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
67396 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
67397 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
67398 +#else
67399 proc_create("modules", 0, NULL, &proc_modules_operations);
67400 +#endif
67401 +#else
67402 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
67403 +#endif
67404 return 0;
67405 }
67406 module_init(proc_modules_init);
67407 @@ -3425,12 +3564,12 @@ struct module *__module_address(unsigned long addr)
67408 {
67409 struct module *mod;
67410
67411 - if (addr < module_addr_min || addr > module_addr_max)
67412 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
67413 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
67414 return NULL;
67415
67416 list_for_each_entry_rcu(mod, &modules, list)
67417 - if (within_module_core(addr, mod)
67418 - || within_module_init(addr, mod))
67419 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
67420 return mod;
67421 return NULL;
67422 }
67423 @@ -3464,11 +3603,20 @@ bool is_module_text_address(unsigned long addr)
67424 */
67425 struct module *__module_text_address(unsigned long addr)
67426 {
67427 - struct module *mod = __module_address(addr);
67428 + struct module *mod;
67429 +
67430 +#ifdef CONFIG_X86_32
67431 + addr = ktla_ktva(addr);
67432 +#endif
67433 +
67434 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
67435 + return NULL;
67436 +
67437 + mod = __module_address(addr);
67438 +
67439 if (mod) {
67440 /* Make sure it's within the text section. */
67441 - if (!within(addr, mod->module_init, mod->init_text_size)
67442 - && !within(addr, mod->module_core, mod->core_text_size))
67443 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
67444 mod = NULL;
67445 }
67446 return mod;
67447 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
67448 index 7e3443f..b2a1e6b 100644
67449 --- a/kernel/mutex-debug.c
67450 +++ b/kernel/mutex-debug.c
67451 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
67452 }
67453
67454 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
67455 - struct thread_info *ti)
67456 + struct task_struct *task)
67457 {
67458 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
67459
67460 /* Mark the current thread as blocked on the lock: */
67461 - ti->task->blocked_on = waiter;
67462 + task->blocked_on = waiter;
67463 }
67464
67465 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
67466 - struct thread_info *ti)
67467 + struct task_struct *task)
67468 {
67469 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
67470 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
67471 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
67472 - ti->task->blocked_on = NULL;
67473 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
67474 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
67475 + task->blocked_on = NULL;
67476
67477 list_del_init(&waiter->list);
67478 waiter->task = NULL;
67479 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
67480 index 0799fd3..d06ae3b 100644
67481 --- a/kernel/mutex-debug.h
67482 +++ b/kernel/mutex-debug.h
67483 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
67484 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
67485 extern void debug_mutex_add_waiter(struct mutex *lock,
67486 struct mutex_waiter *waiter,
67487 - struct thread_info *ti);
67488 + struct task_struct *task);
67489 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
67490 - struct thread_info *ti);
67491 + struct task_struct *task);
67492 extern void debug_mutex_unlock(struct mutex *lock);
67493 extern void debug_mutex_init(struct mutex *lock, const char *name,
67494 struct lock_class_key *key);
67495 diff --git a/kernel/mutex.c b/kernel/mutex.c
67496 index 89096dd..f91ebc5 100644
67497 --- a/kernel/mutex.c
67498 +++ b/kernel/mutex.c
67499 @@ -198,7 +198,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
67500 spin_lock_mutex(&lock->wait_lock, flags);
67501
67502 debug_mutex_lock_common(lock, &waiter);
67503 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
67504 + debug_mutex_add_waiter(lock, &waiter, task);
67505
67506 /* add waiting tasks to the end of the waitqueue (FIFO): */
67507 list_add_tail(&waiter.list, &lock->wait_list);
67508 @@ -227,8 +227,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
67509 * TASK_UNINTERRUPTIBLE case.)
67510 */
67511 if (unlikely(signal_pending_state(state, task))) {
67512 - mutex_remove_waiter(lock, &waiter,
67513 - task_thread_info(task));
67514 + mutex_remove_waiter(lock, &waiter, task);
67515 mutex_release(&lock->dep_map, 1, ip);
67516 spin_unlock_mutex(&lock->wait_lock, flags);
67517
67518 @@ -249,7 +248,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
67519 done:
67520 lock_acquired(&lock->dep_map, ip);
67521 /* got the lock - rejoice! */
67522 - mutex_remove_waiter(lock, &waiter, current_thread_info());
67523 + mutex_remove_waiter(lock, &waiter, task);
67524 mutex_set_owner(lock);
67525
67526 /* set it to 0 if there are no waiters left: */
67527 diff --git a/kernel/padata.c b/kernel/padata.c
67528 index b452599..5d68f4e 100644
67529 --- a/kernel/padata.c
67530 +++ b/kernel/padata.c
67531 @@ -132,10 +132,10 @@ int padata_do_parallel(struct padata_instance *pinst,
67532 padata->pd = pd;
67533 padata->cb_cpu = cb_cpu;
67534
67535 - if (unlikely(atomic_read(&pd->seq_nr) == pd->max_seq_nr))
67536 - atomic_set(&pd->seq_nr, -1);
67537 + if (unlikely(atomic_read_unchecked(&pd->seq_nr) == pd->max_seq_nr))
67538 + atomic_set_unchecked(&pd->seq_nr, -1);
67539
67540 - padata->seq_nr = atomic_inc_return(&pd->seq_nr);
67541 + padata->seq_nr = atomic_inc_return_unchecked(&pd->seq_nr);
67542
67543 target_cpu = padata_cpu_hash(padata);
67544 queue = per_cpu_ptr(pd->pqueue, target_cpu);
67545 @@ -444,7 +444,7 @@ static struct parallel_data *padata_alloc_pd(struct padata_instance *pinst,
67546 padata_init_pqueues(pd);
67547 padata_init_squeues(pd);
67548 setup_timer(&pd->timer, padata_reorder_timer, (unsigned long)pd);
67549 - atomic_set(&pd->seq_nr, -1);
67550 + atomic_set_unchecked(&pd->seq_nr, -1);
67551 atomic_set(&pd->reorder_objects, 0);
67552 atomic_set(&pd->refcnt, 0);
67553 pd->pinst = pinst;
67554 diff --git a/kernel/panic.c b/kernel/panic.c
67555 index 8ed89a1..e83856a 100644
67556 --- a/kernel/panic.c
67557 +++ b/kernel/panic.c
67558 @@ -402,7 +402,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
67559 const char *board;
67560
67561 printk(KERN_WARNING "------------[ cut here ]------------\n");
67562 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
67563 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
67564 board = dmi_get_system_info(DMI_PRODUCT_NAME);
67565 if (board)
67566 printk(KERN_WARNING "Hardware name: %s\n", board);
67567 @@ -457,7 +457,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
67568 */
67569 void __stack_chk_fail(void)
67570 {
67571 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
67572 + dump_stack();
67573 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
67574 __builtin_return_address(0));
67575 }
67576 EXPORT_SYMBOL(__stack_chk_fail);
67577 diff --git a/kernel/pid.c b/kernel/pid.c
67578 index 9f08dfa..6765c40 100644
67579 --- a/kernel/pid.c
67580 +++ b/kernel/pid.c
67581 @@ -33,6 +33,7 @@
67582 #include <linux/rculist.h>
67583 #include <linux/bootmem.h>
67584 #include <linux/hash.h>
67585 +#include <linux/security.h>
67586 #include <linux/pid_namespace.h>
67587 #include <linux/init_task.h>
67588 #include <linux/syscalls.h>
67589 @@ -45,7 +46,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
67590
67591 int pid_max = PID_MAX_DEFAULT;
67592
67593 -#define RESERVED_PIDS 300
67594 +#define RESERVED_PIDS 500
67595
67596 int pid_max_min = RESERVED_PIDS + 1;
67597 int pid_max_max = PID_MAX_LIMIT;
67598 @@ -420,10 +421,18 @@ EXPORT_SYMBOL(pid_task);
67599 */
67600 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
67601 {
67602 + struct task_struct *task;
67603 +
67604 rcu_lockdep_assert(rcu_read_lock_held(),
67605 "find_task_by_pid_ns() needs rcu_read_lock()"
67606 " protection");
67607 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
67608 +
67609 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
67610 +
67611 + if (gr_pid_is_chrooted(task))
67612 + return NULL;
67613 +
67614 + return task;
67615 }
67616
67617 struct task_struct *find_task_by_vpid(pid_t vnr)
67618 @@ -431,6 +440,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
67619 return find_task_by_pid_ns(vnr, current->nsproxy->pid_ns);
67620 }
67621
67622 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
67623 +{
67624 + rcu_lockdep_assert(rcu_read_lock_held(),
67625 + "find_task_by_pid_ns() needs rcu_read_lock()"
67626 + " protection");
67627 + return pid_task(find_pid_ns(vnr, current->nsproxy->pid_ns), PIDTYPE_PID);
67628 +}
67629 +
67630 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
67631 {
67632 struct pid *pid;
67633 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
67634 index 125cb67..a4d1c30 100644
67635 --- a/kernel/posix-cpu-timers.c
67636 +++ b/kernel/posix-cpu-timers.c
67637 @@ -6,6 +6,7 @@
67638 #include <linux/posix-timers.h>
67639 #include <linux/errno.h>
67640 #include <linux/math64.h>
67641 +#include <linux/security.h>
67642 #include <asm/uaccess.h>
67643 #include <linux/kernel_stat.h>
67644 #include <trace/events/timer.h>
67645 @@ -1578,14 +1579,14 @@ struct k_clock clock_posix_cpu = {
67646
67647 static __init int init_posix_cpu_timers(void)
67648 {
67649 - struct k_clock process = {
67650 + static struct k_clock process = {
67651 .clock_getres = process_cpu_clock_getres,
67652 .clock_get = process_cpu_clock_get,
67653 .timer_create = process_cpu_timer_create,
67654 .nsleep = process_cpu_nsleep,
67655 .nsleep_restart = process_cpu_nsleep_restart,
67656 };
67657 - struct k_clock thread = {
67658 + static struct k_clock thread = {
67659 .clock_getres = thread_cpu_clock_getres,
67660 .clock_get = thread_cpu_clock_get,
67661 .timer_create = thread_cpu_timer_create,
67662 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
67663 index 69185ae..cc2847a 100644
67664 --- a/kernel/posix-timers.c
67665 +++ b/kernel/posix-timers.c
67666 @@ -43,6 +43,7 @@
67667 #include <linux/idr.h>
67668 #include <linux/posix-clock.h>
67669 #include <linux/posix-timers.h>
67670 +#include <linux/grsecurity.h>
67671 #include <linux/syscalls.h>
67672 #include <linux/wait.h>
67673 #include <linux/workqueue.h>
67674 @@ -129,7 +130,7 @@ static DEFINE_SPINLOCK(idr_lock);
67675 * which we beg off on and pass to do_sys_settimeofday().
67676 */
67677
67678 -static struct k_clock posix_clocks[MAX_CLOCKS];
67679 +static struct k_clock *posix_clocks[MAX_CLOCKS];
67680
67681 /*
67682 * These ones are defined below.
67683 @@ -227,7 +228,7 @@ static int posix_get_boottime(const clockid_t which_clock, struct timespec *tp)
67684 */
67685 static __init int init_posix_timers(void)
67686 {
67687 - struct k_clock clock_realtime = {
67688 + static struct k_clock clock_realtime = {
67689 .clock_getres = hrtimer_get_res,
67690 .clock_get = posix_clock_realtime_get,
67691 .clock_set = posix_clock_realtime_set,
67692 @@ -239,7 +240,7 @@ static __init int init_posix_timers(void)
67693 .timer_get = common_timer_get,
67694 .timer_del = common_timer_del,
67695 };
67696 - struct k_clock clock_monotonic = {
67697 + static struct k_clock clock_monotonic = {
67698 .clock_getres = hrtimer_get_res,
67699 .clock_get = posix_ktime_get_ts,
67700 .nsleep = common_nsleep,
67701 @@ -249,19 +250,19 @@ static __init int init_posix_timers(void)
67702 .timer_get = common_timer_get,
67703 .timer_del = common_timer_del,
67704 };
67705 - struct k_clock clock_monotonic_raw = {
67706 + static struct k_clock clock_monotonic_raw = {
67707 .clock_getres = hrtimer_get_res,
67708 .clock_get = posix_get_monotonic_raw,
67709 };
67710 - struct k_clock clock_realtime_coarse = {
67711 + static struct k_clock clock_realtime_coarse = {
67712 .clock_getres = posix_get_coarse_res,
67713 .clock_get = posix_get_realtime_coarse,
67714 };
67715 - struct k_clock clock_monotonic_coarse = {
67716 + static struct k_clock clock_monotonic_coarse = {
67717 .clock_getres = posix_get_coarse_res,
67718 .clock_get = posix_get_monotonic_coarse,
67719 };
67720 - struct k_clock clock_boottime = {
67721 + static struct k_clock clock_boottime = {
67722 .clock_getres = hrtimer_get_res,
67723 .clock_get = posix_get_boottime,
67724 .nsleep = common_nsleep,
67725 @@ -473,7 +474,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
67726 return;
67727 }
67728
67729 - posix_clocks[clock_id] = *new_clock;
67730 + posix_clocks[clock_id] = new_clock;
67731 }
67732 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
67733
67734 @@ -519,9 +520,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
67735 return (id & CLOCKFD_MASK) == CLOCKFD ?
67736 &clock_posix_dynamic : &clock_posix_cpu;
67737
67738 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
67739 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
67740 return NULL;
67741 - return &posix_clocks[id];
67742 + return posix_clocks[id];
67743 }
67744
67745 static int common_timer_create(struct k_itimer *new_timer)
67746 @@ -959,6 +960,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
67747 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
67748 return -EFAULT;
67749
67750 + /* only the CLOCK_REALTIME clock can be set, all other clocks
67751 + have their clock_set fptr set to a nosettime dummy function
67752 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
67753 + call common_clock_set, which calls do_sys_settimeofday, which
67754 + we hook
67755 + */
67756 +
67757 return kc->clock_set(which_clock, &new_tp);
67758 }
67759
67760 diff --git a/kernel/power/poweroff.c b/kernel/power/poweroff.c
67761 index d523593..68197a4 100644
67762 --- a/kernel/power/poweroff.c
67763 +++ b/kernel/power/poweroff.c
67764 @@ -37,7 +37,7 @@ static struct sysrq_key_op sysrq_poweroff_op = {
67765 .enable_mask = SYSRQ_ENABLE_BOOT,
67766 };
67767
67768 -static int pm_sysrq_init(void)
67769 +static int __init pm_sysrq_init(void)
67770 {
67771 register_sysrq_key('o', &sysrq_poweroff_op);
67772 return 0;
67773 diff --git a/kernel/power/process.c b/kernel/power/process.c
67774 index 7aac07a..2d3c6dc 100644
67775 --- a/kernel/power/process.c
67776 +++ b/kernel/power/process.c
67777 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
67778 u64 elapsed_csecs64;
67779 unsigned int elapsed_csecs;
67780 bool wakeup = false;
67781 + bool timedout = false;
67782
67783 do_gettimeofday(&start);
67784
67785 @@ -43,6 +44,8 @@ static int try_to_freeze_tasks(bool user_only)
67786
67787 while (true) {
67788 todo = 0;
67789 + if (time_after(jiffies, end_time))
67790 + timedout = true;
67791 read_lock(&tasklist_lock);
67792 do_each_thread(g, p) {
67793 if (p == current || !freeze_task(p))
67794 @@ -60,9 +63,13 @@ static int try_to_freeze_tasks(bool user_only)
67795 * try_to_stop() after schedule() in ptrace/signal
67796 * stop sees TIF_FREEZE.
67797 */
67798 - if (!task_is_stopped_or_traced(p) &&
67799 - !freezer_should_skip(p))
67800 + if (!task_is_stopped_or_traced(p) && !freezer_should_skip(p)) {
67801 todo++;
67802 + if (timedout) {
67803 + printk(KERN_ERR "Task refusing to freeze:\n");
67804 + sched_show_task(p);
67805 + }
67806 + }
67807 } while_each_thread(g, p);
67808 read_unlock(&tasklist_lock);
67809
67810 @@ -71,7 +78,7 @@ static int try_to_freeze_tasks(bool user_only)
67811 todo += wq_busy;
67812 }
67813
67814 - if (!todo || time_after(jiffies, end_time))
67815 + if (!todo || timedout)
67816 break;
67817
67818 if (pm_wakeup_pending()) {
67819 diff --git a/kernel/printk.c b/kernel/printk.c
67820 index 32690a0..cd7c798 100644
67821 --- a/kernel/printk.c
67822 +++ b/kernel/printk.c
67823 @@ -313,6 +313,11 @@ static int check_syslog_permissions(int type, bool from_file)
67824 if (from_file && type != SYSLOG_ACTION_OPEN)
67825 return 0;
67826
67827 +#ifdef CONFIG_GRKERNSEC_DMESG
67828 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
67829 + return -EPERM;
67830 +#endif
67831 +
67832 if (syslog_action_restricted(type)) {
67833 if (capable(CAP_SYSLOG))
67834 return 0;
67835 diff --git a/kernel/profile.c b/kernel/profile.c
67836 index 76b8e77..a2930e8 100644
67837 --- a/kernel/profile.c
67838 +++ b/kernel/profile.c
67839 @@ -39,7 +39,7 @@ struct profile_hit {
67840 /* Oprofile timer tick hook */
67841 static int (*timer_hook)(struct pt_regs *) __read_mostly;
67842
67843 -static atomic_t *prof_buffer;
67844 +static atomic_unchecked_t *prof_buffer;
67845 static unsigned long prof_len, prof_shift;
67846
67847 int prof_on __read_mostly;
67848 @@ -281,7 +281,7 @@ static void profile_flip_buffers(void)
67849 hits[i].pc = 0;
67850 continue;
67851 }
67852 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
67853 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
67854 hits[i].hits = hits[i].pc = 0;
67855 }
67856 }
67857 @@ -342,9 +342,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
67858 * Add the current hit(s) and flush the write-queue out
67859 * to the global buffer:
67860 */
67861 - atomic_add(nr_hits, &prof_buffer[pc]);
67862 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
67863 for (i = 0; i < NR_PROFILE_HIT; ++i) {
67864 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
67865 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
67866 hits[i].pc = hits[i].hits = 0;
67867 }
67868 out:
67869 @@ -419,7 +419,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
67870 {
67871 unsigned long pc;
67872 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
67873 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
67874 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
67875 }
67876 #endif /* !CONFIG_SMP */
67877
67878 @@ -517,7 +517,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
67879 return -EFAULT;
67880 buf++; p++; count--; read++;
67881 }
67882 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
67883 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
67884 if (copy_to_user(buf, (void *)pnt, count))
67885 return -EFAULT;
67886 read += count;
67887 @@ -548,7 +548,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
67888 }
67889 #endif
67890 profile_discard_flip_buffers();
67891 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
67892 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
67893 return count;
67894 }
67895
67896 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
67897 index 00ab2ca..d237f61 100644
67898 --- a/kernel/ptrace.c
67899 +++ b/kernel/ptrace.c
67900 @@ -285,7 +285,7 @@ static int ptrace_attach(struct task_struct *task, long request,
67901 task->ptrace = PT_PTRACED;
67902 if (seize)
67903 task->ptrace |= PT_SEIZED;
67904 - if (ns_capable(task_user_ns(task), CAP_SYS_PTRACE))
67905 + if (ns_capable_nolog(task_user_ns(task), CAP_SYS_PTRACE))
67906 task->ptrace |= PT_PTRACE_CAP;
67907
67908 __ptrace_link(task, current);
67909 @@ -491,7 +491,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
67910 break;
67911 return -EIO;
67912 }
67913 - if (copy_to_user(dst, buf, retval))
67914 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
67915 return -EFAULT;
67916 copied += retval;
67917 src += retval;
67918 @@ -688,7 +688,7 @@ int ptrace_request(struct task_struct *child, long request,
67919 bool seized = child->ptrace & PT_SEIZED;
67920 int ret = -EIO;
67921 siginfo_t siginfo, *si;
67922 - void __user *datavp = (void __user *) data;
67923 + void __user *datavp = (__force void __user *) data;
67924 unsigned long __user *datalp = datavp;
67925 unsigned long flags;
67926
67927 @@ -890,14 +890,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
67928 goto out;
67929 }
67930
67931 + if (gr_handle_ptrace(child, request)) {
67932 + ret = -EPERM;
67933 + goto out_put_task_struct;
67934 + }
67935 +
67936 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
67937 ret = ptrace_attach(child, request, data);
67938 /*
67939 * Some architectures need to do book-keeping after
67940 * a ptrace attach.
67941 */
67942 - if (!ret)
67943 + if (!ret) {
67944 arch_ptrace_attach(child);
67945 + gr_audit_ptrace(child);
67946 + }
67947 goto out_put_task_struct;
67948 }
67949
67950 @@ -923,7 +930,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
67951 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
67952 if (copied != sizeof(tmp))
67953 return -EIO;
67954 - return put_user(tmp, (unsigned long __user *)data);
67955 + return put_user(tmp, (__force unsigned long __user *)data);
67956 }
67957
67958 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
67959 @@ -1033,14 +1040,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
67960 goto out;
67961 }
67962
67963 + if (gr_handle_ptrace(child, request)) {
67964 + ret = -EPERM;
67965 + goto out_put_task_struct;
67966 + }
67967 +
67968 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
67969 ret = ptrace_attach(child, request, data);
67970 /*
67971 * Some architectures need to do book-keeping after
67972 * a ptrace attach.
67973 */
67974 - if (!ret)
67975 + if (!ret) {
67976 arch_ptrace_attach(child);
67977 + gr_audit_ptrace(child);
67978 + }
67979 goto out_put_task_struct;
67980 }
67981
67982 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
67983 index 977296d..c4744dc 100644
67984 --- a/kernel/rcutiny.c
67985 +++ b/kernel/rcutiny.c
67986 @@ -46,7 +46,7 @@
67987 struct rcu_ctrlblk;
67988 static void invoke_rcu_callbacks(void);
67989 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
67990 -static void rcu_process_callbacks(struct softirq_action *unused);
67991 +static void rcu_process_callbacks(void);
67992 static void __call_rcu(struct rcu_head *head,
67993 void (*func)(struct rcu_head *rcu),
67994 struct rcu_ctrlblk *rcp);
67995 @@ -297,7 +297,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
67996 rcu_is_callbacks_kthread()));
67997 }
67998
67999 -static void rcu_process_callbacks(struct softirq_action *unused)
68000 +static void rcu_process_callbacks(void)
68001 {
68002 __rcu_process_callbacks(&rcu_sched_ctrlblk);
68003 __rcu_process_callbacks(&rcu_bh_ctrlblk);
68004 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
68005 index 9cb1ae4..aac7d3e 100644
68006 --- a/kernel/rcutiny_plugin.h
68007 +++ b/kernel/rcutiny_plugin.h
68008 @@ -920,7 +920,7 @@ static int rcu_kthread(void *arg)
68009 have_rcu_kthread_work = morework;
68010 local_irq_restore(flags);
68011 if (work)
68012 - rcu_process_callbacks(NULL);
68013 + rcu_process_callbacks();
68014 schedule_timeout_interruptible(1); /* Leave CPU for others. */
68015 }
68016
68017 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
68018 index a58ac28..196a3d8 100644
68019 --- a/kernel/rcutorture.c
68020 +++ b/kernel/rcutorture.c
68021 @@ -148,12 +148,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
68022 { 0 };
68023 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
68024 { 0 };
68025 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
68026 -static atomic_t n_rcu_torture_alloc;
68027 -static atomic_t n_rcu_torture_alloc_fail;
68028 -static atomic_t n_rcu_torture_free;
68029 -static atomic_t n_rcu_torture_mberror;
68030 -static atomic_t n_rcu_torture_error;
68031 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
68032 +static atomic_unchecked_t n_rcu_torture_alloc;
68033 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
68034 +static atomic_unchecked_t n_rcu_torture_free;
68035 +static atomic_unchecked_t n_rcu_torture_mberror;
68036 +static atomic_unchecked_t n_rcu_torture_error;
68037 static long n_rcu_torture_boost_ktrerror;
68038 static long n_rcu_torture_boost_rterror;
68039 static long n_rcu_torture_boost_failure;
68040 @@ -243,11 +243,11 @@ rcu_torture_alloc(void)
68041
68042 spin_lock_bh(&rcu_torture_lock);
68043 if (list_empty(&rcu_torture_freelist)) {
68044 - atomic_inc(&n_rcu_torture_alloc_fail);
68045 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
68046 spin_unlock_bh(&rcu_torture_lock);
68047 return NULL;
68048 }
68049 - atomic_inc(&n_rcu_torture_alloc);
68050 + atomic_inc_unchecked(&n_rcu_torture_alloc);
68051 p = rcu_torture_freelist.next;
68052 list_del_init(p);
68053 spin_unlock_bh(&rcu_torture_lock);
68054 @@ -260,7 +260,7 @@ rcu_torture_alloc(void)
68055 static void
68056 rcu_torture_free(struct rcu_torture *p)
68057 {
68058 - atomic_inc(&n_rcu_torture_free);
68059 + atomic_inc_unchecked(&n_rcu_torture_free);
68060 spin_lock_bh(&rcu_torture_lock);
68061 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
68062 spin_unlock_bh(&rcu_torture_lock);
68063 @@ -380,7 +380,7 @@ rcu_torture_cb(struct rcu_head *p)
68064 i = rp->rtort_pipe_count;
68065 if (i > RCU_TORTURE_PIPE_LEN)
68066 i = RCU_TORTURE_PIPE_LEN;
68067 - atomic_inc(&rcu_torture_wcount[i]);
68068 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
68069 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
68070 rp->rtort_mbtest = 0;
68071 rcu_torture_free(rp);
68072 @@ -427,7 +427,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
68073 i = rp->rtort_pipe_count;
68074 if (i > RCU_TORTURE_PIPE_LEN)
68075 i = RCU_TORTURE_PIPE_LEN;
68076 - atomic_inc(&rcu_torture_wcount[i]);
68077 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
68078 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
68079 rp->rtort_mbtest = 0;
68080 list_del(&rp->rtort_free);
68081 @@ -916,7 +916,7 @@ rcu_torture_writer(void *arg)
68082 i = old_rp->rtort_pipe_count;
68083 if (i > RCU_TORTURE_PIPE_LEN)
68084 i = RCU_TORTURE_PIPE_LEN;
68085 - atomic_inc(&rcu_torture_wcount[i]);
68086 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
68087 old_rp->rtort_pipe_count++;
68088 cur_ops->deferred_free(old_rp);
68089 }
68090 @@ -997,7 +997,7 @@ static void rcu_torture_timer(unsigned long unused)
68091 return;
68092 }
68093 if (p->rtort_mbtest == 0)
68094 - atomic_inc(&n_rcu_torture_mberror);
68095 + atomic_inc_unchecked(&n_rcu_torture_mberror);
68096 spin_lock(&rand_lock);
68097 cur_ops->read_delay(&rand);
68098 n_rcu_torture_timers++;
68099 @@ -1061,7 +1061,7 @@ rcu_torture_reader(void *arg)
68100 continue;
68101 }
68102 if (p->rtort_mbtest == 0)
68103 - atomic_inc(&n_rcu_torture_mberror);
68104 + atomic_inc_unchecked(&n_rcu_torture_mberror);
68105 cur_ops->read_delay(&rand);
68106 preempt_disable();
68107 pipe_count = p->rtort_pipe_count;
68108 @@ -1123,10 +1123,10 @@ rcu_torture_printk(char *page)
68109 rcu_torture_current,
68110 rcu_torture_current_version,
68111 list_empty(&rcu_torture_freelist),
68112 - atomic_read(&n_rcu_torture_alloc),
68113 - atomic_read(&n_rcu_torture_alloc_fail),
68114 - atomic_read(&n_rcu_torture_free),
68115 - atomic_read(&n_rcu_torture_mberror),
68116 + atomic_read_unchecked(&n_rcu_torture_alloc),
68117 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
68118 + atomic_read_unchecked(&n_rcu_torture_free),
68119 + atomic_read_unchecked(&n_rcu_torture_mberror),
68120 n_rcu_torture_boost_ktrerror,
68121 n_rcu_torture_boost_rterror,
68122 n_rcu_torture_boost_failure,
68123 @@ -1136,7 +1136,7 @@ rcu_torture_printk(char *page)
68124 n_online_attempts,
68125 n_offline_successes,
68126 n_offline_attempts);
68127 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
68128 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
68129 n_rcu_torture_boost_ktrerror != 0 ||
68130 n_rcu_torture_boost_rterror != 0 ||
68131 n_rcu_torture_boost_failure != 0)
68132 @@ -1144,7 +1144,7 @@ rcu_torture_printk(char *page)
68133 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
68134 if (i > 1) {
68135 cnt += sprintf(&page[cnt], "!!! ");
68136 - atomic_inc(&n_rcu_torture_error);
68137 + atomic_inc_unchecked(&n_rcu_torture_error);
68138 WARN_ON_ONCE(1);
68139 }
68140 cnt += sprintf(&page[cnt], "Reader Pipe: ");
68141 @@ -1158,7 +1158,7 @@ rcu_torture_printk(char *page)
68142 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
68143 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
68144 cnt += sprintf(&page[cnt], " %d",
68145 - atomic_read(&rcu_torture_wcount[i]));
68146 + atomic_read_unchecked(&rcu_torture_wcount[i]));
68147 }
68148 cnt += sprintf(&page[cnt], "\n");
68149 if (cur_ops->stats)
68150 @@ -1600,7 +1600,7 @@ rcu_torture_cleanup(void)
68151
68152 if (cur_ops->cleanup)
68153 cur_ops->cleanup();
68154 - if (atomic_read(&n_rcu_torture_error))
68155 + if (atomic_read_unchecked(&n_rcu_torture_error))
68156 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
68157 else
68158 rcu_torture_print_module_parms(cur_ops, "End of test: SUCCESS");
68159 @@ -1664,17 +1664,17 @@ rcu_torture_init(void)
68160
68161 rcu_torture_current = NULL;
68162 rcu_torture_current_version = 0;
68163 - atomic_set(&n_rcu_torture_alloc, 0);
68164 - atomic_set(&n_rcu_torture_alloc_fail, 0);
68165 - atomic_set(&n_rcu_torture_free, 0);
68166 - atomic_set(&n_rcu_torture_mberror, 0);
68167 - atomic_set(&n_rcu_torture_error, 0);
68168 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
68169 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
68170 + atomic_set_unchecked(&n_rcu_torture_free, 0);
68171 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
68172 + atomic_set_unchecked(&n_rcu_torture_error, 0);
68173 n_rcu_torture_boost_ktrerror = 0;
68174 n_rcu_torture_boost_rterror = 0;
68175 n_rcu_torture_boost_failure = 0;
68176 n_rcu_torture_boosts = 0;
68177 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
68178 - atomic_set(&rcu_torture_wcount[i], 0);
68179 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
68180 for_each_possible_cpu(cpu) {
68181 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
68182 per_cpu(rcu_torture_count, cpu)[i] = 0;
68183 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
68184 index 6c4a672..70f3202 100644
68185 --- a/kernel/rcutree.c
68186 +++ b/kernel/rcutree.c
68187 @@ -363,9 +363,9 @@ static void rcu_idle_enter_common(struct rcu_dynticks *rdtp, long long oldval)
68188 rcu_prepare_for_idle(smp_processor_id());
68189 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
68190 smp_mb__before_atomic_inc(); /* See above. */
68191 - atomic_inc(&rdtp->dynticks);
68192 + atomic_inc_unchecked(&rdtp->dynticks);
68193 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
68194 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
68195 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
68196 }
68197
68198 /**
68199 @@ -438,10 +438,10 @@ void rcu_irq_exit(void)
68200 static void rcu_idle_exit_common(struct rcu_dynticks *rdtp, long long oldval)
68201 {
68202 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
68203 - atomic_inc(&rdtp->dynticks);
68204 + atomic_inc_unchecked(&rdtp->dynticks);
68205 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
68206 smp_mb__after_atomic_inc(); /* See above. */
68207 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
68208 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
68209 rcu_cleanup_after_idle(smp_processor_id());
68210 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
68211 if (!is_idle_task(current)) {
68212 @@ -531,14 +531,14 @@ void rcu_nmi_enter(void)
68213 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
68214
68215 if (rdtp->dynticks_nmi_nesting == 0 &&
68216 - (atomic_read(&rdtp->dynticks) & 0x1))
68217 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
68218 return;
68219 rdtp->dynticks_nmi_nesting++;
68220 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
68221 - atomic_inc(&rdtp->dynticks);
68222 + atomic_inc_unchecked(&rdtp->dynticks);
68223 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
68224 smp_mb__after_atomic_inc(); /* See above. */
68225 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
68226 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
68227 }
68228
68229 /**
68230 @@ -557,9 +557,9 @@ void rcu_nmi_exit(void)
68231 return;
68232 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
68233 smp_mb__before_atomic_inc(); /* See above. */
68234 - atomic_inc(&rdtp->dynticks);
68235 + atomic_inc_unchecked(&rdtp->dynticks);
68236 smp_mb__after_atomic_inc(); /* Force delay to next write. */
68237 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
68238 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
68239 }
68240
68241 #ifdef CONFIG_PROVE_RCU
68242 @@ -575,7 +575,7 @@ int rcu_is_cpu_idle(void)
68243 int ret;
68244
68245 preempt_disable();
68246 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
68247 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
68248 preempt_enable();
68249 return ret;
68250 }
68251 @@ -604,7 +604,7 @@ int rcu_is_cpu_rrupt_from_idle(void)
68252 */
68253 static int dyntick_save_progress_counter(struct rcu_data *rdp)
68254 {
68255 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
68256 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
68257 return (rdp->dynticks_snap & 0x1) == 0;
68258 }
68259
68260 @@ -619,7 +619,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
68261 unsigned int curr;
68262 unsigned int snap;
68263
68264 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
68265 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
68266 snap = (unsigned int)rdp->dynticks_snap;
68267
68268 /*
68269 @@ -1667,7 +1667,7 @@ __rcu_process_callbacks(struct rcu_state *rsp, struct rcu_data *rdp)
68270 /*
68271 * Do RCU core processing for the current CPU.
68272 */
68273 -static void rcu_process_callbacks(struct softirq_action *unused)
68274 +static void rcu_process_callbacks(void)
68275 {
68276 trace_rcu_utilization("Start RCU core");
68277 __rcu_process_callbacks(&rcu_sched_state,
68278 @@ -2030,7 +2030,7 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
68279 rdp->qlen = 0;
68280 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
68281 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_NESTING);
68282 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
68283 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
68284 rdp->cpu = cpu;
68285 rdp->rsp = rsp;
68286 raw_spin_unlock_irqrestore(&rnp->lock, flags);
68287 @@ -2058,8 +2058,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
68288 rdp->n_force_qs_snap = rsp->n_force_qs;
68289 rdp->blimit = blimit;
68290 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_NESTING;
68291 - atomic_set(&rdp->dynticks->dynticks,
68292 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
68293 + atomic_set_unchecked(&rdp->dynticks->dynticks,
68294 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
68295 rcu_prepare_for_idle_init(cpu);
68296 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
68297
68298 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
68299 index fddff92..2c08359 100644
68300 --- a/kernel/rcutree.h
68301 +++ b/kernel/rcutree.h
68302 @@ -87,7 +87,7 @@ struct rcu_dynticks {
68303 long long dynticks_nesting; /* Track irq/process nesting level. */
68304 /* Process level is worth LLONG_MAX/2. */
68305 int dynticks_nmi_nesting; /* Track NMI nesting level. */
68306 - atomic_t dynticks; /* Even value for idle, else odd. */
68307 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
68308 };
68309
68310 /* RCU's kthread states for tracing. */
68311 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
68312 index 8bb35d7..6ea0a463 100644
68313 --- a/kernel/rcutree_plugin.h
68314 +++ b/kernel/rcutree_plugin.h
68315 @@ -850,7 +850,7 @@ void synchronize_rcu_expedited(void)
68316
68317 /* Clean up and exit. */
68318 smp_mb(); /* ensure expedited GP seen before counter increment. */
68319 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
68320 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
68321 unlock_mb_ret:
68322 mutex_unlock(&sync_rcu_preempt_exp_mutex);
68323 mb_ret:
68324 @@ -1833,8 +1833,8 @@ EXPORT_SYMBOL_GPL(synchronize_sched_expedited);
68325
68326 #else /* #ifndef CONFIG_SMP */
68327
68328 -static atomic_t sync_sched_expedited_started = ATOMIC_INIT(0);
68329 -static atomic_t sync_sched_expedited_done = ATOMIC_INIT(0);
68330 +static atomic_unchecked_t sync_sched_expedited_started = ATOMIC_INIT(0);
68331 +static atomic_unchecked_t sync_sched_expedited_done = ATOMIC_INIT(0);
68332
68333 static int synchronize_sched_expedited_cpu_stop(void *data)
68334 {
68335 @@ -1889,7 +1889,7 @@ void synchronize_sched_expedited(void)
68336 int firstsnap, s, snap, trycount = 0;
68337
68338 /* Note that atomic_inc_return() implies full memory barrier. */
68339 - firstsnap = snap = atomic_inc_return(&sync_sched_expedited_started);
68340 + firstsnap = snap = atomic_inc_return_unchecked(&sync_sched_expedited_started);
68341 get_online_cpus();
68342
68343 /*
68344 @@ -1910,7 +1910,7 @@ void synchronize_sched_expedited(void)
68345 }
68346
68347 /* Check to see if someone else did our work for us. */
68348 - s = atomic_read(&sync_sched_expedited_done);
68349 + s = atomic_read_unchecked(&sync_sched_expedited_done);
68350 if (UINT_CMP_GE((unsigned)s, (unsigned)firstsnap)) {
68351 smp_mb(); /* ensure test happens before caller kfree */
68352 return;
68353 @@ -1925,7 +1925,7 @@ void synchronize_sched_expedited(void)
68354 * grace period works for us.
68355 */
68356 get_online_cpus();
68357 - snap = atomic_read(&sync_sched_expedited_started);
68358 + snap = atomic_read_unchecked(&sync_sched_expedited_started);
68359 smp_mb(); /* ensure read is before try_stop_cpus(). */
68360 }
68361
68362 @@ -1936,12 +1936,12 @@ void synchronize_sched_expedited(void)
68363 * than we did beat us to the punch.
68364 */
68365 do {
68366 - s = atomic_read(&sync_sched_expedited_done);
68367 + s = atomic_read_unchecked(&sync_sched_expedited_done);
68368 if (UINT_CMP_GE((unsigned)s, (unsigned)snap)) {
68369 smp_mb(); /* ensure test happens before caller kfree */
68370 break;
68371 }
68372 - } while (atomic_cmpxchg(&sync_sched_expedited_done, s, snap) != s);
68373 + } while (atomic_cmpxchg_unchecked(&sync_sched_expedited_done, s, snap) != s);
68374
68375 put_online_cpus();
68376 }
68377 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
68378 index 654cfe6..c0b28e2 100644
68379 --- a/kernel/rcutree_trace.c
68380 +++ b/kernel/rcutree_trace.c
68381 @@ -68,7 +68,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
68382 rdp->passed_quiesce, rdp->passed_quiesce_gpnum,
68383 rdp->qs_pending);
68384 seq_printf(m, " dt=%d/%llx/%d df=%lu",
68385 - atomic_read(&rdp->dynticks->dynticks),
68386 + atomic_read_unchecked(&rdp->dynticks->dynticks),
68387 rdp->dynticks->dynticks_nesting,
68388 rdp->dynticks->dynticks_nmi_nesting,
68389 rdp->dynticks_fqs);
68390 @@ -140,7 +140,7 @@ static void print_one_rcu_data_csv(struct seq_file *m, struct rcu_data *rdp)
68391 rdp->passed_quiesce, rdp->passed_quiesce_gpnum,
68392 rdp->qs_pending);
68393 seq_printf(m, ",%d,%llx,%d,%lu",
68394 - atomic_read(&rdp->dynticks->dynticks),
68395 + atomic_read_unchecked(&rdp->dynticks->dynticks),
68396 rdp->dynticks->dynticks_nesting,
68397 rdp->dynticks->dynticks_nmi_nesting,
68398 rdp->dynticks_fqs);
68399 diff --git a/kernel/resource.c b/kernel/resource.c
68400 index 7640b3a..5879283 100644
68401 --- a/kernel/resource.c
68402 +++ b/kernel/resource.c
68403 @@ -141,8 +141,18 @@ static const struct file_operations proc_iomem_operations = {
68404
68405 static int __init ioresources_init(void)
68406 {
68407 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
68408 +#ifdef CONFIG_GRKERNSEC_PROC_USER
68409 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
68410 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
68411 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
68412 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
68413 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
68414 +#endif
68415 +#else
68416 proc_create("ioports", 0, NULL, &proc_ioports_operations);
68417 proc_create("iomem", 0, NULL, &proc_iomem_operations);
68418 +#endif
68419 return 0;
68420 }
68421 __initcall(ioresources_init);
68422 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
68423 index 98ec494..4241d6d 100644
68424 --- a/kernel/rtmutex-tester.c
68425 +++ b/kernel/rtmutex-tester.c
68426 @@ -20,7 +20,7 @@
68427 #define MAX_RT_TEST_MUTEXES 8
68428
68429 static spinlock_t rttest_lock;
68430 -static atomic_t rttest_event;
68431 +static atomic_unchecked_t rttest_event;
68432
68433 struct test_thread_data {
68434 int opcode;
68435 @@ -61,7 +61,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
68436
68437 case RTTEST_LOCKCONT:
68438 td->mutexes[td->opdata] = 1;
68439 - td->event = atomic_add_return(1, &rttest_event);
68440 + td->event = atomic_add_return_unchecked(1, &rttest_event);
68441 return 0;
68442
68443 case RTTEST_RESET:
68444 @@ -74,7 +74,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
68445 return 0;
68446
68447 case RTTEST_RESETEVENT:
68448 - atomic_set(&rttest_event, 0);
68449 + atomic_set_unchecked(&rttest_event, 0);
68450 return 0;
68451
68452 default:
68453 @@ -91,9 +91,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
68454 return ret;
68455
68456 td->mutexes[id] = 1;
68457 - td->event = atomic_add_return(1, &rttest_event);
68458 + td->event = atomic_add_return_unchecked(1, &rttest_event);
68459 rt_mutex_lock(&mutexes[id]);
68460 - td->event = atomic_add_return(1, &rttest_event);
68461 + td->event = atomic_add_return_unchecked(1, &rttest_event);
68462 td->mutexes[id] = 4;
68463 return 0;
68464
68465 @@ -104,9 +104,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
68466 return ret;
68467
68468 td->mutexes[id] = 1;
68469 - td->event = atomic_add_return(1, &rttest_event);
68470 + td->event = atomic_add_return_unchecked(1, &rttest_event);
68471 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
68472 - td->event = atomic_add_return(1, &rttest_event);
68473 + td->event = atomic_add_return_unchecked(1, &rttest_event);
68474 td->mutexes[id] = ret ? 0 : 4;
68475 return ret ? -EINTR : 0;
68476
68477 @@ -115,9 +115,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
68478 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
68479 return ret;
68480
68481 - td->event = atomic_add_return(1, &rttest_event);
68482 + td->event = atomic_add_return_unchecked(1, &rttest_event);
68483 rt_mutex_unlock(&mutexes[id]);
68484 - td->event = atomic_add_return(1, &rttest_event);
68485 + td->event = atomic_add_return_unchecked(1, &rttest_event);
68486 td->mutexes[id] = 0;
68487 return 0;
68488
68489 @@ -164,7 +164,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
68490 break;
68491
68492 td->mutexes[dat] = 2;
68493 - td->event = atomic_add_return(1, &rttest_event);
68494 + td->event = atomic_add_return_unchecked(1, &rttest_event);
68495 break;
68496
68497 default:
68498 @@ -184,7 +184,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
68499 return;
68500
68501 td->mutexes[dat] = 3;
68502 - td->event = atomic_add_return(1, &rttest_event);
68503 + td->event = atomic_add_return_unchecked(1, &rttest_event);
68504 break;
68505
68506 case RTTEST_LOCKNOWAIT:
68507 @@ -196,7 +196,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
68508 return;
68509
68510 td->mutexes[dat] = 1;
68511 - td->event = atomic_add_return(1, &rttest_event);
68512 + td->event = atomic_add_return_unchecked(1, &rttest_event);
68513 return;
68514
68515 default:
68516 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
68517 index e8a1f83..363d17d 100644
68518 --- a/kernel/sched/auto_group.c
68519 +++ b/kernel/sched/auto_group.c
68520 @@ -11,7 +11,7 @@
68521
68522 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
68523 static struct autogroup autogroup_default;
68524 -static atomic_t autogroup_seq_nr;
68525 +static atomic_unchecked_t autogroup_seq_nr;
68526
68527 void __init autogroup_init(struct task_struct *init_task)
68528 {
68529 @@ -78,7 +78,7 @@ static inline struct autogroup *autogroup_create(void)
68530
68531 kref_init(&ag->kref);
68532 init_rwsem(&ag->lock);
68533 - ag->id = atomic_inc_return(&autogroup_seq_nr);
68534 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
68535 ag->tg = tg;
68536 #ifdef CONFIG_RT_GROUP_SCHED
68537 /*
68538 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
68539 index 478a04c..e16339a 100644
68540 --- a/kernel/sched/core.c
68541 +++ b/kernel/sched/core.c
68542 @@ -3851,6 +3851,8 @@ int can_nice(const struct task_struct *p, const int nice)
68543 /* convert nice value [19,-20] to rlimit style value [1,40] */
68544 int nice_rlim = 20 - nice;
68545
68546 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
68547 +
68548 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
68549 capable(CAP_SYS_NICE));
68550 }
68551 @@ -3884,7 +3886,8 @@ SYSCALL_DEFINE1(nice, int, increment)
68552 if (nice > 19)
68553 nice = 19;
68554
68555 - if (increment < 0 && !can_nice(current, nice))
68556 + if (increment < 0 && (!can_nice(current, nice) ||
68557 + gr_handle_chroot_nice()))
68558 return -EPERM;
68559
68560 retval = security_task_setnice(current, nice);
68561 @@ -4041,6 +4044,7 @@ recheck:
68562 unsigned long rlim_rtprio =
68563 task_rlimit(p, RLIMIT_RTPRIO);
68564
68565 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
68566 /* can't set/change the rt policy */
68567 if (policy != p->policy && !rlim_rtprio)
68568 return -EPERM;
68569 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
68570 index aca16b8..8e3acc4 100644
68571 --- a/kernel/sched/fair.c
68572 +++ b/kernel/sched/fair.c
68573 @@ -5147,7 +5147,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
68574 * run_rebalance_domains is triggered when needed from the scheduler tick.
68575 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
68576 */
68577 -static void run_rebalance_domains(struct softirq_action *h)
68578 +static void run_rebalance_domains(void)
68579 {
68580 int this_cpu = smp_processor_id();
68581 struct rq *this_rq = cpu_rq(this_cpu);
68582 diff --git a/kernel/signal.c b/kernel/signal.c
68583 index b09cf3b..b291c66 100644
68584 --- a/kernel/signal.c
68585 +++ b/kernel/signal.c
68586 @@ -46,12 +46,12 @@ static struct kmem_cache *sigqueue_cachep;
68587
68588 int print_fatal_signals __read_mostly;
68589
68590 -static void __user *sig_handler(struct task_struct *t, int sig)
68591 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
68592 {
68593 return t->sighand->action[sig - 1].sa.sa_handler;
68594 }
68595
68596 -static int sig_handler_ignored(void __user *handler, int sig)
68597 +static int sig_handler_ignored(__sighandler_t handler, int sig)
68598 {
68599 /* Is it explicitly or implicitly ignored? */
68600 return handler == SIG_IGN ||
68601 @@ -61,7 +61,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
68602 static int sig_task_ignored(struct task_struct *t, int sig,
68603 int from_ancestor_ns)
68604 {
68605 - void __user *handler;
68606 + __sighandler_t handler;
68607
68608 handler = sig_handler(t, sig);
68609
68610 @@ -365,6 +365,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
68611 atomic_inc(&user->sigpending);
68612 rcu_read_unlock();
68613
68614 + if (!override_rlimit)
68615 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
68616 +
68617 if (override_rlimit ||
68618 atomic_read(&user->sigpending) <=
68619 task_rlimit(t, RLIMIT_SIGPENDING)) {
68620 @@ -489,7 +492,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
68621
68622 int unhandled_signal(struct task_struct *tsk, int sig)
68623 {
68624 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
68625 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
68626 if (is_global_init(tsk))
68627 return 1;
68628 if (handler != SIG_IGN && handler != SIG_DFL)
68629 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
68630 }
68631 }
68632
68633 + /* allow glibc communication via tgkill to other threads in our
68634 + thread group */
68635 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
68636 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
68637 + && gr_handle_signal(t, sig))
68638 + return -EPERM;
68639 +
68640 return security_task_kill(t, info, sig, 0);
68641 }
68642
68643 @@ -1197,7 +1207,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
68644 return send_signal(sig, info, p, 1);
68645 }
68646
68647 -static int
68648 +int
68649 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
68650 {
68651 return send_signal(sig, info, t, 0);
68652 @@ -1234,6 +1244,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
68653 unsigned long int flags;
68654 int ret, blocked, ignored;
68655 struct k_sigaction *action;
68656 + int is_unhandled = 0;
68657
68658 spin_lock_irqsave(&t->sighand->siglock, flags);
68659 action = &t->sighand->action[sig-1];
68660 @@ -1248,9 +1259,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
68661 }
68662 if (action->sa.sa_handler == SIG_DFL)
68663 t->signal->flags &= ~SIGNAL_UNKILLABLE;
68664 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
68665 + is_unhandled = 1;
68666 ret = specific_send_sig_info(sig, info, t);
68667 spin_unlock_irqrestore(&t->sighand->siglock, flags);
68668
68669 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
68670 + normal operation */
68671 + if (is_unhandled) {
68672 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
68673 + gr_handle_crash(t, sig);
68674 + }
68675 +
68676 return ret;
68677 }
68678
68679 @@ -1317,8 +1337,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
68680 ret = check_kill_permission(sig, info, p);
68681 rcu_read_unlock();
68682
68683 - if (!ret && sig)
68684 + if (!ret && sig) {
68685 ret = do_send_sig_info(sig, info, p, true);
68686 + if (!ret)
68687 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
68688 + }
68689
68690 return ret;
68691 }
68692 @@ -2829,7 +2852,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
68693 int error = -ESRCH;
68694
68695 rcu_read_lock();
68696 - p = find_task_by_vpid(pid);
68697 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68698 + /* allow glibc communication via tgkill to other threads in our
68699 + thread group */
68700 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
68701 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
68702 + p = find_task_by_vpid_unrestricted(pid);
68703 + else
68704 +#endif
68705 + p = find_task_by_vpid(pid);
68706 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
68707 error = check_kill_permission(sig, info, p);
68708 /*
68709 diff --git a/kernel/smp.c b/kernel/smp.c
68710 index db197d6..17aef0b 100644
68711 --- a/kernel/smp.c
68712 +++ b/kernel/smp.c
68713 @@ -580,22 +580,22 @@ int smp_call_function(smp_call_func_t func, void *info, int wait)
68714 }
68715 EXPORT_SYMBOL(smp_call_function);
68716
68717 -void ipi_call_lock(void)
68718 +void ipi_call_lock(void) __acquires(call_function.lock)
68719 {
68720 raw_spin_lock(&call_function.lock);
68721 }
68722
68723 -void ipi_call_unlock(void)
68724 +void ipi_call_unlock(void) __releases(call_function.lock)
68725 {
68726 raw_spin_unlock(&call_function.lock);
68727 }
68728
68729 -void ipi_call_lock_irq(void)
68730 +void ipi_call_lock_irq(void) __acquires(call_function.lock)
68731 {
68732 raw_spin_lock_irq(&call_function.lock);
68733 }
68734
68735 -void ipi_call_unlock_irq(void)
68736 +void ipi_call_unlock_irq(void) __releases(call_function.lock)
68737 {
68738 raw_spin_unlock_irq(&call_function.lock);
68739 }
68740 diff --git a/kernel/softirq.c b/kernel/softirq.c
68741 index 4eb3a0f..6f1fa81 100644
68742 --- a/kernel/softirq.c
68743 +++ b/kernel/softirq.c
68744 @@ -56,7 +56,7 @@ static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp
68745
68746 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
68747
68748 -char *softirq_to_name[NR_SOFTIRQS] = {
68749 +const char * const softirq_to_name[NR_SOFTIRQS] = {
68750 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
68751 "TASKLET", "SCHED", "HRTIMER", "RCU"
68752 };
68753 @@ -235,7 +235,7 @@ restart:
68754 kstat_incr_softirqs_this_cpu(vec_nr);
68755
68756 trace_softirq_entry(vec_nr);
68757 - h->action(h);
68758 + h->action();
68759 trace_softirq_exit(vec_nr);
68760 if (unlikely(prev_count != preempt_count())) {
68761 printk(KERN_ERR "huh, entered softirq %u %s %p"
68762 @@ -385,9 +385,11 @@ void raise_softirq(unsigned int nr)
68763 local_irq_restore(flags);
68764 }
68765
68766 -void open_softirq(int nr, void (*action)(struct softirq_action *))
68767 +void open_softirq(int nr, void (*action)(void))
68768 {
68769 - softirq_vec[nr].action = action;
68770 + pax_open_kernel();
68771 + *(void **)&softirq_vec[nr].action = action;
68772 + pax_close_kernel();
68773 }
68774
68775 /*
68776 @@ -441,7 +443,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
68777
68778 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
68779
68780 -static void tasklet_action(struct softirq_action *a)
68781 +static void tasklet_action(void)
68782 {
68783 struct tasklet_struct *list;
68784
68785 @@ -476,7 +478,7 @@ static void tasklet_action(struct softirq_action *a)
68786 }
68787 }
68788
68789 -static void tasklet_hi_action(struct softirq_action *a)
68790 +static void tasklet_hi_action(void)
68791 {
68792 struct tasklet_struct *list;
68793
68794 diff --git a/kernel/sys.c b/kernel/sys.c
68795 index 888d227..f04b318 100644
68796 --- a/kernel/sys.c
68797 +++ b/kernel/sys.c
68798 @@ -158,6 +158,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
68799 error = -EACCES;
68800 goto out;
68801 }
68802 +
68803 + if (gr_handle_chroot_setpriority(p, niceval)) {
68804 + error = -EACCES;
68805 + goto out;
68806 + }
68807 +
68808 no_nice = security_task_setnice(p, niceval);
68809 if (no_nice) {
68810 error = no_nice;
68811 @@ -572,6 +578,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
68812 goto error;
68813 }
68814
68815 + if (gr_check_group_change(new->gid, new->egid, -1))
68816 + goto error;
68817 +
68818 if (rgid != (gid_t) -1 ||
68819 (egid != (gid_t) -1 && egid != old->gid))
68820 new->sgid = new->egid;
68821 @@ -601,6 +610,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
68822 old = current_cred();
68823
68824 retval = -EPERM;
68825 +
68826 + if (gr_check_group_change(gid, gid, gid))
68827 + goto error;
68828 +
68829 if (nsown_capable(CAP_SETGID))
68830 new->gid = new->egid = new->sgid = new->fsgid = gid;
68831 else if (gid == old->gid || gid == old->sgid)
68832 @@ -618,7 +631,7 @@ error:
68833 /*
68834 * change the user struct in a credentials set to match the new UID
68835 */
68836 -static int set_user(struct cred *new)
68837 +int set_user(struct cred *new)
68838 {
68839 struct user_struct *new_user;
68840
68841 @@ -688,6 +701,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
68842 goto error;
68843 }
68844
68845 + if (gr_check_user_change(new->uid, new->euid, -1))
68846 + goto error;
68847 +
68848 if (new->uid != old->uid) {
68849 retval = set_user(new);
68850 if (retval < 0)
68851 @@ -732,6 +748,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
68852 old = current_cred();
68853
68854 retval = -EPERM;
68855 +
68856 + if (gr_check_crash_uid(uid))
68857 + goto error;
68858 + if (gr_check_user_change(uid, uid, uid))
68859 + goto error;
68860 +
68861 if (nsown_capable(CAP_SETUID)) {
68862 new->suid = new->uid = uid;
68863 if (uid != old->uid) {
68864 @@ -786,6 +808,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
68865 goto error;
68866 }
68867
68868 + if (gr_check_user_change(ruid, euid, -1))
68869 + goto error;
68870 +
68871 if (ruid != (uid_t) -1) {
68872 new->uid = ruid;
68873 if (ruid != old->uid) {
68874 @@ -850,6 +875,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
68875 goto error;
68876 }
68877
68878 + if (gr_check_group_change(rgid, egid, -1))
68879 + goto error;
68880 +
68881 if (rgid != (gid_t) -1)
68882 new->gid = rgid;
68883 if (egid != (gid_t) -1)
68884 @@ -896,6 +924,9 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
68885 old = current_cred();
68886 old_fsuid = old->fsuid;
68887
68888 + if (gr_check_user_change(-1, -1, uid))
68889 + goto error;
68890 +
68891 if (uid == old->uid || uid == old->euid ||
68892 uid == old->suid || uid == old->fsuid ||
68893 nsown_capable(CAP_SETUID)) {
68894 @@ -906,6 +937,7 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
68895 }
68896 }
68897
68898 +error:
68899 abort_creds(new);
68900 return old_fsuid;
68901
68902 @@ -932,12 +964,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
68903 if (gid == old->gid || gid == old->egid ||
68904 gid == old->sgid || gid == old->fsgid ||
68905 nsown_capable(CAP_SETGID)) {
68906 + if (gr_check_group_change(-1, -1, gid))
68907 + goto error;
68908 +
68909 if (gid != old_fsgid) {
68910 new->fsgid = gid;
68911 goto change_okay;
68912 }
68913 }
68914
68915 +error:
68916 abort_creds(new);
68917 return old_fsgid;
68918
68919 @@ -1189,7 +1225,10 @@ static int override_release(char __user *release, int len)
68920 }
68921 v = ((LINUX_VERSION_CODE >> 8) & 0xff) + 40;
68922 snprintf(buf, len, "2.6.%u%s", v, rest);
68923 - ret = copy_to_user(release, buf, len);
68924 + if (len > sizeof(buf))
68925 + ret = -EFAULT;
68926 + else
68927 + ret = copy_to_user(release, buf, len);
68928 }
68929 return ret;
68930 }
68931 @@ -1243,19 +1282,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
68932 return -EFAULT;
68933
68934 down_read(&uts_sem);
68935 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
68936 + error = __copy_to_user(name->sysname, &utsname()->sysname,
68937 __OLD_UTS_LEN);
68938 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
68939 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
68940 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
68941 __OLD_UTS_LEN);
68942 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
68943 - error |= __copy_to_user(&name->release, &utsname()->release,
68944 + error |= __copy_to_user(name->release, &utsname()->release,
68945 __OLD_UTS_LEN);
68946 error |= __put_user(0, name->release + __OLD_UTS_LEN);
68947 - error |= __copy_to_user(&name->version, &utsname()->version,
68948 + error |= __copy_to_user(name->version, &utsname()->version,
68949 __OLD_UTS_LEN);
68950 error |= __put_user(0, name->version + __OLD_UTS_LEN);
68951 - error |= __copy_to_user(&name->machine, &utsname()->machine,
68952 + error |= __copy_to_user(name->machine, &utsname()->machine,
68953 __OLD_UTS_LEN);
68954 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
68955 up_read(&uts_sem);
68956 @@ -1838,7 +1877,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
68957 error = get_dumpable(me->mm);
68958 break;
68959 case PR_SET_DUMPABLE:
68960 - if (arg2 < 0 || arg2 > 1) {
68961 + if (arg2 > 1) {
68962 error = -EINVAL;
68963 break;
68964 }
68965 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
68966 index f03a6ef..5fcc8af 100644
68967 --- a/kernel/sysctl.c
68968 +++ b/kernel/sysctl.c
68969 @@ -86,6 +86,13 @@
68970
68971
68972 #if defined(CONFIG_SYSCTL)
68973 +#include <linux/grsecurity.h>
68974 +#include <linux/grinternal.h>
68975 +
68976 +extern __u32 gr_handle_sysctl(const ctl_table *table, const int op);
68977 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
68978 + const int op);
68979 +extern int gr_handle_chroot_sysctl(const int op);
68980
68981 /* External variables not in a header file. */
68982 extern int sysctl_overcommit_memory;
68983 @@ -191,6 +198,7 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
68984 }
68985
68986 #endif
68987 +extern struct ctl_table grsecurity_table[];
68988
68989 static struct ctl_table root_table[];
68990 static struct ctl_table_root sysctl_table_root;
68991 @@ -220,6 +228,20 @@ extern struct ctl_table epoll_table[];
68992 int sysctl_legacy_va_layout;
68993 #endif
68994
68995 +#ifdef CONFIG_PAX_SOFTMODE
68996 +static ctl_table pax_table[] = {
68997 + {
68998 + .procname = "softmode",
68999 + .data = &pax_softmode,
69000 + .maxlen = sizeof(unsigned int),
69001 + .mode = 0600,
69002 + .proc_handler = &proc_dointvec,
69003 + },
69004 +
69005 + { }
69006 +};
69007 +#endif
69008 +
69009 /* The default sysctl tables: */
69010
69011 static struct ctl_table root_table[] = {
69012 @@ -266,6 +288,22 @@ static int max_extfrag_threshold = 1000;
69013 #endif
69014
69015 static struct ctl_table kern_table[] = {
69016 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
69017 + {
69018 + .procname = "grsecurity",
69019 + .mode = 0500,
69020 + .child = grsecurity_table,
69021 + },
69022 +#endif
69023 +
69024 +#ifdef CONFIG_PAX_SOFTMODE
69025 + {
69026 + .procname = "pax",
69027 + .mode = 0500,
69028 + .child = pax_table,
69029 + },
69030 +#endif
69031 +
69032 {
69033 .procname = "sched_child_runs_first",
69034 .data = &sysctl_sched_child_runs_first,
69035 @@ -550,7 +588,7 @@ static struct ctl_table kern_table[] = {
69036 .data = &modprobe_path,
69037 .maxlen = KMOD_PATH_LEN,
69038 .mode = 0644,
69039 - .proc_handler = proc_dostring,
69040 + .proc_handler = proc_dostring_modpriv,
69041 },
69042 {
69043 .procname = "modules_disabled",
69044 @@ -717,16 +755,20 @@ static struct ctl_table kern_table[] = {
69045 .extra1 = &zero,
69046 .extra2 = &one,
69047 },
69048 +#endif
69049 {
69050 .procname = "kptr_restrict",
69051 .data = &kptr_restrict,
69052 .maxlen = sizeof(int),
69053 .mode = 0644,
69054 .proc_handler = proc_dointvec_minmax_sysadmin,
69055 +#ifdef CONFIG_GRKERNSEC_HIDESYM
69056 + .extra1 = &two,
69057 +#else
69058 .extra1 = &zero,
69059 +#endif
69060 .extra2 = &two,
69061 },
69062 -#endif
69063 {
69064 .procname = "ngroups_max",
69065 .data = &ngroups_max,
69066 @@ -1225,6 +1267,13 @@ static struct ctl_table vm_table[] = {
69067 .proc_handler = proc_dointvec_minmax,
69068 .extra1 = &zero,
69069 },
69070 + {
69071 + .procname = "heap_stack_gap",
69072 + .data = &sysctl_heap_stack_gap,
69073 + .maxlen = sizeof(sysctl_heap_stack_gap),
69074 + .mode = 0644,
69075 + .proc_handler = proc_doulongvec_minmax,
69076 + },
69077 #else
69078 {
69079 .procname = "nr_trim_pages",
69080 @@ -1729,6 +1778,17 @@ static int test_perm(int mode, int op)
69081 int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
69082 {
69083 int mode;
69084 + int error;
69085 +
69086 + if (table->parent != NULL && table->parent->procname != NULL &&
69087 + table->procname != NULL &&
69088 + gr_handle_sysctl_mod(table->parent->procname, table->procname, op))
69089 + return -EACCES;
69090 + if (gr_handle_chroot_sysctl(op))
69091 + return -EACCES;
69092 + error = gr_handle_sysctl(table, op);
69093 + if (error)
69094 + return error;
69095
69096 if (root->permissions)
69097 mode = root->permissions(root, current->nsproxy, table);
69098 @@ -2133,6 +2193,16 @@ int proc_dostring(struct ctl_table *table, int write,
69099 buffer, lenp, ppos);
69100 }
69101
69102 +int proc_dostring_modpriv(struct ctl_table *table, int write,
69103 + void __user *buffer, size_t *lenp, loff_t *ppos)
69104 +{
69105 + if (write && !capable(CAP_SYS_MODULE))
69106 + return -EPERM;
69107 +
69108 + return _proc_do_string(table->data, table->maxlen, write,
69109 + buffer, lenp, ppos);
69110 +}
69111 +
69112 static size_t proc_skip_spaces(char **buf)
69113 {
69114 size_t ret;
69115 @@ -2238,6 +2308,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
69116 len = strlen(tmp);
69117 if (len > *size)
69118 len = *size;
69119 + if (len > sizeof(tmp))
69120 + len = sizeof(tmp);
69121 if (copy_to_user(*buf, tmp, len))
69122 return -EFAULT;
69123 *size -= len;
69124 @@ -2554,8 +2626,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
69125 *i = val;
69126 } else {
69127 val = convdiv * (*i) / convmul;
69128 - if (!first)
69129 + if (!first) {
69130 err = proc_put_char(&buffer, &left, '\t');
69131 + if (err)
69132 + break;
69133 + }
69134 err = proc_put_long(&buffer, &left, val, false);
69135 if (err)
69136 break;
69137 @@ -2950,6 +3025,12 @@ int proc_dostring(struct ctl_table *table, int write,
69138 return -ENOSYS;
69139 }
69140
69141 +int proc_dostring_modpriv(struct ctl_table *table, int write,
69142 + void __user *buffer, size_t *lenp, loff_t *ppos)
69143 +{
69144 + return -ENOSYS;
69145 +}
69146 +
69147 int proc_dointvec(struct ctl_table *table, int write,
69148 void __user *buffer, size_t *lenp, loff_t *ppos)
69149 {
69150 @@ -3006,6 +3087,7 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
69151 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
69152 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
69153 EXPORT_SYMBOL(proc_dostring);
69154 +EXPORT_SYMBOL(proc_dostring_modpriv);
69155 EXPORT_SYMBOL(proc_doulongvec_minmax);
69156 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
69157 EXPORT_SYMBOL(register_sysctl_table);
69158 diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c
69159 index a650694..aaeeb20 100644
69160 --- a/kernel/sysctl_binary.c
69161 +++ b/kernel/sysctl_binary.c
69162 @@ -989,7 +989,7 @@ static ssize_t bin_intvec(struct file *file,
69163 int i;
69164
69165 set_fs(KERNEL_DS);
69166 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
69167 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
69168 set_fs(old_fs);
69169 if (result < 0)
69170 goto out_kfree;
69171 @@ -1034,7 +1034,7 @@ static ssize_t bin_intvec(struct file *file,
69172 }
69173
69174 set_fs(KERNEL_DS);
69175 - result = vfs_write(file, buffer, str - buffer, &pos);
69176 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
69177 set_fs(old_fs);
69178 if (result < 0)
69179 goto out_kfree;
69180 @@ -1067,7 +1067,7 @@ static ssize_t bin_ulongvec(struct file *file,
69181 int i;
69182
69183 set_fs(KERNEL_DS);
69184 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
69185 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
69186 set_fs(old_fs);
69187 if (result < 0)
69188 goto out_kfree;
69189 @@ -1112,7 +1112,7 @@ static ssize_t bin_ulongvec(struct file *file,
69190 }
69191
69192 set_fs(KERNEL_DS);
69193 - result = vfs_write(file, buffer, str - buffer, &pos);
69194 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
69195 set_fs(old_fs);
69196 if (result < 0)
69197 goto out_kfree;
69198 @@ -1138,7 +1138,7 @@ static ssize_t bin_uuid(struct file *file,
69199 int i;
69200
69201 set_fs(KERNEL_DS);
69202 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
69203 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
69204 set_fs(old_fs);
69205 if (result < 0)
69206 goto out;
69207 @@ -1185,7 +1185,7 @@ static ssize_t bin_dn_node_address(struct file *file,
69208 __le16 dnaddr;
69209
69210 set_fs(KERNEL_DS);
69211 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
69212 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
69213 set_fs(old_fs);
69214 if (result < 0)
69215 goto out;
69216 @@ -1233,7 +1233,7 @@ static ssize_t bin_dn_node_address(struct file *file,
69217 le16_to_cpu(dnaddr) & 0x3ff);
69218
69219 set_fs(KERNEL_DS);
69220 - result = vfs_write(file, buf, len, &pos);
69221 + result = vfs_write(file, (const char __force_user *)buf, len, &pos);
69222 set_fs(old_fs);
69223 if (result < 0)
69224 goto out;
69225 diff --git a/kernel/sysctl_check.c b/kernel/sysctl_check.c
69226 index 362da65..ab8ef8c 100644
69227 --- a/kernel/sysctl_check.c
69228 +++ b/kernel/sysctl_check.c
69229 @@ -129,6 +129,7 @@ int sysctl_check_table(struct nsproxy *namespaces, struct ctl_table *table)
69230 set_fail(&fail, table, "Directory with extra2");
69231 } else {
69232 if ((table->proc_handler == proc_dostring) ||
69233 + (table->proc_handler == proc_dostring_modpriv) ||
69234 (table->proc_handler == proc_dointvec) ||
69235 (table->proc_handler == proc_dointvec_minmax) ||
69236 (table->proc_handler == proc_dointvec_jiffies) ||
69237 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
69238 index e660464..c8b9e67 100644
69239 --- a/kernel/taskstats.c
69240 +++ b/kernel/taskstats.c
69241 @@ -27,9 +27,12 @@
69242 #include <linux/cgroup.h>
69243 #include <linux/fs.h>
69244 #include <linux/file.h>
69245 +#include <linux/grsecurity.h>
69246 #include <net/genetlink.h>
69247 #include <linux/atomic.h>
69248
69249 +extern int gr_is_taskstats_denied(int pid);
69250 +
69251 /*
69252 * Maximum length of a cpumask that can be specified in
69253 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
69254 @@ -556,6 +559,9 @@ err:
69255
69256 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
69257 {
69258 + if (gr_is_taskstats_denied(current->pid))
69259 + return -EACCES;
69260 +
69261 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
69262 return cmd_attr_register_cpumask(info);
69263 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
69264 diff --git a/kernel/time.c b/kernel/time.c
69265 index 73e416d..cfc6f69 100644
69266 --- a/kernel/time.c
69267 +++ b/kernel/time.c
69268 @@ -163,6 +163,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
69269 return error;
69270
69271 if (tz) {
69272 + /* we log in do_settimeofday called below, so don't log twice
69273 + */
69274 + if (!tv)
69275 + gr_log_timechange();
69276 +
69277 /* SMP safe, global irq locking makes it work. */
69278 sys_tz = *tz;
69279 update_vsyscall_tz();
69280 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
69281 index 8a46f5d..bbe6f9c 100644
69282 --- a/kernel/time/alarmtimer.c
69283 +++ b/kernel/time/alarmtimer.c
69284 @@ -773,7 +773,7 @@ static int __init alarmtimer_init(void)
69285 struct platform_device *pdev;
69286 int error = 0;
69287 int i;
69288 - struct k_clock alarm_clock = {
69289 + static struct k_clock alarm_clock = {
69290 .clock_getres = alarm_clock_getres,
69291 .clock_get = alarm_clock_get,
69292 .timer_create = alarm_timer_create,
69293 diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
69294 index fd4a7b1..fae5c2a 100644
69295 --- a/kernel/time/tick-broadcast.c
69296 +++ b/kernel/time/tick-broadcast.c
69297 @@ -115,7 +115,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
69298 * then clear the broadcast bit.
69299 */
69300 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
69301 - int cpu = smp_processor_id();
69302 + cpu = smp_processor_id();
69303
69304 cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
69305 tick_broadcast_clear_oneshot(cpu);
69306 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
69307 index 0c63581..e25dcb6 100644
69308 --- a/kernel/time/timekeeping.c
69309 +++ b/kernel/time/timekeeping.c
69310 @@ -14,6 +14,7 @@
69311 #include <linux/init.h>
69312 #include <linux/mm.h>
69313 #include <linux/sched.h>
69314 +#include <linux/grsecurity.h>
69315 #include <linux/syscore_ops.h>
69316 #include <linux/clocksource.h>
69317 #include <linux/jiffies.h>
69318 @@ -365,6 +366,8 @@ int do_settimeofday(const struct timespec *tv)
69319 if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
69320 return -EINVAL;
69321
69322 + gr_log_timechange();
69323 +
69324 write_seqlock_irqsave(&xtime_lock, flags);
69325
69326 timekeeping_forward_now();
69327 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
69328 index 3258455..f35227d 100644
69329 --- a/kernel/time/timer_list.c
69330 +++ b/kernel/time/timer_list.c
69331 @@ -38,12 +38,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
69332
69333 static void print_name_offset(struct seq_file *m, void *sym)
69334 {
69335 +#ifdef CONFIG_GRKERNSEC_HIDESYM
69336 + SEQ_printf(m, "<%p>", NULL);
69337 +#else
69338 char symname[KSYM_NAME_LEN];
69339
69340 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
69341 SEQ_printf(m, "<%pK>", sym);
69342 else
69343 SEQ_printf(m, "%s", symname);
69344 +#endif
69345 }
69346
69347 static void
69348 @@ -112,7 +116,11 @@ next_one:
69349 static void
69350 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
69351 {
69352 +#ifdef CONFIG_GRKERNSEC_HIDESYM
69353 + SEQ_printf(m, " .base: %p\n", NULL);
69354 +#else
69355 SEQ_printf(m, " .base: %pK\n", base);
69356 +#endif
69357 SEQ_printf(m, " .index: %d\n",
69358 base->index);
69359 SEQ_printf(m, " .resolution: %Lu nsecs\n",
69360 @@ -293,7 +301,11 @@ static int __init init_timer_list_procfs(void)
69361 {
69362 struct proc_dir_entry *pe;
69363
69364 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
69365 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
69366 +#else
69367 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
69368 +#endif
69369 if (!pe)
69370 return -ENOMEM;
69371 return 0;
69372 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
69373 index 0b537f2..9e71eca 100644
69374 --- a/kernel/time/timer_stats.c
69375 +++ b/kernel/time/timer_stats.c
69376 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
69377 static unsigned long nr_entries;
69378 static struct entry entries[MAX_ENTRIES];
69379
69380 -static atomic_t overflow_count;
69381 +static atomic_unchecked_t overflow_count;
69382
69383 /*
69384 * The entries are in a hash-table, for fast lookup:
69385 @@ -140,7 +140,7 @@ static void reset_entries(void)
69386 nr_entries = 0;
69387 memset(entries, 0, sizeof(entries));
69388 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
69389 - atomic_set(&overflow_count, 0);
69390 + atomic_set_unchecked(&overflow_count, 0);
69391 }
69392
69393 static struct entry *alloc_entry(void)
69394 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
69395 if (likely(entry))
69396 entry->count++;
69397 else
69398 - atomic_inc(&overflow_count);
69399 + atomic_inc_unchecked(&overflow_count);
69400
69401 out_unlock:
69402 raw_spin_unlock_irqrestore(lock, flags);
69403 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
69404
69405 static void print_name_offset(struct seq_file *m, unsigned long addr)
69406 {
69407 +#ifdef CONFIG_GRKERNSEC_HIDESYM
69408 + seq_printf(m, "<%p>", NULL);
69409 +#else
69410 char symname[KSYM_NAME_LEN];
69411
69412 if (lookup_symbol_name(addr, symname) < 0)
69413 seq_printf(m, "<%p>", (void *)addr);
69414 else
69415 seq_printf(m, "%s", symname);
69416 +#endif
69417 }
69418
69419 static int tstats_show(struct seq_file *m, void *v)
69420 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
69421
69422 seq_puts(m, "Timer Stats Version: v0.2\n");
69423 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
69424 - if (atomic_read(&overflow_count))
69425 + if (atomic_read_unchecked(&overflow_count))
69426 seq_printf(m, "Overflow: %d entries\n",
69427 - atomic_read(&overflow_count));
69428 + atomic_read_unchecked(&overflow_count));
69429
69430 for (i = 0; i < nr_entries; i++) {
69431 entry = entries + i;
69432 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
69433 {
69434 struct proc_dir_entry *pe;
69435
69436 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
69437 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
69438 +#else
69439 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
69440 +#endif
69441 if (!pe)
69442 return -ENOMEM;
69443 return 0;
69444 diff --git a/kernel/timer.c b/kernel/timer.c
69445 index a297ffc..5e16b0b 100644
69446 --- a/kernel/timer.c
69447 +++ b/kernel/timer.c
69448 @@ -1354,7 +1354,7 @@ void update_process_times(int user_tick)
69449 /*
69450 * This function runs timers and the timer-tq in bottom half context.
69451 */
69452 -static void run_timer_softirq(struct softirq_action *h)
69453 +static void run_timer_softirq(void)
69454 {
69455 struct tvec_base *base = __this_cpu_read(tvec_bases);
69456
69457 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
69458 index cdea7b5..9b820d4 100644
69459 --- a/kernel/trace/blktrace.c
69460 +++ b/kernel/trace/blktrace.c
69461 @@ -324,7 +324,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
69462 struct blk_trace *bt = filp->private_data;
69463 char buf[16];
69464
69465 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
69466 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
69467
69468 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
69469 }
69470 @@ -389,7 +389,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
69471 return 1;
69472
69473 bt = buf->chan->private_data;
69474 - atomic_inc(&bt->dropped);
69475 + atomic_inc_unchecked(&bt->dropped);
69476 return 0;
69477 }
69478
69479 @@ -490,7 +490,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
69480
69481 bt->dir = dir;
69482 bt->dev = dev;
69483 - atomic_set(&bt->dropped, 0);
69484 + atomic_set_unchecked(&bt->dropped, 0);
69485
69486 ret = -EIO;
69487 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
69488 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
69489 index 683d559..d70d914 100644
69490 --- a/kernel/trace/ftrace.c
69491 +++ b/kernel/trace/ftrace.c
69492 @@ -1726,12 +1726,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
69493 if (unlikely(ftrace_disabled))
69494 return 0;
69495
69496 + ret = ftrace_arch_code_modify_prepare();
69497 + FTRACE_WARN_ON(ret);
69498 + if (ret)
69499 + return 0;
69500 +
69501 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
69502 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
69503 if (ret) {
69504 ftrace_bug(ret, ip);
69505 - return 0;
69506 }
69507 - return 1;
69508 + return ret ? 0 : 1;
69509 }
69510
69511 /*
69512 @@ -2843,7 +2848,7 @@ static void ftrace_free_entry_rcu(struct rcu_head *rhp)
69513
69514 int
69515 register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
69516 - void *data)
69517 + void *data)
69518 {
69519 struct ftrace_func_probe *entry;
69520 struct ftrace_page *pg;
69521 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
69522 index c4579f1..6a439da 100644
69523 --- a/kernel/trace/trace.c
69524 +++ b/kernel/trace/trace.c
69525 @@ -4258,10 +4258,9 @@ static const struct file_operations tracing_dyn_info_fops = {
69526 };
69527 #endif
69528
69529 -static struct dentry *d_tracer;
69530 -
69531 struct dentry *tracing_init_dentry(void)
69532 {
69533 + static struct dentry *d_tracer;
69534 static int once;
69535
69536 if (d_tracer)
69537 @@ -4281,10 +4280,9 @@ struct dentry *tracing_init_dentry(void)
69538 return d_tracer;
69539 }
69540
69541 -static struct dentry *d_percpu;
69542 -
69543 struct dentry *tracing_dentry_percpu(void)
69544 {
69545 + static struct dentry *d_percpu;
69546 static int once;
69547 struct dentry *d_tracer;
69548
69549 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
69550 index c212a7f..7b02394 100644
69551 --- a/kernel/trace/trace_events.c
69552 +++ b/kernel/trace/trace_events.c
69553 @@ -1299,10 +1299,6 @@ static LIST_HEAD(ftrace_module_file_list);
69554 struct ftrace_module_file_ops {
69555 struct list_head list;
69556 struct module *mod;
69557 - struct file_operations id;
69558 - struct file_operations enable;
69559 - struct file_operations format;
69560 - struct file_operations filter;
69561 };
69562
69563 static struct ftrace_module_file_ops *
69564 @@ -1323,17 +1319,12 @@ trace_create_file_ops(struct module *mod)
69565
69566 file_ops->mod = mod;
69567
69568 - file_ops->id = ftrace_event_id_fops;
69569 - file_ops->id.owner = mod;
69570 -
69571 - file_ops->enable = ftrace_enable_fops;
69572 - file_ops->enable.owner = mod;
69573 -
69574 - file_ops->filter = ftrace_event_filter_fops;
69575 - file_ops->filter.owner = mod;
69576 -
69577 - file_ops->format = ftrace_event_format_fops;
69578 - file_ops->format.owner = mod;
69579 + pax_open_kernel();
69580 + *(void **)&mod->trace_id.owner = mod;
69581 + *(void **)&mod->trace_enable.owner = mod;
69582 + *(void **)&mod->trace_filter.owner = mod;
69583 + *(void **)&mod->trace_format.owner = mod;
69584 + pax_close_kernel();
69585
69586 list_add(&file_ops->list, &ftrace_module_file_list);
69587
69588 @@ -1357,8 +1348,8 @@ static void trace_module_add_events(struct module *mod)
69589
69590 for_each_event(call, start, end) {
69591 __trace_add_event_call(*call, mod,
69592 - &file_ops->id, &file_ops->enable,
69593 - &file_ops->filter, &file_ops->format);
69594 + &mod->trace_id, &mod->trace_enable,
69595 + &mod->trace_filter, &mod->trace_format);
69596 }
69597 }
69598
69599 diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
69600 index 00d527c..7c5b1a3 100644
69601 --- a/kernel/trace/trace_kprobe.c
69602 +++ b/kernel/trace/trace_kprobe.c
69603 @@ -217,7 +217,7 @@ static __kprobes void FETCH_FUNC_NAME(memory, string)(struct pt_regs *regs,
69604 long ret;
69605 int maxlen = get_rloc_len(*(u32 *)dest);
69606 u8 *dst = get_rloc_data(dest);
69607 - u8 *src = addr;
69608 + const u8 __user *src = (const u8 __force_user *)addr;
69609 mm_segment_t old_fs = get_fs();
69610 if (!maxlen)
69611 return;
69612 @@ -229,7 +229,7 @@ static __kprobes void FETCH_FUNC_NAME(memory, string)(struct pt_regs *regs,
69613 pagefault_disable();
69614 do
69615 ret = __copy_from_user_inatomic(dst++, src++, 1);
69616 - while (dst[-1] && ret == 0 && src - (u8 *)addr < maxlen);
69617 + while (dst[-1] && ret == 0 && src - (const u8 __force_user *)addr < maxlen);
69618 dst[-1] = '\0';
69619 pagefault_enable();
69620 set_fs(old_fs);
69621 @@ -238,7 +238,7 @@ static __kprobes void FETCH_FUNC_NAME(memory, string)(struct pt_regs *regs,
69622 ((u8 *)get_rloc_data(dest))[0] = '\0';
69623 *(u32 *)dest = make_data_rloc(0, get_rloc_offs(*(u32 *)dest));
69624 } else
69625 - *(u32 *)dest = make_data_rloc(src - (u8 *)addr,
69626 + *(u32 *)dest = make_data_rloc(src - (const u8 __force_user *)addr,
69627 get_rloc_offs(*(u32 *)dest));
69628 }
69629 /* Return the length of string -- including null terminal byte */
69630 @@ -252,7 +252,7 @@ static __kprobes void FETCH_FUNC_NAME(memory, string_size)(struct pt_regs *regs,
69631 set_fs(KERNEL_DS);
69632 pagefault_disable();
69633 do {
69634 - ret = __copy_from_user_inatomic(&c, (u8 *)addr + len, 1);
69635 + ret = __copy_from_user_inatomic(&c, (const u8 __force_user *)addr + len, 1);
69636 len++;
69637 } while (c && ret == 0 && len < MAX_STRING_SIZE);
69638 pagefault_enable();
69639 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
69640 index fd3c8aa..5f324a6 100644
69641 --- a/kernel/trace/trace_mmiotrace.c
69642 +++ b/kernel/trace/trace_mmiotrace.c
69643 @@ -24,7 +24,7 @@ struct header_iter {
69644 static struct trace_array *mmio_trace_array;
69645 static bool overrun_detected;
69646 static unsigned long prev_overruns;
69647 -static atomic_t dropped_count;
69648 +static atomic_unchecked_t dropped_count;
69649
69650 static void mmio_reset_data(struct trace_array *tr)
69651 {
69652 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
69653
69654 static unsigned long count_overruns(struct trace_iterator *iter)
69655 {
69656 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
69657 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
69658 unsigned long over = ring_buffer_overruns(iter->tr->buffer);
69659
69660 if (over > prev_overruns)
69661 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
69662 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
69663 sizeof(*entry), 0, pc);
69664 if (!event) {
69665 - atomic_inc(&dropped_count);
69666 + atomic_inc_unchecked(&dropped_count);
69667 return;
69668 }
69669 entry = ring_buffer_event_data(event);
69670 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
69671 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
69672 sizeof(*entry), 0, pc);
69673 if (!event) {
69674 - atomic_inc(&dropped_count);
69675 + atomic_inc_unchecked(&dropped_count);
69676 return;
69677 }
69678 entry = ring_buffer_event_data(event);
69679 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
69680 index d9c07f0..c1eeceb 100644
69681 --- a/kernel/trace/trace_output.c
69682 +++ b/kernel/trace/trace_output.c
69683 @@ -278,7 +278,7 @@ int trace_seq_path(struct trace_seq *s, struct path *path)
69684
69685 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
69686 if (!IS_ERR(p)) {
69687 - p = mangle_path(s->buffer + s->len, p, "\n");
69688 + p = mangle_path(s->buffer + s->len, p, "\n\\");
69689 if (p) {
69690 s->len = p - s->buffer;
69691 return 1;
69692 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
69693 index d4545f4..a9010a1 100644
69694 --- a/kernel/trace/trace_stack.c
69695 +++ b/kernel/trace/trace_stack.c
69696 @@ -53,7 +53,7 @@ static inline void check_stack(void)
69697 return;
69698
69699 /* we do not handle interrupt stacks yet */
69700 - if (!object_is_on_stack(&this_size))
69701 + if (!object_starts_on_stack(&this_size))
69702 return;
69703
69704 local_irq_save(flags);
69705 diff --git a/kernel/trace/trace_workqueue.c b/kernel/trace/trace_workqueue.c
69706 index 209b379..7f76423 100644
69707 --- a/kernel/trace/trace_workqueue.c
69708 +++ b/kernel/trace/trace_workqueue.c
69709 @@ -22,7 +22,7 @@ struct cpu_workqueue_stats {
69710 int cpu;
69711 pid_t pid;
69712 /* Can be inserted from interrupt or user context, need to be atomic */
69713 - atomic_t inserted;
69714 + atomic_unchecked_t inserted;
69715 /*
69716 * Don't need to be atomic, works are serialized in a single workqueue thread
69717 * on a single CPU.
69718 @@ -60,7 +60,7 @@ probe_workqueue_insertion(void *ignore,
69719 spin_lock_irqsave(&workqueue_cpu_stat(cpu)->lock, flags);
69720 list_for_each_entry(node, &workqueue_cpu_stat(cpu)->list, list) {
69721 if (node->pid == wq_thread->pid) {
69722 - atomic_inc(&node->inserted);
69723 + atomic_inc_unchecked(&node->inserted);
69724 goto found;
69725 }
69726 }
69727 @@ -210,7 +210,7 @@ static int workqueue_stat_show(struct seq_file *s, void *p)
69728 tsk = get_pid_task(pid, PIDTYPE_PID);
69729 if (tsk) {
69730 seq_printf(s, "%3d %6d %6u %s\n", cws->cpu,
69731 - atomic_read(&cws->inserted), cws->executed,
69732 + atomic_read_unchecked(&cws->inserted), cws->executed,
69733 tsk->comm);
69734 put_task_struct(tsk);
69735 }
69736 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
69737 index 8745ac7..d144e37 100644
69738 --- a/lib/Kconfig.debug
69739 +++ b/lib/Kconfig.debug
69740 @@ -1103,6 +1103,7 @@ config LATENCYTOP
69741 depends on DEBUG_KERNEL
69742 depends on STACKTRACE_SUPPORT
69743 depends on PROC_FS
69744 + depends on !GRKERNSEC_HIDESYM
69745 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
69746 select KALLSYMS
69747 select KALLSYMS_ALL
69748 diff --git a/lib/bitmap.c b/lib/bitmap.c
69749 index 0d4a127..33a06c7 100644
69750 --- a/lib/bitmap.c
69751 +++ b/lib/bitmap.c
69752 @@ -419,7 +419,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
69753 {
69754 int c, old_c, totaldigits, ndigits, nchunks, nbits;
69755 u32 chunk;
69756 - const char __user __force *ubuf = (const char __user __force *)buf;
69757 + const char __user *ubuf = (const char __force_user *)buf;
69758
69759 bitmap_zero(maskp, nmaskbits);
69760
69761 @@ -504,7 +504,7 @@ int bitmap_parse_user(const char __user *ubuf,
69762 {
69763 if (!access_ok(VERIFY_READ, ubuf, ulen))
69764 return -EFAULT;
69765 - return __bitmap_parse((const char __force *)ubuf,
69766 + return __bitmap_parse((const char __force_kernel *)ubuf,
69767 ulen, 1, maskp, nmaskbits);
69768
69769 }
69770 @@ -596,7 +596,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
69771 {
69772 unsigned a, b;
69773 int c, old_c, totaldigits;
69774 - const char __user __force *ubuf = (const char __user __force *)buf;
69775 + const char __user *ubuf = (const char __force_user *)buf;
69776 int exp_digit, in_range;
69777
69778 totaldigits = c = 0;
69779 @@ -696,7 +696,7 @@ int bitmap_parselist_user(const char __user *ubuf,
69780 {
69781 if (!access_ok(VERIFY_READ, ubuf, ulen))
69782 return -EFAULT;
69783 - return __bitmap_parselist((const char __force *)ubuf,
69784 + return __bitmap_parselist((const char __force_kernel *)ubuf,
69785 ulen, 1, maskp, nmaskbits);
69786 }
69787 EXPORT_SYMBOL(bitmap_parselist_user);
69788 diff --git a/lib/bug.c b/lib/bug.c
69789 index a28c141..2bd3d95 100644
69790 --- a/lib/bug.c
69791 +++ b/lib/bug.c
69792 @@ -133,6 +133,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
69793 return BUG_TRAP_TYPE_NONE;
69794
69795 bug = find_bug(bugaddr);
69796 + if (!bug)
69797 + return BUG_TRAP_TYPE_NONE;
69798
69799 file = NULL;
69800 line = 0;
69801 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
69802 index 0ab9ae8..f01ceca 100644
69803 --- a/lib/debugobjects.c
69804 +++ b/lib/debugobjects.c
69805 @@ -288,7 +288,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
69806 if (limit > 4)
69807 return;
69808
69809 - is_on_stack = object_is_on_stack(addr);
69810 + is_on_stack = object_starts_on_stack(addr);
69811 if (is_on_stack == onstack)
69812 return;
69813
69814 diff --git a/lib/devres.c b/lib/devres.c
69815 index 9676617..5149e15 100644
69816 --- a/lib/devres.c
69817 +++ b/lib/devres.c
69818 @@ -80,7 +80,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
69819 void devm_iounmap(struct device *dev, void __iomem *addr)
69820 {
69821 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
69822 - (void *)addr));
69823 + (void __force *)addr));
69824 iounmap(addr);
69825 }
69826 EXPORT_SYMBOL(devm_iounmap);
69827 @@ -192,7 +192,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
69828 {
69829 ioport_unmap(addr);
69830 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
69831 - devm_ioport_map_match, (void *)addr));
69832 + devm_ioport_map_match, (void __force *)addr));
69833 }
69834 EXPORT_SYMBOL(devm_ioport_unmap);
69835
69836 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
69837 index fea790a..ebb0e82 100644
69838 --- a/lib/dma-debug.c
69839 +++ b/lib/dma-debug.c
69840 @@ -925,7 +925,7 @@ out:
69841
69842 static void check_for_stack(struct device *dev, void *addr)
69843 {
69844 - if (object_is_on_stack(addr))
69845 + if (object_starts_on_stack(addr))
69846 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
69847 "stack [addr=%p]\n", addr);
69848 }
69849 diff --git a/lib/extable.c b/lib/extable.c
69850 index 4cac81e..63e9b8f 100644
69851 --- a/lib/extable.c
69852 +++ b/lib/extable.c
69853 @@ -13,6 +13,7 @@
69854 #include <linux/init.h>
69855 #include <linux/sort.h>
69856 #include <asm/uaccess.h>
69857 +#include <asm/pgtable.h>
69858
69859 #ifndef ARCH_HAS_SORT_EXTABLE
69860 /*
69861 @@ -36,8 +37,10 @@ static int cmp_ex(const void *a, const void *b)
69862 void sort_extable(struct exception_table_entry *start,
69863 struct exception_table_entry *finish)
69864 {
69865 + pax_open_kernel();
69866 sort(start, finish - start, sizeof(struct exception_table_entry),
69867 cmp_ex, NULL);
69868 + pax_close_kernel();
69869 }
69870
69871 #ifdef CONFIG_MODULES
69872 diff --git a/lib/inflate.c b/lib/inflate.c
69873 index 013a761..c28f3fc 100644
69874 --- a/lib/inflate.c
69875 +++ b/lib/inflate.c
69876 @@ -269,7 +269,7 @@ static void free(void *where)
69877 malloc_ptr = free_mem_ptr;
69878 }
69879 #else
69880 -#define malloc(a) kmalloc(a, GFP_KERNEL)
69881 +#define malloc(a) kmalloc((a), GFP_KERNEL)
69882 #define free(a) kfree(a)
69883 #endif
69884
69885 diff --git a/lib/ioremap.c b/lib/ioremap.c
69886 index da4e2ad..6373b5f 100644
69887 --- a/lib/ioremap.c
69888 +++ b/lib/ioremap.c
69889 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
69890 unsigned long next;
69891
69892 phys_addr -= addr;
69893 - pmd = pmd_alloc(&init_mm, pud, addr);
69894 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
69895 if (!pmd)
69896 return -ENOMEM;
69897 do {
69898 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
69899 unsigned long next;
69900
69901 phys_addr -= addr;
69902 - pud = pud_alloc(&init_mm, pgd, addr);
69903 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
69904 if (!pud)
69905 return -ENOMEM;
69906 do {
69907 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
69908 index bd2bea9..6b3c95e 100644
69909 --- a/lib/is_single_threaded.c
69910 +++ b/lib/is_single_threaded.c
69911 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
69912 struct task_struct *p, *t;
69913 bool ret;
69914
69915 + if (!mm)
69916 + return true;
69917 +
69918 if (atomic_read(&task->signal->live) != 1)
69919 return false;
69920
69921 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
69922 index dc63d08..95ae14a 100644
69923 --- a/lib/radix-tree.c
69924 +++ b/lib/radix-tree.c
69925 @@ -78,7 +78,7 @@ struct radix_tree_preload {
69926 int nr;
69927 struct radix_tree_node *nodes[RADIX_TREE_MAX_PATH];
69928 };
69929 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
69930 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
69931
69932 static inline void *ptr_to_indirect(void *ptr)
69933 {
69934 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
69935 index 38e612e..4fb99a8 100644
69936 --- a/lib/vsprintf.c
69937 +++ b/lib/vsprintf.c
69938 @@ -16,6 +16,9 @@
69939 * - scnprintf and vscnprintf
69940 */
69941
69942 +#ifdef CONFIG_GRKERNSEC_HIDESYM
69943 +#define __INCLUDED_BY_HIDESYM 1
69944 +#endif
69945 #include <stdarg.h>
69946 #include <linux/module.h>
69947 #include <linux/types.h>
69948 @@ -413,7 +416,7 @@ char *symbol_string(char *buf, char *end, void *ptr,
69949 char sym[KSYM_SYMBOL_LEN];
69950 if (ext == 'B')
69951 sprint_backtrace(sym, value);
69952 - else if (ext != 'f' && ext != 's')
69953 + else if (ext != 'f' && ext != 's' && ext != 'a')
69954 sprint_symbol(sym, value);
69955 else
69956 kallsyms_lookup(value, NULL, NULL, NULL, sym);
69957 @@ -789,7 +792,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
69958 return number(buf, end, *(const netdev_features_t *)addr, spec);
69959 }
69960
69961 +#ifdef CONFIG_GRKERNSEC_HIDESYM
69962 +int kptr_restrict __read_mostly = 2;
69963 +#else
69964 int kptr_restrict __read_mostly;
69965 +#endif
69966
69967 /*
69968 * Show a '%p' thing. A kernel extension is that the '%p' is followed
69969 @@ -803,6 +810,8 @@ int kptr_restrict __read_mostly;
69970 * - 'S' For symbolic direct pointers with offset
69971 * - 's' For symbolic direct pointers without offset
69972 * - 'B' For backtraced symbolic direct pointers with offset
69973 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
69974 + * - 'a' For symbolic direct pointers without offset approved for use with GRKERNSEC_HIDESYM
69975 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
69976 * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]
69977 * - 'M' For a 6-byte MAC address, it prints the address in the
69978 @@ -848,12 +857,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
69979 {
69980 if (!ptr && *fmt != 'K') {
69981 /*
69982 - * Print (null) with the same width as a pointer so it makes
69983 + * Print (nil) with the same width as a pointer so it makes
69984 * tabular output look nice.
69985 */
69986 if (spec.field_width == -1)
69987 spec.field_width = 2 * sizeof(void *);
69988 - return string(buf, end, "(null)", spec);
69989 + return string(buf, end, "(nil)", spec);
69990 }
69991
69992 switch (*fmt) {
69993 @@ -863,6 +872,13 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
69994 /* Fallthrough */
69995 case 'S':
69996 case 's':
69997 +#ifdef CONFIG_GRKERNSEC_HIDESYM
69998 + break;
69999 +#else
70000 + return symbol_string(buf, end, ptr, spec, *fmt);
70001 +#endif
70002 + case 'A':
70003 + case 'a':
70004 case 'B':
70005 return symbol_string(buf, end, ptr, spec, *fmt);
70006 case 'R':
70007 @@ -1633,11 +1649,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
70008 typeof(type) value; \
70009 if (sizeof(type) == 8) { \
70010 args = PTR_ALIGN(args, sizeof(u32)); \
70011 - *(u32 *)&value = *(u32 *)args; \
70012 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
70013 + *(u32 *)&value = *(const u32 *)args; \
70014 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
70015 } else { \
70016 args = PTR_ALIGN(args, sizeof(type)); \
70017 - value = *(typeof(type) *)args; \
70018 + value = *(const typeof(type) *)args; \
70019 } \
70020 args += sizeof(type); \
70021 value; \
70022 @@ -1700,7 +1716,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
70023 case FORMAT_TYPE_STR: {
70024 const char *str_arg = args;
70025 args += strlen(str_arg) + 1;
70026 - str = string(str, end, (char *)str_arg, spec);
70027 + str = string(str, end, str_arg, spec);
70028 break;
70029 }
70030
70031 diff --git a/localversion-grsec b/localversion-grsec
70032 new file mode 100644
70033 index 0000000..7cd6065
70034 --- /dev/null
70035 +++ b/localversion-grsec
70036 @@ -0,0 +1 @@
70037 +-grsec
70038 diff --git a/mm/Kconfig b/mm/Kconfig
70039 index e338407..49b5b7a 100644
70040 --- a/mm/Kconfig
70041 +++ b/mm/Kconfig
70042 @@ -247,10 +247,10 @@ config KSM
70043 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
70044
70045 config DEFAULT_MMAP_MIN_ADDR
70046 - int "Low address space to protect from user allocation"
70047 + int "Low address space to protect from user allocation"
70048 depends on MMU
70049 - default 4096
70050 - help
70051 + default 65536
70052 + help
70053 This is the portion of low virtual memory which should be protected
70054 from userspace allocation. Keeping a user from writing to low pages
70055 can help reduce the impact of kernel NULL pointer bugs.
70056 diff --git a/mm/filemap.c b/mm/filemap.c
70057 index b662757..3081ddd 100644
70058 --- a/mm/filemap.c
70059 +++ b/mm/filemap.c
70060 @@ -1770,7 +1770,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
70061 struct address_space *mapping = file->f_mapping;
70062
70063 if (!mapping->a_ops->readpage)
70064 - return -ENOEXEC;
70065 + return -ENODEV;
70066 file_accessed(file);
70067 vma->vm_ops = &generic_file_vm_ops;
70068 vma->vm_flags |= VM_CAN_NONLINEAR;
70069 @@ -2176,6 +2176,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
70070 *pos = i_size_read(inode);
70071
70072 if (limit != RLIM_INFINITY) {
70073 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
70074 if (*pos >= limit) {
70075 send_sig(SIGXFSZ, current, 0);
70076 return -EFBIG;
70077 diff --git a/mm/fremap.c b/mm/fremap.c
70078 index 9ed4fd4..c42648d 100644
70079 --- a/mm/fremap.c
70080 +++ b/mm/fremap.c
70081 @@ -155,6 +155,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
70082 retry:
70083 vma = find_vma(mm, start);
70084
70085 +#ifdef CONFIG_PAX_SEGMEXEC
70086 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
70087 + goto out;
70088 +#endif
70089 +
70090 /*
70091 * Make sure the vma is shared, that it supports prefaulting,
70092 * and that the remapped range is valid and fully within
70093 diff --git a/mm/highmem.c b/mm/highmem.c
70094 index 57d82c6..e9e0552 100644
70095 --- a/mm/highmem.c
70096 +++ b/mm/highmem.c
70097 @@ -125,9 +125,10 @@ static void flush_all_zero_pkmaps(void)
70098 * So no dangers, even with speculative execution.
70099 */
70100 page = pte_page(pkmap_page_table[i]);
70101 + pax_open_kernel();
70102 pte_clear(&init_mm, (unsigned long)page_address(page),
70103 &pkmap_page_table[i]);
70104 -
70105 + pax_close_kernel();
70106 set_page_address(page, NULL);
70107 need_flush = 1;
70108 }
70109 @@ -186,9 +187,11 @@ start:
70110 }
70111 }
70112 vaddr = PKMAP_ADDR(last_pkmap_nr);
70113 +
70114 + pax_open_kernel();
70115 set_pte_at(&init_mm, vaddr,
70116 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
70117 -
70118 + pax_close_kernel();
70119 pkmap_count[last_pkmap_nr] = 1;
70120 set_page_address(page, (void *)vaddr);
70121
70122 diff --git a/mm/huge_memory.c b/mm/huge_memory.c
70123 index 8f7fc39..69bf1e9 100644
70124 --- a/mm/huge_memory.c
70125 +++ b/mm/huge_memory.c
70126 @@ -733,7 +733,7 @@ out:
70127 * run pte_offset_map on the pmd, if an huge pmd could
70128 * materialize from under us from a different thread.
70129 */
70130 - if (unlikely(__pte_alloc(mm, vma, pmd, address)))
70131 + if (unlikely(pmd_none(*pmd) && __pte_alloc(mm, vma, pmd, address)))
70132 return VM_FAULT_OOM;
70133 /* if an huge pmd materialized from under us just retry later */
70134 if (unlikely(pmd_trans_huge(*pmd)))
70135 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
70136 index fece520..7fad868 100644
70137 --- a/mm/hugetlb.c
70138 +++ b/mm/hugetlb.c
70139 @@ -2146,6 +2146,15 @@ static void hugetlb_vm_op_open(struct vm_area_struct *vma)
70140 kref_get(&reservations->refs);
70141 }
70142
70143 +static void resv_map_put(struct vm_area_struct *vma)
70144 +{
70145 + struct resv_map *reservations = vma_resv_map(vma);
70146 +
70147 + if (!reservations)
70148 + return;
70149 + kref_put(&reservations->refs, resv_map_release);
70150 +}
70151 +
70152 static void hugetlb_vm_op_close(struct vm_area_struct *vma)
70153 {
70154 struct hstate *h = hstate_vma(vma);
70155 @@ -2162,7 +2171,7 @@ static void hugetlb_vm_op_close(struct vm_area_struct *vma)
70156 reserve = (end - start) -
70157 region_count(&reservations->regions, start, end);
70158
70159 - kref_put(&reservations->refs, resv_map_release);
70160 + resv_map_put(vma);
70161
70162 if (reserve) {
70163 hugetlb_acct_memory(h, -reserve);
70164 @@ -2425,6 +2434,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
70165 return 1;
70166 }
70167
70168 +#ifdef CONFIG_PAX_SEGMEXEC
70169 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
70170 +{
70171 + struct mm_struct *mm = vma->vm_mm;
70172 + struct vm_area_struct *vma_m;
70173 + unsigned long address_m;
70174 + pte_t *ptep_m;
70175 +
70176 + vma_m = pax_find_mirror_vma(vma);
70177 + if (!vma_m)
70178 + return;
70179 +
70180 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
70181 + address_m = address + SEGMEXEC_TASK_SIZE;
70182 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
70183 + get_page(page_m);
70184 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
70185 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
70186 +}
70187 +#endif
70188 +
70189 /*
70190 * Hugetlb_cow() should be called with page lock of the original hugepage held.
70191 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
70192 @@ -2537,6 +2567,11 @@ retry_avoidcopy:
70193 make_huge_pte(vma, new_page, 1));
70194 page_remove_rmap(old_page);
70195 hugepage_add_new_anon_rmap(new_page, vma, address);
70196 +
70197 +#ifdef CONFIG_PAX_SEGMEXEC
70198 + pax_mirror_huge_pte(vma, address, new_page);
70199 +#endif
70200 +
70201 /* Make the old page be freed below */
70202 new_page = old_page;
70203 mmu_notifier_invalidate_range_end(mm,
70204 @@ -2691,6 +2726,10 @@ retry:
70205 && (vma->vm_flags & VM_SHARED)));
70206 set_huge_pte_at(mm, address, ptep, new_pte);
70207
70208 +#ifdef CONFIG_PAX_SEGMEXEC
70209 + pax_mirror_huge_pte(vma, address, page);
70210 +#endif
70211 +
70212 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
70213 /* Optimization, do the COW without a second fault */
70214 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
70215 @@ -2720,6 +2759,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
70216 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
70217 struct hstate *h = hstate_vma(vma);
70218
70219 +#ifdef CONFIG_PAX_SEGMEXEC
70220 + struct vm_area_struct *vma_m;
70221 +#endif
70222 +
70223 address &= huge_page_mask(h);
70224
70225 ptep = huge_pte_offset(mm, address);
70226 @@ -2733,6 +2776,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
70227 VM_FAULT_SET_HINDEX(h - hstates);
70228 }
70229
70230 +#ifdef CONFIG_PAX_SEGMEXEC
70231 + vma_m = pax_find_mirror_vma(vma);
70232 + if (vma_m) {
70233 + unsigned long address_m;
70234 +
70235 + if (vma->vm_start > vma_m->vm_start) {
70236 + address_m = address;
70237 + address -= SEGMEXEC_TASK_SIZE;
70238 + vma = vma_m;
70239 + h = hstate_vma(vma);
70240 + } else
70241 + address_m = address + SEGMEXEC_TASK_SIZE;
70242 +
70243 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
70244 + return VM_FAULT_OOM;
70245 + address_m &= HPAGE_MASK;
70246 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
70247 + }
70248 +#endif
70249 +
70250 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
70251 if (!ptep)
70252 return VM_FAULT_OOM;
70253 @@ -2978,12 +3041,16 @@ int hugetlb_reserve_pages(struct inode *inode,
70254 set_vma_resv_flags(vma, HPAGE_RESV_OWNER);
70255 }
70256
70257 - if (chg < 0)
70258 - return chg;
70259 + if (chg < 0) {
70260 + ret = chg;
70261 + goto out_err;
70262 + }
70263
70264 /* There must be enough pages in the subpool for the mapping */
70265 - if (hugepage_subpool_get_pages(spool, chg))
70266 - return -ENOSPC;
70267 + if (hugepage_subpool_get_pages(spool, chg)) {
70268 + ret = -ENOSPC;
70269 + goto out_err;
70270 + }
70271
70272 /*
70273 * Check enough hugepages are available for the reservation.
70274 @@ -2992,7 +3059,7 @@ int hugetlb_reserve_pages(struct inode *inode,
70275 ret = hugetlb_acct_memory(h, chg);
70276 if (ret < 0) {
70277 hugepage_subpool_put_pages(spool, chg);
70278 - return ret;
70279 + goto out_err;
70280 }
70281
70282 /*
70283 @@ -3009,6 +3076,9 @@ int hugetlb_reserve_pages(struct inode *inode,
70284 if (!vma || vma->vm_flags & VM_MAYSHARE)
70285 region_add(&inode->i_mapping->private_list, from, to);
70286 return 0;
70287 +out_err:
70288 + resv_map_put(vma);
70289 + return ret;
70290 }
70291
70292 void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed)
70293 diff --git a/mm/internal.h b/mm/internal.h
70294 index 2189af4..f2ca332 100644
70295 --- a/mm/internal.h
70296 +++ b/mm/internal.h
70297 @@ -95,6 +95,7 @@ extern void putback_lru_page(struct page *page);
70298 * in mm/page_alloc.c
70299 */
70300 extern void __free_pages_bootmem(struct page *page, unsigned int order);
70301 +extern void free_compound_page(struct page *page);
70302 extern void prep_compound_page(struct page *page, unsigned long order);
70303 #ifdef CONFIG_MEMORY_FAILURE
70304 extern bool is_free_buddy_page(struct page *page);
70305 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
70306 index 45eb621..6ccd8ea 100644
70307 --- a/mm/kmemleak.c
70308 +++ b/mm/kmemleak.c
70309 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
70310
70311 for (i = 0; i < object->trace_len; i++) {
70312 void *ptr = (void *)object->trace[i];
70313 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
70314 + seq_printf(seq, " [<%p>] %pA\n", ptr, ptr);
70315 }
70316 }
70317
70318 diff --git a/mm/maccess.c b/mm/maccess.c
70319 index d53adf9..03a24bf 100644
70320 --- a/mm/maccess.c
70321 +++ b/mm/maccess.c
70322 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
70323 set_fs(KERNEL_DS);
70324 pagefault_disable();
70325 ret = __copy_from_user_inatomic(dst,
70326 - (__force const void __user *)src, size);
70327 + (const void __force_user *)src, size);
70328 pagefault_enable();
70329 set_fs(old_fs);
70330
70331 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
70332
70333 set_fs(KERNEL_DS);
70334 pagefault_disable();
70335 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
70336 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
70337 pagefault_enable();
70338 set_fs(old_fs);
70339
70340 diff --git a/mm/madvise.c b/mm/madvise.c
70341 index 74bf193..feb6fd3 100644
70342 --- a/mm/madvise.c
70343 +++ b/mm/madvise.c
70344 @@ -45,6 +45,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
70345 pgoff_t pgoff;
70346 unsigned long new_flags = vma->vm_flags;
70347
70348 +#ifdef CONFIG_PAX_SEGMEXEC
70349 + struct vm_area_struct *vma_m;
70350 +#endif
70351 +
70352 switch (behavior) {
70353 case MADV_NORMAL:
70354 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
70355 @@ -110,6 +114,13 @@ success:
70356 /*
70357 * vm_flags is protected by the mmap_sem held in write mode.
70358 */
70359 +
70360 +#ifdef CONFIG_PAX_SEGMEXEC
70361 + vma_m = pax_find_mirror_vma(vma);
70362 + if (vma_m)
70363 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
70364 +#endif
70365 +
70366 vma->vm_flags = new_flags;
70367
70368 out:
70369 @@ -168,6 +179,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
70370 struct vm_area_struct ** prev,
70371 unsigned long start, unsigned long end)
70372 {
70373 +
70374 +#ifdef CONFIG_PAX_SEGMEXEC
70375 + struct vm_area_struct *vma_m;
70376 +#endif
70377 +
70378 *prev = vma;
70379 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
70380 return -EINVAL;
70381 @@ -180,6 +196,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
70382 zap_page_range(vma, start, end - start, &details);
70383 } else
70384 zap_page_range(vma, start, end - start, NULL);
70385 +
70386 +#ifdef CONFIG_PAX_SEGMEXEC
70387 + vma_m = pax_find_mirror_vma(vma);
70388 + if (vma_m) {
70389 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
70390 + struct zap_details details = {
70391 + .nonlinear_vma = vma_m,
70392 + .last_index = ULONG_MAX,
70393 + };
70394 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
70395 + } else
70396 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
70397 + }
70398 +#endif
70399 +
70400 return 0;
70401 }
70402
70403 @@ -376,6 +407,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
70404 if (end < start)
70405 goto out;
70406
70407 +#ifdef CONFIG_PAX_SEGMEXEC
70408 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
70409 + if (end > SEGMEXEC_TASK_SIZE)
70410 + goto out;
70411 + } else
70412 +#endif
70413 +
70414 + if (end > TASK_SIZE)
70415 + goto out;
70416 +
70417 error = 0;
70418 if (end == start)
70419 goto out;
70420 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
70421 index 56080ea..115071e 100644
70422 --- a/mm/memory-failure.c
70423 +++ b/mm/memory-failure.c
70424 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
70425
70426 int sysctl_memory_failure_recovery __read_mostly = 1;
70427
70428 -atomic_long_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
70429 +atomic_long_unchecked_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
70430
70431 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
70432
70433 @@ -202,7 +202,7 @@ static int kill_proc_ao(struct task_struct *t, unsigned long addr, int trapno,
70434 si.si_signo = SIGBUS;
70435 si.si_errno = 0;
70436 si.si_code = BUS_MCEERR_AO;
70437 - si.si_addr = (void *)addr;
70438 + si.si_addr = (void __user *)addr;
70439 #ifdef __ARCH_SI_TRAPNO
70440 si.si_trapno = trapno;
70441 #endif
70442 @@ -1010,7 +1010,7 @@ int __memory_failure(unsigned long pfn, int trapno, int flags)
70443 }
70444
70445 nr_pages = 1 << compound_trans_order(hpage);
70446 - atomic_long_add(nr_pages, &mce_bad_pages);
70447 + atomic_long_add_unchecked(nr_pages, &mce_bad_pages);
70448
70449 /*
70450 * We need/can do nothing about count=0 pages.
70451 @@ -1040,7 +1040,7 @@ int __memory_failure(unsigned long pfn, int trapno, int flags)
70452 if (!PageHWPoison(hpage)
70453 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
70454 || (p != hpage && TestSetPageHWPoison(hpage))) {
70455 - atomic_long_sub(nr_pages, &mce_bad_pages);
70456 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
70457 return 0;
70458 }
70459 set_page_hwpoison_huge_page(hpage);
70460 @@ -1098,7 +1098,7 @@ int __memory_failure(unsigned long pfn, int trapno, int flags)
70461 }
70462 if (hwpoison_filter(p)) {
70463 if (TestClearPageHWPoison(p))
70464 - atomic_long_sub(nr_pages, &mce_bad_pages);
70465 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
70466 unlock_page(hpage);
70467 put_page(hpage);
70468 return 0;
70469 @@ -1315,7 +1315,7 @@ int unpoison_memory(unsigned long pfn)
70470 return 0;
70471 }
70472 if (TestClearPageHWPoison(p))
70473 - atomic_long_sub(nr_pages, &mce_bad_pages);
70474 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
70475 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
70476 return 0;
70477 }
70478 @@ -1329,7 +1329,7 @@ int unpoison_memory(unsigned long pfn)
70479 */
70480 if (TestClearPageHWPoison(page)) {
70481 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
70482 - atomic_long_sub(nr_pages, &mce_bad_pages);
70483 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
70484 freeit = 1;
70485 if (PageHuge(page))
70486 clear_page_hwpoison_huge_page(page);
70487 @@ -1442,7 +1442,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
70488 }
70489 done:
70490 if (!PageHWPoison(hpage))
70491 - atomic_long_add(1 << compound_trans_order(hpage), &mce_bad_pages);
70492 + atomic_long_add_unchecked(1 << compound_trans_order(hpage), &mce_bad_pages);
70493 set_page_hwpoison_huge_page(hpage);
70494 dequeue_hwpoisoned_huge_page(hpage);
70495 /* keep elevated page count for bad page */
70496 @@ -1573,7 +1573,7 @@ int soft_offline_page(struct page *page, int flags)
70497 return ret;
70498
70499 done:
70500 - atomic_long_add(1, &mce_bad_pages);
70501 + atomic_long_add_unchecked(1, &mce_bad_pages);
70502 SetPageHWPoison(page);
70503 /* keep elevated page count for bad page */
70504 return ret;
70505 diff --git a/mm/memory.c b/mm/memory.c
70506 index 10b4dda..06857f3 100644
70507 --- a/mm/memory.c
70508 +++ b/mm/memory.c
70509 @@ -457,8 +457,12 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
70510 return;
70511
70512 pmd = pmd_offset(pud, start);
70513 +
70514 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
70515 pud_clear(pud);
70516 pmd_free_tlb(tlb, pmd, start);
70517 +#endif
70518 +
70519 }
70520
70521 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
70522 @@ -489,9 +493,12 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
70523 if (end - 1 > ceiling - 1)
70524 return;
70525
70526 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
70527 pud = pud_offset(pgd, start);
70528 pgd_clear(pgd);
70529 pud_free_tlb(tlb, pud, start);
70530 +#endif
70531 +
70532 }
70533
70534 /*
70535 @@ -1593,12 +1600,6 @@ no_page_table:
70536 return page;
70537 }
70538
70539 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
70540 -{
70541 - return stack_guard_page_start(vma, addr) ||
70542 - stack_guard_page_end(vma, addr+PAGE_SIZE);
70543 -}
70544 -
70545 /**
70546 * __get_user_pages() - pin user pages in memory
70547 * @tsk: task_struct of target task
70548 @@ -1671,10 +1672,10 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
70549 (VM_MAYREAD | VM_MAYWRITE) : (VM_READ | VM_WRITE);
70550 i = 0;
70551
70552 - do {
70553 + while (nr_pages) {
70554 struct vm_area_struct *vma;
70555
70556 - vma = find_extend_vma(mm, start);
70557 + vma = find_vma(mm, start);
70558 if (!vma && in_gate_area(mm, start)) {
70559 unsigned long pg = start & PAGE_MASK;
70560 pgd_t *pgd;
70561 @@ -1722,7 +1723,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
70562 goto next_page;
70563 }
70564
70565 - if (!vma ||
70566 + if (!vma || start < vma->vm_start ||
70567 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
70568 !(vm_flags & vma->vm_flags))
70569 return i ? : -EFAULT;
70570 @@ -1749,11 +1750,6 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
70571 int ret;
70572 unsigned int fault_flags = 0;
70573
70574 - /* For mlock, just skip the stack guard page. */
70575 - if (foll_flags & FOLL_MLOCK) {
70576 - if (stack_guard_page(vma, start))
70577 - goto next_page;
70578 - }
70579 if (foll_flags & FOLL_WRITE)
70580 fault_flags |= FAULT_FLAG_WRITE;
70581 if (nonblocking)
70582 @@ -1827,7 +1823,7 @@ next_page:
70583 start += PAGE_SIZE;
70584 nr_pages--;
70585 } while (nr_pages && start < vma->vm_end);
70586 - } while (nr_pages);
70587 + }
70588 return i;
70589 }
70590 EXPORT_SYMBOL(__get_user_pages);
70591 @@ -2034,6 +2030,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
70592 page_add_file_rmap(page);
70593 set_pte_at(mm, addr, pte, mk_pte(page, prot));
70594
70595 +#ifdef CONFIG_PAX_SEGMEXEC
70596 + pax_mirror_file_pte(vma, addr, page, ptl);
70597 +#endif
70598 +
70599 retval = 0;
70600 pte_unmap_unlock(pte, ptl);
70601 return retval;
70602 @@ -2068,10 +2068,22 @@ out:
70603 int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
70604 struct page *page)
70605 {
70606 +
70607 +#ifdef CONFIG_PAX_SEGMEXEC
70608 + struct vm_area_struct *vma_m;
70609 +#endif
70610 +
70611 if (addr < vma->vm_start || addr >= vma->vm_end)
70612 return -EFAULT;
70613 if (!page_count(page))
70614 return -EINVAL;
70615 +
70616 +#ifdef CONFIG_PAX_SEGMEXEC
70617 + vma_m = pax_find_mirror_vma(vma);
70618 + if (vma_m)
70619 + vma_m->vm_flags |= VM_INSERTPAGE;
70620 +#endif
70621 +
70622 vma->vm_flags |= VM_INSERTPAGE;
70623 return insert_page(vma, addr, page, vma->vm_page_prot);
70624 }
70625 @@ -2157,6 +2169,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
70626 unsigned long pfn)
70627 {
70628 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
70629 + BUG_ON(vma->vm_mirror);
70630
70631 if (addr < vma->vm_start || addr >= vma->vm_end)
70632 return -EFAULT;
70633 @@ -2364,7 +2377,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
70634
70635 BUG_ON(pud_huge(*pud));
70636
70637 - pmd = pmd_alloc(mm, pud, addr);
70638 + pmd = (mm == &init_mm) ?
70639 + pmd_alloc_kernel(mm, pud, addr) :
70640 + pmd_alloc(mm, pud, addr);
70641 if (!pmd)
70642 return -ENOMEM;
70643 do {
70644 @@ -2384,7 +2399,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
70645 unsigned long next;
70646 int err;
70647
70648 - pud = pud_alloc(mm, pgd, addr);
70649 + pud = (mm == &init_mm) ?
70650 + pud_alloc_kernel(mm, pgd, addr) :
70651 + pud_alloc(mm, pgd, addr);
70652 if (!pud)
70653 return -ENOMEM;
70654 do {
70655 @@ -2472,6 +2489,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
70656 copy_user_highpage(dst, src, va, vma);
70657 }
70658
70659 +#ifdef CONFIG_PAX_SEGMEXEC
70660 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
70661 +{
70662 + struct mm_struct *mm = vma->vm_mm;
70663 + spinlock_t *ptl;
70664 + pte_t *pte, entry;
70665 +
70666 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
70667 + entry = *pte;
70668 + if (!pte_present(entry)) {
70669 + if (!pte_none(entry)) {
70670 + BUG_ON(pte_file(entry));
70671 + free_swap_and_cache(pte_to_swp_entry(entry));
70672 + pte_clear_not_present_full(mm, address, pte, 0);
70673 + }
70674 + } else {
70675 + struct page *page;
70676 +
70677 + flush_cache_page(vma, address, pte_pfn(entry));
70678 + entry = ptep_clear_flush(vma, address, pte);
70679 + BUG_ON(pte_dirty(entry));
70680 + page = vm_normal_page(vma, address, entry);
70681 + if (page) {
70682 + update_hiwater_rss(mm);
70683 + if (PageAnon(page))
70684 + dec_mm_counter_fast(mm, MM_ANONPAGES);
70685 + else
70686 + dec_mm_counter_fast(mm, MM_FILEPAGES);
70687 + page_remove_rmap(page);
70688 + page_cache_release(page);
70689 + }
70690 + }
70691 + pte_unmap_unlock(pte, ptl);
70692 +}
70693 +
70694 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
70695 + *
70696 + * the ptl of the lower mapped page is held on entry and is not released on exit
70697 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
70698 + */
70699 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
70700 +{
70701 + struct mm_struct *mm = vma->vm_mm;
70702 + unsigned long address_m;
70703 + spinlock_t *ptl_m;
70704 + struct vm_area_struct *vma_m;
70705 + pmd_t *pmd_m;
70706 + pte_t *pte_m, entry_m;
70707 +
70708 + BUG_ON(!page_m || !PageAnon(page_m));
70709 +
70710 + vma_m = pax_find_mirror_vma(vma);
70711 + if (!vma_m)
70712 + return;
70713 +
70714 + BUG_ON(!PageLocked(page_m));
70715 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
70716 + address_m = address + SEGMEXEC_TASK_SIZE;
70717 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
70718 + pte_m = pte_offset_map(pmd_m, address_m);
70719 + ptl_m = pte_lockptr(mm, pmd_m);
70720 + if (ptl != ptl_m) {
70721 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
70722 + if (!pte_none(*pte_m))
70723 + goto out;
70724 + }
70725 +
70726 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
70727 + page_cache_get(page_m);
70728 + page_add_anon_rmap(page_m, vma_m, address_m);
70729 + inc_mm_counter_fast(mm, MM_ANONPAGES);
70730 + set_pte_at(mm, address_m, pte_m, entry_m);
70731 + update_mmu_cache(vma_m, address_m, entry_m);
70732 +out:
70733 + if (ptl != ptl_m)
70734 + spin_unlock(ptl_m);
70735 + pte_unmap(pte_m);
70736 + unlock_page(page_m);
70737 +}
70738 +
70739 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
70740 +{
70741 + struct mm_struct *mm = vma->vm_mm;
70742 + unsigned long address_m;
70743 + spinlock_t *ptl_m;
70744 + struct vm_area_struct *vma_m;
70745 + pmd_t *pmd_m;
70746 + pte_t *pte_m, entry_m;
70747 +
70748 + BUG_ON(!page_m || PageAnon(page_m));
70749 +
70750 + vma_m = pax_find_mirror_vma(vma);
70751 + if (!vma_m)
70752 + return;
70753 +
70754 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
70755 + address_m = address + SEGMEXEC_TASK_SIZE;
70756 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
70757 + pte_m = pte_offset_map(pmd_m, address_m);
70758 + ptl_m = pte_lockptr(mm, pmd_m);
70759 + if (ptl != ptl_m) {
70760 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
70761 + if (!pte_none(*pte_m))
70762 + goto out;
70763 + }
70764 +
70765 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
70766 + page_cache_get(page_m);
70767 + page_add_file_rmap(page_m);
70768 + inc_mm_counter_fast(mm, MM_FILEPAGES);
70769 + set_pte_at(mm, address_m, pte_m, entry_m);
70770 + update_mmu_cache(vma_m, address_m, entry_m);
70771 +out:
70772 + if (ptl != ptl_m)
70773 + spin_unlock(ptl_m);
70774 + pte_unmap(pte_m);
70775 +}
70776 +
70777 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
70778 +{
70779 + struct mm_struct *mm = vma->vm_mm;
70780 + unsigned long address_m;
70781 + spinlock_t *ptl_m;
70782 + struct vm_area_struct *vma_m;
70783 + pmd_t *pmd_m;
70784 + pte_t *pte_m, entry_m;
70785 +
70786 + vma_m = pax_find_mirror_vma(vma);
70787 + if (!vma_m)
70788 + return;
70789 +
70790 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
70791 + address_m = address + SEGMEXEC_TASK_SIZE;
70792 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
70793 + pte_m = pte_offset_map(pmd_m, address_m);
70794 + ptl_m = pte_lockptr(mm, pmd_m);
70795 + if (ptl != ptl_m) {
70796 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
70797 + if (!pte_none(*pte_m))
70798 + goto out;
70799 + }
70800 +
70801 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
70802 + set_pte_at(mm, address_m, pte_m, entry_m);
70803 +out:
70804 + if (ptl != ptl_m)
70805 + spin_unlock(ptl_m);
70806 + pte_unmap(pte_m);
70807 +}
70808 +
70809 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
70810 +{
70811 + struct page *page_m;
70812 + pte_t entry;
70813 +
70814 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
70815 + goto out;
70816 +
70817 + entry = *pte;
70818 + page_m = vm_normal_page(vma, address, entry);
70819 + if (!page_m)
70820 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
70821 + else if (PageAnon(page_m)) {
70822 + if (pax_find_mirror_vma(vma)) {
70823 + pte_unmap_unlock(pte, ptl);
70824 + lock_page(page_m);
70825 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
70826 + if (pte_same(entry, *pte))
70827 + pax_mirror_anon_pte(vma, address, page_m, ptl);
70828 + else
70829 + unlock_page(page_m);
70830 + }
70831 + } else
70832 + pax_mirror_file_pte(vma, address, page_m, ptl);
70833 +
70834 +out:
70835 + pte_unmap_unlock(pte, ptl);
70836 +}
70837 +#endif
70838 +
70839 /*
70840 * This routine handles present pages, when users try to write
70841 * to a shared page. It is done by copying the page to a new address
70842 @@ -2683,6 +2880,12 @@ gotten:
70843 */
70844 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
70845 if (likely(pte_same(*page_table, orig_pte))) {
70846 +
70847 +#ifdef CONFIG_PAX_SEGMEXEC
70848 + if (pax_find_mirror_vma(vma))
70849 + BUG_ON(!trylock_page(new_page));
70850 +#endif
70851 +
70852 if (old_page) {
70853 if (!PageAnon(old_page)) {
70854 dec_mm_counter_fast(mm, MM_FILEPAGES);
70855 @@ -2734,6 +2937,10 @@ gotten:
70856 page_remove_rmap(old_page);
70857 }
70858
70859 +#ifdef CONFIG_PAX_SEGMEXEC
70860 + pax_mirror_anon_pte(vma, address, new_page, ptl);
70861 +#endif
70862 +
70863 /* Free the old page.. */
70864 new_page = old_page;
70865 ret |= VM_FAULT_WRITE;
70866 @@ -3013,6 +3220,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
70867 swap_free(entry);
70868 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
70869 try_to_free_swap(page);
70870 +
70871 +#ifdef CONFIG_PAX_SEGMEXEC
70872 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
70873 +#endif
70874 +
70875 unlock_page(page);
70876 if (swapcache) {
70877 /*
70878 @@ -3036,6 +3248,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
70879
70880 /* No need to invalidate - it was non-present before */
70881 update_mmu_cache(vma, address, page_table);
70882 +
70883 +#ifdef CONFIG_PAX_SEGMEXEC
70884 + pax_mirror_anon_pte(vma, address, page, ptl);
70885 +#endif
70886 +
70887 unlock:
70888 pte_unmap_unlock(page_table, ptl);
70889 out:
70890 @@ -3055,40 +3272,6 @@ out_release:
70891 }
70892
70893 /*
70894 - * This is like a special single-page "expand_{down|up}wards()",
70895 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
70896 - * doesn't hit another vma.
70897 - */
70898 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
70899 -{
70900 - address &= PAGE_MASK;
70901 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
70902 - struct vm_area_struct *prev = vma->vm_prev;
70903 -
70904 - /*
70905 - * Is there a mapping abutting this one below?
70906 - *
70907 - * That's only ok if it's the same stack mapping
70908 - * that has gotten split..
70909 - */
70910 - if (prev && prev->vm_end == address)
70911 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
70912 -
70913 - expand_downwards(vma, address - PAGE_SIZE);
70914 - }
70915 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
70916 - struct vm_area_struct *next = vma->vm_next;
70917 -
70918 - /* As VM_GROWSDOWN but s/below/above/ */
70919 - if (next && next->vm_start == address + PAGE_SIZE)
70920 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
70921 -
70922 - expand_upwards(vma, address + PAGE_SIZE);
70923 - }
70924 - return 0;
70925 -}
70926 -
70927 -/*
70928 * We enter with non-exclusive mmap_sem (to exclude vma changes,
70929 * but allow concurrent faults), and pte mapped but not yet locked.
70930 * We return with mmap_sem still held, but pte unmapped and unlocked.
70931 @@ -3097,27 +3280,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
70932 unsigned long address, pte_t *page_table, pmd_t *pmd,
70933 unsigned int flags)
70934 {
70935 - struct page *page;
70936 + struct page *page = NULL;
70937 spinlock_t *ptl;
70938 pte_t entry;
70939
70940 - pte_unmap(page_table);
70941 -
70942 - /* Check if we need to add a guard page to the stack */
70943 - if (check_stack_guard_page(vma, address) < 0)
70944 - return VM_FAULT_SIGBUS;
70945 -
70946 - /* Use the zero-page for reads */
70947 if (!(flags & FAULT_FLAG_WRITE)) {
70948 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
70949 vma->vm_page_prot));
70950 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
70951 + ptl = pte_lockptr(mm, pmd);
70952 + spin_lock(ptl);
70953 if (!pte_none(*page_table))
70954 goto unlock;
70955 goto setpte;
70956 }
70957
70958 /* Allocate our own private page. */
70959 + pte_unmap(page_table);
70960 +
70961 if (unlikely(anon_vma_prepare(vma)))
70962 goto oom;
70963 page = alloc_zeroed_user_highpage_movable(vma, address);
70964 @@ -3136,6 +3315,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
70965 if (!pte_none(*page_table))
70966 goto release;
70967
70968 +#ifdef CONFIG_PAX_SEGMEXEC
70969 + if (pax_find_mirror_vma(vma))
70970 + BUG_ON(!trylock_page(page));
70971 +#endif
70972 +
70973 inc_mm_counter_fast(mm, MM_ANONPAGES);
70974 page_add_new_anon_rmap(page, vma, address);
70975 setpte:
70976 @@ -3143,6 +3327,12 @@ setpte:
70977
70978 /* No need to invalidate - it was non-present before */
70979 update_mmu_cache(vma, address, page_table);
70980 +
70981 +#ifdef CONFIG_PAX_SEGMEXEC
70982 + if (page)
70983 + pax_mirror_anon_pte(vma, address, page, ptl);
70984 +#endif
70985 +
70986 unlock:
70987 pte_unmap_unlock(page_table, ptl);
70988 return 0;
70989 @@ -3286,6 +3476,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
70990 */
70991 /* Only go through if we didn't race with anybody else... */
70992 if (likely(pte_same(*page_table, orig_pte))) {
70993 +
70994 +#ifdef CONFIG_PAX_SEGMEXEC
70995 + if (anon && pax_find_mirror_vma(vma))
70996 + BUG_ON(!trylock_page(page));
70997 +#endif
70998 +
70999 flush_icache_page(vma, page);
71000 entry = mk_pte(page, vma->vm_page_prot);
71001 if (flags & FAULT_FLAG_WRITE)
71002 @@ -3305,6 +3501,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
71003
71004 /* no need to invalidate: a not-present page won't be cached */
71005 update_mmu_cache(vma, address, page_table);
71006 +
71007 +#ifdef CONFIG_PAX_SEGMEXEC
71008 + if (anon)
71009 + pax_mirror_anon_pte(vma, address, page, ptl);
71010 + else
71011 + pax_mirror_file_pte(vma, address, page, ptl);
71012 +#endif
71013 +
71014 } else {
71015 if (cow_page)
71016 mem_cgroup_uncharge_page(cow_page);
71017 @@ -3458,6 +3662,12 @@ int handle_pte_fault(struct mm_struct *mm,
71018 if (flags & FAULT_FLAG_WRITE)
71019 flush_tlb_fix_spurious_fault(vma, address);
71020 }
71021 +
71022 +#ifdef CONFIG_PAX_SEGMEXEC
71023 + pax_mirror_pte(vma, address, pte, pmd, ptl);
71024 + return 0;
71025 +#endif
71026 +
71027 unlock:
71028 pte_unmap_unlock(pte, ptl);
71029 return 0;
71030 @@ -3474,6 +3684,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
71031 pmd_t *pmd;
71032 pte_t *pte;
71033
71034 +#ifdef CONFIG_PAX_SEGMEXEC
71035 + struct vm_area_struct *vma_m;
71036 +#endif
71037 +
71038 __set_current_state(TASK_RUNNING);
71039
71040 count_vm_event(PGFAULT);
71041 @@ -3485,6 +3699,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
71042 if (unlikely(is_vm_hugetlb_page(vma)))
71043 return hugetlb_fault(mm, vma, address, flags);
71044
71045 +#ifdef CONFIG_PAX_SEGMEXEC
71046 + vma_m = pax_find_mirror_vma(vma);
71047 + if (vma_m) {
71048 + unsigned long address_m;
71049 + pgd_t *pgd_m;
71050 + pud_t *pud_m;
71051 + pmd_t *pmd_m;
71052 +
71053 + if (vma->vm_start > vma_m->vm_start) {
71054 + address_m = address;
71055 + address -= SEGMEXEC_TASK_SIZE;
71056 + vma = vma_m;
71057 + } else
71058 + address_m = address + SEGMEXEC_TASK_SIZE;
71059 +
71060 + pgd_m = pgd_offset(mm, address_m);
71061 + pud_m = pud_alloc(mm, pgd_m, address_m);
71062 + if (!pud_m)
71063 + return VM_FAULT_OOM;
71064 + pmd_m = pmd_alloc(mm, pud_m, address_m);
71065 + if (!pmd_m)
71066 + return VM_FAULT_OOM;
71067 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
71068 + return VM_FAULT_OOM;
71069 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
71070 + }
71071 +#endif
71072 +
71073 pgd = pgd_offset(mm, address);
71074 pud = pud_alloc(mm, pgd, address);
71075 if (!pud)
71076 @@ -3514,7 +3756,7 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
71077 * run pte_offset_map on the pmd, if an huge pmd could
71078 * materialize from under us from a different thread.
71079 */
71080 - if (unlikely(pmd_none(*pmd)) && __pte_alloc(mm, vma, pmd, address))
71081 + if (unlikely(pmd_none(*pmd) && __pte_alloc(mm, vma, pmd, address)))
71082 return VM_FAULT_OOM;
71083 /* if an huge pmd materialized from under us just retry later */
71084 if (unlikely(pmd_trans_huge(*pmd)))
71085 @@ -3551,6 +3793,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
71086 spin_unlock(&mm->page_table_lock);
71087 return 0;
71088 }
71089 +
71090 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
71091 +{
71092 + pud_t *new = pud_alloc_one(mm, address);
71093 + if (!new)
71094 + return -ENOMEM;
71095 +
71096 + smp_wmb(); /* See comment in __pte_alloc */
71097 +
71098 + spin_lock(&mm->page_table_lock);
71099 + if (pgd_present(*pgd)) /* Another has populated it */
71100 + pud_free(mm, new);
71101 + else
71102 + pgd_populate_kernel(mm, pgd, new);
71103 + spin_unlock(&mm->page_table_lock);
71104 + return 0;
71105 +}
71106 #endif /* __PAGETABLE_PUD_FOLDED */
71107
71108 #ifndef __PAGETABLE_PMD_FOLDED
71109 @@ -3581,6 +3840,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
71110 spin_unlock(&mm->page_table_lock);
71111 return 0;
71112 }
71113 +
71114 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
71115 +{
71116 + pmd_t *new = pmd_alloc_one(mm, address);
71117 + if (!new)
71118 + return -ENOMEM;
71119 +
71120 + smp_wmb(); /* See comment in __pte_alloc */
71121 +
71122 + spin_lock(&mm->page_table_lock);
71123 +#ifndef __ARCH_HAS_4LEVEL_HACK
71124 + if (pud_present(*pud)) /* Another has populated it */
71125 + pmd_free(mm, new);
71126 + else
71127 + pud_populate_kernel(mm, pud, new);
71128 +#else
71129 + if (pgd_present(*pud)) /* Another has populated it */
71130 + pmd_free(mm, new);
71131 + else
71132 + pgd_populate_kernel(mm, pud, new);
71133 +#endif /* __ARCH_HAS_4LEVEL_HACK */
71134 + spin_unlock(&mm->page_table_lock);
71135 + return 0;
71136 +}
71137 #endif /* __PAGETABLE_PMD_FOLDED */
71138
71139 int make_pages_present(unsigned long addr, unsigned long end)
71140 @@ -3618,7 +3901,7 @@ static int __init gate_vma_init(void)
71141 gate_vma.vm_start = FIXADDR_USER_START;
71142 gate_vma.vm_end = FIXADDR_USER_END;
71143 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
71144 - gate_vma.vm_page_prot = __P101;
71145 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
71146 /*
71147 * Make sure the vDSO gets into every core dump.
71148 * Dumping its contents makes post-mortem fully interpretable later
71149 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
71150 index 0a37570..2048346 100644
71151 --- a/mm/mempolicy.c
71152 +++ b/mm/mempolicy.c
71153 @@ -640,6 +640,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
71154 unsigned long vmstart;
71155 unsigned long vmend;
71156
71157 +#ifdef CONFIG_PAX_SEGMEXEC
71158 + struct vm_area_struct *vma_m;
71159 +#endif
71160 +
71161 vma = find_vma(mm, start);
71162 if (!vma || vma->vm_start > start)
71163 return -EFAULT;
71164 @@ -679,6 +683,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
71165 err = policy_vma(vma, new_pol);
71166 if (err)
71167 goto out;
71168 +
71169 +#ifdef CONFIG_PAX_SEGMEXEC
71170 + vma_m = pax_find_mirror_vma(vma);
71171 + if (vma_m) {
71172 + err = policy_vma(vma_m, new_pol);
71173 + if (err)
71174 + goto out;
71175 + }
71176 +#endif
71177 +
71178 }
71179
71180 out:
71181 @@ -1112,6 +1126,17 @@ static long do_mbind(unsigned long start, unsigned long len,
71182
71183 if (end < start)
71184 return -EINVAL;
71185 +
71186 +#ifdef CONFIG_PAX_SEGMEXEC
71187 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
71188 + if (end > SEGMEXEC_TASK_SIZE)
71189 + return -EINVAL;
71190 + } else
71191 +#endif
71192 +
71193 + if (end > TASK_SIZE)
71194 + return -EINVAL;
71195 +
71196 if (end == start)
71197 return 0;
71198
71199 @@ -1330,6 +1355,14 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
71200 if (!mm)
71201 goto out;
71202
71203 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71204 + if (mm != current->mm &&
71205 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
71206 + err = -EPERM;
71207 + goto out;
71208 + }
71209 +#endif
71210 +
71211 /*
71212 * Check if this process has the right to modify the specified
71213 * process. The right exists if the process has administrative
71214 @@ -1339,8 +1372,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
71215 rcu_read_lock();
71216 tcred = __task_cred(task);
71217 if (cred->euid != tcred->suid && cred->euid != tcred->uid &&
71218 - cred->uid != tcred->suid && cred->uid != tcred->uid &&
71219 - !capable(CAP_SYS_NICE)) {
71220 + cred->uid != tcred->suid && !capable(CAP_SYS_NICE)) {
71221 rcu_read_unlock();
71222 err = -EPERM;
71223 goto out;
71224 diff --git a/mm/migrate.c b/mm/migrate.c
71225 index 1503b6b..156c672 100644
71226 --- a/mm/migrate.c
71227 +++ b/mm/migrate.c
71228 @@ -1370,6 +1370,14 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
71229 if (!mm)
71230 return -EINVAL;
71231
71232 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71233 + if (mm != current->mm &&
71234 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
71235 + err = -EPERM;
71236 + goto out;
71237 + }
71238 +#endif
71239 +
71240 /*
71241 * Check if this process has the right to modify the specified
71242 * process. The right exists if the process has administrative
71243 @@ -1379,8 +1387,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
71244 rcu_read_lock();
71245 tcred = __task_cred(task);
71246 if (cred->euid != tcred->suid && cred->euid != tcred->uid &&
71247 - cred->uid != tcred->suid && cred->uid != tcred->uid &&
71248 - !capable(CAP_SYS_NICE)) {
71249 + cred->uid != tcred->suid && !capable(CAP_SYS_NICE)) {
71250 rcu_read_unlock();
71251 err = -EPERM;
71252 goto out;
71253 diff --git a/mm/mlock.c b/mm/mlock.c
71254 index ef726e8..13e0901 100644
71255 --- a/mm/mlock.c
71256 +++ b/mm/mlock.c
71257 @@ -13,6 +13,7 @@
71258 #include <linux/pagemap.h>
71259 #include <linux/mempolicy.h>
71260 #include <linux/syscalls.h>
71261 +#include <linux/security.h>
71262 #include <linux/sched.h>
71263 #include <linux/export.h>
71264 #include <linux/rmap.h>
71265 @@ -385,6 +386,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
71266 return -EINVAL;
71267 if (end == start)
71268 return 0;
71269 + if (end > TASK_SIZE)
71270 + return -EINVAL;
71271 +
71272 vma = find_vma(current->mm, start);
71273 if (!vma || vma->vm_start > start)
71274 return -ENOMEM;
71275 @@ -396,6 +400,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
71276 for (nstart = start ; ; ) {
71277 vm_flags_t newflags;
71278
71279 +#ifdef CONFIG_PAX_SEGMEXEC
71280 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
71281 + break;
71282 +#endif
71283 +
71284 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
71285
71286 newflags = vma->vm_flags | VM_LOCKED;
71287 @@ -501,6 +510,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
71288 lock_limit >>= PAGE_SHIFT;
71289
71290 /* check against resource limits */
71291 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
71292 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
71293 error = do_mlock(start, len, 1);
71294 up_write(&current->mm->mmap_sem);
71295 @@ -524,17 +534,23 @@ SYSCALL_DEFINE2(munlock, unsigned long, start, size_t, len)
71296 static int do_mlockall(int flags)
71297 {
71298 struct vm_area_struct * vma, * prev = NULL;
71299 - unsigned int def_flags = 0;
71300
71301 if (flags & MCL_FUTURE)
71302 - def_flags = VM_LOCKED;
71303 - current->mm->def_flags = def_flags;
71304 + current->mm->def_flags |= VM_LOCKED;
71305 + else
71306 + current->mm->def_flags &= ~VM_LOCKED;
71307 if (flags == MCL_FUTURE)
71308 goto out;
71309
71310 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
71311 vm_flags_t newflags;
71312
71313 +#ifdef CONFIG_PAX_SEGMEXEC
71314 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
71315 + break;
71316 +#endif
71317 +
71318 + BUG_ON(vma->vm_end > TASK_SIZE);
71319 newflags = vma->vm_flags | VM_LOCKED;
71320 if (!(flags & MCL_CURRENT))
71321 newflags &= ~VM_LOCKED;
71322 @@ -567,6 +583,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
71323 lock_limit >>= PAGE_SHIFT;
71324
71325 ret = -ENOMEM;
71326 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
71327 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
71328 capable(CAP_IPC_LOCK))
71329 ret = do_mlockall(flags);
71330 diff --git a/mm/mmap.c b/mm/mmap.c
71331 index da15a79..314aef3 100644
71332 --- a/mm/mmap.c
71333 +++ b/mm/mmap.c
71334 @@ -46,6 +46,16 @@
71335 #define arch_rebalance_pgtables(addr, len) (addr)
71336 #endif
71337
71338 +static inline void verify_mm_writelocked(struct mm_struct *mm)
71339 +{
71340 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
71341 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
71342 + up_read(&mm->mmap_sem);
71343 + BUG();
71344 + }
71345 +#endif
71346 +}
71347 +
71348 static void unmap_region(struct mm_struct *mm,
71349 struct vm_area_struct *vma, struct vm_area_struct *prev,
71350 unsigned long start, unsigned long end);
71351 @@ -71,22 +81,32 @@ static void unmap_region(struct mm_struct *mm,
71352 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
71353 *
71354 */
71355 -pgprot_t protection_map[16] = {
71356 +pgprot_t protection_map[16] __read_only = {
71357 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
71358 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
71359 };
71360
71361 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
71362 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
71363 {
71364 - return __pgprot(pgprot_val(protection_map[vm_flags &
71365 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
71366 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
71367 pgprot_val(arch_vm_get_page_prot(vm_flags)));
71368 +
71369 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
71370 + if (!(__supported_pte_mask & _PAGE_NX) &&
71371 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
71372 + (vm_flags & (VM_READ | VM_WRITE)))
71373 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
71374 +#endif
71375 +
71376 + return prot;
71377 }
71378 EXPORT_SYMBOL(vm_get_page_prot);
71379
71380 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; /* heuristic overcommit */
71381 int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
71382 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
71383 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
71384 /*
71385 * Make sure vm_committed_as in one cacheline and not cacheline shared with
71386 * other variables. It can be updated by several CPUs frequently.
71387 @@ -228,6 +248,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
71388 struct vm_area_struct *next = vma->vm_next;
71389
71390 might_sleep();
71391 + BUG_ON(vma->vm_mirror);
71392 if (vma->vm_ops && vma->vm_ops->close)
71393 vma->vm_ops->close(vma);
71394 if (vma->vm_file) {
71395 @@ -272,6 +293,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
71396 * not page aligned -Ram Gupta
71397 */
71398 rlim = rlimit(RLIMIT_DATA);
71399 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
71400 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
71401 (mm->end_data - mm->start_data) > rlim)
71402 goto out;
71403 @@ -689,6 +711,12 @@ static int
71404 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
71405 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
71406 {
71407 +
71408 +#ifdef CONFIG_PAX_SEGMEXEC
71409 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
71410 + return 0;
71411 +#endif
71412 +
71413 if (is_mergeable_vma(vma, file, vm_flags) &&
71414 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
71415 if (vma->vm_pgoff == vm_pgoff)
71416 @@ -708,6 +736,12 @@ static int
71417 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
71418 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
71419 {
71420 +
71421 +#ifdef CONFIG_PAX_SEGMEXEC
71422 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
71423 + return 0;
71424 +#endif
71425 +
71426 if (is_mergeable_vma(vma, file, vm_flags) &&
71427 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
71428 pgoff_t vm_pglen;
71429 @@ -750,13 +784,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
71430 struct vm_area_struct *vma_merge(struct mm_struct *mm,
71431 struct vm_area_struct *prev, unsigned long addr,
71432 unsigned long end, unsigned long vm_flags,
71433 - struct anon_vma *anon_vma, struct file *file,
71434 + struct anon_vma *anon_vma, struct file *file,
71435 pgoff_t pgoff, struct mempolicy *policy)
71436 {
71437 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
71438 struct vm_area_struct *area, *next;
71439 int err;
71440
71441 +#ifdef CONFIG_PAX_SEGMEXEC
71442 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
71443 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
71444 +
71445 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
71446 +#endif
71447 +
71448 /*
71449 * We later require that vma->vm_flags == vm_flags,
71450 * so this tests vma->vm_flags & VM_SPECIAL, too.
71451 @@ -772,6 +813,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
71452 if (next && next->vm_end == end) /* cases 6, 7, 8 */
71453 next = next->vm_next;
71454
71455 +#ifdef CONFIG_PAX_SEGMEXEC
71456 + if (prev)
71457 + prev_m = pax_find_mirror_vma(prev);
71458 + if (area)
71459 + area_m = pax_find_mirror_vma(area);
71460 + if (next)
71461 + next_m = pax_find_mirror_vma(next);
71462 +#endif
71463 +
71464 /*
71465 * Can it merge with the predecessor?
71466 */
71467 @@ -791,9 +841,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
71468 /* cases 1, 6 */
71469 err = vma_adjust(prev, prev->vm_start,
71470 next->vm_end, prev->vm_pgoff, NULL);
71471 - } else /* cases 2, 5, 7 */
71472 +
71473 +#ifdef CONFIG_PAX_SEGMEXEC
71474 + if (!err && prev_m)
71475 + err = vma_adjust(prev_m, prev_m->vm_start,
71476 + next_m->vm_end, prev_m->vm_pgoff, NULL);
71477 +#endif
71478 +
71479 + } else { /* cases 2, 5, 7 */
71480 err = vma_adjust(prev, prev->vm_start,
71481 end, prev->vm_pgoff, NULL);
71482 +
71483 +#ifdef CONFIG_PAX_SEGMEXEC
71484 + if (!err && prev_m)
71485 + err = vma_adjust(prev_m, prev_m->vm_start,
71486 + end_m, prev_m->vm_pgoff, NULL);
71487 +#endif
71488 +
71489 + }
71490 if (err)
71491 return NULL;
71492 khugepaged_enter_vma_merge(prev);
71493 @@ -807,12 +872,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
71494 mpol_equal(policy, vma_policy(next)) &&
71495 can_vma_merge_before(next, vm_flags,
71496 anon_vma, file, pgoff+pglen)) {
71497 - if (prev && addr < prev->vm_end) /* case 4 */
71498 + if (prev && addr < prev->vm_end) { /* case 4 */
71499 err = vma_adjust(prev, prev->vm_start,
71500 addr, prev->vm_pgoff, NULL);
71501 - else /* cases 3, 8 */
71502 +
71503 +#ifdef CONFIG_PAX_SEGMEXEC
71504 + if (!err && prev_m)
71505 + err = vma_adjust(prev_m, prev_m->vm_start,
71506 + addr_m, prev_m->vm_pgoff, NULL);
71507 +#endif
71508 +
71509 + } else { /* cases 3, 8 */
71510 err = vma_adjust(area, addr, next->vm_end,
71511 next->vm_pgoff - pglen, NULL);
71512 +
71513 +#ifdef CONFIG_PAX_SEGMEXEC
71514 + if (!err && area_m)
71515 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
71516 + next_m->vm_pgoff - pglen, NULL);
71517 +#endif
71518 +
71519 + }
71520 if (err)
71521 return NULL;
71522 khugepaged_enter_vma_merge(area);
71523 @@ -921,14 +1001,11 @@ none:
71524 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
71525 struct file *file, long pages)
71526 {
71527 - const unsigned long stack_flags
71528 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
71529 -
71530 if (file) {
71531 mm->shared_vm += pages;
71532 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
71533 mm->exec_vm += pages;
71534 - } else if (flags & stack_flags)
71535 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
71536 mm->stack_vm += pages;
71537 if (flags & (VM_RESERVED|VM_IO))
71538 mm->reserved_vm += pages;
71539 @@ -955,7 +1032,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
71540 * (the exception is when the underlying filesystem is noexec
71541 * mounted, in which case we dont add PROT_EXEC.)
71542 */
71543 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
71544 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
71545 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
71546 prot |= PROT_EXEC;
71547
71548 @@ -981,7 +1058,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
71549 /* Obtain the address to map to. we verify (or select) it and ensure
71550 * that it represents a valid section of the address space.
71551 */
71552 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
71553 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
71554 if (addr & ~PAGE_MASK)
71555 return addr;
71556
71557 @@ -992,6 +1069,36 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
71558 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
71559 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
71560
71561 +#ifdef CONFIG_PAX_MPROTECT
71562 + if (mm->pax_flags & MF_PAX_MPROTECT) {
71563 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
71564 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
71565 + gr_log_rwxmmap(file);
71566 +
71567 +#ifdef CONFIG_PAX_EMUPLT
71568 + vm_flags &= ~VM_EXEC;
71569 +#else
71570 + return -EPERM;
71571 +#endif
71572 +
71573 + }
71574 +
71575 + if (!(vm_flags & VM_EXEC))
71576 + vm_flags &= ~VM_MAYEXEC;
71577 +#else
71578 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
71579 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
71580 +#endif
71581 + else
71582 + vm_flags &= ~VM_MAYWRITE;
71583 + }
71584 +#endif
71585 +
71586 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
71587 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
71588 + vm_flags &= ~VM_PAGEEXEC;
71589 +#endif
71590 +
71591 if (flags & MAP_LOCKED)
71592 if (!can_do_mlock())
71593 return -EPERM;
71594 @@ -1003,6 +1110,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
71595 locked += mm->locked_vm;
71596 lock_limit = rlimit(RLIMIT_MEMLOCK);
71597 lock_limit >>= PAGE_SHIFT;
71598 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
71599 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
71600 return -EAGAIN;
71601 }
71602 @@ -1073,6 +1181,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
71603 if (error)
71604 return error;
71605
71606 + if (!gr_acl_handle_mmap(file, prot))
71607 + return -EACCES;
71608 +
71609 return mmap_region(file, addr, len, flags, vm_flags, pgoff);
71610 }
71611 EXPORT_SYMBOL(do_mmap_pgoff);
71612 @@ -1153,7 +1264,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
71613 vm_flags_t vm_flags = vma->vm_flags;
71614
71615 /* If it was private or non-writable, the write bit is already clear */
71616 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
71617 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
71618 return 0;
71619
71620 /* The backer wishes to know when pages are first written to? */
71621 @@ -1202,14 +1313,24 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
71622 unsigned long charged = 0;
71623 struct inode *inode = file ? file->f_path.dentry->d_inode : NULL;
71624
71625 +#ifdef CONFIG_PAX_SEGMEXEC
71626 + struct vm_area_struct *vma_m = NULL;
71627 +#endif
71628 +
71629 + /*
71630 + * mm->mmap_sem is required to protect against another thread
71631 + * changing the mappings in case we sleep.
71632 + */
71633 + verify_mm_writelocked(mm);
71634 +
71635 /* Clear old maps */
71636 error = -ENOMEM;
71637 -munmap_back:
71638 vma = find_vma_prepare(mm, addr, &prev, &rb_link, &rb_parent);
71639 if (vma && vma->vm_start < addr + len) {
71640 if (do_munmap(mm, addr, len))
71641 return -ENOMEM;
71642 - goto munmap_back;
71643 + vma = find_vma_prepare(mm, addr, &prev, &rb_link, &rb_parent);
71644 + BUG_ON(vma && vma->vm_start < addr + len);
71645 }
71646
71647 /* Check against address space limit. */
71648 @@ -1258,6 +1379,16 @@ munmap_back:
71649 goto unacct_error;
71650 }
71651
71652 +#ifdef CONFIG_PAX_SEGMEXEC
71653 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
71654 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
71655 + if (!vma_m) {
71656 + error = -ENOMEM;
71657 + goto free_vma;
71658 + }
71659 + }
71660 +#endif
71661 +
71662 vma->vm_mm = mm;
71663 vma->vm_start = addr;
71664 vma->vm_end = addr + len;
71665 @@ -1282,6 +1413,19 @@ munmap_back:
71666 error = file->f_op->mmap(file, vma);
71667 if (error)
71668 goto unmap_and_free_vma;
71669 +
71670 +#ifdef CONFIG_PAX_SEGMEXEC
71671 + if (vma_m && (vm_flags & VM_EXECUTABLE))
71672 + added_exe_file_vma(mm);
71673 +#endif
71674 +
71675 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
71676 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
71677 + vma->vm_flags |= VM_PAGEEXEC;
71678 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
71679 + }
71680 +#endif
71681 +
71682 if (vm_flags & VM_EXECUTABLE)
71683 added_exe_file_vma(mm);
71684
71685 @@ -1319,6 +1463,11 @@ munmap_back:
71686 vma_link(mm, vma, prev, rb_link, rb_parent);
71687 file = vma->vm_file;
71688
71689 +#ifdef CONFIG_PAX_SEGMEXEC
71690 + if (vma_m)
71691 + BUG_ON(pax_mirror_vma(vma_m, vma));
71692 +#endif
71693 +
71694 /* Once vma denies write, undo our temporary denial count */
71695 if (correct_wcount)
71696 atomic_inc(&inode->i_writecount);
71697 @@ -1327,6 +1476,7 @@ out:
71698
71699 mm->total_vm += len >> PAGE_SHIFT;
71700 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
71701 + track_exec_limit(mm, addr, addr + len, vm_flags);
71702 if (vm_flags & VM_LOCKED) {
71703 if (!mlock_vma_pages_range(vma, addr, addr + len))
71704 mm->locked_vm += (len >> PAGE_SHIFT);
71705 @@ -1344,6 +1494,12 @@ unmap_and_free_vma:
71706 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
71707 charged = 0;
71708 free_vma:
71709 +
71710 +#ifdef CONFIG_PAX_SEGMEXEC
71711 + if (vma_m)
71712 + kmem_cache_free(vm_area_cachep, vma_m);
71713 +#endif
71714 +
71715 kmem_cache_free(vm_area_cachep, vma);
71716 unacct_error:
71717 if (charged)
71718 @@ -1351,6 +1507,44 @@ unacct_error:
71719 return error;
71720 }
71721
71722 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len)
71723 +{
71724 + if (!vma) {
71725 +#ifdef CONFIG_STACK_GROWSUP
71726 + if (addr > sysctl_heap_stack_gap)
71727 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
71728 + else
71729 + vma = find_vma(current->mm, 0);
71730 + if (vma && (vma->vm_flags & VM_GROWSUP))
71731 + return false;
71732 +#endif
71733 + return true;
71734 + }
71735 +
71736 + if (addr + len > vma->vm_start)
71737 + return false;
71738 +
71739 + if (vma->vm_flags & VM_GROWSDOWN)
71740 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
71741 +#ifdef CONFIG_STACK_GROWSUP
71742 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
71743 + return addr - vma->vm_prev->vm_end <= sysctl_heap_stack_gap;
71744 +#endif
71745 +
71746 + return true;
71747 +}
71748 +
71749 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len)
71750 +{
71751 + if (vma->vm_start < len)
71752 + return -ENOMEM;
71753 + if (!(vma->vm_flags & VM_GROWSDOWN))
71754 + return vma->vm_start - len;
71755 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
71756 + return vma->vm_start - len - sysctl_heap_stack_gap;
71757 + return -ENOMEM;
71758 +}
71759 +
71760 /* Get an address range which is currently unmapped.
71761 * For shmat() with addr=0.
71762 *
71763 @@ -1377,18 +1571,23 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
71764 if (flags & MAP_FIXED)
71765 return addr;
71766
71767 +#ifdef CONFIG_PAX_RANDMMAP
71768 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
71769 +#endif
71770 +
71771 if (addr) {
71772 addr = PAGE_ALIGN(addr);
71773 - vma = find_vma(mm, addr);
71774 - if (TASK_SIZE - len >= addr &&
71775 - (!vma || addr + len <= vma->vm_start))
71776 - return addr;
71777 + if (TASK_SIZE - len >= addr) {
71778 + vma = find_vma(mm, addr);
71779 + if (check_heap_stack_gap(vma, addr, len))
71780 + return addr;
71781 + }
71782 }
71783 if (len > mm->cached_hole_size) {
71784 - start_addr = addr = mm->free_area_cache;
71785 + start_addr = addr = mm->free_area_cache;
71786 } else {
71787 - start_addr = addr = TASK_UNMAPPED_BASE;
71788 - mm->cached_hole_size = 0;
71789 + start_addr = addr = mm->mmap_base;
71790 + mm->cached_hole_size = 0;
71791 }
71792
71793 full_search:
71794 @@ -1399,34 +1598,40 @@ full_search:
71795 * Start a new search - just in case we missed
71796 * some holes.
71797 */
71798 - if (start_addr != TASK_UNMAPPED_BASE) {
71799 - addr = TASK_UNMAPPED_BASE;
71800 - start_addr = addr;
71801 + if (start_addr != mm->mmap_base) {
71802 + start_addr = addr = mm->mmap_base;
71803 mm->cached_hole_size = 0;
71804 goto full_search;
71805 }
71806 return -ENOMEM;
71807 }
71808 - if (!vma || addr + len <= vma->vm_start) {
71809 - /*
71810 - * Remember the place where we stopped the search:
71811 - */
71812 - mm->free_area_cache = addr + len;
71813 - return addr;
71814 - }
71815 + if (check_heap_stack_gap(vma, addr, len))
71816 + break;
71817 if (addr + mm->cached_hole_size < vma->vm_start)
71818 mm->cached_hole_size = vma->vm_start - addr;
71819 addr = vma->vm_end;
71820 }
71821 +
71822 + /*
71823 + * Remember the place where we stopped the search:
71824 + */
71825 + mm->free_area_cache = addr + len;
71826 + return addr;
71827 }
71828 #endif
71829
71830 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
71831 {
71832 +
71833 +#ifdef CONFIG_PAX_SEGMEXEC
71834 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
71835 + return;
71836 +#endif
71837 +
71838 /*
71839 * Is this a new hole at the lowest possible address?
71840 */
71841 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache) {
71842 + if (addr >= mm->mmap_base && addr < mm->free_area_cache) {
71843 mm->free_area_cache = addr;
71844 mm->cached_hole_size = ~0UL;
71845 }
71846 @@ -1444,7 +1649,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
71847 {
71848 struct vm_area_struct *vma;
71849 struct mm_struct *mm = current->mm;
71850 - unsigned long addr = addr0;
71851 + unsigned long base = mm->mmap_base, addr = addr0;
71852
71853 /* requested length too big for entire address space */
71854 if (len > TASK_SIZE)
71855 @@ -1453,13 +1658,18 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
71856 if (flags & MAP_FIXED)
71857 return addr;
71858
71859 +#ifdef CONFIG_PAX_RANDMMAP
71860 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
71861 +#endif
71862 +
71863 /* requesting a specific address */
71864 if (addr) {
71865 addr = PAGE_ALIGN(addr);
71866 - vma = find_vma(mm, addr);
71867 - if (TASK_SIZE - len >= addr &&
71868 - (!vma || addr + len <= vma->vm_start))
71869 - return addr;
71870 + if (TASK_SIZE - len >= addr) {
71871 + vma = find_vma(mm, addr);
71872 + if (check_heap_stack_gap(vma, addr, len))
71873 + return addr;
71874 + }
71875 }
71876
71877 /* check if free_area_cache is useful for us */
71878 @@ -1474,7 +1684,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
71879 /* make sure it can fit in the remaining address space */
71880 if (addr > len) {
71881 vma = find_vma(mm, addr-len);
71882 - if (!vma || addr <= vma->vm_start)
71883 + if (check_heap_stack_gap(vma, addr - len, len))
71884 /* remember the address as a hint for next time */
71885 return (mm->free_area_cache = addr-len);
71886 }
71887 @@ -1491,7 +1701,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
71888 * return with success:
71889 */
71890 vma = find_vma(mm, addr);
71891 - if (!vma || addr+len <= vma->vm_start)
71892 + if (check_heap_stack_gap(vma, addr, len))
71893 /* remember the address as a hint for next time */
71894 return (mm->free_area_cache = addr);
71895
71896 @@ -1500,8 +1710,8 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
71897 mm->cached_hole_size = vma->vm_start - addr;
71898
71899 /* try just below the current vma->vm_start */
71900 - addr = vma->vm_start-len;
71901 - } while (len < vma->vm_start);
71902 + addr = skip_heap_stack_gap(vma, len);
71903 + } while (!IS_ERR_VALUE(addr));
71904
71905 bottomup:
71906 /*
71907 @@ -1510,13 +1720,21 @@ bottomup:
71908 * can happen with large stack limits and large mmap()
71909 * allocations.
71910 */
71911 + mm->mmap_base = TASK_UNMAPPED_BASE;
71912 +
71913 +#ifdef CONFIG_PAX_RANDMMAP
71914 + if (mm->pax_flags & MF_PAX_RANDMMAP)
71915 + mm->mmap_base += mm->delta_mmap;
71916 +#endif
71917 +
71918 + mm->free_area_cache = mm->mmap_base;
71919 mm->cached_hole_size = ~0UL;
71920 - mm->free_area_cache = TASK_UNMAPPED_BASE;
71921 addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
71922 /*
71923 * Restore the topdown base:
71924 */
71925 - mm->free_area_cache = mm->mmap_base;
71926 + mm->mmap_base = base;
71927 + mm->free_area_cache = base;
71928 mm->cached_hole_size = ~0UL;
71929
71930 return addr;
71931 @@ -1525,6 +1743,12 @@ bottomup:
71932
71933 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
71934 {
71935 +
71936 +#ifdef CONFIG_PAX_SEGMEXEC
71937 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
71938 + return;
71939 +#endif
71940 +
71941 /*
71942 * Is this a new hole at the highest possible address?
71943 */
71944 @@ -1532,8 +1756,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
71945 mm->free_area_cache = addr;
71946
71947 /* dont allow allocations above current base */
71948 - if (mm->free_area_cache > mm->mmap_base)
71949 + if (mm->free_area_cache > mm->mmap_base) {
71950 mm->free_area_cache = mm->mmap_base;
71951 + mm->cached_hole_size = ~0UL;
71952 + }
71953 }
71954
71955 unsigned long
71956 @@ -1629,6 +1855,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
71957 return vma;
71958 }
71959
71960 +#ifdef CONFIG_PAX_SEGMEXEC
71961 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
71962 +{
71963 + struct vm_area_struct *vma_m;
71964 +
71965 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
71966 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
71967 + BUG_ON(vma->vm_mirror);
71968 + return NULL;
71969 + }
71970 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
71971 + vma_m = vma->vm_mirror;
71972 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
71973 + BUG_ON(vma->vm_file != vma_m->vm_file);
71974 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
71975 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
71976 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
71977 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED | VM_RESERVED));
71978 + return vma_m;
71979 +}
71980 +#endif
71981 +
71982 /*
71983 * Verify that the stack growth is acceptable and
71984 * update accounting. This is shared with both the
71985 @@ -1645,6 +1893,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
71986 return -ENOMEM;
71987
71988 /* Stack limit test */
71989 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
71990 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
71991 return -ENOMEM;
71992
71993 @@ -1655,6 +1904,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
71994 locked = mm->locked_vm + grow;
71995 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
71996 limit >>= PAGE_SHIFT;
71997 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
71998 if (locked > limit && !capable(CAP_IPC_LOCK))
71999 return -ENOMEM;
72000 }
72001 @@ -1685,37 +1935,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
72002 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
72003 * vma is the last one with address > vma->vm_end. Have to extend vma.
72004 */
72005 +#ifndef CONFIG_IA64
72006 +static
72007 +#endif
72008 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
72009 {
72010 int error;
72011 + bool locknext;
72012
72013 if (!(vma->vm_flags & VM_GROWSUP))
72014 return -EFAULT;
72015
72016 + /* Also guard against wrapping around to address 0. */
72017 + if (address < PAGE_ALIGN(address+1))
72018 + address = PAGE_ALIGN(address+1);
72019 + else
72020 + return -ENOMEM;
72021 +
72022 /*
72023 * We must make sure the anon_vma is allocated
72024 * so that the anon_vma locking is not a noop.
72025 */
72026 if (unlikely(anon_vma_prepare(vma)))
72027 return -ENOMEM;
72028 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
72029 + if (locknext && anon_vma_prepare(vma->vm_next))
72030 + return -ENOMEM;
72031 vma_lock_anon_vma(vma);
72032 + if (locknext)
72033 + vma_lock_anon_vma(vma->vm_next);
72034
72035 /*
72036 * vma->vm_start/vm_end cannot change under us because the caller
72037 * is required to hold the mmap_sem in read mode. We need the
72038 - * anon_vma lock to serialize against concurrent expand_stacks.
72039 - * Also guard against wrapping around to address 0.
72040 + * anon_vma locks to serialize against concurrent expand_stacks
72041 + * and expand_upwards.
72042 */
72043 - if (address < PAGE_ALIGN(address+4))
72044 - address = PAGE_ALIGN(address+4);
72045 - else {
72046 - vma_unlock_anon_vma(vma);
72047 - return -ENOMEM;
72048 - }
72049 error = 0;
72050
72051 /* Somebody else might have raced and expanded it already */
72052 - if (address > vma->vm_end) {
72053 + 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)
72054 + error = -ENOMEM;
72055 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
72056 unsigned long size, grow;
72057
72058 size = address - vma->vm_start;
72059 @@ -1730,6 +1991,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
72060 }
72061 }
72062 }
72063 + if (locknext)
72064 + vma_unlock_anon_vma(vma->vm_next);
72065 vma_unlock_anon_vma(vma);
72066 khugepaged_enter_vma_merge(vma);
72067 return error;
72068 @@ -1743,6 +2006,8 @@ int expand_downwards(struct vm_area_struct *vma,
72069 unsigned long address)
72070 {
72071 int error;
72072 + bool lockprev = false;
72073 + struct vm_area_struct *prev;
72074
72075 /*
72076 * We must make sure the anon_vma is allocated
72077 @@ -1756,6 +2021,15 @@ int expand_downwards(struct vm_area_struct *vma,
72078 if (error)
72079 return error;
72080
72081 + prev = vma->vm_prev;
72082 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
72083 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
72084 +#endif
72085 + if (lockprev && anon_vma_prepare(prev))
72086 + return -ENOMEM;
72087 + if (lockprev)
72088 + vma_lock_anon_vma(prev);
72089 +
72090 vma_lock_anon_vma(vma);
72091
72092 /*
72093 @@ -1765,9 +2039,17 @@ int expand_downwards(struct vm_area_struct *vma,
72094 */
72095
72096 /* Somebody else might have raced and expanded it already */
72097 - if (address < vma->vm_start) {
72098 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
72099 + error = -ENOMEM;
72100 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
72101 unsigned long size, grow;
72102
72103 +#ifdef CONFIG_PAX_SEGMEXEC
72104 + struct vm_area_struct *vma_m;
72105 +
72106 + vma_m = pax_find_mirror_vma(vma);
72107 +#endif
72108 +
72109 size = vma->vm_end - address;
72110 grow = (vma->vm_start - address) >> PAGE_SHIFT;
72111
72112 @@ -1777,11 +2059,22 @@ int expand_downwards(struct vm_area_struct *vma,
72113 if (!error) {
72114 vma->vm_start = address;
72115 vma->vm_pgoff -= grow;
72116 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
72117 +
72118 +#ifdef CONFIG_PAX_SEGMEXEC
72119 + if (vma_m) {
72120 + vma_m->vm_start -= grow << PAGE_SHIFT;
72121 + vma_m->vm_pgoff -= grow;
72122 + }
72123 +#endif
72124 +
72125 perf_event_mmap(vma);
72126 }
72127 }
72128 }
72129 vma_unlock_anon_vma(vma);
72130 + if (lockprev)
72131 + vma_unlock_anon_vma(prev);
72132 khugepaged_enter_vma_merge(vma);
72133 return error;
72134 }
72135 @@ -1851,6 +2144,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
72136 do {
72137 long nrpages = vma_pages(vma);
72138
72139 +#ifdef CONFIG_PAX_SEGMEXEC
72140 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
72141 + vma = remove_vma(vma);
72142 + continue;
72143 + }
72144 +#endif
72145 +
72146 mm->total_vm -= nrpages;
72147 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
72148 vma = remove_vma(vma);
72149 @@ -1896,6 +2196,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
72150 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
72151 vma->vm_prev = NULL;
72152 do {
72153 +
72154 +#ifdef CONFIG_PAX_SEGMEXEC
72155 + if (vma->vm_mirror) {
72156 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
72157 + vma->vm_mirror->vm_mirror = NULL;
72158 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
72159 + vma->vm_mirror = NULL;
72160 + }
72161 +#endif
72162 +
72163 rb_erase(&vma->vm_rb, &mm->mm_rb);
72164 mm->map_count--;
72165 tail_vma = vma;
72166 @@ -1924,14 +2234,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
72167 struct vm_area_struct *new;
72168 int err = -ENOMEM;
72169
72170 +#ifdef CONFIG_PAX_SEGMEXEC
72171 + struct vm_area_struct *vma_m, *new_m = NULL;
72172 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
72173 +#endif
72174 +
72175 if (is_vm_hugetlb_page(vma) && (addr &
72176 ~(huge_page_mask(hstate_vma(vma)))))
72177 return -EINVAL;
72178
72179 +#ifdef CONFIG_PAX_SEGMEXEC
72180 + vma_m = pax_find_mirror_vma(vma);
72181 +#endif
72182 +
72183 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
72184 if (!new)
72185 goto out_err;
72186
72187 +#ifdef CONFIG_PAX_SEGMEXEC
72188 + if (vma_m) {
72189 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
72190 + if (!new_m) {
72191 + kmem_cache_free(vm_area_cachep, new);
72192 + goto out_err;
72193 + }
72194 + }
72195 +#endif
72196 +
72197 /* most fields are the same, copy all, and then fixup */
72198 *new = *vma;
72199
72200 @@ -1944,6 +2273,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
72201 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
72202 }
72203
72204 +#ifdef CONFIG_PAX_SEGMEXEC
72205 + if (vma_m) {
72206 + *new_m = *vma_m;
72207 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
72208 + new_m->vm_mirror = new;
72209 + new->vm_mirror = new_m;
72210 +
72211 + if (new_below)
72212 + new_m->vm_end = addr_m;
72213 + else {
72214 + new_m->vm_start = addr_m;
72215 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
72216 + }
72217 + }
72218 +#endif
72219 +
72220 pol = mpol_dup(vma_policy(vma));
72221 if (IS_ERR(pol)) {
72222 err = PTR_ERR(pol);
72223 @@ -1969,6 +2314,42 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
72224 else
72225 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
72226
72227 +#ifdef CONFIG_PAX_SEGMEXEC
72228 + if (!err && vma_m) {
72229 + if (anon_vma_clone(new_m, vma_m))
72230 + goto out_free_mpol;
72231 +
72232 + mpol_get(pol);
72233 + vma_set_policy(new_m, pol);
72234 +
72235 + if (new_m->vm_file) {
72236 + get_file(new_m->vm_file);
72237 + if (vma_m->vm_flags & VM_EXECUTABLE)
72238 + added_exe_file_vma(mm);
72239 + }
72240 +
72241 + if (new_m->vm_ops && new_m->vm_ops->open)
72242 + new_m->vm_ops->open(new_m);
72243 +
72244 + if (new_below)
72245 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
72246 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
72247 + else
72248 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
72249 +
72250 + if (err) {
72251 + if (new_m->vm_ops && new_m->vm_ops->close)
72252 + new_m->vm_ops->close(new_m);
72253 + if (new_m->vm_file) {
72254 + if (vma_m->vm_flags & VM_EXECUTABLE)
72255 + removed_exe_file_vma(mm);
72256 + fput(new_m->vm_file);
72257 + }
72258 + mpol_put(pol);
72259 + }
72260 + }
72261 +#endif
72262 +
72263 /* Success. */
72264 if (!err)
72265 return 0;
72266 @@ -1981,10 +2362,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
72267 removed_exe_file_vma(mm);
72268 fput(new->vm_file);
72269 }
72270 - unlink_anon_vmas(new);
72271 out_free_mpol:
72272 mpol_put(pol);
72273 out_free_vma:
72274 +
72275 +#ifdef CONFIG_PAX_SEGMEXEC
72276 + if (new_m) {
72277 + unlink_anon_vmas(new_m);
72278 + kmem_cache_free(vm_area_cachep, new_m);
72279 + }
72280 +#endif
72281 +
72282 + unlink_anon_vmas(new);
72283 kmem_cache_free(vm_area_cachep, new);
72284 out_err:
72285 return err;
72286 @@ -1997,6 +2386,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
72287 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
72288 unsigned long addr, int new_below)
72289 {
72290 +
72291 +#ifdef CONFIG_PAX_SEGMEXEC
72292 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
72293 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
72294 + if (mm->map_count >= sysctl_max_map_count-1)
72295 + return -ENOMEM;
72296 + } else
72297 +#endif
72298 +
72299 if (mm->map_count >= sysctl_max_map_count)
72300 return -ENOMEM;
72301
72302 @@ -2008,11 +2406,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
72303 * work. This now handles partial unmappings.
72304 * Jeremy Fitzhardinge <jeremy@goop.org>
72305 */
72306 +#ifdef CONFIG_PAX_SEGMEXEC
72307 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
72308 {
72309 + int ret = __do_munmap(mm, start, len);
72310 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
72311 + return ret;
72312 +
72313 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
72314 +}
72315 +
72316 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
72317 +#else
72318 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
72319 +#endif
72320 +{
72321 unsigned long end;
72322 struct vm_area_struct *vma, *prev, *last;
72323
72324 + /*
72325 + * mm->mmap_sem is required to protect against another thread
72326 + * changing the mappings in case we sleep.
72327 + */
72328 + verify_mm_writelocked(mm);
72329 +
72330 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
72331 return -EINVAL;
72332
72333 @@ -2087,6 +2504,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
72334 /* Fix up all other VM information */
72335 remove_vma_list(mm, vma);
72336
72337 + track_exec_limit(mm, start, end, 0UL);
72338 +
72339 return 0;
72340 }
72341
72342 @@ -2099,22 +2518,18 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
72343
72344 profile_munmap(addr);
72345
72346 +#ifdef CONFIG_PAX_SEGMEXEC
72347 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
72348 + (len > SEGMEXEC_TASK_SIZE || addr > SEGMEXEC_TASK_SIZE-len))
72349 + return -EINVAL;
72350 +#endif
72351 +
72352 down_write(&mm->mmap_sem);
72353 ret = do_munmap(mm, addr, len);
72354 up_write(&mm->mmap_sem);
72355 return ret;
72356 }
72357
72358 -static inline void verify_mm_writelocked(struct mm_struct *mm)
72359 -{
72360 -#ifdef CONFIG_DEBUG_VM
72361 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
72362 - WARN_ON(1);
72363 - up_read(&mm->mmap_sem);
72364 - }
72365 -#endif
72366 -}
72367 -
72368 /*
72369 * this is really a simplified "do_mmap". it only handles
72370 * anonymous maps. eventually we may be able to do some
72371 @@ -2128,6 +2543,7 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
72372 struct rb_node ** rb_link, * rb_parent;
72373 pgoff_t pgoff = addr >> PAGE_SHIFT;
72374 int error;
72375 + unsigned long charged;
72376
72377 len = PAGE_ALIGN(len);
72378 if (!len)
72379 @@ -2139,16 +2555,30 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
72380
72381 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
72382
72383 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
72384 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
72385 + flags &= ~VM_EXEC;
72386 +
72387 +#ifdef CONFIG_PAX_MPROTECT
72388 + if (mm->pax_flags & MF_PAX_MPROTECT)
72389 + flags &= ~VM_MAYEXEC;
72390 +#endif
72391 +
72392 + }
72393 +#endif
72394 +
72395 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
72396 if (error & ~PAGE_MASK)
72397 return error;
72398
72399 + charged = len >> PAGE_SHIFT;
72400 +
72401 /*
72402 * mlock MCL_FUTURE?
72403 */
72404 if (mm->def_flags & VM_LOCKED) {
72405 unsigned long locked, lock_limit;
72406 - locked = len >> PAGE_SHIFT;
72407 + locked = charged;
72408 locked += mm->locked_vm;
72409 lock_limit = rlimit(RLIMIT_MEMLOCK);
72410 lock_limit >>= PAGE_SHIFT;
72411 @@ -2165,22 +2595,22 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
72412 /*
72413 * Clear old maps. this also does some error checking for us
72414 */
72415 - munmap_back:
72416 vma = find_vma_prepare(mm, addr, &prev, &rb_link, &rb_parent);
72417 if (vma && vma->vm_start < addr + len) {
72418 if (do_munmap(mm, addr, len))
72419 return -ENOMEM;
72420 - goto munmap_back;
72421 + vma = find_vma_prepare(mm, addr, &prev, &rb_link, &rb_parent);
72422 + BUG_ON(vma && vma->vm_start < addr + len);
72423 }
72424
72425 /* Check against address space limits *after* clearing old maps... */
72426 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
72427 + if (!may_expand_vm(mm, charged))
72428 return -ENOMEM;
72429
72430 if (mm->map_count > sysctl_max_map_count)
72431 return -ENOMEM;
72432
72433 - if (security_vm_enough_memory(len >> PAGE_SHIFT))
72434 + if (security_vm_enough_memory(charged))
72435 return -ENOMEM;
72436
72437 /* Can we just expand an old private anonymous mapping? */
72438 @@ -2194,7 +2624,7 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
72439 */
72440 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
72441 if (!vma) {
72442 - vm_unacct_memory(len >> PAGE_SHIFT);
72443 + vm_unacct_memory(charged);
72444 return -ENOMEM;
72445 }
72446
72447 @@ -2208,11 +2638,12 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
72448 vma_link(mm, vma, prev, rb_link, rb_parent);
72449 out:
72450 perf_event_mmap(vma);
72451 - mm->total_vm += len >> PAGE_SHIFT;
72452 + mm->total_vm += charged;
72453 if (flags & VM_LOCKED) {
72454 if (!mlock_vma_pages_range(vma, addr, addr + len))
72455 - mm->locked_vm += (len >> PAGE_SHIFT);
72456 + mm->locked_vm += charged;
72457 }
72458 + track_exec_limit(mm, addr, addr + len, flags);
72459 return addr;
72460 }
72461
72462 @@ -2259,8 +2690,10 @@ void exit_mmap(struct mm_struct *mm)
72463 * Walk the list again, actually closing and freeing it,
72464 * with preemption enabled, without holding any MM locks.
72465 */
72466 - while (vma)
72467 + while (vma) {
72468 + vma->vm_mirror = NULL;
72469 vma = remove_vma(vma);
72470 + }
72471
72472 BUG_ON(mm->nr_ptes > (FIRST_USER_ADDRESS+PMD_SIZE-1)>>PMD_SHIFT);
72473 }
72474 @@ -2274,6 +2707,13 @@ int insert_vm_struct(struct mm_struct * mm, struct vm_area_struct * vma)
72475 struct vm_area_struct * __vma, * prev;
72476 struct rb_node ** rb_link, * rb_parent;
72477
72478 +#ifdef CONFIG_PAX_SEGMEXEC
72479 + struct vm_area_struct *vma_m = NULL;
72480 +#endif
72481 +
72482 + if (security_file_mmap(NULL, 0, 0, 0, vma->vm_start, 1))
72483 + return -EPERM;
72484 +
72485 /*
72486 * The vm_pgoff of a purely anonymous vma should be irrelevant
72487 * until its first write fault, when page's anon_vma and index
72488 @@ -2296,7 +2736,22 @@ int insert_vm_struct(struct mm_struct * mm, struct vm_area_struct * vma)
72489 if ((vma->vm_flags & VM_ACCOUNT) &&
72490 security_vm_enough_memory_mm(mm, vma_pages(vma)))
72491 return -ENOMEM;
72492 +
72493 +#ifdef CONFIG_PAX_SEGMEXEC
72494 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
72495 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
72496 + if (!vma_m)
72497 + return -ENOMEM;
72498 + }
72499 +#endif
72500 +
72501 vma_link(mm, vma, prev, rb_link, rb_parent);
72502 +
72503 +#ifdef CONFIG_PAX_SEGMEXEC
72504 + if (vma_m)
72505 + BUG_ON(pax_mirror_vma(vma_m, vma));
72506 +#endif
72507 +
72508 return 0;
72509 }
72510
72511 @@ -2315,6 +2770,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
72512 struct mempolicy *pol;
72513 bool faulted_in_anon_vma = true;
72514
72515 + BUG_ON(vma->vm_mirror);
72516 +
72517 /*
72518 * If anonymous vma has not yet been faulted, update new pgoff
72519 * to match new location, to increase its chance of merging.
72520 @@ -2382,6 +2839,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
72521 return NULL;
72522 }
72523
72524 +#ifdef CONFIG_PAX_SEGMEXEC
72525 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
72526 +{
72527 + struct vm_area_struct *prev_m;
72528 + struct rb_node **rb_link_m, *rb_parent_m;
72529 + struct mempolicy *pol_m;
72530 +
72531 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
72532 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
72533 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
72534 + *vma_m = *vma;
72535 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
72536 + if (anon_vma_clone(vma_m, vma))
72537 + return -ENOMEM;
72538 + pol_m = vma_policy(vma_m);
72539 + mpol_get(pol_m);
72540 + vma_set_policy(vma_m, pol_m);
72541 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
72542 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
72543 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
72544 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
72545 + if (vma_m->vm_file)
72546 + get_file(vma_m->vm_file);
72547 + if (vma_m->vm_ops && vma_m->vm_ops->open)
72548 + vma_m->vm_ops->open(vma_m);
72549 + find_vma_prepare(vma->vm_mm, vma_m->vm_start, &prev_m, &rb_link_m, &rb_parent_m);
72550 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
72551 + vma_m->vm_mirror = vma;
72552 + vma->vm_mirror = vma_m;
72553 + return 0;
72554 +}
72555 +#endif
72556 +
72557 /*
72558 * Return true if the calling process may expand its vm space by the passed
72559 * number of pages
72560 @@ -2393,6 +2883,12 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
72561
72562 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
72563
72564 +#ifdef CONFIG_PAX_RANDMMAP
72565 + if (mm->pax_flags & MF_PAX_RANDMMAP)
72566 + cur -= mm->brk_gap;
72567 +#endif
72568 +
72569 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
72570 if (cur + npages > lim)
72571 return 0;
72572 return 1;
72573 @@ -2463,6 +2959,22 @@ int install_special_mapping(struct mm_struct *mm,
72574 vma->vm_start = addr;
72575 vma->vm_end = addr + len;
72576
72577 +#ifdef CONFIG_PAX_MPROTECT
72578 + if (mm->pax_flags & MF_PAX_MPROTECT) {
72579 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
72580 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
72581 + return -EPERM;
72582 + if (!(vm_flags & VM_EXEC))
72583 + vm_flags &= ~VM_MAYEXEC;
72584 +#else
72585 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
72586 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
72587 +#endif
72588 + else
72589 + vm_flags &= ~VM_MAYWRITE;
72590 + }
72591 +#endif
72592 +
72593 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
72594 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
72595
72596 diff --git a/mm/mprotect.c b/mm/mprotect.c
72597 index f437d05..e3763f6 100644
72598 --- a/mm/mprotect.c
72599 +++ b/mm/mprotect.c
72600 @@ -23,10 +23,16 @@
72601 #include <linux/mmu_notifier.h>
72602 #include <linux/migrate.h>
72603 #include <linux/perf_event.h>
72604 +
72605 +#ifdef CONFIG_PAX_MPROTECT
72606 +#include <linux/elf.h>
72607 +#endif
72608 +
72609 #include <asm/uaccess.h>
72610 #include <asm/pgtable.h>
72611 #include <asm/cacheflush.h>
72612 #include <asm/tlbflush.h>
72613 +#include <asm/mmu_context.h>
72614
72615 #ifndef pgprot_modify
72616 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
72617 @@ -141,6 +147,48 @@ static void change_protection(struct vm_area_struct *vma,
72618 flush_tlb_range(vma, start, end);
72619 }
72620
72621 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
72622 +/* called while holding the mmap semaphor for writing except stack expansion */
72623 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
72624 +{
72625 + unsigned long oldlimit, newlimit = 0UL;
72626 +
72627 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
72628 + return;
72629 +
72630 + spin_lock(&mm->page_table_lock);
72631 + oldlimit = mm->context.user_cs_limit;
72632 + if ((prot & VM_EXEC) && oldlimit < end)
72633 + /* USER_CS limit moved up */
72634 + newlimit = end;
72635 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
72636 + /* USER_CS limit moved down */
72637 + newlimit = start;
72638 +
72639 + if (newlimit) {
72640 + mm->context.user_cs_limit = newlimit;
72641 +
72642 +#ifdef CONFIG_SMP
72643 + wmb();
72644 + cpus_clear(mm->context.cpu_user_cs_mask);
72645 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
72646 +#endif
72647 +
72648 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
72649 + }
72650 + spin_unlock(&mm->page_table_lock);
72651 + if (newlimit == end) {
72652 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
72653 +
72654 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
72655 + if (is_vm_hugetlb_page(vma))
72656 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
72657 + else
72658 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma));
72659 + }
72660 +}
72661 +#endif
72662 +
72663 int
72664 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
72665 unsigned long start, unsigned long end, unsigned long newflags)
72666 @@ -153,11 +201,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
72667 int error;
72668 int dirty_accountable = 0;
72669
72670 +#ifdef CONFIG_PAX_SEGMEXEC
72671 + struct vm_area_struct *vma_m = NULL;
72672 + unsigned long start_m, end_m;
72673 +
72674 + start_m = start + SEGMEXEC_TASK_SIZE;
72675 + end_m = end + SEGMEXEC_TASK_SIZE;
72676 +#endif
72677 +
72678 if (newflags == oldflags) {
72679 *pprev = vma;
72680 return 0;
72681 }
72682
72683 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
72684 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
72685 +
72686 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
72687 + return -ENOMEM;
72688 +
72689 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
72690 + return -ENOMEM;
72691 + }
72692 +
72693 /*
72694 * If we make a private mapping writable we increase our commit;
72695 * but (without finer accounting) cannot reduce our commit if we
72696 @@ -174,6 +240,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
72697 }
72698 }
72699
72700 +#ifdef CONFIG_PAX_SEGMEXEC
72701 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
72702 + if (start != vma->vm_start) {
72703 + error = split_vma(mm, vma, start, 1);
72704 + if (error)
72705 + goto fail;
72706 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
72707 + *pprev = (*pprev)->vm_next;
72708 + }
72709 +
72710 + if (end != vma->vm_end) {
72711 + error = split_vma(mm, vma, end, 0);
72712 + if (error)
72713 + goto fail;
72714 + }
72715 +
72716 + if (pax_find_mirror_vma(vma)) {
72717 + error = __do_munmap(mm, start_m, end_m - start_m);
72718 + if (error)
72719 + goto fail;
72720 + } else {
72721 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
72722 + if (!vma_m) {
72723 + error = -ENOMEM;
72724 + goto fail;
72725 + }
72726 + vma->vm_flags = newflags;
72727 + error = pax_mirror_vma(vma_m, vma);
72728 + if (error) {
72729 + vma->vm_flags = oldflags;
72730 + goto fail;
72731 + }
72732 + }
72733 + }
72734 +#endif
72735 +
72736 /*
72737 * First try to merge with previous and/or next vma.
72738 */
72739 @@ -204,9 +306,21 @@ success:
72740 * vm_flags and vm_page_prot are protected by the mmap_sem
72741 * held in write mode.
72742 */
72743 +
72744 +#ifdef CONFIG_PAX_SEGMEXEC
72745 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
72746 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
72747 +#endif
72748 +
72749 vma->vm_flags = newflags;
72750 +
72751 +#ifdef CONFIG_PAX_MPROTECT
72752 + if (mm->binfmt && mm->binfmt->handle_mprotect)
72753 + mm->binfmt->handle_mprotect(vma, newflags);
72754 +#endif
72755 +
72756 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
72757 - vm_get_page_prot(newflags));
72758 + vm_get_page_prot(vma->vm_flags));
72759
72760 if (vma_wants_writenotify(vma)) {
72761 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
72762 @@ -248,6 +362,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
72763 end = start + len;
72764 if (end <= start)
72765 return -ENOMEM;
72766 +
72767 +#ifdef CONFIG_PAX_SEGMEXEC
72768 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
72769 + if (end > SEGMEXEC_TASK_SIZE)
72770 + return -EINVAL;
72771 + } else
72772 +#endif
72773 +
72774 + if (end > TASK_SIZE)
72775 + return -EINVAL;
72776 +
72777 if (!arch_validate_prot(prot))
72778 return -EINVAL;
72779
72780 @@ -255,7 +380,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
72781 /*
72782 * Does the application expect PROT_READ to imply PROT_EXEC:
72783 */
72784 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
72785 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
72786 prot |= PROT_EXEC;
72787
72788 vm_flags = calc_vm_prot_bits(prot);
72789 @@ -288,6 +413,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
72790 if (start > vma->vm_start)
72791 prev = vma;
72792
72793 +#ifdef CONFIG_PAX_MPROTECT
72794 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
72795 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
72796 +#endif
72797 +
72798 for (nstart = start ; ; ) {
72799 unsigned long newflags;
72800
72801 @@ -297,6 +427,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
72802
72803 /* newflags >> 4 shift VM_MAY% in place of VM_% */
72804 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
72805 + if (prot & (PROT_WRITE | PROT_EXEC))
72806 + gr_log_rwxmprotect(vma->vm_file);
72807 +
72808 + error = -EACCES;
72809 + goto out;
72810 + }
72811 +
72812 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
72813 error = -EACCES;
72814 goto out;
72815 }
72816 @@ -311,6 +449,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
72817 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
72818 if (error)
72819 goto out;
72820 +
72821 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
72822 +
72823 nstart = tmp;
72824
72825 if (nstart < prev->vm_end)
72826 diff --git a/mm/mremap.c b/mm/mremap.c
72827 index 87bb839..c3bfadb 100644
72828 --- a/mm/mremap.c
72829 +++ b/mm/mremap.c
72830 @@ -106,6 +106,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
72831 continue;
72832 pte = ptep_get_and_clear(mm, old_addr, old_pte);
72833 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
72834 +
72835 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
72836 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
72837 + pte = pte_exprotect(pte);
72838 +#endif
72839 +
72840 set_pte_at(mm, new_addr, new_pte, pte);
72841 }
72842
72843 @@ -299,6 +305,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
72844 if (is_vm_hugetlb_page(vma))
72845 goto Einval;
72846
72847 +#ifdef CONFIG_PAX_SEGMEXEC
72848 + if (pax_find_mirror_vma(vma))
72849 + goto Einval;
72850 +#endif
72851 +
72852 /* We can't remap across vm area boundaries */
72853 if (old_len > vma->vm_end - addr)
72854 goto Efault;
72855 @@ -355,20 +366,25 @@ static unsigned long mremap_to(unsigned long addr,
72856 unsigned long ret = -EINVAL;
72857 unsigned long charged = 0;
72858 unsigned long map_flags;
72859 + unsigned long pax_task_size = TASK_SIZE;
72860
72861 if (new_addr & ~PAGE_MASK)
72862 goto out;
72863
72864 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
72865 +#ifdef CONFIG_PAX_SEGMEXEC
72866 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
72867 + pax_task_size = SEGMEXEC_TASK_SIZE;
72868 +#endif
72869 +
72870 + pax_task_size -= PAGE_SIZE;
72871 +
72872 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
72873 goto out;
72874
72875 /* Check if the location we're moving into overlaps the
72876 * old location at all, and fail if it does.
72877 */
72878 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
72879 - goto out;
72880 -
72881 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
72882 + if (addr + old_len > new_addr && new_addr + new_len > addr)
72883 goto out;
72884
72885 ret = security_file_mmap(NULL, 0, 0, 0, new_addr, 1);
72886 @@ -440,6 +456,7 @@ unsigned long do_mremap(unsigned long addr,
72887 struct vm_area_struct *vma;
72888 unsigned long ret = -EINVAL;
72889 unsigned long charged = 0;
72890 + unsigned long pax_task_size = TASK_SIZE;
72891
72892 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
72893 goto out;
72894 @@ -458,6 +475,17 @@ unsigned long do_mremap(unsigned long addr,
72895 if (!new_len)
72896 goto out;
72897
72898 +#ifdef CONFIG_PAX_SEGMEXEC
72899 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
72900 + pax_task_size = SEGMEXEC_TASK_SIZE;
72901 +#endif
72902 +
72903 + pax_task_size -= PAGE_SIZE;
72904 +
72905 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
72906 + old_len > pax_task_size || addr > pax_task_size-old_len)
72907 + goto out;
72908 +
72909 if (flags & MREMAP_FIXED) {
72910 if (flags & MREMAP_MAYMOVE)
72911 ret = mremap_to(addr, old_len, new_addr, new_len);
72912 @@ -507,6 +535,7 @@ unsigned long do_mremap(unsigned long addr,
72913 addr + new_len);
72914 }
72915 ret = addr;
72916 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
72917 goto out;
72918 }
72919 }
72920 @@ -533,7 +562,13 @@ unsigned long do_mremap(unsigned long addr,
72921 ret = security_file_mmap(NULL, 0, 0, 0, new_addr, 1);
72922 if (ret)
72923 goto out;
72924 +
72925 + map_flags = vma->vm_flags;
72926 ret = move_vma(vma, addr, old_len, new_len, new_addr);
72927 + if (!(ret & ~PAGE_MASK)) {
72928 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
72929 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
72930 + }
72931 }
72932 out:
72933 if (ret & ~PAGE_MASK)
72934 diff --git a/mm/nommu.c b/mm/nommu.c
72935 index f59e170..34e2a2b 100644
72936 --- a/mm/nommu.c
72937 +++ b/mm/nommu.c
72938 @@ -62,7 +62,6 @@ int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
72939 int sysctl_overcommit_ratio = 50; /* default is 50% */
72940 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
72941 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
72942 -int heap_stack_gap = 0;
72943
72944 atomic_long_t mmap_pages_allocated;
72945
72946 @@ -827,15 +826,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
72947 EXPORT_SYMBOL(find_vma);
72948
72949 /*
72950 - * find a VMA
72951 - * - we don't extend stack VMAs under NOMMU conditions
72952 - */
72953 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
72954 -{
72955 - return find_vma(mm, addr);
72956 -}
72957 -
72958 -/*
72959 * expand a stack to a given address
72960 * - not supported under NOMMU conditions
72961 */
72962 @@ -1555,6 +1545,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
72963
72964 /* most fields are the same, copy all, and then fixup */
72965 *new = *vma;
72966 + INIT_LIST_HEAD(&new->anon_vma_chain);
72967 *region = *vma->vm_region;
72968 new->vm_region = region;
72969
72970 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
72971 index a13ded1..b949d15 100644
72972 --- a/mm/page_alloc.c
72973 +++ b/mm/page_alloc.c
72974 @@ -335,7 +335,7 @@ out:
72975 * This usage means that zero-order pages may not be compound.
72976 */
72977
72978 -static void free_compound_page(struct page *page)
72979 +void free_compound_page(struct page *page)
72980 {
72981 __free_pages_ok(page, compound_order(page));
72982 }
72983 @@ -692,6 +692,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
72984 int i;
72985 int bad = 0;
72986
72987 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
72988 + unsigned long index = 1UL << order;
72989 +#endif
72990 +
72991 trace_mm_page_free(page, order);
72992 kmemcheck_free_shadow(page, order);
72993
72994 @@ -707,6 +711,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
72995 debug_check_no_obj_freed(page_address(page),
72996 PAGE_SIZE << order);
72997 }
72998 +
72999 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
73000 + for (; index; --index)
73001 + sanitize_highpage(page + index - 1);
73002 +#endif
73003 +
73004 arch_free_page(page, order);
73005 kernel_map_pages(page, 1 << order, 0);
73006
73007 @@ -830,8 +840,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
73008 arch_alloc_page(page, order);
73009 kernel_map_pages(page, 1 << order, 1);
73010
73011 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
73012 if (gfp_flags & __GFP_ZERO)
73013 prep_zero_page(page, order, gfp_flags);
73014 +#endif
73015
73016 if (order && (gfp_flags & __GFP_COMP))
73017 prep_compound_page(page, order);
73018 @@ -3468,7 +3480,13 @@ static int pageblock_is_reserved(unsigned long start_pfn, unsigned long end_pfn)
73019 unsigned long pfn;
73020
73021 for (pfn = start_pfn; pfn < end_pfn; pfn++) {
73022 +#ifdef CONFIG_X86_32
73023 + /* boot failures in VMware 8 on 32bit vanilla since
73024 + this change */
73025 + if (!pfn_valid(pfn) || PageReserved(pfn_to_page(pfn)))
73026 +#else
73027 if (!pfn_valid_within(pfn) || PageReserved(pfn_to_page(pfn)))
73028 +#endif
73029 return 1;
73030 }
73031 return 0;
73032 diff --git a/mm/percpu.c b/mm/percpu.c
73033 index 317de23..1ba7776 100644
73034 --- a/mm/percpu.c
73035 +++ b/mm/percpu.c
73036 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
73037 static unsigned int pcpu_high_unit_cpu __read_mostly;
73038
73039 /* the address of the first chunk which starts with the kernel static area */
73040 -void *pcpu_base_addr __read_mostly;
73041 +void *pcpu_base_addr __read_only;
73042 EXPORT_SYMBOL_GPL(pcpu_base_addr);
73043
73044 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
73045 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
73046 index c20ff48..137702a 100644
73047 --- a/mm/process_vm_access.c
73048 +++ b/mm/process_vm_access.c
73049 @@ -13,6 +13,7 @@
73050 #include <linux/uio.h>
73051 #include <linux/sched.h>
73052 #include <linux/highmem.h>
73053 +#include <linux/security.h>
73054 #include <linux/ptrace.h>
73055 #include <linux/slab.h>
73056 #include <linux/syscalls.h>
73057 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
73058 size_t iov_l_curr_offset = 0;
73059 ssize_t iov_len;
73060
73061 + return -ENOSYS; // PaX: until properly audited
73062 +
73063 /*
73064 * Work out how many pages of struct pages we're going to need
73065 * when eventually calling get_user_pages
73066 */
73067 for (i = 0; i < riovcnt; i++) {
73068 iov_len = rvec[i].iov_len;
73069 - if (iov_len > 0) {
73070 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
73071 - + iov_len)
73072 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
73073 - / PAGE_SIZE + 1;
73074 - nr_pages = max(nr_pages, nr_pages_iov);
73075 - }
73076 + if (iov_len <= 0)
73077 + continue;
73078 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
73079 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
73080 + nr_pages = max(nr_pages, nr_pages_iov);
73081 }
73082
73083 if (nr_pages == 0)
73084 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
73085 goto free_proc_pages;
73086 }
73087
73088 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
73089 + rc = -EPERM;
73090 + goto put_task_struct;
73091 + }
73092 +
73093 mm = mm_access(task, PTRACE_MODE_ATTACH);
73094 if (!mm || IS_ERR(mm)) {
73095 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
73096 diff --git a/mm/rmap.c b/mm/rmap.c
73097 index c8454e0..b04f3a2 100644
73098 --- a/mm/rmap.c
73099 +++ b/mm/rmap.c
73100 @@ -152,6 +152,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
73101 struct anon_vma *anon_vma = vma->anon_vma;
73102 struct anon_vma_chain *avc;
73103
73104 +#ifdef CONFIG_PAX_SEGMEXEC
73105 + struct anon_vma_chain *avc_m = NULL;
73106 +#endif
73107 +
73108 might_sleep();
73109 if (unlikely(!anon_vma)) {
73110 struct mm_struct *mm = vma->vm_mm;
73111 @@ -161,6 +165,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
73112 if (!avc)
73113 goto out_enomem;
73114
73115 +#ifdef CONFIG_PAX_SEGMEXEC
73116 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
73117 + if (!avc_m)
73118 + goto out_enomem_free_avc;
73119 +#endif
73120 +
73121 anon_vma = find_mergeable_anon_vma(vma);
73122 allocated = NULL;
73123 if (!anon_vma) {
73124 @@ -174,6 +184,21 @@ int anon_vma_prepare(struct vm_area_struct *vma)
73125 /* page_table_lock to protect against threads */
73126 spin_lock(&mm->page_table_lock);
73127 if (likely(!vma->anon_vma)) {
73128 +
73129 +#ifdef CONFIG_PAX_SEGMEXEC
73130 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
73131 +
73132 + if (vma_m) {
73133 + BUG_ON(vma_m->anon_vma);
73134 + vma_m->anon_vma = anon_vma;
73135 + avc_m->anon_vma = anon_vma;
73136 + avc_m->vma = vma;
73137 + list_add(&avc_m->same_vma, &vma_m->anon_vma_chain);
73138 + list_add(&avc_m->same_anon_vma, &anon_vma->head);
73139 + avc_m = NULL;
73140 + }
73141 +#endif
73142 +
73143 vma->anon_vma = anon_vma;
73144 avc->anon_vma = anon_vma;
73145 avc->vma = vma;
73146 @@ -187,12 +212,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
73147
73148 if (unlikely(allocated))
73149 put_anon_vma(allocated);
73150 +
73151 +#ifdef CONFIG_PAX_SEGMEXEC
73152 + if (unlikely(avc_m))
73153 + anon_vma_chain_free(avc_m);
73154 +#endif
73155 +
73156 if (unlikely(avc))
73157 anon_vma_chain_free(avc);
73158 }
73159 return 0;
73160
73161 out_enomem_free_avc:
73162 +
73163 +#ifdef CONFIG_PAX_SEGMEXEC
73164 + if (avc_m)
73165 + anon_vma_chain_free(avc_m);
73166 +#endif
73167 +
73168 anon_vma_chain_free(avc);
73169 out_enomem:
73170 return -ENOMEM;
73171 @@ -243,7 +280,7 @@ static void anon_vma_chain_link(struct vm_area_struct *vma,
73172 * Attach the anon_vmas from src to dst.
73173 * Returns 0 on success, -ENOMEM on failure.
73174 */
73175 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
73176 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
73177 {
73178 struct anon_vma_chain *avc, *pavc;
73179 struct anon_vma *root = NULL;
73180 @@ -321,7 +358,7 @@ void anon_vma_moveto_tail(struct vm_area_struct *dst)
73181 * the corresponding VMA in the parent process is attached to.
73182 * Returns 0 on success, non-zero on failure.
73183 */
73184 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
73185 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
73186 {
73187 struct anon_vma_chain *avc;
73188 struct anon_vma *anon_vma;
73189 diff --git a/mm/shmem.c b/mm/shmem.c
73190 index 269d049..a9d2b50 100644
73191 --- a/mm/shmem.c
73192 +++ b/mm/shmem.c
73193 @@ -31,7 +31,7 @@
73194 #include <linux/export.h>
73195 #include <linux/swap.h>
73196
73197 -static struct vfsmount *shm_mnt;
73198 +struct vfsmount *shm_mnt;
73199
73200 #ifdef CONFIG_SHMEM
73201 /*
73202 @@ -74,7 +74,7 @@ static struct vfsmount *shm_mnt;
73203 #define BOGO_DIRENT_SIZE 20
73204
73205 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
73206 -#define SHORT_SYMLINK_LEN 128
73207 +#define SHORT_SYMLINK_LEN 64
73208
73209 struct shmem_xattr {
73210 struct list_head list; /* anchored by shmem_inode_info->xattr_list */
73211 @@ -2180,8 +2180,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
73212 int err = -ENOMEM;
73213
73214 /* Round up to L1_CACHE_BYTES to resist false sharing */
73215 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
73216 - L1_CACHE_BYTES), GFP_KERNEL);
73217 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
73218 if (!sbinfo)
73219 return -ENOMEM;
73220
73221 diff --git a/mm/slab.c b/mm/slab.c
73222 index f0bd785..348b96a 100644
73223 --- a/mm/slab.c
73224 +++ b/mm/slab.c
73225 @@ -153,7 +153,7 @@
73226
73227 /* Legal flag mask for kmem_cache_create(). */
73228 #if DEBUG
73229 -# define CREATE_MASK (SLAB_RED_ZONE | \
73230 +# define CREATE_MASK (SLAB_USERCOPY | SLAB_RED_ZONE | \
73231 SLAB_POISON | SLAB_HWCACHE_ALIGN | \
73232 SLAB_CACHE_DMA | \
73233 SLAB_STORE_USER | \
73234 @@ -161,7 +161,7 @@
73235 SLAB_DESTROY_BY_RCU | SLAB_MEM_SPREAD | \
73236 SLAB_DEBUG_OBJECTS | SLAB_NOLEAKTRACE | SLAB_NOTRACK)
73237 #else
73238 -# define CREATE_MASK (SLAB_HWCACHE_ALIGN | \
73239 +# define CREATE_MASK (SLAB_USERCOPY | SLAB_HWCACHE_ALIGN | \
73240 SLAB_CACHE_DMA | \
73241 SLAB_RECLAIM_ACCOUNT | SLAB_PANIC | \
73242 SLAB_DESTROY_BY_RCU | SLAB_MEM_SPREAD | \
73243 @@ -290,7 +290,7 @@ struct kmem_list3 {
73244 * Need this for bootstrapping a per node allocator.
73245 */
73246 #define NUM_INIT_LISTS (3 * MAX_NUMNODES)
73247 -static struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS];
73248 +static struct kmem_list3 initkmem_list3[NUM_INIT_LISTS];
73249 #define CACHE_CACHE 0
73250 #define SIZE_AC MAX_NUMNODES
73251 #define SIZE_L3 (2 * MAX_NUMNODES)
73252 @@ -391,10 +391,10 @@ static void kmem_list3_init(struct kmem_list3 *parent)
73253 if ((x)->max_freeable < i) \
73254 (x)->max_freeable = i; \
73255 } while (0)
73256 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
73257 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
73258 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
73259 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
73260 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
73261 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
73262 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
73263 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
73264 #else
73265 #define STATS_INC_ACTIVE(x) do { } while (0)
73266 #define STATS_DEC_ACTIVE(x) do { } while (0)
73267 @@ -542,7 +542,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
73268 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
73269 */
73270 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
73271 - const struct slab *slab, void *obj)
73272 + const struct slab *slab, const void *obj)
73273 {
73274 u32 offset = (obj - slab->s_mem);
73275 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
73276 @@ -568,7 +568,7 @@ struct cache_names {
73277 static struct cache_names __initdata cache_names[] = {
73278 #define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)" },
73279 #include <linux/kmalloc_sizes.h>
73280 - {NULL,}
73281 + {NULL}
73282 #undef CACHE
73283 };
73284
73285 @@ -1588,7 +1588,7 @@ void __init kmem_cache_init(void)
73286 sizes[INDEX_AC].cs_cachep = kmem_cache_create(names[INDEX_AC].name,
73287 sizes[INDEX_AC].cs_size,
73288 ARCH_KMALLOC_MINALIGN,
73289 - ARCH_KMALLOC_FLAGS|SLAB_PANIC,
73290 + ARCH_KMALLOC_FLAGS|SLAB_PANIC|SLAB_USERCOPY,
73291 NULL);
73292
73293 if (INDEX_AC != INDEX_L3) {
73294 @@ -1596,7 +1596,7 @@ void __init kmem_cache_init(void)
73295 kmem_cache_create(names[INDEX_L3].name,
73296 sizes[INDEX_L3].cs_size,
73297 ARCH_KMALLOC_MINALIGN,
73298 - ARCH_KMALLOC_FLAGS|SLAB_PANIC,
73299 + ARCH_KMALLOC_FLAGS|SLAB_PANIC|SLAB_USERCOPY,
73300 NULL);
73301 }
73302
73303 @@ -1614,7 +1614,7 @@ void __init kmem_cache_init(void)
73304 sizes->cs_cachep = kmem_cache_create(names->name,
73305 sizes->cs_size,
73306 ARCH_KMALLOC_MINALIGN,
73307 - ARCH_KMALLOC_FLAGS|SLAB_PANIC,
73308 + ARCH_KMALLOC_FLAGS|SLAB_PANIC|SLAB_USERCOPY,
73309 NULL);
73310 }
73311 #ifdef CONFIG_ZONE_DMA
73312 @@ -4339,10 +4339,10 @@ static int s_show(struct seq_file *m, void *p)
73313 }
73314 /* cpu stats */
73315 {
73316 - unsigned long allochit = atomic_read(&cachep->allochit);
73317 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
73318 - unsigned long freehit = atomic_read(&cachep->freehit);
73319 - unsigned long freemiss = atomic_read(&cachep->freemiss);
73320 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
73321 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
73322 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
73323 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
73324
73325 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
73326 allochit, allocmiss, freehit, freemiss);
73327 @@ -4601,13 +4601,62 @@ static int __init slab_proc_init(void)
73328 {
73329 proc_create("slabinfo",S_IWUSR|S_IRUSR,NULL,&proc_slabinfo_operations);
73330 #ifdef CONFIG_DEBUG_SLAB_LEAK
73331 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
73332 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
73333 #endif
73334 return 0;
73335 }
73336 module_init(slab_proc_init);
73337 #endif
73338
73339 +void check_object_size(const void *ptr, unsigned long n, bool to)
73340 +{
73341 +
73342 +#ifdef CONFIG_PAX_USERCOPY
73343 + struct page *page;
73344 + struct kmem_cache *cachep = NULL;
73345 + struct slab *slabp;
73346 + unsigned int objnr;
73347 + unsigned long offset;
73348 + const char *type;
73349 +
73350 + if (!n)
73351 + return;
73352 +
73353 + type = "<null>";
73354 + if (ZERO_OR_NULL_PTR(ptr))
73355 + goto report;
73356 +
73357 + if (!virt_addr_valid(ptr))
73358 + return;
73359 +
73360 + page = virt_to_head_page(ptr);
73361 +
73362 + type = "<process stack>";
73363 + if (!PageSlab(page)) {
73364 + if (object_is_on_stack(ptr, n) == -1)
73365 + goto report;
73366 + return;
73367 + }
73368 +
73369 + cachep = page_get_cache(page);
73370 + type = cachep->name;
73371 + if (!(cachep->flags & SLAB_USERCOPY))
73372 + goto report;
73373 +
73374 + slabp = page_get_slab(page);
73375 + objnr = obj_to_index(cachep, slabp, ptr);
73376 + BUG_ON(objnr >= cachep->num);
73377 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
73378 + if (offset <= obj_size(cachep) && n <= obj_size(cachep) - offset)
73379 + return;
73380 +
73381 +report:
73382 + pax_report_usercopy(ptr, n, to, type);
73383 +#endif
73384 +
73385 +}
73386 +EXPORT_SYMBOL(check_object_size);
73387 +
73388 /**
73389 * ksize - get the actual amount of memory allocated for a given object
73390 * @objp: Pointer to the object
73391 diff --git a/mm/slob.c b/mm/slob.c
73392 index 8105be4..e045f96 100644
73393 --- a/mm/slob.c
73394 +++ b/mm/slob.c
73395 @@ -29,7 +29,7 @@
73396 * If kmalloc is asked for objects of PAGE_SIZE or larger, it calls
73397 * alloc_pages() directly, allocating compound pages so the page order
73398 * does not have to be separately tracked, and also stores the exact
73399 - * allocation size in page->private so that it can be used to accurately
73400 + * allocation size in slob_page->size so that it can be used to accurately
73401 * provide ksize(). These objects are detected in kfree() because slob_page()
73402 * is false for them.
73403 *
73404 @@ -58,6 +58,7 @@
73405 */
73406
73407 #include <linux/kernel.h>
73408 +#include <linux/sched.h>
73409 #include <linux/slab.h>
73410 #include <linux/mm.h>
73411 #include <linux/swap.h> /* struct reclaim_state */
73412 @@ -102,7 +103,8 @@ struct slob_page {
73413 unsigned long flags; /* mandatory */
73414 atomic_t _count; /* mandatory */
73415 slobidx_t units; /* free units left in page */
73416 - unsigned long pad[2];
73417 + unsigned long pad[1];
73418 + unsigned long size; /* size when >=PAGE_SIZE */
73419 slob_t *free; /* first free slob_t in page */
73420 struct list_head list; /* linked list of free pages */
73421 };
73422 @@ -135,7 +137,7 @@ static LIST_HEAD(free_slob_large);
73423 */
73424 static inline int is_slob_page(struct slob_page *sp)
73425 {
73426 - return PageSlab((struct page *)sp);
73427 + return PageSlab((struct page *)sp) && !sp->size;
73428 }
73429
73430 static inline void set_slob_page(struct slob_page *sp)
73431 @@ -150,7 +152,7 @@ static inline void clear_slob_page(struct slob_page *sp)
73432
73433 static inline struct slob_page *slob_page(const void *addr)
73434 {
73435 - return (struct slob_page *)virt_to_page(addr);
73436 + return (struct slob_page *)virt_to_head_page(addr);
73437 }
73438
73439 /*
73440 @@ -210,7 +212,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
73441 /*
73442 * Return the size of a slob block.
73443 */
73444 -static slobidx_t slob_units(slob_t *s)
73445 +static slobidx_t slob_units(const slob_t *s)
73446 {
73447 if (s->units > 0)
73448 return s->units;
73449 @@ -220,7 +222,7 @@ static slobidx_t slob_units(slob_t *s)
73450 /*
73451 * Return the next free slob block pointer after this one.
73452 */
73453 -static slob_t *slob_next(slob_t *s)
73454 +static slob_t *slob_next(const slob_t *s)
73455 {
73456 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
73457 slobidx_t next;
73458 @@ -235,7 +237,7 @@ static slob_t *slob_next(slob_t *s)
73459 /*
73460 * Returns true if s is the last free block in its page.
73461 */
73462 -static int slob_last(slob_t *s)
73463 +static int slob_last(const slob_t *s)
73464 {
73465 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
73466 }
73467 @@ -254,6 +256,7 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
73468 if (!page)
73469 return NULL;
73470
73471 + set_slob_page(page);
73472 return page_address(page);
73473 }
73474
73475 @@ -370,11 +373,11 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
73476 if (!b)
73477 return NULL;
73478 sp = slob_page(b);
73479 - set_slob_page(sp);
73480
73481 spin_lock_irqsave(&slob_lock, flags);
73482 sp->units = SLOB_UNITS(PAGE_SIZE);
73483 sp->free = b;
73484 + sp->size = 0;
73485 INIT_LIST_HEAD(&sp->list);
73486 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
73487 set_slob_page_free(sp, slob_list);
73488 @@ -476,10 +479,9 @@ out:
73489 * End of slob allocator proper. Begin kmem_cache_alloc and kmalloc frontend.
73490 */
73491
73492 -void *__kmalloc_node(size_t size, gfp_t gfp, int node)
73493 +static void *__kmalloc_node_align(size_t size, gfp_t gfp, int node, int align)
73494 {
73495 - unsigned int *m;
73496 - int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
73497 + slob_t *m;
73498 void *ret;
73499
73500 gfp &= gfp_allowed_mask;
73501 @@ -494,7 +496,10 @@ void *__kmalloc_node(size_t size, gfp_t gfp, int node)
73502
73503 if (!m)
73504 return NULL;
73505 - *m = size;
73506 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
73507 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
73508 + m[0].units = size;
73509 + m[1].units = align;
73510 ret = (void *)m + align;
73511
73512 trace_kmalloc_node(_RET_IP_, ret,
73513 @@ -506,16 +511,25 @@ void *__kmalloc_node(size_t size, gfp_t gfp, int node)
73514 gfp |= __GFP_COMP;
73515 ret = slob_new_pages(gfp, order, node);
73516 if (ret) {
73517 - struct page *page;
73518 - page = virt_to_page(ret);
73519 - page->private = size;
73520 + struct slob_page *sp;
73521 + sp = slob_page(ret);
73522 + sp->size = size;
73523 }
73524
73525 trace_kmalloc_node(_RET_IP_, ret,
73526 size, PAGE_SIZE << order, gfp, node);
73527 }
73528
73529 - kmemleak_alloc(ret, size, 1, gfp);
73530 + return ret;
73531 +}
73532 +
73533 +void *__kmalloc_node(size_t size, gfp_t gfp, int node)
73534 +{
73535 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
73536 + void *ret = __kmalloc_node_align(size, gfp, node, align);
73537 +
73538 + if (!ZERO_OR_NULL_PTR(ret))
73539 + kmemleak_alloc(ret, size, 1, gfp);
73540 return ret;
73541 }
73542 EXPORT_SYMBOL(__kmalloc_node);
73543 @@ -533,13 +547,92 @@ void kfree(const void *block)
73544 sp = slob_page(block);
73545 if (is_slob_page(sp)) {
73546 int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
73547 - unsigned int *m = (unsigned int *)(block - align);
73548 - slob_free(m, *m + align);
73549 - } else
73550 + slob_t *m = (slob_t *)(block - align);
73551 + slob_free(m, m[0].units + align);
73552 + } else {
73553 + clear_slob_page(sp);
73554 + free_slob_page(sp);
73555 + sp->size = 0;
73556 put_page(&sp->page);
73557 + }
73558 }
73559 EXPORT_SYMBOL(kfree);
73560
73561 +void check_object_size(const void *ptr, unsigned long n, bool to)
73562 +{
73563 +
73564 +#ifdef CONFIG_PAX_USERCOPY
73565 + struct slob_page *sp;
73566 + const slob_t *free;
73567 + const void *base;
73568 + unsigned long flags;
73569 + const char *type;
73570 +
73571 + if (!n)
73572 + return;
73573 +
73574 + type = "<null>";
73575 + if (ZERO_OR_NULL_PTR(ptr))
73576 + goto report;
73577 +
73578 + if (!virt_addr_valid(ptr))
73579 + return;
73580 +
73581 + type = "<process stack>";
73582 + sp = slob_page(ptr);
73583 + if (!PageSlab((struct page *)sp)) {
73584 + if (object_is_on_stack(ptr, n) == -1)
73585 + goto report;
73586 + return;
73587 + }
73588 +
73589 + type = "<slob>";
73590 + if (sp->size) {
73591 + base = page_address(&sp->page);
73592 + if (base <= ptr && n <= sp->size - (ptr - base))
73593 + return;
73594 + goto report;
73595 + }
73596 +
73597 + /* some tricky double walking to find the chunk */
73598 + spin_lock_irqsave(&slob_lock, flags);
73599 + base = (void *)((unsigned long)ptr & PAGE_MASK);
73600 + free = sp->free;
73601 +
73602 + while (!slob_last(free) && (void *)free <= ptr) {
73603 + base = free + slob_units(free);
73604 + free = slob_next(free);
73605 + }
73606 +
73607 + while (base < (void *)free) {
73608 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
73609 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
73610 + int offset;
73611 +
73612 + if (ptr < base + align)
73613 + break;
73614 +
73615 + offset = ptr - base - align;
73616 + if (offset >= m) {
73617 + base += size;
73618 + continue;
73619 + }
73620 +
73621 + if (n > m - offset)
73622 + break;
73623 +
73624 + spin_unlock_irqrestore(&slob_lock, flags);
73625 + return;
73626 + }
73627 +
73628 + spin_unlock_irqrestore(&slob_lock, flags);
73629 +report:
73630 + pax_report_usercopy(ptr, n, to, type);
73631 +#endif
73632 +
73633 +}
73634 +EXPORT_SYMBOL(check_object_size);
73635 +
73636 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
73637 size_t ksize(const void *block)
73638 {
73639 @@ -552,10 +645,10 @@ size_t ksize(const void *block)
73640 sp = slob_page(block);
73641 if (is_slob_page(sp)) {
73642 int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
73643 - unsigned int *m = (unsigned int *)(block - align);
73644 - return SLOB_UNITS(*m) * SLOB_UNIT;
73645 + slob_t *m = (slob_t *)(block - align);
73646 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
73647 } else
73648 - return sp->page.private;
73649 + return sp->size;
73650 }
73651 EXPORT_SYMBOL(ksize);
73652
73653 @@ -571,8 +664,13 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size,
73654 {
73655 struct kmem_cache *c;
73656
73657 +#ifdef CONFIG_PAX_USERCOPY
73658 + c = __kmalloc_node_align(sizeof(struct kmem_cache),
73659 + GFP_KERNEL, -1, ARCH_KMALLOC_MINALIGN);
73660 +#else
73661 c = slob_alloc(sizeof(struct kmem_cache),
73662 GFP_KERNEL, ARCH_KMALLOC_MINALIGN, -1);
73663 +#endif
73664
73665 if (c) {
73666 c->name = name;
73667 @@ -614,17 +712,25 @@ void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
73668
73669 lockdep_trace_alloc(flags);
73670
73671 +#ifdef CONFIG_PAX_USERCOPY
73672 + b = __kmalloc_node_align(c->size, flags, node, c->align);
73673 +#else
73674 if (c->size < PAGE_SIZE) {
73675 b = slob_alloc(c->size, flags, c->align, node);
73676 trace_kmem_cache_alloc_node(_RET_IP_, b, c->size,
73677 SLOB_UNITS(c->size) * SLOB_UNIT,
73678 flags, node);
73679 } else {
73680 + struct slob_page *sp;
73681 +
73682 b = slob_new_pages(flags, get_order(c->size), node);
73683 + sp = slob_page(b);
73684 + sp->size = c->size;
73685 trace_kmem_cache_alloc_node(_RET_IP_, b, c->size,
73686 PAGE_SIZE << get_order(c->size),
73687 flags, node);
73688 }
73689 +#endif
73690
73691 if (c->ctor)
73692 c->ctor(b);
73693 @@ -636,10 +742,16 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
73694
73695 static void __kmem_cache_free(void *b, int size)
73696 {
73697 - if (size < PAGE_SIZE)
73698 + struct slob_page *sp = slob_page(b);
73699 +
73700 + if (is_slob_page(sp))
73701 slob_free(b, size);
73702 - else
73703 + else {
73704 + clear_slob_page(sp);
73705 + free_slob_page(sp);
73706 + sp->size = 0;
73707 slob_free_pages(b, get_order(size));
73708 + }
73709 }
73710
73711 static void kmem_rcu_free(struct rcu_head *head)
73712 @@ -652,17 +764,31 @@ static void kmem_rcu_free(struct rcu_head *head)
73713
73714 void kmem_cache_free(struct kmem_cache *c, void *b)
73715 {
73716 + int size = c->size;
73717 +
73718 +#ifdef CONFIG_PAX_USERCOPY
73719 + if (size + c->align < PAGE_SIZE) {
73720 + size += c->align;
73721 + b -= c->align;
73722 + }
73723 +#endif
73724 +
73725 kmemleak_free_recursive(b, c->flags);
73726 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
73727 struct slob_rcu *slob_rcu;
73728 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
73729 - slob_rcu->size = c->size;
73730 + slob_rcu = b + (size - sizeof(struct slob_rcu));
73731 + slob_rcu->size = size;
73732 call_rcu(&slob_rcu->head, kmem_rcu_free);
73733 } else {
73734 - __kmem_cache_free(b, c->size);
73735 + __kmem_cache_free(b, size);
73736 }
73737
73738 +#ifdef CONFIG_PAX_USERCOPY
73739 + trace_kfree(_RET_IP_, b);
73740 +#else
73741 trace_kmem_cache_free(_RET_IP_, b);
73742 +#endif
73743 +
73744 }
73745 EXPORT_SYMBOL(kmem_cache_free);
73746
73747 diff --git a/mm/slub.c b/mm/slub.c
73748 index 0342a5d..8180ae9 100644
73749 --- a/mm/slub.c
73750 +++ b/mm/slub.c
73751 @@ -208,7 +208,7 @@ struct track {
73752
73753 enum track_item { TRACK_ALLOC, TRACK_FREE };
73754
73755 -#ifdef CONFIG_SYSFS
73756 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
73757 static int sysfs_slab_add(struct kmem_cache *);
73758 static int sysfs_slab_alias(struct kmem_cache *, const char *);
73759 static void sysfs_slab_remove(struct kmem_cache *);
73760 @@ -532,7 +532,7 @@ static void print_track(const char *s, struct track *t)
73761 if (!t->addr)
73762 return;
73763
73764 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
73765 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
73766 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
73767 #ifdef CONFIG_STACKTRACE
73768 {
73769 @@ -2571,6 +2571,8 @@ void kmem_cache_free(struct kmem_cache *s, void *x)
73770
73771 page = virt_to_head_page(x);
73772
73773 + BUG_ON(!PageSlab(page));
73774 +
73775 slab_free(s, page, x, _RET_IP_);
73776
73777 trace_kmem_cache_free(_RET_IP_, x);
73778 @@ -2604,7 +2606,7 @@ static int slub_min_objects;
73779 * Merge control. If this is set then no merging of slab caches will occur.
73780 * (Could be removed. This was introduced to pacify the merge skeptics.)
73781 */
73782 -static int slub_nomerge;
73783 +static int slub_nomerge = 1;
73784
73785 /*
73786 * Calculate the order of allocation given an slab object size.
73787 @@ -3057,7 +3059,7 @@ static int kmem_cache_open(struct kmem_cache *s,
73788 else
73789 s->cpu_partial = 30;
73790
73791 - s->refcount = 1;
73792 + atomic_set(&s->refcount, 1);
73793 #ifdef CONFIG_NUMA
73794 s->remote_node_defrag_ratio = 1000;
73795 #endif
73796 @@ -3161,8 +3163,7 @@ static inline int kmem_cache_close(struct kmem_cache *s)
73797 void kmem_cache_destroy(struct kmem_cache *s)
73798 {
73799 down_write(&slub_lock);
73800 - s->refcount--;
73801 - if (!s->refcount) {
73802 + if (atomic_dec_and_test(&s->refcount)) {
73803 list_del(&s->list);
73804 up_write(&slub_lock);
73805 if (kmem_cache_close(s)) {
73806 @@ -3373,6 +3374,50 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
73807 EXPORT_SYMBOL(__kmalloc_node);
73808 #endif
73809
73810 +void check_object_size(const void *ptr, unsigned long n, bool to)
73811 +{
73812 +
73813 +#ifdef CONFIG_PAX_USERCOPY
73814 + struct page *page;
73815 + struct kmem_cache *s = NULL;
73816 + unsigned long offset;
73817 + const char *type;
73818 +
73819 + if (!n)
73820 + return;
73821 +
73822 + type = "<null>";
73823 + if (ZERO_OR_NULL_PTR(ptr))
73824 + goto report;
73825 +
73826 + if (!virt_addr_valid(ptr))
73827 + return;
73828 +
73829 + page = virt_to_head_page(ptr);
73830 +
73831 + type = "<process stack>";
73832 + if (!PageSlab(page)) {
73833 + if (object_is_on_stack(ptr, n) == -1)
73834 + goto report;
73835 + return;
73836 + }
73837 +
73838 + s = page->slab;
73839 + type = s->name;
73840 + if (!(s->flags & SLAB_USERCOPY))
73841 + goto report;
73842 +
73843 + offset = (ptr - page_address(page)) % s->size;
73844 + if (offset <= s->objsize && n <= s->objsize - offset)
73845 + return;
73846 +
73847 +report:
73848 + pax_report_usercopy(ptr, n, to, type);
73849 +#endif
73850 +
73851 +}
73852 +EXPORT_SYMBOL(check_object_size);
73853 +
73854 size_t ksize(const void *object)
73855 {
73856 struct page *page;
73857 @@ -3647,7 +3692,7 @@ static void __init kmem_cache_bootstrap_fixup(struct kmem_cache *s)
73858 int node;
73859
73860 list_add(&s->list, &slab_caches);
73861 - s->refcount = -1;
73862 + atomic_set(&s->refcount, -1);
73863
73864 for_each_node_state(node, N_NORMAL_MEMORY) {
73865 struct kmem_cache_node *n = get_node(s, node);
73866 @@ -3767,17 +3812,17 @@ void __init kmem_cache_init(void)
73867
73868 /* Caches that are not of the two-to-the-power-of size */
73869 if (KMALLOC_MIN_SIZE <= 32) {
73870 - kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, 0);
73871 + kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, SLAB_USERCOPY);
73872 caches++;
73873 }
73874
73875 if (KMALLOC_MIN_SIZE <= 64) {
73876 - kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, 0);
73877 + kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, SLAB_USERCOPY);
73878 caches++;
73879 }
73880
73881 for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) {
73882 - kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, 0);
73883 + kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, SLAB_USERCOPY);
73884 caches++;
73885 }
73886
73887 @@ -3845,7 +3890,7 @@ static int slab_unmergeable(struct kmem_cache *s)
73888 /*
73889 * We may have set a slab to be unmergeable during bootstrap.
73890 */
73891 - if (s->refcount < 0)
73892 + if (atomic_read(&s->refcount) < 0)
73893 return 1;
73894
73895 return 0;
73896 @@ -3904,7 +3949,7 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size,
73897 down_write(&slub_lock);
73898 s = find_mergeable(size, align, flags, name, ctor);
73899 if (s) {
73900 - s->refcount++;
73901 + atomic_inc(&s->refcount);
73902 /*
73903 * Adjust the object sizes so that we clear
73904 * the complete object on kzalloc.
73905 @@ -3913,7 +3958,7 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size,
73906 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
73907
73908 if (sysfs_slab_alias(s, name)) {
73909 - s->refcount--;
73910 + atomic_dec(&s->refcount);
73911 goto err;
73912 }
73913 up_write(&slub_lock);
73914 @@ -4042,7 +4087,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
73915 }
73916 #endif
73917
73918 -#ifdef CONFIG_SYSFS
73919 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
73920 static int count_inuse(struct page *page)
73921 {
73922 return page->inuse;
73923 @@ -4429,12 +4474,12 @@ static void resiliency_test(void)
73924 validate_slab_cache(kmalloc_caches[9]);
73925 }
73926 #else
73927 -#ifdef CONFIG_SYSFS
73928 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
73929 static void resiliency_test(void) {};
73930 #endif
73931 #endif
73932
73933 -#ifdef CONFIG_SYSFS
73934 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
73935 enum slab_stat_type {
73936 SL_ALL, /* All slabs */
73937 SL_PARTIAL, /* Only partially allocated slabs */
73938 @@ -4677,7 +4722,7 @@ SLAB_ATTR_RO(ctor);
73939
73940 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
73941 {
73942 - return sprintf(buf, "%d\n", s->refcount - 1);
73943 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
73944 }
73945 SLAB_ATTR_RO(aliases);
73946
73947 @@ -5244,6 +5289,7 @@ static char *create_unique_id(struct kmem_cache *s)
73948 return name;
73949 }
73950
73951 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
73952 static int sysfs_slab_add(struct kmem_cache *s)
73953 {
73954 int err;
73955 @@ -5306,6 +5352,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
73956 kobject_del(&s->kobj);
73957 kobject_put(&s->kobj);
73958 }
73959 +#endif
73960
73961 /*
73962 * Need to buffer aliases during bootup until sysfs becomes
73963 @@ -5319,6 +5366,7 @@ struct saved_alias {
73964
73965 static struct saved_alias *alias_list;
73966
73967 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
73968 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
73969 {
73970 struct saved_alias *al;
73971 @@ -5341,6 +5389,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
73972 alias_list = al;
73973 return 0;
73974 }
73975 +#endif
73976
73977 static int __init slab_sysfs_init(void)
73978 {
73979 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
73980 index 1b7e22a..3fcd4f3 100644
73981 --- a/mm/sparse-vmemmap.c
73982 +++ b/mm/sparse-vmemmap.c
73983 @@ -128,7 +128,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
73984 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
73985 if (!p)
73986 return NULL;
73987 - pud_populate(&init_mm, pud, p);
73988 + pud_populate_kernel(&init_mm, pud, p);
73989 }
73990 return pud;
73991 }
73992 @@ -140,7 +140,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
73993 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
73994 if (!p)
73995 return NULL;
73996 - pgd_populate(&init_mm, pgd, p);
73997 + pgd_populate_kernel(&init_mm, pgd, p);
73998 }
73999 return pgd;
74000 }
74001 diff --git a/mm/swap.c b/mm/swap.c
74002 index 14380e9..e244704 100644
74003 --- a/mm/swap.c
74004 +++ b/mm/swap.c
74005 @@ -30,6 +30,7 @@
74006 #include <linux/backing-dev.h>
74007 #include <linux/memcontrol.h>
74008 #include <linux/gfp.h>
74009 +#include <linux/hugetlb.h>
74010
74011 #include "internal.h"
74012
74013 @@ -70,6 +71,8 @@ static void __put_compound_page(struct page *page)
74014
74015 __page_cache_release(page);
74016 dtor = get_compound_page_dtor(page);
74017 + if (!PageHuge(page))
74018 + BUG_ON(dtor != free_compound_page);
74019 (*dtor)(page);
74020 }
74021
74022 diff --git a/mm/swapfile.c b/mm/swapfile.c
74023 index f31b29d..8bdcae2 100644
74024 --- a/mm/swapfile.c
74025 +++ b/mm/swapfile.c
74026 @@ -61,7 +61,7 @@ static DEFINE_MUTEX(swapon_mutex);
74027
74028 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
74029 /* Activity counter to indicate that a swapon or swapoff has occurred */
74030 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
74031 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
74032
74033 static inline unsigned char swap_count(unsigned char ent)
74034 {
74035 @@ -1669,7 +1669,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
74036 }
74037 filp_close(swap_file, NULL);
74038 err = 0;
74039 - atomic_inc(&proc_poll_event);
74040 + atomic_inc_unchecked(&proc_poll_event);
74041 wake_up_interruptible(&proc_poll_wait);
74042
74043 out_dput:
74044 @@ -1685,8 +1685,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
74045
74046 poll_wait(file, &proc_poll_wait, wait);
74047
74048 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
74049 - seq->poll_event = atomic_read(&proc_poll_event);
74050 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
74051 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
74052 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
74053 }
74054
74055 @@ -1784,7 +1784,7 @@ static int swaps_open(struct inode *inode, struct file *file)
74056 return ret;
74057
74058 seq = file->private_data;
74059 - seq->poll_event = atomic_read(&proc_poll_event);
74060 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
74061 return 0;
74062 }
74063
74064 @@ -2122,7 +2122,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
74065 (p->flags & SWP_DISCARDABLE) ? "D" : "");
74066
74067 mutex_unlock(&swapon_mutex);
74068 - atomic_inc(&proc_poll_event);
74069 + atomic_inc_unchecked(&proc_poll_event);
74070 wake_up_interruptible(&proc_poll_wait);
74071
74072 if (S_ISREG(inode->i_mode))
74073 diff --git a/mm/util.c b/mm/util.c
74074 index 136ac4f..f917fa9 100644
74075 --- a/mm/util.c
74076 +++ b/mm/util.c
74077 @@ -243,6 +243,12 @@ void __vma_link_list(struct mm_struct *mm, struct vm_area_struct *vma,
74078 void arch_pick_mmap_layout(struct mm_struct *mm)
74079 {
74080 mm->mmap_base = TASK_UNMAPPED_BASE;
74081 +
74082 +#ifdef CONFIG_PAX_RANDMMAP
74083 + if (mm->pax_flags & MF_PAX_RANDMMAP)
74084 + mm->mmap_base += mm->delta_mmap;
74085 +#endif
74086 +
74087 mm->get_unmapped_area = arch_get_unmapped_area;
74088 mm->unmap_area = arch_unmap_area;
74089 }
74090 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
74091 index 86ce9a5..fc9fb61 100644
74092 --- a/mm/vmalloc.c
74093 +++ b/mm/vmalloc.c
74094 @@ -39,8 +39,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
74095
74096 pte = pte_offset_kernel(pmd, addr);
74097 do {
74098 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
74099 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
74100 +
74101 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
74102 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
74103 + BUG_ON(!pte_exec(*pte));
74104 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
74105 + continue;
74106 + }
74107 +#endif
74108 +
74109 + {
74110 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
74111 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
74112 + }
74113 } while (pte++, addr += PAGE_SIZE, addr != end);
74114 }
74115
74116 @@ -91,6 +102,7 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
74117 unsigned long end, pgprot_t prot, struct page **pages, int *nr)
74118 {
74119 pte_t *pte;
74120 + int ret = -ENOMEM;
74121
74122 /*
74123 * nr is a running index into the array which helps higher level
74124 @@ -100,17 +112,30 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
74125 pte = pte_alloc_kernel(pmd, addr);
74126 if (!pte)
74127 return -ENOMEM;
74128 +
74129 + pax_open_kernel();
74130 do {
74131 struct page *page = pages[*nr];
74132
74133 - if (WARN_ON(!pte_none(*pte)))
74134 - return -EBUSY;
74135 - if (WARN_ON(!page))
74136 - return -ENOMEM;
74137 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
74138 + if (pgprot_val(prot) & _PAGE_NX)
74139 +#endif
74140 +
74141 + if (WARN_ON(!pte_none(*pte))) {
74142 + ret = -EBUSY;
74143 + goto out;
74144 + }
74145 + if (WARN_ON(!page)) {
74146 + ret = -ENOMEM;
74147 + goto out;
74148 + }
74149 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
74150 (*nr)++;
74151 } while (pte++, addr += PAGE_SIZE, addr != end);
74152 - return 0;
74153 + ret = 0;
74154 +out:
74155 + pax_close_kernel();
74156 + return ret;
74157 }
74158
74159 static int vmap_pmd_range(pud_t *pud, unsigned long addr,
74160 @@ -119,7 +144,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
74161 pmd_t *pmd;
74162 unsigned long next;
74163
74164 - pmd = pmd_alloc(&init_mm, pud, addr);
74165 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
74166 if (!pmd)
74167 return -ENOMEM;
74168 do {
74169 @@ -136,7 +161,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
74170 pud_t *pud;
74171 unsigned long next;
74172
74173 - pud = pud_alloc(&init_mm, pgd, addr);
74174 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
74175 if (!pud)
74176 return -ENOMEM;
74177 do {
74178 @@ -191,11 +216,20 @@ int is_vmalloc_or_module_addr(const void *x)
74179 * and fall back on vmalloc() if that fails. Others
74180 * just put it in the vmalloc space.
74181 */
74182 -#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
74183 +#ifdef CONFIG_MODULES
74184 +#ifdef MODULES_VADDR
74185 unsigned long addr = (unsigned long)x;
74186 if (addr >= MODULES_VADDR && addr < MODULES_END)
74187 return 1;
74188 #endif
74189 +
74190 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
74191 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
74192 + return 1;
74193 +#endif
74194 +
74195 +#endif
74196 +
74197 return is_vmalloc_addr(x);
74198 }
74199
74200 @@ -216,8 +250,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
74201
74202 if (!pgd_none(*pgd)) {
74203 pud_t *pud = pud_offset(pgd, addr);
74204 +#ifdef CONFIG_X86
74205 + if (!pud_large(*pud))
74206 +#endif
74207 if (!pud_none(*pud)) {
74208 pmd_t *pmd = pmd_offset(pud, addr);
74209 +#ifdef CONFIG_X86
74210 + if (!pmd_large(*pmd))
74211 +#endif
74212 if (!pmd_none(*pmd)) {
74213 pte_t *ptep, pte;
74214
74215 @@ -332,6 +372,10 @@ static void purge_vmap_area_lazy(void);
74216 static struct vmap_area *alloc_vmap_area(unsigned long size,
74217 unsigned long align,
74218 unsigned long vstart, unsigned long vend,
74219 + int node, gfp_t gfp_mask) __size_overflow(1);
74220 +static struct vmap_area *alloc_vmap_area(unsigned long size,
74221 + unsigned long align,
74222 + unsigned long vstart, unsigned long vend,
74223 int node, gfp_t gfp_mask)
74224 {
74225 struct vmap_area *va;
74226 @@ -1319,6 +1363,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
74227 struct vm_struct *area;
74228
74229 BUG_ON(in_interrupt());
74230 +
74231 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
74232 + if (flags & VM_KERNEXEC) {
74233 + if (start != VMALLOC_START || end != VMALLOC_END)
74234 + return NULL;
74235 + start = (unsigned long)MODULES_EXEC_VADDR;
74236 + end = (unsigned long)MODULES_EXEC_END;
74237 + }
74238 +#endif
74239 +
74240 if (flags & VM_IOREMAP) {
74241 int bit = fls(size);
74242
74243 @@ -1551,6 +1605,11 @@ void *vmap(struct page **pages, unsigned int count,
74244 if (count > totalram_pages)
74245 return NULL;
74246
74247 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
74248 + if (!(pgprot_val(prot) & _PAGE_NX))
74249 + flags |= VM_KERNEXEC;
74250 +#endif
74251 +
74252 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
74253 __builtin_return_address(0));
74254 if (!area)
74255 @@ -1652,6 +1711,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
74256 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
74257 goto fail;
74258
74259 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
74260 + if (!(pgprot_val(prot) & _PAGE_NX))
74261 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
74262 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
74263 + else
74264 +#endif
74265 +
74266 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
74267 start, end, node, gfp_mask, caller);
74268 if (!area)
74269 @@ -1825,10 +1891,9 @@ EXPORT_SYMBOL(vzalloc_node);
74270 * For tight control over page level allocator and protection flags
74271 * use __vmalloc() instead.
74272 */
74273 -
74274 void *vmalloc_exec(unsigned long size)
74275 {
74276 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
74277 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
74278 -1, __builtin_return_address(0));
74279 }
74280
74281 @@ -2123,6 +2188,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
74282 unsigned long uaddr = vma->vm_start;
74283 unsigned long usize = vma->vm_end - vma->vm_start;
74284
74285 + BUG_ON(vma->vm_mirror);
74286 +
74287 if ((PAGE_SIZE-1) & (unsigned long)addr)
74288 return -EINVAL;
74289
74290 diff --git a/mm/vmstat.c b/mm/vmstat.c
74291 index f600557..1459fc8 100644
74292 --- a/mm/vmstat.c
74293 +++ b/mm/vmstat.c
74294 @@ -78,7 +78,7 @@ void vm_events_fold_cpu(int cpu)
74295 *
74296 * vm_stat contains the global counters
74297 */
74298 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
74299 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
74300 EXPORT_SYMBOL(vm_stat);
74301
74302 #ifdef CONFIG_SMP
74303 @@ -454,7 +454,7 @@ void refresh_cpu_vm_stats(int cpu)
74304 v = p->vm_stat_diff[i];
74305 p->vm_stat_diff[i] = 0;
74306 local_irq_restore(flags);
74307 - atomic_long_add(v, &zone->vm_stat[i]);
74308 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
74309 global_diff[i] += v;
74310 #ifdef CONFIG_NUMA
74311 /* 3 seconds idle till flush */
74312 @@ -492,7 +492,7 @@ void refresh_cpu_vm_stats(int cpu)
74313
74314 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
74315 if (global_diff[i])
74316 - atomic_long_add(global_diff[i], &vm_stat[i]);
74317 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
74318 }
74319
74320 #endif
74321 @@ -1208,10 +1208,20 @@ static int __init setup_vmstat(void)
74322 start_cpu_timer(cpu);
74323 #endif
74324 #ifdef CONFIG_PROC_FS
74325 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
74326 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
74327 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
74328 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
74329 + {
74330 + mode_t gr_mode = S_IRUGO;
74331 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
74332 + gr_mode = S_IRUSR;
74333 +#endif
74334 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
74335 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
74336 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
74337 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
74338 +#else
74339 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
74340 +#endif
74341 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
74342 + }
74343 #endif
74344 return 0;
74345 }
74346 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
74347 index efea35b..9c8dd0b 100644
74348 --- a/net/8021q/vlan.c
74349 +++ b/net/8021q/vlan.c
74350 @@ -554,8 +554,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
74351 err = -EPERM;
74352 if (!capable(CAP_NET_ADMIN))
74353 break;
74354 - if ((args.u.name_type >= 0) &&
74355 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
74356 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
74357 struct vlan_net *vn;
74358
74359 vn = net_generic(net, vlan_net_id);
74360 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
74361 index fccae26..e7ece2f 100644
74362 --- a/net/9p/trans_fd.c
74363 +++ b/net/9p/trans_fd.c
74364 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
74365 oldfs = get_fs();
74366 set_fs(get_ds());
74367 /* The cast to a user pointer is valid due to the set_fs() */
74368 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
74369 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
74370 set_fs(oldfs);
74371
74372 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
74373 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
74374 index 876fbe8..8bbea9f 100644
74375 --- a/net/atm/atm_misc.c
74376 +++ b/net/atm/atm_misc.c
74377 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
74378 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
74379 return 1;
74380 atm_return(vcc, truesize);
74381 - atomic_inc(&vcc->stats->rx_drop);
74382 + atomic_inc_unchecked(&vcc->stats->rx_drop);
74383 return 0;
74384 }
74385 EXPORT_SYMBOL(atm_charge);
74386 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
74387 }
74388 }
74389 atm_return(vcc, guess);
74390 - atomic_inc(&vcc->stats->rx_drop);
74391 + atomic_inc_unchecked(&vcc->stats->rx_drop);
74392 return NULL;
74393 }
74394 EXPORT_SYMBOL(atm_alloc_charge);
74395 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
74396
74397 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
74398 {
74399 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
74400 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
74401 __SONET_ITEMS
74402 #undef __HANDLE_ITEM
74403 }
74404 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
74405
74406 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
74407 {
74408 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
74409 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
74410 __SONET_ITEMS
74411 #undef __HANDLE_ITEM
74412 }
74413 diff --git a/net/atm/lec.h b/net/atm/lec.h
74414 index dfc0719..47c5322 100644
74415 --- a/net/atm/lec.h
74416 +++ b/net/atm/lec.h
74417 @@ -48,7 +48,7 @@ struct lane2_ops {
74418 const u8 *tlvs, u32 sizeoftlvs);
74419 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
74420 const u8 *tlvs, u32 sizeoftlvs);
74421 -};
74422 +} __no_const;
74423
74424 /*
74425 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
74426 diff --git a/net/atm/mpc.h b/net/atm/mpc.h
74427 index 0919a88..a23d54e 100644
74428 --- a/net/atm/mpc.h
74429 +++ b/net/atm/mpc.h
74430 @@ -33,7 +33,7 @@ struct mpoa_client {
74431 struct mpc_parameters parameters; /* parameters for this client */
74432
74433 const struct net_device_ops *old_ops;
74434 - struct net_device_ops new_ops;
74435 + net_device_ops_no_const new_ops;
74436 };
74437
74438
74439 diff --git a/net/atm/proc.c b/net/atm/proc.c
74440 index 0d020de..011c7bb 100644
74441 --- a/net/atm/proc.c
74442 +++ b/net/atm/proc.c
74443 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
74444 const struct k_atm_aal_stats *stats)
74445 {
74446 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
74447 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
74448 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
74449 - atomic_read(&stats->rx_drop));
74450 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
74451 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
74452 + atomic_read_unchecked(&stats->rx_drop));
74453 }
74454
74455 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
74456 diff --git a/net/atm/resources.c b/net/atm/resources.c
74457 index 23f45ce..c748f1a 100644
74458 --- a/net/atm/resources.c
74459 +++ b/net/atm/resources.c
74460 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
74461 static void copy_aal_stats(struct k_atm_aal_stats *from,
74462 struct atm_aal_stats *to)
74463 {
74464 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
74465 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
74466 __AAL_STAT_ITEMS
74467 #undef __HANDLE_ITEM
74468 }
74469 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
74470 static void subtract_aal_stats(struct k_atm_aal_stats *from,
74471 struct atm_aal_stats *to)
74472 {
74473 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
74474 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
74475 __AAL_STAT_ITEMS
74476 #undef __HANDLE_ITEM
74477 }
74478 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
74479 index 3512e25..2b33401 100644
74480 --- a/net/batman-adv/bat_iv_ogm.c
74481 +++ b/net/batman-adv/bat_iv_ogm.c
74482 @@ -541,7 +541,7 @@ void bat_ogm_schedule(struct hard_iface *hard_iface, int tt_num_changes)
74483
74484 /* change sequence number to network order */
74485 batman_ogm_packet->seqno =
74486 - htonl((uint32_t)atomic_read(&hard_iface->seqno));
74487 + htonl((uint32_t)atomic_read_unchecked(&hard_iface->seqno));
74488
74489 batman_ogm_packet->ttvn = atomic_read(&bat_priv->ttvn);
74490 batman_ogm_packet->tt_crc = htons((uint16_t)
74491 @@ -561,7 +561,7 @@ void bat_ogm_schedule(struct hard_iface *hard_iface, int tt_num_changes)
74492 else
74493 batman_ogm_packet->gw_flags = NO_FLAGS;
74494
74495 - atomic_inc(&hard_iface->seqno);
74496 + atomic_inc_unchecked(&hard_iface->seqno);
74497
74498 slide_own_bcast_window(hard_iface);
74499 bat_ogm_queue_add(bat_priv, hard_iface->packet_buff,
74500 @@ -922,7 +922,7 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
74501 return;
74502
74503 /* could be changed by schedule_own_packet() */
74504 - if_incoming_seqno = atomic_read(&if_incoming->seqno);
74505 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->seqno);
74506
74507 has_directlink_flag = (batman_ogm_packet->flags & DIRECTLINK ? 1 : 0);
74508
74509 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
74510 index 7704df4..beb4e16 100644
74511 --- a/net/batman-adv/hard-interface.c
74512 +++ b/net/batman-adv/hard-interface.c
74513 @@ -326,8 +326,8 @@ int hardif_enable_interface(struct hard_iface *hard_iface,
74514 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
74515 dev_add_pack(&hard_iface->batman_adv_ptype);
74516
74517 - atomic_set(&hard_iface->seqno, 1);
74518 - atomic_set(&hard_iface->frag_seqno, 1);
74519 + atomic_set_unchecked(&hard_iface->seqno, 1);
74520 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
74521 bat_info(hard_iface->soft_iface, "Adding interface: %s\n",
74522 hard_iface->net_dev->name);
74523
74524 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
74525 index 987c75a..20d6f36 100644
74526 --- a/net/batman-adv/soft-interface.c
74527 +++ b/net/batman-adv/soft-interface.c
74528 @@ -645,7 +645,7 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
74529
74530 /* set broadcast sequence number */
74531 bcast_packet->seqno =
74532 - htonl(atomic_inc_return(&bat_priv->bcast_seqno));
74533 + htonl(atomic_inc_return_unchecked(&bat_priv->bcast_seqno));
74534
74535 add_bcast_packet_to_list(bat_priv, skb, 1);
74536
74537 @@ -843,7 +843,7 @@ struct net_device *softif_create(const char *name)
74538 atomic_set(&bat_priv->batman_queue_left, BATMAN_QUEUE_LEN);
74539
74540 atomic_set(&bat_priv->mesh_state, MESH_INACTIVE);
74541 - atomic_set(&bat_priv->bcast_seqno, 1);
74542 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
74543 atomic_set(&bat_priv->ttvn, 0);
74544 atomic_set(&bat_priv->tt_local_changes, 0);
74545 atomic_set(&bat_priv->tt_ogm_append_cnt, 0);
74546 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
74547 index e9eb043..d174eeb 100644
74548 --- a/net/batman-adv/types.h
74549 +++ b/net/batman-adv/types.h
74550 @@ -38,8 +38,8 @@ struct hard_iface {
74551 int16_t if_num;
74552 char if_status;
74553 struct net_device *net_dev;
74554 - atomic_t seqno;
74555 - atomic_t frag_seqno;
74556 + atomic_unchecked_t seqno;
74557 + atomic_unchecked_t frag_seqno;
74558 unsigned char *packet_buff;
74559 int packet_len;
74560 struct kobject *hardif_obj;
74561 @@ -154,7 +154,7 @@ struct bat_priv {
74562 atomic_t orig_interval; /* uint */
74563 atomic_t hop_penalty; /* uint */
74564 atomic_t log_level; /* uint */
74565 - atomic_t bcast_seqno;
74566 + atomic_unchecked_t bcast_seqno;
74567 atomic_t bcast_queue_left;
74568 atomic_t batman_queue_left;
74569 atomic_t ttvn; /* translation table version number */
74570 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
74571 index 07d1c1d..7e9bea9 100644
74572 --- a/net/batman-adv/unicast.c
74573 +++ b/net/batman-adv/unicast.c
74574 @@ -264,7 +264,7 @@ int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
74575 frag1->flags = UNI_FRAG_HEAD | large_tail;
74576 frag2->flags = large_tail;
74577
74578 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
74579 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
74580 frag1->seqno = htons(seqno - 1);
74581 frag2->seqno = htons(seqno);
74582
74583 diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
74584 index 280953b..cd219bb 100644
74585 --- a/net/bluetooth/hci_conn.c
74586 +++ b/net/bluetooth/hci_conn.c
74587 @@ -234,7 +234,7 @@ void hci_le_ltk_reply(struct hci_conn *conn, u8 ltk[16])
74588 memset(&cp, 0, sizeof(cp));
74589
74590 cp.handle = cpu_to_le16(conn->handle);
74591 - memcpy(cp.ltk, ltk, sizeof(ltk));
74592 + memcpy(cp.ltk, ltk, sizeof(cp.ltk));
74593
74594 hci_send_cmd(hdev, HCI_OP_LE_LTK_REPLY, sizeof(cp), &cp);
74595 }
74596 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
74597 index 32d338c..d24bcdb 100644
74598 --- a/net/bluetooth/l2cap_core.c
74599 +++ b/net/bluetooth/l2cap_core.c
74600 @@ -2418,8 +2418,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi
74601 break;
74602
74603 case L2CAP_CONF_RFC:
74604 - if (olen == sizeof(rfc))
74605 - memcpy(&rfc, (void *)val, olen);
74606 + if (olen != sizeof(rfc))
74607 + break;
74608 +
74609 + memcpy(&rfc, (void *)val, olen);
74610
74611 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
74612 rfc.mode != chan->mode)
74613 @@ -2537,8 +2539,10 @@ static void l2cap_conf_rfc_get(struct l2cap_chan *chan, void *rsp, int len)
74614
74615 switch (type) {
74616 case L2CAP_CONF_RFC:
74617 - if (olen == sizeof(rfc))
74618 - memcpy(&rfc, (void *)val, olen);
74619 + if (olen != sizeof(rfc))
74620 + break;
74621 +
74622 + memcpy(&rfc, (void *)val, olen);
74623 goto done;
74624 }
74625 }
74626 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
74627 index 5fe2ff3..10968b5 100644
74628 --- a/net/bridge/netfilter/ebtables.c
74629 +++ b/net/bridge/netfilter/ebtables.c
74630 @@ -1523,7 +1523,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
74631 tmp.valid_hooks = t->table->valid_hooks;
74632 }
74633 mutex_unlock(&ebt_mutex);
74634 - if (copy_to_user(user, &tmp, *len) != 0){
74635 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
74636 BUGPRINT("c2u Didn't work\n");
74637 ret = -EFAULT;
74638 break;
74639 diff --git a/net/caif/caif_socket.c b/net/caif/caif_socket.c
74640 index a97d97a..6f679ed 100644
74641 --- a/net/caif/caif_socket.c
74642 +++ b/net/caif/caif_socket.c
74643 @@ -48,19 +48,20 @@ static struct dentry *debugfsdir;
74644 #ifdef CONFIG_DEBUG_FS
74645 struct debug_fs_counter {
74646 atomic_t caif_nr_socks;
74647 - atomic_t caif_sock_create;
74648 - atomic_t num_connect_req;
74649 - atomic_t num_connect_resp;
74650 - atomic_t num_connect_fail_resp;
74651 - atomic_t num_disconnect;
74652 - atomic_t num_remote_shutdown_ind;
74653 - atomic_t num_tx_flow_off_ind;
74654 - atomic_t num_tx_flow_on_ind;
74655 - atomic_t num_rx_flow_off;
74656 - atomic_t num_rx_flow_on;
74657 + atomic_unchecked_t caif_sock_create;
74658 + atomic_unchecked_t num_connect_req;
74659 + atomic_unchecked_t num_connect_resp;
74660 + atomic_unchecked_t num_connect_fail_resp;
74661 + atomic_unchecked_t num_disconnect;
74662 + atomic_unchecked_t num_remote_shutdown_ind;
74663 + atomic_unchecked_t num_tx_flow_off_ind;
74664 + atomic_unchecked_t num_tx_flow_on_ind;
74665 + atomic_unchecked_t num_rx_flow_off;
74666 + atomic_unchecked_t num_rx_flow_on;
74667 };
74668 static struct debug_fs_counter cnt;
74669 #define dbfs_atomic_inc(v) atomic_inc_return(v)
74670 +#define dbfs_atomic_inc_unchecked(v) atomic_inc_return_unchecked(v)
74671 #define dbfs_atomic_dec(v) atomic_dec_return(v)
74672 #else
74673 #define dbfs_atomic_inc(v) 0
74674 @@ -161,7 +162,7 @@ static int caif_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
74675 atomic_read(&cf_sk->sk.sk_rmem_alloc),
74676 sk_rcvbuf_lowwater(cf_sk));
74677 set_rx_flow_off(cf_sk);
74678 - dbfs_atomic_inc(&cnt.num_rx_flow_off);
74679 + dbfs_atomic_inc_unchecked(&cnt.num_rx_flow_off);
74680 caif_flow_ctrl(sk, CAIF_MODEMCMD_FLOW_OFF_REQ);
74681 }
74682
74683 @@ -172,7 +173,7 @@ static int caif_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
74684 set_rx_flow_off(cf_sk);
74685 if (net_ratelimit())
74686 pr_debug("sending flow OFF due to rmem_schedule\n");
74687 - dbfs_atomic_inc(&cnt.num_rx_flow_off);
74688 + dbfs_atomic_inc_unchecked(&cnt.num_rx_flow_off);
74689 caif_flow_ctrl(sk, CAIF_MODEMCMD_FLOW_OFF_REQ);
74690 }
74691 skb->dev = NULL;
74692 @@ -233,14 +234,14 @@ static void caif_ctrl_cb(struct cflayer *layr,
74693 switch (flow) {
74694 case CAIF_CTRLCMD_FLOW_ON_IND:
74695 /* OK from modem to start sending again */
74696 - dbfs_atomic_inc(&cnt.num_tx_flow_on_ind);
74697 + dbfs_atomic_inc_unchecked(&cnt.num_tx_flow_on_ind);
74698 set_tx_flow_on(cf_sk);
74699 cf_sk->sk.sk_state_change(&cf_sk->sk);
74700 break;
74701
74702 case CAIF_CTRLCMD_FLOW_OFF_IND:
74703 /* Modem asks us to shut up */
74704 - dbfs_atomic_inc(&cnt.num_tx_flow_off_ind);
74705 + dbfs_atomic_inc_unchecked(&cnt.num_tx_flow_off_ind);
74706 set_tx_flow_off(cf_sk);
74707 cf_sk->sk.sk_state_change(&cf_sk->sk);
74708 break;
74709 @@ -249,7 +250,7 @@ static void caif_ctrl_cb(struct cflayer *layr,
74710 /* We're now connected */
74711 caif_client_register_refcnt(&cf_sk->layer,
74712 cfsk_hold, cfsk_put);
74713 - dbfs_atomic_inc(&cnt.num_connect_resp);
74714 + dbfs_atomic_inc_unchecked(&cnt.num_connect_resp);
74715 cf_sk->sk.sk_state = CAIF_CONNECTED;
74716 set_tx_flow_on(cf_sk);
74717 cf_sk->sk.sk_state_change(&cf_sk->sk);
74718 @@ -263,7 +264,7 @@ static void caif_ctrl_cb(struct cflayer *layr,
74719
74720 case CAIF_CTRLCMD_INIT_FAIL_RSP:
74721 /* Connect request failed */
74722 - dbfs_atomic_inc(&cnt.num_connect_fail_resp);
74723 + dbfs_atomic_inc_unchecked(&cnt.num_connect_fail_resp);
74724 cf_sk->sk.sk_err = ECONNREFUSED;
74725 cf_sk->sk.sk_state = CAIF_DISCONNECTED;
74726 cf_sk->sk.sk_shutdown = SHUTDOWN_MASK;
74727 @@ -277,7 +278,7 @@ static void caif_ctrl_cb(struct cflayer *layr,
74728
74729 case CAIF_CTRLCMD_REMOTE_SHUTDOWN_IND:
74730 /* Modem has closed this connection, or device is down. */
74731 - dbfs_atomic_inc(&cnt.num_remote_shutdown_ind);
74732 + dbfs_atomic_inc_unchecked(&cnt.num_remote_shutdown_ind);
74733 cf_sk->sk.sk_shutdown = SHUTDOWN_MASK;
74734 cf_sk->sk.sk_err = ECONNRESET;
74735 set_rx_flow_on(cf_sk);
74736 @@ -297,7 +298,7 @@ static void caif_check_flow_release(struct sock *sk)
74737 return;
74738
74739 if (atomic_read(&sk->sk_rmem_alloc) <= sk_rcvbuf_lowwater(cf_sk)) {
74740 - dbfs_atomic_inc(&cnt.num_rx_flow_on);
74741 + dbfs_atomic_inc_unchecked(&cnt.num_rx_flow_on);
74742 set_rx_flow_on(cf_sk);
74743 caif_flow_ctrl(sk, CAIF_MODEMCMD_FLOW_ON_REQ);
74744 }
74745 @@ -856,7 +857,7 @@ static int caif_connect(struct socket *sock, struct sockaddr *uaddr,
74746 /*ifindex = id of the interface.*/
74747 cf_sk->conn_req.ifindex = cf_sk->sk.sk_bound_dev_if;
74748
74749 - dbfs_atomic_inc(&cnt.num_connect_req);
74750 + dbfs_atomic_inc_unchecked(&cnt.num_connect_req);
74751 cf_sk->layer.receive = caif_sktrecv_cb;
74752
74753 err = caif_connect_client(sock_net(sk), &cf_sk->conn_req,
74754 @@ -945,7 +946,7 @@ static int caif_release(struct socket *sock)
74755 spin_unlock_bh(&sk->sk_receive_queue.lock);
74756 sock->sk = NULL;
74757
74758 - dbfs_atomic_inc(&cnt.num_disconnect);
74759 + dbfs_atomic_inc_unchecked(&cnt.num_disconnect);
74760
74761 WARN_ON(IS_ERR(cf_sk->debugfs_socket_dir));
74762 if (cf_sk->debugfs_socket_dir != NULL)
74763 @@ -1124,7 +1125,7 @@ static int caif_create(struct net *net, struct socket *sock, int protocol,
74764 cf_sk->conn_req.protocol = protocol;
74765 /* Increase the number of sockets created. */
74766 dbfs_atomic_inc(&cnt.caif_nr_socks);
74767 - num = dbfs_atomic_inc(&cnt.caif_sock_create);
74768 + num = dbfs_atomic_inc_unchecked(&cnt.caif_sock_create);
74769 #ifdef CONFIG_DEBUG_FS
74770 if (!IS_ERR(debugfsdir)) {
74771
74772 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
74773 index 5cf5222..6f704ad 100644
74774 --- a/net/caif/cfctrl.c
74775 +++ b/net/caif/cfctrl.c
74776 @@ -9,6 +9,7 @@
74777 #include <linux/stddef.h>
74778 #include <linux/spinlock.h>
74779 #include <linux/slab.h>
74780 +#include <linux/sched.h>
74781 #include <net/caif/caif_layer.h>
74782 #include <net/caif/cfpkt.h>
74783 #include <net/caif/cfctrl.h>
74784 @@ -42,8 +43,8 @@ struct cflayer *cfctrl_create(void)
74785 memset(&dev_info, 0, sizeof(dev_info));
74786 dev_info.id = 0xff;
74787 cfsrvl_init(&this->serv, 0, &dev_info, false);
74788 - atomic_set(&this->req_seq_no, 1);
74789 - atomic_set(&this->rsp_seq_no, 1);
74790 + atomic_set_unchecked(&this->req_seq_no, 1);
74791 + atomic_set_unchecked(&this->rsp_seq_no, 1);
74792 this->serv.layer.receive = cfctrl_recv;
74793 sprintf(this->serv.layer.name, "ctrl");
74794 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
74795 @@ -129,8 +130,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
74796 struct cfctrl_request_info *req)
74797 {
74798 spin_lock_bh(&ctrl->info_list_lock);
74799 - atomic_inc(&ctrl->req_seq_no);
74800 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
74801 + atomic_inc_unchecked(&ctrl->req_seq_no);
74802 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
74803 list_add_tail(&req->list, &ctrl->list);
74804 spin_unlock_bh(&ctrl->info_list_lock);
74805 }
74806 @@ -148,7 +149,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
74807 if (p != first)
74808 pr_warn("Requests are not received in order\n");
74809
74810 - atomic_set(&ctrl->rsp_seq_no,
74811 + atomic_set_unchecked(&ctrl->rsp_seq_no,
74812 p->sequence_no);
74813 list_del(&p->list);
74814 goto out;
74815 diff --git a/net/can/gw.c b/net/can/gw.c
74816 index 3d79b12..8de85fa 100644
74817 --- a/net/can/gw.c
74818 +++ b/net/can/gw.c
74819 @@ -96,7 +96,7 @@ struct cf_mod {
74820 struct {
74821 void (*xor)(struct can_frame *cf, struct cgw_csum_xor *xor);
74822 void (*crc8)(struct can_frame *cf, struct cgw_csum_crc8 *crc8);
74823 - } csumfunc;
74824 + } __no_const csumfunc;
74825 };
74826
74827
74828 diff --git a/net/compat.c b/net/compat.c
74829 index 6def90e..c6992fa 100644
74830 --- a/net/compat.c
74831 +++ b/net/compat.c
74832 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
74833 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
74834 __get_user(kmsg->msg_flags, &umsg->msg_flags))
74835 return -EFAULT;
74836 - kmsg->msg_name = compat_ptr(tmp1);
74837 - kmsg->msg_iov = compat_ptr(tmp2);
74838 - kmsg->msg_control = compat_ptr(tmp3);
74839 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
74840 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
74841 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
74842 return 0;
74843 }
74844
74845 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
74846
74847 if (kern_msg->msg_namelen) {
74848 if (mode == VERIFY_READ) {
74849 - int err = move_addr_to_kernel(kern_msg->msg_name,
74850 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
74851 kern_msg->msg_namelen,
74852 kern_address);
74853 if (err < 0)
74854 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
74855 kern_msg->msg_name = NULL;
74856
74857 tot_len = iov_from_user_compat_to_kern(kern_iov,
74858 - (struct compat_iovec __user *)kern_msg->msg_iov,
74859 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
74860 kern_msg->msg_iovlen);
74861 if (tot_len >= 0)
74862 kern_msg->msg_iov = kern_iov;
74863 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
74864
74865 #define CMSG_COMPAT_FIRSTHDR(msg) \
74866 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
74867 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
74868 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
74869 (struct compat_cmsghdr __user *)NULL)
74870
74871 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
74872 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
74873 (ucmlen) <= (unsigned long) \
74874 ((mhdr)->msg_controllen - \
74875 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
74876 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
74877
74878 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
74879 struct compat_cmsghdr __user *cmsg, int cmsg_len)
74880 {
74881 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
74882 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
74883 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
74884 msg->msg_controllen)
74885 return NULL;
74886 return (struct compat_cmsghdr __user *)ptr;
74887 @@ -221,7 +221,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
74888 {
74889 struct compat_timeval ctv;
74890 struct compat_timespec cts[3];
74891 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
74892 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
74893 struct compat_cmsghdr cmhdr;
74894 int cmlen;
74895
74896 @@ -273,7 +273,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
74897
74898 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
74899 {
74900 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
74901 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
74902 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
74903 int fdnum = scm->fp->count;
74904 struct file **fp = scm->fp->fp;
74905 @@ -370,7 +370,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
74906 return -EFAULT;
74907 old_fs = get_fs();
74908 set_fs(KERNEL_DS);
74909 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
74910 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
74911 set_fs(old_fs);
74912
74913 return err;
74914 @@ -431,7 +431,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
74915 len = sizeof(ktime);
74916 old_fs = get_fs();
74917 set_fs(KERNEL_DS);
74918 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
74919 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
74920 set_fs(old_fs);
74921
74922 if (!err) {
74923 @@ -566,7 +566,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
74924 case MCAST_JOIN_GROUP:
74925 case MCAST_LEAVE_GROUP:
74926 {
74927 - struct compat_group_req __user *gr32 = (void *)optval;
74928 + struct compat_group_req __user *gr32 = (void __user *)optval;
74929 struct group_req __user *kgr =
74930 compat_alloc_user_space(sizeof(struct group_req));
74931 u32 interface;
74932 @@ -587,7 +587,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
74933 case MCAST_BLOCK_SOURCE:
74934 case MCAST_UNBLOCK_SOURCE:
74935 {
74936 - struct compat_group_source_req __user *gsr32 = (void *)optval;
74937 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
74938 struct group_source_req __user *kgsr = compat_alloc_user_space(
74939 sizeof(struct group_source_req));
74940 u32 interface;
74941 @@ -608,7 +608,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
74942 }
74943 case MCAST_MSFILTER:
74944 {
74945 - struct compat_group_filter __user *gf32 = (void *)optval;
74946 + struct compat_group_filter __user *gf32 = (void __user *)optval;
74947 struct group_filter __user *kgf;
74948 u32 interface, fmode, numsrc;
74949
74950 @@ -646,7 +646,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
74951 char __user *optval, int __user *optlen,
74952 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
74953 {
74954 - struct compat_group_filter __user *gf32 = (void *)optval;
74955 + struct compat_group_filter __user *gf32 = (void __user *)optval;
74956 struct group_filter __user *kgf;
74957 int __user *koptlen;
74958 u32 interface, fmode, numsrc;
74959 diff --git a/net/core/datagram.c b/net/core/datagram.c
74960 index 68bbf9f..5ef0d12 100644
74961 --- a/net/core/datagram.c
74962 +++ b/net/core/datagram.c
74963 @@ -285,7 +285,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
74964 }
74965
74966 kfree_skb(skb);
74967 - atomic_inc(&sk->sk_drops);
74968 + atomic_inc_unchecked(&sk->sk_drops);
74969 sk_mem_reclaim_partial(sk);
74970
74971 return err;
74972 diff --git a/net/core/dev.c b/net/core/dev.c
74973 index 0336374..659088a 100644
74974 --- a/net/core/dev.c
74975 +++ b/net/core/dev.c
74976 @@ -1138,10 +1138,14 @@ void dev_load(struct net *net, const char *name)
74977 if (no_module && capable(CAP_NET_ADMIN))
74978 no_module = request_module("netdev-%s", name);
74979 if (no_module && capable(CAP_SYS_MODULE)) {
74980 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
74981 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
74982 +#else
74983 if (!request_module("%s", name))
74984 pr_err("Loading kernel module for a network device "
74985 "with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s "
74986 "instead\n", name);
74987 +#endif
74988 }
74989 }
74990 EXPORT_SYMBOL(dev_load);
74991 @@ -1605,7 +1609,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
74992 {
74993 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
74994 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
74995 - atomic_long_inc(&dev->rx_dropped);
74996 + atomic_long_inc_unchecked(&dev->rx_dropped);
74997 kfree_skb(skb);
74998 return NET_RX_DROP;
74999 }
75000 @@ -1615,7 +1619,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
75001 nf_reset(skb);
75002
75003 if (unlikely(!is_skb_forwardable(dev, skb))) {
75004 - atomic_long_inc(&dev->rx_dropped);
75005 + atomic_long_inc_unchecked(&dev->rx_dropped);
75006 kfree_skb(skb);
75007 return NET_RX_DROP;
75008 }
75009 @@ -2077,7 +2081,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
75010
75011 struct dev_gso_cb {
75012 void (*destructor)(struct sk_buff *skb);
75013 -};
75014 +} __no_const;
75015
75016 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
75017
75018 @@ -2933,7 +2937,7 @@ enqueue:
75019
75020 local_irq_restore(flags);
75021
75022 - atomic_long_inc(&skb->dev->rx_dropped);
75023 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
75024 kfree_skb(skb);
75025 return NET_RX_DROP;
75026 }
75027 @@ -3005,7 +3009,7 @@ int netif_rx_ni(struct sk_buff *skb)
75028 }
75029 EXPORT_SYMBOL(netif_rx_ni);
75030
75031 -static void net_tx_action(struct softirq_action *h)
75032 +static void net_tx_action(void)
75033 {
75034 struct softnet_data *sd = &__get_cpu_var(softnet_data);
75035
75036 @@ -3293,7 +3297,7 @@ ncls:
75037 if (pt_prev) {
75038 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
75039 } else {
75040 - atomic_long_inc(&skb->dev->rx_dropped);
75041 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
75042 kfree_skb(skb);
75043 /* Jamal, now you will not able to escape explaining
75044 * me how you were going to use this. :-)
75045 @@ -3853,7 +3857,7 @@ void netif_napi_del(struct napi_struct *napi)
75046 }
75047 EXPORT_SYMBOL(netif_napi_del);
75048
75049 -static void net_rx_action(struct softirq_action *h)
75050 +static void net_rx_action(void)
75051 {
75052 struct softnet_data *sd = &__get_cpu_var(softnet_data);
75053 unsigned long time_limit = jiffies + 2;
75054 @@ -5878,7 +5882,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
75055 } else {
75056 netdev_stats_to_stats64(storage, &dev->stats);
75057 }
75058 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
75059 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
75060 return storage;
75061 }
75062 EXPORT_SYMBOL(dev_get_stats);
75063 diff --git a/net/core/flow.c b/net/core/flow.c
75064 index e318c7e..168b1d0 100644
75065 --- a/net/core/flow.c
75066 +++ b/net/core/flow.c
75067 @@ -61,7 +61,7 @@ struct flow_cache {
75068 struct timer_list rnd_timer;
75069 };
75070
75071 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
75072 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
75073 EXPORT_SYMBOL(flow_cache_genid);
75074 static struct flow_cache flow_cache_global;
75075 static struct kmem_cache *flow_cachep __read_mostly;
75076 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
75077
75078 static int flow_entry_valid(struct flow_cache_entry *fle)
75079 {
75080 - if (atomic_read(&flow_cache_genid) != fle->genid)
75081 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
75082 return 0;
75083 if (fle->object && !fle->object->ops->check(fle->object))
75084 return 0;
75085 @@ -259,7 +259,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
75086 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
75087 fcp->hash_count++;
75088 }
75089 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
75090 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
75091 flo = fle->object;
75092 if (!flo)
75093 goto ret_object;
75094 @@ -280,7 +280,7 @@ nocache:
75095 }
75096 flo = resolver(net, key, family, dir, flo, ctx);
75097 if (fle) {
75098 - fle->genid = atomic_read(&flow_cache_genid);
75099 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
75100 if (!IS_ERR(flo))
75101 fle->object = flo;
75102 else
75103 diff --git a/net/core/iovec.c b/net/core/iovec.c
75104 index c40f27e..7f49254 100644
75105 --- a/net/core/iovec.c
75106 +++ b/net/core/iovec.c
75107 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr *address,
75108 if (m->msg_namelen) {
75109 if (mode == VERIFY_READ) {
75110 void __user *namep;
75111 - namep = (void __user __force *) m->msg_name;
75112 + namep = (void __force_user *) m->msg_name;
75113 err = move_addr_to_kernel(namep, m->msg_namelen,
75114 address);
75115 if (err < 0)
75116 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr *address,
75117 }
75118
75119 size = m->msg_iovlen * sizeof(struct iovec);
75120 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
75121 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
75122 return -EFAULT;
75123
75124 m->msg_iov = iov;
75125 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
75126 index 5c30296..ebe7b61 100644
75127 --- a/net/core/rtnetlink.c
75128 +++ b/net/core/rtnetlink.c
75129 @@ -57,7 +57,7 @@ struct rtnl_link {
75130 rtnl_doit_func doit;
75131 rtnl_dumpit_func dumpit;
75132 rtnl_calcit_func calcit;
75133 -};
75134 +} __no_const;
75135
75136 static DEFINE_MUTEX(rtnl_mutex);
75137
75138 diff --git a/net/core/scm.c b/net/core/scm.c
75139 index ff52ad0..aff1c0f 100644
75140 --- a/net/core/scm.c
75141 +++ b/net/core/scm.c
75142 @@ -220,7 +220,7 @@ EXPORT_SYMBOL(__scm_send);
75143 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
75144 {
75145 struct cmsghdr __user *cm
75146 - = (__force struct cmsghdr __user *)msg->msg_control;
75147 + = (struct cmsghdr __force_user *)msg->msg_control;
75148 struct cmsghdr cmhdr;
75149 int cmlen = CMSG_LEN(len);
75150 int err;
75151 @@ -243,7 +243,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
75152 err = -EFAULT;
75153 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
75154 goto out;
75155 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
75156 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
75157 goto out;
75158 cmlen = CMSG_SPACE(len);
75159 if (msg->msg_controllen < cmlen)
75160 @@ -259,7 +259,7 @@ EXPORT_SYMBOL(put_cmsg);
75161 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
75162 {
75163 struct cmsghdr __user *cm
75164 - = (__force struct cmsghdr __user*)msg->msg_control;
75165 + = (struct cmsghdr __force_user *)msg->msg_control;
75166
75167 int fdmax = 0;
75168 int fdnum = scm->fp->count;
75169 @@ -279,7 +279,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
75170 if (fdnum < fdmax)
75171 fdmax = fdnum;
75172
75173 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
75174 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
75175 i++, cmfptr++)
75176 {
75177 int new_fd;
75178 diff --git a/net/core/sock.c b/net/core/sock.c
75179 index 02f8dfe..86dfd4a 100644
75180 --- a/net/core/sock.c
75181 +++ b/net/core/sock.c
75182 @@ -341,7 +341,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
75183 struct sk_buff_head *list = &sk->sk_receive_queue;
75184
75185 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
75186 - atomic_inc(&sk->sk_drops);
75187 + atomic_inc_unchecked(&sk->sk_drops);
75188 trace_sock_rcvqueue_full(sk, skb);
75189 return -ENOMEM;
75190 }
75191 @@ -351,7 +351,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
75192 return err;
75193
75194 if (!sk_rmem_schedule(sk, skb->truesize)) {
75195 - atomic_inc(&sk->sk_drops);
75196 + atomic_inc_unchecked(&sk->sk_drops);
75197 return -ENOBUFS;
75198 }
75199
75200 @@ -371,7 +371,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
75201 skb_dst_force(skb);
75202
75203 spin_lock_irqsave(&list->lock, flags);
75204 - skb->dropcount = atomic_read(&sk->sk_drops);
75205 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
75206 __skb_queue_tail(list, skb);
75207 spin_unlock_irqrestore(&list->lock, flags);
75208
75209 @@ -391,7 +391,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
75210 skb->dev = NULL;
75211
75212 if (sk_rcvqueues_full(sk, skb)) {
75213 - atomic_inc(&sk->sk_drops);
75214 + atomic_inc_unchecked(&sk->sk_drops);
75215 goto discard_and_relse;
75216 }
75217 if (nested)
75218 @@ -409,7 +409,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
75219 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
75220 } else if (sk_add_backlog(sk, skb)) {
75221 bh_unlock_sock(sk);
75222 - atomic_inc(&sk->sk_drops);
75223 + atomic_inc_unchecked(&sk->sk_drops);
75224 goto discard_and_relse;
75225 }
75226
75227 @@ -974,7 +974,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
75228 if (len > sizeof(peercred))
75229 len = sizeof(peercred);
75230 cred_to_ucred(sk->sk_peer_pid, sk->sk_peer_cred, &peercred);
75231 - if (copy_to_user(optval, &peercred, len))
75232 + if (len > sizeof(peercred) || copy_to_user(optval, &peercred, len))
75233 return -EFAULT;
75234 goto lenout;
75235 }
75236 @@ -987,7 +987,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
75237 return -ENOTCONN;
75238 if (lv < len)
75239 return -EINVAL;
75240 - if (copy_to_user(optval, address, len))
75241 + if (len > sizeof(address) || copy_to_user(optval, address, len))
75242 return -EFAULT;
75243 goto lenout;
75244 }
75245 @@ -1024,7 +1024,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
75246
75247 if (len > lv)
75248 len = lv;
75249 - if (copy_to_user(optval, &v, len))
75250 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
75251 return -EFAULT;
75252 lenout:
75253 if (put_user(len, optlen))
75254 @@ -2108,7 +2108,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
75255 */
75256 smp_wmb();
75257 atomic_set(&sk->sk_refcnt, 1);
75258 - atomic_set(&sk->sk_drops, 0);
75259 + atomic_set_unchecked(&sk->sk_drops, 0);
75260 }
75261 EXPORT_SYMBOL(sock_init_data);
75262
75263 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
75264 index b9868e1..849f809 100644
75265 --- a/net/core/sock_diag.c
75266 +++ b/net/core/sock_diag.c
75267 @@ -16,20 +16,27 @@ static DEFINE_MUTEX(sock_diag_table_mutex);
75268
75269 int sock_diag_check_cookie(void *sk, __u32 *cookie)
75270 {
75271 +#ifndef CONFIG_GRKERNSEC_HIDESYM
75272 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
75273 cookie[1] != INET_DIAG_NOCOOKIE) &&
75274 ((u32)(unsigned long)sk != cookie[0] ||
75275 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
75276 return -ESTALE;
75277 else
75278 +#endif
75279 return 0;
75280 }
75281 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
75282
75283 void sock_diag_save_cookie(void *sk, __u32 *cookie)
75284 {
75285 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75286 + cookie[0] = 0;
75287 + cookie[1] = 0;
75288 +#else
75289 cookie[0] = (u32)(unsigned long)sk;
75290 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
75291 +#endif
75292 }
75293 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
75294
75295 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
75296 index 02e75d1..9a57a7c 100644
75297 --- a/net/decnet/sysctl_net_decnet.c
75298 +++ b/net/decnet/sysctl_net_decnet.c
75299 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
75300
75301 if (len > *lenp) len = *lenp;
75302
75303 - if (copy_to_user(buffer, addr, len))
75304 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
75305 return -EFAULT;
75306
75307 *lenp = len;
75308 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
75309
75310 if (len > *lenp) len = *lenp;
75311
75312 - if (copy_to_user(buffer, devname, len))
75313 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
75314 return -EFAULT;
75315
75316 *lenp = len;
75317 diff --git a/net/econet/Kconfig b/net/econet/Kconfig
75318 index 39a2d29..f39c0fe 100644
75319 --- a/net/econet/Kconfig
75320 +++ b/net/econet/Kconfig
75321 @@ -4,7 +4,7 @@
75322
75323 config ECONET
75324 tristate "Acorn Econet/AUN protocols (EXPERIMENTAL)"
75325 - depends on EXPERIMENTAL && INET
75326 + depends on EXPERIMENTAL && INET && BROKEN
75327 ---help---
75328 Econet is a fairly old and slow networking protocol mainly used by
75329 Acorn computers to access file and print servers. It uses native
75330 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
75331 index 92fc5f6..b790d91 100644
75332 --- a/net/ipv4/fib_frontend.c
75333 +++ b/net/ipv4/fib_frontend.c
75334 @@ -970,12 +970,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
75335 #ifdef CONFIG_IP_ROUTE_MULTIPATH
75336 fib_sync_up(dev);
75337 #endif
75338 - atomic_inc(&net->ipv4.dev_addr_genid);
75339 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
75340 rt_cache_flush(dev_net(dev), -1);
75341 break;
75342 case NETDEV_DOWN:
75343 fib_del_ifaddr(ifa, NULL);
75344 - atomic_inc(&net->ipv4.dev_addr_genid);
75345 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
75346 if (ifa->ifa_dev->ifa_list == NULL) {
75347 /* Last address was deleted from this interface.
75348 * Disable IP.
75349 @@ -1011,7 +1011,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
75350 #ifdef CONFIG_IP_ROUTE_MULTIPATH
75351 fib_sync_up(dev);
75352 #endif
75353 - atomic_inc(&net->ipv4.dev_addr_genid);
75354 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
75355 rt_cache_flush(dev_net(dev), -1);
75356 break;
75357 case NETDEV_DOWN:
75358 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
75359 index 80106d8..232e898 100644
75360 --- a/net/ipv4/fib_semantics.c
75361 +++ b/net/ipv4/fib_semantics.c
75362 @@ -699,7 +699,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
75363 nh->nh_saddr = inet_select_addr(nh->nh_dev,
75364 nh->nh_gw,
75365 nh->nh_parent->fib_scope);
75366 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
75367 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
75368
75369 return nh->nh_saddr;
75370 }
75371 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
75372 index 984ec65..97ac518 100644
75373 --- a/net/ipv4/inet_hashtables.c
75374 +++ b/net/ipv4/inet_hashtables.c
75375 @@ -18,12 +18,15 @@
75376 #include <linux/sched.h>
75377 #include <linux/slab.h>
75378 #include <linux/wait.h>
75379 +#include <linux/security.h>
75380
75381 #include <net/inet_connection_sock.h>
75382 #include <net/inet_hashtables.h>
75383 #include <net/secure_seq.h>
75384 #include <net/ip.h>
75385
75386 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
75387 +
75388 /*
75389 * Allocate and initialize a new local port bind bucket.
75390 * The bindhash mutex for snum's hash chain must be held here.
75391 @@ -530,6 +533,8 @@ ok:
75392 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
75393 spin_unlock(&head->lock);
75394
75395 + gr_update_task_in_ip_table(current, inet_sk(sk));
75396 +
75397 if (tw) {
75398 inet_twsk_deschedule(tw, death_row);
75399 while (twrefcnt) {
75400 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
75401 index d4d61b6..b81aec8 100644
75402 --- a/net/ipv4/inetpeer.c
75403 +++ b/net/ipv4/inetpeer.c
75404 @@ -487,8 +487,8 @@ relookup:
75405 if (p) {
75406 p->daddr = *daddr;
75407 atomic_set(&p->refcnt, 1);
75408 - atomic_set(&p->rid, 0);
75409 - atomic_set(&p->ip_id_count,
75410 + atomic_set_unchecked(&p->rid, 0);
75411 + atomic_set_unchecked(&p->ip_id_count,
75412 (daddr->family == AF_INET) ?
75413 secure_ip_id(daddr->addr.a4) :
75414 secure_ipv6_id(daddr->addr.a6));
75415 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
75416 index 1f23a57..7180dfe 100644
75417 --- a/net/ipv4/ip_fragment.c
75418 +++ b/net/ipv4/ip_fragment.c
75419 @@ -316,7 +316,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
75420 return 0;
75421
75422 start = qp->rid;
75423 - end = atomic_inc_return(&peer->rid);
75424 + end = atomic_inc_return_unchecked(&peer->rid);
75425 qp->rid = end;
75426
75427 rc = qp->q.fragments && (end - start) > max;
75428 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
75429 index 8aa87c1..35c3248 100644
75430 --- a/net/ipv4/ip_sockglue.c
75431 +++ b/net/ipv4/ip_sockglue.c
75432 @@ -1112,7 +1112,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
75433 len = min_t(unsigned int, len, opt->optlen);
75434 if (put_user(len, optlen))
75435 return -EFAULT;
75436 - if (copy_to_user(optval, opt->__data, len))
75437 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
75438 + copy_to_user(optval, opt->__data, len))
75439 return -EFAULT;
75440 return 0;
75441 }
75442 @@ -1240,7 +1241,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
75443 if (sk->sk_type != SOCK_STREAM)
75444 return -ENOPROTOOPT;
75445
75446 - msg.msg_control = optval;
75447 + msg.msg_control = (void __force_kernel *)optval;
75448 msg.msg_controllen = len;
75449 msg.msg_flags = flags;
75450
75451 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
75452 index 6e412a6..6640538 100644
75453 --- a/net/ipv4/ipconfig.c
75454 +++ b/net/ipv4/ipconfig.c
75455 @@ -318,7 +318,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
75456
75457 mm_segment_t oldfs = get_fs();
75458 set_fs(get_ds());
75459 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
75460 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
75461 set_fs(oldfs);
75462 return res;
75463 }
75464 @@ -329,7 +329,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
75465
75466 mm_segment_t oldfs = get_fs();
75467 set_fs(get_ds());
75468 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
75469 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
75470 set_fs(oldfs);
75471 return res;
75472 }
75473 @@ -340,7 +340,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
75474
75475 mm_segment_t oldfs = get_fs();
75476 set_fs(get_ds());
75477 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
75478 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
75479 set_fs(oldfs);
75480 return res;
75481 }
75482 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
75483 index b072386..abdebcf 100644
75484 --- a/net/ipv4/ping.c
75485 +++ b/net/ipv4/ping.c
75486 @@ -838,7 +838,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
75487 sk_rmem_alloc_get(sp),
75488 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
75489 atomic_read(&sp->sk_refcnt), sp,
75490 - atomic_read(&sp->sk_drops), len);
75491 + atomic_read_unchecked(&sp->sk_drops), len);
75492 }
75493
75494 static int ping_seq_show(struct seq_file *seq, void *v)
75495 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
75496 index 3ccda5a..3c1e61d 100644
75497 --- a/net/ipv4/raw.c
75498 +++ b/net/ipv4/raw.c
75499 @@ -304,7 +304,7 @@ static int raw_rcv_skb(struct sock * sk, struct sk_buff * skb)
75500 int raw_rcv(struct sock *sk, struct sk_buff *skb)
75501 {
75502 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
75503 - atomic_inc(&sk->sk_drops);
75504 + atomic_inc_unchecked(&sk->sk_drops);
75505 kfree_skb(skb);
75506 return NET_RX_DROP;
75507 }
75508 @@ -742,16 +742,20 @@ static int raw_init(struct sock *sk)
75509
75510 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
75511 {
75512 + struct icmp_filter filter;
75513 +
75514 if (optlen > sizeof(struct icmp_filter))
75515 optlen = sizeof(struct icmp_filter);
75516 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
75517 + if (copy_from_user(&filter, optval, optlen))
75518 return -EFAULT;
75519 + raw_sk(sk)->filter = filter;
75520 return 0;
75521 }
75522
75523 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
75524 {
75525 int len, ret = -EFAULT;
75526 + struct icmp_filter filter;
75527
75528 if (get_user(len, optlen))
75529 goto out;
75530 @@ -761,8 +765,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
75531 if (len > sizeof(struct icmp_filter))
75532 len = sizeof(struct icmp_filter);
75533 ret = -EFAULT;
75534 - if (put_user(len, optlen) ||
75535 - copy_to_user(optval, &raw_sk(sk)->filter, len))
75536 + filter = raw_sk(sk)->filter;
75537 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
75538 goto out;
75539 ret = 0;
75540 out: return ret;
75541 @@ -990,7 +994,13 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
75542 sk_wmem_alloc_get(sp),
75543 sk_rmem_alloc_get(sp),
75544 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
75545 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
75546 + atomic_read(&sp->sk_refcnt),
75547 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75548 + NULL,
75549 +#else
75550 + sp,
75551 +#endif
75552 + atomic_read_unchecked(&sp->sk_drops));
75553 }
75554
75555 static int raw_seq_show(struct seq_file *seq, void *v)
75556 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
75557 index 0197747..7adb0dc 100644
75558 --- a/net/ipv4/route.c
75559 +++ b/net/ipv4/route.c
75560 @@ -311,7 +311,7 @@ static inline unsigned int rt_hash(__be32 daddr, __be32 saddr, int idx,
75561
75562 static inline int rt_genid(struct net *net)
75563 {
75564 - return atomic_read(&net->ipv4.rt_genid);
75565 + return atomic_read_unchecked(&net->ipv4.rt_genid);
75566 }
75567
75568 #ifdef CONFIG_PROC_FS
75569 @@ -935,7 +935,7 @@ static void rt_cache_invalidate(struct net *net)
75570 unsigned char shuffle;
75571
75572 get_random_bytes(&shuffle, sizeof(shuffle));
75573 - atomic_add(shuffle + 1U, &net->ipv4.rt_genid);
75574 + atomic_add_unchecked(shuffle + 1U, &net->ipv4.rt_genid);
75575 inetpeer_invalidate_tree(AF_INET);
75576 }
75577
75578 @@ -3010,7 +3010,7 @@ static int rt_fill_info(struct net *net,
75579 error = rt->dst.error;
75580 if (peer) {
75581 inet_peer_refcheck(rt->peer);
75582 - id = atomic_read(&peer->ip_id_count) & 0xffff;
75583 + id = atomic_read_unchecked(&peer->ip_id_count) & 0xffff;
75584 if (peer->tcp_ts_stamp) {
75585 ts = peer->tcp_ts;
75586 tsage = get_seconds() - peer->tcp_ts_stamp;
75587 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
75588 index fd54c5f..96d6407 100644
75589 --- a/net/ipv4/tcp_ipv4.c
75590 +++ b/net/ipv4/tcp_ipv4.c
75591 @@ -88,6 +88,9 @@ int sysctl_tcp_tw_reuse __read_mostly;
75592 int sysctl_tcp_low_latency __read_mostly;
75593 EXPORT_SYMBOL(sysctl_tcp_low_latency);
75594
75595 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
75596 +extern int grsec_enable_blackhole;
75597 +#endif
75598
75599 #ifdef CONFIG_TCP_MD5SIG
75600 static struct tcp_md5sig_key *tcp_v4_md5_do_lookup(struct sock *sk,
75601 @@ -1638,6 +1641,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
75602 return 0;
75603
75604 reset:
75605 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
75606 + if (!grsec_enable_blackhole)
75607 +#endif
75608 tcp_v4_send_reset(rsk, skb);
75609 discard:
75610 kfree_skb(skb);
75611 @@ -1700,12 +1706,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
75612 TCP_SKB_CB(skb)->sacked = 0;
75613
75614 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
75615 - if (!sk)
75616 + if (!sk) {
75617 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
75618 + ret = 1;
75619 +#endif
75620 goto no_tcp_socket;
75621 -
75622 + }
75623 process:
75624 - if (sk->sk_state == TCP_TIME_WAIT)
75625 + if (sk->sk_state == TCP_TIME_WAIT) {
75626 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
75627 + ret = 2;
75628 +#endif
75629 goto do_time_wait;
75630 + }
75631
75632 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
75633 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
75634 @@ -1755,6 +1768,10 @@ no_tcp_socket:
75635 bad_packet:
75636 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
75637 } else {
75638 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
75639 + if (!grsec_enable_blackhole || (ret == 1 &&
75640 + (skb->dev->flags & IFF_LOOPBACK)))
75641 +#endif
75642 tcp_v4_send_reset(NULL, skb);
75643 }
75644
75645 @@ -2417,7 +2434,11 @@ static void get_openreq4(const struct sock *sk, const struct request_sock *req,
75646 0, /* non standard timer */
75647 0, /* open_requests have no inode */
75648 atomic_read(&sk->sk_refcnt),
75649 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75650 + NULL,
75651 +#else
75652 req,
75653 +#endif
75654 len);
75655 }
75656
75657 @@ -2467,7 +2488,12 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i, int *len)
75658 sock_i_uid(sk),
75659 icsk->icsk_probes_out,
75660 sock_i_ino(sk),
75661 - atomic_read(&sk->sk_refcnt), sk,
75662 + atomic_read(&sk->sk_refcnt),
75663 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75664 + NULL,
75665 +#else
75666 + sk,
75667 +#endif
75668 jiffies_to_clock_t(icsk->icsk_rto),
75669 jiffies_to_clock_t(icsk->icsk_ack.ato),
75670 (icsk->icsk_ack.quick << 1) | icsk->icsk_ack.pingpong,
75671 @@ -2495,7 +2521,13 @@ static void get_timewait4_sock(const struct inet_timewait_sock *tw,
75672 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %pK%n",
75673 i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
75674 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
75675 - atomic_read(&tw->tw_refcnt), tw, len);
75676 + atomic_read(&tw->tw_refcnt),
75677 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75678 + NULL,
75679 +#else
75680 + tw,
75681 +#endif
75682 + len);
75683 }
75684
75685 #define TMPSZ 150
75686 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
75687 index 550e755..25721b3 100644
75688 --- a/net/ipv4/tcp_minisocks.c
75689 +++ b/net/ipv4/tcp_minisocks.c
75690 @@ -27,6 +27,10 @@
75691 #include <net/inet_common.h>
75692 #include <net/xfrm.h>
75693
75694 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
75695 +extern int grsec_enable_blackhole;
75696 +#endif
75697 +
75698 int sysctl_tcp_syncookies __read_mostly = 1;
75699 EXPORT_SYMBOL(sysctl_tcp_syncookies);
75700
75701 @@ -753,6 +757,10 @@ listen_overflow:
75702
75703 embryonic_reset:
75704 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_EMBRYONICRSTS);
75705 +
75706 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
75707 + if (!grsec_enable_blackhole)
75708 +#endif
75709 if (!(flg & TCP_FLAG_RST))
75710 req->rsk_ops->send_reset(sk, skb);
75711
75712 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
75713 index 85ee7eb..53277ab 100644
75714 --- a/net/ipv4/tcp_probe.c
75715 +++ b/net/ipv4/tcp_probe.c
75716 @@ -202,7 +202,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
75717 if (cnt + width >= len)
75718 break;
75719
75720 - if (copy_to_user(buf + cnt, tbuf, width))
75721 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
75722 return -EFAULT;
75723 cnt += width;
75724 }
75725 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
75726 index cd2e072..1fffee2 100644
75727 --- a/net/ipv4/tcp_timer.c
75728 +++ b/net/ipv4/tcp_timer.c
75729 @@ -22,6 +22,10 @@
75730 #include <linux/gfp.h>
75731 #include <net/tcp.h>
75732
75733 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
75734 +extern int grsec_lastack_retries;
75735 +#endif
75736 +
75737 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
75738 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
75739 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
75740 @@ -196,6 +200,13 @@ static int tcp_write_timeout(struct sock *sk)
75741 }
75742 }
75743
75744 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
75745 + if ((sk->sk_state == TCP_LAST_ACK) &&
75746 + (grsec_lastack_retries > 0) &&
75747 + (grsec_lastack_retries < retry_until))
75748 + retry_until = grsec_lastack_retries;
75749 +#endif
75750 +
75751 if (retransmits_timed_out(sk, retry_until,
75752 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
75753 /* Has it gone just too far? */
75754 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
75755 index 5d075b5..d907d5f 100644
75756 --- a/net/ipv4/udp.c
75757 +++ b/net/ipv4/udp.c
75758 @@ -86,6 +86,7 @@
75759 #include <linux/types.h>
75760 #include <linux/fcntl.h>
75761 #include <linux/module.h>
75762 +#include <linux/security.h>
75763 #include <linux/socket.h>
75764 #include <linux/sockios.h>
75765 #include <linux/igmp.h>
75766 @@ -108,6 +109,10 @@
75767 #include <trace/events/udp.h>
75768 #include "udp_impl.h"
75769
75770 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
75771 +extern int grsec_enable_blackhole;
75772 +#endif
75773 +
75774 struct udp_table udp_table __read_mostly;
75775 EXPORT_SYMBOL(udp_table);
75776
75777 @@ -566,6 +571,9 @@ found:
75778 return s;
75779 }
75780
75781 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
75782 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
75783 +
75784 /*
75785 * This routine is called by the ICMP module when it gets some
75786 * sort of error condition. If err < 0 then the socket should
75787 @@ -857,9 +865,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
75788 dport = usin->sin_port;
75789 if (dport == 0)
75790 return -EINVAL;
75791 +
75792 + err = gr_search_udp_sendmsg(sk, usin);
75793 + if (err)
75794 + return err;
75795 } else {
75796 if (sk->sk_state != TCP_ESTABLISHED)
75797 return -EDESTADDRREQ;
75798 +
75799 + err = gr_search_udp_sendmsg(sk, NULL);
75800 + if (err)
75801 + return err;
75802 +
75803 daddr = inet->inet_daddr;
75804 dport = inet->inet_dport;
75805 /* Open fast path for connected socket.
75806 @@ -1100,7 +1117,7 @@ static unsigned int first_packet_length(struct sock *sk)
75807 udp_lib_checksum_complete(skb)) {
75808 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
75809 IS_UDPLITE(sk));
75810 - atomic_inc(&sk->sk_drops);
75811 + atomic_inc_unchecked(&sk->sk_drops);
75812 __skb_unlink(skb, rcvq);
75813 __skb_queue_tail(&list_kill, skb);
75814 }
75815 @@ -1186,6 +1203,10 @@ try_again:
75816 if (!skb)
75817 goto out;
75818
75819 + err = gr_search_udp_recvmsg(sk, skb);
75820 + if (err)
75821 + goto out_free;
75822 +
75823 ulen = skb->len - sizeof(struct udphdr);
75824 copied = len;
75825 if (copied > ulen)
75826 @@ -1489,7 +1510,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
75827
75828 drop:
75829 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
75830 - atomic_inc(&sk->sk_drops);
75831 + atomic_inc_unchecked(&sk->sk_drops);
75832 kfree_skb(skb);
75833 return -1;
75834 }
75835 @@ -1508,7 +1529,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
75836 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
75837
75838 if (!skb1) {
75839 - atomic_inc(&sk->sk_drops);
75840 + atomic_inc_unchecked(&sk->sk_drops);
75841 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
75842 IS_UDPLITE(sk));
75843 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
75844 @@ -1677,6 +1698,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
75845 goto csum_error;
75846
75847 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
75848 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
75849 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
75850 +#endif
75851 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
75852
75853 /*
75854 @@ -2100,8 +2124,13 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
75855 sk_wmem_alloc_get(sp),
75856 sk_rmem_alloc_get(sp),
75857 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
75858 - atomic_read(&sp->sk_refcnt), sp,
75859 - atomic_read(&sp->sk_drops), len);
75860 + atomic_read(&sp->sk_refcnt),
75861 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75862 + NULL,
75863 +#else
75864 + sp,
75865 +#endif
75866 + atomic_read_unchecked(&sp->sk_drops), len);
75867 }
75868
75869 int udp4_seq_show(struct seq_file *seq, void *v)
75870 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
75871 index 6b8ebc5..1d624f4 100644
75872 --- a/net/ipv6/addrconf.c
75873 +++ b/net/ipv6/addrconf.c
75874 @@ -2145,7 +2145,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
75875 p.iph.ihl = 5;
75876 p.iph.protocol = IPPROTO_IPV6;
75877 p.iph.ttl = 64;
75878 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
75879 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
75880
75881 if (ops->ndo_do_ioctl) {
75882 mm_segment_t oldfs = get_fs();
75883 diff --git a/net/ipv6/inet6_connection_sock.c b/net/ipv6/inet6_connection_sock.c
75884 index 02dd203..e03fcc9 100644
75885 --- a/net/ipv6/inet6_connection_sock.c
75886 +++ b/net/ipv6/inet6_connection_sock.c
75887 @@ -178,7 +178,7 @@ void __inet6_csk_dst_store(struct sock *sk, struct dst_entry *dst,
75888 #ifdef CONFIG_XFRM
75889 {
75890 struct rt6_info *rt = (struct rt6_info *)dst;
75891 - rt->rt6i_flow_cache_genid = atomic_read(&flow_cache_genid);
75892 + rt->rt6i_flow_cache_genid = atomic_read_unchecked(&flow_cache_genid);
75893 }
75894 #endif
75895 }
75896 @@ -193,7 +193,7 @@ struct dst_entry *__inet6_csk_dst_check(struct sock *sk, u32 cookie)
75897 #ifdef CONFIG_XFRM
75898 if (dst) {
75899 struct rt6_info *rt = (struct rt6_info *)dst;
75900 - if (rt->rt6i_flow_cache_genid != atomic_read(&flow_cache_genid)) {
75901 + if (rt->rt6i_flow_cache_genid != atomic_read_unchecked(&flow_cache_genid)) {
75902 __sk_dst_reset(sk);
75903 dst = NULL;
75904 }
75905 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
75906 index 18a2719..779f36a 100644
75907 --- a/net/ipv6/ipv6_sockglue.c
75908 +++ b/net/ipv6/ipv6_sockglue.c
75909 @@ -960,7 +960,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
75910 if (sk->sk_type != SOCK_STREAM)
75911 return -ENOPROTOOPT;
75912
75913 - msg.msg_control = optval;
75914 + msg.msg_control = (void __force_kernel *)optval;
75915 msg.msg_controllen = len;
75916 msg.msg_flags = flags;
75917
75918 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
75919 index d02f7e4..2d2a0f1 100644
75920 --- a/net/ipv6/raw.c
75921 +++ b/net/ipv6/raw.c
75922 @@ -377,7 +377,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
75923 {
75924 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
75925 skb_checksum_complete(skb)) {
75926 - atomic_inc(&sk->sk_drops);
75927 + atomic_inc_unchecked(&sk->sk_drops);
75928 kfree_skb(skb);
75929 return NET_RX_DROP;
75930 }
75931 @@ -405,7 +405,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
75932 struct raw6_sock *rp = raw6_sk(sk);
75933
75934 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
75935 - atomic_inc(&sk->sk_drops);
75936 + atomic_inc_unchecked(&sk->sk_drops);
75937 kfree_skb(skb);
75938 return NET_RX_DROP;
75939 }
75940 @@ -429,7 +429,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
75941
75942 if (inet->hdrincl) {
75943 if (skb_checksum_complete(skb)) {
75944 - atomic_inc(&sk->sk_drops);
75945 + atomic_inc_unchecked(&sk->sk_drops);
75946 kfree_skb(skb);
75947 return NET_RX_DROP;
75948 }
75949 @@ -602,7 +602,7 @@ out:
75950 return err;
75951 }
75952
75953 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
75954 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
75955 struct flowi6 *fl6, struct dst_entry **dstp,
75956 unsigned int flags)
75957 {
75958 @@ -912,12 +912,15 @@ do_confirm:
75959 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
75960 char __user *optval, int optlen)
75961 {
75962 + struct icmp6_filter filter;
75963 +
75964 switch (optname) {
75965 case ICMPV6_FILTER:
75966 if (optlen > sizeof(struct icmp6_filter))
75967 optlen = sizeof(struct icmp6_filter);
75968 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
75969 + if (copy_from_user(&filter, optval, optlen))
75970 return -EFAULT;
75971 + raw6_sk(sk)->filter = filter;
75972 return 0;
75973 default:
75974 return -ENOPROTOOPT;
75975 @@ -930,6 +933,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
75976 char __user *optval, int __user *optlen)
75977 {
75978 int len;
75979 + struct icmp6_filter filter;
75980
75981 switch (optname) {
75982 case ICMPV6_FILTER:
75983 @@ -941,7 +945,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
75984 len = sizeof(struct icmp6_filter);
75985 if (put_user(len, optlen))
75986 return -EFAULT;
75987 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
75988 + filter = raw6_sk(sk)->filter;
75989 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
75990 return -EFAULT;
75991 return 0;
75992 default:
75993 @@ -1248,7 +1253,13 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
75994 0, 0L, 0,
75995 sock_i_uid(sp), 0,
75996 sock_i_ino(sp),
75997 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
75998 + atomic_read(&sp->sk_refcnt),
75999 +#ifdef CONFIG_GRKERNSEC_HIDESYM
76000 + NULL,
76001 +#else
76002 + sp,
76003 +#endif
76004 + atomic_read_unchecked(&sp->sk_drops));
76005 }
76006
76007 static int raw6_seq_show(struct seq_file *seq, void *v)
76008 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
76009 index a89ca8d..12e66b0 100644
76010 --- a/net/ipv6/tcp_ipv6.c
76011 +++ b/net/ipv6/tcp_ipv6.c
76012 @@ -94,6 +94,10 @@ static struct tcp_md5sig_key *tcp_v6_md5_do_lookup(struct sock *sk,
76013 }
76014 #endif
76015
76016 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
76017 +extern int grsec_enable_blackhole;
76018 +#endif
76019 +
76020 static void tcp_v6_hash(struct sock *sk)
76021 {
76022 if (sk->sk_state != TCP_CLOSE) {
76023 @@ -1654,6 +1658,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
76024 return 0;
76025
76026 reset:
76027 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
76028 + if (!grsec_enable_blackhole)
76029 +#endif
76030 tcp_v6_send_reset(sk, skb);
76031 discard:
76032 if (opt_skb)
76033 @@ -1733,12 +1740,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
76034 TCP_SKB_CB(skb)->sacked = 0;
76035
76036 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
76037 - if (!sk)
76038 + if (!sk) {
76039 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
76040 + ret = 1;
76041 +#endif
76042 goto no_tcp_socket;
76043 + }
76044
76045 process:
76046 - if (sk->sk_state == TCP_TIME_WAIT)
76047 + if (sk->sk_state == TCP_TIME_WAIT) {
76048 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
76049 + ret = 2;
76050 +#endif
76051 goto do_time_wait;
76052 + }
76053
76054 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
76055 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
76056 @@ -1786,6 +1801,10 @@ no_tcp_socket:
76057 bad_packet:
76058 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
76059 } else {
76060 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
76061 + if (!grsec_enable_blackhole || (ret == 1 &&
76062 + (skb->dev->flags & IFF_LOOPBACK)))
76063 +#endif
76064 tcp_v6_send_reset(NULL, skb);
76065 }
76066
76067 @@ -2047,7 +2066,13 @@ static void get_openreq6(struct seq_file *seq,
76068 uid,
76069 0, /* non standard timer */
76070 0, /* open_requests have no inode */
76071 - 0, req);
76072 + 0,
76073 +#ifdef CONFIG_GRKERNSEC_HIDESYM
76074 + NULL
76075 +#else
76076 + req
76077 +#endif
76078 + );
76079 }
76080
76081 static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
76082 @@ -2097,7 +2122,12 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
76083 sock_i_uid(sp),
76084 icsk->icsk_probes_out,
76085 sock_i_ino(sp),
76086 - atomic_read(&sp->sk_refcnt), sp,
76087 + atomic_read(&sp->sk_refcnt),
76088 +#ifdef CONFIG_GRKERNSEC_HIDESYM
76089 + NULL,
76090 +#else
76091 + sp,
76092 +#endif
76093 jiffies_to_clock_t(icsk->icsk_rto),
76094 jiffies_to_clock_t(icsk->icsk_ack.ato),
76095 (icsk->icsk_ack.quick << 1 ) | icsk->icsk_ack.pingpong,
76096 @@ -2132,7 +2162,13 @@ static void get_timewait6_sock(struct seq_file *seq,
76097 dest->s6_addr32[2], dest->s6_addr32[3], destp,
76098 tw->tw_substate, 0, 0,
76099 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
76100 - atomic_read(&tw->tw_refcnt), tw);
76101 + atomic_read(&tw->tw_refcnt),
76102 +#ifdef CONFIG_GRKERNSEC_HIDESYM
76103 + NULL
76104 +#else
76105 + tw
76106 +#endif
76107 + );
76108 }
76109
76110 static int tcp6_seq_show(struct seq_file *seq, void *v)
76111 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
76112 index 4f96b5c..75543d7 100644
76113 --- a/net/ipv6/udp.c
76114 +++ b/net/ipv6/udp.c
76115 @@ -50,6 +50,10 @@
76116 #include <linux/seq_file.h>
76117 #include "udp_impl.h"
76118
76119 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
76120 +extern int grsec_enable_blackhole;
76121 +#endif
76122 +
76123 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
76124 {
76125 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
76126 @@ -551,7 +555,7 @@ int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
76127
76128 return 0;
76129 drop:
76130 - atomic_inc(&sk->sk_drops);
76131 + atomic_inc_unchecked(&sk->sk_drops);
76132 drop_no_sk_drops_inc:
76133 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
76134 kfree_skb(skb);
76135 @@ -627,7 +631,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
76136 continue;
76137 }
76138 drop:
76139 - atomic_inc(&sk->sk_drops);
76140 + atomic_inc_unchecked(&sk->sk_drops);
76141 UDP6_INC_STATS_BH(sock_net(sk),
76142 UDP_MIB_RCVBUFERRORS, IS_UDPLITE(sk));
76143 UDP6_INC_STATS_BH(sock_net(sk),
76144 @@ -782,6 +786,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
76145 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS,
76146 proto == IPPROTO_UDPLITE);
76147
76148 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
76149 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
76150 +#endif
76151 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
76152
76153 kfree_skb(skb);
76154 @@ -798,7 +805,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
76155 if (!sock_owned_by_user(sk))
76156 udpv6_queue_rcv_skb(sk, skb);
76157 else if (sk_add_backlog(sk, skb)) {
76158 - atomic_inc(&sk->sk_drops);
76159 + atomic_inc_unchecked(&sk->sk_drops);
76160 bh_unlock_sock(sk);
76161 sock_put(sk);
76162 goto discard;
76163 @@ -1410,8 +1417,13 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
76164 0, 0L, 0,
76165 sock_i_uid(sp), 0,
76166 sock_i_ino(sp),
76167 - atomic_read(&sp->sk_refcnt), sp,
76168 - atomic_read(&sp->sk_drops));
76169 + atomic_read(&sp->sk_refcnt),
76170 +#ifdef CONFIG_GRKERNSEC_HIDESYM
76171 + NULL,
76172 +#else
76173 + sp,
76174 +#endif
76175 + atomic_read_unchecked(&sp->sk_drops));
76176 }
76177
76178 int udp6_seq_show(struct seq_file *seq, void *v)
76179 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
76180 index 253695d..9481ce8 100644
76181 --- a/net/irda/ircomm/ircomm_tty.c
76182 +++ b/net/irda/ircomm/ircomm_tty.c
76183 @@ -282,16 +282,16 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
76184 add_wait_queue(&self->open_wait, &wait);
76185
76186 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
76187 - __FILE__,__LINE__, tty->driver->name, self->open_count );
76188 + __FILE__,__LINE__, tty->driver->name, local_read(&self->open_count) );
76189
76190 /* As far as I can see, we protect open_count - Jean II */
76191 spin_lock_irqsave(&self->spinlock, flags);
76192 if (!tty_hung_up_p(filp)) {
76193 extra_count = 1;
76194 - self->open_count--;
76195 + local_dec(&self->open_count);
76196 }
76197 spin_unlock_irqrestore(&self->spinlock, flags);
76198 - self->blocked_open++;
76199 + local_inc(&self->blocked_open);
76200
76201 while (1) {
76202 if (tty->termios->c_cflag & CBAUD) {
76203 @@ -331,7 +331,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
76204 }
76205
76206 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
76207 - __FILE__,__LINE__, tty->driver->name, self->open_count );
76208 + __FILE__,__LINE__, tty->driver->name, local_read(&self->open_count) );
76209
76210 schedule();
76211 }
76212 @@ -342,13 +342,13 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
76213 if (extra_count) {
76214 /* ++ is not atomic, so this should be protected - Jean II */
76215 spin_lock_irqsave(&self->spinlock, flags);
76216 - self->open_count++;
76217 + local_inc(&self->open_count);
76218 spin_unlock_irqrestore(&self->spinlock, flags);
76219 }
76220 - self->blocked_open--;
76221 + local_dec(&self->blocked_open);
76222
76223 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
76224 - __FILE__,__LINE__, tty->driver->name, self->open_count);
76225 + __FILE__,__LINE__, tty->driver->name, local_read(&self->open_count));
76226
76227 if (!retval)
76228 self->flags |= ASYNC_NORMAL_ACTIVE;
76229 @@ -417,14 +417,14 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
76230 }
76231 /* ++ is not atomic, so this should be protected - Jean II */
76232 spin_lock_irqsave(&self->spinlock, flags);
76233 - self->open_count++;
76234 + local_inc(&self->open_count);
76235
76236 tty->driver_data = self;
76237 self->tty = tty;
76238 spin_unlock_irqrestore(&self->spinlock, flags);
76239
76240 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
76241 - self->line, self->open_count);
76242 + self->line, local_read(&self->open_count));
76243
76244 /* Not really used by us, but lets do it anyway */
76245 self->tty->low_latency = (self->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
76246 @@ -510,7 +510,7 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
76247 return;
76248 }
76249
76250 - if ((tty->count == 1) && (self->open_count != 1)) {
76251 + if ((tty->count == 1) && (local_read(&self->open_count) != 1)) {
76252 /*
76253 * Uh, oh. tty->count is 1, which means that the tty
76254 * structure will be freed. state->count should always
76255 @@ -520,16 +520,16 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
76256 */
76257 IRDA_DEBUG(0, "%s(), bad serial port count; "
76258 "tty->count is 1, state->count is %d\n", __func__ ,
76259 - self->open_count);
76260 - self->open_count = 1;
76261 + local_read(&self->open_count));
76262 + local_set(&self->open_count, 1);
76263 }
76264
76265 - if (--self->open_count < 0) {
76266 + if (local_dec_return(&self->open_count) < 0) {
76267 IRDA_ERROR("%s(), bad serial port count for ttys%d: %d\n",
76268 - __func__, self->line, self->open_count);
76269 - self->open_count = 0;
76270 + __func__, self->line, local_read(&self->open_count));
76271 + local_set(&self->open_count, 0);
76272 }
76273 - if (self->open_count) {
76274 + if (local_read(&self->open_count)) {
76275 spin_unlock_irqrestore(&self->spinlock, flags);
76276
76277 IRDA_DEBUG(0, "%s(), open count > 0\n", __func__ );
76278 @@ -561,7 +561,7 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
76279 tty->closing = 0;
76280 self->tty = NULL;
76281
76282 - if (self->blocked_open) {
76283 + if (local_read(&self->blocked_open)) {
76284 if (self->close_delay)
76285 schedule_timeout_interruptible(self->close_delay);
76286 wake_up_interruptible(&self->open_wait);
76287 @@ -1013,7 +1013,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
76288 spin_lock_irqsave(&self->spinlock, flags);
76289 self->flags &= ~ASYNC_NORMAL_ACTIVE;
76290 self->tty = NULL;
76291 - self->open_count = 0;
76292 + local_set(&self->open_count, 0);
76293 spin_unlock_irqrestore(&self->spinlock, flags);
76294
76295 wake_up_interruptible(&self->open_wait);
76296 @@ -1360,7 +1360,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
76297 seq_putc(m, '\n');
76298
76299 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
76300 - seq_printf(m, "Open count: %d\n", self->open_count);
76301 + seq_printf(m, "Open count: %d\n", local_read(&self->open_count));
76302 seq_printf(m, "Max data size: %d\n", self->max_data_size);
76303 seq_printf(m, "Max header size: %d\n", self->max_header_size);
76304
76305 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
76306 index d5c5b8f..33beff0 100644
76307 --- a/net/iucv/af_iucv.c
76308 +++ b/net/iucv/af_iucv.c
76309 @@ -764,10 +764,10 @@ static int iucv_sock_autobind(struct sock *sk)
76310
76311 write_lock_bh(&iucv_sk_list.lock);
76312
76313 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
76314 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
76315 while (__iucv_get_sock_by_name(name)) {
76316 sprintf(name, "%08x",
76317 - atomic_inc_return(&iucv_sk_list.autobind_name));
76318 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
76319 }
76320
76321 write_unlock_bh(&iucv_sk_list.lock);
76322 diff --git a/net/key/af_key.c b/net/key/af_key.c
76323 index 11dbb22..c20f667 100644
76324 --- a/net/key/af_key.c
76325 +++ b/net/key/af_key.c
76326 @@ -3016,10 +3016,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
76327 static u32 get_acqseq(void)
76328 {
76329 u32 res;
76330 - static atomic_t acqseq;
76331 + static atomic_unchecked_t acqseq;
76332
76333 do {
76334 - res = atomic_inc_return(&acqseq);
76335 + res = atomic_inc_return_unchecked(&acqseq);
76336 } while (!res);
76337 return res;
76338 }
76339 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
76340 index 2f0642d..e5c6fba 100644
76341 --- a/net/mac80211/ieee80211_i.h
76342 +++ b/net/mac80211/ieee80211_i.h
76343 @@ -28,6 +28,7 @@
76344 #include <net/ieee80211_radiotap.h>
76345 #include <net/cfg80211.h>
76346 #include <net/mac80211.h>
76347 +#include <asm/local.h>
76348 #include "key.h"
76349 #include "sta_info.h"
76350
76351 @@ -781,7 +782,7 @@ struct ieee80211_local {
76352 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
76353 spinlock_t queue_stop_reason_lock;
76354
76355 - int open_count;
76356 + local_t open_count;
76357 int monitors, cooked_mntrs;
76358 /* number of interfaces with corresponding FIF_ flags */
76359 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
76360 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
76361 index 8e2137b..2974283 100644
76362 --- a/net/mac80211/iface.c
76363 +++ b/net/mac80211/iface.c
76364 @@ -222,7 +222,7 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up)
76365 break;
76366 }
76367
76368 - if (local->open_count == 0) {
76369 + if (local_read(&local->open_count) == 0) {
76370 res = drv_start(local);
76371 if (res)
76372 goto err_del_bss;
76373 @@ -246,7 +246,7 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up)
76374 memcpy(dev->perm_addr, dev->dev_addr, ETH_ALEN);
76375
76376 if (!is_valid_ether_addr(dev->dev_addr)) {
76377 - if (!local->open_count)
76378 + if (!local_read(&local->open_count))
76379 drv_stop(local);
76380 return -EADDRNOTAVAIL;
76381 }
76382 @@ -347,7 +347,7 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up)
76383 mutex_unlock(&local->mtx);
76384
76385 if (coming_up)
76386 - local->open_count++;
76387 + local_inc(&local->open_count);
76388
76389 if (hw_reconf_flags)
76390 ieee80211_hw_config(local, hw_reconf_flags);
76391 @@ -360,7 +360,7 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up)
76392 err_del_interface:
76393 drv_remove_interface(local, sdata);
76394 err_stop:
76395 - if (!local->open_count)
76396 + if (!local_read(&local->open_count))
76397 drv_stop(local);
76398 err_del_bss:
76399 sdata->bss = NULL;
76400 @@ -489,7 +489,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
76401 }
76402
76403 if (going_down)
76404 - local->open_count--;
76405 + local_dec(&local->open_count);
76406
76407 switch (sdata->vif.type) {
76408 case NL80211_IFTYPE_AP_VLAN:
76409 @@ -548,7 +548,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
76410
76411 ieee80211_recalc_ps(local, -1);
76412
76413 - if (local->open_count == 0) {
76414 + if (local_read(&local->open_count) == 0) {
76415 if (local->ops->napi_poll)
76416 napi_disable(&local->napi);
76417 ieee80211_clear_tx_pending(local);
76418 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
76419 index b142bd4..a651749 100644
76420 --- a/net/mac80211/main.c
76421 +++ b/net/mac80211/main.c
76422 @@ -166,7 +166,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
76423 local->hw.conf.power_level = power;
76424 }
76425
76426 - if (changed && local->open_count) {
76427 + if (changed && local_read(&local->open_count)) {
76428 ret = drv_config(local, changed);
76429 /*
76430 * Goal:
76431 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
76432 index 596efaf..8f1911f 100644
76433 --- a/net/mac80211/pm.c
76434 +++ b/net/mac80211/pm.c
76435 @@ -34,7 +34,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
76436 struct ieee80211_sub_if_data *sdata;
76437 struct sta_info *sta;
76438
76439 - if (!local->open_count)
76440 + if (!local_read(&local->open_count))
76441 goto suspend;
76442
76443 ieee80211_scan_cancel(local);
76444 @@ -72,7 +72,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
76445 cancel_work_sync(&local->dynamic_ps_enable_work);
76446 del_timer_sync(&local->dynamic_ps_timer);
76447
76448 - local->wowlan = wowlan && local->open_count;
76449 + local->wowlan = wowlan && local_read(&local->open_count);
76450 if (local->wowlan) {
76451 int err = drv_suspend(local, wowlan);
76452 if (err < 0) {
76453 @@ -129,7 +129,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
76454 }
76455
76456 /* stop hardware - this must stop RX */
76457 - if (local->open_count)
76458 + if (local_read(&local->open_count))
76459 ieee80211_stop_device(local);
76460
76461 suspend:
76462 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
76463 index f9b8e81..bb89b46 100644
76464 --- a/net/mac80211/rate.c
76465 +++ b/net/mac80211/rate.c
76466 @@ -401,7 +401,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
76467
76468 ASSERT_RTNL();
76469
76470 - if (local->open_count)
76471 + if (local_read(&local->open_count))
76472 return -EBUSY;
76473
76474 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
76475 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
76476 index c97a065..ff61928 100644
76477 --- a/net/mac80211/rc80211_pid_debugfs.c
76478 +++ b/net/mac80211/rc80211_pid_debugfs.c
76479 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
76480
76481 spin_unlock_irqrestore(&events->lock, status);
76482
76483 - if (copy_to_user(buf, pb, p))
76484 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
76485 return -EFAULT;
76486
76487 return p;
76488 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
76489 index 9919892..8c49803 100644
76490 --- a/net/mac80211/util.c
76491 +++ b/net/mac80211/util.c
76492 @@ -1143,7 +1143,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
76493 }
76494 #endif
76495 /* everything else happens only if HW was up & running */
76496 - if (!local->open_count)
76497 + if (!local_read(&local->open_count))
76498 goto wake_up;
76499
76500 /*
76501 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
76502 index f8ac4ef..b02560b 100644
76503 --- a/net/netfilter/Kconfig
76504 +++ b/net/netfilter/Kconfig
76505 @@ -806,6 +806,16 @@ config NETFILTER_XT_MATCH_ESP
76506
76507 To compile it as a module, choose M here. If unsure, say N.
76508
76509 +config NETFILTER_XT_MATCH_GRADM
76510 + tristate '"gradm" match support'
76511 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
76512 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
76513 + ---help---
76514 + The gradm match allows to match on grsecurity RBAC being enabled.
76515 + It is useful when iptables rules are applied early on bootup to
76516 + prevent connections to the machine (except from a trusted host)
76517 + while the RBAC system is disabled.
76518 +
76519 config NETFILTER_XT_MATCH_HASHLIMIT
76520 tristate '"hashlimit" match support'
76521 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
76522 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
76523 index 40f4c3d..0d5dd6b 100644
76524 --- a/net/netfilter/Makefile
76525 +++ b/net/netfilter/Makefile
76526 @@ -83,6 +83,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
76527 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
76528 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
76529 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
76530 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
76531 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
76532 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
76533 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
76534 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
76535 index 29fa5ba..8debc79 100644
76536 --- a/net/netfilter/ipvs/ip_vs_conn.c
76537 +++ b/net/netfilter/ipvs/ip_vs_conn.c
76538 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
76539 /* Increase the refcnt counter of the dest */
76540 atomic_inc(&dest->refcnt);
76541
76542 - conn_flags = atomic_read(&dest->conn_flags);
76543 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
76544 if (cp->protocol != IPPROTO_UDP)
76545 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
76546 /* Bind with the destination and its corresponding transmitter */
76547 @@ -869,7 +869,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
76548 atomic_set(&cp->refcnt, 1);
76549
76550 atomic_set(&cp->n_control, 0);
76551 - atomic_set(&cp->in_pkts, 0);
76552 + atomic_set_unchecked(&cp->in_pkts, 0);
76553
76554 atomic_inc(&ipvs->conn_count);
76555 if (flags & IP_VS_CONN_F_NO_CPORT)
76556 @@ -1149,7 +1149,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
76557
76558 /* Don't drop the entry if its number of incoming packets is not
76559 located in [0, 8] */
76560 - i = atomic_read(&cp->in_pkts);
76561 + i = atomic_read_unchecked(&cp->in_pkts);
76562 if (i > 8 || i < 0) return 0;
76563
76564 if (!todrop_rate[i]) return 0;
76565 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
76566 index 2555816..31492d9 100644
76567 --- a/net/netfilter/ipvs/ip_vs_core.c
76568 +++ b/net/netfilter/ipvs/ip_vs_core.c
76569 @@ -562,7 +562,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
76570 ret = cp->packet_xmit(skb, cp, pd->pp);
76571 /* do not touch skb anymore */
76572
76573 - atomic_inc(&cp->in_pkts);
76574 + atomic_inc_unchecked(&cp->in_pkts);
76575 ip_vs_conn_put(cp);
76576 return ret;
76577 }
76578 @@ -1611,7 +1611,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
76579 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
76580 pkts = sysctl_sync_threshold(ipvs);
76581 else
76582 - pkts = atomic_add_return(1, &cp->in_pkts);
76583 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
76584
76585 if ((ipvs->sync_state & IP_VS_STATE_MASTER) &&
76586 cp->protocol == IPPROTO_SCTP) {
76587 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
76588 index b3afe18..08ec940 100644
76589 --- a/net/netfilter/ipvs/ip_vs_ctl.c
76590 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
76591 @@ -788,7 +788,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
76592 ip_vs_rs_hash(ipvs, dest);
76593 write_unlock_bh(&ipvs->rs_lock);
76594 }
76595 - atomic_set(&dest->conn_flags, conn_flags);
76596 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
76597
76598 /* bind the service */
76599 if (!dest->svc) {
76600 @@ -2028,7 +2028,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
76601 " %-7s %-6d %-10d %-10d\n",
76602 &dest->addr.in6,
76603 ntohs(dest->port),
76604 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
76605 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
76606 atomic_read(&dest->weight),
76607 atomic_read(&dest->activeconns),
76608 atomic_read(&dest->inactconns));
76609 @@ -2039,7 +2039,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
76610 "%-7s %-6d %-10d %-10d\n",
76611 ntohl(dest->addr.ip),
76612 ntohs(dest->port),
76613 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
76614 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
76615 atomic_read(&dest->weight),
76616 atomic_read(&dest->activeconns),
76617 atomic_read(&dest->inactconns));
76618 @@ -2509,7 +2509,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
76619
76620 entry.addr = dest->addr.ip;
76621 entry.port = dest->port;
76622 - entry.conn_flags = atomic_read(&dest->conn_flags);
76623 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
76624 entry.weight = atomic_read(&dest->weight);
76625 entry.u_threshold = dest->u_threshold;
76626 entry.l_threshold = dest->l_threshold;
76627 @@ -3042,7 +3042,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
76628 NLA_PUT_U16(skb, IPVS_DEST_ATTR_PORT, dest->port);
76629
76630 NLA_PUT_U32(skb, IPVS_DEST_ATTR_FWD_METHOD,
76631 - atomic_read(&dest->conn_flags) & IP_VS_CONN_F_FWD_MASK);
76632 + atomic_read_unchecked(&dest->conn_flags) & IP_VS_CONN_F_FWD_MASK);
76633 NLA_PUT_U32(skb, IPVS_DEST_ATTR_WEIGHT, atomic_read(&dest->weight));
76634 NLA_PUT_U32(skb, IPVS_DEST_ATTR_U_THRESH, dest->u_threshold);
76635 NLA_PUT_U32(skb, IPVS_DEST_ATTR_L_THRESH, dest->l_threshold);
76636 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
76637 index 8a0d6d6..90ec197 100644
76638 --- a/net/netfilter/ipvs/ip_vs_sync.c
76639 +++ b/net/netfilter/ipvs/ip_vs_sync.c
76640 @@ -649,7 +649,7 @@ control:
76641 * i.e only increment in_pkts for Templates.
76642 */
76643 if (cp->flags & IP_VS_CONN_F_TEMPLATE) {
76644 - int pkts = atomic_add_return(1, &cp->in_pkts);
76645 + int pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
76646
76647 if (pkts % sysctl_sync_period(ipvs) != 1)
76648 return;
76649 @@ -795,7 +795,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
76650
76651 if (opt)
76652 memcpy(&cp->in_seq, opt, sizeof(*opt));
76653 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
76654 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
76655 cp->state = state;
76656 cp->old_state = cp->state;
76657 /*
76658 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
76659 index 7fd66de..e6fb361 100644
76660 --- a/net/netfilter/ipvs/ip_vs_xmit.c
76661 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
76662 @@ -1151,7 +1151,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
76663 else
76664 rc = NF_ACCEPT;
76665 /* do not touch skb anymore */
76666 - atomic_inc(&cp->in_pkts);
76667 + atomic_inc_unchecked(&cp->in_pkts);
76668 goto out;
76669 }
76670
76671 @@ -1272,7 +1272,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
76672 else
76673 rc = NF_ACCEPT;
76674 /* do not touch skb anymore */
76675 - atomic_inc(&cp->in_pkts);
76676 + atomic_inc_unchecked(&cp->in_pkts);
76677 goto out;
76678 }
76679
76680 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
76681 index 66b2c54..c7884e3 100644
76682 --- a/net/netfilter/nfnetlink_log.c
76683 +++ b/net/netfilter/nfnetlink_log.c
76684 @@ -70,7 +70,7 @@ struct nfulnl_instance {
76685 };
76686
76687 static DEFINE_SPINLOCK(instances_lock);
76688 -static atomic_t global_seq;
76689 +static atomic_unchecked_t global_seq;
76690
76691 #define INSTANCE_BUCKETS 16
76692 static struct hlist_head instance_table[INSTANCE_BUCKETS];
76693 @@ -502,7 +502,7 @@ __build_packet_message(struct nfulnl_instance *inst,
76694 /* global sequence number */
76695 if (inst->flags & NFULNL_CFG_F_SEQ_GLOBAL)
76696 NLA_PUT_BE32(inst->skb, NFULA_SEQ_GLOBAL,
76697 - htonl(atomic_inc_return(&global_seq)));
76698 + htonl(atomic_inc_return_unchecked(&global_seq)));
76699
76700 if (data_len) {
76701 struct nlattr *nla;
76702 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
76703 new file mode 100644
76704 index 0000000..6905327
76705 --- /dev/null
76706 +++ b/net/netfilter/xt_gradm.c
76707 @@ -0,0 +1,51 @@
76708 +/*
76709 + * gradm match for netfilter
76710 + * Copyright © Zbigniew Krzystolik, 2010
76711 + *
76712 + * This program is free software; you can redistribute it and/or modify
76713 + * it under the terms of the GNU General Public License; either version
76714 + * 2 or 3 as published by the Free Software Foundation.
76715 + */
76716 +#include <linux/module.h>
76717 +#include <linux/moduleparam.h>
76718 +#include <linux/skbuff.h>
76719 +#include <linux/netfilter/x_tables.h>
76720 +#include <linux/grsecurity.h>
76721 +#include <linux/netfilter/xt_gradm.h>
76722 +
76723 +static bool
76724 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
76725 +{
76726 + const struct xt_gradm_mtinfo *info = par->matchinfo;
76727 + bool retval = false;
76728 + if (gr_acl_is_enabled())
76729 + retval = true;
76730 + return retval ^ info->invflags;
76731 +}
76732 +
76733 +static struct xt_match gradm_mt_reg __read_mostly = {
76734 + .name = "gradm",
76735 + .revision = 0,
76736 + .family = NFPROTO_UNSPEC,
76737 + .match = gradm_mt,
76738 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
76739 + .me = THIS_MODULE,
76740 +};
76741 +
76742 +static int __init gradm_mt_init(void)
76743 +{
76744 + return xt_register_match(&gradm_mt_reg);
76745 +}
76746 +
76747 +static void __exit gradm_mt_exit(void)
76748 +{
76749 + xt_unregister_match(&gradm_mt_reg);
76750 +}
76751 +
76752 +module_init(gradm_mt_init);
76753 +module_exit(gradm_mt_exit);
76754 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
76755 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
76756 +MODULE_LICENSE("GPL");
76757 +MODULE_ALIAS("ipt_gradm");
76758 +MODULE_ALIAS("ip6t_gradm");
76759 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
76760 index 4fe4fb4..87a89e5 100644
76761 --- a/net/netfilter/xt_statistic.c
76762 +++ b/net/netfilter/xt_statistic.c
76763 @@ -19,7 +19,7 @@
76764 #include <linux/module.h>
76765
76766 struct xt_statistic_priv {
76767 - atomic_t count;
76768 + atomic_unchecked_t count;
76769 } ____cacheline_aligned_in_smp;
76770
76771 MODULE_LICENSE("GPL");
76772 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
76773 break;
76774 case XT_STATISTIC_MODE_NTH:
76775 do {
76776 - oval = atomic_read(&info->master->count);
76777 + oval = atomic_read_unchecked(&info->master->count);
76778 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
76779 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
76780 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
76781 if (nval == 0)
76782 ret = !ret;
76783 break;
76784 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
76785 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
76786 if (info->master == NULL)
76787 return -ENOMEM;
76788 - atomic_set(&info->master->count, info->u.nth.count);
76789 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
76790
76791 return 0;
76792 }
76793 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
76794 index 467af9c..8f415cc 100644
76795 --- a/net/netlink/af_netlink.c
76796 +++ b/net/netlink/af_netlink.c
76797 @@ -741,7 +741,7 @@ static void netlink_overrun(struct sock *sk)
76798 sk->sk_error_report(sk);
76799 }
76800 }
76801 - atomic_inc(&sk->sk_drops);
76802 + atomic_inc_unchecked(&sk->sk_drops);
76803 }
76804
76805 static struct sock *netlink_getsockbypid(struct sock *ssk, u32 pid)
76806 @@ -1997,7 +1997,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
76807 sk_wmem_alloc_get(s),
76808 nlk->cb,
76809 atomic_read(&s->sk_refcnt),
76810 - atomic_read(&s->sk_drops),
76811 + atomic_read_unchecked(&s->sk_drops),
76812 sock_i_ino(s)
76813 );
76814
76815 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
76816 index 7dab229..212156f 100644
76817 --- a/net/netrom/af_netrom.c
76818 +++ b/net/netrom/af_netrom.c
76819 @@ -839,6 +839,7 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
76820 struct sock *sk = sock->sk;
76821 struct nr_sock *nr = nr_sk(sk);
76822
76823 + memset(sax, 0, sizeof(*sax));
76824 lock_sock(sk);
76825 if (peer != 0) {
76826 if (sk->sk_state != TCP_ESTABLISHED) {
76827 @@ -853,7 +854,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
76828 *uaddr_len = sizeof(struct full_sockaddr_ax25);
76829 } else {
76830 sax->fsa_ax25.sax25_family = AF_NETROM;
76831 - sax->fsa_ax25.sax25_ndigis = 0;
76832 sax->fsa_ax25.sax25_call = nr->source_addr;
76833 *uaddr_len = sizeof(struct sockaddr_ax25);
76834 }
76835 diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
76836 index 2c03050..5cf68c1 100644
76837 --- a/net/openvswitch/datapath.c
76838 +++ b/net/openvswitch/datapath.c
76839 @@ -322,7 +322,7 @@ static int queue_userspace_packet(int dp_ifindex, struct sk_buff *skb,
76840 return -ENOMEM;
76841
76842 nskb = __vlan_put_tag(nskb, vlan_tx_tag_get(nskb));
76843 - if (!skb)
76844 + if (!nskb)
76845 return -ENOMEM;
76846
76847 nskb->vlan_tci = 0;
76848 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
76849 index 2dbb32b..a1b4722 100644
76850 --- a/net/packet/af_packet.c
76851 +++ b/net/packet/af_packet.c
76852 @@ -1676,7 +1676,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
76853
76854 spin_lock(&sk->sk_receive_queue.lock);
76855 po->stats.tp_packets++;
76856 - skb->dropcount = atomic_read(&sk->sk_drops);
76857 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
76858 __skb_queue_tail(&sk->sk_receive_queue, skb);
76859 spin_unlock(&sk->sk_receive_queue.lock);
76860 sk->sk_data_ready(sk, skb->len);
76861 @@ -1685,7 +1685,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
76862 drop_n_acct:
76863 spin_lock(&sk->sk_receive_queue.lock);
76864 po->stats.tp_drops++;
76865 - atomic_inc(&sk->sk_drops);
76866 + atomic_inc_unchecked(&sk->sk_drops);
76867 spin_unlock(&sk->sk_receive_queue.lock);
76868
76869 drop_n_restore:
76870 @@ -3271,7 +3271,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
76871 case PACKET_HDRLEN:
76872 if (len > sizeof(int))
76873 len = sizeof(int);
76874 - if (copy_from_user(&val, optval, len))
76875 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
76876 return -EFAULT;
76877 switch (val) {
76878 case TPACKET_V1:
76879 @@ -3321,7 +3321,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
76880
76881 if (put_user(len, optlen))
76882 return -EFAULT;
76883 - if (copy_to_user(optval, data, len))
76884 + if (len > sizeof(st) || copy_to_user(optval, data, len))
76885 return -EFAULT;
76886 return 0;
76887 }
76888 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
76889 index d65f699..05aa6ce 100644
76890 --- a/net/phonet/af_phonet.c
76891 +++ b/net/phonet/af_phonet.c
76892 @@ -41,7 +41,7 @@ static struct phonet_protocol *phonet_proto_get(unsigned int protocol)
76893 {
76894 struct phonet_protocol *pp;
76895
76896 - if (protocol >= PHONET_NPROTO)
76897 + if (protocol < 0 || protocol >= PHONET_NPROTO)
76898 return NULL;
76899
76900 rcu_read_lock();
76901 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
76902 {
76903 int err = 0;
76904
76905 - if (protocol >= PHONET_NPROTO)
76906 + if (protocol < 0 || protocol >= PHONET_NPROTO)
76907 return -EINVAL;
76908
76909 err = proto_register(pp->prot, 1);
76910 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
76911 index 9726fe6..fc4e3a4 100644
76912 --- a/net/phonet/pep.c
76913 +++ b/net/phonet/pep.c
76914 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
76915
76916 case PNS_PEP_CTRL_REQ:
76917 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
76918 - atomic_inc(&sk->sk_drops);
76919 + atomic_inc_unchecked(&sk->sk_drops);
76920 break;
76921 }
76922 __skb_pull(skb, 4);
76923 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
76924 }
76925
76926 if (pn->rx_credits == 0) {
76927 - atomic_inc(&sk->sk_drops);
76928 + atomic_inc_unchecked(&sk->sk_drops);
76929 err = -ENOBUFS;
76930 break;
76931 }
76932 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
76933 }
76934
76935 if (pn->rx_credits == 0) {
76936 - atomic_inc(&sk->sk_drops);
76937 + atomic_inc_unchecked(&sk->sk_drops);
76938 err = NET_RX_DROP;
76939 break;
76940 }
76941 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
76942 index 4c7eff3..59c727f 100644
76943 --- a/net/phonet/socket.c
76944 +++ b/net/phonet/socket.c
76945 @@ -613,8 +613,13 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
76946 pn->resource, sk->sk_state,
76947 sk_wmem_alloc_get(sk), sk_rmem_alloc_get(sk),
76948 sock_i_uid(sk), sock_i_ino(sk),
76949 - atomic_read(&sk->sk_refcnt), sk,
76950 - atomic_read(&sk->sk_drops), &len);
76951 + atomic_read(&sk->sk_refcnt),
76952 +#ifdef CONFIG_GRKERNSEC_HIDESYM
76953 + NULL,
76954 +#else
76955 + sk,
76956 +#endif
76957 + atomic_read_unchecked(&sk->sk_drops), &len);
76958 }
76959 seq_printf(seq, "%*s\n", 127 - len, "");
76960 return 0;
76961 diff --git a/net/rds/cong.c b/net/rds/cong.c
76962 index e5b65ac..f3b6fb7 100644
76963 --- a/net/rds/cong.c
76964 +++ b/net/rds/cong.c
76965 @@ -78,7 +78,7 @@
76966 * finds that the saved generation number is smaller than the global generation
76967 * number, it wakes up the process.
76968 */
76969 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
76970 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
76971
76972 /*
76973 * Congestion monitoring
76974 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
76975 rdsdebug("waking map %p for %pI4\n",
76976 map, &map->m_addr);
76977 rds_stats_inc(s_cong_update_received);
76978 - atomic_inc(&rds_cong_generation);
76979 + atomic_inc_unchecked(&rds_cong_generation);
76980 if (waitqueue_active(&map->m_waitq))
76981 wake_up(&map->m_waitq);
76982 if (waitqueue_active(&rds_poll_waitq))
76983 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
76984
76985 int rds_cong_updated_since(unsigned long *recent)
76986 {
76987 - unsigned long gen = atomic_read(&rds_cong_generation);
76988 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
76989
76990 if (likely(*recent == gen))
76991 return 0;
76992 diff --git a/net/rds/ib.h b/net/rds/ib.h
76993 index edfaaaf..8c89879 100644
76994 --- a/net/rds/ib.h
76995 +++ b/net/rds/ib.h
76996 @@ -128,7 +128,7 @@ struct rds_ib_connection {
76997 /* sending acks */
76998 unsigned long i_ack_flags;
76999 #ifdef KERNEL_HAS_ATOMIC64
77000 - atomic64_t i_ack_next; /* next ACK to send */
77001 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
77002 #else
77003 spinlock_t i_ack_lock; /* protect i_ack_next */
77004 u64 i_ack_next; /* next ACK to send */
77005 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
77006 index 51c8689..36c555f 100644
77007 --- a/net/rds/ib_cm.c
77008 +++ b/net/rds/ib_cm.c
77009 @@ -718,7 +718,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
77010 /* Clear the ACK state */
77011 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
77012 #ifdef KERNEL_HAS_ATOMIC64
77013 - atomic64_set(&ic->i_ack_next, 0);
77014 + atomic64_set_unchecked(&ic->i_ack_next, 0);
77015 #else
77016 ic->i_ack_next = 0;
77017 #endif
77018 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
77019 index e29e0ca..fa3a6a3 100644
77020 --- a/net/rds/ib_recv.c
77021 +++ b/net/rds/ib_recv.c
77022 @@ -592,7 +592,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
77023 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
77024 int ack_required)
77025 {
77026 - atomic64_set(&ic->i_ack_next, seq);
77027 + atomic64_set_unchecked(&ic->i_ack_next, seq);
77028 if (ack_required) {
77029 smp_mb__before_clear_bit();
77030 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
77031 @@ -604,7 +604,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
77032 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
77033 smp_mb__after_clear_bit();
77034
77035 - return atomic64_read(&ic->i_ack_next);
77036 + return atomic64_read_unchecked(&ic->i_ack_next);
77037 }
77038 #endif
77039
77040 diff --git a/net/rds/iw.h b/net/rds/iw.h
77041 index 04ce3b1..48119a6 100644
77042 --- a/net/rds/iw.h
77043 +++ b/net/rds/iw.h
77044 @@ -134,7 +134,7 @@ struct rds_iw_connection {
77045 /* sending acks */
77046 unsigned long i_ack_flags;
77047 #ifdef KERNEL_HAS_ATOMIC64
77048 - atomic64_t i_ack_next; /* next ACK to send */
77049 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
77050 #else
77051 spinlock_t i_ack_lock; /* protect i_ack_next */
77052 u64 i_ack_next; /* next ACK to send */
77053 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
77054 index 9556d28..f046d0e 100644
77055 --- a/net/rds/iw_cm.c
77056 +++ b/net/rds/iw_cm.c
77057 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
77058 /* Clear the ACK state */
77059 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
77060 #ifdef KERNEL_HAS_ATOMIC64
77061 - atomic64_set(&ic->i_ack_next, 0);
77062 + atomic64_set_unchecked(&ic->i_ack_next, 0);
77063 #else
77064 ic->i_ack_next = 0;
77065 #endif
77066 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
77067 index 5e57347..3916042 100644
77068 --- a/net/rds/iw_recv.c
77069 +++ b/net/rds/iw_recv.c
77070 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
77071 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
77072 int ack_required)
77073 {
77074 - atomic64_set(&ic->i_ack_next, seq);
77075 + atomic64_set_unchecked(&ic->i_ack_next, seq);
77076 if (ack_required) {
77077 smp_mb__before_clear_bit();
77078 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
77079 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
77080 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
77081 smp_mb__after_clear_bit();
77082
77083 - return atomic64_read(&ic->i_ack_next);
77084 + return atomic64_read_unchecked(&ic->i_ack_next);
77085 }
77086 #endif
77087
77088 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
77089 index edac9ef..16bcb98 100644
77090 --- a/net/rds/tcp.c
77091 +++ b/net/rds/tcp.c
77092 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
77093 int val = 1;
77094
77095 set_fs(KERNEL_DS);
77096 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
77097 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
77098 sizeof(val));
77099 set_fs(oldfs);
77100 }
77101 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
77102 index 1b4fd68..2234175 100644
77103 --- a/net/rds/tcp_send.c
77104 +++ b/net/rds/tcp_send.c
77105 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
77106
77107 oldfs = get_fs();
77108 set_fs(KERNEL_DS);
77109 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
77110 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
77111 sizeof(val));
77112 set_fs(oldfs);
77113 }
77114 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
77115 index 74c064c..fdec26f 100644
77116 --- a/net/rxrpc/af_rxrpc.c
77117 +++ b/net/rxrpc/af_rxrpc.c
77118 @@ -39,7 +39,7 @@ static const struct proto_ops rxrpc_rpc_ops;
77119 __be32 rxrpc_epoch;
77120
77121 /* current debugging ID */
77122 -atomic_t rxrpc_debug_id;
77123 +atomic_unchecked_t rxrpc_debug_id;
77124
77125 /* count of skbs currently in use */
77126 atomic_t rxrpc_n_skbs;
77127 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
77128 index c3126e8..21facc7 100644
77129 --- a/net/rxrpc/ar-ack.c
77130 +++ b/net/rxrpc/ar-ack.c
77131 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
77132
77133 _enter("{%d,%d,%d,%d},",
77134 call->acks_hard, call->acks_unacked,
77135 - atomic_read(&call->sequence),
77136 + atomic_read_unchecked(&call->sequence),
77137 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
77138
77139 stop = 0;
77140 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
77141
77142 /* each Tx packet has a new serial number */
77143 sp->hdr.serial =
77144 - htonl(atomic_inc_return(&call->conn->serial));
77145 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
77146
77147 hdr = (struct rxrpc_header *) txb->head;
77148 hdr->serial = sp->hdr.serial;
77149 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
77150 */
77151 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
77152 {
77153 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
77154 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
77155 }
77156
77157 /*
77158 @@ -629,7 +629,7 @@ process_further:
77159
77160 latest = ntohl(sp->hdr.serial);
77161 hard = ntohl(ack.firstPacket);
77162 - tx = atomic_read(&call->sequence);
77163 + tx = atomic_read_unchecked(&call->sequence);
77164
77165 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
77166 latest,
77167 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
77168 goto maybe_reschedule;
77169
77170 send_ACK_with_skew:
77171 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
77172 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
77173 ntohl(ack.serial));
77174 send_ACK:
77175 mtu = call->conn->trans->peer->if_mtu;
77176 @@ -1173,7 +1173,7 @@ send_ACK:
77177 ackinfo.rxMTU = htonl(5692);
77178 ackinfo.jumbo_max = htonl(4);
77179
77180 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
77181 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
77182 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
77183 ntohl(hdr.serial),
77184 ntohs(ack.maxSkew),
77185 @@ -1191,7 +1191,7 @@ send_ACK:
77186 send_message:
77187 _debug("send message");
77188
77189 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
77190 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
77191 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
77192 send_message_2:
77193
77194 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
77195 index bf656c2..48f9d27 100644
77196 --- a/net/rxrpc/ar-call.c
77197 +++ b/net/rxrpc/ar-call.c
77198 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
77199 spin_lock_init(&call->lock);
77200 rwlock_init(&call->state_lock);
77201 atomic_set(&call->usage, 1);
77202 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
77203 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
77204 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
77205
77206 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
77207 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
77208 index 4106ca9..a338d7a 100644
77209 --- a/net/rxrpc/ar-connection.c
77210 +++ b/net/rxrpc/ar-connection.c
77211 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
77212 rwlock_init(&conn->lock);
77213 spin_lock_init(&conn->state_lock);
77214 atomic_set(&conn->usage, 1);
77215 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
77216 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
77217 conn->avail_calls = RXRPC_MAXCALLS;
77218 conn->size_align = 4;
77219 conn->header_size = sizeof(struct rxrpc_header);
77220 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
77221 index e7ed43a..6afa140 100644
77222 --- a/net/rxrpc/ar-connevent.c
77223 +++ b/net/rxrpc/ar-connevent.c
77224 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
77225
77226 len = iov[0].iov_len + iov[1].iov_len;
77227
77228 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
77229 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
77230 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
77231
77232 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
77233 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
77234 index 1a2b0633..e8d1382 100644
77235 --- a/net/rxrpc/ar-input.c
77236 +++ b/net/rxrpc/ar-input.c
77237 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
77238 /* track the latest serial number on this connection for ACK packet
77239 * information */
77240 serial = ntohl(sp->hdr.serial);
77241 - hi_serial = atomic_read(&call->conn->hi_serial);
77242 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
77243 while (serial > hi_serial)
77244 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
77245 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
77246 serial);
77247
77248 /* request ACK generation for any ACK or DATA packet that requests
77249 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
77250 index 8e22bd3..f66d1c0 100644
77251 --- a/net/rxrpc/ar-internal.h
77252 +++ b/net/rxrpc/ar-internal.h
77253 @@ -272,8 +272,8 @@ struct rxrpc_connection {
77254 int error; /* error code for local abort */
77255 int debug_id; /* debug ID for printks */
77256 unsigned call_counter; /* call ID counter */
77257 - atomic_t serial; /* packet serial number counter */
77258 - atomic_t hi_serial; /* highest serial number received */
77259 + atomic_unchecked_t serial; /* packet serial number counter */
77260 + atomic_unchecked_t hi_serial; /* highest serial number received */
77261 u8 avail_calls; /* number of calls available */
77262 u8 size_align; /* data size alignment (for security) */
77263 u8 header_size; /* rxrpc + security header size */
77264 @@ -346,7 +346,7 @@ struct rxrpc_call {
77265 spinlock_t lock;
77266 rwlock_t state_lock; /* lock for state transition */
77267 atomic_t usage;
77268 - atomic_t sequence; /* Tx data packet sequence counter */
77269 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
77270 u32 abort_code; /* local/remote abort code */
77271 enum { /* current state of call */
77272 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
77273 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
77274 */
77275 extern atomic_t rxrpc_n_skbs;
77276 extern __be32 rxrpc_epoch;
77277 -extern atomic_t rxrpc_debug_id;
77278 +extern atomic_unchecked_t rxrpc_debug_id;
77279 extern struct workqueue_struct *rxrpc_workqueue;
77280
77281 /*
77282 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
77283 index 87f7135..74d3703 100644
77284 --- a/net/rxrpc/ar-local.c
77285 +++ b/net/rxrpc/ar-local.c
77286 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
77287 spin_lock_init(&local->lock);
77288 rwlock_init(&local->services_lock);
77289 atomic_set(&local->usage, 1);
77290 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
77291 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
77292 memcpy(&local->srx, srx, sizeof(*srx));
77293 }
77294
77295 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
77296 index 16ae887..d24f12b 100644
77297 --- a/net/rxrpc/ar-output.c
77298 +++ b/net/rxrpc/ar-output.c
77299 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
77300 sp->hdr.cid = call->cid;
77301 sp->hdr.callNumber = call->call_id;
77302 sp->hdr.seq =
77303 - htonl(atomic_inc_return(&call->sequence));
77304 + htonl(atomic_inc_return_unchecked(&call->sequence));
77305 sp->hdr.serial =
77306 - htonl(atomic_inc_return(&conn->serial));
77307 + htonl(atomic_inc_return_unchecked(&conn->serial));
77308 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
77309 sp->hdr.userStatus = 0;
77310 sp->hdr.securityIndex = conn->security_ix;
77311 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
77312 index 2754f09..b20e38f 100644
77313 --- a/net/rxrpc/ar-peer.c
77314 +++ b/net/rxrpc/ar-peer.c
77315 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
77316 INIT_LIST_HEAD(&peer->error_targets);
77317 spin_lock_init(&peer->lock);
77318 atomic_set(&peer->usage, 1);
77319 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
77320 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
77321 memcpy(&peer->srx, srx, sizeof(*srx));
77322
77323 rxrpc_assess_MTU_size(peer);
77324 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
77325 index 38047f7..9f48511 100644
77326 --- a/net/rxrpc/ar-proc.c
77327 +++ b/net/rxrpc/ar-proc.c
77328 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
77329 atomic_read(&conn->usage),
77330 rxrpc_conn_states[conn->state],
77331 key_serial(conn->key),
77332 - atomic_read(&conn->serial),
77333 - atomic_read(&conn->hi_serial));
77334 + atomic_read_unchecked(&conn->serial),
77335 + atomic_read_unchecked(&conn->hi_serial));
77336
77337 return 0;
77338 }
77339 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
77340 index 92df566..87ec1bf 100644
77341 --- a/net/rxrpc/ar-transport.c
77342 +++ b/net/rxrpc/ar-transport.c
77343 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
77344 spin_lock_init(&trans->client_lock);
77345 rwlock_init(&trans->conn_lock);
77346 atomic_set(&trans->usage, 1);
77347 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
77348 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
77349
77350 if (peer->srx.transport.family == AF_INET) {
77351 switch (peer->srx.transport_type) {
77352 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
77353 index 7635107..4670276 100644
77354 --- a/net/rxrpc/rxkad.c
77355 +++ b/net/rxrpc/rxkad.c
77356 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
77357
77358 len = iov[0].iov_len + iov[1].iov_len;
77359
77360 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
77361 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
77362 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
77363
77364 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
77365 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
77366
77367 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
77368
77369 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
77370 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
77371 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
77372
77373 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
77374 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
77375 index 1e2eee8..ce3967e 100644
77376 --- a/net/sctp/proc.c
77377 +++ b/net/sctp/proc.c
77378 @@ -319,7 +319,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
77379 seq_printf(seq,
77380 "%8pK %8pK %-3d %-3d %-2d %-4d "
77381 "%4d %8d %8d %7d %5lu %-5d %5d ",
77382 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
77383 + assoc, sk,
77384 + sctp_sk(sk)->type, sk->sk_state,
77385 assoc->state, hash,
77386 assoc->assoc_id,
77387 assoc->sndbuf_used,
77388 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
77389 index d043722..6903416 100644
77390 --- a/net/sctp/socket.c
77391 +++ b/net/sctp/socket.c
77392 @@ -4575,7 +4575,7 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
77393 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
77394 if (space_left < addrlen)
77395 return -ENOMEM;
77396 - if (copy_to_user(to, &temp, addrlen))
77397 + if (addrlen > sizeof(temp) || copy_to_user(to, &temp, addrlen))
77398 return -EFAULT;
77399 to += addrlen;
77400 cnt++;
77401 diff --git a/net/socket.c b/net/socket.c
77402 index 0de4131..7e7ddab 100644
77403 --- a/net/socket.c
77404 +++ b/net/socket.c
77405 @@ -88,6 +88,7 @@
77406 #include <linux/nsproxy.h>
77407 #include <linux/magic.h>
77408 #include <linux/slab.h>
77409 +#include <linux/in.h>
77410
77411 #include <asm/uaccess.h>
77412 #include <asm/unistd.h>
77413 @@ -105,6 +106,8 @@
77414 #include <linux/sockios.h>
77415 #include <linux/atalk.h>
77416
77417 +#include <linux/grsock.h>
77418 +
77419 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
77420 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
77421 unsigned long nr_segs, loff_t pos);
77422 @@ -321,7 +324,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
77423 &sockfs_dentry_operations, SOCKFS_MAGIC);
77424 }
77425
77426 -static struct vfsmount *sock_mnt __read_mostly;
77427 +struct vfsmount *sock_mnt __read_mostly;
77428
77429 static struct file_system_type sock_fs_type = {
77430 .name = "sockfs",
77431 @@ -1207,6 +1210,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
77432 return -EAFNOSUPPORT;
77433 if (type < 0 || type >= SOCK_MAX)
77434 return -EINVAL;
77435 + if (protocol < 0)
77436 + return -EINVAL;
77437
77438 /* Compatibility.
77439
77440 @@ -1339,6 +1344,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
77441 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
77442 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
77443
77444 + if(!gr_search_socket(family, type, protocol)) {
77445 + retval = -EACCES;
77446 + goto out;
77447 + }
77448 +
77449 + if (gr_handle_sock_all(family, type, protocol)) {
77450 + retval = -EACCES;
77451 + goto out;
77452 + }
77453 +
77454 retval = sock_create(family, type, protocol, &sock);
77455 if (retval < 0)
77456 goto out;
77457 @@ -1451,6 +1466,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
77458 if (sock) {
77459 err = move_addr_to_kernel(umyaddr, addrlen, (struct sockaddr *)&address);
77460 if (err >= 0) {
77461 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
77462 + err = -EACCES;
77463 + goto error;
77464 + }
77465 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
77466 + if (err)
77467 + goto error;
77468 +
77469 err = security_socket_bind(sock,
77470 (struct sockaddr *)&address,
77471 addrlen);
77472 @@ -1459,6 +1482,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
77473 (struct sockaddr *)
77474 &address, addrlen);
77475 }
77476 +error:
77477 fput_light(sock->file, fput_needed);
77478 }
77479 return err;
77480 @@ -1482,10 +1506,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
77481 if ((unsigned)backlog > somaxconn)
77482 backlog = somaxconn;
77483
77484 + if (gr_handle_sock_server_other(sock->sk)) {
77485 + err = -EPERM;
77486 + goto error;
77487 + }
77488 +
77489 + err = gr_search_listen(sock);
77490 + if (err)
77491 + goto error;
77492 +
77493 err = security_socket_listen(sock, backlog);
77494 if (!err)
77495 err = sock->ops->listen(sock, backlog);
77496
77497 +error:
77498 fput_light(sock->file, fput_needed);
77499 }
77500 return err;
77501 @@ -1529,6 +1563,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
77502 newsock->type = sock->type;
77503 newsock->ops = sock->ops;
77504
77505 + if (gr_handle_sock_server_other(sock->sk)) {
77506 + err = -EPERM;
77507 + sock_release(newsock);
77508 + goto out_put;
77509 + }
77510 +
77511 + err = gr_search_accept(sock);
77512 + if (err) {
77513 + sock_release(newsock);
77514 + goto out_put;
77515 + }
77516 +
77517 /*
77518 * We don't need try_module_get here, as the listening socket (sock)
77519 * has the protocol module (sock->ops->owner) held.
77520 @@ -1567,6 +1613,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
77521 fd_install(newfd, newfile);
77522 err = newfd;
77523
77524 + gr_attach_curr_ip(newsock->sk);
77525 +
77526 out_put:
77527 fput_light(sock->file, fput_needed);
77528 out:
77529 @@ -1599,6 +1647,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
77530 int, addrlen)
77531 {
77532 struct socket *sock;
77533 + struct sockaddr *sck;
77534 struct sockaddr_storage address;
77535 int err, fput_needed;
77536
77537 @@ -1609,6 +1658,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
77538 if (err < 0)
77539 goto out_put;
77540
77541 + sck = (struct sockaddr *)&address;
77542 +
77543 + if (gr_handle_sock_client(sck)) {
77544 + err = -EACCES;
77545 + goto out_put;
77546 + }
77547 +
77548 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
77549 + if (err)
77550 + goto out_put;
77551 +
77552 err =
77553 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
77554 if (err)
77555 @@ -1970,7 +2030,7 @@ static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
77556 * checking falls down on this.
77557 */
77558 if (copy_from_user(ctl_buf,
77559 - (void __user __force *)msg_sys->msg_control,
77560 + (void __force_user *)msg_sys->msg_control,
77561 ctl_len))
77562 goto out_freectl;
77563 msg_sys->msg_control = ctl_buf;
77564 @@ -2140,7 +2200,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
77565 * kernel msghdr to use the kernel address space)
77566 */
77567
77568 - uaddr = (__force void __user *)msg_sys->msg_name;
77569 + uaddr = (void __force_user *)msg_sys->msg_name;
77570 uaddr_len = COMPAT_NAMELEN(msg);
77571 if (MSG_CMSG_COMPAT & flags) {
77572 err = verify_compat_iovec(msg_sys, iov,
77573 @@ -2768,7 +2828,7 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
77574 }
77575
77576 ifr = compat_alloc_user_space(buf_size);
77577 - rxnfc = (void *)ifr + ALIGN(sizeof(struct ifreq), 8);
77578 + rxnfc = (void __user *)ifr + ALIGN(sizeof(struct ifreq), 8);
77579
77580 if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
77581 return -EFAULT;
77582 @@ -2792,12 +2852,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
77583 offsetof(struct ethtool_rxnfc, fs.ring_cookie));
77584
77585 if (copy_in_user(rxnfc, compat_rxnfc,
77586 - (void *)(&rxnfc->fs.m_ext + 1) -
77587 - (void *)rxnfc) ||
77588 + (void __user *)(&rxnfc->fs.m_ext + 1) -
77589 + (void __user *)rxnfc) ||
77590 copy_in_user(&rxnfc->fs.ring_cookie,
77591 &compat_rxnfc->fs.ring_cookie,
77592 - (void *)(&rxnfc->fs.location + 1) -
77593 - (void *)&rxnfc->fs.ring_cookie) ||
77594 + (void __user *)(&rxnfc->fs.location + 1) -
77595 + (void __user *)&rxnfc->fs.ring_cookie) ||
77596 copy_in_user(&rxnfc->rule_cnt, &compat_rxnfc->rule_cnt,
77597 sizeof(rxnfc->rule_cnt)))
77598 return -EFAULT;
77599 @@ -2809,12 +2869,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
77600
77601 if (convert_out) {
77602 if (copy_in_user(compat_rxnfc, rxnfc,
77603 - (const void *)(&rxnfc->fs.m_ext + 1) -
77604 - (const void *)rxnfc) ||
77605 + (const void __user *)(&rxnfc->fs.m_ext + 1) -
77606 + (const void __user *)rxnfc) ||
77607 copy_in_user(&compat_rxnfc->fs.ring_cookie,
77608 &rxnfc->fs.ring_cookie,
77609 - (const void *)(&rxnfc->fs.location + 1) -
77610 - (const void *)&rxnfc->fs.ring_cookie) ||
77611 + (const void __user *)(&rxnfc->fs.location + 1) -
77612 + (const void __user *)&rxnfc->fs.ring_cookie) ||
77613 copy_in_user(&compat_rxnfc->rule_cnt, &rxnfc->rule_cnt,
77614 sizeof(rxnfc->rule_cnt)))
77615 return -EFAULT;
77616 @@ -2884,7 +2944,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
77617 old_fs = get_fs();
77618 set_fs(KERNEL_DS);
77619 err = dev_ioctl(net, cmd,
77620 - (struct ifreq __user __force *) &kifr);
77621 + (struct ifreq __force_user *) &kifr);
77622 set_fs(old_fs);
77623
77624 return err;
77625 @@ -2993,7 +3053,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
77626
77627 old_fs = get_fs();
77628 set_fs(KERNEL_DS);
77629 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
77630 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
77631 set_fs(old_fs);
77632
77633 if (cmd == SIOCGIFMAP && !err) {
77634 @@ -3098,7 +3158,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
77635 ret |= __get_user(rtdev, &(ur4->rt_dev));
77636 if (rtdev) {
77637 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
77638 - r4.rt_dev = (char __user __force *)devname;
77639 + r4.rt_dev = (char __force_user *)devname;
77640 devname[15] = 0;
77641 } else
77642 r4.rt_dev = NULL;
77643 @@ -3324,8 +3384,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
77644 int __user *uoptlen;
77645 int err;
77646
77647 - uoptval = (char __user __force *) optval;
77648 - uoptlen = (int __user __force *) optlen;
77649 + uoptval = (char __force_user *) optval;
77650 + uoptlen = (int __force_user *) optlen;
77651
77652 set_fs(KERNEL_DS);
77653 if (level == SOL_SOCKET)
77654 @@ -3345,7 +3405,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
77655 char __user *uoptval;
77656 int err;
77657
77658 - uoptval = (char __user __force *) optval;
77659 + uoptval = (char __force_user *) optval;
77660
77661 set_fs(KERNEL_DS);
77662 if (level == SOL_SOCKET)
77663 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
77664 index 8efd96c..b492ab2 100644
77665 --- a/net/sunrpc/sched.c
77666 +++ b/net/sunrpc/sched.c
77667 @@ -239,9 +239,9 @@ static int rpc_wait_bit_killable(void *word)
77668 #ifdef RPC_DEBUG
77669 static void rpc_task_set_debuginfo(struct rpc_task *task)
77670 {
77671 - static atomic_t rpc_pid;
77672 + static atomic_unchecked_t rpc_pid;
77673
77674 - task->tk_pid = atomic_inc_return(&rpc_pid);
77675 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
77676 }
77677 #else
77678 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
77679 diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
77680 index 4645709..d41d668 100644
77681 --- a/net/sunrpc/svcsock.c
77682 +++ b/net/sunrpc/svcsock.c
77683 @@ -396,7 +396,7 @@ static int svc_partial_recvfrom(struct svc_rqst *rqstp,
77684 int buflen, unsigned int base)
77685 {
77686 size_t save_iovlen;
77687 - void __user *save_iovbase;
77688 + void *save_iovbase;
77689 unsigned int i;
77690 int ret;
77691
77692 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
77693 index 09af4fa..77110a9 100644
77694 --- a/net/sunrpc/xprtrdma/svc_rdma.c
77695 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
77696 @@ -61,15 +61,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
77697 static unsigned int min_max_inline = 4096;
77698 static unsigned int max_max_inline = 65536;
77699
77700 -atomic_t rdma_stat_recv;
77701 -atomic_t rdma_stat_read;
77702 -atomic_t rdma_stat_write;
77703 -atomic_t rdma_stat_sq_starve;
77704 -atomic_t rdma_stat_rq_starve;
77705 -atomic_t rdma_stat_rq_poll;
77706 -atomic_t rdma_stat_rq_prod;
77707 -atomic_t rdma_stat_sq_poll;
77708 -atomic_t rdma_stat_sq_prod;
77709 +atomic_unchecked_t rdma_stat_recv;
77710 +atomic_unchecked_t rdma_stat_read;
77711 +atomic_unchecked_t rdma_stat_write;
77712 +atomic_unchecked_t rdma_stat_sq_starve;
77713 +atomic_unchecked_t rdma_stat_rq_starve;
77714 +atomic_unchecked_t rdma_stat_rq_poll;
77715 +atomic_unchecked_t rdma_stat_rq_prod;
77716 +atomic_unchecked_t rdma_stat_sq_poll;
77717 +atomic_unchecked_t rdma_stat_sq_prod;
77718
77719 /* Temporary NFS request map and context caches */
77720 struct kmem_cache *svc_rdma_map_cachep;
77721 @@ -109,7 +109,7 @@ static int read_reset_stat(ctl_table *table, int write,
77722 len -= *ppos;
77723 if (len > *lenp)
77724 len = *lenp;
77725 - if (len && copy_to_user(buffer, str_buf, len))
77726 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
77727 return -EFAULT;
77728 *lenp = len;
77729 *ppos += len;
77730 @@ -150,63 +150,63 @@ static ctl_table svcrdma_parm_table[] = {
77731 {
77732 .procname = "rdma_stat_read",
77733 .data = &rdma_stat_read,
77734 - .maxlen = sizeof(atomic_t),
77735 + .maxlen = sizeof(atomic_unchecked_t),
77736 .mode = 0644,
77737 .proc_handler = read_reset_stat,
77738 },
77739 {
77740 .procname = "rdma_stat_recv",
77741 .data = &rdma_stat_recv,
77742 - .maxlen = sizeof(atomic_t),
77743 + .maxlen = sizeof(atomic_unchecked_t),
77744 .mode = 0644,
77745 .proc_handler = read_reset_stat,
77746 },
77747 {
77748 .procname = "rdma_stat_write",
77749 .data = &rdma_stat_write,
77750 - .maxlen = sizeof(atomic_t),
77751 + .maxlen = sizeof(atomic_unchecked_t),
77752 .mode = 0644,
77753 .proc_handler = read_reset_stat,
77754 },
77755 {
77756 .procname = "rdma_stat_sq_starve",
77757 .data = &rdma_stat_sq_starve,
77758 - .maxlen = sizeof(atomic_t),
77759 + .maxlen = sizeof(atomic_unchecked_t),
77760 .mode = 0644,
77761 .proc_handler = read_reset_stat,
77762 },
77763 {
77764 .procname = "rdma_stat_rq_starve",
77765 .data = &rdma_stat_rq_starve,
77766 - .maxlen = sizeof(atomic_t),
77767 + .maxlen = sizeof(atomic_unchecked_t),
77768 .mode = 0644,
77769 .proc_handler = read_reset_stat,
77770 },
77771 {
77772 .procname = "rdma_stat_rq_poll",
77773 .data = &rdma_stat_rq_poll,
77774 - .maxlen = sizeof(atomic_t),
77775 + .maxlen = sizeof(atomic_unchecked_t),
77776 .mode = 0644,
77777 .proc_handler = read_reset_stat,
77778 },
77779 {
77780 .procname = "rdma_stat_rq_prod",
77781 .data = &rdma_stat_rq_prod,
77782 - .maxlen = sizeof(atomic_t),
77783 + .maxlen = sizeof(atomic_unchecked_t),
77784 .mode = 0644,
77785 .proc_handler = read_reset_stat,
77786 },
77787 {
77788 .procname = "rdma_stat_sq_poll",
77789 .data = &rdma_stat_sq_poll,
77790 - .maxlen = sizeof(atomic_t),
77791 + .maxlen = sizeof(atomic_unchecked_t),
77792 .mode = 0644,
77793 .proc_handler = read_reset_stat,
77794 },
77795 {
77796 .procname = "rdma_stat_sq_prod",
77797 .data = &rdma_stat_sq_prod,
77798 - .maxlen = sizeof(atomic_t),
77799 + .maxlen = sizeof(atomic_unchecked_t),
77800 .mode = 0644,
77801 .proc_handler = read_reset_stat,
77802 },
77803 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
77804 index df67211..c354b13 100644
77805 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
77806 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
77807 @@ -499,7 +499,7 @@ next_sge:
77808 svc_rdma_put_context(ctxt, 0);
77809 goto out;
77810 }
77811 - atomic_inc(&rdma_stat_read);
77812 + atomic_inc_unchecked(&rdma_stat_read);
77813
77814 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
77815 chl_map->ch[ch_no].count -= read_wr.num_sge;
77816 @@ -609,7 +609,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
77817 dto_q);
77818 list_del_init(&ctxt->dto_q);
77819 } else {
77820 - atomic_inc(&rdma_stat_rq_starve);
77821 + atomic_inc_unchecked(&rdma_stat_rq_starve);
77822 clear_bit(XPT_DATA, &xprt->xpt_flags);
77823 ctxt = NULL;
77824 }
77825 @@ -629,7 +629,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
77826 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
77827 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
77828 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
77829 - atomic_inc(&rdma_stat_recv);
77830 + atomic_inc_unchecked(&rdma_stat_recv);
77831
77832 /* Build up the XDR from the receive buffers. */
77833 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
77834 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
77835 index 249a835..fb2794b 100644
77836 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
77837 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
77838 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
77839 write_wr.wr.rdma.remote_addr = to;
77840
77841 /* Post It */
77842 - atomic_inc(&rdma_stat_write);
77843 + atomic_inc_unchecked(&rdma_stat_write);
77844 if (svc_rdma_send(xprt, &write_wr))
77845 goto err;
77846 return 0;
77847 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
77848 index 894cb42..cf5bafb 100644
77849 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
77850 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
77851 @@ -300,7 +300,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
77852 return;
77853
77854 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
77855 - atomic_inc(&rdma_stat_rq_poll);
77856 + atomic_inc_unchecked(&rdma_stat_rq_poll);
77857
77858 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
77859 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
77860 @@ -322,7 +322,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
77861 }
77862
77863 if (ctxt)
77864 - atomic_inc(&rdma_stat_rq_prod);
77865 + atomic_inc_unchecked(&rdma_stat_rq_prod);
77866
77867 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
77868 /*
77869 @@ -394,7 +394,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
77870 return;
77871
77872 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
77873 - atomic_inc(&rdma_stat_sq_poll);
77874 + atomic_inc_unchecked(&rdma_stat_sq_poll);
77875 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
77876 if (wc.status != IB_WC_SUCCESS)
77877 /* Close the transport */
77878 @@ -412,7 +412,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
77879 }
77880
77881 if (ctxt)
77882 - atomic_inc(&rdma_stat_sq_prod);
77883 + atomic_inc_unchecked(&rdma_stat_sq_prod);
77884 }
77885
77886 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
77887 @@ -1274,7 +1274,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
77888 spin_lock_bh(&xprt->sc_lock);
77889 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
77890 spin_unlock_bh(&xprt->sc_lock);
77891 - atomic_inc(&rdma_stat_sq_starve);
77892 + atomic_inc_unchecked(&rdma_stat_sq_starve);
77893
77894 /* See if we can opportunistically reap SQ WR to make room */
77895 sq_cq_reap(xprt);
77896 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
77897 index e758139..d29ea47 100644
77898 --- a/net/sysctl_net.c
77899 +++ b/net/sysctl_net.c
77900 @@ -47,7 +47,7 @@ static int net_ctl_permissions(struct ctl_table_root *root,
77901 struct ctl_table *table)
77902 {
77903 /* Allow network administrator to have same access as root. */
77904 - if (capable(CAP_NET_ADMIN)) {
77905 + if (capable_nolog(CAP_NET_ADMIN)) {
77906 int mode = (table->mode >> 6) & 7;
77907 return (mode << 6) | (mode << 3) | mode;
77908 }
77909 diff --git a/net/tipc/link.c b/net/tipc/link.c
77910 index ac1832a..533ed97 100644
77911 --- a/net/tipc/link.c
77912 +++ b/net/tipc/link.c
77913 @@ -1205,7 +1205,7 @@ static int link_send_sections_long(struct tipc_port *sender,
77914 struct tipc_msg fragm_hdr;
77915 struct sk_buff *buf, *buf_chain, *prev;
77916 u32 fragm_crs, fragm_rest, hsz, sect_rest;
77917 - const unchar *sect_crs;
77918 + const unchar __user *sect_crs;
77919 int curr_sect;
77920 u32 fragm_no;
77921
77922 @@ -1249,7 +1249,7 @@ again:
77923
77924 if (!sect_rest) {
77925 sect_rest = msg_sect[++curr_sect].iov_len;
77926 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
77927 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
77928 }
77929
77930 if (sect_rest < fragm_rest)
77931 @@ -1268,7 +1268,7 @@ error:
77932 }
77933 } else
77934 skb_copy_to_linear_data_offset(buf, fragm_crs,
77935 - sect_crs, sz);
77936 + (const void __force_kernel *)sect_crs, sz);
77937 sect_crs += sz;
77938 sect_rest -= sz;
77939 fragm_crs += sz;
77940 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
77941 index 3e4d3e2..27b55dc 100644
77942 --- a/net/tipc/msg.c
77943 +++ b/net/tipc/msg.c
77944 @@ -99,7 +99,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
77945 msg_sect[cnt].iov_len);
77946 else
77947 skb_copy_to_linear_data_offset(*buf, pos,
77948 - msg_sect[cnt].iov_base,
77949 + (const void __force_kernel *)msg_sect[cnt].iov_base,
77950 msg_sect[cnt].iov_len);
77951 pos += msg_sect[cnt].iov_len;
77952 }
77953 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
77954 index 8c49566..14510cb 100644
77955 --- a/net/tipc/subscr.c
77956 +++ b/net/tipc/subscr.c
77957 @@ -101,7 +101,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
77958 {
77959 struct iovec msg_sect;
77960
77961 - msg_sect.iov_base = (void *)&sub->evt;
77962 + msg_sect.iov_base = (void __force_user *)&sub->evt;
77963 msg_sect.iov_len = sizeof(struct tipc_event);
77964
77965 sub->evt.event = htohl(event, sub->swap);
77966 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
77967 index 85d3bb7..79f4487 100644
77968 --- a/net/unix/af_unix.c
77969 +++ b/net/unix/af_unix.c
77970 @@ -770,6 +770,12 @@ static struct sock *unix_find_other(struct net *net,
77971 err = -ECONNREFUSED;
77972 if (!S_ISSOCK(inode->i_mode))
77973 goto put_fail;
77974 +
77975 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
77976 + err = -EACCES;
77977 + goto put_fail;
77978 + }
77979 +
77980 u = unix_find_socket_byinode(inode);
77981 if (!u)
77982 goto put_fail;
77983 @@ -790,6 +796,13 @@ static struct sock *unix_find_other(struct net *net,
77984 if (u) {
77985 struct dentry *dentry;
77986 dentry = unix_sk(u)->dentry;
77987 +
77988 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
77989 + err = -EPERM;
77990 + sock_put(u);
77991 + goto fail;
77992 + }
77993 +
77994 if (dentry)
77995 touch_atime(unix_sk(u)->mnt, dentry);
77996 } else
77997 @@ -872,11 +885,18 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
77998 err = security_path_mknod(&path, dentry, mode, 0);
77999 if (err)
78000 goto out_mknod_drop_write;
78001 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
78002 + err = -EACCES;
78003 + goto out_mknod_drop_write;
78004 + }
78005 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
78006 out_mknod_drop_write:
78007 mnt_drop_write(path.mnt);
78008 if (err)
78009 goto out_mknod_dput;
78010 +
78011 + gr_handle_create(dentry, path.mnt);
78012 +
78013 mutex_unlock(&path.dentry->d_inode->i_mutex);
78014 dput(path.dentry);
78015 path.dentry = dentry;
78016 diff --git a/net/wireless/core.h b/net/wireless/core.h
78017 index 43ad9c8..ab5127c 100644
78018 --- a/net/wireless/core.h
78019 +++ b/net/wireless/core.h
78020 @@ -27,7 +27,7 @@ struct cfg80211_registered_device {
78021 struct mutex mtx;
78022
78023 /* rfkill support */
78024 - struct rfkill_ops rfkill_ops;
78025 + rfkill_ops_no_const rfkill_ops;
78026 struct rfkill *rfkill;
78027 struct work_struct rfkill_sync;
78028
78029 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
78030 index 0af7f54..c916d2f 100644
78031 --- a/net/wireless/wext-core.c
78032 +++ b/net/wireless/wext-core.c
78033 @@ -747,8 +747,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
78034 */
78035
78036 /* Support for very large requests */
78037 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
78038 - (user_length > descr->max_tokens)) {
78039 + if (user_length > descr->max_tokens) {
78040 /* Allow userspace to GET more than max so
78041 * we can support any size GET requests.
78042 * There is still a limit : -ENOMEM.
78043 @@ -785,22 +784,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
78044 }
78045 }
78046
78047 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
78048 - /*
78049 - * If this is a GET, but not NOMAX, it means that the extra
78050 - * data is not bounded by userspace, but by max_tokens. Thus
78051 - * set the length to max_tokens. This matches the extra data
78052 - * allocation.
78053 - * The driver should fill it with the number of tokens it
78054 - * provided, and it may check iwp->length rather than having
78055 - * knowledge of max_tokens. If the driver doesn't change the
78056 - * iwp->length, this ioctl just copies back max_token tokens
78057 - * filled with zeroes. Hopefully the driver isn't claiming
78058 - * them to be valid data.
78059 - */
78060 - iwp->length = descr->max_tokens;
78061 - }
78062 -
78063 err = handler(dev, info, (union iwreq_data *) iwp, extra);
78064
78065 iwp->length += essid_compat;
78066 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
78067 index 7661576..80f7627 100644
78068 --- a/net/xfrm/xfrm_policy.c
78069 +++ b/net/xfrm/xfrm_policy.c
78070 @@ -299,7 +299,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
78071 {
78072 policy->walk.dead = 1;
78073
78074 - atomic_inc(&policy->genid);
78075 + atomic_inc_unchecked(&policy->genid);
78076
78077 if (del_timer(&policy->timer))
78078 xfrm_pol_put(policy);
78079 @@ -583,7 +583,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
78080 hlist_add_head(&policy->bydst, chain);
78081 xfrm_pol_hold(policy);
78082 net->xfrm.policy_count[dir]++;
78083 - atomic_inc(&flow_cache_genid);
78084 + atomic_inc_unchecked(&flow_cache_genid);
78085 if (delpol)
78086 __xfrm_policy_unlink(delpol, dir);
78087 policy->index = delpol ? delpol->index : xfrm_gen_index(net, dir);
78088 @@ -1530,7 +1530,7 @@ free_dst:
78089 goto out;
78090 }
78091
78092 -static int inline
78093 +static inline int
78094 xfrm_dst_alloc_copy(void **target, const void *src, int size)
78095 {
78096 if (!*target) {
78097 @@ -1542,7 +1542,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
78098 return 0;
78099 }
78100
78101 -static int inline
78102 +static inline int
78103 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
78104 {
78105 #ifdef CONFIG_XFRM_SUB_POLICY
78106 @@ -1554,7 +1554,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
78107 #endif
78108 }
78109
78110 -static int inline
78111 +static inline int
78112 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
78113 {
78114 #ifdef CONFIG_XFRM_SUB_POLICY
78115 @@ -1648,7 +1648,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
78116
78117 xdst->num_pols = num_pols;
78118 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
78119 - xdst->policy_genid = atomic_read(&pols[0]->genid);
78120 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
78121
78122 return xdst;
78123 }
78124 @@ -2345,7 +2345,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
78125 if (xdst->xfrm_genid != dst->xfrm->genid)
78126 return 0;
78127 if (xdst->num_pols > 0 &&
78128 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
78129 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
78130 return 0;
78131
78132 mtu = dst_mtu(dst->child);
78133 @@ -2882,7 +2882,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
78134 sizeof(pol->xfrm_vec[i].saddr));
78135 pol->xfrm_vec[i].encap_family = mp->new_family;
78136 /* flush bundles */
78137 - atomic_inc(&pol->genid);
78138 + atomic_inc_unchecked(&pol->genid);
78139 }
78140 }
78141
78142 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
78143 index d2b366c..51ff91ebc 100644
78144 --- a/scripts/Makefile.build
78145 +++ b/scripts/Makefile.build
78146 @@ -109,7 +109,7 @@ endif
78147 endif
78148
78149 # Do not include host rules unless needed
78150 -ifneq ($(hostprogs-y)$(hostprogs-m),)
78151 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m),)
78152 include scripts/Makefile.host
78153 endif
78154
78155 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
78156 index 686cb0d..9d653bf 100644
78157 --- a/scripts/Makefile.clean
78158 +++ b/scripts/Makefile.clean
78159 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
78160 __clean-files := $(extra-y) $(always) \
78161 $(targets) $(clean-files) \
78162 $(host-progs) \
78163 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
78164 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
78165 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
78166
78167 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
78168
78169 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
78170 index 1ac414f..a1c1451 100644
78171 --- a/scripts/Makefile.host
78172 +++ b/scripts/Makefile.host
78173 @@ -31,6 +31,7 @@
78174 # Note: Shared libraries consisting of C++ files are not supported
78175
78176 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
78177 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
78178
78179 # C code
78180 # Executables compiled from a single .c file
78181 @@ -54,6 +55,7 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
78182 # Shared libaries (only .c supported)
78183 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
78184 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
78185 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
78186 # Remove .so files from "xxx-objs"
78187 host-cobjs := $(filter-out %.so,$(host-cobjs))
78188
78189 diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
78190 index 00c368c..bb3f3e9 100644
78191 --- a/scripts/Makefile.lib
78192 +++ b/scripts/Makefile.lib
78193 @@ -144,14 +144,14 @@ __a_flags = $(call flags,_a_flags)
78194 __cpp_flags = $(call flags,_cpp_flags)
78195 endif
78196
78197 -c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
78198 +c_flags = -Wp,-MD,$(depfile) $(LINUXINCLUDE) $(NOSTDINC_FLAGS) \
78199 $(__c_flags) $(modkern_cflags) \
78200 -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)
78201
78202 -a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
78203 +a_flags = -Wp,-MD,$(depfile) $(LINUXINCLUDE) $(NOSTDINC_FLAGS) \
78204 $(__a_flags) $(modkern_aflags)
78205
78206 -cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
78207 +cpp_flags = -Wp,-MD,$(depfile) $(LINUXINCLUDE) $(NOSTDINC_FLAGS) \
78208 $(__cpp_flags)
78209
78210 ld_flags = $(LDFLAGS) $(ldflags-y)
78211 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
78212 index cb1f50c..cef2a7c 100644
78213 --- a/scripts/basic/fixdep.c
78214 +++ b/scripts/basic/fixdep.c
78215 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
78216 /*
78217 * Lookup a value in the configuration string.
78218 */
78219 -static int is_defined_config(const char *name, int len, unsigned int hash)
78220 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
78221 {
78222 struct item *aux;
78223
78224 @@ -211,10 +211,10 @@ static void clear_config(void)
78225 /*
78226 * Record the use of a CONFIG_* word.
78227 */
78228 -static void use_config(const char *m, int slen)
78229 +static void use_config(const char *m, unsigned int slen)
78230 {
78231 unsigned int hash = strhash(m, slen);
78232 - int c, i;
78233 + unsigned int c, i;
78234
78235 if (is_defined_config(m, slen, hash))
78236 return;
78237 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
78238
78239 static void parse_config_file(const char *map, size_t len)
78240 {
78241 - const int *end = (const int *) (map + len);
78242 + const unsigned int *end = (const unsigned int *) (map + len);
78243 /* start at +1, so that p can never be < map */
78244 - const int *m = (const int *) map + 1;
78245 + const unsigned int *m = (const unsigned int *) map + 1;
78246 const char *p, *q;
78247
78248 for (; m < end; m++) {
78249 @@ -406,7 +406,7 @@ static void print_deps(void)
78250 static void traps(void)
78251 {
78252 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
78253 - int *p = (int *)test;
78254 + unsigned int *p = (unsigned int *)test;
78255
78256 if (*p != INT_CONF) {
78257 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianess? %#x\n",
78258 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
78259 new file mode 100644
78260 index 0000000..8729101
78261 --- /dev/null
78262 +++ b/scripts/gcc-plugin.sh
78263 @@ -0,0 +1,2 @@
78264 +#!/bin/sh
78265 +echo -e "#include \"gcc-plugin.h\"\n#include \"tree.h\"\n#include \"tm.h\"\n#include \"rtl.h\"" | $1 -x c -shared - -o /dev/null -I`$2 -print-file-name=plugin`/include >/dev/null 2>&1 && echo "y"
78266 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
78267 index e047e17..ea646ec 100644
78268 --- a/scripts/mod/file2alias.c
78269 +++ b/scripts/mod/file2alias.c
78270 @@ -128,7 +128,7 @@ static void device_id_check(const char *modname, const char *device_id,
78271 unsigned long size, unsigned long id_size,
78272 void *symval)
78273 {
78274 - int i;
78275 + unsigned int i;
78276
78277 if (size % id_size || size < id_size) {
78278 if (cross_build != 0)
78279 @@ -158,7 +158,7 @@ static void device_id_check(const char *modname, const char *device_id,
78280 /* USB is special because the bcdDevice can be matched against a numeric range */
78281 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipN" */
78282 static void do_usb_entry(struct usb_device_id *id,
78283 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
78284 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
78285 unsigned char range_lo, unsigned char range_hi,
78286 unsigned char max, struct module *mod)
78287 {
78288 @@ -259,7 +259,7 @@ static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod)
78289 {
78290 unsigned int devlo, devhi;
78291 unsigned char chi, clo, max;
78292 - int ndigits;
78293 + unsigned int ndigits;
78294
78295 id->match_flags = TO_NATIVE(id->match_flags);
78296 id->idVendor = TO_NATIVE(id->idVendor);
78297 @@ -501,7 +501,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
78298 for (i = 0; i < count; i++) {
78299 const char *id = (char *)devs[i].id;
78300 char acpi_id[sizeof(devs[0].id)];
78301 - int j;
78302 + unsigned int j;
78303
78304 buf_printf(&mod->dev_table_buf,
78305 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
78306 @@ -531,7 +531,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
78307
78308 for (j = 0; j < PNP_MAX_DEVICES; j++) {
78309 const char *id = (char *)card->devs[j].id;
78310 - int i2, j2;
78311 + unsigned int i2, j2;
78312 int dup = 0;
78313
78314 if (!id[0])
78315 @@ -557,7 +557,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
78316 /* add an individual alias for every device entry */
78317 if (!dup) {
78318 char acpi_id[sizeof(card->devs[0].id)];
78319 - int k;
78320 + unsigned int k;
78321
78322 buf_printf(&mod->dev_table_buf,
78323 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
78324 @@ -882,7 +882,7 @@ static void dmi_ascii_filter(char *d, const char *s)
78325 static int do_dmi_entry(const char *filename, struct dmi_system_id *id,
78326 char *alias)
78327 {
78328 - int i, j;
78329 + unsigned int i, j;
78330
78331 sprintf(alias, "dmi*");
78332
78333 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
78334 index c4e7d15..4241aef 100644
78335 --- a/scripts/mod/modpost.c
78336 +++ b/scripts/mod/modpost.c
78337 @@ -922,6 +922,7 @@ enum mismatch {
78338 ANY_INIT_TO_ANY_EXIT,
78339 ANY_EXIT_TO_ANY_INIT,
78340 EXPORT_TO_INIT_EXIT,
78341 + DATA_TO_TEXT
78342 };
78343
78344 struct sectioncheck {
78345 @@ -1030,6 +1031,12 @@ const struct sectioncheck sectioncheck[] = {
78346 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
78347 .mismatch = EXPORT_TO_INIT_EXIT,
78348 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
78349 +},
78350 +/* Do not reference code from writable data */
78351 +{
78352 + .fromsec = { DATA_SECTIONS, NULL },
78353 + .tosec = { TEXT_SECTIONS, NULL },
78354 + .mismatch = DATA_TO_TEXT
78355 }
78356 };
78357
78358 @@ -1152,10 +1159,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
78359 continue;
78360 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
78361 continue;
78362 - if (sym->st_value == addr)
78363 - return sym;
78364 /* Find a symbol nearby - addr are maybe negative */
78365 d = sym->st_value - addr;
78366 + if (d == 0)
78367 + return sym;
78368 if (d < 0)
78369 d = addr - sym->st_value;
78370 if (d < distance) {
78371 @@ -1434,6 +1441,14 @@ static void report_sec_mismatch(const char *modname,
78372 tosym, prl_to, prl_to, tosym);
78373 free(prl_to);
78374 break;
78375 + case DATA_TO_TEXT:
78376 +/*
78377 + fprintf(stderr,
78378 + "The variable %s references\n"
78379 + "the %s %s%s%s\n",
78380 + fromsym, to, sec2annotation(tosec), tosym, to_p);
78381 +*/
78382 + break;
78383 }
78384 fprintf(stderr, "\n");
78385 }
78386 @@ -1668,7 +1683,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
78387 static void check_sec_ref(struct module *mod, const char *modname,
78388 struct elf_info *elf)
78389 {
78390 - int i;
78391 + unsigned int i;
78392 Elf_Shdr *sechdrs = elf->sechdrs;
78393
78394 /* Walk through all sections */
78395 @@ -1766,7 +1781,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
78396 va_end(ap);
78397 }
78398
78399 -void buf_write(struct buffer *buf, const char *s, int len)
78400 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
78401 {
78402 if (buf->size - buf->pos < len) {
78403 buf->size += len + SZ;
78404 @@ -1984,7 +1999,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
78405 if (fstat(fileno(file), &st) < 0)
78406 goto close_write;
78407
78408 - if (st.st_size != b->pos)
78409 + if (st.st_size != (off_t)b->pos)
78410 goto close_write;
78411
78412 tmp = NOFAIL(malloc(b->pos));
78413 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
78414 index 51207e4..f7d603d 100644
78415 --- a/scripts/mod/modpost.h
78416 +++ b/scripts/mod/modpost.h
78417 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
78418
78419 struct buffer {
78420 char *p;
78421 - int pos;
78422 - int size;
78423 + unsigned int pos;
78424 + unsigned int size;
78425 };
78426
78427 void __attribute__((format(printf, 2, 3)))
78428 buf_printf(struct buffer *buf, const char *fmt, ...);
78429
78430 void
78431 -buf_write(struct buffer *buf, const char *s, int len);
78432 +buf_write(struct buffer *buf, const char *s, unsigned int len);
78433
78434 struct module {
78435 struct module *next;
78436 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
78437 index 9dfcd6d..099068e 100644
78438 --- a/scripts/mod/sumversion.c
78439 +++ b/scripts/mod/sumversion.c
78440 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
78441 goto out;
78442 }
78443
78444 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
78445 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
78446 warn("writing sum in %s failed: %s\n",
78447 filename, strerror(errno));
78448 goto out;
78449 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
78450 index 5c11312..72742b5 100644
78451 --- a/scripts/pnmtologo.c
78452 +++ b/scripts/pnmtologo.c
78453 @@ -237,14 +237,14 @@ static void write_header(void)
78454 fprintf(out, " * Linux logo %s\n", logoname);
78455 fputs(" */\n\n", out);
78456 fputs("#include <linux/linux_logo.h>\n\n", out);
78457 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
78458 + fprintf(out, "static unsigned char %s_data[] = {\n",
78459 logoname);
78460 }
78461
78462 static void write_footer(void)
78463 {
78464 fputs("\n};\n\n", out);
78465 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
78466 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
78467 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
78468 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
78469 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
78470 @@ -374,7 +374,7 @@ static void write_logo_clut224(void)
78471 fputs("\n};\n\n", out);
78472
78473 /* write logo clut */
78474 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
78475 + fprintf(out, "static unsigned char %s_clut[] = {\n",
78476 logoname);
78477 write_hex_cnt = 0;
78478 for (i = 0; i < logo_clutsize; i++) {
78479 diff --git a/scripts/tags.sh b/scripts/tags.sh
78480 index 833813a..0bc8588 100755
78481 --- a/scripts/tags.sh
78482 +++ b/scripts/tags.sh
78483 @@ -116,7 +116,7 @@ docscope()
78484
78485 dogtags()
78486 {
78487 - all_sources | gtags -f -
78488 + all_sources | gtags -i -f -
78489 }
78490
78491 exuberant()
78492 diff --git a/security/Kconfig b/security/Kconfig
78493 index 51bd5a0..c37f5e6 100644
78494 --- a/security/Kconfig
78495 +++ b/security/Kconfig
78496 @@ -4,6 +4,640 @@
78497
78498 menu "Security options"
78499
78500 +source grsecurity/Kconfig
78501 +
78502 +menu "PaX"
78503 +
78504 + config ARCH_TRACK_EXEC_LIMIT
78505 + bool
78506 +
78507 + config PAX_KERNEXEC_PLUGIN
78508 + bool
78509 +
78510 + config PAX_PER_CPU_PGD
78511 + bool
78512 +
78513 + config TASK_SIZE_MAX_SHIFT
78514 + int
78515 + depends on X86_64
78516 + default 47 if !PAX_PER_CPU_PGD
78517 + default 42 if PAX_PER_CPU_PGD
78518 +
78519 + config PAX_ENABLE_PAE
78520 + bool
78521 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
78522 +
78523 +config PAX
78524 + bool "Enable various PaX features"
78525 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
78526 + help
78527 + This allows you to enable various PaX features. PaX adds
78528 + intrusion prevention mechanisms to the kernel that reduce
78529 + the risks posed by exploitable memory corruption bugs.
78530 +
78531 +menu "PaX Control"
78532 + depends on PAX
78533 +
78534 +config PAX_SOFTMODE
78535 + bool 'Support soft mode'
78536 + help
78537 + Enabling this option will allow you to run PaX in soft mode, that
78538 + is, PaX features will not be enforced by default, only on executables
78539 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
78540 + support as they are the only way to mark executables for soft mode use.
78541 +
78542 + Soft mode can be activated by using the "pax_softmode=1" kernel command
78543 + line option on boot. Furthermore you can control various PaX features
78544 + at runtime via the entries in /proc/sys/kernel/pax.
78545 +
78546 +config PAX_EI_PAX
78547 + bool 'Use legacy ELF header marking'
78548 + help
78549 + Enabling this option will allow you to control PaX features on
78550 + a per executable basis via the 'chpax' utility available at
78551 + http://pax.grsecurity.net/. The control flags will be read from
78552 + an otherwise reserved part of the ELF header. This marking has
78553 + numerous drawbacks (no support for soft-mode, toolchain does not
78554 + know about the non-standard use of the ELF header) therefore it
78555 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
78556 + support.
78557 +
78558 + If you have applications not marked by the PT_PAX_FLAGS ELF program
78559 + header and you cannot use XATTR_PAX_FLAGS then you MUST enable this
78560 + option otherwise they will not get any protection.
78561 +
78562 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
78563 + support as well, they will override the legacy EI_PAX marks.
78564 +
78565 +config PAX_PT_PAX_FLAGS
78566 + bool 'Use ELF program header marking'
78567 + help
78568 + Enabling this option will allow you to control PaX features on
78569 + a per executable basis via the 'paxctl' utility available at
78570 + http://pax.grsecurity.net/. The control flags will be read from
78571 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
78572 + has the benefits of supporting both soft mode and being fully
78573 + integrated into the toolchain (the binutils patch is available
78574 + from http://pax.grsecurity.net).
78575 +
78576 + If you have applications not marked by the PT_PAX_FLAGS ELF program
78577 + header then you MUST enable either XATTR_PAX_FLAGS or EI_PAX marking
78578 + support otherwise they will not get any protection.
78579 +
78580 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
78581 + must make sure that the marks are the same if a binary has both marks.
78582 +
78583 + Note that if you enable the legacy EI_PAX marking support as well,
78584 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
78585 +
78586 +config PAX_XATTR_PAX_FLAGS
78587 + bool 'Use filesystem extended attributes marking'
78588 + select CIFS_XATTR if CIFS
78589 + select EXT2_FS_XATTR if EXT2_FS
78590 + select EXT3_FS_XATTR if EXT3_FS
78591 + select EXT4_FS_XATTR if EXT4_FS
78592 + select JFFS2_FS_XATTR if JFFS2_FS
78593 + select REISERFS_FS_XATTR if REISERFS_FS
78594 + select SQUASHFS_XATTR if SQUASHFS
78595 + select TMPFS_XATTR if TMPFS
78596 + select UBIFS_FS_XATTR if UBIFS_FS
78597 + help
78598 + Enabling this option will allow you to control PaX features on
78599 + a per executable basis via the 'setfattr' utility. The control
78600 + flags will be read from the user.pax.flags extended attribute of
78601 + the file. This marking has the benefit of supporting binary-only
78602 + applications that self-check themselves (e.g., skype) and would
78603 + not tolerate chpax/paxctl changes. The main drawback is that
78604 + extended attributes are not supported by some filesystems (e.g.,
78605 + isofs, udf, vfat) so copying files through such filesystems will
78606 + lose the extended attributes and these PaX markings.
78607 +
78608 + If you have applications not marked by the PT_PAX_FLAGS ELF program
78609 + header then you MUST enable either XATTR_PAX_FLAGS or EI_PAX marking
78610 + support otherwise they will not get any protection.
78611 +
78612 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
78613 + must make sure that the marks are the same if a binary has both marks.
78614 +
78615 + Note that if you enable the legacy EI_PAX marking support as well,
78616 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
78617 +
78618 +choice
78619 + prompt 'MAC system integration'
78620 + default PAX_HAVE_ACL_FLAGS
78621 + help
78622 + Mandatory Access Control systems have the option of controlling
78623 + PaX flags on a per executable basis, choose the method supported
78624 + by your particular system.
78625 +
78626 + - "none": if your MAC system does not interact with PaX,
78627 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
78628 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
78629 +
78630 + NOTE: this option is for developers/integrators only.
78631 +
78632 + config PAX_NO_ACL_FLAGS
78633 + bool 'none'
78634 +
78635 + config PAX_HAVE_ACL_FLAGS
78636 + bool 'direct'
78637 +
78638 + config PAX_HOOK_ACL_FLAGS
78639 + bool 'hook'
78640 +endchoice
78641 +
78642 +endmenu
78643 +
78644 +menu "Non-executable pages"
78645 + depends on PAX
78646 +
78647 +config PAX_NOEXEC
78648 + bool "Enforce non-executable pages"
78649 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
78650 + help
78651 + By design some architectures do not allow for protecting memory
78652 + pages against execution or even if they do, Linux does not make
78653 + use of this feature. In practice this means that if a page is
78654 + readable (such as the stack or heap) it is also executable.
78655 +
78656 + There is a well known exploit technique that makes use of this
78657 + fact and a common programming mistake where an attacker can
78658 + introduce code of his choice somewhere in the attacked program's
78659 + memory (typically the stack or the heap) and then execute it.
78660 +
78661 + If the attacked program was running with different (typically
78662 + higher) privileges than that of the attacker, then he can elevate
78663 + his own privilege level (e.g. get a root shell, write to files for
78664 + which he does not have write access to, etc).
78665 +
78666 + Enabling this option will let you choose from various features
78667 + that prevent the injection and execution of 'foreign' code in
78668 + a program.
78669 +
78670 + This will also break programs that rely on the old behaviour and
78671 + expect that dynamically allocated memory via the malloc() family
78672 + of functions is executable (which it is not). Notable examples
78673 + are the XFree86 4.x server, the java runtime and wine.
78674 +
78675 +config PAX_PAGEEXEC
78676 + bool "Paging based non-executable pages"
78677 + 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)
78678 + select S390_SWITCH_AMODE if S390
78679 + select S390_EXEC_PROTECT if S390
78680 + select ARCH_TRACK_EXEC_LIMIT if X86_32
78681 + help
78682 + This implementation is based on the paging feature of the CPU.
78683 + On i386 without hardware non-executable bit support there is a
78684 + variable but usually low performance impact, however on Intel's
78685 + P4 core based CPUs it is very high so you should not enable this
78686 + for kernels meant to be used on such CPUs.
78687 +
78688 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
78689 + with hardware non-executable bit support there is no performance
78690 + impact, on ppc the impact is negligible.
78691 +
78692 + Note that several architectures require various emulations due to
78693 + badly designed userland ABIs, this will cause a performance impact
78694 + but will disappear as soon as userland is fixed. For example, ppc
78695 + userland MUST have been built with secure-plt by a recent toolchain.
78696 +
78697 +config PAX_SEGMEXEC
78698 + bool "Segmentation based non-executable pages"
78699 + depends on PAX_NOEXEC && X86_32
78700 + help
78701 + This implementation is based on the segmentation feature of the
78702 + CPU and has a very small performance impact, however applications
78703 + will be limited to a 1.5 GB address space instead of the normal
78704 + 3 GB.
78705 +
78706 +config PAX_EMUTRAMP
78707 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
78708 + default y if PARISC
78709 + help
78710 + There are some programs and libraries that for one reason or
78711 + another attempt to execute special small code snippets from
78712 + non-executable memory pages. Most notable examples are the
78713 + signal handler return code generated by the kernel itself and
78714 + the GCC trampolines.
78715 +
78716 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
78717 + such programs will no longer work under your kernel.
78718 +
78719 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
78720 + utilities to enable trampoline emulation for the affected programs
78721 + yet still have the protection provided by the non-executable pages.
78722 +
78723 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
78724 + your system will not even boot.
78725 +
78726 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
78727 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
78728 + for the affected files.
78729 +
78730 + NOTE: enabling this feature *may* open up a loophole in the
78731 + protection provided by non-executable pages that an attacker
78732 + could abuse. Therefore the best solution is to not have any
78733 + files on your system that would require this option. This can
78734 + be achieved by not using libc5 (which relies on the kernel
78735 + signal handler return code) and not using or rewriting programs
78736 + that make use of the nested function implementation of GCC.
78737 + Skilled users can just fix GCC itself so that it implements
78738 + nested function calls in a way that does not interfere with PaX.
78739 +
78740 +config PAX_EMUSIGRT
78741 + bool "Automatically emulate sigreturn trampolines"
78742 + depends on PAX_EMUTRAMP && PARISC
78743 + default y
78744 + help
78745 + Enabling this option will have the kernel automatically detect
78746 + and emulate signal return trampolines executing on the stack
78747 + that would otherwise lead to task termination.
78748 +
78749 + This solution is intended as a temporary one for users with
78750 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
78751 + Modula-3 runtime, etc) or executables linked to such, basically
78752 + everything that does not specify its own SA_RESTORER function in
78753 + normal executable memory like glibc 2.1+ does.
78754 +
78755 + On parisc you MUST enable this option, otherwise your system will
78756 + not even boot.
78757 +
78758 + NOTE: this feature cannot be disabled on a per executable basis
78759 + and since it *does* open up a loophole in the protection provided
78760 + by non-executable pages, the best solution is to not have any
78761 + files on your system that would require this option.
78762 +
78763 +config PAX_MPROTECT
78764 + bool "Restrict mprotect()"
78765 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
78766 + help
78767 + Enabling this option will prevent programs from
78768 + - changing the executable status of memory pages that were
78769 + not originally created as executable,
78770 + - making read-only executable pages writable again,
78771 + - creating executable pages from anonymous memory,
78772 + - making read-only-after-relocations (RELRO) data pages writable again.
78773 +
78774 + You should say Y here to complete the protection provided by
78775 + the enforcement of non-executable pages.
78776 +
78777 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
78778 + this feature on a per file basis.
78779 +
78780 +config PAX_MPROTECT_COMPAT
78781 + bool "Use legacy/compat protection demoting (read help)"
78782 + depends on PAX_MPROTECT
78783 + default n
78784 + help
78785 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
78786 + by sending the proper error code to the application. For some broken
78787 + userland, this can cause problems with Python or other applications. The
78788 + current implementation however allows for applications like clamav to
78789 + detect if JIT compilation/execution is allowed and to fall back gracefully
78790 + to an interpreter-based mode if it does not. While we encourage everyone
78791 + to use the current implementation as-is and push upstream to fix broken
78792 + userland (note that the RWX logging option can assist with this), in some
78793 + environments this may not be possible. Having to disable MPROTECT
78794 + completely on certain binaries reduces the security benefit of PaX,
78795 + so this option is provided for those environments to revert to the old
78796 + behavior.
78797 +
78798 +config PAX_ELFRELOCS
78799 + bool "Allow ELF text relocations (read help)"
78800 + depends on PAX_MPROTECT
78801 + default n
78802 + help
78803 + Non-executable pages and mprotect() restrictions are effective
78804 + in preventing the introduction of new executable code into an
78805 + attacked task's address space. There remain only two venues
78806 + for this kind of attack: if the attacker can execute already
78807 + existing code in the attacked task then he can either have it
78808 + create and mmap() a file containing his code or have it mmap()
78809 + an already existing ELF library that does not have position
78810 + independent code in it and use mprotect() on it to make it
78811 + writable and copy his code there. While protecting against
78812 + the former approach is beyond PaX, the latter can be prevented
78813 + by having only PIC ELF libraries on one's system (which do not
78814 + need to relocate their code). If you are sure this is your case,
78815 + as is the case with all modern Linux distributions, then leave
78816 + this option disabled. You should say 'n' here.
78817 +
78818 +config PAX_ETEXECRELOCS
78819 + bool "Allow ELF ET_EXEC text relocations"
78820 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
78821 + select PAX_ELFRELOCS
78822 + default y
78823 + help
78824 + On some architectures there are incorrectly created applications
78825 + that require text relocations and would not work without enabling
78826 + this option. If you are an alpha, ia64 or parisc user, you should
78827 + enable this option and disable it once you have made sure that
78828 + none of your applications need it.
78829 +
78830 +config PAX_EMUPLT
78831 + bool "Automatically emulate ELF PLT"
78832 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
78833 + default y
78834 + help
78835 + Enabling this option will have the kernel automatically detect
78836 + and emulate the Procedure Linkage Table entries in ELF files.
78837 + On some architectures such entries are in writable memory, and
78838 + become non-executable leading to task termination. Therefore
78839 + it is mandatory that you enable this option on alpha, parisc,
78840 + sparc and sparc64, otherwise your system would not even boot.
78841 +
78842 + NOTE: this feature *does* open up a loophole in the protection
78843 + provided by the non-executable pages, therefore the proper
78844 + solution is to modify the toolchain to produce a PLT that does
78845 + not need to be writable.
78846 +
78847 +config PAX_DLRESOLVE
78848 + bool 'Emulate old glibc resolver stub'
78849 + depends on PAX_EMUPLT && SPARC
78850 + default n
78851 + help
78852 + This option is needed if userland has an old glibc (before 2.4)
78853 + that puts a 'save' instruction into the runtime generated resolver
78854 + stub that needs special emulation.
78855 +
78856 +config PAX_KERNEXEC
78857 + bool "Enforce non-executable kernel pages"
78858 + depends on (PPC || X86) && (!X86_32 || X86_WP_WORKS_OK) && !XEN
78859 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
78860 + select PAX_KERNEXEC_PLUGIN if X86_64
78861 + help
78862 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
78863 + that is, enabling this option will make it harder to inject
78864 + and execute 'foreign' code in kernel memory itself.
78865 +
78866 + Note that on x86_64 kernels there is a known regression when
78867 + this feature and KVM/VMX are both enabled in the host kernel.
78868 +
78869 +choice
78870 + prompt "Return Address Instrumentation Method"
78871 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
78872 + depends on PAX_KERNEXEC_PLUGIN
78873 + help
78874 + Select the method used to instrument function pointer dereferences.
78875 + Note that binary modules cannot be instrumented by this approach.
78876 +
78877 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
78878 + bool "bts"
78879 + help
78880 + This method is compatible with binary only modules but has
78881 + a higher runtime overhead.
78882 +
78883 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
78884 + bool "or"
78885 + depends on !PARAVIRT
78886 + help
78887 + This method is incompatible with binary only modules but has
78888 + a lower runtime overhead.
78889 +endchoice
78890 +
78891 +config PAX_KERNEXEC_PLUGIN_METHOD
78892 + string
78893 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
78894 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
78895 + default ""
78896 +
78897 +config PAX_KERNEXEC_MODULE_TEXT
78898 + int "Minimum amount of memory reserved for module code"
78899 + default "4"
78900 + depends on PAX_KERNEXEC && X86_32 && MODULES
78901 + help
78902 + Due to implementation details the kernel must reserve a fixed
78903 + amount of memory for module code at compile time that cannot be
78904 + changed at runtime. Here you can specify the minimum amount
78905 + in MB that will be reserved. Due to the same implementation
78906 + details this size will always be rounded up to the next 2/4 MB
78907 + boundary (depends on PAE) so the actually available memory for
78908 + module code will usually be more than this minimum.
78909 +
78910 + The default 4 MB should be enough for most users but if you have
78911 + an excessive number of modules (e.g., most distribution configs
78912 + compile many drivers as modules) or use huge modules such as
78913 + nvidia's kernel driver, you will need to adjust this amount.
78914 + A good rule of thumb is to look at your currently loaded kernel
78915 + modules and add up their sizes.
78916 +
78917 +endmenu
78918 +
78919 +menu "Address Space Layout Randomization"
78920 + depends on PAX
78921 +
78922 +config PAX_ASLR
78923 + bool "Address Space Layout Randomization"
78924 + help
78925 + Many if not most exploit techniques rely on the knowledge of
78926 + certain addresses in the attacked program. The following options
78927 + will allow the kernel to apply a certain amount of randomization
78928 + to specific parts of the program thereby forcing an attacker to
78929 + guess them in most cases. Any failed guess will most likely crash
78930 + the attacked program which allows the kernel to detect such attempts
78931 + and react on them. PaX itself provides no reaction mechanisms,
78932 + instead it is strongly encouraged that you make use of Nergal's
78933 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
78934 + (http://www.grsecurity.net/) built-in crash detection features or
78935 + develop one yourself.
78936 +
78937 + By saying Y here you can choose to randomize the following areas:
78938 + - top of the task's kernel stack
78939 + - top of the task's userland stack
78940 + - base address for mmap() requests that do not specify one
78941 + (this includes all libraries)
78942 + - base address of the main executable
78943 +
78944 + It is strongly recommended to say Y here as address space layout
78945 + randomization has negligible impact on performance yet it provides
78946 + a very effective protection.
78947 +
78948 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
78949 + this feature on a per file basis.
78950 +
78951 +config PAX_RANDKSTACK
78952 + bool "Randomize kernel stack base"
78953 + depends on X86_TSC && X86
78954 + help
78955 + By saying Y here the kernel will randomize every task's kernel
78956 + stack on every system call. This will not only force an attacker
78957 + to guess it but also prevent him from making use of possible
78958 + leaked information about it.
78959 +
78960 + Since the kernel stack is a rather scarce resource, randomization
78961 + may cause unexpected stack overflows, therefore you should very
78962 + carefully test your system. Note that once enabled in the kernel
78963 + configuration, this feature cannot be disabled on a per file basis.
78964 +
78965 +config PAX_RANDUSTACK
78966 + bool "Randomize user stack base"
78967 + depends on PAX_ASLR
78968 + help
78969 + By saying Y here the kernel will randomize every task's userland
78970 + stack. The randomization is done in two steps where the second
78971 + one may apply a big amount of shift to the top of the stack and
78972 + cause problems for programs that want to use lots of memory (more
78973 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
78974 + For this reason the second step can be controlled by 'chpax' or
78975 + 'paxctl' on a per file basis.
78976 +
78977 +config PAX_RANDMMAP
78978 + bool "Randomize mmap() base"
78979 + depends on PAX_ASLR
78980 + help
78981 + By saying Y here the kernel will use a randomized base address for
78982 + mmap() requests that do not specify one themselves. As a result
78983 + all dynamically loaded libraries will appear at random addresses
78984 + and therefore be harder to exploit by a technique where an attacker
78985 + attempts to execute library code for his purposes (e.g. spawn a
78986 + shell from an exploited program that is running at an elevated
78987 + privilege level).
78988 +
78989 + Furthermore, if a program is relinked as a dynamic ELF file, its
78990 + base address will be randomized as well, completing the full
78991 + randomization of the address space layout. Attacking such programs
78992 + becomes a guess game. You can find an example of doing this at
78993 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
78994 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
78995 +
78996 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
78997 + feature on a per file basis.
78998 +
78999 +endmenu
79000 +
79001 +menu "Miscellaneous hardening features"
79002 +
79003 +config PAX_MEMORY_SANITIZE
79004 + bool "Sanitize all freed memory"
79005 + depends on !HIBERNATION
79006 + help
79007 + By saying Y here the kernel will erase memory pages as soon as they
79008 + are freed. This in turn reduces the lifetime of data stored in the
79009 + pages, making it less likely that sensitive information such as
79010 + passwords, cryptographic secrets, etc stay in memory for too long.
79011 +
79012 + This is especially useful for programs whose runtime is short, long
79013 + lived processes and the kernel itself benefit from this as long as
79014 + they operate on whole memory pages and ensure timely freeing of pages
79015 + that may hold sensitive information.
79016 +
79017 + The tradeoff is performance impact, on a single CPU system kernel
79018 + compilation sees a 3% slowdown, other systems and workloads may vary
79019 + and you are advised to test this feature on your expected workload
79020 + before deploying it.
79021 +
79022 + Note that this feature does not protect data stored in live pages,
79023 + e.g., process memory swapped to disk may stay there for a long time.
79024 +
79025 +config PAX_MEMORY_STACKLEAK
79026 + bool "Sanitize kernel stack"
79027 + depends on X86
79028 + help
79029 + By saying Y here the kernel will erase the kernel stack before it
79030 + returns from a system call. This in turn reduces the information
79031 + that a kernel stack leak bug can reveal.
79032 +
79033 + Note that such a bug can still leak information that was put on
79034 + the stack by the current system call (the one eventually triggering
79035 + the bug) but traces of earlier system calls on the kernel stack
79036 + cannot leak anymore.
79037 +
79038 + The tradeoff is performance impact: on a single CPU system kernel
79039 + compilation sees a 1% slowdown, other systems and workloads may vary
79040 + and you are advised to test this feature on your expected workload
79041 + before deploying it.
79042 +
79043 + Note: full support for this feature requires gcc with plugin support
79044 + so make sure your compiler is at least gcc 4.5.0. Using older gcc
79045 + versions means that functions with large enough stack frames may
79046 + leave uninitialized memory behind that may be exposed to a later
79047 + syscall leaking the stack.
79048 +
79049 +config PAX_MEMORY_UDEREF
79050 + bool "Prevent invalid userland pointer dereference"
79051 + depends on X86 && !UML_X86 && !XEN
79052 + select PAX_PER_CPU_PGD if X86_64
79053 + help
79054 + By saying Y here the kernel will be prevented from dereferencing
79055 + userland pointers in contexts where the kernel expects only kernel
79056 + pointers. This is both a useful runtime debugging feature and a
79057 + security measure that prevents exploiting a class of kernel bugs.
79058 +
79059 + The tradeoff is that some virtualization solutions may experience
79060 + a huge slowdown and therefore you should not enable this feature
79061 + for kernels meant to run in such environments. Whether a given VM
79062 + solution is affected or not is best determined by simply trying it
79063 + out, the performance impact will be obvious right on boot as this
79064 + mechanism engages from very early on. A good rule of thumb is that
79065 + VMs running on CPUs without hardware virtualization support (i.e.,
79066 + the majority of IA-32 CPUs) will likely experience the slowdown.
79067 +
79068 +config PAX_REFCOUNT
79069 + bool "Prevent various kernel object reference counter overflows"
79070 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
79071 + help
79072 + By saying Y here the kernel will detect and prevent overflowing
79073 + various (but not all) kinds of object reference counters. Such
79074 + overflows can normally occur due to bugs only and are often, if
79075 + not always, exploitable.
79076 +
79077 + The tradeoff is that data structures protected by an overflowed
79078 + refcount will never be freed and therefore will leak memory. Note
79079 + that this leak also happens even without this protection but in
79080 + that case the overflow can eventually trigger the freeing of the
79081 + data structure while it is still being used elsewhere, resulting
79082 + in the exploitable situation that this feature prevents.
79083 +
79084 + Since this has a negligible performance impact, you should enable
79085 + this feature.
79086 +
79087 +config PAX_USERCOPY
79088 + bool "Harden heap object copies between kernel and userland"
79089 + depends on X86 || PPC || SPARC || ARM
79090 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
79091 + help
79092 + By saying Y here the kernel will enforce the size of heap objects
79093 + when they are copied in either direction between the kernel and
79094 + userland, even if only a part of the heap object is copied.
79095 +
79096 + Specifically, this checking prevents information leaking from the
79097 + kernel heap during kernel to userland copies (if the kernel heap
79098 + object is otherwise fully initialized) and prevents kernel heap
79099 + overflows during userland to kernel copies.
79100 +
79101 + Note that the current implementation provides the strictest bounds
79102 + checks for the SLUB allocator.
79103 +
79104 + Enabling this option also enables per-slab cache protection against
79105 + data in a given cache being copied into/out of via userland
79106 + accessors. Though the whitelist of regions will be reduced over
79107 + time, it notably protects important data structures like task structs.
79108 +
79109 + If frame pointers are enabled on x86, this option will also restrict
79110 + copies into and out of the kernel stack to local variables within a
79111 + single frame.
79112 +
79113 + Since this has a negligible performance impact, you should enable
79114 + this feature.
79115 +
79116 +config PAX_SIZE_OVERFLOW
79117 + bool "Prevent various integer overflows in function size parameters"
79118 + depends on X86
79119 + help
79120 + By saying Y here the kernel recomputes expressions of function
79121 + arguments marked by a size_overflow attribute with double integer
79122 + precision (DImode/TImode for 32/64 bit integer types).
79123 +
79124 + The recomputed argument is checked against INT_MAX and an event
79125 + is logged on overflow and the triggering process is killed.
79126 +
79127 + Homepage:
79128 + http://www.grsecurity.net/~ephox/overflow_plugin/
79129 +
79130 +endmenu
79131 +
79132 +endmenu
79133 +
79134 config KEYS
79135 bool "Enable access key retention support"
79136 help
79137 @@ -169,7 +803,7 @@ config INTEL_TXT
79138 config LSM_MMAP_MIN_ADDR
79139 int "Low address space for LSM to protect from user allocation"
79140 depends on SECURITY && SECURITY_SELINUX
79141 - default 32768 if ARM
79142 + default 32768 if ALPHA || ARM || PARISC || SPARC32
79143 default 65536
79144 help
79145 This is the portion of low virtual memory which should be protected
79146 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
79147 index 97ce8fa..23dad96 100644
79148 --- a/security/apparmor/lsm.c
79149 +++ b/security/apparmor/lsm.c
79150 @@ -620,7 +620,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
79151 return error;
79152 }
79153
79154 -static struct security_operations apparmor_ops = {
79155 +static struct security_operations apparmor_ops __read_only = {
79156 .name = "apparmor",
79157
79158 .ptrace_access_check = apparmor_ptrace_access_check,
79159 diff --git a/security/commoncap.c b/security/commoncap.c
79160 index b8d2bb9..980069e 100644
79161 --- a/security/commoncap.c
79162 +++ b/security/commoncap.c
79163 @@ -29,6 +29,7 @@
79164 #include <linux/securebits.h>
79165 #include <linux/user_namespace.h>
79166 #include <linux/personality.h>
79167 +#include <net/sock.h>
79168
79169 /*
79170 * If a non-root user executes a setuid-root binary in
79171 @@ -575,6 +576,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
79172 {
79173 const struct cred *cred = current_cred();
79174
79175 + if (gr_acl_enable_at_secure())
79176 + return 1;
79177 +
79178 if (cred->uid != 0) {
79179 if (bprm->cap_effective)
79180 return 1;
79181 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
79182 index 3ccf7ac..d73ad64 100644
79183 --- a/security/integrity/ima/ima.h
79184 +++ b/security/integrity/ima/ima.h
79185 @@ -86,8 +86,8 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
79186 extern spinlock_t ima_queue_lock;
79187
79188 struct ima_h_table {
79189 - atomic_long_t len; /* number of stored measurements in the list */
79190 - atomic_long_t violations;
79191 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
79192 + atomic_long_unchecked_t violations;
79193 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
79194 };
79195 extern struct ima_h_table ima_htable;
79196 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
79197 index 88a2788..581ab92 100644
79198 --- a/security/integrity/ima/ima_api.c
79199 +++ b/security/integrity/ima/ima_api.c
79200 @@ -75,7 +75,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
79201 int result;
79202
79203 /* can overflow, only indicator */
79204 - atomic_long_inc(&ima_htable.violations);
79205 + atomic_long_inc_unchecked(&ima_htable.violations);
79206
79207 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
79208 if (!entry) {
79209 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
79210 index e1aa2b4..52027bf 100644
79211 --- a/security/integrity/ima/ima_fs.c
79212 +++ b/security/integrity/ima/ima_fs.c
79213 @@ -28,12 +28,12 @@
79214 static int valid_policy = 1;
79215 #define TMPBUFLEN 12
79216 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
79217 - loff_t *ppos, atomic_long_t *val)
79218 + loff_t *ppos, atomic_long_unchecked_t *val)
79219 {
79220 char tmpbuf[TMPBUFLEN];
79221 ssize_t len;
79222
79223 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
79224 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
79225 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
79226 }
79227
79228 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
79229 index 55a6271..ad829c3 100644
79230 --- a/security/integrity/ima/ima_queue.c
79231 +++ b/security/integrity/ima/ima_queue.c
79232 @@ -81,7 +81,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
79233 INIT_LIST_HEAD(&qe->later);
79234 list_add_tail_rcu(&qe->later, &ima_measurements);
79235
79236 - atomic_long_inc(&ima_htable.len);
79237 + atomic_long_inc_unchecked(&ima_htable.len);
79238 key = ima_hash_key(entry->digest);
79239 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
79240 return 0;
79241 diff --git a/security/keys/compat.c b/security/keys/compat.c
79242 index 4c48e13..7abdac9 100644
79243 --- a/security/keys/compat.c
79244 +++ b/security/keys/compat.c
79245 @@ -44,7 +44,7 @@ long compat_keyctl_instantiate_key_iov(
79246 if (ret == 0)
79247 goto no_payload_free;
79248
79249 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
79250 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
79251
79252 if (iov != iovstack)
79253 kfree(iov);
79254 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
79255 index 0b3f5d7..892c8a6 100644
79256 --- a/security/keys/keyctl.c
79257 +++ b/security/keys/keyctl.c
79258 @@ -921,7 +921,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
79259 /*
79260 * Copy the iovec data from userspace
79261 */
79262 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
79263 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
79264 unsigned ioc)
79265 {
79266 for (; ioc > 0; ioc--) {
79267 @@ -943,7 +943,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
79268 * If successful, 0 will be returned.
79269 */
79270 long keyctl_instantiate_key_common(key_serial_t id,
79271 - const struct iovec *payload_iov,
79272 + const struct iovec __user *payload_iov,
79273 unsigned ioc,
79274 size_t plen,
79275 key_serial_t ringid)
79276 @@ -1038,7 +1038,7 @@ long keyctl_instantiate_key(key_serial_t id,
79277 [0].iov_len = plen
79278 };
79279
79280 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
79281 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
79282 }
79283
79284 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
79285 @@ -1071,7 +1071,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
79286 if (ret == 0)
79287 goto no_payload_free;
79288
79289 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
79290 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
79291
79292 if (iov != iovstack)
79293 kfree(iov);
79294 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
79295 index d605f75..2bc6be9 100644
79296 --- a/security/keys/keyring.c
79297 +++ b/security/keys/keyring.c
79298 @@ -214,15 +214,15 @@ static long keyring_read(const struct key *keyring,
79299 ret = -EFAULT;
79300
79301 for (loop = 0; loop < klist->nkeys; loop++) {
79302 + key_serial_t serial;
79303 key = klist->keys[loop];
79304 + serial = key->serial;
79305
79306 tmp = sizeof(key_serial_t);
79307 if (tmp > buflen)
79308 tmp = buflen;
79309
79310 - if (copy_to_user(buffer,
79311 - &key->serial,
79312 - tmp) != 0)
79313 + if (copy_to_user(buffer, &serial, tmp))
79314 goto error;
79315
79316 buflen -= tmp;
79317 diff --git a/security/min_addr.c b/security/min_addr.c
79318 index f728728..6457a0c 100644
79319 --- a/security/min_addr.c
79320 +++ b/security/min_addr.c
79321 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
79322 */
79323 static void update_mmap_min_addr(void)
79324 {
79325 +#ifndef SPARC
79326 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
79327 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
79328 mmap_min_addr = dac_mmap_min_addr;
79329 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
79330 #else
79331 mmap_min_addr = dac_mmap_min_addr;
79332 #endif
79333 +#endif
79334 }
79335
79336 /*
79337 diff --git a/security/security.c b/security/security.c
79338 index d754249..8bf426e 100644
79339 --- a/security/security.c
79340 +++ b/security/security.c
79341 @@ -26,8 +26,8 @@
79342 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
79343 CONFIG_DEFAULT_SECURITY;
79344
79345 -static struct security_operations *security_ops;
79346 -static struct security_operations default_security_ops = {
79347 +static struct security_operations *security_ops __read_only;
79348 +static struct security_operations default_security_ops __read_only = {
79349 .name = "default",
79350 };
79351
79352 @@ -68,7 +68,9 @@ int __init security_init(void)
79353
79354 void reset_security_ops(void)
79355 {
79356 + pax_open_kernel();
79357 security_ops = &default_security_ops;
79358 + pax_close_kernel();
79359 }
79360
79361 /* Save user chosen LSM */
79362 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
79363 index 6a3683e..f52f4c0 100644
79364 --- a/security/selinux/hooks.c
79365 +++ b/security/selinux/hooks.c
79366 @@ -94,8 +94,6 @@
79367
79368 #define NUM_SEL_MNT_OPTS 5
79369
79370 -extern struct security_operations *security_ops;
79371 -
79372 /* SECMARK reference count */
79373 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
79374
79375 @@ -5429,7 +5427,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
79376
79377 #endif
79378
79379 -static struct security_operations selinux_ops = {
79380 +static struct security_operations selinux_ops __read_only = {
79381 .name = "selinux",
79382
79383 .ptrace_access_check = selinux_ptrace_access_check,
79384 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
79385 index b43813c..74be837 100644
79386 --- a/security/selinux/include/xfrm.h
79387 +++ b/security/selinux/include/xfrm.h
79388 @@ -48,7 +48,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
79389
79390 static inline void selinux_xfrm_notify_policyload(void)
79391 {
79392 - atomic_inc(&flow_cache_genid);
79393 + atomic_inc_unchecked(&flow_cache_genid);
79394 }
79395 #else
79396 static inline int selinux_xfrm_enabled(void)
79397 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
79398 index e8af5b0b..78527ef 100644
79399 --- a/security/smack/smack_lsm.c
79400 +++ b/security/smack/smack_lsm.c
79401 @@ -3481,7 +3481,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
79402 return 0;
79403 }
79404
79405 -struct security_operations smack_ops = {
79406 +struct security_operations smack_ops __read_only = {
79407 .name = "smack",
79408
79409 .ptrace_access_check = smack_ptrace_access_check,
79410 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
79411 index 620d37c..e2ad89b 100644
79412 --- a/security/tomoyo/tomoyo.c
79413 +++ b/security/tomoyo/tomoyo.c
79414 @@ -501,7 +501,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
79415 * tomoyo_security_ops is a "struct security_operations" which is used for
79416 * registering TOMOYO.
79417 */
79418 -static struct security_operations tomoyo_security_ops = {
79419 +static struct security_operations tomoyo_security_ops __read_only = {
79420 .name = "tomoyo",
79421 .cred_alloc_blank = tomoyo_cred_alloc_blank,
79422 .cred_prepare = tomoyo_cred_prepare,
79423 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
79424 index 762af68..7103453 100644
79425 --- a/sound/aoa/codecs/onyx.c
79426 +++ b/sound/aoa/codecs/onyx.c
79427 @@ -54,7 +54,7 @@ struct onyx {
79428 spdif_locked:1,
79429 analog_locked:1,
79430 original_mute:2;
79431 - int open_count;
79432 + local_t open_count;
79433 struct codec_info *codec_info;
79434
79435 /* mutex serializes concurrent access to the device
79436 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
79437 struct onyx *onyx = cii->codec_data;
79438
79439 mutex_lock(&onyx->mutex);
79440 - onyx->open_count++;
79441 + local_inc(&onyx->open_count);
79442 mutex_unlock(&onyx->mutex);
79443
79444 return 0;
79445 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
79446 struct onyx *onyx = cii->codec_data;
79447
79448 mutex_lock(&onyx->mutex);
79449 - onyx->open_count--;
79450 - if (!onyx->open_count)
79451 + if (local_dec_and_test(&onyx->open_count))
79452 onyx->spdif_locked = onyx->analog_locked = 0;
79453 mutex_unlock(&onyx->mutex);
79454
79455 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
79456 index ffd2025..df062c9 100644
79457 --- a/sound/aoa/codecs/onyx.h
79458 +++ b/sound/aoa/codecs/onyx.h
79459 @@ -11,6 +11,7 @@
79460 #include <linux/i2c.h>
79461 #include <asm/pmac_low_i2c.h>
79462 #include <asm/prom.h>
79463 +#include <asm/local.h>
79464
79465 /* PCM3052 register definitions */
79466
79467 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
79468 index 08fde00..0bf641a 100644
79469 --- a/sound/core/oss/pcm_oss.c
79470 +++ b/sound/core/oss/pcm_oss.c
79471 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
79472 if (in_kernel) {
79473 mm_segment_t fs;
79474 fs = snd_enter_user();
79475 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
79476 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
79477 snd_leave_user(fs);
79478 } else {
79479 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
79480 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
79481 }
79482 if (ret != -EPIPE && ret != -ESTRPIPE)
79483 break;
79484 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
79485 if (in_kernel) {
79486 mm_segment_t fs;
79487 fs = snd_enter_user();
79488 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
79489 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
79490 snd_leave_user(fs);
79491 } else {
79492 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
79493 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
79494 }
79495 if (ret == -EPIPE) {
79496 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
79497 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
79498 struct snd_pcm_plugin_channel *channels;
79499 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
79500 if (!in_kernel) {
79501 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
79502 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
79503 return -EFAULT;
79504 buf = runtime->oss.buffer;
79505 }
79506 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
79507 }
79508 } else {
79509 tmp = snd_pcm_oss_write2(substream,
79510 - (const char __force *)buf,
79511 + (const char __force_kernel *)buf,
79512 runtime->oss.period_bytes, 0);
79513 if (tmp <= 0)
79514 goto err;
79515 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
79516 struct snd_pcm_runtime *runtime = substream->runtime;
79517 snd_pcm_sframes_t frames, frames1;
79518 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
79519 - char __user *final_dst = (char __force __user *)buf;
79520 + char __user *final_dst = (char __force_user *)buf;
79521 if (runtime->oss.plugin_first) {
79522 struct snd_pcm_plugin_channel *channels;
79523 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
79524 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
79525 xfer += tmp;
79526 runtime->oss.buffer_used -= tmp;
79527 } else {
79528 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
79529 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
79530 runtime->oss.period_bytes, 0);
79531 if (tmp <= 0)
79532 goto err;
79533 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
79534 size1);
79535 size1 /= runtime->channels; /* frames */
79536 fs = snd_enter_user();
79537 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
79538 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
79539 snd_leave_user(fs);
79540 }
79541 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
79542 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
79543 index 91cdf94..4085161 100644
79544 --- a/sound/core/pcm_compat.c
79545 +++ b/sound/core/pcm_compat.c
79546 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
79547 int err;
79548
79549 fs = snd_enter_user();
79550 - err = snd_pcm_delay(substream, &delay);
79551 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
79552 snd_leave_user(fs);
79553 if (err < 0)
79554 return err;
79555 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
79556 index 25ed9fe..24c46e9 100644
79557 --- a/sound/core/pcm_native.c
79558 +++ b/sound/core/pcm_native.c
79559 @@ -2765,11 +2765,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
79560 switch (substream->stream) {
79561 case SNDRV_PCM_STREAM_PLAYBACK:
79562 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
79563 - (void __user *)arg);
79564 + (void __force_user *)arg);
79565 break;
79566 case SNDRV_PCM_STREAM_CAPTURE:
79567 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
79568 - (void __user *)arg);
79569 + (void __force_user *)arg);
79570 break;
79571 default:
79572 result = -EINVAL;
79573 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
79574 index 5cf8d65..912a79c 100644
79575 --- a/sound/core/seq/seq_device.c
79576 +++ b/sound/core/seq/seq_device.c
79577 @@ -64,7 +64,7 @@ struct ops_list {
79578 int argsize; /* argument size */
79579
79580 /* operators */
79581 - struct snd_seq_dev_ops ops;
79582 + struct snd_seq_dev_ops *ops;
79583
79584 /* registred devices */
79585 struct list_head dev_list; /* list of devices */
79586 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
79587
79588 mutex_lock(&ops->reg_mutex);
79589 /* copy driver operators */
79590 - ops->ops = *entry;
79591 + ops->ops = entry;
79592 ops->driver |= DRIVER_LOADED;
79593 ops->argsize = argsize;
79594
79595 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
79596 dev->name, ops->id, ops->argsize, dev->argsize);
79597 return -EINVAL;
79598 }
79599 - if (ops->ops.init_device(dev) >= 0) {
79600 + if (ops->ops->init_device(dev) >= 0) {
79601 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
79602 ops->num_init_devices++;
79603 } else {
79604 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
79605 dev->name, ops->id, ops->argsize, dev->argsize);
79606 return -EINVAL;
79607 }
79608 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
79609 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
79610 dev->status = SNDRV_SEQ_DEVICE_FREE;
79611 dev->driver_data = NULL;
79612 ops->num_init_devices--;
79613 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
79614 index 621e60e..f4543f5 100644
79615 --- a/sound/drivers/mts64.c
79616 +++ b/sound/drivers/mts64.c
79617 @@ -29,6 +29,7 @@
79618 #include <sound/initval.h>
79619 #include <sound/rawmidi.h>
79620 #include <sound/control.h>
79621 +#include <asm/local.h>
79622
79623 #define CARD_NAME "Miditerminal 4140"
79624 #define DRIVER_NAME "MTS64"
79625 @@ -67,7 +68,7 @@ struct mts64 {
79626 struct pardevice *pardev;
79627 int pardev_claimed;
79628
79629 - int open_count;
79630 + local_t open_count;
79631 int current_midi_output_port;
79632 int current_midi_input_port;
79633 u8 mode[MTS64_NUM_INPUT_PORTS];
79634 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
79635 {
79636 struct mts64 *mts = substream->rmidi->private_data;
79637
79638 - if (mts->open_count == 0) {
79639 + if (local_read(&mts->open_count) == 0) {
79640 /* We don't need a spinlock here, because this is just called
79641 if the device has not been opened before.
79642 So there aren't any IRQs from the device */
79643 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
79644
79645 msleep(50);
79646 }
79647 - ++(mts->open_count);
79648 + local_inc(&mts->open_count);
79649
79650 return 0;
79651 }
79652 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
79653 struct mts64 *mts = substream->rmidi->private_data;
79654 unsigned long flags;
79655
79656 - --(mts->open_count);
79657 - if (mts->open_count == 0) {
79658 + if (local_dec_return(&mts->open_count) == 0) {
79659 /* We need the spinlock_irqsave here because we can still
79660 have IRQs at this point */
79661 spin_lock_irqsave(&mts->lock, flags);
79662 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
79663
79664 msleep(500);
79665
79666 - } else if (mts->open_count < 0)
79667 - mts->open_count = 0;
79668 + } else if (local_read(&mts->open_count) < 0)
79669 + local_set(&mts->open_count, 0);
79670
79671 return 0;
79672 }
79673 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
79674 index b953fb4..1999c01 100644
79675 --- a/sound/drivers/opl4/opl4_lib.c
79676 +++ b/sound/drivers/opl4/opl4_lib.c
79677 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
79678 MODULE_DESCRIPTION("OPL4 driver");
79679 MODULE_LICENSE("GPL");
79680
79681 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
79682 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
79683 {
79684 int timeout = 10;
79685 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
79686 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
79687 index 3e32bd3..46fc152 100644
79688 --- a/sound/drivers/portman2x4.c
79689 +++ b/sound/drivers/portman2x4.c
79690 @@ -48,6 +48,7 @@
79691 #include <sound/initval.h>
79692 #include <sound/rawmidi.h>
79693 #include <sound/control.h>
79694 +#include <asm/local.h>
79695
79696 #define CARD_NAME "Portman 2x4"
79697 #define DRIVER_NAME "portman"
79698 @@ -85,7 +86,7 @@ struct portman {
79699 struct pardevice *pardev;
79700 int pardev_claimed;
79701
79702 - int open_count;
79703 + local_t open_count;
79704 int mode[PORTMAN_NUM_INPUT_PORTS];
79705 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
79706 };
79707 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
79708 index 87657dd..a8268d4 100644
79709 --- a/sound/firewire/amdtp.c
79710 +++ b/sound/firewire/amdtp.c
79711 @@ -371,7 +371,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
79712 ptr = s->pcm_buffer_pointer + data_blocks;
79713 if (ptr >= pcm->runtime->buffer_size)
79714 ptr -= pcm->runtime->buffer_size;
79715 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
79716 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
79717
79718 s->pcm_period_pointer += data_blocks;
79719 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
79720 @@ -511,7 +511,7 @@ EXPORT_SYMBOL(amdtp_out_stream_start);
79721 */
79722 void amdtp_out_stream_update(struct amdtp_out_stream *s)
79723 {
79724 - ACCESS_ONCE(s->source_node_id_field) =
79725 + ACCESS_ONCE_RW(s->source_node_id_field) =
79726 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
79727 }
79728 EXPORT_SYMBOL(amdtp_out_stream_update);
79729 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
79730 index 537a9cb..8e8c8e9 100644
79731 --- a/sound/firewire/amdtp.h
79732 +++ b/sound/firewire/amdtp.h
79733 @@ -146,7 +146,7 @@ static inline void amdtp_out_stream_pcm_prepare(struct amdtp_out_stream *s)
79734 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
79735 struct snd_pcm_substream *pcm)
79736 {
79737 - ACCESS_ONCE(s->pcm) = pcm;
79738 + ACCESS_ONCE_RW(s->pcm) = pcm;
79739 }
79740
79741 /**
79742 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
79743 index cd094ec..eca1277 100644
79744 --- a/sound/firewire/isight.c
79745 +++ b/sound/firewire/isight.c
79746 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
79747 ptr += count;
79748 if (ptr >= runtime->buffer_size)
79749 ptr -= runtime->buffer_size;
79750 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
79751 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
79752
79753 isight->period_counter += count;
79754 if (isight->period_counter >= runtime->period_size) {
79755 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
79756 if (err < 0)
79757 return err;
79758
79759 - ACCESS_ONCE(isight->pcm_active) = true;
79760 + ACCESS_ONCE_RW(isight->pcm_active) = true;
79761
79762 return 0;
79763 }
79764 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
79765 {
79766 struct isight *isight = substream->private_data;
79767
79768 - ACCESS_ONCE(isight->pcm_active) = false;
79769 + ACCESS_ONCE_RW(isight->pcm_active) = false;
79770
79771 mutex_lock(&isight->mutex);
79772 isight_stop_streaming(isight);
79773 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
79774
79775 switch (cmd) {
79776 case SNDRV_PCM_TRIGGER_START:
79777 - ACCESS_ONCE(isight->pcm_running) = true;
79778 + ACCESS_ONCE_RW(isight->pcm_running) = true;
79779 break;
79780 case SNDRV_PCM_TRIGGER_STOP:
79781 - ACCESS_ONCE(isight->pcm_running) = false;
79782 + ACCESS_ONCE_RW(isight->pcm_running) = false;
79783 break;
79784 default:
79785 return -EINVAL;
79786 diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c
79787 index 7bd5e33..1fcab12 100644
79788 --- a/sound/isa/cmi8330.c
79789 +++ b/sound/isa/cmi8330.c
79790 @@ -172,7 +172,7 @@ struct snd_cmi8330 {
79791
79792 struct snd_pcm *pcm;
79793 struct snd_cmi8330_stream {
79794 - struct snd_pcm_ops ops;
79795 + snd_pcm_ops_no_const ops;
79796 snd_pcm_open_callback_t open;
79797 void *private_data; /* sb or wss */
79798 } streams[2];
79799 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
79800 index 733b014..56ce96f 100644
79801 --- a/sound/oss/sb_audio.c
79802 +++ b/sound/oss/sb_audio.c
79803 @@ -901,7 +901,7 @@ sb16_copy_from_user(int dev,
79804 buf16 = (signed short *)(localbuf + localoffs);
79805 while (c)
79806 {
79807 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
79808 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
79809 if (copy_from_user(lbuf8,
79810 userbuf+useroffs + p,
79811 locallen))
79812 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
79813 index 09d4648..cf234c7 100644
79814 --- a/sound/oss/swarm_cs4297a.c
79815 +++ b/sound/oss/swarm_cs4297a.c
79816 @@ -2606,7 +2606,6 @@ static int __init cs4297a_init(void)
79817 {
79818 struct cs4297a_state *s;
79819 u32 pwr, id;
79820 - mm_segment_t fs;
79821 int rval;
79822 #ifndef CONFIG_BCM_CS4297A_CSWARM
79823 u64 cfg;
79824 @@ -2696,22 +2695,23 @@ static int __init cs4297a_init(void)
79825 if (!rval) {
79826 char *sb1250_duart_present;
79827
79828 +#if 0
79829 + mm_segment_t fs;
79830 fs = get_fs();
79831 set_fs(KERNEL_DS);
79832 -#if 0
79833 val = SOUND_MASK_LINE;
79834 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
79835 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
79836 val = initvol[i].vol;
79837 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
79838 }
79839 + set_fs(fs);
79840 // cs4297a_write_ac97(s, 0x18, 0x0808);
79841 #else
79842 // cs4297a_write_ac97(s, 0x5e, 0x180);
79843 cs4297a_write_ac97(s, 0x02, 0x0808);
79844 cs4297a_write_ac97(s, 0x18, 0x0808);
79845 #endif
79846 - set_fs(fs);
79847
79848 list_add(&s->list, &cs4297a_devs);
79849
79850 diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
79851 index f0f1943..8e1f96c 100644
79852 --- a/sound/pci/hda/hda_codec.h
79853 +++ b/sound/pci/hda/hda_codec.h
79854 @@ -611,7 +611,7 @@ struct hda_bus_ops {
79855 /* notify power-up/down from codec to controller */
79856 void (*pm_notify)(struct hda_bus *bus);
79857 #endif
79858 -};
79859 +} __no_const;
79860
79861 /* template to pass to the bus constructor */
79862 struct hda_bus_template {
79863 @@ -713,6 +713,7 @@ struct hda_codec_ops {
79864 #endif
79865 void (*reboot_notify)(struct hda_codec *codec);
79866 };
79867 +typedef struct hda_codec_ops __no_const hda_codec_ops_no_const;
79868
79869 /* record for amp information cache */
79870 struct hda_cache_head {
79871 @@ -743,7 +744,7 @@ struct hda_pcm_ops {
79872 struct snd_pcm_substream *substream);
79873 int (*cleanup)(struct hda_pcm_stream *info, struct hda_codec *codec,
79874 struct snd_pcm_substream *substream);
79875 -};
79876 +} __no_const;
79877
79878 /* PCM information for each substream */
79879 struct hda_pcm_stream {
79880 @@ -801,7 +802,7 @@ struct hda_codec {
79881 const char *modelname; /* model name for preset */
79882
79883 /* set by patch */
79884 - struct hda_codec_ops patch_ops;
79885 + hda_codec_ops_no_const patch_ops;
79886
79887 /* PCM to create, set by patch_ops.build_pcms callback */
79888 unsigned int num_pcms;
79889 diff --git a/sound/pci/ice1712/ice1712.h b/sound/pci/ice1712/ice1712.h
79890 index 0da778a..bc38b84 100644
79891 --- a/sound/pci/ice1712/ice1712.h
79892 +++ b/sound/pci/ice1712/ice1712.h
79893 @@ -269,7 +269,7 @@ struct snd_ak4xxx_private {
79894 unsigned int mask_flags; /* total mask bits */
79895 struct snd_akm4xxx_ops {
79896 void (*set_rate_val)(struct snd_akm4xxx *ak, unsigned int rate);
79897 - } ops;
79898 + } __no_const ops;
79899 };
79900
79901 struct snd_ice1712_spdif {
79902 @@ -285,7 +285,7 @@ struct snd_ice1712_spdif {
79903 int (*default_put)(struct snd_ice1712 *, struct snd_ctl_elem_value *ucontrol);
79904 void (*stream_get)(struct snd_ice1712 *, struct snd_ctl_elem_value *ucontrol);
79905 int (*stream_put)(struct snd_ice1712 *, struct snd_ctl_elem_value *ucontrol);
79906 - } ops;
79907 + } __no_const ops;
79908 };
79909
79910
79911 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
79912 index 12a9a2b..2b6138f 100644
79913 --- a/sound/pci/ymfpci/ymfpci_main.c
79914 +++ b/sound/pci/ymfpci/ymfpci_main.c
79915 @@ -203,8 +203,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
79916 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
79917 break;
79918 }
79919 - if (atomic_read(&chip->interrupt_sleep_count)) {
79920 - atomic_set(&chip->interrupt_sleep_count, 0);
79921 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
79922 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
79923 wake_up(&chip->interrupt_sleep);
79924 }
79925 __end:
79926 @@ -788,7 +788,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
79927 continue;
79928 init_waitqueue_entry(&wait, current);
79929 add_wait_queue(&chip->interrupt_sleep, &wait);
79930 - atomic_inc(&chip->interrupt_sleep_count);
79931 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
79932 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
79933 remove_wait_queue(&chip->interrupt_sleep, &wait);
79934 }
79935 @@ -826,8 +826,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
79936 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
79937 spin_unlock(&chip->reg_lock);
79938
79939 - if (atomic_read(&chip->interrupt_sleep_count)) {
79940 - atomic_set(&chip->interrupt_sleep_count, 0);
79941 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
79942 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
79943 wake_up(&chip->interrupt_sleep);
79944 }
79945 }
79946 @@ -2389,7 +2389,7 @@ int __devinit snd_ymfpci_create(struct snd_card *card,
79947 spin_lock_init(&chip->reg_lock);
79948 spin_lock_init(&chip->voice_lock);
79949 init_waitqueue_head(&chip->interrupt_sleep);
79950 - atomic_set(&chip->interrupt_sleep_count, 0);
79951 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
79952 chip->card = card;
79953 chip->pci = pci;
79954 chip->irq = -1;
79955 diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
79956 index cdc860a..db34a93 100644
79957 --- a/sound/soc/soc-pcm.c
79958 +++ b/sound/soc/soc-pcm.c
79959 @@ -605,7 +605,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
79960 struct snd_soc_platform *platform = rtd->platform;
79961 struct snd_soc_dai *codec_dai = rtd->codec_dai;
79962 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
79963 - struct snd_pcm_ops *soc_pcm_ops = &rtd->ops;
79964 + snd_pcm_ops_no_const *soc_pcm_ops = &rtd->ops;
79965 struct snd_pcm *pcm;
79966 char new_name[64];
79967 int ret = 0, playback = 0, capture = 0;
79968 diff --git a/sound/usb/card.h b/sound/usb/card.h
79969 index da5fa1a..113cd02 100644
79970 --- a/sound/usb/card.h
79971 +++ b/sound/usb/card.h
79972 @@ -45,6 +45,7 @@ struct snd_urb_ops {
79973 int (*prepare_sync)(struct snd_usb_substream *subs, struct snd_pcm_runtime *runtime, struct urb *u);
79974 int (*retire_sync)(struct snd_usb_substream *subs, struct snd_pcm_runtime *runtime, struct urb *u);
79975 };
79976 +typedef struct snd_urb_ops __no_const snd_urb_ops_no_const;
79977
79978 struct snd_usb_substream {
79979 struct snd_usb_stream *stream;
79980 @@ -94,7 +95,7 @@ struct snd_usb_substream {
79981 struct snd_pcm_hw_constraint_list rate_list; /* limited rates */
79982 spinlock_t lock;
79983
79984 - struct snd_urb_ops ops; /* callbacks (must be filled at init) */
79985 + snd_urb_ops_no_const ops; /* callbacks (must be filled at init) */
79986 int last_frame_number; /* stored frame number */
79987 int last_delay; /* stored delay */
79988 };
79989 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
79990 new file mode 100644
79991 index 0000000..ca64170
79992 --- /dev/null
79993 +++ b/tools/gcc/Makefile
79994 @@ -0,0 +1,26 @@
79995 +#CC := gcc
79996 +#PLUGIN_SOURCE_FILES := pax_plugin.c
79997 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
79998 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
79999 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
80000 +
80001 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -I$(GCCPLUGINS_DIR)/include/c-family -std=gnu99 -ggdb
80002 +CFLAGS_size_overflow_plugin.o := -Wno-missing-initializer
80003 +
80004 +hostlibs-y := constify_plugin.so
80005 +hostlibs-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
80006 +hostlibs-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
80007 +hostlibs-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
80008 +hostlibs-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
80009 +hostlibs-y += colorize_plugin.so
80010 +hostlibs-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
80011 +
80012 +always := $(hostlibs-y)
80013 +
80014 +constify_plugin-objs := constify_plugin.o
80015 +stackleak_plugin-objs := stackleak_plugin.o
80016 +kallocstat_plugin-objs := kallocstat_plugin.o
80017 +kernexec_plugin-objs := kernexec_plugin.o
80018 +checker_plugin-objs := checker_plugin.o
80019 +colorize_plugin-objs := colorize_plugin.o
80020 +size_overflow_plugin-objs := size_overflow_plugin.o
80021 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
80022 new file mode 100644
80023 index 0000000..d41b5af
80024 --- /dev/null
80025 +++ b/tools/gcc/checker_plugin.c
80026 @@ -0,0 +1,171 @@
80027 +/*
80028 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
80029 + * Licensed under the GPL v2
80030 + *
80031 + * Note: the choice of the license means that the compilation process is
80032 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
80033 + * but for the kernel it doesn't matter since it doesn't link against
80034 + * any of the gcc libraries
80035 + *
80036 + * gcc plugin to implement various sparse (source code checker) features
80037 + *
80038 + * TODO:
80039 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
80040 + *
80041 + * BUGS:
80042 + * - none known
80043 + */
80044 +#include "gcc-plugin.h"
80045 +#include "config.h"
80046 +#include "system.h"
80047 +#include "coretypes.h"
80048 +#include "tree.h"
80049 +#include "tree-pass.h"
80050 +#include "flags.h"
80051 +#include "intl.h"
80052 +#include "toplev.h"
80053 +#include "plugin.h"
80054 +//#include "expr.h" where are you...
80055 +#include "diagnostic.h"
80056 +#include "plugin-version.h"
80057 +#include "tm.h"
80058 +#include "function.h"
80059 +#include "basic-block.h"
80060 +#include "gimple.h"
80061 +#include "rtl.h"
80062 +#include "emit-rtl.h"
80063 +#include "tree-flow.h"
80064 +#include "target.h"
80065 +
80066 +extern void c_register_addr_space (const char *str, addr_space_t as);
80067 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
80068 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
80069 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
80070 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
80071 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
80072 +
80073 +extern void print_gimple_stmt(FILE *, gimple, int, int);
80074 +extern rtx emit_move_insn(rtx x, rtx y);
80075 +
80076 +int plugin_is_GPL_compatible;
80077 +
80078 +static struct plugin_info checker_plugin_info = {
80079 + .version = "201111150100",
80080 +};
80081 +
80082 +#define ADDR_SPACE_KERNEL 0
80083 +#define ADDR_SPACE_FORCE_KERNEL 1
80084 +#define ADDR_SPACE_USER 2
80085 +#define ADDR_SPACE_FORCE_USER 3
80086 +#define ADDR_SPACE_IOMEM 0
80087 +#define ADDR_SPACE_FORCE_IOMEM 0
80088 +#define ADDR_SPACE_PERCPU 0
80089 +#define ADDR_SPACE_FORCE_PERCPU 0
80090 +#define ADDR_SPACE_RCU 0
80091 +#define ADDR_SPACE_FORCE_RCU 0
80092 +
80093 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
80094 +{
80095 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
80096 +}
80097 +
80098 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
80099 +{
80100 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
80101 +}
80102 +
80103 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
80104 +{
80105 + return default_addr_space_valid_pointer_mode(mode, as);
80106 +}
80107 +
80108 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
80109 +{
80110 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
80111 +}
80112 +
80113 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
80114 +{
80115 + return default_addr_space_legitimize_address(x, oldx, mode, as);
80116 +}
80117 +
80118 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
80119 +{
80120 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
80121 + return true;
80122 +
80123 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
80124 + return true;
80125 +
80126 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
80127 + return true;
80128 +
80129 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
80130 + return true;
80131 +
80132 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
80133 + return true;
80134 +
80135 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
80136 + return true;
80137 +
80138 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
80139 + return true;
80140 +
80141 + return subset == superset;
80142 +}
80143 +
80144 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
80145 +{
80146 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
80147 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
80148 +
80149 + return op;
80150 +}
80151 +
80152 +static void register_checker_address_spaces(void *event_data, void *data)
80153 +{
80154 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
80155 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
80156 + c_register_addr_space("__user", ADDR_SPACE_USER);
80157 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
80158 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
80159 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
80160 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
80161 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
80162 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
80163 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
80164 +
80165 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
80166 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
80167 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
80168 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
80169 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
80170 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
80171 + targetm.addr_space.convert = checker_addr_space_convert;
80172 +}
80173 +
80174 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
80175 +{
80176 + const char * const plugin_name = plugin_info->base_name;
80177 + const int argc = plugin_info->argc;
80178 + const struct plugin_argument * const argv = plugin_info->argv;
80179 + int i;
80180 +
80181 + if (!plugin_default_version_check(version, &gcc_version)) {
80182 + error(G_("incompatible gcc/plugin versions"));
80183 + return 1;
80184 + }
80185 +
80186 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
80187 +
80188 + for (i = 0; i < argc; ++i)
80189 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
80190 +
80191 + if (TARGET_64BIT == 0)
80192 + return 0;
80193 +
80194 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
80195 +
80196 + return 0;
80197 +}
80198 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
80199 new file mode 100644
80200 index 0000000..ee950d0
80201 --- /dev/null
80202 +++ b/tools/gcc/colorize_plugin.c
80203 @@ -0,0 +1,147 @@
80204 +/*
80205 + * Copyright 2012 by PaX Team <pageexec@freemail.hu>
80206 + * Licensed under the GPL v2
80207 + *
80208 + * Note: the choice of the license means that the compilation process is
80209 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
80210 + * but for the kernel it doesn't matter since it doesn't link against
80211 + * any of the gcc libraries
80212 + *
80213 + * gcc plugin to colorize diagnostic output
80214 + *
80215 + */
80216 +
80217 +#include "gcc-plugin.h"
80218 +#include "config.h"
80219 +#include "system.h"
80220 +#include "coretypes.h"
80221 +#include "tree.h"
80222 +#include "tree-pass.h"
80223 +#include "flags.h"
80224 +#include "intl.h"
80225 +#include "toplev.h"
80226 +#include "plugin.h"
80227 +#include "diagnostic.h"
80228 +#include "plugin-version.h"
80229 +#include "tm.h"
80230 +
80231 +int plugin_is_GPL_compatible;
80232 +
80233 +static struct plugin_info colorize_plugin_info = {
80234 + .version = "201203092200",
80235 +};
80236 +
80237 +#define GREEN "\033[32m\033[2m"
80238 +#define LIGHTGREEN "\033[32m\033[1m"
80239 +#define YELLOW "\033[33m\033[2m"
80240 +#define LIGHTYELLOW "\033[33m\033[1m"
80241 +#define RED "\033[31m\033[2m"
80242 +#define LIGHTRED "\033[31m\033[1m"
80243 +#define BLUE "\033[34m\033[2m"
80244 +#define LIGHTBLUE "\033[34m\033[1m"
80245 +#define BRIGHT "\033[m\033[1m"
80246 +#define NORMAL "\033[m"
80247 +
80248 +static diagnostic_starter_fn old_starter;
80249 +static diagnostic_finalizer_fn old_finalizer;
80250 +
80251 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
80252 +{
80253 + const char *color;
80254 + char *newprefix;
80255 +
80256 + switch (diagnostic->kind) {
80257 + case DK_NOTE:
80258 + color = LIGHTBLUE;
80259 + break;
80260 +
80261 + case DK_PEDWARN:
80262 + case DK_WARNING:
80263 + color = LIGHTYELLOW;
80264 + break;
80265 +
80266 + case DK_ERROR:
80267 + case DK_FATAL:
80268 + case DK_ICE:
80269 + case DK_PERMERROR:
80270 + case DK_SORRY:
80271 + color = LIGHTRED;
80272 + break;
80273 +
80274 + default:
80275 + color = NORMAL;
80276 + }
80277 +
80278 + old_starter(context, diagnostic);
80279 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
80280 + return;
80281 + pp_destroy_prefix(context->printer);
80282 + pp_set_prefix(context->printer, newprefix);
80283 +}
80284 +
80285 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
80286 +{
80287 + old_finalizer(context, diagnostic);
80288 +}
80289 +
80290 +static void colorize_arm(void)
80291 +{
80292 + old_starter = diagnostic_starter(global_dc);
80293 + old_finalizer = diagnostic_finalizer(global_dc);
80294 +
80295 + diagnostic_starter(global_dc) = start_colorize;
80296 + diagnostic_finalizer(global_dc) = finalize_colorize;
80297 +}
80298 +
80299 +static unsigned int execute_colorize_rearm(void)
80300 +{
80301 + if (diagnostic_starter(global_dc) == start_colorize)
80302 + return 0;
80303 +
80304 + colorize_arm();
80305 + return 0;
80306 +}
80307 +
80308 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
80309 + .pass = {
80310 + .type = SIMPLE_IPA_PASS,
80311 + .name = "colorize_rearm",
80312 + .gate = NULL,
80313 + .execute = execute_colorize_rearm,
80314 + .sub = NULL,
80315 + .next = NULL,
80316 + .static_pass_number = 0,
80317 + .tv_id = TV_NONE,
80318 + .properties_required = 0,
80319 + .properties_provided = 0,
80320 + .properties_destroyed = 0,
80321 + .todo_flags_start = 0,
80322 + .todo_flags_finish = 0
80323 + }
80324 +};
80325 +
80326 +static void colorize_start_unit(void *gcc_data, void *user_data)
80327 +{
80328 + colorize_arm();
80329 +}
80330 +
80331 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
80332 +{
80333 + const char * const plugin_name = plugin_info->base_name;
80334 + struct register_pass_info colorize_rearm_pass_info = {
80335 + .pass = &pass_ipa_colorize_rearm.pass,
80336 + .reference_pass_name = "*free_lang_data",
80337 + .ref_pass_instance_number = 0,
80338 + .pos_op = PASS_POS_INSERT_AFTER
80339 + };
80340 +
80341 + if (!plugin_default_version_check(version, &gcc_version)) {
80342 + error(G_("incompatible gcc/plugin versions"));
80343 + return 1;
80344 + }
80345 +
80346 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
80347 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
80348 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
80349 + return 0;
80350 +}
80351 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
80352 new file mode 100644
80353 index 0000000..88a7438
80354 --- /dev/null
80355 +++ b/tools/gcc/constify_plugin.c
80356 @@ -0,0 +1,303 @@
80357 +/*
80358 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
80359 + * Copyright 2011 by PaX Team <pageexec@freemail.hu>
80360 + * Licensed under the GPL v2, or (at your option) v3
80361 + *
80362 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
80363 + *
80364 + * Homepage:
80365 + * http://www.grsecurity.net/~ephox/const_plugin/
80366 + *
80367 + * Usage:
80368 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
80369 + * $ gcc -fplugin=constify_plugin.so test.c -O2
80370 + */
80371 +
80372 +#include "gcc-plugin.h"
80373 +#include "config.h"
80374 +#include "system.h"
80375 +#include "coretypes.h"
80376 +#include "tree.h"
80377 +#include "tree-pass.h"
80378 +#include "flags.h"
80379 +#include "intl.h"
80380 +#include "toplev.h"
80381 +#include "plugin.h"
80382 +#include "diagnostic.h"
80383 +#include "plugin-version.h"
80384 +#include "tm.h"
80385 +#include "function.h"
80386 +#include "basic-block.h"
80387 +#include "gimple.h"
80388 +#include "rtl.h"
80389 +#include "emit-rtl.h"
80390 +#include "tree-flow.h"
80391 +
80392 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
80393 +
80394 +int plugin_is_GPL_compatible;
80395 +
80396 +static struct plugin_info const_plugin_info = {
80397 + .version = "201111150100",
80398 + .help = "no-constify\tturn off constification\n",
80399 +};
80400 +
80401 +static void constify_type(tree type);
80402 +static bool walk_struct(tree node);
80403 +
80404 +static tree deconstify_type(tree old_type)
80405 +{
80406 + tree new_type, field;
80407 +
80408 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
80409 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
80410 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
80411 + DECL_FIELD_CONTEXT(field) = new_type;
80412 + TYPE_READONLY(new_type) = 0;
80413 + C_TYPE_FIELDS_READONLY(new_type) = 0;
80414 + return new_type;
80415 +}
80416 +
80417 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
80418 +{
80419 + tree type;
80420 +
80421 + *no_add_attrs = true;
80422 + if (TREE_CODE(*node) == FUNCTION_DECL) {
80423 + error("%qE attribute does not apply to functions", name);
80424 + return NULL_TREE;
80425 + }
80426 +
80427 + if (TREE_CODE(*node) == VAR_DECL) {
80428 + error("%qE attribute does not apply to variables", name);
80429 + return NULL_TREE;
80430 + }
80431 +
80432 + if (TYPE_P(*node)) {
80433 + if (TREE_CODE(*node) == RECORD_TYPE || TREE_CODE(*node) == UNION_TYPE)
80434 + *no_add_attrs = false;
80435 + else
80436 + error("%qE attribute applies to struct and union types only", name);
80437 + return NULL_TREE;
80438 + }
80439 +
80440 + type = TREE_TYPE(*node);
80441 +
80442 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
80443 + error("%qE attribute applies to struct and union types only", name);
80444 + return NULL_TREE;
80445 + }
80446 +
80447 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
80448 + error("%qE attribute is already applied to the type", name);
80449 + return NULL_TREE;
80450 + }
80451 +
80452 + if (TREE_CODE(*node) == TYPE_DECL && !TYPE_READONLY(type)) {
80453 + error("%qE attribute used on type that is not constified", name);
80454 + return NULL_TREE;
80455 + }
80456 +
80457 + if (TREE_CODE(*node) == TYPE_DECL) {
80458 + TREE_TYPE(*node) = deconstify_type(type);
80459 + TREE_READONLY(*node) = 0;
80460 + return NULL_TREE;
80461 + }
80462 +
80463 + return NULL_TREE;
80464 +}
80465 +
80466 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
80467 +{
80468 + *no_add_attrs = true;
80469 + if (!TYPE_P(*node)) {
80470 + error("%qE attribute applies to types only", name);
80471 + return NULL_TREE;
80472 + }
80473 +
80474 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
80475 + error("%qE attribute applies to struct and union types only", name);
80476 + return NULL_TREE;
80477 + }
80478 +
80479 + *no_add_attrs = false;
80480 + constify_type(*node);
80481 + return NULL_TREE;
80482 +}
80483 +
80484 +static struct attribute_spec no_const_attr = {
80485 + .name = "no_const",
80486 + .min_length = 0,
80487 + .max_length = 0,
80488 + .decl_required = false,
80489 + .type_required = false,
80490 + .function_type_required = false,
80491 + .handler = handle_no_const_attribute,
80492 +#if BUILDING_GCC_VERSION >= 4007
80493 + .affects_type_identity = true
80494 +#endif
80495 +};
80496 +
80497 +static struct attribute_spec do_const_attr = {
80498 + .name = "do_const",
80499 + .min_length = 0,
80500 + .max_length = 0,
80501 + .decl_required = false,
80502 + .type_required = false,
80503 + .function_type_required = false,
80504 + .handler = handle_do_const_attribute,
80505 +#if BUILDING_GCC_VERSION >= 4007
80506 + .affects_type_identity = true
80507 +#endif
80508 +};
80509 +
80510 +static void register_attributes(void *event_data, void *data)
80511 +{
80512 + register_attribute(&no_const_attr);
80513 + register_attribute(&do_const_attr);
80514 +}
80515 +
80516 +static void constify_type(tree type)
80517 +{
80518 + TYPE_READONLY(type) = 1;
80519 + C_TYPE_FIELDS_READONLY(type) = 1;
80520 +}
80521 +
80522 +static bool is_fptr(tree field)
80523 +{
80524 + tree ptr = TREE_TYPE(field);
80525 +
80526 + if (TREE_CODE(ptr) != POINTER_TYPE)
80527 + return false;
80528 +
80529 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
80530 +}
80531 +
80532 +static bool walk_struct(tree node)
80533 +{
80534 + tree field;
80535 +
80536 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node)))
80537 + return false;
80538 +
80539 + if (TYPE_FIELDS(node) == NULL_TREE)
80540 + return false;
80541 +
80542 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
80543 + tree type = TREE_TYPE(field);
80544 + enum tree_code code = TREE_CODE(type);
80545 + if (code == RECORD_TYPE || code == UNION_TYPE) {
80546 + if (!(walk_struct(type)))
80547 + return false;
80548 + } else if (!is_fptr(field) && !TREE_READONLY(field))
80549 + return false;
80550 + }
80551 + return true;
80552 +}
80553 +
80554 +static void finish_type(void *event_data, void *data)
80555 +{
80556 + tree type = (tree)event_data;
80557 +
80558 + if (type == NULL_TREE)
80559 + return;
80560 +
80561 + if (TYPE_READONLY(type))
80562 + return;
80563 +
80564 + if (walk_struct(type))
80565 + constify_type(type);
80566 +}
80567 +
80568 +static unsigned int check_local_variables(void);
80569 +
80570 +struct gimple_opt_pass pass_local_variable = {
80571 + {
80572 + .type = GIMPLE_PASS,
80573 + .name = "check_local_variables",
80574 + .gate = NULL,
80575 + .execute = check_local_variables,
80576 + .sub = NULL,
80577 + .next = NULL,
80578 + .static_pass_number = 0,
80579 + .tv_id = TV_NONE,
80580 + .properties_required = 0,
80581 + .properties_provided = 0,
80582 + .properties_destroyed = 0,
80583 + .todo_flags_start = 0,
80584 + .todo_flags_finish = 0
80585 + }
80586 +};
80587 +
80588 +static unsigned int check_local_variables(void)
80589 +{
80590 + tree var;
80591 + referenced_var_iterator rvi;
80592 +
80593 +#if BUILDING_GCC_VERSION == 4005
80594 + FOR_EACH_REFERENCED_VAR(var, rvi) {
80595 +#else
80596 + FOR_EACH_REFERENCED_VAR(cfun, var, rvi) {
80597 +#endif
80598 + tree type = TREE_TYPE(var);
80599 +
80600 + if (!DECL_P(var) || TREE_STATIC(var) || DECL_EXTERNAL(var))
80601 + continue;
80602 +
80603 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
80604 + continue;
80605 +
80606 + if (!TYPE_READONLY(type))
80607 + continue;
80608 +
80609 +// if (lookup_attribute("no_const", DECL_ATTRIBUTES(var)))
80610 +// continue;
80611 +
80612 +// if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
80613 +// continue;
80614 +
80615 + if (walk_struct(type)) {
80616 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
80617 + return 1;
80618 + }
80619 + }
80620 + return 0;
80621 +}
80622 +
80623 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
80624 +{
80625 + const char * const plugin_name = plugin_info->base_name;
80626 + const int argc = plugin_info->argc;
80627 + const struct plugin_argument * const argv = plugin_info->argv;
80628 + int i;
80629 + bool constify = true;
80630 +
80631 + struct register_pass_info local_variable_pass_info = {
80632 + .pass = &pass_local_variable.pass,
80633 + .reference_pass_name = "*referenced_vars",
80634 + .ref_pass_instance_number = 0,
80635 + .pos_op = PASS_POS_INSERT_AFTER
80636 + };
80637 +
80638 + if (!plugin_default_version_check(version, &gcc_version)) {
80639 + error(G_("incompatible gcc/plugin versions"));
80640 + return 1;
80641 + }
80642 +
80643 + for (i = 0; i < argc; ++i) {
80644 + if (!(strcmp(argv[i].key, "no-constify"))) {
80645 + constify = false;
80646 + continue;
80647 + }
80648 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
80649 + }
80650 +
80651 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
80652 + if (constify) {
80653 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
80654 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
80655 + }
80656 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
80657 +
80658 + return 0;
80659 +}
80660 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
80661 new file mode 100644
80662 index 0000000..a5eabce
80663 --- /dev/null
80664 +++ b/tools/gcc/kallocstat_plugin.c
80665 @@ -0,0 +1,167 @@
80666 +/*
80667 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
80668 + * Licensed under the GPL v2
80669 + *
80670 + * Note: the choice of the license means that the compilation process is
80671 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
80672 + * but for the kernel it doesn't matter since it doesn't link against
80673 + * any of the gcc libraries
80674 + *
80675 + * gcc plugin to find the distribution of k*alloc sizes
80676 + *
80677 + * TODO:
80678 + *
80679 + * BUGS:
80680 + * - none known
80681 + */
80682 +#include "gcc-plugin.h"
80683 +#include "config.h"
80684 +#include "system.h"
80685 +#include "coretypes.h"
80686 +#include "tree.h"
80687 +#include "tree-pass.h"
80688 +#include "flags.h"
80689 +#include "intl.h"
80690 +#include "toplev.h"
80691 +#include "plugin.h"
80692 +//#include "expr.h" where are you...
80693 +#include "diagnostic.h"
80694 +#include "plugin-version.h"
80695 +#include "tm.h"
80696 +#include "function.h"
80697 +#include "basic-block.h"
80698 +#include "gimple.h"
80699 +#include "rtl.h"
80700 +#include "emit-rtl.h"
80701 +
80702 +extern void print_gimple_stmt(FILE *, gimple, int, int);
80703 +
80704 +int plugin_is_GPL_compatible;
80705 +
80706 +static const char * const kalloc_functions[] = {
80707 + "__kmalloc",
80708 + "kmalloc",
80709 + "kmalloc_large",
80710 + "kmalloc_node",
80711 + "kmalloc_order",
80712 + "kmalloc_order_trace",
80713 + "kmalloc_slab",
80714 + "kzalloc",
80715 + "kzalloc_node",
80716 +};
80717 +
80718 +static struct plugin_info kallocstat_plugin_info = {
80719 + .version = "201111150100",
80720 +};
80721 +
80722 +static unsigned int execute_kallocstat(void);
80723 +
80724 +static struct gimple_opt_pass kallocstat_pass = {
80725 + .pass = {
80726 + .type = GIMPLE_PASS,
80727 + .name = "kallocstat",
80728 + .gate = NULL,
80729 + .execute = execute_kallocstat,
80730 + .sub = NULL,
80731 + .next = NULL,
80732 + .static_pass_number = 0,
80733 + .tv_id = TV_NONE,
80734 + .properties_required = 0,
80735 + .properties_provided = 0,
80736 + .properties_destroyed = 0,
80737 + .todo_flags_start = 0,
80738 + .todo_flags_finish = 0
80739 + }
80740 +};
80741 +
80742 +static bool is_kalloc(const char *fnname)
80743 +{
80744 + size_t i;
80745 +
80746 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
80747 + if (!strcmp(fnname, kalloc_functions[i]))
80748 + return true;
80749 + return false;
80750 +}
80751 +
80752 +static unsigned int execute_kallocstat(void)
80753 +{
80754 + basic_block bb;
80755 +
80756 + // 1. loop through BBs and GIMPLE statements
80757 + FOR_EACH_BB(bb) {
80758 + gimple_stmt_iterator gsi;
80759 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
80760 + // gimple match:
80761 + tree fndecl, size;
80762 + gimple call_stmt;
80763 + const char *fnname;
80764 +
80765 + // is it a call
80766 + call_stmt = gsi_stmt(gsi);
80767 + if (!is_gimple_call(call_stmt))
80768 + continue;
80769 + fndecl = gimple_call_fndecl(call_stmt);
80770 + if (fndecl == NULL_TREE)
80771 + continue;
80772 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
80773 + continue;
80774 +
80775 + // is it a call to k*alloc
80776 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
80777 + if (!is_kalloc(fnname))
80778 + continue;
80779 +
80780 + // is the size arg the result of a simple const assignment
80781 + size = gimple_call_arg(call_stmt, 0);
80782 + while (true) {
80783 + gimple def_stmt;
80784 + expanded_location xloc;
80785 + size_t size_val;
80786 +
80787 + if (TREE_CODE(size) != SSA_NAME)
80788 + break;
80789 + def_stmt = SSA_NAME_DEF_STMT(size);
80790 + if (!def_stmt || !is_gimple_assign(def_stmt))
80791 + break;
80792 + if (gimple_num_ops(def_stmt) != 2)
80793 + break;
80794 + size = gimple_assign_rhs1(def_stmt);
80795 + if (!TREE_CONSTANT(size))
80796 + continue;
80797 + xloc = expand_location(gimple_location(def_stmt));
80798 + if (!xloc.file)
80799 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
80800 + size_val = TREE_INT_CST_LOW(size);
80801 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
80802 + break;
80803 + }
80804 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
80805 +//debug_tree(gimple_call_fn(call_stmt));
80806 +//print_node(stderr, "pax", fndecl, 4);
80807 + }
80808 + }
80809 +
80810 + return 0;
80811 +}
80812 +
80813 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
80814 +{
80815 + const char * const plugin_name = plugin_info->base_name;
80816 + struct register_pass_info kallocstat_pass_info = {
80817 + .pass = &kallocstat_pass.pass,
80818 + .reference_pass_name = "ssa",
80819 + .ref_pass_instance_number = 0,
80820 + .pos_op = PASS_POS_INSERT_AFTER
80821 + };
80822 +
80823 + if (!plugin_default_version_check(version, &gcc_version)) {
80824 + error(G_("incompatible gcc/plugin versions"));
80825 + return 1;
80826 + }
80827 +
80828 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
80829 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
80830 +
80831 + return 0;
80832 +}
80833 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
80834 new file mode 100644
80835 index 0000000..d8a8da2
80836 --- /dev/null
80837 +++ b/tools/gcc/kernexec_plugin.c
80838 @@ -0,0 +1,427 @@
80839 +/*
80840 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
80841 + * Licensed under the GPL v2
80842 + *
80843 + * Note: the choice of the license means that the compilation process is
80844 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
80845 + * but for the kernel it doesn't matter since it doesn't link against
80846 + * any of the gcc libraries
80847 + *
80848 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
80849 + *
80850 + * TODO:
80851 + *
80852 + * BUGS:
80853 + * - none known
80854 + */
80855 +#include "gcc-plugin.h"
80856 +#include "config.h"
80857 +#include "system.h"
80858 +#include "coretypes.h"
80859 +#include "tree.h"
80860 +#include "tree-pass.h"
80861 +#include "flags.h"
80862 +#include "intl.h"
80863 +#include "toplev.h"
80864 +#include "plugin.h"
80865 +//#include "expr.h" where are you...
80866 +#include "diagnostic.h"
80867 +#include "plugin-version.h"
80868 +#include "tm.h"
80869 +#include "function.h"
80870 +#include "basic-block.h"
80871 +#include "gimple.h"
80872 +#include "rtl.h"
80873 +#include "emit-rtl.h"
80874 +#include "tree-flow.h"
80875 +
80876 +extern void print_gimple_stmt(FILE *, gimple, int, int);
80877 +extern rtx emit_move_insn(rtx x, rtx y);
80878 +
80879 +int plugin_is_GPL_compatible;
80880 +
80881 +static struct plugin_info kernexec_plugin_info = {
80882 + .version = "201111291120",
80883 + .help = "method=[bts|or]\tinstrumentation method\n"
80884 +};
80885 +
80886 +static unsigned int execute_kernexec_reload(void);
80887 +static unsigned int execute_kernexec_fptr(void);
80888 +static unsigned int execute_kernexec_retaddr(void);
80889 +static bool kernexec_cmodel_check(void);
80890 +
80891 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
80892 +static void (*kernexec_instrument_retaddr)(rtx);
80893 +
80894 +static struct gimple_opt_pass kernexec_reload_pass = {
80895 + .pass = {
80896 + .type = GIMPLE_PASS,
80897 + .name = "kernexec_reload",
80898 + .gate = kernexec_cmodel_check,
80899 + .execute = execute_kernexec_reload,
80900 + .sub = NULL,
80901 + .next = NULL,
80902 + .static_pass_number = 0,
80903 + .tv_id = TV_NONE,
80904 + .properties_required = 0,
80905 + .properties_provided = 0,
80906 + .properties_destroyed = 0,
80907 + .todo_flags_start = 0,
80908 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
80909 + }
80910 +};
80911 +
80912 +static struct gimple_opt_pass kernexec_fptr_pass = {
80913 + .pass = {
80914 + .type = GIMPLE_PASS,
80915 + .name = "kernexec_fptr",
80916 + .gate = kernexec_cmodel_check,
80917 + .execute = execute_kernexec_fptr,
80918 + .sub = NULL,
80919 + .next = NULL,
80920 + .static_pass_number = 0,
80921 + .tv_id = TV_NONE,
80922 + .properties_required = 0,
80923 + .properties_provided = 0,
80924 + .properties_destroyed = 0,
80925 + .todo_flags_start = 0,
80926 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
80927 + }
80928 +};
80929 +
80930 +static struct rtl_opt_pass kernexec_retaddr_pass = {
80931 + .pass = {
80932 + .type = RTL_PASS,
80933 + .name = "kernexec_retaddr",
80934 + .gate = kernexec_cmodel_check,
80935 + .execute = execute_kernexec_retaddr,
80936 + .sub = NULL,
80937 + .next = NULL,
80938 + .static_pass_number = 0,
80939 + .tv_id = TV_NONE,
80940 + .properties_required = 0,
80941 + .properties_provided = 0,
80942 + .properties_destroyed = 0,
80943 + .todo_flags_start = 0,
80944 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
80945 + }
80946 +};
80947 +
80948 +static bool kernexec_cmodel_check(void)
80949 +{
80950 + tree section;
80951 +
80952 + if (ix86_cmodel != CM_KERNEL)
80953 + return false;
80954 +
80955 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
80956 + if (!section || !TREE_VALUE(section))
80957 + return true;
80958 +
80959 + section = TREE_VALUE(TREE_VALUE(section));
80960 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
80961 + return true;
80962 +
80963 + return false;
80964 +}
80965 +
80966 +/*
80967 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
80968 + */
80969 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
80970 +{
80971 + gimple asm_movabs_stmt;
80972 +
80973 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
80974 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
80975 + gimple_asm_set_volatile(asm_movabs_stmt, true);
80976 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
80977 + update_stmt(asm_movabs_stmt);
80978 +}
80979 +
80980 +/*
80981 + * find all asm() stmts that clobber r10 and add a reload of r10
80982 + */
80983 +static unsigned int execute_kernexec_reload(void)
80984 +{
80985 + basic_block bb;
80986 +
80987 + // 1. loop through BBs and GIMPLE statements
80988 + FOR_EACH_BB(bb) {
80989 + gimple_stmt_iterator gsi;
80990 +
80991 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
80992 + // gimple match: __asm__ ("" : : : "r10");
80993 + gimple asm_stmt;
80994 + size_t nclobbers;
80995 +
80996 + // is it an asm ...
80997 + asm_stmt = gsi_stmt(gsi);
80998 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
80999 + continue;
81000 +
81001 + // ... clobbering r10
81002 + nclobbers = gimple_asm_nclobbers(asm_stmt);
81003 + while (nclobbers--) {
81004 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
81005 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
81006 + continue;
81007 + kernexec_reload_fptr_mask(&gsi);
81008 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
81009 + break;
81010 + }
81011 + }
81012 + }
81013 +
81014 + return 0;
81015 +}
81016 +
81017 +/*
81018 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
81019 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
81020 + */
81021 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
81022 +{
81023 + gimple assign_intptr, assign_new_fptr, call_stmt;
81024 + tree intptr, old_fptr, new_fptr, kernexec_mask;
81025 +
81026 + call_stmt = gsi_stmt(*gsi);
81027 + old_fptr = gimple_call_fn(call_stmt);
81028 +
81029 + // create temporary unsigned long variable used for bitops and cast fptr to it
81030 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
81031 + add_referenced_var(intptr);
81032 + mark_sym_for_renaming(intptr);
81033 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
81034 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
81035 + update_stmt(assign_intptr);
81036 +
81037 + // apply logical or to temporary unsigned long and bitmask
81038 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
81039 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
81040 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
81041 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
81042 + update_stmt(assign_intptr);
81043 +
81044 + // cast temporary unsigned long back to a temporary fptr variable
81045 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
81046 + add_referenced_var(new_fptr);
81047 + mark_sym_for_renaming(new_fptr);
81048 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
81049 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
81050 + update_stmt(assign_new_fptr);
81051 +
81052 + // replace call stmt fn with the new fptr
81053 + gimple_call_set_fn(call_stmt, new_fptr);
81054 + update_stmt(call_stmt);
81055 +}
81056 +
81057 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
81058 +{
81059 + gimple asm_or_stmt, call_stmt;
81060 + tree old_fptr, new_fptr, input, output;
81061 + VEC(tree, gc) *inputs = NULL;
81062 + VEC(tree, gc) *outputs = NULL;
81063 +
81064 + call_stmt = gsi_stmt(*gsi);
81065 + old_fptr = gimple_call_fn(call_stmt);
81066 +
81067 + // create temporary fptr variable
81068 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
81069 + add_referenced_var(new_fptr);
81070 + mark_sym_for_renaming(new_fptr);
81071 +
81072 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
81073 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
81074 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
81075 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
81076 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
81077 + VEC_safe_push(tree, gc, inputs, input);
81078 + VEC_safe_push(tree, gc, outputs, output);
81079 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
81080 + gimple_asm_set_volatile(asm_or_stmt, true);
81081 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
81082 + update_stmt(asm_or_stmt);
81083 +
81084 + // replace call stmt fn with the new fptr
81085 + gimple_call_set_fn(call_stmt, new_fptr);
81086 + update_stmt(call_stmt);
81087 +}
81088 +
81089 +/*
81090 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
81091 + */
81092 +static unsigned int execute_kernexec_fptr(void)
81093 +{
81094 + basic_block bb;
81095 +
81096 + // 1. loop through BBs and GIMPLE statements
81097 + FOR_EACH_BB(bb) {
81098 + gimple_stmt_iterator gsi;
81099 +
81100 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
81101 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
81102 + tree fn;
81103 + gimple call_stmt;
81104 +
81105 + // is it a call ...
81106 + call_stmt = gsi_stmt(gsi);
81107 + if (!is_gimple_call(call_stmt))
81108 + continue;
81109 + fn = gimple_call_fn(call_stmt);
81110 + if (TREE_CODE(fn) == ADDR_EXPR)
81111 + continue;
81112 + if (TREE_CODE(fn) != SSA_NAME)
81113 + gcc_unreachable();
81114 +
81115 + // ... through a function pointer
81116 + fn = SSA_NAME_VAR(fn);
81117 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL)
81118 + continue;
81119 + fn = TREE_TYPE(fn);
81120 + if (TREE_CODE(fn) != POINTER_TYPE)
81121 + continue;
81122 + fn = TREE_TYPE(fn);
81123 + if (TREE_CODE(fn) != FUNCTION_TYPE)
81124 + continue;
81125 +
81126 + kernexec_instrument_fptr(&gsi);
81127 +
81128 +//debug_tree(gimple_call_fn(call_stmt));
81129 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
81130 + }
81131 + }
81132 +
81133 + return 0;
81134 +}
81135 +
81136 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
81137 +static void kernexec_instrument_retaddr_bts(rtx insn)
81138 +{
81139 + rtx btsq;
81140 + rtvec argvec, constraintvec, labelvec;
81141 + int line;
81142 +
81143 + // create asm volatile("btsq $63,(%%rsp)":::)
81144 + argvec = rtvec_alloc(0);
81145 + constraintvec = rtvec_alloc(0);
81146 + labelvec = rtvec_alloc(0);
81147 + line = expand_location(RTL_LOCATION(insn)).line;
81148 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
81149 + MEM_VOLATILE_P(btsq) = 1;
81150 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
81151 + emit_insn_before(btsq, insn);
81152 +}
81153 +
81154 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
81155 +static void kernexec_instrument_retaddr_or(rtx insn)
81156 +{
81157 + rtx orq;
81158 + rtvec argvec, constraintvec, labelvec;
81159 + int line;
81160 +
81161 + // create asm volatile("orq %%r10,(%%rsp)":::)
81162 + argvec = rtvec_alloc(0);
81163 + constraintvec = rtvec_alloc(0);
81164 + labelvec = rtvec_alloc(0);
81165 + line = expand_location(RTL_LOCATION(insn)).line;
81166 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
81167 + MEM_VOLATILE_P(orq) = 1;
81168 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
81169 + emit_insn_before(orq, insn);
81170 +}
81171 +
81172 +/*
81173 + * find all asm level function returns and forcibly set the highest bit of the return address
81174 + */
81175 +static unsigned int execute_kernexec_retaddr(void)
81176 +{
81177 + rtx insn;
81178 +
81179 + // 1. find function returns
81180 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
81181 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
81182 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
81183 + rtx body;
81184 +
81185 + // is it a retn
81186 + if (!JUMP_P(insn))
81187 + continue;
81188 + body = PATTERN(insn);
81189 + if (GET_CODE(body) == PARALLEL)
81190 + body = XVECEXP(body, 0, 0);
81191 + if (GET_CODE(body) != RETURN)
81192 + continue;
81193 + kernexec_instrument_retaddr(insn);
81194 + }
81195 +
81196 +// print_simple_rtl(stderr, get_insns());
81197 +// print_rtl(stderr, get_insns());
81198 +
81199 + return 0;
81200 +}
81201 +
81202 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
81203 +{
81204 + const char * const plugin_name = plugin_info->base_name;
81205 + const int argc = plugin_info->argc;
81206 + const struct plugin_argument * const argv = plugin_info->argv;
81207 + int i;
81208 + struct register_pass_info kernexec_reload_pass_info = {
81209 + .pass = &kernexec_reload_pass.pass,
81210 + .reference_pass_name = "ssa",
81211 + .ref_pass_instance_number = 0,
81212 + .pos_op = PASS_POS_INSERT_AFTER
81213 + };
81214 + struct register_pass_info kernexec_fptr_pass_info = {
81215 + .pass = &kernexec_fptr_pass.pass,
81216 + .reference_pass_name = "ssa",
81217 + .ref_pass_instance_number = 0,
81218 + .pos_op = PASS_POS_INSERT_AFTER
81219 + };
81220 + struct register_pass_info kernexec_retaddr_pass_info = {
81221 + .pass = &kernexec_retaddr_pass.pass,
81222 + .reference_pass_name = "pro_and_epilogue",
81223 + .ref_pass_instance_number = 0,
81224 + .pos_op = PASS_POS_INSERT_AFTER
81225 + };
81226 +
81227 + if (!plugin_default_version_check(version, &gcc_version)) {
81228 + error(G_("incompatible gcc/plugin versions"));
81229 + return 1;
81230 + }
81231 +
81232 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
81233 +
81234 + if (TARGET_64BIT == 0)
81235 + return 0;
81236 +
81237 + for (i = 0; i < argc; ++i) {
81238 + if (!strcmp(argv[i].key, "method")) {
81239 + if (!argv[i].value) {
81240 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
81241 + continue;
81242 + }
81243 + if (!strcmp(argv[i].value, "bts")) {
81244 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
81245 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
81246 + } else if (!strcmp(argv[i].value, "or")) {
81247 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
81248 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
81249 + fix_register("r10", 1, 1);
81250 + } else
81251 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
81252 + continue;
81253 + }
81254 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
81255 + }
81256 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
81257 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
81258 +
81259 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
81260 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
81261 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
81262 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
81263 +
81264 + return 0;
81265 +}
81266 diff --git a/tools/gcc/size_overflow_hash.h b/tools/gcc/size_overflow_hash.h
81267 new file mode 100644
81268 index 0000000..ce7366b
81269 --- /dev/null
81270 +++ b/tools/gcc/size_overflow_hash.h
81271 @@ -0,0 +1,13933 @@
81272 +struct size_overflow_hash _000001_hash = {
81273 + .next = NULL,
81274 + .name = "alloc_dr",
81275 + .file = "drivers/base/devres.c",
81276 + .param2 = 1,
81277 +};
81278 +
81279 +struct size_overflow_hash _000002_hash = {
81280 + .next = NULL,
81281 + .name = "__copy_from_user",
81282 + .file = "arch/x86/include/asm/uaccess_32.h",
81283 + .param3 = 1,
81284 +};
81285 +
81286 +struct size_overflow_hash _000003_hash = {
81287 + .next = NULL,
81288 + .name = "copy_from_user",
81289 + .file = "arch/x86/include/asm/uaccess_32.h",
81290 + .param3 = 1,
81291 +};
81292 +
81293 +struct size_overflow_hash _000004_hash = {
81294 + .next = NULL,
81295 + .name = "__copy_from_user_inatomic",
81296 + .file = "arch/x86/include/asm/uaccess_32.h",
81297 + .param3 = 1,
81298 +};
81299 +
81300 +struct size_overflow_hash _000005_hash = {
81301 + .next = NULL,
81302 + .name = "__copy_from_user_nocache",
81303 + .file = "arch/x86/include/asm/uaccess_32.h",
81304 + .param3 = 1,
81305 +};
81306 +
81307 +struct size_overflow_hash _000006_hash = {
81308 + .next = NULL,
81309 + .name = "__copy_to_user_inatomic",
81310 + .file = "arch/x86/include/asm/uaccess_32.h",
81311 + .param3 = 1,
81312 +};
81313 +
81314 +struct size_overflow_hash _000007_hash = {
81315 + .next = NULL,
81316 + .name = "do_xip_mapping_read",
81317 + .file = "mm/filemap_xip.c",
81318 + .param5 = 1,
81319 +};
81320 +
81321 +struct size_overflow_hash _000008_hash = {
81322 + .next = NULL,
81323 + .name = "hugetlbfs_read",
81324 + .file = "fs/hugetlbfs/inode.c",
81325 + .param3 = 1,
81326 +};
81327 +
81328 +struct size_overflow_hash _000009_hash = {
81329 + .next = NULL,
81330 + .name = "kcalloc",
81331 + .file = "include/linux/slab.h",
81332 + .param1 = 1,
81333 + .param2 = 1,
81334 +};
81335 +
81336 +struct size_overflow_hash _000011_hash = {
81337 + .next = NULL,
81338 + .name = "kmalloc",
81339 + .file = "include/linux/slub_def.h",
81340 + .param1 = 1,
81341 +};
81342 +
81343 +struct size_overflow_hash _000012_hash = {
81344 + .next = NULL,
81345 + .name = "kmalloc_slab",
81346 + .file = "include/linux/slub_def.h",
81347 + .param1 = 1,
81348 +};
81349 +
81350 +struct size_overflow_hash _000013_hash = {
81351 + .next = NULL,
81352 + .name = "kmemdup",
81353 + .file = "include/linux/string.h",
81354 + .param2 = 1,
81355 +};
81356 +
81357 +struct size_overflow_hash _000014_hash = {
81358 + .next = NULL,
81359 + .name = "__krealloc",
81360 + .file = "include/linux/slab.h",
81361 + .param2 = 1,
81362 +};
81363 +
81364 +struct size_overflow_hash _000015_hash = {
81365 + .next = NULL,
81366 + .name = "memdup_user",
81367 + .file = "include/linux/string.h",
81368 + .param2 = 1,
81369 +};
81370 +
81371 +struct size_overflow_hash _000016_hash = {
81372 + .next = NULL,
81373 + .name = "module_alloc",
81374 + .file = "include/linux/moduleloader.h",
81375 + .param1 = 1,
81376 +};
81377 +
81378 +struct size_overflow_hash _000017_hash = {
81379 + .next = NULL,
81380 + .name = "read_default_ldt",
81381 + .file = "arch/x86/kernel/ldt.c",
81382 + .param2 = 1,
81383 +};
81384 +
81385 +struct size_overflow_hash _000018_hash = {
81386 + .next = NULL,
81387 + .name = "read_kcore",
81388 + .file = "fs/proc/kcore.c",
81389 + .param3 = 1,
81390 +};
81391 +
81392 +struct size_overflow_hash _000019_hash = {
81393 + .next = NULL,
81394 + .name = "read_ldt",
81395 + .file = "arch/x86/kernel/ldt.c",
81396 + .param2 = 1,
81397 +};
81398 +
81399 +struct size_overflow_hash _000020_hash = {
81400 + .next = NULL,
81401 + .name = "read_zero",
81402 + .file = "drivers/char/mem.c",
81403 + .param3 = 1,
81404 +};
81405 +
81406 +struct size_overflow_hash _000021_hash = {
81407 + .next = NULL,
81408 + .name = "__vmalloc_node",
81409 + .file = "mm/vmalloc.c",
81410 + .param1 = 1,
81411 +};
81412 +
81413 +struct size_overflow_hash _000022_hash = {
81414 + .next = NULL,
81415 + .name = "vm_map_ram",
81416 + .file = "include/linux/vmalloc.h",
81417 + .param2 = 1,
81418 +};
81419 +
81420 +struct size_overflow_hash _000023_hash = {
81421 + .next = NULL,
81422 + .name = "aa_simple_write_to_buffer",
81423 + .file = "security/apparmor/apparmorfs.c",
81424 + .param4 = 1,
81425 +};
81426 +
81427 +struct size_overflow_hash _000024_hash = {
81428 + .next = NULL,
81429 + .name = "ablkcipher_copy_iv",
81430 + .file = "crypto/ablkcipher.c",
81431 + .param3 = 1,
81432 +};
81433 +
81434 +struct size_overflow_hash _000025_hash = {
81435 + .next = NULL,
81436 + .name = "ablkcipher_next_slow",
81437 + .file = "crypto/ablkcipher.c",
81438 + .param4 = 1,
81439 +};
81440 +
81441 +struct size_overflow_hash _000026_hash = {
81442 + .next = NULL,
81443 + .name = "acpi_os_allocate",
81444 + .file = "include/acpi/platform/aclinux.h",
81445 + .param1 = 1,
81446 +};
81447 +
81448 +struct size_overflow_hash _000027_hash = {
81449 + .next = NULL,
81450 + .name = "acpi_system_write_wakeup_device",
81451 + .file = "drivers/acpi/proc.c",
81452 + .param3 = 1,
81453 +};
81454 +
81455 +struct size_overflow_hash _000028_hash = {
81456 + .next = NULL,
81457 + .name = "ahash_setkey_unaligned",
81458 + .file = "crypto/ahash.c",
81459 + .param3 = 1,
81460 +};
81461 +
81462 +struct size_overflow_hash _000029_hash = {
81463 + .next = NULL,
81464 + .name = "alloc_fdmem",
81465 + .file = "fs/file.c",
81466 + .param1 = 1,
81467 +};
81468 +
81469 +struct size_overflow_hash _000030_hash = {
81470 + .next = NULL,
81471 + .name = "audit_unpack_string",
81472 + .file = "kernel/auditfilter.c",
81473 + .param3 = 1,
81474 +};
81475 +
81476 +struct size_overflow_hash _000031_hash = {
81477 + .next = NULL,
81478 + .name = "bio_alloc_map_data",
81479 + .file = "fs/bio.c",
81480 + .param2 = 1,
81481 +};
81482 +
81483 +struct size_overflow_hash _000032_hash = {
81484 + .next = NULL,
81485 + .name = "bio_kmalloc",
81486 + .file = "include/linux/bio.h",
81487 + .param2 = 1,
81488 +};
81489 +
81490 +struct size_overflow_hash _000033_hash = {
81491 + .next = NULL,
81492 + .name = "blkcipher_copy_iv",
81493 + .file = "crypto/blkcipher.c",
81494 + .param3 = 1,
81495 +};
81496 +
81497 +struct size_overflow_hash _000034_hash = {
81498 + .next = NULL,
81499 + .name = "blkcipher_next_slow",
81500 + .file = "crypto/blkcipher.c",
81501 + .param4 = 1,
81502 +};
81503 +
81504 +struct size_overflow_hash _000035_hash = {
81505 + .next = NULL,
81506 + .name = "cgroup_write_string",
81507 + .file = "kernel/cgroup.c",
81508 + .param5 = 1,
81509 +};
81510 +
81511 +struct size_overflow_hash _000036_hash = {
81512 + .next = NULL,
81513 + .name = "cgroup_write_X64",
81514 + .file = "kernel/cgroup.c",
81515 + .param5 = 1,
81516 +};
81517 +
81518 +struct size_overflow_hash _000037_hash = {
81519 + .next = NULL,
81520 + .name = "clear_refs_write",
81521 + .file = "fs/proc/task_mmu.c",
81522 + .param3 = 1,
81523 +};
81524 +
81525 +struct size_overflow_hash _000038_hash = {
81526 + .next = NULL,
81527 + .name = "comm_write",
81528 + .file = "fs/proc/base.c",
81529 + .param3 = 1,
81530 +};
81531 +
81532 +struct size_overflow_hash _000039_hash = {
81533 + .next = NULL,
81534 + .name = "copy_and_check",
81535 + .file = "kernel/module.c",
81536 + .param3 = 1,
81537 +};
81538 +
81539 +struct size_overflow_hash _000040_hash = {
81540 + .next = NULL,
81541 + .name = "__copy_to_user",
81542 + .file = "arch/x86/include/asm/uaccess_32.h",
81543 + .param3 = 1,
81544 +};
81545 +
81546 +struct size_overflow_hash _000041_hash = {
81547 + .next = NULL,
81548 + .name = "copy_vm86_regs_from_user",
81549 + .file = "arch/x86/kernel/vm86_32.c",
81550 + .param3 = 1,
81551 +};
81552 +
81553 +struct size_overflow_hash _000042_hash = {
81554 + .next = NULL,
81555 + .name = "csum_partial_copy_fromiovecend",
81556 + .file = "include/linux/socket.h",
81557 + .param4 = 1,
81558 +};
81559 +
81560 +struct size_overflow_hash _000043_hash = {
81561 + .next = NULL,
81562 + .name = "ddebug_proc_write",
81563 + .file = "lib/dynamic_debug.c",
81564 + .param3 = 1,
81565 +};
81566 +
81567 +struct size_overflow_hash _000044_hash = {
81568 + .next = NULL,
81569 + .name = "devm_kzalloc",
81570 + .file = "include/linux/device.h",
81571 + .param2 = 1,
81572 +};
81573 +
81574 +struct size_overflow_hash _000045_hash = {
81575 + .next = NULL,
81576 + .name = "devres_alloc",
81577 + .file = "include/linux/device.h",
81578 + .param2 = 1,
81579 +};
81580 +
81581 +struct size_overflow_hash _000046_hash = {
81582 + .next = NULL,
81583 + .name = "do_ip_setsockopt",
81584 + .file = "net/ipv4/ip_sockglue.c",
81585 + .param5 = 1,
81586 +};
81587 +
81588 +struct size_overflow_hash _000047_hash = {
81589 + .next = NULL,
81590 + .name = "do_kimage_alloc",
81591 + .file = "kernel/kexec.c",
81592 + .param3 = 1,
81593 +};
81594 +
81595 +struct size_overflow_hash _000048_hash = {
81596 + .next = NULL,
81597 + .name = "do_tty_write",
81598 + .file = "drivers/tty/tty_io.c",
81599 + .param5 = 1,
81600 +};
81601 +
81602 +struct size_overflow_hash _000049_hash = {
81603 + .next = NULL,
81604 + .name = "fanotify_write",
81605 + .file = "fs/notify/fanotify/fanotify_user.c",
81606 + .param3 = 1,
81607 +};
81608 +
81609 +struct size_overflow_hash _000050_hash = {
81610 + .next = NULL,
81611 + .name = "file_read_actor",
81612 + .file = "include/linux/fs.h",
81613 + .param4 = 1,
81614 +};
81615 +
81616 +struct size_overflow_hash _000051_hash = {
81617 + .next = NULL,
81618 + .name = "fill_write_buffer",
81619 + .file = "fs/sysfs/file.c",
81620 + .param3 = 1,
81621 +};
81622 +
81623 +struct size_overflow_hash _000052_hash = {
81624 + .next = NULL,
81625 + .name = "get_user_cpu_mask",
81626 + .file = "kernel/sched/core.c",
81627 + .param2 = 1,
81628 +};
81629 +
81630 +struct size_overflow_hash _000053_hash = {
81631 + .next = NULL,
81632 + .name = "hashtab_create",
81633 + .file = "security/selinux/ss/hashtab.c",
81634 + .param3 = 1,
81635 +};
81636 +
81637 +struct size_overflow_hash _000054_hash = {
81638 + .next = NULL,
81639 + .name = "heap_init",
81640 + .file = "include/linux/prio_heap.h",
81641 + .param2 = 1,
81642 +};
81643 +
81644 +struct size_overflow_hash _000055_hash = {
81645 + .next = NULL,
81646 + .name = "hest_ghes_dev_register",
81647 + .file = "drivers/acpi/apei/hest.c",
81648 + .param1 = 1,
81649 +};
81650 +
81651 +struct size_overflow_hash _000056_hash = {
81652 + .next = NULL,
81653 + .name = "ima_write_policy",
81654 + .file = "security/integrity/ima/ima_fs.c",
81655 + .param3 = 1,
81656 +};
81657 +
81658 +struct size_overflow_hash _000057_hash = {
81659 + .next = NULL,
81660 + .name = "input_ff_create",
81661 + .file = "include/linux/input.h",
81662 + .param2 = 1,
81663 +};
81664 +
81665 +struct size_overflow_hash _000058_hash = {
81666 + .next = NULL,
81667 + .name = "input_mt_init_slots",
81668 + .file = "include/linux/input/mt.h",
81669 + .param2 = 1,
81670 +};
81671 +
81672 +struct size_overflow_hash _000059_hash = {
81673 + .next = NULL,
81674 + .name = "iov_iter_copy_from_user",
81675 + .file = "include/linux/fs.h",
81676 + .param4 = 1,
81677 +};
81678 +
81679 +struct size_overflow_hash _000060_hash = {
81680 + .next = NULL,
81681 + .name = "iov_iter_copy_from_user_atomic",
81682 + .file = "include/linux/fs.h",
81683 + .param4 = 1,
81684 +};
81685 +
81686 +struct size_overflow_hash _000061_hash = {
81687 + .next = NULL,
81688 + .name = "keyctl_instantiate_key_common",
81689 + .file = "security/keys/keyctl.c",
81690 + .param4 = 1,
81691 +};
81692 +
81693 +struct size_overflow_hash _000062_hash = {
81694 + .next = NULL,
81695 + .name = "keyctl_update_key",
81696 + .file = "security/keys/keyctl.c",
81697 + .param3 = 1,
81698 +};
81699 +
81700 +struct size_overflow_hash _000063_hash = {
81701 + .next = NULL,
81702 + .name = "__kfifo_alloc",
81703 + .file = "include/linux/kfifo.h",
81704 + .param2 = 1,
81705 + .param3 = 1,
81706 +};
81707 +
81708 +struct size_overflow_hash _000065_hash = {
81709 + .next = NULL,
81710 + .name = "kfifo_copy_from_user",
81711 + .file = "kernel/kfifo.c",
81712 + .param3 = 1,
81713 +};
81714 +
81715 +struct size_overflow_hash _000066_hash = {
81716 + .next = NULL,
81717 + .name = "kmalloc_node",
81718 + .file = "include/linux/slab.h",
81719 + .param1 = 1,
81720 +};
81721 +
81722 +struct size_overflow_hash _000067_hash = {
81723 + .next = NULL,
81724 + .name = "kmalloc_parameter",
81725 + .file = "kernel/params.c",
81726 + .param1 = 1,
81727 +};
81728 +
81729 +struct size_overflow_hash _000068_hash = {
81730 + .next = NULL,
81731 + .name = "kobj_map",
81732 + .file = "include/linux/kobj_map.h",
81733 + .param2 = 1,
81734 + .param3 = 1,
81735 +};
81736 +
81737 +struct size_overflow_hash _000070_hash = {
81738 + .next = NULL,
81739 + .name = "krealloc",
81740 + .file = "include/linux/slab.h",
81741 + .param2 = 1,
81742 +};
81743 +
81744 +struct size_overflow_hash _000071_hash = {
81745 + .next = NULL,
81746 + .name = "kvmalloc",
81747 + .file = "security/apparmor/lib.c",
81748 + .param1 = 1,
81749 +};
81750 +
81751 +struct size_overflow_hash _000072_hash = {
81752 + .next = NULL,
81753 + .name = "kzalloc",
81754 + .file = "include/linux/slab.h",
81755 + .param1 = 1,
81756 +};
81757 +
81758 +struct size_overflow_hash _000073_hash = {
81759 + .next = NULL,
81760 + .name = "listxattr",
81761 + .file = "fs/xattr.c",
81762 + .param3 = 1,
81763 +};
81764 +
81765 +struct size_overflow_hash _000074_hash = {
81766 + .next = NULL,
81767 + .name = "mempool_kmalloc",
81768 + .file = "include/linux/mempool.h",
81769 + .param2 = 1,
81770 +};
81771 +
81772 +struct size_overflow_hash _000075_hash = {
81773 + .next = NULL,
81774 + .name = "mem_rw",
81775 + .file = "fs/proc/base.c",
81776 + .param3 = 1,
81777 +};
81778 +
81779 +struct size_overflow_hash _000076_hash = {
81780 + .next = NULL,
81781 + .name = "module_alloc_update_bounds",
81782 + .file = "kernel/module.c",
81783 + .param1 = 1,
81784 +};
81785 +
81786 +struct size_overflow_hash _000077_hash = {
81787 + .next = NULL,
81788 + .name = "mpi_alloc_limb_space",
81789 + .file = "lib/mpi/mpiutil.c",
81790 + .param1 = 1,
81791 +};
81792 +
81793 +struct size_overflow_hash _000078_hash = {
81794 + .next = NULL,
81795 + .name = "mpi_resize",
81796 + .file = "include/linux/mpi.h",
81797 + .param2 = 1,
81798 +};
81799 +
81800 +struct size_overflow_hash _000079_hash = {
81801 + .next = NULL,
81802 + .name = "mtrr_write",
81803 + .file = "arch/x86/kernel/cpu/mtrr/if.c",
81804 + .param3 = 1,
81805 +};
81806 +
81807 +struct size_overflow_hash _000080_hash = {
81808 + .next = NULL,
81809 + .name = "oom_adjust_write",
81810 + .file = "fs/proc/base.c",
81811 + .param3 = 1,
81812 +};
81813 +
81814 +struct size_overflow_hash _000081_hash = {
81815 + .next = NULL,
81816 + .name = "oom_score_adj_write",
81817 + .file = "fs/proc/base.c",
81818 + .param3 = 1,
81819 +};
81820 +
81821 +struct size_overflow_hash _000082_hash = {
81822 + .next = NULL,
81823 + .name = "pipe_iov_copy_from_user",
81824 + .file = "fs/pipe.c",
81825 + .param3 = 1,
81826 +};
81827 +
81828 +struct size_overflow_hash _000083_hash = {
81829 + .next = NULL,
81830 + .name = "pipe_iov_copy_to_user",
81831 + .file = "fs/pipe.c",
81832 + .param3 = 1,
81833 +};
81834 +
81835 +struct size_overflow_hash _000084_hash = {
81836 + .next = NULL,
81837 + .name = "pipe_set_size",
81838 + .file = "fs/pipe.c",
81839 + .param2 = 1,
81840 +};
81841 +
81842 +struct size_overflow_hash _000085_hash = {
81843 + .next = NULL,
81844 + .name = "platform_device_add_data",
81845 + .file = "include/linux/platform_device.h",
81846 + .param3 = 1,
81847 +};
81848 +
81849 +struct size_overflow_hash _000086_hash = {
81850 + .next = NULL,
81851 + .name = "platform_device_add_resources",
81852 + .file = "include/linux/platform_device.h",
81853 + .param3 = 1,
81854 +};
81855 +
81856 +struct size_overflow_hash _000087_hash = {
81857 + .next = NULL,
81858 + .name = "pm_qos_power_write",
81859 + .file = "kernel/power/qos.c",
81860 + .param3 = 1,
81861 +};
81862 +
81863 +struct size_overflow_hash _000088_hash = {
81864 + .next = NULL,
81865 + .name = "pnpbios_proc_write",
81866 + .file = "drivers/pnp/pnpbios/proc.c",
81867 + .param3 = 1,
81868 +};
81869 +
81870 +struct size_overflow_hash _000089_hash = {
81871 + .next = NULL,
81872 + .name = "__probe_kernel_read",
81873 + .file = "include/linux/uaccess.h",
81874 + .param3 = 1,
81875 +};
81876 +
81877 +struct size_overflow_hash _000090_hash = {
81878 + .next = NULL,
81879 + .name = "__probe_kernel_write",
81880 + .file = "include/linux/uaccess.h",
81881 + .param3 = 1,
81882 +};
81883 +
81884 +struct size_overflow_hash _000091_hash = {
81885 + .next = NULL,
81886 + .name = "proc_coredump_filter_write",
81887 + .file = "fs/proc/base.c",
81888 + .param3 = 1,
81889 +};
81890 +
81891 +struct size_overflow_hash _000092_hash = {
81892 + .next = NULL,
81893 + .name = "process_vm_rw_pages",
81894 + .file = "mm/process_vm_access.c",
81895 + .param5 = 1,
81896 + .param6 = 1,
81897 +};
81898 +
81899 +struct size_overflow_hash _000094_hash = {
81900 + .next = NULL,
81901 + .name = "proc_loginuid_write",
81902 + .file = "fs/proc/base.c",
81903 + .param3 = 1,
81904 +};
81905 +
81906 +struct size_overflow_hash _000095_hash = {
81907 + .next = NULL,
81908 + .name = "proc_pid_attr_write",
81909 + .file = "fs/proc/base.c",
81910 + .param3 = 1,
81911 +};
81912 +
81913 +struct size_overflow_hash _000096_hash = {
81914 + .next = NULL,
81915 + .name = "pstore_mkfile",
81916 + .file = "fs/pstore/inode.c",
81917 + .param5 = 1,
81918 +};
81919 +
81920 +struct size_overflow_hash _000097_hash = {
81921 + .next = NULL,
81922 + .name = "qdisc_class_hash_alloc",
81923 + .file = "net/sched/sch_api.c",
81924 + .param1 = 1,
81925 +};
81926 +
81927 +struct size_overflow_hash _000098_hash = {
81928 + .next = NULL,
81929 + .name = "read",
81930 + .file = "fs/sysfs/bin.c",
81931 + .param3 = 1,
81932 +};
81933 +
81934 +struct size_overflow_hash _000099_hash = {
81935 + .next = NULL,
81936 + .name = "regmap_access_read_file",
81937 + .file = "drivers/base/regmap/regmap-debugfs.c",
81938 + .param3 = 1,
81939 +};
81940 +
81941 +struct size_overflow_hash _000100_hash = {
81942 + .next = NULL,
81943 + .name = "regmap_map_read_file",
81944 + .file = "drivers/base/regmap/regmap-debugfs.c",
81945 + .param3 = 1,
81946 +};
81947 +
81948 +struct size_overflow_hash _000101_hash = {
81949 + .next = NULL,
81950 + .name = "_regmap_raw_write",
81951 + .file = "drivers/base/regmap/regmap.c",
81952 + .param4 = 1,
81953 +};
81954 +
81955 +struct size_overflow_hash _000102_hash = {
81956 + .next = NULL,
81957 + .name = "regset_tls_set",
81958 + .file = "arch/x86/kernel/tls.c",
81959 + .param4 = 1,
81960 +};
81961 +
81962 +struct size_overflow_hash _000103_hash = {
81963 + .next = NULL,
81964 + .name = "request_key_auth_new",
81965 + .file = "security/keys/request_key_auth.c",
81966 + .param3 = 1,
81967 +};
81968 +
81969 +struct size_overflow_hash _000104_hash = {
81970 + .next = NULL,
81971 + .name = "restore_i387_fxsave",
81972 + .file = "arch/x86/kernel/i387.c",
81973 + .param2 = 1,
81974 +};
81975 +
81976 +struct size_overflow_hash _000105_hash = {
81977 + .next = NULL,
81978 + .name = "rngapi_reset",
81979 + .file = "crypto/rng.c",
81980 + .param3 = 1,
81981 +};
81982 +
81983 +struct size_overflow_hash _000106_hash = {
81984 + .next = NULL,
81985 + .name = "rw_copy_check_uvector",
81986 + .file = "include/linux/fs.h",
81987 + .param3 = 1,
81988 +};
81989 +
81990 +struct size_overflow_hash _000107_hash = {
81991 + .next = NULL,
81992 + .name = "sched_autogroup_write",
81993 + .file = "fs/proc/base.c",
81994 + .param3 = 1,
81995 +};
81996 +
81997 +struct size_overflow_hash _000108_hash = {
81998 + .next = NULL,
81999 + .name = "security_context_to_sid_core",
82000 + .file = "security/selinux/ss/services.c",
82001 + .param2 = 1,
82002 +};
82003 +
82004 +struct size_overflow_hash _000109_hash = {
82005 + .next = NULL,
82006 + .name = "sel_commit_bools_write",
82007 + .file = "security/selinux/selinuxfs.c",
82008 + .param3 = 1,
82009 +};
82010 +
82011 +struct size_overflow_hash _000110_hash = {
82012 + .next = NULL,
82013 + .name = "sel_write_avc_cache_threshold",
82014 + .file = "security/selinux/selinuxfs.c",
82015 + .param3 = 1,
82016 +};
82017 +
82018 +struct size_overflow_hash _000111_hash = {
82019 + .next = NULL,
82020 + .name = "sel_write_bool",
82021 + .file = "security/selinux/selinuxfs.c",
82022 + .param3 = 1,
82023 +};
82024 +
82025 +struct size_overflow_hash _000112_hash = {
82026 + .next = NULL,
82027 + .name = "sel_write_checkreqprot",
82028 + .file = "security/selinux/selinuxfs.c",
82029 + .param3 = 1,
82030 +};
82031 +
82032 +struct size_overflow_hash _000113_hash = {
82033 + .next = NULL,
82034 + .name = "sel_write_disable",
82035 + .file = "security/selinux/selinuxfs.c",
82036 + .param3 = 1,
82037 +};
82038 +
82039 +struct size_overflow_hash _000114_hash = {
82040 + .next = NULL,
82041 + .name = "sel_write_enforce",
82042 + .file = "security/selinux/selinuxfs.c",
82043 + .param3 = 1,
82044 +};
82045 +
82046 +struct size_overflow_hash _000115_hash = {
82047 + .next = NULL,
82048 + .name = "sel_write_load",
82049 + .file = "security/selinux/selinuxfs.c",
82050 + .param3 = 1,
82051 +};
82052 +
82053 +struct size_overflow_hash _000116_hash = {
82054 + .next = NULL,
82055 + .name = "setkey_unaligned",
82056 + .file = "crypto/ablkcipher.c",
82057 + .param3 = 1,
82058 +};
82059 +
82060 +struct size_overflow_hash _000117_hash = {
82061 + .next = NULL,
82062 + .name = "setkey_unaligned",
82063 + .file = "crypto/blkcipher.c",
82064 + .param3 = 1,
82065 +};
82066 +
82067 +struct size_overflow_hash _000118_hash = {
82068 + .next = NULL,
82069 + .name = "setkey_unaligned",
82070 + .file = "crypto/aead.c",
82071 + .param3 = 1,
82072 +};
82073 +
82074 +struct size_overflow_hash _000119_hash = {
82075 + .next = NULL,
82076 + .name = "setkey_unaligned",
82077 + .file = "crypto/cipher.c",
82078 + .param3 = 1,
82079 +};
82080 +
82081 +struct size_overflow_hash _000120_hash = {
82082 + .next = NULL,
82083 + .name = "setxattr",
82084 + .file = "fs/xattr.c",
82085 + .param4 = 1,
82086 +};
82087 +
82088 +struct size_overflow_hash _000121_hash = {
82089 + .next = NULL,
82090 + .name = "sg_kmalloc",
82091 + .file = "lib/scatterlist.c",
82092 + .param1 = 1,
82093 +};
82094 +
82095 +struct size_overflow_hash _000122_hash = {
82096 + .next = NULL,
82097 + .name = "shash_setkey_unaligned",
82098 + .file = "crypto/shash.c",
82099 + .param3 = 1,
82100 +};
82101 +
82102 +struct size_overflow_hash _000123_hash = {
82103 + .next = NULL,
82104 + .name = "shmem_xattr_set",
82105 + .file = "mm/shmem.c",
82106 + .param4 = 1,
82107 +};
82108 +
82109 +struct size_overflow_hash _000124_hash = {
82110 + .next = NULL,
82111 + .name = "simple_transaction_get",
82112 + .file = "include/linux/fs.h",
82113 + .param3 = 1,
82114 +};
82115 +
82116 +struct size_overflow_hash _000125_hash = {
82117 + .next = NULL,
82118 + .name = "simple_write_to_buffer",
82119 + .file = "include/linux/fs.h",
82120 + .param2 = 1,
82121 + .param5 = 1,
82122 +};
82123 +
82124 +struct size_overflow_hash _000127_hash = {
82125 + .next = NULL,
82126 + .name = "smk_write_ambient",
82127 + .file = "security/smack/smackfs.c",
82128 + .param3 = 1,
82129 +};
82130 +
82131 +struct size_overflow_hash _000128_hash = {
82132 + .next = NULL,
82133 + .name = "smk_write_cipso",
82134 + .file = "security/smack/smackfs.c",
82135 + .param3 = 1,
82136 +};
82137 +
82138 +struct size_overflow_hash _000129_hash = {
82139 + .next = NULL,
82140 + .name = "smk_write_direct",
82141 + .file = "security/smack/smackfs.c",
82142 + .param3 = 1,
82143 +};
82144 +
82145 +struct size_overflow_hash _000130_hash = {
82146 + .next = NULL,
82147 + .name = "smk_write_doi",
82148 + .file = "security/smack/smackfs.c",
82149 + .param3 = 1,
82150 +};
82151 +
82152 +struct size_overflow_hash _000131_hash = {
82153 + .next = NULL,
82154 + .name = "smk_write_load_list",
82155 + .file = "security/smack/smackfs.c",
82156 + .param3 = 1,
82157 +};
82158 +
82159 +struct size_overflow_hash _000132_hash = {
82160 + .next = &_000102_hash,
82161 + .name = "smk_write_logging",
82162 + .file = "security/smack/smackfs.c",
82163 + .param3 = 1,
82164 +};
82165 +
82166 +struct size_overflow_hash _000133_hash = {
82167 + .next = NULL,
82168 + .name = "smk_write_netlbladdr",
82169 + .file = "security/smack/smackfs.c",
82170 + .param3 = 1,
82171 +};
82172 +
82173 +struct size_overflow_hash _000134_hash = {
82174 + .next = NULL,
82175 + .name = "smk_write_onlycap",
82176 + .file = "security/smack/smackfs.c",
82177 + .param3 = 1,
82178 +};
82179 +
82180 +struct size_overflow_hash _000135_hash = {
82181 + .next = NULL,
82182 + .name = "sys_add_key",
82183 + .file = "include/linux/syscalls.h",
82184 + .param4 = 1,
82185 +};
82186 +
82187 +struct size_overflow_hash _000136_hash = {
82188 + .next = NULL,
82189 + .name = "sys_modify_ldt",
82190 + .file = "arch/x86/include/asm/syscalls.h",
82191 + .param3 = 1,
82192 +};
82193 +
82194 +struct size_overflow_hash _000137_hash = {
82195 + .next = NULL,
82196 + .name = "sys_semtimedop",
82197 + .file = "include/linux/syscalls.h",
82198 + .param3 = 1,
82199 +};
82200 +
82201 +struct size_overflow_hash _000138_hash = {
82202 + .next = NULL,
82203 + .name = "tomoyo_write_self",
82204 + .file = "security/tomoyo/securityfs_if.c",
82205 + .param3 = 1,
82206 +};
82207 +
82208 +struct size_overflow_hash _000139_hash = {
82209 + .next = NULL,
82210 + .name = "tpm_write",
82211 + .file = "drivers/char/tpm/tpm.c",
82212 + .param3 = 1,
82213 +};
82214 +
82215 +struct size_overflow_hash _000140_hash = {
82216 + .next = NULL,
82217 + .name = "tty_buffer_alloc",
82218 + .file = "drivers/tty/tty_buffer.c",
82219 + .param2 = 1,
82220 +};
82221 +
82222 +struct size_overflow_hash _000141_hash = {
82223 + .next = NULL,
82224 + .name = "user_instantiate",
82225 + .file = "include/keys/user-type.h",
82226 + .param3 = 1,
82227 +};
82228 +
82229 +struct size_overflow_hash _000142_hash = {
82230 + .next = NULL,
82231 + .name = "user_update",
82232 + .file = "include/keys/user-type.h",
82233 + .param3 = 1,
82234 +};
82235 +
82236 +struct size_overflow_hash _000143_hash = {
82237 + .next = NULL,
82238 + .name = "vc_do_resize",
82239 + .file = "drivers/tty/vt/vt.c",
82240 + .param3 = 1,
82241 + .param4 = 1,
82242 +};
82243 +
82244 +struct size_overflow_hash _000145_hash = {
82245 + .next = NULL,
82246 + .name = "vcs_write",
82247 + .file = "drivers/tty/vt/vc_screen.c",
82248 + .param3 = 1,
82249 +};
82250 +
82251 +struct size_overflow_hash _000146_hash = {
82252 + .next = NULL,
82253 + .name = "vga_arb_write",
82254 + .file = "drivers/gpu/vga/vgaarb.c",
82255 + .param3 = 1,
82256 +};
82257 +
82258 +struct size_overflow_hash _000147_hash = {
82259 + .next = NULL,
82260 + .name = "vga_switcheroo_debugfs_write",
82261 + .file = "drivers/gpu/vga/vga_switcheroo.c",
82262 + .param3 = 1,
82263 +};
82264 +
82265 +struct size_overflow_hash _000148_hash = {
82266 + .next = NULL,
82267 + .name = "__vmalloc",
82268 + .file = "include/linux/vmalloc.h",
82269 + .param1 = 1,
82270 +};
82271 +
82272 +struct size_overflow_hash _000149_hash = {
82273 + .next = NULL,
82274 + .name = "vmalloc_32",
82275 + .file = "include/linux/vmalloc.h",
82276 + .param1 = 1,
82277 +};
82278 +
82279 +struct size_overflow_hash _000150_hash = {
82280 + .next = NULL,
82281 + .name = "vmalloc_32_user",
82282 + .file = "include/linux/vmalloc.h",
82283 + .param1 = 1,
82284 +};
82285 +
82286 +struct size_overflow_hash _000151_hash = {
82287 + .next = NULL,
82288 + .name = "vmalloc_exec",
82289 + .file = "include/linux/vmalloc.h",
82290 + .param1 = 1,
82291 +};
82292 +
82293 +struct size_overflow_hash _000152_hash = {
82294 + .next = NULL,
82295 + .name = "vmalloc_node",
82296 + .file = "include/linux/vmalloc.h",
82297 + .param1 = 1,
82298 +};
82299 +
82300 +struct size_overflow_hash _000153_hash = {
82301 + .next = NULL,
82302 + .name = "__vmalloc_node_flags",
82303 + .file = "mm/vmalloc.c",
82304 + .param1 = 1,
82305 +};
82306 +
82307 +struct size_overflow_hash _000154_hash = {
82308 + .next = NULL,
82309 + .name = "vmalloc_user",
82310 + .file = "include/linux/vmalloc.h",
82311 + .param1 = 1,
82312 +};
82313 +
82314 +struct size_overflow_hash _000155_hash = {
82315 + .next = NULL,
82316 + .name = "write",
82317 + .file = "fs/sysfs/bin.c",
82318 + .param3 = 1,
82319 +};
82320 +
82321 +struct size_overflow_hash _000156_hash = {
82322 + .next = NULL,
82323 + .name = "__xip_file_write",
82324 + .file = "mm/filemap_xip.c",
82325 + .param3 = 1,
82326 +};
82327 +
82328 +struct size_overflow_hash _000157_hash = {
82329 + .next = NULL,
82330 + .name = "acpi_ex_allocate_name_string",
82331 + .file = "drivers/acpi/acpica/exnames.c",
82332 + .param2 = 1,
82333 +};
82334 +
82335 +struct size_overflow_hash _000158_hash = {
82336 + .next = NULL,
82337 + .name = "acpi_os_allocate_zeroed",
82338 + .file = "include/acpi/platform/aclinux.h",
82339 + .param1 = 1,
82340 +};
82341 +
82342 +struct size_overflow_hash _000159_hash = {
82343 + .next = NULL,
82344 + .name = "acpi_ut_initialize_buffer",
82345 + .file = "drivers/acpi/acpica/utalloc.c",
82346 + .param2 = 1,
82347 +};
82348 +
82349 +struct size_overflow_hash _000160_hash = {
82350 + .next = NULL,
82351 + .name = "add_numbered_child",
82352 + .file = "drivers/mfd/twl-core.c",
82353 + .param5 = 1,
82354 +};
82355 +
82356 +struct size_overflow_hash _000161_hash = {
82357 + .next = NULL,
82358 + .name = "___alloc_bootmem_nopanic",
82359 + .file = "mm/nobootmem.c",
82360 + .param1 = 1,
82361 +};
82362 +
82363 +struct size_overflow_hash _000162_hash = {
82364 + .next = NULL,
82365 + .name = "alloc_large_system_hash",
82366 + .file = "include/linux/bootmem.h",
82367 + .param2 = 1,
82368 +};
82369 +
82370 +struct size_overflow_hash _000163_hash = {
82371 + .next = NULL,
82372 + .name = "audit_init_entry",
82373 + .file = "kernel/auditfilter.c",
82374 + .param1 = 1,
82375 +};
82376 +
82377 +struct size_overflow_hash _000164_hash = {
82378 + .next = NULL,
82379 + .name = "__bio_map_kern",
82380 + .file = "fs/bio.c",
82381 + .param2 = 1,
82382 + .param3 = 1,
82383 +};
82384 +
82385 +struct size_overflow_hash _000166_hash = {
82386 + .next = NULL,
82387 + .name = "blk_register_region",
82388 + .file = "include/linux/genhd.h",
82389 + .param1 = 1,
82390 + .param2 = 1,
82391 +};
82392 +
82393 +struct size_overflow_hash _000168_hash = {
82394 + .next = NULL,
82395 + .name = "cdev_add",
82396 + .file = "include/linux/cdev.h",
82397 + .param2 = 1,
82398 + .param3 = 1,
82399 +};
82400 +
82401 +struct size_overflow_hash _000170_hash = {
82402 + .next = NULL,
82403 + .name = "copy_to_user",
82404 + .file = "arch/x86/include/asm/uaccess_32.h",
82405 + .param3 = 1,
82406 +};
82407 +
82408 +struct size_overflow_hash _000171_hash = {
82409 + .next = NULL,
82410 + .name = "crypto_ahash_setkey",
82411 + .file = "include/crypto/hash.h",
82412 + .param3 = 1,
82413 +};
82414 +
82415 +struct size_overflow_hash _000172_hash = {
82416 + .next = NULL,
82417 + .name = "crypto_alloc_instance2",
82418 + .file = "include/crypto/algapi.h",
82419 + .param3 = 1,
82420 +};
82421 +
82422 +struct size_overflow_hash _000173_hash = {
82423 + .next = NULL,
82424 + .name = "crypto_shash_setkey",
82425 + .file = "include/crypto/hash.h",
82426 + .param3 = 1,
82427 +};
82428 +
82429 +struct size_overflow_hash _000174_hash = {
82430 + .next = NULL,
82431 + .name = "dev_set_alias",
82432 + .file = "include/linux/netdevice.h",
82433 + .param3 = 1,
82434 +};
82435 +
82436 +struct size_overflow_hash _000175_hash = {
82437 + .next = NULL,
82438 + .name = "do_readv_writev",
82439 + .file = "fs/read_write.c",
82440 + .param4 = 1,
82441 +};
82442 +
82443 +struct size_overflow_hash _000176_hash = {
82444 + .next = NULL,
82445 + .name = "getxattr",
82446 + .file = "fs/xattr.c",
82447 + .param4 = 1,
82448 +};
82449 +
82450 +struct size_overflow_hash _000177_hash = {
82451 + .next = NULL,
82452 + .name = "hugetlbfs_read_actor",
82453 + .file = "fs/hugetlbfs/inode.c",
82454 + .param2 = 1,
82455 + .param5 = 1,
82456 + .param4 = 1,
82457 +};
82458 +
82459 +struct size_overflow_hash _000180_hash = {
82460 + .next = NULL,
82461 + .name = "keyctl_instantiate_key",
82462 + .file = "security/keys/keyctl.c",
82463 + .param3 = 1,
82464 +};
82465 +
82466 +struct size_overflow_hash _000181_hash = {
82467 + .next = NULL,
82468 + .name = "keyctl_instantiate_key_iov",
82469 + .file = "security/keys/keyctl.c",
82470 + .param3 = 1,
82471 +};
82472 +
82473 +struct size_overflow_hash _000182_hash = {
82474 + .next = NULL,
82475 + .name = "__kfifo_from_user",
82476 + .file = "include/linux/kfifo.h",
82477 + .param3 = 1,
82478 +};
82479 +
82480 +struct size_overflow_hash _000183_hash = {
82481 + .next = NULL,
82482 + .name = "kimage_crash_alloc",
82483 + .file = "kernel/kexec.c",
82484 + .param3 = 1,
82485 +};
82486 +
82487 +struct size_overflow_hash _000184_hash = {
82488 + .next = NULL,
82489 + .name = "kimage_normal_alloc",
82490 + .file = "kernel/kexec.c",
82491 + .param3 = 1,
82492 +};
82493 +
82494 +struct size_overflow_hash _000185_hash = {
82495 + .next = NULL,
82496 + .name = "mpi_alloc",
82497 + .file = "include/linux/mpi.h",
82498 + .param1 = 1,
82499 +};
82500 +
82501 +struct size_overflow_hash _000186_hash = {
82502 + .next = NULL,
82503 + .name = "mpi_set_bit",
82504 + .file = "include/linux/mpi.h",
82505 + .param2 = 1,
82506 +};
82507 +
82508 +struct size_overflow_hash _000187_hash = {
82509 + .next = NULL,
82510 + .name = "mpi_set_highbit",
82511 + .file = "include/linux/mpi.h",
82512 + .param2 = 1,
82513 +};
82514 +
82515 +struct size_overflow_hash _000188_hash = {
82516 + .next = NULL,
82517 + .name = "neigh_hash_alloc",
82518 + .file = "net/core/neighbour.c",
82519 + .param1 = 1,
82520 +};
82521 +
82522 +struct size_overflow_hash _000189_hash = {
82523 + .next = NULL,
82524 + .name = "nl_pid_hash_zalloc",
82525 + .file = "net/netlink/af_netlink.c",
82526 + .param1 = 1,
82527 +};
82528 +
82529 +struct size_overflow_hash _000190_hash = {
82530 + .next = NULL,
82531 + .name = "pci_add_cap_save_buffer",
82532 + .file = "drivers/pci/pci.c",
82533 + .param3 = 1,
82534 +};
82535 +
82536 +struct size_overflow_hash _000191_hash = {
82537 + .next = NULL,
82538 + .name = "pcpu_mem_zalloc",
82539 + .file = "mm/percpu.c",
82540 + .param1 = 1,
82541 +};
82542 +
82543 +struct size_overflow_hash _000192_hash = {
82544 + .next = NULL,
82545 + .name = "platform_create_bundle",
82546 + .file = "include/linux/platform_device.h",
82547 + .param4 = 1,
82548 + .param6 = 1,
82549 +};
82550 +
82551 +struct size_overflow_hash _000194_hash = {
82552 + .next = NULL,
82553 + .name = "process_vm_rw",
82554 + .file = "mm/process_vm_access.c",
82555 + .param3 = 1,
82556 + .param5 = 1,
82557 +};
82558 +
82559 +struct size_overflow_hash _000196_hash = {
82560 + .next = NULL,
82561 + .name = "process_vm_rw_single_vec",
82562 + .file = "mm/process_vm_access.c",
82563 + .param1 = 1,
82564 + .param2 = 1,
82565 +};
82566 +
82567 +struct size_overflow_hash _000198_hash = {
82568 + .next = NULL,
82569 + .name = "profile_load",
82570 + .file = "security/apparmor/apparmorfs.c",
82571 + .param3 = 1,
82572 +};
82573 +
82574 +struct size_overflow_hash _000199_hash = {
82575 + .next = NULL,
82576 + .name = "profile_remove",
82577 + .file = "security/apparmor/apparmorfs.c",
82578 + .param3 = 1,
82579 +};
82580 +
82581 +struct size_overflow_hash _000200_hash = {
82582 + .next = NULL,
82583 + .name = "profile_replace",
82584 + .file = "security/apparmor/apparmorfs.c",
82585 + .param3 = 1,
82586 +};
82587 +
82588 +struct size_overflow_hash _000201_hash = {
82589 + .next = NULL,
82590 + .name = "regcache_rbtree_insert_to_block",
82591 + .file = "drivers/base/regmap/regcache-rbtree.c",
82592 + .param5 = 1,
82593 +};
82594 +
82595 +struct size_overflow_hash _000202_hash = {
82596 + .next = NULL,
82597 + .name = "regmap_raw_write",
82598 + .file = "include/linux/regmap.h",
82599 + .param4 = 1,
82600 +};
82601 +
82602 +struct size_overflow_hash _000203_hash = {
82603 + .next = NULL,
82604 + .name = "relay_alloc_page_array",
82605 + .file = "kernel/relay.c",
82606 + .param1 = 1,
82607 +};
82608 +
82609 +struct size_overflow_hash _000204_hash = {
82610 + .next = NULL,
82611 + .name = "RESIZE_IF_NEEDED",
82612 + .file = "lib/mpi/mpi-internal.h",
82613 + .param2 = 1,
82614 +};
82615 +
82616 +struct size_overflow_hash _000205_hash = {
82617 + .next = NULL,
82618 + .name = "security_context_to_sid",
82619 + .file = "security/selinux/ss/services.c",
82620 + .param2 = 1,
82621 +};
82622 +
82623 +struct size_overflow_hash _000206_hash = {
82624 + .next = NULL,
82625 + .name = "security_context_to_sid_default",
82626 + .file = "security/selinux/ss/services.c",
82627 + .param2 = 1,
82628 +};
82629 +
82630 +struct size_overflow_hash _000207_hash = {
82631 + .next = NULL,
82632 + .name = "security_context_to_sid_force",
82633 + .file = "security/selinux/ss/services.c",
82634 + .param2 = 1,
82635 +};
82636 +
82637 +struct size_overflow_hash _000208_hash = {
82638 + .next = NULL,
82639 + .name = "selinux_transaction_write",
82640 + .file = "security/selinux/selinuxfs.c",
82641 + .param3 = 1,
82642 +};
82643 +
82644 +struct size_overflow_hash _000209_hash = {
82645 + .next = NULL,
82646 + .name = "sel_write_access",
82647 + .file = "security/selinux/selinuxfs.c",
82648 + .param3 = 1,
82649 +};
82650 +
82651 +struct size_overflow_hash _000210_hash = {
82652 + .next = NULL,
82653 + .name = "sel_write_create",
82654 + .file = "security/selinux/selinuxfs.c",
82655 + .param3 = 1,
82656 +};
82657 +
82658 +struct size_overflow_hash _000211_hash = {
82659 + .next = NULL,
82660 + .name = "sel_write_member",
82661 + .file = "security/selinux/selinuxfs.c",
82662 + .param3 = 1,
82663 +};
82664 +
82665 +struct size_overflow_hash _000212_hash = {
82666 + .next = NULL,
82667 + .name = "sel_write_relabel",
82668 + .file = "security/selinux/selinuxfs.c",
82669 + .param3 = 1,
82670 +};
82671 +
82672 +struct size_overflow_hash _000213_hash = {
82673 + .next = NULL,
82674 + .name = "sel_write_user",
82675 + .file = "security/selinux/selinuxfs.c",
82676 + .param3 = 1,
82677 +};
82678 +
82679 +struct size_overflow_hash _000214_hash = {
82680 + .next = NULL,
82681 + .name = "setkey",
82682 + .file = "crypto/cipher.c",
82683 + .param3 = 1,
82684 +};
82685 +
82686 +struct size_overflow_hash _000215_hash = {
82687 + .next = NULL,
82688 + .name = "setkey",
82689 + .file = "crypto/ablkcipher.c",
82690 + .param3 = 1,
82691 +};
82692 +
82693 +struct size_overflow_hash _000216_hash = {
82694 + .next = NULL,
82695 + .name = "setkey",
82696 + .file = "crypto/aead.c",
82697 + .param3 = 1,
82698 +};
82699 +
82700 +struct size_overflow_hash _000217_hash = {
82701 + .next = NULL,
82702 + .name = "setkey",
82703 + .file = "crypto/blkcipher.c",
82704 + .param3 = 1,
82705 +};
82706 +
82707 +struct size_overflow_hash _000218_hash = {
82708 + .next = NULL,
82709 + .name = "smk_write_access",
82710 + .file = "security/smack/smackfs.c",
82711 + .param3 = 1,
82712 +};
82713 +
82714 +struct size_overflow_hash _000219_hash = {
82715 + .next = NULL,
82716 + .name = "snapshot_write",
82717 + .file = "kernel/power/user.c",
82718 + .param3 = 1,
82719 +};
82720 +
82721 +struct size_overflow_hash _000220_hash = {
82722 + .next = NULL,
82723 + .name = "spi_alloc_master",
82724 + .file = "include/linux/spi/spi.h",
82725 + .param2 = 1,
82726 +};
82727 +
82728 +struct size_overflow_hash _000221_hash = {
82729 + .next = NULL,
82730 + .name = "spi_register_board_info",
82731 + .file = "include/linux/spi/spi.h",
82732 + .param2 = 1,
82733 +};
82734 +
82735 +struct size_overflow_hash _000222_hash = {
82736 + .next = NULL,
82737 + .name = "sys_flistxattr",
82738 + .file = "include/linux/syscalls.h",
82739 + .param3 = 1,
82740 +};
82741 +
82742 +struct size_overflow_hash _000223_hash = {
82743 + .next = NULL,
82744 + .name = "sys_fsetxattr",
82745 + .file = "include/linux/syscalls.h",
82746 + .param4 = 1,
82747 +};
82748 +
82749 +struct size_overflow_hash _000224_hash = {
82750 + .next = NULL,
82751 + .name = "sysfs_write_file",
82752 + .file = "fs/sysfs/file.c",
82753 + .param3 = 1,
82754 +};
82755 +
82756 +struct size_overflow_hash _000225_hash = {
82757 + .next = NULL,
82758 + .name = "sys_ipc",
82759 + .file = "include/linux/syscalls.h",
82760 + .param3 = 1,
82761 +};
82762 +
82763 +struct size_overflow_hash _000226_hash = {
82764 + .next = NULL,
82765 + .name = "sys_keyctl",
82766 + .file = "include/linux/syscalls.h",
82767 + .param4 = 1,
82768 +};
82769 +
82770 +struct size_overflow_hash _000227_hash = {
82771 + .next = NULL,
82772 + .name = "sys_listxattr",
82773 + .file = "include/linux/syscalls.h",
82774 + .param3 = 1,
82775 +};
82776 +
82777 +struct size_overflow_hash _000228_hash = {
82778 + .next = NULL,
82779 + .name = "sys_llistxattr",
82780 + .file = "include/linux/syscalls.h",
82781 + .param3 = 1,
82782 +};
82783 +
82784 +struct size_overflow_hash _000229_hash = {
82785 + .next = NULL,
82786 + .name = "sys_lsetxattr",
82787 + .file = "include/linux/syscalls.h",
82788 + .param4 = 1,
82789 +};
82790 +
82791 +struct size_overflow_hash _000230_hash = {
82792 + .next = NULL,
82793 + .name = "sys_sched_setaffinity",
82794 + .file = "include/linux/syscalls.h",
82795 + .param2 = 1,
82796 +};
82797 +
82798 +struct size_overflow_hash _000231_hash = {
82799 + .next = NULL,
82800 + .name = "sys_semop",
82801 + .file = "include/linux/syscalls.h",
82802 + .param3 = 1,
82803 +};
82804 +
82805 +struct size_overflow_hash _000232_hash = {
82806 + .next = NULL,
82807 + .name = "sys_setxattr",
82808 + .file = "include/linux/syscalls.h",
82809 + .param4 = 1,
82810 +};
82811 +
82812 +struct size_overflow_hash _000233_hash = {
82813 + .next = NULL,
82814 + .name = "tnode_alloc",
82815 + .file = "net/ipv4/fib_trie.c",
82816 + .param1 = 1,
82817 +};
82818 +
82819 +struct size_overflow_hash _000234_hash = {
82820 + .next = NULL,
82821 + .name = "tomoyo_commit_ok",
82822 + .file = "security/tomoyo/memory.c",
82823 + .param2 = 1,
82824 +};
82825 +
82826 +struct size_overflow_hash _000235_hash = {
82827 + .next = NULL,
82828 + .name = "tomoyo_scan_bprm",
82829 + .file = "security/tomoyo/condition.c",
82830 + .param2 = 1,
82831 + .param4 = 1,
82832 +};
82833 +
82834 +struct size_overflow_hash _000237_hash = {
82835 + .next = NULL,
82836 + .name = "tty_write",
82837 + .file = "drivers/tty/tty_io.c",
82838 + .param3 = 1,
82839 +};
82840 +
82841 +struct size_overflow_hash _000238_hash = {
82842 + .next = NULL,
82843 + .name = "vc_resize",
82844 + .file = "include/linux/vt_kern.h",
82845 + .param2 = 1,
82846 + .param3 = 1,
82847 +};
82848 +
82849 +struct size_overflow_hash _000240_hash = {
82850 + .next = NULL,
82851 + .name = "vmalloc",
82852 + .file = "include/linux/vmalloc.h",
82853 + .param1 = 1,
82854 +};
82855 +
82856 +struct size_overflow_hash _000241_hash = {
82857 + .next = NULL,
82858 + .name = "vzalloc",
82859 + .file = "include/linux/vmalloc.h",
82860 + .param1 = 1,
82861 +};
82862 +
82863 +struct size_overflow_hash _000242_hash = {
82864 + .next = NULL,
82865 + .name = "vzalloc_node",
82866 + .file = "include/linux/vmalloc.h",
82867 + .param1 = 1,
82868 +};
82869 +
82870 +struct size_overflow_hash _000243_hash = {
82871 + .next = NULL,
82872 + .name = "xfrm_hash_alloc",
82873 + .file = "net/xfrm/xfrm_hash.c",
82874 + .param1 = 1,
82875 +};
82876 +
82877 +struct size_overflow_hash _000244_hash = {
82878 + .next = NULL,
82879 + .name = "acpi_ds_build_internal_package_obj",
82880 + .file = "drivers/acpi/acpica/dsobject.c",
82881 + .param3 = 1,
82882 +};
82883 +
82884 +struct size_overflow_hash _000245_hash = {
82885 + .next = NULL,
82886 + .name = "acpi_system_read_event",
82887 + .file = "drivers/acpi/event.c",
82888 + .param3 = 1,
82889 +};
82890 +
82891 +struct size_overflow_hash _000246_hash = {
82892 + .next = NULL,
82893 + .name = "acpi_ut_create_buffer_object",
82894 + .file = "drivers/acpi/acpica/utobject.c",
82895 + .param1 = 1,
82896 +};
82897 +
82898 +struct size_overflow_hash _000247_hash = {
82899 + .next = NULL,
82900 + .name = "acpi_ut_create_package_object",
82901 + .file = "drivers/acpi/acpica/utobject.c",
82902 + .param1 = 1,
82903 +};
82904 +
82905 +struct size_overflow_hash _000248_hash = {
82906 + .next = NULL,
82907 + .name = "acpi_ut_create_string_object",
82908 + .file = "drivers/acpi/acpica/utobject.c",
82909 + .param1 = 1,
82910 +};
82911 +
82912 +struct size_overflow_hash _000249_hash = {
82913 + .next = NULL,
82914 + .name = "add_child",
82915 + .file = "drivers/mfd/twl-core.c",
82916 + .param4 = 1,
82917 +};
82918 +
82919 +struct size_overflow_hash _000250_hash = {
82920 + .next = NULL,
82921 + .name = "___alloc_bootmem",
82922 + .file = "mm/nobootmem.c",
82923 + .param1 = 1,
82924 +};
82925 +
82926 +struct size_overflow_hash _000251_hash = {
82927 + .next = NULL,
82928 + .name = "__alloc_bootmem_nopanic",
82929 + .file = "include/linux/bootmem.h",
82930 + .param1 = 1,
82931 +};
82932 +
82933 +struct size_overflow_hash _000252_hash = {
82934 + .next = NULL,
82935 + .name = "async_setkey",
82936 + .file = "crypto/blkcipher.c",
82937 + .param3 = 1,
82938 +};
82939 +
82940 +struct size_overflow_hash _000253_hash = {
82941 + .next = NULL,
82942 + .name = "bio_map_kern",
82943 + .file = "include/linux/bio.h",
82944 + .param3 = 1,
82945 +};
82946 +
82947 +struct size_overflow_hash _000254_hash = {
82948 + .next = NULL,
82949 + .name = "copy_oldmem_page",
82950 + .file = "include/linux/crash_dump.h",
82951 + .param3 = 1,
82952 +};
82953 +
82954 +struct size_overflow_hash _000255_hash = {
82955 + .next = NULL,
82956 + .name = "do_sigpending",
82957 + .file = "include/linux/signal.h",
82958 + .param2 = 1,
82959 +};
82960 +
82961 +struct size_overflow_hash _000257_hash = {
82962 + .next = NULL,
82963 + .name = "keyctl_describe_key",
82964 + .file = "security/keys/keyctl.c",
82965 + .param3 = 1,
82966 +};
82967 +
82968 +struct size_overflow_hash _000258_hash = {
82969 + .next = NULL,
82970 + .name = "keyctl_get_security",
82971 + .file = "security/keys/keyctl.c",
82972 + .param3 = 1,
82973 +};
82974 +
82975 +struct size_overflow_hash _000259_hash = {
82976 + .next = NULL,
82977 + .name = "keyring_read",
82978 + .file = "security/keys/keyring.c",
82979 + .param3 = 1,
82980 +};
82981 +
82982 +struct size_overflow_hash _000260_hash = {
82983 + .next = NULL,
82984 + .name = "kfifo_copy_to_user",
82985 + .file = "kernel/kfifo.c",
82986 + .param3 = 1,
82987 +};
82988 +
82989 +struct size_overflow_hash _000261_hash = {
82990 + .next = NULL,
82991 + .name = "mousedev_read",
82992 + .file = "drivers/input/mousedev.c",
82993 + .param3 = 1,
82994 +};
82995 +
82996 +struct size_overflow_hash _000262_hash = {
82997 + .next = NULL,
82998 + .name = "mpi_lshift_limbs",
82999 + .file = "lib/mpi/mpi-bit.c",
83000 + .param2 = 1,
83001 +};
83002 +
83003 +struct size_overflow_hash _000263_hash = {
83004 + .next = NULL,
83005 + .name = "neigh_hash_grow",
83006 + .file = "net/core/neighbour.c",
83007 + .param2 = 1,
83008 +};
83009 +
83010 +struct size_overflow_hash _000264_hash = {
83011 + .next = NULL,
83012 + .name = "posix_clock_register",
83013 + .file = "include/linux/posix-clock.h",
83014 + .param2 = 1,
83015 +};
83016 +
83017 +struct size_overflow_hash _000265_hash = {
83018 + .next = NULL,
83019 + .name = "__proc_file_read",
83020 + .file = "fs/proc/generic.c",
83021 + .param3 = 1,
83022 +};
83023 +
83024 +struct size_overflow_hash _000266_hash = {
83025 + .next = NULL,
83026 + .name = "read_profile",
83027 + .file = "kernel/profile.c",
83028 + .param3 = 1,
83029 +};
83030 +
83031 +struct size_overflow_hash _000267_hash = {
83032 + .next = NULL,
83033 + .name = "read_vmcore",
83034 + .file = "fs/proc/vmcore.c",
83035 + .param3 = 1,
83036 +};
83037 +
83038 +struct size_overflow_hash _000268_hash = {
83039 + .next = NULL,
83040 + .name = "redirected_tty_write",
83041 + .file = "drivers/tty/tty_io.c",
83042 + .param3 = 1,
83043 +};
83044 +
83045 +struct size_overflow_hash _000269_hash = {
83046 + .next = NULL,
83047 + .name = "__register_chrdev",
83048 + .file = "include/linux/fs.h",
83049 + .param2 = 1,
83050 + .param3 = 1,
83051 +};
83052 +
83053 +struct size_overflow_hash _000271_hash = {
83054 + .next = NULL,
83055 + .name = "request_key_auth_read",
83056 + .file = "security/keys/request_key_auth.c",
83057 + .param3 = 1,
83058 +};
83059 +
83060 +struct size_overflow_hash _000272_hash = {
83061 + .next = NULL,
83062 + .name = "shash_async_setkey",
83063 + .file = "crypto/shash.c",
83064 + .param3 = 1,
83065 +};
83066 +
83067 +struct size_overflow_hash _000273_hash = {
83068 + .next = NULL,
83069 + .name = "shash_compat_setkey",
83070 + .file = "crypto/shash.c",
83071 + .param3 = 1,
83072 +};
83073 +
83074 +struct size_overflow_hash _000274_hash = {
83075 + .next = NULL,
83076 + .name = "simple_read_from_buffer",
83077 + .file = "include/linux/fs.h",
83078 + .param2 = 1,
83079 + .param5 = 1,
83080 +};
83081 +
83082 +struct size_overflow_hash _000276_hash = {
83083 + .next = NULL,
83084 + .name = "store_ifalias",
83085 + .file = "net/core/net-sysfs.c",
83086 + .param4 = 1,
83087 +};
83088 +
83089 +struct size_overflow_hash _000277_hash = {
83090 + .next = NULL,
83091 + .name = "subbuf_read_actor",
83092 + .file = "kernel/relay.c",
83093 + .param3 = 1,
83094 +};
83095 +
83096 +struct size_overflow_hash _000278_hash = {
83097 + .next = NULL,
83098 + .name = "sys_fgetxattr",
83099 + .file = "include/linux/syscalls.h",
83100 + .param4 = 1,
83101 +};
83102 +
83103 +struct size_overflow_hash _000279_hash = {
83104 + .next = NULL,
83105 + .name = "sys_getxattr",
83106 + .file = "include/linux/syscalls.h",
83107 + .param4 = 1,
83108 +};
83109 +
83110 +struct size_overflow_hash _000280_hash = {
83111 + .next = NULL,
83112 + .name = "sys_kexec_load",
83113 + .file = "include/linux/syscalls.h",
83114 + .param2 = 1,
83115 +};
83116 +
83117 +struct size_overflow_hash _000281_hash = {
83118 + .next = NULL,
83119 + .name = "sys_lgetxattr",
83120 + .file = "include/linux/syscalls.h",
83121 + .param4 = 1,
83122 +};
83123 +
83124 +struct size_overflow_hash _000282_hash = {
83125 + .next = NULL,
83126 + .name = "sys_process_vm_readv",
83127 + .file = "include/linux/syscalls.h",
83128 + .param3 = 1,
83129 + .param5 = 1,
83130 +};
83131 +
83132 +struct size_overflow_hash _000284_hash = {
83133 + .next = NULL,
83134 + .name = "sys_process_vm_writev",
83135 + .file = "include/linux/syscalls.h",
83136 + .param3 = 1,
83137 + .param5 = 1,
83138 +};
83139 +
83140 +struct size_overflow_hash _000286_hash = {
83141 + .next = NULL,
83142 + .name = "sys_sched_getaffinity",
83143 + .file = "include/linux/syscalls.h",
83144 + .param2 = 1,
83145 +};
83146 +
83147 +struct size_overflow_hash _000287_hash = {
83148 + .next = NULL,
83149 + .name = "tomoyo_read_self",
83150 + .file = "security/tomoyo/securityfs_if.c",
83151 + .param3 = 1,
83152 +};
83153 +
83154 +struct size_overflow_hash _000288_hash = {
83155 + .next = NULL,
83156 + .name = "tpm_read",
83157 + .file = "drivers/char/tpm/tpm.c",
83158 + .param3 = 1,
83159 +};
83160 +
83161 +struct size_overflow_hash _000289_hash = {
83162 + .next = NULL,
83163 + .name = "user_read",
83164 + .file = "include/keys/user-type.h",
83165 + .param3 = 1,
83166 +};
83167 +
83168 +struct size_overflow_hash _000290_hash = {
83169 + .next = NULL,
83170 + .name = "vcs_read",
83171 + .file = "drivers/tty/vt/vc_screen.c",
83172 + .param3 = 1,
83173 +};
83174 +
83175 +struct size_overflow_hash _000291_hash = {
83176 + .next = NULL,
83177 + .name = "vfs_readv",
83178 + .file = "include/linux/fs.h",
83179 + .param3 = 1,
83180 +};
83181 +
83182 +struct size_overflow_hash _000292_hash = {
83183 + .next = NULL,
83184 + .name = "vfs_writev",
83185 + .file = "include/linux/fs.h",
83186 + .param3 = 1,
83187 +};
83188 +
83189 +struct size_overflow_hash _000293_hash = {
83190 + .next = NULL,
83191 + .name = "vga_arb_read",
83192 + .file = "drivers/gpu/vga/vgaarb.c",
83193 + .param3 = 1,
83194 +};
83195 +
83196 +struct size_overflow_hash _000294_hash = {
83197 + .next = NULL,
83198 + .name = "xz_dec_lzma2_create",
83199 + .file = "lib/xz/xz_dec_lzma2.c",
83200 + .param2 = 1,
83201 +};
83202 +
83203 +struct size_overflow_hash _000295_hash = {
83204 + .next = NULL,
83205 + .name = "aat2870_reg_read_file",
83206 + .file = "drivers/mfd/aat2870-core.c",
83207 + .param3 = 1,
83208 +};
83209 +
83210 +struct size_overflow_hash _000296_hash = {
83211 + .next = NULL,
83212 + .name = "__alloc_bootmem",
83213 + .file = "include/linux/bootmem.h",
83214 + .param1 = 1,
83215 +};
83216 +
83217 +struct size_overflow_hash _000297_hash = {
83218 + .next = NULL,
83219 + .name = "__alloc_bootmem_low",
83220 + .file = "include/linux/bootmem.h",
83221 + .param1 = 1,
83222 +};
83223 +
83224 +struct size_overflow_hash _000298_hash = {
83225 + .next = NULL,
83226 + .name = "__alloc_bootmem_node_nopanic",
83227 + .file = "include/linux/bootmem.h",
83228 + .param2 = 1,
83229 +};
83230 +
83231 +struct size_overflow_hash _000299_hash = {
83232 + .next = NULL,
83233 + .name = "blk_rq_map_kern",
83234 + .file = "include/linux/blkdev.h",
83235 + .param4 = 1,
83236 +};
83237 +
83238 +struct size_overflow_hash _000300_hash = {
83239 + .next = NULL,
83240 + .name = "cgroup_read_s64",
83241 + .file = "kernel/cgroup.c",
83242 + .param5 = 1,
83243 +};
83244 +
83245 +struct size_overflow_hash _000301_hash = {
83246 + .next = NULL,
83247 + .name = "cgroup_read_u64",
83248 + .file = "kernel/cgroup.c",
83249 + .param5 = 1,
83250 +};
83251 +
83252 +struct size_overflow_hash _000302_hash = {
83253 + .next = NULL,
83254 + .name = "cpuset_common_file_read",
83255 + .file = "kernel/cpuset.c",
83256 + .param5 = 1,
83257 +};
83258 +
83259 +struct size_overflow_hash _000303_hash = {
83260 + .next = NULL,
83261 + .name = "filter_read",
83262 + .file = "lib/dma-debug.c",
83263 + .param3 = 1,
83264 +};
83265 +
83266 +struct size_overflow_hash _000304_hash = {
83267 + .next = NULL,
83268 + .name = "ima_show_htable_value",
83269 + .file = "security/integrity/ima/ima_fs.c",
83270 + .param2 = 1,
83271 +};
83272 +
83273 +struct size_overflow_hash _000305_hash = {
83274 + .next = NULL,
83275 + .name = "kernel_readv",
83276 + .file = "fs/splice.c",
83277 + .param3 = 1,
83278 +};
83279 +
83280 +struct size_overflow_hash _000306_hash = {
83281 + .next = NULL,
83282 + .name = "__kfifo_to_user",
83283 + .file = "include/linux/kfifo.h",
83284 + .param3 = 1,
83285 +};
83286 +
83287 +struct size_overflow_hash _000307_hash = {
83288 + .next = NULL,
83289 + .name = "__kfifo_to_user_r",
83290 + .file = "include/linux/kfifo.h",
83291 + .param3 = 1,
83292 +};
83293 +
83294 +struct size_overflow_hash _000308_hash = {
83295 + .next = NULL,
83296 + .name = "mqueue_read_file",
83297 + .file = "ipc/mqueue.c",
83298 + .param3 = 1,
83299 +};
83300 +
83301 +struct size_overflow_hash _000309_hash = {
83302 + .next = NULL,
83303 + .name = "oom_adjust_read",
83304 + .file = "fs/proc/base.c",
83305 + .param3 = 1,
83306 +};
83307 +
83308 +struct size_overflow_hash _000310_hash = {
83309 + .next = NULL,
83310 + .name = "oom_score_adj_read",
83311 + .file = "fs/proc/base.c",
83312 + .param3 = 1,
83313 +};
83314 +
83315 +struct size_overflow_hash _000311_hash = {
83316 + .next = NULL,
83317 + .name = "pm_qos_power_read",
83318 + .file = "kernel/power/qos.c",
83319 + .param3 = 1,
83320 +};
83321 +
83322 +struct size_overflow_hash _000312_hash = {
83323 + .next = NULL,
83324 + .name = "proc_coredump_filter_read",
83325 + .file = "fs/proc/base.c",
83326 + .param3 = 1,
83327 +};
83328 +
83329 +struct size_overflow_hash _000313_hash = {
83330 + .next = NULL,
83331 + .name = "proc_fdinfo_read",
83332 + .file = "fs/proc/base.c",
83333 + .param3 = 1,
83334 +};
83335 +
83336 +struct size_overflow_hash _000314_hash = {
83337 + .next = NULL,
83338 + .name = "proc_info_read",
83339 + .file = "fs/proc/base.c",
83340 + .param3 = 1,
83341 +};
83342 +
83343 +struct size_overflow_hash _000315_hash = {
83344 + .next = NULL,
83345 + .name = "proc_loginuid_read",
83346 + .file = "fs/proc/base.c",
83347 + .param3 = 1,
83348 +};
83349 +
83350 +struct size_overflow_hash _000316_hash = {
83351 + .next = NULL,
83352 + .name = "proc_pid_attr_read",
83353 + .file = "fs/proc/base.c",
83354 + .param3 = 1,
83355 +};
83356 +
83357 +struct size_overflow_hash _000317_hash = {
83358 + .next = NULL,
83359 + .name = "proc_sessionid_read",
83360 + .file = "fs/proc/base.c",
83361 + .param3 = 1,
83362 +};
83363 +
83364 +struct size_overflow_hash _000318_hash = {
83365 + .next = NULL,
83366 + .name = "pstore_file_read",
83367 + .file = "fs/pstore/inode.c",
83368 + .param3 = 1,
83369 +};
83370 +
83371 +struct size_overflow_hash _000319_hash = {
83372 + .next = NULL,
83373 + .name = "read_enabled_file_bool",
83374 + .file = "kernel/kprobes.c",
83375 + .param3 = 1,
83376 +};
83377 +
83378 +struct size_overflow_hash _000320_hash = {
83379 + .next = NULL,
83380 + .name = "read_file_blob",
83381 + .file = "fs/debugfs/file.c",
83382 + .param3 = 1,
83383 +};
83384 +
83385 +struct size_overflow_hash _000321_hash = {
83386 + .next = NULL,
83387 + .name = "read_file_bool",
83388 + .file = "fs/debugfs/file.c",
83389 + .param3 = 1,
83390 +};
83391 +
83392 +struct size_overflow_hash _000322_hash = {
83393 + .next = NULL,
83394 + .name = "read_from_oldmem",
83395 + .file = "fs/proc/vmcore.c",
83396 + .param2 = 1,
83397 +};
83398 +
83399 +struct size_overflow_hash _000323_hash = {
83400 + .next = NULL,
83401 + .name = "read_oldmem",
83402 + .file = "drivers/char/mem.c",
83403 + .param3 = 1,
83404 +};
83405 +
83406 +struct size_overflow_hash _000324_hash = {
83407 + .next = NULL,
83408 + .name = "res_counter_read",
83409 + .file = "include/linux/res_counter.h",
83410 + .param4 = 1,
83411 +};
83412 +
83413 +struct size_overflow_hash _000325_hash = {
83414 + .next = NULL,
83415 + .name = "sel_read_avc_cache_threshold",
83416 + .file = "security/selinux/selinuxfs.c",
83417 + .param3 = 1,
83418 +};
83419 +
83420 +struct size_overflow_hash _000326_hash = {
83421 + .next = NULL,
83422 + .name = "sel_read_avc_hash_stats",
83423 + .file = "security/selinux/selinuxfs.c",
83424 + .param3 = 1,
83425 +};
83426 +
83427 +struct size_overflow_hash _000327_hash = {
83428 + .next = NULL,
83429 + .name = "sel_read_bool",
83430 + .file = "security/selinux/selinuxfs.c",
83431 + .param3 = 1,
83432 +};
83433 +
83434 +struct size_overflow_hash _000328_hash = {
83435 + .next = NULL,
83436 + .name = "sel_read_checkreqprot",
83437 + .file = "security/selinux/selinuxfs.c",
83438 + .param3 = 1,
83439 +};
83440 +
83441 +struct size_overflow_hash _000329_hash = {
83442 + .next = NULL,
83443 + .name = "sel_read_class",
83444 + .file = "security/selinux/selinuxfs.c",
83445 + .param3 = 1,
83446 +};
83447 +
83448 +struct size_overflow_hash _000330_hash = {
83449 + .next = NULL,
83450 + .name = "sel_read_enforce",
83451 + .file = "security/selinux/selinuxfs.c",
83452 + .param3 = 1,
83453 +};
83454 +
83455 +struct size_overflow_hash _000331_hash = {
83456 + .next = NULL,
83457 + .name = "sel_read_handle_status",
83458 + .file = "security/selinux/selinuxfs.c",
83459 + .param3 = 1,
83460 +};
83461 +
83462 +struct size_overflow_hash _000332_hash = {
83463 + .next = NULL,
83464 + .name = "sel_read_handle_unknown",
83465 + .file = "security/selinux/selinuxfs.c",
83466 + .param3 = 1,
83467 +};
83468 +
83469 +struct size_overflow_hash _000333_hash = {
83470 + .next = NULL,
83471 + .name = "sel_read_initcon",
83472 + .file = "security/selinux/selinuxfs.c",
83473 + .param3 = 1,
83474 +};
83475 +
83476 +struct size_overflow_hash _000334_hash = {
83477 + .next = NULL,
83478 + .name = "sel_read_mls",
83479 + .file = "security/selinux/selinuxfs.c",
83480 + .param3 = 1,
83481 +};
83482 +
83483 +struct size_overflow_hash _000335_hash = {
83484 + .next = NULL,
83485 + .name = "sel_read_perm",
83486 + .file = "security/selinux/selinuxfs.c",
83487 + .param3 = 1,
83488 +};
83489 +
83490 +struct size_overflow_hash _000336_hash = {
83491 + .next = NULL,
83492 + .name = "sel_read_policy",
83493 + .file = "security/selinux/selinuxfs.c",
83494 + .param3 = 1,
83495 +};
83496 +
83497 +struct size_overflow_hash _000337_hash = {
83498 + .next = NULL,
83499 + .name = "sel_read_policycap",
83500 + .file = "security/selinux/selinuxfs.c",
83501 + .param3 = 1,
83502 +};
83503 +
83504 +struct size_overflow_hash _000338_hash = {
83505 + .next = NULL,
83506 + .name = "sel_read_policyvers",
83507 + .file = "security/selinux/selinuxfs.c",
83508 + .param3 = 1,
83509 +};
83510 +
83511 +struct size_overflow_hash _000339_hash = {
83512 + .next = NULL,
83513 + .name = "simple_attr_read",
83514 + .file = "include/linux/fs.h",
83515 + .param3 = 1,
83516 +};
83517 +
83518 +struct size_overflow_hash _000340_hash = {
83519 + .next = NULL,
83520 + .name = "simple_transaction_read",
83521 + .file = "include/linux/fs.h",
83522 + .param3 = 1,
83523 +};
83524 +
83525 +struct size_overflow_hash _000341_hash = {
83526 + .next = NULL,
83527 + .name = "smk_read_ambient",
83528 + .file = "security/smack/smackfs.c",
83529 + .param3 = 1,
83530 +};
83531 +
83532 +struct size_overflow_hash _000342_hash = {
83533 + .next = NULL,
83534 + .name = "smk_read_direct",
83535 + .file = "security/smack/smackfs.c",
83536 + .param3 = 1,
83537 +};
83538 +
83539 +struct size_overflow_hash _000343_hash = {
83540 + .next = NULL,
83541 + .name = "smk_read_doi",
83542 + .file = "security/smack/smackfs.c",
83543 + .param3 = 1,
83544 +};
83545 +
83546 +struct size_overflow_hash _000344_hash = {
83547 + .next = NULL,
83548 + .name = "smk_read_logging",
83549 + .file = "security/smack/smackfs.c",
83550 + .param3 = 1,
83551 +};
83552 +
83553 +struct size_overflow_hash _000345_hash = {
83554 + .next = NULL,
83555 + .name = "smk_read_onlycap",
83556 + .file = "security/smack/smackfs.c",
83557 + .param3 = 1,
83558 +};
83559 +
83560 +struct size_overflow_hash _000346_hash = {
83561 + .next = NULL,
83562 + .name = "snapshot_read",
83563 + .file = "kernel/power/user.c",
83564 + .param3 = 1,
83565 +};
83566 +
83567 +struct size_overflow_hash _000347_hash = {
83568 + .next = NULL,
83569 + .name = "supply_map_read_file",
83570 + .file = "drivers/regulator/core.c",
83571 + .param3 = 1,
83572 +};
83573 +
83574 +struct size_overflow_hash _000348_hash = {
83575 + .next = NULL,
83576 + .name = "sysfs_read_file",
83577 + .file = "fs/sysfs/file.c",
83578 + .param3 = 1,
83579 +};
83580 +
83581 +struct size_overflow_hash _000349_hash = {
83582 + .next = NULL,
83583 + .name = "sys_preadv",
83584 + .file = "include/linux/syscalls.h",
83585 + .param3 = 1,
83586 +};
83587 +
83588 +struct size_overflow_hash _000350_hash = {
83589 + .next = NULL,
83590 + .name = "sys_pwritev",
83591 + .file = "include/linux/syscalls.h",
83592 + .param3 = 1,
83593 +};
83594 +
83595 +struct size_overflow_hash _000351_hash = {
83596 + .next = NULL,
83597 + .name = "sys_readv",
83598 + .file = "include/linux/syscalls.h",
83599 + .param3 = 1,
83600 +};
83601 +
83602 +struct size_overflow_hash _000352_hash = {
83603 + .next = NULL,
83604 + .name = "sys_rt_sigpending",
83605 + .file = "include/linux/syscalls.h",
83606 + .param2 = 1,
83607 +};
83608 +
83609 +struct size_overflow_hash _000353_hash = {
83610 + .next = NULL,
83611 + .name = "sys_writev",
83612 + .file = "include/linux/syscalls.h",
83613 + .param3 = 1,
83614 +};
83615 +
83616 +struct size_overflow_hash _000354_hash = {
83617 + .next = NULL,
83618 + .name = "ima_show_htable_violations",
83619 + .file = "security/integrity/ima/ima_fs.c",
83620 + .param3 = 1,
83621 +};
83622 +
83623 +struct size_overflow_hash _000355_hash = {
83624 + .next = NULL,
83625 + .name = "ima_show_measurements_count",
83626 + .file = "security/integrity/ima/ima_fs.c",
83627 + .param3 = 1,
83628 +};
83629 +
83630 +struct size_overflow_hash _000356_hash = {
83631 + .next = NULL,
83632 + .name = "alloc_cpu_rmap",
83633 + .file = "include/linux/cpu_rmap.h",
83634 + .param1 = 1,
83635 +};
83636 +
83637 +struct size_overflow_hash _000357_hash = {
83638 + .next = NULL,
83639 + .name = "alloc_page_cgroup",
83640 + .file = "mm/page_cgroup.c",
83641 + .param1 = 1,
83642 +};
83643 +
83644 +struct size_overflow_hash _000358_hash = {
83645 + .next = NULL,
83646 + .name = "alloc_sched_domains",
83647 + .file = "include/linux/sched.h",
83648 + .param1 = 1,
83649 +};
83650 +
83651 +struct size_overflow_hash _000359_hash = {
83652 + .next = NULL,
83653 + .name = "compat_rw_copy_check_uvector",
83654 + .file = "include/linux/compat.h",
83655 + .param3 = 1,
83656 +};
83657 +
83658 +struct size_overflow_hash _000360_hash = {
83659 + .next = NULL,
83660 + .name = "compat_sys_kexec_load",
83661 + .file = "include/linux/kexec.h",
83662 + .param2 = 1,
83663 +};
83664 +
83665 +struct size_overflow_hash _000361_hash = {
83666 + .next = NULL,
83667 + .name = "compat_sys_semtimedop",
83668 + .file = "include/linux/compat.h",
83669 + .param3 = 1,
83670 +};
83671 +
83672 +struct size_overflow_hash _000362_hash = {
83673 + .next = NULL,
83674 + .name = "copy_from_user",
83675 + .file = "arch/x86/include/asm/uaccess_64.h",
83676 + .param3 = 1,
83677 +};
83678 +
83679 +struct size_overflow_hash _000363_hash = {
83680 + .next = NULL,
83681 + .name = "__copy_from_user",
83682 + .file = "arch/x86/include/asm/uaccess_64.h",
83683 + .param3 = 1,
83684 +};
83685 +
83686 +struct size_overflow_hash _000364_hash = {
83687 + .next = NULL,
83688 + .name = "__copy_from_user_inatomic",
83689 + .file = "arch/x86/include/asm/uaccess_64.h",
83690 + .param3 = 1,
83691 +};
83692 +
83693 +struct size_overflow_hash _000365_hash = {
83694 + .next = NULL,
83695 + .name = "__copy_from_user_nocache",
83696 + .file = "arch/x86/include/asm/uaccess_64.h",
83697 + .param3 = 1,
83698 +};
83699 +
83700 +struct size_overflow_hash _000366_hash = {
83701 + .next = NULL,
83702 + .name = "__copy_in_user",
83703 + .file = "arch/x86/include/asm/uaccess_64.h",
83704 + .param3 = 1,
83705 +};
83706 +
83707 +struct size_overflow_hash _000367_hash = {
83708 + .next = NULL,
83709 + .name = "copy_in_user",
83710 + .file = "arch/x86/include/asm/uaccess_64.h",
83711 + .param3 = 1,
83712 +};
83713 +
83714 +struct size_overflow_hash _000368_hash = {
83715 + .next = NULL,
83716 + .name = "__copy_to_user",
83717 + .file = "arch/x86/include/asm/uaccess_64.h",
83718 + .param3 = 1,
83719 +};
83720 +
83721 +struct size_overflow_hash _000369_hash = {
83722 + .next = NULL,
83723 + .name = "copy_to_user",
83724 + .file = "arch/x86/include/asm/uaccess_64.h",
83725 + .param3 = 1,
83726 +};
83727 +
83728 +struct size_overflow_hash _000370_hash = {
83729 + .next = NULL,
83730 + .name = "__copy_to_user_inatomic",
83731 + .file = "arch/x86/include/asm/uaccess_64.h",
83732 + .param3 = 1,
83733 +};
83734 +
83735 +struct size_overflow_hash _000371_hash = {
83736 + .next = NULL,
83737 + .name = "kmalloc_node",
83738 + .file = "include/linux/slub_def.h",
83739 + .param1 = 1,
83740 +};
83741 +
83742 +struct size_overflow_hash _000372_hash = {
83743 + .next = NULL,
83744 + .name = "pcpu_alloc_bootmem",
83745 + .file = "arch/x86/kernel/setup_percpu.c",
83746 + .param2 = 1,
83747 +};
83748 +
83749 +struct size_overflow_hash _000373_hash = {
83750 + .next = NULL,
83751 + .name = "sys32_rt_sigpending",
83752 + .file = "arch/x86/include/asm/sys_ia32.h",
83753 + .param2 = 1,
83754 +};
83755 +
83756 +struct size_overflow_hash _000374_hash = {
83757 + .next = NULL,
83758 + .name = "tunables_read",
83759 + .file = "arch/x86/platform/uv/tlb_uv.c",
83760 + .param3 = 1,
83761 +};
83762 +
83763 +struct size_overflow_hash _000375_hash = {
83764 + .next = NULL,
83765 + .name = "compat_do_readv_writev",
83766 + .file = "fs/compat.c",
83767 + .param4 = 1,
83768 +};
83769 +
83770 +struct size_overflow_hash _000376_hash = {
83771 + .next = NULL,
83772 + .name = "compat_keyctl_instantiate_key_iov",
83773 + .file = "security/keys/compat.c",
83774 + .param3 = 1,
83775 +};
83776 +
83777 +struct size_overflow_hash _000377_hash = {
83778 + .next = NULL,
83779 + .name = "compat_process_vm_rw",
83780 + .file = "mm/process_vm_access.c",
83781 + .param3 = 1,
83782 + .param5 = 1,
83783 +};
83784 +
83785 +struct size_overflow_hash _000379_hash = {
83786 + .next = NULL,
83787 + .name = "do_pages_stat",
83788 + .file = "mm/migrate.c",
83789 + .param2 = 1,
83790 +};
83791 +
83792 +struct size_overflow_hash _000380_hash = {
83793 + .next = NULL,
83794 + .name = "kzalloc_node",
83795 + .file = "include/linux/slab.h",
83796 + .param1 = 1,
83797 +};
83798 +
83799 +struct size_overflow_hash _000381_hash = {
83800 + .next = NULL,
83801 + .name = "pcpu_fc_alloc",
83802 + .file = "arch/x86/kernel/setup_percpu.c",
83803 + .param2 = 1,
83804 +};
83805 +
83806 +struct size_overflow_hash _000382_hash = {
83807 + .next = NULL,
83808 + .name = "ptc_proc_write",
83809 + .file = "arch/x86/platform/uv/tlb_uv.c",
83810 + .param3 = 1,
83811 +};
83812 +
83813 +struct size_overflow_hash _000383_hash = {
83814 + .next = NULL,
83815 + .name = "tunables_write",
83816 + .file = "arch/x86/platform/uv/tlb_uv.c",
83817 + .param3 = 1,
83818 +};
83819 +
83820 +struct size_overflow_hash _000384_hash = {
83821 + .next = NULL,
83822 + .name = "__alloc_bootmem_low_node",
83823 + .file = "include/linux/bootmem.h",
83824 + .param2 = 1,
83825 +};
83826 +
83827 +struct size_overflow_hash _000385_hash = {
83828 + .next = NULL,
83829 + .name = "__alloc_bootmem_node",
83830 + .file = "include/linux/bootmem.h",
83831 + .param2 = 1,
83832 +};
83833 +
83834 +struct size_overflow_hash _000386_hash = {
83835 + .next = NULL,
83836 + .name = "compat_readv",
83837 + .file = "fs/compat.c",
83838 + .param3 = 1,
83839 +};
83840 +
83841 +struct size_overflow_hash _000387_hash = {
83842 + .next = NULL,
83843 + .name = "compat_sys_keyctl",
83844 + .file = "include/linux/compat.h",
83845 + .param4 = 1,
83846 +};
83847 +
83848 +struct size_overflow_hash _000388_hash = {
83849 + .next = NULL,
83850 + .name = "compat_sys_process_vm_readv",
83851 + .file = "include/linux/compat.h",
83852 + .param3 = 1,
83853 + .param5 = 1,
83854 +};
83855 +
83856 +struct size_overflow_hash _000390_hash = {
83857 + .next = NULL,
83858 + .name = "compat_sys_process_vm_writev",
83859 + .file = "include/linux/compat.h",
83860 + .param3 = 1,
83861 + .param5 = 1,
83862 +};
83863 +
83864 +struct size_overflow_hash _000392_hash = {
83865 + .next = NULL,
83866 + .name = "compat_writev",
83867 + .file = "fs/compat.c",
83868 + .param3 = 1,
83869 +};
83870 +
83871 +struct size_overflow_hash _000393_hash = {
83872 + .next = NULL,
83873 + .name = "sys_move_pages",
83874 + .file = "include/linux/syscalls.h",
83875 + .param2 = 1,
83876 +};
83877 +
83878 +struct size_overflow_hash _000394_hash = {
83879 + .next = NULL,
83880 + .name = "__alloc_bootmem_node_high",
83881 + .file = "include/linux/bootmem.h",
83882 + .param2 = 1,
83883 +};
83884 +
83885 +struct size_overflow_hash _000395_hash = {
83886 + .next = NULL,
83887 + .name = "compat_sys_move_pages",
83888 + .file = "include/linux/compat.h",
83889 + .param2 = 1,
83890 +};
83891 +
83892 +struct size_overflow_hash _000396_hash = {
83893 + .next = NULL,
83894 + .name = "compat_sys_preadv",
83895 + .file = "include/linux/compat.h",
83896 + .param3 = 1,
83897 +};
83898 +
83899 +struct size_overflow_hash _000397_hash = {
83900 + .next = NULL,
83901 + .name = "compat_sys_pwritev",
83902 + .file = "include/linux/compat.h",
83903 + .param3 = 1,
83904 +};
83905 +
83906 +struct size_overflow_hash _000398_hash = {
83907 + .next = NULL,
83908 + .name = "compat_sys_readv",
83909 + .file = "include/linux/compat.h",
83910 + .param3 = 1,
83911 +};
83912 +
83913 +struct size_overflow_hash _000399_hash = {
83914 + .next = NULL,
83915 + .name = "compat_sys_writev",
83916 + .file = "include/linux/compat.h",
83917 + .param3 = 1,
83918 +};
83919 +
83920 +struct size_overflow_hash _000400_hash = {
83921 + .next = NULL,
83922 + .name = "sparse_early_usemaps_alloc_node",
83923 + .file = "mm/sparse.c",
83924 + .param4 = 1,
83925 +};
83926 +
83927 +struct size_overflow_hash _000401_hash = {
83928 + .next = NULL,
83929 + .name = "__earlyonly_bootmem_alloc",
83930 + .file = "mm/sparse-vmemmap.c",
83931 + .param2 = 1,
83932 +};
83933 +
83934 +struct size_overflow_hash _000402_hash = {
83935 + .next = NULL,
83936 + .name = "sparse_mem_maps_populate_node",
83937 + .file = "include/linux/mm.h",
83938 + .param4 = 1,
83939 +};
83940 +
83941 +struct size_overflow_hash _000403_hash = {
83942 + .next = NULL,
83943 + .name = "vmemmap_alloc_block",
83944 + .file = "include/linux/mm.h",
83945 + .param1 = 1,
83946 +};
83947 +
83948 +struct size_overflow_hash _000404_hash = {
83949 + .next = NULL,
83950 + .name = "sparse_early_mem_maps_alloc_node",
83951 + .file = "mm/sparse.c",
83952 + .param4 = 1,
83953 +};
83954 +
83955 +struct size_overflow_hash _000405_hash = {
83956 + .next = NULL,
83957 + .name = "vmemmap_alloc_block_buf",
83958 + .file = "include/linux/mm.h",
83959 + .param1 = 1,
83960 +};
83961 +
83962 +struct size_overflow_hash _000406_hash = {
83963 + .next = NULL,
83964 + .name = "acpi_battery_write_alarm",
83965 + .file = "drivers/acpi/battery.c",
83966 + .param3 = 1,
83967 +};
83968 +
83969 +struct size_overflow_hash _000407_hash = {
83970 + .next = NULL,
83971 + .name = "acpi_battery_write_alarm",
83972 + .file = "drivers/acpi/sbs.c",
83973 + .param3 = 1,
83974 +};
83975 +
83976 +struct size_overflow_hash _000408_hash = {
83977 + .next = NULL,
83978 + .name = "ad7879_spi_xfer",
83979 + .file = "drivers/input/touchscreen/ad7879-spi.c",
83980 + .param3 = 1,
83981 +};
83982 +
83983 +struct size_overflow_hash _000409_hash = {
83984 + .next = NULL,
83985 + .name = "add_port",
83986 + .file = "drivers/char/virtio_console.c",
83987 + .param2 = 1,
83988 +};
83989 +
83990 +struct size_overflow_hash _000410_hash = {
83991 + .next = NULL,
83992 + .name = "addtgt",
83993 + .file = "drivers/block/aoe/aoecmd.c",
83994 + .param3 = 1,
83995 +};
83996 +
83997 +struct size_overflow_hash _000411_hash = {
83998 + .next = NULL,
83999 + .name = "adu_read",
84000 + .file = "drivers/usb/misc/adutux.c",
84001 + .param3 = 1,
84002 +};
84003 +
84004 +struct size_overflow_hash _000412_hash = {
84005 + .next = NULL,
84006 + .name = "adu_write",
84007 + .file = "drivers/usb/misc/adutux.c",
84008 + .param3 = 1,
84009 +};
84010 +
84011 +struct size_overflow_hash _000413_hash = {
84012 + .next = NULL,
84013 + .name = "aer_inject_write",
84014 + .file = "drivers/pci/pcie/aer/aer_inject.c",
84015 + .param3 = 1,
84016 +};
84017 +
84018 +struct size_overflow_hash _000414_hash = {
84019 + .next = NULL,
84020 + .name = "aes_decrypt_fail_read",
84021 + .file = "drivers/net/wireless/wl1251/debugfs.c",
84022 + .param3 = 1,
84023 +};
84024 +
84025 +struct size_overflow_hash _000415_hash = {
84026 + .next = NULL,
84027 + .name = "aes_decrypt_interrupt_read",
84028 + .file = "drivers/net/wireless/wl1251/debugfs.c",
84029 + .param3 = 1,
84030 +};
84031 +
84032 +struct size_overflow_hash _000416_hash = {
84033 + .next = NULL,
84034 + .name = "aes_decrypt_packets_read",
84035 + .file = "drivers/net/wireless/wl1251/debugfs.c",
84036 + .param3 = 1,
84037 +};
84038 +
84039 +struct size_overflow_hash _000417_hash = {
84040 + .next = NULL,
84041 + .name = "aes_encrypt_fail_read",
84042 + .file = "drivers/net/wireless/wl1251/debugfs.c",
84043 + .param3 = 1,
84044 +};
84045 +
84046 +struct size_overflow_hash _000418_hash = {
84047 + .next = NULL,
84048 + .name = "aes_encrypt_interrupt_read",
84049 + .file = "drivers/net/wireless/wl1251/debugfs.c",
84050 + .param3 = 1,
84051 +};
84052 +
84053 +struct size_overflow_hash _000419_hash = {
84054 + .next = NULL,
84055 + .name = "aes_encrypt_packets_read",
84056 + .file = "drivers/net/wireless/wl1251/debugfs.c",
84057 + .param3 = 1,
84058 +};
84059 +
84060 +struct size_overflow_hash _000420_hash = {
84061 + .next = NULL,
84062 + .name = "afs_alloc_flat_call",
84063 + .file = "fs/afs/rxrpc.c",
84064 + .param2 = 1,
84065 + .param3 = 1,
84066 +};
84067 +
84068 +struct size_overflow_hash _000422_hash = {
84069 + .next = NULL,
84070 + .name = "afs_cell_alloc",
84071 + .file = "fs/afs/cell.c",
84072 + .param2 = 1,
84073 +};
84074 +
84075 +struct size_overflow_hash _000423_hash = {
84076 + .next = NULL,
84077 + .name = "afs_proc_cells_write",
84078 + .file = "fs/afs/proc.c",
84079 + .param3 = 1,
84080 +};
84081 +
84082 +struct size_overflow_hash _000424_hash = {
84083 + .next = NULL,
84084 + .name = "afs_proc_rootcell_write",
84085 + .file = "fs/afs/proc.c",
84086 + .param3 = 1,
84087 +};
84088 +
84089 +struct size_overflow_hash _000425_hash = {
84090 + .next = NULL,
84091 + .name = "aggr_recv_addba_req_evt",
84092 + .file = "drivers/net/wireless/ath/ath6kl/txrx.c",
84093 + .param4 = 1,
84094 +};
84095 +
84096 +struct size_overflow_hash _000426_hash = {
84097 + .next = NULL,
84098 + .name = "agp_3_5_isochronous_node_enable",
84099 + .file = "drivers/char/agp/isoch.c",
84100 + .param3 = 1,
84101 +};
84102 +
84103 +struct size_overflow_hash _000427_hash = {
84104 + .next = NULL,
84105 + .name = "agp_alloc_page_array",
84106 + .file = "drivers/char/agp/generic.c",
84107 + .param1 = 1,
84108 +};
84109 +
84110 +struct size_overflow_hash _000428_hash = {
84111 + .next = NULL,
84112 + .name = "alg_setkey",
84113 + .file = "crypto/af_alg.c",
84114 + .param3 = 1,
84115 +};
84116 +
84117 +struct size_overflow_hash _000429_hash = {
84118 + .next = NULL,
84119 + .name = "alloc_buf",
84120 + .file = "drivers/char/virtio_console.c",
84121 + .param1 = 1,
84122 +};
84123 +
84124 +struct size_overflow_hash _000430_hash = {
84125 + .next = NULL,
84126 + .name = "alloc_context",
84127 + .file = "drivers/md/dm-raid1.c",
84128 + .param1 = 1,
84129 +};
84130 +
84131 +struct size_overflow_hash _000431_hash = {
84132 + .next = NULL,
84133 + .name = "alloc_context",
84134 + .file = "drivers/md/dm-stripe.c",
84135 + .param1 = 1,
84136 +};
84137 +
84138 +struct size_overflow_hash _000432_hash = {
84139 + .next = NULL,
84140 + .name = "__alloc_dev_table",
84141 + .file = "fs/exofs/super.c",
84142 + .param2 = 1,
84143 +};
84144 +
84145 +struct size_overflow_hash _000433_hash = {
84146 + .next = NULL,
84147 + .name = "alloc_ep_req",
84148 + .file = "drivers/usb/gadget/f_midi.c",
84149 + .param2 = 1,
84150 +};
84151 +
84152 +struct size_overflow_hash _000434_hash = {
84153 + .next = NULL,
84154 + .name = "alloc_flex_gd",
84155 + .file = "fs/ext4/resize.c",
84156 + .param1 = 1,
84157 +};
84158 +
84159 +struct size_overflow_hash _000435_hash = {
84160 + .next = NULL,
84161 + .name = "__alloc_objio_seg",
84162 + .file = "fs/nfs/objlayout/objio_osd.c",
84163 + .param1 = 1,
84164 +};
84165 +
84166 +struct size_overflow_hash _000436_hash = {
84167 + .next = NULL,
84168 + .name = "alloc_one_pg_vec_page",
84169 + .file = "net/packet/af_packet.c",
84170 + .param1 = 1,
84171 +};
84172 +
84173 +struct size_overflow_hash _000437_hash = {
84174 + .next = NULL,
84175 + .name = "alloc_ring",
84176 + .file = "drivers/net/ethernet/chelsio/cxgb3/sge.c",
84177 + .param2 = 1,
84178 + .param4 = 1,
84179 +};
84180 +
84181 +struct size_overflow_hash _000438_hash = {
84182 + .next = NULL,
84183 + .name = "alloc_ring",
84184 + .file = "drivers/net/ethernet/chelsio/cxgb4vf/sge.c",
84185 + .param2 = 1,
84186 + .param4 = 1,
84187 +};
84188 +
84189 +struct size_overflow_hash _000441_hash = {
84190 + .next = NULL,
84191 + .name = "alloc_ts_config",
84192 + .file = "include/linux/textsearch.h",
84193 + .param1 = 1,
84194 +};
84195 +
84196 +struct size_overflow_hash _000442_hash = {
84197 + .next = NULL,
84198 + .name = "altera_drscan",
84199 + .file = "drivers/misc/altera-stapl/altera-jtag.c",
84200 + .param2 = 1,
84201 +};
84202 +
84203 +struct size_overflow_hash _000443_hash = {
84204 + .next = NULL,
84205 + .name = "altera_irscan",
84206 + .file = "drivers/misc/altera-stapl/altera-jtag.c",
84207 + .param2 = 1,
84208 +};
84209 +
84210 +struct size_overflow_hash _000444_hash = {
84211 + .next = &_000066_hash,
84212 + .name = "altera_set_dr_post",
84213 + .file = "drivers/misc/altera-stapl/altera-jtag.c",
84214 + .param2 = 1,
84215 +};
84216 +
84217 +struct size_overflow_hash _000445_hash = {
84218 + .next = NULL,
84219 + .name = "altera_set_dr_pre",
84220 + .file = "drivers/misc/altera-stapl/altera-jtag.c",
84221 + .param2 = 1,
84222 +};
84223 +
84224 +struct size_overflow_hash _000446_hash = {
84225 + .next = NULL,
84226 + .name = "altera_set_ir_post",
84227 + .file = "drivers/misc/altera-stapl/altera-jtag.c",
84228 + .param2 = 1,
84229 +};
84230 +
84231 +struct size_overflow_hash _000447_hash = {
84232 + .next = NULL,
84233 + .name = "altera_set_ir_pre",
84234 + .file = "drivers/misc/altera-stapl/altera-jtag.c",
84235 + .param2 = 1,
84236 +};
84237 +
84238 +struct size_overflow_hash _000448_hash = {
84239 + .next = NULL,
84240 + .name = "altera_swap_dr",
84241 + .file = "drivers/misc/altera-stapl/altera-jtag.c",
84242 + .param2 = 1,
84243 +};
84244 +
84245 +struct size_overflow_hash _000449_hash = {
84246 + .next = NULL,
84247 + .name = "altera_swap_ir",
84248 + .file = "drivers/misc/altera-stapl/altera-jtag.c",
84249 + .param2 = 1,
84250 +};
84251 +
84252 +struct size_overflow_hash _000450_hash = {
84253 + .next = NULL,
84254 + .name = "aoedev_flush",
84255 + .file = "drivers/block/aoe/aoedev.c",
84256 + .param2 = 1,
84257 +};
84258 +
84259 +struct size_overflow_hash _000451_hash = {
84260 + .next = NULL,
84261 + .name = "asd_store_update_bios",
84262 + .file = "drivers/scsi/aic94xx/aic94xx_init.c",
84263 + .param4 = 1,
84264 +};
84265 +
84266 +struct size_overflow_hash _000452_hash = {
84267 + .next = NULL,
84268 + .name = "asix_read_cmd",
84269 + .file = "drivers/net/usb/asix.c",
84270 + .param5 = 1,
84271 +};
84272 +
84273 +struct size_overflow_hash _000453_hash = {
84274 + .next = NULL,
84275 + .name = "asix_write_cmd",
84276 + .file = "drivers/net/usb/asix.c",
84277 + .param5 = 1,
84278 +};
84279 +
84280 +struct size_overflow_hash _000454_hash = {
84281 + .next = NULL,
84282 + .name = "asn1_octets_decode",
84283 + .file = "net/ipv4/netfilter/nf_nat_snmp_basic.c",
84284 + .param2 = 1,
84285 +};
84286 +
84287 +struct size_overflow_hash _000455_hash = {
84288 + .next = NULL,
84289 + .name = "asn1_oid_decode",
84290 + .file = "net/ipv4/netfilter/nf_nat_snmp_basic.c",
84291 + .param2 = 1,
84292 +};
84293 +
84294 +struct size_overflow_hash _000456_hash = {
84295 + .next = NULL,
84296 + .name = "asn1_oid_decode",
84297 + .file = "fs/cifs/asn1.c",
84298 + .param2 = 1,
84299 +};
84300 +
84301 +struct size_overflow_hash _000457_hash = {
84302 + .next = NULL,
84303 + .name = "ath6kl_add_bss_if_needed",
84304 + .file = "drivers/net/wireless/ath/ath6kl/cfg80211.c",
84305 + .param6 = 1,
84306 +};
84307 +
84308 +struct size_overflow_hash _000458_hash = {
84309 + .next = NULL,
84310 + .name = "ath6kl_debug_roam_tbl_event",
84311 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
84312 + .param3 = 1,
84313 +};
84314 +
84315 +struct size_overflow_hash _000459_hash = {
84316 + .next = NULL,
84317 + .name = "ath6kl_disconnect_timeout_read",
84318 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
84319 + .param3 = 1,
84320 +};
84321 +
84322 +struct size_overflow_hash _000460_hash = {
84323 + .next = NULL,
84324 + .name = "ath6kl_endpoint_stats_read",
84325 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
84326 + .param3 = 1,
84327 +};
84328 +
84329 +struct size_overflow_hash _000461_hash = {
84330 + .next = NULL,
84331 + .name = "ath6kl_fwlog_mask_read",
84332 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
84333 + .param3 = 1,
84334 +};
84335 +
84336 +struct size_overflow_hash _000462_hash = {
84337 + .next = NULL,
84338 + .name = "ath6kl_fwlog_read",
84339 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
84340 + .param3 = 1,
84341 +};
84342 +
84343 +struct size_overflow_hash _000463_hash = {
84344 + .next = NULL,
84345 + .name = "ath6kl_keepalive_read",
84346 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
84347 + .param3 = 1,
84348 +};
84349 +
84350 +struct size_overflow_hash _000464_hash = {
84351 + .next = NULL,
84352 + .name = "ath6kl_lrssi_roam_read",
84353 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
84354 + .param3 = 1,
84355 +};
84356 +
84357 +struct size_overflow_hash _000465_hash = {
84358 + .next = NULL,
84359 + .name = "ath6kl_regdump_read",
84360 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
84361 + .param3 = 1,
84362 +};
84363 +
84364 +struct size_overflow_hash _000466_hash = {
84365 + .next = NULL,
84366 + .name = "ath6kl_regread_read",
84367 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
84368 + .param3 = 1,
84369 +};
84370 +
84371 +struct size_overflow_hash _000467_hash = {
84372 + .next = NULL,
84373 + .name = "ath6kl_regwrite_read",
84374 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
84375 + .param3 = 1,
84376 +};
84377 +
84378 +struct size_overflow_hash _000468_hash = {
84379 + .next = NULL,
84380 + .name = "ath6kl_roam_table_read",
84381 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
84382 + .param3 = 1,
84383 +};
84384 +
84385 +struct size_overflow_hash _000469_hash = {
84386 + .next = NULL,
84387 + .name = "ath6kl_send_go_probe_resp",
84388 + .file = "drivers/net/wireless/ath/ath6kl/cfg80211.c",
84389 + .param3 = 1,
84390 +};
84391 +
84392 +struct size_overflow_hash _000470_hash = {
84393 + .next = NULL,
84394 + .name = "ath6kl_set_ap_probe_resp_ies",
84395 + .file = "drivers/net/wireless/ath/ath6kl/cfg80211.c",
84396 + .param3 = 1,
84397 +};
84398 +
84399 +struct size_overflow_hash _000471_hash = {
84400 + .next = NULL,
84401 + .name = "ath6kl_set_assoc_req_ies",
84402 + .file = "drivers/net/wireless/ath/ath6kl/cfg80211.c",
84403 + .param3 = 1,
84404 +};
84405 +
84406 +struct size_overflow_hash _000472_hash = {
84407 + .next = NULL,
84408 + .name = "ath6kl_tm_rx_report_event",
84409 + .file = "drivers/net/wireless/ath/ath6kl/testmode.c",
84410 + .param3 = 1,
84411 +};
84412 +
84413 +struct size_overflow_hash _000473_hash = {
84414 + .next = NULL,
84415 + .name = "ath6kl_wmi_send_action_cmd",
84416 + .file = "drivers/net/wireless/ath/ath6kl/wmi.c",
84417 + .param7 = 1,
84418 +};
84419 +
84420 +struct size_overflow_hash _000474_hash = {
84421 + .next = NULL,
84422 + .name = "ath6kl_wmi_send_mgmt_cmd",
84423 + .file = "drivers/net/wireless/ath/ath6kl/wmi.c",
84424 + .param7 = 1,
84425 +};
84426 +
84427 +struct size_overflow_hash _000475_hash = {
84428 + .next = NULL,
84429 + .name = "ath9k_debugfs_read_buf",
84430 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
84431 + .param3 = 1,
84432 +};
84433 +
84434 +struct size_overflow_hash _000476_hash = {
84435 + .next = NULL,
84436 + .name = "atk_debugfs_ggrp_read",
84437 + .file = "drivers/hwmon/asus_atk0110.c",
84438 + .param3 = 1,
84439 +};
84440 +
84441 +struct size_overflow_hash _000477_hash = {
84442 + .next = NULL,
84443 + .name = "atm_get_addr",
84444 + .file = "net/atm/addr.c",
84445 + .param3 = 1,
84446 +};
84447 +
84448 +struct size_overflow_hash _000478_hash = {
84449 + .next = NULL,
84450 + .name = "attach_hdlc_protocol",
84451 + .file = "include/linux/hdlc.h",
84452 + .param3 = 1,
84453 +};
84454 +
84455 +struct size_overflow_hash _000479_hash = {
84456 + .next = NULL,
84457 + .name = "av7110_vbi_write",
84458 + .file = "drivers/media/dvb/ttpci/av7110_v4l.c",
84459 + .param3 = 1,
84460 +};
84461 +
84462 +struct size_overflow_hash _000480_hash = {
84463 + .next = NULL,
84464 + .name = "ax25_setsockopt",
84465 + .file = "net/ax25/af_ax25.c",
84466 + .param5 = 1,
84467 +};
84468 +
84469 +struct size_overflow_hash _000481_hash = {
84470 + .next = NULL,
84471 + .name = "b43_debugfs_read",
84472 + .file = "drivers/net/wireless/b43/debugfs.c",
84473 + .param3 = 1,
84474 +};
84475 +
84476 +struct size_overflow_hash _000482_hash = {
84477 + .next = NULL,
84478 + .name = "b43_debugfs_write",
84479 + .file = "drivers/net/wireless/b43/debugfs.c",
84480 + .param3 = 1,
84481 +};
84482 +
84483 +struct size_overflow_hash _000483_hash = {
84484 + .next = NULL,
84485 + .name = "b43legacy_debugfs_read",
84486 + .file = "drivers/net/wireless/b43legacy/debugfs.c",
84487 + .param3 = 1,
84488 +};
84489 +
84490 +struct size_overflow_hash _000484_hash = {
84491 + .next = NULL,
84492 + .name = "b43legacy_debugfs_write",
84493 + .file = "drivers/net/wireless/b43legacy/debugfs.c",
84494 + .param3 = 1,
84495 +};
84496 +
84497 +struct size_overflow_hash _000485_hash = {
84498 + .next = NULL,
84499 + .name = "b43_nphy_load_samples",
84500 + .file = "drivers/net/wireless/b43/phy_n.c",
84501 + .param3 = 1,
84502 +};
84503 +
84504 +struct size_overflow_hash _000486_hash = {
84505 + .next = NULL,
84506 + .name = "bch_alloc",
84507 + .file = "lib/bch.c",
84508 + .param1 = 1,
84509 +};
84510 +
84511 +struct size_overflow_hash _000487_hash = {
84512 + .next = NULL,
84513 + .name = "bfad_debugfs_read",
84514 + .file = "drivers/scsi/bfa/bfad_debugfs.c",
84515 + .param3 = 1,
84516 +};
84517 +
84518 +struct size_overflow_hash _000488_hash = {
84519 + .next = NULL,
84520 + .name = "bfad_debugfs_read_regrd",
84521 + .file = "drivers/scsi/bfa/bfad_debugfs.c",
84522 + .param3 = 1,
84523 +};
84524 +
84525 +struct size_overflow_hash _000489_hash = {
84526 + .next = NULL,
84527 + .name = "bfad_debugfs_write_regrd",
84528 + .file = "drivers/scsi/bfa/bfad_debugfs.c",
84529 + .param3 = 1,
84530 +};
84531 +
84532 +struct size_overflow_hash _000490_hash = {
84533 + .next = NULL,
84534 + .name = "bfad_debugfs_write_regwr",
84535 + .file = "drivers/scsi/bfa/bfad_debugfs.c",
84536 + .param3 = 1,
84537 +};
84538 +
84539 +struct size_overflow_hash _000491_hash = {
84540 + .next = NULL,
84541 + .name = "bits_to_user",
84542 + .file = "drivers/input/evdev.c",
84543 + .param3 = 1,
84544 +};
84545 +
84546 +struct size_overflow_hash _000492_hash = {
84547 + .next = NULL,
84548 + .name = "bl_pipe_downcall",
84549 + .file = "fs/nfs/blocklayout/blocklayoutdev.c",
84550 + .param3 = 1,
84551 +};
84552 +
84553 +struct size_overflow_hash _000493_hash = {
84554 + .next = NULL,
84555 + .name = "bm_entry_read",
84556 + .file = "fs/binfmt_misc.c",
84557 + .param3 = 1,
84558 +};
84559 +
84560 +struct size_overflow_hash _000494_hash = {
84561 + .next = NULL,
84562 + .name = "bm_realloc_pages",
84563 + .file = "drivers/block/drbd/drbd_bitmap.c",
84564 + .param2 = 1,
84565 +};
84566 +
84567 +struct size_overflow_hash _000495_hash = {
84568 + .next = NULL,
84569 + .name = "bm_status_read",
84570 + .file = "fs/binfmt_misc.c",
84571 + .param3 = 1,
84572 +};
84573 +
84574 +struct size_overflow_hash _000496_hash = {
84575 + .next = NULL,
84576 + .name = "bnad_debugfs_read",
84577 + .file = "drivers/net/ethernet/brocade/bna/bnad_debugfs.c",
84578 + .param3 = 1,
84579 +};
84580 +
84581 +struct size_overflow_hash _000497_hash = {
84582 + .next = NULL,
84583 + .name = "bnad_debugfs_read_regrd",
84584 + .file = "drivers/net/ethernet/brocade/bna/bnad_debugfs.c",
84585 + .param3 = 1,
84586 +};
84587 +
84588 +struct size_overflow_hash _000498_hash = {
84589 + .next = NULL,
84590 + .name = "bnad_debugfs_write_regrd",
84591 + .file = "drivers/net/ethernet/brocade/bna/bnad_debugfs.c",
84592 + .param3 = 1,
84593 +};
84594 +
84595 +struct size_overflow_hash _000499_hash = {
84596 + .next = NULL,
84597 + .name = "bnad_debugfs_write_regwr",
84598 + .file = "drivers/net/ethernet/brocade/bna/bnad_debugfs.c",
84599 + .param3 = 1,
84600 +};
84601 +
84602 +struct size_overflow_hash _000500_hash = {
84603 + .next = NULL,
84604 + .name = "bnx2fc_cmd_mgr_alloc",
84605 + .file = "drivers/scsi/bnx2fc/bnx2fc_io.c",
84606 + .param2 = 1,
84607 + .param3 = 1,
84608 +};
84609 +
84610 +struct size_overflow_hash _000502_hash = {
84611 + .next = NULL,
84612 + .name = "btmrvl_curpsmode_read",
84613 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84614 + .param3 = 1,
84615 +};
84616 +
84617 +struct size_overflow_hash _000503_hash = {
84618 + .next = NULL,
84619 + .name = "btmrvl_gpiogap_read",
84620 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84621 + .param3 = 1,
84622 +};
84623 +
84624 +struct size_overflow_hash _000504_hash = {
84625 + .next = NULL,
84626 + .name = "btmrvl_gpiogap_write",
84627 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84628 + .param3 = 1,
84629 +};
84630 +
84631 +struct size_overflow_hash _000505_hash = {
84632 + .next = NULL,
84633 + .name = "btmrvl_hscfgcmd_read",
84634 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84635 + .param3 = 1,
84636 +};
84637 +
84638 +struct size_overflow_hash _000506_hash = {
84639 + .next = NULL,
84640 + .name = "btmrvl_hscfgcmd_write",
84641 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84642 + .param3 = 1,
84643 +};
84644 +
84645 +struct size_overflow_hash _000507_hash = {
84646 + .next = &_000006_hash,
84647 + .name = "btmrvl_hscmd_read",
84648 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84649 + .param3 = 1,
84650 +};
84651 +
84652 +struct size_overflow_hash _000508_hash = {
84653 + .next = NULL,
84654 + .name = "btmrvl_hscmd_write",
84655 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84656 + .param3 = 1,
84657 +};
84658 +
84659 +struct size_overflow_hash _000509_hash = {
84660 + .next = NULL,
84661 + .name = "btmrvl_hsmode_read",
84662 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84663 + .param3 = 1,
84664 +};
84665 +
84666 +struct size_overflow_hash _000510_hash = {
84667 + .next = NULL,
84668 + .name = "btmrvl_hsmode_write",
84669 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84670 + .param3 = 1,
84671 +};
84672 +
84673 +struct size_overflow_hash _000511_hash = {
84674 + .next = NULL,
84675 + .name = "btmrvl_hsstate_read",
84676 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84677 + .param3 = 1,
84678 +};
84679 +
84680 +struct size_overflow_hash _000512_hash = {
84681 + .next = NULL,
84682 + .name = "btmrvl_pscmd_read",
84683 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84684 + .param3 = 1,
84685 +};
84686 +
84687 +struct size_overflow_hash _000513_hash = {
84688 + .next = NULL,
84689 + .name = "btmrvl_pscmd_write",
84690 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84691 + .param3 = 1,
84692 +};
84693 +
84694 +struct size_overflow_hash _000514_hash = {
84695 + .next = NULL,
84696 + .name = "btmrvl_psmode_read",
84697 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84698 + .param3 = 1,
84699 +};
84700 +
84701 +struct size_overflow_hash _000515_hash = {
84702 + .next = NULL,
84703 + .name = "btmrvl_psmode_write",
84704 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84705 + .param3 = 1,
84706 +};
84707 +
84708 +struct size_overflow_hash _000516_hash = {
84709 + .next = NULL,
84710 + .name = "btmrvl_psstate_read",
84711 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84712 + .param3 = 1,
84713 +};
84714 +
84715 +struct size_overflow_hash _000517_hash = {
84716 + .next = NULL,
84717 + .name = "btmrvl_txdnldready_read",
84718 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84719 + .param3 = 1,
84720 +};
84721 +
84722 +struct size_overflow_hash _000518_hash = {
84723 + .next = NULL,
84724 + .name = "btrfs_alloc_delayed_item",
84725 + .file = "fs/btrfs/delayed-inode.c",
84726 + .param1 = 1,
84727 +};
84728 +
84729 +struct size_overflow_hash _000519_hash = {
84730 + .next = NULL,
84731 + .name = "btrfs_copy_from_user",
84732 + .file = "fs/btrfs/file.c",
84733 + .param3 = 1,
84734 +};
84735 +
84736 +struct size_overflow_hash _000520_hash = {
84737 + .next = NULL,
84738 + .name = "__btrfs_map_block",
84739 + .file = "fs/btrfs/volumes.c",
84740 + .param3 = 1,
84741 +};
84742 +
84743 +struct size_overflow_hash _000521_hash = {
84744 + .next = NULL,
84745 + .name = "__c4iw_init_resource_fifo",
84746 + .file = "drivers/infiniband/hw/cxgb4/resource.c",
84747 + .param3 = 1,
84748 +};
84749 +
84750 +struct size_overflow_hash _000522_hash = {
84751 + .next = NULL,
84752 + .name = "cache_do_downcall",
84753 + .file = "net/sunrpc/cache.c",
84754 + .param3 = 1,
84755 +};
84756 +
84757 +struct size_overflow_hash _000523_hash = {
84758 + .next = NULL,
84759 + .name = "cachefiles_daemon_write",
84760 + .file = "fs/cachefiles/daemon.c",
84761 + .param3 = 1,
84762 +};
84763 +
84764 +struct size_overflow_hash _000524_hash = {
84765 + .next = NULL,
84766 + .name = "cache_read",
84767 + .file = "net/sunrpc/cache.c",
84768 + .param3 = 1,
84769 +};
84770 +
84771 +struct size_overflow_hash _000525_hash = {
84772 + .next = NULL,
84773 + .name = "ca_extend",
84774 + .file = "drivers/md/persistent-data/dm-space-map-checker.c",
84775 + .param2 = 1,
84776 +};
84777 +
84778 +struct size_overflow_hash _000526_hash = {
84779 + .next = NULL,
84780 + .name = "calc_hmac",
84781 + .file = "security/keys/encrypted-keys/encrypted.c",
84782 + .param3 = 1,
84783 +};
84784 +
84785 +struct size_overflow_hash _000527_hash = {
84786 + .next = NULL,
84787 + .name = "capi_write",
84788 + .file = "drivers/isdn/capi/capi.c",
84789 + .param3 = 1,
84790 +};
84791 +
84792 +struct size_overflow_hash _000528_hash = {
84793 + .next = NULL,
84794 + .name = "carl9170_cmd_buf",
84795 + .file = "drivers/net/wireless/ath/carl9170/cmd.c",
84796 + .param3 = 1,
84797 +};
84798 +
84799 +struct size_overflow_hash _000529_hash = {
84800 + .next = NULL,
84801 + .name = "carl9170_debugfs_read",
84802 + .file = "drivers/net/wireless/ath/carl9170/debug.c",
84803 + .param3 = 1,
84804 +};
84805 +
84806 +struct size_overflow_hash _000530_hash = {
84807 + .next = NULL,
84808 + .name = "carl9170_debugfs_write",
84809 + .file = "drivers/net/wireless/ath/carl9170/debug.c",
84810 + .param3 = 1,
84811 +};
84812 +
84813 +struct size_overflow_hash _000531_hash = {
84814 + .next = NULL,
84815 + .name = "cciss_proc_write",
84816 + .file = "drivers/block/cciss.c",
84817 + .param3 = 1,
84818 +};
84819 +
84820 +struct size_overflow_hash _000532_hash = {
84821 + .next = NULL,
84822 + .name = "ceph_buffer_new",
84823 + .file = "include/linux/ceph/buffer.h",
84824 + .param1 = 1,
84825 +};
84826 +
84827 +struct size_overflow_hash _000533_hash = {
84828 + .next = NULL,
84829 + .name = "ceph_copy_page_vector_to_user",
84830 + .file = "include/linux/ceph/libceph.h",
84831 + .param4 = 1,
84832 +};
84833 +
84834 +struct size_overflow_hash _000534_hash = {
84835 + .next = NULL,
84836 + .name = "ceph_copy_user_to_page_vector",
84837 + .file = "include/linux/ceph/libceph.h",
84838 + .param4 = 1,
84839 +};
84840 +
84841 +struct size_overflow_hash _000535_hash = {
84842 + .next = NULL,
84843 + .name = "ceph_read_dir",
84844 + .file = "fs/ceph/dir.c",
84845 + .param3 = 1,
84846 +};
84847 +
84848 +struct size_overflow_hash _000536_hash = {
84849 + .next = NULL,
84850 + .name = "ceph_setxattr",
84851 + .file = "fs/ceph/xattr.c",
84852 + .param4 = 1,
84853 +};
84854 +
84855 +struct size_overflow_hash _000537_hash = {
84856 + .next = NULL,
84857 + .name = "cfg80211_connect_result",
84858 + .file = "include/net/cfg80211.h",
84859 + .param4 = 1,
84860 + .param6 = 1,
84861 +};
84862 +
84863 +struct size_overflow_hash _000539_hash = {
84864 + .next = NULL,
84865 + .name = "cfg80211_disconnected",
84866 + .file = "include/net/cfg80211.h",
84867 + .param4 = 1,
84868 +};
84869 +
84870 +struct size_overflow_hash _000540_hash = {
84871 + .next = NULL,
84872 + .name = "cfg80211_inform_bss",
84873 + .file = "include/net/cfg80211.h",
84874 + .param8 = 1,
84875 +};
84876 +
84877 +struct size_overflow_hash _000541_hash = {
84878 + .next = NULL,
84879 + .name = "cfg80211_inform_bss_frame",
84880 + .file = "include/net/cfg80211.h",
84881 + .param4 = 1,
84882 +};
84883 +
84884 +struct size_overflow_hash _000542_hash = {
84885 + .next = NULL,
84886 + .name = "cfg80211_roamed_bss",
84887 + .file = "include/net/cfg80211.h",
84888 + .param4 = 1,
84889 + .param6 = 1,
84890 +};
84891 +
84892 +struct size_overflow_hash _000544_hash = {
84893 + .next = NULL,
84894 + .name = "cfi_read_pri",
84895 + .file = "include/linux/mtd/cfi.h",
84896 + .param3 = 1,
84897 +};
84898 +
84899 +struct size_overflow_hash _000545_hash = {
84900 + .next = NULL,
84901 + .name = "channel_type_read",
84902 + .file = "net/mac80211/debugfs.c",
84903 + .param3 = 1,
84904 +};
84905 +
84906 +struct size_overflow_hash _000546_hash = {
84907 + .next = NULL,
84908 + .name = "cifs_idmap_key_instantiate",
84909 + .file = "fs/cifs/cifsacl.c",
84910 + .param3 = 1,
84911 +};
84912 +
84913 +struct size_overflow_hash _000547_hash = {
84914 + .next = NULL,
84915 + .name = "cifs_readdata_alloc",
84916 + .file = "fs/cifs/cifssmb.c",
84917 + .param1 = 1,
84918 +};
84919 +
84920 +struct size_overflow_hash _000548_hash = {
84921 + .next = NULL,
84922 + .name = "cifs_security_flags_proc_write",
84923 + .file = "fs/cifs/cifs_debug.c",
84924 + .param3 = 1,
84925 +};
84926 +
84927 +struct size_overflow_hash _000549_hash = {
84928 + .next = NULL,
84929 + .name = "cifs_setxattr",
84930 + .file = "fs/cifs/xattr.c",
84931 + .param4 = 1,
84932 +};
84933 +
84934 +struct size_overflow_hash _000550_hash = {
84935 + .next = NULL,
84936 + .name = "cifs_spnego_key_instantiate",
84937 + .file = "fs/cifs/cifs_spnego.c",
84938 + .param3 = 1,
84939 +};
84940 +
84941 +struct size_overflow_hash _000551_hash = {
84942 + .next = NULL,
84943 + .name = "cifs_writedata_alloc",
84944 + .file = "fs/cifs/cifssmb.c",
84945 + .param1 = 1,
84946 +};
84947 +
84948 +struct size_overflow_hash _000552_hash = {
84949 + .next = NULL,
84950 + .name = "ci_ll_write",
84951 + .file = "drivers/media/dvb/ttpci/av7110_ca.c",
84952 + .param4 = 1,
84953 +};
84954 +
84955 +struct size_overflow_hash _000553_hash = {
84956 + .next = NULL,
84957 + .name = "clusterip_proc_write",
84958 + .file = "net/ipv4/netfilter/ipt_CLUSTERIP.c",
84959 + .param3 = 1,
84960 +};
84961 +
84962 +struct size_overflow_hash _000554_hash = {
84963 + .next = &_000108_hash,
84964 + .name = "cm4040_write",
84965 + .file = "drivers/char/pcmcia/cm4040_cs.c",
84966 + .param3 = 1,
84967 +};
84968 +
84969 +struct size_overflow_hash _000555_hash = {
84970 + .next = NULL,
84971 + .name = "cm_copy_private_data",
84972 + .file = "drivers/infiniband/core/cm.c",
84973 + .param2 = 1,
84974 +};
84975 +
84976 +struct size_overflow_hash _000556_hash = {
84977 + .next = NULL,
84978 + .name = "cmm_write",
84979 + .file = "drivers/char/pcmcia/cm4000_cs.c",
84980 + .param3 = 1,
84981 +};
84982 +
84983 +struct size_overflow_hash _000557_hash = {
84984 + .next = NULL,
84985 + .name = "cm_write",
84986 + .file = "drivers/acpi/custom_method.c",
84987 + .param3 = 1,
84988 +};
84989 +
84990 +struct size_overflow_hash _000558_hash = {
84991 + .next = NULL,
84992 + .name = "coda_psdev_read",
84993 + .file = "fs/coda/psdev.c",
84994 + .param3 = 1,
84995 +};
84996 +
84997 +struct size_overflow_hash _000559_hash = {
84998 + .next = NULL,
84999 + .name = "coda_psdev_write",
85000 + .file = "fs/coda/psdev.c",
85001 + .param3 = 1,
85002 +};
85003 +
85004 +struct size_overflow_hash _000560_hash = {
85005 + .next = NULL,
85006 + .name = "codec_list_read_file",
85007 + .file = "sound/soc/soc-core.c",
85008 + .param3 = 1,
85009 +};
85010 +
85011 +struct size_overflow_hash _000561_hash = {
85012 + .next = NULL,
85013 + .name = "codec_reg_read_file",
85014 + .file = "sound/soc/soc-core.c",
85015 + .param3 = 1,
85016 +};
85017 +
85018 +struct size_overflow_hash _000562_hash = {
85019 + .next = NULL,
85020 + .name = "command_file_write",
85021 + .file = "drivers/misc/ibmasm/ibmasmfs.c",
85022 + .param3 = 1,
85023 +};
85024 +
85025 +struct size_overflow_hash _000563_hash = {
85026 + .next = NULL,
85027 + .name = "command_write",
85028 + .file = "drivers/uwb/uwb-debug.c",
85029 + .param3 = 1,
85030 +};
85031 +
85032 +struct size_overflow_hash _000564_hash = {
85033 + .next = NULL,
85034 + .name = "concat_writev",
85035 + .file = "drivers/mtd/mtdconcat.c",
85036 + .param3 = 1,
85037 +};
85038 +
85039 +struct size_overflow_hash _000565_hash = {
85040 + .next = NULL,
85041 + .name = "configfs_read_file",
85042 + .file = "fs/configfs/file.c",
85043 + .param3 = 1,
85044 +};
85045 +
85046 +struct size_overflow_hash _000566_hash = {
85047 + .next = NULL,
85048 + .name = "context_alloc",
85049 + .file = "drivers/md/dm-raid.c",
85050 + .param3 = 1,
85051 +};
85052 +
85053 +struct size_overflow_hash _000567_hash = {
85054 + .next = NULL,
85055 + .name = "copy_counters_to_user",
85056 + .file = "net/bridge/netfilter/ebtables.c",
85057 + .param5 = 1,
85058 +};
85059 +
85060 +struct size_overflow_hash _000568_hash = {
85061 + .next = NULL,
85062 + .name = "copy_entries_to_user",
85063 + .file = "net/ipv6/netfilter/ip6_tables.c",
85064 + .param1 = 1,
85065 +};
85066 +
85067 +struct size_overflow_hash _000569_hash = {
85068 + .next = NULL,
85069 + .name = "copy_entries_to_user",
85070 + .file = "net/ipv4/netfilter/arp_tables.c",
85071 + .param1 = 1,
85072 +};
85073 +
85074 +struct size_overflow_hash _000570_hash = {
85075 + .next = NULL,
85076 + .name = "copy_entries_to_user",
85077 + .file = "net/ipv4/netfilter/ip_tables.c",
85078 + .param1 = 1,
85079 +};
85080 +
85081 +struct size_overflow_hash _000571_hash = {
85082 + .next = NULL,
85083 + .name = "copy_from_user_toio",
85084 + .file = "include/sound/core.h",
85085 + .param3 = 1,
85086 +};
85087 +
85088 +struct size_overflow_hash _000572_hash = {
85089 + .next = NULL,
85090 + .name = "copy_macs",
85091 + .file = "net/atm/mpc.c",
85092 + .param4 = 1,
85093 +};
85094 +
85095 +struct size_overflow_hash _000573_hash = {
85096 + .next = NULL,
85097 + .name = "copy_to_user_fromio",
85098 + .file = "include/sound/core.h",
85099 + .param3 = 1,
85100 +};
85101 +
85102 +struct size_overflow_hash _000574_hash = {
85103 + .next = NULL,
85104 + .name = "cosa_write",
85105 + .file = "drivers/net/wan/cosa.c",
85106 + .param3 = 1,
85107 +};
85108 +
85109 +struct size_overflow_hash _000575_hash = {
85110 + .next = NULL,
85111 + .name = "create_attr_set",
85112 + .file = "drivers/platform/x86/thinkpad_acpi.c",
85113 + .param1 = 1,
85114 +};
85115 +
85116 +struct size_overflow_hash _000576_hash = {
85117 + .next = NULL,
85118 + .name = "create_entry",
85119 + .file = "fs/binfmt_misc.c",
85120 + .param2 = 1,
85121 +};
85122 +
85123 +struct size_overflow_hash _000577_hash = {
85124 + .next = NULL,
85125 + .name = "create_gpadl_header",
85126 + .file = "drivers/hv/channel.c",
85127 + .param2 = 1,
85128 +};
85129 +
85130 +struct size_overflow_hash _000578_hash = {
85131 + .next = NULL,
85132 + .name = "create_queues",
85133 + .file = "drivers/atm/ambassador.c",
85134 + .param2 = 1,
85135 + .param3 = 1,
85136 +};
85137 +
85138 +struct size_overflow_hash _000580_hash = {
85139 + .next = NULL,
85140 + .name = "_create_sg_bios",
85141 + .file = "drivers/scsi/osd/osd_initiator.c",
85142 + .param4 = 1,
85143 +};
85144 +
85145 +struct size_overflow_hash _000581_hash = {
85146 + .next = NULL,
85147 + .name = "cryptd_alloc_instance",
85148 + .file = "crypto/cryptd.c",
85149 + .param2 = 1,
85150 + .param3 = 1,
85151 +};
85152 +
85153 +struct size_overflow_hash _000583_hash = {
85154 + .next = NULL,
85155 + .name = "cryptd_hash_setkey",
85156 + .file = "crypto/cryptd.c",
85157 + .param3 = 1,
85158 +};
85159 +
85160 +struct size_overflow_hash _000584_hash = {
85161 + .next = NULL,
85162 + .name = "crypto_authenc_esn_setkey",
85163 + .file = "crypto/authencesn.c",
85164 + .param3 = 1,
85165 +};
85166 +
85167 +struct size_overflow_hash _000585_hash = {
85168 + .next = NULL,
85169 + .name = "crypto_authenc_setkey",
85170 + .file = "crypto/authenc.c",
85171 + .param3 = 1,
85172 +};
85173 +
85174 +struct size_overflow_hash _000586_hash = {
85175 + .next = NULL,
85176 + .name = "ctrl_out",
85177 + .file = "drivers/usb/misc/usbtest.c",
85178 + .param3 = 1,
85179 + .param5 = 1,
85180 +};
85181 +
85182 +struct size_overflow_hash _000588_hash = {
85183 + .next = NULL,
85184 + .name = "cx18_copy_buf_to_user",
85185 + .file = "drivers/media/video/cx18/cx18-fileops.c",
85186 + .param4 = 1,
85187 +};
85188 +
85189 +struct size_overflow_hash _000589_hash = {
85190 + .next = NULL,
85191 + .name = "cx24116_writeregN",
85192 + .file = "drivers/media/dvb/frontends/cx24116.c",
85193 + .param4 = 1,
85194 +};
85195 +
85196 +struct size_overflow_hash _000590_hash = {
85197 + .next = NULL,
85198 + .name = "cxgb_alloc_mem",
85199 + .file = "drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c",
85200 + .param1 = 1,
85201 +};
85202 +
85203 +struct size_overflow_hash _000591_hash = {
85204 + .next = NULL,
85205 + .name = "cxgbi_alloc_big_mem",
85206 + .file = "drivers/scsi/cxgbi/libcxgbi.h",
85207 + .param1 = 1,
85208 +};
85209 +
85210 +struct size_overflow_hash _000592_hash = {
85211 + .next = NULL,
85212 + .name = "cxgbi_device_register",
85213 + .file = "drivers/scsi/cxgbi/libcxgbi.c",
85214 + .param1 = 1,
85215 + .param2 = 1,
85216 +};
85217 +
85218 +struct size_overflow_hash _000594_hash = {
85219 + .next = NULL,
85220 + .name = "__cxio_init_resource_fifo",
85221 + .file = "drivers/infiniband/hw/cxgb3/cxio_resource.c",
85222 + .param3 = 1,
85223 +};
85224 +
85225 +struct size_overflow_hash _000595_hash = {
85226 + .next = NULL,
85227 + .name = "dac960_user_command_proc_write",
85228 + .file = "drivers/block/DAC960.c",
85229 + .param3 = 1,
85230 +};
85231 +
85232 +struct size_overflow_hash _000596_hash = {
85233 + .next = NULL,
85234 + .name = "dai_list_read_file",
85235 + .file = "sound/soc/soc-core.c",
85236 + .param3 = 1,
85237 +};
85238 +
85239 +struct size_overflow_hash _000597_hash = {
85240 + .next = NULL,
85241 + .name = "dapm_bias_read_file",
85242 + .file = "sound/soc/soc-dapm.c",
85243 + .param3 = 1,
85244 +};
85245 +
85246 +struct size_overflow_hash _000598_hash = {
85247 + .next = NULL,
85248 + .name = "dapm_widget_power_read_file",
85249 + .file = "sound/soc/soc-dapm.c",
85250 + .param3 = 1,
85251 +};
85252 +
85253 +struct size_overflow_hash _000599_hash = {
85254 + .next = NULL,
85255 + .name = "datablob_format",
85256 + .file = "security/keys/encrypted-keys/encrypted.c",
85257 + .param2 = 1,
85258 +};
85259 +
85260 +struct size_overflow_hash _000600_hash = {
85261 + .next = NULL,
85262 + .name = "dbgfs_frame",
85263 + .file = "drivers/net/caif/caif_spi.c",
85264 + .param3 = 1,
85265 +};
85266 +
85267 +struct size_overflow_hash _000601_hash = {
85268 + .next = NULL,
85269 + .name = "dbgfs_state",
85270 + .file = "drivers/net/caif/caif_spi.c",
85271 + .param3 = 1,
85272 +};
85273 +
85274 +struct size_overflow_hash _000602_hash = {
85275 + .next = NULL,
85276 + .name = "dccp_feat_clone_sp_val",
85277 + .file = "net/dccp/feat.c",
85278 + .param3 = 1,
85279 +};
85280 +
85281 +struct size_overflow_hash _000603_hash = {
85282 + .next = NULL,
85283 + .name = "dccp_setsockopt_ccid",
85284 + .file = "net/dccp/proto.c",
85285 + .param4 = 1,
85286 +};
85287 +
85288 +struct size_overflow_hash _000604_hash = {
85289 + .next = NULL,
85290 + .name = "dccp_setsockopt_service",
85291 + .file = "net/dccp/proto.c",
85292 + .param4 = 1,
85293 +};
85294 +
85295 +struct size_overflow_hash _000605_hash = {
85296 + .next = NULL,
85297 + .name = "ddb_input_read",
85298 + .file = "drivers/media/dvb/ddbridge/ddbridge-core.c",
85299 + .param3 = 1,
85300 +};
85301 +
85302 +struct size_overflow_hash _000606_hash = {
85303 + .next = NULL,
85304 + .name = "ddb_output_write",
85305 + .file = "drivers/media/dvb/ddbridge/ddbridge-core.c",
85306 + .param3 = 1,
85307 +};
85308 +
85309 +struct size_overflow_hash _000607_hash = {
85310 + .next = NULL,
85311 + .name = "ddp_make_gl",
85312 + .file = "drivers/scsi/cxgbi/libcxgbi.c",
85313 + .param1 = 1,
85314 +};
85315 +
85316 +struct size_overflow_hash _000608_hash = {
85317 + .next = NULL,
85318 + .name = "debugfs_read",
85319 + .file = "drivers/infiniband/hw/cxgb4/device.c",
85320 + .param3 = 1,
85321 +};
85322 +
85323 +struct size_overflow_hash _000609_hash = {
85324 + .next = NULL,
85325 + .name = "debugfs_read",
85326 + .file = "drivers/char/virtio_console.c",
85327 + .param3 = 1,
85328 +};
85329 +
85330 +struct size_overflow_hash _000610_hash = {
85331 + .next = NULL,
85332 + .name = "debug_output",
85333 + .file = "drivers/usb/host/ohci-dbg.c",
85334 + .param3 = 1,
85335 +};
85336 +
85337 +struct size_overflow_hash _000611_hash = {
85338 + .next = NULL,
85339 + .name = "debug_output",
85340 + .file = "drivers/usb/host/ehci-dbg.c",
85341 + .param3 = 1,
85342 +};
85343 +
85344 +struct size_overflow_hash _000612_hash = {
85345 + .next = NULL,
85346 + .name = "debug_read",
85347 + .file = "fs/ocfs2/dlm/dlmdebug.c",
85348 + .param3 = 1,
85349 +};
85350 +
85351 +struct size_overflow_hash _000613_hash = {
85352 + .next = NULL,
85353 + .name = "dev_config",
85354 + .file = "drivers/usb/gadget/inode.c",
85355 + .param3 = 1,
85356 +};
85357 +
85358 +struct size_overflow_hash _000614_hash = {
85359 + .next = NULL,
85360 + .name = "device_write",
85361 + .file = "fs/dlm/user.c",
85362 + .param3 = 1,
85363 +};
85364 +
85365 +struct size_overflow_hash _000615_hash = {
85366 + .next = NULL,
85367 + .name = "dev_read",
85368 + .file = "drivers/media/video/gspca/gspca.c",
85369 + .param3 = 1,
85370 +};
85371 +
85372 +struct size_overflow_hash _000616_hash = {
85373 + .next = NULL,
85374 + .name = "dfs_file_read",
85375 + .file = "drivers/mtd/ubi/debug.c",
85376 + .param3 = 1,
85377 +};
85378 +
85379 +struct size_overflow_hash _000617_hash = {
85380 + .next = NULL,
85381 + .name = "dfs_file_write",
85382 + .file = "drivers/mtd/ubi/debug.c",
85383 + .param3 = 1,
85384 +};
85385 +
85386 +struct size_overflow_hash _000618_hash = {
85387 + .next = NULL,
85388 + .name = "direct_entry",
85389 + .file = "drivers/misc/lkdtm.c",
85390 + .param3 = 1,
85391 +};
85392 +
85393 +struct size_overflow_hash _000619_hash = {
85394 + .next = NULL,
85395 + .name = "dispatch_proc_write",
85396 + .file = "drivers/platform/x86/thinkpad_acpi.c",
85397 + .param3 = 1,
85398 +};
85399 +
85400 +struct size_overflow_hash _000620_hash = {
85401 + .next = NULL,
85402 + .name = "diva_os_malloc",
85403 + .file = "drivers/isdn/hardware/eicon/platform.h",
85404 + .param2 = 1,
85405 +};
85406 +
85407 +struct size_overflow_hash _000621_hash = {
85408 + .next = NULL,
85409 + .name = "dlmfs_file_read",
85410 + .file = "fs/ocfs2/dlmfs/dlmfs.c",
85411 + .param3 = 1,
85412 +};
85413 +
85414 +struct size_overflow_hash _000622_hash = {
85415 + .next = NULL,
85416 + .name = "dlmfs_file_write",
85417 + .file = "fs/ocfs2/dlmfs/dlmfs.c",
85418 + .param3 = 1,
85419 +};
85420 +
85421 +struct size_overflow_hash _000623_hash = {
85422 + .next = NULL,
85423 + .name = "dma_attach",
85424 + .file = "drivers/net/wireless/brcm80211/brcmsmac/dma.c",
85425 + .param6 = 1,
85426 + .param7 = 1,
85427 +};
85428 +
85429 +struct size_overflow_hash _000625_hash = {
85430 + .next = NULL,
85431 + .name = "dma_rx_errors_read",
85432 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85433 + .param3 = 1,
85434 +};
85435 +
85436 +struct size_overflow_hash _000626_hash = {
85437 + .next = NULL,
85438 + .name = "dma_rx_requested_read",
85439 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85440 + .param3 = 1,
85441 +};
85442 +
85443 +struct size_overflow_hash _000627_hash = {
85444 + .next = NULL,
85445 + .name = "dma_show_regs",
85446 + .file = "drivers/tty/serial/mfd.c",
85447 + .param3 = 1,
85448 +};
85449 +
85450 +struct size_overflow_hash _000628_hash = {
85451 + .next = NULL,
85452 + .name = "dma_tx_errors_read",
85453 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85454 + .param3 = 1,
85455 +};
85456 +
85457 +struct size_overflow_hash _000629_hash = {
85458 + .next = NULL,
85459 + .name = "dma_tx_requested_read",
85460 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85461 + .param3 = 1,
85462 +};
85463 +
85464 +struct size_overflow_hash _000630_hash = {
85465 + .next = NULL,
85466 + .name = "dm_read",
85467 + .file = "drivers/net/usb/dm9601.c",
85468 + .param3 = 1,
85469 +};
85470 +
85471 +struct size_overflow_hash _000631_hash = {
85472 + .next = NULL,
85473 + .name = "dm_vcalloc",
85474 + .file = "include/linux/device-mapper.h",
85475 + .param1 = 1,
85476 + .param2 = 1,
85477 +};
85478 +
85479 +struct size_overflow_hash _000633_hash = {
85480 + .next = NULL,
85481 + .name = "dm_write",
85482 + .file = "drivers/net/usb/dm9601.c",
85483 + .param3 = 1,
85484 +};
85485 +
85486 +struct size_overflow_hash _000634_hash = {
85487 + .next = NULL,
85488 + .name = "__dn_setsockopt",
85489 + .file = "net/decnet/af_decnet.c",
85490 + .param5 = 1,
85491 +};
85492 +
85493 +struct size_overflow_hash _000635_hash = {
85494 + .next = NULL,
85495 + .name = "dns_query",
85496 + .file = "include/linux/dns_resolver.h",
85497 + .param3 = 1,
85498 +};
85499 +
85500 +struct size_overflow_hash _000636_hash = {
85501 + .next = NULL,
85502 + .name = "dns_resolver_instantiate",
85503 + .file = "net/dns_resolver/dns_key.c",
85504 + .param3 = 1,
85505 +};
85506 +
85507 +struct size_overflow_hash _000637_hash = {
85508 + .next = NULL,
85509 + .name = "dns_resolver_read",
85510 + .file = "net/dns_resolver/dns_key.c",
85511 + .param3 = 1,
85512 +};
85513 +
85514 +struct size_overflow_hash _000638_hash = {
85515 + .next = NULL,
85516 + .name = "do_add_counters",
85517 + .file = "net/ipv6/netfilter/ip6_tables.c",
85518 + .param3 = 1,
85519 +};
85520 +
85521 +struct size_overflow_hash _000639_hash = {
85522 + .next = NULL,
85523 + .name = "do_add_counters",
85524 + .file = "net/ipv4/netfilter/ip_tables.c",
85525 + .param3 = 1,
85526 +};
85527 +
85528 +struct size_overflow_hash _000640_hash = {
85529 + .next = NULL,
85530 + .name = "do_add_counters",
85531 + .file = "net/ipv4/netfilter/arp_tables.c",
85532 + .param3 = 1,
85533 +};
85534 +
85535 +struct size_overflow_hash _000641_hash = {
85536 + .next = NULL,
85537 + .name = "__do_config_autodelink",
85538 + .file = "drivers/usb/storage/realtek_cr.c",
85539 + .param3 = 1,
85540 +};
85541 +
85542 +struct size_overflow_hash _000642_hash = {
85543 + .next = NULL,
85544 + .name = "do_ipv6_setsockopt",
85545 + .file = "net/ipv6/ipv6_sockglue.c",
85546 + .param5 = 1,
85547 +};
85548 +
85549 +struct size_overflow_hash _000643_hash = {
85550 + .next = NULL,
85551 + .name = "do_ip_vs_set_ctl",
85552 + .file = "net/netfilter/ipvs/ip_vs_ctl.c",
85553 + .param4 = 1,
85554 +};
85555 +
85556 +struct size_overflow_hash _000644_hash = {
85557 + .next = NULL,
85558 + .name = "do_register_entry",
85559 + .file = "drivers/misc/lkdtm.c",
85560 + .param4 = 1,
85561 +};
85562 +
85563 +struct size_overflow_hash _000645_hash = {
85564 + .next = NULL,
85565 + .name = "__do_replace",
85566 + .file = "net/ipv6/netfilter/ip6_tables.c",
85567 + .param5 = 1,
85568 +};
85569 +
85570 +struct size_overflow_hash _000646_hash = {
85571 + .next = NULL,
85572 + .name = "__do_replace",
85573 + .file = "net/ipv4/netfilter/ip_tables.c",
85574 + .param5 = 1,
85575 +};
85576 +
85577 +struct size_overflow_hash _000647_hash = {
85578 + .next = NULL,
85579 + .name = "__do_replace",
85580 + .file = "net/ipv4/netfilter/arp_tables.c",
85581 + .param5 = 1,
85582 +};
85583 +
85584 +struct size_overflow_hash _000648_hash = {
85585 + .next = NULL,
85586 + .name = "do_sync",
85587 + .file = "fs/gfs2/quota.c",
85588 + .param1 = 1,
85589 +};
85590 +
85591 +struct size_overflow_hash _000649_hash = {
85592 + .next = NULL,
85593 + .name = "do_update_counters",
85594 + .file = "net/bridge/netfilter/ebtables.c",
85595 + .param4 = 1,
85596 +};
85597 +
85598 +struct size_overflow_hash _000650_hash = {
85599 + .next = NULL,
85600 + .name = "driver_state_read",
85601 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
85602 + .param3 = 1,
85603 +};
85604 +
85605 +struct size_overflow_hash _000651_hash = {
85606 + .next = NULL,
85607 + .name = "dsp_write",
85608 + .file = "sound/oss/msnd_pinnacle.c",
85609 + .param2 = 1,
85610 +};
85611 +
85612 +struct size_overflow_hash _000652_hash = {
85613 + .next = NULL,
85614 + .name = "dvb_aplay",
85615 + .file = "drivers/media/dvb/ttpci/av7110_av.c",
85616 + .param3 = 1,
85617 +};
85618 +
85619 +struct size_overflow_hash _000653_hash = {
85620 + .next = NULL,
85621 + .name = "dvb_ca_en50221_io_write",
85622 + .file = "drivers/media/dvb/dvb-core/dvb_ca_en50221.c",
85623 + .param3 = 1,
85624 +};
85625 +
85626 +struct size_overflow_hash _000654_hash = {
85627 + .next = NULL,
85628 + .name = "dvb_dmxdev_set_buffer_size",
85629 + .file = "drivers/media/dvb/dvb-core/dmxdev.c",
85630 + .param2 = 1,
85631 +};
85632 +
85633 +struct size_overflow_hash _000655_hash = {
85634 + .next = NULL,
85635 + .name = "dvbdmx_write",
85636 + .file = "drivers/media/dvb/dvb-core/dvb_demux.c",
85637 + .param3 = 1,
85638 +};
85639 +
85640 +struct size_overflow_hash _000656_hash = {
85641 + .next = NULL,
85642 + .name = "dvb_dvr_set_buffer_size",
85643 + .file = "drivers/media/dvb/dvb-core/dmxdev.c",
85644 + .param2 = 1,
85645 +};
85646 +
85647 +struct size_overflow_hash _000657_hash = {
85648 + .next = NULL,
85649 + .name = "dvb_play",
85650 + .file = "drivers/media/dvb/ttpci/av7110_av.c",
85651 + .param3 = 1,
85652 +};
85653 +
85654 +struct size_overflow_hash _000658_hash = {
85655 + .next = NULL,
85656 + .name = "dvb_ringbuffer_pkt_read_user",
85657 + .file = "drivers/media/dvb/dvb-core/dvb_ringbuffer.c",
85658 + .param5 = 1,
85659 +};
85660 +
85661 +struct size_overflow_hash _000659_hash = {
85662 + .next = NULL,
85663 + .name = "dvb_ringbuffer_read_user",
85664 + .file = "drivers/media/dvb/dvb-core/dvb_ringbuffer.c",
85665 + .param3 = 1,
85666 +};
85667 +
85668 +struct size_overflow_hash _000660_hash = {
85669 + .next = NULL,
85670 + .name = "dw210x_op_rw",
85671 + .file = "drivers/media/dvb/dvb-usb/dw2102.c",
85672 + .param6 = 1,
85673 +};
85674 +
85675 +struct size_overflow_hash _000661_hash = {
85676 + .next = NULL,
85677 + .name = "dwc3_mode_write",
85678 + .file = "drivers/usb/dwc3/debugfs.c",
85679 + .param3 = 1,
85680 +};
85681 +
85682 +struct size_overflow_hash _000662_hash = {
85683 + .next = NULL,
85684 + .name = "econet_sendmsg",
85685 + .file = "net/econet/af_econet.c",
85686 + .param4 = 1,
85687 +};
85688 +
85689 +struct size_overflow_hash _000663_hash = {
85690 + .next = NULL,
85691 + .name = "ecryptfs_copy_filename",
85692 + .file = "fs/ecryptfs/crypto.c",
85693 + .param4 = 1,
85694 +};
85695 +
85696 +struct size_overflow_hash _000664_hash = {
85697 + .next = NULL,
85698 + .name = "ecryptfs_miscdev_write",
85699 + .file = "fs/ecryptfs/miscdev.c",
85700 + .param3 = 1,
85701 +};
85702 +
85703 +struct size_overflow_hash _000665_hash = {
85704 + .next = NULL,
85705 + .name = "ecryptfs_send_miscdev",
85706 + .file = "fs/ecryptfs/miscdev.c",
85707 + .param2 = 1,
85708 +};
85709 +
85710 +struct size_overflow_hash _000666_hash = {
85711 + .next = NULL,
85712 + .name = "edac_device_alloc_ctl_info",
85713 + .file = "drivers/edac/edac_device.c",
85714 + .param1 = 1,
85715 +};
85716 +
85717 +struct size_overflow_hash _000667_hash = {
85718 + .next = NULL,
85719 + .name = "edac_mc_alloc",
85720 + .file = "drivers/edac/edac_mc.c",
85721 + .param1 = 1,
85722 +};
85723 +
85724 +struct size_overflow_hash _000668_hash = {
85725 + .next = NULL,
85726 + .name = "edac_pci_alloc_ctl_info",
85727 + .file = "drivers/edac/edac_pci.c",
85728 + .param1 = 1,
85729 +};
85730 +
85731 +struct size_overflow_hash _000669_hash = {
85732 + .next = NULL,
85733 + .name = "efivar_create_sysfs_entry",
85734 + .file = "drivers/firmware/efivars.c",
85735 + .param2 = 1,
85736 +};
85737 +
85738 +struct size_overflow_hash _000670_hash = {
85739 + .next = NULL,
85740 + .name = "efx_tsoh_heap_alloc",
85741 + .file = "drivers/net/ethernet/sfc/tx.c",
85742 + .param2 = 1,
85743 +};
85744 +
85745 +struct size_overflow_hash _000671_hash = {
85746 + .next = NULL,
85747 + .name = "encrypted_instantiate",
85748 + .file = "security/keys/encrypted-keys/encrypted.c",
85749 + .param3 = 1,
85750 +};
85751 +
85752 +struct size_overflow_hash _000672_hash = {
85753 + .next = NULL,
85754 + .name = "encrypted_update",
85755 + .file = "security/keys/encrypted-keys/encrypted.c",
85756 + .param3 = 1,
85757 +};
85758 +
85759 +struct size_overflow_hash _000673_hash = {
85760 + .next = NULL,
85761 + .name = "ep0_write",
85762 + .file = "drivers/usb/gadget/inode.c",
85763 + .param3 = 1,
85764 +};
85765 +
85766 +struct size_overflow_hash _000674_hash = {
85767 + .next = NULL,
85768 + .name = "ep_read",
85769 + .file = "drivers/usb/gadget/inode.c",
85770 + .param3 = 1,
85771 +};
85772 +
85773 +struct size_overflow_hash _000675_hash = {
85774 + .next = NULL,
85775 + .name = "ep_write",
85776 + .file = "drivers/usb/gadget/inode.c",
85777 + .param3 = 1,
85778 +};
85779 +
85780 +struct size_overflow_hash _000676_hash = {
85781 + .next = NULL,
85782 + .name = "erst_dbg_write",
85783 + .file = "drivers/acpi/apei/erst-dbg.c",
85784 + .param3 = 1,
85785 +};
85786 +
85787 +struct size_overflow_hash _000677_hash = {
85788 + .next = NULL,
85789 + .name = "et61x251_read",
85790 + .file = "drivers/media/video/et61x251/et61x251_core.c",
85791 + .param3 = 1,
85792 +};
85793 +
85794 +struct size_overflow_hash _000678_hash = {
85795 + .next = NULL,
85796 + .name = "event_calibration_read",
85797 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85798 + .param3 = 1,
85799 +};
85800 +
85801 +struct size_overflow_hash _000679_hash = {
85802 + .next = NULL,
85803 + .name = "event_heart_beat_read",
85804 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85805 + .param3 = 1,
85806 +};
85807 +
85808 +struct size_overflow_hash _000680_hash = {
85809 + .next = NULL,
85810 + .name = "event_oom_late_read",
85811 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85812 + .param3 = 1,
85813 +};
85814 +
85815 +struct size_overflow_hash _000681_hash = {
85816 + .next = NULL,
85817 + .name = "event_phy_transmit_error_read",
85818 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85819 + .param3 = 1,
85820 +};
85821 +
85822 +struct size_overflow_hash _000682_hash = {
85823 + .next = NULL,
85824 + .name = "event_rx_mem_empty_read",
85825 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85826 + .param3 = 1,
85827 +};
85828 +
85829 +struct size_overflow_hash _000683_hash = {
85830 + .next = NULL,
85831 + .name = "event_rx_mismatch_read",
85832 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85833 + .param3 = 1,
85834 +};
85835 +
85836 +struct size_overflow_hash _000684_hash = {
85837 + .next = NULL,
85838 + .name = "event_rx_pool_read",
85839 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85840 + .param3 = 1,
85841 +};
85842 +
85843 +struct size_overflow_hash _000685_hash = {
85844 + .next = NULL,
85845 + .name = "event_tx_stuck_read",
85846 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85847 + .param3 = 1,
85848 +};
85849 +
85850 +struct size_overflow_hash _000686_hash = {
85851 + .next = NULL,
85852 + .name = "excessive_retries_read",
85853 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85854 + .param3 = 1,
85855 +};
85856 +
85857 +struct size_overflow_hash _000687_hash = {
85858 + .next = NULL,
85859 + .name = "exofs_read_lookup_dev_table",
85860 + .file = "fs/exofs/super.c",
85861 + .param3 = 1,
85862 +};
85863 +
85864 +struct size_overflow_hash _000688_hash = {
85865 + .next = NULL,
85866 + .name = "ext4_kvmalloc",
85867 + .file = "fs/ext4/super.c",
85868 + .param1 = 1,
85869 +};
85870 +
85871 +struct size_overflow_hash _000689_hash = {
85872 + .next = NULL,
85873 + .name = "ext4_kvzalloc",
85874 + .file = "fs/ext4/super.c",
85875 + .param1 = 1,
85876 +};
85877 +
85878 +struct size_overflow_hash _000690_hash = {
85879 + .next = NULL,
85880 + .name = "extend_netdev_table",
85881 + .file = "net/core/netprio_cgroup.c",
85882 + .param2 = 1,
85883 +};
85884 +
85885 +struct size_overflow_hash _000691_hash = {
85886 + .next = NULL,
85887 + .name = "fd_copyin",
85888 + .file = "drivers/block/floppy.c",
85889 + .param3 = 1,
85890 +};
85891 +
85892 +struct size_overflow_hash _000692_hash = {
85893 + .next = NULL,
85894 + .name = "fd_copyout",
85895 + .file = "drivers/block/floppy.c",
85896 + .param3 = 1,
85897 +};
85898 +
85899 +struct size_overflow_hash _000693_hash = {
85900 + .next = NULL,
85901 + .name = "__ffs_ep0_read_events",
85902 + .file = "drivers/usb/gadget/f_fs.c",
85903 + .param3 = 1,
85904 +};
85905 +
85906 +struct size_overflow_hash _000694_hash = {
85907 + .next = NULL,
85908 + .name = "ffs_epfile_io",
85909 + .file = "drivers/usb/gadget/f_fs.c",
85910 + .param3 = 1,
85911 +};
85912 +
85913 +struct size_overflow_hash _000695_hash = {
85914 + .next = NULL,
85915 + .name = "ffs_prepare_buffer",
85916 + .file = "drivers/usb/gadget/f_fs.c",
85917 + .param2 = 1,
85918 +};
85919 +
85920 +struct size_overflow_hash _000696_hash = {
85921 + .next = NULL,
85922 + .name = "f_hidg_read",
85923 + .file = "drivers/usb/gadget/f_hid.c",
85924 + .param3 = 1,
85925 +};
85926 +
85927 +struct size_overflow_hash _000697_hash = {
85928 + .next = NULL,
85929 + .name = "f_hidg_write",
85930 + .file = "drivers/usb/gadget/f_hid.c",
85931 + .param3 = 1,
85932 +};
85933 +
85934 +struct size_overflow_hash _000698_hash = {
85935 + .next = NULL,
85936 + .name = "fill_write_buffer",
85937 + .file = "fs/configfs/file.c",
85938 + .param3 = 1,
85939 +};
85940 +
85941 +struct size_overflow_hash _000699_hash = {
85942 + .next = NULL,
85943 + .name = "flexcop_device_kmalloc",
85944 + .file = "drivers/media/dvb/b2c2/flexcop.c",
85945 + .param1 = 1,
85946 +};
85947 +
85948 +struct size_overflow_hash _000700_hash = {
85949 + .next = NULL,
85950 + .name = "fops_read",
85951 + .file = "drivers/media/video/saa7164/saa7164-encoder.c",
85952 + .param3 = 1,
85953 +};
85954 +
85955 +struct size_overflow_hash _000701_hash = {
85956 + .next = NULL,
85957 + .name = "fops_read",
85958 + .file = "drivers/media/video/saa7164/saa7164-vbi.c",
85959 + .param3 = 1,
85960 +};
85961 +
85962 +struct size_overflow_hash _000702_hash = {
85963 + .next = NULL,
85964 + .name = "format_devstat_counter",
85965 + .file = "net/mac80211/debugfs.c",
85966 + .param3 = 1,
85967 +};
85968 +
85969 +struct size_overflow_hash _000703_hash = {
85970 + .next = NULL,
85971 + .name = "fragmentation_threshold_read",
85972 + .file = "net/wireless/debugfs.c",
85973 + .param3 = 1,
85974 +};
85975 +
85976 +struct size_overflow_hash _000704_hash = {
85977 + .next = NULL,
85978 + .name = "frame_alloc",
85979 + .file = "drivers/media/video/gspca/gspca.c",
85980 + .param4 = 1,
85981 +};
85982 +
85983 +struct size_overflow_hash _000705_hash = {
85984 + .next = NULL,
85985 + .name = "ftdi_elan_write",
85986 + .file = "drivers/usb/misc/ftdi-elan.c",
85987 + .param3 = 1,
85988 +};
85989 +
85990 +struct size_overflow_hash _000706_hash = {
85991 + .next = NULL,
85992 + .name = "fuse_conn_limit_read",
85993 + .file = "fs/fuse/control.c",
85994 + .param3 = 1,
85995 +};
85996 +
85997 +struct size_overflow_hash _000707_hash = {
85998 + .next = NULL,
85999 + .name = "fuse_conn_limit_write",
86000 + .file = "fs/fuse/control.c",
86001 + .param3 = 1,
86002 +};
86003 +
86004 +struct size_overflow_hash _000708_hash = {
86005 + .next = &_000531_hash,
86006 + .name = "fuse_conn_waiting_read",
86007 + .file = "fs/fuse/control.c",
86008 + .param3 = 1,
86009 +};
86010 +
86011 +struct size_overflow_hash _000709_hash = {
86012 + .next = NULL,
86013 + .name = "garp_attr_create",
86014 + .file = "net/802/garp.c",
86015 + .param3 = 1,
86016 +};
86017 +
86018 +struct size_overflow_hash _000710_hash = {
86019 + .next = NULL,
86020 + .name = "get_alua_req",
86021 + .file = "drivers/scsi/device_handler/scsi_dh_alua.c",
86022 + .param3 = 1,
86023 +};
86024 +
86025 +struct size_overflow_hash _000711_hash = {
86026 + .next = NULL,
86027 + .name = "get_derived_key",
86028 + .file = "security/keys/encrypted-keys/encrypted.c",
86029 + .param4 = 1,
86030 +};
86031 +
86032 +struct size_overflow_hash _000712_hash = {
86033 + .next = NULL,
86034 + .name = "getdqbuf",
86035 + .file = "fs/quota/quota_tree.c",
86036 + .param1 = 1,
86037 +};
86038 +
86039 +struct size_overflow_hash _000713_hash = {
86040 + .next = NULL,
86041 + .name = "get_fdb_entries",
86042 + .file = "net/bridge/br_ioctl.c",
86043 + .param3 = 1,
86044 +};
86045 +
86046 +struct size_overflow_hash _000714_hash = {
86047 + .next = NULL,
86048 + .name = "get_rdac_req",
86049 + .file = "drivers/scsi/device_handler/scsi_dh_rdac.c",
86050 + .param3 = 1,
86051 +};
86052 +
86053 +struct size_overflow_hash _000715_hash = {
86054 + .next = NULL,
86055 + .name = "get_registers",
86056 + .file = "drivers/net/usb/pegasus.c",
86057 + .param3 = 1,
86058 +};
86059 +
86060 +struct size_overflow_hash _000716_hash = {
86061 + .next = NULL,
86062 + .name = "get_server_iovec",
86063 + .file = "fs/cifs/connect.c",
86064 + .param2 = 1,
86065 +};
86066 +
86067 +struct size_overflow_hash _000717_hash = {
86068 + .next = NULL,
86069 + .name = "get_ucode_user",
86070 + .file = "arch/x86/kernel/microcode_intel.c",
86071 + .param3 = 1,
86072 +};
86073 +
86074 +struct size_overflow_hash _000718_hash = {
86075 + .next = NULL,
86076 + .name = "gfs2_alloc_sort_buffer",
86077 + .file = "fs/gfs2/dir.c",
86078 + .param1 = 1,
86079 +};
86080 +
86081 +struct size_overflow_hash _000719_hash = {
86082 + .next = NULL,
86083 + .name = "gfs2_glock_nq_m",
86084 + .file = "fs/gfs2/glock.c",
86085 + .param1 = 1,
86086 +};
86087 +
86088 +struct size_overflow_hash _000720_hash = {
86089 + .next = NULL,
86090 + .name = "gigaset_initdriver",
86091 + .file = "drivers/isdn/gigaset/common.c",
86092 + .param2 = 1,
86093 +};
86094 +
86095 +struct size_overflow_hash _000721_hash = {
86096 + .next = NULL,
86097 + .name = "gpio_power_read",
86098 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
86099 + .param3 = 1,
86100 +};
86101 +
86102 +struct size_overflow_hash _000722_hash = {
86103 + .next = NULL,
86104 + .name = "gs_alloc_req",
86105 + .file = "drivers/usb/gadget/u_serial.c",
86106 + .param2 = 1,
86107 +};
86108 +
86109 +struct size_overflow_hash _000723_hash = {
86110 + .next = NULL,
86111 + .name = "gs_buf_alloc",
86112 + .file = "drivers/usb/gadget/u_serial.c",
86113 + .param2 = 1,
86114 +};
86115 +
86116 +struct size_overflow_hash _000724_hash = {
86117 + .next = NULL,
86118 + .name = "gss_pipe_downcall",
86119 + .file = "net/sunrpc/auth_gss/auth_gss.c",
86120 + .param3 = 1,
86121 +};
86122 +
86123 +struct size_overflow_hash _000725_hash = {
86124 + .next = NULL,
86125 + .name = "handle_request",
86126 + .file = "drivers/firewire/core-cdev.c",
86127 + .param9 = 1,
86128 +};
86129 +
86130 +struct size_overflow_hash _000726_hash = {
86131 + .next = NULL,
86132 + .name = "hash_new",
86133 + .file = "net/batman-adv/hash.c",
86134 + .param1 = 1,
86135 +};
86136 +
86137 +struct size_overflow_hash _000727_hash = {
86138 + .next = NULL,
86139 + .name = "hash_setkey",
86140 + .file = "crypto/algif_hash.c",
86141 + .param3 = 1,
86142 +};
86143 +
86144 +struct size_overflow_hash _000728_hash = {
86145 + .next = NULL,
86146 + .name = "hcd_buffer_alloc",
86147 + .file = "include/linux/usb/hcd.h",
86148 + .param2 = 1,
86149 +};
86150 +
86151 +struct size_overflow_hash _000729_hash = {
86152 + .next = NULL,
86153 + .name = "hci_sock_setsockopt",
86154 + .file = "net/bluetooth/hci_sock.c",
86155 + .param5 = 1,
86156 +};
86157 +
86158 +struct size_overflow_hash _000730_hash = {
86159 + .next = NULL,
86160 + .name = "hdpvr_read",
86161 + .file = "drivers/media/video/hdpvr/hdpvr-video.c",
86162 + .param3 = 1,
86163 +};
86164 +
86165 +struct size_overflow_hash _000731_hash = {
86166 + .next = NULL,
86167 + .name = "hidraw_get_report",
86168 + .file = "drivers/hid/hidraw.c",
86169 + .param3 = 1,
86170 +};
86171 +
86172 +struct size_overflow_hash _000732_hash = {
86173 + .next = NULL,
86174 + .name = "hidraw_read",
86175 + .file = "drivers/hid/hidraw.c",
86176 + .param3 = 1,
86177 +};
86178 +
86179 +struct size_overflow_hash _000733_hash = {
86180 + .next = NULL,
86181 + .name = "hidraw_send_report",
86182 + .file = "drivers/hid/hidraw.c",
86183 + .param3 = 1,
86184 +};
86185 +
86186 +struct size_overflow_hash _000734_hash = {
86187 + .next = NULL,
86188 + .name = "hid_register_field",
86189 + .file = "drivers/hid/hid-core.c",
86190 + .param2 = 1,
86191 + .param3 = 1,
86192 +};
86193 +
86194 +struct size_overflow_hash _000736_hash = {
86195 + .next = NULL,
86196 + .name = "hpfs_translate_name",
86197 + .file = "fs/hpfs/name.c",
86198 + .param3 = 1,
86199 +};
86200 +
86201 +struct size_overflow_hash _000737_hash = {
86202 + .next = NULL,
86203 + .name = "hpi_alloc_control_cache",
86204 + .file = "sound/pci/asihpi/hpicmn.c",
86205 + .param1 = 1,
86206 +};
86207 +
86208 +struct size_overflow_hash _000738_hash = {
86209 + .next = NULL,
86210 + .name = "ht40allow_map_read",
86211 + .file = "net/wireless/debugfs.c",
86212 + .param3 = 1,
86213 +};
86214 +
86215 +struct size_overflow_hash _000739_hash = {
86216 + .next = NULL,
86217 + .name = "__hwahc_dev_set_key",
86218 + .file = "drivers/usb/host/hwa-hc.c",
86219 + .param5 = 1,
86220 +};
86221 +
86222 +struct size_overflow_hash _000740_hash = {
86223 + .next = NULL,
86224 + .name = "hwflags_read",
86225 + .file = "net/mac80211/debugfs.c",
86226 + .param3 = 1,
86227 +};
86228 +
86229 +struct size_overflow_hash _000741_hash = {
86230 + .next = NULL,
86231 + .name = "hysdn_conf_read",
86232 + .file = "drivers/isdn/hysdn/hysdn_procconf.c",
86233 + .param3 = 1,
86234 +};
86235 +
86236 +struct size_overflow_hash _000742_hash = {
86237 + .next = NULL,
86238 + .name = "hysdn_conf_write",
86239 + .file = "drivers/isdn/hysdn/hysdn_procconf.c",
86240 + .param3 = 1,
86241 +};
86242 +
86243 +struct size_overflow_hash _000743_hash = {
86244 + .next = NULL,
86245 + .name = "hysdn_log_write",
86246 + .file = "drivers/isdn/hysdn/hysdn_proclog.c",
86247 + .param3 = 1,
86248 +};
86249 +
86250 +struct size_overflow_hash _000744_hash = {
86251 + .next = NULL,
86252 + .name = "i2400m_rx_stats_read",
86253 + .file = "drivers/net/wimax/i2400m/debugfs.c",
86254 + .param3 = 1,
86255 +};
86256 +
86257 +struct size_overflow_hash _000745_hash = {
86258 + .next = NULL,
86259 + .name = "i2400m_tx_stats_read",
86260 + .file = "drivers/net/wimax/i2400m/debugfs.c",
86261 + .param3 = 1,
86262 +};
86263 +
86264 +struct size_overflow_hash _000746_hash = {
86265 + .next = NULL,
86266 + .name = "__i2400mu_send_barker",
86267 + .file = "drivers/net/wimax/i2400m/usb.c",
86268 + .param3 = 1,
86269 +};
86270 +
86271 +struct size_overflow_hash _000747_hash = {
86272 + .next = NULL,
86273 + .name = "i2400m_zrealloc_2x",
86274 + .file = "drivers/net/wimax/i2400m/fw.c",
86275 + .param3 = 1,
86276 +};
86277 +
86278 +struct size_overflow_hash _000748_hash = {
86279 + .next = NULL,
86280 + .name = "i2cdev_read",
86281 + .file = "drivers/i2c/i2c-dev.c",
86282 + .param3 = 1,
86283 +};
86284 +
86285 +struct size_overflow_hash _000749_hash = {
86286 + .next = &_000459_hash,
86287 + .name = "i2cdev_write",
86288 + .file = "drivers/i2c/i2c-dev.c",
86289 + .param3 = 1,
86290 +};
86291 +
86292 +struct size_overflow_hash _000750_hash = {
86293 + .next = NULL,
86294 + .name = "ib_alloc_device",
86295 + .file = "include/rdma/ib_verbs.h",
86296 + .param1 = 1,
86297 +};
86298 +
86299 +struct size_overflow_hash _000751_hash = {
86300 + .next = NULL,
86301 + .name = "ib_copy_from_udata",
86302 + .file = "include/rdma/ib_verbs.h",
86303 + .param3 = 1,
86304 +};
86305 +
86306 +struct size_overflow_hash _000752_hash = {
86307 + .next = NULL,
86308 + .name = "ib_copy_to_udata",
86309 + .file = "include/rdma/ib_verbs.h",
86310 + .param3 = 1,
86311 +};
86312 +
86313 +struct size_overflow_hash _000753_hash = {
86314 + .next = NULL,
86315 + .name = "ibmasm_new_command",
86316 + .file = "drivers/misc/ibmasm/command.c",
86317 + .param2 = 1,
86318 +};
86319 +
86320 +struct size_overflow_hash _000754_hash = {
86321 + .next = NULL,
86322 + .name = "ib_ucm_alloc_data",
86323 + .file = "drivers/infiniband/core/ucm.c",
86324 + .param3 = 1,
86325 +};
86326 +
86327 +struct size_overflow_hash _000755_hash = {
86328 + .next = NULL,
86329 + .name = "ib_umad_write",
86330 + .file = "drivers/infiniband/core/user_mad.c",
86331 + .param3 = 1,
86332 +};
86333 +
86334 +struct size_overflow_hash _000756_hash = {
86335 + .next = NULL,
86336 + .name = "ib_uverbs_unmarshall_recv",
86337 + .file = "drivers/infiniband/core/uverbs_cmd.c",
86338 + .param5 = 1,
86339 +};
86340 +
86341 +struct size_overflow_hash _000757_hash = {
86342 + .next = NULL,
86343 + .name = "ide_driver_proc_write",
86344 + .file = "drivers/ide/ide-proc.c",
86345 + .param3 = 1,
86346 +};
86347 +
86348 +struct size_overflow_hash _000758_hash = {
86349 + .next = NULL,
86350 + .name = "ide_queue_pc_tail",
86351 + .file = "include/linux/ide.h",
86352 + .param5 = 1,
86353 +};
86354 +
86355 +struct size_overflow_hash _000759_hash = {
86356 + .next = NULL,
86357 + .name = "ide_raw_taskfile",
86358 + .file = "include/linux/ide.h",
86359 + .param4 = 1,
86360 +};
86361 +
86362 +struct size_overflow_hash _000760_hash = {
86363 + .next = NULL,
86364 + .name = "ide_settings_proc_write",
86365 + .file = "drivers/ide/ide-proc.c",
86366 + .param3 = 1,
86367 +};
86368 +
86369 +struct size_overflow_hash _000761_hash = {
86370 + .next = NULL,
86371 + .name = "idetape_chrdev_read",
86372 + .file = "drivers/ide/ide-tape.c",
86373 + .param3 = 1,
86374 +};
86375 +
86376 +struct size_overflow_hash _000762_hash = {
86377 + .next = NULL,
86378 + .name = "idetape_chrdev_write",
86379 + .file = "drivers/ide/ide-tape.c",
86380 + .param3 = 1,
86381 +};
86382 +
86383 +struct size_overflow_hash _000763_hash = {
86384 + .next = NULL,
86385 + .name = "idmouse_read",
86386 + .file = "drivers/usb/misc/idmouse.c",
86387 + .param3 = 1,
86388 +};
86389 +
86390 +struct size_overflow_hash _000764_hash = {
86391 + .next = NULL,
86392 + .name = "ieee80211_build_probe_req",
86393 + .file = "net/mac80211/util.c",
86394 + .param7 = 1,
86395 +};
86396 +
86397 +struct size_overflow_hash _000765_hash = {
86398 + .next = NULL,
86399 + .name = "ieee80211_if_read",
86400 + .file = "net/mac80211/debugfs_netdev.c",
86401 + .param3 = 1,
86402 +};
86403 +
86404 +struct size_overflow_hash _000766_hash = {
86405 + .next = NULL,
86406 + .name = "ieee80211_if_write",
86407 + .file = "net/mac80211/debugfs_netdev.c",
86408 + .param3 = 1,
86409 +};
86410 +
86411 +struct size_overflow_hash _000767_hash = {
86412 + .next = NULL,
86413 + .name = "ieee80211_key_alloc",
86414 + .file = "net/mac80211/key.c",
86415 + .param3 = 1,
86416 +};
86417 +
86418 +struct size_overflow_hash _000768_hash = {
86419 + .next = NULL,
86420 + .name = "ieee80211_mgmt_tx",
86421 + .file = "net/mac80211/cfg.c",
86422 + .param9 = 1,
86423 +};
86424 +
86425 +struct size_overflow_hash _000769_hash = {
86426 + .next = NULL,
86427 + .name = "ikconfig_read_current",
86428 + .file = "kernel/configs.c",
86429 + .param3 = 1,
86430 +};
86431 +
86432 +struct size_overflow_hash _000770_hash = {
86433 + .next = NULL,
86434 + .name = "il3945_sta_dbgfs_stats_table_read",
86435 + .file = "drivers/net/wireless/iwlegacy/3945-rs.c",
86436 + .param3 = 1,
86437 +};
86438 +
86439 +struct size_overflow_hash _000771_hash = {
86440 + .next = NULL,
86441 + .name = "il3945_ucode_general_stats_read",
86442 + .file = "drivers/net/wireless/iwlegacy/3945-debug.c",
86443 + .param3 = 1,
86444 +};
86445 +
86446 +struct size_overflow_hash _000772_hash = {
86447 + .next = NULL,
86448 + .name = "il3945_ucode_rx_stats_read",
86449 + .file = "drivers/net/wireless/iwlegacy/3945-debug.c",
86450 + .param3 = 1,
86451 +};
86452 +
86453 +struct size_overflow_hash _000773_hash = {
86454 + .next = NULL,
86455 + .name = "il3945_ucode_tx_stats_read",
86456 + .file = "drivers/net/wireless/iwlegacy/3945-debug.c",
86457 + .param3 = 1,
86458 +};
86459 +
86460 +struct size_overflow_hash _000774_hash = {
86461 + .next = NULL,
86462 + .name = "il4965_rs_sta_dbgfs_rate_scale_data_read",
86463 + .file = "drivers/net/wireless/iwlegacy/4965-rs.c",
86464 + .param3 = 1,
86465 +};
86466 +
86467 +struct size_overflow_hash _000775_hash = {
86468 + .next = NULL,
86469 + .name = "il4965_rs_sta_dbgfs_scale_table_read",
86470 + .file = "drivers/net/wireless/iwlegacy/4965-rs.c",
86471 + .param3 = 1,
86472 +};
86473 +
86474 +struct size_overflow_hash _000776_hash = {
86475 + .next = NULL,
86476 + .name = "il4965_rs_sta_dbgfs_stats_table_read",
86477 + .file = "drivers/net/wireless/iwlegacy/4965-rs.c",
86478 + .param3 = 1,
86479 +};
86480 +
86481 +struct size_overflow_hash _000777_hash = {
86482 + .next = NULL,
86483 + .name = "il4965_ucode_general_stats_read",
86484 + .file = "drivers/net/wireless/iwlegacy/4965-debug.c",
86485 + .param3 = 1,
86486 +};
86487 +
86488 +struct size_overflow_hash _000778_hash = {
86489 + .next = NULL,
86490 + .name = "il4965_ucode_rx_stats_read",
86491 + .file = "drivers/net/wireless/iwlegacy/4965-debug.c",
86492 + .param3 = 1,
86493 +};
86494 +
86495 +struct size_overflow_hash _000779_hash = {
86496 + .next = NULL,
86497 + .name = "il4965_ucode_tx_stats_read",
86498 + .file = "drivers/net/wireless/iwlegacy/4965-debug.c",
86499 + .param3 = 1,
86500 +};
86501 +
86502 +struct size_overflow_hash _000780_hash = {
86503 + .next = NULL,
86504 + .name = "il_dbgfs_chain_noise_read",
86505 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86506 + .param3 = 1,
86507 +};
86508 +
86509 +struct size_overflow_hash _000781_hash = {
86510 + .next = NULL,
86511 + .name = "il_dbgfs_channels_read",
86512 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86513 + .param3 = 1,
86514 +};
86515 +
86516 +struct size_overflow_hash _000782_hash = {
86517 + .next = NULL,
86518 + .name = "il_dbgfs_disable_ht40_read",
86519 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86520 + .param3 = 1,
86521 +};
86522 +
86523 +struct size_overflow_hash _000783_hash = {
86524 + .next = NULL,
86525 + .name = "il_dbgfs_fh_reg_read",
86526 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86527 + .param3 = 1,
86528 +};
86529 +
86530 +struct size_overflow_hash _000784_hash = {
86531 + .next = NULL,
86532 + .name = "il_dbgfs_force_reset_read",
86533 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86534 + .param3 = 1,
86535 +};
86536 +
86537 +struct size_overflow_hash _000785_hash = {
86538 + .next = NULL,
86539 + .name = "il_dbgfs_interrupt_read",
86540 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86541 + .param3 = 1,
86542 +};
86543 +
86544 +struct size_overflow_hash _000786_hash = {
86545 + .next = NULL,
86546 + .name = "il_dbgfs_missed_beacon_read",
86547 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86548 + .param3 = 1,
86549 +};
86550 +
86551 +struct size_overflow_hash _000787_hash = {
86552 + .next = NULL,
86553 + .name = "il_dbgfs_nvm_read",
86554 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86555 + .param3 = 1,
86556 +};
86557 +
86558 +struct size_overflow_hash _000788_hash = {
86559 + .next = NULL,
86560 + .name = "il_dbgfs_power_save_status_read",
86561 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86562 + .param3 = 1,
86563 +};
86564 +
86565 +struct size_overflow_hash _000789_hash = {
86566 + .next = NULL,
86567 + .name = "il_dbgfs_qos_read",
86568 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86569 + .param3 = 1,
86570 +};
86571 +
86572 +struct size_overflow_hash _000790_hash = {
86573 + .next = &_000221_hash,
86574 + .name = "il_dbgfs_rxon_filter_flags_read",
86575 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86576 + .param3 = 1,
86577 +};
86578 +
86579 +struct size_overflow_hash _000791_hash = {
86580 + .next = NULL,
86581 + .name = "il_dbgfs_rxon_flags_read",
86582 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86583 + .param3 = 1,
86584 +};
86585 +
86586 +struct size_overflow_hash _000792_hash = {
86587 + .next = NULL,
86588 + .name = "il_dbgfs_rx_queue_read",
86589 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86590 + .param3 = 1,
86591 +};
86592 +
86593 +struct size_overflow_hash _000793_hash = {
86594 + .next = NULL,
86595 + .name = "il_dbgfs_rx_stats_read",
86596 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86597 + .param3 = 1,
86598 +};
86599 +
86600 +struct size_overflow_hash _000794_hash = {
86601 + .next = NULL,
86602 + .name = "il_dbgfs_sensitivity_read",
86603 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86604 + .param3 = 1,
86605 +};
86606 +
86607 +struct size_overflow_hash _000795_hash = {
86608 + .next = NULL,
86609 + .name = "il_dbgfs_sram_read",
86610 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86611 + .param3 = 1,
86612 +};
86613 +
86614 +struct size_overflow_hash _000796_hash = {
86615 + .next = NULL,
86616 + .name = "il_dbgfs_stations_read",
86617 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86618 + .param3 = 1,
86619 +};
86620 +
86621 +struct size_overflow_hash _000797_hash = {
86622 + .next = NULL,
86623 + .name = "il_dbgfs_status_read",
86624 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86625 + .param3 = 1,
86626 +};
86627 +
86628 +struct size_overflow_hash _000798_hash = {
86629 + .next = NULL,
86630 + .name = "il_dbgfs_traffic_log_read",
86631 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86632 + .param3 = 1,
86633 +};
86634 +
86635 +struct size_overflow_hash _000799_hash = {
86636 + .next = NULL,
86637 + .name = "il_dbgfs_tx_queue_read",
86638 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86639 + .param3 = 1,
86640 +};
86641 +
86642 +struct size_overflow_hash _000800_hash = {
86643 + .next = NULL,
86644 + .name = "il_dbgfs_tx_stats_read",
86645 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86646 + .param3 = 1,
86647 +};
86648 +
86649 +struct size_overflow_hash _000801_hash = {
86650 + .next = NULL,
86651 + .name = "ilo_read",
86652 + .file = "drivers/misc/hpilo.c",
86653 + .param3 = 1,
86654 +};
86655 +
86656 +struct size_overflow_hash _000802_hash = {
86657 + .next = NULL,
86658 + .name = "ilo_write",
86659 + .file = "drivers/misc/hpilo.c",
86660 + .param3 = 1,
86661 +};
86662 +
86663 +struct size_overflow_hash _000803_hash = {
86664 + .next = NULL,
86665 + .name = "init_data_container",
86666 + .file = "fs/btrfs/backref.c",
86667 + .param1 = 1,
86668 +};
86669 +
86670 +struct size_overflow_hash _000804_hash = {
86671 + .next = NULL,
86672 + .name = "init_list_set",
86673 + .file = "net/netfilter/ipset/ip_set_list_set.c",
86674 + .param2 = 1,
86675 + .param3 = 1,
86676 +};
86677 +
86678 +struct size_overflow_hash _000806_hash = {
86679 + .next = NULL,
86680 + .name = "interpret_user_input",
86681 + .file = "fs/ubifs/debug.c",
86682 + .param2 = 1,
86683 +};
86684 +
86685 +struct size_overflow_hash _000807_hash = {
86686 + .next = NULL,
86687 + .name = "int_proc_write",
86688 + .file = "drivers/net/wireless/ray_cs.c",
86689 + .param3 = 1,
86690 +};
86691 +
86692 +struct size_overflow_hash _000808_hash = {
86693 + .next = NULL,
86694 + .name = "iowarrior_read",
86695 + .file = "drivers/usb/misc/iowarrior.c",
86696 + .param3 = 1,
86697 +};
86698 +
86699 +struct size_overflow_hash _000809_hash = {
86700 + .next = NULL,
86701 + .name = "iowarrior_write",
86702 + .file = "drivers/usb/misc/iowarrior.c",
86703 + .param3 = 1,
86704 +};
86705 +
86706 +struct size_overflow_hash _000810_hash = {
86707 + .next = NULL,
86708 + .name = "ip_set_alloc",
86709 + .file = "include/linux/netfilter/ipset/ip_set.h",
86710 + .param1 = 1,
86711 +};
86712 +
86713 +struct size_overflow_hash _000811_hash = {
86714 + .next = NULL,
86715 + .name = "ip_vs_conn_fill_param_sync",
86716 + .file = "net/netfilter/ipvs/ip_vs_sync.c",
86717 + .param6 = 1,
86718 +};
86719 +
86720 +struct size_overflow_hash _000812_hash = {
86721 + .next = NULL,
86722 + .name = "irda_setsockopt",
86723 + .file = "net/irda/af_irda.c",
86724 + .param5 = 1,
86725 +};
86726 +
86727 +struct size_overflow_hash _000813_hash = {
86728 + .next = NULL,
86729 + .name = "ir_lirc_transmit_ir",
86730 + .file = "drivers/media/rc/ir-lirc-codec.c",
86731 + .param3 = 1,
86732 +};
86733 +
86734 +struct size_overflow_hash _000814_hash = {
86735 + .next = NULL,
86736 + .name = "irnet_ctrl_write",
86737 + .file = "net/irda/irnet/irnet_ppp.c",
86738 + .param3 = 1,
86739 +};
86740 +
86741 +struct size_overflow_hash _000815_hash = {
86742 + .next = NULL,
86743 + .name = "iscsi_decode_text_input",
86744 + .file = "drivers/target/iscsi/iscsi_target_parameters.c",
86745 + .param4 = 1,
86746 +};
86747 +
86748 +struct size_overflow_hash _000816_hash = {
86749 + .next = NULL,
86750 + .name = "iscsit_dump_data_payload",
86751 + .file = "drivers/target/iscsi/iscsi_target_erl1.c",
86752 + .param2 = 1,
86753 +};
86754 +
86755 +struct size_overflow_hash _000817_hash = {
86756 + .next = NULL,
86757 + .name = "isdn_read",
86758 + .file = "drivers/isdn/i4l/isdn_common.c",
86759 + .param3 = 1,
86760 +};
86761 +
86762 +struct size_overflow_hash _000818_hash = {
86763 + .next = NULL,
86764 + .name = "iso_callback",
86765 + .file = "drivers/firewire/core-cdev.c",
86766 + .param3 = 1,
86767 +};
86768 +
86769 +struct size_overflow_hash _000819_hash = {
86770 + .next = NULL,
86771 + .name = "iso_packets_buffer_init",
86772 + .file = "sound/firewire/packets-buffer.c",
86773 + .param3 = 1,
86774 +};
86775 +
86776 +struct size_overflow_hash _000820_hash = {
86777 + .next = NULL,
86778 + .name = "iso_sched_alloc",
86779 + .file = "drivers/usb/host/ehci-sched.c",
86780 + .param1 = 1,
86781 +};
86782 +
86783 +struct size_overflow_hash _000821_hash = {
86784 + .next = NULL,
86785 + .name = "isr_cmd_cmplt_read",
86786 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86787 + .param3 = 1,
86788 +};
86789 +
86790 +struct size_overflow_hash _000822_hash = {
86791 + .next = NULL,
86792 + .name = "isr_commands_read",
86793 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86794 + .param3 = 1,
86795 +};
86796 +
86797 +struct size_overflow_hash _000823_hash = {
86798 + .next = NULL,
86799 + .name = "isr_decrypt_done_read",
86800 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86801 + .param3 = 1,
86802 +};
86803 +
86804 +struct size_overflow_hash _000824_hash = {
86805 + .next = NULL,
86806 + .name = "isr_dma0_done_read",
86807 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86808 + .param3 = 1,
86809 +};
86810 +
86811 +struct size_overflow_hash _000825_hash = {
86812 + .next = NULL,
86813 + .name = "isr_dma1_done_read",
86814 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86815 + .param3 = 1,
86816 +};
86817 +
86818 +struct size_overflow_hash _000826_hash = {
86819 + .next = NULL,
86820 + .name = "isr_fiqs_read",
86821 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86822 + .param3 = 1,
86823 +};
86824 +
86825 +struct size_overflow_hash _000827_hash = {
86826 + .next = NULL,
86827 + .name = "isr_host_acknowledges_read",
86828 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86829 + .param3 = 1,
86830 +};
86831 +
86832 +struct size_overflow_hash _000828_hash = {
86833 + .next = &_000629_hash,
86834 + .name = "isr_hw_pm_mode_changes_read",
86835 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86836 + .param3 = 1,
86837 +};
86838 +
86839 +struct size_overflow_hash _000829_hash = {
86840 + .next = &_000329_hash,
86841 + .name = "isr_irqs_read",
86842 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86843 + .param3 = 1,
86844 +};
86845 +
86846 +struct size_overflow_hash _000830_hash = {
86847 + .next = NULL,
86848 + .name = "isr_low_rssi_read",
86849 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86850 + .param3 = 1,
86851 +};
86852 +
86853 +struct size_overflow_hash _000831_hash = {
86854 + .next = NULL,
86855 + .name = "isr_pci_pm_read",
86856 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86857 + .param3 = 1,
86858 +};
86859 +
86860 +struct size_overflow_hash _000832_hash = {
86861 + .next = NULL,
86862 + .name = "isr_rx_headers_read",
86863 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86864 + .param3 = 1,
86865 +};
86866 +
86867 +struct size_overflow_hash _000833_hash = {
86868 + .next = NULL,
86869 + .name = "isr_rx_mem_overflow_read",
86870 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86871 + .param3 = 1,
86872 +};
86873 +
86874 +struct size_overflow_hash _000834_hash = {
86875 + .next = NULL,
86876 + .name = "isr_rx_procs_read",
86877 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86878 + .param3 = 1,
86879 +};
86880 +
86881 +struct size_overflow_hash _000835_hash = {
86882 + .next = NULL,
86883 + .name = "isr_rx_rdys_read",
86884 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86885 + .param3 = 1,
86886 +};
86887 +
86888 +struct size_overflow_hash _000836_hash = {
86889 + .next = NULL,
86890 + .name = "isr_tx_exch_complete_read",
86891 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86892 + .param3 = 1,
86893 +};
86894 +
86895 +struct size_overflow_hash _000837_hash = {
86896 + .next = NULL,
86897 + .name = "isr_tx_procs_read",
86898 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86899 + .param3 = 1,
86900 +};
86901 +
86902 +struct size_overflow_hash _000838_hash = {
86903 + .next = NULL,
86904 + .name = "isr_wakeups_read",
86905 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86906 + .param3 = 1,
86907 +};
86908 +
86909 +struct size_overflow_hash _000839_hash = {
86910 + .next = NULL,
86911 + .name = "ivtv_copy_buf_to_user",
86912 + .file = "drivers/media/video/ivtv/ivtv-fileops.c",
86913 + .param4 = 1,
86914 +};
86915 +
86916 +struct size_overflow_hash _000840_hash = {
86917 + .next = NULL,
86918 + .name = "iwl_dbgfs_bt_traffic_read",
86919 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
86920 + .param3 = 1,
86921 +};
86922 +
86923 +struct size_overflow_hash _000841_hash = {
86924 + .next = NULL,
86925 + .name = "iwl_dbgfs_chain_noise_read",
86926 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
86927 + .param3 = 1,
86928 +};
86929 +
86930 +struct size_overflow_hash _000842_hash = {
86931 + .next = NULL,
86932 + .name = "iwl_dbgfs_channels_read",
86933 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
86934 + .param3 = 1,
86935 +};
86936 +
86937 +struct size_overflow_hash _000843_hash = {
86938 + .next = NULL,
86939 + .name = "iwl_dbgfs_current_sleep_command_read",
86940 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
86941 + .param3 = 1,
86942 +};
86943 +
86944 +struct size_overflow_hash _000844_hash = {
86945 + .next = NULL,
86946 + .name = "iwl_dbgfs_debug_level_read",
86947 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
86948 + .param3 = 1,
86949 +};
86950 +
86951 +struct size_overflow_hash _000845_hash = {
86952 + .next = NULL,
86953 + .name = "iwl_dbgfs_debug_level_write",
86954 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
86955 + .param3 = 1,
86956 +};
86957 +
86958 +struct size_overflow_hash _000846_hash = {
86959 + .next = NULL,
86960 + .name = "iwl_dbgfs_disable_ht40_read",
86961 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
86962 + .param3 = 1,
86963 +};
86964 +
86965 +struct size_overflow_hash _000847_hash = {
86966 + .next = NULL,
86967 + .name = "iwl_dbgfs_fh_reg_read",
86968 + .file = "drivers/net/wireless/iwlwifi/iwl-trans-pcie.c",
86969 + .param3 = 1,
86970 +};
86971 +
86972 +struct size_overflow_hash _000848_hash = {
86973 + .next = NULL,
86974 + .name = "iwl_dbgfs_force_reset_read",
86975 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
86976 + .param3 = 1,
86977 +};
86978 +
86979 +struct size_overflow_hash _000849_hash = {
86980 + .next = NULL,
86981 + .name = "iwl_dbgfs_interrupt_read",
86982 + .file = "drivers/net/wireless/iwlwifi/iwl-trans-pcie.c",
86983 + .param3 = 1,
86984 +};
86985 +
86986 +struct size_overflow_hash _000850_hash = {
86987 + .next = NULL,
86988 + .name = "iwl_dbgfs_log_event_read",
86989 + .file = "drivers/net/wireless/iwlwifi/iwl-trans-pcie.c",
86990 + .param3 = 1,
86991 +};
86992 +
86993 +struct size_overflow_hash _000851_hash = {
86994 + .next = NULL,
86995 + .name = "iwl_dbgfs_missed_beacon_read",
86996 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
86997 + .param3 = 1,
86998 +};
86999 +
87000 +struct size_overflow_hash _000852_hash = {
87001 + .next = NULL,
87002 + .name = "iwl_dbgfs_nvm_read",
87003 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87004 + .param3 = 1,
87005 +};
87006 +
87007 +struct size_overflow_hash _000853_hash = {
87008 + .next = NULL,
87009 + .name = "iwl_dbgfs_plcp_delta_read",
87010 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87011 + .param3 = 1,
87012 +};
87013 +
87014 +struct size_overflow_hash _000854_hash = {
87015 + .next = NULL,
87016 + .name = "iwl_dbgfs_power_save_status_read",
87017 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87018 + .param3 = 1,
87019 +};
87020 +
87021 +struct size_overflow_hash _000855_hash = {
87022 + .next = NULL,
87023 + .name = "iwl_dbgfs_protection_mode_read",
87024 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87025 + .param3 = 1,
87026 +};
87027 +
87028 +struct size_overflow_hash _000856_hash = {
87029 + .next = NULL,
87030 + .name = "iwl_dbgfs_qos_read",
87031 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87032 + .param3 = 1,
87033 +};
87034 +
87035 +struct size_overflow_hash _000857_hash = {
87036 + .next = NULL,
87037 + .name = "iwl_dbgfs_reply_tx_error_read",
87038 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87039 + .param3 = 1,
87040 +};
87041 +
87042 +struct size_overflow_hash _000858_hash = {
87043 + .next = NULL,
87044 + .name = "iwl_dbgfs_rx_handlers_read",
87045 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87046 + .param3 = 1,
87047 +};
87048 +
87049 +struct size_overflow_hash _000859_hash = {
87050 + .next = NULL,
87051 + .name = "iwl_dbgfs_rxon_filter_flags_read",
87052 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87053 + .param3 = 1,
87054 +};
87055 +
87056 +struct size_overflow_hash _000860_hash = {
87057 + .next = NULL,
87058 + .name = "iwl_dbgfs_rxon_flags_read",
87059 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87060 + .param3 = 1,
87061 +};
87062 +
87063 +struct size_overflow_hash _000861_hash = {
87064 + .next = NULL,
87065 + .name = "iwl_dbgfs_rx_queue_read",
87066 + .file = "drivers/net/wireless/iwlwifi/iwl-trans-pcie.c",
87067 + .param3 = 1,
87068 +};
87069 +
87070 +struct size_overflow_hash _000862_hash = {
87071 + .next = NULL,
87072 + .name = "iwl_dbgfs_rx_statistics_read",
87073 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87074 + .param3 = 1,
87075 +};
87076 +
87077 +struct size_overflow_hash _000863_hash = {
87078 + .next = NULL,
87079 + .name = "iwl_dbgfs_sensitivity_read",
87080 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87081 + .param3 = 1,
87082 +};
87083 +
87084 +struct size_overflow_hash _000864_hash = {
87085 + .next = NULL,
87086 + .name = "iwl_dbgfs_sleep_level_override_read",
87087 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87088 + .param3 = 1,
87089 +};
87090 +
87091 +struct size_overflow_hash _000865_hash = {
87092 + .next = NULL,
87093 + .name = "iwl_dbgfs_sram_read",
87094 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87095 + .param3 = 1,
87096 +};
87097 +
87098 +struct size_overflow_hash _000866_hash = {
87099 + .next = NULL,
87100 + .name = "iwl_dbgfs_stations_read",
87101 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87102 + .param3 = 1,
87103 +};
87104 +
87105 +struct size_overflow_hash _000867_hash = {
87106 + .next = NULL,
87107 + .name = "iwl_dbgfs_status_read",
87108 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87109 + .param3 = 1,
87110 +};
87111 +
87112 +struct size_overflow_hash _000868_hash = {
87113 + .next = NULL,
87114 + .name = "iwl_dbgfs_temperature_read",
87115 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87116 + .param3 = 1,
87117 +};
87118 +
87119 +struct size_overflow_hash _000869_hash = {
87120 + .next = NULL,
87121 + .name = "iwl_dbgfs_thermal_throttling_read",
87122 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87123 + .param3 = 1,
87124 +};
87125 +
87126 +struct size_overflow_hash _000870_hash = {
87127 + .next = NULL,
87128 + .name = "iwl_dbgfs_traffic_log_read",
87129 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87130 + .param3 = 1,
87131 +};
87132 +
87133 +struct size_overflow_hash _000871_hash = {
87134 + .next = NULL,
87135 + .name = "iwl_dbgfs_tx_queue_read",
87136 + .file = "drivers/net/wireless/iwlwifi/iwl-trans-pcie.c",
87137 + .param3 = 1,
87138 +};
87139 +
87140 +struct size_overflow_hash _000872_hash = {
87141 + .next = NULL,
87142 + .name = "iwl_dbgfs_tx_statistics_read",
87143 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87144 + .param3 = 1,
87145 +};
87146 +
87147 +struct size_overflow_hash _000873_hash = {
87148 + .next = NULL,
87149 + .name = "iwl_dbgfs_ucode_bt_stats_read",
87150 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87151 + .param3 = 1,
87152 +};
87153 +
87154 +struct size_overflow_hash _000874_hash = {
87155 + .next = NULL,
87156 + .name = "iwl_dbgfs_ucode_general_stats_read",
87157 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87158 + .param3 = 1,
87159 +};
87160 +
87161 +struct size_overflow_hash _000875_hash = {
87162 + .next = NULL,
87163 + .name = "iwl_dbgfs_ucode_rx_stats_read",
87164 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87165 + .param3 = 1,
87166 +};
87167 +
87168 +struct size_overflow_hash _000876_hash = {
87169 + .next = NULL,
87170 + .name = "iwl_dbgfs_ucode_tracing_read",
87171 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87172 + .param3 = 1,
87173 +};
87174 +
87175 +struct size_overflow_hash _000877_hash = {
87176 + .next = NULL,
87177 + .name = "iwl_dbgfs_ucode_tx_stats_read",
87178 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87179 + .param3 = 1,
87180 +};
87181 +
87182 +struct size_overflow_hash _000878_hash = {
87183 + .next = NULL,
87184 + .name = "iwl_dbgfs_wowlan_sram_read",
87185 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87186 + .param3 = 1,
87187 +};
87188 +
87189 +struct size_overflow_hash _000879_hash = {
87190 + .next = NULL,
87191 + .name = "iwmct_fw_parser_init",
87192 + .file = "drivers/misc/iwmc3200top/fw-download.c",
87193 + .param4 = 1,
87194 +};
87195 +
87196 +struct size_overflow_hash _000880_hash = {
87197 + .next = NULL,
87198 + .name = "iwm_notif_send",
87199 + .file = "drivers/net/wireless/iwmc3200wifi/main.c",
87200 + .param6 = 1,
87201 +};
87202 +
87203 +struct size_overflow_hash _000881_hash = {
87204 + .next = NULL,
87205 + .name = "iwm_ntf_calib_res",
87206 + .file = "drivers/net/wireless/iwmc3200wifi/rx.c",
87207 + .param3 = 1,
87208 +};
87209 +
87210 +struct size_overflow_hash _000882_hash = {
87211 + .next = NULL,
87212 + .name = "iwm_umac_set_config_var",
87213 + .file = "drivers/net/wireless/iwmc3200wifi/commands.c",
87214 + .param4 = 1,
87215 +};
87216 +
87217 +struct size_overflow_hash _000883_hash = {
87218 + .next = NULL,
87219 + .name = "jbd2_alloc",
87220 + .file = "include/linux/jbd2.h",
87221 + .param1 = 1,
87222 +};
87223 +
87224 +struct size_overflow_hash _000884_hash = {
87225 + .next = NULL,
87226 + .name = "key_algorithm_read",
87227 + .file = "net/mac80211/debugfs_key.c",
87228 + .param3 = 1,
87229 +};
87230 +
87231 +struct size_overflow_hash _000885_hash = {
87232 + .next = NULL,
87233 + .name = "key_icverrors_read",
87234 + .file = "net/mac80211/debugfs_key.c",
87235 + .param3 = 1,
87236 +};
87237 +
87238 +struct size_overflow_hash _000886_hash = {
87239 + .next = NULL,
87240 + .name = "key_key_read",
87241 + .file = "net/mac80211/debugfs_key.c",
87242 + .param3 = 1,
87243 +};
87244 +
87245 +struct size_overflow_hash _000887_hash = {
87246 + .next = NULL,
87247 + .name = "key_replays_read",
87248 + .file = "net/mac80211/debugfs_key.c",
87249 + .param3 = 1,
87250 +};
87251 +
87252 +struct size_overflow_hash _000888_hash = {
87253 + .next = NULL,
87254 + .name = "key_rx_spec_read",
87255 + .file = "net/mac80211/debugfs_key.c",
87256 + .param3 = 1,
87257 +};
87258 +
87259 +struct size_overflow_hash _000889_hash = {
87260 + .next = NULL,
87261 + .name = "key_tx_spec_read",
87262 + .file = "net/mac80211/debugfs_key.c",
87263 + .param3 = 1,
87264 +};
87265 +
87266 +struct size_overflow_hash _000890_hash = {
87267 + .next = NULL,
87268 + .name = "kmem_alloc",
87269 + .file = "fs/xfs/kmem.c",
87270 + .param1 = 1,
87271 +};
87272 +
87273 +struct size_overflow_hash _000891_hash = {
87274 + .next = NULL,
87275 + .name = "kmem_zalloc_large",
87276 + .file = "fs/xfs/kmem.h",
87277 + .param1 = 1,
87278 +};
87279 +
87280 +struct size_overflow_hash _000892_hash = {
87281 + .next = NULL,
87282 + .name = "kone_receive",
87283 + .file = "drivers/hid/hid-roccat-kone.c",
87284 + .param4 = 1,
87285 +};
87286 +
87287 +struct size_overflow_hash _000893_hash = {
87288 + .next = NULL,
87289 + .name = "kone_send",
87290 + .file = "drivers/hid/hid-roccat-kone.c",
87291 + .param4 = 1,
87292 +};
87293 +
87294 +struct size_overflow_hash _000894_hash = {
87295 + .next = NULL,
87296 + .name = "kvm_read_guest_atomic",
87297 + .file = "include/linux/kvm_host.h",
87298 + .param4 = 1,
87299 +};
87300 +
87301 +struct size_overflow_hash _000895_hash = {
87302 + .next = NULL,
87303 + .name = "kvm_read_guest_cached",
87304 + .file = "include/linux/kvm_host.h",
87305 + .param4 = 1,
87306 +};
87307 +
87308 +struct size_overflow_hash _000896_hash = {
87309 + .next = NULL,
87310 + .name = "kvm_set_irq_routing",
87311 + .file = "include/linux/kvm_host.h",
87312 + .param3 = 1,
87313 +};
87314 +
87315 +struct size_overflow_hash _000897_hash = {
87316 + .next = NULL,
87317 + .name = "kvm_write_guest_cached",
87318 + .file = "include/linux/kvm_host.h",
87319 + .param4 = 1,
87320 +};
87321 +
87322 +struct size_overflow_hash _000898_hash = {
87323 + .next = NULL,
87324 + .name = "l2cap_sock_setsockopt",
87325 + .file = "net/bluetooth/l2cap_sock.c",
87326 + .param5 = 1,
87327 +};
87328 +
87329 +struct size_overflow_hash _000899_hash = {
87330 + .next = NULL,
87331 + .name = "l2cap_sock_setsockopt_old",
87332 + .file = "net/bluetooth/l2cap_sock.c",
87333 + .param4 = 1,
87334 +};
87335 +
87336 +struct size_overflow_hash _000900_hash = {
87337 + .next = NULL,
87338 + .name = "lane2_associate_req",
87339 + .file = "net/atm/lec.c",
87340 + .param4 = 1,
87341 +};
87342 +
87343 +struct size_overflow_hash _000901_hash = {
87344 + .next = NULL,
87345 + .name = "lbs_debugfs_read",
87346 + .file = "drivers/net/wireless/libertas/debugfs.c",
87347 + .param3 = 1,
87348 +};
87349 +
87350 +struct size_overflow_hash _000902_hash = {
87351 + .next = NULL,
87352 + .name = "lbs_debugfs_write",
87353 + .file = "drivers/net/wireless/libertas/debugfs.c",
87354 + .param3 = 1,
87355 +};
87356 +
87357 +struct size_overflow_hash _000903_hash = {
87358 + .next = NULL,
87359 + .name = "lbs_dev_info",
87360 + .file = "drivers/net/wireless/libertas/debugfs.c",
87361 + .param3 = 1,
87362 +};
87363 +
87364 +struct size_overflow_hash _000904_hash = {
87365 + .next = NULL,
87366 + .name = "lbs_host_sleep_read",
87367 + .file = "drivers/net/wireless/libertas/debugfs.c",
87368 + .param3 = 1,
87369 +};
87370 +
87371 +struct size_overflow_hash _000905_hash = {
87372 + .next = NULL,
87373 + .name = "lbs_rdbbp_read",
87374 + .file = "drivers/net/wireless/libertas/debugfs.c",
87375 + .param3 = 1,
87376 +};
87377 +
87378 +struct size_overflow_hash _000906_hash = {
87379 + .next = NULL,
87380 + .name = "lbs_rdmac_read",
87381 + .file = "drivers/net/wireless/libertas/debugfs.c",
87382 + .param3 = 1,
87383 +};
87384 +
87385 +struct size_overflow_hash _000907_hash = {
87386 + .next = NULL,
87387 + .name = "lbs_rdrf_read",
87388 + .file = "drivers/net/wireless/libertas/debugfs.c",
87389 + .param3 = 1,
87390 +};
87391 +
87392 +struct size_overflow_hash _000908_hash = {
87393 + .next = NULL,
87394 + .name = "lbs_sleepparams_read",
87395 + .file = "drivers/net/wireless/libertas/debugfs.c",
87396 + .param3 = 1,
87397 +};
87398 +
87399 +struct size_overflow_hash _000909_hash = {
87400 + .next = NULL,
87401 + .name = "lbs_threshold_read",
87402 + .file = "drivers/net/wireless/libertas/debugfs.c",
87403 + .param5 = 1,
87404 +};
87405 +
87406 +struct size_overflow_hash _000910_hash = {
87407 + .next = NULL,
87408 + .name = "lc_create",
87409 + .file = "include/linux/lru_cache.h",
87410 + .param3 = 1,
87411 +};
87412 +
87413 +struct size_overflow_hash _000911_hash = {
87414 + .next = NULL,
87415 + .name = "lcd_write",
87416 + .file = "drivers/usb/misc/usblcd.c",
87417 + .param3 = 1,
87418 +};
87419 +
87420 +struct size_overflow_hash _000912_hash = {
87421 + .next = NULL,
87422 + .name = "leaf_dealloc",
87423 + .file = "fs/gfs2/dir.c",
87424 + .param3 = 1,
87425 +};
87426 +
87427 +struct size_overflow_hash _000913_hash = {
87428 + .next = NULL,
87429 + .name = "__lgread",
87430 + .file = "drivers/lguest/core.c",
87431 + .param4 = 1,
87432 +};
87433 +
87434 +struct size_overflow_hash _000914_hash = {
87435 + .next = NULL,
87436 + .name = "__lgwrite",
87437 + .file = "drivers/lguest/core.c",
87438 + .param4 = 1,
87439 +};
87440 +
87441 +struct size_overflow_hash _000915_hash = {
87442 + .next = NULL,
87443 + .name = "link_send_sections_long",
87444 + .file = "net/tipc/link.c",
87445 + .param4 = 1,
87446 +};
87447 +
87448 +struct size_overflow_hash _000916_hash = {
87449 + .next = NULL,
87450 + .name = "lirc_buffer_init",
87451 + .file = "include/media/lirc_dev.h",
87452 + .param2 = 1,
87453 + .param3 = 1,
87454 +};
87455 +
87456 +struct size_overflow_hash _000918_hash = {
87457 + .next = NULL,
87458 + .name = "lkdtm_debugfs_read",
87459 + .file = "drivers/misc/lkdtm.c",
87460 + .param3 = 1,
87461 +};
87462 +
87463 +struct size_overflow_hash _000919_hash = {
87464 + .next = NULL,
87465 + .name = "LoadBitmap",
87466 + .file = "drivers/media/dvb/ttpci/av7110_hw.c",
87467 + .param2 = 1,
87468 +};
87469 +
87470 +struct size_overflow_hash _000920_hash = {
87471 + .next = NULL,
87472 + .name = "long_retry_limit_read",
87473 + .file = "net/wireless/debugfs.c",
87474 + .param3 = 1,
87475 +};
87476 +
87477 +struct size_overflow_hash _000921_hash = {
87478 + .next = NULL,
87479 + .name = "lpfc_debugfs_dif_err_read",
87480 + .file = "drivers/scsi/lpfc/lpfc_debugfs.c",
87481 + .param3 = 1,
87482 +};
87483 +
87484 +struct size_overflow_hash _000922_hash = {
87485 + .next = NULL,
87486 + .name = "lpfc_debugfs_dif_err_write",
87487 + .file = "drivers/scsi/lpfc/lpfc_debugfs.c",
87488 + .param3 = 1,
87489 +};
87490 +
87491 +struct size_overflow_hash _000923_hash = {
87492 + .next = NULL,
87493 + .name = "lpfc_debugfs_read",
87494 + .file = "drivers/scsi/lpfc/lpfc_debugfs.c",
87495 + .param3 = 1,
87496 +};
87497 +
87498 +struct size_overflow_hash _000924_hash = {
87499 + .next = NULL,
87500 + .name = "lpfc_idiag_baracc_read",
87501 + .file = "drivers/scsi/lpfc/lpfc_debugfs.c",
87502 + .param3 = 1,
87503 +};
87504 +
87505 +struct size_overflow_hash _000925_hash = {
87506 + .next = NULL,
87507 + .name = "lpfc_idiag_ctlacc_read",
87508 + .file = "drivers/scsi/lpfc/lpfc_debugfs.c",
87509 + .param3 = 1,
87510 +};
87511 +
87512 +struct size_overflow_hash _000926_hash = {
87513 + .next = NULL,
87514 + .name = "lpfc_idiag_drbacc_read",
87515 + .file = "drivers/scsi/lpfc/lpfc_debugfs.c",
87516 + .param3 = 1,
87517 +};
87518 +
87519 +struct size_overflow_hash _000927_hash = {
87520 + .next = NULL,
87521 + .name = "lpfc_idiag_extacc_read",
87522 + .file = "drivers/scsi/lpfc/lpfc_debugfs.c",
87523 + .param3 = 1,
87524 +};
87525 +
87526 +struct size_overflow_hash _000928_hash = {
87527 + .next = NULL,
87528 + .name = "lpfc_idiag_mbxacc_read",
87529 + .file = "drivers/scsi/lpfc/lpfc_debugfs.c",
87530 + .param3 = 1,
87531 +};
87532 +
87533 +struct size_overflow_hash _000929_hash = {
87534 + .next = NULL,
87535 + .name = "lpfc_idiag_pcicfg_read",
87536 + .file = "drivers/scsi/lpfc/lpfc_debugfs.c",
87537 + .param3 = 1,
87538 +};
87539 +
87540 +struct size_overflow_hash _000930_hash = {
87541 + .next = NULL,
87542 + .name = "lpfc_idiag_queacc_read",
87543 + .file = "drivers/scsi/lpfc/lpfc_debugfs.c",
87544 + .param3 = 1,
87545 +};
87546 +
87547 +struct size_overflow_hash _000931_hash = {
87548 + .next = NULL,
87549 + .name = "lpfc_idiag_queinfo_read",
87550 + .file = "drivers/scsi/lpfc/lpfc_debugfs.c",
87551 + .param3 = 1,
87552 +};
87553 +
87554 +struct size_overflow_hash _000932_hash = {
87555 + .next = NULL,
87556 + .name = "lpfc_sli4_queue_alloc",
87557 + .file = "drivers/scsi/lpfc/lpfc_sli.c",
87558 + .param3 = 1,
87559 +};
87560 +
87561 +struct size_overflow_hash _000933_hash = {
87562 + .next = NULL,
87563 + .name = "lp_write",
87564 + .file = "drivers/char/lp.c",
87565 + .param3 = 1,
87566 +};
87567 +
87568 +struct size_overflow_hash _000934_hash = {
87569 + .next = NULL,
87570 + .name = "mac80211_format_buffer",
87571 + .file = "net/mac80211/debugfs.c",
87572 + .param2 = 1,
87573 +};
87574 +
87575 +struct size_overflow_hash _000935_hash = {
87576 + .next = NULL,
87577 + .name = "mce_write",
87578 + .file = "arch/x86/kernel/cpu/mcheck/mce-inject.c",
87579 + .param3 = 1,
87580 +};
87581 +
87582 +struct size_overflow_hash _000936_hash = {
87583 + .next = NULL,
87584 + .name = "mcs7830_get_reg",
87585 + .file = "drivers/net/usb/mcs7830.c",
87586 + .param3 = 1,
87587 +};
87588 +
87589 +struct size_overflow_hash _000937_hash = {
87590 + .next = NULL,
87591 + .name = "mcs7830_set_reg",
87592 + .file = "drivers/net/usb/mcs7830.c",
87593 + .param3 = 1,
87594 +};
87595 +
87596 +struct size_overflow_hash _000938_hash = {
87597 + .next = NULL,
87598 + .name = "mdc800_device_read",
87599 + .file = "drivers/usb/image/mdc800.c",
87600 + .param3 = 1,
87601 +};
87602 +
87603 +struct size_overflow_hash _000939_hash = {
87604 + .next = NULL,
87605 + .name = "mdiobus_alloc_size",
87606 + .file = "include/linux/phy.h",
87607 + .param1 = 1,
87608 +};
87609 +
87610 +struct size_overflow_hash _000940_hash = {
87611 + .next = NULL,
87612 + .name = "media_entity_init",
87613 + .file = "include/media/media-entity.h",
87614 + .param2 = 1,
87615 + .param4 = 1,
87616 +};
87617 +
87618 +struct size_overflow_hash _000942_hash = {
87619 + .next = NULL,
87620 + .name = "memstick_alloc_host",
87621 + .file = "include/linux/memstick.h",
87622 + .param1 = 1,
87623 +};
87624 +
87625 +struct size_overflow_hash _000943_hash = {
87626 + .next = NULL,
87627 + .name = "mgmt_control",
87628 + .file = "include/net/bluetooth/hci_core.h",
87629 + .param3 = 1,
87630 +};
87631 +
87632 +struct size_overflow_hash _000944_hash = {
87633 + .next = NULL,
87634 + .name = "mgmt_pending_add",
87635 + .file = "net/bluetooth/mgmt.c",
87636 + .param5 = 1,
87637 +};
87638 +
87639 +struct size_overflow_hash _000945_hash = {
87640 + .next = &_000321_hash,
87641 + .name = "mic_calc_failure_read",
87642 + .file = "drivers/net/wireless/wl1251/debugfs.c",
87643 + .param3 = 1,
87644 +};
87645 +
87646 +struct size_overflow_hash _000946_hash = {
87647 + .next = NULL,
87648 + .name = "mic_rx_pkts_read",
87649 + .file = "drivers/net/wireless/wl1251/debugfs.c",
87650 + .param3 = 1,
87651 +};
87652 +
87653 +struct size_overflow_hash _000947_hash = {
87654 + .next = NULL,
87655 + .name = "minstrel_stats_read",
87656 + .file = "net/mac80211/rc80211_minstrel_debugfs.c",
87657 + .param3 = 1,
87658 +};
87659 +
87660 +struct size_overflow_hash _000948_hash = {
87661 + .next = NULL,
87662 + .name = "mlx4_en_create_rx_ring",
87663 + .file = "drivers/net/ethernet/mellanox/mlx4/en_rx.c",
87664 + .param3 = 1,
87665 +};
87666 +
87667 +struct size_overflow_hash _000949_hash = {
87668 + .next = NULL,
87669 + .name = "mlx4_en_create_tx_ring",
87670 + .file = "drivers/net/ethernet/mellanox/mlx4/en_tx.c",
87671 + .param4 = 1,
87672 +};
87673 +
87674 +struct size_overflow_hash _000950_hash = {
87675 + .next = NULL,
87676 + .name = "mmc_ext_csd_read",
87677 + .file = "drivers/mmc/core/debugfs.c",
87678 + .param3 = 1,
87679 +};
87680 +
87681 +struct size_overflow_hash _000951_hash = {
87682 + .next = NULL,
87683 + .name = "mmc_send_bus_test",
87684 + .file = "drivers/mmc/core/mmc_ops.c",
87685 + .param4 = 1,
87686 +};
87687 +
87688 +struct size_overflow_hash _000952_hash = {
87689 + .next = NULL,
87690 + .name = "mmc_send_cxd_data",
87691 + .file = "drivers/mmc/core/mmc_ops.c",
87692 + .param5 = 1,
87693 +};
87694 +
87695 +struct size_overflow_hash _000953_hash = {
87696 + .next = NULL,
87697 + .name = "mmc_test_alloc_mem",
87698 + .file = "drivers/mmc/card/mmc_test.c",
87699 + .param3 = 1,
87700 +};
87701 +
87702 +struct size_overflow_hash _000954_hash = {
87703 + .next = NULL,
87704 + .name = "mon_bin_get_event",
87705 + .file = "drivers/usb/mon/mon_bin.c",
87706 + .param4 = 1,
87707 +};
87708 +
87709 +struct size_overflow_hash _000955_hash = {
87710 + .next = NULL,
87711 + .name = "mon_stat_read",
87712 + .file = "drivers/usb/mon/mon_stat.c",
87713 + .param3 = 1,
87714 +};
87715 +
87716 +struct size_overflow_hash _000956_hash = {
87717 + .next = NULL,
87718 + .name = "mptctl_getiocinfo",
87719 + .file = "drivers/message/fusion/mptctl.c",
87720 + .param2 = 1,
87721 +};
87722 +
87723 +struct size_overflow_hash _000957_hash = {
87724 + .next = NULL,
87725 + .name = "msnd_fifo_alloc",
87726 + .file = "sound/oss/msnd.c",
87727 + .param2 = 1,
87728 +};
87729 +
87730 +struct size_overflow_hash _000958_hash = {
87731 + .next = NULL,
87732 + .name = "mtdchar_readoob",
87733 + .file = "drivers/mtd/mtdchar.c",
87734 + .param4 = 1,
87735 +};
87736 +
87737 +struct size_overflow_hash _000959_hash = {
87738 + .next = NULL,
87739 + .name = "mtdchar_write",
87740 + .file = "drivers/mtd/mtdchar.c",
87741 + .param3 = 1,
87742 +};
87743 +
87744 +struct size_overflow_hash _000960_hash = {
87745 + .next = NULL,
87746 + .name = "mtdchar_writeoob",
87747 + .file = "drivers/mtd/mtdchar.c",
87748 + .param4 = 1,
87749 +};
87750 +
87751 +struct size_overflow_hash _000961_hash = {
87752 + .next = NULL,
87753 + .name = "mtdswap_init",
87754 + .file = "drivers/mtd/mtdswap.c",
87755 + .param2 = 1,
87756 +};
87757 +
87758 +struct size_overflow_hash _000962_hash = {
87759 + .next = NULL,
87760 + .name = "mtf_test_write",
87761 + .file = "drivers/mmc/card/mmc_test.c",
87762 + .param3 = 1,
87763 +};
87764 +
87765 +struct size_overflow_hash _000963_hash = {
87766 + .next = NULL,
87767 + .name = "musb_test_mode_write",
87768 + .file = "drivers/usb/musb/musb_debugfs.c",
87769 + .param3 = 1,
87770 +};
87771 +
87772 +struct size_overflow_hash _000964_hash = {
87773 + .next = NULL,
87774 + .name = "mvumi_alloc_mem_resource",
87775 + .file = "drivers/scsi/mvumi.c",
87776 + .param3 = 1,
87777 +};
87778 +
87779 +struct size_overflow_hash _000965_hash = {
87780 + .next = NULL,
87781 + .name = "mwifiex_alloc_sdio_mpa_buffers",
87782 + .file = "drivers/net/wireless/mwifiex/sdio.c",
87783 + .param2 = 1,
87784 + .param3 = 1,
87785 +};
87786 +
87787 +struct size_overflow_hash _000967_hash = {
87788 + .next = NULL,
87789 + .name = "mwifiex_debug_read",
87790 + .file = "drivers/net/wireless/mwifiex/debugfs.c",
87791 + .param3 = 1,
87792 +};
87793 +
87794 +struct size_overflow_hash _000968_hash = {
87795 + .next = NULL,
87796 + .name = "mwifiex_get_common_rates",
87797 + .file = "drivers/net/wireless/mwifiex/join.c",
87798 + .param3 = 1,
87799 +};
87800 +
87801 +struct size_overflow_hash _000969_hash = {
87802 + .next = NULL,
87803 + .name = "mwifiex_getlog_read",
87804 + .file = "drivers/net/wireless/mwifiex/debugfs.c",
87805 + .param3 = 1,
87806 +};
87807 +
87808 +struct size_overflow_hash _000970_hash = {
87809 + .next = NULL,
87810 + .name = "mwifiex_info_read",
87811 + .file = "drivers/net/wireless/mwifiex/debugfs.c",
87812 + .param3 = 1,
87813 +};
87814 +
87815 +struct size_overflow_hash _000971_hash = {
87816 + .next = NULL,
87817 + .name = "mwifiex_rdeeprom_read",
87818 + .file = "drivers/net/wireless/mwifiex/debugfs.c",
87819 + .param3 = 1,
87820 +};
87821 +
87822 +struct size_overflow_hash _000972_hash = {
87823 + .next = NULL,
87824 + .name = "mwifiex_regrdwr_read",
87825 + .file = "drivers/net/wireless/mwifiex/debugfs.c",
87826 + .param3 = 1,
87827 +};
87828 +
87829 +struct size_overflow_hash _000973_hash = {
87830 + .next = NULL,
87831 + .name = "mwifiex_update_curr_bss_params",
87832 + .file = "drivers/net/wireless/mwifiex/scan.c",
87833 + .param5 = 1,
87834 +};
87835 +
87836 +struct size_overflow_hash _000974_hash = {
87837 + .next = NULL,
87838 + .name = "nand_bch_init",
87839 + .file = "include/linux/mtd/nand_bch.h",
87840 + .param2 = 1,
87841 + .param3 = 1,
87842 +};
87843 +
87844 +struct size_overflow_hash _000976_hash = {
87845 + .next = NULL,
87846 + .name = "ncp_file_write",
87847 + .file = "fs/ncpfs/file.c",
87848 + .param3 = 1,
87849 +};
87850 +
87851 +struct size_overflow_hash _000977_hash = {
87852 + .next = NULL,
87853 + .name = "ncp__vol2io",
87854 + .file = "fs/ncpfs/ncplib_kernel.c",
87855 + .param5 = 1,
87856 +};
87857 +
87858 +struct size_overflow_hash _000978_hash = {
87859 + .next = NULL,
87860 + .name = "new_bind_ctl",
87861 + .file = "sound/pci/hda/patch_realtek.c",
87862 + .param2 = 1,
87863 +};
87864 +
87865 +struct size_overflow_hash _000979_hash = {
87866 + .next = NULL,
87867 + .name = "nfc_llcp_build_tlv",
87868 + .file = "net/nfc/llcp/commands.c",
87869 + .param3 = 1,
87870 +};
87871 +
87872 +struct size_overflow_hash _000980_hash = {
87873 + .next = NULL,
87874 + .name = "nfs4_alloc_slots",
87875 + .file = "fs/nfs/nfs4proc.c",
87876 + .param1 = 1,
87877 +};
87878 +
87879 +struct size_overflow_hash _000981_hash = {
87880 + .next = NULL,
87881 + .name = "nfs4_write_cached_acl",
87882 + .file = "fs/nfs/nfs4proc.c",
87883 + .param3 = 1,
87884 +};
87885 +
87886 +struct size_overflow_hash _000982_hash = {
87887 + .next = NULL,
87888 + .name = "nfsctl_transaction_read",
87889 + .file = "fs/nfsd/nfsctl.c",
87890 + .param3 = 1,
87891 +};
87892 +
87893 +struct size_overflow_hash _000983_hash = {
87894 + .next = NULL,
87895 + .name = "nfsctl_transaction_write",
87896 + .file = "fs/nfsd/nfsctl.c",
87897 + .param3 = 1,
87898 +};
87899 +
87900 +struct size_overflow_hash _000984_hash = {
87901 + .next = NULL,
87902 + .name = "nfsd_cache_update",
87903 + .file = "fs/nfsd/nfscache.c",
87904 + .param3 = 1,
87905 +};
87906 +
87907 +struct size_overflow_hash _000985_hash = {
87908 + .next = NULL,
87909 + .name = "nfs_idmap_get_desc",
87910 + .file = "fs/nfs/idmap.c",
87911 + .param2 = 1,
87912 + .param4 = 1,
87913 +};
87914 +
87915 +struct size_overflow_hash _000987_hash = {
87916 + .next = NULL,
87917 + .name = "nfs_readdata_alloc",
87918 + .file = "include/linux/nfs_fs.h",
87919 + .param1 = 1,
87920 +};
87921 +
87922 +struct size_overflow_hash _000988_hash = {
87923 + .next = NULL,
87924 + .name = "nfs_readdir_make_qstr",
87925 + .file = "fs/nfs/dir.c",
87926 + .param3 = 1,
87927 +};
87928 +
87929 +struct size_overflow_hash _000989_hash = {
87930 + .next = NULL,
87931 + .name = "nfs_writedata_alloc",
87932 + .file = "include/linux/nfs_fs.h",
87933 + .param1 = 1,
87934 +};
87935 +
87936 +struct size_overflow_hash _000990_hash = {
87937 + .next = NULL,
87938 + .name = "nsm_create_handle",
87939 + .file = "fs/lockd/mon.c",
87940 + .param4 = 1,
87941 +};
87942 +
87943 +struct size_overflow_hash _000991_hash = {
87944 + .next = NULL,
87945 + .name = "ntfs_copy_from_user",
87946 + .file = "fs/ntfs/file.c",
87947 + .param3 = 1,
87948 + .param5 = 1,
87949 +};
87950 +
87951 +struct size_overflow_hash _000993_hash = {
87952 + .next = NULL,
87953 + .name = "__ntfs_copy_from_user_iovec_inatomic",
87954 + .file = "fs/ntfs/file.c",
87955 + .param3 = 1,
87956 + .param4 = 1,
87957 +};
87958 +
87959 +struct size_overflow_hash _000995_hash = {
87960 + .next = NULL,
87961 + .name = "__ntfs_malloc",
87962 + .file = "fs/ntfs/malloc.h",
87963 + .param1 = 1,
87964 +};
87965 +
87966 +struct size_overflow_hash _000996_hash = {
87967 + .next = NULL,
87968 + .name = "nvme_alloc_iod",
87969 + .file = "drivers/block/nvme.c",
87970 + .param1 = 1,
87971 +};
87972 +
87973 +struct size_overflow_hash _000997_hash = {
87974 + .next = NULL,
87975 + .name = "nvram_write",
87976 + .file = "drivers/char/nvram.c",
87977 + .param3 = 1,
87978 +};
87979 +
87980 +struct size_overflow_hash _000998_hash = {
87981 + .next = NULL,
87982 + .name = "o2hb_debug_read",
87983 + .file = "fs/ocfs2/cluster/heartbeat.c",
87984 + .param3 = 1,
87985 +};
87986 +
87987 +struct size_overflow_hash _000999_hash = {
87988 + .next = NULL,
87989 + .name = "o2net_debug_read",
87990 + .file = "fs/ocfs2/cluster/netdebug.c",
87991 + .param3 = 1,
87992 +};
87993 +
87994 +struct size_overflow_hash _001000_hash = {
87995 + .next = NULL,
87996 + .name = "o2net_send_message_vec",
87997 + .file = "fs/ocfs2/cluster/tcp.c",
87998 + .param4 = 1,
87999 +};
88000 +
88001 +struct size_overflow_hash _001001_hash = {
88002 + .next = NULL,
88003 + .name = "ocfs2_control_cfu",
88004 + .file = "fs/ocfs2/stack_user.c",
88005 + .param2 = 1,
88006 +};
88007 +
88008 +struct size_overflow_hash _001002_hash = {
88009 + .next = NULL,
88010 + .name = "ocfs2_control_read",
88011 + .file = "fs/ocfs2/stack_user.c",
88012 + .param3 = 1,
88013 +};
88014 +
88015 +struct size_overflow_hash _001003_hash = {
88016 + .next = NULL,
88017 + .name = "ocfs2_debug_read",
88018 + .file = "fs/ocfs2/super.c",
88019 + .param3 = 1,
88020 +};
88021 +
88022 +struct size_overflow_hash _001004_hash = {
88023 + .next = NULL,
88024 + .name = "opera1_xilinx_rw",
88025 + .file = "drivers/media/dvb/dvb-usb/opera1.c",
88026 + .param5 = 1,
88027 +};
88028 +
88029 +struct size_overflow_hash _001005_hash = {
88030 + .next = NULL,
88031 + .name = "oprofilefs_str_to_user",
88032 + .file = "include/linux/oprofile.h",
88033 + .param3 = 1,
88034 +};
88035 +
88036 +struct size_overflow_hash _001006_hash = {
88037 + .next = NULL,
88038 + .name = "oprofilefs_ulong_from_user",
88039 + .file = "include/linux/oprofile.h",
88040 + .param3 = 1,
88041 +};
88042 +
88043 +struct size_overflow_hash _001007_hash = {
88044 + .next = &_000626_hash,
88045 + .name = "oprofilefs_ulong_to_user",
88046 + .file = "include/linux/oprofile.h",
88047 + .param3 = 1,
88048 +};
88049 +
88050 +struct size_overflow_hash _001008_hash = {
88051 + .next = NULL,
88052 + .name = "_ore_get_io_state",
88053 + .file = "fs/exofs/ore.c",
88054 + .param3 = 1,
88055 +};
88056 +
88057 +struct size_overflow_hash _001009_hash = {
88058 + .next = NULL,
88059 + .name = "_osd_realloc_seg",
88060 + .file = "drivers/scsi/osd/osd_initiator.c",
88061 + .param3 = 1,
88062 +};
88063 +
88064 +struct size_overflow_hash _001010_hash = {
88065 + .next = NULL,
88066 + .name = "_osd_req_list_objects",
88067 + .file = "drivers/scsi/osd/osd_initiator.c",
88068 + .param6 = 1,
88069 +};
88070 +
88071 +struct size_overflow_hash _001011_hash = {
88072 + .next = NULL,
88073 + .name = "osd_req_read_kern",
88074 + .file = "include/scsi/osd_initiator.h",
88075 + .param5 = 1,
88076 +};
88077 +
88078 +struct size_overflow_hash _001012_hash = {
88079 + .next = NULL,
88080 + .name = "osd_req_write_kern",
88081 + .file = "include/scsi/osd_initiator.h",
88082 + .param5 = 1,
88083 +};
88084 +
88085 +struct size_overflow_hash _001013_hash = {
88086 + .next = NULL,
88087 + .name = "osst_execute",
88088 + .file = "drivers/scsi/osst.c",
88089 + .param6 = 1,
88090 +};
88091 +
88092 +struct size_overflow_hash _001014_hash = {
88093 + .next = NULL,
88094 + .name = "otp_read",
88095 + .file = "drivers/mtd/devices/mtd_dataflash.c",
88096 + .param2 = 1,
88097 + .param5 = 1,
88098 +};
88099 +
88100 +struct size_overflow_hash _001016_hash = {
88101 + .next = NULL,
88102 + .name = "packet_buffer_init",
88103 + .file = "drivers/firewire/nosy.c",
88104 + .param2 = 1,
88105 +};
88106 +
88107 +struct size_overflow_hash _001017_hash = {
88108 + .next = NULL,
88109 + .name = "packet_setsockopt",
88110 + .file = "net/packet/af_packet.c",
88111 + .param5 = 1,
88112 +};
88113 +
88114 +struct size_overflow_hash _001018_hash = {
88115 + .next = NULL,
88116 + .name = "parse_arg",
88117 + .file = "drivers/platform/x86/asus_acpi.c",
88118 + .param2 = 1,
88119 +};
88120 +
88121 +struct size_overflow_hash _001019_hash = {
88122 + .next = NULL,
88123 + .name = "parse_command",
88124 + .file = "fs/binfmt_misc.c",
88125 + .param2 = 1,
88126 +};
88127 +
88128 +struct size_overflow_hash _001020_hash = {
88129 + .next = NULL,
88130 + .name = "pcmcia_replace_cis",
88131 + .file = "drivers/pcmcia/cistpl.c",
88132 + .param3 = 1,
88133 +};
88134 +
88135 +struct size_overflow_hash _001021_hash = {
88136 + .next = NULL,
88137 + .name = "pcnet32_realloc_rx_ring",
88138 + .file = "drivers/net/ethernet/amd/pcnet32.c",
88139 + .param3 = 1,
88140 +};
88141 +
88142 +struct size_overflow_hash _001022_hash = {
88143 + .next = NULL,
88144 + .name = "pcnet32_realloc_tx_ring",
88145 + .file = "drivers/net/ethernet/amd/pcnet32.c",
88146 + .param3 = 1,
88147 +};
88148 +
88149 +struct size_overflow_hash _001023_hash = {
88150 + .next = NULL,
88151 + .name = "pgctrl_write",
88152 + .file = "net/core/pktgen.c",
88153 + .param3 = 1,
88154 +};
88155 +
88156 +struct size_overflow_hash _001024_hash = {
88157 + .next = NULL,
88158 + .name = "pg_read",
88159 + .file = "drivers/block/paride/pg.c",
88160 + .param3 = 1,
88161 +};
88162 +
88163 +struct size_overflow_hash _001025_hash = {
88164 + .next = NULL,
88165 + .name = "pg_write",
88166 + .file = "drivers/block/paride/pg.c",
88167 + .param3 = 1,
88168 +};
88169 +
88170 +struct size_overflow_hash _001026_hash = {
88171 + .next = NULL,
88172 + .name = "picolcd_debug_eeprom_read",
88173 + .file = "drivers/hid/hid-picolcd.c",
88174 + .param3 = 1,
88175 +};
88176 +
88177 +struct size_overflow_hash _001027_hash = {
88178 + .next = NULL,
88179 + .name = "pkt_add",
88180 + .file = "drivers/usb/serial/garmin_gps.c",
88181 + .param3 = 1,
88182 +};
88183 +
88184 +struct size_overflow_hash _001028_hash = {
88185 + .next = NULL,
88186 + .name = "pktgen_if_write",
88187 + .file = "net/core/pktgen.c",
88188 + .param3 = 1,
88189 +};
88190 +
88191 +struct size_overflow_hash _001029_hash = {
88192 + .next = NULL,
88193 + .name = "platform_list_read_file",
88194 + .file = "sound/soc/soc-core.c",
88195 + .param3 = 1,
88196 +};
88197 +
88198 +struct size_overflow_hash _001030_hash = {
88199 + .next = NULL,
88200 + .name = "pm8001_store_update_fw",
88201 + .file = "drivers/scsi/pm8001/pm8001_ctl.c",
88202 + .param4 = 1,
88203 +};
88204 +
88205 +struct size_overflow_hash _001031_hash = {
88206 + .next = NULL,
88207 + .name = "port_show_regs",
88208 + .file = "drivers/tty/serial/mfd.c",
88209 + .param3 = 1,
88210 +};
88211 +
88212 +struct size_overflow_hash _001032_hash = {
88213 + .next = NULL,
88214 + .name = "ppp_cp_parse_cr",
88215 + .file = "drivers/net/wan/hdlc_ppp.c",
88216 + .param4 = 1,
88217 +};
88218 +
88219 +struct size_overflow_hash _001033_hash = {
88220 + .next = NULL,
88221 + .name = "ppp_write",
88222 + .file = "drivers/net/ppp/ppp_generic.c",
88223 + .param3 = 1,
88224 +};
88225 +
88226 +struct size_overflow_hash _001034_hash = {
88227 + .next = NULL,
88228 + .name = "pp_read",
88229 + .file = "drivers/char/ppdev.c",
88230 + .param3 = 1,
88231 +};
88232 +
88233 +struct size_overflow_hash _001035_hash = {
88234 + .next = NULL,
88235 + .name = "pp_write",
88236 + .file = "drivers/char/ppdev.c",
88237 + .param3 = 1,
88238 +};
88239 +
88240 +struct size_overflow_hash _001036_hash = {
88241 + .next = NULL,
88242 + .name = "printer_read",
88243 + .file = "drivers/usb/gadget/printer.c",
88244 + .param3 = 1,
88245 +};
88246 +
88247 +struct size_overflow_hash _001037_hash = {
88248 + .next = NULL,
88249 + .name = "printer_req_alloc",
88250 + .file = "drivers/usb/gadget/printer.c",
88251 + .param2 = 1,
88252 +};
88253 +
88254 +struct size_overflow_hash _001038_hash = {
88255 + .next = NULL,
88256 + .name = "printer_write",
88257 + .file = "drivers/usb/gadget/printer.c",
88258 + .param3 = 1,
88259 +};
88260 +
88261 +struct size_overflow_hash _001039_hash = {
88262 + .next = NULL,
88263 + .name = "prism2_set_genericelement",
88264 + .file = "drivers/net/wireless/hostap/hostap_ioctl.c",
88265 + .param3 = 1,
88266 +};
88267 +
88268 +struct size_overflow_hash _001040_hash = {
88269 + .next = NULL,
88270 + .name = "proc_read",
88271 + .file = "drivers/net/wireless/airo.c",
88272 + .param3 = 1,
88273 +};
88274 +
88275 +struct size_overflow_hash _001041_hash = {
88276 + .next = NULL,
88277 + .name = "proc_scsi_devinfo_write",
88278 + .file = "drivers/scsi/scsi_devinfo.c",
88279 + .param3 = 1,
88280 +};
88281 +
88282 +struct size_overflow_hash _001042_hash = {
88283 + .next = NULL,
88284 + .name = "proc_scsi_write",
88285 + .file = "drivers/scsi/scsi_proc.c",
88286 + .param3 = 1,
88287 +};
88288 +
88289 +struct size_overflow_hash _001043_hash = {
88290 + .next = NULL,
88291 + .name = "proc_scsi_write_proc",
88292 + .file = "drivers/scsi/scsi_proc.c",
88293 + .param3 = 1,
88294 +};
88295 +
88296 +struct size_overflow_hash _001044_hash = {
88297 + .next = NULL,
88298 + .name = "proc_write",
88299 + .file = "drivers/net/wireless/airo.c",
88300 + .param3 = 1,
88301 +};
88302 +
88303 +struct size_overflow_hash _001045_hash = {
88304 + .next = NULL,
88305 + .name = "provide_user_output",
88306 + .file = "fs/ubifs/debug.c",
88307 + .param3 = 1,
88308 +};
88309 +
88310 +struct size_overflow_hash _001046_hash = {
88311 + .next = NULL,
88312 + .name = "ps_pspoll_max_apturn_read",
88313 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88314 + .param3 = 1,
88315 +};
88316 +
88317 +struct size_overflow_hash _001047_hash = {
88318 + .next = NULL,
88319 + .name = "ps_pspoll_timeouts_read",
88320 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88321 + .param3 = 1,
88322 +};
88323 +
88324 +struct size_overflow_hash _001048_hash = {
88325 + .next = NULL,
88326 + .name = "ps_pspoll_utilization_read",
88327 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88328 + .param3 = 1,
88329 +};
88330 +
88331 +struct size_overflow_hash _001049_hash = {
88332 + .next = NULL,
88333 + .name = "ps_upsd_max_apturn_read",
88334 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88335 + .param3 = 1,
88336 +};
88337 +
88338 +struct size_overflow_hash _001050_hash = {
88339 + .next = NULL,
88340 + .name = "ps_upsd_max_sptime_read",
88341 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88342 + .param3 = 1,
88343 +};
88344 +
88345 +struct size_overflow_hash _001051_hash = {
88346 + .next = NULL,
88347 + .name = "ps_upsd_timeouts_read",
88348 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88349 + .param3 = 1,
88350 +};
88351 +
88352 +struct size_overflow_hash _001052_hash = {
88353 + .next = NULL,
88354 + .name = "ps_upsd_utilization_read",
88355 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88356 + .param3 = 1,
88357 +};
88358 +
88359 +struct size_overflow_hash _001053_hash = {
88360 + .next = NULL,
88361 + .name = "pti_char_write",
88362 + .file = "drivers/misc/pti.c",
88363 + .param3 = 1,
88364 +};
88365 +
88366 +struct size_overflow_hash _001054_hash = {
88367 + .next = NULL,
88368 + .name = "pt_read",
88369 + .file = "drivers/block/paride/pt.c",
88370 + .param3 = 1,
88371 +};
88372 +
88373 +struct size_overflow_hash _001055_hash = {
88374 + .next = NULL,
88375 + .name = "pt_write",
88376 + .file = "drivers/block/paride/pt.c",
88377 + .param3 = 1,
88378 +};
88379 +
88380 +struct size_overflow_hash _001056_hash = {
88381 + .next = NULL,
88382 + .name = "pvr2_ioread_read",
88383 + .file = "drivers/media/video/pvrusb2/pvrusb2-ioread.c",
88384 + .param3 = 1,
88385 +};
88386 +
88387 +struct size_overflow_hash _001057_hash = {
88388 + .next = NULL,
88389 + .name = "pvr2_ioread_set_sync_key",
88390 + .file = "drivers/media/video/pvrusb2/pvrusb2-ioread.c",
88391 + .param3 = 1,
88392 +};
88393 +
88394 +struct size_overflow_hash _001058_hash = {
88395 + .next = NULL,
88396 + .name = "pvr2_stream_buffer_count",
88397 + .file = "drivers/media/video/pvrusb2/pvrusb2-io.c",
88398 + .param2 = 1,
88399 +};
88400 +
88401 +struct size_overflow_hash _001059_hash = {
88402 + .next = NULL,
88403 + .name = "pwr_disable_ps_read",
88404 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88405 + .param3 = 1,
88406 +};
88407 +
88408 +struct size_overflow_hash _001060_hash = {
88409 + .next = NULL,
88410 + .name = "pwr_elp_enter_read",
88411 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88412 + .param3 = 1,
88413 +};
88414 +
88415 +struct size_overflow_hash _001061_hash = {
88416 + .next = NULL,
88417 + .name = "pwr_enable_ps_read",
88418 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88419 + .param3 = 1,
88420 +};
88421 +
88422 +struct size_overflow_hash _001062_hash = {
88423 + .next = NULL,
88424 + .name = "pwr_fix_tsf_ps_read",
88425 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88426 + .param3 = 1,
88427 +};
88428 +
88429 +struct size_overflow_hash _001063_hash = {
88430 + .next = NULL,
88431 + .name = "pwr_missing_bcns_read",
88432 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88433 + .param3 = 1,
88434 +};
88435 +
88436 +struct size_overflow_hash _001064_hash = {
88437 + .next = NULL,
88438 + .name = "pwr_power_save_off_read",
88439 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88440 + .param3 = 1,
88441 +};
88442 +
88443 +struct size_overflow_hash _001065_hash = {
88444 + .next = NULL,
88445 + .name = "pwr_ps_enter_read",
88446 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88447 + .param3 = 1,
88448 +};
88449 +
88450 +struct size_overflow_hash _001066_hash = {
88451 + .next = NULL,
88452 + .name = "pwr_rcvd_awake_beacons_read",
88453 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88454 + .param3 = 1,
88455 +};
88456 +
88457 +struct size_overflow_hash _001067_hash = {
88458 + .next = NULL,
88459 + .name = "pwr_rcvd_beacons_read",
88460 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88461 + .param3 = 1,
88462 +};
88463 +
88464 +struct size_overflow_hash _001068_hash = {
88465 + .next = NULL,
88466 + .name = "pwr_tx_without_ps_read",
88467 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88468 + .param3 = 1,
88469 +};
88470 +
88471 +struct size_overflow_hash _001069_hash = {
88472 + .next = NULL,
88473 + .name = "pwr_tx_with_ps_read",
88474 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88475 + .param3 = 1,
88476 +};
88477 +
88478 +struct size_overflow_hash _001070_hash = {
88479 + .next = NULL,
88480 + .name = "pwr_wake_on_host_read",
88481 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88482 + .param3 = 1,
88483 +};
88484 +
88485 +struct size_overflow_hash _001071_hash = {
88486 + .next = NULL,
88487 + .name = "pwr_wake_on_timer_exp_read",
88488 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88489 + .param3 = 1,
88490 +};
88491 +
88492 +struct size_overflow_hash _001072_hash = {
88493 + .next = NULL,
88494 + .name = "qc_capture",
88495 + .file = "drivers/media/video/c-qcam.c",
88496 + .param3 = 1,
88497 +};
88498 +
88499 +struct size_overflow_hash _001073_hash = {
88500 + .next = NULL,
88501 + .name = "qla2x00_get_ctx_bsg_sp",
88502 + .file = "drivers/scsi/qla2xxx/qla_bsg.c",
88503 + .param3 = 1,
88504 +};
88505 +
88506 +struct size_overflow_hash _001074_hash = {
88507 + .next = NULL,
88508 + .name = "qla2x00_get_ctx_sp",
88509 + .file = "drivers/scsi/qla2xxx/qla_init.c",
88510 + .param3 = 1,
88511 +};
88512 +
88513 +struct size_overflow_hash _001075_hash = {
88514 + .next = NULL,
88515 + .name = "qlcnic_alloc_msix_entries",
88516 + .file = "drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c",
88517 + .param2 = 1,
88518 +};
88519 +
88520 +struct size_overflow_hash _001076_hash = {
88521 + .next = NULL,
88522 + .name = "queues_read",
88523 + .file = "net/mac80211/debugfs.c",
88524 + .param3 = 1,
88525 +};
88526 +
88527 +struct size_overflow_hash _001077_hash = {
88528 + .next = NULL,
88529 + .name = "r3964_write",
88530 + .file = "drivers/tty/n_r3964.c",
88531 + .param4 = 1,
88532 +};
88533 +
88534 +struct size_overflow_hash _001078_hash = {
88535 + .next = NULL,
88536 + .name = "raw_setsockopt",
88537 + .file = "net/can/raw.c",
88538 + .param5 = 1,
88539 +};
88540 +
88541 +struct size_overflow_hash _001079_hash = {
88542 + .next = NULL,
88543 + .name = "ray_cs_essid_proc_write",
88544 + .file = "drivers/net/wireless/ray_cs.c",
88545 + .param3 = 1,
88546 +};
88547 +
88548 +struct size_overflow_hash _001080_hash = {
88549 + .next = NULL,
88550 + .name = "rbd_snap_add",
88551 + .file = "drivers/block/rbd.c",
88552 + .param4 = 1,
88553 +};
88554 +
88555 +struct size_overflow_hash _001081_hash = {
88556 + .next = NULL,
88557 + .name = "rcname_read",
88558 + .file = "net/mac80211/rate.c",
88559 + .param3 = 1,
88560 +};
88561 +
88562 +struct size_overflow_hash _001082_hash = {
88563 + .next = NULL,
88564 + .name = "rds_message_alloc",
88565 + .file = "net/rds/message.c",
88566 + .param1 = 1,
88567 +};
88568 +
88569 +struct size_overflow_hash _001083_hash = {
88570 + .next = NULL,
88571 + .name = "rds_page_copy_user",
88572 + .file = "net/rds/page.c",
88573 + .param4 = 1,
88574 +};
88575 +
88576 +struct size_overflow_hash _001084_hash = {
88577 + .next = NULL,
88578 + .name = "read",
88579 + .file = "drivers/pci/hotplug/cpqphp_sysfs.c",
88580 + .param3 = 1,
88581 +};
88582 +
88583 +struct size_overflow_hash _001085_hash = {
88584 + .next = NULL,
88585 + .name = "read_4k_modal_eeprom",
88586 + .file = "drivers/net/wireless/ath/ath9k/htc_drv_debug.c",
88587 + .param3 = 1,
88588 +};
88589 +
88590 +struct size_overflow_hash _001086_hash = {
88591 + .next = NULL,
88592 + .name = "read_9287_modal_eeprom",
88593 + .file = "drivers/net/wireless/ath/ath9k/htc_drv_debug.c",
88594 + .param3 = 1,
88595 +};
88596 +
88597 +struct size_overflow_hash _001087_hash = {
88598 + .next = NULL,
88599 + .name = "read_buf",
88600 + .file = "fs/nfsd/nfs4xdr.c",
88601 + .param2 = 1,
88602 +};
88603 +
88604 +struct size_overflow_hash _001088_hash = {
88605 + .next = NULL,
88606 + .name = "read_cis_cache",
88607 + .file = "drivers/pcmcia/cistpl.c",
88608 + .param4 = 1,
88609 +};
88610 +
88611 +struct size_overflow_hash _001089_hash = {
88612 + .next = NULL,
88613 + .name = "read_def_modal_eeprom",
88614 + .file = "drivers/net/wireless/ath/ath9k/htc_drv_debug.c",
88615 + .param3 = 1,
88616 +};
88617 +
88618 +struct size_overflow_hash _001090_hash = {
88619 + .next = NULL,
88620 + .name = "read_file_ani",
88621 + .file = "drivers/net/wireless/ath/ath5k/debug.c",
88622 + .param3 = 1,
88623 +};
88624 +
88625 +struct size_overflow_hash _001091_hash = {
88626 + .next = NULL,
88627 + .name = "read_file_antenna",
88628 + .file = "drivers/net/wireless/ath/ath5k/debug.c",
88629 + .param3 = 1,
88630 +};
88631 +
88632 +struct size_overflow_hash _001092_hash = {
88633 + .next = NULL,
88634 + .name = "read_file_base_eeprom",
88635 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88636 + .param3 = 1,
88637 +};
88638 +
88639 +struct size_overflow_hash _001093_hash = {
88640 + .next = NULL,
88641 + .name = "read_file_base_eeprom",
88642 + .file = "drivers/net/wireless/ath/ath9k/htc_drv_debug.c",
88643 + .param3 = 1,
88644 +};
88645 +
88646 +struct size_overflow_hash _001094_hash = {
88647 + .next = NULL,
88648 + .name = "read_file_beacon",
88649 + .file = "drivers/net/wireless/ath/ath5k/debug.c",
88650 + .param3 = 1,
88651 +};
88652 +
88653 +struct size_overflow_hash _001095_hash = {
88654 + .next = NULL,
88655 + .name = "read_file_credit_dist_stats",
88656 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
88657 + .param3 = 1,
88658 +};
88659 +
88660 +struct size_overflow_hash _001096_hash = {
88661 + .next = NULL,
88662 + .name = "read_file_debug",
88663 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88664 + .param3 = 1,
88665 +};
88666 +
88667 +struct size_overflow_hash _001097_hash = {
88668 + .next = NULL,
88669 + .name = "read_file_debug",
88670 + .file = "drivers/net/wireless/ath/ath9k/htc_drv_debug.c",
88671 + .param3 = 1,
88672 +};
88673 +
88674 +struct size_overflow_hash _001098_hash = {
88675 + .next = NULL,
88676 + .name = "read_file_debug",
88677 + .file = "drivers/net/wireless/ath/ath5k/debug.c",
88678 + .param3 = 1,
88679 +};
88680 +
88681 +struct size_overflow_hash _001099_hash = {
88682 + .next = NULL,
88683 + .name = "read_file_disable_ani",
88684 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88685 + .param3 = 1,
88686 +};
88687 +
88688 +struct size_overflow_hash _001100_hash = {
88689 + .next = NULL,
88690 + .name = "read_file_dma",
88691 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88692 + .param3 = 1,
88693 +};
88694 +
88695 +struct size_overflow_hash _001101_hash = {
88696 + .next = NULL,
88697 + .name = "read_file_dump_nfcal",
88698 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88699 + .param3 = 1,
88700 +};
88701 +
88702 +struct size_overflow_hash _001102_hash = {
88703 + .next = NULL,
88704 + .name = "read_file_frameerrors",
88705 + .file = "drivers/net/wireless/ath/ath5k/debug.c",
88706 + .param3 = 1,
88707 +};
88708 +
88709 +struct size_overflow_hash _001103_hash = {
88710 + .next = NULL,
88711 + .name = "read_file_interrupt",
88712 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88713 + .param3 = 1,
88714 +};
88715 +
88716 +struct size_overflow_hash _001104_hash = {
88717 + .next = NULL,
88718 + .name = "read_file_misc",
88719 + .file = "drivers/net/wireless/ath/ath5k/debug.c",
88720 + .param3 = 1,
88721 +};
88722 +
88723 +struct size_overflow_hash _001105_hash = {
88724 + .next = NULL,
88725 + .name = "read_file_misc",
88726 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88727 + .param3 = 1,
88728 +};
88729 +
88730 +struct size_overflow_hash _001106_hash = {
88731 + .next = NULL,
88732 + .name = "read_file_modal_eeprom",
88733 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88734 + .param3 = 1,
88735 +};
88736 +
88737 +struct size_overflow_hash _001107_hash = {
88738 + .next = NULL,
88739 + .name = "read_file_queue",
88740 + .file = "drivers/net/wireless/ath/ath5k/debug.c",
88741 + .param3 = 1,
88742 +};
88743 +
88744 +struct size_overflow_hash _001108_hash = {
88745 + .next = NULL,
88746 + .name = "read_file_queue",
88747 + .file = "drivers/net/wireless/ath/ath9k/htc_drv_debug.c",
88748 + .param3 = 1,
88749 +};
88750 +
88751 +struct size_overflow_hash _001109_hash = {
88752 + .next = NULL,
88753 + .name = "read_file_rcstat",
88754 + .file = "drivers/net/wireless/ath/ath9k/rc.c",
88755 + .param3 = 1,
88756 +};
88757 +
88758 +struct size_overflow_hash _001110_hash = {
88759 + .next = NULL,
88760 + .name = "read_file_recv",
88761 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88762 + .param3 = 1,
88763 +};
88764 +
88765 +struct size_overflow_hash _001111_hash = {
88766 + .next = NULL,
88767 + .name = "read_file_recv",
88768 + .file = "drivers/net/wireless/ath/ath9k/htc_drv_debug.c",
88769 + .param3 = 1,
88770 +};
88771 +
88772 +struct size_overflow_hash _001112_hash = {
88773 + .next = NULL,
88774 + .name = "read_file_regidx",
88775 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88776 + .param3 = 1,
88777 +};
88778 +
88779 +struct size_overflow_hash _001113_hash = {
88780 + .next = &_001103_hash,
88781 + .name = "read_file_regval",
88782 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88783 + .param3 = 1,
88784 +};
88785 +
88786 +struct size_overflow_hash _001114_hash = {
88787 + .next = NULL,
88788 + .name = "read_file_rx_chainmask",
88789 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88790 + .param3 = 1,
88791 +};
88792 +
88793 +struct size_overflow_hash _001115_hash = {
88794 + .next = NULL,
88795 + .name = "read_file_slot",
88796 + .file = "drivers/net/wireless/ath/ath9k/htc_drv_debug.c",
88797 + .param3 = 1,
88798 +};
88799 +
88800 +struct size_overflow_hash _001116_hash = {
88801 + .next = NULL,
88802 + .name = "read_file_stations",
88803 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88804 + .param3 = 1,
88805 +};
88806 +
88807 +struct size_overflow_hash _001117_hash = {
88808 + .next = NULL,
88809 + .name = "read_file_tgt_int_stats",
88810 + .file = "drivers/net/wireless/ath/ath9k/htc_drv_debug.c",
88811 + .param3 = 1,
88812 +};
88813 +
88814 +struct size_overflow_hash _001118_hash = {
88815 + .next = NULL,
88816 + .name = "read_file_tgt_rx_stats",
88817 + .file = "drivers/net/wireless/ath/ath9k/htc_drv_debug.c",
88818 + .param3 = 1,
88819 +};
88820 +
88821 +struct size_overflow_hash _001119_hash = {
88822 + .next = NULL,
88823 + .name = "read_file_tgt_stats",
88824 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
88825 + .param3 = 1,
88826 +};
88827 +
88828 +struct size_overflow_hash _001120_hash = {
88829 + .next = NULL,
88830 + .name = "read_file_tgt_tx_stats",
88831 + .file = "drivers/net/wireless/ath/ath9k/htc_drv_debug.c",
88832 + .param3 = 1,
88833 +};
88834 +
88835 +struct size_overflow_hash _001121_hash = {
88836 + .next = NULL,
88837 + .name = "read_file_tx_chainmask",
88838 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88839 + .param3 = 1,
88840 +};
88841 +
88842 +struct size_overflow_hash _001122_hash = {
88843 + .next = NULL,
88844 + .name = "read_file_war_stats",
88845 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
88846 + .param3 = 1,
88847 +};
88848 +
88849 +struct size_overflow_hash _001123_hash = {
88850 + .next = NULL,
88851 + .name = "read_file_wiphy",
88852 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88853 + .param3 = 1,
88854 +};
88855 +
88856 +struct size_overflow_hash _001124_hash = {
88857 + .next = NULL,
88858 + .name = "read_file_xmit",
88859 + .file = "drivers/net/wireless/ath/ath9k/htc_drv_debug.c",
88860 + .param3 = 1,
88861 +};
88862 +
88863 +struct size_overflow_hash _001125_hash = {
88864 + .next = NULL,
88865 + .name = "read_file_xmit",
88866 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88867 + .param3 = 1,
88868 +};
88869 +
88870 +struct size_overflow_hash _001126_hash = {
88871 + .next = NULL,
88872 + .name = "read_flush",
88873 + .file = "net/sunrpc/cache.c",
88874 + .param3 = 1,
88875 +};
88876 +
88877 +struct size_overflow_hash _001127_hash = {
88878 + .next = NULL,
88879 + .name = "realloc_buffer",
88880 + .file = "drivers/scsi/device_handler/scsi_dh_alua.c",
88881 + .param2 = 1,
88882 +};
88883 +
88884 +struct size_overflow_hash _001128_hash = {
88885 + .next = NULL,
88886 + .name = "receive_DataRequest",
88887 + .file = "drivers/block/drbd/drbd_receiver.c",
88888 + .param3 = 1,
88889 +};
88890 +
88891 +struct size_overflow_hash _001129_hash = {
88892 + .next = NULL,
88893 + .name = "recent_mt_proc_write",
88894 + .file = "net/netfilter/xt_recent.c",
88895 + .param3 = 1,
88896 +};
88897 +
88898 +struct size_overflow_hash _001130_hash = {
88899 + .next = NULL,
88900 + .name = "redrat3_transmit_ir",
88901 + .file = "drivers/media/rc/redrat3.c",
88902 + .param3 = 1,
88903 +};
88904 +
88905 +struct size_overflow_hash _001131_hash = {
88906 + .next = NULL,
88907 + .name = "reg_w_buf",
88908 + .file = "drivers/media/video/gspca/t613.c",
88909 + .param3 = 1,
88910 +};
88911 +
88912 +struct size_overflow_hash _001132_hash = {
88913 + .next = NULL,
88914 + .name = "reg_w_ixbuf",
88915 + .file = "drivers/media/video/gspca/t613.c",
88916 + .param4 = 1,
88917 +};
88918 +
88919 +struct size_overflow_hash _001133_hash = {
88920 + .next = NULL,
88921 + .name = "reiserfs_allocate_list_bitmaps",
88922 + .file = "include/linux/reiserfs_fs.h",
88923 + .param3 = 1,
88924 +};
88925 +
88926 +struct size_overflow_hash _001134_hash = {
88927 + .next = NULL,
88928 + .name = "reiserfs_resize",
88929 + .file = "include/linux/reiserfs_fs_sb.h",
88930 + .param2 = 1,
88931 +};
88932 +
88933 +struct size_overflow_hash _001135_hash = {
88934 + .next = NULL,
88935 + .name = "remote_settings_file_write",
88936 + .file = "drivers/misc/ibmasm/ibmasmfs.c",
88937 + .param3 = 1,
88938 +};
88939 +
88940 +struct size_overflow_hash _001136_hash = {
88941 + .next = NULL,
88942 + .name = "_req_append_segment",
88943 + .file = "drivers/scsi/osd/osd_initiator.c",
88944 + .param2 = 1,
88945 +};
88946 +
88947 +struct size_overflow_hash _001137_hash = {
88948 + .next = NULL,
88949 + .name = "retry_count_read",
88950 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88951 + .param3 = 1,
88952 +};
88953 +
88954 +struct size_overflow_hash _001138_hash = {
88955 + .next = NULL,
88956 + .name = "revalidate",
88957 + .file = "drivers/block/aoe/aoechr.c",
88958 + .param2 = 1,
88959 +};
88960 +
88961 +struct size_overflow_hash _001139_hash = {
88962 + .next = NULL,
88963 + .name = "rfcomm_sock_setsockopt",
88964 + .file = "net/bluetooth/rfcomm/sock.c",
88965 + .param5 = 1,
88966 +};
88967 +
88968 +struct size_overflow_hash _001140_hash = {
88969 + .next = NULL,
88970 + .name = "rfkill_fop_read",
88971 + .file = "net/rfkill/core.c",
88972 + .param3 = 1,
88973 +};
88974 +
88975 +struct size_overflow_hash _001141_hash = {
88976 + .next = NULL,
88977 + .name = "rndis_add_response",
88978 + .file = "drivers/usb/gadget/rndis.c",
88979 + .param2 = 1,
88980 +};
88981 +
88982 +struct size_overflow_hash _001142_hash = {
88983 + .next = NULL,
88984 + .name = "rng_dev_read",
88985 + .file = "drivers/char/hw_random/core.c",
88986 + .param3 = 1,
88987 +};
88988 +
88989 +struct size_overflow_hash _001143_hash = {
88990 + .next = NULL,
88991 + .name = "roccat_common_receive",
88992 + .file = "drivers/hid/hid-roccat-common.c",
88993 + .param4 = 1,
88994 +};
88995 +
88996 +struct size_overflow_hash _001144_hash = {
88997 + .next = NULL,
88998 + .name = "roccat_common_send",
88999 + .file = "drivers/hid/hid-roccat-common.c",
89000 + .param4 = 1,
89001 +};
89002 +
89003 +struct size_overflow_hash _001145_hash = {
89004 + .next = NULL,
89005 + .name = "roccat_read",
89006 + .file = "drivers/hid/hid-roccat.c",
89007 + .param3 = 1,
89008 +};
89009 +
89010 +struct size_overflow_hash _001146_hash = {
89011 + .next = NULL,
89012 + .name = "rpc_malloc",
89013 + .file = "include/linux/sunrpc/sched.h",
89014 + .param2 = 1,
89015 +};
89016 +
89017 +struct size_overflow_hash _001147_hash = {
89018 + .next = NULL,
89019 + .name = "rs_sta_dbgfs_rate_scale_data_read",
89020 + .file = "drivers/net/wireless/iwlwifi/iwl-agn-rs.c",
89021 + .param3 = 1,
89022 +};
89023 +
89024 +struct size_overflow_hash _001148_hash = {
89025 + .next = NULL,
89026 + .name = "rs_sta_dbgfs_scale_table_read",
89027 + .file = "drivers/net/wireless/iwlwifi/iwl-agn-rs.c",
89028 + .param3 = 1,
89029 +};
89030 +
89031 +struct size_overflow_hash _001149_hash = {
89032 + .next = NULL,
89033 + .name = "rs_sta_dbgfs_stats_table_read",
89034 + .file = "drivers/net/wireless/iwlwifi/iwl-agn-rs.c",
89035 + .param3 = 1,
89036 +};
89037 +
89038 +struct size_overflow_hash _001150_hash = {
89039 + .next = NULL,
89040 + .name = "rt2x00debug_write_bbp",
89041 + .file = "drivers/net/wireless/rt2x00/rt2x00debug.c",
89042 + .param3 = 1,
89043 +};
89044 +
89045 +struct size_overflow_hash _001151_hash = {
89046 + .next = NULL,
89047 + .name = "rt2x00debug_write_csr",
89048 + .file = "drivers/net/wireless/rt2x00/rt2x00debug.c",
89049 + .param3 = 1,
89050 +};
89051 +
89052 +struct size_overflow_hash _001152_hash = {
89053 + .next = &_000808_hash,
89054 + .name = "rt2x00debug_write_eeprom",
89055 + .file = "drivers/net/wireless/rt2x00/rt2x00debug.c",
89056 + .param3 = 1,
89057 +};
89058 +
89059 +struct size_overflow_hash _001153_hash = {
89060 + .next = NULL,
89061 + .name = "rt2x00debug_write_rf",
89062 + .file = "drivers/net/wireless/rt2x00/rt2x00debug.c",
89063 + .param3 = 1,
89064 +};
89065 +
89066 +struct size_overflow_hash _001154_hash = {
89067 + .next = NULL,
89068 + .name = "rts51x_read_mem",
89069 + .file = "drivers/usb/storage/realtek_cr.c",
89070 + .param4 = 1,
89071 +};
89072 +
89073 +struct size_overflow_hash _001155_hash = {
89074 + .next = NULL,
89075 + .name = "rts51x_write_mem",
89076 + .file = "drivers/usb/storage/realtek_cr.c",
89077 + .param4 = 1,
89078 +};
89079 +
89080 +struct size_overflow_hash _001156_hash = {
89081 + .next = NULL,
89082 + .name = "rts_threshold_read",
89083 + .file = "net/wireless/debugfs.c",
89084 + .param3 = 1,
89085 +};
89086 +
89087 +struct size_overflow_hash _001157_hash = {
89088 + .next = NULL,
89089 + .name = "rx_dropped_read",
89090 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89091 + .param3 = 1,
89092 +};
89093 +
89094 +struct size_overflow_hash _001158_hash = {
89095 + .next = NULL,
89096 + .name = "rx_fcs_err_read",
89097 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89098 + .param3 = 1,
89099 +};
89100 +
89101 +struct size_overflow_hash _001159_hash = {
89102 + .next = NULL,
89103 + .name = "rx_hdr_overflow_read",
89104 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89105 + .param3 = 1,
89106 +};
89107 +
89108 +struct size_overflow_hash _001160_hash = {
89109 + .next = NULL,
89110 + .name = "rx_hw_stuck_read",
89111 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89112 + .param3 = 1,
89113 +};
89114 +
89115 +struct size_overflow_hash _001161_hash = {
89116 + .next = NULL,
89117 + .name = "rx_out_of_mem_read",
89118 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89119 + .param3 = 1,
89120 +};
89121 +
89122 +struct size_overflow_hash _001162_hash = {
89123 + .next = NULL,
89124 + .name = "rx_path_reset_read",
89125 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89126 + .param3 = 1,
89127 +};
89128 +
89129 +struct size_overflow_hash _001163_hash = {
89130 + .next = NULL,
89131 + .name = "rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read",
89132 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89133 + .param3 = 1,
89134 +};
89135 +
89136 +struct size_overflow_hash _001164_hash = {
89137 + .next = NULL,
89138 + .name = "rxpipe_descr_host_int_trig_rx_data_read",
89139 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89140 + .param3 = 1,
89141 +};
89142 +
89143 +struct size_overflow_hash _001165_hash = {
89144 + .next = NULL,
89145 + .name = "rxpipe_missed_beacon_host_int_trig_rx_data_read",
89146 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89147 + .param3 = 1,
89148 +};
89149 +
89150 +struct size_overflow_hash _001166_hash = {
89151 + .next = NULL,
89152 + .name = "rxpipe_rx_prep_beacon_drop_read",
89153 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89154 + .param3 = 1,
89155 +};
89156 +
89157 +struct size_overflow_hash _001167_hash = {
89158 + .next = NULL,
89159 + .name = "rxpipe_tx_xfr_host_int_trig_rx_data_read",
89160 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89161 + .param3 = 1,
89162 +};
89163 +
89164 +struct size_overflow_hash _001168_hash = {
89165 + .next = NULL,
89166 + .name = "rx_reset_counter_read",
89167 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89168 + .param3 = 1,
89169 +};
89170 +
89171 +struct size_overflow_hash _001169_hash = {
89172 + .next = NULL,
89173 + .name = "rx_xfr_hint_trig_read",
89174 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89175 + .param3 = 1,
89176 +};
89177 +
89178 +struct size_overflow_hash _001170_hash = {
89179 + .next = NULL,
89180 + .name = "saa7164_buffer_alloc_user",
89181 + .file = "drivers/media/video/saa7164/saa7164-buffer.c",
89182 + .param2 = 1,
89183 +};
89184 +
89185 +struct size_overflow_hash _001171_hash = {
89186 + .next = NULL,
89187 + .name = "scsi_execute",
89188 + .file = "include/scsi/scsi_device.h",
89189 + .param5 = 1,
89190 +};
89191 +
89192 +struct size_overflow_hash _001172_hash = {
89193 + .next = NULL,
89194 + .name = "scsi_tgt_copy_sense",
89195 + .file = "drivers/scsi/scsi_tgt_lib.c",
89196 + .param3 = 1,
89197 +};
89198 +
89199 +struct size_overflow_hash _001173_hash = {
89200 + .next = NULL,
89201 + .name = "sctp_auth_create_key",
89202 + .file = "net/sctp/auth.c",
89203 + .param1 = 1,
89204 +};
89205 +
89206 +struct size_overflow_hash _001174_hash = {
89207 + .next = NULL,
89208 + .name = "sctp_make_abort_user",
89209 + .file = "include/net/sctp/sm.h",
89210 + .param3 = 1,
89211 +};
89212 +
89213 +struct size_overflow_hash _001175_hash = {
89214 + .next = NULL,
89215 + .name = "sctpprobe_read",
89216 + .file = "net/sctp/probe.c",
89217 + .param3 = 1,
89218 +};
89219 +
89220 +struct size_overflow_hash _001176_hash = {
89221 + .next = NULL,
89222 + .name = "sctp_setsockopt_active_key",
89223 + .file = "net/sctp/socket.c",
89224 + .param3 = 1,
89225 +};
89226 +
89227 +struct size_overflow_hash _001177_hash = {
89228 + .next = NULL,
89229 + .name = "sctp_setsockopt_adaptation_layer",
89230 + .file = "net/sctp/socket.c",
89231 + .param3 = 1,
89232 +};
89233 +
89234 +struct size_overflow_hash _001178_hash = {
89235 + .next = NULL,
89236 + .name = "sctp_setsockopt_associnfo",
89237 + .file = "net/sctp/socket.c",
89238 + .param3 = 1,
89239 +};
89240 +
89241 +struct size_overflow_hash _001179_hash = {
89242 + .next = NULL,
89243 + .name = "sctp_setsockopt_auth_chunk",
89244 + .file = "net/sctp/socket.c",
89245 + .param3 = 1,
89246 +};
89247 +
89248 +struct size_overflow_hash _001180_hash = {
89249 + .next = NULL,
89250 + .name = "sctp_setsockopt_auth_key",
89251 + .file = "net/sctp/socket.c",
89252 + .param3 = 1,
89253 +};
89254 +
89255 +struct size_overflow_hash _001181_hash = {
89256 + .next = NULL,
89257 + .name = "sctp_setsockopt_autoclose",
89258 + .file = "net/sctp/socket.c",
89259 + .param3 = 1,
89260 +};
89261 +
89262 +struct size_overflow_hash _001182_hash = {
89263 + .next = NULL,
89264 + .name = "sctp_setsockopt_context",
89265 + .file = "net/sctp/socket.c",
89266 + .param3 = 1,
89267 +};
89268 +
89269 +struct size_overflow_hash _001183_hash = {
89270 + .next = NULL,
89271 + .name = "sctp_setsockopt_default_send_param",
89272 + .file = "net/sctp/socket.c",
89273 + .param3 = 1,
89274 +};
89275 +
89276 +struct size_overflow_hash _001184_hash = {
89277 + .next = NULL,
89278 + .name = "sctp_setsockopt_delayed_ack",
89279 + .file = "net/sctp/socket.c",
89280 + .param3 = 1,
89281 +};
89282 +
89283 +struct size_overflow_hash _001185_hash = {
89284 + .next = NULL,
89285 + .name = "sctp_setsockopt_del_key",
89286 + .file = "net/sctp/socket.c",
89287 + .param3 = 1,
89288 +};
89289 +
89290 +struct size_overflow_hash _001186_hash = {
89291 + .next = NULL,
89292 + .name = "sctp_setsockopt_events",
89293 + .file = "net/sctp/socket.c",
89294 + .param3 = 1,
89295 +};
89296 +
89297 +struct size_overflow_hash _001187_hash = {
89298 + .next = NULL,
89299 + .name = "sctp_setsockopt_hmac_ident",
89300 + .file = "net/sctp/socket.c",
89301 + .param3 = 1,
89302 +};
89303 +
89304 +struct size_overflow_hash _001188_hash = {
89305 + .next = NULL,
89306 + .name = "sctp_setsockopt_initmsg",
89307 + .file = "net/sctp/socket.c",
89308 + .param3 = 1,
89309 +};
89310 +
89311 +struct size_overflow_hash _001189_hash = {
89312 + .next = NULL,
89313 + .name = "sctp_setsockopt_maxburst",
89314 + .file = "net/sctp/socket.c",
89315 + .param3 = 1,
89316 +};
89317 +
89318 +struct size_overflow_hash _001190_hash = {
89319 + .next = NULL,
89320 + .name = "sctp_setsockopt_maxseg",
89321 + .file = "net/sctp/socket.c",
89322 + .param3 = 1,
89323 +};
89324 +
89325 +struct size_overflow_hash _001191_hash = {
89326 + .next = NULL,
89327 + .name = "sctp_setsockopt_peer_addr_params",
89328 + .file = "net/sctp/socket.c",
89329 + .param3 = 1,
89330 +};
89331 +
89332 +struct size_overflow_hash _001192_hash = {
89333 + .next = NULL,
89334 + .name = "sctp_setsockopt_peer_primary_addr",
89335 + .file = "net/sctp/socket.c",
89336 + .param3 = 1,
89337 +};
89338 +
89339 +struct size_overflow_hash _001193_hash = {
89340 + .next = NULL,
89341 + .name = "sctp_setsockopt_rtoinfo",
89342 + .file = "net/sctp/socket.c",
89343 + .param3 = 1,
89344 +};
89345 +
89346 +struct size_overflow_hash _001194_hash = {
89347 + .next = NULL,
89348 + .name = "sctp_tsnmap_init",
89349 + .file = "include/net/sctp/tsnmap.h",
89350 + .param2 = 1,
89351 +};
89352 +
89353 +struct size_overflow_hash _001195_hash = {
89354 + .next = NULL,
89355 + .name = "send_control_msg",
89356 + .file = "drivers/media/video/zr364xx.c",
89357 + .param6 = 1,
89358 +};
89359 +
89360 +struct size_overflow_hash _001196_hash = {
89361 + .next = NULL,
89362 + .name = "set_aoe_iflist",
89363 + .file = "drivers/block/aoe/aoenet.c",
89364 + .param2 = 1,
89365 +};
89366 +
89367 +struct size_overflow_hash _001197_hash = {
89368 + .next = NULL,
89369 + .name = "set_registers",
89370 + .file = "drivers/net/usb/pegasus.c",
89371 + .param3 = 1,
89372 +};
89373 +
89374 +struct size_overflow_hash _001198_hash = {
89375 + .next = NULL,
89376 + .name = "setsockopt",
89377 + .file = "net/caif/caif_socket.c",
89378 + .param5 = 1,
89379 +};
89380 +
89381 +struct size_overflow_hash _001199_hash = {
89382 + .next = NULL,
89383 + .name = "setup_req",
89384 + .file = "drivers/usb/gadget/inode.c",
89385 + .param3 = 1,
89386 +};
89387 +
89388 +struct size_overflow_hash _001200_hash = {
89389 + .next = NULL,
89390 + .name = "sfq_alloc",
89391 + .file = "net/sched/sch_sfq.c",
89392 + .param1 = 1,
89393 +};
89394 +
89395 +struct size_overflow_hash _001201_hash = {
89396 + .next = NULL,
89397 + .name = "sgl_map_user_pages",
89398 + .file = "drivers/scsi/st.c",
89399 + .param2 = 1,
89400 +};
89401 +
89402 +struct size_overflow_hash _001202_hash = {
89403 + .next = NULL,
89404 + .name = "short_retry_limit_read",
89405 + .file = "net/wireless/debugfs.c",
89406 + .param3 = 1,
89407 +};
89408 +
89409 +struct size_overflow_hash _001203_hash = {
89410 + .next = NULL,
89411 + .name = "sm501_create_subdev",
89412 + .file = "drivers/mfd/sm501.c",
89413 + .param3 = 1,
89414 + .param4 = 1,
89415 +};
89416 +
89417 +struct size_overflow_hash _001205_hash = {
89418 + .next = NULL,
89419 + .name = "sn9c102_read",
89420 + .file = "drivers/media/video/sn9c102/sn9c102_core.c",
89421 + .param3 = 1,
89422 +};
89423 +
89424 +struct size_overflow_hash _001206_hash = {
89425 + .next = NULL,
89426 + .name = "snd_ac97_pcm_assign",
89427 + .file = "include/sound/ac97_codec.h",
89428 + .param2 = 1,
89429 +};
89430 +
89431 +struct size_overflow_hash _001207_hash = {
89432 + .next = NULL,
89433 + .name = "snd_ctl_elem_user_tlv",
89434 + .file = "sound/core/control.c",
89435 + .param3 = 1,
89436 +};
89437 +
89438 +struct size_overflow_hash _001208_hash = {
89439 + .next = NULL,
89440 + .name = "snd_emu10k1_fx8010_read",
89441 + .file = "sound/pci/emu10k1/emuproc.c",
89442 + .param5 = 1,
89443 +};
89444 +
89445 +struct size_overflow_hash _001209_hash = {
89446 + .next = NULL,
89447 + .name = "snd_es1938_capture_copy",
89448 + .file = "sound/pci/es1938.c",
89449 + .param5 = 1,
89450 +};
89451 +
89452 +struct size_overflow_hash _001210_hash = {
89453 + .next = NULL,
89454 + .name = "snd_gus_dram_peek",
89455 + .file = "sound/isa/gus/gus_dram.c",
89456 + .param4 = 1,
89457 +};
89458 +
89459 +struct size_overflow_hash _001211_hash = {
89460 + .next = NULL,
89461 + .name = "snd_gus_dram_poke",
89462 + .file = "sound/isa/gus/gus_dram.c",
89463 + .param4 = 1,
89464 +};
89465 +
89466 +struct size_overflow_hash _001212_hash = {
89467 + .next = NULL,
89468 + .name = "snd_hdsp_capture_copy",
89469 + .file = "sound/pci/rme9652/hdsp.c",
89470 + .param5 = 1,
89471 +};
89472 +
89473 +struct size_overflow_hash _001213_hash = {
89474 + .next = NULL,
89475 + .name = "snd_hdsp_playback_copy",
89476 + .file = "sound/pci/rme9652/hdsp.c",
89477 + .param5 = 1,
89478 +};
89479 +
89480 +struct size_overflow_hash _001214_hash = {
89481 + .next = NULL,
89482 + .name = "snd_info_entry_write",
89483 + .file = "sound/core/info.c",
89484 + .param3 = 1,
89485 +};
89486 +
89487 +struct size_overflow_hash _001215_hash = {
89488 + .next = NULL,
89489 + .name = "snd_opl4_mem_proc_read",
89490 + .file = "sound/drivers/opl4/opl4_proc.c",
89491 + .param5 = 1,
89492 +};
89493 +
89494 +struct size_overflow_hash _001216_hash = {
89495 + .next = NULL,
89496 + .name = "snd_opl4_mem_proc_write",
89497 + .file = "sound/drivers/opl4/opl4_proc.c",
89498 + .param5 = 1,
89499 +};
89500 +
89501 +struct size_overflow_hash _001217_hash = {
89502 + .next = NULL,
89503 + .name = "snd_pcm_aio_read",
89504 + .file = "sound/core/pcm_native.c",
89505 + .param3 = 1,
89506 +};
89507 +
89508 +struct size_overflow_hash _001218_hash = {
89509 + .next = NULL,
89510 + .name = "snd_pcm_aio_write",
89511 + .file = "sound/core/pcm_native.c",
89512 + .param3 = 1,
89513 +};
89514 +
89515 +struct size_overflow_hash _001219_hash = {
89516 + .next = NULL,
89517 + .name = "snd_pcm_alloc_vmalloc_buffer",
89518 + .file = "drivers/media/video/cx231xx/cx231xx-audio.c",
89519 + .param2 = 1,
89520 +};
89521 +
89522 +struct size_overflow_hash _001220_hash = {
89523 + .next = NULL,
89524 + .name = "snd_pcm_alloc_vmalloc_buffer",
89525 + .file = "drivers/media/video/cx18/cx18-alsa-pcm.c",
89526 + .param2 = 1,
89527 +};
89528 +
89529 +struct size_overflow_hash _001221_hash = {
89530 + .next = NULL,
89531 + .name = "snd_pcm_alloc_vmalloc_buffer",
89532 + .file = "drivers/media/video/em28xx/em28xx-audio.c",
89533 + .param2 = 1,
89534 +};
89535 +
89536 +struct size_overflow_hash _001222_hash = {
89537 + .next = NULL,
89538 + .name = "_snd_pcm_lib_alloc_vmalloc_buffer",
89539 + .file = "include/sound/pcm.h",
89540 + .param2 = 1,
89541 +};
89542 +
89543 +struct size_overflow_hash _001223_hash = {
89544 + .next = NULL,
89545 + .name = "snd_pcm_oss_read1",
89546 + .file = "sound/core/oss/pcm_oss.c",
89547 + .param3 = 1,
89548 +};
89549 +
89550 +struct size_overflow_hash _001224_hash = {
89551 + .next = NULL,
89552 + .name = "snd_pcm_oss_write1",
89553 + .file = "sound/core/oss/pcm_oss.c",
89554 + .param3 = 1,
89555 +};
89556 +
89557 +struct size_overflow_hash _001225_hash = {
89558 + .next = NULL,
89559 + .name = "snd_pcm_oss_write2",
89560 + .file = "sound/core/oss/pcm_oss.c",
89561 + .param3 = 1,
89562 +};
89563 +
89564 +struct size_overflow_hash _001226_hash = {
89565 + .next = NULL,
89566 + .name = "snd_pcm_plugin_build",
89567 + .file = "sound/core/oss/pcm_plugin.c",
89568 + .param5 = 1,
89569 +};
89570 +
89571 +struct size_overflow_hash _001227_hash = {
89572 + .next = NULL,
89573 + .name = "snd_rme9652_capture_copy",
89574 + .file = "sound/pci/rme9652/rme9652.c",
89575 + .param5 = 1,
89576 +};
89577 +
89578 +struct size_overflow_hash _001228_hash = {
89579 + .next = NULL,
89580 + .name = "snd_rme9652_playback_copy",
89581 + .file = "sound/pci/rme9652/rme9652.c",
89582 + .param5 = 1,
89583 +};
89584 +
89585 +struct size_overflow_hash _001229_hash = {
89586 + .next = NULL,
89587 + .name = "snd_soc_hw_bulk_write_raw",
89588 + .file = "sound/soc/soc-io.c",
89589 + .param4 = 1,
89590 +};
89591 +
89592 +struct size_overflow_hash _001230_hash = {
89593 + .next = NULL,
89594 + .name = "snd_usb_ctl_msg",
89595 + .file = "sound/usb/helper.c",
89596 + .param8 = 1,
89597 +};
89598 +
89599 +struct size_overflow_hash _001231_hash = {
89600 + .next = NULL,
89601 + .name = "_sp2d_alloc",
89602 + .file = "fs/exofs/ore_raid.c",
89603 + .param1 = 1,
89604 +};
89605 +
89606 +struct size_overflow_hash _001232_hash = {
89607 + .next = NULL,
89608 + .name = "spidev_message",
89609 + .file = "drivers/spi/spidev.c",
89610 + .param3 = 1,
89611 +};
89612 +
89613 +struct size_overflow_hash _001233_hash = {
89614 + .next = NULL,
89615 + .name = "spidev_write",
89616 + .file = "drivers/spi/spidev.c",
89617 + .param3 = 1,
89618 +};
89619 +
89620 +struct size_overflow_hash _001234_hash = {
89621 + .next = NULL,
89622 + .name = "spi_show_regs",
89623 + .file = "drivers/spi/spi-dw.c",
89624 + .param3 = 1,
89625 +};
89626 +
89627 +struct size_overflow_hash _001235_hash = {
89628 + .next = NULL,
89629 + .name = "srp_alloc_iu",
89630 + .file = "drivers/infiniband/ulp/srp/ib_srp.c",
89631 + .param2 = 1,
89632 +};
89633 +
89634 +struct size_overflow_hash _001236_hash = {
89635 + .next = NULL,
89636 + .name = "srp_iu_pool_alloc",
89637 + .file = "drivers/scsi/libsrp.c",
89638 + .param2 = 1,
89639 +};
89640 +
89641 +struct size_overflow_hash _001237_hash = {
89642 + .next = NULL,
89643 + .name = "srp_ring_alloc",
89644 + .file = "drivers/scsi/libsrp.c",
89645 + .param2 = 1,
89646 +};
89647 +
89648 +struct size_overflow_hash _001238_hash = {
89649 + .next = NULL,
89650 + .name = "sta_agg_status_read",
89651 + .file = "net/mac80211/debugfs_sta.c",
89652 + .param3 = 1,
89653 +};
89654 +
89655 +struct size_overflow_hash _001239_hash = {
89656 + .next = NULL,
89657 + .name = "sta_agg_status_write",
89658 + .file = "net/mac80211/debugfs_sta.c",
89659 + .param3 = 1,
89660 +};
89661 +
89662 +struct size_overflow_hash _001240_hash = {
89663 + .next = NULL,
89664 + .name = "sta_connected_time_read",
89665 + .file = "net/mac80211/debugfs_sta.c",
89666 + .param3 = 1,
89667 +};
89668 +
89669 +struct size_overflow_hash _001241_hash = {
89670 + .next = NULL,
89671 + .name = "sta_flags_read",
89672 + .file = "net/mac80211/debugfs_sta.c",
89673 + .param3 = 1,
89674 +};
89675 +
89676 +struct size_overflow_hash _001242_hash = {
89677 + .next = NULL,
89678 + .name = "sta_ht_capa_read",
89679 + .file = "net/mac80211/debugfs_sta.c",
89680 + .param3 = 1,
89681 +};
89682 +
89683 +struct size_overflow_hash _001243_hash = {
89684 + .next = NULL,
89685 + .name = "sta_last_seq_ctrl_read",
89686 + .file = "net/mac80211/debugfs_sta.c",
89687 + .param3 = 1,
89688 +};
89689 +
89690 +struct size_overflow_hash _001244_hash = {
89691 + .next = NULL,
89692 + .name = "sta_num_ps_buf_frames_read",
89693 + .file = "net/mac80211/debugfs_sta.c",
89694 + .param3 = 1,
89695 +};
89696 +
89697 +struct size_overflow_hash _001245_hash = {
89698 + .next = NULL,
89699 + .name = "stk_prepare_sio_buffers",
89700 + .file = "drivers/media/video/stk-webcam.c",
89701 + .param2 = 1,
89702 +};
89703 +
89704 +struct size_overflow_hash _001246_hash = {
89705 + .next = NULL,
89706 + .name = "store_iwmct_log_level",
89707 + .file = "drivers/misc/iwmc3200top/log.c",
89708 + .param4 = 1,
89709 +};
89710 +
89711 +struct size_overflow_hash _001247_hash = {
89712 + .next = NULL,
89713 + .name = "store_iwmct_log_level_fw",
89714 + .file = "drivers/misc/iwmc3200top/log.c",
89715 + .param4 = 1,
89716 +};
89717 +
89718 +struct size_overflow_hash _001248_hash = {
89719 + .next = NULL,
89720 + .name = "str_to_user",
89721 + .file = "drivers/input/evdev.c",
89722 + .param2 = 1,
89723 +};
89724 +
89725 +struct size_overflow_hash _001249_hash = {
89726 + .next = NULL,
89727 + .name = "svc_pool_map_alloc_arrays",
89728 + .file = "net/sunrpc/svc.c",
89729 + .param2 = 1,
89730 +};
89731 +
89732 +struct size_overflow_hash _001250_hash = {
89733 + .next = NULL,
89734 + .name = "svc_setsockopt",
89735 + .file = "net/atm/svc.c",
89736 + .param5 = 1,
89737 +};
89738 +
89739 +struct size_overflow_hash _001251_hash = {
89740 + .next = NULL,
89741 + .name = "t4_alloc_mem",
89742 + .file = "drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c",
89743 + .param1 = 1,
89744 +};
89745 +
89746 +struct size_overflow_hash _001252_hash = {
89747 + .next = NULL,
89748 + .name = "tda10048_writeregbulk",
89749 + .file = "drivers/media/dvb/frontends/tda10048.c",
89750 + .param4 = 1,
89751 +};
89752 +
89753 +struct size_overflow_hash _001253_hash = {
89754 + .next = NULL,
89755 + .name = "__team_options_register",
89756 + .file = "drivers/net/team/team.c",
89757 + .param3 = 1,
89758 +};
89759 +
89760 +struct size_overflow_hash _001254_hash = {
89761 + .next = NULL,
89762 + .name = "tifm_alloc_adapter",
89763 + .file = "include/linux/tifm.h",
89764 + .param1 = 1,
89765 +};
89766 +
89767 +struct size_overflow_hash _001255_hash = {
89768 + .next = NULL,
89769 + .name = "tipc_subseq_alloc",
89770 + .file = "net/tipc/name_table.c",
89771 + .param1 = 1,
89772 +};
89773 +
89774 +struct size_overflow_hash _001256_hash = {
89775 + .next = NULL,
89776 + .name = "tm6000_read_write_usb",
89777 + .file = "drivers/media/video/tm6000/tm6000-core.c",
89778 + .param7 = 1,
89779 +};
89780 +
89781 +struct size_overflow_hash _001257_hash = {
89782 + .next = NULL,
89783 + .name = "tower_write",
89784 + .file = "drivers/usb/misc/legousbtower.c",
89785 + .param3 = 1,
89786 +};
89787 +
89788 +struct size_overflow_hash _001258_hash = {
89789 + .next = NULL,
89790 + .name = "trusted_instantiate",
89791 + .file = "security/keys/trusted.c",
89792 + .param3 = 1,
89793 +};
89794 +
89795 +struct size_overflow_hash _001259_hash = {
89796 + .next = NULL,
89797 + .name = "trusted_update",
89798 + .file = "security/keys/trusted.c",
89799 + .param3 = 1,
89800 +};
89801 +
89802 +struct size_overflow_hash _001260_hash = {
89803 + .next = NULL,
89804 + .name = "TSS_rawhmac",
89805 + .file = "security/keys/trusted.c",
89806 + .param3 = 1,
89807 +};
89808 +
89809 +struct size_overflow_hash _001261_hash = {
89810 + .next = NULL,
89811 + .name = "tx_internal_desc_overflow_read",
89812 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89813 + .param3 = 1,
89814 +};
89815 +
89816 +struct size_overflow_hash _001262_hash = {
89817 + .next = NULL,
89818 + .name = "tx_queue_len_read",
89819 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89820 + .param3 = 1,
89821 +};
89822 +
89823 +struct size_overflow_hash _001263_hash = {
89824 + .next = NULL,
89825 + .name = "tx_queue_len_read",
89826 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
89827 + .param3 = 1,
89828 +};
89829 +
89830 +struct size_overflow_hash _001264_hash = {
89831 + .next = NULL,
89832 + .name = "tx_queue_status_read",
89833 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89834 + .param3 = 1,
89835 +};
89836 +
89837 +struct size_overflow_hash _001265_hash = {
89838 + .next = NULL,
89839 + .name = "udf_alloc_i_data",
89840 + .file = "fs/udf/inode.c",
89841 + .param2 = 1,
89842 +};
89843 +
89844 +struct size_overflow_hash _001266_hash = {
89845 + .next = NULL,
89846 + .name = "udf_sb_alloc_partition_maps",
89847 + .file = "fs/udf/super.c",
89848 + .param2 = 1,
89849 +};
89850 +
89851 +struct size_overflow_hash _001267_hash = {
89852 + .next = NULL,
89853 + .name = "uea_idma_write",
89854 + .file = "drivers/usb/atm/ueagle-atm.c",
89855 + .param3 = 1,
89856 +};
89857 +
89858 +struct size_overflow_hash _001268_hash = {
89859 + .next = NULL,
89860 + .name = "uea_request",
89861 + .file = "drivers/usb/atm/ueagle-atm.c",
89862 + .param4 = 1,
89863 +};
89864 +
89865 +struct size_overflow_hash _001269_hash = {
89866 + .next = NULL,
89867 + .name = "uea_send_modem_cmd",
89868 + .file = "drivers/usb/atm/ueagle-atm.c",
89869 + .param3 = 1,
89870 +};
89871 +
89872 +struct size_overflow_hash _001270_hash = {
89873 + .next = NULL,
89874 + .name = "uhci_debug_read",
89875 + .file = "drivers/usb/host/uhci-debug.c",
89876 + .param3 = 1,
89877 +};
89878 +
89879 +struct size_overflow_hash _001271_hash = {
89880 + .next = NULL,
89881 + .name = "uio_read",
89882 + .file = "drivers/uio/uio.c",
89883 + .param3 = 1,
89884 +};
89885 +
89886 +struct size_overflow_hash _001272_hash = {
89887 + .next = NULL,
89888 + .name = "uio_write",
89889 + .file = "drivers/uio/uio.c",
89890 + .param3 = 1,
89891 +};
89892 +
89893 +struct size_overflow_hash _001273_hash = {
89894 + .next = NULL,
89895 + .name = "um_idi_write",
89896 + .file = "drivers/isdn/hardware/eicon/divasi.c",
89897 + .param3 = 1,
89898 +};
89899 +
89900 +struct size_overflow_hash _001274_hash = {
89901 + .next = NULL,
89902 + .name = "unlink_queued",
89903 + .file = "drivers/usb/misc/usbtest.c",
89904 + .param3 = 1,
89905 + .param4 = 1,
89906 +};
89907 +
89908 +struct size_overflow_hash _001275_hash = {
89909 + .next = NULL,
89910 + .name = "us122l_ctl_msg",
89911 + .file = "sound/usb/usx2y/us122l.c",
89912 + .param8 = 1,
89913 +};
89914 +
89915 +struct size_overflow_hash _001276_hash = {
89916 + .next = NULL,
89917 + .name = "usbdev_read",
89918 + .file = "drivers/usb/core/devio.c",
89919 + .param3 = 1,
89920 +};
89921 +
89922 +struct size_overflow_hash _001277_hash = {
89923 + .next = NULL,
89924 + .name = "usblp_read",
89925 + .file = "drivers/usb/class/usblp.c",
89926 + .param3 = 1,
89927 +};
89928 +
89929 +struct size_overflow_hash _001278_hash = {
89930 + .next = NULL,
89931 + .name = "usblp_write",
89932 + .file = "drivers/usb/class/usblp.c",
89933 + .param3 = 1,
89934 +};
89935 +
89936 +struct size_overflow_hash _001279_hash = {
89937 + .next = NULL,
89938 + .name = "usbtest_alloc_urb",
89939 + .file = "drivers/usb/misc/usbtest.c",
89940 + .param3 = 1,
89941 + .param5 = 1,
89942 +};
89943 +
89944 +struct size_overflow_hash _001281_hash = {
89945 + .next = NULL,
89946 + .name = "usbtmc_read",
89947 + .file = "drivers/usb/class/usbtmc.c",
89948 + .param3 = 1,
89949 +};
89950 +
89951 +struct size_overflow_hash _001282_hash = {
89952 + .next = NULL,
89953 + .name = "usbtmc_write",
89954 + .file = "drivers/usb/class/usbtmc.c",
89955 + .param3 = 1,
89956 +};
89957 +
89958 +struct size_overflow_hash _001283_hash = {
89959 + .next = NULL,
89960 + .name = "usbvision_v4l2_read",
89961 + .file = "drivers/media/video/usbvision/usbvision-video.c",
89962 + .param3 = 1,
89963 +};
89964 +
89965 +struct size_overflow_hash _001284_hash = {
89966 + .next = NULL,
89967 + .name = "uvc_alloc_buffers",
89968 + .file = "drivers/usb/gadget/uvc_queue.c",
89969 + .param2 = 1,
89970 +};
89971 +
89972 +struct size_overflow_hash _001285_hash = {
89973 + .next = NULL,
89974 + .name = "uvc_alloc_entity",
89975 + .file = "drivers/media/video/uvc/uvc_driver.c",
89976 + .param3 = 1,
89977 +};
89978 +
89979 +struct size_overflow_hash _001286_hash = {
89980 + .next = NULL,
89981 + .name = "uvc_debugfs_stats_read",
89982 + .file = "drivers/media/video/uvc/uvc_debugfs.c",
89983 + .param3 = 1,
89984 +};
89985 +
89986 +struct size_overflow_hash _001287_hash = {
89987 + .next = NULL,
89988 + .name = "uvc_simplify_fraction",
89989 + .file = "drivers/media/video/uvc/uvc_driver.c",
89990 + .param3 = 1,
89991 +};
89992 +
89993 +struct size_overflow_hash _001288_hash = {
89994 + .next = NULL,
89995 + .name = "uwb_rc_neh_grok_event",
89996 + .file = "drivers/uwb/neh.c",
89997 + .param3 = 1,
89998 +};
89999 +
90000 +struct size_overflow_hash _001289_hash = {
90001 + .next = NULL,
90002 + .name = "v4l2_event_subscribe",
90003 + .file = "include/media/v4l2-event.h",
90004 + .param3 = 1,
90005 +};
90006 +
90007 +struct size_overflow_hash _001290_hash = {
90008 + .next = NULL,
90009 + .name = "v4l_stk_read",
90010 + .file = "drivers/media/video/stk-webcam.c",
90011 + .param3 = 1,
90012 +};
90013 +
90014 +struct size_overflow_hash _001291_hash = {
90015 + .next = NULL,
90016 + .name = "__vb2_perform_fileio",
90017 + .file = "drivers/media/video/videobuf2-core.c",
90018 + .param3 = 1,
90019 +};
90020 +
90021 +struct size_overflow_hash _001292_hash = {
90022 + .next = NULL,
90023 + .name = "vdma_mem_alloc",
90024 + .file = "arch/x86/include/asm/floppy.h",
90025 + .param1 = 1,
90026 +};
90027 +
90028 +struct size_overflow_hash _001293_hash = {
90029 + .next = NULL,
90030 + .name = "vfd_write",
90031 + .file = "drivers/media/rc/imon.c",
90032 + .param3 = 1,
90033 +};
90034 +
90035 +struct size_overflow_hash _001294_hash = {
90036 + .next = NULL,
90037 + .name = "vhci_get_user",
90038 + .file = "drivers/bluetooth/hci_vhci.c",
90039 + .param3 = 1,
90040 +};
90041 +
90042 +struct size_overflow_hash _001295_hash = {
90043 + .next = NULL,
90044 + .name = "__vhost_add_used_n",
90045 + .file = "drivers/vhost/vhost.c",
90046 + .param3 = 1,
90047 +};
90048 +
90049 +struct size_overflow_hash _001296_hash = {
90050 + .next = NULL,
90051 + .name = "__videobuf_alloc_vb",
90052 + .file = "drivers/media/video/videobuf-dma-sg.c",
90053 + .param1 = 1,
90054 +};
90055 +
90056 +struct size_overflow_hash _001297_hash = {
90057 + .next = NULL,
90058 + .name = "__videobuf_alloc_vb",
90059 + .file = "drivers/media/video/videobuf-dma-contig.c",
90060 + .param1 = 1,
90061 +};
90062 +
90063 +struct size_overflow_hash _001298_hash = {
90064 + .next = NULL,
90065 + .name = "__videobuf_alloc_vb",
90066 + .file = "drivers/media/video/videobuf-vmalloc.c",
90067 + .param1 = 1,
90068 +};
90069 +
90070 +struct size_overflow_hash _001299_hash = {
90071 + .next = NULL,
90072 + .name = "__videobuf_copy_to_user",
90073 + .file = "drivers/media/video/videobuf-core.c",
90074 + .param4 = 1,
90075 +};
90076 +
90077 +struct size_overflow_hash _001300_hash = {
90078 + .next = NULL,
90079 + .name = "video_proc_write",
90080 + .file = "drivers/platform/x86/toshiba_acpi.c",
90081 + .param3 = 1,
90082 +};
90083 +
90084 +struct size_overflow_hash _001301_hash = {
90085 + .next = NULL,
90086 + .name = "vifs_state_read",
90087 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90088 + .param3 = 1,
90089 +};
90090 +
90091 +struct size_overflow_hash _001302_hash = {
90092 + .next = NULL,
90093 + .name = "vlsi_alloc_ring",
90094 + .file = "drivers/net/irda/vlsi_ir.c",
90095 + .param3 = 1,
90096 + .param4 = 1,
90097 +};
90098 +
90099 +struct size_overflow_hash _001304_hash = {
90100 + .next = NULL,
90101 + .name = "vol_cdev_direct_write",
90102 + .file = "drivers/mtd/ubi/cdev.c",
90103 + .param3 = 1,
90104 +};
90105 +
90106 +struct size_overflow_hash _001305_hash = {
90107 + .next = NULL,
90108 + .name = "vol_cdev_read",
90109 + .file = "drivers/mtd/ubi/cdev.c",
90110 + .param3 = 1,
90111 +};
90112 +
90113 +struct size_overflow_hash _001306_hash = {
90114 + .next = NULL,
90115 + .name = "vring_add_indirect",
90116 + .file = "drivers/virtio/virtio_ring.c",
90117 + .param3 = 1,
90118 + .param4 = 1,
90119 +};
90120 +
90121 +struct size_overflow_hash _001308_hash = {
90122 + .next = NULL,
90123 + .name = "vring_new_virtqueue",
90124 + .file = "include/linux/virtio_ring.h",
90125 + .param1 = 1,
90126 +};
90127 +
90128 +struct size_overflow_hash _001309_hash = {
90129 + .next = NULL,
90130 + .name = "__vxge_hw_channel_allocate",
90131 + .file = "drivers/net/ethernet/neterion/vxge/vxge-config.c",
90132 + .param3 = 1,
90133 +};
90134 +
90135 +struct size_overflow_hash _001310_hash = {
90136 + .next = NULL,
90137 + .name = "vxge_os_dma_malloc",
90138 + .file = "drivers/net/ethernet/neterion/vxge/vxge-config.h",
90139 + .param2 = 1,
90140 +};
90141 +
90142 +struct size_overflow_hash _001311_hash = {
90143 + .next = NULL,
90144 + .name = "vxge_os_dma_malloc_async",
90145 + .file = "drivers/net/ethernet/neterion/vxge/vxge-config.c",
90146 + .param3 = 1,
90147 +};
90148 +
90149 +struct size_overflow_hash _001312_hash = {
90150 + .next = NULL,
90151 + .name = "w9966_v4l_read",
90152 + .file = "drivers/media/video/w9966.c",
90153 + .param3 = 1,
90154 +};
90155 +
90156 +struct size_overflow_hash _001313_hash = {
90157 + .next = NULL,
90158 + .name = "waiters_read",
90159 + .file = "fs/dlm/debug_fs.c",
90160 + .param3 = 1,
90161 +};
90162 +
90163 +struct size_overflow_hash _001314_hash = {
90164 + .next = NULL,
90165 + .name = "wa_nep_queue",
90166 + .file = "drivers/usb/wusbcore/wa-nep.c",
90167 + .param2 = 1,
90168 +};
90169 +
90170 +struct size_overflow_hash _001315_hash = {
90171 + .next = NULL,
90172 + .name = "__wa_xfer_setup_segs",
90173 + .file = "drivers/usb/wusbcore/wa-xfer.c",
90174 + .param2 = 1,
90175 +};
90176 +
90177 +struct size_overflow_hash _001316_hash = {
90178 + .next = NULL,
90179 + .name = "wdm_read",
90180 + .file = "drivers/usb/class/cdc-wdm.c",
90181 + .param3 = 1,
90182 +};
90183 +
90184 +struct size_overflow_hash _001317_hash = {
90185 + .next = NULL,
90186 + .name = "wdm_write",
90187 + .file = "drivers/usb/class/cdc-wdm.c",
90188 + .param3 = 1,
90189 +};
90190 +
90191 +struct size_overflow_hash _001318_hash = {
90192 + .next = NULL,
90193 + .name = "wep_addr_key_count_read",
90194 + .file = "drivers/net/wireless/wl1251/debugfs.c",
90195 + .param3 = 1,
90196 +};
90197 +
90198 +struct size_overflow_hash _001319_hash = {
90199 + .next = &_000480_hash,
90200 + .name = "wep_decrypt_fail_read",
90201 + .file = "drivers/net/wireless/wl1251/debugfs.c",
90202 + .param3 = 1,
90203 +};
90204 +
90205 +struct size_overflow_hash _001320_hash = {
90206 + .next = NULL,
90207 + .name = "wep_default_key_count_read",
90208 + .file = "drivers/net/wireless/wl1251/debugfs.c",
90209 + .param3 = 1,
90210 +};
90211 +
90212 +struct size_overflow_hash _001321_hash = {
90213 + .next = NULL,
90214 + .name = "wep_interrupt_read",
90215 + .file = "drivers/net/wireless/wl1251/debugfs.c",
90216 + .param3 = 1,
90217 +};
90218 +
90219 +struct size_overflow_hash _001322_hash = {
90220 + .next = NULL,
90221 + .name = "wep_key_not_found_read",
90222 + .file = "drivers/net/wireless/wl1251/debugfs.c",
90223 + .param3 = 1,
90224 +};
90225 +
90226 +struct size_overflow_hash _001323_hash = {
90227 + .next = NULL,
90228 + .name = "wep_packets_read",
90229 + .file = "drivers/net/wireless/wl1251/debugfs.c",
90230 + .param3 = 1,
90231 +};
90232 +
90233 +struct size_overflow_hash _001324_hash = {
90234 + .next = NULL,
90235 + .name = "wiimote_hid_send",
90236 + .file = "drivers/hid/hid-wiimote-core.c",
90237 + .param3 = 1,
90238 +};
90239 +
90240 +struct size_overflow_hash _001325_hash = {
90241 + .next = NULL,
90242 + .name = "wl1271_format_buffer",
90243 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90244 + .param2 = 1,
90245 +};
90246 +
90247 +struct size_overflow_hash _001326_hash = {
90248 + .next = NULL,
90249 + .name = "wl1273_fm_fops_write",
90250 + .file = "drivers/media/radio/radio-wl1273.c",
90251 + .param3 = 1,
90252 +};
90253 +
90254 +struct size_overflow_hash _001327_hash = {
90255 + .next = NULL,
90256 + .name = "wlc_phy_loadsampletable_nphy",
90257 + .file = "drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c",
90258 + .param3 = 1,
90259 +};
90260 +
90261 +struct size_overflow_hash _001328_hash = {
90262 + .next = NULL,
90263 + .name = "wpan_phy_alloc",
90264 + .file = "include/net/wpan-phy.h",
90265 + .param1 = 1,
90266 +};
90267 +
90268 +struct size_overflow_hash _001329_hash = {
90269 + .next = NULL,
90270 + .name = "write_flush",
90271 + .file = "net/sunrpc/cache.c",
90272 + .param3 = 1,
90273 +};
90274 +
90275 +struct size_overflow_hash _001330_hash = {
90276 + .next = NULL,
90277 + .name = "write_rio",
90278 + .file = "drivers/usb/misc/rio500.c",
90279 + .param3 = 1,
90280 +};
90281 +
90282 +struct size_overflow_hash _001331_hash = {
90283 + .next = NULL,
90284 + .name = "wusb_ccm_mac",
90285 + .file = "drivers/usb/wusbcore/crypto.c",
90286 + .param7 = 1,
90287 +};
90288 +
90289 +struct size_overflow_hash _001332_hash = {
90290 + .next = NULL,
90291 + .name = "xfs_attrmulti_attr_set",
90292 + .file = "fs/xfs/xfs_ioctl.c",
90293 + .param4 = 1,
90294 +};
90295 +
90296 +struct size_overflow_hash _001333_hash = {
90297 + .next = NULL,
90298 + .name = "xfs_handle_to_dentry",
90299 + .file = "fs/xfs/xfs_ioctl.c",
90300 + .param3 = 1,
90301 +};
90302 +
90303 +struct size_overflow_hash _001334_hash = {
90304 + .next = NULL,
90305 + .name = "xhci_alloc_stream_info",
90306 + .file = "drivers/usb/host/xhci-mem.c",
90307 + .param3 = 1,
90308 +};
90309 +
90310 +struct size_overflow_hash _001335_hash = {
90311 + .next = NULL,
90312 + .name = "xprt_alloc",
90313 + .file = "include/linux/sunrpc/xprt.h",
90314 + .param2 = 1,
90315 +};
90316 +
90317 +struct size_overflow_hash _001336_hash = {
90318 + .next = NULL,
90319 + .name = "xprt_rdma_allocate",
90320 + .file = "net/sunrpc/xprtrdma/transport.c",
90321 + .param2 = 1,
90322 +};
90323 +
90324 +struct size_overflow_hash _001337_hash = {
90325 + .next = NULL,
90326 + .name = "xt_alloc_table_info",
90327 + .file = "include/linux/netfilter/x_tables.h",
90328 + .param1 = 1,
90329 +};
90330 +
90331 +struct size_overflow_hash _001338_hash = {
90332 + .next = NULL,
90333 + .name = "zd_usb_iowrite16v_async",
90334 + .file = "drivers/net/wireless/zd1211rw/zd_usb.c",
90335 + .param3 = 1,
90336 +};
90337 +
90338 +struct size_overflow_hash _001339_hash = {
90339 + .next = NULL,
90340 + .name = "zd_usb_read_fw",
90341 + .file = "drivers/net/wireless/zd1211rw/zd_usb.c",
90342 + .param4 = 1,
90343 +};
90344 +
90345 +struct size_overflow_hash _001340_hash = {
90346 + .next = NULL,
90347 + .name = "zoran_write",
90348 + .file = "drivers/media/video/zoran/zoran_procfs.c",
90349 + .param3 = 1,
90350 +};
90351 +
90352 +struct size_overflow_hash _001341_hash = {
90353 + .next = NULL,
90354 + .name = "ad7879_spi_multi_read",
90355 + .file = "drivers/input/touchscreen/ad7879-spi.c",
90356 + .param3 = 1,
90357 +};
90358 +
90359 +struct size_overflow_hash _001342_hash = {
90360 + .next = NULL,
90361 + .name = "aes_decrypt_fail_read",
90362 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90363 + .param3 = 1,
90364 +};
90365 +
90366 +struct size_overflow_hash _001343_hash = {
90367 + .next = NULL,
90368 + .name = "aes_decrypt_interrupt_read",
90369 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90370 + .param3 = 1,
90371 +};
90372 +
90373 +struct size_overflow_hash _001344_hash = {
90374 + .next = NULL,
90375 + .name = "aes_decrypt_packets_read",
90376 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90377 + .param3 = 1,
90378 +};
90379 +
90380 +struct size_overflow_hash _001345_hash = {
90381 + .next = NULL,
90382 + .name = "aes_encrypt_fail_read",
90383 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90384 + .param3 = 1,
90385 +};
90386 +
90387 +struct size_overflow_hash _001346_hash = {
90388 + .next = NULL,
90389 + .name = "aes_encrypt_interrupt_read",
90390 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90391 + .param3 = 1,
90392 +};
90393 +
90394 +struct size_overflow_hash _001347_hash = {
90395 + .next = NULL,
90396 + .name = "aes_encrypt_packets_read",
90397 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90398 + .param3 = 1,
90399 +};
90400 +
90401 +struct size_overflow_hash _001348_hash = {
90402 + .next = NULL,
90403 + .name = "afs_cell_create",
90404 + .file = "fs/afs/cell.c",
90405 + .param2 = 1,
90406 +};
90407 +
90408 +struct size_overflow_hash _001349_hash = {
90409 + .next = NULL,
90410 + .name = "agp_create_user_memory",
90411 + .file = "drivers/char/agp/generic.c",
90412 + .param1 = 1,
90413 +};
90414 +
90415 +struct size_overflow_hash _001350_hash = {
90416 + .next = NULL,
90417 + .name = "alg_setsockopt",
90418 + .file = "crypto/af_alg.c",
90419 + .param5 = 1,
90420 +};
90421 +
90422 +struct size_overflow_hash _001351_hash = {
90423 + .next = NULL,
90424 + .name = "alloc_targets",
90425 + .file = "drivers/md/dm-table.c",
90426 + .param2 = 1,
90427 +};
90428 +
90429 +struct size_overflow_hash _001352_hash = {
90430 + .next = NULL,
90431 + .name = "aoechr_write",
90432 + .file = "drivers/block/aoe/aoechr.c",
90433 + .param3 = 1,
90434 +};
90435 +
90436 +struct size_overflow_hash _001353_hash = {
90437 + .next = NULL,
90438 + .name = "ath6kl_cfg80211_connect_event",
90439 + .file = "drivers/net/wireless/ath/ath6kl/cfg80211.c",
90440 + .param7 = 1,
90441 + .param9 = 1,
90442 + .param8 = 1,
90443 +};
90444 +
90445 +struct size_overflow_hash _001356_hash = {
90446 + .next = NULL,
90447 + .name = "ath6kl_mgmt_tx",
90448 + .file = "drivers/net/wireless/ath/ath6kl/cfg80211.c",
90449 + .param9 = 1,
90450 +};
90451 +
90452 +struct size_overflow_hash _001357_hash = {
90453 + .next = NULL,
90454 + .name = "atomic_read_file",
90455 + .file = "arch/x86/oprofile/../../../drivers/oprofile/oprofilefs.c",
90456 + .param3 = 1,
90457 +};
90458 +
90459 +struct size_overflow_hash _001358_hash = {
90460 + .next = NULL,
90461 + .name = "beacon_interval_read",
90462 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90463 + .param3 = 1,
90464 +};
90465 +
90466 +struct size_overflow_hash _001359_hash = {
90467 + .next = NULL,
90468 + .name = "bm_entry_write",
90469 + .file = "fs/binfmt_misc.c",
90470 + .param3 = 1,
90471 +};
90472 +
90473 +struct size_overflow_hash _001360_hash = {
90474 + .next = NULL,
90475 + .name = "bm_init",
90476 + .file = "lib/ts_bm.c",
90477 + .param2 = 1,
90478 +};
90479 +
90480 +struct size_overflow_hash _001361_hash = {
90481 + .next = NULL,
90482 + .name = "bm_register_write",
90483 + .file = "fs/binfmt_misc.c",
90484 + .param3 = 1,
90485 +};
90486 +
90487 +struct size_overflow_hash _001362_hash = {
90488 + .next = NULL,
90489 + .name = "bm_status_write",
90490 + .file = "fs/binfmt_misc.c",
90491 + .param3 = 1,
90492 +};
90493 +
90494 +struct size_overflow_hash _001363_hash = {
90495 + .next = NULL,
90496 + .name = "brn_proc_write",
90497 + .file = "drivers/platform/x86/asus_acpi.c",
90498 + .param3 = 1,
90499 +};
90500 +
90501 +struct size_overflow_hash _001364_hash = {
90502 + .next = NULL,
90503 + .name = "btrfs_map_block",
90504 + .file = "fs/btrfs/volumes.c",
90505 + .param3 = 1,
90506 +};
90507 +
90508 +struct size_overflow_hash _001365_hash = {
90509 + .next = NULL,
90510 + .name = "cache_downcall",
90511 + .file = "net/sunrpc/cache.c",
90512 + .param3 = 1,
90513 +};
90514 +
90515 +struct size_overflow_hash _001366_hash = {
90516 + .next = NULL,
90517 + .name = "cache_slow_downcall",
90518 + .file = "net/sunrpc/cache.c",
90519 + .param2 = 1,
90520 +};
90521 +
90522 +struct size_overflow_hash _001367_hash = {
90523 + .next = NULL,
90524 + .name = "ceph_dns_resolve_name",
90525 + .file = "net/ceph/messenger.c",
90526 + .param1 = 1,
90527 +};
90528 +
90529 +struct size_overflow_hash _001368_hash = {
90530 + .next = NULL,
90531 + .name = "cfg80211_roamed",
90532 + .file = "include/net/cfg80211.h",
90533 + .param5 = 1,
90534 + .param7 = 1,
90535 +};
90536 +
90537 +struct size_overflow_hash _001370_hash = {
90538 + .next = NULL,
90539 + .name = "cifs_readv_from_socket",
90540 + .file = "fs/cifs/connect.c",
90541 + .param3 = 1,
90542 +};
90543 +
90544 +struct size_overflow_hash _001371_hash = {
90545 + .next = NULL,
90546 + .name = "configfs_write_file",
90547 + .file = "fs/configfs/file.c",
90548 + .param3 = 1,
90549 +};
90550 +
90551 +struct size_overflow_hash _001372_hash = {
90552 + .next = &_001370_hash,
90553 + .name = "cpu_type_read",
90554 + .file = "arch/x86/oprofile/../../../drivers/oprofile/oprofile_files.c",
90555 + .param3 = 1,
90556 +};
90557 +
90558 +struct size_overflow_hash _001373_hash = {
90559 + .next = NULL,
90560 + .name = "cx18_copy_mdl_to_user",
90561 + .file = "drivers/media/video/cx18/cx18-fileops.c",
90562 + .param4 = 1,
90563 +};
90564 +
90565 +struct size_overflow_hash _001374_hash = {
90566 + .next = NULL,
90567 + .name = "cxgbi_ddp_reserve",
90568 + .file = "drivers/scsi/cxgbi/libcxgbi.c",
90569 + .param4 = 1,
90570 +};
90571 +
90572 +struct size_overflow_hash _001375_hash = {
90573 + .next = NULL,
90574 + .name = "cxgbi_device_portmap_create",
90575 + .file = "drivers/scsi/cxgbi/libcxgbi.c",
90576 + .param3 = 1,
90577 +};
90578 +
90579 +struct size_overflow_hash _001376_hash = {
90580 + .next = NULL,
90581 + .name = "datablob_hmac_append",
90582 + .file = "security/keys/encrypted-keys/encrypted.c",
90583 + .param3 = 1,
90584 +};
90585 +
90586 +struct size_overflow_hash _001377_hash = {
90587 + .next = NULL,
90588 + .name = "datablob_hmac_verify",
90589 + .file = "security/keys/encrypted-keys/encrypted.c",
90590 + .param4 = 1,
90591 +};
90592 +
90593 +struct size_overflow_hash _001378_hash = {
90594 + .next = NULL,
90595 + .name = "dataflash_read_fact_otp",
90596 + .file = "drivers/mtd/devices/mtd_dataflash.c",
90597 + .param3 = 1,
90598 +};
90599 +
90600 +struct size_overflow_hash _001379_hash = {
90601 + .next = NULL,
90602 + .name = "dataflash_read_user_otp",
90603 + .file = "drivers/mtd/devices/mtd_dataflash.c",
90604 + .param3 = 1,
90605 +};
90606 +
90607 +struct size_overflow_hash _001380_hash = {
90608 + .next = NULL,
90609 + .name = "depth_read",
90610 + .file = "arch/x86/oprofile/../../../drivers/oprofile/oprofile_files.c",
90611 + .param3 = 1,
90612 +};
90613 +
90614 +struct size_overflow_hash _001381_hash = {
90615 + .next = NULL,
90616 + .name = "depth_write",
90617 + .file = "arch/x86/oprofile/../../../drivers/oprofile/oprofile_files.c",
90618 + .param3 = 1,
90619 +};
90620 +
90621 +struct size_overflow_hash _001382_hash = {
90622 + .next = NULL,
90623 + .name = "dev_irnet_write",
90624 + .file = "net/irda/irnet/irnet_ppp.c",
90625 + .param3 = 1,
90626 +};
90627 +
90628 +struct size_overflow_hash _001383_hash = {
90629 + .next = NULL,
90630 + .name = "dev_write",
90631 + .file = "sound/oss/msnd_pinnacle.c",
90632 + .param3 = 1,
90633 +};
90634 +
90635 +struct size_overflow_hash _001384_hash = {
90636 + .next = NULL,
90637 + .name = "dfs_file_read",
90638 + .file = "fs/ubifs/debug.c",
90639 + .param3 = 1,
90640 +};
90641 +
90642 +struct size_overflow_hash _001385_hash = {
90643 + .next = NULL,
90644 + .name = "dfs_file_write",
90645 + .file = "fs/ubifs/debug.c",
90646 + .param3 = 1,
90647 +};
90648 +
90649 +struct size_overflow_hash _001386_hash = {
90650 + .next = NULL,
90651 + .name = "dfs_global_file_read",
90652 + .file = "fs/ubifs/debug.c",
90653 + .param3 = 1,
90654 +};
90655 +
90656 +struct size_overflow_hash _001387_hash = {
90657 + .next = NULL,
90658 + .name = "dfs_global_file_write",
90659 + .file = "fs/ubifs/debug.c",
90660 + .param3 = 1,
90661 +};
90662 +
90663 +struct size_overflow_hash _001388_hash = {
90664 + .next = NULL,
90665 + .name = "disconnect",
90666 + .file = "net/bluetooth/mgmt.c",
90667 + .param4 = 1,
90668 +};
90669 +
90670 +struct size_overflow_hash _001389_hash = {
90671 + .next = NULL,
90672 + .name = "disp_proc_write",
90673 + .file = "drivers/platform/x86/asus_acpi.c",
90674 + .param3 = 1,
90675 +};
90676 +
90677 +struct size_overflow_hash _001390_hash = {
90678 + .next = NULL,
90679 + .name = "dma_rx_errors_read",
90680 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90681 + .param3 = 1,
90682 +};
90683 +
90684 +struct size_overflow_hash _001391_hash = {
90685 + .next = NULL,
90686 + .name = "dma_rx_requested_read",
90687 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90688 + .param3 = 1,
90689 +};
90690 +
90691 +struct size_overflow_hash _001392_hash = {
90692 + .next = NULL,
90693 + .name = "dma_tx_errors_read",
90694 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90695 + .param3 = 1,
90696 +};
90697 +
90698 +struct size_overflow_hash _001393_hash = {
90699 + .next = NULL,
90700 + .name = "dma_tx_requested_read",
90701 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90702 + .param3 = 1,
90703 +};
90704 +
90705 +struct size_overflow_hash _001394_hash = {
90706 + .next = NULL,
90707 + .name = "dm_exception_table_init",
90708 + .file = "drivers/md/dm-snap.c",
90709 + .param2 = 1,
90710 +};
90711 +
90712 +struct size_overflow_hash _001395_hash = {
90713 + .next = NULL,
90714 + .name = "do_dccp_setsockopt",
90715 + .file = "net/dccp/proto.c",
90716 + .param5 = 1,
90717 +};
90718 +
90719 +struct size_overflow_hash _001396_hash = {
90720 + .next = NULL,
90721 + .name = "dtim_interval_read",
90722 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90723 + .param3 = 1,
90724 +};
90725 +
90726 +struct size_overflow_hash _001397_hash = {
90727 + .next = NULL,
90728 + .name = "dvb_audio_write",
90729 + .file = "drivers/media/dvb/ttpci/av7110_av.c",
90730 + .param3 = 1,
90731 +};
90732 +
90733 +struct size_overflow_hash _001398_hash = {
90734 + .next = NULL,
90735 + .name = "dvb_demux_do_ioctl",
90736 + .file = "drivers/media/dvb/dvb-core/dmxdev.c",
90737 + .param3 = 1,
90738 +};
90739 +
90740 +struct size_overflow_hash _001399_hash = {
90741 + .next = NULL,
90742 + .name = "dvb_dvr_do_ioctl",
90743 + .file = "drivers/media/dvb/dvb-core/dmxdev.c",
90744 + .param3 = 1,
90745 +};
90746 +
90747 +struct size_overflow_hash _001400_hash = {
90748 + .next = NULL,
90749 + .name = "dvb_video_write",
90750 + .file = "drivers/media/dvb/ttpci/av7110_av.c",
90751 + .param3 = 1,
90752 +};
90753 +
90754 +struct size_overflow_hash _001401_hash = {
90755 + .next = NULL,
90756 + .name = "ecryptfs_decode_and_decrypt_filename",
90757 + .file = "fs/ecryptfs/crypto.c",
90758 + .param5 = 1,
90759 +};
90760 +
90761 +struct size_overflow_hash _001402_hash = {
90762 + .next = NULL,
90763 + .name = "ecryptfs_encrypt_and_encode_filename",
90764 + .file = "fs/ecryptfs/crypto.c",
90765 + .param6 = 1,
90766 +};
90767 +
90768 +struct size_overflow_hash _001403_hash = {
90769 + .next = NULL,
90770 + .name = "enable_read",
90771 + .file = "arch/x86/oprofile/../../../drivers/oprofile/oprofile_files.c",
90772 + .param3 = 1,
90773 +};
90774 +
90775 +struct size_overflow_hash _001404_hash = {
90776 + .next = NULL,
90777 + .name = "enable_write",
90778 + .file = "arch/x86/oprofile/../../../drivers/oprofile/oprofile_files.c",
90779 + .param3 = 1,
90780 +};
90781 +
90782 +struct size_overflow_hash _001405_hash = {
90783 + .next = NULL,
90784 + .name = "event_calibration_read",
90785 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90786 + .param3 = 1,
90787 +};
90788 +
90789 +struct size_overflow_hash _001406_hash = {
90790 + .next = NULL,
90791 + .name = "event_heart_beat_read",
90792 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90793 + .param3 = 1,
90794 +};
90795 +
90796 +struct size_overflow_hash _001407_hash = {
90797 + .next = NULL,
90798 + .name = "event_oom_late_read",
90799 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90800 + .param3 = 1,
90801 +};
90802 +
90803 +struct size_overflow_hash _001408_hash = {
90804 + .next = NULL,
90805 + .name = "event_phy_transmit_error_read",
90806 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90807 + .param3 = 1,
90808 +};
90809 +
90810 +struct size_overflow_hash _001409_hash = {
90811 + .next = NULL,
90812 + .name = "event_rx_mem_empty_read",
90813 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90814 + .param3 = 1,
90815 +};
90816 +
90817 +struct size_overflow_hash _001410_hash = {
90818 + .next = NULL,
90819 + .name = "event_rx_mismatch_read",
90820 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90821 + .param3 = 1,
90822 +};
90823 +
90824 +struct size_overflow_hash _001411_hash = {
90825 + .next = NULL,
90826 + .name = "event_rx_pool_read",
90827 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90828 + .param3 = 1,
90829 +};
90830 +
90831 +struct size_overflow_hash _001412_hash = {
90832 + .next = NULL,
90833 + .name = "event_tx_stuck_read",
90834 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90835 + .param3 = 1,
90836 +};
90837 +
90838 +struct size_overflow_hash _001413_hash = {
90839 + .next = NULL,
90840 + .name = "excessive_retries_read",
90841 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90842 + .param3 = 1,
90843 +};
90844 +
90845 +struct size_overflow_hash _001414_hash = {
90846 + .next = NULL,
90847 + .name = "exofs_read_kern",
90848 + .file = "fs/exofs/super.c",
90849 + .param6 = 1,
90850 +};
90851 +
90852 +struct size_overflow_hash _001415_hash = {
90853 + .next = NULL,
90854 + .name = "fallback_on_nodma_alloc",
90855 + .file = "drivers/block/floppy.c",
90856 + .param2 = 1,
90857 +};
90858 +
90859 +struct size_overflow_hash _001416_hash = {
90860 + .next = NULL,
90861 + .name = "__feat_register_sp",
90862 + .file = "net/dccp/feat.c",
90863 + .param6 = 1,
90864 +};
90865 +
90866 +struct size_overflow_hash _001417_hash = {
90867 + .next = NULL,
90868 + .name = "ffs_ep0_write",
90869 + .file = "drivers/usb/gadget/f_fs.c",
90870 + .param3 = 1,
90871 +};
90872 +
90873 +struct size_overflow_hash _001418_hash = {
90874 + .next = NULL,
90875 + .name = "ffs_epfile_read",
90876 + .file = "drivers/usb/gadget/f_fs.c",
90877 + .param3 = 1,
90878 +};
90879 +
90880 +struct size_overflow_hash _001419_hash = {
90881 + .next = NULL,
90882 + .name = "ffs_epfile_write",
90883 + .file = "drivers/usb/gadget/f_fs.c",
90884 + .param3 = 1,
90885 +};
90886 +
90887 +struct size_overflow_hash _001420_hash = {
90888 + .next = NULL,
90889 + .name = "frequency_read",
90890 + .file = "net/mac80211/debugfs.c",
90891 + .param3 = 1,
90892 +};
90893 +
90894 +struct size_overflow_hash _001421_hash = {
90895 + .next = NULL,
90896 + .name = "fsm_init",
90897 + .file = "lib/ts_fsm.c",
90898 + .param2 = 1,
90899 +};
90900 +
90901 +struct size_overflow_hash _001422_hash = {
90902 + .next = NULL,
90903 + .name = "garmin_read_process",
90904 + .file = "drivers/usb/serial/garmin_gps.c",
90905 + .param3 = 1,
90906 +};
90907 +
90908 +struct size_overflow_hash _001423_hash = {
90909 + .next = NULL,
90910 + .name = "garp_request_join",
90911 + .file = "include/net/garp.h",
90912 + .param4 = 1,
90913 +};
90914 +
90915 +struct size_overflow_hash _001424_hash = {
90916 + .next = NULL,
90917 + .name = "hcd_alloc_coherent",
90918 + .file = "drivers/usb/core/hcd.c",
90919 + .param5 = 1,
90920 +};
90921 +
90922 +struct size_overflow_hash _001425_hash = {
90923 + .next = NULL,
90924 + .name = "hci_sock_sendmsg",
90925 + .file = "net/bluetooth/hci_sock.c",
90926 + .param4 = 1,
90927 +};
90928 +
90929 +struct size_overflow_hash _001426_hash = {
90930 + .next = NULL,
90931 + .name = "__hwahc_op_set_gtk",
90932 + .file = "drivers/usb/host/hwa-hc.c",
90933 + .param4 = 1,
90934 +};
90935 +
90936 +struct size_overflow_hash _001427_hash = {
90937 + .next = NULL,
90938 + .name = "__hwahc_op_set_ptk",
90939 + .file = "drivers/usb/host/hwa-hc.c",
90940 + .param5 = 1,
90941 +};
90942 +
90943 +struct size_overflow_hash _001428_hash = {
90944 + .next = NULL,
90945 + .name = "ib_send_cm_drep",
90946 + .file = "include/rdma/ib_cm.h",
90947 + .param3 = 1,
90948 +};
90949 +
90950 +struct size_overflow_hash _001429_hash = {
90951 + .next = NULL,
90952 + .name = "ib_send_cm_mra",
90953 + .file = "include/rdma/ib_cm.h",
90954 + .param4 = 1,
90955 +};
90956 +
90957 +struct size_overflow_hash _001430_hash = {
90958 + .next = NULL,
90959 + .name = "ib_send_cm_rtu",
90960 + .file = "include/rdma/ib_cm.h",
90961 + .param3 = 1,
90962 +};
90963 +
90964 +struct size_overflow_hash _001431_hash = {
90965 + .next = NULL,
90966 + .name = "ieee80211_bss_info_update",
90967 + .file = "net/mac80211/scan.c",
90968 + .param4 = 1,
90969 +};
90970 +
90971 +struct size_overflow_hash _001432_hash = {
90972 + .next = NULL,
90973 + .name = "ieee80211_if_read_aid",
90974 + .file = "net/mac80211/debugfs_netdev.c",
90975 + .param3 = 1,
90976 +};
90977 +
90978 +struct size_overflow_hash _001433_hash = {
90979 + .next = NULL,
90980 + .name = "ieee80211_if_read_auto_open_plinks",
90981 + .file = "net/mac80211/debugfs_netdev.c",
90982 + .param3 = 1,
90983 +};
90984 +
90985 +struct size_overflow_hash _001434_hash = {
90986 + .next = NULL,
90987 + .name = "ieee80211_if_read_ave_beacon",
90988 + .file = "net/mac80211/debugfs_netdev.c",
90989 + .param3 = 1,
90990 +};
90991 +
90992 +struct size_overflow_hash _001435_hash = {
90993 + .next = NULL,
90994 + .name = "ieee80211_if_read_bssid",
90995 + .file = "net/mac80211/debugfs_netdev.c",
90996 + .param3 = 1,
90997 +};
90998 +
90999 +struct size_overflow_hash _001436_hash = {
91000 + .next = NULL,
91001 + .name = "ieee80211_if_read_channel_type",
91002 + .file = "net/mac80211/debugfs_netdev.c",
91003 + .param3 = 1,
91004 +};
91005 +
91006 +struct size_overflow_hash _001437_hash = {
91007 + .next = NULL,
91008 + .name = "ieee80211_if_read_dot11MeshConfirmTimeout",
91009 + .file = "net/mac80211/debugfs_netdev.c",
91010 + .param3 = 1,
91011 +};
91012 +
91013 +struct size_overflow_hash _001438_hash = {
91014 + .next = NULL,
91015 + .name = "ieee80211_if_read_dot11MeshGateAnnouncementProtocol",
91016 + .file = "net/mac80211/debugfs_netdev.c",
91017 + .param3 = 1,
91018 +};
91019 +
91020 +struct size_overflow_hash _001439_hash = {
91021 + .next = NULL,
91022 + .name = "ieee80211_if_read_dot11MeshHoldingTimeout",
91023 + .file = "net/mac80211/debugfs_netdev.c",
91024 + .param3 = 1,
91025 +};
91026 +
91027 +struct size_overflow_hash _001440_hash = {
91028 + .next = NULL,
91029 + .name = "ieee80211_if_read_dot11MeshHWMPactivePathTimeout",
91030 + .file = "net/mac80211/debugfs_netdev.c",
91031 + .param3 = 1,
91032 +};
91033 +
91034 +struct size_overflow_hash _001441_hash = {
91035 + .next = NULL,
91036 + .name = "ieee80211_if_read_dot11MeshHWMPmaxPREQretries",
91037 + .file = "net/mac80211/debugfs_netdev.c",
91038 + .param3 = 1,
91039 +};
91040 +
91041 +struct size_overflow_hash _001442_hash = {
91042 + .next = NULL,
91043 + .name = "ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime",
91044 + .file = "net/mac80211/debugfs_netdev.c",
91045 + .param3 = 1,
91046 +};
91047 +
91048 +struct size_overflow_hash _001443_hash = {
91049 + .next = NULL,
91050 + .name = "ieee80211_if_read_dot11MeshHWMPperrMinInterval",
91051 + .file = "net/mac80211/debugfs_netdev.c",
91052 + .param3 = 1,
91053 +};
91054 +
91055 +struct size_overflow_hash _001444_hash = {
91056 + .next = NULL,
91057 + .name = "ieee80211_if_read_dot11MeshHWMPpreqMinInterval",
91058 + .file = "net/mac80211/debugfs_netdev.c",
91059 + .param3 = 1,
91060 +};
91061 +
91062 +struct size_overflow_hash _001445_hash = {
91063 + .next = NULL,
91064 + .name = "ieee80211_if_read_dot11MeshHWMPRannInterval",
91065 + .file = "net/mac80211/debugfs_netdev.c",
91066 + .param3 = 1,
91067 +};
91068 +
91069 +struct size_overflow_hash _001446_hash = {
91070 + .next = NULL,
91071 + .name = "ieee80211_if_read_dot11MeshHWMPRootMode",
91072 + .file = "net/mac80211/debugfs_netdev.c",
91073 + .param3 = 1,
91074 +};
91075 +
91076 +struct size_overflow_hash _001447_hash = {
91077 + .next = NULL,
91078 + .name = "ieee80211_if_read_dot11MeshMaxPeerLinks",
91079 + .file = "net/mac80211/debugfs_netdev.c",
91080 + .param3 = 1,
91081 +};
91082 +
91083 +struct size_overflow_hash _001448_hash = {
91084 + .next = NULL,
91085 + .name = "ieee80211_if_read_dot11MeshMaxRetries",
91086 + .file = "net/mac80211/debugfs_netdev.c",
91087 + .param3 = 1,
91088 +};
91089 +
91090 +struct size_overflow_hash _001449_hash = {
91091 + .next = NULL,
91092 + .name = "ieee80211_if_read_dot11MeshRetryTimeout",
91093 + .file = "net/mac80211/debugfs_netdev.c",
91094 + .param3 = 1,
91095 +};
91096 +
91097 +struct size_overflow_hash _001450_hash = {
91098 + .next = NULL,
91099 + .name = "ieee80211_if_read_dot11MeshTTL",
91100 + .file = "net/mac80211/debugfs_netdev.c",
91101 + .param3 = 1,
91102 +};
91103 +
91104 +struct size_overflow_hash _001451_hash = {
91105 + .next = NULL,
91106 + .name = "ieee80211_if_read_dropped_frames_congestion",
91107 + .file = "net/mac80211/debugfs_netdev.c",
91108 + .param3 = 1,
91109 +};
91110 +
91111 +struct size_overflow_hash _001452_hash = {
91112 + .next = NULL,
91113 + .name = "ieee80211_if_read_dropped_frames_no_route",
91114 + .file = "net/mac80211/debugfs_netdev.c",
91115 + .param3 = 1,
91116 +};
91117 +
91118 +struct size_overflow_hash _001453_hash = {
91119 + .next = NULL,
91120 + .name = "ieee80211_if_read_dropped_frames_ttl",
91121 + .file = "net/mac80211/debugfs_netdev.c",
91122 + .param3 = 1,
91123 +};
91124 +
91125 +struct size_overflow_hash _001454_hash = {
91126 + .next = NULL,
91127 + .name = "ieee80211_if_read_drop_unencrypted",
91128 + .file = "net/mac80211/debugfs_netdev.c",
91129 + .param3 = 1,
91130 +};
91131 +
91132 +struct size_overflow_hash _001455_hash = {
91133 + .next = NULL,
91134 + .name = "ieee80211_if_read_dtim_count",
91135 + .file = "net/mac80211/debugfs_netdev.c",
91136 + .param3 = 1,
91137 +};
91138 +
91139 +struct size_overflow_hash _001456_hash = {
91140 + .next = NULL,
91141 + .name = "ieee80211_if_read_element_ttl",
91142 + .file = "net/mac80211/debugfs_netdev.c",
91143 + .param3 = 1,
91144 +};
91145 +
91146 +struct size_overflow_hash _001457_hash = {
91147 + .next = NULL,
91148 + .name = "ieee80211_if_read_estab_plinks",
91149 + .file = "net/mac80211/debugfs_netdev.c",
91150 + .param3 = 1,
91151 +};
91152 +
91153 +struct size_overflow_hash _001458_hash = {
91154 + .next = NULL,
91155 + .name = "ieee80211_if_read_flags",
91156 + .file = "net/mac80211/debugfs_netdev.c",
91157 + .param3 = 1,
91158 +};
91159 +
91160 +struct size_overflow_hash _001459_hash = {
91161 + .next = NULL,
91162 + .name = "ieee80211_if_read_fwded_frames",
91163 + .file = "net/mac80211/debugfs_netdev.c",
91164 + .param3 = 1,
91165 +};
91166 +
91167 +struct size_overflow_hash _001460_hash = {
91168 + .next = NULL,
91169 + .name = "ieee80211_if_read_fwded_mcast",
91170 + .file = "net/mac80211/debugfs_netdev.c",
91171 + .param3 = 1,
91172 +};
91173 +
91174 +struct size_overflow_hash _001461_hash = {
91175 + .next = NULL,
91176 + .name = "ieee80211_if_read_fwded_unicast",
91177 + .file = "net/mac80211/debugfs_netdev.c",
91178 + .param3 = 1,
91179 +};
91180 +
91181 +struct size_overflow_hash _001462_hash = {
91182 + .next = NULL,
91183 + .name = "ieee80211_if_read_last_beacon",
91184 + .file = "net/mac80211/debugfs_netdev.c",
91185 + .param3 = 1,
91186 +};
91187 +
91188 +struct size_overflow_hash _001463_hash = {
91189 + .next = NULL,
91190 + .name = "ieee80211_if_read_min_discovery_timeout",
91191 + .file = "net/mac80211/debugfs_netdev.c",
91192 + .param3 = 1,
91193 +};
91194 +
91195 +struct size_overflow_hash _001464_hash = {
91196 + .next = NULL,
91197 + .name = "ieee80211_if_read_num_buffered_multicast",
91198 + .file = "net/mac80211/debugfs_netdev.c",
91199 + .param3 = 1,
91200 +};
91201 +
91202 +struct size_overflow_hash _001465_hash = {
91203 + .next = NULL,
91204 + .name = "ieee80211_if_read_num_sta_authorized",
91205 + .file = "net/mac80211/debugfs_netdev.c",
91206 + .param3 = 1,
91207 +};
91208 +
91209 +struct size_overflow_hash _001466_hash = {
91210 + .next = NULL,
91211 + .name = "ieee80211_if_read_num_sta_ps",
91212 + .file = "net/mac80211/debugfs_netdev.c",
91213 + .param3 = 1,
91214 +};
91215 +
91216 +struct size_overflow_hash _001467_hash = {
91217 + .next = NULL,
91218 + .name = "ieee80211_if_read_path_refresh_time",
91219 + .file = "net/mac80211/debugfs_netdev.c",
91220 + .param3 = 1,
91221 +};
91222 +
91223 +struct size_overflow_hash _001468_hash = {
91224 + .next = NULL,
91225 + .name = "ieee80211_if_read_peer",
91226 + .file = "net/mac80211/debugfs_netdev.c",
91227 + .param3 = 1,
91228 +};
91229 +
91230 +struct size_overflow_hash _001469_hash = {
91231 + .next = NULL,
91232 + .name = "ieee80211_if_read_rc_rateidx_mask_2ghz",
91233 + .file = "net/mac80211/debugfs_netdev.c",
91234 + .param3 = 1,
91235 +};
91236 +
91237 +struct size_overflow_hash _001470_hash = {
91238 + .next = NULL,
91239 + .name = "ieee80211_if_read_rc_rateidx_mask_5ghz",
91240 + .file = "net/mac80211/debugfs_netdev.c",
91241 + .param3 = 1,
91242 +};
91243 +
91244 +struct size_overflow_hash _001471_hash = {
91245 + .next = NULL,
91246 + .name = "ieee80211_if_read_smps",
91247 + .file = "net/mac80211/debugfs_netdev.c",
91248 + .param3 = 1,
91249 +};
91250 +
91251 +struct size_overflow_hash _001472_hash = {
91252 + .next = NULL,
91253 + .name = "ieee80211_if_read_state",
91254 + .file = "net/mac80211/debugfs_netdev.c",
91255 + .param3 = 1,
91256 +};
91257 +
91258 +struct size_overflow_hash _001473_hash = {
91259 + .next = NULL,
91260 + .name = "ieee80211_if_read_tkip_mic_test",
91261 + .file = "net/mac80211/debugfs_netdev.c",
91262 + .param3 = 1,
91263 +};
91264 +
91265 +struct size_overflow_hash _001474_hash = {
91266 + .next = NULL,
91267 + .name = "ieee80211_if_read_tsf",
91268 + .file = "net/mac80211/debugfs_netdev.c",
91269 + .param3 = 1,
91270 +};
91271 +
91272 +struct size_overflow_hash _001475_hash = {
91273 + .next = NULL,
91274 + .name = "ieee80211_send_probe_req",
91275 + .file = "net/mac80211/util.c",
91276 + .param6 = 1,
91277 +};
91278 +
91279 +struct size_overflow_hash _001476_hash = {
91280 + .next = NULL,
91281 + .name = "init_map_ipmac",
91282 + .file = "net/netfilter/ipset/ip_set_bitmap_ipmac.c",
91283 + .param3 = 1,
91284 + .param4 = 1,
91285 +};
91286 +
91287 +struct size_overflow_hash _001478_hash = {
91288 + .next = NULL,
91289 + .name = "init_tid_tabs",
91290 + .file = "drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c",
91291 + .param2 = 1,
91292 + .param4 = 1,
91293 + .param3 = 1,
91294 +};
91295 +
91296 +struct size_overflow_hash _001481_hash = {
91297 + .next = NULL,
91298 + .name = "isr_cmd_cmplt_read",
91299 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91300 + .param3 = 1,
91301 +};
91302 +
91303 +struct size_overflow_hash _001482_hash = {
91304 + .next = NULL,
91305 + .name = "isr_commands_read",
91306 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91307 + .param3 = 1,
91308 +};
91309 +
91310 +struct size_overflow_hash _001483_hash = {
91311 + .next = NULL,
91312 + .name = "isr_decrypt_done_read",
91313 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91314 + .param3 = 1,
91315 +};
91316 +
91317 +struct size_overflow_hash _001484_hash = {
91318 + .next = NULL,
91319 + .name = "isr_dma0_done_read",
91320 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91321 + .param3 = 1,
91322 +};
91323 +
91324 +struct size_overflow_hash _001485_hash = {
91325 + .next = NULL,
91326 + .name = "isr_dma1_done_read",
91327 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91328 + .param3 = 1,
91329 +};
91330 +
91331 +struct size_overflow_hash _001486_hash = {
91332 + .next = NULL,
91333 + .name = "isr_fiqs_read",
91334 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91335 + .param3 = 1,
91336 +};
91337 +
91338 +struct size_overflow_hash _001487_hash = {
91339 + .next = NULL,
91340 + .name = "isr_host_acknowledges_read",
91341 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91342 + .param3 = 1,
91343 +};
91344 +
91345 +struct size_overflow_hash _001488_hash = {
91346 + .next = &_001393_hash,
91347 + .name = "isr_hw_pm_mode_changes_read",
91348 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91349 + .param3 = 1,
91350 +};
91351 +
91352 +struct size_overflow_hash _001489_hash = {
91353 + .next = &_001205_hash,
91354 + .name = "isr_irqs_read",
91355 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91356 + .param3 = 1,
91357 +};
91358 +
91359 +struct size_overflow_hash _001490_hash = {
91360 + .next = NULL,
91361 + .name = "isr_low_rssi_read",
91362 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91363 + .param3 = 1,
91364 +};
91365 +
91366 +struct size_overflow_hash _001491_hash = {
91367 + .next = NULL,
91368 + .name = "isr_pci_pm_read",
91369 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91370 + .param3 = 1,
91371 +};
91372 +
91373 +struct size_overflow_hash _001492_hash = {
91374 + .next = NULL,
91375 + .name = "isr_rx_headers_read",
91376 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91377 + .param3 = 1,
91378 +};
91379 +
91380 +struct size_overflow_hash _001493_hash = {
91381 + .next = NULL,
91382 + .name = "isr_rx_mem_overflow_read",
91383 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91384 + .param3 = 1,
91385 +};
91386 +
91387 +struct size_overflow_hash _001494_hash = {
91388 + .next = NULL,
91389 + .name = "isr_rx_procs_read",
91390 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91391 + .param3 = 1,
91392 +};
91393 +
91394 +struct size_overflow_hash _001495_hash = {
91395 + .next = NULL,
91396 + .name = "isr_rx_rdys_read",
91397 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91398 + .param3 = 1,
91399 +};
91400 +
91401 +struct size_overflow_hash _001496_hash = {
91402 + .next = NULL,
91403 + .name = "isr_tx_exch_complete_read",
91404 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91405 + .param3 = 1,
91406 +};
91407 +
91408 +struct size_overflow_hash _001497_hash = {
91409 + .next = NULL,
91410 + .name = "isr_tx_procs_read",
91411 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91412 + .param3 = 1,
91413 +};
91414 +
91415 +struct size_overflow_hash _001498_hash = {
91416 + .next = NULL,
91417 + .name = "isr_wakeups_read",
91418 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91419 + .param3 = 1,
91420 +};
91421 +
91422 +struct size_overflow_hash _001499_hash = {
91423 + .next = NULL,
91424 + .name = "ivtv_read",
91425 + .file = "drivers/media/video/ivtv/ivtv-fileops.c",
91426 + .param3 = 1,
91427 +};
91428 +
91429 +struct size_overflow_hash _001500_hash = {
91430 + .next = NULL,
91431 + .name = "kmem_realloc",
91432 + .file = "fs/xfs/kmem.c",
91433 + .param2 = 1,
91434 +};
91435 +
91436 +struct size_overflow_hash _001501_hash = {
91437 + .next = NULL,
91438 + .name = "kmem_zalloc",
91439 + .file = "fs/xfs/kmem.c",
91440 + .param1 = 1,
91441 +};
91442 +
91443 +struct size_overflow_hash _001502_hash = {
91444 + .next = NULL,
91445 + .name = "kmem_zalloc_greedy",
91446 + .file = "fs/xfs/kmem.c",
91447 + .param2 = 1,
91448 + .param3 = 1,
91449 +};
91450 +
91451 +struct size_overflow_hash _001504_hash = {
91452 + .next = NULL,
91453 + .name = "kmp_init",
91454 + .file = "lib/ts_kmp.c",
91455 + .param2 = 1,
91456 +};
91457 +
91458 +struct size_overflow_hash _001505_hash = {
91459 + .next = NULL,
91460 + .name = "lcd_proc_write",
91461 + .file = "drivers/platform/x86/asus_acpi.c",
91462 + .param3 = 1,
91463 +};
91464 +
91465 +struct size_overflow_hash _001506_hash = {
91466 + .next = NULL,
91467 + .name = "ledd_proc_write",
91468 + .file = "drivers/platform/x86/asus_acpi.c",
91469 + .param3 = 1,
91470 +};
91471 +
91472 +struct size_overflow_hash _001507_hash = {
91473 + .next = NULL,
91474 + .name = "mic_calc_failure_read",
91475 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91476 + .param3 = 1,
91477 +};
91478 +
91479 +struct size_overflow_hash _001508_hash = {
91480 + .next = NULL,
91481 + .name = "mic_rx_pkts_read",
91482 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91483 + .param3 = 1,
91484 +};
91485 +
91486 +struct size_overflow_hash _001509_hash = {
91487 + .next = NULL,
91488 + .name = "nfs4_realloc_slot_table",
91489 + .file = "fs/nfs/nfs4proc.c",
91490 + .param2 = 1,
91491 +};
91492 +
91493 +struct size_overflow_hash _001510_hash = {
91494 + .next = NULL,
91495 + .name = "nfs_idmap_request_key",
91496 + .file = "fs/nfs/idmap.c",
91497 + .param2 = 1,
91498 +};
91499 +
91500 +struct size_overflow_hash _001511_hash = {
91501 + .next = NULL,
91502 + .name = "nsm_get_handle",
91503 + .file = "include/linux/lockd/lockd.h",
91504 + .param4 = 1,
91505 +};
91506 +
91507 +struct size_overflow_hash _001512_hash = {
91508 + .next = NULL,
91509 + .name = "ntfs_copy_from_user_iovec",
91510 + .file = "fs/ntfs/file.c",
91511 + .param3 = 1,
91512 + .param6 = 1,
91513 +};
91514 +
91515 +struct size_overflow_hash _001514_hash = {
91516 + .next = NULL,
91517 + .name = "ntfs_file_buffered_write",
91518 + .file = "fs/ntfs/file.c",
91519 + .param6 = 1,
91520 +};
91521 +
91522 +struct size_overflow_hash _001515_hash = {
91523 + .next = NULL,
91524 + .name = "ntfs_malloc_nofs",
91525 + .file = "fs/ntfs/malloc.h",
91526 + .param1 = 1,
91527 +};
91528 +
91529 +struct size_overflow_hash _001516_hash = {
91530 + .next = NULL,
91531 + .name = "ntfs_malloc_nofs_nofail",
91532 + .file = "fs/ntfs/malloc.h",
91533 + .param1 = 1,
91534 +};
91535 +
91536 +struct size_overflow_hash _001517_hash = {
91537 + .next = NULL,
91538 + .name = "ocfs2_control_message",
91539 + .file = "fs/ocfs2/stack_user.c",
91540 + .param3 = 1,
91541 +};
91542 +
91543 +struct size_overflow_hash _001518_hash = {
91544 + .next = NULL,
91545 + .name = "opera1_usb_i2c_msgxfer",
91546 + .file = "drivers/media/dvb/dvb-usb/opera1.c",
91547 + .param4 = 1,
91548 +};
91549 +
91550 +struct size_overflow_hash _001519_hash = {
91551 + .next = NULL,
91552 + .name = "orinoco_add_extscan_result",
91553 + .file = "drivers/net/wireless/orinoco/scan.c",
91554 + .param3 = 1,
91555 +};
91556 +
91557 +struct size_overflow_hash _001520_hash = {
91558 + .next = NULL,
91559 + .name = "osd_req_list_collection_objects",
91560 + .file = "include/scsi/osd_initiator.h",
91561 + .param5 = 1,
91562 +};
91563 +
91564 +struct size_overflow_hash _001521_hash = {
91565 + .next = NULL,
91566 + .name = "osd_req_list_partition_objects",
91567 + .file = "include/scsi/osd_initiator.h",
91568 + .param5 = 1,
91569 +};
91570 +
91571 +struct size_overflow_hash _001522_hash = {
91572 + .next = NULL,
91573 + .name = "pair_device",
91574 + .file = "net/bluetooth/mgmt.c",
91575 + .param4 = 1,
91576 +};
91577 +
91578 +struct size_overflow_hash _001523_hash = {
91579 + .next = NULL,
91580 + .name = "pccard_store_cis",
91581 + .file = "drivers/pcmcia/cistpl.c",
91582 + .param6 = 1,
91583 +};
91584 +
91585 +struct size_overflow_hash _001524_hash = {
91586 + .next = NULL,
91587 + .name = "pin_code_reply",
91588 + .file = "net/bluetooth/mgmt.c",
91589 + .param4 = 1,
91590 +};
91591 +
91592 +struct size_overflow_hash _001525_hash = {
91593 + .next = NULL,
91594 + .name = "play_iframe",
91595 + .file = "drivers/media/dvb/ttpci/av7110_av.c",
91596 + .param3 = 1,
91597 +};
91598 +
91599 +struct size_overflow_hash _001526_hash = {
91600 + .next = NULL,
91601 + .name = "pointer_size_read",
91602 + .file = "arch/x86/oprofile/../../../drivers/oprofile/oprofile_files.c",
91603 + .param3 = 1,
91604 +};
91605 +
91606 +struct size_overflow_hash _001527_hash = {
91607 + .next = NULL,
91608 + .name = "power_read",
91609 + .file = "net/mac80211/debugfs.c",
91610 + .param3 = 1,
91611 +};
91612 +
91613 +struct size_overflow_hash _001528_hash = {
91614 + .next = NULL,
91615 + .name = "ps_pspoll_max_apturn_read",
91616 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91617 + .param3 = 1,
91618 +};
91619 +
91620 +struct size_overflow_hash _001529_hash = {
91621 + .next = NULL,
91622 + .name = "ps_pspoll_timeouts_read",
91623 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91624 + .param3 = 1,
91625 +};
91626 +
91627 +struct size_overflow_hash _001530_hash = {
91628 + .next = NULL,
91629 + .name = "ps_pspoll_utilization_read",
91630 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91631 + .param3 = 1,
91632 +};
91633 +
91634 +struct size_overflow_hash _001531_hash = {
91635 + .next = NULL,
91636 + .name = "ps_upsd_max_apturn_read",
91637 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91638 + .param3 = 1,
91639 +};
91640 +
91641 +struct size_overflow_hash _001532_hash = {
91642 + .next = NULL,
91643 + .name = "ps_upsd_max_sptime_read",
91644 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91645 + .param3 = 1,
91646 +};
91647 +
91648 +struct size_overflow_hash _001533_hash = {
91649 + .next = NULL,
91650 + .name = "ps_upsd_timeouts_read",
91651 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91652 + .param3 = 1,
91653 +};
91654 +
91655 +struct size_overflow_hash _001534_hash = {
91656 + .next = NULL,
91657 + .name = "ps_upsd_utilization_read",
91658 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91659 + .param3 = 1,
91660 +};
91661 +
91662 +struct size_overflow_hash _001535_hash = {
91663 + .next = NULL,
91664 + .name = "pwr_disable_ps_read",
91665 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91666 + .param3 = 1,
91667 +};
91668 +
91669 +struct size_overflow_hash _001536_hash = {
91670 + .next = NULL,
91671 + .name = "pwr_elp_enter_read",
91672 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91673 + .param3 = 1,
91674 +};
91675 +
91676 +struct size_overflow_hash _001537_hash = {
91677 + .next = NULL,
91678 + .name = "pwr_enable_ps_read",
91679 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91680 + .param3 = 1,
91681 +};
91682 +
91683 +struct size_overflow_hash _001538_hash = {
91684 + .next = NULL,
91685 + .name = "pwr_fix_tsf_ps_read",
91686 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91687 + .param3 = 1,
91688 +};
91689 +
91690 +struct size_overflow_hash _001539_hash = {
91691 + .next = NULL,
91692 + .name = "pwr_missing_bcns_read",
91693 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91694 + .param3 = 1,
91695 +};
91696 +
91697 +struct size_overflow_hash _001540_hash = {
91698 + .next = NULL,
91699 + .name = "pwr_power_save_off_read",
91700 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91701 + .param3 = 1,
91702 +};
91703 +
91704 +struct size_overflow_hash _001541_hash = {
91705 + .next = NULL,
91706 + .name = "pwr_ps_enter_read",
91707 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91708 + .param3 = 1,
91709 +};
91710 +
91711 +struct size_overflow_hash _001542_hash = {
91712 + .next = NULL,
91713 + .name = "pwr_rcvd_awake_beacons_read",
91714 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91715 + .param3 = 1,
91716 +};
91717 +
91718 +struct size_overflow_hash _001543_hash = {
91719 + .next = NULL,
91720 + .name = "pwr_rcvd_beacons_read",
91721 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91722 + .param3 = 1,
91723 +};
91724 +
91725 +struct size_overflow_hash _001544_hash = {
91726 + .next = NULL,
91727 + .name = "pwr_tx_without_ps_read",
91728 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91729 + .param3 = 1,
91730 +};
91731 +
91732 +struct size_overflow_hash _001545_hash = {
91733 + .next = NULL,
91734 + .name = "pwr_tx_with_ps_read",
91735 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91736 + .param3 = 1,
91737 +};
91738 +
91739 +struct size_overflow_hash _001546_hash = {
91740 + .next = NULL,
91741 + .name = "pwr_wake_on_host_read",
91742 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91743 + .param3 = 1,
91744 +};
91745 +
91746 +struct size_overflow_hash _001547_hash = {
91747 + .next = NULL,
91748 + .name = "pwr_wake_on_timer_exp_read",
91749 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91750 + .param3 = 1,
91751 +};
91752 +
91753 +struct size_overflow_hash _001548_hash = {
91754 + .next = NULL,
91755 + .name = "qcam_read",
91756 + .file = "drivers/media/video/c-qcam.c",
91757 + .param3 = 1,
91758 +};
91759 +
91760 +struct size_overflow_hash _001549_hash = {
91761 + .next = NULL,
91762 + .name = "retry_count_read",
91763 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91764 + .param3 = 1,
91765 +};
91766 +
91767 +struct size_overflow_hash _001550_hash = {
91768 + .next = NULL,
91769 + .name = "rx_dropped_read",
91770 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91771 + .param3 = 1,
91772 +};
91773 +
91774 +struct size_overflow_hash _001551_hash = {
91775 + .next = NULL,
91776 + .name = "rx_fcs_err_read",
91777 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91778 + .param3 = 1,
91779 +};
91780 +
91781 +struct size_overflow_hash _001552_hash = {
91782 + .next = NULL,
91783 + .name = "rx_hdr_overflow_read",
91784 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91785 + .param3 = 1,
91786 +};
91787 +
91788 +struct size_overflow_hash _001553_hash = {
91789 + .next = NULL,
91790 + .name = "rx_hw_stuck_read",
91791 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91792 + .param3 = 1,
91793 +};
91794 +
91795 +struct size_overflow_hash _001554_hash = {
91796 + .next = NULL,
91797 + .name = "rx_out_of_mem_read",
91798 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91799 + .param3 = 1,
91800 +};
91801 +
91802 +struct size_overflow_hash _001555_hash = {
91803 + .next = NULL,
91804 + .name = "rx_path_reset_read",
91805 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91806 + .param3 = 1,
91807 +};
91808 +
91809 +struct size_overflow_hash _001556_hash = {
91810 + .next = NULL,
91811 + .name = "rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read",
91812 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91813 + .param3 = 1,
91814 +};
91815 +
91816 +struct size_overflow_hash _001557_hash = {
91817 + .next = NULL,
91818 + .name = "rxpipe_descr_host_int_trig_rx_data_read",
91819 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91820 + .param3 = 1,
91821 +};
91822 +
91823 +struct size_overflow_hash _001558_hash = {
91824 + .next = NULL,
91825 + .name = "rxpipe_missed_beacon_host_int_trig_rx_data_read",
91826 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91827 + .param3 = 1,
91828 +};
91829 +
91830 +struct size_overflow_hash _001559_hash = {
91831 + .next = NULL,
91832 + .name = "rxpipe_rx_prep_beacon_drop_read",
91833 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91834 + .param3 = 1,
91835 +};
91836 +
91837 +struct size_overflow_hash _001560_hash = {
91838 + .next = NULL,
91839 + .name = "rxpipe_tx_xfr_host_int_trig_rx_data_read",
91840 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91841 + .param3 = 1,
91842 +};
91843 +
91844 +struct size_overflow_hash _001561_hash = {
91845 + .next = NULL,
91846 + .name = "rx_reset_counter_read",
91847 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91848 + .param3 = 1,
91849 +};
91850 +
91851 +struct size_overflow_hash _001562_hash = {
91852 + .next = NULL,
91853 + .name = "rx_streaming_always_read",
91854 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91855 + .param3 = 1,
91856 +};
91857 +
91858 +struct size_overflow_hash _001563_hash = {
91859 + .next = NULL,
91860 + .name = "rx_streaming_interval_read",
91861 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91862 + .param3 = 1,
91863 +};
91864 +
91865 +struct size_overflow_hash _001564_hash = {
91866 + .next = NULL,
91867 + .name = "rx_xfr_hint_trig_read",
91868 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91869 + .param3 = 1,
91870 +};
91871 +
91872 +struct size_overflow_hash _001565_hash = {
91873 + .next = NULL,
91874 + .name = "scsi_execute_req",
91875 + .file = "include/scsi/scsi_device.h",
91876 + .param5 = 1,
91877 +};
91878 +
91879 +struct size_overflow_hash _001566_hash = {
91880 + .next = NULL,
91881 + .name = "scsi_tgt_kspace_exec",
91882 + .file = "drivers/scsi/scsi_tgt_lib.c",
91883 + .param8 = 1,
91884 +};
91885 +
91886 +struct size_overflow_hash _001567_hash = {
91887 + .next = NULL,
91888 + .name = "sctp_sendmsg",
91889 + .file = "net/sctp/socket.c",
91890 + .param4 = 1,
91891 +};
91892 +
91893 +struct size_overflow_hash _001568_hash = {
91894 + .next = NULL,
91895 + .name = "sctp_setsockopt",
91896 + .file = "net/sctp/socket.c",
91897 + .param5 = 1,
91898 +};
91899 +
91900 +struct size_overflow_hash _001569_hash = {
91901 + .next = NULL,
91902 + .name = "set_connectable",
91903 + .file = "net/bluetooth/mgmt.c",
91904 + .param4 = 1,
91905 +};
91906 +
91907 +struct size_overflow_hash _001570_hash = {
91908 + .next = NULL,
91909 + .name = "set_discoverable",
91910 + .file = "net/bluetooth/mgmt.c",
91911 + .param4 = 1,
91912 +};
91913 +
91914 +struct size_overflow_hash _001571_hash = {
91915 + .next = NULL,
91916 + .name = "set_local_name",
91917 + .file = "net/bluetooth/mgmt.c",
91918 + .param4 = 1,
91919 +};
91920 +
91921 +struct size_overflow_hash _001572_hash = {
91922 + .next = NULL,
91923 + .name = "set_powered",
91924 + .file = "net/bluetooth/mgmt.c",
91925 + .param4 = 1,
91926 +};
91927 +
91928 +struct size_overflow_hash _001573_hash = {
91929 + .next = NULL,
91930 + .name = "simple_alloc_urb",
91931 + .file = "drivers/usb/misc/usbtest.c",
91932 + .param3 = 1,
91933 +};
91934 +
91935 +struct size_overflow_hash _001574_hash = {
91936 + .next = NULL,
91937 + .name = "sm_checker_extend",
91938 + .file = "drivers/md/persistent-data/dm-space-map-checker.c",
91939 + .param2 = 1,
91940 +};
91941 +
91942 +struct size_overflow_hash _001575_hash = {
91943 + .next = NULL,
91944 + .name = "snd_cs4281_BA0_read",
91945 + .file = "sound/pci/cs4281.c",
91946 + .param5 = 1,
91947 +};
91948 +
91949 +struct size_overflow_hash _001576_hash = {
91950 + .next = NULL,
91951 + .name = "snd_cs4281_BA1_read",
91952 + .file = "sound/pci/cs4281.c",
91953 + .param5 = 1,
91954 +};
91955 +
91956 +struct size_overflow_hash _001577_hash = {
91957 + .next = NULL,
91958 + .name = "snd_cs46xx_io_read",
91959 + .file = "sound/pci/cs46xx/cs46xx_lib.c",
91960 + .param5 = 1,
91961 +};
91962 +
91963 +struct size_overflow_hash _001578_hash = {
91964 + .next = NULL,
91965 + .name = "snd_gus_dram_read",
91966 + .file = "include/sound/gus.h",
91967 + .param4 = 1,
91968 +};
91969 +
91970 +struct size_overflow_hash _001579_hash = {
91971 + .next = NULL,
91972 + .name = "snd_gus_dram_write",
91973 + .file = "include/sound/gus.h",
91974 + .param4 = 1,
91975 +};
91976 +
91977 +struct size_overflow_hash _001580_hash = {
91978 + .next = NULL,
91979 + .name = "snd_mem_proc_write",
91980 + .file = "sound/core/memalloc.c",
91981 + .param3 = 1,
91982 +};
91983 +
91984 +struct size_overflow_hash _001581_hash = {
91985 + .next = NULL,
91986 + .name = "snd_pcm_oss_read",
91987 + .file = "sound/core/oss/pcm_oss.c",
91988 + .param3 = 1,
91989 +};
91990 +
91991 +struct size_overflow_hash _001582_hash = {
91992 + .next = NULL,
91993 + .name = "snd_pcm_oss_sync1",
91994 + .file = "sound/core/oss/pcm_oss.c",
91995 + .param2 = 1,
91996 +};
91997 +
91998 +struct size_overflow_hash _001583_hash = {
91999 + .next = NULL,
92000 + .name = "snd_pcm_oss_write",
92001 + .file = "sound/core/oss/pcm_oss.c",
92002 + .param3 = 1,
92003 +};
92004 +
92005 +struct size_overflow_hash _001584_hash = {
92006 + .next = NULL,
92007 + .name = "snd_rme32_capture_copy",
92008 + .file = "sound/pci/rme32.c",
92009 + .param5 = 1,
92010 +};
92011 +
92012 +struct size_overflow_hash _001585_hash = {
92013 + .next = NULL,
92014 + .name = "snd_rme32_playback_copy",
92015 + .file = "sound/pci/rme32.c",
92016 + .param5 = 1,
92017 +};
92018 +
92019 +struct size_overflow_hash _001586_hash = {
92020 + .next = NULL,
92021 + .name = "snd_rme96_capture_copy",
92022 + .file = "sound/pci/rme96.c",
92023 + .param5 = 1,
92024 +};
92025 +
92026 +struct size_overflow_hash _001587_hash = {
92027 + .next = NULL,
92028 + .name = "snd_rme96_playback_copy",
92029 + .file = "sound/pci/rme96.c",
92030 + .param5 = 1,
92031 +};
92032 +
92033 +struct size_overflow_hash _001588_hash = {
92034 + .next = NULL,
92035 + .name = "spi_execute",
92036 + .file = "drivers/scsi/scsi_transport_spi.c",
92037 + .param5 = 1,
92038 +};
92039 +
92040 +struct size_overflow_hash _001589_hash = {
92041 + .next = NULL,
92042 + .name = "srp_target_alloc",
92043 + .file = "include/scsi/libsrp.h",
92044 + .param3 = 1,
92045 +};
92046 +
92047 +struct size_overflow_hash _001590_hash = {
92048 + .next = NULL,
92049 + .name = "stats_dot11ACKFailureCount_read",
92050 + .file = "net/mac80211/debugfs.c",
92051 + .param3 = 1,
92052 +};
92053 +
92054 +struct size_overflow_hash _001591_hash = {
92055 + .next = NULL,
92056 + .name = "stats_dot11FCSErrorCount_read",
92057 + .file = "net/mac80211/debugfs.c",
92058 + .param3 = 1,
92059 +};
92060 +
92061 +struct size_overflow_hash _001592_hash = {
92062 + .next = NULL,
92063 + .name = "stats_dot11RTSFailureCount_read",
92064 + .file = "net/mac80211/debugfs.c",
92065 + .param3 = 1,
92066 +};
92067 +
92068 +struct size_overflow_hash _001593_hash = {
92069 + .next = NULL,
92070 + .name = "stats_dot11RTSSuccessCount_read",
92071 + .file = "net/mac80211/debugfs.c",
92072 + .param3 = 1,
92073 +};
92074 +
92075 +struct size_overflow_hash _001594_hash = {
92076 + .next = NULL,
92077 + .name = "stk_allocate_buffers",
92078 + .file = "drivers/media/video/stk-webcam.c",
92079 + .param2 = 1,
92080 +};
92081 +
92082 +struct size_overflow_hash _001595_hash = {
92083 + .next = NULL,
92084 + .name = "submit_inquiry",
92085 + .file = "drivers/scsi/device_handler/scsi_dh_rdac.c",
92086 + .param3 = 1,
92087 +};
92088 +
92089 +struct size_overflow_hash _001596_hash = {
92090 + .next = NULL,
92091 + .name = "team_options_register",
92092 + .file = "include/linux/if_team.h",
92093 + .param3 = 1,
92094 +};
92095 +
92096 +struct size_overflow_hash _001597_hash = {
92097 + .next = NULL,
92098 + .name = "test_unaligned_bulk",
92099 + .file = "drivers/usb/misc/usbtest.c",
92100 + .param3 = 1,
92101 +};
92102 +
92103 +struct size_overflow_hash _001598_hash = {
92104 + .next = NULL,
92105 + .name = "timeout_read",
92106 + .file = "arch/x86/oprofile/../../../drivers/oprofile/oprofile_files.c",
92107 + .param3 = 1,
92108 +};
92109 +
92110 +struct size_overflow_hash _001599_hash = {
92111 + .next = NULL,
92112 + .name = "timeout_write",
92113 + .file = "arch/x86/oprofile/../../../drivers/oprofile/oprofile_files.c",
92114 + .param3 = 1,
92115 +};
92116 +
92117 +struct size_overflow_hash _001600_hash = {
92118 + .next = NULL,
92119 + .name = "tipc_link_send_sections_fast",
92120 + .file = "net/tipc/link.c",
92121 + .param4 = 1,
92122 +};
92123 +
92124 +struct size_overflow_hash _001601_hash = {
92125 + .next = NULL,
92126 + .name = "total_ps_buffered_read",
92127 + .file = "net/mac80211/debugfs.c",
92128 + .param3 = 1,
92129 +};
92130 +
92131 +struct size_overflow_hash _001602_hash = {
92132 + .next = NULL,
92133 + .name = "ts_read",
92134 + .file = "drivers/media/dvb/ddbridge/ddbridge-core.c",
92135 + .param3 = 1,
92136 +};
92137 +
92138 +struct size_overflow_hash _001603_hash = {
92139 + .next = NULL,
92140 + .name = "TSS_authhmac",
92141 + .file = "security/keys/trusted.c",
92142 + .param3 = 1,
92143 +};
92144 +
92145 +struct size_overflow_hash _001604_hash = {
92146 + .next = NULL,
92147 + .name = "TSS_checkhmac1",
92148 + .file = "security/keys/trusted.c",
92149 + .param5 = 1,
92150 +};
92151 +
92152 +struct size_overflow_hash _001605_hash = {
92153 + .next = NULL,
92154 + .name = "TSS_checkhmac2",
92155 + .file = "security/keys/trusted.c",
92156 + .param5 = 1,
92157 + .param7 = 1,
92158 +};
92159 +
92160 +struct size_overflow_hash _001607_hash = {
92161 + .next = NULL,
92162 + .name = "ts_write",
92163 + .file = "drivers/media/dvb/ddbridge/ddbridge-core.c",
92164 + .param3 = 1,
92165 +};
92166 +
92167 +struct size_overflow_hash _001608_hash = {
92168 + .next = NULL,
92169 + .name = "tx_internal_desc_overflow_read",
92170 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
92171 + .param3 = 1,
92172 +};
92173 +
92174 +struct size_overflow_hash _001609_hash = {
92175 + .next = NULL,
92176 + .name = "uapsd_max_sp_len_read",
92177 + .file = "net/mac80211/debugfs.c",
92178 + .param3 = 1,
92179 +};
92180 +
92181 +struct size_overflow_hash _001610_hash = {
92182 + .next = NULL,
92183 + .name = "uapsd_queues_read",
92184 + .file = "net/mac80211/debugfs.c",
92185 + .param3 = 1,
92186 +};
92187 +
92188 +struct size_overflow_hash _001611_hash = {
92189 + .next = NULL,
92190 + .name = "ulong_read_file",
92191 + .file = "arch/x86/oprofile/../../../drivers/oprofile/oprofilefs.c",
92192 + .param3 = 1,
92193 +};
92194 +
92195 +struct size_overflow_hash _001612_hash = {
92196 + .next = NULL,
92197 + .name = "ulong_write_file",
92198 + .file = "arch/x86/oprofile/../../../drivers/oprofile/oprofilefs.c",
92199 + .param3 = 1,
92200 +};
92201 +
92202 +struct size_overflow_hash _001613_hash = {
92203 + .next = NULL,
92204 + .name = "usb_alloc_coherent",
92205 + .file = "include/linux/usb.h",
92206 + .param2 = 1,
92207 +};
92208 +
92209 +struct size_overflow_hash _001614_hash = {
92210 + .next = NULL,
92211 + .name = "user_power_read",
92212 + .file = "net/mac80211/debugfs.c",
92213 + .param3 = 1,
92214 +};
92215 +
92216 +struct size_overflow_hash _001615_hash = {
92217 + .next = NULL,
92218 + .name = "vb2_read",
92219 + .file = "include/media/videobuf2-core.h",
92220 + .param3 = 1,
92221 +};
92222 +
92223 +struct size_overflow_hash _001616_hash = {
92224 + .next = NULL,
92225 + .name = "vb2_write",
92226 + .file = "include/media/videobuf2-core.h",
92227 + .param3 = 1,
92228 +};
92229 +
92230 +struct size_overflow_hash _001617_hash = {
92231 + .next = NULL,
92232 + .name = "vhost_add_used_n",
92233 + .file = "drivers/vhost/vhost.c",
92234 + .param3 = 1,
92235 +};
92236 +
92237 +struct size_overflow_hash _001618_hash = {
92238 + .next = NULL,
92239 + .name = "virtqueue_add_buf",
92240 + .file = "include/linux/virtio.h",
92241 + .param3 = 1,
92242 + .param4 = 1,
92243 +};
92244 +
92245 +struct size_overflow_hash _001620_hash = {
92246 + .next = NULL,
92247 + .name = "vmbus_establish_gpadl",
92248 + .file = "include/linux/hyperv.h",
92249 + .param3 = 1,
92250 +};
92251 +
92252 +struct size_overflow_hash _001621_hash = {
92253 + .next = NULL,
92254 + .name = "wep_addr_key_count_read",
92255 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
92256 + .param3 = 1,
92257 +};
92258 +
92259 +struct size_overflow_hash _001622_hash = {
92260 + .next = NULL,
92261 + .name = "wep_decrypt_fail_read",
92262 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
92263 + .param3 = 1,
92264 +};
92265 +
92266 +struct size_overflow_hash _001623_hash = {
92267 + .next = NULL,
92268 + .name = "wep_default_key_count_read",
92269 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
92270 + .param3 = 1,
92271 +};
92272 +
92273 +struct size_overflow_hash _001624_hash = {
92274 + .next = NULL,
92275 + .name = "wep_interrupt_read",
92276 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
92277 + .param3 = 1,
92278 +};
92279 +
92280 +struct size_overflow_hash _001625_hash = {
92281 + .next = NULL,
92282 + .name = "wep_iv_read",
92283 + .file = "net/mac80211/debugfs.c",
92284 + .param3 = 1,
92285 +};
92286 +
92287 +struct size_overflow_hash _001626_hash = {
92288 + .next = NULL,
92289 + .name = "wep_key_not_found_read",
92290 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
92291 + .param3 = 1,
92292 +};
92293 +
92294 +struct size_overflow_hash _001627_hash = {
92295 + .next = NULL,
92296 + .name = "wep_packets_read",
92297 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
92298 + .param3 = 1,
92299 +};
92300 +
92301 +struct size_overflow_hash _001628_hash = {
92302 + .next = NULL,
92303 + .name = "write_led",
92304 + .file = "drivers/platform/x86/asus_acpi.c",
92305 + .param2 = 1,
92306 +};
92307 +
92308 +struct size_overflow_hash _001629_hash = {
92309 + .next = NULL,
92310 + .name = "wusb_prf",
92311 + .file = "include/linux/usb/wusb.h",
92312 + .param7 = 1,
92313 +};
92314 +
92315 +struct size_overflow_hash _001630_hash = {
92316 + .next = NULL,
92317 + .name = "zd_usb_iowrite16v",
92318 + .file = "drivers/net/wireless/zd1211rw/zd_usb.c",
92319 + .param3 = 1,
92320 +};
92321 +
92322 +struct size_overflow_hash _001631_hash = {
92323 + .next = NULL,
92324 + .name = "afs_cell_lookup",
92325 + .file = "fs/afs/cell.c",
92326 + .param2 = 1,
92327 +};
92328 +
92329 +struct size_overflow_hash _001632_hash = {
92330 + .next = NULL,
92331 + .name = "agp_generic_alloc_user",
92332 + .file = "drivers/char/agp/generic.c",
92333 + .param1 = 1,
92334 +};
92335 +
92336 +struct size_overflow_hash _001634_hash = {
92337 + .next = NULL,
92338 + .name = "bluetooth_proc_write",
92339 + .file = "drivers/platform/x86/asus_acpi.c",
92340 + .param3 = 1,
92341 +};
92342 +
92343 +struct size_overflow_hash _001635_hash = {
92344 + .next = NULL,
92345 + .name = "cache_write",
92346 + .file = "net/sunrpc/cache.c",
92347 + .param3 = 1,
92348 +};
92349 +
92350 +struct size_overflow_hash _001636_hash = {
92351 + .next = NULL,
92352 + .name = "ch_do_scsi",
92353 + .file = "drivers/scsi/ch.c",
92354 + .param4 = 1,
92355 +};
92356 +
92357 +struct size_overflow_hash _001637_hash = {
92358 + .next = NULL,
92359 + .name = "cx18_read",
92360 + .file = "drivers/media/video/cx18/cx18-fileops.c",
92361 + .param3 = 1,
92362 +};
92363 +
92364 +struct size_overflow_hash _001638_hash = {
92365 + .next = NULL,
92366 + .name = "dccp_feat_register_sp",
92367 + .file = "net/dccp/feat.c",
92368 + .param5 = 1,
92369 +};
92370 +
92371 +struct size_overflow_hash _001640_hash = {
92372 + .next = NULL,
92373 + .name = "iso_alloc_urb",
92374 + .file = "drivers/usb/misc/usbtest.c",
92375 + .param5 = 1,
92376 +};
92377 +
92378 +struct size_overflow_hash _001641_hash = {
92379 + .next = NULL,
92380 + .name = "ivtv_read_pos",
92381 + .file = "drivers/media/video/ivtv/ivtv-fileops.c",
92382 + .param3 = 1,
92383 +};
92384 +
92385 +struct size_overflow_hash _001642_hash = {
92386 + .next = NULL,
92387 + .name = "mcam_v4l_read",
92388 + .file = "drivers/media/video/marvell-ccic/mcam-core.c",
92389 + .param3 = 1,
92390 +};
92391 +
92392 +struct size_overflow_hash _001643_hash = {
92393 + .next = NULL,
92394 + .name = "mled_proc_write",
92395 + .file = "drivers/platform/x86/asus_acpi.c",
92396 + .param3 = 1,
92397 +};
92398 +
92399 +struct size_overflow_hash _001644_hash = {
92400 + .next = NULL,
92401 + .name = "nfs_idmap_lookup_id",
92402 + .file = "fs/nfs/idmap.c",
92403 + .param2 = 1,
92404 +};
92405 +
92406 +struct size_overflow_hash _001645_hash = {
92407 + .next = NULL,
92408 + .name = "ocfs2_control_write",
92409 + .file = "fs/ocfs2/stack_user.c",
92410 + .param3 = 1,
92411 +};
92412 +
92413 +struct size_overflow_hash _001646_hash = {
92414 + .next = NULL,
92415 + .name = "osd_req_list_dev_partitions",
92416 + .file = "include/scsi/osd_initiator.h",
92417 + .param4 = 1,
92418 +};
92419 +
92420 +struct size_overflow_hash _001647_hash = {
92421 + .next = NULL,
92422 + .name = "osd_req_list_partition_collections",
92423 + .file = "include/scsi/osd_initiator.h",
92424 + .param5 = 1,
92425 +};
92426 +
92427 +struct size_overflow_hash _001648_hash = {
92428 + .next = NULL,
92429 + .name = "pwc_video_read",
92430 + .file = "drivers/media/video/pwc/pwc-if.c",
92431 + .param3 = 1,
92432 +};
92433 +
92434 +struct size_overflow_hash _001649_hash = {
92435 + .next = NULL,
92436 + .name = "scsi_vpd_inquiry",
92437 + .file = "drivers/scsi/scsi.c",
92438 + .param4 = 1,
92439 +};
92440 +
92441 +struct size_overflow_hash _001650_hash = {
92442 + .next = NULL,
92443 + .name = "snd_gf1_mem_proc_dump",
92444 + .file = "sound/isa/gus/gus_mem_proc.c",
92445 + .param5 = 1,
92446 +};
92447 +
92448 +struct size_overflow_hash _001651_hash = {
92449 + .next = NULL,
92450 + .name = "spi_dv_device_echo_buffer",
92451 + .file = "drivers/scsi/scsi_transport_spi.c",
92452 + .param2 = 1,
92453 + .param3 = 1,
92454 +};
92455 +
92456 +struct size_overflow_hash _001653_hash = {
92457 + .next = NULL,
92458 + .name = "tled_proc_write",
92459 + .file = "drivers/platform/x86/asus_acpi.c",
92460 + .param3 = 1,
92461 +};
92462 +
92463 +struct size_overflow_hash _001655_hash = {
92464 + .next = NULL,
92465 + .name = "usb_allocate_stream_buffers",
92466 + .file = "drivers/media/dvb/dvb-usb/usb-urb.c",
92467 + .param3 = 1,
92468 +};
92469 +
92470 +struct size_overflow_hash _001656_hash = {
92471 + .next = NULL,
92472 + .name = "_usb_writeN_sync",
92473 + .file = "drivers/net/wireless/rtlwifi/usb.c",
92474 + .param4 = 1,
92475 +};
92476 +
92477 +struct size_overflow_hash _001657_hash = {
92478 + .next = NULL,
92479 + .name = "vhost_add_used_and_signal_n",
92480 + .file = "drivers/vhost/vhost.c",
92481 + .param4 = 1,
92482 +};
92483 +
92484 +struct size_overflow_hash _001658_hash = {
92485 + .next = NULL,
92486 + .name = "vmbus_open",
92487 + .file = "include/linux/hyperv.h",
92488 + .param2 = 1,
92489 + .param3 = 1,
92490 +};
92491 +
92492 +struct size_overflow_hash _001660_hash = {
92493 + .next = NULL,
92494 + .name = "wled_proc_write",
92495 + .file = "drivers/platform/x86/asus_acpi.c",
92496 + .param3 = 1,
92497 +};
92498 +
92499 +struct size_overflow_hash _001661_hash = {
92500 + .next = NULL,
92501 + .name = "wusb_prf_256",
92502 + .file = "include/linux/usb/wusb.h",
92503 + .param7 = 1,
92504 +};
92505 +
92506 +struct size_overflow_hash _001662_hash = {
92507 + .next = NULL,
92508 + .name = "wusb_prf_64",
92509 + .file = "include/linux/usb/wusb.h",
92510 + .param7 = 1,
92511 +};
92512 +
92513 +struct size_overflow_hash _001663_hash = {
92514 + .next = NULL,
92515 + .name = "agp_allocate_memory",
92516 + .file = "include/linux/agp_backend.h",
92517 + .param2 = 1,
92518 +};
92519 +
92520 +struct size_overflow_hash _001664_hash = {
92521 + .next = NULL,
92522 + .name = "cx18_read_pos",
92523 + .file = "drivers/media/video/cx18/cx18-fileops.c",
92524 + .param3 = 1,
92525 +};
92526 +
92527 +struct size_overflow_hash _001665_hash = {
92528 + .next = NULL,
92529 + .name = "nfs_map_group_to_gid",
92530 + .file = "include/linux/nfs_idmap.h",
92531 + .param3 = 1,
92532 +};
92533 +
92534 +struct size_overflow_hash _001666_hash = {
92535 + .next = NULL,
92536 + .name = "nfs_map_name_to_uid",
92537 + .file = "include/linux/nfs_idmap.h",
92538 + .param3 = 1,
92539 +};
92540 +
92541 +struct size_overflow_hash _001667_hash = {
92542 + .next = NULL,
92543 + .name = "test_iso_queue",
92544 + .file = "drivers/usb/misc/usbtest.c",
92545 + .param5 = 1,
92546 +};
92547 +
92548 +struct size_overflow_hash _001668_hash = {
92549 + .next = NULL,
92550 + .name = "agp_allocate_memory_wrap",
92551 + .file = "drivers/char/agp/frontend.c",
92552 + .param1 = 1,
92553 +};
92554 +
92555 +struct size_overflow_hash _001669_hash = {
92556 + .next = NULL,
92557 + .name = "alloc_irq_cpu_rmap",
92558 + .file = "include/linux/cpu_rmap.h",
92559 + .param1 = 1,
92560 +};
92561 +
92562 +struct size_overflow_hash _001670_hash = {
92563 + .next = NULL,
92564 + .name = "alloc_ring",
92565 + .file = "drivers/net/ethernet/chelsio/cxgb4/sge.c",
92566 + .param2 = 1,
92567 + .param4 = 1,
92568 +};
92569 +
92570 +struct size_overflow_hash _001672_hash = {
92571 + .next = &_001124_hash,
92572 + .name = "atomic_counters_read",
92573 + .file = "drivers/infiniband/hw/ipath/ipath_fs.c",
92574 + .param3 = 1,
92575 +};
92576 +
92577 +struct size_overflow_hash _001673_hash = {
92578 + .next = NULL,
92579 + .name = "atomic_stats_read",
92580 + .file = "drivers/infiniband/hw/ipath/ipath_fs.c",
92581 + .param3 = 1,
92582 +};
92583 +
92584 +struct size_overflow_hash _001674_hash = {
92585 + .next = NULL,
92586 + .name = "c4iw_init_resource_fifo",
92587 + .file = "drivers/infiniband/hw/cxgb4/resource.c",
92588 + .param3 = 1,
92589 +};
92590 +
92591 +struct size_overflow_hash _001675_hash = {
92592 + .next = NULL,
92593 + .name = "c4iw_init_resource_fifo_random",
92594 + .file = "drivers/infiniband/hw/cxgb4/resource.c",
92595 + .param3 = 1,
92596 +};
92597 +
92598 +struct size_overflow_hash _001676_hash = {
92599 + .next = NULL,
92600 + .name = "compat_do_arpt_set_ctl",
92601 + .file = "net/ipv4/netfilter/arp_tables.c",
92602 + .param4 = 1,
92603 +};
92604 +
92605 +struct size_overflow_hash _001677_hash = {
92606 + .next = NULL,
92607 + .name = "compat_do_ip6t_set_ctl",
92608 + .file = "net/ipv6/netfilter/ip6_tables.c",
92609 + .param4 = 1,
92610 +};
92611 +
92612 +struct size_overflow_hash _001678_hash = {
92613 + .next = NULL,
92614 + .name = "compat_do_ipt_set_ctl",
92615 + .file = "net/ipv4/netfilter/ip_tables.c",
92616 + .param4 = 1,
92617 +};
92618 +
92619 +struct size_overflow_hash _001679_hash = {
92620 + .next = NULL,
92621 + .name = "cxio_init_resource_fifo",
92622 + .file = "drivers/infiniband/hw/cxgb3/cxio_resource.c",
92623 + .param3 = 1,
92624 +};
92625 +
92626 +struct size_overflow_hash _001680_hash = {
92627 + .next = NULL,
92628 + .name = "cxio_init_resource_fifo_random",
92629 + .file = "drivers/infiniband/hw/cxgb3/cxio_resource.c",
92630 + .param3 = 1,
92631 +};
92632 +
92633 +struct size_overflow_hash _001681_hash = {
92634 + .next = NULL,
92635 + .name = "dev_counters_read",
92636 + .file = "drivers/infiniband/hw/qib/qib_fs.c",
92637 + .param3 = 1,
92638 +};
92639 +
92640 +struct size_overflow_hash _001682_hash = {
92641 + .next = NULL,
92642 + .name = "dev_names_read",
92643 + .file = "drivers/infiniband/hw/qib/qib_fs.c",
92644 + .param3 = 1,
92645 +};
92646 +
92647 +struct size_overflow_hash _001683_hash = {
92648 + .next = &_001468_hash,
92649 + .name = "do_arpt_set_ctl",
92650 + .file = "net/ipv4/netfilter/arp_tables.c",
92651 + .param4 = 1,
92652 +};
92653 +
92654 +struct size_overflow_hash _001684_hash = {
92655 + .next = NULL,
92656 + .name = "do_ip6t_set_ctl",
92657 + .file = "net/ipv6/netfilter/ip6_tables.c",
92658 + .param4 = 1,
92659 +};
92660 +
92661 +struct size_overflow_hash _001685_hash = {
92662 + .next = NULL,
92663 + .name = "do_ipt_set_ctl",
92664 + .file = "net/ipv4/netfilter/ip_tables.c",
92665 + .param4 = 1,
92666 +};
92667 +
92668 +struct size_overflow_hash _001686_hash = {
92669 + .next = NULL,
92670 + .name = "drbd_bm_resize",
92671 + .file = "drivers/block/drbd/drbd_bitmap.c",
92672 + .param2 = 1,
92673 +};
92674 +
92675 +struct size_overflow_hash _001687_hash = {
92676 + .next = NULL,
92677 + .name = "driver_names_read",
92678 + .file = "drivers/infiniband/hw/qib/qib_fs.c",
92679 + .param3 = 1,
92680 +};
92681 +
92682 +struct size_overflow_hash _001688_hash = {
92683 + .next = NULL,
92684 + .name = "driver_stats_read",
92685 + .file = "drivers/infiniband/hw/qib/qib_fs.c",
92686 + .param3 = 1,
92687 +};
92688 +
92689 +struct size_overflow_hash _001689_hash = {
92690 + .next = NULL,
92691 + .name = "flash_read",
92692 + .file = "drivers/infiniband/hw/qib/qib_fs.c",
92693 + .param3 = 1,
92694 +};
92695 +
92696 +struct size_overflow_hash _001690_hash = {
92697 + .next = NULL,
92698 + .name = "flash_read",
92699 + .file = "drivers/infiniband/hw/ipath/ipath_fs.c",
92700 + .param3 = 1,
92701 +};
92702 +
92703 +struct size_overflow_hash _001691_hash = {
92704 + .next = NULL,
92705 + .name = "flash_write",
92706 + .file = "drivers/infiniband/hw/qib/qib_fs.c",
92707 + .param3 = 1,
92708 +};
92709 +
92710 +struct size_overflow_hash _001692_hash = {
92711 + .next = NULL,
92712 + .name = "flash_write",
92713 + .file = "drivers/infiniband/hw/ipath/ipath_fs.c",
92714 + .param3 = 1,
92715 +};
92716 +
92717 +struct size_overflow_hash _001693_hash = {
92718 + .next = NULL,
92719 + .name = "ghash_async_setkey",
92720 + .file = "arch/x86/crypto/ghash-clmulni-intel_glue.c",
92721 + .param3 = 1,
92722 +};
92723 +
92724 +struct size_overflow_hash _001694_hash = {
92725 + .next = NULL,
92726 + .name = "handle_eviocgbit",
92727 + .file = "drivers/input/evdev.c",
92728 + .param3 = 1,
92729 +};
92730 +
92731 +struct size_overflow_hash _001695_hash = {
92732 + .next = NULL,
92733 + .name = "hid_parse_report",
92734 + .file = "include/linux/hid.h",
92735 + .param3 = 1,
92736 +};
92737 +
92738 +struct size_overflow_hash _001696_hash = {
92739 + .next = NULL,
92740 + .name = "ipath_get_base_info",
92741 + .file = "drivers/infiniband/hw/ipath/ipath_file_ops.c",
92742 + .param3 = 1,
92743 +};
92744 +
92745 +struct size_overflow_hash _001697_hash = {
92746 + .next = NULL,
92747 + .name = "options_write",
92748 + .file = "drivers/misc/sgi-gru/gruprocfs.c",
92749 + .param3 = 1,
92750 +};
92751 +
92752 +struct size_overflow_hash _001698_hash = {
92753 + .next = NULL,
92754 + .name = "portcntrs_1_read",
92755 + .file = "drivers/infiniband/hw/qib/qib_fs.c",
92756 + .param3 = 1,
92757 +};
92758 +
92759 +struct size_overflow_hash _001699_hash = {
92760 + .next = NULL,
92761 + .name = "portcntrs_2_read",
92762 + .file = "drivers/infiniband/hw/qib/qib_fs.c",
92763 + .param3 = 1,
92764 +};
92765 +
92766 +struct size_overflow_hash _001700_hash = {
92767 + .next = NULL,
92768 + .name = "portnames_read",
92769 + .file = "drivers/infiniband/hw/qib/qib_fs.c",
92770 + .param3 = 1,
92771 +};
92772 +
92773 +struct size_overflow_hash _001701_hash = {
92774 + .next = NULL,
92775 + .name = "qib_alloc_devdata",
92776 + .file = "drivers/infiniband/hw/qib/qib_init.c",
92777 + .param2 = 1,
92778 +};
92779 +
92780 +struct size_overflow_hash _001702_hash = {
92781 + .next = NULL,
92782 + .name = "qib_diag_write",
92783 + .file = "drivers/infiniband/hw/qib/qib_diag.c",
92784 + .param3 = 1,
92785 +};
92786 +
92787 +struct size_overflow_hash _001703_hash = {
92788 + .next = NULL,
92789 + .name = "qib_get_base_info",
92790 + .file = "drivers/infiniband/hw/qib/qib_file_ops.c",
92791 + .param3 = 1,
92792 +};
92793 +
92794 +struct size_overflow_hash _001704_hash = {
92795 + .next = NULL,
92796 + .name = "qsfp_1_read",
92797 + .file = "drivers/infiniband/hw/qib/qib_fs.c",
92798 + .param3 = 1,
92799 +};
92800 +
92801 +struct size_overflow_hash _001705_hash = {
92802 + .next = NULL,
92803 + .name = "qsfp_2_read",
92804 + .file = "drivers/infiniband/hw/qib/qib_fs.c",
92805 + .param3 = 1,
92806 +};
92807 +
92808 +struct size_overflow_hash _001706_hash = {
92809 + .next = NULL,
92810 + .name = "rfc4106_set_key",
92811 + .file = "arch/x86/crypto/aesni-intel_glue.c",
92812 + .param3 = 1,
92813 +};
92814 +
92815 +struct size_overflow_hash _001707_hash = {
92816 + .next = &_000258_hash,
92817 + .name = "stats_read_ul",
92818 + .file = "drivers/idle/i7300_idle.c",
92819 + .param3 = 1,
92820 +};
92821 +
92822 +struct size_overflow_hash _001708_hash = {
92823 + .next = NULL,
92824 + .name = "xpc_kmalloc_cacheline_aligned",
92825 + .file = "drivers/misc/sgi-xp/xpc_partition.c",
92826 + .param1 = 1,
92827 +};
92828 +
92829 +struct size_overflow_hash _001709_hash = {
92830 + .next = NULL,
92831 + .name = "xpc_kzalloc_cacheline_aligned",
92832 + .file = "drivers/misc/sgi-xp/xpc_main.c",
92833 + .param1 = 1,
92834 +};
92835 +
92836 +struct size_overflow_hash _001710_hash = {
92837 + .next = NULL,
92838 + .name = "c4iw_init_resource",
92839 + .file = "drivers/infiniband/hw/cxgb4/resource.c",
92840 + .param2 = 1,
92841 + .param3 = 1,
92842 +};
92843 +
92844 +struct size_overflow_hash _001712_hash = {
92845 + .next = NULL,
92846 + .name = "cxio_hal_init_resource",
92847 + .file = "drivers/infiniband/hw/cxgb3/cxio_resource.c",
92848 + .param2 = 1,
92849 + .param7 = 1,
92850 + .param6 = 1,
92851 +};
92852 +
92853 +struct size_overflow_hash _001715_hash = {
92854 + .next = &_000734_hash,
92855 + .name = "cxio_hal_init_rhdl_resource",
92856 + .file = "drivers/infiniband/hw/cxgb3/cxio_resource.c",
92857 + .param1 = 1,
92858 +};
92859 +
92860 +struct size_overflow_hash _001716_hash = {
92861 + .next = NULL,
92862 + .name = "amthi_read",
92863 + .file = "drivers/staging/mei/iorw.c",
92864 + .param4 = 1,
92865 +};
92866 +
92867 +struct size_overflow_hash _001717_hash = {
92868 + .next = NULL,
92869 + .name = "bcm_char_read",
92870 + .file = "drivers/staging/bcm/Bcmchar.c",
92871 + .param3 = 1,
92872 +};
92873 +
92874 +struct size_overflow_hash _001718_hash = {
92875 + .next = NULL,
92876 + .name = "BcmCopySection",
92877 + .file = "drivers/staging/bcm/nvm.c",
92878 + .param5 = 1,
92879 +};
92880 +
92881 +struct size_overflow_hash _001719_hash = {
92882 + .next = NULL,
92883 + .name = "buffer_from_user",
92884 + .file = "drivers/staging/vme/devices/vme_user.c",
92885 + .param3 = 1,
92886 +};
92887 +
92888 +struct size_overflow_hash _001720_hash = {
92889 + .next = NULL,
92890 + .name = "buffer_to_user",
92891 + .file = "drivers/staging/vme/devices/vme_user.c",
92892 + .param3 = 1,
92893 +};
92894 +
92895 +struct size_overflow_hash _001721_hash = {
92896 + .next = NULL,
92897 + .name = "capabilities_read",
92898 + .file = "drivers/xen/xenfs/super.c",
92899 + .param3 = 1,
92900 +};
92901 +
92902 +struct size_overflow_hash _001722_hash = {
92903 + .next = NULL,
92904 + .name = "chd_dec_fetch_cdata",
92905 + .file = "drivers/staging/crystalhd/crystalhd_lnx.c",
92906 + .param3 = 1,
92907 +};
92908 +
92909 +struct size_overflow_hash _001723_hash = {
92910 + .next = NULL,
92911 + .name = "create_bounce_buffer",
92912 + .file = "drivers/staging/hv/storvsc_drv.c",
92913 + .param3 = 1,
92914 +};
92915 +
92916 +struct size_overflow_hash _001724_hash = {
92917 + .next = NULL,
92918 + .name = "crystalhd_create_dio_pool",
92919 + .file = "drivers/staging/crystalhd/crystalhd_misc.c",
92920 + .param2 = 1,
92921 +};
92922 +
92923 +struct size_overflow_hash _001725_hash = {
92924 + .next = NULL,
92925 + .name = "do_read_log_to_user",
92926 + .file = "drivers/staging/android/logger.c",
92927 + .param4 = 1,
92928 +};
92929 +
92930 +struct size_overflow_hash _001726_hash = {
92931 + .next = NULL,
92932 + .name = "do_write_log_from_user",
92933 + .file = "drivers/staging/android/logger.c",
92934 + .param3 = 1,
92935 +};
92936 +
92937 +struct size_overflow_hash _001727_hash = {
92938 + .next = NULL,
92939 + .name = "dt3155_read",
92940 + .file = "drivers/staging/media/dt3155v4l/dt3155v4l.c",
92941 + .param3 = 1,
92942 +};
92943 +
92944 +struct size_overflow_hash _001728_hash = {
92945 + .next = NULL,
92946 + .name = "easycap_alsa_vmalloc",
92947 + .file = "drivers/staging/media/easycap/easycap_sound.c",
92948 + .param2 = 1,
92949 +};
92950 +
92951 +struct size_overflow_hash _001729_hash = {
92952 + .next = NULL,
92953 + .name = "evm_read_key",
92954 + .file = "security/integrity/evm/evm_secfs.c",
92955 + .param3 = 1,
92956 +};
92957 +
92958 +struct size_overflow_hash _001730_hash = {
92959 + .next = NULL,
92960 + .name = "evm_write_key",
92961 + .file = "security/integrity/evm/evm_secfs.c",
92962 + .param3 = 1,
92963 +};
92964 +
92965 +struct size_overflow_hash _001731_hash = {
92966 + .next = NULL,
92967 + .name = "evtchn_read",
92968 + .file = "drivers/xen/evtchn.c",
92969 + .param3 = 1,
92970 +};
92971 +
92972 +struct size_overflow_hash _001732_hash = {
92973 + .next = NULL,
92974 + .name = "gather_array",
92975 + .file = "drivers/xen/privcmd.c",
92976 + .param3 = 1,
92977 +};
92978 +
92979 +struct size_overflow_hash _001733_hash = {
92980 + .next = NULL,
92981 + .name = "gnttab_map",
92982 + .file = "drivers/xen/grant-table.c",
92983 + .param2 = 1,
92984 +};
92985 +
92986 +struct size_overflow_hash _001734_hash = {
92987 + .next = NULL,
92988 + .name = "iio_read_first_n_kfifo",
92989 + .file = "drivers/staging/iio/kfifo_buf.c",
92990 + .param2 = 1,
92991 +};
92992 +
92993 +struct size_overflow_hash _001735_hash = {
92994 + .next = NULL,
92995 + .name = "iio_read_first_n_sw_rb",
92996 + .file = "drivers/staging/iio/ring_sw.c",
92997 + .param2 = 1,
92998 +};
92999 +
93000 +struct size_overflow_hash _001736_hash = {
93001 + .next = NULL,
93002 + .name = "keymap_store",
93003 + .file = "drivers/staging/speakup/kobjects.c",
93004 + .param4 = 1,
93005 +};
93006 +
93007 +struct size_overflow_hash _001737_hash = {
93008 + .next = NULL,
93009 + .name = "line6_dumpreq_initbuf",
93010 + .file = "drivers/staging/line6/dumprequest.c",
93011 + .param3 = 1,
93012 +};
93013 +
93014 +struct size_overflow_hash _001738_hash = {
93015 + .next = NULL,
93016 + .name = "lirc_write",
93017 + .file = "drivers/staging/media/lirc/lirc_parallel.c",
93018 + .param3 = 1,
93019 +};
93020 +
93021 +struct size_overflow_hash _001739_hash = {
93022 + .next = NULL,
93023 + .name = "lirc_write",
93024 + .file = "drivers/staging/media/lirc/lirc_sir.c",
93025 + .param3 = 1,
93026 +};
93027 +
93028 +struct size_overflow_hash _001740_hash = {
93029 + .next = &_000815_hash,
93030 + .name = "lirc_write",
93031 + .file = "drivers/staging/media/lirc/lirc_serial.c",
93032 + .param3 = 1,
93033 +};
93034 +
93035 +struct size_overflow_hash _001741_hash = {
93036 + .next = &_001021_hash,
93037 + .name = "_malloc",
93038 + .file = "drivers/staging/rtl8712/osdep_service.h",
93039 + .param1 = 1,
93040 +};
93041 +
93042 +struct size_overflow_hash _001742_hash = {
93043 + .next = NULL,
93044 + .name = "mei_read",
93045 + .file = "drivers/staging/mei/main.c",
93046 + .param3 = 1,
93047 +};
93048 +
93049 +struct size_overflow_hash _001743_hash = {
93050 + .next = NULL,
93051 + .name = "mei_write",
93052 + .file = "drivers/staging/mei/main.c",
93053 + .param3 = 1,
93054 +};
93055 +
93056 +struct size_overflow_hash _001744_hash = {
93057 + .next = NULL,
93058 + .name = "msg_set",
93059 + .file = "drivers/staging/speakup/i18n.c",
93060 + .param3 = 1,
93061 +};
93062 +
93063 +struct size_overflow_hash _001745_hash = {
93064 + .next = NULL,
93065 + .name = "OS_kmalloc",
93066 + .file = "drivers/staging/cxt1e1/sbecom_inline_linux.h",
93067 + .param1 = 1,
93068 +};
93069 +
93070 +struct size_overflow_hash _001746_hash = {
93071 + .next = NULL,
93072 + .name = "queue_reply",
93073 + .file = "drivers/xen/xenbus/xenbus_dev_frontend.c",
93074 + .param3 = 1,
93075 +};
93076 +
93077 +struct size_overflow_hash _001747_hash = {
93078 + .next = &_000841_hash,
93079 + .name = "resource_from_user",
93080 + .file = "drivers/staging/vme/devices/vme_user.c",
93081 + .param3 = 1,
93082 +};
93083 +
93084 +struct size_overflow_hash _001748_hash = {
93085 + .next = NULL,
93086 + .name = "sca3000_read_first_n_hw_rb",
93087 + .file = "drivers/staging/iio/accel/sca3000_ring.c",
93088 + .param2 = 1,
93089 +};
93090 +
93091 +struct size_overflow_hash _001749_hash = {
93092 + .next = NULL,
93093 + .name = "sep_lock_user_pages",
93094 + .file = "drivers/staging/sep/sep_driver.c",
93095 + .param2 = 1,
93096 + .param3 = 1,
93097 +};
93098 +
93099 +struct size_overflow_hash _001751_hash = {
93100 + .next = NULL,
93101 + .name = "sep_prepare_input_output_dma_table_in_dcb",
93102 + .file = "drivers/staging/sep/sep_driver.c",
93103 + .param4 = 1,
93104 + .param5 = 1,
93105 + .param2 = 1,
93106 + .param3 = 1,
93107 +};
93108 +
93109 +struct size_overflow_hash _001753_hash = {
93110 + .next = NULL,
93111 + .name = "split",
93112 + .file = "drivers/xen/xenbus/xenbus_xs.c",
93113 + .param2 = 1,
93114 +};
93115 +
93116 +struct size_overflow_hash _001754_hash = {
93117 + .next = NULL,
93118 + .name = "storvsc_connect_to_vsp",
93119 + .file = "drivers/staging/hv/storvsc_drv.c",
93120 + .param2 = 1,
93121 +};
93122 +
93123 +struct size_overflow_hash _001755_hash = {
93124 + .next = NULL,
93125 + .name = "u32_array_read",
93126 + .file = "arch/x86/xen/debugfs.c",
93127 + .param3 = 1,
93128 +};
93129 +
93130 +struct size_overflow_hash _001756_hash = {
93131 + .next = NULL,
93132 + .name = "ValidateDSDParamsChecksum",
93133 + .file = "drivers/staging/bcm/led_control.c",
93134 + .param3 = 1,
93135 +};
93136 +
93137 +struct size_overflow_hash _001757_hash = {
93138 + .next = NULL,
93139 + .name = "vfd_write",
93140 + .file = "drivers/staging/media/lirc/lirc_sasem.c",
93141 + .param3 = 1,
93142 +};
93143 +
93144 +struct size_overflow_hash _001758_hash = {
93145 + .next = NULL,
93146 + .name = "vfd_write",
93147 + .file = "drivers/staging/media/lirc/lirc_imon.c",
93148 + .param3 = 1,
93149 +};
93150 +
93151 +struct size_overflow_hash _001759_hash = {
93152 + .next = NULL,
93153 + .name = "Wb35Reg_BurstWrite",
93154 + .file = "drivers/staging/winbond/wb35reg.c",
93155 + .param4 = 1,
93156 +};
93157 +
93158 +struct size_overflow_hash _001760_hash = {
93159 + .next = NULL,
93160 + .name = "xenbus_file_write",
93161 + .file = "drivers/xen/xenbus/xenbus_dev_frontend.c",
93162 + .param3 = 1,
93163 +};
93164 +
93165 +struct size_overflow_hash _001761_hash = {
93166 + .next = NULL,
93167 + .name = "xsd_read",
93168 + .file = "drivers/xen/xenfs/xenstored.c",
93169 + .param3 = 1,
93170 +};
93171 +
93172 +struct size_overflow_hash _001762_hash = {
93173 + .next = NULL,
93174 + .name = "line6_dumpreq_init",
93175 + .file = "drivers/staging/line6/dumprequest.c",
93176 + .param3 = 1,
93177 +};
93178 +
93179 +struct size_overflow_hash _001763_hash = {
93180 + .next = NULL,
93181 + .name = "r8712_usbctrl_vendorreq",
93182 + .file = "drivers/staging/rtl8712/usb_ops_linux.c",
93183 + .param6 = 1,
93184 +};
93185 +
93186 +struct size_overflow_hash _001764_hash = {
93187 + .next = NULL,
93188 + .name = "r871x_set_wpa_ie",
93189 + .file = "drivers/staging/rtl8712/rtl871x_ioctl_linux.c",
93190 + .param3 = 1,
93191 +};
93192 +
93193 +struct size_overflow_hash _001765_hash = {
93194 + .next = NULL,
93195 + .name = "sep_prepare_input_dma_table",
93196 + .file = "drivers/staging/sep/sep_driver.c",
93197 + .param2 = 1,
93198 + .param3 = 1,
93199 +};
93200 +
93201 +struct size_overflow_hash _001767_hash = {
93202 + .next = NULL,
93203 + .name = "sep_prepare_input_output_dma_table",
93204 + .file = "drivers/staging/sep/sep_driver.c",
93205 + .param2 = 1,
93206 + .param4 = 1,
93207 + .param3 = 1,
93208 +};
93209 +
93210 +struct size_overflow_hash _001770_hash = {
93211 + .next = NULL,
93212 + .name = "vme_user_write",
93213 + .file = "drivers/staging/vme/devices/vme_user.c",
93214 + .param3 = 1,
93215 +};
93216 +
93217 +struct size_overflow_hash _001771_hash = {
93218 + .next = NULL,
93219 + .name = "alloc_ebda_hpc",
93220 + .file = "drivers/pci/hotplug/ibmphp_ebda.c",
93221 + .param1 = 1,
93222 + .param2 = 1,
93223 +};
93224 +
93225 +struct size_overflow_hash _001772_hash = {
93226 + .next = NULL,
93227 + .name = "alloc_apertures",
93228 + .file = "include/linux/fb.h",
93229 + .param1 = 1,
93230 +};
93231 +
93232 +struct size_overflow_hash _001773_hash = {
93233 + .next = NULL,
93234 + .name = "bin_uuid",
93235 + .file = "kernel/sysctl_binary.c",
93236 + .param3 = 1,
93237 +};
93238 +
93239 +struct size_overflow_hash _001774_hash = {
93240 + .next = &_000640_hash,
93241 + .name = "__copy_from_user_inatomic_nocache",
93242 + .file = "arch/x86/include/asm/uaccess_64.h",
93243 + .param3 = 1,
93244 +};
93245 +
93246 +struct size_overflow_hash _001775_hash = {
93247 + .next = NULL,
93248 + .name = "do_dmabuf_dirty_sou",
93249 + .file = "drivers/gpu/drm/vmwgfx/vmwgfx_kms.c",
93250 + .param7 = 1,
93251 +};
93252 +
93253 +struct size_overflow_hash _001776_hash = {
93254 + .next = NULL,
93255 + .name = "do_surface_dirty_sou",
93256 + .file = "drivers/gpu/drm/vmwgfx/vmwgfx_kms.c",
93257 + .param7 = 1,
93258 +};
93259 +
93260 +struct size_overflow_hash _001777_hash = {
93261 + .next = NULL,
93262 + .name = "drm_agp_bind_pages",
93263 + .file = "drivers/gpu/drm/drm_agpsupport.c",
93264 + .param3 = 1,
93265 +};
93266 +
93267 +struct size_overflow_hash _001778_hash = {
93268 + .next = NULL,
93269 + .name = "drm_calloc_large",
93270 + .file = "include/drm/drm_mem_util.h",
93271 + .param1 = 1,
93272 + .param2 = 1,
93273 +};
93274 +
93275 +struct size_overflow_hash _001780_hash = {
93276 + .next = NULL,
93277 + .name = "drm_ht_create",
93278 + .file = "drivers/gpu/drm/drm_hashtab.c",
93279 + .param2 = 1,
93280 +};
93281 +
93282 +struct size_overflow_hash _001781_hash = {
93283 + .next = NULL,
93284 + .name = "drm_malloc_ab",
93285 + .file = "include/drm/drm_mem_util.h",
93286 + .param1 = 1,
93287 + .param2 = 1,
93288 +};
93289 +
93290 +struct size_overflow_hash _001783_hash = {
93291 + .next = NULL,
93292 + .name = "drm_plane_init",
93293 + .file = "drivers/gpu/drm/drm_crtc.c",
93294 + .param6 = 1,
93295 +};
93296 +
93297 +struct size_overflow_hash _001784_hash = {
93298 + .next = NULL,
93299 + .name = "drm_vmalloc_dma",
93300 + .file = "drivers/gpu/drm/drm_scatter.c",
93301 + .param1 = 1,
93302 +};
93303 +
93304 +struct size_overflow_hash _001785_hash = {
93305 + .next = NULL,
93306 + .name = "fb_read",
93307 + .file = "drivers/video/fbmem.c",
93308 + .param3 = 1,
93309 +};
93310 +
93311 +struct size_overflow_hash _001786_hash = {
93312 + .next = NULL,
93313 + .name = "fb_write",
93314 + .file = "drivers/video/fbmem.c",
93315 + .param3 = 1,
93316 +};
93317 +
93318 +struct size_overflow_hash _001787_hash = {
93319 + .next = NULL,
93320 + .name = "framebuffer_alloc",
93321 + .file = "include/linux/fb.h",
93322 + .param1 = 1,
93323 +};
93324 +
93325 +struct size_overflow_hash _001788_hash = {
93326 + .next = NULL,
93327 + .name = "i915_cache_sharing_read",
93328 + .file = "drivers/gpu/drm/i915/i915_debugfs.c",
93329 + .param3 = 1,
93330 +};
93331 +
93332 +struct size_overflow_hash _001789_hash = {
93333 + .next = NULL,
93334 + .name = "i915_cache_sharing_write",
93335 + .file = "drivers/gpu/drm/i915/i915_debugfs.c",
93336 + .param3 = 1,
93337 +};
93338 +
93339 +struct size_overflow_hash _001790_hash = {
93340 + .next = NULL,
93341 + .name = "i915_max_freq_read",
93342 + .file = "drivers/gpu/drm/i915/i915_debugfs.c",
93343 + .param3 = 1,
93344 +};
93345 +
93346 +struct size_overflow_hash _001791_hash = {
93347 + .next = NULL,
93348 + .name = "i915_max_freq_write",
93349 + .file = "drivers/gpu/drm/i915/i915_debugfs.c",
93350 + .param3 = 1,
93351 +};
93352 +
93353 +struct size_overflow_hash _001792_hash = {
93354 + .next = NULL,
93355 + .name = "i915_wedged_read",
93356 + .file = "drivers/gpu/drm/i915/i915_debugfs.c",
93357 + .param3 = 1,
93358 +};
93359 +
93360 +struct size_overflow_hash _001793_hash = {
93361 + .next = NULL,
93362 + .name = "i915_wedged_write",
93363 + .file = "drivers/gpu/drm/i915/i915_debugfs.c",
93364 + .param3 = 1,
93365 +};
93366 +
93367 +struct size_overflow_hash _001794_hash = {
93368 + .next = NULL,
93369 + .name = "__module_alloc",
93370 + .file = "arch/x86/kernel/module.c",
93371 + .param1 = 1,
93372 +};
93373 +
93374 +struct size_overflow_hash _001795_hash = {
93375 + .next = NULL,
93376 + .name = "module_alloc_update_bounds_rw",
93377 + .file = "kernel/module.c",
93378 + .param1 = 1,
93379 +};
93380 +
93381 +struct size_overflow_hash _001796_hash = {
93382 + .next = NULL,
93383 + .name = "module_alloc_update_bounds_rx",
93384 + .file = "kernel/module.c",
93385 + .param1 = 1,
93386 +};
93387 +
93388 +struct size_overflow_hash _001797_hash = {
93389 + .next = NULL,
93390 + .name = "p9_client_read",
93391 + .file = "include/net/9p/client.h",
93392 + .param5 = 1,
93393 +};
93394 +
93395 +struct size_overflow_hash _001798_hash = {
93396 + .next = NULL,
93397 + .name = "probe_kernel_write",
93398 + .file = "include/linux/uaccess.h",
93399 + .param3 = 1,
93400 +};
93401 +
93402 +struct size_overflow_hash _001799_hash = {
93403 + .next = NULL,
93404 + .name = "sched_feat_write",
93405 + .file = "kernel/sched/core.c",
93406 + .param3 = 1,
93407 +};
93408 +
93409 +struct size_overflow_hash _001800_hash = {
93410 + .next = NULL,
93411 + .name = "tstats_write",
93412 + .file = "kernel/time/timer_stats.c",
93413 + .param3 = 1,
93414 +};
93415 +
93416 +struct size_overflow_hash _001801_hash = {
93417 + .next = NULL,
93418 + .name = "ttm_bo_fbdev_io",
93419 + .file = "drivers/gpu/drm/ttm/ttm_bo_vm.c",
93420 + .param4 = 1,
93421 +};
93422 +
93423 +struct size_overflow_hash _001802_hash = {
93424 + .next = NULL,
93425 + .name = "ttm_bo_io",
93426 + .file = "drivers/gpu/drm/ttm/ttm_bo_vm.c",
93427 + .param5 = 1,
93428 +};
93429 +
93430 +struct size_overflow_hash _001803_hash = {
93431 + .next = NULL,
93432 + .name = "ttm_dma_page_pool_free",
93433 + .file = "drivers/gpu/drm/ttm/ttm_page_alloc_dma.c",
93434 + .param2 = 1,
93435 +};
93436 +
93437 +struct size_overflow_hash _001804_hash = {
93438 + .next = NULL,
93439 + .name = "ttm_page_pool_free",
93440 + .file = "drivers/gpu/drm/ttm/ttm_page_alloc.c",
93441 + .param2 = 1,
93442 +};
93443 +
93444 +struct size_overflow_hash _001805_hash = {
93445 + .next = NULL,
93446 + .name = "vmw_execbuf_process",
93447 + .file = "drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c",
93448 + .param5 = 1,
93449 +};
93450 +
93451 +struct size_overflow_hash _001806_hash = {
93452 + .next = NULL,
93453 + .name = "vmw_fifo_reserve",
93454 + .file = "drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c",
93455 + .param2 = 1,
93456 +};
93457 +
93458 +struct size_overflow_hash _001807_hash = {
93459 + .next = NULL,
93460 + .name = "vmw_kms_present",
93461 + .file = "drivers/gpu/drm/vmwgfx/vmwgfx_kms.c",
93462 + .param9 = 1,
93463 +};
93464 +
93465 +struct size_overflow_hash _001808_hash = {
93466 + .next = NULL,
93467 + .name = "vmw_kms_readback",
93468 + .file = "drivers/gpu/drm/vmwgfx/vmwgfx_kms.c",
93469 + .param6 = 1,
93470 +};
93471 +
93472 +struct size_overflow_hash _001809_hash = {
93473 + .next = NULL,
93474 + .name = "acpi_system_write_alarm",
93475 + .file = "drivers/acpi/proc.c",
93476 + .param3 = 1,
93477 +};
93478 +
93479 +struct size_overflow_hash _001810_hash = {
93480 + .next = NULL,
93481 + .name = "kmalloc",
93482 + .file = "include/linux/slab_def.h",
93483 + .param1 = 1,
93484 +};
93485 +
93486 +struct size_overflow_hash _001811_hash = {
93487 + .next = NULL,
93488 + .name = "slabinfo_write",
93489 + .file = "mm/slab.c",
93490 + .param3 = 1,
93491 +};
93492 +
93493 +struct size_overflow_hash *size_overflow_hash[65536] = {
93494 + [56878] = &_000001_hash,
93495 + [11151] = &_000002_hash,
93496 + [17854] = &_000003_hash,
93497 + [4132] = &_000004_hash,
93498 + [39070] = &_000005_hash,
93499 + [35447] = &_000007_hash,
93500 + [47830] = &_000008_hash,
93501 + [65254] = &_000009_hash,
93502 + [17521] = &_000011_hash,
93503 + [41425] = &_000012_hash,
93504 + [5785] = &_000013_hash,
93505 + [19960] = &_000014_hash,
93506 + [26729] = &_000015_hash,
93507 + [7954] = &_000016_hash,
93508 + [22403] = &_000017_hash,
93509 + [23258] = &_000018_hash,
93510 + [55695] = &_000019_hash,
93511 + [38964] = &_000020_hash,
93512 + [64250] = &_000021_hash,
93513 + [31825] = &_000022_hash,
93514 + [47446] = &_000023_hash,
93515 + [61521] = &_000024_hash,
93516 + [64227] = &_000025_hash,
93517 + [53378] = &_000026_hash,
93518 + [8885] = &_000027_hash,
93519 + [62101] = &_000028_hash,
93520 + [18152] = &_000029_hash,
93521 + [37525] = &_000030_hash,
93522 + [25827] = &_000031_hash,
93523 + [1169] = &_000032_hash,
93524 + [11925] = &_000033_hash,
93525 + [20558] = &_000034_hash,
93526 + [44019] = &_000035_hash,
93527 + [21909] = &_000036_hash,
93528 + [63679] = &_000037_hash,
93529 + [39450] = &_000038_hash,
93530 + [25085] = &_000039_hash,
93531 + [17830] = &_000040_hash,
93532 + [14329] = &_000041_hash,
93533 + [31235] = &_000042_hash,
93534 + [48207] = &_000043_hash,
93535 + [34918] = &_000044_hash,
93536 + [46839] = &_000045_hash,
93537 + [57930] = &_000046_hash,
93538 + [41364] = &_000047_hash,
93539 + [17581] = &_000048_hash,
93540 + [45922] = &_000049_hash,
93541 + [49567] = &_000050_hash,
93542 + [18248] = &_000051_hash,
93543 + [25528] = &_000052_hash,
93544 + [61874] = &_000053_hash,
93545 + [22591] = &_000054_hash,
93546 + [48456] = &_000055_hash,
93547 + [8743] = &_000056_hash,
93548 + [39131] = &_000057_hash,
93549 + [48328] = &_000058_hash,
93550 + [47136] = &_000059_hash,
93551 + [6358] = &_000060_hash,
93552 + [12252] = &_000061_hash,
93553 + [49340] = &_000062_hash,
93554 + [45875] = &_000063_hash,
93555 + [52182] = &_000065_hash,
93556 + [31149] = &_000067_hash,
93557 + [20455] = &_000068_hash,
93558 + [19917] = &_000070_hash,
93559 + [64771] = &_000071_hash,
93560 + [25140] = &_000072_hash,
93561 + [34097] = &_000073_hash,
93562 + [58131] = &_000074_hash,
93563 + [65311] = &_000075_hash,
93564 + [60609] = &_000076_hash,
93565 + [1917] = &_000077_hash,
93566 + [15337] = &_000078_hash,
93567 + [4732] = &_000079_hash,
93568 + [38783] = &_000080_hash,
93569 + [37249] = &_000081_hash,
93570 + [9234] = &_000082_hash,
93571 + [33309] = &_000083_hash,
93572 + [22389] = &_000084_hash,
93573 + [56319] = &_000085_hash,
93574 + [21496] = &_000086_hash,
93575 + [8163] = &_000087_hash,
93576 + [58766] = &_000088_hash,
93577 + [21048] = &_000089_hash,
93578 + [51221] = &_000090_hash,
93579 + [21498] = &_000091_hash,
93580 + [42627] = &_000092_hash,
93581 + [53059] = &_000094_hash,
93582 + [52870] = &_000095_hash,
93583 + [1567] = &_000096_hash,
93584 + [38330] = &_000097_hash,
93585 + [30892] = &_000098_hash,
93586 + [16927] = &_000099_hash,
93587 + [16461] = &_000100_hash,
93588 + [5634] = &_000101_hash,
93589 + [16496] = &_000103_hash,
93590 + [40012] = &_000104_hash,
93591 + [46014] = &_000105_hash,
93592 + [39600] = &_000106_hash,
93593 + [7435] = &_000107_hash,
93594 + [13332] = &_000109_hash,
93595 + [36665] = &_000110_hash,
93596 + [12413] = &_000111_hash,
93597 + [27279] = &_000112_hash,
93598 + [44774] = &_000113_hash,
93599 + [14479] = &_000114_hash,
93600 + [32447] = &_000115_hash,
93601 + [15439] = &_000116_hash,
93602 + [17932] = &_000117_hash,
93603 + [26096] = &_000118_hash,
93604 + [50814] = &_000119_hash,
93605 + [22598] = &_000120_hash,
93606 + [48287] = &_000121_hash,
93607 + [15611] = &_000122_hash,
93608 + [13414] = &_000123_hash,
93609 + [40371] = &_000124_hash,
93610 + [284] = &_000125_hash,
93611 + [6293] = &_000127_hash,
93612 + [60587] = &_000128_hash,
93613 + [8181] = &_000129_hash,
93614 + [27451] = &_000130_hash,
93615 + [29259] = &_000131_hash,
93616 + [41172] = &_000132_hash,
93617 + [3315] = &_000133_hash,
93618 + [37550] = &_000134_hash,
93619 + [40395] = &_000135_hash,
93620 + [24124] = &_000136_hash,
93621 + [63535] = &_000137_hash,
93622 + [14981] = &_000138_hash,
93623 + [52008] = &_000139_hash,
93624 + [22091] = &_000140_hash,
93625 + [64800] = &_000141_hash,
93626 + [14919] = &_000142_hash,
93627 + [60340] = &_000143_hash,
93628 + [34205] = &_000145_hash,
93629 + [65246] = &_000146_hash,
93630 + [1299] = &_000147_hash,
93631 + [33165] = &_000148_hash,
93632 + [22394] = &_000149_hash,
93633 + [49562] = &_000150_hash,
93634 + [56881] = &_000151_hash,
93635 + [13870] = &_000152_hash,
93636 + [65074] = &_000153_hash,
93637 + [11553] = &_000154_hash,
93638 + [43222] = &_000155_hash,
93639 + [17984] = &_000156_hash,
93640 + [26811] = &_000157_hash,
93641 + [30848] = &_000158_hash,
93642 + [15627] = &_000159_hash,
93643 + [43101] = &_000160_hash,
93644 + [4082] = &_000161_hash,
93645 + [43692] = &_000162_hash,
93646 + [21622] = &_000163_hash,
93647 + [50734] = &_000164_hash,
93648 + [803] = &_000166_hash,
93649 + [64674] = &_000168_hash,
93650 + [57538] = &_000170_hash,
93651 + [42442] = &_000171_hash,
93652 + [23031] = &_000172_hash,
93653 + [40663] = &_000173_hash,
93654 + [51180] = &_000174_hash,
93655 + [24173] = &_000175_hash,
93656 + [9286] = &_000176_hash,
93657 + [49517] = &_000177_hash,
93658 + [34878] = &_000180_hash,
93659 + [22819] = &_000181_hash,
93660 + [64314] = &_000182_hash,
93661 + [20494] = &_000183_hash,
93662 + [9483] = &_000184_hash,
93663 + [26518] = &_000185_hash,
93664 + [44651] = &_000186_hash,
93665 + [1188] = &_000187_hash,
93666 + [36031] = &_000188_hash,
93667 + [33469] = &_000189_hash,
93668 + [19672] = &_000190_hash,
93669 + [3216] = &_000191_hash,
93670 + [25071] = &_000192_hash,
93671 + [11744] = &_000194_hash,
93672 + [2358] = &_000196_hash,
93673 + [10146] = &_000198_hash,
93674 + [58709] = &_000199_hash,
93675 + [64773] = &_000200_hash,
93676 + [6159] = &_000201_hash,
93677 + [28617] = &_000202_hash,
93678 + [61067] = &_000203_hash,
93679 + [12884] = &_000204_hash,
93680 + [37308] = &_000205_hash,
93681 + [59973] = &_000206_hash,
93682 + [35895] = &_000207_hash,
93683 + [24951] = &_000208_hash,
93684 + [3070] = &_000209_hash,
93685 + [61023] = &_000210_hash,
93686 + [45702] = &_000211_hash,
93687 + [5533] = &_000212_hash,
93688 + [29186] = &_000213_hash,
93689 + [26311] = &_000214_hash,
93690 + [40182] = &_000215_hash,
93691 + [50505] = &_000216_hash,
93692 + [59061] = &_000217_hash,
93693 + [27511] = &_000218_hash,
93694 + [63286] = &_000219_hash,
93695 + [6678] = &_000220_hash,
93696 + [23065] = &_000222_hash,
93697 + [18156] = &_000223_hash,
93698 + [53757] = &_000224_hash,
93699 + [53720] = &_000225_hash,
93700 + [50241] = &_000226_hash,
93701 + [22498] = &_000227_hash,
93702 + [10991] = &_000228_hash,
93703 + [40026] = &_000229_hash,
93704 + [19995] = &_000230_hash,
93705 + [30445] = &_000231_hash,
93706 + [57691] = &_000232_hash,
93707 + [23150] = &_000233_hash,
93708 + [9960] = &_000234_hash,
93709 + [8736] = &_000235_hash,
93710 + [23750] = &_000237_hash,
93711 + [18393] = &_000238_hash,
93712 + [28541] = &_000240_hash,
93713 + [59944] = &_000241_hash,
93714 + [35042] = &_000242_hash,
93715 + [63488] = &_000243_hash,
93716 + [27286] = &_000244_hash,
93717 + [46922] = &_000245_hash,
93718 + [11860] = &_000246_hash,
93719 + [52928] = &_000247_hash,
93720 + [46714] = &_000248_hash,
93721 + [57313] = &_000249_hash,
93722 + [61978] = &_000250_hash,
93723 + [61063] = &_000251_hash,
93724 + [22271] = &_000252_hash,
93725 + [4214] = &_000253_hash,
93726 + [46247] = &_000254_hash,
93727 + [33246] = &_000255_hash,
93728 + [58325] = &_000257_hash,
93729 + [47399] = &_000259_hash,
93730 + [34963] = &_000260_hash,
93731 + [21221] = &_000261_hash,
93732 + [32211] = &_000262_hash,
93733 + [20854] = &_000263_hash,
93734 + [49351] = &_000264_hash,
93735 + [52341] = &_000265_hash,
93736 + [53533] = &_000266_hash,
93737 + [52267] = &_000267_hash,
93738 + [46753] = &_000268_hash,
93739 + [2115] = &_000269_hash,
93740 + [44017] = &_000271_hash,
93741 + [13495] = &_000272_hash,
93742 + [12988] = &_000273_hash,
93743 + [55227] = &_000274_hash,
93744 + [47762] = &_000276_hash,
93745 + [17613] = &_000277_hash,
93746 + [52037] = &_000278_hash,
93747 + [5994] = &_000279_hash,
93748 + [46818] = &_000280_hash,
93749 + [13467] = &_000281_hash,
93750 + [61848] = &_000282_hash,
93751 + [43082] = &_000284_hash,
93752 + [55732] = &_000286_hash,
93753 + [2543] = &_000287_hash,
93754 + [51694] = &_000288_hash,
93755 + [18402] = &_000289_hash,
93756 + [38282] = &_000290_hash,
93757 + [5456] = &_000291_hash,
93758 + [58261] = &_000292_hash,
93759 + [24792] = &_000293_hash,
93760 + [6422] = &_000294_hash,
93761 + [63953] = &_000295_hash,
93762 + [27384] = &_000296_hash,
93763 + [47213] = &_000297_hash,
93764 + [23548] = &_000298_hash,
93765 + [47858] = &_000299_hash,
93766 + [52501] = &_000300_hash,
93767 + [12475] = &_000301_hash,
93768 + [52921] = &_000302_hash,
93769 + [19120] = &_000303_hash,
93770 + [14355] = &_000304_hash,
93771 + [30563] = &_000305_hash,
93772 + [14942] = &_000306_hash,
93773 + [30969] = &_000307_hash,
93774 + [57776] = &_000308_hash,
93775 + [21956] = &_000309_hash,
93776 + [44050] = &_000310_hash,
93777 + [2193] = &_000311_hash,
93778 + [44818] = &_000312_hash,
93779 + [50616] = &_000313_hash,
93780 + [49299] = &_000314_hash,
93781 + [2796] = &_000315_hash,
93782 + [4190] = &_000316_hash,
93783 + [11548] = &_000317_hash,
93784 + [53798] = &_000318_hash,
93785 + [60370] = &_000319_hash,
93786 + [35863] = &_000320_hash,
93787 + [54595] = &_000322_hash,
93788 + [2808] = &_000323_hash,
93789 + [24656] = &_000324_hash,
93790 + [895] = &_000325_hash,
93791 + [32809] = &_000326_hash,
93792 + [55621] = &_000327_hash,
93793 + [1733] = &_000328_hash,
93794 + [36069] = &_000330_hash,
93795 + [23714] = &_000331_hash,
93796 + [26020] = &_000332_hash,
93797 + [63875] = &_000333_hash,
93798 + [58608] = &_000334_hash,
93799 + [8919] = &_000335_hash,
93800 + [23906] = &_000336_hash,
93801 + [59497] = &_000337_hash,
93802 + [34782] = &_000338_hash,
93803 + [40998] = &_000339_hash,
93804 + [33328] = &_000340_hash,
93805 + [17866] = &_000341_hash,
93806 + [38741] = &_000342_hash,
93807 + [53939] = &_000343_hash,
93808 + [14658] = &_000344_hash,
93809 + [42465] = &_000345_hash,
93810 + [49600] = &_000346_hash,
93811 + [7391] = &_000347_hash,
93812 + [43616] = &_000348_hash,
93813 + [16775] = &_000349_hash,
93814 + [41393] = &_000350_hash,
93815 + [10532] = &_000351_hash,
93816 + [50366] = &_000352_hash,
93817 + [33324] = &_000353_hash,
93818 + [38200] = &_000354_hash,
93819 + [59315] = &_000355_hash,
93820 + [33916] = &_000356_hash,
93821 + [36593] = &_000357_hash,
93822 + [63079] = &_000358_hash,
93823 + [379] = &_000359_hash,
93824 + [34248] = &_000360_hash,
93825 + [27251] = &_000361_hash,
93826 + [29460] = &_000362_hash,
93827 + [7461] = &_000363_hash,
93828 + [9870] = &_000364_hash,
93829 + [44596] = &_000365_hash,
93830 + [45157] = &_000366_hash,
93831 + [55069] = &_000367_hash,
93832 + [29452] = &_000368_hash,
93833 + [54888] = &_000369_hash,
93834 + [31885] = &_000370_hash,
93835 + [20206] = &_000371_hash,
93836 + [59852] = &_000372_hash,
93837 + [20325] = &_000373_hash,
93838 + [18488] = &_000374_hash,
93839 + [22017] = &_000375_hash,
93840 + [57485] = &_000376_hash,
93841 + [49827] = &_000377_hash,
93842 + [37770] = &_000379_hash,
93843 + [52668] = &_000380_hash,
93844 + [13724] = &_000381_hash,
93845 + [59701] = &_000382_hash,
93846 + [11954] = &_000383_hash,
93847 + [9890] = &_000384_hash,
93848 + [17684] = &_000385_hash,
93849 + [18158] = &_000386_hash,
93850 + [61318] = &_000387_hash,
93851 + [2760] = &_000388_hash,
93852 + [38444] = &_000390_hash,
93853 + [55856] = &_000392_hash,
93854 + [34762] = &_000393_hash,
93855 + [48360] = &_000394_hash,
93856 + [40885] = &_000395_hash,
93857 + [36032] = &_000396_hash,
93858 + [52057] = &_000397_hash,
93859 + [12463] = &_000398_hash,
93860 + [30616] = &_000399_hash,
93861 + [38680] = &_000400_hash,
93862 + [41742] = &_000401_hash,
93863 + [50662] = &_000402_hash,
93864 + [48440] = &_000403_hash,
93865 + [34418] = &_000404_hash,
93866 + [64275] = &_000405_hash,
93867 + [12231] = &_000406_hash,
93868 + [53530] = &_000407_hash,
93869 + [54723] = &_000408_hash,
93870 + [19490] = &_000409_hash,
93871 + [11595] = &_000410_hash,
93872 + [15277] = &_000411_hash,
93873 + [4811] = &_000412_hash,
93874 + [42017] = &_000413_hash,
93875 + [17238] = &_000414_hash,
93876 + [55439] = &_000415_hash,
93877 + [45794] = &_000416_hash,
93878 + [60027] = &_000417_hash,
93879 + [3750] = &_000418_hash,
93880 + [11091] = &_000419_hash,
93881 + [32935] = &_000420_hash,
93882 + [22809] = &_000422_hash,
93883 + [60193] = &_000423_hash,
93884 + [14396] = &_000424_hash,
93885 + [18101] = &_000425_hash,
93886 + [46395] = &_000426_hash,
93887 + [24339] = &_000427_hash,
93888 + [26065] = &_000428_hash,
93889 + [43016] = &_000429_hash,
93890 + [41996] = &_000430_hash,
93891 + [7371] = &_000431_hash,
93892 + [32968] = &_000432_hash,
93893 + [53082] = &_000433_hash,
93894 + [38798] = &_000434_hash,
93895 + [12726] = &_000435_hash,
93896 + [55018] = &_000436_hash,
93897 + [26114] = &_000437_hash,
93898 + [31697] = &_000438_hash,
93899 + [21401] = &_000441_hash,
93900 + [33193] = &_000442_hash,
93901 + [52271] = &_000443_hash,
93902 + [20847] = &_000444_hash,
93903 + [30754] = &_000445_hash,
93904 + [54440] = &_000446_hash,
93905 + [22059] = &_000447_hash,
93906 + [47566] = &_000448_hash,
93907 + [22926] = &_000449_hash,
93908 + [20788] = &_000450_hash,
93909 + [18162] = &_000451_hash,
93910 + [65006] = &_000452_hash,
93911 + [11523] = &_000453_hash,
93912 + [29207] = &_000454_hash,
93913 + [18071] = &_000455_hash,
93914 + [7601] = &_000456_hash,
93915 + [12773] = &_000457_hash,
93916 + [61543] = &_000458_hash,
93917 + [5578] = &_000460_hash,
93918 + [49050] = &_000461_hash,
93919 + [51965] = &_000462_hash,
93920 + [6807] = &_000463_hash,
93921 + [22982] = &_000464_hash,
93922 + [36769] = &_000465_hash,
93923 + [53892] = &_000466_hash,
93924 + [2547] = &_000467_hash,
93925 + [53678] = &_000468_hash,
93926 + [61439] = &_000469_hash,
93927 + [31287] = &_000470_hash,
93928 + [6125] = &_000471_hash,
93929 + [57511] = &_000472_hash,
93930 + [13001] = &_000473_hash,
93931 + [62932] = &_000474_hash,
93932 + [62284] = &_000475_hash,
93933 + [9472] = &_000476_hash,
93934 + [26260] = &_000477_hash,
93935 + [63065] = &_000478_hash,
93936 + [18949] = &_000479_hash,
93937 + [29891] = &_000481_hash,
93938 + [41916] = &_000482_hash,
93939 + [40474] = &_000483_hash,
93940 + [63551] = &_000484_hash,
93941 + [36557] = &_000485_hash,
93942 + [2994] = &_000486_hash,
93943 + [5521] = &_000487_hash,
93944 + [51016] = &_000488_hash,
93945 + [7644] = &_000489_hash,
93946 + [55103] = &_000490_hash,
93947 + [11488] = &_000491_hash,
93948 + [7184] = &_000492_hash,
93949 + [36934] = &_000493_hash,
93950 + [54855] = &_000494_hash,
93951 + [63193] = &_000495_hash,
93952 + [12369] = &_000496_hash,
93953 + [15828] = &_000497_hash,
93954 + [61322] = &_000498_hash,
93955 + [5412] = &_000499_hash,
93956 + [28089] = &_000500_hash,
93957 + [64306] = &_000502_hash,
93958 + [24071] = &_000503_hash,
93959 + [50308] = &_000504_hash,
93960 + [38790] = &_000505_hash,
93961 + [9838] = &_000506_hash,
93962 + [18983] = &_000507_hash,
93963 + [9656] = &_000508_hash,
93964 + [18950] = &_000509_hash,
93965 + [59749] = &_000510_hash,
93966 + [20465] = &_000511_hash,
93967 + [4765] = &_000512_hash,
93968 + [16169] = &_000513_hash,
93969 + [6930] = &_000514_hash,
93970 + [16926] = &_000515_hash,
93971 + [35218] = &_000516_hash,
93972 + [19956] = &_000517_hash,
93973 + [55255] = &_000518_hash,
93974 + [861] = &_000519_hash,
93975 + [26574] = &_000520_hash,
93976 + [26794] = &_000521_hash,
93977 + [2133] = &_000522_hash,
93978 + [44616] = &_000523_hash,
93979 + [12840] = &_000524_hash,
93980 + [60426] = &_000525_hash,
93981 + [18133] = &_000526_hash,
93982 + [30479] = &_000527_hash,
93983 + [3219] = &_000528_hash,
93984 + [36488] = &_000529_hash,
93985 + [62043] = &_000530_hash,
93986 + [21714] = &_000532_hash,
93987 + [48007] = &_000533_hash,
93988 + [49969] = &_000534_hash,
93989 + [7701] = &_000535_hash,
93990 + [11521] = &_000536_hash,
93991 + [4269] = &_000537_hash,
93992 + [37627] = &_000539_hash,
93993 + [33555] = &_000540_hash,
93994 + [25900] = &_000541_hash,
93995 + [31709] = &_000542_hash,
93996 + [44626] = &_000544_hash,
93997 + [1679] = &_000545_hash,
93998 + [18349] = &_000546_hash,
93999 + [15338] = &_000547_hash,
94000 + [57935] = &_000548_hash,
94001 + [55850] = &_000549_hash,
94002 + [36063] = &_000550_hash,
94003 + [56674] = &_000551_hash,
94004 + [21379] = &_000552_hash,
94005 + [18507] = &_000553_hash,
94006 + [55719] = &_000554_hash,
94007 + [31210] = &_000555_hash,
94008 + [36207] = &_000556_hash,
94009 + [64180] = &_000557_hash,
94010 + [41770] = &_000558_hash,
94011 + [11600] = &_000559_hash,
94012 + [36638] = &_000560_hash,
94013 + [25576] = &_000561_hash,
94014 + [7000] = &_000562_hash,
94015 + [34187] = &_000563_hash,
94016 + [58533] = &_000564_hash,
94017 + [5083] = &_000565_hash,
94018 + [62614] = &_000566_hash,
94019 + [20085] = &_000567_hash,
94020 + [1135] = &_000568_hash,
94021 + [25613] = &_000569_hash,
94022 + [9541] = &_000570_hash,
94023 + [30577] = &_000571_hash,
94024 + [35722] = &_000572_hash,
94025 + [60407] = &_000573_hash,
94026 + [29465] = &_000574_hash,
94027 + [46891] = &_000575_hash,
94028 + [43633] = &_000576_hash,
94029 + [53743] = &_000577_hash,
94030 + [16196] = &_000578_hash,
94031 + [34425] = &_000580_hash,
94032 + [9646] = &_000581_hash,
94033 + [59756] = &_000583_hash,
94034 + [45524] = &_000584_hash,
94035 + [36702] = &_000585_hash,
94036 + [36747] = &_000586_hash,
94037 + [33643] = &_000588_hash,
94038 + [29158] = &_000589_hash,
94039 + [49662] = &_000590_hash,
94040 + [51062] = &_000591_hash,
94041 + [64755] = &_000592_hash,
94042 + [4829] = &_000594_hash,
94043 + [16413] = &_000595_hash,
94044 + [36125] = &_000596_hash,
94045 + [36293] = &_000597_hash,
94046 + [39712] = &_000598_hash,
94047 + [32160] = &_000599_hash,
94048 + [22962] = &_000600_hash,
94049 + [32001] = &_000601_hash,
94050 + [35828] = &_000602_hash,
94051 + [3106] = &_000603_hash,
94052 + [34039] = &_000604_hash,
94053 + [22393] = &_000605_hash,
94054 + [3560] = &_000606_hash,
94055 + [28195] = &_000607_hash,
94056 + [2062] = &_000608_hash,
94057 + [64001] = &_000609_hash,
94058 + [42407] = &_000610_hash,
94059 + [6253] = &_000611_hash,
94060 + [58640] = &_000612_hash,
94061 + [32195] = &_000613_hash,
94062 + [26197] = &_000614_hash,
94063 + [58003] = &_000615_hash,
94064 + [21662] = &_000616_hash,
94065 + [45750] = &_000617_hash,
94066 + [25798] = &_000618_hash,
94067 + [41052] = &_000619_hash,
94068 + [14096] = &_000620_hash,
94069 + [1439] = &_000621_hash,
94070 + [29074] = &_000622_hash,
94071 + [2376] = &_000623_hash,
94072 + [24068] = &_000625_hash,
94073 + [59519] = &_000627_hash,
94074 + [9893] = &_000628_hash,
94075 + [39979] = &_000630_hash,
94076 + [41540] = &_000631_hash,
94077 + [43200] = &_000633_hash,
94078 + [33494] = &_000634_hash,
94079 + [2028] = &_000635_hash,
94080 + [27206] = &_000636_hash,
94081 + [24302] = &_000637_hash,
94082 + [38112] = &_000638_hash,
94083 + [46538] = &_000639_hash,
94084 + [35228] = &_000641_hash,
94085 + [8339] = &_000642_hash,
94086 + [45349] = &_000643_hash,
94087 + [48404] = &_000644_hash,
94088 + [37865] = &_000645_hash,
94089 + [45763] = &_000646_hash,
94090 + [62347] = &_000647_hash,
94091 + [21644] = &_000648_hash,
94092 + [53135] = &_000649_hash,
94093 + [25095] = &_000650_hash,
94094 + [11697] = &_000651_hash,
94095 + [27003] = &_000652_hash,
94096 + [32464] = &_000653_hash,
94097 + [65339] = &_000654_hash,
94098 + [44248] = &_000655_hash,
94099 + [16] = &_000656_hash,
94100 + [29933] = &_000657_hash,
94101 + [34359] = &_000658_hash,
94102 + [3154] = &_000659_hash,
94103 + [59308] = &_000660_hash,
94104 + [61661] = &_000661_hash,
94105 + [23959] = &_000662_hash,
94106 + [6724] = &_000663_hash,
94107 + [54587] = &_000664_hash,
94108 + [28479] = &_000665_hash,
94109 + [56583] = &_000666_hash,
94110 + [64644] = &_000667_hash,
94111 + [23284] = &_000668_hash,
94112 + [61655] = &_000669_hash,
94113 + [20980] = &_000670_hash,
94114 + [19794] = &_000671_hash,
94115 + [30036] = &_000672_hash,
94116 + [25649] = &_000673_hash,
94117 + [47428] = &_000674_hash,
94118 + [47737] = &_000675_hash,
94119 + [8367] = &_000676_hash,
94120 + [2987] = &_000677_hash,
94121 + [50962] = &_000678_hash,
94122 + [10760] = &_000679_hash,
94123 + [31678] = &_000680_hash,
94124 + [48558] = &_000681_hash,
94125 + [2274] = &_000682_hash,
94126 + [831] = &_000683_hash,
94127 + [61833] = &_000684_hash,
94128 + [56864] = &_000685_hash,
94129 + [31040] = &_000686_hash,
94130 + [22196] = &_000687_hash,
94131 + [20076] = &_000688_hash,
94132 + [52821] = &_000689_hash,
94133 + [21896] = &_000690_hash,
94134 + [49367] = &_000691_hash,
94135 + [64731] = &_000692_hash,
94136 + [37110] = &_000693_hash,
94137 + [53694] = &_000694_hash,
94138 + [6175] = &_000695_hash,
94139 + [33048] = &_000696_hash,
94140 + [34746] = &_000697_hash,
94141 + [23777] = &_000698_hash,
94142 + [53828] = &_000699_hash,
94143 + [26539] = &_000700_hash,
94144 + [42628] = &_000701_hash,
94145 + [59115] = &_000702_hash,
94146 + [4456] = &_000703_hash,
94147 + [63619] = &_000704_hash,
94148 + [47329] = &_000705_hash,
94149 + [13534] = &_000706_hash,
94150 + [36955] = &_000707_hash,
94151 + [9841] = &_000708_hash,
94152 + [19308] = &_000709_hash,
94153 + [52439] = &_000710_hash,
94154 + [24680] = &_000711_hash,
94155 + [55652] = &_000712_hash,
94156 + [7842] = &_000713_hash,
94157 + [6500] = &_000714_hash,
94158 + [33485] = &_000715_hash,
94159 + [49920] = &_000716_hash,
94160 + [50750] = &_000717_hash,
94161 + [22318] = &_000718_hash,
94162 + [44599] = &_000719_hash,
94163 + [46403] = &_000720_hash,
94164 + [44534] = &_000721_hash,
94165 + [303] = &_000722_hash,
94166 + [22960] = &_000723_hash,
94167 + [10544] = &_000724_hash,
94168 + [8236] = &_000725_hash,
94169 + [21239] = &_000726_hash,
94170 + [24712] = &_000727_hash,
94171 + [37974] = &_000728_hash,
94172 + [62082] = &_000729_hash,
94173 + [57054] = &_000730_hash,
94174 + [53265] = &_000731_hash,
94175 + [52239] = &_000732_hash,
94176 + [14753] = &_000733_hash,
94177 + [60221] = &_000736_hash,
94178 + [27142] = &_000737_hash,
94179 + [14295] = &_000738_hash,
94180 + [25923] = &_000739_hash,
94181 + [29213] = &_000740_hash,
94182 + [31865] = &_000741_hash,
94183 + [4764] = &_000742_hash,
94184 + [10574] = &_000743_hash,
94185 + [55766] = &_000744_hash,
94186 + [22483] = &_000745_hash,
94187 + [61047] = &_000746_hash,
94188 + [41044] = &_000747_hash,
94189 + [58978] = &_000748_hash,
94190 + [47578] = &_000749_hash,
94191 + [7730] = &_000750_hash,
94192 + [15904] = &_000751_hash,
94193 + [25081] = &_000752_hash,
94194 + [45743] = &_000753_hash,
94195 + [58830] = &_000754_hash,
94196 + [59081] = &_000755_hash,
94197 + [47533] = &_000756_hash,
94198 + [11305] = &_000757_hash,
94199 + [29096] = &_000758_hash,
94200 + [19749] = &_000759_hash,
94201 + [56290] = &_000760_hash,
94202 + [44963] = &_000761_hash,
94203 + [30026] = &_000762_hash,
94204 + [27694] = &_000763_hash,
94205 + [8089] = &_000764_hash,
94206 + [38583] = &_000765_hash,
94207 + [1144] = &_000766_hash,
94208 + [20939] = &_000767_hash,
94209 + [22231] = &_000768_hash,
94210 + [17486] = &_000769_hash,
94211 + [51811] = &_000770_hash,
94212 + [62746] = &_000771_hash,
94213 + [19181] = &_000772_hash,
94214 + [52661] = &_000773_hash,
94215 + [51148] = &_000774_hash,
94216 + [49864] = &_000775_hash,
94217 + [37978] = &_000776_hash,
94218 + [6280] = &_000777_hash,
94219 + [12961] = &_000778_hash,
94220 + [60541] = &_000779_hash,
94221 + [37021] = &_000780_hash,
94222 + [26028] = &_000781_hash,
94223 + [41363] = &_000782_hash,
94224 + [42016] = &_000783_hash,
94225 + [58540] = &_000784_hash,
94226 + [2326] = &_000785_hash,
94227 + [60981] = &_000786_hash,
94228 + [13313] = &_000787_hash,
94229 + [44188] = &_000788_hash,
94230 + [34638] = &_000789_hash,
94231 + [20304] = &_000790_hash,
94232 + [60975] = &_000791_hash,
94233 + [12244] = &_000792_hash,
94234 + [16266] = &_000793_hash,
94235 + [3395] = &_000794_hash,
94236 + [63321] = &_000795_hash,
94237 + [20509] = &_000796_hash,
94238 + [57365] = &_000797_hash,
94239 + [47449] = &_000798_hash,
94240 + [56693] = &_000799_hash,
94241 + [33936] = &_000800_hash,
94242 + [52548] = &_000801_hash,
94243 + [18733] = &_000802_hash,
94244 + [15560] = &_000803_hash,
94245 + [13231] = &_000804_hash,
94246 + [64518] = &_000806_hash,
94247 + [54551] = &_000807_hash,
94248 + [54359] = &_000809_hash,
94249 + [46503] = &_000810_hash,
94250 + [22258] = &_000811_hash,
94251 + [39434] = &_000812_hash,
94252 + [52887] = &_000813_hash,
94253 + [3079] = &_000814_hash,
94254 + [18813] = &_000816_hash,
94255 + [47614] = &_000817_hash,
94256 + [38186] = &_000818_hash,
94257 + [57652] = &_000819_hash,
94258 + [10078] = &_000820_hash,
94259 + [17910] = &_000821_hash,
94260 + [13567] = &_000822_hash,
94261 + [21531] = &_000823_hash,
94262 + [46135] = &_000824_hash,
94263 + [10582] = &_000825_hash,
94264 + [4662] = &_000826_hash,
94265 + [17969] = &_000827_hash,
94266 + [43943] = &_000828_hash,
94267 + [46740] = &_000829_hash,
94268 + [26716] = &_000830_hash,
94269 + [58230] = &_000831_hash,
94270 + [252] = &_000832_hash,
94271 + [15704] = &_000833_hash,
94272 + [59765] = &_000834_hash,
94273 + [7322] = &_000835_hash,
94274 + [43950] = &_000836_hash,
94275 + [53093] = &_000837_hash,
94276 + [21646] = &_000838_hash,
94277 + [57063] = &_000839_hash,
94278 + [17132] = &_000840_hash,
94279 + [53922] = &_000842_hash,
94280 + [49155] = &_000843_hash,
94281 + [16356] = &_000844_hash,
94282 + [60037] = &_000845_hash,
94283 + [17299] = &_000846_hash,
94284 + [25678] = &_000847_hash,
94285 + [15494] = &_000848_hash,
94286 + [15159] = &_000849_hash,
94287 + [28442] = &_000850_hash,
94288 + [3514] = &_000851_hash,
94289 + [38151] = &_000852_hash,
94290 + [4173] = &_000853_hash,
94291 + [7258] = &_000854_hash,
94292 + [65109] = &_000855_hash,
94293 + [58827] = &_000856_hash,
94294 + [33575] = &_000857_hash,
94295 + [33078] = &_000858_hash,
94296 + [47234] = &_000859_hash,
94297 + [39193] = &_000860_hash,
94298 + [10950] = &_000861_hash,
94299 + [15613] = &_000862_hash,
94300 + [16046] = &_000863_hash,
94301 + [50172] = &_000864_hash,
94302 + [26107] = &_000865_hash,
94303 + [60543] = &_000866_hash,
94304 + [56337] = &_000867_hash,
94305 + [47626] = &_000868_hash,
94306 + [24409] = &_000869_hash,
94307 + [11732] = &_000870_hash,
94308 + [30010] = &_000871_hash,
94309 + [51480] = &_000872_hash,
94310 + [28518] = &_000873_hash,
94311 + [2061] = &_000874_hash,
94312 + [10885] = &_000875_hash,
94313 + [29517] = &_000876_hash,
94314 + [45913] = &_000877_hash,
94315 + [51774] = &_000878_hash,
94316 + [62298] = &_000879_hash,
94317 + [8892] = &_000880_hash,
94318 + [64891] = &_000881_hash,
94319 + [64537] = &_000882_hash,
94320 + [38103] = &_000883_hash,
94321 + [55518] = &_000884_hash,
94322 + [27419] = &_000885_hash,
94323 + [13869] = &_000886_hash,
94324 + [53150] = &_000887_hash,
94325 + [2884] = &_000888_hash,
94326 + [10362] = &_000889_hash,
94327 + [6961] = &_000890_hash,
94328 + [56975] = &_000891_hash,
94329 + [12508] = &_000892_hash,
94330 + [54597] = &_000893_hash,
94331 + [60499] = &_000894_hash,
94332 + [50109] = &_000895_hash,
94333 + [944] = &_000896_hash,
94334 + [29229] = &_000897_hash,
94335 + [37648] = &_000898_hash,
94336 + [1568] = &_000899_hash,
94337 + [61793] = &_000900_hash,
94338 + [53395] = &_000901_hash,
94339 + [5519] = &_000902_hash,
94340 + [28637] = &_000903_hash,
94341 + [53687] = &_000904_hash,
94342 + [6783] = &_000905_hash,
94343 + [43312] = &_000906_hash,
94344 + [2373] = &_000907_hash,
94345 + [33482] = &_000908_hash,
94346 + [24886] = &_000909_hash,
94347 + [48154] = &_000910_hash,
94348 + [12838] = &_000911_hash,
94349 + [47012] = &_000912_hash,
94350 + [23691] = &_000913_hash,
94351 + [37924] = &_000914_hash,
94352 + [47346] = &_000915_hash,
94353 + [5624] = &_000916_hash,
94354 + [16842] = &_000918_hash,
94355 + [60399] = &_000919_hash,
94356 + [2312] = &_000920_hash,
94357 + [59212] = &_000921_hash,
94358 + [11923] = &_000922_hash,
94359 + [10805] = &_000923_hash,
94360 + [36577] = &_000924_hash,
94361 + [60948] = &_000925_hash,
94362 + [21711] = &_000926_hash,
94363 + [54830] = &_000927_hash,
94364 + [1822] = &_000928_hash,
94365 + [44573] = &_000929_hash,
94366 + [23805] = &_000930_hash,
94367 + [46061] = &_000931_hash,
94368 + [33996] = &_000932_hash,
94369 + [40856] = &_000933_hash,
94370 + [16299] = &_000934_hash,
94371 + [63446] = &_000935_hash,
94372 + [31205] = &_000936_hash,
94373 + [33100] = &_000937_hash,
94374 + [40843] = &_000938_hash,
94375 + [23712] = &_000939_hash,
94376 + [36962] = &_000940_hash,
94377 + [9845] = &_000942_hash,
94378 + [13738] = &_000943_hash,
94379 + [58099] = &_000944_hash,
94380 + [31869] = &_000945_hash,
94381 + [63501] = &_000946_hash,
94382 + [58188] = &_000947_hash,
94383 + [51338] = &_000948_hash,
94384 + [54999] = &_000949_hash,
94385 + [2434] = &_000950_hash,
94386 + [34958] = &_000951_hash,
94387 + [41487] = &_000952_hash,
94388 + [11941] = &_000953_hash,
94389 + [56728] = &_000954_hash,
94390 + [48150] = &_000955_hash,
94391 + [13905] = &_000956_hash,
94392 + [9054] = &_000957_hash,
94393 + [10758] = &_000958_hash,
94394 + [48056] = &_000959_hash,
94395 + [24231] = &_000960_hash,
94396 + [43748] = &_000961_hash,
94397 + [24237] = &_000962_hash,
94398 + [14899] = &_000963_hash,
94399 + [38652] = &_000964_hash,
94400 + [65013] = &_000965_hash,
94401 + [16645] = &_000967_hash,
94402 + [55031] = &_000968_hash,
94403 + [23978] = &_000969_hash,
94404 + [24208] = &_000970_hash,
94405 + [18098] = &_000971_hash,
94406 + [2303] = &_000972_hash,
94407 + [3338] = &_000973_hash,
94408 + [39219] = &_000974_hash,
94409 + [18609] = &_000976_hash,
94410 + [64412] = &_000977_hash,
94411 + [16962] = &_000978_hash,
94412 + [26346] = &_000979_hash,
94413 + [39380] = &_000980_hash,
94414 + [33020] = &_000981_hash,
94415 + [22639] = &_000982_hash,
94416 + [6453] = &_000983_hash,
94417 + [58602] = &_000984_hash,
94418 + [50920] = &_000985_hash,
94419 + [56471] = &_000987_hash,
94420 + [15378] = &_000988_hash,
94421 + [3589] = &_000989_hash,
94422 + [12558] = &_000990_hash,
94423 + [3201] = &_000991_hash,
94424 + [28175] = &_000993_hash,
94425 + [43888] = &_000995_hash,
94426 + [56010] = &_000996_hash,
94427 + [32456] = &_000997_hash,
94428 + [29036] = &_000998_hash,
94429 + [32330] = &_000999_hash,
94430 + [25603] = &_001000_hash,
94431 + [17675] = &_001001_hash,
94432 + [36271] = &_001002_hash,
94433 + [49814] = &_001003_hash,
94434 + [5693] = &_001004_hash,
94435 + [51009] = &_001005_hash,
94436 + [62835] = &_001006_hash,
94437 + [27139] = &_001007_hash,
94438 + [45155] = &_001008_hash,
94439 + [17186] = &_001009_hash,
94440 + [46734] = &_001010_hash,
94441 + [61957] = &_001011_hash,
94442 + [51389] = &_001012_hash,
94443 + [23687] = &_001013_hash,
94444 + [46825] = &_001014_hash,
94445 + [52287] = &_001016_hash,
94446 + [31408] = &_001017_hash,
94447 + [5396] = &_001018_hash,
94448 + [62247] = &_001019_hash,
94449 + [7946] = &_001020_hash,
94450 + [58210] = &_001022_hash,
94451 + [15618] = &_001023_hash,
94452 + [61225] = &_001024_hash,
94453 + [13163] = &_001025_hash,
94454 + [36882] = &_001026_hash,
94455 + [8719] = &_001027_hash,
94456 + [8539] = &_001028_hash,
94457 + [27134] = &_001029_hash,
94458 + [53335] = &_001030_hash,
94459 + [30381] = &_001031_hash,
94460 + [32336] = &_001032_hash,
94461 + [32867] = &_001033_hash,
94462 + [1238] = &_001034_hash,
94463 + [8174] = &_001035_hash,
94464 + [6368] = &_001036_hash,
94465 + [29170] = &_001037_hash,
94466 + [9687] = &_001038_hash,
94467 + [61116] = &_001039_hash,
94468 + [31681] = &_001040_hash,
94469 + [22119] = &_001041_hash,
94470 + [59885] = &_001042_hash,
94471 + [47789] = &_001043_hash,
94472 + [5796] = &_001044_hash,
94473 + [43376] = &_001045_hash,
94474 + [36706] = &_001046_hash,
94475 + [47945] = &_001047_hash,
94476 + [33208] = &_001048_hash,
94477 + [55431] = &_001049_hash,
94478 + [25291] = &_001050_hash,
94479 + [58805] = &_001051_hash,
94480 + [23708] = &_001052_hash,
94481 + [29278] = &_001053_hash,
94482 + [1272] = &_001054_hash,
94483 + [10199] = &_001055_hash,
94484 + [34666] = &_001056_hash,
94485 + [49317] = &_001057_hash,
94486 + [18604] = &_001058_hash,
94487 + [42545] = &_001059_hash,
94488 + [33157] = &_001060_hash,
94489 + [53343] = &_001061_hash,
94490 + [64842] = &_001062_hash,
94491 + [61865] = &_001063_hash,
94492 + [54010] = &_001064_hash,
94493 + [64638] = &_001065_hash,
94494 + [20480] = &_001066_hash,
94495 + [23341] = &_001067_hash,
94496 + [10350] = &_001068_hash,
94497 + [30970] = &_001069_hash,
94498 + [62360] = &_001070_hash,
94499 + [52537] = &_001071_hash,
94500 + [51386] = &_001072_hash,
94501 + [48731] = &_001073_hash,
94502 + [58061] = &_001074_hash,
94503 + [40405] = &_001075_hash,
94504 + [57198] = &_001076_hash,
94505 + [19290] = &_001077_hash,
94506 + [60403] = &_001078_hash,
94507 + [2738] = &_001079_hash,
94508 + [59721] = &_001080_hash,
94509 + [24980] = &_001081_hash,
94510 + [55896] = &_001082_hash,
94511 + [57055] = &_001083_hash,
94512 + [46010] = &_001084_hash,
94513 + [712] = &_001085_hash,
94514 + [37747] = &_001086_hash,
94515 + [59996] = &_001087_hash,
94516 + [45219] = &_001088_hash,
94517 + [16917] = &_001089_hash,
94518 + [7415] = &_001090_hash,
94519 + [29576] = &_001091_hash,
94520 + [13584] = &_001092_hash,
94521 + [53364] = &_001093_hash,
94522 + [14813] = &_001094_hash,
94523 + [25543] = &_001095_hash,
94524 + [29240] = &_001096_hash,
94525 + [38748] = &_001097_hash,
94526 + [42270] = &_001098_hash,
94527 + [34848] = &_001099_hash,
94528 + [46226] = &_001100_hash,
94529 + [55526] = &_001101_hash,
94530 + [48271] = &_001102_hash,
94531 + [24658] = &_001104_hash,
94532 + [46964] = &_001105_hash,
94533 + [2637] = &_001106_hash,
94534 + [55601] = &_001107_hash,
94535 + [60275] = &_001108_hash,
94536 + [52645] = &_001109_hash,
94537 + [11712] = &_001110_hash,
94538 + [51364] = &_001111_hash,
94539 + [5106] = &_001112_hash,
94540 + [24710] = &_001113_hash,
94541 + [13101] = &_001114_hash,
94542 + [46963] = &_001115_hash,
94543 + [6779] = &_001116_hash,
94544 + [9237] = &_001117_hash,
94545 + [61524] = &_001118_hash,
94546 + [38247] = &_001119_hash,
94547 + [48715] = &_001120_hash,
94548 + [40797] = &_001121_hash,
94549 + [46780] = &_001122_hash,
94550 + [22071] = &_001123_hash,
94551 + [49735] = &_001125_hash,
94552 + [63925] = &_001126_hash,
94553 + [30902] = &_001127_hash,
94554 + [39828] = &_001128_hash,
94555 + [53089] = &_001129_hash,
94556 + [6394] = &_001130_hash,
94557 + [5116] = &_001131_hash,
94558 + [50702] = &_001132_hash,
94559 + [59565] = &_001133_hash,
94560 + [61042] = &_001134_hash,
94561 + [14533] = &_001135_hash,
94562 + [23807] = &_001136_hash,
94563 + [24296] = &_001137_hash,
94564 + [8808] = &_001138_hash,
94565 + [52383] = &_001139_hash,
94566 + [30487] = &_001140_hash,
94567 + [30125] = &_001141_hash,
94568 + [40665] = &_001142_hash,
94569 + [60809] = &_001143_hash,
94570 + [4842] = &_001144_hash,
94571 + [13955] = &_001145_hash,
94572 + [33237] = &_001146_hash,
94573 + [40673] = &_001147_hash,
94574 + [48026] = &_001148_hash,
94575 + [64033] = &_001149_hash,
94576 + [13879] = &_001150_hash,
94577 + [60114] = &_001151_hash,
94578 + [19472] = &_001152_hash,
94579 + [33552] = &_001153_hash,
94580 + [28575] = &_001154_hash,
94581 + [19696] = &_001155_hash,
94582 + [19742] = &_001156_hash,
94583 + [15286] = &_001157_hash,
94584 + [24629] = &_001158_hash,
94585 + [28382] = &_001159_hash,
94586 + [18962] = &_001160_hash,
94587 + [45796] = &_001161_hash,
94588 + [51632] = &_001162_hash,
94589 + [16907] = &_001163_hash,
94590 + [49336] = &_001164_hash,
94591 + [25316] = &_001165_hash,
94592 + [39978] = &_001166_hash,
94593 + [8091] = &_001167_hash,
94594 + [30680] = &_001168_hash,
94595 + [2066] = &_001169_hash,
94596 + [24271] = &_001170_hash,
94597 + [34934] = &_001171_hash,
94598 + [29208] = &_001172_hash,
94599 + [18591] = &_001173_hash,
94600 + [24373] = &_001174_hash,
94601 + [41485] = &_001175_hash,
94602 + [45487] = &_001176_hash,
94603 + [29299] = &_001177_hash,
94604 + [53920] = &_001178_hash,
94605 + [25407] = &_001179_hash,
94606 + [5525] = &_001180_hash,
94607 + [3531] = &_001181_hash,
94608 + [25143] = &_001182_hash,
94609 + [56046] = &_001183_hash,
94610 + [34693] = &_001184_hash,
94611 + [48644] = &_001185_hash,
94612 + [21226] = &_001186_hash,
94613 + [14051] = &_001187_hash,
94614 + [7715] = &_001188_hash,
94615 + [30413] = &_001189_hash,
94616 + [13681] = &_001190_hash,
94617 + [6554] = &_001191_hash,
94618 + [12228] = &_001192_hash,
94619 + [25497] = &_001193_hash,
94620 + [52228] = &_001194_hash,
94621 + [49069] = &_001195_hash,
94622 + [26961] = &_001196_hash,
94623 + [13768] = &_001197_hash,
94624 + [56185] = &_001198_hash,
94625 + [41838] = &_001199_hash,
94626 + [60119] = &_001200_hash,
94627 + [3112] = &_001201_hash,
94628 + [62001] = &_001202_hash,
94629 + [35888] = &_001203_hash,
94630 + [54718] = &_001206_hash,
94631 + [64177] = &_001207_hash,
94632 + [57222] = &_001208_hash,
94633 + [5260] = &_001209_hash,
94634 + [55517] = &_001210_hash,
94635 + [18186] = &_001211_hash,
94636 + [14257] = &_001212_hash,
94637 + [26846] = &_001213_hash,
94638 + [56097] = &_001214_hash,
94639 + [55151] = &_001215_hash,
94640 + [2999] = &_001216_hash,
94641 + [3602] = &_001217_hash,
94642 + [18460] = &_001218_hash,
94643 + [3507] = &_001219_hash,
94644 + [57847] = &_001220_hash,
94645 + [58077] = &_001221_hash,
94646 + [2659] = &_001222_hash,
94647 + [39846] = &_001223_hash,
94648 + [18629] = &_001224_hash,
94649 + [2723] = &_001225_hash,
94650 + [45230] = &_001226_hash,
94651 + [26941] = &_001227_hash,
94652 + [4344] = &_001228_hash,
94653 + [8487] = &_001229_hash,
94654 + [9901] = &_001230_hash,
94655 + [43061] = &_001231_hash,
94656 + [42551] = &_001232_hash,
94657 + [63272] = &_001233_hash,
94658 + [37771] = &_001234_hash,
94659 + [28261] = &_001235_hash,
94660 + [44694] = &_001236_hash,
94661 + [8573] = &_001237_hash,
94662 + [60174] = &_001238_hash,
94663 + [28040] = &_001239_hash,
94664 + [39423] = &_001240_hash,
94665 + [98] = &_001241_hash,
94666 + [62874] = &_001242_hash,
94667 + [38726] = &_001243_hash,
94668 + [55348] = &_001244_hash,
94669 + [10997] = &_001245_hash,
94670 + [88] = &_001246_hash,
94671 + [60639] = &_001247_hash,
94672 + [48159] = &_001248_hash,
94673 + [47899] = &_001249_hash,
94674 + [25367] = &_001250_hash,
94675 + [55681] = &_001251_hash,
94676 + [44716] = &_001252_hash,
94677 + [26161] = &_001253_hash,
94678 + [55347] = &_001254_hash,
94679 + [14518] = &_001255_hash,
94680 + [8887] = &_001256_hash,
94681 + [23009] = &_001257_hash,
94682 + [27962] = &_001258_hash,
94683 + [20004] = &_001259_hash,
94684 + [61750] = &_001260_hash,
94685 + [11661] = &_001261_hash,
94686 + [37118] = &_001262_hash,
94687 + [9370] = &_001263_hash,
94688 + [15099] = &_001264_hash,
94689 + [2404] = &_001265_hash,
94690 + [64074] = &_001266_hash,
94691 + [7538] = &_001267_hash,
94692 + [19736] = &_001268_hash,
94693 + [8199] = &_001269_hash,
94694 + [40711] = &_001270_hash,
94695 + [47859] = &_001271_hash,
94696 + [53925] = &_001272_hash,
94697 + [46888] = &_001273_hash,
94698 + [21783] = &_001274_hash,
94699 + [37305] = &_001275_hash,
94700 + [18414] = &_001276_hash,
94701 + [62423] = &_001277_hash,
94702 + [30371] = &_001278_hash,
94703 + [32617] = &_001279_hash,
94704 + [14530] = &_001281_hash,
94705 + [48623] = &_001282_hash,
94706 + [12845] = &_001283_hash,
94707 + [8895] = &_001284_hash,
94708 + [33661] = &_001285_hash,
94709 + [23178] = &_001286_hash,
94710 + [54706] = &_001287_hash,
94711 + [27133] = &_001288_hash,
94712 + [52745] = &_001289_hash,
94713 + [64420] = &_001290_hash,
94714 + [25617] = &_001291_hash,
94715 + [25414] = &_001292_hash,
94716 + [20445] = &_001293_hash,
94717 + [64006] = &_001294_hash,
94718 + [52646] = &_001295_hash,
94719 + [30281] = &_001296_hash,
94720 + [3761] = &_001297_hash,
94721 + [44345] = &_001298_hash,
94722 + [14713] = &_001299_hash,
94723 + [26043] = &_001300_hash,
94724 + [41679] = &_001301_hash,
94725 + [6267] = &_001302_hash,
94726 + [22247] = &_001304_hash,
94727 + [9440] = &_001305_hash,
94728 + [54676] = &_001306_hash,
94729 + [53982] = &_001308_hash,
94730 + [9467] = &_001309_hash,
94731 + [53419] = &_001310_hash,
94732 + [1424] = &_001311_hash,
94733 + [17561] = &_001312_hash,
94734 + [28161] = &_001313_hash,
94735 + [57262] = &_001314_hash,
94736 + [61071] = &_001315_hash,
94737 + [20067] = &_001316_hash,
94738 + [34321] = &_001317_hash,
94739 + [56199] = &_001318_hash,
94740 + [29070] = &_001319_hash,
94741 + [15698] = &_001320_hash,
94742 + [14173] = &_001321_hash,
94743 + [41224] = &_001322_hash,
94744 + [56438] = &_001323_hash,
94745 + [41894] = &_001324_hash,
94746 + [20885] = &_001325_hash,
94747 + [23275] = &_001326_hash,
94748 + [45043] = &_001327_hash,
94749 + [22143] = &_001328_hash,
94750 + [38029] = &_001329_hash,
94751 + [55343] = &_001330_hash,
94752 + [40624] = &_001331_hash,
94753 + [26476] = &_001332_hash,
94754 + [43128] = &_001333_hash,
94755 + [45115] = &_001334_hash,
94756 + [32958] = &_001335_hash,
94757 + [43091] = &_001336_hash,
94758 + [33299] = &_001337_hash,
94759 + [55021] = &_001338_hash,
94760 + [5509] = &_001339_hash,
94761 + [53012] = &_001340_hash,
94762 + [57849] = &_001341_hash,
94763 + [63282] = &_001342_hash,
94764 + [27883] = &_001343_hash,
94765 + [1670] = &_001344_hash,
94766 + [24095] = &_001345_hash,
94767 + [47810] = &_001346_hash,
94768 + [40759] = &_001347_hash,
94769 + [42139] = &_001348_hash,
94770 + [50484] = &_001349_hash,
94771 + [2305] = &_001350_hash,
94772 + [59832] = &_001351_hash,
94773 + [17662] = &_001352_hash,
94774 + [58943] = &_001353_hash,
94775 + [37417] = &_001356_hash,
94776 + [25127] = &_001357_hash,
94777 + [15006] = &_001358_hash,
94778 + [54292] = &_001359_hash,
94779 + [30642] = &_001360_hash,
94780 + [39939] = &_001361_hash,
94781 + [34818] = &_001362_hash,
94782 + [23378] = &_001363_hash,
94783 + [24090] = &_001364_hash,
94784 + [11111] = &_001365_hash,
94785 + [64141] = &_001366_hash,
94786 + [46457] = &_001367_hash,
94787 + [57927] = &_001368_hash,
94788 + [58877] = &_001371_hash,
94789 + [13880] = &_001372_hash,
94790 + [62888] = &_001373_hash,
94791 + [57962] = &_001374_hash,
94792 + [9117] = &_001375_hash,
94793 + [52012] = &_001376_hash,
94794 + [49246] = &_001377_hash,
94795 + [52701] = &_001378_hash,
94796 + [29857] = &_001379_hash,
94797 + [49420] = &_001380_hash,
94798 + [45897] = &_001381_hash,
94799 + [15141] = &_001382_hash,
94800 + [24177] = &_001383_hash,
94801 + [10325] = &_001384_hash,
94802 + [52861] = &_001385_hash,
94803 + [28922] = &_001386_hash,
94804 + [31089] = &_001387_hash,
94805 + [63084] = &_001388_hash,
94806 + [26245] = &_001389_hash,
94807 + [60000] = &_001390_hash,
94808 + [56935] = &_001391_hash,
94809 + [37569] = &_001392_hash,
94810 + [6446] = &_001394_hash,
94811 + [35883] = &_001395_hash,
94812 + [9123] = &_001396_hash,
94813 + [51457] = &_001397_hash,
94814 + [1787] = &_001398_hash,
94815 + [10135] = &_001399_hash,
94816 + [952] = &_001400_hash,
94817 + [53578] = &_001401_hash,
94818 + [9923] = &_001402_hash,
94819 + [45249] = &_001403_hash,
94820 + [52860] = &_001404_hash,
94821 + [29558] = &_001405_hash,
94822 + [40556] = &_001406_hash,
94823 + [53210] = &_001407_hash,
94824 + [2506] = &_001408_hash,
94825 + [48262] = &_001409_hash,
94826 + [46939] = &_001410_hash,
94827 + [17901] = &_001411_hash,
94828 + [27204] = &_001412_hash,
94829 + [52516] = &_001413_hash,
94830 + [55885] = &_001414_hash,
94831 + [6681] = &_001415_hash,
94832 + [42360] = &_001416_hash,
94833 + [20259] = &_001417_hash,
94834 + [8874] = &_001418_hash,
94835 + [53363] = &_001419_hash,
94836 + [17500] = &_001420_hash,
94837 + [63988] = &_001421_hash,
94838 + [26378] = &_001422_hash,
94839 + [7768] = &_001423_hash,
94840 + [12938] = &_001424_hash,
94841 + [6755] = &_001425_hash,
94842 + [43806] = &_001426_hash,
94843 + [15976] = &_001427_hash,
94844 + [2732] = &_001428_hash,
94845 + [2519] = &_001429_hash,
94846 + [14340] = &_001430_hash,
94847 + [34772] = &_001431_hash,
94848 + [36433] = &_001432_hash,
94849 + [16068] = &_001433_hash,
94850 + [22052] = &_001434_hash,
94851 + [8929] = &_001435_hash,
94852 + [63220] = &_001436_hash,
94853 + [18246] = &_001437_hash,
94854 + [37678] = &_001438_hash,
94855 + [4932] = &_001439_hash,
94856 + [46960] = &_001440_hash,
94857 + [16909] = &_001441_hash,
94858 + [44429] = &_001442_hash,
94859 + [59514] = &_001443_hash,
94860 + [62760] = &_001444_hash,
94861 + [41841] = &_001445_hash,
94862 + [25417] = &_001446_hash,
94863 + [63230] = &_001447_hash,
94864 + [39532] = &_001448_hash,
94865 + [24688] = &_001449_hash,
94866 + [18555] = &_001450_hash,
94867 + [54499] = &_001451_hash,
94868 + [10719] = &_001452_hash,
94869 + [1644] = &_001453_hash,
94870 + [15109] = &_001454_hash,
94871 + [15787] = &_001455_hash,
94872 + [57869] = &_001456_hash,
94873 + [54445] = &_001457_hash,
94874 + [19398] = &_001458_hash,
94875 + [9488] = &_001459_hash,
94876 + [12587] = &_001460_hash,
94877 + [17124] = &_001461_hash,
94878 + [53665] = &_001462_hash,
94879 + [40386] = &_001463_hash,
94880 + [39444] = &_001464_hash,
94881 + [28873] = &_001465_hash,
94882 + [11290] = &_001466_hash,
94883 + [51313] = &_001467_hash,
94884 + [23354] = &_001469_hash,
94885 + [49559] = &_001470_hash,
94886 + [49312] = &_001471_hash,
94887 + [36333] = &_001472_hash,
94888 + [59349] = &_001473_hash,
94889 + [60316] = &_001474_hash,
94890 + [2546] = &_001475_hash,
94891 + [57483] = &_001476_hash,
94892 + [14569] = &_001478_hash,
94893 + [61842] = &_001481_hash,
94894 + [32923] = &_001482_hash,
94895 + [57471] = &_001483_hash,
94896 + [83] = &_001484_hash,
94897 + [40242] = &_001485_hash,
94898 + [42578] = &_001486_hash,
94899 + [62037] = &_001487_hash,
94900 + [8131] = &_001488_hash,
94901 + [752] = &_001489_hash,
94902 + [56376] = &_001490_hash,
94903 + [22290] = &_001491_hash,
94904 + [46232] = &_001492_hash,
94905 + [35132] = &_001493_hash,
94906 + [23825] = &_001494_hash,
94907 + [43262] = &_001495_hash,
94908 + [8138] = &_001496_hash,
94909 + [31489] = &_001497_hash,
94910 + [57578] = &_001498_hash,
94911 + [28007] = &_001499_hash,
94912 + [28688] = &_001500_hash,
94913 + [19319] = &_001501_hash,
94914 + [12575] = &_001502_hash,
94915 + [62762] = &_001504_hash,
94916 + [47450] = &_001505_hash,
94917 + [1869] = &_001506_hash,
94918 + [51225] = &_001507_hash,
94919 + [19561] = &_001508_hash,
94920 + [64894] = &_001509_hash,
94921 + [6829] = &_001510_hash,
94922 + [30644] = &_001511_hash,
94923 + [63391] = &_001512_hash,
94924 + [11655] = &_001514_hash,
94925 + [28229] = &_001515_hash,
94926 + [22382] = &_001516_hash,
94927 + [22649] = &_001517_hash,
94928 + [42619] = &_001518_hash,
94929 + [19761] = &_001519_hash,
94930 + [56990] = &_001520_hash,
94931 + [19531] = &_001521_hash,
94932 + [26514] = &_001522_hash,
94933 + [56773] = &_001523_hash,
94934 + [15563] = &_001524_hash,
94935 + [26212] = &_001525_hash,
94936 + [29203] = &_001526_hash,
94937 + [32768] = &_001527_hash,
94938 + [15110] = &_001528_hash,
94939 + [3885] = &_001529_hash,
94940 + [13788] = &_001530_hash,
94941 + [27875] = &_001531_hash,
94942 + [54959] = &_001532_hash,
94943 + [20945] = &_001533_hash,
94944 + [59640] = &_001534_hash,
94945 + [4693] = &_001535_hash,
94946 + [13793] = &_001536_hash,
94947 + [25659] = &_001537_hash,
94948 + [18734] = &_001538_hash,
94949 + [17869] = &_001539_hash,
94950 + [26270] = &_001540_hash,
94951 + [18458] = &_001541_hash,
94952 + [58468] = &_001542_hash,
94953 + [61257] = &_001543_hash,
94954 + [39946] = &_001544_hash,
94955 + [52382] = &_001545_hash,
94956 + [18428] = &_001546_hash,
94957 + [31069] = &_001547_hash,
94958 + [61614] = &_001548_hash,
94959 + [60044] = &_001549_hash,
94960 + [36818] = &_001550_hash,
94961 + [54353] = &_001551_hash,
94962 + [55994] = &_001552_hash,
94963 + [65142] = &_001553_hash,
94964 + [1664] = &_001554_hash,
94965 + [32212] = &_001555_hash,
94966 + [63087] = &_001556_hash,
94967 + [29916] = &_001557_hash,
94968 + [54912] = &_001558_hash,
94969 + [10318] = &_001559_hash,
94970 + [44031] = &_001560_hash,
94971 + [50108] = &_001561_hash,
94972 + [57812] = &_001562_hash,
94973 + [63190] = &_001563_hash,
94974 + [48246] = &_001564_hash,
94975 + [3744] = &_001565_hash,
94976 + [56321] = &_001566_hash,
94977 + [42691] = &_001567_hash,
94978 + [62052] = &_001568_hash,
94979 + [21999] = &_001569_hash,
94980 + [13672] = &_001570_hash,
94981 + [20648] = &_001571_hash,
94982 + [42500] = &_001572_hash,
94983 + [22795] = &_001573_hash,
94984 + [19496] = &_001574_hash,
94985 + [35556] = &_001575_hash,
94986 + [57144] = &_001576_hash,
94987 + [1019] = &_001577_hash,
94988 + [28818] = &_001578_hash,
94989 + [52880] = &_001579_hash,
94990 + [6543] = &_001580_hash,
94991 + [18895] = &_001581_hash,
94992 + [857] = &_001582_hash,
94993 + [45966] = &_001583_hash,
94994 + [11785] = &_001584_hash,
94995 + [7736] = &_001585_hash,
94996 + [4308] = &_001586_hash,
94997 + [51095] = &_001587_hash,
94998 + [12101] = &_001588_hash,
94999 + [427] = &_001589_hash,
95000 + [4021] = &_001590_hash,
95001 + [54201] = &_001591_hash,
95002 + [5615] = &_001592_hash,
95003 + [16234] = &_001593_hash,
95004 + [51718] = &_001594_hash,
95005 + [42390] = &_001595_hash,
95006 + [55391] = &_001596_hash,
95007 + [28539] = &_001597_hash,
95008 + [943] = &_001598_hash,
95009 + [32683] = &_001599_hash,
95010 + [39182] = &_001600_hash,
95011 + [33198] = &_001601_hash,
95012 + [39446] = &_001602_hash,
95013 + [16394] = &_001603_hash,
95014 + [30791] = &_001604_hash,
95015 + [35530] = &_001605_hash,
95016 + [53193] = &_001607_hash,
95017 + [39401] = &_001608_hash,
95018 + [28624] = &_001609_hash,
95019 + [12066] = &_001610_hash,
95020 + [63492] = &_001611_hash,
95021 + [14897] = &_001612_hash,
95022 + [29641] = &_001613_hash,
95023 + [10165] = &_001614_hash,
95024 + [60046] = &_001615_hash,
95025 + [12429] = &_001616_hash,
95026 + [32788] = &_001617_hash,
95027 + [52698] = &_001618_hash,
95028 + [13130] = &_001620_hash,
95029 + [28643] = &_001621_hash,
95030 + [50666] = &_001622_hash,
95031 + [35126] = &_001623_hash,
95032 + [33593] = &_001624_hash,
95033 + [27547] = &_001625_hash,
95034 + [5484] = &_001626_hash,
95035 + [26642] = &_001627_hash,
95036 + [25586] = &_001628_hash,
95037 + [58757] = &_001629_hash,
95038 + [18701] = &_001630_hash,
95039 + [26271] = &_001631_hash,
95040 + [23829] = &_001632_hash,
95041 + [63659] = &_001634_hash,
95042 + [26603] = &_001635_hash,
95043 + [25704] = &_001636_hash,
95044 + [21149] = &_001637_hash,
95045 + [36900] = &_001638_hash,
95046 + [61577] = &_001640_hash,
95047 + [54095] = &_001641_hash,
95048 + [31650] = &_001642_hash,
95049 + [48970] = &_001643_hash,
95050 + [49357] = &_001644_hash,
95051 + [33835] = &_001645_hash,
95052 + [46861] = &_001646_hash,
95053 + [1428] = &_001647_hash,
95054 + [36247] = &_001648_hash,
95055 + [21600] = &_001649_hash,
95056 + [24747] = &_001650_hash,
95057 + [51012] = &_001651_hash,
95058 + [38974] = &_001653_hash,
95059 + [30549] = &_001655_hash,
95060 + [40146] = &_001656_hash,
95061 + [41756] = &_001657_hash,
95062 + [37010] = &_001658_hash,
95063 + [35072] = &_001660_hash,
95064 + [2114] = &_001661_hash,
95065 + [48424] = &_001662_hash,
95066 + [61522] = &_001663_hash,
95067 + [50633] = &_001664_hash,
95068 + [2283] = &_001665_hash,
95069 + [61763] = &_001666_hash,
95070 + [48195] = &_001667_hash,
95071 + [31000] = &_001668_hash,
95072 + [23856] = &_001669_hash,
95073 + [37421] = &_001670_hash,
95074 + [10019] = &_001672_hash,
95075 + [5148] = &_001673_hash,
95076 + [14363] = &_001674_hash,
95077 + [57354] = &_001675_hash,
95078 + [62460] = &_001676_hash,
95079 + [45174] = &_001677_hash,
95080 + [31054] = &_001678_hash,
95081 + [62195] = &_001679_hash,
95082 + [14976] = &_001680_hash,
95083 + [55676] = &_001681_hash,
95084 + [1025] = &_001682_hash,
95085 + [6921] = &_001683_hash,
95086 + [22158] = &_001684_hash,
95087 + [18050] = &_001685_hash,
95088 + [18612] = &_001686_hash,
95089 + [31107] = &_001687_hash,
95090 + [45212] = &_001688_hash,
95091 + [29599] = &_001689_hash,
95092 + [30827] = &_001690_hash,
95093 + [25086] = &_001691_hash,
95094 + [27146] = &_001692_hash,
95095 + [2467] = &_001693_hash,
95096 + [45786] = &_001694_hash,
95097 + [51909] = &_001695_hash,
95098 + [64604] = &_001696_hash,
95099 + [57819] = &_001697_hash,
95100 + [11001] = &_001698_hash,
95101 + [20326] = &_001699_hash,
95102 + [12682] = &_001700_hash,
95103 + [28932] = &_001701_hash,
95104 + [53491] = &_001702_hash,
95105 + [63894] = &_001703_hash,
95106 + [51191] = &_001704_hash,
95107 + [59759] = &_001705_hash,
95108 + [15691] = &_001706_hash,
95109 + [38786] = &_001707_hash,
95110 + [51546] = &_001708_hash,
95111 + [10121] = &_001709_hash,
95112 + [60786] = &_001710_hash,
95113 + [19952] = &_001712_hash,
95114 + [7271] = &_001715_hash,
95115 + [10729] = &_001716_hash,
95116 + [28883] = &_001717_hash,
95117 + [52042] = &_001718_hash,
95118 + [49606] = &_001719_hash,
95119 + [33243] = &_001720_hash,
95120 + [57341] = &_001721_hash,
95121 + [7978] = &_001722_hash,
95122 + [36330] = &_001723_hash,
95123 + [39035] = &_001724_hash,
95124 + [34498] = &_001725_hash,
95125 + [19789] = &_001726_hash,
95126 + [55685] = &_001727_hash,
95127 + [55419] = &_001728_hash,
95128 + [27798] = &_001729_hash,
95129 + [54599] = &_001730_hash,
95130 + [65522] = &_001731_hash,
95131 + [38111] = &_001732_hash,
95132 + [57077] = &_001733_hash,
95133 + [53053] = &_001734_hash,
95134 + [14190] = &_001735_hash,
95135 + [47037] = &_001736_hash,
95136 + [33296] = &_001737_hash,
95137 + [23803] = &_001738_hash,
95138 + [48773] = &_001739_hash,
95139 + [63014] = &_001740_hash,
95140 + [64392] = &_001741_hash,
95141 + [44203] = &_001742_hash,
95142 + [47717] = &_001743_hash,
95143 + [38399] = &_001744_hash,
95144 + [30385] = &_001745_hash,
95145 + [61693] = &_001746_hash,
95146 + [32049] = &_001747_hash,
95147 + [26133] = &_001748_hash,
95148 + [45038] = &_001749_hash,
95149 + [8582] = &_001751_hash,
95150 + [38182] = &_001753_hash,
95151 + [62457] = &_001754_hash,
95152 + [27937] = &_001755_hash,
95153 + [3795] = &_001756_hash,
95154 + [23228] = &_001757_hash,
95155 + [56511] = &_001758_hash,
95156 + [47807] = &_001759_hash,
95157 + [60528] = &_001760_hash,
95158 + [51858] = &_001761_hash,
95159 + [49183] = &_001762_hash,
95160 + [33807] = &_001763_hash,
95161 + [34791] = &_001764_hash,
95162 + [8150] = &_001765_hash,
95163 + [19691] = &_001767_hash,
95164 + [20519] = &_001770_hash,
95165 + [17144] = &_001771_hash,
95166 + [14000] = &_001772_hash,
95167 + [31148] = &_001773_hash,
95168 + [62594] = &_001774_hash,
95169 + [39210] = &_001775_hash,
95170 + [2077] = &_001776_hash,
95171 + [23497] = &_001777_hash,
95172 + [34512] = &_001778_hash,
95173 + [16268] = &_001780_hash,
95174 + [14562] = &_001781_hash,
95175 + [17606] = &_001783_hash,
95176 + [25654] = &_001784_hash,
95177 + [56078] = &_001785_hash,
95178 + [61088] = &_001786_hash,
95179 + [53442] = &_001787_hash,
95180 + [54456] = &_001788_hash,
95181 + [22038] = &_001789_hash,
95182 + [58394] = &_001790_hash,
95183 + [38953] = &_001791_hash,
95184 + [16109] = &_001792_hash,
95185 + [3812] = &_001793_hash,
95186 + [5084] = &_001794_hash,
95187 + [41893] = &_001795_hash,
95188 + [45486] = &_001796_hash,
95189 + [50226] = &_001797_hash,
95190 + [63694] = &_001798_hash,
95191 + [56763] = &_001799_hash,
95192 + [20905] = &_001800_hash,
95193 + [13080] = &_001801_hash,
95194 + [54700] = &_001802_hash,
95195 + [40947] = &_001803_hash,
95196 + [32645] = &_001804_hash,
95197 + [57462] = &_001805_hash,
95198 + [33853] = &_001806_hash,
95199 + [57940] = &_001807_hash,
95200 + [45583] = &_001808_hash,
95201 + [14237] = &_001809_hash,
95202 + [27495] = &_001810_hash,
95203 + [12489] = &_001811_hash,
95204 +};
95205 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
95206 new file mode 100644
95207 index 0000000..4154daf
95208 --- /dev/null
95209 +++ b/tools/gcc/size_overflow_plugin.c
95210 @@ -0,0 +1,1188 @@
95211 +/*
95212 + * Copyright 2011, 2012 by Emese Revfy <re.emese@gmail.com>
95213 + * Licensed under the GPL v2, or (at your option) v3
95214 + *
95215 + * Homepage:
95216 + * http://www.grsecurity.net/~ephox/overflow_plugin/
95217 + *
95218 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
95219 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
95220 + * The recomputed argument is checked against INT_MAX and an event is logged on overflow and the triggering process is killed.
95221 + *
95222 + * Usage:
95223 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o size_overflow_plugin.so size_overflow_plugin.c
95224 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
95225 + */
95226 +
95227 +#include "gcc-plugin.h"
95228 +#include "config.h"
95229 +#include "system.h"
95230 +#include "coretypes.h"
95231 +#include "tree.h"
95232 +#include "tree-pass.h"
95233 +#include "intl.h"
95234 +#include "plugin-version.h"
95235 +#include "tm.h"
95236 +#include "toplev.h"
95237 +#include "function.h"
95238 +#include "tree-flow.h"
95239 +#include "plugin.h"
95240 +#include "gimple.h"
95241 +#include "c-common.h"
95242 +#include "diagnostic.h"
95243 +#include "cfgloop.h"
95244 +
95245 +struct size_overflow_hash {
95246 + struct size_overflow_hash *next;
95247 + const char *name;
95248 + const char *file;
95249 + unsigned short param1:1;
95250 + unsigned short param2:1;
95251 + unsigned short param3:1;
95252 + unsigned short param4:1;
95253 + unsigned short param5:1;
95254 + unsigned short param6:1;
95255 + unsigned short param7:1;
95256 + unsigned short param8:1;
95257 + unsigned short param9:1;
95258 +};
95259 +
95260 +#include "size_overflow_hash.h"
95261 +
95262 +#define __unused __attribute__((__unused__))
95263 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
95264 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
95265 +#define BEFORE_STMT true
95266 +#define AFTER_STMT false
95267 +#define CREATE_NEW_VAR NULL_TREE
95268 +
95269 +int plugin_is_GPL_compatible;
95270 +void debug_gimple_stmt(gimple gs);
95271 +
95272 +static tree expand(struct pointer_set_t *visited, bool *potentionally_overflowed, tree var);
95273 +static tree signed_size_overflow_type;
95274 +static tree unsigned_size_overflow_type;
95275 +static tree report_size_overflow_decl;
95276 +static tree const_char_ptr_type_node;
95277 +static unsigned int handle_function(void);
95278 +static bool file_match = true;
95279 +
95280 +static struct plugin_info size_overflow_plugin_info = {
95281 + .version = "20120521beta",
95282 + .help = "no-size_overflow\tturn off size overflow checking\n",
95283 +};
95284 +
95285 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
95286 +{
95287 + unsigned int arg_count = type_num_arguments(*node);
95288 +
95289 + for (; args; args = TREE_CHAIN(args)) {
95290 + tree position = TREE_VALUE(args);
95291 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_HIGH(position) || TREE_INT_CST_LOW(position) < 1 || TREE_INT_CST_LOW(position) > arg_count ) {
95292 + error("handle_size_overflow_attribute: overflow parameter outside range.");
95293 + *no_add_attrs = true;
95294 + }
95295 + }
95296 + return NULL_TREE;
95297 +}
95298 +
95299 +static struct attribute_spec no_size_overflow_attr = {
95300 + .name = "size_overflow",
95301 + .min_length = 1,
95302 + .max_length = -1,
95303 + .decl_required = false,
95304 + .type_required = true,
95305 + .function_type_required = true,
95306 + .handler = handle_size_overflow_attribute
95307 +};
95308 +
95309 +static void register_attributes(void __unused *event_data, void __unused *data)
95310 +{
95311 + register_attribute(&no_size_overflow_attr);
95312 +}
95313 +
95314 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
95315 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
95316 +{
95317 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
95318 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
95319 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
95320 +
95321 + const unsigned int m = 0x57559429;
95322 + const unsigned int n = 0x5052acdb;
95323 + const unsigned int *key4 = (const unsigned int *)key;
95324 + unsigned int h = len;
95325 + unsigned int k = len + seed + n;
95326 + unsigned long long p;
95327 +
95328 + while (len >= 8) {
95329 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
95330 + len -= 8;
95331 + }
95332 + if (len >= 4) {
95333 + cwmixb(key4[0]) key4 += 1;
95334 + len -= 4;
95335 + }
95336 + if (len)
95337 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
95338 + cwmixb(h ^ (k + n));
95339 + return k ^ h;
95340 +
95341 +#undef cwfold
95342 +#undef cwmixa
95343 +#undef cwmixb
95344 +}
95345 +
95346 +static inline unsigned int get_hash_num(const char *fndecl, const char *loc_file, unsigned int seed)
95347 +{
95348 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
95349 + unsigned int file = CrapWow(loc_file, strlen(loc_file), seed) & 0xffff;
95350 +
95351 + if (file_match)
95352 + return fn ^ file;
95353 + else
95354 + return fn;
95355 +}
95356 +
95357 +static inline tree get_original_function_decl(tree fndecl)
95358 +{
95359 + if (DECL_ABSTRACT_ORIGIN(fndecl))
95360 + return DECL_ABSTRACT_ORIGIN(fndecl);
95361 + return fndecl;
95362 +}
95363 +
95364 +static inline gimple get_def_stmt(tree node)
95365 +{
95366 + gcc_assert(TREE_CODE(node) == SSA_NAME);
95367 + return SSA_NAME_DEF_STMT(node);
95368 +}
95369 +
95370 +static struct size_overflow_hash *get_function_hash(tree fndecl, const char *loc_file)
95371 +{
95372 + unsigned int hash;
95373 + struct size_overflow_hash *entry;
95374 + const char *func_name = NAME(fndecl);
95375 +
95376 + hash = get_hash_num(NAME(fndecl), loc_file, 0);
95377 +
95378 + entry = size_overflow_hash[hash];
95379 + while (entry) {
95380 + if (!strcmp(entry->name, func_name) && (!file_match || !strcmp(entry->file, loc_file)))
95381 + return entry;
95382 + entry = entry->next;
95383 + }
95384 +
95385 + return NULL;
95386 +}
95387 +
95388 +static void check_arg_type(tree var)
95389 +{
95390 + tree type = TREE_TYPE(var);
95391 + enum tree_code code = TREE_CODE(type);
95392 +
95393 + gcc_assert(code == INTEGER_TYPE || code == ENUMERAL_TYPE ||
95394 + (code == POINTER_TYPE && TREE_CODE(TREE_TYPE(type)) == VOID_TYPE) ||
95395 + (code == POINTER_TYPE && TREE_CODE(TREE_TYPE(type)) == INTEGER_TYPE));
95396 +}
95397 +
95398 +static int find_arg_number(tree arg, tree func)
95399 +{
95400 + tree var;
95401 + bool match = false;
95402 + unsigned int argnum = 1;
95403 +
95404 + if (TREE_CODE(arg) == SSA_NAME)
95405 + arg = SSA_NAME_VAR(arg);
95406 +
95407 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var)) {
95408 + if (strcmp(NAME(arg), NAME(var))) {
95409 + argnum++;
95410 + continue;
95411 + }
95412 + check_arg_type(var);
95413 +
95414 + match = true;
95415 + if (!TYPE_UNSIGNED(TREE_TYPE(var)))
95416 + return 0;
95417 + break;
95418 + }
95419 + if (!match) {
95420 + warning(0, "find_arg_number: cannot find the %s argument in %s", NAME(arg), NAME(func));
95421 + return 0;
95422 + }
95423 + return argnum;
95424 +}
95425 +
95426 +static void print_missing_msg(tree func, const char *filename, unsigned int argnum)
95427 +{
95428 + unsigned int new_hash;
95429 + location_t loc = DECL_SOURCE_LOCATION(func);
95430 + const char *curfunc = NAME(func);
95431 +
95432 + new_hash = get_hash_num(curfunc, filename, 0);
95433 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%d+%u+%s+", curfunc, curfunc, argnum, new_hash, filename);
95434 +}
95435 +
95436 +static void check_missing_attribute(tree arg)
95437 +{
95438 + tree type, func = get_original_function_decl(current_function_decl);
95439 + unsigned int argnum;
95440 + struct size_overflow_hash *hash;
95441 + const char *filename;
95442 +
95443 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
95444 +
95445 + type = TREE_TYPE(arg);
95446 + // skip function pointers
95447 + if (TREE_CODE(type) == POINTER_TYPE && TREE_CODE(TREE_TYPE(type)) == FUNCTION_TYPE)
95448 + return;
95449 +
95450 + if (lookup_attribute("size_overflow", TYPE_ATTRIBUTES(TREE_TYPE(func))))
95451 + return;
95452 +
95453 + argnum = find_arg_number(arg, func);
95454 + if (argnum == 0)
95455 + return;
95456 +
95457 + filename = DECL_SOURCE_FILE(func);
95458 +
95459 + hash = get_function_hash(func, filename);
95460 + if (!hash) {
95461 + print_missing_msg(func, filename, argnum);
95462 + return;
95463 + }
95464 +
95465 +#define check_param(num) \
95466 + if (num == argnum && hash->param##num) \
95467 + return;
95468 + check_param(1);
95469 + check_param(2);
95470 + check_param(3);
95471 + check_param(4);
95472 + check_param(5);
95473 + check_param(6);
95474 + check_param(7);
95475 + check_param(8);
95476 + check_param(9);
95477 +#undef check_param
95478 +
95479 + print_missing_msg(func, filename, argnum);
95480 +}
95481 +
95482 +static tree create_new_var(tree type)
95483 +{
95484 + tree new_var = create_tmp_var(type, "cicus");
95485 +
95486 + add_referenced_var(new_var);
95487 + mark_sym_for_renaming(new_var);
95488 + return new_var;
95489 +}
95490 +
95491 +static bool is_bool(tree node)
95492 +{
95493 + tree type;
95494 +
95495 + if (node == NULL_TREE)
95496 + return false;
95497 +
95498 + type = TREE_TYPE(node);
95499 + if (!INTEGRAL_TYPE_P(type))
95500 + return false;
95501 + if (TREE_CODE(type) == BOOLEAN_TYPE)
95502 + return true;
95503 + if (TYPE_PRECISION(type) == 1)
95504 + return true;
95505 + return false;
95506 +}
95507 +
95508 +static tree cast_a_tree(tree type, tree var)
95509 +{
95510 + gcc_assert(fold_convertible_p(type, var));
95511 +
95512 + return fold_convert(type, var);
95513 +}
95514 +
95515 +static gimple build_cast_stmt(tree type, tree var, tree new_var, location_t loc)
95516 +{
95517 + gimple assign;
95518 +
95519 + if (new_var == CREATE_NEW_VAR)
95520 + new_var = create_new_var(type);
95521 +
95522 + assign = gimple_build_assign(new_var, cast_a_tree(type, var));
95523 + gimple_set_location(assign, loc);
95524 + gimple_set_lhs(assign, make_ssa_name(new_var, assign));
95525 +
95526 + return assign;
95527 +}
95528 +
95529 +static tree create_assign(struct pointer_set_t *visited, bool *potentionally_overflowed, gimple oldstmt, tree rhs1, bool before)
95530 +{
95531 + tree oldstmt_rhs1;
95532 + enum tree_code code;
95533 + gimple stmt;
95534 + gimple_stmt_iterator gsi;
95535 +
95536 + if (!*potentionally_overflowed)
95537 + return NULL_TREE;
95538 +
95539 + if (rhs1 == NULL_TREE) {
95540 + debug_gimple_stmt(oldstmt);
95541 + error("create_assign: rhs1 is NULL_TREE");
95542 + gcc_unreachable();
95543 + }
95544 +
95545 + oldstmt_rhs1 = gimple_assign_rhs1(oldstmt);
95546 + code = TREE_CODE(oldstmt_rhs1);
95547 + if (code == PARM_DECL || (code == SSA_NAME && gimple_code(get_def_stmt(oldstmt_rhs1)) == GIMPLE_NOP))
95548 + check_missing_attribute(oldstmt_rhs1);
95549 +
95550 + stmt = build_cast_stmt(signed_size_overflow_type, rhs1, CREATE_NEW_VAR, gimple_location(oldstmt));
95551 + gsi = gsi_for_stmt(oldstmt);
95552 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
95553 + basic_block next_bb, cur_bb;
95554 + edge e;
95555 +
95556 + gcc_assert(before == false);
95557 + gcc_assert(stmt_can_throw_internal(oldstmt));
95558 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
95559 + gcc_assert(!gsi_end_p(gsi));
95560 +
95561 + cur_bb = gimple_bb(oldstmt);
95562 + next_bb = cur_bb->next_bb;
95563 + e = find_edge(cur_bb, next_bb);
95564 + gcc_assert(e != NULL);
95565 + gcc_assert(e->flags & EDGE_FALLTHRU);
95566 +
95567 + gsi = gsi_after_labels(next_bb);
95568 + gcc_assert(!gsi_end_p(gsi));
95569 + before = true;
95570 + }
95571 + if (before)
95572 + gsi_insert_before(&gsi, stmt, GSI_NEW_STMT);
95573 + else
95574 + gsi_insert_after(&gsi, stmt, GSI_NEW_STMT);
95575 + update_stmt(stmt);
95576 + pointer_set_insert(visited, oldstmt);
95577 + return gimple_get_lhs(stmt);
95578 +}
95579 +
95580 +static tree dup_assign(struct pointer_set_t *visited, bool *potentionally_overflowed, gimple oldstmt, tree rhs1, tree rhs2, tree __unused rhs3)
95581 +{
95582 + tree new_var, lhs = gimple_get_lhs(oldstmt);
95583 + gimple stmt;
95584 + gimple_stmt_iterator gsi;
95585 +
95586 + if (!*potentionally_overflowed)
95587 + return NULL_TREE;
95588 +
95589 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
95590 + rhs1 = gimple_assign_rhs1(oldstmt);
95591 + rhs1 = create_assign(visited, potentionally_overflowed, oldstmt, rhs1, BEFORE_STMT);
95592 + }
95593 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
95594 + rhs2 = gimple_assign_rhs2(oldstmt);
95595 + rhs2 = create_assign(visited, potentionally_overflowed, oldstmt, rhs2, BEFORE_STMT);
95596 + }
95597 +
95598 + stmt = gimple_copy(oldstmt);
95599 + gimple_set_location(stmt, gimple_location(oldstmt));
95600 +
95601 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
95602 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
95603 +
95604 + if (is_bool(lhs))
95605 + new_var = SSA_NAME_VAR(lhs);
95606 + else
95607 + new_var = create_new_var(signed_size_overflow_type);
95608 + new_var = make_ssa_name(new_var, stmt);
95609 + gimple_set_lhs(stmt, new_var);
95610 +
95611 + if (rhs1 != NULL_TREE) {
95612 + if (!gimple_assign_cast_p(oldstmt))
95613 + rhs1 = cast_a_tree(signed_size_overflow_type, rhs1);
95614 + gimple_assign_set_rhs1(stmt, rhs1);
95615 + }
95616 +
95617 + if (rhs2 != NULL_TREE)
95618 + gimple_assign_set_rhs2(stmt, rhs2);
95619 +#if BUILDING_GCC_VERSION >= 4007
95620 + if (rhs3 != NULL_TREE)
95621 + gimple_assign_set_rhs3(stmt, rhs3);
95622 +#endif
95623 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
95624 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
95625 +
95626 + gsi = gsi_for_stmt(oldstmt);
95627 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
95628 + update_stmt(stmt);
95629 + pointer_set_insert(visited, oldstmt);
95630 + return gimple_get_lhs(stmt);
95631 +}
95632 +
95633 +static gimple overflow_create_phi_node(gimple oldstmt, tree var)
95634 +{
95635 + basic_block bb;
95636 + gimple phi;
95637 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
95638 +
95639 + bb = gsi_bb(gsi);
95640 +
95641 + phi = create_phi_node(var, bb);
95642 + gsi = gsi_last(phi_nodes(bb));
95643 + gsi_remove(&gsi, false);
95644 +
95645 + gsi = gsi_for_stmt(oldstmt);
95646 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
95647 + gimple_set_bb(phi, bb);
95648 + return phi;
95649 +}
95650 +
95651 +static tree signed_cast_constant(tree node)
95652 +{
95653 + gcc_assert(is_gimple_constant(node));
95654 +
95655 + return cast_a_tree(signed_size_overflow_type, node);
95656 +}
95657 +
95658 +static basic_block create_a_first_bb(void)
95659 +{
95660 + basic_block first_bb;
95661 +
95662 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
95663 + if (dom_info_available_p(CDI_DOMINATORS))
95664 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
95665 + return first_bb;
95666 +}
95667 +
95668 +static gimple cast_old_phi_arg(gimple oldstmt, tree arg, tree new_var, unsigned int i)
95669 +{
95670 + basic_block bb;
95671 + gimple newstmt, def_stmt;
95672 + gimple_stmt_iterator gsi;
95673 +
95674 + newstmt = build_cast_stmt(signed_size_overflow_type, arg, new_var, gimple_location(oldstmt));
95675 + if (TREE_CODE(arg) == SSA_NAME) {
95676 + def_stmt = get_def_stmt(arg);
95677 + if (gimple_code(def_stmt) != GIMPLE_NOP) {
95678 + gsi = gsi_for_stmt(def_stmt);
95679 + gsi_insert_after(&gsi, newstmt, GSI_NEW_STMT);
95680 + return newstmt;
95681 + }
95682 + }
95683 +
95684 + bb = gimple_phi_arg_edge(oldstmt, i)->src;
95685 + if (bb->index == 0)
95686 + bb = create_a_first_bb();
95687 + gsi = gsi_after_labels(bb);
95688 + gsi_insert_before(&gsi, newstmt, GSI_NEW_STMT);
95689 + return newstmt;
95690 +}
95691 +
95692 +static gimple handle_new_phi_arg(tree arg, tree new_var, tree new_rhs)
95693 +{
95694 + gimple newstmt;
95695 + gimple_stmt_iterator gsi;
95696 + void (*gsi_insert)(gimple_stmt_iterator *, gimple, enum gsi_iterator_update);
95697 + gimple def_newstmt = get_def_stmt(new_rhs);
95698 +
95699 + gsi_insert = gsi_insert_after;
95700 + gsi = gsi_for_stmt(def_newstmt);
95701 +
95702 + switch (gimple_code(get_def_stmt(arg))) {
95703 + case GIMPLE_PHI:
95704 + newstmt = gimple_build_assign(new_var, new_rhs);
95705 + gsi = gsi_after_labels(gimple_bb(def_newstmt));
95706 + gsi_insert = gsi_insert_before;
95707 + break;
95708 + case GIMPLE_ASM:
95709 + case GIMPLE_CALL:
95710 + newstmt = gimple_build_assign(new_var, new_rhs);
95711 + break;
95712 + case GIMPLE_ASSIGN:
95713 + newstmt = gimple_build_assign(new_var, gimple_get_lhs(def_newstmt));
95714 + break;
95715 + default:
95716 + /* unknown gimple_code (handle_build_new_phi_arg) */
95717 + gcc_unreachable();
95718 + }
95719 +
95720 + gimple_set_lhs(newstmt, make_ssa_name(new_var, newstmt));
95721 + gsi_insert(&gsi, newstmt, GSI_NEW_STMT);
95722 + update_stmt(newstmt);
95723 + return newstmt;
95724 +}
95725 +
95726 +static tree build_new_phi_arg(struct pointer_set_t *visited, bool *potentionally_overflowed, tree arg, tree new_var)
95727 +{
95728 + gimple newstmt;
95729 + tree new_rhs;
95730 +
95731 + new_rhs = expand(visited, potentionally_overflowed, arg);
95732 +
95733 + if (new_rhs == NULL_TREE)
95734 + return NULL_TREE;
95735 +
95736 + newstmt = handle_new_phi_arg(arg, new_var, new_rhs);
95737 + return gimple_get_lhs(newstmt);
95738 +}
95739 +
95740 +static tree build_new_phi(struct pointer_set_t *visited, bool *potentionally_overflowed, gimple oldstmt)
95741 +{
95742 + gimple phi;
95743 + tree new_var = create_new_var(signed_size_overflow_type);
95744 + unsigned int i, n = gimple_phi_num_args(oldstmt);
95745 +
95746 + pointer_set_insert(visited, oldstmt);
95747 + phi = overflow_create_phi_node(oldstmt, new_var);
95748 + for (i = 0; i < n; i++) {
95749 + tree arg, lhs;
95750 +
95751 + arg = gimple_phi_arg_def(oldstmt, i);
95752 + if (is_gimple_constant(arg))
95753 + arg = signed_cast_constant(arg);
95754 + lhs = build_new_phi_arg(visited, potentionally_overflowed, arg, new_var);
95755 + if (lhs == NULL_TREE)
95756 + lhs = gimple_get_lhs(cast_old_phi_arg(oldstmt, arg, new_var, i));
95757 + add_phi_arg(phi, lhs, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
95758 + }
95759 +
95760 + update_stmt(phi);
95761 + return gimple_phi_result(phi);
95762 +}
95763 +
95764 +static tree handle_unary_rhs(struct pointer_set_t *visited, bool *potentionally_overflowed, tree var)
95765 +{
95766 + gimple def_stmt = get_def_stmt(var);
95767 + tree new_rhs1, rhs1 = gimple_assign_rhs1(def_stmt);
95768 +
95769 + *potentionally_overflowed = true;
95770 + new_rhs1 = expand(visited, potentionally_overflowed, rhs1);
95771 + if (new_rhs1 == NULL_TREE) {
95772 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
95773 + return create_assign(visited, potentionally_overflowed, def_stmt, var, AFTER_STMT);
95774 + else
95775 + return create_assign(visited, potentionally_overflowed, def_stmt, rhs1, AFTER_STMT);
95776 + }
95777 + return dup_assign(visited, potentionally_overflowed, def_stmt, new_rhs1, NULL_TREE, NULL_TREE);
95778 +}
95779 +
95780 +static tree handle_unary_ops(struct pointer_set_t *visited, bool *potentionally_overflowed, tree var)
95781 +{
95782 + gimple def_stmt = get_def_stmt(var);
95783 + tree rhs1 = gimple_assign_rhs1(def_stmt);
95784 +
95785 + if (is_gimple_constant(rhs1))
95786 + return dup_assign(visited, potentionally_overflowed, def_stmt, signed_cast_constant(rhs1), NULL_TREE, NULL_TREE);
95787 +
95788 + gcc_assert(TREE_CODE(rhs1) != COND_EXPR);
95789 + switch (TREE_CODE(rhs1)) {
95790 + case SSA_NAME:
95791 + return handle_unary_rhs(visited, potentionally_overflowed, var);
95792 +
95793 + case ARRAY_REF:
95794 + case BIT_FIELD_REF:
95795 + case ADDR_EXPR:
95796 + case COMPONENT_REF:
95797 + case INDIRECT_REF:
95798 +#if BUILDING_GCC_VERSION >= 4006
95799 + case MEM_REF:
95800 +#endif
95801 + case PARM_DECL:
95802 + case TARGET_MEM_REF:
95803 + case VAR_DECL:
95804 + return create_assign(visited, potentionally_overflowed, def_stmt, var, AFTER_STMT);
95805 +
95806 + default:
95807 + debug_gimple_stmt(def_stmt);
95808 + debug_tree(rhs1);
95809 + gcc_unreachable();
95810 + }
95811 +}
95812 +
95813 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
95814 +{
95815 + gimple cond_stmt;
95816 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
95817 +
95818 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
95819 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
95820 + update_stmt(cond_stmt);
95821 +}
95822 +
95823 +static tree create_string_param(tree string)
95824 +{
95825 + tree i_type, a_type;
95826 + int length = TREE_STRING_LENGTH(string);
95827 +
95828 + gcc_assert(length > 0);
95829 +
95830 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
95831 + a_type = build_array_type(char_type_node, i_type);
95832 +
95833 + TREE_TYPE(string) = a_type;
95834 + TREE_CONSTANT(string) = 1;
95835 + TREE_READONLY(string) = 1;
95836 +
95837 + return build1(ADDR_EXPR, ptr_type_node, string);
95838 +}
95839 +
95840 +static void insert_cond_result(basic_block bb_true, gimple stmt, tree arg)
95841 +{
95842 + gimple func_stmt, def_stmt;
95843 + tree current_func, loc_file, loc_line;
95844 + expanded_location xloc;
95845 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
95846 +
95847 + def_stmt = get_def_stmt(arg);
95848 + xloc = expand_location(gimple_location(def_stmt));
95849 +
95850 + if (!gimple_has_location(def_stmt)) {
95851 + xloc = expand_location(gimple_location(stmt));
95852 + if (!gimple_has_location(stmt))
95853 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
95854 + }
95855 +
95856 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
95857 +
95858 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
95859 + loc_file = create_string_param(loc_file);
95860 +
95861 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
95862 + current_func = create_string_param(current_func);
95863 +
95864 + // void report_size_overflow(const char *file, unsigned int line, const char *func)
95865 + func_stmt = gimple_build_call(report_size_overflow_decl, 3, loc_file, loc_line, current_func);
95866 +
95867 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
95868 +}
95869 +
95870 +static void __unused print_the_code_insertions(gimple stmt)
95871 +{
95872 + location_t loc = gimple_location(stmt);
95873 +
95874 + inform(loc, "Integer size_overflow check applied here.");
95875 +}
95876 +
95877 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value)
95878 +{
95879 + basic_block cond_bb, join_bb, bb_true;
95880 + edge e;
95881 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
95882 +
95883 + cond_bb = gimple_bb(stmt);
95884 + gsi_prev(&gsi);
95885 + if (gsi_end_p(gsi))
95886 + e = split_block_after_labels(cond_bb);
95887 + else
95888 + e = split_block(cond_bb, gsi_stmt(gsi));
95889 + cond_bb = e->src;
95890 + join_bb = e->dest;
95891 + e->flags = EDGE_FALSE_VALUE;
95892 + e->probability = REG_BR_PROB_BASE;
95893 +
95894 + bb_true = create_empty_bb(cond_bb);
95895 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
95896 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
95897 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
95898 +
95899 + if (dom_info_available_p(CDI_DOMINATORS)) {
95900 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
95901 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
95902 + }
95903 +
95904 + if (current_loops != NULL) {
95905 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
95906 + add_bb_to_loop(bb_true, cond_bb->loop_father);
95907 + }
95908 +
95909 + insert_cond(cond_bb, arg, cond_code, type_value);
95910 + insert_cond_result(bb_true, stmt, arg);
95911 +
95912 +// print_the_code_insertions(stmt);
95913 +}
95914 +
95915 +static tree get_type_for_check(tree rhs)
95916 +{
95917 + tree def_rhs;
95918 + gimple def_stmt = get_def_stmt(rhs);
95919 +
95920 + if (!gimple_assign_cast_p(def_stmt))
95921 + return TREE_TYPE(rhs);
95922 + def_rhs = gimple_assign_rhs1(def_stmt);
95923 + if (TREE_CODE(TREE_TYPE(def_rhs)) == INTEGER_TYPE)
95924 + return TREE_TYPE(def_rhs);
95925 + return TREE_TYPE(rhs);
95926 +}
95927 +
95928 +static gimple cast_to_unsigned_size_overflow_type(gimple stmt, tree cast_rhs)
95929 +{
95930 + gimple ucast_stmt;
95931 + gimple_stmt_iterator gsi;
95932 + location_t loc = gimple_location(stmt);
95933 +
95934 + ucast_stmt = build_cast_stmt(unsigned_size_overflow_type, cast_rhs, CREATE_NEW_VAR, loc);
95935 + gsi = gsi_for_stmt(stmt);
95936 + gsi_insert_before(&gsi, ucast_stmt, GSI_SAME_STMT);
95937 + return ucast_stmt;
95938 +}
95939 +
95940 +static void check_size_overflow(gimple stmt, tree cast_rhs, tree rhs, bool *potentionally_overflowed)
95941 +{
95942 + tree type_max, type_min, rhs_type;
95943 + gimple ucast_stmt;
95944 +
95945 + if (!*potentionally_overflowed)
95946 + return;
95947 +
95948 + rhs_type = get_type_for_check(rhs);
95949 +
95950 + if (TYPE_UNSIGNED(rhs_type)) {
95951 + ucast_stmt = cast_to_unsigned_size_overflow_type(stmt, cast_rhs);
95952 + type_max = cast_a_tree(unsigned_size_overflow_type, TYPE_MAX_VALUE(rhs_type));
95953 + insert_check_size_overflow(stmt, GT_EXPR, gimple_get_lhs(ucast_stmt), type_max);
95954 + } else {
95955 + type_max = cast_a_tree(signed_size_overflow_type, TYPE_MAX_VALUE(rhs_type));
95956 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max);
95957 +
95958 + type_min = cast_a_tree(signed_size_overflow_type, TYPE_MIN_VALUE(rhs_type));
95959 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min);
95960 + }
95961 +}
95962 +
95963 +static tree change_assign_rhs(struct pointer_set_t *visited, bool *potentionally_overflowed, gimple stmt, tree orig_rhs)
95964 +{
95965 + gimple assign;
95966 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
95967 + tree new_rhs, origtype = TREE_TYPE(orig_rhs);
95968 +
95969 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
95970 +
95971 + new_rhs = expand(visited, potentionally_overflowed, orig_rhs);
95972 + if (new_rhs == NULL_TREE)
95973 + return NULL_TREE;
95974 +
95975 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, gimple_location(stmt));
95976 + gsi_insert_before(&gsi, assign, GSI_SAME_STMT);
95977 + update_stmt(assign);
95978 + return gimple_get_lhs(assign);
95979 +}
95980 +
95981 +static tree handle_const_assign(struct pointer_set_t *visited, bool *potentionally_overflowed, gimple def_stmt, tree var, tree rhs, tree new_rhs1, tree new_rhs2, void (*gimple_assign_set_rhs)(gimple, tree))
95982 +{
95983 + tree new_rhs, cast_rhs;
95984 +
95985 + if (gimple_assign_rhs_code(def_stmt) == MIN_EXPR)
95986 + return dup_assign(visited, potentionally_overflowed, def_stmt, new_rhs1, new_rhs2, NULL_TREE);
95987 +
95988 + new_rhs = change_assign_rhs(visited, potentionally_overflowed, def_stmt, rhs);
95989 + if (new_rhs != NULL_TREE) {
95990 + gimple_assign_set_rhs(def_stmt, new_rhs);
95991 + update_stmt(def_stmt);
95992 +
95993 + cast_rhs = gimple_assign_rhs1(get_def_stmt(new_rhs));
95994 +
95995 + check_size_overflow(def_stmt, cast_rhs, rhs, potentionally_overflowed);
95996 + }
95997 + return create_assign(visited, potentionally_overflowed, def_stmt, var, AFTER_STMT);
95998 +}
95999 +
96000 +static tree handle_binary_ops(struct pointer_set_t *visited, bool *potentionally_overflowed, tree var)
96001 +{
96002 + tree rhs1, rhs2;
96003 + gimple def_stmt = get_def_stmt(var);
96004 + tree new_rhs1 = NULL_TREE;
96005 + tree new_rhs2 = NULL_TREE;
96006 +
96007 + rhs1 = gimple_assign_rhs1(def_stmt);
96008 + rhs2 = gimple_assign_rhs2(def_stmt);
96009 +
96010 + /* no DImode/TImode division in the 32/64 bit kernel */
96011 + switch (gimple_assign_rhs_code(def_stmt)) {
96012 + case RDIV_EXPR:
96013 + case TRUNC_DIV_EXPR:
96014 + case CEIL_DIV_EXPR:
96015 + case FLOOR_DIV_EXPR:
96016 + case ROUND_DIV_EXPR:
96017 + case TRUNC_MOD_EXPR:
96018 + case CEIL_MOD_EXPR:
96019 + case FLOOR_MOD_EXPR:
96020 + case ROUND_MOD_EXPR:
96021 + case EXACT_DIV_EXPR:
96022 + case POINTER_PLUS_EXPR:
96023 + case BIT_AND_EXPR:
96024 + return create_assign(visited, potentionally_overflowed, def_stmt, var, AFTER_STMT);
96025 + default:
96026 + break;
96027 + }
96028 +
96029 + *potentionally_overflowed = true;
96030 +
96031 + if (TREE_CODE(rhs1) == SSA_NAME)
96032 + new_rhs1 = expand(visited, potentionally_overflowed, rhs1);
96033 + if (TREE_CODE(rhs2) == SSA_NAME)
96034 + new_rhs2 = expand(visited, potentionally_overflowed, rhs2);
96035 +
96036 + if (is_gimple_constant(rhs2))
96037 + return handle_const_assign(visited, potentionally_overflowed, def_stmt, var, rhs1, new_rhs1, signed_cast_constant(rhs2), &gimple_assign_set_rhs1);
96038 +
96039 + if (is_gimple_constant(rhs1))
96040 + return handle_const_assign(visited, potentionally_overflowed, def_stmt, var, rhs2, signed_cast_constant(rhs1), new_rhs2, &gimple_assign_set_rhs2);
96041 +
96042 + return dup_assign(visited, potentionally_overflowed, def_stmt, new_rhs1, new_rhs2, NULL_TREE);
96043 +}
96044 +
96045 +#if BUILDING_GCC_VERSION >= 4007
96046 +static tree get_new_rhs(struct pointer_set_t *visited, bool *potentionally_overflowed, tree rhs)
96047 +{
96048 + if (is_gimple_constant(rhs))
96049 + return signed_cast_constant(rhs);
96050 + if (TREE_CODE(rhs) != SSA_NAME)
96051 + return NULL_TREE;
96052 + return expand(visited, potentionally_overflowed, rhs);
96053 +}
96054 +
96055 +static tree handle_ternary_ops(struct pointer_set_t *visited, bool *potentionally_overflowed, tree var)
96056 +{
96057 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3;
96058 + gimple def_stmt = get_def_stmt(var);
96059 +
96060 + *potentionally_overflowed = true;
96061 +
96062 + rhs1 = gimple_assign_rhs1(def_stmt);
96063 + rhs2 = gimple_assign_rhs2(def_stmt);
96064 + rhs3 = gimple_assign_rhs3(def_stmt);
96065 + new_rhs1 = get_new_rhs(visited, potentionally_overflowed, rhs1);
96066 + new_rhs2 = get_new_rhs(visited, potentionally_overflowed, rhs2);
96067 + new_rhs3 = get_new_rhs(visited, potentionally_overflowed, rhs3);
96068 +
96069 + if (new_rhs1 == NULL_TREE && new_rhs2 != NULL_TREE && new_rhs3 != NULL_TREE)
96070 + return dup_assign(visited, potentionally_overflowed, def_stmt, new_rhs1, new_rhs2, new_rhs3);
96071 + error("handle_ternary_ops: unknown rhs");
96072 + gcc_unreachable();
96073 +}
96074 +#endif
96075 +
96076 +static void set_size_overflow_type(tree node)
96077 +{
96078 + switch (TYPE_MODE(TREE_TYPE(node))) {
96079 + case SImode:
96080 + signed_size_overflow_type = intDI_type_node;
96081 + unsigned_size_overflow_type = unsigned_intDI_type_node;
96082 + break;
96083 + case DImode:
96084 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode)) {
96085 + signed_size_overflow_type = intDI_type_node;
96086 + unsigned_size_overflow_type = unsigned_intDI_type_node;
96087 + } else {
96088 + signed_size_overflow_type = intTI_type_node;
96089 + unsigned_size_overflow_type = unsigned_intTI_type_node;
96090 + }
96091 + break;
96092 + default:
96093 + error("set_size_overflow_type: unsupported gcc configuration.");
96094 + gcc_unreachable();
96095 + }
96096 +}
96097 +
96098 +static tree expand_visited(gimple def_stmt)
96099 +{
96100 + gimple tmp;
96101 + gimple_stmt_iterator gsi = gsi_for_stmt(def_stmt);
96102 +
96103 + gsi_next(&gsi);
96104 + tmp = gsi_stmt(gsi);
96105 + switch (gimple_code(tmp)) {
96106 + case GIMPLE_ASSIGN:
96107 + return gimple_get_lhs(tmp);
96108 + case GIMPLE_PHI:
96109 + return gimple_phi_result(tmp);
96110 + case GIMPLE_CALL:
96111 + return gimple_call_lhs(tmp);
96112 + default:
96113 + return NULL_TREE;
96114 + }
96115 +}
96116 +
96117 +static tree expand(struct pointer_set_t *visited, bool *potentionally_overflowed, tree var)
96118 +{
96119 + gimple def_stmt;
96120 + enum tree_code code = TREE_CODE(TREE_TYPE(var));
96121 +
96122 + if (is_gimple_constant(var))
96123 + return NULL_TREE;
96124 +
96125 + if (TREE_CODE(var) == ADDR_EXPR)
96126 + return NULL_TREE;
96127 +
96128 + gcc_assert(code == INTEGER_TYPE || code == POINTER_TYPE || code == BOOLEAN_TYPE || code == ENUMERAL_TYPE);
96129 + if (code != INTEGER_TYPE)
96130 + return NULL_TREE;
96131 +
96132 + if (SSA_NAME_IS_DEFAULT_DEF(var)) {
96133 + check_missing_attribute(var);
96134 + return NULL_TREE;
96135 + }
96136 +
96137 + def_stmt = get_def_stmt(var);
96138 +
96139 + if (!def_stmt)
96140 + return NULL_TREE;
96141 +
96142 + if (pointer_set_contains(visited, def_stmt))
96143 + return expand_visited(def_stmt);
96144 +
96145 + switch (gimple_code(def_stmt)) {
96146 + case GIMPLE_NOP:
96147 + check_missing_attribute(var);
96148 + return NULL_TREE;
96149 + case GIMPLE_PHI:
96150 + return build_new_phi(visited, potentionally_overflowed, def_stmt);
96151 + case GIMPLE_CALL:
96152 + case GIMPLE_ASM:
96153 + return create_assign(visited, potentionally_overflowed, def_stmt, var, AFTER_STMT);
96154 + case GIMPLE_ASSIGN:
96155 + switch (gimple_num_ops(def_stmt)) {
96156 + case 2:
96157 + return handle_unary_ops(visited, potentionally_overflowed, var);
96158 + case 3:
96159 + return handle_binary_ops(visited, potentionally_overflowed, var);
96160 +#if BUILDING_GCC_VERSION >= 4007
96161 + case 4:
96162 + return handle_ternary_ops(visited, potentionally_overflowed, var);
96163 +#endif
96164 + }
96165 + default:
96166 + debug_gimple_stmt(def_stmt);
96167 + error("expand: unknown gimple code");
96168 + gcc_unreachable();
96169 + }
96170 +}
96171 +
96172 +static void change_function_arg(gimple stmt, tree origarg, unsigned int argnum, tree newarg)
96173 +{
96174 + gimple assign;
96175 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
96176 + tree origtype = TREE_TYPE(origarg);
96177 +
96178 + gcc_assert(gimple_code(stmt) == GIMPLE_CALL);
96179 +
96180 + assign = build_cast_stmt(origtype, newarg, CREATE_NEW_VAR, gimple_location(stmt));
96181 + gsi_insert_before(&gsi, assign, GSI_SAME_STMT);
96182 + update_stmt(assign);
96183 +
96184 + gimple_call_set_arg(stmt, argnum, gimple_get_lhs(assign));
96185 + update_stmt(stmt);
96186 +}
96187 +
96188 +static tree get_function_arg(unsigned int argnum, gimple stmt, tree fndecl)
96189 +{
96190 + const char *origid;
96191 + tree arg, origarg;
96192 +
96193 + if (!DECL_ABSTRACT_ORIGIN(fndecl)) {
96194 + gcc_assert(gimple_call_num_args(stmt) > argnum);
96195 + return gimple_call_arg(stmt, argnum);
96196 + }
96197 +
96198 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
96199 + while (origarg && argnum) {
96200 + argnum--;
96201 + origarg = TREE_CHAIN(origarg);
96202 + }
96203 +
96204 + gcc_assert(argnum == 0);
96205 +
96206 + gcc_assert(origarg != NULL_TREE);
96207 + origid = NAME(origarg);
96208 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg)) {
96209 + if (!strcmp(origid, NAME(arg)))
96210 + return arg;
96211 + }
96212 + return NULL_TREE;
96213 +}
96214 +
96215 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
96216 +{
96217 + struct pointer_set_t *visited;
96218 + tree arg, newarg, type_max;
96219 + gimple ucast_stmt;
96220 + bool potentionally_overflowed;
96221 +
96222 + arg = get_function_arg(argnum, stmt, fndecl);
96223 + if (arg == NULL_TREE)
96224 + return;
96225 +
96226 + if (is_gimple_constant(arg))
96227 + return;
96228 + if (TREE_CODE(arg) != SSA_NAME)
96229 + return;
96230 +
96231 + check_arg_type(arg);
96232 +
96233 + set_size_overflow_type(arg);
96234 +
96235 + visited = pointer_set_create();
96236 + potentionally_overflowed = false;
96237 + newarg = expand(visited, &potentionally_overflowed, arg);
96238 + pointer_set_destroy(visited);
96239 +
96240 + if (newarg == NULL_TREE || !potentionally_overflowed)
96241 + return;
96242 +
96243 + change_function_arg(stmt, arg, argnum, newarg);
96244 +
96245 + ucast_stmt = cast_to_unsigned_size_overflow_type(stmt, newarg);
96246 +
96247 + type_max = build_int_cstu(unsigned_size_overflow_type, 0x7fffffff);
96248 + insert_check_size_overflow(stmt, GT_EXPR, gimple_get_lhs(ucast_stmt), type_max);
96249 +}
96250 +
96251 +static void handle_function_by_attribute(gimple stmt, tree attr, tree fndecl)
96252 +{
96253 + tree p = TREE_VALUE(attr);
96254 + do {
96255 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p))-1);
96256 + p = TREE_CHAIN(p);
96257 + } while (p);
96258 +}
96259 +
96260 +static void handle_function_by_hash(gimple stmt, tree fndecl)
96261 +{
96262 + tree orig_fndecl;
96263 + struct size_overflow_hash *hash;
96264 + const char *filename = DECL_SOURCE_FILE(fndecl);
96265 +
96266 + orig_fndecl = get_original_function_decl(fndecl);
96267 + hash = get_function_hash(orig_fndecl, filename);
96268 + if (!hash)
96269 + return;
96270 +
96271 +#define search_param(argnum) \
96272 + if (hash->param##argnum) \
96273 + handle_function_arg(stmt, fndecl, argnum - 1);
96274 +
96275 + search_param(1);
96276 + search_param(2);
96277 + search_param(3);
96278 + search_param(4);
96279 + search_param(5);
96280 + search_param(6);
96281 + search_param(7);
96282 + search_param(8);
96283 + search_param(9);
96284 +#undef search_param
96285 +}
96286 +
96287 +static unsigned int handle_function(void)
96288 +{
96289 + basic_block bb = ENTRY_BLOCK_PTR->next_bb;
96290 + int saved_last_basic_block = last_basic_block;
96291 +
96292 + do {
96293 + gimple_stmt_iterator gsi;
96294 + basic_block next = bb->next_bb;
96295 +
96296 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
96297 + tree fndecl, attr;
96298 + gimple stmt = gsi_stmt(gsi);
96299 +
96300 + if (!(is_gimple_call(stmt)))
96301 + continue;
96302 + fndecl = gimple_call_fndecl(stmt);
96303 + if (fndecl == NULL_TREE)
96304 + continue;
96305 + if (gimple_call_num_args(stmt) == 0)
96306 + continue;
96307 + attr = lookup_attribute("size_overflow", TYPE_ATTRIBUTES(TREE_TYPE(fndecl)));
96308 + if (!attr || !TREE_VALUE(attr))
96309 + handle_function_by_hash(stmt, fndecl);
96310 + else
96311 + handle_function_by_attribute(stmt, attr, fndecl);
96312 + gsi = gsi_for_stmt(stmt);
96313 + }
96314 + bb = next;
96315 + } while (bb && bb->index <= saved_last_basic_block);
96316 + return 0;
96317 +}
96318 +
96319 +static struct gimple_opt_pass size_overflow_pass = {
96320 + .pass = {
96321 + .type = GIMPLE_PASS,
96322 + .name = "size_overflow",
96323 + .gate = NULL,
96324 + .execute = handle_function,
96325 + .sub = NULL,
96326 + .next = NULL,
96327 + .static_pass_number = 0,
96328 + .tv_id = TV_NONE,
96329 + .properties_required = PROP_cfg | PROP_referenced_vars,
96330 + .properties_provided = 0,
96331 + .properties_destroyed = 0,
96332 + .todo_flags_start = 0,
96333 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi | TODO_cleanup_cfg | TODO_ggc_collect | TODO_verify_flow
96334 + }
96335 +};
96336 +
96337 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
96338 +{
96339 + tree fntype;
96340 +
96341 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
96342 +
96343 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func)
96344 + fntype = build_function_type_list(void_type_node,
96345 + const_char_ptr_type_node,
96346 + unsigned_type_node,
96347 + const_char_ptr_type_node,
96348 + NULL_TREE);
96349 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
96350 +
96351 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
96352 + TREE_PUBLIC(report_size_overflow_decl) = 1;
96353 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
96354 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
96355 +}
96356 +
96357 +extern struct gimple_opt_pass pass_dce;
96358 +
96359 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
96360 +{
96361 + int i;
96362 + const char * const plugin_name = plugin_info->base_name;
96363 + const int argc = plugin_info->argc;
96364 + const struct plugin_argument * const argv = plugin_info->argv;
96365 + bool enable = true;
96366 +
96367 + struct register_pass_info size_overflow_pass_info = {
96368 + .pass = &size_overflow_pass.pass,
96369 + .reference_pass_name = "ssa",
96370 + .ref_pass_instance_number = 1,
96371 + .pos_op = PASS_POS_INSERT_AFTER
96372 + };
96373 +
96374 + if (!plugin_default_version_check(version, &gcc_version)) {
96375 + error(G_("incompatible gcc/plugin versions"));
96376 + return 1;
96377 + }
96378 +
96379 + for (i = 0; i < argc; ++i) {
96380 + if (!strcmp(argv[i].key, "no-size-overflow")) {
96381 + enable = false;
96382 + continue;
96383 + } else if (!(strcmp(argv[i].key, "no-file-match"))) {
96384 + file_match = false;
96385 + continue;
96386 + }
96387 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
96388 + }
96389 +
96390 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
96391 + if (enable) {
96392 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
96393 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
96394 + }
96395 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
96396 +
96397 + return 0;
96398 +}
96399 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
96400 new file mode 100644
96401 index 0000000..b87ec9d
96402 --- /dev/null
96403 +++ b/tools/gcc/stackleak_plugin.c
96404 @@ -0,0 +1,313 @@
96405 +/*
96406 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
96407 + * Licensed under the GPL v2
96408 + *
96409 + * Note: the choice of the license means that the compilation process is
96410 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
96411 + * but for the kernel it doesn't matter since it doesn't link against
96412 + * any of the gcc libraries
96413 + *
96414 + * gcc plugin to help implement various PaX features
96415 + *
96416 + * - track lowest stack pointer
96417 + *
96418 + * TODO:
96419 + * - initialize all local variables
96420 + *
96421 + * BUGS:
96422 + * - none known
96423 + */
96424 +#include "gcc-plugin.h"
96425 +#include "config.h"
96426 +#include "system.h"
96427 +#include "coretypes.h"
96428 +#include "tree.h"
96429 +#include "tree-pass.h"
96430 +#include "flags.h"
96431 +#include "intl.h"
96432 +#include "toplev.h"
96433 +#include "plugin.h"
96434 +//#include "expr.h" where are you...
96435 +#include "diagnostic.h"
96436 +#include "plugin-version.h"
96437 +#include "tm.h"
96438 +#include "function.h"
96439 +#include "basic-block.h"
96440 +#include "gimple.h"
96441 +#include "rtl.h"
96442 +#include "emit-rtl.h"
96443 +
96444 +extern void print_gimple_stmt(FILE *, gimple, int, int);
96445 +
96446 +int plugin_is_GPL_compatible;
96447 +
96448 +static int track_frame_size = -1;
96449 +static const char track_function[] = "pax_track_stack";
96450 +static const char check_function[] = "pax_check_alloca";
96451 +static bool init_locals;
96452 +
96453 +static struct plugin_info stackleak_plugin_info = {
96454 + .version = "201203140940",
96455 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
96456 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
96457 +};
96458 +
96459 +static bool gate_stackleak_track_stack(void);
96460 +static unsigned int execute_stackleak_tree_instrument(void);
96461 +static unsigned int execute_stackleak_final(void);
96462 +
96463 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
96464 + .pass = {
96465 + .type = GIMPLE_PASS,
96466 + .name = "stackleak_tree_instrument",
96467 + .gate = gate_stackleak_track_stack,
96468 + .execute = execute_stackleak_tree_instrument,
96469 + .sub = NULL,
96470 + .next = NULL,
96471 + .static_pass_number = 0,
96472 + .tv_id = TV_NONE,
96473 + .properties_required = PROP_gimple_leh | PROP_cfg,
96474 + .properties_provided = 0,
96475 + .properties_destroyed = 0,
96476 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
96477 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
96478 + }
96479 +};
96480 +
96481 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
96482 + .pass = {
96483 + .type = RTL_PASS,
96484 + .name = "stackleak_final",
96485 + .gate = gate_stackleak_track_stack,
96486 + .execute = execute_stackleak_final,
96487 + .sub = NULL,
96488 + .next = NULL,
96489 + .static_pass_number = 0,
96490 + .tv_id = TV_NONE,
96491 + .properties_required = 0,
96492 + .properties_provided = 0,
96493 + .properties_destroyed = 0,
96494 + .todo_flags_start = 0,
96495 + .todo_flags_finish = TODO_dump_func
96496 + }
96497 +};
96498 +
96499 +static bool gate_stackleak_track_stack(void)
96500 +{
96501 + return track_frame_size >= 0;
96502 +}
96503 +
96504 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
96505 +{
96506 + gimple check_alloca;
96507 + tree fntype, fndecl, alloca_size;
96508 +
96509 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
96510 + fndecl = build_fn_decl(check_function, fntype);
96511 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
96512 +
96513 + // insert call to void pax_check_alloca(unsigned long size)
96514 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
96515 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
96516 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
96517 +}
96518 +
96519 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
96520 +{
96521 + gimple track_stack;
96522 + tree fntype, fndecl;
96523 +
96524 + fntype = build_function_type_list(void_type_node, NULL_TREE);
96525 + fndecl = build_fn_decl(track_function, fntype);
96526 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
96527 +
96528 + // insert call to void pax_track_stack(void)
96529 + track_stack = gimple_build_call(fndecl, 0);
96530 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
96531 +}
96532 +
96533 +#if BUILDING_GCC_VERSION == 4005
96534 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
96535 +{
96536 + tree fndecl;
96537 +
96538 + if (!is_gimple_call(stmt))
96539 + return false;
96540 + fndecl = gimple_call_fndecl(stmt);
96541 + if (!fndecl)
96542 + return false;
96543 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
96544 + return false;
96545 +// print_node(stderr, "pax", fndecl, 4);
96546 + return DECL_FUNCTION_CODE(fndecl) == code;
96547 +}
96548 +#endif
96549 +
96550 +static bool is_alloca(gimple stmt)
96551 +{
96552 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
96553 + return true;
96554 +
96555 +#if BUILDING_GCC_VERSION >= 4007
96556 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
96557 + return true;
96558 +#endif
96559 +
96560 + return false;
96561 +}
96562 +
96563 +static unsigned int execute_stackleak_tree_instrument(void)
96564 +{
96565 + basic_block bb, entry_bb;
96566 + bool prologue_instrumented = false, is_leaf = true;
96567 +
96568 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
96569 +
96570 + // 1. loop through BBs and GIMPLE statements
96571 + FOR_EACH_BB(bb) {
96572 + gimple_stmt_iterator gsi;
96573 +
96574 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
96575 + gimple stmt;
96576 +
96577 + stmt = gsi_stmt(gsi);
96578 +
96579 + if (is_gimple_call(stmt))
96580 + is_leaf = false;
96581 +
96582 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
96583 + if (!is_alloca(stmt))
96584 + continue;
96585 +
96586 + // 2. insert stack overflow check before each __builtin_alloca call
96587 + stackleak_check_alloca(&gsi);
96588 +
96589 + // 3. insert track call after each __builtin_alloca call
96590 + stackleak_add_instrumentation(&gsi);
96591 + if (bb == entry_bb)
96592 + prologue_instrumented = true;
96593 + }
96594 + }
96595 +
96596 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
96597 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
96598 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
96599 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
96600 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
96601 + return 0;
96602 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
96603 + return 0;
96604 +
96605 + // 4. insert track call at the beginning
96606 + if (!prologue_instrumented) {
96607 + gimple_stmt_iterator gsi;
96608 +
96609 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
96610 + if (dom_info_available_p(CDI_DOMINATORS))
96611 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
96612 + gsi = gsi_start_bb(bb);
96613 + stackleak_add_instrumentation(&gsi);
96614 + }
96615 +
96616 + return 0;
96617 +}
96618 +
96619 +static unsigned int execute_stackleak_final(void)
96620 +{
96621 + rtx insn;
96622 +
96623 + if (cfun->calls_alloca)
96624 + return 0;
96625 +
96626 + // keep calls only if function frame is big enough
96627 + if (get_frame_size() >= track_frame_size)
96628 + return 0;
96629 +
96630 + // 1. find pax_track_stack calls
96631 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
96632 + // 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))
96633 + rtx body;
96634 +
96635 + if (!CALL_P(insn))
96636 + continue;
96637 + body = PATTERN(insn);
96638 + if (GET_CODE(body) != CALL)
96639 + continue;
96640 + body = XEXP(body, 0);
96641 + if (GET_CODE(body) != MEM)
96642 + continue;
96643 + body = XEXP(body, 0);
96644 + if (GET_CODE(body) != SYMBOL_REF)
96645 + continue;
96646 + if (strcmp(XSTR(body, 0), track_function))
96647 + continue;
96648 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
96649 + // 2. delete call
96650 + insn = delete_insn_and_edges(insn);
96651 +#if BUILDING_GCC_VERSION >= 4007
96652 + if (GET_CODE(insn) == NOTE && NOTE_KIND(insn) == NOTE_INSN_CALL_ARG_LOCATION)
96653 + insn = delete_insn_and_edges(insn);
96654 +#endif
96655 + }
96656 +
96657 +// print_simple_rtl(stderr, get_insns());
96658 +// print_rtl(stderr, get_insns());
96659 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
96660 +
96661 + return 0;
96662 +}
96663 +
96664 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
96665 +{
96666 + const char * const plugin_name = plugin_info->base_name;
96667 + const int argc = plugin_info->argc;
96668 + const struct plugin_argument * const argv = plugin_info->argv;
96669 + int i;
96670 + struct register_pass_info stackleak_tree_instrument_pass_info = {
96671 + .pass = &stackleak_tree_instrument_pass.pass,
96672 +// .reference_pass_name = "tree_profile",
96673 + .reference_pass_name = "optimized",
96674 + .ref_pass_instance_number = 0,
96675 + .pos_op = PASS_POS_INSERT_BEFORE
96676 + };
96677 + struct register_pass_info stackleak_final_pass_info = {
96678 + .pass = &stackleak_final_rtl_opt_pass.pass,
96679 + .reference_pass_name = "final",
96680 + .ref_pass_instance_number = 0,
96681 + .pos_op = PASS_POS_INSERT_BEFORE
96682 + };
96683 +
96684 + if (!plugin_default_version_check(version, &gcc_version)) {
96685 + error(G_("incompatible gcc/plugin versions"));
96686 + return 1;
96687 + }
96688 +
96689 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
96690 +
96691 + for (i = 0; i < argc; ++i) {
96692 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
96693 + if (!argv[i].value) {
96694 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
96695 + continue;
96696 + }
96697 + track_frame_size = atoi(argv[i].value);
96698 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
96699 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
96700 + continue;
96701 + }
96702 + if (!strcmp(argv[i].key, "initialize-locals")) {
96703 + if (argv[i].value) {
96704 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
96705 + continue;
96706 + }
96707 + init_locals = true;
96708 + continue;
96709 + }
96710 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
96711 + }
96712 +
96713 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
96714 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
96715 +
96716 + return 0;
96717 +}
96718 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
96719 index 6789d78..4afd019 100644
96720 --- a/tools/perf/util/include/asm/alternative-asm.h
96721 +++ b/tools/perf/util/include/asm/alternative-asm.h
96722 @@ -5,4 +5,7 @@
96723
96724 #define altinstruction_entry #
96725
96726 + .macro pax_force_retaddr rip=0, reload=0
96727 + .endm
96728 +
96729 #endif
96730 diff --git a/usr/gen_init_cpio.c b/usr/gen_init_cpio.c
96731 index af0f22f..9a7d479 100644
96732 --- a/usr/gen_init_cpio.c
96733 +++ b/usr/gen_init_cpio.c
96734 @@ -303,7 +303,7 @@ static int cpio_mkfile(const char *name, const char *location,
96735 int retval;
96736 int rc = -1;
96737 int namesize;
96738 - int i;
96739 + unsigned int i;
96740
96741 mode |= S_IFREG;
96742
96743 @@ -392,9 +392,10 @@ static char *cpio_replace_env(char *new_location)
96744 *env_var = *expanded = '\0';
96745 strncat(env_var, start + 2, end - start - 2);
96746 strncat(expanded, new_location, start - new_location);
96747 - strncat(expanded, getenv(env_var), PATH_MAX);
96748 - strncat(expanded, end + 1, PATH_MAX);
96749 + strncat(expanded, getenv(env_var), PATH_MAX - strlen(expanded));
96750 + strncat(expanded, end + 1, PATH_MAX - strlen(expanded));
96751 strncpy(new_location, expanded, PATH_MAX);
96752 + new_location[PATH_MAX] = 0;
96753 } else
96754 break;
96755 }
96756 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
96757 index 7858228..2919715 100644
96758 --- a/virt/kvm/kvm_main.c
96759 +++ b/virt/kvm/kvm_main.c
96760 @@ -75,7 +75,7 @@ LIST_HEAD(vm_list);
96761
96762 static cpumask_var_t cpus_hardware_enabled;
96763 static int kvm_usage_count = 0;
96764 -static atomic_t hardware_enable_failed;
96765 +static atomic_unchecked_t hardware_enable_failed;
96766
96767 struct kmem_cache *kvm_vcpu_cache;
96768 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
96769 @@ -2318,7 +2318,7 @@ static void hardware_enable_nolock(void *junk)
96770
96771 if (r) {
96772 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
96773 - atomic_inc(&hardware_enable_failed);
96774 + atomic_inc_unchecked(&hardware_enable_failed);
96775 printk(KERN_INFO "kvm: enabling virtualization on "
96776 "CPU%d failed\n", cpu);
96777 }
96778 @@ -2372,10 +2372,10 @@ static int hardware_enable_all(void)
96779
96780 kvm_usage_count++;
96781 if (kvm_usage_count == 1) {
96782 - atomic_set(&hardware_enable_failed, 0);
96783 + atomic_set_unchecked(&hardware_enable_failed, 0);
96784 on_each_cpu(hardware_enable_nolock, NULL, 1);
96785
96786 - if (atomic_read(&hardware_enable_failed)) {
96787 + if (atomic_read_unchecked(&hardware_enable_failed)) {
96788 hardware_disable_all_nolock();
96789 r = -EBUSY;
96790 }
96791 @@ -2738,7 +2738,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
96792 kvm_arch_vcpu_put(vcpu);
96793 }
96794
96795 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
96796 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
96797 struct module *module)
96798 {
96799 int r;
96800 @@ -2801,7 +2801,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
96801 if (!vcpu_align)
96802 vcpu_align = __alignof__(struct kvm_vcpu);
96803 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
96804 - 0, NULL);
96805 + SLAB_USERCOPY, NULL);
96806 if (!kvm_vcpu_cache) {
96807 r = -ENOMEM;
96808 goto out_free_3;
96809 @@ -2811,9 +2811,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
96810 if (r)
96811 goto out_free;
96812
96813 - kvm_chardev_ops.owner = module;
96814 - kvm_vm_fops.owner = module;
96815 - kvm_vcpu_fops.owner = module;
96816 + pax_open_kernel();
96817 + *(void **)&kvm_chardev_ops.owner = module;
96818 + *(void **)&kvm_vm_fops.owner = module;
96819 + *(void **)&kvm_vcpu_fops.owner = module;
96820 + pax_close_kernel();
96821
96822 r = misc_register(&kvm_dev);
96823 if (r) {