]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9-3.3.7-201206011935.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9-3.3.7-201206011935.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..02aebe9 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 @@ -407,8 +408,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exc
214 # Rules shared between *config targets and build targets
215
216 # Basic helpers built in scripts/
217 -PHONY += scripts_basic
218 -scripts_basic:
219 +PHONY += scripts_basic gcc-plugins
220 +scripts_basic: gcc-plugins
221 $(Q)$(MAKE) $(build)=scripts/basic
222 $(Q)rm -f .tmp_quiet_recordmcount
223
224 @@ -564,6 +565,55 @@ else
225 KBUILD_CFLAGS += -O2
226 endif
227
228 +ifndef DISABLE_PAX_PLUGINS
229 +ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(CC)"), y)
230 +ifndef DISABLE_PAX_CONSTIFY_PLUGIN
231 +ifndef CONFIG_UML
232 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
233 +endif
234 +endif
235 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
236 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
237 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
238 +endif
239 +ifdef CONFIG_KALLOCSTAT_PLUGIN
240 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
241 +endif
242 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
243 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
244 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
245 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
246 +endif
247 +ifdef CONFIG_CHECKER_PLUGIN
248 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
249 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
250 +endif
251 +endif
252 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
253 +ifdef CONFIG_PAX_SIZE_OVERFLOW
254 +SIZE_OVERFLOW_PLUGIN := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
255 +endif
256 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
257 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS) $(SIZE_OVERFLOW_PLUGIN)
258 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
259 +export CONSTIFY_PLUGIN STACKLEAK_PLUGIN KERNEXEC_PLUGIN CHECKER_PLUGIN SIZE_OVERFLOW_PLUGIN
260 +ifeq ($(KBUILD_EXTMOD),)
261 +gcc-plugins:
262 + $(Q)$(MAKE) $(build)=tools/gcc
263 +else
264 +gcc-plugins: ;
265 +endif
266 +else
267 +gcc-plugins:
268 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
269 + $(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.))
270 +else
271 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
272 +endif
273 + $(Q)echo "PAX_MEMORY_STACKLEAK and other features will be less secure"
274 +endif
275 +endif
276 +
277 include $(srctree)/arch/$(SRCARCH)/Makefile
278
279 ifneq ($(CONFIG_FRAME_WARN),0)
280 @@ -708,7 +758,7 @@ export mod_strip_cmd
281
282
283 ifeq ($(KBUILD_EXTMOD),)
284 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
285 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
286
287 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
288 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
289 @@ -932,6 +982,8 @@ vmlinux.o: $(modpost-init) $(vmlinux-main) FORCE
290
291 # The actual objects are generated when descending,
292 # make sure no implicit rule kicks in
293 +$(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
294 +$(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
295 $(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): $(vmlinux-dirs) ;
296
297 # Handle descending into subdirectories listed in $(vmlinux-dirs)
298 @@ -941,7 +993,7 @@ $(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): $(vmlinux-dirs) ;
299 # Error messages still appears in the original language
300
301 PHONY += $(vmlinux-dirs)
302 -$(vmlinux-dirs): prepare scripts
303 +$(vmlinux-dirs): gcc-plugins prepare scripts
304 $(Q)$(MAKE) $(build)=$@
305
306 # Store (new) KERNELRELASE string in include/config/kernel.release
307 @@ -985,6 +1037,7 @@ prepare0: archprepare FORCE
308 $(Q)$(MAKE) $(build)=.
309
310 # All the preparing..
311 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
312 prepare: prepare0
313
314 # Generate some files
315 @@ -1089,6 +1142,8 @@ all: modules
316 # using awk while concatenating to the final file.
317
318 PHONY += modules
319 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
320 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
321 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
322 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
323 @$(kecho) ' Building modules, stage 2.';
324 @@ -1104,7 +1159,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
325
326 # Target to prepare building external modules
327 PHONY += modules_prepare
328 -modules_prepare: prepare scripts
329 +modules_prepare: gcc-plugins prepare scripts
330
331 # Target to install modules
332 PHONY += modules_install
333 @@ -1201,6 +1256,7 @@ distclean: mrproper
334 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
335 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
336 -o -name '.*.rej' \
337 + -o -name '.*.rej' -o -name '*.so' \
338 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
339 -type f -print | xargs rm -f
340
341 @@ -1361,6 +1417,8 @@ PHONY += $(module-dirs) modules
342 $(module-dirs): crmodverdir $(objtree)/Module.symvers
343 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
344
345 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
346 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
347 modules: $(module-dirs)
348 @$(kecho) ' Building modules, stage 2.';
349 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
350 @@ -1487,17 +1545,21 @@ else
351 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
352 endif
353
354 -%.s: %.c prepare scripts FORCE
355 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
356 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
357 +%.s: %.c gcc-plugins prepare scripts FORCE
358 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
359 %.i: %.c prepare scripts FORCE
360 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
361 -%.o: %.c prepare scripts FORCE
362 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
363 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
364 +%.o: %.c gcc-plugins prepare scripts FORCE
365 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
366 %.lst: %.c prepare scripts FORCE
367 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
368 -%.s: %.S prepare scripts FORCE
369 +%.s: %.S gcc-plugins prepare scripts FORCE
370 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
371 -%.o: %.S prepare scripts FORCE
372 +%.o: %.S gcc-plugins prepare scripts FORCE
373 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
374 %.symtypes: %.c prepare scripts FORCE
375 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
376 @@ -1507,11 +1569,15 @@ endif
377 $(cmd_crmodverdir)
378 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
379 $(build)=$(build-dir)
380 -%/: prepare scripts FORCE
381 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
382 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
383 +%/: gcc-plugins prepare scripts FORCE
384 $(cmd_crmodverdir)
385 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
386 $(build)=$(build-dir)
387 -%.ko: prepare scripts FORCE
388 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
389 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
390 +%.ko: gcc-plugins prepare scripts FORCE
391 $(cmd_crmodverdir)
392 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
393 $(build)=$(build-dir) $(@:.ko=.o)
394 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
395 index 640f909..48b6597 100644
396 --- a/arch/alpha/include/asm/atomic.h
397 +++ b/arch/alpha/include/asm/atomic.h
398 @@ -250,6 +250,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
399 #define atomic_dec(v) atomic_sub(1,(v))
400 #define atomic64_dec(v) atomic64_sub(1,(v))
401
402 +#define atomic64_read_unchecked(v) atomic64_read(v)
403 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
404 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
405 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
406 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
407 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
408 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
409 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
410 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
411 +
412 #define smp_mb__before_atomic_dec() smp_mb()
413 #define smp_mb__after_atomic_dec() smp_mb()
414 #define smp_mb__before_atomic_inc() smp_mb()
415 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
416 index ad368a9..fbe0f25 100644
417 --- a/arch/alpha/include/asm/cache.h
418 +++ b/arch/alpha/include/asm/cache.h
419 @@ -4,19 +4,19 @@
420 #ifndef __ARCH_ALPHA_CACHE_H
421 #define __ARCH_ALPHA_CACHE_H
422
423 +#include <linux/const.h>
424
425 /* Bytes per L1 (data) cache line. */
426 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
427 -# define L1_CACHE_BYTES 64
428 # define L1_CACHE_SHIFT 6
429 #else
430 /* Both EV4 and EV5 are write-through, read-allocate,
431 direct-mapped, physical.
432 */
433 -# define L1_CACHE_BYTES 32
434 # define L1_CACHE_SHIFT 5
435 #endif
436
437 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
438 #define SMP_CACHE_BYTES L1_CACHE_BYTES
439
440 #endif
441 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
442 index da5449e..7418343 100644
443 --- a/arch/alpha/include/asm/elf.h
444 +++ b/arch/alpha/include/asm/elf.h
445 @@ -90,6 +90,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
446
447 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
448
449 +#ifdef CONFIG_PAX_ASLR
450 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
451 +
452 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
453 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
454 +#endif
455 +
456 /* $0 is set by ld.so to a pointer to a function which might be
457 registered using atexit. This provides a mean for the dynamic
458 linker to call DT_FINI functions for shared libraries that have
459 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
460 index bc2a0da..8ad11ee 100644
461 --- a/arch/alpha/include/asm/pgalloc.h
462 +++ b/arch/alpha/include/asm/pgalloc.h
463 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
464 pgd_set(pgd, pmd);
465 }
466
467 +static inline void
468 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
469 +{
470 + pgd_populate(mm, pgd, pmd);
471 +}
472 +
473 extern pgd_t *pgd_alloc(struct mm_struct *mm);
474
475 static inline void
476 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
477 index de98a73..bd4f1f8 100644
478 --- a/arch/alpha/include/asm/pgtable.h
479 +++ b/arch/alpha/include/asm/pgtable.h
480 @@ -101,6 +101,17 @@ struct vm_area_struct;
481 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
482 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
483 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
484 +
485 +#ifdef CONFIG_PAX_PAGEEXEC
486 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
487 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
488 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
489 +#else
490 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
491 +# define PAGE_COPY_NOEXEC PAGE_COPY
492 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
493 +#endif
494 +
495 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
496
497 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
498 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
499 index 2fd00b7..cfd5069 100644
500 --- a/arch/alpha/kernel/module.c
501 +++ b/arch/alpha/kernel/module.c
502 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
503
504 /* The small sections were sorted to the end of the segment.
505 The following should definitely cover them. */
506 - gp = (u64)me->module_core + me->core_size - 0x8000;
507 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
508 got = sechdrs[me->arch.gotsecindex].sh_addr;
509
510 for (i = 0; i < n; i++) {
511 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
512 index 01e8715..be0e80f 100644
513 --- a/arch/alpha/kernel/osf_sys.c
514 +++ b/arch/alpha/kernel/osf_sys.c
515 @@ -1147,7 +1147,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
516 /* At this point: (!vma || addr < vma->vm_end). */
517 if (limit - len < addr)
518 return -ENOMEM;
519 - if (!vma || addr + len <= vma->vm_start)
520 + if (check_heap_stack_gap(vma, addr, len))
521 return addr;
522 addr = vma->vm_end;
523 vma = vma->vm_next;
524 @@ -1183,6 +1183,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
525 merely specific addresses, but regions of memory -- perhaps
526 this feature should be incorporated into all ports? */
527
528 +#ifdef CONFIG_PAX_RANDMMAP
529 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
530 +#endif
531 +
532 if (addr) {
533 addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
534 if (addr != (unsigned long) -ENOMEM)
535 @@ -1190,8 +1194,8 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
536 }
537
538 /* Next, try allocating at TASK_UNMAPPED_BASE. */
539 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
540 - len, limit);
541 + addr = arch_get_unmapped_area_1 (PAGE_ALIGN(current->mm->mmap_base), len, limit);
542 +
543 if (addr != (unsigned long) -ENOMEM)
544 return addr;
545
546 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
547 index fadd5f8..904e73a 100644
548 --- a/arch/alpha/mm/fault.c
549 +++ b/arch/alpha/mm/fault.c
550 @@ -54,6 +54,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
551 __reload_thread(pcb);
552 }
553
554 +#ifdef CONFIG_PAX_PAGEEXEC
555 +/*
556 + * PaX: decide what to do with offenders (regs->pc = fault address)
557 + *
558 + * returns 1 when task should be killed
559 + * 2 when patched PLT trampoline was detected
560 + * 3 when unpatched PLT trampoline was detected
561 + */
562 +static int pax_handle_fetch_fault(struct pt_regs *regs)
563 +{
564 +
565 +#ifdef CONFIG_PAX_EMUPLT
566 + int err;
567 +
568 + do { /* PaX: patched PLT emulation #1 */
569 + unsigned int ldah, ldq, jmp;
570 +
571 + err = get_user(ldah, (unsigned int *)regs->pc);
572 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
573 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
574 +
575 + if (err)
576 + break;
577 +
578 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
579 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
580 + jmp == 0x6BFB0000U)
581 + {
582 + unsigned long r27, addr;
583 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
584 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
585 +
586 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
587 + err = get_user(r27, (unsigned long *)addr);
588 + if (err)
589 + break;
590 +
591 + regs->r27 = r27;
592 + regs->pc = r27;
593 + return 2;
594 + }
595 + } while (0);
596 +
597 + do { /* PaX: patched PLT emulation #2 */
598 + unsigned int ldah, lda, br;
599 +
600 + err = get_user(ldah, (unsigned int *)regs->pc);
601 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
602 + err |= get_user(br, (unsigned int *)(regs->pc+8));
603 +
604 + if (err)
605 + break;
606 +
607 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
608 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
609 + (br & 0xFFE00000U) == 0xC3E00000U)
610 + {
611 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
612 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
613 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
614 +
615 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
616 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
617 + return 2;
618 + }
619 + } while (0);
620 +
621 + do { /* PaX: unpatched PLT emulation */
622 + unsigned int br;
623 +
624 + err = get_user(br, (unsigned int *)regs->pc);
625 +
626 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
627 + unsigned int br2, ldq, nop, jmp;
628 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
629 +
630 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
631 + err = get_user(br2, (unsigned int *)addr);
632 + err |= get_user(ldq, (unsigned int *)(addr+4));
633 + err |= get_user(nop, (unsigned int *)(addr+8));
634 + err |= get_user(jmp, (unsigned int *)(addr+12));
635 + err |= get_user(resolver, (unsigned long *)(addr+16));
636 +
637 + if (err)
638 + break;
639 +
640 + if (br2 == 0xC3600000U &&
641 + ldq == 0xA77B000CU &&
642 + nop == 0x47FF041FU &&
643 + jmp == 0x6B7B0000U)
644 + {
645 + regs->r28 = regs->pc+4;
646 + regs->r27 = addr+16;
647 + regs->pc = resolver;
648 + return 3;
649 + }
650 + }
651 + } while (0);
652 +#endif
653 +
654 + return 1;
655 +}
656 +
657 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
658 +{
659 + unsigned long i;
660 +
661 + printk(KERN_ERR "PAX: bytes at PC: ");
662 + for (i = 0; i < 5; i++) {
663 + unsigned int c;
664 + if (get_user(c, (unsigned int *)pc+i))
665 + printk(KERN_CONT "???????? ");
666 + else
667 + printk(KERN_CONT "%08x ", c);
668 + }
669 + printk("\n");
670 +}
671 +#endif
672
673 /*
674 * This routine handles page faults. It determines the address,
675 @@ -131,8 +249,29 @@ do_page_fault(unsigned long address, unsigned long mmcsr,
676 good_area:
677 si_code = SEGV_ACCERR;
678 if (cause < 0) {
679 - if (!(vma->vm_flags & VM_EXEC))
680 + if (!(vma->vm_flags & VM_EXEC)) {
681 +
682 +#ifdef CONFIG_PAX_PAGEEXEC
683 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
684 + goto bad_area;
685 +
686 + up_read(&mm->mmap_sem);
687 + switch (pax_handle_fetch_fault(regs)) {
688 +
689 +#ifdef CONFIG_PAX_EMUPLT
690 + case 2:
691 + case 3:
692 + return;
693 +#endif
694 +
695 + }
696 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
697 + do_group_exit(SIGKILL);
698 +#else
699 goto bad_area;
700 +#endif
701 +
702 + }
703 } else if (!cause) {
704 /* Allow reads even for write-only mappings */
705 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
706 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
707 index 86976d0..c63ea6b 100644
708 --- a/arch/arm/include/asm/atomic.h
709 +++ b/arch/arm/include/asm/atomic.h
710 @@ -15,6 +15,10 @@
711 #include <linux/types.h>
712 #include <asm/system.h>
713
714 +#ifdef CONFIG_GENERIC_ATOMIC64
715 +#include <asm-generic/atomic64.h>
716 +#endif
717 +
718 #define ATOMIC_INIT(i) { (i) }
719
720 #ifdef __KERNEL__
721 @@ -25,7 +29,15 @@
722 * atomic_set() is the clrex or dummy strex done on every exception return.
723 */
724 #define atomic_read(v) (*(volatile int *)&(v)->counter)
725 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
726 +{
727 + return v->counter;
728 +}
729 #define atomic_set(v,i) (((v)->counter) = (i))
730 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
731 +{
732 + v->counter = i;
733 +}
734
735 #if __LINUX_ARM_ARCH__ >= 6
736
737 @@ -40,6 +52,35 @@ static inline void atomic_add(int i, atomic_t *v)
738 int result;
739
740 __asm__ __volatile__("@ atomic_add\n"
741 +"1: ldrex %1, [%3]\n"
742 +" adds %0, %1, %4\n"
743 +
744 +#ifdef CONFIG_PAX_REFCOUNT
745 +" bvc 3f\n"
746 +"2: bkpt 0xf103\n"
747 +"3:\n"
748 +#endif
749 +
750 +" strex %1, %0, [%3]\n"
751 +" teq %1, #0\n"
752 +" bne 1b"
753 +
754 +#ifdef CONFIG_PAX_REFCOUNT
755 +"\n4:\n"
756 + _ASM_EXTABLE(2b, 4b)
757 +#endif
758 +
759 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
760 + : "r" (&v->counter), "Ir" (i)
761 + : "cc");
762 +}
763 +
764 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
765 +{
766 + unsigned long tmp;
767 + int result;
768 +
769 + __asm__ __volatile__("@ atomic_add_unchecked\n"
770 "1: ldrex %0, [%3]\n"
771 " add %0, %0, %4\n"
772 " strex %1, %0, [%3]\n"
773 @@ -58,6 +99,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
774 smp_mb();
775
776 __asm__ __volatile__("@ atomic_add_return\n"
777 +"1: ldrex %1, [%3]\n"
778 +" adds %0, %1, %4\n"
779 +
780 +#ifdef CONFIG_PAX_REFCOUNT
781 +" bvc 3f\n"
782 +" mov %0, %1\n"
783 +"2: bkpt 0xf103\n"
784 +"3:\n"
785 +#endif
786 +
787 +" strex %1, %0, [%3]\n"
788 +" teq %1, #0\n"
789 +" bne 1b"
790 +
791 +#ifdef CONFIG_PAX_REFCOUNT
792 +"\n4:\n"
793 + _ASM_EXTABLE(2b, 4b)
794 +#endif
795 +
796 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
797 + : "r" (&v->counter), "Ir" (i)
798 + : "cc");
799 +
800 + smp_mb();
801 +
802 + return result;
803 +}
804 +
805 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
806 +{
807 + unsigned long tmp;
808 + int result;
809 +
810 + smp_mb();
811 +
812 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
813 "1: ldrex %0, [%3]\n"
814 " add %0, %0, %4\n"
815 " strex %1, %0, [%3]\n"
816 @@ -78,6 +155,35 @@ static inline void atomic_sub(int i, atomic_t *v)
817 int result;
818
819 __asm__ __volatile__("@ atomic_sub\n"
820 +"1: ldrex %1, [%3]\n"
821 +" subs %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_sub_unchecked(int i, atomic_unchecked_t *v)
844 +{
845 + unsigned long tmp;
846 + int result;
847 +
848 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
849 "1: ldrex %0, [%3]\n"
850 " sub %0, %0, %4\n"
851 " strex %1, %0, [%3]\n"
852 @@ -96,11 +202,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
853 smp_mb();
854
855 __asm__ __volatile__("@ atomic_sub_return\n"
856 -"1: ldrex %0, [%3]\n"
857 -" sub %0, %0, %4\n"
858 +"1: ldrex %1, [%3]\n"
859 +" sub %0, %1, %4\n"
860 +
861 +#ifdef CONFIG_PAX_REFCOUNT
862 +" bvc 3f\n"
863 +" mov %0, %1\n"
864 +"2: bkpt 0xf103\n"
865 +"3:\n"
866 +#endif
867 +
868 " strex %1, %0, [%3]\n"
869 " teq %1, #0\n"
870 " bne 1b"
871 +
872 +#ifdef CONFIG_PAX_REFCOUNT
873 +"\n4:\n"
874 + _ASM_EXTABLE(2b, 4b)
875 +#endif
876 +
877 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
878 : "r" (&v->counter), "Ir" (i)
879 : "cc");
880 @@ -132,6 +252,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
881 return oldval;
882 }
883
884 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
885 +{
886 + unsigned long oldval, res;
887 +
888 + smp_mb();
889 +
890 + do {
891 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
892 + "ldrex %1, [%3]\n"
893 + "mov %0, #0\n"
894 + "teq %1, %4\n"
895 + "strexeq %0, %5, [%3]\n"
896 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
897 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
898 + : "cc");
899 + } while (res);
900 +
901 + smp_mb();
902 +
903 + return oldval;
904 +}
905 +
906 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
907 {
908 unsigned long tmp, tmp2;
909 @@ -165,7 +307,9 @@ static inline int atomic_add_return(int i, atomic_t *v)
910
911 return val;
912 }
913 +#define atomic_add_return_unchecked(i, v) atomic_add_return(i, v)
914 #define atomic_add(i, v) (void) atomic_add_return(i, v)
915 +#define atomic_add_unchecked(i, v) (void) atomic_add_return_unchecked(i, v)
916
917 static inline int atomic_sub_return(int i, atomic_t *v)
918 {
919 @@ -179,7 +323,9 @@ static inline int atomic_sub_return(int i, atomic_t *v)
920
921 return val;
922 }
923 +#define atomic_sub_return_unchecked(i, v) atomic_sub_return(i, v)
924 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
925 +#define atomic_sub_unchecked(i, v) (void) atomic_sub_return_unchecked(i, v)
926
927 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
928 {
929 @@ -194,6 +340,7 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
930
931 return ret;
932 }
933 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg(v, o, n)
934
935 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
936 {
937 @@ -207,6 +354,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
938 #endif /* __LINUX_ARM_ARCH__ */
939
940 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
941 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
942 +{
943 + return xchg(&v->counter, new);
944 +}
945
946 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
947 {
948 @@ -219,11 +370,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
949 }
950
951 #define atomic_inc(v) atomic_add(1, v)
952 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
953 +{
954 + atomic_add_unchecked(1, v);
955 +}
956 #define atomic_dec(v) atomic_sub(1, v)
957 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
958 +{
959 + atomic_sub_unchecked(1, v);
960 +}
961
962 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
963 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
964 +{
965 + return atomic_add_return_unchecked(1, v) == 0;
966 +}
967 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
968 #define atomic_inc_return(v) (atomic_add_return(1, v))
969 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
970 +{
971 + return atomic_add_return_unchecked(1, v);
972 +}
973 #define atomic_dec_return(v) (atomic_sub_return(1, v))
974 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
975
976 @@ -239,6 +406,14 @@ typedef struct {
977 u64 __aligned(8) counter;
978 } atomic64_t;
979
980 +#ifdef CONFIG_PAX_REFCOUNT
981 +typedef struct {
982 + u64 __aligned(8) counter;
983 +} atomic64_unchecked_t;
984 +#else
985 +typedef atomic64_t atomic64_unchecked_t;
986 +#endif
987 +
988 #define ATOMIC64_INIT(i) { (i) }
989
990 static inline u64 atomic64_read(atomic64_t *v)
991 @@ -254,6 +429,19 @@ static inline u64 atomic64_read(atomic64_t *v)
992 return result;
993 }
994
995 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
996 +{
997 + u64 result;
998 +
999 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1000 +" ldrexd %0, %H0, [%1]"
1001 + : "=&r" (result)
1002 + : "r" (&v->counter), "Qo" (v->counter)
1003 + );
1004 +
1005 + return result;
1006 +}
1007 +
1008 static inline void atomic64_set(atomic64_t *v, u64 i)
1009 {
1010 u64 tmp;
1011 @@ -268,6 +456,20 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1012 : "cc");
1013 }
1014
1015 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1016 +{
1017 + u64 tmp;
1018 +
1019 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1020 +"1: ldrexd %0, %H0, [%2]\n"
1021 +" strexd %0, %3, %H3, [%2]\n"
1022 +" teq %0, #0\n"
1023 +" bne 1b"
1024 + : "=&r" (tmp), "=Qo" (v->counter)
1025 + : "r" (&v->counter), "r" (i)
1026 + : "cc");
1027 +}
1028 +
1029 static inline void atomic64_add(u64 i, atomic64_t *v)
1030 {
1031 u64 result;
1032 @@ -276,6 +478,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1033 __asm__ __volatile__("@ atomic64_add\n"
1034 "1: ldrexd %0, %H0, [%3]\n"
1035 " adds %0, %0, %4\n"
1036 +" adcs %H0, %H0, %H4\n"
1037 +
1038 +#ifdef CONFIG_PAX_REFCOUNT
1039 +" bvc 3f\n"
1040 +"2: bkpt 0xf103\n"
1041 +"3:\n"
1042 +#endif
1043 +
1044 +" strexd %1, %0, %H0, [%3]\n"
1045 +" teq %1, #0\n"
1046 +" bne 1b"
1047 +
1048 +#ifdef CONFIG_PAX_REFCOUNT
1049 +"\n4:\n"
1050 + _ASM_EXTABLE(2b, 4b)
1051 +#endif
1052 +
1053 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1054 + : "r" (&v->counter), "r" (i)
1055 + : "cc");
1056 +}
1057 +
1058 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1059 +{
1060 + u64 result;
1061 + unsigned long tmp;
1062 +
1063 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1064 +"1: ldrexd %0, %H0, [%3]\n"
1065 +" adds %0, %0, %4\n"
1066 " adc %H0, %H0, %H4\n"
1067 " strexd %1, %0, %H0, [%3]\n"
1068 " teq %1, #0\n"
1069 @@ -287,12 +519,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1070
1071 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1072 {
1073 - u64 result;
1074 - unsigned long tmp;
1075 + u64 result, tmp;
1076
1077 smp_mb();
1078
1079 __asm__ __volatile__("@ atomic64_add_return\n"
1080 +"1: ldrexd %1, %H1, [%3]\n"
1081 +" adds %0, %1, %4\n"
1082 +" adcs %H0, %H1, %H4\n"
1083 +
1084 +#ifdef CONFIG_PAX_REFCOUNT
1085 +" bvc 3f\n"
1086 +" mov %0, %1\n"
1087 +" mov %H0, %H1\n"
1088 +"2: bkpt 0xf103\n"
1089 +"3:\n"
1090 +#endif
1091 +
1092 +" strexd %1, %0, %H0, [%3]\n"
1093 +" teq %1, #0\n"
1094 +" bne 1b"
1095 +
1096 +#ifdef CONFIG_PAX_REFCOUNT
1097 +"\n4:\n"
1098 + _ASM_EXTABLE(2b, 4b)
1099 +#endif
1100 +
1101 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1102 + : "r" (&v->counter), "r" (i)
1103 + : "cc");
1104 +
1105 + smp_mb();
1106 +
1107 + return result;
1108 +}
1109 +
1110 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1111 +{
1112 + u64 result;
1113 + unsigned long tmp;
1114 +
1115 + smp_mb();
1116 +
1117 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1118 "1: ldrexd %0, %H0, [%3]\n"
1119 " adds %0, %0, %4\n"
1120 " adc %H0, %H0, %H4\n"
1121 @@ -316,6 +585,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1122 __asm__ __volatile__("@ atomic64_sub\n"
1123 "1: ldrexd %0, %H0, [%3]\n"
1124 " subs %0, %0, %4\n"
1125 +" sbcs %H0, %H0, %H4\n"
1126 +
1127 +#ifdef CONFIG_PAX_REFCOUNT
1128 +" bvc 3f\n"
1129 +"2: bkpt 0xf103\n"
1130 +"3:\n"
1131 +#endif
1132 +
1133 +" strexd %1, %0, %H0, [%3]\n"
1134 +" teq %1, #0\n"
1135 +" bne 1b"
1136 +
1137 +#ifdef CONFIG_PAX_REFCOUNT
1138 +"\n4:\n"
1139 + _ASM_EXTABLE(2b, 4b)
1140 +#endif
1141 +
1142 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1143 + : "r" (&v->counter), "r" (i)
1144 + : "cc");
1145 +}
1146 +
1147 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1148 +{
1149 + u64 result;
1150 + unsigned long tmp;
1151 +
1152 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1153 +"1: ldrexd %0, %H0, [%3]\n"
1154 +" subs %0, %0, %4\n"
1155 " sbc %H0, %H0, %H4\n"
1156 " strexd %1, %0, %H0, [%3]\n"
1157 " teq %1, #0\n"
1158 @@ -327,18 +626,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1159
1160 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1161 {
1162 - u64 result;
1163 - unsigned long tmp;
1164 + u64 result, tmp;
1165
1166 smp_mb();
1167
1168 __asm__ __volatile__("@ atomic64_sub_return\n"
1169 -"1: ldrexd %0, %H0, [%3]\n"
1170 -" subs %0, %0, %4\n"
1171 -" sbc %H0, %H0, %H4\n"
1172 +"1: ldrexd %1, %H1, [%3]\n"
1173 +" subs %0, %1, %4\n"
1174 +" sbc %H0, %H1, %H4\n"
1175 +
1176 +#ifdef CONFIG_PAX_REFCOUNT
1177 +" bvc 3f\n"
1178 +" mov %0, %1\n"
1179 +" mov %H0, %H1\n"
1180 +"2: bkpt 0xf103\n"
1181 +"3:\n"
1182 +#endif
1183 +
1184 " strexd %1, %0, %H0, [%3]\n"
1185 " teq %1, #0\n"
1186 " bne 1b"
1187 +
1188 +#ifdef CONFIG_PAX_REFCOUNT
1189 +"\n4:\n"
1190 + _ASM_EXTABLE(2b, 4b)
1191 +#endif
1192 +
1193 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1194 : "r" (&v->counter), "r" (i)
1195 : "cc");
1196 @@ -372,6 +685,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1197 return oldval;
1198 }
1199
1200 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1201 +{
1202 + u64 oldval;
1203 + unsigned long res;
1204 +
1205 + smp_mb();
1206 +
1207 + do {
1208 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1209 + "ldrexd %1, %H1, [%3]\n"
1210 + "mov %0, #0\n"
1211 + "teq %1, %4\n"
1212 + "teqeq %H1, %H4\n"
1213 + "strexdeq %0, %5, %H5, [%3]"
1214 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1215 + : "r" (&ptr->counter), "r" (old), "r" (new)
1216 + : "cc");
1217 + } while (res);
1218 +
1219 + smp_mb();
1220 +
1221 + return oldval;
1222 +}
1223 +
1224 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1225 {
1226 u64 result;
1227 @@ -395,21 +732,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1228
1229 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1230 {
1231 - u64 result;
1232 - unsigned long tmp;
1233 + u64 result, tmp;
1234
1235 smp_mb();
1236
1237 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1238 -"1: ldrexd %0, %H0, [%3]\n"
1239 -" subs %0, %0, #1\n"
1240 -" sbc %H0, %H0, #0\n"
1241 +"1: ldrexd %1, %H1, [%3]\n"
1242 +" subs %0, %1, #1\n"
1243 +" sbc %H0, %H1, #0\n"
1244 +
1245 +#ifdef CONFIG_PAX_REFCOUNT
1246 +" bvc 3f\n"
1247 +" mov %0, %1\n"
1248 +" mov %H0, %H1\n"
1249 +"2: bkpt 0xf103\n"
1250 +"3:\n"
1251 +#endif
1252 +
1253 " teq %H0, #0\n"
1254 -" bmi 2f\n"
1255 +" bmi 4f\n"
1256 " strexd %1, %0, %H0, [%3]\n"
1257 " teq %1, #0\n"
1258 " bne 1b\n"
1259 -"2:"
1260 +"4:\n"
1261 +
1262 +#ifdef CONFIG_PAX_REFCOUNT
1263 + _ASM_EXTABLE(2b, 4b)
1264 +#endif
1265 +
1266 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1267 : "r" (&v->counter)
1268 : "cc");
1269 @@ -432,13 +782,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1270 " teq %0, %5\n"
1271 " teqeq %H0, %H5\n"
1272 " moveq %1, #0\n"
1273 -" beq 2f\n"
1274 +" beq 4f\n"
1275 " adds %0, %0, %6\n"
1276 " adc %H0, %H0, %H6\n"
1277 +
1278 +#ifdef CONFIG_PAX_REFCOUNT
1279 +" bvc 3f\n"
1280 +"2: bkpt 0xf103\n"
1281 +"3:\n"
1282 +#endif
1283 +
1284 " strexd %2, %0, %H0, [%4]\n"
1285 " teq %2, #0\n"
1286 " bne 1b\n"
1287 -"2:"
1288 +"4:\n"
1289 +
1290 +#ifdef CONFIG_PAX_REFCOUNT
1291 + _ASM_EXTABLE(2b, 4b)
1292 +#endif
1293 +
1294 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1295 : "r" (&v->counter), "r" (u), "r" (a)
1296 : "cc");
1297 @@ -451,10 +813,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1298
1299 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1300 #define atomic64_inc(v) atomic64_add(1LL, (v))
1301 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1302 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1303 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1304 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1305 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1306 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1307 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1308 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1309 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1310 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1311 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1312 index 75fe66b..2255c86 100644
1313 --- a/arch/arm/include/asm/cache.h
1314 +++ b/arch/arm/include/asm/cache.h
1315 @@ -4,8 +4,10 @@
1316 #ifndef __ASMARM_CACHE_H
1317 #define __ASMARM_CACHE_H
1318
1319 +#include <linux/const.h>
1320 +
1321 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1322 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1323 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1324
1325 /*
1326 * Memory returned by kmalloc() may be used for DMA, so we must make
1327 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1328 index d5d8d5c..ad92c96 100644
1329 --- a/arch/arm/include/asm/cacheflush.h
1330 +++ b/arch/arm/include/asm/cacheflush.h
1331 @@ -108,7 +108,7 @@ struct cpu_cache_fns {
1332 void (*dma_unmap_area)(const void *, size_t, int);
1333
1334 void (*dma_flush_range)(const void *, const void *);
1335 -};
1336 +} __no_const;
1337
1338 /*
1339 * Select the calling method
1340 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1341 index 0e9ce8d..6ef1e03 100644
1342 --- a/arch/arm/include/asm/elf.h
1343 +++ b/arch/arm/include/asm/elf.h
1344 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1345 the loader. We need to make sure that it is out of the way of the program
1346 that it will "exec", and that there is sufficient room for the brk. */
1347
1348 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1349 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1350 +
1351 +#ifdef CONFIG_PAX_ASLR
1352 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1353 +
1354 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1355 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1356 +#endif
1357
1358 /* When the program starts, a1 contains a pointer to a function to be
1359 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1360 @@ -126,10 +133,6 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1361 extern void elf_set_personality(const struct elf32_hdr *);
1362 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1363
1364 -struct mm_struct;
1365 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1366 -#define arch_randomize_brk arch_randomize_brk
1367 -
1368 extern int vectors_user_mapping(void);
1369 #define arch_setup_additional_pages(bprm, uses_interp) vectors_user_mapping()
1370 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES
1371 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1372 index e51b1e8..32a3113 100644
1373 --- a/arch/arm/include/asm/kmap_types.h
1374 +++ b/arch/arm/include/asm/kmap_types.h
1375 @@ -21,6 +21,7 @@ enum km_type {
1376 KM_L1_CACHE,
1377 KM_L2_CACHE,
1378 KM_KDB,
1379 + KM_CLEARPAGE,
1380 KM_TYPE_NR
1381 };
1382
1383 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1384 index 53426c6..c7baff3 100644
1385 --- a/arch/arm/include/asm/outercache.h
1386 +++ b/arch/arm/include/asm/outercache.h
1387 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1388 #endif
1389 void (*set_debug)(unsigned long);
1390 void (*resume)(void);
1391 -};
1392 +} __no_const;
1393
1394 #ifdef CONFIG_OUTER_CACHE
1395
1396 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1397 index 97b440c..b7ff179 100644
1398 --- a/arch/arm/include/asm/page.h
1399 +++ b/arch/arm/include/asm/page.h
1400 @@ -123,7 +123,7 @@ struct cpu_user_fns {
1401 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1402 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1403 unsigned long vaddr, struct vm_area_struct *vma);
1404 -};
1405 +} __no_const;
1406
1407 #ifdef MULTI_USER
1408 extern struct cpu_user_fns cpu_user;
1409 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1410 index 943504f..bf8d667 100644
1411 --- a/arch/arm/include/asm/pgalloc.h
1412 +++ b/arch/arm/include/asm/pgalloc.h
1413 @@ -43,6 +43,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1414 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1415 }
1416
1417 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1418 +{
1419 + pud_populate(mm, pud, pmd);
1420 +}
1421 +
1422 #else /* !CONFIG_ARM_LPAE */
1423
1424 /*
1425 @@ -51,6 +56,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1426 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1427 #define pmd_free(mm, pmd) do { } while (0)
1428 #define pud_populate(mm,pmd,pte) BUG()
1429 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1430
1431 #endif /* CONFIG_ARM_LPAE */
1432
1433 diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
1434 index e4c96cc..1145653 100644
1435 --- a/arch/arm/include/asm/system.h
1436 +++ b/arch/arm/include/asm/system.h
1437 @@ -98,6 +98,8 @@ void hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int,
1438
1439 #define xchg(ptr,x) \
1440 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1441 +#define xchg_unchecked(ptr,x) \
1442 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1443
1444 extern asmlinkage void c_backtrace(unsigned long fp, int pmode);
1445
1446 @@ -534,6 +536,13 @@ static inline unsigned long long __cmpxchg64_mb(volatile void *ptr,
1447
1448 #endif /* __LINUX_ARM_ARCH__ >= 6 */
1449
1450 +#define _ASM_EXTABLE(from, to) \
1451 +" .pushsection __ex_table,\"a\"\n"\
1452 +" .align 3\n" \
1453 +" .long " #from ", " #to"\n" \
1454 +" .popsection"
1455 +
1456 +
1457 #endif /* __ASSEMBLY__ */
1458
1459 #define arch_align_stack(x) (x)
1460 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
1461 index d4c24d4..4ac53e8 100644
1462 --- a/arch/arm/include/asm/thread_info.h
1463 +++ b/arch/arm/include/asm/thread_info.h
1464 @@ -141,6 +141,12 @@ extern void vfp_flush_hwstate(struct thread_info *);
1465 #define TIF_NOTIFY_RESUME 2 /* callback before returning to user */
1466 #define TIF_SYSCALL_TRACE 8
1467 #define TIF_SYSCALL_AUDIT 9
1468 +
1469 +/* within 8 bits of TIF_SYSCALL_TRACE
1470 + to meet flexible second operand requirements
1471 +*/
1472 +#define TIF_GRSEC_SETXID 10
1473 +
1474 #define TIF_POLLING_NRFLAG 16
1475 #define TIF_USING_IWMMXT 17
1476 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
1477 @@ -156,9 +162,11 @@ extern void vfp_flush_hwstate(struct thread_info *);
1478 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
1479 #define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
1480 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
1481 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
1482
1483 /* Checks for any syscall work in entry-common.S */
1484 -#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
1485 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
1486 + _TIF_GRSEC_SETXID)
1487
1488 /*
1489 * Change these and you break ASM code in entry-common.S
1490 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
1491 index 2958976..12ccac4 100644
1492 --- a/arch/arm/include/asm/uaccess.h
1493 +++ b/arch/arm/include/asm/uaccess.h
1494 @@ -22,6 +22,8 @@
1495 #define VERIFY_READ 0
1496 #define VERIFY_WRITE 1
1497
1498 +extern void check_object_size(const void *ptr, unsigned long n, bool to);
1499 +
1500 /*
1501 * The exception table consists of pairs of addresses: the first is the
1502 * address of an instruction that is allowed to fault, and the second is
1503 @@ -387,8 +389,23 @@ do { \
1504
1505
1506 #ifdef CONFIG_MMU
1507 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
1508 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
1509 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
1510 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
1511 +
1512 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
1513 +{
1514 + if (!__builtin_constant_p(n))
1515 + check_object_size(to, n, false);
1516 + return ___copy_from_user(to, from, n);
1517 +}
1518 +
1519 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
1520 +{
1521 + if (!__builtin_constant_p(n))
1522 + check_object_size(from, n, true);
1523 + return ___copy_to_user(to, from, n);
1524 +}
1525 +
1526 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
1527 extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
1528 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
1529 @@ -403,6 +420,9 @@ extern unsigned long __must_check __strnlen_user(const char __user *s, long n);
1530
1531 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
1532 {
1533 + if ((long)n < 0)
1534 + return n;
1535 +
1536 if (access_ok(VERIFY_READ, from, n))
1537 n = __copy_from_user(to, from, n);
1538 else /* security hole - plug it */
1539 @@ -412,6 +432,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
1540
1541 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
1542 {
1543 + if ((long)n < 0)
1544 + return n;
1545 +
1546 if (access_ok(VERIFY_WRITE, to, n))
1547 n = __copy_to_user(to, from, n);
1548 return n;
1549 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
1550 index 5b0bce6..becd81c 100644
1551 --- a/arch/arm/kernel/armksyms.c
1552 +++ b/arch/arm/kernel/armksyms.c
1553 @@ -95,8 +95,8 @@ EXPORT_SYMBOL(__strncpy_from_user);
1554 #ifdef CONFIG_MMU
1555 EXPORT_SYMBOL(copy_page);
1556
1557 -EXPORT_SYMBOL(__copy_from_user);
1558 -EXPORT_SYMBOL(__copy_to_user);
1559 +EXPORT_SYMBOL(___copy_from_user);
1560 +EXPORT_SYMBOL(___copy_to_user);
1561 EXPORT_SYMBOL(__clear_user);
1562
1563 EXPORT_SYMBOL(__get_user_1);
1564 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
1565 index 971d65c..cc936fb 100644
1566 --- a/arch/arm/kernel/process.c
1567 +++ b/arch/arm/kernel/process.c
1568 @@ -28,7 +28,6 @@
1569 #include <linux/tick.h>
1570 #include <linux/utsname.h>
1571 #include <linux/uaccess.h>
1572 -#include <linux/random.h>
1573 #include <linux/hw_breakpoint.h>
1574 #include <linux/cpuidle.h>
1575
1576 @@ -273,9 +272,10 @@ void machine_power_off(void)
1577 machine_shutdown();
1578 if (pm_power_off)
1579 pm_power_off();
1580 + BUG();
1581 }
1582
1583 -void machine_restart(char *cmd)
1584 +__noreturn void machine_restart(char *cmd)
1585 {
1586 machine_shutdown();
1587
1588 @@ -517,12 +517,6 @@ unsigned long get_wchan(struct task_struct *p)
1589 return 0;
1590 }
1591
1592 -unsigned long arch_randomize_brk(struct mm_struct *mm)
1593 -{
1594 - unsigned long range_end = mm->brk + 0x02000000;
1595 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
1596 -}
1597 -
1598 #ifdef CONFIG_MMU
1599 /*
1600 * The vectors page is always readable from user space for the
1601 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
1602 index f5ce8ab..4b73893 100644
1603 --- a/arch/arm/kernel/ptrace.c
1604 +++ b/arch/arm/kernel/ptrace.c
1605 @@ -905,10 +905,19 @@ long arch_ptrace(struct task_struct *child, long request,
1606 return ret;
1607 }
1608
1609 +#ifdef CONFIG_GRKERNSEC_SETXID
1610 +extern void gr_delayed_cred_worker(void);
1611 +#endif
1612 +
1613 asmlinkage int syscall_trace(int why, struct pt_regs *regs, int scno)
1614 {
1615 unsigned long ip;
1616
1617 +#ifdef CONFIG_GRKERNSEC_SETXID
1618 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
1619 + gr_delayed_cred_worker();
1620 +#endif
1621 +
1622 if (why)
1623 audit_syscall_exit(regs);
1624 else
1625 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
1626 index a255c39..4a19b25 100644
1627 --- a/arch/arm/kernel/setup.c
1628 +++ b/arch/arm/kernel/setup.c
1629 @@ -109,13 +109,13 @@ struct processor processor __read_mostly;
1630 struct cpu_tlb_fns cpu_tlb __read_mostly;
1631 #endif
1632 #ifdef MULTI_USER
1633 -struct cpu_user_fns cpu_user __read_mostly;
1634 +struct cpu_user_fns cpu_user __read_only;
1635 #endif
1636 #ifdef MULTI_CACHE
1637 -struct cpu_cache_fns cpu_cache __read_mostly;
1638 +struct cpu_cache_fns cpu_cache __read_only;
1639 #endif
1640 #ifdef CONFIG_OUTER_CACHE
1641 -struct outer_cache_fns outer_cache __read_mostly;
1642 +struct outer_cache_fns outer_cache __read_only;
1643 EXPORT_SYMBOL(outer_cache);
1644 #endif
1645
1646 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
1647 index f84dfe6..13e94f7 100644
1648 --- a/arch/arm/kernel/traps.c
1649 +++ b/arch/arm/kernel/traps.c
1650 @@ -259,6 +259,8 @@ static int __die(const char *str, int err, struct thread_info *thread, struct pt
1651
1652 static DEFINE_RAW_SPINLOCK(die_lock);
1653
1654 +extern void gr_handle_kernel_exploit(void);
1655 +
1656 /*
1657 * This function is protected against re-entrancy.
1658 */
1659 @@ -291,6 +293,9 @@ void die(const char *str, struct pt_regs *regs, int err)
1660 panic("Fatal exception in interrupt");
1661 if (panic_on_oops)
1662 panic("Fatal exception");
1663 +
1664 + gr_handle_kernel_exploit();
1665 +
1666 if (ret != NOTIFY_STOP)
1667 do_exit(SIGSEGV);
1668 }
1669 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
1670 index 66a477a..bee61d3 100644
1671 --- a/arch/arm/lib/copy_from_user.S
1672 +++ b/arch/arm/lib/copy_from_user.S
1673 @@ -16,7 +16,7 @@
1674 /*
1675 * Prototype:
1676 *
1677 - * size_t __copy_from_user(void *to, const void *from, size_t n)
1678 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
1679 *
1680 * Purpose:
1681 *
1682 @@ -84,11 +84,11 @@
1683
1684 .text
1685
1686 -ENTRY(__copy_from_user)
1687 +ENTRY(___copy_from_user)
1688
1689 #include "copy_template.S"
1690
1691 -ENDPROC(__copy_from_user)
1692 +ENDPROC(___copy_from_user)
1693
1694 .pushsection .fixup,"ax"
1695 .align 0
1696 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
1697 index 6ee2f67..d1cce76 100644
1698 --- a/arch/arm/lib/copy_page.S
1699 +++ b/arch/arm/lib/copy_page.S
1700 @@ -10,6 +10,7 @@
1701 * ASM optimised string functions
1702 */
1703 #include <linux/linkage.h>
1704 +#include <linux/const.h>
1705 #include <asm/assembler.h>
1706 #include <asm/asm-offsets.h>
1707 #include <asm/cache.h>
1708 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
1709 index d066df6..df28194 100644
1710 --- a/arch/arm/lib/copy_to_user.S
1711 +++ b/arch/arm/lib/copy_to_user.S
1712 @@ -16,7 +16,7 @@
1713 /*
1714 * Prototype:
1715 *
1716 - * size_t __copy_to_user(void *to, const void *from, size_t n)
1717 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
1718 *
1719 * Purpose:
1720 *
1721 @@ -88,11 +88,11 @@
1722 .text
1723
1724 ENTRY(__copy_to_user_std)
1725 -WEAK(__copy_to_user)
1726 +WEAK(___copy_to_user)
1727
1728 #include "copy_template.S"
1729
1730 -ENDPROC(__copy_to_user)
1731 +ENDPROC(___copy_to_user)
1732 ENDPROC(__copy_to_user_std)
1733
1734 .pushsection .fixup,"ax"
1735 diff --git a/arch/arm/lib/uaccess.S b/arch/arm/lib/uaccess.S
1736 index 5c908b1..e712687 100644
1737 --- a/arch/arm/lib/uaccess.S
1738 +++ b/arch/arm/lib/uaccess.S
1739 @@ -20,7 +20,7 @@
1740
1741 #define PAGE_SHIFT 12
1742
1743 -/* Prototype: int __copy_to_user(void *to, const char *from, size_t n)
1744 +/* Prototype: int ___copy_to_user(void *to, const char *from, size_t n)
1745 * Purpose : copy a block to user memory from kernel memory
1746 * Params : to - user memory
1747 * : from - kernel memory
1748 @@ -40,7 +40,7 @@ USER( TUSER( strgtb) r3, [r0], #1) @ May fault
1749 sub r2, r2, ip
1750 b .Lc2u_dest_aligned
1751
1752 -ENTRY(__copy_to_user)
1753 +ENTRY(___copy_to_user)
1754 stmfd sp!, {r2, r4 - r7, lr}
1755 cmp r2, #4
1756 blt .Lc2u_not_enough
1757 @@ -278,14 +278,14 @@ USER( TUSER( strgeb) r3, [r0], #1) @ May fault
1758 ldrgtb r3, [r1], #0
1759 USER( TUSER( strgtb) r3, [r0], #1) @ May fault
1760 b .Lc2u_finished
1761 -ENDPROC(__copy_to_user)
1762 +ENDPROC(___copy_to_user)
1763
1764 .pushsection .fixup,"ax"
1765 .align 0
1766 9001: ldmfd sp!, {r0, r4 - r7, pc}
1767 .popsection
1768
1769 -/* Prototype: unsigned long __copy_from_user(void *to,const void *from,unsigned long n);
1770 +/* Prototype: unsigned long ___copy_from_user(void *to,const void *from,unsigned long n);
1771 * Purpose : copy a block from user memory to kernel memory
1772 * Params : to - kernel memory
1773 * : from - user memory
1774 @@ -304,7 +304,7 @@ USER( TUSER( ldrgtb) r3, [r1], #1) @ May fault
1775 sub r2, r2, ip
1776 b .Lcfu_dest_aligned
1777
1778 -ENTRY(__copy_from_user)
1779 +ENTRY(___copy_from_user)
1780 stmfd sp!, {r0, r2, r4 - r7, lr}
1781 cmp r2, #4
1782 blt .Lcfu_not_enough
1783 @@ -544,7 +544,7 @@ USER( TUSER( ldrgeb) r3, [r1], #1) @ May fault
1784 USER( TUSER( ldrgtb) r3, [r1], #1) @ May fault
1785 strgtb r3, [r0], #1
1786 b .Lcfu_finished
1787 -ENDPROC(__copy_from_user)
1788 +ENDPROC(___copy_from_user)
1789
1790 .pushsection .fixup,"ax"
1791 .align 0
1792 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
1793 index 025f742..8432b08 100644
1794 --- a/arch/arm/lib/uaccess_with_memcpy.c
1795 +++ b/arch/arm/lib/uaccess_with_memcpy.c
1796 @@ -104,7 +104,7 @@ out:
1797 }
1798
1799 unsigned long
1800 -__copy_to_user(void __user *to, const void *from, unsigned long n)
1801 +___copy_to_user(void __user *to, const void *from, unsigned long n)
1802 {
1803 /*
1804 * This test is stubbed out of the main function above to keep
1805 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
1806 index 6722627..8f97548c 100644
1807 --- a/arch/arm/mach-omap2/board-n8x0.c
1808 +++ b/arch/arm/mach-omap2/board-n8x0.c
1809 @@ -597,7 +597,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
1810 }
1811 #endif
1812
1813 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
1814 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
1815 .late_init = n8x0_menelaus_late_init,
1816 };
1817
1818 diff --git a/arch/arm/mach-ux500/mbox-db5500.c b/arch/arm/mach-ux500/mbox-db5500.c
1819 index 2b2d51c..0127490 100644
1820 --- a/arch/arm/mach-ux500/mbox-db5500.c
1821 +++ b/arch/arm/mach-ux500/mbox-db5500.c
1822 @@ -168,7 +168,7 @@ static ssize_t mbox_read_fifo(struct device *dev,
1823 return sprintf(buf, "0x%X\n", mbox_value);
1824 }
1825
1826 -static DEVICE_ATTR(fifo, S_IWUGO | S_IRUGO, mbox_read_fifo, mbox_write_fifo);
1827 +static DEVICE_ATTR(fifo, S_IWUSR | S_IRUGO, mbox_read_fifo, mbox_write_fifo);
1828
1829 static int mbox_show(struct seq_file *s, void *data)
1830 {
1831 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
1832 index 90e366a..1b92505 100644
1833 --- a/arch/arm/mm/fault.c
1834 +++ b/arch/arm/mm/fault.c
1835 @@ -172,6 +172,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
1836 }
1837 #endif
1838
1839 +#ifdef CONFIG_PAX_PAGEEXEC
1840 + if (fsr & FSR_LNX_PF) {
1841 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
1842 + do_group_exit(SIGKILL);
1843 + }
1844 +#endif
1845 +
1846 tsk->thread.address = addr;
1847 tsk->thread.error_code = fsr;
1848 tsk->thread.trap_no = 14;
1849 @@ -395,6 +402,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
1850 }
1851 #endif /* CONFIG_MMU */
1852
1853 +#ifdef CONFIG_PAX_PAGEEXEC
1854 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
1855 +{
1856 + long i;
1857 +
1858 + printk(KERN_ERR "PAX: bytes at PC: ");
1859 + for (i = 0; i < 20; i++) {
1860 + unsigned char c;
1861 + if (get_user(c, (__force unsigned char __user *)pc+i))
1862 + printk(KERN_CONT "?? ");
1863 + else
1864 + printk(KERN_CONT "%02x ", c);
1865 + }
1866 + printk("\n");
1867 +
1868 + printk(KERN_ERR "PAX: bytes at SP-4: ");
1869 + for (i = -1; i < 20; i++) {
1870 + unsigned long c;
1871 + if (get_user(c, (__force unsigned long __user *)sp+i))
1872 + printk(KERN_CONT "???????? ");
1873 + else
1874 + printk(KERN_CONT "%08lx ", c);
1875 + }
1876 + printk("\n");
1877 +}
1878 +#endif
1879 +
1880 /*
1881 * First Level Translation Fault Handler
1882 *
1883 @@ -575,6 +609,20 @@ do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
1884 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
1885 struct siginfo info;
1886
1887 +#ifdef CONFIG_PAX_REFCOUNT
1888 + if (fsr_fs(ifsr) == 2) {
1889 + unsigned int bkpt;
1890 +
1891 + if (!probe_kernel_address((unsigned int *)addr, bkpt) && bkpt == 0xe12f1073) {
1892 + current->thread.error_code = ifsr;
1893 + current->thread.trap_no = 0;
1894 + pax_report_refcount_overflow(regs);
1895 + fixup_exception(regs);
1896 + return;
1897 + }
1898 + }
1899 +#endif
1900 +
1901 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
1902 return;
1903
1904 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
1905 index ce8cb19..3ec539d 100644
1906 --- a/arch/arm/mm/mmap.c
1907 +++ b/arch/arm/mm/mmap.c
1908 @@ -93,6 +93,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
1909 if (len > TASK_SIZE)
1910 return -ENOMEM;
1911
1912 +#ifdef CONFIG_PAX_RANDMMAP
1913 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
1914 +#endif
1915 +
1916 if (addr) {
1917 if (do_align)
1918 addr = COLOUR_ALIGN(addr, pgoff);
1919 @@ -100,15 +104,14 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
1920 addr = PAGE_ALIGN(addr);
1921
1922 vma = find_vma(mm, addr);
1923 - if (TASK_SIZE - len >= addr &&
1924 - (!vma || addr + len <= vma->vm_start))
1925 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len))
1926 return addr;
1927 }
1928 if (len > mm->cached_hole_size) {
1929 - start_addr = addr = mm->free_area_cache;
1930 + start_addr = addr = mm->free_area_cache;
1931 } else {
1932 - start_addr = addr = mm->mmap_base;
1933 - mm->cached_hole_size = 0;
1934 + start_addr = addr = mm->mmap_base;
1935 + mm->cached_hole_size = 0;
1936 }
1937
1938 full_search:
1939 @@ -124,14 +127,14 @@ full_search:
1940 * Start a new search - just in case we missed
1941 * some holes.
1942 */
1943 - if (start_addr != TASK_UNMAPPED_BASE) {
1944 - start_addr = addr = TASK_UNMAPPED_BASE;
1945 + if (start_addr != mm->mmap_base) {
1946 + start_addr = addr = mm->mmap_base;
1947 mm->cached_hole_size = 0;
1948 goto full_search;
1949 }
1950 return -ENOMEM;
1951 }
1952 - if (!vma || addr + len <= vma->vm_start) {
1953 + if (check_heap_stack_gap(vma, addr, len)) {
1954 /*
1955 * Remember the place where we stopped the search:
1956 */
1957 @@ -266,10 +269,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
1958
1959 if (mmap_is_legacy()) {
1960 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
1961 +
1962 +#ifdef CONFIG_PAX_RANDMMAP
1963 + if (mm->pax_flags & MF_PAX_RANDMMAP)
1964 + mm->mmap_base += mm->delta_mmap;
1965 +#endif
1966 +
1967 mm->get_unmapped_area = arch_get_unmapped_area;
1968 mm->unmap_area = arch_unmap_area;
1969 } else {
1970 mm->mmap_base = mmap_base(random_factor);
1971 +
1972 +#ifdef CONFIG_PAX_RANDMMAP
1973 + if (mm->pax_flags & MF_PAX_RANDMMAP)
1974 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
1975 +#endif
1976 +
1977 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
1978 mm->unmap_area = arch_unmap_area_topdown;
1979 }
1980 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
1981 index 71a6827..e7fbc23 100644
1982 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
1983 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
1984 @@ -43,7 +43,7 @@ struct samsung_dma_ops {
1985 int (*started)(unsigned ch);
1986 int (*flush)(unsigned ch);
1987 int (*stop)(unsigned ch);
1988 -};
1989 +} __no_const;
1990
1991 extern void *samsung_dmadev_get_ops(void);
1992 extern void *s3c_dma_get_ops(void);
1993 diff --git a/arch/arm/plat-samsung/include/plat/ehci.h b/arch/arm/plat-samsung/include/plat/ehci.h
1994 index 5f28cae..3d23723 100644
1995 --- a/arch/arm/plat-samsung/include/plat/ehci.h
1996 +++ b/arch/arm/plat-samsung/include/plat/ehci.h
1997 @@ -14,7 +14,7 @@
1998 struct s5p_ehci_platdata {
1999 int (*phy_init)(struct platform_device *pdev, int type);
2000 int (*phy_exit)(struct platform_device *pdev, int type);
2001 -};
2002 +} __no_const;
2003
2004 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
2005
2006 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
2007 index c3a58a1..78fbf54 100644
2008 --- a/arch/avr32/include/asm/cache.h
2009 +++ b/arch/avr32/include/asm/cache.h
2010 @@ -1,8 +1,10 @@
2011 #ifndef __ASM_AVR32_CACHE_H
2012 #define __ASM_AVR32_CACHE_H
2013
2014 +#include <linux/const.h>
2015 +
2016 #define L1_CACHE_SHIFT 5
2017 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
2018 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
2019
2020 /*
2021 * Memory returned by kmalloc() may be used for DMA, so we must make
2022 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
2023 index 3b3159b..425ea94 100644
2024 --- a/arch/avr32/include/asm/elf.h
2025 +++ b/arch/avr32/include/asm/elf.h
2026 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
2027 the loader. We need to make sure that it is out of the way of the program
2028 that it will "exec", and that there is sufficient room for the brk. */
2029
2030 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
2031 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
2032
2033 +#ifdef CONFIG_PAX_ASLR
2034 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
2035 +
2036 +#define PAX_DELTA_MMAP_LEN 15
2037 +#define PAX_DELTA_STACK_LEN 15
2038 +#endif
2039
2040 /* This yields a mask that user programs can use to figure out what
2041 instruction set this CPU supports. This could be done in user space,
2042 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
2043 index b7f5c68..556135c 100644
2044 --- a/arch/avr32/include/asm/kmap_types.h
2045 +++ b/arch/avr32/include/asm/kmap_types.h
2046 @@ -22,7 +22,8 @@ D(10) KM_IRQ0,
2047 D(11) KM_IRQ1,
2048 D(12) KM_SOFTIRQ0,
2049 D(13) KM_SOFTIRQ1,
2050 -D(14) KM_TYPE_NR
2051 +D(14) KM_CLEARPAGE,
2052 +D(15) KM_TYPE_NR
2053 };
2054
2055 #undef D
2056 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
2057 index f7040a1..db9f300 100644
2058 --- a/arch/avr32/mm/fault.c
2059 +++ b/arch/avr32/mm/fault.c
2060 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
2061
2062 int exception_trace = 1;
2063
2064 +#ifdef CONFIG_PAX_PAGEEXEC
2065 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
2066 +{
2067 + unsigned long i;
2068 +
2069 + printk(KERN_ERR "PAX: bytes at PC: ");
2070 + for (i = 0; i < 20; i++) {
2071 + unsigned char c;
2072 + if (get_user(c, (unsigned char *)pc+i))
2073 + printk(KERN_CONT "???????? ");
2074 + else
2075 + printk(KERN_CONT "%02x ", c);
2076 + }
2077 + printk("\n");
2078 +}
2079 +#endif
2080 +
2081 /*
2082 * This routine handles page faults. It determines the address and the
2083 * problem, and then passes it off to one of the appropriate routines.
2084 @@ -156,6 +173,16 @@ bad_area:
2085 up_read(&mm->mmap_sem);
2086
2087 if (user_mode(regs)) {
2088 +
2089 +#ifdef CONFIG_PAX_PAGEEXEC
2090 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
2091 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
2092 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
2093 + do_group_exit(SIGKILL);
2094 + }
2095 + }
2096 +#endif
2097 +
2098 if (exception_trace && printk_ratelimit())
2099 printk("%s%s[%d]: segfault at %08lx pc %08lx "
2100 "sp %08lx ecr %lu\n",
2101 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
2102 index 568885a..f8008df 100644
2103 --- a/arch/blackfin/include/asm/cache.h
2104 +++ b/arch/blackfin/include/asm/cache.h
2105 @@ -7,6 +7,7 @@
2106 #ifndef __ARCH_BLACKFIN_CACHE_H
2107 #define __ARCH_BLACKFIN_CACHE_H
2108
2109 +#include <linux/const.h>
2110 #include <linux/linkage.h> /* for asmlinkage */
2111
2112 /*
2113 @@ -14,7 +15,7 @@
2114 * Blackfin loads 32 bytes for cache
2115 */
2116 #define L1_CACHE_SHIFT 5
2117 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
2118 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
2119 #define SMP_CACHE_BYTES L1_CACHE_BYTES
2120
2121 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
2122 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
2123 index aea2718..3639a60 100644
2124 --- a/arch/cris/include/arch-v10/arch/cache.h
2125 +++ b/arch/cris/include/arch-v10/arch/cache.h
2126 @@ -1,8 +1,9 @@
2127 #ifndef _ASM_ARCH_CACHE_H
2128 #define _ASM_ARCH_CACHE_H
2129
2130 +#include <linux/const.h>
2131 /* Etrax 100LX have 32-byte cache-lines. */
2132 -#define L1_CACHE_BYTES 32
2133 #define L1_CACHE_SHIFT 5
2134 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
2135
2136 #endif /* _ASM_ARCH_CACHE_H */
2137 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
2138 index 1de779f..336fad3 100644
2139 --- a/arch/cris/include/arch-v32/arch/cache.h
2140 +++ b/arch/cris/include/arch-v32/arch/cache.h
2141 @@ -1,11 +1,12 @@
2142 #ifndef _ASM_CRIS_ARCH_CACHE_H
2143 #define _ASM_CRIS_ARCH_CACHE_H
2144
2145 +#include <linux/const.h>
2146 #include <arch/hwregs/dma.h>
2147
2148 /* A cache-line is 32 bytes. */
2149 -#define L1_CACHE_BYTES 32
2150 #define L1_CACHE_SHIFT 5
2151 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
2152
2153 #define __read_mostly __attribute__((__section__(".data.read_mostly")))
2154
2155 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
2156 index 0d8a7d6..d0c9ff5 100644
2157 --- a/arch/frv/include/asm/atomic.h
2158 +++ b/arch/frv/include/asm/atomic.h
2159 @@ -241,6 +241,16 @@ extern uint32_t __xchg_32(uint32_t i, volatile void *v);
2160 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
2161 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
2162
2163 +#define atomic64_read_unchecked(v) atomic64_read(v)
2164 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
2165 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
2166 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
2167 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
2168 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
2169 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
2170 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
2171 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
2172 +
2173 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
2174 {
2175 int c, old;
2176 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
2177 index 2797163..c2a401d 100644
2178 --- a/arch/frv/include/asm/cache.h
2179 +++ b/arch/frv/include/asm/cache.h
2180 @@ -12,10 +12,11 @@
2181 #ifndef __ASM_CACHE_H
2182 #define __ASM_CACHE_H
2183
2184 +#include <linux/const.h>
2185
2186 /* bytes per L1 cache line */
2187 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
2188 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
2189 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
2190
2191 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
2192 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
2193 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
2194 index f8e16b2..c73ff79 100644
2195 --- a/arch/frv/include/asm/kmap_types.h
2196 +++ b/arch/frv/include/asm/kmap_types.h
2197 @@ -23,6 +23,7 @@ enum km_type {
2198 KM_IRQ1,
2199 KM_SOFTIRQ0,
2200 KM_SOFTIRQ1,
2201 + KM_CLEARPAGE,
2202 KM_TYPE_NR
2203 };
2204
2205 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
2206 index 385fd30..6c3d97e 100644
2207 --- a/arch/frv/mm/elf-fdpic.c
2208 +++ b/arch/frv/mm/elf-fdpic.c
2209 @@ -73,8 +73,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
2210 if (addr) {
2211 addr = PAGE_ALIGN(addr);
2212 vma = find_vma(current->mm, addr);
2213 - if (TASK_SIZE - len >= addr &&
2214 - (!vma || addr + len <= vma->vm_start))
2215 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len))
2216 goto success;
2217 }
2218
2219 @@ -89,7 +88,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
2220 for (; vma; vma = vma->vm_next) {
2221 if (addr > limit)
2222 break;
2223 - if (addr + len <= vma->vm_start)
2224 + if (check_heap_stack_gap(vma, addr, len))
2225 goto success;
2226 addr = vma->vm_end;
2227 }
2228 @@ -104,7 +103,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
2229 for (; vma; vma = vma->vm_next) {
2230 if (addr > limit)
2231 break;
2232 - if (addr + len <= vma->vm_start)
2233 + if (check_heap_stack_gap(vma, addr, len))
2234 goto success;
2235 addr = vma->vm_end;
2236 }
2237 diff --git a/arch/h8300/include/asm/cache.h b/arch/h8300/include/asm/cache.h
2238 index c635028..6d9445a 100644
2239 --- a/arch/h8300/include/asm/cache.h
2240 +++ b/arch/h8300/include/asm/cache.h
2241 @@ -1,8 +1,10 @@
2242 #ifndef __ARCH_H8300_CACHE_H
2243 #define __ARCH_H8300_CACHE_H
2244
2245 +#include <linux/const.h>
2246 +
2247 /* bytes per L1 cache line */
2248 -#define L1_CACHE_BYTES 4
2249 +#define L1_CACHE_BYTES _AC(4,UL)
2250
2251 /* m68k-elf-gcc 2.95.2 doesn't like these */
2252
2253 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
2254 index 0f01de2..d37d309 100644
2255 --- a/arch/hexagon/include/asm/cache.h
2256 +++ b/arch/hexagon/include/asm/cache.h
2257 @@ -21,9 +21,11 @@
2258 #ifndef __ASM_CACHE_H
2259 #define __ASM_CACHE_H
2260
2261 +#include <linux/const.h>
2262 +
2263 /* Bytes per L1 cache line */
2264 -#define L1_CACHE_SHIFT (5)
2265 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
2266 +#define L1_CACHE_SHIFT 5
2267 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
2268
2269 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
2270 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
2271 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
2272 index 3fad89e..3047da5 100644
2273 --- a/arch/ia64/include/asm/atomic.h
2274 +++ b/arch/ia64/include/asm/atomic.h
2275 @@ -209,6 +209,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
2276 #define atomic64_inc(v) atomic64_add(1, (v))
2277 #define atomic64_dec(v) atomic64_sub(1, (v))
2278
2279 +#define atomic64_read_unchecked(v) atomic64_read(v)
2280 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
2281 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
2282 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
2283 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
2284 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
2285 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
2286 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
2287 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
2288 +
2289 /* Atomic operations are already serializing */
2290 #define smp_mb__before_atomic_dec() barrier()
2291 #define smp_mb__after_atomic_dec() barrier()
2292 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
2293 index 988254a..e1ee885 100644
2294 --- a/arch/ia64/include/asm/cache.h
2295 +++ b/arch/ia64/include/asm/cache.h
2296 @@ -1,6 +1,7 @@
2297 #ifndef _ASM_IA64_CACHE_H
2298 #define _ASM_IA64_CACHE_H
2299
2300 +#include <linux/const.h>
2301
2302 /*
2303 * Copyright (C) 1998-2000 Hewlett-Packard Co
2304 @@ -9,7 +10,7 @@
2305
2306 /* Bytes per L1 (data) cache line. */
2307 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
2308 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
2309 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
2310
2311 #ifdef CONFIG_SMP
2312 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
2313 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
2314 index b5298eb..67c6e62 100644
2315 --- a/arch/ia64/include/asm/elf.h
2316 +++ b/arch/ia64/include/asm/elf.h
2317 @@ -42,6 +42,13 @@
2318 */
2319 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
2320
2321 +#ifdef CONFIG_PAX_ASLR
2322 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
2323 +
2324 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
2325 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
2326 +#endif
2327 +
2328 #define PT_IA_64_UNWIND 0x70000001
2329
2330 /* IA-64 relocations: */
2331 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
2332 index 96a8d92..617a1cf 100644
2333 --- a/arch/ia64/include/asm/pgalloc.h
2334 +++ b/arch/ia64/include/asm/pgalloc.h
2335 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
2336 pgd_val(*pgd_entry) = __pa(pud);
2337 }
2338
2339 +static inline void
2340 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
2341 +{
2342 + pgd_populate(mm, pgd_entry, pud);
2343 +}
2344 +
2345 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
2346 {
2347 return quicklist_alloc(0, GFP_KERNEL, NULL);
2348 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
2349 pud_val(*pud_entry) = __pa(pmd);
2350 }
2351
2352 +static inline void
2353 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
2354 +{
2355 + pud_populate(mm, pud_entry, pmd);
2356 +}
2357 +
2358 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
2359 {
2360 return quicklist_alloc(0, GFP_KERNEL, NULL);
2361 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
2362 index 1a97af3..7529d31 100644
2363 --- a/arch/ia64/include/asm/pgtable.h
2364 +++ b/arch/ia64/include/asm/pgtable.h
2365 @@ -12,7 +12,7 @@
2366 * David Mosberger-Tang <davidm@hpl.hp.com>
2367 */
2368
2369 -
2370 +#include <linux/const.h>
2371 #include <asm/mman.h>
2372 #include <asm/page.h>
2373 #include <asm/processor.h>
2374 @@ -143,6 +143,17 @@
2375 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
2376 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
2377 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
2378 +
2379 +#ifdef CONFIG_PAX_PAGEEXEC
2380 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
2381 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
2382 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
2383 +#else
2384 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
2385 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
2386 +# define PAGE_COPY_NOEXEC PAGE_COPY
2387 +#endif
2388 +
2389 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
2390 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
2391 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
2392 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
2393 index b77768d..e0795eb 100644
2394 --- a/arch/ia64/include/asm/spinlock.h
2395 +++ b/arch/ia64/include/asm/spinlock.h
2396 @@ -72,7 +72,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
2397 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
2398
2399 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
2400 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
2401 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
2402 }
2403
2404 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
2405 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
2406 index 449c8c0..432a3d2 100644
2407 --- a/arch/ia64/include/asm/uaccess.h
2408 +++ b/arch/ia64/include/asm/uaccess.h
2409 @@ -257,7 +257,7 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
2410 const void *__cu_from = (from); \
2411 long __cu_len = (n); \
2412 \
2413 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
2414 + if (__cu_len > 0 && __cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) \
2415 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
2416 __cu_len; \
2417 })
2418 @@ -269,7 +269,7 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
2419 long __cu_len = (n); \
2420 \
2421 __chk_user_ptr(__cu_from); \
2422 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
2423 + if (__cu_len > 0 && __cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) \
2424 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
2425 __cu_len; \
2426 })
2427 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
2428 index 24603be..948052d 100644
2429 --- a/arch/ia64/kernel/module.c
2430 +++ b/arch/ia64/kernel/module.c
2431 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
2432 void
2433 module_free (struct module *mod, void *module_region)
2434 {
2435 - if (mod && mod->arch.init_unw_table &&
2436 - module_region == mod->module_init) {
2437 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
2438 unw_remove_unwind_table(mod->arch.init_unw_table);
2439 mod->arch.init_unw_table = NULL;
2440 }
2441 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
2442 }
2443
2444 static inline int
2445 +in_init_rx (const struct module *mod, uint64_t addr)
2446 +{
2447 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
2448 +}
2449 +
2450 +static inline int
2451 +in_init_rw (const struct module *mod, uint64_t addr)
2452 +{
2453 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
2454 +}
2455 +
2456 +static inline int
2457 in_init (const struct module *mod, uint64_t addr)
2458 {
2459 - return addr - (uint64_t) mod->module_init < mod->init_size;
2460 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
2461 +}
2462 +
2463 +static inline int
2464 +in_core_rx (const struct module *mod, uint64_t addr)
2465 +{
2466 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
2467 +}
2468 +
2469 +static inline int
2470 +in_core_rw (const struct module *mod, uint64_t addr)
2471 +{
2472 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
2473 }
2474
2475 static inline int
2476 in_core (const struct module *mod, uint64_t addr)
2477 {
2478 - return addr - (uint64_t) mod->module_core < mod->core_size;
2479 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
2480 }
2481
2482 static inline int
2483 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
2484 break;
2485
2486 case RV_BDREL:
2487 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
2488 + if (in_init_rx(mod, val))
2489 + val -= (uint64_t) mod->module_init_rx;
2490 + else if (in_init_rw(mod, val))
2491 + val -= (uint64_t) mod->module_init_rw;
2492 + else if (in_core_rx(mod, val))
2493 + val -= (uint64_t) mod->module_core_rx;
2494 + else if (in_core_rw(mod, val))
2495 + val -= (uint64_t) mod->module_core_rw;
2496 break;
2497
2498 case RV_LTV:
2499 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
2500 * addresses have been selected...
2501 */
2502 uint64_t gp;
2503 - if (mod->core_size > MAX_LTOFF)
2504 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
2505 /*
2506 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
2507 * at the end of the module.
2508 */
2509 - gp = mod->core_size - MAX_LTOFF / 2;
2510 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
2511 else
2512 - gp = mod->core_size / 2;
2513 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
2514 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
2515 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
2516 mod->arch.gp = gp;
2517 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
2518 }
2519 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
2520 index 609d500..7dde2a8 100644
2521 --- a/arch/ia64/kernel/sys_ia64.c
2522 +++ b/arch/ia64/kernel/sys_ia64.c
2523 @@ -43,6 +43,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
2524 if (REGION_NUMBER(addr) == RGN_HPAGE)
2525 addr = 0;
2526 #endif
2527 +
2528 +#ifdef CONFIG_PAX_RANDMMAP
2529 + if (mm->pax_flags & MF_PAX_RANDMMAP)
2530 + addr = mm->free_area_cache;
2531 + else
2532 +#endif
2533 +
2534 if (!addr)
2535 addr = mm->free_area_cache;
2536
2537 @@ -61,14 +68,14 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
2538 for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
2539 /* At this point: (!vma || addr < vma->vm_end). */
2540 if (TASK_SIZE - len < addr || RGN_MAP_LIMIT - len < REGION_OFFSET(addr)) {
2541 - if (start_addr != TASK_UNMAPPED_BASE) {
2542 + if (start_addr != mm->mmap_base) {
2543 /* Start a new search --- just in case we missed some holes. */
2544 - addr = TASK_UNMAPPED_BASE;
2545 + addr = mm->mmap_base;
2546 goto full_search;
2547 }
2548 return -ENOMEM;
2549 }
2550 - if (!vma || addr + len <= vma->vm_start) {
2551 + if (check_heap_stack_gap(vma, addr, len)) {
2552 /* Remember the address where we stopped this search: */
2553 mm->free_area_cache = addr + len;
2554 return addr;
2555 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
2556 index 53c0ba0..2accdde 100644
2557 --- a/arch/ia64/kernel/vmlinux.lds.S
2558 +++ b/arch/ia64/kernel/vmlinux.lds.S
2559 @@ -199,7 +199,7 @@ SECTIONS {
2560 /* Per-cpu data: */
2561 . = ALIGN(PERCPU_PAGE_SIZE);
2562 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
2563 - __phys_per_cpu_start = __per_cpu_load;
2564 + __phys_per_cpu_start = per_cpu_load;
2565 /*
2566 * ensure percpu data fits
2567 * into percpu page size
2568 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
2569 index 20b3593..1ce77f0 100644
2570 --- a/arch/ia64/mm/fault.c
2571 +++ b/arch/ia64/mm/fault.c
2572 @@ -73,6 +73,23 @@ mapped_kernel_page_is_present (unsigned long address)
2573 return pte_present(pte);
2574 }
2575
2576 +#ifdef CONFIG_PAX_PAGEEXEC
2577 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
2578 +{
2579 + unsigned long i;
2580 +
2581 + printk(KERN_ERR "PAX: bytes at PC: ");
2582 + for (i = 0; i < 8; i++) {
2583 + unsigned int c;
2584 + if (get_user(c, (unsigned int *)pc+i))
2585 + printk(KERN_CONT "???????? ");
2586 + else
2587 + printk(KERN_CONT "%08x ", c);
2588 + }
2589 + printk("\n");
2590 +}
2591 +#endif
2592 +
2593 void __kprobes
2594 ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *regs)
2595 {
2596 @@ -146,9 +163,23 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
2597 mask = ( (((isr >> IA64_ISR_X_BIT) & 1UL) << VM_EXEC_BIT)
2598 | (((isr >> IA64_ISR_W_BIT) & 1UL) << VM_WRITE_BIT));
2599
2600 - if ((vma->vm_flags & mask) != mask)
2601 + if ((vma->vm_flags & mask) != mask) {
2602 +
2603 +#ifdef CONFIG_PAX_PAGEEXEC
2604 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
2605 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
2606 + goto bad_area;
2607 +
2608 + up_read(&mm->mmap_sem);
2609 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
2610 + do_group_exit(SIGKILL);
2611 + }
2612 +#endif
2613 +
2614 goto bad_area;
2615
2616 + }
2617 +
2618 /*
2619 * If for any reason at all we couldn't handle the fault, make
2620 * sure we exit gracefully rather than endlessly redo the
2621 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
2622 index 5ca674b..e0e1b70 100644
2623 --- a/arch/ia64/mm/hugetlbpage.c
2624 +++ b/arch/ia64/mm/hugetlbpage.c
2625 @@ -171,7 +171,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
2626 /* At this point: (!vmm || addr < vmm->vm_end). */
2627 if (REGION_OFFSET(addr) + len > RGN_MAP_LIMIT)
2628 return -ENOMEM;
2629 - if (!vmm || (addr + len) <= vmm->vm_start)
2630 + if (check_heap_stack_gap(vmm, addr, len))
2631 return addr;
2632 addr = ALIGN(vmm->vm_end, HPAGE_SIZE);
2633 }
2634 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
2635 index 13df239d..cb52116 100644
2636 --- a/arch/ia64/mm/init.c
2637 +++ b/arch/ia64/mm/init.c
2638 @@ -121,6 +121,19 @@ ia64_init_addr_space (void)
2639 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
2640 vma->vm_end = vma->vm_start + PAGE_SIZE;
2641 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
2642 +
2643 +#ifdef CONFIG_PAX_PAGEEXEC
2644 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
2645 + vma->vm_flags &= ~VM_EXEC;
2646 +
2647 +#ifdef CONFIG_PAX_MPROTECT
2648 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
2649 + vma->vm_flags &= ~VM_MAYEXEC;
2650 +#endif
2651 +
2652 + }
2653 +#endif
2654 +
2655 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
2656 down_write(&current->mm->mmap_sem);
2657 if (insert_vm_struct(current->mm, vma)) {
2658 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
2659 index 40b3ee9..8c2c112 100644
2660 --- a/arch/m32r/include/asm/cache.h
2661 +++ b/arch/m32r/include/asm/cache.h
2662 @@ -1,8 +1,10 @@
2663 #ifndef _ASM_M32R_CACHE_H
2664 #define _ASM_M32R_CACHE_H
2665
2666 +#include <linux/const.h>
2667 +
2668 /* L1 cache line size */
2669 #define L1_CACHE_SHIFT 4
2670 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
2671 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
2672
2673 #endif /* _ASM_M32R_CACHE_H */
2674 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
2675 index 82abd15..d95ae5d 100644
2676 --- a/arch/m32r/lib/usercopy.c
2677 +++ b/arch/m32r/lib/usercopy.c
2678 @@ -14,6 +14,9 @@
2679 unsigned long
2680 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
2681 {
2682 + if ((long)n < 0)
2683 + return n;
2684 +
2685 prefetch(from);
2686 if (access_ok(VERIFY_WRITE, to, n))
2687 __copy_user(to,from,n);
2688 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
2689 unsigned long
2690 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
2691 {
2692 + if ((long)n < 0)
2693 + return n;
2694 +
2695 prefetchw(to);
2696 if (access_ok(VERIFY_READ, from, n))
2697 __copy_user_zeroing(to,from,n);
2698 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
2699 index 0395c51..5f26031 100644
2700 --- a/arch/m68k/include/asm/cache.h
2701 +++ b/arch/m68k/include/asm/cache.h
2702 @@ -4,9 +4,11 @@
2703 #ifndef __ARCH_M68K_CACHE_H
2704 #define __ARCH_M68K_CACHE_H
2705
2706 +#include <linux/const.h>
2707 +
2708 /* bytes per L1 cache line */
2709 #define L1_CACHE_SHIFT 4
2710 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
2711 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
2712
2713 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
2714
2715 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
2716 index 4efe96a..60e8699 100644
2717 --- a/arch/microblaze/include/asm/cache.h
2718 +++ b/arch/microblaze/include/asm/cache.h
2719 @@ -13,11 +13,12 @@
2720 #ifndef _ASM_MICROBLAZE_CACHE_H
2721 #define _ASM_MICROBLAZE_CACHE_H
2722
2723 +#include <linux/const.h>
2724 #include <asm/registers.h>
2725
2726 #define L1_CACHE_SHIFT 5
2727 /* word-granular cache in microblaze */
2728 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
2729 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
2730
2731 #define SMP_CACHE_BYTES L1_CACHE_BYTES
2732
2733 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
2734 index 1d93f81..67794d0 100644
2735 --- a/arch/mips/include/asm/atomic.h
2736 +++ b/arch/mips/include/asm/atomic.h
2737 @@ -21,6 +21,10 @@
2738 #include <asm/war.h>
2739 #include <asm/system.h>
2740
2741 +#ifdef CONFIG_GENERIC_ATOMIC64
2742 +#include <asm-generic/atomic64.h>
2743 +#endif
2744 +
2745 #define ATOMIC_INIT(i) { (i) }
2746
2747 /*
2748 @@ -765,6 +769,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
2749 */
2750 #define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
2751
2752 +#define atomic64_read_unchecked(v) atomic64_read(v)
2753 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
2754 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
2755 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
2756 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
2757 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
2758 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
2759 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
2760 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
2761 +
2762 #endif /* CONFIG_64BIT */
2763
2764 /*
2765 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
2766 index b4db69f..8f3b093 100644
2767 --- a/arch/mips/include/asm/cache.h
2768 +++ b/arch/mips/include/asm/cache.h
2769 @@ -9,10 +9,11 @@
2770 #ifndef _ASM_CACHE_H
2771 #define _ASM_CACHE_H
2772
2773 +#include <linux/const.h>
2774 #include <kmalloc.h>
2775
2776 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
2777 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
2778 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
2779
2780 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
2781 #define SMP_CACHE_BYTES L1_CACHE_BYTES
2782 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
2783 index 455c0ac..ad65fbe 100644
2784 --- a/arch/mips/include/asm/elf.h
2785 +++ b/arch/mips/include/asm/elf.h
2786 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
2787 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
2788 #endif
2789
2790 +#ifdef CONFIG_PAX_ASLR
2791 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
2792 +
2793 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
2794 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
2795 +#endif
2796 +
2797 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
2798 struct linux_binprm;
2799 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
2800 int uses_interp);
2801
2802 -struct mm_struct;
2803 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
2804 -#define arch_randomize_brk arch_randomize_brk
2805 -
2806 #endif /* _ASM_ELF_H */
2807 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
2808 index da9bd7d..91aa7ab 100644
2809 --- a/arch/mips/include/asm/page.h
2810 +++ b/arch/mips/include/asm/page.h
2811 @@ -98,7 +98,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
2812 #ifdef CONFIG_CPU_MIPS32
2813 typedef struct { unsigned long pte_low, pte_high; } pte_t;
2814 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
2815 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
2816 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
2817 #else
2818 typedef struct { unsigned long long pte; } pte_t;
2819 #define pte_val(x) ((x).pte)
2820 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
2821 index 881d18b..cea38bc 100644
2822 --- a/arch/mips/include/asm/pgalloc.h
2823 +++ b/arch/mips/include/asm/pgalloc.h
2824 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
2825 {
2826 set_pud(pud, __pud((unsigned long)pmd));
2827 }
2828 +
2829 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
2830 +{
2831 + pud_populate(mm, pud, pmd);
2832 +}
2833 #endif
2834
2835 /*
2836 diff --git a/arch/mips/include/asm/system.h b/arch/mips/include/asm/system.h
2837 index 6018c80..7c37203 100644
2838 --- a/arch/mips/include/asm/system.h
2839 +++ b/arch/mips/include/asm/system.h
2840 @@ -230,6 +230,6 @@ extern void per_cpu_trap_init(void);
2841 */
2842 #define __ARCH_WANT_UNLOCKED_CTXSW
2843
2844 -extern unsigned long arch_align_stack(unsigned long sp);
2845 +#define arch_align_stack(x) ((x) & ~0xfUL)
2846
2847 #endif /* _ASM_SYSTEM_H */
2848 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
2849 index 0d85d8e..ec71487 100644
2850 --- a/arch/mips/include/asm/thread_info.h
2851 +++ b/arch/mips/include/asm/thread_info.h
2852 @@ -123,6 +123,8 @@ register struct thread_info *__current_thread_info __asm__("$28");
2853 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
2854 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
2855 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
2856 +/* li takes a 32bit immediate */
2857 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
2858 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
2859
2860 #ifdef CONFIG_MIPS32_O32
2861 @@ -146,15 +148,18 @@ register struct thread_info *__current_thread_info __asm__("$28");
2862 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
2863 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
2864 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
2865 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
2866 +
2867 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
2868
2869 /* work to do in syscall_trace_leave() */
2870 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
2871 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
2872
2873 /* work to do on interrupt/exception return */
2874 #define _TIF_WORK_MASK (0x0000ffef & \
2875 ~(_TIF_SECCOMP | _TIF_SYSCALL_AUDIT))
2876 /* work to do on any return to u-space */
2877 -#define _TIF_ALLWORK_MASK (0x8000ffff & ~_TIF_SECCOMP)
2878 +#define _TIF_ALLWORK_MASK ((0x8000ffff & ~_TIF_SECCOMP) | _TIF_GRSEC_SETXID)
2879
2880 #endif /* __KERNEL__ */
2881
2882 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
2883 index 9fdd8bc..4bd7f1a 100644
2884 --- a/arch/mips/kernel/binfmt_elfn32.c
2885 +++ b/arch/mips/kernel/binfmt_elfn32.c
2886 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
2887 #undef ELF_ET_DYN_BASE
2888 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
2889
2890 +#ifdef CONFIG_PAX_ASLR
2891 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
2892 +
2893 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
2894 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
2895 +#endif
2896 +
2897 #include <asm/processor.h>
2898 #include <linux/module.h>
2899 #include <linux/elfcore.h>
2900 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
2901 index ff44823..97f8906 100644
2902 --- a/arch/mips/kernel/binfmt_elfo32.c
2903 +++ b/arch/mips/kernel/binfmt_elfo32.c
2904 @@ -52,6 +52,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
2905 #undef ELF_ET_DYN_BASE
2906 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
2907
2908 +#ifdef CONFIG_PAX_ASLR
2909 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
2910 +
2911 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
2912 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
2913 +#endif
2914 +
2915 #include <asm/processor.h>
2916
2917 /*
2918 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
2919 index 7955409..ceaea7c 100644
2920 --- a/arch/mips/kernel/process.c
2921 +++ b/arch/mips/kernel/process.c
2922 @@ -483,15 +483,3 @@ unsigned long get_wchan(struct task_struct *task)
2923 out:
2924 return pc;
2925 }
2926 -
2927 -/*
2928 - * Don't forget that the stack pointer must be aligned on a 8 bytes
2929 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
2930 - */
2931 -unsigned long arch_align_stack(unsigned long sp)
2932 -{
2933 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
2934 - sp -= get_random_int() & ~PAGE_MASK;
2935 -
2936 - return sp & ALMASK;
2937 -}
2938 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
2939 index 7786b60..3e38c72 100644
2940 --- a/arch/mips/kernel/ptrace.c
2941 +++ b/arch/mips/kernel/ptrace.c
2942 @@ -529,6 +529,10 @@ static inline int audit_arch(void)
2943 return arch;
2944 }
2945
2946 +#ifdef CONFIG_GRKERNSEC_SETXID
2947 +extern void gr_delayed_cred_worker(void);
2948 +#endif
2949 +
2950 /*
2951 * Notification of system call entry/exit
2952 * - triggered by current->work.syscall_trace
2953 @@ -538,6 +542,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
2954 /* do the secure computing check first */
2955 secure_computing(regs->regs[2]);
2956
2957 +#ifdef CONFIG_GRKERNSEC_SETXID
2958 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2959 + gr_delayed_cred_worker();
2960 +#endif
2961 +
2962 if (!(current->ptrace & PT_PTRACED))
2963 goto out;
2964
2965 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
2966 index a632bc1..0b77c7c 100644
2967 --- a/arch/mips/kernel/scall32-o32.S
2968 +++ b/arch/mips/kernel/scall32-o32.S
2969 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
2970
2971 stack_done:
2972 lw t0, TI_FLAGS($28) # syscall tracing enabled?
2973 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
2974 + li t1, _TIF_SYSCALL_WORK
2975 and t0, t1
2976 bnez t0, syscall_trace_entry # -> yes
2977
2978 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
2979 index 3b5a5e9..e1ee86d 100644
2980 --- a/arch/mips/kernel/scall64-64.S
2981 +++ b/arch/mips/kernel/scall64-64.S
2982 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
2983
2984 sd a3, PT_R26(sp) # save a3 for syscall restarting
2985
2986 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
2987 + li t1, _TIF_SYSCALL_WORK
2988 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
2989 and t0, t1, t0
2990 bnez t0, syscall_trace_entry
2991 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
2992 index 6be6f70..1859577 100644
2993 --- a/arch/mips/kernel/scall64-n32.S
2994 +++ b/arch/mips/kernel/scall64-n32.S
2995 @@ -53,7 +53,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
2996
2997 sd a3, PT_R26(sp) # save a3 for syscall restarting
2998
2999 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
3000 + li t1, _TIF_SYSCALL_WORK
3001 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
3002 and t0, t1, t0
3003 bnez t0, n32_syscall_trace_entry
3004 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
3005 index 5422855..74e63a3 100644
3006 --- a/arch/mips/kernel/scall64-o32.S
3007 +++ b/arch/mips/kernel/scall64-o32.S
3008 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
3009 PTR 4b, bad_stack
3010 .previous
3011
3012 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
3013 + li t1, _TIF_SYSCALL_WORK
3014 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
3015 and t0, t1, t0
3016 bnez t0, trace_a_syscall
3017 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
3018 index 69ebd58..e4bff83 100644
3019 --- a/arch/mips/mm/fault.c
3020 +++ b/arch/mips/mm/fault.c
3021 @@ -28,6 +28,23 @@
3022 #include <asm/highmem.h> /* For VMALLOC_END */
3023 #include <linux/kdebug.h>
3024
3025 +#ifdef CONFIG_PAX_PAGEEXEC
3026 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3027 +{
3028 + unsigned long i;
3029 +
3030 + printk(KERN_ERR "PAX: bytes at PC: ");
3031 + for (i = 0; i < 5; i++) {
3032 + unsigned int c;
3033 + if (get_user(c, (unsigned int *)pc+i))
3034 + printk(KERN_CONT "???????? ");
3035 + else
3036 + printk(KERN_CONT "%08x ", c);
3037 + }
3038 + printk("\n");
3039 +}
3040 +#endif
3041 +
3042 /*
3043 * This routine handles page faults. It determines the address,
3044 * and the problem, and then passes it off to one of the appropriate
3045 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
3046 index 302d779..7d35bf8 100644
3047 --- a/arch/mips/mm/mmap.c
3048 +++ b/arch/mips/mm/mmap.c
3049 @@ -95,6 +95,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
3050 do_color_align = 1;
3051
3052 /* requesting a specific address */
3053 +
3054 +#ifdef CONFIG_PAX_RANDMMAP
3055 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
3056 +#endif
3057 +
3058 if (addr) {
3059 if (do_color_align)
3060 addr = COLOUR_ALIGN(addr, pgoff);
3061 @@ -102,8 +107,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
3062 addr = PAGE_ALIGN(addr);
3063
3064 vma = find_vma(mm, addr);
3065 - if (TASK_SIZE - len >= addr &&
3066 - (!vma || addr + len <= vma->vm_start))
3067 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len))
3068 return addr;
3069 }
3070
3071 @@ -118,7 +122,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
3072 /* At this point: (!vma || addr < vma->vm_end). */
3073 if (TASK_SIZE - len < addr)
3074 return -ENOMEM;
3075 - if (!vma || addr + len <= vma->vm_start)
3076 + if (check_heap_stack_gap(vmm, addr, len))
3077 return addr;
3078 addr = vma->vm_end;
3079 if (do_color_align)
3080 @@ -145,7 +149,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
3081 /* make sure it can fit in the remaining address space */
3082 if (likely(addr > len)) {
3083 vma = find_vma(mm, addr - len);
3084 - if (!vma || addr <= vma->vm_start) {
3085 + if (check_heap_stack_gap(vmm, addr - len, len))
3086 /* cache the address as a hint for next time */
3087 return mm->free_area_cache = addr - len;
3088 }
3089 @@ -165,7 +169,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
3090 * return with success:
3091 */
3092 vma = find_vma(mm, addr);
3093 - if (likely(!vma || addr + len <= vma->vm_start)) {
3094 + if (check_heap_stack_gap(vmm, addr, len)) {
3095 /* cache the address as a hint for next time */
3096 return mm->free_area_cache = addr;
3097 }
3098 @@ -242,30 +246,3 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3099 mm->unmap_area = arch_unmap_area_topdown;
3100 }
3101 }
3102 -
3103 -static inline unsigned long brk_rnd(void)
3104 -{
3105 - unsigned long rnd = get_random_int();
3106 -
3107 - rnd = rnd << PAGE_SHIFT;
3108 - /* 8MB for 32bit, 256MB for 64bit */
3109 - if (TASK_IS_32BIT_ADDR)
3110 - rnd = rnd & 0x7ffffful;
3111 - else
3112 - rnd = rnd & 0xffffffful;
3113 -
3114 - return rnd;
3115 -}
3116 -
3117 -unsigned long arch_randomize_brk(struct mm_struct *mm)
3118 -{
3119 - unsigned long base = mm->brk;
3120 - unsigned long ret;
3121 -
3122 - ret = PAGE_ALIGN(base + brk_rnd());
3123 -
3124 - if (ret < mm->brk)
3125 - return mm->brk;
3126 -
3127 - return ret;
3128 -}
3129 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
3130 index 967d144..db12197 100644
3131 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
3132 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
3133 @@ -11,12 +11,14 @@
3134 #ifndef _ASM_PROC_CACHE_H
3135 #define _ASM_PROC_CACHE_H
3136
3137 +#include <linux/const.h>
3138 +
3139 /* L1 cache */
3140
3141 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
3142 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
3143 -#define L1_CACHE_BYTES 16 /* bytes per entry */
3144 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
3145 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
3146 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
3147
3148 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
3149 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
3150 index bcb5df2..84fabd2 100644
3151 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
3152 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
3153 @@ -16,13 +16,15 @@
3154 #ifndef _ASM_PROC_CACHE_H
3155 #define _ASM_PROC_CACHE_H
3156
3157 +#include <linux/const.h>
3158 +
3159 /*
3160 * L1 cache
3161 */
3162 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
3163 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
3164 -#define L1_CACHE_BYTES 32 /* bytes per entry */
3165 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
3166 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
3167 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
3168
3169 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
3170 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
3171 index 4ce7a01..449202a 100644
3172 --- a/arch/openrisc/include/asm/cache.h
3173 +++ b/arch/openrisc/include/asm/cache.h
3174 @@ -19,11 +19,13 @@
3175 #ifndef __ASM_OPENRISC_CACHE_H
3176 #define __ASM_OPENRISC_CACHE_H
3177
3178 +#include <linux/const.h>
3179 +
3180 /* FIXME: How can we replace these with values from the CPU...
3181 * they shouldn't be hard-coded!
3182 */
3183
3184 -#define L1_CACHE_BYTES 16
3185 #define L1_CACHE_SHIFT 4
3186 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
3187
3188 #endif /* __ASM_OPENRISC_CACHE_H */
3189 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
3190 index 4054b31..a10c105 100644
3191 --- a/arch/parisc/include/asm/atomic.h
3192 +++ b/arch/parisc/include/asm/atomic.h
3193 @@ -335,6 +335,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
3194
3195 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
3196
3197 +#define atomic64_read_unchecked(v) atomic64_read(v)
3198 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
3199 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
3200 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
3201 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
3202 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
3203 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
3204 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
3205 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
3206 +
3207 #endif /* !CONFIG_64BIT */
3208
3209
3210 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
3211 index 47f11c7..3420df2 100644
3212 --- a/arch/parisc/include/asm/cache.h
3213 +++ b/arch/parisc/include/asm/cache.h
3214 @@ -5,6 +5,7 @@
3215 #ifndef __ARCH_PARISC_CACHE_H
3216 #define __ARCH_PARISC_CACHE_H
3217
3218 +#include <linux/const.h>
3219
3220 /*
3221 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
3222 @@ -15,13 +16,13 @@
3223 * just ruin performance.
3224 */
3225 #ifdef CONFIG_PA20
3226 -#define L1_CACHE_BYTES 64
3227 #define L1_CACHE_SHIFT 6
3228 #else
3229 -#define L1_CACHE_BYTES 32
3230 #define L1_CACHE_SHIFT 5
3231 #endif
3232
3233 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
3234 +
3235 #ifndef __ASSEMBLY__
3236
3237 #define SMP_CACHE_BYTES L1_CACHE_BYTES
3238 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
3239 index 19f6cb1..6c78cf2 100644
3240 --- a/arch/parisc/include/asm/elf.h
3241 +++ b/arch/parisc/include/asm/elf.h
3242 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
3243
3244 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
3245
3246 +#ifdef CONFIG_PAX_ASLR
3247 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
3248 +
3249 +#define PAX_DELTA_MMAP_LEN 16
3250 +#define PAX_DELTA_STACK_LEN 16
3251 +#endif
3252 +
3253 /* This yields a mask that user programs can use to figure out what
3254 instruction set this CPU supports. This could be done in user space,
3255 but it's not easy, and we've already done it here. */
3256 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
3257 index fc987a1..6e068ef 100644
3258 --- a/arch/parisc/include/asm/pgalloc.h
3259 +++ b/arch/parisc/include/asm/pgalloc.h
3260 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
3261 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
3262 }
3263
3264 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
3265 +{
3266 + pgd_populate(mm, pgd, pmd);
3267 +}
3268 +
3269 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
3270 {
3271 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
3272 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
3273 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
3274 #define pmd_free(mm, x) do { } while (0)
3275 #define pgd_populate(mm, pmd, pte) BUG()
3276 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
3277
3278 #endif
3279
3280 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
3281 index 22dadeb..f6c2be4 100644
3282 --- a/arch/parisc/include/asm/pgtable.h
3283 +++ b/arch/parisc/include/asm/pgtable.h
3284 @@ -210,6 +210,17 @@ struct vm_area_struct;
3285 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
3286 #define PAGE_COPY PAGE_EXECREAD
3287 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
3288 +
3289 +#ifdef CONFIG_PAX_PAGEEXEC
3290 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
3291 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
3292 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
3293 +#else
3294 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
3295 +# define PAGE_COPY_NOEXEC PAGE_COPY
3296 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
3297 +#endif
3298 +
3299 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
3300 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
3301 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
3302 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
3303 index 5e34ccf..672bc9c 100644
3304 --- a/arch/parisc/kernel/module.c
3305 +++ b/arch/parisc/kernel/module.c
3306 @@ -98,16 +98,38 @@
3307
3308 /* three functions to determine where in the module core
3309 * or init pieces the location is */
3310 +static inline int in_init_rx(struct module *me, void *loc)
3311 +{
3312 + return (loc >= me->module_init_rx &&
3313 + loc < (me->module_init_rx + me->init_size_rx));
3314 +}
3315 +
3316 +static inline int in_init_rw(struct module *me, void *loc)
3317 +{
3318 + return (loc >= me->module_init_rw &&
3319 + loc < (me->module_init_rw + me->init_size_rw));
3320 +}
3321 +
3322 static inline int in_init(struct module *me, void *loc)
3323 {
3324 - return (loc >= me->module_init &&
3325 - loc <= (me->module_init + me->init_size));
3326 + return in_init_rx(me, loc) || in_init_rw(me, loc);
3327 +}
3328 +
3329 +static inline int in_core_rx(struct module *me, void *loc)
3330 +{
3331 + return (loc >= me->module_core_rx &&
3332 + loc < (me->module_core_rx + me->core_size_rx));
3333 +}
3334 +
3335 +static inline int in_core_rw(struct module *me, void *loc)
3336 +{
3337 + return (loc >= me->module_core_rw &&
3338 + loc < (me->module_core_rw + me->core_size_rw));
3339 }
3340
3341 static inline int in_core(struct module *me, void *loc)
3342 {
3343 - return (loc >= me->module_core &&
3344 - loc <= (me->module_core + me->core_size));
3345 + return in_core_rx(me, loc) || in_core_rw(me, loc);
3346 }
3347
3348 static inline int in_local(struct module *me, void *loc)
3349 @@ -373,13 +395,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
3350 }
3351
3352 /* align things a bit */
3353 - me->core_size = ALIGN(me->core_size, 16);
3354 - me->arch.got_offset = me->core_size;
3355 - me->core_size += gots * sizeof(struct got_entry);
3356 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
3357 + me->arch.got_offset = me->core_size_rw;
3358 + me->core_size_rw += gots * sizeof(struct got_entry);
3359
3360 - me->core_size = ALIGN(me->core_size, 16);
3361 - me->arch.fdesc_offset = me->core_size;
3362 - me->core_size += fdescs * sizeof(Elf_Fdesc);
3363 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
3364 + me->arch.fdesc_offset = me->core_size_rw;
3365 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
3366
3367 me->arch.got_max = gots;
3368 me->arch.fdesc_max = fdescs;
3369 @@ -397,7 +419,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
3370
3371 BUG_ON(value == 0);
3372
3373 - got = me->module_core + me->arch.got_offset;
3374 + got = me->module_core_rw + me->arch.got_offset;
3375 for (i = 0; got[i].addr; i++)
3376 if (got[i].addr == value)
3377 goto out;
3378 @@ -415,7 +437,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
3379 #ifdef CONFIG_64BIT
3380 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
3381 {
3382 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
3383 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
3384
3385 if (!value) {
3386 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
3387 @@ -433,7 +455,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
3388
3389 /* Create new one */
3390 fdesc->addr = value;
3391 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
3392 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
3393 return (Elf_Addr)fdesc;
3394 }
3395 #endif /* CONFIG_64BIT */
3396 @@ -845,7 +867,7 @@ register_unwind_table(struct module *me,
3397
3398 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
3399 end = table + sechdrs[me->arch.unwind_section].sh_size;
3400 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
3401 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
3402
3403 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
3404 me->arch.unwind_section, table, end, gp);
3405 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
3406 index c9b9322..02d8940 100644
3407 --- a/arch/parisc/kernel/sys_parisc.c
3408 +++ b/arch/parisc/kernel/sys_parisc.c
3409 @@ -43,7 +43,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
3410 /* At this point: (!vma || addr < vma->vm_end). */
3411 if (TASK_SIZE - len < addr)
3412 return -ENOMEM;
3413 - if (!vma || addr + len <= vma->vm_start)
3414 + if (check_heap_stack_gap(vma, addr, len))
3415 return addr;
3416 addr = vma->vm_end;
3417 }
3418 @@ -79,7 +79,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
3419 /* At this point: (!vma || addr < vma->vm_end). */
3420 if (TASK_SIZE - len < addr)
3421 return -ENOMEM;
3422 - if (!vma || addr + len <= vma->vm_start)
3423 + if (check_heap_stack_gap(vma, addr, len))
3424 return addr;
3425 addr = DCACHE_ALIGN(vma->vm_end - offset) + offset;
3426 if (addr < vma->vm_end) /* handle wraparound */
3427 @@ -98,7 +98,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
3428 if (flags & MAP_FIXED)
3429 return addr;
3430 if (!addr)
3431 - addr = TASK_UNMAPPED_BASE;
3432 + addr = current->mm->mmap_base;
3433
3434 if (filp) {
3435 addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
3436 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
3437 index f19e660..414fe24 100644
3438 --- a/arch/parisc/kernel/traps.c
3439 +++ b/arch/parisc/kernel/traps.c
3440 @@ -733,9 +733,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
3441
3442 down_read(&current->mm->mmap_sem);
3443 vma = find_vma(current->mm,regs->iaoq[0]);
3444 - if (vma && (regs->iaoq[0] >= vma->vm_start)
3445 - && (vma->vm_flags & VM_EXEC)) {
3446 -
3447 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
3448 fault_address = regs->iaoq[0];
3449 fault_space = regs->iasq[0];
3450
3451 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
3452 index 18162ce..94de376 100644
3453 --- a/arch/parisc/mm/fault.c
3454 +++ b/arch/parisc/mm/fault.c
3455 @@ -15,6 +15,7 @@
3456 #include <linux/sched.h>
3457 #include <linux/interrupt.h>
3458 #include <linux/module.h>
3459 +#include <linux/unistd.h>
3460
3461 #include <asm/uaccess.h>
3462 #include <asm/traps.h>
3463 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
3464 static unsigned long
3465 parisc_acctyp(unsigned long code, unsigned int inst)
3466 {
3467 - if (code == 6 || code == 16)
3468 + if (code == 6 || code == 7 || code == 16)
3469 return VM_EXEC;
3470
3471 switch (inst & 0xf0000000) {
3472 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
3473 }
3474 #endif
3475
3476 +#ifdef CONFIG_PAX_PAGEEXEC
3477 +/*
3478 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
3479 + *
3480 + * returns 1 when task should be killed
3481 + * 2 when rt_sigreturn trampoline was detected
3482 + * 3 when unpatched PLT trampoline was detected
3483 + */
3484 +static int pax_handle_fetch_fault(struct pt_regs *regs)
3485 +{
3486 +
3487 +#ifdef CONFIG_PAX_EMUPLT
3488 + int err;
3489 +
3490 + do { /* PaX: unpatched PLT emulation */
3491 + unsigned int bl, depwi;
3492 +
3493 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
3494 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
3495 +
3496 + if (err)
3497 + break;
3498 +
3499 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
3500 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
3501 +
3502 + err = get_user(ldw, (unsigned int *)addr);
3503 + err |= get_user(bv, (unsigned int *)(addr+4));
3504 + err |= get_user(ldw2, (unsigned int *)(addr+8));
3505 +
3506 + if (err)
3507 + break;
3508 +
3509 + if (ldw == 0x0E801096U &&
3510 + bv == 0xEAC0C000U &&
3511 + ldw2 == 0x0E881095U)
3512 + {
3513 + unsigned int resolver, map;
3514 +
3515 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
3516 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
3517 + if (err)
3518 + break;
3519 +
3520 + regs->gr[20] = instruction_pointer(regs)+8;
3521 + regs->gr[21] = map;
3522 + regs->gr[22] = resolver;
3523 + regs->iaoq[0] = resolver | 3UL;
3524 + regs->iaoq[1] = regs->iaoq[0] + 4;
3525 + return 3;
3526 + }
3527 + }
3528 + } while (0);
3529 +#endif
3530 +
3531 +#ifdef CONFIG_PAX_EMUTRAMP
3532 +
3533 +#ifndef CONFIG_PAX_EMUSIGRT
3534 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
3535 + return 1;
3536 +#endif
3537 +
3538 + do { /* PaX: rt_sigreturn emulation */
3539 + unsigned int ldi1, ldi2, bel, nop;
3540 +
3541 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
3542 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
3543 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
3544 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
3545 +
3546 + if (err)
3547 + break;
3548 +
3549 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
3550 + ldi2 == 0x3414015AU &&
3551 + bel == 0xE4008200U &&
3552 + nop == 0x08000240U)
3553 + {
3554 + regs->gr[25] = (ldi1 & 2) >> 1;
3555 + regs->gr[20] = __NR_rt_sigreturn;
3556 + regs->gr[31] = regs->iaoq[1] + 16;
3557 + regs->sr[0] = regs->iasq[1];
3558 + regs->iaoq[0] = 0x100UL;
3559 + regs->iaoq[1] = regs->iaoq[0] + 4;
3560 + regs->iasq[0] = regs->sr[2];
3561 + regs->iasq[1] = regs->sr[2];
3562 + return 2;
3563 + }
3564 + } while (0);
3565 +#endif
3566 +
3567 + return 1;
3568 +}
3569 +
3570 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3571 +{
3572 + unsigned long i;
3573 +
3574 + printk(KERN_ERR "PAX: bytes at PC: ");
3575 + for (i = 0; i < 5; i++) {
3576 + unsigned int c;
3577 + if (get_user(c, (unsigned int *)pc+i))
3578 + printk(KERN_CONT "???????? ");
3579 + else
3580 + printk(KERN_CONT "%08x ", c);
3581 + }
3582 + printk("\n");
3583 +}
3584 +#endif
3585 +
3586 int fixup_exception(struct pt_regs *regs)
3587 {
3588 const struct exception_table_entry *fix;
3589 @@ -192,8 +303,33 @@ good_area:
3590
3591 acc_type = parisc_acctyp(code,regs->iir);
3592
3593 - if ((vma->vm_flags & acc_type) != acc_type)
3594 + if ((vma->vm_flags & acc_type) != acc_type) {
3595 +
3596 +#ifdef CONFIG_PAX_PAGEEXEC
3597 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
3598 + (address & ~3UL) == instruction_pointer(regs))
3599 + {
3600 + up_read(&mm->mmap_sem);
3601 + switch (pax_handle_fetch_fault(regs)) {
3602 +
3603 +#ifdef CONFIG_PAX_EMUPLT
3604 + case 3:
3605 + return;
3606 +#endif
3607 +
3608 +#ifdef CONFIG_PAX_EMUTRAMP
3609 + case 2:
3610 + return;
3611 +#endif
3612 +
3613 + }
3614 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
3615 + do_group_exit(SIGKILL);
3616 + }
3617 +#endif
3618 +
3619 goto bad_area;
3620 + }
3621
3622 /*
3623 * If for any reason at all we couldn't handle the fault, make
3624 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
3625 index 02e41b5..ec6e26c 100644
3626 --- a/arch/powerpc/include/asm/atomic.h
3627 +++ b/arch/powerpc/include/asm/atomic.h
3628 @@ -469,6 +469,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
3629
3630 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
3631
3632 +#define atomic64_read_unchecked(v) atomic64_read(v)
3633 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
3634 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
3635 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
3636 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
3637 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
3638 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
3639 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
3640 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
3641 +
3642 #endif /* __powerpc64__ */
3643
3644 #endif /* __KERNEL__ */
3645 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
3646 index 4b50941..5605819 100644
3647 --- a/arch/powerpc/include/asm/cache.h
3648 +++ b/arch/powerpc/include/asm/cache.h
3649 @@ -3,6 +3,7 @@
3650
3651 #ifdef __KERNEL__
3652
3653 +#include <linux/const.h>
3654
3655 /* bytes per L1 cache line */
3656 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
3657 @@ -22,7 +23,7 @@
3658 #define L1_CACHE_SHIFT 7
3659 #endif
3660
3661 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
3662 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
3663
3664 #define SMP_CACHE_BYTES L1_CACHE_BYTES
3665
3666 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
3667 index 3bf9cca..e7457d0 100644
3668 --- a/arch/powerpc/include/asm/elf.h
3669 +++ b/arch/powerpc/include/asm/elf.h
3670 @@ -178,8 +178,19 @@ typedef elf_fpreg_t elf_vsrreghalf_t32[ELF_NVSRHALFREG];
3671 the loader. We need to make sure that it is out of the way of the program
3672 that it will "exec", and that there is sufficient room for the brk. */
3673
3674 -extern unsigned long randomize_et_dyn(unsigned long base);
3675 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
3676 +#define ELF_ET_DYN_BASE (0x20000000)
3677 +
3678 +#ifdef CONFIG_PAX_ASLR
3679 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
3680 +
3681 +#ifdef __powerpc64__
3682 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
3683 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
3684 +#else
3685 +#define PAX_DELTA_MMAP_LEN 15
3686 +#define PAX_DELTA_STACK_LEN 15
3687 +#endif
3688 +#endif
3689
3690 /*
3691 * Our registers are always unsigned longs, whether we're a 32 bit
3692 @@ -274,9 +285,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
3693 (0x7ff >> (PAGE_SHIFT - 12)) : \
3694 (0x3ffff >> (PAGE_SHIFT - 12)))
3695
3696 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
3697 -#define arch_randomize_brk arch_randomize_brk
3698 -
3699 #endif /* __KERNEL__ */
3700
3701 /*
3702 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
3703 index bca8fdc..61e9580 100644
3704 --- a/arch/powerpc/include/asm/kmap_types.h
3705 +++ b/arch/powerpc/include/asm/kmap_types.h
3706 @@ -27,6 +27,7 @@ enum km_type {
3707 KM_PPC_SYNC_PAGE,
3708 KM_PPC_SYNC_ICACHE,
3709 KM_KDB,
3710 + KM_CLEARPAGE,
3711 KM_TYPE_NR
3712 };
3713
3714 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
3715 index d4a7f64..451de1c 100644
3716 --- a/arch/powerpc/include/asm/mman.h
3717 +++ b/arch/powerpc/include/asm/mman.h
3718 @@ -44,7 +44,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
3719 }
3720 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
3721
3722 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
3723 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
3724 {
3725 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
3726 }
3727 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
3728 index f072e97..b436dee 100644
3729 --- a/arch/powerpc/include/asm/page.h
3730 +++ b/arch/powerpc/include/asm/page.h
3731 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
3732 * and needs to be executable. This means the whole heap ends
3733 * up being executable.
3734 */
3735 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
3736 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
3737 +#define VM_DATA_DEFAULT_FLAGS32 \
3738 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
3739 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
3740
3741 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
3742 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
3743 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
3744 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
3745 #endif
3746
3747 +#define ktla_ktva(addr) (addr)
3748 +#define ktva_ktla(addr) (addr)
3749 +
3750 /*
3751 * Use the top bit of the higher-level page table entries to indicate whether
3752 * the entries we point to contain hugepages. This works because we know that
3753 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
3754 index fed85e6..da5c71b 100644
3755 --- a/arch/powerpc/include/asm/page_64.h
3756 +++ b/arch/powerpc/include/asm/page_64.h
3757 @@ -146,15 +146,18 @@ do { \
3758 * stack by default, so in the absence of a PT_GNU_STACK program header
3759 * we turn execute permission off.
3760 */
3761 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
3762 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
3763 +#define VM_STACK_DEFAULT_FLAGS32 \
3764 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
3765 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
3766
3767 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
3768 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
3769
3770 +#ifndef CONFIG_PAX_PAGEEXEC
3771 #define VM_STACK_DEFAULT_FLAGS \
3772 (is_32bit_task() ? \
3773 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
3774 +#endif
3775
3776 #include <asm-generic/getorder.h>
3777
3778 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
3779 index 292725c..f87ae14 100644
3780 --- a/arch/powerpc/include/asm/pgalloc-64.h
3781 +++ b/arch/powerpc/include/asm/pgalloc-64.h
3782 @@ -50,6 +50,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
3783 #ifndef CONFIG_PPC_64K_PAGES
3784
3785 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
3786 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
3787
3788 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
3789 {
3790 @@ -67,6 +68,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
3791 pud_set(pud, (unsigned long)pmd);
3792 }
3793
3794 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
3795 +{
3796 + pud_populate(mm, pud, pmd);
3797 +}
3798 +
3799 #define pmd_populate(mm, pmd, pte_page) \
3800 pmd_populate_kernel(mm, pmd, page_address(pte_page))
3801 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
3802 @@ -76,6 +82,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
3803 #else /* CONFIG_PPC_64K_PAGES */
3804
3805 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
3806 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
3807
3808 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
3809 pte_t *pte)
3810 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
3811 index 2e0e411..7899c68 100644
3812 --- a/arch/powerpc/include/asm/pgtable.h
3813 +++ b/arch/powerpc/include/asm/pgtable.h
3814 @@ -2,6 +2,7 @@
3815 #define _ASM_POWERPC_PGTABLE_H
3816 #ifdef __KERNEL__
3817
3818 +#include <linux/const.h>
3819 #ifndef __ASSEMBLY__
3820 #include <asm/processor.h> /* For TASK_SIZE */
3821 #include <asm/mmu.h>
3822 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
3823 index 4aad413..85d86bf 100644
3824 --- a/arch/powerpc/include/asm/pte-hash32.h
3825 +++ b/arch/powerpc/include/asm/pte-hash32.h
3826 @@ -21,6 +21,7 @@
3827 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
3828 #define _PAGE_USER 0x004 /* usermode access allowed */
3829 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
3830 +#define _PAGE_EXEC _PAGE_GUARDED
3831 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
3832 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
3833 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
3834 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
3835 index 7fdc2c0..e47a9b02d3 100644
3836 --- a/arch/powerpc/include/asm/reg.h
3837 +++ b/arch/powerpc/include/asm/reg.h
3838 @@ -212,6 +212,7 @@
3839 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
3840 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
3841 #define DSISR_NOHPTE 0x40000000 /* no translation found */
3842 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
3843 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
3844 #define DSISR_ISSTORE 0x02000000 /* access was a store */
3845 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
3846 diff --git a/arch/powerpc/include/asm/system.h b/arch/powerpc/include/asm/system.h
3847 index c377457..3c69fbc 100644
3848 --- a/arch/powerpc/include/asm/system.h
3849 +++ b/arch/powerpc/include/asm/system.h
3850 @@ -539,7 +539,7 @@ __cmpxchg_local(volatile void *ptr, unsigned long old, unsigned long new,
3851 #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
3852 #endif
3853
3854 -extern unsigned long arch_align_stack(unsigned long sp);
3855 +#define arch_align_stack(x) ((x) & ~0xfUL)
3856
3857 /* Used in very early kernel initialization. */
3858 extern unsigned long reloc_offset(void);
3859 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
3860 index 96471494..60ed5a2 100644
3861 --- a/arch/powerpc/include/asm/thread_info.h
3862 +++ b/arch/powerpc/include/asm/thread_info.h
3863 @@ -104,13 +104,15 @@ static inline struct thread_info *current_thread_info(void)
3864 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
3865 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
3866 #define TIF_SINGLESTEP 8 /* singlestepping active */
3867 -#define TIF_MEMDIE 9 /* is terminating due to OOM killer */
3868 #define TIF_SECCOMP 10 /* secure computing */
3869 #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
3870 #define TIF_NOERROR 12 /* Force successful syscall return */
3871 #define TIF_NOTIFY_RESUME 13 /* callback before returning to user */
3872 #define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */
3873 #define TIF_RUNLATCH 16 /* Is the runlatch enabled? */
3874 +#define TIF_MEMDIE 17 /* is terminating due to OOM killer */
3875 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
3876 +#define TIF_GRSEC_SETXID 9 /* update credentials on syscall entry/exit */
3877
3878 /* as above, but as bit values */
3879 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
3880 @@ -128,8 +130,11 @@ static inline struct thread_info *current_thread_info(void)
3881 #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
3882 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
3883 #define _TIF_RUNLATCH (1<<TIF_RUNLATCH)
3884 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
3885 +
3886 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
3887 - _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
3888 + _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT \
3889 + _TIF_GRSEC_SETXID)
3890
3891 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
3892 _TIF_NOTIFY_RESUME)
3893 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
3894 index bd0fb84..a42a14b 100644
3895 --- a/arch/powerpc/include/asm/uaccess.h
3896 +++ b/arch/powerpc/include/asm/uaccess.h
3897 @@ -13,6 +13,8 @@
3898 #define VERIFY_READ 0
3899 #define VERIFY_WRITE 1
3900
3901 +extern void check_object_size(const void *ptr, unsigned long n, bool to);
3902 +
3903 /*
3904 * The fs value determines whether argument validity checking should be
3905 * performed or not. If get_fs() == USER_DS, checking is performed, with
3906 @@ -327,52 +329,6 @@ do { \
3907 extern unsigned long __copy_tofrom_user(void __user *to,
3908 const void __user *from, unsigned long size);
3909
3910 -#ifndef __powerpc64__
3911 -
3912 -static inline unsigned long copy_from_user(void *to,
3913 - const void __user *from, unsigned long n)
3914 -{
3915 - unsigned long over;
3916 -
3917 - if (access_ok(VERIFY_READ, from, n))
3918 - return __copy_tofrom_user((__force void __user *)to, from, n);
3919 - if ((unsigned long)from < TASK_SIZE) {
3920 - over = (unsigned long)from + n - TASK_SIZE;
3921 - return __copy_tofrom_user((__force void __user *)to, from,
3922 - n - over) + over;
3923 - }
3924 - return n;
3925 -}
3926 -
3927 -static inline unsigned long copy_to_user(void __user *to,
3928 - const void *from, unsigned long n)
3929 -{
3930 - unsigned long over;
3931 -
3932 - if (access_ok(VERIFY_WRITE, to, n))
3933 - return __copy_tofrom_user(to, (__force void __user *)from, n);
3934 - if ((unsigned long)to < TASK_SIZE) {
3935 - over = (unsigned long)to + n - TASK_SIZE;
3936 - return __copy_tofrom_user(to, (__force void __user *)from,
3937 - n - over) + over;
3938 - }
3939 - return n;
3940 -}
3941 -
3942 -#else /* __powerpc64__ */
3943 -
3944 -#define __copy_in_user(to, from, size) \
3945 - __copy_tofrom_user((to), (from), (size))
3946 -
3947 -extern unsigned long copy_from_user(void *to, const void __user *from,
3948 - unsigned long n);
3949 -extern unsigned long copy_to_user(void __user *to, const void *from,
3950 - unsigned long n);
3951 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
3952 - unsigned long n);
3953 -
3954 -#endif /* __powerpc64__ */
3955 -
3956 static inline unsigned long __copy_from_user_inatomic(void *to,
3957 const void __user *from, unsigned long n)
3958 {
3959 @@ -396,6 +352,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
3960 if (ret == 0)
3961 return 0;
3962 }
3963 +
3964 + if (!__builtin_constant_p(n))
3965 + check_object_size(to, n, false);
3966 +
3967 return __copy_tofrom_user((__force void __user *)to, from, n);
3968 }
3969
3970 @@ -422,6 +382,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
3971 if (ret == 0)
3972 return 0;
3973 }
3974 +
3975 + if (!__builtin_constant_p(n))
3976 + check_object_size(from, n, true);
3977 +
3978 return __copy_tofrom_user(to, (__force const void __user *)from, n);
3979 }
3980
3981 @@ -439,6 +403,92 @@ static inline unsigned long __copy_to_user(void __user *to,
3982 return __copy_to_user_inatomic(to, from, size);
3983 }
3984
3985 +#ifndef __powerpc64__
3986 +
3987 +static inline unsigned long __must_check copy_from_user(void *to,
3988 + const void __user *from, unsigned long n)
3989 +{
3990 + unsigned long over;
3991 +
3992 + if ((long)n < 0)
3993 + return n;
3994 +
3995 + if (access_ok(VERIFY_READ, from, n)) {
3996 + if (!__builtin_constant_p(n))
3997 + check_object_size(to, n, false);
3998 + return __copy_tofrom_user((__force void __user *)to, from, n);
3999 + }
4000 + if ((unsigned long)from < TASK_SIZE) {
4001 + over = (unsigned long)from + n - TASK_SIZE;
4002 + if (!__builtin_constant_p(n - over))
4003 + check_object_size(to, n - over, false);
4004 + return __copy_tofrom_user((__force void __user *)to, from,
4005 + n - over) + over;
4006 + }
4007 + return n;
4008 +}
4009 +
4010 +static inline unsigned long __must_check copy_to_user(void __user *to,
4011 + const void *from, unsigned long n)
4012 +{
4013 + unsigned long over;
4014 +
4015 + if ((long)n < 0)
4016 + return n;
4017 +
4018 + if (access_ok(VERIFY_WRITE, to, n)) {
4019 + if (!__builtin_constant_p(n))
4020 + check_object_size(from, n, true);
4021 + return __copy_tofrom_user(to, (__force void __user *)from, n);
4022 + }
4023 + if ((unsigned long)to < TASK_SIZE) {
4024 + over = (unsigned long)to + n - TASK_SIZE;
4025 + if (!__builtin_constant_p(n))
4026 + check_object_size(from, n - over, true);
4027 + return __copy_tofrom_user(to, (__force void __user *)from,
4028 + n - over) + over;
4029 + }
4030 + return n;
4031 +}
4032 +
4033 +#else /* __powerpc64__ */
4034 +
4035 +#define __copy_in_user(to, from, size) \
4036 + __copy_tofrom_user((to), (from), (size))
4037 +
4038 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
4039 +{
4040 + if ((long)n < 0 || n > INT_MAX)
4041 + return n;
4042 +
4043 + if (!__builtin_constant_p(n))
4044 + check_object_size(to, n, false);
4045 +
4046 + if (likely(access_ok(VERIFY_READ, from, n)))
4047 + n = __copy_from_user(to, from, n);
4048 + else
4049 + memset(to, 0, n);
4050 + return n;
4051 +}
4052 +
4053 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
4054 +{
4055 + if ((long)n < 0 || n > INT_MAX)
4056 + return n;
4057 +
4058 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
4059 + if (!__builtin_constant_p(n))
4060 + check_object_size(from, n, true);
4061 + n = __copy_to_user(to, from, n);
4062 + }
4063 + return n;
4064 +}
4065 +
4066 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
4067 + unsigned long n);
4068 +
4069 +#endif /* __powerpc64__ */
4070 +
4071 extern unsigned long __clear_user(void __user *addr, unsigned long size);
4072
4073 static inline unsigned long clear_user(void __user *addr, unsigned long size)
4074 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
4075 index 429983c..7af363b 100644
4076 --- a/arch/powerpc/kernel/exceptions-64e.S
4077 +++ b/arch/powerpc/kernel/exceptions-64e.S
4078 @@ -587,6 +587,7 @@ storage_fault_common:
4079 std r14,_DAR(r1)
4080 std r15,_DSISR(r1)
4081 addi r3,r1,STACK_FRAME_OVERHEAD
4082 + bl .save_nvgprs
4083 mr r4,r14
4084 mr r5,r15
4085 ld r14,PACA_EXGEN+EX_R14(r13)
4086 @@ -596,8 +597,7 @@ storage_fault_common:
4087 cmpdi r3,0
4088 bne- 1f
4089 b .ret_from_except_lite
4090 -1: bl .save_nvgprs
4091 - mr r5,r3
4092 +1: mr r5,r3
4093 addi r3,r1,STACK_FRAME_OVERHEAD
4094 ld r4,_DAR(r1)
4095 bl .bad_page_fault
4096 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
4097 index 15c5a4f..22a4000 100644
4098 --- a/arch/powerpc/kernel/exceptions-64s.S
4099 +++ b/arch/powerpc/kernel/exceptions-64s.S
4100 @@ -1004,10 +1004,10 @@ handle_page_fault:
4101 11: ld r4,_DAR(r1)
4102 ld r5,_DSISR(r1)
4103 addi r3,r1,STACK_FRAME_OVERHEAD
4104 + bl .save_nvgprs
4105 bl .do_page_fault
4106 cmpdi r3,0
4107 beq+ 13f
4108 - bl .save_nvgprs
4109 mr r5,r3
4110 addi r3,r1,STACK_FRAME_OVERHEAD
4111 lwz r4,_DAR(r1)
4112 diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
4113 index 01e2877..a1ba360 100644
4114 --- a/arch/powerpc/kernel/irq.c
4115 +++ b/arch/powerpc/kernel/irq.c
4116 @@ -560,9 +560,6 @@ struct irq_host *irq_alloc_host(struct device_node *of_node,
4117 host->ops = ops;
4118 host->of_node = of_node_get(of_node);
4119
4120 - if (host->ops->match == NULL)
4121 - host->ops->match = default_irq_host_match;
4122 -
4123 raw_spin_lock_irqsave(&irq_big_lock, flags);
4124
4125 /* If it's a legacy controller, check for duplicates and
4126 @@ -635,7 +632,12 @@ struct irq_host *irq_find_host(struct device_node *node)
4127 */
4128 raw_spin_lock_irqsave(&irq_big_lock, flags);
4129 list_for_each_entry(h, &irq_hosts, link)
4130 - if (h->ops->match(h, node)) {
4131 + if (h->ops->match) {
4132 + if (h->ops->match(h, node)) {
4133 + found = h;
4134 + break;
4135 + }
4136 + } else if (default_irq_host_match(h, node)) {
4137 found = h;
4138 break;
4139 }
4140 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
4141 index 0b6d796..d760ddb 100644
4142 --- a/arch/powerpc/kernel/module_32.c
4143 +++ b/arch/powerpc/kernel/module_32.c
4144 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
4145 me->arch.core_plt_section = i;
4146 }
4147 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
4148 - printk("Module doesn't contain .plt or .init.plt sections.\n");
4149 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
4150 return -ENOEXEC;
4151 }
4152
4153 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
4154
4155 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
4156 /* Init, or core PLT? */
4157 - if (location >= mod->module_core
4158 - && location < mod->module_core + mod->core_size)
4159 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
4160 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
4161 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
4162 - else
4163 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
4164 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
4165 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
4166 + else {
4167 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
4168 + return ~0UL;
4169 + }
4170
4171 /* Find this entry, or if that fails, the next avail. entry */
4172 while (entry->jump[0]) {
4173 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
4174 index d817ab0..b23b18e 100644
4175 --- a/arch/powerpc/kernel/process.c
4176 +++ b/arch/powerpc/kernel/process.c
4177 @@ -676,8 +676,8 @@ void show_regs(struct pt_regs * regs)
4178 * Lookup NIP late so we have the best change of getting the
4179 * above info out without failing
4180 */
4181 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
4182 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
4183 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
4184 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
4185 #endif
4186 show_stack(current, (unsigned long *) regs->gpr[1]);
4187 if (!user_mode(regs))
4188 @@ -1181,10 +1181,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
4189 newsp = stack[0];
4190 ip = stack[STACK_FRAME_LR_SAVE];
4191 if (!firstframe || ip != lr) {
4192 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
4193 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
4194 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
4195 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
4196 - printk(" (%pS)",
4197 + printk(" (%pA)",
4198 (void *)current->ret_stack[curr_frame].ret);
4199 curr_frame--;
4200 }
4201 @@ -1204,7 +1204,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
4202 struct pt_regs *regs = (struct pt_regs *)
4203 (sp + STACK_FRAME_OVERHEAD);
4204 lr = regs->link;
4205 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
4206 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
4207 regs->trap, (void *)regs->nip, (void *)lr);
4208 firstframe = 1;
4209 }
4210 @@ -1279,58 +1279,3 @@ void thread_info_cache_init(void)
4211 }
4212
4213 #endif /* THREAD_SHIFT < PAGE_SHIFT */
4214 -
4215 -unsigned long arch_align_stack(unsigned long sp)
4216 -{
4217 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
4218 - sp -= get_random_int() & ~PAGE_MASK;
4219 - return sp & ~0xf;
4220 -}
4221 -
4222 -static inline unsigned long brk_rnd(void)
4223 -{
4224 - unsigned long rnd = 0;
4225 -
4226 - /* 8MB for 32bit, 1GB for 64bit */
4227 - if (is_32bit_task())
4228 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
4229 - else
4230 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
4231 -
4232 - return rnd << PAGE_SHIFT;
4233 -}
4234 -
4235 -unsigned long arch_randomize_brk(struct mm_struct *mm)
4236 -{
4237 - unsigned long base = mm->brk;
4238 - unsigned long ret;
4239 -
4240 -#ifdef CONFIG_PPC_STD_MMU_64
4241 - /*
4242 - * If we are using 1TB segments and we are allowed to randomise
4243 - * the heap, we can put it above 1TB so it is backed by a 1TB
4244 - * segment. Otherwise the heap will be in the bottom 1TB
4245 - * which always uses 256MB segments and this may result in a
4246 - * performance penalty.
4247 - */
4248 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
4249 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
4250 -#endif
4251 -
4252 - ret = PAGE_ALIGN(base + brk_rnd());
4253 -
4254 - if (ret < mm->brk)
4255 - return mm->brk;
4256 -
4257 - return ret;
4258 -}
4259 -
4260 -unsigned long randomize_et_dyn(unsigned long base)
4261 -{
4262 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
4263 -
4264 - if (ret < base)
4265 - return base;
4266 -
4267 - return ret;
4268 -}
4269 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
4270 index 5b43325..94a5bb4 100644
4271 --- a/arch/powerpc/kernel/ptrace.c
4272 +++ b/arch/powerpc/kernel/ptrace.c
4273 @@ -1702,6 +1702,10 @@ long arch_ptrace(struct task_struct *child, long request,
4274 return ret;
4275 }
4276
4277 +#ifdef CONFIG_GRKERNSEC_SETXID
4278 +extern void gr_delayed_cred_worker(void);
4279 +#endif
4280 +
4281 /*
4282 * We must return the syscall number to actually look up in the table.
4283 * This can be -1L to skip running any syscall at all.
4284 @@ -1712,6 +1716,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
4285
4286 secure_computing(regs->gpr[0]);
4287
4288 +#ifdef CONFIG_GRKERNSEC_SETXID
4289 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
4290 + gr_delayed_cred_worker();
4291 +#endif
4292 +
4293 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
4294 tracehook_report_syscall_entry(regs))
4295 /*
4296 @@ -1746,6 +1755,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
4297 {
4298 int step;
4299
4300 +#ifdef CONFIG_GRKERNSEC_SETXID
4301 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
4302 + gr_delayed_cred_worker();
4303 +#endif
4304 +
4305 audit_syscall_exit(regs);
4306
4307 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
4308 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
4309 index 836a5a1..27289a3 100644
4310 --- a/arch/powerpc/kernel/signal_32.c
4311 +++ b/arch/powerpc/kernel/signal_32.c
4312 @@ -859,7 +859,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
4313 /* Save user registers on the stack */
4314 frame = &rt_sf->uc.uc_mcontext;
4315 addr = frame;
4316 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
4317 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
4318 if (save_user_regs(regs, frame, 0, 1))
4319 goto badframe;
4320 regs->link = current->mm->context.vdso_base + vdso32_rt_sigtramp;
4321 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
4322 index a50b5ec..547078a 100644
4323 --- a/arch/powerpc/kernel/signal_64.c
4324 +++ b/arch/powerpc/kernel/signal_64.c
4325 @@ -429,7 +429,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
4326 current->thread.fpscr.val = 0;
4327
4328 /* Set up to return from userspace. */
4329 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
4330 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
4331 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
4332 } else {
4333 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
4334 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
4335 index c091527..5592625 100644
4336 --- a/arch/powerpc/kernel/traps.c
4337 +++ b/arch/powerpc/kernel/traps.c
4338 @@ -131,6 +131,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
4339 return flags;
4340 }
4341
4342 +extern void gr_handle_kernel_exploit(void);
4343 +
4344 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
4345 int signr)
4346 {
4347 @@ -178,6 +180,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
4348 panic("Fatal exception in interrupt");
4349 if (panic_on_oops)
4350 panic("Fatal exception");
4351 +
4352 + gr_handle_kernel_exploit();
4353 +
4354 do_exit(signr);
4355 }
4356
4357 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
4358 index 7d14bb6..1305601 100644
4359 --- a/arch/powerpc/kernel/vdso.c
4360 +++ b/arch/powerpc/kernel/vdso.c
4361 @@ -35,6 +35,7 @@
4362 #include <asm/firmware.h>
4363 #include <asm/vdso.h>
4364 #include <asm/vdso_datapage.h>
4365 +#include <asm/mman.h>
4366
4367 #include "setup.h"
4368
4369 @@ -219,7 +220,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
4370 vdso_base = VDSO32_MBASE;
4371 #endif
4372
4373 - current->mm->context.vdso_base = 0;
4374 + current->mm->context.vdso_base = ~0UL;
4375
4376 /* vDSO has a problem and was disabled, just don't "enable" it for the
4377 * process
4378 @@ -239,7 +240,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
4379 vdso_base = get_unmapped_area(NULL, vdso_base,
4380 (vdso_pages << PAGE_SHIFT) +
4381 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
4382 - 0, 0);
4383 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
4384 if (IS_ERR_VALUE(vdso_base)) {
4385 rc = vdso_base;
4386 goto fail_mmapsem;
4387 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
4388 index 5eea6f3..5d10396 100644
4389 --- a/arch/powerpc/lib/usercopy_64.c
4390 +++ b/arch/powerpc/lib/usercopy_64.c
4391 @@ -9,22 +9,6 @@
4392 #include <linux/module.h>
4393 #include <asm/uaccess.h>
4394
4395 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
4396 -{
4397 - if (likely(access_ok(VERIFY_READ, from, n)))
4398 - n = __copy_from_user(to, from, n);
4399 - else
4400 - memset(to, 0, n);
4401 - return n;
4402 -}
4403 -
4404 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
4405 -{
4406 - if (likely(access_ok(VERIFY_WRITE, to, n)))
4407 - n = __copy_to_user(to, from, n);
4408 - return n;
4409 -}
4410 -
4411 unsigned long copy_in_user(void __user *to, const void __user *from,
4412 unsigned long n)
4413 {
4414 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
4415 return n;
4416 }
4417
4418 -EXPORT_SYMBOL(copy_from_user);
4419 -EXPORT_SYMBOL(copy_to_user);
4420 EXPORT_SYMBOL(copy_in_user);
4421
4422 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
4423 index 2f0d1b0..36fb5cc 100644
4424 --- a/arch/powerpc/mm/fault.c
4425 +++ b/arch/powerpc/mm/fault.c
4426 @@ -32,6 +32,10 @@
4427 #include <linux/perf_event.h>
4428 #include <linux/magic.h>
4429 #include <linux/ratelimit.h>
4430 +#include <linux/slab.h>
4431 +#include <linux/pagemap.h>
4432 +#include <linux/compiler.h>
4433 +#include <linux/unistd.h>
4434
4435 #include <asm/firmware.h>
4436 #include <asm/page.h>
4437 @@ -43,6 +47,7 @@
4438 #include <asm/tlbflush.h>
4439 #include <asm/siginfo.h>
4440 #include <mm/mmu_decl.h>
4441 +#include <asm/ptrace.h>
4442
4443 #include "icswx.h"
4444
4445 @@ -68,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
4446 }
4447 #endif
4448
4449 +#ifdef CONFIG_PAX_PAGEEXEC
4450 +/*
4451 + * PaX: decide what to do with offenders (regs->nip = fault address)
4452 + *
4453 + * returns 1 when task should be killed
4454 + */
4455 +static int pax_handle_fetch_fault(struct pt_regs *regs)
4456 +{
4457 + return 1;
4458 +}
4459 +
4460 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4461 +{
4462 + unsigned long i;
4463 +
4464 + printk(KERN_ERR "PAX: bytes at PC: ");
4465 + for (i = 0; i < 5; i++) {
4466 + unsigned int c;
4467 + if (get_user(c, (unsigned int __user *)pc+i))
4468 + printk(KERN_CONT "???????? ");
4469 + else
4470 + printk(KERN_CONT "%08x ", c);
4471 + }
4472 + printk("\n");
4473 +}
4474 +#endif
4475 +
4476 /*
4477 * Check whether the instruction at regs->nip is a store using
4478 * an update addressing form which will update r1.
4479 @@ -138,7 +170,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
4480 * indicate errors in DSISR but can validly be set in SRR1.
4481 */
4482 if (trap == 0x400)
4483 - error_code &= 0x48200000;
4484 + error_code &= 0x58200000;
4485 else
4486 is_write = error_code & DSISR_ISSTORE;
4487 #else
4488 @@ -276,7 +308,7 @@ good_area:
4489 * "undefined". Of those that can be set, this is the only
4490 * one which seems bad.
4491 */
4492 - if (error_code & 0x10000000)
4493 + if (error_code & DSISR_GUARDED)
4494 /* Guarded storage error. */
4495 goto bad_area;
4496 #endif /* CONFIG_8xx */
4497 @@ -291,7 +323,7 @@ good_area:
4498 * processors use the same I/D cache coherency mechanism
4499 * as embedded.
4500 */
4501 - if (error_code & DSISR_PROTFAULT)
4502 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
4503 goto bad_area;
4504 #endif /* CONFIG_PPC_STD_MMU */
4505
4506 @@ -360,6 +392,23 @@ bad_area:
4507 bad_area_nosemaphore:
4508 /* User mode accesses cause a SIGSEGV */
4509 if (user_mode(regs)) {
4510 +
4511 +#ifdef CONFIG_PAX_PAGEEXEC
4512 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4513 +#ifdef CONFIG_PPC_STD_MMU
4514 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
4515 +#else
4516 + if (is_exec && regs->nip == address) {
4517 +#endif
4518 + switch (pax_handle_fetch_fault(regs)) {
4519 + }
4520 +
4521 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
4522 + do_group_exit(SIGKILL);
4523 + }
4524 + }
4525 +#endif
4526 +
4527 _exception(SIGSEGV, regs, code, address);
4528 return 0;
4529 }
4530 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
4531 index 67a42ed..1c7210c 100644
4532 --- a/arch/powerpc/mm/mmap_64.c
4533 +++ b/arch/powerpc/mm/mmap_64.c
4534 @@ -91,10 +91,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4535 */
4536 if (mmap_is_legacy()) {
4537 mm->mmap_base = TASK_UNMAPPED_BASE;
4538 +
4539 +#ifdef CONFIG_PAX_RANDMMAP
4540 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4541 + mm->mmap_base += mm->delta_mmap;
4542 +#endif
4543 +
4544 mm->get_unmapped_area = arch_get_unmapped_area;
4545 mm->unmap_area = arch_unmap_area;
4546 } else {
4547 mm->mmap_base = mmap_base();
4548 +
4549 +#ifdef CONFIG_PAX_RANDMMAP
4550 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4551 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4552 +#endif
4553 +
4554 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4555 mm->unmap_area = arch_unmap_area_topdown;
4556 }
4557 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
4558 index 73709f7..6b90313 100644
4559 --- a/arch/powerpc/mm/slice.c
4560 +++ b/arch/powerpc/mm/slice.c
4561 @@ -98,7 +98,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
4562 if ((mm->task_size - len) < addr)
4563 return 0;
4564 vma = find_vma(mm, addr);
4565 - return (!vma || (addr + len) <= vma->vm_start);
4566 + return check_heap_stack_gap(vma, addr, len);
4567 }
4568
4569 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
4570 @@ -256,7 +256,7 @@ full_search:
4571 addr = _ALIGN_UP(addr + 1, 1ul << SLICE_HIGH_SHIFT);
4572 continue;
4573 }
4574 - if (!vma || addr + len <= vma->vm_start) {
4575 + if (check_heap_stack_gap(vma, addr, len)) {
4576 /*
4577 * Remember the place where we stopped the search:
4578 */
4579 @@ -313,10 +313,14 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
4580 }
4581 }
4582
4583 - addr = mm->mmap_base;
4584 - while (addr > len) {
4585 + if (mm->mmap_base < len)
4586 + addr = -ENOMEM;
4587 + else
4588 + addr = mm->mmap_base - len;
4589 +
4590 + while (!IS_ERR_VALUE(addr)) {
4591 /* Go down by chunk size */
4592 - addr = _ALIGN_DOWN(addr - len, 1ul << pshift);
4593 + addr = _ALIGN_DOWN(addr, 1ul << pshift);
4594
4595 /* Check for hit with different page size */
4596 mask = slice_range_to_mask(addr, len);
4597 @@ -336,7 +340,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
4598 * return with success:
4599 */
4600 vma = find_vma(mm, addr);
4601 - if (!vma || (addr + len) <= vma->vm_start) {
4602 + if (check_heap_stack_gap(vma, addr, len)) {
4603 /* remember the address as a hint for next time */
4604 if (use_cache)
4605 mm->free_area_cache = addr;
4606 @@ -348,7 +352,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
4607 mm->cached_hole_size = vma->vm_start - addr;
4608
4609 /* try just below the current vma->vm_start */
4610 - addr = vma->vm_start;
4611 + addr = skip_heap_stack_gap(vma, len);
4612 }
4613
4614 /*
4615 @@ -426,6 +430,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
4616 if (fixed && addr > (mm->task_size - len))
4617 return -EINVAL;
4618
4619 +#ifdef CONFIG_PAX_RANDMMAP
4620 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
4621 + addr = 0;
4622 +#endif
4623 +
4624 /* If hint, make sure it matches our alignment restrictions */
4625 if (!fixed && addr) {
4626 addr = _ALIGN_UP(addr, 1ul << pshift);
4627 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
4628 index 8517d2a..d2738d4 100644
4629 --- a/arch/s390/include/asm/atomic.h
4630 +++ b/arch/s390/include/asm/atomic.h
4631 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
4632 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
4633 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
4634
4635 +#define atomic64_read_unchecked(v) atomic64_read(v)
4636 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4637 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4638 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4639 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4640 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4641 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4642 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4643 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4644 +
4645 #define smp_mb__before_atomic_dec() smp_mb()
4646 #define smp_mb__after_atomic_dec() smp_mb()
4647 #define smp_mb__before_atomic_inc() smp_mb()
4648 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
4649 index 2a30d5a..5e5586f 100644
4650 --- a/arch/s390/include/asm/cache.h
4651 +++ b/arch/s390/include/asm/cache.h
4652 @@ -11,8 +11,10 @@
4653 #ifndef __ARCH_S390_CACHE_H
4654 #define __ARCH_S390_CACHE_H
4655
4656 -#define L1_CACHE_BYTES 256
4657 +#include <linux/const.h>
4658 +
4659 #define L1_CACHE_SHIFT 8
4660 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4661 #define NET_SKB_PAD 32
4662
4663 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4664 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
4665 index 547f1a6..0b22b53 100644
4666 --- a/arch/s390/include/asm/elf.h
4667 +++ b/arch/s390/include/asm/elf.h
4668 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
4669 the loader. We need to make sure that it is out of the way of the program
4670 that it will "exec", and that there is sufficient room for the brk. */
4671
4672 -extern unsigned long randomize_et_dyn(unsigned long base);
4673 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
4674 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
4675 +
4676 +#ifdef CONFIG_PAX_ASLR
4677 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
4678 +
4679 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
4680 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
4681 +#endif
4682
4683 /* This yields a mask that user programs can use to figure out what
4684 instruction set this CPU supports. */
4685 @@ -211,7 +217,4 @@ struct linux_binprm;
4686 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
4687 int arch_setup_additional_pages(struct linux_binprm *, int);
4688
4689 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
4690 -#define arch_randomize_brk arch_randomize_brk
4691 -
4692 #endif
4693 diff --git a/arch/s390/include/asm/system.h b/arch/s390/include/asm/system.h
4694 index d73cc6b..1a296ad 100644
4695 --- a/arch/s390/include/asm/system.h
4696 +++ b/arch/s390/include/asm/system.h
4697 @@ -260,7 +260,7 @@ extern void (*_machine_restart)(char *command);
4698 extern void (*_machine_halt)(void);
4699 extern void (*_machine_power_off)(void);
4700
4701 -extern unsigned long arch_align_stack(unsigned long sp);
4702 +#define arch_align_stack(x) ((x) & ~0xfUL)
4703
4704 static inline int tprot(unsigned long addr)
4705 {
4706 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
4707 index 2b23885..e136e31 100644
4708 --- a/arch/s390/include/asm/uaccess.h
4709 +++ b/arch/s390/include/asm/uaccess.h
4710 @@ -235,6 +235,10 @@ static inline unsigned long __must_check
4711 copy_to_user(void __user *to, const void *from, unsigned long n)
4712 {
4713 might_fault();
4714 +
4715 + if ((long)n < 0)
4716 + return n;
4717 +
4718 if (access_ok(VERIFY_WRITE, to, n))
4719 n = __copy_to_user(to, from, n);
4720 return n;
4721 @@ -260,6 +264,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
4722 static inline unsigned long __must_check
4723 __copy_from_user(void *to, const void __user *from, unsigned long n)
4724 {
4725 + if ((long)n < 0)
4726 + return n;
4727 +
4728 if (__builtin_constant_p(n) && (n <= 256))
4729 return uaccess.copy_from_user_small(n, from, to);
4730 else
4731 @@ -294,6 +301,10 @@ copy_from_user(void *to, const void __user *from, unsigned long n)
4732 unsigned int sz = __compiletime_object_size(to);
4733
4734 might_fault();
4735 +
4736 + if ((long)n < 0)
4737 + return n;
4738 +
4739 if (unlikely(sz != -1 && sz < n)) {
4740 copy_from_user_overflow();
4741 return n;
4742 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
4743 index dfcb343..eda788a 100644
4744 --- a/arch/s390/kernel/module.c
4745 +++ b/arch/s390/kernel/module.c
4746 @@ -161,11 +161,11 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
4747
4748 /* Increase core size by size of got & plt and set start
4749 offsets for got and plt. */
4750 - me->core_size = ALIGN(me->core_size, 4);
4751 - me->arch.got_offset = me->core_size;
4752 - me->core_size += me->arch.got_size;
4753 - me->arch.plt_offset = me->core_size;
4754 - me->core_size += me->arch.plt_size;
4755 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
4756 + me->arch.got_offset = me->core_size_rw;
4757 + me->core_size_rw += me->arch.got_size;
4758 + me->arch.plt_offset = me->core_size_rx;
4759 + me->core_size_rx += me->arch.plt_size;
4760 return 0;
4761 }
4762
4763 @@ -242,7 +242,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
4764 if (info->got_initialized == 0) {
4765 Elf_Addr *gotent;
4766
4767 - gotent = me->module_core + me->arch.got_offset +
4768 + gotent = me->module_core_rw + me->arch.got_offset +
4769 info->got_offset;
4770 *gotent = val;
4771 info->got_initialized = 1;
4772 @@ -266,7 +266,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
4773 else if (r_type == R_390_GOTENT ||
4774 r_type == R_390_GOTPLTENT)
4775 *(unsigned int *) loc =
4776 - (val + (Elf_Addr) me->module_core - loc) >> 1;
4777 + (val + (Elf_Addr) me->module_core_rw - loc) >> 1;
4778 else if (r_type == R_390_GOT64 ||
4779 r_type == R_390_GOTPLT64)
4780 *(unsigned long *) loc = val;
4781 @@ -280,7 +280,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
4782 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
4783 if (info->plt_initialized == 0) {
4784 unsigned int *ip;
4785 - ip = me->module_core + me->arch.plt_offset +
4786 + ip = me->module_core_rx + me->arch.plt_offset +
4787 info->plt_offset;
4788 #ifndef CONFIG_64BIT
4789 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
4790 @@ -305,7 +305,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
4791 val - loc + 0xffffUL < 0x1ffffeUL) ||
4792 (r_type == R_390_PLT32DBL &&
4793 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
4794 - val = (Elf_Addr) me->module_core +
4795 + val = (Elf_Addr) me->module_core_rx +
4796 me->arch.plt_offset +
4797 info->plt_offset;
4798 val += rela->r_addend - loc;
4799 @@ -327,7 +327,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
4800 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
4801 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
4802 val = val + rela->r_addend -
4803 - ((Elf_Addr) me->module_core + me->arch.got_offset);
4804 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
4805 if (r_type == R_390_GOTOFF16)
4806 *(unsigned short *) loc = val;
4807 else if (r_type == R_390_GOTOFF32)
4808 @@ -337,7 +337,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
4809 break;
4810 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
4811 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
4812 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
4813 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
4814 rela->r_addend - loc;
4815 if (r_type == R_390_GOTPC)
4816 *(unsigned int *) loc = val;
4817 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
4818 index e795933..b32563c 100644
4819 --- a/arch/s390/kernel/process.c
4820 +++ b/arch/s390/kernel/process.c
4821 @@ -323,39 +323,3 @@ unsigned long get_wchan(struct task_struct *p)
4822 }
4823 return 0;
4824 }
4825 -
4826 -unsigned long arch_align_stack(unsigned long sp)
4827 -{
4828 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
4829 - sp -= get_random_int() & ~PAGE_MASK;
4830 - return sp & ~0xf;
4831 -}
4832 -
4833 -static inline unsigned long brk_rnd(void)
4834 -{
4835 - /* 8MB for 32bit, 1GB for 64bit */
4836 - if (is_32bit_task())
4837 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
4838 - else
4839 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
4840 -}
4841 -
4842 -unsigned long arch_randomize_brk(struct mm_struct *mm)
4843 -{
4844 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
4845 -
4846 - if (ret < mm->brk)
4847 - return mm->brk;
4848 - return ret;
4849 -}
4850 -
4851 -unsigned long randomize_et_dyn(unsigned long base)
4852 -{
4853 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
4854 -
4855 - if (!(current->flags & PF_RANDOMIZE))
4856 - return base;
4857 - if (ret < base)
4858 - return base;
4859 - return ret;
4860 -}
4861 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
4862 index a0155c0..34cc491 100644
4863 --- a/arch/s390/mm/mmap.c
4864 +++ b/arch/s390/mm/mmap.c
4865 @@ -92,10 +92,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4866 */
4867 if (mmap_is_legacy()) {
4868 mm->mmap_base = TASK_UNMAPPED_BASE;
4869 +
4870 +#ifdef CONFIG_PAX_RANDMMAP
4871 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4872 + mm->mmap_base += mm->delta_mmap;
4873 +#endif
4874 +
4875 mm->get_unmapped_area = arch_get_unmapped_area;
4876 mm->unmap_area = arch_unmap_area;
4877 } else {
4878 mm->mmap_base = mmap_base();
4879 +
4880 +#ifdef CONFIG_PAX_RANDMMAP
4881 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4882 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4883 +#endif
4884 +
4885 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4886 mm->unmap_area = arch_unmap_area_topdown;
4887 }
4888 @@ -167,10 +179,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4889 */
4890 if (mmap_is_legacy()) {
4891 mm->mmap_base = TASK_UNMAPPED_BASE;
4892 +
4893 +#ifdef CONFIG_PAX_RANDMMAP
4894 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4895 + mm->mmap_base += mm->delta_mmap;
4896 +#endif
4897 +
4898 mm->get_unmapped_area = s390_get_unmapped_area;
4899 mm->unmap_area = arch_unmap_area;
4900 } else {
4901 mm->mmap_base = mmap_base();
4902 +
4903 +#ifdef CONFIG_PAX_RANDMMAP
4904 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4905 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4906 +#endif
4907 +
4908 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
4909 mm->unmap_area = arch_unmap_area_topdown;
4910 }
4911 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
4912 index ae3d59f..f65f075 100644
4913 --- a/arch/score/include/asm/cache.h
4914 +++ b/arch/score/include/asm/cache.h
4915 @@ -1,7 +1,9 @@
4916 #ifndef _ASM_SCORE_CACHE_H
4917 #define _ASM_SCORE_CACHE_H
4918
4919 +#include <linux/const.h>
4920 +
4921 #define L1_CACHE_SHIFT 4
4922 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4923 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4924
4925 #endif /* _ASM_SCORE_CACHE_H */
4926 diff --git a/arch/score/include/asm/system.h b/arch/score/include/asm/system.h
4927 index 589d5c7..669e274 100644
4928 --- a/arch/score/include/asm/system.h
4929 +++ b/arch/score/include/asm/system.h
4930 @@ -17,7 +17,7 @@ do { \
4931 #define finish_arch_switch(prev) do {} while (0)
4932
4933 typedef void (*vi_handler_t)(void);
4934 -extern unsigned long arch_align_stack(unsigned long sp);
4935 +#define arch_align_stack(x) (x)
4936
4937 #define mb() barrier()
4938 #define rmb() barrier()
4939 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
4940 index 25d0803..d6c8e36 100644
4941 --- a/arch/score/kernel/process.c
4942 +++ b/arch/score/kernel/process.c
4943 @@ -161,8 +161,3 @@ unsigned long get_wchan(struct task_struct *task)
4944
4945 return task_pt_regs(task)->cp0_epc;
4946 }
4947 -
4948 -unsigned long arch_align_stack(unsigned long sp)
4949 -{
4950 - return sp;
4951 -}
4952 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
4953 index ef9e555..331bd29 100644
4954 --- a/arch/sh/include/asm/cache.h
4955 +++ b/arch/sh/include/asm/cache.h
4956 @@ -9,10 +9,11 @@
4957 #define __ASM_SH_CACHE_H
4958 #ifdef __KERNEL__
4959
4960 +#include <linux/const.h>
4961 #include <linux/init.h>
4962 #include <cpu/cache.h>
4963
4964 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4965 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4966
4967 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4968
4969 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
4970 index afeb710..d1d1289 100644
4971 --- a/arch/sh/mm/mmap.c
4972 +++ b/arch/sh/mm/mmap.c
4973 @@ -74,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
4974 addr = PAGE_ALIGN(addr);
4975
4976 vma = find_vma(mm, addr);
4977 - if (TASK_SIZE - len >= addr &&
4978 - (!vma || addr + len <= vma->vm_start))
4979 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len))
4980 return addr;
4981 }
4982
4983 @@ -106,7 +105,7 @@ full_search:
4984 }
4985 return -ENOMEM;
4986 }
4987 - if (likely(!vma || addr + len <= vma->vm_start)) {
4988 + if (likely(check_heap_stack_gap(vma, addr, len))) {
4989 /*
4990 * Remember the place where we stopped the search:
4991 */
4992 @@ -157,8 +156,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4993 addr = PAGE_ALIGN(addr);
4994
4995 vma = find_vma(mm, addr);
4996 - if (TASK_SIZE - len >= addr &&
4997 - (!vma || addr + len <= vma->vm_start))
4998 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len))
4999 return addr;
5000 }
5001
5002 @@ -179,7 +177,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
5003 /* make sure it can fit in the remaining address space */
5004 if (likely(addr > len)) {
5005 vma = find_vma(mm, addr-len);
5006 - if (!vma || addr <= vma->vm_start) {
5007 + if (check_heap_stack_gap(vma, addr - len, len)) {
5008 /* remember the address as a hint for next time */
5009 return (mm->free_area_cache = addr-len);
5010 }
5011 @@ -188,18 +186,18 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
5012 if (unlikely(mm->mmap_base < len))
5013 goto bottomup;
5014
5015 - addr = mm->mmap_base-len;
5016 - if (do_colour_align)
5017 - addr = COLOUR_ALIGN_DOWN(addr, pgoff);
5018 + addr = mm->mmap_base - len;
5019
5020 do {
5021 + if (do_colour_align)
5022 + addr = COLOUR_ALIGN_DOWN(addr, pgoff);
5023 /*
5024 * Lookup failure means no vma is above this address,
5025 * else if new region fits below vma->vm_start,
5026 * return with success:
5027 */
5028 vma = find_vma(mm, addr);
5029 - if (likely(!vma || addr+len <= vma->vm_start)) {
5030 + if (likely(check_heap_stack_gap(vma, addr, len))) {
5031 /* remember the address as a hint for next time */
5032 return (mm->free_area_cache = addr);
5033 }
5034 @@ -209,10 +207,8 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
5035 mm->cached_hole_size = vma->vm_start - addr;
5036
5037 /* try just below the current vma->vm_start */
5038 - addr = vma->vm_start-len;
5039 - if (do_colour_align)
5040 - addr = COLOUR_ALIGN_DOWN(addr, pgoff);
5041 - } while (likely(len < vma->vm_start));
5042 + addr = skip_heap_stack_gap(vma, len);
5043 + } while (!IS_ERR_VALUE(addr));
5044
5045 bottomup:
5046 /*
5047 diff --git a/arch/sparc/Makefile b/arch/sparc/Makefile
5048 index eddcfb3..b117d90 100644
5049 --- a/arch/sparc/Makefile
5050 +++ b/arch/sparc/Makefile
5051 @@ -75,7 +75,7 @@ drivers-$(CONFIG_OPROFILE) += arch/sparc/oprofile/
5052 # Export what is needed by arch/sparc/boot/Makefile
5053 export VMLINUX_INIT VMLINUX_MAIN
5054 VMLINUX_INIT := $(head-y) $(init-y)
5055 -VMLINUX_MAIN := $(core-y) kernel/ mm/ fs/ ipc/ security/ crypto/ block/
5056 +VMLINUX_MAIN := $(core-y) kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
5057 VMLINUX_MAIN += $(patsubst %/, %/lib.a, $(libs-y)) $(libs-y)
5058 VMLINUX_MAIN += $(drivers-y) $(net-y)
5059
5060 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
5061 index 9f421df..b81fc12 100644
5062 --- a/arch/sparc/include/asm/atomic_64.h
5063 +++ b/arch/sparc/include/asm/atomic_64.h
5064 @@ -14,18 +14,40 @@
5065 #define ATOMIC64_INIT(i) { (i) }
5066
5067 #define atomic_read(v) (*(volatile int *)&(v)->counter)
5068 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
5069 +{
5070 + return v->counter;
5071 +}
5072 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
5073 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
5074 +{
5075 + return v->counter;
5076 +}
5077
5078 #define atomic_set(v, i) (((v)->counter) = i)
5079 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
5080 +{
5081 + v->counter = i;
5082 +}
5083 #define atomic64_set(v, i) (((v)->counter) = i)
5084 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
5085 +{
5086 + v->counter = i;
5087 +}
5088
5089 extern void atomic_add(int, atomic_t *);
5090 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
5091 extern void atomic64_add(long, atomic64_t *);
5092 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
5093 extern void atomic_sub(int, atomic_t *);
5094 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
5095 extern void atomic64_sub(long, atomic64_t *);
5096 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
5097
5098 extern int atomic_add_ret(int, atomic_t *);
5099 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
5100 extern long atomic64_add_ret(long, atomic64_t *);
5101 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
5102 extern int atomic_sub_ret(int, atomic_t *);
5103 extern long atomic64_sub_ret(long, atomic64_t *);
5104
5105 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
5106 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
5107
5108 #define atomic_inc_return(v) atomic_add_ret(1, v)
5109 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
5110 +{
5111 + return atomic_add_ret_unchecked(1, v);
5112 +}
5113 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
5114 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
5115 +{
5116 + return atomic64_add_ret_unchecked(1, v);
5117 +}
5118
5119 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
5120 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
5121
5122 #define atomic_add_return(i, v) atomic_add_ret(i, v)
5123 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
5124 +{
5125 + return atomic_add_ret_unchecked(i, v);
5126 +}
5127 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
5128 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
5129 +{
5130 + return atomic64_add_ret_unchecked(i, v);
5131 +}
5132
5133 /*
5134 * atomic_inc_and_test - increment and test
5135 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
5136 * other cases.
5137 */
5138 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
5139 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
5140 +{
5141 + return atomic_inc_return_unchecked(v) == 0;
5142 +}
5143 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
5144
5145 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
5146 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
5147 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
5148
5149 #define atomic_inc(v) atomic_add(1, v)
5150 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
5151 +{
5152 + atomic_add_unchecked(1, v);
5153 +}
5154 #define atomic64_inc(v) atomic64_add(1, v)
5155 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
5156 +{
5157 + atomic64_add_unchecked(1, v);
5158 +}
5159
5160 #define atomic_dec(v) atomic_sub(1, v)
5161 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
5162 +{
5163 + atomic_sub_unchecked(1, v);
5164 +}
5165 #define atomic64_dec(v) atomic64_sub(1, v)
5166 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
5167 +{
5168 + atomic64_sub_unchecked(1, v);
5169 +}
5170
5171 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
5172 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
5173
5174 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
5175 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
5176 +{
5177 + return cmpxchg(&v->counter, old, new);
5178 +}
5179 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
5180 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
5181 +{
5182 + return xchg(&v->counter, new);
5183 +}
5184
5185 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
5186 {
5187 - int c, old;
5188 + int c, old, new;
5189 c = atomic_read(v);
5190 for (;;) {
5191 - if (unlikely(c == (u)))
5192 + if (unlikely(c == u))
5193 break;
5194 - old = atomic_cmpxchg((v), c, c + (a));
5195 +
5196 + asm volatile("addcc %2, %0, %0\n"
5197 +
5198 +#ifdef CONFIG_PAX_REFCOUNT
5199 + "tvs %%icc, 6\n"
5200 +#endif
5201 +
5202 + : "=r" (new)
5203 + : "0" (c), "ir" (a)
5204 + : "cc");
5205 +
5206 + old = atomic_cmpxchg(v, c, new);
5207 if (likely(old == c))
5208 break;
5209 c = old;
5210 @@ -89,20 +166,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
5211 #define atomic64_cmpxchg(v, o, n) \
5212 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
5213 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
5214 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
5215 +{
5216 + return xchg(&v->counter, new);
5217 +}
5218
5219 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
5220 {
5221 - long c, old;
5222 + long c, old, new;
5223 c = atomic64_read(v);
5224 for (;;) {
5225 - if (unlikely(c == (u)))
5226 + if (unlikely(c == u))
5227 break;
5228 - old = atomic64_cmpxchg((v), c, c + (a));
5229 +
5230 + asm volatile("addcc %2, %0, %0\n"
5231 +
5232 +#ifdef CONFIG_PAX_REFCOUNT
5233 + "tvs %%xcc, 6\n"
5234 +#endif
5235 +
5236 + : "=r" (new)
5237 + : "0" (c), "ir" (a)
5238 + : "cc");
5239 +
5240 + old = atomic64_cmpxchg(v, c, new);
5241 if (likely(old == c))
5242 break;
5243 c = old;
5244 }
5245 - return c != (u);
5246 + return c != u;
5247 }
5248
5249 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
5250 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
5251 index 69358b5..9d0d492 100644
5252 --- a/arch/sparc/include/asm/cache.h
5253 +++ b/arch/sparc/include/asm/cache.h
5254 @@ -7,10 +7,12 @@
5255 #ifndef _SPARC_CACHE_H
5256 #define _SPARC_CACHE_H
5257
5258 +#include <linux/const.h>
5259 +
5260 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
5261
5262 #define L1_CACHE_SHIFT 5
5263 -#define L1_CACHE_BYTES 32
5264 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5265
5266 #ifdef CONFIG_SPARC32
5267 #define SMP_CACHE_BYTES_SHIFT 5
5268 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
5269 index 4269ca6..e3da77f 100644
5270 --- a/arch/sparc/include/asm/elf_32.h
5271 +++ b/arch/sparc/include/asm/elf_32.h
5272 @@ -114,6 +114,13 @@ typedef struct {
5273
5274 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
5275
5276 +#ifdef CONFIG_PAX_ASLR
5277 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
5278 +
5279 +#define PAX_DELTA_MMAP_LEN 16
5280 +#define PAX_DELTA_STACK_LEN 16
5281 +#endif
5282 +
5283 /* This yields a mask that user programs can use to figure out what
5284 instruction set this cpu supports. This can NOT be done in userspace
5285 on Sparc. */
5286 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
5287 index 7df8b7f..4946269 100644
5288 --- a/arch/sparc/include/asm/elf_64.h
5289 +++ b/arch/sparc/include/asm/elf_64.h
5290 @@ -180,6 +180,13 @@ typedef struct {
5291 #define ELF_ET_DYN_BASE 0x0000010000000000UL
5292 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
5293
5294 +#ifdef CONFIG_PAX_ASLR
5295 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
5296 +
5297 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
5298 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
5299 +#endif
5300 +
5301 extern unsigned long sparc64_elf_hwcap;
5302 #define ELF_HWCAP sparc64_elf_hwcap
5303
5304 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
5305 index ca2b344..c6084f89 100644
5306 --- a/arch/sparc/include/asm/pgalloc_32.h
5307 +++ b/arch/sparc/include/asm/pgalloc_32.h
5308 @@ -37,6 +37,7 @@ BTFIXUPDEF_CALL(void, free_pgd_fast, pgd_t *)
5309 BTFIXUPDEF_CALL(void, pgd_set, pgd_t *, pmd_t *)
5310 #define pgd_set(pgdp,pmdp) BTFIXUP_CALL(pgd_set)(pgdp,pmdp)
5311 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
5312 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
5313
5314 BTFIXUPDEF_CALL(pmd_t *, pmd_alloc_one, struct mm_struct *, unsigned long)
5315 #define pmd_alloc_one(mm, address) BTFIXUP_CALL(pmd_alloc_one)(mm, address)
5316 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
5317 index 40b2d7a..22a665b 100644
5318 --- a/arch/sparc/include/asm/pgalloc_64.h
5319 +++ b/arch/sparc/include/asm/pgalloc_64.h
5320 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
5321 }
5322
5323 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
5324 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
5325
5326 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
5327 {
5328 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
5329 index a790cc6..091ed94 100644
5330 --- a/arch/sparc/include/asm/pgtable_32.h
5331 +++ b/arch/sparc/include/asm/pgtable_32.h
5332 @@ -45,6 +45,13 @@ BTFIXUPDEF_SIMM13(user_ptrs_per_pgd)
5333 BTFIXUPDEF_INT(page_none)
5334 BTFIXUPDEF_INT(page_copy)
5335 BTFIXUPDEF_INT(page_readonly)
5336 +
5337 +#ifdef CONFIG_PAX_PAGEEXEC
5338 +BTFIXUPDEF_INT(page_shared_noexec)
5339 +BTFIXUPDEF_INT(page_copy_noexec)
5340 +BTFIXUPDEF_INT(page_readonly_noexec)
5341 +#endif
5342 +
5343 BTFIXUPDEF_INT(page_kernel)
5344
5345 #define PMD_SHIFT SUN4C_PMD_SHIFT
5346 @@ -66,6 +73,16 @@ extern pgprot_t PAGE_SHARED;
5347 #define PAGE_COPY __pgprot(BTFIXUP_INT(page_copy))
5348 #define PAGE_READONLY __pgprot(BTFIXUP_INT(page_readonly))
5349
5350 +#ifdef CONFIG_PAX_PAGEEXEC
5351 +extern pgprot_t PAGE_SHARED_NOEXEC;
5352 +# define PAGE_COPY_NOEXEC __pgprot(BTFIXUP_INT(page_copy_noexec))
5353 +# define PAGE_READONLY_NOEXEC __pgprot(BTFIXUP_INT(page_readonly_noexec))
5354 +#else
5355 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
5356 +# define PAGE_COPY_NOEXEC PAGE_COPY
5357 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
5358 +#endif
5359 +
5360 extern unsigned long page_kernel;
5361
5362 #ifdef MODULE
5363 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
5364 index f6ae2b2..b03ffc7 100644
5365 --- a/arch/sparc/include/asm/pgtsrmmu.h
5366 +++ b/arch/sparc/include/asm/pgtsrmmu.h
5367 @@ -115,6 +115,13 @@
5368 SRMMU_EXEC | SRMMU_REF)
5369 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
5370 SRMMU_EXEC | SRMMU_REF)
5371 +
5372 +#ifdef CONFIG_PAX_PAGEEXEC
5373 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
5374 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
5375 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
5376 +#endif
5377 +
5378 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
5379 SRMMU_DIRTY | SRMMU_REF)
5380
5381 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
5382 index 9689176..63c18ea 100644
5383 --- a/arch/sparc/include/asm/spinlock_64.h
5384 +++ b/arch/sparc/include/asm/spinlock_64.h
5385 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
5386
5387 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
5388
5389 -static void inline arch_read_lock(arch_rwlock_t *lock)
5390 +static inline void arch_read_lock(arch_rwlock_t *lock)
5391 {
5392 unsigned long tmp1, tmp2;
5393
5394 __asm__ __volatile__ (
5395 "1: ldsw [%2], %0\n"
5396 " brlz,pn %0, 2f\n"
5397 -"4: add %0, 1, %1\n"
5398 +"4: addcc %0, 1, %1\n"
5399 +
5400 +#ifdef CONFIG_PAX_REFCOUNT
5401 +" tvs %%icc, 6\n"
5402 +#endif
5403 +
5404 " cas [%2], %0, %1\n"
5405 " cmp %0, %1\n"
5406 " bne,pn %%icc, 1b\n"
5407 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
5408 " .previous"
5409 : "=&r" (tmp1), "=&r" (tmp2)
5410 : "r" (lock)
5411 - : "memory");
5412 + : "memory", "cc");
5413 }
5414
5415 -static int inline arch_read_trylock(arch_rwlock_t *lock)
5416 +static inline int arch_read_trylock(arch_rwlock_t *lock)
5417 {
5418 int tmp1, tmp2;
5419
5420 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
5421 "1: ldsw [%2], %0\n"
5422 " brlz,a,pn %0, 2f\n"
5423 " mov 0, %0\n"
5424 -" add %0, 1, %1\n"
5425 +" addcc %0, 1, %1\n"
5426 +
5427 +#ifdef CONFIG_PAX_REFCOUNT
5428 +" tvs %%icc, 6\n"
5429 +#endif
5430 +
5431 " cas [%2], %0, %1\n"
5432 " cmp %0, %1\n"
5433 " bne,pn %%icc, 1b\n"
5434 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
5435 return tmp1;
5436 }
5437
5438 -static void inline arch_read_unlock(arch_rwlock_t *lock)
5439 +static inline void arch_read_unlock(arch_rwlock_t *lock)
5440 {
5441 unsigned long tmp1, tmp2;
5442
5443 __asm__ __volatile__(
5444 "1: lduw [%2], %0\n"
5445 -" sub %0, 1, %1\n"
5446 +" subcc %0, 1, %1\n"
5447 +
5448 +#ifdef CONFIG_PAX_REFCOUNT
5449 +" tvs %%icc, 6\n"
5450 +#endif
5451 +
5452 " cas [%2], %0, %1\n"
5453 " cmp %0, %1\n"
5454 " bne,pn %%xcc, 1b\n"
5455 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
5456 : "memory");
5457 }
5458
5459 -static void inline arch_write_lock(arch_rwlock_t *lock)
5460 +static inline void arch_write_lock(arch_rwlock_t *lock)
5461 {
5462 unsigned long mask, tmp1, tmp2;
5463
5464 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
5465 : "memory");
5466 }
5467
5468 -static void inline arch_write_unlock(arch_rwlock_t *lock)
5469 +static inline void arch_write_unlock(arch_rwlock_t *lock)
5470 {
5471 __asm__ __volatile__(
5472 " stw %%g0, [%0]"
5473 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
5474 : "memory");
5475 }
5476
5477 -static int inline arch_write_trylock(arch_rwlock_t *lock)
5478 +static inline int arch_write_trylock(arch_rwlock_t *lock)
5479 {
5480 unsigned long mask, tmp1, tmp2, result;
5481
5482 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
5483 index c2a1080..21ed218 100644
5484 --- a/arch/sparc/include/asm/thread_info_32.h
5485 +++ b/arch/sparc/include/asm/thread_info_32.h
5486 @@ -50,6 +50,8 @@ struct thread_info {
5487 unsigned long w_saved;
5488
5489 struct restart_block restart_block;
5490 +
5491 + unsigned long lowest_stack;
5492 };
5493
5494 /*
5495 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
5496 index 01d057f..13a7d2f 100644
5497 --- a/arch/sparc/include/asm/thread_info_64.h
5498 +++ b/arch/sparc/include/asm/thread_info_64.h
5499 @@ -63,6 +63,8 @@ struct thread_info {
5500 struct pt_regs *kern_una_regs;
5501 unsigned int kern_una_insn;
5502
5503 + unsigned long lowest_stack;
5504 +
5505 unsigned long fpregs[0] __attribute__ ((aligned(64)));
5506 };
5507
5508 @@ -214,10 +216,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
5509 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
5510 /* flag bit 6 is available */
5511 #define TIF_32BIT 7 /* 32-bit binary */
5512 -/* flag bit 8 is available */
5513 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
5514 #define TIF_SECCOMP 9 /* secure computing */
5515 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
5516 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
5517 +
5518 /* NOTE: Thread flags >= 12 should be ones we have no interest
5519 * in using in assembly, else we can't use the mask as
5520 * an immediate value in instructions such as andcc.
5521 @@ -236,12 +239,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
5522 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
5523 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
5524 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
5525 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
5526
5527 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
5528 _TIF_DO_NOTIFY_RESUME_MASK | \
5529 _TIF_NEED_RESCHED)
5530 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
5531
5532 +#define _TIF_WORK_SYSCALL \
5533 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
5534 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
5535 +
5536 +
5537 /*
5538 * Thread-synchronous status.
5539 *
5540 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
5541 index e88fbe5..96b0ce5 100644
5542 --- a/arch/sparc/include/asm/uaccess.h
5543 +++ b/arch/sparc/include/asm/uaccess.h
5544 @@ -1,5 +1,13 @@
5545 #ifndef ___ASM_SPARC_UACCESS_H
5546 #define ___ASM_SPARC_UACCESS_H
5547 +
5548 +#ifdef __KERNEL__
5549 +#ifndef __ASSEMBLY__
5550 +#include <linux/types.h>
5551 +extern void check_object_size(const void *ptr, unsigned long n, bool to);
5552 +#endif
5553 +#endif
5554 +
5555 #if defined(__sparc__) && defined(__arch64__)
5556 #include <asm/uaccess_64.h>
5557 #else
5558 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
5559 index 8303ac4..07f333d 100644
5560 --- a/arch/sparc/include/asm/uaccess_32.h
5561 +++ b/arch/sparc/include/asm/uaccess_32.h
5562 @@ -249,27 +249,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
5563
5564 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
5565 {
5566 - if (n && __access_ok((unsigned long) to, n))
5567 + if ((long)n < 0)
5568 + return n;
5569 +
5570 + if (n && __access_ok((unsigned long) to, n)) {
5571 + if (!__builtin_constant_p(n))
5572 + check_object_size(from, n, true);
5573 return __copy_user(to, (__force void __user *) from, n);
5574 - else
5575 + } else
5576 return n;
5577 }
5578
5579 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
5580 {
5581 + if ((long)n < 0)
5582 + return n;
5583 +
5584 + if (!__builtin_constant_p(n))
5585 + check_object_size(from, n, true);
5586 +
5587 return __copy_user(to, (__force void __user *) from, n);
5588 }
5589
5590 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
5591 {
5592 - if (n && __access_ok((unsigned long) from, n))
5593 + if ((long)n < 0)
5594 + return n;
5595 +
5596 + if (n && __access_ok((unsigned long) from, n)) {
5597 + if (!__builtin_constant_p(n))
5598 + check_object_size(to, n, false);
5599 return __copy_user((__force void __user *) to, from, n);
5600 - else
5601 + } else
5602 return n;
5603 }
5604
5605 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
5606 {
5607 + if ((long)n < 0)
5608 + return n;
5609 +
5610 return __copy_user((__force void __user *) to, from, n);
5611 }
5612
5613 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
5614 index 3e1449f..5293a0e 100644
5615 --- a/arch/sparc/include/asm/uaccess_64.h
5616 +++ b/arch/sparc/include/asm/uaccess_64.h
5617 @@ -10,6 +10,7 @@
5618 #include <linux/compiler.h>
5619 #include <linux/string.h>
5620 #include <linux/thread_info.h>
5621 +#include <linux/kernel.h>
5622 #include <asm/asi.h>
5623 #include <asm/system.h>
5624 #include <asm/spitfire.h>
5625 @@ -213,8 +214,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
5626 static inline unsigned long __must_check
5627 copy_from_user(void *to, const void __user *from, unsigned long size)
5628 {
5629 - unsigned long ret = ___copy_from_user(to, from, size);
5630 + unsigned long ret;
5631
5632 + if ((long)size < 0 || size > INT_MAX)
5633 + return size;
5634 +
5635 + if (!__builtin_constant_p(size))
5636 + check_object_size(to, size, false);
5637 +
5638 + ret = ___copy_from_user(to, from, size);
5639 if (unlikely(ret))
5640 ret = copy_from_user_fixup(to, from, size);
5641
5642 @@ -230,8 +238,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
5643 static inline unsigned long __must_check
5644 copy_to_user(void __user *to, const void *from, unsigned long size)
5645 {
5646 - unsigned long ret = ___copy_to_user(to, from, size);
5647 + unsigned long ret;
5648
5649 + if ((long)size < 0 || size > INT_MAX)
5650 + return size;
5651 +
5652 + if (!__builtin_constant_p(size))
5653 + check_object_size(from, size, true);
5654 +
5655 + ret = ___copy_to_user(to, from, size);
5656 if (unlikely(ret))
5657 ret = copy_to_user_fixup(to, from, size);
5658 return ret;
5659 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
5660 index cb85458..e063f17 100644
5661 --- a/arch/sparc/kernel/Makefile
5662 +++ b/arch/sparc/kernel/Makefile
5663 @@ -3,7 +3,7 @@
5664 #
5665
5666 asflags-y := -ansi
5667 -ccflags-y := -Werror
5668 +#ccflags-y := -Werror
5669
5670 extra-y := head_$(BITS).o
5671 extra-y += init_task.o
5672 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
5673 index f793742..4d880af 100644
5674 --- a/arch/sparc/kernel/process_32.c
5675 +++ b/arch/sparc/kernel/process_32.c
5676 @@ -204,7 +204,7 @@ void __show_backtrace(unsigned long fp)
5677 rw->ins[4], rw->ins[5],
5678 rw->ins[6],
5679 rw->ins[7]);
5680 - printk("%pS\n", (void *) rw->ins[7]);
5681 + printk("%pA\n", (void *) rw->ins[7]);
5682 rw = (struct reg_window32 *) rw->ins[6];
5683 }
5684 spin_unlock_irqrestore(&sparc_backtrace_lock, flags);
5685 @@ -271,14 +271,14 @@ void show_regs(struct pt_regs *r)
5686
5687 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
5688 r->psr, r->pc, r->npc, r->y, print_tainted());
5689 - printk("PC: <%pS>\n", (void *) r->pc);
5690 + printk("PC: <%pA>\n", (void *) r->pc);
5691 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
5692 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
5693 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
5694 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
5695 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
5696 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
5697 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
5698 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
5699
5700 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
5701 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
5702 @@ -313,7 +313,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
5703 rw = (struct reg_window32 *) fp;
5704 pc = rw->ins[7];
5705 printk("[%08lx : ", pc);
5706 - printk("%pS ] ", (void *) pc);
5707 + printk("%pA ] ", (void *) pc);
5708 fp = rw->ins[6];
5709 } while (++count < 16);
5710 printk("\n");
5711 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
5712 index 39d8b05..d1a7d90 100644
5713 --- a/arch/sparc/kernel/process_64.c
5714 +++ b/arch/sparc/kernel/process_64.c
5715 @@ -182,14 +182,14 @@ static void show_regwindow(struct pt_regs *regs)
5716 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
5717 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
5718 if (regs->tstate & TSTATE_PRIV)
5719 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
5720 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
5721 }
5722
5723 void show_regs(struct pt_regs *regs)
5724 {
5725 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
5726 regs->tpc, regs->tnpc, regs->y, print_tainted());
5727 - printk("TPC: <%pS>\n", (void *) regs->tpc);
5728 + printk("TPC: <%pA>\n", (void *) regs->tpc);
5729 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
5730 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
5731 regs->u_regs[3]);
5732 @@ -202,7 +202,7 @@ void show_regs(struct pt_regs *regs)
5733 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
5734 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
5735 regs->u_regs[15]);
5736 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
5737 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
5738 show_regwindow(regs);
5739 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
5740 }
5741 @@ -287,7 +287,7 @@ void arch_trigger_all_cpu_backtrace(void)
5742 ((tp && tp->task) ? tp->task->pid : -1));
5743
5744 if (gp->tstate & TSTATE_PRIV) {
5745 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
5746 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
5747 (void *) gp->tpc,
5748 (void *) gp->o7,
5749 (void *) gp->i7,
5750 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
5751 index 9388844..0075fd2 100644
5752 --- a/arch/sparc/kernel/ptrace_64.c
5753 +++ b/arch/sparc/kernel/ptrace_64.c
5754 @@ -1058,6 +1058,10 @@ long arch_ptrace(struct task_struct *child, long request,
5755 return ret;
5756 }
5757
5758 +#ifdef CONFIG_GRKERNSEC_SETXID
5759 +extern void gr_delayed_cred_worker(void);
5760 +#endif
5761 +
5762 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
5763 {
5764 int ret = 0;
5765 @@ -1065,6 +1069,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
5766 /* do the secure computing check first */
5767 secure_computing(regs->u_regs[UREG_G1]);
5768
5769 +#ifdef CONFIG_GRKERNSEC_SETXID
5770 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5771 + gr_delayed_cred_worker();
5772 +#endif
5773 +
5774 if (test_thread_flag(TIF_SYSCALL_TRACE))
5775 ret = tracehook_report_syscall_entry(regs);
5776
5777 @@ -1085,6 +1094,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
5778
5779 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
5780 {
5781 +#ifdef CONFIG_GRKERNSEC_SETXID
5782 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5783 + gr_delayed_cred_worker();
5784 +#endif
5785 +
5786 audit_syscall_exit(regs);
5787
5788 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
5789 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
5790 index 42b282f..28ce9f2 100644
5791 --- a/arch/sparc/kernel/sys_sparc_32.c
5792 +++ b/arch/sparc/kernel/sys_sparc_32.c
5793 @@ -56,7 +56,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
5794 if (ARCH_SUN4C && len > 0x20000000)
5795 return -ENOMEM;
5796 if (!addr)
5797 - addr = TASK_UNMAPPED_BASE;
5798 + addr = current->mm->mmap_base;
5799
5800 if (flags & MAP_SHARED)
5801 addr = COLOUR_ALIGN(addr);
5802 @@ -71,7 +71,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
5803 }
5804 if (TASK_SIZE - PAGE_SIZE - len < addr)
5805 return -ENOMEM;
5806 - if (!vmm || addr + len <= vmm->vm_start)
5807 + if (check_heap_stack_gap(vmm, addr, len))
5808 return addr;
5809 addr = vmm->vm_end;
5810 if (flags & MAP_SHARED)
5811 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
5812 index 232df99..cee1f9c 100644
5813 --- a/arch/sparc/kernel/sys_sparc_64.c
5814 +++ b/arch/sparc/kernel/sys_sparc_64.c
5815 @@ -124,7 +124,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
5816 /* We do not accept a shared mapping if it would violate
5817 * cache aliasing constraints.
5818 */
5819 - if ((flags & MAP_SHARED) &&
5820 + if ((filp || (flags & MAP_SHARED)) &&
5821 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
5822 return -EINVAL;
5823 return addr;
5824 @@ -139,6 +139,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
5825 if (filp || (flags & MAP_SHARED))
5826 do_color_align = 1;
5827
5828 +#ifdef CONFIG_PAX_RANDMMAP
5829 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
5830 +#endif
5831 +
5832 if (addr) {
5833 if (do_color_align)
5834 addr = COLOUR_ALIGN(addr, pgoff);
5835 @@ -146,15 +150,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
5836 addr = PAGE_ALIGN(addr);
5837
5838 vma = find_vma(mm, addr);
5839 - if (task_size - len >= addr &&
5840 - (!vma || addr + len <= vma->vm_start))
5841 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len))
5842 return addr;
5843 }
5844
5845 if (len > mm->cached_hole_size) {
5846 - start_addr = addr = mm->free_area_cache;
5847 + start_addr = addr = mm->free_area_cache;
5848 } else {
5849 - start_addr = addr = TASK_UNMAPPED_BASE;
5850 + start_addr = addr = mm->mmap_base;
5851 mm->cached_hole_size = 0;
5852 }
5853
5854 @@ -174,14 +177,14 @@ full_search:
5855 vma = find_vma(mm, VA_EXCLUDE_END);
5856 }
5857 if (unlikely(task_size < addr)) {
5858 - if (start_addr != TASK_UNMAPPED_BASE) {
5859 - start_addr = addr = TASK_UNMAPPED_BASE;
5860 + if (start_addr != mm->mmap_base) {
5861 + start_addr = addr = mm->mmap_base;
5862 mm->cached_hole_size = 0;
5863 goto full_search;
5864 }
5865 return -ENOMEM;
5866 }
5867 - if (likely(!vma || addr + len <= vma->vm_start)) {
5868 + if (likely(check_heap_stack_gap(vma, addr, len))) {
5869 /*
5870 * Remember the place where we stopped the search:
5871 */
5872 @@ -215,7 +218,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
5873 /* We do not accept a shared mapping if it would violate
5874 * cache aliasing constraints.
5875 */
5876 - if ((flags & MAP_SHARED) &&
5877 + if ((filp || (flags & MAP_SHARED)) &&
5878 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
5879 return -EINVAL;
5880 return addr;
5881 @@ -236,8 +239,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
5882 addr = PAGE_ALIGN(addr);
5883
5884 vma = find_vma(mm, addr);
5885 - if (task_size - len >= addr &&
5886 - (!vma || addr + len <= vma->vm_start))
5887 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len))
5888 return addr;
5889 }
5890
5891 @@ -258,7 +260,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
5892 /* make sure it can fit in the remaining address space */
5893 if (likely(addr > len)) {
5894 vma = find_vma(mm, addr-len);
5895 - if (!vma || addr <= vma->vm_start) {
5896 + if (check_heap_stack_gap(vma, addr - len, len)) {
5897 /* remember the address as a hint for next time */
5898 return (mm->free_area_cache = addr-len);
5899 }
5900 @@ -267,18 +269,18 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
5901 if (unlikely(mm->mmap_base < len))
5902 goto bottomup;
5903
5904 - addr = mm->mmap_base-len;
5905 - if (do_color_align)
5906 - addr = COLOUR_ALIGN_DOWN(addr, pgoff);
5907 + addr = mm->mmap_base - len;
5908
5909 do {
5910 + if (do_color_align)
5911 + addr = COLOUR_ALIGN_DOWN(addr, pgoff);
5912 /*
5913 * Lookup failure means no vma is above this address,
5914 * else if new region fits below vma->vm_start,
5915 * return with success:
5916 */
5917 vma = find_vma(mm, addr);
5918 - if (likely(!vma || addr+len <= vma->vm_start)) {
5919 + if (likely(check_heap_stack_gap(vma, addr, len))) {
5920 /* remember the address as a hint for next time */
5921 return (mm->free_area_cache = addr);
5922 }
5923 @@ -288,10 +290,8 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
5924 mm->cached_hole_size = vma->vm_start - addr;
5925
5926 /* try just below the current vma->vm_start */
5927 - addr = vma->vm_start-len;
5928 - if (do_color_align)
5929 - addr = COLOUR_ALIGN_DOWN(addr, pgoff);
5930 - } while (likely(len < vma->vm_start));
5931 + addr = skip_heap_stack_gap(vma, len);
5932 + } while (!IS_ERR_VALUE(addr));
5933
5934 bottomup:
5935 /*
5936 @@ -390,6 +390,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5937 gap == RLIM_INFINITY ||
5938 sysctl_legacy_va_layout) {
5939 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
5940 +
5941 +#ifdef CONFIG_PAX_RANDMMAP
5942 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5943 + mm->mmap_base += mm->delta_mmap;
5944 +#endif
5945 +
5946 mm->get_unmapped_area = arch_get_unmapped_area;
5947 mm->unmap_area = arch_unmap_area;
5948 } else {
5949 @@ -402,6 +408,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5950 gap = (task_size / 6 * 5);
5951
5952 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
5953 +
5954 +#ifdef CONFIG_PAX_RANDMMAP
5955 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5956 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
5957 +#endif
5958 +
5959 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
5960 mm->unmap_area = arch_unmap_area_topdown;
5961 }
5962 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
5963 index 1d7e274..b39c527 100644
5964 --- a/arch/sparc/kernel/syscalls.S
5965 +++ b/arch/sparc/kernel/syscalls.S
5966 @@ -62,7 +62,7 @@ sys32_rt_sigreturn:
5967 #endif
5968 .align 32
5969 1: ldx [%g6 + TI_FLAGS], %l5
5970 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
5971 + andcc %l5, _TIF_WORK_SYSCALL, %g0
5972 be,pt %icc, rtrap
5973 nop
5974 call syscall_trace_leave
5975 @@ -179,7 +179,7 @@ linux_sparc_syscall32:
5976
5977 srl %i5, 0, %o5 ! IEU1
5978 srl %i2, 0, %o2 ! IEU0 Group
5979 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
5980 + andcc %l0, _TIF_WORK_SYSCALL, %g0
5981 bne,pn %icc, linux_syscall_trace32 ! CTI
5982 mov %i0, %l5 ! IEU1
5983 call %l7 ! CTI Group brk forced
5984 @@ -202,7 +202,7 @@ linux_sparc_syscall:
5985
5986 mov %i3, %o3 ! IEU1
5987 mov %i4, %o4 ! IEU0 Group
5988 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
5989 + andcc %l0, _TIF_WORK_SYSCALL, %g0
5990 bne,pn %icc, linux_syscall_trace ! CTI Group
5991 mov %i0, %l5 ! IEU0
5992 2: call %l7 ! CTI Group brk forced
5993 @@ -226,7 +226,7 @@ ret_sys_call:
5994
5995 cmp %o0, -ERESTART_RESTARTBLOCK
5996 bgeu,pn %xcc, 1f
5997 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %l6
5998 + andcc %l0, _TIF_WORK_SYSCALL, %l6
5999 80:
6000 /* System call success, clear Carry condition code. */
6001 andn %g3, %g2, %g3
6002 @@ -241,7 +241,7 @@ ret_sys_call:
6003 /* System call failure, set Carry condition code.
6004 * Also, get abs(errno) to return to the process.
6005 */
6006 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %l6
6007 + andcc %l0, _TIF_WORK_SYSCALL, %l6
6008 sub %g0, %o0, %o0
6009 or %g3, %g2, %g3
6010 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
6011 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
6012 index 591f20c..0f1b925 100644
6013 --- a/arch/sparc/kernel/traps_32.c
6014 +++ b/arch/sparc/kernel/traps_32.c
6015 @@ -45,6 +45,8 @@ static void instruction_dump(unsigned long *pc)
6016 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
6017 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
6018
6019 +extern void gr_handle_kernel_exploit(void);
6020 +
6021 void die_if_kernel(char *str, struct pt_regs *regs)
6022 {
6023 static int die_counter;
6024 @@ -77,15 +79,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
6025 count++ < 30 &&
6026 (((unsigned long) rw) >= PAGE_OFFSET) &&
6027 !(((unsigned long) rw) & 0x7)) {
6028 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
6029 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
6030 (void *) rw->ins[7]);
6031 rw = (struct reg_window32 *)rw->ins[6];
6032 }
6033 }
6034 printk("Instruction DUMP:");
6035 instruction_dump ((unsigned long *) regs->pc);
6036 - if(regs->psr & PSR_PS)
6037 + if(regs->psr & PSR_PS) {
6038 + gr_handle_kernel_exploit();
6039 do_exit(SIGKILL);
6040 + }
6041 do_exit(SIGSEGV);
6042 }
6043
6044 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
6045 index 0cbdaa4..438e4c9 100644
6046 --- a/arch/sparc/kernel/traps_64.c
6047 +++ b/arch/sparc/kernel/traps_64.c
6048 @@ -75,7 +75,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
6049 i + 1,
6050 p->trapstack[i].tstate, p->trapstack[i].tpc,
6051 p->trapstack[i].tnpc, p->trapstack[i].tt);
6052 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
6053 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
6054 }
6055 }
6056
6057 @@ -95,6 +95,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
6058
6059 lvl -= 0x100;
6060 if (regs->tstate & TSTATE_PRIV) {
6061 +
6062 +#ifdef CONFIG_PAX_REFCOUNT
6063 + if (lvl == 6)
6064 + pax_report_refcount_overflow(regs);
6065 +#endif
6066 +
6067 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
6068 die_if_kernel(buffer, regs);
6069 }
6070 @@ -113,11 +119,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
6071 void bad_trap_tl1(struct pt_regs *regs, long lvl)
6072 {
6073 char buffer[32];
6074 -
6075 +
6076 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
6077 0, lvl, SIGTRAP) == NOTIFY_STOP)
6078 return;
6079
6080 +#ifdef CONFIG_PAX_REFCOUNT
6081 + if (lvl == 6)
6082 + pax_report_refcount_overflow(regs);
6083 +#endif
6084 +
6085 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
6086
6087 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
6088 @@ -1141,7 +1152,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
6089 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
6090 printk("%s" "ERROR(%d): ",
6091 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
6092 - printk("TPC<%pS>\n", (void *) regs->tpc);
6093 + printk("TPC<%pA>\n", (void *) regs->tpc);
6094 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
6095 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
6096 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
6097 @@ -1748,7 +1759,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
6098 smp_processor_id(),
6099 (type & 0x1) ? 'I' : 'D',
6100 regs->tpc);
6101 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
6102 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
6103 panic("Irrecoverable Cheetah+ parity error.");
6104 }
6105
6106 @@ -1756,7 +1767,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
6107 smp_processor_id(),
6108 (type & 0x1) ? 'I' : 'D',
6109 regs->tpc);
6110 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
6111 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
6112 }
6113
6114 struct sun4v_error_entry {
6115 @@ -1963,9 +1974,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
6116
6117 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
6118 regs->tpc, tl);
6119 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
6120 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
6121 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
6122 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
6123 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
6124 (void *) regs->u_regs[UREG_I7]);
6125 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
6126 "pte[%lx] error[%lx]\n",
6127 @@ -1987,9 +1998,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
6128
6129 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
6130 regs->tpc, tl);
6131 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
6132 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
6133 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
6134 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
6135 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
6136 (void *) regs->u_regs[UREG_I7]);
6137 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
6138 "pte[%lx] error[%lx]\n",
6139 @@ -2195,13 +2206,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
6140 fp = (unsigned long)sf->fp + STACK_BIAS;
6141 }
6142
6143 - printk(" [%016lx] %pS\n", pc, (void *) pc);
6144 + printk(" [%016lx] %pA\n", pc, (void *) pc);
6145 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
6146 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
6147 int index = tsk->curr_ret_stack;
6148 if (tsk->ret_stack && index >= graph) {
6149 pc = tsk->ret_stack[index - graph].ret;
6150 - printk(" [%016lx] %pS\n", pc, (void *) pc);
6151 + printk(" [%016lx] %pA\n", pc, (void *) pc);
6152 graph++;
6153 }
6154 }
6155 @@ -2226,6 +2237,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
6156 return (struct reg_window *) (fp + STACK_BIAS);
6157 }
6158
6159 +extern void gr_handle_kernel_exploit(void);
6160 +
6161 void die_if_kernel(char *str, struct pt_regs *regs)
6162 {
6163 static int die_counter;
6164 @@ -2254,7 +2267,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
6165 while (rw &&
6166 count++ < 30 &&
6167 kstack_valid(tp, (unsigned long) rw)) {
6168 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
6169 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
6170 (void *) rw->ins[7]);
6171
6172 rw = kernel_stack_up(rw);
6173 @@ -2267,8 +2280,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
6174 }
6175 user_instruction_dump ((unsigned int __user *) regs->tpc);
6176 }
6177 - if (regs->tstate & TSTATE_PRIV)
6178 + if (regs->tstate & TSTATE_PRIV) {
6179 + gr_handle_kernel_exploit();
6180 do_exit(SIGKILL);
6181 + }
6182 do_exit(SIGSEGV);
6183 }
6184 EXPORT_SYMBOL(die_if_kernel);
6185 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
6186 index 76e4ac1..78f8bb1 100644
6187 --- a/arch/sparc/kernel/unaligned_64.c
6188 +++ b/arch/sparc/kernel/unaligned_64.c
6189 @@ -279,7 +279,7 @@ static void log_unaligned(struct pt_regs *regs)
6190 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
6191
6192 if (__ratelimit(&ratelimit)) {
6193 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
6194 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
6195 regs->tpc, (void *) regs->tpc);
6196 }
6197 }
6198 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
6199 index a3fc437..fea9957 100644
6200 --- a/arch/sparc/lib/Makefile
6201 +++ b/arch/sparc/lib/Makefile
6202 @@ -2,7 +2,7 @@
6203 #
6204
6205 asflags-y := -ansi -DST_DIV0=0x02
6206 -ccflags-y := -Werror
6207 +#ccflags-y := -Werror
6208
6209 lib-$(CONFIG_SPARC32) += mul.o rem.o sdiv.o udiv.o umul.o urem.o ashrdi3.o
6210 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
6211 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
6212 index 59186e0..f747d7a 100644
6213 --- a/arch/sparc/lib/atomic_64.S
6214 +++ b/arch/sparc/lib/atomic_64.S
6215 @@ -18,7 +18,12 @@
6216 atomic_add: /* %o0 = increment, %o1 = atomic_ptr */
6217 BACKOFF_SETUP(%o2)
6218 1: lduw [%o1], %g1
6219 - add %g1, %o0, %g7
6220 + addcc %g1, %o0, %g7
6221 +
6222 +#ifdef CONFIG_PAX_REFCOUNT
6223 + tvs %icc, 6
6224 +#endif
6225 +
6226 cas [%o1], %g1, %g7
6227 cmp %g1, %g7
6228 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
6229 @@ -28,12 +33,32 @@ atomic_add: /* %o0 = increment, %o1 = atomic_ptr */
6230 2: BACKOFF_SPIN(%o2, %o3, 1b)
6231 .size atomic_add, .-atomic_add
6232
6233 + .globl atomic_add_unchecked
6234 + .type atomic_add_unchecked,#function
6235 +atomic_add_unchecked: /* %o0 = increment, %o1 = atomic_ptr */
6236 + BACKOFF_SETUP(%o2)
6237 +1: lduw [%o1], %g1
6238 + add %g1, %o0, %g7
6239 + cas [%o1], %g1, %g7
6240 + cmp %g1, %g7
6241 + bne,pn %icc, 2f
6242 + nop
6243 + retl
6244 + nop
6245 +2: BACKOFF_SPIN(%o2, %o3, 1b)
6246 + .size atomic_add_unchecked, .-atomic_add_unchecked
6247 +
6248 .globl atomic_sub
6249 .type atomic_sub,#function
6250 atomic_sub: /* %o0 = decrement, %o1 = atomic_ptr */
6251 BACKOFF_SETUP(%o2)
6252 1: lduw [%o1], %g1
6253 - sub %g1, %o0, %g7
6254 + subcc %g1, %o0, %g7
6255 +
6256 +#ifdef CONFIG_PAX_REFCOUNT
6257 + tvs %icc, 6
6258 +#endif
6259 +
6260 cas [%o1], %g1, %g7
6261 cmp %g1, %g7
6262 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
6263 @@ -43,12 +68,32 @@ atomic_sub: /* %o0 = decrement, %o1 = atomic_ptr */
6264 2: BACKOFF_SPIN(%o2, %o3, 1b)
6265 .size atomic_sub, .-atomic_sub
6266
6267 + .globl atomic_sub_unchecked
6268 + .type atomic_sub_unchecked,#function
6269 +atomic_sub_unchecked: /* %o0 = decrement, %o1 = atomic_ptr */
6270 + BACKOFF_SETUP(%o2)
6271 +1: lduw [%o1], %g1
6272 + sub %g1, %o0, %g7
6273 + cas [%o1], %g1, %g7
6274 + cmp %g1, %g7
6275 + bne,pn %icc, 2f
6276 + nop
6277 + retl
6278 + nop
6279 +2: BACKOFF_SPIN(%o2, %o3, 1b)
6280 + .size atomic_sub_unchecked, .-atomic_sub_unchecked
6281 +
6282 .globl atomic_add_ret
6283 .type atomic_add_ret,#function
6284 atomic_add_ret: /* %o0 = increment, %o1 = atomic_ptr */
6285 BACKOFF_SETUP(%o2)
6286 1: lduw [%o1], %g1
6287 - add %g1, %o0, %g7
6288 + addcc %g1, %o0, %g7
6289 +
6290 +#ifdef CONFIG_PAX_REFCOUNT
6291 + tvs %icc, 6
6292 +#endif
6293 +
6294 cas [%o1], %g1, %g7
6295 cmp %g1, %g7
6296 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
6297 @@ -58,12 +103,33 @@ atomic_add_ret: /* %o0 = increment, %o1 = atomic_ptr */
6298 2: BACKOFF_SPIN(%o2, %o3, 1b)
6299 .size atomic_add_ret, .-atomic_add_ret
6300
6301 + .globl atomic_add_ret_unchecked
6302 + .type atomic_add_ret_unchecked,#function
6303 +atomic_add_ret_unchecked: /* %o0 = increment, %o1 = atomic_ptr */
6304 + BACKOFF_SETUP(%o2)
6305 +1: lduw [%o1], %g1
6306 + addcc %g1, %o0, %g7
6307 + cas [%o1], %g1, %g7
6308 + cmp %g1, %g7
6309 + bne,pn %icc, 2f
6310 + add %g7, %o0, %g7
6311 + sra %g7, 0, %o0
6312 + retl
6313 + nop
6314 +2: BACKOFF_SPIN(%o2, %o3, 1b)
6315 + .size atomic_add_ret_unchecked, .-atomic_add_ret_unchecked
6316 +
6317 .globl atomic_sub_ret
6318 .type atomic_sub_ret,#function
6319 atomic_sub_ret: /* %o0 = decrement, %o1 = atomic_ptr */
6320 BACKOFF_SETUP(%o2)
6321 1: lduw [%o1], %g1
6322 - sub %g1, %o0, %g7
6323 + subcc %g1, %o0, %g7
6324 +
6325 +#ifdef CONFIG_PAX_REFCOUNT
6326 + tvs %icc, 6
6327 +#endif
6328 +
6329 cas [%o1], %g1, %g7
6330 cmp %g1, %g7
6331 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
6332 @@ -78,7 +144,12 @@ atomic_sub_ret: /* %o0 = decrement, %o1 = atomic_ptr */
6333 atomic64_add: /* %o0 = increment, %o1 = atomic_ptr */
6334 BACKOFF_SETUP(%o2)
6335 1: ldx [%o1], %g1
6336 - add %g1, %o0, %g7
6337 + addcc %g1, %o0, %g7
6338 +
6339 +#ifdef CONFIG_PAX_REFCOUNT
6340 + tvs %xcc, 6
6341 +#endif
6342 +
6343 casx [%o1], %g1, %g7
6344 cmp %g1, %g7
6345 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
6346 @@ -88,12 +159,32 @@ atomic64_add: /* %o0 = increment, %o1 = atomic_ptr */
6347 2: BACKOFF_SPIN(%o2, %o3, 1b)
6348 .size atomic64_add, .-atomic64_add
6349
6350 + .globl atomic64_add_unchecked
6351 + .type atomic64_add_unchecked,#function
6352 +atomic64_add_unchecked: /* %o0 = increment, %o1 = atomic_ptr */
6353 + BACKOFF_SETUP(%o2)
6354 +1: ldx [%o1], %g1
6355 + addcc %g1, %o0, %g7
6356 + casx [%o1], %g1, %g7
6357 + cmp %g1, %g7
6358 + bne,pn %xcc, 2f
6359 + nop
6360 + retl
6361 + nop
6362 +2: BACKOFF_SPIN(%o2, %o3, 1b)
6363 + .size atomic64_add_unchecked, .-atomic64_add_unchecked
6364 +
6365 .globl atomic64_sub
6366 .type atomic64_sub,#function
6367 atomic64_sub: /* %o0 = decrement, %o1 = atomic_ptr */
6368 BACKOFF_SETUP(%o2)
6369 1: ldx [%o1], %g1
6370 - sub %g1, %o0, %g7
6371 + subcc %g1, %o0, %g7
6372 +
6373 +#ifdef CONFIG_PAX_REFCOUNT
6374 + tvs %xcc, 6
6375 +#endif
6376 +
6377 casx [%o1], %g1, %g7
6378 cmp %g1, %g7
6379 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
6380 @@ -103,12 +194,32 @@ atomic64_sub: /* %o0 = decrement, %o1 = atomic_ptr */
6381 2: BACKOFF_SPIN(%o2, %o3, 1b)
6382 .size atomic64_sub, .-atomic64_sub
6383
6384 + .globl atomic64_sub_unchecked
6385 + .type atomic64_sub_unchecked,#function
6386 +atomic64_sub_unchecked: /* %o0 = decrement, %o1 = atomic_ptr */
6387 + BACKOFF_SETUP(%o2)
6388 +1: ldx [%o1], %g1
6389 + subcc %g1, %o0, %g7
6390 + casx [%o1], %g1, %g7
6391 + cmp %g1, %g7
6392 + bne,pn %xcc, 2f
6393 + nop
6394 + retl
6395 + nop
6396 +2: BACKOFF_SPIN(%o2, %o3, 1b)
6397 + .size atomic64_sub_unchecked, .-atomic64_sub_unchecked
6398 +
6399 .globl atomic64_add_ret
6400 .type atomic64_add_ret,#function
6401 atomic64_add_ret: /* %o0 = increment, %o1 = atomic_ptr */
6402 BACKOFF_SETUP(%o2)
6403 1: ldx [%o1], %g1
6404 - add %g1, %o0, %g7
6405 + addcc %g1, %o0, %g7
6406 +
6407 +#ifdef CONFIG_PAX_REFCOUNT
6408 + tvs %xcc, 6
6409 +#endif
6410 +
6411 casx [%o1], %g1, %g7
6412 cmp %g1, %g7
6413 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
6414 @@ -118,12 +229,33 @@ atomic64_add_ret: /* %o0 = increment, %o1 = atomic_ptr */
6415 2: BACKOFF_SPIN(%o2, %o3, 1b)
6416 .size atomic64_add_ret, .-atomic64_add_ret
6417
6418 + .globl atomic64_add_ret_unchecked
6419 + .type atomic64_add_ret_unchecked,#function
6420 +atomic64_add_ret_unchecked: /* %o0 = increment, %o1 = atomic_ptr */
6421 + BACKOFF_SETUP(%o2)
6422 +1: ldx [%o1], %g1
6423 + addcc %g1, %o0, %g7
6424 + casx [%o1], %g1, %g7
6425 + cmp %g1, %g7
6426 + bne,pn %xcc, 2f
6427 + add %g7, %o0, %g7
6428 + mov %g7, %o0
6429 + retl
6430 + nop
6431 +2: BACKOFF_SPIN(%o2, %o3, 1b)
6432 + .size atomic64_add_ret_unchecked, .-atomic64_add_ret_unchecked
6433 +
6434 .globl atomic64_sub_ret
6435 .type atomic64_sub_ret,#function
6436 atomic64_sub_ret: /* %o0 = decrement, %o1 = atomic_ptr */
6437 BACKOFF_SETUP(%o2)
6438 1: ldx [%o1], %g1
6439 - sub %g1, %o0, %g7
6440 + subcc %g1, %o0, %g7
6441 +
6442 +#ifdef CONFIG_PAX_REFCOUNT
6443 + tvs %xcc, 6
6444 +#endif
6445 +
6446 casx [%o1], %g1, %g7
6447 cmp %g1, %g7
6448 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
6449 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
6450 index f73c224..662af10 100644
6451 --- a/arch/sparc/lib/ksyms.c
6452 +++ b/arch/sparc/lib/ksyms.c
6453 @@ -136,12 +136,18 @@ EXPORT_SYMBOL(__downgrade_write);
6454
6455 /* Atomic counter implementation. */
6456 EXPORT_SYMBOL(atomic_add);
6457 +EXPORT_SYMBOL(atomic_add_unchecked);
6458 EXPORT_SYMBOL(atomic_add_ret);
6459 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
6460 EXPORT_SYMBOL(atomic_sub);
6461 +EXPORT_SYMBOL(atomic_sub_unchecked);
6462 EXPORT_SYMBOL(atomic_sub_ret);
6463 EXPORT_SYMBOL(atomic64_add);
6464 +EXPORT_SYMBOL(atomic64_add_unchecked);
6465 EXPORT_SYMBOL(atomic64_add_ret);
6466 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
6467 EXPORT_SYMBOL(atomic64_sub);
6468 +EXPORT_SYMBOL(atomic64_sub_unchecked);
6469 EXPORT_SYMBOL(atomic64_sub_ret);
6470
6471 /* Atomic bit operations. */
6472 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
6473 index 301421c..e2535d1 100644
6474 --- a/arch/sparc/mm/Makefile
6475 +++ b/arch/sparc/mm/Makefile
6476 @@ -2,7 +2,7 @@
6477 #
6478
6479 asflags-y := -ansi
6480 -ccflags-y := -Werror
6481 +#ccflags-y := -Werror
6482
6483 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
6484 obj-y += fault_$(BITS).o
6485 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
6486 index 8023fd7..c8e89e9 100644
6487 --- a/arch/sparc/mm/fault_32.c
6488 +++ b/arch/sparc/mm/fault_32.c
6489 @@ -21,6 +21,9 @@
6490 #include <linux/perf_event.h>
6491 #include <linux/interrupt.h>
6492 #include <linux/kdebug.h>
6493 +#include <linux/slab.h>
6494 +#include <linux/pagemap.h>
6495 +#include <linux/compiler.h>
6496
6497 #include <asm/system.h>
6498 #include <asm/page.h>
6499 @@ -208,6 +211,268 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
6500 return safe_compute_effective_address(regs, insn);
6501 }
6502
6503 +#ifdef CONFIG_PAX_PAGEEXEC
6504 +#ifdef CONFIG_PAX_DLRESOLVE
6505 +static void pax_emuplt_close(struct vm_area_struct *vma)
6506 +{
6507 + vma->vm_mm->call_dl_resolve = 0UL;
6508 +}
6509 +
6510 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
6511 +{
6512 + unsigned int *kaddr;
6513 +
6514 + vmf->page = alloc_page(GFP_HIGHUSER);
6515 + if (!vmf->page)
6516 + return VM_FAULT_OOM;
6517 +
6518 + kaddr = kmap(vmf->page);
6519 + memset(kaddr, 0, PAGE_SIZE);
6520 + kaddr[0] = 0x9DE3BFA8U; /* save */
6521 + flush_dcache_page(vmf->page);
6522 + kunmap(vmf->page);
6523 + return VM_FAULT_MAJOR;
6524 +}
6525 +
6526 +static const struct vm_operations_struct pax_vm_ops = {
6527 + .close = pax_emuplt_close,
6528 + .fault = pax_emuplt_fault
6529 +};
6530 +
6531 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
6532 +{
6533 + int ret;
6534 +
6535 + INIT_LIST_HEAD(&vma->anon_vma_chain);
6536 + vma->vm_mm = current->mm;
6537 + vma->vm_start = addr;
6538 + vma->vm_end = addr + PAGE_SIZE;
6539 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
6540 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
6541 + vma->vm_ops = &pax_vm_ops;
6542 +
6543 + ret = insert_vm_struct(current->mm, vma);
6544 + if (ret)
6545 + return ret;
6546 +
6547 + ++current->mm->total_vm;
6548 + return 0;
6549 +}
6550 +#endif
6551 +
6552 +/*
6553 + * PaX: decide what to do with offenders (regs->pc = fault address)
6554 + *
6555 + * returns 1 when task should be killed
6556 + * 2 when patched PLT trampoline was detected
6557 + * 3 when unpatched PLT trampoline was detected
6558 + */
6559 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6560 +{
6561 +
6562 +#ifdef CONFIG_PAX_EMUPLT
6563 + int err;
6564 +
6565 + do { /* PaX: patched PLT emulation #1 */
6566 + unsigned int sethi1, sethi2, jmpl;
6567 +
6568 + err = get_user(sethi1, (unsigned int *)regs->pc);
6569 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
6570 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
6571 +
6572 + if (err)
6573 + break;
6574 +
6575 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
6576 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
6577 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
6578 + {
6579 + unsigned int addr;
6580 +
6581 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
6582 + addr = regs->u_regs[UREG_G1];
6583 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
6584 + regs->pc = addr;
6585 + regs->npc = addr+4;
6586 + return 2;
6587 + }
6588 + } while (0);
6589 +
6590 + { /* PaX: patched PLT emulation #2 */
6591 + unsigned int ba;
6592 +
6593 + err = get_user(ba, (unsigned int *)regs->pc);
6594 +
6595 + if (!err && (ba & 0xFFC00000U) == 0x30800000U) {
6596 + unsigned int addr;
6597 +
6598 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
6599 + regs->pc = addr;
6600 + regs->npc = addr+4;
6601 + return 2;
6602 + }
6603 + }
6604 +
6605 + do { /* PaX: patched PLT emulation #3 */
6606 + unsigned int sethi, jmpl, nop;
6607 +
6608 + err = get_user(sethi, (unsigned int *)regs->pc);
6609 + err |= get_user(jmpl, (unsigned int *)(regs->pc+4));
6610 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
6611 +
6612 + if (err)
6613 + break;
6614 +
6615 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
6616 + (jmpl & 0xFFFFE000U) == 0x81C06000U &&
6617 + nop == 0x01000000U)
6618 + {
6619 + unsigned int addr;
6620 +
6621 + addr = (sethi & 0x003FFFFFU) << 10;
6622 + regs->u_regs[UREG_G1] = addr;
6623 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
6624 + regs->pc = addr;
6625 + regs->npc = addr+4;
6626 + return 2;
6627 + }
6628 + } while (0);
6629 +
6630 + do { /* PaX: unpatched PLT emulation step 1 */
6631 + unsigned int sethi, ba, nop;
6632 +
6633 + err = get_user(sethi, (unsigned int *)regs->pc);
6634 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
6635 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
6636 +
6637 + if (err)
6638 + break;
6639 +
6640 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
6641 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
6642 + nop == 0x01000000U)
6643 + {
6644 + unsigned int addr, save, call;
6645 +
6646 + if ((ba & 0xFFC00000U) == 0x30800000U)
6647 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
6648 + else
6649 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
6650 +
6651 + err = get_user(save, (unsigned int *)addr);
6652 + err |= get_user(call, (unsigned int *)(addr+4));
6653 + err |= get_user(nop, (unsigned int *)(addr+8));
6654 + if (err)
6655 + break;
6656 +
6657 +#ifdef CONFIG_PAX_DLRESOLVE
6658 + if (save == 0x9DE3BFA8U &&
6659 + (call & 0xC0000000U) == 0x40000000U &&
6660 + nop == 0x01000000U)
6661 + {
6662 + struct vm_area_struct *vma;
6663 + unsigned long call_dl_resolve;
6664 +
6665 + down_read(&current->mm->mmap_sem);
6666 + call_dl_resolve = current->mm->call_dl_resolve;
6667 + up_read(&current->mm->mmap_sem);
6668 + if (likely(call_dl_resolve))
6669 + goto emulate;
6670 +
6671 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
6672 +
6673 + down_write(&current->mm->mmap_sem);
6674 + if (current->mm->call_dl_resolve) {
6675 + call_dl_resolve = current->mm->call_dl_resolve;
6676 + up_write(&current->mm->mmap_sem);
6677 + if (vma)
6678 + kmem_cache_free(vm_area_cachep, vma);
6679 + goto emulate;
6680 + }
6681 +
6682 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
6683 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
6684 + up_write(&current->mm->mmap_sem);
6685 + if (vma)
6686 + kmem_cache_free(vm_area_cachep, vma);
6687 + return 1;
6688 + }
6689 +
6690 + if (pax_insert_vma(vma, call_dl_resolve)) {
6691 + up_write(&current->mm->mmap_sem);
6692 + kmem_cache_free(vm_area_cachep, vma);
6693 + return 1;
6694 + }
6695 +
6696 + current->mm->call_dl_resolve = call_dl_resolve;
6697 + up_write(&current->mm->mmap_sem);
6698 +
6699 +emulate:
6700 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
6701 + regs->pc = call_dl_resolve;
6702 + regs->npc = addr+4;
6703 + return 3;
6704 + }
6705 +#endif
6706 +
6707 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
6708 + if ((save & 0xFFC00000U) == 0x05000000U &&
6709 + (call & 0xFFFFE000U) == 0x85C0A000U &&
6710 + nop == 0x01000000U)
6711 + {
6712 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
6713 + regs->u_regs[UREG_G2] = addr + 4;
6714 + addr = (save & 0x003FFFFFU) << 10;
6715 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
6716 + regs->pc = addr;
6717 + regs->npc = addr+4;
6718 + return 3;
6719 + }
6720 + }
6721 + } while (0);
6722 +
6723 + do { /* PaX: unpatched PLT emulation step 2 */
6724 + unsigned int save, call, nop;
6725 +
6726 + err = get_user(save, (unsigned int *)(regs->pc-4));
6727 + err |= get_user(call, (unsigned int *)regs->pc);
6728 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
6729 + if (err)
6730 + break;
6731 +
6732 + if (save == 0x9DE3BFA8U &&
6733 + (call & 0xC0000000U) == 0x40000000U &&
6734 + nop == 0x01000000U)
6735 + {
6736 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
6737 +
6738 + regs->u_regs[UREG_RETPC] = regs->pc;
6739 + regs->pc = dl_resolve;
6740 + regs->npc = dl_resolve+4;
6741 + return 3;
6742 + }
6743 + } while (0);
6744 +#endif
6745 +
6746 + return 1;
6747 +}
6748 +
6749 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6750 +{
6751 + unsigned long i;
6752 +
6753 + printk(KERN_ERR "PAX: bytes at PC: ");
6754 + for (i = 0; i < 8; i++) {
6755 + unsigned int c;
6756 + if (get_user(c, (unsigned int *)pc+i))
6757 + printk(KERN_CONT "???????? ");
6758 + else
6759 + printk(KERN_CONT "%08x ", c);
6760 + }
6761 + printk("\n");
6762 +}
6763 +#endif
6764 +
6765 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
6766 int text_fault)
6767 {
6768 @@ -280,6 +545,24 @@ good_area:
6769 if(!(vma->vm_flags & VM_WRITE))
6770 goto bad_area;
6771 } else {
6772 +
6773 +#ifdef CONFIG_PAX_PAGEEXEC
6774 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
6775 + up_read(&mm->mmap_sem);
6776 + switch (pax_handle_fetch_fault(regs)) {
6777 +
6778 +#ifdef CONFIG_PAX_EMUPLT
6779 + case 2:
6780 + case 3:
6781 + return;
6782 +#endif
6783 +
6784 + }
6785 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
6786 + do_group_exit(SIGKILL);
6787 + }
6788 +#endif
6789 +
6790 /* Allow reads even for write-only mappings */
6791 if(!(vma->vm_flags & (VM_READ | VM_EXEC)))
6792 goto bad_area;
6793 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
6794 index 504c062..6fcb9c6 100644
6795 --- a/arch/sparc/mm/fault_64.c
6796 +++ b/arch/sparc/mm/fault_64.c
6797 @@ -21,6 +21,9 @@
6798 #include <linux/kprobes.h>
6799 #include <linux/kdebug.h>
6800 #include <linux/percpu.h>
6801 +#include <linux/slab.h>
6802 +#include <linux/pagemap.h>
6803 +#include <linux/compiler.h>
6804
6805 #include <asm/page.h>
6806 #include <asm/pgtable.h>
6807 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
6808 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
6809 regs->tpc);
6810 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
6811 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
6812 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
6813 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
6814 dump_stack();
6815 unhandled_fault(regs->tpc, current, regs);
6816 @@ -272,6 +275,457 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
6817 show_regs(regs);
6818 }
6819
6820 +#ifdef CONFIG_PAX_PAGEEXEC
6821 +#ifdef CONFIG_PAX_DLRESOLVE
6822 +static void pax_emuplt_close(struct vm_area_struct *vma)
6823 +{
6824 + vma->vm_mm->call_dl_resolve = 0UL;
6825 +}
6826 +
6827 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
6828 +{
6829 + unsigned int *kaddr;
6830 +
6831 + vmf->page = alloc_page(GFP_HIGHUSER);
6832 + if (!vmf->page)
6833 + return VM_FAULT_OOM;
6834 +
6835 + kaddr = kmap(vmf->page);
6836 + memset(kaddr, 0, PAGE_SIZE);
6837 + kaddr[0] = 0x9DE3BFA8U; /* save */
6838 + flush_dcache_page(vmf->page);
6839 + kunmap(vmf->page);
6840 + return VM_FAULT_MAJOR;
6841 +}
6842 +
6843 +static const struct vm_operations_struct pax_vm_ops = {
6844 + .close = pax_emuplt_close,
6845 + .fault = pax_emuplt_fault
6846 +};
6847 +
6848 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
6849 +{
6850 + int ret;
6851 +
6852 + INIT_LIST_HEAD(&vma->anon_vma_chain);
6853 + vma->vm_mm = current->mm;
6854 + vma->vm_start = addr;
6855 + vma->vm_end = addr + PAGE_SIZE;
6856 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
6857 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
6858 + vma->vm_ops = &pax_vm_ops;
6859 +
6860 + ret = insert_vm_struct(current->mm, vma);
6861 + if (ret)
6862 + return ret;
6863 +
6864 + ++current->mm->total_vm;
6865 + return 0;
6866 +}
6867 +#endif
6868 +
6869 +/*
6870 + * PaX: decide what to do with offenders (regs->tpc = fault address)
6871 + *
6872 + * returns 1 when task should be killed
6873 + * 2 when patched PLT trampoline was detected
6874 + * 3 when unpatched PLT trampoline was detected
6875 + */
6876 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6877 +{
6878 +
6879 +#ifdef CONFIG_PAX_EMUPLT
6880 + int err;
6881 +
6882 + do { /* PaX: patched PLT emulation #1 */
6883 + unsigned int sethi1, sethi2, jmpl;
6884 +
6885 + err = get_user(sethi1, (unsigned int *)regs->tpc);
6886 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
6887 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
6888 +
6889 + if (err)
6890 + break;
6891 +
6892 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
6893 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
6894 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
6895 + {
6896 + unsigned long addr;
6897 +
6898 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
6899 + addr = regs->u_regs[UREG_G1];
6900 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
6901 +
6902 + if (test_thread_flag(TIF_32BIT))
6903 + addr &= 0xFFFFFFFFUL;
6904 +
6905 + regs->tpc = addr;
6906 + regs->tnpc = addr+4;
6907 + return 2;
6908 + }
6909 + } while (0);
6910 +
6911 + { /* PaX: patched PLT emulation #2 */
6912 + unsigned int ba;
6913 +
6914 + err = get_user(ba, (unsigned int *)regs->tpc);
6915 +
6916 + if (!err && (ba & 0xFFC00000U) == 0x30800000U) {
6917 + unsigned long addr;
6918 +
6919 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
6920 +
6921 + if (test_thread_flag(TIF_32BIT))
6922 + addr &= 0xFFFFFFFFUL;
6923 +
6924 + regs->tpc = addr;
6925 + regs->tnpc = addr+4;
6926 + return 2;
6927 + }
6928 + }
6929 +
6930 + do { /* PaX: patched PLT emulation #3 */
6931 + unsigned int sethi, jmpl, nop;
6932 +
6933 + err = get_user(sethi, (unsigned int *)regs->tpc);
6934 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+4));
6935 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
6936 +
6937 + if (err)
6938 + break;
6939 +
6940 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
6941 + (jmpl & 0xFFFFE000U) == 0x81C06000U &&
6942 + nop == 0x01000000U)
6943 + {
6944 + unsigned long addr;
6945 +
6946 + addr = (sethi & 0x003FFFFFU) << 10;
6947 + regs->u_regs[UREG_G1] = addr;
6948 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
6949 +
6950 + if (test_thread_flag(TIF_32BIT))
6951 + addr &= 0xFFFFFFFFUL;
6952 +
6953 + regs->tpc = addr;
6954 + regs->tnpc = addr+4;
6955 + return 2;
6956 + }
6957 + } while (0);
6958 +
6959 + do { /* PaX: patched PLT emulation #4 */
6960 + unsigned int sethi, mov1, call, mov2;
6961 +
6962 + err = get_user(sethi, (unsigned int *)regs->tpc);
6963 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
6964 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
6965 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
6966 +
6967 + if (err)
6968 + break;
6969 +
6970 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
6971 + mov1 == 0x8210000FU &&
6972 + (call & 0xC0000000U) == 0x40000000U &&
6973 + mov2 == 0x9E100001U)
6974 + {
6975 + unsigned long addr;
6976 +
6977 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
6978 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
6979 +
6980 + if (test_thread_flag(TIF_32BIT))
6981 + addr &= 0xFFFFFFFFUL;
6982 +
6983 + regs->tpc = addr;
6984 + regs->tnpc = addr+4;
6985 + return 2;
6986 + }
6987 + } while (0);
6988 +
6989 + do { /* PaX: patched PLT emulation #5 */
6990 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
6991 +
6992 + err = get_user(sethi, (unsigned int *)regs->tpc);
6993 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
6994 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
6995 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
6996 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
6997 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
6998 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
6999 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
7000 +
7001 + if (err)
7002 + break;
7003 +
7004 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
7005 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
7006 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
7007 + (or1 & 0xFFFFE000U) == 0x82106000U &&
7008 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
7009 + sllx == 0x83287020U &&
7010 + jmpl == 0x81C04005U &&
7011 + nop == 0x01000000U)
7012 + {
7013 + unsigned long addr;
7014 +
7015 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
7016 + regs->u_regs[UREG_G1] <<= 32;
7017 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
7018 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
7019 + regs->tpc = addr;
7020 + regs->tnpc = addr+4;
7021 + return 2;
7022 + }
7023 + } while (0);
7024 +
7025 + do { /* PaX: patched PLT emulation #6 */
7026 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
7027 +
7028 + err = get_user(sethi, (unsigned int *)regs->tpc);
7029 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
7030 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
7031 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
7032 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
7033 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
7034 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
7035 +
7036 + if (err)
7037 + break;
7038 +
7039 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
7040 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
7041 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
7042 + sllx == 0x83287020U &&
7043 + (or & 0xFFFFE000U) == 0x8A116000U &&
7044 + jmpl == 0x81C04005U &&
7045 + nop == 0x01000000U)
7046 + {
7047 + unsigned long addr;
7048 +
7049 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
7050 + regs->u_regs[UREG_G1] <<= 32;
7051 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
7052 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
7053 + regs->tpc = addr;
7054 + regs->tnpc = addr+4;
7055 + return 2;
7056 + }
7057 + } while (0);
7058 +
7059 + do { /* PaX: unpatched PLT emulation step 1 */
7060 + unsigned int sethi, ba, nop;
7061 +
7062 + err = get_user(sethi, (unsigned int *)regs->tpc);
7063 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
7064 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
7065 +
7066 + if (err)
7067 + break;
7068 +
7069 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
7070 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
7071 + nop == 0x01000000U)
7072 + {
7073 + unsigned long addr;
7074 + unsigned int save, call;
7075 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
7076 +
7077 + if ((ba & 0xFFC00000U) == 0x30800000U)
7078 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
7079 + else
7080 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
7081 +
7082 + if (test_thread_flag(TIF_32BIT))
7083 + addr &= 0xFFFFFFFFUL;
7084 +
7085 + err = get_user(save, (unsigned int *)addr);
7086 + err |= get_user(call, (unsigned int *)(addr+4));
7087 + err |= get_user(nop, (unsigned int *)(addr+8));
7088 + if (err)
7089 + break;
7090 +
7091 +#ifdef CONFIG_PAX_DLRESOLVE
7092 + if (save == 0x9DE3BFA8U &&
7093 + (call & 0xC0000000U) == 0x40000000U &&
7094 + nop == 0x01000000U)
7095 + {
7096 + struct vm_area_struct *vma;
7097 + unsigned long call_dl_resolve;
7098 +
7099 + down_read(&current->mm->mmap_sem);
7100 + call_dl_resolve = current->mm->call_dl_resolve;
7101 + up_read(&current->mm->mmap_sem);
7102 + if (likely(call_dl_resolve))
7103 + goto emulate;
7104 +
7105 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
7106 +
7107 + down_write(&current->mm->mmap_sem);
7108 + if (current->mm->call_dl_resolve) {
7109 + call_dl_resolve = current->mm->call_dl_resolve;
7110 + up_write(&current->mm->mmap_sem);
7111 + if (vma)
7112 + kmem_cache_free(vm_area_cachep, vma);
7113 + goto emulate;
7114 + }
7115 +
7116 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
7117 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
7118 + up_write(&current->mm->mmap_sem);
7119 + if (vma)
7120 + kmem_cache_free(vm_area_cachep, vma);
7121 + return 1;
7122 + }
7123 +
7124 + if (pax_insert_vma(vma, call_dl_resolve)) {
7125 + up_write(&current->mm->mmap_sem);
7126 + kmem_cache_free(vm_area_cachep, vma);
7127 + return 1;
7128 + }
7129 +
7130 + current->mm->call_dl_resolve = call_dl_resolve;
7131 + up_write(&current->mm->mmap_sem);
7132 +
7133 +emulate:
7134 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
7135 + regs->tpc = call_dl_resolve;
7136 + regs->tnpc = addr+4;
7137 + return 3;
7138 + }
7139 +#endif
7140 +
7141 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
7142 + if ((save & 0xFFC00000U) == 0x05000000U &&
7143 + (call & 0xFFFFE000U) == 0x85C0A000U &&
7144 + nop == 0x01000000U)
7145 + {
7146 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
7147 + regs->u_regs[UREG_G2] = addr + 4;
7148 + addr = (save & 0x003FFFFFU) << 10;
7149 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
7150 +
7151 + if (test_thread_flag(TIF_32BIT))
7152 + addr &= 0xFFFFFFFFUL;
7153 +
7154 + regs->tpc = addr;
7155 + regs->tnpc = addr+4;
7156 + return 3;
7157 + }
7158 +
7159 + /* PaX: 64-bit PLT stub */
7160 + err = get_user(sethi1, (unsigned int *)addr);
7161 + err |= get_user(sethi2, (unsigned int *)(addr+4));
7162 + err |= get_user(or1, (unsigned int *)(addr+8));
7163 + err |= get_user(or2, (unsigned int *)(addr+12));
7164 + err |= get_user(sllx, (unsigned int *)(addr+16));
7165 + err |= get_user(add, (unsigned int *)(addr+20));
7166 + err |= get_user(jmpl, (unsigned int *)(addr+24));
7167 + err |= get_user(nop, (unsigned int *)(addr+28));
7168 + if (err)
7169 + break;
7170 +
7171 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
7172 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
7173 + (or1 & 0xFFFFE000U) == 0x88112000U &&
7174 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
7175 + sllx == 0x89293020U &&
7176 + add == 0x8A010005U &&
7177 + jmpl == 0x89C14000U &&
7178 + nop == 0x01000000U)
7179 + {
7180 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
7181 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
7182 + regs->u_regs[UREG_G4] <<= 32;
7183 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
7184 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
7185 + regs->u_regs[UREG_G4] = addr + 24;
7186 + addr = regs->u_regs[UREG_G5];
7187 + regs->tpc = addr;
7188 + regs->tnpc = addr+4;
7189 + return 3;
7190 + }
7191 + }
7192 + } while (0);
7193 +
7194 +#ifdef CONFIG_PAX_DLRESOLVE
7195 + do { /* PaX: unpatched PLT emulation step 2 */
7196 + unsigned int save, call, nop;
7197 +
7198 + err = get_user(save, (unsigned int *)(regs->tpc-4));
7199 + err |= get_user(call, (unsigned int *)regs->tpc);
7200 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
7201 + if (err)
7202 + break;
7203 +
7204 + if (save == 0x9DE3BFA8U &&
7205 + (call & 0xC0000000U) == 0x40000000U &&
7206 + nop == 0x01000000U)
7207 + {
7208 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
7209 +
7210 + if (test_thread_flag(TIF_32BIT))
7211 + dl_resolve &= 0xFFFFFFFFUL;
7212 +
7213 + regs->u_regs[UREG_RETPC] = regs->tpc;
7214 + regs->tpc = dl_resolve;
7215 + regs->tnpc = dl_resolve+4;
7216 + return 3;
7217 + }
7218 + } while (0);
7219 +#endif
7220 +
7221 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
7222 + unsigned int sethi, ba, nop;
7223 +
7224 + err = get_user(sethi, (unsigned int *)regs->tpc);
7225 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
7226 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
7227 +
7228 + if (err)
7229 + break;
7230 +
7231 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
7232 + (ba & 0xFFF00000U) == 0x30600000U &&
7233 + nop == 0x01000000U)
7234 + {
7235 + unsigned long addr;
7236 +
7237 + addr = (sethi & 0x003FFFFFU) << 10;
7238 + regs->u_regs[UREG_G1] = addr;
7239 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
7240 +
7241 + if (test_thread_flag(TIF_32BIT))
7242 + addr &= 0xFFFFFFFFUL;
7243 +
7244 + regs->tpc = addr;
7245 + regs->tnpc = addr+4;
7246 + return 2;
7247 + }
7248 + } while (0);
7249 +
7250 +#endif
7251 +
7252 + return 1;
7253 +}
7254 +
7255 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7256 +{
7257 + unsigned long i;
7258 +
7259 + printk(KERN_ERR "PAX: bytes at PC: ");
7260 + for (i = 0; i < 8; i++) {
7261 + unsigned int c;
7262 + if (get_user(c, (unsigned int *)pc+i))
7263 + printk(KERN_CONT "???????? ");
7264 + else
7265 + printk(KERN_CONT "%08x ", c);
7266 + }
7267 + printk("\n");
7268 +}
7269 +#endif
7270 +
7271 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
7272 {
7273 struct mm_struct *mm = current->mm;
7274 @@ -340,6 +794,29 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
7275 if (!vma)
7276 goto bad_area;
7277
7278 +#ifdef CONFIG_PAX_PAGEEXEC
7279 + /* PaX: detect ITLB misses on non-exec pages */
7280 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
7281 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
7282 + {
7283 + if (address != regs->tpc)
7284 + goto good_area;
7285 +
7286 + up_read(&mm->mmap_sem);
7287 + switch (pax_handle_fetch_fault(regs)) {
7288 +
7289 +#ifdef CONFIG_PAX_EMUPLT
7290 + case 2:
7291 + case 3:
7292 + return;
7293 +#endif
7294 +
7295 + }
7296 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
7297 + do_group_exit(SIGKILL);
7298 + }
7299 +#endif
7300 +
7301 /* Pure DTLB misses do not tell us whether the fault causing
7302 * load/store/atomic was a write or not, it only says that there
7303 * was no match. So in such a case we (carefully) read the
7304 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
7305 index 07e1453..0a7d9e9 100644
7306 --- a/arch/sparc/mm/hugetlbpage.c
7307 +++ b/arch/sparc/mm/hugetlbpage.c
7308 @@ -67,7 +67,7 @@ full_search:
7309 }
7310 return -ENOMEM;
7311 }
7312 - if (likely(!vma || addr + len <= vma->vm_start)) {
7313 + if (likely(check_heap_stack_gap(vma, addr, len))) {
7314 /*
7315 * Remember the place where we stopped the search:
7316 */
7317 @@ -106,7 +106,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7318 /* make sure it can fit in the remaining address space */
7319 if (likely(addr > len)) {
7320 vma = find_vma(mm, addr-len);
7321 - if (!vma || addr <= vma->vm_start) {
7322 + if (check_heap_stack_gap(vma, addr - len, len)) {
7323 /* remember the address as a hint for next time */
7324 return (mm->free_area_cache = addr-len);
7325 }
7326 @@ -115,16 +115,17 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7327 if (unlikely(mm->mmap_base < len))
7328 goto bottomup;
7329
7330 - addr = (mm->mmap_base-len) & HPAGE_MASK;
7331 + addr = mm->mmap_base - len;
7332
7333 do {
7334 + addr &= HPAGE_MASK;
7335 /*
7336 * Lookup failure means no vma is above this address,
7337 * else if new region fits below vma->vm_start,
7338 * return with success:
7339 */
7340 vma = find_vma(mm, addr);
7341 - if (likely(!vma || addr+len <= vma->vm_start)) {
7342 + if (likely(check_heap_stack_gap(vma, addr, len))) {
7343 /* remember the address as a hint for next time */
7344 return (mm->free_area_cache = addr);
7345 }
7346 @@ -134,8 +135,8 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7347 mm->cached_hole_size = vma->vm_start - addr;
7348
7349 /* try just below the current vma->vm_start */
7350 - addr = (vma->vm_start-len) & HPAGE_MASK;
7351 - } while (likely(len < vma->vm_start));
7352 + addr = skip_heap_stack_gap(vma, len);
7353 + } while (!IS_ERR_VALUE(addr));
7354
7355 bottomup:
7356 /*
7357 @@ -181,8 +182,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
7358 if (addr) {
7359 addr = ALIGN(addr, HPAGE_SIZE);
7360 vma = find_vma(mm, addr);
7361 - if (task_size - len >= addr &&
7362 - (!vma || addr + len <= vma->vm_start))
7363 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len))
7364 return addr;
7365 }
7366 if (mm->get_unmapped_area == arch_get_unmapped_area)
7367 diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c
7368 index 7b00de6..78239f4 100644
7369 --- a/arch/sparc/mm/init_32.c
7370 +++ b/arch/sparc/mm/init_32.c
7371 @@ -316,6 +316,9 @@ extern void device_scan(void);
7372 pgprot_t PAGE_SHARED __read_mostly;
7373 EXPORT_SYMBOL(PAGE_SHARED);
7374
7375 +pgprot_t PAGE_SHARED_NOEXEC __read_mostly;
7376 +EXPORT_SYMBOL(PAGE_SHARED_NOEXEC);
7377 +
7378 void __init paging_init(void)
7379 {
7380 switch(sparc_cpu_model) {
7381 @@ -344,17 +347,17 @@ void __init paging_init(void)
7382
7383 /* Initialize the protection map with non-constant, MMU dependent values. */
7384 protection_map[0] = PAGE_NONE;
7385 - protection_map[1] = PAGE_READONLY;
7386 - protection_map[2] = PAGE_COPY;
7387 - protection_map[3] = PAGE_COPY;
7388 + protection_map[1] = PAGE_READONLY_NOEXEC;
7389 + protection_map[2] = PAGE_COPY_NOEXEC;
7390 + protection_map[3] = PAGE_COPY_NOEXEC;
7391 protection_map[4] = PAGE_READONLY;
7392 protection_map[5] = PAGE_READONLY;
7393 protection_map[6] = PAGE_COPY;
7394 protection_map[7] = PAGE_COPY;
7395 protection_map[8] = PAGE_NONE;
7396 - protection_map[9] = PAGE_READONLY;
7397 - protection_map[10] = PAGE_SHARED;
7398 - protection_map[11] = PAGE_SHARED;
7399 + protection_map[9] = PAGE_READONLY_NOEXEC;
7400 + protection_map[10] = PAGE_SHARED_NOEXEC;
7401 + protection_map[11] = PAGE_SHARED_NOEXEC;
7402 protection_map[12] = PAGE_READONLY;
7403 protection_map[13] = PAGE_READONLY;
7404 protection_map[14] = PAGE_SHARED;
7405 diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
7406 index cbef74e..c38fead 100644
7407 --- a/arch/sparc/mm/srmmu.c
7408 +++ b/arch/sparc/mm/srmmu.c
7409 @@ -2200,6 +2200,13 @@ void __init ld_mmu_srmmu(void)
7410 PAGE_SHARED = pgprot_val(SRMMU_PAGE_SHARED);
7411 BTFIXUPSET_INT(page_copy, pgprot_val(SRMMU_PAGE_COPY));
7412 BTFIXUPSET_INT(page_readonly, pgprot_val(SRMMU_PAGE_RDONLY));
7413 +
7414 +#ifdef CONFIG_PAX_PAGEEXEC
7415 + PAGE_SHARED_NOEXEC = pgprot_val(SRMMU_PAGE_SHARED_NOEXEC);
7416 + BTFIXUPSET_INT(page_copy_noexec, pgprot_val(SRMMU_PAGE_COPY_NOEXEC));
7417 + BTFIXUPSET_INT(page_readonly_noexec, pgprot_val(SRMMU_PAGE_RDONLY_NOEXEC));
7418 +#endif
7419 +
7420 BTFIXUPSET_INT(page_kernel, pgprot_val(SRMMU_PAGE_KERNEL));
7421 page_kernel = pgprot_val(SRMMU_PAGE_KERNEL);
7422
7423 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
7424 index 27fe667..36d474c 100644
7425 --- a/arch/tile/include/asm/atomic_64.h
7426 +++ b/arch/tile/include/asm/atomic_64.h
7427 @@ -142,6 +142,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
7428
7429 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7430
7431 +#define atomic64_read_unchecked(v) atomic64_read(v)
7432 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7433 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7434 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7435 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7436 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7437 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7438 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7439 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7440 +
7441 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
7442 #define smp_mb__before_atomic_dec() smp_mb()
7443 #define smp_mb__after_atomic_dec() smp_mb()
7444 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
7445 index 392e533..536b092 100644
7446 --- a/arch/tile/include/asm/cache.h
7447 +++ b/arch/tile/include/asm/cache.h
7448 @@ -15,11 +15,12 @@
7449 #ifndef _ASM_TILE_CACHE_H
7450 #define _ASM_TILE_CACHE_H
7451
7452 +#include <linux/const.h>
7453 #include <arch/chip.h>
7454
7455 /* bytes per L1 data cache line */
7456 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
7457 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7458 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7459
7460 /* bytes per L2 cache line */
7461 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
7462 diff --git a/arch/um/Makefile b/arch/um/Makefile
7463 index 28688e6..4c0aa1c 100644
7464 --- a/arch/um/Makefile
7465 +++ b/arch/um/Makefile
7466 @@ -61,6 +61,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
7467 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
7468 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
7469
7470 +ifdef CONSTIFY_PLUGIN
7471 +USER_CFLAGS += $(CONSTIFY_PLUGIN) -fplugin-arg-constify_plugin-no-constify
7472 +endif
7473 +
7474 #This will adjust *FLAGS accordingly to the platform.
7475 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
7476
7477 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
7478 index 19e1bdd..3665b77 100644
7479 --- a/arch/um/include/asm/cache.h
7480 +++ b/arch/um/include/asm/cache.h
7481 @@ -1,6 +1,7 @@
7482 #ifndef __UM_CACHE_H
7483 #define __UM_CACHE_H
7484
7485 +#include <linux/const.h>
7486
7487 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
7488 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
7489 @@ -12,6 +13,6 @@
7490 # define L1_CACHE_SHIFT 5
7491 #endif
7492
7493 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7494 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7495
7496 #endif
7497 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
7498 index 6c03acd..a5e0215 100644
7499 --- a/arch/um/include/asm/kmap_types.h
7500 +++ b/arch/um/include/asm/kmap_types.h
7501 @@ -23,6 +23,7 @@ enum km_type {
7502 KM_IRQ1,
7503 KM_SOFTIRQ0,
7504 KM_SOFTIRQ1,
7505 + KM_CLEARPAGE,
7506 KM_TYPE_NR
7507 };
7508
7509 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
7510 index 7cfc3ce..cbd1a58 100644
7511 --- a/arch/um/include/asm/page.h
7512 +++ b/arch/um/include/asm/page.h
7513 @@ -14,6 +14,9 @@
7514 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
7515 #define PAGE_MASK (~(PAGE_SIZE-1))
7516
7517 +#define ktla_ktva(addr) (addr)
7518 +#define ktva_ktla(addr) (addr)
7519 +
7520 #ifndef __ASSEMBLY__
7521
7522 struct page;
7523 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
7524 index 0032f92..cd151e0 100644
7525 --- a/arch/um/include/asm/pgtable-3level.h
7526 +++ b/arch/um/include/asm/pgtable-3level.h
7527 @@ -58,6 +58,7 @@
7528 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
7529 #define pud_populate(mm, pud, pmd) \
7530 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
7531 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
7532
7533 #ifdef CONFIG_64BIT
7534 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
7535 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
7536 index 69f2490..2634831 100644
7537 --- a/arch/um/kernel/process.c
7538 +++ b/arch/um/kernel/process.c
7539 @@ -408,22 +408,6 @@ int singlestepping(void * t)
7540 return 2;
7541 }
7542
7543 -/*
7544 - * Only x86 and x86_64 have an arch_align_stack().
7545 - * All other arches have "#define arch_align_stack(x) (x)"
7546 - * in their asm/system.h
7547 - * As this is included in UML from asm-um/system-generic.h,
7548 - * we can use it to behave as the subarch does.
7549 - */
7550 -#ifndef arch_align_stack
7551 -unsigned long arch_align_stack(unsigned long sp)
7552 -{
7553 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7554 - sp -= get_random_int() % 8192;
7555 - return sp & ~0xf;
7556 -}
7557 -#endif
7558 -
7559 unsigned long get_wchan(struct task_struct *p)
7560 {
7561 unsigned long stack_page, sp, ip;
7562 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
7563 index ad8f795..2c7eec6 100644
7564 --- a/arch/unicore32/include/asm/cache.h
7565 +++ b/arch/unicore32/include/asm/cache.h
7566 @@ -12,8 +12,10 @@
7567 #ifndef __UNICORE_CACHE_H__
7568 #define __UNICORE_CACHE_H__
7569
7570 -#define L1_CACHE_SHIFT (5)
7571 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7572 +#include <linux/const.h>
7573 +
7574 +#define L1_CACHE_SHIFT 5
7575 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7576
7577 /*
7578 * Memory returned by kmalloc() may be used for DMA, so we must make
7579 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
7580 index 5bed94e..fbcf200 100644
7581 --- a/arch/x86/Kconfig
7582 +++ b/arch/x86/Kconfig
7583 @@ -226,7 +226,7 @@ config X86_HT
7584
7585 config X86_32_LAZY_GS
7586 def_bool y
7587 - depends on X86_32 && !CC_STACKPROTECTOR
7588 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
7589
7590 config ARCH_HWEIGHT_CFLAGS
7591 string
7592 @@ -1058,7 +1058,7 @@ choice
7593
7594 config NOHIGHMEM
7595 bool "off"
7596 - depends on !X86_NUMAQ
7597 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
7598 ---help---
7599 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
7600 However, the address space of 32-bit x86 processors is only 4
7601 @@ -1095,7 +1095,7 @@ config NOHIGHMEM
7602
7603 config HIGHMEM4G
7604 bool "4GB"
7605 - depends on !X86_NUMAQ
7606 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
7607 ---help---
7608 Select this if you have a 32-bit processor and between 1 and 4
7609 gigabytes of physical RAM.
7610 @@ -1149,7 +1149,7 @@ config PAGE_OFFSET
7611 hex
7612 default 0xB0000000 if VMSPLIT_3G_OPT
7613 default 0x80000000 if VMSPLIT_2G
7614 - default 0x78000000 if VMSPLIT_2G_OPT
7615 + default 0x70000000 if VMSPLIT_2G_OPT
7616 default 0x40000000 if VMSPLIT_1G
7617 default 0xC0000000
7618 depends on X86_32
7619 @@ -1539,6 +1539,7 @@ config SECCOMP
7620
7621 config CC_STACKPROTECTOR
7622 bool "Enable -fstack-protector buffer overflow detection (EXPERIMENTAL)"
7623 + depends on X86_64 || !PAX_MEMORY_UDEREF
7624 ---help---
7625 This option turns on the -fstack-protector GCC feature. This
7626 feature puts, at the beginning of functions, a canary value on
7627 @@ -1596,6 +1597,7 @@ config KEXEC_JUMP
7628 config PHYSICAL_START
7629 hex "Physical address where the kernel is loaded" if (EXPERT || CRASH_DUMP)
7630 default "0x1000000"
7631 + range 0x400000 0x40000000
7632 ---help---
7633 This gives the physical address where the kernel is loaded.
7634
7635 @@ -1659,6 +1661,7 @@ config X86_NEED_RELOCS
7636 config PHYSICAL_ALIGN
7637 hex "Alignment value to which kernel should be aligned" if X86_32
7638 default "0x1000000"
7639 + range 0x400000 0x1000000 if PAX_KERNEXEC
7640 range 0x2000 0x1000000
7641 ---help---
7642 This value puts the alignment restrictions on physical address
7643 @@ -1690,9 +1693,10 @@ config HOTPLUG_CPU
7644 Say N if you want to disable CPU hotplug.
7645
7646 config COMPAT_VDSO
7647 - def_bool y
7648 + def_bool n
7649 prompt "Compat VDSO support"
7650 depends on X86_32 || IA32_EMULATION
7651 + depends on !PAX_NOEXEC && !PAX_MEMORY_UDEREF
7652 ---help---
7653 Map the 32-bit VDSO to the predictable old-style address too.
7654
7655 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
7656 index 3c57033..22d44aa 100644
7657 --- a/arch/x86/Kconfig.cpu
7658 +++ b/arch/x86/Kconfig.cpu
7659 @@ -335,7 +335,7 @@ config X86_PPRO_FENCE
7660
7661 config X86_F00F_BUG
7662 def_bool y
7663 - depends on M586MMX || M586TSC || M586 || M486 || M386
7664 + depends on (M586MMX || M586TSC || M586 || M486 || M386) && !PAX_KERNEXEC
7665
7666 config X86_INVD_BUG
7667 def_bool y
7668 @@ -359,7 +359,7 @@ config X86_POPAD_OK
7669
7670 config X86_ALIGNMENT_16
7671 def_bool y
7672 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
7673 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
7674
7675 config X86_INTEL_USERCOPY
7676 def_bool y
7677 @@ -405,7 +405,7 @@ config X86_CMPXCHG64
7678 # generates cmov.
7679 config X86_CMOV
7680 def_bool y
7681 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
7682 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
7683
7684 config X86_MINIMUM_CPU_FAMILY
7685 int
7686 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
7687 index e46c214..7c72b55 100644
7688 --- a/arch/x86/Kconfig.debug
7689 +++ b/arch/x86/Kconfig.debug
7690 @@ -84,7 +84,7 @@ config X86_PTDUMP
7691 config DEBUG_RODATA
7692 bool "Write protect kernel read-only data structures"
7693 default y
7694 - depends on DEBUG_KERNEL
7695 + depends on DEBUG_KERNEL && BROKEN
7696 ---help---
7697 Mark the kernel read-only data as write-protected in the pagetables,
7698 in order to catch accidental (and incorrect) writes to such const
7699 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
7700
7701 config DEBUG_SET_MODULE_RONX
7702 bool "Set loadable kernel module data as NX and text as RO"
7703 - depends on MODULES
7704 + depends on MODULES && BROKEN
7705 ---help---
7706 This option helps catch unintended modifications to loadable
7707 kernel module's text and read-only data. It also prevents execution
7708 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
7709 index 209ba12..15140db 100644
7710 --- a/arch/x86/Makefile
7711 +++ b/arch/x86/Makefile
7712 @@ -46,6 +46,7 @@ else
7713 UTS_MACHINE := x86_64
7714 CHECKFLAGS += -D__x86_64__ -m64
7715
7716 + biarch := $(call cc-option,-m64)
7717 KBUILD_AFLAGS += -m64
7718 KBUILD_CFLAGS += -m64
7719
7720 @@ -201,3 +202,12 @@ define archhelp
7721 echo ' FDARGS="..." arguments for the booted kernel'
7722 echo ' FDINITRD=file initrd for the booted kernel'
7723 endef
7724 +
7725 +define OLD_LD
7726 +
7727 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
7728 +*** Please upgrade your binutils to 2.18 or newer
7729 +endef
7730 +
7731 +archprepare:
7732 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
7733 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
7734 index 5a747dd..ff7b12c 100644
7735 --- a/arch/x86/boot/Makefile
7736 +++ b/arch/x86/boot/Makefile
7737 @@ -64,6 +64,9 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
7738 $(call cc-option, -fno-stack-protector) \
7739 $(call cc-option, -mpreferred-stack-boundary=2)
7740 KBUILD_CFLAGS += $(call cc-option, -m32)
7741 +ifdef CONSTIFY_PLUGIN
7742 +KBUILD_CFLAGS += $(CONSTIFY_PLUGIN) -fplugin-arg-constify_plugin-no-constify
7743 +endif
7744 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
7745 GCOV_PROFILE := n
7746
7747 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
7748 index 878e4b9..20537ab 100644
7749 --- a/arch/x86/boot/bitops.h
7750 +++ b/arch/x86/boot/bitops.h
7751 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
7752 u8 v;
7753 const u32 *p = (const u32 *)addr;
7754
7755 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
7756 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
7757 return v;
7758 }
7759
7760 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
7761
7762 static inline void set_bit(int nr, void *addr)
7763 {
7764 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
7765 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
7766 }
7767
7768 #endif /* BOOT_BITOPS_H */
7769 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
7770 index c7093bd..d4247ffe0 100644
7771 --- a/arch/x86/boot/boot.h
7772 +++ b/arch/x86/boot/boot.h
7773 @@ -85,7 +85,7 @@ static inline void io_delay(void)
7774 static inline u16 ds(void)
7775 {
7776 u16 seg;
7777 - asm("movw %%ds,%0" : "=rm" (seg));
7778 + asm volatile("movw %%ds,%0" : "=rm" (seg));
7779 return seg;
7780 }
7781
7782 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
7783 static inline int memcmp(const void *s1, const void *s2, size_t len)
7784 {
7785 u8 diff;
7786 - asm("repe; cmpsb; setnz %0"
7787 + asm volatile("repe; cmpsb; setnz %0"
7788 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
7789 return diff;
7790 }
7791 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
7792 index fd55a2f..217b501 100644
7793 --- a/arch/x86/boot/compressed/Makefile
7794 +++ b/arch/x86/boot/compressed/Makefile
7795 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
7796 KBUILD_CFLAGS += $(cflags-y)
7797 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
7798 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
7799 +ifdef CONSTIFY_PLUGIN
7800 +KBUILD_CFLAGS += $(CONSTIFY_PLUGIN) -fplugin-arg-constify_plugin-no-constify
7801 +endif
7802
7803 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
7804 GCOV_PROFILE := n
7805 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
7806 index 0cdfc0d..6e79437 100644
7807 --- a/arch/x86/boot/compressed/eboot.c
7808 +++ b/arch/x86/boot/compressed/eboot.c
7809 @@ -122,7 +122,6 @@ again:
7810 *addr = max_addr;
7811 }
7812
7813 -free_pool:
7814 efi_call_phys1(sys_table->boottime->free_pool, map);
7815
7816 fail:
7817 @@ -186,7 +185,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
7818 if (i == map_size / desc_size)
7819 status = EFI_NOT_FOUND;
7820
7821 -free_pool:
7822 efi_call_phys1(sys_table->boottime->free_pool, map);
7823 fail:
7824 return status;
7825 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
7826 index c85e3ac..6f5aa80 100644
7827 --- a/arch/x86/boot/compressed/head_32.S
7828 +++ b/arch/x86/boot/compressed/head_32.S
7829 @@ -106,7 +106,7 @@ preferred_addr:
7830 notl %eax
7831 andl %eax, %ebx
7832 #else
7833 - movl $LOAD_PHYSICAL_ADDR, %ebx
7834 + movl $____LOAD_PHYSICAL_ADDR, %ebx
7835 #endif
7836
7837 /* Target address to relocate to for decompression */
7838 @@ -192,7 +192,7 @@ relocated:
7839 * and where it was actually loaded.
7840 */
7841 movl %ebp, %ebx
7842 - subl $LOAD_PHYSICAL_ADDR, %ebx
7843 + subl $____LOAD_PHYSICAL_ADDR, %ebx
7844 jz 2f /* Nothing to be done if loaded at compiled addr. */
7845 /*
7846 * Process relocations.
7847 @@ -200,8 +200,7 @@ relocated:
7848
7849 1: subl $4, %edi
7850 movl (%edi), %ecx
7851 - testl %ecx, %ecx
7852 - jz 2f
7853 + jecxz 2f
7854 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
7855 jmp 1b
7856 2:
7857 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
7858 index 87e03a1..0d94c76 100644
7859 --- a/arch/x86/boot/compressed/head_64.S
7860 +++ b/arch/x86/boot/compressed/head_64.S
7861 @@ -91,7 +91,7 @@ ENTRY(startup_32)
7862 notl %eax
7863 andl %eax, %ebx
7864 #else
7865 - movl $LOAD_PHYSICAL_ADDR, %ebx
7866 + movl $____LOAD_PHYSICAL_ADDR, %ebx
7867 #endif
7868
7869 /* Target address to relocate to for decompression */
7870 @@ -263,7 +263,7 @@ preferred_addr:
7871 notq %rax
7872 andq %rax, %rbp
7873 #else
7874 - movq $LOAD_PHYSICAL_ADDR, %rbp
7875 + movq $____LOAD_PHYSICAL_ADDR, %rbp
7876 #endif
7877
7878 /* Target address to relocate to for decompression */
7879 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
7880 index 7116dcb..d9ae1d7 100644
7881 --- a/arch/x86/boot/compressed/misc.c
7882 +++ b/arch/x86/boot/compressed/misc.c
7883 @@ -310,7 +310,7 @@ static void parse_elf(void *output)
7884 case PT_LOAD:
7885 #ifdef CONFIG_RELOCATABLE
7886 dest = output;
7887 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
7888 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
7889 #else
7890 dest = (void *)(phdr->p_paddr);
7891 #endif
7892 @@ -365,7 +365,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
7893 error("Destination address too large");
7894 #endif
7895 #ifndef CONFIG_RELOCATABLE
7896 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
7897 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
7898 error("Wrong destination address");
7899 #endif
7900
7901 diff --git a/arch/x86/boot/compressed/relocs.c b/arch/x86/boot/compressed/relocs.c
7902 index e77f4e4..17e511f 100644
7903 --- a/arch/x86/boot/compressed/relocs.c
7904 +++ b/arch/x86/boot/compressed/relocs.c
7905 @@ -13,8 +13,11 @@
7906
7907 static void die(char *fmt, ...);
7908
7909 +#include "../../../../include/generated/autoconf.h"
7910 +
7911 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
7912 static Elf32_Ehdr ehdr;
7913 +static Elf32_Phdr *phdr;
7914 static unsigned long reloc_count, reloc_idx;
7915 static unsigned long *relocs;
7916
7917 @@ -270,9 +273,39 @@ static void read_ehdr(FILE *fp)
7918 }
7919 }
7920
7921 +static void read_phdrs(FILE *fp)
7922 +{
7923 + unsigned int i;
7924 +
7925 + phdr = calloc(ehdr.e_phnum, sizeof(Elf32_Phdr));
7926 + if (!phdr) {
7927 + die("Unable to allocate %d program headers\n",
7928 + ehdr.e_phnum);
7929 + }
7930 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
7931 + die("Seek to %d failed: %s\n",
7932 + ehdr.e_phoff, strerror(errno));
7933 + }
7934 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
7935 + die("Cannot read ELF program headers: %s\n",
7936 + strerror(errno));
7937 + }
7938 + for(i = 0; i < ehdr.e_phnum; i++) {
7939 + phdr[i].p_type = elf32_to_cpu(phdr[i].p_type);
7940 + phdr[i].p_offset = elf32_to_cpu(phdr[i].p_offset);
7941 + phdr[i].p_vaddr = elf32_to_cpu(phdr[i].p_vaddr);
7942 + phdr[i].p_paddr = elf32_to_cpu(phdr[i].p_paddr);
7943 + phdr[i].p_filesz = elf32_to_cpu(phdr[i].p_filesz);
7944 + phdr[i].p_memsz = elf32_to_cpu(phdr[i].p_memsz);
7945 + phdr[i].p_flags = elf32_to_cpu(phdr[i].p_flags);
7946 + phdr[i].p_align = elf32_to_cpu(phdr[i].p_align);
7947 + }
7948 +
7949 +}
7950 +
7951 static void read_shdrs(FILE *fp)
7952 {
7953 - int i;
7954 + unsigned int i;
7955 Elf32_Shdr shdr;
7956
7957 secs = calloc(ehdr.e_shnum, sizeof(struct section));
7958 @@ -307,7 +340,7 @@ static void read_shdrs(FILE *fp)
7959
7960 static void read_strtabs(FILE *fp)
7961 {
7962 - int i;
7963 + unsigned int i;
7964 for (i = 0; i < ehdr.e_shnum; i++) {
7965 struct section *sec = &secs[i];
7966 if (sec->shdr.sh_type != SHT_STRTAB) {
7967 @@ -332,7 +365,7 @@ static void read_strtabs(FILE *fp)
7968
7969 static void read_symtabs(FILE *fp)
7970 {
7971 - int i,j;
7972 + unsigned int i,j;
7973 for (i = 0; i < ehdr.e_shnum; i++) {
7974 struct section *sec = &secs[i];
7975 if (sec->shdr.sh_type != SHT_SYMTAB) {
7976 @@ -365,7 +398,9 @@ static void read_symtabs(FILE *fp)
7977
7978 static void read_relocs(FILE *fp)
7979 {
7980 - int i,j;
7981 + unsigned int i,j;
7982 + uint32_t base;
7983 +
7984 for (i = 0; i < ehdr.e_shnum; i++) {
7985 struct section *sec = &secs[i];
7986 if (sec->shdr.sh_type != SHT_REL) {
7987 @@ -385,9 +420,18 @@ static void read_relocs(FILE *fp)
7988 die("Cannot read symbol table: %s\n",
7989 strerror(errno));
7990 }
7991 + base = 0;
7992 + for (j = 0; j < ehdr.e_phnum; j++) {
7993 + if (phdr[j].p_type != PT_LOAD )
7994 + continue;
7995 + 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)
7996 + continue;
7997 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
7998 + break;
7999 + }
8000 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
8001 Elf32_Rel *rel = &sec->reltab[j];
8002 - rel->r_offset = elf32_to_cpu(rel->r_offset);
8003 + rel->r_offset = elf32_to_cpu(rel->r_offset) + base;
8004 rel->r_info = elf32_to_cpu(rel->r_info);
8005 }
8006 }
8007 @@ -396,13 +440,13 @@ static void read_relocs(FILE *fp)
8008
8009 static void print_absolute_symbols(void)
8010 {
8011 - int i;
8012 + unsigned int i;
8013 printf("Absolute symbols\n");
8014 printf(" Num: Value Size Type Bind Visibility Name\n");
8015 for (i = 0; i < ehdr.e_shnum; i++) {
8016 struct section *sec = &secs[i];
8017 char *sym_strtab;
8018 - int j;
8019 + unsigned int j;
8020
8021 if (sec->shdr.sh_type != SHT_SYMTAB) {
8022 continue;
8023 @@ -429,14 +473,14 @@ static void print_absolute_symbols(void)
8024
8025 static void print_absolute_relocs(void)
8026 {
8027 - int i, printed = 0;
8028 + unsigned int i, printed = 0;
8029
8030 for (i = 0; i < ehdr.e_shnum; i++) {
8031 struct section *sec = &secs[i];
8032 struct section *sec_applies, *sec_symtab;
8033 char *sym_strtab;
8034 Elf32_Sym *sh_symtab;
8035 - int j;
8036 + unsigned int j;
8037 if (sec->shdr.sh_type != SHT_REL) {
8038 continue;
8039 }
8040 @@ -497,13 +541,13 @@ static void print_absolute_relocs(void)
8041
8042 static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym))
8043 {
8044 - int i;
8045 + unsigned int i;
8046 /* Walk through the relocations */
8047 for (i = 0; i < ehdr.e_shnum; i++) {
8048 char *sym_strtab;
8049 Elf32_Sym *sh_symtab;
8050 struct section *sec_applies, *sec_symtab;
8051 - int j;
8052 + unsigned int j;
8053 struct section *sec = &secs[i];
8054
8055 if (sec->shdr.sh_type != SHT_REL) {
8056 @@ -528,6 +572,22 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym))
8057 !is_rel_reloc(sym_name(sym_strtab, sym))) {
8058 continue;
8059 }
8060 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
8061 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
8062 + continue;
8063 +
8064 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_X86_32)
8065 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
8066 + if (!strcmp(sec_name(sym->st_shndx), ".module.text") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
8067 + continue;
8068 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
8069 + continue;
8070 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
8071 + continue;
8072 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
8073 + continue;
8074 +#endif
8075 +
8076 switch (r_type) {
8077 case R_386_NONE:
8078 case R_386_PC32:
8079 @@ -569,7 +629,7 @@ static int cmp_relocs(const void *va, const void *vb)
8080
8081 static void emit_relocs(int as_text)
8082 {
8083 - int i;
8084 + unsigned int i;
8085 /* Count how many relocations I have and allocate space for them. */
8086 reloc_count = 0;
8087 walk_relocs(count_reloc);
8088 @@ -663,6 +723,7 @@ int main(int argc, char **argv)
8089 fname, strerror(errno));
8090 }
8091 read_ehdr(fp);
8092 + read_phdrs(fp);
8093 read_shdrs(fp);
8094 read_strtabs(fp);
8095 read_symtabs(fp);
8096 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
8097 index 4d3ff03..e4972ff 100644
8098 --- a/arch/x86/boot/cpucheck.c
8099 +++ b/arch/x86/boot/cpucheck.c
8100 @@ -74,7 +74,7 @@ static int has_fpu(void)
8101 u16 fcw = -1, fsw = -1;
8102 u32 cr0;
8103
8104 - asm("movl %%cr0,%0" : "=r" (cr0));
8105 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
8106 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
8107 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
8108 asm volatile("movl %0,%%cr0" : : "r" (cr0));
8109 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
8110 {
8111 u32 f0, f1;
8112
8113 - asm("pushfl ; "
8114 + asm volatile("pushfl ; "
8115 "pushfl ; "
8116 "popl %0 ; "
8117 "movl %0,%1 ; "
8118 @@ -115,7 +115,7 @@ static void get_flags(void)
8119 set_bit(X86_FEATURE_FPU, cpu.flags);
8120
8121 if (has_eflag(X86_EFLAGS_ID)) {
8122 - asm("cpuid"
8123 + asm volatile("cpuid"
8124 : "=a" (max_intel_level),
8125 "=b" (cpu_vendor[0]),
8126 "=d" (cpu_vendor[1]),
8127 @@ -124,7 +124,7 @@ static void get_flags(void)
8128
8129 if (max_intel_level >= 0x00000001 &&
8130 max_intel_level <= 0x0000ffff) {
8131 - asm("cpuid"
8132 + asm volatile("cpuid"
8133 : "=a" (tfms),
8134 "=c" (cpu.flags[4]),
8135 "=d" (cpu.flags[0])
8136 @@ -136,7 +136,7 @@ static void get_flags(void)
8137 cpu.model += ((tfms >> 16) & 0xf) << 4;
8138 }
8139
8140 - asm("cpuid"
8141 + asm volatile("cpuid"
8142 : "=a" (max_amd_level)
8143 : "a" (0x80000000)
8144 : "ebx", "ecx", "edx");
8145 @@ -144,7 +144,7 @@ static void get_flags(void)
8146 if (max_amd_level >= 0x80000001 &&
8147 max_amd_level <= 0x8000ffff) {
8148 u32 eax = 0x80000001;
8149 - asm("cpuid"
8150 + asm volatile("cpuid"
8151 : "+a" (eax),
8152 "=c" (cpu.flags[6]),
8153 "=d" (cpu.flags[1])
8154 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
8155 u32 ecx = MSR_K7_HWCR;
8156 u32 eax, edx;
8157
8158 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
8159 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
8160 eax &= ~(1 << 15);
8161 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
8162 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
8163
8164 get_flags(); /* Make sure it really did something */
8165 err = check_flags();
8166 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
8167 u32 ecx = MSR_VIA_FCR;
8168 u32 eax, edx;
8169
8170 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
8171 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
8172 eax |= (1<<1)|(1<<7);
8173 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
8174 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
8175
8176 set_bit(X86_FEATURE_CX8, cpu.flags);
8177 err = check_flags();
8178 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
8179 u32 eax, edx;
8180 u32 level = 1;
8181
8182 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
8183 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
8184 - asm("cpuid"
8185 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
8186 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
8187 + asm volatile("cpuid"
8188 : "+a" (level), "=d" (cpu.flags[0])
8189 : : "ecx", "ebx");
8190 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
8191 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
8192
8193 err = check_flags();
8194 }
8195 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
8196 index f1bbeeb..aff09cb 100644
8197 --- a/arch/x86/boot/header.S
8198 +++ b/arch/x86/boot/header.S
8199 @@ -372,7 +372,7 @@ setup_data: .quad 0 # 64-bit physical pointer to
8200 # single linked list of
8201 # struct setup_data
8202
8203 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
8204 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
8205
8206 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
8207 #define VO_INIT_SIZE (VO__end - VO__text)
8208 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
8209 index db75d07..8e6d0af 100644
8210 --- a/arch/x86/boot/memory.c
8211 +++ b/arch/x86/boot/memory.c
8212 @@ -19,7 +19,7 @@
8213
8214 static int detect_memory_e820(void)
8215 {
8216 - int count = 0;
8217 + unsigned int count = 0;
8218 struct biosregs ireg, oreg;
8219 struct e820entry *desc = boot_params.e820_map;
8220 static struct e820entry buf; /* static so it is zeroed */
8221 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
8222 index 11e8c6e..fdbb1ed 100644
8223 --- a/arch/x86/boot/video-vesa.c
8224 +++ b/arch/x86/boot/video-vesa.c
8225 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
8226
8227 boot_params.screen_info.vesapm_seg = oreg.es;
8228 boot_params.screen_info.vesapm_off = oreg.di;
8229 + boot_params.screen_info.vesapm_size = oreg.cx;
8230 }
8231
8232 /*
8233 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
8234 index 43eda28..5ab5fdb 100644
8235 --- a/arch/x86/boot/video.c
8236 +++ b/arch/x86/boot/video.c
8237 @@ -96,7 +96,7 @@ static void store_mode_params(void)
8238 static unsigned int get_entry(void)
8239 {
8240 char entry_buf[4];
8241 - int i, len = 0;
8242 + unsigned int i, len = 0;
8243 int key;
8244 unsigned int v;
8245
8246 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
8247 index 5b577d5..3c1fed4 100644
8248 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
8249 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
8250 @@ -8,6 +8,8 @@
8251 * including this sentence is retained in full.
8252 */
8253
8254 +#include <asm/alternative-asm.h>
8255 +
8256 .extern crypto_ft_tab
8257 .extern crypto_it_tab
8258 .extern crypto_fl_tab
8259 @@ -71,6 +73,8 @@ FUNC: movq r1,r2; \
8260 je B192; \
8261 leaq 32(r9),r9;
8262
8263 +#define ret pax_force_retaddr 0, 1; ret
8264 +
8265 #define epilogue(r1,r2,r3,r4,r5,r6,r7,r8,r9) \
8266 movq r1,r2; \
8267 movq r3,r4; \
8268 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
8269 index be6d9e3..21fbbca 100644
8270 --- a/arch/x86/crypto/aesni-intel_asm.S
8271 +++ b/arch/x86/crypto/aesni-intel_asm.S
8272 @@ -31,6 +31,7 @@
8273
8274 #include <linux/linkage.h>
8275 #include <asm/inst.h>
8276 +#include <asm/alternative-asm.h>
8277
8278 #ifdef __x86_64__
8279 .data
8280 @@ -1436,7 +1437,9 @@ _return_T_done_decrypt:
8281 pop %r14
8282 pop %r13
8283 pop %r12
8284 + pax_force_retaddr 0, 1
8285 ret
8286 +ENDPROC(aesni_gcm_dec)
8287
8288
8289 /*****************************************************************************
8290 @@ -1699,7 +1702,9 @@ _return_T_done_encrypt:
8291 pop %r14
8292 pop %r13
8293 pop %r12
8294 + pax_force_retaddr 0, 1
8295 ret
8296 +ENDPROC(aesni_gcm_enc)
8297
8298 #endif
8299
8300 @@ -1714,6 +1719,7 @@ _key_expansion_256a:
8301 pxor %xmm1, %xmm0
8302 movaps %xmm0, (TKEYP)
8303 add $0x10, TKEYP
8304 + pax_force_retaddr_bts
8305 ret
8306
8307 .align 4
8308 @@ -1738,6 +1744,7 @@ _key_expansion_192a:
8309 shufps $0b01001110, %xmm2, %xmm1
8310 movaps %xmm1, 0x10(TKEYP)
8311 add $0x20, TKEYP
8312 + pax_force_retaddr_bts
8313 ret
8314
8315 .align 4
8316 @@ -1757,6 +1764,7 @@ _key_expansion_192b:
8317
8318 movaps %xmm0, (TKEYP)
8319 add $0x10, TKEYP
8320 + pax_force_retaddr_bts
8321 ret
8322
8323 .align 4
8324 @@ -1769,6 +1777,7 @@ _key_expansion_256b:
8325 pxor %xmm1, %xmm2
8326 movaps %xmm2, (TKEYP)
8327 add $0x10, TKEYP
8328 + pax_force_retaddr_bts
8329 ret
8330
8331 /*
8332 @@ -1881,7 +1890,9 @@ ENTRY(aesni_set_key)
8333 #ifndef __x86_64__
8334 popl KEYP
8335 #endif
8336 + pax_force_retaddr 0, 1
8337 ret
8338 +ENDPROC(aesni_set_key)
8339
8340 /*
8341 * void aesni_enc(struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src)
8342 @@ -1902,7 +1913,9 @@ ENTRY(aesni_enc)
8343 popl KLEN
8344 popl KEYP
8345 #endif
8346 + pax_force_retaddr 0, 1
8347 ret
8348 +ENDPROC(aesni_enc)
8349
8350 /*
8351 * _aesni_enc1: internal ABI
8352 @@ -1959,6 +1972,7 @@ _aesni_enc1:
8353 AESENC KEY STATE
8354 movaps 0x70(TKEYP), KEY
8355 AESENCLAST KEY STATE
8356 + pax_force_retaddr_bts
8357 ret
8358
8359 /*
8360 @@ -2067,6 +2081,7 @@ _aesni_enc4:
8361 AESENCLAST KEY STATE2
8362 AESENCLAST KEY STATE3
8363 AESENCLAST KEY STATE4
8364 + pax_force_retaddr_bts
8365 ret
8366
8367 /*
8368 @@ -2089,7 +2104,9 @@ ENTRY(aesni_dec)
8369 popl KLEN
8370 popl KEYP
8371 #endif
8372 + pax_force_retaddr 0, 1
8373 ret
8374 +ENDPROC(aesni_dec)
8375
8376 /*
8377 * _aesni_dec1: internal ABI
8378 @@ -2146,6 +2163,7 @@ _aesni_dec1:
8379 AESDEC KEY STATE
8380 movaps 0x70(TKEYP), KEY
8381 AESDECLAST KEY STATE
8382 + pax_force_retaddr_bts
8383 ret
8384
8385 /*
8386 @@ -2254,6 +2272,7 @@ _aesni_dec4:
8387 AESDECLAST KEY STATE2
8388 AESDECLAST KEY STATE3
8389 AESDECLAST KEY STATE4
8390 + pax_force_retaddr_bts
8391 ret
8392
8393 /*
8394 @@ -2311,7 +2330,9 @@ ENTRY(aesni_ecb_enc)
8395 popl KEYP
8396 popl LEN
8397 #endif
8398 + pax_force_retaddr 0, 1
8399 ret
8400 +ENDPROC(aesni_ecb_enc)
8401
8402 /*
8403 * void aesni_ecb_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
8404 @@ -2369,7 +2390,9 @@ ENTRY(aesni_ecb_dec)
8405 popl KEYP
8406 popl LEN
8407 #endif
8408 + pax_force_retaddr 0, 1
8409 ret
8410 +ENDPROC(aesni_ecb_dec)
8411
8412 /*
8413 * void aesni_cbc_enc(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
8414 @@ -2410,7 +2433,9 @@ ENTRY(aesni_cbc_enc)
8415 popl LEN
8416 popl IVP
8417 #endif
8418 + pax_force_retaddr 0, 1
8419 ret
8420 +ENDPROC(aesni_cbc_enc)
8421
8422 /*
8423 * void aesni_cbc_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
8424 @@ -2498,7 +2523,9 @@ ENTRY(aesni_cbc_dec)
8425 popl LEN
8426 popl IVP
8427 #endif
8428 + pax_force_retaddr 0, 1
8429 ret
8430 +ENDPROC(aesni_cbc_dec)
8431
8432 #ifdef __x86_64__
8433 .align 16
8434 @@ -2524,6 +2551,7 @@ _aesni_inc_init:
8435 mov $1, TCTR_LOW
8436 MOVQ_R64_XMM TCTR_LOW INC
8437 MOVQ_R64_XMM CTR TCTR_LOW
8438 + pax_force_retaddr_bts
8439 ret
8440
8441 /*
8442 @@ -2552,6 +2580,7 @@ _aesni_inc:
8443 .Linc_low:
8444 movaps CTR, IV
8445 PSHUFB_XMM BSWAP_MASK IV
8446 + pax_force_retaddr_bts
8447 ret
8448
8449 /*
8450 @@ -2612,5 +2641,7 @@ ENTRY(aesni_ctr_enc)
8451 .Lctr_enc_ret:
8452 movups IV, (IVP)
8453 .Lctr_enc_just_ret:
8454 + pax_force_retaddr 0, 1
8455 ret
8456 +ENDPROC(aesni_ctr_enc)
8457 #endif
8458 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
8459 index 391d245..67f35c2 100644
8460 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
8461 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
8462 @@ -20,6 +20,8 @@
8463 *
8464 */
8465
8466 +#include <asm/alternative-asm.h>
8467 +
8468 .file "blowfish-x86_64-asm.S"
8469 .text
8470
8471 @@ -151,9 +153,11 @@ __blowfish_enc_blk:
8472 jnz __enc_xor;
8473
8474 write_block();
8475 + pax_force_retaddr 0, 1
8476 ret;
8477 __enc_xor:
8478 xor_block();
8479 + pax_force_retaddr 0, 1
8480 ret;
8481
8482 .align 8
8483 @@ -188,6 +192,7 @@ blowfish_dec_blk:
8484
8485 movq %r11, %rbp;
8486
8487 + pax_force_retaddr 0, 1
8488 ret;
8489
8490 /**********************************************************************
8491 @@ -342,6 +347,7 @@ __blowfish_enc_blk_4way:
8492
8493 popq %rbx;
8494 popq %rbp;
8495 + pax_force_retaddr 0, 1
8496 ret;
8497
8498 __enc_xor4:
8499 @@ -349,6 +355,7 @@ __enc_xor4:
8500
8501 popq %rbx;
8502 popq %rbp;
8503 + pax_force_retaddr 0, 1
8504 ret;
8505
8506 .align 8
8507 @@ -386,5 +393,6 @@ blowfish_dec_blk_4way:
8508 popq %rbx;
8509 popq %rbp;
8510
8511 + pax_force_retaddr 0, 1
8512 ret;
8513
8514 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
8515 index 6214a9b..1f4fc9a 100644
8516 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
8517 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
8518 @@ -1,3 +1,5 @@
8519 +#include <asm/alternative-asm.h>
8520 +
8521 # enter ECRYPT_encrypt_bytes
8522 .text
8523 .p2align 5
8524 @@ -790,6 +792,7 @@ ECRYPT_encrypt_bytes:
8525 add %r11,%rsp
8526 mov %rdi,%rax
8527 mov %rsi,%rdx
8528 + pax_force_retaddr 0, 1
8529 ret
8530 # bytesatleast65:
8531 ._bytesatleast65:
8532 @@ -891,6 +894,7 @@ ECRYPT_keysetup:
8533 add %r11,%rsp
8534 mov %rdi,%rax
8535 mov %rsi,%rdx
8536 + pax_force_retaddr
8537 ret
8538 # enter ECRYPT_ivsetup
8539 .text
8540 @@ -917,4 +921,5 @@ ECRYPT_ivsetup:
8541 add %r11,%rsp
8542 mov %rdi,%rax
8543 mov %rsi,%rdx
8544 + pax_force_retaddr
8545 ret
8546 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
8547 index 7f24a15..9cd3ffe 100644
8548 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
8549 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
8550 @@ -24,6 +24,8 @@
8551 *
8552 */
8553
8554 +#include <asm/alternative-asm.h>
8555 +
8556 .file "serpent-sse2-x86_64-asm_64.S"
8557 .text
8558
8559 @@ -695,12 +697,14 @@ __serpent_enc_blk_8way:
8560 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
8561 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
8562
8563 + pax_force_retaddr
8564 ret;
8565
8566 __enc_xor8:
8567 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
8568 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
8569
8570 + pax_force_retaddr
8571 ret;
8572
8573 .align 8
8574 @@ -758,4 +762,5 @@ serpent_dec_blk_8way:
8575 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
8576 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
8577
8578 + pax_force_retaddr
8579 ret;
8580 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
8581 index b2c2f57..8470cab 100644
8582 --- a/arch/x86/crypto/sha1_ssse3_asm.S
8583 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
8584 @@ -28,6 +28,8 @@
8585 * (at your option) any later version.
8586 */
8587
8588 +#include <asm/alternative-asm.h>
8589 +
8590 #define CTX %rdi // arg1
8591 #define BUF %rsi // arg2
8592 #define CNT %rdx // arg3
8593 @@ -104,6 +106,7 @@
8594 pop %r12
8595 pop %rbp
8596 pop %rbx
8597 + pax_force_retaddr 0, 1
8598 ret
8599
8600 .size \name, .-\name
8601 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
8602 index 5b012a2..36d5364 100644
8603 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
8604 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
8605 @@ -20,6 +20,8 @@
8606 *
8607 */
8608
8609 +#include <asm/alternative-asm.h>
8610 +
8611 .file "twofish-x86_64-asm-3way.S"
8612 .text
8613
8614 @@ -260,6 +262,7 @@ __twofish_enc_blk_3way:
8615 popq %r13;
8616 popq %r14;
8617 popq %r15;
8618 + pax_force_retaddr 0, 1
8619 ret;
8620
8621 __enc_xor3:
8622 @@ -271,6 +274,7 @@ __enc_xor3:
8623 popq %r13;
8624 popq %r14;
8625 popq %r15;
8626 + pax_force_retaddr 0, 1
8627 ret;
8628
8629 .global twofish_dec_blk_3way
8630 @@ -312,5 +316,6 @@ twofish_dec_blk_3way:
8631 popq %r13;
8632 popq %r14;
8633 popq %r15;
8634 + pax_force_retaddr 0, 1
8635 ret;
8636
8637 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
8638 index 7bcf3fc..f53832f 100644
8639 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
8640 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
8641 @@ -21,6 +21,7 @@
8642 .text
8643
8644 #include <asm/asm-offsets.h>
8645 +#include <asm/alternative-asm.h>
8646
8647 #define a_offset 0
8648 #define b_offset 4
8649 @@ -268,6 +269,7 @@ twofish_enc_blk:
8650
8651 popq R1
8652 movq $1,%rax
8653 + pax_force_retaddr 0, 1
8654 ret
8655
8656 twofish_dec_blk:
8657 @@ -319,4 +321,5 @@ twofish_dec_blk:
8658
8659 popq R1
8660 movq $1,%rax
8661 + pax_force_retaddr 0, 1
8662 ret
8663 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
8664 index 39e4909..887aa7e 100644
8665 --- a/arch/x86/ia32/ia32_aout.c
8666 +++ b/arch/x86/ia32/ia32_aout.c
8667 @@ -162,6 +162,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
8668 unsigned long dump_start, dump_size;
8669 struct user32 dump;
8670
8671 + memset(&dump, 0, sizeof(dump));
8672 +
8673 fs = get_fs();
8674 set_fs(KERNEL_DS);
8675 has_dumped = 1;
8676 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
8677 index 6557769..ef6ae89 100644
8678 --- a/arch/x86/ia32/ia32_signal.c
8679 +++ b/arch/x86/ia32/ia32_signal.c
8680 @@ -169,7 +169,7 @@ asmlinkage long sys32_sigaltstack(const stack_ia32_t __user *uss_ptr,
8681 }
8682 seg = get_fs();
8683 set_fs(KERNEL_DS);
8684 - ret = do_sigaltstack(uss_ptr ? &uss : NULL, &uoss, regs->sp);
8685 + ret = do_sigaltstack(uss_ptr ? (const stack_t __force_user *)&uss : NULL, (stack_t __force_user *)&uoss, regs->sp);
8686 set_fs(seg);
8687 if (ret >= 0 && uoss_ptr) {
8688 if (!access_ok(VERIFY_WRITE, uoss_ptr, sizeof(stack_ia32_t)))
8689 @@ -370,7 +370,7 @@ static int ia32_setup_sigcontext(struct sigcontext_ia32 __user *sc,
8690 */
8691 static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
8692 size_t frame_size,
8693 - void **fpstate)
8694 + void __user **fpstate)
8695 {
8696 unsigned long sp;
8697
8698 @@ -391,7 +391,7 @@ static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
8699
8700 if (used_math()) {
8701 sp = sp - sig_xstate_ia32_size;
8702 - *fpstate = (struct _fpstate_ia32 *) sp;
8703 + *fpstate = (struct _fpstate_ia32 __user *) sp;
8704 if (save_i387_xstate_ia32(*fpstate) < 0)
8705 return (void __user *) -1L;
8706 }
8707 @@ -399,7 +399,7 @@ static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
8708 sp -= frame_size;
8709 /* Align the stack pointer according to the i386 ABI,
8710 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
8711 - sp = ((sp + 4) & -16ul) - 4;
8712 + sp = ((sp - 12) & -16ul) - 4;
8713 return (void __user *) sp;
8714 }
8715
8716 @@ -457,7 +457,7 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
8717 * These are actually not used anymore, but left because some
8718 * gdb versions depend on them as a marker.
8719 */
8720 - put_user_ex(*((u64 *)&code), (u64 *)frame->retcode);
8721 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
8722 } put_user_catch(err);
8723
8724 if (err)
8725 @@ -499,7 +499,7 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
8726 0xb8,
8727 __NR_ia32_rt_sigreturn,
8728 0x80cd,
8729 - 0,
8730 + 0
8731 };
8732
8733 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
8734 @@ -529,16 +529,18 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
8735
8736 if (ka->sa.sa_flags & SA_RESTORER)
8737 restorer = ka->sa.sa_restorer;
8738 + else if (current->mm->context.vdso)
8739 + /* Return stub is in 32bit vsyscall page */
8740 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
8741 else
8742 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
8743 - rt_sigreturn);
8744 + restorer = &frame->retcode;
8745 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
8746
8747 /*
8748 * Not actually used anymore, but left because some gdb
8749 * versions need it.
8750 */
8751 - put_user_ex(*((u64 *)&code), (u64 *)frame->retcode);
8752 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
8753 } put_user_catch(err);
8754
8755 if (err)
8756 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
8757 index e3e7340..05ed805 100644
8758 --- a/arch/x86/ia32/ia32entry.S
8759 +++ b/arch/x86/ia32/ia32entry.S
8760 @@ -13,8 +13,10 @@
8761 #include <asm/thread_info.h>
8762 #include <asm/segment.h>
8763 #include <asm/irqflags.h>
8764 +#include <asm/pgtable.h>
8765 #include <linux/linkage.h>
8766 #include <linux/err.h>
8767 +#include <asm/alternative-asm.h>
8768
8769 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
8770 #include <linux/elf-em.h>
8771 @@ -94,6 +96,32 @@ ENTRY(native_irq_enable_sysexit)
8772 ENDPROC(native_irq_enable_sysexit)
8773 #endif
8774
8775 + .macro pax_enter_kernel_user
8776 + pax_set_fptr_mask
8777 +#ifdef CONFIG_PAX_MEMORY_UDEREF
8778 + call pax_enter_kernel_user
8779 +#endif
8780 + .endm
8781 +
8782 + .macro pax_exit_kernel_user
8783 +#ifdef CONFIG_PAX_MEMORY_UDEREF
8784 + call pax_exit_kernel_user
8785 +#endif
8786 +#ifdef CONFIG_PAX_RANDKSTACK
8787 + pushq %rax
8788 + pushq %r11
8789 + call pax_randomize_kstack
8790 + popq %r11
8791 + popq %rax
8792 +#endif
8793 + .endm
8794 +
8795 +.macro pax_erase_kstack
8796 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
8797 + call pax_erase_kstack
8798 +#endif
8799 +.endm
8800 +
8801 /*
8802 * 32bit SYSENTER instruction entry.
8803 *
8804 @@ -120,12 +148,6 @@ ENTRY(ia32_sysenter_target)
8805 CFI_REGISTER rsp,rbp
8806 SWAPGS_UNSAFE_STACK
8807 movq PER_CPU_VAR(kernel_stack), %rsp
8808 - addq $(KERNEL_STACK_OFFSET),%rsp
8809 - /*
8810 - * No need to follow this irqs on/off section: the syscall
8811 - * disabled irqs, here we enable it straight after entry:
8812 - */
8813 - ENABLE_INTERRUPTS(CLBR_NONE)
8814 movl %ebp,%ebp /* zero extension */
8815 pushq_cfi $__USER32_DS
8816 /*CFI_REL_OFFSET ss,0*/
8817 @@ -133,24 +155,39 @@ ENTRY(ia32_sysenter_target)
8818 CFI_REL_OFFSET rsp,0
8819 pushfq_cfi
8820 /*CFI_REL_OFFSET rflags,0*/
8821 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
8822 - CFI_REGISTER rip,r10
8823 + orl $X86_EFLAGS_IF,(%rsp)
8824 + GET_THREAD_INFO(%r11)
8825 + movl TI_sysenter_return(%r11), %r11d
8826 + CFI_REGISTER rip,r11
8827 pushq_cfi $__USER32_CS
8828 /*CFI_REL_OFFSET cs,0*/
8829 movl %eax, %eax
8830 - pushq_cfi %r10
8831 + pushq_cfi %r11
8832 CFI_REL_OFFSET rip,0
8833 pushq_cfi %rax
8834 cld
8835 SAVE_ARGS 0,1,0
8836 + pax_enter_kernel_user
8837 + /*
8838 + * No need to follow this irqs on/off section: the syscall
8839 + * disabled irqs, here we enable it straight after entry:
8840 + */
8841 + ENABLE_INTERRUPTS(CLBR_NONE)
8842 /* no need to do an access_ok check here because rbp has been
8843 32bit zero extended */
8844 +
8845 +#ifdef CONFIG_PAX_MEMORY_UDEREF
8846 + mov $PAX_USER_SHADOW_BASE,%r11
8847 + add %r11,%rbp
8848 +#endif
8849 +
8850 1: movl (%rbp),%ebp
8851 .section __ex_table,"a"
8852 .quad 1b,ia32_badarg
8853 .previous
8854 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
8855 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
8856 + GET_THREAD_INFO(%r11)
8857 + orl $TS_COMPAT,TI_status(%r11)
8858 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
8859 CFI_REMEMBER_STATE
8860 jnz sysenter_tracesys
8861 cmpq $(IA32_NR_syscalls-1),%rax
8862 @@ -160,12 +197,15 @@ sysenter_do_call:
8863 sysenter_dispatch:
8864 call *ia32_sys_call_table(,%rax,8)
8865 movq %rax,RAX-ARGOFFSET(%rsp)
8866 + GET_THREAD_INFO(%r11)
8867 DISABLE_INTERRUPTS(CLBR_NONE)
8868 TRACE_IRQS_OFF
8869 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
8870 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
8871 jnz sysexit_audit
8872 sysexit_from_sys_call:
8873 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
8874 + pax_exit_kernel_user
8875 + pax_erase_kstack
8876 + andl $~TS_COMPAT,TI_status(%r11)
8877 /* clear IF, that popfq doesn't enable interrupts early */
8878 andl $~0x200,EFLAGS-R11(%rsp)
8879 movl RIP-R11(%rsp),%edx /* User %eip */
8880 @@ -191,6 +231,9 @@ sysexit_from_sys_call:
8881 movl %eax,%esi /* 2nd arg: syscall number */
8882 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
8883 call __audit_syscall_entry
8884 +
8885 + pax_erase_kstack
8886 +
8887 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
8888 cmpq $(IA32_NR_syscalls-1),%rax
8889 ja ia32_badsys
8890 @@ -202,7 +245,7 @@ sysexit_from_sys_call:
8891 .endm
8892
8893 .macro auditsys_exit exit
8894 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
8895 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
8896 jnz ia32_ret_from_sys_call
8897 TRACE_IRQS_ON
8898 sti
8899 @@ -213,11 +256,12 @@ sysexit_from_sys_call:
8900 1: setbe %al /* 1 if error, 0 if not */
8901 movzbl %al,%edi /* zero-extend that into %edi */
8902 call __audit_syscall_exit
8903 + GET_THREAD_INFO(%r11)
8904 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
8905 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
8906 cli
8907 TRACE_IRQS_OFF
8908 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
8909 + testl %edi,TI_flags(%r11)
8910 jz \exit
8911 CLEAR_RREGS -ARGOFFSET
8912 jmp int_with_check
8913 @@ -235,7 +279,7 @@ sysexit_audit:
8914
8915 sysenter_tracesys:
8916 #ifdef CONFIG_AUDITSYSCALL
8917 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
8918 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
8919 jz sysenter_auditsys
8920 #endif
8921 SAVE_REST
8922 @@ -243,6 +287,9 @@ sysenter_tracesys:
8923 movq $-ENOSYS,RAX(%rsp)/* ptrace can change this for a bad syscall */
8924 movq %rsp,%rdi /* &pt_regs -> arg1 */
8925 call syscall_trace_enter
8926 +
8927 + pax_erase_kstack
8928 +
8929 LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */
8930 RESTORE_REST
8931 cmpq $(IA32_NR_syscalls-1),%rax
8932 @@ -274,19 +321,20 @@ ENDPROC(ia32_sysenter_target)
8933 ENTRY(ia32_cstar_target)
8934 CFI_STARTPROC32 simple
8935 CFI_SIGNAL_FRAME
8936 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
8937 + CFI_DEF_CFA rsp,0
8938 CFI_REGISTER rip,rcx
8939 /*CFI_REGISTER rflags,r11*/
8940 SWAPGS_UNSAFE_STACK
8941 movl %esp,%r8d
8942 CFI_REGISTER rsp,r8
8943 movq PER_CPU_VAR(kernel_stack),%rsp
8944 + SAVE_ARGS 8*6,0,0
8945 + pax_enter_kernel_user
8946 /*
8947 * No need to follow this irqs on/off section: the syscall
8948 * disabled irqs and here we enable it straight after entry:
8949 */
8950 ENABLE_INTERRUPTS(CLBR_NONE)
8951 - SAVE_ARGS 8,0,0
8952 movl %eax,%eax /* zero extension */
8953 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
8954 movq %rcx,RIP-ARGOFFSET(%rsp)
8955 @@ -302,12 +350,19 @@ ENTRY(ia32_cstar_target)
8956 /* no need to do an access_ok check here because r8 has been
8957 32bit zero extended */
8958 /* hardware stack frame is complete now */
8959 +
8960 +#ifdef CONFIG_PAX_MEMORY_UDEREF
8961 + mov $PAX_USER_SHADOW_BASE,%r11
8962 + add %r11,%r8
8963 +#endif
8964 +
8965 1: movl (%r8),%r9d
8966 .section __ex_table,"a"
8967 .quad 1b,ia32_badarg
8968 .previous
8969 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
8970 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
8971 + GET_THREAD_INFO(%r11)
8972 + orl $TS_COMPAT,TI_status(%r11)
8973 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
8974 CFI_REMEMBER_STATE
8975 jnz cstar_tracesys
8976 cmpq $IA32_NR_syscalls-1,%rax
8977 @@ -317,12 +372,15 @@ cstar_do_call:
8978 cstar_dispatch:
8979 call *ia32_sys_call_table(,%rax,8)
8980 movq %rax,RAX-ARGOFFSET(%rsp)
8981 + GET_THREAD_INFO(%r11)
8982 DISABLE_INTERRUPTS(CLBR_NONE)
8983 TRACE_IRQS_OFF
8984 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
8985 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
8986 jnz sysretl_audit
8987 sysretl_from_sys_call:
8988 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
8989 + pax_exit_kernel_user
8990 + pax_erase_kstack
8991 + andl $~TS_COMPAT,TI_status(%r11)
8992 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
8993 movl RIP-ARGOFFSET(%rsp),%ecx
8994 CFI_REGISTER rip,rcx
8995 @@ -350,7 +408,7 @@ sysretl_audit:
8996
8997 cstar_tracesys:
8998 #ifdef CONFIG_AUDITSYSCALL
8999 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
9000 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
9001 jz cstar_auditsys
9002 #endif
9003 xchgl %r9d,%ebp
9004 @@ -359,6 +417,9 @@ cstar_tracesys:
9005 movq $-ENOSYS,RAX(%rsp) /* ptrace can change this for a bad syscall */
9006 movq %rsp,%rdi /* &pt_regs -> arg1 */
9007 call syscall_trace_enter
9008 +
9009 + pax_erase_kstack
9010 +
9011 LOAD_ARGS32 ARGOFFSET, 1 /* reload args from stack in case ptrace changed it */
9012 RESTORE_REST
9013 xchgl %ebp,%r9d
9014 @@ -404,19 +465,21 @@ ENTRY(ia32_syscall)
9015 CFI_REL_OFFSET rip,RIP-RIP
9016 PARAVIRT_ADJUST_EXCEPTION_FRAME
9017 SWAPGS
9018 - /*
9019 - * No need to follow this irqs on/off section: the syscall
9020 - * disabled irqs and here we enable it straight after entry:
9021 - */
9022 - ENABLE_INTERRUPTS(CLBR_NONE)
9023 movl %eax,%eax
9024 pushq_cfi %rax
9025 cld
9026 /* note the registers are not zero extended to the sf.
9027 this could be a problem. */
9028 SAVE_ARGS 0,1,0
9029 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
9030 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
9031 + pax_enter_kernel_user
9032 + /*
9033 + * No need to follow this irqs on/off section: the syscall
9034 + * disabled irqs and here we enable it straight after entry:
9035 + */
9036 + ENABLE_INTERRUPTS(CLBR_NONE)
9037 + GET_THREAD_INFO(%r11)
9038 + orl $TS_COMPAT,TI_status(%r11)
9039 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
9040 jnz ia32_tracesys
9041 cmpq $(IA32_NR_syscalls-1),%rax
9042 ja ia32_badsys
9043 @@ -435,6 +498,9 @@ ia32_tracesys:
9044 movq $-ENOSYS,RAX(%rsp) /* ptrace can change this for a bad syscall */
9045 movq %rsp,%rdi /* &pt_regs -> arg1 */
9046 call syscall_trace_enter
9047 +
9048 + pax_erase_kstack
9049 +
9050 LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */
9051 RESTORE_REST
9052 cmpq $(IA32_NR_syscalls-1),%rax
9053 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
9054 index f6f5c53..b358b28 100644
9055 --- a/arch/x86/ia32/sys_ia32.c
9056 +++ b/arch/x86/ia32/sys_ia32.c
9057 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
9058 */
9059 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
9060 {
9061 - typeof(ubuf->st_uid) uid = 0;
9062 - typeof(ubuf->st_gid) gid = 0;
9063 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
9064 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
9065 SET_UID(uid, stat->uid);
9066 SET_GID(gid, stat->gid);
9067 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
9068 @@ -308,8 +308,8 @@ asmlinkage long sys32_rt_sigprocmask(int how, compat_sigset_t __user *set,
9069 }
9070 set_fs(KERNEL_DS);
9071 ret = sys_rt_sigprocmask(how,
9072 - set ? (sigset_t __user *)&s : NULL,
9073 - oset ? (sigset_t __user *)&s : NULL,
9074 + set ? (sigset_t __force_user *)&s : NULL,
9075 + oset ? (sigset_t __force_user *)&s : NULL,
9076 sigsetsize);
9077 set_fs(old_fs);
9078 if (ret)
9079 @@ -332,7 +332,7 @@ asmlinkage long sys32_alarm(unsigned int seconds)
9080 return alarm_setitimer(seconds);
9081 }
9082
9083 -asmlinkage long sys32_waitpid(compat_pid_t pid, unsigned int *stat_addr,
9084 +asmlinkage long sys32_waitpid(compat_pid_t pid, unsigned int __user *stat_addr,
9085 int options)
9086 {
9087 return compat_sys_wait4(pid, stat_addr, options, NULL);
9088 @@ -353,7 +353,7 @@ asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
9089 mm_segment_t old_fs = get_fs();
9090
9091 set_fs(KERNEL_DS);
9092 - ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
9093 + ret = sys_sched_rr_get_interval(pid, (struct timespec __force_user *)&t);
9094 set_fs(old_fs);
9095 if (put_compat_timespec(&t, interval))
9096 return -EFAULT;
9097 @@ -369,7 +369,7 @@ asmlinkage long sys32_rt_sigpending(compat_sigset_t __user *set,
9098 mm_segment_t old_fs = get_fs();
9099
9100 set_fs(KERNEL_DS);
9101 - ret = sys_rt_sigpending((sigset_t __user *)&s, sigsetsize);
9102 + ret = sys_rt_sigpending((sigset_t __force_user *)&s, sigsetsize);
9103 set_fs(old_fs);
9104 if (!ret) {
9105 switch (_NSIG_WORDS) {
9106 @@ -394,7 +394,7 @@ asmlinkage long sys32_rt_sigqueueinfo(int pid, int sig,
9107 if (copy_siginfo_from_user32(&info, uinfo))
9108 return -EFAULT;
9109 set_fs(KERNEL_DS);
9110 - ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *)&info);
9111 + ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __force_user *)&info);
9112 set_fs(old_fs);
9113 return ret;
9114 }
9115 @@ -439,7 +439,7 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd,
9116 return -EFAULT;
9117
9118 set_fs(KERNEL_DS);
9119 - ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL,
9120 + ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __force_user *)&of : NULL,
9121 count);
9122 set_fs(old_fs);
9123
9124 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
9125 index 952bd01..7692c6f 100644
9126 --- a/arch/x86/include/asm/alternative-asm.h
9127 +++ b/arch/x86/include/asm/alternative-asm.h
9128 @@ -15,6 +15,45 @@
9129 .endm
9130 #endif
9131
9132 +#ifdef KERNEXEC_PLUGIN
9133 + .macro pax_force_retaddr_bts rip=0
9134 + btsq $63,\rip(%rsp)
9135 + .endm
9136 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
9137 + .macro pax_force_retaddr rip=0, reload=0
9138 + btsq $63,\rip(%rsp)
9139 + .endm
9140 + .macro pax_force_fptr ptr
9141 + btsq $63,\ptr
9142 + .endm
9143 + .macro pax_set_fptr_mask
9144 + .endm
9145 +#endif
9146 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
9147 + .macro pax_force_retaddr rip=0, reload=0
9148 + .if \reload
9149 + pax_set_fptr_mask
9150 + .endif
9151 + orq %r10,\rip(%rsp)
9152 + .endm
9153 + .macro pax_force_fptr ptr
9154 + orq %r10,\ptr
9155 + .endm
9156 + .macro pax_set_fptr_mask
9157 + movabs $0x8000000000000000,%r10
9158 + .endm
9159 +#endif
9160 +#else
9161 + .macro pax_force_retaddr rip=0, reload=0
9162 + .endm
9163 + .macro pax_force_fptr ptr
9164 + .endm
9165 + .macro pax_force_retaddr_bts rip=0
9166 + .endm
9167 + .macro pax_set_fptr_mask
9168 + .endm
9169 +#endif
9170 +
9171 .macro altinstruction_entry orig alt feature orig_len alt_len
9172 .long \orig - .
9173 .long \alt - .
9174 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
9175 index 37ad100..7d47faa 100644
9176 --- a/arch/x86/include/asm/alternative.h
9177 +++ b/arch/x86/include/asm/alternative.h
9178 @@ -89,7 +89,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
9179 ".section .discard,\"aw\",@progbits\n" \
9180 " .byte 0xff + (664f-663f) - (662b-661b)\n" /* rlen <= slen */ \
9181 ".previous\n" \
9182 - ".section .altinstr_replacement, \"ax\"\n" \
9183 + ".section .altinstr_replacement, \"a\"\n" \
9184 "663:\n\t" newinstr "\n664:\n" /* replacement */ \
9185 ".previous"
9186
9187 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
9188 index 3ab9bdd..238033e 100644
9189 --- a/arch/x86/include/asm/apic.h
9190 +++ b/arch/x86/include/asm/apic.h
9191 @@ -45,7 +45,7 @@ static inline void generic_apic_probe(void)
9192
9193 #ifdef CONFIG_X86_LOCAL_APIC
9194
9195 -extern unsigned int apic_verbosity;
9196 +extern int apic_verbosity;
9197 extern int local_apic_timer_c2_ok;
9198
9199 extern int disable_apic;
9200 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
9201 index 20370c6..a2eb9b0 100644
9202 --- a/arch/x86/include/asm/apm.h
9203 +++ b/arch/x86/include/asm/apm.h
9204 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
9205 __asm__ __volatile__(APM_DO_ZERO_SEGS
9206 "pushl %%edi\n\t"
9207 "pushl %%ebp\n\t"
9208 - "lcall *%%cs:apm_bios_entry\n\t"
9209 + "lcall *%%ss:apm_bios_entry\n\t"
9210 "setc %%al\n\t"
9211 "popl %%ebp\n\t"
9212 "popl %%edi\n\t"
9213 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
9214 __asm__ __volatile__(APM_DO_ZERO_SEGS
9215 "pushl %%edi\n\t"
9216 "pushl %%ebp\n\t"
9217 - "lcall *%%cs:apm_bios_entry\n\t"
9218 + "lcall *%%ss:apm_bios_entry\n\t"
9219 "setc %%bl\n\t"
9220 "popl %%ebp\n\t"
9221 "popl %%edi\n\t"
9222 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
9223 index 58cb6d4..ca9010d 100644
9224 --- a/arch/x86/include/asm/atomic.h
9225 +++ b/arch/x86/include/asm/atomic.h
9226 @@ -22,7 +22,18 @@
9227 */
9228 static inline int atomic_read(const atomic_t *v)
9229 {
9230 - return (*(volatile int *)&(v)->counter);
9231 + return (*(volatile const int *)&(v)->counter);
9232 +}
9233 +
9234 +/**
9235 + * atomic_read_unchecked - read atomic variable
9236 + * @v: pointer of type atomic_unchecked_t
9237 + *
9238 + * Atomically reads the value of @v.
9239 + */
9240 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
9241 +{
9242 + return (*(volatile const int *)&(v)->counter);
9243 }
9244
9245 /**
9246 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
9247 }
9248
9249 /**
9250 + * atomic_set_unchecked - set atomic variable
9251 + * @v: pointer of type atomic_unchecked_t
9252 + * @i: required value
9253 + *
9254 + * Atomically sets the value of @v to @i.
9255 + */
9256 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
9257 +{
9258 + v->counter = i;
9259 +}
9260 +
9261 +/**
9262 * atomic_add - add integer to atomic variable
9263 * @i: integer value to add
9264 * @v: pointer of type atomic_t
9265 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
9266 */
9267 static inline void atomic_add(int i, atomic_t *v)
9268 {
9269 - asm volatile(LOCK_PREFIX "addl %1,%0"
9270 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
9271 +
9272 +#ifdef CONFIG_PAX_REFCOUNT
9273 + "jno 0f\n"
9274 + LOCK_PREFIX "subl %1,%0\n"
9275 + "int $4\n0:\n"
9276 + _ASM_EXTABLE(0b, 0b)
9277 +#endif
9278 +
9279 + : "+m" (v->counter)
9280 + : "ir" (i));
9281 +}
9282 +
9283 +/**
9284 + * atomic_add_unchecked - add integer to atomic variable
9285 + * @i: integer value to add
9286 + * @v: pointer of type atomic_unchecked_t
9287 + *
9288 + * Atomically adds @i to @v.
9289 + */
9290 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
9291 +{
9292 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
9293 : "+m" (v->counter)
9294 : "ir" (i));
9295 }
9296 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
9297 */
9298 static inline void atomic_sub(int i, atomic_t *v)
9299 {
9300 - asm volatile(LOCK_PREFIX "subl %1,%0"
9301 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
9302 +
9303 +#ifdef CONFIG_PAX_REFCOUNT
9304 + "jno 0f\n"
9305 + LOCK_PREFIX "addl %1,%0\n"
9306 + "int $4\n0:\n"
9307 + _ASM_EXTABLE(0b, 0b)
9308 +#endif
9309 +
9310 + : "+m" (v->counter)
9311 + : "ir" (i));
9312 +}
9313 +
9314 +/**
9315 + * atomic_sub_unchecked - subtract integer from atomic variable
9316 + * @i: integer value to subtract
9317 + * @v: pointer of type atomic_unchecked_t
9318 + *
9319 + * Atomically subtracts @i from @v.
9320 + */
9321 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
9322 +{
9323 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
9324 : "+m" (v->counter)
9325 : "ir" (i));
9326 }
9327 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
9328 {
9329 unsigned char c;
9330
9331 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
9332 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
9333 +
9334 +#ifdef CONFIG_PAX_REFCOUNT
9335 + "jno 0f\n"
9336 + LOCK_PREFIX "addl %2,%0\n"
9337 + "int $4\n0:\n"
9338 + _ASM_EXTABLE(0b, 0b)
9339 +#endif
9340 +
9341 + "sete %1\n"
9342 : "+m" (v->counter), "=qm" (c)
9343 : "ir" (i) : "memory");
9344 return c;
9345 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
9346 */
9347 static inline void atomic_inc(atomic_t *v)
9348 {
9349 - asm volatile(LOCK_PREFIX "incl %0"
9350 + asm volatile(LOCK_PREFIX "incl %0\n"
9351 +
9352 +#ifdef CONFIG_PAX_REFCOUNT
9353 + "jno 0f\n"
9354 + LOCK_PREFIX "decl %0\n"
9355 + "int $4\n0:\n"
9356 + _ASM_EXTABLE(0b, 0b)
9357 +#endif
9358 +
9359 + : "+m" (v->counter));
9360 +}
9361 +
9362 +/**
9363 + * atomic_inc_unchecked - increment atomic variable
9364 + * @v: pointer of type atomic_unchecked_t
9365 + *
9366 + * Atomically increments @v by 1.
9367 + */
9368 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
9369 +{
9370 + asm volatile(LOCK_PREFIX "incl %0\n"
9371 : "+m" (v->counter));
9372 }
9373
9374 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
9375 */
9376 static inline void atomic_dec(atomic_t *v)
9377 {
9378 - asm volatile(LOCK_PREFIX "decl %0"
9379 + asm volatile(LOCK_PREFIX "decl %0\n"
9380 +
9381 +#ifdef CONFIG_PAX_REFCOUNT
9382 + "jno 0f\n"
9383 + LOCK_PREFIX "incl %0\n"
9384 + "int $4\n0:\n"
9385 + _ASM_EXTABLE(0b, 0b)
9386 +#endif
9387 +
9388 + : "+m" (v->counter));
9389 +}
9390 +
9391 +/**
9392 + * atomic_dec_unchecked - decrement atomic variable
9393 + * @v: pointer of type atomic_unchecked_t
9394 + *
9395 + * Atomically decrements @v by 1.
9396 + */
9397 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
9398 +{
9399 + asm volatile(LOCK_PREFIX "decl %0\n"
9400 : "+m" (v->counter));
9401 }
9402
9403 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
9404 {
9405 unsigned char c;
9406
9407 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
9408 + asm volatile(LOCK_PREFIX "decl %0\n"
9409 +
9410 +#ifdef CONFIG_PAX_REFCOUNT
9411 + "jno 0f\n"
9412 + LOCK_PREFIX "incl %0\n"
9413 + "int $4\n0:\n"
9414 + _ASM_EXTABLE(0b, 0b)
9415 +#endif
9416 +
9417 + "sete %1\n"
9418 : "+m" (v->counter), "=qm" (c)
9419 : : "memory");
9420 return c != 0;
9421 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
9422 {
9423 unsigned char c;
9424
9425 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
9426 + asm volatile(LOCK_PREFIX "incl %0\n"
9427 +
9428 +#ifdef CONFIG_PAX_REFCOUNT
9429 + "jno 0f\n"
9430 + LOCK_PREFIX "decl %0\n"
9431 + "int $4\n0:\n"
9432 + _ASM_EXTABLE(0b, 0b)
9433 +#endif
9434 +
9435 + "sete %1\n"
9436 + : "+m" (v->counter), "=qm" (c)
9437 + : : "memory");
9438 + return c != 0;
9439 +}
9440 +
9441 +/**
9442 + * atomic_inc_and_test_unchecked - increment and test
9443 + * @v: pointer of type atomic_unchecked_t
9444 + *
9445 + * Atomically increments @v by 1
9446 + * and returns true if the result is zero, or false for all
9447 + * other cases.
9448 + */
9449 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
9450 +{
9451 + unsigned char c;
9452 +
9453 + asm volatile(LOCK_PREFIX "incl %0\n"
9454 + "sete %1\n"
9455 : "+m" (v->counter), "=qm" (c)
9456 : : "memory");
9457 return c != 0;
9458 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
9459 {
9460 unsigned char c;
9461
9462 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
9463 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
9464 +
9465 +#ifdef CONFIG_PAX_REFCOUNT
9466 + "jno 0f\n"
9467 + LOCK_PREFIX "subl %2,%0\n"
9468 + "int $4\n0:\n"
9469 + _ASM_EXTABLE(0b, 0b)
9470 +#endif
9471 +
9472 + "sets %1\n"
9473 : "+m" (v->counter), "=qm" (c)
9474 : "ir" (i) : "memory");
9475 return c;
9476 @@ -179,7 +341,7 @@ static inline int atomic_add_return(int i, atomic_t *v)
9477 goto no_xadd;
9478 #endif
9479 /* Modern 486+ processor */
9480 - return i + xadd(&v->counter, i);
9481 + return i + xadd_check_overflow(&v->counter, i);
9482
9483 #ifdef CONFIG_M386
9484 no_xadd: /* Legacy 386 processor */
9485 @@ -192,6 +354,34 @@ no_xadd: /* Legacy 386 processor */
9486 }
9487
9488 /**
9489 + * atomic_add_return_unchecked - add integer and return
9490 + * @i: integer value to add
9491 + * @v: pointer of type atomic_unchecked_t
9492 + *
9493 + * Atomically adds @i to @v and returns @i + @v
9494 + */
9495 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
9496 +{
9497 +#ifdef CONFIG_M386
9498 + int __i;
9499 + unsigned long flags;
9500 + if (unlikely(boot_cpu_data.x86 <= 3))
9501 + goto no_xadd;
9502 +#endif
9503 + /* Modern 486+ processor */
9504 + return i + xadd(&v->counter, i);
9505 +
9506 +#ifdef CONFIG_M386
9507 +no_xadd: /* Legacy 386 processor */
9508 + raw_local_irq_save(flags);
9509 + __i = atomic_read_unchecked(v);
9510 + atomic_set_unchecked(v, i + __i);
9511 + raw_local_irq_restore(flags);
9512 + return i + __i;
9513 +#endif
9514 +}
9515 +
9516 +/**
9517 * atomic_sub_return - subtract integer and return
9518 * @v: pointer of type atomic_t
9519 * @i: integer value to subtract
9520 @@ -204,6 +394,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
9521 }
9522
9523 #define atomic_inc_return(v) (atomic_add_return(1, v))
9524 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
9525 +{
9526 + return atomic_add_return_unchecked(1, v);
9527 +}
9528 #define atomic_dec_return(v) (atomic_sub_return(1, v))
9529
9530 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
9531 @@ -211,11 +405,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
9532 return cmpxchg(&v->counter, old, new);
9533 }
9534
9535 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
9536 +{
9537 + return cmpxchg(&v->counter, old, new);
9538 +}
9539 +
9540 static inline int atomic_xchg(atomic_t *v, int new)
9541 {
9542 return xchg(&v->counter, new);
9543 }
9544
9545 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
9546 +{
9547 + return xchg(&v->counter, new);
9548 +}
9549 +
9550 /**
9551 * __atomic_add_unless - add unless the number is already a given value
9552 * @v: pointer of type atomic_t
9553 @@ -227,12 +431,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
9554 */
9555 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9556 {
9557 - int c, old;
9558 + int c, old, new;
9559 c = atomic_read(v);
9560 for (;;) {
9561 - if (unlikely(c == (u)))
9562 + if (unlikely(c == u))
9563 break;
9564 - old = atomic_cmpxchg((v), c, c + (a));
9565 +
9566 + asm volatile("addl %2,%0\n"
9567 +
9568 +#ifdef CONFIG_PAX_REFCOUNT
9569 + "jno 0f\n"
9570 + "subl %2,%0\n"
9571 + "int $4\n0:\n"
9572 + _ASM_EXTABLE(0b, 0b)
9573 +#endif
9574 +
9575 + : "=r" (new)
9576 + : "0" (c), "ir" (a));
9577 +
9578 + old = atomic_cmpxchg(v, c, new);
9579 if (likely(old == c))
9580 break;
9581 c = old;
9582 @@ -240,6 +457,48 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9583 return c;
9584 }
9585
9586 +/**
9587 + * atomic_inc_not_zero_hint - increment if not null
9588 + * @v: pointer of type atomic_t
9589 + * @hint: probable value of the atomic before the increment
9590 + *
9591 + * This version of atomic_inc_not_zero() gives a hint of probable
9592 + * value of the atomic. This helps processor to not read the memory
9593 + * before doing the atomic read/modify/write cycle, lowering
9594 + * number of bus transactions on some arches.
9595 + *
9596 + * Returns: 0 if increment was not done, 1 otherwise.
9597 + */
9598 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
9599 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
9600 +{
9601 + int val, c = hint, new;
9602 +
9603 + /* sanity test, should be removed by compiler if hint is a constant */
9604 + if (!hint)
9605 + return __atomic_add_unless(v, 1, 0);
9606 +
9607 + do {
9608 + asm volatile("incl %0\n"
9609 +
9610 +#ifdef CONFIG_PAX_REFCOUNT
9611 + "jno 0f\n"
9612 + "decl %0\n"
9613 + "int $4\n0:\n"
9614 + _ASM_EXTABLE(0b, 0b)
9615 +#endif
9616 +
9617 + : "=r" (new)
9618 + : "0" (c));
9619 +
9620 + val = atomic_cmpxchg(v, c, new);
9621 + if (val == c)
9622 + return 1;
9623 + c = val;
9624 + } while (c);
9625 +
9626 + return 0;
9627 +}
9628
9629 /*
9630 * atomic_dec_if_positive - decrement by 1 if old value positive
9631 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
9632 index fa13f0e..27c2e08 100644
9633 --- a/arch/x86/include/asm/atomic64_32.h
9634 +++ b/arch/x86/include/asm/atomic64_32.h
9635 @@ -12,6 +12,14 @@ typedef struct {
9636 u64 __aligned(8) counter;
9637 } atomic64_t;
9638
9639 +#ifdef CONFIG_PAX_REFCOUNT
9640 +typedef struct {
9641 + u64 __aligned(8) counter;
9642 +} atomic64_unchecked_t;
9643 +#else
9644 +typedef atomic64_t atomic64_unchecked_t;
9645 +#endif
9646 +
9647 #define ATOMIC64_INIT(val) { (val) }
9648
9649 #ifdef CONFIG_X86_CMPXCHG64
9650 @@ -38,6 +46,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
9651 }
9652
9653 /**
9654 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
9655 + * @p: pointer to type atomic64_unchecked_t
9656 + * @o: expected value
9657 + * @n: new value
9658 + *
9659 + * Atomically sets @v to @n if it was equal to @o and returns
9660 + * the old value.
9661 + */
9662 +
9663 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
9664 +{
9665 + return cmpxchg64(&v->counter, o, n);
9666 +}
9667 +
9668 +/**
9669 * atomic64_xchg - xchg atomic64 variable
9670 * @v: pointer to type atomic64_t
9671 * @n: value to assign
9672 @@ -77,6 +100,24 @@ static inline void atomic64_set(atomic64_t *v, long long i)
9673 }
9674
9675 /**
9676 + * atomic64_set_unchecked - set atomic64 variable
9677 + * @v: pointer to type atomic64_unchecked_t
9678 + * @n: value to assign
9679 + *
9680 + * Atomically sets the value of @v to @n.
9681 + */
9682 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
9683 +{
9684 + unsigned high = (unsigned)(i >> 32);
9685 + unsigned low = (unsigned)i;
9686 + asm volatile(ATOMIC64_ALTERNATIVE(set)
9687 + : "+b" (low), "+c" (high)
9688 + : "S" (v)
9689 + : "eax", "edx", "memory"
9690 + );
9691 +}
9692 +
9693 +/**
9694 * atomic64_read - read atomic64 variable
9695 * @v: pointer to type atomic64_t
9696 *
9697 @@ -93,6 +134,22 @@ static inline long long atomic64_read(const atomic64_t *v)
9698 }
9699
9700 /**
9701 + * atomic64_read_unchecked - read atomic64 variable
9702 + * @v: pointer to type atomic64_unchecked_t
9703 + *
9704 + * Atomically reads the value of @v and returns it.
9705 + */
9706 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
9707 +{
9708 + long long r;
9709 + asm volatile(ATOMIC64_ALTERNATIVE(read_unchecked)
9710 + : "=A" (r), "+c" (v)
9711 + : : "memory"
9712 + );
9713 + return r;
9714 + }
9715 +
9716 +/**
9717 * atomic64_add_return - add and return
9718 * @i: integer value to add
9719 * @v: pointer to type atomic64_t
9720 @@ -108,6 +165,22 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
9721 return i;
9722 }
9723
9724 +/**
9725 + * atomic64_add_return_unchecked - add and return
9726 + * @i: integer value to add
9727 + * @v: pointer to type atomic64_unchecked_t
9728 + *
9729 + * Atomically adds @i to @v and returns @i + *@v
9730 + */
9731 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
9732 +{
9733 + asm volatile(ATOMIC64_ALTERNATIVE(add_return_unchecked)
9734 + : "+A" (i), "+c" (v)
9735 + : : "memory"
9736 + );
9737 + return i;
9738 +}
9739 +
9740 /*
9741 * Other variants with different arithmetic operators:
9742 */
9743 @@ -131,6 +204,17 @@ static inline long long atomic64_inc_return(atomic64_t *v)
9744 return a;
9745 }
9746
9747 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
9748 +{
9749 + long long a;
9750 + asm volatile(ATOMIC64_ALTERNATIVE(inc_return_unchecked)
9751 + : "=A" (a)
9752 + : "S" (v)
9753 + : "memory", "ecx"
9754 + );
9755 + return a;
9756 +}
9757 +
9758 static inline long long atomic64_dec_return(atomic64_t *v)
9759 {
9760 long long a;
9761 @@ -159,6 +243,22 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
9762 }
9763
9764 /**
9765 + * atomic64_add_unchecked - add integer to atomic64 variable
9766 + * @i: integer value to add
9767 + * @v: pointer to type atomic64_unchecked_t
9768 + *
9769 + * Atomically adds @i to @v.
9770 + */
9771 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
9772 +{
9773 + asm volatile(ATOMIC64_ALTERNATIVE_(add_unchecked, add_return_unchecked)
9774 + : "+A" (i), "+c" (v)
9775 + : : "memory"
9776 + );
9777 + return i;
9778 +}
9779 +
9780 +/**
9781 * atomic64_sub - subtract the atomic64 variable
9782 * @i: integer value to subtract
9783 * @v: pointer to type atomic64_t
9784 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
9785 index 0e1cbfc..5623683 100644
9786 --- a/arch/x86/include/asm/atomic64_64.h
9787 +++ b/arch/x86/include/asm/atomic64_64.h
9788 @@ -18,7 +18,19 @@
9789 */
9790 static inline long atomic64_read(const atomic64_t *v)
9791 {
9792 - return (*(volatile long *)&(v)->counter);
9793 + return (*(volatile const long *)&(v)->counter);
9794 +}
9795 +
9796 +/**
9797 + * atomic64_read_unchecked - read atomic64 variable
9798 + * @v: pointer of type atomic64_unchecked_t
9799 + *
9800 + * Atomically reads the value of @v.
9801 + * Doesn't imply a read memory barrier.
9802 + */
9803 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
9804 +{
9805 + return (*(volatile const long *)&(v)->counter);
9806 }
9807
9808 /**
9809 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
9810 }
9811
9812 /**
9813 + * atomic64_set_unchecked - set atomic64 variable
9814 + * @v: pointer to type atomic64_unchecked_t
9815 + * @i: required value
9816 + *
9817 + * Atomically sets the value of @v to @i.
9818 + */
9819 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
9820 +{
9821 + v->counter = i;
9822 +}
9823 +
9824 +/**
9825 * atomic64_add - add integer to atomic64 variable
9826 * @i: integer value to add
9827 * @v: pointer to type atomic64_t
9828 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
9829 */
9830 static inline void atomic64_add(long i, atomic64_t *v)
9831 {
9832 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
9833 +
9834 +#ifdef CONFIG_PAX_REFCOUNT
9835 + "jno 0f\n"
9836 + LOCK_PREFIX "subq %1,%0\n"
9837 + "int $4\n0:\n"
9838 + _ASM_EXTABLE(0b, 0b)
9839 +#endif
9840 +
9841 + : "=m" (v->counter)
9842 + : "er" (i), "m" (v->counter));
9843 +}
9844 +
9845 +/**
9846 + * atomic64_add_unchecked - add integer to atomic64 variable
9847 + * @i: integer value to add
9848 + * @v: pointer to type atomic64_unchecked_t
9849 + *
9850 + * Atomically adds @i to @v.
9851 + */
9852 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
9853 +{
9854 asm volatile(LOCK_PREFIX "addq %1,%0"
9855 : "=m" (v->counter)
9856 : "er" (i), "m" (v->counter));
9857 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
9858 */
9859 static inline void atomic64_sub(long i, atomic64_t *v)
9860 {
9861 - asm volatile(LOCK_PREFIX "subq %1,%0"
9862 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
9863 +
9864 +#ifdef CONFIG_PAX_REFCOUNT
9865 + "jno 0f\n"
9866 + LOCK_PREFIX "addq %1,%0\n"
9867 + "int $4\n0:\n"
9868 + _ASM_EXTABLE(0b, 0b)
9869 +#endif
9870 +
9871 + : "=m" (v->counter)
9872 + : "er" (i), "m" (v->counter));
9873 +}
9874 +
9875 +/**
9876 + * atomic64_sub_unchecked - subtract the atomic64 variable
9877 + * @i: integer value to subtract
9878 + * @v: pointer to type atomic64_unchecked_t
9879 + *
9880 + * Atomically subtracts @i from @v.
9881 + */
9882 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
9883 +{
9884 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
9885 : "=m" (v->counter)
9886 : "er" (i), "m" (v->counter));
9887 }
9888 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
9889 {
9890 unsigned char c;
9891
9892 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
9893 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
9894 +
9895 +#ifdef CONFIG_PAX_REFCOUNT
9896 + "jno 0f\n"
9897 + LOCK_PREFIX "addq %2,%0\n"
9898 + "int $4\n0:\n"
9899 + _ASM_EXTABLE(0b, 0b)
9900 +#endif
9901 +
9902 + "sete %1\n"
9903 : "=m" (v->counter), "=qm" (c)
9904 : "er" (i), "m" (v->counter) : "memory");
9905 return c;
9906 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
9907 */
9908 static inline void atomic64_inc(atomic64_t *v)
9909 {
9910 + asm volatile(LOCK_PREFIX "incq %0\n"
9911 +
9912 +#ifdef CONFIG_PAX_REFCOUNT
9913 + "jno 0f\n"
9914 + LOCK_PREFIX "decq %0\n"
9915 + "int $4\n0:\n"
9916 + _ASM_EXTABLE(0b, 0b)
9917 +#endif
9918 +
9919 + : "=m" (v->counter)
9920 + : "m" (v->counter));
9921 +}
9922 +
9923 +/**
9924 + * atomic64_inc_unchecked - increment atomic64 variable
9925 + * @v: pointer to type atomic64_unchecked_t
9926 + *
9927 + * Atomically increments @v by 1.
9928 + */
9929 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
9930 +{
9931 asm volatile(LOCK_PREFIX "incq %0"
9932 : "=m" (v->counter)
9933 : "m" (v->counter));
9934 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
9935 */
9936 static inline void atomic64_dec(atomic64_t *v)
9937 {
9938 - asm volatile(LOCK_PREFIX "decq %0"
9939 + asm volatile(LOCK_PREFIX "decq %0\n"
9940 +
9941 +#ifdef CONFIG_PAX_REFCOUNT
9942 + "jno 0f\n"
9943 + LOCK_PREFIX "incq %0\n"
9944 + "int $4\n0:\n"
9945 + _ASM_EXTABLE(0b, 0b)
9946 +#endif
9947 +
9948 + : "=m" (v->counter)
9949 + : "m" (v->counter));
9950 +}
9951 +
9952 +/**
9953 + * atomic64_dec_unchecked - decrement atomic64 variable
9954 + * @v: pointer to type atomic64_t
9955 + *
9956 + * Atomically decrements @v by 1.
9957 + */
9958 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
9959 +{
9960 + asm volatile(LOCK_PREFIX "decq %0\n"
9961 : "=m" (v->counter)
9962 : "m" (v->counter));
9963 }
9964 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
9965 {
9966 unsigned char c;
9967
9968 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
9969 + asm volatile(LOCK_PREFIX "decq %0\n"
9970 +
9971 +#ifdef CONFIG_PAX_REFCOUNT
9972 + "jno 0f\n"
9973 + LOCK_PREFIX "incq %0\n"
9974 + "int $4\n0:\n"
9975 + _ASM_EXTABLE(0b, 0b)
9976 +#endif
9977 +
9978 + "sete %1\n"
9979 : "=m" (v->counter), "=qm" (c)
9980 : "m" (v->counter) : "memory");
9981 return c != 0;
9982 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
9983 {
9984 unsigned char c;
9985
9986 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
9987 + asm volatile(LOCK_PREFIX "incq %0\n"
9988 +
9989 +#ifdef CONFIG_PAX_REFCOUNT
9990 + "jno 0f\n"
9991 + LOCK_PREFIX "decq %0\n"
9992 + "int $4\n0:\n"
9993 + _ASM_EXTABLE(0b, 0b)
9994 +#endif
9995 +
9996 + "sete %1\n"
9997 : "=m" (v->counter), "=qm" (c)
9998 : "m" (v->counter) : "memory");
9999 return c != 0;
10000 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
10001 {
10002 unsigned char c;
10003
10004 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
10005 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
10006 +
10007 +#ifdef CONFIG_PAX_REFCOUNT
10008 + "jno 0f\n"
10009 + LOCK_PREFIX "subq %2,%0\n"
10010 + "int $4\n0:\n"
10011 + _ASM_EXTABLE(0b, 0b)
10012 +#endif
10013 +
10014 + "sets %1\n"
10015 : "=m" (v->counter), "=qm" (c)
10016 : "er" (i), "m" (v->counter) : "memory");
10017 return c;
10018 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
10019 */
10020 static inline long atomic64_add_return(long i, atomic64_t *v)
10021 {
10022 + return i + xadd_check_overflow(&v->counter, i);
10023 +}
10024 +
10025 +/**
10026 + * atomic64_add_return_unchecked - add and return
10027 + * @i: integer value to add
10028 + * @v: pointer to type atomic64_unchecked_t
10029 + *
10030 + * Atomically adds @i to @v and returns @i + @v
10031 + */
10032 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
10033 +{
10034 return i + xadd(&v->counter, i);
10035 }
10036
10037 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
10038 }
10039
10040 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
10041 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
10042 +{
10043 + return atomic64_add_return_unchecked(1, v);
10044 +}
10045 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
10046
10047 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
10048 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
10049 return cmpxchg(&v->counter, old, new);
10050 }
10051
10052 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
10053 +{
10054 + return cmpxchg(&v->counter, old, new);
10055 +}
10056 +
10057 static inline long atomic64_xchg(atomic64_t *v, long new)
10058 {
10059 return xchg(&v->counter, new);
10060 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
10061 */
10062 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
10063 {
10064 - long c, old;
10065 + long c, old, new;
10066 c = atomic64_read(v);
10067 for (;;) {
10068 - if (unlikely(c == (u)))
10069 + if (unlikely(c == u))
10070 break;
10071 - old = atomic64_cmpxchg((v), c, c + (a));
10072 +
10073 + asm volatile("add %2,%0\n"
10074 +
10075 +#ifdef CONFIG_PAX_REFCOUNT
10076 + "jno 0f\n"
10077 + "sub %2,%0\n"
10078 + "int $4\n0:\n"
10079 + _ASM_EXTABLE(0b, 0b)
10080 +#endif
10081 +
10082 + : "=r" (new)
10083 + : "0" (c), "ir" (a));
10084 +
10085 + old = atomic64_cmpxchg(v, c, new);
10086 if (likely(old == c))
10087 break;
10088 c = old;
10089 }
10090 - return c != (u);
10091 + return c != u;
10092 }
10093
10094 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
10095 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
10096 index b97596e..9bd48b06 100644
10097 --- a/arch/x86/include/asm/bitops.h
10098 +++ b/arch/x86/include/asm/bitops.h
10099 @@ -38,7 +38,7 @@
10100 * a mask operation on a byte.
10101 */
10102 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
10103 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
10104 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
10105 #define CONST_MASK(nr) (1 << ((nr) & 7))
10106
10107 /**
10108 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
10109 index 5e1a2ee..c9f9533 100644
10110 --- a/arch/x86/include/asm/boot.h
10111 +++ b/arch/x86/include/asm/boot.h
10112 @@ -11,10 +11,15 @@
10113 #include <asm/pgtable_types.h>
10114
10115 /* Physical address where kernel should be loaded. */
10116 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
10117 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
10118 + (CONFIG_PHYSICAL_ALIGN - 1)) \
10119 & ~(CONFIG_PHYSICAL_ALIGN - 1))
10120
10121 +#ifndef __ASSEMBLY__
10122 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
10123 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
10124 +#endif
10125 +
10126 /* Minimum kernel alignment, as a power of two */
10127 #ifdef CONFIG_X86_64
10128 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
10129 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
10130 index 48f99f1..d78ebf9 100644
10131 --- a/arch/x86/include/asm/cache.h
10132 +++ b/arch/x86/include/asm/cache.h
10133 @@ -5,12 +5,13 @@
10134
10135 /* L1 cache line size */
10136 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10137 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10138 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10139
10140 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
10141 +#define __read_only __attribute__((__section__(".data..read_only")))
10142
10143 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
10144 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
10145 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
10146
10147 #ifdef CONFIG_X86_VSMP
10148 #ifdef CONFIG_SMP
10149 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
10150 index 4e12668..501d239 100644
10151 --- a/arch/x86/include/asm/cacheflush.h
10152 +++ b/arch/x86/include/asm/cacheflush.h
10153 @@ -26,7 +26,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
10154 unsigned long pg_flags = pg->flags & _PGMT_MASK;
10155
10156 if (pg_flags == _PGMT_DEFAULT)
10157 - return -1;
10158 + return ~0UL;
10159 else if (pg_flags == _PGMT_WC)
10160 return _PAGE_CACHE_WC;
10161 else if (pg_flags == _PGMT_UC_MINUS)
10162 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
10163 index 46fc474..b02b0f9 100644
10164 --- a/arch/x86/include/asm/checksum_32.h
10165 +++ b/arch/x86/include/asm/checksum_32.h
10166 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
10167 int len, __wsum sum,
10168 int *src_err_ptr, int *dst_err_ptr);
10169
10170 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
10171 + int len, __wsum sum,
10172 + int *src_err_ptr, int *dst_err_ptr);
10173 +
10174 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
10175 + int len, __wsum sum,
10176 + int *src_err_ptr, int *dst_err_ptr);
10177 +
10178 /*
10179 * Note: when you get a NULL pointer exception here this means someone
10180 * passed in an incorrect kernel address to one of these functions.
10181 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
10182 int *err_ptr)
10183 {
10184 might_sleep();
10185 - return csum_partial_copy_generic((__force void *)src, dst,
10186 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
10187 len, sum, err_ptr, NULL);
10188 }
10189
10190 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
10191 {
10192 might_sleep();
10193 if (access_ok(VERIFY_WRITE, dst, len))
10194 - return csum_partial_copy_generic(src, (__force void *)dst,
10195 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
10196 len, sum, NULL, err_ptr);
10197
10198 if (len)
10199 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
10200 index 99480e5..d81165b 100644
10201 --- a/arch/x86/include/asm/cmpxchg.h
10202 +++ b/arch/x86/include/asm/cmpxchg.h
10203 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
10204 __compiletime_error("Bad argument size for cmpxchg");
10205 extern void __xadd_wrong_size(void)
10206 __compiletime_error("Bad argument size for xadd");
10207 +extern void __xadd_check_overflow_wrong_size(void)
10208 + __compiletime_error("Bad argument size for xadd_check_overflow");
10209 extern void __add_wrong_size(void)
10210 __compiletime_error("Bad argument size for add");
10211 +extern void __add_check_overflow_wrong_size(void)
10212 + __compiletime_error("Bad argument size for add_check_overflow");
10213
10214 /*
10215 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
10216 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
10217 __ret; \
10218 })
10219
10220 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
10221 + ({ \
10222 + __typeof__ (*(ptr)) __ret = (arg); \
10223 + switch (sizeof(*(ptr))) { \
10224 + case __X86_CASE_L: \
10225 + asm volatile (lock #op "l %0, %1\n" \
10226 + "jno 0f\n" \
10227 + "mov %0,%1\n" \
10228 + "int $4\n0:\n" \
10229 + _ASM_EXTABLE(0b, 0b) \
10230 + : "+r" (__ret), "+m" (*(ptr)) \
10231 + : : "memory", "cc"); \
10232 + break; \
10233 + case __X86_CASE_Q: \
10234 + asm volatile (lock #op "q %q0, %1\n" \
10235 + "jno 0f\n" \
10236 + "mov %0,%1\n" \
10237 + "int $4\n0:\n" \
10238 + _ASM_EXTABLE(0b, 0b) \
10239 + : "+r" (__ret), "+m" (*(ptr)) \
10240 + : : "memory", "cc"); \
10241 + break; \
10242 + default: \
10243 + __ ## op ## _check_overflow_wrong_size(); \
10244 + } \
10245 + __ret; \
10246 + })
10247 +
10248 /*
10249 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
10250 * Since this is generally used to protect other memory information, we
10251 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
10252 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
10253 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
10254
10255 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
10256 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
10257 +
10258 #define __add(ptr, inc, lock) \
10259 ({ \
10260 __typeof__ (*(ptr)) __ret = (inc); \
10261 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
10262 index 8d67d42..183d0eb 100644
10263 --- a/arch/x86/include/asm/cpufeature.h
10264 +++ b/arch/x86/include/asm/cpufeature.h
10265 @@ -367,7 +367,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
10266 ".section .discard,\"aw\",@progbits\n"
10267 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
10268 ".previous\n"
10269 - ".section .altinstr_replacement,\"ax\"\n"
10270 + ".section .altinstr_replacement,\"a\"\n"
10271 "3: movb $1,%0\n"
10272 "4:\n"
10273 ".previous\n"
10274 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
10275 index e95822d..a90010e 100644
10276 --- a/arch/x86/include/asm/desc.h
10277 +++ b/arch/x86/include/asm/desc.h
10278 @@ -4,6 +4,7 @@
10279 #include <asm/desc_defs.h>
10280 #include <asm/ldt.h>
10281 #include <asm/mmu.h>
10282 +#include <asm/pgtable.h>
10283
10284 #include <linux/smp.h>
10285
10286 @@ -16,6 +17,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
10287
10288 desc->type = (info->read_exec_only ^ 1) << 1;
10289 desc->type |= info->contents << 2;
10290 + desc->type |= info->seg_not_present ^ 1;
10291
10292 desc->s = 1;
10293 desc->dpl = 0x3;
10294 @@ -34,19 +36,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
10295 }
10296
10297 extern struct desc_ptr idt_descr;
10298 -extern gate_desc idt_table[];
10299 extern struct desc_ptr nmi_idt_descr;
10300 -extern gate_desc nmi_idt_table[];
10301 -
10302 -struct gdt_page {
10303 - struct desc_struct gdt[GDT_ENTRIES];
10304 -} __attribute__((aligned(PAGE_SIZE)));
10305 -
10306 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
10307 +extern gate_desc idt_table[256];
10308 +extern gate_desc nmi_idt_table[256];
10309
10310 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
10311 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
10312 {
10313 - return per_cpu(gdt_page, cpu).gdt;
10314 + return cpu_gdt_table[cpu];
10315 }
10316
10317 #ifdef CONFIG_X86_64
10318 @@ -71,8 +68,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
10319 unsigned long base, unsigned dpl, unsigned flags,
10320 unsigned short seg)
10321 {
10322 - gate->a = (seg << 16) | (base & 0xffff);
10323 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
10324 + gate->gate.offset_low = base;
10325 + gate->gate.seg = seg;
10326 + gate->gate.reserved = 0;
10327 + gate->gate.type = type;
10328 + gate->gate.s = 0;
10329 + gate->gate.dpl = dpl;
10330 + gate->gate.p = 1;
10331 + gate->gate.offset_high = base >> 16;
10332 }
10333
10334 #endif
10335 @@ -117,12 +120,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
10336
10337 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
10338 {
10339 + pax_open_kernel();
10340 memcpy(&idt[entry], gate, sizeof(*gate));
10341 + pax_close_kernel();
10342 }
10343
10344 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
10345 {
10346 + pax_open_kernel();
10347 memcpy(&ldt[entry], desc, 8);
10348 + pax_close_kernel();
10349 }
10350
10351 static inline void
10352 @@ -136,7 +143,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
10353 default: size = sizeof(*gdt); break;
10354 }
10355
10356 + pax_open_kernel();
10357 memcpy(&gdt[entry], desc, size);
10358 + pax_close_kernel();
10359 }
10360
10361 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
10362 @@ -209,7 +218,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
10363
10364 static inline void native_load_tr_desc(void)
10365 {
10366 + pax_open_kernel();
10367 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
10368 + pax_close_kernel();
10369 }
10370
10371 static inline void native_load_gdt(const struct desc_ptr *dtr)
10372 @@ -246,8 +257,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
10373 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
10374 unsigned int i;
10375
10376 + pax_open_kernel();
10377 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
10378 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
10379 + pax_close_kernel();
10380 }
10381
10382 #define _LDT_empty(info) \
10383 @@ -310,7 +323,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
10384 }
10385
10386 #ifdef CONFIG_X86_64
10387 -static inline void set_nmi_gate(int gate, void *addr)
10388 +static inline void set_nmi_gate(int gate, const void *addr)
10389 {
10390 gate_desc s;
10391
10392 @@ -319,7 +332,7 @@ static inline void set_nmi_gate(int gate, void *addr)
10393 }
10394 #endif
10395
10396 -static inline void _set_gate(int gate, unsigned type, void *addr,
10397 +static inline void _set_gate(int gate, unsigned type, const void *addr,
10398 unsigned dpl, unsigned ist, unsigned seg)
10399 {
10400 gate_desc s;
10401 @@ -338,7 +351,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
10402 * Pentium F0 0F bugfix can have resulted in the mapped
10403 * IDT being write-protected.
10404 */
10405 -static inline void set_intr_gate(unsigned int n, void *addr)
10406 +static inline void set_intr_gate(unsigned int n, const void *addr)
10407 {
10408 BUG_ON((unsigned)n > 0xFF);
10409 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
10410 @@ -368,19 +381,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
10411 /*
10412 * This routine sets up an interrupt gate at directory privilege level 3.
10413 */
10414 -static inline void set_system_intr_gate(unsigned int n, void *addr)
10415 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
10416 {
10417 BUG_ON((unsigned)n > 0xFF);
10418 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
10419 }
10420
10421 -static inline void set_system_trap_gate(unsigned int n, void *addr)
10422 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
10423 {
10424 BUG_ON((unsigned)n > 0xFF);
10425 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
10426 }
10427
10428 -static inline void set_trap_gate(unsigned int n, void *addr)
10429 +static inline void set_trap_gate(unsigned int n, const void *addr)
10430 {
10431 BUG_ON((unsigned)n > 0xFF);
10432 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
10433 @@ -389,19 +402,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
10434 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
10435 {
10436 BUG_ON((unsigned)n > 0xFF);
10437 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
10438 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
10439 }
10440
10441 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
10442 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
10443 {
10444 BUG_ON((unsigned)n > 0xFF);
10445 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
10446 }
10447
10448 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
10449 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
10450 {
10451 BUG_ON((unsigned)n > 0xFF);
10452 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
10453 }
10454
10455 +#ifdef CONFIG_X86_32
10456 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
10457 +{
10458 + struct desc_struct d;
10459 +
10460 + if (likely(limit))
10461 + limit = (limit - 1UL) >> PAGE_SHIFT;
10462 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
10463 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
10464 +}
10465 +#endif
10466 +
10467 #endif /* _ASM_X86_DESC_H */
10468 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
10469 index 278441f..b95a174 100644
10470 --- a/arch/x86/include/asm/desc_defs.h
10471 +++ b/arch/x86/include/asm/desc_defs.h
10472 @@ -31,6 +31,12 @@ struct desc_struct {
10473 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
10474 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
10475 };
10476 + struct {
10477 + u16 offset_low;
10478 + u16 seg;
10479 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
10480 + unsigned offset_high: 16;
10481 + } gate;
10482 };
10483 } __attribute__((packed));
10484
10485 diff --git a/arch/x86/include/asm/e820.h b/arch/x86/include/asm/e820.h
10486 index 3778256..c5d4fce 100644
10487 --- a/arch/x86/include/asm/e820.h
10488 +++ b/arch/x86/include/asm/e820.h
10489 @@ -69,7 +69,7 @@ struct e820map {
10490 #define ISA_START_ADDRESS 0xa0000
10491 #define ISA_END_ADDRESS 0x100000
10492
10493 -#define BIOS_BEGIN 0x000a0000
10494 +#define BIOS_BEGIN 0x000c0000
10495 #define BIOS_END 0x00100000
10496
10497 #define BIOS_ROM_BASE 0xffe00000
10498 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
10499 index 5f962df..7289f09 100644
10500 --- a/arch/x86/include/asm/elf.h
10501 +++ b/arch/x86/include/asm/elf.h
10502 @@ -238,7 +238,25 @@ extern int force_personality32;
10503 the loader. We need to make sure that it is out of the way of the program
10504 that it will "exec", and that there is sufficient room for the brk. */
10505
10506 +#ifdef CONFIG_PAX_SEGMEXEC
10507 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
10508 +#else
10509 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
10510 +#endif
10511 +
10512 +#ifdef CONFIG_PAX_ASLR
10513 +#ifdef CONFIG_X86_32
10514 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
10515 +
10516 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
10517 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
10518 +#else
10519 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
10520 +
10521 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_IA32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
10522 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_IA32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
10523 +#endif
10524 +#endif
10525
10526 /* This yields a mask that user programs can use to figure out what
10527 instruction set this CPU supports. This could be done in user space,
10528 @@ -291,9 +309,7 @@ do { \
10529
10530 #define ARCH_DLINFO \
10531 do { \
10532 - if (vdso_enabled) \
10533 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
10534 - (unsigned long)current->mm->context.vdso); \
10535 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
10536 } while (0)
10537
10538 #define AT_SYSINFO 32
10539 @@ -304,7 +320,7 @@ do { \
10540
10541 #endif /* !CONFIG_X86_32 */
10542
10543 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
10544 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
10545
10546 #define VDSO_ENTRY \
10547 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
10548 @@ -318,9 +334,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
10549 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
10550 #define compat_arch_setup_additional_pages syscall32_setup_pages
10551
10552 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
10553 -#define arch_randomize_brk arch_randomize_brk
10554 -
10555 /*
10556 * True on X86_32 or when emulating IA32 on X86_64
10557 */
10558 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
10559 index cc70c1c..d96d011 100644
10560 --- a/arch/x86/include/asm/emergency-restart.h
10561 +++ b/arch/x86/include/asm/emergency-restart.h
10562 @@ -15,6 +15,6 @@ enum reboot_type {
10563
10564 extern enum reboot_type reboot_type;
10565
10566 -extern void machine_emergency_restart(void);
10567 +extern void machine_emergency_restart(void) __noreturn;
10568
10569 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
10570 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
10571 index d09bb03..4ea4194 100644
10572 --- a/arch/x86/include/asm/futex.h
10573 +++ b/arch/x86/include/asm/futex.h
10574 @@ -12,16 +12,18 @@
10575 #include <asm/system.h>
10576
10577 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
10578 + typecheck(u32 __user *, uaddr); \
10579 asm volatile("1:\t" insn "\n" \
10580 "2:\t.section .fixup,\"ax\"\n" \
10581 "3:\tmov\t%3, %1\n" \
10582 "\tjmp\t2b\n" \
10583 "\t.previous\n" \
10584 _ASM_EXTABLE(1b, 3b) \
10585 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
10586 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr))\
10587 : "i" (-EFAULT), "0" (oparg), "1" (0))
10588
10589 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
10590 + typecheck(u32 __user *, uaddr); \
10591 asm volatile("1:\tmovl %2, %0\n" \
10592 "\tmovl\t%0, %3\n" \
10593 "\t" insn "\n" \
10594 @@ -34,7 +36,7 @@
10595 _ASM_EXTABLE(1b, 4b) \
10596 _ASM_EXTABLE(2b, 4b) \
10597 : "=&a" (oldval), "=&r" (ret), \
10598 - "+m" (*uaddr), "=&r" (tem) \
10599 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
10600 : "r" (oparg), "i" (-EFAULT), "1" (0))
10601
10602 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
10603 @@ -61,10 +63,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
10604
10605 switch (op) {
10606 case FUTEX_OP_SET:
10607 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
10608 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
10609 break;
10610 case FUTEX_OP_ADD:
10611 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
10612 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
10613 uaddr, oparg);
10614 break;
10615 case FUTEX_OP_OR:
10616 @@ -123,13 +125,13 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
10617 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
10618 return -EFAULT;
10619
10620 - asm volatile("1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
10621 + asm volatile("1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
10622 "2:\t.section .fixup, \"ax\"\n"
10623 "3:\tmov %3, %0\n"
10624 "\tjmp 2b\n"
10625 "\t.previous\n"
10626 _ASM_EXTABLE(1b, 3b)
10627 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
10628 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
10629 : "i" (-EFAULT), "r" (newval), "1" (oldval)
10630 : "memory"
10631 );
10632 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
10633 index eb92a6e..b98b2f4 100644
10634 --- a/arch/x86/include/asm/hw_irq.h
10635 +++ b/arch/x86/include/asm/hw_irq.h
10636 @@ -136,8 +136,8 @@ extern void setup_ioapic_dest(void);
10637 extern void enable_IO_APIC(void);
10638
10639 /* Statistics */
10640 -extern atomic_t irq_err_count;
10641 -extern atomic_t irq_mis_count;
10642 +extern atomic_unchecked_t irq_err_count;
10643 +extern atomic_unchecked_t irq_mis_count;
10644
10645 /* EISA */
10646 extern void eisa_set_level_irq(unsigned int irq);
10647 diff --git a/arch/x86/include/asm/i387.h b/arch/x86/include/asm/i387.h
10648 index 2479049..3fb9795 100644
10649 --- a/arch/x86/include/asm/i387.h
10650 +++ b/arch/x86/include/asm/i387.h
10651 @@ -93,6 +93,11 @@ static inline int fxrstor_checking(struct i387_fxsave_struct *fx)
10652 {
10653 int err;
10654
10655 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
10656 + if ((unsigned long)fx < PAX_USER_SHADOW_BASE)
10657 + fx = (struct i387_fxsave_struct __user *)((void *)fx + PAX_USER_SHADOW_BASE);
10658 +#endif
10659 +
10660 /* See comment in fxsave() below. */
10661 #ifdef CONFIG_AS_FXSAVEQ
10662 asm volatile("1: fxrstorq %[fx]\n\t"
10663 @@ -122,6 +127,11 @@ static inline int fxsave_user(struct i387_fxsave_struct __user *fx)
10664 {
10665 int err;
10666
10667 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
10668 + if ((unsigned long)fx < PAX_USER_SHADOW_BASE)
10669 + fx = (struct i387_fxsave_struct __user *)((void __user *)fx + PAX_USER_SHADOW_BASE);
10670 +#endif
10671 +
10672 /*
10673 * Clear the bytes not touched by the fxsave and reserved
10674 * for the SW usage.
10675 @@ -278,7 +288,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
10676 "emms\n\t" /* clear stack tags */
10677 "fildl %P[addr]", /* set F?P to defined value */
10678 X86_FEATURE_FXSAVE_LEAK,
10679 - [addr] "m" (tsk->thread.fpu.has_fpu));
10680 + [addr] "m" (init_tss[smp_processor_id()].x86_tss.sp0));
10681
10682 return fpu_restore_checking(&tsk->thread.fpu);
10683 }
10684 @@ -445,7 +455,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
10685 static inline bool interrupted_user_mode(void)
10686 {
10687 struct pt_regs *regs = get_irq_regs();
10688 - return regs && user_mode_vm(regs);
10689 + return regs && user_mode(regs);
10690 }
10691
10692 /*
10693 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
10694 index d8e8eef..99f81ae 100644
10695 --- a/arch/x86/include/asm/io.h
10696 +++ b/arch/x86/include/asm/io.h
10697 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
10698
10699 #include <linux/vmalloc.h>
10700
10701 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
10702 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
10703 +{
10704 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
10705 +}
10706 +
10707 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
10708 +{
10709 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
10710 +}
10711 +
10712 /*
10713 * Convert a virtual cached pointer to an uncached pointer
10714 */
10715 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
10716 index bba3cf8..06bc8da 100644
10717 --- a/arch/x86/include/asm/irqflags.h
10718 +++ b/arch/x86/include/asm/irqflags.h
10719 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
10720 sti; \
10721 sysexit
10722
10723 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
10724 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
10725 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
10726 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
10727 +
10728 #else
10729 #define INTERRUPT_RETURN iret
10730 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
10731 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
10732 index 5478825..839e88c 100644
10733 --- a/arch/x86/include/asm/kprobes.h
10734 +++ b/arch/x86/include/asm/kprobes.h
10735 @@ -37,13 +37,8 @@ typedef u8 kprobe_opcode_t;
10736 #define RELATIVEJUMP_SIZE 5
10737 #define RELATIVECALL_OPCODE 0xe8
10738 #define RELATIVE_ADDR_SIZE 4
10739 -#define MAX_STACK_SIZE 64
10740 -#define MIN_STACK_SIZE(ADDR) \
10741 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
10742 - THREAD_SIZE - (unsigned long)(ADDR))) \
10743 - ? (MAX_STACK_SIZE) \
10744 - : (((unsigned long)current_thread_info()) + \
10745 - THREAD_SIZE - (unsigned long)(ADDR)))
10746 +#define MAX_STACK_SIZE 64UL
10747 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
10748
10749 #define flush_insn_slot(p) do { } while (0)
10750
10751 diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
10752 index 52d6640..a013b87 100644
10753 --- a/arch/x86/include/asm/kvm_host.h
10754 +++ b/arch/x86/include/asm/kvm_host.h
10755 @@ -663,7 +663,7 @@ struct kvm_x86_ops {
10756 int (*check_intercept)(struct kvm_vcpu *vcpu,
10757 struct x86_instruction_info *info,
10758 enum x86_intercept_stage stage);
10759 -};
10760 +} __do_const;
10761
10762 struct kvm_arch_async_pf {
10763 u32 token;
10764 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
10765 index 9cdae5d..300d20f 100644
10766 --- a/arch/x86/include/asm/local.h
10767 +++ b/arch/x86/include/asm/local.h
10768 @@ -18,26 +18,58 @@ typedef struct {
10769
10770 static inline void local_inc(local_t *l)
10771 {
10772 - asm volatile(_ASM_INC "%0"
10773 + asm volatile(_ASM_INC "%0\n"
10774 +
10775 +#ifdef CONFIG_PAX_REFCOUNT
10776 + "jno 0f\n"
10777 + _ASM_DEC "%0\n"
10778 + "int $4\n0:\n"
10779 + _ASM_EXTABLE(0b, 0b)
10780 +#endif
10781 +
10782 : "+m" (l->a.counter));
10783 }
10784
10785 static inline void local_dec(local_t *l)
10786 {
10787 - asm volatile(_ASM_DEC "%0"
10788 + asm volatile(_ASM_DEC "%0\n"
10789 +
10790 +#ifdef CONFIG_PAX_REFCOUNT
10791 + "jno 0f\n"
10792 + _ASM_INC "%0\n"
10793 + "int $4\n0:\n"
10794 + _ASM_EXTABLE(0b, 0b)
10795 +#endif
10796 +
10797 : "+m" (l->a.counter));
10798 }
10799
10800 static inline void local_add(long i, local_t *l)
10801 {
10802 - asm volatile(_ASM_ADD "%1,%0"
10803 + asm volatile(_ASM_ADD "%1,%0\n"
10804 +
10805 +#ifdef CONFIG_PAX_REFCOUNT
10806 + "jno 0f\n"
10807 + _ASM_SUB "%1,%0\n"
10808 + "int $4\n0:\n"
10809 + _ASM_EXTABLE(0b, 0b)
10810 +#endif
10811 +
10812 : "+m" (l->a.counter)
10813 : "ir" (i));
10814 }
10815
10816 static inline void local_sub(long i, local_t *l)
10817 {
10818 - asm volatile(_ASM_SUB "%1,%0"
10819 + asm volatile(_ASM_SUB "%1,%0\n"
10820 +
10821 +#ifdef CONFIG_PAX_REFCOUNT
10822 + "jno 0f\n"
10823 + _ASM_ADD "%1,%0\n"
10824 + "int $4\n0:\n"
10825 + _ASM_EXTABLE(0b, 0b)
10826 +#endif
10827 +
10828 : "+m" (l->a.counter)
10829 : "ir" (i));
10830 }
10831 @@ -55,7 +87,16 @@ static inline int local_sub_and_test(long i, local_t *l)
10832 {
10833 unsigned char c;
10834
10835 - asm volatile(_ASM_SUB "%2,%0; sete %1"
10836 + asm volatile(_ASM_SUB "%2,%0\n"
10837 +
10838 +#ifdef CONFIG_PAX_REFCOUNT
10839 + "jno 0f\n"
10840 + _ASM_ADD "%2,%0\n"
10841 + "int $4\n0:\n"
10842 + _ASM_EXTABLE(0b, 0b)
10843 +#endif
10844 +
10845 + "sete %1\n"
10846 : "+m" (l->a.counter), "=qm" (c)
10847 : "ir" (i) : "memory");
10848 return c;
10849 @@ -73,7 +114,16 @@ static inline int local_dec_and_test(local_t *l)
10850 {
10851 unsigned char c;
10852
10853 - asm volatile(_ASM_DEC "%0; sete %1"
10854 + asm volatile(_ASM_DEC "%0\n"
10855 +
10856 +#ifdef CONFIG_PAX_REFCOUNT
10857 + "jno 0f\n"
10858 + _ASM_INC "%0\n"
10859 + "int $4\n0:\n"
10860 + _ASM_EXTABLE(0b, 0b)
10861 +#endif
10862 +
10863 + "sete %1\n"
10864 : "+m" (l->a.counter), "=qm" (c)
10865 : : "memory");
10866 return c != 0;
10867 @@ -91,7 +141,16 @@ static inline int local_inc_and_test(local_t *l)
10868 {
10869 unsigned char c;
10870
10871 - asm volatile(_ASM_INC "%0; sete %1"
10872 + asm volatile(_ASM_INC "%0\n"
10873 +
10874 +#ifdef CONFIG_PAX_REFCOUNT
10875 + "jno 0f\n"
10876 + _ASM_DEC "%0\n"
10877 + "int $4\n0:\n"
10878 + _ASM_EXTABLE(0b, 0b)
10879 +#endif
10880 +
10881 + "sete %1\n"
10882 : "+m" (l->a.counter), "=qm" (c)
10883 : : "memory");
10884 return c != 0;
10885 @@ -110,7 +169,16 @@ static inline int local_add_negative(long i, local_t *l)
10886 {
10887 unsigned char c;
10888
10889 - asm volatile(_ASM_ADD "%2,%0; sets %1"
10890 + asm volatile(_ASM_ADD "%2,%0\n"
10891 +
10892 +#ifdef CONFIG_PAX_REFCOUNT
10893 + "jno 0f\n"
10894 + _ASM_SUB "%2,%0\n"
10895 + "int $4\n0:\n"
10896 + _ASM_EXTABLE(0b, 0b)
10897 +#endif
10898 +
10899 + "sets %1\n"
10900 : "+m" (l->a.counter), "=qm" (c)
10901 : "ir" (i) : "memory");
10902 return c;
10903 @@ -133,7 +201,15 @@ static inline long local_add_return(long i, local_t *l)
10904 #endif
10905 /* Modern 486+ processor */
10906 __i = i;
10907 - asm volatile(_ASM_XADD "%0, %1;"
10908 + asm volatile(_ASM_XADD "%0, %1\n"
10909 +
10910 +#ifdef CONFIG_PAX_REFCOUNT
10911 + "jno 0f\n"
10912 + _ASM_MOV "%0,%1\n"
10913 + "int $4\n0:\n"
10914 + _ASM_EXTABLE(0b, 0b)
10915 +#endif
10916 +
10917 : "+r" (i), "+m" (l->a.counter)
10918 : : "memory");
10919 return i + __i;
10920 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
10921 index 593e51d..fa69c9a 100644
10922 --- a/arch/x86/include/asm/mman.h
10923 +++ b/arch/x86/include/asm/mman.h
10924 @@ -5,4 +5,14 @@
10925
10926 #include <asm-generic/mman.h>
10927
10928 +#ifdef __KERNEL__
10929 +#ifndef __ASSEMBLY__
10930 +#ifdef CONFIG_X86_32
10931 +#define arch_mmap_check i386_mmap_check
10932 +int i386_mmap_check(unsigned long addr, unsigned long len,
10933 + unsigned long flags);
10934 +#endif
10935 +#endif
10936 +#endif
10937 +
10938 #endif /* _ASM_X86_MMAN_H */
10939 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
10940 index 5f55e69..e20bfb1 100644
10941 --- a/arch/x86/include/asm/mmu.h
10942 +++ b/arch/x86/include/asm/mmu.h
10943 @@ -9,7 +9,7 @@
10944 * we put the segment information here.
10945 */
10946 typedef struct {
10947 - void *ldt;
10948 + struct desc_struct *ldt;
10949 int size;
10950
10951 #ifdef CONFIG_X86_64
10952 @@ -18,7 +18,19 @@ typedef struct {
10953 #endif
10954
10955 struct mutex lock;
10956 - void *vdso;
10957 + unsigned long vdso;
10958 +
10959 +#ifdef CONFIG_X86_32
10960 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
10961 + unsigned long user_cs_base;
10962 + unsigned long user_cs_limit;
10963 +
10964 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
10965 + cpumask_t cpu_user_cs_mask;
10966 +#endif
10967 +
10968 +#endif
10969 +#endif
10970 } mm_context_t;
10971
10972 #ifdef CONFIG_SMP
10973 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
10974 index 6902152..da4283a 100644
10975 --- a/arch/x86/include/asm/mmu_context.h
10976 +++ b/arch/x86/include/asm/mmu_context.h
10977 @@ -24,6 +24,18 @@ void destroy_context(struct mm_struct *mm);
10978
10979 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
10980 {
10981 +
10982 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
10983 + unsigned int i;
10984 + pgd_t *pgd;
10985 +
10986 + pax_open_kernel();
10987 + pgd = get_cpu_pgd(smp_processor_id());
10988 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
10989 + set_pgd_batched(pgd+i, native_make_pgd(0));
10990 + pax_close_kernel();
10991 +#endif
10992 +
10993 #ifdef CONFIG_SMP
10994 if (percpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
10995 percpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
10996 @@ -34,16 +46,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
10997 struct task_struct *tsk)
10998 {
10999 unsigned cpu = smp_processor_id();
11000 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
11001 + int tlbstate = TLBSTATE_OK;
11002 +#endif
11003
11004 if (likely(prev != next)) {
11005 #ifdef CONFIG_SMP
11006 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
11007 + tlbstate = percpu_read(cpu_tlbstate.state);
11008 +#endif
11009 percpu_write(cpu_tlbstate.state, TLBSTATE_OK);
11010 percpu_write(cpu_tlbstate.active_mm, next);
11011 #endif
11012 cpumask_set_cpu(cpu, mm_cpumask(next));
11013
11014 /* Re-load page tables */
11015 +#ifdef CONFIG_PAX_PER_CPU_PGD
11016 + pax_open_kernel();
11017 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
11018 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
11019 + pax_close_kernel();
11020 + load_cr3(get_cpu_pgd(cpu));
11021 +#else
11022 load_cr3(next->pgd);
11023 +#endif
11024
11025 /* stop flush ipis for the previous mm */
11026 cpumask_clear_cpu(cpu, mm_cpumask(prev));
11027 @@ -53,9 +79,38 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
11028 */
11029 if (unlikely(prev->context.ldt != next->context.ldt))
11030 load_LDT_nolock(&next->context);
11031 - }
11032 +
11033 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
11034 + if (!(__supported_pte_mask & _PAGE_NX)) {
11035 + smp_mb__before_clear_bit();
11036 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
11037 + smp_mb__after_clear_bit();
11038 + cpu_set(cpu, next->context.cpu_user_cs_mask);
11039 + }
11040 +#endif
11041 +
11042 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
11043 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
11044 + prev->context.user_cs_limit != next->context.user_cs_limit))
11045 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
11046 #ifdef CONFIG_SMP
11047 + else if (unlikely(tlbstate != TLBSTATE_OK))
11048 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
11049 +#endif
11050 +#endif
11051 +
11052 + }
11053 else {
11054 +
11055 +#ifdef CONFIG_PAX_PER_CPU_PGD
11056 + pax_open_kernel();
11057 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
11058 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
11059 + pax_close_kernel();
11060 + load_cr3(get_cpu_pgd(cpu));
11061 +#endif
11062 +
11063 +#ifdef CONFIG_SMP
11064 percpu_write(cpu_tlbstate.state, TLBSTATE_OK);
11065 BUG_ON(percpu_read(cpu_tlbstate.active_mm) != next);
11066
11067 @@ -64,11 +119,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
11068 * tlb flush IPI delivery. We must reload CR3
11069 * to make sure to use no freed page tables.
11070 */
11071 +
11072 +#ifndef CONFIG_PAX_PER_CPU_PGD
11073 load_cr3(next->pgd);
11074 +#endif
11075 +
11076 load_LDT_nolock(&next->context);
11077 +
11078 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
11079 + if (!(__supported_pte_mask & _PAGE_NX))
11080 + cpu_set(cpu, next->context.cpu_user_cs_mask);
11081 +#endif
11082 +
11083 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
11084 +#ifdef CONFIG_PAX_PAGEEXEC
11085 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
11086 +#endif
11087 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
11088 +#endif
11089 +
11090 }
11091 +#endif
11092 }
11093 -#endif
11094 }
11095
11096 #define activate_mm(prev, next) \
11097 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
11098 index 9eae775..c914fea 100644
11099 --- a/arch/x86/include/asm/module.h
11100 +++ b/arch/x86/include/asm/module.h
11101 @@ -5,6 +5,7 @@
11102
11103 #ifdef CONFIG_X86_64
11104 /* X86_64 does not define MODULE_PROC_FAMILY */
11105 +#define MODULE_PROC_FAMILY ""
11106 #elif defined CONFIG_M386
11107 #define MODULE_PROC_FAMILY "386 "
11108 #elif defined CONFIG_M486
11109 @@ -59,8 +60,20 @@
11110 #error unknown processor family
11111 #endif
11112
11113 -#ifdef CONFIG_X86_32
11114 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
11115 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
11116 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
11117 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
11118 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
11119 +#else
11120 +#define MODULE_PAX_KERNEXEC ""
11121 #endif
11122
11123 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11124 +#define MODULE_PAX_UDEREF "UDEREF "
11125 +#else
11126 +#define MODULE_PAX_UDEREF ""
11127 +#endif
11128 +
11129 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
11130 +
11131 #endif /* _ASM_X86_MODULE_H */
11132 diff --git a/arch/x86/include/asm/page_64_types.h b/arch/x86/include/asm/page_64_types.h
11133 index 7639dbf..e08a58c 100644
11134 --- a/arch/x86/include/asm/page_64_types.h
11135 +++ b/arch/x86/include/asm/page_64_types.h
11136 @@ -56,7 +56,7 @@ void copy_page(void *to, void *from);
11137
11138 /* duplicated to the one in bootmem.h */
11139 extern unsigned long max_pfn;
11140 -extern unsigned long phys_base;
11141 +extern const unsigned long phys_base;
11142
11143 extern unsigned long __phys_addr(unsigned long);
11144 #define __phys_reloc_hide(x) (x)
11145 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
11146 index a7d2db9..edb023e 100644
11147 --- a/arch/x86/include/asm/paravirt.h
11148 +++ b/arch/x86/include/asm/paravirt.h
11149 @@ -667,6 +667,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
11150 val);
11151 }
11152
11153 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
11154 +{
11155 + pgdval_t val = native_pgd_val(pgd);
11156 +
11157 + if (sizeof(pgdval_t) > sizeof(long))
11158 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
11159 + val, (u64)val >> 32);
11160 + else
11161 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
11162 + val);
11163 +}
11164 +
11165 static inline void pgd_clear(pgd_t *pgdp)
11166 {
11167 set_pgd(pgdp, __pgd(0));
11168 @@ -748,6 +760,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
11169 pv_mmu_ops.set_fixmap(idx, phys, flags);
11170 }
11171
11172 +#ifdef CONFIG_PAX_KERNEXEC
11173 +static inline unsigned long pax_open_kernel(void)
11174 +{
11175 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
11176 +}
11177 +
11178 +static inline unsigned long pax_close_kernel(void)
11179 +{
11180 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
11181 +}
11182 +#else
11183 +static inline unsigned long pax_open_kernel(void) { return 0; }
11184 +static inline unsigned long pax_close_kernel(void) { return 0; }
11185 +#endif
11186 +
11187 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
11188
11189 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
11190 @@ -964,7 +991,7 @@ extern void default_banner(void);
11191
11192 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
11193 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
11194 -#define PARA_INDIRECT(addr) *%cs:addr
11195 +#define PARA_INDIRECT(addr) *%ss:addr
11196 #endif
11197
11198 #define INTERRUPT_RETURN \
11199 @@ -1041,6 +1068,21 @@ extern void default_banner(void);
11200 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
11201 CLBR_NONE, \
11202 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
11203 +
11204 +#define GET_CR0_INTO_RDI \
11205 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
11206 + mov %rax,%rdi
11207 +
11208 +#define SET_RDI_INTO_CR0 \
11209 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
11210 +
11211 +#define GET_CR3_INTO_RDI \
11212 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
11213 + mov %rax,%rdi
11214 +
11215 +#define SET_RDI_INTO_CR3 \
11216 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
11217 +
11218 #endif /* CONFIG_X86_32 */
11219
11220 #endif /* __ASSEMBLY__ */
11221 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
11222 index 8e8b9a4..f07d725 100644
11223 --- a/arch/x86/include/asm/paravirt_types.h
11224 +++ b/arch/x86/include/asm/paravirt_types.h
11225 @@ -84,20 +84,20 @@ struct pv_init_ops {
11226 */
11227 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
11228 unsigned long addr, unsigned len);
11229 -};
11230 +} __no_const;
11231
11232
11233 struct pv_lazy_ops {
11234 /* Set deferred update mode, used for batching operations. */
11235 void (*enter)(void);
11236 void (*leave)(void);
11237 -};
11238 +} __no_const;
11239
11240 struct pv_time_ops {
11241 unsigned long long (*sched_clock)(void);
11242 unsigned long long (*steal_clock)(int cpu);
11243 unsigned long (*get_tsc_khz)(void);
11244 -};
11245 +} __no_const;
11246
11247 struct pv_cpu_ops {
11248 /* hooks for various privileged instructions */
11249 @@ -193,7 +193,7 @@ struct pv_cpu_ops {
11250
11251 void (*start_context_switch)(struct task_struct *prev);
11252 void (*end_context_switch)(struct task_struct *next);
11253 -};
11254 +} __no_const;
11255
11256 struct pv_irq_ops {
11257 /*
11258 @@ -224,7 +224,7 @@ struct pv_apic_ops {
11259 unsigned long start_eip,
11260 unsigned long start_esp);
11261 #endif
11262 -};
11263 +} __no_const;
11264
11265 struct pv_mmu_ops {
11266 unsigned long (*read_cr2)(void);
11267 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
11268 struct paravirt_callee_save make_pud;
11269
11270 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
11271 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
11272 #endif /* PAGETABLE_LEVELS == 4 */
11273 #endif /* PAGETABLE_LEVELS >= 3 */
11274
11275 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
11276 an mfn. We can tell which is which from the index. */
11277 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
11278 phys_addr_t phys, pgprot_t flags);
11279 +
11280 +#ifdef CONFIG_PAX_KERNEXEC
11281 + unsigned long (*pax_open_kernel)(void);
11282 + unsigned long (*pax_close_kernel)(void);
11283 +#endif
11284 +
11285 };
11286
11287 struct arch_spinlock;
11288 @@ -334,7 +341,7 @@ struct pv_lock_ops {
11289 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
11290 int (*spin_trylock)(struct arch_spinlock *lock);
11291 void (*spin_unlock)(struct arch_spinlock *lock);
11292 -};
11293 +} __no_const;
11294
11295 /* This contains all the paravirt structures: we get a convenient
11296 * number for each function using the offset which we use to indicate
11297 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
11298 index b4389a4..7024269 100644
11299 --- a/arch/x86/include/asm/pgalloc.h
11300 +++ b/arch/x86/include/asm/pgalloc.h
11301 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
11302 pmd_t *pmd, pte_t *pte)
11303 {
11304 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
11305 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
11306 +}
11307 +
11308 +static inline void pmd_populate_user(struct mm_struct *mm,
11309 + pmd_t *pmd, pte_t *pte)
11310 +{
11311 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
11312 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
11313 }
11314
11315 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
11316
11317 #ifdef CONFIG_X86_PAE
11318 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
11319 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
11320 +{
11321 + pud_populate(mm, pudp, pmd);
11322 +}
11323 #else /* !CONFIG_X86_PAE */
11324 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
11325 {
11326 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
11327 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
11328 }
11329 +
11330 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
11331 +{
11332 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
11333 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
11334 +}
11335 #endif /* CONFIG_X86_PAE */
11336
11337 #if PAGETABLE_LEVELS > 3
11338 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
11339 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
11340 }
11341
11342 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
11343 +{
11344 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
11345 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
11346 +}
11347 +
11348 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
11349 {
11350 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
11351 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
11352 index 98391db..8f6984e 100644
11353 --- a/arch/x86/include/asm/pgtable-2level.h
11354 +++ b/arch/x86/include/asm/pgtable-2level.h
11355 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
11356
11357 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
11358 {
11359 + pax_open_kernel();
11360 *pmdp = pmd;
11361 + pax_close_kernel();
11362 }
11363
11364 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
11365 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
11366 index effff47..bbb8295 100644
11367 --- a/arch/x86/include/asm/pgtable-3level.h
11368 +++ b/arch/x86/include/asm/pgtable-3level.h
11369 @@ -31,6 +31,56 @@ static inline void native_set_pte(pte_t *ptep, pte_t pte)
11370 ptep->pte_low = pte.pte_low;
11371 }
11372
11373 +#define __HAVE_ARCH_READ_PMD_ATOMIC
11374 +/*
11375 + * pte_offset_map_lock on 32bit PAE kernels was reading the pmd_t with
11376 + * a "*pmdp" dereference done by gcc. Problem is, in certain places
11377 + * where pte_offset_map_lock is called, concurrent page faults are
11378 + * allowed, if the mmap_sem is hold for reading. An example is mincore
11379 + * vs page faults vs MADV_DONTNEED. On the page fault side
11380 + * pmd_populate rightfully does a set_64bit, but if we're reading the
11381 + * pmd_t with a "*pmdp" on the mincore side, a SMP race can happen
11382 + * because gcc will not read the 64bit of the pmd atomically. To fix
11383 + * this all places running pmd_offset_map_lock() while holding the
11384 + * mmap_sem in read mode, shall read the pmdp pointer using this
11385 + * function to know if the pmd is null nor not, and in turn to know if
11386 + * they can run pmd_offset_map_lock or pmd_trans_huge or other pmd
11387 + * operations.
11388 + *
11389 + * Without THP if the mmap_sem is hold for reading, the
11390 + * pmd can only transition from null to not null while read_pmd_atomic runs.
11391 + * So there's no need of literally reading it atomically.
11392 + *
11393 + * With THP if the mmap_sem is hold for reading, the pmd can become
11394 + * THP or null or point to a pte (and in turn become "stable") at any
11395 + * time under read_pmd_atomic, so it's mandatory to read it atomically
11396 + * with cmpxchg8b.
11397 + */
11398 +#ifndef CONFIG_TRANSPARENT_HUGEPAGE
11399 +static inline pmd_t read_pmd_atomic(pmd_t *pmdp)
11400 +{
11401 + pmdval_t ret;
11402 + u32 *tmp = (u32 *)pmdp;
11403 +
11404 + ret = (pmdval_t) (*tmp);
11405 + if (ret) {
11406 + /*
11407 + * If the low part is null, we must not read the high part
11408 + * or we can end up with a partial pmd.
11409 + */
11410 + smp_rmb();
11411 + ret |= ((pmdval_t)*(tmp + 1)) << 32;
11412 + }
11413 +
11414 + return __pmd(ret);
11415 +}
11416 +#else /* CONFIG_TRANSPARENT_HUGEPAGE */
11417 +static inline pmd_t read_pmd_atomic(pmd_t *pmdp)
11418 +{
11419 + return __pmd(atomic64_read((atomic64_t *)pmdp));
11420 +}
11421 +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
11422 +
11423 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
11424 {
11425 set_64bit((unsigned long long *)(ptep), native_pte_val(pte));
11426 @@ -38,12 +88,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
11427
11428 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
11429 {
11430 + pax_open_kernel();
11431 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
11432 + pax_close_kernel();
11433 }
11434
11435 static inline void native_set_pud(pud_t *pudp, pud_t pud)
11436 {
11437 + pax_open_kernel();
11438 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
11439 + pax_close_kernel();
11440 }
11441
11442 /*
11443 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
11444 index 49afb3f..91a8c63 100644
11445 --- a/arch/x86/include/asm/pgtable.h
11446 +++ b/arch/x86/include/asm/pgtable.h
11447 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
11448
11449 #ifndef __PAGETABLE_PUD_FOLDED
11450 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
11451 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
11452 #define pgd_clear(pgd) native_pgd_clear(pgd)
11453 #endif
11454
11455 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
11456
11457 #define arch_end_context_switch(prev) do {} while(0)
11458
11459 +#define pax_open_kernel() native_pax_open_kernel()
11460 +#define pax_close_kernel() native_pax_close_kernel()
11461 #endif /* CONFIG_PARAVIRT */
11462
11463 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
11464 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
11465 +
11466 +#ifdef CONFIG_PAX_KERNEXEC
11467 +static inline unsigned long native_pax_open_kernel(void)
11468 +{
11469 + unsigned long cr0;
11470 +
11471 + preempt_disable();
11472 + barrier();
11473 + cr0 = read_cr0() ^ X86_CR0_WP;
11474 + BUG_ON(unlikely(cr0 & X86_CR0_WP));
11475 + write_cr0(cr0);
11476 + return cr0 ^ X86_CR0_WP;
11477 +}
11478 +
11479 +static inline unsigned long native_pax_close_kernel(void)
11480 +{
11481 + unsigned long cr0;
11482 +
11483 + cr0 = read_cr0() ^ X86_CR0_WP;
11484 + BUG_ON(unlikely(!(cr0 & X86_CR0_WP)));
11485 + write_cr0(cr0);
11486 + barrier();
11487 + preempt_enable_no_resched();
11488 + return cr0 ^ X86_CR0_WP;
11489 +}
11490 +#else
11491 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
11492 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
11493 +#endif
11494 +
11495 /*
11496 * The following only work if pte_present() is true.
11497 * Undefined behaviour if not..
11498 */
11499 +static inline int pte_user(pte_t pte)
11500 +{
11501 + return pte_val(pte) & _PAGE_USER;
11502 +}
11503 +
11504 static inline int pte_dirty(pte_t pte)
11505 {
11506 return pte_flags(pte) & _PAGE_DIRTY;
11507 @@ -196,9 +236,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
11508 return pte_clear_flags(pte, _PAGE_RW);
11509 }
11510
11511 +static inline pte_t pte_mkread(pte_t pte)
11512 +{
11513 + return __pte(pte_val(pte) | _PAGE_USER);
11514 +}
11515 +
11516 static inline pte_t pte_mkexec(pte_t pte)
11517 {
11518 - return pte_clear_flags(pte, _PAGE_NX);
11519 +#ifdef CONFIG_X86_PAE
11520 + if (__supported_pte_mask & _PAGE_NX)
11521 + return pte_clear_flags(pte, _PAGE_NX);
11522 + else
11523 +#endif
11524 + return pte_set_flags(pte, _PAGE_USER);
11525 +}
11526 +
11527 +static inline pte_t pte_exprotect(pte_t pte)
11528 +{
11529 +#ifdef CONFIG_X86_PAE
11530 + if (__supported_pte_mask & _PAGE_NX)
11531 + return pte_set_flags(pte, _PAGE_NX);
11532 + else
11533 +#endif
11534 + return pte_clear_flags(pte, _PAGE_USER);
11535 }
11536
11537 static inline pte_t pte_mkdirty(pte_t pte)
11538 @@ -390,6 +450,15 @@ pte_t *populate_extra_pte(unsigned long vaddr);
11539 #endif
11540
11541 #ifndef __ASSEMBLY__
11542 +
11543 +#ifdef CONFIG_PAX_PER_CPU_PGD
11544 +extern pgd_t cpu_pgd[NR_CPUS][PTRS_PER_PGD];
11545 +static inline pgd_t *get_cpu_pgd(unsigned int cpu)
11546 +{
11547 + return cpu_pgd[cpu];
11548 +}
11549 +#endif
11550 +
11551 #include <linux/mm_types.h>
11552
11553 static inline int pte_none(pte_t pte)
11554 @@ -560,7 +629,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
11555
11556 static inline int pgd_bad(pgd_t pgd)
11557 {
11558 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
11559 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
11560 }
11561
11562 static inline int pgd_none(pgd_t pgd)
11563 @@ -583,7 +652,12 @@ static inline int pgd_none(pgd_t pgd)
11564 * pgd_offset() returns a (pgd_t *)
11565 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
11566 */
11567 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
11568 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
11569 +
11570 +#ifdef CONFIG_PAX_PER_CPU_PGD
11571 +#define pgd_offset_cpu(cpu, address) (get_cpu_pgd(cpu) + pgd_index(address))
11572 +#endif
11573 +
11574 /*
11575 * a shortcut which implies the use of the kernel's pgd, instead
11576 * of a process's
11577 @@ -594,6 +668,20 @@ static inline int pgd_none(pgd_t pgd)
11578 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
11579 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
11580
11581 +#ifdef CONFIG_X86_32
11582 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
11583 +#else
11584 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
11585 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
11586 +
11587 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11588 +#define PAX_USER_SHADOW_BASE (_AC(1,UL) << TASK_SIZE_MAX_SHIFT)
11589 +#else
11590 +#define PAX_USER_SHADOW_BASE (_AC(0,UL))
11591 +#endif
11592 +
11593 +#endif
11594 +
11595 #ifndef __ASSEMBLY__
11596
11597 extern int direct_gbpages;
11598 @@ -758,11 +846,23 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
11599 * dst and src can be on the same page, but the range must not overlap,
11600 * and must not cross a page boundary.
11601 */
11602 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
11603 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
11604 {
11605 - memcpy(dst, src, count * sizeof(pgd_t));
11606 + pax_open_kernel();
11607 + while (count--)
11608 + *dst++ = *src++;
11609 + pax_close_kernel();
11610 }
11611
11612 +#ifdef CONFIG_PAX_PER_CPU_PGD
11613 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
11614 +#endif
11615 +
11616 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
11617 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
11618 +#else
11619 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
11620 +#endif
11621
11622 #include <asm-generic/pgtable.h>
11623 #endif /* __ASSEMBLY__ */
11624 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
11625 index 0c92113..34a77c6 100644
11626 --- a/arch/x86/include/asm/pgtable_32.h
11627 +++ b/arch/x86/include/asm/pgtable_32.h
11628 @@ -25,9 +25,6 @@
11629 struct mm_struct;
11630 struct vm_area_struct;
11631
11632 -extern pgd_t swapper_pg_dir[1024];
11633 -extern pgd_t initial_page_table[1024];
11634 -
11635 static inline void pgtable_cache_init(void) { }
11636 static inline void check_pgt_cache(void) { }
11637 void paging_init(void);
11638 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
11639 # include <asm/pgtable-2level.h>
11640 #endif
11641
11642 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
11643 +extern pgd_t initial_page_table[PTRS_PER_PGD];
11644 +#ifdef CONFIG_X86_PAE
11645 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
11646 +#endif
11647 +
11648 #if defined(CONFIG_HIGHPTE)
11649 #define pte_offset_map(dir, address) \
11650 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
11651 @@ -62,7 +65,9 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
11652 /* Clear a kernel PTE and flush it from the TLB */
11653 #define kpte_clear_flush(ptep, vaddr) \
11654 do { \
11655 + pax_open_kernel(); \
11656 pte_clear(&init_mm, (vaddr), (ptep)); \
11657 + pax_close_kernel(); \
11658 __flush_tlb_one((vaddr)); \
11659 } while (0)
11660
11661 @@ -74,6 +79,9 @@ do { \
11662
11663 #endif /* !__ASSEMBLY__ */
11664
11665 +#define HAVE_ARCH_UNMAPPED_AREA
11666 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
11667 +
11668 /*
11669 * kern_addr_valid() is (1) for FLATMEM and (0) for
11670 * SPARSEMEM and DISCONTIGMEM
11671 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
11672 index ed5903b..c7fe163 100644
11673 --- a/arch/x86/include/asm/pgtable_32_types.h
11674 +++ b/arch/x86/include/asm/pgtable_32_types.h
11675 @@ -8,7 +8,7 @@
11676 */
11677 #ifdef CONFIG_X86_PAE
11678 # include <asm/pgtable-3level_types.h>
11679 -# define PMD_SIZE (1UL << PMD_SHIFT)
11680 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
11681 # define PMD_MASK (~(PMD_SIZE - 1))
11682 #else
11683 # include <asm/pgtable-2level_types.h>
11684 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
11685 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
11686 #endif
11687
11688 +#ifdef CONFIG_PAX_KERNEXEC
11689 +#ifndef __ASSEMBLY__
11690 +extern unsigned char MODULES_EXEC_VADDR[];
11691 +extern unsigned char MODULES_EXEC_END[];
11692 +#endif
11693 +#include <asm/boot.h>
11694 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
11695 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
11696 +#else
11697 +#define ktla_ktva(addr) (addr)
11698 +#define ktva_ktla(addr) (addr)
11699 +#endif
11700 +
11701 #define MODULES_VADDR VMALLOC_START
11702 #define MODULES_END VMALLOC_END
11703 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
11704 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
11705 index 975f709..9f779c9 100644
11706 --- a/arch/x86/include/asm/pgtable_64.h
11707 +++ b/arch/x86/include/asm/pgtable_64.h
11708 @@ -16,10 +16,14 @@
11709
11710 extern pud_t level3_kernel_pgt[512];
11711 extern pud_t level3_ident_pgt[512];
11712 +extern pud_t level3_vmalloc_start_pgt[512];
11713 +extern pud_t level3_vmalloc_end_pgt[512];
11714 +extern pud_t level3_vmemmap_pgt[512];
11715 +extern pud_t level2_vmemmap_pgt[512];
11716 extern pmd_t level2_kernel_pgt[512];
11717 extern pmd_t level2_fixmap_pgt[512];
11718 -extern pmd_t level2_ident_pgt[512];
11719 -extern pgd_t init_level4_pgt[];
11720 +extern pmd_t level2_ident_pgt[512*2];
11721 +extern pgd_t init_level4_pgt[512];
11722
11723 #define swapper_pg_dir init_level4_pgt
11724
11725 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
11726
11727 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
11728 {
11729 + pax_open_kernel();
11730 *pmdp = pmd;
11731 + pax_close_kernel();
11732 }
11733
11734 static inline void native_pmd_clear(pmd_t *pmd)
11735 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
11736
11737 static inline void native_set_pud(pud_t *pudp, pud_t pud)
11738 {
11739 + pax_open_kernel();
11740 *pudp = pud;
11741 + pax_close_kernel();
11742 }
11743
11744 static inline void native_pud_clear(pud_t *pud)
11745 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
11746
11747 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
11748 {
11749 + pax_open_kernel();
11750 + *pgdp = pgd;
11751 + pax_close_kernel();
11752 +}
11753 +
11754 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
11755 +{
11756 *pgdp = pgd;
11757 }
11758
11759 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
11760 index 766ea16..5b96cb3 100644
11761 --- a/arch/x86/include/asm/pgtable_64_types.h
11762 +++ b/arch/x86/include/asm/pgtable_64_types.h
11763 @@ -59,5 +59,10 @@ typedef struct { pteval_t pte; } pte_t;
11764 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
11765 #define MODULES_END _AC(0xffffffffff000000, UL)
11766 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
11767 +#define MODULES_EXEC_VADDR MODULES_VADDR
11768 +#define MODULES_EXEC_END MODULES_END
11769 +
11770 +#define ktla_ktva(addr) (addr)
11771 +#define ktva_ktla(addr) (addr)
11772
11773 #endif /* _ASM_X86_PGTABLE_64_DEFS_H */
11774 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
11775 index 013286a..8b42f4f 100644
11776 --- a/arch/x86/include/asm/pgtable_types.h
11777 +++ b/arch/x86/include/asm/pgtable_types.h
11778 @@ -16,13 +16,12 @@
11779 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
11780 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
11781 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
11782 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
11783 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
11784 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
11785 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
11786 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
11787 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
11788 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
11789 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
11790 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
11791 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
11792 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
11793
11794 /* If _PAGE_BIT_PRESENT is clear, we use these: */
11795 @@ -40,7 +39,6 @@
11796 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
11797 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
11798 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
11799 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
11800 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
11801 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
11802 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
11803 @@ -57,8 +55,10 @@
11804
11805 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
11806 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
11807 -#else
11808 +#elif defined(CONFIG_KMEMCHECK)
11809 #define _PAGE_NX (_AT(pteval_t, 0))
11810 +#else
11811 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
11812 #endif
11813
11814 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
11815 @@ -96,6 +96,9 @@
11816 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
11817 _PAGE_ACCESSED)
11818
11819 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
11820 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
11821 +
11822 #define __PAGE_KERNEL_EXEC \
11823 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
11824 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
11825 @@ -106,7 +109,7 @@
11826 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
11827 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
11828 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
11829 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
11830 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
11831 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
11832 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
11833 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
11834 @@ -168,8 +171,8 @@
11835 * bits are combined, this will alow user to access the high address mapped
11836 * VDSO in the presence of CONFIG_COMPAT_VDSO
11837 */
11838 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
11839 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
11840 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
11841 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
11842 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
11843 #endif
11844
11845 @@ -207,7 +210,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
11846 {
11847 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
11848 }
11849 +#endif
11850
11851 +#if PAGETABLE_LEVELS == 3
11852 +#include <asm-generic/pgtable-nopud.h>
11853 +#endif
11854 +
11855 +#if PAGETABLE_LEVELS == 2
11856 +#include <asm-generic/pgtable-nopmd.h>
11857 +#endif
11858 +
11859 +#ifndef __ASSEMBLY__
11860 #if PAGETABLE_LEVELS > 3
11861 typedef struct { pudval_t pud; } pud_t;
11862
11863 @@ -221,8 +234,6 @@ static inline pudval_t native_pud_val(pud_t pud)
11864 return pud.pud;
11865 }
11866 #else
11867 -#include <asm-generic/pgtable-nopud.h>
11868 -
11869 static inline pudval_t native_pud_val(pud_t pud)
11870 {
11871 return native_pgd_val(pud.pgd);
11872 @@ -242,8 +253,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
11873 return pmd.pmd;
11874 }
11875 #else
11876 -#include <asm-generic/pgtable-nopmd.h>
11877 -
11878 static inline pmdval_t native_pmd_val(pmd_t pmd)
11879 {
11880 return native_pgd_val(pmd.pud.pgd);
11881 @@ -283,7 +292,6 @@ typedef struct page *pgtable_t;
11882
11883 extern pteval_t __supported_pte_mask;
11884 extern void set_nx(void);
11885 -extern int nx_enabled;
11886
11887 #define pgprot_writecombine pgprot_writecombine
11888 extern pgprot_t pgprot_writecombine(pgprot_t prot);
11889 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
11890 index 58545c9..fe6fc38e 100644
11891 --- a/arch/x86/include/asm/processor.h
11892 +++ b/arch/x86/include/asm/processor.h
11893 @@ -266,7 +266,7 @@ struct tss_struct {
11894
11895 } ____cacheline_aligned;
11896
11897 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
11898 +extern struct tss_struct init_tss[NR_CPUS];
11899
11900 /*
11901 * Save the original ist values for checking stack pointers during debugging
11902 @@ -860,11 +860,18 @@ static inline void spin_lock_prefetch(const void *x)
11903 */
11904 #define TASK_SIZE PAGE_OFFSET
11905 #define TASK_SIZE_MAX TASK_SIZE
11906 +
11907 +#ifdef CONFIG_PAX_SEGMEXEC
11908 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
11909 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
11910 +#else
11911 #define STACK_TOP TASK_SIZE
11912 -#define STACK_TOP_MAX STACK_TOP
11913 +#endif
11914 +
11915 +#define STACK_TOP_MAX TASK_SIZE
11916
11917 #define INIT_THREAD { \
11918 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
11919 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
11920 .vm86_info = NULL, \
11921 .sysenter_cs = __KERNEL_CS, \
11922 .io_bitmap_ptr = NULL, \
11923 @@ -878,7 +885,7 @@ static inline void spin_lock_prefetch(const void *x)
11924 */
11925 #define INIT_TSS { \
11926 .x86_tss = { \
11927 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
11928 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
11929 .ss0 = __KERNEL_DS, \
11930 .ss1 = __KERNEL_CS, \
11931 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
11932 @@ -889,11 +896,7 @@ static inline void spin_lock_prefetch(const void *x)
11933 extern unsigned long thread_saved_pc(struct task_struct *tsk);
11934
11935 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
11936 -#define KSTK_TOP(info) \
11937 -({ \
11938 - unsigned long *__ptr = (unsigned long *)(info); \
11939 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
11940 -})
11941 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
11942
11943 /*
11944 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
11945 @@ -908,7 +911,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
11946 #define task_pt_regs(task) \
11947 ({ \
11948 struct pt_regs *__regs__; \
11949 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
11950 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
11951 __regs__ - 1; \
11952 })
11953
11954 @@ -918,13 +921,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
11955 /*
11956 * User space process size. 47bits minus one guard page.
11957 */
11958 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
11959 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
11960
11961 /* This decides where the kernel will search for a free chunk of vm
11962 * space during mmap's.
11963 */
11964 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
11965 - 0xc0000000 : 0xFFFFe000)
11966 + 0xc0000000 : 0xFFFFf000)
11967
11968 #define TASK_SIZE (test_thread_flag(TIF_IA32) ? \
11969 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
11970 @@ -935,11 +938,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
11971 #define STACK_TOP_MAX TASK_SIZE_MAX
11972
11973 #define INIT_THREAD { \
11974 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
11975 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
11976 }
11977
11978 #define INIT_TSS { \
11979 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
11980 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
11981 }
11982
11983 /*
11984 @@ -961,6 +964,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
11985 */
11986 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
11987
11988 +#ifdef CONFIG_PAX_SEGMEXEC
11989 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
11990 +#endif
11991 +
11992 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
11993
11994 /* Get/set a process' ability to use the timestamp counter instruction */
11995 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
11996 index 3566454..4bdfb8c 100644
11997 --- a/arch/x86/include/asm/ptrace.h
11998 +++ b/arch/x86/include/asm/ptrace.h
11999 @@ -156,28 +156,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
12000 }
12001
12002 /*
12003 - * user_mode_vm(regs) determines whether a register set came from user mode.
12004 + * user_mode(regs) determines whether a register set came from user mode.
12005 * This is true if V8086 mode was enabled OR if the register set was from
12006 * protected mode with RPL-3 CS value. This tricky test checks that with
12007 * one comparison. Many places in the kernel can bypass this full check
12008 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
12009 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
12010 + * be used.
12011 */
12012 -static inline int user_mode(struct pt_regs *regs)
12013 +static inline int user_mode_novm(struct pt_regs *regs)
12014 {
12015 #ifdef CONFIG_X86_32
12016 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
12017 #else
12018 - return !!(regs->cs & 3);
12019 + return !!(regs->cs & SEGMENT_RPL_MASK);
12020 #endif
12021 }
12022
12023 -static inline int user_mode_vm(struct pt_regs *regs)
12024 +static inline int user_mode(struct pt_regs *regs)
12025 {
12026 #ifdef CONFIG_X86_32
12027 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
12028 USER_RPL;
12029 #else
12030 - return user_mode(regs);
12031 + return user_mode_novm(regs);
12032 #endif
12033 }
12034
12035 @@ -193,15 +194,16 @@ static inline int v8086_mode(struct pt_regs *regs)
12036 #ifdef CONFIG_X86_64
12037 static inline bool user_64bit_mode(struct pt_regs *regs)
12038 {
12039 + unsigned long cs = regs->cs & 0xffff;
12040 #ifndef CONFIG_PARAVIRT
12041 /*
12042 * On non-paravirt systems, this is the only long mode CPL 3
12043 * selector. We do not allow long mode selectors in the LDT.
12044 */
12045 - return regs->cs == __USER_CS;
12046 + return cs == __USER_CS;
12047 #else
12048 /* Headers are too twisted for this to go in paravirt.h. */
12049 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
12050 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
12051 #endif
12052 }
12053 #endif
12054 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
12055 index 92f29706..a79cbbb 100644
12056 --- a/arch/x86/include/asm/reboot.h
12057 +++ b/arch/x86/include/asm/reboot.h
12058 @@ -6,19 +6,19 @@
12059 struct pt_regs;
12060
12061 struct machine_ops {
12062 - void (*restart)(char *cmd);
12063 - void (*halt)(void);
12064 - void (*power_off)(void);
12065 + void (* __noreturn restart)(char *cmd);
12066 + void (* __noreturn halt)(void);
12067 + void (* __noreturn power_off)(void);
12068 void (*shutdown)(void);
12069 void (*crash_shutdown)(struct pt_regs *);
12070 - void (*emergency_restart)(void);
12071 -};
12072 + void (* __noreturn emergency_restart)(void);
12073 +} __no_const;
12074
12075 extern struct machine_ops machine_ops;
12076
12077 void native_machine_crash_shutdown(struct pt_regs *regs);
12078 void native_machine_shutdown(void);
12079 -void machine_real_restart(unsigned int type);
12080 +void machine_real_restart(unsigned int type) __noreturn;
12081 /* These must match dispatch_table in reboot_32.S */
12082 #define MRR_BIOS 0
12083 #define MRR_APM 1
12084 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
12085 index 2dbe4a7..ce1db00 100644
12086 --- a/arch/x86/include/asm/rwsem.h
12087 +++ b/arch/x86/include/asm/rwsem.h
12088 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
12089 {
12090 asm volatile("# beginning down_read\n\t"
12091 LOCK_PREFIX _ASM_INC "(%1)\n\t"
12092 +
12093 +#ifdef CONFIG_PAX_REFCOUNT
12094 + "jno 0f\n"
12095 + LOCK_PREFIX _ASM_DEC "(%1)\n"
12096 + "int $4\n0:\n"
12097 + _ASM_EXTABLE(0b, 0b)
12098 +#endif
12099 +
12100 /* adds 0x00000001 */
12101 " jns 1f\n"
12102 " call call_rwsem_down_read_failed\n"
12103 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
12104 "1:\n\t"
12105 " mov %1,%2\n\t"
12106 " add %3,%2\n\t"
12107 +
12108 +#ifdef CONFIG_PAX_REFCOUNT
12109 + "jno 0f\n"
12110 + "sub %3,%2\n"
12111 + "int $4\n0:\n"
12112 + _ASM_EXTABLE(0b, 0b)
12113 +#endif
12114 +
12115 " jle 2f\n\t"
12116 LOCK_PREFIX " cmpxchg %2,%0\n\t"
12117 " jnz 1b\n\t"
12118 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
12119 long tmp;
12120 asm volatile("# beginning down_write\n\t"
12121 LOCK_PREFIX " xadd %1,(%2)\n\t"
12122 +
12123 +#ifdef CONFIG_PAX_REFCOUNT
12124 + "jno 0f\n"
12125 + "mov %1,(%2)\n"
12126 + "int $4\n0:\n"
12127 + _ASM_EXTABLE(0b, 0b)
12128 +#endif
12129 +
12130 /* adds 0xffff0001, returns the old value */
12131 " test %1,%1\n\t"
12132 /* was the count 0 before? */
12133 @@ -141,6 +165,14 @@ static inline void __up_read(struct rw_semaphore *sem)
12134 long tmp;
12135 asm volatile("# beginning __up_read\n\t"
12136 LOCK_PREFIX " xadd %1,(%2)\n\t"
12137 +
12138 +#ifdef CONFIG_PAX_REFCOUNT
12139 + "jno 0f\n"
12140 + "mov %1,(%2)\n"
12141 + "int $4\n0:\n"
12142 + _ASM_EXTABLE(0b, 0b)
12143 +#endif
12144 +
12145 /* subtracts 1, returns the old value */
12146 " jns 1f\n\t"
12147 " call call_rwsem_wake\n" /* expects old value in %edx */
12148 @@ -159,6 +191,14 @@ static inline void __up_write(struct rw_semaphore *sem)
12149 long tmp;
12150 asm volatile("# beginning __up_write\n\t"
12151 LOCK_PREFIX " xadd %1,(%2)\n\t"
12152 +
12153 +#ifdef CONFIG_PAX_REFCOUNT
12154 + "jno 0f\n"
12155 + "mov %1,(%2)\n"
12156 + "int $4\n0:\n"
12157 + _ASM_EXTABLE(0b, 0b)
12158 +#endif
12159 +
12160 /* subtracts 0xffff0001, returns the old value */
12161 " jns 1f\n\t"
12162 " call call_rwsem_wake\n" /* expects old value in %edx */
12163 @@ -176,6 +216,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
12164 {
12165 asm volatile("# beginning __downgrade_write\n\t"
12166 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
12167 +
12168 +#ifdef CONFIG_PAX_REFCOUNT
12169 + "jno 0f\n"
12170 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
12171 + "int $4\n0:\n"
12172 + _ASM_EXTABLE(0b, 0b)
12173 +#endif
12174 +
12175 /*
12176 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
12177 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
12178 @@ -194,7 +242,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
12179 */
12180 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
12181 {
12182 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
12183 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
12184 +
12185 +#ifdef CONFIG_PAX_REFCOUNT
12186 + "jno 0f\n"
12187 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
12188 + "int $4\n0:\n"
12189 + _ASM_EXTABLE(0b, 0b)
12190 +#endif
12191 +
12192 : "+m" (sem->count)
12193 : "er" (delta));
12194 }
12195 @@ -204,7 +260,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
12196 */
12197 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
12198 {
12199 - return delta + xadd(&sem->count, delta);
12200 + return delta + xadd_check_overflow(&sem->count, delta);
12201 }
12202
12203 #endif /* __KERNEL__ */
12204 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
12205 index 5e64171..f58957e 100644
12206 --- a/arch/x86/include/asm/segment.h
12207 +++ b/arch/x86/include/asm/segment.h
12208 @@ -64,10 +64,15 @@
12209 * 26 - ESPFIX small SS
12210 * 27 - per-cpu [ offset to per-cpu data area ]
12211 * 28 - stack_canary-20 [ for stack protector ]
12212 - * 29 - unused
12213 - * 30 - unused
12214 + * 29 - PCI BIOS CS
12215 + * 30 - PCI BIOS DS
12216 * 31 - TSS for double fault handler
12217 */
12218 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
12219 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
12220 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
12221 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
12222 +
12223 #define GDT_ENTRY_TLS_MIN 6
12224 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
12225
12226 @@ -79,6 +84,8 @@
12227
12228 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
12229
12230 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
12231 +
12232 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
12233
12234 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
12235 @@ -104,6 +111,12 @@
12236 #define __KERNEL_STACK_CANARY 0
12237 #endif
12238
12239 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
12240 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
12241 +
12242 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
12243 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
12244 +
12245 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
12246
12247 /*
12248 @@ -141,7 +154,7 @@
12249 */
12250
12251 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
12252 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
12253 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
12254
12255
12256 #else
12257 @@ -165,6 +178,8 @@
12258 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
12259 #define __USER32_DS __USER_DS
12260
12261 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
12262 +
12263 #define GDT_ENTRY_TSS 8 /* needs two entries */
12264 #define GDT_ENTRY_LDT 10 /* needs two entries */
12265 #define GDT_ENTRY_TLS_MIN 12
12266 @@ -185,6 +200,7 @@
12267 #endif
12268
12269 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
12270 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
12271 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
12272 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
12273 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
12274 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
12275 index 0434c40..1714bf0 100644
12276 --- a/arch/x86/include/asm/smp.h
12277 +++ b/arch/x86/include/asm/smp.h
12278 @@ -36,7 +36,7 @@ DECLARE_PER_CPU(cpumask_var_t, cpu_core_map);
12279 /* cpus sharing the last level cache: */
12280 DECLARE_PER_CPU(cpumask_var_t, cpu_llc_shared_map);
12281 DECLARE_PER_CPU(u16, cpu_llc_id);
12282 -DECLARE_PER_CPU(int, cpu_number);
12283 +DECLARE_PER_CPU(unsigned int, cpu_number);
12284
12285 static inline struct cpumask *cpu_sibling_mask(int cpu)
12286 {
12287 @@ -77,7 +77,7 @@ struct smp_ops {
12288
12289 void (*send_call_func_ipi)(const struct cpumask *mask);
12290 void (*send_call_func_single_ipi)(int cpu);
12291 -};
12292 +} __no_const;
12293
12294 /* Globals due to paravirt */
12295 extern void set_cpu_sibling_map(int cpu);
12296 @@ -192,14 +192,8 @@ extern unsigned disabled_cpus __cpuinitdata;
12297 extern int safe_smp_processor_id(void);
12298
12299 #elif defined(CONFIG_X86_64_SMP)
12300 -#define raw_smp_processor_id() (percpu_read(cpu_number))
12301 -
12302 -#define stack_smp_processor_id() \
12303 -({ \
12304 - struct thread_info *ti; \
12305 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
12306 - ti->cpu; \
12307 -})
12308 +#define raw_smp_processor_id() (percpu_read(cpu_number))
12309 +#define stack_smp_processor_id() raw_smp_processor_id()
12310 #define safe_smp_processor_id() smp_processor_id()
12311
12312 #endif
12313 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
12314 index a82c2bf..2198f61 100644
12315 --- a/arch/x86/include/asm/spinlock.h
12316 +++ b/arch/x86/include/asm/spinlock.h
12317 @@ -175,6 +175,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
12318 static inline void arch_read_lock(arch_rwlock_t *rw)
12319 {
12320 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
12321 +
12322 +#ifdef CONFIG_PAX_REFCOUNT
12323 + "jno 0f\n"
12324 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
12325 + "int $4\n0:\n"
12326 + _ASM_EXTABLE(0b, 0b)
12327 +#endif
12328 +
12329 "jns 1f\n"
12330 "call __read_lock_failed\n\t"
12331 "1:\n"
12332 @@ -184,6 +192,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
12333 static inline void arch_write_lock(arch_rwlock_t *rw)
12334 {
12335 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
12336 +
12337 +#ifdef CONFIG_PAX_REFCOUNT
12338 + "jno 0f\n"
12339 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
12340 + "int $4\n0:\n"
12341 + _ASM_EXTABLE(0b, 0b)
12342 +#endif
12343 +
12344 "jz 1f\n"
12345 "call __write_lock_failed\n\t"
12346 "1:\n"
12347 @@ -213,13 +229,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
12348
12349 static inline void arch_read_unlock(arch_rwlock_t *rw)
12350 {
12351 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
12352 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
12353 +
12354 +#ifdef CONFIG_PAX_REFCOUNT
12355 + "jno 0f\n"
12356 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
12357 + "int $4\n0:\n"
12358 + _ASM_EXTABLE(0b, 0b)
12359 +#endif
12360 +
12361 :"+m" (rw->lock) : : "memory");
12362 }
12363
12364 static inline void arch_write_unlock(arch_rwlock_t *rw)
12365 {
12366 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
12367 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
12368 +
12369 +#ifdef CONFIG_PAX_REFCOUNT
12370 + "jno 0f\n"
12371 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
12372 + "int $4\n0:\n"
12373 + _ASM_EXTABLE(0b, 0b)
12374 +#endif
12375 +
12376 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
12377 }
12378
12379 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
12380 index 1575177..cb23f52 100644
12381 --- a/arch/x86/include/asm/stackprotector.h
12382 +++ b/arch/x86/include/asm/stackprotector.h
12383 @@ -48,7 +48,7 @@
12384 * head_32 for boot CPU and setup_per_cpu_areas() for others.
12385 */
12386 #define GDT_STACK_CANARY_INIT \
12387 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
12388 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
12389
12390 /*
12391 * Initialize the stackprotector canary value.
12392 @@ -113,7 +113,7 @@ static inline void setup_stack_canary_segment(int cpu)
12393
12394 static inline void load_stack_canary_segment(void)
12395 {
12396 -#ifdef CONFIG_X86_32
12397 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
12398 asm volatile ("mov %0, %%gs" : : "r" (0));
12399 #endif
12400 }
12401 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
12402 index 70bbe39..4ae2bd4 100644
12403 --- a/arch/x86/include/asm/stacktrace.h
12404 +++ b/arch/x86/include/asm/stacktrace.h
12405 @@ -11,28 +11,20 @@
12406
12407 extern int kstack_depth_to_print;
12408
12409 -struct thread_info;
12410 +struct task_struct;
12411 struct stacktrace_ops;
12412
12413 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
12414 - unsigned long *stack,
12415 - unsigned long bp,
12416 - const struct stacktrace_ops *ops,
12417 - void *data,
12418 - unsigned long *end,
12419 - int *graph);
12420 +typedef unsigned long walk_stack_t(struct task_struct *task,
12421 + void *stack_start,
12422 + unsigned long *stack,
12423 + unsigned long bp,
12424 + const struct stacktrace_ops *ops,
12425 + void *data,
12426 + unsigned long *end,
12427 + int *graph);
12428
12429 -extern unsigned long
12430 -print_context_stack(struct thread_info *tinfo,
12431 - unsigned long *stack, unsigned long bp,
12432 - const struct stacktrace_ops *ops, void *data,
12433 - unsigned long *end, int *graph);
12434 -
12435 -extern unsigned long
12436 -print_context_stack_bp(struct thread_info *tinfo,
12437 - unsigned long *stack, unsigned long bp,
12438 - const struct stacktrace_ops *ops, void *data,
12439 - unsigned long *end, int *graph);
12440 +extern walk_stack_t print_context_stack;
12441 +extern walk_stack_t print_context_stack_bp;
12442
12443 /* Generic stack tracer with callbacks */
12444
12445 @@ -40,7 +32,7 @@ struct stacktrace_ops {
12446 void (*address)(void *data, unsigned long address, int reliable);
12447 /* On negative return stop dumping */
12448 int (*stack)(void *data, char *name);
12449 - walk_stack_t walk_stack;
12450 + walk_stack_t *walk_stack;
12451 };
12452
12453 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
12454 diff --git a/arch/x86/include/asm/sys_ia32.h b/arch/x86/include/asm/sys_ia32.h
12455 index cb23852..2dde194 100644
12456 --- a/arch/x86/include/asm/sys_ia32.h
12457 +++ b/arch/x86/include/asm/sys_ia32.h
12458 @@ -40,7 +40,7 @@ asmlinkage long sys32_rt_sigprocmask(int, compat_sigset_t __user *,
12459 compat_sigset_t __user *, unsigned int);
12460 asmlinkage long sys32_alarm(unsigned int);
12461
12462 -asmlinkage long sys32_waitpid(compat_pid_t, unsigned int *, int);
12463 +asmlinkage long sys32_waitpid(compat_pid_t, unsigned int __user *, int);
12464 asmlinkage long sys32_sysfs(int, u32, u32);
12465
12466 asmlinkage long sys32_sched_rr_get_interval(compat_pid_t,
12467 diff --git a/arch/x86/include/asm/system.h b/arch/x86/include/asm/system.h
12468 index 2d2f01c..f985723 100644
12469 --- a/arch/x86/include/asm/system.h
12470 +++ b/arch/x86/include/asm/system.h
12471 @@ -129,7 +129,7 @@ do { \
12472 "call __switch_to\n\t" \
12473 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
12474 __switch_canary \
12475 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
12476 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
12477 "movq %%rax,%%rdi\n\t" \
12478 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
12479 "jnz ret_from_fork\n\t" \
12480 @@ -140,7 +140,7 @@ do { \
12481 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
12482 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
12483 [_tif_fork] "i" (_TIF_FORK), \
12484 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
12485 + [thread_info] "m" (current_tinfo), \
12486 [current_task] "m" (current_task) \
12487 __switch_canary_iparam \
12488 : "memory", "cc" __EXTRA_CLOBBER)
12489 @@ -200,7 +200,7 @@ static inline unsigned long get_limit(unsigned long segment)
12490 {
12491 unsigned long __limit;
12492 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
12493 - return __limit + 1;
12494 + return __limit;
12495 }
12496
12497 static inline void native_clts(void)
12498 @@ -397,13 +397,13 @@ void enable_hlt(void);
12499
12500 void cpu_idle_wait(void);
12501
12502 -extern unsigned long arch_align_stack(unsigned long sp);
12503 +#define arch_align_stack(x) ((x) & ~0xfUL)
12504 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
12505
12506 void default_idle(void);
12507 bool set_pm_idle_to_default(void);
12508
12509 -void stop_this_cpu(void *dummy);
12510 +void stop_this_cpu(void *dummy) __noreturn;
12511
12512 /*
12513 * Force strict CPU ordering.
12514 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
12515 index cfd8144..664ac89 100644
12516 --- a/arch/x86/include/asm/thread_info.h
12517 +++ b/arch/x86/include/asm/thread_info.h
12518 @@ -10,6 +10,7 @@
12519 #include <linux/compiler.h>
12520 #include <asm/page.h>
12521 #include <asm/types.h>
12522 +#include <asm/percpu.h>
12523
12524 /*
12525 * low level task data that entry.S needs immediate access to
12526 @@ -24,7 +25,6 @@ struct exec_domain;
12527 #include <linux/atomic.h>
12528
12529 struct thread_info {
12530 - struct task_struct *task; /* main task structure */
12531 struct exec_domain *exec_domain; /* execution domain */
12532 __u32 flags; /* low level flags */
12533 __u32 status; /* thread synchronous flags */
12534 @@ -34,19 +34,13 @@ struct thread_info {
12535 mm_segment_t addr_limit;
12536 struct restart_block restart_block;
12537 void __user *sysenter_return;
12538 -#ifdef CONFIG_X86_32
12539 - unsigned long previous_esp; /* ESP of the previous stack in
12540 - case of nested (IRQ) stacks
12541 - */
12542 - __u8 supervisor_stack[0];
12543 -#endif
12544 + unsigned long lowest_stack;
12545 unsigned int sig_on_uaccess_error:1;
12546 unsigned int uaccess_err:1; /* uaccess failed */
12547 };
12548
12549 -#define INIT_THREAD_INFO(tsk) \
12550 +#define INIT_THREAD_INFO \
12551 { \
12552 - .task = &tsk, \
12553 .exec_domain = &default_exec_domain, \
12554 .flags = 0, \
12555 .cpu = 0, \
12556 @@ -57,7 +51,7 @@ struct thread_info {
12557 }, \
12558 }
12559
12560 -#define init_thread_info (init_thread_union.thread_info)
12561 +#define init_thread_info (init_thread_union.stack)
12562 #define init_stack (init_thread_union.stack)
12563
12564 #else /* !__ASSEMBLY__ */
12565 @@ -95,6 +89,7 @@ struct thread_info {
12566 #define TIF_BLOCKSTEP 25 /* set when we want DEBUGCTLMSR_BTF */
12567 #define TIF_LAZY_MMU_UPDATES 27 /* task is updating the mmu lazily */
12568 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
12569 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
12570
12571 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
12572 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
12573 @@ -116,16 +111,17 @@ struct thread_info {
12574 #define _TIF_BLOCKSTEP (1 << TIF_BLOCKSTEP)
12575 #define _TIF_LAZY_MMU_UPDATES (1 << TIF_LAZY_MMU_UPDATES)
12576 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
12577 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
12578
12579 /* work to do in syscall_trace_enter() */
12580 #define _TIF_WORK_SYSCALL_ENTRY \
12581 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
12582 - _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT)
12583 + _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
12584
12585 /* work to do in syscall_trace_leave() */
12586 #define _TIF_WORK_SYSCALL_EXIT \
12587 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
12588 - _TIF_SYSCALL_TRACEPOINT)
12589 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
12590
12591 /* work to do on interrupt/exception return */
12592 #define _TIF_WORK_MASK \
12593 @@ -135,7 +131,8 @@ struct thread_info {
12594
12595 /* work to do on any return to user space */
12596 #define _TIF_ALLWORK_MASK \
12597 - ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT)
12598 + ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
12599 + _TIF_GRSEC_SETXID)
12600
12601 /* Only used for 64 bit */
12602 #define _TIF_DO_NOTIFY_MASK \
12603 @@ -169,45 +166,40 @@ struct thread_info {
12604 ret; \
12605 })
12606
12607 -#ifdef CONFIG_X86_32
12608 -
12609 -#define STACK_WARN (THREAD_SIZE/8)
12610 -/*
12611 - * macros/functions for gaining access to the thread information structure
12612 - *
12613 - * preempt_count needs to be 1 initially, until the scheduler is functional.
12614 - */
12615 -#ifndef __ASSEMBLY__
12616 -
12617 -
12618 -/* how to get the current stack pointer from C */
12619 -register unsigned long current_stack_pointer asm("esp") __used;
12620 -
12621 -/* how to get the thread information struct from C */
12622 -static inline struct thread_info *current_thread_info(void)
12623 -{
12624 - return (struct thread_info *)
12625 - (current_stack_pointer & ~(THREAD_SIZE - 1));
12626 -}
12627 -
12628 -#else /* !__ASSEMBLY__ */
12629 -
12630 +#ifdef __ASSEMBLY__
12631 /* how to get the thread information struct from ASM */
12632 #define GET_THREAD_INFO(reg) \
12633 - movl $-THREAD_SIZE, reg; \
12634 - andl %esp, reg
12635 + mov PER_CPU_VAR(current_tinfo), reg
12636
12637 /* use this one if reg already contains %esp */
12638 -#define GET_THREAD_INFO_WITH_ESP(reg) \
12639 - andl $-THREAD_SIZE, reg
12640 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
12641 +#else
12642 +/* how to get the thread information struct from C */
12643 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
12644 +
12645 +static __always_inline struct thread_info *current_thread_info(void)
12646 +{
12647 + return percpu_read_stable(current_tinfo);
12648 +}
12649 +#endif
12650 +
12651 +#ifdef CONFIG_X86_32
12652 +
12653 +#define STACK_WARN (THREAD_SIZE/8)
12654 +/*
12655 + * macros/functions for gaining access to the thread information structure
12656 + *
12657 + * preempt_count needs to be 1 initially, until the scheduler is functional.
12658 + */
12659 +#ifndef __ASSEMBLY__
12660 +
12661 +/* how to get the current stack pointer from C */
12662 +register unsigned long current_stack_pointer asm("esp") __used;
12663
12664 #endif
12665
12666 #else /* X86_32 */
12667
12668 -#include <asm/percpu.h>
12669 -#define KERNEL_STACK_OFFSET (5*8)
12670 -
12671 /*
12672 * macros/functions for gaining access to the thread information structure
12673 * preempt_count needs to be 1 initially, until the scheduler is functional.
12674 @@ -215,27 +207,8 @@ static inline struct thread_info *current_thread_info(void)
12675 #ifndef __ASSEMBLY__
12676 DECLARE_PER_CPU(unsigned long, kernel_stack);
12677
12678 -static inline struct thread_info *current_thread_info(void)
12679 -{
12680 - struct thread_info *ti;
12681 - ti = (void *)(percpu_read_stable(kernel_stack) +
12682 - KERNEL_STACK_OFFSET - THREAD_SIZE);
12683 - return ti;
12684 -}
12685 -
12686 -#else /* !__ASSEMBLY__ */
12687 -
12688 -/* how to get the thread information struct from ASM */
12689 -#define GET_THREAD_INFO(reg) \
12690 - movq PER_CPU_VAR(kernel_stack),reg ; \
12691 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
12692 -
12693 -/*
12694 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
12695 - * a certain register (to be used in assembler memory operands).
12696 - */
12697 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
12698 -
12699 +/* how to get the current stack pointer from C */
12700 +register unsigned long current_stack_pointer asm("rsp") __used;
12701 #endif
12702
12703 #endif /* !X86_32 */
12704 @@ -269,5 +242,16 @@ extern void arch_task_cache_init(void);
12705 extern void free_thread_info(struct thread_info *ti);
12706 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
12707 #define arch_task_cache_init arch_task_cache_init
12708 +
12709 +#define __HAVE_THREAD_FUNCTIONS
12710 +#define task_thread_info(task) (&(task)->tinfo)
12711 +#define task_stack_page(task) ((task)->stack)
12712 +#define setup_thread_stack(p, org) do {} while (0)
12713 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
12714 +
12715 +#define __HAVE_ARCH_TASK_STRUCT_ALLOCATOR
12716 +extern struct task_struct *alloc_task_struct_node(int node);
12717 +extern void free_task_struct(struct task_struct *);
12718 +
12719 #endif
12720 #endif /* _ASM_X86_THREAD_INFO_H */
12721 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
12722 index 8be5f54..7ae826d 100644
12723 --- a/arch/x86/include/asm/uaccess.h
12724 +++ b/arch/x86/include/asm/uaccess.h
12725 @@ -7,12 +7,15 @@
12726 #include <linux/compiler.h>
12727 #include <linux/thread_info.h>
12728 #include <linux/string.h>
12729 +#include <linux/sched.h>
12730 #include <asm/asm.h>
12731 #include <asm/page.h>
12732
12733 #define VERIFY_READ 0
12734 #define VERIFY_WRITE 1
12735
12736 +extern void check_object_size(const void *ptr, unsigned long n, bool to);
12737 +
12738 /*
12739 * The fs value determines whether argument validity checking should be
12740 * performed or not. If get_fs() == USER_DS, checking is performed, with
12741 @@ -28,7 +31,12 @@
12742
12743 #define get_ds() (KERNEL_DS)
12744 #define get_fs() (current_thread_info()->addr_limit)
12745 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
12746 +void __set_fs(mm_segment_t x);
12747 +void set_fs(mm_segment_t x);
12748 +#else
12749 #define set_fs(x) (current_thread_info()->addr_limit = (x))
12750 +#endif
12751
12752 #define segment_eq(a, b) ((a).seg == (b).seg)
12753
12754 @@ -76,7 +84,33 @@
12755 * checks that the pointer is in the user space range - after calling
12756 * this function, memory access functions may still return -EFAULT.
12757 */
12758 -#define access_ok(type, addr, size) (likely(__range_not_ok(addr, size) == 0))
12759 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size) == 0))
12760 +#define access_ok(type, addr, size) \
12761 +({ \
12762 + long __size = size; \
12763 + unsigned long __addr = (unsigned long)addr; \
12764 + unsigned long __addr_ao = __addr & PAGE_MASK; \
12765 + unsigned long __end_ao = __addr + __size - 1; \
12766 + bool __ret_ao = __range_not_ok(__addr, __size) == 0; \
12767 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
12768 + while(__addr_ao <= __end_ao) { \
12769 + char __c_ao; \
12770 + __addr_ao += PAGE_SIZE; \
12771 + if (__size > PAGE_SIZE) \
12772 + cond_resched(); \
12773 + if (__get_user(__c_ao, (char __user *)__addr)) \
12774 + break; \
12775 + if (type != VERIFY_WRITE) { \
12776 + __addr = __addr_ao; \
12777 + continue; \
12778 + } \
12779 + if (__put_user(__c_ao, (char __user *)__addr)) \
12780 + break; \
12781 + __addr = __addr_ao; \
12782 + } \
12783 + } \
12784 + __ret_ao; \
12785 +})
12786
12787 /*
12788 * The exception table consists of pairs of addresses: the first is the
12789 @@ -182,12 +216,20 @@ extern int __get_user_bad(void);
12790 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
12791 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
12792
12793 -
12794 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
12795 +#define __copyuser_seg "gs;"
12796 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
12797 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
12798 +#else
12799 +#define __copyuser_seg
12800 +#define __COPYUSER_SET_ES
12801 +#define __COPYUSER_RESTORE_ES
12802 +#endif
12803
12804 #ifdef CONFIG_X86_32
12805 #define __put_user_asm_u64(x, addr, err, errret) \
12806 - asm volatile("1: movl %%eax,0(%2)\n" \
12807 - "2: movl %%edx,4(%2)\n" \
12808 + asm volatile("1: "__copyuser_seg"movl %%eax,0(%2)\n" \
12809 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
12810 "3:\n" \
12811 ".section .fixup,\"ax\"\n" \
12812 "4: movl %3,%0\n" \
12813 @@ -199,8 +241,8 @@ extern int __get_user_bad(void);
12814 : "A" (x), "r" (addr), "i" (errret), "0" (err))
12815
12816 #define __put_user_asm_ex_u64(x, addr) \
12817 - asm volatile("1: movl %%eax,0(%1)\n" \
12818 - "2: movl %%edx,4(%1)\n" \
12819 + asm volatile("1: "__copyuser_seg"movl %%eax,0(%1)\n" \
12820 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
12821 "3:\n" \
12822 _ASM_EXTABLE(1b, 2b - 1b) \
12823 _ASM_EXTABLE(2b, 3b - 2b) \
12824 @@ -252,7 +294,7 @@ extern void __put_user_8(void);
12825 __typeof__(*(ptr)) __pu_val; \
12826 __chk_user_ptr(ptr); \
12827 might_fault(); \
12828 - __pu_val = x; \
12829 + __pu_val = (x); \
12830 switch (sizeof(*(ptr))) { \
12831 case 1: \
12832 __put_user_x(1, __pu_val, ptr, __ret_pu); \
12833 @@ -373,7 +415,7 @@ do { \
12834 } while (0)
12835
12836 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
12837 - asm volatile("1: mov"itype" %2,%"rtype"1\n" \
12838 + asm volatile("1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
12839 "2:\n" \
12840 ".section .fixup,\"ax\"\n" \
12841 "3: mov %3,%0\n" \
12842 @@ -381,7 +423,7 @@ do { \
12843 " jmp 2b\n" \
12844 ".previous\n" \
12845 _ASM_EXTABLE(1b, 3b) \
12846 - : "=r" (err), ltype(x) \
12847 + : "=r" (err), ltype (x) \
12848 : "m" (__m(addr)), "i" (errret), "0" (err))
12849
12850 #define __get_user_size_ex(x, ptr, size) \
12851 @@ -406,7 +448,7 @@ do { \
12852 } while (0)
12853
12854 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
12855 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
12856 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
12857 "2:\n" \
12858 _ASM_EXTABLE(1b, 2b - 1b) \
12859 : ltype(x) : "m" (__m(addr)))
12860 @@ -423,13 +465,24 @@ do { \
12861 int __gu_err; \
12862 unsigned long __gu_val; \
12863 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
12864 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
12865 + (x) = (__typeof__(*(ptr)))__gu_val; \
12866 __gu_err; \
12867 })
12868
12869 /* FIXME: this hack is definitely wrong -AK */
12870 struct __large_struct { unsigned long buf[100]; };
12871 -#define __m(x) (*(struct __large_struct __user *)(x))
12872 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
12873 +#define ____m(x) \
12874 +({ \
12875 + unsigned long ____x = (unsigned long)(x); \
12876 + if (____x < PAX_USER_SHADOW_BASE) \
12877 + ____x += PAX_USER_SHADOW_BASE; \
12878 + (void __user *)____x; \
12879 +})
12880 +#else
12881 +#define ____m(x) (x)
12882 +#endif
12883 +#define __m(x) (*(struct __large_struct __user *)____m(x))
12884
12885 /*
12886 * Tell gcc we read from memory instead of writing: this is because
12887 @@ -437,7 +490,7 @@ struct __large_struct { unsigned long buf[100]; };
12888 * aliasing issues.
12889 */
12890 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
12891 - asm volatile("1: mov"itype" %"rtype"1,%2\n" \
12892 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
12893 "2:\n" \
12894 ".section .fixup,\"ax\"\n" \
12895 "3: mov %3,%0\n" \
12896 @@ -445,10 +498,10 @@ struct __large_struct { unsigned long buf[100]; };
12897 ".previous\n" \
12898 _ASM_EXTABLE(1b, 3b) \
12899 : "=r"(err) \
12900 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
12901 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
12902
12903 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
12904 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
12905 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
12906 "2:\n" \
12907 _ASM_EXTABLE(1b, 2b - 1b) \
12908 : : ltype(x), "m" (__m(addr)))
12909 @@ -487,8 +540,12 @@ struct __large_struct { unsigned long buf[100]; };
12910 * On error, the variable @x is set to zero.
12911 */
12912
12913 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
12914 +#define __get_user(x, ptr) get_user((x), (ptr))
12915 +#else
12916 #define __get_user(x, ptr) \
12917 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
12918 +#endif
12919
12920 /**
12921 * __put_user: - Write a simple value into user space, with less checking.
12922 @@ -510,8 +567,12 @@ struct __large_struct { unsigned long buf[100]; };
12923 * Returns zero on success, or -EFAULT on error.
12924 */
12925
12926 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
12927 +#define __put_user(x, ptr) put_user((x), (ptr))
12928 +#else
12929 #define __put_user(x, ptr) \
12930 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
12931 +#endif
12932
12933 #define __get_user_unaligned __get_user
12934 #define __put_user_unaligned __put_user
12935 @@ -529,7 +590,7 @@ struct __large_struct { unsigned long buf[100]; };
12936 #define get_user_ex(x, ptr) do { \
12937 unsigned long __gue_val; \
12938 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
12939 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
12940 + (x) = (__typeof__(*(ptr)))__gue_val; \
12941 } while (0)
12942
12943 #ifdef CONFIG_X86_WP_WORKS_OK
12944 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
12945 index 566e803..1230707 100644
12946 --- a/arch/x86/include/asm/uaccess_32.h
12947 +++ b/arch/x86/include/asm/uaccess_32.h
12948 @@ -11,15 +11,15 @@
12949 #include <asm/page.h>
12950
12951 unsigned long __must_check __copy_to_user_ll
12952 - (void __user *to, const void *from, unsigned long n);
12953 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
12954 unsigned long __must_check __copy_from_user_ll
12955 - (void *to, const void __user *from, unsigned long n);
12956 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
12957 unsigned long __must_check __copy_from_user_ll_nozero
12958 - (void *to, const void __user *from, unsigned long n);
12959 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
12960 unsigned long __must_check __copy_from_user_ll_nocache
12961 - (void *to, const void __user *from, unsigned long n);
12962 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
12963 unsigned long __must_check __copy_from_user_ll_nocache_nozero
12964 - (void *to, const void __user *from, unsigned long n);
12965 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
12966
12967 /**
12968 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
12969 @@ -43,6 +43,9 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
12970 static __always_inline unsigned long __must_check
12971 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
12972 {
12973 + if ((long)n < 0)
12974 + return n;
12975 +
12976 if (__builtin_constant_p(n)) {
12977 unsigned long ret;
12978
12979 @@ -61,6 +64,8 @@ __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
12980 return ret;
12981 }
12982 }
12983 + if (!__builtin_constant_p(n))
12984 + check_object_size(from, n, true);
12985 return __copy_to_user_ll(to, from, n);
12986 }
12987
12988 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
12989 __copy_to_user(void __user *to, const void *from, unsigned long n)
12990 {
12991 might_fault();
12992 +
12993 return __copy_to_user_inatomic(to, from, n);
12994 }
12995
12996 static __always_inline unsigned long
12997 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
12998 {
12999 + if ((long)n < 0)
13000 + return n;
13001 +
13002 /* Avoid zeroing the tail if the copy fails..
13003 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
13004 * but as the zeroing behaviour is only significant when n is not
13005 @@ -137,6 +146,10 @@ static __always_inline unsigned long
13006 __copy_from_user(void *to, const void __user *from, unsigned long n)
13007 {
13008 might_fault();
13009 +
13010 + if ((long)n < 0)
13011 + return n;
13012 +
13013 if (__builtin_constant_p(n)) {
13014 unsigned long ret;
13015
13016 @@ -152,6 +165,8 @@ __copy_from_user(void *to, const void __user *from, unsigned long n)
13017 return ret;
13018 }
13019 }
13020 + if (!__builtin_constant_p(n))
13021 + check_object_size(to, n, false);
13022 return __copy_from_user_ll(to, from, n);
13023 }
13024
13025 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
13026 const void __user *from, unsigned long n)
13027 {
13028 might_fault();
13029 +
13030 + if ((long)n < 0)
13031 + return n;
13032 +
13033 if (__builtin_constant_p(n)) {
13034 unsigned long ret;
13035
13036 @@ -181,15 +200,19 @@ static __always_inline unsigned long
13037 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
13038 unsigned long n)
13039 {
13040 - return __copy_from_user_ll_nocache_nozero(to, from, n);
13041 + if ((long)n < 0)
13042 + return n;
13043 +
13044 + return __copy_from_user_ll_nocache_nozero(to, from, n);
13045 }
13046
13047 -unsigned long __must_check copy_to_user(void __user *to,
13048 - const void *from, unsigned long n);
13049 -unsigned long __must_check _copy_from_user(void *to,
13050 - const void __user *from,
13051 - unsigned long n);
13052 -
13053 +extern void copy_to_user_overflow(void)
13054 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
13055 + __compiletime_error("copy_to_user() buffer size is not provably correct")
13056 +#else
13057 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
13058 +#endif
13059 +;
13060
13061 extern void copy_from_user_overflow(void)
13062 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
13063 @@ -199,17 +222,61 @@ extern void copy_from_user_overflow(void)
13064 #endif
13065 ;
13066
13067 -static inline unsigned long __must_check copy_from_user(void *to,
13068 - const void __user *from,
13069 - unsigned long n)
13070 +/**
13071 + * copy_to_user: - Copy a block of data into user space.
13072 + * @to: Destination address, in user space.
13073 + * @from: Source address, in kernel space.
13074 + * @n: Number of bytes to copy.
13075 + *
13076 + * Context: User context only. This function may sleep.
13077 + *
13078 + * Copy data from kernel space to user space.
13079 + *
13080 + * Returns number of bytes that could not be copied.
13081 + * On success, this will be zero.
13082 + */
13083 +static inline unsigned long __must_check
13084 +copy_to_user(void __user *to, const void *from, unsigned long n)
13085 +{
13086 + int sz = __compiletime_object_size(from);
13087 +
13088 + if (unlikely(sz != -1 && sz < n))
13089 + copy_to_user_overflow();
13090 + else if (access_ok(VERIFY_WRITE, to, n))
13091 + n = __copy_to_user(to, from, n);
13092 + return n;
13093 +}
13094 +
13095 +/**
13096 + * copy_from_user: - Copy a block of data from user space.
13097 + * @to: Destination address, in kernel space.
13098 + * @from: Source address, in user space.
13099 + * @n: Number of bytes to copy.
13100 + *
13101 + * Context: User context only. This function may sleep.
13102 + *
13103 + * Copy data from user space to kernel space.
13104 + *
13105 + * Returns number of bytes that could not be copied.
13106 + * On success, this will be zero.
13107 + *
13108 + * If some data could not be copied, this function will pad the copied
13109 + * data to the requested size using zero bytes.
13110 + */
13111 +static inline unsigned long __must_check
13112 +copy_from_user(void *to, const void __user *from, unsigned long n)
13113 {
13114 int sz = __compiletime_object_size(to);
13115
13116 - if (likely(sz == -1 || sz >= n))
13117 - n = _copy_from_user(to, from, n);
13118 - else
13119 + if (unlikely(sz != -1 && sz < n))
13120 copy_from_user_overflow();
13121 -
13122 + else if (access_ok(VERIFY_READ, from, n))
13123 + n = __copy_from_user(to, from, n);
13124 + else if ((long)n > 0) {
13125 + if (!__builtin_constant_p(n))
13126 + check_object_size(to, n, false);
13127 + memset(to, 0, n);
13128 + }
13129 return n;
13130 }
13131
13132 @@ -235,7 +302,7 @@ long __must_check __strncpy_from_user(char *dst,
13133 #define strlen_user(str) strnlen_user(str, LONG_MAX)
13134
13135 long strnlen_user(const char __user *str, long n);
13136 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
13137 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
13138 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
13139 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
13140
13141 #endif /* _ASM_X86_UACCESS_32_H */
13142 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
13143 index 1c66d30..bf1a2cc 100644
13144 --- a/arch/x86/include/asm/uaccess_64.h
13145 +++ b/arch/x86/include/asm/uaccess_64.h
13146 @@ -10,6 +10,9 @@
13147 #include <asm/alternative.h>
13148 #include <asm/cpufeature.h>
13149 #include <asm/page.h>
13150 +#include <asm/pgtable.h>
13151 +
13152 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
13153
13154 /*
13155 * Copy To/From Userspace
13156 @@ -17,12 +20,14 @@
13157
13158 /* Handles exceptions in both to and from, but doesn't do access_ok */
13159 __must_check unsigned long
13160 -copy_user_generic_string(void *to, const void *from, unsigned len);
13161 +copy_user_generic_string(void *to, const void *from, unsigned long len) __size_overflow(3);
13162 __must_check unsigned long
13163 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
13164 +copy_user_generic_unrolled(void *to, const void *from, unsigned long len) __size_overflow(3);
13165
13166 static __always_inline __must_check unsigned long
13167 -copy_user_generic(void *to, const void *from, unsigned len)
13168 +copy_user_generic(void *to, const void *from, unsigned long len) __size_overflow(3);
13169 +static __always_inline __must_check unsigned long
13170 +copy_user_generic(void *to, const void *from, unsigned long len)
13171 {
13172 unsigned ret;
13173
13174 @@ -32,142 +37,226 @@ copy_user_generic(void *to, const void *from, unsigned len)
13175 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
13176 "=d" (len)),
13177 "1" (to), "2" (from), "3" (len)
13178 - : "memory", "rcx", "r8", "r9", "r10", "r11");
13179 + : "memory", "rcx", "r8", "r9", "r11");
13180 return ret;
13181 }
13182
13183 +static __always_inline __must_check unsigned long
13184 +__copy_to_user(void __user *to, const void *from, unsigned long len) __size_overflow(3);
13185 +static __always_inline __must_check unsigned long
13186 +__copy_from_user(void *to, const void __user *from, unsigned long len) __size_overflow(3);
13187 __must_check unsigned long
13188 -_copy_to_user(void __user *to, const void *from, unsigned len);
13189 -__must_check unsigned long
13190 -_copy_from_user(void *to, const void __user *from, unsigned len);
13191 -__must_check unsigned long
13192 -copy_in_user(void __user *to, const void __user *from, unsigned len);
13193 +copy_in_user(void __user *to, const void __user *from, unsigned long len) __size_overflow(3);
13194
13195 static inline unsigned long __must_check copy_from_user(void *to,
13196 const void __user *from,
13197 unsigned long n)
13198 {
13199 - int sz = __compiletime_object_size(to);
13200 -
13201 might_fault();
13202 - if (likely(sz == -1 || sz >= n))
13203 - n = _copy_from_user(to, from, n);
13204 -#ifdef CONFIG_DEBUG_VM
13205 - else
13206 - WARN(1, "Buffer overflow detected!\n");
13207 -#endif
13208 +
13209 + if (access_ok(VERIFY_READ, from, n))
13210 + n = __copy_from_user(to, from, n);
13211 + else if (n < INT_MAX) {
13212 + if (!__builtin_constant_p(n))
13213 + check_object_size(to, n, false);
13214 + memset(to, 0, n);
13215 + }
13216 return n;
13217 }
13218
13219 static __always_inline __must_check
13220 -int copy_to_user(void __user *dst, const void *src, unsigned size)
13221 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
13222 {
13223 might_fault();
13224
13225 - return _copy_to_user(dst, src, size);
13226 + if (access_ok(VERIFY_WRITE, dst, size))
13227 + size = __copy_to_user(dst, src, size);
13228 + return size;
13229 }
13230
13231 static __always_inline __must_check
13232 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
13233 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
13234 {
13235 - int ret = 0;
13236 + int sz = __compiletime_object_size(dst);
13237 + unsigned ret = 0;
13238
13239 might_fault();
13240 - if (!__builtin_constant_p(size))
13241 - return copy_user_generic(dst, (__force void *)src, size);
13242 +
13243 + if (size > INT_MAX)
13244 + return size;
13245 +
13246 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13247 + if (!__access_ok(VERIFY_READ, src, size))
13248 + return size;
13249 +#endif
13250 +
13251 + if (unlikely(sz != -1 && sz < size)) {
13252 +#ifdef CONFIG_DEBUG_VM
13253 + WARN(1, "Buffer overflow detected!\n");
13254 +#endif
13255 + return size;
13256 + }
13257 +
13258 + if (!__builtin_constant_p(size)) {
13259 + check_object_size(dst, size, false);
13260 +
13261 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13262 + if ((unsigned long)src < PAX_USER_SHADOW_BASE)
13263 + src += PAX_USER_SHADOW_BASE;
13264 +#endif
13265 +
13266 + return copy_user_generic(dst, (__force_kernel const void *)src, size);
13267 + }
13268 switch (size) {
13269 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
13270 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
13271 ret, "b", "b", "=q", 1);
13272 return ret;
13273 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
13274 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
13275 ret, "w", "w", "=r", 2);
13276 return ret;
13277 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
13278 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
13279 ret, "l", "k", "=r", 4);
13280 return ret;
13281 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
13282 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
13283 ret, "q", "", "=r", 8);
13284 return ret;
13285 case 10:
13286 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
13287 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
13288 ret, "q", "", "=r", 10);
13289 if (unlikely(ret))
13290 return ret;
13291 __get_user_asm(*(u16 *)(8 + (char *)dst),
13292 - (u16 __user *)(8 + (char __user *)src),
13293 + (const u16 __user *)(8 + (const char __user *)src),
13294 ret, "w", "w", "=r", 2);
13295 return ret;
13296 case 16:
13297 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
13298 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
13299 ret, "q", "", "=r", 16);
13300 if (unlikely(ret))
13301 return ret;
13302 __get_user_asm(*(u64 *)(8 + (char *)dst),
13303 - (u64 __user *)(8 + (char __user *)src),
13304 + (const u64 __user *)(8 + (const char __user *)src),
13305 ret, "q", "", "=r", 8);
13306 return ret;
13307 default:
13308 - return copy_user_generic(dst, (__force void *)src, size);
13309 +
13310 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13311 + if ((unsigned long)src < PAX_USER_SHADOW_BASE)
13312 + src += PAX_USER_SHADOW_BASE;
13313 +#endif
13314 +
13315 + return copy_user_generic(dst, (__force_kernel const void *)src, size);
13316 }
13317 }
13318
13319 static __always_inline __must_check
13320 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
13321 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
13322 {
13323 - int ret = 0;
13324 + int sz = __compiletime_object_size(src);
13325 + unsigned ret = 0;
13326
13327 might_fault();
13328 - if (!__builtin_constant_p(size))
13329 - return copy_user_generic((__force void *)dst, src, size);
13330 +
13331 + if (size > INT_MAX)
13332 + return size;
13333 +
13334 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13335 + if (!__access_ok(VERIFY_WRITE, dst, size))
13336 + return size;
13337 +#endif
13338 +
13339 + if (unlikely(sz != -1 && sz < size)) {
13340 +#ifdef CONFIG_DEBUG_VM
13341 + WARN(1, "Buffer overflow detected!\n");
13342 +#endif
13343 + return size;
13344 + }
13345 +
13346 + if (!__builtin_constant_p(size)) {
13347 + check_object_size(src, size, true);
13348 +
13349 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13350 + if ((unsigned long)dst < PAX_USER_SHADOW_BASE)
13351 + dst += PAX_USER_SHADOW_BASE;
13352 +#endif
13353 +
13354 + return copy_user_generic((__force_kernel void *)dst, src, size);
13355 + }
13356 switch (size) {
13357 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
13358 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
13359 ret, "b", "b", "iq", 1);
13360 return ret;
13361 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
13362 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
13363 ret, "w", "w", "ir", 2);
13364 return ret;
13365 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
13366 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
13367 ret, "l", "k", "ir", 4);
13368 return ret;
13369 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
13370 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
13371 ret, "q", "", "er", 8);
13372 return ret;
13373 case 10:
13374 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
13375 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
13376 ret, "q", "", "er", 10);
13377 if (unlikely(ret))
13378 return ret;
13379 asm("":::"memory");
13380 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
13381 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
13382 ret, "w", "w", "ir", 2);
13383 return ret;
13384 case 16:
13385 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
13386 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
13387 ret, "q", "", "er", 16);
13388 if (unlikely(ret))
13389 return ret;
13390 asm("":::"memory");
13391 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
13392 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
13393 ret, "q", "", "er", 8);
13394 return ret;
13395 default:
13396 - return copy_user_generic((__force void *)dst, src, size);
13397 +
13398 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13399 + if ((unsigned long)dst < PAX_USER_SHADOW_BASE)
13400 + dst += PAX_USER_SHADOW_BASE;
13401 +#endif
13402 +
13403 + return copy_user_generic((__force_kernel void *)dst, src, size);
13404 }
13405 }
13406
13407 static __always_inline __must_check
13408 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
13409 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
13410 {
13411 - int ret = 0;
13412 + unsigned ret = 0;
13413
13414 might_fault();
13415 - if (!__builtin_constant_p(size))
13416 - return copy_user_generic((__force void *)dst,
13417 - (__force void *)src, size);
13418 +
13419 + if (size > INT_MAX)
13420 + return size;
13421 +
13422 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13423 + if (!__access_ok(VERIFY_READ, src, size))
13424 + return size;
13425 + if (!__access_ok(VERIFY_WRITE, dst, size))
13426 + return size;
13427 +#endif
13428 +
13429 + if (!__builtin_constant_p(size)) {
13430 +
13431 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13432 + if ((unsigned long)src < PAX_USER_SHADOW_BASE)
13433 + src += PAX_USER_SHADOW_BASE;
13434 + if ((unsigned long)dst < PAX_USER_SHADOW_BASE)
13435 + dst += PAX_USER_SHADOW_BASE;
13436 +#endif
13437 +
13438 + return copy_user_generic((__force_kernel void *)dst,
13439 + (__force_kernel const void *)src, size);
13440 + }
13441 switch (size) {
13442 case 1: {
13443 u8 tmp;
13444 - __get_user_asm(tmp, (u8 __user *)src,
13445 + __get_user_asm(tmp, (const u8 __user *)src,
13446 ret, "b", "b", "=q", 1);
13447 if (likely(!ret))
13448 __put_user_asm(tmp, (u8 __user *)dst,
13449 @@ -176,7 +265,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
13450 }
13451 case 2: {
13452 u16 tmp;
13453 - __get_user_asm(tmp, (u16 __user *)src,
13454 + __get_user_asm(tmp, (const u16 __user *)src,
13455 ret, "w", "w", "=r", 2);
13456 if (likely(!ret))
13457 __put_user_asm(tmp, (u16 __user *)dst,
13458 @@ -186,7 +275,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
13459
13460 case 4: {
13461 u32 tmp;
13462 - __get_user_asm(tmp, (u32 __user *)src,
13463 + __get_user_asm(tmp, (const u32 __user *)src,
13464 ret, "l", "k", "=r", 4);
13465 if (likely(!ret))
13466 __put_user_asm(tmp, (u32 __user *)dst,
13467 @@ -195,7 +284,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
13468 }
13469 case 8: {
13470 u64 tmp;
13471 - __get_user_asm(tmp, (u64 __user *)src,
13472 + __get_user_asm(tmp, (const u64 __user *)src,
13473 ret, "q", "", "=r", 8);
13474 if (likely(!ret))
13475 __put_user_asm(tmp, (u64 __user *)dst,
13476 @@ -203,8 +292,16 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
13477 return ret;
13478 }
13479 default:
13480 - return copy_user_generic((__force void *)dst,
13481 - (__force void *)src, size);
13482 +
13483 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13484 + if ((unsigned long)src < PAX_USER_SHADOW_BASE)
13485 + src += PAX_USER_SHADOW_BASE;
13486 + if ((unsigned long)dst < PAX_USER_SHADOW_BASE)
13487 + dst += PAX_USER_SHADOW_BASE;
13488 +#endif
13489 +
13490 + return copy_user_generic((__force_kernel void *)dst,
13491 + (__force_kernel const void *)src, size);
13492 }
13493 }
13494
13495 @@ -215,39 +312,76 @@ __strncpy_from_user(char *dst, const char __user *src, long count);
13496 __must_check long strnlen_user(const char __user *str, long n);
13497 __must_check long __strnlen_user(const char __user *str, long n);
13498 __must_check long strlen_user(const char __user *str);
13499 -__must_check unsigned long clear_user(void __user *mem, unsigned long len);
13500 -__must_check unsigned long __clear_user(void __user *mem, unsigned long len);
13501 +__must_check unsigned long clear_user(void __user *mem, unsigned long len) __size_overflow(2);
13502 +__must_check unsigned long __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
13503
13504 static __must_check __always_inline int
13505 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
13506 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
13507 {
13508 - return copy_user_generic(dst, (__force const void *)src, size);
13509 + if (size > INT_MAX)
13510 + return size;
13511 +
13512 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13513 + if (!__access_ok(VERIFY_READ, src, size))
13514 + return size;
13515 +
13516 + if ((unsigned long)src < PAX_USER_SHADOW_BASE)
13517 + src += PAX_USER_SHADOW_BASE;
13518 +#endif
13519 +
13520 + return copy_user_generic(dst, (__force_kernel const void *)src, size);
13521 }
13522
13523 -static __must_check __always_inline int
13524 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
13525 +static __must_check __always_inline unsigned long
13526 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
13527 {
13528 - return copy_user_generic((__force void *)dst, src, size);
13529 + if (size > INT_MAX)
13530 + return size;
13531 +
13532 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13533 + if (!__access_ok(VERIFY_WRITE, dst, size))
13534 + return size;
13535 +
13536 + if ((unsigned long)dst < PAX_USER_SHADOW_BASE)
13537 + dst += PAX_USER_SHADOW_BASE;
13538 +#endif
13539 +
13540 + return copy_user_generic((__force_kernel void *)dst, src, size);
13541 }
13542
13543 -extern long __copy_user_nocache(void *dst, const void __user *src,
13544 - unsigned size, int zerorest);
13545 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
13546 + unsigned long size, int zerorest) __size_overflow(3);
13547
13548 -static inline int
13549 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
13550 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
13551 {
13552 might_sleep();
13553 +
13554 + if (size > INT_MAX)
13555 + return size;
13556 +
13557 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13558 + if (!__access_ok(VERIFY_READ, src, size))
13559 + return size;
13560 +#endif
13561 +
13562 return __copy_user_nocache(dst, src, size, 1);
13563 }
13564
13565 -static inline int
13566 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
13567 - unsigned size)
13568 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
13569 + unsigned long size)
13570 {
13571 + if (size > INT_MAX)
13572 + return size;
13573 +
13574 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13575 + if (!__access_ok(VERIFY_READ, src, size))
13576 + return size;
13577 +#endif
13578 +
13579 return __copy_user_nocache(dst, src, size, 0);
13580 }
13581
13582 -unsigned long
13583 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
13584 +extern unsigned long
13585 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
13586
13587 #endif /* _ASM_X86_UACCESS_64_H */
13588 diff --git a/arch/x86/include/asm/vdso.h b/arch/x86/include/asm/vdso.h
13589 index bb05228..d763d5b 100644
13590 --- a/arch/x86/include/asm/vdso.h
13591 +++ b/arch/x86/include/asm/vdso.h
13592 @@ -11,7 +11,7 @@ extern const char VDSO32_PRELINK[];
13593 #define VDSO32_SYMBOL(base, name) \
13594 ({ \
13595 extern const char VDSO32_##name[]; \
13596 - (void *)(VDSO32_##name - VDSO32_PRELINK + (unsigned long)(base)); \
13597 + (void __user *)(VDSO32_##name - VDSO32_PRELINK + (unsigned long)(base)); \
13598 })
13599 #endif
13600
13601 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
13602 index a609c39..7a68dc7 100644
13603 --- a/arch/x86/include/asm/x86_init.h
13604 +++ b/arch/x86/include/asm/x86_init.h
13605 @@ -29,7 +29,7 @@ struct x86_init_mpparse {
13606 void (*mpc_oem_bus_info)(struct mpc_bus *m, char *name);
13607 void (*find_smp_config)(void);
13608 void (*get_smp_config)(unsigned int early);
13609 -};
13610 +} __no_const;
13611
13612 /**
13613 * struct x86_init_resources - platform specific resource related ops
13614 @@ -43,7 +43,7 @@ struct x86_init_resources {
13615 void (*probe_roms)(void);
13616 void (*reserve_resources)(void);
13617 char *(*memory_setup)(void);
13618 -};
13619 +} __no_const;
13620
13621 /**
13622 * struct x86_init_irqs - platform specific interrupt setup
13623 @@ -56,7 +56,7 @@ struct x86_init_irqs {
13624 void (*pre_vector_init)(void);
13625 void (*intr_init)(void);
13626 void (*trap_init)(void);
13627 -};
13628 +} __no_const;
13629
13630 /**
13631 * struct x86_init_oem - oem platform specific customizing functions
13632 @@ -66,7 +66,7 @@ struct x86_init_irqs {
13633 struct x86_init_oem {
13634 void (*arch_setup)(void);
13635 void (*banner)(void);
13636 -};
13637 +} __no_const;
13638
13639 /**
13640 * struct x86_init_mapping - platform specific initial kernel pagetable setup
13641 @@ -77,7 +77,7 @@ struct x86_init_oem {
13642 */
13643 struct x86_init_mapping {
13644 void (*pagetable_reserve)(u64 start, u64 end);
13645 -};
13646 +} __no_const;
13647
13648 /**
13649 * struct x86_init_paging - platform specific paging functions
13650 @@ -87,7 +87,7 @@ struct x86_init_mapping {
13651 struct x86_init_paging {
13652 void (*pagetable_setup_start)(pgd_t *base);
13653 void (*pagetable_setup_done)(pgd_t *base);
13654 -};
13655 +} __no_const;
13656
13657 /**
13658 * struct x86_init_timers - platform specific timer setup
13659 @@ -102,7 +102,7 @@ struct x86_init_timers {
13660 void (*tsc_pre_init)(void);
13661 void (*timer_init)(void);
13662 void (*wallclock_init)(void);
13663 -};
13664 +} __no_const;
13665
13666 /**
13667 * struct x86_init_iommu - platform specific iommu setup
13668 @@ -110,7 +110,7 @@ struct x86_init_timers {
13669 */
13670 struct x86_init_iommu {
13671 int (*iommu_init)(void);
13672 -};
13673 +} __no_const;
13674
13675 /**
13676 * struct x86_init_pci - platform specific pci init functions
13677 @@ -124,7 +124,7 @@ struct x86_init_pci {
13678 int (*init)(void);
13679 void (*init_irq)(void);
13680 void (*fixup_irqs)(void);
13681 -};
13682 +} __no_const;
13683
13684 /**
13685 * struct x86_init_ops - functions for platform specific setup
13686 @@ -140,7 +140,7 @@ struct x86_init_ops {
13687 struct x86_init_timers timers;
13688 struct x86_init_iommu iommu;
13689 struct x86_init_pci pci;
13690 -};
13691 +} __no_const;
13692
13693 /**
13694 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
13695 @@ -149,7 +149,7 @@ struct x86_init_ops {
13696 struct x86_cpuinit_ops {
13697 void (*setup_percpu_clockev)(void);
13698 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
13699 -};
13700 +} __no_const;
13701
13702 /**
13703 * struct x86_platform_ops - platform specific runtime functions
13704 @@ -171,7 +171,7 @@ struct x86_platform_ops {
13705 void (*nmi_init)(void);
13706 unsigned char (*get_nmi_reason)(void);
13707 int (*i8042_detect)(void);
13708 -};
13709 +} __no_const;
13710
13711 struct pci_dev;
13712
13713 @@ -180,7 +180,7 @@ struct x86_msi_ops {
13714 void (*teardown_msi_irq)(unsigned int irq);
13715 void (*teardown_msi_irqs)(struct pci_dev *dev);
13716 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
13717 -};
13718 +} __no_const;
13719
13720 extern struct x86_init_ops x86_init;
13721 extern struct x86_cpuinit_ops x86_cpuinit;
13722 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
13723 index c6ce245..ffbdab7 100644
13724 --- a/arch/x86/include/asm/xsave.h
13725 +++ b/arch/x86/include/asm/xsave.h
13726 @@ -65,6 +65,11 @@ static inline int xsave_user(struct xsave_struct __user *buf)
13727 {
13728 int err;
13729
13730 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
13731 + if ((unsigned long)buf < PAX_USER_SHADOW_BASE)
13732 + buf = (struct xsave_struct __user *)((void __user*)buf + PAX_USER_SHADOW_BASE);
13733 +#endif
13734 +
13735 /*
13736 * Clear the xsave header first, so that reserved fields are
13737 * initialized to zero.
13738 @@ -96,10 +101,15 @@ static inline int xsave_user(struct xsave_struct __user *buf)
13739 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
13740 {
13741 int err;
13742 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
13743 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
13744 u32 lmask = mask;
13745 u32 hmask = mask >> 32;
13746
13747 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
13748 + if ((unsigned long)xstate < PAX_USER_SHADOW_BASE)
13749 + xstate = (struct xsave_struct *)((void *)xstate + PAX_USER_SHADOW_BASE);
13750 +#endif
13751 +
13752 __asm__ __volatile__("1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
13753 "2:\n"
13754 ".section .fixup,\"ax\"\n"
13755 diff --git a/arch/x86/kernel/acpi/realmode/Makefile b/arch/x86/kernel/acpi/realmode/Makefile
13756 index 6a564ac..9b1340c 100644
13757 --- a/arch/x86/kernel/acpi/realmode/Makefile
13758 +++ b/arch/x86/kernel/acpi/realmode/Makefile
13759 @@ -41,6 +41,9 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -g -Os -D_SETUP -D_WAKEUP -D__KERNEL__ \
13760 $(call cc-option, -fno-stack-protector) \
13761 $(call cc-option, -mpreferred-stack-boundary=2)
13762 KBUILD_CFLAGS += $(call cc-option, -m32)
13763 +ifdef CONSTIFY_PLUGIN
13764 +KBUILD_CFLAGS += $(CONSTIFY_PLUGIN) -fplugin-arg-constify_plugin-no-constify
13765 +endif
13766 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
13767 GCOV_PROFILE := n
13768
13769 diff --git a/arch/x86/kernel/acpi/realmode/wakeup.S b/arch/x86/kernel/acpi/realmode/wakeup.S
13770 index b4fd836..4358fe3 100644
13771 --- a/arch/x86/kernel/acpi/realmode/wakeup.S
13772 +++ b/arch/x86/kernel/acpi/realmode/wakeup.S
13773 @@ -108,6 +108,9 @@ wakeup_code:
13774 /* Do any other stuff... */
13775
13776 #ifndef CONFIG_64BIT
13777 + /* Recheck NX bit overrides (64bit path does this in trampoline */
13778 + call verify_cpu
13779 +
13780 /* This could also be done in C code... */
13781 movl pmode_cr3, %eax
13782 movl %eax, %cr3
13783 @@ -131,6 +134,7 @@ wakeup_code:
13784 movl pmode_cr0, %eax
13785 movl %eax, %cr0
13786 jmp pmode_return
13787 +# include "../../verify_cpu.S"
13788 #else
13789 pushw $0
13790 pushw trampoline_segment
13791 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
13792 index 103b6ab..2004d0a 100644
13793 --- a/arch/x86/kernel/acpi/sleep.c
13794 +++ b/arch/x86/kernel/acpi/sleep.c
13795 @@ -94,8 +94,12 @@ int acpi_suspend_lowlevel(void)
13796 header->trampoline_segment = trampoline_address() >> 4;
13797 #ifdef CONFIG_SMP
13798 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
13799 +
13800 + pax_open_kernel();
13801 early_gdt_descr.address =
13802 (unsigned long)get_cpu_gdt_table(smp_processor_id());
13803 + pax_close_kernel();
13804 +
13805 initial_gs = per_cpu_offset(smp_processor_id());
13806 #endif
13807 initial_code = (unsigned long)wakeup_long64;
13808 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
13809 index 13ab720..95d5442 100644
13810 --- a/arch/x86/kernel/acpi/wakeup_32.S
13811 +++ b/arch/x86/kernel/acpi/wakeup_32.S
13812 @@ -30,13 +30,11 @@ wakeup_pmode_return:
13813 # and restore the stack ... but you need gdt for this to work
13814 movl saved_context_esp, %esp
13815
13816 - movl %cs:saved_magic, %eax
13817 - cmpl $0x12345678, %eax
13818 + cmpl $0x12345678, saved_magic
13819 jne bogus_magic
13820
13821 # jump to place where we left off
13822 - movl saved_eip, %eax
13823 - jmp *%eax
13824 + jmp *(saved_eip)
13825
13826 bogus_magic:
13827 jmp bogus_magic
13828 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
13829 index 1f84794..e23f862 100644
13830 --- a/arch/x86/kernel/alternative.c
13831 +++ b/arch/x86/kernel/alternative.c
13832 @@ -276,6 +276,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
13833 */
13834 for (a = start; a < end; a++) {
13835 instr = (u8 *)&a->instr_offset + a->instr_offset;
13836 +
13837 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
13838 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
13839 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
13840 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
13841 +#endif
13842 +
13843 replacement = (u8 *)&a->repl_offset + a->repl_offset;
13844 BUG_ON(a->replacementlen > a->instrlen);
13845 BUG_ON(a->instrlen > sizeof(insnbuf));
13846 @@ -307,10 +314,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
13847 for (poff = start; poff < end; poff++) {
13848 u8 *ptr = (u8 *)poff + *poff;
13849
13850 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
13851 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
13852 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
13853 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
13854 +#endif
13855 +
13856 if (!*poff || ptr < text || ptr >= text_end)
13857 continue;
13858 /* turn DS segment override prefix into lock prefix */
13859 - if (*ptr == 0x3e)
13860 + if (*ktla_ktva(ptr) == 0x3e)
13861 text_poke(ptr, ((unsigned char []){0xf0}), 1);
13862 };
13863 mutex_unlock(&text_mutex);
13864 @@ -328,10 +341,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
13865 for (poff = start; poff < end; poff++) {
13866 u8 *ptr = (u8 *)poff + *poff;
13867
13868 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
13869 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
13870 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
13871 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
13872 +#endif
13873 +
13874 if (!*poff || ptr < text || ptr >= text_end)
13875 continue;
13876 /* turn lock prefix into DS segment override prefix */
13877 - if (*ptr == 0xf0)
13878 + if (*ktla_ktva(ptr) == 0xf0)
13879 text_poke(ptr, ((unsigned char []){0x3E}), 1);
13880 };
13881 mutex_unlock(&text_mutex);
13882 @@ -500,7 +519,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
13883
13884 BUG_ON(p->len > MAX_PATCH_LEN);
13885 /* prep the buffer with the original instructions */
13886 - memcpy(insnbuf, p->instr, p->len);
13887 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
13888 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
13889 (unsigned long)p->instr, p->len);
13890
13891 @@ -568,7 +587,7 @@ void __init alternative_instructions(void)
13892 if (smp_alt_once)
13893 free_init_pages("SMP alternatives",
13894 (unsigned long)__smp_locks,
13895 - (unsigned long)__smp_locks_end);
13896 + PAGE_ALIGN((unsigned long)__smp_locks_end));
13897
13898 restart_nmi();
13899 }
13900 @@ -585,13 +604,17 @@ void __init alternative_instructions(void)
13901 * instructions. And on the local CPU you need to be protected again NMI or MCE
13902 * handlers seeing an inconsistent instruction while you patch.
13903 */
13904 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
13905 +void *__kprobes text_poke_early(void *addr, const void *opcode,
13906 size_t len)
13907 {
13908 unsigned long flags;
13909 local_irq_save(flags);
13910 - memcpy(addr, opcode, len);
13911 +
13912 + pax_open_kernel();
13913 + memcpy(ktla_ktva(addr), opcode, len);
13914 sync_core();
13915 + pax_close_kernel();
13916 +
13917 local_irq_restore(flags);
13918 /* Could also do a CLFLUSH here to speed up CPU recovery; but
13919 that causes hangs on some VIA CPUs. */
13920 @@ -613,36 +636,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
13921 */
13922 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
13923 {
13924 - unsigned long flags;
13925 - char *vaddr;
13926 + unsigned char *vaddr = ktla_ktva(addr);
13927 struct page *pages[2];
13928 - int i;
13929 + size_t i;
13930
13931 if (!core_kernel_text((unsigned long)addr)) {
13932 - pages[0] = vmalloc_to_page(addr);
13933 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
13934 + pages[0] = vmalloc_to_page(vaddr);
13935 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
13936 } else {
13937 - pages[0] = virt_to_page(addr);
13938 + pages[0] = virt_to_page(vaddr);
13939 WARN_ON(!PageReserved(pages[0]));
13940 - pages[1] = virt_to_page(addr + PAGE_SIZE);
13941 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
13942 }
13943 BUG_ON(!pages[0]);
13944 - local_irq_save(flags);
13945 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
13946 - if (pages[1])
13947 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
13948 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
13949 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
13950 - clear_fixmap(FIX_TEXT_POKE0);
13951 - if (pages[1])
13952 - clear_fixmap(FIX_TEXT_POKE1);
13953 - local_flush_tlb();
13954 - sync_core();
13955 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
13956 - that causes hangs on some VIA CPUs. */
13957 + text_poke_early(addr, opcode, len);
13958 for (i = 0; i < len; i++)
13959 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
13960 - local_irq_restore(flags);
13961 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
13962 return addr;
13963 }
13964
13965 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
13966 index 5b3f88e..61232b4 100644
13967 --- a/arch/x86/kernel/apic/apic.c
13968 +++ b/arch/x86/kernel/apic/apic.c
13969 @@ -184,7 +184,7 @@ int first_system_vector = 0xfe;
13970 /*
13971 * Debug level, exported for io_apic.c
13972 */
13973 -unsigned int apic_verbosity;
13974 +int apic_verbosity;
13975
13976 int pic_mode;
13977
13978 @@ -1912,7 +1912,7 @@ void smp_error_interrupt(struct pt_regs *regs)
13979 apic_write(APIC_ESR, 0);
13980 v1 = apic_read(APIC_ESR);
13981 ack_APIC_irq();
13982 - atomic_inc(&irq_err_count);
13983 + atomic_inc_unchecked(&irq_err_count);
13984
13985 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
13986 smp_processor_id(), v0 , v1);
13987 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
13988 index fb07275..e06bb59 100644
13989 --- a/arch/x86/kernel/apic/io_apic.c
13990 +++ b/arch/x86/kernel/apic/io_apic.c
13991 @@ -1096,7 +1096,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
13992 }
13993 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
13994
13995 -void lock_vector_lock(void)
13996 +void lock_vector_lock(void) __acquires(vector_lock)
13997 {
13998 /* Used to the online set of cpus does not change
13999 * during assign_irq_vector.
14000 @@ -1104,7 +1104,7 @@ void lock_vector_lock(void)
14001 raw_spin_lock(&vector_lock);
14002 }
14003
14004 -void unlock_vector_lock(void)
14005 +void unlock_vector_lock(void) __releases(vector_lock)
14006 {
14007 raw_spin_unlock(&vector_lock);
14008 }
14009 @@ -2510,7 +2510,7 @@ static void ack_apic_edge(struct irq_data *data)
14010 ack_APIC_irq();
14011 }
14012
14013 -atomic_t irq_mis_count;
14014 +atomic_unchecked_t irq_mis_count;
14015
14016 static void ack_apic_level(struct irq_data *data)
14017 {
14018 @@ -2576,7 +2576,7 @@ static void ack_apic_level(struct irq_data *data)
14019 * at the cpu.
14020 */
14021 if (!(v & (1 << (i & 0x1f)))) {
14022 - atomic_inc(&irq_mis_count);
14023 + atomic_inc_unchecked(&irq_mis_count);
14024
14025 eoi_ioapic_irq(irq, cfg);
14026 }
14027 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
14028 index f76623c..aab694f 100644
14029 --- a/arch/x86/kernel/apm_32.c
14030 +++ b/arch/x86/kernel/apm_32.c
14031 @@ -411,7 +411,7 @@ static DEFINE_MUTEX(apm_mutex);
14032 * This is for buggy BIOS's that refer to (real mode) segment 0x40
14033 * even though they are called in protected mode.
14034 */
14035 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
14036 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
14037 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
14038
14039 static const char driver_version[] = "1.16ac"; /* no spaces */
14040 @@ -589,7 +589,10 @@ static long __apm_bios_call(void *_call)
14041 BUG_ON(cpu != 0);
14042 gdt = get_cpu_gdt_table(cpu);
14043 save_desc_40 = gdt[0x40 / 8];
14044 +
14045 + pax_open_kernel();
14046 gdt[0x40 / 8] = bad_bios_desc;
14047 + pax_close_kernel();
14048
14049 apm_irq_save(flags);
14050 APM_DO_SAVE_SEGS;
14051 @@ -598,7 +601,11 @@ static long __apm_bios_call(void *_call)
14052 &call->esi);
14053 APM_DO_RESTORE_SEGS;
14054 apm_irq_restore(flags);
14055 +
14056 + pax_open_kernel();
14057 gdt[0x40 / 8] = save_desc_40;
14058 + pax_close_kernel();
14059 +
14060 put_cpu();
14061
14062 return call->eax & 0xff;
14063 @@ -665,7 +672,10 @@ static long __apm_bios_call_simple(void *_call)
14064 BUG_ON(cpu != 0);
14065 gdt = get_cpu_gdt_table(cpu);
14066 save_desc_40 = gdt[0x40 / 8];
14067 +
14068 + pax_open_kernel();
14069 gdt[0x40 / 8] = bad_bios_desc;
14070 + pax_close_kernel();
14071
14072 apm_irq_save(flags);
14073 APM_DO_SAVE_SEGS;
14074 @@ -673,7 +683,11 @@ static long __apm_bios_call_simple(void *_call)
14075 &call->eax);
14076 APM_DO_RESTORE_SEGS;
14077 apm_irq_restore(flags);
14078 +
14079 + pax_open_kernel();
14080 gdt[0x40 / 8] = save_desc_40;
14081 + pax_close_kernel();
14082 +
14083 put_cpu();
14084 return error;
14085 }
14086 @@ -2347,12 +2361,15 @@ static int __init apm_init(void)
14087 * code to that CPU.
14088 */
14089 gdt = get_cpu_gdt_table(0);
14090 +
14091 + pax_open_kernel();
14092 set_desc_base(&gdt[APM_CS >> 3],
14093 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
14094 set_desc_base(&gdt[APM_CS_16 >> 3],
14095 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
14096 set_desc_base(&gdt[APM_DS >> 3],
14097 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
14098 + pax_close_kernel();
14099
14100 proc_create("apm", 0, NULL, &apm_file_ops);
14101
14102 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
14103 index 68de2dc..1f3c720 100644
14104 --- a/arch/x86/kernel/asm-offsets.c
14105 +++ b/arch/x86/kernel/asm-offsets.c
14106 @@ -33,6 +33,8 @@ void common(void) {
14107 OFFSET(TI_status, thread_info, status);
14108 OFFSET(TI_addr_limit, thread_info, addr_limit);
14109 OFFSET(TI_preempt_count, thread_info, preempt_count);
14110 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
14111 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
14112
14113 BLANK();
14114 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
14115 @@ -53,8 +55,26 @@ void common(void) {
14116 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
14117 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
14118 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
14119 +
14120 +#ifdef CONFIG_PAX_KERNEXEC
14121 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
14122 #endif
14123
14124 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14125 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
14126 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
14127 +#ifdef CONFIG_X86_64
14128 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
14129 +#endif
14130 +#endif
14131 +
14132 +#endif
14133 +
14134 + BLANK();
14135 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
14136 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
14137 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
14138 +
14139 #ifdef CONFIG_XEN
14140 BLANK();
14141 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
14142 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
14143 index 834e897..dacddc8 100644
14144 --- a/arch/x86/kernel/asm-offsets_64.c
14145 +++ b/arch/x86/kernel/asm-offsets_64.c
14146 @@ -70,6 +70,7 @@ int main(void)
14147 BLANK();
14148 #undef ENTRY
14149
14150 + DEFINE(TSS_size, sizeof(struct tss_struct));
14151 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
14152 BLANK();
14153
14154 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
14155 index 25f24dc..4094a7f 100644
14156 --- a/arch/x86/kernel/cpu/Makefile
14157 +++ b/arch/x86/kernel/cpu/Makefile
14158 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
14159 CFLAGS_REMOVE_perf_event.o = -pg
14160 endif
14161
14162 -# Make sure load_percpu_segment has no stackprotector
14163 -nostackp := $(call cc-option, -fno-stack-protector)
14164 -CFLAGS_common.o := $(nostackp)
14165 -
14166 obj-y := intel_cacheinfo.o scattered.o topology.o
14167 obj-y += proc.o capflags.o powerflags.o common.o
14168 obj-y += vmware.o hypervisor.o sched.o mshyperv.o
14169 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
14170 index 80ab83d..0a7b34e 100644
14171 --- a/arch/x86/kernel/cpu/amd.c
14172 +++ b/arch/x86/kernel/cpu/amd.c
14173 @@ -670,7 +670,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
14174 unsigned int size)
14175 {
14176 /* AMD errata T13 (order #21922) */
14177 - if ((c->x86 == 6)) {
14178 + if (c->x86 == 6) {
14179 /* Duron Rev A0 */
14180 if (c->x86_model == 3 && c->x86_mask == 0)
14181 size = 64;
14182 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
14183 index 1a810e4..9fa8201 100644
14184 --- a/arch/x86/kernel/cpu/common.c
14185 +++ b/arch/x86/kernel/cpu/common.c
14186 @@ -84,60 +84,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
14187
14188 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
14189
14190 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
14191 -#ifdef CONFIG_X86_64
14192 - /*
14193 - * We need valid kernel segments for data and code in long mode too
14194 - * IRET will check the segment types kkeil 2000/10/28
14195 - * Also sysret mandates a special GDT layout
14196 - *
14197 - * TLS descriptors are currently at a different place compared to i386.
14198 - * Hopefully nobody expects them at a fixed place (Wine?)
14199 - */
14200 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
14201 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
14202 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
14203 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
14204 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
14205 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
14206 -#else
14207 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
14208 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
14209 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
14210 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
14211 - /*
14212 - * Segments used for calling PnP BIOS have byte granularity.
14213 - * They code segments and data segments have fixed 64k limits,
14214 - * the transfer segment sizes are set at run time.
14215 - */
14216 - /* 32-bit code */
14217 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
14218 - /* 16-bit code */
14219 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
14220 - /* 16-bit data */
14221 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
14222 - /* 16-bit data */
14223 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
14224 - /* 16-bit data */
14225 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
14226 - /*
14227 - * The APM segments have byte granularity and their bases
14228 - * are set at run time. All have 64k limits.
14229 - */
14230 - /* 32-bit code */
14231 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
14232 - /* 16-bit code */
14233 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
14234 - /* data */
14235 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
14236 -
14237 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
14238 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
14239 - GDT_STACK_CANARY_INIT
14240 -#endif
14241 -} };
14242 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
14243 -
14244 static int __init x86_xsave_setup(char *s)
14245 {
14246 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
14247 @@ -372,7 +318,7 @@ void switch_to_new_gdt(int cpu)
14248 {
14249 struct desc_ptr gdt_descr;
14250
14251 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
14252 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
14253 gdt_descr.size = GDT_SIZE - 1;
14254 load_gdt(&gdt_descr);
14255 /* Reload the per-cpu base */
14256 @@ -839,6 +785,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
14257 /* Filter out anything that depends on CPUID levels we don't have */
14258 filter_cpuid_features(c, true);
14259
14260 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
14261 + setup_clear_cpu_cap(X86_FEATURE_SEP);
14262 +#endif
14263 +
14264 /* If the model name is still unset, do table lookup. */
14265 if (!c->x86_model_id[0]) {
14266 const char *p;
14267 @@ -1019,10 +969,12 @@ static __init int setup_disablecpuid(char *arg)
14268 }
14269 __setup("clearcpuid=", setup_disablecpuid);
14270
14271 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
14272 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
14273 +
14274 #ifdef CONFIG_X86_64
14275 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
14276 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
14277 - (unsigned long) nmi_idt_table };
14278 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
14279
14280 DEFINE_PER_CPU_FIRST(union irq_stack_union,
14281 irq_stack_union) __aligned(PAGE_SIZE);
14282 @@ -1036,7 +988,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
14283 EXPORT_PER_CPU_SYMBOL(current_task);
14284
14285 DEFINE_PER_CPU(unsigned long, kernel_stack) =
14286 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
14287 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
14288 EXPORT_PER_CPU_SYMBOL(kernel_stack);
14289
14290 DEFINE_PER_CPU(char *, irq_stack_ptr) =
14291 @@ -1126,7 +1078,7 @@ struct pt_regs * __cpuinit idle_regs(struct pt_regs *regs)
14292 {
14293 memset(regs, 0, sizeof(struct pt_regs));
14294 regs->fs = __KERNEL_PERCPU;
14295 - regs->gs = __KERNEL_STACK_CANARY;
14296 + savesegment(gs, regs->gs);
14297
14298 return regs;
14299 }
14300 @@ -1181,7 +1133,7 @@ void __cpuinit cpu_init(void)
14301 int i;
14302
14303 cpu = stack_smp_processor_id();
14304 - t = &per_cpu(init_tss, cpu);
14305 + t = init_tss + cpu;
14306 oist = &per_cpu(orig_ist, cpu);
14307
14308 #ifdef CONFIG_NUMA
14309 @@ -1207,7 +1159,7 @@ void __cpuinit cpu_init(void)
14310 switch_to_new_gdt(cpu);
14311 loadsegment(fs, 0);
14312
14313 - load_idt((const struct desc_ptr *)&idt_descr);
14314 + load_idt(&idt_descr);
14315
14316 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
14317 syscall_init();
14318 @@ -1216,7 +1168,6 @@ void __cpuinit cpu_init(void)
14319 wrmsrl(MSR_KERNEL_GS_BASE, 0);
14320 barrier();
14321
14322 - x86_configure_nx();
14323 if (cpu != 0)
14324 enable_x2apic();
14325
14326 @@ -1272,7 +1223,7 @@ void __cpuinit cpu_init(void)
14327 {
14328 int cpu = smp_processor_id();
14329 struct task_struct *curr = current;
14330 - struct tss_struct *t = &per_cpu(init_tss, cpu);
14331 + struct tss_struct *t = init_tss + cpu;
14332 struct thread_struct *thread = &curr->thread;
14333
14334 if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) {
14335 diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
14336 index 3e6ff6c..54b4992 100644
14337 --- a/arch/x86/kernel/cpu/intel.c
14338 +++ b/arch/x86/kernel/cpu/intel.c
14339 @@ -174,7 +174,7 @@ static void __cpuinit trap_init_f00f_bug(void)
14340 * Update the IDT descriptor and reload the IDT so that
14341 * it uses the read-only mapped virtual address.
14342 */
14343 - idt_descr.address = fix_to_virt(FIX_F00F_IDT);
14344 + idt_descr.address = (struct desc_struct *)fix_to_virt(FIX_F00F_IDT);
14345 load_idt(&idt_descr);
14346 }
14347 #endif
14348 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
14349 index 5a11ae2..a1a1c8a 100644
14350 --- a/arch/x86/kernel/cpu/mcheck/mce.c
14351 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
14352 @@ -42,6 +42,7 @@
14353 #include <asm/processor.h>
14354 #include <asm/mce.h>
14355 #include <asm/msr.h>
14356 +#include <asm/local.h>
14357
14358 #include "mce-internal.h"
14359
14360 @@ -250,7 +251,7 @@ static void print_mce(struct mce *m)
14361 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
14362 m->cs, m->ip);
14363
14364 - if (m->cs == __KERNEL_CS)
14365 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
14366 print_symbol("{%s}", m->ip);
14367 pr_cont("\n");
14368 }
14369 @@ -283,10 +284,10 @@ static void print_mce(struct mce *m)
14370
14371 #define PANIC_TIMEOUT 5 /* 5 seconds */
14372
14373 -static atomic_t mce_paniced;
14374 +static atomic_unchecked_t mce_paniced;
14375
14376 static int fake_panic;
14377 -static atomic_t mce_fake_paniced;
14378 +static atomic_unchecked_t mce_fake_paniced;
14379
14380 /* Panic in progress. Enable interrupts and wait for final IPI */
14381 static void wait_for_panic(void)
14382 @@ -310,7 +311,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
14383 /*
14384 * Make sure only one CPU runs in machine check panic
14385 */
14386 - if (atomic_inc_return(&mce_paniced) > 1)
14387 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
14388 wait_for_panic();
14389 barrier();
14390
14391 @@ -318,7 +319,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
14392 console_verbose();
14393 } else {
14394 /* Don't log too much for fake panic */
14395 - if (atomic_inc_return(&mce_fake_paniced) > 1)
14396 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
14397 return;
14398 }
14399 /* First print corrected ones that are still unlogged */
14400 @@ -658,7 +659,7 @@ static int mce_timed_out(u64 *t)
14401 * might have been modified by someone else.
14402 */
14403 rmb();
14404 - if (atomic_read(&mce_paniced))
14405 + if (atomic_read_unchecked(&mce_paniced))
14406 wait_for_panic();
14407 if (!monarch_timeout)
14408 goto out;
14409 @@ -1446,7 +1447,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
14410 }
14411
14412 /* Call the installed machine check handler for this CPU setup. */
14413 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
14414 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
14415 unexpected_machine_check;
14416
14417 /*
14418 @@ -1469,7 +1470,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
14419 return;
14420 }
14421
14422 + pax_open_kernel();
14423 machine_check_vector = do_machine_check;
14424 + pax_close_kernel();
14425
14426 __mcheck_cpu_init_generic();
14427 __mcheck_cpu_init_vendor(c);
14428 @@ -1483,7 +1486,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
14429 */
14430
14431 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
14432 -static int mce_chrdev_open_count; /* #times opened */
14433 +static local_t mce_chrdev_open_count; /* #times opened */
14434 static int mce_chrdev_open_exclu; /* already open exclusive? */
14435
14436 static int mce_chrdev_open(struct inode *inode, struct file *file)
14437 @@ -1491,7 +1494,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
14438 spin_lock(&mce_chrdev_state_lock);
14439
14440 if (mce_chrdev_open_exclu ||
14441 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
14442 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
14443 spin_unlock(&mce_chrdev_state_lock);
14444
14445 return -EBUSY;
14446 @@ -1499,7 +1502,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
14447
14448 if (file->f_flags & O_EXCL)
14449 mce_chrdev_open_exclu = 1;
14450 - mce_chrdev_open_count++;
14451 + local_inc(&mce_chrdev_open_count);
14452
14453 spin_unlock(&mce_chrdev_state_lock);
14454
14455 @@ -1510,7 +1513,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
14456 {
14457 spin_lock(&mce_chrdev_state_lock);
14458
14459 - mce_chrdev_open_count--;
14460 + local_dec(&mce_chrdev_open_count);
14461 mce_chrdev_open_exclu = 0;
14462
14463 spin_unlock(&mce_chrdev_state_lock);
14464 @@ -2229,7 +2232,7 @@ struct dentry *mce_get_debugfs_dir(void)
14465 static void mce_reset(void)
14466 {
14467 cpu_missing = 0;
14468 - atomic_set(&mce_fake_paniced, 0);
14469 + atomic_set_unchecked(&mce_fake_paniced, 0);
14470 atomic_set(&mce_executing, 0);
14471 atomic_set(&mce_callin, 0);
14472 atomic_set(&global_nwo, 0);
14473 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
14474 index 5c0e653..0882b0a 100644
14475 --- a/arch/x86/kernel/cpu/mcheck/p5.c
14476 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
14477 @@ -12,6 +12,7 @@
14478 #include <asm/system.h>
14479 #include <asm/mce.h>
14480 #include <asm/msr.h>
14481 +#include <asm/pgtable.h>
14482
14483 /* By default disabled */
14484 int mce_p5_enabled __read_mostly;
14485 @@ -50,7 +51,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
14486 if (!cpu_has(c, X86_FEATURE_MCE))
14487 return;
14488
14489 + pax_open_kernel();
14490 machine_check_vector = pentium_machine_check;
14491 + pax_close_kernel();
14492 /* Make sure the vector pointer is visible before we enable MCEs: */
14493 wmb();
14494
14495 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
14496 index 54060f5..c1a7577 100644
14497 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
14498 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
14499 @@ -11,6 +11,7 @@
14500 #include <asm/system.h>
14501 #include <asm/mce.h>
14502 #include <asm/msr.h>
14503 +#include <asm/pgtable.h>
14504
14505 /* Machine check handler for WinChip C6: */
14506 static void winchip_machine_check(struct pt_regs *regs, long error_code)
14507 @@ -24,7 +25,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
14508 {
14509 u32 lo, hi;
14510
14511 + pax_open_kernel();
14512 machine_check_vector = winchip_machine_check;
14513 + pax_close_kernel();
14514 /* Make sure the vector pointer is visible before we enable MCEs: */
14515 wmb();
14516
14517 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
14518 index 6b96110..0da73eb 100644
14519 --- a/arch/x86/kernel/cpu/mtrr/main.c
14520 +++ b/arch/x86/kernel/cpu/mtrr/main.c
14521 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
14522 u64 size_or_mask, size_and_mask;
14523 static bool mtrr_aps_delayed_init;
14524
14525 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
14526 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
14527
14528 const struct mtrr_ops *mtrr_if;
14529
14530 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
14531 index df5e41f..816c719 100644
14532 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
14533 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
14534 @@ -25,7 +25,7 @@ struct mtrr_ops {
14535 int (*validate_add_page)(unsigned long base, unsigned long size,
14536 unsigned int type);
14537 int (*have_wrcomb)(void);
14538 -};
14539 +} __do_const;
14540
14541 extern int generic_get_free_region(unsigned long base, unsigned long size,
14542 int replace_reg);
14543 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
14544 index 5adce10..99284ec 100644
14545 --- a/arch/x86/kernel/cpu/perf_event.c
14546 +++ b/arch/x86/kernel/cpu/perf_event.c
14547 @@ -1665,7 +1665,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
14548 break;
14549
14550 perf_callchain_store(entry, frame.return_address);
14551 - fp = frame.next_frame;
14552 + fp = (const void __force_user *)frame.next_frame;
14553 }
14554 }
14555
14556 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
14557 index 13ad899..f642b9a 100644
14558 --- a/arch/x86/kernel/crash.c
14559 +++ b/arch/x86/kernel/crash.c
14560 @@ -36,10 +36,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
14561 {
14562 #ifdef CONFIG_X86_32
14563 struct pt_regs fixed_regs;
14564 -#endif
14565
14566 -#ifdef CONFIG_X86_32
14567 - if (!user_mode_vm(regs)) {
14568 + if (!user_mode(regs)) {
14569 crash_fixup_ss_esp(&fixed_regs, regs);
14570 regs = &fixed_regs;
14571 }
14572 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
14573 index 37250fe..bf2ec74 100644
14574 --- a/arch/x86/kernel/doublefault_32.c
14575 +++ b/arch/x86/kernel/doublefault_32.c
14576 @@ -11,7 +11,7 @@
14577
14578 #define DOUBLEFAULT_STACKSIZE (1024)
14579 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
14580 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
14581 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
14582
14583 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
14584
14585 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
14586 unsigned long gdt, tss;
14587
14588 store_gdt(&gdt_desc);
14589 - gdt = gdt_desc.address;
14590 + gdt = (unsigned long)gdt_desc.address;
14591
14592 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
14593
14594 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
14595 /* 0x2 bit is always set */
14596 .flags = X86_EFLAGS_SF | 0x2,
14597 .sp = STACK_START,
14598 - .es = __USER_DS,
14599 + .es = __KERNEL_DS,
14600 .cs = __KERNEL_CS,
14601 .ss = __KERNEL_DS,
14602 - .ds = __USER_DS,
14603 + .ds = __KERNEL_DS,
14604 .fs = __KERNEL_PERCPU,
14605
14606 .__cr3 = __pa_nodebug(swapper_pg_dir),
14607 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
14608 index 4025fe4..d8451c6 100644
14609 --- a/arch/x86/kernel/dumpstack.c
14610 +++ b/arch/x86/kernel/dumpstack.c
14611 @@ -2,6 +2,9 @@
14612 * Copyright (C) 1991, 1992 Linus Torvalds
14613 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
14614 */
14615 +#ifdef CONFIG_GRKERNSEC_HIDESYM
14616 +#define __INCLUDED_BY_HIDESYM 1
14617 +#endif
14618 #include <linux/kallsyms.h>
14619 #include <linux/kprobes.h>
14620 #include <linux/uaccess.h>
14621 @@ -35,9 +38,8 @@ void printk_address(unsigned long address, int reliable)
14622 static void
14623 print_ftrace_graph_addr(unsigned long addr, void *data,
14624 const struct stacktrace_ops *ops,
14625 - struct thread_info *tinfo, int *graph)
14626 + struct task_struct *task, int *graph)
14627 {
14628 - struct task_struct *task = tinfo->task;
14629 unsigned long ret_addr;
14630 int index = task->curr_ret_stack;
14631
14632 @@ -58,7 +60,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
14633 static inline void
14634 print_ftrace_graph_addr(unsigned long addr, void *data,
14635 const struct stacktrace_ops *ops,
14636 - struct thread_info *tinfo, int *graph)
14637 + struct task_struct *task, int *graph)
14638 { }
14639 #endif
14640
14641 @@ -69,10 +71,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
14642 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
14643 */
14644
14645 -static inline int valid_stack_ptr(struct thread_info *tinfo,
14646 - void *p, unsigned int size, void *end)
14647 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
14648 {
14649 - void *t = tinfo;
14650 if (end) {
14651 if (p < end && p >= (end-THREAD_SIZE))
14652 return 1;
14653 @@ -83,14 +83,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
14654 }
14655
14656 unsigned long
14657 -print_context_stack(struct thread_info *tinfo,
14658 +print_context_stack(struct task_struct *task, void *stack_start,
14659 unsigned long *stack, unsigned long bp,
14660 const struct stacktrace_ops *ops, void *data,
14661 unsigned long *end, int *graph)
14662 {
14663 struct stack_frame *frame = (struct stack_frame *)bp;
14664
14665 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
14666 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
14667 unsigned long addr;
14668
14669 addr = *stack;
14670 @@ -102,7 +102,7 @@ print_context_stack(struct thread_info *tinfo,
14671 } else {
14672 ops->address(data, addr, 0);
14673 }
14674 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
14675 + print_ftrace_graph_addr(addr, data, ops, task, graph);
14676 }
14677 stack++;
14678 }
14679 @@ -111,7 +111,7 @@ print_context_stack(struct thread_info *tinfo,
14680 EXPORT_SYMBOL_GPL(print_context_stack);
14681
14682 unsigned long
14683 -print_context_stack_bp(struct thread_info *tinfo,
14684 +print_context_stack_bp(struct task_struct *task, void *stack_start,
14685 unsigned long *stack, unsigned long bp,
14686 const struct stacktrace_ops *ops, void *data,
14687 unsigned long *end, int *graph)
14688 @@ -119,7 +119,7 @@ print_context_stack_bp(struct thread_info *tinfo,
14689 struct stack_frame *frame = (struct stack_frame *)bp;
14690 unsigned long *ret_addr = &frame->return_address;
14691
14692 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
14693 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
14694 unsigned long addr = *ret_addr;
14695
14696 if (!__kernel_text_address(addr))
14697 @@ -128,7 +128,7 @@ print_context_stack_bp(struct thread_info *tinfo,
14698 ops->address(data, addr, 1);
14699 frame = frame->next_frame;
14700 ret_addr = &frame->return_address;
14701 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
14702 + print_ftrace_graph_addr(addr, data, ops, task, graph);
14703 }
14704
14705 return (unsigned long)frame;
14706 @@ -186,7 +186,7 @@ void dump_stack(void)
14707
14708 bp = stack_frame(current, NULL);
14709 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
14710 - current->pid, current->comm, print_tainted(),
14711 + task_pid_nr(current), current->comm, print_tainted(),
14712 init_utsname()->release,
14713 (int)strcspn(init_utsname()->version, " "),
14714 init_utsname()->version);
14715 @@ -222,6 +222,8 @@ unsigned __kprobes long oops_begin(void)
14716 }
14717 EXPORT_SYMBOL_GPL(oops_begin);
14718
14719 +extern void gr_handle_kernel_exploit(void);
14720 +
14721 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
14722 {
14723 if (regs && kexec_should_crash(current))
14724 @@ -243,7 +245,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
14725 panic("Fatal exception in interrupt");
14726 if (panic_on_oops)
14727 panic("Fatal exception");
14728 - do_exit(signr);
14729 +
14730 + gr_handle_kernel_exploit();
14731 +
14732 + do_group_exit(signr);
14733 }
14734
14735 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
14736 @@ -270,7 +275,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
14737
14738 show_registers(regs);
14739 #ifdef CONFIG_X86_32
14740 - if (user_mode_vm(regs)) {
14741 + if (user_mode(regs)) {
14742 sp = regs->sp;
14743 ss = regs->ss & 0xffff;
14744 } else {
14745 @@ -298,7 +303,7 @@ void die(const char *str, struct pt_regs *regs, long err)
14746 unsigned long flags = oops_begin();
14747 int sig = SIGSEGV;
14748
14749 - if (!user_mode_vm(regs))
14750 + if (!user_mode(regs))
14751 report_bug(regs->ip, regs);
14752
14753 if (__die(str, regs, err))
14754 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
14755 index c99f9ed..2a15d80 100644
14756 --- a/arch/x86/kernel/dumpstack_32.c
14757 +++ b/arch/x86/kernel/dumpstack_32.c
14758 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
14759 bp = stack_frame(task, regs);
14760
14761 for (;;) {
14762 - struct thread_info *context;
14763 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
14764
14765 - context = (struct thread_info *)
14766 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
14767 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
14768 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
14769
14770 - stack = (unsigned long *)context->previous_esp;
14771 - if (!stack)
14772 + if (stack_start == task_stack_page(task))
14773 break;
14774 + stack = *(unsigned long **)stack_start;
14775 if (ops->stack(data, "IRQ") < 0)
14776 break;
14777 touch_nmi_watchdog();
14778 @@ -96,21 +94,22 @@ void show_registers(struct pt_regs *regs)
14779 * When in-kernel, we also print out the stack and code at the
14780 * time of the fault..
14781 */
14782 - if (!user_mode_vm(regs)) {
14783 + if (!user_mode(regs)) {
14784 unsigned int code_prologue = code_bytes * 43 / 64;
14785 unsigned int code_len = code_bytes;
14786 unsigned char c;
14787 u8 *ip;
14788 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(smp_processor_id())[(0xffff & regs->cs) >> 3]);
14789
14790 printk(KERN_EMERG "Stack:\n");
14791 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
14792
14793 printk(KERN_EMERG "Code: ");
14794
14795 - ip = (u8 *)regs->ip - code_prologue;
14796 + ip = (u8 *)regs->ip - code_prologue + cs_base;
14797 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
14798 /* try starting at IP */
14799 - ip = (u8 *)regs->ip;
14800 + ip = (u8 *)regs->ip + cs_base;
14801 code_len = code_len - code_prologue + 1;
14802 }
14803 for (i = 0; i < code_len; i++, ip++) {
14804 @@ -119,7 +118,7 @@ void show_registers(struct pt_regs *regs)
14805 printk(KERN_CONT " Bad EIP value.");
14806 break;
14807 }
14808 - if (ip == (u8 *)regs->ip)
14809 + if (ip == (u8 *)regs->ip + cs_base)
14810 printk(KERN_CONT "<%02x> ", c);
14811 else
14812 printk(KERN_CONT "%02x ", c);
14813 @@ -132,6 +131,7 @@ int is_valid_bugaddr(unsigned long ip)
14814 {
14815 unsigned short ud2;
14816
14817 + ip = ktla_ktva(ip);
14818 if (ip < PAGE_OFFSET)
14819 return 0;
14820 if (probe_kernel_address((unsigned short *)ip, ud2))
14821 @@ -139,3 +139,15 @@ int is_valid_bugaddr(unsigned long ip)
14822
14823 return ud2 == 0x0b0f;
14824 }
14825 +
14826 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
14827 +void pax_check_alloca(unsigned long size)
14828 +{
14829 + unsigned long sp = (unsigned long)&sp, stack_left;
14830 +
14831 + /* all kernel stacks are of the same size */
14832 + stack_left = sp & (THREAD_SIZE - 1);
14833 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
14834 +}
14835 +EXPORT_SYMBOL(pax_check_alloca);
14836 +#endif
14837 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
14838 index 17107bd..9623722 100644
14839 --- a/arch/x86/kernel/dumpstack_64.c
14840 +++ b/arch/x86/kernel/dumpstack_64.c
14841 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
14842 unsigned long *irq_stack_end =
14843 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
14844 unsigned used = 0;
14845 - struct thread_info *tinfo;
14846 int graph = 0;
14847 unsigned long dummy;
14848 + void *stack_start;
14849
14850 if (!task)
14851 task = current;
14852 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
14853 * current stack address. If the stacks consist of nested
14854 * exceptions
14855 */
14856 - tinfo = task_thread_info(task);
14857 for (;;) {
14858 char *id;
14859 unsigned long *estack_end;
14860 +
14861 estack_end = in_exception_stack(cpu, (unsigned long)stack,
14862 &used, &id);
14863
14864 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
14865 if (ops->stack(data, id) < 0)
14866 break;
14867
14868 - bp = ops->walk_stack(tinfo, stack, bp, ops,
14869 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
14870 data, estack_end, &graph);
14871 ops->stack(data, "<EOE>");
14872 /*
14873 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
14874 * second-to-last pointer (index -2 to end) in the
14875 * exception stack:
14876 */
14877 + if ((u16)estack_end[-1] != __KERNEL_DS)
14878 + goto out;
14879 stack = (unsigned long *) estack_end[-2];
14880 continue;
14881 }
14882 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
14883 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
14884 if (ops->stack(data, "IRQ") < 0)
14885 break;
14886 - bp = ops->walk_stack(tinfo, stack, bp,
14887 + bp = ops->walk_stack(task, irq_stack, stack, bp,
14888 ops, data, irq_stack_end, &graph);
14889 /*
14890 * We link to the next stack (which would be
14891 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
14892 /*
14893 * This handles the process stack:
14894 */
14895 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
14896 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
14897 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
14898 +out:
14899 put_cpu();
14900 }
14901 EXPORT_SYMBOL(dump_trace);
14902 @@ -305,3 +309,50 @@ int is_valid_bugaddr(unsigned long ip)
14903
14904 return ud2 == 0x0b0f;
14905 }
14906 +
14907 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
14908 +void pax_check_alloca(unsigned long size)
14909 +{
14910 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
14911 + unsigned cpu, used;
14912 + char *id;
14913 +
14914 + /* check the process stack first */
14915 + stack_start = (unsigned long)task_stack_page(current);
14916 + stack_end = stack_start + THREAD_SIZE;
14917 + if (likely(stack_start <= sp && sp < stack_end)) {
14918 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
14919 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
14920 + return;
14921 + }
14922 +
14923 + cpu = get_cpu();
14924 +
14925 + /* check the irq stacks */
14926 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
14927 + stack_start = stack_end - IRQ_STACK_SIZE;
14928 + if (stack_start <= sp && sp < stack_end) {
14929 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
14930 + put_cpu();
14931 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
14932 + return;
14933 + }
14934 +
14935 + /* check the exception stacks */
14936 + used = 0;
14937 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
14938 + stack_start = stack_end - EXCEPTION_STKSZ;
14939 + if (stack_end && stack_start <= sp && sp < stack_end) {
14940 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
14941 + put_cpu();
14942 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
14943 + return;
14944 + }
14945 +
14946 + put_cpu();
14947 +
14948 + /* unknown stack */
14949 + BUG();
14950 +}
14951 +EXPORT_SYMBOL(pax_check_alloca);
14952 +#endif
14953 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
14954 index 9b9f18b..9fcaa04 100644
14955 --- a/arch/x86/kernel/early_printk.c
14956 +++ b/arch/x86/kernel/early_printk.c
14957 @@ -7,6 +7,7 @@
14958 #include <linux/pci_regs.h>
14959 #include <linux/pci_ids.h>
14960 #include <linux/errno.h>
14961 +#include <linux/sched.h>
14962 #include <asm/io.h>
14963 #include <asm/processor.h>
14964 #include <asm/fcntl.h>
14965 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
14966 index 7b784f4..db6b628 100644
14967 --- a/arch/x86/kernel/entry_32.S
14968 +++ b/arch/x86/kernel/entry_32.S
14969 @@ -179,13 +179,146 @@
14970 /*CFI_REL_OFFSET gs, PT_GS*/
14971 .endm
14972 .macro SET_KERNEL_GS reg
14973 +
14974 +#ifdef CONFIG_CC_STACKPROTECTOR
14975 movl $(__KERNEL_STACK_CANARY), \reg
14976 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
14977 + movl $(__USER_DS), \reg
14978 +#else
14979 + xorl \reg, \reg
14980 +#endif
14981 +
14982 movl \reg, %gs
14983 .endm
14984
14985 #endif /* CONFIG_X86_32_LAZY_GS */
14986
14987 -.macro SAVE_ALL
14988 +.macro pax_enter_kernel
14989 +#ifdef CONFIG_PAX_KERNEXEC
14990 + call pax_enter_kernel
14991 +#endif
14992 +.endm
14993 +
14994 +.macro pax_exit_kernel
14995 +#ifdef CONFIG_PAX_KERNEXEC
14996 + call pax_exit_kernel
14997 +#endif
14998 +.endm
14999 +
15000 +#ifdef CONFIG_PAX_KERNEXEC
15001 +ENTRY(pax_enter_kernel)
15002 +#ifdef CONFIG_PARAVIRT
15003 + pushl %eax
15004 + pushl %ecx
15005 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
15006 + mov %eax, %esi
15007 +#else
15008 + mov %cr0, %esi
15009 +#endif
15010 + bts $16, %esi
15011 + jnc 1f
15012 + mov %cs, %esi
15013 + cmp $__KERNEL_CS, %esi
15014 + jz 3f
15015 + ljmp $__KERNEL_CS, $3f
15016 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
15017 +2:
15018 +#ifdef CONFIG_PARAVIRT
15019 + mov %esi, %eax
15020 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
15021 +#else
15022 + mov %esi, %cr0
15023 +#endif
15024 +3:
15025 +#ifdef CONFIG_PARAVIRT
15026 + popl %ecx
15027 + popl %eax
15028 +#endif
15029 + ret
15030 +ENDPROC(pax_enter_kernel)
15031 +
15032 +ENTRY(pax_exit_kernel)
15033 +#ifdef CONFIG_PARAVIRT
15034 + pushl %eax
15035 + pushl %ecx
15036 +#endif
15037 + mov %cs, %esi
15038 + cmp $__KERNEXEC_KERNEL_CS, %esi
15039 + jnz 2f
15040 +#ifdef CONFIG_PARAVIRT
15041 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
15042 + mov %eax, %esi
15043 +#else
15044 + mov %cr0, %esi
15045 +#endif
15046 + btr $16, %esi
15047 + ljmp $__KERNEL_CS, $1f
15048 +1:
15049 +#ifdef CONFIG_PARAVIRT
15050 + mov %esi, %eax
15051 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
15052 +#else
15053 + mov %esi, %cr0
15054 +#endif
15055 +2:
15056 +#ifdef CONFIG_PARAVIRT
15057 + popl %ecx
15058 + popl %eax
15059 +#endif
15060 + ret
15061 +ENDPROC(pax_exit_kernel)
15062 +#endif
15063 +
15064 +.macro pax_erase_kstack
15065 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
15066 + call pax_erase_kstack
15067 +#endif
15068 +.endm
15069 +
15070 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
15071 +/*
15072 + * ebp: thread_info
15073 + * ecx, edx: can be clobbered
15074 + */
15075 +ENTRY(pax_erase_kstack)
15076 + pushl %edi
15077 + pushl %eax
15078 +
15079 + mov TI_lowest_stack(%ebp), %edi
15080 + mov $-0xBEEF, %eax
15081 + std
15082 +
15083 +1: mov %edi, %ecx
15084 + and $THREAD_SIZE_asm - 1, %ecx
15085 + shr $2, %ecx
15086 + repne scasl
15087 + jecxz 2f
15088 +
15089 + cmp $2*16, %ecx
15090 + jc 2f
15091 +
15092 + mov $2*16, %ecx
15093 + repe scasl
15094 + jecxz 2f
15095 + jne 1b
15096 +
15097 +2: cld
15098 + mov %esp, %ecx
15099 + sub %edi, %ecx
15100 + shr $2, %ecx
15101 + rep stosl
15102 +
15103 + mov TI_task_thread_sp0(%ebp), %edi
15104 + sub $128, %edi
15105 + mov %edi, TI_lowest_stack(%ebp)
15106 +
15107 + popl %eax
15108 + popl %edi
15109 + ret
15110 +ENDPROC(pax_erase_kstack)
15111 +#endif
15112 +
15113 +.macro __SAVE_ALL _DS
15114 cld
15115 PUSH_GS
15116 pushl_cfi %fs
15117 @@ -208,7 +341,7 @@
15118 CFI_REL_OFFSET ecx, 0
15119 pushl_cfi %ebx
15120 CFI_REL_OFFSET ebx, 0
15121 - movl $(__USER_DS), %edx
15122 + movl $\_DS, %edx
15123 movl %edx, %ds
15124 movl %edx, %es
15125 movl $(__KERNEL_PERCPU), %edx
15126 @@ -216,6 +349,15 @@
15127 SET_KERNEL_GS %edx
15128 .endm
15129
15130 +.macro SAVE_ALL
15131 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
15132 + __SAVE_ALL __KERNEL_DS
15133 + pax_enter_kernel
15134 +#else
15135 + __SAVE_ALL __USER_DS
15136 +#endif
15137 +.endm
15138 +
15139 .macro RESTORE_INT_REGS
15140 popl_cfi %ebx
15141 CFI_RESTORE ebx
15142 @@ -301,7 +443,7 @@ ENTRY(ret_from_fork)
15143 popfl_cfi
15144 jmp syscall_exit
15145 CFI_ENDPROC
15146 -END(ret_from_fork)
15147 +ENDPROC(ret_from_fork)
15148
15149 /*
15150 * Interrupt exit functions should be protected against kprobes
15151 @@ -335,7 +477,15 @@ resume_userspace_sig:
15152 andl $SEGMENT_RPL_MASK, %eax
15153 #endif
15154 cmpl $USER_RPL, %eax
15155 +
15156 +#ifdef CONFIG_PAX_KERNEXEC
15157 + jae resume_userspace
15158 +
15159 + pax_exit_kernel
15160 + jmp resume_kernel
15161 +#else
15162 jb resume_kernel # not returning to v8086 or userspace
15163 +#endif
15164
15165 ENTRY(resume_userspace)
15166 LOCKDEP_SYS_EXIT
15167 @@ -347,8 +497,8 @@ ENTRY(resume_userspace)
15168 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
15169 # int/exception return?
15170 jne work_pending
15171 - jmp restore_all
15172 -END(ret_from_exception)
15173 + jmp restore_all_pax
15174 +ENDPROC(ret_from_exception)
15175
15176 #ifdef CONFIG_PREEMPT
15177 ENTRY(resume_kernel)
15178 @@ -363,7 +513,7 @@ need_resched:
15179 jz restore_all
15180 call preempt_schedule_irq
15181 jmp need_resched
15182 -END(resume_kernel)
15183 +ENDPROC(resume_kernel)
15184 #endif
15185 CFI_ENDPROC
15186 /*
15187 @@ -397,23 +547,34 @@ sysenter_past_esp:
15188 /*CFI_REL_OFFSET cs, 0*/
15189 /*
15190 * Push current_thread_info()->sysenter_return to the stack.
15191 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
15192 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
15193 */
15194 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
15195 + pushl_cfi $0
15196 CFI_REL_OFFSET eip, 0
15197
15198 pushl_cfi %eax
15199 SAVE_ALL
15200 + GET_THREAD_INFO(%ebp)
15201 + movl TI_sysenter_return(%ebp),%ebp
15202 + movl %ebp,PT_EIP(%esp)
15203 ENABLE_INTERRUPTS(CLBR_NONE)
15204
15205 /*
15206 * Load the potential sixth argument from user stack.
15207 * Careful about security.
15208 */
15209 + movl PT_OLDESP(%esp),%ebp
15210 +
15211 +#ifdef CONFIG_PAX_MEMORY_UDEREF
15212 + mov PT_OLDSS(%esp),%ds
15213 +1: movl %ds:(%ebp),%ebp
15214 + push %ss
15215 + pop %ds
15216 +#else
15217 cmpl $__PAGE_OFFSET-3,%ebp
15218 jae syscall_fault
15219 1: movl (%ebp),%ebp
15220 +#endif
15221 +
15222 movl %ebp,PT_EBP(%esp)
15223 .section __ex_table,"a"
15224 .align 4
15225 @@ -436,12 +597,24 @@ sysenter_do_call:
15226 testl $_TIF_ALLWORK_MASK, %ecx
15227 jne sysexit_audit
15228 sysenter_exit:
15229 +
15230 +#ifdef CONFIG_PAX_RANDKSTACK
15231 + pushl_cfi %eax
15232 + movl %esp, %eax
15233 + call pax_randomize_kstack
15234 + popl_cfi %eax
15235 +#endif
15236 +
15237 + pax_erase_kstack
15238 +
15239 /* if something modifies registers it must also disable sysexit */
15240 movl PT_EIP(%esp), %edx
15241 movl PT_OLDESP(%esp), %ecx
15242 xorl %ebp,%ebp
15243 TRACE_IRQS_ON
15244 1: mov PT_FS(%esp), %fs
15245 +2: mov PT_DS(%esp), %ds
15246 +3: mov PT_ES(%esp), %es
15247 PTGS_TO_GS
15248 ENABLE_INTERRUPTS_SYSEXIT
15249
15250 @@ -458,6 +631,9 @@ sysenter_audit:
15251 movl %eax,%edx /* 2nd arg: syscall number */
15252 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
15253 call __audit_syscall_entry
15254 +
15255 + pax_erase_kstack
15256 +
15257 pushl_cfi %ebx
15258 movl PT_EAX(%esp),%eax /* reload syscall number */
15259 jmp sysenter_do_call
15260 @@ -483,11 +659,17 @@ sysexit_audit:
15261
15262 CFI_ENDPROC
15263 .pushsection .fixup,"ax"
15264 -2: movl $0,PT_FS(%esp)
15265 +4: movl $0,PT_FS(%esp)
15266 + jmp 1b
15267 +5: movl $0,PT_DS(%esp)
15268 + jmp 1b
15269 +6: movl $0,PT_ES(%esp)
15270 jmp 1b
15271 .section __ex_table,"a"
15272 .align 4
15273 - .long 1b,2b
15274 + .long 1b,4b
15275 + .long 2b,5b
15276 + .long 3b,6b
15277 .popsection
15278 PTGS_TO_GS_EX
15279 ENDPROC(ia32_sysenter_target)
15280 @@ -520,6 +702,15 @@ syscall_exit:
15281 testl $_TIF_ALLWORK_MASK, %ecx # current->work
15282 jne syscall_exit_work
15283
15284 +restore_all_pax:
15285 +
15286 +#ifdef CONFIG_PAX_RANDKSTACK
15287 + movl %esp, %eax
15288 + call pax_randomize_kstack
15289 +#endif
15290 +
15291 + pax_erase_kstack
15292 +
15293 restore_all:
15294 TRACE_IRQS_IRET
15295 restore_all_notrace:
15296 @@ -579,14 +770,34 @@ ldt_ss:
15297 * compensating for the offset by changing to the ESPFIX segment with
15298 * a base address that matches for the difference.
15299 */
15300 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
15301 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
15302 mov %esp, %edx /* load kernel esp */
15303 mov PT_OLDESP(%esp), %eax /* load userspace esp */
15304 mov %dx, %ax /* eax: new kernel esp */
15305 sub %eax, %edx /* offset (low word is 0) */
15306 +#ifdef CONFIG_SMP
15307 + movl PER_CPU_VAR(cpu_number), %ebx
15308 + shll $PAGE_SHIFT_asm, %ebx
15309 + addl $cpu_gdt_table, %ebx
15310 +#else
15311 + movl $cpu_gdt_table, %ebx
15312 +#endif
15313 shr $16, %edx
15314 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
15315 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
15316 +
15317 +#ifdef CONFIG_PAX_KERNEXEC
15318 + mov %cr0, %esi
15319 + btr $16, %esi
15320 + mov %esi, %cr0
15321 +#endif
15322 +
15323 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
15324 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
15325 +
15326 +#ifdef CONFIG_PAX_KERNEXEC
15327 + bts $16, %esi
15328 + mov %esi, %cr0
15329 +#endif
15330 +
15331 pushl_cfi $__ESPFIX_SS
15332 pushl_cfi %eax /* new kernel esp */
15333 /* Disable interrupts, but do not irqtrace this section: we
15334 @@ -615,38 +826,30 @@ work_resched:
15335 movl TI_flags(%ebp), %ecx
15336 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
15337 # than syscall tracing?
15338 - jz restore_all
15339 + jz restore_all_pax
15340 testb $_TIF_NEED_RESCHED, %cl
15341 jnz work_resched
15342
15343 work_notifysig: # deal with pending signals and
15344 # notify-resume requests
15345 + movl %esp, %eax
15346 #ifdef CONFIG_VM86
15347 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
15348 - movl %esp, %eax
15349 - jne work_notifysig_v86 # returning to kernel-space or
15350 + jz 1f # returning to kernel-space or
15351 # vm86-space
15352 - TRACE_IRQS_ON
15353 - ENABLE_INTERRUPTS(CLBR_NONE)
15354 - xorl %edx, %edx
15355 - call do_notify_resume
15356 - jmp resume_userspace_sig
15357
15358 - ALIGN
15359 -work_notifysig_v86:
15360 pushl_cfi %ecx # save ti_flags for do_notify_resume
15361 call save_v86_state # %eax contains pt_regs pointer
15362 popl_cfi %ecx
15363 movl %eax, %esp
15364 -#else
15365 - movl %esp, %eax
15366 +1:
15367 #endif
15368 TRACE_IRQS_ON
15369 ENABLE_INTERRUPTS(CLBR_NONE)
15370 xorl %edx, %edx
15371 call do_notify_resume
15372 jmp resume_userspace_sig
15373 -END(work_pending)
15374 +ENDPROC(work_pending)
15375
15376 # perform syscall exit tracing
15377 ALIGN
15378 @@ -654,11 +857,14 @@ syscall_trace_entry:
15379 movl $-ENOSYS,PT_EAX(%esp)
15380 movl %esp, %eax
15381 call syscall_trace_enter
15382 +
15383 + pax_erase_kstack
15384 +
15385 /* What it returned is what we'll actually use. */
15386 cmpl $(NR_syscalls), %eax
15387 jnae syscall_call
15388 jmp syscall_exit
15389 -END(syscall_trace_entry)
15390 +ENDPROC(syscall_trace_entry)
15391
15392 # perform syscall exit tracing
15393 ALIGN
15394 @@ -671,20 +877,24 @@ syscall_exit_work:
15395 movl %esp, %eax
15396 call syscall_trace_leave
15397 jmp resume_userspace
15398 -END(syscall_exit_work)
15399 +ENDPROC(syscall_exit_work)
15400 CFI_ENDPROC
15401
15402 RING0_INT_FRAME # can't unwind into user space anyway
15403 syscall_fault:
15404 +#ifdef CONFIG_PAX_MEMORY_UDEREF
15405 + push %ss
15406 + pop %ds
15407 +#endif
15408 GET_THREAD_INFO(%ebp)
15409 movl $-EFAULT,PT_EAX(%esp)
15410 jmp resume_userspace
15411 -END(syscall_fault)
15412 +ENDPROC(syscall_fault)
15413
15414 syscall_badsys:
15415 movl $-ENOSYS,PT_EAX(%esp)
15416 jmp resume_userspace
15417 -END(syscall_badsys)
15418 +ENDPROC(syscall_badsys)
15419 CFI_ENDPROC
15420 /*
15421 * End of kprobes section
15422 @@ -756,6 +966,36 @@ ENTRY(ptregs_clone)
15423 CFI_ENDPROC
15424 ENDPROC(ptregs_clone)
15425
15426 + ALIGN;
15427 +ENTRY(kernel_execve)
15428 + CFI_STARTPROC
15429 + pushl_cfi %ebp
15430 + sub $PT_OLDSS+4,%esp
15431 + pushl_cfi %edi
15432 + pushl_cfi %ecx
15433 + pushl_cfi %eax
15434 + lea 3*4(%esp),%edi
15435 + mov $PT_OLDSS/4+1,%ecx
15436 + xorl %eax,%eax
15437 + rep stosl
15438 + popl_cfi %eax
15439 + popl_cfi %ecx
15440 + popl_cfi %edi
15441 + movl $X86_EFLAGS_IF,PT_EFLAGS(%esp)
15442 + pushl_cfi %esp
15443 + call sys_execve
15444 + add $4,%esp
15445 + CFI_ADJUST_CFA_OFFSET -4
15446 + GET_THREAD_INFO(%ebp)
15447 + test %eax,%eax
15448 + jz syscall_exit
15449 + add $PT_OLDSS+4,%esp
15450 + CFI_ADJUST_CFA_OFFSET -PT_OLDSS-4
15451 + popl_cfi %ebp
15452 + ret
15453 + CFI_ENDPROC
15454 +ENDPROC(kernel_execve)
15455 +
15456 .macro FIXUP_ESPFIX_STACK
15457 /*
15458 * Switch back for ESPFIX stack to the normal zerobased stack
15459 @@ -765,8 +1005,15 @@ ENDPROC(ptregs_clone)
15460 * normal stack and adjusts ESP with the matching offset.
15461 */
15462 /* fixup the stack */
15463 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
15464 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
15465 +#ifdef CONFIG_SMP
15466 + movl PER_CPU_VAR(cpu_number), %ebx
15467 + shll $PAGE_SHIFT_asm, %ebx
15468 + addl $cpu_gdt_table, %ebx
15469 +#else
15470 + movl $cpu_gdt_table, %ebx
15471 +#endif
15472 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
15473 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
15474 shl $16, %eax
15475 addl %esp, %eax /* the adjusted stack pointer */
15476 pushl_cfi $__KERNEL_DS
15477 @@ -819,7 +1066,7 @@ vector=vector+1
15478 .endr
15479 2: jmp common_interrupt
15480 .endr
15481 -END(irq_entries_start)
15482 +ENDPROC(irq_entries_start)
15483
15484 .previous
15485 END(interrupt)
15486 @@ -867,7 +1114,7 @@ ENTRY(coprocessor_error)
15487 pushl_cfi $do_coprocessor_error
15488 jmp error_code
15489 CFI_ENDPROC
15490 -END(coprocessor_error)
15491 +ENDPROC(coprocessor_error)
15492
15493 ENTRY(simd_coprocessor_error)
15494 RING0_INT_FRAME
15495 @@ -888,7 +1135,7 @@ ENTRY(simd_coprocessor_error)
15496 #endif
15497 jmp error_code
15498 CFI_ENDPROC
15499 -END(simd_coprocessor_error)
15500 +ENDPROC(simd_coprocessor_error)
15501
15502 ENTRY(device_not_available)
15503 RING0_INT_FRAME
15504 @@ -896,7 +1143,7 @@ ENTRY(device_not_available)
15505 pushl_cfi $do_device_not_available
15506 jmp error_code
15507 CFI_ENDPROC
15508 -END(device_not_available)
15509 +ENDPROC(device_not_available)
15510
15511 #ifdef CONFIG_PARAVIRT
15512 ENTRY(native_iret)
15513 @@ -905,12 +1152,12 @@ ENTRY(native_iret)
15514 .align 4
15515 .long native_iret, iret_exc
15516 .previous
15517 -END(native_iret)
15518 +ENDPROC(native_iret)
15519
15520 ENTRY(native_irq_enable_sysexit)
15521 sti
15522 sysexit
15523 -END(native_irq_enable_sysexit)
15524 +ENDPROC(native_irq_enable_sysexit)
15525 #endif
15526
15527 ENTRY(overflow)
15528 @@ -919,7 +1166,7 @@ ENTRY(overflow)
15529 pushl_cfi $do_overflow
15530 jmp error_code
15531 CFI_ENDPROC
15532 -END(overflow)
15533 +ENDPROC(overflow)
15534
15535 ENTRY(bounds)
15536 RING0_INT_FRAME
15537 @@ -927,7 +1174,7 @@ ENTRY(bounds)
15538 pushl_cfi $do_bounds
15539 jmp error_code
15540 CFI_ENDPROC
15541 -END(bounds)
15542 +ENDPROC(bounds)
15543
15544 ENTRY(invalid_op)
15545 RING0_INT_FRAME
15546 @@ -935,7 +1182,7 @@ ENTRY(invalid_op)
15547 pushl_cfi $do_invalid_op
15548 jmp error_code
15549 CFI_ENDPROC
15550 -END(invalid_op)
15551 +ENDPROC(invalid_op)
15552
15553 ENTRY(coprocessor_segment_overrun)
15554 RING0_INT_FRAME
15555 @@ -943,35 +1190,35 @@ ENTRY(coprocessor_segment_overrun)
15556 pushl_cfi $do_coprocessor_segment_overrun
15557 jmp error_code
15558 CFI_ENDPROC
15559 -END(coprocessor_segment_overrun)
15560 +ENDPROC(coprocessor_segment_overrun)
15561
15562 ENTRY(invalid_TSS)
15563 RING0_EC_FRAME
15564 pushl_cfi $do_invalid_TSS
15565 jmp error_code
15566 CFI_ENDPROC
15567 -END(invalid_TSS)
15568 +ENDPROC(invalid_TSS)
15569
15570 ENTRY(segment_not_present)
15571 RING0_EC_FRAME
15572 pushl_cfi $do_segment_not_present
15573 jmp error_code
15574 CFI_ENDPROC
15575 -END(segment_not_present)
15576 +ENDPROC(segment_not_present)
15577
15578 ENTRY(stack_segment)
15579 RING0_EC_FRAME
15580 pushl_cfi $do_stack_segment
15581 jmp error_code
15582 CFI_ENDPROC
15583 -END(stack_segment)
15584 +ENDPROC(stack_segment)
15585
15586 ENTRY(alignment_check)
15587 RING0_EC_FRAME
15588 pushl_cfi $do_alignment_check
15589 jmp error_code
15590 CFI_ENDPROC
15591 -END(alignment_check)
15592 +ENDPROC(alignment_check)
15593
15594 ENTRY(divide_error)
15595 RING0_INT_FRAME
15596 @@ -979,7 +1226,7 @@ ENTRY(divide_error)
15597 pushl_cfi $do_divide_error
15598 jmp error_code
15599 CFI_ENDPROC
15600 -END(divide_error)
15601 +ENDPROC(divide_error)
15602
15603 #ifdef CONFIG_X86_MCE
15604 ENTRY(machine_check)
15605 @@ -988,7 +1235,7 @@ ENTRY(machine_check)
15606 pushl_cfi machine_check_vector
15607 jmp error_code
15608 CFI_ENDPROC
15609 -END(machine_check)
15610 +ENDPROC(machine_check)
15611 #endif
15612
15613 ENTRY(spurious_interrupt_bug)
15614 @@ -997,7 +1244,7 @@ ENTRY(spurious_interrupt_bug)
15615 pushl_cfi $do_spurious_interrupt_bug
15616 jmp error_code
15617 CFI_ENDPROC
15618 -END(spurious_interrupt_bug)
15619 +ENDPROC(spurious_interrupt_bug)
15620 /*
15621 * End of kprobes section
15622 */
15623 @@ -1112,7 +1359,7 @@ BUILD_INTERRUPT3(xen_hvm_callback_vector, XEN_HVM_EVTCHN_CALLBACK,
15624
15625 ENTRY(mcount)
15626 ret
15627 -END(mcount)
15628 +ENDPROC(mcount)
15629
15630 ENTRY(ftrace_caller)
15631 cmpl $0, function_trace_stop
15632 @@ -1141,7 +1388,7 @@ ftrace_graph_call:
15633 .globl ftrace_stub
15634 ftrace_stub:
15635 ret
15636 -END(ftrace_caller)
15637 +ENDPROC(ftrace_caller)
15638
15639 #else /* ! CONFIG_DYNAMIC_FTRACE */
15640
15641 @@ -1177,7 +1424,7 @@ trace:
15642 popl %ecx
15643 popl %eax
15644 jmp ftrace_stub
15645 -END(mcount)
15646 +ENDPROC(mcount)
15647 #endif /* CONFIG_DYNAMIC_FTRACE */
15648 #endif /* CONFIG_FUNCTION_TRACER */
15649
15650 @@ -1198,7 +1445,7 @@ ENTRY(ftrace_graph_caller)
15651 popl %ecx
15652 popl %eax
15653 ret
15654 -END(ftrace_graph_caller)
15655 +ENDPROC(ftrace_graph_caller)
15656
15657 .globl return_to_handler
15658 return_to_handler:
15659 @@ -1253,15 +1500,18 @@ error_code:
15660 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
15661 REG_TO_PTGS %ecx
15662 SET_KERNEL_GS %ecx
15663 - movl $(__USER_DS), %ecx
15664 + movl $(__KERNEL_DS), %ecx
15665 movl %ecx, %ds
15666 movl %ecx, %es
15667 +
15668 + pax_enter_kernel
15669 +
15670 TRACE_IRQS_OFF
15671 movl %esp,%eax # pt_regs pointer
15672 call *%edi
15673 jmp ret_from_exception
15674 CFI_ENDPROC
15675 -END(page_fault)
15676 +ENDPROC(page_fault)
15677
15678 /*
15679 * Debug traps and NMI can happen at the one SYSENTER instruction
15680 @@ -1303,7 +1553,7 @@ debug_stack_correct:
15681 call do_debug
15682 jmp ret_from_exception
15683 CFI_ENDPROC
15684 -END(debug)
15685 +ENDPROC(debug)
15686
15687 /*
15688 * NMI is doubly nasty. It can happen _while_ we're handling
15689 @@ -1340,6 +1590,9 @@ nmi_stack_correct:
15690 xorl %edx,%edx # zero error code
15691 movl %esp,%eax # pt_regs pointer
15692 call do_nmi
15693 +
15694 + pax_exit_kernel
15695 +
15696 jmp restore_all_notrace
15697 CFI_ENDPROC
15698
15699 @@ -1376,12 +1629,15 @@ nmi_espfix_stack:
15700 FIXUP_ESPFIX_STACK # %eax == %esp
15701 xorl %edx,%edx # zero error code
15702 call do_nmi
15703 +
15704 + pax_exit_kernel
15705 +
15706 RESTORE_REGS
15707 lss 12+4(%esp), %esp # back to espfix stack
15708 CFI_ADJUST_CFA_OFFSET -24
15709 jmp irq_return
15710 CFI_ENDPROC
15711 -END(nmi)
15712 +ENDPROC(nmi)
15713
15714 ENTRY(int3)
15715 RING0_INT_FRAME
15716 @@ -1393,14 +1649,14 @@ ENTRY(int3)
15717 call do_int3
15718 jmp ret_from_exception
15719 CFI_ENDPROC
15720 -END(int3)
15721 +ENDPROC(int3)
15722
15723 ENTRY(general_protection)
15724 RING0_EC_FRAME
15725 pushl_cfi $do_general_protection
15726 jmp error_code
15727 CFI_ENDPROC
15728 -END(general_protection)
15729 +ENDPROC(general_protection)
15730
15731 #ifdef CONFIG_KVM_GUEST
15732 ENTRY(async_page_fault)
15733 @@ -1408,7 +1664,7 @@ ENTRY(async_page_fault)
15734 pushl_cfi $do_async_page_fault
15735 jmp error_code
15736 CFI_ENDPROC
15737 -END(async_page_fault)
15738 +ENDPROC(async_page_fault)
15739 #endif
15740
15741 /*
15742 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
15743 index 1333d98..b340ca2 100644
15744 --- a/arch/x86/kernel/entry_64.S
15745 +++ b/arch/x86/kernel/entry_64.S
15746 @@ -56,6 +56,8 @@
15747 #include <asm/ftrace.h>
15748 #include <asm/percpu.h>
15749 #include <linux/err.h>
15750 +#include <asm/pgtable.h>
15751 +#include <asm/alternative-asm.h>
15752
15753 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
15754 #include <linux/elf-em.h>
15755 @@ -69,8 +71,9 @@
15756 #ifdef CONFIG_FUNCTION_TRACER
15757 #ifdef CONFIG_DYNAMIC_FTRACE
15758 ENTRY(mcount)
15759 + pax_force_retaddr
15760 retq
15761 -END(mcount)
15762 +ENDPROC(mcount)
15763
15764 ENTRY(ftrace_caller)
15765 cmpl $0, function_trace_stop
15766 @@ -93,8 +96,9 @@ GLOBAL(ftrace_graph_call)
15767 #endif
15768
15769 GLOBAL(ftrace_stub)
15770 + pax_force_retaddr
15771 retq
15772 -END(ftrace_caller)
15773 +ENDPROC(ftrace_caller)
15774
15775 #else /* ! CONFIG_DYNAMIC_FTRACE */
15776 ENTRY(mcount)
15777 @@ -113,6 +117,7 @@ ENTRY(mcount)
15778 #endif
15779
15780 GLOBAL(ftrace_stub)
15781 + pax_force_retaddr
15782 retq
15783
15784 trace:
15785 @@ -122,12 +127,13 @@ trace:
15786 movq 8(%rbp), %rsi
15787 subq $MCOUNT_INSN_SIZE, %rdi
15788
15789 + pax_force_fptr ftrace_trace_function
15790 call *ftrace_trace_function
15791
15792 MCOUNT_RESTORE_FRAME
15793
15794 jmp ftrace_stub
15795 -END(mcount)
15796 +ENDPROC(mcount)
15797 #endif /* CONFIG_DYNAMIC_FTRACE */
15798 #endif /* CONFIG_FUNCTION_TRACER */
15799
15800 @@ -147,8 +153,9 @@ ENTRY(ftrace_graph_caller)
15801
15802 MCOUNT_RESTORE_FRAME
15803
15804 + pax_force_retaddr
15805 retq
15806 -END(ftrace_graph_caller)
15807 +ENDPROC(ftrace_graph_caller)
15808
15809 GLOBAL(return_to_handler)
15810 subq $24, %rsp
15811 @@ -164,6 +171,7 @@ GLOBAL(return_to_handler)
15812 movq 8(%rsp), %rdx
15813 movq (%rsp), %rax
15814 addq $24, %rsp
15815 + pax_force_fptr %rdi
15816 jmp *%rdi
15817 #endif
15818
15819 @@ -179,6 +187,282 @@ ENTRY(native_usergs_sysret64)
15820 ENDPROC(native_usergs_sysret64)
15821 #endif /* CONFIG_PARAVIRT */
15822
15823 + .macro ljmpq sel, off
15824 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
15825 + .byte 0x48; ljmp *1234f(%rip)
15826 + .pushsection .rodata
15827 + .align 16
15828 + 1234: .quad \off; .word \sel
15829 + .popsection
15830 +#else
15831 + pushq $\sel
15832 + pushq $\off
15833 + lretq
15834 +#endif
15835 + .endm
15836 +
15837 + .macro pax_enter_kernel
15838 + pax_set_fptr_mask
15839 +#ifdef CONFIG_PAX_KERNEXEC
15840 + call pax_enter_kernel
15841 +#endif
15842 + .endm
15843 +
15844 + .macro pax_exit_kernel
15845 +#ifdef CONFIG_PAX_KERNEXEC
15846 + call pax_exit_kernel
15847 +#endif
15848 + .endm
15849 +
15850 +#ifdef CONFIG_PAX_KERNEXEC
15851 +ENTRY(pax_enter_kernel)
15852 + pushq %rdi
15853 +
15854 +#ifdef CONFIG_PARAVIRT
15855 + PV_SAVE_REGS(CLBR_RDI)
15856 +#endif
15857 +
15858 + GET_CR0_INTO_RDI
15859 + bts $16,%rdi
15860 + jnc 3f
15861 + mov %cs,%edi
15862 + cmp $__KERNEL_CS,%edi
15863 + jnz 2f
15864 +1:
15865 +
15866 +#ifdef CONFIG_PARAVIRT
15867 + PV_RESTORE_REGS(CLBR_RDI)
15868 +#endif
15869 +
15870 + popq %rdi
15871 + pax_force_retaddr
15872 + retq
15873 +
15874 +2: ljmpq __KERNEL_CS,1f
15875 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
15876 +4: SET_RDI_INTO_CR0
15877 + jmp 1b
15878 +ENDPROC(pax_enter_kernel)
15879 +
15880 +ENTRY(pax_exit_kernel)
15881 + pushq %rdi
15882 +
15883 +#ifdef CONFIG_PARAVIRT
15884 + PV_SAVE_REGS(CLBR_RDI)
15885 +#endif
15886 +
15887 + mov %cs,%rdi
15888 + cmp $__KERNEXEC_KERNEL_CS,%edi
15889 + jz 2f
15890 +1:
15891 +
15892 +#ifdef CONFIG_PARAVIRT
15893 + PV_RESTORE_REGS(CLBR_RDI);
15894 +#endif
15895 +
15896 + popq %rdi
15897 + pax_force_retaddr
15898 + retq
15899 +
15900 +2: GET_CR0_INTO_RDI
15901 + btr $16,%rdi
15902 + ljmpq __KERNEL_CS,3f
15903 +3: SET_RDI_INTO_CR0
15904 + jmp 1b
15905 +#ifdef CONFIG_PARAVIRT
15906 + PV_RESTORE_REGS(CLBR_RDI);
15907 +#endif
15908 +
15909 + popq %rdi
15910 + pax_force_retaddr
15911 + retq
15912 +ENDPROC(pax_exit_kernel)
15913 +#endif
15914 +
15915 + .macro pax_enter_kernel_user
15916 + pax_set_fptr_mask
15917 +#ifdef CONFIG_PAX_MEMORY_UDEREF
15918 + call pax_enter_kernel_user
15919 +#endif
15920 + .endm
15921 +
15922 + .macro pax_exit_kernel_user
15923 +#ifdef CONFIG_PAX_MEMORY_UDEREF
15924 + call pax_exit_kernel_user
15925 +#endif
15926 +#ifdef CONFIG_PAX_RANDKSTACK
15927 + pushq %rax
15928 + call pax_randomize_kstack
15929 + popq %rax
15930 +#endif
15931 + .endm
15932 +
15933 +#ifdef CONFIG_PAX_MEMORY_UDEREF
15934 +ENTRY(pax_enter_kernel_user)
15935 + pushq %rdi
15936 + pushq %rbx
15937 +
15938 +#ifdef CONFIG_PARAVIRT
15939 + PV_SAVE_REGS(CLBR_RDI)
15940 +#endif
15941 +
15942 + GET_CR3_INTO_RDI
15943 + mov %rdi,%rbx
15944 + add $__START_KERNEL_map,%rbx
15945 + sub phys_base(%rip),%rbx
15946 +
15947 +#ifdef CONFIG_PARAVIRT
15948 + pushq %rdi
15949 + cmpl $0, pv_info+PARAVIRT_enabled
15950 + jz 1f
15951 + i = 0
15952 + .rept USER_PGD_PTRS
15953 + mov i*8(%rbx),%rsi
15954 + mov $0,%sil
15955 + lea i*8(%rbx),%rdi
15956 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
15957 + i = i + 1
15958 + .endr
15959 + jmp 2f
15960 +1:
15961 +#endif
15962 +
15963 + i = 0
15964 + .rept USER_PGD_PTRS
15965 + movb $0,i*8(%rbx)
15966 + i = i + 1
15967 + .endr
15968 +
15969 +#ifdef CONFIG_PARAVIRT
15970 +2: popq %rdi
15971 +#endif
15972 + SET_RDI_INTO_CR3
15973 +
15974 +#ifdef CONFIG_PAX_KERNEXEC
15975 + GET_CR0_INTO_RDI
15976 + bts $16,%rdi
15977 + SET_RDI_INTO_CR0
15978 +#endif
15979 +
15980 +#ifdef CONFIG_PARAVIRT
15981 + PV_RESTORE_REGS(CLBR_RDI)
15982 +#endif
15983 +
15984 + popq %rbx
15985 + popq %rdi
15986 + pax_force_retaddr
15987 + retq
15988 +ENDPROC(pax_enter_kernel_user)
15989 +
15990 +ENTRY(pax_exit_kernel_user)
15991 + push %rdi
15992 +
15993 +#ifdef CONFIG_PARAVIRT
15994 + pushq %rbx
15995 + PV_SAVE_REGS(CLBR_RDI)
15996 +#endif
15997 +
15998 +#ifdef CONFIG_PAX_KERNEXEC
15999 + GET_CR0_INTO_RDI
16000 + btr $16,%rdi
16001 + SET_RDI_INTO_CR0
16002 +#endif
16003 +
16004 + GET_CR3_INTO_RDI
16005 + add $__START_KERNEL_map,%rdi
16006 + sub phys_base(%rip),%rdi
16007 +
16008 +#ifdef CONFIG_PARAVIRT
16009 + cmpl $0, pv_info+PARAVIRT_enabled
16010 + jz 1f
16011 + mov %rdi,%rbx
16012 + i = 0
16013 + .rept USER_PGD_PTRS
16014 + mov i*8(%rbx),%rsi
16015 + mov $0x67,%sil
16016 + lea i*8(%rbx),%rdi
16017 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
16018 + i = i + 1
16019 + .endr
16020 + jmp 2f
16021 +1:
16022 +#endif
16023 +
16024 + i = 0
16025 + .rept USER_PGD_PTRS
16026 + movb $0x67,i*8(%rdi)
16027 + i = i + 1
16028 + .endr
16029 +
16030 +#ifdef CONFIG_PARAVIRT
16031 +2: PV_RESTORE_REGS(CLBR_RDI)
16032 + popq %rbx
16033 +#endif
16034 +
16035 + popq %rdi
16036 + pax_force_retaddr
16037 + retq
16038 +ENDPROC(pax_exit_kernel_user)
16039 +#endif
16040 +
16041 +.macro pax_erase_kstack
16042 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
16043 + call pax_erase_kstack
16044 +#endif
16045 +.endm
16046 +
16047 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
16048 +/*
16049 + * r11: thread_info
16050 + * rcx, rdx: can be clobbered
16051 + */
16052 +ENTRY(pax_erase_kstack)
16053 + pushq %rdi
16054 + pushq %rax
16055 + pushq %r11
16056 +
16057 + GET_THREAD_INFO(%r11)
16058 + mov TI_lowest_stack(%r11), %rdi
16059 + mov $-0xBEEF, %rax
16060 + std
16061 +
16062 +1: mov %edi, %ecx
16063 + and $THREAD_SIZE_asm - 1, %ecx
16064 + shr $3, %ecx
16065 + repne scasq
16066 + jecxz 2f
16067 +
16068 + cmp $2*8, %ecx
16069 + jc 2f
16070 +
16071 + mov $2*8, %ecx
16072 + repe scasq
16073 + jecxz 2f
16074 + jne 1b
16075 +
16076 +2: cld
16077 + mov %esp, %ecx
16078 + sub %edi, %ecx
16079 +
16080 + cmp $THREAD_SIZE_asm, %rcx
16081 + jb 3f
16082 + ud2
16083 +3:
16084 +
16085 + shr $3, %ecx
16086 + rep stosq
16087 +
16088 + mov TI_task_thread_sp0(%r11), %rdi
16089 + sub $256, %rdi
16090 + mov %rdi, TI_lowest_stack(%r11)
16091 +
16092 + popq %r11
16093 + popq %rax
16094 + popq %rdi
16095 + pax_force_retaddr
16096 + ret
16097 +ENDPROC(pax_erase_kstack)
16098 +#endif
16099
16100 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
16101 #ifdef CONFIG_TRACE_IRQFLAGS
16102 @@ -232,8 +516,8 @@ ENDPROC(native_usergs_sysret64)
16103 .endm
16104
16105 .macro UNFAKE_STACK_FRAME
16106 - addq $8*6, %rsp
16107 - CFI_ADJUST_CFA_OFFSET -(6*8)
16108 + addq $8*6 + ARG_SKIP, %rsp
16109 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
16110 .endm
16111
16112 /*
16113 @@ -320,7 +604,7 @@ ENDPROC(native_usergs_sysret64)
16114 movq %rsp, %rsi
16115
16116 leaq -RBP(%rsp),%rdi /* arg1 for handler */
16117 - testl $3, CS(%rdi)
16118 + testb $3, CS(%rdi)
16119 je 1f
16120 SWAPGS
16121 /*
16122 @@ -356,9 +640,10 @@ ENTRY(save_rest)
16123 movq_cfi r15, R15+16
16124 movq %r11, 8(%rsp) /* return address */
16125 FIXUP_TOP_OF_STACK %r11, 16
16126 + pax_force_retaddr
16127 ret
16128 CFI_ENDPROC
16129 -END(save_rest)
16130 +ENDPROC(save_rest)
16131
16132 /* save complete stack frame */
16133 .pushsection .kprobes.text, "ax"
16134 @@ -387,9 +672,10 @@ ENTRY(save_paranoid)
16135 js 1f /* negative -> in kernel */
16136 SWAPGS
16137 xorl %ebx,%ebx
16138 -1: ret
16139 +1: pax_force_retaddr_bts
16140 + ret
16141 CFI_ENDPROC
16142 -END(save_paranoid)
16143 +ENDPROC(save_paranoid)
16144 .popsection
16145
16146 /*
16147 @@ -411,7 +697,7 @@ ENTRY(ret_from_fork)
16148
16149 RESTORE_REST
16150
16151 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
16152 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
16153 jz retint_restore_args
16154
16155 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
16156 @@ -421,7 +707,7 @@ ENTRY(ret_from_fork)
16157 jmp ret_from_sys_call # go to the SYSRET fastpath
16158
16159 CFI_ENDPROC
16160 -END(ret_from_fork)
16161 +ENDPROC(ret_from_fork)
16162
16163 /*
16164 * System call entry. Up to 6 arguments in registers are supported.
16165 @@ -457,7 +743,7 @@ END(ret_from_fork)
16166 ENTRY(system_call)
16167 CFI_STARTPROC simple
16168 CFI_SIGNAL_FRAME
16169 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
16170 + CFI_DEF_CFA rsp,0
16171 CFI_REGISTER rip,rcx
16172 /*CFI_REGISTER rflags,r11*/
16173 SWAPGS_UNSAFE_STACK
16174 @@ -470,21 +756,23 @@ GLOBAL(system_call_after_swapgs)
16175
16176 movq %rsp,PER_CPU_VAR(old_rsp)
16177 movq PER_CPU_VAR(kernel_stack),%rsp
16178 + SAVE_ARGS 8*6,0
16179 + pax_enter_kernel_user
16180 /*
16181 * No need to follow this irqs off/on section - it's straight
16182 * and short:
16183 */
16184 ENABLE_INTERRUPTS(CLBR_NONE)
16185 - SAVE_ARGS 8,0
16186 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
16187 movq %rcx,RIP-ARGOFFSET(%rsp)
16188 CFI_REL_OFFSET rip,RIP-ARGOFFSET
16189 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
16190 + GET_THREAD_INFO(%rcx)
16191 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
16192 jnz tracesys
16193 system_call_fastpath:
16194 cmpq $__NR_syscall_max,%rax
16195 ja badsys
16196 - movq %r10,%rcx
16197 + movq R10-ARGOFFSET(%rsp),%rcx
16198 call *sys_call_table(,%rax,8) # XXX: rip relative
16199 movq %rax,RAX-ARGOFFSET(%rsp)
16200 /*
16201 @@ -498,10 +786,13 @@ sysret_check:
16202 LOCKDEP_SYS_EXIT
16203 DISABLE_INTERRUPTS(CLBR_NONE)
16204 TRACE_IRQS_OFF
16205 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
16206 + GET_THREAD_INFO(%rcx)
16207 + movl TI_flags(%rcx),%edx
16208 andl %edi,%edx
16209 jnz sysret_careful
16210 CFI_REMEMBER_STATE
16211 + pax_exit_kernel_user
16212 + pax_erase_kstack
16213 /*
16214 * sysretq will re-enable interrupts:
16215 */
16216 @@ -553,14 +844,18 @@ badsys:
16217 * jump back to the normal fast path.
16218 */
16219 auditsys:
16220 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
16221 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
16222 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
16223 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
16224 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
16225 movq %rax,%rsi /* 2nd arg: syscall number */
16226 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
16227 call __audit_syscall_entry
16228 +
16229 + pax_erase_kstack
16230 +
16231 LOAD_ARGS 0 /* reload call-clobbered registers */
16232 + pax_set_fptr_mask
16233 jmp system_call_fastpath
16234
16235 /*
16236 @@ -581,7 +876,7 @@ sysret_audit:
16237 /* Do syscall tracing */
16238 tracesys:
16239 #ifdef CONFIG_AUDITSYSCALL
16240 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
16241 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
16242 jz auditsys
16243 #endif
16244 SAVE_REST
16245 @@ -589,16 +884,20 @@ tracesys:
16246 FIXUP_TOP_OF_STACK %rdi
16247 movq %rsp,%rdi
16248 call syscall_trace_enter
16249 +
16250 + pax_erase_kstack
16251 +
16252 /*
16253 * Reload arg registers from stack in case ptrace changed them.
16254 * We don't reload %rax because syscall_trace_enter() returned
16255 * the value it wants us to use in the table lookup.
16256 */
16257 LOAD_ARGS ARGOFFSET, 1
16258 + pax_set_fptr_mask
16259 RESTORE_REST
16260 cmpq $__NR_syscall_max,%rax
16261 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
16262 - movq %r10,%rcx /* fixup for C */
16263 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
16264 call *sys_call_table(,%rax,8)
16265 movq %rax,RAX-ARGOFFSET(%rsp)
16266 /* Use IRET because user could have changed frame */
16267 @@ -619,6 +918,7 @@ GLOBAL(int_with_check)
16268 andl %edi,%edx
16269 jnz int_careful
16270 andl $~TS_COMPAT,TI_status(%rcx)
16271 + pax_erase_kstack
16272 jmp retint_swapgs
16273
16274 /* Either reschedule or signal or syscall exit tracking needed. */
16275 @@ -665,7 +965,7 @@ int_restore_rest:
16276 TRACE_IRQS_OFF
16277 jmp int_with_check
16278 CFI_ENDPROC
16279 -END(system_call)
16280 +ENDPROC(system_call)
16281
16282 /*
16283 * Certain special system calls that need to save a complete full stack frame.
16284 @@ -681,7 +981,7 @@ ENTRY(\label)
16285 call \func
16286 jmp ptregscall_common
16287 CFI_ENDPROC
16288 -END(\label)
16289 +ENDPROC(\label)
16290 .endm
16291
16292 PTREGSCALL stub_clone, sys_clone, %r8
16293 @@ -699,9 +999,10 @@ ENTRY(ptregscall_common)
16294 movq_cfi_restore R12+8, r12
16295 movq_cfi_restore RBP+8, rbp
16296 movq_cfi_restore RBX+8, rbx
16297 + pax_force_retaddr
16298 ret $REST_SKIP /* pop extended registers */
16299 CFI_ENDPROC
16300 -END(ptregscall_common)
16301 +ENDPROC(ptregscall_common)
16302
16303 ENTRY(stub_execve)
16304 CFI_STARTPROC
16305 @@ -716,7 +1017,7 @@ ENTRY(stub_execve)
16306 RESTORE_REST
16307 jmp int_ret_from_sys_call
16308 CFI_ENDPROC
16309 -END(stub_execve)
16310 +ENDPROC(stub_execve)
16311
16312 /*
16313 * sigreturn is special because it needs to restore all registers on return.
16314 @@ -734,7 +1035,7 @@ ENTRY(stub_rt_sigreturn)
16315 RESTORE_REST
16316 jmp int_ret_from_sys_call
16317 CFI_ENDPROC
16318 -END(stub_rt_sigreturn)
16319 +ENDPROC(stub_rt_sigreturn)
16320
16321 /*
16322 * Build the entry stubs and pointer table with some assembler magic.
16323 @@ -769,7 +1070,7 @@ vector=vector+1
16324 2: jmp common_interrupt
16325 .endr
16326 CFI_ENDPROC
16327 -END(irq_entries_start)
16328 +ENDPROC(irq_entries_start)
16329
16330 .previous
16331 END(interrupt)
16332 @@ -789,6 +1090,16 @@ END(interrupt)
16333 subq $ORIG_RAX-RBP, %rsp
16334 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
16335 SAVE_ARGS_IRQ
16336 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16337 + testb $3, CS(%rdi)
16338 + jnz 1f
16339 + pax_enter_kernel
16340 + jmp 2f
16341 +1: pax_enter_kernel_user
16342 +2:
16343 +#else
16344 + pax_enter_kernel
16345 +#endif
16346 call \func
16347 .endm
16348
16349 @@ -820,7 +1131,7 @@ ret_from_intr:
16350
16351 exit_intr:
16352 GET_THREAD_INFO(%rcx)
16353 - testl $3,CS-ARGOFFSET(%rsp)
16354 + testb $3,CS-ARGOFFSET(%rsp)
16355 je retint_kernel
16356
16357 /* Interrupt came from user space */
16358 @@ -842,12 +1153,15 @@ retint_swapgs: /* return to user-space */
16359 * The iretq could re-enable interrupts:
16360 */
16361 DISABLE_INTERRUPTS(CLBR_ANY)
16362 + pax_exit_kernel_user
16363 TRACE_IRQS_IRETQ
16364 SWAPGS
16365 jmp restore_args
16366
16367 retint_restore_args: /* return to kernel space */
16368 DISABLE_INTERRUPTS(CLBR_ANY)
16369 + pax_exit_kernel
16370 + pax_force_retaddr RIP-ARGOFFSET
16371 /*
16372 * The iretq could re-enable interrupts:
16373 */
16374 @@ -936,7 +1250,7 @@ ENTRY(retint_kernel)
16375 #endif
16376
16377 CFI_ENDPROC
16378 -END(common_interrupt)
16379 +ENDPROC(common_interrupt)
16380 /*
16381 * End of kprobes section
16382 */
16383 @@ -953,7 +1267,7 @@ ENTRY(\sym)
16384 interrupt \do_sym
16385 jmp ret_from_intr
16386 CFI_ENDPROC
16387 -END(\sym)
16388 +ENDPROC(\sym)
16389 .endm
16390
16391 #ifdef CONFIG_SMP
16392 @@ -1026,12 +1340,22 @@ ENTRY(\sym)
16393 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
16394 call error_entry
16395 DEFAULT_FRAME 0
16396 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16397 + testb $3, CS(%rsp)
16398 + jnz 1f
16399 + pax_enter_kernel
16400 + jmp 2f
16401 +1: pax_enter_kernel_user
16402 +2:
16403 +#else
16404 + pax_enter_kernel
16405 +#endif
16406 movq %rsp,%rdi /* pt_regs pointer */
16407 xorl %esi,%esi /* no error code */
16408 call \do_sym
16409 jmp error_exit /* %ebx: no swapgs flag */
16410 CFI_ENDPROC
16411 -END(\sym)
16412 +ENDPROC(\sym)
16413 .endm
16414
16415 .macro paranoidzeroentry sym do_sym
16416 @@ -1043,15 +1367,25 @@ ENTRY(\sym)
16417 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
16418 call save_paranoid
16419 TRACE_IRQS_OFF
16420 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16421 + testb $3, CS(%rsp)
16422 + jnz 1f
16423 + pax_enter_kernel
16424 + jmp 2f
16425 +1: pax_enter_kernel_user
16426 +2:
16427 +#else
16428 + pax_enter_kernel
16429 +#endif
16430 movq %rsp,%rdi /* pt_regs pointer */
16431 xorl %esi,%esi /* no error code */
16432 call \do_sym
16433 jmp paranoid_exit /* %ebx: no swapgs flag */
16434 CFI_ENDPROC
16435 -END(\sym)
16436 +ENDPROC(\sym)
16437 .endm
16438
16439 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
16440 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
16441 .macro paranoidzeroentry_ist sym do_sym ist
16442 ENTRY(\sym)
16443 INTR_FRAME
16444 @@ -1061,14 +1395,30 @@ ENTRY(\sym)
16445 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
16446 call save_paranoid
16447 TRACE_IRQS_OFF
16448 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16449 + testb $3, CS(%rsp)
16450 + jnz 1f
16451 + pax_enter_kernel
16452 + jmp 2f
16453 +1: pax_enter_kernel_user
16454 +2:
16455 +#else
16456 + pax_enter_kernel
16457 +#endif
16458 movq %rsp,%rdi /* pt_regs pointer */
16459 xorl %esi,%esi /* no error code */
16460 +#ifdef CONFIG_SMP
16461 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
16462 + lea init_tss(%r12), %r12
16463 +#else
16464 + lea init_tss(%rip), %r12
16465 +#endif
16466 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
16467 call \do_sym
16468 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
16469 jmp paranoid_exit /* %ebx: no swapgs flag */
16470 CFI_ENDPROC
16471 -END(\sym)
16472 +ENDPROC(\sym)
16473 .endm
16474
16475 .macro errorentry sym do_sym
16476 @@ -1079,13 +1429,23 @@ ENTRY(\sym)
16477 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
16478 call error_entry
16479 DEFAULT_FRAME 0
16480 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16481 + testb $3, CS(%rsp)
16482 + jnz 1f
16483 + pax_enter_kernel
16484 + jmp 2f
16485 +1: pax_enter_kernel_user
16486 +2:
16487 +#else
16488 + pax_enter_kernel
16489 +#endif
16490 movq %rsp,%rdi /* pt_regs pointer */
16491 movq ORIG_RAX(%rsp),%rsi /* get error code */
16492 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
16493 call \do_sym
16494 jmp error_exit /* %ebx: no swapgs flag */
16495 CFI_ENDPROC
16496 -END(\sym)
16497 +ENDPROC(\sym)
16498 .endm
16499
16500 /* error code is on the stack already */
16501 @@ -1098,13 +1458,23 @@ ENTRY(\sym)
16502 call save_paranoid
16503 DEFAULT_FRAME 0
16504 TRACE_IRQS_OFF
16505 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16506 + testb $3, CS(%rsp)
16507 + jnz 1f
16508 + pax_enter_kernel
16509 + jmp 2f
16510 +1: pax_enter_kernel_user
16511 +2:
16512 +#else
16513 + pax_enter_kernel
16514 +#endif
16515 movq %rsp,%rdi /* pt_regs pointer */
16516 movq ORIG_RAX(%rsp),%rsi /* get error code */
16517 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
16518 call \do_sym
16519 jmp paranoid_exit /* %ebx: no swapgs flag */
16520 CFI_ENDPROC
16521 -END(\sym)
16522 +ENDPROC(\sym)
16523 .endm
16524
16525 zeroentry divide_error do_divide_error
16526 @@ -1134,9 +1504,10 @@ gs_change:
16527 2: mfence /* workaround */
16528 SWAPGS
16529 popfq_cfi
16530 + pax_force_retaddr
16531 ret
16532 CFI_ENDPROC
16533 -END(native_load_gs_index)
16534 +ENDPROC(native_load_gs_index)
16535
16536 .section __ex_table,"a"
16537 .align 8
16538 @@ -1158,13 +1529,14 @@ ENTRY(kernel_thread_helper)
16539 * Here we are in the child and the registers are set as they were
16540 * at kernel_thread() invocation in the parent.
16541 */
16542 + pax_force_fptr %rsi
16543 call *%rsi
16544 # exit
16545 mov %eax, %edi
16546 call do_exit
16547 ud2 # padding for call trace
16548 CFI_ENDPROC
16549 -END(kernel_thread_helper)
16550 +ENDPROC(kernel_thread_helper)
16551
16552 /*
16553 * execve(). This function needs to use IRET, not SYSRET, to set up all state properly.
16554 @@ -1191,11 +1563,11 @@ ENTRY(kernel_execve)
16555 RESTORE_REST
16556 testq %rax,%rax
16557 je int_ret_from_sys_call
16558 - RESTORE_ARGS
16559 UNFAKE_STACK_FRAME
16560 + pax_force_retaddr
16561 ret
16562 CFI_ENDPROC
16563 -END(kernel_execve)
16564 +ENDPROC(kernel_execve)
16565
16566 /* Call softirq on interrupt stack. Interrupts are off. */
16567 ENTRY(call_softirq)
16568 @@ -1213,9 +1585,10 @@ ENTRY(call_softirq)
16569 CFI_DEF_CFA_REGISTER rsp
16570 CFI_ADJUST_CFA_OFFSET -8
16571 decl PER_CPU_VAR(irq_count)
16572 + pax_force_retaddr
16573 ret
16574 CFI_ENDPROC
16575 -END(call_softirq)
16576 +ENDPROC(call_softirq)
16577
16578 #ifdef CONFIG_XEN
16579 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
16580 @@ -1253,7 +1626,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
16581 decl PER_CPU_VAR(irq_count)
16582 jmp error_exit
16583 CFI_ENDPROC
16584 -END(xen_do_hypervisor_callback)
16585 +ENDPROC(xen_do_hypervisor_callback)
16586
16587 /*
16588 * Hypervisor uses this for application faults while it executes.
16589 @@ -1312,7 +1685,7 @@ ENTRY(xen_failsafe_callback)
16590 SAVE_ALL
16591 jmp error_exit
16592 CFI_ENDPROC
16593 -END(xen_failsafe_callback)
16594 +ENDPROC(xen_failsafe_callback)
16595
16596 apicinterrupt XEN_HVM_EVTCHN_CALLBACK \
16597 xen_hvm_callback_vector xen_evtchn_do_upcall
16598 @@ -1361,16 +1734,31 @@ ENTRY(paranoid_exit)
16599 TRACE_IRQS_OFF
16600 testl %ebx,%ebx /* swapgs needed? */
16601 jnz paranoid_restore
16602 - testl $3,CS(%rsp)
16603 + testb $3,CS(%rsp)
16604 jnz paranoid_userspace
16605 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16606 + pax_exit_kernel
16607 + TRACE_IRQS_IRETQ 0
16608 + SWAPGS_UNSAFE_STACK
16609 + RESTORE_ALL 8
16610 + pax_force_retaddr_bts
16611 + jmp irq_return
16612 +#endif
16613 paranoid_swapgs:
16614 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16615 + pax_exit_kernel_user
16616 +#else
16617 + pax_exit_kernel
16618 +#endif
16619 TRACE_IRQS_IRETQ 0
16620 SWAPGS_UNSAFE_STACK
16621 RESTORE_ALL 8
16622 jmp irq_return
16623 paranoid_restore:
16624 + pax_exit_kernel
16625 TRACE_IRQS_IRETQ 0
16626 RESTORE_ALL 8
16627 + pax_force_retaddr_bts
16628 jmp irq_return
16629 paranoid_userspace:
16630 GET_THREAD_INFO(%rcx)
16631 @@ -1399,7 +1787,7 @@ paranoid_schedule:
16632 TRACE_IRQS_OFF
16633 jmp paranoid_userspace
16634 CFI_ENDPROC
16635 -END(paranoid_exit)
16636 +ENDPROC(paranoid_exit)
16637
16638 /*
16639 * Exception entry point. This expects an error code/orig_rax on the stack.
16640 @@ -1426,12 +1814,13 @@ ENTRY(error_entry)
16641 movq_cfi r14, R14+8
16642 movq_cfi r15, R15+8
16643 xorl %ebx,%ebx
16644 - testl $3,CS+8(%rsp)
16645 + testb $3,CS+8(%rsp)
16646 je error_kernelspace
16647 error_swapgs:
16648 SWAPGS
16649 error_sti:
16650 TRACE_IRQS_OFF
16651 + pax_force_retaddr_bts
16652 ret
16653
16654 /*
16655 @@ -1458,7 +1847,7 @@ bstep_iret:
16656 movq %rcx,RIP+8(%rsp)
16657 jmp error_swapgs
16658 CFI_ENDPROC
16659 -END(error_entry)
16660 +ENDPROC(error_entry)
16661
16662
16663 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
16664 @@ -1478,7 +1867,7 @@ ENTRY(error_exit)
16665 jnz retint_careful
16666 jmp retint_swapgs
16667 CFI_ENDPROC
16668 -END(error_exit)
16669 +ENDPROC(error_exit)
16670
16671 /*
16672 * Test if a given stack is an NMI stack or not.
16673 @@ -1535,9 +1924,11 @@ ENTRY(nmi)
16674 * If %cs was not the kernel segment, then the NMI triggered in user
16675 * space, which means it is definitely not nested.
16676 */
16677 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
16678 + je 1f
16679 cmpl $__KERNEL_CS, 16(%rsp)
16680 jne first_nmi
16681 -
16682 +1:
16683 /*
16684 * Check the special variable on the stack to see if NMIs are
16685 * executing.
16686 @@ -1659,6 +2050,16 @@ restart_nmi:
16687 */
16688 call save_paranoid
16689 DEFAULT_FRAME 0
16690 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16691 + testb $3, CS(%rsp)
16692 + jnz 1f
16693 + pax_enter_kernel
16694 + jmp 2f
16695 +1: pax_enter_kernel_user
16696 +2:
16697 +#else
16698 + pax_enter_kernel
16699 +#endif
16700 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
16701 movq %rsp,%rdi
16702 movq $-1,%rsi
16703 @@ -1666,14 +2067,25 @@ restart_nmi:
16704 testl %ebx,%ebx /* swapgs needed? */
16705 jnz nmi_restore
16706 nmi_swapgs:
16707 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16708 + pax_exit_kernel_user
16709 +#else
16710 + pax_exit_kernel
16711 +#endif
16712 SWAPGS_UNSAFE_STACK
16713 + RESTORE_ALL 8
16714 + /* Clear the NMI executing stack variable */
16715 + movq $0, 10*8(%rsp)
16716 + jmp irq_return
16717 nmi_restore:
16718 + pax_exit_kernel
16719 RESTORE_ALL 8
16720 + pax_force_retaddr_bts
16721 /* Clear the NMI executing stack variable */
16722 movq $0, 10*8(%rsp)
16723 jmp irq_return
16724 CFI_ENDPROC
16725 -END(nmi)
16726 +ENDPROC(nmi)
16727
16728 /*
16729 * If an NMI hit an iret because of an exception or breakpoint,
16730 @@ -1700,7 +2112,7 @@ ENTRY(ignore_sysret)
16731 mov $-ENOSYS,%eax
16732 sysret
16733 CFI_ENDPROC
16734 -END(ignore_sysret)
16735 +ENDPROC(ignore_sysret)
16736
16737 /*
16738 * End of kprobes section
16739 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
16740 index c9a281f..ce2f317 100644
16741 --- a/arch/x86/kernel/ftrace.c
16742 +++ b/arch/x86/kernel/ftrace.c
16743 @@ -126,7 +126,7 @@ static void *mod_code_ip; /* holds the IP to write to */
16744 static const void *mod_code_newcode; /* holds the text to write to the IP */
16745
16746 static unsigned nmi_wait_count;
16747 -static atomic_t nmi_update_count = ATOMIC_INIT(0);
16748 +static atomic_unchecked_t nmi_update_count = ATOMIC_INIT(0);
16749
16750 int ftrace_arch_read_dyn_info(char *buf, int size)
16751 {
16752 @@ -134,7 +134,7 @@ int ftrace_arch_read_dyn_info(char *buf, int size)
16753
16754 r = snprintf(buf, size, "%u %u",
16755 nmi_wait_count,
16756 - atomic_read(&nmi_update_count));
16757 + atomic_read_unchecked(&nmi_update_count));
16758 return r;
16759 }
16760
16761 @@ -177,8 +177,10 @@ void ftrace_nmi_enter(void)
16762
16763 if (atomic_inc_return(&nmi_running) & MOD_CODE_WRITE_FLAG) {
16764 smp_rmb();
16765 + pax_open_kernel();
16766 ftrace_mod_code();
16767 - atomic_inc(&nmi_update_count);
16768 + pax_close_kernel();
16769 + atomic_inc_unchecked(&nmi_update_count);
16770 }
16771 /* Must have previous changes seen before executions */
16772 smp_mb();
16773 @@ -271,6 +273,8 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
16774 {
16775 unsigned char replaced[MCOUNT_INSN_SIZE];
16776
16777 + ip = ktla_ktva(ip);
16778 +
16779 /*
16780 * Note: Due to modules and __init, code can
16781 * disappear and change, we need to protect against faulting
16782 @@ -327,7 +331,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
16783 unsigned char old[MCOUNT_INSN_SIZE], *new;
16784 int ret;
16785
16786 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
16787 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
16788 new = ftrace_call_replace(ip, (unsigned long)func);
16789 ret = ftrace_modify_code(ip, old, new);
16790
16791 @@ -353,6 +357,8 @@ static int ftrace_mod_jmp(unsigned long ip,
16792 {
16793 unsigned char code[MCOUNT_INSN_SIZE];
16794
16795 + ip = ktla_ktva(ip);
16796 +
16797 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
16798 return -EFAULT;
16799
16800 diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c
16801 index 51ff186..9e77418 100644
16802 --- a/arch/x86/kernel/head32.c
16803 +++ b/arch/x86/kernel/head32.c
16804 @@ -19,6 +19,7 @@
16805 #include <asm/io_apic.h>
16806 #include <asm/bios_ebda.h>
16807 #include <asm/tlbflush.h>
16808 +#include <asm/boot.h>
16809
16810 static void __init i386_default_early_setup(void)
16811 {
16812 @@ -31,8 +32,7 @@ static void __init i386_default_early_setup(void)
16813
16814 void __init i386_start_kernel(void)
16815 {
16816 - memblock_reserve(__pa_symbol(&_text),
16817 - __pa_symbol(&__bss_stop) - __pa_symbol(&_text));
16818 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(&__bss_stop) - LOAD_PHYSICAL_ADDR);
16819
16820 #ifdef CONFIG_BLK_DEV_INITRD
16821 /* Reserve INITRD */
16822 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
16823 index ce0be7c..c41476e 100644
16824 --- a/arch/x86/kernel/head_32.S
16825 +++ b/arch/x86/kernel/head_32.S
16826 @@ -25,6 +25,12 @@
16827 /* Physical address */
16828 #define pa(X) ((X) - __PAGE_OFFSET)
16829
16830 +#ifdef CONFIG_PAX_KERNEXEC
16831 +#define ta(X) (X)
16832 +#else
16833 +#define ta(X) ((X) - __PAGE_OFFSET)
16834 +#endif
16835 +
16836 /*
16837 * References to members of the new_cpu_data structure.
16838 */
16839 @@ -54,11 +60,7 @@
16840 * and small than max_low_pfn, otherwise will waste some page table entries
16841 */
16842
16843 -#if PTRS_PER_PMD > 1
16844 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
16845 -#else
16846 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
16847 -#endif
16848 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
16849
16850 /* Number of possible pages in the lowmem region */
16851 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
16852 @@ -77,6 +79,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
16853 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
16854
16855 /*
16856 + * Real beginning of normal "text" segment
16857 + */
16858 +ENTRY(stext)
16859 +ENTRY(_stext)
16860 +
16861 +/*
16862 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
16863 * %esi points to the real-mode code as a 32-bit pointer.
16864 * CS and DS must be 4 GB flat segments, but we don't depend on
16865 @@ -84,6 +92,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
16866 * can.
16867 */
16868 __HEAD
16869 +
16870 +#ifdef CONFIG_PAX_KERNEXEC
16871 + jmp startup_32
16872 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
16873 +.fill PAGE_SIZE-5,1,0xcc
16874 +#endif
16875 +
16876 ENTRY(startup_32)
16877 movl pa(stack_start),%ecx
16878
16879 @@ -105,6 +120,57 @@ ENTRY(startup_32)
16880 2:
16881 leal -__PAGE_OFFSET(%ecx),%esp
16882
16883 +#ifdef CONFIG_SMP
16884 + movl $pa(cpu_gdt_table),%edi
16885 + movl $__per_cpu_load,%eax
16886 + movw %ax,__KERNEL_PERCPU + 2(%edi)
16887 + rorl $16,%eax
16888 + movb %al,__KERNEL_PERCPU + 4(%edi)
16889 + movb %ah,__KERNEL_PERCPU + 7(%edi)
16890 + movl $__per_cpu_end - 1,%eax
16891 + subl $__per_cpu_start,%eax
16892 + movw %ax,__KERNEL_PERCPU + 0(%edi)
16893 +#endif
16894 +
16895 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16896 + movl $NR_CPUS,%ecx
16897 + movl $pa(cpu_gdt_table),%edi
16898 +1:
16899 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
16900 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
16901 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
16902 + addl $PAGE_SIZE_asm,%edi
16903 + loop 1b
16904 +#endif
16905 +
16906 +#ifdef CONFIG_PAX_KERNEXEC
16907 + movl $pa(boot_gdt),%edi
16908 + movl $__LOAD_PHYSICAL_ADDR,%eax
16909 + movw %ax,__BOOT_CS + 2(%edi)
16910 + rorl $16,%eax
16911 + movb %al,__BOOT_CS + 4(%edi)
16912 + movb %ah,__BOOT_CS + 7(%edi)
16913 + rorl $16,%eax
16914 +
16915 + ljmp $(__BOOT_CS),$1f
16916 +1:
16917 +
16918 + movl $NR_CPUS,%ecx
16919 + movl $pa(cpu_gdt_table),%edi
16920 + addl $__PAGE_OFFSET,%eax
16921 +1:
16922 + movw %ax,__KERNEL_CS + 2(%edi)
16923 + movw %ax,__KERNEXEC_KERNEL_CS + 2(%edi)
16924 + rorl $16,%eax
16925 + movb %al,__KERNEL_CS + 4(%edi)
16926 + movb %al,__KERNEXEC_KERNEL_CS + 4(%edi)
16927 + movb %ah,__KERNEL_CS + 7(%edi)
16928 + movb %ah,__KERNEXEC_KERNEL_CS + 7(%edi)
16929 + rorl $16,%eax
16930 + addl $PAGE_SIZE_asm,%edi
16931 + loop 1b
16932 +#endif
16933 +
16934 /*
16935 * Clear BSS first so that there are no surprises...
16936 */
16937 @@ -195,8 +261,11 @@ ENTRY(startup_32)
16938 movl %eax, pa(max_pfn_mapped)
16939
16940 /* Do early initialization of the fixmap area */
16941 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
16942 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
16943 +#ifdef CONFIG_COMPAT_VDSO
16944 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
16945 +#else
16946 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
16947 +#endif
16948 #else /* Not PAE */
16949
16950 page_pde_offset = (__PAGE_OFFSET >> 20);
16951 @@ -226,8 +295,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
16952 movl %eax, pa(max_pfn_mapped)
16953
16954 /* Do early initialization of the fixmap area */
16955 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
16956 - movl %eax,pa(initial_page_table+0xffc)
16957 +#ifdef CONFIG_COMPAT_VDSO
16958 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
16959 +#else
16960 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
16961 +#endif
16962 #endif
16963
16964 #ifdef CONFIG_PARAVIRT
16965 @@ -241,9 +313,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
16966 cmpl $num_subarch_entries, %eax
16967 jae bad_subarch
16968
16969 - movl pa(subarch_entries)(,%eax,4), %eax
16970 - subl $__PAGE_OFFSET, %eax
16971 - jmp *%eax
16972 + jmp *pa(subarch_entries)(,%eax,4)
16973
16974 bad_subarch:
16975 WEAK(lguest_entry)
16976 @@ -255,10 +325,10 @@ WEAK(xen_entry)
16977 __INITDATA
16978
16979 subarch_entries:
16980 - .long default_entry /* normal x86/PC */
16981 - .long lguest_entry /* lguest hypervisor */
16982 - .long xen_entry /* Xen hypervisor */
16983 - .long default_entry /* Moorestown MID */
16984 + .long ta(default_entry) /* normal x86/PC */
16985 + .long ta(lguest_entry) /* lguest hypervisor */
16986 + .long ta(xen_entry) /* Xen hypervisor */
16987 + .long ta(default_entry) /* Moorestown MID */
16988 num_subarch_entries = (. - subarch_entries) / 4
16989 .previous
16990 #else
16991 @@ -312,6 +382,7 @@ default_entry:
16992 orl %edx,%eax
16993 movl %eax,%cr4
16994
16995 +#ifdef CONFIG_X86_PAE
16996 testb $X86_CR4_PAE, %al # check if PAE is enabled
16997 jz 6f
16998
16999 @@ -340,6 +411,9 @@ default_entry:
17000 /* Make changes effective */
17001 wrmsr
17002
17003 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
17004 +#endif
17005 +
17006 6:
17007
17008 /*
17009 @@ -443,7 +517,7 @@ is386: movl $2,%ecx # set MP
17010 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
17011 movl %eax,%ss # after changing gdt.
17012
17013 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
17014 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
17015 movl %eax,%ds
17016 movl %eax,%es
17017
17018 @@ -457,15 +531,22 @@ is386: movl $2,%ecx # set MP
17019 */
17020 cmpb $0,ready
17021 jne 1f
17022 - movl $gdt_page,%eax
17023 + movl $cpu_gdt_table,%eax
17024 movl $stack_canary,%ecx
17025 +#ifdef CONFIG_SMP
17026 + addl $__per_cpu_load,%ecx
17027 +#endif
17028 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
17029 shrl $16, %ecx
17030 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
17031 movb %ch, 8 * GDT_ENTRY_STACK_CANARY + 7(%eax)
17032 1:
17033 -#endif
17034 movl $(__KERNEL_STACK_CANARY),%eax
17035 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
17036 + movl $(__USER_DS),%eax
17037 +#else
17038 + xorl %eax,%eax
17039 +#endif
17040 movl %eax,%gs
17041
17042 xorl %eax,%eax # Clear LDT
17043 @@ -558,22 +639,22 @@ early_page_fault:
17044 jmp early_fault
17045
17046 early_fault:
17047 - cld
17048 #ifdef CONFIG_PRINTK
17049 + cmpl $1,%ss:early_recursion_flag
17050 + je hlt_loop
17051 + incl %ss:early_recursion_flag
17052 + cld
17053 pusha
17054 movl $(__KERNEL_DS),%eax
17055 movl %eax,%ds
17056 movl %eax,%es
17057 - cmpl $2,early_recursion_flag
17058 - je hlt_loop
17059 - incl early_recursion_flag
17060 movl %cr2,%eax
17061 pushl %eax
17062 pushl %edx /* trapno */
17063 pushl $fault_msg
17064 call printk
17065 +; call dump_stack
17066 #endif
17067 - call dump_stack
17068 hlt_loop:
17069 hlt
17070 jmp hlt_loop
17071 @@ -581,8 +662,11 @@ hlt_loop:
17072 /* This is the default interrupt "handler" :-) */
17073 ALIGN
17074 ignore_int:
17075 - cld
17076 #ifdef CONFIG_PRINTK
17077 + cmpl $2,%ss:early_recursion_flag
17078 + je hlt_loop
17079 + incl %ss:early_recursion_flag
17080 + cld
17081 pushl %eax
17082 pushl %ecx
17083 pushl %edx
17084 @@ -591,9 +675,6 @@ ignore_int:
17085 movl $(__KERNEL_DS),%eax
17086 movl %eax,%ds
17087 movl %eax,%es
17088 - cmpl $2,early_recursion_flag
17089 - je hlt_loop
17090 - incl early_recursion_flag
17091 pushl 16(%esp)
17092 pushl 24(%esp)
17093 pushl 32(%esp)
17094 @@ -622,29 +703,43 @@ ENTRY(initial_code)
17095 /*
17096 * BSS section
17097 */
17098 -__PAGE_ALIGNED_BSS
17099 - .align PAGE_SIZE
17100 #ifdef CONFIG_X86_PAE
17101 +.section .initial_pg_pmd,"a",@progbits
17102 initial_pg_pmd:
17103 .fill 1024*KPMDS,4,0
17104 #else
17105 +.section .initial_page_table,"a",@progbits
17106 ENTRY(initial_page_table)
17107 .fill 1024,4,0
17108 #endif
17109 +.section .initial_pg_fixmap,"a",@progbits
17110 initial_pg_fixmap:
17111 .fill 1024,4,0
17112 +.section .empty_zero_page,"a",@progbits
17113 ENTRY(empty_zero_page)
17114 .fill 4096,1,0
17115 +.section .swapper_pg_dir,"a",@progbits
17116 ENTRY(swapper_pg_dir)
17117 +#ifdef CONFIG_X86_PAE
17118 + .fill 4,8,0
17119 +#else
17120 .fill 1024,4,0
17121 +#endif
17122 +
17123 +/*
17124 + * The IDT has to be page-aligned to simplify the Pentium
17125 + * F0 0F bug workaround.. We have a special link segment
17126 + * for this.
17127 + */
17128 +.section .idt,"a",@progbits
17129 +ENTRY(idt_table)
17130 + .fill 256,8,0
17131
17132 /*
17133 * This starts the data section.
17134 */
17135 #ifdef CONFIG_X86_PAE
17136 -__PAGE_ALIGNED_DATA
17137 - /* Page-aligned for the benefit of paravirt? */
17138 - .align PAGE_SIZE
17139 +.section .initial_page_table,"a",@progbits
17140 ENTRY(initial_page_table)
17141 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
17142 # if KPMDS == 3
17143 @@ -663,18 +758,27 @@ ENTRY(initial_page_table)
17144 # error "Kernel PMDs should be 1, 2 or 3"
17145 # endif
17146 .align PAGE_SIZE /* needs to be page-sized too */
17147 +
17148 +#ifdef CONFIG_PAX_PER_CPU_PGD
17149 +ENTRY(cpu_pgd)
17150 + .rept NR_CPUS
17151 + .fill 4,8,0
17152 + .endr
17153 +#endif
17154 +
17155 #endif
17156
17157 .data
17158 .balign 4
17159 ENTRY(stack_start)
17160 - .long init_thread_union+THREAD_SIZE
17161 + .long init_thread_union+THREAD_SIZE-8
17162
17163 +ready: .byte 0
17164 +
17165 +.section .rodata,"a",@progbits
17166 early_recursion_flag:
17167 .long 0
17168
17169 -ready: .byte 0
17170 -
17171 int_msg:
17172 .asciz "Unknown interrupt or fault at: %p %p %p\n"
17173
17174 @@ -707,7 +811,7 @@ fault_msg:
17175 .word 0 # 32 bit align gdt_desc.address
17176 boot_gdt_descr:
17177 .word __BOOT_DS+7
17178 - .long boot_gdt - __PAGE_OFFSET
17179 + .long pa(boot_gdt)
17180
17181 .word 0 # 32-bit align idt_desc.address
17182 idt_descr:
17183 @@ -718,7 +822,7 @@ idt_descr:
17184 .word 0 # 32 bit align gdt_desc.address
17185 ENTRY(early_gdt_descr)
17186 .word GDT_ENTRIES*8-1
17187 - .long gdt_page /* Overwritten for secondary CPUs */
17188 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
17189
17190 /*
17191 * The boot_gdt must mirror the equivalent in setup.S and is
17192 @@ -727,5 +831,65 @@ ENTRY(early_gdt_descr)
17193 .align L1_CACHE_BYTES
17194 ENTRY(boot_gdt)
17195 .fill GDT_ENTRY_BOOT_CS,8,0
17196 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
17197 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
17198 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
17199 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
17200 +
17201 + .align PAGE_SIZE_asm
17202 +ENTRY(cpu_gdt_table)
17203 + .rept NR_CPUS
17204 + .quad 0x0000000000000000 /* NULL descriptor */
17205 + .quad 0x0000000000000000 /* 0x0b reserved */
17206 + .quad 0x0000000000000000 /* 0x13 reserved */
17207 + .quad 0x0000000000000000 /* 0x1b reserved */
17208 +
17209 +#ifdef CONFIG_PAX_KERNEXEC
17210 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
17211 +#else
17212 + .quad 0x0000000000000000 /* 0x20 unused */
17213 +#endif
17214 +
17215 + .quad 0x0000000000000000 /* 0x28 unused */
17216 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
17217 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
17218 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
17219 + .quad 0x0000000000000000 /* 0x4b reserved */
17220 + .quad 0x0000000000000000 /* 0x53 reserved */
17221 + .quad 0x0000000000000000 /* 0x5b reserved */
17222 +
17223 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
17224 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
17225 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
17226 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
17227 +
17228 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
17229 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
17230 +
17231 + /*
17232 + * Segments used for calling PnP BIOS have byte granularity.
17233 + * The code segments and data segments have fixed 64k limits,
17234 + * the transfer segment sizes are set at run time.
17235 + */
17236 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
17237 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
17238 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
17239 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
17240 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
17241 +
17242 + /*
17243 + * The APM segments have byte granularity and their bases
17244 + * are set at run time. All have 64k limits.
17245 + */
17246 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
17247 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
17248 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
17249 +
17250 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
17251 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
17252 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
17253 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
17254 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
17255 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
17256 +
17257 + /* Be sure this is zeroed to avoid false validations in Xen */
17258 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
17259 + .endr
17260 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
17261 index 40f4eb3..6d24d9d 100644
17262 --- a/arch/x86/kernel/head_64.S
17263 +++ b/arch/x86/kernel/head_64.S
17264 @@ -19,6 +19,8 @@
17265 #include <asm/cache.h>
17266 #include <asm/processor-flags.h>
17267 #include <asm/percpu.h>
17268 +#include <asm/cpufeature.h>
17269 +#include <asm/alternative-asm.h>
17270
17271 #ifdef CONFIG_PARAVIRT
17272 #include <asm/asm-offsets.h>
17273 @@ -38,6 +40,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
17274 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
17275 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
17276 L3_START_KERNEL = pud_index(__START_KERNEL_map)
17277 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
17278 +L3_VMALLOC_START = pud_index(VMALLOC_START)
17279 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
17280 +L3_VMALLOC_END = pud_index(VMALLOC_END)
17281 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
17282 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
17283
17284 .text
17285 __HEAD
17286 @@ -85,35 +93,23 @@ startup_64:
17287 */
17288 addq %rbp, init_level4_pgt + 0(%rip)
17289 addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
17290 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
17291 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
17292 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
17293 addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
17294
17295 addq %rbp, level3_ident_pgt + 0(%rip)
17296 +#ifndef CONFIG_XEN
17297 + addq %rbp, level3_ident_pgt + 8(%rip)
17298 +#endif
17299
17300 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
17301 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
17302 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
17303 +
17304 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
17305 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8+8)(%rip)
17306
17307 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
17308 -
17309 - /* Add an Identity mapping if I am above 1G */
17310 - leaq _text(%rip), %rdi
17311 - andq $PMD_PAGE_MASK, %rdi
17312 -
17313 - movq %rdi, %rax
17314 - shrq $PUD_SHIFT, %rax
17315 - andq $(PTRS_PER_PUD - 1), %rax
17316 - jz ident_complete
17317 -
17318 - leaq (level2_spare_pgt - __START_KERNEL_map + _KERNPG_TABLE)(%rbp), %rdx
17319 - leaq level3_ident_pgt(%rip), %rbx
17320 - movq %rdx, 0(%rbx, %rax, 8)
17321 -
17322 - movq %rdi, %rax
17323 - shrq $PMD_SHIFT, %rax
17324 - andq $(PTRS_PER_PMD - 1), %rax
17325 - leaq __PAGE_KERNEL_IDENT_LARGE_EXEC(%rdi), %rdx
17326 - leaq level2_spare_pgt(%rip), %rbx
17327 - movq %rdx, 0(%rbx, %rax, 8)
17328 -ident_complete:
17329 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
17330
17331 /*
17332 * Fixup the kernel text+data virtual addresses. Note that
17333 @@ -160,8 +156,8 @@ ENTRY(secondary_startup_64)
17334 * after the boot processor executes this code.
17335 */
17336
17337 - /* Enable PAE mode and PGE */
17338 - movl $(X86_CR4_PAE | X86_CR4_PGE), %eax
17339 + /* Enable PAE mode and PSE/PGE */
17340 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %eax
17341 movq %rax, %cr4
17342
17343 /* Setup early boot stage 4 level pagetables. */
17344 @@ -183,9 +179,17 @@ ENTRY(secondary_startup_64)
17345 movl $MSR_EFER, %ecx
17346 rdmsr
17347 btsl $_EFER_SCE, %eax /* Enable System Call */
17348 - btl $20,%edi /* No Execute supported? */
17349 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
17350 jnc 1f
17351 btsl $_EFER_NX, %eax
17352 + leaq init_level4_pgt(%rip), %rdi
17353 +#ifndef CONFIG_EFI
17354 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
17355 +#endif
17356 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
17357 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
17358 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
17359 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
17360 1: wrmsr /* Make changes effective */
17361
17362 /* Setup cr0 */
17363 @@ -247,6 +251,7 @@ ENTRY(secondary_startup_64)
17364 * jump. In addition we need to ensure %cs is set so we make this
17365 * a far return.
17366 */
17367 + pax_set_fptr_mask
17368 movq initial_code(%rip),%rax
17369 pushq $0 # fake return address to stop unwinder
17370 pushq $__KERNEL_CS # set correct cs
17371 @@ -269,7 +274,7 @@ ENTRY(secondary_startup_64)
17372 bad_address:
17373 jmp bad_address
17374
17375 - .section ".init.text","ax"
17376 + __INIT
17377 #ifdef CONFIG_EARLY_PRINTK
17378 .globl early_idt_handlers
17379 early_idt_handlers:
17380 @@ -314,18 +319,23 @@ ENTRY(early_idt_handler)
17381 #endif /* EARLY_PRINTK */
17382 1: hlt
17383 jmp 1b
17384 + .previous
17385
17386 #ifdef CONFIG_EARLY_PRINTK
17387 + __INITDATA
17388 early_recursion_flag:
17389 .long 0
17390 + .previous
17391
17392 + .section .rodata,"a",@progbits
17393 early_idt_msg:
17394 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
17395 early_idt_ripmsg:
17396 .asciz "RIP %s\n"
17397 + .previous
17398 #endif /* CONFIG_EARLY_PRINTK */
17399 - .previous
17400
17401 + .section .rodata,"a",@progbits
17402 #define NEXT_PAGE(name) \
17403 .balign PAGE_SIZE; \
17404 ENTRY(name)
17405 @@ -338,7 +348,6 @@ ENTRY(name)
17406 i = i + 1 ; \
17407 .endr
17408
17409 - .data
17410 /*
17411 * This default setting generates an ident mapping at address 0x100000
17412 * and a mapping for the kernel that precisely maps virtual address
17413 @@ -349,13 +358,41 @@ NEXT_PAGE(init_level4_pgt)
17414 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
17415 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
17416 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
17417 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
17418 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
17419 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
17420 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
17421 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
17422 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
17423 .org init_level4_pgt + L4_START_KERNEL*8, 0
17424 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
17425 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
17426
17427 +#ifdef CONFIG_PAX_PER_CPU_PGD
17428 +NEXT_PAGE(cpu_pgd)
17429 + .rept NR_CPUS
17430 + .fill 512,8,0
17431 + .endr
17432 +#endif
17433 +
17434 NEXT_PAGE(level3_ident_pgt)
17435 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
17436 +#ifdef CONFIG_XEN
17437 .fill 511,8,0
17438 +#else
17439 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
17440 + .fill 510,8,0
17441 +#endif
17442 +
17443 +NEXT_PAGE(level3_vmalloc_start_pgt)
17444 + .fill 512,8,0
17445 +
17446 +NEXT_PAGE(level3_vmalloc_end_pgt)
17447 + .fill 512,8,0
17448 +
17449 +NEXT_PAGE(level3_vmemmap_pgt)
17450 + .fill L3_VMEMMAP_START,8,0
17451 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
17452
17453 NEXT_PAGE(level3_kernel_pgt)
17454 .fill L3_START_KERNEL,8,0
17455 @@ -363,20 +400,23 @@ NEXT_PAGE(level3_kernel_pgt)
17456 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
17457 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
17458
17459 +NEXT_PAGE(level2_vmemmap_pgt)
17460 + .fill 512,8,0
17461 +
17462 NEXT_PAGE(level2_fixmap_pgt)
17463 - .fill 506,8,0
17464 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
17465 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
17466 - .fill 5,8,0
17467 + .fill 507,8,0
17468 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
17469 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
17470 + .fill 4,8,0
17471
17472 -NEXT_PAGE(level1_fixmap_pgt)
17473 +NEXT_PAGE(level1_vsyscall_pgt)
17474 .fill 512,8,0
17475
17476 -NEXT_PAGE(level2_ident_pgt)
17477 - /* Since I easily can, map the first 1G.
17478 + /* Since I easily can, map the first 2G.
17479 * Don't set NX because code runs from these pages.
17480 */
17481 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
17482 +NEXT_PAGE(level2_ident_pgt)
17483 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
17484
17485 NEXT_PAGE(level2_kernel_pgt)
17486 /*
17487 @@ -389,37 +429,59 @@ NEXT_PAGE(level2_kernel_pgt)
17488 * If you want to increase this then increase MODULES_VADDR
17489 * too.)
17490 */
17491 - PMDS(0, __PAGE_KERNEL_LARGE_EXEC,
17492 - KERNEL_IMAGE_SIZE/PMD_SIZE)
17493 -
17494 -NEXT_PAGE(level2_spare_pgt)
17495 - .fill 512, 8, 0
17496 + PMDS(0, __PAGE_KERNEL_LARGE_EXEC, KERNEL_IMAGE_SIZE/PMD_SIZE)
17497
17498 #undef PMDS
17499 #undef NEXT_PAGE
17500
17501 - .data
17502 + .align PAGE_SIZE
17503 +ENTRY(cpu_gdt_table)
17504 + .rept NR_CPUS
17505 + .quad 0x0000000000000000 /* NULL descriptor */
17506 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
17507 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
17508 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
17509 + .quad 0x00cffb000000ffff /* __USER32_CS */
17510 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
17511 + .quad 0x00affb000000ffff /* __USER_CS */
17512 +
17513 +#ifdef CONFIG_PAX_KERNEXEC
17514 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
17515 +#else
17516 + .quad 0x0 /* unused */
17517 +#endif
17518 +
17519 + .quad 0,0 /* TSS */
17520 + .quad 0,0 /* LDT */
17521 + .quad 0,0,0 /* three TLS descriptors */
17522 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
17523 + /* asm/segment.h:GDT_ENTRIES must match this */
17524 +
17525 + /* zero the remaining page */
17526 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
17527 + .endr
17528 +
17529 .align 16
17530 .globl early_gdt_descr
17531 early_gdt_descr:
17532 .word GDT_ENTRIES*8-1
17533 early_gdt_descr_base:
17534 - .quad INIT_PER_CPU_VAR(gdt_page)
17535 + .quad cpu_gdt_table
17536
17537 ENTRY(phys_base)
17538 /* This must match the first entry in level2_kernel_pgt */
17539 .quad 0x0000000000000000
17540
17541 #include "../../x86/xen/xen-head.S"
17542 -
17543 - .section .bss, "aw", @nobits
17544 +
17545 + .section .rodata,"a",@progbits
17546 .align L1_CACHE_BYTES
17547 ENTRY(idt_table)
17548 - .skip IDT_ENTRIES * 16
17549 + .fill 512,8,0
17550
17551 .align L1_CACHE_BYTES
17552 ENTRY(nmi_idt_table)
17553 - .skip IDT_ENTRIES * 16
17554 + .fill 512,8,0
17555
17556 __PAGE_ALIGNED_BSS
17557 .align PAGE_SIZE
17558 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
17559 index 9c3bd4a..e1d9b35 100644
17560 --- a/arch/x86/kernel/i386_ksyms_32.c
17561 +++ b/arch/x86/kernel/i386_ksyms_32.c
17562 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
17563 EXPORT_SYMBOL(cmpxchg8b_emu);
17564 #endif
17565
17566 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
17567 +
17568 /* Networking helper routines. */
17569 EXPORT_SYMBOL(csum_partial_copy_generic);
17570 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
17571 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
17572
17573 EXPORT_SYMBOL(__get_user_1);
17574 EXPORT_SYMBOL(__get_user_2);
17575 @@ -36,3 +40,7 @@ EXPORT_SYMBOL(strstr);
17576
17577 EXPORT_SYMBOL(csum_partial);
17578 EXPORT_SYMBOL(empty_zero_page);
17579 +
17580 +#ifdef CONFIG_PAX_KERNEXEC
17581 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
17582 +#endif
17583 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
17584 index 6104852..6114160 100644
17585 --- a/arch/x86/kernel/i8259.c
17586 +++ b/arch/x86/kernel/i8259.c
17587 @@ -210,7 +210,7 @@ spurious_8259A_irq:
17588 "spurious 8259A interrupt: IRQ%d.\n", irq);
17589 spurious_irq_mask |= irqmask;
17590 }
17591 - atomic_inc(&irq_err_count);
17592 + atomic_inc_unchecked(&irq_err_count);
17593 /*
17594 * Theoretically we do not have to handle this IRQ,
17595 * but in Linux this does not cause problems and is
17596 diff --git a/arch/x86/kernel/init_task.c b/arch/x86/kernel/init_task.c
17597 index 43e9ccf..44ccf6f 100644
17598 --- a/arch/x86/kernel/init_task.c
17599 +++ b/arch/x86/kernel/init_task.c
17600 @@ -20,8 +20,7 @@ static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
17601 * way process stacks are handled. This is done by having a special
17602 * "init_task" linker map entry..
17603 */
17604 -union thread_union init_thread_union __init_task_data =
17605 - { INIT_THREAD_INFO(init_task) };
17606 +union thread_union init_thread_union __init_task_data;
17607
17608 /*
17609 * Initial task structure.
17610 @@ -38,5 +37,5 @@ EXPORT_SYMBOL(init_task);
17611 * section. Since TSS's are completely CPU-local, we want them
17612 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
17613 */
17614 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
17615 -
17616 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
17617 +EXPORT_SYMBOL(init_tss);
17618 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
17619 index 8c96897..be66bfa 100644
17620 --- a/arch/x86/kernel/ioport.c
17621 +++ b/arch/x86/kernel/ioport.c
17622 @@ -6,6 +6,7 @@
17623 #include <linux/sched.h>
17624 #include <linux/kernel.h>
17625 #include <linux/capability.h>
17626 +#include <linux/security.h>
17627 #include <linux/errno.h>
17628 #include <linux/types.h>
17629 #include <linux/ioport.h>
17630 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
17631
17632 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
17633 return -EINVAL;
17634 +#ifdef CONFIG_GRKERNSEC_IO
17635 + if (turn_on && grsec_disable_privio) {
17636 + gr_handle_ioperm();
17637 + return -EPERM;
17638 + }
17639 +#endif
17640 if (turn_on && !capable(CAP_SYS_RAWIO))
17641 return -EPERM;
17642
17643 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
17644 * because the ->io_bitmap_max value must match the bitmap
17645 * contents:
17646 */
17647 - tss = &per_cpu(init_tss, get_cpu());
17648 + tss = init_tss + get_cpu();
17649
17650 if (turn_on)
17651 bitmap_clear(t->io_bitmap_ptr, from, num);
17652 @@ -102,6 +109,12 @@ long sys_iopl(unsigned int level, struct pt_regs *regs)
17653 return -EINVAL;
17654 /* Trying to gain more privileges? */
17655 if (level > old) {
17656 +#ifdef CONFIG_GRKERNSEC_IO
17657 + if (grsec_disable_privio) {
17658 + gr_handle_iopl();
17659 + return -EPERM;
17660 + }
17661 +#endif
17662 if (!capable(CAP_SYS_RAWIO))
17663 return -EPERM;
17664 }
17665 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
17666 index 7943e0c..dd32c5c 100644
17667 --- a/arch/x86/kernel/irq.c
17668 +++ b/arch/x86/kernel/irq.c
17669 @@ -18,7 +18,7 @@
17670 #include <asm/mce.h>
17671 #include <asm/hw_irq.h>
17672
17673 -atomic_t irq_err_count;
17674 +atomic_unchecked_t irq_err_count;
17675
17676 /* Function pointer for generic interrupt vector handling */
17677 void (*x86_platform_ipi_callback)(void) = NULL;
17678 @@ -121,9 +121,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
17679 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
17680 seq_printf(p, " Machine check polls\n");
17681 #endif
17682 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
17683 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
17684 #if defined(CONFIG_X86_IO_APIC)
17685 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
17686 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
17687 #endif
17688 return 0;
17689 }
17690 @@ -164,10 +164,10 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
17691
17692 u64 arch_irq_stat(void)
17693 {
17694 - u64 sum = atomic_read(&irq_err_count);
17695 + u64 sum = atomic_read_unchecked(&irq_err_count);
17696
17697 #ifdef CONFIG_X86_IO_APIC
17698 - sum += atomic_read(&irq_mis_count);
17699 + sum += atomic_read_unchecked(&irq_mis_count);
17700 #endif
17701 return sum;
17702 }
17703 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
17704 index 40fc861..9b8739b 100644
17705 --- a/arch/x86/kernel/irq_32.c
17706 +++ b/arch/x86/kernel/irq_32.c
17707 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
17708 __asm__ __volatile__("andl %%esp,%0" :
17709 "=r" (sp) : "0" (THREAD_SIZE - 1));
17710
17711 - return sp < (sizeof(struct thread_info) + STACK_WARN);
17712 + return sp < STACK_WARN;
17713 }
17714
17715 static void print_stack_overflow(void)
17716 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
17717 * per-CPU IRQ handling contexts (thread information and stack)
17718 */
17719 union irq_ctx {
17720 - struct thread_info tinfo;
17721 - u32 stack[THREAD_SIZE/sizeof(u32)];
17722 + unsigned long previous_esp;
17723 + u32 stack[THREAD_SIZE/sizeof(u32)];
17724 } __attribute__((aligned(THREAD_SIZE)));
17725
17726 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
17727 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
17728 static inline int
17729 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
17730 {
17731 - union irq_ctx *curctx, *irqctx;
17732 + union irq_ctx *irqctx;
17733 u32 *isp, arg1, arg2;
17734
17735 - curctx = (union irq_ctx *) current_thread_info();
17736 irqctx = __this_cpu_read(hardirq_ctx);
17737
17738 /*
17739 @@ -92,21 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
17740 * handler) we can't do that and just have to keep using the
17741 * current stack (which is the irq stack already after all)
17742 */
17743 - if (unlikely(curctx == irqctx))
17744 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
17745 return 0;
17746
17747 /* build the stack frame on the IRQ stack */
17748 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
17749 - irqctx->tinfo.task = curctx->tinfo.task;
17750 - irqctx->tinfo.previous_esp = current_stack_pointer;
17751 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
17752 + irqctx->previous_esp = current_stack_pointer;
17753
17754 - /*
17755 - * Copy the softirq bits in preempt_count so that the
17756 - * softirq checks work in the hardirq context.
17757 - */
17758 - irqctx->tinfo.preempt_count =
17759 - (irqctx->tinfo.preempt_count & ~SOFTIRQ_MASK) |
17760 - (curctx->tinfo.preempt_count & SOFTIRQ_MASK);
17761 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17762 + __set_fs(MAKE_MM_SEG(0));
17763 +#endif
17764
17765 if (unlikely(overflow))
17766 call_on_stack(print_stack_overflow, isp);
17767 @@ -118,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
17768 : "0" (irq), "1" (desc), "2" (isp),
17769 "D" (desc->handle_irq)
17770 : "memory", "cc", "ecx");
17771 +
17772 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17773 + __set_fs(current_thread_info()->addr_limit);
17774 +#endif
17775 +
17776 return 1;
17777 }
17778
17779 @@ -126,29 +125,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
17780 */
17781 void __cpuinit irq_ctx_init(int cpu)
17782 {
17783 - union irq_ctx *irqctx;
17784 -
17785 if (per_cpu(hardirq_ctx, cpu))
17786 return;
17787
17788 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
17789 - THREAD_FLAGS,
17790 - THREAD_ORDER));
17791 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
17792 - irqctx->tinfo.cpu = cpu;
17793 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
17794 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
17795 -
17796 - per_cpu(hardirq_ctx, cpu) = irqctx;
17797 -
17798 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
17799 - THREAD_FLAGS,
17800 - THREAD_ORDER));
17801 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
17802 - irqctx->tinfo.cpu = cpu;
17803 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
17804 -
17805 - per_cpu(softirq_ctx, cpu) = irqctx;
17806 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREAD_FLAGS, THREAD_ORDER));
17807 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREAD_FLAGS, THREAD_ORDER));
17808
17809 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
17810 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
17811 @@ -157,7 +138,6 @@ void __cpuinit irq_ctx_init(int cpu)
17812 asmlinkage void do_softirq(void)
17813 {
17814 unsigned long flags;
17815 - struct thread_info *curctx;
17816 union irq_ctx *irqctx;
17817 u32 *isp;
17818
17819 @@ -167,15 +147,22 @@ asmlinkage void do_softirq(void)
17820 local_irq_save(flags);
17821
17822 if (local_softirq_pending()) {
17823 - curctx = current_thread_info();
17824 irqctx = __this_cpu_read(softirq_ctx);
17825 - irqctx->tinfo.task = curctx->task;
17826 - irqctx->tinfo.previous_esp = current_stack_pointer;
17827 + irqctx->previous_esp = current_stack_pointer;
17828
17829 /* build the stack frame on the softirq stack */
17830 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
17831 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
17832 +
17833 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17834 + __set_fs(MAKE_MM_SEG(0));
17835 +#endif
17836
17837 call_on_stack(__do_softirq, isp);
17838 +
17839 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17840 + __set_fs(current_thread_info()->addr_limit);
17841 +#endif
17842 +
17843 /*
17844 * Shouldn't happen, we returned above if in_interrupt():
17845 */
17846 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
17847 index d04d3ec..ea4b374 100644
17848 --- a/arch/x86/kernel/irq_64.c
17849 +++ b/arch/x86/kernel/irq_64.c
17850 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
17851 u64 estack_top, estack_bottom;
17852 u64 curbase = (u64)task_stack_page(current);
17853
17854 - if (user_mode_vm(regs))
17855 + if (user_mode(regs))
17856 return;
17857
17858 if (regs->sp >= curbase + sizeof(struct thread_info) +
17859 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
17860 index 90fcf62..e682cdd 100644
17861 --- a/arch/x86/kernel/kdebugfs.c
17862 +++ b/arch/x86/kernel/kdebugfs.c
17863 @@ -28,6 +28,8 @@ struct setup_data_node {
17864 };
17865
17866 static ssize_t setup_data_read(struct file *file, char __user *user_buf,
17867 + size_t count, loff_t *ppos) __size_overflow(3);
17868 +static ssize_t setup_data_read(struct file *file, char __user *user_buf,
17869 size_t count, loff_t *ppos)
17870 {
17871 struct setup_data_node *node = file->private_data;
17872 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
17873 index 2f45c4c..d95504f 100644
17874 --- a/arch/x86/kernel/kgdb.c
17875 +++ b/arch/x86/kernel/kgdb.c
17876 @@ -126,11 +126,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
17877 #ifdef CONFIG_X86_32
17878 switch (regno) {
17879 case GDB_SS:
17880 - if (!user_mode_vm(regs))
17881 + if (!user_mode(regs))
17882 *(unsigned long *)mem = __KERNEL_DS;
17883 break;
17884 case GDB_SP:
17885 - if (!user_mode_vm(regs))
17886 + if (!user_mode(regs))
17887 *(unsigned long *)mem = kernel_stack_pointer(regs);
17888 break;
17889 case GDB_GS:
17890 @@ -475,12 +475,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
17891 case 'k':
17892 /* clear the trace bit */
17893 linux_regs->flags &= ~X86_EFLAGS_TF;
17894 - atomic_set(&kgdb_cpu_doing_single_step, -1);
17895 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
17896
17897 /* set the trace bit if we're stepping */
17898 if (remcomInBuffer[0] == 's') {
17899 linux_regs->flags |= X86_EFLAGS_TF;
17900 - atomic_set(&kgdb_cpu_doing_single_step,
17901 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
17902 raw_smp_processor_id());
17903 }
17904
17905 @@ -545,7 +545,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
17906
17907 switch (cmd) {
17908 case DIE_DEBUG:
17909 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
17910 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
17911 if (user_mode(regs))
17912 return single_step_cont(regs, args);
17913 break;
17914 diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
17915 index 7da647d..56fe348 100644
17916 --- a/arch/x86/kernel/kprobes.c
17917 +++ b/arch/x86/kernel/kprobes.c
17918 @@ -118,8 +118,11 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
17919 } __attribute__((packed)) *insn;
17920
17921 insn = (struct __arch_relative_insn *)from;
17922 +
17923 + pax_open_kernel();
17924 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
17925 insn->op = op;
17926 + pax_close_kernel();
17927 }
17928
17929 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
17930 @@ -156,7 +159,7 @@ static int __kprobes can_boost(kprobe_opcode_t *opcodes)
17931 kprobe_opcode_t opcode;
17932 kprobe_opcode_t *orig_opcodes = opcodes;
17933
17934 - if (search_exception_tables((unsigned long)opcodes))
17935 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
17936 return 0; /* Page fault may occur on this address. */
17937
17938 retry:
17939 @@ -317,7 +320,9 @@ static int __kprobes __copy_instruction(u8 *dest, u8 *src, int recover)
17940 }
17941 }
17942 insn_get_length(&insn);
17943 + pax_open_kernel();
17944 memcpy(dest, insn.kaddr, insn.length);
17945 + pax_close_kernel();
17946
17947 #ifdef CONFIG_X86_64
17948 if (insn_rip_relative(&insn)) {
17949 @@ -341,7 +346,9 @@ static int __kprobes __copy_instruction(u8 *dest, u8 *src, int recover)
17950 (u8 *) dest;
17951 BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */
17952 disp = (u8 *) dest + insn_offset_displacement(&insn);
17953 + pax_open_kernel();
17954 *(s32 *) disp = (s32) newdisp;
17955 + pax_close_kernel();
17956 }
17957 #endif
17958 return insn.length;
17959 @@ -355,12 +362,12 @@ static void __kprobes arch_copy_kprobe(struct kprobe *p)
17960 */
17961 __copy_instruction(p->ainsn.insn, p->addr, 0);
17962
17963 - if (can_boost(p->addr))
17964 + if (can_boost(ktla_ktva(p->addr)))
17965 p->ainsn.boostable = 0;
17966 else
17967 p->ainsn.boostable = -1;
17968
17969 - p->opcode = *p->addr;
17970 + p->opcode = *(ktla_ktva(p->addr));
17971 }
17972
17973 int __kprobes arch_prepare_kprobe(struct kprobe *p)
17974 @@ -477,7 +484,7 @@ static void __kprobes setup_singlestep(struct kprobe *p, struct pt_regs *regs,
17975 * nor set current_kprobe, because it doesn't use single
17976 * stepping.
17977 */
17978 - regs->ip = (unsigned long)p->ainsn.insn;
17979 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
17980 preempt_enable_no_resched();
17981 return;
17982 }
17983 @@ -496,7 +503,7 @@ static void __kprobes setup_singlestep(struct kprobe *p, struct pt_regs *regs,
17984 if (p->opcode == BREAKPOINT_INSTRUCTION)
17985 regs->ip = (unsigned long)p->addr;
17986 else
17987 - regs->ip = (unsigned long)p->ainsn.insn;
17988 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
17989 }
17990
17991 /*
17992 @@ -575,7 +582,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
17993 setup_singlestep(p, regs, kcb, 0);
17994 return 1;
17995 }
17996 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
17997 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
17998 /*
17999 * The breakpoint instruction was removed right
18000 * after we hit it. Another cpu has removed
18001 @@ -683,6 +690,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
18002 " movq %rax, 152(%rsp)\n"
18003 RESTORE_REGS_STRING
18004 " popfq\n"
18005 +#ifdef KERNEXEC_PLUGIN
18006 + " btsq $63,(%rsp)\n"
18007 +#endif
18008 #else
18009 " pushf\n"
18010 SAVE_REGS_STRING
18011 @@ -820,7 +830,7 @@ static void __kprobes resume_execution(struct kprobe *p,
18012 struct pt_regs *regs, struct kprobe_ctlblk *kcb)
18013 {
18014 unsigned long *tos = stack_addr(regs);
18015 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
18016 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
18017 unsigned long orig_ip = (unsigned long)p->addr;
18018 kprobe_opcode_t *insn = p->ainsn.insn;
18019
18020 @@ -1002,7 +1012,7 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
18021 struct die_args *args = data;
18022 int ret = NOTIFY_DONE;
18023
18024 - if (args->regs && user_mode_vm(args->regs))
18025 + if (args->regs && user_mode(args->regs))
18026 return ret;
18027
18028 switch (val) {
18029 @@ -1384,7 +1394,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
18030 * Verify if the address gap is in 2GB range, because this uses
18031 * a relative jump.
18032 */
18033 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
18034 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
18035 if (abs(rel) > 0x7fffffff)
18036 return -ERANGE;
18037
18038 @@ -1405,11 +1415,11 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
18039 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
18040
18041 /* Set probe function call */
18042 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
18043 + synthesize_relcall(buf + TMPL_CALL_IDX, ktla_ktva(optimized_callback));
18044
18045 /* Set returning jmp instruction at the tail of out-of-line buffer */
18046 synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
18047 - (u8 *)op->kp.addr + op->optinsn.size);
18048 + (u8 *)ktla_ktva(op->kp.addr) + op->optinsn.size);
18049
18050 flush_icache_range((unsigned long) buf,
18051 (unsigned long) buf + TMPL_END_IDX +
18052 @@ -1431,7 +1441,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
18053 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
18054
18055 /* Backup instructions which will be replaced by jump address */
18056 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
18057 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
18058 RELATIVE_ADDR_SIZE);
18059
18060 insn_buf[0] = RELATIVEJUMP_OPCODE;
18061 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
18062 index ea69726..604d066 100644
18063 --- a/arch/x86/kernel/ldt.c
18064 +++ b/arch/x86/kernel/ldt.c
18065 @@ -67,13 +67,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
18066 if (reload) {
18067 #ifdef CONFIG_SMP
18068 preempt_disable();
18069 - load_LDT(pc);
18070 + load_LDT_nolock(pc);
18071 if (!cpumask_equal(mm_cpumask(current->mm),
18072 cpumask_of(smp_processor_id())))
18073 smp_call_function(flush_ldt, current->mm, 1);
18074 preempt_enable();
18075 #else
18076 - load_LDT(pc);
18077 + load_LDT_nolock(pc);
18078 #endif
18079 }
18080 if (oldsize) {
18081 @@ -95,7 +95,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
18082 return err;
18083
18084 for (i = 0; i < old->size; i++)
18085 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
18086 + write_ldt_entry(new->ldt, i, old->ldt + i);
18087 return 0;
18088 }
18089
18090 @@ -116,6 +116,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
18091 retval = copy_ldt(&mm->context, &old_mm->context);
18092 mutex_unlock(&old_mm->context.lock);
18093 }
18094 +
18095 + if (tsk == current) {
18096 + mm->context.vdso = 0;
18097 +
18098 +#ifdef CONFIG_X86_32
18099 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
18100 + mm->context.user_cs_base = 0UL;
18101 + mm->context.user_cs_limit = ~0UL;
18102 +
18103 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
18104 + cpus_clear(mm->context.cpu_user_cs_mask);
18105 +#endif
18106 +
18107 +#endif
18108 +#endif
18109 +
18110 + }
18111 +
18112 return retval;
18113 }
18114
18115 @@ -230,6 +248,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
18116 }
18117 }
18118
18119 +#ifdef CONFIG_PAX_SEGMEXEC
18120 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
18121 + error = -EINVAL;
18122 + goto out_unlock;
18123 + }
18124 +#endif
18125 +
18126 fill_ldt(&ldt, &ldt_info);
18127 if (oldmode)
18128 ldt.avl = 0;
18129 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
18130 index a3fa43b..8966f4c 100644
18131 --- a/arch/x86/kernel/machine_kexec_32.c
18132 +++ b/arch/x86/kernel/machine_kexec_32.c
18133 @@ -27,7 +27,7 @@
18134 #include <asm/cacheflush.h>
18135 #include <asm/debugreg.h>
18136
18137 -static void set_idt(void *newidt, __u16 limit)
18138 +static void set_idt(struct desc_struct *newidt, __u16 limit)
18139 {
18140 struct desc_ptr curidt;
18141
18142 @@ -39,7 +39,7 @@ static void set_idt(void *newidt, __u16 limit)
18143 }
18144
18145
18146 -static void set_gdt(void *newgdt, __u16 limit)
18147 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
18148 {
18149 struct desc_ptr curgdt;
18150
18151 @@ -217,7 +217,7 @@ void machine_kexec(struct kimage *image)
18152 }
18153
18154 control_page = page_address(image->control_code_page);
18155 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
18156 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
18157
18158 relocate_kernel_ptr = control_page;
18159 page_list[PA_CONTROL_PAGE] = __pa(control_page);
18160 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
18161 index 3ca42d0..7cff8cc 100644
18162 --- a/arch/x86/kernel/microcode_intel.c
18163 +++ b/arch/x86/kernel/microcode_intel.c
18164 @@ -436,13 +436,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device)
18165
18166 static int get_ucode_user(void *to, const void *from, size_t n)
18167 {
18168 - return copy_from_user(to, from, n);
18169 + return copy_from_user(to, (const void __force_user *)from, n);
18170 }
18171
18172 static enum ucode_state
18173 request_microcode_user(int cpu, const void __user *buf, size_t size)
18174 {
18175 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
18176 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
18177 }
18178
18179 static void microcode_fini_cpu(int cpu)
18180 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
18181 index 925179f..267ac7a 100644
18182 --- a/arch/x86/kernel/module.c
18183 +++ b/arch/x86/kernel/module.c
18184 @@ -36,15 +36,60 @@
18185 #define DEBUGP(fmt...)
18186 #endif
18187
18188 -void *module_alloc(unsigned long size)
18189 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
18190 {
18191 - if (PAGE_ALIGN(size) > MODULES_LEN)
18192 + if (size == 0 || PAGE_ALIGN(size) > MODULES_LEN)
18193 return NULL;
18194 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
18195 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
18196 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
18197 -1, __builtin_return_address(0));
18198 }
18199
18200 +void *module_alloc(unsigned long size)
18201 +{
18202 +
18203 +#ifdef CONFIG_PAX_KERNEXEC
18204 + return __module_alloc(size, PAGE_KERNEL);
18205 +#else
18206 + return __module_alloc(size, PAGE_KERNEL_EXEC);
18207 +#endif
18208 +
18209 +}
18210 +
18211 +#ifdef CONFIG_PAX_KERNEXEC
18212 +#ifdef CONFIG_X86_32
18213 +void *module_alloc_exec(unsigned long size)
18214 +{
18215 + struct vm_struct *area;
18216 +
18217 + if (size == 0)
18218 + return NULL;
18219 +
18220 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
18221 + return area ? area->addr : NULL;
18222 +}
18223 +EXPORT_SYMBOL(module_alloc_exec);
18224 +
18225 +void module_free_exec(struct module *mod, void *module_region)
18226 +{
18227 + vunmap(module_region);
18228 +}
18229 +EXPORT_SYMBOL(module_free_exec);
18230 +#else
18231 +void module_free_exec(struct module *mod, void *module_region)
18232 +{
18233 + module_free(mod, module_region);
18234 +}
18235 +EXPORT_SYMBOL(module_free_exec);
18236 +
18237 +void *module_alloc_exec(unsigned long size)
18238 +{
18239 + return __module_alloc(size, PAGE_KERNEL_RX);
18240 +}
18241 +EXPORT_SYMBOL(module_alloc_exec);
18242 +#endif
18243 +#endif
18244 +
18245 #ifdef CONFIG_X86_32
18246 int apply_relocate(Elf32_Shdr *sechdrs,
18247 const char *strtab,
18248 @@ -55,14 +100,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
18249 unsigned int i;
18250 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
18251 Elf32_Sym *sym;
18252 - uint32_t *location;
18253 + uint32_t *plocation, location;
18254
18255 DEBUGP("Applying relocate section %u to %u\n", relsec,
18256 sechdrs[relsec].sh_info);
18257 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
18258 /* This is where to make the change */
18259 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
18260 - + rel[i].r_offset;
18261 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
18262 + location = (uint32_t)plocation;
18263 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
18264 + plocation = ktla_ktva((void *)plocation);
18265 /* This is the symbol it is referring to. Note that all
18266 undefined symbols have been resolved. */
18267 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
18268 @@ -71,11 +118,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
18269 switch (ELF32_R_TYPE(rel[i].r_info)) {
18270 case R_386_32:
18271 /* We add the value into the location given */
18272 - *location += sym->st_value;
18273 + pax_open_kernel();
18274 + *plocation += sym->st_value;
18275 + pax_close_kernel();
18276 break;
18277 case R_386_PC32:
18278 /* Add the value, subtract its postition */
18279 - *location += sym->st_value - (uint32_t)location;
18280 + pax_open_kernel();
18281 + *plocation += sym->st_value - location;
18282 + pax_close_kernel();
18283 break;
18284 default:
18285 printk(KERN_ERR "module %s: Unknown relocation: %u\n",
18286 @@ -120,21 +171,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
18287 case R_X86_64_NONE:
18288 break;
18289 case R_X86_64_64:
18290 + pax_open_kernel();
18291 *(u64 *)loc = val;
18292 + pax_close_kernel();
18293 break;
18294 case R_X86_64_32:
18295 + pax_open_kernel();
18296 *(u32 *)loc = val;
18297 + pax_close_kernel();
18298 if (val != *(u32 *)loc)
18299 goto overflow;
18300 break;
18301 case R_X86_64_32S:
18302 + pax_open_kernel();
18303 *(s32 *)loc = val;
18304 + pax_close_kernel();
18305 if ((s64)val != *(s32 *)loc)
18306 goto overflow;
18307 break;
18308 case R_X86_64_PC32:
18309 val -= (u64)loc;
18310 + pax_open_kernel();
18311 *(u32 *)loc = val;
18312 + pax_close_kernel();
18313 +
18314 #if 0
18315 if ((s64)val != *(s32 *)loc)
18316 goto overflow;
18317 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
18318 index 47acaf3..ec48ab6 100644
18319 --- a/arch/x86/kernel/nmi.c
18320 +++ b/arch/x86/kernel/nmi.c
18321 @@ -505,6 +505,17 @@ static inline void nmi_nesting_postprocess(void)
18322 dotraplinkage notrace __kprobes void
18323 do_nmi(struct pt_regs *regs, long error_code)
18324 {
18325 +
18326 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18327 + if (!user_mode(regs)) {
18328 + unsigned long cs = regs->cs & 0xFFFF;
18329 + unsigned long ip = ktva_ktla(regs->ip);
18330 +
18331 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
18332 + regs->ip = ip;
18333 + }
18334 +#endif
18335 +
18336 nmi_nesting_preprocess(regs);
18337
18338 nmi_enter();
18339 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
18340 index 676b8c7..870ba04 100644
18341 --- a/arch/x86/kernel/paravirt-spinlocks.c
18342 +++ b/arch/x86/kernel/paravirt-spinlocks.c
18343 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
18344 arch_spin_lock(lock);
18345 }
18346
18347 -struct pv_lock_ops pv_lock_ops = {
18348 +struct pv_lock_ops pv_lock_ops __read_only = {
18349 #ifdef CONFIG_SMP
18350 .spin_is_locked = __ticket_spin_is_locked,
18351 .spin_is_contended = __ticket_spin_is_contended,
18352 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
18353 index d90272e..6bb013b 100644
18354 --- a/arch/x86/kernel/paravirt.c
18355 +++ b/arch/x86/kernel/paravirt.c
18356 @@ -53,6 +53,9 @@ u64 _paravirt_ident_64(u64 x)
18357 {
18358 return x;
18359 }
18360 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
18361 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
18362 +#endif
18363
18364 void __init default_banner(void)
18365 {
18366 @@ -145,15 +148,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
18367 if (opfunc == NULL)
18368 /* If there's no function, patch it with a ud2a (BUG) */
18369 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
18370 - else if (opfunc == _paravirt_nop)
18371 + else if (opfunc == (void *)_paravirt_nop)
18372 /* If the operation is a nop, then nop the callsite */
18373 ret = paravirt_patch_nop();
18374
18375 /* identity functions just return their single argument */
18376 - else if (opfunc == _paravirt_ident_32)
18377 + else if (opfunc == (void *)_paravirt_ident_32)
18378 ret = paravirt_patch_ident_32(insnbuf, len);
18379 - else if (opfunc == _paravirt_ident_64)
18380 + else if (opfunc == (void *)_paravirt_ident_64)
18381 ret = paravirt_patch_ident_64(insnbuf, len);
18382 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
18383 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
18384 + ret = paravirt_patch_ident_64(insnbuf, len);
18385 +#endif
18386
18387 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
18388 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
18389 @@ -178,7 +185,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
18390 if (insn_len > len || start == NULL)
18391 insn_len = len;
18392 else
18393 - memcpy(insnbuf, start, insn_len);
18394 + memcpy(insnbuf, ktla_ktva(start), insn_len);
18395
18396 return insn_len;
18397 }
18398 @@ -302,7 +309,7 @@ void arch_flush_lazy_mmu_mode(void)
18399 preempt_enable();
18400 }
18401
18402 -struct pv_info pv_info = {
18403 +struct pv_info pv_info __read_only = {
18404 .name = "bare hardware",
18405 .paravirt_enabled = 0,
18406 .kernel_rpl = 0,
18407 @@ -313,16 +320,16 @@ struct pv_info pv_info = {
18408 #endif
18409 };
18410
18411 -struct pv_init_ops pv_init_ops = {
18412 +struct pv_init_ops pv_init_ops __read_only = {
18413 .patch = native_patch,
18414 };
18415
18416 -struct pv_time_ops pv_time_ops = {
18417 +struct pv_time_ops pv_time_ops __read_only = {
18418 .sched_clock = native_sched_clock,
18419 .steal_clock = native_steal_clock,
18420 };
18421
18422 -struct pv_irq_ops pv_irq_ops = {
18423 +struct pv_irq_ops pv_irq_ops __read_only = {
18424 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
18425 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
18426 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
18427 @@ -334,7 +341,7 @@ struct pv_irq_ops pv_irq_ops = {
18428 #endif
18429 };
18430
18431 -struct pv_cpu_ops pv_cpu_ops = {
18432 +struct pv_cpu_ops pv_cpu_ops __read_only = {
18433 .cpuid = native_cpuid,
18434 .get_debugreg = native_get_debugreg,
18435 .set_debugreg = native_set_debugreg,
18436 @@ -395,21 +402,26 @@ struct pv_cpu_ops pv_cpu_ops = {
18437 .end_context_switch = paravirt_nop,
18438 };
18439
18440 -struct pv_apic_ops pv_apic_ops = {
18441 +struct pv_apic_ops pv_apic_ops __read_only = {
18442 #ifdef CONFIG_X86_LOCAL_APIC
18443 .startup_ipi_hook = paravirt_nop,
18444 #endif
18445 };
18446
18447 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
18448 +#ifdef CONFIG_X86_32
18449 +#ifdef CONFIG_X86_PAE
18450 +/* 64-bit pagetable entries */
18451 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
18452 +#else
18453 /* 32-bit pagetable entries */
18454 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
18455 +#endif
18456 #else
18457 /* 64-bit pagetable entries */
18458 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
18459 #endif
18460
18461 -struct pv_mmu_ops pv_mmu_ops = {
18462 +struct pv_mmu_ops pv_mmu_ops __read_only = {
18463
18464 .read_cr2 = native_read_cr2,
18465 .write_cr2 = native_write_cr2,
18466 @@ -459,6 +471,7 @@ struct pv_mmu_ops pv_mmu_ops = {
18467 .make_pud = PTE_IDENT,
18468
18469 .set_pgd = native_set_pgd,
18470 + .set_pgd_batched = native_set_pgd_batched,
18471 #endif
18472 #endif /* PAGETABLE_LEVELS >= 3 */
18473
18474 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
18475 },
18476
18477 .set_fixmap = native_set_fixmap,
18478 +
18479 +#ifdef CONFIG_PAX_KERNEXEC
18480 + .pax_open_kernel = native_pax_open_kernel,
18481 + .pax_close_kernel = native_pax_close_kernel,
18482 +#endif
18483 +
18484 };
18485
18486 EXPORT_SYMBOL_GPL(pv_time_ops);
18487 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
18488 index 35ccf75..7a15747 100644
18489 --- a/arch/x86/kernel/pci-iommu_table.c
18490 +++ b/arch/x86/kernel/pci-iommu_table.c
18491 @@ -2,7 +2,7 @@
18492 #include <asm/iommu_table.h>
18493 #include <linux/string.h>
18494 #include <linux/kallsyms.h>
18495 -
18496 +#include <linux/sched.h>
18497
18498 #define DEBUG 1
18499
18500 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
18501 index 15763af..da59ada 100644
18502 --- a/arch/x86/kernel/process.c
18503 +++ b/arch/x86/kernel/process.c
18504 @@ -48,16 +48,33 @@ void free_thread_xstate(struct task_struct *tsk)
18505
18506 void free_thread_info(struct thread_info *ti)
18507 {
18508 - free_thread_xstate(ti->task);
18509 free_pages((unsigned long)ti, THREAD_ORDER);
18510 }
18511
18512 +static struct kmem_cache *task_struct_cachep;
18513 +
18514 void arch_task_cache_init(void)
18515 {
18516 - task_xstate_cachep =
18517 - kmem_cache_create("task_xstate", xstate_size,
18518 + /* create a slab on which task_structs can be allocated */
18519 + task_struct_cachep =
18520 + kmem_cache_create("task_struct", sizeof(struct task_struct),
18521 + ARCH_MIN_TASKALIGN, SLAB_PANIC | SLAB_NOTRACK, NULL);
18522 +
18523 + task_xstate_cachep =
18524 + kmem_cache_create("task_xstate", xstate_size,
18525 __alignof__(union thread_xstate),
18526 - SLAB_PANIC | SLAB_NOTRACK, NULL);
18527 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
18528 +}
18529 +
18530 +struct task_struct *alloc_task_struct_node(int node)
18531 +{
18532 + return kmem_cache_alloc_node(task_struct_cachep, GFP_KERNEL, node);
18533 +}
18534 +
18535 +void free_task_struct(struct task_struct *task)
18536 +{
18537 + free_thread_xstate(task);
18538 + kmem_cache_free(task_struct_cachep, task);
18539 }
18540
18541 /*
18542 @@ -70,7 +87,7 @@ void exit_thread(void)
18543 unsigned long *bp = t->io_bitmap_ptr;
18544
18545 if (bp) {
18546 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
18547 + struct tss_struct *tss = init_tss + get_cpu();
18548
18549 t->io_bitmap_ptr = NULL;
18550 clear_thread_flag(TIF_IO_BITMAP);
18551 @@ -106,7 +123,7 @@ void show_regs_common(void)
18552
18553 printk(KERN_CONT "\n");
18554 printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s",
18555 - current->pid, current->comm, print_tainted(),
18556 + task_pid_nr(current), current->comm, print_tainted(),
18557 init_utsname()->release,
18558 (int)strcspn(init_utsname()->version, " "),
18559 init_utsname()->version);
18560 @@ -120,6 +137,9 @@ void flush_thread(void)
18561 {
18562 struct task_struct *tsk = current;
18563
18564 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
18565 + loadsegment(gs, 0);
18566 +#endif
18567 flush_ptrace_hw_breakpoint(tsk);
18568 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
18569 /*
18570 @@ -282,10 +302,10 @@ int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
18571 regs.di = (unsigned long) arg;
18572
18573 #ifdef CONFIG_X86_32
18574 - regs.ds = __USER_DS;
18575 - regs.es = __USER_DS;
18576 + regs.ds = __KERNEL_DS;
18577 + regs.es = __KERNEL_DS;
18578 regs.fs = __KERNEL_PERCPU;
18579 - regs.gs = __KERNEL_STACK_CANARY;
18580 + savesegment(gs, regs.gs);
18581 #else
18582 regs.ss = __KERNEL_DS;
18583 #endif
18584 @@ -411,7 +431,7 @@ bool set_pm_idle_to_default(void)
18585
18586 return ret;
18587 }
18588 -void stop_this_cpu(void *dummy)
18589 +__noreturn void stop_this_cpu(void *dummy)
18590 {
18591 local_irq_disable();
18592 /*
18593 @@ -653,16 +673,37 @@ static int __init idle_setup(char *str)
18594 }
18595 early_param("idle", idle_setup);
18596
18597 -unsigned long arch_align_stack(unsigned long sp)
18598 +#ifdef CONFIG_PAX_RANDKSTACK
18599 +void pax_randomize_kstack(struct pt_regs *regs)
18600 {
18601 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
18602 - sp -= get_random_int() % 8192;
18603 - return sp & ~0xf;
18604 -}
18605 + struct thread_struct *thread = &current->thread;
18606 + unsigned long time;
18607
18608 -unsigned long arch_randomize_brk(struct mm_struct *mm)
18609 -{
18610 - unsigned long range_end = mm->brk + 0x02000000;
18611 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
18612 -}
18613 + if (!randomize_va_space)
18614 + return;
18615 +
18616 + if (v8086_mode(regs))
18617 + return;
18618
18619 + rdtscl(time);
18620 +
18621 + /* P4 seems to return a 0 LSB, ignore it */
18622 +#ifdef CONFIG_MPENTIUM4
18623 + time &= 0x3EUL;
18624 + time <<= 2;
18625 +#elif defined(CONFIG_X86_64)
18626 + time &= 0xFUL;
18627 + time <<= 4;
18628 +#else
18629 + time &= 0x1FUL;
18630 + time <<= 3;
18631 +#endif
18632 +
18633 + thread->sp0 ^= time;
18634 + load_sp0(init_tss + smp_processor_id(), thread);
18635 +
18636 +#ifdef CONFIG_X86_64
18637 + percpu_write(kernel_stack, thread->sp0);
18638 +#endif
18639 +}
18640 +#endif
18641 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
18642 index c08d1ff..6ae1c81 100644
18643 --- a/arch/x86/kernel/process_32.c
18644 +++ b/arch/x86/kernel/process_32.c
18645 @@ -67,6 +67,7 @@ asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
18646 unsigned long thread_saved_pc(struct task_struct *tsk)
18647 {
18648 return ((unsigned long *)tsk->thread.sp)[3];
18649 +//XXX return tsk->thread.eip;
18650 }
18651
18652 #ifndef CONFIG_SMP
18653 @@ -132,15 +133,14 @@ void __show_regs(struct pt_regs *regs, int all)
18654 unsigned long sp;
18655 unsigned short ss, gs;
18656
18657 - if (user_mode_vm(regs)) {
18658 + if (user_mode(regs)) {
18659 sp = regs->sp;
18660 ss = regs->ss & 0xffff;
18661 - gs = get_user_gs(regs);
18662 } else {
18663 sp = kernel_stack_pointer(regs);
18664 savesegment(ss, ss);
18665 - savesegment(gs, gs);
18666 }
18667 + gs = get_user_gs(regs);
18668
18669 show_regs_common();
18670
18671 @@ -202,13 +202,14 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
18672 struct task_struct *tsk;
18673 int err;
18674
18675 - childregs = task_pt_regs(p);
18676 + childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
18677 *childregs = *regs;
18678 childregs->ax = 0;
18679 childregs->sp = sp;
18680
18681 p->thread.sp = (unsigned long) childregs;
18682 p->thread.sp0 = (unsigned long) (childregs+1);
18683 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
18684
18685 p->thread.ip = (unsigned long) ret_from_fork;
18686
18687 @@ -299,7 +300,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
18688 struct thread_struct *prev = &prev_p->thread,
18689 *next = &next_p->thread;
18690 int cpu = smp_processor_id();
18691 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
18692 + struct tss_struct *tss = init_tss + cpu;
18693 fpu_switch_t fpu;
18694
18695 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
18696 @@ -323,6 +324,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
18697 */
18698 lazy_save_gs(prev->gs);
18699
18700 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18701 + __set_fs(task_thread_info(next_p)->addr_limit);
18702 +#endif
18703 +
18704 /*
18705 * Load the per-thread Thread-Local Storage descriptor.
18706 */
18707 @@ -353,6 +358,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
18708 */
18709 arch_end_context_switch(next_p);
18710
18711 + percpu_write(current_task, next_p);
18712 + percpu_write(current_tinfo, &next_p->tinfo);
18713 +
18714 /*
18715 * Restore %gs if needed (which is common)
18716 */
18717 @@ -361,8 +369,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
18718
18719 switch_fpu_finish(next_p, fpu);
18720
18721 - percpu_write(current_task, next_p);
18722 -
18723 return prev_p;
18724 }
18725
18726 @@ -392,4 +398,3 @@ unsigned long get_wchan(struct task_struct *p)
18727 } while (count++ < 16);
18728 return 0;
18729 }
18730 -
18731 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
18732 index cfa5c90..4facd28 100644
18733 --- a/arch/x86/kernel/process_64.c
18734 +++ b/arch/x86/kernel/process_64.c
18735 @@ -89,7 +89,7 @@ static void __exit_idle(void)
18736 void exit_idle(void)
18737 {
18738 /* idle loop has pid 0 */
18739 - if (current->pid)
18740 + if (task_pid_nr(current))
18741 return;
18742 __exit_idle();
18743 }
18744 @@ -270,8 +270,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
18745 struct pt_regs *childregs;
18746 struct task_struct *me = current;
18747
18748 - childregs = ((struct pt_regs *)
18749 - (THREAD_SIZE + task_stack_page(p))) - 1;
18750 + childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 16;
18751 *childregs = *regs;
18752
18753 childregs->ax = 0;
18754 @@ -283,6 +282,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
18755 p->thread.sp = (unsigned long) childregs;
18756 p->thread.sp0 = (unsigned long) (childregs+1);
18757 p->thread.usersp = me->thread.usersp;
18758 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
18759
18760 set_tsk_thread_flag(p, TIF_FORK);
18761
18762 @@ -385,7 +385,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
18763 struct thread_struct *prev = &prev_p->thread;
18764 struct thread_struct *next = &next_p->thread;
18765 int cpu = smp_processor_id();
18766 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
18767 + struct tss_struct *tss = init_tss + cpu;
18768 unsigned fsindex, gsindex;
18769 fpu_switch_t fpu;
18770
18771 @@ -467,10 +467,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
18772 prev->usersp = percpu_read(old_rsp);
18773 percpu_write(old_rsp, next->usersp);
18774 percpu_write(current_task, next_p);
18775 + percpu_write(current_tinfo, &next_p->tinfo);
18776
18777 - percpu_write(kernel_stack,
18778 - (unsigned long)task_stack_page(next_p) +
18779 - THREAD_SIZE - KERNEL_STACK_OFFSET);
18780 + percpu_write(kernel_stack, next->sp0);
18781
18782 /*
18783 * Now maybe reload the debug registers and handle I/O bitmaps
18784 @@ -525,12 +524,11 @@ unsigned long get_wchan(struct task_struct *p)
18785 if (!p || p == current || p->state == TASK_RUNNING)
18786 return 0;
18787 stack = (unsigned long)task_stack_page(p);
18788 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
18789 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
18790 return 0;
18791 fp = *(u64 *)(p->thread.sp);
18792 do {
18793 - if (fp < (unsigned long)stack ||
18794 - fp >= (unsigned long)stack+THREAD_SIZE)
18795 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
18796 return 0;
18797 ip = *(u64 *)(fp+8);
18798 if (!in_sched_functions(ip))
18799 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
18800 index 5026738..c5925c0 100644
18801 --- a/arch/x86/kernel/ptrace.c
18802 +++ b/arch/x86/kernel/ptrace.c
18803 @@ -823,7 +823,7 @@ long arch_ptrace(struct task_struct *child, long request,
18804 unsigned long addr, unsigned long data)
18805 {
18806 int ret;
18807 - unsigned long __user *datap = (unsigned long __user *)data;
18808 + unsigned long __user *datap = (__force unsigned long __user *)data;
18809
18810 switch (request) {
18811 /* read the word at location addr in the USER area. */
18812 @@ -908,14 +908,14 @@ long arch_ptrace(struct task_struct *child, long request,
18813 if ((int) addr < 0)
18814 return -EIO;
18815 ret = do_get_thread_area(child, addr,
18816 - (struct user_desc __user *)data);
18817 + (__force struct user_desc __user *) data);
18818 break;
18819
18820 case PTRACE_SET_THREAD_AREA:
18821 if ((int) addr < 0)
18822 return -EIO;
18823 ret = do_set_thread_area(child, addr,
18824 - (struct user_desc __user *)data, 0);
18825 + (__force struct user_desc __user *) data, 0);
18826 break;
18827 #endif
18828
18829 @@ -1332,7 +1332,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
18830 memset(info, 0, sizeof(*info));
18831 info->si_signo = SIGTRAP;
18832 info->si_code = si_code;
18833 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
18834 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
18835 }
18836
18837 void user_single_step_siginfo(struct task_struct *tsk,
18838 @@ -1361,6 +1361,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
18839 # define IS_IA32 0
18840 #endif
18841
18842 +#ifdef CONFIG_GRKERNSEC_SETXID
18843 +extern void gr_delayed_cred_worker(void);
18844 +#endif
18845 +
18846 /*
18847 * We must return the syscall number to actually look up in the table.
18848 * This can be -1L to skip running any syscall at all.
18849 @@ -1369,6 +1373,11 @@ long syscall_trace_enter(struct pt_regs *regs)
18850 {
18851 long ret = 0;
18852
18853 +#ifdef CONFIG_GRKERNSEC_SETXID
18854 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
18855 + gr_delayed_cred_worker();
18856 +#endif
18857 +
18858 /*
18859 * If we stepped into a sysenter/syscall insn, it trapped in
18860 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
18861 @@ -1412,6 +1421,11 @@ void syscall_trace_leave(struct pt_regs *regs)
18862 {
18863 bool step;
18864
18865 +#ifdef CONFIG_GRKERNSEC_SETXID
18866 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
18867 + gr_delayed_cred_worker();
18868 +#endif
18869 +
18870 audit_syscall_exit(regs);
18871
18872 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
18873 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
18874 index 42eb330..139955c 100644
18875 --- a/arch/x86/kernel/pvclock.c
18876 +++ b/arch/x86/kernel/pvclock.c
18877 @@ -81,11 +81,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
18878 return pv_tsc_khz;
18879 }
18880
18881 -static atomic64_t last_value = ATOMIC64_INIT(0);
18882 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
18883
18884 void pvclock_resume(void)
18885 {
18886 - atomic64_set(&last_value, 0);
18887 + atomic64_set_unchecked(&last_value, 0);
18888 }
18889
18890 cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
18891 @@ -121,11 +121,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
18892 * updating at the same time, and one of them could be slightly behind,
18893 * making the assumption that last_value always go forward fail to hold.
18894 */
18895 - last = atomic64_read(&last_value);
18896 + last = atomic64_read_unchecked(&last_value);
18897 do {
18898 if (ret < last)
18899 return last;
18900 - last = atomic64_cmpxchg(&last_value, last, ret);
18901 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
18902 } while (unlikely(last != ret));
18903
18904 return ret;
18905 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
18906 index d840e69..98e9581 100644
18907 --- a/arch/x86/kernel/reboot.c
18908 +++ b/arch/x86/kernel/reboot.c
18909 @@ -35,7 +35,7 @@ void (*pm_power_off)(void);
18910 EXPORT_SYMBOL(pm_power_off);
18911
18912 static const struct desc_ptr no_idt = {};
18913 -static int reboot_mode;
18914 +static unsigned short reboot_mode;
18915 enum reboot_type reboot_type = BOOT_ACPI;
18916 int reboot_force;
18917
18918 @@ -335,13 +335,17 @@ core_initcall(reboot_init);
18919 extern const unsigned char machine_real_restart_asm[];
18920 extern const u64 machine_real_restart_gdt[3];
18921
18922 -void machine_real_restart(unsigned int type)
18923 +__noreturn void machine_real_restart(unsigned int type)
18924 {
18925 void *restart_va;
18926 unsigned long restart_pa;
18927 - void (*restart_lowmem)(unsigned int);
18928 + void (* __noreturn restart_lowmem)(unsigned int);
18929 u64 *lowmem_gdt;
18930
18931 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
18932 + struct desc_struct *gdt;
18933 +#endif
18934 +
18935 local_irq_disable();
18936
18937 /* Write zero to CMOS register number 0x0f, which the BIOS POST
18938 @@ -367,14 +371,14 @@ void machine_real_restart(unsigned int type)
18939 boot)". This seems like a fairly standard thing that gets set by
18940 REBOOT.COM programs, and the previous reset routine did this
18941 too. */
18942 - *((unsigned short *)0x472) = reboot_mode;
18943 + *(unsigned short *)(__va(0x472)) = reboot_mode;
18944
18945 /* Patch the GDT in the low memory trampoline */
18946 lowmem_gdt = TRAMPOLINE_SYM(machine_real_restart_gdt);
18947
18948 restart_va = TRAMPOLINE_SYM(machine_real_restart_asm);
18949 restart_pa = virt_to_phys(restart_va);
18950 - restart_lowmem = (void (*)(unsigned int))restart_pa;
18951 + restart_lowmem = (void *)restart_pa;
18952
18953 /* GDT[0]: GDT self-pointer */
18954 lowmem_gdt[0] =
18955 @@ -385,7 +389,33 @@ void machine_real_restart(unsigned int type)
18956 GDT_ENTRY(0x009b, restart_pa, 0xffff);
18957
18958 /* Jump to the identity-mapped low memory code */
18959 +
18960 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
18961 + gdt = get_cpu_gdt_table(smp_processor_id());
18962 + pax_open_kernel();
18963 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18964 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
18965 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
18966 + asm("mov %0, %%ds; mov %0, %%es; mov %0, %%ss" : : "r" (__KERNEL_DS) : "memory");
18967 +#endif
18968 +#ifdef CONFIG_PAX_KERNEXEC
18969 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
18970 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
18971 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
18972 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
18973 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
18974 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
18975 +#endif
18976 + pax_close_kernel();
18977 +#endif
18978 +
18979 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18980 + asm volatile("push %0; push %1; lret\n" : : "i" (__KERNEL_CS), "rm" (restart_lowmem), "a" (type));
18981 + unreachable();
18982 +#else
18983 restart_lowmem(type);
18984 +#endif
18985 +
18986 }
18987 #ifdef CONFIG_APM_MODULE
18988 EXPORT_SYMBOL(machine_real_restart);
18989 @@ -556,7 +586,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
18990 * try to force a triple fault and then cycle between hitting the keyboard
18991 * controller and doing that
18992 */
18993 -static void native_machine_emergency_restart(void)
18994 +__noreturn static void native_machine_emergency_restart(void)
18995 {
18996 int i;
18997 int attempt = 0;
18998 @@ -680,13 +710,13 @@ void native_machine_shutdown(void)
18999 #endif
19000 }
19001
19002 -static void __machine_emergency_restart(int emergency)
19003 +static __noreturn void __machine_emergency_restart(int emergency)
19004 {
19005 reboot_emergency = emergency;
19006 machine_ops.emergency_restart();
19007 }
19008
19009 -static void native_machine_restart(char *__unused)
19010 +static __noreturn void native_machine_restart(char *__unused)
19011 {
19012 printk("machine restart\n");
19013
19014 @@ -695,7 +725,7 @@ static void native_machine_restart(char *__unused)
19015 __machine_emergency_restart(0);
19016 }
19017
19018 -static void native_machine_halt(void)
19019 +static __noreturn void native_machine_halt(void)
19020 {
19021 /* stop other cpus and apics */
19022 machine_shutdown();
19023 @@ -706,7 +736,7 @@ static void native_machine_halt(void)
19024 stop_this_cpu(NULL);
19025 }
19026
19027 -static void native_machine_power_off(void)
19028 +__noreturn static void native_machine_power_off(void)
19029 {
19030 if (pm_power_off) {
19031 if (!reboot_force)
19032 @@ -715,6 +745,7 @@ static void native_machine_power_off(void)
19033 }
19034 /* a fallback in case there is no PM info available */
19035 tboot_shutdown(TB_SHUTDOWN_HALT);
19036 + unreachable();
19037 }
19038
19039 struct machine_ops machine_ops = {
19040 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
19041 index 7a6f3b3..bed145d7 100644
19042 --- a/arch/x86/kernel/relocate_kernel_64.S
19043 +++ b/arch/x86/kernel/relocate_kernel_64.S
19044 @@ -11,6 +11,7 @@
19045 #include <asm/kexec.h>
19046 #include <asm/processor-flags.h>
19047 #include <asm/pgtable_types.h>
19048 +#include <asm/alternative-asm.h>
19049
19050 /*
19051 * Must be relocatable PIC code callable as a C function
19052 @@ -160,13 +161,14 @@ identity_mapped:
19053 xorq %rbp, %rbp
19054 xorq %r8, %r8
19055 xorq %r9, %r9
19056 - xorq %r10, %r9
19057 + xorq %r10, %r10
19058 xorq %r11, %r11
19059 xorq %r12, %r12
19060 xorq %r13, %r13
19061 xorq %r14, %r14
19062 xorq %r15, %r15
19063
19064 + pax_force_retaddr 0, 1
19065 ret
19066
19067 1:
19068 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
19069 index d7d5099..28555d0 100644
19070 --- a/arch/x86/kernel/setup.c
19071 +++ b/arch/x86/kernel/setup.c
19072 @@ -448,7 +448,7 @@ static void __init parse_setup_data(void)
19073
19074 switch (data->type) {
19075 case SETUP_E820_EXT:
19076 - parse_e820_ext(data);
19077 + parse_e820_ext((struct setup_data __force_kernel *)data);
19078 break;
19079 case SETUP_DTB:
19080 add_dtb(pa_data);
19081 @@ -649,7 +649,7 @@ static void __init trim_bios_range(void)
19082 * area (640->1Mb) as ram even though it is not.
19083 * take them out.
19084 */
19085 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
19086 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
19087 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
19088 }
19089
19090 @@ -767,14 +767,14 @@ void __init setup_arch(char **cmdline_p)
19091
19092 if (!boot_params.hdr.root_flags)
19093 root_mountflags &= ~MS_RDONLY;
19094 - init_mm.start_code = (unsigned long) _text;
19095 - init_mm.end_code = (unsigned long) _etext;
19096 + init_mm.start_code = ktla_ktva((unsigned long) _text);
19097 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
19098 init_mm.end_data = (unsigned long) _edata;
19099 init_mm.brk = _brk_end;
19100
19101 - code_resource.start = virt_to_phys(_text);
19102 - code_resource.end = virt_to_phys(_etext)-1;
19103 - data_resource.start = virt_to_phys(_etext);
19104 + code_resource.start = virt_to_phys(ktla_ktva(_text));
19105 + code_resource.end = virt_to_phys(ktla_ktva(_etext))-1;
19106 + data_resource.start = virt_to_phys(_sdata);
19107 data_resource.end = virt_to_phys(_edata)-1;
19108 bss_resource.start = virt_to_phys(&__bss_start);
19109 bss_resource.end = virt_to_phys(&__bss_stop)-1;
19110 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
19111 index 5a98aa2..2f9288d 100644
19112 --- a/arch/x86/kernel/setup_percpu.c
19113 +++ b/arch/x86/kernel/setup_percpu.c
19114 @@ -21,19 +21,17 @@
19115 #include <asm/cpu.h>
19116 #include <asm/stackprotector.h>
19117
19118 -DEFINE_PER_CPU(int, cpu_number);
19119 +#ifdef CONFIG_SMP
19120 +DEFINE_PER_CPU(unsigned int, cpu_number);
19121 EXPORT_PER_CPU_SYMBOL(cpu_number);
19122 +#endif
19123
19124 -#ifdef CONFIG_X86_64
19125 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
19126 -#else
19127 -#define BOOT_PERCPU_OFFSET 0
19128 -#endif
19129
19130 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
19131 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
19132
19133 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
19134 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
19135 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
19136 };
19137 EXPORT_SYMBOL(__per_cpu_offset);
19138 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
19139 {
19140 #ifdef CONFIG_X86_32
19141 struct desc_struct gdt;
19142 + unsigned long base = per_cpu_offset(cpu);
19143
19144 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
19145 - 0x2 | DESCTYPE_S, 0x8);
19146 - gdt.s = 1;
19147 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
19148 + 0x83 | DESCTYPE_S, 0xC);
19149 write_gdt_entry(get_cpu_gdt_table(cpu),
19150 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
19151 #endif
19152 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
19153 /* alrighty, percpu areas up and running */
19154 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
19155 for_each_possible_cpu(cpu) {
19156 +#ifdef CONFIG_CC_STACKPROTECTOR
19157 +#ifdef CONFIG_X86_32
19158 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
19159 +#endif
19160 +#endif
19161 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
19162 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
19163 per_cpu(cpu_number, cpu) = cpu;
19164 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
19165 */
19166 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
19167 #endif
19168 +#ifdef CONFIG_CC_STACKPROTECTOR
19169 +#ifdef CONFIG_X86_32
19170 + if (!cpu)
19171 + per_cpu(stack_canary.canary, cpu) = canary;
19172 +#endif
19173 +#endif
19174 /*
19175 * Up to this point, the boot CPU has been using .init.data
19176 * area. Reload any changed state for the boot CPU.
19177 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
19178 index 46a01bd..2e88e6d 100644
19179 --- a/arch/x86/kernel/signal.c
19180 +++ b/arch/x86/kernel/signal.c
19181 @@ -198,7 +198,7 @@ static unsigned long align_sigframe(unsigned long sp)
19182 * Align the stack pointer according to the i386 ABI,
19183 * i.e. so that on function entry ((sp + 4) & 15) == 0.
19184 */
19185 - sp = ((sp + 4) & -16ul) - 4;
19186 + sp = ((sp - 12) & -16ul) - 4;
19187 #else /* !CONFIG_X86_32 */
19188 sp = round_down(sp, 16) - 8;
19189 #endif
19190 @@ -249,11 +249,11 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size,
19191 * Return an always-bogus address instead so we will die with SIGSEGV.
19192 */
19193 if (onsigstack && !likely(on_sig_stack(sp)))
19194 - return (void __user *)-1L;
19195 + return (__force void __user *)-1L;
19196
19197 /* save i387 state */
19198 if (used_math() && save_i387_xstate(*fpstate) < 0)
19199 - return (void __user *)-1L;
19200 + return (__force void __user *)-1L;
19201
19202 return (void __user *)sp;
19203 }
19204 @@ -308,9 +308,9 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
19205 }
19206
19207 if (current->mm->context.vdso)
19208 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
19209 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
19210 else
19211 - restorer = &frame->retcode;
19212 + restorer = (void __user *)&frame->retcode;
19213 if (ka->sa.sa_flags & SA_RESTORER)
19214 restorer = ka->sa.sa_restorer;
19215
19216 @@ -324,7 +324,7 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
19217 * reasons and because gdb uses it as a signature to notice
19218 * signal handler stack frames.
19219 */
19220 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
19221 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
19222
19223 if (err)
19224 return -EFAULT;
19225 @@ -378,7 +378,10 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
19226 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
19227
19228 /* Set up to return from userspace. */
19229 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
19230 + if (current->mm->context.vdso)
19231 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
19232 + else
19233 + restorer = (void __user *)&frame->retcode;
19234 if (ka->sa.sa_flags & SA_RESTORER)
19235 restorer = ka->sa.sa_restorer;
19236 put_user_ex(restorer, &frame->pretcode);
19237 @@ -390,7 +393,7 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
19238 * reasons and because gdb uses it as a signature to notice
19239 * signal handler stack frames.
19240 */
19241 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
19242 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
19243 } put_user_catch(err);
19244
19245 if (err)
19246 @@ -765,7 +768,7 @@ static void do_signal(struct pt_regs *regs)
19247 * X86_32: vm86 regs switched out by assembly code before reaching
19248 * here, so testing against kernel CS suffices.
19249 */
19250 - if (!user_mode(regs))
19251 + if (!user_mode_novm(regs))
19252 return;
19253
19254 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
19255 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
19256 index 66d250c..f1b10bd 100644
19257 --- a/arch/x86/kernel/smpboot.c
19258 +++ b/arch/x86/kernel/smpboot.c
19259 @@ -715,17 +715,20 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu)
19260 set_idle_for_cpu(cpu, c_idle.idle);
19261 do_rest:
19262 per_cpu(current_task, cpu) = c_idle.idle;
19263 + per_cpu(current_tinfo, cpu) = &c_idle.idle->tinfo;
19264 #ifdef CONFIG_X86_32
19265 /* Stack for startup_32 can be just as for start_secondary onwards */
19266 irq_ctx_init(cpu);
19267 #else
19268 clear_tsk_thread_flag(c_idle.idle, TIF_FORK);
19269 initial_gs = per_cpu_offset(cpu);
19270 - per_cpu(kernel_stack, cpu) =
19271 - (unsigned long)task_stack_page(c_idle.idle) -
19272 - KERNEL_STACK_OFFSET + THREAD_SIZE;
19273 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(c_idle.idle) - 16 + THREAD_SIZE;
19274 #endif
19275 +
19276 + pax_open_kernel();
19277 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
19278 + pax_close_kernel();
19279 +
19280 initial_code = (unsigned long)start_secondary;
19281 stack_start = c_idle.idle->thread.sp;
19282
19283 @@ -868,6 +871,12 @@ int __cpuinit native_cpu_up(unsigned int cpu)
19284
19285 per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
19286
19287 +#ifdef CONFIG_PAX_PER_CPU_PGD
19288 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
19289 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
19290 + KERNEL_PGD_PTRS);
19291 +#endif
19292 +
19293 err = do_boot_cpu(apicid, cpu);
19294 if (err) {
19295 pr_debug("do_boot_cpu failed %d\n", err);
19296 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
19297 index c346d11..d43b163 100644
19298 --- a/arch/x86/kernel/step.c
19299 +++ b/arch/x86/kernel/step.c
19300 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
19301 struct desc_struct *desc;
19302 unsigned long base;
19303
19304 - seg &= ~7UL;
19305 + seg >>= 3;
19306
19307 mutex_lock(&child->mm->context.lock);
19308 - if (unlikely((seg >> 3) >= child->mm->context.size))
19309 + if (unlikely(seg >= child->mm->context.size))
19310 addr = -1L; /* bogus selector, access would fault */
19311 else {
19312 desc = child->mm->context.ldt + seg;
19313 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
19314 addr += base;
19315 }
19316 mutex_unlock(&child->mm->context.lock);
19317 - }
19318 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
19319 + addr = ktla_ktva(addr);
19320
19321 return addr;
19322 }
19323 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
19324 unsigned char opcode[15];
19325 unsigned long addr = convert_ip_to_linear(child, regs);
19326
19327 + if (addr == -EINVAL)
19328 + return 0;
19329 +
19330 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
19331 for (i = 0; i < copied; i++) {
19332 switch (opcode[i]) {
19333 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
19334 index 0b0cb5f..db6b9ed 100644
19335 --- a/arch/x86/kernel/sys_i386_32.c
19336 +++ b/arch/x86/kernel/sys_i386_32.c
19337 @@ -24,17 +24,224 @@
19338
19339 #include <asm/syscalls.h>
19340
19341 -/*
19342 - * Do a system call from kernel instead of calling sys_execve so we
19343 - * end up with proper pt_regs.
19344 - */
19345 -int kernel_execve(const char *filename,
19346 - const char *const argv[],
19347 - const char *const envp[])
19348 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
19349 {
19350 - long __res;
19351 - asm volatile ("int $0x80"
19352 - : "=a" (__res)
19353 - : "0" (__NR_execve), "b" (filename), "c" (argv), "d" (envp) : "memory");
19354 - return __res;
19355 + unsigned long pax_task_size = TASK_SIZE;
19356 +
19357 +#ifdef CONFIG_PAX_SEGMEXEC
19358 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
19359 + pax_task_size = SEGMEXEC_TASK_SIZE;
19360 +#endif
19361 +
19362 + if (len > pax_task_size || addr > pax_task_size - len)
19363 + return -EINVAL;
19364 +
19365 + return 0;
19366 +}
19367 +
19368 +unsigned long
19369 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
19370 + unsigned long len, unsigned long pgoff, unsigned long flags)
19371 +{
19372 + struct mm_struct *mm = current->mm;
19373 + struct vm_area_struct *vma;
19374 + unsigned long start_addr, pax_task_size = TASK_SIZE;
19375 +
19376 +#ifdef CONFIG_PAX_SEGMEXEC
19377 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
19378 + pax_task_size = SEGMEXEC_TASK_SIZE;
19379 +#endif
19380 +
19381 + pax_task_size -= PAGE_SIZE;
19382 +
19383 + if (len > pax_task_size)
19384 + return -ENOMEM;
19385 +
19386 + if (flags & MAP_FIXED)
19387 + return addr;
19388 +
19389 +#ifdef CONFIG_PAX_RANDMMAP
19390 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
19391 +#endif
19392 +
19393 + if (addr) {
19394 + addr = PAGE_ALIGN(addr);
19395 + if (pax_task_size - len >= addr) {
19396 + vma = find_vma(mm, addr);
19397 + if (check_heap_stack_gap(vma, addr, len))
19398 + return addr;
19399 + }
19400 + }
19401 + if (len > mm->cached_hole_size) {
19402 + start_addr = addr = mm->free_area_cache;
19403 + } else {
19404 + start_addr = addr = mm->mmap_base;
19405 + mm->cached_hole_size = 0;
19406 + }
19407 +
19408 +#ifdef CONFIG_PAX_PAGEEXEC
19409 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE) && start_addr >= mm->mmap_base) {
19410 + start_addr = 0x00110000UL;
19411 +
19412 +#ifdef CONFIG_PAX_RANDMMAP
19413 + if (mm->pax_flags & MF_PAX_RANDMMAP)
19414 + start_addr += mm->delta_mmap & 0x03FFF000UL;
19415 +#endif
19416 +
19417 + if (mm->start_brk <= start_addr && start_addr < mm->mmap_base)
19418 + start_addr = addr = mm->mmap_base;
19419 + else
19420 + addr = start_addr;
19421 + }
19422 +#endif
19423 +
19424 +full_search:
19425 + for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
19426 + /* At this point: (!vma || addr < vma->vm_end). */
19427 + if (pax_task_size - len < addr) {
19428 + /*
19429 + * Start a new search - just in case we missed
19430 + * some holes.
19431 + */
19432 + if (start_addr != mm->mmap_base) {
19433 + start_addr = addr = mm->mmap_base;
19434 + mm->cached_hole_size = 0;
19435 + goto full_search;
19436 + }
19437 + return -ENOMEM;
19438 + }
19439 + if (check_heap_stack_gap(vma, addr, len))
19440 + break;
19441 + if (addr + mm->cached_hole_size < vma->vm_start)
19442 + mm->cached_hole_size = vma->vm_start - addr;
19443 + addr = vma->vm_end;
19444 + if (mm->start_brk <= addr && addr < mm->mmap_base) {
19445 + start_addr = addr = mm->mmap_base;
19446 + mm->cached_hole_size = 0;
19447 + goto full_search;
19448 + }
19449 + }
19450 +
19451 + /*
19452 + * Remember the place where we stopped the search:
19453 + */
19454 + mm->free_area_cache = addr + len;
19455 + return addr;
19456 +}
19457 +
19458 +unsigned long
19459 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
19460 + const unsigned long len, const unsigned long pgoff,
19461 + const unsigned long flags)
19462 +{
19463 + struct vm_area_struct *vma;
19464 + struct mm_struct *mm = current->mm;
19465 + unsigned long base = mm->mmap_base, addr = addr0, pax_task_size = TASK_SIZE;
19466 +
19467 +#ifdef CONFIG_PAX_SEGMEXEC
19468 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
19469 + pax_task_size = SEGMEXEC_TASK_SIZE;
19470 +#endif
19471 +
19472 + pax_task_size -= PAGE_SIZE;
19473 +
19474 + /* requested length too big for entire address space */
19475 + if (len > pax_task_size)
19476 + return -ENOMEM;
19477 +
19478 + if (flags & MAP_FIXED)
19479 + return addr;
19480 +
19481 +#ifdef CONFIG_PAX_PAGEEXEC
19482 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
19483 + goto bottomup;
19484 +#endif
19485 +
19486 +#ifdef CONFIG_PAX_RANDMMAP
19487 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
19488 +#endif
19489 +
19490 + /* requesting a specific address */
19491 + if (addr) {
19492 + addr = PAGE_ALIGN(addr);
19493 + if (pax_task_size - len >= addr) {
19494 + vma = find_vma(mm, addr);
19495 + if (check_heap_stack_gap(vma, addr, len))
19496 + return addr;
19497 + }
19498 + }
19499 +
19500 + /* check if free_area_cache is useful for us */
19501 + if (len <= mm->cached_hole_size) {
19502 + mm->cached_hole_size = 0;
19503 + mm->free_area_cache = mm->mmap_base;
19504 + }
19505 +
19506 + /* either no address requested or can't fit in requested address hole */
19507 + addr = mm->free_area_cache;
19508 +
19509 + /* make sure it can fit in the remaining address space */
19510 + if (addr > len) {
19511 + vma = find_vma(mm, addr-len);
19512 + if (check_heap_stack_gap(vma, addr - len, len))
19513 + /* remember the address as a hint for next time */
19514 + return (mm->free_area_cache = addr-len);
19515 + }
19516 +
19517 + if (mm->mmap_base < len)
19518 + goto bottomup;
19519 +
19520 + addr = mm->mmap_base-len;
19521 +
19522 + do {
19523 + /*
19524 + * Lookup failure means no vma is above this address,
19525 + * else if new region fits below vma->vm_start,
19526 + * return with success:
19527 + */
19528 + vma = find_vma(mm, addr);
19529 + if (check_heap_stack_gap(vma, addr, len))
19530 + /* remember the address as a hint for next time */
19531 + return (mm->free_area_cache = addr);
19532 +
19533 + /* remember the largest hole we saw so far */
19534 + if (addr + mm->cached_hole_size < vma->vm_start)
19535 + mm->cached_hole_size = vma->vm_start - addr;
19536 +
19537 + /* try just below the current vma->vm_start */
19538 + addr = skip_heap_stack_gap(vma, len);
19539 + } while (!IS_ERR_VALUE(addr));
19540 +
19541 +bottomup:
19542 + /*
19543 + * A failed mmap() very likely causes application failure,
19544 + * so fall back to the bottom-up function here. This scenario
19545 + * can happen with large stack limits and large mmap()
19546 + * allocations.
19547 + */
19548 +
19549 +#ifdef CONFIG_PAX_SEGMEXEC
19550 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
19551 + mm->mmap_base = SEGMEXEC_TASK_UNMAPPED_BASE;
19552 + else
19553 +#endif
19554 +
19555 + mm->mmap_base = TASK_UNMAPPED_BASE;
19556 +
19557 +#ifdef CONFIG_PAX_RANDMMAP
19558 + if (mm->pax_flags & MF_PAX_RANDMMAP)
19559 + mm->mmap_base += mm->delta_mmap;
19560 +#endif
19561 +
19562 + mm->free_area_cache = mm->mmap_base;
19563 + mm->cached_hole_size = ~0UL;
19564 + addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
19565 + /*
19566 + * Restore the topdown base:
19567 + */
19568 + mm->mmap_base = base;
19569 + mm->free_area_cache = base;
19570 + mm->cached_hole_size = ~0UL;
19571 +
19572 + return addr;
19573 }
19574 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
19575 index 0514890..3dbebce 100644
19576 --- a/arch/x86/kernel/sys_x86_64.c
19577 +++ b/arch/x86/kernel/sys_x86_64.c
19578 @@ -95,8 +95,8 @@ out:
19579 return error;
19580 }
19581
19582 -static void find_start_end(unsigned long flags, unsigned long *begin,
19583 - unsigned long *end)
19584 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
19585 + unsigned long *begin, unsigned long *end)
19586 {
19587 if (!test_thread_flag(TIF_IA32) && (flags & MAP_32BIT)) {
19588 unsigned long new_begin;
19589 @@ -115,7 +115,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
19590 *begin = new_begin;
19591 }
19592 } else {
19593 - *begin = TASK_UNMAPPED_BASE;
19594 + *begin = mm->mmap_base;
19595 *end = TASK_SIZE;
19596 }
19597 }
19598 @@ -132,16 +132,19 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
19599 if (flags & MAP_FIXED)
19600 return addr;
19601
19602 - find_start_end(flags, &begin, &end);
19603 + find_start_end(mm, flags, &begin, &end);
19604
19605 if (len > end)
19606 return -ENOMEM;
19607
19608 +#ifdef CONFIG_PAX_RANDMMAP
19609 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
19610 +#endif
19611 +
19612 if (addr) {
19613 addr = PAGE_ALIGN(addr);
19614 vma = find_vma(mm, addr);
19615 - if (end - len >= addr &&
19616 - (!vma || addr + len <= vma->vm_start))
19617 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len))
19618 return addr;
19619 }
19620 if (((flags & MAP_32BIT) || test_thread_flag(TIF_IA32))
19621 @@ -172,7 +175,7 @@ full_search:
19622 }
19623 return -ENOMEM;
19624 }
19625 - if (!vma || addr + len <= vma->vm_start) {
19626 + if (check_heap_stack_gap(vma, addr, len)) {
19627 /*
19628 * Remember the place where we stopped the search:
19629 */
19630 @@ -195,7 +198,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
19631 {
19632 struct vm_area_struct *vma;
19633 struct mm_struct *mm = current->mm;
19634 - unsigned long addr = addr0;
19635 + unsigned long base = mm->mmap_base, addr = addr0;
19636
19637 /* requested length too big for entire address space */
19638 if (len > TASK_SIZE)
19639 @@ -208,13 +211,18 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
19640 if (!test_thread_flag(TIF_IA32) && (flags & MAP_32BIT))
19641 goto bottomup;
19642
19643 +#ifdef CONFIG_PAX_RANDMMAP
19644 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
19645 +#endif
19646 +
19647 /* requesting a specific address */
19648 if (addr) {
19649 addr = PAGE_ALIGN(addr);
19650 - vma = find_vma(mm, addr);
19651 - if (TASK_SIZE - len >= addr &&
19652 - (!vma || addr + len <= vma->vm_start))
19653 - return addr;
19654 + if (TASK_SIZE - len >= addr) {
19655 + vma = find_vma(mm, addr);
19656 + if (check_heap_stack_gap(vma, addr, len))
19657 + return addr;
19658 + }
19659 }
19660
19661 /* check if free_area_cache is useful for us */
19662 @@ -232,7 +240,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
19663 ALIGN_TOPDOWN);
19664
19665 vma = find_vma(mm, tmp_addr);
19666 - if (!vma || tmp_addr + len <= vma->vm_start)
19667 + if (check_heap_stack_gap(vma, tmp_addr, len))
19668 /* remember the address as a hint for next time */
19669 return mm->free_area_cache = tmp_addr;
19670 }
19671 @@ -251,7 +259,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
19672 * return with success:
19673 */
19674 vma = find_vma(mm, addr);
19675 - if (!vma || addr+len <= vma->vm_start)
19676 + if (check_heap_stack_gap(vma, addr, len))
19677 /* remember the address as a hint for next time */
19678 return mm->free_area_cache = addr;
19679
19680 @@ -260,8 +268,8 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
19681 mm->cached_hole_size = vma->vm_start - addr;
19682
19683 /* try just below the current vma->vm_start */
19684 - addr = vma->vm_start-len;
19685 - } while (len < vma->vm_start);
19686 + addr = skip_heap_stack_gap(vma, len);
19687 + } while (!IS_ERR_VALUE(addr));
19688
19689 bottomup:
19690 /*
19691 @@ -270,13 +278,21 @@ bottomup:
19692 * can happen with large stack limits and large mmap()
19693 * allocations.
19694 */
19695 + mm->mmap_base = TASK_UNMAPPED_BASE;
19696 +
19697 +#ifdef CONFIG_PAX_RANDMMAP
19698 + if (mm->pax_flags & MF_PAX_RANDMMAP)
19699 + mm->mmap_base += mm->delta_mmap;
19700 +#endif
19701 +
19702 + mm->free_area_cache = mm->mmap_base;
19703 mm->cached_hole_size = ~0UL;
19704 - mm->free_area_cache = TASK_UNMAPPED_BASE;
19705 addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
19706 /*
19707 * Restore the topdown base:
19708 */
19709 - mm->free_area_cache = mm->mmap_base;
19710 + mm->mmap_base = base;
19711 + mm->free_area_cache = base;
19712 mm->cached_hole_size = ~0UL;
19713
19714 return addr;
19715 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
19716 index e2410e2..4fe3fbc 100644
19717 --- a/arch/x86/kernel/tboot.c
19718 +++ b/arch/x86/kernel/tboot.c
19719 @@ -219,7 +219,7 @@ static int tboot_setup_sleep(void)
19720
19721 void tboot_shutdown(u32 shutdown_type)
19722 {
19723 - void (*shutdown)(void);
19724 + void (* __noreturn shutdown)(void);
19725
19726 if (!tboot_enabled())
19727 return;
19728 @@ -241,7 +241,7 @@ void tboot_shutdown(u32 shutdown_type)
19729
19730 switch_to_tboot_pt();
19731
19732 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
19733 + shutdown = (void *)tboot->shutdown_entry;
19734 shutdown();
19735
19736 /* should not reach here */
19737 @@ -298,7 +298,7 @@ void tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
19738 tboot_shutdown(acpi_shutdown_map[sleep_state]);
19739 }
19740
19741 -static atomic_t ap_wfs_count;
19742 +static atomic_unchecked_t ap_wfs_count;
19743
19744 static int tboot_wait_for_aps(int num_aps)
19745 {
19746 @@ -322,9 +322,9 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
19747 {
19748 switch (action) {
19749 case CPU_DYING:
19750 - atomic_inc(&ap_wfs_count);
19751 + atomic_inc_unchecked(&ap_wfs_count);
19752 if (num_online_cpus() == 1)
19753 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
19754 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
19755 return NOTIFY_BAD;
19756 break;
19757 }
19758 @@ -343,7 +343,7 @@ static __init int tboot_late_init(void)
19759
19760 tboot_create_trampoline();
19761
19762 - atomic_set(&ap_wfs_count, 0);
19763 + atomic_set_unchecked(&ap_wfs_count, 0);
19764 register_hotcpu_notifier(&tboot_cpu_notifier);
19765 return 0;
19766 }
19767 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
19768 index dd5fbf4..b7f2232 100644
19769 --- a/arch/x86/kernel/time.c
19770 +++ b/arch/x86/kernel/time.c
19771 @@ -31,9 +31,9 @@ unsigned long profile_pc(struct pt_regs *regs)
19772 {
19773 unsigned long pc = instruction_pointer(regs);
19774
19775 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
19776 + if (!user_mode(regs) && in_lock_functions(pc)) {
19777 #ifdef CONFIG_FRAME_POINTER
19778 - return *(unsigned long *)(regs->bp + sizeof(long));
19779 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
19780 #else
19781 unsigned long *sp =
19782 (unsigned long *)kernel_stack_pointer(regs);
19783 @@ -42,11 +42,17 @@ unsigned long profile_pc(struct pt_regs *regs)
19784 * or above a saved flags. Eflags has bits 22-31 zero,
19785 * kernel addresses don't.
19786 */
19787 +
19788 +#ifdef CONFIG_PAX_KERNEXEC
19789 + return ktla_ktva(sp[0]);
19790 +#else
19791 if (sp[0] >> 22)
19792 return sp[0];
19793 if (sp[1] >> 22)
19794 return sp[1];
19795 #endif
19796 +
19797 +#endif
19798 }
19799 return pc;
19800 }
19801 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
19802 index bcfec2d..8f88b4a 100644
19803 --- a/arch/x86/kernel/tls.c
19804 +++ b/arch/x86/kernel/tls.c
19805 @@ -85,6 +85,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
19806 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
19807 return -EINVAL;
19808
19809 +#ifdef CONFIG_PAX_SEGMEXEC
19810 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
19811 + return -EINVAL;
19812 +#endif
19813 +
19814 set_tls_desc(p, idx, &info, 1);
19815
19816 return 0;
19817 diff --git a/arch/x86/kernel/trampoline_32.S b/arch/x86/kernel/trampoline_32.S
19818 index 451c0a7..e57f551 100644
19819 --- a/arch/x86/kernel/trampoline_32.S
19820 +++ b/arch/x86/kernel/trampoline_32.S
19821 @@ -32,6 +32,12 @@
19822 #include <asm/segment.h>
19823 #include <asm/page_types.h>
19824
19825 +#ifdef CONFIG_PAX_KERNEXEC
19826 +#define ta(X) (X)
19827 +#else
19828 +#define ta(X) ((X) - __PAGE_OFFSET)
19829 +#endif
19830 +
19831 #ifdef CONFIG_SMP
19832
19833 .section ".x86_trampoline","a"
19834 @@ -62,7 +68,7 @@ r_base = .
19835 inc %ax # protected mode (PE) bit
19836 lmsw %ax # into protected mode
19837 # flush prefetch and jump to startup_32_smp in arch/i386/kernel/head.S
19838 - ljmpl $__BOOT_CS, $(startup_32_smp-__PAGE_OFFSET)
19839 + ljmpl $__BOOT_CS, $ta(startup_32_smp)
19840
19841 # These need to be in the same 64K segment as the above;
19842 # hence we don't use the boot_gdt_descr defined in head.S
19843 diff --git a/arch/x86/kernel/trampoline_64.S b/arch/x86/kernel/trampoline_64.S
19844 index 09ff517..df19fbff 100644
19845 --- a/arch/x86/kernel/trampoline_64.S
19846 +++ b/arch/x86/kernel/trampoline_64.S
19847 @@ -90,7 +90,7 @@ startup_32:
19848 movl $__KERNEL_DS, %eax # Initialize the %ds segment register
19849 movl %eax, %ds
19850
19851 - movl $X86_CR4_PAE, %eax
19852 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %eax
19853 movl %eax, %cr4 # Enable PAE mode
19854
19855 # Setup trampoline 4 level pagetables
19856 @@ -138,7 +138,7 @@ tidt:
19857 # so the kernel can live anywhere
19858 .balign 4
19859 tgdt:
19860 - .short tgdt_end - tgdt # gdt limit
19861 + .short tgdt_end - tgdt - 1 # gdt limit
19862 .long tgdt - r_base
19863 .short 0
19864 .quad 0x00cf9b000000ffff # __KERNEL32_CS
19865 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
19866 index 4bbe04d..41d0943 100644
19867 --- a/arch/x86/kernel/traps.c
19868 +++ b/arch/x86/kernel/traps.c
19869 @@ -70,12 +70,6 @@ asmlinkage int system_call(void);
19870
19871 /* Do we ignore FPU interrupts ? */
19872 char ignore_fpu_irq;
19873 -
19874 -/*
19875 - * The IDT has to be page-aligned to simplify the Pentium
19876 - * F0 0F bug workaround.
19877 - */
19878 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
19879 #endif
19880
19881 DECLARE_BITMAP(used_vectors, NR_VECTORS);
19882 @@ -108,13 +102,13 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
19883 }
19884
19885 static void __kprobes
19886 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
19887 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
19888 long error_code, siginfo_t *info)
19889 {
19890 struct task_struct *tsk = current;
19891
19892 #ifdef CONFIG_X86_32
19893 - if (regs->flags & X86_VM_MASK) {
19894 + if (v8086_mode(regs)) {
19895 /*
19896 * traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
19897 * On nmi (interrupt 2), do_trap should not be called.
19898 @@ -125,7 +119,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
19899 }
19900 #endif
19901
19902 - if (!user_mode(regs))
19903 + if (!user_mode_novm(regs))
19904 goto kernel_trap;
19905
19906 #ifdef CONFIG_X86_32
19907 @@ -148,7 +142,7 @@ trap_signal:
19908 printk_ratelimit()) {
19909 printk(KERN_INFO
19910 "%s[%d] trap %s ip:%lx sp:%lx error:%lx",
19911 - tsk->comm, tsk->pid, str,
19912 + tsk->comm, task_pid_nr(tsk), str,
19913 regs->ip, regs->sp, error_code);
19914 print_vma_addr(" in ", regs->ip);
19915 printk("\n");
19916 @@ -165,8 +159,20 @@ kernel_trap:
19917 if (!fixup_exception(regs)) {
19918 tsk->thread.error_code = error_code;
19919 tsk->thread.trap_no = trapnr;
19920 +
19921 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
19922 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
19923 + str = "PAX: suspicious stack segment fault";
19924 +#endif
19925 +
19926 die(str, regs, error_code);
19927 }
19928 +
19929 +#ifdef CONFIG_PAX_REFCOUNT
19930 + if (trapnr == 4)
19931 + pax_report_refcount_overflow(regs);
19932 +#endif
19933 +
19934 return;
19935
19936 #ifdef CONFIG_X86_32
19937 @@ -255,14 +261,30 @@ do_general_protection(struct pt_regs *regs, long error_code)
19938 conditional_sti(regs);
19939
19940 #ifdef CONFIG_X86_32
19941 - if (regs->flags & X86_VM_MASK)
19942 + if (v8086_mode(regs))
19943 goto gp_in_vm86;
19944 #endif
19945
19946 tsk = current;
19947 - if (!user_mode(regs))
19948 + if (!user_mode_novm(regs))
19949 goto gp_in_kernel;
19950
19951 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
19952 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
19953 + struct mm_struct *mm = tsk->mm;
19954 + unsigned long limit;
19955 +
19956 + down_write(&mm->mmap_sem);
19957 + limit = mm->context.user_cs_limit;
19958 + if (limit < TASK_SIZE) {
19959 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
19960 + up_write(&mm->mmap_sem);
19961 + return;
19962 + }
19963 + up_write(&mm->mmap_sem);
19964 + }
19965 +#endif
19966 +
19967 tsk->thread.error_code = error_code;
19968 tsk->thread.trap_no = 13;
19969
19970 @@ -295,6 +317,13 @@ gp_in_kernel:
19971 if (notify_die(DIE_GPF, "general protection fault", regs,
19972 error_code, 13, SIGSEGV) == NOTIFY_STOP)
19973 return;
19974 +
19975 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
19976 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
19977 + die("PAX: suspicious general protection fault", regs, error_code);
19978 + else
19979 +#endif
19980 +
19981 die("general protection fault", regs, error_code);
19982 }
19983
19984 @@ -421,7 +450,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
19985 /* It's safe to allow irq's after DR6 has been saved */
19986 preempt_conditional_sti(regs);
19987
19988 - if (regs->flags & X86_VM_MASK) {
19989 + if (v8086_mode(regs)) {
19990 handle_vm86_trap((struct kernel_vm86_regs *) regs,
19991 error_code, 1);
19992 preempt_conditional_cli(regs);
19993 @@ -436,7 +465,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
19994 * We already checked v86 mode above, so we can check for kernel mode
19995 * by just checking the CPL of CS.
19996 */
19997 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
19998 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
19999 tsk->thread.debugreg6 &= ~DR_STEP;
20000 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
20001 regs->flags &= ~X86_EFLAGS_TF;
20002 @@ -466,7 +495,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
20003 return;
20004 conditional_sti(regs);
20005
20006 - if (!user_mode_vm(regs))
20007 + if (!user_mode(regs))
20008 {
20009 if (!fixup_exception(regs)) {
20010 task->thread.error_code = error_code;
20011 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
20012 index b9242ba..50c5edd 100644
20013 --- a/arch/x86/kernel/verify_cpu.S
20014 +++ b/arch/x86/kernel/verify_cpu.S
20015 @@ -20,6 +20,7 @@
20016 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
20017 * arch/x86/kernel/trampoline_64.S: secondary processor verification
20018 * arch/x86/kernel/head_32.S: processor startup
20019 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
20020 *
20021 * verify_cpu, returns the status of longmode and SSE in register %eax.
20022 * 0: Success 1: Failure
20023 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
20024 index 328cb37..56556b4 100644
20025 --- a/arch/x86/kernel/vm86_32.c
20026 +++ b/arch/x86/kernel/vm86_32.c
20027 @@ -41,6 +41,7 @@
20028 #include <linux/ptrace.h>
20029 #include <linux/audit.h>
20030 #include <linux/stddef.h>
20031 +#include <linux/grsecurity.h>
20032
20033 #include <asm/uaccess.h>
20034 #include <asm/io.h>
20035 @@ -148,7 +149,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
20036 do_exit(SIGSEGV);
20037 }
20038
20039 - tss = &per_cpu(init_tss, get_cpu());
20040 + tss = init_tss + get_cpu();
20041 current->thread.sp0 = current->thread.saved_sp0;
20042 current->thread.sysenter_cs = __KERNEL_CS;
20043 load_sp0(tss, &current->thread);
20044 @@ -210,6 +211,13 @@ int sys_vm86old(struct vm86_struct __user *v86, struct pt_regs *regs)
20045 struct task_struct *tsk;
20046 int tmp, ret = -EPERM;
20047
20048 +#ifdef CONFIG_GRKERNSEC_VM86
20049 + if (!capable(CAP_SYS_RAWIO)) {
20050 + gr_handle_vm86();
20051 + goto out;
20052 + }
20053 +#endif
20054 +
20055 tsk = current;
20056 if (tsk->thread.saved_sp0)
20057 goto out;
20058 @@ -240,6 +248,14 @@ int sys_vm86(unsigned long cmd, unsigned long arg, struct pt_regs *regs)
20059 int tmp, ret;
20060 struct vm86plus_struct __user *v86;
20061
20062 +#ifdef CONFIG_GRKERNSEC_VM86
20063 + if (!capable(CAP_SYS_RAWIO)) {
20064 + gr_handle_vm86();
20065 + ret = -EPERM;
20066 + goto out;
20067 + }
20068 +#endif
20069 +
20070 tsk = current;
20071 switch (cmd) {
20072 case VM86_REQUEST_IRQ:
20073 @@ -326,7 +342,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
20074 tsk->thread.saved_fs = info->regs32->fs;
20075 tsk->thread.saved_gs = get_user_gs(info->regs32);
20076
20077 - tss = &per_cpu(init_tss, get_cpu());
20078 + tss = init_tss + get_cpu();
20079 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
20080 if (cpu_has_sep)
20081 tsk->thread.sysenter_cs = 0;
20082 @@ -533,7 +549,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
20083 goto cannot_handle;
20084 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
20085 goto cannot_handle;
20086 - intr_ptr = (unsigned long __user *) (i << 2);
20087 + intr_ptr = (__force unsigned long __user *) (i << 2);
20088 if (get_user(segoffs, intr_ptr))
20089 goto cannot_handle;
20090 if ((segoffs >> 16) == BIOSSEG)
20091 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
20092 index 0f703f1..9e15f64 100644
20093 --- a/arch/x86/kernel/vmlinux.lds.S
20094 +++ b/arch/x86/kernel/vmlinux.lds.S
20095 @@ -26,6 +26,13 @@
20096 #include <asm/page_types.h>
20097 #include <asm/cache.h>
20098 #include <asm/boot.h>
20099 +#include <asm/segment.h>
20100 +
20101 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
20102 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
20103 +#else
20104 +#define __KERNEL_TEXT_OFFSET 0
20105 +#endif
20106
20107 #undef i386 /* in case the preprocessor is a 32bit one */
20108
20109 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
20110
20111 PHDRS {
20112 text PT_LOAD FLAGS(5); /* R_E */
20113 +#ifdef CONFIG_X86_32
20114 + module PT_LOAD FLAGS(5); /* R_E */
20115 +#endif
20116 +#ifdef CONFIG_XEN
20117 + rodata PT_LOAD FLAGS(5); /* R_E */
20118 +#else
20119 + rodata PT_LOAD FLAGS(4); /* R__ */
20120 +#endif
20121 data PT_LOAD FLAGS(6); /* RW_ */
20122 -#ifdef CONFIG_X86_64
20123 + init.begin PT_LOAD FLAGS(6); /* RW_ */
20124 #ifdef CONFIG_SMP
20125 percpu PT_LOAD FLAGS(6); /* RW_ */
20126 #endif
20127 + text.init PT_LOAD FLAGS(5); /* R_E */
20128 + text.exit PT_LOAD FLAGS(5); /* R_E */
20129 init PT_LOAD FLAGS(7); /* RWE */
20130 -#endif
20131 note PT_NOTE FLAGS(0); /* ___ */
20132 }
20133
20134 SECTIONS
20135 {
20136 #ifdef CONFIG_X86_32
20137 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
20138 - phys_startup_32 = startup_32 - LOAD_OFFSET;
20139 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
20140 #else
20141 - . = __START_KERNEL;
20142 - phys_startup_64 = startup_64 - LOAD_OFFSET;
20143 + . = __START_KERNEL;
20144 #endif
20145
20146 /* Text and read-only data */
20147 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
20148 - _text = .;
20149 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
20150 /* bootstrapping code */
20151 +#ifdef CONFIG_X86_32
20152 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
20153 +#else
20154 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
20155 +#endif
20156 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
20157 + _text = .;
20158 HEAD_TEXT
20159 #ifdef CONFIG_X86_32
20160 . = ALIGN(PAGE_SIZE);
20161 @@ -108,13 +128,47 @@ SECTIONS
20162 IRQENTRY_TEXT
20163 *(.fixup)
20164 *(.gnu.warning)
20165 - /* End of text section */
20166 - _etext = .;
20167 } :text = 0x9090
20168
20169 - NOTES :text :note
20170 + . += __KERNEL_TEXT_OFFSET;
20171
20172 - EXCEPTION_TABLE(16) :text = 0x9090
20173 +#ifdef CONFIG_X86_32
20174 + . = ALIGN(PAGE_SIZE);
20175 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
20176 +
20177 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_MODULES)
20178 + MODULES_EXEC_VADDR = .;
20179 + BYTE(0)
20180 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
20181 + . = ALIGN(HPAGE_SIZE);
20182 + MODULES_EXEC_END = . - 1;
20183 +#endif
20184 +
20185 + } :module
20186 +#endif
20187 +
20188 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
20189 + /* End of text section */
20190 + _etext = . - __KERNEL_TEXT_OFFSET;
20191 + }
20192 +
20193 +#ifdef CONFIG_X86_32
20194 + . = ALIGN(PAGE_SIZE);
20195 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
20196 + *(.idt)
20197 + . = ALIGN(PAGE_SIZE);
20198 + *(.empty_zero_page)
20199 + *(.initial_pg_fixmap)
20200 + *(.initial_pg_pmd)
20201 + *(.initial_page_table)
20202 + *(.swapper_pg_dir)
20203 + } :rodata
20204 +#endif
20205 +
20206 + . = ALIGN(PAGE_SIZE);
20207 + NOTES :rodata :note
20208 +
20209 + EXCEPTION_TABLE(16) :rodata
20210
20211 #if defined(CONFIG_DEBUG_RODATA)
20212 /* .text should occupy whole number of pages */
20213 @@ -126,16 +180,20 @@ SECTIONS
20214
20215 /* Data */
20216 .data : AT(ADDR(.data) - LOAD_OFFSET) {
20217 +
20218 +#ifdef CONFIG_PAX_KERNEXEC
20219 + . = ALIGN(HPAGE_SIZE);
20220 +#else
20221 + . = ALIGN(PAGE_SIZE);
20222 +#endif
20223 +
20224 /* Start of data section */
20225 _sdata = .;
20226
20227 /* init_task */
20228 INIT_TASK_DATA(THREAD_SIZE)
20229
20230 -#ifdef CONFIG_X86_32
20231 - /* 32 bit has nosave before _edata */
20232 NOSAVE_DATA
20233 -#endif
20234
20235 PAGE_ALIGNED_DATA(PAGE_SIZE)
20236
20237 @@ -176,12 +234,19 @@ SECTIONS
20238 #endif /* CONFIG_X86_64 */
20239
20240 /* Init code and data - will be freed after init */
20241 - . = ALIGN(PAGE_SIZE);
20242 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
20243 + BYTE(0)
20244 +
20245 +#ifdef CONFIG_PAX_KERNEXEC
20246 + . = ALIGN(HPAGE_SIZE);
20247 +#else
20248 + . = ALIGN(PAGE_SIZE);
20249 +#endif
20250 +
20251 __init_begin = .; /* paired with __init_end */
20252 - }
20253 + } :init.begin
20254
20255 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
20256 +#ifdef CONFIG_SMP
20257 /*
20258 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
20259 * output PHDR, so the next output section - .init.text - should
20260 @@ -190,12 +255,27 @@ SECTIONS
20261 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
20262 #endif
20263
20264 - INIT_TEXT_SECTION(PAGE_SIZE)
20265 -#ifdef CONFIG_X86_64
20266 - :init
20267 -#endif
20268 + . = ALIGN(PAGE_SIZE);
20269 + init_begin = .;
20270 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
20271 + VMLINUX_SYMBOL(_sinittext) = .;
20272 + INIT_TEXT
20273 + VMLINUX_SYMBOL(_einittext) = .;
20274 + . = ALIGN(PAGE_SIZE);
20275 + } :text.init
20276
20277 - INIT_DATA_SECTION(16)
20278 + /*
20279 + * .exit.text is discard at runtime, not link time, to deal with
20280 + * references from .altinstructions and .eh_frame
20281 + */
20282 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
20283 + EXIT_TEXT
20284 + . = ALIGN(16);
20285 + } :text.exit
20286 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
20287 +
20288 + . = ALIGN(PAGE_SIZE);
20289 + INIT_DATA_SECTION(16) :init
20290
20291 /*
20292 * Code and data for a variety of lowlevel trampolines, to be
20293 @@ -269,19 +349,12 @@ SECTIONS
20294 }
20295
20296 . = ALIGN(8);
20297 - /*
20298 - * .exit.text is discard at runtime, not link time, to deal with
20299 - * references from .altinstructions and .eh_frame
20300 - */
20301 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
20302 - EXIT_TEXT
20303 - }
20304
20305 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
20306 EXIT_DATA
20307 }
20308
20309 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
20310 +#ifndef CONFIG_SMP
20311 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
20312 #endif
20313
20314 @@ -300,16 +373,10 @@ SECTIONS
20315 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
20316 __smp_locks = .;
20317 *(.smp_locks)
20318 - . = ALIGN(PAGE_SIZE);
20319 __smp_locks_end = .;
20320 + . = ALIGN(PAGE_SIZE);
20321 }
20322
20323 -#ifdef CONFIG_X86_64
20324 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
20325 - NOSAVE_DATA
20326 - }
20327 -#endif
20328 -
20329 /* BSS */
20330 . = ALIGN(PAGE_SIZE);
20331 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
20332 @@ -325,6 +392,7 @@ SECTIONS
20333 __brk_base = .;
20334 . += 64 * 1024; /* 64k alignment slop space */
20335 *(.brk_reservation) /* areas brk users have reserved */
20336 + . = ALIGN(HPAGE_SIZE);
20337 __brk_limit = .;
20338 }
20339
20340 @@ -351,13 +419,12 @@ SECTIONS
20341 * for the boot processor.
20342 */
20343 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
20344 -INIT_PER_CPU(gdt_page);
20345 INIT_PER_CPU(irq_stack_union);
20346
20347 /*
20348 * Build-time check on the image size:
20349 */
20350 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
20351 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
20352 "kernel image bigger than KERNEL_IMAGE_SIZE");
20353
20354 #ifdef CONFIG_SMP
20355 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
20356 index b07ba93..a212969 100644
20357 --- a/arch/x86/kernel/vsyscall_64.c
20358 +++ b/arch/x86/kernel/vsyscall_64.c
20359 @@ -57,15 +57,13 @@ DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data) =
20360 .lock = __SEQLOCK_UNLOCKED(__vsyscall_gtod_data.lock),
20361 };
20362
20363 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
20364 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
20365
20366 static int __init vsyscall_setup(char *str)
20367 {
20368 if (str) {
20369 if (!strcmp("emulate", str))
20370 vsyscall_mode = EMULATE;
20371 - else if (!strcmp("native", str))
20372 - vsyscall_mode = NATIVE;
20373 else if (!strcmp("none", str))
20374 vsyscall_mode = NONE;
20375 else
20376 @@ -207,7 +205,7 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
20377
20378 tsk = current;
20379 if (seccomp_mode(&tsk->seccomp))
20380 - do_exit(SIGKILL);
20381 + do_group_exit(SIGKILL);
20382
20383 /*
20384 * With a real vsyscall, page faults cause SIGSEGV. We want to
20385 @@ -279,8 +277,7 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
20386 return true;
20387
20388 sigsegv:
20389 - force_sig(SIGSEGV, current);
20390 - return true;
20391 + do_group_exit(SIGKILL);
20392 }
20393
20394 /*
20395 @@ -333,10 +330,7 @@ void __init map_vsyscall(void)
20396 extern char __vvar_page;
20397 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
20398
20399 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
20400 - vsyscall_mode == NATIVE
20401 - ? PAGE_KERNEL_VSYSCALL
20402 - : PAGE_KERNEL_VVAR);
20403 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
20404 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
20405 (unsigned long)VSYSCALL_START);
20406
20407 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
20408 index 9796c2f..f686fbf 100644
20409 --- a/arch/x86/kernel/x8664_ksyms_64.c
20410 +++ b/arch/x86/kernel/x8664_ksyms_64.c
20411 @@ -29,8 +29,6 @@ EXPORT_SYMBOL(__put_user_8);
20412 EXPORT_SYMBOL(copy_user_generic_string);
20413 EXPORT_SYMBOL(copy_user_generic_unrolled);
20414 EXPORT_SYMBOL(__copy_user_nocache);
20415 -EXPORT_SYMBOL(_copy_from_user);
20416 -EXPORT_SYMBOL(_copy_to_user);
20417
20418 EXPORT_SYMBOL(copy_page);
20419 EXPORT_SYMBOL(clear_page);
20420 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
20421 index 7110911..e8cdee5 100644
20422 --- a/arch/x86/kernel/xsave.c
20423 +++ b/arch/x86/kernel/xsave.c
20424 @@ -130,7 +130,7 @@ int check_for_xstate(struct i387_fxsave_struct __user *buf,
20425 fx_sw_user->xstate_size > fx_sw_user->extended_size)
20426 return -EINVAL;
20427
20428 - err = __get_user(magic2, (__u32 *) (((void *)fpstate) +
20429 + err = __get_user(magic2, (__u32 __user *) (((void __user *)fpstate) +
20430 fx_sw_user->extended_size -
20431 FP_XSTATE_MAGIC2_SIZE));
20432 if (err)
20433 @@ -266,7 +266,7 @@ fx_only:
20434 * the other extended state.
20435 */
20436 xrstor_state(init_xstate_buf, pcntxt_mask & ~XSTATE_FPSSE);
20437 - return fxrstor_checking((__force struct i387_fxsave_struct *)buf);
20438 + return fxrstor_checking((struct i387_fxsave_struct __force_kernel *)buf);
20439 }
20440
20441 /*
20442 @@ -295,7 +295,7 @@ int restore_i387_xstate(void __user *buf)
20443 if (use_xsave())
20444 err = restore_user_xstate(buf);
20445 else
20446 - err = fxrstor_checking((__force struct i387_fxsave_struct *)
20447 + err = fxrstor_checking((struct i387_fxsave_struct __force_kernel *)
20448 buf);
20449 if (unlikely(err)) {
20450 /*
20451 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
20452 index 89b02bf..0f6511d 100644
20453 --- a/arch/x86/kvm/cpuid.c
20454 +++ b/arch/x86/kvm/cpuid.c
20455 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
20456 struct kvm_cpuid2 *cpuid,
20457 struct kvm_cpuid_entry2 __user *entries)
20458 {
20459 - int r;
20460 + int r, i;
20461
20462 r = -E2BIG;
20463 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
20464 goto out;
20465 r = -EFAULT;
20466 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
20467 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
20468 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
20469 goto out;
20470 + for (i = 0; i < cpuid->nent; ++i) {
20471 + struct kvm_cpuid_entry2 cpuid_entry;
20472 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
20473 + goto out;
20474 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
20475 + }
20476 vcpu->arch.cpuid_nent = cpuid->nent;
20477 kvm_apic_set_version(vcpu);
20478 kvm_x86_ops->cpuid_update(vcpu);
20479 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
20480 struct kvm_cpuid2 *cpuid,
20481 struct kvm_cpuid_entry2 __user *entries)
20482 {
20483 - int r;
20484 + int r, i;
20485
20486 r = -E2BIG;
20487 if (cpuid->nent < vcpu->arch.cpuid_nent)
20488 goto out;
20489 r = -EFAULT;
20490 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
20491 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
20492 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
20493 goto out;
20494 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
20495 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
20496 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
20497 + goto out;
20498 + }
20499 return 0;
20500
20501 out:
20502 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
20503 index 0982507..7f6d72f 100644
20504 --- a/arch/x86/kvm/emulate.c
20505 +++ b/arch/x86/kvm/emulate.c
20506 @@ -250,6 +250,7 @@ struct gprefix {
20507
20508 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
20509 do { \
20510 + unsigned long _tmp; \
20511 __asm__ __volatile__ ( \
20512 _PRE_EFLAGS("0", "4", "2") \
20513 _op _suffix " %"_x"3,%1; " \
20514 @@ -264,8 +265,6 @@ struct gprefix {
20515 /* Raw emulation: instruction has two explicit operands. */
20516 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
20517 do { \
20518 - unsigned long _tmp; \
20519 - \
20520 switch ((ctxt)->dst.bytes) { \
20521 case 2: \
20522 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
20523 @@ -281,7 +280,6 @@ struct gprefix {
20524
20525 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
20526 do { \
20527 - unsigned long _tmp; \
20528 switch ((ctxt)->dst.bytes) { \
20529 case 1: \
20530 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
20531 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
20532 index cfdc6e0..ab92e84 100644
20533 --- a/arch/x86/kvm/lapic.c
20534 +++ b/arch/x86/kvm/lapic.c
20535 @@ -54,7 +54,7 @@
20536 #define APIC_BUS_CYCLE_NS 1
20537
20538 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
20539 -#define apic_debug(fmt, arg...)
20540 +#define apic_debug(fmt, arg...) do {} while (0)
20541
20542 #define APIC_LVT_NUM 6
20543 /* 14 is the version for Xeon and Pentium 8.4.8*/
20544 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
20545 index 1561028..0ed7f14 100644
20546 --- a/arch/x86/kvm/paging_tmpl.h
20547 +++ b/arch/x86/kvm/paging_tmpl.h
20548 @@ -197,7 +197,7 @@ retry_walk:
20549 if (unlikely(kvm_is_error_hva(host_addr)))
20550 goto error;
20551
20552 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
20553 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
20554 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
20555 goto error;
20556
20557 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
20558 index e385214..f8df033 100644
20559 --- a/arch/x86/kvm/svm.c
20560 +++ b/arch/x86/kvm/svm.c
20561 @@ -3420,7 +3420,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
20562 int cpu = raw_smp_processor_id();
20563
20564 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
20565 +
20566 + pax_open_kernel();
20567 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
20568 + pax_close_kernel();
20569 +
20570 load_TR_desc();
20571 }
20572
20573 @@ -3798,6 +3802,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
20574 #endif
20575 #endif
20576
20577 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
20578 + __set_fs(current_thread_info()->addr_limit);
20579 +#endif
20580 +
20581 reload_tss(vcpu);
20582
20583 local_irq_disable();
20584 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
20585 index a7a6f60..04b745a 100644
20586 --- a/arch/x86/kvm/vmx.c
20587 +++ b/arch/x86/kvm/vmx.c
20588 @@ -1306,7 +1306,11 @@ static void reload_tss(void)
20589 struct desc_struct *descs;
20590
20591 descs = (void *)gdt->address;
20592 +
20593 + pax_open_kernel();
20594 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
20595 + pax_close_kernel();
20596 +
20597 load_TR_desc();
20598 }
20599
20600 @@ -2637,8 +2641,11 @@ static __init int hardware_setup(void)
20601 if (!cpu_has_vmx_flexpriority())
20602 flexpriority_enabled = 0;
20603
20604 - if (!cpu_has_vmx_tpr_shadow())
20605 - kvm_x86_ops->update_cr8_intercept = NULL;
20606 + if (!cpu_has_vmx_tpr_shadow()) {
20607 + pax_open_kernel();
20608 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
20609 + pax_close_kernel();
20610 + }
20611
20612 if (enable_ept && !cpu_has_vmx_ept_2m_page())
20613 kvm_disable_largepages();
20614 @@ -3654,7 +3661,7 @@ static void vmx_set_constant_host_state(void)
20615 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
20616
20617 asm("mov $.Lkvm_vmx_return, %0" : "=r"(tmpl));
20618 - vmcs_writel(HOST_RIP, tmpl); /* 22.2.5 */
20619 + vmcs_writel(HOST_RIP, ktla_ktva(tmpl)); /* 22.2.5 */
20620
20621 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
20622 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
20623 @@ -6192,6 +6199,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
20624 "jmp .Lkvm_vmx_return \n\t"
20625 ".Llaunched: " __ex(ASM_VMX_VMRESUME) "\n\t"
20626 ".Lkvm_vmx_return: "
20627 +
20628 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
20629 + "ljmp %[cs],$.Lkvm_vmx_return2\n\t"
20630 + ".Lkvm_vmx_return2: "
20631 +#endif
20632 +
20633 /* Save guest registers, load host registers, keep flags */
20634 "mov %0, %c[wordsize](%%"R"sp) \n\t"
20635 "pop %0 \n\t"
20636 @@ -6240,6 +6253,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
20637 #endif
20638 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
20639 [wordsize]"i"(sizeof(ulong))
20640 +
20641 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
20642 + ,[cs]"i"(__KERNEL_CS)
20643 +#endif
20644 +
20645 : "cc", "memory"
20646 , R"ax", R"bx", R"di", R"si"
20647 #ifdef CONFIG_X86_64
20648 @@ -6268,7 +6286,16 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
20649 }
20650 }
20651
20652 - asm("mov %0, %%ds; mov %0, %%es" : : "r"(__USER_DS));
20653 + asm("mov %0, %%ds; mov %0, %%es; mov %0, %%ss" : : "r"(__KERNEL_DS));
20654 +
20655 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
20656 + loadsegment(fs, __KERNEL_PERCPU);
20657 +#endif
20658 +
20659 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
20660 + __set_fs(current_thread_info()->addr_limit);
20661 +#endif
20662 +
20663 vmx->loaded_vmcs->launched = 1;
20664
20665 vmx->exit_reason = vmcs_read32(VM_EXIT_REASON);
20666 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
20667 index 8d1c6c6..99c2d5f 100644
20668 --- a/arch/x86/kvm/x86.c
20669 +++ b/arch/x86/kvm/x86.c
20670 @@ -1311,8 +1311,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
20671 {
20672 struct kvm *kvm = vcpu->kvm;
20673 int lm = is_long_mode(vcpu);
20674 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
20675 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
20676 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
20677 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
20678 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
20679 : kvm->arch.xen_hvm_config.blob_size_32;
20680 u32 page_num = data & ~PAGE_MASK;
20681 @@ -2145,6 +2145,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
20682 if (n < msr_list.nmsrs)
20683 goto out;
20684 r = -EFAULT;
20685 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
20686 + goto out;
20687 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
20688 num_msrs_to_save * sizeof(u32)))
20689 goto out;
20690 @@ -2266,7 +2268,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu,
20691 static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
20692 struct kvm_interrupt *irq)
20693 {
20694 - if (irq->irq < 0 || irq->irq >= 256)
20695 + if (irq->irq >= 256)
20696 return -EINVAL;
20697 if (irqchip_in_kernel(vcpu->kvm))
20698 return -ENXIO;
20699 @@ -4782,7 +4784,7 @@ static void kvm_set_mmio_spte_mask(void)
20700 kvm_mmu_set_mmio_spte_mask(mask);
20701 }
20702
20703 -int kvm_arch_init(void *opaque)
20704 +int kvm_arch_init(const void *opaque)
20705 {
20706 int r;
20707 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
20708 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
20709 index 642d880..44e0f3f 100644
20710 --- a/arch/x86/lguest/boot.c
20711 +++ b/arch/x86/lguest/boot.c
20712 @@ -1200,9 +1200,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
20713 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
20714 * Launcher to reboot us.
20715 */
20716 -static void lguest_restart(char *reason)
20717 +static __noreturn void lguest_restart(char *reason)
20718 {
20719 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
20720 + BUG();
20721 }
20722
20723 /*G:050
20724 diff --git a/arch/x86/lib/atomic64_32.c b/arch/x86/lib/atomic64_32.c
20725 index 042f682..c92afb6 100644
20726 --- a/arch/x86/lib/atomic64_32.c
20727 +++ b/arch/x86/lib/atomic64_32.c
20728 @@ -8,18 +8,30 @@
20729
20730 long long atomic64_read_cx8(long long, const atomic64_t *v);
20731 EXPORT_SYMBOL(atomic64_read_cx8);
20732 +long long atomic64_read_unchecked_cx8(long long, const atomic64_unchecked_t *v);
20733 +EXPORT_SYMBOL(atomic64_read_unchecked_cx8);
20734 long long atomic64_set_cx8(long long, const atomic64_t *v);
20735 EXPORT_SYMBOL(atomic64_set_cx8);
20736 +long long atomic64_set_unchecked_cx8(long long, const atomic64_unchecked_t *v);
20737 +EXPORT_SYMBOL(atomic64_set_unchecked_cx8);
20738 long long atomic64_xchg_cx8(long long, unsigned high);
20739 EXPORT_SYMBOL(atomic64_xchg_cx8);
20740 long long atomic64_add_return_cx8(long long a, atomic64_t *v);
20741 EXPORT_SYMBOL(atomic64_add_return_cx8);
20742 +long long atomic64_add_return_unchecked_cx8(long long a, atomic64_unchecked_t *v);
20743 +EXPORT_SYMBOL(atomic64_add_return_unchecked_cx8);
20744 long long atomic64_sub_return_cx8(long long a, atomic64_t *v);
20745 EXPORT_SYMBOL(atomic64_sub_return_cx8);
20746 +long long atomic64_sub_return_unchecked_cx8(long long a, atomic64_unchecked_t *v);
20747 +EXPORT_SYMBOL(atomic64_sub_return_unchecked_cx8);
20748 long long atomic64_inc_return_cx8(long long a, atomic64_t *v);
20749 EXPORT_SYMBOL(atomic64_inc_return_cx8);
20750 +long long atomic64_inc_return_unchecked_cx8(long long a, atomic64_unchecked_t *v);
20751 +EXPORT_SYMBOL(atomic64_inc_return_unchecked_cx8);
20752 long long atomic64_dec_return_cx8(long long a, atomic64_t *v);
20753 EXPORT_SYMBOL(atomic64_dec_return_cx8);
20754 +long long atomic64_dec_return_unchecked_cx8(long long a, atomic64_unchecked_t *v);
20755 +EXPORT_SYMBOL(atomic64_dec_return_unchecked_cx8);
20756 long long atomic64_dec_if_positive_cx8(atomic64_t *v);
20757 EXPORT_SYMBOL(atomic64_dec_if_positive_cx8);
20758 int atomic64_inc_not_zero_cx8(atomic64_t *v);
20759 @@ -30,26 +42,46 @@ EXPORT_SYMBOL(atomic64_add_unless_cx8);
20760 #ifndef CONFIG_X86_CMPXCHG64
20761 long long atomic64_read_386(long long, const atomic64_t *v);
20762 EXPORT_SYMBOL(atomic64_read_386);
20763 +long long atomic64_read_unchecked_386(long long, const atomic64_unchecked_t *v);
20764 +EXPORT_SYMBOL(atomic64_read_unchecked_386);
20765 long long atomic64_set_386(long long, const atomic64_t *v);
20766 EXPORT_SYMBOL(atomic64_set_386);
20767 +long long atomic64_set_unchecked_386(long long, const atomic64_unchecked_t *v);
20768 +EXPORT_SYMBOL(atomic64_set_unchecked_386);
20769 long long atomic64_xchg_386(long long, unsigned high);
20770 EXPORT_SYMBOL(atomic64_xchg_386);
20771 long long atomic64_add_return_386(long long a, atomic64_t *v);
20772 EXPORT_SYMBOL(atomic64_add_return_386);
20773 +long long atomic64_add_return_unchecked_386(long long a, atomic64_unchecked_t *v);
20774 +EXPORT_SYMBOL(atomic64_add_return_unchecked_386);
20775 long long atomic64_sub_return_386(long long a, atomic64_t *v);
20776 EXPORT_SYMBOL(atomic64_sub_return_386);
20777 +long long atomic64_sub_return_unchecked_386(long long a, atomic64_unchecked_t *v);
20778 +EXPORT_SYMBOL(atomic64_sub_return_unchecked_386);
20779 long long atomic64_inc_return_386(long long a, atomic64_t *v);
20780 EXPORT_SYMBOL(atomic64_inc_return_386);
20781 +long long atomic64_inc_return_unchecked_386(long long a, atomic64_unchecked_t *v);
20782 +EXPORT_SYMBOL(atomic64_inc_return_unchecked_386);
20783 long long atomic64_dec_return_386(long long a, atomic64_t *v);
20784 EXPORT_SYMBOL(atomic64_dec_return_386);
20785 +long long atomic64_dec_return_unchecked_386(long long a, atomic64_unchecked_t *v);
20786 +EXPORT_SYMBOL(atomic64_dec_return_unchecked_386);
20787 long long atomic64_add_386(long long a, atomic64_t *v);
20788 EXPORT_SYMBOL(atomic64_add_386);
20789 +long long atomic64_add_unchecked_386(long long a, atomic64_unchecked_t *v);
20790 +EXPORT_SYMBOL(atomic64_add_unchecked_386);
20791 long long atomic64_sub_386(long long a, atomic64_t *v);
20792 EXPORT_SYMBOL(atomic64_sub_386);
20793 +long long atomic64_sub_unchecked_386(long long a, atomic64_unchecked_t *v);
20794 +EXPORT_SYMBOL(atomic64_sub_unchecked_386);
20795 long long atomic64_inc_386(long long a, atomic64_t *v);
20796 EXPORT_SYMBOL(atomic64_inc_386);
20797 +long long atomic64_inc_unchecked_386(long long a, atomic64_unchecked_t *v);
20798 +EXPORT_SYMBOL(atomic64_inc_unchecked_386);
20799 long long atomic64_dec_386(long long a, atomic64_t *v);
20800 EXPORT_SYMBOL(atomic64_dec_386);
20801 +long long atomic64_dec_unchecked_386(long long a, atomic64_unchecked_t *v);
20802 +EXPORT_SYMBOL(atomic64_dec_unchecked_386);
20803 long long atomic64_dec_if_positive_386(atomic64_t *v);
20804 EXPORT_SYMBOL(atomic64_dec_if_positive_386);
20805 int atomic64_inc_not_zero_386(atomic64_t *v);
20806 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
20807 index e8e7e0d..56fd1b0 100644
20808 --- a/arch/x86/lib/atomic64_386_32.S
20809 +++ b/arch/x86/lib/atomic64_386_32.S
20810 @@ -48,6 +48,10 @@ BEGIN(read)
20811 movl (v), %eax
20812 movl 4(v), %edx
20813 RET_ENDP
20814 +BEGIN(read_unchecked)
20815 + movl (v), %eax
20816 + movl 4(v), %edx
20817 +RET_ENDP
20818 #undef v
20819
20820 #define v %esi
20821 @@ -55,6 +59,10 @@ BEGIN(set)
20822 movl %ebx, (v)
20823 movl %ecx, 4(v)
20824 RET_ENDP
20825 +BEGIN(set_unchecked)
20826 + movl %ebx, (v)
20827 + movl %ecx, 4(v)
20828 +RET_ENDP
20829 #undef v
20830
20831 #define v %esi
20832 @@ -70,6 +78,20 @@ RET_ENDP
20833 BEGIN(add)
20834 addl %eax, (v)
20835 adcl %edx, 4(v)
20836 +
20837 +#ifdef CONFIG_PAX_REFCOUNT
20838 + jno 0f
20839 + subl %eax, (v)
20840 + sbbl %edx, 4(v)
20841 + int $4
20842 +0:
20843 + _ASM_EXTABLE(0b, 0b)
20844 +#endif
20845 +
20846 +RET_ENDP
20847 +BEGIN(add_unchecked)
20848 + addl %eax, (v)
20849 + adcl %edx, 4(v)
20850 RET_ENDP
20851 #undef v
20852
20853 @@ -77,6 +99,24 @@ RET_ENDP
20854 BEGIN(add_return)
20855 addl (v), %eax
20856 adcl 4(v), %edx
20857 +
20858 +#ifdef CONFIG_PAX_REFCOUNT
20859 + into
20860 +1234:
20861 + _ASM_EXTABLE(1234b, 2f)
20862 +#endif
20863 +
20864 + movl %eax, (v)
20865 + movl %edx, 4(v)
20866 +
20867 +#ifdef CONFIG_PAX_REFCOUNT
20868 +2:
20869 +#endif
20870 +
20871 +RET_ENDP
20872 +BEGIN(add_return_unchecked)
20873 + addl (v), %eax
20874 + adcl 4(v), %edx
20875 movl %eax, (v)
20876 movl %edx, 4(v)
20877 RET_ENDP
20878 @@ -86,6 +126,20 @@ RET_ENDP
20879 BEGIN(sub)
20880 subl %eax, (v)
20881 sbbl %edx, 4(v)
20882 +
20883 +#ifdef CONFIG_PAX_REFCOUNT
20884 + jno 0f
20885 + addl %eax, (v)
20886 + adcl %edx, 4(v)
20887 + int $4
20888 +0:
20889 + _ASM_EXTABLE(0b, 0b)
20890 +#endif
20891 +
20892 +RET_ENDP
20893 +BEGIN(sub_unchecked)
20894 + subl %eax, (v)
20895 + sbbl %edx, 4(v)
20896 RET_ENDP
20897 #undef v
20898
20899 @@ -96,6 +150,27 @@ BEGIN(sub_return)
20900 sbbl $0, %edx
20901 addl (v), %eax
20902 adcl 4(v), %edx
20903 +
20904 +#ifdef CONFIG_PAX_REFCOUNT
20905 + into
20906 +1234:
20907 + _ASM_EXTABLE(1234b, 2f)
20908 +#endif
20909 +
20910 + movl %eax, (v)
20911 + movl %edx, 4(v)
20912 +
20913 +#ifdef CONFIG_PAX_REFCOUNT
20914 +2:
20915 +#endif
20916 +
20917 +RET_ENDP
20918 +BEGIN(sub_return_unchecked)
20919 + negl %edx
20920 + negl %eax
20921 + sbbl $0, %edx
20922 + addl (v), %eax
20923 + adcl 4(v), %edx
20924 movl %eax, (v)
20925 movl %edx, 4(v)
20926 RET_ENDP
20927 @@ -105,6 +180,20 @@ RET_ENDP
20928 BEGIN(inc)
20929 addl $1, (v)
20930 adcl $0, 4(v)
20931 +
20932 +#ifdef CONFIG_PAX_REFCOUNT
20933 + jno 0f
20934 + subl $1, (v)
20935 + sbbl $0, 4(v)
20936 + int $4
20937 +0:
20938 + _ASM_EXTABLE(0b, 0b)
20939 +#endif
20940 +
20941 +RET_ENDP
20942 +BEGIN(inc_unchecked)
20943 + addl $1, (v)
20944 + adcl $0, 4(v)
20945 RET_ENDP
20946 #undef v
20947
20948 @@ -114,6 +203,26 @@ BEGIN(inc_return)
20949 movl 4(v), %edx
20950 addl $1, %eax
20951 adcl $0, %edx
20952 +
20953 +#ifdef CONFIG_PAX_REFCOUNT
20954 + into
20955 +1234:
20956 + _ASM_EXTABLE(1234b, 2f)
20957 +#endif
20958 +
20959 + movl %eax, (v)
20960 + movl %edx, 4(v)
20961 +
20962 +#ifdef CONFIG_PAX_REFCOUNT
20963 +2:
20964 +#endif
20965 +
20966 +RET_ENDP
20967 +BEGIN(inc_return_unchecked)
20968 + movl (v), %eax
20969 + movl 4(v), %edx
20970 + addl $1, %eax
20971 + adcl $0, %edx
20972 movl %eax, (v)
20973 movl %edx, 4(v)
20974 RET_ENDP
20975 @@ -123,6 +232,20 @@ RET_ENDP
20976 BEGIN(dec)
20977 subl $1, (v)
20978 sbbl $0, 4(v)
20979 +
20980 +#ifdef CONFIG_PAX_REFCOUNT
20981 + jno 0f
20982 + addl $1, (v)
20983 + adcl $0, 4(v)
20984 + int $4
20985 +0:
20986 + _ASM_EXTABLE(0b, 0b)
20987 +#endif
20988 +
20989 +RET_ENDP
20990 +BEGIN(dec_unchecked)
20991 + subl $1, (v)
20992 + sbbl $0, 4(v)
20993 RET_ENDP
20994 #undef v
20995
20996 @@ -132,6 +255,26 @@ BEGIN(dec_return)
20997 movl 4(v), %edx
20998 subl $1, %eax
20999 sbbl $0, %edx
21000 +
21001 +#ifdef CONFIG_PAX_REFCOUNT
21002 + into
21003 +1234:
21004 + _ASM_EXTABLE(1234b, 2f)
21005 +#endif
21006 +
21007 + movl %eax, (v)
21008 + movl %edx, 4(v)
21009 +
21010 +#ifdef CONFIG_PAX_REFCOUNT
21011 +2:
21012 +#endif
21013 +
21014 +RET_ENDP
21015 +BEGIN(dec_return_unchecked)
21016 + movl (v), %eax
21017 + movl 4(v), %edx
21018 + subl $1, %eax
21019 + sbbl $0, %edx
21020 movl %eax, (v)
21021 movl %edx, 4(v)
21022 RET_ENDP
21023 @@ -143,6 +286,13 @@ BEGIN(add_unless)
21024 adcl %edx, %edi
21025 addl (v), %eax
21026 adcl 4(v), %edx
21027 +
21028 +#ifdef CONFIG_PAX_REFCOUNT
21029 + into
21030 +1234:
21031 + _ASM_EXTABLE(1234b, 2f)
21032 +#endif
21033 +
21034 cmpl %eax, %esi
21035 je 3f
21036 1:
21037 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
21038 1:
21039 addl $1, %eax
21040 adcl $0, %edx
21041 +
21042 +#ifdef CONFIG_PAX_REFCOUNT
21043 + into
21044 +1234:
21045 + _ASM_EXTABLE(1234b, 2f)
21046 +#endif
21047 +
21048 movl %eax, (v)
21049 movl %edx, 4(v)
21050 movl $1, %eax
21051 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
21052 movl 4(v), %edx
21053 subl $1, %eax
21054 sbbl $0, %edx
21055 +
21056 +#ifdef CONFIG_PAX_REFCOUNT
21057 + into
21058 +1234:
21059 + _ASM_EXTABLE(1234b, 1f)
21060 +#endif
21061 +
21062 js 1f
21063 movl %eax, (v)
21064 movl %edx, 4(v)
21065 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
21066 index 391a083..3a2cf39 100644
21067 --- a/arch/x86/lib/atomic64_cx8_32.S
21068 +++ b/arch/x86/lib/atomic64_cx8_32.S
21069 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
21070 CFI_STARTPROC
21071
21072 read64 %ecx
21073 + pax_force_retaddr
21074 ret
21075 CFI_ENDPROC
21076 ENDPROC(atomic64_read_cx8)
21077
21078 +ENTRY(atomic64_read_unchecked_cx8)
21079 + CFI_STARTPROC
21080 +
21081 + read64 %ecx
21082 + pax_force_retaddr
21083 + ret
21084 + CFI_ENDPROC
21085 +ENDPROC(atomic64_read_unchecked_cx8)
21086 +
21087 ENTRY(atomic64_set_cx8)
21088 CFI_STARTPROC
21089
21090 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
21091 cmpxchg8b (%esi)
21092 jne 1b
21093
21094 + pax_force_retaddr
21095 ret
21096 CFI_ENDPROC
21097 ENDPROC(atomic64_set_cx8)
21098
21099 +ENTRY(atomic64_set_unchecked_cx8)
21100 + CFI_STARTPROC
21101 +
21102 +1:
21103 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
21104 + * are atomic on 586 and newer */
21105 + cmpxchg8b (%esi)
21106 + jne 1b
21107 +
21108 + pax_force_retaddr
21109 + ret
21110 + CFI_ENDPROC
21111 +ENDPROC(atomic64_set_unchecked_cx8)
21112 +
21113 ENTRY(atomic64_xchg_cx8)
21114 CFI_STARTPROC
21115
21116 @@ -62,12 +87,13 @@ ENTRY(atomic64_xchg_cx8)
21117 cmpxchg8b (%esi)
21118 jne 1b
21119
21120 + pax_force_retaddr
21121 ret
21122 CFI_ENDPROC
21123 ENDPROC(atomic64_xchg_cx8)
21124
21125 -.macro addsub_return func ins insc
21126 -ENTRY(atomic64_\func\()_return_cx8)
21127 +.macro addsub_return func ins insc unchecked=""
21128 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
21129 CFI_STARTPROC
21130 SAVE ebp
21131 SAVE ebx
21132 @@ -84,27 +110,44 @@ ENTRY(atomic64_\func\()_return_cx8)
21133 movl %edx, %ecx
21134 \ins\()l %esi, %ebx
21135 \insc\()l %edi, %ecx
21136 +
21137 +.ifb \unchecked
21138 +#ifdef CONFIG_PAX_REFCOUNT
21139 + into
21140 +2:
21141 + _ASM_EXTABLE(2b, 3f)
21142 +#endif
21143 +.endif
21144 +
21145 LOCK_PREFIX
21146 cmpxchg8b (%ebp)
21147 jne 1b
21148 -
21149 -10:
21150 movl %ebx, %eax
21151 movl %ecx, %edx
21152 +
21153 +.ifb \unchecked
21154 +#ifdef CONFIG_PAX_REFCOUNT
21155 +3:
21156 +#endif
21157 +.endif
21158 +
21159 RESTORE edi
21160 RESTORE esi
21161 RESTORE ebx
21162 RESTORE ebp
21163 + pax_force_retaddr
21164 ret
21165 CFI_ENDPROC
21166 -ENDPROC(atomic64_\func\()_return_cx8)
21167 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
21168 .endm
21169
21170 addsub_return add add adc
21171 addsub_return sub sub sbb
21172 +addsub_return add add adc _unchecked
21173 +addsub_return sub sub sbb _unchecked
21174
21175 -.macro incdec_return func ins insc
21176 -ENTRY(atomic64_\func\()_return_cx8)
21177 +.macro incdec_return func ins insc unchecked=""
21178 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
21179 CFI_STARTPROC
21180 SAVE ebx
21181
21182 @@ -114,21 +157,39 @@ ENTRY(atomic64_\func\()_return_cx8)
21183 movl %edx, %ecx
21184 \ins\()l $1, %ebx
21185 \insc\()l $0, %ecx
21186 +
21187 +.ifb \unchecked
21188 +#ifdef CONFIG_PAX_REFCOUNT
21189 + into
21190 +2:
21191 + _ASM_EXTABLE(2b, 3f)
21192 +#endif
21193 +.endif
21194 +
21195 LOCK_PREFIX
21196 cmpxchg8b (%esi)
21197 jne 1b
21198
21199 -10:
21200 movl %ebx, %eax
21201 movl %ecx, %edx
21202 +
21203 +.ifb \unchecked
21204 +#ifdef CONFIG_PAX_REFCOUNT
21205 +3:
21206 +#endif
21207 +.endif
21208 +
21209 RESTORE ebx
21210 + pax_force_retaddr
21211 ret
21212 CFI_ENDPROC
21213 -ENDPROC(atomic64_\func\()_return_cx8)
21214 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
21215 .endm
21216
21217 incdec_return inc add adc
21218 incdec_return dec sub sbb
21219 +incdec_return inc add adc _unchecked
21220 +incdec_return dec sub sbb _unchecked
21221
21222 ENTRY(atomic64_dec_if_positive_cx8)
21223 CFI_STARTPROC
21224 @@ -140,6 +201,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
21225 movl %edx, %ecx
21226 subl $1, %ebx
21227 sbb $0, %ecx
21228 +
21229 +#ifdef CONFIG_PAX_REFCOUNT
21230 + into
21231 +1234:
21232 + _ASM_EXTABLE(1234b, 2f)
21233 +#endif
21234 +
21235 js 2f
21236 LOCK_PREFIX
21237 cmpxchg8b (%esi)
21238 @@ -149,6 +217,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
21239 movl %ebx, %eax
21240 movl %ecx, %edx
21241 RESTORE ebx
21242 + pax_force_retaddr
21243 ret
21244 CFI_ENDPROC
21245 ENDPROC(atomic64_dec_if_positive_cx8)
21246 @@ -174,6 +243,13 @@ ENTRY(atomic64_add_unless_cx8)
21247 movl %edx, %ecx
21248 addl %esi, %ebx
21249 adcl %edi, %ecx
21250 +
21251 +#ifdef CONFIG_PAX_REFCOUNT
21252 + into
21253 +1234:
21254 + _ASM_EXTABLE(1234b, 3f)
21255 +#endif
21256 +
21257 LOCK_PREFIX
21258 cmpxchg8b (%ebp)
21259 jne 1b
21260 @@ -184,6 +260,7 @@ ENTRY(atomic64_add_unless_cx8)
21261 CFI_ADJUST_CFA_OFFSET -8
21262 RESTORE ebx
21263 RESTORE ebp
21264 + pax_force_retaddr
21265 ret
21266 4:
21267 cmpl %edx, 4(%esp)
21268 @@ -206,6 +283,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
21269 movl %edx, %ecx
21270 addl $1, %ebx
21271 adcl $0, %ecx
21272 +
21273 +#ifdef CONFIG_PAX_REFCOUNT
21274 + into
21275 +1234:
21276 + _ASM_EXTABLE(1234b, 3f)
21277 +#endif
21278 +
21279 LOCK_PREFIX
21280 cmpxchg8b (%esi)
21281 jne 1b
21282 @@ -213,6 +297,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
21283 movl $1, %eax
21284 3:
21285 RESTORE ebx
21286 + pax_force_retaddr
21287 ret
21288 4:
21289 testl %edx, %edx
21290 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
21291 index 78d16a5..fbcf666 100644
21292 --- a/arch/x86/lib/checksum_32.S
21293 +++ b/arch/x86/lib/checksum_32.S
21294 @@ -28,7 +28,8 @@
21295 #include <linux/linkage.h>
21296 #include <asm/dwarf2.h>
21297 #include <asm/errno.h>
21298 -
21299 +#include <asm/segment.h>
21300 +
21301 /*
21302 * computes a partial checksum, e.g. for TCP/UDP fragments
21303 */
21304 @@ -296,9 +297,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
21305
21306 #define ARGBASE 16
21307 #define FP 12
21308 -
21309 -ENTRY(csum_partial_copy_generic)
21310 +
21311 +ENTRY(csum_partial_copy_generic_to_user)
21312 CFI_STARTPROC
21313 +
21314 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21315 + pushl_cfi %gs
21316 + popl_cfi %es
21317 + jmp csum_partial_copy_generic
21318 +#endif
21319 +
21320 +ENTRY(csum_partial_copy_generic_from_user)
21321 +
21322 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21323 + pushl_cfi %gs
21324 + popl_cfi %ds
21325 +#endif
21326 +
21327 +ENTRY(csum_partial_copy_generic)
21328 subl $4,%esp
21329 CFI_ADJUST_CFA_OFFSET 4
21330 pushl_cfi %edi
21331 @@ -320,7 +336,7 @@ ENTRY(csum_partial_copy_generic)
21332 jmp 4f
21333 SRC(1: movw (%esi), %bx )
21334 addl $2, %esi
21335 -DST( movw %bx, (%edi) )
21336 +DST( movw %bx, %es:(%edi) )
21337 addl $2, %edi
21338 addw %bx, %ax
21339 adcl $0, %eax
21340 @@ -332,30 +348,30 @@ DST( movw %bx, (%edi) )
21341 SRC(1: movl (%esi), %ebx )
21342 SRC( movl 4(%esi), %edx )
21343 adcl %ebx, %eax
21344 -DST( movl %ebx, (%edi) )
21345 +DST( movl %ebx, %es:(%edi) )
21346 adcl %edx, %eax
21347 -DST( movl %edx, 4(%edi) )
21348 +DST( movl %edx, %es:4(%edi) )
21349
21350 SRC( movl 8(%esi), %ebx )
21351 SRC( movl 12(%esi), %edx )
21352 adcl %ebx, %eax
21353 -DST( movl %ebx, 8(%edi) )
21354 +DST( movl %ebx, %es:8(%edi) )
21355 adcl %edx, %eax
21356 -DST( movl %edx, 12(%edi) )
21357 +DST( movl %edx, %es:12(%edi) )
21358
21359 SRC( movl 16(%esi), %ebx )
21360 SRC( movl 20(%esi), %edx )
21361 adcl %ebx, %eax
21362 -DST( movl %ebx, 16(%edi) )
21363 +DST( movl %ebx, %es:16(%edi) )
21364 adcl %edx, %eax
21365 -DST( movl %edx, 20(%edi) )
21366 +DST( movl %edx, %es:20(%edi) )
21367
21368 SRC( movl 24(%esi), %ebx )
21369 SRC( movl 28(%esi), %edx )
21370 adcl %ebx, %eax
21371 -DST( movl %ebx, 24(%edi) )
21372 +DST( movl %ebx, %es:24(%edi) )
21373 adcl %edx, %eax
21374 -DST( movl %edx, 28(%edi) )
21375 +DST( movl %edx, %es:28(%edi) )
21376
21377 lea 32(%esi), %esi
21378 lea 32(%edi), %edi
21379 @@ -369,7 +385,7 @@ DST( movl %edx, 28(%edi) )
21380 shrl $2, %edx # This clears CF
21381 SRC(3: movl (%esi), %ebx )
21382 adcl %ebx, %eax
21383 -DST( movl %ebx, (%edi) )
21384 +DST( movl %ebx, %es:(%edi) )
21385 lea 4(%esi), %esi
21386 lea 4(%edi), %edi
21387 dec %edx
21388 @@ -381,12 +397,12 @@ DST( movl %ebx, (%edi) )
21389 jb 5f
21390 SRC( movw (%esi), %cx )
21391 leal 2(%esi), %esi
21392 -DST( movw %cx, (%edi) )
21393 +DST( movw %cx, %es:(%edi) )
21394 leal 2(%edi), %edi
21395 je 6f
21396 shll $16,%ecx
21397 SRC(5: movb (%esi), %cl )
21398 -DST( movb %cl, (%edi) )
21399 +DST( movb %cl, %es:(%edi) )
21400 6: addl %ecx, %eax
21401 adcl $0, %eax
21402 7:
21403 @@ -397,7 +413,7 @@ DST( movb %cl, (%edi) )
21404
21405 6001:
21406 movl ARGBASE+20(%esp), %ebx # src_err_ptr
21407 - movl $-EFAULT, (%ebx)
21408 + movl $-EFAULT, %ss:(%ebx)
21409
21410 # zero the complete destination - computing the rest
21411 # is too much work
21412 @@ -410,11 +426,15 @@ DST( movb %cl, (%edi) )
21413
21414 6002:
21415 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
21416 - movl $-EFAULT,(%ebx)
21417 + movl $-EFAULT,%ss:(%ebx)
21418 jmp 5000b
21419
21420 .previous
21421
21422 + pushl_cfi %ss
21423 + popl_cfi %ds
21424 + pushl_cfi %ss
21425 + popl_cfi %es
21426 popl_cfi %ebx
21427 CFI_RESTORE ebx
21428 popl_cfi %esi
21429 @@ -424,26 +444,43 @@ DST( movb %cl, (%edi) )
21430 popl_cfi %ecx # equivalent to addl $4,%esp
21431 ret
21432 CFI_ENDPROC
21433 -ENDPROC(csum_partial_copy_generic)
21434 +ENDPROC(csum_partial_copy_generic_to_user)
21435
21436 #else
21437
21438 /* Version for PentiumII/PPro */
21439
21440 #define ROUND1(x) \
21441 + nop; nop; nop; \
21442 SRC(movl x(%esi), %ebx ) ; \
21443 addl %ebx, %eax ; \
21444 - DST(movl %ebx, x(%edi) ) ;
21445 + DST(movl %ebx, %es:x(%edi)) ;
21446
21447 #define ROUND(x) \
21448 + nop; nop; nop; \
21449 SRC(movl x(%esi), %ebx ) ; \
21450 adcl %ebx, %eax ; \
21451 - DST(movl %ebx, x(%edi) ) ;
21452 + DST(movl %ebx, %es:x(%edi)) ;
21453
21454 #define ARGBASE 12
21455 -
21456 -ENTRY(csum_partial_copy_generic)
21457 +
21458 +ENTRY(csum_partial_copy_generic_to_user)
21459 CFI_STARTPROC
21460 +
21461 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21462 + pushl_cfi %gs
21463 + popl_cfi %es
21464 + jmp csum_partial_copy_generic
21465 +#endif
21466 +
21467 +ENTRY(csum_partial_copy_generic_from_user)
21468 +
21469 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21470 + pushl_cfi %gs
21471 + popl_cfi %ds
21472 +#endif
21473 +
21474 +ENTRY(csum_partial_copy_generic)
21475 pushl_cfi %ebx
21476 CFI_REL_OFFSET ebx, 0
21477 pushl_cfi %edi
21478 @@ -464,7 +501,7 @@ ENTRY(csum_partial_copy_generic)
21479 subl %ebx, %edi
21480 lea -1(%esi),%edx
21481 andl $-32,%edx
21482 - lea 3f(%ebx,%ebx), %ebx
21483 + lea 3f(%ebx,%ebx,2), %ebx
21484 testl %esi, %esi
21485 jmp *%ebx
21486 1: addl $64,%esi
21487 @@ -485,19 +522,19 @@ ENTRY(csum_partial_copy_generic)
21488 jb 5f
21489 SRC( movw (%esi), %dx )
21490 leal 2(%esi), %esi
21491 -DST( movw %dx, (%edi) )
21492 +DST( movw %dx, %es:(%edi) )
21493 leal 2(%edi), %edi
21494 je 6f
21495 shll $16,%edx
21496 5:
21497 SRC( movb (%esi), %dl )
21498 -DST( movb %dl, (%edi) )
21499 +DST( movb %dl, %es:(%edi) )
21500 6: addl %edx, %eax
21501 adcl $0, %eax
21502 7:
21503 .section .fixup, "ax"
21504 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
21505 - movl $-EFAULT, (%ebx)
21506 + movl $-EFAULT, %ss:(%ebx)
21507 # zero the complete destination (computing the rest is too much work)
21508 movl ARGBASE+8(%esp),%edi # dst
21509 movl ARGBASE+12(%esp),%ecx # len
21510 @@ -505,10 +542,17 @@ DST( movb %dl, (%edi) )
21511 rep; stosb
21512 jmp 7b
21513 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
21514 - movl $-EFAULT, (%ebx)
21515 + movl $-EFAULT, %ss:(%ebx)
21516 jmp 7b
21517 .previous
21518
21519 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21520 + pushl_cfi %ss
21521 + popl_cfi %ds
21522 + pushl_cfi %ss
21523 + popl_cfi %es
21524 +#endif
21525 +
21526 popl_cfi %esi
21527 CFI_RESTORE esi
21528 popl_cfi %edi
21529 @@ -517,7 +561,7 @@ DST( movb %dl, (%edi) )
21530 CFI_RESTORE ebx
21531 ret
21532 CFI_ENDPROC
21533 -ENDPROC(csum_partial_copy_generic)
21534 +ENDPROC(csum_partial_copy_generic_to_user)
21535
21536 #undef ROUND
21537 #undef ROUND1
21538 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
21539 index f2145cf..cea889d 100644
21540 --- a/arch/x86/lib/clear_page_64.S
21541 +++ b/arch/x86/lib/clear_page_64.S
21542 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
21543 movl $4096/8,%ecx
21544 xorl %eax,%eax
21545 rep stosq
21546 + pax_force_retaddr
21547 ret
21548 CFI_ENDPROC
21549 ENDPROC(clear_page_c)
21550 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
21551 movl $4096,%ecx
21552 xorl %eax,%eax
21553 rep stosb
21554 + pax_force_retaddr
21555 ret
21556 CFI_ENDPROC
21557 ENDPROC(clear_page_c_e)
21558 @@ -43,6 +45,7 @@ ENTRY(clear_page)
21559 leaq 64(%rdi),%rdi
21560 jnz .Lloop
21561 nop
21562 + pax_force_retaddr
21563 ret
21564 CFI_ENDPROC
21565 .Lclear_page_end:
21566 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
21567
21568 #include <asm/cpufeature.h>
21569
21570 - .section .altinstr_replacement,"ax"
21571 + .section .altinstr_replacement,"a"
21572 1: .byte 0xeb /* jmp <disp8> */
21573 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
21574 2: .byte 0xeb /* jmp <disp8> */
21575 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
21576 index 1e572c5..2a162cd 100644
21577 --- a/arch/x86/lib/cmpxchg16b_emu.S
21578 +++ b/arch/x86/lib/cmpxchg16b_emu.S
21579 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
21580
21581 popf
21582 mov $1, %al
21583 + pax_force_retaddr
21584 ret
21585
21586 not_same:
21587 popf
21588 xor %al,%al
21589 + pax_force_retaddr
21590 ret
21591
21592 CFI_ENDPROC
21593 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
21594 index 01c805b..dccb07f 100644
21595 --- a/arch/x86/lib/copy_page_64.S
21596 +++ b/arch/x86/lib/copy_page_64.S
21597 @@ -9,6 +9,7 @@ copy_page_c:
21598 CFI_STARTPROC
21599 movl $4096/8,%ecx
21600 rep movsq
21601 + pax_force_retaddr
21602 ret
21603 CFI_ENDPROC
21604 ENDPROC(copy_page_c)
21605 @@ -39,7 +40,7 @@ ENTRY(copy_page)
21606 movq 16 (%rsi), %rdx
21607 movq 24 (%rsi), %r8
21608 movq 32 (%rsi), %r9
21609 - movq 40 (%rsi), %r10
21610 + movq 40 (%rsi), %r13
21611 movq 48 (%rsi), %r11
21612 movq 56 (%rsi), %r12
21613
21614 @@ -50,7 +51,7 @@ ENTRY(copy_page)
21615 movq %rdx, 16 (%rdi)
21616 movq %r8, 24 (%rdi)
21617 movq %r9, 32 (%rdi)
21618 - movq %r10, 40 (%rdi)
21619 + movq %r13, 40 (%rdi)
21620 movq %r11, 48 (%rdi)
21621 movq %r12, 56 (%rdi)
21622
21623 @@ -69,7 +70,7 @@ ENTRY(copy_page)
21624 movq 16 (%rsi), %rdx
21625 movq 24 (%rsi), %r8
21626 movq 32 (%rsi), %r9
21627 - movq 40 (%rsi), %r10
21628 + movq 40 (%rsi), %r13
21629 movq 48 (%rsi), %r11
21630 movq 56 (%rsi), %r12
21631
21632 @@ -78,7 +79,7 @@ ENTRY(copy_page)
21633 movq %rdx, 16 (%rdi)
21634 movq %r8, 24 (%rdi)
21635 movq %r9, 32 (%rdi)
21636 - movq %r10, 40 (%rdi)
21637 + movq %r13, 40 (%rdi)
21638 movq %r11, 48 (%rdi)
21639 movq %r12, 56 (%rdi)
21640
21641 @@ -95,6 +96,7 @@ ENTRY(copy_page)
21642 CFI_RESTORE r13
21643 addq $3*8,%rsp
21644 CFI_ADJUST_CFA_OFFSET -3*8
21645 + pax_force_retaddr
21646 ret
21647 .Lcopy_page_end:
21648 CFI_ENDPROC
21649 @@ -105,7 +107,7 @@ ENDPROC(copy_page)
21650
21651 #include <asm/cpufeature.h>
21652
21653 - .section .altinstr_replacement,"ax"
21654 + .section .altinstr_replacement,"a"
21655 1: .byte 0xeb /* jmp <disp8> */
21656 .byte (copy_page_c - copy_page) - (2f - 1b) /* offset */
21657 2:
21658 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
21659 index 0248402..821c786 100644
21660 --- a/arch/x86/lib/copy_user_64.S
21661 +++ b/arch/x86/lib/copy_user_64.S
21662 @@ -16,6 +16,7 @@
21663 #include <asm/thread_info.h>
21664 #include <asm/cpufeature.h>
21665 #include <asm/alternative-asm.h>
21666 +#include <asm/pgtable.h>
21667
21668 /*
21669 * By placing feature2 after feature1 in altinstructions section, we logically
21670 @@ -29,7 +30,7 @@
21671 .byte 0xe9 /* 32bit jump */
21672 .long \orig-1f /* by default jump to orig */
21673 1:
21674 - .section .altinstr_replacement,"ax"
21675 + .section .altinstr_replacement,"a"
21676 2: .byte 0xe9 /* near jump with 32bit immediate */
21677 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
21678 3: .byte 0xe9 /* near jump with 32bit immediate */
21679 @@ -71,47 +72,20 @@
21680 #endif
21681 .endm
21682
21683 -/* Standard copy_to_user with segment limit checking */
21684 -ENTRY(_copy_to_user)
21685 - CFI_STARTPROC
21686 - GET_THREAD_INFO(%rax)
21687 - movq %rdi,%rcx
21688 - addq %rdx,%rcx
21689 - jc bad_to_user
21690 - cmpq TI_addr_limit(%rax),%rcx
21691 - ja bad_to_user
21692 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
21693 - copy_user_generic_unrolled,copy_user_generic_string, \
21694 - copy_user_enhanced_fast_string
21695 - CFI_ENDPROC
21696 -ENDPROC(_copy_to_user)
21697 -
21698 -/* Standard copy_from_user with segment limit checking */
21699 -ENTRY(_copy_from_user)
21700 - CFI_STARTPROC
21701 - GET_THREAD_INFO(%rax)
21702 - movq %rsi,%rcx
21703 - addq %rdx,%rcx
21704 - jc bad_from_user
21705 - cmpq TI_addr_limit(%rax),%rcx
21706 - ja bad_from_user
21707 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
21708 - copy_user_generic_unrolled,copy_user_generic_string, \
21709 - copy_user_enhanced_fast_string
21710 - CFI_ENDPROC
21711 -ENDPROC(_copy_from_user)
21712 -
21713 .section .fixup,"ax"
21714 /* must zero dest */
21715 ENTRY(bad_from_user)
21716 bad_from_user:
21717 CFI_STARTPROC
21718 + testl %edx,%edx
21719 + js bad_to_user
21720 movl %edx,%ecx
21721 xorl %eax,%eax
21722 rep
21723 stosb
21724 bad_to_user:
21725 movl %edx,%eax
21726 + pax_force_retaddr
21727 ret
21728 CFI_ENDPROC
21729 ENDPROC(bad_from_user)
21730 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
21731 jz 17f
21732 1: movq (%rsi),%r8
21733 2: movq 1*8(%rsi),%r9
21734 -3: movq 2*8(%rsi),%r10
21735 +3: movq 2*8(%rsi),%rax
21736 4: movq 3*8(%rsi),%r11
21737 5: movq %r8,(%rdi)
21738 6: movq %r9,1*8(%rdi)
21739 -7: movq %r10,2*8(%rdi)
21740 +7: movq %rax,2*8(%rdi)
21741 8: movq %r11,3*8(%rdi)
21742 9: movq 4*8(%rsi),%r8
21743 10: movq 5*8(%rsi),%r9
21744 -11: movq 6*8(%rsi),%r10
21745 +11: movq 6*8(%rsi),%rax
21746 12: movq 7*8(%rsi),%r11
21747 13: movq %r8,4*8(%rdi)
21748 14: movq %r9,5*8(%rdi)
21749 -15: movq %r10,6*8(%rdi)
21750 +15: movq %rax,6*8(%rdi)
21751 16: movq %r11,7*8(%rdi)
21752 leaq 64(%rsi),%rsi
21753 leaq 64(%rdi),%rdi
21754 @@ -179,6 +153,7 @@ ENTRY(copy_user_generic_unrolled)
21755 decl %ecx
21756 jnz 21b
21757 23: xor %eax,%eax
21758 + pax_force_retaddr
21759 ret
21760
21761 .section .fixup,"ax"
21762 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
21763 3: rep
21764 movsb
21765 4: xorl %eax,%eax
21766 + pax_force_retaddr
21767 ret
21768
21769 .section .fixup,"ax"
21770 @@ -287,6 +263,7 @@ ENTRY(copy_user_enhanced_fast_string)
21771 1: rep
21772 movsb
21773 2: xorl %eax,%eax
21774 + pax_force_retaddr
21775 ret
21776
21777 .section .fixup,"ax"
21778 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
21779 index cb0c112..e3a6895 100644
21780 --- a/arch/x86/lib/copy_user_nocache_64.S
21781 +++ b/arch/x86/lib/copy_user_nocache_64.S
21782 @@ -8,12 +8,14 @@
21783
21784 #include <linux/linkage.h>
21785 #include <asm/dwarf2.h>
21786 +#include <asm/alternative-asm.h>
21787
21788 #define FIX_ALIGNMENT 1
21789
21790 #include <asm/current.h>
21791 #include <asm/asm-offsets.h>
21792 #include <asm/thread_info.h>
21793 +#include <asm/pgtable.h>
21794
21795 .macro ALIGN_DESTINATION
21796 #ifdef FIX_ALIGNMENT
21797 @@ -50,6 +52,15 @@
21798 */
21799 ENTRY(__copy_user_nocache)
21800 CFI_STARTPROC
21801 +
21802 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21803 + mov $PAX_USER_SHADOW_BASE,%rcx
21804 + cmp %rcx,%rsi
21805 + jae 1f
21806 + add %rcx,%rsi
21807 +1:
21808 +#endif
21809 +
21810 cmpl $8,%edx
21811 jb 20f /* less then 8 bytes, go to byte copy loop */
21812 ALIGN_DESTINATION
21813 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
21814 jz 17f
21815 1: movq (%rsi),%r8
21816 2: movq 1*8(%rsi),%r9
21817 -3: movq 2*8(%rsi),%r10
21818 +3: movq 2*8(%rsi),%rax
21819 4: movq 3*8(%rsi),%r11
21820 5: movnti %r8,(%rdi)
21821 6: movnti %r9,1*8(%rdi)
21822 -7: movnti %r10,2*8(%rdi)
21823 +7: movnti %rax,2*8(%rdi)
21824 8: movnti %r11,3*8(%rdi)
21825 9: movq 4*8(%rsi),%r8
21826 10: movq 5*8(%rsi),%r9
21827 -11: movq 6*8(%rsi),%r10
21828 +11: movq 6*8(%rsi),%rax
21829 12: movq 7*8(%rsi),%r11
21830 13: movnti %r8,4*8(%rdi)
21831 14: movnti %r9,5*8(%rdi)
21832 -15: movnti %r10,6*8(%rdi)
21833 +15: movnti %rax,6*8(%rdi)
21834 16: movnti %r11,7*8(%rdi)
21835 leaq 64(%rsi),%rsi
21836 leaq 64(%rdi),%rdi
21837 @@ -98,6 +109,7 @@ ENTRY(__copy_user_nocache)
21838 jnz 21b
21839 23: xorl %eax,%eax
21840 sfence
21841 + pax_force_retaddr
21842 ret
21843
21844 .section .fixup,"ax"
21845 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
21846 index fb903b7..c92b7f7 100644
21847 --- a/arch/x86/lib/csum-copy_64.S
21848 +++ b/arch/x86/lib/csum-copy_64.S
21849 @@ -8,6 +8,7 @@
21850 #include <linux/linkage.h>
21851 #include <asm/dwarf2.h>
21852 #include <asm/errno.h>
21853 +#include <asm/alternative-asm.h>
21854
21855 /*
21856 * Checksum copy with exception handling.
21857 @@ -228,6 +229,7 @@ ENTRY(csum_partial_copy_generic)
21858 CFI_RESTORE rbp
21859 addq $7*8, %rsp
21860 CFI_ADJUST_CFA_OFFSET -7*8
21861 + pax_force_retaddr 0, 1
21862 ret
21863 CFI_RESTORE_STATE
21864
21865 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
21866 index 459b58a..9570bc7 100644
21867 --- a/arch/x86/lib/csum-wrappers_64.c
21868 +++ b/arch/x86/lib/csum-wrappers_64.c
21869 @@ -52,7 +52,13 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
21870 len -= 2;
21871 }
21872 }
21873 - isum = csum_partial_copy_generic((__force const void *)src,
21874 +
21875 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21876 + if ((unsigned long)src < PAX_USER_SHADOW_BASE)
21877 + src += PAX_USER_SHADOW_BASE;
21878 +#endif
21879 +
21880 + isum = csum_partial_copy_generic((const void __force_kernel *)src,
21881 dst, len, isum, errp, NULL);
21882 if (unlikely(*errp))
21883 goto out_err;
21884 @@ -105,7 +111,13 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
21885 }
21886
21887 *errp = 0;
21888 - return csum_partial_copy_generic(src, (void __force *)dst,
21889 +
21890 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21891 + if ((unsigned long)dst < PAX_USER_SHADOW_BASE)
21892 + dst += PAX_USER_SHADOW_BASE;
21893 +#endif
21894 +
21895 + return csum_partial_copy_generic(src, (void __force_kernel *)dst,
21896 len, isum, NULL, errp);
21897 }
21898 EXPORT_SYMBOL(csum_partial_copy_to_user);
21899 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
21900 index 51f1504..ddac4c1 100644
21901 --- a/arch/x86/lib/getuser.S
21902 +++ b/arch/x86/lib/getuser.S
21903 @@ -33,15 +33,38 @@
21904 #include <asm/asm-offsets.h>
21905 #include <asm/thread_info.h>
21906 #include <asm/asm.h>
21907 +#include <asm/segment.h>
21908 +#include <asm/pgtable.h>
21909 +#include <asm/alternative-asm.h>
21910 +
21911 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
21912 +#define __copyuser_seg gs;
21913 +#else
21914 +#define __copyuser_seg
21915 +#endif
21916
21917 .text
21918 ENTRY(__get_user_1)
21919 CFI_STARTPROC
21920 +
21921 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
21922 GET_THREAD_INFO(%_ASM_DX)
21923 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
21924 jae bad_get_user
21925 -1: movzb (%_ASM_AX),%edx
21926 +
21927 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
21928 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
21929 + cmp %_ASM_DX,%_ASM_AX
21930 + jae 1234f
21931 + add %_ASM_DX,%_ASM_AX
21932 +1234:
21933 +#endif
21934 +
21935 +#endif
21936 +
21937 +1: __copyuser_seg movzb (%_ASM_AX),%edx
21938 xor %eax,%eax
21939 + pax_force_retaddr
21940 ret
21941 CFI_ENDPROC
21942 ENDPROC(__get_user_1)
21943 @@ -49,12 +72,26 @@ ENDPROC(__get_user_1)
21944 ENTRY(__get_user_2)
21945 CFI_STARTPROC
21946 add $1,%_ASM_AX
21947 +
21948 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
21949 jc bad_get_user
21950 GET_THREAD_INFO(%_ASM_DX)
21951 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
21952 jae bad_get_user
21953 -2: movzwl -1(%_ASM_AX),%edx
21954 +
21955 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
21956 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
21957 + cmp %_ASM_DX,%_ASM_AX
21958 + jae 1234f
21959 + add %_ASM_DX,%_ASM_AX
21960 +1234:
21961 +#endif
21962 +
21963 +#endif
21964 +
21965 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
21966 xor %eax,%eax
21967 + pax_force_retaddr
21968 ret
21969 CFI_ENDPROC
21970 ENDPROC(__get_user_2)
21971 @@ -62,12 +99,26 @@ ENDPROC(__get_user_2)
21972 ENTRY(__get_user_4)
21973 CFI_STARTPROC
21974 add $3,%_ASM_AX
21975 +
21976 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
21977 jc bad_get_user
21978 GET_THREAD_INFO(%_ASM_DX)
21979 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
21980 jae bad_get_user
21981 -3: mov -3(%_ASM_AX),%edx
21982 +
21983 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
21984 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
21985 + cmp %_ASM_DX,%_ASM_AX
21986 + jae 1234f
21987 + add %_ASM_DX,%_ASM_AX
21988 +1234:
21989 +#endif
21990 +
21991 +#endif
21992 +
21993 +3: __copyuser_seg mov -3(%_ASM_AX),%edx
21994 xor %eax,%eax
21995 + pax_force_retaddr
21996 ret
21997 CFI_ENDPROC
21998 ENDPROC(__get_user_4)
21999 @@ -80,8 +131,18 @@ ENTRY(__get_user_8)
22000 GET_THREAD_INFO(%_ASM_DX)
22001 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
22002 jae bad_get_user
22003 +
22004 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22005 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
22006 + cmp %_ASM_DX,%_ASM_AX
22007 + jae 1234f
22008 + add %_ASM_DX,%_ASM_AX
22009 +1234:
22010 +#endif
22011 +
22012 4: movq -7(%_ASM_AX),%_ASM_DX
22013 xor %eax,%eax
22014 + pax_force_retaddr
22015 ret
22016 CFI_ENDPROC
22017 ENDPROC(__get_user_8)
22018 @@ -91,6 +152,7 @@ bad_get_user:
22019 CFI_STARTPROC
22020 xor %edx,%edx
22021 mov $(-EFAULT),%_ASM_AX
22022 + pax_force_retaddr
22023 ret
22024 CFI_ENDPROC
22025 END(bad_get_user)
22026 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
22027 index 5a1f9f3..ba9f577 100644
22028 --- a/arch/x86/lib/insn.c
22029 +++ b/arch/x86/lib/insn.c
22030 @@ -21,6 +21,11 @@
22031 #include <linux/string.h>
22032 #include <asm/inat.h>
22033 #include <asm/insn.h>
22034 +#ifdef __KERNEL__
22035 +#include <asm/pgtable_types.h>
22036 +#else
22037 +#define ktla_ktva(addr) addr
22038 +#endif
22039
22040 /* Verify next sizeof(t) bytes can be on the same instruction */
22041 #define validate_next(t, insn, n) \
22042 @@ -49,8 +54,8 @@
22043 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
22044 {
22045 memset(insn, 0, sizeof(*insn));
22046 - insn->kaddr = kaddr;
22047 - insn->next_byte = kaddr;
22048 + insn->kaddr = ktla_ktva(kaddr);
22049 + insn->next_byte = ktla_ktva(kaddr);
22050 insn->x86_64 = x86_64 ? 1 : 0;
22051 insn->opnd_bytes = 4;
22052 if (x86_64)
22053 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
22054 index 05a95e7..326f2fa 100644
22055 --- a/arch/x86/lib/iomap_copy_64.S
22056 +++ b/arch/x86/lib/iomap_copy_64.S
22057 @@ -17,6 +17,7 @@
22058
22059 #include <linux/linkage.h>
22060 #include <asm/dwarf2.h>
22061 +#include <asm/alternative-asm.h>
22062
22063 /*
22064 * override generic version in lib/iomap_copy.c
22065 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
22066 CFI_STARTPROC
22067 movl %edx,%ecx
22068 rep movsd
22069 + pax_force_retaddr
22070 ret
22071 CFI_ENDPROC
22072 ENDPROC(__iowrite32_copy)
22073 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
22074 index efbf2a0..8893637 100644
22075 --- a/arch/x86/lib/memcpy_64.S
22076 +++ b/arch/x86/lib/memcpy_64.S
22077 @@ -34,6 +34,7 @@
22078 rep movsq
22079 movl %edx, %ecx
22080 rep movsb
22081 + pax_force_retaddr
22082 ret
22083 .Lmemcpy_e:
22084 .previous
22085 @@ -51,6 +52,7 @@
22086
22087 movl %edx, %ecx
22088 rep movsb
22089 + pax_force_retaddr
22090 ret
22091 .Lmemcpy_e_e:
22092 .previous
22093 @@ -81,13 +83,13 @@ ENTRY(memcpy)
22094 */
22095 movq 0*8(%rsi), %r8
22096 movq 1*8(%rsi), %r9
22097 - movq 2*8(%rsi), %r10
22098 + movq 2*8(%rsi), %rcx
22099 movq 3*8(%rsi), %r11
22100 leaq 4*8(%rsi), %rsi
22101
22102 movq %r8, 0*8(%rdi)
22103 movq %r9, 1*8(%rdi)
22104 - movq %r10, 2*8(%rdi)
22105 + movq %rcx, 2*8(%rdi)
22106 movq %r11, 3*8(%rdi)
22107 leaq 4*8(%rdi), %rdi
22108 jae .Lcopy_forward_loop
22109 @@ -110,12 +112,12 @@ ENTRY(memcpy)
22110 subq $0x20, %rdx
22111 movq -1*8(%rsi), %r8
22112 movq -2*8(%rsi), %r9
22113 - movq -3*8(%rsi), %r10
22114 + movq -3*8(%rsi), %rcx
22115 movq -4*8(%rsi), %r11
22116 leaq -4*8(%rsi), %rsi
22117 movq %r8, -1*8(%rdi)
22118 movq %r9, -2*8(%rdi)
22119 - movq %r10, -3*8(%rdi)
22120 + movq %rcx, -3*8(%rdi)
22121 movq %r11, -4*8(%rdi)
22122 leaq -4*8(%rdi), %rdi
22123 jae .Lcopy_backward_loop
22124 @@ -135,12 +137,13 @@ ENTRY(memcpy)
22125 */
22126 movq 0*8(%rsi), %r8
22127 movq 1*8(%rsi), %r9
22128 - movq -2*8(%rsi, %rdx), %r10
22129 + movq -2*8(%rsi, %rdx), %rcx
22130 movq -1*8(%rsi, %rdx), %r11
22131 movq %r8, 0*8(%rdi)
22132 movq %r9, 1*8(%rdi)
22133 - movq %r10, -2*8(%rdi, %rdx)
22134 + movq %rcx, -2*8(%rdi, %rdx)
22135 movq %r11, -1*8(%rdi, %rdx)
22136 + pax_force_retaddr
22137 retq
22138 .p2align 4
22139 .Lless_16bytes:
22140 @@ -153,6 +156,7 @@ ENTRY(memcpy)
22141 movq -1*8(%rsi, %rdx), %r9
22142 movq %r8, 0*8(%rdi)
22143 movq %r9, -1*8(%rdi, %rdx)
22144 + pax_force_retaddr
22145 retq
22146 .p2align 4
22147 .Lless_8bytes:
22148 @@ -166,6 +170,7 @@ ENTRY(memcpy)
22149 movl -4(%rsi, %rdx), %r8d
22150 movl %ecx, (%rdi)
22151 movl %r8d, -4(%rdi, %rdx)
22152 + pax_force_retaddr
22153 retq
22154 .p2align 4
22155 .Lless_3bytes:
22156 @@ -183,6 +188,7 @@ ENTRY(memcpy)
22157 jnz .Lloop_1
22158
22159 .Lend:
22160 + pax_force_retaddr
22161 retq
22162 CFI_ENDPROC
22163 ENDPROC(memcpy)
22164 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
22165 index ee16461..c39c199 100644
22166 --- a/arch/x86/lib/memmove_64.S
22167 +++ b/arch/x86/lib/memmove_64.S
22168 @@ -61,13 +61,13 @@ ENTRY(memmove)
22169 5:
22170 sub $0x20, %rdx
22171 movq 0*8(%rsi), %r11
22172 - movq 1*8(%rsi), %r10
22173 + movq 1*8(%rsi), %rcx
22174 movq 2*8(%rsi), %r9
22175 movq 3*8(%rsi), %r8
22176 leaq 4*8(%rsi), %rsi
22177
22178 movq %r11, 0*8(%rdi)
22179 - movq %r10, 1*8(%rdi)
22180 + movq %rcx, 1*8(%rdi)
22181 movq %r9, 2*8(%rdi)
22182 movq %r8, 3*8(%rdi)
22183 leaq 4*8(%rdi), %rdi
22184 @@ -81,10 +81,10 @@ ENTRY(memmove)
22185 4:
22186 movq %rdx, %rcx
22187 movq -8(%rsi, %rdx), %r11
22188 - lea -8(%rdi, %rdx), %r10
22189 + lea -8(%rdi, %rdx), %r9
22190 shrq $3, %rcx
22191 rep movsq
22192 - movq %r11, (%r10)
22193 + movq %r11, (%r9)
22194 jmp 13f
22195 .Lmemmove_end_forward:
22196
22197 @@ -95,14 +95,14 @@ ENTRY(memmove)
22198 7:
22199 movq %rdx, %rcx
22200 movq (%rsi), %r11
22201 - movq %rdi, %r10
22202 + movq %rdi, %r9
22203 leaq -8(%rsi, %rdx), %rsi
22204 leaq -8(%rdi, %rdx), %rdi
22205 shrq $3, %rcx
22206 std
22207 rep movsq
22208 cld
22209 - movq %r11, (%r10)
22210 + movq %r11, (%r9)
22211 jmp 13f
22212
22213 /*
22214 @@ -127,13 +127,13 @@ ENTRY(memmove)
22215 8:
22216 subq $0x20, %rdx
22217 movq -1*8(%rsi), %r11
22218 - movq -2*8(%rsi), %r10
22219 + movq -2*8(%rsi), %rcx
22220 movq -3*8(%rsi), %r9
22221 movq -4*8(%rsi), %r8
22222 leaq -4*8(%rsi), %rsi
22223
22224 movq %r11, -1*8(%rdi)
22225 - movq %r10, -2*8(%rdi)
22226 + movq %rcx, -2*8(%rdi)
22227 movq %r9, -3*8(%rdi)
22228 movq %r8, -4*8(%rdi)
22229 leaq -4*8(%rdi), %rdi
22230 @@ -151,11 +151,11 @@ ENTRY(memmove)
22231 * Move data from 16 bytes to 31 bytes.
22232 */
22233 movq 0*8(%rsi), %r11
22234 - movq 1*8(%rsi), %r10
22235 + movq 1*8(%rsi), %rcx
22236 movq -2*8(%rsi, %rdx), %r9
22237 movq -1*8(%rsi, %rdx), %r8
22238 movq %r11, 0*8(%rdi)
22239 - movq %r10, 1*8(%rdi)
22240 + movq %rcx, 1*8(%rdi)
22241 movq %r9, -2*8(%rdi, %rdx)
22242 movq %r8, -1*8(%rdi, %rdx)
22243 jmp 13f
22244 @@ -167,9 +167,9 @@ ENTRY(memmove)
22245 * Move data from 8 bytes to 15 bytes.
22246 */
22247 movq 0*8(%rsi), %r11
22248 - movq -1*8(%rsi, %rdx), %r10
22249 + movq -1*8(%rsi, %rdx), %r9
22250 movq %r11, 0*8(%rdi)
22251 - movq %r10, -1*8(%rdi, %rdx)
22252 + movq %r9, -1*8(%rdi, %rdx)
22253 jmp 13f
22254 10:
22255 cmpq $4, %rdx
22256 @@ -178,9 +178,9 @@ ENTRY(memmove)
22257 * Move data from 4 bytes to 7 bytes.
22258 */
22259 movl (%rsi), %r11d
22260 - movl -4(%rsi, %rdx), %r10d
22261 + movl -4(%rsi, %rdx), %r9d
22262 movl %r11d, (%rdi)
22263 - movl %r10d, -4(%rdi, %rdx)
22264 + movl %r9d, -4(%rdi, %rdx)
22265 jmp 13f
22266 11:
22267 cmp $2, %rdx
22268 @@ -189,9 +189,9 @@ ENTRY(memmove)
22269 * Move data from 2 bytes to 3 bytes.
22270 */
22271 movw (%rsi), %r11w
22272 - movw -2(%rsi, %rdx), %r10w
22273 + movw -2(%rsi, %rdx), %r9w
22274 movw %r11w, (%rdi)
22275 - movw %r10w, -2(%rdi, %rdx)
22276 + movw %r9w, -2(%rdi, %rdx)
22277 jmp 13f
22278 12:
22279 cmp $1, %rdx
22280 @@ -202,6 +202,7 @@ ENTRY(memmove)
22281 movb (%rsi), %r11b
22282 movb %r11b, (%rdi)
22283 13:
22284 + pax_force_retaddr
22285 retq
22286 CFI_ENDPROC
22287
22288 @@ -210,6 +211,7 @@ ENTRY(memmove)
22289 /* Forward moving data. */
22290 movq %rdx, %rcx
22291 rep movsb
22292 + pax_force_retaddr
22293 retq
22294 .Lmemmove_end_forward_efs:
22295 .previous
22296 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
22297 index 79bd454..dff325a 100644
22298 --- a/arch/x86/lib/memset_64.S
22299 +++ b/arch/x86/lib/memset_64.S
22300 @@ -31,6 +31,7 @@
22301 movl %r8d,%ecx
22302 rep stosb
22303 movq %r9,%rax
22304 + pax_force_retaddr
22305 ret
22306 .Lmemset_e:
22307 .previous
22308 @@ -53,6 +54,7 @@
22309 movl %edx,%ecx
22310 rep stosb
22311 movq %r9,%rax
22312 + pax_force_retaddr
22313 ret
22314 .Lmemset_e_e:
22315 .previous
22316 @@ -60,13 +62,13 @@
22317 ENTRY(memset)
22318 ENTRY(__memset)
22319 CFI_STARTPROC
22320 - movq %rdi,%r10
22321 movq %rdx,%r11
22322
22323 /* expand byte value */
22324 movzbl %sil,%ecx
22325 movabs $0x0101010101010101,%rax
22326 mul %rcx /* with rax, clobbers rdx */
22327 + movq %rdi,%rdx
22328
22329 /* align dst */
22330 movl %edi,%r9d
22331 @@ -120,7 +122,8 @@ ENTRY(__memset)
22332 jnz .Lloop_1
22333
22334 .Lende:
22335 - movq %r10,%rax
22336 + movq %rdx,%rax
22337 + pax_force_retaddr
22338 ret
22339
22340 CFI_RESTORE_STATE
22341 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
22342 index c9f2d9b..e7fd2c0 100644
22343 --- a/arch/x86/lib/mmx_32.c
22344 +++ b/arch/x86/lib/mmx_32.c
22345 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
22346 {
22347 void *p;
22348 int i;
22349 + unsigned long cr0;
22350
22351 if (unlikely(in_interrupt()))
22352 return __memcpy(to, from, len);
22353 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
22354 kernel_fpu_begin();
22355
22356 __asm__ __volatile__ (
22357 - "1: prefetch (%0)\n" /* This set is 28 bytes */
22358 - " prefetch 64(%0)\n"
22359 - " prefetch 128(%0)\n"
22360 - " prefetch 192(%0)\n"
22361 - " prefetch 256(%0)\n"
22362 + "1: prefetch (%1)\n" /* This set is 28 bytes */
22363 + " prefetch 64(%1)\n"
22364 + " prefetch 128(%1)\n"
22365 + " prefetch 192(%1)\n"
22366 + " prefetch 256(%1)\n"
22367 "2: \n"
22368 ".section .fixup, \"ax\"\n"
22369 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
22370 + "3: \n"
22371 +
22372 +#ifdef CONFIG_PAX_KERNEXEC
22373 + " movl %%cr0, %0\n"
22374 + " movl %0, %%eax\n"
22375 + " andl $0xFFFEFFFF, %%eax\n"
22376 + " movl %%eax, %%cr0\n"
22377 +#endif
22378 +
22379 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
22380 +
22381 +#ifdef CONFIG_PAX_KERNEXEC
22382 + " movl %0, %%cr0\n"
22383 +#endif
22384 +
22385 " jmp 2b\n"
22386 ".previous\n"
22387 _ASM_EXTABLE(1b, 3b)
22388 - : : "r" (from));
22389 + : "=&r" (cr0) : "r" (from) : "ax");
22390
22391 for ( ; i > 5; i--) {
22392 __asm__ __volatile__ (
22393 - "1: prefetch 320(%0)\n"
22394 - "2: movq (%0), %%mm0\n"
22395 - " movq 8(%0), %%mm1\n"
22396 - " movq 16(%0), %%mm2\n"
22397 - " movq 24(%0), %%mm3\n"
22398 - " movq %%mm0, (%1)\n"
22399 - " movq %%mm1, 8(%1)\n"
22400 - " movq %%mm2, 16(%1)\n"
22401 - " movq %%mm3, 24(%1)\n"
22402 - " movq 32(%0), %%mm0\n"
22403 - " movq 40(%0), %%mm1\n"
22404 - " movq 48(%0), %%mm2\n"
22405 - " movq 56(%0), %%mm3\n"
22406 - " movq %%mm0, 32(%1)\n"
22407 - " movq %%mm1, 40(%1)\n"
22408 - " movq %%mm2, 48(%1)\n"
22409 - " movq %%mm3, 56(%1)\n"
22410 + "1: prefetch 320(%1)\n"
22411 + "2: movq (%1), %%mm0\n"
22412 + " movq 8(%1), %%mm1\n"
22413 + " movq 16(%1), %%mm2\n"
22414 + " movq 24(%1), %%mm3\n"
22415 + " movq %%mm0, (%2)\n"
22416 + " movq %%mm1, 8(%2)\n"
22417 + " movq %%mm2, 16(%2)\n"
22418 + " movq %%mm3, 24(%2)\n"
22419 + " movq 32(%1), %%mm0\n"
22420 + " movq 40(%1), %%mm1\n"
22421 + " movq 48(%1), %%mm2\n"
22422 + " movq 56(%1), %%mm3\n"
22423 + " movq %%mm0, 32(%2)\n"
22424 + " movq %%mm1, 40(%2)\n"
22425 + " movq %%mm2, 48(%2)\n"
22426 + " movq %%mm3, 56(%2)\n"
22427 ".section .fixup, \"ax\"\n"
22428 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
22429 + "3:\n"
22430 +
22431 +#ifdef CONFIG_PAX_KERNEXEC
22432 + " movl %%cr0, %0\n"
22433 + " movl %0, %%eax\n"
22434 + " andl $0xFFFEFFFF, %%eax\n"
22435 + " movl %%eax, %%cr0\n"
22436 +#endif
22437 +
22438 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
22439 +
22440 +#ifdef CONFIG_PAX_KERNEXEC
22441 + " movl %0, %%cr0\n"
22442 +#endif
22443 +
22444 " jmp 2b\n"
22445 ".previous\n"
22446 _ASM_EXTABLE(1b, 3b)
22447 - : : "r" (from), "r" (to) : "memory");
22448 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
22449
22450 from += 64;
22451 to += 64;
22452 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
22453 static void fast_copy_page(void *to, void *from)
22454 {
22455 int i;
22456 + unsigned long cr0;
22457
22458 kernel_fpu_begin();
22459
22460 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
22461 * but that is for later. -AV
22462 */
22463 __asm__ __volatile__(
22464 - "1: prefetch (%0)\n"
22465 - " prefetch 64(%0)\n"
22466 - " prefetch 128(%0)\n"
22467 - " prefetch 192(%0)\n"
22468 - " prefetch 256(%0)\n"
22469 + "1: prefetch (%1)\n"
22470 + " prefetch 64(%1)\n"
22471 + " prefetch 128(%1)\n"
22472 + " prefetch 192(%1)\n"
22473 + " prefetch 256(%1)\n"
22474 "2: \n"
22475 ".section .fixup, \"ax\"\n"
22476 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
22477 + "3: \n"
22478 +
22479 +#ifdef CONFIG_PAX_KERNEXEC
22480 + " movl %%cr0, %0\n"
22481 + " movl %0, %%eax\n"
22482 + " andl $0xFFFEFFFF, %%eax\n"
22483 + " movl %%eax, %%cr0\n"
22484 +#endif
22485 +
22486 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
22487 +
22488 +#ifdef CONFIG_PAX_KERNEXEC
22489 + " movl %0, %%cr0\n"
22490 +#endif
22491 +
22492 " jmp 2b\n"
22493 ".previous\n"
22494 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
22495 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
22496
22497 for (i = 0; i < (4096-320)/64; i++) {
22498 __asm__ __volatile__ (
22499 - "1: prefetch 320(%0)\n"
22500 - "2: movq (%0), %%mm0\n"
22501 - " movntq %%mm0, (%1)\n"
22502 - " movq 8(%0), %%mm1\n"
22503 - " movntq %%mm1, 8(%1)\n"
22504 - " movq 16(%0), %%mm2\n"
22505 - " movntq %%mm2, 16(%1)\n"
22506 - " movq 24(%0), %%mm3\n"
22507 - " movntq %%mm3, 24(%1)\n"
22508 - " movq 32(%0), %%mm4\n"
22509 - " movntq %%mm4, 32(%1)\n"
22510 - " movq 40(%0), %%mm5\n"
22511 - " movntq %%mm5, 40(%1)\n"
22512 - " movq 48(%0), %%mm6\n"
22513 - " movntq %%mm6, 48(%1)\n"
22514 - " movq 56(%0), %%mm7\n"
22515 - " movntq %%mm7, 56(%1)\n"
22516 + "1: prefetch 320(%1)\n"
22517 + "2: movq (%1), %%mm0\n"
22518 + " movntq %%mm0, (%2)\n"
22519 + " movq 8(%1), %%mm1\n"
22520 + " movntq %%mm1, 8(%2)\n"
22521 + " movq 16(%1), %%mm2\n"
22522 + " movntq %%mm2, 16(%2)\n"
22523 + " movq 24(%1), %%mm3\n"
22524 + " movntq %%mm3, 24(%2)\n"
22525 + " movq 32(%1), %%mm4\n"
22526 + " movntq %%mm4, 32(%2)\n"
22527 + " movq 40(%1), %%mm5\n"
22528 + " movntq %%mm5, 40(%2)\n"
22529 + " movq 48(%1), %%mm6\n"
22530 + " movntq %%mm6, 48(%2)\n"
22531 + " movq 56(%1), %%mm7\n"
22532 + " movntq %%mm7, 56(%2)\n"
22533 ".section .fixup, \"ax\"\n"
22534 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
22535 + "3:\n"
22536 +
22537 +#ifdef CONFIG_PAX_KERNEXEC
22538 + " movl %%cr0, %0\n"
22539 + " movl %0, %%eax\n"
22540 + " andl $0xFFFEFFFF, %%eax\n"
22541 + " movl %%eax, %%cr0\n"
22542 +#endif
22543 +
22544 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
22545 +
22546 +#ifdef CONFIG_PAX_KERNEXEC
22547 + " movl %0, %%cr0\n"
22548 +#endif
22549 +
22550 " jmp 2b\n"
22551 ".previous\n"
22552 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
22553 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
22554
22555 from += 64;
22556 to += 64;
22557 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
22558 static void fast_copy_page(void *to, void *from)
22559 {
22560 int i;
22561 + unsigned long cr0;
22562
22563 kernel_fpu_begin();
22564
22565 __asm__ __volatile__ (
22566 - "1: prefetch (%0)\n"
22567 - " prefetch 64(%0)\n"
22568 - " prefetch 128(%0)\n"
22569 - " prefetch 192(%0)\n"
22570 - " prefetch 256(%0)\n"
22571 + "1: prefetch (%1)\n"
22572 + " prefetch 64(%1)\n"
22573 + " prefetch 128(%1)\n"
22574 + " prefetch 192(%1)\n"
22575 + " prefetch 256(%1)\n"
22576 "2: \n"
22577 ".section .fixup, \"ax\"\n"
22578 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
22579 + "3: \n"
22580 +
22581 +#ifdef CONFIG_PAX_KERNEXEC
22582 + " movl %%cr0, %0\n"
22583 + " movl %0, %%eax\n"
22584 + " andl $0xFFFEFFFF, %%eax\n"
22585 + " movl %%eax, %%cr0\n"
22586 +#endif
22587 +
22588 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
22589 +
22590 +#ifdef CONFIG_PAX_KERNEXEC
22591 + " movl %0, %%cr0\n"
22592 +#endif
22593 +
22594 " jmp 2b\n"
22595 ".previous\n"
22596 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
22597 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
22598
22599 for (i = 0; i < 4096/64; i++) {
22600 __asm__ __volatile__ (
22601 - "1: prefetch 320(%0)\n"
22602 - "2: movq (%0), %%mm0\n"
22603 - " movq 8(%0), %%mm1\n"
22604 - " movq 16(%0), %%mm2\n"
22605 - " movq 24(%0), %%mm3\n"
22606 - " movq %%mm0, (%1)\n"
22607 - " movq %%mm1, 8(%1)\n"
22608 - " movq %%mm2, 16(%1)\n"
22609 - " movq %%mm3, 24(%1)\n"
22610 - " movq 32(%0), %%mm0\n"
22611 - " movq 40(%0), %%mm1\n"
22612 - " movq 48(%0), %%mm2\n"
22613 - " movq 56(%0), %%mm3\n"
22614 - " movq %%mm0, 32(%1)\n"
22615 - " movq %%mm1, 40(%1)\n"
22616 - " movq %%mm2, 48(%1)\n"
22617 - " movq %%mm3, 56(%1)\n"
22618 + "1: prefetch 320(%1)\n"
22619 + "2: movq (%1), %%mm0\n"
22620 + " movq 8(%1), %%mm1\n"
22621 + " movq 16(%1), %%mm2\n"
22622 + " movq 24(%1), %%mm3\n"
22623 + " movq %%mm0, (%2)\n"
22624 + " movq %%mm1, 8(%2)\n"
22625 + " movq %%mm2, 16(%2)\n"
22626 + " movq %%mm3, 24(%2)\n"
22627 + " movq 32(%1), %%mm0\n"
22628 + " movq 40(%1), %%mm1\n"
22629 + " movq 48(%1), %%mm2\n"
22630 + " movq 56(%1), %%mm3\n"
22631 + " movq %%mm0, 32(%2)\n"
22632 + " movq %%mm1, 40(%2)\n"
22633 + " movq %%mm2, 48(%2)\n"
22634 + " movq %%mm3, 56(%2)\n"
22635 ".section .fixup, \"ax\"\n"
22636 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
22637 + "3:\n"
22638 +
22639 +#ifdef CONFIG_PAX_KERNEXEC
22640 + " movl %%cr0, %0\n"
22641 + " movl %0, %%eax\n"
22642 + " andl $0xFFFEFFFF, %%eax\n"
22643 + " movl %%eax, %%cr0\n"
22644 +#endif
22645 +
22646 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
22647 +
22648 +#ifdef CONFIG_PAX_KERNEXEC
22649 + " movl %0, %%cr0\n"
22650 +#endif
22651 +
22652 " jmp 2b\n"
22653 ".previous\n"
22654 _ASM_EXTABLE(1b, 3b)
22655 - : : "r" (from), "r" (to) : "memory");
22656 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
22657
22658 from += 64;
22659 to += 64;
22660 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
22661 index 69fa106..adda88b 100644
22662 --- a/arch/x86/lib/msr-reg.S
22663 +++ b/arch/x86/lib/msr-reg.S
22664 @@ -3,6 +3,7 @@
22665 #include <asm/dwarf2.h>
22666 #include <asm/asm.h>
22667 #include <asm/msr.h>
22668 +#include <asm/alternative-asm.h>
22669
22670 #ifdef CONFIG_X86_64
22671 /*
22672 @@ -16,7 +17,7 @@ ENTRY(native_\op\()_safe_regs)
22673 CFI_STARTPROC
22674 pushq_cfi %rbx
22675 pushq_cfi %rbp
22676 - movq %rdi, %r10 /* Save pointer */
22677 + movq %rdi, %r9 /* Save pointer */
22678 xorl %r11d, %r11d /* Return value */
22679 movl (%rdi), %eax
22680 movl 4(%rdi), %ecx
22681 @@ -27,16 +28,17 @@ ENTRY(native_\op\()_safe_regs)
22682 movl 28(%rdi), %edi
22683 CFI_REMEMBER_STATE
22684 1: \op
22685 -2: movl %eax, (%r10)
22686 +2: movl %eax, (%r9)
22687 movl %r11d, %eax /* Return value */
22688 - movl %ecx, 4(%r10)
22689 - movl %edx, 8(%r10)
22690 - movl %ebx, 12(%r10)
22691 - movl %ebp, 20(%r10)
22692 - movl %esi, 24(%r10)
22693 - movl %edi, 28(%r10)
22694 + movl %ecx, 4(%r9)
22695 + movl %edx, 8(%r9)
22696 + movl %ebx, 12(%r9)
22697 + movl %ebp, 20(%r9)
22698 + movl %esi, 24(%r9)
22699 + movl %edi, 28(%r9)
22700 popq_cfi %rbp
22701 popq_cfi %rbx
22702 + pax_force_retaddr
22703 ret
22704 3:
22705 CFI_RESTORE_STATE
22706 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
22707 index 36b0d15..d381858 100644
22708 --- a/arch/x86/lib/putuser.S
22709 +++ b/arch/x86/lib/putuser.S
22710 @@ -15,7 +15,9 @@
22711 #include <asm/thread_info.h>
22712 #include <asm/errno.h>
22713 #include <asm/asm.h>
22714 -
22715 +#include <asm/segment.h>
22716 +#include <asm/pgtable.h>
22717 +#include <asm/alternative-asm.h>
22718
22719 /*
22720 * __put_user_X
22721 @@ -29,52 +31,119 @@
22722 * as they get called from within inline assembly.
22723 */
22724
22725 -#define ENTER CFI_STARTPROC ; \
22726 - GET_THREAD_INFO(%_ASM_BX)
22727 -#define EXIT ret ; \
22728 +#define ENTER CFI_STARTPROC
22729 +#define EXIT pax_force_retaddr; ret ; \
22730 CFI_ENDPROC
22731
22732 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
22733 +#define _DEST %_ASM_CX,%_ASM_BX
22734 +#else
22735 +#define _DEST %_ASM_CX
22736 +#endif
22737 +
22738 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
22739 +#define __copyuser_seg gs;
22740 +#else
22741 +#define __copyuser_seg
22742 +#endif
22743 +
22744 .text
22745 ENTRY(__put_user_1)
22746 ENTER
22747 +
22748 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
22749 + GET_THREAD_INFO(%_ASM_BX)
22750 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
22751 jae bad_put_user
22752 -1: movb %al,(%_ASM_CX)
22753 +
22754 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
22755 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
22756 + cmp %_ASM_BX,%_ASM_CX
22757 + jb 1234f
22758 + xor %ebx,%ebx
22759 +1234:
22760 +#endif
22761 +
22762 +#endif
22763 +
22764 +1: __copyuser_seg movb %al,(_DEST)
22765 xor %eax,%eax
22766 EXIT
22767 ENDPROC(__put_user_1)
22768
22769 ENTRY(__put_user_2)
22770 ENTER
22771 +
22772 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
22773 + GET_THREAD_INFO(%_ASM_BX)
22774 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
22775 sub $1,%_ASM_BX
22776 cmp %_ASM_BX,%_ASM_CX
22777 jae bad_put_user
22778 -2: movw %ax,(%_ASM_CX)
22779 +
22780 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
22781 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
22782 + cmp %_ASM_BX,%_ASM_CX
22783 + jb 1234f
22784 + xor %ebx,%ebx
22785 +1234:
22786 +#endif
22787 +
22788 +#endif
22789 +
22790 +2: __copyuser_seg movw %ax,(_DEST)
22791 xor %eax,%eax
22792 EXIT
22793 ENDPROC(__put_user_2)
22794
22795 ENTRY(__put_user_4)
22796 ENTER
22797 +
22798 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
22799 + GET_THREAD_INFO(%_ASM_BX)
22800 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
22801 sub $3,%_ASM_BX
22802 cmp %_ASM_BX,%_ASM_CX
22803 jae bad_put_user
22804 -3: movl %eax,(%_ASM_CX)
22805 +
22806 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
22807 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
22808 + cmp %_ASM_BX,%_ASM_CX
22809 + jb 1234f
22810 + xor %ebx,%ebx
22811 +1234:
22812 +#endif
22813 +
22814 +#endif
22815 +
22816 +3: __copyuser_seg movl %eax,(_DEST)
22817 xor %eax,%eax
22818 EXIT
22819 ENDPROC(__put_user_4)
22820
22821 ENTRY(__put_user_8)
22822 ENTER
22823 +
22824 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
22825 + GET_THREAD_INFO(%_ASM_BX)
22826 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
22827 sub $7,%_ASM_BX
22828 cmp %_ASM_BX,%_ASM_CX
22829 jae bad_put_user
22830 -4: mov %_ASM_AX,(%_ASM_CX)
22831 +
22832 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
22833 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
22834 + cmp %_ASM_BX,%_ASM_CX
22835 + jb 1234f
22836 + xor %ebx,%ebx
22837 +1234:
22838 +#endif
22839 +
22840 +#endif
22841 +
22842 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
22843 #ifdef CONFIG_X86_32
22844 -5: movl %edx,4(%_ASM_CX)
22845 +5: __copyuser_seg movl %edx,4(_DEST)
22846 #endif
22847 xor %eax,%eax
22848 EXIT
22849 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
22850 index 1cad221..de671ee 100644
22851 --- a/arch/x86/lib/rwlock.S
22852 +++ b/arch/x86/lib/rwlock.S
22853 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
22854 FRAME
22855 0: LOCK_PREFIX
22856 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
22857 +
22858 +#ifdef CONFIG_PAX_REFCOUNT
22859 + jno 1234f
22860 + LOCK_PREFIX
22861 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
22862 + int $4
22863 +1234:
22864 + _ASM_EXTABLE(1234b, 1234b)
22865 +#endif
22866 +
22867 1: rep; nop
22868 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
22869 jne 1b
22870 LOCK_PREFIX
22871 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
22872 +
22873 +#ifdef CONFIG_PAX_REFCOUNT
22874 + jno 1234f
22875 + LOCK_PREFIX
22876 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
22877 + int $4
22878 +1234:
22879 + _ASM_EXTABLE(1234b, 1234b)
22880 +#endif
22881 +
22882 jnz 0b
22883 ENDFRAME
22884 + pax_force_retaddr
22885 ret
22886 CFI_ENDPROC
22887 END(__write_lock_failed)
22888 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
22889 FRAME
22890 0: LOCK_PREFIX
22891 READ_LOCK_SIZE(inc) (%__lock_ptr)
22892 +
22893 +#ifdef CONFIG_PAX_REFCOUNT
22894 + jno 1234f
22895 + LOCK_PREFIX
22896 + READ_LOCK_SIZE(dec) (%__lock_ptr)
22897 + int $4
22898 +1234:
22899 + _ASM_EXTABLE(1234b, 1234b)
22900 +#endif
22901 +
22902 1: rep; nop
22903 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
22904 js 1b
22905 LOCK_PREFIX
22906 READ_LOCK_SIZE(dec) (%__lock_ptr)
22907 +
22908 +#ifdef CONFIG_PAX_REFCOUNT
22909 + jno 1234f
22910 + LOCK_PREFIX
22911 + READ_LOCK_SIZE(inc) (%__lock_ptr)
22912 + int $4
22913 +1234:
22914 + _ASM_EXTABLE(1234b, 1234b)
22915 +#endif
22916 +
22917 js 0b
22918 ENDFRAME
22919 + pax_force_retaddr
22920 ret
22921 CFI_ENDPROC
22922 END(__read_lock_failed)
22923 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
22924 index 5dff5f0..cadebf4 100644
22925 --- a/arch/x86/lib/rwsem.S
22926 +++ b/arch/x86/lib/rwsem.S
22927 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
22928 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
22929 CFI_RESTORE __ASM_REG(dx)
22930 restore_common_regs
22931 + pax_force_retaddr
22932 ret
22933 CFI_ENDPROC
22934 ENDPROC(call_rwsem_down_read_failed)
22935 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
22936 movq %rax,%rdi
22937 call rwsem_down_write_failed
22938 restore_common_regs
22939 + pax_force_retaddr
22940 ret
22941 CFI_ENDPROC
22942 ENDPROC(call_rwsem_down_write_failed)
22943 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
22944 movq %rax,%rdi
22945 call rwsem_wake
22946 restore_common_regs
22947 -1: ret
22948 +1: pax_force_retaddr
22949 + ret
22950 CFI_ENDPROC
22951 ENDPROC(call_rwsem_wake)
22952
22953 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
22954 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
22955 CFI_RESTORE __ASM_REG(dx)
22956 restore_common_regs
22957 + pax_force_retaddr
22958 ret
22959 CFI_ENDPROC
22960 ENDPROC(call_rwsem_downgrade_wake)
22961 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
22962 index a63efd6..ccecad8 100644
22963 --- a/arch/x86/lib/thunk_64.S
22964 +++ b/arch/x86/lib/thunk_64.S
22965 @@ -8,6 +8,7 @@
22966 #include <linux/linkage.h>
22967 #include <asm/dwarf2.h>
22968 #include <asm/calling.h>
22969 +#include <asm/alternative-asm.h>
22970
22971 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
22972 .macro THUNK name, func, put_ret_addr_in_rdi=0
22973 @@ -41,5 +42,6 @@
22974 SAVE_ARGS
22975 restore:
22976 RESTORE_ARGS
22977 + pax_force_retaddr
22978 ret
22979 CFI_ENDPROC
22980 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
22981 index e218d5d..a99a1eb 100644
22982 --- a/arch/x86/lib/usercopy_32.c
22983 +++ b/arch/x86/lib/usercopy_32.c
22984 @@ -43,7 +43,7 @@ do { \
22985 __asm__ __volatile__( \
22986 " testl %1,%1\n" \
22987 " jz 2f\n" \
22988 - "0: lodsb\n" \
22989 + "0: "__copyuser_seg"lodsb\n" \
22990 " stosb\n" \
22991 " testb %%al,%%al\n" \
22992 " jz 1f\n" \
22993 @@ -128,10 +128,12 @@ do { \
22994 int __d0; \
22995 might_fault(); \
22996 __asm__ __volatile__( \
22997 + __COPYUSER_SET_ES \
22998 "0: rep; stosl\n" \
22999 " movl %2,%0\n" \
23000 "1: rep; stosb\n" \
23001 "2:\n" \
23002 + __COPYUSER_RESTORE_ES \
23003 ".section .fixup,\"ax\"\n" \
23004 "3: lea 0(%2,%0,4),%0\n" \
23005 " jmp 2b\n" \
23006 @@ -200,6 +202,7 @@ long strnlen_user(const char __user *s, long n)
23007 might_fault();
23008
23009 __asm__ __volatile__(
23010 + __COPYUSER_SET_ES
23011 " testl %0, %0\n"
23012 " jz 3f\n"
23013 " andl %0,%%ecx\n"
23014 @@ -208,6 +211,7 @@ long strnlen_user(const char __user *s, long n)
23015 " subl %%ecx,%0\n"
23016 " addl %0,%%eax\n"
23017 "1:\n"
23018 + __COPYUSER_RESTORE_ES
23019 ".section .fixup,\"ax\"\n"
23020 "2: xorl %%eax,%%eax\n"
23021 " jmp 1b\n"
23022 @@ -227,7 +231,7 @@ EXPORT_SYMBOL(strnlen_user);
23023
23024 #ifdef CONFIG_X86_INTEL_USERCOPY
23025 static unsigned long
23026 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
23027 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
23028 {
23029 int d0, d1;
23030 __asm__ __volatile__(
23031 @@ -239,36 +243,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
23032 " .align 2,0x90\n"
23033 "3: movl 0(%4), %%eax\n"
23034 "4: movl 4(%4), %%edx\n"
23035 - "5: movl %%eax, 0(%3)\n"
23036 - "6: movl %%edx, 4(%3)\n"
23037 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
23038 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
23039 "7: movl 8(%4), %%eax\n"
23040 "8: movl 12(%4),%%edx\n"
23041 - "9: movl %%eax, 8(%3)\n"
23042 - "10: movl %%edx, 12(%3)\n"
23043 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
23044 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
23045 "11: movl 16(%4), %%eax\n"
23046 "12: movl 20(%4), %%edx\n"
23047 - "13: movl %%eax, 16(%3)\n"
23048 - "14: movl %%edx, 20(%3)\n"
23049 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
23050 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
23051 "15: movl 24(%4), %%eax\n"
23052 "16: movl 28(%4), %%edx\n"
23053 - "17: movl %%eax, 24(%3)\n"
23054 - "18: movl %%edx, 28(%3)\n"
23055 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
23056 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
23057 "19: movl 32(%4), %%eax\n"
23058 "20: movl 36(%4), %%edx\n"
23059 - "21: movl %%eax, 32(%3)\n"
23060 - "22: movl %%edx, 36(%3)\n"
23061 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
23062 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
23063 "23: movl 40(%4), %%eax\n"
23064 "24: movl 44(%4), %%edx\n"
23065 - "25: movl %%eax, 40(%3)\n"
23066 - "26: movl %%edx, 44(%3)\n"
23067 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
23068 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
23069 "27: movl 48(%4), %%eax\n"
23070 "28: movl 52(%4), %%edx\n"
23071 - "29: movl %%eax, 48(%3)\n"
23072 - "30: movl %%edx, 52(%3)\n"
23073 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
23074 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
23075 "31: movl 56(%4), %%eax\n"
23076 "32: movl 60(%4), %%edx\n"
23077 - "33: movl %%eax, 56(%3)\n"
23078 - "34: movl %%edx, 60(%3)\n"
23079 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
23080 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
23081 " addl $-64, %0\n"
23082 " addl $64, %4\n"
23083 " addl $64, %3\n"
23084 @@ -278,10 +282,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
23085 " shrl $2, %0\n"
23086 " andl $3, %%eax\n"
23087 " cld\n"
23088 + __COPYUSER_SET_ES
23089 "99: rep; movsl\n"
23090 "36: movl %%eax, %0\n"
23091 "37: rep; movsb\n"
23092 "100:\n"
23093 + __COPYUSER_RESTORE_ES
23094 ".section .fixup,\"ax\"\n"
23095 "101: lea 0(%%eax,%0,4),%0\n"
23096 " jmp 100b\n"
23097 @@ -334,46 +340,155 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
23098 }
23099
23100 static unsigned long
23101 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
23102 +{
23103 + int d0, d1;
23104 + __asm__ __volatile__(
23105 + " .align 2,0x90\n"
23106 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
23107 + " cmpl $67, %0\n"
23108 + " jbe 3f\n"
23109 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
23110 + " .align 2,0x90\n"
23111 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
23112 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
23113 + "5: movl %%eax, 0(%3)\n"
23114 + "6: movl %%edx, 4(%3)\n"
23115 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
23116 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
23117 + "9: movl %%eax, 8(%3)\n"
23118 + "10: movl %%edx, 12(%3)\n"
23119 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
23120 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
23121 + "13: movl %%eax, 16(%3)\n"
23122 + "14: movl %%edx, 20(%3)\n"
23123 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
23124 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
23125 + "17: movl %%eax, 24(%3)\n"
23126 + "18: movl %%edx, 28(%3)\n"
23127 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
23128 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
23129 + "21: movl %%eax, 32(%3)\n"
23130 + "22: movl %%edx, 36(%3)\n"
23131 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
23132 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
23133 + "25: movl %%eax, 40(%3)\n"
23134 + "26: movl %%edx, 44(%3)\n"
23135 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
23136 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
23137 + "29: movl %%eax, 48(%3)\n"
23138 + "30: movl %%edx, 52(%3)\n"
23139 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
23140 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
23141 + "33: movl %%eax, 56(%3)\n"
23142 + "34: movl %%edx, 60(%3)\n"
23143 + " addl $-64, %0\n"
23144 + " addl $64, %4\n"
23145 + " addl $64, %3\n"
23146 + " cmpl $63, %0\n"
23147 + " ja 1b\n"
23148 + "35: movl %0, %%eax\n"
23149 + " shrl $2, %0\n"
23150 + " andl $3, %%eax\n"
23151 + " cld\n"
23152 + "99: rep; "__copyuser_seg" movsl\n"
23153 + "36: movl %%eax, %0\n"
23154 + "37: rep; "__copyuser_seg" movsb\n"
23155 + "100:\n"
23156 + ".section .fixup,\"ax\"\n"
23157 + "101: lea 0(%%eax,%0,4),%0\n"
23158 + " jmp 100b\n"
23159 + ".previous\n"
23160 + ".section __ex_table,\"a\"\n"
23161 + " .align 4\n"
23162 + " .long 1b,100b\n"
23163 + " .long 2b,100b\n"
23164 + " .long 3b,100b\n"
23165 + " .long 4b,100b\n"
23166 + " .long 5b,100b\n"
23167 + " .long 6b,100b\n"
23168 + " .long 7b,100b\n"
23169 + " .long 8b,100b\n"
23170 + " .long 9b,100b\n"
23171 + " .long 10b,100b\n"
23172 + " .long 11b,100b\n"
23173 + " .long 12b,100b\n"
23174 + " .long 13b,100b\n"
23175 + " .long 14b,100b\n"
23176 + " .long 15b,100b\n"
23177 + " .long 16b,100b\n"
23178 + " .long 17b,100b\n"
23179 + " .long 18b,100b\n"
23180 + " .long 19b,100b\n"
23181 + " .long 20b,100b\n"
23182 + " .long 21b,100b\n"
23183 + " .long 22b,100b\n"
23184 + " .long 23b,100b\n"
23185 + " .long 24b,100b\n"
23186 + " .long 25b,100b\n"
23187 + " .long 26b,100b\n"
23188 + " .long 27b,100b\n"
23189 + " .long 28b,100b\n"
23190 + " .long 29b,100b\n"
23191 + " .long 30b,100b\n"
23192 + " .long 31b,100b\n"
23193 + " .long 32b,100b\n"
23194 + " .long 33b,100b\n"
23195 + " .long 34b,100b\n"
23196 + " .long 35b,100b\n"
23197 + " .long 36b,100b\n"
23198 + " .long 37b,100b\n"
23199 + " .long 99b,101b\n"
23200 + ".previous"
23201 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
23202 + : "1"(to), "2"(from), "0"(size)
23203 + : "eax", "edx", "memory");
23204 + return size;
23205 +}
23206 +
23207 +static unsigned long
23208 +__copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size) __size_overflow(3);
23209 +static unsigned long
23210 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
23211 {
23212 int d0, d1;
23213 __asm__ __volatile__(
23214 " .align 2,0x90\n"
23215 - "0: movl 32(%4), %%eax\n"
23216 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
23217 " cmpl $67, %0\n"
23218 " jbe 2f\n"
23219 - "1: movl 64(%4), %%eax\n"
23220 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
23221 " .align 2,0x90\n"
23222 - "2: movl 0(%4), %%eax\n"
23223 - "21: movl 4(%4), %%edx\n"
23224 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
23225 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
23226 " movl %%eax, 0(%3)\n"
23227 " movl %%edx, 4(%3)\n"
23228 - "3: movl 8(%4), %%eax\n"
23229 - "31: movl 12(%4),%%edx\n"
23230 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
23231 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
23232 " movl %%eax, 8(%3)\n"
23233 " movl %%edx, 12(%3)\n"
23234 - "4: movl 16(%4), %%eax\n"
23235 - "41: movl 20(%4), %%edx\n"
23236 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
23237 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
23238 " movl %%eax, 16(%3)\n"
23239 " movl %%edx, 20(%3)\n"
23240 - "10: movl 24(%4), %%eax\n"
23241 - "51: movl 28(%4), %%edx\n"
23242 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
23243 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
23244 " movl %%eax, 24(%3)\n"
23245 " movl %%edx, 28(%3)\n"
23246 - "11: movl 32(%4), %%eax\n"
23247 - "61: movl 36(%4), %%edx\n"
23248 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
23249 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
23250 " movl %%eax, 32(%3)\n"
23251 " movl %%edx, 36(%3)\n"
23252 - "12: movl 40(%4), %%eax\n"
23253 - "71: movl 44(%4), %%edx\n"
23254 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
23255 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
23256 " movl %%eax, 40(%3)\n"
23257 " movl %%edx, 44(%3)\n"
23258 - "13: movl 48(%4), %%eax\n"
23259 - "81: movl 52(%4), %%edx\n"
23260 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
23261 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
23262 " movl %%eax, 48(%3)\n"
23263 " movl %%edx, 52(%3)\n"
23264 - "14: movl 56(%4), %%eax\n"
23265 - "91: movl 60(%4), %%edx\n"
23266 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
23267 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
23268 " movl %%eax, 56(%3)\n"
23269 " movl %%edx, 60(%3)\n"
23270 " addl $-64, %0\n"
23271 @@ -385,9 +500,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
23272 " shrl $2, %0\n"
23273 " andl $3, %%eax\n"
23274 " cld\n"
23275 - "6: rep; movsl\n"
23276 + "6: rep; "__copyuser_seg" movsl\n"
23277 " movl %%eax,%0\n"
23278 - "7: rep; movsb\n"
23279 + "7: rep; "__copyuser_seg" movsb\n"
23280 "8:\n"
23281 ".section .fixup,\"ax\"\n"
23282 "9: lea 0(%%eax,%0,4),%0\n"
23283 @@ -434,47 +549,49 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
23284 */
23285
23286 static unsigned long __copy_user_zeroing_intel_nocache(void *to,
23287 + const void __user *from, unsigned long size) __size_overflow(3);
23288 +static unsigned long __copy_user_zeroing_intel_nocache(void *to,
23289 const void __user *from, unsigned long size)
23290 {
23291 int d0, d1;
23292
23293 __asm__ __volatile__(
23294 " .align 2,0x90\n"
23295 - "0: movl 32(%4), %%eax\n"
23296 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
23297 " cmpl $67, %0\n"
23298 " jbe 2f\n"
23299 - "1: movl 64(%4), %%eax\n"
23300 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
23301 " .align 2,0x90\n"
23302 - "2: movl 0(%4), %%eax\n"
23303 - "21: movl 4(%4), %%edx\n"
23304 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
23305 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
23306 " movnti %%eax, 0(%3)\n"
23307 " movnti %%edx, 4(%3)\n"
23308 - "3: movl 8(%4), %%eax\n"
23309 - "31: movl 12(%4),%%edx\n"
23310 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
23311 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
23312 " movnti %%eax, 8(%3)\n"
23313 " movnti %%edx, 12(%3)\n"
23314 - "4: movl 16(%4), %%eax\n"
23315 - "41: movl 20(%4), %%edx\n"
23316 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
23317 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
23318 " movnti %%eax, 16(%3)\n"
23319 " movnti %%edx, 20(%3)\n"
23320 - "10: movl 24(%4), %%eax\n"
23321 - "51: movl 28(%4), %%edx\n"
23322 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
23323 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
23324 " movnti %%eax, 24(%3)\n"
23325 " movnti %%edx, 28(%3)\n"
23326 - "11: movl 32(%4), %%eax\n"
23327 - "61: movl 36(%4), %%edx\n"
23328 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
23329 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
23330 " movnti %%eax, 32(%3)\n"
23331 " movnti %%edx, 36(%3)\n"
23332 - "12: movl 40(%4), %%eax\n"
23333 - "71: movl 44(%4), %%edx\n"
23334 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
23335 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
23336 " movnti %%eax, 40(%3)\n"
23337 " movnti %%edx, 44(%3)\n"
23338 - "13: movl 48(%4), %%eax\n"
23339 - "81: movl 52(%4), %%edx\n"
23340 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
23341 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
23342 " movnti %%eax, 48(%3)\n"
23343 " movnti %%edx, 52(%3)\n"
23344 - "14: movl 56(%4), %%eax\n"
23345 - "91: movl 60(%4), %%edx\n"
23346 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
23347 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
23348 " movnti %%eax, 56(%3)\n"
23349 " movnti %%edx, 60(%3)\n"
23350 " addl $-64, %0\n"
23351 @@ -487,9 +604,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
23352 " shrl $2, %0\n"
23353 " andl $3, %%eax\n"
23354 " cld\n"
23355 - "6: rep; movsl\n"
23356 + "6: rep; "__copyuser_seg" movsl\n"
23357 " movl %%eax,%0\n"
23358 - "7: rep; movsb\n"
23359 + "7: rep; "__copyuser_seg" movsb\n"
23360 "8:\n"
23361 ".section .fixup,\"ax\"\n"
23362 "9: lea 0(%%eax,%0,4),%0\n"
23363 @@ -531,47 +648,49 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
23364 }
23365
23366 static unsigned long __copy_user_intel_nocache(void *to,
23367 + const void __user *from, unsigned long size) __size_overflow(3);
23368 +static unsigned long __copy_user_intel_nocache(void *to,
23369 const void __user *from, unsigned long size)
23370 {
23371 int d0, d1;
23372
23373 __asm__ __volatile__(
23374 " .align 2,0x90\n"
23375 - "0: movl 32(%4), %%eax\n"
23376 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
23377 " cmpl $67, %0\n"
23378 " jbe 2f\n"
23379 - "1: movl 64(%4), %%eax\n"
23380 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
23381 " .align 2,0x90\n"
23382 - "2: movl 0(%4), %%eax\n"
23383 - "21: movl 4(%4), %%edx\n"
23384 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
23385 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
23386 " movnti %%eax, 0(%3)\n"
23387 " movnti %%edx, 4(%3)\n"
23388 - "3: movl 8(%4), %%eax\n"
23389 - "31: movl 12(%4),%%edx\n"
23390 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
23391 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
23392 " movnti %%eax, 8(%3)\n"
23393 " movnti %%edx, 12(%3)\n"
23394 - "4: movl 16(%4), %%eax\n"
23395 - "41: movl 20(%4), %%edx\n"
23396 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
23397 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
23398 " movnti %%eax, 16(%3)\n"
23399 " movnti %%edx, 20(%3)\n"
23400 - "10: movl 24(%4), %%eax\n"
23401 - "51: movl 28(%4), %%edx\n"
23402 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
23403 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
23404 " movnti %%eax, 24(%3)\n"
23405 " movnti %%edx, 28(%3)\n"
23406 - "11: movl 32(%4), %%eax\n"
23407 - "61: movl 36(%4), %%edx\n"
23408 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
23409 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
23410 " movnti %%eax, 32(%3)\n"
23411 " movnti %%edx, 36(%3)\n"
23412 - "12: movl 40(%4), %%eax\n"
23413 - "71: movl 44(%4), %%edx\n"
23414 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
23415 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
23416 " movnti %%eax, 40(%3)\n"
23417 " movnti %%edx, 44(%3)\n"
23418 - "13: movl 48(%4), %%eax\n"
23419 - "81: movl 52(%4), %%edx\n"
23420 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
23421 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
23422 " movnti %%eax, 48(%3)\n"
23423 " movnti %%edx, 52(%3)\n"
23424 - "14: movl 56(%4), %%eax\n"
23425 - "91: movl 60(%4), %%edx\n"
23426 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
23427 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
23428 " movnti %%eax, 56(%3)\n"
23429 " movnti %%edx, 60(%3)\n"
23430 " addl $-64, %0\n"
23431 @@ -584,9 +703,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
23432 " shrl $2, %0\n"
23433 " andl $3, %%eax\n"
23434 " cld\n"
23435 - "6: rep; movsl\n"
23436 + "6: rep; "__copyuser_seg" movsl\n"
23437 " movl %%eax,%0\n"
23438 - "7: rep; movsb\n"
23439 + "7: rep; "__copyuser_seg" movsb\n"
23440 "8:\n"
23441 ".section .fixup,\"ax\"\n"
23442 "9: lea 0(%%eax,%0,4),%0\n"
23443 @@ -629,32 +748,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
23444 */
23445 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
23446 unsigned long size);
23447 -unsigned long __copy_user_intel(void __user *to, const void *from,
23448 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
23449 + unsigned long size);
23450 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
23451 unsigned long size);
23452 unsigned long __copy_user_zeroing_intel_nocache(void *to,
23453 const void __user *from, unsigned long size);
23454 #endif /* CONFIG_X86_INTEL_USERCOPY */
23455
23456 /* Generic arbitrary sized copy. */
23457 -#define __copy_user(to, from, size) \
23458 +#define __copy_user(to, from, size, prefix, set, restore) \
23459 do { \
23460 int __d0, __d1, __d2; \
23461 __asm__ __volatile__( \
23462 + set \
23463 " cmp $7,%0\n" \
23464 " jbe 1f\n" \
23465 " movl %1,%0\n" \
23466 " negl %0\n" \
23467 " andl $7,%0\n" \
23468 " subl %0,%3\n" \
23469 - "4: rep; movsb\n" \
23470 + "4: rep; "prefix"movsb\n" \
23471 " movl %3,%0\n" \
23472 " shrl $2,%0\n" \
23473 " andl $3,%3\n" \
23474 " .align 2,0x90\n" \
23475 - "0: rep; movsl\n" \
23476 + "0: rep; "prefix"movsl\n" \
23477 " movl %3,%0\n" \
23478 - "1: rep; movsb\n" \
23479 + "1: rep; "prefix"movsb\n" \
23480 "2:\n" \
23481 + restore \
23482 ".section .fixup,\"ax\"\n" \
23483 "5: addl %3,%0\n" \
23484 " jmp 2b\n" \
23485 @@ -682,14 +805,14 @@ do { \
23486 " negl %0\n" \
23487 " andl $7,%0\n" \
23488 " subl %0,%3\n" \
23489 - "4: rep; movsb\n" \
23490 + "4: rep; "__copyuser_seg"movsb\n" \
23491 " movl %3,%0\n" \
23492 " shrl $2,%0\n" \
23493 " andl $3,%3\n" \
23494 " .align 2,0x90\n" \
23495 - "0: rep; movsl\n" \
23496 + "0: rep; "__copyuser_seg"movsl\n" \
23497 " movl %3,%0\n" \
23498 - "1: rep; movsb\n" \
23499 + "1: rep; "__copyuser_seg"movsb\n" \
23500 "2:\n" \
23501 ".section .fixup,\"ax\"\n" \
23502 "5: addl %3,%0\n" \
23503 @@ -775,9 +898,9 @@ survive:
23504 }
23505 #endif
23506 if (movsl_is_ok(to, from, n))
23507 - __copy_user(to, from, n);
23508 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
23509 else
23510 - n = __copy_user_intel(to, from, n);
23511 + n = __generic_copy_to_user_intel(to, from, n);
23512 return n;
23513 }
23514 EXPORT_SYMBOL(__copy_to_user_ll);
23515 @@ -797,10 +920,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
23516 unsigned long n)
23517 {
23518 if (movsl_is_ok(to, from, n))
23519 - __copy_user(to, from, n);
23520 + __copy_user(to, from, n, __copyuser_seg, "", "");
23521 else
23522 - n = __copy_user_intel((void __user *)to,
23523 - (const void *)from, n);
23524 + n = __generic_copy_from_user_intel(to, from, n);
23525 return n;
23526 }
23527 EXPORT_SYMBOL(__copy_from_user_ll_nozero);
23528 @@ -827,65 +949,50 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
23529 if (n > 64 && cpu_has_xmm2)
23530 n = __copy_user_intel_nocache(to, from, n);
23531 else
23532 - __copy_user(to, from, n);
23533 + __copy_user(to, from, n, __copyuser_seg, "", "");
23534 #else
23535 - __copy_user(to, from, n);
23536 + __copy_user(to, from, n, __copyuser_seg, "", "");
23537 #endif
23538 return n;
23539 }
23540 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
23541
23542 -/**
23543 - * copy_to_user: - Copy a block of data into user space.
23544 - * @to: Destination address, in user space.
23545 - * @from: Source address, in kernel space.
23546 - * @n: Number of bytes to copy.
23547 - *
23548 - * Context: User context only. This function may sleep.
23549 - *
23550 - * Copy data from kernel space to user space.
23551 - *
23552 - * Returns number of bytes that could not be copied.
23553 - * On success, this will be zero.
23554 - */
23555 -unsigned long
23556 -copy_to_user(void __user *to, const void *from, unsigned long n)
23557 -{
23558 - if (access_ok(VERIFY_WRITE, to, n))
23559 - n = __copy_to_user(to, from, n);
23560 - return n;
23561 -}
23562 -EXPORT_SYMBOL(copy_to_user);
23563 -
23564 -/**
23565 - * copy_from_user: - Copy a block of data from user space.
23566 - * @to: Destination address, in kernel space.
23567 - * @from: Source address, in user space.
23568 - * @n: Number of bytes to copy.
23569 - *
23570 - * Context: User context only. This function may sleep.
23571 - *
23572 - * Copy data from user space to kernel space.
23573 - *
23574 - * Returns number of bytes that could not be copied.
23575 - * On success, this will be zero.
23576 - *
23577 - * If some data could not be copied, this function will pad the copied
23578 - * data to the requested size using zero bytes.
23579 - */
23580 -unsigned long
23581 -_copy_from_user(void *to, const void __user *from, unsigned long n)
23582 -{
23583 - if (access_ok(VERIFY_READ, from, n))
23584 - n = __copy_from_user(to, from, n);
23585 - else
23586 - memset(to, 0, n);
23587 - return n;
23588 -}
23589 -EXPORT_SYMBOL(_copy_from_user);
23590 -
23591 void copy_from_user_overflow(void)
23592 {
23593 WARN(1, "Buffer overflow detected!\n");
23594 }
23595 EXPORT_SYMBOL(copy_from_user_overflow);
23596 +
23597 +void copy_to_user_overflow(void)
23598 +{
23599 + WARN(1, "Buffer overflow detected!\n");
23600 +}
23601 +EXPORT_SYMBOL(copy_to_user_overflow);
23602 +
23603 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23604 +void __set_fs(mm_segment_t x)
23605 +{
23606 + switch (x.seg) {
23607 + case 0:
23608 + loadsegment(gs, 0);
23609 + break;
23610 + case TASK_SIZE_MAX:
23611 + loadsegment(gs, __USER_DS);
23612 + break;
23613 + case -1UL:
23614 + loadsegment(gs, __KERNEL_DS);
23615 + break;
23616 + default:
23617 + BUG();
23618 + }
23619 + return;
23620 +}
23621 +EXPORT_SYMBOL(__set_fs);
23622 +
23623 +void set_fs(mm_segment_t x)
23624 +{
23625 + current_thread_info()->addr_limit = x;
23626 + __set_fs(x);
23627 +}
23628 +EXPORT_SYMBOL(set_fs);
23629 +#endif
23630 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
23631 index b7c2849..8633ad8 100644
23632 --- a/arch/x86/lib/usercopy_64.c
23633 +++ b/arch/x86/lib/usercopy_64.c
23634 @@ -42,6 +42,12 @@ long
23635 __strncpy_from_user(char *dst, const char __user *src, long count)
23636 {
23637 long res;
23638 +
23639 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23640 + if ((unsigned long)src < PAX_USER_SHADOW_BASE)
23641 + src += PAX_USER_SHADOW_BASE;
23642 +#endif
23643 +
23644 __do_strncpy_from_user(dst, src, count, res);
23645 return res;
23646 }
23647 @@ -65,6 +71,12 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
23648 {
23649 long __d0;
23650 might_fault();
23651 +
23652 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23653 + if ((unsigned long)addr < PAX_USER_SHADOW_BASE)
23654 + addr += PAX_USER_SHADOW_BASE;
23655 +#endif
23656 +
23657 /* no memory constraint because it doesn't change any memory gcc knows
23658 about */
23659 asm volatile(
23660 @@ -149,12 +161,20 @@ long strlen_user(const char __user *s)
23661 }
23662 EXPORT_SYMBOL(strlen_user);
23663
23664 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
23665 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
23666 {
23667 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
23668 - return copy_user_generic((__force void *)to, (__force void *)from, len);
23669 - }
23670 - return len;
23671 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
23672 +
23673 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23674 + if ((unsigned long)to < PAX_USER_SHADOW_BASE)
23675 + to += PAX_USER_SHADOW_BASE;
23676 + if ((unsigned long)from < PAX_USER_SHADOW_BASE)
23677 + from += PAX_USER_SHADOW_BASE;
23678 +#endif
23679 +
23680 + return copy_user_generic((void __force_kernel *)to, (void __force_kernel *)from, len);
23681 + }
23682 + return len;
23683 }
23684 EXPORT_SYMBOL(copy_in_user);
23685
23686 @@ -164,7 +184,7 @@ EXPORT_SYMBOL(copy_in_user);
23687 * it is not necessary to optimize tail handling.
23688 */
23689 unsigned long
23690 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
23691 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
23692 {
23693 char c;
23694 unsigned zero_len;
23695 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
23696 index 1fb85db..8b3540b 100644
23697 --- a/arch/x86/mm/extable.c
23698 +++ b/arch/x86/mm/extable.c
23699 @@ -8,7 +8,7 @@ int fixup_exception(struct pt_regs *regs)
23700 const struct exception_table_entry *fixup;
23701
23702 #ifdef CONFIG_PNPBIOS
23703 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
23704 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
23705 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
23706 extern u32 pnp_bios_is_utter_crap;
23707 pnp_bios_is_utter_crap = 1;
23708 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
23709 index f0b4caf..d92fd42 100644
23710 --- a/arch/x86/mm/fault.c
23711 +++ b/arch/x86/mm/fault.c
23712 @@ -13,11 +13,18 @@
23713 #include <linux/perf_event.h> /* perf_sw_event */
23714 #include <linux/hugetlb.h> /* hstate_index_to_shift */
23715 #include <linux/prefetch.h> /* prefetchw */
23716 +#include <linux/unistd.h>
23717 +#include <linux/compiler.h>
23718
23719 #include <asm/traps.h> /* dotraplinkage, ... */
23720 #include <asm/pgalloc.h> /* pgd_*(), ... */
23721 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
23722 #include <asm/fixmap.h> /* VSYSCALL_START */
23723 +#include <asm/tlbflush.h>
23724 +
23725 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
23726 +#include <asm/stacktrace.h>
23727 +#endif
23728
23729 /*
23730 * Page fault error code bits:
23731 @@ -55,7 +62,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
23732 int ret = 0;
23733
23734 /* kprobe_running() needs smp_processor_id() */
23735 - if (kprobes_built_in() && !user_mode_vm(regs)) {
23736 + if (kprobes_built_in() && !user_mode(regs)) {
23737 preempt_disable();
23738 if (kprobe_running() && kprobe_fault_handler(regs, 14))
23739 ret = 1;
23740 @@ -116,7 +123,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
23741 return !instr_lo || (instr_lo>>1) == 1;
23742 case 0x00:
23743 /* Prefetch instruction is 0x0F0D or 0x0F18 */
23744 - if (probe_kernel_address(instr, opcode))
23745 + if (user_mode(regs)) {
23746 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
23747 + return 0;
23748 + } else if (probe_kernel_address(instr, opcode))
23749 return 0;
23750
23751 *prefetch = (instr_lo == 0xF) &&
23752 @@ -150,7 +160,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
23753 while (instr < max_instr) {
23754 unsigned char opcode;
23755
23756 - if (probe_kernel_address(instr, opcode))
23757 + if (user_mode(regs)) {
23758 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
23759 + break;
23760 + } else if (probe_kernel_address(instr, opcode))
23761 break;
23762
23763 instr++;
23764 @@ -181,6 +194,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
23765 force_sig_info(si_signo, &info, tsk);
23766 }
23767
23768 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
23769 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
23770 +#endif
23771 +
23772 +#ifdef CONFIG_PAX_EMUTRAMP
23773 +static int pax_handle_fetch_fault(struct pt_regs *regs);
23774 +#endif
23775 +
23776 +#ifdef CONFIG_PAX_PAGEEXEC
23777 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
23778 +{
23779 + pgd_t *pgd;
23780 + pud_t *pud;
23781 + pmd_t *pmd;
23782 +
23783 + pgd = pgd_offset(mm, address);
23784 + if (!pgd_present(*pgd))
23785 + return NULL;
23786 + pud = pud_offset(pgd, address);
23787 + if (!pud_present(*pud))
23788 + return NULL;
23789 + pmd = pmd_offset(pud, address);
23790 + if (!pmd_present(*pmd))
23791 + return NULL;
23792 + return pmd;
23793 +}
23794 +#endif
23795 +
23796 DEFINE_SPINLOCK(pgd_lock);
23797 LIST_HEAD(pgd_list);
23798
23799 @@ -231,10 +272,22 @@ void vmalloc_sync_all(void)
23800 for (address = VMALLOC_START & PMD_MASK;
23801 address >= TASK_SIZE && address < FIXADDR_TOP;
23802 address += PMD_SIZE) {
23803 +
23804 +#ifdef CONFIG_PAX_PER_CPU_PGD
23805 + unsigned long cpu;
23806 +#else
23807 struct page *page;
23808 +#endif
23809
23810 spin_lock(&pgd_lock);
23811 +
23812 +#ifdef CONFIG_PAX_PER_CPU_PGD
23813 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
23814 + pgd_t *pgd = get_cpu_pgd(cpu);
23815 + pmd_t *ret;
23816 +#else
23817 list_for_each_entry(page, &pgd_list, lru) {
23818 + pgd_t *pgd = page_address(page);
23819 spinlock_t *pgt_lock;
23820 pmd_t *ret;
23821
23822 @@ -242,8 +295,13 @@ void vmalloc_sync_all(void)
23823 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
23824
23825 spin_lock(pgt_lock);
23826 - ret = vmalloc_sync_one(page_address(page), address);
23827 +#endif
23828 +
23829 + ret = vmalloc_sync_one(pgd, address);
23830 +
23831 +#ifndef CONFIG_PAX_PER_CPU_PGD
23832 spin_unlock(pgt_lock);
23833 +#endif
23834
23835 if (!ret)
23836 break;
23837 @@ -277,6 +335,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
23838 * an interrupt in the middle of a task switch..
23839 */
23840 pgd_paddr = read_cr3();
23841 +
23842 +#ifdef CONFIG_PAX_PER_CPU_PGD
23843 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
23844 +#endif
23845 +
23846 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
23847 if (!pmd_k)
23848 return -1;
23849 @@ -372,7 +435,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
23850 * happen within a race in page table update. In the later
23851 * case just flush:
23852 */
23853 +
23854 +#ifdef CONFIG_PAX_PER_CPU_PGD
23855 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
23856 + pgd = pgd_offset_cpu(smp_processor_id(), address);
23857 +#else
23858 pgd = pgd_offset(current->active_mm, address);
23859 +#endif
23860 +
23861 pgd_ref = pgd_offset_k(address);
23862 if (pgd_none(*pgd_ref))
23863 return -1;
23864 @@ -540,7 +610,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
23865 static int is_errata100(struct pt_regs *regs, unsigned long address)
23866 {
23867 #ifdef CONFIG_X86_64
23868 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
23869 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
23870 return 1;
23871 #endif
23872 return 0;
23873 @@ -567,7 +637,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
23874 }
23875
23876 static const char nx_warning[] = KERN_CRIT
23877 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
23878 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
23879
23880 static void
23881 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
23882 @@ -576,15 +646,26 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
23883 if (!oops_may_print())
23884 return;
23885
23886 - if (error_code & PF_INSTR) {
23887 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
23888 unsigned int level;
23889
23890 pte_t *pte = lookup_address(address, &level);
23891
23892 if (pte && pte_present(*pte) && !pte_exec(*pte))
23893 - printk(nx_warning, current_uid());
23894 + printk(nx_warning, current_uid(), current->comm, task_pid_nr(current));
23895 }
23896
23897 +#ifdef CONFIG_PAX_KERNEXEC
23898 + if (init_mm.start_code <= address && address < init_mm.end_code) {
23899 + if (current->signal->curr_ip)
23900 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
23901 + &current->signal->curr_ip, current->comm, task_pid_nr(current), current_uid(), current_euid());
23902 + else
23903 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
23904 + current->comm, task_pid_nr(current), current_uid(), current_euid());
23905 + }
23906 +#endif
23907 +
23908 printk(KERN_ALERT "BUG: unable to handle kernel ");
23909 if (address < PAGE_SIZE)
23910 printk(KERN_CONT "NULL pointer dereference");
23911 @@ -748,6 +829,21 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
23912 }
23913 #endif
23914
23915 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
23916 + if (pax_is_fetch_fault(regs, error_code, address)) {
23917 +
23918 +#ifdef CONFIG_PAX_EMUTRAMP
23919 + switch (pax_handle_fetch_fault(regs)) {
23920 + case 2:
23921 + return;
23922 + }
23923 +#endif
23924 +
23925 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
23926 + do_group_exit(SIGKILL);
23927 + }
23928 +#endif
23929 +
23930 if (unlikely(show_unhandled_signals))
23931 show_signal_msg(regs, error_code, address, tsk);
23932
23933 @@ -844,7 +940,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
23934 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
23935 printk(KERN_ERR
23936 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
23937 - tsk->comm, tsk->pid, address);
23938 + tsk->comm, task_pid_nr(tsk), address);
23939 code = BUS_MCEERR_AR;
23940 }
23941 #endif
23942 @@ -900,6 +996,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
23943 return 1;
23944 }
23945
23946 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
23947 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
23948 +{
23949 + pte_t *pte;
23950 + pmd_t *pmd;
23951 + spinlock_t *ptl;
23952 + unsigned char pte_mask;
23953 +
23954 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
23955 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
23956 + return 0;
23957 +
23958 + /* PaX: it's our fault, let's handle it if we can */
23959 +
23960 + /* PaX: take a look at read faults before acquiring any locks */
23961 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
23962 + /* instruction fetch attempt from a protected page in user mode */
23963 + up_read(&mm->mmap_sem);
23964 +
23965 +#ifdef CONFIG_PAX_EMUTRAMP
23966 + switch (pax_handle_fetch_fault(regs)) {
23967 + case 2:
23968 + return 1;
23969 + }
23970 +#endif
23971 +
23972 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
23973 + do_group_exit(SIGKILL);
23974 + }
23975 +
23976 + pmd = pax_get_pmd(mm, address);
23977 + if (unlikely(!pmd))
23978 + return 0;
23979 +
23980 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
23981 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
23982 + pte_unmap_unlock(pte, ptl);
23983 + return 0;
23984 + }
23985 +
23986 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
23987 + /* write attempt to a protected page in user mode */
23988 + pte_unmap_unlock(pte, ptl);
23989 + return 0;
23990 + }
23991 +
23992 +#ifdef CONFIG_SMP
23993 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
23994 +#else
23995 + if (likely(address > get_limit(regs->cs)))
23996 +#endif
23997 + {
23998 + set_pte(pte, pte_mkread(*pte));
23999 + __flush_tlb_one(address);
24000 + pte_unmap_unlock(pte, ptl);
24001 + up_read(&mm->mmap_sem);
24002 + return 1;
24003 + }
24004 +
24005 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
24006 +
24007 + /*
24008 + * PaX: fill DTLB with user rights and retry
24009 + */
24010 + __asm__ __volatile__ (
24011 + "orb %2,(%1)\n"
24012 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
24013 +/*
24014 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
24015 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
24016 + * page fault when examined during a TLB load attempt. this is true not only
24017 + * for PTEs holding a non-present entry but also present entries that will
24018 + * raise a page fault (such as those set up by PaX, or the copy-on-write
24019 + * mechanism). in effect it means that we do *not* need to flush the TLBs
24020 + * for our target pages since their PTEs are simply not in the TLBs at all.
24021 +
24022 + * the best thing in omitting it is that we gain around 15-20% speed in the
24023 + * fast path of the page fault handler and can get rid of tracing since we
24024 + * can no longer flush unintended entries.
24025 + */
24026 + "invlpg (%0)\n"
24027 +#endif
24028 + __copyuser_seg"testb $0,(%0)\n"
24029 + "xorb %3,(%1)\n"
24030 + :
24031 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
24032 + : "memory", "cc");
24033 + pte_unmap_unlock(pte, ptl);
24034 + up_read(&mm->mmap_sem);
24035 + return 1;
24036 +}
24037 +#endif
24038 +
24039 /*
24040 * Handle a spurious fault caused by a stale TLB entry.
24041 *
24042 @@ -972,6 +1161,9 @@ int show_unhandled_signals = 1;
24043 static inline int
24044 access_error(unsigned long error_code, struct vm_area_struct *vma)
24045 {
24046 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
24047 + return 1;
24048 +
24049 if (error_code & PF_WRITE) {
24050 /* write, present and write, not present: */
24051 if (unlikely(!(vma->vm_flags & VM_WRITE)))
24052 @@ -1005,18 +1197,32 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
24053 {
24054 struct vm_area_struct *vma;
24055 struct task_struct *tsk;
24056 - unsigned long address;
24057 struct mm_struct *mm;
24058 int fault;
24059 int write = error_code & PF_WRITE;
24060 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
24061 (write ? FAULT_FLAG_WRITE : 0);
24062
24063 - tsk = current;
24064 - mm = tsk->mm;
24065 -
24066 /* Get the faulting address: */
24067 - address = read_cr2();
24068 + unsigned long address = read_cr2();
24069 +
24070 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
24071 + if (!user_mode(regs) && address < 2 * PAX_USER_SHADOW_BASE) {
24072 + if (!search_exception_tables(regs->ip)) {
24073 + bad_area_nosemaphore(regs, error_code, address);
24074 + return;
24075 + }
24076 + if (address < PAX_USER_SHADOW_BASE) {
24077 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
24078 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
24079 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
24080 + } else
24081 + address -= PAX_USER_SHADOW_BASE;
24082 + }
24083 +#endif
24084 +
24085 + tsk = current;
24086 + mm = tsk->mm;
24087
24088 /*
24089 * Detect and handle instructions that would cause a page fault for
24090 @@ -1077,7 +1283,7 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
24091 * User-mode registers count as a user access even for any
24092 * potential system fault or CPU buglet:
24093 */
24094 - if (user_mode_vm(regs)) {
24095 + if (user_mode(regs)) {
24096 local_irq_enable();
24097 error_code |= PF_USER;
24098 } else {
24099 @@ -1132,6 +1338,11 @@ retry:
24100 might_sleep();
24101 }
24102
24103 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
24104 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
24105 + return;
24106 +#endif
24107 +
24108 vma = find_vma(mm, address);
24109 if (unlikely(!vma)) {
24110 bad_area(regs, error_code, address);
24111 @@ -1143,18 +1354,24 @@ retry:
24112 bad_area(regs, error_code, address);
24113 return;
24114 }
24115 - if (error_code & PF_USER) {
24116 - /*
24117 - * Accessing the stack below %sp is always a bug.
24118 - * The large cushion allows instructions like enter
24119 - * and pusha to work. ("enter $65535, $31" pushes
24120 - * 32 pointers and then decrements %sp by 65535.)
24121 - */
24122 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
24123 - bad_area(regs, error_code, address);
24124 - return;
24125 - }
24126 + /*
24127 + * Accessing the stack below %sp is always a bug.
24128 + * The large cushion allows instructions like enter
24129 + * and pusha to work. ("enter $65535, $31" pushes
24130 + * 32 pointers and then decrements %sp by 65535.)
24131 + */
24132 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
24133 + bad_area(regs, error_code, address);
24134 + return;
24135 }
24136 +
24137 +#ifdef CONFIG_PAX_SEGMEXEC
24138 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
24139 + bad_area(regs, error_code, address);
24140 + return;
24141 + }
24142 +#endif
24143 +
24144 if (unlikely(expand_stack(vma, address))) {
24145 bad_area(regs, error_code, address);
24146 return;
24147 @@ -1209,3 +1426,292 @@ good_area:
24148
24149 up_read(&mm->mmap_sem);
24150 }
24151 +
24152 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
24153 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
24154 +{
24155 + struct mm_struct *mm = current->mm;
24156 + unsigned long ip = regs->ip;
24157 +
24158 + if (v8086_mode(regs))
24159 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
24160 +
24161 +#ifdef CONFIG_PAX_PAGEEXEC
24162 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
24163 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
24164 + return true;
24165 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
24166 + return true;
24167 + return false;
24168 + }
24169 +#endif
24170 +
24171 +#ifdef CONFIG_PAX_SEGMEXEC
24172 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
24173 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
24174 + return true;
24175 + return false;
24176 + }
24177 +#endif
24178 +
24179 + return false;
24180 +}
24181 +#endif
24182 +
24183 +#ifdef CONFIG_PAX_EMUTRAMP
24184 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
24185 +{
24186 + int err;
24187 +
24188 + do { /* PaX: libffi trampoline emulation */
24189 + unsigned char mov, jmp;
24190 + unsigned int addr1, addr2;
24191 +
24192 +#ifdef CONFIG_X86_64
24193 + if ((regs->ip + 9) >> 32)
24194 + break;
24195 +#endif
24196 +
24197 + err = get_user(mov, (unsigned char __user *)regs->ip);
24198 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
24199 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
24200 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
24201 +
24202 + if (err)
24203 + break;
24204 +
24205 + if (mov == 0xB8 && jmp == 0xE9) {
24206 + regs->ax = addr1;
24207 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
24208 + return 2;
24209 + }
24210 + } while (0);
24211 +
24212 + do { /* PaX: gcc trampoline emulation #1 */
24213 + unsigned char mov1, mov2;
24214 + unsigned short jmp;
24215 + unsigned int addr1, addr2;
24216 +
24217 +#ifdef CONFIG_X86_64
24218 + if ((regs->ip + 11) >> 32)
24219 + break;
24220 +#endif
24221 +
24222 + err = get_user(mov1, (unsigned char __user *)regs->ip);
24223 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
24224 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
24225 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
24226 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
24227 +
24228 + if (err)
24229 + break;
24230 +
24231 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
24232 + regs->cx = addr1;
24233 + regs->ax = addr2;
24234 + regs->ip = addr2;
24235 + return 2;
24236 + }
24237 + } while (0);
24238 +
24239 + do { /* PaX: gcc trampoline emulation #2 */
24240 + unsigned char mov, jmp;
24241 + unsigned int addr1, addr2;
24242 +
24243 +#ifdef CONFIG_X86_64
24244 + if ((regs->ip + 9) >> 32)
24245 + break;
24246 +#endif
24247 +
24248 + err = get_user(mov, (unsigned char __user *)regs->ip);
24249 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
24250 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
24251 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
24252 +
24253 + if (err)
24254 + break;
24255 +
24256 + if (mov == 0xB9 && jmp == 0xE9) {
24257 + regs->cx = addr1;
24258 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
24259 + return 2;
24260 + }
24261 + } while (0);
24262 +
24263 + return 1; /* PaX in action */
24264 +}
24265 +
24266 +#ifdef CONFIG_X86_64
24267 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
24268 +{
24269 + int err;
24270 +
24271 + do { /* PaX: libffi trampoline emulation */
24272 + unsigned short mov1, mov2, jmp1;
24273 + unsigned char stcclc, jmp2;
24274 + unsigned long addr1, addr2;
24275 +
24276 + err = get_user(mov1, (unsigned short __user *)regs->ip);
24277 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
24278 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
24279 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
24280 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
24281 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
24282 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
24283 +
24284 + if (err)
24285 + break;
24286 +
24287 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
24288 + regs->r11 = addr1;
24289 + regs->r10 = addr2;
24290 + if (stcclc == 0xF8)
24291 + regs->flags &= ~X86_EFLAGS_CF;
24292 + else
24293 + regs->flags |= X86_EFLAGS_CF;
24294 + regs->ip = addr1;
24295 + return 2;
24296 + }
24297 + } while (0);
24298 +
24299 + do { /* PaX: gcc trampoline emulation #1 */
24300 + unsigned short mov1, mov2, jmp1;
24301 + unsigned char jmp2;
24302 + unsigned int addr1;
24303 + unsigned long addr2;
24304 +
24305 + err = get_user(mov1, (unsigned short __user *)regs->ip);
24306 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
24307 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
24308 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
24309 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
24310 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
24311 +
24312 + if (err)
24313 + break;
24314 +
24315 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
24316 + regs->r11 = addr1;
24317 + regs->r10 = addr2;
24318 + regs->ip = addr1;
24319 + return 2;
24320 + }
24321 + } while (0);
24322 +
24323 + do { /* PaX: gcc trampoline emulation #2 */
24324 + unsigned short mov1, mov2, jmp1;
24325 + unsigned char jmp2;
24326 + unsigned long addr1, addr2;
24327 +
24328 + err = get_user(mov1, (unsigned short __user *)regs->ip);
24329 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
24330 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
24331 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
24332 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
24333 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
24334 +
24335 + if (err)
24336 + break;
24337 +
24338 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
24339 + regs->r11 = addr1;
24340 + regs->r10 = addr2;
24341 + regs->ip = addr1;
24342 + return 2;
24343 + }
24344 + } while (0);
24345 +
24346 + return 1; /* PaX in action */
24347 +}
24348 +#endif
24349 +
24350 +/*
24351 + * PaX: decide what to do with offenders (regs->ip = fault address)
24352 + *
24353 + * returns 1 when task should be killed
24354 + * 2 when gcc trampoline was detected
24355 + */
24356 +static int pax_handle_fetch_fault(struct pt_regs *regs)
24357 +{
24358 + if (v8086_mode(regs))
24359 + return 1;
24360 +
24361 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
24362 + return 1;
24363 +
24364 +#ifdef CONFIG_X86_32
24365 + return pax_handle_fetch_fault_32(regs);
24366 +#else
24367 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
24368 + return pax_handle_fetch_fault_32(regs);
24369 + else
24370 + return pax_handle_fetch_fault_64(regs);
24371 +#endif
24372 +}
24373 +#endif
24374 +
24375 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
24376 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
24377 +{
24378 + long i;
24379 +
24380 + printk(KERN_ERR "PAX: bytes at PC: ");
24381 + for (i = 0; i < 20; i++) {
24382 + unsigned char c;
24383 + if (get_user(c, (unsigned char __force_user *)pc+i))
24384 + printk(KERN_CONT "?? ");
24385 + else
24386 + printk(KERN_CONT "%02x ", c);
24387 + }
24388 + printk("\n");
24389 +
24390 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
24391 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
24392 + unsigned long c;
24393 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
24394 +#ifdef CONFIG_X86_32
24395 + printk(KERN_CONT "???????? ");
24396 +#else
24397 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
24398 + printk(KERN_CONT "???????? ???????? ");
24399 + else
24400 + printk(KERN_CONT "???????????????? ");
24401 +#endif
24402 + } else {
24403 +#ifdef CONFIG_X86_64
24404 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
24405 + printk(KERN_CONT "%08x ", (unsigned int)c);
24406 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
24407 + } else
24408 +#endif
24409 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
24410 + }
24411 + }
24412 + printk("\n");
24413 +}
24414 +#endif
24415 +
24416 +/**
24417 + * probe_kernel_write(): safely attempt to write to a location
24418 + * @dst: address to write to
24419 + * @src: pointer to the data that shall be written
24420 + * @size: size of the data chunk
24421 + *
24422 + * Safely write to address @dst from the buffer at @src. If a kernel fault
24423 + * happens, handle that and return -EFAULT.
24424 + */
24425 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
24426 +{
24427 + long ret;
24428 + mm_segment_t old_fs = get_fs();
24429 +
24430 + set_fs(KERNEL_DS);
24431 + pagefault_disable();
24432 + pax_open_kernel();
24433 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
24434 + pax_close_kernel();
24435 + pagefault_enable();
24436 + set_fs(old_fs);
24437 +
24438 + return ret ? -EFAULT : 0;
24439 +}
24440 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
24441 index dd74e46..7d26398 100644
24442 --- a/arch/x86/mm/gup.c
24443 +++ b/arch/x86/mm/gup.c
24444 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
24445 addr = start;
24446 len = (unsigned long) nr_pages << PAGE_SHIFT;
24447 end = start + len;
24448 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
24449 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
24450 (void __user *)start, len)))
24451 return 0;
24452
24453 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
24454 index f4f29b1..5cac4fb 100644
24455 --- a/arch/x86/mm/highmem_32.c
24456 +++ b/arch/x86/mm/highmem_32.c
24457 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
24458 idx = type + KM_TYPE_NR*smp_processor_id();
24459 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
24460 BUG_ON(!pte_none(*(kmap_pte-idx)));
24461 +
24462 + pax_open_kernel();
24463 set_pte(kmap_pte-idx, mk_pte(page, prot));
24464 + pax_close_kernel();
24465 +
24466 arch_flush_lazy_mmu_mode();
24467
24468 return (void *)vaddr;
24469 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
24470 index 8ecbb4b..a269cab 100644
24471 --- a/arch/x86/mm/hugetlbpage.c
24472 +++ b/arch/x86/mm/hugetlbpage.c
24473 @@ -266,13 +266,20 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
24474 struct hstate *h = hstate_file(file);
24475 struct mm_struct *mm = current->mm;
24476 struct vm_area_struct *vma;
24477 - unsigned long start_addr;
24478 + unsigned long start_addr, pax_task_size = TASK_SIZE;
24479 +
24480 +#ifdef CONFIG_PAX_SEGMEXEC
24481 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
24482 + pax_task_size = SEGMEXEC_TASK_SIZE;
24483 +#endif
24484 +
24485 + pax_task_size -= PAGE_SIZE;
24486
24487 if (len > mm->cached_hole_size) {
24488 - start_addr = mm->free_area_cache;
24489 + start_addr = mm->free_area_cache;
24490 } else {
24491 - start_addr = TASK_UNMAPPED_BASE;
24492 - mm->cached_hole_size = 0;
24493 + start_addr = mm->mmap_base;
24494 + mm->cached_hole_size = 0;
24495 }
24496
24497 full_search:
24498 @@ -280,26 +287,27 @@ full_search:
24499
24500 for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
24501 /* At this point: (!vma || addr < vma->vm_end). */
24502 - if (TASK_SIZE - len < addr) {
24503 + if (pax_task_size - len < addr) {
24504 /*
24505 * Start a new search - just in case we missed
24506 * some holes.
24507 */
24508 - if (start_addr != TASK_UNMAPPED_BASE) {
24509 - start_addr = TASK_UNMAPPED_BASE;
24510 + if (start_addr != mm->mmap_base) {
24511 + start_addr = mm->mmap_base;
24512 mm->cached_hole_size = 0;
24513 goto full_search;
24514 }
24515 return -ENOMEM;
24516 }
24517 - if (!vma || addr + len <= vma->vm_start) {
24518 - mm->free_area_cache = addr + len;
24519 - return addr;
24520 - }
24521 + if (check_heap_stack_gap(vma, addr, len))
24522 + break;
24523 if (addr + mm->cached_hole_size < vma->vm_start)
24524 mm->cached_hole_size = vma->vm_start - addr;
24525 addr = ALIGN(vma->vm_end, huge_page_size(h));
24526 }
24527 +
24528 + mm->free_area_cache = addr + len;
24529 + return addr;
24530 }
24531
24532 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
24533 @@ -308,10 +316,9 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
24534 {
24535 struct hstate *h = hstate_file(file);
24536 struct mm_struct *mm = current->mm;
24537 - struct vm_area_struct *vma, *prev_vma;
24538 - unsigned long base = mm->mmap_base, addr = addr0;
24539 + struct vm_area_struct *vma;
24540 + unsigned long base = mm->mmap_base, addr;
24541 unsigned long largest_hole = mm->cached_hole_size;
24542 - int first_time = 1;
24543
24544 /* don't allow allocations above current base */
24545 if (mm->free_area_cache > base)
24546 @@ -321,14 +328,15 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
24547 largest_hole = 0;
24548 mm->free_area_cache = base;
24549 }
24550 -try_again:
24551 +
24552 /* make sure it can fit in the remaining address space */
24553 if (mm->free_area_cache < len)
24554 goto fail;
24555
24556 /* either no address requested or can't fit in requested address hole */
24557 - addr = (mm->free_area_cache - len) & huge_page_mask(h);
24558 + addr = (mm->free_area_cache - len);
24559 do {
24560 + addr &= huge_page_mask(h);
24561 /*
24562 * Lookup failure means no vma is above this address,
24563 * i.e. return with success:
24564 @@ -341,46 +349,47 @@ try_again:
24565 * new region fits between prev_vma->vm_end and
24566 * vma->vm_start, use it:
24567 */
24568 - prev_vma = vma->vm_prev;
24569 - if (addr + len <= vma->vm_start &&
24570 - (!prev_vma || (addr >= prev_vma->vm_end))) {
24571 + if (check_heap_stack_gap(vma, addr, len)) {
24572 /* remember the address as a hint for next time */
24573 - mm->cached_hole_size = largest_hole;
24574 - return (mm->free_area_cache = addr);
24575 - } else {
24576 - /* pull free_area_cache down to the first hole */
24577 - if (mm->free_area_cache == vma->vm_end) {
24578 - mm->free_area_cache = vma->vm_start;
24579 - mm->cached_hole_size = largest_hole;
24580 - }
24581 + mm->cached_hole_size = largest_hole;
24582 + return (mm->free_area_cache = addr);
24583 + }
24584 + /* pull free_area_cache down to the first hole */
24585 + if (mm->free_area_cache == vma->vm_end) {
24586 + mm->free_area_cache = vma->vm_start;
24587 + mm->cached_hole_size = largest_hole;
24588 }
24589
24590 /* remember the largest hole we saw so far */
24591 if (addr + largest_hole < vma->vm_start)
24592 - largest_hole = vma->vm_start - addr;
24593 + largest_hole = vma->vm_start - addr;
24594
24595 /* try just below the current vma->vm_start */
24596 - addr = (vma->vm_start - len) & huge_page_mask(h);
24597 - } while (len <= vma->vm_start);
24598 + addr = skip_heap_stack_gap(vma, len);
24599 + } while (!IS_ERR_VALUE(addr));
24600
24601 fail:
24602 /*
24603 - * if hint left us with no space for the requested
24604 - * mapping then try again:
24605 - */
24606 - if (first_time) {
24607 - mm->free_area_cache = base;
24608 - largest_hole = 0;
24609 - first_time = 0;
24610 - goto try_again;
24611 - }
24612 - /*
24613 * A failed mmap() very likely causes application failure,
24614 * so fall back to the bottom-up function here. This scenario
24615 * can happen with large stack limits and large mmap()
24616 * allocations.
24617 */
24618 - mm->free_area_cache = TASK_UNMAPPED_BASE;
24619 +
24620 +#ifdef CONFIG_PAX_SEGMEXEC
24621 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
24622 + mm->mmap_base = SEGMEXEC_TASK_UNMAPPED_BASE;
24623 + else
24624 +#endif
24625 +
24626 + mm->mmap_base = TASK_UNMAPPED_BASE;
24627 +
24628 +#ifdef CONFIG_PAX_RANDMMAP
24629 + if (mm->pax_flags & MF_PAX_RANDMMAP)
24630 + mm->mmap_base += mm->delta_mmap;
24631 +#endif
24632 +
24633 + mm->free_area_cache = mm->mmap_base;
24634 mm->cached_hole_size = ~0UL;
24635 addr = hugetlb_get_unmapped_area_bottomup(file, addr0,
24636 len, pgoff, flags);
24637 @@ -388,6 +397,7 @@ fail:
24638 /*
24639 * Restore the topdown base:
24640 */
24641 + mm->mmap_base = base;
24642 mm->free_area_cache = base;
24643 mm->cached_hole_size = ~0UL;
24644
24645 @@ -401,10 +411,19 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
24646 struct hstate *h = hstate_file(file);
24647 struct mm_struct *mm = current->mm;
24648 struct vm_area_struct *vma;
24649 + unsigned long pax_task_size = TASK_SIZE;
24650
24651 if (len & ~huge_page_mask(h))
24652 return -EINVAL;
24653 - if (len > TASK_SIZE)
24654 +
24655 +#ifdef CONFIG_PAX_SEGMEXEC
24656 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
24657 + pax_task_size = SEGMEXEC_TASK_SIZE;
24658 +#endif
24659 +
24660 + pax_task_size -= PAGE_SIZE;
24661 +
24662 + if (len > pax_task_size)
24663 return -ENOMEM;
24664
24665 if (flags & MAP_FIXED) {
24666 @@ -416,8 +435,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
24667 if (addr) {
24668 addr = ALIGN(addr, huge_page_size(h));
24669 vma = find_vma(mm, addr);
24670 - if (TASK_SIZE - len >= addr &&
24671 - (!vma || addr + len <= vma->vm_start))
24672 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len))
24673 return addr;
24674 }
24675 if (mm->get_unmapped_area == arch_get_unmapped_area)
24676 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
24677 index 6cabf65..9976a56 100644
24678 --- a/arch/x86/mm/init.c
24679 +++ b/arch/x86/mm/init.c
24680 @@ -17,6 +17,8 @@
24681 #include <asm/tlb.h>
24682 #include <asm/proto.h>
24683 #include <asm/dma.h> /* for MAX_DMA_PFN */
24684 +#include <asm/desc.h>
24685 +#include <asm/bios_ebda.h>
24686
24687 unsigned long __initdata pgt_buf_start;
24688 unsigned long __meminitdata pgt_buf_end;
24689 @@ -33,7 +35,7 @@ int direct_gbpages
24690 static void __init find_early_table_space(unsigned long end, int use_pse,
24691 int use_gbpages)
24692 {
24693 - unsigned long puds, pmds, ptes, tables, start = 0, good_end = end;
24694 + unsigned long puds, pmds, ptes, tables, start = 0x100000, good_end = end;
24695 phys_addr_t base;
24696
24697 puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
24698 @@ -312,10 +314,37 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
24699 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
24700 * mmio resources as well as potential bios/acpi data regions.
24701 */
24702 +
24703 +#ifdef CONFIG_GRKERNSEC_KMEM
24704 +static unsigned int ebda_start __read_only;
24705 +static unsigned int ebda_end __read_only;
24706 +#endif
24707 +
24708 int devmem_is_allowed(unsigned long pagenr)
24709 {
24710 +#ifdef CONFIG_GRKERNSEC_KMEM
24711 + /* allow BDA */
24712 + if (!pagenr)
24713 + return 1;
24714 + /* allow EBDA */
24715 + if (pagenr >= ebda_start && pagenr < ebda_end)
24716 + return 1;
24717 +#else
24718 + if (!pagenr)
24719 + return 1;
24720 +#ifdef CONFIG_VM86
24721 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
24722 + return 1;
24723 +#endif
24724 +#endif
24725 +
24726 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
24727 + return 1;
24728 +#ifdef CONFIG_GRKERNSEC_KMEM
24729 + /* throw out everything else below 1MB */
24730 if (pagenr <= 256)
24731 - return 1;
24732 + return 0;
24733 +#endif
24734 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
24735 return 0;
24736 if (!page_is_ram(pagenr))
24737 @@ -372,8 +401,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
24738 #endif
24739 }
24740
24741 +#ifdef CONFIG_GRKERNSEC_KMEM
24742 +static inline void gr_init_ebda(void)
24743 +{
24744 + unsigned int ebda_addr;
24745 + unsigned int ebda_size = 0;
24746 +
24747 + ebda_addr = get_bios_ebda();
24748 + if (ebda_addr) {
24749 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
24750 + ebda_size <<= 10;
24751 + }
24752 + if (ebda_addr && ebda_size) {
24753 + ebda_start = ebda_addr >> PAGE_SHIFT;
24754 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
24755 + } else {
24756 + ebda_start = 0x9f000 >> PAGE_SHIFT;
24757 + ebda_end = 0xa0000 >> PAGE_SHIFT;
24758 + }
24759 +}
24760 +#else
24761 +static inline void gr_init_ebda(void) { }
24762 +#endif
24763 +
24764 void free_initmem(void)
24765 {
24766 +#ifdef CONFIG_PAX_KERNEXEC
24767 +#ifdef CONFIG_X86_32
24768 + /* PaX: limit KERNEL_CS to actual size */
24769 + unsigned long addr, limit;
24770 + struct desc_struct d;
24771 + int cpu;
24772 +#endif
24773 +#endif
24774 +#ifndef CONFIG_X86_PAE
24775 + pgd_t *pgd;
24776 + pud_t *pud;
24777 + pmd_t *pmd;
24778 + unsigned long addr, end;
24779 +#endif
24780 +
24781 + gr_init_ebda();
24782 +
24783 +#ifdef CONFIG_PAX_KERNEXEC
24784 +#ifdef CONFIG_X86_32
24785 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
24786 + limit = (limit - 1UL) >> PAGE_SHIFT;
24787 +
24788 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
24789 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
24790 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
24791 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
24792 + }
24793 +
24794 + /* PaX: make KERNEL_CS read-only */
24795 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
24796 + if (!paravirt_enabled())
24797 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
24798 +/*
24799 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
24800 + pgd = pgd_offset_k(addr);
24801 + pud = pud_offset(pgd, addr);
24802 + pmd = pmd_offset(pud, addr);
24803 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
24804 + }
24805 +*/
24806 +#ifdef CONFIG_X86_PAE
24807 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
24808 +/*
24809 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
24810 + pgd = pgd_offset_k(addr);
24811 + pud = pud_offset(pgd, addr);
24812 + pmd = pmd_offset(pud, addr);
24813 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
24814 + }
24815 +*/
24816 +#endif
24817 +
24818 +#ifdef CONFIG_MODULES
24819 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
24820 +#endif
24821 +
24822 +#else
24823 + /* PaX: make kernel code/rodata read-only, rest non-executable */
24824 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
24825 + pgd = pgd_offset_k(addr);
24826 + pud = pud_offset(pgd, addr);
24827 + pmd = pmd_offset(pud, addr);
24828 + if (!pmd_present(*pmd))
24829 + continue;
24830 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
24831 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
24832 + else
24833 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
24834 + }
24835 +
24836 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
24837 + end = addr + KERNEL_IMAGE_SIZE;
24838 + for (; addr < end; addr += PMD_SIZE) {
24839 + pgd = pgd_offset_k(addr);
24840 + pud = pud_offset(pgd, addr);
24841 + pmd = pmd_offset(pud, addr);
24842 + if (!pmd_present(*pmd))
24843 + continue;
24844 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
24845 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
24846 + }
24847 +#endif
24848 +
24849 + flush_tlb_all();
24850 +#endif
24851 +
24852 free_init_pages("unused kernel memory",
24853 (unsigned long)(&__init_begin),
24854 (unsigned long)(&__init_end));
24855 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
24856 index 8663f6c..829ae76 100644
24857 --- a/arch/x86/mm/init_32.c
24858 +++ b/arch/x86/mm/init_32.c
24859 @@ -74,36 +74,6 @@ static __init void *alloc_low_page(void)
24860 }
24861
24862 /*
24863 - * Creates a middle page table and puts a pointer to it in the
24864 - * given global directory entry. This only returns the gd entry
24865 - * in non-PAE compilation mode, since the middle layer is folded.
24866 - */
24867 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
24868 -{
24869 - pud_t *pud;
24870 - pmd_t *pmd_table;
24871 -
24872 -#ifdef CONFIG_X86_PAE
24873 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
24874 - if (after_bootmem)
24875 - pmd_table = (pmd_t *)alloc_bootmem_pages(PAGE_SIZE);
24876 - else
24877 - pmd_table = (pmd_t *)alloc_low_page();
24878 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
24879 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
24880 - pud = pud_offset(pgd, 0);
24881 - BUG_ON(pmd_table != pmd_offset(pud, 0));
24882 -
24883 - return pmd_table;
24884 - }
24885 -#endif
24886 - pud = pud_offset(pgd, 0);
24887 - pmd_table = pmd_offset(pud, 0);
24888 -
24889 - return pmd_table;
24890 -}
24891 -
24892 -/*
24893 * Create a page table and place a pointer to it in a middle page
24894 * directory entry:
24895 */
24896 @@ -123,13 +93,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
24897 page_table = (pte_t *)alloc_low_page();
24898
24899 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
24900 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
24901 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
24902 +#else
24903 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
24904 +#endif
24905 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
24906 }
24907
24908 return pte_offset_kernel(pmd, 0);
24909 }
24910
24911 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
24912 +{
24913 + pud_t *pud;
24914 + pmd_t *pmd_table;
24915 +
24916 + pud = pud_offset(pgd, 0);
24917 + pmd_table = pmd_offset(pud, 0);
24918 +
24919 + return pmd_table;
24920 +}
24921 +
24922 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
24923 {
24924 int pgd_idx = pgd_index(vaddr);
24925 @@ -203,6 +188,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
24926 int pgd_idx, pmd_idx;
24927 unsigned long vaddr;
24928 pgd_t *pgd;
24929 + pud_t *pud;
24930 pmd_t *pmd;
24931 pte_t *pte = NULL;
24932
24933 @@ -212,8 +198,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
24934 pgd = pgd_base + pgd_idx;
24935
24936 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
24937 - pmd = one_md_table_init(pgd);
24938 - pmd = pmd + pmd_index(vaddr);
24939 + pud = pud_offset(pgd, vaddr);
24940 + pmd = pmd_offset(pud, vaddr);
24941 +
24942 +#ifdef CONFIG_X86_PAE
24943 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
24944 +#endif
24945 +
24946 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
24947 pmd++, pmd_idx++) {
24948 pte = page_table_kmap_check(one_page_table_init(pmd),
24949 @@ -225,11 +216,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
24950 }
24951 }
24952
24953 -static inline int is_kernel_text(unsigned long addr)
24954 +static inline int is_kernel_text(unsigned long start, unsigned long end)
24955 {
24956 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
24957 - return 1;
24958 - return 0;
24959 + if ((start > ktla_ktva((unsigned long)_etext) ||
24960 + end <= ktla_ktva((unsigned long)_stext)) &&
24961 + (start > ktla_ktva((unsigned long)_einittext) ||
24962 + end <= ktla_ktva((unsigned long)_sinittext)) &&
24963 +
24964 +#ifdef CONFIG_ACPI_SLEEP
24965 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
24966 +#endif
24967 +
24968 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
24969 + return 0;
24970 + return 1;
24971 }
24972
24973 /*
24974 @@ -246,9 +246,10 @@ kernel_physical_mapping_init(unsigned long start,
24975 unsigned long last_map_addr = end;
24976 unsigned long start_pfn, end_pfn;
24977 pgd_t *pgd_base = swapper_pg_dir;
24978 - int pgd_idx, pmd_idx, pte_ofs;
24979 + unsigned int pgd_idx, pmd_idx, pte_ofs;
24980 unsigned long pfn;
24981 pgd_t *pgd;
24982 + pud_t *pud;
24983 pmd_t *pmd;
24984 pte_t *pte;
24985 unsigned pages_2m, pages_4k;
24986 @@ -281,8 +282,13 @@ repeat:
24987 pfn = start_pfn;
24988 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
24989 pgd = pgd_base + pgd_idx;
24990 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
24991 - pmd = one_md_table_init(pgd);
24992 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
24993 + pud = pud_offset(pgd, 0);
24994 + pmd = pmd_offset(pud, 0);
24995 +
24996 +#ifdef CONFIG_X86_PAE
24997 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
24998 +#endif
24999
25000 if (pfn >= end_pfn)
25001 continue;
25002 @@ -294,14 +300,13 @@ repeat:
25003 #endif
25004 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
25005 pmd++, pmd_idx++) {
25006 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
25007 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
25008
25009 /*
25010 * Map with big pages if possible, otherwise
25011 * create normal page tables:
25012 */
25013 if (use_pse) {
25014 - unsigned int addr2;
25015 pgprot_t prot = PAGE_KERNEL_LARGE;
25016 /*
25017 * first pass will use the same initial
25018 @@ -311,11 +316,7 @@ repeat:
25019 __pgprot(PTE_IDENT_ATTR |
25020 _PAGE_PSE);
25021
25022 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
25023 - PAGE_OFFSET + PAGE_SIZE-1;
25024 -
25025 - if (is_kernel_text(addr) ||
25026 - is_kernel_text(addr2))
25027 + if (is_kernel_text(address, address + PMD_SIZE))
25028 prot = PAGE_KERNEL_LARGE_EXEC;
25029
25030 pages_2m++;
25031 @@ -332,7 +333,7 @@ repeat:
25032 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
25033 pte += pte_ofs;
25034 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
25035 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
25036 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
25037 pgprot_t prot = PAGE_KERNEL;
25038 /*
25039 * first pass will use the same initial
25040 @@ -340,7 +341,7 @@ repeat:
25041 */
25042 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
25043
25044 - if (is_kernel_text(addr))
25045 + if (is_kernel_text(address, address + PAGE_SIZE))
25046 prot = PAGE_KERNEL_EXEC;
25047
25048 pages_4k++;
25049 @@ -466,7 +467,7 @@ void __init native_pagetable_setup_start(pgd_t *base)
25050
25051 pud = pud_offset(pgd, va);
25052 pmd = pmd_offset(pud, va);
25053 - if (!pmd_present(*pmd))
25054 + if (!pmd_present(*pmd) || pmd_huge(*pmd))
25055 break;
25056
25057 pte = pte_offset_kernel(pmd, va);
25058 @@ -518,12 +519,10 @@ void __init early_ioremap_page_table_range_init(void)
25059
25060 static void __init pagetable_init(void)
25061 {
25062 - pgd_t *pgd_base = swapper_pg_dir;
25063 -
25064 - permanent_kmaps_init(pgd_base);
25065 + permanent_kmaps_init(swapper_pg_dir);
25066 }
25067
25068 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
25069 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
25070 EXPORT_SYMBOL_GPL(__supported_pte_mask);
25071
25072 /* user-defined highmem size */
25073 @@ -735,6 +734,12 @@ void __init mem_init(void)
25074
25075 pci_iommu_alloc();
25076
25077 +#ifdef CONFIG_PAX_PER_CPU_PGD
25078 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
25079 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25080 + KERNEL_PGD_PTRS);
25081 +#endif
25082 +
25083 #ifdef CONFIG_FLATMEM
25084 BUG_ON(!mem_map);
25085 #endif
25086 @@ -761,7 +766,7 @@ void __init mem_init(void)
25087 reservedpages++;
25088
25089 codesize = (unsigned long) &_etext - (unsigned long) &_text;
25090 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
25091 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
25092 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
25093
25094 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
25095 @@ -802,10 +807,10 @@ void __init mem_init(void)
25096 ((unsigned long)&__init_end -
25097 (unsigned long)&__init_begin) >> 10,
25098
25099 - (unsigned long)&_etext, (unsigned long)&_edata,
25100 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
25101 + (unsigned long)&_sdata, (unsigned long)&_edata,
25102 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
25103
25104 - (unsigned long)&_text, (unsigned long)&_etext,
25105 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
25106 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
25107
25108 /*
25109 @@ -883,6 +888,7 @@ void set_kernel_text_rw(void)
25110 if (!kernel_set_to_readonly)
25111 return;
25112
25113 + start = ktla_ktva(start);
25114 pr_debug("Set kernel text: %lx - %lx for read write\n",
25115 start, start+size);
25116
25117 @@ -897,6 +903,7 @@ void set_kernel_text_ro(void)
25118 if (!kernel_set_to_readonly)
25119 return;
25120
25121 + start = ktla_ktva(start);
25122 pr_debug("Set kernel text: %lx - %lx for read only\n",
25123 start, start+size);
25124
25125 @@ -925,6 +932,7 @@ void mark_rodata_ro(void)
25126 unsigned long start = PFN_ALIGN(_text);
25127 unsigned long size = PFN_ALIGN(_etext) - start;
25128
25129 + start = ktla_ktva(start);
25130 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
25131 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
25132 size >> 10);
25133 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
25134 index 436a030..4f97ffc 100644
25135 --- a/arch/x86/mm/init_64.c
25136 +++ b/arch/x86/mm/init_64.c
25137 @@ -75,7 +75,7 @@ early_param("gbpages", parse_direct_gbpages_on);
25138 * around without checking the pgd every time.
25139 */
25140
25141 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
25142 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
25143 EXPORT_SYMBOL_GPL(__supported_pte_mask);
25144
25145 int force_personality32;
25146 @@ -108,12 +108,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
25147
25148 for (address = start; address <= end; address += PGDIR_SIZE) {
25149 const pgd_t *pgd_ref = pgd_offset_k(address);
25150 +
25151 +#ifdef CONFIG_PAX_PER_CPU_PGD
25152 + unsigned long cpu;
25153 +#else
25154 struct page *page;
25155 +#endif
25156
25157 if (pgd_none(*pgd_ref))
25158 continue;
25159
25160 spin_lock(&pgd_lock);
25161 +
25162 +#ifdef CONFIG_PAX_PER_CPU_PGD
25163 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
25164 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
25165 +#else
25166 list_for_each_entry(page, &pgd_list, lru) {
25167 pgd_t *pgd;
25168 spinlock_t *pgt_lock;
25169 @@ -122,6 +132,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
25170 /* the pgt_lock only for Xen */
25171 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
25172 spin_lock(pgt_lock);
25173 +#endif
25174
25175 if (pgd_none(*pgd))
25176 set_pgd(pgd, *pgd_ref);
25177 @@ -129,7 +140,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
25178 BUG_ON(pgd_page_vaddr(*pgd)
25179 != pgd_page_vaddr(*pgd_ref));
25180
25181 +#ifndef CONFIG_PAX_PER_CPU_PGD
25182 spin_unlock(pgt_lock);
25183 +#endif
25184 +
25185 }
25186 spin_unlock(&pgd_lock);
25187 }
25188 @@ -162,7 +176,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
25189 {
25190 if (pgd_none(*pgd)) {
25191 pud_t *pud = (pud_t *)spp_getpage();
25192 - pgd_populate(&init_mm, pgd, pud);
25193 + pgd_populate_kernel(&init_mm, pgd, pud);
25194 if (pud != pud_offset(pgd, 0))
25195 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
25196 pud, pud_offset(pgd, 0));
25197 @@ -174,7 +188,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
25198 {
25199 if (pud_none(*pud)) {
25200 pmd_t *pmd = (pmd_t *) spp_getpage();
25201 - pud_populate(&init_mm, pud, pmd);
25202 + pud_populate_kernel(&init_mm, pud, pmd);
25203 if (pmd != pmd_offset(pud, 0))
25204 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
25205 pmd, pmd_offset(pud, 0));
25206 @@ -203,7 +217,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
25207 pmd = fill_pmd(pud, vaddr);
25208 pte = fill_pte(pmd, vaddr);
25209
25210 + pax_open_kernel();
25211 set_pte(pte, new_pte);
25212 + pax_close_kernel();
25213
25214 /*
25215 * It's enough to flush this one mapping.
25216 @@ -262,14 +278,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
25217 pgd = pgd_offset_k((unsigned long)__va(phys));
25218 if (pgd_none(*pgd)) {
25219 pud = (pud_t *) spp_getpage();
25220 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
25221 - _PAGE_USER));
25222 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
25223 }
25224 pud = pud_offset(pgd, (unsigned long)__va(phys));
25225 if (pud_none(*pud)) {
25226 pmd = (pmd_t *) spp_getpage();
25227 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
25228 - _PAGE_USER));
25229 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
25230 }
25231 pmd = pmd_offset(pud, phys);
25232 BUG_ON(!pmd_none(*pmd));
25233 @@ -330,7 +344,7 @@ static __ref void *alloc_low_page(unsigned long *phys)
25234 if (pfn >= pgt_buf_top)
25235 panic("alloc_low_page: ran out of memory");
25236
25237 - adr = early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
25238 + adr = (void __force_kernel *)early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
25239 clear_page(adr);
25240 *phys = pfn * PAGE_SIZE;
25241 return adr;
25242 @@ -346,7 +360,7 @@ static __ref void *map_low_page(void *virt)
25243
25244 phys = __pa(virt);
25245 left = phys & (PAGE_SIZE - 1);
25246 - adr = early_memremap(phys & PAGE_MASK, PAGE_SIZE);
25247 + adr = (void __force_kernel *)early_memremap(phys & PAGE_MASK, PAGE_SIZE);
25248 adr = (void *)(((unsigned long)adr) | left);
25249
25250 return adr;
25251 @@ -546,7 +560,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
25252 unmap_low_page(pmd);
25253
25254 spin_lock(&init_mm.page_table_lock);
25255 - pud_populate(&init_mm, pud, __va(pmd_phys));
25256 + pud_populate_kernel(&init_mm, pud, __va(pmd_phys));
25257 spin_unlock(&init_mm.page_table_lock);
25258 }
25259 __flush_tlb_all();
25260 @@ -592,7 +606,7 @@ kernel_physical_mapping_init(unsigned long start,
25261 unmap_low_page(pud);
25262
25263 spin_lock(&init_mm.page_table_lock);
25264 - pgd_populate(&init_mm, pgd, __va(pud_phys));
25265 + pgd_populate_kernel(&init_mm, pgd, __va(pud_phys));
25266 spin_unlock(&init_mm.page_table_lock);
25267 pgd_changed = true;
25268 }
25269 @@ -684,6 +698,12 @@ void __init mem_init(void)
25270
25271 pci_iommu_alloc();
25272
25273 +#ifdef CONFIG_PAX_PER_CPU_PGD
25274 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
25275 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25276 + KERNEL_PGD_PTRS);
25277 +#endif
25278 +
25279 /* clear_bss() already clear the empty_zero_page */
25280
25281 reservedpages = 0;
25282 @@ -844,8 +864,8 @@ int kern_addr_valid(unsigned long addr)
25283 static struct vm_area_struct gate_vma = {
25284 .vm_start = VSYSCALL_START,
25285 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
25286 - .vm_page_prot = PAGE_READONLY_EXEC,
25287 - .vm_flags = VM_READ | VM_EXEC
25288 + .vm_page_prot = PAGE_READONLY,
25289 + .vm_flags = VM_READ
25290 };
25291
25292 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
25293 @@ -879,7 +899,7 @@ int in_gate_area_no_mm(unsigned long addr)
25294
25295 const char *arch_vma_name(struct vm_area_struct *vma)
25296 {
25297 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
25298 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
25299 return "[vdso]";
25300 if (vma == &gate_vma)
25301 return "[vsyscall]";
25302 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
25303 index 7b179b4..6bd1777 100644
25304 --- a/arch/x86/mm/iomap_32.c
25305 +++ b/arch/x86/mm/iomap_32.c
25306 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
25307 type = kmap_atomic_idx_push();
25308 idx = type + KM_TYPE_NR * smp_processor_id();
25309 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
25310 +
25311 + pax_open_kernel();
25312 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
25313 + pax_close_kernel();
25314 +
25315 arch_flush_lazy_mmu_mode();
25316
25317 return (void *)vaddr;
25318 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
25319 index be1ef57..55f0160 100644
25320 --- a/arch/x86/mm/ioremap.c
25321 +++ b/arch/x86/mm/ioremap.c
25322 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
25323 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
25324 int is_ram = page_is_ram(pfn);
25325
25326 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
25327 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
25328 return NULL;
25329 WARN_ON_ONCE(is_ram);
25330 }
25331 @@ -315,6 +315,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
25332
25333 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
25334 if (page_is_ram(start >> PAGE_SHIFT))
25335 +#ifdef CONFIG_HIGHMEM
25336 + if ((start >> PAGE_SHIFT) < max_low_pfn)
25337 +#endif
25338 return __va(phys);
25339
25340 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
25341 @@ -344,7 +347,7 @@ static int __init early_ioremap_debug_setup(char *str)
25342 early_param("early_ioremap_debug", early_ioremap_debug_setup);
25343
25344 static __initdata int after_paging_init;
25345 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
25346 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
25347
25348 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
25349 {
25350 @@ -381,8 +384,7 @@ void __init early_ioremap_init(void)
25351 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
25352
25353 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
25354 - memset(bm_pte, 0, sizeof(bm_pte));
25355 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
25356 + pmd_populate_user(&init_mm, pmd, bm_pte);
25357
25358 /*
25359 * The boot-ioremap range spans multiple pmds, for which
25360 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
25361 index d87dd6d..bf3fa66 100644
25362 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
25363 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
25364 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
25365 * memory (e.g. tracked pages)? For now, we need this to avoid
25366 * invoking kmemcheck for PnP BIOS calls.
25367 */
25368 - if (regs->flags & X86_VM_MASK)
25369 + if (v8086_mode(regs))
25370 return false;
25371 - if (regs->cs != __KERNEL_CS)
25372 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
25373 return false;
25374
25375 pte = kmemcheck_pte_lookup(address);
25376 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
25377 index 845df68..1d8d29f 100644
25378 --- a/arch/x86/mm/mmap.c
25379 +++ b/arch/x86/mm/mmap.c
25380 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
25381 * Leave an at least ~128 MB hole with possible stack randomization.
25382 */
25383 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
25384 -#define MAX_GAP (TASK_SIZE/6*5)
25385 +#define MAX_GAP (pax_task_size/6*5)
25386
25387 static int mmap_is_legacy(void)
25388 {
25389 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
25390 return rnd << PAGE_SHIFT;
25391 }
25392
25393 -static unsigned long mmap_base(void)
25394 +static unsigned long mmap_base(struct mm_struct *mm)
25395 {
25396 unsigned long gap = rlimit(RLIMIT_STACK);
25397 + unsigned long pax_task_size = TASK_SIZE;
25398 +
25399 +#ifdef CONFIG_PAX_SEGMEXEC
25400 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25401 + pax_task_size = SEGMEXEC_TASK_SIZE;
25402 +#endif
25403
25404 if (gap < MIN_GAP)
25405 gap = MIN_GAP;
25406 else if (gap > MAX_GAP)
25407 gap = MAX_GAP;
25408
25409 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
25410 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
25411 }
25412
25413 /*
25414 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
25415 * does, but not when emulating X86_32
25416 */
25417 -static unsigned long mmap_legacy_base(void)
25418 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
25419 {
25420 - if (mmap_is_ia32())
25421 + if (mmap_is_ia32()) {
25422 +
25423 +#ifdef CONFIG_PAX_SEGMEXEC
25424 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25425 + return SEGMEXEC_TASK_UNMAPPED_BASE;
25426 + else
25427 +#endif
25428 +
25429 return TASK_UNMAPPED_BASE;
25430 - else
25431 + } else
25432 return TASK_UNMAPPED_BASE + mmap_rnd();
25433 }
25434
25435 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
25436 void arch_pick_mmap_layout(struct mm_struct *mm)
25437 {
25438 if (mmap_is_legacy()) {
25439 - mm->mmap_base = mmap_legacy_base();
25440 + mm->mmap_base = mmap_legacy_base(mm);
25441 +
25442 +#ifdef CONFIG_PAX_RANDMMAP
25443 + if (mm->pax_flags & MF_PAX_RANDMMAP)
25444 + mm->mmap_base += mm->delta_mmap;
25445 +#endif
25446 +
25447 mm->get_unmapped_area = arch_get_unmapped_area;
25448 mm->unmap_area = arch_unmap_area;
25449 } else {
25450 - mm->mmap_base = mmap_base();
25451 + mm->mmap_base = mmap_base(mm);
25452 +
25453 +#ifdef CONFIG_PAX_RANDMMAP
25454 + if (mm->pax_flags & MF_PAX_RANDMMAP)
25455 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
25456 +#endif
25457 +
25458 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
25459 mm->unmap_area = arch_unmap_area_topdown;
25460 }
25461 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
25462 index dc0b727..dc9d71a 100644
25463 --- a/arch/x86/mm/mmio-mod.c
25464 +++ b/arch/x86/mm/mmio-mod.c
25465 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
25466 break;
25467 default:
25468 {
25469 - unsigned char *ip = (unsigned char *)instptr;
25470 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
25471 my_trace->opcode = MMIO_UNKNOWN_OP;
25472 my_trace->width = 0;
25473 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
25474 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
25475 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
25476 void __iomem *addr)
25477 {
25478 - static atomic_t next_id;
25479 + static atomic_unchecked_t next_id;
25480 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
25481 /* These are page-unaligned. */
25482 struct mmiotrace_map map = {
25483 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
25484 .private = trace
25485 },
25486 .phys = offset,
25487 - .id = atomic_inc_return(&next_id)
25488 + .id = atomic_inc_return_unchecked(&next_id)
25489 };
25490 map.map_id = trace->id;
25491
25492 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
25493 index b008656..773eac2 100644
25494 --- a/arch/x86/mm/pageattr-test.c
25495 +++ b/arch/x86/mm/pageattr-test.c
25496 @@ -36,7 +36,7 @@ enum {
25497
25498 static int pte_testbit(pte_t pte)
25499 {
25500 - return pte_flags(pte) & _PAGE_UNUSED1;
25501 + return pte_flags(pte) & _PAGE_CPA_TEST;
25502 }
25503
25504 struct split_state {
25505 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
25506 index e1ebde3..b1e1db38 100644
25507 --- a/arch/x86/mm/pageattr.c
25508 +++ b/arch/x86/mm/pageattr.c
25509 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
25510 */
25511 #ifdef CONFIG_PCI_BIOS
25512 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
25513 - pgprot_val(forbidden) |= _PAGE_NX;
25514 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
25515 #endif
25516
25517 /*
25518 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
25519 * Does not cover __inittext since that is gone later on. On
25520 * 64bit we do not enforce !NX on the low mapping
25521 */
25522 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
25523 - pgprot_val(forbidden) |= _PAGE_NX;
25524 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
25525 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
25526
25527 +#ifdef CONFIG_DEBUG_RODATA
25528 /*
25529 * The .rodata section needs to be read-only. Using the pfn
25530 * catches all aliases.
25531 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
25532 if (within(pfn, __pa((unsigned long)__start_rodata) >> PAGE_SHIFT,
25533 __pa((unsigned long)__end_rodata) >> PAGE_SHIFT))
25534 pgprot_val(forbidden) |= _PAGE_RW;
25535 +#endif
25536
25537 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
25538 /*
25539 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
25540 }
25541 #endif
25542
25543 +#ifdef CONFIG_PAX_KERNEXEC
25544 + if (within(pfn, __pa((unsigned long)&_text), __pa((unsigned long)&_sdata))) {
25545 + pgprot_val(forbidden) |= _PAGE_RW;
25546 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
25547 + }
25548 +#endif
25549 +
25550 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
25551
25552 return prot;
25553 @@ -369,23 +378,37 @@ EXPORT_SYMBOL_GPL(lookup_address);
25554 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
25555 {
25556 /* change init_mm */
25557 + pax_open_kernel();
25558 set_pte_atomic(kpte, pte);
25559 +
25560 #ifdef CONFIG_X86_32
25561 if (!SHARED_KERNEL_PMD) {
25562 +
25563 +#ifdef CONFIG_PAX_PER_CPU_PGD
25564 + unsigned long cpu;
25565 +#else
25566 struct page *page;
25567 +#endif
25568
25569 +#ifdef CONFIG_PAX_PER_CPU_PGD
25570 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
25571 + pgd_t *pgd = get_cpu_pgd(cpu);
25572 +#else
25573 list_for_each_entry(page, &pgd_list, lru) {
25574 - pgd_t *pgd;
25575 + pgd_t *pgd = (pgd_t *)page_address(page);
25576 +#endif
25577 +
25578 pud_t *pud;
25579 pmd_t *pmd;
25580
25581 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
25582 + pgd += pgd_index(address);
25583 pud = pud_offset(pgd, address);
25584 pmd = pmd_offset(pud, address);
25585 set_pte_atomic((pte_t *)pmd, pte);
25586 }
25587 }
25588 #endif
25589 + pax_close_kernel();
25590 }
25591
25592 static int
25593 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
25594 index f6ff57b..481690f 100644
25595 --- a/arch/x86/mm/pat.c
25596 +++ b/arch/x86/mm/pat.c
25597 @@ -361,7 +361,7 @@ int free_memtype(u64 start, u64 end)
25598
25599 if (!entry) {
25600 printk(KERN_INFO "%s:%d freeing invalid memtype %Lx-%Lx\n",
25601 - current->comm, current->pid, start, end);
25602 + current->comm, task_pid_nr(current), start, end);
25603 return -EINVAL;
25604 }
25605
25606 @@ -492,8 +492,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
25607 while (cursor < to) {
25608 if (!devmem_is_allowed(pfn)) {
25609 printk(KERN_INFO
25610 - "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
25611 - current->comm, from, to);
25612 + "Program %s tried to access /dev/mem between %Lx->%Lx (%Lx).\n",
25613 + current->comm, from, to, cursor);
25614 return 0;
25615 }
25616 cursor += PAGE_SIZE;
25617 @@ -557,7 +557,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
25618 printk(KERN_INFO
25619 "%s:%d ioremap_change_attr failed %s "
25620 "for %Lx-%Lx\n",
25621 - current->comm, current->pid,
25622 + current->comm, task_pid_nr(current),
25623 cattr_name(flags),
25624 base, (unsigned long long)(base + size));
25625 return -EINVAL;
25626 @@ -593,7 +593,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
25627 if (want_flags != flags) {
25628 printk(KERN_WARNING
25629 "%s:%d map pfn RAM range req %s for %Lx-%Lx, got %s\n",
25630 - current->comm, current->pid,
25631 + current->comm, task_pid_nr(current),
25632 cattr_name(want_flags),
25633 (unsigned long long)paddr,
25634 (unsigned long long)(paddr + size),
25635 @@ -615,7 +615,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
25636 free_memtype(paddr, paddr + size);
25637 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
25638 " for %Lx-%Lx, got %s\n",
25639 - current->comm, current->pid,
25640 + current->comm, task_pid_nr(current),
25641 cattr_name(want_flags),
25642 (unsigned long long)paddr,
25643 (unsigned long long)(paddr + size),
25644 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
25645 index 9f0614d..92ae64a 100644
25646 --- a/arch/x86/mm/pf_in.c
25647 +++ b/arch/x86/mm/pf_in.c
25648 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
25649 int i;
25650 enum reason_type rv = OTHERS;
25651
25652 - p = (unsigned char *)ins_addr;
25653 + p = (unsigned char *)ktla_ktva(ins_addr);
25654 p += skip_prefix(p, &prf);
25655 p += get_opcode(p, &opcode);
25656
25657 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
25658 struct prefix_bits prf;
25659 int i;
25660
25661 - p = (unsigned char *)ins_addr;
25662 + p = (unsigned char *)ktla_ktva(ins_addr);
25663 p += skip_prefix(p, &prf);
25664 p += get_opcode(p, &opcode);
25665
25666 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
25667 struct prefix_bits prf;
25668 int i;
25669
25670 - p = (unsigned char *)ins_addr;
25671 + p = (unsigned char *)ktla_ktva(ins_addr);
25672 p += skip_prefix(p, &prf);
25673 p += get_opcode(p, &opcode);
25674
25675 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
25676 struct prefix_bits prf;
25677 int i;
25678
25679 - p = (unsigned char *)ins_addr;
25680 + p = (unsigned char *)ktla_ktva(ins_addr);
25681 p += skip_prefix(p, &prf);
25682 p += get_opcode(p, &opcode);
25683 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
25684 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
25685 struct prefix_bits prf;
25686 int i;
25687
25688 - p = (unsigned char *)ins_addr;
25689 + p = (unsigned char *)ktla_ktva(ins_addr);
25690 p += skip_prefix(p, &prf);
25691 p += get_opcode(p, &opcode);
25692 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
25693 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
25694 index 8573b83..4f3ed7e 100644
25695 --- a/arch/x86/mm/pgtable.c
25696 +++ b/arch/x86/mm/pgtable.c
25697 @@ -84,10 +84,64 @@ static inline void pgd_list_del(pgd_t *pgd)
25698 list_del(&page->lru);
25699 }
25700
25701 -#define UNSHARED_PTRS_PER_PGD \
25702 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
25703 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25704 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
25705
25706 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
25707 +{
25708 + unsigned int count = USER_PGD_PTRS;
25709
25710 + while (count--)
25711 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
25712 +}
25713 +#endif
25714 +
25715 +#ifdef CONFIG_PAX_PER_CPU_PGD
25716 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
25717 +{
25718 + unsigned int count = USER_PGD_PTRS;
25719 +
25720 + while (count--) {
25721 + pgd_t pgd;
25722 +
25723 +#ifdef CONFIG_X86_64
25724 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
25725 +#else
25726 + pgd = *src++;
25727 +#endif
25728 +
25729 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25730 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
25731 +#endif
25732 +
25733 + *dst++ = pgd;
25734 + }
25735 +
25736 +}
25737 +#endif
25738 +
25739 +#ifdef CONFIG_X86_64
25740 +#define pxd_t pud_t
25741 +#define pyd_t pgd_t
25742 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
25743 +#define pxd_free(mm, pud) pud_free((mm), (pud))
25744 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
25745 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
25746 +#define PYD_SIZE PGDIR_SIZE
25747 +#else
25748 +#define pxd_t pmd_t
25749 +#define pyd_t pud_t
25750 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
25751 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
25752 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
25753 +#define pyd_offset(mm, address) pud_offset((mm), (address))
25754 +#define PYD_SIZE PUD_SIZE
25755 +#endif
25756 +
25757 +#ifdef CONFIG_PAX_PER_CPU_PGD
25758 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
25759 +static inline void pgd_dtor(pgd_t *pgd) {}
25760 +#else
25761 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
25762 {
25763 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
25764 @@ -128,6 +182,7 @@ static void pgd_dtor(pgd_t *pgd)
25765 pgd_list_del(pgd);
25766 spin_unlock(&pgd_lock);
25767 }
25768 +#endif
25769
25770 /*
25771 * List of all pgd's needed for non-PAE so it can invalidate entries
25772 @@ -140,7 +195,7 @@ static void pgd_dtor(pgd_t *pgd)
25773 * -- wli
25774 */
25775
25776 -#ifdef CONFIG_X86_PAE
25777 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
25778 /*
25779 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
25780 * updating the top-level pagetable entries to guarantee the
25781 @@ -152,7 +207,7 @@ static void pgd_dtor(pgd_t *pgd)
25782 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
25783 * and initialize the kernel pmds here.
25784 */
25785 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
25786 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
25787
25788 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
25789 {
25790 @@ -170,36 +225,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
25791 */
25792 flush_tlb_mm(mm);
25793 }
25794 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
25795 +#define PREALLOCATED_PXDS USER_PGD_PTRS
25796 #else /* !CONFIG_X86_PAE */
25797
25798 /* No need to prepopulate any pagetable entries in non-PAE modes. */
25799 -#define PREALLOCATED_PMDS 0
25800 +#define PREALLOCATED_PXDS 0
25801
25802 #endif /* CONFIG_X86_PAE */
25803
25804 -static void free_pmds(pmd_t *pmds[])
25805 +static void free_pxds(pxd_t *pxds[])
25806 {
25807 int i;
25808
25809 - for(i = 0; i < PREALLOCATED_PMDS; i++)
25810 - if (pmds[i])
25811 - free_page((unsigned long)pmds[i]);
25812 + for(i = 0; i < PREALLOCATED_PXDS; i++)
25813 + if (pxds[i])
25814 + free_page((unsigned long)pxds[i]);
25815 }
25816
25817 -static int preallocate_pmds(pmd_t *pmds[])
25818 +static int preallocate_pxds(pxd_t *pxds[])
25819 {
25820 int i;
25821 bool failed = false;
25822
25823 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
25824 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
25825 - if (pmd == NULL)
25826 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
25827 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
25828 + if (pxd == NULL)
25829 failed = true;
25830 - pmds[i] = pmd;
25831 + pxds[i] = pxd;
25832 }
25833
25834 if (failed) {
25835 - free_pmds(pmds);
25836 + free_pxds(pxds);
25837 return -ENOMEM;
25838 }
25839
25840 @@ -212,51 +269,55 @@ static int preallocate_pmds(pmd_t *pmds[])
25841 * preallocate which never got a corresponding vma will need to be
25842 * freed manually.
25843 */
25844 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
25845 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
25846 {
25847 int i;
25848
25849 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
25850 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
25851 pgd_t pgd = pgdp[i];
25852
25853 if (pgd_val(pgd) != 0) {
25854 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
25855 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
25856
25857 - pgdp[i] = native_make_pgd(0);
25858 + set_pgd(pgdp + i, native_make_pgd(0));
25859
25860 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
25861 - pmd_free(mm, pmd);
25862 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
25863 + pxd_free(mm, pxd);
25864 }
25865 }
25866 }
25867
25868 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
25869 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
25870 {
25871 - pud_t *pud;
25872 + pyd_t *pyd;
25873 unsigned long addr;
25874 int i;
25875
25876 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
25877 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
25878 return;
25879
25880 - pud = pud_offset(pgd, 0);
25881 +#ifdef CONFIG_X86_64
25882 + pyd = pyd_offset(mm, 0L);
25883 +#else
25884 + pyd = pyd_offset(pgd, 0L);
25885 +#endif
25886
25887 - for (addr = i = 0; i < PREALLOCATED_PMDS;
25888 - i++, pud++, addr += PUD_SIZE) {
25889 - pmd_t *pmd = pmds[i];
25890 + for (addr = i = 0; i < PREALLOCATED_PXDS;
25891 + i++, pyd++, addr += PYD_SIZE) {
25892 + pxd_t *pxd = pxds[i];
25893
25894 if (i >= KERNEL_PGD_BOUNDARY)
25895 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
25896 - sizeof(pmd_t) * PTRS_PER_PMD);
25897 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
25898 + sizeof(pxd_t) * PTRS_PER_PMD);
25899
25900 - pud_populate(mm, pud, pmd);
25901 + pyd_populate(mm, pyd, pxd);
25902 }
25903 }
25904
25905 pgd_t *pgd_alloc(struct mm_struct *mm)
25906 {
25907 pgd_t *pgd;
25908 - pmd_t *pmds[PREALLOCATED_PMDS];
25909 + pxd_t *pxds[PREALLOCATED_PXDS];
25910
25911 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
25912
25913 @@ -265,11 +326,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
25914
25915 mm->pgd = pgd;
25916
25917 - if (preallocate_pmds(pmds) != 0)
25918 + if (preallocate_pxds(pxds) != 0)
25919 goto out_free_pgd;
25920
25921 if (paravirt_pgd_alloc(mm) != 0)
25922 - goto out_free_pmds;
25923 + goto out_free_pxds;
25924
25925 /*
25926 * Make sure that pre-populating the pmds is atomic with
25927 @@ -279,14 +340,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
25928 spin_lock(&pgd_lock);
25929
25930 pgd_ctor(mm, pgd);
25931 - pgd_prepopulate_pmd(mm, pgd, pmds);
25932 + pgd_prepopulate_pxd(mm, pgd, pxds);
25933
25934 spin_unlock(&pgd_lock);
25935
25936 return pgd;
25937
25938 -out_free_pmds:
25939 - free_pmds(pmds);
25940 +out_free_pxds:
25941 + free_pxds(pxds);
25942 out_free_pgd:
25943 free_page((unsigned long)pgd);
25944 out:
25945 @@ -295,7 +356,7 @@ out:
25946
25947 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
25948 {
25949 - pgd_mop_up_pmds(mm, pgd);
25950 + pgd_mop_up_pxds(mm, pgd);
25951 pgd_dtor(pgd);
25952 paravirt_pgd_free(mm, pgd);
25953 free_page((unsigned long)pgd);
25954 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
25955 index cac7184..09a39fa 100644
25956 --- a/arch/x86/mm/pgtable_32.c
25957 +++ b/arch/x86/mm/pgtable_32.c
25958 @@ -48,10 +48,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
25959 return;
25960 }
25961 pte = pte_offset_kernel(pmd, vaddr);
25962 +
25963 + pax_open_kernel();
25964 if (pte_val(pteval))
25965 set_pte_at(&init_mm, vaddr, pte, pteval);
25966 else
25967 pte_clear(&init_mm, vaddr, pte);
25968 + pax_close_kernel();
25969
25970 /*
25971 * It's enough to flush this one mapping.
25972 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
25973 index 410531d..0f16030 100644
25974 --- a/arch/x86/mm/setup_nx.c
25975 +++ b/arch/x86/mm/setup_nx.c
25976 @@ -5,8 +5,10 @@
25977 #include <asm/pgtable.h>
25978 #include <asm/proto.h>
25979
25980 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
25981 static int disable_nx __cpuinitdata;
25982
25983 +#ifndef CONFIG_PAX_PAGEEXEC
25984 /*
25985 * noexec = on|off
25986 *
25987 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
25988 return 0;
25989 }
25990 early_param("noexec", noexec_setup);
25991 +#endif
25992 +
25993 +#endif
25994
25995 void __cpuinit x86_configure_nx(void)
25996 {
25997 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
25998 if (cpu_has_nx && !disable_nx)
25999 __supported_pte_mask |= _PAGE_NX;
26000 else
26001 +#endif
26002 __supported_pte_mask &= ~_PAGE_NX;
26003 }
26004
26005 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
26006 index d6c0418..06a0ad5 100644
26007 --- a/arch/x86/mm/tlb.c
26008 +++ b/arch/x86/mm/tlb.c
26009 @@ -65,7 +65,11 @@ void leave_mm(int cpu)
26010 BUG();
26011 cpumask_clear_cpu(cpu,
26012 mm_cpumask(percpu_read(cpu_tlbstate.active_mm)));
26013 +
26014 +#ifndef CONFIG_PAX_PER_CPU_PGD
26015 load_cr3(swapper_pg_dir);
26016 +#endif
26017 +
26018 }
26019 EXPORT_SYMBOL_GPL(leave_mm);
26020
26021 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
26022 index 6687022..ceabcfa 100644
26023 --- a/arch/x86/net/bpf_jit.S
26024 +++ b/arch/x86/net/bpf_jit.S
26025 @@ -9,6 +9,7 @@
26026 */
26027 #include <linux/linkage.h>
26028 #include <asm/dwarf2.h>
26029 +#include <asm/alternative-asm.h>
26030
26031 /*
26032 * Calling convention :
26033 @@ -35,6 +36,7 @@ sk_load_word:
26034 jle bpf_slow_path_word
26035 mov (SKBDATA,%rsi),%eax
26036 bswap %eax /* ntohl() */
26037 + pax_force_retaddr
26038 ret
26039
26040
26041 @@ -53,6 +55,7 @@ sk_load_half:
26042 jle bpf_slow_path_half
26043 movzwl (SKBDATA,%rsi),%eax
26044 rol $8,%ax # ntohs()
26045 + pax_force_retaddr
26046 ret
26047
26048 sk_load_byte_ind:
26049 @@ -66,6 +69,7 @@ sk_load_byte:
26050 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
26051 jle bpf_slow_path_byte
26052 movzbl (SKBDATA,%rsi),%eax
26053 + pax_force_retaddr
26054 ret
26055
26056 /**
26057 @@ -82,6 +86,7 @@ ENTRY(sk_load_byte_msh)
26058 movzbl (SKBDATA,%rsi),%ebx
26059 and $15,%bl
26060 shl $2,%bl
26061 + pax_force_retaddr
26062 ret
26063 CFI_ENDPROC
26064 ENDPROC(sk_load_byte_msh)
26065 @@ -91,6 +96,7 @@ bpf_error:
26066 xor %eax,%eax
26067 mov -8(%rbp),%rbx
26068 leaveq
26069 + pax_force_retaddr
26070 ret
26071
26072 /* rsi contains offset and can be scratched */
26073 @@ -113,6 +119,7 @@ bpf_slow_path_word:
26074 js bpf_error
26075 mov -12(%rbp),%eax
26076 bswap %eax
26077 + pax_force_retaddr
26078 ret
26079
26080 bpf_slow_path_half:
26081 @@ -121,12 +128,14 @@ bpf_slow_path_half:
26082 mov -12(%rbp),%ax
26083 rol $8,%ax
26084 movzwl %ax,%eax
26085 + pax_force_retaddr
26086 ret
26087
26088 bpf_slow_path_byte:
26089 bpf_slow_path_common(1)
26090 js bpf_error
26091 movzbl -12(%rbp),%eax
26092 + pax_force_retaddr
26093 ret
26094
26095 bpf_slow_path_byte_msh:
26096 @@ -137,4 +146,5 @@ bpf_slow_path_byte_msh:
26097 and $15,%al
26098 shl $2,%al
26099 xchg %eax,%ebx
26100 + pax_force_retaddr
26101 ret
26102 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
26103 index 5a5b6e4..201d42e 100644
26104 --- a/arch/x86/net/bpf_jit_comp.c
26105 +++ b/arch/x86/net/bpf_jit_comp.c
26106 @@ -117,6 +117,10 @@ static inline void bpf_flush_icache(void *start, void *end)
26107 set_fs(old_fs);
26108 }
26109
26110 +struct bpf_jit_work {
26111 + struct work_struct work;
26112 + void *image;
26113 +};
26114
26115 void bpf_jit_compile(struct sk_filter *fp)
26116 {
26117 @@ -141,6 +145,10 @@ void bpf_jit_compile(struct sk_filter *fp)
26118 if (addrs == NULL)
26119 return;
26120
26121 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
26122 + if (!fp->work)
26123 + goto out;
26124 +
26125 /* Before first pass, make a rough estimation of addrs[]
26126 * each bpf instruction is translated to less than 64 bytes
26127 */
26128 @@ -477,7 +485,7 @@ void bpf_jit_compile(struct sk_filter *fp)
26129 common_load: seen |= SEEN_DATAREF;
26130 if ((int)K < 0) {
26131 /* Abort the JIT because __load_pointer() is needed. */
26132 - goto out;
26133 + goto error;
26134 }
26135 t_offset = func - (image + addrs[i]);
26136 EMIT1_off32(0xbe, K); /* mov imm32,%esi */
26137 @@ -492,7 +500,7 @@ common_load: seen |= SEEN_DATAREF;
26138 case BPF_S_LDX_B_MSH:
26139 if ((int)K < 0) {
26140 /* Abort the JIT because __load_pointer() is needed. */
26141 - goto out;
26142 + goto error;
26143 }
26144 seen |= SEEN_DATAREF | SEEN_XREG;
26145 t_offset = sk_load_byte_msh - (image + addrs[i]);
26146 @@ -582,17 +590,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
26147 break;
26148 default:
26149 /* hmm, too complex filter, give up with jit compiler */
26150 - goto out;
26151 + goto error;
26152 }
26153 ilen = prog - temp;
26154 if (image) {
26155 if (unlikely(proglen + ilen > oldproglen)) {
26156 pr_err("bpb_jit_compile fatal error\n");
26157 - kfree(addrs);
26158 - module_free(NULL, image);
26159 - return;
26160 + module_free_exec(NULL, image);
26161 + goto error;
26162 }
26163 + pax_open_kernel();
26164 memcpy(image + proglen, temp, ilen);
26165 + pax_close_kernel();
26166 }
26167 proglen += ilen;
26168 addrs[i] = proglen;
26169 @@ -613,11 +622,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
26170 break;
26171 }
26172 if (proglen == oldproglen) {
26173 - image = module_alloc(max_t(unsigned int,
26174 - proglen,
26175 - sizeof(struct work_struct)));
26176 + image = module_alloc_exec(proglen);
26177 if (!image)
26178 - goto out;
26179 + goto error;
26180 }
26181 oldproglen = proglen;
26182 }
26183 @@ -633,7 +640,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
26184 bpf_flush_icache(image, image + proglen);
26185
26186 fp->bpf_func = (void *)image;
26187 - }
26188 + } else
26189 +error:
26190 + kfree(fp->work);
26191 +
26192 out:
26193 kfree(addrs);
26194 return;
26195 @@ -641,18 +651,20 @@ out:
26196
26197 static void jit_free_defer(struct work_struct *arg)
26198 {
26199 - module_free(NULL, arg);
26200 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
26201 + kfree(arg);
26202 }
26203
26204 /* run from softirq, we must use a work_struct to call
26205 - * module_free() from process context
26206 + * module_free_exec() from process context
26207 */
26208 void bpf_jit_free(struct sk_filter *fp)
26209 {
26210 if (fp->bpf_func != sk_run_filter) {
26211 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
26212 + struct work_struct *work = &fp->work->work;
26213
26214 INIT_WORK(work, jit_free_defer);
26215 + fp->work->image = fp->bpf_func;
26216 schedule_work(work);
26217 }
26218 }
26219 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
26220 index bff89df..377758a 100644
26221 --- a/arch/x86/oprofile/backtrace.c
26222 +++ b/arch/x86/oprofile/backtrace.c
26223 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
26224 struct stack_frame_ia32 *fp;
26225 unsigned long bytes;
26226
26227 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
26228 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
26229 if (bytes != sizeof(bufhead))
26230 return NULL;
26231
26232 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
26233 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
26234
26235 oprofile_add_trace(bufhead[0].return_address);
26236
26237 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
26238 struct stack_frame bufhead[2];
26239 unsigned long bytes;
26240
26241 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
26242 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
26243 if (bytes != sizeof(bufhead))
26244 return NULL;
26245
26246 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
26247 {
26248 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
26249
26250 - if (!user_mode_vm(regs)) {
26251 + if (!user_mode(regs)) {
26252 unsigned long stack = kernel_stack_pointer(regs);
26253 if (depth)
26254 dump_trace(NULL, regs, (unsigned long *)stack, 0,
26255 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
26256 index cb29191..036766d 100644
26257 --- a/arch/x86/pci/mrst.c
26258 +++ b/arch/x86/pci/mrst.c
26259 @@ -234,7 +234,9 @@ int __init pci_mrst_init(void)
26260 printk(KERN_INFO "Moorestown platform detected, using MRST PCI ops\n");
26261 pci_mmcfg_late_init();
26262 pcibios_enable_irq = mrst_pci_irq_enable;
26263 - pci_root_ops = pci_mrst_ops;
26264 + pax_open_kernel();
26265 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
26266 + pax_close_kernel();
26267 /* Continue with standard init */
26268 return 1;
26269 }
26270 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
26271 index da8fe05..7ee6704 100644
26272 --- a/arch/x86/pci/pcbios.c
26273 +++ b/arch/x86/pci/pcbios.c
26274 @@ -79,50 +79,93 @@ union bios32 {
26275 static struct {
26276 unsigned long address;
26277 unsigned short segment;
26278 -} bios32_indirect = { 0, __KERNEL_CS };
26279 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
26280
26281 /*
26282 * Returns the entry point for the given service, NULL on error
26283 */
26284
26285 -static unsigned long bios32_service(unsigned long service)
26286 +static unsigned long __devinit bios32_service(unsigned long service)
26287 {
26288 unsigned char return_code; /* %al */
26289 unsigned long address; /* %ebx */
26290 unsigned long length; /* %ecx */
26291 unsigned long entry; /* %edx */
26292 unsigned long flags;
26293 + struct desc_struct d, *gdt;
26294
26295 local_irq_save(flags);
26296 - __asm__("lcall *(%%edi); cld"
26297 +
26298 + gdt = get_cpu_gdt_table(smp_processor_id());
26299 +
26300 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
26301 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
26302 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
26303 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
26304 +
26305 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
26306 : "=a" (return_code),
26307 "=b" (address),
26308 "=c" (length),
26309 "=d" (entry)
26310 : "0" (service),
26311 "1" (0),
26312 - "D" (&bios32_indirect));
26313 + "D" (&bios32_indirect),
26314 + "r"(__PCIBIOS_DS)
26315 + : "memory");
26316 +
26317 + pax_open_kernel();
26318 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
26319 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
26320 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
26321 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
26322 + pax_close_kernel();
26323 +
26324 local_irq_restore(flags);
26325
26326 switch (return_code) {
26327 - case 0:
26328 - return address + entry;
26329 - case 0x80: /* Not present */
26330 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
26331 - return 0;
26332 - default: /* Shouldn't happen */
26333 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
26334 - service, return_code);
26335 + case 0: {
26336 + int cpu;
26337 + unsigned char flags;
26338 +
26339 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
26340 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
26341 + printk(KERN_WARNING "bios32_service: not valid\n");
26342 return 0;
26343 + }
26344 + address = address + PAGE_OFFSET;
26345 + length += 16UL; /* some BIOSs underreport this... */
26346 + flags = 4;
26347 + if (length >= 64*1024*1024) {
26348 + length >>= PAGE_SHIFT;
26349 + flags |= 8;
26350 + }
26351 +
26352 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
26353 + gdt = get_cpu_gdt_table(cpu);
26354 + pack_descriptor(&d, address, length, 0x9b, flags);
26355 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
26356 + pack_descriptor(&d, address, length, 0x93, flags);
26357 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
26358 + }
26359 + return entry;
26360 + }
26361 + case 0x80: /* Not present */
26362 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
26363 + return 0;
26364 + default: /* Shouldn't happen */
26365 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
26366 + service, return_code);
26367 + return 0;
26368 }
26369 }
26370
26371 static struct {
26372 unsigned long address;
26373 unsigned short segment;
26374 -} pci_indirect = { 0, __KERNEL_CS };
26375 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
26376
26377 -static int pci_bios_present;
26378 +static int pci_bios_present __read_only;
26379
26380 static int __devinit check_pcibios(void)
26381 {
26382 @@ -131,11 +174,13 @@ static int __devinit check_pcibios(void)
26383 unsigned long flags, pcibios_entry;
26384
26385 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
26386 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
26387 + pci_indirect.address = pcibios_entry;
26388
26389 local_irq_save(flags);
26390 - __asm__(
26391 - "lcall *(%%edi); cld\n\t"
26392 + __asm__("movw %w6, %%ds\n\t"
26393 + "lcall *%%ss:(%%edi); cld\n\t"
26394 + "push %%ss\n\t"
26395 + "pop %%ds\n\t"
26396 "jc 1f\n\t"
26397 "xor %%ah, %%ah\n"
26398 "1:"
26399 @@ -144,7 +189,8 @@ static int __devinit check_pcibios(void)
26400 "=b" (ebx),
26401 "=c" (ecx)
26402 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
26403 - "D" (&pci_indirect)
26404 + "D" (&pci_indirect),
26405 + "r" (__PCIBIOS_DS)
26406 : "memory");
26407 local_irq_restore(flags);
26408
26409 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
26410
26411 switch (len) {
26412 case 1:
26413 - __asm__("lcall *(%%esi); cld\n\t"
26414 + __asm__("movw %w6, %%ds\n\t"
26415 + "lcall *%%ss:(%%esi); cld\n\t"
26416 + "push %%ss\n\t"
26417 + "pop %%ds\n\t"
26418 "jc 1f\n\t"
26419 "xor %%ah, %%ah\n"
26420 "1:"
26421 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
26422 : "1" (PCIBIOS_READ_CONFIG_BYTE),
26423 "b" (bx),
26424 "D" ((long)reg),
26425 - "S" (&pci_indirect));
26426 + "S" (&pci_indirect),
26427 + "r" (__PCIBIOS_DS));
26428 /*
26429 * Zero-extend the result beyond 8 bits, do not trust the
26430 * BIOS having done it:
26431 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
26432 *value &= 0xff;
26433 break;
26434 case 2:
26435 - __asm__("lcall *(%%esi); cld\n\t"
26436 + __asm__("movw %w6, %%ds\n\t"
26437 + "lcall *%%ss:(%%esi); cld\n\t"
26438 + "push %%ss\n\t"
26439 + "pop %%ds\n\t"
26440 "jc 1f\n\t"
26441 "xor %%ah, %%ah\n"
26442 "1:"
26443 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
26444 : "1" (PCIBIOS_READ_CONFIG_WORD),
26445 "b" (bx),
26446 "D" ((long)reg),
26447 - "S" (&pci_indirect));
26448 + "S" (&pci_indirect),
26449 + "r" (__PCIBIOS_DS));
26450 /*
26451 * Zero-extend the result beyond 16 bits, do not trust the
26452 * BIOS having done it:
26453 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
26454 *value &= 0xffff;
26455 break;
26456 case 4:
26457 - __asm__("lcall *(%%esi); cld\n\t"
26458 + __asm__("movw %w6, %%ds\n\t"
26459 + "lcall *%%ss:(%%esi); cld\n\t"
26460 + "push %%ss\n\t"
26461 + "pop %%ds\n\t"
26462 "jc 1f\n\t"
26463 "xor %%ah, %%ah\n"
26464 "1:"
26465 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
26466 : "1" (PCIBIOS_READ_CONFIG_DWORD),
26467 "b" (bx),
26468 "D" ((long)reg),
26469 - "S" (&pci_indirect));
26470 + "S" (&pci_indirect),
26471 + "r" (__PCIBIOS_DS));
26472 break;
26473 }
26474
26475 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
26476
26477 switch (len) {
26478 case 1:
26479 - __asm__("lcall *(%%esi); cld\n\t"
26480 + __asm__("movw %w6, %%ds\n\t"
26481 + "lcall *%%ss:(%%esi); cld\n\t"
26482 + "push %%ss\n\t"
26483 + "pop %%ds\n\t"
26484 "jc 1f\n\t"
26485 "xor %%ah, %%ah\n"
26486 "1:"
26487 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
26488 "c" (value),
26489 "b" (bx),
26490 "D" ((long)reg),
26491 - "S" (&pci_indirect));
26492 + "S" (&pci_indirect),
26493 + "r" (__PCIBIOS_DS));
26494 break;
26495 case 2:
26496 - __asm__("lcall *(%%esi); cld\n\t"
26497 + __asm__("movw %w6, %%ds\n\t"
26498 + "lcall *%%ss:(%%esi); cld\n\t"
26499 + "push %%ss\n\t"
26500 + "pop %%ds\n\t"
26501 "jc 1f\n\t"
26502 "xor %%ah, %%ah\n"
26503 "1:"
26504 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
26505 "c" (value),
26506 "b" (bx),
26507 "D" ((long)reg),
26508 - "S" (&pci_indirect));
26509 + "S" (&pci_indirect),
26510 + "r" (__PCIBIOS_DS));
26511 break;
26512 case 4:
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 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
26522 "c" (value),
26523 "b" (bx),
26524 "D" ((long)reg),
26525 - "S" (&pci_indirect));
26526 + "S" (&pci_indirect),
26527 + "r" (__PCIBIOS_DS));
26528 break;
26529 }
26530
26531 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
26532
26533 DBG("PCI: Fetching IRQ routing table... ");
26534 __asm__("push %%es\n\t"
26535 + "movw %w8, %%ds\n\t"
26536 "push %%ds\n\t"
26537 "pop %%es\n\t"
26538 - "lcall *(%%esi); cld\n\t"
26539 + "lcall *%%ss:(%%esi); cld\n\t"
26540 "pop %%es\n\t"
26541 + "push %%ss\n\t"
26542 + "pop %%ds\n"
26543 "jc 1f\n\t"
26544 "xor %%ah, %%ah\n"
26545 "1:"
26546 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
26547 "1" (0),
26548 "D" ((long) &opt),
26549 "S" (&pci_indirect),
26550 - "m" (opt)
26551 + "m" (opt),
26552 + "r" (__PCIBIOS_DS)
26553 : "memory");
26554 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
26555 if (ret & 0xff00)
26556 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
26557 {
26558 int ret;
26559
26560 - __asm__("lcall *(%%esi); cld\n\t"
26561 + __asm__("movw %w5, %%ds\n\t"
26562 + "lcall *%%ss:(%%esi); cld\n\t"
26563 + "push %%ss\n\t"
26564 + "pop %%ds\n"
26565 "jc 1f\n\t"
26566 "xor %%ah, %%ah\n"
26567 "1:"
26568 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
26569 : "0" (PCIBIOS_SET_PCI_HW_INT),
26570 "b" ((dev->bus->number << 8) | dev->devfn),
26571 "c" ((irq << 8) | (pin + 10)),
26572 - "S" (&pci_indirect));
26573 + "S" (&pci_indirect),
26574 + "r" (__PCIBIOS_DS));
26575 return !(ret & 0xff00);
26576 }
26577 EXPORT_SYMBOL(pcibios_set_irq_routing);
26578 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
26579 index 40e4469..1ab536e 100644
26580 --- a/arch/x86/platform/efi/efi_32.c
26581 +++ b/arch/x86/platform/efi/efi_32.c
26582 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
26583 {
26584 struct desc_ptr gdt_descr;
26585
26586 +#ifdef CONFIG_PAX_KERNEXEC
26587 + struct desc_struct d;
26588 +#endif
26589 +
26590 local_irq_save(efi_rt_eflags);
26591
26592 load_cr3(initial_page_table);
26593 __flush_tlb_all();
26594
26595 +#ifdef CONFIG_PAX_KERNEXEC
26596 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
26597 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
26598 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
26599 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
26600 +#endif
26601 +
26602 gdt_descr.address = __pa(get_cpu_gdt_table(0));
26603 gdt_descr.size = GDT_SIZE - 1;
26604 load_gdt(&gdt_descr);
26605 @@ -58,6 +69,14 @@ void efi_call_phys_epilog(void)
26606 {
26607 struct desc_ptr gdt_descr;
26608
26609 +#ifdef CONFIG_PAX_KERNEXEC
26610 + struct desc_struct d;
26611 +
26612 + memset(&d, 0, sizeof d);
26613 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
26614 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
26615 +#endif
26616 +
26617 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
26618 gdt_descr.size = GDT_SIZE - 1;
26619 load_gdt(&gdt_descr);
26620 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
26621 index fbe66e6..c5c0dd2 100644
26622 --- a/arch/x86/platform/efi/efi_stub_32.S
26623 +++ b/arch/x86/platform/efi/efi_stub_32.S
26624 @@ -6,7 +6,9 @@
26625 */
26626
26627 #include <linux/linkage.h>
26628 +#include <linux/init.h>
26629 #include <asm/page_types.h>
26630 +#include <asm/segment.h>
26631
26632 /*
26633 * efi_call_phys(void *, ...) is a function with variable parameters.
26634 @@ -20,7 +22,7 @@
26635 * service functions will comply with gcc calling convention, too.
26636 */
26637
26638 -.text
26639 +__INIT
26640 ENTRY(efi_call_phys)
26641 /*
26642 * 0. The function can only be called in Linux kernel. So CS has been
26643 @@ -36,9 +38,11 @@ ENTRY(efi_call_phys)
26644 * The mapping of lower virtual memory has been created in prelog and
26645 * epilog.
26646 */
26647 - movl $1f, %edx
26648 - subl $__PAGE_OFFSET, %edx
26649 - jmp *%edx
26650 + movl $(__KERNEXEC_EFI_DS), %edx
26651 + mov %edx, %ds
26652 + mov %edx, %es
26653 + mov %edx, %ss
26654 + ljmp $(__KERNEXEC_EFI_CS),$1f-__PAGE_OFFSET
26655 1:
26656
26657 /*
26658 @@ -47,14 +51,8 @@ ENTRY(efi_call_phys)
26659 * parameter 2, ..., param n. To make things easy, we save the return
26660 * address of efi_call_phys in a global variable.
26661 */
26662 - popl %edx
26663 - movl %edx, saved_return_addr
26664 - /* get the function pointer into ECX*/
26665 - popl %ecx
26666 - movl %ecx, efi_rt_function_ptr
26667 - movl $2f, %edx
26668 - subl $__PAGE_OFFSET, %edx
26669 - pushl %edx
26670 + popl (saved_return_addr)
26671 + popl (efi_rt_function_ptr)
26672
26673 /*
26674 * 3. Clear PG bit in %CR0.
26675 @@ -73,9 +71,8 @@ ENTRY(efi_call_phys)
26676 /*
26677 * 5. Call the physical function.
26678 */
26679 - jmp *%ecx
26680 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
26681
26682 -2:
26683 /*
26684 * 6. After EFI runtime service returns, control will return to
26685 * following instruction. We'd better readjust stack pointer first.
26686 @@ -88,35 +85,32 @@ ENTRY(efi_call_phys)
26687 movl %cr0, %edx
26688 orl $0x80000000, %edx
26689 movl %edx, %cr0
26690 - jmp 1f
26691 -1:
26692 +
26693 /*
26694 * 8. Now restore the virtual mode from flat mode by
26695 * adding EIP with PAGE_OFFSET.
26696 */
26697 - movl $1f, %edx
26698 - jmp *%edx
26699 + ljmp $(__KERNEL_CS),$1f+__PAGE_OFFSET
26700 1:
26701 + movl $(__KERNEL_DS), %edx
26702 + mov %edx, %ds
26703 + mov %edx, %es
26704 + mov %edx, %ss
26705
26706 /*
26707 * 9. Balance the stack. And because EAX contain the return value,
26708 * we'd better not clobber it.
26709 */
26710 - leal efi_rt_function_ptr, %edx
26711 - movl (%edx), %ecx
26712 - pushl %ecx
26713 + pushl (efi_rt_function_ptr)
26714
26715 /*
26716 - * 10. Push the saved return address onto the stack and return.
26717 + * 10. Return to the saved return address.
26718 */
26719 - leal saved_return_addr, %edx
26720 - movl (%edx), %ecx
26721 - pushl %ecx
26722 - ret
26723 + jmpl *(saved_return_addr)
26724 ENDPROC(efi_call_phys)
26725 .previous
26726
26727 -.data
26728 +__INITDATA
26729 saved_return_addr:
26730 .long 0
26731 efi_rt_function_ptr:
26732 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
26733 index 4c07cca..2c8427d 100644
26734 --- a/arch/x86/platform/efi/efi_stub_64.S
26735 +++ b/arch/x86/platform/efi/efi_stub_64.S
26736 @@ -7,6 +7,7 @@
26737 */
26738
26739 #include <linux/linkage.h>
26740 +#include <asm/alternative-asm.h>
26741
26742 #define SAVE_XMM \
26743 mov %rsp, %rax; \
26744 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
26745 call *%rdi
26746 addq $32, %rsp
26747 RESTORE_XMM
26748 + pax_force_retaddr 0, 1
26749 ret
26750 ENDPROC(efi_call0)
26751
26752 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
26753 call *%rdi
26754 addq $32, %rsp
26755 RESTORE_XMM
26756 + pax_force_retaddr 0, 1
26757 ret
26758 ENDPROC(efi_call1)
26759
26760 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
26761 call *%rdi
26762 addq $32, %rsp
26763 RESTORE_XMM
26764 + pax_force_retaddr 0, 1
26765 ret
26766 ENDPROC(efi_call2)
26767
26768 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
26769 call *%rdi
26770 addq $32, %rsp
26771 RESTORE_XMM
26772 + pax_force_retaddr 0, 1
26773 ret
26774 ENDPROC(efi_call3)
26775
26776 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
26777 call *%rdi
26778 addq $32, %rsp
26779 RESTORE_XMM
26780 + pax_force_retaddr 0, 1
26781 ret
26782 ENDPROC(efi_call4)
26783
26784 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
26785 call *%rdi
26786 addq $48, %rsp
26787 RESTORE_XMM
26788 + pax_force_retaddr 0, 1
26789 ret
26790 ENDPROC(efi_call5)
26791
26792 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
26793 call *%rdi
26794 addq $48, %rsp
26795 RESTORE_XMM
26796 + pax_force_retaddr 0, 1
26797 ret
26798 ENDPROC(efi_call6)
26799 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
26800 index 475e2cd..1b8e708 100644
26801 --- a/arch/x86/platform/mrst/mrst.c
26802 +++ b/arch/x86/platform/mrst/mrst.c
26803 @@ -76,18 +76,20 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
26804 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
26805 int sfi_mrtc_num;
26806
26807 -static void mrst_power_off(void)
26808 +static __noreturn void mrst_power_off(void)
26809 {
26810 if (__mrst_cpu_chip == MRST_CPU_CHIP_LINCROFT)
26811 intel_scu_ipc_simple_command(IPCMSG_COLD_RESET, 1);
26812 + BUG();
26813 }
26814
26815 -static void mrst_reboot(void)
26816 +static __noreturn void mrst_reboot(void)
26817 {
26818 if (__mrst_cpu_chip == MRST_CPU_CHIP_LINCROFT)
26819 intel_scu_ipc_simple_command(IPCMSG_COLD_RESET, 0);
26820 else
26821 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
26822 + BUG();
26823 }
26824
26825 /* parse all the mtimer info to a static mtimer array */
26826 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
26827 index f10c0af..3ec1f95 100644
26828 --- a/arch/x86/power/cpu.c
26829 +++ b/arch/x86/power/cpu.c
26830 @@ -131,7 +131,7 @@ static void do_fpu_end(void)
26831 static void fix_processor_context(void)
26832 {
26833 int cpu = smp_processor_id();
26834 - struct tss_struct *t = &per_cpu(init_tss, cpu);
26835 + struct tss_struct *t = init_tss + cpu;
26836
26837 set_tss_desc(cpu, t); /*
26838 * This just modifies memory; should not be
26839 @@ -141,7 +141,9 @@ static void fix_processor_context(void)
26840 */
26841
26842 #ifdef CONFIG_X86_64
26843 + pax_open_kernel();
26844 get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9;
26845 + pax_close_kernel();
26846
26847 syscall_init(); /* This sets MSR_*STAR and related */
26848 #endif
26849 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
26850 index 5d17950..2253fc9 100644
26851 --- a/arch/x86/vdso/Makefile
26852 +++ b/arch/x86/vdso/Makefile
26853 @@ -137,7 +137,7 @@ quiet_cmd_vdso = VDSO $@
26854 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
26855 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
26856
26857 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
26858 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
26859 GCOV_PROFILE := n
26860
26861 #
26862 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
26863 index 468d591..8e80a0a 100644
26864 --- a/arch/x86/vdso/vdso32-setup.c
26865 +++ b/arch/x86/vdso/vdso32-setup.c
26866 @@ -25,6 +25,7 @@
26867 #include <asm/tlbflush.h>
26868 #include <asm/vdso.h>
26869 #include <asm/proto.h>
26870 +#include <asm/mman.h>
26871
26872 enum {
26873 VDSO_DISABLED = 0,
26874 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
26875 void enable_sep_cpu(void)
26876 {
26877 int cpu = get_cpu();
26878 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
26879 + struct tss_struct *tss = init_tss + cpu;
26880
26881 if (!boot_cpu_has(X86_FEATURE_SEP)) {
26882 put_cpu();
26883 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
26884 gate_vma.vm_start = FIXADDR_USER_START;
26885 gate_vma.vm_end = FIXADDR_USER_END;
26886 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
26887 - gate_vma.vm_page_prot = __P101;
26888 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
26889 /*
26890 * Make sure the vDSO gets into every core dump.
26891 * Dumping its contents makes post-mortem fully interpretable later
26892 @@ -331,14 +332,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
26893 if (compat)
26894 addr = VDSO_HIGH_BASE;
26895 else {
26896 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
26897 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
26898 if (IS_ERR_VALUE(addr)) {
26899 ret = addr;
26900 goto up_fail;
26901 }
26902 }
26903
26904 - current->mm->context.vdso = (void *)addr;
26905 + current->mm->context.vdso = addr;
26906
26907 if (compat_uses_vma || !compat) {
26908 /*
26909 @@ -361,11 +362,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
26910 }
26911
26912 current_thread_info()->sysenter_return =
26913 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
26914 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
26915
26916 up_fail:
26917 if (ret)
26918 - current->mm->context.vdso = NULL;
26919 + current->mm->context.vdso = 0;
26920
26921 up_write(&mm->mmap_sem);
26922
26923 @@ -412,8 +413,14 @@ __initcall(ia32_binfmt_init);
26924
26925 const char *arch_vma_name(struct vm_area_struct *vma)
26926 {
26927 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
26928 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
26929 return "[vdso]";
26930 +
26931 +#ifdef CONFIG_PAX_SEGMEXEC
26932 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
26933 + return "[vdso]";
26934 +#endif
26935 +
26936 return NULL;
26937 }
26938
26939 @@ -423,7 +430,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
26940 * Check to see if the corresponding task was created in compat vdso
26941 * mode.
26942 */
26943 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
26944 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
26945 return &gate_vma;
26946 return NULL;
26947 }
26948 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
26949 index 153407c..611cba9 100644
26950 --- a/arch/x86/vdso/vma.c
26951 +++ b/arch/x86/vdso/vma.c
26952 @@ -16,8 +16,6 @@
26953 #include <asm/vdso.h>
26954 #include <asm/page.h>
26955
26956 -unsigned int __read_mostly vdso_enabled = 1;
26957 -
26958 extern char vdso_start[], vdso_end[];
26959 extern unsigned short vdso_sync_cpuid;
26960
26961 @@ -96,7 +94,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
26962 * unaligned here as a result of stack start randomization.
26963 */
26964 addr = PAGE_ALIGN(addr);
26965 - addr = align_addr(addr, NULL, ALIGN_VDSO);
26966
26967 return addr;
26968 }
26969 @@ -106,40 +103,35 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
26970 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
26971 {
26972 struct mm_struct *mm = current->mm;
26973 - unsigned long addr;
26974 + unsigned long addr = 0;
26975 int ret;
26976
26977 - if (!vdso_enabled)
26978 - return 0;
26979 -
26980 down_write(&mm->mmap_sem);
26981 +
26982 +#ifdef CONFIG_PAX_RANDMMAP
26983 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
26984 +#endif
26985 +
26986 addr = vdso_addr(mm->start_stack, vdso_size);
26987 + addr = align_addr(addr, NULL, ALIGN_VDSO);
26988 addr = get_unmapped_area(NULL, addr, vdso_size, 0, 0);
26989 if (IS_ERR_VALUE(addr)) {
26990 ret = addr;
26991 goto up_fail;
26992 }
26993
26994 - current->mm->context.vdso = (void *)addr;
26995 + mm->context.vdso = addr;
26996
26997 ret = install_special_mapping(mm, addr, vdso_size,
26998 VM_READ|VM_EXEC|
26999 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC|
27000 VM_ALWAYSDUMP,
27001 vdso_pages);
27002 - if (ret) {
27003 - current->mm->context.vdso = NULL;
27004 - goto up_fail;
27005 - }
27006 +
27007 + if (ret)
27008 + mm->context.vdso = 0;
27009
27010 up_fail:
27011 up_write(&mm->mmap_sem);
27012 return ret;
27013 }
27014 -
27015 -static __init int vdso_setup(char *s)
27016 -{
27017 - vdso_enabled = simple_strtoul(s, NULL, 0);
27018 - return 0;
27019 -}
27020 -__setup("vdso=", vdso_setup);
27021 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
27022 index 4e517d4..68a48f5 100644
27023 --- a/arch/x86/xen/enlighten.c
27024 +++ b/arch/x86/xen/enlighten.c
27025 @@ -86,8 +86,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
27026
27027 struct shared_info xen_dummy_shared_info;
27028
27029 -void *xen_initial_gdt;
27030 -
27031 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
27032 __read_mostly int xen_have_vector_callback;
27033 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
27034 @@ -1030,30 +1028,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
27035 #endif
27036 };
27037
27038 -static void xen_reboot(int reason)
27039 +static __noreturn void xen_reboot(int reason)
27040 {
27041 struct sched_shutdown r = { .reason = reason };
27042
27043 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
27044 - BUG();
27045 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
27046 + BUG();
27047 }
27048
27049 -static void xen_restart(char *msg)
27050 +static __noreturn void xen_restart(char *msg)
27051 {
27052 xen_reboot(SHUTDOWN_reboot);
27053 }
27054
27055 -static void xen_emergency_restart(void)
27056 +static __noreturn void xen_emergency_restart(void)
27057 {
27058 xen_reboot(SHUTDOWN_reboot);
27059 }
27060
27061 -static void xen_machine_halt(void)
27062 +static __noreturn void xen_machine_halt(void)
27063 {
27064 xen_reboot(SHUTDOWN_poweroff);
27065 }
27066
27067 -static void xen_machine_power_off(void)
27068 +static __noreturn void xen_machine_power_off(void)
27069 {
27070 if (pm_power_off)
27071 pm_power_off();
27072 @@ -1156,7 +1154,17 @@ asmlinkage void __init xen_start_kernel(void)
27073 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
27074
27075 /* Work out if we support NX */
27076 - x86_configure_nx();
27077 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
27078 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
27079 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
27080 + unsigned l, h;
27081 +
27082 + __supported_pte_mask |= _PAGE_NX;
27083 + rdmsr(MSR_EFER, l, h);
27084 + l |= EFER_NX;
27085 + wrmsr(MSR_EFER, l, h);
27086 + }
27087 +#endif
27088
27089 xen_setup_features();
27090
27091 @@ -1187,13 +1195,6 @@ asmlinkage void __init xen_start_kernel(void)
27092
27093 machine_ops = xen_machine_ops;
27094
27095 - /*
27096 - * The only reliable way to retain the initial address of the
27097 - * percpu gdt_page is to remember it here, so we can go and
27098 - * mark it RW later, when the initial percpu area is freed.
27099 - */
27100 - xen_initial_gdt = &per_cpu(gdt_page, 0);
27101 -
27102 xen_smp_init();
27103
27104 #ifdef CONFIG_ACPI_NUMA
27105 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
27106 index dc19347..1b07a2c 100644
27107 --- a/arch/x86/xen/mmu.c
27108 +++ b/arch/x86/xen/mmu.c
27109 @@ -1738,6 +1738,9 @@ pgd_t * __init xen_setup_kernel_pagetable(pgd_t *pgd,
27110 convert_pfn_mfn(init_level4_pgt);
27111 convert_pfn_mfn(level3_ident_pgt);
27112 convert_pfn_mfn(level3_kernel_pgt);
27113 + convert_pfn_mfn(level3_vmalloc_start_pgt);
27114 + convert_pfn_mfn(level3_vmalloc_end_pgt);
27115 + convert_pfn_mfn(level3_vmemmap_pgt);
27116
27117 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
27118 l2 = m2v(l3[pud_index(__START_KERNEL_map)].pud);
27119 @@ -1756,7 +1759,11 @@ pgd_t * __init xen_setup_kernel_pagetable(pgd_t *pgd,
27120 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
27121 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
27122 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
27123 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
27124 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
27125 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
27126 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
27127 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
27128 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
27129 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
27130
27131 @@ -1963,6 +1970,7 @@ static void __init xen_post_allocator_init(void)
27132 pv_mmu_ops.set_pud = xen_set_pud;
27133 #if PAGETABLE_LEVELS == 4
27134 pv_mmu_ops.set_pgd = xen_set_pgd;
27135 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
27136 #endif
27137
27138 /* This will work as long as patching hasn't happened yet
27139 @@ -2044,6 +2052,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
27140 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
27141 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
27142 .set_pgd = xen_set_pgd_hyper,
27143 + .set_pgd_batched = xen_set_pgd_hyper,
27144
27145 .alloc_pud = xen_alloc_pmd_init,
27146 .release_pud = xen_release_pmd_init,
27147 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
27148 index f2ce60a..14e08dc 100644
27149 --- a/arch/x86/xen/smp.c
27150 +++ b/arch/x86/xen/smp.c
27151 @@ -209,11 +209,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
27152 {
27153 BUG_ON(smp_processor_id() != 0);
27154 native_smp_prepare_boot_cpu();
27155 -
27156 - /* We've switched to the "real" per-cpu gdt, so make sure the
27157 - old memory can be recycled */
27158 - make_lowmem_page_readwrite(xen_initial_gdt);
27159 -
27160 xen_filter_cpu_maps();
27161 xen_setup_vcpu_info_placement();
27162 }
27163 @@ -290,12 +285,12 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
27164 gdt = get_cpu_gdt_table(cpu);
27165
27166 ctxt->flags = VGCF_IN_KERNEL;
27167 - ctxt->user_regs.ds = __USER_DS;
27168 - ctxt->user_regs.es = __USER_DS;
27169 + ctxt->user_regs.ds = __KERNEL_DS;
27170 + ctxt->user_regs.es = __KERNEL_DS;
27171 ctxt->user_regs.ss = __KERNEL_DS;
27172 #ifdef CONFIG_X86_32
27173 ctxt->user_regs.fs = __KERNEL_PERCPU;
27174 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
27175 + savesegment(gs, ctxt->user_regs.gs);
27176 #else
27177 ctxt->gs_base_kernel = per_cpu_offset(cpu);
27178 #endif
27179 @@ -346,13 +341,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu)
27180 int rc;
27181
27182 per_cpu(current_task, cpu) = idle;
27183 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
27184 #ifdef CONFIG_X86_32
27185 irq_ctx_init(cpu);
27186 #else
27187 clear_tsk_thread_flag(idle, TIF_FORK);
27188 - per_cpu(kernel_stack, cpu) =
27189 - (unsigned long)task_stack_page(idle) -
27190 - KERNEL_STACK_OFFSET + THREAD_SIZE;
27191 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
27192 #endif
27193 xen_setup_runstate_info(cpu);
27194 xen_setup_timer(cpu);
27195 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
27196 index b040b0e..8cc4fe0 100644
27197 --- a/arch/x86/xen/xen-asm_32.S
27198 +++ b/arch/x86/xen/xen-asm_32.S
27199 @@ -83,14 +83,14 @@ ENTRY(xen_iret)
27200 ESP_OFFSET=4 # bytes pushed onto stack
27201
27202 /*
27203 - * Store vcpu_info pointer for easy access. Do it this way to
27204 - * avoid having to reload %fs
27205 + * Store vcpu_info pointer for easy access.
27206 */
27207 #ifdef CONFIG_SMP
27208 - GET_THREAD_INFO(%eax)
27209 - movl TI_cpu(%eax), %eax
27210 - movl __per_cpu_offset(,%eax,4), %eax
27211 - mov xen_vcpu(%eax), %eax
27212 + push %fs
27213 + mov $(__KERNEL_PERCPU), %eax
27214 + mov %eax, %fs
27215 + mov PER_CPU_VAR(xen_vcpu), %eax
27216 + pop %fs
27217 #else
27218 movl xen_vcpu, %eax
27219 #endif
27220 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
27221 index aaa7291..3f77960 100644
27222 --- a/arch/x86/xen/xen-head.S
27223 +++ b/arch/x86/xen/xen-head.S
27224 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
27225 #ifdef CONFIG_X86_32
27226 mov %esi,xen_start_info
27227 mov $init_thread_union+THREAD_SIZE,%esp
27228 +#ifdef CONFIG_SMP
27229 + movl $cpu_gdt_table,%edi
27230 + movl $__per_cpu_load,%eax
27231 + movw %ax,__KERNEL_PERCPU + 2(%edi)
27232 + rorl $16,%eax
27233 + movb %al,__KERNEL_PERCPU + 4(%edi)
27234 + movb %ah,__KERNEL_PERCPU + 7(%edi)
27235 + movl $__per_cpu_end - 1,%eax
27236 + subl $__per_cpu_start,%eax
27237 + movw %ax,__KERNEL_PERCPU + 0(%edi)
27238 +#endif
27239 #else
27240 mov %rsi,xen_start_info
27241 mov $init_thread_union+THREAD_SIZE,%rsp
27242 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
27243 index b095739..8c17bcd 100644
27244 --- a/arch/x86/xen/xen-ops.h
27245 +++ b/arch/x86/xen/xen-ops.h
27246 @@ -10,8 +10,6 @@
27247 extern const char xen_hypervisor_callback[];
27248 extern const char xen_failsafe_callback[];
27249
27250 -extern void *xen_initial_gdt;
27251 -
27252 struct trap_info;
27253 void xen_copy_trap_info(struct trap_info *traps);
27254
27255 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
27256 index 525bd3d..ef888b1 100644
27257 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
27258 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
27259 @@ -119,9 +119,9 @@
27260 ----------------------------------------------------------------------*/
27261
27262 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
27263 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
27264 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
27265 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
27266 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
27267
27268 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
27269 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
27270 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
27271 index 2f33760..835e50a 100644
27272 --- a/arch/xtensa/variants/fsf/include/variant/core.h
27273 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
27274 @@ -11,6 +11,7 @@
27275 #ifndef _XTENSA_CORE_H
27276 #define _XTENSA_CORE_H
27277
27278 +#include <linux/const.h>
27279
27280 /****************************************************************************
27281 Parameters Useful for Any Code, USER or PRIVILEGED
27282 @@ -112,9 +113,9 @@
27283 ----------------------------------------------------------------------*/
27284
27285 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
27286 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
27287 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
27288 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
27289 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
27290
27291 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
27292 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
27293 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
27294 index af00795..2bb8105 100644
27295 --- a/arch/xtensa/variants/s6000/include/variant/core.h
27296 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
27297 @@ -11,6 +11,7 @@
27298 #ifndef _XTENSA_CORE_CONFIGURATION_H
27299 #define _XTENSA_CORE_CONFIGURATION_H
27300
27301 +#include <linux/const.h>
27302
27303 /****************************************************************************
27304 Parameters Useful for Any Code, USER or PRIVILEGED
27305 @@ -118,9 +119,9 @@
27306 ----------------------------------------------------------------------*/
27307
27308 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
27309 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
27310 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
27311 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
27312 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
27313
27314 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
27315 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
27316 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
27317 index 58916af..9cb880b 100644
27318 --- a/block/blk-iopoll.c
27319 +++ b/block/blk-iopoll.c
27320 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
27321 }
27322 EXPORT_SYMBOL(blk_iopoll_complete);
27323
27324 -static void blk_iopoll_softirq(struct softirq_action *h)
27325 +static void blk_iopoll_softirq(void)
27326 {
27327 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
27328 int rearm = 0, budget = blk_iopoll_budget;
27329 diff --git a/block/blk-map.c b/block/blk-map.c
27330 index 623e1cd..ca1e109 100644
27331 --- a/block/blk-map.c
27332 +++ b/block/blk-map.c
27333 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
27334 if (!len || !kbuf)
27335 return -EINVAL;
27336
27337 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
27338 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
27339 if (do_copy)
27340 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
27341 else
27342 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
27343 index 1366a89..e17f54b 100644
27344 --- a/block/blk-softirq.c
27345 +++ b/block/blk-softirq.c
27346 @@ -17,7 +17,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
27347 * Softirq action handler - move entries to local list and loop over them
27348 * while passing them to the queue registered handler.
27349 */
27350 -static void blk_done_softirq(struct softirq_action *h)
27351 +static void blk_done_softirq(void)
27352 {
27353 struct list_head *cpu_list, local_list;
27354
27355 diff --git a/block/bsg.c b/block/bsg.c
27356 index ff64ae3..593560c 100644
27357 --- a/block/bsg.c
27358 +++ b/block/bsg.c
27359 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
27360 struct sg_io_v4 *hdr, struct bsg_device *bd,
27361 fmode_t has_write_perm)
27362 {
27363 + unsigned char tmpcmd[sizeof(rq->__cmd)];
27364 + unsigned char *cmdptr;
27365 +
27366 if (hdr->request_len > BLK_MAX_CDB) {
27367 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
27368 if (!rq->cmd)
27369 return -ENOMEM;
27370 - }
27371 + cmdptr = rq->cmd;
27372 + } else
27373 + cmdptr = tmpcmd;
27374
27375 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
27376 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
27377 hdr->request_len))
27378 return -EFAULT;
27379
27380 + if (cmdptr != rq->cmd)
27381 + memcpy(rq->cmd, cmdptr, hdr->request_len);
27382 +
27383 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
27384 if (blk_verify_command(rq->cmd, has_write_perm))
27385 return -EPERM;
27386 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
27387 index 7c668c8..db3521c 100644
27388 --- a/block/compat_ioctl.c
27389 +++ b/block/compat_ioctl.c
27390 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
27391 err |= __get_user(f->spec1, &uf->spec1);
27392 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
27393 err |= __get_user(name, &uf->name);
27394 - f->name = compat_ptr(name);
27395 + f->name = (void __force_kernel *)compat_ptr(name);
27396 if (err) {
27397 err = -EFAULT;
27398 goto out;
27399 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
27400 index 6296b40..417c00f 100644
27401 --- a/block/partitions/efi.c
27402 +++ b/block/partitions/efi.c
27403 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
27404 if (!gpt)
27405 return NULL;
27406
27407 + if (!le32_to_cpu(gpt->num_partition_entries))
27408 + return NULL;
27409 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
27410 + if (!pte)
27411 + return NULL;
27412 +
27413 count = le32_to_cpu(gpt->num_partition_entries) *
27414 le32_to_cpu(gpt->sizeof_partition_entry);
27415 - if (!count)
27416 - return NULL;
27417 - pte = kzalloc(count, GFP_KERNEL);
27418 - if (!pte)
27419 - return NULL;
27420 -
27421 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
27422 (u8 *) pte,
27423 count) < count) {
27424 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
27425 index 260fa80..e8f3caf 100644
27426 --- a/block/scsi_ioctl.c
27427 +++ b/block/scsi_ioctl.c
27428 @@ -223,8 +223,20 @@ EXPORT_SYMBOL(blk_verify_command);
27429 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
27430 struct sg_io_hdr *hdr, fmode_t mode)
27431 {
27432 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
27433 + unsigned char tmpcmd[sizeof(rq->__cmd)];
27434 + unsigned char *cmdptr;
27435 +
27436 + if (rq->cmd != rq->__cmd)
27437 + cmdptr = rq->cmd;
27438 + else
27439 + cmdptr = tmpcmd;
27440 +
27441 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
27442 return -EFAULT;
27443 +
27444 + if (cmdptr != rq->cmd)
27445 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
27446 +
27447 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
27448 return -EPERM;
27449
27450 @@ -433,6 +445,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
27451 int err;
27452 unsigned int in_len, out_len, bytes, opcode, cmdlen;
27453 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
27454 + unsigned char tmpcmd[sizeof(rq->__cmd)];
27455 + unsigned char *cmdptr;
27456
27457 if (!sic)
27458 return -EINVAL;
27459 @@ -466,9 +480,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
27460 */
27461 err = -EFAULT;
27462 rq->cmd_len = cmdlen;
27463 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
27464 +
27465 + if (rq->cmd != rq->__cmd)
27466 + cmdptr = rq->cmd;
27467 + else
27468 + cmdptr = tmpcmd;
27469 +
27470 + if (copy_from_user(cmdptr, sic->data, cmdlen))
27471 goto error;
27472
27473 + if (rq->cmd != cmdptr)
27474 + memcpy(rq->cmd, cmdptr, cmdlen);
27475 +
27476 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
27477 goto error;
27478
27479 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
27480 index 671d4d6..5f24030 100644
27481 --- a/crypto/cryptd.c
27482 +++ b/crypto/cryptd.c
27483 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
27484
27485 struct cryptd_blkcipher_request_ctx {
27486 crypto_completion_t complete;
27487 -};
27488 +} __no_const;
27489
27490 struct cryptd_hash_ctx {
27491 struct crypto_shash *child;
27492 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
27493
27494 struct cryptd_aead_request_ctx {
27495 crypto_completion_t complete;
27496 -};
27497 +} __no_const;
27498
27499 static void cryptd_queue_worker(struct work_struct *work);
27500
27501 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
27502 index 5d41894..22021e4 100644
27503 --- a/drivers/acpi/apei/cper.c
27504 +++ b/drivers/acpi/apei/cper.c
27505 @@ -38,12 +38,12 @@
27506 */
27507 u64 cper_next_record_id(void)
27508 {
27509 - static atomic64_t seq;
27510 + static atomic64_unchecked_t seq;
27511
27512 - if (!atomic64_read(&seq))
27513 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
27514 + if (!atomic64_read_unchecked(&seq))
27515 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
27516
27517 - return atomic64_inc_return(&seq);
27518 + return atomic64_inc_return_unchecked(&seq);
27519 }
27520 EXPORT_SYMBOL_GPL(cper_next_record_id);
27521
27522 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
27523 index b258cab..3fb7da7 100644
27524 --- a/drivers/acpi/ec_sys.c
27525 +++ b/drivers/acpi/ec_sys.c
27526 @@ -12,6 +12,7 @@
27527 #include <linux/acpi.h>
27528 #include <linux/debugfs.h>
27529 #include <linux/module.h>
27530 +#include <linux/uaccess.h>
27531 #include "internal.h"
27532
27533 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
27534 @@ -40,7 +41,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
27535 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
27536 */
27537 unsigned int size = EC_SPACE_SIZE;
27538 - u8 *data = (u8 *) buf;
27539 + u8 data;
27540 loff_t init_off = *off;
27541 int err = 0;
27542
27543 @@ -53,9 +54,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
27544 size = count;
27545
27546 while (size) {
27547 - err = ec_read(*off, &data[*off - init_off]);
27548 + err = ec_read(*off, &data);
27549 if (err)
27550 return err;
27551 + if (put_user(data, &buf[*off - init_off]))
27552 + return -EFAULT;
27553 *off += 1;
27554 size--;
27555 }
27556 @@ -71,7 +74,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
27557
27558 unsigned int size = count;
27559 loff_t init_off = *off;
27560 - u8 *data = (u8 *) buf;
27561 int err = 0;
27562
27563 if (*off >= EC_SPACE_SIZE)
27564 @@ -82,7 +84,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
27565 }
27566
27567 while (size) {
27568 - u8 byte_write = data[*off - init_off];
27569 + u8 byte_write;
27570 + if (get_user(byte_write, &buf[*off - init_off]))
27571 + return -EFAULT;
27572 err = ec_write(*off, byte_write);
27573 if (err)
27574 return err;
27575 diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c
27576 index 251c7b62..000462d 100644
27577 --- a/drivers/acpi/proc.c
27578 +++ b/drivers/acpi/proc.c
27579 @@ -343,19 +343,13 @@ acpi_system_write_wakeup_device(struct file *file,
27580 size_t count, loff_t * ppos)
27581 {
27582 struct list_head *node, *next;
27583 - char strbuf[5];
27584 - char str[5] = "";
27585 - unsigned int len = count;
27586 + char strbuf[5] = {0};
27587
27588 - if (len > 4)
27589 - len = 4;
27590 - if (len < 0)
27591 + if (count > 4)
27592 + count = 4;
27593 + if (copy_from_user(strbuf, buffer, count))
27594 return -EFAULT;
27595 -
27596 - if (copy_from_user(strbuf, buffer, len))
27597 - return -EFAULT;
27598 - strbuf[len] = '\0';
27599 - sscanf(strbuf, "%s", str);
27600 + strbuf[count] = '\0';
27601
27602 mutex_lock(&acpi_device_lock);
27603 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
27604 @@ -364,7 +358,7 @@ acpi_system_write_wakeup_device(struct file *file,
27605 if (!dev->wakeup.flags.valid)
27606 continue;
27607
27608 - if (!strncmp(dev->pnp.bus_id, str, 4)) {
27609 + if (!strncmp(dev->pnp.bus_id, strbuf, 4)) {
27610 if (device_can_wakeup(&dev->dev)) {
27611 bool enable = !device_may_wakeup(&dev->dev);
27612 device_set_wakeup_enable(&dev->dev, enable);
27613 diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
27614 index 8ae05ce..7dbbed9 100644
27615 --- a/drivers/acpi/processor_driver.c
27616 +++ b/drivers/acpi/processor_driver.c
27617 @@ -555,7 +555,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
27618 return 0;
27619 #endif
27620
27621 - BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0));
27622 + BUG_ON(pr->id >= nr_cpu_ids);
27623
27624 /*
27625 * Buggy BIOS check
27626 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
27627 index c06e0ec..a2c06ba 100644
27628 --- a/drivers/ata/libata-core.c
27629 +++ b/drivers/ata/libata-core.c
27630 @@ -4736,7 +4736,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
27631 struct ata_port *ap;
27632 unsigned int tag;
27633
27634 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
27635 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
27636 ap = qc->ap;
27637
27638 qc->flags = 0;
27639 @@ -4752,7 +4752,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
27640 struct ata_port *ap;
27641 struct ata_link *link;
27642
27643 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
27644 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
27645 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
27646 ap = qc->ap;
27647 link = qc->dev->link;
27648 @@ -5816,6 +5816,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
27649 return;
27650
27651 spin_lock(&lock);
27652 + pax_open_kernel();
27653
27654 for (cur = ops->inherits; cur; cur = cur->inherits) {
27655 void **inherit = (void **)cur;
27656 @@ -5829,8 +5830,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
27657 if (IS_ERR(*pp))
27658 *pp = NULL;
27659
27660 - ops->inherits = NULL;
27661 + *(struct ata_port_operations **)&ops->inherits = NULL;
27662
27663 + pax_close_kernel();
27664 spin_unlock(&lock);
27665 }
27666
27667 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
27668 index 048589f..4002b98 100644
27669 --- a/drivers/ata/pata_arasan_cf.c
27670 +++ b/drivers/ata/pata_arasan_cf.c
27671 @@ -862,7 +862,9 @@ static int __devinit arasan_cf_probe(struct platform_device *pdev)
27672 /* Handle platform specific quirks */
27673 if (pdata->quirk) {
27674 if (pdata->quirk & CF_BROKEN_PIO) {
27675 - ap->ops->set_piomode = NULL;
27676 + pax_open_kernel();
27677 + *(void **)&ap->ops->set_piomode = NULL;
27678 + pax_close_kernel();
27679 ap->pio_mask = 0;
27680 }
27681 if (pdata->quirk & CF_BROKEN_MWDMA)
27682 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
27683 index f9b983a..887b9d8 100644
27684 --- a/drivers/atm/adummy.c
27685 +++ b/drivers/atm/adummy.c
27686 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
27687 vcc->pop(vcc, skb);
27688 else
27689 dev_kfree_skb_any(skb);
27690 - atomic_inc(&vcc->stats->tx);
27691 + atomic_inc_unchecked(&vcc->stats->tx);
27692
27693 return 0;
27694 }
27695 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
27696 index f8f41e0..1f987dd 100644
27697 --- a/drivers/atm/ambassador.c
27698 +++ b/drivers/atm/ambassador.c
27699 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
27700 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
27701
27702 // VC layer stats
27703 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
27704 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
27705
27706 // free the descriptor
27707 kfree (tx_descr);
27708 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
27709 dump_skb ("<<<", vc, skb);
27710
27711 // VC layer stats
27712 - atomic_inc(&atm_vcc->stats->rx);
27713 + atomic_inc_unchecked(&atm_vcc->stats->rx);
27714 __net_timestamp(skb);
27715 // end of our responsibility
27716 atm_vcc->push (atm_vcc, skb);
27717 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
27718 } else {
27719 PRINTK (KERN_INFO, "dropped over-size frame");
27720 // should we count this?
27721 - atomic_inc(&atm_vcc->stats->rx_drop);
27722 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
27723 }
27724
27725 } else {
27726 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
27727 }
27728
27729 if (check_area (skb->data, skb->len)) {
27730 - atomic_inc(&atm_vcc->stats->tx_err);
27731 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
27732 return -ENOMEM; // ?
27733 }
27734
27735 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
27736 index b22d71c..d6e1049 100644
27737 --- a/drivers/atm/atmtcp.c
27738 +++ b/drivers/atm/atmtcp.c
27739 @@ -207,7 +207,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
27740 if (vcc->pop) vcc->pop(vcc,skb);
27741 else dev_kfree_skb(skb);
27742 if (dev_data) return 0;
27743 - atomic_inc(&vcc->stats->tx_err);
27744 + atomic_inc_unchecked(&vcc->stats->tx_err);
27745 return -ENOLINK;
27746 }
27747 size = skb->len+sizeof(struct atmtcp_hdr);
27748 @@ -215,7 +215,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
27749 if (!new_skb) {
27750 if (vcc->pop) vcc->pop(vcc,skb);
27751 else dev_kfree_skb(skb);
27752 - atomic_inc(&vcc->stats->tx_err);
27753 + atomic_inc_unchecked(&vcc->stats->tx_err);
27754 return -ENOBUFS;
27755 }
27756 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
27757 @@ -226,8 +226,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
27758 if (vcc->pop) vcc->pop(vcc,skb);
27759 else dev_kfree_skb(skb);
27760 out_vcc->push(out_vcc,new_skb);
27761 - atomic_inc(&vcc->stats->tx);
27762 - atomic_inc(&out_vcc->stats->rx);
27763 + atomic_inc_unchecked(&vcc->stats->tx);
27764 + atomic_inc_unchecked(&out_vcc->stats->rx);
27765 return 0;
27766 }
27767
27768 @@ -301,7 +301,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
27769 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
27770 read_unlock(&vcc_sklist_lock);
27771 if (!out_vcc) {
27772 - atomic_inc(&vcc->stats->tx_err);
27773 + atomic_inc_unchecked(&vcc->stats->tx_err);
27774 goto done;
27775 }
27776 skb_pull(skb,sizeof(struct atmtcp_hdr));
27777 @@ -313,8 +313,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
27778 __net_timestamp(new_skb);
27779 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
27780 out_vcc->push(out_vcc,new_skb);
27781 - atomic_inc(&vcc->stats->tx);
27782 - atomic_inc(&out_vcc->stats->rx);
27783 + atomic_inc_unchecked(&vcc->stats->tx);
27784 + atomic_inc_unchecked(&out_vcc->stats->rx);
27785 done:
27786 if (vcc->pop) vcc->pop(vcc,skb);
27787 else dev_kfree_skb(skb);
27788 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
27789 index 956e9ac..133516d 100644
27790 --- a/drivers/atm/eni.c
27791 +++ b/drivers/atm/eni.c
27792 @@ -526,7 +526,7 @@ static int rx_aal0(struct atm_vcc *vcc)
27793 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
27794 vcc->dev->number);
27795 length = 0;
27796 - atomic_inc(&vcc->stats->rx_err);
27797 + atomic_inc_unchecked(&vcc->stats->rx_err);
27798 }
27799 else {
27800 length = ATM_CELL_SIZE-1; /* no HEC */
27801 @@ -581,7 +581,7 @@ static int rx_aal5(struct atm_vcc *vcc)
27802 size);
27803 }
27804 eff = length = 0;
27805 - atomic_inc(&vcc->stats->rx_err);
27806 + atomic_inc_unchecked(&vcc->stats->rx_err);
27807 }
27808 else {
27809 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
27810 @@ -598,7 +598,7 @@ static int rx_aal5(struct atm_vcc *vcc)
27811 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
27812 vcc->dev->number,vcc->vci,length,size << 2,descr);
27813 length = eff = 0;
27814 - atomic_inc(&vcc->stats->rx_err);
27815 + atomic_inc_unchecked(&vcc->stats->rx_err);
27816 }
27817 }
27818 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
27819 @@ -771,7 +771,7 @@ rx_dequeued++;
27820 vcc->push(vcc,skb);
27821 pushed++;
27822 }
27823 - atomic_inc(&vcc->stats->rx);
27824 + atomic_inc_unchecked(&vcc->stats->rx);
27825 }
27826 wake_up(&eni_dev->rx_wait);
27827 }
27828 @@ -1229,7 +1229,7 @@ static void dequeue_tx(struct atm_dev *dev)
27829 PCI_DMA_TODEVICE);
27830 if (vcc->pop) vcc->pop(vcc,skb);
27831 else dev_kfree_skb_irq(skb);
27832 - atomic_inc(&vcc->stats->tx);
27833 + atomic_inc_unchecked(&vcc->stats->tx);
27834 wake_up(&eni_dev->tx_wait);
27835 dma_complete++;
27836 }
27837 @@ -1569,7 +1569,7 @@ tx_complete++;
27838 /*--------------------------------- entries ---------------------------------*/
27839
27840
27841 -static const char *media_name[] __devinitdata = {
27842 +static const char *media_name[] __devinitconst = {
27843 "MMF", "SMF", "MMF", "03?", /* 0- 3 */
27844 "UTP", "05?", "06?", "07?", /* 4- 7 */
27845 "TAXI","09?", "10?", "11?", /* 8-11 */
27846 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
27847 index 5072f8a..fa52520d 100644
27848 --- a/drivers/atm/firestream.c
27849 +++ b/drivers/atm/firestream.c
27850 @@ -750,7 +750,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
27851 }
27852 }
27853
27854 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
27855 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
27856
27857 fs_dprintk (FS_DEBUG_TXMEM, "i");
27858 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
27859 @@ -817,7 +817,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
27860 #endif
27861 skb_put (skb, qe->p1 & 0xffff);
27862 ATM_SKB(skb)->vcc = atm_vcc;
27863 - atomic_inc(&atm_vcc->stats->rx);
27864 + atomic_inc_unchecked(&atm_vcc->stats->rx);
27865 __net_timestamp(skb);
27866 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
27867 atm_vcc->push (atm_vcc, skb);
27868 @@ -838,12 +838,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
27869 kfree (pe);
27870 }
27871 if (atm_vcc)
27872 - atomic_inc(&atm_vcc->stats->rx_drop);
27873 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
27874 break;
27875 case 0x1f: /* Reassembly abort: no buffers. */
27876 /* Silently increment error counter. */
27877 if (atm_vcc)
27878 - atomic_inc(&atm_vcc->stats->rx_drop);
27879 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
27880 break;
27881 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
27882 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
27883 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
27884 index 361f5ae..7fc552d 100644
27885 --- a/drivers/atm/fore200e.c
27886 +++ b/drivers/atm/fore200e.c
27887 @@ -933,9 +933,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
27888 #endif
27889 /* check error condition */
27890 if (*entry->status & STATUS_ERROR)
27891 - atomic_inc(&vcc->stats->tx_err);
27892 + atomic_inc_unchecked(&vcc->stats->tx_err);
27893 else
27894 - atomic_inc(&vcc->stats->tx);
27895 + atomic_inc_unchecked(&vcc->stats->tx);
27896 }
27897 }
27898
27899 @@ -1084,7 +1084,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
27900 if (skb == NULL) {
27901 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
27902
27903 - atomic_inc(&vcc->stats->rx_drop);
27904 + atomic_inc_unchecked(&vcc->stats->rx_drop);
27905 return -ENOMEM;
27906 }
27907
27908 @@ -1127,14 +1127,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
27909
27910 dev_kfree_skb_any(skb);
27911
27912 - atomic_inc(&vcc->stats->rx_drop);
27913 + atomic_inc_unchecked(&vcc->stats->rx_drop);
27914 return -ENOMEM;
27915 }
27916
27917 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
27918
27919 vcc->push(vcc, skb);
27920 - atomic_inc(&vcc->stats->rx);
27921 + atomic_inc_unchecked(&vcc->stats->rx);
27922
27923 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
27924
27925 @@ -1212,7 +1212,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
27926 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
27927 fore200e->atm_dev->number,
27928 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
27929 - atomic_inc(&vcc->stats->rx_err);
27930 + atomic_inc_unchecked(&vcc->stats->rx_err);
27931 }
27932 }
27933
27934 @@ -1657,7 +1657,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
27935 goto retry_here;
27936 }
27937
27938 - atomic_inc(&vcc->stats->tx_err);
27939 + atomic_inc_unchecked(&vcc->stats->tx_err);
27940
27941 fore200e->tx_sat++;
27942 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
27943 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
27944 index b182c2f..1c6fa8a 100644
27945 --- a/drivers/atm/he.c
27946 +++ b/drivers/atm/he.c
27947 @@ -1709,7 +1709,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
27948
27949 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
27950 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
27951 - atomic_inc(&vcc->stats->rx_drop);
27952 + atomic_inc_unchecked(&vcc->stats->rx_drop);
27953 goto return_host_buffers;
27954 }
27955
27956 @@ -1736,7 +1736,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
27957 RBRQ_LEN_ERR(he_dev->rbrq_head)
27958 ? "LEN_ERR" : "",
27959 vcc->vpi, vcc->vci);
27960 - atomic_inc(&vcc->stats->rx_err);
27961 + atomic_inc_unchecked(&vcc->stats->rx_err);
27962 goto return_host_buffers;
27963 }
27964
27965 @@ -1788,7 +1788,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
27966 vcc->push(vcc, skb);
27967 spin_lock(&he_dev->global_lock);
27968
27969 - atomic_inc(&vcc->stats->rx);
27970 + atomic_inc_unchecked(&vcc->stats->rx);
27971
27972 return_host_buffers:
27973 ++pdus_assembled;
27974 @@ -2114,7 +2114,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
27975 tpd->vcc->pop(tpd->vcc, tpd->skb);
27976 else
27977 dev_kfree_skb_any(tpd->skb);
27978 - atomic_inc(&tpd->vcc->stats->tx_err);
27979 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
27980 }
27981 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
27982 return;
27983 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
27984 vcc->pop(vcc, skb);
27985 else
27986 dev_kfree_skb_any(skb);
27987 - atomic_inc(&vcc->stats->tx_err);
27988 + atomic_inc_unchecked(&vcc->stats->tx_err);
27989 return -EINVAL;
27990 }
27991
27992 @@ -2537,7 +2537,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
27993 vcc->pop(vcc, skb);
27994 else
27995 dev_kfree_skb_any(skb);
27996 - atomic_inc(&vcc->stats->tx_err);
27997 + atomic_inc_unchecked(&vcc->stats->tx_err);
27998 return -EINVAL;
27999 }
28000 #endif
28001 @@ -2549,7 +2549,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
28002 vcc->pop(vcc, skb);
28003 else
28004 dev_kfree_skb_any(skb);
28005 - atomic_inc(&vcc->stats->tx_err);
28006 + atomic_inc_unchecked(&vcc->stats->tx_err);
28007 spin_unlock_irqrestore(&he_dev->global_lock, flags);
28008 return -ENOMEM;
28009 }
28010 @@ -2591,7 +2591,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
28011 vcc->pop(vcc, skb);
28012 else
28013 dev_kfree_skb_any(skb);
28014 - atomic_inc(&vcc->stats->tx_err);
28015 + atomic_inc_unchecked(&vcc->stats->tx_err);
28016 spin_unlock_irqrestore(&he_dev->global_lock, flags);
28017 return -ENOMEM;
28018 }
28019 @@ -2622,7 +2622,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
28020 __enqueue_tpd(he_dev, tpd, cid);
28021 spin_unlock_irqrestore(&he_dev->global_lock, flags);
28022
28023 - atomic_inc(&vcc->stats->tx);
28024 + atomic_inc_unchecked(&vcc->stats->tx);
28025
28026 return 0;
28027 }
28028 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
28029 index b812103..e391a49 100644
28030 --- a/drivers/atm/horizon.c
28031 +++ b/drivers/atm/horizon.c
28032 @@ -1035,7 +1035,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
28033 {
28034 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
28035 // VC layer stats
28036 - atomic_inc(&vcc->stats->rx);
28037 + atomic_inc_unchecked(&vcc->stats->rx);
28038 __net_timestamp(skb);
28039 // end of our responsibility
28040 vcc->push (vcc, skb);
28041 @@ -1187,7 +1187,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
28042 dev->tx_iovec = NULL;
28043
28044 // VC layer stats
28045 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
28046 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
28047
28048 // free the skb
28049 hrz_kfree_skb (skb);
28050 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
28051 index 1c05212..c28e200 100644
28052 --- a/drivers/atm/idt77252.c
28053 +++ b/drivers/atm/idt77252.c
28054 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
28055 else
28056 dev_kfree_skb(skb);
28057
28058 - atomic_inc(&vcc->stats->tx);
28059 + atomic_inc_unchecked(&vcc->stats->tx);
28060 }
28061
28062 atomic_dec(&scq->used);
28063 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
28064 if ((sb = dev_alloc_skb(64)) == NULL) {
28065 printk("%s: Can't allocate buffers for aal0.\n",
28066 card->name);
28067 - atomic_add(i, &vcc->stats->rx_drop);
28068 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
28069 break;
28070 }
28071 if (!atm_charge(vcc, sb->truesize)) {
28072 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
28073 card->name);
28074 - atomic_add(i - 1, &vcc->stats->rx_drop);
28075 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
28076 dev_kfree_skb(sb);
28077 break;
28078 }
28079 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
28080 ATM_SKB(sb)->vcc = vcc;
28081 __net_timestamp(sb);
28082 vcc->push(vcc, sb);
28083 - atomic_inc(&vcc->stats->rx);
28084 + atomic_inc_unchecked(&vcc->stats->rx);
28085
28086 cell += ATM_CELL_PAYLOAD;
28087 }
28088 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
28089 "(CDC: %08x)\n",
28090 card->name, len, rpp->len, readl(SAR_REG_CDC));
28091 recycle_rx_pool_skb(card, rpp);
28092 - atomic_inc(&vcc->stats->rx_err);
28093 + atomic_inc_unchecked(&vcc->stats->rx_err);
28094 return;
28095 }
28096 if (stat & SAR_RSQE_CRC) {
28097 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
28098 recycle_rx_pool_skb(card, rpp);
28099 - atomic_inc(&vcc->stats->rx_err);
28100 + atomic_inc_unchecked(&vcc->stats->rx_err);
28101 return;
28102 }
28103 if (skb_queue_len(&rpp->queue) > 1) {
28104 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
28105 RXPRINTK("%s: Can't alloc RX skb.\n",
28106 card->name);
28107 recycle_rx_pool_skb(card, rpp);
28108 - atomic_inc(&vcc->stats->rx_err);
28109 + atomic_inc_unchecked(&vcc->stats->rx_err);
28110 return;
28111 }
28112 if (!atm_charge(vcc, skb->truesize)) {
28113 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
28114 __net_timestamp(skb);
28115
28116 vcc->push(vcc, skb);
28117 - atomic_inc(&vcc->stats->rx);
28118 + atomic_inc_unchecked(&vcc->stats->rx);
28119
28120 return;
28121 }
28122 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
28123 __net_timestamp(skb);
28124
28125 vcc->push(vcc, skb);
28126 - atomic_inc(&vcc->stats->rx);
28127 + atomic_inc_unchecked(&vcc->stats->rx);
28128
28129 if (skb->truesize > SAR_FB_SIZE_3)
28130 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
28131 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
28132 if (vcc->qos.aal != ATM_AAL0) {
28133 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
28134 card->name, vpi, vci);
28135 - atomic_inc(&vcc->stats->rx_drop);
28136 + atomic_inc_unchecked(&vcc->stats->rx_drop);
28137 goto drop;
28138 }
28139
28140 if ((sb = dev_alloc_skb(64)) == NULL) {
28141 printk("%s: Can't allocate buffers for AAL0.\n",
28142 card->name);
28143 - atomic_inc(&vcc->stats->rx_err);
28144 + atomic_inc_unchecked(&vcc->stats->rx_err);
28145 goto drop;
28146 }
28147
28148 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
28149 ATM_SKB(sb)->vcc = vcc;
28150 __net_timestamp(sb);
28151 vcc->push(vcc, sb);
28152 - atomic_inc(&vcc->stats->rx);
28153 + atomic_inc_unchecked(&vcc->stats->rx);
28154
28155 drop:
28156 skb_pull(queue, 64);
28157 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
28158
28159 if (vc == NULL) {
28160 printk("%s: NULL connection in send().\n", card->name);
28161 - atomic_inc(&vcc->stats->tx_err);
28162 + atomic_inc_unchecked(&vcc->stats->tx_err);
28163 dev_kfree_skb(skb);
28164 return -EINVAL;
28165 }
28166 if (!test_bit(VCF_TX, &vc->flags)) {
28167 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
28168 - atomic_inc(&vcc->stats->tx_err);
28169 + atomic_inc_unchecked(&vcc->stats->tx_err);
28170 dev_kfree_skb(skb);
28171 return -EINVAL;
28172 }
28173 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
28174 break;
28175 default:
28176 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
28177 - atomic_inc(&vcc->stats->tx_err);
28178 + atomic_inc_unchecked(&vcc->stats->tx_err);
28179 dev_kfree_skb(skb);
28180 return -EINVAL;
28181 }
28182
28183 if (skb_shinfo(skb)->nr_frags != 0) {
28184 printk("%s: No scatter-gather yet.\n", card->name);
28185 - atomic_inc(&vcc->stats->tx_err);
28186 + atomic_inc_unchecked(&vcc->stats->tx_err);
28187 dev_kfree_skb(skb);
28188 return -EINVAL;
28189 }
28190 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
28191
28192 err = queue_skb(card, vc, skb, oam);
28193 if (err) {
28194 - atomic_inc(&vcc->stats->tx_err);
28195 + atomic_inc_unchecked(&vcc->stats->tx_err);
28196 dev_kfree_skb(skb);
28197 return err;
28198 }
28199 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
28200 skb = dev_alloc_skb(64);
28201 if (!skb) {
28202 printk("%s: Out of memory in send_oam().\n", card->name);
28203 - atomic_inc(&vcc->stats->tx_err);
28204 + atomic_inc_unchecked(&vcc->stats->tx_err);
28205 return -ENOMEM;
28206 }
28207 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
28208 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
28209 index 9e373ba..cf93727 100644
28210 --- a/drivers/atm/iphase.c
28211 +++ b/drivers/atm/iphase.c
28212 @@ -1146,7 +1146,7 @@ static int rx_pkt(struct atm_dev *dev)
28213 status = (u_short) (buf_desc_ptr->desc_mode);
28214 if (status & (RX_CER | RX_PTE | RX_OFL))
28215 {
28216 - atomic_inc(&vcc->stats->rx_err);
28217 + atomic_inc_unchecked(&vcc->stats->rx_err);
28218 IF_ERR(printk("IA: bad packet, dropping it");)
28219 if (status & RX_CER) {
28220 IF_ERR(printk(" cause: packet CRC error\n");)
28221 @@ -1169,7 +1169,7 @@ static int rx_pkt(struct atm_dev *dev)
28222 len = dma_addr - buf_addr;
28223 if (len > iadev->rx_buf_sz) {
28224 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
28225 - atomic_inc(&vcc->stats->rx_err);
28226 + atomic_inc_unchecked(&vcc->stats->rx_err);
28227 goto out_free_desc;
28228 }
28229
28230 @@ -1319,7 +1319,7 @@ static void rx_dle_intr(struct atm_dev *dev)
28231 ia_vcc = INPH_IA_VCC(vcc);
28232 if (ia_vcc == NULL)
28233 {
28234 - atomic_inc(&vcc->stats->rx_err);
28235 + atomic_inc_unchecked(&vcc->stats->rx_err);
28236 atm_return(vcc, skb->truesize);
28237 dev_kfree_skb_any(skb);
28238 goto INCR_DLE;
28239 @@ -1331,7 +1331,7 @@ static void rx_dle_intr(struct atm_dev *dev)
28240 if ((length > iadev->rx_buf_sz) || (length >
28241 (skb->len - sizeof(struct cpcs_trailer))))
28242 {
28243 - atomic_inc(&vcc->stats->rx_err);
28244 + atomic_inc_unchecked(&vcc->stats->rx_err);
28245 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
28246 length, skb->len);)
28247 atm_return(vcc, skb->truesize);
28248 @@ -1347,7 +1347,7 @@ static void rx_dle_intr(struct atm_dev *dev)
28249
28250 IF_RX(printk("rx_dle_intr: skb push");)
28251 vcc->push(vcc,skb);
28252 - atomic_inc(&vcc->stats->rx);
28253 + atomic_inc_unchecked(&vcc->stats->rx);
28254 iadev->rx_pkt_cnt++;
28255 }
28256 INCR_DLE:
28257 @@ -2827,15 +2827,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
28258 {
28259 struct k_sonet_stats *stats;
28260 stats = &PRIV(_ia_dev[board])->sonet_stats;
28261 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
28262 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
28263 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
28264 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
28265 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
28266 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
28267 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
28268 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
28269 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
28270 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
28271 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
28272 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
28273 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
28274 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
28275 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
28276 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
28277 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
28278 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
28279 }
28280 ia_cmds.status = 0;
28281 break;
28282 @@ -2940,7 +2940,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
28283 if ((desc == 0) || (desc > iadev->num_tx_desc))
28284 {
28285 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
28286 - atomic_inc(&vcc->stats->tx);
28287 + atomic_inc_unchecked(&vcc->stats->tx);
28288 if (vcc->pop)
28289 vcc->pop(vcc, skb);
28290 else
28291 @@ -3045,14 +3045,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
28292 ATM_DESC(skb) = vcc->vci;
28293 skb_queue_tail(&iadev->tx_dma_q, skb);
28294
28295 - atomic_inc(&vcc->stats->tx);
28296 + atomic_inc_unchecked(&vcc->stats->tx);
28297 iadev->tx_pkt_cnt++;
28298 /* Increment transaction counter */
28299 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
28300
28301 #if 0
28302 /* add flow control logic */
28303 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
28304 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
28305 if (iavcc->vc_desc_cnt > 10) {
28306 vcc->tx_quota = vcc->tx_quota * 3 / 4;
28307 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
28308 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
28309 index f556969..0da15eb 100644
28310 --- a/drivers/atm/lanai.c
28311 +++ b/drivers/atm/lanai.c
28312 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
28313 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
28314 lanai_endtx(lanai, lvcc);
28315 lanai_free_skb(lvcc->tx.atmvcc, skb);
28316 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
28317 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
28318 }
28319
28320 /* Try to fill the buffer - don't call unless there is backlog */
28321 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
28322 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
28323 __net_timestamp(skb);
28324 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
28325 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
28326 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
28327 out:
28328 lvcc->rx.buf.ptr = end;
28329 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
28330 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
28331 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
28332 "vcc %d\n", lanai->number, (unsigned int) s, vci);
28333 lanai->stats.service_rxnotaal5++;
28334 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
28335 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
28336 return 0;
28337 }
28338 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
28339 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
28340 int bytes;
28341 read_unlock(&vcc_sklist_lock);
28342 DPRINTK("got trashed rx pdu on vci %d\n", vci);
28343 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
28344 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
28345 lvcc->stats.x.aal5.service_trash++;
28346 bytes = (SERVICE_GET_END(s) * 16) -
28347 (((unsigned long) lvcc->rx.buf.ptr) -
28348 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
28349 }
28350 if (s & SERVICE_STREAM) {
28351 read_unlock(&vcc_sklist_lock);
28352 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
28353 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
28354 lvcc->stats.x.aal5.service_stream++;
28355 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
28356 "PDU on VCI %d!\n", lanai->number, vci);
28357 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
28358 return 0;
28359 }
28360 DPRINTK("got rx crc error on vci %d\n", vci);
28361 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
28362 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
28363 lvcc->stats.x.aal5.service_rxcrc++;
28364 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
28365 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
28366 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
28367 index 1c70c45..300718d 100644
28368 --- a/drivers/atm/nicstar.c
28369 +++ b/drivers/atm/nicstar.c
28370 @@ -1654,7 +1654,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
28371 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
28372 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
28373 card->index);
28374 - atomic_inc(&vcc->stats->tx_err);
28375 + atomic_inc_unchecked(&vcc->stats->tx_err);
28376 dev_kfree_skb_any(skb);
28377 return -EINVAL;
28378 }
28379 @@ -1662,7 +1662,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
28380 if (!vc->tx) {
28381 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
28382 card->index);
28383 - atomic_inc(&vcc->stats->tx_err);
28384 + atomic_inc_unchecked(&vcc->stats->tx_err);
28385 dev_kfree_skb_any(skb);
28386 return -EINVAL;
28387 }
28388 @@ -1670,14 +1670,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
28389 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
28390 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
28391 card->index);
28392 - atomic_inc(&vcc->stats->tx_err);
28393 + atomic_inc_unchecked(&vcc->stats->tx_err);
28394 dev_kfree_skb_any(skb);
28395 return -EINVAL;
28396 }
28397
28398 if (skb_shinfo(skb)->nr_frags != 0) {
28399 printk("nicstar%d: No scatter-gather yet.\n", card->index);
28400 - atomic_inc(&vcc->stats->tx_err);
28401 + atomic_inc_unchecked(&vcc->stats->tx_err);
28402 dev_kfree_skb_any(skb);
28403 return -EINVAL;
28404 }
28405 @@ -1725,11 +1725,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
28406 }
28407
28408 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
28409 - atomic_inc(&vcc->stats->tx_err);
28410 + atomic_inc_unchecked(&vcc->stats->tx_err);
28411 dev_kfree_skb_any(skb);
28412 return -EIO;
28413 }
28414 - atomic_inc(&vcc->stats->tx);
28415 + atomic_inc_unchecked(&vcc->stats->tx);
28416
28417 return 0;
28418 }
28419 @@ -2046,14 +2046,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28420 printk
28421 ("nicstar%d: Can't allocate buffers for aal0.\n",
28422 card->index);
28423 - atomic_add(i, &vcc->stats->rx_drop);
28424 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
28425 break;
28426 }
28427 if (!atm_charge(vcc, sb->truesize)) {
28428 RXPRINTK
28429 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
28430 card->index);
28431 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
28432 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
28433 dev_kfree_skb_any(sb);
28434 break;
28435 }
28436 @@ -2068,7 +2068,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28437 ATM_SKB(sb)->vcc = vcc;
28438 __net_timestamp(sb);
28439 vcc->push(vcc, sb);
28440 - atomic_inc(&vcc->stats->rx);
28441 + atomic_inc_unchecked(&vcc->stats->rx);
28442 cell += ATM_CELL_PAYLOAD;
28443 }
28444
28445 @@ -2085,7 +2085,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28446 if (iovb == NULL) {
28447 printk("nicstar%d: Out of iovec buffers.\n",
28448 card->index);
28449 - atomic_inc(&vcc->stats->rx_drop);
28450 + atomic_inc_unchecked(&vcc->stats->rx_drop);
28451 recycle_rx_buf(card, skb);
28452 return;
28453 }
28454 @@ -2109,7 +2109,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28455 small or large buffer itself. */
28456 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
28457 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
28458 - atomic_inc(&vcc->stats->rx_err);
28459 + atomic_inc_unchecked(&vcc->stats->rx_err);
28460 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
28461 NS_MAX_IOVECS);
28462 NS_PRV_IOVCNT(iovb) = 0;
28463 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28464 ("nicstar%d: Expected a small buffer, and this is not one.\n",
28465 card->index);
28466 which_list(card, skb);
28467 - atomic_inc(&vcc->stats->rx_err);
28468 + atomic_inc_unchecked(&vcc->stats->rx_err);
28469 recycle_rx_buf(card, skb);
28470 vc->rx_iov = NULL;
28471 recycle_iov_buf(card, iovb);
28472 @@ -2142,7 +2142,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28473 ("nicstar%d: Expected a large buffer, and this is not one.\n",
28474 card->index);
28475 which_list(card, skb);
28476 - atomic_inc(&vcc->stats->rx_err);
28477 + atomic_inc_unchecked(&vcc->stats->rx_err);
28478 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
28479 NS_PRV_IOVCNT(iovb));
28480 vc->rx_iov = NULL;
28481 @@ -2165,7 +2165,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28482 printk(" - PDU size mismatch.\n");
28483 else
28484 printk(".\n");
28485 - atomic_inc(&vcc->stats->rx_err);
28486 + atomic_inc_unchecked(&vcc->stats->rx_err);
28487 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
28488 NS_PRV_IOVCNT(iovb));
28489 vc->rx_iov = NULL;
28490 @@ -2179,7 +2179,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28491 /* skb points to a small buffer */
28492 if (!atm_charge(vcc, skb->truesize)) {
28493 push_rxbufs(card, skb);
28494 - atomic_inc(&vcc->stats->rx_drop);
28495 + atomic_inc_unchecked(&vcc->stats->rx_drop);
28496 } else {
28497 skb_put(skb, len);
28498 dequeue_sm_buf(card, skb);
28499 @@ -2189,7 +2189,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28500 ATM_SKB(skb)->vcc = vcc;
28501 __net_timestamp(skb);
28502 vcc->push(vcc, skb);
28503 - atomic_inc(&vcc->stats->rx);
28504 + atomic_inc_unchecked(&vcc->stats->rx);
28505 }
28506 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
28507 struct sk_buff *sb;
28508 @@ -2200,7 +2200,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28509 if (len <= NS_SMBUFSIZE) {
28510 if (!atm_charge(vcc, sb->truesize)) {
28511 push_rxbufs(card, sb);
28512 - atomic_inc(&vcc->stats->rx_drop);
28513 + atomic_inc_unchecked(&vcc->stats->rx_drop);
28514 } else {
28515 skb_put(sb, len);
28516 dequeue_sm_buf(card, sb);
28517 @@ -2210,7 +2210,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28518 ATM_SKB(sb)->vcc = vcc;
28519 __net_timestamp(sb);
28520 vcc->push(vcc, sb);
28521 - atomic_inc(&vcc->stats->rx);
28522 + atomic_inc_unchecked(&vcc->stats->rx);
28523 }
28524
28525 push_rxbufs(card, skb);
28526 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28527
28528 if (!atm_charge(vcc, skb->truesize)) {
28529 push_rxbufs(card, skb);
28530 - atomic_inc(&vcc->stats->rx_drop);
28531 + atomic_inc_unchecked(&vcc->stats->rx_drop);
28532 } else {
28533 dequeue_lg_buf(card, skb);
28534 #ifdef NS_USE_DESTRUCTORS
28535 @@ -2232,7 +2232,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28536 ATM_SKB(skb)->vcc = vcc;
28537 __net_timestamp(skb);
28538 vcc->push(vcc, skb);
28539 - atomic_inc(&vcc->stats->rx);
28540 + atomic_inc_unchecked(&vcc->stats->rx);
28541 }
28542
28543 push_rxbufs(card, sb);
28544 @@ -2253,7 +2253,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28545 printk
28546 ("nicstar%d: Out of huge buffers.\n",
28547 card->index);
28548 - atomic_inc(&vcc->stats->rx_drop);
28549 + atomic_inc_unchecked(&vcc->stats->rx_drop);
28550 recycle_iovec_rx_bufs(card,
28551 (struct iovec *)
28552 iovb->data,
28553 @@ -2304,7 +2304,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28554 card->hbpool.count++;
28555 } else
28556 dev_kfree_skb_any(hb);
28557 - atomic_inc(&vcc->stats->rx_drop);
28558 + atomic_inc_unchecked(&vcc->stats->rx_drop);
28559 } else {
28560 /* Copy the small buffer to the huge buffer */
28561 sb = (struct sk_buff *)iov->iov_base;
28562 @@ -2341,7 +2341,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
28563 #endif /* NS_USE_DESTRUCTORS */
28564 __net_timestamp(hb);
28565 vcc->push(vcc, hb);
28566 - atomic_inc(&vcc->stats->rx);
28567 + atomic_inc_unchecked(&vcc->stats->rx);
28568 }
28569 }
28570
28571 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
28572 index e8cd652..bbbd1fc 100644
28573 --- a/drivers/atm/solos-pci.c
28574 +++ b/drivers/atm/solos-pci.c
28575 @@ -714,7 +714,7 @@ void solos_bh(unsigned long card_arg)
28576 }
28577 atm_charge(vcc, skb->truesize);
28578 vcc->push(vcc, skb);
28579 - atomic_inc(&vcc->stats->rx);
28580 + atomic_inc_unchecked(&vcc->stats->rx);
28581 break;
28582
28583 case PKT_STATUS:
28584 @@ -1008,7 +1008,7 @@ static uint32_t fpga_tx(struct solos_card *card)
28585 vcc = SKB_CB(oldskb)->vcc;
28586
28587 if (vcc) {
28588 - atomic_inc(&vcc->stats->tx);
28589 + atomic_inc_unchecked(&vcc->stats->tx);
28590 solos_pop(vcc, oldskb);
28591 } else
28592 dev_kfree_skb_irq(oldskb);
28593 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
28594 index 90f1ccc..04c4a1e 100644
28595 --- a/drivers/atm/suni.c
28596 +++ b/drivers/atm/suni.c
28597 @@ -50,8 +50,8 @@ static DEFINE_SPINLOCK(sunis_lock);
28598
28599
28600 #define ADD_LIMITED(s,v) \
28601 - atomic_add((v),&stats->s); \
28602 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
28603 + atomic_add_unchecked((v),&stats->s); \
28604 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
28605
28606
28607 static void suni_hz(unsigned long from_timer)
28608 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
28609 index 5120a96..e2572bd 100644
28610 --- a/drivers/atm/uPD98402.c
28611 +++ b/drivers/atm/uPD98402.c
28612 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
28613 struct sonet_stats tmp;
28614 int error = 0;
28615
28616 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
28617 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
28618 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
28619 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
28620 if (zero && !error) {
28621 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
28622
28623
28624 #define ADD_LIMITED(s,v) \
28625 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
28626 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
28627 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
28628 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
28629 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
28630 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
28631
28632
28633 static void stat_event(struct atm_dev *dev)
28634 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
28635 if (reason & uPD98402_INT_PFM) stat_event(dev);
28636 if (reason & uPD98402_INT_PCO) {
28637 (void) GET(PCOCR); /* clear interrupt cause */
28638 - atomic_add(GET(HECCT),
28639 + atomic_add_unchecked(GET(HECCT),
28640 &PRIV(dev)->sonet_stats.uncorr_hcs);
28641 }
28642 if ((reason & uPD98402_INT_RFO) &&
28643 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
28644 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
28645 uPD98402_INT_LOS),PIMR); /* enable them */
28646 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
28647 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
28648 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
28649 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
28650 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
28651 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
28652 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
28653 return 0;
28654 }
28655
28656 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
28657 index d889f56..17eb71e 100644
28658 --- a/drivers/atm/zatm.c
28659 +++ b/drivers/atm/zatm.c
28660 @@ -460,7 +460,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
28661 }
28662 if (!size) {
28663 dev_kfree_skb_irq(skb);
28664 - if (vcc) atomic_inc(&vcc->stats->rx_err);
28665 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
28666 continue;
28667 }
28668 if (!atm_charge(vcc,skb->truesize)) {
28669 @@ -470,7 +470,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
28670 skb->len = size;
28671 ATM_SKB(skb)->vcc = vcc;
28672 vcc->push(vcc,skb);
28673 - atomic_inc(&vcc->stats->rx);
28674 + atomic_inc_unchecked(&vcc->stats->rx);
28675 }
28676 zout(pos & 0xffff,MTA(mbx));
28677 #if 0 /* probably a stupid idea */
28678 @@ -734,7 +734,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
28679 skb_queue_head(&zatm_vcc->backlog,skb);
28680 break;
28681 }
28682 - atomic_inc(&vcc->stats->tx);
28683 + atomic_inc_unchecked(&vcc->stats->tx);
28684 wake_up(&zatm_vcc->tx_wait);
28685 }
28686
28687 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
28688 index 8493536..31adee0 100644
28689 --- a/drivers/base/devtmpfs.c
28690 +++ b/drivers/base/devtmpfs.c
28691 @@ -368,7 +368,7 @@ int devtmpfs_mount(const char *mntdir)
28692 if (!thread)
28693 return 0;
28694
28695 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
28696 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
28697 if (err)
28698 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
28699 else
28700 diff --git a/drivers/base/node.c b/drivers/base/node.c
28701 index 90aa2a1..af1a177 100644
28702 --- a/drivers/base/node.c
28703 +++ b/drivers/base/node.c
28704 @@ -592,11 +592,9 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
28705 {
28706 int n;
28707
28708 - n = nodelist_scnprintf(buf, PAGE_SIZE, node_states[state]);
28709 - if (n > 0 && PAGE_SIZE > n + 1) {
28710 - *(buf + n++) = '\n';
28711 - *(buf + n++) = '\0';
28712 - }
28713 + n = nodelist_scnprintf(buf, PAGE_SIZE-2, node_states[state]);
28714 + buf[n++] = '\n';
28715 + buf[n] = '\0';
28716 return n;
28717 }
28718
28719 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
28720 index caf995f..6f76697 100644
28721 --- a/drivers/base/power/wakeup.c
28722 +++ b/drivers/base/power/wakeup.c
28723 @@ -30,14 +30,14 @@ bool events_check_enabled;
28724 * They need to be modified together atomically, so it's better to use one
28725 * atomic variable to hold them both.
28726 */
28727 -static atomic_t combined_event_count = ATOMIC_INIT(0);
28728 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
28729
28730 #define IN_PROGRESS_BITS (sizeof(int) * 4)
28731 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
28732
28733 static void split_counters(unsigned int *cnt, unsigned int *inpr)
28734 {
28735 - unsigned int comb = atomic_read(&combined_event_count);
28736 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
28737
28738 *cnt = (comb >> IN_PROGRESS_BITS);
28739 *inpr = comb & MAX_IN_PROGRESS;
28740 @@ -353,7 +353,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
28741 ws->last_time = ktime_get();
28742
28743 /* Increment the counter of events in progress. */
28744 - atomic_inc(&combined_event_count);
28745 + atomic_inc_unchecked(&combined_event_count);
28746 }
28747
28748 /**
28749 @@ -443,7 +443,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
28750 * Increment the counter of registered wakeup events and decrement the
28751 * couter of wakeup events in progress simultaneously.
28752 */
28753 - atomic_add(MAX_IN_PROGRESS, &combined_event_count);
28754 + atomic_add_unchecked(MAX_IN_PROGRESS, &combined_event_count);
28755 }
28756
28757 /**
28758 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
28759 index b0f553b..77b928b 100644
28760 --- a/drivers/block/cciss.c
28761 +++ b/drivers/block/cciss.c
28762 @@ -1198,6 +1198,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
28763 int err;
28764 u32 cp;
28765
28766 + memset(&arg64, 0, sizeof(arg64));
28767 +
28768 err = 0;
28769 err |=
28770 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
28771 @@ -3007,7 +3009,7 @@ static void start_io(ctlr_info_t *h)
28772 while (!list_empty(&h->reqQ)) {
28773 c = list_entry(h->reqQ.next, CommandList_struct, list);
28774 /* can't do anything if fifo is full */
28775 - if ((h->access.fifo_full(h))) {
28776 + if ((h->access->fifo_full(h))) {
28777 dev_warn(&h->pdev->dev, "fifo full\n");
28778 break;
28779 }
28780 @@ -3017,7 +3019,7 @@ static void start_io(ctlr_info_t *h)
28781 h->Qdepth--;
28782
28783 /* Tell the controller execute command */
28784 - h->access.submit_command(h, c);
28785 + h->access->submit_command(h, c);
28786
28787 /* Put job onto the completed Q */
28788 addQ(&h->cmpQ, c);
28789 @@ -3443,17 +3445,17 @@ startio:
28790
28791 static inline unsigned long get_next_completion(ctlr_info_t *h)
28792 {
28793 - return h->access.command_completed(h);
28794 + return h->access->command_completed(h);
28795 }
28796
28797 static inline int interrupt_pending(ctlr_info_t *h)
28798 {
28799 - return h->access.intr_pending(h);
28800 + return h->access->intr_pending(h);
28801 }
28802
28803 static inline long interrupt_not_for_us(ctlr_info_t *h)
28804 {
28805 - return ((h->access.intr_pending(h) == 0) ||
28806 + return ((h->access->intr_pending(h) == 0) ||
28807 (h->interrupts_enabled == 0));
28808 }
28809
28810 @@ -3486,7 +3488,7 @@ static inline u32 next_command(ctlr_info_t *h)
28811 u32 a;
28812
28813 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
28814 - return h->access.command_completed(h);
28815 + return h->access->command_completed(h);
28816
28817 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
28818 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
28819 @@ -4044,7 +4046,7 @@ static void __devinit cciss_put_controller_into_performant_mode(ctlr_info_t *h)
28820 trans_support & CFGTBL_Trans_use_short_tags);
28821
28822 /* Change the access methods to the performant access methods */
28823 - h->access = SA5_performant_access;
28824 + h->access = &SA5_performant_access;
28825 h->transMethod = CFGTBL_Trans_Performant;
28826
28827 return;
28828 @@ -4316,7 +4318,7 @@ static int __devinit cciss_pci_init(ctlr_info_t *h)
28829 if (prod_index < 0)
28830 return -ENODEV;
28831 h->product_name = products[prod_index].product_name;
28832 - h->access = *(products[prod_index].access);
28833 + h->access = products[prod_index].access;
28834
28835 if (cciss_board_disabled(h)) {
28836 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
28837 @@ -5041,7 +5043,7 @@ reinit_after_soft_reset:
28838 }
28839
28840 /* make sure the board interrupts are off */
28841 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
28842 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
28843 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
28844 if (rc)
28845 goto clean2;
28846 @@ -5093,7 +5095,7 @@ reinit_after_soft_reset:
28847 * fake ones to scoop up any residual completions.
28848 */
28849 spin_lock_irqsave(&h->lock, flags);
28850 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
28851 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
28852 spin_unlock_irqrestore(&h->lock, flags);
28853 free_irq(h->intr[h->intr_mode], h);
28854 rc = cciss_request_irq(h, cciss_msix_discard_completions,
28855 @@ -5113,9 +5115,9 @@ reinit_after_soft_reset:
28856 dev_info(&h->pdev->dev, "Board READY.\n");
28857 dev_info(&h->pdev->dev,
28858 "Waiting for stale completions to drain.\n");
28859 - h->access.set_intr_mask(h, CCISS_INTR_ON);
28860 + h->access->set_intr_mask(h, CCISS_INTR_ON);
28861 msleep(10000);
28862 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
28863 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
28864
28865 rc = controller_reset_failed(h->cfgtable);
28866 if (rc)
28867 @@ -5138,7 +5140,7 @@ reinit_after_soft_reset:
28868 cciss_scsi_setup(h);
28869
28870 /* Turn the interrupts on so we can service requests */
28871 - h->access.set_intr_mask(h, CCISS_INTR_ON);
28872 + h->access->set_intr_mask(h, CCISS_INTR_ON);
28873
28874 /* Get the firmware version */
28875 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
28876 @@ -5211,7 +5213,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
28877 kfree(flush_buf);
28878 if (return_code != IO_OK)
28879 dev_warn(&h->pdev->dev, "Error flushing cache\n");
28880 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
28881 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
28882 free_irq(h->intr[h->intr_mode], h);
28883 }
28884
28885 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
28886 index 7fda30e..eb5dfe0 100644
28887 --- a/drivers/block/cciss.h
28888 +++ b/drivers/block/cciss.h
28889 @@ -101,7 +101,7 @@ struct ctlr_info
28890 /* information about each logical volume */
28891 drive_info_struct *drv[CISS_MAX_LUN];
28892
28893 - struct access_method access;
28894 + struct access_method *access;
28895
28896 /* queue and queue Info */
28897 struct list_head reqQ;
28898 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
28899 index 9125bbe..eede5c8 100644
28900 --- a/drivers/block/cpqarray.c
28901 +++ b/drivers/block/cpqarray.c
28902 @@ -404,7 +404,7 @@ static int __devinit cpqarray_register_ctlr( int i, struct pci_dev *pdev)
28903 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
28904 goto Enomem4;
28905 }
28906 - hba[i]->access.set_intr_mask(hba[i], 0);
28907 + hba[i]->access->set_intr_mask(hba[i], 0);
28908 if (request_irq(hba[i]->intr, do_ida_intr,
28909 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
28910 {
28911 @@ -459,7 +459,7 @@ static int __devinit cpqarray_register_ctlr( int i, struct pci_dev *pdev)
28912 add_timer(&hba[i]->timer);
28913
28914 /* Enable IRQ now that spinlock and rate limit timer are set up */
28915 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
28916 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
28917
28918 for(j=0; j<NWD; j++) {
28919 struct gendisk *disk = ida_gendisk[i][j];
28920 @@ -694,7 +694,7 @@ DBGINFO(
28921 for(i=0; i<NR_PRODUCTS; i++) {
28922 if (board_id == products[i].board_id) {
28923 c->product_name = products[i].product_name;
28924 - c->access = *(products[i].access);
28925 + c->access = products[i].access;
28926 break;
28927 }
28928 }
28929 @@ -792,7 +792,7 @@ static int __devinit cpqarray_eisa_detect(void)
28930 hba[ctlr]->intr = intr;
28931 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
28932 hba[ctlr]->product_name = products[j].product_name;
28933 - hba[ctlr]->access = *(products[j].access);
28934 + hba[ctlr]->access = products[j].access;
28935 hba[ctlr]->ctlr = ctlr;
28936 hba[ctlr]->board_id = board_id;
28937 hba[ctlr]->pci_dev = NULL; /* not PCI */
28938 @@ -980,7 +980,7 @@ static void start_io(ctlr_info_t *h)
28939
28940 while((c = h->reqQ) != NULL) {
28941 /* Can't do anything if we're busy */
28942 - if (h->access.fifo_full(h) == 0)
28943 + if (h->access->fifo_full(h) == 0)
28944 return;
28945
28946 /* Get the first entry from the request Q */
28947 @@ -988,7 +988,7 @@ static void start_io(ctlr_info_t *h)
28948 h->Qdepth--;
28949
28950 /* Tell the controller to do our bidding */
28951 - h->access.submit_command(h, c);
28952 + h->access->submit_command(h, c);
28953
28954 /* Get onto the completion Q */
28955 addQ(&h->cmpQ, c);
28956 @@ -1050,7 +1050,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
28957 unsigned long flags;
28958 __u32 a,a1;
28959
28960 - istat = h->access.intr_pending(h);
28961 + istat = h->access->intr_pending(h);
28962 /* Is this interrupt for us? */
28963 if (istat == 0)
28964 return IRQ_NONE;
28965 @@ -1061,7 +1061,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
28966 */
28967 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
28968 if (istat & FIFO_NOT_EMPTY) {
28969 - while((a = h->access.command_completed(h))) {
28970 + while((a = h->access->command_completed(h))) {
28971 a1 = a; a &= ~3;
28972 if ((c = h->cmpQ) == NULL)
28973 {
28974 @@ -1449,11 +1449,11 @@ static int sendcmd(
28975 /*
28976 * Disable interrupt
28977 */
28978 - info_p->access.set_intr_mask(info_p, 0);
28979 + info_p->access->set_intr_mask(info_p, 0);
28980 /* Make sure there is room in the command FIFO */
28981 /* Actually it should be completely empty at this time. */
28982 for (i = 200000; i > 0; i--) {
28983 - temp = info_p->access.fifo_full(info_p);
28984 + temp = info_p->access->fifo_full(info_p);
28985 if (temp != 0) {
28986 break;
28987 }
28988 @@ -1466,7 +1466,7 @@ DBG(
28989 /*
28990 * Send the cmd
28991 */
28992 - info_p->access.submit_command(info_p, c);
28993 + info_p->access->submit_command(info_p, c);
28994 complete = pollcomplete(ctlr);
28995
28996 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
28997 @@ -1549,9 +1549,9 @@ static int revalidate_allvol(ctlr_info_t *host)
28998 * we check the new geometry. Then turn interrupts back on when
28999 * we're done.
29000 */
29001 - host->access.set_intr_mask(host, 0);
29002 + host->access->set_intr_mask(host, 0);
29003 getgeometry(ctlr);
29004 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
29005 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
29006
29007 for(i=0; i<NWD; i++) {
29008 struct gendisk *disk = ida_gendisk[ctlr][i];
29009 @@ -1591,7 +1591,7 @@ static int pollcomplete(int ctlr)
29010 /* Wait (up to 2 seconds) for a command to complete */
29011
29012 for (i = 200000; i > 0; i--) {
29013 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
29014 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
29015 if (done == 0) {
29016 udelay(10); /* a short fixed delay */
29017 } else
29018 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
29019 index be73e9d..7fbf140 100644
29020 --- a/drivers/block/cpqarray.h
29021 +++ b/drivers/block/cpqarray.h
29022 @@ -99,7 +99,7 @@ struct ctlr_info {
29023 drv_info_t drv[NWD];
29024 struct proc_dir_entry *proc;
29025
29026 - struct access_method access;
29027 + struct access_method *access;
29028
29029 cmdlist_t *reqQ;
29030 cmdlist_t *cmpQ;
29031 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
29032 index 8d68056..e67050f 100644
29033 --- a/drivers/block/drbd/drbd_int.h
29034 +++ b/drivers/block/drbd/drbd_int.h
29035 @@ -736,7 +736,7 @@ struct drbd_request;
29036 struct drbd_epoch {
29037 struct list_head list;
29038 unsigned int barrier_nr;
29039 - atomic_t epoch_size; /* increased on every request added. */
29040 + atomic_unchecked_t epoch_size; /* increased on every request added. */
29041 atomic_t active; /* increased on every req. added, and dec on every finished. */
29042 unsigned long flags;
29043 };
29044 @@ -1108,7 +1108,7 @@ struct drbd_conf {
29045 void *int_dig_in;
29046 void *int_dig_vv;
29047 wait_queue_head_t seq_wait;
29048 - atomic_t packet_seq;
29049 + atomic_unchecked_t packet_seq;
29050 unsigned int peer_seq;
29051 spinlock_t peer_seq_lock;
29052 unsigned int minor;
29053 @@ -1617,30 +1617,30 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
29054
29055 static inline void drbd_tcp_cork(struct socket *sock)
29056 {
29057 - int __user val = 1;
29058 + int val = 1;
29059 (void) drbd_setsockopt(sock, SOL_TCP, TCP_CORK,
29060 - (char __user *)&val, sizeof(val));
29061 + (char __force_user *)&val, sizeof(val));
29062 }
29063
29064 static inline void drbd_tcp_uncork(struct socket *sock)
29065 {
29066 - int __user val = 0;
29067 + int val = 0;
29068 (void) drbd_setsockopt(sock, SOL_TCP, TCP_CORK,
29069 - (char __user *)&val, sizeof(val));
29070 + (char __force_user *)&val, sizeof(val));
29071 }
29072
29073 static inline void drbd_tcp_nodelay(struct socket *sock)
29074 {
29075 - int __user val = 1;
29076 + int val = 1;
29077 (void) drbd_setsockopt(sock, SOL_TCP, TCP_NODELAY,
29078 - (char __user *)&val, sizeof(val));
29079 + (char __force_user *)&val, sizeof(val));
29080 }
29081
29082 static inline void drbd_tcp_quickack(struct socket *sock)
29083 {
29084 - int __user val = 2;
29085 + int val = 2;
29086 (void) drbd_setsockopt(sock, SOL_TCP, TCP_QUICKACK,
29087 - (char __user *)&val, sizeof(val));
29088 + (char __force_user *)&val, sizeof(val));
29089 }
29090
29091 void drbd_bump_write_ordering(struct drbd_conf *mdev, enum write_ordering_e wo);
29092 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
29093 index 211fc44..c5116f1 100644
29094 --- a/drivers/block/drbd/drbd_main.c
29095 +++ b/drivers/block/drbd/drbd_main.c
29096 @@ -2397,7 +2397,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packets cmd,
29097 p.sector = sector;
29098 p.block_id = block_id;
29099 p.blksize = blksize;
29100 - p.seq_num = cpu_to_be32(atomic_add_return(1, &mdev->packet_seq));
29101 + p.seq_num = cpu_to_be32(atomic_add_return_unchecked(1, &mdev->packet_seq));
29102
29103 if (!mdev->meta.socket || mdev->state.conn < C_CONNECTED)
29104 return false;
29105 @@ -2696,7 +2696,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
29106 p.sector = cpu_to_be64(req->sector);
29107 p.block_id = (unsigned long)req;
29108 p.seq_num = cpu_to_be32(req->seq_num =
29109 - atomic_add_return(1, &mdev->packet_seq));
29110 + atomic_add_return_unchecked(1, &mdev->packet_seq));
29111
29112 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
29113
29114 @@ -2981,7 +2981,7 @@ void drbd_init_set_defaults(struct drbd_conf *mdev)
29115 atomic_set(&mdev->unacked_cnt, 0);
29116 atomic_set(&mdev->local_cnt, 0);
29117 atomic_set(&mdev->net_cnt, 0);
29118 - atomic_set(&mdev->packet_seq, 0);
29119 + atomic_set_unchecked(&mdev->packet_seq, 0);
29120 atomic_set(&mdev->pp_in_use, 0);
29121 atomic_set(&mdev->pp_in_use_by_net, 0);
29122 atomic_set(&mdev->rs_sect_in, 0);
29123 @@ -3063,8 +3063,8 @@ void drbd_mdev_cleanup(struct drbd_conf *mdev)
29124 mdev->receiver.t_state);
29125
29126 /* no need to lock it, I'm the only thread alive */
29127 - if (atomic_read(&mdev->current_epoch->epoch_size) != 0)
29128 - dev_err(DEV, "epoch_size:%d\n", atomic_read(&mdev->current_epoch->epoch_size));
29129 + if (atomic_read_unchecked(&mdev->current_epoch->epoch_size) != 0)
29130 + dev_err(DEV, "epoch_size:%d\n", atomic_read_unchecked(&mdev->current_epoch->epoch_size));
29131 mdev->al_writ_cnt =
29132 mdev->bm_writ_cnt =
29133 mdev->read_cnt =
29134 diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
29135 index af2a250..0fdeb75 100644
29136 --- a/drivers/block/drbd/drbd_nl.c
29137 +++ b/drivers/block/drbd/drbd_nl.c
29138 @@ -2297,7 +2297,7 @@ static void drbd_connector_callback(struct cn_msg *req, struct netlink_skb_parms
29139 return;
29140 }
29141
29142 - if (!cap_raised(current_cap(), CAP_SYS_ADMIN)) {
29143 + if (!capable(CAP_SYS_ADMIN)) {
29144 retcode = ERR_PERM;
29145 goto fail;
29146 }
29147 @@ -2359,7 +2359,7 @@ static void drbd_connector_callback(struct cn_msg *req, struct netlink_skb_parms
29148 module_put(THIS_MODULE);
29149 }
29150
29151 -static atomic_t drbd_nl_seq = ATOMIC_INIT(2); /* two. */
29152 +static atomic_unchecked_t drbd_nl_seq = ATOMIC_INIT(2); /* two. */
29153
29154 static unsigned short *
29155 __tl_add_blob(unsigned short *tl, enum drbd_tags tag, const void *data,
29156 @@ -2430,7 +2430,7 @@ void drbd_bcast_state(struct drbd_conf *mdev, union drbd_state state)
29157 cn_reply->id.idx = CN_IDX_DRBD;
29158 cn_reply->id.val = CN_VAL_DRBD;
29159
29160 - cn_reply->seq = atomic_add_return(1, &drbd_nl_seq);
29161 + cn_reply->seq = atomic_add_return_unchecked(1, &drbd_nl_seq);
29162 cn_reply->ack = 0; /* not used here. */
29163 cn_reply->len = sizeof(struct drbd_nl_cfg_reply) +
29164 (int)((char *)tl - (char *)reply->tag_list);
29165 @@ -2462,7 +2462,7 @@ void drbd_bcast_ev_helper(struct drbd_conf *mdev, char *helper_name)
29166 cn_reply->id.idx = CN_IDX_DRBD;
29167 cn_reply->id.val = CN_VAL_DRBD;
29168
29169 - cn_reply->seq = atomic_add_return(1, &drbd_nl_seq);
29170 + cn_reply->seq = atomic_add_return_unchecked(1, &drbd_nl_seq);
29171 cn_reply->ack = 0; /* not used here. */
29172 cn_reply->len = sizeof(struct drbd_nl_cfg_reply) +
29173 (int)((char *)tl - (char *)reply->tag_list);
29174 @@ -2540,7 +2540,7 @@ void drbd_bcast_ee(struct drbd_conf *mdev,
29175 cn_reply->id.idx = CN_IDX_DRBD;
29176 cn_reply->id.val = CN_VAL_DRBD;
29177
29178 - cn_reply->seq = atomic_add_return(1,&drbd_nl_seq);
29179 + cn_reply->seq = atomic_add_return_unchecked(1,&drbd_nl_seq);
29180 cn_reply->ack = 0; // not used here.
29181 cn_reply->len = sizeof(struct drbd_nl_cfg_reply) +
29182 (int)((char*)tl - (char*)reply->tag_list);
29183 @@ -2579,7 +2579,7 @@ void drbd_bcast_sync_progress(struct drbd_conf *mdev)
29184 cn_reply->id.idx = CN_IDX_DRBD;
29185 cn_reply->id.val = CN_VAL_DRBD;
29186
29187 - cn_reply->seq = atomic_add_return(1, &drbd_nl_seq);
29188 + cn_reply->seq = atomic_add_return_unchecked(1, &drbd_nl_seq);
29189 cn_reply->ack = 0; /* not used here. */
29190 cn_reply->len = sizeof(struct drbd_nl_cfg_reply) +
29191 (int)((char *)tl - (char *)reply->tag_list);
29192 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
29193 index 43beaca..4a5b1dd 100644
29194 --- a/drivers/block/drbd/drbd_receiver.c
29195 +++ b/drivers/block/drbd/drbd_receiver.c
29196 @@ -894,7 +894,7 @@ retry:
29197 sock->sk->sk_sndtimeo = mdev->net_conf->timeout*HZ/10;
29198 sock->sk->sk_rcvtimeo = MAX_SCHEDULE_TIMEOUT;
29199
29200 - atomic_set(&mdev->packet_seq, 0);
29201 + atomic_set_unchecked(&mdev->packet_seq, 0);
29202 mdev->peer_seq = 0;
29203
29204 drbd_thread_start(&mdev->asender);
29205 @@ -985,7 +985,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_conf *mdev,
29206 do {
29207 next_epoch = NULL;
29208
29209 - epoch_size = atomic_read(&epoch->epoch_size);
29210 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
29211
29212 switch (ev & ~EV_CLEANUP) {
29213 case EV_PUT:
29214 @@ -1020,7 +1020,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_conf *mdev,
29215 rv = FE_DESTROYED;
29216 } else {
29217 epoch->flags = 0;
29218 - atomic_set(&epoch->epoch_size, 0);
29219 + atomic_set_unchecked(&epoch->epoch_size, 0);
29220 /* atomic_set(&epoch->active, 0); is already zero */
29221 if (rv == FE_STILL_LIVE)
29222 rv = FE_RECYCLED;
29223 @@ -1191,14 +1191,14 @@ static int receive_Barrier(struct drbd_conf *mdev, enum drbd_packets cmd, unsign
29224 drbd_wait_ee_list_empty(mdev, &mdev->active_ee);
29225 drbd_flush(mdev);
29226
29227 - if (atomic_read(&mdev->current_epoch->epoch_size)) {
29228 + if (atomic_read_unchecked(&mdev->current_epoch->epoch_size)) {
29229 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
29230 if (epoch)
29231 break;
29232 }
29233
29234 epoch = mdev->current_epoch;
29235 - wait_event(mdev->ee_wait, atomic_read(&epoch->epoch_size) == 0);
29236 + wait_event(mdev->ee_wait, atomic_read_unchecked(&epoch->epoch_size) == 0);
29237
29238 D_ASSERT(atomic_read(&epoch->active) == 0);
29239 D_ASSERT(epoch->flags == 0);
29240 @@ -1210,11 +1210,11 @@ static int receive_Barrier(struct drbd_conf *mdev, enum drbd_packets cmd, unsign
29241 }
29242
29243 epoch->flags = 0;
29244 - atomic_set(&epoch->epoch_size, 0);
29245 + atomic_set_unchecked(&epoch->epoch_size, 0);
29246 atomic_set(&epoch->active, 0);
29247
29248 spin_lock(&mdev->epoch_lock);
29249 - if (atomic_read(&mdev->current_epoch->epoch_size)) {
29250 + if (atomic_read_unchecked(&mdev->current_epoch->epoch_size)) {
29251 list_add(&epoch->list, &mdev->current_epoch->list);
29252 mdev->current_epoch = epoch;
29253 mdev->epochs++;
29254 @@ -1663,7 +1663,7 @@ static int receive_Data(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned
29255 spin_unlock(&mdev->peer_seq_lock);
29256
29257 drbd_send_ack_dp(mdev, P_NEG_ACK, p, data_size);
29258 - atomic_inc(&mdev->current_epoch->epoch_size);
29259 + atomic_inc_unchecked(&mdev->current_epoch->epoch_size);
29260 return drbd_drain_block(mdev, data_size);
29261 }
29262
29263 @@ -1689,7 +1689,7 @@ static int receive_Data(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned
29264
29265 spin_lock(&mdev->epoch_lock);
29266 e->epoch = mdev->current_epoch;
29267 - atomic_inc(&e->epoch->epoch_size);
29268 + atomic_inc_unchecked(&e->epoch->epoch_size);
29269 atomic_inc(&e->epoch->active);
29270 spin_unlock(&mdev->epoch_lock);
29271
29272 @@ -3885,7 +3885,7 @@ static void drbd_disconnect(struct drbd_conf *mdev)
29273 D_ASSERT(list_empty(&mdev->done_ee));
29274
29275 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
29276 - atomic_set(&mdev->current_epoch->epoch_size, 0);
29277 + atomic_set_unchecked(&mdev->current_epoch->epoch_size, 0);
29278 D_ASSERT(list_empty(&mdev->current_epoch->list));
29279 }
29280
29281 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
29282 index cd50435..ba1ffb5 100644
29283 --- a/drivers/block/loop.c
29284 +++ b/drivers/block/loop.c
29285 @@ -226,7 +226,7 @@ static int __do_lo_send_write(struct file *file,
29286 mm_segment_t old_fs = get_fs();
29287
29288 set_fs(get_ds());
29289 - bw = file->f_op->write(file, buf, len, &pos);
29290 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
29291 set_fs(old_fs);
29292 if (likely(bw == len))
29293 return 0;
29294 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
29295 index 4364303..9adf4ee 100644
29296 --- a/drivers/char/Kconfig
29297 +++ b/drivers/char/Kconfig
29298 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
29299
29300 config DEVKMEM
29301 bool "/dev/kmem virtual device support"
29302 - default y
29303 + default n
29304 + depends on !GRKERNSEC_KMEM
29305 help
29306 Say Y here if you want to support the /dev/kmem device. The
29307 /dev/kmem device is rarely used, but can be used for certain
29308 @@ -596,6 +597,7 @@ config DEVPORT
29309 bool
29310 depends on !M68K
29311 depends on ISA || PCI
29312 + depends on !GRKERNSEC_KMEM
29313 default y
29314
29315 source "drivers/s390/char/Kconfig"
29316 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
29317 index 2e04433..22afc64 100644
29318 --- a/drivers/char/agp/frontend.c
29319 +++ b/drivers/char/agp/frontend.c
29320 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
29321 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
29322 return -EFAULT;
29323
29324 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
29325 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
29326 return -EFAULT;
29327
29328 client = agp_find_client_by_pid(reserve.pid);
29329 diff --git a/drivers/char/briq_panel.c b/drivers/char/briq_panel.c
29330 index 095ab90..afad0a4 100644
29331 --- a/drivers/char/briq_panel.c
29332 +++ b/drivers/char/briq_panel.c
29333 @@ -9,6 +9,7 @@
29334 #include <linux/types.h>
29335 #include <linux/errno.h>
29336 #include <linux/tty.h>
29337 +#include <linux/mutex.h>
29338 #include <linux/timer.h>
29339 #include <linux/kernel.h>
29340 #include <linux/wait.h>
29341 @@ -34,6 +35,7 @@ static int vfd_is_open;
29342 static unsigned char vfd[40];
29343 static int vfd_cursor;
29344 static unsigned char ledpb, led;
29345 +static DEFINE_MUTEX(vfd_mutex);
29346
29347 static void update_vfd(void)
29348 {
29349 @@ -140,12 +142,15 @@ static ssize_t briq_panel_write(struct file *file, const char __user *buf, size_
29350 if (!vfd_is_open)
29351 return -EBUSY;
29352
29353 + mutex_lock(&vfd_mutex);
29354 for (;;) {
29355 char c;
29356 if (!indx)
29357 break;
29358 - if (get_user(c, buf))
29359 + if (get_user(c, buf)) {
29360 + mutex_unlock(&vfd_mutex);
29361 return -EFAULT;
29362 + }
29363 if (esc) {
29364 set_led(c);
29365 esc = 0;
29366 @@ -175,6 +180,7 @@ static ssize_t briq_panel_write(struct file *file, const char __user *buf, size_
29367 buf++;
29368 }
29369 update_vfd();
29370 + mutex_unlock(&vfd_mutex);
29371
29372 return len;
29373 }
29374 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
29375 index f773a9d..65cd683 100644
29376 --- a/drivers/char/genrtc.c
29377 +++ b/drivers/char/genrtc.c
29378 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
29379 switch (cmd) {
29380
29381 case RTC_PLL_GET:
29382 + memset(&pll, 0, sizeof(pll));
29383 if (get_rtc_pll(&pll))
29384 return -EINVAL;
29385 else
29386 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
29387 index 0833896..cccce52 100644
29388 --- a/drivers/char/hpet.c
29389 +++ b/drivers/char/hpet.c
29390 @@ -572,7 +572,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
29391 }
29392
29393 static int
29394 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
29395 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
29396 struct hpet_info *info)
29397 {
29398 struct hpet_timer __iomem *timer;
29399 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
29400 index 58c0e63..46c16bf 100644
29401 --- a/drivers/char/ipmi/ipmi_msghandler.c
29402 +++ b/drivers/char/ipmi/ipmi_msghandler.c
29403 @@ -415,7 +415,7 @@ struct ipmi_smi {
29404 struct proc_dir_entry *proc_dir;
29405 char proc_dir_name[10];
29406
29407 - atomic_t stats[IPMI_NUM_STATS];
29408 + atomic_unchecked_t stats[IPMI_NUM_STATS];
29409
29410 /*
29411 * run_to_completion duplicate of smb_info, smi_info
29412 @@ -448,9 +448,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
29413
29414
29415 #define ipmi_inc_stat(intf, stat) \
29416 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
29417 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
29418 #define ipmi_get_stat(intf, stat) \
29419 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
29420 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
29421
29422 static int is_lan_addr(struct ipmi_addr *addr)
29423 {
29424 @@ -2868,7 +2868,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
29425 INIT_LIST_HEAD(&intf->cmd_rcvrs);
29426 init_waitqueue_head(&intf->waitq);
29427 for (i = 0; i < IPMI_NUM_STATS; i++)
29428 - atomic_set(&intf->stats[i], 0);
29429 + atomic_set_unchecked(&intf->stats[i], 0);
29430
29431 intf->proc_dir = NULL;
29432
29433 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
29434 index 50fcf9c..91b5528 100644
29435 --- a/drivers/char/ipmi/ipmi_si_intf.c
29436 +++ b/drivers/char/ipmi/ipmi_si_intf.c
29437 @@ -277,7 +277,7 @@ struct smi_info {
29438 unsigned char slave_addr;
29439
29440 /* Counters and things for the proc filesystem. */
29441 - atomic_t stats[SI_NUM_STATS];
29442 + atomic_unchecked_t stats[SI_NUM_STATS];
29443
29444 struct task_struct *thread;
29445
29446 @@ -286,9 +286,9 @@ struct smi_info {
29447 };
29448
29449 #define smi_inc_stat(smi, stat) \
29450 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
29451 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
29452 #define smi_get_stat(smi, stat) \
29453 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
29454 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
29455
29456 #define SI_MAX_PARMS 4
29457
29458 @@ -3230,7 +3230,7 @@ static int try_smi_init(struct smi_info *new_smi)
29459 atomic_set(&new_smi->req_events, 0);
29460 new_smi->run_to_completion = 0;
29461 for (i = 0; i < SI_NUM_STATS; i++)
29462 - atomic_set(&new_smi->stats[i], 0);
29463 + atomic_set_unchecked(&new_smi->stats[i], 0);
29464
29465 new_smi->interrupt_disabled = 1;
29466 atomic_set(&new_smi->stop_operation, 0);
29467 diff --git a/drivers/char/mbcs.c b/drivers/char/mbcs.c
29468 index 1aeaaba..e018570 100644
29469 --- a/drivers/char/mbcs.c
29470 +++ b/drivers/char/mbcs.c
29471 @@ -800,7 +800,7 @@ static int mbcs_remove(struct cx_dev *dev)
29472 return 0;
29473 }
29474
29475 -static const struct cx_device_id __devinitdata mbcs_id_table[] = {
29476 +static const struct cx_device_id __devinitconst mbcs_id_table[] = {
29477 {
29478 .part_num = MBCS_PART_NUM,
29479 .mfg_num = MBCS_MFG_NUM,
29480 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
29481 index d6e9d08..4493e89 100644
29482 --- a/drivers/char/mem.c
29483 +++ b/drivers/char/mem.c
29484 @@ -18,6 +18,7 @@
29485 #include <linux/raw.h>
29486 #include <linux/tty.h>
29487 #include <linux/capability.h>
29488 +#include <linux/security.h>
29489 #include <linux/ptrace.h>
29490 #include <linux/device.h>
29491 #include <linux/highmem.h>
29492 @@ -35,6 +36,10 @@
29493 # include <linux/efi.h>
29494 #endif
29495
29496 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
29497 +extern const struct file_operations grsec_fops;
29498 +#endif
29499 +
29500 static inline unsigned long size_inside_page(unsigned long start,
29501 unsigned long size)
29502 {
29503 @@ -66,9 +71,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29504
29505 while (cursor < to) {
29506 if (!devmem_is_allowed(pfn)) {
29507 +#ifdef CONFIG_GRKERNSEC_KMEM
29508 + gr_handle_mem_readwrite(from, to);
29509 +#else
29510 printk(KERN_INFO
29511 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
29512 current->comm, from, to);
29513 +#endif
29514 return 0;
29515 }
29516 cursor += PAGE_SIZE;
29517 @@ -76,6 +85,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29518 }
29519 return 1;
29520 }
29521 +#elif defined(CONFIG_GRKERNSEC_KMEM)
29522 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29523 +{
29524 + return 0;
29525 +}
29526 #else
29527 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29528 {
29529 @@ -118,6 +132,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
29530
29531 while (count > 0) {
29532 unsigned long remaining;
29533 + char *temp;
29534
29535 sz = size_inside_page(p, count);
29536
29537 @@ -133,7 +148,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
29538 if (!ptr)
29539 return -EFAULT;
29540
29541 - remaining = copy_to_user(buf, ptr, sz);
29542 +#ifdef CONFIG_PAX_USERCOPY
29543 + temp = kmalloc(sz, GFP_KERNEL);
29544 + if (!temp) {
29545 + unxlate_dev_mem_ptr(p, ptr);
29546 + return -ENOMEM;
29547 + }
29548 + memcpy(temp, ptr, sz);
29549 +#else
29550 + temp = ptr;
29551 +#endif
29552 +
29553 + remaining = copy_to_user(buf, temp, sz);
29554 +
29555 +#ifdef CONFIG_PAX_USERCOPY
29556 + kfree(temp);
29557 +#endif
29558 +
29559 unxlate_dev_mem_ptr(p, ptr);
29560 if (remaining)
29561 return -EFAULT;
29562 @@ -396,9 +427,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
29563 size_t count, loff_t *ppos)
29564 {
29565 unsigned long p = *ppos;
29566 - ssize_t low_count, read, sz;
29567 + ssize_t low_count, read, sz, err = 0;
29568 char * kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
29569 - int err = 0;
29570
29571 read = 0;
29572 if (p < (unsigned long) high_memory) {
29573 @@ -420,6 +450,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
29574 }
29575 #endif
29576 while (low_count > 0) {
29577 + char *temp;
29578 +
29579 sz = size_inside_page(p, low_count);
29580
29581 /*
29582 @@ -429,7 +461,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
29583 */
29584 kbuf = xlate_dev_kmem_ptr((char *)p);
29585
29586 - if (copy_to_user(buf, kbuf, sz))
29587 +#ifdef CONFIG_PAX_USERCOPY
29588 + temp = kmalloc(sz, GFP_KERNEL);
29589 + if (!temp)
29590 + return -ENOMEM;
29591 + memcpy(temp, kbuf, sz);
29592 +#else
29593 + temp = kbuf;
29594 +#endif
29595 +
29596 + err = copy_to_user(buf, temp, sz);
29597 +
29598 +#ifdef CONFIG_PAX_USERCOPY
29599 + kfree(temp);
29600 +#endif
29601 +
29602 + if (err)
29603 return -EFAULT;
29604 buf += sz;
29605 p += sz;
29606 @@ -867,6 +914,9 @@ static const struct memdev {
29607 #ifdef CONFIG_CRASH_DUMP
29608 [12] = { "oldmem", 0, &oldmem_fops, NULL },
29609 #endif
29610 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
29611 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
29612 +#endif
29613 };
29614
29615 static int memory_open(struct inode *inode, struct file *filp)
29616 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
29617 index da3cfee..a5a6606 100644
29618 --- a/drivers/char/nvram.c
29619 +++ b/drivers/char/nvram.c
29620 @@ -248,7 +248,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
29621
29622 spin_unlock_irq(&rtc_lock);
29623
29624 - if (copy_to_user(buf, contents, tmp - contents))
29625 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
29626 return -EFAULT;
29627
29628 *ppos = i;
29629 diff --git a/drivers/char/random.c b/drivers/char/random.c
29630 index 54ca8b2..4a092ed 100644
29631 --- a/drivers/char/random.c
29632 +++ b/drivers/char/random.c
29633 @@ -261,8 +261,13 @@
29634 /*
29635 * Configuration information
29636 */
29637 +#ifdef CONFIG_GRKERNSEC_RANDNET
29638 +#define INPUT_POOL_WORDS 512
29639 +#define OUTPUT_POOL_WORDS 128
29640 +#else
29641 #define INPUT_POOL_WORDS 128
29642 #define OUTPUT_POOL_WORDS 32
29643 +#endif
29644 #define SEC_XFER_SIZE 512
29645 #define EXTRACT_SIZE 10
29646
29647 @@ -300,10 +305,17 @@ static struct poolinfo {
29648 int poolwords;
29649 int tap1, tap2, tap3, tap4, tap5;
29650 } poolinfo_table[] = {
29651 +#ifdef CONFIG_GRKERNSEC_RANDNET
29652 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
29653 + { 512, 411, 308, 208, 104, 1 },
29654 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
29655 + { 128, 103, 76, 51, 25, 1 },
29656 +#else
29657 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
29658 { 128, 103, 76, 51, 25, 1 },
29659 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
29660 { 32, 26, 20, 14, 7, 1 },
29661 +#endif
29662 #if 0
29663 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
29664 { 2048, 1638, 1231, 819, 411, 1 },
29665 @@ -913,7 +925,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
29666
29667 extract_buf(r, tmp);
29668 i = min_t(int, nbytes, EXTRACT_SIZE);
29669 - if (copy_to_user(buf, tmp, i)) {
29670 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
29671 ret = -EFAULT;
29672 break;
29673 }
29674 @@ -1238,7 +1250,7 @@ EXPORT_SYMBOL(generate_random_uuid);
29675 #include <linux/sysctl.h>
29676
29677 static int min_read_thresh = 8, min_write_thresh;
29678 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
29679 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
29680 static int max_write_thresh = INPUT_POOL_WORDS * 32;
29681 static char sysctl_bootid[16];
29682
29683 @@ -1260,10 +1272,15 @@ static int proc_do_uuid(ctl_table *table, int write,
29684 uuid = table->data;
29685 if (!uuid) {
29686 uuid = tmp_uuid;
29687 - uuid[8] = 0;
29688 - }
29689 - if (uuid[8] == 0)
29690 generate_random_uuid(uuid);
29691 + } else {
29692 + static DEFINE_SPINLOCK(bootid_spinlock);
29693 +
29694 + spin_lock(&bootid_spinlock);
29695 + if (!uuid[8])
29696 + generate_random_uuid(uuid);
29697 + spin_unlock(&bootid_spinlock);
29698 + }
29699
29700 sprintf(buf, "%pU", uuid);
29701
29702 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
29703 index 1ee8ce7..b778bef 100644
29704 --- a/drivers/char/sonypi.c
29705 +++ b/drivers/char/sonypi.c
29706 @@ -55,6 +55,7 @@
29707 #include <asm/uaccess.h>
29708 #include <asm/io.h>
29709 #include <asm/system.h>
29710 +#include <asm/local.h>
29711
29712 #include <linux/sonypi.h>
29713
29714 @@ -491,7 +492,7 @@ static struct sonypi_device {
29715 spinlock_t fifo_lock;
29716 wait_queue_head_t fifo_proc_list;
29717 struct fasync_struct *fifo_async;
29718 - int open_count;
29719 + local_t open_count;
29720 int model;
29721 struct input_dev *input_jog_dev;
29722 struct input_dev *input_key_dev;
29723 @@ -898,7 +899,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
29724 static int sonypi_misc_release(struct inode *inode, struct file *file)
29725 {
29726 mutex_lock(&sonypi_device.lock);
29727 - sonypi_device.open_count--;
29728 + local_dec(&sonypi_device.open_count);
29729 mutex_unlock(&sonypi_device.lock);
29730 return 0;
29731 }
29732 @@ -907,9 +908,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
29733 {
29734 mutex_lock(&sonypi_device.lock);
29735 /* Flush input queue on first open */
29736 - if (!sonypi_device.open_count)
29737 + if (!local_read(&sonypi_device.open_count))
29738 kfifo_reset(&sonypi_device.fifo);
29739 - sonypi_device.open_count++;
29740 + local_inc(&sonypi_device.open_count);
29741 mutex_unlock(&sonypi_device.lock);
29742
29743 return 0;
29744 diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
29745 index ad7c732..5aa8054 100644
29746 --- a/drivers/char/tpm/tpm.c
29747 +++ b/drivers/char/tpm/tpm.c
29748 @@ -415,7 +415,7 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
29749 chip->vendor.req_complete_val)
29750 goto out_recv;
29751
29752 - if ((status == chip->vendor.req_canceled)) {
29753 + if (status == chip->vendor.req_canceled) {
29754 dev_err(chip->dev, "Operation Canceled\n");
29755 rc = -ECANCELED;
29756 goto out;
29757 diff --git a/drivers/char/tpm/tpm_bios.c b/drivers/char/tpm/tpm_bios.c
29758 index 0636520..169c1d0 100644
29759 --- a/drivers/char/tpm/tpm_bios.c
29760 +++ b/drivers/char/tpm/tpm_bios.c
29761 @@ -173,7 +173,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
29762 event = addr;
29763
29764 if ((event->event_type == 0 && event->event_size == 0) ||
29765 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
29766 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
29767 return NULL;
29768
29769 return addr;
29770 @@ -198,7 +198,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
29771 return NULL;
29772
29773 if ((event->event_type == 0 && event->event_size == 0) ||
29774 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
29775 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
29776 return NULL;
29777
29778 (*pos)++;
29779 @@ -291,7 +291,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
29780 int i;
29781
29782 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
29783 - seq_putc(m, data[i]);
29784 + if (!seq_putc(m, data[i]))
29785 + return -EFAULT;
29786
29787 return 0;
29788 }
29789 @@ -410,8 +411,13 @@ static int read_log(struct tpm_bios_log *log)
29790 log->bios_event_log_end = log->bios_event_log + len;
29791
29792 virt = acpi_os_map_memory(start, len);
29793 + if (!virt) {
29794 + kfree(log->bios_event_log);
29795 + log->bios_event_log = NULL;
29796 + return -EFAULT;
29797 + }
29798
29799 - memcpy(log->bios_event_log, virt, len);
29800 + memcpy(log->bios_event_log, (const char __force_kernel *)virt, len);
29801
29802 acpi_os_unmap_memory(virt, len);
29803 return 0;
29804 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
29805 index 41fc148..0dba6dd 100644
29806 --- a/drivers/char/virtio_console.c
29807 +++ b/drivers/char/virtio_console.c
29808 @@ -563,7 +563,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
29809 if (to_user) {
29810 ssize_t ret;
29811
29812 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
29813 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
29814 if (ret)
29815 return -EFAULT;
29816 } else {
29817 @@ -662,7 +662,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
29818 if (!port_has_data(port) && !port->host_connected)
29819 return 0;
29820
29821 - return fill_readbuf(port, ubuf, count, true);
29822 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
29823 }
29824
29825 static ssize_t port_fops_write(struct file *filp, const char __user *ubuf,
29826 diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
29827 index c9eee6d..f9d5280 100644
29828 --- a/drivers/edac/amd64_edac.c
29829 +++ b/drivers/edac/amd64_edac.c
29830 @@ -2685,7 +2685,7 @@ static void __devexit amd64_remove_one_instance(struct pci_dev *pdev)
29831 * PCI core identifies what devices are on a system during boot, and then
29832 * inquiry this table to see if this driver is for a given device found.
29833 */
29834 -static const struct pci_device_id amd64_pci_table[] __devinitdata = {
29835 +static const struct pci_device_id amd64_pci_table[] __devinitconst = {
29836 {
29837 .vendor = PCI_VENDOR_ID_AMD,
29838 .device = PCI_DEVICE_ID_AMD_K8_NB_MEMCTL,
29839 diff --git a/drivers/edac/amd76x_edac.c b/drivers/edac/amd76x_edac.c
29840 index e47e73b..348e0bd 100644
29841 --- a/drivers/edac/amd76x_edac.c
29842 +++ b/drivers/edac/amd76x_edac.c
29843 @@ -321,7 +321,7 @@ static void __devexit amd76x_remove_one(struct pci_dev *pdev)
29844 edac_mc_free(mci);
29845 }
29846
29847 -static const struct pci_device_id amd76x_pci_tbl[] __devinitdata = {
29848 +static const struct pci_device_id amd76x_pci_tbl[] __devinitconst = {
29849 {
29850 PCI_VEND_DEV(AMD, FE_GATE_700C), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
29851 AMD762},
29852 diff --git a/drivers/edac/e752x_edac.c b/drivers/edac/e752x_edac.c
29853 index 1af531a..3a8ff27 100644
29854 --- a/drivers/edac/e752x_edac.c
29855 +++ b/drivers/edac/e752x_edac.c
29856 @@ -1380,7 +1380,7 @@ static void __devexit e752x_remove_one(struct pci_dev *pdev)
29857 edac_mc_free(mci);
29858 }
29859
29860 -static const struct pci_device_id e752x_pci_tbl[] __devinitdata = {
29861 +static const struct pci_device_id e752x_pci_tbl[] __devinitconst = {
29862 {
29863 PCI_VEND_DEV(INTEL, 7520_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
29864 E7520},
29865 diff --git a/drivers/edac/e7xxx_edac.c b/drivers/edac/e7xxx_edac.c
29866 index 6ffb6d2..383d8d7 100644
29867 --- a/drivers/edac/e7xxx_edac.c
29868 +++ b/drivers/edac/e7xxx_edac.c
29869 @@ -525,7 +525,7 @@ static void __devexit e7xxx_remove_one(struct pci_dev *pdev)
29870 edac_mc_free(mci);
29871 }
29872
29873 -static const struct pci_device_id e7xxx_pci_tbl[] __devinitdata = {
29874 +static const struct pci_device_id e7xxx_pci_tbl[] __devinitconst = {
29875 {
29876 PCI_VEND_DEV(INTEL, 7205_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
29877 E7205},
29878 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
29879 index 97f5064..202b6e6 100644
29880 --- a/drivers/edac/edac_pci_sysfs.c
29881 +++ b/drivers/edac/edac_pci_sysfs.c
29882 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
29883 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
29884 static int edac_pci_poll_msec = 1000; /* one second workq period */
29885
29886 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
29887 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
29888 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
29889 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
29890
29891 static struct kobject *edac_pci_top_main_kobj;
29892 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
29893 @@ -582,7 +582,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
29894 edac_printk(KERN_CRIT, EDAC_PCI,
29895 "Signaled System Error on %s\n",
29896 pci_name(dev));
29897 - atomic_inc(&pci_nonparity_count);
29898 + atomic_inc_unchecked(&pci_nonparity_count);
29899 }
29900
29901 if (status & (PCI_STATUS_PARITY)) {
29902 @@ -590,7 +590,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
29903 "Master Data Parity Error on %s\n",
29904 pci_name(dev));
29905
29906 - atomic_inc(&pci_parity_count);
29907 + atomic_inc_unchecked(&pci_parity_count);
29908 }
29909
29910 if (status & (PCI_STATUS_DETECTED_PARITY)) {
29911 @@ -598,7 +598,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
29912 "Detected Parity Error on %s\n",
29913 pci_name(dev));
29914
29915 - atomic_inc(&pci_parity_count);
29916 + atomic_inc_unchecked(&pci_parity_count);
29917 }
29918 }
29919
29920 @@ -619,7 +619,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
29921 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
29922 "Signaled System Error on %s\n",
29923 pci_name(dev));
29924 - atomic_inc(&pci_nonparity_count);
29925 + atomic_inc_unchecked(&pci_nonparity_count);
29926 }
29927
29928 if (status & (PCI_STATUS_PARITY)) {
29929 @@ -627,7 +627,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
29930 "Master Data Parity Error on "
29931 "%s\n", pci_name(dev));
29932
29933 - atomic_inc(&pci_parity_count);
29934 + atomic_inc_unchecked(&pci_parity_count);
29935 }
29936
29937 if (status & (PCI_STATUS_DETECTED_PARITY)) {
29938 @@ -635,7 +635,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
29939 "Detected Parity Error on %s\n",
29940 pci_name(dev));
29941
29942 - atomic_inc(&pci_parity_count);
29943 + atomic_inc_unchecked(&pci_parity_count);
29944 }
29945 }
29946 }
29947 @@ -677,7 +677,7 @@ void edac_pci_do_parity_check(void)
29948 if (!check_pci_errors)
29949 return;
29950
29951 - before_count = atomic_read(&pci_parity_count);
29952 + before_count = atomic_read_unchecked(&pci_parity_count);
29953
29954 /* scan all PCI devices looking for a Parity Error on devices and
29955 * bridges.
29956 @@ -689,7 +689,7 @@ void edac_pci_do_parity_check(void)
29957 /* Only if operator has selected panic on PCI Error */
29958 if (edac_pci_get_panic_on_pe()) {
29959 /* If the count is different 'after' from 'before' */
29960 - if (before_count != atomic_read(&pci_parity_count))
29961 + if (before_count != atomic_read_unchecked(&pci_parity_count))
29962 panic("EDAC: PCI Parity Error");
29963 }
29964 }
29965 diff --git a/drivers/edac/i3000_edac.c b/drivers/edac/i3000_edac.c
29966 index c0510b3..6e2a954 100644
29967 --- a/drivers/edac/i3000_edac.c
29968 +++ b/drivers/edac/i3000_edac.c
29969 @@ -470,7 +470,7 @@ static void __devexit i3000_remove_one(struct pci_dev *pdev)
29970 edac_mc_free(mci);
29971 }
29972
29973 -static const struct pci_device_id i3000_pci_tbl[] __devinitdata = {
29974 +static const struct pci_device_id i3000_pci_tbl[] __devinitconst = {
29975 {
29976 PCI_VEND_DEV(INTEL, 3000_HB), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
29977 I3000},
29978 diff --git a/drivers/edac/i3200_edac.c b/drivers/edac/i3200_edac.c
29979 index 73f55e200..5faaf59 100644
29980 --- a/drivers/edac/i3200_edac.c
29981 +++ b/drivers/edac/i3200_edac.c
29982 @@ -445,7 +445,7 @@ static void __devexit i3200_remove_one(struct pci_dev *pdev)
29983 edac_mc_free(mci);
29984 }
29985
29986 -static const struct pci_device_id i3200_pci_tbl[] __devinitdata = {
29987 +static const struct pci_device_id i3200_pci_tbl[] __devinitconst = {
29988 {
29989 PCI_VEND_DEV(INTEL, 3200_HB), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
29990 I3200},
29991 diff --git a/drivers/edac/i5000_edac.c b/drivers/edac/i5000_edac.c
29992 index 4dc3ac2..67d05a6 100644
29993 --- a/drivers/edac/i5000_edac.c
29994 +++ b/drivers/edac/i5000_edac.c
29995 @@ -1516,7 +1516,7 @@ static void __devexit i5000_remove_one(struct pci_dev *pdev)
29996 *
29997 * The "E500P" device is the first device supported.
29998 */
29999 -static const struct pci_device_id i5000_pci_tbl[] __devinitdata = {
30000 +static const struct pci_device_id i5000_pci_tbl[] __devinitconst = {
30001 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_I5000_DEV16),
30002 .driver_data = I5000P},
30003
30004 diff --git a/drivers/edac/i5100_edac.c b/drivers/edac/i5100_edac.c
30005 index bcbdeec..9886d16 100644
30006 --- a/drivers/edac/i5100_edac.c
30007 +++ b/drivers/edac/i5100_edac.c
30008 @@ -1051,7 +1051,7 @@ static void __devexit i5100_remove_one(struct pci_dev *pdev)
30009 edac_mc_free(mci);
30010 }
30011
30012 -static const struct pci_device_id i5100_pci_tbl[] __devinitdata = {
30013 +static const struct pci_device_id i5100_pci_tbl[] __devinitconst = {
30014 /* Device 16, Function 0, Channel 0 Memory Map, Error Flag/Mask, ... */
30015 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5100_16) },
30016 { 0, }
30017 diff --git a/drivers/edac/i5400_edac.c b/drivers/edac/i5400_edac.c
30018 index 74d6ec34..baff517 100644
30019 --- a/drivers/edac/i5400_edac.c
30020 +++ b/drivers/edac/i5400_edac.c
30021 @@ -1383,7 +1383,7 @@ static void __devexit i5400_remove_one(struct pci_dev *pdev)
30022 *
30023 * The "E500P" device is the first device supported.
30024 */
30025 -static const struct pci_device_id i5400_pci_tbl[] __devinitdata = {
30026 +static const struct pci_device_id i5400_pci_tbl[] __devinitconst = {
30027 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5400_ERR)},
30028 {0,} /* 0 terminated list. */
30029 };
30030 diff --git a/drivers/edac/i7300_edac.c b/drivers/edac/i7300_edac.c
30031 index 6104dba..e7ea8e1 100644
30032 --- a/drivers/edac/i7300_edac.c
30033 +++ b/drivers/edac/i7300_edac.c
30034 @@ -1192,7 +1192,7 @@ static void __devexit i7300_remove_one(struct pci_dev *pdev)
30035 *
30036 * Has only 8086:360c PCI ID
30037 */
30038 -static const struct pci_device_id i7300_pci_tbl[] __devinitdata = {
30039 +static const struct pci_device_id i7300_pci_tbl[] __devinitconst = {
30040 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_I7300_MCH_ERR)},
30041 {0,} /* 0 terminated list. */
30042 };
30043 diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
30044 index 8568d9b..42b2fa8 100644
30045 --- a/drivers/edac/i7core_edac.c
30046 +++ b/drivers/edac/i7core_edac.c
30047 @@ -391,7 +391,7 @@ static const struct pci_id_table pci_dev_table[] = {
30048 /*
30049 * pci_device_id table for which devices we are looking for
30050 */
30051 -static const struct pci_device_id i7core_pci_tbl[] __devinitdata = {
30052 +static const struct pci_device_id i7core_pci_tbl[] __devinitconst = {
30053 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_X58_HUB_MGMT)},
30054 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_LYNNFIELD_QPI_LINK0)},
30055 {0,} /* 0 terminated list. */
30056 diff --git a/drivers/edac/i82443bxgx_edac.c b/drivers/edac/i82443bxgx_edac.c
30057 index 4329d39..f3022ef 100644
30058 --- a/drivers/edac/i82443bxgx_edac.c
30059 +++ b/drivers/edac/i82443bxgx_edac.c
30060 @@ -380,7 +380,7 @@ static void __devexit i82443bxgx_edacmc_remove_one(struct pci_dev *pdev)
30061
30062 EXPORT_SYMBOL_GPL(i82443bxgx_edacmc_remove_one);
30063
30064 -static const struct pci_device_id i82443bxgx_pci_tbl[] __devinitdata = {
30065 +static const struct pci_device_id i82443bxgx_pci_tbl[] __devinitconst = {
30066 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443BX_0)},
30067 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443BX_2)},
30068 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443GX_0)},
30069 diff --git a/drivers/edac/i82860_edac.c b/drivers/edac/i82860_edac.c
30070 index 931a057..fd28340 100644
30071 --- a/drivers/edac/i82860_edac.c
30072 +++ b/drivers/edac/i82860_edac.c
30073 @@ -270,7 +270,7 @@ static void __devexit i82860_remove_one(struct pci_dev *pdev)
30074 edac_mc_free(mci);
30075 }
30076
30077 -static const struct pci_device_id i82860_pci_tbl[] __devinitdata = {
30078 +static const struct pci_device_id i82860_pci_tbl[] __devinitconst = {
30079 {
30080 PCI_VEND_DEV(INTEL, 82860_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
30081 I82860},
30082 diff --git a/drivers/edac/i82875p_edac.c b/drivers/edac/i82875p_edac.c
30083 index 33864c6..01edc61 100644
30084 --- a/drivers/edac/i82875p_edac.c
30085 +++ b/drivers/edac/i82875p_edac.c
30086 @@ -511,7 +511,7 @@ static void __devexit i82875p_remove_one(struct pci_dev *pdev)
30087 edac_mc_free(mci);
30088 }
30089
30090 -static const struct pci_device_id i82875p_pci_tbl[] __devinitdata = {
30091 +static const struct pci_device_id i82875p_pci_tbl[] __devinitconst = {
30092 {
30093 PCI_VEND_DEV(INTEL, 82875_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
30094 I82875P},
30095 diff --git a/drivers/edac/i82975x_edac.c b/drivers/edac/i82975x_edac.c
30096 index 4184e01..dcb2cd3 100644
30097 --- a/drivers/edac/i82975x_edac.c
30098 +++ b/drivers/edac/i82975x_edac.c
30099 @@ -612,7 +612,7 @@ static void __devexit i82975x_remove_one(struct pci_dev *pdev)
30100 edac_mc_free(mci);
30101 }
30102
30103 -static const struct pci_device_id i82975x_pci_tbl[] __devinitdata = {
30104 +static const struct pci_device_id i82975x_pci_tbl[] __devinitconst = {
30105 {
30106 PCI_VEND_DEV(INTEL, 82975_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
30107 I82975X
30108 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
30109 index 0106747..0b40417 100644
30110 --- a/drivers/edac/mce_amd.h
30111 +++ b/drivers/edac/mce_amd.h
30112 @@ -83,7 +83,7 @@ struct amd_decoder_ops {
30113 bool (*dc_mce)(u16, u8);
30114 bool (*ic_mce)(u16, u8);
30115 bool (*nb_mce)(u16, u8);
30116 -};
30117 +} __no_const;
30118
30119 void amd_report_gart_errors(bool);
30120 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
30121 diff --git a/drivers/edac/r82600_edac.c b/drivers/edac/r82600_edac.c
30122 index e294e1b..a41b05b 100644
30123 --- a/drivers/edac/r82600_edac.c
30124 +++ b/drivers/edac/r82600_edac.c
30125 @@ -373,7 +373,7 @@ static void __devexit r82600_remove_one(struct pci_dev *pdev)
30126 edac_mc_free(mci);
30127 }
30128
30129 -static const struct pci_device_id r82600_pci_tbl[] __devinitdata = {
30130 +static const struct pci_device_id r82600_pci_tbl[] __devinitconst = {
30131 {
30132 PCI_DEVICE(PCI_VENDOR_ID_RADISYS, R82600_BRIDGE_ID)
30133 },
30134 diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
30135 index 1dc118d..8c68af9 100644
30136 --- a/drivers/edac/sb_edac.c
30137 +++ b/drivers/edac/sb_edac.c
30138 @@ -367,7 +367,7 @@ static const struct pci_id_table pci_dev_descr_sbridge_table[] = {
30139 /*
30140 * pci_device_id table for which devices we are looking for
30141 */
30142 -static const struct pci_device_id sbridge_pci_tbl[] __devinitdata = {
30143 +static const struct pci_device_id sbridge_pci_tbl[] __devinitconst = {
30144 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TA)},
30145 {0,} /* 0 terminated list. */
30146 };
30147 diff --git a/drivers/edac/x38_edac.c b/drivers/edac/x38_edac.c
30148 index b6f47de..c5acf3a 100644
30149 --- a/drivers/edac/x38_edac.c
30150 +++ b/drivers/edac/x38_edac.c
30151 @@ -440,7 +440,7 @@ static void __devexit x38_remove_one(struct pci_dev *pdev)
30152 edac_mc_free(mci);
30153 }
30154
30155 -static const struct pci_device_id x38_pci_tbl[] __devinitdata = {
30156 +static const struct pci_device_id x38_pci_tbl[] __devinitconst = {
30157 {
30158 PCI_VEND_DEV(INTEL, X38_HB), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
30159 X38},
30160 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
30161 index 85661b0..c784559a 100644
30162 --- a/drivers/firewire/core-card.c
30163 +++ b/drivers/firewire/core-card.c
30164 @@ -657,7 +657,7 @@ void fw_card_release(struct kref *kref)
30165
30166 void fw_core_remove_card(struct fw_card *card)
30167 {
30168 - struct fw_card_driver dummy_driver = dummy_driver_template;
30169 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
30170
30171 card->driver->update_phy_reg(card, 4,
30172 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
30173 diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
30174 index 4799393..37bd3ab 100644
30175 --- a/drivers/firewire/core-cdev.c
30176 +++ b/drivers/firewire/core-cdev.c
30177 @@ -1331,8 +1331,7 @@ static int init_iso_resource(struct client *client,
30178 int ret;
30179
30180 if ((request->channels == 0 && request->bandwidth == 0) ||
30181 - request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL ||
30182 - request->bandwidth < 0)
30183 + request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL)
30184 return -EINVAL;
30185
30186 r = kmalloc(sizeof(*r), GFP_KERNEL);
30187 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
30188 index 855ab3f..11f4bbd 100644
30189 --- a/drivers/firewire/core-transaction.c
30190 +++ b/drivers/firewire/core-transaction.c
30191 @@ -37,6 +37,7 @@
30192 #include <linux/timer.h>
30193 #include <linux/types.h>
30194 #include <linux/workqueue.h>
30195 +#include <linux/sched.h>
30196
30197 #include <asm/byteorder.h>
30198
30199 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
30200 index b45be57..5fad18b 100644
30201 --- a/drivers/firewire/core.h
30202 +++ b/drivers/firewire/core.h
30203 @@ -101,6 +101,7 @@ struct fw_card_driver {
30204
30205 int (*stop_iso)(struct fw_iso_context *ctx);
30206 };
30207 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
30208
30209 void fw_card_initialize(struct fw_card *card,
30210 const struct fw_card_driver *driver, struct device *device);
30211 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
30212 index 153980b..4b4d046 100644
30213 --- a/drivers/firmware/dmi_scan.c
30214 +++ b/drivers/firmware/dmi_scan.c
30215 @@ -449,11 +449,6 @@ void __init dmi_scan_machine(void)
30216 }
30217 }
30218 else {
30219 - /*
30220 - * no iounmap() for that ioremap(); it would be a no-op, but
30221 - * it's so early in setup that sucker gets confused into doing
30222 - * what it shouldn't if we actually call it.
30223 - */
30224 p = dmi_ioremap(0xF0000, 0x10000);
30225 if (p == NULL)
30226 goto error;
30227 @@ -723,7 +718,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
30228 if (buf == NULL)
30229 return -1;
30230
30231 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
30232 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
30233
30234 iounmap(buf);
30235 return 0;
30236 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
30237 index 82d5c20..44a7177 100644
30238 --- a/drivers/gpio/gpio-vr41xx.c
30239 +++ b/drivers/gpio/gpio-vr41xx.c
30240 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
30241 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
30242 maskl, pendl, maskh, pendh);
30243
30244 - atomic_inc(&irq_err_count);
30245 + atomic_inc_unchecked(&irq_err_count);
30246
30247 return -EINVAL;
30248 }
30249 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
30250 index 84a4a80..ce0306e 100644
30251 --- a/drivers/gpu/drm/drm_crtc_helper.c
30252 +++ b/drivers/gpu/drm/drm_crtc_helper.c
30253 @@ -280,7 +280,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
30254 struct drm_crtc *tmp;
30255 int crtc_mask = 1;
30256
30257 - WARN(!crtc, "checking null crtc?\n");
30258 + BUG_ON(!crtc);
30259
30260 dev = crtc->dev;
30261
30262 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
30263 index ebf7d3f..d64c436 100644
30264 --- a/drivers/gpu/drm/drm_drv.c
30265 +++ b/drivers/gpu/drm/drm_drv.c
30266 @@ -312,7 +312,7 @@ module_exit(drm_core_exit);
30267 /**
30268 * Copy and IOCTL return string to user space
30269 */
30270 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
30271 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
30272 {
30273 int len;
30274
30275 @@ -391,7 +391,7 @@ long drm_ioctl(struct file *filp,
30276
30277 dev = file_priv->minor->dev;
30278 atomic_inc(&dev->ioctl_count);
30279 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
30280 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
30281 ++file_priv->ioctl_count;
30282
30283 DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
30284 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
30285 index 6263b01..7987f55 100644
30286 --- a/drivers/gpu/drm/drm_fops.c
30287 +++ b/drivers/gpu/drm/drm_fops.c
30288 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
30289 }
30290
30291 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
30292 - atomic_set(&dev->counts[i], 0);
30293 + atomic_set_unchecked(&dev->counts[i], 0);
30294
30295 dev->sigdata.lock = NULL;
30296
30297 @@ -135,8 +135,8 @@ int drm_open(struct inode *inode, struct file *filp)
30298
30299 retcode = drm_open_helper(inode, filp, dev);
30300 if (!retcode) {
30301 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
30302 - if (!dev->open_count++)
30303 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
30304 + if (local_inc_return(&dev->open_count) == 1)
30305 retcode = drm_setup(dev);
30306 }
30307 if (!retcode) {
30308 @@ -473,7 +473,7 @@ int drm_release(struct inode *inode, struct file *filp)
30309
30310 mutex_lock(&drm_global_mutex);
30311
30312 - DRM_DEBUG("open_count = %d\n", dev->open_count);
30313 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
30314
30315 if (dev->driver->preclose)
30316 dev->driver->preclose(dev, file_priv);
30317 @@ -482,10 +482,10 @@ int drm_release(struct inode *inode, struct file *filp)
30318 * Begin inline drm_release
30319 */
30320
30321 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
30322 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
30323 task_pid_nr(current),
30324 (long)old_encode_dev(file_priv->minor->device),
30325 - dev->open_count);
30326 + local_read(&dev->open_count));
30327
30328 /* Release any auth tokens that might point to this file_priv,
30329 (do that under the drm_global_mutex) */
30330 @@ -571,8 +571,8 @@ int drm_release(struct inode *inode, struct file *filp)
30331 * End inline drm_release
30332 */
30333
30334 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
30335 - if (!--dev->open_count) {
30336 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
30337 + if (local_dec_and_test(&dev->open_count)) {
30338 if (atomic_read(&dev->ioctl_count)) {
30339 DRM_ERROR("Device busy: %d\n",
30340 atomic_read(&dev->ioctl_count));
30341 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
30342 index c87dc96..326055d 100644
30343 --- a/drivers/gpu/drm/drm_global.c
30344 +++ b/drivers/gpu/drm/drm_global.c
30345 @@ -36,7 +36,7 @@
30346 struct drm_global_item {
30347 struct mutex mutex;
30348 void *object;
30349 - int refcount;
30350 + atomic_t refcount;
30351 };
30352
30353 static struct drm_global_item glob[DRM_GLOBAL_NUM];
30354 @@ -49,7 +49,7 @@ void drm_global_init(void)
30355 struct drm_global_item *item = &glob[i];
30356 mutex_init(&item->mutex);
30357 item->object = NULL;
30358 - item->refcount = 0;
30359 + atomic_set(&item->refcount, 0);
30360 }
30361 }
30362
30363 @@ -59,7 +59,7 @@ void drm_global_release(void)
30364 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
30365 struct drm_global_item *item = &glob[i];
30366 BUG_ON(item->object != NULL);
30367 - BUG_ON(item->refcount != 0);
30368 + BUG_ON(atomic_read(&item->refcount) != 0);
30369 }
30370 }
30371
30372 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
30373 void *object;
30374
30375 mutex_lock(&item->mutex);
30376 - if (item->refcount == 0) {
30377 + if (atomic_read(&item->refcount) == 0) {
30378 item->object = kzalloc(ref->size, GFP_KERNEL);
30379 if (unlikely(item->object == NULL)) {
30380 ret = -ENOMEM;
30381 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
30382 goto out_err;
30383
30384 }
30385 - ++item->refcount;
30386 + atomic_inc(&item->refcount);
30387 ref->object = item->object;
30388 object = item->object;
30389 mutex_unlock(&item->mutex);
30390 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
30391 struct drm_global_item *item = &glob[ref->global_type];
30392
30393 mutex_lock(&item->mutex);
30394 - BUG_ON(item->refcount == 0);
30395 + BUG_ON(atomic_read(&item->refcount) == 0);
30396 BUG_ON(ref->object != item->object);
30397 - if (--item->refcount == 0) {
30398 + if (atomic_dec_and_test(&item->refcount)) {
30399 ref->release(ref);
30400 item->object = NULL;
30401 }
30402 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
30403 index ab1162d..42587b2 100644
30404 --- a/drivers/gpu/drm/drm_info.c
30405 +++ b/drivers/gpu/drm/drm_info.c
30406 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
30407 struct drm_local_map *map;
30408 struct drm_map_list *r_list;
30409
30410 - /* Hardcoded from _DRM_FRAME_BUFFER,
30411 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
30412 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
30413 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
30414 + static const char * const types[] = {
30415 + [_DRM_FRAME_BUFFER] = "FB",
30416 + [_DRM_REGISTERS] = "REG",
30417 + [_DRM_SHM] = "SHM",
30418 + [_DRM_AGP] = "AGP",
30419 + [_DRM_SCATTER_GATHER] = "SG",
30420 + [_DRM_CONSISTENT] = "PCI",
30421 + [_DRM_GEM] = "GEM" };
30422 const char *type;
30423 int i;
30424
30425 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
30426 map = r_list->map;
30427 if (!map)
30428 continue;
30429 - if (map->type < 0 || map->type > 5)
30430 + if (map->type >= ARRAY_SIZE(types))
30431 type = "??";
30432 else
30433 type = types[map->type];
30434 @@ -290,7 +294,11 @@ int drm_vma_info(struct seq_file *m, void *data)
30435 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
30436 vma->vm_flags & VM_LOCKED ? 'l' : '-',
30437 vma->vm_flags & VM_IO ? 'i' : '-',
30438 +#ifdef CONFIG_GRKERNSEC_HIDESYM
30439 + 0);
30440 +#else
30441 vma->vm_pgoff);
30442 +#endif
30443
30444 #if defined(__i386__)
30445 pgprot = pgprot_val(vma->vm_page_prot);
30446 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
30447 index 637fcc3..e890b33 100644
30448 --- a/drivers/gpu/drm/drm_ioc32.c
30449 +++ b/drivers/gpu/drm/drm_ioc32.c
30450 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
30451 request = compat_alloc_user_space(nbytes);
30452 if (!access_ok(VERIFY_WRITE, request, nbytes))
30453 return -EFAULT;
30454 - list = (struct drm_buf_desc *) (request + 1);
30455 + list = (struct drm_buf_desc __user *) (request + 1);
30456
30457 if (__put_user(count, &request->count)
30458 || __put_user(list, &request->list))
30459 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
30460 request = compat_alloc_user_space(nbytes);
30461 if (!access_ok(VERIFY_WRITE, request, nbytes))
30462 return -EFAULT;
30463 - list = (struct drm_buf_pub *) (request + 1);
30464 + list = (struct drm_buf_pub __user *) (request + 1);
30465
30466 if (__put_user(count, &request->count)
30467 || __put_user(list, &request->list))
30468 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
30469 index 956fd38..e52167a 100644
30470 --- a/drivers/gpu/drm/drm_ioctl.c
30471 +++ b/drivers/gpu/drm/drm_ioctl.c
30472 @@ -251,7 +251,7 @@ int drm_getstats(struct drm_device *dev, void *data,
30473 stats->data[i].value =
30474 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
30475 else
30476 - stats->data[i].value = atomic_read(&dev->counts[i]);
30477 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
30478 stats->data[i].type = dev->types[i];
30479 }
30480
30481 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
30482 index c79c713..2048588 100644
30483 --- a/drivers/gpu/drm/drm_lock.c
30484 +++ b/drivers/gpu/drm/drm_lock.c
30485 @@ -90,7 +90,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
30486 if (drm_lock_take(&master->lock, lock->context)) {
30487 master->lock.file_priv = file_priv;
30488 master->lock.lock_time = jiffies;
30489 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
30490 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
30491 break; /* Got lock */
30492 }
30493
30494 @@ -161,7 +161,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
30495 return -EINVAL;
30496 }
30497
30498 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
30499 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
30500
30501 if (drm_lock_free(&master->lock, lock->context)) {
30502 /* FIXME: Should really bail out here. */
30503 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
30504 index 7f4b4e1..bf4def2 100644
30505 --- a/drivers/gpu/drm/i810/i810_dma.c
30506 +++ b/drivers/gpu/drm/i810/i810_dma.c
30507 @@ -948,8 +948,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
30508 dma->buflist[vertex->idx],
30509 vertex->discard, vertex->used);
30510
30511 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
30512 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
30513 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
30514 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
30515 sarea_priv->last_enqueue = dev_priv->counter - 1;
30516 sarea_priv->last_dispatch = (int)hw_status[5];
30517
30518 @@ -1109,8 +1109,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
30519 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
30520 mc->last_render);
30521
30522 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
30523 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
30524 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
30525 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
30526 sarea_priv->last_enqueue = dev_priv->counter - 1;
30527 sarea_priv->last_dispatch = (int)hw_status[5];
30528
30529 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
30530 index c9339f4..f5e1b9d 100644
30531 --- a/drivers/gpu/drm/i810/i810_drv.h
30532 +++ b/drivers/gpu/drm/i810/i810_drv.h
30533 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
30534 int page_flipping;
30535
30536 wait_queue_head_t irq_queue;
30537 - atomic_t irq_received;
30538 - atomic_t irq_emitted;
30539 + atomic_unchecked_t irq_received;
30540 + atomic_unchecked_t irq_emitted;
30541
30542 int front_offset;
30543 } drm_i810_private_t;
30544 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
30545 index deaa657..e0fd296 100644
30546 --- a/drivers/gpu/drm/i915/i915_debugfs.c
30547 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
30548 @@ -499,7 +499,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
30549 I915_READ(GTIMR));
30550 }
30551 seq_printf(m, "Interrupts received: %d\n",
30552 - atomic_read(&dev_priv->irq_received));
30553 + atomic_read_unchecked(&dev_priv->irq_received));
30554 for (i = 0; i < I915_NUM_RINGS; i++) {
30555 if (IS_GEN6(dev) || IS_GEN7(dev)) {
30556 seq_printf(m, "Graphics Interrupt mask (%s): %08x\n",
30557 @@ -1321,7 +1321,7 @@ static int i915_opregion(struct seq_file *m, void *unused)
30558 return ret;
30559
30560 if (opregion->header)
30561 - seq_write(m, opregion->header, OPREGION_SIZE);
30562 + seq_write(m, (const void __force_kernel *)opregion->header, OPREGION_SIZE);
30563
30564 mutex_unlock(&dev->struct_mutex);
30565
30566 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
30567 index ddfe3d9..f6e6b21 100644
30568 --- a/drivers/gpu/drm/i915/i915_dma.c
30569 +++ b/drivers/gpu/drm/i915/i915_dma.c
30570 @@ -1175,7 +1175,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
30571 bool can_switch;
30572
30573 spin_lock(&dev->count_lock);
30574 - can_switch = (dev->open_count == 0);
30575 + can_switch = (local_read(&dev->open_count) == 0);
30576 spin_unlock(&dev->count_lock);
30577 return can_switch;
30578 }
30579 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
30580 index 9689ca3..294f9c1 100644
30581 --- a/drivers/gpu/drm/i915/i915_drv.h
30582 +++ b/drivers/gpu/drm/i915/i915_drv.h
30583 @@ -231,7 +231,7 @@ struct drm_i915_display_funcs {
30584 /* render clock increase/decrease */
30585 /* display clock increase/decrease */
30586 /* pll clock increase/decrease */
30587 -};
30588 +} __no_const;
30589
30590 struct intel_device_info {
30591 u8 gen;
30592 @@ -320,7 +320,7 @@ typedef struct drm_i915_private {
30593 int current_page;
30594 int page_flipping;
30595
30596 - atomic_t irq_received;
30597 + atomic_unchecked_t irq_received;
30598
30599 /* protects the irq masks */
30600 spinlock_t irq_lock;
30601 @@ -896,7 +896,7 @@ struct drm_i915_gem_object {
30602 * will be page flipped away on the next vblank. When it
30603 * reaches 0, dev_priv->pending_flip_queue will be woken up.
30604 */
30605 - atomic_t pending_flip;
30606 + atomic_unchecked_t pending_flip;
30607 };
30608
30609 #define to_intel_bo(x) container_of(x, struct drm_i915_gem_object, base)
30610 @@ -1276,7 +1276,7 @@ extern int intel_setup_gmbus(struct drm_device *dev);
30611 extern void intel_teardown_gmbus(struct drm_device *dev);
30612 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
30613 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
30614 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
30615 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
30616 {
30617 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
30618 }
30619 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
30620 index e159e33..cdcc663 100644
30621 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
30622 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
30623 @@ -189,7 +189,7 @@ i915_gem_object_set_to_gpu_domain(struct drm_i915_gem_object *obj,
30624 i915_gem_clflush_object(obj);
30625
30626 if (obj->base.pending_write_domain)
30627 - cd->flips |= atomic_read(&obj->pending_flip);
30628 + cd->flips |= atomic_read_unchecked(&obj->pending_flip);
30629
30630 /* The actual obj->write_domain will be updated with
30631 * pending_write_domain after we emit the accumulated flush for all
30632 @@ -882,9 +882,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
30633
30634 static int
30635 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
30636 - int count)
30637 + unsigned int count)
30638 {
30639 - int i;
30640 + unsigned int i;
30641
30642 for (i = 0; i < count; i++) {
30643 char __user *ptr = (char __user *)(uintptr_t)exec[i].relocs_ptr;
30644 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
30645 index 5bd4361..0241a42 100644
30646 --- a/drivers/gpu/drm/i915/i915_irq.c
30647 +++ b/drivers/gpu/drm/i915/i915_irq.c
30648 @@ -475,7 +475,7 @@ static irqreturn_t ivybridge_irq_handler(DRM_IRQ_ARGS)
30649 u32 de_iir, gt_iir, de_ier, pch_iir, pm_iir;
30650 struct drm_i915_master_private *master_priv;
30651
30652 - atomic_inc(&dev_priv->irq_received);
30653 + atomic_inc_unchecked(&dev_priv->irq_received);
30654
30655 /* disable master interrupt before clearing iir */
30656 de_ier = I915_READ(DEIER);
30657 @@ -566,7 +566,7 @@ static irqreturn_t ironlake_irq_handler(DRM_IRQ_ARGS)
30658 struct drm_i915_master_private *master_priv;
30659 u32 bsd_usr_interrupt = GT_BSD_USER_INTERRUPT;
30660
30661 - atomic_inc(&dev_priv->irq_received);
30662 + atomic_inc_unchecked(&dev_priv->irq_received);
30663
30664 if (IS_GEN6(dev))
30665 bsd_usr_interrupt = GT_GEN6_BSD_USER_INTERRUPT;
30666 @@ -1231,7 +1231,7 @@ static irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
30667 int ret = IRQ_NONE, pipe;
30668 bool blc_event = false;
30669
30670 - atomic_inc(&dev_priv->irq_received);
30671 + atomic_inc_unchecked(&dev_priv->irq_received);
30672
30673 iir = I915_READ(IIR);
30674
30675 @@ -1743,7 +1743,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
30676 {
30677 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
30678
30679 - atomic_set(&dev_priv->irq_received, 0);
30680 + atomic_set_unchecked(&dev_priv->irq_received, 0);
30681
30682 INIT_WORK(&dev_priv->hotplug_work, i915_hotplug_work_func);
30683 INIT_WORK(&dev_priv->error_work, i915_error_work_func);
30684 @@ -1932,7 +1932,7 @@ static void i915_driver_irq_preinstall(struct drm_device * dev)
30685 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
30686 int pipe;
30687
30688 - atomic_set(&dev_priv->irq_received, 0);
30689 + atomic_set_unchecked(&dev_priv->irq_received, 0);
30690
30691 INIT_WORK(&dev_priv->hotplug_work, i915_hotplug_work_func);
30692 INIT_WORK(&dev_priv->error_work, i915_error_work_func);
30693 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
30694 index 2163818..cede019 100644
30695 --- a/drivers/gpu/drm/i915/intel_display.c
30696 +++ b/drivers/gpu/drm/i915/intel_display.c
30697 @@ -2238,7 +2238,7 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
30698
30699 wait_event(dev_priv->pending_flip_queue,
30700 atomic_read(&dev_priv->mm.wedged) ||
30701 - atomic_read(&obj->pending_flip) == 0);
30702 + atomic_read_unchecked(&obj->pending_flip) == 0);
30703
30704 /* Big Hammer, we also need to ensure that any pending
30705 * MI_WAIT_FOR_EVENT inside a user batch buffer on the
30706 @@ -2859,7 +2859,7 @@ static void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc)
30707 obj = to_intel_framebuffer(crtc->fb)->obj;
30708 dev_priv = crtc->dev->dev_private;
30709 wait_event(dev_priv->pending_flip_queue,
30710 - atomic_read(&obj->pending_flip) == 0);
30711 + atomic_read_unchecked(&obj->pending_flip) == 0);
30712 }
30713
30714 static bool intel_crtc_driving_pch(struct drm_crtc *crtc)
30715 @@ -7171,7 +7171,7 @@ static void do_intel_finish_page_flip(struct drm_device *dev,
30716
30717 atomic_clear_mask(1 << intel_crtc->plane,
30718 &obj->pending_flip.counter);
30719 - if (atomic_read(&obj->pending_flip) == 0)
30720 + if (atomic_read_unchecked(&obj->pending_flip) == 0)
30721 wake_up(&dev_priv->pending_flip_queue);
30722
30723 schedule_work(&work->work);
30724 @@ -7354,7 +7354,13 @@ static int intel_gen6_queue_flip(struct drm_device *dev,
30725 OUT_RING(fb->pitches[0] | obj->tiling_mode);
30726 OUT_RING(obj->gtt_offset);
30727
30728 - pf = I915_READ(PF_CTL(intel_crtc->pipe)) & PF_ENABLE;
30729 + /* Contrary to the suggestions in the documentation,
30730 + * "Enable Panel Fitter" does not seem to be required when page
30731 + * flipping with a non-native mode, and worse causes a normal
30732 + * modeset to fail.
30733 + * pf = I915_READ(PF_CTL(intel_crtc->pipe)) & PF_ENABLE;
30734 + */
30735 + pf = 0;
30736 pipesrc = I915_READ(PIPESRC(intel_crtc->pipe)) & 0x0fff0fff;
30737 OUT_RING(pf | pipesrc);
30738 ADVANCE_LP_RING();
30739 @@ -7461,7 +7467,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
30740 /* Block clients from rendering to the new back buffer until
30741 * the flip occurs and the object is no longer visible.
30742 */
30743 - atomic_add(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
30744 + atomic_add_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
30745
30746 ret = dev_priv->display.queue_flip(dev, crtc, fb, obj);
30747 if (ret)
30748 @@ -7475,7 +7481,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
30749 return 0;
30750
30751 cleanup_pending:
30752 - atomic_sub(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
30753 + atomic_sub_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
30754 drm_gem_object_unreference(&work->old_fb_obj->base);
30755 drm_gem_object_unreference(&obj->base);
30756 mutex_unlock(&dev->struct_mutex);
30757 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
30758 index 54558a0..2d97005 100644
30759 --- a/drivers/gpu/drm/mga/mga_drv.h
30760 +++ b/drivers/gpu/drm/mga/mga_drv.h
30761 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
30762 u32 clear_cmd;
30763 u32 maccess;
30764
30765 - atomic_t vbl_received; /**< Number of vblanks received. */
30766 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
30767 wait_queue_head_t fence_queue;
30768 - atomic_t last_fence_retired;
30769 + atomic_unchecked_t last_fence_retired;
30770 u32 next_fence_to_post;
30771
30772 unsigned int fb_cpp;
30773 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
30774 index 2581202..f230a8d9 100644
30775 --- a/drivers/gpu/drm/mga/mga_irq.c
30776 +++ b/drivers/gpu/drm/mga/mga_irq.c
30777 @@ -44,7 +44,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
30778 if (crtc != 0)
30779 return 0;
30780
30781 - return atomic_read(&dev_priv->vbl_received);
30782 + return atomic_read_unchecked(&dev_priv->vbl_received);
30783 }
30784
30785
30786 @@ -60,7 +60,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
30787 /* VBLANK interrupt */
30788 if (status & MGA_VLINEPEN) {
30789 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
30790 - atomic_inc(&dev_priv->vbl_received);
30791 + atomic_inc_unchecked(&dev_priv->vbl_received);
30792 drm_handle_vblank(dev, 0);
30793 handled = 1;
30794 }
30795 @@ -79,7 +79,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
30796 if ((prim_start & ~0x03) != (prim_end & ~0x03))
30797 MGA_WRITE(MGA_PRIMEND, prim_end);
30798
30799 - atomic_inc(&dev_priv->last_fence_retired);
30800 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
30801 DRM_WAKEUP(&dev_priv->fence_queue);
30802 handled = 1;
30803 }
30804 @@ -130,7 +130,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
30805 * using fences.
30806 */
30807 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
30808 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
30809 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
30810 - *sequence) <= (1 << 23)));
30811
30812 *sequence = cur_fence;
30813 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
30814 index e5cbead..6c354a3 100644
30815 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
30816 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
30817 @@ -199,7 +199,7 @@ struct methods {
30818 const char desc[8];
30819 void (*loadbios)(struct drm_device *, uint8_t *);
30820 const bool rw;
30821 -};
30822 +} __do_const;
30823
30824 static struct methods shadow_methods[] = {
30825 { "PRAMIN", load_vbios_pramin, true },
30826 @@ -5290,7 +5290,7 @@ parse_bit_U_tbl_entry(struct drm_device *dev, struct nvbios *bios,
30827 struct bit_table {
30828 const char id;
30829 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
30830 -};
30831 +} __no_const;
30832
30833 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
30834
30835 diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
30836 index b827098..c31a797 100644
30837 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h
30838 +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
30839 @@ -242,7 +242,7 @@ struct nouveau_channel {
30840 struct list_head pending;
30841 uint32_t sequence;
30842 uint32_t sequence_ack;
30843 - atomic_t last_sequence_irq;
30844 + atomic_unchecked_t last_sequence_irq;
30845 struct nouveau_vma vma;
30846 } fence;
30847
30848 @@ -323,7 +323,7 @@ struct nouveau_exec_engine {
30849 u32 handle, u16 class);
30850 void (*set_tile_region)(struct drm_device *dev, int i);
30851 void (*tlb_flush)(struct drm_device *, int engine);
30852 -};
30853 +} __no_const;
30854
30855 struct nouveau_instmem_engine {
30856 void *priv;
30857 @@ -345,13 +345,13 @@ struct nouveau_instmem_engine {
30858 struct nouveau_mc_engine {
30859 int (*init)(struct drm_device *dev);
30860 void (*takedown)(struct drm_device *dev);
30861 -};
30862 +} __no_const;
30863
30864 struct nouveau_timer_engine {
30865 int (*init)(struct drm_device *dev);
30866 void (*takedown)(struct drm_device *dev);
30867 uint64_t (*read)(struct drm_device *dev);
30868 -};
30869 +} __no_const;
30870
30871 struct nouveau_fb_engine {
30872 int num_tiles;
30873 @@ -566,7 +566,7 @@ struct nouveau_vram_engine {
30874 void (*put)(struct drm_device *, struct nouveau_mem **);
30875
30876 bool (*flags_valid)(struct drm_device *, u32 tile_flags);
30877 -};
30878 +} __no_const;
30879
30880 struct nouveau_engine {
30881 struct nouveau_instmem_engine instmem;
30882 @@ -714,7 +714,7 @@ struct drm_nouveau_private {
30883 struct drm_global_reference mem_global_ref;
30884 struct ttm_bo_global_ref bo_global_ref;
30885 struct ttm_bo_device bdev;
30886 - atomic_t validate_sequence;
30887 + atomic_unchecked_t validate_sequence;
30888 } ttm;
30889
30890 struct {
30891 diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
30892 index 2f6daae..c9d7b9e 100644
30893 --- a/drivers/gpu/drm/nouveau/nouveau_fence.c
30894 +++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
30895 @@ -85,7 +85,7 @@ nouveau_fence_update(struct nouveau_channel *chan)
30896 if (USE_REFCNT(dev))
30897 sequence = nvchan_rd32(chan, 0x48);
30898 else
30899 - sequence = atomic_read(&chan->fence.last_sequence_irq);
30900 + sequence = atomic_read_unchecked(&chan->fence.last_sequence_irq);
30901
30902 if (chan->fence.sequence_ack == sequence)
30903 goto out;
30904 @@ -539,7 +539,7 @@ nouveau_fence_channel_init(struct nouveau_channel *chan)
30905 return ret;
30906 }
30907
30908 - atomic_set(&chan->fence.last_sequence_irq, 0);
30909 + atomic_set_unchecked(&chan->fence.last_sequence_irq, 0);
30910 return 0;
30911 }
30912
30913 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
30914 index 7ce3fde..cb3ea04 100644
30915 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
30916 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
30917 @@ -314,7 +314,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
30918 int trycnt = 0;
30919 int ret, i;
30920
30921 - sequence = atomic_add_return(1, &dev_priv->ttm.validate_sequence);
30922 + sequence = atomic_add_return_unchecked(1, &dev_priv->ttm.validate_sequence);
30923 retry:
30924 if (++trycnt > 100000) {
30925 NV_ERROR(dev, "%s failed and gave up.\n", __func__);
30926 diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c
30927 index f80c5e0..936baa7 100644
30928 --- a/drivers/gpu/drm/nouveau/nouveau_state.c
30929 +++ b/drivers/gpu/drm/nouveau/nouveau_state.c
30930 @@ -543,7 +543,7 @@ static bool nouveau_switcheroo_can_switch(struct pci_dev *pdev)
30931 bool can_switch;
30932
30933 spin_lock(&dev->count_lock);
30934 - can_switch = (dev->open_count == 0);
30935 + can_switch = (local_read(&dev->open_count) == 0);
30936 spin_unlock(&dev->count_lock);
30937 return can_switch;
30938 }
30939 diff --git a/drivers/gpu/drm/nouveau/nv04_graph.c b/drivers/gpu/drm/nouveau/nv04_graph.c
30940 index dbdea8e..cd6eeeb 100644
30941 --- a/drivers/gpu/drm/nouveau/nv04_graph.c
30942 +++ b/drivers/gpu/drm/nouveau/nv04_graph.c
30943 @@ -554,7 +554,7 @@ static int
30944 nv04_graph_mthd_set_ref(struct nouveau_channel *chan,
30945 u32 class, u32 mthd, u32 data)
30946 {
30947 - atomic_set(&chan->fence.last_sequence_irq, data);
30948 + atomic_set_unchecked(&chan->fence.last_sequence_irq, data);
30949 return 0;
30950 }
30951
30952 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
30953 index bcac90b..53bfc76 100644
30954 --- a/drivers/gpu/drm/r128/r128_cce.c
30955 +++ b/drivers/gpu/drm/r128/r128_cce.c
30956 @@ -378,7 +378,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
30957
30958 /* GH: Simple idle check.
30959 */
30960 - atomic_set(&dev_priv->idle_count, 0);
30961 + atomic_set_unchecked(&dev_priv->idle_count, 0);
30962
30963 /* We don't support anything other than bus-mastering ring mode,
30964 * but the ring can be in either AGP or PCI space for the ring
30965 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
30966 index 930c71b..499aded 100644
30967 --- a/drivers/gpu/drm/r128/r128_drv.h
30968 +++ b/drivers/gpu/drm/r128/r128_drv.h
30969 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
30970 int is_pci;
30971 unsigned long cce_buffers_offset;
30972
30973 - atomic_t idle_count;
30974 + atomic_unchecked_t idle_count;
30975
30976 int page_flipping;
30977 int current_page;
30978 u32 crtc_offset;
30979 u32 crtc_offset_cntl;
30980
30981 - atomic_t vbl_received;
30982 + atomic_unchecked_t vbl_received;
30983
30984 u32 color_fmt;
30985 unsigned int front_offset;
30986 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
30987 index 429d5a0..7e899ed 100644
30988 --- a/drivers/gpu/drm/r128/r128_irq.c
30989 +++ b/drivers/gpu/drm/r128/r128_irq.c
30990 @@ -42,7 +42,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
30991 if (crtc != 0)
30992 return 0;
30993
30994 - return atomic_read(&dev_priv->vbl_received);
30995 + return atomic_read_unchecked(&dev_priv->vbl_received);
30996 }
30997
30998 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
30999 @@ -56,7 +56,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
31000 /* VBLANK interrupt */
31001 if (status & R128_CRTC_VBLANK_INT) {
31002 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
31003 - atomic_inc(&dev_priv->vbl_received);
31004 + atomic_inc_unchecked(&dev_priv->vbl_received);
31005 drm_handle_vblank(dev, 0);
31006 return IRQ_HANDLED;
31007 }
31008 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
31009 index a9e33ce..09edd4b 100644
31010 --- a/drivers/gpu/drm/r128/r128_state.c
31011 +++ b/drivers/gpu/drm/r128/r128_state.c
31012 @@ -321,10 +321,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
31013
31014 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
31015 {
31016 - if (atomic_read(&dev_priv->idle_count) == 0)
31017 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
31018 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
31019 else
31020 - atomic_set(&dev_priv->idle_count, 0);
31021 + atomic_set_unchecked(&dev_priv->idle_count, 0);
31022 }
31023
31024 #endif
31025 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
31026 index 5a82b6b..9e69c73 100644
31027 --- a/drivers/gpu/drm/radeon/mkregtable.c
31028 +++ b/drivers/gpu/drm/radeon/mkregtable.c
31029 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
31030 regex_t mask_rex;
31031 regmatch_t match[4];
31032 char buf[1024];
31033 - size_t end;
31034 + long end;
31035 int len;
31036 int done = 0;
31037 int r;
31038 unsigned o;
31039 struct offset *offset;
31040 char last_reg_s[10];
31041 - int last_reg;
31042 + unsigned long last_reg;
31043
31044 if (regcomp
31045 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
31046 diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
31047 index 1668ec1..30ebdab 100644
31048 --- a/drivers/gpu/drm/radeon/radeon.h
31049 +++ b/drivers/gpu/drm/radeon/radeon.h
31050 @@ -250,7 +250,7 @@ struct radeon_fence_driver {
31051 uint32_t scratch_reg;
31052 uint64_t gpu_addr;
31053 volatile uint32_t *cpu_addr;
31054 - atomic_t seq;
31055 + atomic_unchecked_t seq;
31056 uint32_t last_seq;
31057 unsigned long last_jiffies;
31058 unsigned long last_timeout;
31059 @@ -752,7 +752,7 @@ struct r600_blit_cp_primitives {
31060 int x2, int y2);
31061 void (*draw_auto)(struct radeon_device *rdev);
31062 void (*set_default_state)(struct radeon_device *rdev);
31063 -};
31064 +} __no_const;
31065
31066 struct r600_blit {
31067 struct mutex mutex;
31068 @@ -1201,7 +1201,7 @@ struct radeon_asic {
31069 void (*pre_page_flip)(struct radeon_device *rdev, int crtc);
31070 u32 (*page_flip)(struct radeon_device *rdev, int crtc, u64 crtc_base);
31071 void (*post_page_flip)(struct radeon_device *rdev, int crtc);
31072 -};
31073 +} __no_const;
31074
31075 /*
31076 * Asic structures
31077 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
31078 index 49f7cb7..2fcb48f 100644
31079 --- a/drivers/gpu/drm/radeon/radeon_device.c
31080 +++ b/drivers/gpu/drm/radeon/radeon_device.c
31081 @@ -687,7 +687,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
31082 bool can_switch;
31083
31084 spin_lock(&dev->count_lock);
31085 - can_switch = (dev->open_count == 0);
31086 + can_switch = (local_read(&dev->open_count) == 0);
31087 spin_unlock(&dev->count_lock);
31088 return can_switch;
31089 }
31090 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
31091 index a1b59ca..86f2d44 100644
31092 --- a/drivers/gpu/drm/radeon/radeon_drv.h
31093 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
31094 @@ -255,7 +255,7 @@ typedef struct drm_radeon_private {
31095
31096 /* SW interrupt */
31097 wait_queue_head_t swi_queue;
31098 - atomic_t swi_emitted;
31099 + atomic_unchecked_t swi_emitted;
31100 int vblank_crtc;
31101 uint32_t irq_enable_reg;
31102 uint32_t r500_disp_irq_reg;
31103 diff --git a/drivers/gpu/drm/radeon/radeon_fence.c b/drivers/gpu/drm/radeon/radeon_fence.c
31104 index 4bd36a3..e66fe9c 100644
31105 --- a/drivers/gpu/drm/radeon/radeon_fence.c
31106 +++ b/drivers/gpu/drm/radeon/radeon_fence.c
31107 @@ -70,7 +70,7 @@ int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence *fence)
31108 write_unlock_irqrestore(&rdev->fence_lock, irq_flags);
31109 return 0;
31110 }
31111 - fence->seq = atomic_add_return(1, &rdev->fence_drv[fence->ring].seq);
31112 + fence->seq = atomic_add_return_unchecked(1, &rdev->fence_drv[fence->ring].seq);
31113 if (!rdev->ring[fence->ring].ready)
31114 /* FIXME: cp is not running assume everythings is done right
31115 * away
31116 @@ -405,7 +405,7 @@ int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring)
31117 }
31118 rdev->fence_drv[ring].cpu_addr = &rdev->wb.wb[index/4];
31119 rdev->fence_drv[ring].gpu_addr = rdev->wb.gpu_addr + index;
31120 - radeon_fence_write(rdev, atomic_read(&rdev->fence_drv[ring].seq), ring);
31121 + radeon_fence_write(rdev, atomic_read_unchecked(&rdev->fence_drv[ring].seq), ring);
31122 rdev->fence_drv[ring].initialized = true;
31123 DRM_INFO("fence driver on ring %d use gpu addr 0x%08Lx and cpu addr 0x%p\n",
31124 ring, rdev->fence_drv[ring].gpu_addr, rdev->fence_drv[ring].cpu_addr);
31125 @@ -418,7 +418,7 @@ static void radeon_fence_driver_init_ring(struct radeon_device *rdev, int ring)
31126 rdev->fence_drv[ring].scratch_reg = -1;
31127 rdev->fence_drv[ring].cpu_addr = NULL;
31128 rdev->fence_drv[ring].gpu_addr = 0;
31129 - atomic_set(&rdev->fence_drv[ring].seq, 0);
31130 + atomic_set_unchecked(&rdev->fence_drv[ring].seq, 0);
31131 INIT_LIST_HEAD(&rdev->fence_drv[ring].created);
31132 INIT_LIST_HEAD(&rdev->fence_drv[ring].emitted);
31133 INIT_LIST_HEAD(&rdev->fence_drv[ring].signaled);
31134 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
31135 index 48b7cea..342236f 100644
31136 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
31137 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
31138 @@ -359,7 +359,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
31139 request = compat_alloc_user_space(sizeof(*request));
31140 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
31141 || __put_user(req32.param, &request->param)
31142 - || __put_user((void __user *)(unsigned long)req32.value,
31143 + || __put_user((unsigned long)req32.value,
31144 &request->value))
31145 return -EFAULT;
31146
31147 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
31148 index 00da384..32f972d 100644
31149 --- a/drivers/gpu/drm/radeon/radeon_irq.c
31150 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
31151 @@ -225,8 +225,8 @@ static int radeon_emit_irq(struct drm_device * dev)
31152 unsigned int ret;
31153 RING_LOCALS;
31154
31155 - atomic_inc(&dev_priv->swi_emitted);
31156 - ret = atomic_read(&dev_priv->swi_emitted);
31157 + atomic_inc_unchecked(&dev_priv->swi_emitted);
31158 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
31159
31160 BEGIN_RING(4);
31161 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
31162 @@ -352,7 +352,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
31163 drm_radeon_private_t *dev_priv =
31164 (drm_radeon_private_t *) dev->dev_private;
31165
31166 - atomic_set(&dev_priv->swi_emitted, 0);
31167 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
31168 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
31169
31170 dev->max_vblank_count = 0x001fffff;
31171 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
31172 index e8422ae..d22d4a8 100644
31173 --- a/drivers/gpu/drm/radeon/radeon_state.c
31174 +++ b/drivers/gpu/drm/radeon/radeon_state.c
31175 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
31176 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
31177 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
31178
31179 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
31180 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
31181 sarea_priv->nbox * sizeof(depth_boxes[0])))
31182 return -EFAULT;
31183
31184 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
31185 {
31186 drm_radeon_private_t *dev_priv = dev->dev_private;
31187 drm_radeon_getparam_t *param = data;
31188 - int value;
31189 + int value = 0;
31190
31191 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
31192
31193 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
31194 index c421e77..e6bf2e8 100644
31195 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
31196 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
31197 @@ -842,8 +842,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
31198 }
31199 if (unlikely(ttm_vm_ops == NULL)) {
31200 ttm_vm_ops = vma->vm_ops;
31201 - radeon_ttm_vm_ops = *ttm_vm_ops;
31202 - radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
31203 + pax_open_kernel();
31204 + memcpy((void *)&radeon_ttm_vm_ops, ttm_vm_ops, sizeof(radeon_ttm_vm_ops));
31205 + *(void **)&radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
31206 + pax_close_kernel();
31207 }
31208 vma->vm_ops = &radeon_ttm_vm_ops;
31209 return 0;
31210 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
31211 index f68dff2..8df955c 100644
31212 --- a/drivers/gpu/drm/radeon/rs690.c
31213 +++ b/drivers/gpu/drm/radeon/rs690.c
31214 @@ -304,9 +304,11 @@ void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
31215 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
31216 rdev->pm.sideport_bandwidth.full)
31217 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
31218 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
31219 + read_delay_latency.full = dfixed_const(800 * 1000);
31220 read_delay_latency.full = dfixed_div(read_delay_latency,
31221 rdev->pm.igp_sideport_mclk);
31222 + a.full = dfixed_const(370);
31223 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
31224 } else {
31225 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
31226 rdev->pm.k8_bandwidth.full)
31227 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
31228 index 499debd..66fce72 100644
31229 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
31230 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
31231 @@ -398,9 +398,9 @@ static int ttm_pool_get_num_unused_pages(void)
31232 static int ttm_pool_mm_shrink(struct shrinker *shrink,
31233 struct shrink_control *sc)
31234 {
31235 - static atomic_t start_pool = ATOMIC_INIT(0);
31236 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
31237 unsigned i;
31238 - unsigned pool_offset = atomic_add_return(1, &start_pool);
31239 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
31240 struct ttm_page_pool *pool;
31241 int shrink_pages = sc->nr_to_scan;
31242
31243 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
31244 index 88edacc..1e5412b 100644
31245 --- a/drivers/gpu/drm/via/via_drv.h
31246 +++ b/drivers/gpu/drm/via/via_drv.h
31247 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
31248 typedef uint32_t maskarray_t[5];
31249
31250 typedef struct drm_via_irq {
31251 - atomic_t irq_received;
31252 + atomic_unchecked_t irq_received;
31253 uint32_t pending_mask;
31254 uint32_t enable_mask;
31255 wait_queue_head_t irq_queue;
31256 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
31257 struct timeval last_vblank;
31258 int last_vblank_valid;
31259 unsigned usec_per_vblank;
31260 - atomic_t vbl_received;
31261 + atomic_unchecked_t vbl_received;
31262 drm_via_state_t hc_state;
31263 char pci_buf[VIA_PCI_BUF_SIZE];
31264 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
31265 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
31266 index d391f48..10c8ca3 100644
31267 --- a/drivers/gpu/drm/via/via_irq.c
31268 +++ b/drivers/gpu/drm/via/via_irq.c
31269 @@ -102,7 +102,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
31270 if (crtc != 0)
31271 return 0;
31272
31273 - return atomic_read(&dev_priv->vbl_received);
31274 + return atomic_read_unchecked(&dev_priv->vbl_received);
31275 }
31276
31277 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
31278 @@ -117,8 +117,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
31279
31280 status = VIA_READ(VIA_REG_INTERRUPT);
31281 if (status & VIA_IRQ_VBLANK_PENDING) {
31282 - atomic_inc(&dev_priv->vbl_received);
31283 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
31284 + atomic_inc_unchecked(&dev_priv->vbl_received);
31285 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
31286 do_gettimeofday(&cur_vblank);
31287 if (dev_priv->last_vblank_valid) {
31288 dev_priv->usec_per_vblank =
31289 @@ -128,7 +128,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
31290 dev_priv->last_vblank = cur_vblank;
31291 dev_priv->last_vblank_valid = 1;
31292 }
31293 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
31294 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
31295 DRM_DEBUG("US per vblank is: %u\n",
31296 dev_priv->usec_per_vblank);
31297 }
31298 @@ -138,7 +138,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
31299
31300 for (i = 0; i < dev_priv->num_irqs; ++i) {
31301 if (status & cur_irq->pending_mask) {
31302 - atomic_inc(&cur_irq->irq_received);
31303 + atomic_inc_unchecked(&cur_irq->irq_received);
31304 DRM_WAKEUP(&cur_irq->irq_queue);
31305 handled = 1;
31306 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
31307 @@ -243,11 +243,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
31308 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
31309 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
31310 masks[irq][4]));
31311 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
31312 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
31313 } else {
31314 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
31315 (((cur_irq_sequence =
31316 - atomic_read(&cur_irq->irq_received)) -
31317 + atomic_read_unchecked(&cur_irq->irq_received)) -
31318 *sequence) <= (1 << 23)));
31319 }
31320 *sequence = cur_irq_sequence;
31321 @@ -285,7 +285,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
31322 }
31323
31324 for (i = 0; i < dev_priv->num_irqs; ++i) {
31325 - atomic_set(&cur_irq->irq_received, 0);
31326 + atomic_set_unchecked(&cur_irq->irq_received, 0);
31327 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
31328 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
31329 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
31330 @@ -367,7 +367,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
31331 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
31332 case VIA_IRQ_RELATIVE:
31333 irqwait->request.sequence +=
31334 - atomic_read(&cur_irq->irq_received);
31335 + atomic_read_unchecked(&cur_irq->irq_received);
31336 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
31337 case VIA_IRQ_ABSOLUTE:
31338 break;
31339 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
31340 index dc27970..f18b008 100644
31341 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
31342 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
31343 @@ -260,7 +260,7 @@ struct vmw_private {
31344 * Fencing and IRQs.
31345 */
31346
31347 - atomic_t marker_seq;
31348 + atomic_unchecked_t marker_seq;
31349 wait_queue_head_t fence_queue;
31350 wait_queue_head_t fifo_queue;
31351 int fence_queue_waiters; /* Protected by hw_mutex */
31352 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
31353 index a0c2f12..68ae6cb 100644
31354 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
31355 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
31356 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
31357 (unsigned int) min,
31358 (unsigned int) fifo->capabilities);
31359
31360 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
31361 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
31362 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
31363 vmw_marker_queue_init(&fifo->marker_queue);
31364 return vmw_fifo_send_fence(dev_priv, &dummy);
31365 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
31366 if (reserveable)
31367 iowrite32(bytes, fifo_mem +
31368 SVGA_FIFO_RESERVED);
31369 - return fifo_mem + (next_cmd >> 2);
31370 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
31371 } else {
31372 need_bounce = true;
31373 }
31374 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
31375
31376 fm = vmw_fifo_reserve(dev_priv, bytes);
31377 if (unlikely(fm == NULL)) {
31378 - *seqno = atomic_read(&dev_priv->marker_seq);
31379 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
31380 ret = -ENOMEM;
31381 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
31382 false, 3*HZ);
31383 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
31384 }
31385
31386 do {
31387 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
31388 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
31389 } while (*seqno == 0);
31390
31391 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
31392 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
31393 index cabc95f..14b3d77 100644
31394 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
31395 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
31396 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
31397 * emitted. Then the fence is stale and signaled.
31398 */
31399
31400 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
31401 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
31402 > VMW_FENCE_WRAP);
31403
31404 return ret;
31405 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
31406
31407 if (fifo_idle)
31408 down_read(&fifo_state->rwsem);
31409 - signal_seq = atomic_read(&dev_priv->marker_seq);
31410 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
31411 ret = 0;
31412
31413 for (;;) {
31414 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
31415 index 8a8725c..afed796 100644
31416 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
31417 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
31418 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
31419 while (!vmw_lag_lt(queue, us)) {
31420 spin_lock(&queue->lock);
31421 if (list_empty(&queue->head))
31422 - seqno = atomic_read(&dev_priv->marker_seq);
31423 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
31424 else {
31425 marker = list_first_entry(&queue->head,
31426 struct vmw_marker, head);
31427 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
31428 index 75dbe34..f9204a8 100644
31429 --- a/drivers/hid/hid-core.c
31430 +++ b/drivers/hid/hid-core.c
31431 @@ -2021,7 +2021,7 @@ static bool hid_ignore(struct hid_device *hdev)
31432
31433 int hid_add_device(struct hid_device *hdev)
31434 {
31435 - static atomic_t id = ATOMIC_INIT(0);
31436 + static atomic_unchecked_t id = ATOMIC_INIT(0);
31437 int ret;
31438
31439 if (WARN_ON(hdev->status & HID_STAT_ADDED))
31440 @@ -2036,7 +2036,7 @@ int hid_add_device(struct hid_device *hdev)
31441 /* XXX hack, any other cleaner solution after the driver core
31442 * is converted to allow more than 20 bytes as the device name? */
31443 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
31444 - hdev->vendor, hdev->product, atomic_inc_return(&id));
31445 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
31446
31447 hid_debug_register(hdev, dev_name(&hdev->dev));
31448 ret = device_add(&hdev->dev);
31449 diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
31450 index b1ec0e2..c295a61 100644
31451 --- a/drivers/hid/usbhid/hiddev.c
31452 +++ b/drivers/hid/usbhid/hiddev.c
31453 @@ -624,7 +624,7 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
31454 break;
31455
31456 case HIDIOCAPPLICATION:
31457 - if (arg < 0 || arg >= hid->maxapplication)
31458 + if (arg >= hid->maxapplication)
31459 break;
31460
31461 for (i = 0; i < hid->maxcollection; i++)
31462 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
31463 index 4065374..10ed7dc 100644
31464 --- a/drivers/hv/channel.c
31465 +++ b/drivers/hv/channel.c
31466 @@ -400,8 +400,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
31467 int ret = 0;
31468 int t;
31469
31470 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
31471 - atomic_inc(&vmbus_connection.next_gpadl_handle);
31472 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
31473 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
31474
31475 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
31476 if (ret)
31477 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
31478 index 12aa97f..c0679f7 100644
31479 --- a/drivers/hv/hv.c
31480 +++ b/drivers/hv/hv.c
31481 @@ -132,7 +132,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
31482 u64 output_address = (output) ? virt_to_phys(output) : 0;
31483 u32 output_address_hi = output_address >> 32;
31484 u32 output_address_lo = output_address & 0xFFFFFFFF;
31485 - void *hypercall_page = hv_context.hypercall_page;
31486 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
31487
31488 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
31489 "=a"(hv_status_lo) : "d" (control_hi),
31490 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
31491 index 6d7d286..92b0873 100644
31492 --- a/drivers/hv/hyperv_vmbus.h
31493 +++ b/drivers/hv/hyperv_vmbus.h
31494 @@ -556,7 +556,7 @@ enum vmbus_connect_state {
31495 struct vmbus_connection {
31496 enum vmbus_connect_state conn_state;
31497
31498 - atomic_t next_gpadl_handle;
31499 + atomic_unchecked_t next_gpadl_handle;
31500
31501 /*
31502 * Represents channel interrupts. Each bit position represents a
31503 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
31504 index a220e57..428f54d 100644
31505 --- a/drivers/hv/vmbus_drv.c
31506 +++ b/drivers/hv/vmbus_drv.c
31507 @@ -663,10 +663,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
31508 {
31509 int ret = 0;
31510
31511 - static atomic_t device_num = ATOMIC_INIT(0);
31512 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
31513
31514 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
31515 - atomic_inc_return(&device_num));
31516 + atomic_inc_return_unchecked(&device_num));
31517
31518 child_device_obj->device.bus = &hv_bus;
31519 child_device_obj->device.parent = &hv_acpi_dev->dev;
31520 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
31521 index 554f046..f8b4729 100644
31522 --- a/drivers/hwmon/acpi_power_meter.c
31523 +++ b/drivers/hwmon/acpi_power_meter.c
31524 @@ -316,8 +316,6 @@ static ssize_t set_trip(struct device *dev, struct device_attribute *devattr,
31525 return res;
31526
31527 temp /= 1000;
31528 - if (temp < 0)
31529 - return -EINVAL;
31530
31531 mutex_lock(&resource->lock);
31532 resource->trip[attr->index - 7] = temp;
31533 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
31534 index 91fdd1f..b66a686 100644
31535 --- a/drivers/hwmon/sht15.c
31536 +++ b/drivers/hwmon/sht15.c
31537 @@ -166,7 +166,7 @@ struct sht15_data {
31538 int supply_uV;
31539 bool supply_uV_valid;
31540 struct work_struct update_supply_work;
31541 - atomic_t interrupt_handled;
31542 + atomic_unchecked_t interrupt_handled;
31543 };
31544
31545 /**
31546 @@ -509,13 +509,13 @@ static int sht15_measurement(struct sht15_data *data,
31547 return ret;
31548
31549 gpio_direction_input(data->pdata->gpio_data);
31550 - atomic_set(&data->interrupt_handled, 0);
31551 + atomic_set_unchecked(&data->interrupt_handled, 0);
31552
31553 enable_irq(gpio_to_irq(data->pdata->gpio_data));
31554 if (gpio_get_value(data->pdata->gpio_data) == 0) {
31555 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
31556 /* Only relevant if the interrupt hasn't occurred. */
31557 - if (!atomic_read(&data->interrupt_handled))
31558 + if (!atomic_read_unchecked(&data->interrupt_handled))
31559 schedule_work(&data->read_work);
31560 }
31561 ret = wait_event_timeout(data->wait_queue,
31562 @@ -782,7 +782,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
31563
31564 /* First disable the interrupt */
31565 disable_irq_nosync(irq);
31566 - atomic_inc(&data->interrupt_handled);
31567 + atomic_inc_unchecked(&data->interrupt_handled);
31568 /* Then schedule a reading work struct */
31569 if (data->state != SHT15_READING_NOTHING)
31570 schedule_work(&data->read_work);
31571 @@ -804,11 +804,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
31572 * If not, then start the interrupt again - care here as could
31573 * have gone low in meantime so verify it hasn't!
31574 */
31575 - atomic_set(&data->interrupt_handled, 0);
31576 + atomic_set_unchecked(&data->interrupt_handled, 0);
31577 enable_irq(gpio_to_irq(data->pdata->gpio_data));
31578 /* If still not occurred or another handler has been scheduled */
31579 if (gpio_get_value(data->pdata->gpio_data)
31580 - || atomic_read(&data->interrupt_handled))
31581 + || atomic_read_unchecked(&data->interrupt_handled))
31582 return;
31583 }
31584
31585 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
31586 index 378fcb5..5e91fa8 100644
31587 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
31588 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
31589 @@ -43,7 +43,7 @@
31590 extern struct i2c_adapter amd756_smbus;
31591
31592 static struct i2c_adapter *s4882_adapter;
31593 -static struct i2c_algorithm *s4882_algo;
31594 +static i2c_algorithm_no_const *s4882_algo;
31595
31596 /* Wrapper access functions for multiplexed SMBus */
31597 static DEFINE_MUTEX(amd756_lock);
31598 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
31599 index 29015eb..af2d8e9 100644
31600 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
31601 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
31602 @@ -41,7 +41,7 @@
31603 extern struct i2c_adapter *nforce2_smbus;
31604
31605 static struct i2c_adapter *s4985_adapter;
31606 -static struct i2c_algorithm *s4985_algo;
31607 +static i2c_algorithm_no_const *s4985_algo;
31608
31609 /* Wrapper access functions for multiplexed SMBus */
31610 static DEFINE_MUTEX(nforce2_lock);
31611 diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c
31612 index d7a4833..7fae376 100644
31613 --- a/drivers/i2c/i2c-mux.c
31614 +++ b/drivers/i2c/i2c-mux.c
31615 @@ -28,7 +28,7 @@
31616 /* multiplexer per channel data */
31617 struct i2c_mux_priv {
31618 struct i2c_adapter adap;
31619 - struct i2c_algorithm algo;
31620 + i2c_algorithm_no_const algo;
31621
31622 struct i2c_adapter *parent;
31623 void *mux_dev; /* the mux chip/device */
31624 diff --git a/drivers/ide/aec62xx.c b/drivers/ide/aec62xx.c
31625 index 57d00ca..0145194 100644
31626 --- a/drivers/ide/aec62xx.c
31627 +++ b/drivers/ide/aec62xx.c
31628 @@ -181,7 +181,7 @@ static const struct ide_port_ops atp86x_port_ops = {
31629 .cable_detect = atp86x_cable_detect,
31630 };
31631
31632 -static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
31633 +static const struct ide_port_info aec62xx_chipsets[] __devinitconst = {
31634 { /* 0: AEC6210 */
31635 .name = DRV_NAME,
31636 .init_chipset = init_chipset_aec62xx,
31637 diff --git a/drivers/ide/alim15x3.c b/drivers/ide/alim15x3.c
31638 index 2c8016a..911a27c 100644
31639 --- a/drivers/ide/alim15x3.c
31640 +++ b/drivers/ide/alim15x3.c
31641 @@ -512,7 +512,7 @@ static const struct ide_dma_ops ali_dma_ops = {
31642 .dma_sff_read_status = ide_dma_sff_read_status,
31643 };
31644
31645 -static const struct ide_port_info ali15x3_chipset __devinitdata = {
31646 +static const struct ide_port_info ali15x3_chipset __devinitconst = {
31647 .name = DRV_NAME,
31648 .init_chipset = init_chipset_ali15x3,
31649 .init_hwif = init_hwif_ali15x3,
31650 diff --git a/drivers/ide/amd74xx.c b/drivers/ide/amd74xx.c
31651 index 3747b25..56fc995 100644
31652 --- a/drivers/ide/amd74xx.c
31653 +++ b/drivers/ide/amd74xx.c
31654 @@ -223,7 +223,7 @@ static const struct ide_port_ops amd_port_ops = {
31655 .udma_mask = udma, \
31656 }
31657
31658 -static const struct ide_port_info amd74xx_chipsets[] __devinitdata = {
31659 +static const struct ide_port_info amd74xx_chipsets[] __devinitconst = {
31660 /* 0: AMD7401 */ DECLARE_AMD_DEV(0x00, ATA_UDMA2),
31661 /* 1: AMD7409 */ DECLARE_AMD_DEV(ATA_SWDMA2, ATA_UDMA4),
31662 /* 2: AMD7411/7441 */ DECLARE_AMD_DEV(ATA_SWDMA2, ATA_UDMA5),
31663 diff --git a/drivers/ide/atiixp.c b/drivers/ide/atiixp.c
31664 index 15f0ead..cb43480 100644
31665 --- a/drivers/ide/atiixp.c
31666 +++ b/drivers/ide/atiixp.c
31667 @@ -139,7 +139,7 @@ static const struct ide_port_ops atiixp_port_ops = {
31668 .cable_detect = atiixp_cable_detect,
31669 };
31670
31671 -static const struct ide_port_info atiixp_pci_info[] __devinitdata = {
31672 +static const struct ide_port_info atiixp_pci_info[] __devinitconst = {
31673 { /* 0: IXP200/300/400/700 */
31674 .name = DRV_NAME,
31675 .enablebits = {{0x48,0x01,0x00}, {0x48,0x08,0x00}},
31676 diff --git a/drivers/ide/cmd64x.c b/drivers/ide/cmd64x.c
31677 index 5f80312..d1fc438 100644
31678 --- a/drivers/ide/cmd64x.c
31679 +++ b/drivers/ide/cmd64x.c
31680 @@ -327,7 +327,7 @@ static const struct ide_dma_ops cmd646_rev1_dma_ops = {
31681 .dma_sff_read_status = ide_dma_sff_read_status,
31682 };
31683
31684 -static const struct ide_port_info cmd64x_chipsets[] __devinitdata = {
31685 +static const struct ide_port_info cmd64x_chipsets[] __devinitconst = {
31686 { /* 0: CMD643 */
31687 .name = DRV_NAME,
31688 .init_chipset = init_chipset_cmd64x,
31689 diff --git a/drivers/ide/cs5520.c b/drivers/ide/cs5520.c
31690 index 2c1e5f7..1444762 100644
31691 --- a/drivers/ide/cs5520.c
31692 +++ b/drivers/ide/cs5520.c
31693 @@ -94,7 +94,7 @@ static const struct ide_port_ops cs5520_port_ops = {
31694 .set_dma_mode = cs5520_set_dma_mode,
31695 };
31696
31697 -static const struct ide_port_info cyrix_chipset __devinitdata = {
31698 +static const struct ide_port_info cyrix_chipset __devinitconst = {
31699 .name = DRV_NAME,
31700 .enablebits = { { 0x60, 0x01, 0x01 }, { 0x60, 0x02, 0x02 } },
31701 .port_ops = &cs5520_port_ops,
31702 diff --git a/drivers/ide/cs5530.c b/drivers/ide/cs5530.c
31703 index 4dc4eb9..49b40ad 100644
31704 --- a/drivers/ide/cs5530.c
31705 +++ b/drivers/ide/cs5530.c
31706 @@ -245,7 +245,7 @@ static const struct ide_port_ops cs5530_port_ops = {
31707 .udma_filter = cs5530_udma_filter,
31708 };
31709
31710 -static const struct ide_port_info cs5530_chipset __devinitdata = {
31711 +static const struct ide_port_info cs5530_chipset __devinitconst = {
31712 .name = DRV_NAME,
31713 .init_chipset = init_chipset_cs5530,
31714 .init_hwif = init_hwif_cs5530,
31715 diff --git a/drivers/ide/cs5535.c b/drivers/ide/cs5535.c
31716 index 5059faf..18d4c85 100644
31717 --- a/drivers/ide/cs5535.c
31718 +++ b/drivers/ide/cs5535.c
31719 @@ -170,7 +170,7 @@ static const struct ide_port_ops cs5535_port_ops = {
31720 .cable_detect = cs5535_cable_detect,
31721 };
31722
31723 -static const struct ide_port_info cs5535_chipset __devinitdata = {
31724 +static const struct ide_port_info cs5535_chipset __devinitconst = {
31725 .name = DRV_NAME,
31726 .port_ops = &cs5535_port_ops,
31727 .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_POST_SET_MODE,
31728 diff --git a/drivers/ide/cy82c693.c b/drivers/ide/cy82c693.c
31729 index 847553f..3ffb49d 100644
31730 --- a/drivers/ide/cy82c693.c
31731 +++ b/drivers/ide/cy82c693.c
31732 @@ -163,7 +163,7 @@ static const struct ide_port_ops cy82c693_port_ops = {
31733 .set_dma_mode = cy82c693_set_dma_mode,
31734 };
31735
31736 -static const struct ide_port_info cy82c693_chipset __devinitdata = {
31737 +static const struct ide_port_info cy82c693_chipset __devinitconst = {
31738 .name = DRV_NAME,
31739 .init_iops = init_iops_cy82c693,
31740 .port_ops = &cy82c693_port_ops,
31741 diff --git a/drivers/ide/hpt366.c b/drivers/ide/hpt366.c
31742 index 58c51cd..4aec3b8 100644
31743 --- a/drivers/ide/hpt366.c
31744 +++ b/drivers/ide/hpt366.c
31745 @@ -443,7 +443,7 @@ static struct hpt_timings hpt37x_timings = {
31746 }
31747 };
31748
31749 -static const struct hpt_info hpt36x __devinitdata = {
31750 +static const struct hpt_info hpt36x __devinitconst = {
31751 .chip_name = "HPT36x",
31752 .chip_type = HPT36x,
31753 .udma_mask = HPT366_ALLOW_ATA66_3 ? (HPT366_ALLOW_ATA66_4 ? ATA_UDMA4 : ATA_UDMA3) : ATA_UDMA2,
31754 @@ -451,7 +451,7 @@ static const struct hpt_info hpt36x __devinitdata = {
31755 .timings = &hpt36x_timings
31756 };
31757
31758 -static const struct hpt_info hpt370 __devinitdata = {
31759 +static const struct hpt_info hpt370 __devinitconst = {
31760 .chip_name = "HPT370",
31761 .chip_type = HPT370,
31762 .udma_mask = HPT370_ALLOW_ATA100_5 ? ATA_UDMA5 : ATA_UDMA4,
31763 @@ -459,7 +459,7 @@ static const struct hpt_info hpt370 __devinitdata = {
31764 .timings = &hpt37x_timings
31765 };
31766
31767 -static const struct hpt_info hpt370a __devinitdata = {
31768 +static const struct hpt_info hpt370a __devinitconst = {
31769 .chip_name = "HPT370A",
31770 .chip_type = HPT370A,
31771 .udma_mask = HPT370_ALLOW_ATA100_5 ? ATA_UDMA5 : ATA_UDMA4,
31772 @@ -467,7 +467,7 @@ static const struct hpt_info hpt370a __devinitdata = {
31773 .timings = &hpt37x_timings
31774 };
31775
31776 -static const struct hpt_info hpt374 __devinitdata = {
31777 +static const struct hpt_info hpt374 __devinitconst = {
31778 .chip_name = "HPT374",
31779 .chip_type = HPT374,
31780 .udma_mask = ATA_UDMA5,
31781 @@ -475,7 +475,7 @@ static const struct hpt_info hpt374 __devinitdata = {
31782 .timings = &hpt37x_timings
31783 };
31784
31785 -static const struct hpt_info hpt372 __devinitdata = {
31786 +static const struct hpt_info hpt372 __devinitconst = {
31787 .chip_name = "HPT372",
31788 .chip_type = HPT372,
31789 .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5,
31790 @@ -483,7 +483,7 @@ static const struct hpt_info hpt372 __devinitdata = {
31791 .timings = &hpt37x_timings
31792 };
31793
31794 -static const struct hpt_info hpt372a __devinitdata = {
31795 +static const struct hpt_info hpt372a __devinitconst = {
31796 .chip_name = "HPT372A",
31797 .chip_type = HPT372A,
31798 .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5,
31799 @@ -491,7 +491,7 @@ static const struct hpt_info hpt372a __devinitdata = {
31800 .timings = &hpt37x_timings
31801 };
31802
31803 -static const struct hpt_info hpt302 __devinitdata = {
31804 +static const struct hpt_info hpt302 __devinitconst = {
31805 .chip_name = "HPT302",
31806 .chip_type = HPT302,
31807 .udma_mask = HPT302_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5,
31808 @@ -499,7 +499,7 @@ static const struct hpt_info hpt302 __devinitdata = {
31809 .timings = &hpt37x_timings
31810 };
31811
31812 -static const struct hpt_info hpt371 __devinitdata = {
31813 +static const struct hpt_info hpt371 __devinitconst = {
31814 .chip_name = "HPT371",
31815 .chip_type = HPT371,
31816 .udma_mask = HPT371_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5,
31817 @@ -507,7 +507,7 @@ static const struct hpt_info hpt371 __devinitdata = {
31818 .timings = &hpt37x_timings
31819 };
31820
31821 -static const struct hpt_info hpt372n __devinitdata = {
31822 +static const struct hpt_info hpt372n __devinitconst = {
31823 .chip_name = "HPT372N",
31824 .chip_type = HPT372N,
31825 .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5,
31826 @@ -515,7 +515,7 @@ static const struct hpt_info hpt372n __devinitdata = {
31827 .timings = &hpt37x_timings
31828 };
31829
31830 -static const struct hpt_info hpt302n __devinitdata = {
31831 +static const struct hpt_info hpt302n __devinitconst = {
31832 .chip_name = "HPT302N",
31833 .chip_type = HPT302N,
31834 .udma_mask = HPT302_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5,
31835 @@ -523,7 +523,7 @@ static const struct hpt_info hpt302n __devinitdata = {
31836 .timings = &hpt37x_timings
31837 };
31838
31839 -static const struct hpt_info hpt371n __devinitdata = {
31840 +static const struct hpt_info hpt371n __devinitconst = {
31841 .chip_name = "HPT371N",
31842 .chip_type = HPT371N,
31843 .udma_mask = HPT371_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5,
31844 @@ -1361,7 +1361,7 @@ static const struct ide_dma_ops hpt36x_dma_ops = {
31845 .dma_sff_read_status = ide_dma_sff_read_status,
31846 };
31847
31848 -static const struct ide_port_info hpt366_chipsets[] __devinitdata = {
31849 +static const struct ide_port_info hpt366_chipsets[] __devinitconst = {
31850 { /* 0: HPT36x */
31851 .name = DRV_NAME,
31852 .init_chipset = init_chipset_hpt366,
31853 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
31854 index 8126824..55a2798 100644
31855 --- a/drivers/ide/ide-cd.c
31856 +++ b/drivers/ide/ide-cd.c
31857 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
31858 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
31859 if ((unsigned long)buf & alignment
31860 || blk_rq_bytes(rq) & q->dma_pad_mask
31861 - || object_is_on_stack(buf))
31862 + || object_starts_on_stack(buf))
31863 drive->dma = 0;
31864 }
31865 }
31866 diff --git a/drivers/ide/ide-pci-generic.c b/drivers/ide/ide-pci-generic.c
31867 index 7f56b73..dab5b67 100644
31868 --- a/drivers/ide/ide-pci-generic.c
31869 +++ b/drivers/ide/ide-pci-generic.c
31870 @@ -53,7 +53,7 @@ static const struct ide_port_ops netcell_port_ops = {
31871 .udma_mask = ATA_UDMA6, \
31872 }
31873
31874 -static const struct ide_port_info generic_chipsets[] __devinitdata = {
31875 +static const struct ide_port_info generic_chipsets[] __devinitconst = {
31876 /* 0: Unknown */
31877 DECLARE_GENERIC_PCI_DEV(0),
31878
31879 diff --git a/drivers/ide/it8172.c b/drivers/ide/it8172.c
31880 index 560e66d..d5dd180 100644
31881 --- a/drivers/ide/it8172.c
31882 +++ b/drivers/ide/it8172.c
31883 @@ -115,7 +115,7 @@ static const struct ide_port_ops it8172_port_ops = {
31884 .set_dma_mode = it8172_set_dma_mode,
31885 };
31886
31887 -static const struct ide_port_info it8172_port_info __devinitdata = {
31888 +static const struct ide_port_info it8172_port_info __devinitconst = {
31889 .name = DRV_NAME,
31890 .port_ops = &it8172_port_ops,
31891 .enablebits = { {0x41, 0x80, 0x80}, {0x00, 0x00, 0x00} },
31892 diff --git a/drivers/ide/it8213.c b/drivers/ide/it8213.c
31893 index 46816ba..1847aeb 100644
31894 --- a/drivers/ide/it8213.c
31895 +++ b/drivers/ide/it8213.c
31896 @@ -156,7 +156,7 @@ static const struct ide_port_ops it8213_port_ops = {
31897 .cable_detect = it8213_cable_detect,
31898 };
31899
31900 -static const struct ide_port_info it8213_chipset __devinitdata = {
31901 +static const struct ide_port_info it8213_chipset __devinitconst = {
31902 .name = DRV_NAME,
31903 .enablebits = { {0x41, 0x80, 0x80} },
31904 .port_ops = &it8213_port_ops,
31905 diff --git a/drivers/ide/it821x.c b/drivers/ide/it821x.c
31906 index 2e3169f..c5611db 100644
31907 --- a/drivers/ide/it821x.c
31908 +++ b/drivers/ide/it821x.c
31909 @@ -630,7 +630,7 @@ static const struct ide_port_ops it821x_port_ops = {
31910 .cable_detect = it821x_cable_detect,
31911 };
31912
31913 -static const struct ide_port_info it821x_chipset __devinitdata = {
31914 +static const struct ide_port_info it821x_chipset __devinitconst = {
31915 .name = DRV_NAME,
31916 .init_chipset = init_chipset_it821x,
31917 .init_hwif = init_hwif_it821x,
31918 diff --git a/drivers/ide/jmicron.c b/drivers/ide/jmicron.c
31919 index 74c2c4a..efddd7d 100644
31920 --- a/drivers/ide/jmicron.c
31921 +++ b/drivers/ide/jmicron.c
31922 @@ -102,7 +102,7 @@ static const struct ide_port_ops jmicron_port_ops = {
31923 .cable_detect = jmicron_cable_detect,
31924 };
31925
31926 -static const struct ide_port_info jmicron_chipset __devinitdata = {
31927 +static const struct ide_port_info jmicron_chipset __devinitconst = {
31928 .name = DRV_NAME,
31929 .enablebits = { { 0x40, 0x01, 0x01 }, { 0x40, 0x10, 0x10 } },
31930 .port_ops = &jmicron_port_ops,
31931 diff --git a/drivers/ide/ns87415.c b/drivers/ide/ns87415.c
31932 index 95327a2..73f78d8 100644
31933 --- a/drivers/ide/ns87415.c
31934 +++ b/drivers/ide/ns87415.c
31935 @@ -293,7 +293,7 @@ static const struct ide_dma_ops ns87415_dma_ops = {
31936 .dma_sff_read_status = superio_dma_sff_read_status,
31937 };
31938
31939 -static const struct ide_port_info ns87415_chipset __devinitdata = {
31940 +static const struct ide_port_info ns87415_chipset __devinitconst = {
31941 .name = DRV_NAME,
31942 .init_hwif = init_hwif_ns87415,
31943 .tp_ops = &ns87415_tp_ops,
31944 diff --git a/drivers/ide/opti621.c b/drivers/ide/opti621.c
31945 index 1a53a4c..39edc66 100644
31946 --- a/drivers/ide/opti621.c
31947 +++ b/drivers/ide/opti621.c
31948 @@ -131,7 +131,7 @@ static const struct ide_port_ops opti621_port_ops = {
31949 .set_pio_mode = opti621_set_pio_mode,
31950 };
31951
31952 -static const struct ide_port_info opti621_chipset __devinitdata = {
31953 +static const struct ide_port_info opti621_chipset __devinitconst = {
31954 .name = DRV_NAME,
31955 .enablebits = { {0x45, 0x80, 0x00}, {0x40, 0x08, 0x00} },
31956 .port_ops = &opti621_port_ops,
31957 diff --git a/drivers/ide/pdc202xx_new.c b/drivers/ide/pdc202xx_new.c
31958 index 9546fe2..2e5ceb6 100644
31959 --- a/drivers/ide/pdc202xx_new.c
31960 +++ b/drivers/ide/pdc202xx_new.c
31961 @@ -465,7 +465,7 @@ static const struct ide_port_ops pdcnew_port_ops = {
31962 .udma_mask = udma, \
31963 }
31964
31965 -static const struct ide_port_info pdcnew_chipsets[] __devinitdata = {
31966 +static const struct ide_port_info pdcnew_chipsets[] __devinitconst = {
31967 /* 0: PDC202{68,70} */ DECLARE_PDCNEW_DEV(ATA_UDMA5),
31968 /* 1: PDC202{69,71,75,76,77} */ DECLARE_PDCNEW_DEV(ATA_UDMA6),
31969 };
31970 diff --git a/drivers/ide/pdc202xx_old.c b/drivers/ide/pdc202xx_old.c
31971 index 3a35ec6..5634510 100644
31972 --- a/drivers/ide/pdc202xx_old.c
31973 +++ b/drivers/ide/pdc202xx_old.c
31974 @@ -270,7 +270,7 @@ static const struct ide_dma_ops pdc2026x_dma_ops = {
31975 .max_sectors = sectors, \
31976 }
31977
31978 -static const struct ide_port_info pdc202xx_chipsets[] __devinitdata = {
31979 +static const struct ide_port_info pdc202xx_chipsets[] __devinitconst = {
31980 { /* 0: PDC20246 */
31981 .name = DRV_NAME,
31982 .init_chipset = init_chipset_pdc202xx,
31983 diff --git a/drivers/ide/piix.c b/drivers/ide/piix.c
31984 index 1892e81..fe0fd60 100644
31985 --- a/drivers/ide/piix.c
31986 +++ b/drivers/ide/piix.c
31987 @@ -344,7 +344,7 @@ static const struct ide_port_ops ich_port_ops = {
31988 .udma_mask = udma, \
31989 }
31990
31991 -static const struct ide_port_info piix_pci_info[] __devinitdata = {
31992 +static const struct ide_port_info piix_pci_info[] __devinitconst = {
31993 /* 0: MPIIX */
31994 { /*
31995 * MPIIX actually has only a single IDE channel mapped to
31996 diff --git a/drivers/ide/rz1000.c b/drivers/ide/rz1000.c
31997 index a6414a8..c04173e 100644
31998 --- a/drivers/ide/rz1000.c
31999 +++ b/drivers/ide/rz1000.c
32000 @@ -38,7 +38,7 @@ static int __devinit rz1000_disable_readahead(struct pci_dev *dev)
32001 }
32002 }
32003
32004 -static const struct ide_port_info rz1000_chipset __devinitdata = {
32005 +static const struct ide_port_info rz1000_chipset __devinitconst = {
32006 .name = DRV_NAME,
32007 .host_flags = IDE_HFLAG_NO_DMA,
32008 };
32009 diff --git a/drivers/ide/sc1200.c b/drivers/ide/sc1200.c
32010 index 356b9b5..d4758eb 100644
32011 --- a/drivers/ide/sc1200.c
32012 +++ b/drivers/ide/sc1200.c
32013 @@ -291,7 +291,7 @@ static const struct ide_dma_ops sc1200_dma_ops = {
32014 .dma_sff_read_status = ide_dma_sff_read_status,
32015 };
32016
32017 -static const struct ide_port_info sc1200_chipset __devinitdata = {
32018 +static const struct ide_port_info sc1200_chipset __devinitconst = {
32019 .name = DRV_NAME,
32020 .port_ops = &sc1200_port_ops,
32021 .dma_ops = &sc1200_dma_ops,
32022 diff --git a/drivers/ide/scc_pata.c b/drivers/ide/scc_pata.c
32023 index b7f5b0c..9701038 100644
32024 --- a/drivers/ide/scc_pata.c
32025 +++ b/drivers/ide/scc_pata.c
32026 @@ -811,7 +811,7 @@ static const struct ide_dma_ops scc_dma_ops = {
32027 .dma_sff_read_status = scc_dma_sff_read_status,
32028 };
32029
32030 -static const struct ide_port_info scc_chipset __devinitdata = {
32031 +static const struct ide_port_info scc_chipset __devinitconst = {
32032 .name = "sccIDE",
32033 .init_iops = init_iops_scc,
32034 .init_dma = scc_init_dma,
32035 diff --git a/drivers/ide/serverworks.c b/drivers/ide/serverworks.c
32036 index 35fb8da..24d72ef 100644
32037 --- a/drivers/ide/serverworks.c
32038 +++ b/drivers/ide/serverworks.c
32039 @@ -337,7 +337,7 @@ static const struct ide_port_ops svwks_port_ops = {
32040 .cable_detect = svwks_cable_detect,
32041 };
32042
32043 -static const struct ide_port_info serverworks_chipsets[] __devinitdata = {
32044 +static const struct ide_port_info serverworks_chipsets[] __devinitconst = {
32045 { /* 0: OSB4 */
32046 .name = DRV_NAME,
32047 .init_chipset = init_chipset_svwks,
32048 diff --git a/drivers/ide/siimage.c b/drivers/ide/siimage.c
32049 index ddeda44..46f7e30 100644
32050 --- a/drivers/ide/siimage.c
32051 +++ b/drivers/ide/siimage.c
32052 @@ -719,7 +719,7 @@ static const struct ide_dma_ops sil_dma_ops = {
32053 .udma_mask = ATA_UDMA6, \
32054 }
32055
32056 -static const struct ide_port_info siimage_chipsets[] __devinitdata = {
32057 +static const struct ide_port_info siimage_chipsets[] __devinitconst = {
32058 /* 0: SiI680 */ DECLARE_SII_DEV(&sil_pata_port_ops),
32059 /* 1: SiI3112 */ DECLARE_SII_DEV(&sil_sata_port_ops)
32060 };
32061 diff --git a/drivers/ide/sis5513.c b/drivers/ide/sis5513.c
32062 index 4a00225..09e61b4 100644
32063 --- a/drivers/ide/sis5513.c
32064 +++ b/drivers/ide/sis5513.c
32065 @@ -563,7 +563,7 @@ static const struct ide_port_ops sis_ata133_port_ops = {
32066 .cable_detect = sis_cable_detect,
32067 };
32068
32069 -static const struct ide_port_info sis5513_chipset __devinitdata = {
32070 +static const struct ide_port_info sis5513_chipset __devinitconst = {
32071 .name = DRV_NAME,
32072 .init_chipset = init_chipset_sis5513,
32073 .enablebits = { {0x4a, 0x02, 0x02}, {0x4a, 0x04, 0x04} },
32074 diff --git a/drivers/ide/sl82c105.c b/drivers/ide/sl82c105.c
32075 index f21dc2a..d051cd2 100644
32076 --- a/drivers/ide/sl82c105.c
32077 +++ b/drivers/ide/sl82c105.c
32078 @@ -299,7 +299,7 @@ static const struct ide_dma_ops sl82c105_dma_ops = {
32079 .dma_sff_read_status = ide_dma_sff_read_status,
32080 };
32081
32082 -static const struct ide_port_info sl82c105_chipset __devinitdata = {
32083 +static const struct ide_port_info sl82c105_chipset __devinitconst = {
32084 .name = DRV_NAME,
32085 .init_chipset = init_chipset_sl82c105,
32086 .enablebits = {{0x40,0x01,0x01}, {0x40,0x10,0x10}},
32087 diff --git a/drivers/ide/slc90e66.c b/drivers/ide/slc90e66.c
32088 index 864ffe0..863a5e9 100644
32089 --- a/drivers/ide/slc90e66.c
32090 +++ b/drivers/ide/slc90e66.c
32091 @@ -132,7 +132,7 @@ static const struct ide_port_ops slc90e66_port_ops = {
32092 .cable_detect = slc90e66_cable_detect,
32093 };
32094
32095 -static const struct ide_port_info slc90e66_chipset __devinitdata = {
32096 +static const struct ide_port_info slc90e66_chipset __devinitconst = {
32097 .name = DRV_NAME,
32098 .enablebits = { {0x41, 0x80, 0x80}, {0x43, 0x80, 0x80} },
32099 .port_ops = &slc90e66_port_ops,
32100 diff --git a/drivers/ide/tc86c001.c b/drivers/ide/tc86c001.c
32101 index 4799d5c..1794678 100644
32102 --- a/drivers/ide/tc86c001.c
32103 +++ b/drivers/ide/tc86c001.c
32104 @@ -192,7 +192,7 @@ static const struct ide_dma_ops tc86c001_dma_ops = {
32105 .dma_sff_read_status = ide_dma_sff_read_status,
32106 };
32107
32108 -static const struct ide_port_info tc86c001_chipset __devinitdata = {
32109 +static const struct ide_port_info tc86c001_chipset __devinitconst = {
32110 .name = DRV_NAME,
32111 .init_hwif = init_hwif_tc86c001,
32112 .port_ops = &tc86c001_port_ops,
32113 diff --git a/drivers/ide/triflex.c b/drivers/ide/triflex.c
32114 index 281c914..55ce1b8 100644
32115 --- a/drivers/ide/triflex.c
32116 +++ b/drivers/ide/triflex.c
32117 @@ -92,7 +92,7 @@ static const struct ide_port_ops triflex_port_ops = {
32118 .set_dma_mode = triflex_set_mode,
32119 };
32120
32121 -static const struct ide_port_info triflex_device __devinitdata = {
32122 +static const struct ide_port_info triflex_device __devinitconst = {
32123 .name = DRV_NAME,
32124 .enablebits = {{0x80, 0x01, 0x01}, {0x80, 0x02, 0x02}},
32125 .port_ops = &triflex_port_ops,
32126 diff --git a/drivers/ide/trm290.c b/drivers/ide/trm290.c
32127 index 4b42ca0..e494a98 100644
32128 --- a/drivers/ide/trm290.c
32129 +++ b/drivers/ide/trm290.c
32130 @@ -324,7 +324,7 @@ static struct ide_dma_ops trm290_dma_ops = {
32131 .dma_check = trm290_dma_check,
32132 };
32133
32134 -static const struct ide_port_info trm290_chipset __devinitdata = {
32135 +static const struct ide_port_info trm290_chipset __devinitconst = {
32136 .name = DRV_NAME,
32137 .init_hwif = init_hwif_trm290,
32138 .tp_ops = &trm290_tp_ops,
32139 diff --git a/drivers/ide/via82cxxx.c b/drivers/ide/via82cxxx.c
32140 index f46f49c..eb77678 100644
32141 --- a/drivers/ide/via82cxxx.c
32142 +++ b/drivers/ide/via82cxxx.c
32143 @@ -403,7 +403,7 @@ static const struct ide_port_ops via_port_ops = {
32144 .cable_detect = via82cxxx_cable_detect,
32145 };
32146
32147 -static const struct ide_port_info via82cxxx_chipset __devinitdata = {
32148 +static const struct ide_port_info via82cxxx_chipset __devinitconst = {
32149 .name = DRV_NAME,
32150 .init_chipset = init_chipset_via82cxxx,
32151 .enablebits = { { 0x40, 0x02, 0x02 }, { 0x40, 0x01, 0x01 } },
32152 diff --git a/drivers/ieee802154/fakehard.c b/drivers/ieee802154/fakehard.c
32153 index 73d4531..c90cd2d 100644
32154 --- a/drivers/ieee802154/fakehard.c
32155 +++ b/drivers/ieee802154/fakehard.c
32156 @@ -386,7 +386,7 @@ static int __devinit ieee802154fake_probe(struct platform_device *pdev)
32157 phy->transmit_power = 0xbf;
32158
32159 dev->netdev_ops = &fake_ops;
32160 - dev->ml_priv = &fake_mlme;
32161 + dev->ml_priv = (void *)&fake_mlme;
32162
32163 priv = netdev_priv(dev);
32164 priv->phy = phy;
32165 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
32166 index c889aae..6cf5aa7 100644
32167 --- a/drivers/infiniband/core/cm.c
32168 +++ b/drivers/infiniband/core/cm.c
32169 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
32170
32171 struct cm_counter_group {
32172 struct kobject obj;
32173 - atomic_long_t counter[CM_ATTR_COUNT];
32174 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
32175 };
32176
32177 struct cm_counter_attribute {
32178 @@ -1394,7 +1394,7 @@ static void cm_dup_req_handler(struct cm_work *work,
32179 struct ib_mad_send_buf *msg = NULL;
32180 int ret;
32181
32182 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
32183 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
32184 counter[CM_REQ_COUNTER]);
32185
32186 /* Quick state check to discard duplicate REQs. */
32187 @@ -1778,7 +1778,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
32188 if (!cm_id_priv)
32189 return;
32190
32191 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
32192 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
32193 counter[CM_REP_COUNTER]);
32194 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
32195 if (ret)
32196 @@ -1945,7 +1945,7 @@ static int cm_rtu_handler(struct cm_work *work)
32197 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
32198 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
32199 spin_unlock_irq(&cm_id_priv->lock);
32200 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
32201 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
32202 counter[CM_RTU_COUNTER]);
32203 goto out;
32204 }
32205 @@ -2128,7 +2128,7 @@ static int cm_dreq_handler(struct cm_work *work)
32206 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
32207 dreq_msg->local_comm_id);
32208 if (!cm_id_priv) {
32209 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
32210 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
32211 counter[CM_DREQ_COUNTER]);
32212 cm_issue_drep(work->port, work->mad_recv_wc);
32213 return -EINVAL;
32214 @@ -2153,7 +2153,7 @@ static int cm_dreq_handler(struct cm_work *work)
32215 case IB_CM_MRA_REP_RCVD:
32216 break;
32217 case IB_CM_TIMEWAIT:
32218 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
32219 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
32220 counter[CM_DREQ_COUNTER]);
32221 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
32222 goto unlock;
32223 @@ -2167,7 +2167,7 @@ static int cm_dreq_handler(struct cm_work *work)
32224 cm_free_msg(msg);
32225 goto deref;
32226 case IB_CM_DREQ_RCVD:
32227 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
32228 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
32229 counter[CM_DREQ_COUNTER]);
32230 goto unlock;
32231 default:
32232 @@ -2534,7 +2534,7 @@ static int cm_mra_handler(struct cm_work *work)
32233 ib_modify_mad(cm_id_priv->av.port->mad_agent,
32234 cm_id_priv->msg, timeout)) {
32235 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
32236 - atomic_long_inc(&work->port->
32237 + atomic_long_inc_unchecked(&work->port->
32238 counter_group[CM_RECV_DUPLICATES].
32239 counter[CM_MRA_COUNTER]);
32240 goto out;
32241 @@ -2543,7 +2543,7 @@ static int cm_mra_handler(struct cm_work *work)
32242 break;
32243 case IB_CM_MRA_REQ_RCVD:
32244 case IB_CM_MRA_REP_RCVD:
32245 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
32246 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
32247 counter[CM_MRA_COUNTER]);
32248 /* fall through */
32249 default:
32250 @@ -2705,7 +2705,7 @@ static int cm_lap_handler(struct cm_work *work)
32251 case IB_CM_LAP_IDLE:
32252 break;
32253 case IB_CM_MRA_LAP_SENT:
32254 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
32255 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
32256 counter[CM_LAP_COUNTER]);
32257 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
32258 goto unlock;
32259 @@ -2721,7 +2721,7 @@ static int cm_lap_handler(struct cm_work *work)
32260 cm_free_msg(msg);
32261 goto deref;
32262 case IB_CM_LAP_RCVD:
32263 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
32264 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
32265 counter[CM_LAP_COUNTER]);
32266 goto unlock;
32267 default:
32268 @@ -3005,7 +3005,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
32269 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
32270 if (cur_cm_id_priv) {
32271 spin_unlock_irq(&cm.lock);
32272 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
32273 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
32274 counter[CM_SIDR_REQ_COUNTER]);
32275 goto out; /* Duplicate message. */
32276 }
32277 @@ -3217,10 +3217,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
32278 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
32279 msg->retries = 1;
32280
32281 - atomic_long_add(1 + msg->retries,
32282 + atomic_long_add_unchecked(1 + msg->retries,
32283 &port->counter_group[CM_XMIT].counter[attr_index]);
32284 if (msg->retries)
32285 - atomic_long_add(msg->retries,
32286 + atomic_long_add_unchecked(msg->retries,
32287 &port->counter_group[CM_XMIT_RETRIES].
32288 counter[attr_index]);
32289
32290 @@ -3430,7 +3430,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
32291 }
32292
32293 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
32294 - atomic_long_inc(&port->counter_group[CM_RECV].
32295 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
32296 counter[attr_id - CM_ATTR_ID_OFFSET]);
32297
32298 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
32299 @@ -3635,7 +3635,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
32300 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
32301
32302 return sprintf(buf, "%ld\n",
32303 - atomic_long_read(&group->counter[cm_attr->index]));
32304 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
32305 }
32306
32307 static const struct sysfs_ops cm_counter_ops = {
32308 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
32309 index 176c8f9..2627b62 100644
32310 --- a/drivers/infiniband/core/fmr_pool.c
32311 +++ b/drivers/infiniband/core/fmr_pool.c
32312 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
32313
32314 struct task_struct *thread;
32315
32316 - atomic_t req_ser;
32317 - atomic_t flush_ser;
32318 + atomic_unchecked_t req_ser;
32319 + atomic_unchecked_t flush_ser;
32320
32321 wait_queue_head_t force_wait;
32322 };
32323 @@ -180,10 +180,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
32324 struct ib_fmr_pool *pool = pool_ptr;
32325
32326 do {
32327 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
32328 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
32329 ib_fmr_batch_release(pool);
32330
32331 - atomic_inc(&pool->flush_ser);
32332 + atomic_inc_unchecked(&pool->flush_ser);
32333 wake_up_interruptible(&pool->force_wait);
32334
32335 if (pool->flush_function)
32336 @@ -191,7 +191,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
32337 }
32338
32339 set_current_state(TASK_INTERRUPTIBLE);
32340 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
32341 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
32342 !kthread_should_stop())
32343 schedule();
32344 __set_current_state(TASK_RUNNING);
32345 @@ -283,8 +283,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
32346 pool->dirty_watermark = params->dirty_watermark;
32347 pool->dirty_len = 0;
32348 spin_lock_init(&pool->pool_lock);
32349 - atomic_set(&pool->req_ser, 0);
32350 - atomic_set(&pool->flush_ser, 0);
32351 + atomic_set_unchecked(&pool->req_ser, 0);
32352 + atomic_set_unchecked(&pool->flush_ser, 0);
32353 init_waitqueue_head(&pool->force_wait);
32354
32355 pool->thread = kthread_run(ib_fmr_cleanup_thread,
32356 @@ -412,11 +412,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
32357 }
32358 spin_unlock_irq(&pool->pool_lock);
32359
32360 - serial = atomic_inc_return(&pool->req_ser);
32361 + serial = atomic_inc_return_unchecked(&pool->req_ser);
32362 wake_up_process(pool->thread);
32363
32364 if (wait_event_interruptible(pool->force_wait,
32365 - atomic_read(&pool->flush_ser) - serial >= 0))
32366 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
32367 return -EINTR;
32368
32369 return 0;
32370 @@ -526,7 +526,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
32371 } else {
32372 list_add_tail(&fmr->list, &pool->dirty_list);
32373 if (++pool->dirty_len >= pool->dirty_watermark) {
32374 - atomic_inc(&pool->req_ser);
32375 + atomic_inc_unchecked(&pool->req_ser);
32376 wake_up_process(pool->thread);
32377 }
32378 }
32379 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
32380 index 40c8353..946b0e4 100644
32381 --- a/drivers/infiniband/hw/cxgb4/mem.c
32382 +++ b/drivers/infiniband/hw/cxgb4/mem.c
32383 @@ -122,7 +122,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
32384 int err;
32385 struct fw_ri_tpte tpt;
32386 u32 stag_idx;
32387 - static atomic_t key;
32388 + static atomic_unchecked_t key;
32389
32390 if (c4iw_fatal_error(rdev))
32391 return -EIO;
32392 @@ -135,7 +135,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
32393 &rdev->resource.tpt_fifo_lock);
32394 if (!stag_idx)
32395 return -ENOMEM;
32396 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
32397 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
32398 }
32399 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
32400 __func__, stag_state, type, pdid, stag_idx);
32401 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
32402 index 79b3dbc..96e5fcc 100644
32403 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
32404 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
32405 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
32406 struct ib_atomic_eth *ateth;
32407 struct ipath_ack_entry *e;
32408 u64 vaddr;
32409 - atomic64_t *maddr;
32410 + atomic64_unchecked_t *maddr;
32411 u64 sdata;
32412 u32 rkey;
32413 u8 next;
32414 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
32415 IB_ACCESS_REMOTE_ATOMIC)))
32416 goto nack_acc_unlck;
32417 /* Perform atomic OP and save result. */
32418 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
32419 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
32420 sdata = be64_to_cpu(ateth->swap_data);
32421 e = &qp->s_ack_queue[qp->r_head_ack_queue];
32422 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
32423 - (u64) atomic64_add_return(sdata, maddr) - sdata :
32424 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
32425 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
32426 be64_to_cpu(ateth->compare_data),
32427 sdata);
32428 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
32429 index 1f95bba..9530f87 100644
32430 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
32431 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
32432 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
32433 unsigned long flags;
32434 struct ib_wc wc;
32435 u64 sdata;
32436 - atomic64_t *maddr;
32437 + atomic64_unchecked_t *maddr;
32438 enum ib_wc_status send_status;
32439
32440 /*
32441 @@ -382,11 +382,11 @@ again:
32442 IB_ACCESS_REMOTE_ATOMIC)))
32443 goto acc_err;
32444 /* Perform atomic OP and save result. */
32445 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
32446 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
32447 sdata = wqe->wr.wr.atomic.compare_add;
32448 *(u64 *) sqp->s_sge.sge.vaddr =
32449 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
32450 - (u64) atomic64_add_return(sdata, maddr) - sdata :
32451 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
32452 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
32453 sdata, wqe->wr.wr.atomic.swap);
32454 goto send_comp;
32455 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
32456 index 7140199..da60063 100644
32457 --- a/drivers/infiniband/hw/nes/nes.c
32458 +++ b/drivers/infiniband/hw/nes/nes.c
32459 @@ -103,7 +103,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
32460 LIST_HEAD(nes_adapter_list);
32461 static LIST_HEAD(nes_dev_list);
32462
32463 -atomic_t qps_destroyed;
32464 +atomic_unchecked_t qps_destroyed;
32465
32466 static unsigned int ee_flsh_adapter;
32467 static unsigned int sysfs_nonidx_addr;
32468 @@ -272,7 +272,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
32469 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
32470 struct nes_adapter *nesadapter = nesdev->nesadapter;
32471
32472 - atomic_inc(&qps_destroyed);
32473 + atomic_inc_unchecked(&qps_destroyed);
32474
32475 /* Free the control structures */
32476
32477 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
32478 index c438e46..ca30356 100644
32479 --- a/drivers/infiniband/hw/nes/nes.h
32480 +++ b/drivers/infiniband/hw/nes/nes.h
32481 @@ -178,17 +178,17 @@ extern unsigned int nes_debug_level;
32482 extern unsigned int wqm_quanta;
32483 extern struct list_head nes_adapter_list;
32484
32485 -extern atomic_t cm_connects;
32486 -extern atomic_t cm_accepts;
32487 -extern atomic_t cm_disconnects;
32488 -extern atomic_t cm_closes;
32489 -extern atomic_t cm_connecteds;
32490 -extern atomic_t cm_connect_reqs;
32491 -extern atomic_t cm_rejects;
32492 -extern atomic_t mod_qp_timouts;
32493 -extern atomic_t qps_created;
32494 -extern atomic_t qps_destroyed;
32495 -extern atomic_t sw_qps_destroyed;
32496 +extern atomic_unchecked_t cm_connects;
32497 +extern atomic_unchecked_t cm_accepts;
32498 +extern atomic_unchecked_t cm_disconnects;
32499 +extern atomic_unchecked_t cm_closes;
32500 +extern atomic_unchecked_t cm_connecteds;
32501 +extern atomic_unchecked_t cm_connect_reqs;
32502 +extern atomic_unchecked_t cm_rejects;
32503 +extern atomic_unchecked_t mod_qp_timouts;
32504 +extern atomic_unchecked_t qps_created;
32505 +extern atomic_unchecked_t qps_destroyed;
32506 +extern atomic_unchecked_t sw_qps_destroyed;
32507 extern u32 mh_detected;
32508 extern u32 mh_pauses_sent;
32509 extern u32 cm_packets_sent;
32510 @@ -197,16 +197,16 @@ extern u32 cm_packets_created;
32511 extern u32 cm_packets_received;
32512 extern u32 cm_packets_dropped;
32513 extern u32 cm_packets_retrans;
32514 -extern atomic_t cm_listens_created;
32515 -extern atomic_t cm_listens_destroyed;
32516 +extern atomic_unchecked_t cm_listens_created;
32517 +extern atomic_unchecked_t cm_listens_destroyed;
32518 extern u32 cm_backlog_drops;
32519 -extern atomic_t cm_loopbacks;
32520 -extern atomic_t cm_nodes_created;
32521 -extern atomic_t cm_nodes_destroyed;
32522 -extern atomic_t cm_accel_dropped_pkts;
32523 -extern atomic_t cm_resets_recvd;
32524 -extern atomic_t pau_qps_created;
32525 -extern atomic_t pau_qps_destroyed;
32526 +extern atomic_unchecked_t cm_loopbacks;
32527 +extern atomic_unchecked_t cm_nodes_created;
32528 +extern atomic_unchecked_t cm_nodes_destroyed;
32529 +extern atomic_unchecked_t cm_accel_dropped_pkts;
32530 +extern atomic_unchecked_t cm_resets_recvd;
32531 +extern atomic_unchecked_t pau_qps_created;
32532 +extern atomic_unchecked_t pau_qps_destroyed;
32533
32534 extern u32 int_mod_timer_init;
32535 extern u32 int_mod_cq_depth_256;
32536 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
32537 index a4972ab..1bcfc31 100644
32538 --- a/drivers/infiniband/hw/nes/nes_cm.c
32539 +++ b/drivers/infiniband/hw/nes/nes_cm.c
32540 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
32541 u32 cm_packets_retrans;
32542 u32 cm_packets_created;
32543 u32 cm_packets_received;
32544 -atomic_t cm_listens_created;
32545 -atomic_t cm_listens_destroyed;
32546 +atomic_unchecked_t cm_listens_created;
32547 +atomic_unchecked_t cm_listens_destroyed;
32548 u32 cm_backlog_drops;
32549 -atomic_t cm_loopbacks;
32550 -atomic_t cm_nodes_created;
32551 -atomic_t cm_nodes_destroyed;
32552 -atomic_t cm_accel_dropped_pkts;
32553 -atomic_t cm_resets_recvd;
32554 +atomic_unchecked_t cm_loopbacks;
32555 +atomic_unchecked_t cm_nodes_created;
32556 +atomic_unchecked_t cm_nodes_destroyed;
32557 +atomic_unchecked_t cm_accel_dropped_pkts;
32558 +atomic_unchecked_t cm_resets_recvd;
32559
32560 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
32561 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
32562 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
32563
32564 static struct nes_cm_core *g_cm_core;
32565
32566 -atomic_t cm_connects;
32567 -atomic_t cm_accepts;
32568 -atomic_t cm_disconnects;
32569 -atomic_t cm_closes;
32570 -atomic_t cm_connecteds;
32571 -atomic_t cm_connect_reqs;
32572 -atomic_t cm_rejects;
32573 +atomic_unchecked_t cm_connects;
32574 +atomic_unchecked_t cm_accepts;
32575 +atomic_unchecked_t cm_disconnects;
32576 +atomic_unchecked_t cm_closes;
32577 +atomic_unchecked_t cm_connecteds;
32578 +atomic_unchecked_t cm_connect_reqs;
32579 +atomic_unchecked_t cm_rejects;
32580
32581 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
32582 {
32583 @@ -1274,7 +1274,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
32584 kfree(listener);
32585 listener = NULL;
32586 ret = 0;
32587 - atomic_inc(&cm_listens_destroyed);
32588 + atomic_inc_unchecked(&cm_listens_destroyed);
32589 } else {
32590 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
32591 }
32592 @@ -1473,7 +1473,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
32593 cm_node->rem_mac);
32594
32595 add_hte_node(cm_core, cm_node);
32596 - atomic_inc(&cm_nodes_created);
32597 + atomic_inc_unchecked(&cm_nodes_created);
32598
32599 return cm_node;
32600 }
32601 @@ -1531,7 +1531,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
32602 }
32603
32604 atomic_dec(&cm_core->node_cnt);
32605 - atomic_inc(&cm_nodes_destroyed);
32606 + atomic_inc_unchecked(&cm_nodes_destroyed);
32607 nesqp = cm_node->nesqp;
32608 if (nesqp) {
32609 nesqp->cm_node = NULL;
32610 @@ -1595,7 +1595,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
32611
32612 static void drop_packet(struct sk_buff *skb)
32613 {
32614 - atomic_inc(&cm_accel_dropped_pkts);
32615 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
32616 dev_kfree_skb_any(skb);
32617 }
32618
32619 @@ -1658,7 +1658,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
32620 {
32621
32622 int reset = 0; /* whether to send reset in case of err.. */
32623 - atomic_inc(&cm_resets_recvd);
32624 + atomic_inc_unchecked(&cm_resets_recvd);
32625 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
32626 " refcnt=%d\n", cm_node, cm_node->state,
32627 atomic_read(&cm_node->ref_count));
32628 @@ -2299,7 +2299,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
32629 rem_ref_cm_node(cm_node->cm_core, cm_node);
32630 return NULL;
32631 }
32632 - atomic_inc(&cm_loopbacks);
32633 + atomic_inc_unchecked(&cm_loopbacks);
32634 loopbackremotenode->loopbackpartner = cm_node;
32635 loopbackremotenode->tcp_cntxt.rcv_wscale =
32636 NES_CM_DEFAULT_RCV_WND_SCALE;
32637 @@ -2574,7 +2574,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
32638 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
32639 else {
32640 rem_ref_cm_node(cm_core, cm_node);
32641 - atomic_inc(&cm_accel_dropped_pkts);
32642 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
32643 dev_kfree_skb_any(skb);
32644 }
32645 break;
32646 @@ -2881,7 +2881,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
32647
32648 if ((cm_id) && (cm_id->event_handler)) {
32649 if (issue_disconn) {
32650 - atomic_inc(&cm_disconnects);
32651 + atomic_inc_unchecked(&cm_disconnects);
32652 cm_event.event = IW_CM_EVENT_DISCONNECT;
32653 cm_event.status = disconn_status;
32654 cm_event.local_addr = cm_id->local_addr;
32655 @@ -2903,7 +2903,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
32656 }
32657
32658 if (issue_close) {
32659 - atomic_inc(&cm_closes);
32660 + atomic_inc_unchecked(&cm_closes);
32661 nes_disconnect(nesqp, 1);
32662
32663 cm_id->provider_data = nesqp;
32664 @@ -3039,7 +3039,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
32665
32666 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
32667 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
32668 - atomic_inc(&cm_accepts);
32669 + atomic_inc_unchecked(&cm_accepts);
32670
32671 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
32672 netdev_refcnt_read(nesvnic->netdev));
32673 @@ -3241,7 +3241,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
32674 struct nes_cm_core *cm_core;
32675 u8 *start_buff;
32676
32677 - atomic_inc(&cm_rejects);
32678 + atomic_inc_unchecked(&cm_rejects);
32679 cm_node = (struct nes_cm_node *)cm_id->provider_data;
32680 loopback = cm_node->loopbackpartner;
32681 cm_core = cm_node->cm_core;
32682 @@ -3301,7 +3301,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
32683 ntohl(cm_id->local_addr.sin_addr.s_addr),
32684 ntohs(cm_id->local_addr.sin_port));
32685
32686 - atomic_inc(&cm_connects);
32687 + atomic_inc_unchecked(&cm_connects);
32688 nesqp->active_conn = 1;
32689
32690 /* cache the cm_id in the qp */
32691 @@ -3407,7 +3407,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
32692 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
32693 return err;
32694 }
32695 - atomic_inc(&cm_listens_created);
32696 + atomic_inc_unchecked(&cm_listens_created);
32697 }
32698
32699 cm_id->add_ref(cm_id);
32700 @@ -3508,7 +3508,7 @@ static void cm_event_connected(struct nes_cm_event *event)
32701
32702 if (nesqp->destroyed)
32703 return;
32704 - atomic_inc(&cm_connecteds);
32705 + atomic_inc_unchecked(&cm_connecteds);
32706 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
32707 " local port 0x%04X. jiffies = %lu.\n",
32708 nesqp->hwqp.qp_id,
32709 @@ -3695,7 +3695,7 @@ static void cm_event_reset(struct nes_cm_event *event)
32710
32711 cm_id->add_ref(cm_id);
32712 ret = cm_id->event_handler(cm_id, &cm_event);
32713 - atomic_inc(&cm_closes);
32714 + atomic_inc_unchecked(&cm_closes);
32715 cm_event.event = IW_CM_EVENT_CLOSE;
32716 cm_event.status = 0;
32717 cm_event.provider_data = cm_id->provider_data;
32718 @@ -3731,7 +3731,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
32719 return;
32720 cm_id = cm_node->cm_id;
32721
32722 - atomic_inc(&cm_connect_reqs);
32723 + atomic_inc_unchecked(&cm_connect_reqs);
32724 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
32725 cm_node, cm_id, jiffies);
32726
32727 @@ -3771,7 +3771,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
32728 return;
32729 cm_id = cm_node->cm_id;
32730
32731 - atomic_inc(&cm_connect_reqs);
32732 + atomic_inc_unchecked(&cm_connect_reqs);
32733 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
32734 cm_node, cm_id, jiffies);
32735
32736 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
32737 index 3ba7be3..c81f6ff 100644
32738 --- a/drivers/infiniband/hw/nes/nes_mgt.c
32739 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
32740 @@ -40,8 +40,8 @@
32741 #include "nes.h"
32742 #include "nes_mgt.h"
32743
32744 -atomic_t pau_qps_created;
32745 -atomic_t pau_qps_destroyed;
32746 +atomic_unchecked_t pau_qps_created;
32747 +atomic_unchecked_t pau_qps_destroyed;
32748
32749 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
32750 {
32751 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
32752 {
32753 struct sk_buff *skb;
32754 unsigned long flags;
32755 - atomic_inc(&pau_qps_destroyed);
32756 + atomic_inc_unchecked(&pau_qps_destroyed);
32757
32758 /* Free packets that have not yet been forwarded */
32759 /* Lock is acquired by skb_dequeue when removing the skb */
32760 @@ -812,7 +812,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
32761 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
32762 skb_queue_head_init(&nesqp->pau_list);
32763 spin_lock_init(&nesqp->pau_lock);
32764 - atomic_inc(&pau_qps_created);
32765 + atomic_inc_unchecked(&pau_qps_created);
32766 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
32767 }
32768
32769 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
32770 index f3a3ecf..57d311d 100644
32771 --- a/drivers/infiniband/hw/nes/nes_nic.c
32772 +++ b/drivers/infiniband/hw/nes/nes_nic.c
32773 @@ -1277,39 +1277,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
32774 target_stat_values[++index] = mh_detected;
32775 target_stat_values[++index] = mh_pauses_sent;
32776 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
32777 - target_stat_values[++index] = atomic_read(&cm_connects);
32778 - target_stat_values[++index] = atomic_read(&cm_accepts);
32779 - target_stat_values[++index] = atomic_read(&cm_disconnects);
32780 - target_stat_values[++index] = atomic_read(&cm_connecteds);
32781 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
32782 - target_stat_values[++index] = atomic_read(&cm_rejects);
32783 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
32784 - target_stat_values[++index] = atomic_read(&qps_created);
32785 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
32786 - target_stat_values[++index] = atomic_read(&qps_destroyed);
32787 - target_stat_values[++index] = atomic_read(&cm_closes);
32788 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
32789 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
32790 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
32791 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
32792 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
32793 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
32794 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
32795 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
32796 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
32797 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
32798 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
32799 target_stat_values[++index] = cm_packets_sent;
32800 target_stat_values[++index] = cm_packets_bounced;
32801 target_stat_values[++index] = cm_packets_created;
32802 target_stat_values[++index] = cm_packets_received;
32803 target_stat_values[++index] = cm_packets_dropped;
32804 target_stat_values[++index] = cm_packets_retrans;
32805 - target_stat_values[++index] = atomic_read(&cm_listens_created);
32806 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
32807 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
32808 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
32809 target_stat_values[++index] = cm_backlog_drops;
32810 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
32811 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
32812 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
32813 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
32814 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
32815 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
32816 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
32817 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
32818 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
32819 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
32820 target_stat_values[++index] = nesadapter->free_4kpbl;
32821 target_stat_values[++index] = nesadapter->free_256pbl;
32822 target_stat_values[++index] = int_mod_timer_init;
32823 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
32824 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
32825 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
32826 - target_stat_values[++index] = atomic_read(&pau_qps_created);
32827 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
32828 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
32829 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
32830 }
32831
32832 /**
32833 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
32834 index 0927b5c..ed67986 100644
32835 --- a/drivers/infiniband/hw/nes/nes_verbs.c
32836 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
32837 @@ -46,9 +46,9 @@
32838
32839 #include <rdma/ib_umem.h>
32840
32841 -atomic_t mod_qp_timouts;
32842 -atomic_t qps_created;
32843 -atomic_t sw_qps_destroyed;
32844 +atomic_unchecked_t mod_qp_timouts;
32845 +atomic_unchecked_t qps_created;
32846 +atomic_unchecked_t sw_qps_destroyed;
32847
32848 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
32849
32850 @@ -1131,7 +1131,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
32851 if (init_attr->create_flags)
32852 return ERR_PTR(-EINVAL);
32853
32854 - atomic_inc(&qps_created);
32855 + atomic_inc_unchecked(&qps_created);
32856 switch (init_attr->qp_type) {
32857 case IB_QPT_RC:
32858 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
32859 @@ -1460,7 +1460,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
32860 struct iw_cm_event cm_event;
32861 int ret = 0;
32862
32863 - atomic_inc(&sw_qps_destroyed);
32864 + atomic_inc_unchecked(&sw_qps_destroyed);
32865 nesqp->destroyed = 1;
32866
32867 /* Blow away the connection if it exists. */
32868 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
32869 index b881bdc..c2e360c 100644
32870 --- a/drivers/infiniband/hw/qib/qib.h
32871 +++ b/drivers/infiniband/hw/qib/qib.h
32872 @@ -51,6 +51,7 @@
32873 #include <linux/completion.h>
32874 #include <linux/kref.h>
32875 #include <linux/sched.h>
32876 +#include <linux/slab.h>
32877
32878 #include "qib_common.h"
32879 #include "qib_verbs.h"
32880 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
32881 index c351aa4..e6967c2 100644
32882 --- a/drivers/input/gameport/gameport.c
32883 +++ b/drivers/input/gameport/gameport.c
32884 @@ -488,14 +488,14 @@ EXPORT_SYMBOL(gameport_set_phys);
32885 */
32886 static void gameport_init_port(struct gameport *gameport)
32887 {
32888 - static atomic_t gameport_no = ATOMIC_INIT(0);
32889 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
32890
32891 __module_get(THIS_MODULE);
32892
32893 mutex_init(&gameport->drv_mutex);
32894 device_initialize(&gameport->dev);
32895 dev_set_name(&gameport->dev, "gameport%lu",
32896 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
32897 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
32898 gameport->dev.bus = &gameport_bus;
32899 gameport->dev.release = gameport_release_port;
32900 if (gameport->parent)
32901 diff --git a/drivers/input/input.c b/drivers/input/input.c
32902 index 1f78c95..3cddc6c 100644
32903 --- a/drivers/input/input.c
32904 +++ b/drivers/input/input.c
32905 @@ -1814,7 +1814,7 @@ static void input_cleanse_bitmasks(struct input_dev *dev)
32906 */
32907 int input_register_device(struct input_dev *dev)
32908 {
32909 - static atomic_t input_no = ATOMIC_INIT(0);
32910 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
32911 struct input_handler *handler;
32912 const char *path;
32913 int error;
32914 @@ -1851,7 +1851,7 @@ int input_register_device(struct input_dev *dev)
32915 dev->setkeycode = input_default_setkeycode;
32916
32917 dev_set_name(&dev->dev, "input%ld",
32918 - (unsigned long) atomic_inc_return(&input_no) - 1);
32919 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
32920
32921 error = device_add(&dev->dev);
32922 if (error)
32923 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
32924 index b8d8611..7a4a04b 100644
32925 --- a/drivers/input/joystick/sidewinder.c
32926 +++ b/drivers/input/joystick/sidewinder.c
32927 @@ -30,6 +30,7 @@
32928 #include <linux/kernel.h>
32929 #include <linux/module.h>
32930 #include <linux/slab.h>
32931 +#include <linux/sched.h>
32932 #include <linux/init.h>
32933 #include <linux/input.h>
32934 #include <linux/gameport.h>
32935 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
32936 index fd7a0d5..a4af10c 100644
32937 --- a/drivers/input/joystick/xpad.c
32938 +++ b/drivers/input/joystick/xpad.c
32939 @@ -710,7 +710,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
32940
32941 static int xpad_led_probe(struct usb_xpad *xpad)
32942 {
32943 - static atomic_t led_seq = ATOMIC_INIT(0);
32944 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
32945 long led_no;
32946 struct xpad_led *led;
32947 struct led_classdev *led_cdev;
32948 @@ -723,7 +723,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
32949 if (!led)
32950 return -ENOMEM;
32951
32952 - led_no = (long)atomic_inc_return(&led_seq) - 1;
32953 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
32954
32955 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
32956 led->xpad = xpad;
32957 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
32958 index 0110b5a..d3ad144 100644
32959 --- a/drivers/input/mousedev.c
32960 +++ b/drivers/input/mousedev.c
32961 @@ -763,7 +763,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
32962
32963 spin_unlock_irq(&client->packet_lock);
32964
32965 - if (copy_to_user(buffer, data, count))
32966 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
32967 return -EFAULT;
32968
32969 return count;
32970 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
32971 index ba70058..571d25d 100644
32972 --- a/drivers/input/serio/serio.c
32973 +++ b/drivers/input/serio/serio.c
32974 @@ -497,7 +497,7 @@ static void serio_release_port(struct device *dev)
32975 */
32976 static void serio_init_port(struct serio *serio)
32977 {
32978 - static atomic_t serio_no = ATOMIC_INIT(0);
32979 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
32980
32981 __module_get(THIS_MODULE);
32982
32983 @@ -508,7 +508,7 @@ static void serio_init_port(struct serio *serio)
32984 mutex_init(&serio->drv_mutex);
32985 device_initialize(&serio->dev);
32986 dev_set_name(&serio->dev, "serio%ld",
32987 - (long)atomic_inc_return(&serio_no) - 1);
32988 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
32989 serio->dev.bus = &serio_bus;
32990 serio->dev.release = serio_release_port;
32991 serio->dev.groups = serio_device_attr_groups;
32992 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
32993 index e44933d..9ba484a 100644
32994 --- a/drivers/isdn/capi/capi.c
32995 +++ b/drivers/isdn/capi/capi.c
32996 @@ -83,8 +83,8 @@ struct capiminor {
32997
32998 struct capi20_appl *ap;
32999 u32 ncci;
33000 - atomic_t datahandle;
33001 - atomic_t msgid;
33002 + atomic_unchecked_t datahandle;
33003 + atomic_unchecked_t msgid;
33004
33005 struct tty_port port;
33006 int ttyinstop;
33007 @@ -397,7 +397,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
33008 capimsg_setu16(s, 2, mp->ap->applid);
33009 capimsg_setu8 (s, 4, CAPI_DATA_B3);
33010 capimsg_setu8 (s, 5, CAPI_RESP);
33011 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
33012 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
33013 capimsg_setu32(s, 8, mp->ncci);
33014 capimsg_setu16(s, 12, datahandle);
33015 }
33016 @@ -518,14 +518,14 @@ static void handle_minor_send(struct capiminor *mp)
33017 mp->outbytes -= len;
33018 spin_unlock_bh(&mp->outlock);
33019
33020 - datahandle = atomic_inc_return(&mp->datahandle);
33021 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
33022 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
33023 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
33024 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
33025 capimsg_setu16(skb->data, 2, mp->ap->applid);
33026 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
33027 capimsg_setu8 (skb->data, 5, CAPI_REQ);
33028 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
33029 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
33030 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
33031 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
33032 capimsg_setu16(skb->data, 16, len); /* Data length */
33033 diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c
33034 index db621db..825ea1a 100644
33035 --- a/drivers/isdn/gigaset/common.c
33036 +++ b/drivers/isdn/gigaset/common.c
33037 @@ -723,7 +723,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
33038 cs->commands_pending = 0;
33039 cs->cur_at_seq = 0;
33040 cs->gotfwver = -1;
33041 - cs->open_count = 0;
33042 + local_set(&cs->open_count, 0);
33043 cs->dev = NULL;
33044 cs->tty = NULL;
33045 cs->tty_dev = NULL;
33046 diff --git a/drivers/isdn/gigaset/gigaset.h b/drivers/isdn/gigaset/gigaset.h
33047 index 212efaf..f187c6b 100644
33048 --- a/drivers/isdn/gigaset/gigaset.h
33049 +++ b/drivers/isdn/gigaset/gigaset.h
33050 @@ -35,6 +35,7 @@
33051 #include <linux/tty_driver.h>
33052 #include <linux/list.h>
33053 #include <linux/atomic.h>
33054 +#include <asm/local.h>
33055
33056 #define GIG_VERSION {0, 5, 0, 0}
33057 #define GIG_COMPAT {0, 4, 0, 0}
33058 @@ -433,7 +434,7 @@ struct cardstate {
33059 spinlock_t cmdlock;
33060 unsigned curlen, cmdbytes;
33061
33062 - unsigned open_count;
33063 + local_t open_count;
33064 struct tty_struct *tty;
33065 struct tasklet_struct if_wake_tasklet;
33066 unsigned control_state;
33067 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
33068 index ee0a549..a7c9798 100644
33069 --- a/drivers/isdn/gigaset/interface.c
33070 +++ b/drivers/isdn/gigaset/interface.c
33071 @@ -163,9 +163,7 @@ static int if_open(struct tty_struct *tty, struct file *filp)
33072 }
33073 tty->driver_data = cs;
33074
33075 - ++cs->open_count;
33076 -
33077 - if (cs->open_count == 1) {
33078 + if (local_inc_return(&cs->open_count) == 1) {
33079 spin_lock_irqsave(&cs->lock, flags);
33080 cs->tty = tty;
33081 spin_unlock_irqrestore(&cs->lock, flags);
33082 @@ -193,10 +191,10 @@ static void if_close(struct tty_struct *tty, struct file *filp)
33083
33084 if (!cs->connected)
33085 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
33086 - else if (!cs->open_count)
33087 + else if (!local_read(&cs->open_count))
33088 dev_warn(cs->dev, "%s: device not opened\n", __func__);
33089 else {
33090 - if (!--cs->open_count) {
33091 + if (!local_dec_return(&cs->open_count)) {
33092 spin_lock_irqsave(&cs->lock, flags);
33093 cs->tty = NULL;
33094 spin_unlock_irqrestore(&cs->lock, flags);
33095 @@ -231,7 +229,7 @@ static int if_ioctl(struct tty_struct *tty,
33096 if (!cs->connected) {
33097 gig_dbg(DEBUG_IF, "not connected");
33098 retval = -ENODEV;
33099 - } else if (!cs->open_count)
33100 + } else if (!local_read(&cs->open_count))
33101 dev_warn(cs->dev, "%s: device not opened\n", __func__);
33102 else {
33103 retval = 0;
33104 @@ -361,7 +359,7 @@ static int if_write(struct tty_struct *tty, const unsigned char *buf, int count)
33105 retval = -ENODEV;
33106 goto done;
33107 }
33108 - if (!cs->open_count) {
33109 + if (!local_read(&cs->open_count)) {
33110 dev_warn(cs->dev, "%s: device not opened\n", __func__);
33111 retval = -ENODEV;
33112 goto done;
33113 @@ -414,7 +412,7 @@ static int if_write_room(struct tty_struct *tty)
33114 if (!cs->connected) {
33115 gig_dbg(DEBUG_IF, "not connected");
33116 retval = -ENODEV;
33117 - } else if (!cs->open_count)
33118 + } else if (!local_read(&cs->open_count))
33119 dev_warn(cs->dev, "%s: device not opened\n", __func__);
33120 else if (cs->mstate != MS_LOCKED) {
33121 dev_warn(cs->dev, "can't write to unlocked device\n");
33122 @@ -444,7 +442,7 @@ static int if_chars_in_buffer(struct tty_struct *tty)
33123
33124 if (!cs->connected)
33125 gig_dbg(DEBUG_IF, "not connected");
33126 - else if (!cs->open_count)
33127 + else if (!local_read(&cs->open_count))
33128 dev_warn(cs->dev, "%s: device not opened\n", __func__);
33129 else if (cs->mstate != MS_LOCKED)
33130 dev_warn(cs->dev, "can't write to unlocked device\n");
33131 @@ -472,7 +470,7 @@ static void if_throttle(struct tty_struct *tty)
33132
33133 if (!cs->connected)
33134 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
33135 - else if (!cs->open_count)
33136 + else if (!local_read(&cs->open_count))
33137 dev_warn(cs->dev, "%s: device not opened\n", __func__);
33138 else
33139 gig_dbg(DEBUG_IF, "%s: not implemented\n", __func__);
33140 @@ -496,7 +494,7 @@ static void if_unthrottle(struct tty_struct *tty)
33141
33142 if (!cs->connected)
33143 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
33144 - else if (!cs->open_count)
33145 + else if (!local_read(&cs->open_count))
33146 dev_warn(cs->dev, "%s: device not opened\n", __func__);
33147 else
33148 gig_dbg(DEBUG_IF, "%s: not implemented\n", __func__);
33149 @@ -527,7 +525,7 @@ static void if_set_termios(struct tty_struct *tty, struct ktermios *old)
33150 goto out;
33151 }
33152
33153 - if (!cs->open_count) {
33154 + if (!local_read(&cs->open_count)) {
33155 dev_warn(cs->dev, "%s: device not opened\n", __func__);
33156 goto out;
33157 }
33158 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
33159 index 2a57da59..e7a12ed 100644
33160 --- a/drivers/isdn/hardware/avm/b1.c
33161 +++ b/drivers/isdn/hardware/avm/b1.c
33162 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart * t4file)
33163 }
33164 if (left) {
33165 if (t4file->user) {
33166 - if (copy_from_user(buf, dp, left))
33167 + if (left > sizeof buf || copy_from_user(buf, dp, left))
33168 return -EFAULT;
33169 } else {
33170 memcpy(buf, dp, left);
33171 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart * config)
33172 }
33173 if (left) {
33174 if (config->user) {
33175 - if (copy_from_user(buf, dp, left))
33176 + if (left > sizeof buf || copy_from_user(buf, dp, left))
33177 return -EFAULT;
33178 } else {
33179 memcpy(buf, dp, left);
33180 diff --git a/drivers/isdn/hardware/eicon/divasync.h b/drivers/isdn/hardware/eicon/divasync.h
33181 index 85784a7..a19ca98 100644
33182 --- a/drivers/isdn/hardware/eicon/divasync.h
33183 +++ b/drivers/isdn/hardware/eicon/divasync.h
33184 @@ -146,7 +146,7 @@ typedef struct _diva_didd_add_adapter {
33185 } diva_didd_add_adapter_t;
33186 typedef struct _diva_didd_remove_adapter {
33187 IDI_CALL p_request;
33188 -} diva_didd_remove_adapter_t;
33189 +} __no_const diva_didd_remove_adapter_t;
33190 typedef struct _diva_didd_read_adapter_array {
33191 void * buffer;
33192 dword length;
33193 diff --git a/drivers/isdn/hardware/eicon/xdi_adapter.h b/drivers/isdn/hardware/eicon/xdi_adapter.h
33194 index a3bd163..8956575 100644
33195 --- a/drivers/isdn/hardware/eicon/xdi_adapter.h
33196 +++ b/drivers/isdn/hardware/eicon/xdi_adapter.h
33197 @@ -44,7 +44,7 @@ typedef struct _xdi_mbox_t {
33198 typedef struct _diva_os_idi_adapter_interface {
33199 diva_init_card_proc_t cleanup_adapter_proc;
33200 diva_cmd_card_proc_t cmd_proc;
33201 -} diva_os_idi_adapter_interface_t;
33202 +} __no_const diva_os_idi_adapter_interface_t;
33203
33204 typedef struct _diva_os_xdi_adapter {
33205 struct list_head link;
33206 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
33207 index 1f355bb..43f1fea 100644
33208 --- a/drivers/isdn/icn/icn.c
33209 +++ b/drivers/isdn/icn/icn.c
33210 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char * buf, int len, int user, icn_card * card)
33211 if (count > len)
33212 count = len;
33213 if (user) {
33214 - if (copy_from_user(msg, buf, count))
33215 + if (count > sizeof msg || copy_from_user(msg, buf, count))
33216 return -EFAULT;
33217 } else
33218 memcpy(msg, buf, count);
33219 diff --git a/drivers/leds/leds-mc13783.c b/drivers/leds/leds-mc13783.c
33220 index 8bc4915..4cc6a2e 100644
33221 --- a/drivers/leds/leds-mc13783.c
33222 +++ b/drivers/leds/leds-mc13783.c
33223 @@ -280,7 +280,7 @@ static int __devinit mc13783_led_probe(struct platform_device *pdev)
33224 return -EINVAL;
33225 }
33226
33227 - led = kzalloc(sizeof(*led) * pdata->num_leds, GFP_KERNEL);
33228 + led = kcalloc(pdata->num_leds, sizeof(*led), GFP_KERNEL);
33229 if (led == NULL) {
33230 dev_err(&pdev->dev, "failed to alloc memory\n");
33231 return -ENOMEM;
33232 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
33233 index b5fdcb7..5b6c59f 100644
33234 --- a/drivers/lguest/core.c
33235 +++ b/drivers/lguest/core.c
33236 @@ -92,9 +92,17 @@ static __init int map_switcher(void)
33237 * it's worked so far. The end address needs +1 because __get_vm_area
33238 * allocates an extra guard page, so we need space for that.
33239 */
33240 +
33241 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
33242 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
33243 + VM_ALLOC | VM_KERNEXEC, SWITCHER_ADDR, SWITCHER_ADDR
33244 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
33245 +#else
33246 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
33247 VM_ALLOC, SWITCHER_ADDR, SWITCHER_ADDR
33248 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
33249 +#endif
33250 +
33251 if (!switcher_vma) {
33252 err = -ENOMEM;
33253 printk("lguest: could not map switcher pages high\n");
33254 @@ -119,7 +127,7 @@ static __init int map_switcher(void)
33255 * Now the Switcher is mapped at the right address, we can't fail!
33256 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
33257 */
33258 - memcpy(switcher_vma->addr, start_switcher_text,
33259 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
33260 end_switcher_text - start_switcher_text);
33261
33262 printk(KERN_INFO "lguest: mapped switcher at %p\n",
33263 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
33264 index 3980903..ce25c5e 100644
33265 --- a/drivers/lguest/x86/core.c
33266 +++ b/drivers/lguest/x86/core.c
33267 @@ -59,7 +59,7 @@ static struct {
33268 /* Offset from where switcher.S was compiled to where we've copied it */
33269 static unsigned long switcher_offset(void)
33270 {
33271 - return SWITCHER_ADDR - (unsigned long)start_switcher_text;
33272 + return SWITCHER_ADDR - (unsigned long)ktla_ktva(start_switcher_text);
33273 }
33274
33275 /* This cpu's struct lguest_pages. */
33276 @@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
33277 * These copies are pretty cheap, so we do them unconditionally: */
33278 /* Save the current Host top-level page directory.
33279 */
33280 +
33281 +#ifdef CONFIG_PAX_PER_CPU_PGD
33282 + pages->state.host_cr3 = read_cr3();
33283 +#else
33284 pages->state.host_cr3 = __pa(current->mm->pgd);
33285 +#endif
33286 +
33287 /*
33288 * Set up the Guest's page tables to see this CPU's pages (and no
33289 * other CPU's pages).
33290 @@ -472,7 +478,7 @@ void __init lguest_arch_host_init(void)
33291 * compiled-in switcher code and the high-mapped copy we just made.
33292 */
33293 for (i = 0; i < IDT_ENTRIES; i++)
33294 - default_idt_entries[i] += switcher_offset();
33295 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
33296
33297 /*
33298 * Set up the Switcher's per-cpu areas.
33299 @@ -555,7 +561,7 @@ void __init lguest_arch_host_init(void)
33300 * it will be undisturbed when we switch. To change %cs and jump we
33301 * need this structure to feed to Intel's "lcall" instruction.
33302 */
33303 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
33304 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
33305 lguest_entry.segment = LGUEST_CS;
33306
33307 /*
33308 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
33309 index 40634b0..4f5855e 100644
33310 --- a/drivers/lguest/x86/switcher_32.S
33311 +++ b/drivers/lguest/x86/switcher_32.S
33312 @@ -87,6 +87,7 @@
33313 #include <asm/page.h>
33314 #include <asm/segment.h>
33315 #include <asm/lguest.h>
33316 +#include <asm/processor-flags.h>
33317
33318 // We mark the start of the code to copy
33319 // It's placed in .text tho it's never run here
33320 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
33321 // Changes type when we load it: damn Intel!
33322 // For after we switch over our page tables
33323 // That entry will be read-only: we'd crash.
33324 +
33325 +#ifdef CONFIG_PAX_KERNEXEC
33326 + mov %cr0, %edx
33327 + xor $X86_CR0_WP, %edx
33328 + mov %edx, %cr0
33329 +#endif
33330 +
33331 movl $(GDT_ENTRY_TSS*8), %edx
33332 ltr %dx
33333
33334 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
33335 // Let's clear it again for our return.
33336 // The GDT descriptor of the Host
33337 // Points to the table after two "size" bytes
33338 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
33339 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
33340 // Clear "used" from type field (byte 5, bit 2)
33341 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
33342 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
33343 +
33344 +#ifdef CONFIG_PAX_KERNEXEC
33345 + mov %cr0, %eax
33346 + xor $X86_CR0_WP, %eax
33347 + mov %eax, %cr0
33348 +#endif
33349
33350 // Once our page table's switched, the Guest is live!
33351 // The Host fades as we run this final step.
33352 @@ -295,13 +309,12 @@ deliver_to_host:
33353 // I consulted gcc, and it gave
33354 // These instructions, which I gladly credit:
33355 leal (%edx,%ebx,8), %eax
33356 - movzwl (%eax),%edx
33357 - movl 4(%eax), %eax
33358 - xorw %ax, %ax
33359 - orl %eax, %edx
33360 + movl 4(%eax), %edx
33361 + movw (%eax), %dx
33362 // Now the address of the handler's in %edx
33363 // We call it now: its "iret" drops us home.
33364 - jmp *%edx
33365 + ljmp $__KERNEL_CS, $1f
33366 +1: jmp *%edx
33367
33368 // Every interrupt can come to us here
33369 // But we must truly tell each apart.
33370 diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
33371 index 4daf9e5..b8d1d0f 100644
33372 --- a/drivers/macintosh/macio_asic.c
33373 +++ b/drivers/macintosh/macio_asic.c
33374 @@ -748,7 +748,7 @@ static void __devexit macio_pci_remove(struct pci_dev* pdev)
33375 * MacIO is matched against any Apple ID, it's probe() function
33376 * will then decide wether it applies or not
33377 */
33378 -static const struct pci_device_id __devinitdata pci_ids [] = { {
33379 +static const struct pci_device_id __devinitconst pci_ids [] = { {
33380 .vendor = PCI_VENDOR_ID_APPLE,
33381 .device = PCI_ANY_ID,
33382 .subvendor = PCI_ANY_ID,
33383 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
33384 index 1ce84ed..0fdd40a 100644
33385 --- a/drivers/md/dm-ioctl.c
33386 +++ b/drivers/md/dm-ioctl.c
33387 @@ -1589,7 +1589,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
33388 cmd == DM_LIST_VERSIONS_CMD)
33389 return 0;
33390
33391 - if ((cmd == DM_DEV_CREATE_CMD)) {
33392 + if (cmd == DM_DEV_CREATE_CMD) {
33393 if (!*param->name) {
33394 DMWARN("name not supplied when creating device");
33395 return -EINVAL;
33396 diff --git a/drivers/md/dm-log-userspace-transfer.c b/drivers/md/dm-log-userspace-transfer.c
33397 index 1f23e04..08d9a20 100644
33398 --- a/drivers/md/dm-log-userspace-transfer.c
33399 +++ b/drivers/md/dm-log-userspace-transfer.c
33400 @@ -134,7 +134,7 @@ static void cn_ulog_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp)
33401 {
33402 struct dm_ulog_request *tfr = (struct dm_ulog_request *)(msg + 1);
33403
33404 - if (!cap_raised(current_cap(), CAP_SYS_ADMIN))
33405 + if (!capable(CAP_SYS_ADMIN))
33406 return;
33407
33408 spin_lock(&receiving_list_lock);
33409 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
33410 index 9bfd057..01180bc 100644
33411 --- a/drivers/md/dm-raid1.c
33412 +++ b/drivers/md/dm-raid1.c
33413 @@ -40,7 +40,7 @@ enum dm_raid1_error {
33414
33415 struct mirror {
33416 struct mirror_set *ms;
33417 - atomic_t error_count;
33418 + atomic_unchecked_t error_count;
33419 unsigned long error_type;
33420 struct dm_dev *dev;
33421 sector_t offset;
33422 @@ -185,7 +185,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
33423 struct mirror *m;
33424
33425 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
33426 - if (!atomic_read(&m->error_count))
33427 + if (!atomic_read_unchecked(&m->error_count))
33428 return m;
33429
33430 return NULL;
33431 @@ -217,7 +217,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
33432 * simple way to tell if a device has encountered
33433 * errors.
33434 */
33435 - atomic_inc(&m->error_count);
33436 + atomic_inc_unchecked(&m->error_count);
33437
33438 if (test_and_set_bit(error_type, &m->error_type))
33439 return;
33440 @@ -408,7 +408,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
33441 struct mirror *m = get_default_mirror(ms);
33442
33443 do {
33444 - if (likely(!atomic_read(&m->error_count)))
33445 + if (likely(!atomic_read_unchecked(&m->error_count)))
33446 return m;
33447
33448 if (m-- == ms->mirror)
33449 @@ -422,7 +422,7 @@ static int default_ok(struct mirror *m)
33450 {
33451 struct mirror *default_mirror = get_default_mirror(m->ms);
33452
33453 - return !atomic_read(&default_mirror->error_count);
33454 + return !atomic_read_unchecked(&default_mirror->error_count);
33455 }
33456
33457 static int mirror_available(struct mirror_set *ms, struct bio *bio)
33458 @@ -559,7 +559,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
33459 */
33460 if (likely(region_in_sync(ms, region, 1)))
33461 m = choose_mirror(ms, bio->bi_sector);
33462 - else if (m && atomic_read(&m->error_count))
33463 + else if (m && atomic_read_unchecked(&m->error_count))
33464 m = NULL;
33465
33466 if (likely(m))
33467 @@ -937,7 +937,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
33468 }
33469
33470 ms->mirror[mirror].ms = ms;
33471 - atomic_set(&(ms->mirror[mirror].error_count), 0);
33472 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
33473 ms->mirror[mirror].error_type = 0;
33474 ms->mirror[mirror].offset = offset;
33475
33476 @@ -1347,7 +1347,7 @@ static void mirror_resume(struct dm_target *ti)
33477 */
33478 static char device_status_char(struct mirror *m)
33479 {
33480 - if (!atomic_read(&(m->error_count)))
33481 + if (!atomic_read_unchecked(&(m->error_count)))
33482 return 'A';
33483
33484 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
33485 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
33486 index 3d80cf0..b77cc47 100644
33487 --- a/drivers/md/dm-stripe.c
33488 +++ b/drivers/md/dm-stripe.c
33489 @@ -20,7 +20,7 @@ struct stripe {
33490 struct dm_dev *dev;
33491 sector_t physical_start;
33492
33493 - atomic_t error_count;
33494 + atomic_unchecked_t error_count;
33495 };
33496
33497 struct stripe_c {
33498 @@ -192,7 +192,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
33499 kfree(sc);
33500 return r;
33501 }
33502 - atomic_set(&(sc->stripe[i].error_count), 0);
33503 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
33504 }
33505
33506 ti->private = sc;
33507 @@ -314,7 +314,7 @@ static int stripe_status(struct dm_target *ti,
33508 DMEMIT("%d ", sc->stripes);
33509 for (i = 0; i < sc->stripes; i++) {
33510 DMEMIT("%s ", sc->stripe[i].dev->name);
33511 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
33512 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
33513 'D' : 'A';
33514 }
33515 buffer[i] = '\0';
33516 @@ -361,8 +361,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio,
33517 */
33518 for (i = 0; i < sc->stripes; i++)
33519 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
33520 - atomic_inc(&(sc->stripe[i].error_count));
33521 - if (atomic_read(&(sc->stripe[i].error_count)) <
33522 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
33523 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
33524 DM_IO_ERROR_THRESHOLD)
33525 schedule_work(&sc->trigger_event);
33526 }
33527 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
33528 index 63cc542..8d45caf3 100644
33529 --- a/drivers/md/dm-table.c
33530 +++ b/drivers/md/dm-table.c
33531 @@ -391,7 +391,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
33532 if (!dev_size)
33533 return 0;
33534
33535 - if ((start >= dev_size) || (start + len > dev_size)) {
33536 + if ((start >= dev_size) || (len > dev_size - start)) {
33537 DMWARN("%s: %s too small for target: "
33538 "start=%llu, len=%llu, dev_size=%llu",
33539 dm_device_name(ti->table->md), bdevname(bdev, b),
33540 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
33541 index 237571a..fb6d19b 100644
33542 --- a/drivers/md/dm-thin-metadata.c
33543 +++ b/drivers/md/dm-thin-metadata.c
33544 @@ -432,7 +432,7 @@ static int init_pmd(struct dm_pool_metadata *pmd,
33545
33546 pmd->info.tm = tm;
33547 pmd->info.levels = 2;
33548 - pmd->info.value_type.context = pmd->data_sm;
33549 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
33550 pmd->info.value_type.size = sizeof(__le64);
33551 pmd->info.value_type.inc = data_block_inc;
33552 pmd->info.value_type.dec = data_block_dec;
33553 @@ -451,7 +451,7 @@ static int init_pmd(struct dm_pool_metadata *pmd,
33554
33555 pmd->bl_info.tm = tm;
33556 pmd->bl_info.levels = 1;
33557 - pmd->bl_info.value_type.context = pmd->data_sm;
33558 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
33559 pmd->bl_info.value_type.size = sizeof(__le64);
33560 pmd->bl_info.value_type.inc = data_block_inc;
33561 pmd->bl_info.value_type.dec = data_block_dec;
33562 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
33563 index b89c548..2af3ce4 100644
33564 --- a/drivers/md/dm.c
33565 +++ b/drivers/md/dm.c
33566 @@ -176,9 +176,9 @@ struct mapped_device {
33567 /*
33568 * Event handling.
33569 */
33570 - atomic_t event_nr;
33571 + atomic_unchecked_t event_nr;
33572 wait_queue_head_t eventq;
33573 - atomic_t uevent_seq;
33574 + atomic_unchecked_t uevent_seq;
33575 struct list_head uevent_list;
33576 spinlock_t uevent_lock; /* Protect access to uevent_list */
33577
33578 @@ -1844,8 +1844,8 @@ static struct mapped_device *alloc_dev(int minor)
33579 rwlock_init(&md->map_lock);
33580 atomic_set(&md->holders, 1);
33581 atomic_set(&md->open_count, 0);
33582 - atomic_set(&md->event_nr, 0);
33583 - atomic_set(&md->uevent_seq, 0);
33584 + atomic_set_unchecked(&md->event_nr, 0);
33585 + atomic_set_unchecked(&md->uevent_seq, 0);
33586 INIT_LIST_HEAD(&md->uevent_list);
33587 spin_lock_init(&md->uevent_lock);
33588
33589 @@ -1979,7 +1979,7 @@ static void event_callback(void *context)
33590
33591 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
33592
33593 - atomic_inc(&md->event_nr);
33594 + atomic_inc_unchecked(&md->event_nr);
33595 wake_up(&md->eventq);
33596 }
33597
33598 @@ -2621,18 +2621,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
33599
33600 uint32_t dm_next_uevent_seq(struct mapped_device *md)
33601 {
33602 - return atomic_add_return(1, &md->uevent_seq);
33603 + return atomic_add_return_unchecked(1, &md->uevent_seq);
33604 }
33605
33606 uint32_t dm_get_event_nr(struct mapped_device *md)
33607 {
33608 - return atomic_read(&md->event_nr);
33609 + return atomic_read_unchecked(&md->event_nr);
33610 }
33611
33612 int dm_wait_event(struct mapped_device *md, int event_nr)
33613 {
33614 return wait_event_interruptible(md->eventq,
33615 - (event_nr != atomic_read(&md->event_nr)));
33616 + (event_nr != atomic_read_unchecked(&md->event_nr)));
33617 }
33618
33619 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
33620 diff --git a/drivers/md/md.c b/drivers/md/md.c
33621 index 363aaf4..d875264 100644
33622 --- a/drivers/md/md.c
33623 +++ b/drivers/md/md.c
33624 @@ -277,10 +277,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
33625 * start build, activate spare
33626 */
33627 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
33628 -static atomic_t md_event_count;
33629 +static atomic_unchecked_t md_event_count;
33630 void md_new_event(struct mddev *mddev)
33631 {
33632 - atomic_inc(&md_event_count);
33633 + atomic_inc_unchecked(&md_event_count);
33634 wake_up(&md_event_waiters);
33635 }
33636 EXPORT_SYMBOL_GPL(md_new_event);
33637 @@ -290,7 +290,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
33638 */
33639 static void md_new_event_inintr(struct mddev *mddev)
33640 {
33641 - atomic_inc(&md_event_count);
33642 + atomic_inc_unchecked(&md_event_count);
33643 wake_up(&md_event_waiters);
33644 }
33645
33646 @@ -1526,7 +1526,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
33647
33648 rdev->preferred_minor = 0xffff;
33649 rdev->data_offset = le64_to_cpu(sb->data_offset);
33650 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
33651 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
33652
33653 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
33654 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
33655 @@ -1745,7 +1745,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
33656 else
33657 sb->resync_offset = cpu_to_le64(0);
33658
33659 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
33660 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
33661
33662 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
33663 sb->size = cpu_to_le64(mddev->dev_sectors);
33664 @@ -2691,7 +2691,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
33665 static ssize_t
33666 errors_show(struct md_rdev *rdev, char *page)
33667 {
33668 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
33669 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
33670 }
33671
33672 static ssize_t
33673 @@ -2700,7 +2700,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
33674 char *e;
33675 unsigned long n = simple_strtoul(buf, &e, 10);
33676 if (*buf && (*e == 0 || *e == '\n')) {
33677 - atomic_set(&rdev->corrected_errors, n);
33678 + atomic_set_unchecked(&rdev->corrected_errors, n);
33679 return len;
33680 }
33681 return -EINVAL;
33682 @@ -3086,8 +3086,8 @@ int md_rdev_init(struct md_rdev *rdev)
33683 rdev->sb_loaded = 0;
33684 rdev->bb_page = NULL;
33685 atomic_set(&rdev->nr_pending, 0);
33686 - atomic_set(&rdev->read_errors, 0);
33687 - atomic_set(&rdev->corrected_errors, 0);
33688 + atomic_set_unchecked(&rdev->read_errors, 0);
33689 + atomic_set_unchecked(&rdev->corrected_errors, 0);
33690
33691 INIT_LIST_HEAD(&rdev->same_set);
33692 init_waitqueue_head(&rdev->blocked_wait);
33693 @@ -6738,7 +6738,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
33694
33695 spin_unlock(&pers_lock);
33696 seq_printf(seq, "\n");
33697 - seq->poll_event = atomic_read(&md_event_count);
33698 + seq->poll_event = atomic_read_unchecked(&md_event_count);
33699 return 0;
33700 }
33701 if (v == (void*)2) {
33702 @@ -6830,7 +6830,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
33703 chunk_kb ? "KB" : "B");
33704 if (bitmap->file) {
33705 seq_printf(seq, ", file: ");
33706 - seq_path(seq, &bitmap->file->f_path, " \t\n");
33707 + seq_path(seq, &bitmap->file->f_path, " \t\n\\");
33708 }
33709
33710 seq_printf(seq, "\n");
33711 @@ -6861,7 +6861,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
33712 return error;
33713
33714 seq = file->private_data;
33715 - seq->poll_event = atomic_read(&md_event_count);
33716 + seq->poll_event = atomic_read_unchecked(&md_event_count);
33717 return error;
33718 }
33719
33720 @@ -6875,7 +6875,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
33721 /* always allow read */
33722 mask = POLLIN | POLLRDNORM;
33723
33724 - if (seq->poll_event != atomic_read(&md_event_count))
33725 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
33726 mask |= POLLERR | POLLPRI;
33727 return mask;
33728 }
33729 @@ -6919,7 +6919,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
33730 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
33731 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
33732 (int)part_stat_read(&disk->part0, sectors[1]) -
33733 - atomic_read(&disk->sync_io);
33734 + atomic_read_unchecked(&disk->sync_io);
33735 /* sync IO will cause sync_io to increase before the disk_stats
33736 * as sync_io is counted when a request starts, and
33737 * disk_stats is counted when it completes.
33738 diff --git a/drivers/md/md.h b/drivers/md/md.h
33739 index 44c63df..b795d1a 100644
33740 --- a/drivers/md/md.h
33741 +++ b/drivers/md/md.h
33742 @@ -93,13 +93,13 @@ struct md_rdev {
33743 * only maintained for arrays that
33744 * support hot removal
33745 */
33746 - atomic_t read_errors; /* number of consecutive read errors that
33747 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
33748 * we have tried to ignore.
33749 */
33750 struct timespec last_read_error; /* monotonic time since our
33751 * last read error
33752 */
33753 - atomic_t corrected_errors; /* number of corrected read errors,
33754 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
33755 * for reporting to userspace and storing
33756 * in superblock.
33757 */
33758 @@ -421,7 +421,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
33759
33760 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
33761 {
33762 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
33763 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
33764 }
33765
33766 struct md_personality
33767 diff --git a/drivers/md/persistent-data/dm-space-map-checker.c b/drivers/md/persistent-data/dm-space-map-checker.c
33768 index 50ed53b..4f29d7d 100644
33769 --- a/drivers/md/persistent-data/dm-space-map-checker.c
33770 +++ b/drivers/md/persistent-data/dm-space-map-checker.c
33771 @@ -159,7 +159,7 @@ static void ca_destroy(struct count_array *ca)
33772 /*----------------------------------------------------------------*/
33773
33774 struct sm_checker {
33775 - struct dm_space_map sm;
33776 + dm_space_map_no_const sm;
33777
33778 struct count_array old_counts;
33779 struct count_array counts;
33780 diff --git a/drivers/md/persistent-data/dm-space-map-disk.c b/drivers/md/persistent-data/dm-space-map-disk.c
33781 index fc469ba..2d91555 100644
33782 --- a/drivers/md/persistent-data/dm-space-map-disk.c
33783 +++ b/drivers/md/persistent-data/dm-space-map-disk.c
33784 @@ -23,7 +23,7 @@
33785 * Space map interface.
33786 */
33787 struct sm_disk {
33788 - struct dm_space_map sm;
33789 + dm_space_map_no_const sm;
33790
33791 struct ll_disk ll;
33792 struct ll_disk old_ll;
33793 diff --git a/drivers/md/persistent-data/dm-space-map-metadata.c b/drivers/md/persistent-data/dm-space-map-metadata.c
33794 index e89ae5e..062e4c2 100644
33795 --- a/drivers/md/persistent-data/dm-space-map-metadata.c
33796 +++ b/drivers/md/persistent-data/dm-space-map-metadata.c
33797 @@ -43,7 +43,7 @@ struct block_op {
33798 };
33799
33800 struct sm_metadata {
33801 - struct dm_space_map sm;
33802 + dm_space_map_no_const sm;
33803
33804 struct ll_disk ll;
33805 struct ll_disk old_ll;
33806 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
33807 index 1cbfc6b..56e1dbb 100644
33808 --- a/drivers/md/persistent-data/dm-space-map.h
33809 +++ b/drivers/md/persistent-data/dm-space-map.h
33810 @@ -60,6 +60,7 @@ struct dm_space_map {
33811 int (*root_size)(struct dm_space_map *sm, size_t *result);
33812 int (*copy_root)(struct dm_space_map *sm, void *copy_to_here_le, size_t len);
33813 };
33814 +typedef struct dm_space_map __no_const dm_space_map_no_const;
33815
33816 /*----------------------------------------------------------------*/
33817
33818 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
33819 index edc735a..e9b97f1 100644
33820 --- a/drivers/md/raid1.c
33821 +++ b/drivers/md/raid1.c
33822 @@ -1645,7 +1645,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
33823 if (r1_sync_page_io(rdev, sect, s,
33824 bio->bi_io_vec[idx].bv_page,
33825 READ) != 0)
33826 - atomic_add(s, &rdev->corrected_errors);
33827 + atomic_add_unchecked(s, &rdev->corrected_errors);
33828 }
33829 sectors -= s;
33830 sect += s;
33831 @@ -1859,7 +1859,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
33832 test_bit(In_sync, &rdev->flags)) {
33833 if (r1_sync_page_io(rdev, sect, s,
33834 conf->tmppage, READ)) {
33835 - atomic_add(s, &rdev->corrected_errors);
33836 + atomic_add_unchecked(s, &rdev->corrected_errors);
33837 printk(KERN_INFO
33838 "md/raid1:%s: read error corrected "
33839 "(%d sectors at %llu on %s)\n",
33840 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
33841 index 1898389..a3aa617 100644
33842 --- a/drivers/md/raid10.c
33843 +++ b/drivers/md/raid10.c
33844 @@ -1636,7 +1636,7 @@ static void end_sync_read(struct bio *bio, int error)
33845 /* The write handler will notice the lack of
33846 * R10BIO_Uptodate and record any errors etc
33847 */
33848 - atomic_add(r10_bio->sectors,
33849 + atomic_add_unchecked(r10_bio->sectors,
33850 &conf->mirrors[d].rdev->corrected_errors);
33851
33852 /* for reconstruct, we always reschedule after a read.
33853 @@ -1987,7 +1987,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
33854 {
33855 struct timespec cur_time_mon;
33856 unsigned long hours_since_last;
33857 - unsigned int read_errors = atomic_read(&rdev->read_errors);
33858 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
33859
33860 ktime_get_ts(&cur_time_mon);
33861
33862 @@ -2009,9 +2009,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
33863 * overflowing the shift of read_errors by hours_since_last.
33864 */
33865 if (hours_since_last >= 8 * sizeof(read_errors))
33866 - atomic_set(&rdev->read_errors, 0);
33867 + atomic_set_unchecked(&rdev->read_errors, 0);
33868 else
33869 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
33870 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
33871 }
33872
33873 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
33874 @@ -2065,8 +2065,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
33875 return;
33876
33877 check_decay_read_errors(mddev, rdev);
33878 - atomic_inc(&rdev->read_errors);
33879 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
33880 + atomic_inc_unchecked(&rdev->read_errors);
33881 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
33882 char b[BDEVNAME_SIZE];
33883 bdevname(rdev->bdev, b);
33884
33885 @@ -2074,7 +2074,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
33886 "md/raid10:%s: %s: Raid device exceeded "
33887 "read_error threshold [cur %d:max %d]\n",
33888 mdname(mddev), b,
33889 - atomic_read(&rdev->read_errors), max_read_errors);
33890 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
33891 printk(KERN_NOTICE
33892 "md/raid10:%s: %s: Failing raid device\n",
33893 mdname(mddev), b);
33894 @@ -2223,7 +2223,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
33895 (unsigned long long)(
33896 sect + rdev->data_offset),
33897 bdevname(rdev->bdev, b));
33898 - atomic_add(s, &rdev->corrected_errors);
33899 + atomic_add_unchecked(s, &rdev->corrected_errors);
33900 }
33901
33902 rdev_dec_pending(rdev, mddev);
33903 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
33904 index d1162e5..c7cd902 100644
33905 --- a/drivers/md/raid5.c
33906 +++ b/drivers/md/raid5.c
33907 @@ -1687,18 +1687,18 @@ static void raid5_end_read_request(struct bio * bi, int error)
33908 (unsigned long long)(sh->sector
33909 + rdev->data_offset),
33910 bdevname(rdev->bdev, b));
33911 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
33912 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
33913 clear_bit(R5_ReadError, &sh->dev[i].flags);
33914 clear_bit(R5_ReWrite, &sh->dev[i].flags);
33915 }
33916 - if (atomic_read(&rdev->read_errors))
33917 - atomic_set(&rdev->read_errors, 0);
33918 + if (atomic_read_unchecked(&rdev->read_errors))
33919 + atomic_set_unchecked(&rdev->read_errors, 0);
33920 } else {
33921 const char *bdn = bdevname(rdev->bdev, b);
33922 int retry = 0;
33923
33924 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
33925 - atomic_inc(&rdev->read_errors);
33926 + atomic_inc_unchecked(&rdev->read_errors);
33927 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
33928 printk_ratelimited(
33929 KERN_WARNING
33930 @@ -1727,7 +1727,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
33931 (unsigned long long)(sh->sector
33932 + rdev->data_offset),
33933 bdn);
33934 - else if (atomic_read(&rdev->read_errors)
33935 + else if (atomic_read_unchecked(&rdev->read_errors)
33936 > conf->max_nr_stripes)
33937 printk(KERN_WARNING
33938 "md/raid:%s: Too many read errors, failing device %s.\n",
33939 diff --git a/drivers/media/dvb/ddbridge/ddbridge-core.c b/drivers/media/dvb/ddbridge/ddbridge-core.c
33940 index ce4f858..7bcfb46 100644
33941 --- a/drivers/media/dvb/ddbridge/ddbridge-core.c
33942 +++ b/drivers/media/dvb/ddbridge/ddbridge-core.c
33943 @@ -1678,7 +1678,7 @@ static struct ddb_info ddb_v6 = {
33944 .subvendor = _subvend, .subdevice = _subdev, \
33945 .driver_data = (unsigned long)&_driverdata }
33946
33947 -static const struct pci_device_id ddb_id_tbl[] __devinitdata = {
33948 +static const struct pci_device_id ddb_id_tbl[] __devinitconst = {
33949 DDB_ID(DDVID, 0x0002, DDVID, 0x0001, ddb_octopus),
33950 DDB_ID(DDVID, 0x0003, DDVID, 0x0001, ddb_octopus),
33951 DDB_ID(DDVID, 0x0003, DDVID, 0x0002, ddb_octopus_le),
33952 diff --git a/drivers/media/dvb/dvb-core/dvb_demux.h b/drivers/media/dvb/dvb-core/dvb_demux.h
33953 index a7d876f..8c21b61 100644
33954 --- a/drivers/media/dvb/dvb-core/dvb_demux.h
33955 +++ b/drivers/media/dvb/dvb-core/dvb_demux.h
33956 @@ -73,7 +73,7 @@ struct dvb_demux_feed {
33957 union {
33958 dmx_ts_cb ts;
33959 dmx_section_cb sec;
33960 - } cb;
33961 + } __no_const cb;
33962
33963 struct dvb_demux *demux;
33964 void *priv;
33965 diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
33966 index 00a6732..70a682e 100644
33967 --- a/drivers/media/dvb/dvb-core/dvbdev.c
33968 +++ b/drivers/media/dvb/dvb-core/dvbdev.c
33969 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
33970 const struct dvb_device *template, void *priv, int type)
33971 {
33972 struct dvb_device *dvbdev;
33973 - struct file_operations *dvbdevfops;
33974 + file_operations_no_const *dvbdevfops;
33975 struct device *clsdev;
33976 int minor;
33977 int id;
33978 diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c
33979 index 3940bb0..fb3952a 100644
33980 --- a/drivers/media/dvb/dvb-usb/cxusb.c
33981 +++ b/drivers/media/dvb/dvb-usb/cxusb.c
33982 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
33983
33984 struct dib0700_adapter_state {
33985 int (*set_param_save) (struct dvb_frontend *);
33986 -};
33987 +} __no_const;
33988
33989 static int dib7070_set_param_override(struct dvb_frontend *fe)
33990 {
33991 diff --git a/drivers/media/dvb/dvb-usb/dw2102.c b/drivers/media/dvb/dvb-usb/dw2102.c
33992 index 451c5a7..649f711 100644
33993 --- a/drivers/media/dvb/dvb-usb/dw2102.c
33994 +++ b/drivers/media/dvb/dvb-usb/dw2102.c
33995 @@ -95,7 +95,7 @@ struct su3000_state {
33996
33997 struct s6x0_state {
33998 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
33999 -};
34000 +} __no_const;
34001
34002 /* debug */
34003 static int dvb_usb_dw2102_debug;
34004 diff --git a/drivers/media/dvb/frontends/dib3000.h b/drivers/media/dvb/frontends/dib3000.h
34005 index 404f63a..4796533 100644
34006 --- a/drivers/media/dvb/frontends/dib3000.h
34007 +++ b/drivers/media/dvb/frontends/dib3000.h
34008 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
34009 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
34010 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
34011 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
34012 -};
34013 +} __no_const;
34014
34015 #if defined(CONFIG_DVB_DIB3000MB) || (defined(CONFIG_DVB_DIB3000MB_MODULE) && defined(MODULE))
34016 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
34017 diff --git a/drivers/media/dvb/ngene/ngene-cards.c b/drivers/media/dvb/ngene/ngene-cards.c
34018 index 8418c02..8555013 100644
34019 --- a/drivers/media/dvb/ngene/ngene-cards.c
34020 +++ b/drivers/media/dvb/ngene/ngene-cards.c
34021 @@ -477,7 +477,7 @@ static struct ngene_info ngene_info_m780 = {
34022
34023 /****************************************************************************/
34024
34025 -static const struct pci_device_id ngene_id_tbl[] __devinitdata = {
34026 +static const struct pci_device_id ngene_id_tbl[] __devinitconst = {
34027 NGENE_ID(0x18c3, 0xabc3, ngene_info_cineS2),
34028 NGENE_ID(0x18c3, 0xabc4, ngene_info_cineS2),
34029 NGENE_ID(0x18c3, 0xdb01, ngene_info_satixS2),
34030 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
34031 index 16a089f..ab1667d 100644
34032 --- a/drivers/media/radio/radio-cadet.c
34033 +++ b/drivers/media/radio/radio-cadet.c
34034 @@ -326,6 +326,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
34035 unsigned char readbuf[RDS_BUFFER];
34036 int i = 0;
34037
34038 + if (count > RDS_BUFFER)
34039 + return -EFAULT;
34040 mutex_lock(&dev->lock);
34041 if (dev->rdsstat == 0) {
34042 dev->rdsstat = 1;
34043 diff --git a/drivers/media/video/au0828/au0828.h b/drivers/media/video/au0828/au0828.h
34044 index 9cde353..8c6a1c3 100644
34045 --- a/drivers/media/video/au0828/au0828.h
34046 +++ b/drivers/media/video/au0828/au0828.h
34047 @@ -191,7 +191,7 @@ struct au0828_dev {
34048
34049 /* I2C */
34050 struct i2c_adapter i2c_adap;
34051 - struct i2c_algorithm i2c_algo;
34052 + i2c_algorithm_no_const i2c_algo;
34053 struct i2c_client i2c_client;
34054 u32 i2c_rc;
34055
34056 diff --git a/drivers/media/video/cx88/cx88-alsa.c b/drivers/media/video/cx88/cx88-alsa.c
34057 index 04bf662..e0ac026 100644
34058 --- a/drivers/media/video/cx88/cx88-alsa.c
34059 +++ b/drivers/media/video/cx88/cx88-alsa.c
34060 @@ -766,7 +766,7 @@ static struct snd_kcontrol_new snd_cx88_alc_switch = {
34061 * Only boards with eeprom and byte 1 at eeprom=1 have it
34062 */
34063
34064 -static const struct pci_device_id const cx88_audio_pci_tbl[] __devinitdata = {
34065 +static const struct pci_device_id const cx88_audio_pci_tbl[] __devinitconst = {
34066 {0x14f1,0x8801,PCI_ANY_ID,PCI_ANY_ID,0,0,0},
34067 {0x14f1,0x8811,PCI_ANY_ID,PCI_ANY_ID,0,0,0},
34068 {0, }
34069 diff --git a/drivers/media/video/omap/omap_vout.c b/drivers/media/video/omap/omap_vout.c
34070 index 1fb7d5b..3901e77 100644
34071 --- a/drivers/media/video/omap/omap_vout.c
34072 +++ b/drivers/media/video/omap/omap_vout.c
34073 @@ -64,7 +64,6 @@ enum omap_vout_channels {
34074 OMAP_VIDEO2,
34075 };
34076
34077 -static struct videobuf_queue_ops video_vbq_ops;
34078 /* Variables configurable through module params*/
34079 static u32 video1_numbuffers = 3;
34080 static u32 video2_numbuffers = 3;
34081 @@ -1000,6 +999,12 @@ static int omap_vout_open(struct file *file)
34082 {
34083 struct videobuf_queue *q;
34084 struct omap_vout_device *vout = NULL;
34085 + static struct videobuf_queue_ops video_vbq_ops = {
34086 + .buf_setup = omap_vout_buffer_setup,
34087 + .buf_prepare = omap_vout_buffer_prepare,
34088 + .buf_release = omap_vout_buffer_release,
34089 + .buf_queue = omap_vout_buffer_queue,
34090 + };
34091
34092 vout = video_drvdata(file);
34093 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
34094 @@ -1017,10 +1022,6 @@ static int omap_vout_open(struct file *file)
34095 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
34096
34097 q = &vout->vbq;
34098 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
34099 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
34100 - video_vbq_ops.buf_release = omap_vout_buffer_release;
34101 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
34102 spin_lock_init(&vout->vbq_lock);
34103
34104 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
34105 diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
34106 index 305e6aa..0143317 100644
34107 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
34108 +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
34109 @@ -196,7 +196,7 @@ struct pvr2_hdw {
34110
34111 /* I2C stuff */
34112 struct i2c_adapter i2c_adap;
34113 - struct i2c_algorithm i2c_algo;
34114 + i2c_algorithm_no_const i2c_algo;
34115 pvr2_i2c_func i2c_func[PVR2_I2C_FUNC_CNT];
34116 int i2c_cx25840_hack_state;
34117 int i2c_linked;
34118 diff --git a/drivers/media/video/timblogiw.c b/drivers/media/video/timblogiw.c
34119 index 4ed1c7c2..8f15e13 100644
34120 --- a/drivers/media/video/timblogiw.c
34121 +++ b/drivers/media/video/timblogiw.c
34122 @@ -745,7 +745,7 @@ static int timblogiw_mmap(struct file *file, struct vm_area_struct *vma)
34123
34124 /* Platform device functions */
34125
34126 -static __devinitconst struct v4l2_ioctl_ops timblogiw_ioctl_ops = {
34127 +static __devinitconst v4l2_ioctl_ops_no_const timblogiw_ioctl_ops = {
34128 .vidioc_querycap = timblogiw_querycap,
34129 .vidioc_enum_fmt_vid_cap = timblogiw_enum_fmt,
34130 .vidioc_g_fmt_vid_cap = timblogiw_g_fmt,
34131 @@ -767,7 +767,7 @@ static __devinitconst struct v4l2_ioctl_ops timblogiw_ioctl_ops = {
34132 .vidioc_enum_framesizes = timblogiw_enum_framesizes,
34133 };
34134
34135 -static __devinitconst struct v4l2_file_operations timblogiw_fops = {
34136 +static __devinitconst v4l2_file_operations_no_const timblogiw_fops = {
34137 .owner = THIS_MODULE,
34138 .open = timblogiw_open,
34139 .release = timblogiw_close,
34140 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
34141 index a7dc467..a55c423 100644
34142 --- a/drivers/message/fusion/mptbase.c
34143 +++ b/drivers/message/fusion/mptbase.c
34144 @@ -6754,8 +6754,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
34145 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
34146 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
34147
34148 +#ifdef CONFIG_GRKERNSEC_HIDESYM
34149 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
34150 +#else
34151 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
34152 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
34153 +#endif
34154 +
34155 /*
34156 * Rounding UP to nearest 4-kB boundary here...
34157 */
34158 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
34159 index 551262e..7551198 100644
34160 --- a/drivers/message/fusion/mptsas.c
34161 +++ b/drivers/message/fusion/mptsas.c
34162 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
34163 return 0;
34164 }
34165
34166 +static inline void
34167 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
34168 +{
34169 + if (phy_info->port_details) {
34170 + phy_info->port_details->rphy = rphy;
34171 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
34172 + ioc->name, rphy));
34173 + }
34174 +
34175 + if (rphy) {
34176 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
34177 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
34178 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
34179 + ioc->name, rphy, rphy->dev.release));
34180 + }
34181 +}
34182 +
34183 /* no mutex */
34184 static void
34185 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
34186 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
34187 return NULL;
34188 }
34189
34190 -static inline void
34191 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
34192 -{
34193 - if (phy_info->port_details) {
34194 - phy_info->port_details->rphy = rphy;
34195 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
34196 - ioc->name, rphy));
34197 - }
34198 -
34199 - if (rphy) {
34200 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
34201 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
34202 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
34203 - ioc->name, rphy, rphy->dev.release));
34204 - }
34205 -}
34206 -
34207 static inline struct sas_port *
34208 mptsas_get_port(struct mptsas_phyinfo *phy_info)
34209 {
34210 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
34211 index 0c3ced7..1fe34ec 100644
34212 --- a/drivers/message/fusion/mptscsih.c
34213 +++ b/drivers/message/fusion/mptscsih.c
34214 @@ -1270,15 +1270,16 @@ mptscsih_info(struct Scsi_Host *SChost)
34215
34216 h = shost_priv(SChost);
34217
34218 - if (h) {
34219 - if (h->info_kbuf == NULL)
34220 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
34221 - return h->info_kbuf;
34222 - h->info_kbuf[0] = '\0';
34223 + if (!h)
34224 + return NULL;
34225
34226 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
34227 - h->info_kbuf[size-1] = '\0';
34228 - }
34229 + if (h->info_kbuf == NULL)
34230 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
34231 + return h->info_kbuf;
34232 + h->info_kbuf[0] = '\0';
34233 +
34234 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
34235 + h->info_kbuf[size-1] = '\0';
34236
34237 return h->info_kbuf;
34238 }
34239 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
34240 index 6d115c7..58ff7fd 100644
34241 --- a/drivers/message/i2o/i2o_proc.c
34242 +++ b/drivers/message/i2o/i2o_proc.c
34243 @@ -255,13 +255,6 @@ static char *scsi_devices[] = {
34244 "Array Controller Device"
34245 };
34246
34247 -static char *chtostr(u8 * chars, int n)
34248 -{
34249 - char tmp[256];
34250 - tmp[0] = 0;
34251 - return strncat(tmp, (char *)chars, n);
34252 -}
34253 -
34254 static int i2o_report_query_status(struct seq_file *seq, int block_status,
34255 char *group)
34256 {
34257 @@ -838,8 +831,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
34258
34259 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
34260 seq_printf(seq, "%-#8x", ddm_table.module_id);
34261 - seq_printf(seq, "%-29s",
34262 - chtostr(ddm_table.module_name_version, 28));
34263 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
34264 seq_printf(seq, "%9d ", ddm_table.data_size);
34265 seq_printf(seq, "%8d", ddm_table.code_size);
34266
34267 @@ -940,8 +932,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
34268
34269 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
34270 seq_printf(seq, "%-#8x", dst->module_id);
34271 - seq_printf(seq, "%-29s", chtostr(dst->module_name_version, 28));
34272 - seq_printf(seq, "%-9s", chtostr(dst->date, 8));
34273 + seq_printf(seq, "%-.28s", dst->module_name_version);
34274 + seq_printf(seq, "%-.8s", dst->date);
34275 seq_printf(seq, "%8d ", dst->module_size);
34276 seq_printf(seq, "%8d ", dst->mpb_size);
34277 seq_printf(seq, "0x%04x", dst->module_flags);
34278 @@ -1272,14 +1264,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
34279 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
34280 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
34281 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
34282 - seq_printf(seq, "Vendor info : %s\n",
34283 - chtostr((u8 *) (work32 + 2), 16));
34284 - seq_printf(seq, "Product info : %s\n",
34285 - chtostr((u8 *) (work32 + 6), 16));
34286 - seq_printf(seq, "Description : %s\n",
34287 - chtostr((u8 *) (work32 + 10), 16));
34288 - seq_printf(seq, "Product rev. : %s\n",
34289 - chtostr((u8 *) (work32 + 14), 8));
34290 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
34291 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
34292 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
34293 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
34294
34295 seq_printf(seq, "Serial number : ");
34296 print_serial_number(seq, (u8 *) (work32 + 16),
34297 @@ -1324,10 +1312,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
34298 }
34299
34300 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
34301 - seq_printf(seq, "Module name : %s\n",
34302 - chtostr(result.module_name, 24));
34303 - seq_printf(seq, "Module revision : %s\n",
34304 - chtostr(result.module_rev, 8));
34305 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
34306 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
34307
34308 seq_printf(seq, "Serial number : ");
34309 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
34310 @@ -1358,14 +1344,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
34311 return 0;
34312 }
34313
34314 - seq_printf(seq, "Device name : %s\n",
34315 - chtostr(result.device_name, 64));
34316 - seq_printf(seq, "Service name : %s\n",
34317 - chtostr(result.service_name, 64));
34318 - seq_printf(seq, "Physical name : %s\n",
34319 - chtostr(result.physical_location, 64));
34320 - seq_printf(seq, "Instance number : %s\n",
34321 - chtostr(result.instance_number, 4));
34322 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
34323 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
34324 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
34325 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
34326
34327 return 0;
34328 }
34329 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
34330 index a8c08f3..155fe3d 100644
34331 --- a/drivers/message/i2o/iop.c
34332 +++ b/drivers/message/i2o/iop.c
34333 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
34334
34335 spin_lock_irqsave(&c->context_list_lock, flags);
34336
34337 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
34338 - atomic_inc(&c->context_list_counter);
34339 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
34340 + atomic_inc_unchecked(&c->context_list_counter);
34341
34342 - entry->context = atomic_read(&c->context_list_counter);
34343 + entry->context = atomic_read_unchecked(&c->context_list_counter);
34344
34345 list_add(&entry->list, &c->context_list);
34346
34347 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
34348
34349 #if BITS_PER_LONG == 64
34350 spin_lock_init(&c->context_list_lock);
34351 - atomic_set(&c->context_list_counter, 0);
34352 + atomic_set_unchecked(&c->context_list_counter, 0);
34353 INIT_LIST_HEAD(&c->context_list);
34354 #endif
34355
34356 diff --git a/drivers/mfd/abx500-core.c b/drivers/mfd/abx500-core.c
34357 index 7ce65f4..e66e9bc 100644
34358 --- a/drivers/mfd/abx500-core.c
34359 +++ b/drivers/mfd/abx500-core.c
34360 @@ -15,7 +15,7 @@ static LIST_HEAD(abx500_list);
34361
34362 struct abx500_device_entry {
34363 struct list_head list;
34364 - struct abx500_ops ops;
34365 + abx500_ops_no_const ops;
34366 struct device *dev;
34367 };
34368
34369 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
34370 index a9223ed..4127b13 100644
34371 --- a/drivers/mfd/janz-cmodio.c
34372 +++ b/drivers/mfd/janz-cmodio.c
34373 @@ -13,6 +13,7 @@
34374
34375 #include <linux/kernel.h>
34376 #include <linux/module.h>
34377 +#include <linux/slab.h>
34378 #include <linux/init.h>
34379 #include <linux/pci.h>
34380 #include <linux/interrupt.h>
34381 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
34382 index a981e2a..5ca0c8b 100644
34383 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
34384 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
34385 @@ -466,7 +466,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
34386 * the lid is closed. This leads to interrupts as soon as a little move
34387 * is done.
34388 */
34389 - atomic_inc(&lis3->count);
34390 + atomic_inc_unchecked(&lis3->count);
34391
34392 wake_up_interruptible(&lis3->misc_wait);
34393 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
34394 @@ -552,7 +552,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
34395 if (lis3->pm_dev)
34396 pm_runtime_get_sync(lis3->pm_dev);
34397
34398 - atomic_set(&lis3->count, 0);
34399 + atomic_set_unchecked(&lis3->count, 0);
34400 return 0;
34401 }
34402
34403 @@ -585,7 +585,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
34404 add_wait_queue(&lis3->misc_wait, &wait);
34405 while (true) {
34406 set_current_state(TASK_INTERRUPTIBLE);
34407 - data = atomic_xchg(&lis3->count, 0);
34408 + data = atomic_xchg_unchecked(&lis3->count, 0);
34409 if (data)
34410 break;
34411
34412 @@ -626,7 +626,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
34413 struct lis3lv02d, miscdev);
34414
34415 poll_wait(file, &lis3->misc_wait, wait);
34416 - if (atomic_read(&lis3->count))
34417 + if (atomic_read_unchecked(&lis3->count))
34418 return POLLIN | POLLRDNORM;
34419 return 0;
34420 }
34421 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
34422 index 2b1482a..5d33616 100644
34423 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
34424 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
34425 @@ -266,7 +266,7 @@ struct lis3lv02d {
34426 struct input_polled_dev *idev; /* input device */
34427 struct platform_device *pdev; /* platform device */
34428 struct regulator_bulk_data regulators[2];
34429 - atomic_t count; /* interrupt count after last read */
34430 + atomic_unchecked_t count; /* interrupt count after last read */
34431 union axis_conversion ac; /* hw -> logical axis */
34432 int mapped_btns[3];
34433
34434 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
34435 index 2f30bad..c4c13d0 100644
34436 --- a/drivers/misc/sgi-gru/gruhandles.c
34437 +++ b/drivers/misc/sgi-gru/gruhandles.c
34438 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
34439 unsigned long nsec;
34440
34441 nsec = CLKS2NSEC(clks);
34442 - atomic_long_inc(&mcs_op_statistics[op].count);
34443 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
34444 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
34445 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
34446 if (mcs_op_statistics[op].max < nsec)
34447 mcs_op_statistics[op].max = nsec;
34448 }
34449 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
34450 index 950dbe9..eeef0f8 100644
34451 --- a/drivers/misc/sgi-gru/gruprocfs.c
34452 +++ b/drivers/misc/sgi-gru/gruprocfs.c
34453 @@ -32,9 +32,9 @@
34454
34455 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
34456
34457 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
34458 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
34459 {
34460 - unsigned long val = atomic_long_read(v);
34461 + unsigned long val = atomic_long_read_unchecked(v);
34462
34463 seq_printf(s, "%16lu %s\n", val, id);
34464 }
34465 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
34466
34467 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
34468 for (op = 0; op < mcsop_last; op++) {
34469 - count = atomic_long_read(&mcs_op_statistics[op].count);
34470 - total = atomic_long_read(&mcs_op_statistics[op].total);
34471 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
34472 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
34473 max = mcs_op_statistics[op].max;
34474 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
34475 count ? total / count : 0, max);
34476 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
34477 index 5c3ce24..4915ccb 100644
34478 --- a/drivers/misc/sgi-gru/grutables.h
34479 +++ b/drivers/misc/sgi-gru/grutables.h
34480 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
34481 * GRU statistics.
34482 */
34483 struct gru_stats_s {
34484 - atomic_long_t vdata_alloc;
34485 - atomic_long_t vdata_free;
34486 - atomic_long_t gts_alloc;
34487 - atomic_long_t gts_free;
34488 - atomic_long_t gms_alloc;
34489 - atomic_long_t gms_free;
34490 - atomic_long_t gts_double_allocate;
34491 - atomic_long_t assign_context;
34492 - atomic_long_t assign_context_failed;
34493 - atomic_long_t free_context;
34494 - atomic_long_t load_user_context;
34495 - atomic_long_t load_kernel_context;
34496 - atomic_long_t lock_kernel_context;
34497 - atomic_long_t unlock_kernel_context;
34498 - atomic_long_t steal_user_context;
34499 - atomic_long_t steal_kernel_context;
34500 - atomic_long_t steal_context_failed;
34501 - atomic_long_t nopfn;
34502 - atomic_long_t asid_new;
34503 - atomic_long_t asid_next;
34504 - atomic_long_t asid_wrap;
34505 - atomic_long_t asid_reuse;
34506 - atomic_long_t intr;
34507 - atomic_long_t intr_cbr;
34508 - atomic_long_t intr_tfh;
34509 - atomic_long_t intr_spurious;
34510 - atomic_long_t intr_mm_lock_failed;
34511 - atomic_long_t call_os;
34512 - atomic_long_t call_os_wait_queue;
34513 - atomic_long_t user_flush_tlb;
34514 - atomic_long_t user_unload_context;
34515 - atomic_long_t user_exception;
34516 - atomic_long_t set_context_option;
34517 - atomic_long_t check_context_retarget_intr;
34518 - atomic_long_t check_context_unload;
34519 - atomic_long_t tlb_dropin;
34520 - atomic_long_t tlb_preload_page;
34521 - atomic_long_t tlb_dropin_fail_no_asid;
34522 - atomic_long_t tlb_dropin_fail_upm;
34523 - atomic_long_t tlb_dropin_fail_invalid;
34524 - atomic_long_t tlb_dropin_fail_range_active;
34525 - atomic_long_t tlb_dropin_fail_idle;
34526 - atomic_long_t tlb_dropin_fail_fmm;
34527 - atomic_long_t tlb_dropin_fail_no_exception;
34528 - atomic_long_t tfh_stale_on_fault;
34529 - atomic_long_t mmu_invalidate_range;
34530 - atomic_long_t mmu_invalidate_page;
34531 - atomic_long_t flush_tlb;
34532 - atomic_long_t flush_tlb_gru;
34533 - atomic_long_t flush_tlb_gru_tgh;
34534 - atomic_long_t flush_tlb_gru_zero_asid;
34535 + atomic_long_unchecked_t vdata_alloc;
34536 + atomic_long_unchecked_t vdata_free;
34537 + atomic_long_unchecked_t gts_alloc;
34538 + atomic_long_unchecked_t gts_free;
34539 + atomic_long_unchecked_t gms_alloc;
34540 + atomic_long_unchecked_t gms_free;
34541 + atomic_long_unchecked_t gts_double_allocate;
34542 + atomic_long_unchecked_t assign_context;
34543 + atomic_long_unchecked_t assign_context_failed;
34544 + atomic_long_unchecked_t free_context;
34545 + atomic_long_unchecked_t load_user_context;
34546 + atomic_long_unchecked_t load_kernel_context;
34547 + atomic_long_unchecked_t lock_kernel_context;
34548 + atomic_long_unchecked_t unlock_kernel_context;
34549 + atomic_long_unchecked_t steal_user_context;
34550 + atomic_long_unchecked_t steal_kernel_context;
34551 + atomic_long_unchecked_t steal_context_failed;
34552 + atomic_long_unchecked_t nopfn;
34553 + atomic_long_unchecked_t asid_new;
34554 + atomic_long_unchecked_t asid_next;
34555 + atomic_long_unchecked_t asid_wrap;
34556 + atomic_long_unchecked_t asid_reuse;
34557 + atomic_long_unchecked_t intr;
34558 + atomic_long_unchecked_t intr_cbr;
34559 + atomic_long_unchecked_t intr_tfh;
34560 + atomic_long_unchecked_t intr_spurious;
34561 + atomic_long_unchecked_t intr_mm_lock_failed;
34562 + atomic_long_unchecked_t call_os;
34563 + atomic_long_unchecked_t call_os_wait_queue;
34564 + atomic_long_unchecked_t user_flush_tlb;
34565 + atomic_long_unchecked_t user_unload_context;
34566 + atomic_long_unchecked_t user_exception;
34567 + atomic_long_unchecked_t set_context_option;
34568 + atomic_long_unchecked_t check_context_retarget_intr;
34569 + atomic_long_unchecked_t check_context_unload;
34570 + atomic_long_unchecked_t tlb_dropin;
34571 + atomic_long_unchecked_t tlb_preload_page;
34572 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
34573 + atomic_long_unchecked_t tlb_dropin_fail_upm;
34574 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
34575 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
34576 + atomic_long_unchecked_t tlb_dropin_fail_idle;
34577 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
34578 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
34579 + atomic_long_unchecked_t tfh_stale_on_fault;
34580 + atomic_long_unchecked_t mmu_invalidate_range;
34581 + atomic_long_unchecked_t mmu_invalidate_page;
34582 + atomic_long_unchecked_t flush_tlb;
34583 + atomic_long_unchecked_t flush_tlb_gru;
34584 + atomic_long_unchecked_t flush_tlb_gru_tgh;
34585 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
34586
34587 - atomic_long_t copy_gpa;
34588 - atomic_long_t read_gpa;
34589 + atomic_long_unchecked_t copy_gpa;
34590 + atomic_long_unchecked_t read_gpa;
34591
34592 - atomic_long_t mesq_receive;
34593 - atomic_long_t mesq_receive_none;
34594 - atomic_long_t mesq_send;
34595 - atomic_long_t mesq_send_failed;
34596 - atomic_long_t mesq_noop;
34597 - atomic_long_t mesq_send_unexpected_error;
34598 - atomic_long_t mesq_send_lb_overflow;
34599 - atomic_long_t mesq_send_qlimit_reached;
34600 - atomic_long_t mesq_send_amo_nacked;
34601 - atomic_long_t mesq_send_put_nacked;
34602 - atomic_long_t mesq_page_overflow;
34603 - atomic_long_t mesq_qf_locked;
34604 - atomic_long_t mesq_qf_noop_not_full;
34605 - atomic_long_t mesq_qf_switch_head_failed;
34606 - atomic_long_t mesq_qf_unexpected_error;
34607 - atomic_long_t mesq_noop_unexpected_error;
34608 - atomic_long_t mesq_noop_lb_overflow;
34609 - atomic_long_t mesq_noop_qlimit_reached;
34610 - atomic_long_t mesq_noop_amo_nacked;
34611 - atomic_long_t mesq_noop_put_nacked;
34612 - atomic_long_t mesq_noop_page_overflow;
34613 + atomic_long_unchecked_t mesq_receive;
34614 + atomic_long_unchecked_t mesq_receive_none;
34615 + atomic_long_unchecked_t mesq_send;
34616 + atomic_long_unchecked_t mesq_send_failed;
34617 + atomic_long_unchecked_t mesq_noop;
34618 + atomic_long_unchecked_t mesq_send_unexpected_error;
34619 + atomic_long_unchecked_t mesq_send_lb_overflow;
34620 + atomic_long_unchecked_t mesq_send_qlimit_reached;
34621 + atomic_long_unchecked_t mesq_send_amo_nacked;
34622 + atomic_long_unchecked_t mesq_send_put_nacked;
34623 + atomic_long_unchecked_t mesq_page_overflow;
34624 + atomic_long_unchecked_t mesq_qf_locked;
34625 + atomic_long_unchecked_t mesq_qf_noop_not_full;
34626 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
34627 + atomic_long_unchecked_t mesq_qf_unexpected_error;
34628 + atomic_long_unchecked_t mesq_noop_unexpected_error;
34629 + atomic_long_unchecked_t mesq_noop_lb_overflow;
34630 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
34631 + atomic_long_unchecked_t mesq_noop_amo_nacked;
34632 + atomic_long_unchecked_t mesq_noop_put_nacked;
34633 + atomic_long_unchecked_t mesq_noop_page_overflow;
34634
34635 };
34636
34637 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
34638 tghop_invalidate, mcsop_last};
34639
34640 struct mcs_op_statistic {
34641 - atomic_long_t count;
34642 - atomic_long_t total;
34643 + atomic_long_unchecked_t count;
34644 + atomic_long_unchecked_t total;
34645 unsigned long max;
34646 };
34647
34648 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
34649
34650 #define STAT(id) do { \
34651 if (gru_options & OPT_STATS) \
34652 - atomic_long_inc(&gru_stats.id); \
34653 + atomic_long_inc_unchecked(&gru_stats.id); \
34654 } while (0)
34655
34656 #ifdef CONFIG_SGI_GRU_DEBUG
34657 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
34658 index 851b2f2..a4ec097 100644
34659 --- a/drivers/misc/sgi-xp/xp.h
34660 +++ b/drivers/misc/sgi-xp/xp.h
34661 @@ -289,7 +289,7 @@ struct xpc_interface {
34662 xpc_notify_func, void *);
34663 void (*received) (short, int, void *);
34664 enum xp_retval (*partid_to_nasids) (short, void *);
34665 -};
34666 +} __no_const;
34667
34668 extern struct xpc_interface xpc_interface;
34669
34670 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
34671 index b94d5f7..7f494c5 100644
34672 --- a/drivers/misc/sgi-xp/xpc.h
34673 +++ b/drivers/misc/sgi-xp/xpc.h
34674 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
34675 void (*received_payload) (struct xpc_channel *, void *);
34676 void (*notify_senders_of_disconnect) (struct xpc_channel *);
34677 };
34678 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
34679
34680 /* struct xpc_partition act_state values (for XPC HB) */
34681
34682 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
34683 /* found in xpc_main.c */
34684 extern struct device *xpc_part;
34685 extern struct device *xpc_chan;
34686 -extern struct xpc_arch_operations xpc_arch_ops;
34687 +extern xpc_arch_operations_no_const xpc_arch_ops;
34688 extern int xpc_disengage_timelimit;
34689 extern int xpc_disengage_timedout;
34690 extern int xpc_activate_IRQ_rcvd;
34691 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
34692 index 8d082b4..aa749ae 100644
34693 --- a/drivers/misc/sgi-xp/xpc_main.c
34694 +++ b/drivers/misc/sgi-xp/xpc_main.c
34695 @@ -162,7 +162,7 @@ static struct notifier_block xpc_die_notifier = {
34696 .notifier_call = xpc_system_die,
34697 };
34698
34699 -struct xpc_arch_operations xpc_arch_ops;
34700 +xpc_arch_operations_no_const xpc_arch_ops;
34701
34702 /*
34703 * Timer function to enforce the timelimit on the partition disengage.
34704 diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
34705 index 6ebdc40..9edf5d8 100644
34706 --- a/drivers/mmc/host/sdhci-pci.c
34707 +++ b/drivers/mmc/host/sdhci-pci.c
34708 @@ -631,7 +631,7 @@ static const struct sdhci_pci_fixes sdhci_via = {
34709 .probe = via_probe,
34710 };
34711
34712 -static const struct pci_device_id pci_ids[] __devinitdata = {
34713 +static const struct pci_device_id pci_ids[] __devinitconst = {
34714 {
34715 .vendor = PCI_VENDOR_ID_RICOH,
34716 .device = PCI_DEVICE_ID_RICOH_R5C822,
34717 diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
34718 index 87a431c..4959b43 100644
34719 --- a/drivers/mtd/devices/doc2000.c
34720 +++ b/drivers/mtd/devices/doc2000.c
34721 @@ -764,7 +764,7 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
34722
34723 /* The ECC will not be calculated correctly if less than 512 is written */
34724 /* DBB-
34725 - if (len != 0x200 && eccbuf)
34726 + if (len != 0x200)
34727 printk(KERN_WARNING
34728 "ECC needs a full sector write (adr: %lx size %lx)\n",
34729 (long) to, (long) len);
34730 diff --git a/drivers/mtd/devices/doc2001.c b/drivers/mtd/devices/doc2001.c
34731 index 9eacf67..4534b5b 100644
34732 --- a/drivers/mtd/devices/doc2001.c
34733 +++ b/drivers/mtd/devices/doc2001.c
34734 @@ -384,7 +384,7 @@ static int doc_read (struct mtd_info *mtd, loff_t from, size_t len,
34735 struct Nand *mychip = &this->chips[from >> (this->chipshift)];
34736
34737 /* Don't allow read past end of device */
34738 - if (from >= this->totlen)
34739 + if (from >= this->totlen || !len)
34740 return -EINVAL;
34741
34742 /* Don't allow a single read to cross a 512-byte block boundary */
34743 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
34744 index 3984d48..28aa897 100644
34745 --- a/drivers/mtd/nand/denali.c
34746 +++ b/drivers/mtd/nand/denali.c
34747 @@ -26,6 +26,7 @@
34748 #include <linux/pci.h>
34749 #include <linux/mtd/mtd.h>
34750 #include <linux/module.h>
34751 +#include <linux/slab.h>
34752
34753 #include "denali.h"
34754
34755 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
34756 index 51b9d6a..52af9a7 100644
34757 --- a/drivers/mtd/nftlmount.c
34758 +++ b/drivers/mtd/nftlmount.c
34759 @@ -24,6 +24,7 @@
34760 #include <asm/errno.h>
34761 #include <linux/delay.h>
34762 #include <linux/slab.h>
34763 +#include <linux/sched.h>
34764 #include <linux/mtd/mtd.h>
34765 #include <linux/mtd/nand.h>
34766 #include <linux/mtd/nftl.h>
34767 diff --git a/drivers/net/ethernet/atheros/atlx/atl2.c b/drivers/net/ethernet/atheros/atlx/atl2.c
34768 index 071f4c8..440862e 100644
34769 --- a/drivers/net/ethernet/atheros/atlx/atl2.c
34770 +++ b/drivers/net/ethernet/atheros/atlx/atl2.c
34771 @@ -2862,7 +2862,7 @@ static void atl2_force_ps(struct atl2_hw *hw)
34772 */
34773
34774 #define ATL2_PARAM(X, desc) \
34775 - static const int __devinitdata X[ATL2_MAX_NIC + 1] = ATL2_PARAM_INIT; \
34776 + static const int __devinitconst X[ATL2_MAX_NIC + 1] = ATL2_PARAM_INIT; \
34777 MODULE_PARM(X, "1-" __MODULE_STRING(ATL2_MAX_NIC) "i"); \
34778 MODULE_PARM_DESC(X, desc);
34779 #else
34780 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
34781 index 66da39f..5dc436d 100644
34782 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
34783 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
34784 @@ -473,7 +473,7 @@ struct bnx2x_rx_mode_obj {
34785
34786 int (*wait_comp)(struct bnx2x *bp,
34787 struct bnx2x_rx_mode_ramrod_params *p);
34788 -};
34789 +} __no_const;
34790
34791 /********************** Set multicast group ***********************************/
34792
34793 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
34794 index aea8f72..fcebf75 100644
34795 --- a/drivers/net/ethernet/broadcom/tg3.h
34796 +++ b/drivers/net/ethernet/broadcom/tg3.h
34797 @@ -140,6 +140,7 @@
34798 #define CHIPREV_ID_5750_A0 0x4000
34799 #define CHIPREV_ID_5750_A1 0x4001
34800 #define CHIPREV_ID_5750_A3 0x4003
34801 +#define CHIPREV_ID_5750_C1 0x4201
34802 #define CHIPREV_ID_5750_C2 0x4202
34803 #define CHIPREV_ID_5752_A0_HW 0x5000
34804 #define CHIPREV_ID_5752_A0 0x6000
34805 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
34806 index c4e8643..0979484 100644
34807 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
34808 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
34809 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
34810 */
34811 struct l2t_skb_cb {
34812 arp_failure_handler_func arp_failure_handler;
34813 -};
34814 +} __no_const;
34815
34816 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
34817
34818 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
34819 index 4d71f5a..8004440 100644
34820 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
34821 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
34822 @@ -5392,7 +5392,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
34823 for (i=0; i<ETH_ALEN; i++) {
34824 tmp.addr[i] = dev->dev_addr[i];
34825 }
34826 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
34827 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
34828 break;
34829
34830 case DE4X5_SET_HWADDR: /* Set the hardware address */
34831 @@ -5432,7 +5432,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
34832 spin_lock_irqsave(&lp->lock, flags);
34833 memcpy(&statbuf, &lp->pktStats, ioc->len);
34834 spin_unlock_irqrestore(&lp->lock, flags);
34835 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
34836 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
34837 return -EFAULT;
34838 break;
34839 }
34840 diff --git a/drivers/net/ethernet/dec/tulip/eeprom.c b/drivers/net/ethernet/dec/tulip/eeprom.c
34841 index 14d5b61..1398636 100644
34842 --- a/drivers/net/ethernet/dec/tulip/eeprom.c
34843 +++ b/drivers/net/ethernet/dec/tulip/eeprom.c
34844 @@ -79,7 +79,7 @@ static struct eeprom_fixup eeprom_fixups[] __devinitdata = {
34845 {NULL}};
34846
34847
34848 -static const char *block_name[] __devinitdata = {
34849 +static const char *block_name[] __devinitconst = {
34850 "21140 non-MII",
34851 "21140 MII PHY",
34852 "21142 Serial PHY",
34853 diff --git a/drivers/net/ethernet/dec/tulip/winbond-840.c b/drivers/net/ethernet/dec/tulip/winbond-840.c
34854 index 52da7b2..4ddfe1c 100644
34855 --- a/drivers/net/ethernet/dec/tulip/winbond-840.c
34856 +++ b/drivers/net/ethernet/dec/tulip/winbond-840.c
34857 @@ -236,7 +236,7 @@ struct pci_id_info {
34858 int drv_flags; /* Driver use, intended as capability flags. */
34859 };
34860
34861 -static const struct pci_id_info pci_id_tbl[] __devinitdata = {
34862 +static const struct pci_id_info pci_id_tbl[] __devinitconst = {
34863 { /* Sometime a Level-One switch card. */
34864 "Winbond W89c840", CanHaveMII | HasBrokenTx | FDXOnNoMII},
34865 { "Winbond W89c840", CanHaveMII | HasBrokenTx},
34866 diff --git a/drivers/net/ethernet/dlink/sundance.c b/drivers/net/ethernet/dlink/sundance.c
34867 index 28a3a9b..d96cb63 100644
34868 --- a/drivers/net/ethernet/dlink/sundance.c
34869 +++ b/drivers/net/ethernet/dlink/sundance.c
34870 @@ -218,7 +218,7 @@ enum {
34871 struct pci_id_info {
34872 const char *name;
34873 };
34874 -static const struct pci_id_info pci_id_tbl[] __devinitdata = {
34875 +static const struct pci_id_info pci_id_tbl[] __devinitconst = {
34876 {"D-Link DFE-550TX FAST Ethernet Adapter"},
34877 {"D-Link DFE-550FX 100Mbps Fiber-optics Adapter"},
34878 {"D-Link DFE-580TX 4 port Server Adapter"},
34879 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
34880 index e703d64..d62ecf9 100644
34881 --- a/drivers/net/ethernet/emulex/benet/be_main.c
34882 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
34883 @@ -402,7 +402,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
34884
34885 if (wrapped)
34886 newacc += 65536;
34887 - ACCESS_ONCE(*acc) = newacc;
34888 + ACCESS_ONCE_RW(*acc) = newacc;
34889 }
34890
34891 void be_parse_stats(struct be_adapter *adapter)
34892 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
34893 index 47f85c3..82ab6c4 100644
34894 --- a/drivers/net/ethernet/faraday/ftgmac100.c
34895 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
34896 @@ -31,6 +31,8 @@
34897 #include <linux/netdevice.h>
34898 #include <linux/phy.h>
34899 #include <linux/platform_device.h>
34900 +#include <linux/interrupt.h>
34901 +#include <linux/irqreturn.h>
34902 #include <net/ip.h>
34903
34904 #include "ftgmac100.h"
34905 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
34906 index bb336a0..4b472da 100644
34907 --- a/drivers/net/ethernet/faraday/ftmac100.c
34908 +++ b/drivers/net/ethernet/faraday/ftmac100.c
34909 @@ -31,6 +31,8 @@
34910 #include <linux/module.h>
34911 #include <linux/netdevice.h>
34912 #include <linux/platform_device.h>
34913 +#include <linux/interrupt.h>
34914 +#include <linux/irqreturn.h>
34915
34916 #include "ftmac100.h"
34917
34918 diff --git a/drivers/net/ethernet/fealnx.c b/drivers/net/ethernet/fealnx.c
34919 index c82d444..0007fb4 100644
34920 --- a/drivers/net/ethernet/fealnx.c
34921 +++ b/drivers/net/ethernet/fealnx.c
34922 @@ -150,7 +150,7 @@ struct chip_info {
34923 int flags;
34924 };
34925
34926 -static const struct chip_info skel_netdrv_tbl[] __devinitdata = {
34927 +static const struct chip_info skel_netdrv_tbl[] __devinitconst = {
34928 { "100/10M Ethernet PCI Adapter", HAS_MII_XCVR },
34929 { "100/10M Ethernet PCI Adapter", HAS_CHIP_XCVR },
34930 { "1000/100/10M Ethernet PCI Adapter", HAS_MII_XCVR },
34931 diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.c b/drivers/net/ethernet/intel/e1000e/80003es2lan.c
34932 index e1159e5..e18684d 100644
34933 --- a/drivers/net/ethernet/intel/e1000e/80003es2lan.c
34934 +++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.c
34935 @@ -205,7 +205,7 @@ static s32 e1000_init_mac_params_80003es2lan(struct e1000_adapter *adapter)
34936 {
34937 struct e1000_hw *hw = &adapter->hw;
34938 struct e1000_mac_info *mac = &hw->mac;
34939 - struct e1000_mac_operations *func = &mac->ops;
34940 + e1000_mac_operations_no_const *func = &mac->ops;
34941
34942 /* Set media type */
34943 switch (adapter->pdev->device) {
34944 diff --git a/drivers/net/ethernet/intel/e1000e/82571.c b/drivers/net/ethernet/intel/e1000e/82571.c
34945 index a3e65fd..f451444 100644
34946 --- a/drivers/net/ethernet/intel/e1000e/82571.c
34947 +++ b/drivers/net/ethernet/intel/e1000e/82571.c
34948 @@ -239,7 +239,7 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter)
34949 {
34950 struct e1000_hw *hw = &adapter->hw;
34951 struct e1000_mac_info *mac = &hw->mac;
34952 - struct e1000_mac_operations *func = &mac->ops;
34953 + e1000_mac_operations_no_const *func = &mac->ops;
34954 u32 swsm = 0;
34955 u32 swsm2 = 0;
34956 bool force_clear_smbi = false;
34957 diff --git a/drivers/net/ethernet/intel/e1000e/hw.h b/drivers/net/ethernet/intel/e1000e/hw.h
34958 index 2967039..ca8c40c 100644
34959 --- a/drivers/net/ethernet/intel/e1000e/hw.h
34960 +++ b/drivers/net/ethernet/intel/e1000e/hw.h
34961 @@ -778,6 +778,7 @@ struct e1000_mac_operations {
34962 void (*write_vfta)(struct e1000_hw *, u32, u32);
34963 s32 (*read_mac_addr)(struct e1000_hw *);
34964 };
34965 +typedef struct e1000_mac_operations __no_const e1000_mac_operations_no_const;
34966
34967 /*
34968 * When to use various PHY register access functions:
34969 @@ -818,6 +819,7 @@ struct e1000_phy_operations {
34970 void (*power_up)(struct e1000_hw *);
34971 void (*power_down)(struct e1000_hw *);
34972 };
34973 +typedef struct e1000_phy_operations __no_const e1000_phy_operations_no_const;
34974
34975 /* Function pointers for the NVM. */
34976 struct e1000_nvm_operations {
34977 @@ -829,9 +831,10 @@ struct e1000_nvm_operations {
34978 s32 (*validate)(struct e1000_hw *);
34979 s32 (*write)(struct e1000_hw *, u16, u16, u16 *);
34980 };
34981 +typedef struct e1000_nvm_operations __no_const e1000_nvm_operations_no_const;
34982
34983 struct e1000_mac_info {
34984 - struct e1000_mac_operations ops;
34985 + e1000_mac_operations_no_const ops;
34986 u8 addr[ETH_ALEN];
34987 u8 perm_addr[ETH_ALEN];
34988
34989 @@ -872,7 +875,7 @@ struct e1000_mac_info {
34990 };
34991
34992 struct e1000_phy_info {
34993 - struct e1000_phy_operations ops;
34994 + e1000_phy_operations_no_const ops;
34995
34996 enum e1000_phy_type type;
34997
34998 @@ -906,7 +909,7 @@ struct e1000_phy_info {
34999 };
35000
35001 struct e1000_nvm_info {
35002 - struct e1000_nvm_operations ops;
35003 + e1000_nvm_operations_no_const ops;
35004
35005 enum e1000_nvm_type type;
35006 enum e1000_nvm_override override;
35007 diff --git a/drivers/net/ethernet/intel/igb/e1000_hw.h b/drivers/net/ethernet/intel/igb/e1000_hw.h
35008 index f67cbd3..cef9e3d 100644
35009 --- a/drivers/net/ethernet/intel/igb/e1000_hw.h
35010 +++ b/drivers/net/ethernet/intel/igb/e1000_hw.h
35011 @@ -314,6 +314,7 @@ struct e1000_mac_operations {
35012 s32 (*read_mac_addr)(struct e1000_hw *);
35013 s32 (*get_speed_and_duplex)(struct e1000_hw *, u16 *, u16 *);
35014 };
35015 +typedef struct e1000_mac_operations __no_const e1000_mac_operations_no_const;
35016
35017 struct e1000_phy_operations {
35018 s32 (*acquire)(struct e1000_hw *);
35019 @@ -330,6 +331,7 @@ struct e1000_phy_operations {
35020 s32 (*set_d3_lplu_state)(struct e1000_hw *, bool);
35021 s32 (*write_reg)(struct e1000_hw *, u32, u16);
35022 };
35023 +typedef struct e1000_phy_operations __no_const e1000_phy_operations_no_const;
35024
35025 struct e1000_nvm_operations {
35026 s32 (*acquire)(struct e1000_hw *);
35027 @@ -339,6 +341,7 @@ struct e1000_nvm_operations {
35028 s32 (*update)(struct e1000_hw *);
35029 s32 (*validate)(struct e1000_hw *);
35030 };
35031 +typedef struct e1000_nvm_operations __no_const e1000_nvm_operations_no_const;
35032
35033 struct e1000_info {
35034 s32 (*get_invariants)(struct e1000_hw *);
35035 @@ -350,7 +353,7 @@ struct e1000_info {
35036 extern const struct e1000_info e1000_82575_info;
35037
35038 struct e1000_mac_info {
35039 - struct e1000_mac_operations ops;
35040 + e1000_mac_operations_no_const ops;
35041
35042 u8 addr[6];
35043 u8 perm_addr[6];
35044 @@ -388,7 +391,7 @@ struct e1000_mac_info {
35045 };
35046
35047 struct e1000_phy_info {
35048 - struct e1000_phy_operations ops;
35049 + e1000_phy_operations_no_const ops;
35050
35051 enum e1000_phy_type type;
35052
35053 @@ -423,7 +426,7 @@ struct e1000_phy_info {
35054 };
35055
35056 struct e1000_nvm_info {
35057 - struct e1000_nvm_operations ops;
35058 + e1000_nvm_operations_no_const ops;
35059 enum e1000_nvm_type type;
35060 enum e1000_nvm_override override;
35061
35062 @@ -468,6 +471,7 @@ struct e1000_mbx_operations {
35063 s32 (*check_for_ack)(struct e1000_hw *, u16);
35064 s32 (*check_for_rst)(struct e1000_hw *, u16);
35065 };
35066 +typedef struct e1000_mbx_operations __no_const e1000_mbx_operations_no_const;
35067
35068 struct e1000_mbx_stats {
35069 u32 msgs_tx;
35070 @@ -479,7 +483,7 @@ struct e1000_mbx_stats {
35071 };
35072
35073 struct e1000_mbx_info {
35074 - struct e1000_mbx_operations ops;
35075 + e1000_mbx_operations_no_const ops;
35076 struct e1000_mbx_stats stats;
35077 u32 timeout;
35078 u32 usec_delay;
35079 diff --git a/drivers/net/ethernet/intel/igbvf/vf.h b/drivers/net/ethernet/intel/igbvf/vf.h
35080 index 57db3c6..aa825fc 100644
35081 --- a/drivers/net/ethernet/intel/igbvf/vf.h
35082 +++ b/drivers/net/ethernet/intel/igbvf/vf.h
35083 @@ -189,9 +189,10 @@ struct e1000_mac_operations {
35084 s32 (*read_mac_addr)(struct e1000_hw *);
35085 s32 (*set_vfta)(struct e1000_hw *, u16, bool);
35086 };
35087 +typedef struct e1000_mac_operations __no_const e1000_mac_operations_no_const;
35088
35089 struct e1000_mac_info {
35090 - struct e1000_mac_operations ops;
35091 + e1000_mac_operations_no_const ops;
35092 u8 addr[6];
35093 u8 perm_addr[6];
35094
35095 @@ -213,6 +214,7 @@ struct e1000_mbx_operations {
35096 s32 (*check_for_ack)(struct e1000_hw *);
35097 s32 (*check_for_rst)(struct e1000_hw *);
35098 };
35099 +typedef struct e1000_mbx_operations __no_const e1000_mbx_operations_no_const;
35100
35101 struct e1000_mbx_stats {
35102 u32 msgs_tx;
35103 @@ -224,7 +226,7 @@ struct e1000_mbx_stats {
35104 };
35105
35106 struct e1000_mbx_info {
35107 - struct e1000_mbx_operations ops;
35108 + e1000_mbx_operations_no_const ops;
35109 struct e1000_mbx_stats stats;
35110 u32 timeout;
35111 u32 usec_delay;
35112 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
35113 index 9b95bef..7e254ee 100644
35114 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
35115 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
35116 @@ -2708,6 +2708,7 @@ struct ixgbe_eeprom_operations {
35117 s32 (*update_checksum)(struct ixgbe_hw *);
35118 u16 (*calc_checksum)(struct ixgbe_hw *);
35119 };
35120 +typedef struct ixgbe_eeprom_operations __no_const ixgbe_eeprom_operations_no_const;
35121
35122 struct ixgbe_mac_operations {
35123 s32 (*init_hw)(struct ixgbe_hw *);
35124 @@ -2769,6 +2770,7 @@ struct ixgbe_mac_operations {
35125 /* Manageability interface */
35126 s32 (*set_fw_drv_ver)(struct ixgbe_hw *, u8, u8, u8, u8);
35127 };
35128 +typedef struct ixgbe_mac_operations __no_const ixgbe_mac_operations_no_const;
35129
35130 struct ixgbe_phy_operations {
35131 s32 (*identify)(struct ixgbe_hw *);
35132 @@ -2788,9 +2790,10 @@ struct ixgbe_phy_operations {
35133 s32 (*write_i2c_eeprom)(struct ixgbe_hw *, u8, u8);
35134 s32 (*check_overtemp)(struct ixgbe_hw *);
35135 };
35136 +typedef struct ixgbe_phy_operations __no_const ixgbe_phy_operations_no_const;
35137
35138 struct ixgbe_eeprom_info {
35139 - struct ixgbe_eeprom_operations ops;
35140 + ixgbe_eeprom_operations_no_const ops;
35141 enum ixgbe_eeprom_type type;
35142 u32 semaphore_delay;
35143 u16 word_size;
35144 @@ -2800,7 +2803,7 @@ struct ixgbe_eeprom_info {
35145
35146 #define IXGBE_FLAGS_DOUBLE_RESET_REQUIRED 0x01
35147 struct ixgbe_mac_info {
35148 - struct ixgbe_mac_operations ops;
35149 + ixgbe_mac_operations_no_const ops;
35150 enum ixgbe_mac_type type;
35151 u8 addr[ETH_ALEN];
35152 u8 perm_addr[ETH_ALEN];
35153 @@ -2828,7 +2831,7 @@ struct ixgbe_mac_info {
35154 };
35155
35156 struct ixgbe_phy_info {
35157 - struct ixgbe_phy_operations ops;
35158 + ixgbe_phy_operations_no_const ops;
35159 struct mdio_if_info mdio;
35160 enum ixgbe_phy_type type;
35161 u32 id;
35162 @@ -2856,6 +2859,7 @@ struct ixgbe_mbx_operations {
35163 s32 (*check_for_ack)(struct ixgbe_hw *, u16);
35164 s32 (*check_for_rst)(struct ixgbe_hw *, u16);
35165 };
35166 +typedef struct ixgbe_mbx_operations __no_const ixgbe_mbx_operations_no_const;
35167
35168 struct ixgbe_mbx_stats {
35169 u32 msgs_tx;
35170 @@ -2867,7 +2871,7 @@ struct ixgbe_mbx_stats {
35171 };
35172
35173 struct ixgbe_mbx_info {
35174 - struct ixgbe_mbx_operations ops;
35175 + ixgbe_mbx_operations_no_const ops;
35176 struct ixgbe_mbx_stats stats;
35177 u32 timeout;
35178 u32 usec_delay;
35179 diff --git a/drivers/net/ethernet/intel/ixgbevf/vf.h b/drivers/net/ethernet/intel/ixgbevf/vf.h
35180 index 25c951d..cc7cf33 100644
35181 --- a/drivers/net/ethernet/intel/ixgbevf/vf.h
35182 +++ b/drivers/net/ethernet/intel/ixgbevf/vf.h
35183 @@ -70,6 +70,7 @@ struct ixgbe_mac_operations {
35184 s32 (*clear_vfta)(struct ixgbe_hw *);
35185 s32 (*set_vfta)(struct ixgbe_hw *, u32, u32, bool);
35186 };
35187 +typedef struct ixgbe_mac_operations __no_const ixgbe_mac_operations_no_const;
35188
35189 enum ixgbe_mac_type {
35190 ixgbe_mac_unknown = 0,
35191 @@ -79,7 +80,7 @@ enum ixgbe_mac_type {
35192 };
35193
35194 struct ixgbe_mac_info {
35195 - struct ixgbe_mac_operations ops;
35196 + ixgbe_mac_operations_no_const ops;
35197 u8 addr[6];
35198 u8 perm_addr[6];
35199
35200 @@ -103,6 +104,7 @@ struct ixgbe_mbx_operations {
35201 s32 (*check_for_ack)(struct ixgbe_hw *);
35202 s32 (*check_for_rst)(struct ixgbe_hw *);
35203 };
35204 +typedef struct ixgbe_mbx_operations __no_const ixgbe_mbx_operations_no_const;
35205
35206 struct ixgbe_mbx_stats {
35207 u32 msgs_tx;
35208 @@ -114,7 +116,7 @@ struct ixgbe_mbx_stats {
35209 };
35210
35211 struct ixgbe_mbx_info {
35212 - struct ixgbe_mbx_operations ops;
35213 + ixgbe_mbx_operations_no_const ops;
35214 struct ixgbe_mbx_stats stats;
35215 u32 timeout;
35216 u32 udelay;
35217 diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
35218 index 8bf22b6..7f5baaa 100644
35219 --- a/drivers/net/ethernet/mellanox/mlx4/main.c
35220 +++ b/drivers/net/ethernet/mellanox/mlx4/main.c
35221 @@ -41,6 +41,7 @@
35222 #include <linux/slab.h>
35223 #include <linux/io-mapping.h>
35224 #include <linux/delay.h>
35225 +#include <linux/sched.h>
35226
35227 #include <linux/mlx4/device.h>
35228 #include <linux/mlx4/doorbell.h>
35229 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.h b/drivers/net/ethernet/neterion/vxge/vxge-config.h
35230 index 5046a64..71ca936 100644
35231 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.h
35232 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.h
35233 @@ -514,7 +514,7 @@ struct vxge_hw_uld_cbs {
35234 void (*link_down)(struct __vxge_hw_device *devh);
35235 void (*crit_err)(struct __vxge_hw_device *devh,
35236 enum vxge_hw_event type, u64 ext_data);
35237 -};
35238 +} __no_const;
35239
35240 /*
35241 * struct __vxge_hw_blockpool_entry - Block private data structure
35242 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-traffic.h b/drivers/net/ethernet/neterion/vxge/vxge-traffic.h
35243 index 4a518a3..936b334 100644
35244 --- a/drivers/net/ethernet/neterion/vxge/vxge-traffic.h
35245 +++ b/drivers/net/ethernet/neterion/vxge/vxge-traffic.h
35246 @@ -2088,7 +2088,7 @@ struct vxge_hw_mempool_cbs {
35247 struct vxge_hw_mempool_dma *dma_object,
35248 u32 index,
35249 u32 is_last);
35250 -};
35251 +} __no_const;
35252
35253 #define VXGE_HW_VIRTUAL_PATH_HANDLE(vpath) \
35254 ((struct __vxge_hw_vpath_handle *)(vpath)->vpath_handles.next)
35255 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
35256 index bbacb37..d60887d 100644
35257 --- a/drivers/net/ethernet/realtek/r8169.c
35258 +++ b/drivers/net/ethernet/realtek/r8169.c
35259 @@ -695,17 +695,17 @@ struct rtl8169_private {
35260 struct mdio_ops {
35261 void (*write)(void __iomem *, int, int);
35262 int (*read)(void __iomem *, int);
35263 - } mdio_ops;
35264 + } __no_const mdio_ops;
35265
35266 struct pll_power_ops {
35267 void (*down)(struct rtl8169_private *);
35268 void (*up)(struct rtl8169_private *);
35269 - } pll_power_ops;
35270 + } __no_const pll_power_ops;
35271
35272 struct jumbo_ops {
35273 void (*enable)(struct rtl8169_private *);
35274 void (*disable)(struct rtl8169_private *);
35275 - } jumbo_ops;
35276 + } __no_const jumbo_ops;
35277
35278 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
35279 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
35280 diff --git a/drivers/net/ethernet/sis/sis190.c b/drivers/net/ethernet/sis/sis190.c
35281 index 5b118cd..858b523 100644
35282 --- a/drivers/net/ethernet/sis/sis190.c
35283 +++ b/drivers/net/ethernet/sis/sis190.c
35284 @@ -1622,7 +1622,7 @@ static int __devinit sis190_get_mac_addr_from_eeprom(struct pci_dev *pdev,
35285 static int __devinit sis190_get_mac_addr_from_apc(struct pci_dev *pdev,
35286 struct net_device *dev)
35287 {
35288 - static const u16 __devinitdata ids[] = { 0x0965, 0x0966, 0x0968 };
35289 + static const u16 __devinitconst ids[] = { 0x0965, 0x0966, 0x0968 };
35290 struct sis190_private *tp = netdev_priv(dev);
35291 struct pci_dev *isa_bridge;
35292 u8 reg, tmp8;
35293 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
35294 index c07cfe9..81cbf7e 100644
35295 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
35296 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
35297 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
35298
35299 writel(value, ioaddr + MMC_CNTRL);
35300
35301 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
35302 - MMC_CNTRL, value);
35303 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
35304 +// MMC_CNTRL, value);
35305 }
35306
35307 /* To mask all all interrupts.*/
35308 diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
35309 index 6ee593a..3f513b1 100644
35310 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
35311 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
35312 @@ -1585,7 +1585,7 @@ static const struct file_operations stmmac_rings_status_fops = {
35313 .open = stmmac_sysfs_ring_open,
35314 .read = seq_read,
35315 .llseek = seq_lseek,
35316 - .release = seq_release,
35317 + .release = single_release,
35318 };
35319
35320 static int stmmac_sysfs_dma_cap_read(struct seq_file *seq, void *v)
35321 @@ -1657,7 +1657,7 @@ static const struct file_operations stmmac_dma_cap_fops = {
35322 .open = stmmac_sysfs_dma_cap_open,
35323 .read = seq_read,
35324 .llseek = seq_lseek,
35325 - .release = seq_release,
35326 + .release = single_release,
35327 };
35328
35329 static int stmmac_init_fs(struct net_device *dev)
35330 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
35331 index dec5836..6d4db7d 100644
35332 --- a/drivers/net/hyperv/hyperv_net.h
35333 +++ b/drivers/net/hyperv/hyperv_net.h
35334 @@ -97,7 +97,7 @@ struct rndis_device {
35335
35336 enum rndis_device_state state;
35337 bool link_state;
35338 - atomic_t new_req_id;
35339 + atomic_unchecked_t new_req_id;
35340
35341 spinlock_t request_lock;
35342 struct list_head req_list;
35343 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
35344 index 133b7fb..d58c559 100644
35345 --- a/drivers/net/hyperv/rndis_filter.c
35346 +++ b/drivers/net/hyperv/rndis_filter.c
35347 @@ -96,7 +96,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
35348 * template
35349 */
35350 set = &rndis_msg->msg.set_req;
35351 - set->req_id = atomic_inc_return(&dev->new_req_id);
35352 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
35353
35354 /* Add to the request list */
35355 spin_lock_irqsave(&dev->request_lock, flags);
35356 @@ -627,7 +627,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
35357
35358 /* Setup the rndis set */
35359 halt = &request->request_msg.msg.halt_req;
35360 - halt->req_id = atomic_inc_return(&dev->new_req_id);
35361 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
35362
35363 /* Ignore return since this msg is optional. */
35364 rndis_filter_send_request(dev, request);
35365 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
35366 index 58dc117..f140c77 100644
35367 --- a/drivers/net/macvtap.c
35368 +++ b/drivers/net/macvtap.c
35369 @@ -526,6 +526,8 @@ static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from,
35370 }
35371 base = (unsigned long)from->iov_base + offset1;
35372 size = ((base & ~PAGE_MASK) + len + ~PAGE_MASK) >> PAGE_SHIFT;
35373 + if (i + size >= MAX_SKB_FRAGS)
35374 + return -EFAULT;
35375 num_pages = get_user_pages_fast(base, size, 0, &page[i]);
35376 if ((num_pages != size) ||
35377 (num_pages > MAX_SKB_FRAGS - skb_shinfo(skb)->nr_frags))
35378 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
35379 index 3ed983c..a1bb418 100644
35380 --- a/drivers/net/ppp/ppp_generic.c
35381 +++ b/drivers/net/ppp/ppp_generic.c
35382 @@ -986,7 +986,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
35383 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
35384 struct ppp_stats stats;
35385 struct ppp_comp_stats cstats;
35386 - char *vers;
35387
35388 switch (cmd) {
35389 case SIOCGPPPSTATS:
35390 @@ -1008,8 +1007,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
35391 break;
35392
35393 case SIOCGPPPVER:
35394 - vers = PPP_VERSION;
35395 - if (copy_to_user(addr, vers, strlen(vers) + 1))
35396 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
35397 break;
35398 err = 0;
35399 break;
35400 diff --git a/drivers/net/tokenring/abyss.c b/drivers/net/tokenring/abyss.c
35401 index 515f122..41dd273 100644
35402 --- a/drivers/net/tokenring/abyss.c
35403 +++ b/drivers/net/tokenring/abyss.c
35404 @@ -451,10 +451,12 @@ static struct pci_driver abyss_driver = {
35405
35406 static int __init abyss_init (void)
35407 {
35408 - abyss_netdev_ops = tms380tr_netdev_ops;
35409 + pax_open_kernel();
35410 + memcpy((void *)&abyss_netdev_ops, &tms380tr_netdev_ops, sizeof(tms380tr_netdev_ops));
35411
35412 - abyss_netdev_ops.ndo_open = abyss_open;
35413 - abyss_netdev_ops.ndo_stop = abyss_close;
35414 + *(void **)&abyss_netdev_ops.ndo_open = abyss_open;
35415 + *(void **)&abyss_netdev_ops.ndo_stop = abyss_close;
35416 + pax_close_kernel();
35417
35418 return pci_register_driver(&abyss_driver);
35419 }
35420 diff --git a/drivers/net/tokenring/madgemc.c b/drivers/net/tokenring/madgemc.c
35421 index 6153cfd..cf69c1c 100644
35422 --- a/drivers/net/tokenring/madgemc.c
35423 +++ b/drivers/net/tokenring/madgemc.c
35424 @@ -744,9 +744,11 @@ static struct mca_driver madgemc_driver = {
35425
35426 static int __init madgemc_init (void)
35427 {
35428 - madgemc_netdev_ops = tms380tr_netdev_ops;
35429 - madgemc_netdev_ops.ndo_open = madgemc_open;
35430 - madgemc_netdev_ops.ndo_stop = madgemc_close;
35431 + pax_open_kernel();
35432 + memcpy((void *)&madgemc_netdev_ops, &tms380tr_netdev_ops, sizeof(tms380tr_netdev_ops));
35433 + *(void **)&madgemc_netdev_ops.ndo_open = madgemc_open;
35434 + *(void **)&madgemc_netdev_ops.ndo_stop = madgemc_close;
35435 + pax_close_kernel();
35436
35437 return mca_register_driver (&madgemc_driver);
35438 }
35439 diff --git a/drivers/net/tokenring/proteon.c b/drivers/net/tokenring/proteon.c
35440 index 8d362e6..f91cc52 100644
35441 --- a/drivers/net/tokenring/proteon.c
35442 +++ b/drivers/net/tokenring/proteon.c
35443 @@ -353,9 +353,11 @@ static int __init proteon_init(void)
35444 struct platform_device *pdev;
35445 int i, num = 0, err = 0;
35446
35447 - proteon_netdev_ops = tms380tr_netdev_ops;
35448 - proteon_netdev_ops.ndo_open = proteon_open;
35449 - proteon_netdev_ops.ndo_stop = tms380tr_close;
35450 + pax_open_kernel();
35451 + memcpy((void *)&proteon_netdev_ops, &tms380tr_netdev_ops, sizeof(tms380tr_netdev_ops));
35452 + *(void **)&proteon_netdev_ops.ndo_open = proteon_open;
35453 + *(void **)&proteon_netdev_ops.ndo_stop = tms380tr_close;
35454 + pax_close_kernel();
35455
35456 err = platform_driver_register(&proteon_driver);
35457 if (err)
35458 diff --git a/drivers/net/tokenring/skisa.c b/drivers/net/tokenring/skisa.c
35459 index 46db5c5..37c1536 100644
35460 --- a/drivers/net/tokenring/skisa.c
35461 +++ b/drivers/net/tokenring/skisa.c
35462 @@ -363,9 +363,11 @@ static int __init sk_isa_init(void)
35463 struct platform_device *pdev;
35464 int i, num = 0, err = 0;
35465
35466 - sk_isa_netdev_ops = tms380tr_netdev_ops;
35467 - sk_isa_netdev_ops.ndo_open = sk_isa_open;
35468 - sk_isa_netdev_ops.ndo_stop = tms380tr_close;
35469 + pax_open_kernel();
35470 + memcpy((void *)&sk_isa_netdev_ops, &tms380tr_netdev_ops, sizeof(tms380tr_netdev_ops));
35471 + *(void **)&sk_isa_netdev_ops.ndo_open = sk_isa_open;
35472 + *(void **)&sk_isa_netdev_ops.ndo_stop = tms380tr_close;
35473 + pax_close_kernel();
35474
35475 err = platform_driver_register(&sk_isa_driver);
35476 if (err)
35477 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
35478 index e1324b4..e1b0041 100644
35479 --- a/drivers/net/usb/hso.c
35480 +++ b/drivers/net/usb/hso.c
35481 @@ -71,7 +71,7 @@
35482 #include <asm/byteorder.h>
35483 #include <linux/serial_core.h>
35484 #include <linux/serial.h>
35485 -
35486 +#include <asm/local.h>
35487
35488 #define MOD_AUTHOR "Option Wireless"
35489 #define MOD_DESCRIPTION "USB High Speed Option driver"
35490 @@ -257,7 +257,7 @@ struct hso_serial {
35491
35492 /* from usb_serial_port */
35493 struct tty_struct *tty;
35494 - int open_count;
35495 + local_t open_count;
35496 spinlock_t serial_lock;
35497
35498 int (*write_data) (struct hso_serial *serial);
35499 @@ -1190,7 +1190,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
35500 struct urb *urb;
35501
35502 urb = serial->rx_urb[0];
35503 - if (serial->open_count > 0) {
35504 + if (local_read(&serial->open_count) > 0) {
35505 count = put_rxbuf_data(urb, serial);
35506 if (count == -1)
35507 return;
35508 @@ -1226,7 +1226,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
35509 DUMP1(urb->transfer_buffer, urb->actual_length);
35510
35511 /* Anyone listening? */
35512 - if (serial->open_count == 0)
35513 + if (local_read(&serial->open_count) == 0)
35514 return;
35515
35516 if (status == 0) {
35517 @@ -1311,8 +1311,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
35518 spin_unlock_irq(&serial->serial_lock);
35519
35520 /* check for port already opened, if not set the termios */
35521 - serial->open_count++;
35522 - if (serial->open_count == 1) {
35523 + if (local_inc_return(&serial->open_count) == 1) {
35524 serial->rx_state = RX_IDLE;
35525 /* Force default termio settings */
35526 _hso_serial_set_termios(tty, NULL);
35527 @@ -1324,7 +1323,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
35528 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
35529 if (result) {
35530 hso_stop_serial_device(serial->parent);
35531 - serial->open_count--;
35532 + local_dec(&serial->open_count);
35533 kref_put(&serial->parent->ref, hso_serial_ref_free);
35534 }
35535 } else {
35536 @@ -1361,10 +1360,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
35537
35538 /* reset the rts and dtr */
35539 /* do the actual close */
35540 - serial->open_count--;
35541 + local_dec(&serial->open_count);
35542
35543 - if (serial->open_count <= 0) {
35544 - serial->open_count = 0;
35545 + if (local_read(&serial->open_count) <= 0) {
35546 + local_set(&serial->open_count, 0);
35547 spin_lock_irq(&serial->serial_lock);
35548 if (serial->tty == tty) {
35549 serial->tty->driver_data = NULL;
35550 @@ -1446,7 +1445,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
35551
35552 /* the actual setup */
35553 spin_lock_irqsave(&serial->serial_lock, flags);
35554 - if (serial->open_count)
35555 + if (local_read(&serial->open_count))
35556 _hso_serial_set_termios(tty, old);
35557 else
35558 tty->termios = old;
35559 @@ -1905,7 +1904,7 @@ static void intr_callback(struct urb *urb)
35560 D1("Pending read interrupt on port %d\n", i);
35561 spin_lock(&serial->serial_lock);
35562 if (serial->rx_state == RX_IDLE &&
35563 - serial->open_count > 0) {
35564 + local_read(&serial->open_count) > 0) {
35565 /* Setup and send a ctrl req read on
35566 * port i */
35567 if (!serial->rx_urb_filled[0]) {
35568 @@ -3098,7 +3097,7 @@ static int hso_resume(struct usb_interface *iface)
35569 /* Start all serial ports */
35570 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
35571 if (serial_table[i] && (serial_table[i]->interface == iface)) {
35572 - if (dev2ser(serial_table[i])->open_count) {
35573 + if (local_read(&dev2ser(serial_table[i])->open_count)) {
35574 result =
35575 hso_start_serial_device(serial_table[i], GFP_NOIO);
35576 hso_kick_transmit(dev2ser(serial_table[i]));
35577 diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h
35578 index efc0111..79c8f5b 100644
35579 --- a/drivers/net/wireless/ath/ath.h
35580 +++ b/drivers/net/wireless/ath/ath.h
35581 @@ -119,6 +119,7 @@ struct ath_ops {
35582 void (*write_flush) (void *);
35583 u32 (*rmw)(void *, u32 reg_offset, u32 set, u32 clr);
35584 };
35585 +typedef struct ath_ops __no_const ath_ops_no_const;
35586
35587 struct ath_common;
35588 struct ath_bus_ops;
35589 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
35590 index 7b6417b..ab5db98 100644
35591 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
35592 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
35593 @@ -183,8 +183,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
35594 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
35595 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
35596
35597 - ACCESS_ONCE(ads->ds_link) = i->link;
35598 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
35599 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
35600 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
35601
35602 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
35603 ctl6 = SM(i->keytype, AR_EncrType);
35604 @@ -198,26 +198,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
35605
35606 if ((i->is_first || i->is_last) &&
35607 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
35608 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
35609 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
35610 | set11nTries(i->rates, 1)
35611 | set11nTries(i->rates, 2)
35612 | set11nTries(i->rates, 3)
35613 | (i->dur_update ? AR_DurUpdateEna : 0)
35614 | SM(0, AR_BurstDur);
35615
35616 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
35617 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
35618 | set11nRate(i->rates, 1)
35619 | set11nRate(i->rates, 2)
35620 | set11nRate(i->rates, 3);
35621 } else {
35622 - ACCESS_ONCE(ads->ds_ctl2) = 0;
35623 - ACCESS_ONCE(ads->ds_ctl3) = 0;
35624 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
35625 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
35626 }
35627
35628 if (!i->is_first) {
35629 - ACCESS_ONCE(ads->ds_ctl0) = 0;
35630 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
35631 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
35632 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
35633 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
35634 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
35635 return;
35636 }
35637
35638 @@ -242,7 +242,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
35639 break;
35640 }
35641
35642 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
35643 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
35644 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
35645 | SM(i->txpower, AR_XmitPower)
35646 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
35647 @@ -252,19 +252,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
35648 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
35649 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
35650
35651 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
35652 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
35653 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
35654 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
35655
35656 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
35657 return;
35658
35659 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
35660 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
35661 | set11nPktDurRTSCTS(i->rates, 1);
35662
35663 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
35664 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
35665 | set11nPktDurRTSCTS(i->rates, 3);
35666
35667 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
35668 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
35669 | set11nRateFlags(i->rates, 1)
35670 | set11nRateFlags(i->rates, 2)
35671 | set11nRateFlags(i->rates, 3)
35672 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
35673 index 09b8c9d..905339e 100644
35674 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
35675 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
35676 @@ -35,47 +35,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
35677 (i->qcu << AR_TxQcuNum_S) | 0x17;
35678
35679 checksum += val;
35680 - ACCESS_ONCE(ads->info) = val;
35681 + ACCESS_ONCE_RW(ads->info) = val;
35682
35683 checksum += i->link;
35684 - ACCESS_ONCE(ads->link) = i->link;
35685 + ACCESS_ONCE_RW(ads->link) = i->link;
35686
35687 checksum += i->buf_addr[0];
35688 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
35689 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
35690 checksum += i->buf_addr[1];
35691 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
35692 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
35693 checksum += i->buf_addr[2];
35694 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
35695 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
35696 checksum += i->buf_addr[3];
35697 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
35698 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
35699
35700 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
35701 - ACCESS_ONCE(ads->ctl3) = val;
35702 + ACCESS_ONCE_RW(ads->ctl3) = val;
35703 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
35704 - ACCESS_ONCE(ads->ctl5) = val;
35705 + ACCESS_ONCE_RW(ads->ctl5) = val;
35706 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
35707 - ACCESS_ONCE(ads->ctl7) = val;
35708 + ACCESS_ONCE_RW(ads->ctl7) = val;
35709 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
35710 - ACCESS_ONCE(ads->ctl9) = val;
35711 + ACCESS_ONCE_RW(ads->ctl9) = val;
35712
35713 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
35714 - ACCESS_ONCE(ads->ctl10) = checksum;
35715 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
35716
35717 if (i->is_first || i->is_last) {
35718 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
35719 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
35720 | set11nTries(i->rates, 1)
35721 | set11nTries(i->rates, 2)
35722 | set11nTries(i->rates, 3)
35723 | (i->dur_update ? AR_DurUpdateEna : 0)
35724 | SM(0, AR_BurstDur);
35725
35726 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
35727 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
35728 | set11nRate(i->rates, 1)
35729 | set11nRate(i->rates, 2)
35730 | set11nRate(i->rates, 3);
35731 } else {
35732 - ACCESS_ONCE(ads->ctl13) = 0;
35733 - ACCESS_ONCE(ads->ctl14) = 0;
35734 + ACCESS_ONCE_RW(ads->ctl13) = 0;
35735 + ACCESS_ONCE_RW(ads->ctl14) = 0;
35736 }
35737
35738 ads->ctl20 = 0;
35739 @@ -84,17 +84,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
35740
35741 ctl17 = SM(i->keytype, AR_EncrType);
35742 if (!i->is_first) {
35743 - ACCESS_ONCE(ads->ctl11) = 0;
35744 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
35745 - ACCESS_ONCE(ads->ctl15) = 0;
35746 - ACCESS_ONCE(ads->ctl16) = 0;
35747 - ACCESS_ONCE(ads->ctl17) = ctl17;
35748 - ACCESS_ONCE(ads->ctl18) = 0;
35749 - ACCESS_ONCE(ads->ctl19) = 0;
35750 + ACCESS_ONCE_RW(ads->ctl11) = 0;
35751 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
35752 + ACCESS_ONCE_RW(ads->ctl15) = 0;
35753 + ACCESS_ONCE_RW(ads->ctl16) = 0;
35754 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
35755 + ACCESS_ONCE_RW(ads->ctl18) = 0;
35756 + ACCESS_ONCE_RW(ads->ctl19) = 0;
35757 return;
35758 }
35759
35760 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
35761 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
35762 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
35763 | SM(i->txpower, AR_XmitPower)
35764 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
35765 @@ -130,22 +130,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
35766 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
35767 ctl12 |= SM(val, AR_PAPRDChainMask);
35768
35769 - ACCESS_ONCE(ads->ctl12) = ctl12;
35770 - ACCESS_ONCE(ads->ctl17) = ctl17;
35771 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
35772 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
35773
35774 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
35775 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
35776 | set11nPktDurRTSCTS(i->rates, 1);
35777
35778 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
35779 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
35780 | set11nPktDurRTSCTS(i->rates, 3);
35781
35782 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
35783 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
35784 | set11nRateFlags(i->rates, 1)
35785 | set11nRateFlags(i->rates, 2)
35786 | set11nRateFlags(i->rates, 3)
35787 | SM(i->rtscts_rate, AR_RTSCTSRate);
35788
35789 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
35790 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
35791 }
35792
35793 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
35794 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
35795 index c8261d4..8d88929 100644
35796 --- a/drivers/net/wireless/ath/ath9k/hw.h
35797 +++ b/drivers/net/wireless/ath/ath9k/hw.h
35798 @@ -773,7 +773,7 @@ struct ath_hw_private_ops {
35799
35800 /* ANI */
35801 void (*ani_cache_ini_regs)(struct ath_hw *ah);
35802 -};
35803 +} __no_const;
35804
35805 /**
35806 * struct ath_hw_ops - callbacks used by hardware code and driver code
35807 @@ -803,7 +803,7 @@ struct ath_hw_ops {
35808 void (*antdiv_comb_conf_set)(struct ath_hw *ah,
35809 struct ath_hw_antcomb_conf *antconf);
35810
35811 -};
35812 +} __no_const;
35813
35814 struct ath_nf_limits {
35815 s16 max;
35816 @@ -823,7 +823,7 @@ enum ath_cal_list {
35817 #define AH_FASTCC 0x4
35818
35819 struct ath_hw {
35820 - struct ath_ops reg_ops;
35821 + ath_ops_no_const reg_ops;
35822
35823 struct ieee80211_hw *hw;
35824 struct ath_common common;
35825 diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h
35826 index af00e2c..ab04d34 100644
35827 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h
35828 +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h
35829 @@ -545,7 +545,7 @@ struct phy_func_ptr {
35830 void (*carrsuppr)(struct brcms_phy *);
35831 s32 (*rxsigpwr)(struct brcms_phy *, s32);
35832 void (*detach)(struct brcms_phy *);
35833 -};
35834 +} __no_const;
35835
35836 struct brcms_phy {
35837 struct brcms_phy_pub pubpi_ro;
35838 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
35839 index a2ec369..36fdf14 100644
35840 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
35841 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
35842 @@ -3646,7 +3646,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
35843 */
35844 if (il3945_mod_params.disable_hw_scan) {
35845 D_INFO("Disabling hw_scan\n");
35846 - il3945_hw_ops.hw_scan = NULL;
35847 + pax_open_kernel();
35848 + *(void **)&il3945_hw_ops.hw_scan = NULL;
35849 + pax_close_kernel();
35850 }
35851
35852 D_INFO("*** LOAD DRIVER ***\n");
35853 diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h
35854 index f8fc239..8cade22 100644
35855 --- a/drivers/net/wireless/iwlwifi/iwl-debug.h
35856 +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h
35857 @@ -86,8 +86,8 @@ do { \
35858 } while (0)
35859
35860 #else
35861 -#define IWL_DEBUG(m, level, fmt, args...)
35862 -#define IWL_DEBUG_LIMIT(m, level, fmt, args...)
35863 +#define IWL_DEBUG(m, level, fmt, args...) do {} while (0)
35864 +#define IWL_DEBUG_LIMIT(m, level, fmt, args...) do {} while (0)
35865 #define iwl_print_hex_dump(m, level, p, len)
35866 #define IWL_DEBUG_QUIET_RFKILL(p, fmt, args...) \
35867 do { \
35868 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
35869 index 4b9e730..7603659 100644
35870 --- a/drivers/net/wireless/mac80211_hwsim.c
35871 +++ b/drivers/net/wireless/mac80211_hwsim.c
35872 @@ -1677,9 +1677,11 @@ static int __init init_mac80211_hwsim(void)
35873 return -EINVAL;
35874
35875 if (fake_hw_scan) {
35876 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
35877 - mac80211_hwsim_ops.sw_scan_start = NULL;
35878 - mac80211_hwsim_ops.sw_scan_complete = NULL;
35879 + pax_open_kernel();
35880 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
35881 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
35882 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
35883 + pax_close_kernel();
35884 }
35885
35886 spin_lock_init(&hwsim_radio_lock);
35887 diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h
35888 index 3186aa4..b35b09f 100644
35889 --- a/drivers/net/wireless/mwifiex/main.h
35890 +++ b/drivers/net/wireless/mwifiex/main.h
35891 @@ -536,7 +536,7 @@ struct mwifiex_if_ops {
35892 void (*cleanup_mpa_buf) (struct mwifiex_adapter *);
35893 int (*cmdrsp_complete) (struct mwifiex_adapter *, struct sk_buff *);
35894 int (*event_complete) (struct mwifiex_adapter *, struct sk_buff *);
35895 -};
35896 +} __no_const;
35897
35898 struct mwifiex_adapter {
35899 u8 iface_type;
35900 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
35901 index a330c69..a81540f 100644
35902 --- a/drivers/net/wireless/rndis_wlan.c
35903 +++ b/drivers/net/wireless/rndis_wlan.c
35904 @@ -1278,7 +1278,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
35905
35906 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
35907
35908 - if (rts_threshold < 0 || rts_threshold > 2347)
35909 + if (rts_threshold > 2347)
35910 rts_threshold = 2347;
35911
35912 tmp = cpu_to_le32(rts_threshold);
35913 diff --git a/drivers/net/wireless/wl1251/wl1251.h b/drivers/net/wireless/wl1251/wl1251.h
35914 index a77f1bb..c608b2b 100644
35915 --- a/drivers/net/wireless/wl1251/wl1251.h
35916 +++ b/drivers/net/wireless/wl1251/wl1251.h
35917 @@ -266,7 +266,7 @@ struct wl1251_if_operations {
35918 void (*reset)(struct wl1251 *wl);
35919 void (*enable_irq)(struct wl1251 *wl);
35920 void (*disable_irq)(struct wl1251 *wl);
35921 -};
35922 +} __no_const;
35923
35924 struct wl1251 {
35925 struct ieee80211_hw *hw;
35926 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
35927 index f34b5b2..b5abb9f 100644
35928 --- a/drivers/oprofile/buffer_sync.c
35929 +++ b/drivers/oprofile/buffer_sync.c
35930 @@ -343,7 +343,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
35931 if (cookie == NO_COOKIE)
35932 offset = pc;
35933 if (cookie == INVALID_COOKIE) {
35934 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
35935 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
35936 offset = pc;
35937 }
35938 if (cookie != last_cookie) {
35939 @@ -387,14 +387,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
35940 /* add userspace sample */
35941
35942 if (!mm) {
35943 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
35944 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
35945 return 0;
35946 }
35947
35948 cookie = lookup_dcookie(mm, s->eip, &offset);
35949
35950 if (cookie == INVALID_COOKIE) {
35951 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
35952 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
35953 return 0;
35954 }
35955
35956 @@ -563,7 +563,7 @@ void sync_buffer(int cpu)
35957 /* ignore backtraces if failed to add a sample */
35958 if (state == sb_bt_start) {
35959 state = sb_bt_ignore;
35960 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
35961 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
35962 }
35963 }
35964 release_mm(mm);
35965 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
35966 index c0cc4e7..44d4e54 100644
35967 --- a/drivers/oprofile/event_buffer.c
35968 +++ b/drivers/oprofile/event_buffer.c
35969 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
35970 }
35971
35972 if (buffer_pos == buffer_size) {
35973 - atomic_inc(&oprofile_stats.event_lost_overflow);
35974 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
35975 return;
35976 }
35977
35978 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
35979 index ed2c3ec..deda85a 100644
35980 --- a/drivers/oprofile/oprof.c
35981 +++ b/drivers/oprofile/oprof.c
35982 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
35983 if (oprofile_ops.switch_events())
35984 return;
35985
35986 - atomic_inc(&oprofile_stats.multiplex_counter);
35987 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
35988 start_switch_worker();
35989 }
35990
35991 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
35992 index 917d28e..d62d981 100644
35993 --- a/drivers/oprofile/oprofile_stats.c
35994 +++ b/drivers/oprofile/oprofile_stats.c
35995 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
35996 cpu_buf->sample_invalid_eip = 0;
35997 }
35998
35999 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
36000 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
36001 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
36002 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
36003 - atomic_set(&oprofile_stats.multiplex_counter, 0);
36004 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
36005 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
36006 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
36007 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
36008 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
36009 }
36010
36011
36012 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
36013 index 38b6fc0..b5cbfce 100644
36014 --- a/drivers/oprofile/oprofile_stats.h
36015 +++ b/drivers/oprofile/oprofile_stats.h
36016 @@ -13,11 +13,11 @@
36017 #include <linux/atomic.h>
36018
36019 struct oprofile_stat_struct {
36020 - atomic_t sample_lost_no_mm;
36021 - atomic_t sample_lost_no_mapping;
36022 - atomic_t bt_lost_no_mapping;
36023 - atomic_t event_lost_overflow;
36024 - atomic_t multiplex_counter;
36025 + atomic_unchecked_t sample_lost_no_mm;
36026 + atomic_unchecked_t sample_lost_no_mapping;
36027 + atomic_unchecked_t bt_lost_no_mapping;
36028 + atomic_unchecked_t event_lost_overflow;
36029 + atomic_unchecked_t multiplex_counter;
36030 };
36031
36032 extern struct oprofile_stat_struct oprofile_stats;
36033 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
36034 index 2f0aa0f..90fab02 100644
36035 --- a/drivers/oprofile/oprofilefs.c
36036 +++ b/drivers/oprofile/oprofilefs.c
36037 @@ -193,7 +193,7 @@ static const struct file_operations atomic_ro_fops = {
36038
36039
36040 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
36041 - char const *name, atomic_t *val)
36042 + char const *name, atomic_unchecked_t *val)
36043 {
36044 return __oprofilefs_create_file(sb, root, name,
36045 &atomic_ro_fops, 0444, val);
36046 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
36047 index 3f56bc0..707d642 100644
36048 --- a/drivers/parport/procfs.c
36049 +++ b/drivers/parport/procfs.c
36050 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
36051
36052 *ppos += len;
36053
36054 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
36055 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
36056 }
36057
36058 #ifdef CONFIG_PARPORT_1284
36059 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
36060
36061 *ppos += len;
36062
36063 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
36064 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
36065 }
36066 #endif /* IEEE1284.3 support. */
36067
36068 diff --git a/drivers/pci/hotplug/cpci_hotplug.h b/drivers/pci/hotplug/cpci_hotplug.h
36069 index 9fff878..ad0ad53 100644
36070 --- a/drivers/pci/hotplug/cpci_hotplug.h
36071 +++ b/drivers/pci/hotplug/cpci_hotplug.h
36072 @@ -59,7 +59,7 @@ struct cpci_hp_controller_ops {
36073 int (*hardware_test) (struct slot* slot, u32 value);
36074 u8 (*get_power) (struct slot* slot);
36075 int (*set_power) (struct slot* slot, int value);
36076 -};
36077 +} __no_const;
36078
36079 struct cpci_hp_controller {
36080 unsigned int irq;
36081 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
36082 index 76ba8a1..20ca857 100644
36083 --- a/drivers/pci/hotplug/cpqphp_nvram.c
36084 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
36085 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
36086
36087 void compaq_nvram_init (void __iomem *rom_start)
36088 {
36089 +
36090 +#ifndef CONFIG_PAX_KERNEXEC
36091 if (rom_start) {
36092 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
36093 }
36094 +#endif
36095 +
36096 dbg("int15 entry = %p\n", compaq_int15_entry_point);
36097
36098 /* initialize our int15 lock */
36099 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
36100 index 2275162..95f1a92 100644
36101 --- a/drivers/pci/pcie/aspm.c
36102 +++ b/drivers/pci/pcie/aspm.c
36103 @@ -27,9 +27,9 @@
36104 #define MODULE_PARAM_PREFIX "pcie_aspm."
36105
36106 /* Note: those are not register definitions */
36107 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
36108 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
36109 -#define ASPM_STATE_L1 (4) /* L1 state */
36110 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
36111 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
36112 +#define ASPM_STATE_L1 (4U) /* L1 state */
36113 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
36114 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
36115
36116 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
36117 index 71eac9c..2de27ef 100644
36118 --- a/drivers/pci/probe.c
36119 +++ b/drivers/pci/probe.c
36120 @@ -136,7 +136,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
36121 u32 l, sz, mask;
36122 u16 orig_cmd;
36123
36124 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
36125 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
36126
36127 if (!dev->mmio_always_on) {
36128 pci_read_config_word(dev, PCI_COMMAND, &orig_cmd);
36129 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
36130 index 27911b5..5b6db88 100644
36131 --- a/drivers/pci/proc.c
36132 +++ b/drivers/pci/proc.c
36133 @@ -476,7 +476,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
36134 static int __init pci_proc_init(void)
36135 {
36136 struct pci_dev *dev = NULL;
36137 +
36138 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
36139 +#ifdef CONFIG_GRKERNSEC_PROC_USER
36140 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
36141 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
36142 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
36143 +#endif
36144 +#else
36145 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
36146 +#endif
36147 proc_create("devices", 0, proc_bus_pci_dir,
36148 &proc_bus_pci_dev_operations);
36149 proc_initialized = 1;
36150 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
36151 index ea0c607..58c4628 100644
36152 --- a/drivers/platform/x86/thinkpad_acpi.c
36153 +++ b/drivers/platform/x86/thinkpad_acpi.c
36154 @@ -2094,7 +2094,7 @@ static int hotkey_mask_get(void)
36155 return 0;
36156 }
36157
36158 -void static hotkey_mask_warn_incomplete_mask(void)
36159 +static void hotkey_mask_warn_incomplete_mask(void)
36160 {
36161 /* log only what the user can fix... */
36162 const u32 wantedmask = hotkey_driver_mask &
36163 @@ -2325,11 +2325,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
36164 }
36165 }
36166
36167 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
36168 - struct tp_nvram_state *newn,
36169 - const u32 event_mask)
36170 -{
36171 -
36172 #define TPACPI_COMPARE_KEY(__scancode, __member) \
36173 do { \
36174 if ((event_mask & (1 << __scancode)) && \
36175 @@ -2343,36 +2338,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
36176 tpacpi_hotkey_send_key(__scancode); \
36177 } while (0)
36178
36179 - void issue_volchange(const unsigned int oldvol,
36180 - const unsigned int newvol)
36181 - {
36182 - unsigned int i = oldvol;
36183 +static void issue_volchange(const unsigned int oldvol,
36184 + const unsigned int newvol,
36185 + const u32 event_mask)
36186 +{
36187 + unsigned int i = oldvol;
36188
36189 - while (i > newvol) {
36190 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
36191 - i--;
36192 - }
36193 - while (i < newvol) {
36194 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
36195 - i++;
36196 - }
36197 + while (i > newvol) {
36198 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
36199 + i--;
36200 }
36201 + while (i < newvol) {
36202 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
36203 + i++;
36204 + }
36205 +}
36206
36207 - void issue_brightnesschange(const unsigned int oldbrt,
36208 - const unsigned int newbrt)
36209 - {
36210 - unsigned int i = oldbrt;
36211 +static void issue_brightnesschange(const unsigned int oldbrt,
36212 + const unsigned int newbrt,
36213 + const u32 event_mask)
36214 +{
36215 + unsigned int i = oldbrt;
36216
36217 - while (i > newbrt) {
36218 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
36219 - i--;
36220 - }
36221 - while (i < newbrt) {
36222 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
36223 - i++;
36224 - }
36225 + while (i > newbrt) {
36226 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
36227 + i--;
36228 + }
36229 + while (i < newbrt) {
36230 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
36231 + i++;
36232 }
36233 +}
36234
36235 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
36236 + struct tp_nvram_state *newn,
36237 + const u32 event_mask)
36238 +{
36239 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
36240 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
36241 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
36242 @@ -2406,7 +2407,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
36243 oldn->volume_level != newn->volume_level) {
36244 /* recently muted, or repeated mute keypress, or
36245 * multiple presses ending in mute */
36246 - issue_volchange(oldn->volume_level, newn->volume_level);
36247 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
36248 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
36249 }
36250 } else {
36251 @@ -2416,7 +2417,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
36252 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
36253 }
36254 if (oldn->volume_level != newn->volume_level) {
36255 - issue_volchange(oldn->volume_level, newn->volume_level);
36256 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
36257 } else if (oldn->volume_toggle != newn->volume_toggle) {
36258 /* repeated vol up/down keypress at end of scale ? */
36259 if (newn->volume_level == 0)
36260 @@ -2429,7 +2430,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
36261 /* handle brightness */
36262 if (oldn->brightness_level != newn->brightness_level) {
36263 issue_brightnesschange(oldn->brightness_level,
36264 - newn->brightness_level);
36265 + newn->brightness_level,
36266 + event_mask);
36267 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
36268 /* repeated key presses that didn't change state */
36269 if (newn->brightness_level == 0)
36270 @@ -2438,10 +2440,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
36271 && !tp_features.bright_unkfw)
36272 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
36273 }
36274 +}
36275
36276 #undef TPACPI_COMPARE_KEY
36277 #undef TPACPI_MAY_SEND_KEY
36278 -}
36279
36280 /*
36281 * Polling driver
36282 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
36283 index b859d16..5cc6b1a 100644
36284 --- a/drivers/pnp/pnpbios/bioscalls.c
36285 +++ b/drivers/pnp/pnpbios/bioscalls.c
36286 @@ -59,7 +59,7 @@ do { \
36287 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
36288 } while(0)
36289
36290 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
36291 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
36292 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
36293
36294 /*
36295 @@ -96,7 +96,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
36296
36297 cpu = get_cpu();
36298 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
36299 +
36300 + pax_open_kernel();
36301 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
36302 + pax_close_kernel();
36303
36304 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
36305 spin_lock_irqsave(&pnp_bios_lock, flags);
36306 @@ -134,7 +137,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
36307 :"memory");
36308 spin_unlock_irqrestore(&pnp_bios_lock, flags);
36309
36310 + pax_open_kernel();
36311 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
36312 + pax_close_kernel();
36313 +
36314 put_cpu();
36315
36316 /* If we get here and this is set then the PnP BIOS faulted on us. */
36317 @@ -468,7 +474,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
36318 return status;
36319 }
36320
36321 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
36322 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
36323 {
36324 int i;
36325
36326 @@ -476,6 +482,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
36327 pnp_bios_callpoint.offset = header->fields.pm16offset;
36328 pnp_bios_callpoint.segment = PNP_CS16;
36329
36330 + pax_open_kernel();
36331 +
36332 for_each_possible_cpu(i) {
36333 struct desc_struct *gdt = get_cpu_gdt_table(i);
36334 if (!gdt)
36335 @@ -487,4 +495,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
36336 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
36337 (unsigned long)__va(header->fields.pm16dseg));
36338 }
36339 +
36340 + pax_close_kernel();
36341 }
36342 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
36343 index b0ecacb..7c9da2e 100644
36344 --- a/drivers/pnp/resource.c
36345 +++ b/drivers/pnp/resource.c
36346 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
36347 return 1;
36348
36349 /* check if the resource is valid */
36350 - if (*irq < 0 || *irq > 15)
36351 + if (*irq > 15)
36352 return 0;
36353
36354 /* check if the resource is reserved */
36355 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
36356 return 1;
36357
36358 /* check if the resource is valid */
36359 - if (*dma < 0 || *dma == 4 || *dma > 7)
36360 + if (*dma == 4 || *dma > 7)
36361 return 0;
36362
36363 /* check if the resource is reserved */
36364 diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c
36365 index 1ed6ea0..77c0bd2 100644
36366 --- a/drivers/power/bq27x00_battery.c
36367 +++ b/drivers/power/bq27x00_battery.c
36368 @@ -72,7 +72,7 @@
36369 struct bq27x00_device_info;
36370 struct bq27x00_access_methods {
36371 int (*read)(struct bq27x00_device_info *di, u8 reg, bool single);
36372 -};
36373 +} __no_const;
36374
36375 enum bq27x00_chip { BQ27000, BQ27500 };
36376
36377 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
36378 index a838e66..a9e1665 100644
36379 --- a/drivers/regulator/max8660.c
36380 +++ b/drivers/regulator/max8660.c
36381 @@ -383,8 +383,10 @@ static int __devinit max8660_probe(struct i2c_client *client,
36382 max8660->shadow_regs[MAX8660_OVER1] = 5;
36383 } else {
36384 /* Otherwise devices can be toggled via software */
36385 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
36386 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
36387 + pax_open_kernel();
36388 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
36389 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
36390 + pax_close_kernel();
36391 }
36392
36393 /*
36394 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
36395 index e8cfc99..072aee2 100644
36396 --- a/drivers/regulator/mc13892-regulator.c
36397 +++ b/drivers/regulator/mc13892-regulator.c
36398 @@ -574,10 +574,12 @@ static int __devinit mc13892_regulator_probe(struct platform_device *pdev)
36399 }
36400 mc13xxx_unlock(mc13892);
36401
36402 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
36403 + pax_open_kernel();
36404 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
36405 = mc13892_vcam_set_mode;
36406 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
36407 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
36408 = mc13892_vcam_get_mode;
36409 + pax_close_kernel();
36410
36411 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
36412 ARRAY_SIZE(mc13892_regulators));
36413 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
36414 index cace6d3..f623fda 100644
36415 --- a/drivers/rtc/rtc-dev.c
36416 +++ b/drivers/rtc/rtc-dev.c
36417 @@ -14,6 +14,7 @@
36418 #include <linux/module.h>
36419 #include <linux/rtc.h>
36420 #include <linux/sched.h>
36421 +#include <linux/grsecurity.h>
36422 #include "rtc-core.h"
36423
36424 static dev_t rtc_devt;
36425 @@ -345,6 +346,8 @@ static long rtc_dev_ioctl(struct file *file,
36426 if (copy_from_user(&tm, uarg, sizeof(tm)))
36427 return -EFAULT;
36428
36429 + gr_log_timechange();
36430 +
36431 return rtc_set_time(rtc, &tm);
36432
36433 case RTC_PIE_ON:
36434 diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
36435 index ffb5878..e6d785c 100644
36436 --- a/drivers/scsi/aacraid/aacraid.h
36437 +++ b/drivers/scsi/aacraid/aacraid.h
36438 @@ -492,7 +492,7 @@ struct adapter_ops
36439 int (*adapter_scsi)(struct fib * fib, struct scsi_cmnd * cmd);
36440 /* Administrative operations */
36441 int (*adapter_comm)(struct aac_dev * dev, int comm);
36442 -};
36443 +} __no_const;
36444
36445 /*
36446 * Define which interrupt handler needs to be installed
36447 diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
36448 index 705e13e..91c873c 100644
36449 --- a/drivers/scsi/aacraid/linit.c
36450 +++ b/drivers/scsi/aacraid/linit.c
36451 @@ -93,7 +93,7 @@ static DECLARE_PCI_DEVICE_TABLE(aac_pci_tbl) = {
36452 #elif defined(__devinitconst)
36453 static const struct pci_device_id aac_pci_tbl[] __devinitconst = {
36454 #else
36455 -static const struct pci_device_id aac_pci_tbl[] __devinitdata = {
36456 +static const struct pci_device_id aac_pci_tbl[] __devinitconst = {
36457 #endif
36458 { 0x1028, 0x0001, 0x1028, 0x0001, 0, 0, 0 }, /* PERC 2/Si (Iguana/PERC2Si) */
36459 { 0x1028, 0x0002, 0x1028, 0x0002, 0, 0, 1 }, /* PERC 3/Di (Opal/PERC3Di) */
36460 diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c
36461 index d5ff142..49c0ebb 100644
36462 --- a/drivers/scsi/aic94xx/aic94xx_init.c
36463 +++ b/drivers/scsi/aic94xx/aic94xx_init.c
36464 @@ -1012,7 +1012,7 @@ static struct sas_domain_function_template aic94xx_transport_functions = {
36465 .lldd_control_phy = asd_control_phy,
36466 };
36467
36468 -static const struct pci_device_id aic94xx_pci_table[] __devinitdata = {
36469 +static const struct pci_device_id aic94xx_pci_table[] __devinitconst = {
36470 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, 0x410),0, 0, 1},
36471 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, 0x412),0, 0, 1},
36472 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, 0x416),0, 0, 1},
36473 diff --git a/drivers/scsi/bfa/bfa.h b/drivers/scsi/bfa/bfa.h
36474 index a796de9..1ef20e1 100644
36475 --- a/drivers/scsi/bfa/bfa.h
36476 +++ b/drivers/scsi/bfa/bfa.h
36477 @@ -196,7 +196,7 @@ struct bfa_hwif_s {
36478 u32 *end);
36479 int cpe_vec_q0;
36480 int rme_vec_q0;
36481 -};
36482 +} __no_const;
36483 typedef void (*bfa_cb_iocfc_t) (void *cbarg, enum bfa_status status);
36484
36485 struct bfa_faa_cbfn_s {
36486 diff --git a/drivers/scsi/bfa/bfa_fcpim.c b/drivers/scsi/bfa/bfa_fcpim.c
36487 index f0f80e2..8ec946b 100644
36488 --- a/drivers/scsi/bfa/bfa_fcpim.c
36489 +++ b/drivers/scsi/bfa/bfa_fcpim.c
36490 @@ -3715,7 +3715,7 @@ bfa_fcp_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
36491
36492 bfa_iotag_attach(fcp);
36493
36494 - fcp->itn_arr = (struct bfa_itn_s *) bfa_mem_kva_curp(fcp);
36495 + fcp->itn_arr = (bfa_itn_s_no_const *) bfa_mem_kva_curp(fcp);
36496 bfa_mem_kva_curp(fcp) = (u8 *)fcp->itn_arr +
36497 (fcp->num_itns * sizeof(struct bfa_itn_s));
36498 memset(fcp->itn_arr, 0,
36499 @@ -3773,7 +3773,7 @@ bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
36500 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m))
36501 {
36502 struct bfa_fcp_mod_s *fcp = BFA_FCP_MOD(bfa);
36503 - struct bfa_itn_s *itn;
36504 + bfa_itn_s_no_const *itn;
36505
36506 itn = BFA_ITN_FROM_TAG(fcp, rport->rport_tag);
36507 itn->isr = isr;
36508 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
36509 index 36f26da..38a34a8 100644
36510 --- a/drivers/scsi/bfa/bfa_fcpim.h
36511 +++ b/drivers/scsi/bfa/bfa_fcpim.h
36512 @@ -37,6 +37,7 @@ struct bfa_iotag_s {
36513 struct bfa_itn_s {
36514 bfa_isr_func_t isr;
36515 };
36516 +typedef struct bfa_itn_s __no_const bfa_itn_s_no_const;
36517
36518 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
36519 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
36520 @@ -147,7 +148,7 @@ struct bfa_fcp_mod_s {
36521 struct list_head iotag_tio_free_q; /* free IO resources */
36522 struct list_head iotag_unused_q; /* unused IO resources*/
36523 struct bfa_iotag_s *iotag_arr;
36524 - struct bfa_itn_s *itn_arr;
36525 + bfa_itn_s_no_const *itn_arr;
36526 int num_ioim_reqs;
36527 int num_fwtio_reqs;
36528 int num_itns;
36529 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
36530 index 546d46b..642fa5b 100644
36531 --- a/drivers/scsi/bfa/bfa_ioc.h
36532 +++ b/drivers/scsi/bfa/bfa_ioc.h
36533 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
36534 bfa_ioc_disable_cbfn_t disable_cbfn;
36535 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
36536 bfa_ioc_reset_cbfn_t reset_cbfn;
36537 -};
36538 +} __no_const;
36539
36540 /*
36541 * IOC event notification mechanism.
36542 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
36543 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
36544 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
36545 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
36546 -};
36547 +} __no_const;
36548
36549 /*
36550 * Queue element to wait for room in request queue. FIFO order is
36551 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
36552 index 351dc0b..951dc32 100644
36553 --- a/drivers/scsi/hosts.c
36554 +++ b/drivers/scsi/hosts.c
36555 @@ -42,7 +42,7 @@
36556 #include "scsi_logging.h"
36557
36558
36559 -static atomic_t scsi_host_next_hn; /* host_no for next new host */
36560 +static atomic_unchecked_t scsi_host_next_hn; /* host_no for next new host */
36561
36562
36563 static void scsi_host_cls_release(struct device *dev)
36564 @@ -357,7 +357,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
36565 * subtract one because we increment first then return, but we need to
36566 * know what the next host number was before increment
36567 */
36568 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
36569 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
36570 shost->dma_channel = 0xff;
36571
36572 /* These three are default values which can be overridden */
36573 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
36574 index b96962c..0c82ec2 100644
36575 --- a/drivers/scsi/hpsa.c
36576 +++ b/drivers/scsi/hpsa.c
36577 @@ -507,7 +507,7 @@ static inline u32 next_command(struct ctlr_info *h)
36578 u32 a;
36579
36580 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
36581 - return h->access.command_completed(h);
36582 + return h->access->command_completed(h);
36583
36584 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
36585 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
36586 @@ -2991,7 +2991,7 @@ static void start_io(struct ctlr_info *h)
36587 while (!list_empty(&h->reqQ)) {
36588 c = list_entry(h->reqQ.next, struct CommandList, list);
36589 /* can't do anything if fifo is full */
36590 - if ((h->access.fifo_full(h))) {
36591 + if ((h->access->fifo_full(h))) {
36592 dev_warn(&h->pdev->dev, "fifo full\n");
36593 break;
36594 }
36595 @@ -3001,7 +3001,7 @@ static void start_io(struct ctlr_info *h)
36596 h->Qdepth--;
36597
36598 /* Tell the controller execute command */
36599 - h->access.submit_command(h, c);
36600 + h->access->submit_command(h, c);
36601
36602 /* Put job onto the completed Q */
36603 addQ(&h->cmpQ, c);
36604 @@ -3010,17 +3010,17 @@ static void start_io(struct ctlr_info *h)
36605
36606 static inline unsigned long get_next_completion(struct ctlr_info *h)
36607 {
36608 - return h->access.command_completed(h);
36609 + return h->access->command_completed(h);
36610 }
36611
36612 static inline bool interrupt_pending(struct ctlr_info *h)
36613 {
36614 - return h->access.intr_pending(h);
36615 + return h->access->intr_pending(h);
36616 }
36617
36618 static inline long interrupt_not_for_us(struct ctlr_info *h)
36619 {
36620 - return (h->access.intr_pending(h) == 0) ||
36621 + return (h->access->intr_pending(h) == 0) ||
36622 (h->interrupts_enabled == 0);
36623 }
36624
36625 @@ -3919,7 +3919,7 @@ static int __devinit hpsa_pci_init(struct ctlr_info *h)
36626 if (prod_index < 0)
36627 return -ENODEV;
36628 h->product_name = products[prod_index].product_name;
36629 - h->access = *(products[prod_index].access);
36630 + h->access = products[prod_index].access;
36631
36632 if (hpsa_board_disabled(h->pdev)) {
36633 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
36634 @@ -4164,7 +4164,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
36635
36636 assert_spin_locked(&lockup_detector_lock);
36637 remove_ctlr_from_lockup_detector_list(h);
36638 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
36639 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
36640 spin_lock_irqsave(&h->lock, flags);
36641 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
36642 spin_unlock_irqrestore(&h->lock, flags);
36643 @@ -4344,7 +4344,7 @@ reinit_after_soft_reset:
36644 }
36645
36646 /* make sure the board interrupts are off */
36647 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
36648 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
36649
36650 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
36651 goto clean2;
36652 @@ -4378,7 +4378,7 @@ reinit_after_soft_reset:
36653 * fake ones to scoop up any residual completions.
36654 */
36655 spin_lock_irqsave(&h->lock, flags);
36656 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
36657 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
36658 spin_unlock_irqrestore(&h->lock, flags);
36659 free_irq(h->intr[h->intr_mode], h);
36660 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
36661 @@ -4397,9 +4397,9 @@ reinit_after_soft_reset:
36662 dev_info(&h->pdev->dev, "Board READY.\n");
36663 dev_info(&h->pdev->dev,
36664 "Waiting for stale completions to drain.\n");
36665 - h->access.set_intr_mask(h, HPSA_INTR_ON);
36666 + h->access->set_intr_mask(h, HPSA_INTR_ON);
36667 msleep(10000);
36668 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
36669 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
36670
36671 rc = controller_reset_failed(h->cfgtable);
36672 if (rc)
36673 @@ -4420,7 +4420,7 @@ reinit_after_soft_reset:
36674 }
36675
36676 /* Turn the interrupts on so we can service requests */
36677 - h->access.set_intr_mask(h, HPSA_INTR_ON);
36678 + h->access->set_intr_mask(h, HPSA_INTR_ON);
36679
36680 hpsa_hba_inquiry(h);
36681 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
36682 @@ -4472,7 +4472,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
36683 * To write all data in the battery backed cache to disks
36684 */
36685 hpsa_flush_cache(h);
36686 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
36687 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
36688 free_irq(h->intr[h->intr_mode], h);
36689 #ifdef CONFIG_PCI_MSI
36690 if (h->msix_vector)
36691 @@ -4636,7 +4636,7 @@ static __devinit void hpsa_enter_performant_mode(struct ctlr_info *h,
36692 return;
36693 }
36694 /* Change the access methods to the performant access methods */
36695 - h->access = SA5_performant_access;
36696 + h->access = &SA5_performant_access;
36697 h->transMethod = CFGTBL_Trans_Performant;
36698 }
36699
36700 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
36701 index 91edafb..a9b88ec 100644
36702 --- a/drivers/scsi/hpsa.h
36703 +++ b/drivers/scsi/hpsa.h
36704 @@ -73,7 +73,7 @@ struct ctlr_info {
36705 unsigned int msix_vector;
36706 unsigned int msi_vector;
36707 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
36708 - struct access_method access;
36709 + struct access_method *access;
36710
36711 /* queue and queue Info */
36712 struct list_head reqQ;
36713 diff --git a/drivers/scsi/ips.h b/drivers/scsi/ips.h
36714 index f2df059..a3a9930 100644
36715 --- a/drivers/scsi/ips.h
36716 +++ b/drivers/scsi/ips.h
36717 @@ -1027,7 +1027,7 @@ typedef struct {
36718 int (*intr)(struct ips_ha *);
36719 void (*enableint)(struct ips_ha *);
36720 uint32_t (*statupd)(struct ips_ha *);
36721 -} ips_hw_func_t;
36722 +} __no_const ips_hw_func_t;
36723
36724 typedef struct ips_ha {
36725 uint8_t ha_id[IPS_MAX_CHANNELS+1];
36726 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
36727 index 4d70d96..84d0573 100644
36728 --- a/drivers/scsi/libfc/fc_exch.c
36729 +++ b/drivers/scsi/libfc/fc_exch.c
36730 @@ -105,12 +105,12 @@ struct fc_exch_mgr {
36731 * all together if not used XXX
36732 */
36733 struct {
36734 - atomic_t no_free_exch;
36735 - atomic_t no_free_exch_xid;
36736 - atomic_t xid_not_found;
36737 - atomic_t xid_busy;
36738 - atomic_t seq_not_found;
36739 - atomic_t non_bls_resp;
36740 + atomic_unchecked_t no_free_exch;
36741 + atomic_unchecked_t no_free_exch_xid;
36742 + atomic_unchecked_t xid_not_found;
36743 + atomic_unchecked_t xid_busy;
36744 + atomic_unchecked_t seq_not_found;
36745 + atomic_unchecked_t non_bls_resp;
36746 } stats;
36747 };
36748
36749 @@ -719,7 +719,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
36750 /* allocate memory for exchange */
36751 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
36752 if (!ep) {
36753 - atomic_inc(&mp->stats.no_free_exch);
36754 + atomic_inc_unchecked(&mp->stats.no_free_exch);
36755 goto out;
36756 }
36757 memset(ep, 0, sizeof(*ep));
36758 @@ -780,7 +780,7 @@ out:
36759 return ep;
36760 err:
36761 spin_unlock_bh(&pool->lock);
36762 - atomic_inc(&mp->stats.no_free_exch_xid);
36763 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
36764 mempool_free(ep, mp->ep_pool);
36765 return NULL;
36766 }
36767 @@ -923,7 +923,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
36768 xid = ntohs(fh->fh_ox_id); /* we originated exch */
36769 ep = fc_exch_find(mp, xid);
36770 if (!ep) {
36771 - atomic_inc(&mp->stats.xid_not_found);
36772 + atomic_inc_unchecked(&mp->stats.xid_not_found);
36773 reject = FC_RJT_OX_ID;
36774 goto out;
36775 }
36776 @@ -953,7 +953,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
36777 ep = fc_exch_find(mp, xid);
36778 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
36779 if (ep) {
36780 - atomic_inc(&mp->stats.xid_busy);
36781 + atomic_inc_unchecked(&mp->stats.xid_busy);
36782 reject = FC_RJT_RX_ID;
36783 goto rel;
36784 }
36785 @@ -964,7 +964,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
36786 }
36787 xid = ep->xid; /* get our XID */
36788 } else if (!ep) {
36789 - atomic_inc(&mp->stats.xid_not_found);
36790 + atomic_inc_unchecked(&mp->stats.xid_not_found);
36791 reject = FC_RJT_RX_ID; /* XID not found */
36792 goto out;
36793 }
36794 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
36795 } else {
36796 sp = &ep->seq;
36797 if (sp->id != fh->fh_seq_id) {
36798 - atomic_inc(&mp->stats.seq_not_found);
36799 + atomic_inc_unchecked(&mp->stats.seq_not_found);
36800 if (f_ctl & FC_FC_END_SEQ) {
36801 /*
36802 * Update sequence_id based on incoming last
36803 @@ -1431,22 +1431,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
36804
36805 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
36806 if (!ep) {
36807 - atomic_inc(&mp->stats.xid_not_found);
36808 + atomic_inc_unchecked(&mp->stats.xid_not_found);
36809 goto out;
36810 }
36811 if (ep->esb_stat & ESB_ST_COMPLETE) {
36812 - atomic_inc(&mp->stats.xid_not_found);
36813 + atomic_inc_unchecked(&mp->stats.xid_not_found);
36814 goto rel;
36815 }
36816 if (ep->rxid == FC_XID_UNKNOWN)
36817 ep->rxid = ntohs(fh->fh_rx_id);
36818 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
36819 - atomic_inc(&mp->stats.xid_not_found);
36820 + atomic_inc_unchecked(&mp->stats.xid_not_found);
36821 goto rel;
36822 }
36823 if (ep->did != ntoh24(fh->fh_s_id) &&
36824 ep->did != FC_FID_FLOGI) {
36825 - atomic_inc(&mp->stats.xid_not_found);
36826 + atomic_inc_unchecked(&mp->stats.xid_not_found);
36827 goto rel;
36828 }
36829 sof = fr_sof(fp);
36830 @@ -1455,7 +1455,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
36831 sp->ssb_stat |= SSB_ST_RESP;
36832 sp->id = fh->fh_seq_id;
36833 } else if (sp->id != fh->fh_seq_id) {
36834 - atomic_inc(&mp->stats.seq_not_found);
36835 + atomic_inc_unchecked(&mp->stats.seq_not_found);
36836 goto rel;
36837 }
36838
36839 @@ -1519,9 +1519,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
36840 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
36841
36842 if (!sp)
36843 - atomic_inc(&mp->stats.xid_not_found);
36844 + atomic_inc_unchecked(&mp->stats.xid_not_found);
36845 else
36846 - atomic_inc(&mp->stats.non_bls_resp);
36847 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
36848
36849 fc_frame_free(fp);
36850 }
36851 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
36852 index db9238f..4378ed2 100644
36853 --- a/drivers/scsi/libsas/sas_ata.c
36854 +++ b/drivers/scsi/libsas/sas_ata.c
36855 @@ -368,7 +368,7 @@ static struct ata_port_operations sas_sata_ops = {
36856 .postreset = ata_std_postreset,
36857 .error_handler = ata_std_error_handler,
36858 .post_internal_cmd = sas_ata_post_internal,
36859 - .qc_defer = ata_std_qc_defer,
36860 + .qc_defer = ata_std_qc_defer,
36861 .qc_prep = ata_noop_qc_prep,
36862 .qc_issue = sas_ata_qc_issue,
36863 .qc_fill_rtf = sas_ata_qc_fill_rtf,
36864 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
36865 index 825f930..ce42672 100644
36866 --- a/drivers/scsi/lpfc/lpfc.h
36867 +++ b/drivers/scsi/lpfc/lpfc.h
36868 @@ -413,7 +413,7 @@ struct lpfc_vport {
36869 struct dentry *debug_nodelist;
36870 struct dentry *vport_debugfs_root;
36871 struct lpfc_debugfs_trc *disc_trc;
36872 - atomic_t disc_trc_cnt;
36873 + atomic_unchecked_t disc_trc_cnt;
36874 #endif
36875 uint8_t stat_data_enabled;
36876 uint8_t stat_data_blocked;
36877 @@ -821,8 +821,8 @@ struct lpfc_hba {
36878 struct timer_list fabric_block_timer;
36879 unsigned long bit_flags;
36880 #define FABRIC_COMANDS_BLOCKED 0
36881 - atomic_t num_rsrc_err;
36882 - atomic_t num_cmd_success;
36883 + atomic_unchecked_t num_rsrc_err;
36884 + atomic_unchecked_t num_cmd_success;
36885 unsigned long last_rsrc_error_time;
36886 unsigned long last_ramp_down_time;
36887 unsigned long last_ramp_up_time;
36888 @@ -852,7 +852,7 @@ struct lpfc_hba {
36889
36890 struct dentry *debug_slow_ring_trc;
36891 struct lpfc_debugfs_trc *slow_ring_trc;
36892 - atomic_t slow_ring_trc_cnt;
36893 + atomic_unchecked_t slow_ring_trc_cnt;
36894 /* iDiag debugfs sub-directory */
36895 struct dentry *idiag_root;
36896 struct dentry *idiag_pci_cfg;
36897 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
36898 index 3587a3f..d45b81b 100644
36899 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
36900 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
36901 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
36902
36903 #include <linux/debugfs.h>
36904
36905 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
36906 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
36907 static unsigned long lpfc_debugfs_start_time = 0L;
36908
36909 /* iDiag */
36910 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
36911 lpfc_debugfs_enable = 0;
36912
36913 len = 0;
36914 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
36915 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
36916 (lpfc_debugfs_max_disc_trc - 1);
36917 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
36918 dtp = vport->disc_trc + i;
36919 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
36920 lpfc_debugfs_enable = 0;
36921
36922 len = 0;
36923 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
36924 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
36925 (lpfc_debugfs_max_slow_ring_trc - 1);
36926 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
36927 dtp = phba->slow_ring_trc + i;
36928 @@ -636,14 +636,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
36929 !vport || !vport->disc_trc)
36930 return;
36931
36932 - index = atomic_inc_return(&vport->disc_trc_cnt) &
36933 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
36934 (lpfc_debugfs_max_disc_trc - 1);
36935 dtp = vport->disc_trc + index;
36936 dtp->fmt = fmt;
36937 dtp->data1 = data1;
36938 dtp->data2 = data2;
36939 dtp->data3 = data3;
36940 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
36941 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
36942 dtp->jif = jiffies;
36943 #endif
36944 return;
36945 @@ -674,14 +674,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
36946 !phba || !phba->slow_ring_trc)
36947 return;
36948
36949 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
36950 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
36951 (lpfc_debugfs_max_slow_ring_trc - 1);
36952 dtp = phba->slow_ring_trc + index;
36953 dtp->fmt = fmt;
36954 dtp->data1 = data1;
36955 dtp->data2 = data2;
36956 dtp->data3 = data3;
36957 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
36958 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
36959 dtp->jif = jiffies;
36960 #endif
36961 return;
36962 @@ -4040,7 +4040,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
36963 "slow_ring buffer\n");
36964 goto debug_failed;
36965 }
36966 - atomic_set(&phba->slow_ring_trc_cnt, 0);
36967 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
36968 memset(phba->slow_ring_trc, 0,
36969 (sizeof(struct lpfc_debugfs_trc) *
36970 lpfc_debugfs_max_slow_ring_trc));
36971 @@ -4086,7 +4086,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
36972 "buffer\n");
36973 goto debug_failed;
36974 }
36975 - atomic_set(&vport->disc_trc_cnt, 0);
36976 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
36977
36978 snprintf(name, sizeof(name), "discovery_trace");
36979 vport->debug_disc_trc =
36980 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
36981 index dfea2da..8e17227 100644
36982 --- a/drivers/scsi/lpfc/lpfc_init.c
36983 +++ b/drivers/scsi/lpfc/lpfc_init.c
36984 @@ -10145,8 +10145,10 @@ lpfc_init(void)
36985 printk(LPFC_COPYRIGHT "\n");
36986
36987 if (lpfc_enable_npiv) {
36988 - lpfc_transport_functions.vport_create = lpfc_vport_create;
36989 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
36990 + pax_open_kernel();
36991 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
36992 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
36993 + pax_close_kernel();
36994 }
36995 lpfc_transport_template =
36996 fc_attach_transport(&lpfc_transport_functions);
36997 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
36998 index c60f5d0..751535c 100644
36999 --- a/drivers/scsi/lpfc/lpfc_scsi.c
37000 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
37001 @@ -305,7 +305,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
37002 uint32_t evt_posted;
37003
37004 spin_lock_irqsave(&phba->hbalock, flags);
37005 - atomic_inc(&phba->num_rsrc_err);
37006 + atomic_inc_unchecked(&phba->num_rsrc_err);
37007 phba->last_rsrc_error_time = jiffies;
37008
37009 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
37010 @@ -346,7 +346,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
37011 unsigned long flags;
37012 struct lpfc_hba *phba = vport->phba;
37013 uint32_t evt_posted;
37014 - atomic_inc(&phba->num_cmd_success);
37015 + atomic_inc_unchecked(&phba->num_cmd_success);
37016
37017 if (vport->cfg_lun_queue_depth <= queue_depth)
37018 return;
37019 @@ -390,8 +390,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
37020 unsigned long num_rsrc_err, num_cmd_success;
37021 int i;
37022
37023 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
37024 - num_cmd_success = atomic_read(&phba->num_cmd_success);
37025 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
37026 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
37027
37028 vports = lpfc_create_vport_work_array(phba);
37029 if (vports != NULL)
37030 @@ -411,8 +411,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
37031 }
37032 }
37033 lpfc_destroy_vport_work_array(phba, vports);
37034 - atomic_set(&phba->num_rsrc_err, 0);
37035 - atomic_set(&phba->num_cmd_success, 0);
37036 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
37037 + atomic_set_unchecked(&phba->num_cmd_success, 0);
37038 }
37039
37040 /**
37041 @@ -446,8 +446,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
37042 }
37043 }
37044 lpfc_destroy_vport_work_array(phba, vports);
37045 - atomic_set(&phba->num_rsrc_err, 0);
37046 - atomic_set(&phba->num_cmd_success, 0);
37047 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
37048 + atomic_set_unchecked(&phba->num_cmd_success, 0);
37049 }
37050
37051 /**
37052 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
37053 index ea8a0b4..812a124 100644
37054 --- a/drivers/scsi/pmcraid.c
37055 +++ b/drivers/scsi/pmcraid.c
37056 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
37057 res->scsi_dev = scsi_dev;
37058 scsi_dev->hostdata = res;
37059 res->change_detected = 0;
37060 - atomic_set(&res->read_failures, 0);
37061 - atomic_set(&res->write_failures, 0);
37062 + atomic_set_unchecked(&res->read_failures, 0);
37063 + atomic_set_unchecked(&res->write_failures, 0);
37064 rc = 0;
37065 }
37066 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
37067 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
37068
37069 /* If this was a SCSI read/write command keep count of errors */
37070 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
37071 - atomic_inc(&res->read_failures);
37072 + atomic_inc_unchecked(&res->read_failures);
37073 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
37074 - atomic_inc(&res->write_failures);
37075 + atomic_inc_unchecked(&res->write_failures);
37076
37077 if (!RES_IS_GSCSI(res->cfg_entry) &&
37078 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
37079 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
37080 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
37081 * hrrq_id assigned here in queuecommand
37082 */
37083 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
37084 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
37085 pinstance->num_hrrq;
37086 cmd->cmd_done = pmcraid_io_done;
37087
37088 @@ -3859,7 +3859,7 @@ static long pmcraid_ioctl_passthrough(
37089 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
37090 * hrrq_id assigned here in queuecommand
37091 */
37092 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
37093 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
37094 pinstance->num_hrrq;
37095
37096 if (request_size) {
37097 @@ -4497,7 +4497,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
37098
37099 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
37100 /* add resources only after host is added into system */
37101 - if (!atomic_read(&pinstance->expose_resources))
37102 + if (!atomic_read_unchecked(&pinstance->expose_resources))
37103 return;
37104
37105 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
37106 @@ -5331,8 +5331,8 @@ static int __devinit pmcraid_init_instance(
37107 init_waitqueue_head(&pinstance->reset_wait_q);
37108
37109 atomic_set(&pinstance->outstanding_cmds, 0);
37110 - atomic_set(&pinstance->last_message_id, 0);
37111 - atomic_set(&pinstance->expose_resources, 0);
37112 + atomic_set_unchecked(&pinstance->last_message_id, 0);
37113 + atomic_set_unchecked(&pinstance->expose_resources, 0);
37114
37115 INIT_LIST_HEAD(&pinstance->free_res_q);
37116 INIT_LIST_HEAD(&pinstance->used_res_q);
37117 @@ -6047,7 +6047,7 @@ static int __devinit pmcraid_probe(
37118 /* Schedule worker thread to handle CCN and take care of adding and
37119 * removing devices to OS
37120 */
37121 - atomic_set(&pinstance->expose_resources, 1);
37122 + atomic_set_unchecked(&pinstance->expose_resources, 1);
37123 schedule_work(&pinstance->worker_q);
37124 return rc;
37125
37126 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
37127 index ca496c7..9c791d5 100644
37128 --- a/drivers/scsi/pmcraid.h
37129 +++ b/drivers/scsi/pmcraid.h
37130 @@ -748,7 +748,7 @@ struct pmcraid_instance {
37131 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
37132
37133 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
37134 - atomic_t last_message_id;
37135 + atomic_unchecked_t last_message_id;
37136
37137 /* configuration table */
37138 struct pmcraid_config_table *cfg_table;
37139 @@ -777,7 +777,7 @@ struct pmcraid_instance {
37140 atomic_t outstanding_cmds;
37141
37142 /* should add/delete resources to mid-layer now ?*/
37143 - atomic_t expose_resources;
37144 + atomic_unchecked_t expose_resources;
37145
37146
37147
37148 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
37149 struct pmcraid_config_table_entry_ext cfg_entry_ext;
37150 };
37151 struct scsi_device *scsi_dev; /* Link scsi_device structure */
37152 - atomic_t read_failures; /* count of failed READ commands */
37153 - atomic_t write_failures; /* count of failed WRITE commands */
37154 + atomic_unchecked_t read_failures; /* count of failed READ commands */
37155 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
37156
37157 /* To indicate add/delete/modify during CCN */
37158 u8 change_detected;
37159 diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
37160 index af1003f..be55a75 100644
37161 --- a/drivers/scsi/qla2xxx/qla_def.h
37162 +++ b/drivers/scsi/qla2xxx/qla_def.h
37163 @@ -2247,7 +2247,7 @@ struct isp_operations {
37164 int (*start_scsi) (srb_t *);
37165 int (*abort_isp) (struct scsi_qla_host *);
37166 int (*iospace_config)(struct qla_hw_data*);
37167 -};
37168 +} __no_const;
37169
37170 /* MSI-X Support *************************************************************/
37171
37172 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
37173 index bfe6854..ceac088 100644
37174 --- a/drivers/scsi/qla4xxx/ql4_def.h
37175 +++ b/drivers/scsi/qla4xxx/ql4_def.h
37176 @@ -261,7 +261,7 @@ struct ddb_entry {
37177 * (4000 only) */
37178 atomic_t relogin_timer; /* Max Time to wait for
37179 * relogin to complete */
37180 - atomic_t relogin_retry_count; /* Num of times relogin has been
37181 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
37182 * retried */
37183 uint32_t default_time2wait; /* Default Min time between
37184 * relogins (+aens) */
37185 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
37186 index ce6d3b7..73fac54 100644
37187 --- a/drivers/scsi/qla4xxx/ql4_os.c
37188 +++ b/drivers/scsi/qla4xxx/ql4_os.c
37189 @@ -2178,12 +2178,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
37190 */
37191 if (!iscsi_is_session_online(cls_sess)) {
37192 /* Reset retry relogin timer */
37193 - atomic_inc(&ddb_entry->relogin_retry_count);
37194 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
37195 DEBUG2(ql4_printk(KERN_INFO, ha,
37196 "%s: index[%d] relogin timed out-retrying"
37197 " relogin (%d), retry (%d)\n", __func__,
37198 ddb_entry->fw_ddb_index,
37199 - atomic_read(&ddb_entry->relogin_retry_count),
37200 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
37201 ddb_entry->default_time2wait + 4));
37202 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
37203 atomic_set(&ddb_entry->retry_relogin_timer,
37204 @@ -3953,7 +3953,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
37205
37206 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
37207 atomic_set(&ddb_entry->relogin_timer, 0);
37208 - atomic_set(&ddb_entry->relogin_retry_count, 0);
37209 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
37210 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
37211 ddb_entry->default_relogin_timeout =
37212 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
37213 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
37214 index 2aeb2e9..46e3925 100644
37215 --- a/drivers/scsi/scsi.c
37216 +++ b/drivers/scsi/scsi.c
37217 @@ -655,7 +655,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
37218 unsigned long timeout;
37219 int rtn = 0;
37220
37221 - atomic_inc(&cmd->device->iorequest_cnt);
37222 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
37223
37224 /* check if the device is still usable */
37225 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
37226 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
37227 index b2c95db..227d74e 100644
37228 --- a/drivers/scsi/scsi_lib.c
37229 +++ b/drivers/scsi/scsi_lib.c
37230 @@ -1411,7 +1411,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
37231 shost = sdev->host;
37232 scsi_init_cmd_errh(cmd);
37233 cmd->result = DID_NO_CONNECT << 16;
37234 - atomic_inc(&cmd->device->iorequest_cnt);
37235 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
37236
37237 /*
37238 * SCSI request completion path will do scsi_device_unbusy(),
37239 @@ -1437,9 +1437,9 @@ static void scsi_softirq_done(struct request *rq)
37240
37241 INIT_LIST_HEAD(&cmd->eh_entry);
37242
37243 - atomic_inc(&cmd->device->iodone_cnt);
37244 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
37245 if (cmd->result)
37246 - atomic_inc(&cmd->device->ioerr_cnt);
37247 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
37248
37249 disposition = scsi_decide_disposition(cmd);
37250 if (disposition != SUCCESS &&
37251 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
37252 index 04c2a27..9d8bd66 100644
37253 --- a/drivers/scsi/scsi_sysfs.c
37254 +++ b/drivers/scsi/scsi_sysfs.c
37255 @@ -660,7 +660,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
37256 char *buf) \
37257 { \
37258 struct scsi_device *sdev = to_scsi_device(dev); \
37259 - unsigned long long count = atomic_read(&sdev->field); \
37260 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
37261 return snprintf(buf, 20, "0x%llx\n", count); \
37262 } \
37263 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
37264 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
37265 index 84a1fdf..693b0d6 100644
37266 --- a/drivers/scsi/scsi_tgt_lib.c
37267 +++ b/drivers/scsi/scsi_tgt_lib.c
37268 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
37269 int err;
37270
37271 dprintk("%lx %u\n", uaddr, len);
37272 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
37273 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
37274 if (err) {
37275 /*
37276 * TODO: need to fixup sg_tablesize, max_segment_size,
37277 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
37278 index f59d4a0..1d89407 100644
37279 --- a/drivers/scsi/scsi_transport_fc.c
37280 +++ b/drivers/scsi/scsi_transport_fc.c
37281 @@ -484,7 +484,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
37282 * Netlink Infrastructure
37283 */
37284
37285 -static atomic_t fc_event_seq;
37286 +static atomic_unchecked_t fc_event_seq;
37287
37288 /**
37289 * fc_get_event_number - Obtain the next sequential FC event number
37290 @@ -497,7 +497,7 @@ static atomic_t fc_event_seq;
37291 u32
37292 fc_get_event_number(void)
37293 {
37294 - return atomic_add_return(1, &fc_event_seq);
37295 + return atomic_add_return_unchecked(1, &fc_event_seq);
37296 }
37297 EXPORT_SYMBOL(fc_get_event_number);
37298
37299 @@ -645,7 +645,7 @@ static __init int fc_transport_init(void)
37300 {
37301 int error;
37302
37303 - atomic_set(&fc_event_seq, 0);
37304 + atomic_set_unchecked(&fc_event_seq, 0);
37305
37306 error = transport_class_register(&fc_host_class);
37307 if (error)
37308 @@ -835,7 +835,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
37309 char *cp;
37310
37311 *val = simple_strtoul(buf, &cp, 0);
37312 - if ((*cp && (*cp != '\n')) || (*val < 0))
37313 + if (*cp && (*cp != '\n'))
37314 return -EINVAL;
37315 /*
37316 * Check for overflow; dev_loss_tmo is u32
37317 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
37318 index e3e3c7d..ebdab62 100644
37319 --- a/drivers/scsi/scsi_transport_iscsi.c
37320 +++ b/drivers/scsi/scsi_transport_iscsi.c
37321 @@ -79,7 +79,7 @@ struct iscsi_internal {
37322 struct transport_container session_cont;
37323 };
37324
37325 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
37326 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
37327 static struct workqueue_struct *iscsi_eh_timer_workq;
37328
37329 static DEFINE_IDA(iscsi_sess_ida);
37330 @@ -1063,7 +1063,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
37331 int err;
37332
37333 ihost = shost->shost_data;
37334 - session->sid = atomic_add_return(1, &iscsi_session_nr);
37335 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
37336
37337 if (target_id == ISCSI_MAX_TARGET) {
37338 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
37339 @@ -2680,7 +2680,7 @@ static __init int iscsi_transport_init(void)
37340 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
37341 ISCSI_TRANSPORT_VERSION);
37342
37343 - atomic_set(&iscsi_session_nr, 0);
37344 + atomic_set_unchecked(&iscsi_session_nr, 0);
37345
37346 err = class_register(&iscsi_transport_class);
37347 if (err)
37348 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
37349 index 21a045e..ec89e03 100644
37350 --- a/drivers/scsi/scsi_transport_srp.c
37351 +++ b/drivers/scsi/scsi_transport_srp.c
37352 @@ -33,7 +33,7 @@
37353 #include "scsi_transport_srp_internal.h"
37354
37355 struct srp_host_attrs {
37356 - atomic_t next_port_id;
37357 + atomic_unchecked_t next_port_id;
37358 };
37359 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
37360
37361 @@ -62,7 +62,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
37362 struct Scsi_Host *shost = dev_to_shost(dev);
37363 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
37364
37365 - atomic_set(&srp_host->next_port_id, 0);
37366 + atomic_set_unchecked(&srp_host->next_port_id, 0);
37367 return 0;
37368 }
37369
37370 @@ -211,7 +211,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
37371 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
37372 rport->roles = ids->roles;
37373
37374 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
37375 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
37376 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
37377
37378 transport_setup_device(&rport->dev);
37379 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
37380 index eacd46b..e3f4d62 100644
37381 --- a/drivers/scsi/sg.c
37382 +++ b/drivers/scsi/sg.c
37383 @@ -1077,7 +1077,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
37384 sdp->disk->disk_name,
37385 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
37386 NULL,
37387 - (char *)arg);
37388 + (char __user *)arg);
37389 case BLKTRACESTART:
37390 return blk_trace_startstop(sdp->device->request_queue, 1);
37391 case BLKTRACESTOP:
37392 @@ -2312,7 +2312,7 @@ struct sg_proc_leaf {
37393 const struct file_operations * fops;
37394 };
37395
37396 -static struct sg_proc_leaf sg_proc_leaf_arr[] = {
37397 +static const struct sg_proc_leaf sg_proc_leaf_arr[] = {
37398 {"allow_dio", &adio_fops},
37399 {"debug", &debug_fops},
37400 {"def_reserved_size", &dressz_fops},
37401 @@ -2332,7 +2332,7 @@ sg_proc_init(void)
37402 if (!sg_proc_sgp)
37403 return 1;
37404 for (k = 0; k < num_leaves; ++k) {
37405 - struct sg_proc_leaf *leaf = &sg_proc_leaf_arr[k];
37406 + const struct sg_proc_leaf *leaf = &sg_proc_leaf_arr[k];
37407 umode_t mask = leaf->fops->write ? S_IRUGO | S_IWUSR : S_IRUGO;
37408 proc_create(leaf->name, mask, sg_proc_sgp, leaf->fops);
37409 }
37410 diff --git a/drivers/spi/spi-dw-pci.c b/drivers/spi/spi-dw-pci.c
37411 index f64250e..1ee3049 100644
37412 --- a/drivers/spi/spi-dw-pci.c
37413 +++ b/drivers/spi/spi-dw-pci.c
37414 @@ -149,7 +149,7 @@ static int spi_resume(struct pci_dev *pdev)
37415 #define spi_resume NULL
37416 #endif
37417
37418 -static const struct pci_device_id pci_ids[] __devinitdata = {
37419 +static const struct pci_device_id pci_ids[] __devinitconst = {
37420 /* Intel MID platform SPI controller 0 */
37421 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0800) },
37422 {},
37423 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
37424 index b2ccdea..84cde75 100644
37425 --- a/drivers/spi/spi.c
37426 +++ b/drivers/spi/spi.c
37427 @@ -1024,7 +1024,7 @@ int spi_bus_unlock(struct spi_master *master)
37428 EXPORT_SYMBOL_GPL(spi_bus_unlock);
37429
37430 /* portable code must never pass more than 32 bytes */
37431 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
37432 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
37433
37434 static u8 *buf;
37435
37436 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
37437 index 400df8c..065d4f4 100644
37438 --- a/drivers/staging/octeon/ethernet-rx.c
37439 +++ b/drivers/staging/octeon/ethernet-rx.c
37440 @@ -420,11 +420,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
37441 /* Increment RX stats for virtual ports */
37442 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
37443 #ifdef CONFIG_64BIT
37444 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
37445 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
37446 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
37447 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
37448 #else
37449 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
37450 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
37451 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
37452 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
37453 #endif
37454 }
37455 netif_receive_skb(skb);
37456 @@ -436,9 +436,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
37457 dev->name);
37458 */
37459 #ifdef CONFIG_64BIT
37460 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
37461 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
37462 #else
37463 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
37464 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
37465 #endif
37466 dev_kfree_skb_irq(skb);
37467 }
37468 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
37469 index 9112cd8..92f8d51 100644
37470 --- a/drivers/staging/octeon/ethernet.c
37471 +++ b/drivers/staging/octeon/ethernet.c
37472 @@ -258,11 +258,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
37473 * since the RX tasklet also increments it.
37474 */
37475 #ifdef CONFIG_64BIT
37476 - atomic64_add(rx_status.dropped_packets,
37477 - (atomic64_t *)&priv->stats.rx_dropped);
37478 + atomic64_add_unchecked(rx_status.dropped_packets,
37479 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
37480 #else
37481 - atomic_add(rx_status.dropped_packets,
37482 - (atomic_t *)&priv->stats.rx_dropped);
37483 + atomic_add_unchecked(rx_status.dropped_packets,
37484 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
37485 #endif
37486 }
37487
37488 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
37489 index 86308a0..feaa925 100644
37490 --- a/drivers/staging/rtl8712/rtl871x_io.h
37491 +++ b/drivers/staging/rtl8712/rtl871x_io.h
37492 @@ -108,7 +108,7 @@ struct _io_ops {
37493 u8 *pmem);
37494 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
37495 u8 *pmem);
37496 -};
37497 +} __no_const;
37498
37499 struct io_req {
37500 struct list_head list;
37501 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
37502 index c7b5e8b..783d6cb 100644
37503 --- a/drivers/staging/sbe-2t3e3/netdev.c
37504 +++ b/drivers/staging/sbe-2t3e3/netdev.c
37505 @@ -51,7 +51,7 @@ int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
37506 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
37507
37508 if (rlen)
37509 - if (copy_to_user(data, &resp, rlen))
37510 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
37511 return -EFAULT;
37512
37513 return 0;
37514 diff --git a/drivers/staging/speakup/speakup_soft.c b/drivers/staging/speakup/speakup_soft.c
37515 index 42cdafe..2769103 100644
37516 --- a/drivers/staging/speakup/speakup_soft.c
37517 +++ b/drivers/staging/speakup/speakup_soft.c
37518 @@ -241,11 +241,11 @@ static ssize_t softsynth_read(struct file *fp, char *buf, size_t count,
37519 break;
37520 } else if (!initialized) {
37521 if (*init) {
37522 - ch = *init;
37523 init++;
37524 } else {
37525 initialized = 1;
37526 }
37527 + ch = *init;
37528 } else {
37529 ch = synth_buffer_getc();
37530 }
37531 diff --git a/drivers/staging/usbip/usbip_common.h b/drivers/staging/usbip/usbip_common.h
37532 index b8f8c48..1fc5025 100644
37533 --- a/drivers/staging/usbip/usbip_common.h
37534 +++ b/drivers/staging/usbip/usbip_common.h
37535 @@ -289,7 +289,7 @@ struct usbip_device {
37536 void (*shutdown)(struct usbip_device *);
37537 void (*reset)(struct usbip_device *);
37538 void (*unusable)(struct usbip_device *);
37539 - } eh_ops;
37540 + } __no_const eh_ops;
37541 };
37542
37543 /* usbip_common.c */
37544 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
37545 index 88b3298..3783eee 100644
37546 --- a/drivers/staging/usbip/vhci.h
37547 +++ b/drivers/staging/usbip/vhci.h
37548 @@ -88,7 +88,7 @@ struct vhci_hcd {
37549 unsigned resuming:1;
37550 unsigned long re_timeout;
37551
37552 - atomic_t seqnum;
37553 + atomic_unchecked_t seqnum;
37554
37555 /*
37556 * NOTE:
37557 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
37558 index 2ee97e2..0420b86 100644
37559 --- a/drivers/staging/usbip/vhci_hcd.c
37560 +++ b/drivers/staging/usbip/vhci_hcd.c
37561 @@ -527,7 +527,7 @@ static void vhci_tx_urb(struct urb *urb)
37562 return;
37563 }
37564
37565 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
37566 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
37567 if (priv->seqnum == 0xffff)
37568 dev_info(&urb->dev->dev, "seqnum max\n");
37569
37570 @@ -779,7 +779,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
37571 return -ENOMEM;
37572 }
37573
37574 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
37575 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
37576 if (unlink->seqnum == 0xffff)
37577 pr_info("seqnum max\n");
37578
37579 @@ -969,7 +969,7 @@ static int vhci_start(struct usb_hcd *hcd)
37580 vdev->rhport = rhport;
37581 }
37582
37583 - atomic_set(&vhci->seqnum, 0);
37584 + atomic_set_unchecked(&vhci->seqnum, 0);
37585 spin_lock_init(&vhci->lock);
37586
37587 hcd->power_budget = 0; /* no limit */
37588 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
37589 index 3f511b4..d3dbc1e 100644
37590 --- a/drivers/staging/usbip/vhci_rx.c
37591 +++ b/drivers/staging/usbip/vhci_rx.c
37592 @@ -77,7 +77,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
37593 if (!urb) {
37594 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
37595 pr_info("max seqnum %d\n",
37596 - atomic_read(&the_controller->seqnum));
37597 + atomic_read_unchecked(&the_controller->seqnum));
37598 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
37599 return;
37600 }
37601 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
37602 index 7735027..30eed13 100644
37603 --- a/drivers/staging/vt6655/hostap.c
37604 +++ b/drivers/staging/vt6655/hostap.c
37605 @@ -79,14 +79,13 @@ static int msglevel =MSG_LEVEL_INFO;
37606 *
37607 */
37608
37609 +static net_device_ops_no_const apdev_netdev_ops;
37610 +
37611 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
37612 {
37613 PSDevice apdev_priv;
37614 struct net_device *dev = pDevice->dev;
37615 int ret;
37616 - const struct net_device_ops apdev_netdev_ops = {
37617 - .ndo_start_xmit = pDevice->tx_80211,
37618 - };
37619
37620 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
37621
37622 @@ -98,6 +97,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
37623 *apdev_priv = *pDevice;
37624 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
37625
37626 + /* only half broken now */
37627 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
37628 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
37629
37630 pDevice->apdev->type = ARPHRD_IEEE80211;
37631 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
37632 index 51b5adf..098e320 100644
37633 --- a/drivers/staging/vt6656/hostap.c
37634 +++ b/drivers/staging/vt6656/hostap.c
37635 @@ -80,14 +80,13 @@ static int msglevel =MSG_LEVEL_INFO;
37636 *
37637 */
37638
37639 +static net_device_ops_no_const apdev_netdev_ops;
37640 +
37641 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
37642 {
37643 PSDevice apdev_priv;
37644 struct net_device *dev = pDevice->dev;
37645 int ret;
37646 - const struct net_device_ops apdev_netdev_ops = {
37647 - .ndo_start_xmit = pDevice->tx_80211,
37648 - };
37649
37650 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
37651
37652 @@ -99,6 +98,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
37653 *apdev_priv = *pDevice;
37654 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
37655
37656 + /* only half broken now */
37657 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
37658 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
37659
37660 pDevice->apdev->type = ARPHRD_IEEE80211;
37661 diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c
37662 index 7843dfd..3db105f 100644
37663 --- a/drivers/staging/wlan-ng/hfa384x_usb.c
37664 +++ b/drivers/staging/wlan-ng/hfa384x_usb.c
37665 @@ -204,7 +204,7 @@ static void unlocked_usbctlx_complete(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx);
37666
37667 struct usbctlx_completor {
37668 int (*complete) (struct usbctlx_completor *);
37669 -};
37670 +} __no_const;
37671
37672 static int
37673 hfa384x_usbctlx_complete_sync(hfa384x_t *hw,
37674 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
37675 index 1ca66ea..76f1343 100644
37676 --- a/drivers/staging/zcache/tmem.c
37677 +++ b/drivers/staging/zcache/tmem.c
37678 @@ -39,7 +39,7 @@
37679 * A tmem host implementation must use this function to register callbacks
37680 * for memory allocation.
37681 */
37682 -static struct tmem_hostops tmem_hostops;
37683 +static tmem_hostops_no_const tmem_hostops;
37684
37685 static void tmem_objnode_tree_init(void);
37686
37687 @@ -53,7 +53,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
37688 * A tmem host implementation must use this function to register
37689 * callbacks for a page-accessible memory (PAM) implementation
37690 */
37691 -static struct tmem_pamops tmem_pamops;
37692 +static tmem_pamops_no_const tmem_pamops;
37693
37694 void tmem_register_pamops(struct tmem_pamops *m)
37695 {
37696 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
37697 index ed147c4..94fc3c6 100644
37698 --- a/drivers/staging/zcache/tmem.h
37699 +++ b/drivers/staging/zcache/tmem.h
37700 @@ -180,6 +180,7 @@ struct tmem_pamops {
37701 void (*new_obj)(struct tmem_obj *);
37702 int (*replace_in_obj)(void *, struct tmem_obj *);
37703 };
37704 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
37705 extern void tmem_register_pamops(struct tmem_pamops *m);
37706
37707 /* memory allocation methods provided by the host implementation */
37708 @@ -189,6 +190,7 @@ struct tmem_hostops {
37709 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
37710 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
37711 };
37712 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
37713 extern void tmem_register_hostops(struct tmem_hostops *m);
37714
37715 /* core tmem accessor functions */
37716 diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
37717 index 97c74ee..7f6d77d 100644
37718 --- a/drivers/target/iscsi/iscsi_target.c
37719 +++ b/drivers/target/iscsi/iscsi_target.c
37720 @@ -1361,7 +1361,7 @@ static int iscsit_handle_data_out(struct iscsi_conn *conn, unsigned char *buf)
37721 * outstanding_r2ts reaches zero, go ahead and send the delayed
37722 * TASK_ABORTED status.
37723 */
37724 - if (atomic_read(&se_cmd->t_transport_aborted) != 0) {
37725 + if (atomic_read_unchecked(&se_cmd->t_transport_aborted) != 0) {
37726 if (hdr->flags & ISCSI_FLAG_CMD_FINAL)
37727 if (--cmd->outstanding_r2ts < 1) {
37728 iscsit_stop_dataout_timer(cmd);
37729 diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c
37730 index dcb0618..97e3d85 100644
37731 --- a/drivers/target/target_core_tmr.c
37732 +++ b/drivers/target/target_core_tmr.c
37733 @@ -260,7 +260,7 @@ static void core_tmr_drain_task_list(
37734 cmd->se_tfo->get_task_tag(cmd), cmd->pr_res_key,
37735 cmd->t_task_list_num,
37736 atomic_read(&cmd->t_task_cdbs_left),
37737 - atomic_read(&cmd->t_task_cdbs_sent),
37738 + atomic_read_unchecked(&cmd->t_task_cdbs_sent),
37739 atomic_read(&cmd->t_transport_active),
37740 atomic_read(&cmd->t_transport_stop),
37741 atomic_read(&cmd->t_transport_sent));
37742 @@ -291,7 +291,7 @@ static void core_tmr_drain_task_list(
37743 pr_debug("LUN_RESET: got t_transport_active = 1 for"
37744 " task: %p, t_fe_count: %d dev: %p\n", task,
37745 fe_count, dev);
37746 - atomic_set(&cmd->t_transport_aborted, 1);
37747 + atomic_set_unchecked(&cmd->t_transport_aborted, 1);
37748 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
37749
37750 core_tmr_handle_tas_abort(tmr_nacl, cmd, tas, fe_count);
37751 @@ -299,7 +299,7 @@ static void core_tmr_drain_task_list(
37752 }
37753 pr_debug("LUN_RESET: Got t_transport_active = 0 for task: %p,"
37754 " t_fe_count: %d dev: %p\n", task, fe_count, dev);
37755 - atomic_set(&cmd->t_transport_aborted, 1);
37756 + atomic_set_unchecked(&cmd->t_transport_aborted, 1);
37757 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
37758
37759 core_tmr_handle_tas_abort(tmr_nacl, cmd, tas, fe_count);
37760 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
37761 index cd5cd95..5249d30 100644
37762 --- a/drivers/target/target_core_transport.c
37763 +++ b/drivers/target/target_core_transport.c
37764 @@ -1330,7 +1330,7 @@ struct se_device *transport_add_device_to_core_hba(
37765 spin_lock_init(&dev->se_port_lock);
37766 spin_lock_init(&dev->se_tmr_lock);
37767 spin_lock_init(&dev->qf_cmd_lock);
37768 - atomic_set(&dev->dev_ordered_id, 0);
37769 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
37770
37771 se_dev_set_default_attribs(dev, dev_limits);
37772
37773 @@ -1517,7 +1517,7 @@ static int transport_check_alloc_task_attr(struct se_cmd *cmd)
37774 * Used to determine when ORDERED commands should go from
37775 * Dormant to Active status.
37776 */
37777 - cmd->se_ordered_id = atomic_inc_return(&cmd->se_dev->dev_ordered_id);
37778 + cmd->se_ordered_id = atomic_inc_return_unchecked(&cmd->se_dev->dev_ordered_id);
37779 smp_mb__after_atomic_inc();
37780 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
37781 cmd->se_ordered_id, cmd->sam_task_attr,
37782 @@ -1862,7 +1862,7 @@ static void transport_generic_request_failure(struct se_cmd *cmd)
37783 " t_transport_active: %d t_transport_stop: %d"
37784 " t_transport_sent: %d\n", cmd->t_task_list_num,
37785 atomic_read(&cmd->t_task_cdbs_left),
37786 - atomic_read(&cmd->t_task_cdbs_sent),
37787 + atomic_read_unchecked(&cmd->t_task_cdbs_sent),
37788 atomic_read(&cmd->t_task_cdbs_ex_left),
37789 atomic_read(&cmd->t_transport_active),
37790 atomic_read(&cmd->t_transport_stop),
37791 @@ -2121,9 +2121,9 @@ check_depth:
37792 cmd = task->task_se_cmd;
37793 spin_lock_irqsave(&cmd->t_state_lock, flags);
37794 task->task_flags |= (TF_ACTIVE | TF_SENT);
37795 - atomic_inc(&cmd->t_task_cdbs_sent);
37796 + atomic_inc_unchecked(&cmd->t_task_cdbs_sent);
37797
37798 - if (atomic_read(&cmd->t_task_cdbs_sent) ==
37799 + if (atomic_read_unchecked(&cmd->t_task_cdbs_sent) ==
37800 cmd->t_task_list_num)
37801 atomic_set(&cmd->t_transport_sent, 1);
37802
37803 @@ -4348,7 +4348,7 @@ bool transport_wait_for_tasks(struct se_cmd *cmd)
37804 atomic_set(&cmd->transport_lun_stop, 0);
37805 }
37806 if (!atomic_read(&cmd->t_transport_active) ||
37807 - atomic_read(&cmd->t_transport_aborted)) {
37808 + atomic_read_unchecked(&cmd->t_transport_aborted)) {
37809 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
37810 return false;
37811 }
37812 @@ -4597,7 +4597,7 @@ int transport_check_aborted_status(struct se_cmd *cmd, int send_status)
37813 {
37814 int ret = 0;
37815
37816 - if (atomic_read(&cmd->t_transport_aborted) != 0) {
37817 + if (atomic_read_unchecked(&cmd->t_transport_aborted) != 0) {
37818 if (!send_status ||
37819 (cmd->se_cmd_flags & SCF_SENT_DELAYED_TAS))
37820 return 1;
37821 @@ -4634,7 +4634,7 @@ void transport_send_task_abort(struct se_cmd *cmd)
37822 */
37823 if (cmd->data_direction == DMA_TO_DEVICE) {
37824 if (cmd->se_tfo->write_pending_status(cmd) != 0) {
37825 - atomic_inc(&cmd->t_transport_aborted);
37826 + atomic_inc_unchecked(&cmd->t_transport_aborted);
37827 smp_mb__after_atomic_inc();
37828 }
37829 }
37830 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
37831 index b9040be..e3f5aab 100644
37832 --- a/drivers/tty/hvc/hvcs.c
37833 +++ b/drivers/tty/hvc/hvcs.c
37834 @@ -83,6 +83,7 @@
37835 #include <asm/hvcserver.h>
37836 #include <asm/uaccess.h>
37837 #include <asm/vio.h>
37838 +#include <asm/local.h>
37839
37840 /*
37841 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
37842 @@ -270,7 +271,7 @@ struct hvcs_struct {
37843 unsigned int index;
37844
37845 struct tty_struct *tty;
37846 - int open_count;
37847 + local_t open_count;
37848
37849 /*
37850 * Used to tell the driver kernel_thread what operations need to take
37851 @@ -422,7 +423,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
37852
37853 spin_lock_irqsave(&hvcsd->lock, flags);
37854
37855 - if (hvcsd->open_count > 0) {
37856 + if (local_read(&hvcsd->open_count) > 0) {
37857 spin_unlock_irqrestore(&hvcsd->lock, flags);
37858 printk(KERN_INFO "HVCS: vterm state unchanged. "
37859 "The hvcs device node is still in use.\n");
37860 @@ -1145,7 +1146,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
37861 if ((retval = hvcs_partner_connect(hvcsd)))
37862 goto error_release;
37863
37864 - hvcsd->open_count = 1;
37865 + local_set(&hvcsd->open_count, 1);
37866 hvcsd->tty = tty;
37867 tty->driver_data = hvcsd;
37868
37869 @@ -1179,7 +1180,7 @@ fast_open:
37870
37871 spin_lock_irqsave(&hvcsd->lock, flags);
37872 kref_get(&hvcsd->kref);
37873 - hvcsd->open_count++;
37874 + local_inc(&hvcsd->open_count);
37875 hvcsd->todo_mask |= HVCS_SCHED_READ;
37876 spin_unlock_irqrestore(&hvcsd->lock, flags);
37877
37878 @@ -1223,7 +1224,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
37879 hvcsd = tty->driver_data;
37880
37881 spin_lock_irqsave(&hvcsd->lock, flags);
37882 - if (--hvcsd->open_count == 0) {
37883 + if (local_dec_and_test(&hvcsd->open_count)) {
37884
37885 vio_disable_interrupts(hvcsd->vdev);
37886
37887 @@ -1249,10 +1250,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
37888 free_irq(irq, hvcsd);
37889 kref_put(&hvcsd->kref, destroy_hvcs_struct);
37890 return;
37891 - } else if (hvcsd->open_count < 0) {
37892 + } else if (local_read(&hvcsd->open_count) < 0) {
37893 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
37894 " is missmanaged.\n",
37895 - hvcsd->vdev->unit_address, hvcsd->open_count);
37896 + hvcsd->vdev->unit_address, local_read(&hvcsd->open_count));
37897 }
37898
37899 spin_unlock_irqrestore(&hvcsd->lock, flags);
37900 @@ -1268,7 +1269,7 @@ static void hvcs_hangup(struct tty_struct * tty)
37901
37902 spin_lock_irqsave(&hvcsd->lock, flags);
37903 /* Preserve this so that we know how many kref refs to put */
37904 - temp_open_count = hvcsd->open_count;
37905 + temp_open_count = local_read(&hvcsd->open_count);
37906
37907 /*
37908 * Don't kref put inside the spinlock because the destruction
37909 @@ -1283,7 +1284,7 @@ static void hvcs_hangup(struct tty_struct * tty)
37910 hvcsd->tty->driver_data = NULL;
37911 hvcsd->tty = NULL;
37912
37913 - hvcsd->open_count = 0;
37914 + local_set(&hvcsd->open_count, 0);
37915
37916 /* This will drop any buffered data on the floor which is OK in a hangup
37917 * scenario. */
37918 @@ -1354,7 +1355,7 @@ static int hvcs_write(struct tty_struct *tty,
37919 * the middle of a write operation? This is a crummy place to do this
37920 * but we want to keep it all in the spinlock.
37921 */
37922 - if (hvcsd->open_count <= 0) {
37923 + if (local_read(&hvcsd->open_count) <= 0) {
37924 spin_unlock_irqrestore(&hvcsd->lock, flags);
37925 return -ENODEV;
37926 }
37927 @@ -1428,7 +1429,7 @@ static int hvcs_write_room(struct tty_struct *tty)
37928 {
37929 struct hvcs_struct *hvcsd = tty->driver_data;
37930
37931 - if (!hvcsd || hvcsd->open_count <= 0)
37932 + if (!hvcsd || local_read(&hvcsd->open_count) <= 0)
37933 return 0;
37934
37935 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
37936 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
37937 index ef92869..f4ebd88 100644
37938 --- a/drivers/tty/ipwireless/tty.c
37939 +++ b/drivers/tty/ipwireless/tty.c
37940 @@ -29,6 +29,7 @@
37941 #include <linux/tty_driver.h>
37942 #include <linux/tty_flip.h>
37943 #include <linux/uaccess.h>
37944 +#include <asm/local.h>
37945
37946 #include "tty.h"
37947 #include "network.h"
37948 @@ -51,7 +52,7 @@ struct ipw_tty {
37949 int tty_type;
37950 struct ipw_network *network;
37951 struct tty_struct *linux_tty;
37952 - int open_count;
37953 + local_t open_count;
37954 unsigned int control_lines;
37955 struct mutex ipw_tty_mutex;
37956 int tx_bytes_queued;
37957 @@ -127,10 +128,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
37958 mutex_unlock(&tty->ipw_tty_mutex);
37959 return -ENODEV;
37960 }
37961 - if (tty->open_count == 0)
37962 + if (local_read(&tty->open_count) == 0)
37963 tty->tx_bytes_queued = 0;
37964
37965 - tty->open_count++;
37966 + local_inc(&tty->open_count);
37967
37968 tty->linux_tty = linux_tty;
37969 linux_tty->driver_data = tty;
37970 @@ -146,9 +147,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
37971
37972 static void do_ipw_close(struct ipw_tty *tty)
37973 {
37974 - tty->open_count--;
37975 -
37976 - if (tty->open_count == 0) {
37977 + if (local_dec_return(&tty->open_count) == 0) {
37978 struct tty_struct *linux_tty = tty->linux_tty;
37979
37980 if (linux_tty != NULL) {
37981 @@ -169,7 +168,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
37982 return;
37983
37984 mutex_lock(&tty->ipw_tty_mutex);
37985 - if (tty->open_count == 0) {
37986 + if (local_read(&tty->open_count) == 0) {
37987 mutex_unlock(&tty->ipw_tty_mutex);
37988 return;
37989 }
37990 @@ -198,7 +197,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
37991 return;
37992 }
37993
37994 - if (!tty->open_count) {
37995 + if (!local_read(&tty->open_count)) {
37996 mutex_unlock(&tty->ipw_tty_mutex);
37997 return;
37998 }
37999 @@ -240,7 +239,7 @@ static int ipw_write(struct tty_struct *linux_tty,
38000 return -ENODEV;
38001
38002 mutex_lock(&tty->ipw_tty_mutex);
38003 - if (!tty->open_count) {
38004 + if (!local_read(&tty->open_count)) {
38005 mutex_unlock(&tty->ipw_tty_mutex);
38006 return -EINVAL;
38007 }
38008 @@ -280,7 +279,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
38009 if (!tty)
38010 return -ENODEV;
38011
38012 - if (!tty->open_count)
38013 + if (!local_read(&tty->open_count))
38014 return -EINVAL;
38015
38016 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
38017 @@ -322,7 +321,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
38018 if (!tty)
38019 return 0;
38020
38021 - if (!tty->open_count)
38022 + if (!local_read(&tty->open_count))
38023 return 0;
38024
38025 return tty->tx_bytes_queued;
38026 @@ -403,7 +402,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
38027 if (!tty)
38028 return -ENODEV;
38029
38030 - if (!tty->open_count)
38031 + if (!local_read(&tty->open_count))
38032 return -EINVAL;
38033
38034 return get_control_lines(tty);
38035 @@ -419,7 +418,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
38036 if (!tty)
38037 return -ENODEV;
38038
38039 - if (!tty->open_count)
38040 + if (!local_read(&tty->open_count))
38041 return -EINVAL;
38042
38043 return set_control_lines(tty, set, clear);
38044 @@ -433,7 +432,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
38045 if (!tty)
38046 return -ENODEV;
38047
38048 - if (!tty->open_count)
38049 + if (!local_read(&tty->open_count))
38050 return -EINVAL;
38051
38052 /* FIXME: Exactly how is the tty object locked here .. */
38053 @@ -582,7 +581,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
38054 against a parallel ioctl etc */
38055 mutex_lock(&ttyj->ipw_tty_mutex);
38056 }
38057 - while (ttyj->open_count)
38058 + while (local_read(&ttyj->open_count))
38059 do_ipw_close(ttyj);
38060 ipwireless_disassociate_network_ttys(network,
38061 ttyj->channel_idx);
38062 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
38063 index fc7bbba..9527e93 100644
38064 --- a/drivers/tty/n_gsm.c
38065 +++ b/drivers/tty/n_gsm.c
38066 @@ -1629,7 +1629,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
38067 kref_init(&dlci->ref);
38068 mutex_init(&dlci->mutex);
38069 dlci->fifo = &dlci->_fifo;
38070 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
38071 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
38072 kfree(dlci);
38073 return NULL;
38074 }
38075 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
38076 index d2256d0..97476fa 100644
38077 --- a/drivers/tty/n_tty.c
38078 +++ b/drivers/tty/n_tty.c
38079 @@ -2123,6 +2123,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
38080 {
38081 *ops = tty_ldisc_N_TTY;
38082 ops->owner = NULL;
38083 - ops->refcount = ops->flags = 0;
38084 + atomic_set(&ops->refcount, 0);
38085 + ops->flags = 0;
38086 }
38087 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
38088 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
38089 index d8653ab..f8afd9d 100644
38090 --- a/drivers/tty/pty.c
38091 +++ b/drivers/tty/pty.c
38092 @@ -765,8 +765,10 @@ static void __init unix98_pty_init(void)
38093 register_sysctl_table(pty_root_table);
38094
38095 /* Now create the /dev/ptmx special device */
38096 + pax_open_kernel();
38097 tty_default_fops(&ptmx_fops);
38098 - ptmx_fops.open = ptmx_open;
38099 + *(void **)&ptmx_fops.open = ptmx_open;
38100 + pax_close_kernel();
38101
38102 cdev_init(&ptmx_cdev, &ptmx_fops);
38103 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
38104 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
38105 index 2b42a01..32a2ed3 100644
38106 --- a/drivers/tty/serial/kgdboc.c
38107 +++ b/drivers/tty/serial/kgdboc.c
38108 @@ -24,8 +24,9 @@
38109 #define MAX_CONFIG_LEN 40
38110
38111 static struct kgdb_io kgdboc_io_ops;
38112 +static struct kgdb_io kgdboc_io_ops_console;
38113
38114 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
38115 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
38116 static int configured = -1;
38117
38118 static char config[MAX_CONFIG_LEN];
38119 @@ -148,6 +149,8 @@ static void cleanup_kgdboc(void)
38120 kgdboc_unregister_kbd();
38121 if (configured == 1)
38122 kgdb_unregister_io_module(&kgdboc_io_ops);
38123 + else if (configured == 2)
38124 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
38125 }
38126
38127 static int configure_kgdboc(void)
38128 @@ -157,13 +160,13 @@ static int configure_kgdboc(void)
38129 int err;
38130 char *cptr = config;
38131 struct console *cons;
38132 + int is_console = 0;
38133
38134 err = kgdboc_option_setup(config);
38135 if (err || !strlen(config) || isspace(config[0]))
38136 goto noconfig;
38137
38138 err = -ENODEV;
38139 - kgdboc_io_ops.is_console = 0;
38140 kgdb_tty_driver = NULL;
38141
38142 kgdboc_use_kms = 0;
38143 @@ -184,7 +187,7 @@ static int configure_kgdboc(void)
38144 int idx;
38145 if (cons->device && cons->device(cons, &idx) == p &&
38146 idx == tty_line) {
38147 - kgdboc_io_ops.is_console = 1;
38148 + is_console = 1;
38149 break;
38150 }
38151 cons = cons->next;
38152 @@ -194,12 +197,16 @@ static int configure_kgdboc(void)
38153 kgdb_tty_line = tty_line;
38154
38155 do_register:
38156 - err = kgdb_register_io_module(&kgdboc_io_ops);
38157 + if (is_console) {
38158 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
38159 + configured = 2;
38160 + } else {
38161 + err = kgdb_register_io_module(&kgdboc_io_ops);
38162 + configured = 1;
38163 + }
38164 if (err)
38165 goto noconfig;
38166
38167 - configured = 1;
38168 -
38169 return 0;
38170
38171 noconfig:
38172 @@ -213,7 +220,7 @@ noconfig:
38173 static int __init init_kgdboc(void)
38174 {
38175 /* Already configured? */
38176 - if (configured == 1)
38177 + if (configured >= 1)
38178 return 0;
38179
38180 return configure_kgdboc();
38181 @@ -262,7 +269,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
38182 if (config[len - 1] == '\n')
38183 config[len - 1] = '\0';
38184
38185 - if (configured == 1)
38186 + if (configured >= 1)
38187 cleanup_kgdboc();
38188
38189 /* Go and configure with the new params. */
38190 @@ -302,6 +309,15 @@ static struct kgdb_io kgdboc_io_ops = {
38191 .post_exception = kgdboc_post_exp_handler,
38192 };
38193
38194 +static struct kgdb_io kgdboc_io_ops_console = {
38195 + .name = "kgdboc",
38196 + .read_char = kgdboc_get_char,
38197 + .write_char = kgdboc_put_char,
38198 + .pre_exception = kgdboc_pre_exp_handler,
38199 + .post_exception = kgdboc_post_exp_handler,
38200 + .is_console = 1
38201 +};
38202 +
38203 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
38204 /* This is only available if kgdboc is a built in for early debugging */
38205 static int __init kgdboc_early_init(char *opt)
38206 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
38207 index 7867b7c..b3c119d 100644
38208 --- a/drivers/tty/sysrq.c
38209 +++ b/drivers/tty/sysrq.c
38210 @@ -862,7 +862,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
38211 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
38212 size_t count, loff_t *ppos)
38213 {
38214 - if (count) {
38215 + if (count && capable(CAP_SYS_ADMIN)) {
38216 char c;
38217
38218 if (get_user(c, buf))
38219 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
38220 index e41b9bb..84002fb 100644
38221 --- a/drivers/tty/tty_io.c
38222 +++ b/drivers/tty/tty_io.c
38223 @@ -3291,7 +3291,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
38224
38225 void tty_default_fops(struct file_operations *fops)
38226 {
38227 - *fops = tty_fops;
38228 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
38229 }
38230
38231 /*
38232 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
38233 index 24b95db..9c078d0 100644
38234 --- a/drivers/tty/tty_ldisc.c
38235 +++ b/drivers/tty/tty_ldisc.c
38236 @@ -57,7 +57,7 @@ static void put_ldisc(struct tty_ldisc *ld)
38237 if (atomic_dec_and_lock(&ld->users, &tty_ldisc_lock)) {
38238 struct tty_ldisc_ops *ldo = ld->ops;
38239
38240 - ldo->refcount--;
38241 + atomic_dec(&ldo->refcount);
38242 module_put(ldo->owner);
38243 spin_unlock_irqrestore(&tty_ldisc_lock, flags);
38244
38245 @@ -92,7 +92,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
38246 spin_lock_irqsave(&tty_ldisc_lock, flags);
38247 tty_ldiscs[disc] = new_ldisc;
38248 new_ldisc->num = disc;
38249 - new_ldisc->refcount = 0;
38250 + atomic_set(&new_ldisc->refcount, 0);
38251 spin_unlock_irqrestore(&tty_ldisc_lock, flags);
38252
38253 return ret;
38254 @@ -120,7 +120,7 @@ int tty_unregister_ldisc(int disc)
38255 return -EINVAL;
38256
38257 spin_lock_irqsave(&tty_ldisc_lock, flags);
38258 - if (tty_ldiscs[disc]->refcount)
38259 + if (atomic_read(&tty_ldiscs[disc]->refcount))
38260 ret = -EBUSY;
38261 else
38262 tty_ldiscs[disc] = NULL;
38263 @@ -141,7 +141,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
38264 if (ldops) {
38265 ret = ERR_PTR(-EAGAIN);
38266 if (try_module_get(ldops->owner)) {
38267 - ldops->refcount++;
38268 + atomic_inc(&ldops->refcount);
38269 ret = ldops;
38270 }
38271 }
38272 @@ -154,7 +154,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
38273 unsigned long flags;
38274
38275 spin_lock_irqsave(&tty_ldisc_lock, flags);
38276 - ldops->refcount--;
38277 + atomic_dec(&ldops->refcount);
38278 module_put(ldops->owner);
38279 spin_unlock_irqrestore(&tty_ldisc_lock, flags);
38280 }
38281 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
38282 index a605549..6bd3c96 100644
38283 --- a/drivers/tty/vt/keyboard.c
38284 +++ b/drivers/tty/vt/keyboard.c
38285 @@ -657,6 +657,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
38286 kbd->kbdmode == VC_OFF) &&
38287 value != KVAL(K_SAK))
38288 return; /* SAK is allowed even in raw mode */
38289 +
38290 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
38291 + {
38292 + void *func = fn_handler[value];
38293 + if (func == fn_show_state || func == fn_show_ptregs ||
38294 + func == fn_show_mem)
38295 + return;
38296 + }
38297 +#endif
38298 +
38299 fn_handler[value](vc);
38300 }
38301
38302 diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c
38303 index 65447c5..0526f0a 100644
38304 --- a/drivers/tty/vt/vt_ioctl.c
38305 +++ b/drivers/tty/vt/vt_ioctl.c
38306 @@ -207,9 +207,6 @@ do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm, struct kbd_str
38307 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
38308 return -EFAULT;
38309
38310 - if (!capable(CAP_SYS_TTY_CONFIG))
38311 - perm = 0;
38312 -
38313 switch (cmd) {
38314 case KDGKBENT:
38315 key_map = key_maps[s];
38316 @@ -221,6 +218,9 @@ do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm, struct kbd_str
38317 val = (i ? K_HOLE : K_NOSUCHMAP);
38318 return put_user(val, &user_kbe->kb_value);
38319 case KDSKBENT:
38320 + if (!capable(CAP_SYS_TTY_CONFIG))
38321 + perm = 0;
38322 +
38323 if (!perm)
38324 return -EPERM;
38325 if (!i && v == K_NOSUCHMAP) {
38326 @@ -322,9 +322,6 @@ do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
38327 int i, j, k;
38328 int ret;
38329
38330 - if (!capable(CAP_SYS_TTY_CONFIG))
38331 - perm = 0;
38332 -
38333 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
38334 if (!kbs) {
38335 ret = -ENOMEM;
38336 @@ -358,6 +355,9 @@ do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
38337 kfree(kbs);
38338 return ((p && *p) ? -EOVERFLOW : 0);
38339 case KDSKBSENT:
38340 + if (!capable(CAP_SYS_TTY_CONFIG))
38341 + perm = 0;
38342 +
38343 if (!perm) {
38344 ret = -EPERM;
38345 goto reterr;
38346 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
38347 index a783d53..cb30d94 100644
38348 --- a/drivers/uio/uio.c
38349 +++ b/drivers/uio/uio.c
38350 @@ -25,6 +25,7 @@
38351 #include <linux/kobject.h>
38352 #include <linux/cdev.h>
38353 #include <linux/uio_driver.h>
38354 +#include <asm/local.h>
38355
38356 #define UIO_MAX_DEVICES (1U << MINORBITS)
38357
38358 @@ -32,10 +33,10 @@ struct uio_device {
38359 struct module *owner;
38360 struct device *dev;
38361 int minor;
38362 - atomic_t event;
38363 + atomic_unchecked_t event;
38364 struct fasync_struct *async_queue;
38365 wait_queue_head_t wait;
38366 - int vma_count;
38367 + local_t vma_count;
38368 struct uio_info *info;
38369 struct kobject *map_dir;
38370 struct kobject *portio_dir;
38371 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
38372 struct device_attribute *attr, char *buf)
38373 {
38374 struct uio_device *idev = dev_get_drvdata(dev);
38375 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
38376 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
38377 }
38378
38379 static struct device_attribute uio_class_attributes[] = {
38380 @@ -408,7 +409,7 @@ void uio_event_notify(struct uio_info *info)
38381 {
38382 struct uio_device *idev = info->uio_dev;
38383
38384 - atomic_inc(&idev->event);
38385 + atomic_inc_unchecked(&idev->event);
38386 wake_up_interruptible(&idev->wait);
38387 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
38388 }
38389 @@ -461,7 +462,7 @@ static int uio_open(struct inode *inode, struct file *filep)
38390 }
38391
38392 listener->dev = idev;
38393 - listener->event_count = atomic_read(&idev->event);
38394 + listener->event_count = atomic_read_unchecked(&idev->event);
38395 filep->private_data = listener;
38396
38397 if (idev->info->open) {
38398 @@ -512,7 +513,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
38399 return -EIO;
38400
38401 poll_wait(filep, &idev->wait, wait);
38402 - if (listener->event_count != atomic_read(&idev->event))
38403 + if (listener->event_count != atomic_read_unchecked(&idev->event))
38404 return POLLIN | POLLRDNORM;
38405 return 0;
38406 }
38407 @@ -537,7 +538,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
38408 do {
38409 set_current_state(TASK_INTERRUPTIBLE);
38410
38411 - event_count = atomic_read(&idev->event);
38412 + event_count = atomic_read_unchecked(&idev->event);
38413 if (event_count != listener->event_count) {
38414 if (copy_to_user(buf, &event_count, count))
38415 retval = -EFAULT;
38416 @@ -606,13 +607,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
38417 static void uio_vma_open(struct vm_area_struct *vma)
38418 {
38419 struct uio_device *idev = vma->vm_private_data;
38420 - idev->vma_count++;
38421 + local_inc(&idev->vma_count);
38422 }
38423
38424 static void uio_vma_close(struct vm_area_struct *vma)
38425 {
38426 struct uio_device *idev = vma->vm_private_data;
38427 - idev->vma_count--;
38428 + local_dec(&idev->vma_count);
38429 }
38430
38431 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
38432 @@ -821,7 +822,7 @@ int __uio_register_device(struct module *owner,
38433 idev->owner = owner;
38434 idev->info = info;
38435 init_waitqueue_head(&idev->wait);
38436 - atomic_set(&idev->event, 0);
38437 + atomic_set_unchecked(&idev->event, 0);
38438
38439 ret = uio_get_minor(idev);
38440 if (ret)
38441 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
38442 index 98b89fe..aff824e 100644
38443 --- a/drivers/usb/atm/cxacru.c
38444 +++ b/drivers/usb/atm/cxacru.c
38445 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
38446 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
38447 if (ret < 2)
38448 return -EINVAL;
38449 - if (index < 0 || index > 0x7f)
38450 + if (index > 0x7f)
38451 return -EINVAL;
38452 pos += tmp;
38453
38454 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
38455 index d3448ca..d2864ca 100644
38456 --- a/drivers/usb/atm/usbatm.c
38457 +++ b/drivers/usb/atm/usbatm.c
38458 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
38459 if (printk_ratelimit())
38460 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
38461 __func__, vpi, vci);
38462 - atomic_inc(&vcc->stats->rx_err);
38463 + atomic_inc_unchecked(&vcc->stats->rx_err);
38464 return;
38465 }
38466
38467 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
38468 if (length > ATM_MAX_AAL5_PDU) {
38469 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
38470 __func__, length, vcc);
38471 - atomic_inc(&vcc->stats->rx_err);
38472 + atomic_inc_unchecked(&vcc->stats->rx_err);
38473 goto out;
38474 }
38475
38476 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
38477 if (sarb->len < pdu_length) {
38478 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
38479 __func__, pdu_length, sarb->len, vcc);
38480 - atomic_inc(&vcc->stats->rx_err);
38481 + atomic_inc_unchecked(&vcc->stats->rx_err);
38482 goto out;
38483 }
38484
38485 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
38486 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
38487 __func__, vcc);
38488 - atomic_inc(&vcc->stats->rx_err);
38489 + atomic_inc_unchecked(&vcc->stats->rx_err);
38490 goto out;
38491 }
38492
38493 @@ -387,7 +387,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
38494 if (printk_ratelimit())
38495 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
38496 __func__, length);
38497 - atomic_inc(&vcc->stats->rx_drop);
38498 + atomic_inc_unchecked(&vcc->stats->rx_drop);
38499 goto out;
38500 }
38501
38502 @@ -412,7 +412,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
38503
38504 vcc->push(vcc, skb);
38505
38506 - atomic_inc(&vcc->stats->rx);
38507 + atomic_inc_unchecked(&vcc->stats->rx);
38508 out:
38509 skb_trim(sarb, 0);
38510 }
38511 @@ -615,7 +615,7 @@ static void usbatm_tx_process(unsigned long data)
38512 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
38513
38514 usbatm_pop(vcc, skb);
38515 - atomic_inc(&vcc->stats->tx);
38516 + atomic_inc_unchecked(&vcc->stats->tx);
38517
38518 skb = skb_dequeue(&instance->sndqueue);
38519 }
38520 @@ -773,11 +773,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
38521 if (!left--)
38522 return sprintf(page,
38523 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
38524 - atomic_read(&atm_dev->stats.aal5.tx),
38525 - atomic_read(&atm_dev->stats.aal5.tx_err),
38526 - atomic_read(&atm_dev->stats.aal5.rx),
38527 - atomic_read(&atm_dev->stats.aal5.rx_err),
38528 - atomic_read(&atm_dev->stats.aal5.rx_drop));
38529 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
38530 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
38531 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
38532 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
38533 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
38534
38535 if (!left--) {
38536 if (instance->disconnected)
38537 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
38538 index d956965..4179a77 100644
38539 --- a/drivers/usb/core/devices.c
38540 +++ b/drivers/usb/core/devices.c
38541 @@ -126,7 +126,7 @@ static const char format_endpt[] =
38542 * time it gets called.
38543 */
38544 static struct device_connect_event {
38545 - atomic_t count;
38546 + atomic_unchecked_t count;
38547 wait_queue_head_t wait;
38548 } device_event = {
38549 .count = ATOMIC_INIT(1),
38550 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
38551
38552 void usbfs_conn_disc_event(void)
38553 {
38554 - atomic_add(2, &device_event.count);
38555 + atomic_add_unchecked(2, &device_event.count);
38556 wake_up(&device_event.wait);
38557 }
38558
38559 @@ -648,7 +648,7 @@ static unsigned int usb_device_poll(struct file *file,
38560
38561 poll_wait(file, &device_event.wait, wait);
38562
38563 - event_count = atomic_read(&device_event.count);
38564 + event_count = atomic_read_unchecked(&device_event.count);
38565 if (file->f_version != event_count) {
38566 file->f_version = event_count;
38567 return POLLIN | POLLRDNORM;
38568 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
38569 index 1fc8f12..20647c1 100644
38570 --- a/drivers/usb/early/ehci-dbgp.c
38571 +++ b/drivers/usb/early/ehci-dbgp.c
38572 @@ -97,7 +97,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
38573
38574 #ifdef CONFIG_KGDB
38575 static struct kgdb_io kgdbdbgp_io_ops;
38576 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
38577 +static struct kgdb_io kgdbdbgp_io_ops_console;
38578 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
38579 #else
38580 #define dbgp_kgdb_mode (0)
38581 #endif
38582 @@ -1035,6 +1036,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
38583 .write_char = kgdbdbgp_write_char,
38584 };
38585
38586 +static struct kgdb_io kgdbdbgp_io_ops_console = {
38587 + .name = "kgdbdbgp",
38588 + .read_char = kgdbdbgp_read_char,
38589 + .write_char = kgdbdbgp_write_char,
38590 + .is_console = 1
38591 +};
38592 +
38593 static int kgdbdbgp_wait_time;
38594
38595 static int __init kgdbdbgp_parse_config(char *str)
38596 @@ -1050,8 +1058,10 @@ static int __init kgdbdbgp_parse_config(char *str)
38597 ptr++;
38598 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
38599 }
38600 - kgdb_register_io_module(&kgdbdbgp_io_ops);
38601 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
38602 + if (early_dbgp_console.index != -1)
38603 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
38604 + else
38605 + kgdb_register_io_module(&kgdbdbgp_io_ops);
38606
38607 return 0;
38608 }
38609 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
38610 index d6bea3e..60b250e 100644
38611 --- a/drivers/usb/wusbcore/wa-hc.h
38612 +++ b/drivers/usb/wusbcore/wa-hc.h
38613 @@ -192,7 +192,7 @@ struct wahc {
38614 struct list_head xfer_delayed_list;
38615 spinlock_t xfer_list_lock;
38616 struct work_struct xfer_work;
38617 - atomic_t xfer_id_count;
38618 + atomic_unchecked_t xfer_id_count;
38619 };
38620
38621
38622 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
38623 INIT_LIST_HEAD(&wa->xfer_delayed_list);
38624 spin_lock_init(&wa->xfer_list_lock);
38625 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
38626 - atomic_set(&wa->xfer_id_count, 1);
38627 + atomic_set_unchecked(&wa->xfer_id_count, 1);
38628 }
38629
38630 /**
38631 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
38632 index 57c01ab..8a05959 100644
38633 --- a/drivers/usb/wusbcore/wa-xfer.c
38634 +++ b/drivers/usb/wusbcore/wa-xfer.c
38635 @@ -296,7 +296,7 @@ out:
38636 */
38637 static void wa_xfer_id_init(struct wa_xfer *xfer)
38638 {
38639 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
38640 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
38641 }
38642
38643 /*
38644 diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
38645 index c14c42b..f955cc2 100644
38646 --- a/drivers/vhost/vhost.c
38647 +++ b/drivers/vhost/vhost.c
38648 @@ -629,7 +629,7 @@ static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m)
38649 return 0;
38650 }
38651
38652 -static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
38653 +static long vhost_set_vring(struct vhost_dev *d, unsigned int ioctl, void __user *argp)
38654 {
38655 struct file *eventfp, *filep = NULL,
38656 *pollstart = NULL, *pollstop = NULL;
38657 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
38658 index b0b2ac3..89a4399 100644
38659 --- a/drivers/video/aty/aty128fb.c
38660 +++ b/drivers/video/aty/aty128fb.c
38661 @@ -148,7 +148,7 @@ enum {
38662 };
38663
38664 /* Must match above enum */
38665 -static const char *r128_family[] __devinitdata = {
38666 +static const char *r128_family[] __devinitconst = {
38667 "AGP",
38668 "PCI",
38669 "PRO AGP",
38670 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
38671 index 5c3960d..15cf8fc 100644
38672 --- a/drivers/video/fbcmap.c
38673 +++ b/drivers/video/fbcmap.c
38674 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
38675 rc = -ENODEV;
38676 goto out;
38677 }
38678 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
38679 - !info->fbops->fb_setcmap)) {
38680 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
38681 rc = -EINVAL;
38682 goto out1;
38683 }
38684 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
38685 index c6ce416..3b9b642 100644
38686 --- a/drivers/video/fbmem.c
38687 +++ b/drivers/video/fbmem.c
38688 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
38689 image->dx += image->width + 8;
38690 }
38691 } else if (rotate == FB_ROTATE_UD) {
38692 - for (x = 0; x < num && image->dx >= 0; x++) {
38693 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
38694 info->fbops->fb_imageblit(info, image);
38695 image->dx -= image->width + 8;
38696 }
38697 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
38698 image->dy += image->height + 8;
38699 }
38700 } else if (rotate == FB_ROTATE_CCW) {
38701 - for (x = 0; x < num && image->dy >= 0; x++) {
38702 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
38703 info->fbops->fb_imageblit(info, image);
38704 image->dy -= image->height + 8;
38705 }
38706 @@ -1157,7 +1157,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
38707 return -EFAULT;
38708 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
38709 return -EINVAL;
38710 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
38711 + if (con2fb.framebuffer >= FB_MAX)
38712 return -EINVAL;
38713 if (!registered_fb[con2fb.framebuffer])
38714 request_module("fb%d", con2fb.framebuffer);
38715 diff --git a/drivers/video/geode/gx1fb_core.c b/drivers/video/geode/gx1fb_core.c
38716 index 5a5d092..265c5ed 100644
38717 --- a/drivers/video/geode/gx1fb_core.c
38718 +++ b/drivers/video/geode/gx1fb_core.c
38719 @@ -29,7 +29,7 @@ static int crt_option = 1;
38720 static char panel_option[32] = "";
38721
38722 /* Modes relevant to the GX1 (taken from modedb.c) */
38723 -static const struct fb_videomode __devinitdata gx1_modedb[] = {
38724 +static const struct fb_videomode __devinitconst gx1_modedb[] = {
38725 /* 640x480-60 VESA */
38726 { NULL, 60, 640, 480, 39682, 48, 16, 33, 10, 96, 2,
38727 0, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
38728 diff --git a/drivers/video/gxt4500.c b/drivers/video/gxt4500.c
38729 index 0fad23f..0e9afa4 100644
38730 --- a/drivers/video/gxt4500.c
38731 +++ b/drivers/video/gxt4500.c
38732 @@ -156,7 +156,7 @@ struct gxt4500_par {
38733 static char *mode_option;
38734
38735 /* default mode: 1280x1024 @ 60 Hz, 8 bpp */
38736 -static const struct fb_videomode defaultmode __devinitdata = {
38737 +static const struct fb_videomode defaultmode __devinitconst = {
38738 .refresh = 60,
38739 .xres = 1280,
38740 .yres = 1024,
38741 @@ -581,7 +581,7 @@ static int gxt4500_blank(int blank, struct fb_info *info)
38742 return 0;
38743 }
38744
38745 -static const struct fb_fix_screeninfo gxt4500_fix __devinitdata = {
38746 +static const struct fb_fix_screeninfo gxt4500_fix __devinitconst = {
38747 .id = "IBM GXT4500P",
38748 .type = FB_TYPE_PACKED_PIXELS,
38749 .visual = FB_VISUAL_PSEUDOCOLOR,
38750 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
38751 index 7672d2e..b56437f 100644
38752 --- a/drivers/video/i810/i810_accel.c
38753 +++ b/drivers/video/i810/i810_accel.c
38754 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
38755 }
38756 }
38757 printk("ringbuffer lockup!!!\n");
38758 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
38759 i810_report_error(mmio);
38760 par->dev_flags |= LOCKUP;
38761 info->pixmap.scan_align = 1;
38762 diff --git a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c
38763 index b83f361..2b05a91 100644
38764 --- a/drivers/video/i810/i810_main.c
38765 +++ b/drivers/video/i810/i810_main.c
38766 @@ -97,7 +97,7 @@ static int i810fb_blank (int blank_mode, struct fb_info *info);
38767 static void i810fb_release_resource (struct fb_info *info, struct i810fb_par *par);
38768
38769 /* PCI */
38770 -static const char *i810_pci_list[] __devinitdata = {
38771 +static const char *i810_pci_list[] __devinitconst = {
38772 "Intel(R) 810 Framebuffer Device" ,
38773 "Intel(R) 810-DC100 Framebuffer Device" ,
38774 "Intel(R) 810E Framebuffer Device" ,
38775 diff --git a/drivers/video/jz4740_fb.c b/drivers/video/jz4740_fb.c
38776 index de36693..3c63fc2 100644
38777 --- a/drivers/video/jz4740_fb.c
38778 +++ b/drivers/video/jz4740_fb.c
38779 @@ -136,7 +136,7 @@ struct jzfb {
38780 uint32_t pseudo_palette[16];
38781 };
38782
38783 -static const struct fb_fix_screeninfo jzfb_fix __devinitdata = {
38784 +static const struct fb_fix_screeninfo jzfb_fix __devinitconst = {
38785 .id = "JZ4740 FB",
38786 .type = FB_TYPE_PACKED_PIXELS,
38787 .visual = FB_VISUAL_TRUECOLOR,
38788 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
38789 index 3c14e43..eafa544 100644
38790 --- a/drivers/video/logo/logo_linux_clut224.ppm
38791 +++ b/drivers/video/logo/logo_linux_clut224.ppm
38792 @@ -1,1604 +1,1123 @@
38793 P3
38794 -# Standard 224-color Linux logo
38795 80 80
38796 255
38797 - 0 0 0 0 0 0 0 0 0 0 0 0
38798 - 0 0 0 0 0 0 0 0 0 0 0 0
38799 - 0 0 0 0 0 0 0 0 0 0 0 0
38800 - 0 0 0 0 0 0 0 0 0 0 0 0
38801 - 0 0 0 0 0 0 0 0 0 0 0 0
38802 - 0 0 0 0 0 0 0 0 0 0 0 0
38803 - 0 0 0 0 0 0 0 0 0 0 0 0
38804 - 0 0 0 0 0 0 0 0 0 0 0 0
38805 - 0 0 0 0 0 0 0 0 0 0 0 0
38806 - 6 6 6 6 6 6 10 10 10 10 10 10
38807 - 10 10 10 6 6 6 6 6 6 6 6 6
38808 - 0 0 0 0 0 0 0 0 0 0 0 0
38809 - 0 0 0 0 0 0 0 0 0 0 0 0
38810 - 0 0 0 0 0 0 0 0 0 0 0 0
38811 - 0 0 0 0 0 0 0 0 0 0 0 0
38812 - 0 0 0 0 0 0 0 0 0 0 0 0
38813 - 0 0 0 0 0 0 0 0 0 0 0 0
38814 - 0 0 0 0 0 0 0 0 0 0 0 0
38815 - 0 0 0 0 0 0 0 0 0 0 0 0
38816 - 0 0 0 0 0 0 0 0 0 0 0 0
38817 - 0 0 0 0 0 0 0 0 0 0 0 0
38818 - 0 0 0 0 0 0 0 0 0 0 0 0
38819 - 0 0 0 0 0 0 0 0 0 0 0 0
38820 - 0 0 0 0 0 0 0 0 0 0 0 0
38821 - 0 0 0 0 0 0 0 0 0 0 0 0
38822 - 0 0 0 0 0 0 0 0 0 0 0 0
38823 - 0 0 0 0 0 0 0 0 0 0 0 0
38824 - 0 0 0 0 0 0 0 0 0 0 0 0
38825 - 0 0 0 6 6 6 10 10 10 14 14 14
38826 - 22 22 22 26 26 26 30 30 30 34 34 34
38827 - 30 30 30 30 30 30 26 26 26 18 18 18
38828 - 14 14 14 10 10 10 6 6 6 0 0 0
38829 - 0 0 0 0 0 0 0 0 0 0 0 0
38830 - 0 0 0 0 0 0 0 0 0 0 0 0
38831 - 0 0 0 0 0 0 0 0 0 0 0 0
38832 - 0 0 0 0 0 0 0 0 0 0 0 0
38833 - 0 0 0 0 0 0 0 0 0 0 0 0
38834 - 0 0 0 0 0 0 0 0 0 0 0 0
38835 - 0 0 0 0 0 0 0 0 0 0 0 0
38836 - 0 0 0 0 0 0 0 0 0 0 0 0
38837 - 0 0 0 0 0 0 0 0 0 0 0 0
38838 - 0 0 0 0 0 1 0 0 1 0 0 0
38839 - 0 0 0 0 0 0 0 0 0 0 0 0
38840 - 0 0 0 0 0 0 0 0 0 0 0 0
38841 - 0 0 0 0 0 0 0 0 0 0 0 0
38842 - 0 0 0 0 0 0 0 0 0 0 0 0
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 - 6 6 6 14 14 14 26 26 26 42 42 42
38846 - 54 54 54 66 66 66 78 78 78 78 78 78
38847 - 78 78 78 74 74 74 66 66 66 54 54 54
38848 - 42 42 42 26 26 26 18 18 18 10 10 10
38849 - 6 6 6 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 - 0 0 0 0 0 0 0 0 0 0 0 0
38853 - 0 0 0 0 0 0 0 0 0 0 0 0
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 1 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 10 10 10
38865 - 22 22 22 42 42 42 66 66 66 86 86 86
38866 - 66 66 66 38 38 38 38 38 38 22 22 22
38867 - 26 26 26 34 34 34 54 54 54 66 66 66
38868 - 86 86 86 70 70 70 46 46 46 26 26 26
38869 - 14 14 14 6 6 6 0 0 0 0 0 0
38870 - 0 0 0 0 0 0 0 0 0 0 0 0
38871 - 0 0 0 0 0 0 0 0 0 0 0 0
38872 - 0 0 0 0 0 0 0 0 0 0 0 0
38873 - 0 0 0 0 0 0 0 0 0 0 0 0
38874 - 0 0 0 0 0 0 0 0 0 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 1 0 0 1 0 0 1 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 0 10 10 10 26 26 26
38885 - 50 50 50 82 82 82 58 58 58 6 6 6
38886 - 2 2 6 2 2 6 2 2 6 2 2 6
38887 - 2 2 6 2 2 6 2 2 6 2 2 6
38888 - 6 6 6 54 54 54 86 86 86 66 66 66
38889 - 38 38 38 18 18 18 6 6 6 0 0 0
38890 - 0 0 0 0 0 0 0 0 0 0 0 0
38891 - 0 0 0 0 0 0 0 0 0 0 0 0
38892 - 0 0 0 0 0 0 0 0 0 0 0 0
38893 - 0 0 0 0 0 0 0 0 0 0 0 0
38894 - 0 0 0 0 0 0 0 0 0 0 0 0
38895 - 0 0 0 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 0 6 6 6 22 22 22 50 50 50
38905 - 78 78 78 34 34 34 2 2 6 2 2 6
38906 - 2 2 6 2 2 6 2 2 6 2 2 6
38907 - 2 2 6 2 2 6 2 2 6 2 2 6
38908 - 2 2 6 2 2 6 6 6 6 70 70 70
38909 - 78 78 78 46 46 46 22 22 22 6 6 6
38910 - 0 0 0 0 0 0 0 0 0 0 0 0
38911 - 0 0 0 0 0 0 0 0 0 0 0 0
38912 - 0 0 0 0 0 0 0 0 0 0 0 0
38913 - 0 0 0 0 0 0 0 0 0 0 0 0
38914 - 0 0 0 0 0 0 0 0 0 0 0 0
38915 - 0 0 0 0 0 0 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 1 0 0 1 0 0 1 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 - 6 6 6 18 18 18 42 42 42 82 82 82
38925 - 26 26 26 2 2 6 2 2 6 2 2 6
38926 - 2 2 6 2 2 6 2 2 6 2 2 6
38927 - 2 2 6 2 2 6 2 2 6 14 14 14
38928 - 46 46 46 34 34 34 6 6 6 2 2 6
38929 - 42 42 42 78 78 78 42 42 42 18 18 18
38930 - 6 6 6 0 0 0 0 0 0 0 0 0
38931 - 0 0 0 0 0 0 0 0 0 0 0 0
38932 - 0 0 0 0 0 0 0 0 0 0 0 0
38933 - 0 0 0 0 0 0 0 0 0 0 0 0
38934 - 0 0 0 0 0 0 0 0 0 0 0 0
38935 - 0 0 0 0 0 0 0 0 0 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 1 0 0 0 0 0 1 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 - 10 10 10 30 30 30 66 66 66 58 58 58
38945 - 2 2 6 2 2 6 2 2 6 2 2 6
38946 - 2 2 6 2 2 6 2 2 6 2 2 6
38947 - 2 2 6 2 2 6 2 2 6 26 26 26
38948 - 86 86 86 101 101 101 46 46 46 10 10 10
38949 - 2 2 6 58 58 58 70 70 70 34 34 34
38950 - 10 10 10 0 0 0 0 0 0 0 0 0
38951 - 0 0 0 0 0 0 0 0 0 0 0 0
38952 - 0 0 0 0 0 0 0 0 0 0 0 0
38953 - 0 0 0 0 0 0 0 0 0 0 0 0
38954 - 0 0 0 0 0 0 0 0 0 0 0 0
38955 - 0 0 0 0 0 0 0 0 0 0 0 0
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 1 0 0 1 0 0 1 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 - 14 14 14 42 42 42 86 86 86 10 10 10
38965 - 2 2 6 2 2 6 2 2 6 2 2 6
38966 - 2 2 6 2 2 6 2 2 6 2 2 6
38967 - 2 2 6 2 2 6 2 2 6 30 30 30
38968 - 94 94 94 94 94 94 58 58 58 26 26 26
38969 - 2 2 6 6 6 6 78 78 78 54 54 54
38970 - 22 22 22 6 6 6 0 0 0 0 0 0
38971 - 0 0 0 0 0 0 0 0 0 0 0 0
38972 - 0 0 0 0 0 0 0 0 0 0 0 0
38973 - 0 0 0 0 0 0 0 0 0 0 0 0
38974 - 0 0 0 0 0 0 0 0 0 0 0 0
38975 - 0 0 0 0 0 0 0 0 0 0 0 0
38976 - 0 0 0 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 6 6 6
38984 - 22 22 22 62 62 62 62 62 62 2 2 6
38985 - 2 2 6 2 2 6 2 2 6 2 2 6
38986 - 2 2 6 2 2 6 2 2 6 2 2 6
38987 - 2 2 6 2 2 6 2 2 6 26 26 26
38988 - 54 54 54 38 38 38 18 18 18 10 10 10
38989 - 2 2 6 2 2 6 34 34 34 82 82 82
38990 - 38 38 38 14 14 14 0 0 0 0 0 0
38991 - 0 0 0 0 0 0 0 0 0 0 0 0
38992 - 0 0 0 0 0 0 0 0 0 0 0 0
38993 - 0 0 0 0 0 0 0 0 0 0 0 0
38994 - 0 0 0 0 0 0 0 0 0 0 0 0
38995 - 0 0 0 0 0 0 0 0 0 0 0 0
38996 - 0 0 0 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 1 0 0 1 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 6 6 6
39004 - 30 30 30 78 78 78 30 30 30 2 2 6
39005 - 2 2 6 2 2 6 2 2 6 2 2 6
39006 - 2 2 6 2 2 6 2 2 6 2 2 6
39007 - 2 2 6 2 2 6 2 2 6 10 10 10
39008 - 10 10 10 2 2 6 2 2 6 2 2 6
39009 - 2 2 6 2 2 6 2 2 6 78 78 78
39010 - 50 50 50 18 18 18 6 6 6 0 0 0
39011 - 0 0 0 0 0 0 0 0 0 0 0 0
39012 - 0 0 0 0 0 0 0 0 0 0 0 0
39013 - 0 0 0 0 0 0 0 0 0 0 0 0
39014 - 0 0 0 0 0 0 0 0 0 0 0 0
39015 - 0 0 0 0 0 0 0 0 0 0 0 0
39016 - 0 0 0 0 0 0 0 0 0 0 0 0
39017 - 0 0 0 0 0 0 0 0 0 0 0 0
39018 - 0 0 1 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 10 10 10
39024 - 38 38 38 86 86 86 14 14 14 2 2 6
39025 - 2 2 6 2 2 6 2 2 6 2 2 6
39026 - 2 2 6 2 2 6 2 2 6 2 2 6
39027 - 2 2 6 2 2 6 2 2 6 2 2 6
39028 - 2 2 6 2 2 6 2 2 6 2 2 6
39029 - 2 2 6 2 2 6 2 2 6 54 54 54
39030 - 66 66 66 26 26 26 6 6 6 0 0 0
39031 - 0 0 0 0 0 0 0 0 0 0 0 0
39032 - 0 0 0 0 0 0 0 0 0 0 0 0
39033 - 0 0 0 0 0 0 0 0 0 0 0 0
39034 - 0 0 0 0 0 0 0 0 0 0 0 0
39035 - 0 0 0 0 0 0 0 0 0 0 0 0
39036 - 0 0 0 0 0 0 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 1 0 0 1 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 14 14 14
39044 - 42 42 42 82 82 82 2 2 6 2 2 6
39045 - 2 2 6 6 6 6 10 10 10 2 2 6
39046 - 2 2 6 2 2 6 2 2 6 2 2 6
39047 - 2 2 6 2 2 6 2 2 6 6 6 6
39048 - 14 14 14 10 10 10 2 2 6 2 2 6
39049 - 2 2 6 2 2 6 2 2 6 18 18 18
39050 - 82 82 82 34 34 34 10 10 10 0 0 0
39051 - 0 0 0 0 0 0 0 0 0 0 0 0
39052 - 0 0 0 0 0 0 0 0 0 0 0 0
39053 - 0 0 0 0 0 0 0 0 0 0 0 0
39054 - 0 0 0 0 0 0 0 0 0 0 0 0
39055 - 0 0 0 0 0 0 0 0 0 0 0 0
39056 - 0 0 0 0 0 0 0 0 0 0 0 0
39057 - 0 0 0 0 0 0 0 0 0 0 0 0
39058 - 0 0 1 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 14 14 14
39064 - 46 46 46 86 86 86 2 2 6 2 2 6
39065 - 6 6 6 6 6 6 22 22 22 34 34 34
39066 - 6 6 6 2 2 6 2 2 6 2 2 6
39067 - 2 2 6 2 2 6 18 18 18 34 34 34
39068 - 10 10 10 50 50 50 22 22 22 2 2 6
39069 - 2 2 6 2 2 6 2 2 6 10 10 10
39070 - 86 86 86 42 42 42 14 14 14 0 0 0
39071 - 0 0 0 0 0 0 0 0 0 0 0 0
39072 - 0 0 0 0 0 0 0 0 0 0 0 0
39073 - 0 0 0 0 0 0 0 0 0 0 0 0
39074 - 0 0 0 0 0 0 0 0 0 0 0 0
39075 - 0 0 0 0 0 0 0 0 0 0 0 0
39076 - 0 0 0 0 0 0 0 0 0 0 0 0
39077 - 0 0 0 0 0 0 0 0 0 0 0 0
39078 - 0 0 1 0 0 1 0 0 1 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 14 14 14
39084 - 46 46 46 86 86 86 2 2 6 2 2 6
39085 - 38 38 38 116 116 116 94 94 94 22 22 22
39086 - 22 22 22 2 2 6 2 2 6 2 2 6
39087 - 14 14 14 86 86 86 138 138 138 162 162 162
39088 -154 154 154 38 38 38 26 26 26 6 6 6
39089 - 2 2 6 2 2 6 2 2 6 2 2 6
39090 - 86 86 86 46 46 46 14 14 14 0 0 0
39091 - 0 0 0 0 0 0 0 0 0 0 0 0
39092 - 0 0 0 0 0 0 0 0 0 0 0 0
39093 - 0 0 0 0 0 0 0 0 0 0 0 0
39094 - 0 0 0 0 0 0 0 0 0 0 0 0
39095 - 0 0 0 0 0 0 0 0 0 0 0 0
39096 - 0 0 0 0 0 0 0 0 0 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 14 14 14
39104 - 46 46 46 86 86 86 2 2 6 14 14 14
39105 -134 134 134 198 198 198 195 195 195 116 116 116
39106 - 10 10 10 2 2 6 2 2 6 6 6 6
39107 -101 98 89 187 187 187 210 210 210 218 218 218
39108 -214 214 214 134 134 134 14 14 14 6 6 6
39109 - 2 2 6 2 2 6 2 2 6 2 2 6
39110 - 86 86 86 50 50 50 18 18 18 6 6 6
39111 - 0 0 0 0 0 0 0 0 0 0 0 0
39112 - 0 0 0 0 0 0 0 0 0 0 0 0
39113 - 0 0 0 0 0 0 0 0 0 0 0 0
39114 - 0 0 0 0 0 0 0 0 0 0 0 0
39115 - 0 0 0 0 0 0 0 0 0 0 0 0
39116 - 0 0 0 0 0 0 0 0 0 0 0 0
39117 - 0 0 0 0 0 0 0 0 1 0 0 0
39118 - 0 0 1 0 0 1 0 0 1 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 14 14 14
39124 - 46 46 46 86 86 86 2 2 6 54 54 54
39125 -218 218 218 195 195 195 226 226 226 246 246 246
39126 - 58 58 58 2 2 6 2 2 6 30 30 30
39127 -210 210 210 253 253 253 174 174 174 123 123 123
39128 -221 221 221 234 234 234 74 74 74 2 2 6
39129 - 2 2 6 2 2 6 2 2 6 2 2 6
39130 - 70 70 70 58 58 58 22 22 22 6 6 6
39131 - 0 0 0 0 0 0 0 0 0 0 0 0
39132 - 0 0 0 0 0 0 0 0 0 0 0 0
39133 - 0 0 0 0 0 0 0 0 0 0 0 0
39134 - 0 0 0 0 0 0 0 0 0 0 0 0
39135 - 0 0 0 0 0 0 0 0 0 0 0 0
39136 - 0 0 0 0 0 0 0 0 0 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 14 14 14
39144 - 46 46 46 82 82 82 2 2 6 106 106 106
39145 -170 170 170 26 26 26 86 86 86 226 226 226
39146 -123 123 123 10 10 10 14 14 14 46 46 46
39147 -231 231 231 190 190 190 6 6 6 70 70 70
39148 - 90 90 90 238 238 238 158 158 158 2 2 6
39149 - 2 2 6 2 2 6 2 2 6 2 2 6
39150 - 70 70 70 58 58 58 22 22 22 6 6 6
39151 - 0 0 0 0 0 0 0 0 0 0 0 0
39152 - 0 0 0 0 0 0 0 0 0 0 0 0
39153 - 0 0 0 0 0 0 0 0 0 0 0 0
39154 - 0 0 0 0 0 0 0 0 0 0 0 0
39155 - 0 0 0 0 0 0 0 0 0 0 0 0
39156 - 0 0 0 0 0 0 0 0 0 0 0 0
39157 - 0 0 0 0 0 0 0 0 1 0 0 0
39158 - 0 0 1 0 0 1 0 0 1 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 0 14 14 14
39164 - 42 42 42 86 86 86 6 6 6 116 116 116
39165 -106 106 106 6 6 6 70 70 70 149 149 149
39166 -128 128 128 18 18 18 38 38 38 54 54 54
39167 -221 221 221 106 106 106 2 2 6 14 14 14
39168 - 46 46 46 190 190 190 198 198 198 2 2 6
39169 - 2 2 6 2 2 6 2 2 6 2 2 6
39170 - 74 74 74 62 62 62 22 22 22 6 6 6
39171 - 0 0 0 0 0 0 0 0 0 0 0 0
39172 - 0 0 0 0 0 0 0 0 0 0 0 0
39173 - 0 0 0 0 0 0 0 0 0 0 0 0
39174 - 0 0 0 0 0 0 0 0 0 0 0 0
39175 - 0 0 0 0 0 0 0 0 0 0 0 0
39176 - 0 0 0 0 0 0 0 0 0 0 0 0
39177 - 0 0 0 0 0 0 0 0 1 0 0 0
39178 - 0 0 1 0 0 0 0 0 1 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 14 14 14
39184 - 42 42 42 94 94 94 14 14 14 101 101 101
39185 -128 128 128 2 2 6 18 18 18 116 116 116
39186 -118 98 46 121 92 8 121 92 8 98 78 10
39187 -162 162 162 106 106 106 2 2 6 2 2 6
39188 - 2 2 6 195 195 195 195 195 195 6 6 6
39189 - 2 2 6 2 2 6 2 2 6 2 2 6
39190 - 74 74 74 62 62 62 22 22 22 6 6 6
39191 - 0 0 0 0 0 0 0 0 0 0 0 0
39192 - 0 0 0 0 0 0 0 0 0 0 0 0
39193 - 0 0 0 0 0 0 0 0 0 0 0 0
39194 - 0 0 0 0 0 0 0 0 0 0 0 0
39195 - 0 0 0 0 0 0 0 0 0 0 0 0
39196 - 0 0 0 0 0 0 0 0 0 0 0 0
39197 - 0 0 0 0 0 0 0 0 1 0 0 1
39198 - 0 0 1 0 0 0 0 0 1 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 0 10 10 10
39204 - 38 38 38 90 90 90 14 14 14 58 58 58
39205 -210 210 210 26 26 26 54 38 6 154 114 10
39206 -226 170 11 236 186 11 225 175 15 184 144 12
39207 -215 174 15 175 146 61 37 26 9 2 2 6
39208 - 70 70 70 246 246 246 138 138 138 2 2 6
39209 - 2 2 6 2 2 6 2 2 6 2 2 6
39210 - 70 70 70 66 66 66 26 26 26 6 6 6
39211 - 0 0 0 0 0 0 0 0 0 0 0 0
39212 - 0 0 0 0 0 0 0 0 0 0 0 0
39213 - 0 0 0 0 0 0 0 0 0 0 0 0
39214 - 0 0 0 0 0 0 0 0 0 0 0 0
39215 - 0 0 0 0 0 0 0 0 0 0 0 0
39216 - 0 0 0 0 0 0 0 0 0 0 0 0
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 0 10 10 10
39224 - 38 38 38 86 86 86 14 14 14 10 10 10
39225 -195 195 195 188 164 115 192 133 9 225 175 15
39226 -239 182 13 234 190 10 232 195 16 232 200 30
39227 -245 207 45 241 208 19 232 195 16 184 144 12
39228 -218 194 134 211 206 186 42 42 42 2 2 6
39229 - 2 2 6 2 2 6 2 2 6 2 2 6
39230 - 50 50 50 74 74 74 30 30 30 6 6 6
39231 - 0 0 0 0 0 0 0 0 0 0 0 0
39232 - 0 0 0 0 0 0 0 0 0 0 0 0
39233 - 0 0 0 0 0 0 0 0 0 0 0 0
39234 - 0 0 0 0 0 0 0 0 0 0 0 0
39235 - 0 0 0 0 0 0 0 0 0 0 0 0
39236 - 0 0 0 0 0 0 0 0 0 0 0 0
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 0 10 10 10
39244 - 34 34 34 86 86 86 14 14 14 2 2 6
39245 -121 87 25 192 133 9 219 162 10 239 182 13
39246 -236 186 11 232 195 16 241 208 19 244 214 54
39247 -246 218 60 246 218 38 246 215 20 241 208 19
39248 -241 208 19 226 184 13 121 87 25 2 2 6
39249 - 2 2 6 2 2 6 2 2 6 2 2 6
39250 - 50 50 50 82 82 82 34 34 34 10 10 10
39251 - 0 0 0 0 0 0 0 0 0 0 0 0
39252 - 0 0 0 0 0 0 0 0 0 0 0 0
39253 - 0 0 0 0 0 0 0 0 0 0 0 0
39254 - 0 0 0 0 0 0 0 0 0 0 0 0
39255 - 0 0 0 0 0 0 0 0 0 0 0 0
39256 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10
39264 - 34 34 34 82 82 82 30 30 30 61 42 6
39265 -180 123 7 206 145 10 230 174 11 239 182 13
39266 -234 190 10 238 202 15 241 208 19 246 218 74
39267 -246 218 38 246 215 20 246 215 20 246 215 20
39268 -226 184 13 215 174 15 184 144 12 6 6 6
39269 - 2 2 6 2 2 6 2 2 6 2 2 6
39270 - 26 26 26 94 94 94 42 42 42 14 14 14
39271 - 0 0 0 0 0 0 0 0 0 0 0 0
39272 - 0 0 0 0 0 0 0 0 0 0 0 0
39273 - 0 0 0 0 0 0 0 0 0 0 0 0
39274 - 0 0 0 0 0 0 0 0 0 0 0 0
39275 - 0 0 0 0 0 0 0 0 0 0 0 0
39276 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10
39284 - 30 30 30 78 78 78 50 50 50 104 69 6
39285 -192 133 9 216 158 10 236 178 12 236 186 11
39286 -232 195 16 241 208 19 244 214 54 245 215 43
39287 -246 215 20 246 215 20 241 208 19 198 155 10
39288 -200 144 11 216 158 10 156 118 10 2 2 6
39289 - 2 2 6 2 2 6 2 2 6 2 2 6
39290 - 6 6 6 90 90 90 54 54 54 18 18 18
39291 - 6 6 6 0 0 0 0 0 0 0 0 0
39292 - 0 0 0 0 0 0 0 0 0 0 0 0
39293 - 0 0 0 0 0 0 0 0 0 0 0 0
39294 - 0 0 0 0 0 0 0 0 0 0 0 0
39295 - 0 0 0 0 0 0 0 0 0 0 0 0
39296 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10
39304 - 30 30 30 78 78 78 46 46 46 22 22 22
39305 -137 92 6 210 162 10 239 182 13 238 190 10
39306 -238 202 15 241 208 19 246 215 20 246 215 20
39307 -241 208 19 203 166 17 185 133 11 210 150 10
39308 -216 158 10 210 150 10 102 78 10 2 2 6
39309 - 6 6 6 54 54 54 14 14 14 2 2 6
39310 - 2 2 6 62 62 62 74 74 74 30 30 30
39311 - 10 10 10 0 0 0 0 0 0 0 0 0
39312 - 0 0 0 0 0 0 0 0 0 0 0 0
39313 - 0 0 0 0 0 0 0 0 0 0 0 0
39314 - 0 0 0 0 0 0 0 0 0 0 0 0
39315 - 0 0 0 0 0 0 0 0 0 0 0 0
39316 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10
39324 - 34 34 34 78 78 78 50 50 50 6 6 6
39325 - 94 70 30 139 102 15 190 146 13 226 184 13
39326 -232 200 30 232 195 16 215 174 15 190 146 13
39327 -168 122 10 192 133 9 210 150 10 213 154 11
39328 -202 150 34 182 157 106 101 98 89 2 2 6
39329 - 2 2 6 78 78 78 116 116 116 58 58 58
39330 - 2 2 6 22 22 22 90 90 90 46 46 46
39331 - 18 18 18 6 6 6 0 0 0 0 0 0
39332 - 0 0 0 0 0 0 0 0 0 0 0 0
39333 - 0 0 0 0 0 0 0 0 0 0 0 0
39334 - 0 0 0 0 0 0 0 0 0 0 0 0
39335 - 0 0 0 0 0 0 0 0 0 0 0 0
39336 - 0 0 0 0 0 0 0 0 0 0 0 0
39337 - 0 0 0 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 10 10 10
39344 - 38 38 38 86 86 86 50 50 50 6 6 6
39345 -128 128 128 174 154 114 156 107 11 168 122 10
39346 -198 155 10 184 144 12 197 138 11 200 144 11
39347 -206 145 10 206 145 10 197 138 11 188 164 115
39348 -195 195 195 198 198 198 174 174 174 14 14 14
39349 - 2 2 6 22 22 22 116 116 116 116 116 116
39350 - 22 22 22 2 2 6 74 74 74 70 70 70
39351 - 30 30 30 10 10 10 0 0 0 0 0 0
39352 - 0 0 0 0 0 0 0 0 0 0 0 0
39353 - 0 0 0 0 0 0 0 0 0 0 0 0
39354 - 0 0 0 0 0 0 0 0 0 0 0 0
39355 - 0 0 0 0 0 0 0 0 0 0 0 0
39356 - 0 0 0 0 0 0 0 0 0 0 0 0
39357 - 0 0 0 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 6 6 6 18 18 18
39364 - 50 50 50 101 101 101 26 26 26 10 10 10
39365 -138 138 138 190 190 190 174 154 114 156 107 11
39366 -197 138 11 200 144 11 197 138 11 192 133 9
39367 -180 123 7 190 142 34 190 178 144 187 187 187
39368 -202 202 202 221 221 221 214 214 214 66 66 66
39369 - 2 2 6 2 2 6 50 50 50 62 62 62
39370 - 6 6 6 2 2 6 10 10 10 90 90 90
39371 - 50 50 50 18 18 18 6 6 6 0 0 0
39372 - 0 0 0 0 0 0 0 0 0 0 0 0
39373 - 0 0 0 0 0 0 0 0 0 0 0 0
39374 - 0 0 0 0 0 0 0 0 0 0 0 0
39375 - 0 0 0 0 0 0 0 0 0 0 0 0
39376 - 0 0 0 0 0 0 0 0 0 0 0 0
39377 - 0 0 0 0 0 0 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 10 10 10 34 34 34
39384 - 74 74 74 74 74 74 2 2 6 6 6 6
39385 -144 144 144 198 198 198 190 190 190 178 166 146
39386 -154 121 60 156 107 11 156 107 11 168 124 44
39387 -174 154 114 187 187 187 190 190 190 210 210 210
39388 -246 246 246 253 253 253 253 253 253 182 182 182
39389 - 6 6 6 2 2 6 2 2 6 2 2 6
39390 - 2 2 6 2 2 6 2 2 6 62 62 62
39391 - 74 74 74 34 34 34 14 14 14 0 0 0
39392 - 0 0 0 0 0 0 0 0 0 0 0 0
39393 - 0 0 0 0 0 0 0 0 0 0 0 0
39394 - 0 0 0 0 0 0 0 0 0 0 0 0
39395 - 0 0 0 0 0 0 0 0 0 0 0 0
39396 - 0 0 0 0 0 0 0 0 0 0 0 0
39397 - 0 0 0 0 0 0 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 10 10 10 22 22 22 54 54 54
39404 - 94 94 94 18 18 18 2 2 6 46 46 46
39405 -234 234 234 221 221 221 190 190 190 190 190 190
39406 -190 190 190 187 187 187 187 187 187 190 190 190
39407 -190 190 190 195 195 195 214 214 214 242 242 242
39408 -253 253 253 253 253 253 253 253 253 253 253 253
39409 - 82 82 82 2 2 6 2 2 6 2 2 6
39410 - 2 2 6 2 2 6 2 2 6 14 14 14
39411 - 86 86 86 54 54 54 22 22 22 6 6 6
39412 - 0 0 0 0 0 0 0 0 0 0 0 0
39413 - 0 0 0 0 0 0 0 0 0 0 0 0
39414 - 0 0 0 0 0 0 0 0 0 0 0 0
39415 - 0 0 0 0 0 0 0 0 0 0 0 0
39416 - 0 0 0 0 0 0 0 0 0 0 0 0
39417 - 0 0 0 0 0 0 0 0 0 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 - 6 6 6 18 18 18 46 46 46 90 90 90
39424 - 46 46 46 18 18 18 6 6 6 182 182 182
39425 -253 253 253 246 246 246 206 206 206 190 190 190
39426 -190 190 190 190 190 190 190 190 190 190 190 190
39427 -206 206 206 231 231 231 250 250 250 253 253 253
39428 -253 253 253 253 253 253 253 253 253 253 253 253
39429 -202 202 202 14 14 14 2 2 6 2 2 6
39430 - 2 2 6 2 2 6 2 2 6 2 2 6
39431 - 42 42 42 86 86 86 42 42 42 18 18 18
39432 - 6 6 6 0 0 0 0 0 0 0 0 0
39433 - 0 0 0 0 0 0 0 0 0 0 0 0
39434 - 0 0 0 0 0 0 0 0 0 0 0 0
39435 - 0 0 0 0 0 0 0 0 0 0 0 0
39436 - 0 0 0 0 0 0 0 0 0 0 0 0
39437 - 0 0 0 0 0 0 0 0 0 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 6 6 6
39443 - 14 14 14 38 38 38 74 74 74 66 66 66
39444 - 2 2 6 6 6 6 90 90 90 250 250 250
39445 -253 253 253 253 253 253 238 238 238 198 198 198
39446 -190 190 190 190 190 190 195 195 195 221 221 221
39447 -246 246 246 253 253 253 253 253 253 253 253 253
39448 -253 253 253 253 253 253 253 253 253 253 253 253
39449 -253 253 253 82 82 82 2 2 6 2 2 6
39450 - 2 2 6 2 2 6 2 2 6 2 2 6
39451 - 2 2 6 78 78 78 70 70 70 34 34 34
39452 - 14 14 14 6 6 6 0 0 0 0 0 0
39453 - 0 0 0 0 0 0 0 0 0 0 0 0
39454 - 0 0 0 0 0 0 0 0 0 0 0 0
39455 - 0 0 0 0 0 0 0 0 0 0 0 0
39456 - 0 0 0 0 0 0 0 0 0 0 0 0
39457 - 0 0 0 0 0 0 0 0 0 0 0 0
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 14 14 14
39463 - 34 34 34 66 66 66 78 78 78 6 6 6
39464 - 2 2 6 18 18 18 218 218 218 253 253 253
39465 -253 253 253 253 253 253 253 253 253 246 246 246
39466 -226 226 226 231 231 231 246 246 246 253 253 253
39467 -253 253 253 253 253 253 253 253 253 253 253 253
39468 -253 253 253 253 253 253 253 253 253 253 253 253
39469 -253 253 253 178 178 178 2 2 6 2 2 6
39470 - 2 2 6 2 2 6 2 2 6 2 2 6
39471 - 2 2 6 18 18 18 90 90 90 62 62 62
39472 - 30 30 30 10 10 10 0 0 0 0 0 0
39473 - 0 0 0 0 0 0 0 0 0 0 0 0
39474 - 0 0 0 0 0 0 0 0 0 0 0 0
39475 - 0 0 0 0 0 0 0 0 0 0 0 0
39476 - 0 0 0 0 0 0 0 0 0 0 0 0
39477 - 0 0 0 0 0 0 0 0 0 0 0 0
39478 - 0 0 0 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 10 10 10 26 26 26
39483 - 58 58 58 90 90 90 18 18 18 2 2 6
39484 - 2 2 6 110 110 110 253 253 253 253 253 253
39485 -253 253 253 253 253 253 253 253 253 253 253 253
39486 -250 250 250 253 253 253 253 253 253 253 253 253
39487 -253 253 253 253 253 253 253 253 253 253 253 253
39488 -253 253 253 253 253 253 253 253 253 253 253 253
39489 -253 253 253 231 231 231 18 18 18 2 2 6
39490 - 2 2 6 2 2 6 2 2 6 2 2 6
39491 - 2 2 6 2 2 6 18 18 18 94 94 94
39492 - 54 54 54 26 26 26 10 10 10 0 0 0
39493 - 0 0 0 0 0 0 0 0 0 0 0 0
39494 - 0 0 0 0 0 0 0 0 0 0 0 0
39495 - 0 0 0 0 0 0 0 0 0 0 0 0
39496 - 0 0 0 0 0 0 0 0 0 0 0 0
39497 - 0 0 0 0 0 0 0 0 0 0 0 0
39498 - 0 0 0 0 0 0 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 6 6 6 22 22 22 50 50 50
39503 - 90 90 90 26 26 26 2 2 6 2 2 6
39504 - 14 14 14 195 195 195 250 250 250 253 253 253
39505 -253 253 253 253 253 253 253 253 253 253 253 253
39506 -253 253 253 253 253 253 253 253 253 253 253 253
39507 -253 253 253 253 253 253 253 253 253 253 253 253
39508 -253 253 253 253 253 253 253 253 253 253 253 253
39509 -250 250 250 242 242 242 54 54 54 2 2 6
39510 - 2 2 6 2 2 6 2 2 6 2 2 6
39511 - 2 2 6 2 2 6 2 2 6 38 38 38
39512 - 86 86 86 50 50 50 22 22 22 6 6 6
39513 - 0 0 0 0 0 0 0 0 0 0 0 0
39514 - 0 0 0 0 0 0 0 0 0 0 0 0
39515 - 0 0 0 0 0 0 0 0 0 0 0 0
39516 - 0 0 0 0 0 0 0 0 0 0 0 0
39517 - 0 0 0 0 0 0 0 0 0 0 0 0
39518 - 0 0 0 0 0 0 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 - 6 6 6 14 14 14 38 38 38 82 82 82
39523 - 34 34 34 2 2 6 2 2 6 2 2 6
39524 - 42 42 42 195 195 195 246 246 246 253 253 253
39525 -253 253 253 253 253 253 253 253 253 250 250 250
39526 -242 242 242 242 242 242 250 250 250 253 253 253
39527 -253 253 253 253 253 253 253 253 253 253 253 253
39528 -253 253 253 250 250 250 246 246 246 238 238 238
39529 -226 226 226 231 231 231 101 101 101 6 6 6
39530 - 2 2 6 2 2 6 2 2 6 2 2 6
39531 - 2 2 6 2 2 6 2 2 6 2 2 6
39532 - 38 38 38 82 82 82 42 42 42 14 14 14
39533 - 6 6 6 0 0 0 0 0 0 0 0 0
39534 - 0 0 0 0 0 0 0 0 0 0 0 0
39535 - 0 0 0 0 0 0 0 0 0 0 0 0
39536 - 0 0 0 0 0 0 0 0 0 0 0 0
39537 - 0 0 0 0 0 0 0 0 0 0 0 0
39538 - 0 0 0 0 0 0 0 0 0 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 - 10 10 10 26 26 26 62 62 62 66 66 66
39543 - 2 2 6 2 2 6 2 2 6 6 6 6
39544 - 70 70 70 170 170 170 206 206 206 234 234 234
39545 -246 246 246 250 250 250 250 250 250 238 238 238
39546 -226 226 226 231 231 231 238 238 238 250 250 250
39547 -250 250 250 250 250 250 246 246 246 231 231 231
39548 -214 214 214 206 206 206 202 202 202 202 202 202
39549 -198 198 198 202 202 202 182 182 182 18 18 18
39550 - 2 2 6 2 2 6 2 2 6 2 2 6
39551 - 2 2 6 2 2 6 2 2 6 2 2 6
39552 - 2 2 6 62 62 62 66 66 66 30 30 30
39553 - 10 10 10 0 0 0 0 0 0 0 0 0
39554 - 0 0 0 0 0 0 0 0 0 0 0 0
39555 - 0 0 0 0 0 0 0 0 0 0 0 0
39556 - 0 0 0 0 0 0 0 0 0 0 0 0
39557 - 0 0 0 0 0 0 0 0 0 0 0 0
39558 - 0 0 0 0 0 0 0 0 0 0 0 0
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 - 14 14 14 42 42 42 82 82 82 18 18 18
39563 - 2 2 6 2 2 6 2 2 6 10 10 10
39564 - 94 94 94 182 182 182 218 218 218 242 242 242
39565 -250 250 250 253 253 253 253 253 253 250 250 250
39566 -234 234 234 253 253 253 253 253 253 253 253 253
39567 -253 253 253 253 253 253 253 253 253 246 246 246
39568 -238 238 238 226 226 226 210 210 210 202 202 202
39569 -195 195 195 195 195 195 210 210 210 158 158 158
39570 - 6 6 6 14 14 14 50 50 50 14 14 14
39571 - 2 2 6 2 2 6 2 2 6 2 2 6
39572 - 2 2 6 6 6 6 86 86 86 46 46 46
39573 - 18 18 18 6 6 6 0 0 0 0 0 0
39574 - 0 0 0 0 0 0 0 0 0 0 0 0
39575 - 0 0 0 0 0 0 0 0 0 0 0 0
39576 - 0 0 0 0 0 0 0 0 0 0 0 0
39577 - 0 0 0 0 0 0 0 0 0 0 0 0
39578 - 0 0 0 0 0 0 0 0 0 0 0 0
39579 - 0 0 0 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 6 6 6
39582 - 22 22 22 54 54 54 70 70 70 2 2 6
39583 - 2 2 6 10 10 10 2 2 6 22 22 22
39584 -166 166 166 231 231 231 250 250 250 253 253 253
39585 -253 253 253 253 253 253 253 253 253 250 250 250
39586 -242 242 242 253 253 253 253 253 253 253 253 253
39587 -253 253 253 253 253 253 253 253 253 253 253 253
39588 -253 253 253 253 253 253 253 253 253 246 246 246
39589 -231 231 231 206 206 206 198 198 198 226 226 226
39590 - 94 94 94 2 2 6 6 6 6 38 38 38
39591 - 30 30 30 2 2 6 2 2 6 2 2 6
39592 - 2 2 6 2 2 6 62 62 62 66 66 66
39593 - 26 26 26 10 10 10 0 0 0 0 0 0
39594 - 0 0 0 0 0 0 0 0 0 0 0 0
39595 - 0 0 0 0 0 0 0 0 0 0 0 0
39596 - 0 0 0 0 0 0 0 0 0 0 0 0
39597 - 0 0 0 0 0 0 0 0 0 0 0 0
39598 - 0 0 0 0 0 0 0 0 0 0 0 0
39599 - 0 0 0 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 10 10 10
39602 - 30 30 30 74 74 74 50 50 50 2 2 6
39603 - 26 26 26 26 26 26 2 2 6 106 106 106
39604 -238 238 238 253 253 253 253 253 253 253 253 253
39605 -253 253 253 253 253 253 253 253 253 253 253 253
39606 -253 253 253 253 253 253 253 253 253 253 253 253
39607 -253 253 253 253 253 253 253 253 253 253 253 253
39608 -253 253 253 253 253 253 253 253 253 253 253 253
39609 -253 253 253 246 246 246 218 218 218 202 202 202
39610 -210 210 210 14 14 14 2 2 6 2 2 6
39611 - 30 30 30 22 22 22 2 2 6 2 2 6
39612 - 2 2 6 2 2 6 18 18 18 86 86 86
39613 - 42 42 42 14 14 14 0 0 0 0 0 0
39614 - 0 0 0 0 0 0 0 0 0 0 0 0
39615 - 0 0 0 0 0 0 0 0 0 0 0 0
39616 - 0 0 0 0 0 0 0 0 0 0 0 0
39617 - 0 0 0 0 0 0 0 0 0 0 0 0
39618 - 0 0 0 0 0 0 0 0 0 0 0 0
39619 - 0 0 0 0 0 0 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 14 14 14
39622 - 42 42 42 90 90 90 22 22 22 2 2 6
39623 - 42 42 42 2 2 6 18 18 18 218 218 218
39624 -253 253 253 253 253 253 253 253 253 253 253 253
39625 -253 253 253 253 253 253 253 253 253 253 253 253
39626 -253 253 253 253 253 253 253 253 253 253 253 253
39627 -253 253 253 253 253 253 253 253 253 253 253 253
39628 -253 253 253 253 253 253 253 253 253 253 253 253
39629 -253 253 253 253 253 253 250 250 250 221 221 221
39630 -218 218 218 101 101 101 2 2 6 14 14 14
39631 - 18 18 18 38 38 38 10 10 10 2 2 6
39632 - 2 2 6 2 2 6 2 2 6 78 78 78
39633 - 58 58 58 22 22 22 6 6 6 0 0 0
39634 - 0 0 0 0 0 0 0 0 0 0 0 0
39635 - 0 0 0 0 0 0 0 0 0 0 0 0
39636 - 0 0 0 0 0 0 0 0 0 0 0 0
39637 - 0 0 0 0 0 0 0 0 0 0 0 0
39638 - 0 0 0 0 0 0 0 0 0 0 0 0
39639 - 0 0 0 0 0 0 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 6 6 6 18 18 18
39642 - 54 54 54 82 82 82 2 2 6 26 26 26
39643 - 22 22 22 2 2 6 123 123 123 253 253 253
39644 -253 253 253 253 253 253 253 253 253 253 253 253
39645 -253 253 253 253 253 253 253 253 253 253 253 253
39646 -253 253 253 253 253 253 253 253 253 253 253 253
39647 -253 253 253 253 253 253 253 253 253 253 253 253
39648 -253 253 253 253 253 253 253 253 253 253 253 253
39649 -253 253 253 253 253 253 253 253 253 250 250 250
39650 -238 238 238 198 198 198 6 6 6 38 38 38
39651 - 58 58 58 26 26 26 38 38 38 2 2 6
39652 - 2 2 6 2 2 6 2 2 6 46 46 46
39653 - 78 78 78 30 30 30 10 10 10 0 0 0
39654 - 0 0 0 0 0 0 0 0 0 0 0 0
39655 - 0 0 0 0 0 0 0 0 0 0 0 0
39656 - 0 0 0 0 0 0 0 0 0 0 0 0
39657 - 0 0 0 0 0 0 0 0 0 0 0 0
39658 - 0 0 0 0 0 0 0 0 0 0 0 0
39659 - 0 0 0 0 0 0 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 10 10 10 30 30 30
39662 - 74 74 74 58 58 58 2 2 6 42 42 42
39663 - 2 2 6 22 22 22 231 231 231 253 253 253
39664 -253 253 253 253 253 253 253 253 253 253 253 253
39665 -253 253 253 253 253 253 253 253 253 250 250 250
39666 -253 253 253 253 253 253 253 253 253 253 253 253
39667 -253 253 253 253 253 253 253 253 253 253 253 253
39668 -253 253 253 253 253 253 253 253 253 253 253 253
39669 -253 253 253 253 253 253 253 253 253 253 253 253
39670 -253 253 253 246 246 246 46 46 46 38 38 38
39671 - 42 42 42 14 14 14 38 38 38 14 14 14
39672 - 2 2 6 2 2 6 2 2 6 6 6 6
39673 - 86 86 86 46 46 46 14 14 14 0 0 0
39674 - 0 0 0 0 0 0 0 0 0 0 0 0
39675 - 0 0 0 0 0 0 0 0 0 0 0 0
39676 - 0 0 0 0 0 0 0 0 0 0 0 0
39677 - 0 0 0 0 0 0 0 0 0 0 0 0
39678 - 0 0 0 0 0 0 0 0 0 0 0 0
39679 - 0 0 0 0 0 0 0 0 0 0 0 0
39680 - 0 0 0 0 0 0 0 0 0 0 0 0
39681 - 0 0 0 6 6 6 14 14 14 42 42 42
39682 - 90 90 90 18 18 18 18 18 18 26 26 26
39683 - 2 2 6 116 116 116 253 253 253 253 253 253
39684 -253 253 253 253 253 253 253 253 253 253 253 253
39685 -253 253 253 253 253 253 250 250 250 238 238 238
39686 -253 253 253 253 253 253 253 253 253 253 253 253
39687 -253 253 253 253 253 253 253 253 253 253 253 253
39688 -253 253 253 253 253 253 253 253 253 253 253 253
39689 -253 253 253 253 253 253 253 253 253 253 253 253
39690 -253 253 253 253 253 253 94 94 94 6 6 6
39691 - 2 2 6 2 2 6 10 10 10 34 34 34
39692 - 2 2 6 2 2 6 2 2 6 2 2 6
39693 - 74 74 74 58 58 58 22 22 22 6 6 6
39694 - 0 0 0 0 0 0 0 0 0 0 0 0
39695 - 0 0 0 0 0 0 0 0 0 0 0 0
39696 - 0 0 0 0 0 0 0 0 0 0 0 0
39697 - 0 0 0 0 0 0 0 0 0 0 0 0
39698 - 0 0 0 0 0 0 0 0 0 0 0 0
39699 - 0 0 0 0 0 0 0 0 0 0 0 0
39700 - 0 0 0 0 0 0 0 0 0 0 0 0
39701 - 0 0 0 10 10 10 26 26 26 66 66 66
39702 - 82 82 82 2 2 6 38 38 38 6 6 6
39703 - 14 14 14 210 210 210 253 253 253 253 253 253
39704 -253 253 253 253 253 253 253 253 253 253 253 253
39705 -253 253 253 253 253 253 246 246 246 242 242 242
39706 -253 253 253 253 253 253 253 253 253 253 253 253
39707 -253 253 253 253 253 253 253 253 253 253 253 253
39708 -253 253 253 253 253 253 253 253 253 253 253 253
39709 -253 253 253 253 253 253 253 253 253 253 253 253
39710 -253 253 253 253 253 253 144 144 144 2 2 6
39711 - 2 2 6 2 2 6 2 2 6 46 46 46
39712 - 2 2 6 2 2 6 2 2 6 2 2 6
39713 - 42 42 42 74 74 74 30 30 30 10 10 10
39714 - 0 0 0 0 0 0 0 0 0 0 0 0
39715 - 0 0 0 0 0 0 0 0 0 0 0 0
39716 - 0 0 0 0 0 0 0 0 0 0 0 0
39717 - 0 0 0 0 0 0 0 0 0 0 0 0
39718 - 0 0 0 0 0 0 0 0 0 0 0 0
39719 - 0 0 0 0 0 0 0 0 0 0 0 0
39720 - 0 0 0 0 0 0 0 0 0 0 0 0
39721 - 6 6 6 14 14 14 42 42 42 90 90 90
39722 - 26 26 26 6 6 6 42 42 42 2 2 6
39723 - 74 74 74 250 250 250 253 253 253 253 253 253
39724 -253 253 253 253 253 253 253 253 253 253 253 253
39725 -253 253 253 253 253 253 242 242 242 242 242 242
39726 -253 253 253 253 253 253 253 253 253 253 253 253
39727 -253 253 253 253 253 253 253 253 253 253 253 253
39728 -253 253 253 253 253 253 253 253 253 253 253 253
39729 -253 253 253 253 253 253 253 253 253 253 253 253
39730 -253 253 253 253 253 253 182 182 182 2 2 6
39731 - 2 2 6 2 2 6 2 2 6 46 46 46
39732 - 2 2 6 2 2 6 2 2 6 2 2 6
39733 - 10 10 10 86 86 86 38 38 38 10 10 10
39734 - 0 0 0 0 0 0 0 0 0 0 0 0
39735 - 0 0 0 0 0 0 0 0 0 0 0 0
39736 - 0 0 0 0 0 0 0 0 0 0 0 0
39737 - 0 0 0 0 0 0 0 0 0 0 0 0
39738 - 0 0 0 0 0 0 0 0 0 0 0 0
39739 - 0 0 0 0 0 0 0 0 0 0 0 0
39740 - 0 0 0 0 0 0 0 0 0 0 0 0
39741 - 10 10 10 26 26 26 66 66 66 82 82 82
39742 - 2 2 6 22 22 22 18 18 18 2 2 6
39743 -149 149 149 253 253 253 253 253 253 253 253 253
39744 -253 253 253 253 253 253 253 253 253 253 253 253
39745 -253 253 253 253 253 253 234 234 234 242 242 242
39746 -253 253 253 253 253 253 253 253 253 253 253 253
39747 -253 253 253 253 253 253 253 253 253 253 253 253
39748 -253 253 253 253 253 253 253 253 253 253 253 253
39749 -253 253 253 253 253 253 253 253 253 253 253 253
39750 -253 253 253 253 253 253 206 206 206 2 2 6
39751 - 2 2 6 2 2 6 2 2 6 38 38 38
39752 - 2 2 6 2 2 6 2 2 6 2 2 6
39753 - 6 6 6 86 86 86 46 46 46 14 14 14
39754 - 0 0 0 0 0 0 0 0 0 0 0 0
39755 - 0 0 0 0 0 0 0 0 0 0 0 0
39756 - 0 0 0 0 0 0 0 0 0 0 0 0
39757 - 0 0 0 0 0 0 0 0 0 0 0 0
39758 - 0 0 0 0 0 0 0 0 0 0 0 0
39759 - 0 0 0 0 0 0 0 0 0 0 0 0
39760 - 0 0 0 0 0 0 0 0 0 6 6 6
39761 - 18 18 18 46 46 46 86 86 86 18 18 18
39762 - 2 2 6 34 34 34 10 10 10 6 6 6
39763 -210 210 210 253 253 253 253 253 253 253 253 253
39764 -253 253 253 253 253 253 253 253 253 253 253 253
39765 -253 253 253 253 253 253 234 234 234 242 242 242
39766 -253 253 253 253 253 253 253 253 253 253 253 253
39767 -253 253 253 253 253 253 253 253 253 253 253 253
39768 -253 253 253 253 253 253 253 253 253 253 253 253
39769 -253 253 253 253 253 253 253 253 253 253 253 253
39770 -253 253 253 253 253 253 221 221 221 6 6 6
39771 - 2 2 6 2 2 6 6 6 6 30 30 30
39772 - 2 2 6 2 2 6 2 2 6 2 2 6
39773 - 2 2 6 82 82 82 54 54 54 18 18 18
39774 - 6 6 6 0 0 0 0 0 0 0 0 0
39775 - 0 0 0 0 0 0 0 0 0 0 0 0
39776 - 0 0 0 0 0 0 0 0 0 0 0 0
39777 - 0 0 0 0 0 0 0 0 0 0 0 0
39778 - 0 0 0 0 0 0 0 0 0 0 0 0
39779 - 0 0 0 0 0 0 0 0 0 0 0 0
39780 - 0 0 0 0 0 0 0 0 0 10 10 10
39781 - 26 26 26 66 66 66 62 62 62 2 2 6
39782 - 2 2 6 38 38 38 10 10 10 26 26 26
39783 -238 238 238 253 253 253 253 253 253 253 253 253
39784 -253 253 253 253 253 253 253 253 253 253 253 253
39785 -253 253 253 253 253 253 231 231 231 238 238 238
39786 -253 253 253 253 253 253 253 253 253 253 253 253
39787 -253 253 253 253 253 253 253 253 253 253 253 253
39788 -253 253 253 253 253 253 253 253 253 253 253 253
39789 -253 253 253 253 253 253 253 253 253 253 253 253
39790 -253 253 253 253 253 253 231 231 231 6 6 6
39791 - 2 2 6 2 2 6 10 10 10 30 30 30
39792 - 2 2 6 2 2 6 2 2 6 2 2 6
39793 - 2 2 6 66 66 66 58 58 58 22 22 22
39794 - 6 6 6 0 0 0 0 0 0 0 0 0
39795 - 0 0 0 0 0 0 0 0 0 0 0 0
39796 - 0 0 0 0 0 0 0 0 0 0 0 0
39797 - 0 0 0 0 0 0 0 0 0 0 0 0
39798 - 0 0 0 0 0 0 0 0 0 0 0 0
39799 - 0 0 0 0 0 0 0 0 0 0 0 0
39800 - 0 0 0 0 0 0 0 0 0 10 10 10
39801 - 38 38 38 78 78 78 6 6 6 2 2 6
39802 - 2 2 6 46 46 46 14 14 14 42 42 42
39803 -246 246 246 253 253 253 253 253 253 253 253 253
39804 -253 253 253 253 253 253 253 253 253 253 253 253
39805 -253 253 253 253 253 253 231 231 231 242 242 242
39806 -253 253 253 253 253 253 253 253 253 253 253 253
39807 -253 253 253 253 253 253 253 253 253 253 253 253
39808 -253 253 253 253 253 253 253 253 253 253 253 253
39809 -253 253 253 253 253 253 253 253 253 253 253 253
39810 -253 253 253 253 253 253 234 234 234 10 10 10
39811 - 2 2 6 2 2 6 22 22 22 14 14 14
39812 - 2 2 6 2 2 6 2 2 6 2 2 6
39813 - 2 2 6 66 66 66 62 62 62 22 22 22
39814 - 6 6 6 0 0 0 0 0 0 0 0 0
39815 - 0 0 0 0 0 0 0 0 0 0 0 0
39816 - 0 0 0 0 0 0 0 0 0 0 0 0
39817 - 0 0 0 0 0 0 0 0 0 0 0 0
39818 - 0 0 0 0 0 0 0 0 0 0 0 0
39819 - 0 0 0 0 0 0 0 0 0 0 0 0
39820 - 0 0 0 0 0 0 6 6 6 18 18 18
39821 - 50 50 50 74 74 74 2 2 6 2 2 6
39822 - 14 14 14 70 70 70 34 34 34 62 62 62
39823 -250 250 250 253 253 253 253 253 253 253 253 253
39824 -253 253 253 253 253 253 253 253 253 253 253 253
39825 -253 253 253 253 253 253 231 231 231 246 246 246
39826 -253 253 253 253 253 253 253 253 253 253 253 253
39827 -253 253 253 253 253 253 253 253 253 253 253 253
39828 -253 253 253 253 253 253 253 253 253 253 253 253
39829 -253 253 253 253 253 253 253 253 253 253 253 253
39830 -253 253 253 253 253 253 234 234 234 14 14 14
39831 - 2 2 6 2 2 6 30 30 30 2 2 6
39832 - 2 2 6 2 2 6 2 2 6 2 2 6
39833 - 2 2 6 66 66 66 62 62 62 22 22 22
39834 - 6 6 6 0 0 0 0 0 0 0 0 0
39835 - 0 0 0 0 0 0 0 0 0 0 0 0
39836 - 0 0 0 0 0 0 0 0 0 0 0 0
39837 - 0 0 0 0 0 0 0 0 0 0 0 0
39838 - 0 0 0 0 0 0 0 0 0 0 0 0
39839 - 0 0 0 0 0 0 0 0 0 0 0 0
39840 - 0 0 0 0 0 0 6 6 6 18 18 18
39841 - 54 54 54 62 62 62 2 2 6 2 2 6
39842 - 2 2 6 30 30 30 46 46 46 70 70 70
39843 -250 250 250 253 253 253 253 253 253 253 253 253
39844 -253 253 253 253 253 253 253 253 253 253 253 253
39845 -253 253 253 253 253 253 231 231 231 246 246 246
39846 -253 253 253 253 253 253 253 253 253 253 253 253
39847 -253 253 253 253 253 253 253 253 253 253 253 253
39848 -253 253 253 253 253 253 253 253 253 253 253 253
39849 -253 253 253 253 253 253 253 253 253 253 253 253
39850 -253 253 253 253 253 253 226 226 226 10 10 10
39851 - 2 2 6 6 6 6 30 30 30 2 2 6
39852 - 2 2 6 2 2 6 2 2 6 2 2 6
39853 - 2 2 6 66 66 66 58 58 58 22 22 22
39854 - 6 6 6 0 0 0 0 0 0 0 0 0
39855 - 0 0 0 0 0 0 0 0 0 0 0 0
39856 - 0 0 0 0 0 0 0 0 0 0 0 0
39857 - 0 0 0 0 0 0 0 0 0 0 0 0
39858 - 0 0 0 0 0 0 0 0 0 0 0 0
39859 - 0 0 0 0 0 0 0 0 0 0 0 0
39860 - 0 0 0 0 0 0 6 6 6 22 22 22
39861 - 58 58 58 62 62 62 2 2 6 2 2 6
39862 - 2 2 6 2 2 6 30 30 30 78 78 78
39863 -250 250 250 253 253 253 253 253 253 253 253 253
39864 -253 253 253 253 253 253 253 253 253 253 253 253
39865 -253 253 253 253 253 253 231 231 231 246 246 246
39866 -253 253 253 253 253 253 253 253 253 253 253 253
39867 -253 253 253 253 253 253 253 253 253 253 253 253
39868 -253 253 253 253 253 253 253 253 253 253 253 253
39869 -253 253 253 253 253 253 253 253 253 253 253 253
39870 -253 253 253 253 253 253 206 206 206 2 2 6
39871 - 22 22 22 34 34 34 18 14 6 22 22 22
39872 - 26 26 26 18 18 18 6 6 6 2 2 6
39873 - 2 2 6 82 82 82 54 54 54 18 18 18
39874 - 6 6 6 0 0 0 0 0 0 0 0 0
39875 - 0 0 0 0 0 0 0 0 0 0 0 0
39876 - 0 0 0 0 0 0 0 0 0 0 0 0
39877 - 0 0 0 0 0 0 0 0 0 0 0 0
39878 - 0 0 0 0 0 0 0 0 0 0 0 0
39879 - 0 0 0 0 0 0 0 0 0 0 0 0
39880 - 0 0 0 0 0 0 6 6 6 26 26 26
39881 - 62 62 62 106 106 106 74 54 14 185 133 11
39882 -210 162 10 121 92 8 6 6 6 62 62 62
39883 -238 238 238 253 253 253 253 253 253 253 253 253
39884 -253 253 253 253 253 253 253 253 253 253 253 253
39885 -253 253 253 253 253 253 231 231 231 246 246 246
39886 -253 253 253 253 253 253 253 253 253 253 253 253
39887 -253 253 253 253 253 253 253 253 253 253 253 253
39888 -253 253 253 253 253 253 253 253 253 253 253 253
39889 -253 253 253 253 253 253 253 253 253 253 253 253
39890 -253 253 253 253 253 253 158 158 158 18 18 18
39891 - 14 14 14 2 2 6 2 2 6 2 2 6
39892 - 6 6 6 18 18 18 66 66 66 38 38 38
39893 - 6 6 6 94 94 94 50 50 50 18 18 18
39894 - 6 6 6 0 0 0 0 0 0 0 0 0
39895 - 0 0 0 0 0 0 0 0 0 0 0 0
39896 - 0 0 0 0 0 0 0 0 0 0 0 0
39897 - 0 0 0 0 0 0 0 0 0 0 0 0
39898 - 0 0 0 0 0 0 0 0 0 0 0 0
39899 - 0 0 0 0 0 0 0 0 0 6 6 6
39900 - 10 10 10 10 10 10 18 18 18 38 38 38
39901 - 78 78 78 142 134 106 216 158 10 242 186 14
39902 -246 190 14 246 190 14 156 118 10 10 10 10
39903 - 90 90 90 238 238 238 253 253 253 253 253 253
39904 -253 253 253 253 253 253 253 253 253 253 253 253
39905 -253 253 253 253 253 253 231 231 231 250 250 250
39906 -253 253 253 253 253 253 253 253 253 253 253 253
39907 -253 253 253 253 253 253 253 253 253 253 253 253
39908 -253 253 253 253 253 253 253 253 253 253 253 253
39909 -253 253 253 253 253 253 253 253 253 246 230 190
39910 -238 204 91 238 204 91 181 142 44 37 26 9
39911 - 2 2 6 2 2 6 2 2 6 2 2 6
39912 - 2 2 6 2 2 6 38 38 38 46 46 46
39913 - 26 26 26 106 106 106 54 54 54 18 18 18
39914 - 6 6 6 0 0 0 0 0 0 0 0 0
39915 - 0 0 0 0 0 0 0 0 0 0 0 0
39916 - 0 0 0 0 0 0 0 0 0 0 0 0
39917 - 0 0 0 0 0 0 0 0 0 0 0 0
39918 - 0 0 0 0 0 0 0 0 0 0 0 0
39919 - 0 0 0 6 6 6 14 14 14 22 22 22
39920 - 30 30 30 38 38 38 50 50 50 70 70 70
39921 -106 106 106 190 142 34 226 170 11 242 186 14
39922 -246 190 14 246 190 14 246 190 14 154 114 10
39923 - 6 6 6 74 74 74 226 226 226 253 253 253
39924 -253 253 253 253 253 253 253 253 253 253 253 253
39925 -253 253 253 253 253 253 231 231 231 250 250 250
39926 -253 253 253 253 253 253 253 253 253 253 253 253
39927 -253 253 253 253 253 253 253 253 253 253 253 253
39928 -253 253 253 253 253 253 253 253 253 253 253 253
39929 -253 253 253 253 253 253 253 253 253 228 184 62
39930 -241 196 14 241 208 19 232 195 16 38 30 10
39931 - 2 2 6 2 2 6 2 2 6 2 2 6
39932 - 2 2 6 6 6 6 30 30 30 26 26 26
39933 -203 166 17 154 142 90 66 66 66 26 26 26
39934 - 6 6 6 0 0 0 0 0 0 0 0 0
39935 - 0 0 0 0 0 0 0 0 0 0 0 0
39936 - 0 0 0 0 0 0 0 0 0 0 0 0
39937 - 0 0 0 0 0 0 0 0 0 0 0 0
39938 - 0 0 0 0 0 0 0 0 0 0 0 0
39939 - 6 6 6 18 18 18 38 38 38 58 58 58
39940 - 78 78 78 86 86 86 101 101 101 123 123 123
39941 -175 146 61 210 150 10 234 174 13 246 186 14
39942 -246 190 14 246 190 14 246 190 14 238 190 10
39943 -102 78 10 2 2 6 46 46 46 198 198 198
39944 -253 253 253 253 253 253 253 253 253 253 253 253
39945 -253 253 253 253 253 253 234 234 234 242 242 242
39946 -253 253 253 253 253 253 253 253 253 253 253 253
39947 -253 253 253 253 253 253 253 253 253 253 253 253
39948 -253 253 253 253 253 253 253 253 253 253 253 253
39949 -253 253 253 253 253 253 253 253 253 224 178 62
39950 -242 186 14 241 196 14 210 166 10 22 18 6
39951 - 2 2 6 2 2 6 2 2 6 2 2 6
39952 - 2 2 6 2 2 6 6 6 6 121 92 8
39953 -238 202 15 232 195 16 82 82 82 34 34 34
39954 - 10 10 10 0 0 0 0 0 0 0 0 0
39955 - 0 0 0 0 0 0 0 0 0 0 0 0
39956 - 0 0 0 0 0 0 0 0 0 0 0 0
39957 - 0 0 0 0 0 0 0 0 0 0 0 0
39958 - 0 0 0 0 0 0 0 0 0 0 0 0
39959 - 14 14 14 38 38 38 70 70 70 154 122 46
39960 -190 142 34 200 144 11 197 138 11 197 138 11
39961 -213 154 11 226 170 11 242 186 14 246 190 14
39962 -246 190 14 246 190 14 246 190 14 246 190 14
39963 -225 175 15 46 32 6 2 2 6 22 22 22
39964 -158 158 158 250 250 250 253 253 253 253 253 253
39965 -253 253 253 253 253 253 253 253 253 253 253 253
39966 -253 253 253 253 253 253 253 253 253 253 253 253
39967 -253 253 253 253 253 253 253 253 253 253 253 253
39968 -253 253 253 253 253 253 253 253 253 253 253 253
39969 -253 253 253 250 250 250 242 242 242 224 178 62
39970 -239 182 13 236 186 11 213 154 11 46 32 6
39971 - 2 2 6 2 2 6 2 2 6 2 2 6
39972 - 2 2 6 2 2 6 61 42 6 225 175 15
39973 -238 190 10 236 186 11 112 100 78 42 42 42
39974 - 14 14 14 0 0 0 0 0 0 0 0 0
39975 - 0 0 0 0 0 0 0 0 0 0 0 0
39976 - 0 0 0 0 0 0 0 0 0 0 0 0
39977 - 0 0 0 0 0 0 0 0 0 0 0 0
39978 - 0 0 0 0 0 0 0 0 0 6 6 6
39979 - 22 22 22 54 54 54 154 122 46 213 154 11
39980 -226 170 11 230 174 11 226 170 11 226 170 11
39981 -236 178 12 242 186 14 246 190 14 246 190 14
39982 -246 190 14 246 190 14 246 190 14 246 190 14
39983 -241 196 14 184 144 12 10 10 10 2 2 6
39984 - 6 6 6 116 116 116 242 242 242 253 253 253
39985 -253 253 253 253 253 253 253 253 253 253 253 253
39986 -253 253 253 253 253 253 253 253 253 253 253 253
39987 -253 253 253 253 253 253 253 253 253 253 253 253
39988 -253 253 253 253 253 253 253 253 253 253 253 253
39989 -253 253 253 231 231 231 198 198 198 214 170 54
39990 -236 178 12 236 178 12 210 150 10 137 92 6
39991 - 18 14 6 2 2 6 2 2 6 2 2 6
39992 - 6 6 6 70 47 6 200 144 11 236 178 12
39993 -239 182 13 239 182 13 124 112 88 58 58 58
39994 - 22 22 22 6 6 6 0 0 0 0 0 0
39995 - 0 0 0 0 0 0 0 0 0 0 0 0
39996 - 0 0 0 0 0 0 0 0 0 0 0 0
39997 - 0 0 0 0 0 0 0 0 0 0 0 0
39998 - 0 0 0 0 0 0 0 0 0 10 10 10
39999 - 30 30 30 70 70 70 180 133 36 226 170 11
40000 -239 182 13 242 186 14 242 186 14 246 186 14
40001 -246 190 14 246 190 14 246 190 14 246 190 14
40002 -246 190 14 246 190 14 246 190 14 246 190 14
40003 -246 190 14 232 195 16 98 70 6 2 2 6
40004 - 2 2 6 2 2 6 66 66 66 221 221 221
40005 -253 253 253 253 253 253 253 253 253 253 253 253
40006 -253 253 253 253 253 253 253 253 253 253 253 253
40007 -253 253 253 253 253 253 253 253 253 253 253 253
40008 -253 253 253 253 253 253 253 253 253 253 253 253
40009 -253 253 253 206 206 206 198 198 198 214 166 58
40010 -230 174 11 230 174 11 216 158 10 192 133 9
40011 -163 110 8 116 81 8 102 78 10 116 81 8
40012 -167 114 7 197 138 11 226 170 11 239 182 13
40013 -242 186 14 242 186 14 162 146 94 78 78 78
40014 - 34 34 34 14 14 14 6 6 6 0 0 0
40015 - 0 0 0 0 0 0 0 0 0 0 0 0
40016 - 0 0 0 0 0 0 0 0 0 0 0 0
40017 - 0 0 0 0 0 0 0 0 0 0 0 0
40018 - 0 0 0 0 0 0 0 0 0 6 6 6
40019 - 30 30 30 78 78 78 190 142 34 226 170 11
40020 -239 182 13 246 190 14 246 190 14 246 190 14
40021 -246 190 14 246 190 14 246 190 14 246 190 14
40022 -246 190 14 246 190 14 246 190 14 246 190 14
40023 -246 190 14 241 196 14 203 166 17 22 18 6
40024 - 2 2 6 2 2 6 2 2 6 38 38 38
40025 -218 218 218 253 253 253 253 253 253 253 253 253
40026 -253 253 253 253 253 253 253 253 253 253 253 253
40027 -253 253 253 253 253 253 253 253 253 253 253 253
40028 -253 253 253 253 253 253 253 253 253 253 253 253
40029 -250 250 250 206 206 206 198 198 198 202 162 69
40030 -226 170 11 236 178 12 224 166 10 210 150 10
40031 -200 144 11 197 138 11 192 133 9 197 138 11
40032 -210 150 10 226 170 11 242 186 14 246 190 14
40033 -246 190 14 246 186 14 225 175 15 124 112 88
40034 - 62 62 62 30 30 30 14 14 14 6 6 6
40035 - 0 0 0 0 0 0 0 0 0 0 0 0
40036 - 0 0 0 0 0 0 0 0 0 0 0 0
40037 - 0 0 0 0 0 0 0 0 0 0 0 0
40038 - 0 0 0 0 0 0 0 0 0 10 10 10
40039 - 30 30 30 78 78 78 174 135 50 224 166 10
40040 -239 182 13 246 190 14 246 190 14 246 190 14
40041 -246 190 14 246 190 14 246 190 14 246 190 14
40042 -246 190 14 246 190 14 246 190 14 246 190 14
40043 -246 190 14 246 190 14 241 196 14 139 102 15
40044 - 2 2 6 2 2 6 2 2 6 2 2 6
40045 - 78 78 78 250 250 250 253 253 253 253 253 253
40046 -253 253 253 253 253 253 253 253 253 253 253 253
40047 -253 253 253 253 253 253 253 253 253 253 253 253
40048 -253 253 253 253 253 253 253 253 253 253 253 253
40049 -250 250 250 214 214 214 198 198 198 190 150 46
40050 -219 162 10 236 178 12 234 174 13 224 166 10
40051 -216 158 10 213 154 11 213 154 11 216 158 10
40052 -226 170 11 239 182 13 246 190 14 246 190 14
40053 -246 190 14 246 190 14 242 186 14 206 162 42
40054 -101 101 101 58 58 58 30 30 30 14 14 14
40055 - 6 6 6 0 0 0 0 0 0 0 0 0
40056 - 0 0 0 0 0 0 0 0 0 0 0 0
40057 - 0 0 0 0 0 0 0 0 0 0 0 0
40058 - 0 0 0 0 0 0 0 0 0 10 10 10
40059 - 30 30 30 74 74 74 174 135 50 216 158 10
40060 -236 178 12 246 190 14 246 190 14 246 190 14
40061 -246 190 14 246 190 14 246 190 14 246 190 14
40062 -246 190 14 246 190 14 246 190 14 246 190 14
40063 -246 190 14 246 190 14 241 196 14 226 184 13
40064 - 61 42 6 2 2 6 2 2 6 2 2 6
40065 - 22 22 22 238 238 238 253 253 253 253 253 253
40066 -253 253 253 253 253 253 253 253 253 253 253 253
40067 -253 253 253 253 253 253 253 253 253 253 253 253
40068 -253 253 253 253 253 253 253 253 253 253 253 253
40069 -253 253 253 226 226 226 187 187 187 180 133 36
40070 -216 158 10 236 178 12 239 182 13 236 178 12
40071 -230 174 11 226 170 11 226 170 11 230 174 11
40072 -236 178 12 242 186 14 246 190 14 246 190 14
40073 -246 190 14 246 190 14 246 186 14 239 182 13
40074 -206 162 42 106 106 106 66 66 66 34 34 34
40075 - 14 14 14 6 6 6 0 0 0 0 0 0
40076 - 0 0 0 0 0 0 0 0 0 0 0 0
40077 - 0 0 0 0 0 0 0 0 0 0 0 0
40078 - 0 0 0 0 0 0 0 0 0 6 6 6
40079 - 26 26 26 70 70 70 163 133 67 213 154 11
40080 -236 178 12 246 190 14 246 190 14 246 190 14
40081 -246 190 14 246 190 14 246 190 14 246 190 14
40082 -246 190 14 246 190 14 246 190 14 246 190 14
40083 -246 190 14 246 190 14 246 190 14 241 196 14
40084 -190 146 13 18 14 6 2 2 6 2 2 6
40085 - 46 46 46 246 246 246 253 253 253 253 253 253
40086 -253 253 253 253 253 253 253 253 253 253 253 253
40087 -253 253 253 253 253 253 253 253 253 253 253 253
40088 -253 253 253 253 253 253 253 253 253 253 253 253
40089 -253 253 253 221 221 221 86 86 86 156 107 11
40090 -216 158 10 236 178 12 242 186 14 246 186 14
40091 -242 186 14 239 182 13 239 182 13 242 186 14
40092 -242 186 14 246 186 14 246 190 14 246 190 14
40093 -246 190 14 246 190 14 246 190 14 246 190 14
40094 -242 186 14 225 175 15 142 122 72 66 66 66
40095 - 30 30 30 10 10 10 0 0 0 0 0 0
40096 - 0 0 0 0 0 0 0 0 0 0 0 0
40097 - 0 0 0 0 0 0 0 0 0 0 0 0
40098 - 0 0 0 0 0 0 0 0 0 6 6 6
40099 - 26 26 26 70 70 70 163 133 67 210 150 10
40100 -236 178 12 246 190 14 246 190 14 246 190 14
40101 -246 190 14 246 190 14 246 190 14 246 190 14
40102 -246 190 14 246 190 14 246 190 14 246 190 14
40103 -246 190 14 246 190 14 246 190 14 246 190 14
40104 -232 195 16 121 92 8 34 34 34 106 106 106
40105 -221 221 221 253 253 253 253 253 253 253 253 253
40106 -253 253 253 253 253 253 253 253 253 253 253 253
40107 -253 253 253 253 253 253 253 253 253 253 253 253
40108 -253 253 253 253 253 253 253 253 253 253 253 253
40109 -242 242 242 82 82 82 18 14 6 163 110 8
40110 -216 158 10 236 178 12 242 186 14 246 190 14
40111 -246 190 14 246 190 14 246 190 14 246 190 14
40112 -246 190 14 246 190 14 246 190 14 246 190 14
40113 -246 190 14 246 190 14 246 190 14 246 190 14
40114 -246 190 14 246 190 14 242 186 14 163 133 67
40115 - 46 46 46 18 18 18 6 6 6 0 0 0
40116 - 0 0 0 0 0 0 0 0 0 0 0 0
40117 - 0 0 0 0 0 0 0 0 0 0 0 0
40118 - 0 0 0 0 0 0 0 0 0 10 10 10
40119 - 30 30 30 78 78 78 163 133 67 210 150 10
40120 -236 178 12 246 186 14 246 190 14 246 190 14
40121 -246 190 14 246 190 14 246 190 14 246 190 14
40122 -246 190 14 246 190 14 246 190 14 246 190 14
40123 -246 190 14 246 190 14 246 190 14 246 190 14
40124 -241 196 14 215 174 15 190 178 144 253 253 253
40125 -253 253 253 253 253 253 253 253 253 253 253 253
40126 -253 253 253 253 253 253 253 253 253 253 253 253
40127 -253 253 253 253 253 253 253 253 253 253 253 253
40128 -253 253 253 253 253 253 253 253 253 218 218 218
40129 - 58 58 58 2 2 6 22 18 6 167 114 7
40130 -216 158 10 236 178 12 246 186 14 246 190 14
40131 -246 190 14 246 190 14 246 190 14 246 190 14
40132 -246 190 14 246 190 14 246 190 14 246 190 14
40133 -246 190 14 246 190 14 246 190 14 246 190 14
40134 -246 190 14 246 186 14 242 186 14 190 150 46
40135 - 54 54 54 22 22 22 6 6 6 0 0 0
40136 - 0 0 0 0 0 0 0 0 0 0 0 0
40137 - 0 0 0 0 0 0 0 0 0 0 0 0
40138 - 0 0 0 0 0 0 0 0 0 14 14 14
40139 - 38 38 38 86 86 86 180 133 36 213 154 11
40140 -236 178 12 246 186 14 246 190 14 246 190 14
40141 -246 190 14 246 190 14 246 190 14 246 190 14
40142 -246 190 14 246 190 14 246 190 14 246 190 14
40143 -246 190 14 246 190 14 246 190 14 246 190 14
40144 -246 190 14 232 195 16 190 146 13 214 214 214
40145 -253 253 253 253 253 253 253 253 253 253 253 253
40146 -253 253 253 253 253 253 253 253 253 253 253 253
40147 -253 253 253 253 253 253 253 253 253 253 253 253
40148 -253 253 253 250 250 250 170 170 170 26 26 26
40149 - 2 2 6 2 2 6 37 26 9 163 110 8
40150 -219 162 10 239 182 13 246 186 14 246 190 14
40151 -246 190 14 246 190 14 246 190 14 246 190 14
40152 -246 190 14 246 190 14 246 190 14 246 190 14
40153 -246 190 14 246 190 14 246 190 14 246 190 14
40154 -246 186 14 236 178 12 224 166 10 142 122 72
40155 - 46 46 46 18 18 18 6 6 6 0 0 0
40156 - 0 0 0 0 0 0 0 0 0 0 0 0
40157 - 0 0 0 0 0 0 0 0 0 0 0 0
40158 - 0 0 0 0 0 0 6 6 6 18 18 18
40159 - 50 50 50 109 106 95 192 133 9 224 166 10
40160 -242 186 14 246 190 14 246 190 14 246 190 14
40161 -246 190 14 246 190 14 246 190 14 246 190 14
40162 -246 190 14 246 190 14 246 190 14 246 190 14
40163 -246 190 14 246 190 14 246 190 14 246 190 14
40164 -242 186 14 226 184 13 210 162 10 142 110 46
40165 -226 226 226 253 253 253 253 253 253 253 253 253
40166 -253 253 253 253 253 253 253 253 253 253 253 253
40167 -253 253 253 253 253 253 253 253 253 253 253 253
40168 -198 198 198 66 66 66 2 2 6 2 2 6
40169 - 2 2 6 2 2 6 50 34 6 156 107 11
40170 -219 162 10 239 182 13 246 186 14 246 190 14
40171 -246 190 14 246 190 14 246 190 14 246 190 14
40172 -246 190 14 246 190 14 246 190 14 246 190 14
40173 -246 190 14 246 190 14 246 190 14 242 186 14
40174 -234 174 13 213 154 11 154 122 46 66 66 66
40175 - 30 30 30 10 10 10 0 0 0 0 0 0
40176 - 0 0 0 0 0 0 0 0 0 0 0 0
40177 - 0 0 0 0 0 0 0 0 0 0 0 0
40178 - 0 0 0 0 0 0 6 6 6 22 22 22
40179 - 58 58 58 154 121 60 206 145 10 234 174 13
40180 -242 186 14 246 186 14 246 190 14 246 190 14
40181 -246 190 14 246 190 14 246 190 14 246 190 14
40182 -246 190 14 246 190 14 246 190 14 246 190 14
40183 -246 190 14 246 190 14 246 190 14 246 190 14
40184 -246 186 14 236 178 12 210 162 10 163 110 8
40185 - 61 42 6 138 138 138 218 218 218 250 250 250
40186 -253 253 253 253 253 253 253 253 253 250 250 250
40187 -242 242 242 210 210 210 144 144 144 66 66 66
40188 - 6 6 6 2 2 6 2 2 6 2 2 6
40189 - 2 2 6 2 2 6 61 42 6 163 110 8
40190 -216 158 10 236 178 12 246 190 14 246 190 14
40191 -246 190 14 246 190 14 246 190 14 246 190 14
40192 -246 190 14 246 190 14 246 190 14 246 190 14
40193 -246 190 14 239 182 13 230 174 11 216 158 10
40194 -190 142 34 124 112 88 70 70 70 38 38 38
40195 - 18 18 18 6 6 6 0 0 0 0 0 0
40196 - 0 0 0 0 0 0 0 0 0 0 0 0
40197 - 0 0 0 0 0 0 0 0 0 0 0 0
40198 - 0 0 0 0 0 0 6 6 6 22 22 22
40199 - 62 62 62 168 124 44 206 145 10 224 166 10
40200 -236 178 12 239 182 13 242 186 14 242 186 14
40201 -246 186 14 246 190 14 246 190 14 246 190 14
40202 -246 190 14 246 190 14 246 190 14 246 190 14
40203 -246 190 14 246 190 14 246 190 14 246 190 14
40204 -246 190 14 236 178 12 216 158 10 175 118 6
40205 - 80 54 7 2 2 6 6 6 6 30 30 30
40206 - 54 54 54 62 62 62 50 50 50 38 38 38
40207 - 14 14 14 2 2 6 2 2 6 2 2 6
40208 - 2 2 6 2 2 6 2 2 6 2 2 6
40209 - 2 2 6 6 6 6 80 54 7 167 114 7
40210 -213 154 11 236 178 12 246 190 14 246 190 14
40211 -246 190 14 246 190 14 246 190 14 246 190 14
40212 -246 190 14 242 186 14 239 182 13 239 182 13
40213 -230 174 11 210 150 10 174 135 50 124 112 88
40214 - 82 82 82 54 54 54 34 34 34 18 18 18
40215 - 6 6 6 0 0 0 0 0 0 0 0 0
40216 - 0 0 0 0 0 0 0 0 0 0 0 0
40217 - 0 0 0 0 0 0 0 0 0 0 0 0
40218 - 0 0 0 0 0 0 6 6 6 18 18 18
40219 - 50 50 50 158 118 36 192 133 9 200 144 11
40220 -216 158 10 219 162 10 224 166 10 226 170 11
40221 -230 174 11 236 178 12 239 182 13 239 182 13
40222 -242 186 14 246 186 14 246 190 14 246 190 14
40223 -246 190 14 246 190 14 246 190 14 246 190 14
40224 -246 186 14 230 174 11 210 150 10 163 110 8
40225 -104 69 6 10 10 10 2 2 6 2 2 6
40226 - 2 2 6 2 2 6 2 2 6 2 2 6
40227 - 2 2 6 2 2 6 2 2 6 2 2 6
40228 - 2 2 6 2 2 6 2 2 6 2 2 6
40229 - 2 2 6 6 6 6 91 60 6 167 114 7
40230 -206 145 10 230 174 11 242 186 14 246 190 14
40231 -246 190 14 246 190 14 246 186 14 242 186 14
40232 -239 182 13 230 174 11 224 166 10 213 154 11
40233 -180 133 36 124 112 88 86 86 86 58 58 58
40234 - 38 38 38 22 22 22 10 10 10 6 6 6
40235 - 0 0 0 0 0 0 0 0 0 0 0 0
40236 - 0 0 0 0 0 0 0 0 0 0 0 0
40237 - 0 0 0 0 0 0 0 0 0 0 0 0
40238 - 0 0 0 0 0 0 0 0 0 14 14 14
40239 - 34 34 34 70 70 70 138 110 50 158 118 36
40240 -167 114 7 180 123 7 192 133 9 197 138 11
40241 -200 144 11 206 145 10 213 154 11 219 162 10
40242 -224 166 10 230 174 11 239 182 13 242 186 14
40243 -246 186 14 246 186 14 246 186 14 246 186 14
40244 -239 182 13 216 158 10 185 133 11 152 99 6
40245 -104 69 6 18 14 6 2 2 6 2 2 6
40246 - 2 2 6 2 2 6 2 2 6 2 2 6
40247 - 2 2 6 2 2 6 2 2 6 2 2 6
40248 - 2 2 6 2 2 6 2 2 6 2 2 6
40249 - 2 2 6 6 6 6 80 54 7 152 99 6
40250 -192 133 9 219 162 10 236 178 12 239 182 13
40251 -246 186 14 242 186 14 239 182 13 236 178 12
40252 -224 166 10 206 145 10 192 133 9 154 121 60
40253 - 94 94 94 62 62 62 42 42 42 22 22 22
40254 - 14 14 14 6 6 6 0 0 0 0 0 0
40255 - 0 0 0 0 0 0 0 0 0 0 0 0
40256 - 0 0 0 0 0 0 0 0 0 0 0 0
40257 - 0 0 0 0 0 0 0 0 0 0 0 0
40258 - 0 0 0 0 0 0 0 0 0 6 6 6
40259 - 18 18 18 34 34 34 58 58 58 78 78 78
40260 -101 98 89 124 112 88 142 110 46 156 107 11
40261 -163 110 8 167 114 7 175 118 6 180 123 7
40262 -185 133 11 197 138 11 210 150 10 219 162 10
40263 -226 170 11 236 178 12 236 178 12 234 174 13
40264 -219 162 10 197 138 11 163 110 8 130 83 6
40265 - 91 60 6 10 10 10 2 2 6 2 2 6
40266 - 18 18 18 38 38 38 38 38 38 38 38 38
40267 - 38 38 38 38 38 38 38 38 38 38 38 38
40268 - 38 38 38 38 38 38 26 26 26 2 2 6
40269 - 2 2 6 6 6 6 70 47 6 137 92 6
40270 -175 118 6 200 144 11 219 162 10 230 174 11
40271 -234 174 13 230 174 11 219 162 10 210 150 10
40272 -192 133 9 163 110 8 124 112 88 82 82 82
40273 - 50 50 50 30 30 30 14 14 14 6 6 6
40274 - 0 0 0 0 0 0 0 0 0 0 0 0
40275 - 0 0 0 0 0 0 0 0 0 0 0 0
40276 - 0 0 0 0 0 0 0 0 0 0 0 0
40277 - 0 0 0 0 0 0 0 0 0 0 0 0
40278 - 0 0 0 0 0 0 0 0 0 0 0 0
40279 - 6 6 6 14 14 14 22 22 22 34 34 34
40280 - 42 42 42 58 58 58 74 74 74 86 86 86
40281 -101 98 89 122 102 70 130 98 46 121 87 25
40282 -137 92 6 152 99 6 163 110 8 180 123 7
40283 -185 133 11 197 138 11 206 145 10 200 144 11
40284 -180 123 7 156 107 11 130 83 6 104 69 6
40285 - 50 34 6 54 54 54 110 110 110 101 98 89
40286 - 86 86 86 82 82 82 78 78 78 78 78 78
40287 - 78 78 78 78 78 78 78 78 78 78 78 78
40288 - 78 78 78 82 82 82 86 86 86 94 94 94
40289 -106 106 106 101 101 101 86 66 34 124 80 6
40290 -156 107 11 180 123 7 192 133 9 200 144 11
40291 -206 145 10 200 144 11 192 133 9 175 118 6
40292 -139 102 15 109 106 95 70 70 70 42 42 42
40293 - 22 22 22 10 10 10 0 0 0 0 0 0
40294 - 0 0 0 0 0 0 0 0 0 0 0 0
40295 - 0 0 0 0 0 0 0 0 0 0 0 0
40296 - 0 0 0 0 0 0 0 0 0 0 0 0
40297 - 0 0 0 0 0 0 0 0 0 0 0 0
40298 - 0 0 0 0 0 0 0 0 0 0 0 0
40299 - 0 0 0 0 0 0 6 6 6 10 10 10
40300 - 14 14 14 22 22 22 30 30 30 38 38 38
40301 - 50 50 50 62 62 62 74 74 74 90 90 90
40302 -101 98 89 112 100 78 121 87 25 124 80 6
40303 -137 92 6 152 99 6 152 99 6 152 99 6
40304 -138 86 6 124 80 6 98 70 6 86 66 30
40305 -101 98 89 82 82 82 58 58 58 46 46 46
40306 - 38 38 38 34 34 34 34 34 34 34 34 34
40307 - 34 34 34 34 34 34 34 34 34 34 34 34
40308 - 34 34 34 34 34 34 38 38 38 42 42 42
40309 - 54 54 54 82 82 82 94 86 76 91 60 6
40310 -134 86 6 156 107 11 167 114 7 175 118 6
40311 -175 118 6 167 114 7 152 99 6 121 87 25
40312 -101 98 89 62 62 62 34 34 34 18 18 18
40313 - 6 6 6 0 0 0 0 0 0 0 0 0
40314 - 0 0 0 0 0 0 0 0 0 0 0 0
40315 - 0 0 0 0 0 0 0 0 0 0 0 0
40316 - 0 0 0 0 0 0 0 0 0 0 0 0
40317 - 0 0 0 0 0 0 0 0 0 0 0 0
40318 - 0 0 0 0 0 0 0 0 0 0 0 0
40319 - 0 0 0 0 0 0 0 0 0 0 0 0
40320 - 0 0 0 6 6 6 6 6 6 10 10 10
40321 - 18 18 18 22 22 22 30 30 30 42 42 42
40322 - 50 50 50 66 66 66 86 86 86 101 98 89
40323 -106 86 58 98 70 6 104 69 6 104 69 6
40324 -104 69 6 91 60 6 82 62 34 90 90 90
40325 - 62 62 62 38 38 38 22 22 22 14 14 14
40326 - 10 10 10 10 10 10 10 10 10 10 10 10
40327 - 10 10 10 10 10 10 6 6 6 10 10 10
40328 - 10 10 10 10 10 10 10 10 10 14 14 14
40329 - 22 22 22 42 42 42 70 70 70 89 81 66
40330 - 80 54 7 104 69 6 124 80 6 137 92 6
40331 -134 86 6 116 81 8 100 82 52 86 86 86
40332 - 58 58 58 30 30 30 14 14 14 6 6 6
40333 - 0 0 0 0 0 0 0 0 0 0 0 0
40334 - 0 0 0 0 0 0 0 0 0 0 0 0
40335 - 0 0 0 0 0 0 0 0 0 0 0 0
40336 - 0 0 0 0 0 0 0 0 0 0 0 0
40337 - 0 0 0 0 0 0 0 0 0 0 0 0
40338 - 0 0 0 0 0 0 0 0 0 0 0 0
40339 - 0 0 0 0 0 0 0 0 0 0 0 0
40340 - 0 0 0 0 0 0 0 0 0 0 0 0
40341 - 0 0 0 6 6 6 10 10 10 14 14 14
40342 - 18 18 18 26 26 26 38 38 38 54 54 54
40343 - 70 70 70 86 86 86 94 86 76 89 81 66
40344 - 89 81 66 86 86 86 74 74 74 50 50 50
40345 - 30 30 30 14 14 14 6 6 6 0 0 0
40346 - 0 0 0 0 0 0 0 0 0 0 0 0
40347 - 0 0 0 0 0 0 0 0 0 0 0 0
40348 - 0 0 0 0 0 0 0 0 0 0 0 0
40349 - 6 6 6 18 18 18 34 34 34 58 58 58
40350 - 82 82 82 89 81 66 89 81 66 89 81 66
40351 - 94 86 66 94 86 76 74 74 74 50 50 50
40352 - 26 26 26 14 14 14 6 6 6 0 0 0
40353 - 0 0 0 0 0 0 0 0 0 0 0 0
40354 - 0 0 0 0 0 0 0 0 0 0 0 0
40355 - 0 0 0 0 0 0 0 0 0 0 0 0
40356 - 0 0 0 0 0 0 0 0 0 0 0 0
40357 - 0 0 0 0 0 0 0 0 0 0 0 0
40358 - 0 0 0 0 0 0 0 0 0 0 0 0
40359 - 0 0 0 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 - 6 6 6 6 6 6 14 14 14 18 18 18
40363 - 30 30 30 38 38 38 46 46 46 54 54 54
40364 - 50 50 50 42 42 42 30 30 30 18 18 18
40365 - 10 10 10 0 0 0 0 0 0 0 0 0
40366 - 0 0 0 0 0 0 0 0 0 0 0 0
40367 - 0 0 0 0 0 0 0 0 0 0 0 0
40368 - 0 0 0 0 0 0 0 0 0 0 0 0
40369 - 0 0 0 6 6 6 14 14 14 26 26 26
40370 - 38 38 38 50 50 50 58 58 58 58 58 58
40371 - 54 54 54 42 42 42 30 30 30 18 18 18
40372 - 10 10 10 0 0 0 0 0 0 0 0 0
40373 - 0 0 0 0 0 0 0 0 0 0 0 0
40374 - 0 0 0 0 0 0 0 0 0 0 0 0
40375 - 0 0 0 0 0 0 0 0 0 0 0 0
40376 - 0 0 0 0 0 0 0 0 0 0 0 0
40377 - 0 0 0 0 0 0 0 0 0 0 0 0
40378 - 0 0 0 0 0 0 0 0 0 0 0 0
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 6 6 6
40383 - 6 6 6 10 10 10 14 14 14 18 18 18
40384 - 18 18 18 14 14 14 10 10 10 6 6 6
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 0 0 0 0 0 0 0 0 0
40388 - 0 0 0 0 0 0 0 0 0 0 0 0
40389 - 0 0 0 0 0 0 0 0 0 6 6 6
40390 - 14 14 14 18 18 18 22 22 22 22 22 22
40391 - 18 18 18 14 14 14 10 10 10 6 6 6
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 - 0 0 0 0 0 0 0 0 0 0 0 0
40396 - 0 0 0 0 0 0 0 0 0 0 0 0
40397 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40398 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40399 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40400 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40401 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40402 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40403 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40404 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40405 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40406 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40407 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40408 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40409 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40410 +4 4 4 4 4 4
40411 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40412 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40413 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40414 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40415 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40416 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40417 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40418 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40419 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40420 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40421 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40422 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40423 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40424 +4 4 4 4 4 4
40425 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40426 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40427 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40428 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40429 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40430 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40431 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40432 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40433 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40434 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40435 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40436 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40437 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40438 +4 4 4 4 4 4
40439 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40440 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40441 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40442 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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
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 4 4 4 4 4 4 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
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 4 4 4 4 4 4 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
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 4 4 4 4 4 4 4 4 4 4 4 4
40485 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
40486 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 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 1 1 1 0 0 0
40491 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
40492 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
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
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 4 4 4 4 4 4 4 4 4 4 4 4
40499 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
40500 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
40501 +5 5 5 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 3 3 3 0 0 0 1 1 1 6 6 6
40505 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
40506 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
40507 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40508 +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 4 4 4 4 4 4 4 4 4 4 4 4
40513 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
40514 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
40515 +0 0 0 3 3 3 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 0 0 0 4 4 4 41 54 63 125 124 125
40519 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
40520 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
40521 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
40522 +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 5 5 5 5 5 5 2 2 2 0 0 0
40527 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
40528 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
40529 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 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 4 4 4 5 5 5 5 5 5
40532 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
40533 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
40534 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
40535 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
40536 +4 4 4 4 4 4
40537 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40538 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40539 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40540 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
40541 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
40542 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
40543 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
40544 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
40545 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
40546 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
40547 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
40548 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
40549 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
40550 +4 4 4 4 4 4
40551 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40552 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40553 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
40554 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
40555 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
40556 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
40557 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
40558 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
40559 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
40560 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
40561 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
40562 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
40563 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
40564 +4 4 4 4 4 4
40565 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40566 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40567 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
40568 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
40569 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
40570 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
40571 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
40572 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
40573 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
40574 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
40575 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
40576 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
40577 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
40578 +4 4 4 4 4 4
40579 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40580 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40581 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
40582 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
40583 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
40584 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
40585 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
40586 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
40587 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
40588 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
40589 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
40590 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
40591 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
40592 +4 4 4 4 4 4
40593 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40594 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40595 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
40596 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
40597 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
40598 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
40599 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
40600 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
40601 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
40602 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
40603 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
40604 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
40605 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
40606 +4 4 4 4 4 4
40607 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40608 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40609 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
40610 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
40611 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
40612 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
40613 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
40614 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
40615 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
40616 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
40617 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
40618 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
40619 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
40620 +4 4 4 4 4 4
40621 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40622 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
40623 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
40624 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
40625 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
40626 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
40627 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
40628 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
40629 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
40630 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
40631 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
40632 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
40633 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
40634 +4 4 4 4 4 4
40635 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40636 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
40637 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
40638 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
40639 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
40640 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
40641 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
40642 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
40643 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
40644 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
40645 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
40646 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
40647 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
40648 +0 0 0 4 4 4
40649 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
40650 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
40651 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
40652 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
40653 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
40654 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
40655 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
40656 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
40657 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
40658 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
40659 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
40660 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
40661 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
40662 +2 0 0 0 0 0
40663 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
40664 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
40665 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
40666 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
40667 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
40668 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
40669 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
40670 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
40671 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
40672 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
40673 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
40674 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
40675 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
40676 +37 38 37 0 0 0
40677 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
40678 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
40679 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
40680 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
40681 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
40682 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
40683 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
40684 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
40685 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
40686 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
40687 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
40688 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
40689 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
40690 +85 115 134 4 0 0
40691 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
40692 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
40693 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
40694 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
40695 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
40696 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
40697 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
40698 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
40699 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
40700 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
40701 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
40702 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
40703 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
40704 +60 73 81 4 0 0
40705 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
40706 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
40707 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
40708 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
40709 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
40710 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
40711 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
40712 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
40713 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
40714 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
40715 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
40716 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
40717 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
40718 +16 19 21 4 0 0
40719 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
40720 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
40721 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
40722 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
40723 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
40724 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
40725 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
40726 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
40727 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
40728 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
40729 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
40730 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
40731 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
40732 +4 0 0 4 3 3
40733 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
40734 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
40735 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
40736 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
40737 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
40738 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
40739 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
40740 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
40741 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
40742 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
40743 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
40744 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
40745 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
40746 +3 2 2 4 4 4
40747 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
40748 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
40749 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
40750 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
40751 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
40752 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
40753 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
40754 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
40755 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
40756 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
40757 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
40758 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
40759 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
40760 +4 4 4 4 4 4
40761 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
40762 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
40763 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
40764 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
40765 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
40766 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
40767 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
40768 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
40769 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
40770 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
40771 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
40772 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
40773 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
40774 +4 4 4 4 4 4
40775 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
40776 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
40777 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
40778 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
40779 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
40780 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
40781 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
40782 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
40783 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
40784 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
40785 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
40786 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
40787 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
40788 +5 5 5 5 5 5
40789 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
40790 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
40791 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
40792 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
40793 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
40794 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
40795 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
40796 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
40797 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
40798 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
40799 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
40800 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
40801 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
40802 +5 5 5 4 4 4
40803 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
40804 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
40805 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
40806 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
40807 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
40808 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
40809 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
40810 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
40811 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
40812 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
40813 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
40814 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
40815 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40816 +4 4 4 4 4 4
40817 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
40818 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
40819 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
40820 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
40821 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
40822 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
40823 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
40824 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
40825 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
40826 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
40827 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
40828 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
40829 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40830 +4 4 4 4 4 4
40831 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
40832 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
40833 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
40834 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
40835 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
40836 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
40837 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
40838 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
40839 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
40840 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
40841 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
40842 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40843 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40844 +4 4 4 4 4 4
40845 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
40846 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
40847 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
40848 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
40849 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
40850 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
40851 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
40852 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
40853 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
40854 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
40855 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
40856 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40857 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40858 +4 4 4 4 4 4
40859 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
40860 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
40861 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
40862 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
40863 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
40864 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
40865 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
40866 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
40867 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
40868 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
40869 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
40870 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40871 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40872 +4 4 4 4 4 4
40873 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
40874 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
40875 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
40876 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
40877 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
40878 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
40879 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
40880 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
40881 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
40882 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
40883 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
40884 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40885 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40886 +4 4 4 4 4 4
40887 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
40888 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
40889 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
40890 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
40891 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
40892 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
40893 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
40894 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
40895 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
40896 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
40897 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
40898 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40899 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40900 +4 4 4 4 4 4
40901 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
40902 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
40903 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
40904 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
40905 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
40906 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
40907 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
40908 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
40909 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
40910 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
40911 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
40912 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40913 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40914 +4 4 4 4 4 4
40915 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
40916 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
40917 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
40918 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
40919 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
40920 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
40921 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
40922 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
40923 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
40924 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
40925 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
40926 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40927 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40928 +4 4 4 4 4 4
40929 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
40930 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
40931 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
40932 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
40933 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
40934 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
40935 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
40936 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
40937 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
40938 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
40939 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
40940 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40941 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40942 +4 4 4 4 4 4
40943 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
40944 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
40945 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
40946 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
40947 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
40948 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
40949 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
40950 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
40951 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
40952 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
40953 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
40954 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40955 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40956 +4 4 4 4 4 4
40957 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
40958 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
40959 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
40960 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
40961 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
40962 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
40963 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
40964 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
40965 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
40966 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
40967 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
40968 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40969 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40970 +4 4 4 4 4 4
40971 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
40972 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
40973 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
40974 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
40975 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
40976 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
40977 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
40978 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
40979 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
40980 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
40981 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
40982 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40983 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40984 +4 4 4 4 4 4
40985 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
40986 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
40987 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
40988 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
40989 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
40990 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
40991 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
40992 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
40993 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
40994 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
40995 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
40996 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40997 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
40998 +4 4 4 4 4 4
40999 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
41000 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
41001 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
41002 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
41003 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
41004 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
41005 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
41006 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
41007 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
41008 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
41009 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41010 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41011 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41012 +4 4 4 4 4 4
41013 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
41014 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
41015 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
41016 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
41017 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
41018 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
41019 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
41020 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
41021 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
41022 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
41023 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41024 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41025 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41026 +4 4 4 4 4 4
41027 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
41028 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
41029 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
41030 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
41031 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
41032 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
41033 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
41034 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
41035 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
41036 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
41037 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41038 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41039 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41040 +4 4 4 4 4 4
41041 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
41042 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
41043 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
41044 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
41045 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
41046 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
41047 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
41048 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
41049 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
41050 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
41051 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41052 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41053 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41054 +4 4 4 4 4 4
41055 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
41056 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
41057 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
41058 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
41059 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
41060 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
41061 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
41062 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
41063 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
41064 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
41065 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41066 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41067 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41068 +4 4 4 4 4 4
41069 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
41070 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
41071 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
41072 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
41073 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
41074 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
41075 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
41076 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
41077 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
41078 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
41079 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41080 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41081 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41082 +4 4 4 4 4 4
41083 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
41084 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
41085 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
41086 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
41087 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
41088 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
41089 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
41090 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
41091 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
41092 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
41093 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41094 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41095 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41096 +4 4 4 4 4 4
41097 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
41098 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
41099 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
41100 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
41101 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
41102 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
41103 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
41104 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
41105 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
41106 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
41107 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41108 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41109 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41110 +4 4 4 4 4 4
41111 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
41112 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
41113 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
41114 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
41115 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
41116 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
41117 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
41118 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
41119 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
41120 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
41121 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41122 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41123 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41124 +4 4 4 4 4 4
41125 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
41126 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
41127 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
41128 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
41129 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
41130 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
41131 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
41132 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
41133 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
41134 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
41135 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41136 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41137 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41138 +4 4 4 4 4 4
41139 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
41140 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
41141 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
41142 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
41143 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
41144 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
41145 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
41146 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
41147 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
41148 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
41149 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41150 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41151 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41152 +4 4 4 4 4 4
41153 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
41154 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
41155 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
41156 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
41157 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
41158 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
41159 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
41160 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
41161 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
41162 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
41163 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41164 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41165 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41166 +4 4 4 4 4 4
41167 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
41168 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
41169 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
41170 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
41171 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
41172 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
41173 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
41174 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
41175 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
41176 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
41177 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41178 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41179 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41180 +4 4 4 4 4 4
41181 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
41182 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
41183 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
41184 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
41185 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
41186 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
41187 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41188 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
41189 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
41190 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
41191 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
41192 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41193 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41194 +4 4 4 4 4 4
41195 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
41196 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
41197 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
41198 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
41199 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
41200 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
41201 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
41202 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
41203 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
41204 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
41205 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41206 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41207 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41208 +4 4 4 4 4 4
41209 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
41210 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
41211 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
41212 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
41213 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
41214 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
41215 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
41216 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
41217 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
41218 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
41219 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41220 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41221 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41222 +4 4 4 4 4 4
41223 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
41224 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
41225 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
41226 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
41227 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
41228 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
41229 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
41230 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
41231 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
41232 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
41233 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41234 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41235 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41236 +4 4 4 4 4 4
41237 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
41238 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
41239 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
41240 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
41241 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
41242 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
41243 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
41244 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
41245 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
41246 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
41247 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41248 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41249 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41250 +4 4 4 4 4 4
41251 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
41252 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
41253 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
41254 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
41255 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
41256 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
41257 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
41258 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
41259 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
41260 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
41261 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41262 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41263 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41264 +4 4 4 4 4 4
41265 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
41266 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
41267 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
41268 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
41269 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
41270 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
41271 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
41272 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
41273 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
41274 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41275 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41276 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41277 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41278 +4 4 4 4 4 4
41279 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
41280 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
41281 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
41282 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
41283 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
41284 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
41285 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
41286 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
41287 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
41288 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41289 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41290 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41291 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41292 +4 4 4 4 4 4
41293 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
41294 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
41295 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
41296 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
41297 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
41298 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
41299 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
41300 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
41301 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41302 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41303 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41304 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41305 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41306 +4 4 4 4 4 4
41307 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
41308 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
41309 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
41310 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
41311 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
41312 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
41313 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
41314 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
41315 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41316 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41317 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41318 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41319 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41320 +4 4 4 4 4 4
41321 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
41322 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
41323 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
41324 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
41325 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
41326 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
41327 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
41328 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
41329 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41330 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41331 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41332 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41333 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41334 +4 4 4 4 4 4
41335 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
41336 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
41337 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
41338 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
41339 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
41340 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
41341 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
41342 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
41343 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41344 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41345 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41346 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41347 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41348 +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 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
41351 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
41352 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
41353 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
41354 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
41355 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
41356 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
41357 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41358 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41359 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41360 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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
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 5 5 5 5 5 5 5 5 5
41365 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
41366 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
41367 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
41368 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
41369 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
41370 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
41371 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41372 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41373 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41374 +4 4 4 4 4 4 4 4 4 4 4 4 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
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 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
41380 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
41381 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
41382 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
41383 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
41384 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
41385 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41386 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41387 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41388 +4 4 4 4 4 4 4 4 4 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
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 5 5 5
41394 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
41395 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
41396 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
41397 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
41398 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41399 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41400 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41401 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41402 +4 4 4 4 4 4 4 4 4 4 4 4 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
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 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
41409 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
41410 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
41411 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
41412 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41413 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41414 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41415 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41416 +4 4 4 4 4 4 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
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 5 5 5 4 3 3 5 5 5 6 6 6
41423 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
41424 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
41425 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
41426 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41427 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41428 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41429 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41430 +4 4 4 4 4 4 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
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 4 4 4 5 5 5 4 3 3 5 5 5
41437 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
41438 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
41439 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
41440 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41441 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41442 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41443 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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
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 4 4 4 4 4 4 4 4 4 5 5 5
41451 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
41452 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
41453 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
41454 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41455 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41456 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41457 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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
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 4 4 4 4 4 4 4 4 4 4 4 4
41465 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
41466 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
41467 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
41468 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41469 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41470 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41471 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 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
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 4 4 4 4 4 4 4 4 4 4 4 4
41479 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
41480 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
41481 +5 5 5 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 4 4 4 4 4 4 4 4 4
41483 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41484 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41485 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 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
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 4 4 4 4 4 4 4 4 4 4 4 4
41493 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
41494 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
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 4 4 4
41497 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41498 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41499 +4 4 4 4 4 4 4 4 4 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
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 4 4 4 4 4 4 4 4 4 4 4 4
41507 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
41508 +5 5 5 4 3 3 5 5 5 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41512 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
41513 +4 4 4 4 4 4 4 4 4 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
41517 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
41518 index a40c05e..785c583 100644
41519 --- a/drivers/video/udlfb.c
41520 +++ b/drivers/video/udlfb.c
41521 @@ -619,11 +619,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
41522 dlfb_urb_completion(urb);
41523
41524 error:
41525 - atomic_add(bytes_sent, &dev->bytes_sent);
41526 - atomic_add(bytes_identical, &dev->bytes_identical);
41527 - atomic_add(width*height*2, &dev->bytes_rendered);
41528 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
41529 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
41530 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
41531 end_cycles = get_cycles();
41532 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
41533 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
41534 >> 10)), /* Kcycles */
41535 &dev->cpu_kcycles_used);
41536
41537 @@ -744,11 +744,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
41538 dlfb_urb_completion(urb);
41539
41540 error:
41541 - atomic_add(bytes_sent, &dev->bytes_sent);
41542 - atomic_add(bytes_identical, &dev->bytes_identical);
41543 - atomic_add(bytes_rendered, &dev->bytes_rendered);
41544 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
41545 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
41546 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
41547 end_cycles = get_cycles();
41548 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
41549 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
41550 >> 10)), /* Kcycles */
41551 &dev->cpu_kcycles_used);
41552 }
41553 @@ -1368,7 +1368,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
41554 struct fb_info *fb_info = dev_get_drvdata(fbdev);
41555 struct dlfb_data *dev = fb_info->par;
41556 return snprintf(buf, PAGE_SIZE, "%u\n",
41557 - atomic_read(&dev->bytes_rendered));
41558 + atomic_read_unchecked(&dev->bytes_rendered));
41559 }
41560
41561 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
41562 @@ -1376,7 +1376,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
41563 struct fb_info *fb_info = dev_get_drvdata(fbdev);
41564 struct dlfb_data *dev = fb_info->par;
41565 return snprintf(buf, PAGE_SIZE, "%u\n",
41566 - atomic_read(&dev->bytes_identical));
41567 + atomic_read_unchecked(&dev->bytes_identical));
41568 }
41569
41570 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
41571 @@ -1384,7 +1384,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
41572 struct fb_info *fb_info = dev_get_drvdata(fbdev);
41573 struct dlfb_data *dev = fb_info->par;
41574 return snprintf(buf, PAGE_SIZE, "%u\n",
41575 - atomic_read(&dev->bytes_sent));
41576 + atomic_read_unchecked(&dev->bytes_sent));
41577 }
41578
41579 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
41580 @@ -1392,7 +1392,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
41581 struct fb_info *fb_info = dev_get_drvdata(fbdev);
41582 struct dlfb_data *dev = fb_info->par;
41583 return snprintf(buf, PAGE_SIZE, "%u\n",
41584 - atomic_read(&dev->cpu_kcycles_used));
41585 + atomic_read_unchecked(&dev->cpu_kcycles_used));
41586 }
41587
41588 static ssize_t edid_show(
41589 @@ -1449,10 +1449,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
41590 struct fb_info *fb_info = dev_get_drvdata(fbdev);
41591 struct dlfb_data *dev = fb_info->par;
41592
41593 - atomic_set(&dev->bytes_rendered, 0);
41594 - atomic_set(&dev->bytes_identical, 0);
41595 - atomic_set(&dev->bytes_sent, 0);
41596 - atomic_set(&dev->cpu_kcycles_used, 0);
41597 + atomic_set_unchecked(&dev->bytes_rendered, 0);
41598 + atomic_set_unchecked(&dev->bytes_identical, 0);
41599 + atomic_set_unchecked(&dev->bytes_sent, 0);
41600 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
41601
41602 return count;
41603 }
41604 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
41605 index 8408543..d6f20f1 100644
41606 --- a/drivers/video/uvesafb.c
41607 +++ b/drivers/video/uvesafb.c
41608 @@ -19,6 +19,7 @@
41609 #include <linux/io.h>
41610 #include <linux/mutex.h>
41611 #include <linux/slab.h>
41612 +#include <linux/moduleloader.h>
41613 #include <video/edid.h>
41614 #include <video/uvesafb.h>
41615 #ifdef CONFIG_X86
41616 @@ -73,7 +74,7 @@ static void uvesafb_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *ns
41617 struct uvesafb_task *utask;
41618 struct uvesafb_ktask *task;
41619
41620 - if (!cap_raised(current_cap(), CAP_SYS_ADMIN))
41621 + if (!capable(CAP_SYS_ADMIN))
41622 return;
41623
41624 if (msg->seq >= UVESAFB_TASKS_MAX)
41625 @@ -121,7 +122,7 @@ static int uvesafb_helper_start(void)
41626 NULL,
41627 };
41628
41629 - return call_usermodehelper(v86d_path, argv, envp, 1);
41630 + return call_usermodehelper(v86d_path, argv, envp, UMH_WAIT_PROC);
41631 }
41632
41633 /*
41634 @@ -569,10 +570,32 @@ static int __devinit uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
41635 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
41636 par->pmi_setpal = par->ypan = 0;
41637 } else {
41638 +
41639 +#ifdef CONFIG_PAX_KERNEXEC
41640 +#ifdef CONFIG_MODULES
41641 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
41642 +#endif
41643 + if (!par->pmi_code) {
41644 + par->pmi_setpal = par->ypan = 0;
41645 + return 0;
41646 + }
41647 +#endif
41648 +
41649 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
41650 + task->t.regs.edi);
41651 +
41652 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
41653 + pax_open_kernel();
41654 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
41655 + pax_close_kernel();
41656 +
41657 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
41658 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
41659 +#else
41660 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
41661 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
41662 +#endif
41663 +
41664 printk(KERN_INFO "uvesafb: protected mode interface info at "
41665 "%04x:%04x\n",
41666 (u16)task->t.regs.es, (u16)task->t.regs.edi);
41667 @@ -816,13 +839,14 @@ static int __devinit uvesafb_vbe_init(struct fb_info *info)
41668 par->ypan = ypan;
41669
41670 if (par->pmi_setpal || par->ypan) {
41671 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
41672 if (__supported_pte_mask & _PAGE_NX) {
41673 par->pmi_setpal = par->ypan = 0;
41674 printk(KERN_WARNING "uvesafb: NX protection is actively."
41675 "We have better not to use the PMI.\n");
41676 - } else {
41677 + } else
41678 +#endif
41679 uvesafb_vbe_getpmi(task, par);
41680 - }
41681 }
41682 #else
41683 /* The protected mode interface is not available on non-x86. */
41684 @@ -1828,6 +1852,11 @@ out:
41685 if (par->vbe_modes)
41686 kfree(par->vbe_modes);
41687
41688 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
41689 + if (par->pmi_code)
41690 + module_free_exec(NULL, par->pmi_code);
41691 +#endif
41692 +
41693 framebuffer_release(info);
41694 return err;
41695 }
41696 @@ -1854,6 +1883,12 @@ static int uvesafb_remove(struct platform_device *dev)
41697 kfree(par->vbe_state_orig);
41698 if (par->vbe_state_saved)
41699 kfree(par->vbe_state_saved);
41700 +
41701 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
41702 + if (par->pmi_code)
41703 + module_free_exec(NULL, par->pmi_code);
41704 +#endif
41705 +
41706 }
41707
41708 framebuffer_release(info);
41709 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
41710 index 501b340..86bd4cf 100644
41711 --- a/drivers/video/vesafb.c
41712 +++ b/drivers/video/vesafb.c
41713 @@ -9,6 +9,7 @@
41714 */
41715
41716 #include <linux/module.h>
41717 +#include <linux/moduleloader.h>
41718 #include <linux/kernel.h>
41719 #include <linux/errno.h>
41720 #include <linux/string.h>
41721 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
41722 static int vram_total __initdata; /* Set total amount of memory */
41723 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
41724 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
41725 -static void (*pmi_start)(void) __read_mostly;
41726 -static void (*pmi_pal) (void) __read_mostly;
41727 +static void (*pmi_start)(void) __read_only;
41728 +static void (*pmi_pal) (void) __read_only;
41729 static int depth __read_mostly;
41730 static int vga_compat __read_mostly;
41731 /* --------------------------------------------------------------------- */
41732 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
41733 unsigned int size_vmode;
41734 unsigned int size_remap;
41735 unsigned int size_total;
41736 + void *pmi_code = NULL;
41737
41738 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
41739 return -ENODEV;
41740 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
41741 size_remap = size_total;
41742 vesafb_fix.smem_len = size_remap;
41743
41744 -#ifndef __i386__
41745 - screen_info.vesapm_seg = 0;
41746 -#endif
41747 -
41748 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
41749 printk(KERN_WARNING
41750 "vesafb: cannot reserve video memory at 0x%lx\n",
41751 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
41752 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
41753 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
41754
41755 +#ifdef __i386__
41756 +
41757 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
41758 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
41759 + if (!pmi_code)
41760 +#elif !defined(CONFIG_PAX_KERNEXEC)
41761 + if (0)
41762 +#endif
41763 +
41764 +#endif
41765 + screen_info.vesapm_seg = 0;
41766 +
41767 if (screen_info.vesapm_seg) {
41768 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
41769 - screen_info.vesapm_seg,screen_info.vesapm_off);
41770 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
41771 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
41772 }
41773
41774 if (screen_info.vesapm_seg < 0xc000)
41775 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
41776
41777 if (ypan || pmi_setpal) {
41778 unsigned short *pmi_base;
41779 +
41780 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
41781 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
41782 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
41783 +
41784 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
41785 + pax_open_kernel();
41786 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
41787 +#else
41788 + pmi_code = pmi_base;
41789 +#endif
41790 +
41791 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
41792 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
41793 +
41794 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
41795 + pmi_start = ktva_ktla(pmi_start);
41796 + pmi_pal = ktva_ktla(pmi_pal);
41797 + pax_close_kernel();
41798 +#endif
41799 +
41800 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
41801 if (pmi_base[3]) {
41802 printk(KERN_INFO "vesafb: pmi: ports = ");
41803 @@ -488,6 +514,11 @@ static int __init vesafb_probe(struct platform_device *dev)
41804 info->node, info->fix.id);
41805 return 0;
41806 err:
41807 +
41808 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
41809 + module_free_exec(NULL, pmi_code);
41810 +#endif
41811 +
41812 if (info->screen_base)
41813 iounmap(info->screen_base);
41814 framebuffer_release(info);
41815 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
41816 index 88714ae..16c2e11 100644
41817 --- a/drivers/video/via/via_clock.h
41818 +++ b/drivers/video/via/via_clock.h
41819 @@ -56,7 +56,7 @@ struct via_clock {
41820
41821 void (*set_engine_pll_state)(u8 state);
41822 void (*set_engine_pll)(struct via_pll_config config);
41823 -};
41824 +} __no_const;
41825
41826
41827 static inline u32 get_pll_internal_frequency(u32 ref_freq,
41828 diff --git a/drivers/xen/xen-pciback/conf_space.h b/drivers/xen/xen-pciback/conf_space.h
41829 index e56c934..fc22f4b 100644
41830 --- a/drivers/xen/xen-pciback/conf_space.h
41831 +++ b/drivers/xen/xen-pciback/conf_space.h
41832 @@ -44,15 +44,15 @@ struct config_field {
41833 struct {
41834 conf_dword_write write;
41835 conf_dword_read read;
41836 - } dw;
41837 + } __no_const dw;
41838 struct {
41839 conf_word_write write;
41840 conf_word_read read;
41841 - } w;
41842 + } __no_const w;
41843 struct {
41844 conf_byte_write write;
41845 conf_byte_read read;
41846 - } b;
41847 + } __no_const b;
41848 } u;
41849 struct list_head list;
41850 };
41851 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
41852 index 014c8dd..6f3dfe6 100644
41853 --- a/fs/9p/vfs_inode.c
41854 +++ b/fs/9p/vfs_inode.c
41855 @@ -1303,7 +1303,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
41856 void
41857 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
41858 {
41859 - char *s = nd_get_link(nd);
41860 + const char *s = nd_get_link(nd);
41861
41862 p9_debug(P9_DEBUG_VFS, " %s %s\n",
41863 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
41864 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
41865 index e95d1b6..3454244 100644
41866 --- a/fs/Kconfig.binfmt
41867 +++ b/fs/Kconfig.binfmt
41868 @@ -89,7 +89,7 @@ config HAVE_AOUT
41869
41870 config BINFMT_AOUT
41871 tristate "Kernel support for a.out and ECOFF binaries"
41872 - depends on HAVE_AOUT
41873 + depends on HAVE_AOUT && BROKEN
41874 ---help---
41875 A.out (Assembler.OUTput) is a set of formats for libraries and
41876 executables used in the earliest versions of UNIX. Linux used
41877 diff --git a/fs/aio.c b/fs/aio.c
41878 index b9d64d8..86cb1d5 100644
41879 --- a/fs/aio.c
41880 +++ b/fs/aio.c
41881 @@ -119,7 +119,7 @@ static int aio_setup_ring(struct kioctx *ctx)
41882 size += sizeof(struct io_event) * nr_events;
41883 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
41884
41885 - if (nr_pages < 0)
41886 + if (nr_pages <= 0)
41887 return -EINVAL;
41888
41889 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
41890 @@ -1461,22 +1461,27 @@ static ssize_t aio_fsync(struct kiocb *iocb)
41891 static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
41892 {
41893 ssize_t ret;
41894 + struct iovec iovstack;
41895
41896 #ifdef CONFIG_COMPAT
41897 if (compat)
41898 ret = compat_rw_copy_check_uvector(type,
41899 (struct compat_iovec __user *)kiocb->ki_buf,
41900 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
41901 + kiocb->ki_nbytes, 1, &iovstack,
41902 &kiocb->ki_iovec, 1);
41903 else
41904 #endif
41905 ret = rw_copy_check_uvector(type,
41906 (struct iovec __user *)kiocb->ki_buf,
41907 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
41908 + kiocb->ki_nbytes, 1, &iovstack,
41909 &kiocb->ki_iovec, 1);
41910 if (ret < 0)
41911 goto out;
41912
41913 + if (kiocb->ki_iovec == &iovstack) {
41914 + kiocb->ki_inline_vec = iovstack;
41915 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
41916 + }
41917 kiocb->ki_nr_segs = kiocb->ki_nbytes;
41918 kiocb->ki_cur_seg = 0;
41919 /* ki_nbytes/left now reflect bytes instead of segs */
41920 diff --git a/fs/attr.c b/fs/attr.c
41921 index 95053ad..2cc93ca 100644
41922 --- a/fs/attr.c
41923 +++ b/fs/attr.c
41924 @@ -99,6 +99,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
41925 unsigned long limit;
41926
41927 limit = rlimit(RLIMIT_FSIZE);
41928 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
41929 if (limit != RLIM_INFINITY && offset > limit)
41930 goto out_sig;
41931 if (offset > inode->i_sb->s_maxbytes)
41932 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
41933 index f624cd0..3d9a559 100644
41934 --- a/fs/autofs4/waitq.c
41935 +++ b/fs/autofs4/waitq.c
41936 @@ -61,7 +61,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
41937 {
41938 unsigned long sigpipe, flags;
41939 mm_segment_t fs;
41940 - const char *data = (const char *)addr;
41941 + const char __user *data = (const char __force_user *)addr;
41942 ssize_t wr = 0;
41943
41944 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
41945 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
41946 index 6e6d536..457113a 100644
41947 --- a/fs/befs/linuxvfs.c
41948 +++ b/fs/befs/linuxvfs.c
41949 @@ -502,7 +502,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
41950 {
41951 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
41952 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
41953 - char *link = nd_get_link(nd);
41954 + const char *link = nd_get_link(nd);
41955 if (!IS_ERR(link))
41956 kfree(link);
41957 }
41958 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
41959 index 1ff9405..f1e376a 100644
41960 --- a/fs/binfmt_aout.c
41961 +++ b/fs/binfmt_aout.c
41962 @@ -16,6 +16,7 @@
41963 #include <linux/string.h>
41964 #include <linux/fs.h>
41965 #include <linux/file.h>
41966 +#include <linux/security.h>
41967 #include <linux/stat.h>
41968 #include <linux/fcntl.h>
41969 #include <linux/ptrace.h>
41970 @@ -86,6 +87,8 @@ static int aout_core_dump(struct coredump_params *cprm)
41971 #endif
41972 # define START_STACK(u) ((void __user *)u.start_stack)
41973
41974 + memset(&dump, 0, sizeof(dump));
41975 +
41976 fs = get_fs();
41977 set_fs(KERNEL_DS);
41978 has_dumped = 1;
41979 @@ -97,10 +100,12 @@ static int aout_core_dump(struct coredump_params *cprm)
41980
41981 /* If the size of the dump file exceeds the rlimit, then see what would happen
41982 if we wrote the stack, but not the data area. */
41983 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
41984 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
41985 dump.u_dsize = 0;
41986
41987 /* Make sure we have enough room to write the stack and data areas. */
41988 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
41989 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
41990 dump.u_ssize = 0;
41991
41992 @@ -234,6 +239,8 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
41993 rlim = rlimit(RLIMIT_DATA);
41994 if (rlim >= RLIM_INFINITY)
41995 rlim = ~0;
41996 +
41997 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
41998 if (ex.a_data + ex.a_bss > rlim)
41999 return -ENOMEM;
42000
42001 @@ -269,6 +276,27 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
42002 install_exec_creds(bprm);
42003 current->flags &= ~PF_FORKNOEXEC;
42004
42005 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
42006 + current->mm->pax_flags = 0UL;
42007 +#endif
42008 +
42009 +#ifdef CONFIG_PAX_PAGEEXEC
42010 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
42011 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
42012 +
42013 +#ifdef CONFIG_PAX_EMUTRAMP
42014 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
42015 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
42016 +#endif
42017 +
42018 +#ifdef CONFIG_PAX_MPROTECT
42019 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
42020 + current->mm->pax_flags |= MF_PAX_MPROTECT;
42021 +#endif
42022 +
42023 + }
42024 +#endif
42025 +
42026 if (N_MAGIC(ex) == OMAGIC) {
42027 unsigned long text_addr, map_size;
42028 loff_t pos;
42029 @@ -341,7 +369,7 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
42030
42031 down_write(&current->mm->mmap_sem);
42032 error = do_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
42033 - PROT_READ | PROT_WRITE | PROT_EXEC,
42034 + PROT_READ | PROT_WRITE,
42035 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
42036 fd_offset + ex.a_text);
42037 up_write(&current->mm->mmap_sem);
42038 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
42039 index 07d096c..25762af 100644
42040 --- a/fs/binfmt_elf.c
42041 +++ b/fs/binfmt_elf.c
42042 @@ -32,6 +32,7 @@
42043 #include <linux/elf.h>
42044 #include <linux/utsname.h>
42045 #include <linux/coredump.h>
42046 +#include <linux/xattr.h>
42047 #include <asm/uaccess.h>
42048 #include <asm/param.h>
42049 #include <asm/page.h>
42050 @@ -51,6 +52,10 @@ static int elf_core_dump(struct coredump_params *cprm);
42051 #define elf_core_dump NULL
42052 #endif
42053
42054 +#ifdef CONFIG_PAX_MPROTECT
42055 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
42056 +#endif
42057 +
42058 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
42059 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
42060 #else
42061 @@ -70,6 +75,11 @@ static struct linux_binfmt elf_format = {
42062 .load_binary = load_elf_binary,
42063 .load_shlib = load_elf_library,
42064 .core_dump = elf_core_dump,
42065 +
42066 +#ifdef CONFIG_PAX_MPROTECT
42067 + .handle_mprotect= elf_handle_mprotect,
42068 +#endif
42069 +
42070 .min_coredump = ELF_EXEC_PAGESIZE,
42071 };
42072
42073 @@ -77,6 +87,8 @@ static struct linux_binfmt elf_format = {
42074
42075 static int set_brk(unsigned long start, unsigned long end)
42076 {
42077 + unsigned long e = end;
42078 +
42079 start = ELF_PAGEALIGN(start);
42080 end = ELF_PAGEALIGN(end);
42081 if (end > start) {
42082 @@ -87,7 +99,7 @@ static int set_brk(unsigned long start, unsigned long end)
42083 if (BAD_ADDR(addr))
42084 return addr;
42085 }
42086 - current->mm->start_brk = current->mm->brk = end;
42087 + current->mm->start_brk = current->mm->brk = e;
42088 return 0;
42089 }
42090
42091 @@ -148,12 +160,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
42092 elf_addr_t __user *u_rand_bytes;
42093 const char *k_platform = ELF_PLATFORM;
42094 const char *k_base_platform = ELF_BASE_PLATFORM;
42095 - unsigned char k_rand_bytes[16];
42096 + u32 k_rand_bytes[4];
42097 int items;
42098 elf_addr_t *elf_info;
42099 int ei_index = 0;
42100 const struct cred *cred = current_cred();
42101 struct vm_area_struct *vma;
42102 + unsigned long saved_auxv[AT_VECTOR_SIZE];
42103
42104 /*
42105 * In some cases (e.g. Hyper-Threading), we want to avoid L1
42106 @@ -195,8 +208,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
42107 * Generate 16 random bytes for userspace PRNG seeding.
42108 */
42109 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
42110 - u_rand_bytes = (elf_addr_t __user *)
42111 - STACK_ALLOC(p, sizeof(k_rand_bytes));
42112 + srandom32(k_rand_bytes[0] ^ random32());
42113 + srandom32(k_rand_bytes[1] ^ random32());
42114 + srandom32(k_rand_bytes[2] ^ random32());
42115 + srandom32(k_rand_bytes[3] ^ random32());
42116 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
42117 + u_rand_bytes = (elf_addr_t __user *) p;
42118 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
42119 return -EFAULT;
42120
42121 @@ -308,9 +325,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
42122 return -EFAULT;
42123 current->mm->env_end = p;
42124
42125 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
42126 +
42127 /* Put the elf_info on the stack in the right place. */
42128 sp = (elf_addr_t __user *)envp + 1;
42129 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
42130 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
42131 return -EFAULT;
42132 return 0;
42133 }
42134 @@ -381,10 +400,10 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
42135 {
42136 struct elf_phdr *elf_phdata;
42137 struct elf_phdr *eppnt;
42138 - unsigned long load_addr = 0;
42139 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
42140 int load_addr_set = 0;
42141 unsigned long last_bss = 0, elf_bss = 0;
42142 - unsigned long error = ~0UL;
42143 + unsigned long error = -EINVAL;
42144 unsigned long total_size;
42145 int retval, i, size;
42146
42147 @@ -430,6 +449,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
42148 goto out_close;
42149 }
42150
42151 +#ifdef CONFIG_PAX_SEGMEXEC
42152 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
42153 + pax_task_size = SEGMEXEC_TASK_SIZE;
42154 +#endif
42155 +
42156 eppnt = elf_phdata;
42157 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
42158 if (eppnt->p_type == PT_LOAD) {
42159 @@ -473,8 +497,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
42160 k = load_addr + eppnt->p_vaddr;
42161 if (BAD_ADDR(k) ||
42162 eppnt->p_filesz > eppnt->p_memsz ||
42163 - eppnt->p_memsz > TASK_SIZE ||
42164 - TASK_SIZE - eppnt->p_memsz < k) {
42165 + eppnt->p_memsz > pax_task_size ||
42166 + pax_task_size - eppnt->p_memsz < k) {
42167 error = -ENOMEM;
42168 goto out_close;
42169 }
42170 @@ -528,6 +552,351 @@ out:
42171 return error;
42172 }
42173
42174 +#if defined(CONFIG_PAX_EI_PAX) || defined(CONFIG_PAX_PT_PAX_FLAGS) || defined(CONFIG_PAX_XATTR_PAX_FLAGS)
42175 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
42176 +{
42177 + unsigned long pax_flags = 0UL;
42178 +
42179 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
42180 +
42181 +#ifdef CONFIG_PAX_PAGEEXEC
42182 + if (elf_phdata->p_flags & PF_PAGEEXEC)
42183 + pax_flags |= MF_PAX_PAGEEXEC;
42184 +#endif
42185 +
42186 +#ifdef CONFIG_PAX_SEGMEXEC
42187 + if (elf_phdata->p_flags & PF_SEGMEXEC)
42188 + pax_flags |= MF_PAX_SEGMEXEC;
42189 +#endif
42190 +
42191 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
42192 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
42193 + if ((__supported_pte_mask & _PAGE_NX))
42194 + pax_flags &= ~MF_PAX_SEGMEXEC;
42195 + else
42196 + pax_flags &= ~MF_PAX_PAGEEXEC;
42197 + }
42198 +#endif
42199 +
42200 +#ifdef CONFIG_PAX_EMUTRAMP
42201 + if (elf_phdata->p_flags & PF_EMUTRAMP)
42202 + pax_flags |= MF_PAX_EMUTRAMP;
42203 +#endif
42204 +
42205 +#ifdef CONFIG_PAX_MPROTECT
42206 + if (elf_phdata->p_flags & PF_MPROTECT)
42207 + pax_flags |= MF_PAX_MPROTECT;
42208 +#endif
42209 +
42210 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
42211 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
42212 + pax_flags |= MF_PAX_RANDMMAP;
42213 +#endif
42214 +
42215 +#endif
42216 +
42217 + return pax_flags;
42218 +}
42219 +
42220 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
42221 +{
42222 + unsigned long pax_flags = 0UL;
42223 +
42224 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
42225 +
42226 +#ifdef CONFIG_PAX_PAGEEXEC
42227 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
42228 + pax_flags |= MF_PAX_PAGEEXEC;
42229 +#endif
42230 +
42231 +#ifdef CONFIG_PAX_SEGMEXEC
42232 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
42233 + pax_flags |= MF_PAX_SEGMEXEC;
42234 +#endif
42235 +
42236 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
42237 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
42238 + if ((__supported_pte_mask & _PAGE_NX))
42239 + pax_flags &= ~MF_PAX_SEGMEXEC;
42240 + else
42241 + pax_flags &= ~MF_PAX_PAGEEXEC;
42242 + }
42243 +#endif
42244 +
42245 +#ifdef CONFIG_PAX_EMUTRAMP
42246 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
42247 + pax_flags |= MF_PAX_EMUTRAMP;
42248 +#endif
42249 +
42250 +#ifdef CONFIG_PAX_MPROTECT
42251 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
42252 + pax_flags |= MF_PAX_MPROTECT;
42253 +#endif
42254 +
42255 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
42256 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
42257 + pax_flags |= MF_PAX_RANDMMAP;
42258 +#endif
42259 +
42260 +#endif
42261 +
42262 + return pax_flags;
42263 +}
42264 +
42265 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
42266 +{
42267 + unsigned long pax_flags = 0UL;
42268 +
42269 +#ifdef CONFIG_PAX_EI_PAX
42270 +
42271 +#ifdef CONFIG_PAX_PAGEEXEC
42272 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
42273 + pax_flags |= MF_PAX_PAGEEXEC;
42274 +#endif
42275 +
42276 +#ifdef CONFIG_PAX_SEGMEXEC
42277 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
42278 + pax_flags |= MF_PAX_SEGMEXEC;
42279 +#endif
42280 +
42281 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
42282 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
42283 + if ((__supported_pte_mask & _PAGE_NX))
42284 + pax_flags &= ~MF_PAX_SEGMEXEC;
42285 + else
42286 + pax_flags &= ~MF_PAX_PAGEEXEC;
42287 + }
42288 +#endif
42289 +
42290 +#ifdef CONFIG_PAX_EMUTRAMP
42291 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
42292 + pax_flags |= MF_PAX_EMUTRAMP;
42293 +#endif
42294 +
42295 +#ifdef CONFIG_PAX_MPROTECT
42296 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
42297 + pax_flags |= MF_PAX_MPROTECT;
42298 +#endif
42299 +
42300 +#ifdef CONFIG_PAX_ASLR
42301 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
42302 + pax_flags |= MF_PAX_RANDMMAP;
42303 +#endif
42304 +
42305 +#else
42306 +
42307 +#ifdef CONFIG_PAX_PAGEEXEC
42308 + pax_flags |= MF_PAX_PAGEEXEC;
42309 +#endif
42310 +
42311 +#ifdef CONFIG_PAX_MPROTECT
42312 + pax_flags |= MF_PAX_MPROTECT;
42313 +#endif
42314 +
42315 +#ifdef CONFIG_PAX_RANDMMAP
42316 + pax_flags |= MF_PAX_RANDMMAP;
42317 +#endif
42318 +
42319 +#ifdef CONFIG_PAX_SEGMEXEC
42320 + if (!(pax_flags & MF_PAX_PAGEEXEC) || !(__supported_pte_mask & _PAGE_NX)) {
42321 + pax_flags &= ~MF_PAX_PAGEEXEC;
42322 + pax_flags |= MF_PAX_SEGMEXEC;
42323 + }
42324 +#endif
42325 +
42326 +#endif
42327 +
42328 + return pax_flags;
42329 +}
42330 +
42331 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
42332 +{
42333 +
42334 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
42335 + unsigned long i;
42336 +
42337 + for (i = 0UL; i < elf_ex->e_phnum; i++)
42338 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
42339 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
42340 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
42341 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
42342 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
42343 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
42344 + return ~0UL;
42345 +
42346 +#ifdef CONFIG_PAX_SOFTMODE
42347 + if (pax_softmode)
42348 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
42349 + else
42350 +#endif
42351 +
42352 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
42353 + break;
42354 + }
42355 +#endif
42356 +
42357 + return ~0UL;
42358 +}
42359 +
42360 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
42361 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
42362 +{
42363 + unsigned long pax_flags = 0UL;
42364 +
42365 +#ifdef CONFIG_PAX_PAGEEXEC
42366 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
42367 + pax_flags |= MF_PAX_PAGEEXEC;
42368 +#endif
42369 +
42370 +#ifdef CONFIG_PAX_SEGMEXEC
42371 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
42372 + pax_flags |= MF_PAX_SEGMEXEC;
42373 +#endif
42374 +
42375 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
42376 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
42377 + if ((__supported_pte_mask & _PAGE_NX))
42378 + pax_flags &= ~MF_PAX_SEGMEXEC;
42379 + else
42380 + pax_flags &= ~MF_PAX_PAGEEXEC;
42381 + }
42382 +#endif
42383 +
42384 +#ifdef CONFIG_PAX_EMUTRAMP
42385 + if (pax_flags_softmode & MF_PAX_EMUTRAMP)
42386 + pax_flags |= MF_PAX_EMUTRAMP;
42387 +#endif
42388 +
42389 +#ifdef CONFIG_PAX_MPROTECT
42390 + if (pax_flags_softmode & MF_PAX_MPROTECT)
42391 + pax_flags |= MF_PAX_MPROTECT;
42392 +#endif
42393 +
42394 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
42395 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
42396 + pax_flags |= MF_PAX_RANDMMAP;
42397 +#endif
42398 +
42399 + return pax_flags;
42400 +}
42401 +
42402 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
42403 +{
42404 + unsigned long pax_flags = 0UL;
42405 +
42406 +#ifdef CONFIG_PAX_PAGEEXEC
42407 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
42408 + pax_flags |= MF_PAX_PAGEEXEC;
42409 +#endif
42410 +
42411 +#ifdef CONFIG_PAX_SEGMEXEC
42412 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
42413 + pax_flags |= MF_PAX_SEGMEXEC;
42414 +#endif
42415 +
42416 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
42417 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
42418 + if ((__supported_pte_mask & _PAGE_NX))
42419 + pax_flags &= ~MF_PAX_SEGMEXEC;
42420 + else
42421 + pax_flags &= ~MF_PAX_PAGEEXEC;
42422 + }
42423 +#endif
42424 +
42425 +#ifdef CONFIG_PAX_EMUTRAMP
42426 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
42427 + pax_flags |= MF_PAX_EMUTRAMP;
42428 +#endif
42429 +
42430 +#ifdef CONFIG_PAX_MPROTECT
42431 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
42432 + pax_flags |= MF_PAX_MPROTECT;
42433 +#endif
42434 +
42435 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
42436 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
42437 + pax_flags |= MF_PAX_RANDMMAP;
42438 +#endif
42439 +
42440 + return pax_flags;
42441 +}
42442 +#endif
42443 +
42444 +static unsigned long pax_parse_xattr_pax(struct file * const file)
42445 +{
42446 +
42447 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
42448 + ssize_t xattr_size, i;
42449 + unsigned char xattr_value[5];
42450 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
42451 +
42452 + xattr_size = vfs_getxattr(file->f_path.dentry, XATTR_NAME_PAX_FLAGS, xattr_value, sizeof xattr_value);
42453 + if (xattr_size <= 0)
42454 + return ~0UL;
42455 +
42456 + for (i = 0; i < xattr_size; i++)
42457 + switch (xattr_value[i]) {
42458 + default:
42459 + return ~0UL;
42460 +
42461 +#define parse_flag(option1, option2, flag) \
42462 + case option1: \
42463 + pax_flags_hardmode |= MF_PAX_##flag; \
42464 + break; \
42465 + case option2: \
42466 + pax_flags_softmode |= MF_PAX_##flag; \
42467 + break;
42468 +
42469 + parse_flag('p', 'P', PAGEEXEC);
42470 + parse_flag('e', 'E', EMUTRAMP);
42471 + parse_flag('m', 'M', MPROTECT);
42472 + parse_flag('r', 'R', RANDMMAP);
42473 + parse_flag('s', 'S', SEGMEXEC);
42474 +
42475 +#undef parse_flag
42476 + }
42477 +
42478 + if (pax_flags_hardmode & pax_flags_softmode)
42479 + return ~0UL;
42480 +
42481 +#ifdef CONFIG_PAX_SOFTMODE
42482 + if (pax_softmode)
42483 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
42484 + else
42485 +#endif
42486 +
42487 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
42488 +#else
42489 + return ~0UL;
42490 +#endif
42491 +
42492 +}
42493 +
42494 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
42495 +{
42496 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
42497 +
42498 + pax_flags = pax_parse_ei_pax(elf_ex);
42499 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
42500 + xattr_pax_flags = pax_parse_xattr_pax(file);
42501 +
42502 + if (pt_pax_flags == ~0UL)
42503 + pt_pax_flags = xattr_pax_flags;
42504 + else if (xattr_pax_flags == ~0UL)
42505 + xattr_pax_flags = pt_pax_flags;
42506 + if (pt_pax_flags != xattr_pax_flags)
42507 + return -EINVAL;
42508 + if (pt_pax_flags != ~0UL)
42509 + pax_flags = pt_pax_flags;
42510 +
42511 + if (0 > pax_check_flags(&pax_flags))
42512 + return -EINVAL;
42513 +
42514 + current->mm->pax_flags = pax_flags;
42515 + return 0;
42516 +}
42517 +#endif
42518 +
42519 /*
42520 * These are the functions used to load ELF style executables and shared
42521 * libraries. There is no binary dependent code anywhere else.
42522 @@ -544,6 +913,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
42523 {
42524 unsigned int random_variable = 0;
42525
42526 +#ifdef CONFIG_PAX_RANDUSTACK
42527 + if (randomize_va_space)
42528 + return stack_top - current->mm->delta_stack;
42529 +#endif
42530 +
42531 if ((current->flags & PF_RANDOMIZE) &&
42532 !(current->personality & ADDR_NO_RANDOMIZE)) {
42533 random_variable = get_random_int() & STACK_RND_MASK;
42534 @@ -562,7 +936,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
42535 unsigned long load_addr = 0, load_bias = 0;
42536 int load_addr_set = 0;
42537 char * elf_interpreter = NULL;
42538 - unsigned long error;
42539 + unsigned long error = 0;
42540 struct elf_phdr *elf_ppnt, *elf_phdata;
42541 unsigned long elf_bss, elf_brk;
42542 int retval, i;
42543 @@ -572,11 +946,11 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
42544 unsigned long start_code, end_code, start_data, end_data;
42545 unsigned long reloc_func_desc __maybe_unused = 0;
42546 int executable_stack = EXSTACK_DEFAULT;
42547 - unsigned long def_flags = 0;
42548 struct {
42549 struct elfhdr elf_ex;
42550 struct elfhdr interp_elf_ex;
42551 } *loc;
42552 + unsigned long pax_task_size = TASK_SIZE;
42553
42554 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
42555 if (!loc) {
42556 @@ -713,11 +1087,81 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
42557
42558 /* OK, This is the point of no return */
42559 current->flags &= ~PF_FORKNOEXEC;
42560 - current->mm->def_flags = def_flags;
42561 +
42562 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
42563 + current->mm->pax_flags = 0UL;
42564 +#endif
42565 +
42566 +#ifdef CONFIG_PAX_DLRESOLVE
42567 + current->mm->call_dl_resolve = 0UL;
42568 +#endif
42569 +
42570 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
42571 + current->mm->call_syscall = 0UL;
42572 +#endif
42573 +
42574 +#ifdef CONFIG_PAX_ASLR
42575 + current->mm->delta_mmap = 0UL;
42576 + current->mm->delta_stack = 0UL;
42577 +#endif
42578 +
42579 + current->mm->def_flags = 0;
42580 +
42581 +#if defined(CONFIG_PAX_EI_PAX) || defined(CONFIG_PAX_PT_PAX_FLAGS) || defined(CONFIG_PAX_XATTR_PAX_FLAGS)
42582 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
42583 + send_sig(SIGKILL, current, 0);
42584 + goto out_free_dentry;
42585 + }
42586 +#endif
42587 +
42588 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
42589 + pax_set_initial_flags(bprm);
42590 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
42591 + if (pax_set_initial_flags_func)
42592 + (pax_set_initial_flags_func)(bprm);
42593 +#endif
42594 +
42595 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
42596 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
42597 + current->mm->context.user_cs_limit = PAGE_SIZE;
42598 + current->mm->def_flags |= VM_PAGEEXEC;
42599 + }
42600 +#endif
42601 +
42602 +#ifdef CONFIG_PAX_SEGMEXEC
42603 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
42604 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
42605 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
42606 + pax_task_size = SEGMEXEC_TASK_SIZE;
42607 + current->mm->def_flags |= VM_NOHUGEPAGE;
42608 + }
42609 +#endif
42610 +
42611 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
42612 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
42613 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
42614 + put_cpu();
42615 + }
42616 +#endif
42617
42618 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
42619 may depend on the personality. */
42620 SET_PERSONALITY(loc->elf_ex);
42621 +
42622 +#ifdef CONFIG_PAX_ASLR
42623 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
42624 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
42625 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
42626 + }
42627 +#endif
42628 +
42629 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
42630 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
42631 + executable_stack = EXSTACK_DISABLE_X;
42632 + current->personality &= ~READ_IMPLIES_EXEC;
42633 + } else
42634 +#endif
42635 +
42636 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
42637 current->personality |= READ_IMPLIES_EXEC;
42638
42639 @@ -808,6 +1252,20 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
42640 #else
42641 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
42642 #endif
42643 +
42644 +#ifdef CONFIG_PAX_RANDMMAP
42645 + /* PaX: randomize base address at the default exe base if requested */
42646 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
42647 +#ifdef CONFIG_SPARC64
42648 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
42649 +#else
42650 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
42651 +#endif
42652 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
42653 + elf_flags |= MAP_FIXED;
42654 + }
42655 +#endif
42656 +
42657 }
42658
42659 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
42660 @@ -840,9 +1298,9 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
42661 * allowed task size. Note that p_filesz must always be
42662 * <= p_memsz so it is only necessary to check p_memsz.
42663 */
42664 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
42665 - elf_ppnt->p_memsz > TASK_SIZE ||
42666 - TASK_SIZE - elf_ppnt->p_memsz < k) {
42667 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
42668 + elf_ppnt->p_memsz > pax_task_size ||
42669 + pax_task_size - elf_ppnt->p_memsz < k) {
42670 /* set_brk can never work. Avoid overflows. */
42671 send_sig(SIGKILL, current, 0);
42672 retval = -EINVAL;
42673 @@ -881,11 +1339,40 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
42674 goto out_free_dentry;
42675 }
42676 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
42677 - send_sig(SIGSEGV, current, 0);
42678 - retval = -EFAULT; /* Nobody gets to see this, but.. */
42679 - goto out_free_dentry;
42680 + /*
42681 + * This bss-zeroing can fail if the ELF
42682 + * file specifies odd protections. So
42683 + * we don't check the return value
42684 + */
42685 }
42686
42687 +#ifdef CONFIG_PAX_RANDMMAP
42688 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
42689 + unsigned long start, size;
42690 +
42691 + start = ELF_PAGEALIGN(elf_brk);
42692 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
42693 + down_write(&current->mm->mmap_sem);
42694 + retval = -ENOMEM;
42695 + if (!find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
42696 + unsigned long prot = PROT_NONE;
42697 +
42698 + current->mm->brk_gap = PAGE_ALIGN(size) >> PAGE_SHIFT;
42699 +// if (current->personality & ADDR_NO_RANDOMIZE)
42700 +// prot = PROT_READ;
42701 + start = do_mmap(NULL, start, size, prot, MAP_ANONYMOUS | MAP_FIXED | MAP_PRIVATE, 0);
42702 + retval = IS_ERR_VALUE(start) ? start : 0;
42703 + }
42704 + up_write(&current->mm->mmap_sem);
42705 + if (retval == 0)
42706 + retval = set_brk(start + size, start + size + PAGE_SIZE);
42707 + if (retval < 0) {
42708 + send_sig(SIGKILL, current, 0);
42709 + goto out_free_dentry;
42710 + }
42711 + }
42712 +#endif
42713 +
42714 if (elf_interpreter) {
42715 unsigned long uninitialized_var(interp_map_addr);
42716
42717 @@ -1098,7 +1585,7 @@ out:
42718 * Decide what to dump of a segment, part, all or none.
42719 */
42720 static unsigned long vma_dump_size(struct vm_area_struct *vma,
42721 - unsigned long mm_flags)
42722 + unsigned long mm_flags, long signr)
42723 {
42724 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
42725
42726 @@ -1132,7 +1619,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
42727 if (vma->vm_file == NULL)
42728 return 0;
42729
42730 - if (FILTER(MAPPED_PRIVATE))
42731 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
42732 goto whole;
42733
42734 /*
42735 @@ -1354,9 +1841,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
42736 {
42737 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
42738 int i = 0;
42739 - do
42740 + do {
42741 i += 2;
42742 - while (auxv[i - 2] != AT_NULL);
42743 + } while (auxv[i - 2] != AT_NULL);
42744 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
42745 }
42746
42747 @@ -1862,14 +2349,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
42748 }
42749
42750 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
42751 - unsigned long mm_flags)
42752 + struct coredump_params *cprm)
42753 {
42754 struct vm_area_struct *vma;
42755 size_t size = 0;
42756
42757 for (vma = first_vma(current, gate_vma); vma != NULL;
42758 vma = next_vma(vma, gate_vma))
42759 - size += vma_dump_size(vma, mm_flags);
42760 + size += vma_dump_size(vma, cprm->mm_flags, cprm->signr);
42761 return size;
42762 }
42763
42764 @@ -1963,7 +2450,7 @@ static int elf_core_dump(struct coredump_params *cprm)
42765
42766 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
42767
42768 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
42769 + offset += elf_core_vma_data_size(gate_vma, cprm);
42770 offset += elf_core_extra_data_size();
42771 e_shoff = offset;
42772
42773 @@ -1977,10 +2464,12 @@ static int elf_core_dump(struct coredump_params *cprm)
42774 offset = dataoff;
42775
42776 size += sizeof(*elf);
42777 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
42778 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
42779 goto end_coredump;
42780
42781 size += sizeof(*phdr4note);
42782 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
42783 if (size > cprm->limit
42784 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
42785 goto end_coredump;
42786 @@ -1994,7 +2483,7 @@ static int elf_core_dump(struct coredump_params *cprm)
42787 phdr.p_offset = offset;
42788 phdr.p_vaddr = vma->vm_start;
42789 phdr.p_paddr = 0;
42790 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
42791 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->signr);
42792 phdr.p_memsz = vma->vm_end - vma->vm_start;
42793 offset += phdr.p_filesz;
42794 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
42795 @@ -2005,6 +2494,7 @@ static int elf_core_dump(struct coredump_params *cprm)
42796 phdr.p_align = ELF_EXEC_PAGESIZE;
42797
42798 size += sizeof(phdr);
42799 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
42800 if (size > cprm->limit
42801 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
42802 goto end_coredump;
42803 @@ -2029,7 +2519,7 @@ static int elf_core_dump(struct coredump_params *cprm)
42804 unsigned long addr;
42805 unsigned long end;
42806
42807 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
42808 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->signr);
42809
42810 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
42811 struct page *page;
42812 @@ -2038,6 +2528,7 @@ static int elf_core_dump(struct coredump_params *cprm)
42813 page = get_dump_page(addr);
42814 if (page) {
42815 void *kaddr = kmap(page);
42816 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
42817 stop = ((size += PAGE_SIZE) > cprm->limit) ||
42818 !dump_write(cprm->file, kaddr,
42819 PAGE_SIZE);
42820 @@ -2055,6 +2546,7 @@ static int elf_core_dump(struct coredump_params *cprm)
42821
42822 if (e_phnum == PN_XNUM) {
42823 size += sizeof(*shdr4extnum);
42824 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
42825 if (size > cprm->limit
42826 || !dump_write(cprm->file, shdr4extnum,
42827 sizeof(*shdr4extnum)))
42828 @@ -2075,6 +2567,97 @@ out:
42829
42830 #endif /* CONFIG_ELF_CORE */
42831
42832 +#ifdef CONFIG_PAX_MPROTECT
42833 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
42834 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
42835 + * we'll remove VM_MAYWRITE for good on RELRO segments.
42836 + *
42837 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
42838 + * basis because we want to allow the common case and not the special ones.
42839 + */
42840 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
42841 +{
42842 + struct elfhdr elf_h;
42843 + struct elf_phdr elf_p;
42844 + unsigned long i;
42845 + unsigned long oldflags;
42846 + bool is_textrel_rw, is_textrel_rx, is_relro;
42847 +
42848 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
42849 + return;
42850 +
42851 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
42852 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
42853 +
42854 +#ifdef CONFIG_PAX_ELFRELOCS
42855 + /* possible TEXTREL */
42856 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
42857 + 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);
42858 +#else
42859 + is_textrel_rw = false;
42860 + is_textrel_rx = false;
42861 +#endif
42862 +
42863 + /* possible RELRO */
42864 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
42865 +
42866 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
42867 + return;
42868 +
42869 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
42870 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
42871 +
42872 +#ifdef CONFIG_PAX_ETEXECRELOCS
42873 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
42874 +#else
42875 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
42876 +#endif
42877 +
42878 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
42879 + !elf_check_arch(&elf_h) ||
42880 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
42881 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
42882 + return;
42883 +
42884 + for (i = 0UL; i < elf_h.e_phnum; i++) {
42885 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
42886 + return;
42887 + switch (elf_p.p_type) {
42888 + case PT_DYNAMIC:
42889 + if (!is_textrel_rw && !is_textrel_rx)
42890 + continue;
42891 + i = 0UL;
42892 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
42893 + elf_dyn dyn;
42894 +
42895 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
42896 + return;
42897 + if (dyn.d_tag == DT_NULL)
42898 + return;
42899 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
42900 + gr_log_textrel(vma);
42901 + if (is_textrel_rw)
42902 + vma->vm_flags |= VM_MAYWRITE;
42903 + else
42904 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
42905 + vma->vm_flags &= ~VM_MAYWRITE;
42906 + return;
42907 + }
42908 + i++;
42909 + }
42910 + return;
42911 +
42912 + case PT_GNU_RELRO:
42913 + if (!is_relro)
42914 + continue;
42915 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
42916 + vma->vm_flags &= ~VM_MAYWRITE;
42917 + return;
42918 + }
42919 + }
42920 +}
42921 +#endif
42922 +
42923 static int __init init_elf_binfmt(void)
42924 {
42925 return register_binfmt(&elf_format);
42926 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
42927 index 1bffbe0..c8c283e 100644
42928 --- a/fs/binfmt_flat.c
42929 +++ b/fs/binfmt_flat.c
42930 @@ -567,7 +567,9 @@ static int load_flat_file(struct linux_binprm * bprm,
42931 realdatastart = (unsigned long) -ENOMEM;
42932 printk("Unable to allocate RAM for process data, errno %d\n",
42933 (int)-realdatastart);
42934 + down_write(&current->mm->mmap_sem);
42935 do_munmap(current->mm, textpos, text_len);
42936 + up_write(&current->mm->mmap_sem);
42937 ret = realdatastart;
42938 goto err;
42939 }
42940 @@ -591,8 +593,10 @@ static int load_flat_file(struct linux_binprm * bprm,
42941 }
42942 if (IS_ERR_VALUE(result)) {
42943 printk("Unable to read data+bss, errno %d\n", (int)-result);
42944 + down_write(&current->mm->mmap_sem);
42945 do_munmap(current->mm, textpos, text_len);
42946 do_munmap(current->mm, realdatastart, len);
42947 + up_write(&current->mm->mmap_sem);
42948 ret = result;
42949 goto err;
42950 }
42951 @@ -661,8 +665,10 @@ static int load_flat_file(struct linux_binprm * bprm,
42952 }
42953 if (IS_ERR_VALUE(result)) {
42954 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
42955 + down_write(&current->mm->mmap_sem);
42956 do_munmap(current->mm, textpos, text_len + data_len + extra +
42957 MAX_SHARED_LIBS * sizeof(unsigned long));
42958 + up_write(&current->mm->mmap_sem);
42959 ret = result;
42960 goto err;
42961 }
42962 diff --git a/fs/bio.c b/fs/bio.c
42963 index b980ecd..74800bf 100644
42964 --- a/fs/bio.c
42965 +++ b/fs/bio.c
42966 @@ -833,7 +833,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
42967 /*
42968 * Overflow, abort
42969 */
42970 - if (end < start)
42971 + if (end < start || end - start > INT_MAX - nr_pages)
42972 return ERR_PTR(-EINVAL);
42973
42974 nr_pages += end - start;
42975 @@ -1229,7 +1229,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
42976 const int read = bio_data_dir(bio) == READ;
42977 struct bio_map_data *bmd = bio->bi_private;
42978 int i;
42979 - char *p = bmd->sgvecs[0].iov_base;
42980 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
42981
42982 __bio_for_each_segment(bvec, bio, i, 0) {
42983 char *addr = page_address(bvec->bv_page);
42984 diff --git a/fs/block_dev.c b/fs/block_dev.c
42985 index 5e9f198..6bf9b1c 100644
42986 --- a/fs/block_dev.c
42987 +++ b/fs/block_dev.c
42988 @@ -703,7 +703,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
42989 else if (bdev->bd_contains == bdev)
42990 return true; /* is a whole device which isn't held */
42991
42992 - else if (whole->bd_holder == bd_may_claim)
42993 + else if (whole->bd_holder == (void *)bd_may_claim)
42994 return true; /* is a partition of a device that is being partitioned */
42995 else if (whole->bd_holder != NULL)
42996 return false; /* is a partition of a held device */
42997 diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
42998 index d986824..af1befd 100644
42999 --- a/fs/btrfs/check-integrity.c
43000 +++ b/fs/btrfs/check-integrity.c
43001 @@ -157,7 +157,7 @@ struct btrfsic_block {
43002 union {
43003 bio_end_io_t *bio;
43004 bh_end_io_t *bh;
43005 - } orig_bio_bh_end_io;
43006 + } __no_const orig_bio_bh_end_io;
43007 int submit_bio_bh_rw;
43008 u64 flush_gen; /* only valid if !never_written */
43009 };
43010 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
43011 index 0639a55..7d9e07f 100644
43012 --- a/fs/btrfs/ctree.c
43013 +++ b/fs/btrfs/ctree.c
43014 @@ -488,9 +488,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
43015 free_extent_buffer(buf);
43016 add_root_to_dirty_list(root);
43017 } else {
43018 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
43019 - parent_start = parent->start;
43020 - else
43021 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
43022 + if (parent)
43023 + parent_start = parent->start;
43024 + else
43025 + parent_start = 0;
43026 + } else
43027 parent_start = 0;
43028
43029 WARN_ON(trans->transid != btrfs_header_generation(parent));
43030 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
43031 index 892b347..b3db246 100644
43032 --- a/fs/btrfs/inode.c
43033 +++ b/fs/btrfs/inode.c
43034 @@ -6930,7 +6930,7 @@ fail:
43035 return -ENOMEM;
43036 }
43037
43038 -static int btrfs_getattr(struct vfsmount *mnt,
43039 +int btrfs_getattr(struct vfsmount *mnt,
43040 struct dentry *dentry, struct kstat *stat)
43041 {
43042 struct inode *inode = dentry->d_inode;
43043 @@ -6944,6 +6944,14 @@ static int btrfs_getattr(struct vfsmount *mnt,
43044 return 0;
43045 }
43046
43047 +EXPORT_SYMBOL(btrfs_getattr);
43048 +
43049 +dev_t get_btrfs_dev_from_inode(struct inode *inode)
43050 +{
43051 + return BTRFS_I(inode)->root->anon_dev;
43052 +}
43053 +EXPORT_SYMBOL(get_btrfs_dev_from_inode);
43054 +
43055 /*
43056 * If a file is moved, it will inherit the cow and compression flags of the new
43057 * directory.
43058 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
43059 index 1b36f19..5ac7360 100644
43060 --- a/fs/btrfs/ioctl.c
43061 +++ b/fs/btrfs/ioctl.c
43062 @@ -2783,9 +2783,12 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
43063 for (i = 0; i < num_types; i++) {
43064 struct btrfs_space_info *tmp;
43065
43066 + /* Don't copy in more than we allocated */
43067 if (!slot_count)
43068 break;
43069
43070 + slot_count--;
43071 +
43072 info = NULL;
43073 rcu_read_lock();
43074 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
43075 @@ -2807,15 +2810,12 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
43076 memcpy(dest, &space, sizeof(space));
43077 dest++;
43078 space_args.total_spaces++;
43079 - slot_count--;
43080 }
43081 - if (!slot_count)
43082 - break;
43083 }
43084 up_read(&info->groups_sem);
43085 }
43086
43087 - user_dest = (struct btrfs_ioctl_space_info *)
43088 + user_dest = (struct btrfs_ioctl_space_info __user *)
43089 (arg + sizeof(struct btrfs_ioctl_space_args));
43090
43091 if (copy_to_user(user_dest, dest_orig, alloc_size))
43092 diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
43093 index 8c1aae2..1e46446 100644
43094 --- a/fs/btrfs/relocation.c
43095 +++ b/fs/btrfs/relocation.c
43096 @@ -1244,7 +1244,7 @@ static int __update_reloc_root(struct btrfs_root *root, int del)
43097 }
43098 spin_unlock(&rc->reloc_root_tree.lock);
43099
43100 - BUG_ON((struct btrfs_root *)node->data != root);
43101 + BUG_ON(!node || (struct btrfs_root *)node->data != root);
43102
43103 if (!del) {
43104 spin_lock(&rc->reloc_root_tree.lock);
43105 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
43106 index 622f469..e8d2d55 100644
43107 --- a/fs/cachefiles/bind.c
43108 +++ b/fs/cachefiles/bind.c
43109 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
43110 args);
43111
43112 /* start by checking things over */
43113 - ASSERT(cache->fstop_percent >= 0 &&
43114 - cache->fstop_percent < cache->fcull_percent &&
43115 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
43116 cache->fcull_percent < cache->frun_percent &&
43117 cache->frun_percent < 100);
43118
43119 - ASSERT(cache->bstop_percent >= 0 &&
43120 - cache->bstop_percent < cache->bcull_percent &&
43121 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
43122 cache->bcull_percent < cache->brun_percent &&
43123 cache->brun_percent < 100);
43124
43125 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
43126 index 0a1467b..6a53245 100644
43127 --- a/fs/cachefiles/daemon.c
43128 +++ b/fs/cachefiles/daemon.c
43129 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
43130 if (n > buflen)
43131 return -EMSGSIZE;
43132
43133 - if (copy_to_user(_buffer, buffer, n) != 0)
43134 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
43135 return -EFAULT;
43136
43137 return n;
43138 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
43139 if (test_bit(CACHEFILES_DEAD, &cache->flags))
43140 return -EIO;
43141
43142 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
43143 + if (datalen > PAGE_SIZE - 1)
43144 return -EOPNOTSUPP;
43145
43146 /* drag the command string into the kernel so we can parse it */
43147 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
43148 if (args[0] != '%' || args[1] != '\0')
43149 return -EINVAL;
43150
43151 - if (fstop < 0 || fstop >= cache->fcull_percent)
43152 + if (fstop >= cache->fcull_percent)
43153 return cachefiles_daemon_range_error(cache, args);
43154
43155 cache->fstop_percent = fstop;
43156 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
43157 if (args[0] != '%' || args[1] != '\0')
43158 return -EINVAL;
43159
43160 - if (bstop < 0 || bstop >= cache->bcull_percent)
43161 + if (bstop >= cache->bcull_percent)
43162 return cachefiles_daemon_range_error(cache, args);
43163
43164 cache->bstop_percent = bstop;
43165 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
43166 index bd6bc1b..b627b53 100644
43167 --- a/fs/cachefiles/internal.h
43168 +++ b/fs/cachefiles/internal.h
43169 @@ -57,7 +57,7 @@ struct cachefiles_cache {
43170 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
43171 struct rb_root active_nodes; /* active nodes (can't be culled) */
43172 rwlock_t active_lock; /* lock for active_nodes */
43173 - atomic_t gravecounter; /* graveyard uniquifier */
43174 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
43175 unsigned frun_percent; /* when to stop culling (% files) */
43176 unsigned fcull_percent; /* when to start culling (% files) */
43177 unsigned fstop_percent; /* when to stop allocating (% files) */
43178 @@ -169,19 +169,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
43179 * proc.c
43180 */
43181 #ifdef CONFIG_CACHEFILES_HISTOGRAM
43182 -extern atomic_t cachefiles_lookup_histogram[HZ];
43183 -extern atomic_t cachefiles_mkdir_histogram[HZ];
43184 -extern atomic_t cachefiles_create_histogram[HZ];
43185 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
43186 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
43187 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
43188
43189 extern int __init cachefiles_proc_init(void);
43190 extern void cachefiles_proc_cleanup(void);
43191 static inline
43192 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
43193 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
43194 {
43195 unsigned long jif = jiffies - start_jif;
43196 if (jif >= HZ)
43197 jif = HZ - 1;
43198 - atomic_inc(&histogram[jif]);
43199 + atomic_inc_unchecked(&histogram[jif]);
43200 }
43201
43202 #else
43203 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
43204 index a0358c2..d6137f2 100644
43205 --- a/fs/cachefiles/namei.c
43206 +++ b/fs/cachefiles/namei.c
43207 @@ -318,7 +318,7 @@ try_again:
43208 /* first step is to make up a grave dentry in the graveyard */
43209 sprintf(nbuffer, "%08x%08x",
43210 (uint32_t) get_seconds(),
43211 - (uint32_t) atomic_inc_return(&cache->gravecounter));
43212 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
43213
43214 /* do the multiway lock magic */
43215 trap = lock_rename(cache->graveyard, dir);
43216 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
43217 index eccd339..4c1d995 100644
43218 --- a/fs/cachefiles/proc.c
43219 +++ b/fs/cachefiles/proc.c
43220 @@ -14,9 +14,9 @@
43221 #include <linux/seq_file.h>
43222 #include "internal.h"
43223
43224 -atomic_t cachefiles_lookup_histogram[HZ];
43225 -atomic_t cachefiles_mkdir_histogram[HZ];
43226 -atomic_t cachefiles_create_histogram[HZ];
43227 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
43228 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
43229 +atomic_unchecked_t cachefiles_create_histogram[HZ];
43230
43231 /*
43232 * display the latency histogram
43233 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
43234 return 0;
43235 default:
43236 index = (unsigned long) v - 3;
43237 - x = atomic_read(&cachefiles_lookup_histogram[index]);
43238 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
43239 - z = atomic_read(&cachefiles_create_histogram[index]);
43240 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
43241 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
43242 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
43243 if (x == 0 && y == 0 && z == 0)
43244 return 0;
43245
43246 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
43247 index 0e3c092..818480e 100644
43248 --- a/fs/cachefiles/rdwr.c
43249 +++ b/fs/cachefiles/rdwr.c
43250 @@ -945,7 +945,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
43251 old_fs = get_fs();
43252 set_fs(KERNEL_DS);
43253 ret = file->f_op->write(
43254 - file, (const void __user *) data, len, &pos);
43255 + file, (const void __force_user *) data, len, &pos);
43256 set_fs(old_fs);
43257 kunmap(page);
43258 if (ret != len)
43259 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
43260 index 3e8094b..cb3ff3d 100644
43261 --- a/fs/ceph/dir.c
43262 +++ b/fs/ceph/dir.c
43263 @@ -244,7 +244,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
43264 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
43265 struct ceph_mds_client *mdsc = fsc->mdsc;
43266 unsigned frag = fpos_frag(filp->f_pos);
43267 - int off = fpos_off(filp->f_pos);
43268 + unsigned int off = fpos_off(filp->f_pos);
43269 int err;
43270 u32 ftype;
43271 struct ceph_mds_reply_info_parsed *rinfo;
43272 @@ -598,7 +598,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
43273 if (nd &&
43274 (nd->flags & LOOKUP_OPEN) &&
43275 !(nd->intent.open.flags & O_CREAT)) {
43276 - int mode = nd->intent.open.create_mode & ~current->fs->umask;
43277 + int mode = nd->intent.open.create_mode & ~current_umask();
43278 return ceph_lookup_open(dir, dentry, nd, mode, 1);
43279 }
43280
43281 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
43282 index 24b3dfc..3cd5454 100644
43283 --- a/fs/cifs/cifs_debug.c
43284 +++ b/fs/cifs/cifs_debug.c
43285 @@ -265,8 +265,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
43286
43287 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
43288 #ifdef CONFIG_CIFS_STATS2
43289 - atomic_set(&totBufAllocCount, 0);
43290 - atomic_set(&totSmBufAllocCount, 0);
43291 + atomic_set_unchecked(&totBufAllocCount, 0);
43292 + atomic_set_unchecked(&totSmBufAllocCount, 0);
43293 #endif /* CONFIG_CIFS_STATS2 */
43294 spin_lock(&cifs_tcp_ses_lock);
43295 list_for_each(tmp1, &cifs_tcp_ses_list) {
43296 @@ -279,25 +279,25 @@ static ssize_t cifs_stats_proc_write(struct file *file,
43297 tcon = list_entry(tmp3,
43298 struct cifs_tcon,
43299 tcon_list);
43300 - atomic_set(&tcon->num_smbs_sent, 0);
43301 - atomic_set(&tcon->num_writes, 0);
43302 - atomic_set(&tcon->num_reads, 0);
43303 - atomic_set(&tcon->num_oplock_brks, 0);
43304 - atomic_set(&tcon->num_opens, 0);
43305 - atomic_set(&tcon->num_posixopens, 0);
43306 - atomic_set(&tcon->num_posixmkdirs, 0);
43307 - atomic_set(&tcon->num_closes, 0);
43308 - atomic_set(&tcon->num_deletes, 0);
43309 - atomic_set(&tcon->num_mkdirs, 0);
43310 - atomic_set(&tcon->num_rmdirs, 0);
43311 - atomic_set(&tcon->num_renames, 0);
43312 - atomic_set(&tcon->num_t2renames, 0);
43313 - atomic_set(&tcon->num_ffirst, 0);
43314 - atomic_set(&tcon->num_fnext, 0);
43315 - atomic_set(&tcon->num_fclose, 0);
43316 - atomic_set(&tcon->num_hardlinks, 0);
43317 - atomic_set(&tcon->num_symlinks, 0);
43318 - atomic_set(&tcon->num_locks, 0);
43319 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
43320 + atomic_set_unchecked(&tcon->num_writes, 0);
43321 + atomic_set_unchecked(&tcon->num_reads, 0);
43322 + atomic_set_unchecked(&tcon->num_oplock_brks, 0);
43323 + atomic_set_unchecked(&tcon->num_opens, 0);
43324 + atomic_set_unchecked(&tcon->num_posixopens, 0);
43325 + atomic_set_unchecked(&tcon->num_posixmkdirs, 0);
43326 + atomic_set_unchecked(&tcon->num_closes, 0);
43327 + atomic_set_unchecked(&tcon->num_deletes, 0);
43328 + atomic_set_unchecked(&tcon->num_mkdirs, 0);
43329 + atomic_set_unchecked(&tcon->num_rmdirs, 0);
43330 + atomic_set_unchecked(&tcon->num_renames, 0);
43331 + atomic_set_unchecked(&tcon->num_t2renames, 0);
43332 + atomic_set_unchecked(&tcon->num_ffirst, 0);
43333 + atomic_set_unchecked(&tcon->num_fnext, 0);
43334 + atomic_set_unchecked(&tcon->num_fclose, 0);
43335 + atomic_set_unchecked(&tcon->num_hardlinks, 0);
43336 + atomic_set_unchecked(&tcon->num_symlinks, 0);
43337 + atomic_set_unchecked(&tcon->num_locks, 0);
43338 }
43339 }
43340 }
43341 @@ -327,8 +327,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
43342 smBufAllocCount.counter, cifs_min_small);
43343 #ifdef CONFIG_CIFS_STATS2
43344 seq_printf(m, "Total Large %d Small %d Allocations\n",
43345 - atomic_read(&totBufAllocCount),
43346 - atomic_read(&totSmBufAllocCount));
43347 + atomic_read_unchecked(&totBufAllocCount),
43348 + atomic_read_unchecked(&totSmBufAllocCount));
43349 #endif /* CONFIG_CIFS_STATS2 */
43350
43351 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
43352 @@ -357,41 +357,41 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
43353 if (tcon->need_reconnect)
43354 seq_puts(m, "\tDISCONNECTED ");
43355 seq_printf(m, "\nSMBs: %d Oplock Breaks: %d",
43356 - atomic_read(&tcon->num_smbs_sent),
43357 - atomic_read(&tcon->num_oplock_brks));
43358 + atomic_read_unchecked(&tcon->num_smbs_sent),
43359 + atomic_read_unchecked(&tcon->num_oplock_brks));
43360 seq_printf(m, "\nReads: %d Bytes: %lld",
43361 - atomic_read(&tcon->num_reads),
43362 + atomic_read_unchecked(&tcon->num_reads),
43363 (long long)(tcon->bytes_read));
43364 seq_printf(m, "\nWrites: %d Bytes: %lld",
43365 - atomic_read(&tcon->num_writes),
43366 + atomic_read_unchecked(&tcon->num_writes),
43367 (long long)(tcon->bytes_written));
43368 seq_printf(m, "\nFlushes: %d",
43369 - atomic_read(&tcon->num_flushes));
43370 + atomic_read_unchecked(&tcon->num_flushes));
43371 seq_printf(m, "\nLocks: %d HardLinks: %d "
43372 "Symlinks: %d",
43373 - atomic_read(&tcon->num_locks),
43374 - atomic_read(&tcon->num_hardlinks),
43375 - atomic_read(&tcon->num_symlinks));
43376 + atomic_read_unchecked(&tcon->num_locks),
43377 + atomic_read_unchecked(&tcon->num_hardlinks),
43378 + atomic_read_unchecked(&tcon->num_symlinks));
43379 seq_printf(m, "\nOpens: %d Closes: %d "
43380 "Deletes: %d",
43381 - atomic_read(&tcon->num_opens),
43382 - atomic_read(&tcon->num_closes),
43383 - atomic_read(&tcon->num_deletes));
43384 + atomic_read_unchecked(&tcon->num_opens),
43385 + atomic_read_unchecked(&tcon->num_closes),
43386 + atomic_read_unchecked(&tcon->num_deletes));
43387 seq_printf(m, "\nPosix Opens: %d "
43388 "Posix Mkdirs: %d",
43389 - atomic_read(&tcon->num_posixopens),
43390 - atomic_read(&tcon->num_posixmkdirs));
43391 + atomic_read_unchecked(&tcon->num_posixopens),
43392 + atomic_read_unchecked(&tcon->num_posixmkdirs));
43393 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
43394 - atomic_read(&tcon->num_mkdirs),
43395 - atomic_read(&tcon->num_rmdirs));
43396 + atomic_read_unchecked(&tcon->num_mkdirs),
43397 + atomic_read_unchecked(&tcon->num_rmdirs));
43398 seq_printf(m, "\nRenames: %d T2 Renames %d",
43399 - atomic_read(&tcon->num_renames),
43400 - atomic_read(&tcon->num_t2renames));
43401 + atomic_read_unchecked(&tcon->num_renames),
43402 + atomic_read_unchecked(&tcon->num_t2renames));
43403 seq_printf(m, "\nFindFirst: %d FNext %d "
43404 "FClose %d",
43405 - atomic_read(&tcon->num_ffirst),
43406 - atomic_read(&tcon->num_fnext),
43407 - atomic_read(&tcon->num_fclose));
43408 + atomic_read_unchecked(&tcon->num_ffirst),
43409 + atomic_read_unchecked(&tcon->num_fnext),
43410 + atomic_read_unchecked(&tcon->num_fclose));
43411 }
43412 }
43413 }
43414 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
43415 index 70dd381..b8ce03b 100644
43416 --- a/fs/cifs/cifsfs.c
43417 +++ b/fs/cifs/cifsfs.c
43418 @@ -989,7 +989,7 @@ cifs_init_request_bufs(void)
43419 cifs_req_cachep = kmem_cache_create("cifs_request",
43420 CIFSMaxBufSize +
43421 MAX_CIFS_HDR_SIZE, 0,
43422 - SLAB_HWCACHE_ALIGN, NULL);
43423 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
43424 if (cifs_req_cachep == NULL)
43425 return -ENOMEM;
43426
43427 @@ -1016,7 +1016,7 @@ cifs_init_request_bufs(void)
43428 efficient to alloc 1 per page off the slab compared to 17K (5page)
43429 alloc of large cifs buffers even when page debugging is on */
43430 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
43431 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
43432 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
43433 NULL);
43434 if (cifs_sm_req_cachep == NULL) {
43435 mempool_destroy(cifs_req_poolp);
43436 @@ -1101,8 +1101,8 @@ init_cifs(void)
43437 atomic_set(&bufAllocCount, 0);
43438 atomic_set(&smBufAllocCount, 0);
43439 #ifdef CONFIG_CIFS_STATS2
43440 - atomic_set(&totBufAllocCount, 0);
43441 - atomic_set(&totSmBufAllocCount, 0);
43442 + atomic_set_unchecked(&totBufAllocCount, 0);
43443 + atomic_set_unchecked(&totSmBufAllocCount, 0);
43444 #endif /* CONFIG_CIFS_STATS2 */
43445
43446 atomic_set(&midCount, 0);
43447 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
43448 index d47d20a..77e8b33 100644
43449 --- a/fs/cifs/cifsglob.h
43450 +++ b/fs/cifs/cifsglob.h
43451 @@ -388,28 +388,28 @@ struct cifs_tcon {
43452 __u16 Flags; /* optional support bits */
43453 enum statusEnum tidStatus;
43454 #ifdef CONFIG_CIFS_STATS
43455 - atomic_t num_smbs_sent;
43456 - atomic_t num_writes;
43457 - atomic_t num_reads;
43458 - atomic_t num_flushes;
43459 - atomic_t num_oplock_brks;
43460 - atomic_t num_opens;
43461 - atomic_t num_closes;
43462 - atomic_t num_deletes;
43463 - atomic_t num_mkdirs;
43464 - atomic_t num_posixopens;
43465 - atomic_t num_posixmkdirs;
43466 - atomic_t num_rmdirs;
43467 - atomic_t num_renames;
43468 - atomic_t num_t2renames;
43469 - atomic_t num_ffirst;
43470 - atomic_t num_fnext;
43471 - atomic_t num_fclose;
43472 - atomic_t num_hardlinks;
43473 - atomic_t num_symlinks;
43474 - atomic_t num_locks;
43475 - atomic_t num_acl_get;
43476 - atomic_t num_acl_set;
43477 + atomic_unchecked_t num_smbs_sent;
43478 + atomic_unchecked_t num_writes;
43479 + atomic_unchecked_t num_reads;
43480 + atomic_unchecked_t num_flushes;
43481 + atomic_unchecked_t num_oplock_brks;
43482 + atomic_unchecked_t num_opens;
43483 + atomic_unchecked_t num_closes;
43484 + atomic_unchecked_t num_deletes;
43485 + atomic_unchecked_t num_mkdirs;
43486 + atomic_unchecked_t num_posixopens;
43487 + atomic_unchecked_t num_posixmkdirs;
43488 + atomic_unchecked_t num_rmdirs;
43489 + atomic_unchecked_t num_renames;
43490 + atomic_unchecked_t num_t2renames;
43491 + atomic_unchecked_t num_ffirst;
43492 + atomic_unchecked_t num_fnext;
43493 + atomic_unchecked_t num_fclose;
43494 + atomic_unchecked_t num_hardlinks;
43495 + atomic_unchecked_t num_symlinks;
43496 + atomic_unchecked_t num_locks;
43497 + atomic_unchecked_t num_acl_get;
43498 + atomic_unchecked_t num_acl_set;
43499 #ifdef CONFIG_CIFS_STATS2
43500 unsigned long long time_writes;
43501 unsigned long long time_reads;
43502 @@ -624,7 +624,7 @@ convert_delimiter(char *path, char delim)
43503 }
43504
43505 #ifdef CONFIG_CIFS_STATS
43506 -#define cifs_stats_inc atomic_inc
43507 +#define cifs_stats_inc atomic_inc_unchecked
43508
43509 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
43510 unsigned int bytes)
43511 @@ -983,8 +983,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
43512 /* Various Debug counters */
43513 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
43514 #ifdef CONFIG_CIFS_STATS2
43515 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
43516 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
43517 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
43518 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
43519 #endif
43520 GLOBAL_EXTERN atomic_t smBufAllocCount;
43521 GLOBAL_EXTERN atomic_t midCount;
43522 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
43523 index 6b0e064..94e6c3c 100644
43524 --- a/fs/cifs/link.c
43525 +++ b/fs/cifs/link.c
43526 @@ -600,7 +600,7 @@ symlink_exit:
43527
43528 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
43529 {
43530 - char *p = nd_get_link(nd);
43531 + const char *p = nd_get_link(nd);
43532 if (!IS_ERR(p))
43533 kfree(p);
43534 }
43535 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
43536 index 703ef5c..2a44ed5 100644
43537 --- a/fs/cifs/misc.c
43538 +++ b/fs/cifs/misc.c
43539 @@ -156,7 +156,7 @@ cifs_buf_get(void)
43540 memset(ret_buf, 0, sizeof(struct smb_hdr) + 3);
43541 atomic_inc(&bufAllocCount);
43542 #ifdef CONFIG_CIFS_STATS2
43543 - atomic_inc(&totBufAllocCount);
43544 + atomic_inc_unchecked(&totBufAllocCount);
43545 #endif /* CONFIG_CIFS_STATS2 */
43546 }
43547
43548 @@ -191,7 +191,7 @@ cifs_small_buf_get(void)
43549 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
43550 atomic_inc(&smBufAllocCount);
43551 #ifdef CONFIG_CIFS_STATS2
43552 - atomic_inc(&totSmBufAllocCount);
43553 + atomic_inc_unchecked(&totSmBufAllocCount);
43554 #endif /* CONFIG_CIFS_STATS2 */
43555
43556 }
43557 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
43558 index 6901578..d402eb5 100644
43559 --- a/fs/coda/cache.c
43560 +++ b/fs/coda/cache.c
43561 @@ -24,7 +24,7 @@
43562 #include "coda_linux.h"
43563 #include "coda_cache.h"
43564
43565 -static atomic_t permission_epoch = ATOMIC_INIT(0);
43566 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
43567
43568 /* replace or extend an acl cache hit */
43569 void coda_cache_enter(struct inode *inode, int mask)
43570 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
43571 struct coda_inode_info *cii = ITOC(inode);
43572
43573 spin_lock(&cii->c_lock);
43574 - cii->c_cached_epoch = atomic_read(&permission_epoch);
43575 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
43576 if (cii->c_uid != current_fsuid()) {
43577 cii->c_uid = current_fsuid();
43578 cii->c_cached_perm = mask;
43579 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
43580 {
43581 struct coda_inode_info *cii = ITOC(inode);
43582 spin_lock(&cii->c_lock);
43583 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
43584 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
43585 spin_unlock(&cii->c_lock);
43586 }
43587
43588 /* remove all acl caches */
43589 void coda_cache_clear_all(struct super_block *sb)
43590 {
43591 - atomic_inc(&permission_epoch);
43592 + atomic_inc_unchecked(&permission_epoch);
43593 }
43594
43595
43596 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
43597 spin_lock(&cii->c_lock);
43598 hit = (mask & cii->c_cached_perm) == mask &&
43599 cii->c_uid == current_fsuid() &&
43600 - cii->c_cached_epoch == atomic_read(&permission_epoch);
43601 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
43602 spin_unlock(&cii->c_lock);
43603
43604 return hit;
43605 diff --git a/fs/compat.c b/fs/compat.c
43606 index 07880ba..3fb2862 100644
43607 --- a/fs/compat.c
43608 +++ b/fs/compat.c
43609 @@ -491,7 +491,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
43610
43611 set_fs(KERNEL_DS);
43612 /* The __user pointer cast is valid because of the set_fs() */
43613 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
43614 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
43615 set_fs(oldfs);
43616 /* truncating is ok because it's a user address */
43617 if (!ret)
43618 @@ -549,7 +549,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
43619 goto out;
43620
43621 ret = -EINVAL;
43622 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
43623 + if (nr_segs > UIO_MAXIOV)
43624 goto out;
43625 if (nr_segs > fast_segs) {
43626 ret = -ENOMEM;
43627 @@ -832,6 +832,7 @@ struct compat_old_linux_dirent {
43628
43629 struct compat_readdir_callback {
43630 struct compat_old_linux_dirent __user *dirent;
43631 + struct file * file;
43632 int result;
43633 };
43634
43635 @@ -849,6 +850,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
43636 buf->result = -EOVERFLOW;
43637 return -EOVERFLOW;
43638 }
43639 +
43640 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
43641 + return 0;
43642 +
43643 buf->result++;
43644 dirent = buf->dirent;
43645 if (!access_ok(VERIFY_WRITE, dirent,
43646 @@ -881,6 +886,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
43647
43648 buf.result = 0;
43649 buf.dirent = dirent;
43650 + buf.file = file;
43651
43652 error = vfs_readdir(file, compat_fillonedir, &buf);
43653 if (buf.result)
43654 @@ -901,6 +907,7 @@ struct compat_linux_dirent {
43655 struct compat_getdents_callback {
43656 struct compat_linux_dirent __user *current_dir;
43657 struct compat_linux_dirent __user *previous;
43658 + struct file * file;
43659 int count;
43660 int error;
43661 };
43662 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
43663 buf->error = -EOVERFLOW;
43664 return -EOVERFLOW;
43665 }
43666 +
43667 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
43668 + return 0;
43669 +
43670 dirent = buf->previous;
43671 if (dirent) {
43672 if (__put_user(offset, &dirent->d_off))
43673 @@ -969,6 +980,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
43674 buf.previous = NULL;
43675 buf.count = count;
43676 buf.error = 0;
43677 + buf.file = file;
43678
43679 error = vfs_readdir(file, compat_filldir, &buf);
43680 if (error >= 0)
43681 @@ -990,6 +1002,7 @@ out:
43682 struct compat_getdents_callback64 {
43683 struct linux_dirent64 __user *current_dir;
43684 struct linux_dirent64 __user *previous;
43685 + struct file * file;
43686 int count;
43687 int error;
43688 };
43689 @@ -1006,6 +1019,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
43690 buf->error = -EINVAL; /* only used if we fail.. */
43691 if (reclen > buf->count)
43692 return -EINVAL;
43693 +
43694 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
43695 + return 0;
43696 +
43697 dirent = buf->previous;
43698
43699 if (dirent) {
43700 @@ -1057,13 +1074,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
43701 buf.previous = NULL;
43702 buf.count = count;
43703 buf.error = 0;
43704 + buf.file = file;
43705
43706 error = vfs_readdir(file, compat_filldir64, &buf);
43707 if (error >= 0)
43708 error = buf.error;
43709 lastdirent = buf.previous;
43710 if (lastdirent) {
43711 - typeof(lastdirent->d_off) d_off = file->f_pos;
43712 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = file->f_pos;
43713 if (__put_user_unaligned(d_off, &lastdirent->d_off))
43714 error = -EFAULT;
43715 else
43716 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
43717 index 112e45a..b59845b 100644
43718 --- a/fs/compat_binfmt_elf.c
43719 +++ b/fs/compat_binfmt_elf.c
43720 @@ -30,11 +30,13 @@
43721 #undef elf_phdr
43722 #undef elf_shdr
43723 #undef elf_note
43724 +#undef elf_dyn
43725 #undef elf_addr_t
43726 #define elfhdr elf32_hdr
43727 #define elf_phdr elf32_phdr
43728 #define elf_shdr elf32_shdr
43729 #define elf_note elf32_note
43730 +#define elf_dyn Elf32_Dyn
43731 #define elf_addr_t Elf32_Addr
43732
43733 /*
43734 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
43735 index a26bea1..ae23e72 100644
43736 --- a/fs/compat_ioctl.c
43737 +++ b/fs/compat_ioctl.c
43738 @@ -211,6 +211,8 @@ static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd,
43739
43740 err = get_user(palp, &up->palette);
43741 err |= get_user(length, &up->length);
43742 + if (err)
43743 + return -EFAULT;
43744
43745 up_native = compat_alloc_user_space(sizeof(struct video_spu_palette));
43746 err = put_user(compat_ptr(palp), &up_native->palette);
43747 @@ -622,7 +624,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
43748 return -EFAULT;
43749 if (__get_user(udata, &ss32->iomem_base))
43750 return -EFAULT;
43751 - ss.iomem_base = compat_ptr(udata);
43752 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
43753 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
43754 __get_user(ss.port_high, &ss32->port_high))
43755 return -EFAULT;
43756 @@ -797,7 +799,7 @@ static int compat_ioctl_preallocate(struct file *file,
43757 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
43758 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
43759 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
43760 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
43761 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
43762 return -EFAULT;
43763
43764 return ioctl_preallocate(file, p);
43765 @@ -1611,8 +1613,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
43766 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
43767 {
43768 unsigned int a, b;
43769 - a = *(unsigned int *)p;
43770 - b = *(unsigned int *)q;
43771 + a = *(const unsigned int *)p;
43772 + b = *(const unsigned int *)q;
43773 if (a > b)
43774 return 1;
43775 if (a < b)
43776 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
43777 index 5ddd7eb..c18bf04 100644
43778 --- a/fs/configfs/dir.c
43779 +++ b/fs/configfs/dir.c
43780 @@ -1575,7 +1575,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
43781 }
43782 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
43783 struct configfs_dirent *next;
43784 - const char * name;
43785 + const unsigned char * name;
43786 + char d_name[sizeof(next->s_dentry->d_iname)];
43787 int len;
43788 struct inode *inode = NULL;
43789
43790 @@ -1585,7 +1586,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
43791 continue;
43792
43793 name = configfs_get_name(next);
43794 - len = strlen(name);
43795 + if (next->s_dentry && name == next->s_dentry->d_iname) {
43796 + len = next->s_dentry->d_name.len;
43797 + memcpy(d_name, name, len);
43798 + name = d_name;
43799 + } else
43800 + len = strlen(name);
43801
43802 /*
43803 * We'll have a dentry and an inode for
43804 diff --git a/fs/dcache.c b/fs/dcache.c
43805 index 2576d14..0cec38d 100644
43806 --- a/fs/dcache.c
43807 +++ b/fs/dcache.c
43808 @@ -105,10 +105,10 @@ static unsigned int d_hash_shift __read_mostly;
43809 static struct hlist_bl_head *dentry_hashtable __read_mostly;
43810
43811 static inline struct hlist_bl_head *d_hash(const struct dentry *parent,
43812 - unsigned long hash)
43813 + unsigned int hash)
43814 {
43815 - hash += ((unsigned long) parent ^ GOLDEN_RATIO_PRIME) / L1_CACHE_BYTES;
43816 - hash = hash ^ ((hash ^ GOLDEN_RATIO_PRIME) >> D_HASHBITS);
43817 + hash += (unsigned long) parent / L1_CACHE_BYTES;
43818 + hash = hash + (hash >> D_HASHBITS);
43819 return dentry_hashtable + (hash & D_HASHMASK);
43820 }
43821
43822 @@ -3067,7 +3067,7 @@ void __init vfs_caches_init(unsigned long mempages)
43823 mempages -= reserve;
43824
43825 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
43826 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
43827 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY, NULL);
43828
43829 dcache_init();
43830 inode_init();
43831 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
43832 index 956d5dd..e755e04 100644
43833 --- a/fs/debugfs/inode.c
43834 +++ b/fs/debugfs/inode.c
43835 @@ -261,7 +261,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
43836 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
43837 {
43838 return debugfs_create_file(name,
43839 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
43840 + S_IFDIR | S_IRWXU,
43841 +#else
43842 S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
43843 +#endif
43844 parent, NULL, NULL);
43845 }
43846 EXPORT_SYMBOL_GPL(debugfs_create_dir);
43847 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
43848 index ab35b11..b30af66 100644
43849 --- a/fs/ecryptfs/inode.c
43850 +++ b/fs/ecryptfs/inode.c
43851 @@ -672,7 +672,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
43852 old_fs = get_fs();
43853 set_fs(get_ds());
43854 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
43855 - (char __user *)lower_buf,
43856 + (char __force_user *)lower_buf,
43857 lower_bufsiz);
43858 set_fs(old_fs);
43859 if (rc < 0)
43860 @@ -718,7 +718,7 @@ static void *ecryptfs_follow_link(struct dentry *dentry, struct nameidata *nd)
43861 }
43862 old_fs = get_fs();
43863 set_fs(get_ds());
43864 - rc = dentry->d_inode->i_op->readlink(dentry, (char __user *)buf, len);
43865 + rc = dentry->d_inode->i_op->readlink(dentry, (char __force_user *)buf, len);
43866 set_fs(old_fs);
43867 if (rc < 0) {
43868 kfree(buf);
43869 @@ -733,7 +733,7 @@ out:
43870 static void
43871 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
43872 {
43873 - char *buf = nd_get_link(nd);
43874 + const char *buf = nd_get_link(nd);
43875 if (!IS_ERR(buf)) {
43876 /* Free the char* */
43877 kfree(buf);
43878 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
43879 index 3a06f40..f7af544 100644
43880 --- a/fs/ecryptfs/miscdev.c
43881 +++ b/fs/ecryptfs/miscdev.c
43882 @@ -345,7 +345,7 @@ check_list:
43883 goto out_unlock_msg_ctx;
43884 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
43885 if (msg_ctx->msg) {
43886 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
43887 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
43888 goto out_unlock_msg_ctx;
43889 i += packet_length_size;
43890 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
43891 diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
43892 index b2a34a1..162fa69 100644
43893 --- a/fs/ecryptfs/read_write.c
43894 +++ b/fs/ecryptfs/read_write.c
43895 @@ -48,7 +48,7 @@ int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data,
43896 return -EIO;
43897 fs_save = get_fs();
43898 set_fs(get_ds());
43899 - rc = vfs_write(lower_file, data, size, &offset);
43900 + rc = vfs_write(lower_file, (const char __force_user *)data, size, &offset);
43901 set_fs(fs_save);
43902 mark_inode_dirty_sync(ecryptfs_inode);
43903 return rc;
43904 @@ -244,7 +244,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
43905 return -EIO;
43906 fs_save = get_fs();
43907 set_fs(get_ds());
43908 - rc = vfs_read(lower_file, data, size, &offset);
43909 + rc = vfs_read(lower_file, (char __force_user *)data, size, &offset);
43910 set_fs(fs_save);
43911 return rc;
43912 }
43913 diff --git a/fs/exec.c b/fs/exec.c
43914 index ae42277..32c9035 100644
43915 --- a/fs/exec.c
43916 +++ b/fs/exec.c
43917 @@ -55,6 +55,13 @@
43918 #include <linux/pipe_fs_i.h>
43919 #include <linux/oom.h>
43920 #include <linux/compat.h>
43921 +#include <linux/random.h>
43922 +#include <linux/seq_file.h>
43923 +
43924 +#ifdef CONFIG_PAX_REFCOUNT
43925 +#include <linux/kallsyms.h>
43926 +#include <linux/kdebug.h>
43927 +#endif
43928
43929 #include <asm/uaccess.h>
43930 #include <asm/mmu_context.h>
43931 @@ -63,6 +70,15 @@
43932 #include <trace/events/task.h>
43933 #include "internal.h"
43934
43935 +#ifndef CONFIG_PAX_HAVE_ACL_FLAGS
43936 +void __weak pax_set_initial_flags(struct linux_binprm *bprm) {}
43937 +#endif
43938 +
43939 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
43940 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
43941 +EXPORT_SYMBOL(pax_set_initial_flags_func);
43942 +#endif
43943 +
43944 int core_uses_pid;
43945 char core_pattern[CORENAME_MAX_SIZE] = "core";
43946 unsigned int core_pipe_limit;
43947 @@ -72,7 +88,7 @@ struct core_name {
43948 char *corename;
43949 int used, size;
43950 };
43951 -static atomic_t call_count = ATOMIC_INIT(1);
43952 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
43953
43954 /* The maximal length of core_pattern is also specified in sysctl.c */
43955
43956 @@ -190,18 +206,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
43957 int write)
43958 {
43959 struct page *page;
43960 - int ret;
43961
43962 -#ifdef CONFIG_STACK_GROWSUP
43963 - if (write) {
43964 - ret = expand_downwards(bprm->vma, pos);
43965 - if (ret < 0)
43966 - return NULL;
43967 - }
43968 -#endif
43969 - ret = get_user_pages(current, bprm->mm, pos,
43970 - 1, write, 1, &page, NULL);
43971 - if (ret <= 0)
43972 + if (0 > expand_downwards(bprm->vma, pos))
43973 + return NULL;
43974 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
43975 return NULL;
43976
43977 if (write) {
43978 @@ -217,6 +225,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
43979 if (size <= ARG_MAX)
43980 return page;
43981
43982 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
43983 + // only allow 512KB for argv+env on suid/sgid binaries
43984 + // to prevent easy ASLR exhaustion
43985 + if (((bprm->cred->euid != current_euid()) ||
43986 + (bprm->cred->egid != current_egid())) &&
43987 + (size > (512 * 1024))) {
43988 + put_page(page);
43989 + return NULL;
43990 + }
43991 +#endif
43992 +
43993 /*
43994 * Limit to 1/4-th the stack size for the argv+env strings.
43995 * This ensures that:
43996 @@ -276,6 +295,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
43997 vma->vm_end = STACK_TOP_MAX;
43998 vma->vm_start = vma->vm_end - PAGE_SIZE;
43999 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
44000 +
44001 +#ifdef CONFIG_PAX_SEGMEXEC
44002 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
44003 +#endif
44004 +
44005 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
44006 INIT_LIST_HEAD(&vma->anon_vma_chain);
44007
44008 @@ -290,6 +314,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
44009 mm->stack_vm = mm->total_vm = 1;
44010 up_write(&mm->mmap_sem);
44011 bprm->p = vma->vm_end - sizeof(void *);
44012 +
44013 +#ifdef CONFIG_PAX_RANDUSTACK
44014 + if (randomize_va_space)
44015 + bprm->p ^= random32() & ~PAGE_MASK;
44016 +#endif
44017 +
44018 return 0;
44019 err:
44020 up_write(&mm->mmap_sem);
44021 @@ -398,19 +428,7 @@ err:
44022 return err;
44023 }
44024
44025 -struct user_arg_ptr {
44026 -#ifdef CONFIG_COMPAT
44027 - bool is_compat;
44028 -#endif
44029 - union {
44030 - const char __user *const __user *native;
44031 -#ifdef CONFIG_COMPAT
44032 - compat_uptr_t __user *compat;
44033 -#endif
44034 - } ptr;
44035 -};
44036 -
44037 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
44038 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
44039 {
44040 const char __user *native;
44041
44042 @@ -419,14 +437,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
44043 compat_uptr_t compat;
44044
44045 if (get_user(compat, argv.ptr.compat + nr))
44046 - return ERR_PTR(-EFAULT);
44047 + return (const char __force_user *)ERR_PTR(-EFAULT);
44048
44049 return compat_ptr(compat);
44050 }
44051 #endif
44052
44053 if (get_user(native, argv.ptr.native + nr))
44054 - return ERR_PTR(-EFAULT);
44055 + return (const char __force_user *)ERR_PTR(-EFAULT);
44056
44057 return native;
44058 }
44059 @@ -445,7 +463,7 @@ static int count(struct user_arg_ptr argv, int max)
44060 if (!p)
44061 break;
44062
44063 - if (IS_ERR(p))
44064 + if (IS_ERR((const char __force_kernel *)p))
44065 return -EFAULT;
44066
44067 if (i++ >= max)
44068 @@ -479,7 +497,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
44069
44070 ret = -EFAULT;
44071 str = get_user_arg_ptr(argv, argc);
44072 - if (IS_ERR(str))
44073 + if (IS_ERR((const char __force_kernel *)str))
44074 goto out;
44075
44076 len = strnlen_user(str, MAX_ARG_STRLEN);
44077 @@ -561,7 +579,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
44078 int r;
44079 mm_segment_t oldfs = get_fs();
44080 struct user_arg_ptr argv = {
44081 - .ptr.native = (const char __user *const __user *)__argv,
44082 + .ptr.native = (const char __force_user *const __force_user *)__argv,
44083 };
44084
44085 set_fs(KERNEL_DS);
44086 @@ -596,7 +614,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
44087 unsigned long new_end = old_end - shift;
44088 struct mmu_gather tlb;
44089
44090 - BUG_ON(new_start > new_end);
44091 + if (new_start >= new_end || new_start < mmap_min_addr)
44092 + return -ENOMEM;
44093
44094 /*
44095 * ensure there are no vmas between where we want to go
44096 @@ -605,6 +624,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
44097 if (vma != find_vma(mm, new_start))
44098 return -EFAULT;
44099
44100 +#ifdef CONFIG_PAX_SEGMEXEC
44101 + BUG_ON(pax_find_mirror_vma(vma));
44102 +#endif
44103 +
44104 /*
44105 * cover the whole range: [new_start, old_end)
44106 */
44107 @@ -685,10 +708,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
44108 stack_top = arch_align_stack(stack_top);
44109 stack_top = PAGE_ALIGN(stack_top);
44110
44111 - if (unlikely(stack_top < mmap_min_addr) ||
44112 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
44113 - return -ENOMEM;
44114 -
44115 stack_shift = vma->vm_end - stack_top;
44116
44117 bprm->p -= stack_shift;
44118 @@ -700,8 +719,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
44119 bprm->exec -= stack_shift;
44120
44121 down_write(&mm->mmap_sem);
44122 +
44123 + /* Move stack pages down in memory. */
44124 + if (stack_shift) {
44125 + ret = shift_arg_pages(vma, stack_shift);
44126 + if (ret)
44127 + goto out_unlock;
44128 + }
44129 +
44130 vm_flags = VM_STACK_FLAGS;
44131
44132 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
44133 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
44134 + vm_flags &= ~VM_EXEC;
44135 +
44136 +#ifdef CONFIG_PAX_MPROTECT
44137 + if (mm->pax_flags & MF_PAX_MPROTECT)
44138 + vm_flags &= ~VM_MAYEXEC;
44139 +#endif
44140 +
44141 + }
44142 +#endif
44143 +
44144 /*
44145 * Adjust stack execute permissions; explicitly enable for
44146 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
44147 @@ -720,13 +759,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
44148 goto out_unlock;
44149 BUG_ON(prev != vma);
44150
44151 - /* Move stack pages down in memory. */
44152 - if (stack_shift) {
44153 - ret = shift_arg_pages(vma, stack_shift);
44154 - if (ret)
44155 - goto out_unlock;
44156 - }
44157 -
44158 /* mprotect_fixup is overkill to remove the temporary stack flags */
44159 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
44160
44161 @@ -807,7 +839,7 @@ int kernel_read(struct file *file, loff_t offset,
44162 old_fs = get_fs();
44163 set_fs(get_ds());
44164 /* The cast to a user pointer is valid due to the set_fs() */
44165 - result = vfs_read(file, (void __user *)addr, count, &pos);
44166 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
44167 set_fs(old_fs);
44168 return result;
44169 }
44170 @@ -1255,7 +1287,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
44171 }
44172 rcu_read_unlock();
44173
44174 - if (p->fs->users > n_fs) {
44175 + if (atomic_read(&p->fs->users) > n_fs) {
44176 bprm->unsafe |= LSM_UNSAFE_SHARE;
44177 } else {
44178 res = -EAGAIN;
44179 @@ -1450,6 +1482,28 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
44180
44181 EXPORT_SYMBOL(search_binary_handler);
44182
44183 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
44184 +static DEFINE_PER_CPU(u64, exec_counter);
44185 +static int __init init_exec_counters(void)
44186 +{
44187 + unsigned int cpu;
44188 +
44189 + for_each_possible_cpu(cpu) {
44190 + per_cpu(exec_counter, cpu) = (u64)cpu;
44191 + }
44192 +
44193 + return 0;
44194 +}
44195 +early_initcall(init_exec_counters);
44196 +static inline void increment_exec_counter(void)
44197 +{
44198 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
44199 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
44200 +}
44201 +#else
44202 +static inline void increment_exec_counter(void) {}
44203 +#endif
44204 +
44205 /*
44206 * sys_execve() executes a new program.
44207 */
44208 @@ -1458,6 +1512,11 @@ static int do_execve_common(const char *filename,
44209 struct user_arg_ptr envp,
44210 struct pt_regs *regs)
44211 {
44212 +#ifdef CONFIG_GRKERNSEC
44213 + struct file *old_exec_file;
44214 + struct acl_subject_label *old_acl;
44215 + struct rlimit old_rlim[RLIM_NLIMITS];
44216 +#endif
44217 struct linux_binprm *bprm;
44218 struct file *file;
44219 struct files_struct *displaced;
44220 @@ -1465,6 +1524,8 @@ static int do_execve_common(const char *filename,
44221 int retval;
44222 const struct cred *cred = current_cred();
44223
44224 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current->cred->user->processes), 1);
44225 +
44226 /*
44227 * We move the actual failure in case of RLIMIT_NPROC excess from
44228 * set*uid() to execve() because too many poorly written programs
44229 @@ -1505,12 +1566,27 @@ static int do_execve_common(const char *filename,
44230 if (IS_ERR(file))
44231 goto out_unmark;
44232
44233 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
44234 + retval = -EPERM;
44235 + goto out_file;
44236 + }
44237 +
44238 sched_exec();
44239
44240 bprm->file = file;
44241 bprm->filename = filename;
44242 bprm->interp = filename;
44243
44244 + if (gr_process_user_ban()) {
44245 + retval = -EPERM;
44246 + goto out_file;
44247 + }
44248 +
44249 + if (!gr_acl_handle_execve(file->f_dentry, file->f_vfsmnt)) {
44250 + retval = -EACCES;
44251 + goto out_file;
44252 + }
44253 +
44254 retval = bprm_mm_init(bprm);
44255 if (retval)
44256 goto out_file;
44257 @@ -1527,24 +1603,65 @@ static int do_execve_common(const char *filename,
44258 if (retval < 0)
44259 goto out;
44260
44261 +#ifdef CONFIG_GRKERNSEC
44262 + old_acl = current->acl;
44263 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
44264 + old_exec_file = current->exec_file;
44265 + get_file(file);
44266 + current->exec_file = file;
44267 +#endif
44268 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
44269 + /* limit suid stack to 8MB
44270 + we saved the old limits above and will restore them if this exec fails
44271 + */
44272 + if (((bprm->cred->euid != current_euid()) || (bprm->cred->egid != current_egid())) &&
44273 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
44274 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
44275 +#endif
44276 +
44277 + if (!gr_tpe_allow(file)) {
44278 + retval = -EACCES;
44279 + goto out_fail;
44280 + }
44281 +
44282 + if (gr_check_crash_exec(file)) {
44283 + retval = -EACCES;
44284 + goto out_fail;
44285 + }
44286 +
44287 + retval = gr_set_proc_label(file->f_dentry, file->f_vfsmnt,
44288 + bprm->unsafe);
44289 + if (retval < 0)
44290 + goto out_fail;
44291 +
44292 retval = copy_strings_kernel(1, &bprm->filename, bprm);
44293 if (retval < 0)
44294 - goto out;
44295 + goto out_fail;
44296
44297 bprm->exec = bprm->p;
44298 retval = copy_strings(bprm->envc, envp, bprm);
44299 if (retval < 0)
44300 - goto out;
44301 + goto out_fail;
44302
44303 retval = copy_strings(bprm->argc, argv, bprm);
44304 if (retval < 0)
44305 - goto out;
44306 + goto out_fail;
44307 +
44308 + gr_log_chroot_exec(file->f_dentry, file->f_vfsmnt);
44309 +
44310 + gr_handle_exec_args(bprm, argv);
44311
44312 retval = search_binary_handler(bprm,regs);
44313 if (retval < 0)
44314 - goto out;
44315 + goto out_fail;
44316 +#ifdef CONFIG_GRKERNSEC
44317 + if (old_exec_file)
44318 + fput(old_exec_file);
44319 +#endif
44320
44321 /* execve succeeded */
44322 +
44323 + increment_exec_counter();
44324 current->fs->in_exec = 0;
44325 current->in_execve = 0;
44326 acct_update_integrals(current);
44327 @@ -1553,6 +1670,14 @@ static int do_execve_common(const char *filename,
44328 put_files_struct(displaced);
44329 return retval;
44330
44331 +out_fail:
44332 +#ifdef CONFIG_GRKERNSEC
44333 + current->acl = old_acl;
44334 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
44335 + fput(current->exec_file);
44336 + current->exec_file = old_exec_file;
44337 +#endif
44338 +
44339 out:
44340 if (bprm->mm) {
44341 acct_arg_size(bprm, 0);
44342 @@ -1626,7 +1751,7 @@ static int expand_corename(struct core_name *cn)
44343 {
44344 char *old_corename = cn->corename;
44345
44346 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
44347 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
44348 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
44349
44350 if (!cn->corename) {
44351 @@ -1723,7 +1848,7 @@ static int format_corename(struct core_name *cn, long signr)
44352 int pid_in_pattern = 0;
44353 int err = 0;
44354
44355 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
44356 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
44357 cn->corename = kmalloc(cn->size, GFP_KERNEL);
44358 cn->used = 0;
44359
44360 @@ -1820,6 +1945,228 @@ out:
44361 return ispipe;
44362 }
44363
44364 +int pax_check_flags(unsigned long *flags)
44365 +{
44366 + int retval = 0;
44367 +
44368 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
44369 + if (*flags & MF_PAX_SEGMEXEC)
44370 + {
44371 + *flags &= ~MF_PAX_SEGMEXEC;
44372 + retval = -EINVAL;
44373 + }
44374 +#endif
44375 +
44376 + if ((*flags & MF_PAX_PAGEEXEC)
44377 +
44378 +#ifdef CONFIG_PAX_PAGEEXEC
44379 + && (*flags & MF_PAX_SEGMEXEC)
44380 +#endif
44381 +
44382 + )
44383 + {
44384 + *flags &= ~MF_PAX_PAGEEXEC;
44385 + retval = -EINVAL;
44386 + }
44387 +
44388 + if ((*flags & MF_PAX_MPROTECT)
44389 +
44390 +#ifdef CONFIG_PAX_MPROTECT
44391 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
44392 +#endif
44393 +
44394 + )
44395 + {
44396 + *flags &= ~MF_PAX_MPROTECT;
44397 + retval = -EINVAL;
44398 + }
44399 +
44400 + if ((*flags & MF_PAX_EMUTRAMP)
44401 +
44402 +#ifdef CONFIG_PAX_EMUTRAMP
44403 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
44404 +#endif
44405 +
44406 + )
44407 + {
44408 + *flags &= ~MF_PAX_EMUTRAMP;
44409 + retval = -EINVAL;
44410 + }
44411 +
44412 + return retval;
44413 +}
44414 +
44415 +EXPORT_SYMBOL(pax_check_flags);
44416 +
44417 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
44418 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
44419 +{
44420 + struct task_struct *tsk = current;
44421 + struct mm_struct *mm = current->mm;
44422 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
44423 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
44424 + char *path_exec = NULL;
44425 + char *path_fault = NULL;
44426 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
44427 +
44428 + if (buffer_exec && buffer_fault) {
44429 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
44430 +
44431 + down_read(&mm->mmap_sem);
44432 + vma = mm->mmap;
44433 + while (vma && (!vma_exec || !vma_fault)) {
44434 + if ((vma->vm_flags & VM_EXECUTABLE) && vma->vm_file)
44435 + vma_exec = vma;
44436 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
44437 + vma_fault = vma;
44438 + vma = vma->vm_next;
44439 + }
44440 + if (vma_exec) {
44441 + path_exec = d_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
44442 + if (IS_ERR(path_exec))
44443 + path_exec = "<path too long>";
44444 + else {
44445 + path_exec = mangle_path(buffer_exec, path_exec, "\t\n\\");
44446 + if (path_exec) {
44447 + *path_exec = 0;
44448 + path_exec = buffer_exec;
44449 + } else
44450 + path_exec = "<path too long>";
44451 + }
44452 + }
44453 + if (vma_fault) {
44454 + start = vma_fault->vm_start;
44455 + end = vma_fault->vm_end;
44456 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
44457 + if (vma_fault->vm_file) {
44458 + path_fault = d_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
44459 + if (IS_ERR(path_fault))
44460 + path_fault = "<path too long>";
44461 + else {
44462 + path_fault = mangle_path(buffer_fault, path_fault, "\t\n\\");
44463 + if (path_fault) {
44464 + *path_fault = 0;
44465 + path_fault = buffer_fault;
44466 + } else
44467 + path_fault = "<path too long>";
44468 + }
44469 + } else
44470 + path_fault = "<anonymous mapping>";
44471 + }
44472 + up_read(&mm->mmap_sem);
44473 + }
44474 + if (tsk->signal->curr_ip)
44475 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
44476 + else
44477 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
44478 + printk(KERN_ERR "PAX: terminating task: %s(%s):%d, uid/euid: %u/%u, "
44479 + "PC: %p, SP: %p\n", path_exec, tsk->comm, task_pid_nr(tsk),
44480 + task_uid(tsk), task_euid(tsk), pc, sp);
44481 + free_page((unsigned long)buffer_exec);
44482 + free_page((unsigned long)buffer_fault);
44483 + pax_report_insns(regs, pc, sp);
44484 + do_coredump(SIGKILL, SIGKILL, regs);
44485 +}
44486 +#endif
44487 +
44488 +#ifdef CONFIG_PAX_REFCOUNT
44489 +void pax_report_refcount_overflow(struct pt_regs *regs)
44490 +{
44491 + if (current->signal->curr_ip)
44492 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
44493 + &current->signal->curr_ip, current->comm, task_pid_nr(current), current_uid(), current_euid());
44494 + else
44495 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
44496 + current->comm, task_pid_nr(current), current_uid(), current_euid());
44497 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
44498 + show_regs(regs);
44499 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
44500 +}
44501 +#endif
44502 +
44503 +#ifdef CONFIG_PAX_USERCOPY
44504 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
44505 +int object_is_on_stack(const void *obj, unsigned long len)
44506 +{
44507 + const void * const stack = task_stack_page(current);
44508 + const void * const stackend = stack + THREAD_SIZE;
44509 +
44510 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
44511 + const void *frame = NULL;
44512 + const void *oldframe;
44513 +#endif
44514 +
44515 + if (obj + len < obj)
44516 + return -1;
44517 +
44518 + if (obj + len <= stack || stackend <= obj)
44519 + return 0;
44520 +
44521 + if (obj < stack || stackend < obj + len)
44522 + return -1;
44523 +
44524 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
44525 + oldframe = __builtin_frame_address(1);
44526 + if (oldframe)
44527 + frame = __builtin_frame_address(2);
44528 + /*
44529 + low ----------------------------------------------> high
44530 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
44531 + ^----------------^
44532 + allow copies only within here
44533 + */
44534 + while (stack <= frame && frame < stackend) {
44535 + /* if obj + len extends past the last frame, this
44536 + check won't pass and the next frame will be 0,
44537 + causing us to bail out and correctly report
44538 + the copy as invalid
44539 + */
44540 + if (obj + len <= frame)
44541 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
44542 + oldframe = frame;
44543 + frame = *(const void * const *)frame;
44544 + }
44545 + return -1;
44546 +#else
44547 + return 1;
44548 +#endif
44549 +}
44550 +
44551 +__noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to, const char *type)
44552 +{
44553 + if (current->signal->curr_ip)
44554 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
44555 + &current->signal->curr_ip, to ? "leak" : "overwrite", to ? "from" : "to", ptr, type ? : "unknown", len);
44556 + else
44557 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
44558 + to ? "leak" : "overwrite", to ? "from" : "to", ptr, type ? : "unknown", len);
44559 + dump_stack();
44560 + gr_handle_kernel_exploit();
44561 + do_group_exit(SIGKILL);
44562 +}
44563 +#endif
44564 +
44565 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
44566 +void pax_track_stack(void)
44567 +{
44568 + unsigned long sp = (unsigned long)&sp;
44569 + if (sp < current_thread_info()->lowest_stack &&
44570 + sp > (unsigned long)task_stack_page(current))
44571 + current_thread_info()->lowest_stack = sp;
44572 +}
44573 +EXPORT_SYMBOL(pax_track_stack);
44574 +#endif
44575 +
44576 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
44577 +void report_size_overflow(const char *file, unsigned int line, const char *func)
44578 +{
44579 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u\n", func, file, line);
44580 + dump_stack();
44581 + do_group_exit(SIGKILL);
44582 +}
44583 +EXPORT_SYMBOL(report_size_overflow);
44584 +#endif
44585 +
44586 static int zap_process(struct task_struct *start, int exit_code)
44587 {
44588 struct task_struct *t;
44589 @@ -2017,17 +2364,17 @@ static void wait_for_dump_helpers(struct file *file)
44590 pipe = file->f_path.dentry->d_inode->i_pipe;
44591
44592 pipe_lock(pipe);
44593 - pipe->readers++;
44594 - pipe->writers--;
44595 + atomic_inc(&pipe->readers);
44596 + atomic_dec(&pipe->writers);
44597
44598 - while ((pipe->readers > 1) && (!signal_pending(current))) {
44599 + while ((atomic_read(&pipe->readers) > 1) && (!signal_pending(current))) {
44600 wake_up_interruptible_sync(&pipe->wait);
44601 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
44602 pipe_wait(pipe);
44603 }
44604
44605 - pipe->readers--;
44606 - pipe->writers++;
44607 + atomic_dec(&pipe->readers);
44608 + atomic_inc(&pipe->writers);
44609 pipe_unlock(pipe);
44610
44611 }
44612 @@ -2088,7 +2435,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
44613 int retval = 0;
44614 int flag = 0;
44615 int ispipe;
44616 - static atomic_t core_dump_count = ATOMIC_INIT(0);
44617 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
44618 struct coredump_params cprm = {
44619 .signr = signr,
44620 .regs = regs,
44621 @@ -2103,6 +2450,9 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
44622
44623 audit_core_dumps(signr);
44624
44625 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
44626 + gr_handle_brute_attach(current, cprm.mm_flags);
44627 +
44628 binfmt = mm->binfmt;
44629 if (!binfmt || !binfmt->core_dump)
44630 goto fail;
44631 @@ -2170,7 +2520,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
44632 }
44633 cprm.limit = RLIM_INFINITY;
44634
44635 - dump_count = atomic_inc_return(&core_dump_count);
44636 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
44637 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
44638 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
44639 task_tgid_vnr(current), current->comm);
44640 @@ -2197,6 +2547,8 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
44641 } else {
44642 struct inode *inode;
44643
44644 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
44645 +
44646 if (cprm.limit < binfmt->min_coredump)
44647 goto fail_unlock;
44648
44649 @@ -2240,7 +2592,7 @@ close_fail:
44650 filp_close(cprm.file, NULL);
44651 fail_dropcount:
44652 if (ispipe)
44653 - atomic_dec(&core_dump_count);
44654 + atomic_dec_unchecked(&core_dump_count);
44655 fail_unlock:
44656 kfree(cn.corename);
44657 fail_corename:
44658 @@ -2259,7 +2611,7 @@ fail:
44659 */
44660 int dump_write(struct file *file, const void *addr, int nr)
44661 {
44662 - return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
44663 + return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
44664 }
44665 EXPORT_SYMBOL(dump_write);
44666
44667 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
44668 index a8cbe1b..fed04cb 100644
44669 --- a/fs/ext2/balloc.c
44670 +++ b/fs/ext2/balloc.c
44671 @@ -1192,7 +1192,7 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
44672
44673 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
44674 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
44675 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
44676 + if (free_blocks < root_blocks + 1 && !capable_nolog(CAP_SYS_RESOURCE) &&
44677 sbi->s_resuid != current_fsuid() &&
44678 (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
44679 return 0;
44680 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
44681 index a203892..4e64db5 100644
44682 --- a/fs/ext3/balloc.c
44683 +++ b/fs/ext3/balloc.c
44684 @@ -1446,9 +1446,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
44685
44686 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
44687 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
44688 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
44689 + if (free_blocks < root_blocks + 1 &&
44690 !use_reservation && sbi->s_resuid != current_fsuid() &&
44691 - (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
44692 + (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid)) &&
44693 + !capable_nolog(CAP_SYS_RESOURCE)) {
44694 return 0;
44695 }
44696 return 1;
44697 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
44698 index f9e2cd8..bfdc476 100644
44699 --- a/fs/ext4/balloc.c
44700 +++ b/fs/ext4/balloc.c
44701 @@ -438,8 +438,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
44702 /* Hm, nope. Are (enough) root reserved clusters available? */
44703 if (sbi->s_resuid == current_fsuid() ||
44704 ((sbi->s_resgid != 0) && in_group_p(sbi->s_resgid)) ||
44705 - capable(CAP_SYS_RESOURCE) ||
44706 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
44707 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
44708 + capable_nolog(CAP_SYS_RESOURCE)) {
44709
44710 if (free_clusters >= (nclusters + dirty_clusters))
44711 return 1;
44712 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
44713 index 9983ba8..2a5272c 100644
44714 --- a/fs/ext4/ext4.h
44715 +++ b/fs/ext4/ext4.h
44716 @@ -1217,19 +1217,19 @@ struct ext4_sb_info {
44717 unsigned long s_mb_last_start;
44718
44719 /* stats for buddy allocator */
44720 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
44721 - atomic_t s_bal_success; /* we found long enough chunks */
44722 - atomic_t s_bal_allocated; /* in blocks */
44723 - atomic_t s_bal_ex_scanned; /* total extents scanned */
44724 - atomic_t s_bal_goals; /* goal hits */
44725 - atomic_t s_bal_breaks; /* too long searches */
44726 - atomic_t s_bal_2orders; /* 2^order hits */
44727 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
44728 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
44729 + atomic_unchecked_t s_bal_allocated; /* in blocks */
44730 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
44731 + atomic_unchecked_t s_bal_goals; /* goal hits */
44732 + atomic_unchecked_t s_bal_breaks; /* too long searches */
44733 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
44734 spinlock_t s_bal_lock;
44735 unsigned long s_mb_buddies_generated;
44736 unsigned long long s_mb_generation_time;
44737 - atomic_t s_mb_lost_chunks;
44738 - atomic_t s_mb_preallocated;
44739 - atomic_t s_mb_discarded;
44740 + atomic_unchecked_t s_mb_lost_chunks;
44741 + atomic_unchecked_t s_mb_preallocated;
44742 + atomic_unchecked_t s_mb_discarded;
44743 atomic_t s_lock_busy;
44744
44745 /* locality groups */
44746 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
44747 index cb990b2..4820141 100644
44748 --- a/fs/ext4/mballoc.c
44749 +++ b/fs/ext4/mballoc.c
44750 @@ -1794,7 +1794,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
44751 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
44752
44753 if (EXT4_SB(sb)->s_mb_stats)
44754 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
44755 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
44756
44757 break;
44758 }
44759 @@ -2088,7 +2088,7 @@ repeat:
44760 ac->ac_status = AC_STATUS_CONTINUE;
44761 ac->ac_flags |= EXT4_MB_HINT_FIRST;
44762 cr = 3;
44763 - atomic_inc(&sbi->s_mb_lost_chunks);
44764 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
44765 goto repeat;
44766 }
44767 }
44768 @@ -2592,25 +2592,25 @@ int ext4_mb_release(struct super_block *sb)
44769 if (sbi->s_mb_stats) {
44770 ext4_msg(sb, KERN_INFO,
44771 "mballoc: %u blocks %u reqs (%u success)",
44772 - atomic_read(&sbi->s_bal_allocated),
44773 - atomic_read(&sbi->s_bal_reqs),
44774 - atomic_read(&sbi->s_bal_success));
44775 + atomic_read_unchecked(&sbi->s_bal_allocated),
44776 + atomic_read_unchecked(&sbi->s_bal_reqs),
44777 + atomic_read_unchecked(&sbi->s_bal_success));
44778 ext4_msg(sb, KERN_INFO,
44779 "mballoc: %u extents scanned, %u goal hits, "
44780 "%u 2^N hits, %u breaks, %u lost",
44781 - atomic_read(&sbi->s_bal_ex_scanned),
44782 - atomic_read(&sbi->s_bal_goals),
44783 - atomic_read(&sbi->s_bal_2orders),
44784 - atomic_read(&sbi->s_bal_breaks),
44785 - atomic_read(&sbi->s_mb_lost_chunks));
44786 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
44787 + atomic_read_unchecked(&sbi->s_bal_goals),
44788 + atomic_read_unchecked(&sbi->s_bal_2orders),
44789 + atomic_read_unchecked(&sbi->s_bal_breaks),
44790 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
44791 ext4_msg(sb, KERN_INFO,
44792 "mballoc: %lu generated and it took %Lu",
44793 sbi->s_mb_buddies_generated,
44794 sbi->s_mb_generation_time);
44795 ext4_msg(sb, KERN_INFO,
44796 "mballoc: %u preallocated, %u discarded",
44797 - atomic_read(&sbi->s_mb_preallocated),
44798 - atomic_read(&sbi->s_mb_discarded));
44799 + atomic_read_unchecked(&sbi->s_mb_preallocated),
44800 + atomic_read_unchecked(&sbi->s_mb_discarded));
44801 }
44802
44803 free_percpu(sbi->s_locality_groups);
44804 @@ -3096,16 +3096,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
44805 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
44806
44807 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
44808 - atomic_inc(&sbi->s_bal_reqs);
44809 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
44810 + atomic_inc_unchecked(&sbi->s_bal_reqs);
44811 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
44812 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
44813 - atomic_inc(&sbi->s_bal_success);
44814 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
44815 + atomic_inc_unchecked(&sbi->s_bal_success);
44816 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
44817 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
44818 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
44819 - atomic_inc(&sbi->s_bal_goals);
44820 + atomic_inc_unchecked(&sbi->s_bal_goals);
44821 if (ac->ac_found > sbi->s_mb_max_to_scan)
44822 - atomic_inc(&sbi->s_bal_breaks);
44823 + atomic_inc_unchecked(&sbi->s_bal_breaks);
44824 }
44825
44826 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
44827 @@ -3509,7 +3509,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
44828 trace_ext4_mb_new_inode_pa(ac, pa);
44829
44830 ext4_mb_use_inode_pa(ac, pa);
44831 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
44832 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
44833
44834 ei = EXT4_I(ac->ac_inode);
44835 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
44836 @@ -3569,7 +3569,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
44837 trace_ext4_mb_new_group_pa(ac, pa);
44838
44839 ext4_mb_use_group_pa(ac, pa);
44840 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
44841 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
44842
44843 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
44844 lg = ac->ac_lg;
44845 @@ -3658,7 +3658,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
44846 * from the bitmap and continue.
44847 */
44848 }
44849 - atomic_add(free, &sbi->s_mb_discarded);
44850 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
44851
44852 return err;
44853 }
44854 @@ -3676,7 +3676,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
44855 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
44856 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
44857 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
44858 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
44859 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
44860 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
44861
44862 return 0;
44863 diff --git a/fs/fcntl.c b/fs/fcntl.c
44864 index 22764c7..86372c9 100644
44865 --- a/fs/fcntl.c
44866 +++ b/fs/fcntl.c
44867 @@ -224,6 +224,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
44868 if (err)
44869 return err;
44870
44871 + if (gr_handle_chroot_fowner(pid, type))
44872 + return -ENOENT;
44873 + if (gr_check_protected_task_fowner(pid, type))
44874 + return -EACCES;
44875 +
44876 f_modown(filp, pid, type, force);
44877 return 0;
44878 }
44879 @@ -266,7 +271,7 @@ pid_t f_getown(struct file *filp)
44880
44881 static int f_setown_ex(struct file *filp, unsigned long arg)
44882 {
44883 - struct f_owner_ex * __user owner_p = (void * __user)arg;
44884 + struct f_owner_ex __user *owner_p = (void __user *)arg;
44885 struct f_owner_ex owner;
44886 struct pid *pid;
44887 int type;
44888 @@ -306,7 +311,7 @@ static int f_setown_ex(struct file *filp, unsigned long arg)
44889
44890 static int f_getown_ex(struct file *filp, unsigned long arg)
44891 {
44892 - struct f_owner_ex * __user owner_p = (void * __user)arg;
44893 + struct f_owner_ex __user *owner_p = (void __user *)arg;
44894 struct f_owner_ex owner;
44895 int ret = 0;
44896
44897 @@ -348,6 +353,7 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
44898 switch (cmd) {
44899 case F_DUPFD:
44900 case F_DUPFD_CLOEXEC:
44901 + gr_learn_resource(current, RLIMIT_NOFILE, arg, 0);
44902 if (arg >= rlimit(RLIMIT_NOFILE))
44903 break;
44904 err = alloc_fd(arg, cmd == F_DUPFD_CLOEXEC ? O_CLOEXEC : 0);
44905 diff --git a/fs/fifo.c b/fs/fifo.c
44906 index b1a524d..4ee270e 100644
44907 --- a/fs/fifo.c
44908 +++ b/fs/fifo.c
44909 @@ -58,10 +58,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
44910 */
44911 filp->f_op = &read_pipefifo_fops;
44912 pipe->r_counter++;
44913 - if (pipe->readers++ == 0)
44914 + if (atomic_inc_return(&pipe->readers) == 1)
44915 wake_up_partner(inode);
44916
44917 - if (!pipe->writers) {
44918 + if (!atomic_read(&pipe->writers)) {
44919 if ((filp->f_flags & O_NONBLOCK)) {
44920 /* suppress POLLHUP until we have
44921 * seen a writer */
44922 @@ -81,15 +81,15 @@ static int fifo_open(struct inode *inode, struct file *filp)
44923 * errno=ENXIO when there is no process reading the FIFO.
44924 */
44925 ret = -ENXIO;
44926 - if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
44927 + if ((filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
44928 goto err;
44929
44930 filp->f_op = &write_pipefifo_fops;
44931 pipe->w_counter++;
44932 - if (!pipe->writers++)
44933 + if (atomic_inc_return(&pipe->writers) == 1)
44934 wake_up_partner(inode);
44935
44936 - if (!pipe->readers) {
44937 + if (!atomic_read(&pipe->readers)) {
44938 wait_for_partner(inode, &pipe->r_counter);
44939 if (signal_pending(current))
44940 goto err_wr;
44941 @@ -105,11 +105,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
44942 */
44943 filp->f_op = &rdwr_pipefifo_fops;
44944
44945 - pipe->readers++;
44946 - pipe->writers++;
44947 + atomic_inc(&pipe->readers);
44948 + atomic_inc(&pipe->writers);
44949 pipe->r_counter++;
44950 pipe->w_counter++;
44951 - if (pipe->readers == 1 || pipe->writers == 1)
44952 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
44953 wake_up_partner(inode);
44954 break;
44955
44956 @@ -123,19 +123,19 @@ static int fifo_open(struct inode *inode, struct file *filp)
44957 return 0;
44958
44959 err_rd:
44960 - if (!--pipe->readers)
44961 + if (atomic_dec_and_test(&pipe->readers))
44962 wake_up_interruptible(&pipe->wait);
44963 ret = -ERESTARTSYS;
44964 goto err;
44965
44966 err_wr:
44967 - if (!--pipe->writers)
44968 + if (atomic_dec_and_test(&pipe->writers))
44969 wake_up_interruptible(&pipe->wait);
44970 ret = -ERESTARTSYS;
44971 goto err;
44972
44973 err:
44974 - if (!pipe->readers && !pipe->writers)
44975 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers))
44976 free_pipe_info(inode);
44977
44978 err_nocleanup:
44979 diff --git a/fs/file.c b/fs/file.c
44980 index 4c6992d..104cdea 100644
44981 --- a/fs/file.c
44982 +++ b/fs/file.c
44983 @@ -15,6 +15,7 @@
44984 #include <linux/slab.h>
44985 #include <linux/vmalloc.h>
44986 #include <linux/file.h>
44987 +#include <linux/security.h>
44988 #include <linux/fdtable.h>
44989 #include <linux/bitops.h>
44990 #include <linux/interrupt.h>
44991 @@ -254,6 +255,7 @@ int expand_files(struct files_struct *files, int nr)
44992 * N.B. For clone tasks sharing a files structure, this test
44993 * will limit the total number of files that can be opened.
44994 */
44995 + gr_learn_resource(current, RLIMIT_NOFILE, nr, 0);
44996 if (nr >= rlimit(RLIMIT_NOFILE))
44997 return -EMFILE;
44998
44999 diff --git a/fs/filesystems.c b/fs/filesystems.c
45000 index 96f2428..f5eeb8e 100644
45001 --- a/fs/filesystems.c
45002 +++ b/fs/filesystems.c
45003 @@ -273,7 +273,12 @@ struct file_system_type *get_fs_type(const char *name)
45004 int len = dot ? dot - name : strlen(name);
45005
45006 fs = __get_fs_type(name, len);
45007 +
45008 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
45009 + if (!fs && (___request_module(true, "grsec_modharden_fs", "%.*s", len, name) == 0))
45010 +#else
45011 if (!fs && (request_module("%.*s", len, name) == 0))
45012 +#endif
45013 fs = __get_fs_type(name, len);
45014
45015 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
45016 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
45017 index 78b519c..a8b4979 100644
45018 --- a/fs/fs_struct.c
45019 +++ b/fs/fs_struct.c
45020 @@ -4,6 +4,7 @@
45021 #include <linux/path.h>
45022 #include <linux/slab.h>
45023 #include <linux/fs_struct.h>
45024 +#include <linux/grsecurity.h>
45025 #include "internal.h"
45026
45027 static inline void path_get_longterm(struct path *path)
45028 @@ -31,6 +32,7 @@ void set_fs_root(struct fs_struct *fs, struct path *path)
45029 old_root = fs->root;
45030 fs->root = *path;
45031 path_get_longterm(path);
45032 + gr_set_chroot_entries(current, path);
45033 write_seqcount_end(&fs->seq);
45034 spin_unlock(&fs->lock);
45035 if (old_root.dentry)
45036 @@ -74,6 +76,7 @@ void chroot_fs_refs(struct path *old_root, struct path *new_root)
45037 && fs->root.mnt == old_root->mnt) {
45038 path_get_longterm(new_root);
45039 fs->root = *new_root;
45040 + gr_set_chroot_entries(p, new_root);
45041 count++;
45042 }
45043 if (fs->pwd.dentry == old_root->dentry
45044 @@ -109,7 +112,8 @@ void exit_fs(struct task_struct *tsk)
45045 spin_lock(&fs->lock);
45046 write_seqcount_begin(&fs->seq);
45047 tsk->fs = NULL;
45048 - kill = !--fs->users;
45049 + gr_clear_chroot_entries(tsk);
45050 + kill = !atomic_dec_return(&fs->users);
45051 write_seqcount_end(&fs->seq);
45052 spin_unlock(&fs->lock);
45053 task_unlock(tsk);
45054 @@ -123,7 +127,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
45055 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
45056 /* We don't need to lock fs - think why ;-) */
45057 if (fs) {
45058 - fs->users = 1;
45059 + atomic_set(&fs->users, 1);
45060 fs->in_exec = 0;
45061 spin_lock_init(&fs->lock);
45062 seqcount_init(&fs->seq);
45063 @@ -132,6 +136,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
45064 spin_lock(&old->lock);
45065 fs->root = old->root;
45066 path_get_longterm(&fs->root);
45067 + /* instead of calling gr_set_chroot_entries here,
45068 + we call it from every caller of this function
45069 + */
45070 fs->pwd = old->pwd;
45071 path_get_longterm(&fs->pwd);
45072 spin_unlock(&old->lock);
45073 @@ -150,8 +157,9 @@ int unshare_fs_struct(void)
45074
45075 task_lock(current);
45076 spin_lock(&fs->lock);
45077 - kill = !--fs->users;
45078 + kill = !atomic_dec_return(&fs->users);
45079 current->fs = new_fs;
45080 + gr_set_chroot_entries(current, &new_fs->root);
45081 spin_unlock(&fs->lock);
45082 task_unlock(current);
45083
45084 @@ -164,13 +172,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
45085
45086 int current_umask(void)
45087 {
45088 - return current->fs->umask;
45089 + return current->fs->umask | gr_acl_umask();
45090 }
45091 EXPORT_SYMBOL(current_umask);
45092
45093 /* to be mentioned only in INIT_TASK */
45094 struct fs_struct init_fs = {
45095 - .users = 1,
45096 + .users = ATOMIC_INIT(1),
45097 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
45098 .seq = SEQCNT_ZERO,
45099 .umask = 0022,
45100 @@ -186,12 +194,13 @@ void daemonize_fs_struct(void)
45101 task_lock(current);
45102
45103 spin_lock(&init_fs.lock);
45104 - init_fs.users++;
45105 + atomic_inc(&init_fs.users);
45106 spin_unlock(&init_fs.lock);
45107
45108 spin_lock(&fs->lock);
45109 current->fs = &init_fs;
45110 - kill = !--fs->users;
45111 + gr_set_chroot_entries(current, &current->fs->root);
45112 + kill = !atomic_dec_return(&fs->users);
45113 spin_unlock(&fs->lock);
45114
45115 task_unlock(current);
45116 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
45117 index 9905350..02eaec4 100644
45118 --- a/fs/fscache/cookie.c
45119 +++ b/fs/fscache/cookie.c
45120 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
45121 parent ? (char *) parent->def->name : "<no-parent>",
45122 def->name, netfs_data);
45123
45124 - fscache_stat(&fscache_n_acquires);
45125 + fscache_stat_unchecked(&fscache_n_acquires);
45126
45127 /* if there's no parent cookie, then we don't create one here either */
45128 if (!parent) {
45129 - fscache_stat(&fscache_n_acquires_null);
45130 + fscache_stat_unchecked(&fscache_n_acquires_null);
45131 _leave(" [no parent]");
45132 return NULL;
45133 }
45134 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
45135 /* allocate and initialise a cookie */
45136 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
45137 if (!cookie) {
45138 - fscache_stat(&fscache_n_acquires_oom);
45139 + fscache_stat_unchecked(&fscache_n_acquires_oom);
45140 _leave(" [ENOMEM]");
45141 return NULL;
45142 }
45143 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
45144
45145 switch (cookie->def->type) {
45146 case FSCACHE_COOKIE_TYPE_INDEX:
45147 - fscache_stat(&fscache_n_cookie_index);
45148 + fscache_stat_unchecked(&fscache_n_cookie_index);
45149 break;
45150 case FSCACHE_COOKIE_TYPE_DATAFILE:
45151 - fscache_stat(&fscache_n_cookie_data);
45152 + fscache_stat_unchecked(&fscache_n_cookie_data);
45153 break;
45154 default:
45155 - fscache_stat(&fscache_n_cookie_special);
45156 + fscache_stat_unchecked(&fscache_n_cookie_special);
45157 break;
45158 }
45159
45160 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
45161 if (fscache_acquire_non_index_cookie(cookie) < 0) {
45162 atomic_dec(&parent->n_children);
45163 __fscache_cookie_put(cookie);
45164 - fscache_stat(&fscache_n_acquires_nobufs);
45165 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
45166 _leave(" = NULL");
45167 return NULL;
45168 }
45169 }
45170
45171 - fscache_stat(&fscache_n_acquires_ok);
45172 + fscache_stat_unchecked(&fscache_n_acquires_ok);
45173 _leave(" = %p", cookie);
45174 return cookie;
45175 }
45176 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
45177 cache = fscache_select_cache_for_object(cookie->parent);
45178 if (!cache) {
45179 up_read(&fscache_addremove_sem);
45180 - fscache_stat(&fscache_n_acquires_no_cache);
45181 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
45182 _leave(" = -ENOMEDIUM [no cache]");
45183 return -ENOMEDIUM;
45184 }
45185 @@ -256,12 +256,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
45186 object = cache->ops->alloc_object(cache, cookie);
45187 fscache_stat_d(&fscache_n_cop_alloc_object);
45188 if (IS_ERR(object)) {
45189 - fscache_stat(&fscache_n_object_no_alloc);
45190 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
45191 ret = PTR_ERR(object);
45192 goto error;
45193 }
45194
45195 - fscache_stat(&fscache_n_object_alloc);
45196 + fscache_stat_unchecked(&fscache_n_object_alloc);
45197
45198 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
45199
45200 @@ -377,10 +377,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
45201 struct fscache_object *object;
45202 struct hlist_node *_p;
45203
45204 - fscache_stat(&fscache_n_updates);
45205 + fscache_stat_unchecked(&fscache_n_updates);
45206
45207 if (!cookie) {
45208 - fscache_stat(&fscache_n_updates_null);
45209 + fscache_stat_unchecked(&fscache_n_updates_null);
45210 _leave(" [no cookie]");
45211 return;
45212 }
45213 @@ -414,12 +414,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
45214 struct fscache_object *object;
45215 unsigned long event;
45216
45217 - fscache_stat(&fscache_n_relinquishes);
45218 + fscache_stat_unchecked(&fscache_n_relinquishes);
45219 if (retire)
45220 - fscache_stat(&fscache_n_relinquishes_retire);
45221 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
45222
45223 if (!cookie) {
45224 - fscache_stat(&fscache_n_relinquishes_null);
45225 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
45226 _leave(" [no cookie]");
45227 return;
45228 }
45229 @@ -435,7 +435,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
45230
45231 /* wait for the cookie to finish being instantiated (or to fail) */
45232 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
45233 - fscache_stat(&fscache_n_relinquishes_waitcrt);
45234 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
45235 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
45236 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
45237 }
45238 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
45239 index f6aad48..88dcf26 100644
45240 --- a/fs/fscache/internal.h
45241 +++ b/fs/fscache/internal.h
45242 @@ -144,94 +144,94 @@ extern void fscache_proc_cleanup(void);
45243 extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
45244 extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
45245
45246 -extern atomic_t fscache_n_op_pend;
45247 -extern atomic_t fscache_n_op_run;
45248 -extern atomic_t fscache_n_op_enqueue;
45249 -extern atomic_t fscache_n_op_deferred_release;
45250 -extern atomic_t fscache_n_op_release;
45251 -extern atomic_t fscache_n_op_gc;
45252 -extern atomic_t fscache_n_op_cancelled;
45253 -extern atomic_t fscache_n_op_rejected;
45254 +extern atomic_unchecked_t fscache_n_op_pend;
45255 +extern atomic_unchecked_t fscache_n_op_run;
45256 +extern atomic_unchecked_t fscache_n_op_enqueue;
45257 +extern atomic_unchecked_t fscache_n_op_deferred_release;
45258 +extern atomic_unchecked_t fscache_n_op_release;
45259 +extern atomic_unchecked_t fscache_n_op_gc;
45260 +extern atomic_unchecked_t fscache_n_op_cancelled;
45261 +extern atomic_unchecked_t fscache_n_op_rejected;
45262
45263 -extern atomic_t fscache_n_attr_changed;
45264 -extern atomic_t fscache_n_attr_changed_ok;
45265 -extern atomic_t fscache_n_attr_changed_nobufs;
45266 -extern atomic_t fscache_n_attr_changed_nomem;
45267 -extern atomic_t fscache_n_attr_changed_calls;
45268 +extern atomic_unchecked_t fscache_n_attr_changed;
45269 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
45270 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
45271 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
45272 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
45273
45274 -extern atomic_t fscache_n_allocs;
45275 -extern atomic_t fscache_n_allocs_ok;
45276 -extern atomic_t fscache_n_allocs_wait;
45277 -extern atomic_t fscache_n_allocs_nobufs;
45278 -extern atomic_t fscache_n_allocs_intr;
45279 -extern atomic_t fscache_n_allocs_object_dead;
45280 -extern atomic_t fscache_n_alloc_ops;
45281 -extern atomic_t fscache_n_alloc_op_waits;
45282 +extern atomic_unchecked_t fscache_n_allocs;
45283 +extern atomic_unchecked_t fscache_n_allocs_ok;
45284 +extern atomic_unchecked_t fscache_n_allocs_wait;
45285 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
45286 +extern atomic_unchecked_t fscache_n_allocs_intr;
45287 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
45288 +extern atomic_unchecked_t fscache_n_alloc_ops;
45289 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
45290
45291 -extern atomic_t fscache_n_retrievals;
45292 -extern atomic_t fscache_n_retrievals_ok;
45293 -extern atomic_t fscache_n_retrievals_wait;
45294 -extern atomic_t fscache_n_retrievals_nodata;
45295 -extern atomic_t fscache_n_retrievals_nobufs;
45296 -extern atomic_t fscache_n_retrievals_intr;
45297 -extern atomic_t fscache_n_retrievals_nomem;
45298 -extern atomic_t fscache_n_retrievals_object_dead;
45299 -extern atomic_t fscache_n_retrieval_ops;
45300 -extern atomic_t fscache_n_retrieval_op_waits;
45301 +extern atomic_unchecked_t fscache_n_retrievals;
45302 +extern atomic_unchecked_t fscache_n_retrievals_ok;
45303 +extern atomic_unchecked_t fscache_n_retrievals_wait;
45304 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
45305 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
45306 +extern atomic_unchecked_t fscache_n_retrievals_intr;
45307 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
45308 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
45309 +extern atomic_unchecked_t fscache_n_retrieval_ops;
45310 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
45311
45312 -extern atomic_t fscache_n_stores;
45313 -extern atomic_t fscache_n_stores_ok;
45314 -extern atomic_t fscache_n_stores_again;
45315 -extern atomic_t fscache_n_stores_nobufs;
45316 -extern atomic_t fscache_n_stores_oom;
45317 -extern atomic_t fscache_n_store_ops;
45318 -extern atomic_t fscache_n_store_calls;
45319 -extern atomic_t fscache_n_store_pages;
45320 -extern atomic_t fscache_n_store_radix_deletes;
45321 -extern atomic_t fscache_n_store_pages_over_limit;
45322 +extern atomic_unchecked_t fscache_n_stores;
45323 +extern atomic_unchecked_t fscache_n_stores_ok;
45324 +extern atomic_unchecked_t fscache_n_stores_again;
45325 +extern atomic_unchecked_t fscache_n_stores_nobufs;
45326 +extern atomic_unchecked_t fscache_n_stores_oom;
45327 +extern atomic_unchecked_t fscache_n_store_ops;
45328 +extern atomic_unchecked_t fscache_n_store_calls;
45329 +extern atomic_unchecked_t fscache_n_store_pages;
45330 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
45331 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
45332
45333 -extern atomic_t fscache_n_store_vmscan_not_storing;
45334 -extern atomic_t fscache_n_store_vmscan_gone;
45335 -extern atomic_t fscache_n_store_vmscan_busy;
45336 -extern atomic_t fscache_n_store_vmscan_cancelled;
45337 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
45338 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
45339 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
45340 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
45341
45342 -extern atomic_t fscache_n_marks;
45343 -extern atomic_t fscache_n_uncaches;
45344 +extern atomic_unchecked_t fscache_n_marks;
45345 +extern atomic_unchecked_t fscache_n_uncaches;
45346
45347 -extern atomic_t fscache_n_acquires;
45348 -extern atomic_t fscache_n_acquires_null;
45349 -extern atomic_t fscache_n_acquires_no_cache;
45350 -extern atomic_t fscache_n_acquires_ok;
45351 -extern atomic_t fscache_n_acquires_nobufs;
45352 -extern atomic_t fscache_n_acquires_oom;
45353 +extern atomic_unchecked_t fscache_n_acquires;
45354 +extern atomic_unchecked_t fscache_n_acquires_null;
45355 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
45356 +extern atomic_unchecked_t fscache_n_acquires_ok;
45357 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
45358 +extern atomic_unchecked_t fscache_n_acquires_oom;
45359
45360 -extern atomic_t fscache_n_updates;
45361 -extern atomic_t fscache_n_updates_null;
45362 -extern atomic_t fscache_n_updates_run;
45363 +extern atomic_unchecked_t fscache_n_updates;
45364 +extern atomic_unchecked_t fscache_n_updates_null;
45365 +extern atomic_unchecked_t fscache_n_updates_run;
45366
45367 -extern atomic_t fscache_n_relinquishes;
45368 -extern atomic_t fscache_n_relinquishes_null;
45369 -extern atomic_t fscache_n_relinquishes_waitcrt;
45370 -extern atomic_t fscache_n_relinquishes_retire;
45371 +extern atomic_unchecked_t fscache_n_relinquishes;
45372 +extern atomic_unchecked_t fscache_n_relinquishes_null;
45373 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
45374 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
45375
45376 -extern atomic_t fscache_n_cookie_index;
45377 -extern atomic_t fscache_n_cookie_data;
45378 -extern atomic_t fscache_n_cookie_special;
45379 +extern atomic_unchecked_t fscache_n_cookie_index;
45380 +extern atomic_unchecked_t fscache_n_cookie_data;
45381 +extern atomic_unchecked_t fscache_n_cookie_special;
45382
45383 -extern atomic_t fscache_n_object_alloc;
45384 -extern atomic_t fscache_n_object_no_alloc;
45385 -extern atomic_t fscache_n_object_lookups;
45386 -extern atomic_t fscache_n_object_lookups_negative;
45387 -extern atomic_t fscache_n_object_lookups_positive;
45388 -extern atomic_t fscache_n_object_lookups_timed_out;
45389 -extern atomic_t fscache_n_object_created;
45390 -extern atomic_t fscache_n_object_avail;
45391 -extern atomic_t fscache_n_object_dead;
45392 +extern atomic_unchecked_t fscache_n_object_alloc;
45393 +extern atomic_unchecked_t fscache_n_object_no_alloc;
45394 +extern atomic_unchecked_t fscache_n_object_lookups;
45395 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
45396 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
45397 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
45398 +extern atomic_unchecked_t fscache_n_object_created;
45399 +extern atomic_unchecked_t fscache_n_object_avail;
45400 +extern atomic_unchecked_t fscache_n_object_dead;
45401
45402 -extern atomic_t fscache_n_checkaux_none;
45403 -extern atomic_t fscache_n_checkaux_okay;
45404 -extern atomic_t fscache_n_checkaux_update;
45405 -extern atomic_t fscache_n_checkaux_obsolete;
45406 +extern atomic_unchecked_t fscache_n_checkaux_none;
45407 +extern atomic_unchecked_t fscache_n_checkaux_okay;
45408 +extern atomic_unchecked_t fscache_n_checkaux_update;
45409 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
45410
45411 extern atomic_t fscache_n_cop_alloc_object;
45412 extern atomic_t fscache_n_cop_lookup_object;
45413 @@ -255,6 +255,11 @@ static inline void fscache_stat(atomic_t *stat)
45414 atomic_inc(stat);
45415 }
45416
45417 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
45418 +{
45419 + atomic_inc_unchecked(stat);
45420 +}
45421 +
45422 static inline void fscache_stat_d(atomic_t *stat)
45423 {
45424 atomic_dec(stat);
45425 @@ -267,6 +272,7 @@ extern const struct file_operations fscache_stats_fops;
45426
45427 #define __fscache_stat(stat) (NULL)
45428 #define fscache_stat(stat) do {} while (0)
45429 +#define fscache_stat_unchecked(stat) do {} while (0)
45430 #define fscache_stat_d(stat) do {} while (0)
45431 #endif
45432
45433 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
45434 index b6b897c..0ffff9c 100644
45435 --- a/fs/fscache/object.c
45436 +++ b/fs/fscache/object.c
45437 @@ -128,7 +128,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
45438 /* update the object metadata on disk */
45439 case FSCACHE_OBJECT_UPDATING:
45440 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
45441 - fscache_stat(&fscache_n_updates_run);
45442 + fscache_stat_unchecked(&fscache_n_updates_run);
45443 fscache_stat(&fscache_n_cop_update_object);
45444 object->cache->ops->update_object(object);
45445 fscache_stat_d(&fscache_n_cop_update_object);
45446 @@ -217,7 +217,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
45447 spin_lock(&object->lock);
45448 object->state = FSCACHE_OBJECT_DEAD;
45449 spin_unlock(&object->lock);
45450 - fscache_stat(&fscache_n_object_dead);
45451 + fscache_stat_unchecked(&fscache_n_object_dead);
45452 goto terminal_transit;
45453
45454 /* handle the parent cache of this object being withdrawn from
45455 @@ -232,7 +232,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
45456 spin_lock(&object->lock);
45457 object->state = FSCACHE_OBJECT_DEAD;
45458 spin_unlock(&object->lock);
45459 - fscache_stat(&fscache_n_object_dead);
45460 + fscache_stat_unchecked(&fscache_n_object_dead);
45461 goto terminal_transit;
45462
45463 /* complain about the object being woken up once it is
45464 @@ -461,7 +461,7 @@ static void fscache_lookup_object(struct fscache_object *object)
45465 parent->cookie->def->name, cookie->def->name,
45466 object->cache->tag->name);
45467
45468 - fscache_stat(&fscache_n_object_lookups);
45469 + fscache_stat_unchecked(&fscache_n_object_lookups);
45470 fscache_stat(&fscache_n_cop_lookup_object);
45471 ret = object->cache->ops->lookup_object(object);
45472 fscache_stat_d(&fscache_n_cop_lookup_object);
45473 @@ -472,7 +472,7 @@ static void fscache_lookup_object(struct fscache_object *object)
45474 if (ret == -ETIMEDOUT) {
45475 /* probably stuck behind another object, so move this one to
45476 * the back of the queue */
45477 - fscache_stat(&fscache_n_object_lookups_timed_out);
45478 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
45479 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
45480 }
45481
45482 @@ -495,7 +495,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
45483
45484 spin_lock(&object->lock);
45485 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
45486 - fscache_stat(&fscache_n_object_lookups_negative);
45487 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
45488
45489 /* transit here to allow write requests to begin stacking up
45490 * and read requests to begin returning ENODATA */
45491 @@ -541,7 +541,7 @@ void fscache_obtained_object(struct fscache_object *object)
45492 * result, in which case there may be data available */
45493 spin_lock(&object->lock);
45494 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
45495 - fscache_stat(&fscache_n_object_lookups_positive);
45496 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
45497
45498 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
45499
45500 @@ -555,7 +555,7 @@ void fscache_obtained_object(struct fscache_object *object)
45501 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
45502 } else {
45503 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
45504 - fscache_stat(&fscache_n_object_created);
45505 + fscache_stat_unchecked(&fscache_n_object_created);
45506
45507 object->state = FSCACHE_OBJECT_AVAILABLE;
45508 spin_unlock(&object->lock);
45509 @@ -602,7 +602,7 @@ static void fscache_object_available(struct fscache_object *object)
45510 fscache_enqueue_dependents(object);
45511
45512 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
45513 - fscache_stat(&fscache_n_object_avail);
45514 + fscache_stat_unchecked(&fscache_n_object_avail);
45515
45516 _leave("");
45517 }
45518 @@ -861,7 +861,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
45519 enum fscache_checkaux result;
45520
45521 if (!object->cookie->def->check_aux) {
45522 - fscache_stat(&fscache_n_checkaux_none);
45523 + fscache_stat_unchecked(&fscache_n_checkaux_none);
45524 return FSCACHE_CHECKAUX_OKAY;
45525 }
45526
45527 @@ -870,17 +870,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
45528 switch (result) {
45529 /* entry okay as is */
45530 case FSCACHE_CHECKAUX_OKAY:
45531 - fscache_stat(&fscache_n_checkaux_okay);
45532 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
45533 break;
45534
45535 /* entry requires update */
45536 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
45537 - fscache_stat(&fscache_n_checkaux_update);
45538 + fscache_stat_unchecked(&fscache_n_checkaux_update);
45539 break;
45540
45541 /* entry requires deletion */
45542 case FSCACHE_CHECKAUX_OBSOLETE:
45543 - fscache_stat(&fscache_n_checkaux_obsolete);
45544 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
45545 break;
45546
45547 default:
45548 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
45549 index 30afdfa..2256596 100644
45550 --- a/fs/fscache/operation.c
45551 +++ b/fs/fscache/operation.c
45552 @@ -17,7 +17,7 @@
45553 #include <linux/slab.h>
45554 #include "internal.h"
45555
45556 -atomic_t fscache_op_debug_id;
45557 +atomic_unchecked_t fscache_op_debug_id;
45558 EXPORT_SYMBOL(fscache_op_debug_id);
45559
45560 /**
45561 @@ -38,7 +38,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
45562 ASSERTCMP(op->object->state, >=, FSCACHE_OBJECT_AVAILABLE);
45563 ASSERTCMP(atomic_read(&op->usage), >, 0);
45564
45565 - fscache_stat(&fscache_n_op_enqueue);
45566 + fscache_stat_unchecked(&fscache_n_op_enqueue);
45567 switch (op->flags & FSCACHE_OP_TYPE) {
45568 case FSCACHE_OP_ASYNC:
45569 _debug("queue async");
45570 @@ -69,7 +69,7 @@ static void fscache_run_op(struct fscache_object *object,
45571 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
45572 if (op->processor)
45573 fscache_enqueue_operation(op);
45574 - fscache_stat(&fscache_n_op_run);
45575 + fscache_stat_unchecked(&fscache_n_op_run);
45576 }
45577
45578 /*
45579 @@ -98,11 +98,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
45580 if (object->n_ops > 1) {
45581 atomic_inc(&op->usage);
45582 list_add_tail(&op->pend_link, &object->pending_ops);
45583 - fscache_stat(&fscache_n_op_pend);
45584 + fscache_stat_unchecked(&fscache_n_op_pend);
45585 } else if (!list_empty(&object->pending_ops)) {
45586 atomic_inc(&op->usage);
45587 list_add_tail(&op->pend_link, &object->pending_ops);
45588 - fscache_stat(&fscache_n_op_pend);
45589 + fscache_stat_unchecked(&fscache_n_op_pend);
45590 fscache_start_operations(object);
45591 } else {
45592 ASSERTCMP(object->n_in_progress, ==, 0);
45593 @@ -118,7 +118,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
45594 object->n_exclusive++; /* reads and writes must wait */
45595 atomic_inc(&op->usage);
45596 list_add_tail(&op->pend_link, &object->pending_ops);
45597 - fscache_stat(&fscache_n_op_pend);
45598 + fscache_stat_unchecked(&fscache_n_op_pend);
45599 ret = 0;
45600 } else {
45601 /* not allowed to submit ops in any other state */
45602 @@ -203,11 +203,11 @@ int fscache_submit_op(struct fscache_object *object,
45603 if (object->n_exclusive > 0) {
45604 atomic_inc(&op->usage);
45605 list_add_tail(&op->pend_link, &object->pending_ops);
45606 - fscache_stat(&fscache_n_op_pend);
45607 + fscache_stat_unchecked(&fscache_n_op_pend);
45608 } else if (!list_empty(&object->pending_ops)) {
45609 atomic_inc(&op->usage);
45610 list_add_tail(&op->pend_link, &object->pending_ops);
45611 - fscache_stat(&fscache_n_op_pend);
45612 + fscache_stat_unchecked(&fscache_n_op_pend);
45613 fscache_start_operations(object);
45614 } else {
45615 ASSERTCMP(object->n_exclusive, ==, 0);
45616 @@ -219,12 +219,12 @@ int fscache_submit_op(struct fscache_object *object,
45617 object->n_ops++;
45618 atomic_inc(&op->usage);
45619 list_add_tail(&op->pend_link, &object->pending_ops);
45620 - fscache_stat(&fscache_n_op_pend);
45621 + fscache_stat_unchecked(&fscache_n_op_pend);
45622 ret = 0;
45623 } else if (object->state == FSCACHE_OBJECT_DYING ||
45624 object->state == FSCACHE_OBJECT_LC_DYING ||
45625 object->state == FSCACHE_OBJECT_WITHDRAWING) {
45626 - fscache_stat(&fscache_n_op_rejected);
45627 + fscache_stat_unchecked(&fscache_n_op_rejected);
45628 ret = -ENOBUFS;
45629 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
45630 fscache_report_unexpected_submission(object, op, ostate);
45631 @@ -294,7 +294,7 @@ int fscache_cancel_op(struct fscache_operation *op)
45632
45633 ret = -EBUSY;
45634 if (!list_empty(&op->pend_link)) {
45635 - fscache_stat(&fscache_n_op_cancelled);
45636 + fscache_stat_unchecked(&fscache_n_op_cancelled);
45637 list_del_init(&op->pend_link);
45638 object->n_ops--;
45639 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags))
45640 @@ -331,7 +331,7 @@ void fscache_put_operation(struct fscache_operation *op)
45641 if (test_and_set_bit(FSCACHE_OP_DEAD, &op->flags))
45642 BUG();
45643
45644 - fscache_stat(&fscache_n_op_release);
45645 + fscache_stat_unchecked(&fscache_n_op_release);
45646
45647 if (op->release) {
45648 op->release(op);
45649 @@ -348,7 +348,7 @@ void fscache_put_operation(struct fscache_operation *op)
45650 * lock, and defer it otherwise */
45651 if (!spin_trylock(&object->lock)) {
45652 _debug("defer put");
45653 - fscache_stat(&fscache_n_op_deferred_release);
45654 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
45655
45656 cache = object->cache;
45657 spin_lock(&cache->op_gc_list_lock);
45658 @@ -410,7 +410,7 @@ void fscache_operation_gc(struct work_struct *work)
45659
45660 _debug("GC DEFERRED REL OBJ%x OP%x",
45661 object->debug_id, op->debug_id);
45662 - fscache_stat(&fscache_n_op_gc);
45663 + fscache_stat_unchecked(&fscache_n_op_gc);
45664
45665 ASSERTCMP(atomic_read(&op->usage), ==, 0);
45666
45667 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
45668 index 3f7a59b..cf196cc 100644
45669 --- a/fs/fscache/page.c
45670 +++ b/fs/fscache/page.c
45671 @@ -60,7 +60,7 @@ bool __fscache_maybe_release_page(struct fscache_cookie *cookie,
45672 val = radix_tree_lookup(&cookie->stores, page->index);
45673 if (!val) {
45674 rcu_read_unlock();
45675 - fscache_stat(&fscache_n_store_vmscan_not_storing);
45676 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
45677 __fscache_uncache_page(cookie, page);
45678 return true;
45679 }
45680 @@ -90,11 +90,11 @@ bool __fscache_maybe_release_page(struct fscache_cookie *cookie,
45681 spin_unlock(&cookie->stores_lock);
45682
45683 if (xpage) {
45684 - fscache_stat(&fscache_n_store_vmscan_cancelled);
45685 - fscache_stat(&fscache_n_store_radix_deletes);
45686 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
45687 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
45688 ASSERTCMP(xpage, ==, page);
45689 } else {
45690 - fscache_stat(&fscache_n_store_vmscan_gone);
45691 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
45692 }
45693
45694 wake_up_bit(&cookie->flags, 0);
45695 @@ -107,7 +107,7 @@ page_busy:
45696 /* we might want to wait here, but that could deadlock the allocator as
45697 * the work threads writing to the cache may all end up sleeping
45698 * on memory allocation */
45699 - fscache_stat(&fscache_n_store_vmscan_busy);
45700 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
45701 return false;
45702 }
45703 EXPORT_SYMBOL(__fscache_maybe_release_page);
45704 @@ -131,7 +131,7 @@ static void fscache_end_page_write(struct fscache_object *object,
45705 FSCACHE_COOKIE_STORING_TAG);
45706 if (!radix_tree_tag_get(&cookie->stores, page->index,
45707 FSCACHE_COOKIE_PENDING_TAG)) {
45708 - fscache_stat(&fscache_n_store_radix_deletes);
45709 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
45710 xpage = radix_tree_delete(&cookie->stores, page->index);
45711 }
45712 spin_unlock(&cookie->stores_lock);
45713 @@ -152,7 +152,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
45714
45715 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
45716
45717 - fscache_stat(&fscache_n_attr_changed_calls);
45718 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
45719
45720 if (fscache_object_is_active(object)) {
45721 fscache_stat(&fscache_n_cop_attr_changed);
45722 @@ -177,11 +177,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
45723
45724 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
45725
45726 - fscache_stat(&fscache_n_attr_changed);
45727 + fscache_stat_unchecked(&fscache_n_attr_changed);
45728
45729 op = kzalloc(sizeof(*op), GFP_KERNEL);
45730 if (!op) {
45731 - fscache_stat(&fscache_n_attr_changed_nomem);
45732 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
45733 _leave(" = -ENOMEM");
45734 return -ENOMEM;
45735 }
45736 @@ -199,7 +199,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
45737 if (fscache_submit_exclusive_op(object, op) < 0)
45738 goto nobufs;
45739 spin_unlock(&cookie->lock);
45740 - fscache_stat(&fscache_n_attr_changed_ok);
45741 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
45742 fscache_put_operation(op);
45743 _leave(" = 0");
45744 return 0;
45745 @@ -207,7 +207,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
45746 nobufs:
45747 spin_unlock(&cookie->lock);
45748 kfree(op);
45749 - fscache_stat(&fscache_n_attr_changed_nobufs);
45750 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
45751 _leave(" = %d", -ENOBUFS);
45752 return -ENOBUFS;
45753 }
45754 @@ -243,7 +243,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
45755 /* allocate a retrieval operation and attempt to submit it */
45756 op = kzalloc(sizeof(*op), GFP_NOIO);
45757 if (!op) {
45758 - fscache_stat(&fscache_n_retrievals_nomem);
45759 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
45760 return NULL;
45761 }
45762
45763 @@ -271,13 +271,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
45764 return 0;
45765 }
45766
45767 - fscache_stat(&fscache_n_retrievals_wait);
45768 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
45769
45770 jif = jiffies;
45771 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
45772 fscache_wait_bit_interruptible,
45773 TASK_INTERRUPTIBLE) != 0) {
45774 - fscache_stat(&fscache_n_retrievals_intr);
45775 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
45776 _leave(" = -ERESTARTSYS");
45777 return -ERESTARTSYS;
45778 }
45779 @@ -295,8 +295,8 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
45780 */
45781 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
45782 struct fscache_retrieval *op,
45783 - atomic_t *stat_op_waits,
45784 - atomic_t *stat_object_dead)
45785 + atomic_unchecked_t *stat_op_waits,
45786 + atomic_unchecked_t *stat_object_dead)
45787 {
45788 int ret;
45789
45790 @@ -304,7 +304,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
45791 goto check_if_dead;
45792
45793 _debug(">>> WT");
45794 - fscache_stat(stat_op_waits);
45795 + fscache_stat_unchecked(stat_op_waits);
45796 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
45797 fscache_wait_bit_interruptible,
45798 TASK_INTERRUPTIBLE) < 0) {
45799 @@ -321,7 +321,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
45800
45801 check_if_dead:
45802 if (unlikely(fscache_object_is_dead(object))) {
45803 - fscache_stat(stat_object_dead);
45804 + fscache_stat_unchecked(stat_object_dead);
45805 return -ENOBUFS;
45806 }
45807 return 0;
45808 @@ -348,7 +348,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
45809
45810 _enter("%p,%p,,,", cookie, page);
45811
45812 - fscache_stat(&fscache_n_retrievals);
45813 + fscache_stat_unchecked(&fscache_n_retrievals);
45814
45815 if (hlist_empty(&cookie->backing_objects))
45816 goto nobufs;
45817 @@ -381,7 +381,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
45818 goto nobufs_unlock;
45819 spin_unlock(&cookie->lock);
45820
45821 - fscache_stat(&fscache_n_retrieval_ops);
45822 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
45823
45824 /* pin the netfs read context in case we need to do the actual netfs
45825 * read because we've encountered a cache read failure */
45826 @@ -411,15 +411,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
45827
45828 error:
45829 if (ret == -ENOMEM)
45830 - fscache_stat(&fscache_n_retrievals_nomem);
45831 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
45832 else if (ret == -ERESTARTSYS)
45833 - fscache_stat(&fscache_n_retrievals_intr);
45834 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
45835 else if (ret == -ENODATA)
45836 - fscache_stat(&fscache_n_retrievals_nodata);
45837 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
45838 else if (ret < 0)
45839 - fscache_stat(&fscache_n_retrievals_nobufs);
45840 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
45841 else
45842 - fscache_stat(&fscache_n_retrievals_ok);
45843 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
45844
45845 fscache_put_retrieval(op);
45846 _leave(" = %d", ret);
45847 @@ -429,7 +429,7 @@ nobufs_unlock:
45848 spin_unlock(&cookie->lock);
45849 kfree(op);
45850 nobufs:
45851 - fscache_stat(&fscache_n_retrievals_nobufs);
45852 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
45853 _leave(" = -ENOBUFS");
45854 return -ENOBUFS;
45855 }
45856 @@ -467,7 +467,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
45857
45858 _enter("%p,,%d,,,", cookie, *nr_pages);
45859
45860 - fscache_stat(&fscache_n_retrievals);
45861 + fscache_stat_unchecked(&fscache_n_retrievals);
45862
45863 if (hlist_empty(&cookie->backing_objects))
45864 goto nobufs;
45865 @@ -497,7 +497,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
45866 goto nobufs_unlock;
45867 spin_unlock(&cookie->lock);
45868
45869 - fscache_stat(&fscache_n_retrieval_ops);
45870 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
45871
45872 /* pin the netfs read context in case we need to do the actual netfs
45873 * read because we've encountered a cache read failure */
45874 @@ -527,15 +527,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
45875
45876 error:
45877 if (ret == -ENOMEM)
45878 - fscache_stat(&fscache_n_retrievals_nomem);
45879 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
45880 else if (ret == -ERESTARTSYS)
45881 - fscache_stat(&fscache_n_retrievals_intr);
45882 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
45883 else if (ret == -ENODATA)
45884 - fscache_stat(&fscache_n_retrievals_nodata);
45885 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
45886 else if (ret < 0)
45887 - fscache_stat(&fscache_n_retrievals_nobufs);
45888 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
45889 else
45890 - fscache_stat(&fscache_n_retrievals_ok);
45891 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
45892
45893 fscache_put_retrieval(op);
45894 _leave(" = %d", ret);
45895 @@ -545,7 +545,7 @@ nobufs_unlock:
45896 spin_unlock(&cookie->lock);
45897 kfree(op);
45898 nobufs:
45899 - fscache_stat(&fscache_n_retrievals_nobufs);
45900 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
45901 _leave(" = -ENOBUFS");
45902 return -ENOBUFS;
45903 }
45904 @@ -569,7 +569,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
45905
45906 _enter("%p,%p,,,", cookie, page);
45907
45908 - fscache_stat(&fscache_n_allocs);
45909 + fscache_stat_unchecked(&fscache_n_allocs);
45910
45911 if (hlist_empty(&cookie->backing_objects))
45912 goto nobufs;
45913 @@ -595,7 +595,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
45914 goto nobufs_unlock;
45915 spin_unlock(&cookie->lock);
45916
45917 - fscache_stat(&fscache_n_alloc_ops);
45918 + fscache_stat_unchecked(&fscache_n_alloc_ops);
45919
45920 ret = fscache_wait_for_retrieval_activation(
45921 object, op,
45922 @@ -611,11 +611,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
45923
45924 error:
45925 if (ret == -ERESTARTSYS)
45926 - fscache_stat(&fscache_n_allocs_intr);
45927 + fscache_stat_unchecked(&fscache_n_allocs_intr);
45928 else if (ret < 0)
45929 - fscache_stat(&fscache_n_allocs_nobufs);
45930 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
45931 else
45932 - fscache_stat(&fscache_n_allocs_ok);
45933 + fscache_stat_unchecked(&fscache_n_allocs_ok);
45934
45935 fscache_put_retrieval(op);
45936 _leave(" = %d", ret);
45937 @@ -625,7 +625,7 @@ nobufs_unlock:
45938 spin_unlock(&cookie->lock);
45939 kfree(op);
45940 nobufs:
45941 - fscache_stat(&fscache_n_allocs_nobufs);
45942 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
45943 _leave(" = -ENOBUFS");
45944 return -ENOBUFS;
45945 }
45946 @@ -666,7 +666,7 @@ static void fscache_write_op(struct fscache_operation *_op)
45947
45948 spin_lock(&cookie->stores_lock);
45949
45950 - fscache_stat(&fscache_n_store_calls);
45951 + fscache_stat_unchecked(&fscache_n_store_calls);
45952
45953 /* find a page to store */
45954 page = NULL;
45955 @@ -677,7 +677,7 @@ static void fscache_write_op(struct fscache_operation *_op)
45956 page = results[0];
45957 _debug("gang %d [%lx]", n, page->index);
45958 if (page->index > op->store_limit) {
45959 - fscache_stat(&fscache_n_store_pages_over_limit);
45960 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
45961 goto superseded;
45962 }
45963
45964 @@ -689,7 +689,7 @@ static void fscache_write_op(struct fscache_operation *_op)
45965 spin_unlock(&cookie->stores_lock);
45966 spin_unlock(&object->lock);
45967
45968 - fscache_stat(&fscache_n_store_pages);
45969 + fscache_stat_unchecked(&fscache_n_store_pages);
45970 fscache_stat(&fscache_n_cop_write_page);
45971 ret = object->cache->ops->write_page(op, page);
45972 fscache_stat_d(&fscache_n_cop_write_page);
45973 @@ -757,7 +757,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
45974 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
45975 ASSERT(PageFsCache(page));
45976
45977 - fscache_stat(&fscache_n_stores);
45978 + fscache_stat_unchecked(&fscache_n_stores);
45979
45980 op = kzalloc(sizeof(*op), GFP_NOIO);
45981 if (!op)
45982 @@ -808,7 +808,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
45983 spin_unlock(&cookie->stores_lock);
45984 spin_unlock(&object->lock);
45985
45986 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
45987 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
45988 op->store_limit = object->store_limit;
45989
45990 if (fscache_submit_op(object, &op->op) < 0)
45991 @@ -816,8 +816,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
45992
45993 spin_unlock(&cookie->lock);
45994 radix_tree_preload_end();
45995 - fscache_stat(&fscache_n_store_ops);
45996 - fscache_stat(&fscache_n_stores_ok);
45997 + fscache_stat_unchecked(&fscache_n_store_ops);
45998 + fscache_stat_unchecked(&fscache_n_stores_ok);
45999
46000 /* the work queue now carries its own ref on the object */
46001 fscache_put_operation(&op->op);
46002 @@ -825,14 +825,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
46003 return 0;
46004
46005 already_queued:
46006 - fscache_stat(&fscache_n_stores_again);
46007 + fscache_stat_unchecked(&fscache_n_stores_again);
46008 already_pending:
46009 spin_unlock(&cookie->stores_lock);
46010 spin_unlock(&object->lock);
46011 spin_unlock(&cookie->lock);
46012 radix_tree_preload_end();
46013 kfree(op);
46014 - fscache_stat(&fscache_n_stores_ok);
46015 + fscache_stat_unchecked(&fscache_n_stores_ok);
46016 _leave(" = 0");
46017 return 0;
46018
46019 @@ -851,14 +851,14 @@ nobufs:
46020 spin_unlock(&cookie->lock);
46021 radix_tree_preload_end();
46022 kfree(op);
46023 - fscache_stat(&fscache_n_stores_nobufs);
46024 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
46025 _leave(" = -ENOBUFS");
46026 return -ENOBUFS;
46027
46028 nomem_free:
46029 kfree(op);
46030 nomem:
46031 - fscache_stat(&fscache_n_stores_oom);
46032 + fscache_stat_unchecked(&fscache_n_stores_oom);
46033 _leave(" = -ENOMEM");
46034 return -ENOMEM;
46035 }
46036 @@ -876,7 +876,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
46037 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
46038 ASSERTCMP(page, !=, NULL);
46039
46040 - fscache_stat(&fscache_n_uncaches);
46041 + fscache_stat_unchecked(&fscache_n_uncaches);
46042
46043 /* cache withdrawal may beat us to it */
46044 if (!PageFsCache(page))
46045 @@ -929,7 +929,7 @@ void fscache_mark_pages_cached(struct fscache_retrieval *op,
46046 unsigned long loop;
46047
46048 #ifdef CONFIG_FSCACHE_STATS
46049 - atomic_add(pagevec->nr, &fscache_n_marks);
46050 + atomic_add_unchecked(pagevec->nr, &fscache_n_marks);
46051 #endif
46052
46053 for (loop = 0; loop < pagevec->nr; loop++) {
46054 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
46055 index 4765190..2a067f2 100644
46056 --- a/fs/fscache/stats.c
46057 +++ b/fs/fscache/stats.c
46058 @@ -18,95 +18,95 @@
46059 /*
46060 * operation counters
46061 */
46062 -atomic_t fscache_n_op_pend;
46063 -atomic_t fscache_n_op_run;
46064 -atomic_t fscache_n_op_enqueue;
46065 -atomic_t fscache_n_op_requeue;
46066 -atomic_t fscache_n_op_deferred_release;
46067 -atomic_t fscache_n_op_release;
46068 -atomic_t fscache_n_op_gc;
46069 -atomic_t fscache_n_op_cancelled;
46070 -atomic_t fscache_n_op_rejected;
46071 +atomic_unchecked_t fscache_n_op_pend;
46072 +atomic_unchecked_t fscache_n_op_run;
46073 +atomic_unchecked_t fscache_n_op_enqueue;
46074 +atomic_unchecked_t fscache_n_op_requeue;
46075 +atomic_unchecked_t fscache_n_op_deferred_release;
46076 +atomic_unchecked_t fscache_n_op_release;
46077 +atomic_unchecked_t fscache_n_op_gc;
46078 +atomic_unchecked_t fscache_n_op_cancelled;
46079 +atomic_unchecked_t fscache_n_op_rejected;
46080
46081 -atomic_t fscache_n_attr_changed;
46082 -atomic_t fscache_n_attr_changed_ok;
46083 -atomic_t fscache_n_attr_changed_nobufs;
46084 -atomic_t fscache_n_attr_changed_nomem;
46085 -atomic_t fscache_n_attr_changed_calls;
46086 +atomic_unchecked_t fscache_n_attr_changed;
46087 +atomic_unchecked_t fscache_n_attr_changed_ok;
46088 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
46089 +atomic_unchecked_t fscache_n_attr_changed_nomem;
46090 +atomic_unchecked_t fscache_n_attr_changed_calls;
46091
46092 -atomic_t fscache_n_allocs;
46093 -atomic_t fscache_n_allocs_ok;
46094 -atomic_t fscache_n_allocs_wait;
46095 -atomic_t fscache_n_allocs_nobufs;
46096 -atomic_t fscache_n_allocs_intr;
46097 -atomic_t fscache_n_allocs_object_dead;
46098 -atomic_t fscache_n_alloc_ops;
46099 -atomic_t fscache_n_alloc_op_waits;
46100 +atomic_unchecked_t fscache_n_allocs;
46101 +atomic_unchecked_t fscache_n_allocs_ok;
46102 +atomic_unchecked_t fscache_n_allocs_wait;
46103 +atomic_unchecked_t fscache_n_allocs_nobufs;
46104 +atomic_unchecked_t fscache_n_allocs_intr;
46105 +atomic_unchecked_t fscache_n_allocs_object_dead;
46106 +atomic_unchecked_t fscache_n_alloc_ops;
46107 +atomic_unchecked_t fscache_n_alloc_op_waits;
46108
46109 -atomic_t fscache_n_retrievals;
46110 -atomic_t fscache_n_retrievals_ok;
46111 -atomic_t fscache_n_retrievals_wait;
46112 -atomic_t fscache_n_retrievals_nodata;
46113 -atomic_t fscache_n_retrievals_nobufs;
46114 -atomic_t fscache_n_retrievals_intr;
46115 -atomic_t fscache_n_retrievals_nomem;
46116 -atomic_t fscache_n_retrievals_object_dead;
46117 -atomic_t fscache_n_retrieval_ops;
46118 -atomic_t fscache_n_retrieval_op_waits;
46119 +atomic_unchecked_t fscache_n_retrievals;
46120 +atomic_unchecked_t fscache_n_retrievals_ok;
46121 +atomic_unchecked_t fscache_n_retrievals_wait;
46122 +atomic_unchecked_t fscache_n_retrievals_nodata;
46123 +atomic_unchecked_t fscache_n_retrievals_nobufs;
46124 +atomic_unchecked_t fscache_n_retrievals_intr;
46125 +atomic_unchecked_t fscache_n_retrievals_nomem;
46126 +atomic_unchecked_t fscache_n_retrievals_object_dead;
46127 +atomic_unchecked_t fscache_n_retrieval_ops;
46128 +atomic_unchecked_t fscache_n_retrieval_op_waits;
46129
46130 -atomic_t fscache_n_stores;
46131 -atomic_t fscache_n_stores_ok;
46132 -atomic_t fscache_n_stores_again;
46133 -atomic_t fscache_n_stores_nobufs;
46134 -atomic_t fscache_n_stores_oom;
46135 -atomic_t fscache_n_store_ops;
46136 -atomic_t fscache_n_store_calls;
46137 -atomic_t fscache_n_store_pages;
46138 -atomic_t fscache_n_store_radix_deletes;
46139 -atomic_t fscache_n_store_pages_over_limit;
46140 +atomic_unchecked_t fscache_n_stores;
46141 +atomic_unchecked_t fscache_n_stores_ok;
46142 +atomic_unchecked_t fscache_n_stores_again;
46143 +atomic_unchecked_t fscache_n_stores_nobufs;
46144 +atomic_unchecked_t fscache_n_stores_oom;
46145 +atomic_unchecked_t fscache_n_store_ops;
46146 +atomic_unchecked_t fscache_n_store_calls;
46147 +atomic_unchecked_t fscache_n_store_pages;
46148 +atomic_unchecked_t fscache_n_store_radix_deletes;
46149 +atomic_unchecked_t fscache_n_store_pages_over_limit;
46150
46151 -atomic_t fscache_n_store_vmscan_not_storing;
46152 -atomic_t fscache_n_store_vmscan_gone;
46153 -atomic_t fscache_n_store_vmscan_busy;
46154 -atomic_t fscache_n_store_vmscan_cancelled;
46155 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
46156 +atomic_unchecked_t fscache_n_store_vmscan_gone;
46157 +atomic_unchecked_t fscache_n_store_vmscan_busy;
46158 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
46159
46160 -atomic_t fscache_n_marks;
46161 -atomic_t fscache_n_uncaches;
46162 +atomic_unchecked_t fscache_n_marks;
46163 +atomic_unchecked_t fscache_n_uncaches;
46164
46165 -atomic_t fscache_n_acquires;
46166 -atomic_t fscache_n_acquires_null;
46167 -atomic_t fscache_n_acquires_no_cache;
46168 -atomic_t fscache_n_acquires_ok;
46169 -atomic_t fscache_n_acquires_nobufs;
46170 -atomic_t fscache_n_acquires_oom;
46171 +atomic_unchecked_t fscache_n_acquires;
46172 +atomic_unchecked_t fscache_n_acquires_null;
46173 +atomic_unchecked_t fscache_n_acquires_no_cache;
46174 +atomic_unchecked_t fscache_n_acquires_ok;
46175 +atomic_unchecked_t fscache_n_acquires_nobufs;
46176 +atomic_unchecked_t fscache_n_acquires_oom;
46177
46178 -atomic_t fscache_n_updates;
46179 -atomic_t fscache_n_updates_null;
46180 -atomic_t fscache_n_updates_run;
46181 +atomic_unchecked_t fscache_n_updates;
46182 +atomic_unchecked_t fscache_n_updates_null;
46183 +atomic_unchecked_t fscache_n_updates_run;
46184
46185 -atomic_t fscache_n_relinquishes;
46186 -atomic_t fscache_n_relinquishes_null;
46187 -atomic_t fscache_n_relinquishes_waitcrt;
46188 -atomic_t fscache_n_relinquishes_retire;
46189 +atomic_unchecked_t fscache_n_relinquishes;
46190 +atomic_unchecked_t fscache_n_relinquishes_null;
46191 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
46192 +atomic_unchecked_t fscache_n_relinquishes_retire;
46193
46194 -atomic_t fscache_n_cookie_index;
46195 -atomic_t fscache_n_cookie_data;
46196 -atomic_t fscache_n_cookie_special;
46197 +atomic_unchecked_t fscache_n_cookie_index;
46198 +atomic_unchecked_t fscache_n_cookie_data;
46199 +atomic_unchecked_t fscache_n_cookie_special;
46200
46201 -atomic_t fscache_n_object_alloc;
46202 -atomic_t fscache_n_object_no_alloc;
46203 -atomic_t fscache_n_object_lookups;
46204 -atomic_t fscache_n_object_lookups_negative;
46205 -atomic_t fscache_n_object_lookups_positive;
46206 -atomic_t fscache_n_object_lookups_timed_out;
46207 -atomic_t fscache_n_object_created;
46208 -atomic_t fscache_n_object_avail;
46209 -atomic_t fscache_n_object_dead;
46210 +atomic_unchecked_t fscache_n_object_alloc;
46211 +atomic_unchecked_t fscache_n_object_no_alloc;
46212 +atomic_unchecked_t fscache_n_object_lookups;
46213 +atomic_unchecked_t fscache_n_object_lookups_negative;
46214 +atomic_unchecked_t fscache_n_object_lookups_positive;
46215 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
46216 +atomic_unchecked_t fscache_n_object_created;
46217 +atomic_unchecked_t fscache_n_object_avail;
46218 +atomic_unchecked_t fscache_n_object_dead;
46219
46220 -atomic_t fscache_n_checkaux_none;
46221 -atomic_t fscache_n_checkaux_okay;
46222 -atomic_t fscache_n_checkaux_update;
46223 -atomic_t fscache_n_checkaux_obsolete;
46224 +atomic_unchecked_t fscache_n_checkaux_none;
46225 +atomic_unchecked_t fscache_n_checkaux_okay;
46226 +atomic_unchecked_t fscache_n_checkaux_update;
46227 +atomic_unchecked_t fscache_n_checkaux_obsolete;
46228
46229 atomic_t fscache_n_cop_alloc_object;
46230 atomic_t fscache_n_cop_lookup_object;
46231 @@ -133,113 +133,113 @@ static int fscache_stats_show(struct seq_file *m, void *v)
46232 seq_puts(m, "FS-Cache statistics\n");
46233
46234 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
46235 - atomic_read(&fscache_n_cookie_index),
46236 - atomic_read(&fscache_n_cookie_data),
46237 - atomic_read(&fscache_n_cookie_special));
46238 + atomic_read_unchecked(&fscache_n_cookie_index),
46239 + atomic_read_unchecked(&fscache_n_cookie_data),
46240 + atomic_read_unchecked(&fscache_n_cookie_special));
46241
46242 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
46243 - atomic_read(&fscache_n_object_alloc),
46244 - atomic_read(&fscache_n_object_no_alloc),
46245 - atomic_read(&fscache_n_object_avail),
46246 - atomic_read(&fscache_n_object_dead));
46247 + atomic_read_unchecked(&fscache_n_object_alloc),
46248 + atomic_read_unchecked(&fscache_n_object_no_alloc),
46249 + atomic_read_unchecked(&fscache_n_object_avail),
46250 + atomic_read_unchecked(&fscache_n_object_dead));
46251 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
46252 - atomic_read(&fscache_n_checkaux_none),
46253 - atomic_read(&fscache_n_checkaux_okay),
46254 - atomic_read(&fscache_n_checkaux_update),
46255 - atomic_read(&fscache_n_checkaux_obsolete));
46256 + atomic_read_unchecked(&fscache_n_checkaux_none),
46257 + atomic_read_unchecked(&fscache_n_checkaux_okay),
46258 + atomic_read_unchecked(&fscache_n_checkaux_update),
46259 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
46260
46261 seq_printf(m, "Pages : mrk=%u unc=%u\n",
46262 - atomic_read(&fscache_n_marks),
46263 - atomic_read(&fscache_n_uncaches));
46264 + atomic_read_unchecked(&fscache_n_marks),
46265 + atomic_read_unchecked(&fscache_n_uncaches));
46266
46267 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
46268 " oom=%u\n",
46269 - atomic_read(&fscache_n_acquires),
46270 - atomic_read(&fscache_n_acquires_null),
46271 - atomic_read(&fscache_n_acquires_no_cache),
46272 - atomic_read(&fscache_n_acquires_ok),
46273 - atomic_read(&fscache_n_acquires_nobufs),
46274 - atomic_read(&fscache_n_acquires_oom));
46275 + atomic_read_unchecked(&fscache_n_acquires),
46276 + atomic_read_unchecked(&fscache_n_acquires_null),
46277 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
46278 + atomic_read_unchecked(&fscache_n_acquires_ok),
46279 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
46280 + atomic_read_unchecked(&fscache_n_acquires_oom));
46281
46282 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
46283 - atomic_read(&fscache_n_object_lookups),
46284 - atomic_read(&fscache_n_object_lookups_negative),
46285 - atomic_read(&fscache_n_object_lookups_positive),
46286 - atomic_read(&fscache_n_object_created),
46287 - atomic_read(&fscache_n_object_lookups_timed_out));
46288 + atomic_read_unchecked(&fscache_n_object_lookups),
46289 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
46290 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
46291 + atomic_read_unchecked(&fscache_n_object_created),
46292 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
46293
46294 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
46295 - atomic_read(&fscache_n_updates),
46296 - atomic_read(&fscache_n_updates_null),
46297 - atomic_read(&fscache_n_updates_run));
46298 + atomic_read_unchecked(&fscache_n_updates),
46299 + atomic_read_unchecked(&fscache_n_updates_null),
46300 + atomic_read_unchecked(&fscache_n_updates_run));
46301
46302 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
46303 - atomic_read(&fscache_n_relinquishes),
46304 - atomic_read(&fscache_n_relinquishes_null),
46305 - atomic_read(&fscache_n_relinquishes_waitcrt),
46306 - atomic_read(&fscache_n_relinquishes_retire));
46307 + atomic_read_unchecked(&fscache_n_relinquishes),
46308 + atomic_read_unchecked(&fscache_n_relinquishes_null),
46309 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
46310 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
46311
46312 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
46313 - atomic_read(&fscache_n_attr_changed),
46314 - atomic_read(&fscache_n_attr_changed_ok),
46315 - atomic_read(&fscache_n_attr_changed_nobufs),
46316 - atomic_read(&fscache_n_attr_changed_nomem),
46317 - atomic_read(&fscache_n_attr_changed_calls));
46318 + atomic_read_unchecked(&fscache_n_attr_changed),
46319 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
46320 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
46321 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
46322 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
46323
46324 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
46325 - atomic_read(&fscache_n_allocs),
46326 - atomic_read(&fscache_n_allocs_ok),
46327 - atomic_read(&fscache_n_allocs_wait),
46328 - atomic_read(&fscache_n_allocs_nobufs),
46329 - atomic_read(&fscache_n_allocs_intr));
46330 + atomic_read_unchecked(&fscache_n_allocs),
46331 + atomic_read_unchecked(&fscache_n_allocs_ok),
46332 + atomic_read_unchecked(&fscache_n_allocs_wait),
46333 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
46334 + atomic_read_unchecked(&fscache_n_allocs_intr));
46335 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
46336 - atomic_read(&fscache_n_alloc_ops),
46337 - atomic_read(&fscache_n_alloc_op_waits),
46338 - atomic_read(&fscache_n_allocs_object_dead));
46339 + atomic_read_unchecked(&fscache_n_alloc_ops),
46340 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
46341 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
46342
46343 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
46344 " int=%u oom=%u\n",
46345 - atomic_read(&fscache_n_retrievals),
46346 - atomic_read(&fscache_n_retrievals_ok),
46347 - atomic_read(&fscache_n_retrievals_wait),
46348 - atomic_read(&fscache_n_retrievals_nodata),
46349 - atomic_read(&fscache_n_retrievals_nobufs),
46350 - atomic_read(&fscache_n_retrievals_intr),
46351 - atomic_read(&fscache_n_retrievals_nomem));
46352 + atomic_read_unchecked(&fscache_n_retrievals),
46353 + atomic_read_unchecked(&fscache_n_retrievals_ok),
46354 + atomic_read_unchecked(&fscache_n_retrievals_wait),
46355 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
46356 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
46357 + atomic_read_unchecked(&fscache_n_retrievals_intr),
46358 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
46359 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
46360 - atomic_read(&fscache_n_retrieval_ops),
46361 - atomic_read(&fscache_n_retrieval_op_waits),
46362 - atomic_read(&fscache_n_retrievals_object_dead));
46363 + atomic_read_unchecked(&fscache_n_retrieval_ops),
46364 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
46365 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
46366
46367 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
46368 - atomic_read(&fscache_n_stores),
46369 - atomic_read(&fscache_n_stores_ok),
46370 - atomic_read(&fscache_n_stores_again),
46371 - atomic_read(&fscache_n_stores_nobufs),
46372 - atomic_read(&fscache_n_stores_oom));
46373 + atomic_read_unchecked(&fscache_n_stores),
46374 + atomic_read_unchecked(&fscache_n_stores_ok),
46375 + atomic_read_unchecked(&fscache_n_stores_again),
46376 + atomic_read_unchecked(&fscache_n_stores_nobufs),
46377 + atomic_read_unchecked(&fscache_n_stores_oom));
46378 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
46379 - atomic_read(&fscache_n_store_ops),
46380 - atomic_read(&fscache_n_store_calls),
46381 - atomic_read(&fscache_n_store_pages),
46382 - atomic_read(&fscache_n_store_radix_deletes),
46383 - atomic_read(&fscache_n_store_pages_over_limit));
46384 + atomic_read_unchecked(&fscache_n_store_ops),
46385 + atomic_read_unchecked(&fscache_n_store_calls),
46386 + atomic_read_unchecked(&fscache_n_store_pages),
46387 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
46388 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
46389
46390 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u\n",
46391 - atomic_read(&fscache_n_store_vmscan_not_storing),
46392 - atomic_read(&fscache_n_store_vmscan_gone),
46393 - atomic_read(&fscache_n_store_vmscan_busy),
46394 - atomic_read(&fscache_n_store_vmscan_cancelled));
46395 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
46396 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
46397 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
46398 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled));
46399
46400 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
46401 - atomic_read(&fscache_n_op_pend),
46402 - atomic_read(&fscache_n_op_run),
46403 - atomic_read(&fscache_n_op_enqueue),
46404 - atomic_read(&fscache_n_op_cancelled),
46405 - atomic_read(&fscache_n_op_rejected));
46406 + atomic_read_unchecked(&fscache_n_op_pend),
46407 + atomic_read_unchecked(&fscache_n_op_run),
46408 + atomic_read_unchecked(&fscache_n_op_enqueue),
46409 + atomic_read_unchecked(&fscache_n_op_cancelled),
46410 + atomic_read_unchecked(&fscache_n_op_rejected));
46411 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
46412 - atomic_read(&fscache_n_op_deferred_release),
46413 - atomic_read(&fscache_n_op_release),
46414 - atomic_read(&fscache_n_op_gc));
46415 + atomic_read_unchecked(&fscache_n_op_deferred_release),
46416 + atomic_read_unchecked(&fscache_n_op_release),
46417 + atomic_read_unchecked(&fscache_n_op_gc));
46418
46419 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
46420 atomic_read(&fscache_n_cop_alloc_object),
46421 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
46422 index 3426521..3b75162 100644
46423 --- a/fs/fuse/cuse.c
46424 +++ b/fs/fuse/cuse.c
46425 @@ -587,10 +587,12 @@ static int __init cuse_init(void)
46426 INIT_LIST_HEAD(&cuse_conntbl[i]);
46427
46428 /* inherit and extend fuse_dev_operations */
46429 - cuse_channel_fops = fuse_dev_operations;
46430 - cuse_channel_fops.owner = THIS_MODULE;
46431 - cuse_channel_fops.open = cuse_channel_open;
46432 - cuse_channel_fops.release = cuse_channel_release;
46433 + pax_open_kernel();
46434 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
46435 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
46436 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
46437 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
46438 + pax_close_kernel();
46439
46440 cuse_class = class_create(THIS_MODULE, "cuse");
46441 if (IS_ERR(cuse_class))
46442 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
46443 index 5f3368a..8306426 100644
46444 --- a/fs/fuse/dev.c
46445 +++ b/fs/fuse/dev.c
46446 @@ -1242,7 +1242,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
46447 ret = 0;
46448 pipe_lock(pipe);
46449
46450 - if (!pipe->readers) {
46451 + if (!atomic_read(&pipe->readers)) {
46452 send_sig(SIGPIPE, current, 0);
46453 if (!ret)
46454 ret = -EPIPE;
46455 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
46456 index 2066328..f5add3b 100644
46457 --- a/fs/fuse/dir.c
46458 +++ b/fs/fuse/dir.c
46459 @@ -1175,7 +1175,7 @@ static char *read_link(struct dentry *dentry)
46460 return link;
46461 }
46462
46463 -static void free_link(char *link)
46464 +static void free_link(const char *link)
46465 {
46466 if (!IS_ERR(link))
46467 free_page((unsigned long) link);
46468 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
46469 index 5698746..6086012 100644
46470 --- a/fs/gfs2/inode.c
46471 +++ b/fs/gfs2/inode.c
46472 @@ -1487,7 +1487,7 @@ out:
46473
46474 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
46475 {
46476 - char *s = nd_get_link(nd);
46477 + const char *s = nd_get_link(nd);
46478 if (!IS_ERR(s))
46479 kfree(s);
46480 }
46481 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
46482 index c60267e..193d9e4 100644
46483 --- a/fs/hugetlbfs/inode.c
46484 +++ b/fs/hugetlbfs/inode.c
46485 @@ -902,7 +902,7 @@ static struct file_system_type hugetlbfs_fs_type = {
46486 .kill_sb = kill_litter_super,
46487 };
46488
46489 -static struct vfsmount *hugetlbfs_vfsmount;
46490 +struct vfsmount *hugetlbfs_vfsmount;
46491
46492 static int can_do_hugetlb_shm(void)
46493 {
46494 diff --git a/fs/inode.c b/fs/inode.c
46495 index 83ab215..8842101 100644
46496 --- a/fs/inode.c
46497 +++ b/fs/inode.c
46498 @@ -870,8 +870,8 @@ unsigned int get_next_ino(void)
46499
46500 #ifdef CONFIG_SMP
46501 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
46502 - static atomic_t shared_last_ino;
46503 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
46504 + static atomic_unchecked_t shared_last_ino;
46505 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
46506
46507 res = next - LAST_INO_BATCH;
46508 }
46509 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
46510 index eafb8d3..f423d37 100644
46511 --- a/fs/jffs2/erase.c
46512 +++ b/fs/jffs2/erase.c
46513 @@ -438,7 +438,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
46514 struct jffs2_unknown_node marker = {
46515 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
46516 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
46517 - .totlen = cpu_to_je32(c->cleanmarker_size)
46518 + .totlen = cpu_to_je32(c->cleanmarker_size),
46519 + .hdr_crc = cpu_to_je32(0)
46520 };
46521
46522 jffs2_prealloc_raw_node_refs(c, jeb, 1);
46523 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
46524 index 30e8f47..21f600c 100644
46525 --- a/fs/jffs2/wbuf.c
46526 +++ b/fs/jffs2/wbuf.c
46527 @@ -1012,7 +1012,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
46528 {
46529 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
46530 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
46531 - .totlen = constant_cpu_to_je32(8)
46532 + .totlen = constant_cpu_to_je32(8),
46533 + .hdr_crc = constant_cpu_to_je32(0)
46534 };
46535
46536 /*
46537 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
46538 index 682bca6..86b8e6e 100644
46539 --- a/fs/jfs/super.c
46540 +++ b/fs/jfs/super.c
46541 @@ -801,7 +801,7 @@ static int __init init_jfs_fs(void)
46542
46543 jfs_inode_cachep =
46544 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
46545 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
46546 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
46547 init_once);
46548 if (jfs_inode_cachep == NULL)
46549 return -ENOMEM;
46550 diff --git a/fs/libfs.c b/fs/libfs.c
46551 index 5b2dbb3..7442d54 100644
46552 --- a/fs/libfs.c
46553 +++ b/fs/libfs.c
46554 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
46555
46556 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
46557 struct dentry *next;
46558 + char d_name[sizeof(next->d_iname)];
46559 + const unsigned char *name;
46560 +
46561 next = list_entry(p, struct dentry, d_u.d_child);
46562 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
46563 if (!simple_positive(next)) {
46564 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
46565
46566 spin_unlock(&next->d_lock);
46567 spin_unlock(&dentry->d_lock);
46568 - if (filldir(dirent, next->d_name.name,
46569 + name = next->d_name.name;
46570 + if (name == next->d_iname) {
46571 + memcpy(d_name, name, next->d_name.len);
46572 + name = d_name;
46573 + }
46574 + if (filldir(dirent, name,
46575 next->d_name.len, filp->f_pos,
46576 next->d_inode->i_ino,
46577 dt_type(next->d_inode)) < 0)
46578 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
46579 index 8392cb8..80d6193 100644
46580 --- a/fs/lockd/clntproc.c
46581 +++ b/fs/lockd/clntproc.c
46582 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
46583 /*
46584 * Cookie counter for NLM requests
46585 */
46586 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
46587 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
46588
46589 void nlmclnt_next_cookie(struct nlm_cookie *c)
46590 {
46591 - u32 cookie = atomic_inc_return(&nlm_cookie);
46592 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
46593
46594 memcpy(c->data, &cookie, 4);
46595 c->len=4;
46596 diff --git a/fs/locks.c b/fs/locks.c
46597 index 0d68f1f..f216b79 100644
46598 --- a/fs/locks.c
46599 +++ b/fs/locks.c
46600 @@ -2075,16 +2075,16 @@ void locks_remove_flock(struct file *filp)
46601 return;
46602
46603 if (filp->f_op && filp->f_op->flock) {
46604 - struct file_lock fl = {
46605 + struct file_lock flock = {
46606 .fl_pid = current->tgid,
46607 .fl_file = filp,
46608 .fl_flags = FL_FLOCK,
46609 .fl_type = F_UNLCK,
46610 .fl_end = OFFSET_MAX,
46611 };
46612 - filp->f_op->flock(filp, F_SETLKW, &fl);
46613 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
46614 - fl.fl_ops->fl_release_private(&fl);
46615 + filp->f_op->flock(filp, F_SETLKW, &flock);
46616 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
46617 + flock.fl_ops->fl_release_private(&flock);
46618 }
46619
46620 lock_flocks();
46621 diff --git a/fs/namei.c b/fs/namei.c
46622 index 46ea9cc..c7cf3a3 100644
46623 --- a/fs/namei.c
46624 +++ b/fs/namei.c
46625 @@ -278,16 +278,32 @@ int generic_permission(struct inode *inode, int mask)
46626 if (ret != -EACCES)
46627 return ret;
46628
46629 +#ifdef CONFIG_GRKERNSEC
46630 + /* we'll block if we have to log due to a denied capability use */
46631 + if (mask & MAY_NOT_BLOCK)
46632 + return -ECHILD;
46633 +#endif
46634 +
46635 if (S_ISDIR(inode->i_mode)) {
46636 /* DACs are overridable for directories */
46637 - if (ns_capable(inode_userns(inode), CAP_DAC_OVERRIDE))
46638 - return 0;
46639 if (!(mask & MAY_WRITE))
46640 - if (ns_capable(inode_userns(inode), CAP_DAC_READ_SEARCH))
46641 + if (ns_capable_nolog(inode_userns(inode), CAP_DAC_OVERRIDE) ||
46642 + ns_capable(inode_userns(inode), CAP_DAC_READ_SEARCH))
46643 return 0;
46644 + if (ns_capable(inode_userns(inode), CAP_DAC_OVERRIDE))
46645 + return 0;
46646 return -EACCES;
46647 }
46648 /*
46649 + * Searching includes executable on directories, else just read.
46650 + */
46651 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
46652 + if (mask == MAY_READ)
46653 + if (ns_capable_nolog(inode_userns(inode), CAP_DAC_OVERRIDE) ||
46654 + ns_capable(inode_userns(inode), CAP_DAC_READ_SEARCH))
46655 + return 0;
46656 +
46657 + /*
46658 * Read/write DACs are always overridable.
46659 * Executable DACs are overridable when there is
46660 * at least one exec bit set.
46661 @@ -296,14 +312,6 @@ int generic_permission(struct inode *inode, int mask)
46662 if (ns_capable(inode_userns(inode), CAP_DAC_OVERRIDE))
46663 return 0;
46664
46665 - /*
46666 - * Searching includes executable on directories, else just read.
46667 - */
46668 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
46669 - if (mask == MAY_READ)
46670 - if (ns_capable(inode_userns(inode), CAP_DAC_READ_SEARCH))
46671 - return 0;
46672 -
46673 return -EACCES;
46674 }
46675
46676 @@ -652,11 +660,19 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
46677 return error;
46678 }
46679
46680 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
46681 + dentry->d_inode, dentry, nd->path.mnt)) {
46682 + error = -EACCES;
46683 + *p = ERR_PTR(error); /* no ->put_link(), please */
46684 + path_put(&nd->path);
46685 + return error;
46686 + }
46687 +
46688 nd->last_type = LAST_BIND;
46689 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
46690 error = PTR_ERR(*p);
46691 if (!IS_ERR(*p)) {
46692 - char *s = nd_get_link(nd);
46693 + const char *s = nd_get_link(nd);
46694 error = 0;
46695 if (s)
46696 error = __vfs_follow_link(nd, s);
46697 @@ -1650,6 +1666,21 @@ static int path_lookupat(int dfd, const char *name,
46698 if (!err)
46699 err = complete_walk(nd);
46700
46701 + if (!(nd->flags & LOOKUP_PARENT)) {
46702 +#ifdef CONFIG_GRKERNSEC
46703 + if (flags & LOOKUP_RCU) {
46704 + if (!err)
46705 + path_put(&nd->path);
46706 + err = -ECHILD;
46707 + } else
46708 +#endif
46709 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
46710 + if (!err)
46711 + path_put(&nd->path);
46712 + err = -ENOENT;
46713 + }
46714 + }
46715 +
46716 if (!err && nd->flags & LOOKUP_DIRECTORY) {
46717 if (!nd->inode->i_op->lookup) {
46718 path_put(&nd->path);
46719 @@ -1677,6 +1708,15 @@ static int do_path_lookup(int dfd, const char *name,
46720 retval = path_lookupat(dfd, name, flags | LOOKUP_REVAL, nd);
46721
46722 if (likely(!retval)) {
46723 + if (*name != '/' && nd->path.dentry && nd->inode) {
46724 +#ifdef CONFIG_GRKERNSEC
46725 + if (flags & LOOKUP_RCU)
46726 + return -ECHILD;
46727 +#endif
46728 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt))
46729 + return -ENOENT;
46730 + }
46731 +
46732 if (unlikely(!audit_dummy_context())) {
46733 if (nd->path.dentry && nd->inode)
46734 audit_inode(name, nd->path.dentry);
46735 @@ -2071,6 +2111,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
46736 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
46737 return -EPERM;
46738
46739 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
46740 + return -EPERM;
46741 + if (gr_handle_rawio(inode))
46742 + return -EPERM;
46743 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
46744 + return -EACCES;
46745 +
46746 return 0;
46747 }
46748
46749 @@ -2132,6 +2179,16 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
46750 error = complete_walk(nd);
46751 if (error)
46752 return ERR_PTR(error);
46753 +#ifdef CONFIG_GRKERNSEC
46754 + if (nd->flags & LOOKUP_RCU) {
46755 + error = -ECHILD;
46756 + goto exit;
46757 + }
46758 +#endif
46759 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
46760 + error = -ENOENT;
46761 + goto exit;
46762 + }
46763 audit_inode(pathname, nd->path.dentry);
46764 if (open_flag & O_CREAT) {
46765 error = -EISDIR;
46766 @@ -2142,6 +2199,16 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
46767 error = complete_walk(nd);
46768 if (error)
46769 return ERR_PTR(error);
46770 +#ifdef CONFIG_GRKERNSEC
46771 + if (nd->flags & LOOKUP_RCU) {
46772 + error = -ECHILD;
46773 + goto exit;
46774 + }
46775 +#endif
46776 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
46777 + error = -ENOENT;
46778 + goto exit;
46779 + }
46780 audit_inode(pathname, dir);
46781 goto ok;
46782 }
46783 @@ -2163,6 +2230,16 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
46784 error = complete_walk(nd);
46785 if (error)
46786 return ERR_PTR(error);
46787 +#ifdef CONFIG_GRKERNSEC
46788 + if (nd->flags & LOOKUP_RCU) {
46789 + error = -ECHILD;
46790 + goto exit;
46791 + }
46792 +#endif
46793 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
46794 + error = -ENOENT;
46795 + goto exit;
46796 + }
46797
46798 error = -ENOTDIR;
46799 if (nd->flags & LOOKUP_DIRECTORY) {
46800 @@ -2203,6 +2280,12 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
46801 /* Negative dentry, just create the file */
46802 if (!dentry->d_inode) {
46803 umode_t mode = op->mode;
46804 +
46805 + if (!gr_acl_handle_creat(path->dentry, nd->path.dentry, path->mnt, open_flag, acc_mode, mode)) {
46806 + error = -EACCES;
46807 + goto exit_mutex_unlock;
46808 + }
46809 +
46810 if (!IS_POSIXACL(dir->d_inode))
46811 mode &= ~current_umask();
46812 /*
46813 @@ -2226,6 +2309,8 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
46814 error = vfs_create(dir->d_inode, dentry, mode, nd);
46815 if (error)
46816 goto exit_mutex_unlock;
46817 + else
46818 + gr_handle_create(path->dentry, path->mnt);
46819 mutex_unlock(&dir->d_inode->i_mutex);
46820 dput(nd->path.dentry);
46821 nd->path.dentry = dentry;
46822 @@ -2235,6 +2320,19 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
46823 /*
46824 * It already exists.
46825 */
46826 +
46827 + if (!gr_acl_handle_hidden_file(dentry, nd->path.mnt)) {
46828 + error = -ENOENT;
46829 + goto exit_mutex_unlock;
46830 + }
46831 +
46832 + /* only check if O_CREAT is specified, all other checks need to go
46833 + into may_open */
46834 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
46835 + error = -EACCES;
46836 + goto exit_mutex_unlock;
46837 + }
46838 +
46839 mutex_unlock(&dir->d_inode->i_mutex);
46840 audit_inode(pathname, path->dentry);
46841
46842 @@ -2447,6 +2545,11 @@ struct dentry *kern_path_create(int dfd, const char *pathname, struct path *path
46843 *path = nd.path;
46844 return dentry;
46845 eexist:
46846 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
46847 + dput(dentry);
46848 + dentry = ERR_PTR(-ENOENT);
46849 + goto fail;
46850 + }
46851 dput(dentry);
46852 dentry = ERR_PTR(-EEXIST);
46853 fail:
46854 @@ -2469,6 +2572,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname, struct pat
46855 }
46856 EXPORT_SYMBOL(user_path_create);
46857
46858 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, char **to, int is_dir)
46859 +{
46860 + char *tmp = getname(pathname);
46861 + struct dentry *res;
46862 + if (IS_ERR(tmp))
46863 + return ERR_CAST(tmp);
46864 + res = kern_path_create(dfd, tmp, path, is_dir);
46865 + if (IS_ERR(res))
46866 + putname(tmp);
46867 + else
46868 + *to = tmp;
46869 + return res;
46870 +}
46871 +
46872 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
46873 {
46874 int error = may_create(dir, dentry);
46875 @@ -2536,6 +2653,17 @@ SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, filename, umode_t, mode,
46876 error = mnt_want_write(path.mnt);
46877 if (error)
46878 goto out_dput;
46879 +
46880 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
46881 + error = -EPERM;
46882 + goto out_drop_write;
46883 + }
46884 +
46885 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
46886 + error = -EACCES;
46887 + goto out_drop_write;
46888 + }
46889 +
46890 error = security_path_mknod(&path, dentry, mode, dev);
46891 if (error)
46892 goto out_drop_write;
46893 @@ -2553,6 +2681,9 @@ SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, filename, umode_t, mode,
46894 }
46895 out_drop_write:
46896 mnt_drop_write(path.mnt);
46897 +
46898 + if (!error)
46899 + gr_handle_create(dentry, path.mnt);
46900 out_dput:
46901 dput(dentry);
46902 mutex_unlock(&path.dentry->d_inode->i_mutex);
46903 @@ -2602,12 +2733,21 @@ SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, umode_t, mode)
46904 error = mnt_want_write(path.mnt);
46905 if (error)
46906 goto out_dput;
46907 +
46908 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
46909 + error = -EACCES;
46910 + goto out_drop_write;
46911 + }
46912 +
46913 error = security_path_mkdir(&path, dentry, mode);
46914 if (error)
46915 goto out_drop_write;
46916 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
46917 out_drop_write:
46918 mnt_drop_write(path.mnt);
46919 +
46920 + if (!error)
46921 + gr_handle_create(dentry, path.mnt);
46922 out_dput:
46923 dput(dentry);
46924 mutex_unlock(&path.dentry->d_inode->i_mutex);
46925 @@ -2687,6 +2827,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
46926 char * name;
46927 struct dentry *dentry;
46928 struct nameidata nd;
46929 + ino_t saved_ino = 0;
46930 + dev_t saved_dev = 0;
46931
46932 error = user_path_parent(dfd, pathname, &nd, &name);
46933 if (error)
46934 @@ -2715,6 +2857,15 @@ static long do_rmdir(int dfd, const char __user *pathname)
46935 error = -ENOENT;
46936 goto exit3;
46937 }
46938 +
46939 + saved_ino = dentry->d_inode->i_ino;
46940 + saved_dev = gr_get_dev_from_dentry(dentry);
46941 +
46942 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
46943 + error = -EACCES;
46944 + goto exit3;
46945 + }
46946 +
46947 error = mnt_want_write(nd.path.mnt);
46948 if (error)
46949 goto exit3;
46950 @@ -2722,6 +2873,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
46951 if (error)
46952 goto exit4;
46953 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
46954 + if (!error && (saved_dev || saved_ino))
46955 + gr_handle_delete(saved_ino, saved_dev);
46956 exit4:
46957 mnt_drop_write(nd.path.mnt);
46958 exit3:
46959 @@ -2784,6 +2937,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
46960 struct dentry *dentry;
46961 struct nameidata nd;
46962 struct inode *inode = NULL;
46963 + ino_t saved_ino = 0;
46964 + dev_t saved_dev = 0;
46965
46966 error = user_path_parent(dfd, pathname, &nd, &name);
46967 if (error)
46968 @@ -2806,6 +2961,16 @@ static long do_unlinkat(int dfd, const char __user *pathname)
46969 if (!inode)
46970 goto slashes;
46971 ihold(inode);
46972 +
46973 + if (inode->i_nlink <= 1) {
46974 + saved_ino = inode->i_ino;
46975 + saved_dev = gr_get_dev_from_dentry(dentry);
46976 + }
46977 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
46978 + error = -EACCES;
46979 + goto exit2;
46980 + }
46981 +
46982 error = mnt_want_write(nd.path.mnt);
46983 if (error)
46984 goto exit2;
46985 @@ -2813,6 +2978,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
46986 if (error)
46987 goto exit3;
46988 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
46989 + if (!error && (saved_ino || saved_dev))
46990 + gr_handle_delete(saved_ino, saved_dev);
46991 exit3:
46992 mnt_drop_write(nd.path.mnt);
46993 exit2:
46994 @@ -2888,10 +3055,18 @@ SYSCALL_DEFINE3(symlinkat, const char __user *, oldname,
46995 error = mnt_want_write(path.mnt);
46996 if (error)
46997 goto out_dput;
46998 +
46999 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
47000 + error = -EACCES;
47001 + goto out_drop_write;
47002 + }
47003 +
47004 error = security_path_symlink(&path, dentry, from);
47005 if (error)
47006 goto out_drop_write;
47007 error = vfs_symlink(path.dentry->d_inode, dentry, from);
47008 + if (!error)
47009 + gr_handle_create(dentry, path.mnt);
47010 out_drop_write:
47011 mnt_drop_write(path.mnt);
47012 out_dput:
47013 @@ -2963,6 +3138,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
47014 {
47015 struct dentry *new_dentry;
47016 struct path old_path, new_path;
47017 + char *to = NULL;
47018 int how = 0;
47019 int error;
47020
47021 @@ -2986,7 +3162,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
47022 if (error)
47023 return error;
47024
47025 - new_dentry = user_path_create(newdfd, newname, &new_path, 0);
47026 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to, 0);
47027 error = PTR_ERR(new_dentry);
47028 if (IS_ERR(new_dentry))
47029 goto out;
47030 @@ -2997,13 +3173,30 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
47031 error = mnt_want_write(new_path.mnt);
47032 if (error)
47033 goto out_dput;
47034 +
47035 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
47036 + old_path.dentry->d_inode,
47037 + old_path.dentry->d_inode->i_mode, to)) {
47038 + error = -EACCES;
47039 + goto out_drop_write;
47040 + }
47041 +
47042 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
47043 + old_path.dentry, old_path.mnt, to)) {
47044 + error = -EACCES;
47045 + goto out_drop_write;
47046 + }
47047 +
47048 error = security_path_link(old_path.dentry, &new_path, new_dentry);
47049 if (error)
47050 goto out_drop_write;
47051 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
47052 + if (!error)
47053 + gr_handle_create(new_dentry, new_path.mnt);
47054 out_drop_write:
47055 mnt_drop_write(new_path.mnt);
47056 out_dput:
47057 + putname(to);
47058 dput(new_dentry);
47059 mutex_unlock(&new_path.dentry->d_inode->i_mutex);
47060 path_put(&new_path);
47061 @@ -3231,6 +3424,12 @@ SYSCALL_DEFINE4(renameat, int, olddfd, const char __user *, oldname,
47062 if (new_dentry == trap)
47063 goto exit5;
47064
47065 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
47066 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
47067 + to);
47068 + if (error)
47069 + goto exit5;
47070 +
47071 error = mnt_want_write(oldnd.path.mnt);
47072 if (error)
47073 goto exit5;
47074 @@ -3240,6 +3439,9 @@ SYSCALL_DEFINE4(renameat, int, olddfd, const char __user *, oldname,
47075 goto exit6;
47076 error = vfs_rename(old_dir->d_inode, old_dentry,
47077 new_dir->d_inode, new_dentry);
47078 + if (!error)
47079 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
47080 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
47081 exit6:
47082 mnt_drop_write(oldnd.path.mnt);
47083 exit5:
47084 @@ -3265,6 +3467,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
47085
47086 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
47087 {
47088 + char tmpbuf[64];
47089 + const char *newlink;
47090 int len;
47091
47092 len = PTR_ERR(link);
47093 @@ -3274,7 +3478,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
47094 len = strlen(link);
47095 if (len > (unsigned) buflen)
47096 len = buflen;
47097 - if (copy_to_user(buffer, link, len))
47098 +
47099 + if (len < sizeof(tmpbuf)) {
47100 + memcpy(tmpbuf, link, len);
47101 + newlink = tmpbuf;
47102 + } else
47103 + newlink = link;
47104 +
47105 + if (copy_to_user(buffer, newlink, len))
47106 len = -EFAULT;
47107 out:
47108 return len;
47109 diff --git a/fs/namespace.c b/fs/namespace.c
47110 index e608199..9609cb9 100644
47111 --- a/fs/namespace.c
47112 +++ b/fs/namespace.c
47113 @@ -1155,6 +1155,9 @@ static int do_umount(struct mount *mnt, int flags)
47114 if (!(sb->s_flags & MS_RDONLY))
47115 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
47116 up_write(&sb->s_umount);
47117 +
47118 + gr_log_remount(mnt->mnt_devname, retval);
47119 +
47120 return retval;
47121 }
47122
47123 @@ -1174,6 +1177,9 @@ static int do_umount(struct mount *mnt, int flags)
47124 br_write_unlock(vfsmount_lock);
47125 up_write(&namespace_sem);
47126 release_mounts(&umount_list);
47127 +
47128 + gr_log_unmount(mnt->mnt_devname, retval);
47129 +
47130 return retval;
47131 }
47132
47133 @@ -2175,6 +2181,16 @@ long do_mount(char *dev_name, char *dir_name, char *type_page,
47134 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
47135 MS_STRICTATIME);
47136
47137 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
47138 + retval = -EPERM;
47139 + goto dput_out;
47140 + }
47141 +
47142 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
47143 + retval = -EPERM;
47144 + goto dput_out;
47145 + }
47146 +
47147 if (flags & MS_REMOUNT)
47148 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
47149 data_page);
47150 @@ -2189,6 +2205,9 @@ long do_mount(char *dev_name, char *dir_name, char *type_page,
47151 dev_name, data_page);
47152 dput_out:
47153 path_put(&path);
47154 +
47155 + gr_log_mount(dev_name, dir_name, retval);
47156 +
47157 return retval;
47158 }
47159
47160 @@ -2470,6 +2489,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
47161 if (error)
47162 goto out2;
47163
47164 + if (gr_handle_chroot_pivot()) {
47165 + error = -EPERM;
47166 + goto out2;
47167 + }
47168 +
47169 get_fs_root(current->fs, &root);
47170 error = lock_mount(&old);
47171 if (error)
47172 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
47173 index f649fba..236bf92 100644
47174 --- a/fs/nfs/inode.c
47175 +++ b/fs/nfs/inode.c
47176 @@ -151,7 +151,7 @@ static void nfs_zap_caches_locked(struct inode *inode)
47177 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
47178 nfsi->attrtimeo_timestamp = jiffies;
47179
47180 - memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode)));
47181 + memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_I(inode)->cookieverf));
47182 if (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode))
47183 nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL|NFS_INO_REVAL_PAGECACHE;
47184 else
47185 @@ -1003,16 +1003,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
47186 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
47187 }
47188
47189 -static atomic_long_t nfs_attr_generation_counter;
47190 +static atomic_long_unchecked_t nfs_attr_generation_counter;
47191
47192 static unsigned long nfs_read_attr_generation_counter(void)
47193 {
47194 - return atomic_long_read(&nfs_attr_generation_counter);
47195 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
47196 }
47197
47198 unsigned long nfs_inc_attr_generation_counter(void)
47199 {
47200 - return atomic_long_inc_return(&nfs_attr_generation_counter);
47201 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
47202 }
47203
47204 void nfs_fattr_init(struct nfs_fattr *fattr)
47205 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
47206 index b96fe94..a4dbece 100644
47207 --- a/fs/nfsd/vfs.c
47208 +++ b/fs/nfsd/vfs.c
47209 @@ -925,7 +925,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
47210 } else {
47211 oldfs = get_fs();
47212 set_fs(KERNEL_DS);
47213 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
47214 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
47215 set_fs(oldfs);
47216 }
47217
47218 @@ -1029,7 +1029,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
47219
47220 /* Write the data. */
47221 oldfs = get_fs(); set_fs(KERNEL_DS);
47222 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &offset);
47223 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &offset);
47224 set_fs(oldfs);
47225 if (host_err < 0)
47226 goto out_nfserr;
47227 @@ -1564,7 +1564,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
47228 */
47229
47230 oldfs = get_fs(); set_fs(KERNEL_DS);
47231 - host_err = inode->i_op->readlink(dentry, buf, *lenp);
47232 + host_err = inode->i_op->readlink(dentry, (char __force_user *)buf, *lenp);
47233 set_fs(oldfs);
47234
47235 if (host_err < 0)
47236 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
47237 index 3568c8a..e0240d8 100644
47238 --- a/fs/notify/fanotify/fanotify_user.c
47239 +++ b/fs/notify/fanotify/fanotify_user.c
47240 @@ -278,7 +278,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
47241 goto out_close_fd;
47242
47243 ret = -EFAULT;
47244 - if (copy_to_user(buf, &fanotify_event_metadata,
47245 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
47246 + copy_to_user(buf, &fanotify_event_metadata,
47247 fanotify_event_metadata.event_len))
47248 goto out_kill_access_response;
47249
47250 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
47251 index ee18815..7aa5d01 100644
47252 --- a/fs/notify/notification.c
47253 +++ b/fs/notify/notification.c
47254 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
47255 * get set to 0 so it will never get 'freed'
47256 */
47257 static struct fsnotify_event *q_overflow_event;
47258 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
47259 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
47260
47261 /**
47262 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
47263 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
47264 */
47265 u32 fsnotify_get_cookie(void)
47266 {
47267 - return atomic_inc_return(&fsnotify_sync_cookie);
47268 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
47269 }
47270 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
47271
47272 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
47273 index 99e3610..02c1068 100644
47274 --- a/fs/ntfs/dir.c
47275 +++ b/fs/ntfs/dir.c
47276 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
47277 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
47278 ~(s64)(ndir->itype.index.block_size - 1)));
47279 /* Bounds checks. */
47280 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
47281 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
47282 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
47283 "inode 0x%lx or driver bug.", vdir->i_ino);
47284 goto err_out;
47285 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
47286 index c587e2d..3641eaa 100644
47287 --- a/fs/ntfs/file.c
47288 +++ b/fs/ntfs/file.c
47289 @@ -2229,6 +2229,6 @@ const struct inode_operations ntfs_file_inode_ops = {
47290 #endif /* NTFS_RW */
47291 };
47292
47293 -const struct file_operations ntfs_empty_file_ops = {};
47294 +const struct file_operations ntfs_empty_file_ops __read_only;
47295
47296 -const struct inode_operations ntfs_empty_inode_ops = {};
47297 +const struct inode_operations ntfs_empty_inode_ops __read_only;
47298 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
47299 index 210c352..a174f83 100644
47300 --- a/fs/ocfs2/localalloc.c
47301 +++ b/fs/ocfs2/localalloc.c
47302 @@ -1283,7 +1283,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
47303 goto bail;
47304 }
47305
47306 - atomic_inc(&osb->alloc_stats.moves);
47307 + atomic_inc_unchecked(&osb->alloc_stats.moves);
47308
47309 bail:
47310 if (handle)
47311 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
47312 index d355e6e..578d905 100644
47313 --- a/fs/ocfs2/ocfs2.h
47314 +++ b/fs/ocfs2/ocfs2.h
47315 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
47316
47317 struct ocfs2_alloc_stats
47318 {
47319 - atomic_t moves;
47320 - atomic_t local_data;
47321 - atomic_t bitmap_data;
47322 - atomic_t bg_allocs;
47323 - atomic_t bg_extends;
47324 + atomic_unchecked_t moves;
47325 + atomic_unchecked_t local_data;
47326 + atomic_unchecked_t bitmap_data;
47327 + atomic_unchecked_t bg_allocs;
47328 + atomic_unchecked_t bg_extends;
47329 };
47330
47331 enum ocfs2_local_alloc_state
47332 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
47333 index f169da4..9112253 100644
47334 --- a/fs/ocfs2/suballoc.c
47335 +++ b/fs/ocfs2/suballoc.c
47336 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
47337 mlog_errno(status);
47338 goto bail;
47339 }
47340 - atomic_inc(&osb->alloc_stats.bg_extends);
47341 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
47342
47343 /* You should never ask for this much metadata */
47344 BUG_ON(bits_wanted >
47345 @@ -2008,7 +2008,7 @@ int ocfs2_claim_metadata(handle_t *handle,
47346 mlog_errno(status);
47347 goto bail;
47348 }
47349 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
47350 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
47351
47352 *suballoc_loc = res.sr_bg_blkno;
47353 *suballoc_bit_start = res.sr_bit_offset;
47354 @@ -2172,7 +2172,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
47355 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
47356 res->sr_bits);
47357
47358 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
47359 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
47360
47361 BUG_ON(res->sr_bits != 1);
47362
47363 @@ -2214,7 +2214,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
47364 mlog_errno(status);
47365 goto bail;
47366 }
47367 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
47368 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
47369
47370 BUG_ON(res.sr_bits != 1);
47371
47372 @@ -2318,7 +2318,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
47373 cluster_start,
47374 num_clusters);
47375 if (!status)
47376 - atomic_inc(&osb->alloc_stats.local_data);
47377 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
47378 } else {
47379 if (min_clusters > (osb->bitmap_cpg - 1)) {
47380 /* The only paths asking for contiguousness
47381 @@ -2344,7 +2344,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
47382 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
47383 res.sr_bg_blkno,
47384 res.sr_bit_offset);
47385 - atomic_inc(&osb->alloc_stats.bitmap_data);
47386 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
47387 *num_clusters = res.sr_bits;
47388 }
47389 }
47390 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
47391 index 604e12c..8426483 100644
47392 --- a/fs/ocfs2/super.c
47393 +++ b/fs/ocfs2/super.c
47394 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
47395 "%10s => GlobalAllocs: %d LocalAllocs: %d "
47396 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
47397 "Stats",
47398 - atomic_read(&osb->alloc_stats.bitmap_data),
47399 - atomic_read(&osb->alloc_stats.local_data),
47400 - atomic_read(&osb->alloc_stats.bg_allocs),
47401 - atomic_read(&osb->alloc_stats.moves),
47402 - atomic_read(&osb->alloc_stats.bg_extends));
47403 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
47404 + atomic_read_unchecked(&osb->alloc_stats.local_data),
47405 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
47406 + atomic_read_unchecked(&osb->alloc_stats.moves),
47407 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
47408
47409 out += snprintf(buf + out, len - out,
47410 "%10s => State: %u Descriptor: %llu Size: %u bits "
47411 @@ -2117,11 +2117,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
47412 spin_lock_init(&osb->osb_xattr_lock);
47413 ocfs2_init_steal_slots(osb);
47414
47415 - atomic_set(&osb->alloc_stats.moves, 0);
47416 - atomic_set(&osb->alloc_stats.local_data, 0);
47417 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
47418 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
47419 - atomic_set(&osb->alloc_stats.bg_extends, 0);
47420 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
47421 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
47422 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
47423 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
47424 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
47425
47426 /* Copy the blockcheck stats from the superblock probe */
47427 osb->osb_ecc_stats = *stats;
47428 diff --git a/fs/ocfs2/symlink.c b/fs/ocfs2/symlink.c
47429 index 5d22872..523db20 100644
47430 --- a/fs/ocfs2/symlink.c
47431 +++ b/fs/ocfs2/symlink.c
47432 @@ -142,7 +142,7 @@ bail:
47433
47434 static void ocfs2_fast_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
47435 {
47436 - char *link = nd_get_link(nd);
47437 + const char *link = nd_get_link(nd);
47438 if (!IS_ERR(link))
47439 kfree(link);
47440 }
47441 diff --git a/fs/open.c b/fs/open.c
47442 index 77becc0..aad7bd9 100644
47443 --- a/fs/open.c
47444 +++ b/fs/open.c
47445 @@ -112,6 +112,10 @@ static long do_sys_truncate(const char __user *pathname, loff_t length)
47446 error = locks_verify_truncate(inode, NULL, length);
47447 if (!error)
47448 error = security_path_truncate(&path);
47449 +
47450 + if (!error && !gr_acl_handle_truncate(path.dentry, path.mnt))
47451 + error = -EACCES;
47452 +
47453 if (!error)
47454 error = do_truncate(path.dentry, length, 0, NULL);
47455
47456 @@ -358,6 +362,9 @@ SYSCALL_DEFINE3(faccessat, int, dfd, const char __user *, filename, int, mode)
47457 if (__mnt_is_readonly(path.mnt))
47458 res = -EROFS;
47459
47460 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
47461 + res = -EACCES;
47462 +
47463 out_path_release:
47464 path_put(&path);
47465 out:
47466 @@ -384,6 +391,8 @@ SYSCALL_DEFINE1(chdir, const char __user *, filename)
47467 if (error)
47468 goto dput_and_out;
47469
47470 + gr_log_chdir(path.dentry, path.mnt);
47471 +
47472 set_fs_pwd(current->fs, &path);
47473
47474 dput_and_out:
47475 @@ -410,6 +419,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
47476 goto out_putf;
47477
47478 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
47479 +
47480 + if (!error && !gr_chroot_fchdir(file->f_path.dentry, file->f_path.mnt))
47481 + error = -EPERM;
47482 +
47483 + if (!error)
47484 + gr_log_chdir(file->f_path.dentry, file->f_path.mnt);
47485 +
47486 if (!error)
47487 set_fs_pwd(current->fs, &file->f_path);
47488 out_putf:
47489 @@ -438,7 +454,13 @@ SYSCALL_DEFINE1(chroot, const char __user *, filename)
47490 if (error)
47491 goto dput_and_out;
47492
47493 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
47494 + goto dput_and_out;
47495 +
47496 set_fs_root(current->fs, &path);
47497 +
47498 + gr_handle_chroot_chdir(&path);
47499 +
47500 error = 0;
47501 dput_and_out:
47502 path_put(&path);
47503 @@ -456,6 +478,16 @@ static int chmod_common(struct path *path, umode_t mode)
47504 if (error)
47505 return error;
47506 mutex_lock(&inode->i_mutex);
47507 +
47508 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
47509 + error = -EACCES;
47510 + goto out_unlock;
47511 + }
47512 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
47513 + error = -EACCES;
47514 + goto out_unlock;
47515 + }
47516 +
47517 error = security_path_chmod(path, mode);
47518 if (error)
47519 goto out_unlock;
47520 @@ -506,6 +538,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
47521 int error;
47522 struct iattr newattrs;
47523
47524 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
47525 + return -EACCES;
47526 +
47527 newattrs.ia_valid = ATTR_CTIME;
47528 if (user != (uid_t) -1) {
47529 newattrs.ia_valid |= ATTR_UID;
47530 diff --git a/fs/pipe.c b/fs/pipe.c
47531 index 82e651b..8a68573 100644
47532 --- a/fs/pipe.c
47533 +++ b/fs/pipe.c
47534 @@ -437,9 +437,9 @@ redo:
47535 }
47536 if (bufs) /* More to do? */
47537 continue;
47538 - if (!pipe->writers)
47539 + if (!atomic_read(&pipe->writers))
47540 break;
47541 - if (!pipe->waiting_writers) {
47542 + if (!atomic_read(&pipe->waiting_writers)) {
47543 /* syscall merging: Usually we must not sleep
47544 * if O_NONBLOCK is set, or if we got some data.
47545 * But if a writer sleeps in kernel space, then
47546 @@ -503,7 +503,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
47547 mutex_lock(&inode->i_mutex);
47548 pipe = inode->i_pipe;
47549
47550 - if (!pipe->readers) {
47551 + if (!atomic_read(&pipe->readers)) {
47552 send_sig(SIGPIPE, current, 0);
47553 ret = -EPIPE;
47554 goto out;
47555 @@ -552,7 +552,7 @@ redo1:
47556 for (;;) {
47557 int bufs;
47558
47559 - if (!pipe->readers) {
47560 + if (!atomic_read(&pipe->readers)) {
47561 send_sig(SIGPIPE, current, 0);
47562 if (!ret)
47563 ret = -EPIPE;
47564 @@ -643,9 +643,9 @@ redo2:
47565 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
47566 do_wakeup = 0;
47567 }
47568 - pipe->waiting_writers++;
47569 + atomic_inc(&pipe->waiting_writers);
47570 pipe_wait(pipe);
47571 - pipe->waiting_writers--;
47572 + atomic_dec(&pipe->waiting_writers);
47573 }
47574 out:
47575 mutex_unlock(&inode->i_mutex);
47576 @@ -712,7 +712,7 @@ pipe_poll(struct file *filp, poll_table *wait)
47577 mask = 0;
47578 if (filp->f_mode & FMODE_READ) {
47579 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
47580 - if (!pipe->writers && filp->f_version != pipe->w_counter)
47581 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
47582 mask |= POLLHUP;
47583 }
47584
47585 @@ -722,7 +722,7 @@ pipe_poll(struct file *filp, poll_table *wait)
47586 * Most Unices do not set POLLERR for FIFOs but on Linux they
47587 * behave exactly like pipes for poll().
47588 */
47589 - if (!pipe->readers)
47590 + if (!atomic_read(&pipe->readers))
47591 mask |= POLLERR;
47592 }
47593
47594 @@ -736,10 +736,10 @@ pipe_release(struct inode *inode, int decr, int decw)
47595
47596 mutex_lock(&inode->i_mutex);
47597 pipe = inode->i_pipe;
47598 - pipe->readers -= decr;
47599 - pipe->writers -= decw;
47600 + atomic_sub(decr, &pipe->readers);
47601 + atomic_sub(decw, &pipe->writers);
47602
47603 - if (!pipe->readers && !pipe->writers) {
47604 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers)) {
47605 free_pipe_info(inode);
47606 } else {
47607 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
47608 @@ -829,7 +829,7 @@ pipe_read_open(struct inode *inode, struct file *filp)
47609
47610 if (inode->i_pipe) {
47611 ret = 0;
47612 - inode->i_pipe->readers++;
47613 + atomic_inc(&inode->i_pipe->readers);
47614 }
47615
47616 mutex_unlock(&inode->i_mutex);
47617 @@ -846,7 +846,7 @@ pipe_write_open(struct inode *inode, struct file *filp)
47618
47619 if (inode->i_pipe) {
47620 ret = 0;
47621 - inode->i_pipe->writers++;
47622 + atomic_inc(&inode->i_pipe->writers);
47623 }
47624
47625 mutex_unlock(&inode->i_mutex);
47626 @@ -864,9 +864,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
47627 if (inode->i_pipe) {
47628 ret = 0;
47629 if (filp->f_mode & FMODE_READ)
47630 - inode->i_pipe->readers++;
47631 + atomic_inc(&inode->i_pipe->readers);
47632 if (filp->f_mode & FMODE_WRITE)
47633 - inode->i_pipe->writers++;
47634 + atomic_inc(&inode->i_pipe->writers);
47635 }
47636
47637 mutex_unlock(&inode->i_mutex);
47638 @@ -958,7 +958,7 @@ void free_pipe_info(struct inode *inode)
47639 inode->i_pipe = NULL;
47640 }
47641
47642 -static struct vfsmount *pipe_mnt __read_mostly;
47643 +struct vfsmount *pipe_mnt __read_mostly;
47644
47645 /*
47646 * pipefs_dname() is called from d_path().
47647 @@ -988,7 +988,8 @@ static struct inode * get_pipe_inode(void)
47648 goto fail_iput;
47649 inode->i_pipe = pipe;
47650
47651 - pipe->readers = pipe->writers = 1;
47652 + atomic_set(&pipe->readers, 1);
47653 + atomic_set(&pipe->writers, 1);
47654 inode->i_fop = &rdwr_pipefifo_fops;
47655
47656 /*
47657 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
47658 index 15af622..0e9f4467 100644
47659 --- a/fs/proc/Kconfig
47660 +++ b/fs/proc/Kconfig
47661 @@ -30,12 +30,12 @@ config PROC_FS
47662
47663 config PROC_KCORE
47664 bool "/proc/kcore support" if !ARM
47665 - depends on PROC_FS && MMU
47666 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
47667
47668 config PROC_VMCORE
47669 bool "/proc/vmcore support"
47670 - depends on PROC_FS && CRASH_DUMP
47671 - default y
47672 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
47673 + default n
47674 help
47675 Exports the dump image of crashed kernel in ELF format.
47676
47677 @@ -59,8 +59,8 @@ config PROC_SYSCTL
47678 limited in memory.
47679
47680 config PROC_PAGE_MONITOR
47681 - default y
47682 - depends on PROC_FS && MMU
47683 + default n
47684 + depends on PROC_FS && MMU && !GRKERNSEC
47685 bool "Enable /proc page monitoring" if EXPERT
47686 help
47687 Various /proc files exist to monitor process memory utilization:
47688 diff --git a/fs/proc/array.c b/fs/proc/array.c
47689 index c602b8d..a7de642 100644
47690 --- a/fs/proc/array.c
47691 +++ b/fs/proc/array.c
47692 @@ -60,6 +60,7 @@
47693 #include <linux/tty.h>
47694 #include <linux/string.h>
47695 #include <linux/mman.h>
47696 +#include <linux/grsecurity.h>
47697 #include <linux/proc_fs.h>
47698 #include <linux/ioport.h>
47699 #include <linux/uaccess.h>
47700 @@ -337,6 +338,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
47701 seq_putc(m, '\n');
47702 }
47703
47704 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
47705 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
47706 +{
47707 + if (p->mm)
47708 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
47709 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
47710 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
47711 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
47712 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
47713 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
47714 + else
47715 + seq_printf(m, "PaX:\t-----\n");
47716 +}
47717 +#endif
47718 +
47719 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
47720 struct pid *pid, struct task_struct *task)
47721 {
47722 @@ -354,9 +370,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
47723 task_cpus_allowed(m, task);
47724 cpuset_task_status_allowed(m, task);
47725 task_context_switch_counts(m, task);
47726 +
47727 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
47728 + task_pax(m, task);
47729 +#endif
47730 +
47731 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
47732 + task_grsec_rbac(m, task);
47733 +#endif
47734 +
47735 return 0;
47736 }
47737
47738 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
47739 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
47740 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
47741 + _mm->pax_flags & MF_PAX_SEGMEXEC))
47742 +#endif
47743 +
47744 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
47745 struct pid *pid, struct task_struct *task, int whole)
47746 {
47747 @@ -378,6 +409,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
47748 char tcomm[sizeof(task->comm)];
47749 unsigned long flags;
47750
47751 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
47752 + if (current->exec_id != m->exec_id) {
47753 + gr_log_badprocpid("stat");
47754 + return 0;
47755 + }
47756 +#endif
47757 +
47758 state = *get_task_state(task);
47759 vsize = eip = esp = 0;
47760 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
47761 @@ -449,6 +487,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
47762 gtime = task->gtime;
47763 }
47764
47765 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
47766 + if (PAX_RAND_FLAGS(mm)) {
47767 + eip = 0;
47768 + esp = 0;
47769 + wchan = 0;
47770 + }
47771 +#endif
47772 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47773 + wchan = 0;
47774 + eip =0;
47775 + esp =0;
47776 +#endif
47777 +
47778 /* scale priority and nice values from timeslices to -20..20 */
47779 /* to make it look like a "normal" Unix priority/nice value */
47780 priority = task_prio(task);
47781 @@ -489,9 +540,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
47782 vsize,
47783 mm ? get_mm_rss(mm) : 0,
47784 rsslim,
47785 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
47786 + PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0),
47787 + PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0),
47788 + PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0),
47789 +#else
47790 mm ? (permitted ? mm->start_code : 1) : 0,
47791 mm ? (permitted ? mm->end_code : 1) : 0,
47792 (permitted && mm) ? mm->start_stack : 0,
47793 +#endif
47794 esp,
47795 eip,
47796 /* The signal information here is obsolete.
47797 @@ -536,8 +593,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
47798 struct pid *pid, struct task_struct *task)
47799 {
47800 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
47801 - struct mm_struct *mm = get_task_mm(task);
47802 + struct mm_struct *mm;
47803
47804 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
47805 + if (current->exec_id != m->exec_id) {
47806 + gr_log_badprocpid("statm");
47807 + return 0;
47808 + }
47809 +#endif
47810 + mm = get_task_mm(task);
47811 if (mm) {
47812 size = task_statm(mm, &shared, &text, &data, &resident);
47813 mmput(mm);
47814 @@ -547,3 +611,18 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
47815
47816 return 0;
47817 }
47818 +
47819 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
47820 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
47821 +{
47822 + u32 curr_ip = 0;
47823 + unsigned long flags;
47824 +
47825 + if (lock_task_sighand(task, &flags)) {
47826 + curr_ip = task->signal->curr_ip;
47827 + unlock_task_sighand(task, &flags);
47828 + }
47829 +
47830 + return sprintf(buffer, "%pI4\n", &curr_ip);
47831 +}
47832 +#endif
47833 diff --git a/fs/proc/base.c b/fs/proc/base.c
47834 index d4548dd..d101f84 100644
47835 --- a/fs/proc/base.c
47836 +++ b/fs/proc/base.c
47837 @@ -109,6 +109,14 @@ struct pid_entry {
47838 union proc_op op;
47839 };
47840
47841 +struct getdents_callback {
47842 + struct linux_dirent __user * current_dir;
47843 + struct linux_dirent __user * previous;
47844 + struct file * file;
47845 + int count;
47846 + int error;
47847 +};
47848 +
47849 #define NOD(NAME, MODE, IOP, FOP, OP) { \
47850 .name = (NAME), \
47851 .len = sizeof(NAME) - 1, \
47852 @@ -213,6 +221,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
47853 if (!mm->arg_end)
47854 goto out_mm; /* Shh! No looking before we're done */
47855
47856 + if (gr_acl_handle_procpidmem(task))
47857 + goto out_mm;
47858 +
47859 len = mm->arg_end - mm->arg_start;
47860
47861 if (len > PAGE_SIZE)
47862 @@ -240,12 +251,28 @@ out:
47863 return res;
47864 }
47865
47866 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
47867 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
47868 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
47869 + _mm->pax_flags & MF_PAX_SEGMEXEC))
47870 +#endif
47871 +
47872 static int proc_pid_auxv(struct task_struct *task, char *buffer)
47873 {
47874 struct mm_struct *mm = mm_for_maps(task);
47875 int res = PTR_ERR(mm);
47876 if (mm && !IS_ERR(mm)) {
47877 unsigned int nwords = 0;
47878 +
47879 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
47880 + /* allow if we're currently ptracing this task */
47881 + if (PAX_RAND_FLAGS(mm) &&
47882 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
47883 + mmput(mm);
47884 + return 0;
47885 + }
47886 +#endif
47887 +
47888 do {
47889 nwords += 2;
47890 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
47891 @@ -259,7 +286,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
47892 }
47893
47894
47895 -#ifdef CONFIG_KALLSYMS
47896 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
47897 /*
47898 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
47899 * Returns the resolved symbol. If that fails, simply return the address.
47900 @@ -298,7 +325,7 @@ static void unlock_trace(struct task_struct *task)
47901 mutex_unlock(&task->signal->cred_guard_mutex);
47902 }
47903
47904 -#ifdef CONFIG_STACKTRACE
47905 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
47906
47907 #define MAX_STACK_TRACE_DEPTH 64
47908
47909 @@ -489,7 +516,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
47910 return count;
47911 }
47912
47913 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
47914 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
47915 static int proc_pid_syscall(struct task_struct *task, char *buffer)
47916 {
47917 long nr;
47918 @@ -518,7 +545,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
47919 /************************************************************************/
47920
47921 /* permission checks */
47922 -static int proc_fd_access_allowed(struct inode *inode)
47923 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
47924 {
47925 struct task_struct *task;
47926 int allowed = 0;
47927 @@ -528,7 +555,10 @@ static int proc_fd_access_allowed(struct inode *inode)
47928 */
47929 task = get_proc_task(inode);
47930 if (task) {
47931 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
47932 + if (log)
47933 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
47934 + else
47935 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
47936 put_task_struct(task);
47937 }
47938 return allowed;
47939 @@ -566,10 +596,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
47940 struct task_struct *task,
47941 int hide_pid_min)
47942 {
47943 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
47944 + return false;
47945 +
47946 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
47947 + rcu_read_lock();
47948 + {
47949 + const struct cred *tmpcred = current_cred();
47950 + const struct cred *cred = __task_cred(task);
47951 +
47952 + if (!tmpcred->uid || (tmpcred->uid == cred->uid)
47953 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
47954 + || in_group_p(CONFIG_GRKERNSEC_PROC_GID)
47955 +#endif
47956 + ) {
47957 + rcu_read_unlock();
47958 + return true;
47959 + }
47960 + }
47961 + rcu_read_unlock();
47962 +
47963 + if (!pid->hide_pid)
47964 + return false;
47965 +#endif
47966 +
47967 if (pid->hide_pid < hide_pid_min)
47968 return true;
47969 if (in_group_p(pid->pid_gid))
47970 return true;
47971 +
47972 return ptrace_may_access(task, PTRACE_MODE_READ);
47973 }
47974
47975 @@ -587,7 +642,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
47976 put_task_struct(task);
47977
47978 if (!has_perms) {
47979 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
47980 + {
47981 +#else
47982 if (pid->hide_pid == 2) {
47983 +#endif
47984 /*
47985 * Let's make getdents(), stat(), and open()
47986 * consistent with each other. If a process
47987 @@ -702,6 +761,10 @@ static int mem_open(struct inode* inode, struct file* file)
47988 file->f_mode |= FMODE_UNSIGNED_OFFSET;
47989 file->private_data = mm;
47990
47991 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
47992 + file->f_version = current->exec_id;
47993 +#endif
47994 +
47995 return 0;
47996 }
47997
47998 @@ -713,6 +776,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
47999 ssize_t copied;
48000 char *page;
48001
48002 +#ifdef CONFIG_GRKERNSEC
48003 + if (write)
48004 + return -EPERM;
48005 +#endif
48006 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
48007 + if (file->f_version != current->exec_id) {
48008 + gr_log_badprocpid("mem");
48009 + return 0;
48010 + }
48011 +#endif
48012 +
48013 if (!mm)
48014 return 0;
48015
48016 @@ -813,6 +887,9 @@ static ssize_t environ_read(struct file *file, char __user *buf,
48017 if (!task)
48018 goto out_no_task;
48019
48020 + if (gr_acl_handle_procpidmem(task))
48021 + goto out;
48022 +
48023 ret = -ENOMEM;
48024 page = (char *)__get_free_page(GFP_TEMPORARY);
48025 if (!page)
48026 @@ -1434,7 +1511,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
48027 path_put(&nd->path);
48028
48029 /* Are we allowed to snoop on the tasks file descriptors? */
48030 - if (!proc_fd_access_allowed(inode))
48031 + if (!proc_fd_access_allowed(inode, 0))
48032 goto out;
48033
48034 error = PROC_I(inode)->op.proc_get_link(dentry, &nd->path);
48035 @@ -1473,8 +1550,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
48036 struct path path;
48037
48038 /* Are we allowed to snoop on the tasks file descriptors? */
48039 - if (!proc_fd_access_allowed(inode))
48040 - goto out;
48041 + /* logging this is needed for learning on chromium to work properly,
48042 + but we don't want to flood the logs from 'ps' which does a readlink
48043 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
48044 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
48045 + */
48046 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
48047 + if (!proc_fd_access_allowed(inode,0))
48048 + goto out;
48049 + } else {
48050 + if (!proc_fd_access_allowed(inode,1))
48051 + goto out;
48052 + }
48053
48054 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
48055 if (error)
48056 @@ -1539,7 +1626,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
48057 rcu_read_lock();
48058 cred = __task_cred(task);
48059 inode->i_uid = cred->euid;
48060 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
48061 + inode->i_gid = CONFIG_GRKERNSEC_PROC_GID;
48062 +#else
48063 inode->i_gid = cred->egid;
48064 +#endif
48065 rcu_read_unlock();
48066 }
48067 security_task_to_inode(task, inode);
48068 @@ -1575,10 +1666,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
48069 return -ENOENT;
48070 }
48071 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
48072 +#ifdef CONFIG_GRKERNSEC_PROC_USER
48073 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
48074 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
48075 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
48076 +#endif
48077 task_dumpable(task)) {
48078 cred = __task_cred(task);
48079 stat->uid = cred->euid;
48080 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
48081 + stat->gid = CONFIG_GRKERNSEC_PROC_GID;
48082 +#else
48083 stat->gid = cred->egid;
48084 +#endif
48085 }
48086 }
48087 rcu_read_unlock();
48088 @@ -1616,11 +1716,20 @@ int pid_revalidate(struct dentry *dentry, struct nameidata *nd)
48089
48090 if (task) {
48091 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
48092 +#ifdef CONFIG_GRKERNSEC_PROC_USER
48093 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
48094 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
48095 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
48096 +#endif
48097 task_dumpable(task)) {
48098 rcu_read_lock();
48099 cred = __task_cred(task);
48100 inode->i_uid = cred->euid;
48101 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
48102 + inode->i_gid = CONFIG_GRKERNSEC_PROC_GID;
48103 +#else
48104 inode->i_gid = cred->egid;
48105 +#endif
48106 rcu_read_unlock();
48107 } else {
48108 inode->i_uid = 0;
48109 @@ -1738,7 +1847,8 @@ static int proc_fd_info(struct inode *inode, struct path *path, char *info)
48110 int fd = proc_fd(inode);
48111
48112 if (task) {
48113 - files = get_files_struct(task);
48114 + if (!gr_acl_handle_procpidmem(task))
48115 + files = get_files_struct(task);
48116 put_task_struct(task);
48117 }
48118 if (files) {
48119 @@ -2355,11 +2465,21 @@ static const struct file_operations proc_map_files_operations = {
48120 */
48121 static int proc_fd_permission(struct inode *inode, int mask)
48122 {
48123 + struct task_struct *task;
48124 int rv = generic_permission(inode, mask);
48125 - if (rv == 0)
48126 - return 0;
48127 +
48128 if (task_pid(current) == proc_pid(inode))
48129 rv = 0;
48130 +
48131 + task = get_proc_task(inode);
48132 + if (task == NULL)
48133 + return rv;
48134 +
48135 + if (gr_acl_handle_procpidmem(task))
48136 + rv = -EACCES;
48137 +
48138 + put_task_struct(task);
48139 +
48140 return rv;
48141 }
48142
48143 @@ -2469,6 +2589,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
48144 if (!task)
48145 goto out_no_task;
48146
48147 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
48148 + goto out;
48149 +
48150 /*
48151 * Yes, it does not scale. And it should not. Don't add
48152 * new entries into /proc/<tgid>/ without very good reasons.
48153 @@ -2513,6 +2636,9 @@ static int proc_pident_readdir(struct file *filp,
48154 if (!task)
48155 goto out_no_task;
48156
48157 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
48158 + goto out;
48159 +
48160 ret = 0;
48161 i = filp->f_pos;
48162 switch (i) {
48163 @@ -2783,7 +2909,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
48164 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
48165 void *cookie)
48166 {
48167 - char *s = nd_get_link(nd);
48168 + const char *s = nd_get_link(nd);
48169 if (!IS_ERR(s))
48170 __putname(s);
48171 }
48172 @@ -2984,7 +3110,7 @@ static const struct pid_entry tgid_base_stuff[] = {
48173 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
48174 #endif
48175 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
48176 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
48177 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
48178 INF("syscall", S_IRUGO, proc_pid_syscall),
48179 #endif
48180 INF("cmdline", S_IRUGO, proc_pid_cmdline),
48181 @@ -3009,10 +3135,10 @@ static const struct pid_entry tgid_base_stuff[] = {
48182 #ifdef CONFIG_SECURITY
48183 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
48184 #endif
48185 -#ifdef CONFIG_KALLSYMS
48186 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
48187 INF("wchan", S_IRUGO, proc_pid_wchan),
48188 #endif
48189 -#ifdef CONFIG_STACKTRACE
48190 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
48191 ONE("stack", S_IRUGO, proc_pid_stack),
48192 #endif
48193 #ifdef CONFIG_SCHEDSTATS
48194 @@ -3046,6 +3172,9 @@ static const struct pid_entry tgid_base_stuff[] = {
48195 #ifdef CONFIG_HARDWALL
48196 INF("hardwall", S_IRUGO, proc_pid_hardwall),
48197 #endif
48198 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
48199 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
48200 +#endif
48201 };
48202
48203 static int proc_tgid_base_readdir(struct file * filp,
48204 @@ -3172,7 +3301,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
48205 if (!inode)
48206 goto out;
48207
48208 +#ifdef CONFIG_GRKERNSEC_PROC_USER
48209 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
48210 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
48211 + inode->i_gid = CONFIG_GRKERNSEC_PROC_GID;
48212 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
48213 +#else
48214 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
48215 +#endif
48216 inode->i_op = &proc_tgid_base_inode_operations;
48217 inode->i_fop = &proc_tgid_base_operations;
48218 inode->i_flags|=S_IMMUTABLE;
48219 @@ -3214,7 +3350,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct
48220 if (!task)
48221 goto out;
48222
48223 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
48224 + goto out_put_task;
48225 +
48226 result = proc_pid_instantiate(dir, dentry, task, NULL);
48227 +out_put_task:
48228 put_task_struct(task);
48229 out:
48230 return result;
48231 @@ -3277,6 +3417,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
48232 static int fake_filldir(void *buf, const char *name, int namelen,
48233 loff_t offset, u64 ino, unsigned d_type)
48234 {
48235 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
48236 + __buf->error = -EINVAL;
48237 return 0;
48238 }
48239
48240 @@ -3343,7 +3485,7 @@ static const struct pid_entry tid_base_stuff[] = {
48241 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
48242 #endif
48243 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
48244 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
48245 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
48246 INF("syscall", S_IRUGO, proc_pid_syscall),
48247 #endif
48248 INF("cmdline", S_IRUGO, proc_pid_cmdline),
48249 @@ -3367,10 +3509,10 @@ static const struct pid_entry tid_base_stuff[] = {
48250 #ifdef CONFIG_SECURITY
48251 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
48252 #endif
48253 -#ifdef CONFIG_KALLSYMS
48254 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
48255 INF("wchan", S_IRUGO, proc_pid_wchan),
48256 #endif
48257 -#ifdef CONFIG_STACKTRACE
48258 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
48259 ONE("stack", S_IRUGO, proc_pid_stack),
48260 #endif
48261 #ifdef CONFIG_SCHEDSTATS
48262 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
48263 index 82676e3..5f8518a 100644
48264 --- a/fs/proc/cmdline.c
48265 +++ b/fs/proc/cmdline.c
48266 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
48267
48268 static int __init proc_cmdline_init(void)
48269 {
48270 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
48271 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
48272 +#else
48273 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
48274 +#endif
48275 return 0;
48276 }
48277 module_init(proc_cmdline_init);
48278 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
48279 index b143471..bb105e5 100644
48280 --- a/fs/proc/devices.c
48281 +++ b/fs/proc/devices.c
48282 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
48283
48284 static int __init proc_devices_init(void)
48285 {
48286 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
48287 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
48288 +#else
48289 proc_create("devices", 0, NULL, &proc_devinfo_operations);
48290 +#endif
48291 return 0;
48292 }
48293 module_init(proc_devices_init);
48294 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
48295 index 84fd323..f698a32 100644
48296 --- a/fs/proc/inode.c
48297 +++ b/fs/proc/inode.c
48298 @@ -21,12 +21,18 @@
48299 #include <linux/seq_file.h>
48300 #include <linux/slab.h>
48301 #include <linux/mount.h>
48302 +#include <linux/grsecurity.h>
48303
48304 #include <asm/system.h>
48305 #include <asm/uaccess.h>
48306
48307 #include "internal.h"
48308
48309 +#ifdef CONFIG_PROC_SYSCTL
48310 +extern const struct inode_operations proc_sys_inode_operations;
48311 +extern const struct inode_operations proc_sys_dir_operations;
48312 +#endif
48313 +
48314 static void proc_evict_inode(struct inode *inode)
48315 {
48316 struct proc_dir_entry *de;
48317 @@ -52,6 +58,13 @@ static void proc_evict_inode(struct inode *inode)
48318 ns_ops = PROC_I(inode)->ns_ops;
48319 if (ns_ops && ns_ops->put)
48320 ns_ops->put(PROC_I(inode)->ns);
48321 +
48322 +#ifdef CONFIG_PROC_SYSCTL
48323 + if (inode->i_op == &proc_sys_inode_operations ||
48324 + inode->i_op == &proc_sys_dir_operations)
48325 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
48326 +#endif
48327 +
48328 }
48329
48330 static struct kmem_cache * proc_inode_cachep;
48331 @@ -457,7 +470,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
48332 if (de->mode) {
48333 inode->i_mode = de->mode;
48334 inode->i_uid = de->uid;
48335 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
48336 + inode->i_gid = CONFIG_GRKERNSEC_PROC_GID;
48337 +#else
48338 inode->i_gid = de->gid;
48339 +#endif
48340 }
48341 if (de->size)
48342 inode->i_size = de->size;
48343 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
48344 index 2925775..4f08fae 100644
48345 --- a/fs/proc/internal.h
48346 +++ b/fs/proc/internal.h
48347 @@ -51,6 +51,9 @@ extern int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
48348 struct pid *pid, struct task_struct *task);
48349 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
48350 struct pid *pid, struct task_struct *task);
48351 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
48352 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
48353 +#endif
48354 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
48355
48356 extern const struct file_operations proc_maps_operations;
48357 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
48358 index d245cb2..f4e8498 100644
48359 --- a/fs/proc/kcore.c
48360 +++ b/fs/proc/kcore.c
48361 @@ -478,9 +478,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
48362 * the addresses in the elf_phdr on our list.
48363 */
48364 start = kc_offset_to_vaddr(*fpos - elf_buflen);
48365 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
48366 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
48367 + if (tsz > buflen)
48368 tsz = buflen;
48369 -
48370 +
48371 while (buflen) {
48372 struct kcore_list *m;
48373
48374 @@ -509,20 +510,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
48375 kfree(elf_buf);
48376 } else {
48377 if (kern_addr_valid(start)) {
48378 - unsigned long n;
48379 + char *elf_buf;
48380 + mm_segment_t oldfs;
48381
48382 - n = copy_to_user(buffer, (char *)start, tsz);
48383 - /*
48384 - * We cannot distingush between fault on source
48385 - * and fault on destination. When this happens
48386 - * we clear too and hope it will trigger the
48387 - * EFAULT again.
48388 - */
48389 - if (n) {
48390 - if (clear_user(buffer + tsz - n,
48391 - n))
48392 + elf_buf = kmalloc(tsz, GFP_KERNEL);
48393 + if (!elf_buf)
48394 + return -ENOMEM;
48395 + oldfs = get_fs();
48396 + set_fs(KERNEL_DS);
48397 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
48398 + set_fs(oldfs);
48399 + if (copy_to_user(buffer, elf_buf, tsz)) {
48400 + kfree(elf_buf);
48401 return -EFAULT;
48402 + }
48403 }
48404 + set_fs(oldfs);
48405 + kfree(elf_buf);
48406 } else {
48407 if (clear_user(buffer, tsz))
48408 return -EFAULT;
48409 @@ -542,6 +546,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
48410
48411 static int open_kcore(struct inode *inode, struct file *filp)
48412 {
48413 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
48414 + return -EPERM;
48415 +#endif
48416 if (!capable(CAP_SYS_RAWIO))
48417 return -EPERM;
48418 if (kcore_need_update)
48419 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
48420 index 80e4645..53e5fcf 100644
48421 --- a/fs/proc/meminfo.c
48422 +++ b/fs/proc/meminfo.c
48423 @@ -158,7 +158,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
48424 vmi.used >> 10,
48425 vmi.largest_chunk >> 10
48426 #ifdef CONFIG_MEMORY_FAILURE
48427 - ,atomic_long_read(&mce_bad_pages) << (PAGE_SHIFT - 10)
48428 + ,atomic_long_read_unchecked(&mce_bad_pages) << (PAGE_SHIFT - 10)
48429 #endif
48430 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
48431 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
48432 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
48433 index b1822dd..df622cb 100644
48434 --- a/fs/proc/nommu.c
48435 +++ b/fs/proc/nommu.c
48436 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
48437 if (len < 1)
48438 len = 1;
48439 seq_printf(m, "%*c", len, ' ');
48440 - seq_path(m, &file->f_path, "");
48441 + seq_path(m, &file->f_path, "\n\\");
48442 }
48443
48444 seq_putc(m, '\n');
48445 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
48446 index 06e1cc1..177cd98 100644
48447 --- a/fs/proc/proc_net.c
48448 +++ b/fs/proc/proc_net.c
48449 @@ -105,6 +105,17 @@ static struct net *get_proc_task_net(struct inode *dir)
48450 struct task_struct *task;
48451 struct nsproxy *ns;
48452 struct net *net = NULL;
48453 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
48454 + const struct cred *cred = current_cred();
48455 +#endif
48456 +
48457 +#ifdef CONFIG_GRKERNSEC_PROC_USER
48458 + if (cred->fsuid)
48459 + return net;
48460 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
48461 + if (cred->fsuid && !in_group_p(CONFIG_GRKERNSEC_PROC_GID))
48462 + return net;
48463 +#endif
48464
48465 rcu_read_lock();
48466 task = pid_task(proc_pid(dir), PIDTYPE_PID);
48467 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
48468 index 53c3bce..10ad159 100644
48469 --- a/fs/proc/proc_sysctl.c
48470 +++ b/fs/proc/proc_sysctl.c
48471 @@ -9,11 +9,13 @@
48472 #include <linux/namei.h>
48473 #include "internal.h"
48474
48475 +extern __u32 gr_handle_sysctl(const struct ctl_table *table, const int op);
48476 +
48477 static const struct dentry_operations proc_sys_dentry_operations;
48478 static const struct file_operations proc_sys_file_operations;
48479 -static const struct inode_operations proc_sys_inode_operations;
48480 +const struct inode_operations proc_sys_inode_operations;
48481 static const struct file_operations proc_sys_dir_file_operations;
48482 -static const struct inode_operations proc_sys_dir_operations;
48483 +const struct inode_operations proc_sys_dir_operations;
48484
48485 void proc_sys_poll_notify(struct ctl_table_poll *poll)
48486 {
48487 @@ -131,8 +133,14 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
48488
48489 err = NULL;
48490 d_set_d_op(dentry, &proc_sys_dentry_operations);
48491 +
48492 + gr_handle_proc_create(dentry, inode);
48493 +
48494 d_add(dentry, inode);
48495
48496 + if (gr_handle_sysctl(p, MAY_EXEC))
48497 + err = ERR_PTR(-ENOENT);
48498 +
48499 out:
48500 sysctl_head_finish(head);
48501 return err;
48502 @@ -163,6 +171,12 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
48503 if (!table->proc_handler)
48504 goto out;
48505
48506 +#ifdef CONFIG_GRKERNSEC
48507 + error = -EPERM;
48508 + if (write && !capable(CAP_SYS_ADMIN))
48509 + goto out;
48510 +#endif
48511 +
48512 /* careful: calling conventions are nasty here */
48513 res = count;
48514 error = table->proc_handler(table, write, buf, &res, ppos);
48515 @@ -260,6 +274,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
48516 return -ENOMEM;
48517 } else {
48518 d_set_d_op(child, &proc_sys_dentry_operations);
48519 +
48520 + gr_handle_proc_create(child, inode);
48521 +
48522 d_add(child, inode);
48523 }
48524 } else {
48525 @@ -288,6 +305,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
48526 if (*pos < file->f_pos)
48527 continue;
48528
48529 + if (gr_handle_sysctl(table, 0))
48530 + continue;
48531 +
48532 res = proc_sys_fill_cache(file, dirent, filldir, head, table);
48533 if (res)
48534 return res;
48535 @@ -413,6 +433,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
48536 if (IS_ERR(head))
48537 return PTR_ERR(head);
48538
48539 + if (table && gr_handle_sysctl(table, MAY_EXEC))
48540 + return -ENOENT;
48541 +
48542 generic_fillattr(inode, stat);
48543 if (table)
48544 stat->mode = (stat->mode & S_IFMT) | table->mode;
48545 @@ -435,13 +458,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
48546 .llseek = generic_file_llseek,
48547 };
48548
48549 -static const struct inode_operations proc_sys_inode_operations = {
48550 +const struct inode_operations proc_sys_inode_operations = {
48551 .permission = proc_sys_permission,
48552 .setattr = proc_sys_setattr,
48553 .getattr = proc_sys_getattr,
48554 };
48555
48556 -static const struct inode_operations proc_sys_dir_operations = {
48557 +const struct inode_operations proc_sys_dir_operations = {
48558 .lookup = proc_sys_lookup,
48559 .permission = proc_sys_permission,
48560 .setattr = proc_sys_setattr,
48561 diff --git a/fs/proc/root.c b/fs/proc/root.c
48562 index 46a15d8..335631a 100644
48563 --- a/fs/proc/root.c
48564 +++ b/fs/proc/root.c
48565 @@ -187,7 +187,15 @@ void __init proc_root_init(void)
48566 #ifdef CONFIG_PROC_DEVICETREE
48567 proc_device_tree_init();
48568 #endif
48569 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
48570 +#ifdef CONFIG_GRKERNSEC_PROC_USER
48571 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
48572 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
48573 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
48574 +#endif
48575 +#else
48576 proc_mkdir("bus", NULL);
48577 +#endif
48578 proc_sys_init();
48579 }
48580
48581 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
48582 index 3efa725..23c925b 100644
48583 --- a/fs/proc/task_mmu.c
48584 +++ b/fs/proc/task_mmu.c
48585 @@ -11,6 +11,7 @@
48586 #include <linux/rmap.h>
48587 #include <linux/swap.h>
48588 #include <linux/swapops.h>
48589 +#include <linux/grsecurity.h>
48590
48591 #include <asm/elf.h>
48592 #include <asm/uaccess.h>
48593 @@ -52,8 +53,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
48594 "VmExe:\t%8lu kB\n"
48595 "VmLib:\t%8lu kB\n"
48596 "VmPTE:\t%8lu kB\n"
48597 - "VmSwap:\t%8lu kB\n",
48598 - hiwater_vm << (PAGE_SHIFT-10),
48599 + "VmSwap:\t%8lu kB\n"
48600 +
48601 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
48602 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
48603 +#endif
48604 +
48605 + ,hiwater_vm << (PAGE_SHIFT-10),
48606 (total_vm - mm->reserved_vm) << (PAGE_SHIFT-10),
48607 mm->locked_vm << (PAGE_SHIFT-10),
48608 mm->pinned_vm << (PAGE_SHIFT-10),
48609 @@ -62,7 +68,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
48610 data << (PAGE_SHIFT-10),
48611 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
48612 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
48613 - swap << (PAGE_SHIFT-10));
48614 + swap << (PAGE_SHIFT-10)
48615 +
48616 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
48617 + , mm->context.user_cs_base, mm->context.user_cs_limit
48618 +#endif
48619 +
48620 + );
48621 }
48622
48623 unsigned long task_vsize(struct mm_struct *mm)
48624 @@ -209,6 +221,12 @@ static int do_maps_open(struct inode *inode, struct file *file,
48625 return ret;
48626 }
48627
48628 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
48629 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
48630 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
48631 + _mm->pax_flags & MF_PAX_SEGMEXEC))
48632 +#endif
48633 +
48634 static void show_map_vma(struct seq_file *m, struct vm_area_struct *vma)
48635 {
48636 struct mm_struct *mm = vma->vm_mm;
48637 @@ -227,13 +245,13 @@ static void show_map_vma(struct seq_file *m, struct vm_area_struct *vma)
48638 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
48639 }
48640
48641 - /* We don't show the stack guard page in /proc/maps */
48642 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
48643 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
48644 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
48645 +#else
48646 start = vma->vm_start;
48647 - if (stack_guard_page_start(vma, start))
48648 - start += PAGE_SIZE;
48649 end = vma->vm_end;
48650 - if (stack_guard_page_end(vma, end))
48651 - end -= PAGE_SIZE;
48652 +#endif
48653
48654 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
48655 start,
48656 @@ -242,7 +260,11 @@ static void show_map_vma(struct seq_file *m, struct vm_area_struct *vma)
48657 flags & VM_WRITE ? 'w' : '-',
48658 flags & VM_EXEC ? 'x' : '-',
48659 flags & VM_MAYSHARE ? 's' : 'p',
48660 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
48661 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
48662 +#else
48663 pgoff,
48664 +#endif
48665 MAJOR(dev), MINOR(dev), ino, &len);
48666
48667 /*
48668 @@ -251,7 +273,7 @@ static void show_map_vma(struct seq_file *m, struct vm_area_struct *vma)
48669 */
48670 if (file) {
48671 pad_len_spaces(m, len);
48672 - seq_path(m, &file->f_path, "\n");
48673 + seq_path(m, &file->f_path, "\n\\");
48674 } else {
48675 const char *name = arch_vma_name(vma);
48676 if (!name) {
48677 @@ -259,8 +281,9 @@ static void show_map_vma(struct seq_file *m, struct vm_area_struct *vma)
48678 if (vma->vm_start <= mm->brk &&
48679 vma->vm_end >= mm->start_brk) {
48680 name = "[heap]";
48681 - } else if (vma->vm_start <= mm->start_stack &&
48682 - vma->vm_end >= mm->start_stack) {
48683 + } else if ((vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
48684 + (vma->vm_start <= mm->start_stack &&
48685 + vma->vm_end >= mm->start_stack)) {
48686 name = "[stack]";
48687 }
48688 } else {
48689 @@ -281,6 +304,13 @@ static int show_map(struct seq_file *m, void *v)
48690 struct proc_maps_private *priv = m->private;
48691 struct task_struct *task = priv->task;
48692
48693 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
48694 + if (current->exec_id != m->exec_id) {
48695 + gr_log_badprocpid("maps");
48696 + return 0;
48697 + }
48698 +#endif
48699 +
48700 show_map_vma(m, vma);
48701
48702 if (m->count < m->size) /* vma is copied successfully */
48703 @@ -437,12 +467,23 @@ static int show_smap(struct seq_file *m, void *v)
48704 .private = &mss,
48705 };
48706
48707 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
48708 + if (current->exec_id != m->exec_id) {
48709 + gr_log_badprocpid("smaps");
48710 + return 0;
48711 + }
48712 +#endif
48713 memset(&mss, 0, sizeof mss);
48714 - mss.vma = vma;
48715 - /* mmap_sem is held in m_start */
48716 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
48717 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
48718 -
48719 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
48720 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
48721 +#endif
48722 + mss.vma = vma;
48723 + /* mmap_sem is held in m_start */
48724 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
48725 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
48726 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
48727 + }
48728 +#endif
48729 show_map_vma(m, vma);
48730
48731 seq_printf(m,
48732 @@ -460,7 +501,11 @@ static int show_smap(struct seq_file *m, void *v)
48733 "KernelPageSize: %8lu kB\n"
48734 "MMUPageSize: %8lu kB\n"
48735 "Locked: %8lu kB\n",
48736 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
48737 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
48738 +#else
48739 (vma->vm_end - vma->vm_start) >> 10,
48740 +#endif
48741 mss.resident >> 10,
48742 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
48743 mss.shared_clean >> 10,
48744 @@ -1024,6 +1069,13 @@ static int show_numa_map(struct seq_file *m, void *v)
48745 int n;
48746 char buffer[50];
48747
48748 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
48749 + if (current->exec_id != m->exec_id) {
48750 + gr_log_badprocpid("numa_maps");
48751 + return 0;
48752 + }
48753 +#endif
48754 +
48755 if (!mm)
48756 return 0;
48757
48758 @@ -1041,11 +1093,15 @@ static int show_numa_map(struct seq_file *m, void *v)
48759 mpol_to_str(buffer, sizeof(buffer), pol, 0);
48760 mpol_cond_put(pol);
48761
48762 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
48763 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
48764 +#else
48765 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
48766 +#endif
48767
48768 if (file) {
48769 seq_printf(m, " file=");
48770 - seq_path(m, &file->f_path, "\n\t= ");
48771 + seq_path(m, &file->f_path, "\n\t\\= ");
48772 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
48773 seq_printf(m, " heap");
48774 } else if (vma->vm_start <= mm->start_stack &&
48775 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
48776 index 980de54..2a4db5f 100644
48777 --- a/fs/proc/task_nommu.c
48778 +++ b/fs/proc/task_nommu.c
48779 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
48780 else
48781 bytes += kobjsize(mm);
48782
48783 - if (current->fs && current->fs->users > 1)
48784 + if (current->fs && atomic_read(&current->fs->users) > 1)
48785 sbytes += kobjsize(current->fs);
48786 else
48787 bytes += kobjsize(current->fs);
48788 @@ -166,7 +166,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma)
48789
48790 if (file) {
48791 pad_len_spaces(m, len);
48792 - seq_path(m, &file->f_path, "");
48793 + seq_path(m, &file->f_path, "\n\\");
48794 } else if (mm) {
48795 if (vma->vm_start <= mm->start_stack &&
48796 vma->vm_end >= mm->start_stack) {
48797 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
48798 index d67908b..d13f6a6 100644
48799 --- a/fs/quota/netlink.c
48800 +++ b/fs/quota/netlink.c
48801 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
48802 void quota_send_warning(short type, unsigned int id, dev_t dev,
48803 const char warntype)
48804 {
48805 - static atomic_t seq;
48806 + static atomic_unchecked_t seq;
48807 struct sk_buff *skb;
48808 void *msg_head;
48809 int ret;
48810 @@ -49,7 +49,7 @@ void quota_send_warning(short type, unsigned int id, dev_t dev,
48811 "VFS: Not enough memory to send quota warning.\n");
48812 return;
48813 }
48814 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
48815 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
48816 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
48817 if (!msg_head) {
48818 printk(KERN_ERR
48819 diff --git a/fs/readdir.c b/fs/readdir.c
48820 index 356f715..c918d38 100644
48821 --- a/fs/readdir.c
48822 +++ b/fs/readdir.c
48823 @@ -17,6 +17,7 @@
48824 #include <linux/security.h>
48825 #include <linux/syscalls.h>
48826 #include <linux/unistd.h>
48827 +#include <linux/namei.h>
48828
48829 #include <asm/uaccess.h>
48830
48831 @@ -67,6 +68,7 @@ struct old_linux_dirent {
48832
48833 struct readdir_callback {
48834 struct old_linux_dirent __user * dirent;
48835 + struct file * file;
48836 int result;
48837 };
48838
48839 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
48840 buf->result = -EOVERFLOW;
48841 return -EOVERFLOW;
48842 }
48843 +
48844 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
48845 + return 0;
48846 +
48847 buf->result++;
48848 dirent = buf->dirent;
48849 if (!access_ok(VERIFY_WRITE, dirent,
48850 @@ -116,6 +122,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
48851
48852 buf.result = 0;
48853 buf.dirent = dirent;
48854 + buf.file = file;
48855
48856 error = vfs_readdir(file, fillonedir, &buf);
48857 if (buf.result)
48858 @@ -142,6 +149,7 @@ struct linux_dirent {
48859 struct getdents_callback {
48860 struct linux_dirent __user * current_dir;
48861 struct linux_dirent __user * previous;
48862 + struct file * file;
48863 int count;
48864 int error;
48865 };
48866 @@ -163,6 +171,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
48867 buf->error = -EOVERFLOW;
48868 return -EOVERFLOW;
48869 }
48870 +
48871 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
48872 + return 0;
48873 +
48874 dirent = buf->previous;
48875 if (dirent) {
48876 if (__put_user(offset, &dirent->d_off))
48877 @@ -210,6 +222,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
48878 buf.previous = NULL;
48879 buf.count = count;
48880 buf.error = 0;
48881 + buf.file = file;
48882
48883 error = vfs_readdir(file, filldir, &buf);
48884 if (error >= 0)
48885 @@ -229,6 +242,7 @@ out:
48886 struct getdents_callback64 {
48887 struct linux_dirent64 __user * current_dir;
48888 struct linux_dirent64 __user * previous;
48889 + struct file *file;
48890 int count;
48891 int error;
48892 };
48893 @@ -244,6 +258,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
48894 buf->error = -EINVAL; /* only used if we fail.. */
48895 if (reclen > buf->count)
48896 return -EINVAL;
48897 +
48898 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
48899 + return 0;
48900 +
48901 dirent = buf->previous;
48902 if (dirent) {
48903 if (__put_user(offset, &dirent->d_off))
48904 @@ -291,6 +309,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
48905
48906 buf.current_dir = dirent;
48907 buf.previous = NULL;
48908 + buf.file = file;
48909 buf.count = count;
48910 buf.error = 0;
48911
48912 @@ -299,7 +318,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
48913 error = buf.error;
48914 lastdirent = buf.previous;
48915 if (lastdirent) {
48916 - typeof(lastdirent->d_off) d_off = file->f_pos;
48917 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = file->f_pos;
48918 if (__put_user(d_off, &lastdirent->d_off))
48919 error = -EFAULT;
48920 else
48921 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
48922 index 60c0804..d814f98 100644
48923 --- a/fs/reiserfs/do_balan.c
48924 +++ b/fs/reiserfs/do_balan.c
48925 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
48926 return;
48927 }
48928
48929 - atomic_inc(&(fs_generation(tb->tb_sb)));
48930 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
48931 do_balance_starts(tb);
48932
48933 /* balance leaf returns 0 except if combining L R and S into
48934 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
48935 index 7a99811..a7c96c4 100644
48936 --- a/fs/reiserfs/procfs.c
48937 +++ b/fs/reiserfs/procfs.c
48938 @@ -113,7 +113,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
48939 "SMALL_TAILS " : "NO_TAILS ",
48940 replay_only(sb) ? "REPLAY_ONLY " : "",
48941 convert_reiserfs(sb) ? "CONV " : "",
48942 - atomic_read(&r->s_generation_counter),
48943 + atomic_read_unchecked(&r->s_generation_counter),
48944 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
48945 SF(s_do_balance), SF(s_unneeded_left_neighbor),
48946 SF(s_good_search_by_key_reada), SF(s_bmaps),
48947 diff --git a/fs/select.c b/fs/select.c
48948 index e782258..3b4b44c 100644
48949 --- a/fs/select.c
48950 +++ b/fs/select.c
48951 @@ -20,6 +20,7 @@
48952 #include <linux/module.h>
48953 #include <linux/slab.h>
48954 #include <linux/poll.h>
48955 +#include <linux/security.h>
48956 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
48957 #include <linux/file.h>
48958 #include <linux/fdtable.h>
48959 @@ -837,6 +838,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
48960 struct poll_list *walk = head;
48961 unsigned long todo = nfds;
48962
48963 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
48964 if (nfds > rlimit(RLIMIT_NOFILE))
48965 return -EINVAL;
48966
48967 diff --git a/fs/seq_file.c b/fs/seq_file.c
48968 index 4023d6b..ab46c6a 100644
48969 --- a/fs/seq_file.c
48970 +++ b/fs/seq_file.c
48971 @@ -9,6 +9,7 @@
48972 #include <linux/module.h>
48973 #include <linux/seq_file.h>
48974 #include <linux/slab.h>
48975 +#include <linux/sched.h>
48976
48977 #include <asm/uaccess.h>
48978 #include <asm/page.h>
48979 @@ -40,6 +41,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
48980 memset(p, 0, sizeof(*p));
48981 mutex_init(&p->lock);
48982 p->op = op;
48983 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
48984 + p->exec_id = current->exec_id;
48985 +#endif
48986
48987 /*
48988 * Wrappers around seq_open(e.g. swaps_open) need to be
48989 @@ -549,7 +553,7 @@ static void single_stop(struct seq_file *p, void *v)
48990 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
48991 void *data)
48992 {
48993 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
48994 + seq_operations_no_const *op = kmalloc(sizeof(*op), GFP_KERNEL);
48995 int res = -ENOMEM;
48996
48997 if (op) {
48998 diff --git a/fs/splice.c b/fs/splice.c
48999 index 96d7b28..fd465ac 100644
49000 --- a/fs/splice.c
49001 +++ b/fs/splice.c
49002 @@ -194,7 +194,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
49003 pipe_lock(pipe);
49004
49005 for (;;) {
49006 - if (!pipe->readers) {
49007 + if (!atomic_read(&pipe->readers)) {
49008 send_sig(SIGPIPE, current, 0);
49009 if (!ret)
49010 ret = -EPIPE;
49011 @@ -248,9 +248,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
49012 do_wakeup = 0;
49013 }
49014
49015 - pipe->waiting_writers++;
49016 + atomic_inc(&pipe->waiting_writers);
49017 pipe_wait(pipe);
49018 - pipe->waiting_writers--;
49019 + atomic_dec(&pipe->waiting_writers);
49020 }
49021
49022 pipe_unlock(pipe);
49023 @@ -560,7 +560,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
49024 old_fs = get_fs();
49025 set_fs(get_ds());
49026 /* The cast to a user pointer is valid due to the set_fs() */
49027 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
49028 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
49029 set_fs(old_fs);
49030
49031 return res;
49032 @@ -575,7 +575,7 @@ static ssize_t kernel_write(struct file *file, const char *buf, size_t count,
49033 old_fs = get_fs();
49034 set_fs(get_ds());
49035 /* The cast to a user pointer is valid due to the set_fs() */
49036 - res = vfs_write(file, (const char __user *)buf, count, &pos);
49037 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
49038 set_fs(old_fs);
49039
49040 return res;
49041 @@ -626,7 +626,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
49042 goto err;
49043
49044 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
49045 - vec[i].iov_base = (void __user *) page_address(page);
49046 + vec[i].iov_base = (void __force_user *) page_address(page);
49047 vec[i].iov_len = this_len;
49048 spd.pages[i] = page;
49049 spd.nr_pages++;
49050 @@ -848,10 +848,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
49051 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
49052 {
49053 while (!pipe->nrbufs) {
49054 - if (!pipe->writers)
49055 + if (!atomic_read(&pipe->writers))
49056 return 0;
49057
49058 - if (!pipe->waiting_writers && sd->num_spliced)
49059 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
49060 return 0;
49061
49062 if (sd->flags & SPLICE_F_NONBLOCK)
49063 @@ -1184,7 +1184,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
49064 * out of the pipe right after the splice_to_pipe(). So set
49065 * PIPE_READERS appropriately.
49066 */
49067 - pipe->readers = 1;
49068 + atomic_set(&pipe->readers, 1);
49069
49070 current->splice_pipe = pipe;
49071 }
49072 @@ -1736,9 +1736,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
49073 ret = -ERESTARTSYS;
49074 break;
49075 }
49076 - if (!pipe->writers)
49077 + if (!atomic_read(&pipe->writers))
49078 break;
49079 - if (!pipe->waiting_writers) {
49080 + if (!atomic_read(&pipe->waiting_writers)) {
49081 if (flags & SPLICE_F_NONBLOCK) {
49082 ret = -EAGAIN;
49083 break;
49084 @@ -1770,7 +1770,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
49085 pipe_lock(pipe);
49086
49087 while (pipe->nrbufs >= pipe->buffers) {
49088 - if (!pipe->readers) {
49089 + if (!atomic_read(&pipe->readers)) {
49090 send_sig(SIGPIPE, current, 0);
49091 ret = -EPIPE;
49092 break;
49093 @@ -1783,9 +1783,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
49094 ret = -ERESTARTSYS;
49095 break;
49096 }
49097 - pipe->waiting_writers++;
49098 + atomic_inc(&pipe->waiting_writers);
49099 pipe_wait(pipe);
49100 - pipe->waiting_writers--;
49101 + atomic_dec(&pipe->waiting_writers);
49102 }
49103
49104 pipe_unlock(pipe);
49105 @@ -1821,14 +1821,14 @@ retry:
49106 pipe_double_lock(ipipe, opipe);
49107
49108 do {
49109 - if (!opipe->readers) {
49110 + if (!atomic_read(&opipe->readers)) {
49111 send_sig(SIGPIPE, current, 0);
49112 if (!ret)
49113 ret = -EPIPE;
49114 break;
49115 }
49116
49117 - if (!ipipe->nrbufs && !ipipe->writers)
49118 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
49119 break;
49120
49121 /*
49122 @@ -1925,7 +1925,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
49123 pipe_double_lock(ipipe, opipe);
49124
49125 do {
49126 - if (!opipe->readers) {
49127 + if (!atomic_read(&opipe->readers)) {
49128 send_sig(SIGPIPE, current, 0);
49129 if (!ret)
49130 ret = -EPIPE;
49131 @@ -1970,7 +1970,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
49132 * return EAGAIN if we have the potential of some data in the
49133 * future, otherwise just return 0
49134 */
49135 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
49136 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
49137 ret = -EAGAIN;
49138
49139 pipe_unlock(ipipe);
49140 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
49141 index 7fdf6a7..e6cd8ad 100644
49142 --- a/fs/sysfs/dir.c
49143 +++ b/fs/sysfs/dir.c
49144 @@ -642,6 +642,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
49145 struct sysfs_dirent *sd;
49146 int rc;
49147
49148 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
49149 + const char *parent_name = parent_sd->s_name;
49150 +
49151 + mode = S_IFDIR | S_IRWXU;
49152 +
49153 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
49154 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
49155 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse"))) ||
49156 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
49157 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
49158 +#endif
49159 +
49160 /* allocate */
49161 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
49162 if (!sd)
49163 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
49164 index 00012e3..8392349 100644
49165 --- a/fs/sysfs/file.c
49166 +++ b/fs/sysfs/file.c
49167 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
49168
49169 struct sysfs_open_dirent {
49170 atomic_t refcnt;
49171 - atomic_t event;
49172 + atomic_unchecked_t event;
49173 wait_queue_head_t poll;
49174 struct list_head buffers; /* goes through sysfs_buffer.list */
49175 };
49176 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
49177 if (!sysfs_get_active(attr_sd))
49178 return -ENODEV;
49179
49180 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
49181 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
49182 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
49183
49184 sysfs_put_active(attr_sd);
49185 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
49186 return -ENOMEM;
49187
49188 atomic_set(&new_od->refcnt, 0);
49189 - atomic_set(&new_od->event, 1);
49190 + atomic_set_unchecked(&new_od->event, 1);
49191 init_waitqueue_head(&new_od->poll);
49192 INIT_LIST_HEAD(&new_od->buffers);
49193 goto retry;
49194 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
49195
49196 sysfs_put_active(attr_sd);
49197
49198 - if (buffer->event != atomic_read(&od->event))
49199 + if (buffer->event != atomic_read_unchecked(&od->event))
49200 goto trigger;
49201
49202 return DEFAULT_POLLMASK;
49203 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
49204
49205 od = sd->s_attr.open;
49206 if (od) {
49207 - atomic_inc(&od->event);
49208 + atomic_inc_unchecked(&od->event);
49209 wake_up_interruptible(&od->poll);
49210 }
49211
49212 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
49213 index a7ac78f..02158e1 100644
49214 --- a/fs/sysfs/symlink.c
49215 +++ b/fs/sysfs/symlink.c
49216 @@ -286,7 +286,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
49217
49218 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
49219 {
49220 - char *page = nd_get_link(nd);
49221 + const char *page = nd_get_link(nd);
49222 if (!IS_ERR(page))
49223 free_page((unsigned long)page);
49224 }
49225 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
49226 index c175b4d..8f36a16 100644
49227 --- a/fs/udf/misc.c
49228 +++ b/fs/udf/misc.c
49229 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
49230
49231 u8 udf_tag_checksum(const struct tag *t)
49232 {
49233 - u8 *data = (u8 *)t;
49234 + const u8 *data = (const u8 *)t;
49235 u8 checksum = 0;
49236 int i;
49237 for (i = 0; i < sizeof(struct tag); ++i)
49238 diff --git a/fs/utimes.c b/fs/utimes.c
49239 index ba653f3..06ea4b1 100644
49240 --- a/fs/utimes.c
49241 +++ b/fs/utimes.c
49242 @@ -1,6 +1,7 @@
49243 #include <linux/compiler.h>
49244 #include <linux/file.h>
49245 #include <linux/fs.h>
49246 +#include <linux/security.h>
49247 #include <linux/linkage.h>
49248 #include <linux/mount.h>
49249 #include <linux/namei.h>
49250 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
49251 goto mnt_drop_write_and_out;
49252 }
49253 }
49254 +
49255 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
49256 + error = -EACCES;
49257 + goto mnt_drop_write_and_out;
49258 + }
49259 +
49260 mutex_lock(&inode->i_mutex);
49261 error = notify_change(path->dentry, &newattrs);
49262 mutex_unlock(&inode->i_mutex);
49263 diff --git a/fs/xattr.c b/fs/xattr.c
49264 index 82f4337..236473c 100644
49265 --- a/fs/xattr.c
49266 +++ b/fs/xattr.c
49267 @@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
49268 * Extended attribute SET operations
49269 */
49270 static long
49271 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
49272 +setxattr(struct path *path, const char __user *name, const void __user *value,
49273 size_t size, int flags)
49274 {
49275 int error;
49276 @@ -339,7 +339,13 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
49277 return PTR_ERR(kvalue);
49278 }
49279
49280 - error = vfs_setxattr(d, kname, kvalue, size, flags);
49281 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
49282 + error = -EACCES;
49283 + goto out;
49284 + }
49285 +
49286 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
49287 +out:
49288 kfree(kvalue);
49289 return error;
49290 }
49291 @@ -356,7 +362,7 @@ SYSCALL_DEFINE5(setxattr, const char __user *, pathname,
49292 return error;
49293 error = mnt_want_write(path.mnt);
49294 if (!error) {
49295 - error = setxattr(path.dentry, name, value, size, flags);
49296 + error = setxattr(&path, name, value, size, flags);
49297 mnt_drop_write(path.mnt);
49298 }
49299 path_put(&path);
49300 @@ -375,7 +381,7 @@ SYSCALL_DEFINE5(lsetxattr, const char __user *, pathname,
49301 return error;
49302 error = mnt_want_write(path.mnt);
49303 if (!error) {
49304 - error = setxattr(path.dentry, name, value, size, flags);
49305 + error = setxattr(&path, name, value, size, flags);
49306 mnt_drop_write(path.mnt);
49307 }
49308 path_put(&path);
49309 @@ -386,17 +392,15 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
49310 const void __user *,value, size_t, size, int, flags)
49311 {
49312 struct file *f;
49313 - struct dentry *dentry;
49314 int error = -EBADF;
49315
49316 f = fget(fd);
49317 if (!f)
49318 return error;
49319 - dentry = f->f_path.dentry;
49320 - audit_inode(NULL, dentry);
49321 + audit_inode(NULL, f->f_path.dentry);
49322 error = mnt_want_write_file(f);
49323 if (!error) {
49324 - error = setxattr(dentry, name, value, size, flags);
49325 + error = setxattr(&f->f_path, name, value, size, flags);
49326 mnt_drop_write_file(f);
49327 }
49328 fput(f);
49329 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
49330 index 8d5a506..7f62712 100644
49331 --- a/fs/xattr_acl.c
49332 +++ b/fs/xattr_acl.c
49333 @@ -17,8 +17,8 @@
49334 struct posix_acl *
49335 posix_acl_from_xattr(const void *value, size_t size)
49336 {
49337 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
49338 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
49339 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
49340 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
49341 int count;
49342 struct posix_acl *acl;
49343 struct posix_acl_entry *acl_e;
49344 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
49345 index 188ef2f..adcf864 100644
49346 --- a/fs/xfs/xfs_bmap.c
49347 +++ b/fs/xfs/xfs_bmap.c
49348 @@ -190,7 +190,7 @@ xfs_bmap_validate_ret(
49349 int nmap,
49350 int ret_nmap);
49351 #else
49352 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
49353 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do {} while (0)
49354 #endif /* DEBUG */
49355
49356 STATIC int
49357 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
49358 index 79d05e8..e3e5861 100644
49359 --- a/fs/xfs/xfs_dir2_sf.c
49360 +++ b/fs/xfs/xfs_dir2_sf.c
49361 @@ -852,7 +852,15 @@ xfs_dir2_sf_getdents(
49362 }
49363
49364 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
49365 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
49366 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
49367 + char name[sfep->namelen];
49368 + memcpy(name, sfep->name, sfep->namelen);
49369 + if (filldir(dirent, name, sfep->namelen,
49370 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
49371 + *offset = off & 0x7fffffff;
49372 + return 0;
49373 + }
49374 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
49375 off & 0x7fffffff, ino, DT_UNKNOWN)) {
49376 *offset = off & 0x7fffffff;
49377 return 0;
49378 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
49379 index 76f3ca5..f57f712 100644
49380 --- a/fs/xfs/xfs_ioctl.c
49381 +++ b/fs/xfs/xfs_ioctl.c
49382 @@ -128,7 +128,7 @@ xfs_find_handle(
49383 }
49384
49385 error = -EFAULT;
49386 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
49387 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
49388 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
49389 goto out_put;
49390
49391 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
49392 index ab30253..4d86958 100644
49393 --- a/fs/xfs/xfs_iops.c
49394 +++ b/fs/xfs/xfs_iops.c
49395 @@ -447,7 +447,7 @@ xfs_vn_put_link(
49396 struct nameidata *nd,
49397 void *p)
49398 {
49399 - char *s = nd_get_link(nd);
49400 + const char *s = nd_get_link(nd);
49401
49402 if (!IS_ERR(s))
49403 kfree(s);
49404 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
49405 new file mode 100644
49406 index 0000000..2645296
49407 --- /dev/null
49408 +++ b/grsecurity/Kconfig
49409 @@ -0,0 +1,1079 @@
49410 +#
49411 +# grecurity configuration
49412 +#
49413 +
49414 +menu "Grsecurity"
49415 +
49416 +config GRKERNSEC
49417 + bool "Grsecurity"
49418 + select CRYPTO
49419 + select CRYPTO_SHA256
49420 + help
49421 + If you say Y here, you will be able to configure many features
49422 + that will enhance the security of your system. It is highly
49423 + recommended that you say Y here and read through the help
49424 + for each option so that you fully understand the features and
49425 + can evaluate their usefulness for your machine.
49426 +
49427 +choice
49428 + prompt "Security Level"
49429 + depends on GRKERNSEC
49430 + default GRKERNSEC_CUSTOM
49431 +
49432 +config GRKERNSEC_LOW
49433 + bool "Low"
49434 + select GRKERNSEC_LINK
49435 + select GRKERNSEC_FIFO
49436 + select GRKERNSEC_RANDNET
49437 + select GRKERNSEC_DMESG
49438 + select GRKERNSEC_CHROOT
49439 + select GRKERNSEC_CHROOT_CHDIR
49440 +
49441 + help
49442 + If you choose this option, several of the grsecurity options will
49443 + be enabled that will give you greater protection against a number
49444 + of attacks, while assuring that none of your software will have any
49445 + conflicts with the additional security measures. If you run a lot
49446 + of unusual software, or you are having problems with the higher
49447 + security levels, you should say Y here. With this option, the
49448 + following features are enabled:
49449 +
49450 + - Linking restrictions
49451 + - FIFO restrictions
49452 + - Restricted dmesg
49453 + - Enforced chdir("/") on chroot
49454 + - Runtime module disabling
49455 +
49456 +config GRKERNSEC_MEDIUM
49457 + bool "Medium"
49458 + select PAX
49459 + select PAX_EI_PAX
49460 + select PAX_PT_PAX_FLAGS
49461 + select PAX_HAVE_ACL_FLAGS
49462 + select GRKERNSEC_PROC_MEMMAP if (PAX_NOEXEC || PAX_ASLR)
49463 + select GRKERNSEC_CHROOT
49464 + select GRKERNSEC_CHROOT_SYSCTL
49465 + select GRKERNSEC_LINK
49466 + select GRKERNSEC_FIFO
49467 + select GRKERNSEC_DMESG
49468 + select GRKERNSEC_RANDNET
49469 + select GRKERNSEC_FORKFAIL
49470 + select GRKERNSEC_TIME
49471 + select GRKERNSEC_SIGNAL
49472 + select GRKERNSEC_CHROOT
49473 + select GRKERNSEC_CHROOT_UNIX
49474 + select GRKERNSEC_CHROOT_MOUNT
49475 + select GRKERNSEC_CHROOT_PIVOT
49476 + select GRKERNSEC_CHROOT_DOUBLE
49477 + select GRKERNSEC_CHROOT_CHDIR
49478 + select GRKERNSEC_CHROOT_MKNOD
49479 + select GRKERNSEC_PROC
49480 + select GRKERNSEC_PROC_USERGROUP
49481 + select PAX_RANDUSTACK
49482 + select PAX_ASLR
49483 + select PAX_RANDMMAP
49484 + select PAX_REFCOUNT if (X86 || SPARC64)
49485 + select PAX_USERCOPY if ((X86 || SPARC || PPC || ARM) && (SLAB || SLUB || SLOB))
49486 +
49487 + help
49488 + If you say Y here, several features in addition to those included
49489 + in the low additional security level will be enabled. These
49490 + features provide even more security to your system, though in rare
49491 + cases they may be incompatible with very old or poorly written
49492 + software. If you enable this option, make sure that your auth
49493 + service (identd) is running as gid 1001. With this option,
49494 + the following features (in addition to those provided in the
49495 + low additional security level) will be enabled:
49496 +
49497 + - Failed fork logging
49498 + - Time change logging
49499 + - Signal logging
49500 + - Deny mounts in chroot
49501 + - Deny double chrooting
49502 + - Deny sysctl writes in chroot
49503 + - Deny mknod in chroot
49504 + - Deny access to abstract AF_UNIX sockets out of chroot
49505 + - Deny pivot_root in chroot
49506 + - Denied reads/writes of /dev/kmem, /dev/mem, and /dev/port
49507 + - /proc restrictions with special GID set to 10 (usually wheel)
49508 + - Address Space Layout Randomization (ASLR)
49509 + - Prevent exploitation of most refcount overflows
49510 + - Bounds checking of copying between the kernel and userland
49511 +
49512 +config GRKERNSEC_HIGH
49513 + bool "High"
49514 + select GRKERNSEC_LINK
49515 + select GRKERNSEC_FIFO
49516 + select GRKERNSEC_DMESG
49517 + select GRKERNSEC_FORKFAIL
49518 + select GRKERNSEC_TIME
49519 + select GRKERNSEC_SIGNAL
49520 + select GRKERNSEC_CHROOT
49521 + select GRKERNSEC_CHROOT_SHMAT
49522 + select GRKERNSEC_CHROOT_UNIX
49523 + select GRKERNSEC_CHROOT_MOUNT
49524 + select GRKERNSEC_CHROOT_FCHDIR
49525 + select GRKERNSEC_CHROOT_PIVOT
49526 + select GRKERNSEC_CHROOT_DOUBLE
49527 + select GRKERNSEC_CHROOT_CHDIR
49528 + select GRKERNSEC_CHROOT_MKNOD
49529 + select GRKERNSEC_CHROOT_CAPS
49530 + select GRKERNSEC_CHROOT_SYSCTL
49531 + select GRKERNSEC_CHROOT_FINDTASK
49532 + select GRKERNSEC_SYSFS_RESTRICT
49533 + select GRKERNSEC_PROC
49534 + select GRKERNSEC_PROC_MEMMAP if (PAX_NOEXEC || PAX_ASLR)
49535 + select GRKERNSEC_HIDESYM
49536 + select GRKERNSEC_BRUTE
49537 + select GRKERNSEC_PROC_USERGROUP
49538 + select GRKERNSEC_KMEM
49539 + select GRKERNSEC_RESLOG
49540 + select GRKERNSEC_RANDNET
49541 + select GRKERNSEC_PROC_ADD
49542 + select GRKERNSEC_CHROOT_CHMOD
49543 + select GRKERNSEC_CHROOT_NICE
49544 + select GRKERNSEC_SETXID if (X86 || SPARC64 || PPC || ARM || MIPS)
49545 + select GRKERNSEC_AUDIT_MOUNT
49546 + select GRKERNSEC_MODHARDEN if (MODULES)
49547 + select GRKERNSEC_HARDEN_PTRACE
49548 + select GRKERNSEC_PTRACE_READEXEC
49549 + select GRKERNSEC_VM86 if (X86_32)
49550 + select GRKERNSEC_KERN_LOCKOUT if (X86 || ARM || PPC || SPARC)
49551 + select PAX
49552 + select PAX_RANDUSTACK
49553 + select PAX_ASLR
49554 + select PAX_RANDMMAP
49555 + select PAX_NOEXEC
49556 + select PAX_MPROTECT
49557 + select PAX_EI_PAX
49558 + select PAX_PT_PAX_FLAGS
49559 + select PAX_HAVE_ACL_FLAGS
49560 + select PAX_KERNEXEC if ((PPC || X86) && (!X86_32 || X86_WP_WORKS_OK) && !XEN)
49561 + select PAX_MEMORY_UDEREF if (X86 && !XEN)
49562 + select PAX_RANDKSTACK if (X86_TSC && X86)
49563 + select PAX_SEGMEXEC if (X86_32)
49564 + select PAX_PAGEEXEC
49565 + select PAX_EMUPLT if (ALPHA || PARISC || SPARC)
49566 + select PAX_EMUTRAMP if (PARISC)
49567 + select PAX_EMUSIGRT if (PARISC)
49568 + select PAX_ETEXECRELOCS if (ALPHA || IA64 || PARISC)
49569 + select PAX_ELFRELOCS if (PAX_ETEXECRELOCS || (IA64 || PPC || X86))
49570 + select PAX_REFCOUNT if (X86 || SPARC64)
49571 + select PAX_USERCOPY if ((X86 || PPC || SPARC || ARM) && (SLAB || SLUB || SLOB))
49572 + help
49573 + If you say Y here, many of the features of grsecurity will be
49574 + enabled, which will protect you against many kinds of attacks
49575 + against your system. The heightened security comes at a cost
49576 + of an increased chance of incompatibilities with rare software
49577 + on your machine. Since this security level enables PaX, you should
49578 + view <http://pax.grsecurity.net> and read about the PaX
49579 + project. While you are there, download chpax and run it on
49580 + binaries that cause problems with PaX. Also remember that
49581 + since the /proc restrictions are enabled, you must run your
49582 + identd as gid 1001. This security level enables the following
49583 + features in addition to those listed in the low and medium
49584 + security levels:
49585 +
49586 + - Additional /proc restrictions
49587 + - Chmod restrictions in chroot
49588 + - No signals, ptrace, or viewing of processes outside of chroot
49589 + - Capability restrictions in chroot
49590 + - Deny fchdir out of chroot
49591 + - Priority restrictions in chroot
49592 + - Segmentation-based implementation of PaX
49593 + - Mprotect restrictions
49594 + - Removal of addresses from /proc/<pid>/[smaps|maps|stat]
49595 + - Kernel stack randomization
49596 + - Mount/unmount/remount logging
49597 + - Kernel symbol hiding
49598 + - Hardening of module auto-loading
49599 + - Ptrace restrictions
49600 + - Restricted vm86 mode
49601 + - Restricted sysfs/debugfs
49602 + - Active kernel exploit response
49603 +
49604 +config GRKERNSEC_CUSTOM
49605 + bool "Custom"
49606 + help
49607 + If you say Y here, you will be able to configure every grsecurity
49608 + option, which allows you to enable many more features that aren't
49609 + covered in the basic security levels. These additional features
49610 + include TPE, socket restrictions, and the sysctl system for
49611 + grsecurity. It is advised that you read through the help for
49612 + each option to determine its usefulness in your situation.
49613 +
49614 +endchoice
49615 +
49616 +menu "Memory Protections"
49617 +depends on GRKERNSEC
49618 +
49619 +config GRKERNSEC_KMEM
49620 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
49621 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
49622 + help
49623 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
49624 + be written to or read from to modify or leak the contents of the running
49625 + kernel. /dev/port will also not be allowed to be opened. If you have module
49626 + support disabled, enabling this will close up four ways that are
49627 + currently used to insert malicious code into the running kernel.
49628 + Even with all these features enabled, we still highly recommend that
49629 + you use the RBAC system, as it is still possible for an attacker to
49630 + modify the running kernel through privileged I/O granted by ioperm/iopl.
49631 + If you are not using XFree86, you may be able to stop this additional
49632 + case by enabling the 'Disable privileged I/O' option. Though nothing
49633 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
49634 + but only to video memory, which is the only writing we allow in this
49635 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
49636 + not be allowed to mprotect it with PROT_WRITE later.
49637 + It is highly recommended that you say Y here if you meet all the
49638 + conditions above.
49639 +
49640 +config GRKERNSEC_VM86
49641 + bool "Restrict VM86 mode"
49642 + depends on X86_32
49643 +
49644 + help
49645 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
49646 + make use of a special execution mode on 32bit x86 processors called
49647 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
49648 + video cards and will still work with this option enabled. The purpose
49649 + of the option is to prevent exploitation of emulation errors in
49650 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
49651 + Nearly all users should be able to enable this option.
49652 +
49653 +config GRKERNSEC_IO
49654 + bool "Disable privileged I/O"
49655 + depends on X86
49656 + select RTC_CLASS
49657 + select RTC_INTF_DEV
49658 + select RTC_DRV_CMOS
49659 +
49660 + help
49661 + If you say Y here, all ioperm and iopl calls will return an error.
49662 + Ioperm and iopl can be used to modify the running kernel.
49663 + Unfortunately, some programs need this access to operate properly,
49664 + the most notable of which are XFree86 and hwclock. hwclock can be
49665 + remedied by having RTC support in the kernel, so real-time
49666 + clock support is enabled if this option is enabled, to ensure
49667 + that hwclock operates correctly. XFree86 still will not
49668 + operate correctly with this option enabled, so DO NOT CHOOSE Y
49669 + IF YOU USE XFree86. If you use XFree86 and you still want to
49670 + protect your kernel against modification, use the RBAC system.
49671 +
49672 +config GRKERNSEC_PROC_MEMMAP
49673 + bool "Harden ASLR against information leaks and entropy reduction"
49674 + default y if (PAX_NOEXEC || PAX_ASLR)
49675 + depends on PAX_NOEXEC || PAX_ASLR
49676 + help
49677 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
49678 + give no information about the addresses of its mappings if
49679 + PaX features that rely on random addresses are enabled on the task.
49680 + In addition to sanitizing this information and disabling other
49681 + dangerous sources of information, this option causes reads of sensitive
49682 + /proc/<pid> entries where the file descriptor was opened in a different
49683 + task than the one performing the read. Such attempts are logged.
49684 + This option also limits argv/env strings for suid/sgid binaries
49685 + to 512KB to prevent a complete exhaustion of the stack entropy provided
49686 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
49687 + binaries to prevent alternative mmap layouts from being abused.
49688 +
49689 + If you use PaX it is essential that you say Y here as it closes up
49690 + several holes that make full ASLR useless locally.
49691 +
49692 +config GRKERNSEC_BRUTE
49693 + bool "Deter exploit bruteforcing"
49694 + help
49695 + If you say Y here, attempts to bruteforce exploits against forking
49696 + daemons such as apache or sshd, as well as against suid/sgid binaries
49697 + will be deterred. When a child of a forking daemon is killed by PaX
49698 + or crashes due to an illegal instruction or other suspicious signal,
49699 + the parent process will be delayed 30 seconds upon every subsequent
49700 + fork until the administrator is able to assess the situation and
49701 + restart the daemon.
49702 + In the suid/sgid case, the attempt is logged, the user has all their
49703 + processes terminated, and they are prevented from executing any further
49704 + processes for 15 minutes.
49705 + It is recommended that you also enable signal logging in the auditing
49706 + section so that logs are generated when a process triggers a suspicious
49707 + signal.
49708 + If the sysctl option is enabled, a sysctl option with name
49709 + "deter_bruteforce" is created.
49710 +
49711 +
49712 +config GRKERNSEC_MODHARDEN
49713 + bool "Harden module auto-loading"
49714 + depends on MODULES
49715 + help
49716 + If you say Y here, module auto-loading in response to use of some
49717 + feature implemented by an unloaded module will be restricted to
49718 + root users. Enabling this option helps defend against attacks
49719 + by unprivileged users who abuse the auto-loading behavior to
49720 + cause a vulnerable module to load that is then exploited.
49721 +
49722 + If this option prevents a legitimate use of auto-loading for a
49723 + non-root user, the administrator can execute modprobe manually
49724 + with the exact name of the module mentioned in the alert log.
49725 + Alternatively, the administrator can add the module to the list
49726 + of modules loaded at boot by modifying init scripts.
49727 +
49728 + Modification of init scripts will most likely be needed on
49729 + Ubuntu servers with encrypted home directory support enabled,
49730 + as the first non-root user logging in will cause the ecb(aes),
49731 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
49732 +
49733 +config GRKERNSEC_HIDESYM
49734 + bool "Hide kernel symbols"
49735 + help
49736 + If you say Y here, getting information on loaded modules, and
49737 + displaying all kernel symbols through a syscall will be restricted
49738 + to users with CAP_SYS_MODULE. For software compatibility reasons,
49739 + /proc/kallsyms will be restricted to the root user. The RBAC
49740 + system can hide that entry even from root.
49741 +
49742 + This option also prevents leaking of kernel addresses through
49743 + several /proc entries.
49744 +
49745 + Note that this option is only effective provided the following
49746 + conditions are met:
49747 + 1) The kernel using grsecurity is not precompiled by some distribution
49748 + 2) You have also enabled GRKERNSEC_DMESG
49749 + 3) You are using the RBAC system and hiding other files such as your
49750 + kernel image and System.map. Alternatively, enabling this option
49751 + causes the permissions on /boot, /lib/modules, and the kernel
49752 + source directory to change at compile time to prevent
49753 + reading by non-root users.
49754 + If the above conditions are met, this option will aid in providing a
49755 + useful protection against local kernel exploitation of overflows
49756 + and arbitrary read/write vulnerabilities.
49757 +
49758 +config GRKERNSEC_KERN_LOCKOUT
49759 + bool "Active kernel exploit response"
49760 + depends on X86 || ARM || PPC || SPARC
49761 + help
49762 + If you say Y here, when a PaX alert is triggered due to suspicious
49763 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
49764 + or an OOPs occurs due to bad memory accesses, instead of just
49765 + terminating the offending process (and potentially allowing
49766 + a subsequent exploit from the same user), we will take one of two
49767 + actions:
49768 + If the user was root, we will panic the system
49769 + If the user was non-root, we will log the attempt, terminate
49770 + all processes owned by the user, then prevent them from creating
49771 + any new processes until the system is restarted
49772 + This deters repeated kernel exploitation/bruteforcing attempts
49773 + and is useful for later forensics.
49774 +
49775 +endmenu
49776 +menu "Role Based Access Control Options"
49777 +depends on GRKERNSEC
49778 +
49779 +config GRKERNSEC_RBAC_DEBUG
49780 + bool
49781 +
49782 +config GRKERNSEC_NO_RBAC
49783 + bool "Disable RBAC system"
49784 + help
49785 + If you say Y here, the /dev/grsec device will be removed from the kernel,
49786 + preventing the RBAC system from being enabled. You should only say Y
49787 + here if you have no intention of using the RBAC system, so as to prevent
49788 + an attacker with root access from misusing the RBAC system to hide files
49789 + and processes when loadable module support and /dev/[k]mem have been
49790 + locked down.
49791 +
49792 +config GRKERNSEC_ACL_HIDEKERN
49793 + bool "Hide kernel processes"
49794 + help
49795 + If you say Y here, all kernel threads will be hidden to all
49796 + processes but those whose subject has the "view hidden processes"
49797 + flag.
49798 +
49799 +config GRKERNSEC_ACL_MAXTRIES
49800 + int "Maximum tries before password lockout"
49801 + default 3
49802 + help
49803 + This option enforces the maximum number of times a user can attempt
49804 + to authorize themselves with the grsecurity RBAC system before being
49805 + denied the ability to attempt authorization again for a specified time.
49806 + The lower the number, the harder it will be to brute-force a password.
49807 +
49808 +config GRKERNSEC_ACL_TIMEOUT
49809 + int "Time to wait after max password tries, in seconds"
49810 + default 30
49811 + help
49812 + This option specifies the time the user must wait after attempting to
49813 + authorize to the RBAC system with the maximum number of invalid
49814 + passwords. The higher the number, the harder it will be to brute-force
49815 + a password.
49816 +
49817 +endmenu
49818 +menu "Filesystem Protections"
49819 +depends on GRKERNSEC
49820 +
49821 +config GRKERNSEC_PROC
49822 + bool "Proc restrictions"
49823 + help
49824 + If you say Y here, the permissions of the /proc filesystem
49825 + will be altered to enhance system security and privacy. You MUST
49826 + choose either a user only restriction or a user and group restriction.
49827 + Depending upon the option you choose, you can either restrict users to
49828 + see only the processes they themselves run, or choose a group that can
49829 + view all processes and files normally restricted to root if you choose
49830 + the "restrict to user only" option. NOTE: If you're running identd or
49831 + ntpd as a non-root user, you will have to run it as the group you
49832 + specify here.
49833 +
49834 +config GRKERNSEC_PROC_USER
49835 + bool "Restrict /proc to user only"
49836 + depends on GRKERNSEC_PROC
49837 + help
49838 + If you say Y here, non-root users will only be able to view their own
49839 + processes, and restricts them from viewing network-related information,
49840 + and viewing kernel symbol and module information.
49841 +
49842 +config GRKERNSEC_PROC_USERGROUP
49843 + bool "Allow special group"
49844 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
49845 + help
49846 + If you say Y here, you will be able to select a group that will be
49847 + able to view all processes and network-related information. If you've
49848 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
49849 + remain hidden. This option is useful if you want to run identd as
49850 + a non-root user.
49851 +
49852 +config GRKERNSEC_PROC_GID
49853 + int "GID for special group"
49854 + depends on GRKERNSEC_PROC_USERGROUP
49855 + default 1001
49856 +
49857 +config GRKERNSEC_PROC_ADD
49858 + bool "Additional restrictions"
49859 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
49860 + help
49861 + If you say Y here, additional restrictions will be placed on
49862 + /proc that keep normal users from viewing device information and
49863 + slabinfo information that could be useful for exploits.
49864 +
49865 +config GRKERNSEC_LINK
49866 + bool "Linking restrictions"
49867 + help
49868 + If you say Y here, /tmp race exploits will be prevented, since users
49869 + will no longer be able to follow symlinks owned by other users in
49870 + world-writable +t directories (e.g. /tmp), unless the owner of the
49871 + symlink is the owner of the directory. users will also not be
49872 + able to hardlink to files they do not own. If the sysctl option is
49873 + enabled, a sysctl option with name "linking_restrictions" is created.
49874 +
49875 +config GRKERNSEC_FIFO
49876 + bool "FIFO restrictions"
49877 + help
49878 + If you say Y here, users will not be able to write to FIFOs they don't
49879 + own in world-writable +t directories (e.g. /tmp), unless the owner of
49880 + the FIFO is the same owner of the directory it's held in. If the sysctl
49881 + option is enabled, a sysctl option with name "fifo_restrictions" is
49882 + created.
49883 +
49884 +config GRKERNSEC_SYSFS_RESTRICT
49885 + bool "Sysfs/debugfs restriction"
49886 + depends on SYSFS
49887 + help
49888 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
49889 + any filesystem normally mounted under it (e.g. debugfs) will be
49890 + mostly accessible only by root. These filesystems generally provide access
49891 + to hardware and debug information that isn't appropriate for unprivileged
49892 + users of the system. Sysfs and debugfs have also become a large source
49893 + of new vulnerabilities, ranging from infoleaks to local compromise.
49894 + There has been very little oversight with an eye toward security involved
49895 + in adding new exporters of information to these filesystems, so their
49896 + use is discouraged.
49897 + For reasons of compatibility, a few directories have been whitelisted
49898 + for access by non-root users:
49899 + /sys/fs/selinux
49900 + /sys/fs/fuse
49901 + /sys/devices/system/cpu
49902 +
49903 +config GRKERNSEC_ROFS
49904 + bool "Runtime read-only mount protection"
49905 + help
49906 + If you say Y here, a sysctl option with name "romount_protect" will
49907 + be created. By setting this option to 1 at runtime, filesystems
49908 + will be protected in the following ways:
49909 + * No new writable mounts will be allowed
49910 + * Existing read-only mounts won't be able to be remounted read/write
49911 + * Write operations will be denied on all block devices
49912 + This option acts independently of grsec_lock: once it is set to 1,
49913 + it cannot be turned off. Therefore, please be mindful of the resulting
49914 + behavior if this option is enabled in an init script on a read-only
49915 + filesystem. This feature is mainly intended for secure embedded systems.
49916 +
49917 +config GRKERNSEC_CHROOT
49918 + bool "Chroot jail restrictions"
49919 + help
49920 + If you say Y here, you will be able to choose several options that will
49921 + make breaking out of a chrooted jail much more difficult. If you
49922 + encounter no software incompatibilities with the following options, it
49923 + is recommended that you enable each one.
49924 +
49925 +config GRKERNSEC_CHROOT_MOUNT
49926 + bool "Deny mounts"
49927 + depends on GRKERNSEC_CHROOT
49928 + help
49929 + If you say Y here, processes inside a chroot will not be able to
49930 + mount or remount filesystems. If the sysctl option is enabled, a
49931 + sysctl option with name "chroot_deny_mount" is created.
49932 +
49933 +config GRKERNSEC_CHROOT_DOUBLE
49934 + bool "Deny double-chroots"
49935 + depends on GRKERNSEC_CHROOT
49936 + help
49937 + If you say Y here, processes inside a chroot will not be able to chroot
49938 + again outside the chroot. This is a widely used method of breaking
49939 + out of a chroot jail and should not be allowed. If the sysctl
49940 + option is enabled, a sysctl option with name
49941 + "chroot_deny_chroot" is created.
49942 +
49943 +config GRKERNSEC_CHROOT_PIVOT
49944 + bool "Deny pivot_root in chroot"
49945 + depends on GRKERNSEC_CHROOT
49946 + help
49947 + If you say Y here, processes inside a chroot will not be able to use
49948 + a function called pivot_root() that was introduced in Linux 2.3.41. It
49949 + works similar to chroot in that it changes the root filesystem. This
49950 + function could be misused in a chrooted process to attempt to break out
49951 + of the chroot, and therefore should not be allowed. If the sysctl
49952 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
49953 + created.
49954 +
49955 +config GRKERNSEC_CHROOT_CHDIR
49956 + bool "Enforce chdir(\"/\") on all chroots"
49957 + depends on GRKERNSEC_CHROOT
49958 + help
49959 + If you say Y here, the current working directory of all newly-chrooted
49960 + applications will be set to the the root directory of the chroot.
49961 + The man page on chroot(2) states:
49962 + Note that this call does not change the current working
49963 + directory, so that `.' can be outside the tree rooted at
49964 + `/'. In particular, the super-user can escape from a
49965 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
49966 +
49967 + It is recommended that you say Y here, since it's not known to break
49968 + any software. If the sysctl option is enabled, a sysctl option with
49969 + name "chroot_enforce_chdir" is created.
49970 +
49971 +config GRKERNSEC_CHROOT_CHMOD
49972 + bool "Deny (f)chmod +s"
49973 + depends on GRKERNSEC_CHROOT
49974 + help
49975 + If you say Y here, processes inside a chroot will not be able to chmod
49976 + or fchmod files to make them have suid or sgid bits. This protects
49977 + against another published method of breaking a chroot. If the sysctl
49978 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
49979 + created.
49980 +
49981 +config GRKERNSEC_CHROOT_FCHDIR
49982 + bool "Deny fchdir out of chroot"
49983 + depends on GRKERNSEC_CHROOT
49984 + help
49985 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
49986 + to a file descriptor of the chrooting process that points to a directory
49987 + outside the filesystem will be stopped. If the sysctl option
49988 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
49989 +
49990 +config GRKERNSEC_CHROOT_MKNOD
49991 + bool "Deny mknod"
49992 + depends on GRKERNSEC_CHROOT
49993 + help
49994 + If you say Y here, processes inside a chroot will not be allowed to
49995 + mknod. The problem with using mknod inside a chroot is that it
49996 + would allow an attacker to create a device entry that is the same
49997 + as one on the physical root of your system, which could range from
49998 + anything from the console device to a device for your harddrive (which
49999 + they could then use to wipe the drive or steal data). It is recommended
50000 + that you say Y here, unless you run into software incompatibilities.
50001 + If the sysctl option is enabled, a sysctl option with name
50002 + "chroot_deny_mknod" is created.
50003 +
50004 +config GRKERNSEC_CHROOT_SHMAT
50005 + bool "Deny shmat() out of chroot"
50006 + depends on GRKERNSEC_CHROOT
50007 + help
50008 + If you say Y here, processes inside a chroot will not be able to attach
50009 + to shared memory segments that were created outside of the chroot jail.
50010 + It is recommended that you say Y here. If the sysctl option is enabled,
50011 + a sysctl option with name "chroot_deny_shmat" is created.
50012 +
50013 +config GRKERNSEC_CHROOT_UNIX
50014 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
50015 + depends on GRKERNSEC_CHROOT
50016 + help
50017 + If you say Y here, processes inside a chroot will not be able to
50018 + connect to abstract (meaning not belonging to a filesystem) Unix
50019 + domain sockets that were bound outside of a chroot. It is recommended
50020 + that you say Y here. If the sysctl option is enabled, a sysctl option
50021 + with name "chroot_deny_unix" is created.
50022 +
50023 +config GRKERNSEC_CHROOT_FINDTASK
50024 + bool "Protect outside processes"
50025 + depends on GRKERNSEC_CHROOT
50026 + help
50027 + If you say Y here, processes inside a chroot will not be able to
50028 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
50029 + getsid, or view any process outside of the chroot. If the sysctl
50030 + option is enabled, a sysctl option with name "chroot_findtask" is
50031 + created.
50032 +
50033 +config GRKERNSEC_CHROOT_NICE
50034 + bool "Restrict priority changes"
50035 + depends on GRKERNSEC_CHROOT
50036 + help
50037 + If you say Y here, processes inside a chroot will not be able to raise
50038 + the priority of processes in the chroot, or alter the priority of
50039 + processes outside the chroot. This provides more security than simply
50040 + removing CAP_SYS_NICE from the process' capability set. If the
50041 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
50042 + is created.
50043 +
50044 +config GRKERNSEC_CHROOT_SYSCTL
50045 + bool "Deny sysctl writes"
50046 + depends on GRKERNSEC_CHROOT
50047 + help
50048 + If you say Y here, an attacker in a chroot will not be able to
50049 + write to sysctl entries, either by sysctl(2) or through a /proc
50050 + interface. It is strongly recommended that you say Y here. If the
50051 + sysctl option is enabled, a sysctl option with name
50052 + "chroot_deny_sysctl" is created.
50053 +
50054 +config GRKERNSEC_CHROOT_CAPS
50055 + bool "Capability restrictions"
50056 + depends on GRKERNSEC_CHROOT
50057 + help
50058 + If you say Y here, the capabilities on all processes within a
50059 + chroot jail will be lowered to stop module insertion, raw i/o,
50060 + system and net admin tasks, rebooting the system, modifying immutable
50061 + files, modifying IPC owned by another, and changing the system time.
50062 + This is left an option because it can break some apps. Disable this
50063 + if your chrooted apps are having problems performing those kinds of
50064 + tasks. If the sysctl option is enabled, a sysctl option with
50065 + name "chroot_caps" is created.
50066 +
50067 +endmenu
50068 +menu "Kernel Auditing"
50069 +depends on GRKERNSEC
50070 +
50071 +config GRKERNSEC_AUDIT_GROUP
50072 + bool "Single group for auditing"
50073 + help
50074 + If you say Y here, the exec, chdir, and (un)mount logging features
50075 + will only operate on a group you specify. This option is recommended
50076 + if you only want to watch certain users instead of having a large
50077 + amount of logs from the entire system. If the sysctl option is enabled,
50078 + a sysctl option with name "audit_group" is created.
50079 +
50080 +config GRKERNSEC_AUDIT_GID
50081 + int "GID for auditing"
50082 + depends on GRKERNSEC_AUDIT_GROUP
50083 + default 1007
50084 +
50085 +config GRKERNSEC_EXECLOG
50086 + bool "Exec logging"
50087 + help
50088 + If you say Y here, all execve() calls will be logged (since the
50089 + other exec*() calls are frontends to execve(), all execution
50090 + will be logged). Useful for shell-servers that like to keep track
50091 + of their users. If the sysctl option is enabled, a sysctl option with
50092 + name "exec_logging" is created.
50093 + WARNING: This option when enabled will produce a LOT of logs, especially
50094 + on an active system.
50095 +
50096 +config GRKERNSEC_RESLOG
50097 + bool "Resource logging"
50098 + help
50099 + If you say Y here, all attempts to overstep resource limits will
50100 + be logged with the resource name, the requested size, and the current
50101 + limit. It is highly recommended that you say Y here. If the sysctl
50102 + option is enabled, a sysctl option with name "resource_logging" is
50103 + created. If the RBAC system is enabled, the sysctl value is ignored.
50104 +
50105 +config GRKERNSEC_CHROOT_EXECLOG
50106 + bool "Log execs within chroot"
50107 + help
50108 + If you say Y here, all executions inside a chroot jail will be logged
50109 + to syslog. This can cause a large amount of logs if certain
50110 + applications (eg. djb's daemontools) are installed on the system, and
50111 + is therefore left as an option. If the sysctl option is enabled, a
50112 + sysctl option with name "chroot_execlog" is created.
50113 +
50114 +config GRKERNSEC_AUDIT_PTRACE
50115 + bool "Ptrace logging"
50116 + help
50117 + If you say Y here, all attempts to attach to a process via ptrace
50118 + will be logged. If the sysctl option is enabled, a sysctl option
50119 + with name "audit_ptrace" is created.
50120 +
50121 +config GRKERNSEC_AUDIT_CHDIR
50122 + bool "Chdir logging"
50123 + help
50124 + If you say Y here, all chdir() calls will be logged. If the sysctl
50125 + option is enabled, a sysctl option with name "audit_chdir" is created.
50126 +
50127 +config GRKERNSEC_AUDIT_MOUNT
50128 + bool "(Un)Mount logging"
50129 + help
50130 + If you say Y here, all mounts and unmounts will be logged. If the
50131 + sysctl option is enabled, a sysctl option with name "audit_mount" is
50132 + created.
50133 +
50134 +config GRKERNSEC_SIGNAL
50135 + bool "Signal logging"
50136 + help
50137 + If you say Y here, certain important signals will be logged, such as
50138 + SIGSEGV, which will as a result inform you of when a error in a program
50139 + occurred, which in some cases could mean a possible exploit attempt.
50140 + If the sysctl option is enabled, a sysctl option with name
50141 + "signal_logging" is created.
50142 +
50143 +config GRKERNSEC_FORKFAIL
50144 + bool "Fork failure logging"
50145 + help
50146 + If you say Y here, all failed fork() attempts will be logged.
50147 + This could suggest a fork bomb, or someone attempting to overstep
50148 + their process limit. If the sysctl option is enabled, a sysctl option
50149 + with name "forkfail_logging" is created.
50150 +
50151 +config GRKERNSEC_TIME
50152 + bool "Time change logging"
50153 + help
50154 + If you say Y here, any changes of the system clock will be logged.
50155 + If the sysctl option is enabled, a sysctl option with name
50156 + "timechange_logging" is created.
50157 +
50158 +config GRKERNSEC_PROC_IPADDR
50159 + bool "/proc/<pid>/ipaddr support"
50160 + help
50161 + If you say Y here, a new entry will be added to each /proc/<pid>
50162 + directory that contains the IP address of the person using the task.
50163 + The IP is carried across local TCP and AF_UNIX stream sockets.
50164 + This information can be useful for IDS/IPSes to perform remote response
50165 + to a local attack. The entry is readable by only the owner of the
50166 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
50167 + the RBAC system), and thus does not create privacy concerns.
50168 +
50169 +config GRKERNSEC_RWXMAP_LOG
50170 + bool 'Denied RWX mmap/mprotect logging'
50171 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
50172 + help
50173 + If you say Y here, calls to mmap() and mprotect() with explicit
50174 + usage of PROT_WRITE and PROT_EXEC together will be logged when
50175 + denied by the PAX_MPROTECT feature. If the sysctl option is
50176 + enabled, a sysctl option with name "rwxmap_logging" is created.
50177 +
50178 +config GRKERNSEC_AUDIT_TEXTREL
50179 + bool 'ELF text relocations logging (READ HELP)'
50180 + depends on PAX_MPROTECT
50181 + help
50182 + If you say Y here, text relocations will be logged with the filename
50183 + of the offending library or binary. The purpose of the feature is
50184 + to help Linux distribution developers get rid of libraries and
50185 + binaries that need text relocations which hinder the future progress
50186 + of PaX. Only Linux distribution developers should say Y here, and
50187 + never on a production machine, as this option creates an information
50188 + leak that could aid an attacker in defeating the randomization of
50189 + a single memory region. If the sysctl option is enabled, a sysctl
50190 + option with name "audit_textrel" is created.
50191 +
50192 +endmenu
50193 +
50194 +menu "Executable Protections"
50195 +depends on GRKERNSEC
50196 +
50197 +config GRKERNSEC_DMESG
50198 + bool "Dmesg(8) restriction"
50199 + help
50200 + If you say Y here, non-root users will not be able to use dmesg(8)
50201 + to view up to the last 4kb of messages in the kernel's log buffer.
50202 + The kernel's log buffer often contains kernel addresses and other
50203 + identifying information useful to an attacker in fingerprinting a
50204 + system for a targeted exploit.
50205 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
50206 + created.
50207 +
50208 +config GRKERNSEC_HARDEN_PTRACE
50209 + bool "Deter ptrace-based process snooping"
50210 + help
50211 + If you say Y here, TTY sniffers and other malicious monitoring
50212 + programs implemented through ptrace will be defeated. If you
50213 + have been using the RBAC system, this option has already been
50214 + enabled for several years for all users, with the ability to make
50215 + fine-grained exceptions.
50216 +
50217 + This option only affects the ability of non-root users to ptrace
50218 + processes that are not a descendent of the ptracing process.
50219 + This means that strace ./binary and gdb ./binary will still work,
50220 + but attaching to arbitrary processes will not. If the sysctl
50221 + option is enabled, a sysctl option with name "harden_ptrace" is
50222 + created.
50223 +
50224 +config GRKERNSEC_PTRACE_READEXEC
50225 + bool "Require read access to ptrace sensitive binaries"
50226 + help
50227 + If you say Y here, unprivileged users will not be able to ptrace unreadable
50228 + binaries. This option is useful in environments that
50229 + remove the read bits (e.g. file mode 4711) from suid binaries to
50230 + prevent infoleaking of their contents. This option adds
50231 + consistency to the use of that file mode, as the binary could normally
50232 + be read out when run without privileges while ptracing.
50233 +
50234 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
50235 + is created.
50236 +
50237 +config GRKERNSEC_SETXID
50238 + bool "Enforce consistent multithreaded privileges"
50239 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
50240 + help
50241 + If you say Y here, a change from a root uid to a non-root uid
50242 + in a multithreaded application will cause the resulting uids,
50243 + gids, supplementary groups, and capabilities in that thread
50244 + to be propagated to the other threads of the process. In most
50245 + cases this is unnecessary, as glibc will emulate this behavior
50246 + on behalf of the application. Other libcs do not act in the
50247 + same way, allowing the other threads of the process to continue
50248 + running with root privileges. If the sysctl option is enabled,
50249 + a sysctl option with name "consistent_setxid" is created.
50250 +
50251 +config GRKERNSEC_TPE
50252 + bool "Trusted Path Execution (TPE)"
50253 + help
50254 + If you say Y here, you will be able to choose a gid to add to the
50255 + supplementary groups of users you want to mark as "untrusted."
50256 + These users will not be able to execute any files that are not in
50257 + root-owned directories writable only by root. If the sysctl option
50258 + is enabled, a sysctl option with name "tpe" is created.
50259 +
50260 +config GRKERNSEC_TPE_ALL
50261 + bool "Partially restrict all non-root users"
50262 + depends on GRKERNSEC_TPE
50263 + help
50264 + If you say Y here, all non-root users will be covered under
50265 + a weaker TPE restriction. This is separate from, and in addition to,
50266 + the main TPE options that you have selected elsewhere. Thus, if a
50267 + "trusted" GID is chosen, this restriction applies to even that GID.
50268 + Under this restriction, all non-root users will only be allowed to
50269 + execute files in directories they own that are not group or
50270 + world-writable, or in directories owned by root and writable only by
50271 + root. If the sysctl option is enabled, a sysctl option with name
50272 + "tpe_restrict_all" is created.
50273 +
50274 +config GRKERNSEC_TPE_INVERT
50275 + bool "Invert GID option"
50276 + depends on GRKERNSEC_TPE
50277 + help
50278 + If you say Y here, the group you specify in the TPE configuration will
50279 + decide what group TPE restrictions will be *disabled* for. This
50280 + option is useful if you want TPE restrictions to be applied to most
50281 + users on the system. If the sysctl option is enabled, a sysctl option
50282 + with name "tpe_invert" is created. Unlike other sysctl options, this
50283 + entry will default to on for backward-compatibility.
50284 +
50285 +config GRKERNSEC_TPE_GID
50286 + int "GID for untrusted users"
50287 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
50288 + default 1005
50289 + help
50290 + Setting this GID determines what group TPE restrictions will be
50291 + *enabled* for. If the sysctl option is enabled, a sysctl option
50292 + with name "tpe_gid" is created.
50293 +
50294 +config GRKERNSEC_TPE_GID
50295 + int "GID for trusted users"
50296 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
50297 + default 1005
50298 + help
50299 + Setting this GID determines what group TPE restrictions will be
50300 + *disabled* for. If the sysctl option is enabled, a sysctl option
50301 + with name "tpe_gid" is created.
50302 +
50303 +endmenu
50304 +menu "Network Protections"
50305 +depends on GRKERNSEC
50306 +
50307 +config GRKERNSEC_RANDNET
50308 + bool "Larger entropy pools"
50309 + help
50310 + If you say Y here, the entropy pools used for many features of Linux
50311 + and grsecurity will be doubled in size. Since several grsecurity
50312 + features use additional randomness, it is recommended that you say Y
50313 + here. Saying Y here has a similar effect as modifying
50314 + /proc/sys/kernel/random/poolsize.
50315 +
50316 +config GRKERNSEC_BLACKHOLE
50317 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
50318 + depends on NET
50319 + help
50320 + If you say Y here, neither TCP resets nor ICMP
50321 + destination-unreachable packets will be sent in response to packets
50322 + sent to ports for which no associated listening process exists.
50323 + This feature supports both IPV4 and IPV6 and exempts the
50324 + loopback interface from blackholing. Enabling this feature
50325 + makes a host more resilient to DoS attacks and reduces network
50326 + visibility against scanners.
50327 +
50328 + The blackhole feature as-implemented is equivalent to the FreeBSD
50329 + blackhole feature, as it prevents RST responses to all packets, not
50330 + just SYNs. Under most application behavior this causes no
50331 + problems, but applications (like haproxy) may not close certain
50332 + connections in a way that cleanly terminates them on the remote
50333 + end, leaving the remote host in LAST_ACK state. Because of this
50334 + side-effect and to prevent intentional LAST_ACK DoSes, this
50335 + feature also adds automatic mitigation against such attacks.
50336 + The mitigation drastically reduces the amount of time a socket
50337 + can spend in LAST_ACK state. If you're using haproxy and not
50338 + all servers it connects to have this option enabled, consider
50339 + disabling this feature on the haproxy host.
50340 +
50341 + If the sysctl option is enabled, two sysctl options with names
50342 + "ip_blackhole" and "lastack_retries" will be created.
50343 + While "ip_blackhole" takes the standard zero/non-zero on/off
50344 + toggle, "lastack_retries" uses the same kinds of values as
50345 + "tcp_retries1" and "tcp_retries2". The default value of 4
50346 + prevents a socket from lasting more than 45 seconds in LAST_ACK
50347 + state.
50348 +
50349 +config GRKERNSEC_SOCKET
50350 + bool "Socket restrictions"
50351 + depends on NET
50352 + help
50353 + If you say Y here, you will be able to choose from several options.
50354 + If you assign a GID on your system and add it to the supplementary
50355 + groups of users you want to restrict socket access to, this patch
50356 + will perform up to three things, based on the option(s) you choose.
50357 +
50358 +config GRKERNSEC_SOCKET_ALL
50359 + bool "Deny any sockets to group"
50360 + depends on GRKERNSEC_SOCKET
50361 + help
50362 + If you say Y here, you will be able to choose a GID of whose users will
50363 + be unable to connect to other hosts from your machine or run server
50364 + applications from your machine. If the sysctl option is enabled, a
50365 + sysctl option with name "socket_all" is created.
50366 +
50367 +config GRKERNSEC_SOCKET_ALL_GID
50368 + int "GID to deny all sockets for"
50369 + depends on GRKERNSEC_SOCKET_ALL
50370 + default 1004
50371 + help
50372 + Here you can choose the GID to disable socket access for. Remember to
50373 + add the users you want socket access disabled for to the GID
50374 + specified here. If the sysctl option is enabled, a sysctl option
50375 + with name "socket_all_gid" is created.
50376 +
50377 +config GRKERNSEC_SOCKET_CLIENT
50378 + bool "Deny client sockets to group"
50379 + depends on GRKERNSEC_SOCKET
50380 + help
50381 + If you say Y here, you will be able to choose a GID of whose users will
50382 + be unable to connect to other hosts from your machine, but will be
50383 + able to run servers. If this option is enabled, all users in the group
50384 + you specify will have to use passive mode when initiating ftp transfers
50385 + from the shell on your machine. If the sysctl option is enabled, a
50386 + sysctl option with name "socket_client" is created.
50387 +
50388 +config GRKERNSEC_SOCKET_CLIENT_GID
50389 + int "GID to deny client sockets for"
50390 + depends on GRKERNSEC_SOCKET_CLIENT
50391 + default 1003
50392 + help
50393 + Here you can choose the GID to disable client socket access for.
50394 + Remember to add the users you want client socket access disabled for to
50395 + the GID specified here. If the sysctl option is enabled, a sysctl
50396 + option with name "socket_client_gid" is created.
50397 +
50398 +config GRKERNSEC_SOCKET_SERVER
50399 + bool "Deny server sockets to group"
50400 + depends on GRKERNSEC_SOCKET
50401 + help
50402 + If you say Y here, you will be able to choose a GID of whose users will
50403 + be unable to run server applications from your machine. If the sysctl
50404 + option is enabled, a sysctl option with name "socket_server" is created.
50405 +
50406 +config GRKERNSEC_SOCKET_SERVER_GID
50407 + int "GID to deny server sockets for"
50408 + depends on GRKERNSEC_SOCKET_SERVER
50409 + default 1002
50410 + help
50411 + Here you can choose the GID to disable server socket access for.
50412 + Remember to add the users you want server socket access disabled for to
50413 + the GID specified here. If the sysctl option is enabled, a sysctl
50414 + option with name "socket_server_gid" is created.
50415 +
50416 +endmenu
50417 +menu "Sysctl support"
50418 +depends on GRKERNSEC && SYSCTL
50419 +
50420 +config GRKERNSEC_SYSCTL
50421 + bool "Sysctl support"
50422 + help
50423 + If you say Y here, you will be able to change the options that
50424 + grsecurity runs with at bootup, without having to recompile your
50425 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
50426 + to enable (1) or disable (0) various features. All the sysctl entries
50427 + are mutable until the "grsec_lock" entry is set to a non-zero value.
50428 + All features enabled in the kernel configuration are disabled at boot
50429 + if you do not say Y to the "Turn on features by default" option.
50430 + All options should be set at startup, and the grsec_lock entry should
50431 + be set to a non-zero value after all the options are set.
50432 + *THIS IS EXTREMELY IMPORTANT*
50433 +
50434 +config GRKERNSEC_SYSCTL_DISTRO
50435 + bool "Extra sysctl support for distro makers (READ HELP)"
50436 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
50437 + help
50438 + If you say Y here, additional sysctl options will be created
50439 + for features that affect processes running as root. Therefore,
50440 + it is critical when using this option that the grsec_lock entry be
50441 + enabled after boot. Only distros with prebuilt kernel packages
50442 + with this option enabled that can ensure grsec_lock is enabled
50443 + after boot should use this option.
50444 + *Failure to set grsec_lock after boot makes all grsec features
50445 + this option covers useless*
50446 +
50447 + Currently this option creates the following sysctl entries:
50448 + "Disable Privileged I/O": "disable_priv_io"
50449 +
50450 +config GRKERNSEC_SYSCTL_ON
50451 + bool "Turn on features by default"
50452 + depends on GRKERNSEC_SYSCTL
50453 + help
50454 + If you say Y here, instead of having all features enabled in the
50455 + kernel configuration disabled at boot time, the features will be
50456 + enabled at boot time. It is recommended you say Y here unless
50457 + there is some reason you would want all sysctl-tunable features to
50458 + be disabled by default. As mentioned elsewhere, it is important
50459 + to enable the grsec_lock entry once you have finished modifying
50460 + the sysctl entries.
50461 +
50462 +endmenu
50463 +menu "Logging Options"
50464 +depends on GRKERNSEC
50465 +
50466 +config GRKERNSEC_FLOODTIME
50467 + int "Seconds in between log messages (minimum)"
50468 + default 10
50469 + help
50470 + This option allows you to enforce the number of seconds between
50471 + grsecurity log messages. The default should be suitable for most
50472 + people, however, if you choose to change it, choose a value small enough
50473 + to allow informative logs to be produced, but large enough to
50474 + prevent flooding.
50475 +
50476 +config GRKERNSEC_FLOODBURST
50477 + int "Number of messages in a burst (maximum)"
50478 + default 6
50479 + help
50480 + This option allows you to choose the maximum number of messages allowed
50481 + within the flood time interval you chose in a separate option. The
50482 + default should be suitable for most people, however if you find that
50483 + many of your logs are being interpreted as flooding, you may want to
50484 + raise this value.
50485 +
50486 +endmenu
50487 +
50488 +endmenu
50489 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
50490 new file mode 100644
50491 index 0000000..1b9afa9
50492 --- /dev/null
50493 +++ b/grsecurity/Makefile
50494 @@ -0,0 +1,38 @@
50495 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
50496 +# during 2001-2009 it has been completely redesigned by Brad Spengler
50497 +# into an RBAC system
50498 +#
50499 +# All code in this directory and various hooks inserted throughout the kernel
50500 +# are copyright Brad Spengler - Open Source Security, Inc., and released
50501 +# under the GPL v2 or higher
50502 +
50503 +KBUILD_CFLAGS += -Werror
50504 +
50505 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
50506 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
50507 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
50508 +
50509 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
50510 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
50511 + gracl_learn.o grsec_log.o
50512 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
50513 +
50514 +ifdef CONFIG_NET
50515 +obj-y += grsec_sock.o
50516 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
50517 +endif
50518 +
50519 +ifndef CONFIG_GRKERNSEC
50520 +obj-y += grsec_disabled.o
50521 +endif
50522 +
50523 +ifdef CONFIG_GRKERNSEC_HIDESYM
50524 +extra-y := grsec_hidesym.o
50525 +$(obj)/grsec_hidesym.o:
50526 + @-chmod -f 500 /boot
50527 + @-chmod -f 500 /lib/modules
50528 + @-chmod -f 500 /lib64/modules
50529 + @-chmod -f 500 /lib32/modules
50530 + @-chmod -f 700 .
50531 + @echo ' grsec: protected kernel image paths'
50532 +endif
50533 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
50534 new file mode 100644
50535 index 0000000..a6d83f0
50536 --- /dev/null
50537 +++ b/grsecurity/gracl.c
50538 @@ -0,0 +1,4193 @@
50539 +#include <linux/kernel.h>
50540 +#include <linux/module.h>
50541 +#include <linux/sched.h>
50542 +#include <linux/mm.h>
50543 +#include <linux/file.h>
50544 +#include <linux/fs.h>
50545 +#include <linux/namei.h>
50546 +#include <linux/mount.h>
50547 +#include <linux/tty.h>
50548 +#include <linux/proc_fs.h>
50549 +#include <linux/lglock.h>
50550 +#include <linux/slab.h>
50551 +#include <linux/vmalloc.h>
50552 +#include <linux/types.h>
50553 +#include <linux/sysctl.h>
50554 +#include <linux/netdevice.h>
50555 +#include <linux/ptrace.h>
50556 +#include <linux/gracl.h>
50557 +#include <linux/gralloc.h>
50558 +#include <linux/security.h>
50559 +#include <linux/grinternal.h>
50560 +#include <linux/pid_namespace.h>
50561 +#include <linux/fdtable.h>
50562 +#include <linux/percpu.h>
50563 +#include "../fs/mount.h"
50564 +
50565 +#include <asm/uaccess.h>
50566 +#include <asm/errno.h>
50567 +#include <asm/mman.h>
50568 +
50569 +static struct acl_role_db acl_role_set;
50570 +static struct name_db name_set;
50571 +static struct inodev_db inodev_set;
50572 +
50573 +/* for keeping track of userspace pointers used for subjects, so we
50574 + can share references in the kernel as well
50575 +*/
50576 +
50577 +static struct path real_root;
50578 +
50579 +static struct acl_subj_map_db subj_map_set;
50580 +
50581 +static struct acl_role_label *default_role;
50582 +
50583 +static struct acl_role_label *role_list;
50584 +
50585 +static u16 acl_sp_role_value;
50586 +
50587 +extern char *gr_shared_page[4];
50588 +static DEFINE_MUTEX(gr_dev_mutex);
50589 +DEFINE_RWLOCK(gr_inode_lock);
50590 +
50591 +struct gr_arg *gr_usermode;
50592 +
50593 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
50594 +
50595 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
50596 +extern void gr_clear_learn_entries(void);
50597 +
50598 +#ifdef CONFIG_GRKERNSEC_RESLOG
50599 +extern void gr_log_resource(const struct task_struct *task,
50600 + const int res, const unsigned long wanted, const int gt);
50601 +#endif
50602 +
50603 +unsigned char *gr_system_salt;
50604 +unsigned char *gr_system_sum;
50605 +
50606 +static struct sprole_pw **acl_special_roles = NULL;
50607 +static __u16 num_sprole_pws = 0;
50608 +
50609 +static struct acl_role_label *kernel_role = NULL;
50610 +
50611 +static unsigned int gr_auth_attempts = 0;
50612 +static unsigned long gr_auth_expires = 0UL;
50613 +
50614 +#ifdef CONFIG_NET
50615 +extern struct vfsmount *sock_mnt;
50616 +#endif
50617 +
50618 +extern struct vfsmount *pipe_mnt;
50619 +extern struct vfsmount *shm_mnt;
50620 +#ifdef CONFIG_HUGETLBFS
50621 +extern struct vfsmount *hugetlbfs_vfsmount;
50622 +#endif
50623 +
50624 +static struct acl_object_label *fakefs_obj_rw;
50625 +static struct acl_object_label *fakefs_obj_rwx;
50626 +
50627 +extern int gr_init_uidset(void);
50628 +extern void gr_free_uidset(void);
50629 +extern void gr_remove_uid(uid_t uid);
50630 +extern int gr_find_uid(uid_t uid);
50631 +
50632 +DECLARE_BRLOCK(vfsmount_lock);
50633 +
50634 +__inline__ int
50635 +gr_acl_is_enabled(void)
50636 +{
50637 + return (gr_status & GR_READY);
50638 +}
50639 +
50640 +#ifdef CONFIG_BTRFS_FS
50641 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
50642 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
50643 +#endif
50644 +
50645 +static inline dev_t __get_dev(const struct dentry *dentry)
50646 +{
50647 +#ifdef CONFIG_BTRFS_FS
50648 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
50649 + return get_btrfs_dev_from_inode(dentry->d_inode);
50650 + else
50651 +#endif
50652 + return dentry->d_inode->i_sb->s_dev;
50653 +}
50654 +
50655 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
50656 +{
50657 + return __get_dev(dentry);
50658 +}
50659 +
50660 +static char gr_task_roletype_to_char(struct task_struct *task)
50661 +{
50662 + switch (task->role->roletype &
50663 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
50664 + GR_ROLE_SPECIAL)) {
50665 + case GR_ROLE_DEFAULT:
50666 + return 'D';
50667 + case GR_ROLE_USER:
50668 + return 'U';
50669 + case GR_ROLE_GROUP:
50670 + return 'G';
50671 + case GR_ROLE_SPECIAL:
50672 + return 'S';
50673 + }
50674 +
50675 + return 'X';
50676 +}
50677 +
50678 +char gr_roletype_to_char(void)
50679 +{
50680 + return gr_task_roletype_to_char(current);
50681 +}
50682 +
50683 +__inline__ int
50684 +gr_acl_tpe_check(void)
50685 +{
50686 + if (unlikely(!(gr_status & GR_READY)))
50687 + return 0;
50688 + if (current->role->roletype & GR_ROLE_TPE)
50689 + return 1;
50690 + else
50691 + return 0;
50692 +}
50693 +
50694 +int
50695 +gr_handle_rawio(const struct inode *inode)
50696 +{
50697 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
50698 + if (inode && S_ISBLK(inode->i_mode) &&
50699 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
50700 + !capable(CAP_SYS_RAWIO))
50701 + return 1;
50702 +#endif
50703 + return 0;
50704 +}
50705 +
50706 +static int
50707 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
50708 +{
50709 + if (likely(lena != lenb))
50710 + return 0;
50711 +
50712 + return !memcmp(a, b, lena);
50713 +}
50714 +
50715 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
50716 +{
50717 + *buflen -= namelen;
50718 + if (*buflen < 0)
50719 + return -ENAMETOOLONG;
50720 + *buffer -= namelen;
50721 + memcpy(*buffer, str, namelen);
50722 + return 0;
50723 +}
50724 +
50725 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
50726 +{
50727 + return prepend(buffer, buflen, name->name, name->len);
50728 +}
50729 +
50730 +static int prepend_path(const struct path *path, struct path *root,
50731 + char **buffer, int *buflen)
50732 +{
50733 + struct dentry *dentry = path->dentry;
50734 + struct vfsmount *vfsmnt = path->mnt;
50735 + struct mount *mnt = real_mount(vfsmnt);
50736 + bool slash = false;
50737 + int error = 0;
50738 +
50739 + while (dentry != root->dentry || vfsmnt != root->mnt) {
50740 + struct dentry * parent;
50741 +
50742 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
50743 + /* Global root? */
50744 + if (!mnt_has_parent(mnt)) {
50745 + goto out;
50746 + }
50747 + dentry = mnt->mnt_mountpoint;
50748 + mnt = mnt->mnt_parent;
50749 + vfsmnt = &mnt->mnt;
50750 + continue;
50751 + }
50752 + parent = dentry->d_parent;
50753 + prefetch(parent);
50754 + spin_lock(&dentry->d_lock);
50755 + error = prepend_name(buffer, buflen, &dentry->d_name);
50756 + spin_unlock(&dentry->d_lock);
50757 + if (!error)
50758 + error = prepend(buffer, buflen, "/", 1);
50759 + if (error)
50760 + break;
50761 +
50762 + slash = true;
50763 + dentry = parent;
50764 + }
50765 +
50766 +out:
50767 + if (!error && !slash)
50768 + error = prepend(buffer, buflen, "/", 1);
50769 +
50770 + return error;
50771 +}
50772 +
50773 +/* this must be called with vfsmount_lock and rename_lock held */
50774 +
50775 +static char *__our_d_path(const struct path *path, struct path *root,
50776 + char *buf, int buflen)
50777 +{
50778 + char *res = buf + buflen;
50779 + int error;
50780 +
50781 + prepend(&res, &buflen, "\0", 1);
50782 + error = prepend_path(path, root, &res, &buflen);
50783 + if (error)
50784 + return ERR_PTR(error);
50785 +
50786 + return res;
50787 +}
50788 +
50789 +static char *
50790 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
50791 +{
50792 + char *retval;
50793 +
50794 + retval = __our_d_path(path, root, buf, buflen);
50795 + if (unlikely(IS_ERR(retval)))
50796 + retval = strcpy(buf, "<path too long>");
50797 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
50798 + retval[1] = '\0';
50799 +
50800 + return retval;
50801 +}
50802 +
50803 +static char *
50804 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
50805 + char *buf, int buflen)
50806 +{
50807 + struct path path;
50808 + char *res;
50809 +
50810 + path.dentry = (struct dentry *)dentry;
50811 + path.mnt = (struct vfsmount *)vfsmnt;
50812 +
50813 + /* we can use real_root.dentry, real_root.mnt, because this is only called
50814 + by the RBAC system */
50815 + res = gen_full_path(&path, &real_root, buf, buflen);
50816 +
50817 + return res;
50818 +}
50819 +
50820 +static char *
50821 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
50822 + char *buf, int buflen)
50823 +{
50824 + char *res;
50825 + struct path path;
50826 + struct path root;
50827 + struct task_struct *reaper = &init_task;
50828 +
50829 + path.dentry = (struct dentry *)dentry;
50830 + path.mnt = (struct vfsmount *)vfsmnt;
50831 +
50832 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
50833 + get_fs_root(reaper->fs, &root);
50834 +
50835 + write_seqlock(&rename_lock);
50836 + br_read_lock(vfsmount_lock);
50837 + res = gen_full_path(&path, &root, buf, buflen);
50838 + br_read_unlock(vfsmount_lock);
50839 + write_sequnlock(&rename_lock);
50840 +
50841 + path_put(&root);
50842 + return res;
50843 +}
50844 +
50845 +static char *
50846 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
50847 +{
50848 + char *ret;
50849 + write_seqlock(&rename_lock);
50850 + br_read_lock(vfsmount_lock);
50851 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
50852 + PAGE_SIZE);
50853 + br_read_unlock(vfsmount_lock);
50854 + write_sequnlock(&rename_lock);
50855 + return ret;
50856 +}
50857 +
50858 +static char *
50859 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
50860 +{
50861 + char *ret;
50862 + char *buf;
50863 + int buflen;
50864 +
50865 + write_seqlock(&rename_lock);
50866 + br_read_lock(vfsmount_lock);
50867 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
50868 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
50869 + buflen = (int)(ret - buf);
50870 + if (buflen >= 5)
50871 + prepend(&ret, &buflen, "/proc", 5);
50872 + else
50873 + ret = strcpy(buf, "<path too long>");
50874 + br_read_unlock(vfsmount_lock);
50875 + write_sequnlock(&rename_lock);
50876 + return ret;
50877 +}
50878 +
50879 +char *
50880 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
50881 +{
50882 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
50883 + PAGE_SIZE);
50884 +}
50885 +
50886 +char *
50887 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
50888 +{
50889 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
50890 + PAGE_SIZE);
50891 +}
50892 +
50893 +char *
50894 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
50895 +{
50896 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
50897 + PAGE_SIZE);
50898 +}
50899 +
50900 +char *
50901 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
50902 +{
50903 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
50904 + PAGE_SIZE);
50905 +}
50906 +
50907 +char *
50908 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
50909 +{
50910 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
50911 + PAGE_SIZE);
50912 +}
50913 +
50914 +__inline__ __u32
50915 +to_gr_audit(const __u32 reqmode)
50916 +{
50917 + /* masks off auditable permission flags, then shifts them to create
50918 + auditing flags, and adds the special case of append auditing if
50919 + we're requesting write */
50920 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
50921 +}
50922 +
50923 +struct acl_subject_label *
50924 +lookup_subject_map(const struct acl_subject_label *userp)
50925 +{
50926 + unsigned int index = shash(userp, subj_map_set.s_size);
50927 + struct subject_map *match;
50928 +
50929 + match = subj_map_set.s_hash[index];
50930 +
50931 + while (match && match->user != userp)
50932 + match = match->next;
50933 +
50934 + if (match != NULL)
50935 + return match->kernel;
50936 + else
50937 + return NULL;
50938 +}
50939 +
50940 +static void
50941 +insert_subj_map_entry(struct subject_map *subjmap)
50942 +{
50943 + unsigned int index = shash(subjmap->user, subj_map_set.s_size);
50944 + struct subject_map **curr;
50945 +
50946 + subjmap->prev = NULL;
50947 +
50948 + curr = &subj_map_set.s_hash[index];
50949 + if (*curr != NULL)
50950 + (*curr)->prev = subjmap;
50951 +
50952 + subjmap->next = *curr;
50953 + *curr = subjmap;
50954 +
50955 + return;
50956 +}
50957 +
50958 +static struct acl_role_label *
50959 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
50960 + const gid_t gid)
50961 +{
50962 + unsigned int index = rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
50963 + struct acl_role_label *match;
50964 + struct role_allowed_ip *ipp;
50965 + unsigned int x;
50966 + u32 curr_ip = task->signal->curr_ip;
50967 +
50968 + task->signal->saved_ip = curr_ip;
50969 +
50970 + match = acl_role_set.r_hash[index];
50971 +
50972 + while (match) {
50973 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
50974 + for (x = 0; x < match->domain_child_num; x++) {
50975 + if (match->domain_children[x] == uid)
50976 + goto found;
50977 + }
50978 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
50979 + break;
50980 + match = match->next;
50981 + }
50982 +found:
50983 + if (match == NULL) {
50984 + try_group:
50985 + index = rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
50986 + match = acl_role_set.r_hash[index];
50987 +
50988 + while (match) {
50989 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
50990 + for (x = 0; x < match->domain_child_num; x++) {
50991 + if (match->domain_children[x] == gid)
50992 + goto found2;
50993 + }
50994 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
50995 + break;
50996 + match = match->next;
50997 + }
50998 +found2:
50999 + if (match == NULL)
51000 + match = default_role;
51001 + if (match->allowed_ips == NULL)
51002 + return match;
51003 + else {
51004 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
51005 + if (likely
51006 + ((ntohl(curr_ip) & ipp->netmask) ==
51007 + (ntohl(ipp->addr) & ipp->netmask)))
51008 + return match;
51009 + }
51010 + match = default_role;
51011 + }
51012 + } else if (match->allowed_ips == NULL) {
51013 + return match;
51014 + } else {
51015 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
51016 + if (likely
51017 + ((ntohl(curr_ip) & ipp->netmask) ==
51018 + (ntohl(ipp->addr) & ipp->netmask)))
51019 + return match;
51020 + }
51021 + goto try_group;
51022 + }
51023 +
51024 + return match;
51025 +}
51026 +
51027 +struct acl_subject_label *
51028 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
51029 + const struct acl_role_label *role)
51030 +{
51031 + unsigned int index = fhash(ino, dev, role->subj_hash_size);
51032 + struct acl_subject_label *match;
51033 +
51034 + match = role->subj_hash[index];
51035 +
51036 + while (match && (match->inode != ino || match->device != dev ||
51037 + (match->mode & GR_DELETED))) {
51038 + match = match->next;
51039 + }
51040 +
51041 + if (match && !(match->mode & GR_DELETED))
51042 + return match;
51043 + else
51044 + return NULL;
51045 +}
51046 +
51047 +struct acl_subject_label *
51048 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
51049 + const struct acl_role_label *role)
51050 +{
51051 + unsigned int index = fhash(ino, dev, role->subj_hash_size);
51052 + struct acl_subject_label *match;
51053 +
51054 + match = role->subj_hash[index];
51055 +
51056 + while (match && (match->inode != ino || match->device != dev ||
51057 + !(match->mode & GR_DELETED))) {
51058 + match = match->next;
51059 + }
51060 +
51061 + if (match && (match->mode & GR_DELETED))
51062 + return match;
51063 + else
51064 + return NULL;
51065 +}
51066 +
51067 +static struct acl_object_label *
51068 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
51069 + const struct acl_subject_label *subj)
51070 +{
51071 + unsigned int index = fhash(ino, dev, subj->obj_hash_size);
51072 + struct acl_object_label *match;
51073 +
51074 + match = subj->obj_hash[index];
51075 +
51076 + while (match && (match->inode != ino || match->device != dev ||
51077 + (match->mode & GR_DELETED))) {
51078 + match = match->next;
51079 + }
51080 +
51081 + if (match && !(match->mode & GR_DELETED))
51082 + return match;
51083 + else
51084 + return NULL;
51085 +}
51086 +
51087 +static struct acl_object_label *
51088 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
51089 + const struct acl_subject_label *subj)
51090 +{
51091 + unsigned int index = fhash(ino, dev, subj->obj_hash_size);
51092 + struct acl_object_label *match;
51093 +
51094 + match = subj->obj_hash[index];
51095 +
51096 + while (match && (match->inode != ino || match->device != dev ||
51097 + !(match->mode & GR_DELETED))) {
51098 + match = match->next;
51099 + }
51100 +
51101 + if (match && (match->mode & GR_DELETED))
51102 + return match;
51103 +
51104 + match = subj->obj_hash[index];
51105 +
51106 + while (match && (match->inode != ino || match->device != dev ||
51107 + (match->mode & GR_DELETED))) {
51108 + match = match->next;
51109 + }
51110 +
51111 + if (match && !(match->mode & GR_DELETED))
51112 + return match;
51113 + else
51114 + return NULL;
51115 +}
51116 +
51117 +static struct name_entry *
51118 +lookup_name_entry(const char *name)
51119 +{
51120 + unsigned int len = strlen(name);
51121 + unsigned int key = full_name_hash(name, len);
51122 + unsigned int index = key % name_set.n_size;
51123 + struct name_entry *match;
51124 +
51125 + match = name_set.n_hash[index];
51126 +
51127 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
51128 + match = match->next;
51129 +
51130 + return match;
51131 +}
51132 +
51133 +static struct name_entry *
51134 +lookup_name_entry_create(const char *name)
51135 +{
51136 + unsigned int len = strlen(name);
51137 + unsigned int key = full_name_hash(name, len);
51138 + unsigned int index = key % name_set.n_size;
51139 + struct name_entry *match;
51140 +
51141 + match = name_set.n_hash[index];
51142 +
51143 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
51144 + !match->deleted))
51145 + match = match->next;
51146 +
51147 + if (match && match->deleted)
51148 + return match;
51149 +
51150 + match = name_set.n_hash[index];
51151 +
51152 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
51153 + match->deleted))
51154 + match = match->next;
51155 +
51156 + if (match && !match->deleted)
51157 + return match;
51158 + else
51159 + return NULL;
51160 +}
51161 +
51162 +static struct inodev_entry *
51163 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
51164 +{
51165 + unsigned int index = fhash(ino, dev, inodev_set.i_size);
51166 + struct inodev_entry *match;
51167 +
51168 + match = inodev_set.i_hash[index];
51169 +
51170 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
51171 + match = match->next;
51172 +
51173 + return match;
51174 +}
51175 +
51176 +static void
51177 +insert_inodev_entry(struct inodev_entry *entry)
51178 +{
51179 + unsigned int index = fhash(entry->nentry->inode, entry->nentry->device,
51180 + inodev_set.i_size);
51181 + struct inodev_entry **curr;
51182 +
51183 + entry->prev = NULL;
51184 +
51185 + curr = &inodev_set.i_hash[index];
51186 + if (*curr != NULL)
51187 + (*curr)->prev = entry;
51188 +
51189 + entry->next = *curr;
51190 + *curr = entry;
51191 +
51192 + return;
51193 +}
51194 +
51195 +static void
51196 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
51197 +{
51198 + unsigned int index =
51199 + rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
51200 + struct acl_role_label **curr;
51201 + struct acl_role_label *tmp, *tmp2;
51202 +
51203 + curr = &acl_role_set.r_hash[index];
51204 +
51205 + /* simple case, slot is empty, just set it to our role */
51206 + if (*curr == NULL) {
51207 + *curr = role;
51208 + } else {
51209 + /* example:
51210 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
51211 + 2 -> 3
51212 + */
51213 + /* first check to see if we can already be reached via this slot */
51214 + tmp = *curr;
51215 + while (tmp && tmp != role)
51216 + tmp = tmp->next;
51217 + if (tmp == role) {
51218 + /* we don't need to add ourselves to this slot's chain */
51219 + return;
51220 + }
51221 + /* we need to add ourselves to this chain, two cases */
51222 + if (role->next == NULL) {
51223 + /* simple case, append the current chain to our role */
51224 + role->next = *curr;
51225 + *curr = role;
51226 + } else {
51227 + /* 1 -> 2 -> 3 -> 4
51228 + 2 -> 3 -> 4
51229 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
51230 + */
51231 + /* trickier case: walk our role's chain until we find
51232 + the role for the start of the current slot's chain */
51233 + tmp = role;
51234 + tmp2 = *curr;
51235 + while (tmp->next && tmp->next != tmp2)
51236 + tmp = tmp->next;
51237 + if (tmp->next == tmp2) {
51238 + /* from example above, we found 3, so just
51239 + replace this slot's chain with ours */
51240 + *curr = role;
51241 + } else {
51242 + /* we didn't find a subset of our role's chain
51243 + in the current slot's chain, so append their
51244 + chain to ours, and set us as the first role in
51245 + the slot's chain
51246 +
51247 + we could fold this case with the case above,
51248 + but making it explicit for clarity
51249 + */
51250 + tmp->next = tmp2;
51251 + *curr = role;
51252 + }
51253 + }
51254 + }
51255 +
51256 + return;
51257 +}
51258 +
51259 +static void
51260 +insert_acl_role_label(struct acl_role_label *role)
51261 +{
51262 + int i;
51263 +
51264 + if (role_list == NULL) {
51265 + role_list = role;
51266 + role->prev = NULL;
51267 + } else {
51268 + role->prev = role_list;
51269 + role_list = role;
51270 + }
51271 +
51272 + /* used for hash chains */
51273 + role->next = NULL;
51274 +
51275 + if (role->roletype & GR_ROLE_DOMAIN) {
51276 + for (i = 0; i < role->domain_child_num; i++)
51277 + __insert_acl_role_label(role, role->domain_children[i]);
51278 + } else
51279 + __insert_acl_role_label(role, role->uidgid);
51280 +}
51281 +
51282 +static int
51283 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
51284 +{
51285 + struct name_entry **curr, *nentry;
51286 + struct inodev_entry *ientry;
51287 + unsigned int len = strlen(name);
51288 + unsigned int key = full_name_hash(name, len);
51289 + unsigned int index = key % name_set.n_size;
51290 +
51291 + curr = &name_set.n_hash[index];
51292 +
51293 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
51294 + curr = &((*curr)->next);
51295 +
51296 + if (*curr != NULL)
51297 + return 1;
51298 +
51299 + nentry = acl_alloc(sizeof (struct name_entry));
51300 + if (nentry == NULL)
51301 + return 0;
51302 + ientry = acl_alloc(sizeof (struct inodev_entry));
51303 + if (ientry == NULL)
51304 + return 0;
51305 + ientry->nentry = nentry;
51306 +
51307 + nentry->key = key;
51308 + nentry->name = name;
51309 + nentry->inode = inode;
51310 + nentry->device = device;
51311 + nentry->len = len;
51312 + nentry->deleted = deleted;
51313 +
51314 + nentry->prev = NULL;
51315 + curr = &name_set.n_hash[index];
51316 + if (*curr != NULL)
51317 + (*curr)->prev = nentry;
51318 + nentry->next = *curr;
51319 + *curr = nentry;
51320 +
51321 + /* insert us into the table searchable by inode/dev */
51322 + insert_inodev_entry(ientry);
51323 +
51324 + return 1;
51325 +}
51326 +
51327 +static void
51328 +insert_acl_obj_label(struct acl_object_label *obj,
51329 + struct acl_subject_label *subj)
51330 +{
51331 + unsigned int index =
51332 + fhash(obj->inode, obj->device, subj->obj_hash_size);
51333 + struct acl_object_label **curr;
51334 +
51335 +
51336 + obj->prev = NULL;
51337 +
51338 + curr = &subj->obj_hash[index];
51339 + if (*curr != NULL)
51340 + (*curr)->prev = obj;
51341 +
51342 + obj->next = *curr;
51343 + *curr = obj;
51344 +
51345 + return;
51346 +}
51347 +
51348 +static void
51349 +insert_acl_subj_label(struct acl_subject_label *obj,
51350 + struct acl_role_label *role)
51351 +{
51352 + unsigned int index = fhash(obj->inode, obj->device, role->subj_hash_size);
51353 + struct acl_subject_label **curr;
51354 +
51355 + obj->prev = NULL;
51356 +
51357 + curr = &role->subj_hash[index];
51358 + if (*curr != NULL)
51359 + (*curr)->prev = obj;
51360 +
51361 + obj->next = *curr;
51362 + *curr = obj;
51363 +
51364 + return;
51365 +}
51366 +
51367 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
51368 +
51369 +static void *
51370 +create_table(__u32 * len, int elementsize)
51371 +{
51372 + unsigned int table_sizes[] = {
51373 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
51374 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
51375 + 4194301, 8388593, 16777213, 33554393, 67108859
51376 + };
51377 + void *newtable = NULL;
51378 + unsigned int pwr = 0;
51379 +
51380 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
51381 + table_sizes[pwr] <= *len)
51382 + pwr++;
51383 +
51384 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
51385 + return newtable;
51386 +
51387 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
51388 + newtable =
51389 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
51390 + else
51391 + newtable = vmalloc(table_sizes[pwr] * elementsize);
51392 +
51393 + *len = table_sizes[pwr];
51394 +
51395 + return newtable;
51396 +}
51397 +
51398 +static int
51399 +init_variables(const struct gr_arg *arg)
51400 +{
51401 + struct task_struct *reaper = &init_task;
51402 + unsigned int stacksize;
51403 +
51404 + subj_map_set.s_size = arg->role_db.num_subjects;
51405 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
51406 + name_set.n_size = arg->role_db.num_objects;
51407 + inodev_set.i_size = arg->role_db.num_objects;
51408 +
51409 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
51410 + !name_set.n_size || !inodev_set.i_size)
51411 + return 1;
51412 +
51413 + if (!gr_init_uidset())
51414 + return 1;
51415 +
51416 + /* set up the stack that holds allocation info */
51417 +
51418 + stacksize = arg->role_db.num_pointers + 5;
51419 +
51420 + if (!acl_alloc_stack_init(stacksize))
51421 + return 1;
51422 +
51423 + /* grab reference for the real root dentry and vfsmount */
51424 + get_fs_root(reaper->fs, &real_root);
51425 +
51426 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
51427 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
51428 +#endif
51429 +
51430 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
51431 + if (fakefs_obj_rw == NULL)
51432 + return 1;
51433 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
51434 +
51435 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
51436 + if (fakefs_obj_rwx == NULL)
51437 + return 1;
51438 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
51439 +
51440 + subj_map_set.s_hash =
51441 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
51442 + acl_role_set.r_hash =
51443 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
51444 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
51445 + inodev_set.i_hash =
51446 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
51447 +
51448 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
51449 + !name_set.n_hash || !inodev_set.i_hash)
51450 + return 1;
51451 +
51452 + memset(subj_map_set.s_hash, 0,
51453 + sizeof(struct subject_map *) * subj_map_set.s_size);
51454 + memset(acl_role_set.r_hash, 0,
51455 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
51456 + memset(name_set.n_hash, 0,
51457 + sizeof (struct name_entry *) * name_set.n_size);
51458 + memset(inodev_set.i_hash, 0,
51459 + sizeof (struct inodev_entry *) * inodev_set.i_size);
51460 +
51461 + return 0;
51462 +}
51463 +
51464 +/* free information not needed after startup
51465 + currently contains user->kernel pointer mappings for subjects
51466 +*/
51467 +
51468 +static void
51469 +free_init_variables(void)
51470 +{
51471 + __u32 i;
51472 +
51473 + if (subj_map_set.s_hash) {
51474 + for (i = 0; i < subj_map_set.s_size; i++) {
51475 + if (subj_map_set.s_hash[i]) {
51476 + kfree(subj_map_set.s_hash[i]);
51477 + subj_map_set.s_hash[i] = NULL;
51478 + }
51479 + }
51480 +
51481 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
51482 + PAGE_SIZE)
51483 + kfree(subj_map_set.s_hash);
51484 + else
51485 + vfree(subj_map_set.s_hash);
51486 + }
51487 +
51488 + return;
51489 +}
51490 +
51491 +static void
51492 +free_variables(void)
51493 +{
51494 + struct acl_subject_label *s;
51495 + struct acl_role_label *r;
51496 + struct task_struct *task, *task2;
51497 + unsigned int x;
51498 +
51499 + gr_clear_learn_entries();
51500 +
51501 + read_lock(&tasklist_lock);
51502 + do_each_thread(task2, task) {
51503 + task->acl_sp_role = 0;
51504 + task->acl_role_id = 0;
51505 + task->acl = NULL;
51506 + task->role = NULL;
51507 + } while_each_thread(task2, task);
51508 + read_unlock(&tasklist_lock);
51509 +
51510 + /* release the reference to the real root dentry and vfsmount */
51511 + path_put(&real_root);
51512 + memset(&real_root, 0, sizeof(real_root));
51513 +
51514 + /* free all object hash tables */
51515 +
51516 + FOR_EACH_ROLE_START(r)
51517 + if (r->subj_hash == NULL)
51518 + goto next_role;
51519 + FOR_EACH_SUBJECT_START(r, s, x)
51520 + if (s->obj_hash == NULL)
51521 + break;
51522 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
51523 + kfree(s->obj_hash);
51524 + else
51525 + vfree(s->obj_hash);
51526 + FOR_EACH_SUBJECT_END(s, x)
51527 + FOR_EACH_NESTED_SUBJECT_START(r, s)
51528 + if (s->obj_hash == NULL)
51529 + break;
51530 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
51531 + kfree(s->obj_hash);
51532 + else
51533 + vfree(s->obj_hash);
51534 + FOR_EACH_NESTED_SUBJECT_END(s)
51535 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
51536 + kfree(r->subj_hash);
51537 + else
51538 + vfree(r->subj_hash);
51539 + r->subj_hash = NULL;
51540 +next_role:
51541 + FOR_EACH_ROLE_END(r)
51542 +
51543 + acl_free_all();
51544 +
51545 + if (acl_role_set.r_hash) {
51546 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
51547 + PAGE_SIZE)
51548 + kfree(acl_role_set.r_hash);
51549 + else
51550 + vfree(acl_role_set.r_hash);
51551 + }
51552 + if (name_set.n_hash) {
51553 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
51554 + PAGE_SIZE)
51555 + kfree(name_set.n_hash);
51556 + else
51557 + vfree(name_set.n_hash);
51558 + }
51559 +
51560 + if (inodev_set.i_hash) {
51561 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
51562 + PAGE_SIZE)
51563 + kfree(inodev_set.i_hash);
51564 + else
51565 + vfree(inodev_set.i_hash);
51566 + }
51567 +
51568 + gr_free_uidset();
51569 +
51570 + memset(&name_set, 0, sizeof (struct name_db));
51571 + memset(&inodev_set, 0, sizeof (struct inodev_db));
51572 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
51573 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
51574 +
51575 + default_role = NULL;
51576 + kernel_role = NULL;
51577 + role_list = NULL;
51578 +
51579 + return;
51580 +}
51581 +
51582 +static __u32
51583 +count_user_objs(struct acl_object_label *userp)
51584 +{
51585 + struct acl_object_label o_tmp;
51586 + __u32 num = 0;
51587 +
51588 + while (userp) {
51589 + if (copy_from_user(&o_tmp, userp,
51590 + sizeof (struct acl_object_label)))
51591 + break;
51592 +
51593 + userp = o_tmp.prev;
51594 + num++;
51595 + }
51596 +
51597 + return num;
51598 +}
51599 +
51600 +static struct acl_subject_label *
51601 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role);
51602 +
51603 +static int
51604 +copy_user_glob(struct acl_object_label *obj)
51605 +{
51606 + struct acl_object_label *g_tmp, **guser;
51607 + unsigned int len;
51608 + char *tmp;
51609 +
51610 + if (obj->globbed == NULL)
51611 + return 0;
51612 +
51613 + guser = &obj->globbed;
51614 + while (*guser) {
51615 + g_tmp = (struct acl_object_label *)
51616 + acl_alloc(sizeof (struct acl_object_label));
51617 + if (g_tmp == NULL)
51618 + return -ENOMEM;
51619 +
51620 + if (copy_from_user(g_tmp, *guser,
51621 + sizeof (struct acl_object_label)))
51622 + return -EFAULT;
51623 +
51624 + len = strnlen_user(g_tmp->filename, PATH_MAX);
51625 +
51626 + if (!len || len >= PATH_MAX)
51627 + return -EINVAL;
51628 +
51629 + if ((tmp = (char *) acl_alloc(len)) == NULL)
51630 + return -ENOMEM;
51631 +
51632 + if (copy_from_user(tmp, g_tmp->filename, len))
51633 + return -EFAULT;
51634 + tmp[len-1] = '\0';
51635 + g_tmp->filename = tmp;
51636 +
51637 + *guser = g_tmp;
51638 + guser = &(g_tmp->next);
51639 + }
51640 +
51641 + return 0;
51642 +}
51643 +
51644 +static int
51645 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
51646 + struct acl_role_label *role)
51647 +{
51648 + struct acl_object_label *o_tmp;
51649 + unsigned int len;
51650 + int ret;
51651 + char *tmp;
51652 +
51653 + while (userp) {
51654 + if ((o_tmp = (struct acl_object_label *)
51655 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
51656 + return -ENOMEM;
51657 +
51658 + if (copy_from_user(o_tmp, userp,
51659 + sizeof (struct acl_object_label)))
51660 + return -EFAULT;
51661 +
51662 + userp = o_tmp->prev;
51663 +
51664 + len = strnlen_user(o_tmp->filename, PATH_MAX);
51665 +
51666 + if (!len || len >= PATH_MAX)
51667 + return -EINVAL;
51668 +
51669 + if ((tmp = (char *) acl_alloc(len)) == NULL)
51670 + return -ENOMEM;
51671 +
51672 + if (copy_from_user(tmp, o_tmp->filename, len))
51673 + return -EFAULT;
51674 + tmp[len-1] = '\0';
51675 + o_tmp->filename = tmp;
51676 +
51677 + insert_acl_obj_label(o_tmp, subj);
51678 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
51679 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
51680 + return -ENOMEM;
51681 +
51682 + ret = copy_user_glob(o_tmp);
51683 + if (ret)
51684 + return ret;
51685 +
51686 + if (o_tmp->nested) {
51687 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role);
51688 + if (IS_ERR(o_tmp->nested))
51689 + return PTR_ERR(o_tmp->nested);
51690 +
51691 + /* insert into nested subject list */
51692 + o_tmp->nested->next = role->hash->first;
51693 + role->hash->first = o_tmp->nested;
51694 + }
51695 + }
51696 +
51697 + return 0;
51698 +}
51699 +
51700 +static __u32
51701 +count_user_subjs(struct acl_subject_label *userp)
51702 +{
51703 + struct acl_subject_label s_tmp;
51704 + __u32 num = 0;
51705 +
51706 + while (userp) {
51707 + if (copy_from_user(&s_tmp, userp,
51708 + sizeof (struct acl_subject_label)))
51709 + break;
51710 +
51711 + userp = s_tmp.prev;
51712 + /* do not count nested subjects against this count, since
51713 + they are not included in the hash table, but are
51714 + attached to objects. We have already counted
51715 + the subjects in userspace for the allocation
51716 + stack
51717 + */
51718 + if (!(s_tmp.mode & GR_NESTED))
51719 + num++;
51720 + }
51721 +
51722 + return num;
51723 +}
51724 +
51725 +static int
51726 +copy_user_allowedips(struct acl_role_label *rolep)
51727 +{
51728 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
51729 +
51730 + ruserip = rolep->allowed_ips;
51731 +
51732 + while (ruserip) {
51733 + rlast = rtmp;
51734 +
51735 + if ((rtmp = (struct role_allowed_ip *)
51736 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
51737 + return -ENOMEM;
51738 +
51739 + if (copy_from_user(rtmp, ruserip,
51740 + sizeof (struct role_allowed_ip)))
51741 + return -EFAULT;
51742 +
51743 + ruserip = rtmp->prev;
51744 +
51745 + if (!rlast) {
51746 + rtmp->prev = NULL;
51747 + rolep->allowed_ips = rtmp;
51748 + } else {
51749 + rlast->next = rtmp;
51750 + rtmp->prev = rlast;
51751 + }
51752 +
51753 + if (!ruserip)
51754 + rtmp->next = NULL;
51755 + }
51756 +
51757 + return 0;
51758 +}
51759 +
51760 +static int
51761 +copy_user_transitions(struct acl_role_label *rolep)
51762 +{
51763 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
51764 +
51765 + unsigned int len;
51766 + char *tmp;
51767 +
51768 + rusertp = rolep->transitions;
51769 +
51770 + while (rusertp) {
51771 + rlast = rtmp;
51772 +
51773 + if ((rtmp = (struct role_transition *)
51774 + acl_alloc(sizeof (struct role_transition))) == NULL)
51775 + return -ENOMEM;
51776 +
51777 + if (copy_from_user(rtmp, rusertp,
51778 + sizeof (struct role_transition)))
51779 + return -EFAULT;
51780 +
51781 + rusertp = rtmp->prev;
51782 +
51783 + len = strnlen_user(rtmp->rolename, GR_SPROLE_LEN);
51784 +
51785 + if (!len || len >= GR_SPROLE_LEN)
51786 + return -EINVAL;
51787 +
51788 + if ((tmp = (char *) acl_alloc(len)) == NULL)
51789 + return -ENOMEM;
51790 +
51791 + if (copy_from_user(tmp, rtmp->rolename, len))
51792 + return -EFAULT;
51793 + tmp[len-1] = '\0';
51794 + rtmp->rolename = tmp;
51795 +
51796 + if (!rlast) {
51797 + rtmp->prev = NULL;
51798 + rolep->transitions = rtmp;
51799 + } else {
51800 + rlast->next = rtmp;
51801 + rtmp->prev = rlast;
51802 + }
51803 +
51804 + if (!rusertp)
51805 + rtmp->next = NULL;
51806 + }
51807 +
51808 + return 0;
51809 +}
51810 +
51811 +static struct acl_subject_label *
51812 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role)
51813 +{
51814 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
51815 + unsigned int len;
51816 + char *tmp;
51817 + __u32 num_objs;
51818 + struct acl_ip_label **i_tmp, *i_utmp2;
51819 + struct gr_hash_struct ghash;
51820 + struct subject_map *subjmap;
51821 + unsigned int i_num;
51822 + int err;
51823 +
51824 + s_tmp = lookup_subject_map(userp);
51825 +
51826 + /* we've already copied this subject into the kernel, just return
51827 + the reference to it, and don't copy it over again
51828 + */
51829 + if (s_tmp)
51830 + return(s_tmp);
51831 +
51832 + if ((s_tmp = (struct acl_subject_label *)
51833 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
51834 + return ERR_PTR(-ENOMEM);
51835 +
51836 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
51837 + if (subjmap == NULL)
51838 + return ERR_PTR(-ENOMEM);
51839 +
51840 + subjmap->user = userp;
51841 + subjmap->kernel = s_tmp;
51842 + insert_subj_map_entry(subjmap);
51843 +
51844 + if (copy_from_user(s_tmp, userp,
51845 + sizeof (struct acl_subject_label)))
51846 + return ERR_PTR(-EFAULT);
51847 +
51848 + len = strnlen_user(s_tmp->filename, PATH_MAX);
51849 +
51850 + if (!len || len >= PATH_MAX)
51851 + return ERR_PTR(-EINVAL);
51852 +
51853 + if ((tmp = (char *) acl_alloc(len)) == NULL)
51854 + return ERR_PTR(-ENOMEM);
51855 +
51856 + if (copy_from_user(tmp, s_tmp->filename, len))
51857 + return ERR_PTR(-EFAULT);
51858 + tmp[len-1] = '\0';
51859 + s_tmp->filename = tmp;
51860 +
51861 + if (!strcmp(s_tmp->filename, "/"))
51862 + role->root_label = s_tmp;
51863 +
51864 + if (copy_from_user(&ghash, s_tmp->hash, sizeof(struct gr_hash_struct)))
51865 + return ERR_PTR(-EFAULT);
51866 +
51867 + /* copy user and group transition tables */
51868 +
51869 + if (s_tmp->user_trans_num) {
51870 + uid_t *uidlist;
51871 +
51872 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
51873 + if (uidlist == NULL)
51874 + return ERR_PTR(-ENOMEM);
51875 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
51876 + return ERR_PTR(-EFAULT);
51877 +
51878 + s_tmp->user_transitions = uidlist;
51879 + }
51880 +
51881 + if (s_tmp->group_trans_num) {
51882 + gid_t *gidlist;
51883 +
51884 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
51885 + if (gidlist == NULL)
51886 + return ERR_PTR(-ENOMEM);
51887 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
51888 + return ERR_PTR(-EFAULT);
51889 +
51890 + s_tmp->group_transitions = gidlist;
51891 + }
51892 +
51893 + /* set up object hash table */
51894 + num_objs = count_user_objs(ghash.first);
51895 +
51896 + s_tmp->obj_hash_size = num_objs;
51897 + s_tmp->obj_hash =
51898 + (struct acl_object_label **)
51899 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
51900 +
51901 + if (!s_tmp->obj_hash)
51902 + return ERR_PTR(-ENOMEM);
51903 +
51904 + memset(s_tmp->obj_hash, 0,
51905 + s_tmp->obj_hash_size *
51906 + sizeof (struct acl_object_label *));
51907 +
51908 + /* add in objects */
51909 + err = copy_user_objs(ghash.first, s_tmp, role);
51910 +
51911 + if (err)
51912 + return ERR_PTR(err);
51913 +
51914 + /* set pointer for parent subject */
51915 + if (s_tmp->parent_subject) {
51916 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role);
51917 +
51918 + if (IS_ERR(s_tmp2))
51919 + return s_tmp2;
51920 +
51921 + s_tmp->parent_subject = s_tmp2;
51922 + }
51923 +
51924 + /* add in ip acls */
51925 +
51926 + if (!s_tmp->ip_num) {
51927 + s_tmp->ips = NULL;
51928 + goto insert;
51929 + }
51930 +
51931 + i_tmp =
51932 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
51933 + sizeof (struct acl_ip_label *));
51934 +
51935 + if (!i_tmp)
51936 + return ERR_PTR(-ENOMEM);
51937 +
51938 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
51939 + *(i_tmp + i_num) =
51940 + (struct acl_ip_label *)
51941 + acl_alloc(sizeof (struct acl_ip_label));
51942 + if (!*(i_tmp + i_num))
51943 + return ERR_PTR(-ENOMEM);
51944 +
51945 + if (copy_from_user
51946 + (&i_utmp2, s_tmp->ips + i_num,
51947 + sizeof (struct acl_ip_label *)))
51948 + return ERR_PTR(-EFAULT);
51949 +
51950 + if (copy_from_user
51951 + (*(i_tmp + i_num), i_utmp2,
51952 + sizeof (struct acl_ip_label)))
51953 + return ERR_PTR(-EFAULT);
51954 +
51955 + if ((*(i_tmp + i_num))->iface == NULL)
51956 + continue;
51957 +
51958 + len = strnlen_user((*(i_tmp + i_num))->iface, IFNAMSIZ);
51959 + if (!len || len >= IFNAMSIZ)
51960 + return ERR_PTR(-EINVAL);
51961 + tmp = acl_alloc(len);
51962 + if (tmp == NULL)
51963 + return ERR_PTR(-ENOMEM);
51964 + if (copy_from_user(tmp, (*(i_tmp + i_num))->iface, len))
51965 + return ERR_PTR(-EFAULT);
51966 + (*(i_tmp + i_num))->iface = tmp;
51967 + }
51968 +
51969 + s_tmp->ips = i_tmp;
51970 +
51971 +insert:
51972 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
51973 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
51974 + return ERR_PTR(-ENOMEM);
51975 +
51976 + return s_tmp;
51977 +}
51978 +
51979 +static int
51980 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
51981 +{
51982 + struct acl_subject_label s_pre;
51983 + struct acl_subject_label * ret;
51984 + int err;
51985 +
51986 + while (userp) {
51987 + if (copy_from_user(&s_pre, userp,
51988 + sizeof (struct acl_subject_label)))
51989 + return -EFAULT;
51990 +
51991 + /* do not add nested subjects here, add
51992 + while parsing objects
51993 + */
51994 +
51995 + if (s_pre.mode & GR_NESTED) {
51996 + userp = s_pre.prev;
51997 + continue;
51998 + }
51999 +
52000 + ret = do_copy_user_subj(userp, role);
52001 +
52002 + err = PTR_ERR(ret);
52003 + if (IS_ERR(ret))
52004 + return err;
52005 +
52006 + insert_acl_subj_label(ret, role);
52007 +
52008 + userp = s_pre.prev;
52009 + }
52010 +
52011 + return 0;
52012 +}
52013 +
52014 +static int
52015 +copy_user_acl(struct gr_arg *arg)
52016 +{
52017 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
52018 + struct sprole_pw *sptmp;
52019 + struct gr_hash_struct *ghash;
52020 + uid_t *domainlist;
52021 + unsigned int r_num;
52022 + unsigned int len;
52023 + char *tmp;
52024 + int err = 0;
52025 + __u16 i;
52026 + __u32 num_subjs;
52027 +
52028 + /* we need a default and kernel role */
52029 + if (arg->role_db.num_roles < 2)
52030 + return -EINVAL;
52031 +
52032 + /* copy special role authentication info from userspace */
52033 +
52034 + num_sprole_pws = arg->num_sprole_pws;
52035 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
52036 +
52037 + if (!acl_special_roles && num_sprole_pws)
52038 + return -ENOMEM;
52039 +
52040 + for (i = 0; i < num_sprole_pws; i++) {
52041 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
52042 + if (!sptmp)
52043 + return -ENOMEM;
52044 + if (copy_from_user(sptmp, arg->sprole_pws + i,
52045 + sizeof (struct sprole_pw)))
52046 + return -EFAULT;
52047 +
52048 + len = strnlen_user(sptmp->rolename, GR_SPROLE_LEN);
52049 +
52050 + if (!len || len >= GR_SPROLE_LEN)
52051 + return -EINVAL;
52052 +
52053 + if ((tmp = (char *) acl_alloc(len)) == NULL)
52054 + return -ENOMEM;
52055 +
52056 + if (copy_from_user(tmp, sptmp->rolename, len))
52057 + return -EFAULT;
52058 +
52059 + tmp[len-1] = '\0';
52060 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
52061 + printk(KERN_ALERT "Copying special role %s\n", tmp);
52062 +#endif
52063 + sptmp->rolename = tmp;
52064 + acl_special_roles[i] = sptmp;
52065 + }
52066 +
52067 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
52068 +
52069 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
52070 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
52071 +
52072 + if (!r_tmp)
52073 + return -ENOMEM;
52074 +
52075 + if (copy_from_user(&r_utmp2, r_utmp + r_num,
52076 + sizeof (struct acl_role_label *)))
52077 + return -EFAULT;
52078 +
52079 + if (copy_from_user(r_tmp, r_utmp2,
52080 + sizeof (struct acl_role_label)))
52081 + return -EFAULT;
52082 +
52083 + len = strnlen_user(r_tmp->rolename, GR_SPROLE_LEN);
52084 +
52085 + if (!len || len >= PATH_MAX)
52086 + return -EINVAL;
52087 +
52088 + if ((tmp = (char *) acl_alloc(len)) == NULL)
52089 + return -ENOMEM;
52090 +
52091 + if (copy_from_user(tmp, r_tmp->rolename, len))
52092 + return -EFAULT;
52093 +
52094 + tmp[len-1] = '\0';
52095 + r_tmp->rolename = tmp;
52096 +
52097 + if (!strcmp(r_tmp->rolename, "default")
52098 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
52099 + default_role = r_tmp;
52100 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
52101 + kernel_role = r_tmp;
52102 + }
52103 +
52104 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
52105 + return -ENOMEM;
52106 +
52107 + if (copy_from_user(ghash, r_tmp->hash, sizeof(struct gr_hash_struct)))
52108 + return -EFAULT;
52109 +
52110 + r_tmp->hash = ghash;
52111 +
52112 + num_subjs = count_user_subjs(r_tmp->hash->first);
52113 +
52114 + r_tmp->subj_hash_size = num_subjs;
52115 + r_tmp->subj_hash =
52116 + (struct acl_subject_label **)
52117 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
52118 +
52119 + if (!r_tmp->subj_hash)
52120 + return -ENOMEM;
52121 +
52122 + err = copy_user_allowedips(r_tmp);
52123 + if (err)
52124 + return err;
52125 +
52126 + /* copy domain info */
52127 + if (r_tmp->domain_children != NULL) {
52128 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
52129 + if (domainlist == NULL)
52130 + return -ENOMEM;
52131 +
52132 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
52133 + return -EFAULT;
52134 +
52135 + r_tmp->domain_children = domainlist;
52136 + }
52137 +
52138 + err = copy_user_transitions(r_tmp);
52139 + if (err)
52140 + return err;
52141 +
52142 + memset(r_tmp->subj_hash, 0,
52143 + r_tmp->subj_hash_size *
52144 + sizeof (struct acl_subject_label *));
52145 +
52146 + err = copy_user_subjs(r_tmp->hash->first, r_tmp);
52147 +
52148 + if (err)
52149 + return err;
52150 +
52151 + /* set nested subject list to null */
52152 + r_tmp->hash->first = NULL;
52153 +
52154 + insert_acl_role_label(r_tmp);
52155 + }
52156 +
52157 + if (default_role == NULL || kernel_role == NULL)
52158 + return -EINVAL;
52159 +
52160 + return err;
52161 +}
52162 +
52163 +static int
52164 +gracl_init(struct gr_arg *args)
52165 +{
52166 + int error = 0;
52167 +
52168 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
52169 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
52170 +
52171 + if (init_variables(args)) {
52172 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
52173 + error = -ENOMEM;
52174 + free_variables();
52175 + goto out;
52176 + }
52177 +
52178 + error = copy_user_acl(args);
52179 + free_init_variables();
52180 + if (error) {
52181 + free_variables();
52182 + goto out;
52183 + }
52184 +
52185 + if ((error = gr_set_acls(0))) {
52186 + free_variables();
52187 + goto out;
52188 + }
52189 +
52190 + pax_open_kernel();
52191 + gr_status |= GR_READY;
52192 + pax_close_kernel();
52193 +
52194 + out:
52195 + return error;
52196 +}
52197 +
52198 +/* derived from glibc fnmatch() 0: match, 1: no match*/
52199 +
52200 +static int
52201 +glob_match(const char *p, const char *n)
52202 +{
52203 + char c;
52204 +
52205 + while ((c = *p++) != '\0') {
52206 + switch (c) {
52207 + case '?':
52208 + if (*n == '\0')
52209 + return 1;
52210 + else if (*n == '/')
52211 + return 1;
52212 + break;
52213 + case '\\':
52214 + if (*n != c)
52215 + return 1;
52216 + break;
52217 + case '*':
52218 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
52219 + if (*n == '/')
52220 + return 1;
52221 + else if (c == '?') {
52222 + if (*n == '\0')
52223 + return 1;
52224 + else
52225 + ++n;
52226 + }
52227 + }
52228 + if (c == '\0') {
52229 + return 0;
52230 + } else {
52231 + const char *endp;
52232 +
52233 + if ((endp = strchr(n, '/')) == NULL)
52234 + endp = n + strlen(n);
52235 +
52236 + if (c == '[') {
52237 + for (--p; n < endp; ++n)
52238 + if (!glob_match(p, n))
52239 + return 0;
52240 + } else if (c == '/') {
52241 + while (*n != '\0' && *n != '/')
52242 + ++n;
52243 + if (*n == '/' && !glob_match(p, n + 1))
52244 + return 0;
52245 + } else {
52246 + for (--p; n < endp; ++n)
52247 + if (*n == c && !glob_match(p, n))
52248 + return 0;
52249 + }
52250 +
52251 + return 1;
52252 + }
52253 + case '[':
52254 + {
52255 + int not;
52256 + char cold;
52257 +
52258 + if (*n == '\0' || *n == '/')
52259 + return 1;
52260 +
52261 + not = (*p == '!' || *p == '^');
52262 + if (not)
52263 + ++p;
52264 +
52265 + c = *p++;
52266 + for (;;) {
52267 + unsigned char fn = (unsigned char)*n;
52268 +
52269 + if (c == '\0')
52270 + return 1;
52271 + else {
52272 + if (c == fn)
52273 + goto matched;
52274 + cold = c;
52275 + c = *p++;
52276 +
52277 + if (c == '-' && *p != ']') {
52278 + unsigned char cend = *p++;
52279 +
52280 + if (cend == '\0')
52281 + return 1;
52282 +
52283 + if (cold <= fn && fn <= cend)
52284 + goto matched;
52285 +
52286 + c = *p++;
52287 + }
52288 + }
52289 +
52290 + if (c == ']')
52291 + break;
52292 + }
52293 + if (!not)
52294 + return 1;
52295 + break;
52296 + matched:
52297 + while (c != ']') {
52298 + if (c == '\0')
52299 + return 1;
52300 +
52301 + c = *p++;
52302 + }
52303 + if (not)
52304 + return 1;
52305 + }
52306 + break;
52307 + default:
52308 + if (c != *n)
52309 + return 1;
52310 + }
52311 +
52312 + ++n;
52313 + }
52314 +
52315 + if (*n == '\0')
52316 + return 0;
52317 +
52318 + if (*n == '/')
52319 + return 0;
52320 +
52321 + return 1;
52322 +}
52323 +
52324 +static struct acl_object_label *
52325 +chk_glob_label(struct acl_object_label *globbed,
52326 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
52327 +{
52328 + struct acl_object_label *tmp;
52329 +
52330 + if (*path == NULL)
52331 + *path = gr_to_filename_nolock(dentry, mnt);
52332 +
52333 + tmp = globbed;
52334 +
52335 + while (tmp) {
52336 + if (!glob_match(tmp->filename, *path))
52337 + return tmp;
52338 + tmp = tmp->next;
52339 + }
52340 +
52341 + return NULL;
52342 +}
52343 +
52344 +static struct acl_object_label *
52345 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
52346 + const ino_t curr_ino, const dev_t curr_dev,
52347 + const struct acl_subject_label *subj, char **path, const int checkglob)
52348 +{
52349 + struct acl_subject_label *tmpsubj;
52350 + struct acl_object_label *retval;
52351 + struct acl_object_label *retval2;
52352 +
52353 + tmpsubj = (struct acl_subject_label *) subj;
52354 + read_lock(&gr_inode_lock);
52355 + do {
52356 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
52357 + if (retval) {
52358 + if (checkglob && retval->globbed) {
52359 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
52360 + if (retval2)
52361 + retval = retval2;
52362 + }
52363 + break;
52364 + }
52365 + } while ((tmpsubj = tmpsubj->parent_subject));
52366 + read_unlock(&gr_inode_lock);
52367 +
52368 + return retval;
52369 +}
52370 +
52371 +static __inline__ struct acl_object_label *
52372 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
52373 + struct dentry *curr_dentry,
52374 + const struct acl_subject_label *subj, char **path, const int checkglob)
52375 +{
52376 + int newglob = checkglob;
52377 + ino_t inode;
52378 + dev_t device;
52379 +
52380 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
52381 + as we don't want a / * rule to match instead of the / object
52382 + don't do this for create lookups that call this function though, since they're looking up
52383 + on the parent and thus need globbing checks on all paths
52384 + */
52385 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
52386 + newglob = GR_NO_GLOB;
52387 +
52388 + spin_lock(&curr_dentry->d_lock);
52389 + inode = curr_dentry->d_inode->i_ino;
52390 + device = __get_dev(curr_dentry);
52391 + spin_unlock(&curr_dentry->d_lock);
52392 +
52393 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
52394 +}
52395 +
52396 +static struct acl_object_label *
52397 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
52398 + const struct acl_subject_label *subj, char *path, const int checkglob)
52399 +{
52400 + struct dentry *dentry = (struct dentry *) l_dentry;
52401 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
52402 + struct mount *real_mnt = real_mount(mnt);
52403 + struct acl_object_label *retval;
52404 + struct dentry *parent;
52405 +
52406 + write_seqlock(&rename_lock);
52407 + br_read_lock(vfsmount_lock);
52408 +
52409 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
52410 +#ifdef CONFIG_NET
52411 + mnt == sock_mnt ||
52412 +#endif
52413 +#ifdef CONFIG_HUGETLBFS
52414 + (mnt == hugetlbfs_vfsmount && dentry->d_inode->i_nlink == 0) ||
52415 +#endif
52416 + /* ignore Eric Biederman */
52417 + IS_PRIVATE(l_dentry->d_inode))) {
52418 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
52419 + goto out;
52420 + }
52421 +
52422 + for (;;) {
52423 + if (dentry == real_root.dentry && mnt == real_root.mnt)
52424 + break;
52425 +
52426 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
52427 + if (!mnt_has_parent(real_mnt))
52428 + break;
52429 +
52430 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
52431 + if (retval != NULL)
52432 + goto out;
52433 +
52434 + dentry = real_mnt->mnt_mountpoint;
52435 + real_mnt = real_mnt->mnt_parent;
52436 + mnt = &real_mnt->mnt;
52437 + continue;
52438 + }
52439 +
52440 + parent = dentry->d_parent;
52441 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
52442 + if (retval != NULL)
52443 + goto out;
52444 +
52445 + dentry = parent;
52446 + }
52447 +
52448 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
52449 +
52450 + /* real_root is pinned so we don't have to hold a reference */
52451 + if (retval == NULL)
52452 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
52453 +out:
52454 + br_read_unlock(vfsmount_lock);
52455 + write_sequnlock(&rename_lock);
52456 +
52457 + BUG_ON(retval == NULL);
52458 +
52459 + return retval;
52460 +}
52461 +
52462 +static __inline__ struct acl_object_label *
52463 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
52464 + const struct acl_subject_label *subj)
52465 +{
52466 + char *path = NULL;
52467 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
52468 +}
52469 +
52470 +static __inline__ struct acl_object_label *
52471 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
52472 + const struct acl_subject_label *subj)
52473 +{
52474 + char *path = NULL;
52475 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
52476 +}
52477 +
52478 +static __inline__ struct acl_object_label *
52479 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
52480 + const struct acl_subject_label *subj, char *path)
52481 +{
52482 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
52483 +}
52484 +
52485 +static struct acl_subject_label *
52486 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
52487 + const struct acl_role_label *role)
52488 +{
52489 + struct dentry *dentry = (struct dentry *) l_dentry;
52490 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
52491 + struct mount *real_mnt = real_mount(mnt);
52492 + struct acl_subject_label *retval;
52493 + struct dentry *parent;
52494 +
52495 + write_seqlock(&rename_lock);
52496 + br_read_lock(vfsmount_lock);
52497 +
52498 + for (;;) {
52499 + if (dentry == real_root.dentry && mnt == real_root.mnt)
52500 + break;
52501 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
52502 + if (!mnt_has_parent(real_mnt))
52503 + break;
52504 +
52505 + spin_lock(&dentry->d_lock);
52506 + read_lock(&gr_inode_lock);
52507 + retval =
52508 + lookup_acl_subj_label(dentry->d_inode->i_ino,
52509 + __get_dev(dentry), role);
52510 + read_unlock(&gr_inode_lock);
52511 + spin_unlock(&dentry->d_lock);
52512 + if (retval != NULL)
52513 + goto out;
52514 +
52515 + dentry = real_mnt->mnt_mountpoint;
52516 + real_mnt = real_mnt->mnt_parent;
52517 + mnt = &real_mnt->mnt;
52518 + continue;
52519 + }
52520 +
52521 + spin_lock(&dentry->d_lock);
52522 + read_lock(&gr_inode_lock);
52523 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
52524 + __get_dev(dentry), role);
52525 + read_unlock(&gr_inode_lock);
52526 + parent = dentry->d_parent;
52527 + spin_unlock(&dentry->d_lock);
52528 +
52529 + if (retval != NULL)
52530 + goto out;
52531 +
52532 + dentry = parent;
52533 + }
52534 +
52535 + spin_lock(&dentry->d_lock);
52536 + read_lock(&gr_inode_lock);
52537 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
52538 + __get_dev(dentry), role);
52539 + read_unlock(&gr_inode_lock);
52540 + spin_unlock(&dentry->d_lock);
52541 +
52542 + if (unlikely(retval == NULL)) {
52543 + /* real_root is pinned, we don't need to hold a reference */
52544 + read_lock(&gr_inode_lock);
52545 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
52546 + __get_dev(real_root.dentry), role);
52547 + read_unlock(&gr_inode_lock);
52548 + }
52549 +out:
52550 + br_read_unlock(vfsmount_lock);
52551 + write_sequnlock(&rename_lock);
52552 +
52553 + BUG_ON(retval == NULL);
52554 +
52555 + return retval;
52556 +}
52557 +
52558 +static void
52559 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
52560 +{
52561 + struct task_struct *task = current;
52562 + const struct cred *cred = current_cred();
52563 +
52564 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
52565 + cred->uid, cred->gid, task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
52566 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
52567 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
52568 +
52569 + return;
52570 +}
52571 +
52572 +static void
52573 +gr_log_learn_sysctl(const char *path, const __u32 mode)
52574 +{
52575 + struct task_struct *task = current;
52576 + const struct cred *cred = current_cred();
52577 +
52578 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
52579 + cred->uid, cred->gid, task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
52580 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
52581 + 1UL, 1UL, path, (unsigned long) mode, &task->signal->saved_ip);
52582 +
52583 + return;
52584 +}
52585 +
52586 +static void
52587 +gr_log_learn_id_change(const char type, const unsigned int real,
52588 + const unsigned int effective, const unsigned int fs)
52589 +{
52590 + struct task_struct *task = current;
52591 + const struct cred *cred = current_cred();
52592 +
52593 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
52594 + cred->uid, cred->gid, task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
52595 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
52596 + type, real, effective, fs, &task->signal->saved_ip);
52597 +
52598 + return;
52599 +}
52600 +
52601 +__u32
52602 +gr_search_file(const struct dentry * dentry, const __u32 mode,
52603 + const struct vfsmount * mnt)
52604 +{
52605 + __u32 retval = mode;
52606 + struct acl_subject_label *curracl;
52607 + struct acl_object_label *currobj;
52608 +
52609 + if (unlikely(!(gr_status & GR_READY)))
52610 + return (mode & ~GR_AUDITS);
52611 +
52612 + curracl = current->acl;
52613 +
52614 + currobj = chk_obj_label(dentry, mnt, curracl);
52615 + retval = currobj->mode & mode;
52616 +
52617 + /* if we're opening a specified transfer file for writing
52618 + (e.g. /dev/initctl), then transfer our role to init
52619 + */
52620 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
52621 + current->role->roletype & GR_ROLE_PERSIST)) {
52622 + struct task_struct *task = init_pid_ns.child_reaper;
52623 +
52624 + if (task->role != current->role) {
52625 + task->acl_sp_role = 0;
52626 + task->acl_role_id = current->acl_role_id;
52627 + task->role = current->role;
52628 + rcu_read_lock();
52629 + read_lock(&grsec_exec_file_lock);
52630 + gr_apply_subject_to_task(task);
52631 + read_unlock(&grsec_exec_file_lock);
52632 + rcu_read_unlock();
52633 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
52634 + }
52635 + }
52636 +
52637 + if (unlikely
52638 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
52639 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
52640 + __u32 new_mode = mode;
52641 +
52642 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
52643 +
52644 + retval = new_mode;
52645 +
52646 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
52647 + new_mode |= GR_INHERIT;
52648 +
52649 + if (!(mode & GR_NOLEARN))
52650 + gr_log_learn(dentry, mnt, new_mode);
52651 + }
52652 +
52653 + return retval;
52654 +}
52655 +
52656 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
52657 + const struct dentry *parent,
52658 + const struct vfsmount *mnt)
52659 +{
52660 + struct name_entry *match;
52661 + struct acl_object_label *matchpo;
52662 + struct acl_subject_label *curracl;
52663 + char *path;
52664 +
52665 + if (unlikely(!(gr_status & GR_READY)))
52666 + return NULL;
52667 +
52668 + preempt_disable();
52669 + path = gr_to_filename_rbac(new_dentry, mnt);
52670 + match = lookup_name_entry_create(path);
52671 +
52672 + curracl = current->acl;
52673 +
52674 + if (match) {
52675 + read_lock(&gr_inode_lock);
52676 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
52677 + read_unlock(&gr_inode_lock);
52678 +
52679 + if (matchpo) {
52680 + preempt_enable();
52681 + return matchpo;
52682 + }
52683 + }
52684 +
52685 + // lookup parent
52686 +
52687 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
52688 +
52689 + preempt_enable();
52690 + return matchpo;
52691 +}
52692 +
52693 +__u32
52694 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
52695 + const struct vfsmount * mnt, const __u32 mode)
52696 +{
52697 + struct acl_object_label *matchpo;
52698 + __u32 retval;
52699 +
52700 + if (unlikely(!(gr_status & GR_READY)))
52701 + return (mode & ~GR_AUDITS);
52702 +
52703 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
52704 +
52705 + retval = matchpo->mode & mode;
52706 +
52707 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
52708 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
52709 + __u32 new_mode = mode;
52710 +
52711 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
52712 +
52713 + gr_log_learn(new_dentry, mnt, new_mode);
52714 + return new_mode;
52715 + }
52716 +
52717 + return retval;
52718 +}
52719 +
52720 +__u32
52721 +gr_check_link(const struct dentry * new_dentry,
52722 + const struct dentry * parent_dentry,
52723 + const struct vfsmount * parent_mnt,
52724 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
52725 +{
52726 + struct acl_object_label *obj;
52727 + __u32 oldmode, newmode;
52728 + __u32 needmode;
52729 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
52730 + GR_DELETE | GR_INHERIT;
52731 +
52732 + if (unlikely(!(gr_status & GR_READY)))
52733 + return (GR_CREATE | GR_LINK);
52734 +
52735 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
52736 + oldmode = obj->mode;
52737 +
52738 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
52739 + newmode = obj->mode;
52740 +
52741 + needmode = newmode & checkmodes;
52742 +
52743 + // old name for hardlink must have at least the permissions of the new name
52744 + if ((oldmode & needmode) != needmode)
52745 + goto bad;
52746 +
52747 + // if old name had restrictions/auditing, make sure the new name does as well
52748 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
52749 +
52750 + // don't allow hardlinking of suid/sgid files without permission
52751 + if (old_dentry->d_inode->i_mode & (S_ISUID | S_ISGID))
52752 + needmode |= GR_SETID;
52753 +
52754 + if ((newmode & needmode) != needmode)
52755 + goto bad;
52756 +
52757 + // enforce minimum permissions
52758 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
52759 + return newmode;
52760 +bad:
52761 + needmode = oldmode;
52762 + if (old_dentry->d_inode->i_mode & (S_ISUID | S_ISGID))
52763 + needmode |= GR_SETID;
52764 +
52765 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
52766 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
52767 + return (GR_CREATE | GR_LINK);
52768 + } else if (newmode & GR_SUPPRESS)
52769 + return GR_SUPPRESS;
52770 + else
52771 + return 0;
52772 +}
52773 +
52774 +int
52775 +gr_check_hidden_task(const struct task_struct *task)
52776 +{
52777 + if (unlikely(!(gr_status & GR_READY)))
52778 + return 0;
52779 +
52780 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
52781 + return 1;
52782 +
52783 + return 0;
52784 +}
52785 +
52786 +int
52787 +gr_check_protected_task(const struct task_struct *task)
52788 +{
52789 + if (unlikely(!(gr_status & GR_READY) || !task))
52790 + return 0;
52791 +
52792 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
52793 + task->acl != current->acl)
52794 + return 1;
52795 +
52796 + return 0;
52797 +}
52798 +
52799 +int
52800 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
52801 +{
52802 + struct task_struct *p;
52803 + int ret = 0;
52804 +
52805 + if (unlikely(!(gr_status & GR_READY) || !pid))
52806 + return ret;
52807 +
52808 + read_lock(&tasklist_lock);
52809 + do_each_pid_task(pid, type, p) {
52810 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
52811 + p->acl != current->acl) {
52812 + ret = 1;
52813 + goto out;
52814 + }
52815 + } while_each_pid_task(pid, type, p);
52816 +out:
52817 + read_unlock(&tasklist_lock);
52818 +
52819 + return ret;
52820 +}
52821 +
52822 +void
52823 +gr_copy_label(struct task_struct *tsk)
52824 +{
52825 + /* plain copying of fields is already done by dup_task_struct */
52826 + tsk->signal->used_accept = 0;
52827 + tsk->acl_sp_role = 0;
52828 + //tsk->acl_role_id = current->acl_role_id;
52829 + //tsk->acl = current->acl;
52830 + //tsk->role = current->role;
52831 + tsk->signal->curr_ip = current->signal->curr_ip;
52832 + tsk->signal->saved_ip = current->signal->saved_ip;
52833 + if (current->exec_file)
52834 + get_file(current->exec_file);
52835 + //tsk->exec_file = current->exec_file;
52836 + //tsk->is_writable = current->is_writable;
52837 + if (unlikely(current->signal->used_accept)) {
52838 + current->signal->curr_ip = 0;
52839 + current->signal->saved_ip = 0;
52840 + }
52841 +
52842 + return;
52843 +}
52844 +
52845 +static void
52846 +gr_set_proc_res(struct task_struct *task)
52847 +{
52848 + struct acl_subject_label *proc;
52849 + unsigned short i;
52850 +
52851 + proc = task->acl;
52852 +
52853 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
52854 + return;
52855 +
52856 + for (i = 0; i < RLIM_NLIMITS; i++) {
52857 + if (!(proc->resmask & (1 << i)))
52858 + continue;
52859 +
52860 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
52861 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
52862 + }
52863 +
52864 + return;
52865 +}
52866 +
52867 +extern int __gr_process_user_ban(struct user_struct *user);
52868 +
52869 +int
52870 +gr_check_user_change(int real, int effective, int fs)
52871 +{
52872 + unsigned int i;
52873 + __u16 num;
52874 + uid_t *uidlist;
52875 + int curuid;
52876 + int realok = 0;
52877 + int effectiveok = 0;
52878 + int fsok = 0;
52879 +
52880 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
52881 + struct user_struct *user;
52882 +
52883 + if (real == -1)
52884 + goto skipit;
52885 +
52886 + user = find_user(real);
52887 + if (user == NULL)
52888 + goto skipit;
52889 +
52890 + if (__gr_process_user_ban(user)) {
52891 + /* for find_user */
52892 + free_uid(user);
52893 + return 1;
52894 + }
52895 +
52896 + /* for find_user */
52897 + free_uid(user);
52898 +
52899 +skipit:
52900 +#endif
52901 +
52902 + if (unlikely(!(gr_status & GR_READY)))
52903 + return 0;
52904 +
52905 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
52906 + gr_log_learn_id_change('u', real, effective, fs);
52907 +
52908 + num = current->acl->user_trans_num;
52909 + uidlist = current->acl->user_transitions;
52910 +
52911 + if (uidlist == NULL)
52912 + return 0;
52913 +
52914 + if (real == -1)
52915 + realok = 1;
52916 + if (effective == -1)
52917 + effectiveok = 1;
52918 + if (fs == -1)
52919 + fsok = 1;
52920 +
52921 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
52922 + for (i = 0; i < num; i++) {
52923 + curuid = (int)uidlist[i];
52924 + if (real == curuid)
52925 + realok = 1;
52926 + if (effective == curuid)
52927 + effectiveok = 1;
52928 + if (fs == curuid)
52929 + fsok = 1;
52930 + }
52931 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
52932 + for (i = 0; i < num; i++) {
52933 + curuid = (int)uidlist[i];
52934 + if (real == curuid)
52935 + break;
52936 + if (effective == curuid)
52937 + break;
52938 + if (fs == curuid)
52939 + break;
52940 + }
52941 + /* not in deny list */
52942 + if (i == num) {
52943 + realok = 1;
52944 + effectiveok = 1;
52945 + fsok = 1;
52946 + }
52947 + }
52948 +
52949 + if (realok && effectiveok && fsok)
52950 + return 0;
52951 + else {
52952 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : fs) : effective) : real);
52953 + return 1;
52954 + }
52955 +}
52956 +
52957 +int
52958 +gr_check_group_change(int real, int effective, int fs)
52959 +{
52960 + unsigned int i;
52961 + __u16 num;
52962 + gid_t *gidlist;
52963 + int curgid;
52964 + int realok = 0;
52965 + int effectiveok = 0;
52966 + int fsok = 0;
52967 +
52968 + if (unlikely(!(gr_status & GR_READY)))
52969 + return 0;
52970 +
52971 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
52972 + gr_log_learn_id_change('g', real, effective, fs);
52973 +
52974 + num = current->acl->group_trans_num;
52975 + gidlist = current->acl->group_transitions;
52976 +
52977 + if (gidlist == NULL)
52978 + return 0;
52979 +
52980 + if (real == -1)
52981 + realok = 1;
52982 + if (effective == -1)
52983 + effectiveok = 1;
52984 + if (fs == -1)
52985 + fsok = 1;
52986 +
52987 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
52988 + for (i = 0; i < num; i++) {
52989 + curgid = (int)gidlist[i];
52990 + if (real == curgid)
52991 + realok = 1;
52992 + if (effective == curgid)
52993 + effectiveok = 1;
52994 + if (fs == curgid)
52995 + fsok = 1;
52996 + }
52997 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
52998 + for (i = 0; i < num; i++) {
52999 + curgid = (int)gidlist[i];
53000 + if (real == curgid)
53001 + break;
53002 + if (effective == curgid)
53003 + break;
53004 + if (fs == curgid)
53005 + break;
53006 + }
53007 + /* not in deny list */
53008 + if (i == num) {
53009 + realok = 1;
53010 + effectiveok = 1;
53011 + fsok = 1;
53012 + }
53013 + }
53014 +
53015 + if (realok && effectiveok && fsok)
53016 + return 0;
53017 + else {
53018 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : fs) : effective) : real);
53019 + return 1;
53020 + }
53021 +}
53022 +
53023 +extern int gr_acl_is_capable(const int cap);
53024 +
53025 +void
53026 +gr_set_role_label(struct task_struct *task, const uid_t uid, const uid_t gid)
53027 +{
53028 + struct acl_role_label *role = task->role;
53029 + struct acl_subject_label *subj = NULL;
53030 + struct acl_object_label *obj;
53031 + struct file *filp;
53032 +
53033 + if (unlikely(!(gr_status & GR_READY)))
53034 + return;
53035 +
53036 + filp = task->exec_file;
53037 +
53038 + /* kernel process, we'll give them the kernel role */
53039 + if (unlikely(!filp)) {
53040 + task->role = kernel_role;
53041 + task->acl = kernel_role->root_label;
53042 + return;
53043 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
53044 + role = lookup_acl_role_label(task, uid, gid);
53045 +
53046 + /* don't change the role if we're not a privileged process */
53047 + if (role && task->role != role &&
53048 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
53049 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
53050 + return;
53051 +
53052 + /* perform subject lookup in possibly new role
53053 + we can use this result below in the case where role == task->role
53054 + */
53055 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
53056 +
53057 + /* if we changed uid/gid, but result in the same role
53058 + and are using inheritance, don't lose the inherited subject
53059 + if current subject is other than what normal lookup
53060 + would result in, we arrived via inheritance, don't
53061 + lose subject
53062 + */
53063 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
53064 + (subj == task->acl)))
53065 + task->acl = subj;
53066 +
53067 + task->role = role;
53068 +
53069 + task->is_writable = 0;
53070 +
53071 + /* ignore additional mmap checks for processes that are writable
53072 + by the default ACL */
53073 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
53074 + if (unlikely(obj->mode & GR_WRITE))
53075 + task->is_writable = 1;
53076 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
53077 + if (unlikely(obj->mode & GR_WRITE))
53078 + task->is_writable = 1;
53079 +
53080 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
53081 + printk(KERN_ALERT "Set role label for (%s:%d): role:%s, subject:%s\n", task->comm, task->pid, task->role->rolename, task->acl->filename);
53082 +#endif
53083 +
53084 + gr_set_proc_res(task);
53085 +
53086 + return;
53087 +}
53088 +
53089 +int
53090 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
53091 + const int unsafe_flags)
53092 +{
53093 + struct task_struct *task = current;
53094 + struct acl_subject_label *newacl;
53095 + struct acl_object_label *obj;
53096 + __u32 retmode;
53097 +
53098 + if (unlikely(!(gr_status & GR_READY)))
53099 + return 0;
53100 +
53101 + newacl = chk_subj_label(dentry, mnt, task->role);
53102 +
53103 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
53104 + did an exec
53105 + */
53106 + rcu_read_lock();
53107 + read_lock(&tasklist_lock);
53108 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
53109 + (task->parent->acl->mode & GR_POVERRIDE))) {
53110 + read_unlock(&tasklist_lock);
53111 + rcu_read_unlock();
53112 + goto skip_check;
53113 + }
53114 + read_unlock(&tasklist_lock);
53115 + rcu_read_unlock();
53116 +
53117 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
53118 + !(task->role->roletype & GR_ROLE_GOD) &&
53119 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
53120 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
53121 + if (unsafe_flags & LSM_UNSAFE_SHARE)
53122 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
53123 + else
53124 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
53125 + return -EACCES;
53126 + }
53127 +
53128 +skip_check:
53129 +
53130 + obj = chk_obj_label(dentry, mnt, task->acl);
53131 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
53132 +
53133 + if (!(task->acl->mode & GR_INHERITLEARN) &&
53134 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
53135 + if (obj->nested)
53136 + task->acl = obj->nested;
53137 + else
53138 + task->acl = newacl;
53139 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
53140 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
53141 +
53142 + task->is_writable = 0;
53143 +
53144 + /* ignore additional mmap checks for processes that are writable
53145 + by the default ACL */
53146 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
53147 + if (unlikely(obj->mode & GR_WRITE))
53148 + task->is_writable = 1;
53149 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
53150 + if (unlikely(obj->mode & GR_WRITE))
53151 + task->is_writable = 1;
53152 +
53153 + gr_set_proc_res(task);
53154 +
53155 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
53156 + printk(KERN_ALERT "Set subject label for (%s:%d): role:%s, subject:%s\n", task->comm, task->pid, task->role->rolename, task->acl->filename);
53157 +#endif
53158 + return 0;
53159 +}
53160 +
53161 +/* always called with valid inodev ptr */
53162 +static void
53163 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
53164 +{
53165 + struct acl_object_label *matchpo;
53166 + struct acl_subject_label *matchps;
53167 + struct acl_subject_label *subj;
53168 + struct acl_role_label *role;
53169 + unsigned int x;
53170 +
53171 + FOR_EACH_ROLE_START(role)
53172 + FOR_EACH_SUBJECT_START(role, subj, x)
53173 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
53174 + matchpo->mode |= GR_DELETED;
53175 + FOR_EACH_SUBJECT_END(subj,x)
53176 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
53177 + if (subj->inode == ino && subj->device == dev)
53178 + subj->mode |= GR_DELETED;
53179 + FOR_EACH_NESTED_SUBJECT_END(subj)
53180 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
53181 + matchps->mode |= GR_DELETED;
53182 + FOR_EACH_ROLE_END(role)
53183 +
53184 + inodev->nentry->deleted = 1;
53185 +
53186 + return;
53187 +}
53188 +
53189 +void
53190 +gr_handle_delete(const ino_t ino, const dev_t dev)
53191 +{
53192 + struct inodev_entry *inodev;
53193 +
53194 + if (unlikely(!(gr_status & GR_READY)))
53195 + return;
53196 +
53197 + write_lock(&gr_inode_lock);
53198 + inodev = lookup_inodev_entry(ino, dev);
53199 + if (inodev != NULL)
53200 + do_handle_delete(inodev, ino, dev);
53201 + write_unlock(&gr_inode_lock);
53202 +
53203 + return;
53204 +}
53205 +
53206 +static void
53207 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
53208 + const ino_t newinode, const dev_t newdevice,
53209 + struct acl_subject_label *subj)
53210 +{
53211 + unsigned int index = fhash(oldinode, olddevice, subj->obj_hash_size);
53212 + struct acl_object_label *match;
53213 +
53214 + match = subj->obj_hash[index];
53215 +
53216 + while (match && (match->inode != oldinode ||
53217 + match->device != olddevice ||
53218 + !(match->mode & GR_DELETED)))
53219 + match = match->next;
53220 +
53221 + if (match && (match->inode == oldinode)
53222 + && (match->device == olddevice)
53223 + && (match->mode & GR_DELETED)) {
53224 + if (match->prev == NULL) {
53225 + subj->obj_hash[index] = match->next;
53226 + if (match->next != NULL)
53227 + match->next->prev = NULL;
53228 + } else {
53229 + match->prev->next = match->next;
53230 + if (match->next != NULL)
53231 + match->next->prev = match->prev;
53232 + }
53233 + match->prev = NULL;
53234 + match->next = NULL;
53235 + match->inode = newinode;
53236 + match->device = newdevice;
53237 + match->mode &= ~GR_DELETED;
53238 +
53239 + insert_acl_obj_label(match, subj);
53240 + }
53241 +
53242 + return;
53243 +}
53244 +
53245 +static void
53246 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
53247 + const ino_t newinode, const dev_t newdevice,
53248 + struct acl_role_label *role)
53249 +{
53250 + unsigned int index = fhash(oldinode, olddevice, role->subj_hash_size);
53251 + struct acl_subject_label *match;
53252 +
53253 + match = role->subj_hash[index];
53254 +
53255 + while (match && (match->inode != oldinode ||
53256 + match->device != olddevice ||
53257 + !(match->mode & GR_DELETED)))
53258 + match = match->next;
53259 +
53260 + if (match && (match->inode == oldinode)
53261 + && (match->device == olddevice)
53262 + && (match->mode & GR_DELETED)) {
53263 + if (match->prev == NULL) {
53264 + role->subj_hash[index] = match->next;
53265 + if (match->next != NULL)
53266 + match->next->prev = NULL;
53267 + } else {
53268 + match->prev->next = match->next;
53269 + if (match->next != NULL)
53270 + match->next->prev = match->prev;
53271 + }
53272 + match->prev = NULL;
53273 + match->next = NULL;
53274 + match->inode = newinode;
53275 + match->device = newdevice;
53276 + match->mode &= ~GR_DELETED;
53277 +
53278 + insert_acl_subj_label(match, role);
53279 + }
53280 +
53281 + return;
53282 +}
53283 +
53284 +static void
53285 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
53286 + const ino_t newinode, const dev_t newdevice)
53287 +{
53288 + unsigned int index = fhash(oldinode, olddevice, inodev_set.i_size);
53289 + struct inodev_entry *match;
53290 +
53291 + match = inodev_set.i_hash[index];
53292 +
53293 + while (match && (match->nentry->inode != oldinode ||
53294 + match->nentry->device != olddevice || !match->nentry->deleted))
53295 + match = match->next;
53296 +
53297 + if (match && (match->nentry->inode == oldinode)
53298 + && (match->nentry->device == olddevice) &&
53299 + match->nentry->deleted) {
53300 + if (match->prev == NULL) {
53301 + inodev_set.i_hash[index] = match->next;
53302 + if (match->next != NULL)
53303 + match->next->prev = NULL;
53304 + } else {
53305 + match->prev->next = match->next;
53306 + if (match->next != NULL)
53307 + match->next->prev = match->prev;
53308 + }
53309 + match->prev = NULL;
53310 + match->next = NULL;
53311 + match->nentry->inode = newinode;
53312 + match->nentry->device = newdevice;
53313 + match->nentry->deleted = 0;
53314 +
53315 + insert_inodev_entry(match);
53316 + }
53317 +
53318 + return;
53319 +}
53320 +
53321 +static void
53322 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
53323 +{
53324 + struct acl_subject_label *subj;
53325 + struct acl_role_label *role;
53326 + unsigned int x;
53327 +
53328 + FOR_EACH_ROLE_START(role)
53329 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
53330 +
53331 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
53332 + if ((subj->inode == ino) && (subj->device == dev)) {
53333 + subj->inode = ino;
53334 + subj->device = dev;
53335 + }
53336 + FOR_EACH_NESTED_SUBJECT_END(subj)
53337 + FOR_EACH_SUBJECT_START(role, subj, x)
53338 + update_acl_obj_label(matchn->inode, matchn->device,
53339 + ino, dev, subj);
53340 + FOR_EACH_SUBJECT_END(subj,x)
53341 + FOR_EACH_ROLE_END(role)
53342 +
53343 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
53344 +
53345 + return;
53346 +}
53347 +
53348 +static void
53349 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
53350 + const struct vfsmount *mnt)
53351 +{
53352 + ino_t ino = dentry->d_inode->i_ino;
53353 + dev_t dev = __get_dev(dentry);
53354 +
53355 + __do_handle_create(matchn, ino, dev);
53356 +
53357 + return;
53358 +}
53359 +
53360 +void
53361 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
53362 +{
53363 + struct name_entry *matchn;
53364 +
53365 + if (unlikely(!(gr_status & GR_READY)))
53366 + return;
53367 +
53368 + preempt_disable();
53369 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
53370 +
53371 + if (unlikely((unsigned long)matchn)) {
53372 + write_lock(&gr_inode_lock);
53373 + do_handle_create(matchn, dentry, mnt);
53374 + write_unlock(&gr_inode_lock);
53375 + }
53376 + preempt_enable();
53377 +
53378 + return;
53379 +}
53380 +
53381 +void
53382 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
53383 +{
53384 + struct name_entry *matchn;
53385 +
53386 + if (unlikely(!(gr_status & GR_READY)))
53387 + return;
53388 +
53389 + preempt_disable();
53390 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
53391 +
53392 + if (unlikely((unsigned long)matchn)) {
53393 + write_lock(&gr_inode_lock);
53394 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
53395 + write_unlock(&gr_inode_lock);
53396 + }
53397 + preempt_enable();
53398 +
53399 + return;
53400 +}
53401 +
53402 +void
53403 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
53404 + struct dentry *old_dentry,
53405 + struct dentry *new_dentry,
53406 + struct vfsmount *mnt, const __u8 replace)
53407 +{
53408 + struct name_entry *matchn;
53409 + struct inodev_entry *inodev;
53410 + struct inode *inode = new_dentry->d_inode;
53411 + ino_t old_ino = old_dentry->d_inode->i_ino;
53412 + dev_t old_dev = __get_dev(old_dentry);
53413 +
53414 + /* vfs_rename swaps the name and parent link for old_dentry and
53415 + new_dentry
53416 + at this point, old_dentry has the new name, parent link, and inode
53417 + for the renamed file
53418 + if a file is being replaced by a rename, new_dentry has the inode
53419 + and name for the replaced file
53420 + */
53421 +
53422 + if (unlikely(!(gr_status & GR_READY)))
53423 + return;
53424 +
53425 + preempt_disable();
53426 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
53427 +
53428 + /* we wouldn't have to check d_inode if it weren't for
53429 + NFS silly-renaming
53430 + */
53431 +
53432 + write_lock(&gr_inode_lock);
53433 + if (unlikely(replace && inode)) {
53434 + ino_t new_ino = inode->i_ino;
53435 + dev_t new_dev = __get_dev(new_dentry);
53436 +
53437 + inodev = lookup_inodev_entry(new_ino, new_dev);
53438 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
53439 + do_handle_delete(inodev, new_ino, new_dev);
53440 + }
53441 +
53442 + inodev = lookup_inodev_entry(old_ino, old_dev);
53443 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
53444 + do_handle_delete(inodev, old_ino, old_dev);
53445 +
53446 + if (unlikely((unsigned long)matchn))
53447 + do_handle_create(matchn, old_dentry, mnt);
53448 +
53449 + write_unlock(&gr_inode_lock);
53450 + preempt_enable();
53451 +
53452 + return;
53453 +}
53454 +
53455 +static int
53456 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
53457 + unsigned char **sum)
53458 +{
53459 + struct acl_role_label *r;
53460 + struct role_allowed_ip *ipp;
53461 + struct role_transition *trans;
53462 + unsigned int i;
53463 + int found = 0;
53464 + u32 curr_ip = current->signal->curr_ip;
53465 +
53466 + current->signal->saved_ip = curr_ip;
53467 +
53468 + /* check transition table */
53469 +
53470 + for (trans = current->role->transitions; trans; trans = trans->next) {
53471 + if (!strcmp(rolename, trans->rolename)) {
53472 + found = 1;
53473 + break;
53474 + }
53475 + }
53476 +
53477 + if (!found)
53478 + return 0;
53479 +
53480 + /* handle special roles that do not require authentication
53481 + and check ip */
53482 +
53483 + FOR_EACH_ROLE_START(r)
53484 + if (!strcmp(rolename, r->rolename) &&
53485 + (r->roletype & GR_ROLE_SPECIAL)) {
53486 + found = 0;
53487 + if (r->allowed_ips != NULL) {
53488 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
53489 + if ((ntohl(curr_ip) & ipp->netmask) ==
53490 + (ntohl(ipp->addr) & ipp->netmask))
53491 + found = 1;
53492 + }
53493 + } else
53494 + found = 2;
53495 + if (!found)
53496 + return 0;
53497 +
53498 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
53499 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
53500 + *salt = NULL;
53501 + *sum = NULL;
53502 + return 1;
53503 + }
53504 + }
53505 + FOR_EACH_ROLE_END(r)
53506 +
53507 + for (i = 0; i < num_sprole_pws; i++) {
53508 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
53509 + *salt = acl_special_roles[i]->salt;
53510 + *sum = acl_special_roles[i]->sum;
53511 + return 1;
53512 + }
53513 + }
53514 +
53515 + return 0;
53516 +}
53517 +
53518 +static void
53519 +assign_special_role(char *rolename)
53520 +{
53521 + struct acl_object_label *obj;
53522 + struct acl_role_label *r;
53523 + struct acl_role_label *assigned = NULL;
53524 + struct task_struct *tsk;
53525 + struct file *filp;
53526 +
53527 + FOR_EACH_ROLE_START(r)
53528 + if (!strcmp(rolename, r->rolename) &&
53529 + (r->roletype & GR_ROLE_SPECIAL)) {
53530 + assigned = r;
53531 + break;
53532 + }
53533 + FOR_EACH_ROLE_END(r)
53534 +
53535 + if (!assigned)
53536 + return;
53537 +
53538 + read_lock(&tasklist_lock);
53539 + read_lock(&grsec_exec_file_lock);
53540 +
53541 + tsk = current->real_parent;
53542 + if (tsk == NULL)
53543 + goto out_unlock;
53544 +
53545 + filp = tsk->exec_file;
53546 + if (filp == NULL)
53547 + goto out_unlock;
53548 +
53549 + tsk->is_writable = 0;
53550 +
53551 + tsk->acl_sp_role = 1;
53552 + tsk->acl_role_id = ++acl_sp_role_value;
53553 + tsk->role = assigned;
53554 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
53555 +
53556 + /* ignore additional mmap checks for processes that are writable
53557 + by the default ACL */
53558 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
53559 + if (unlikely(obj->mode & GR_WRITE))
53560 + tsk->is_writable = 1;
53561 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
53562 + if (unlikely(obj->mode & GR_WRITE))
53563 + tsk->is_writable = 1;
53564 +
53565 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
53566 + printk(KERN_ALERT "Assigning special role:%s subject:%s to process (%s:%d)\n", tsk->role->rolename, tsk->acl->filename, tsk->comm, tsk->pid);
53567 +#endif
53568 +
53569 +out_unlock:
53570 + read_unlock(&grsec_exec_file_lock);
53571 + read_unlock(&tasklist_lock);
53572 + return;
53573 +}
53574 +
53575 +int gr_check_secure_terminal(struct task_struct *task)
53576 +{
53577 + struct task_struct *p, *p2, *p3;
53578 + struct files_struct *files;
53579 + struct fdtable *fdt;
53580 + struct file *our_file = NULL, *file;
53581 + int i;
53582 +
53583 + if (task->signal->tty == NULL)
53584 + return 1;
53585 +
53586 + files = get_files_struct(task);
53587 + if (files != NULL) {
53588 + rcu_read_lock();
53589 + fdt = files_fdtable(files);
53590 + for (i=0; i < fdt->max_fds; i++) {
53591 + file = fcheck_files(files, i);
53592 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
53593 + get_file(file);
53594 + our_file = file;
53595 + }
53596 + }
53597 + rcu_read_unlock();
53598 + put_files_struct(files);
53599 + }
53600 +
53601 + if (our_file == NULL)
53602 + return 1;
53603 +
53604 + read_lock(&tasklist_lock);
53605 + do_each_thread(p2, p) {
53606 + files = get_files_struct(p);
53607 + if (files == NULL ||
53608 + (p->signal && p->signal->tty == task->signal->tty)) {
53609 + if (files != NULL)
53610 + put_files_struct(files);
53611 + continue;
53612 + }
53613 + rcu_read_lock();
53614 + fdt = files_fdtable(files);
53615 + for (i=0; i < fdt->max_fds; i++) {
53616 + file = fcheck_files(files, i);
53617 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
53618 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
53619 + p3 = task;
53620 + while (p3->pid > 0) {
53621 + if (p3 == p)
53622 + break;
53623 + p3 = p3->real_parent;
53624 + }
53625 + if (p3 == p)
53626 + break;
53627 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
53628 + gr_handle_alertkill(p);
53629 + rcu_read_unlock();
53630 + put_files_struct(files);
53631 + read_unlock(&tasklist_lock);
53632 + fput(our_file);
53633 + return 0;
53634 + }
53635 + }
53636 + rcu_read_unlock();
53637 + put_files_struct(files);
53638 + } while_each_thread(p2, p);
53639 + read_unlock(&tasklist_lock);
53640 +
53641 + fput(our_file);
53642 + return 1;
53643 +}
53644 +
53645 +ssize_t
53646 +write_grsec_handler(struct file *file, const char * buf, size_t count, loff_t *ppos)
53647 +{
53648 + struct gr_arg_wrapper uwrap;
53649 + unsigned char *sprole_salt = NULL;
53650 + unsigned char *sprole_sum = NULL;
53651 + int error = sizeof (struct gr_arg_wrapper);
53652 + int error2 = 0;
53653 +
53654 + mutex_lock(&gr_dev_mutex);
53655 +
53656 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
53657 + error = -EPERM;
53658 + goto out;
53659 + }
53660 +
53661 + if (count != sizeof (struct gr_arg_wrapper)) {
53662 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)sizeof(struct gr_arg_wrapper));
53663 + error = -EINVAL;
53664 + goto out;
53665 + }
53666 +
53667 +
53668 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
53669 + gr_auth_expires = 0;
53670 + gr_auth_attempts = 0;
53671 + }
53672 +
53673 + if (copy_from_user(&uwrap, buf, sizeof (struct gr_arg_wrapper))) {
53674 + error = -EFAULT;
53675 + goto out;
53676 + }
53677 +
53678 + if ((uwrap.version != GRSECURITY_VERSION) || (uwrap.size != sizeof(struct gr_arg))) {
53679 + error = -EINVAL;
53680 + goto out;
53681 + }
53682 +
53683 + if (copy_from_user(gr_usermode, uwrap.arg, sizeof (struct gr_arg))) {
53684 + error = -EFAULT;
53685 + goto out;
53686 + }
53687 +
53688 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
53689 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
53690 + time_after(gr_auth_expires, get_seconds())) {
53691 + error = -EBUSY;
53692 + goto out;
53693 + }
53694 +
53695 + /* if non-root trying to do anything other than use a special role,
53696 + do not attempt authentication, do not count towards authentication
53697 + locking
53698 + */
53699 +
53700 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
53701 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
53702 + current_uid()) {
53703 + error = -EPERM;
53704 + goto out;
53705 + }
53706 +
53707 + /* ensure pw and special role name are null terminated */
53708 +
53709 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
53710 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
53711 +
53712 + /* Okay.
53713 + * We have our enough of the argument structure..(we have yet
53714 + * to copy_from_user the tables themselves) . Copy the tables
53715 + * only if we need them, i.e. for loading operations. */
53716 +
53717 + switch (gr_usermode->mode) {
53718 + case GR_STATUS:
53719 + if (gr_status & GR_READY) {
53720 + error = 1;
53721 + if (!gr_check_secure_terminal(current))
53722 + error = 3;
53723 + } else
53724 + error = 2;
53725 + goto out;
53726 + case GR_SHUTDOWN:
53727 + if ((gr_status & GR_READY)
53728 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
53729 + pax_open_kernel();
53730 + gr_status &= ~GR_READY;
53731 + pax_close_kernel();
53732 +
53733 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
53734 + free_variables();
53735 + memset(gr_usermode, 0, sizeof (struct gr_arg));
53736 + memset(gr_system_salt, 0, GR_SALT_LEN);
53737 + memset(gr_system_sum, 0, GR_SHA_LEN);
53738 + } else if (gr_status & GR_READY) {
53739 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
53740 + error = -EPERM;
53741 + } else {
53742 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
53743 + error = -EAGAIN;
53744 + }
53745 + break;
53746 + case GR_ENABLE:
53747 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
53748 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
53749 + else {
53750 + if (gr_status & GR_READY)
53751 + error = -EAGAIN;
53752 + else
53753 + error = error2;
53754 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
53755 + }
53756 + break;
53757 + case GR_RELOAD:
53758 + if (!(gr_status & GR_READY)) {
53759 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
53760 + error = -EAGAIN;
53761 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
53762 + preempt_disable();
53763 +
53764 + pax_open_kernel();
53765 + gr_status &= ~GR_READY;
53766 + pax_close_kernel();
53767 +
53768 + free_variables();
53769 + if (!(error2 = gracl_init(gr_usermode))) {
53770 + preempt_enable();
53771 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
53772 + } else {
53773 + preempt_enable();
53774 + error = error2;
53775 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
53776 + }
53777 + } else {
53778 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
53779 + error = -EPERM;
53780 + }
53781 + break;
53782 + case GR_SEGVMOD:
53783 + if (unlikely(!(gr_status & GR_READY))) {
53784 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
53785 + error = -EAGAIN;
53786 + break;
53787 + }
53788 +
53789 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
53790 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
53791 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
53792 + struct acl_subject_label *segvacl;
53793 + segvacl =
53794 + lookup_acl_subj_label(gr_usermode->segv_inode,
53795 + gr_usermode->segv_device,
53796 + current->role);
53797 + if (segvacl) {
53798 + segvacl->crashes = 0;
53799 + segvacl->expires = 0;
53800 + }
53801 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
53802 + gr_remove_uid(gr_usermode->segv_uid);
53803 + }
53804 + } else {
53805 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
53806 + error = -EPERM;
53807 + }
53808 + break;
53809 + case GR_SPROLE:
53810 + case GR_SPROLEPAM:
53811 + if (unlikely(!(gr_status & GR_READY))) {
53812 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
53813 + error = -EAGAIN;
53814 + break;
53815 + }
53816 +
53817 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
53818 + current->role->expires = 0;
53819 + current->role->auth_attempts = 0;
53820 + }
53821 +
53822 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
53823 + time_after(current->role->expires, get_seconds())) {
53824 + error = -EBUSY;
53825 + goto out;
53826 + }
53827 +
53828 + if (lookup_special_role_auth
53829 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
53830 + && ((!sprole_salt && !sprole_sum)
53831 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
53832 + char *p = "";
53833 + assign_special_role(gr_usermode->sp_role);
53834 + read_lock(&tasklist_lock);
53835 + if (current->real_parent)
53836 + p = current->real_parent->role->rolename;
53837 + read_unlock(&tasklist_lock);
53838 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
53839 + p, acl_sp_role_value);
53840 + } else {
53841 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
53842 + error = -EPERM;
53843 + if(!(current->role->auth_attempts++))
53844 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
53845 +
53846 + goto out;
53847 + }
53848 + break;
53849 + case GR_UNSPROLE:
53850 + if (unlikely(!(gr_status & GR_READY))) {
53851 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
53852 + error = -EAGAIN;
53853 + break;
53854 + }
53855 +
53856 + if (current->role->roletype & GR_ROLE_SPECIAL) {
53857 + char *p = "";
53858 + int i = 0;
53859 +
53860 + read_lock(&tasklist_lock);
53861 + if (current->real_parent) {
53862 + p = current->real_parent->role->rolename;
53863 + i = current->real_parent->acl_role_id;
53864 + }
53865 + read_unlock(&tasklist_lock);
53866 +
53867 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
53868 + gr_set_acls(1);
53869 + } else {
53870 + error = -EPERM;
53871 + goto out;
53872 + }
53873 + break;
53874 + default:
53875 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
53876 + error = -EINVAL;
53877 + break;
53878 + }
53879 +
53880 + if (error != -EPERM)
53881 + goto out;
53882 +
53883 + if(!(gr_auth_attempts++))
53884 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
53885 +
53886 + out:
53887 + mutex_unlock(&gr_dev_mutex);
53888 + return error;
53889 +}
53890 +
53891 +/* must be called with
53892 + rcu_read_lock();
53893 + read_lock(&tasklist_lock);
53894 + read_lock(&grsec_exec_file_lock);
53895 +*/
53896 +int gr_apply_subject_to_task(struct task_struct *task)
53897 +{
53898 + struct acl_object_label *obj;
53899 + char *tmpname;
53900 + struct acl_subject_label *tmpsubj;
53901 + struct file *filp;
53902 + struct name_entry *nmatch;
53903 +
53904 + filp = task->exec_file;
53905 + if (filp == NULL)
53906 + return 0;
53907 +
53908 + /* the following is to apply the correct subject
53909 + on binaries running when the RBAC system
53910 + is enabled, when the binaries have been
53911 + replaced or deleted since their execution
53912 + -----
53913 + when the RBAC system starts, the inode/dev
53914 + from exec_file will be one the RBAC system
53915 + is unaware of. It only knows the inode/dev
53916 + of the present file on disk, or the absence
53917 + of it.
53918 + */
53919 + preempt_disable();
53920 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
53921 +
53922 + nmatch = lookup_name_entry(tmpname);
53923 + preempt_enable();
53924 + tmpsubj = NULL;
53925 + if (nmatch) {
53926 + if (nmatch->deleted)
53927 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
53928 + else
53929 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
53930 + if (tmpsubj != NULL)
53931 + task->acl = tmpsubj;
53932 + }
53933 + if (tmpsubj == NULL)
53934 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
53935 + task->role);
53936 + if (task->acl) {
53937 + task->is_writable = 0;
53938 + /* ignore additional mmap checks for processes that are writable
53939 + by the default ACL */
53940 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
53941 + if (unlikely(obj->mode & GR_WRITE))
53942 + task->is_writable = 1;
53943 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
53944 + if (unlikely(obj->mode & GR_WRITE))
53945 + task->is_writable = 1;
53946 +
53947 + gr_set_proc_res(task);
53948 +
53949 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
53950 + printk(KERN_ALERT "gr_set_acls for (%s:%d): role:%s, subject:%s\n", task->comm, task->pid, task->role->rolename, task->acl->filename);
53951 +#endif
53952 + } else {
53953 + return 1;
53954 + }
53955 +
53956 + return 0;
53957 +}
53958 +
53959 +int
53960 +gr_set_acls(const int type)
53961 +{
53962 + struct task_struct *task, *task2;
53963 + struct acl_role_label *role = current->role;
53964 + __u16 acl_role_id = current->acl_role_id;
53965 + const struct cred *cred;
53966 + int ret;
53967 +
53968 + rcu_read_lock();
53969 + read_lock(&tasklist_lock);
53970 + read_lock(&grsec_exec_file_lock);
53971 + do_each_thread(task2, task) {
53972 + /* check to see if we're called from the exit handler,
53973 + if so, only replace ACLs that have inherited the admin
53974 + ACL */
53975 +
53976 + if (type && (task->role != role ||
53977 + task->acl_role_id != acl_role_id))
53978 + continue;
53979 +
53980 + task->acl_role_id = 0;
53981 + task->acl_sp_role = 0;
53982 +
53983 + if (task->exec_file) {
53984 + cred = __task_cred(task);
53985 + task->role = lookup_acl_role_label(task, cred->uid, cred->gid);
53986 + ret = gr_apply_subject_to_task(task);
53987 + if (ret) {
53988 + read_unlock(&grsec_exec_file_lock);
53989 + read_unlock(&tasklist_lock);
53990 + rcu_read_unlock();
53991 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task->pid);
53992 + return ret;
53993 + }
53994 + } else {
53995 + // it's a kernel process
53996 + task->role = kernel_role;
53997 + task->acl = kernel_role->root_label;
53998 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
53999 + task->acl->mode &= ~GR_PROCFIND;
54000 +#endif
54001 + }
54002 + } while_each_thread(task2, task);
54003 + read_unlock(&grsec_exec_file_lock);
54004 + read_unlock(&tasklist_lock);
54005 + rcu_read_unlock();
54006 +
54007 + return 0;
54008 +}
54009 +
54010 +void
54011 +gr_learn_resource(const struct task_struct *task,
54012 + const int res, const unsigned long wanted, const int gt)
54013 +{
54014 + struct acl_subject_label *acl;
54015 + const struct cred *cred;
54016 +
54017 + if (unlikely((gr_status & GR_READY) &&
54018 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
54019 + goto skip_reslog;
54020 +
54021 +#ifdef CONFIG_GRKERNSEC_RESLOG
54022 + gr_log_resource(task, res, wanted, gt);
54023 +#endif
54024 + skip_reslog:
54025 +
54026 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
54027 + return;
54028 +
54029 + acl = task->acl;
54030 +
54031 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
54032 + !(acl->resmask & (1 << (unsigned short) res))))
54033 + return;
54034 +
54035 + if (wanted >= acl->res[res].rlim_cur) {
54036 + unsigned long res_add;
54037 +
54038 + res_add = wanted;
54039 + switch (res) {
54040 + case RLIMIT_CPU:
54041 + res_add += GR_RLIM_CPU_BUMP;
54042 + break;
54043 + case RLIMIT_FSIZE:
54044 + res_add += GR_RLIM_FSIZE_BUMP;
54045 + break;
54046 + case RLIMIT_DATA:
54047 + res_add += GR_RLIM_DATA_BUMP;
54048 + break;
54049 + case RLIMIT_STACK:
54050 + res_add += GR_RLIM_STACK_BUMP;
54051 + break;
54052 + case RLIMIT_CORE:
54053 + res_add += GR_RLIM_CORE_BUMP;
54054 + break;
54055 + case RLIMIT_RSS:
54056 + res_add += GR_RLIM_RSS_BUMP;
54057 + break;
54058 + case RLIMIT_NPROC:
54059 + res_add += GR_RLIM_NPROC_BUMP;
54060 + break;
54061 + case RLIMIT_NOFILE:
54062 + res_add += GR_RLIM_NOFILE_BUMP;
54063 + break;
54064 + case RLIMIT_MEMLOCK:
54065 + res_add += GR_RLIM_MEMLOCK_BUMP;
54066 + break;
54067 + case RLIMIT_AS:
54068 + res_add += GR_RLIM_AS_BUMP;
54069 + break;
54070 + case RLIMIT_LOCKS:
54071 + res_add += GR_RLIM_LOCKS_BUMP;
54072 + break;
54073 + case RLIMIT_SIGPENDING:
54074 + res_add += GR_RLIM_SIGPENDING_BUMP;
54075 + break;
54076 + case RLIMIT_MSGQUEUE:
54077 + res_add += GR_RLIM_MSGQUEUE_BUMP;
54078 + break;
54079 + case RLIMIT_NICE:
54080 + res_add += GR_RLIM_NICE_BUMP;
54081 + break;
54082 + case RLIMIT_RTPRIO:
54083 + res_add += GR_RLIM_RTPRIO_BUMP;
54084 + break;
54085 + case RLIMIT_RTTIME:
54086 + res_add += GR_RLIM_RTTIME_BUMP;
54087 + break;
54088 + }
54089 +
54090 + acl->res[res].rlim_cur = res_add;
54091 +
54092 + if (wanted > acl->res[res].rlim_max)
54093 + acl->res[res].rlim_max = res_add;
54094 +
54095 + /* only log the subject filename, since resource logging is supported for
54096 + single-subject learning only */
54097 + rcu_read_lock();
54098 + cred = __task_cred(task);
54099 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
54100 + task->role->roletype, cred->uid, cred->gid, acl->filename,
54101 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
54102 + "", (unsigned long) res, &task->signal->saved_ip);
54103 + rcu_read_unlock();
54104 + }
54105 +
54106 + return;
54107 +}
54108 +
54109 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
54110 +void
54111 +pax_set_initial_flags(struct linux_binprm *bprm)
54112 +{
54113 + struct task_struct *task = current;
54114 + struct acl_subject_label *proc;
54115 + unsigned long flags;
54116 +
54117 + if (unlikely(!(gr_status & GR_READY)))
54118 + return;
54119 +
54120 + flags = pax_get_flags(task);
54121 +
54122 + proc = task->acl;
54123 +
54124 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
54125 + flags &= ~MF_PAX_PAGEEXEC;
54126 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
54127 + flags &= ~MF_PAX_SEGMEXEC;
54128 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
54129 + flags &= ~MF_PAX_RANDMMAP;
54130 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
54131 + flags &= ~MF_PAX_EMUTRAMP;
54132 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
54133 + flags &= ~MF_PAX_MPROTECT;
54134 +
54135 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
54136 + flags |= MF_PAX_PAGEEXEC;
54137 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
54138 + flags |= MF_PAX_SEGMEXEC;
54139 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
54140 + flags |= MF_PAX_RANDMMAP;
54141 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
54142 + flags |= MF_PAX_EMUTRAMP;
54143 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
54144 + flags |= MF_PAX_MPROTECT;
54145 +
54146 + pax_set_flags(task, flags);
54147 +
54148 + return;
54149 +}
54150 +#endif
54151 +
54152 +#ifdef CONFIG_SYSCTL
54153 +/* Eric Biederman likes breaking userland ABI and every inode-based security
54154 + system to save 35kb of memory */
54155 +
54156 +/* we modify the passed in filename, but adjust it back before returning */
54157 +static struct acl_object_label *gr_lookup_by_name(char *name, unsigned int len)
54158 +{
54159 + struct name_entry *nmatch;
54160 + char *p, *lastp = NULL;
54161 + struct acl_object_label *obj = NULL, *tmp;
54162 + struct acl_subject_label *tmpsubj;
54163 + char c = '\0';
54164 +
54165 + read_lock(&gr_inode_lock);
54166 +
54167 + p = name + len - 1;
54168 + do {
54169 + nmatch = lookup_name_entry(name);
54170 + if (lastp != NULL)
54171 + *lastp = c;
54172 +
54173 + if (nmatch == NULL)
54174 + goto next_component;
54175 + tmpsubj = current->acl;
54176 + do {
54177 + obj = lookup_acl_obj_label(nmatch->inode, nmatch->device, tmpsubj);
54178 + if (obj != NULL) {
54179 + tmp = obj->globbed;
54180 + while (tmp) {
54181 + if (!glob_match(tmp->filename, name)) {
54182 + obj = tmp;
54183 + goto found_obj;
54184 + }
54185 + tmp = tmp->next;
54186 + }
54187 + goto found_obj;
54188 + }
54189 + } while ((tmpsubj = tmpsubj->parent_subject));
54190 +next_component:
54191 + /* end case */
54192 + if (p == name)
54193 + break;
54194 +
54195 + while (*p != '/')
54196 + p--;
54197 + if (p == name)
54198 + lastp = p + 1;
54199 + else {
54200 + lastp = p;
54201 + p--;
54202 + }
54203 + c = *lastp;
54204 + *lastp = '\0';
54205 + } while (1);
54206 +found_obj:
54207 + read_unlock(&gr_inode_lock);
54208 + /* obj returned will always be non-null */
54209 + return obj;
54210 +}
54211 +
54212 +/* returns 0 when allowing, non-zero on error
54213 + op of 0 is used for readdir, so we don't log the names of hidden files
54214 +*/
54215 +__u32
54216 +gr_handle_sysctl(const struct ctl_table *table, const int op)
54217 +{
54218 + struct ctl_table *tmp;
54219 + const char *proc_sys = "/proc/sys";
54220 + char *path;
54221 + struct acl_object_label *obj;
54222 + unsigned short len = 0, pos = 0, depth = 0, i;
54223 + __u32 err = 0;
54224 + __u32 mode = 0;
54225 +
54226 + if (unlikely(!(gr_status & GR_READY)))
54227 + return 0;
54228 +
54229 + /* for now, ignore operations on non-sysctl entries if it's not a
54230 + readdir*/
54231 + if (table->child != NULL && op != 0)
54232 + return 0;
54233 +
54234 + mode |= GR_FIND;
54235 + /* it's only a read if it's an entry, read on dirs is for readdir */
54236 + if (op & MAY_READ)
54237 + mode |= GR_READ;
54238 + if (op & MAY_WRITE)
54239 + mode |= GR_WRITE;
54240 +
54241 + preempt_disable();
54242 +
54243 + path = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
54244 +
54245 + /* it's only a read/write if it's an actual entry, not a dir
54246 + (which are opened for readdir)
54247 + */
54248 +
54249 + /* convert the requested sysctl entry into a pathname */
54250 +
54251 + for (tmp = (struct ctl_table *)table; tmp != NULL; tmp = tmp->parent) {
54252 + len += strlen(tmp->procname);
54253 + len++;
54254 + depth++;
54255 + }
54256 +
54257 + if ((len + depth + strlen(proc_sys) + 1) > PAGE_SIZE) {
54258 + /* deny */
54259 + goto out;
54260 + }
54261 +
54262 + memset(path, 0, PAGE_SIZE);
54263 +
54264 + memcpy(path, proc_sys, strlen(proc_sys));
54265 +
54266 + pos += strlen(proc_sys);
54267 +
54268 + for (; depth > 0; depth--) {
54269 + path[pos] = '/';
54270 + pos++;
54271 + for (i = 1, tmp = (struct ctl_table *)table; tmp != NULL; tmp = tmp->parent) {
54272 + if (depth == i) {
54273 + memcpy(path + pos, tmp->procname,
54274 + strlen(tmp->procname));
54275 + pos += strlen(tmp->procname);
54276 + }
54277 + i++;
54278 + }
54279 + }
54280 +
54281 + obj = gr_lookup_by_name(path, pos);
54282 + err = obj->mode & (mode | to_gr_audit(mode) | GR_SUPPRESS);
54283 +
54284 + if (unlikely((current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) &&
54285 + ((err & mode) != mode))) {
54286 + __u32 new_mode = mode;
54287 +
54288 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
54289 +
54290 + err = 0;
54291 + gr_log_learn_sysctl(path, new_mode);
54292 + } else if (!(err & GR_FIND) && !(err & GR_SUPPRESS) && op != 0) {
54293 + gr_log_hidden_sysctl(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, path);
54294 + err = -ENOENT;
54295 + } else if (!(err & GR_FIND)) {
54296 + err = -ENOENT;
54297 + } else if (((err & mode) & ~GR_FIND) != (mode & ~GR_FIND) && !(err & GR_SUPPRESS)) {
54298 + gr_log_str4(GR_DONT_AUDIT, GR_SYSCTL_ACL_MSG, "denied",
54299 + path, (mode & GR_READ) ? " reading" : "",
54300 + (mode & GR_WRITE) ? " writing" : "");
54301 + err = -EACCES;
54302 + } else if ((err & mode) != mode) {
54303 + err = -EACCES;
54304 + } else if ((((err & mode) & ~GR_FIND) == (mode & ~GR_FIND)) && (err & GR_AUDITS)) {
54305 + gr_log_str4(GR_DO_AUDIT, GR_SYSCTL_ACL_MSG, "successful",
54306 + path, (mode & GR_READ) ? " reading" : "",
54307 + (mode & GR_WRITE) ? " writing" : "");
54308 + err = 0;
54309 + } else
54310 + err = 0;
54311 +
54312 + out:
54313 + preempt_enable();
54314 +
54315 + return err;
54316 +}
54317 +#endif
54318 +
54319 +int
54320 +gr_handle_proc_ptrace(struct task_struct *task)
54321 +{
54322 + struct file *filp;
54323 + struct task_struct *tmp = task;
54324 + struct task_struct *curtemp = current;
54325 + __u32 retmode;
54326 +
54327 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
54328 + if (unlikely(!(gr_status & GR_READY)))
54329 + return 0;
54330 +#endif
54331 +
54332 + read_lock(&tasklist_lock);
54333 + read_lock(&grsec_exec_file_lock);
54334 + filp = task->exec_file;
54335 +
54336 + while (tmp->pid > 0) {
54337 + if (tmp == curtemp)
54338 + break;
54339 + tmp = tmp->real_parent;
54340 + }
54341 +
54342 + if (!filp || (tmp->pid == 0 && ((grsec_enable_harden_ptrace && current_uid() && !(gr_status & GR_READY)) ||
54343 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
54344 + read_unlock(&grsec_exec_file_lock);
54345 + read_unlock(&tasklist_lock);
54346 + return 1;
54347 + }
54348 +
54349 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
54350 + if (!(gr_status & GR_READY)) {
54351 + read_unlock(&grsec_exec_file_lock);
54352 + read_unlock(&tasklist_lock);
54353 + return 0;
54354 + }
54355 +#endif
54356 +
54357 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
54358 + read_unlock(&grsec_exec_file_lock);
54359 + read_unlock(&tasklist_lock);
54360 +
54361 + if (retmode & GR_NOPTRACE)
54362 + return 1;
54363 +
54364 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
54365 + && (current->acl != task->acl || (current->acl != current->role->root_label
54366 + && current->pid != task->pid)))
54367 + return 1;
54368 +
54369 + return 0;
54370 +}
54371 +
54372 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
54373 +{
54374 + if (unlikely(!(gr_status & GR_READY)))
54375 + return;
54376 +
54377 + if (!(current->role->roletype & GR_ROLE_GOD))
54378 + return;
54379 +
54380 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
54381 + p->role->rolename, gr_task_roletype_to_char(p),
54382 + p->acl->filename);
54383 +}
54384 +
54385 +int
54386 +gr_handle_ptrace(struct task_struct *task, const long request)
54387 +{
54388 + struct task_struct *tmp = task;
54389 + struct task_struct *curtemp = current;
54390 + __u32 retmode;
54391 +
54392 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
54393 + if (unlikely(!(gr_status & GR_READY)))
54394 + return 0;
54395 +#endif
54396 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
54397 + read_lock(&tasklist_lock);
54398 + while (tmp->pid > 0) {
54399 + if (tmp == curtemp)
54400 + break;
54401 + tmp = tmp->real_parent;
54402 + }
54403 +
54404 + if (tmp->pid == 0 && ((grsec_enable_harden_ptrace && current_uid() && !(gr_status & GR_READY)) ||
54405 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
54406 + read_unlock(&tasklist_lock);
54407 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
54408 + return 1;
54409 + }
54410 + read_unlock(&tasklist_lock);
54411 + }
54412 +
54413 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
54414 + if (!(gr_status & GR_READY))
54415 + return 0;
54416 +#endif
54417 +
54418 + read_lock(&grsec_exec_file_lock);
54419 + if (unlikely(!task->exec_file)) {
54420 + read_unlock(&grsec_exec_file_lock);
54421 + return 0;
54422 + }
54423 +
54424 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
54425 + read_unlock(&grsec_exec_file_lock);
54426 +
54427 + if (retmode & GR_NOPTRACE) {
54428 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
54429 + return 1;
54430 + }
54431 +
54432 + if (retmode & GR_PTRACERD) {
54433 + switch (request) {
54434 + case PTRACE_SEIZE:
54435 + case PTRACE_POKETEXT:
54436 + case PTRACE_POKEDATA:
54437 + case PTRACE_POKEUSR:
54438 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
54439 + case PTRACE_SETREGS:
54440 + case PTRACE_SETFPREGS:
54441 +#endif
54442 +#ifdef CONFIG_X86
54443 + case PTRACE_SETFPXREGS:
54444 +#endif
54445 +#ifdef CONFIG_ALTIVEC
54446 + case PTRACE_SETVRREGS:
54447 +#endif
54448 + return 1;
54449 + default:
54450 + return 0;
54451 + }
54452 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
54453 + !(current->role->roletype & GR_ROLE_GOD) &&
54454 + (current->acl != task->acl)) {
54455 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
54456 + return 1;
54457 + }
54458 +
54459 + return 0;
54460 +}
54461 +
54462 +static int is_writable_mmap(const struct file *filp)
54463 +{
54464 + struct task_struct *task = current;
54465 + struct acl_object_label *obj, *obj2;
54466 +
54467 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
54468 + !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))) {
54469 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
54470 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
54471 + task->role->root_label);
54472 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
54473 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
54474 + return 1;
54475 + }
54476 + }
54477 + return 0;
54478 +}
54479 +
54480 +int
54481 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
54482 +{
54483 + __u32 mode;
54484 +
54485 + if (unlikely(!file || !(prot & PROT_EXEC)))
54486 + return 1;
54487 +
54488 + if (is_writable_mmap(file))
54489 + return 0;
54490 +
54491 + mode =
54492 + gr_search_file(file->f_path.dentry,
54493 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
54494 + file->f_path.mnt);
54495 +
54496 + if (!gr_tpe_allow(file))
54497 + return 0;
54498 +
54499 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
54500 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
54501 + return 0;
54502 + } else if (unlikely(!(mode & GR_EXEC))) {
54503 + return 0;
54504 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
54505 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
54506 + return 1;
54507 + }
54508 +
54509 + return 1;
54510 +}
54511 +
54512 +int
54513 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
54514 +{
54515 + __u32 mode;
54516 +
54517 + if (unlikely(!file || !(prot & PROT_EXEC)))
54518 + return 1;
54519 +
54520 + if (is_writable_mmap(file))
54521 + return 0;
54522 +
54523 + mode =
54524 + gr_search_file(file->f_path.dentry,
54525 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
54526 + file->f_path.mnt);
54527 +
54528 + if (!gr_tpe_allow(file))
54529 + return 0;
54530 +
54531 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
54532 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
54533 + return 0;
54534 + } else if (unlikely(!(mode & GR_EXEC))) {
54535 + return 0;
54536 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
54537 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
54538 + return 1;
54539 + }
54540 +
54541 + return 1;
54542 +}
54543 +
54544 +void
54545 +gr_acl_handle_psacct(struct task_struct *task, const long code)
54546 +{
54547 + unsigned long runtime;
54548 + unsigned long cputime;
54549 + unsigned int wday, cday;
54550 + __u8 whr, chr;
54551 + __u8 wmin, cmin;
54552 + __u8 wsec, csec;
54553 + struct timespec timeval;
54554 +
54555 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
54556 + !(task->acl->mode & GR_PROCACCT)))
54557 + return;
54558 +
54559 + do_posix_clock_monotonic_gettime(&timeval);
54560 + runtime = timeval.tv_sec - task->start_time.tv_sec;
54561 + wday = runtime / (3600 * 24);
54562 + runtime -= wday * (3600 * 24);
54563 + whr = runtime / 3600;
54564 + runtime -= whr * 3600;
54565 + wmin = runtime / 60;
54566 + runtime -= wmin * 60;
54567 + wsec = runtime;
54568 +
54569 + cputime = (task->utime + task->stime) / HZ;
54570 + cday = cputime / (3600 * 24);
54571 + cputime -= cday * (3600 * 24);
54572 + chr = cputime / 3600;
54573 + cputime -= chr * 3600;
54574 + cmin = cputime / 60;
54575 + cputime -= cmin * 60;
54576 + csec = cputime;
54577 +
54578 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
54579 +
54580 + return;
54581 +}
54582 +
54583 +void gr_set_kernel_label(struct task_struct *task)
54584 +{
54585 + if (gr_status & GR_READY) {
54586 + task->role = kernel_role;
54587 + task->acl = kernel_role->root_label;
54588 + }
54589 + return;
54590 +}
54591 +
54592 +#ifdef CONFIG_TASKSTATS
54593 +int gr_is_taskstats_denied(int pid)
54594 +{
54595 + struct task_struct *task;
54596 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54597 + const struct cred *cred;
54598 +#endif
54599 + int ret = 0;
54600 +
54601 + /* restrict taskstats viewing to un-chrooted root users
54602 + who have the 'view' subject flag if the RBAC system is enabled
54603 + */
54604 +
54605 + rcu_read_lock();
54606 + read_lock(&tasklist_lock);
54607 + task = find_task_by_vpid(pid);
54608 + if (task) {
54609 +#ifdef CONFIG_GRKERNSEC_CHROOT
54610 + if (proc_is_chrooted(task))
54611 + ret = -EACCES;
54612 +#endif
54613 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54614 + cred = __task_cred(task);
54615 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54616 + if (cred->uid != 0)
54617 + ret = -EACCES;
54618 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54619 + if (cred->uid != 0 && !groups_search(cred->group_info, CONFIG_GRKERNSEC_PROC_GID))
54620 + ret = -EACCES;
54621 +#endif
54622 +#endif
54623 + if (gr_status & GR_READY) {
54624 + if (!(task->acl->mode & GR_VIEW))
54625 + ret = -EACCES;
54626 + }
54627 + } else
54628 + ret = -ENOENT;
54629 +
54630 + read_unlock(&tasklist_lock);
54631 + rcu_read_unlock();
54632 +
54633 + return ret;
54634 +}
54635 +#endif
54636 +
54637 +/* AUXV entries are filled via a descendant of search_binary_handler
54638 + after we've already applied the subject for the target
54639 +*/
54640 +int gr_acl_enable_at_secure(void)
54641 +{
54642 + if (unlikely(!(gr_status & GR_READY)))
54643 + return 0;
54644 +
54645 + if (current->acl->mode & GR_ATSECURE)
54646 + return 1;
54647 +
54648 + return 0;
54649 +}
54650 +
54651 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
54652 +{
54653 + struct task_struct *task = current;
54654 + struct dentry *dentry = file->f_path.dentry;
54655 + struct vfsmount *mnt = file->f_path.mnt;
54656 + struct acl_object_label *obj, *tmp;
54657 + struct acl_subject_label *subj;
54658 + unsigned int bufsize;
54659 + int is_not_root;
54660 + char *path;
54661 + dev_t dev = __get_dev(dentry);
54662 +
54663 + if (unlikely(!(gr_status & GR_READY)))
54664 + return 1;
54665 +
54666 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
54667 + return 1;
54668 +
54669 + /* ignore Eric Biederman */
54670 + if (IS_PRIVATE(dentry->d_inode))
54671 + return 1;
54672 +
54673 + subj = task->acl;
54674 + do {
54675 + obj = lookup_acl_obj_label(ino, dev, subj);
54676 + if (obj != NULL)
54677 + return (obj->mode & GR_FIND) ? 1 : 0;
54678 + } while ((subj = subj->parent_subject));
54679 +
54680 + /* this is purely an optimization since we're looking for an object
54681 + for the directory we're doing a readdir on
54682 + if it's possible for any globbed object to match the entry we're
54683 + filling into the directory, then the object we find here will be
54684 + an anchor point with attached globbed objects
54685 + */
54686 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
54687 + if (obj->globbed == NULL)
54688 + return (obj->mode & GR_FIND) ? 1 : 0;
54689 +
54690 + is_not_root = ((obj->filename[0] == '/') &&
54691 + (obj->filename[1] == '\0')) ? 0 : 1;
54692 + bufsize = PAGE_SIZE - namelen - is_not_root;
54693 +
54694 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
54695 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
54696 + return 1;
54697 +
54698 + preempt_disable();
54699 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
54700 + bufsize);
54701 +
54702 + bufsize = strlen(path);
54703 +
54704 + /* if base is "/", don't append an additional slash */
54705 + if (is_not_root)
54706 + *(path + bufsize) = '/';
54707 + memcpy(path + bufsize + is_not_root, name, namelen);
54708 + *(path + bufsize + namelen + is_not_root) = '\0';
54709 +
54710 + tmp = obj->globbed;
54711 + while (tmp) {
54712 + if (!glob_match(tmp->filename, path)) {
54713 + preempt_enable();
54714 + return (tmp->mode & GR_FIND) ? 1 : 0;
54715 + }
54716 + tmp = tmp->next;
54717 + }
54718 + preempt_enable();
54719 + return (obj->mode & GR_FIND) ? 1 : 0;
54720 +}
54721 +
54722 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
54723 +EXPORT_SYMBOL(gr_acl_is_enabled);
54724 +#endif
54725 +EXPORT_SYMBOL(gr_learn_resource);
54726 +EXPORT_SYMBOL(gr_set_kernel_label);
54727 +#ifdef CONFIG_SECURITY
54728 +EXPORT_SYMBOL(gr_check_user_change);
54729 +EXPORT_SYMBOL(gr_check_group_change);
54730 +#endif
54731 +
54732 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
54733 new file mode 100644
54734 index 0000000..34fefda
54735 --- /dev/null
54736 +++ b/grsecurity/gracl_alloc.c
54737 @@ -0,0 +1,105 @@
54738 +#include <linux/kernel.h>
54739 +#include <linux/mm.h>
54740 +#include <linux/slab.h>
54741 +#include <linux/vmalloc.h>
54742 +#include <linux/gracl.h>
54743 +#include <linux/grsecurity.h>
54744 +
54745 +static unsigned long alloc_stack_next = 1;
54746 +static unsigned long alloc_stack_size = 1;
54747 +static void **alloc_stack;
54748 +
54749 +static __inline__ int
54750 +alloc_pop(void)
54751 +{
54752 + if (alloc_stack_next == 1)
54753 + return 0;
54754 +
54755 + kfree(alloc_stack[alloc_stack_next - 2]);
54756 +
54757 + alloc_stack_next--;
54758 +
54759 + return 1;
54760 +}
54761 +
54762 +static __inline__ int
54763 +alloc_push(void *buf)
54764 +{
54765 + if (alloc_stack_next >= alloc_stack_size)
54766 + return 1;
54767 +
54768 + alloc_stack[alloc_stack_next - 1] = buf;
54769 +
54770 + alloc_stack_next++;
54771 +
54772 + return 0;
54773 +}
54774 +
54775 +void *
54776 +acl_alloc(unsigned long len)
54777 +{
54778 + void *ret = NULL;
54779 +
54780 + if (!len || len > PAGE_SIZE)
54781 + goto out;
54782 +
54783 + ret = kmalloc(len, GFP_KERNEL);
54784 +
54785 + if (ret) {
54786 + if (alloc_push(ret)) {
54787 + kfree(ret);
54788 + ret = NULL;
54789 + }
54790 + }
54791 +
54792 +out:
54793 + return ret;
54794 +}
54795 +
54796 +void *
54797 +acl_alloc_num(unsigned long num, unsigned long len)
54798 +{
54799 + if (!len || (num > (PAGE_SIZE / len)))
54800 + return NULL;
54801 +
54802 + return acl_alloc(num * len);
54803 +}
54804 +
54805 +void
54806 +acl_free_all(void)
54807 +{
54808 + if (gr_acl_is_enabled() || !alloc_stack)
54809 + return;
54810 +
54811 + while (alloc_pop()) ;
54812 +
54813 + if (alloc_stack) {
54814 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
54815 + kfree(alloc_stack);
54816 + else
54817 + vfree(alloc_stack);
54818 + }
54819 +
54820 + alloc_stack = NULL;
54821 + alloc_stack_size = 1;
54822 + alloc_stack_next = 1;
54823 +
54824 + return;
54825 +}
54826 +
54827 +int
54828 +acl_alloc_stack_init(unsigned long size)
54829 +{
54830 + if ((size * sizeof (void *)) <= PAGE_SIZE)
54831 + alloc_stack =
54832 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
54833 + else
54834 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
54835 +
54836 + alloc_stack_size = size;
54837 +
54838 + if (!alloc_stack)
54839 + return 0;
54840 + else
54841 + return 1;
54842 +}
54843 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
54844 new file mode 100644
54845 index 0000000..6d21049
54846 --- /dev/null
54847 +++ b/grsecurity/gracl_cap.c
54848 @@ -0,0 +1,110 @@
54849 +#include <linux/kernel.h>
54850 +#include <linux/module.h>
54851 +#include <linux/sched.h>
54852 +#include <linux/gracl.h>
54853 +#include <linux/grsecurity.h>
54854 +#include <linux/grinternal.h>
54855 +
54856 +extern const char *captab_log[];
54857 +extern int captab_log_entries;
54858 +
54859 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
54860 +{
54861 + struct acl_subject_label *curracl;
54862 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
54863 + kernel_cap_t cap_audit = __cap_empty_set;
54864 +
54865 + if (!gr_acl_is_enabled())
54866 + return 1;
54867 +
54868 + curracl = task->acl;
54869 +
54870 + cap_drop = curracl->cap_lower;
54871 + cap_mask = curracl->cap_mask;
54872 + cap_audit = curracl->cap_invert_audit;
54873 +
54874 + while ((curracl = curracl->parent_subject)) {
54875 + /* if the cap isn't specified in the current computed mask but is specified in the
54876 + current level subject, and is lowered in the current level subject, then add
54877 + it to the set of dropped capabilities
54878 + otherwise, add the current level subject's mask to the current computed mask
54879 + */
54880 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
54881 + cap_raise(cap_mask, cap);
54882 + if (cap_raised(curracl->cap_lower, cap))
54883 + cap_raise(cap_drop, cap);
54884 + if (cap_raised(curracl->cap_invert_audit, cap))
54885 + cap_raise(cap_audit, cap);
54886 + }
54887 + }
54888 +
54889 + if (!cap_raised(cap_drop, cap)) {
54890 + if (cap_raised(cap_audit, cap))
54891 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
54892 + return 1;
54893 + }
54894 +
54895 + curracl = task->acl;
54896 +
54897 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
54898 + && cap_raised(cred->cap_effective, cap)) {
54899 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
54900 + task->role->roletype, cred->uid,
54901 + cred->gid, task->exec_file ?
54902 + gr_to_filename(task->exec_file->f_path.dentry,
54903 + task->exec_file->f_path.mnt) : curracl->filename,
54904 + curracl->filename, 0UL,
54905 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
54906 + return 1;
54907 + }
54908 +
54909 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
54910 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
54911 +
54912 + return 0;
54913 +}
54914 +
54915 +int
54916 +gr_acl_is_capable(const int cap)
54917 +{
54918 + return gr_task_acl_is_capable(current, current_cred(), cap);
54919 +}
54920 +
54921 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
54922 +{
54923 + struct acl_subject_label *curracl;
54924 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
54925 +
54926 + if (!gr_acl_is_enabled())
54927 + return 1;
54928 +
54929 + curracl = task->acl;
54930 +
54931 + cap_drop = curracl->cap_lower;
54932 + cap_mask = curracl->cap_mask;
54933 +
54934 + while ((curracl = curracl->parent_subject)) {
54935 + /* if the cap isn't specified in the current computed mask but is specified in the
54936 + current level subject, and is lowered in the current level subject, then add
54937 + it to the set of dropped capabilities
54938 + otherwise, add the current level subject's mask to the current computed mask
54939 + */
54940 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
54941 + cap_raise(cap_mask, cap);
54942 + if (cap_raised(curracl->cap_lower, cap))
54943 + cap_raise(cap_drop, cap);
54944 + }
54945 + }
54946 +
54947 + if (!cap_raised(cap_drop, cap))
54948 + return 1;
54949 +
54950 + return 0;
54951 +}
54952 +
54953 +int
54954 +gr_acl_is_capable_nolog(const int cap)
54955 +{
54956 + return gr_task_acl_is_capable_nolog(current, cap);
54957 +}
54958 +
54959 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
54960 new file mode 100644
54961 index 0000000..88d0e87
54962 --- /dev/null
54963 +++ b/grsecurity/gracl_fs.c
54964 @@ -0,0 +1,435 @@
54965 +#include <linux/kernel.h>
54966 +#include <linux/sched.h>
54967 +#include <linux/types.h>
54968 +#include <linux/fs.h>
54969 +#include <linux/file.h>
54970 +#include <linux/stat.h>
54971 +#include <linux/grsecurity.h>
54972 +#include <linux/grinternal.h>
54973 +#include <linux/gracl.h>
54974 +
54975 +umode_t
54976 +gr_acl_umask(void)
54977 +{
54978 + if (unlikely(!gr_acl_is_enabled()))
54979 + return 0;
54980 +
54981 + return current->role->umask;
54982 +}
54983 +
54984 +__u32
54985 +gr_acl_handle_hidden_file(const struct dentry * dentry,
54986 + const struct vfsmount * mnt)
54987 +{
54988 + __u32 mode;
54989 +
54990 + if (unlikely(!dentry->d_inode))
54991 + return GR_FIND;
54992 +
54993 + mode =
54994 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
54995 +
54996 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
54997 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
54998 + return mode;
54999 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
55000 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
55001 + return 0;
55002 + } else if (unlikely(!(mode & GR_FIND)))
55003 + return 0;
55004 +
55005 + return GR_FIND;
55006 +}
55007 +
55008 +__u32
55009 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
55010 + int acc_mode)
55011 +{
55012 + __u32 reqmode = GR_FIND;
55013 + __u32 mode;
55014 +
55015 + if (unlikely(!dentry->d_inode))
55016 + return reqmode;
55017 +
55018 + if (acc_mode & MAY_APPEND)
55019 + reqmode |= GR_APPEND;
55020 + else if (acc_mode & MAY_WRITE)
55021 + reqmode |= GR_WRITE;
55022 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
55023 + reqmode |= GR_READ;
55024 +
55025 + mode =
55026 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
55027 + mnt);
55028 +
55029 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
55030 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
55031 + reqmode & GR_READ ? " reading" : "",
55032 + reqmode & GR_WRITE ? " writing" : reqmode &
55033 + GR_APPEND ? " appending" : "");
55034 + return reqmode;
55035 + } else
55036 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
55037 + {
55038 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
55039 + reqmode & GR_READ ? " reading" : "",
55040 + reqmode & GR_WRITE ? " writing" : reqmode &
55041 + GR_APPEND ? " appending" : "");
55042 + return 0;
55043 + } else if (unlikely((mode & reqmode) != reqmode))
55044 + return 0;
55045 +
55046 + return reqmode;
55047 +}
55048 +
55049 +__u32
55050 +gr_acl_handle_creat(const struct dentry * dentry,
55051 + const struct dentry * p_dentry,
55052 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
55053 + const int imode)
55054 +{
55055 + __u32 reqmode = GR_WRITE | GR_CREATE;
55056 + __u32 mode;
55057 +
55058 + if (acc_mode & MAY_APPEND)
55059 + reqmode |= GR_APPEND;
55060 + // if a directory was required or the directory already exists, then
55061 + // don't count this open as a read
55062 + if ((acc_mode & MAY_READ) &&
55063 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
55064 + reqmode |= GR_READ;
55065 + if ((open_flags & O_CREAT) && (imode & (S_ISUID | S_ISGID)))
55066 + reqmode |= GR_SETID;
55067 +
55068 + mode =
55069 + gr_check_create(dentry, p_dentry, p_mnt,
55070 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
55071 +
55072 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
55073 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
55074 + reqmode & GR_READ ? " reading" : "",
55075 + reqmode & GR_WRITE ? " writing" : reqmode &
55076 + GR_APPEND ? " appending" : "");
55077 + return reqmode;
55078 + } else
55079 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
55080 + {
55081 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
55082 + reqmode & GR_READ ? " reading" : "",
55083 + reqmode & GR_WRITE ? " writing" : reqmode &
55084 + GR_APPEND ? " appending" : "");
55085 + return 0;
55086 + } else if (unlikely((mode & reqmode) != reqmode))
55087 + return 0;
55088 +
55089 + return reqmode;
55090 +}
55091 +
55092 +__u32
55093 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
55094 + const int fmode)
55095 +{
55096 + __u32 mode, reqmode = GR_FIND;
55097 +
55098 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
55099 + reqmode |= GR_EXEC;
55100 + if (fmode & S_IWOTH)
55101 + reqmode |= GR_WRITE;
55102 + if (fmode & S_IROTH)
55103 + reqmode |= GR_READ;
55104 +
55105 + mode =
55106 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
55107 + mnt);
55108 +
55109 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
55110 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
55111 + reqmode & GR_READ ? " reading" : "",
55112 + reqmode & GR_WRITE ? " writing" : "",
55113 + reqmode & GR_EXEC ? " executing" : "");
55114 + return reqmode;
55115 + } else
55116 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
55117 + {
55118 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
55119 + reqmode & GR_READ ? " reading" : "",
55120 + reqmode & GR_WRITE ? " writing" : "",
55121 + reqmode & GR_EXEC ? " executing" : "");
55122 + return 0;
55123 + } else if (unlikely((mode & reqmode) != reqmode))
55124 + return 0;
55125 +
55126 + return reqmode;
55127 +}
55128 +
55129 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
55130 +{
55131 + __u32 mode;
55132 +
55133 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
55134 +
55135 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
55136 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
55137 + return mode;
55138 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
55139 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
55140 + return 0;
55141 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
55142 + return 0;
55143 +
55144 + return (reqmode);
55145 +}
55146 +
55147 +__u32
55148 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
55149 +{
55150 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
55151 +}
55152 +
55153 +__u32
55154 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
55155 +{
55156 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
55157 +}
55158 +
55159 +__u32
55160 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
55161 +{
55162 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
55163 +}
55164 +
55165 +__u32
55166 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
55167 +{
55168 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
55169 +}
55170 +
55171 +__u32
55172 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
55173 + umode_t *modeptr)
55174 +{
55175 + umode_t mode;
55176 +
55177 + *modeptr &= ~gr_acl_umask();
55178 + mode = *modeptr;
55179 +
55180 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
55181 + return 1;
55182 +
55183 + if (unlikely(mode & (S_ISUID | S_ISGID))) {
55184 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
55185 + GR_CHMOD_ACL_MSG);
55186 + } else {
55187 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
55188 + }
55189 +}
55190 +
55191 +__u32
55192 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
55193 +{
55194 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
55195 +}
55196 +
55197 +__u32
55198 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
55199 +{
55200 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
55201 +}
55202 +
55203 +__u32
55204 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
55205 +{
55206 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
55207 +}
55208 +
55209 +__u32
55210 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
55211 +{
55212 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
55213 + GR_UNIXCONNECT_ACL_MSG);
55214 +}
55215 +
55216 +/* hardlinks require at minimum create and link permission,
55217 + any additional privilege required is based on the
55218 + privilege of the file being linked to
55219 +*/
55220 +__u32
55221 +gr_acl_handle_link(const struct dentry * new_dentry,
55222 + const struct dentry * parent_dentry,
55223 + const struct vfsmount * parent_mnt,
55224 + const struct dentry * old_dentry,
55225 + const struct vfsmount * old_mnt, const char *to)
55226 +{
55227 + __u32 mode;
55228 + __u32 needmode = GR_CREATE | GR_LINK;
55229 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
55230 +
55231 + mode =
55232 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
55233 + old_mnt);
55234 +
55235 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
55236 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to);
55237 + return mode;
55238 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
55239 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to);
55240 + return 0;
55241 + } else if (unlikely((mode & needmode) != needmode))
55242 + return 0;
55243 +
55244 + return 1;
55245 +}
55246 +
55247 +__u32
55248 +gr_acl_handle_symlink(const struct dentry * new_dentry,
55249 + const struct dentry * parent_dentry,
55250 + const struct vfsmount * parent_mnt, const char *from)
55251 +{
55252 + __u32 needmode = GR_WRITE | GR_CREATE;
55253 + __u32 mode;
55254 +
55255 + mode =
55256 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
55257 + GR_CREATE | GR_AUDIT_CREATE |
55258 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
55259 +
55260 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
55261 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from, new_dentry, parent_mnt);
55262 + return mode;
55263 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
55264 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from, new_dentry, parent_mnt);
55265 + return 0;
55266 + } else if (unlikely((mode & needmode) != needmode))
55267 + return 0;
55268 +
55269 + return (GR_WRITE | GR_CREATE);
55270 +}
55271 +
55272 +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)
55273 +{
55274 + __u32 mode;
55275 +
55276 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
55277 +
55278 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
55279 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
55280 + return mode;
55281 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
55282 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
55283 + return 0;
55284 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
55285 + return 0;
55286 +
55287 + return (reqmode);
55288 +}
55289 +
55290 +__u32
55291 +gr_acl_handle_mknod(const struct dentry * new_dentry,
55292 + const struct dentry * parent_dentry,
55293 + const struct vfsmount * parent_mnt,
55294 + const int mode)
55295 +{
55296 + __u32 reqmode = GR_WRITE | GR_CREATE;
55297 + if (unlikely(mode & (S_ISUID | S_ISGID)))
55298 + reqmode |= GR_SETID;
55299 +
55300 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
55301 + reqmode, GR_MKNOD_ACL_MSG);
55302 +}
55303 +
55304 +__u32
55305 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
55306 + const struct dentry *parent_dentry,
55307 + const struct vfsmount *parent_mnt)
55308 +{
55309 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
55310 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
55311 +}
55312 +
55313 +#define RENAME_CHECK_SUCCESS(old, new) \
55314 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
55315 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
55316 +
55317 +int
55318 +gr_acl_handle_rename(struct dentry *new_dentry,
55319 + struct dentry *parent_dentry,
55320 + const struct vfsmount *parent_mnt,
55321 + struct dentry *old_dentry,
55322 + struct inode *old_parent_inode,
55323 + struct vfsmount *old_mnt, const char *newname)
55324 +{
55325 + __u32 comp1, comp2;
55326 + int error = 0;
55327 +
55328 + if (unlikely(!gr_acl_is_enabled()))
55329 + return 0;
55330 +
55331 + if (!new_dentry->d_inode) {
55332 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
55333 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
55334 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
55335 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
55336 + GR_DELETE | GR_AUDIT_DELETE |
55337 + GR_AUDIT_READ | GR_AUDIT_WRITE |
55338 + GR_SUPPRESS, old_mnt);
55339 + } else {
55340 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
55341 + GR_CREATE | GR_DELETE |
55342 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
55343 + GR_AUDIT_READ | GR_AUDIT_WRITE |
55344 + GR_SUPPRESS, parent_mnt);
55345 + comp2 =
55346 + gr_search_file(old_dentry,
55347 + GR_READ | GR_WRITE | GR_AUDIT_READ |
55348 + GR_DELETE | GR_AUDIT_DELETE |
55349 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
55350 + }
55351 +
55352 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
55353 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
55354 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname);
55355 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
55356 + && !(comp2 & GR_SUPPRESS)) {
55357 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname);
55358 + error = -EACCES;
55359 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
55360 + error = -EACCES;
55361 +
55362 + return error;
55363 +}
55364 +
55365 +void
55366 +gr_acl_handle_exit(void)
55367 +{
55368 + u16 id;
55369 + char *rolename;
55370 + struct file *exec_file;
55371 +
55372 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
55373 + !(current->role->roletype & GR_ROLE_PERSIST))) {
55374 + id = current->acl_role_id;
55375 + rolename = current->role->rolename;
55376 + gr_set_acls(1);
55377 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
55378 + }
55379 +
55380 + write_lock(&grsec_exec_file_lock);
55381 + exec_file = current->exec_file;
55382 + current->exec_file = NULL;
55383 + write_unlock(&grsec_exec_file_lock);
55384 +
55385 + if (exec_file)
55386 + fput(exec_file);
55387 +}
55388 +
55389 +int
55390 +gr_acl_handle_procpidmem(const struct task_struct *task)
55391 +{
55392 + if (unlikely(!gr_acl_is_enabled()))
55393 + return 0;
55394 +
55395 + if (task != current && task->acl->mode & GR_PROTPROCFD)
55396 + return -EACCES;
55397 +
55398 + return 0;
55399 +}
55400 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
55401 new file mode 100644
55402 index 0000000..58800a7
55403 --- /dev/null
55404 +++ b/grsecurity/gracl_ip.c
55405 @@ -0,0 +1,384 @@
55406 +#include <linux/kernel.h>
55407 +#include <asm/uaccess.h>
55408 +#include <asm/errno.h>
55409 +#include <net/sock.h>
55410 +#include <linux/file.h>
55411 +#include <linux/fs.h>
55412 +#include <linux/net.h>
55413 +#include <linux/in.h>
55414 +#include <linux/skbuff.h>
55415 +#include <linux/ip.h>
55416 +#include <linux/udp.h>
55417 +#include <linux/types.h>
55418 +#include <linux/sched.h>
55419 +#include <linux/netdevice.h>
55420 +#include <linux/inetdevice.h>
55421 +#include <linux/gracl.h>
55422 +#include <linux/grsecurity.h>
55423 +#include <linux/grinternal.h>
55424 +
55425 +#define GR_BIND 0x01
55426 +#define GR_CONNECT 0x02
55427 +#define GR_INVERT 0x04
55428 +#define GR_BINDOVERRIDE 0x08
55429 +#define GR_CONNECTOVERRIDE 0x10
55430 +#define GR_SOCK_FAMILY 0x20
55431 +
55432 +static const char * gr_protocols[IPPROTO_MAX] = {
55433 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
55434 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
55435 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
55436 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
55437 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
55438 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
55439 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
55440 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
55441 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
55442 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
55443 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
55444 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
55445 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
55446 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
55447 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
55448 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
55449 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
55450 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
55451 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
55452 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
55453 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
55454 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
55455 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
55456 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
55457 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
55458 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
55459 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
55460 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
55461 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
55462 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
55463 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
55464 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
55465 + };
55466 +
55467 +static const char * gr_socktypes[SOCK_MAX] = {
55468 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
55469 + "unknown:7", "unknown:8", "unknown:9", "packet"
55470 + };
55471 +
55472 +static const char * gr_sockfamilies[AF_MAX+1] = {
55473 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
55474 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
55475 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
55476 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
55477 + };
55478 +
55479 +const char *
55480 +gr_proto_to_name(unsigned char proto)
55481 +{
55482 + return gr_protocols[proto];
55483 +}
55484 +
55485 +const char *
55486 +gr_socktype_to_name(unsigned char type)
55487 +{
55488 + return gr_socktypes[type];
55489 +}
55490 +
55491 +const char *
55492 +gr_sockfamily_to_name(unsigned char family)
55493 +{
55494 + return gr_sockfamilies[family];
55495 +}
55496 +
55497 +int
55498 +gr_search_socket(const int domain, const int type, const int protocol)
55499 +{
55500 + struct acl_subject_label *curr;
55501 + const struct cred *cred = current_cred();
55502 +
55503 + if (unlikely(!gr_acl_is_enabled()))
55504 + goto exit;
55505 +
55506 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
55507 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
55508 + goto exit; // let the kernel handle it
55509 +
55510 + curr = current->acl;
55511 +
55512 + if (curr->sock_families[domain / 32] & (1 << (domain % 32))) {
55513 + /* the family is allowed, if this is PF_INET allow it only if
55514 + the extra sock type/protocol checks pass */
55515 + if (domain == PF_INET)
55516 + goto inet_check;
55517 + goto exit;
55518 + } else {
55519 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
55520 + __u32 fakeip = 0;
55521 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
55522 + current->role->roletype, cred->uid,
55523 + cred->gid, current->exec_file ?
55524 + gr_to_filename(current->exec_file->f_path.dentry,
55525 + current->exec_file->f_path.mnt) :
55526 + curr->filename, curr->filename,
55527 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
55528 + &current->signal->saved_ip);
55529 + goto exit;
55530 + }
55531 + goto exit_fail;
55532 + }
55533 +
55534 +inet_check:
55535 + /* the rest of this checking is for IPv4 only */
55536 + if (!curr->ips)
55537 + goto exit;
55538 +
55539 + if ((curr->ip_type & (1 << type)) &&
55540 + (curr->ip_proto[protocol / 32] & (1 << (protocol % 32))))
55541 + goto exit;
55542 +
55543 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
55544 + /* we don't place acls on raw sockets , and sometimes
55545 + dgram/ip sockets are opened for ioctl and not
55546 + bind/connect, so we'll fake a bind learn log */
55547 + if (type == SOCK_RAW || type == SOCK_PACKET) {
55548 + __u32 fakeip = 0;
55549 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
55550 + current->role->roletype, cred->uid,
55551 + cred->gid, current->exec_file ?
55552 + gr_to_filename(current->exec_file->f_path.dentry,
55553 + current->exec_file->f_path.mnt) :
55554 + curr->filename, curr->filename,
55555 + &fakeip, 0, type,
55556 + protocol, GR_CONNECT, &current->signal->saved_ip);
55557 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
55558 + __u32 fakeip = 0;
55559 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
55560 + current->role->roletype, cred->uid,
55561 + cred->gid, current->exec_file ?
55562 + gr_to_filename(current->exec_file->f_path.dentry,
55563 + current->exec_file->f_path.mnt) :
55564 + curr->filename, curr->filename,
55565 + &fakeip, 0, type,
55566 + protocol, GR_BIND, &current->signal->saved_ip);
55567 + }
55568 + /* we'll log when they use connect or bind */
55569 + goto exit;
55570 + }
55571 +
55572 +exit_fail:
55573 + if (domain == PF_INET)
55574 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
55575 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
55576 + else
55577 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
55578 + gr_socktype_to_name(type), protocol);
55579 +
55580 + return 0;
55581 +exit:
55582 + return 1;
55583 +}
55584 +
55585 +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)
55586 +{
55587 + if ((ip->mode & mode) &&
55588 + (ip_port >= ip->low) &&
55589 + (ip_port <= ip->high) &&
55590 + ((ntohl(ip_addr) & our_netmask) ==
55591 + (ntohl(our_addr) & our_netmask))
55592 + && (ip->proto[protocol / 32] & (1 << (protocol % 32)))
55593 + && (ip->type & (1 << type))) {
55594 + if (ip->mode & GR_INVERT)
55595 + return 2; // specifically denied
55596 + else
55597 + return 1; // allowed
55598 + }
55599 +
55600 + return 0; // not specifically allowed, may continue parsing
55601 +}
55602 +
55603 +static int
55604 +gr_search_connectbind(const int full_mode, struct sock *sk,
55605 + struct sockaddr_in *addr, const int type)
55606 +{
55607 + char iface[IFNAMSIZ] = {0};
55608 + struct acl_subject_label *curr;
55609 + struct acl_ip_label *ip;
55610 + struct inet_sock *isk;
55611 + struct net_device *dev;
55612 + struct in_device *idev;
55613 + unsigned long i;
55614 + int ret;
55615 + int mode = full_mode & (GR_BIND | GR_CONNECT);
55616 + __u32 ip_addr = 0;
55617 + __u32 our_addr;
55618 + __u32 our_netmask;
55619 + char *p;
55620 + __u16 ip_port = 0;
55621 + const struct cred *cred = current_cred();
55622 +
55623 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
55624 + return 0;
55625 +
55626 + curr = current->acl;
55627 + isk = inet_sk(sk);
55628 +
55629 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
55630 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
55631 + addr->sin_addr.s_addr = curr->inaddr_any_override;
55632 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
55633 + struct sockaddr_in saddr;
55634 + int err;
55635 +
55636 + saddr.sin_family = AF_INET;
55637 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
55638 + saddr.sin_port = isk->inet_sport;
55639 +
55640 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
55641 + if (err)
55642 + return err;
55643 +
55644 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
55645 + if (err)
55646 + return err;
55647 + }
55648 +
55649 + if (!curr->ips)
55650 + return 0;
55651 +
55652 + ip_addr = addr->sin_addr.s_addr;
55653 + ip_port = ntohs(addr->sin_port);
55654 +
55655 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
55656 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
55657 + current->role->roletype, cred->uid,
55658 + cred->gid, current->exec_file ?
55659 + gr_to_filename(current->exec_file->f_path.dentry,
55660 + current->exec_file->f_path.mnt) :
55661 + curr->filename, curr->filename,
55662 + &ip_addr, ip_port, type,
55663 + sk->sk_protocol, mode, &current->signal->saved_ip);
55664 + return 0;
55665 + }
55666 +
55667 + for (i = 0; i < curr->ip_num; i++) {
55668 + ip = *(curr->ips + i);
55669 + if (ip->iface != NULL) {
55670 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
55671 + p = strchr(iface, ':');
55672 + if (p != NULL)
55673 + *p = '\0';
55674 + dev = dev_get_by_name(sock_net(sk), iface);
55675 + if (dev == NULL)
55676 + continue;
55677 + idev = in_dev_get(dev);
55678 + if (idev == NULL) {
55679 + dev_put(dev);
55680 + continue;
55681 + }
55682 + rcu_read_lock();
55683 + for_ifa(idev) {
55684 + if (!strcmp(ip->iface, ifa->ifa_label)) {
55685 + our_addr = ifa->ifa_address;
55686 + our_netmask = 0xffffffff;
55687 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
55688 + if (ret == 1) {
55689 + rcu_read_unlock();
55690 + in_dev_put(idev);
55691 + dev_put(dev);
55692 + return 0;
55693 + } else if (ret == 2) {
55694 + rcu_read_unlock();
55695 + in_dev_put(idev);
55696 + dev_put(dev);
55697 + goto denied;
55698 + }
55699 + }
55700 + } endfor_ifa(idev);
55701 + rcu_read_unlock();
55702 + in_dev_put(idev);
55703 + dev_put(dev);
55704 + } else {
55705 + our_addr = ip->addr;
55706 + our_netmask = ip->netmask;
55707 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
55708 + if (ret == 1)
55709 + return 0;
55710 + else if (ret == 2)
55711 + goto denied;
55712 + }
55713 + }
55714 +
55715 +denied:
55716 + if (mode == GR_BIND)
55717 + 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));
55718 + else if (mode == GR_CONNECT)
55719 + 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));
55720 +
55721 + return -EACCES;
55722 +}
55723 +
55724 +int
55725 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
55726 +{
55727 + /* always allow disconnection of dgram sockets with connect */
55728 + if (addr->sin_family == AF_UNSPEC)
55729 + return 0;
55730 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
55731 +}
55732 +
55733 +int
55734 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
55735 +{
55736 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
55737 +}
55738 +
55739 +int gr_search_listen(struct socket *sock)
55740 +{
55741 + struct sock *sk = sock->sk;
55742 + struct sockaddr_in addr;
55743 +
55744 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
55745 + addr.sin_port = inet_sk(sk)->inet_sport;
55746 +
55747 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
55748 +}
55749 +
55750 +int gr_search_accept(struct socket *sock)
55751 +{
55752 + struct sock *sk = sock->sk;
55753 + struct sockaddr_in addr;
55754 +
55755 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
55756 + addr.sin_port = inet_sk(sk)->inet_sport;
55757 +
55758 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
55759 +}
55760 +
55761 +int
55762 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
55763 +{
55764 + if (addr)
55765 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
55766 + else {
55767 + struct sockaddr_in sin;
55768 + const struct inet_sock *inet = inet_sk(sk);
55769 +
55770 + sin.sin_addr.s_addr = inet->inet_daddr;
55771 + sin.sin_port = inet->inet_dport;
55772 +
55773 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
55774 + }
55775 +}
55776 +
55777 +int
55778 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
55779 +{
55780 + struct sockaddr_in sin;
55781 +
55782 + if (unlikely(skb->len < sizeof (struct udphdr)))
55783 + return 0; // skip this packet
55784 +
55785 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
55786 + sin.sin_port = udp_hdr(skb)->source;
55787 +
55788 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
55789 +}
55790 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
55791 new file mode 100644
55792 index 0000000..25f54ef
55793 --- /dev/null
55794 +++ b/grsecurity/gracl_learn.c
55795 @@ -0,0 +1,207 @@
55796 +#include <linux/kernel.h>
55797 +#include <linux/mm.h>
55798 +#include <linux/sched.h>
55799 +#include <linux/poll.h>
55800 +#include <linux/string.h>
55801 +#include <linux/file.h>
55802 +#include <linux/types.h>
55803 +#include <linux/vmalloc.h>
55804 +#include <linux/grinternal.h>
55805 +
55806 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
55807 + size_t count, loff_t *ppos);
55808 +extern int gr_acl_is_enabled(void);
55809 +
55810 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
55811 +static int gr_learn_attached;
55812 +
55813 +/* use a 512k buffer */
55814 +#define LEARN_BUFFER_SIZE (512 * 1024)
55815 +
55816 +static DEFINE_SPINLOCK(gr_learn_lock);
55817 +static DEFINE_MUTEX(gr_learn_user_mutex);
55818 +
55819 +/* we need to maintain two buffers, so that the kernel context of grlearn
55820 + uses a semaphore around the userspace copying, and the other kernel contexts
55821 + use a spinlock when copying into the buffer, since they cannot sleep
55822 +*/
55823 +static char *learn_buffer;
55824 +static char *learn_buffer_user;
55825 +static int learn_buffer_len;
55826 +static int learn_buffer_user_len;
55827 +
55828 +static ssize_t
55829 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
55830 +{
55831 + DECLARE_WAITQUEUE(wait, current);
55832 + ssize_t retval = 0;
55833 +
55834 + add_wait_queue(&learn_wait, &wait);
55835 + set_current_state(TASK_INTERRUPTIBLE);
55836 + do {
55837 + mutex_lock(&gr_learn_user_mutex);
55838 + spin_lock(&gr_learn_lock);
55839 + if (learn_buffer_len)
55840 + break;
55841 + spin_unlock(&gr_learn_lock);
55842 + mutex_unlock(&gr_learn_user_mutex);
55843 + if (file->f_flags & O_NONBLOCK) {
55844 + retval = -EAGAIN;
55845 + goto out;
55846 + }
55847 + if (signal_pending(current)) {
55848 + retval = -ERESTARTSYS;
55849 + goto out;
55850 + }
55851 +
55852 + schedule();
55853 + } while (1);
55854 +
55855 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
55856 + learn_buffer_user_len = learn_buffer_len;
55857 + retval = learn_buffer_len;
55858 + learn_buffer_len = 0;
55859 +
55860 + spin_unlock(&gr_learn_lock);
55861 +
55862 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
55863 + retval = -EFAULT;
55864 +
55865 + mutex_unlock(&gr_learn_user_mutex);
55866 +out:
55867 + set_current_state(TASK_RUNNING);
55868 + remove_wait_queue(&learn_wait, &wait);
55869 + return retval;
55870 +}
55871 +
55872 +static unsigned int
55873 +poll_learn(struct file * file, poll_table * wait)
55874 +{
55875 + poll_wait(file, &learn_wait, wait);
55876 +
55877 + if (learn_buffer_len)
55878 + return (POLLIN | POLLRDNORM);
55879 +
55880 + return 0;
55881 +}
55882 +
55883 +void
55884 +gr_clear_learn_entries(void)
55885 +{
55886 + char *tmp;
55887 +
55888 + mutex_lock(&gr_learn_user_mutex);
55889 + spin_lock(&gr_learn_lock);
55890 + tmp = learn_buffer;
55891 + learn_buffer = NULL;
55892 + spin_unlock(&gr_learn_lock);
55893 + if (tmp)
55894 + vfree(tmp);
55895 + if (learn_buffer_user != NULL) {
55896 + vfree(learn_buffer_user);
55897 + learn_buffer_user = NULL;
55898 + }
55899 + learn_buffer_len = 0;
55900 + mutex_unlock(&gr_learn_user_mutex);
55901 +
55902 + return;
55903 +}
55904 +
55905 +void
55906 +gr_add_learn_entry(const char *fmt, ...)
55907 +{
55908 + va_list args;
55909 + unsigned int len;
55910 +
55911 + if (!gr_learn_attached)
55912 + return;
55913 +
55914 + spin_lock(&gr_learn_lock);
55915 +
55916 + /* leave a gap at the end so we know when it's "full" but don't have to
55917 + compute the exact length of the string we're trying to append
55918 + */
55919 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
55920 + spin_unlock(&gr_learn_lock);
55921 + wake_up_interruptible(&learn_wait);
55922 + return;
55923 + }
55924 + if (learn_buffer == NULL) {
55925 + spin_unlock(&gr_learn_lock);
55926 + return;
55927 + }
55928 +
55929 + va_start(args, fmt);
55930 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
55931 + va_end(args);
55932 +
55933 + learn_buffer_len += len + 1;
55934 +
55935 + spin_unlock(&gr_learn_lock);
55936 + wake_up_interruptible(&learn_wait);
55937 +
55938 + return;
55939 +}
55940 +
55941 +static int
55942 +open_learn(struct inode *inode, struct file *file)
55943 +{
55944 + if (file->f_mode & FMODE_READ && gr_learn_attached)
55945 + return -EBUSY;
55946 + if (file->f_mode & FMODE_READ) {
55947 + int retval = 0;
55948 + mutex_lock(&gr_learn_user_mutex);
55949 + if (learn_buffer == NULL)
55950 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
55951 + if (learn_buffer_user == NULL)
55952 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
55953 + if (learn_buffer == NULL) {
55954 + retval = -ENOMEM;
55955 + goto out_error;
55956 + }
55957 + if (learn_buffer_user == NULL) {
55958 + retval = -ENOMEM;
55959 + goto out_error;
55960 + }
55961 + learn_buffer_len = 0;
55962 + learn_buffer_user_len = 0;
55963 + gr_learn_attached = 1;
55964 +out_error:
55965 + mutex_unlock(&gr_learn_user_mutex);
55966 + return retval;
55967 + }
55968 + return 0;
55969 +}
55970 +
55971 +static int
55972 +close_learn(struct inode *inode, struct file *file)
55973 +{
55974 + if (file->f_mode & FMODE_READ) {
55975 + char *tmp = NULL;
55976 + mutex_lock(&gr_learn_user_mutex);
55977 + spin_lock(&gr_learn_lock);
55978 + tmp = learn_buffer;
55979 + learn_buffer = NULL;
55980 + spin_unlock(&gr_learn_lock);
55981 + if (tmp)
55982 + vfree(tmp);
55983 + if (learn_buffer_user != NULL) {
55984 + vfree(learn_buffer_user);
55985 + learn_buffer_user = NULL;
55986 + }
55987 + learn_buffer_len = 0;
55988 + learn_buffer_user_len = 0;
55989 + gr_learn_attached = 0;
55990 + mutex_unlock(&gr_learn_user_mutex);
55991 + }
55992 +
55993 + return 0;
55994 +}
55995 +
55996 +const struct file_operations grsec_fops = {
55997 + .read = read_learn,
55998 + .write = write_grsec_handler,
55999 + .open = open_learn,
56000 + .release = close_learn,
56001 + .poll = poll_learn,
56002 +};
56003 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
56004 new file mode 100644
56005 index 0000000..39645c9
56006 --- /dev/null
56007 +++ b/grsecurity/gracl_res.c
56008 @@ -0,0 +1,68 @@
56009 +#include <linux/kernel.h>
56010 +#include <linux/sched.h>
56011 +#include <linux/gracl.h>
56012 +#include <linux/grinternal.h>
56013 +
56014 +static const char *restab_log[] = {
56015 + [RLIMIT_CPU] = "RLIMIT_CPU",
56016 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
56017 + [RLIMIT_DATA] = "RLIMIT_DATA",
56018 + [RLIMIT_STACK] = "RLIMIT_STACK",
56019 + [RLIMIT_CORE] = "RLIMIT_CORE",
56020 + [RLIMIT_RSS] = "RLIMIT_RSS",
56021 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
56022 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
56023 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
56024 + [RLIMIT_AS] = "RLIMIT_AS",
56025 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
56026 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
56027 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
56028 + [RLIMIT_NICE] = "RLIMIT_NICE",
56029 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
56030 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
56031 + [GR_CRASH_RES] = "RLIMIT_CRASH"
56032 +};
56033 +
56034 +void
56035 +gr_log_resource(const struct task_struct *task,
56036 + const int res, const unsigned long wanted, const int gt)
56037 +{
56038 + const struct cred *cred;
56039 + unsigned long rlim;
56040 +
56041 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
56042 + return;
56043 +
56044 + // not yet supported resource
56045 + if (unlikely(!restab_log[res]))
56046 + return;
56047 +
56048 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
56049 + rlim = task_rlimit_max(task, res);
56050 + else
56051 + rlim = task_rlimit(task, res);
56052 +
56053 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
56054 + return;
56055 +
56056 + rcu_read_lock();
56057 + cred = __task_cred(task);
56058 +
56059 + if (res == RLIMIT_NPROC &&
56060 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
56061 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
56062 + goto out_rcu_unlock;
56063 + else if (res == RLIMIT_MEMLOCK &&
56064 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
56065 + goto out_rcu_unlock;
56066 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
56067 + goto out_rcu_unlock;
56068 + rcu_read_unlock();
56069 +
56070 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
56071 +
56072 + return;
56073 +out_rcu_unlock:
56074 + rcu_read_unlock();
56075 + return;
56076 +}
56077 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
56078 new file mode 100644
56079 index 0000000..5556be3
56080 --- /dev/null
56081 +++ b/grsecurity/gracl_segv.c
56082 @@ -0,0 +1,299 @@
56083 +#include <linux/kernel.h>
56084 +#include <linux/mm.h>
56085 +#include <asm/uaccess.h>
56086 +#include <asm/errno.h>
56087 +#include <asm/mman.h>
56088 +#include <net/sock.h>
56089 +#include <linux/file.h>
56090 +#include <linux/fs.h>
56091 +#include <linux/net.h>
56092 +#include <linux/in.h>
56093 +#include <linux/slab.h>
56094 +#include <linux/types.h>
56095 +#include <linux/sched.h>
56096 +#include <linux/timer.h>
56097 +#include <linux/gracl.h>
56098 +#include <linux/grsecurity.h>
56099 +#include <linux/grinternal.h>
56100 +
56101 +static struct crash_uid *uid_set;
56102 +static unsigned short uid_used;
56103 +static DEFINE_SPINLOCK(gr_uid_lock);
56104 +extern rwlock_t gr_inode_lock;
56105 +extern struct acl_subject_label *
56106 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
56107 + struct acl_role_label *role);
56108 +
56109 +#ifdef CONFIG_BTRFS_FS
56110 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
56111 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
56112 +#endif
56113 +
56114 +static inline dev_t __get_dev(const struct dentry *dentry)
56115 +{
56116 +#ifdef CONFIG_BTRFS_FS
56117 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
56118 + return get_btrfs_dev_from_inode(dentry->d_inode);
56119 + else
56120 +#endif
56121 + return dentry->d_inode->i_sb->s_dev;
56122 +}
56123 +
56124 +int
56125 +gr_init_uidset(void)
56126 +{
56127 + uid_set =
56128 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
56129 + uid_used = 0;
56130 +
56131 + return uid_set ? 1 : 0;
56132 +}
56133 +
56134 +void
56135 +gr_free_uidset(void)
56136 +{
56137 + if (uid_set)
56138 + kfree(uid_set);
56139 +
56140 + return;
56141 +}
56142 +
56143 +int
56144 +gr_find_uid(const uid_t uid)
56145 +{
56146 + struct crash_uid *tmp = uid_set;
56147 + uid_t buid;
56148 + int low = 0, high = uid_used - 1, mid;
56149 +
56150 + while (high >= low) {
56151 + mid = (low + high) >> 1;
56152 + buid = tmp[mid].uid;
56153 + if (buid == uid)
56154 + return mid;
56155 + if (buid > uid)
56156 + high = mid - 1;
56157 + if (buid < uid)
56158 + low = mid + 1;
56159 + }
56160 +
56161 + return -1;
56162 +}
56163 +
56164 +static __inline__ void
56165 +gr_insertsort(void)
56166 +{
56167 + unsigned short i, j;
56168 + struct crash_uid index;
56169 +
56170 + for (i = 1; i < uid_used; i++) {
56171 + index = uid_set[i];
56172 + j = i;
56173 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
56174 + uid_set[j] = uid_set[j - 1];
56175 + j--;
56176 + }
56177 + uid_set[j] = index;
56178 + }
56179 +
56180 + return;
56181 +}
56182 +
56183 +static __inline__ void
56184 +gr_insert_uid(const uid_t uid, const unsigned long expires)
56185 +{
56186 + int loc;
56187 +
56188 + if (uid_used == GR_UIDTABLE_MAX)
56189 + return;
56190 +
56191 + loc = gr_find_uid(uid);
56192 +
56193 + if (loc >= 0) {
56194 + uid_set[loc].expires = expires;
56195 + return;
56196 + }
56197 +
56198 + uid_set[uid_used].uid = uid;
56199 + uid_set[uid_used].expires = expires;
56200 + uid_used++;
56201 +
56202 + gr_insertsort();
56203 +
56204 + return;
56205 +}
56206 +
56207 +void
56208 +gr_remove_uid(const unsigned short loc)
56209 +{
56210 + unsigned short i;
56211 +
56212 + for (i = loc + 1; i < uid_used; i++)
56213 + uid_set[i - 1] = uid_set[i];
56214 +
56215 + uid_used--;
56216 +
56217 + return;
56218 +}
56219 +
56220 +int
56221 +gr_check_crash_uid(const uid_t uid)
56222 +{
56223 + int loc;
56224 + int ret = 0;
56225 +
56226 + if (unlikely(!gr_acl_is_enabled()))
56227 + return 0;
56228 +
56229 + spin_lock(&gr_uid_lock);
56230 + loc = gr_find_uid(uid);
56231 +
56232 + if (loc < 0)
56233 + goto out_unlock;
56234 +
56235 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
56236 + gr_remove_uid(loc);
56237 + else
56238 + ret = 1;
56239 +
56240 +out_unlock:
56241 + spin_unlock(&gr_uid_lock);
56242 + return ret;
56243 +}
56244 +
56245 +static __inline__ int
56246 +proc_is_setxid(const struct cred *cred)
56247 +{
56248 + if (cred->uid != cred->euid || cred->uid != cred->suid ||
56249 + cred->uid != cred->fsuid)
56250 + return 1;
56251 + if (cred->gid != cred->egid || cred->gid != cred->sgid ||
56252 + cred->gid != cred->fsgid)
56253 + return 1;
56254 +
56255 + return 0;
56256 +}
56257 +
56258 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
56259 +
56260 +void
56261 +gr_handle_crash(struct task_struct *task, const int sig)
56262 +{
56263 + struct acl_subject_label *curr;
56264 + struct task_struct *tsk, *tsk2;
56265 + const struct cred *cred;
56266 + const struct cred *cred2;
56267 +
56268 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
56269 + return;
56270 +
56271 + if (unlikely(!gr_acl_is_enabled()))
56272 + return;
56273 +
56274 + curr = task->acl;
56275 +
56276 + if (!(curr->resmask & (1 << GR_CRASH_RES)))
56277 + return;
56278 +
56279 + if (time_before_eq(curr->expires, get_seconds())) {
56280 + curr->expires = 0;
56281 + curr->crashes = 0;
56282 + }
56283 +
56284 + curr->crashes++;
56285 +
56286 + if (!curr->expires)
56287 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
56288 +
56289 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
56290 + time_after(curr->expires, get_seconds())) {
56291 + rcu_read_lock();
56292 + cred = __task_cred(task);
56293 + if (cred->uid && proc_is_setxid(cred)) {
56294 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
56295 + spin_lock(&gr_uid_lock);
56296 + gr_insert_uid(cred->uid, curr->expires);
56297 + spin_unlock(&gr_uid_lock);
56298 + curr->expires = 0;
56299 + curr->crashes = 0;
56300 + read_lock(&tasklist_lock);
56301 + do_each_thread(tsk2, tsk) {
56302 + cred2 = __task_cred(tsk);
56303 + if (tsk != task && cred2->uid == cred->uid)
56304 + gr_fake_force_sig(SIGKILL, tsk);
56305 + } while_each_thread(tsk2, tsk);
56306 + read_unlock(&tasklist_lock);
56307 + } else {
56308 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
56309 + read_lock(&tasklist_lock);
56310 + read_lock(&grsec_exec_file_lock);
56311 + do_each_thread(tsk2, tsk) {
56312 + if (likely(tsk != task)) {
56313 + // if this thread has the same subject as the one that triggered
56314 + // RES_CRASH and it's the same binary, kill it
56315 + if (tsk->acl == task->acl && tsk->exec_file == task->exec_file)
56316 + gr_fake_force_sig(SIGKILL, tsk);
56317 + }
56318 + } while_each_thread(tsk2, tsk);
56319 + read_unlock(&grsec_exec_file_lock);
56320 + read_unlock(&tasklist_lock);
56321 + }
56322 + rcu_read_unlock();
56323 + }
56324 +
56325 + return;
56326 +}
56327 +
56328 +int
56329 +gr_check_crash_exec(const struct file *filp)
56330 +{
56331 + struct acl_subject_label *curr;
56332 +
56333 + if (unlikely(!gr_acl_is_enabled()))
56334 + return 0;
56335 +
56336 + read_lock(&gr_inode_lock);
56337 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
56338 + __get_dev(filp->f_path.dentry),
56339 + current->role);
56340 + read_unlock(&gr_inode_lock);
56341 +
56342 + if (!curr || !(curr->resmask & (1 << GR_CRASH_RES)) ||
56343 + (!curr->crashes && !curr->expires))
56344 + return 0;
56345 +
56346 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
56347 + time_after(curr->expires, get_seconds()))
56348 + return 1;
56349 + else if (time_before_eq(curr->expires, get_seconds())) {
56350 + curr->crashes = 0;
56351 + curr->expires = 0;
56352 + }
56353 +
56354 + return 0;
56355 +}
56356 +
56357 +void
56358 +gr_handle_alertkill(struct task_struct *task)
56359 +{
56360 + struct acl_subject_label *curracl;
56361 + __u32 curr_ip;
56362 + struct task_struct *p, *p2;
56363 +
56364 + if (unlikely(!gr_acl_is_enabled()))
56365 + return;
56366 +
56367 + curracl = task->acl;
56368 + curr_ip = task->signal->curr_ip;
56369 +
56370 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
56371 + read_lock(&tasklist_lock);
56372 + do_each_thread(p2, p) {
56373 + if (p->signal->curr_ip == curr_ip)
56374 + gr_fake_force_sig(SIGKILL, p);
56375 + } while_each_thread(p2, p);
56376 + read_unlock(&tasklist_lock);
56377 + } else if (curracl->mode & GR_KILLPROC)
56378 + gr_fake_force_sig(SIGKILL, task);
56379 +
56380 + return;
56381 +}
56382 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
56383 new file mode 100644
56384 index 0000000..9d83a69
56385 --- /dev/null
56386 +++ b/grsecurity/gracl_shm.c
56387 @@ -0,0 +1,40 @@
56388 +#include <linux/kernel.h>
56389 +#include <linux/mm.h>
56390 +#include <linux/sched.h>
56391 +#include <linux/file.h>
56392 +#include <linux/ipc.h>
56393 +#include <linux/gracl.h>
56394 +#include <linux/grsecurity.h>
56395 +#include <linux/grinternal.h>
56396 +
56397 +int
56398 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
56399 + const time_t shm_createtime, const uid_t cuid, const int shmid)
56400 +{
56401 + struct task_struct *task;
56402 +
56403 + if (!gr_acl_is_enabled())
56404 + return 1;
56405 +
56406 + rcu_read_lock();
56407 + read_lock(&tasklist_lock);
56408 +
56409 + task = find_task_by_vpid(shm_cprid);
56410 +
56411 + if (unlikely(!task))
56412 + task = find_task_by_vpid(shm_lapid);
56413 +
56414 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
56415 + (task->pid == shm_lapid)) &&
56416 + (task->acl->mode & GR_PROTSHM) &&
56417 + (task->acl != current->acl))) {
56418 + read_unlock(&tasklist_lock);
56419 + rcu_read_unlock();
56420 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, cuid, shm_cprid, shmid);
56421 + return 0;
56422 + }
56423 + read_unlock(&tasklist_lock);
56424 + rcu_read_unlock();
56425 +
56426 + return 1;
56427 +}
56428 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
56429 new file mode 100644
56430 index 0000000..bc0be01
56431 --- /dev/null
56432 +++ b/grsecurity/grsec_chdir.c
56433 @@ -0,0 +1,19 @@
56434 +#include <linux/kernel.h>
56435 +#include <linux/sched.h>
56436 +#include <linux/fs.h>
56437 +#include <linux/file.h>
56438 +#include <linux/grsecurity.h>
56439 +#include <linux/grinternal.h>
56440 +
56441 +void
56442 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
56443 +{
56444 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
56445 + if ((grsec_enable_chdir && grsec_enable_group &&
56446 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
56447 + !grsec_enable_group)) {
56448 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
56449 + }
56450 +#endif
56451 + return;
56452 +}
56453 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
56454 new file mode 100644
56455 index 0000000..9807ee2
56456 --- /dev/null
56457 +++ b/grsecurity/grsec_chroot.c
56458 @@ -0,0 +1,368 @@
56459 +#include <linux/kernel.h>
56460 +#include <linux/module.h>
56461 +#include <linux/sched.h>
56462 +#include <linux/file.h>
56463 +#include <linux/fs.h>
56464 +#include <linux/mount.h>
56465 +#include <linux/types.h>
56466 +#include "../fs/mount.h"
56467 +#include <linux/grsecurity.h>
56468 +#include <linux/grinternal.h>
56469 +
56470 +void gr_set_chroot_entries(struct task_struct *task, struct path *path)
56471 +{
56472 +#ifdef CONFIG_GRKERNSEC
56473 + if (task->pid > 1 && path->dentry != init_task.fs->root.dentry &&
56474 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root)
56475 + task->gr_is_chrooted = 1;
56476 + else
56477 + task->gr_is_chrooted = 0;
56478 +
56479 + task->gr_chroot_dentry = path->dentry;
56480 +#endif
56481 + return;
56482 +}
56483 +
56484 +void gr_clear_chroot_entries(struct task_struct *task)
56485 +{
56486 +#ifdef CONFIG_GRKERNSEC
56487 + task->gr_is_chrooted = 0;
56488 + task->gr_chroot_dentry = NULL;
56489 +#endif
56490 + return;
56491 +}
56492 +
56493 +int
56494 +gr_handle_chroot_unix(const pid_t pid)
56495 +{
56496 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
56497 + struct task_struct *p;
56498 +
56499 + if (unlikely(!grsec_enable_chroot_unix))
56500 + return 1;
56501 +
56502 + if (likely(!proc_is_chrooted(current)))
56503 + return 1;
56504 +
56505 + rcu_read_lock();
56506 + read_lock(&tasklist_lock);
56507 + p = find_task_by_vpid_unrestricted(pid);
56508 + if (unlikely(p && !have_same_root(current, p))) {
56509 + read_unlock(&tasklist_lock);
56510 + rcu_read_unlock();
56511 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
56512 + return 0;
56513 + }
56514 + read_unlock(&tasklist_lock);
56515 + rcu_read_unlock();
56516 +#endif
56517 + return 1;
56518 +}
56519 +
56520 +int
56521 +gr_handle_chroot_nice(void)
56522 +{
56523 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
56524 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
56525 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
56526 + return -EPERM;
56527 + }
56528 +#endif
56529 + return 0;
56530 +}
56531 +
56532 +int
56533 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
56534 +{
56535 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
56536 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
56537 + && proc_is_chrooted(current)) {
56538 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, p->pid);
56539 + return -EACCES;
56540 + }
56541 +#endif
56542 + return 0;
56543 +}
56544 +
56545 +int
56546 +gr_handle_chroot_rawio(const struct inode *inode)
56547 +{
56548 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
56549 + if (grsec_enable_chroot_caps && proc_is_chrooted(current) &&
56550 + inode && S_ISBLK(inode->i_mode) && !capable(CAP_SYS_RAWIO))
56551 + return 1;
56552 +#endif
56553 + return 0;
56554 +}
56555 +
56556 +int
56557 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
56558 +{
56559 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
56560 + struct task_struct *p;
56561 + int ret = 0;
56562 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
56563 + return ret;
56564 +
56565 + read_lock(&tasklist_lock);
56566 + do_each_pid_task(pid, type, p) {
56567 + if (!have_same_root(current, p)) {
56568 + ret = 1;
56569 + goto out;
56570 + }
56571 + } while_each_pid_task(pid, type, p);
56572 +out:
56573 + read_unlock(&tasklist_lock);
56574 + return ret;
56575 +#endif
56576 + return 0;
56577 +}
56578 +
56579 +int
56580 +gr_pid_is_chrooted(struct task_struct *p)
56581 +{
56582 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
56583 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
56584 + return 0;
56585 +
56586 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
56587 + !have_same_root(current, p)) {
56588 + return 1;
56589 + }
56590 +#endif
56591 + return 0;
56592 +}
56593 +
56594 +EXPORT_SYMBOL(gr_pid_is_chrooted);
56595 +
56596 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
56597 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
56598 +{
56599 + struct path path, currentroot;
56600 + int ret = 0;
56601 +
56602 + path.dentry = (struct dentry *)u_dentry;
56603 + path.mnt = (struct vfsmount *)u_mnt;
56604 + get_fs_root(current->fs, &currentroot);
56605 + if (path_is_under(&path, &currentroot))
56606 + ret = 1;
56607 + path_put(&currentroot);
56608 +
56609 + return ret;
56610 +}
56611 +#endif
56612 +
56613 +int
56614 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
56615 +{
56616 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
56617 + if (!grsec_enable_chroot_fchdir)
56618 + return 1;
56619 +
56620 + if (!proc_is_chrooted(current))
56621 + return 1;
56622 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
56623 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
56624 + return 0;
56625 + }
56626 +#endif
56627 + return 1;
56628 +}
56629 +
56630 +int
56631 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
56632 + const time_t shm_createtime)
56633 +{
56634 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
56635 + struct task_struct *p;
56636 + time_t starttime;
56637 +
56638 + if (unlikely(!grsec_enable_chroot_shmat))
56639 + return 1;
56640 +
56641 + if (likely(!proc_is_chrooted(current)))
56642 + return 1;
56643 +
56644 + rcu_read_lock();
56645 + read_lock(&tasklist_lock);
56646 +
56647 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
56648 + starttime = p->start_time.tv_sec;
56649 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
56650 + if (have_same_root(current, p)) {
56651 + goto allow;
56652 + } else {
56653 + read_unlock(&tasklist_lock);
56654 + rcu_read_unlock();
56655 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
56656 + return 0;
56657 + }
56658 + }
56659 + /* creator exited, pid reuse, fall through to next check */
56660 + }
56661 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
56662 + if (unlikely(!have_same_root(current, p))) {
56663 + read_unlock(&tasklist_lock);
56664 + rcu_read_unlock();
56665 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
56666 + return 0;
56667 + }
56668 + }
56669 +
56670 +allow:
56671 + read_unlock(&tasklist_lock);
56672 + rcu_read_unlock();
56673 +#endif
56674 + return 1;
56675 +}
56676 +
56677 +void
56678 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
56679 +{
56680 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
56681 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
56682 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
56683 +#endif
56684 + return;
56685 +}
56686 +
56687 +int
56688 +gr_handle_chroot_mknod(const struct dentry *dentry,
56689 + const struct vfsmount *mnt, const int mode)
56690 +{
56691 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
56692 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
56693 + proc_is_chrooted(current)) {
56694 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
56695 + return -EPERM;
56696 + }
56697 +#endif
56698 + return 0;
56699 +}
56700 +
56701 +int
56702 +gr_handle_chroot_mount(const struct dentry *dentry,
56703 + const struct vfsmount *mnt, const char *dev_name)
56704 +{
56705 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
56706 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
56707 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
56708 + return -EPERM;
56709 + }
56710 +#endif
56711 + return 0;
56712 +}
56713 +
56714 +int
56715 +gr_handle_chroot_pivot(void)
56716 +{
56717 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
56718 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
56719 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
56720 + return -EPERM;
56721 + }
56722 +#endif
56723 + return 0;
56724 +}
56725 +
56726 +int
56727 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
56728 +{
56729 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
56730 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
56731 + !gr_is_outside_chroot(dentry, mnt)) {
56732 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
56733 + return -EPERM;
56734 + }
56735 +#endif
56736 + return 0;
56737 +}
56738 +
56739 +extern const char *captab_log[];
56740 +extern int captab_log_entries;
56741 +
56742 +int
56743 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
56744 +{
56745 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
56746 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
56747 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
56748 + if (cap_raised(chroot_caps, cap)) {
56749 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
56750 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
56751 + }
56752 + return 0;
56753 + }
56754 + }
56755 +#endif
56756 + return 1;
56757 +}
56758 +
56759 +int
56760 +gr_chroot_is_capable(const int cap)
56761 +{
56762 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
56763 + return gr_task_chroot_is_capable(current, current_cred(), cap);
56764 +#endif
56765 + return 1;
56766 +}
56767 +
56768 +int
56769 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
56770 +{
56771 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
56772 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
56773 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
56774 + if (cap_raised(chroot_caps, cap)) {
56775 + return 0;
56776 + }
56777 + }
56778 +#endif
56779 + return 1;
56780 +}
56781 +
56782 +int
56783 +gr_chroot_is_capable_nolog(const int cap)
56784 +{
56785 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
56786 + return gr_task_chroot_is_capable_nolog(current, cap);
56787 +#endif
56788 + return 1;
56789 +}
56790 +
56791 +int
56792 +gr_handle_chroot_sysctl(const int op)
56793 +{
56794 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
56795 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
56796 + proc_is_chrooted(current))
56797 + return -EACCES;
56798 +#endif
56799 + return 0;
56800 +}
56801 +
56802 +void
56803 +gr_handle_chroot_chdir(struct path *path)
56804 +{
56805 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
56806 + if (grsec_enable_chroot_chdir)
56807 + set_fs_pwd(current->fs, path);
56808 +#endif
56809 + return;
56810 +}
56811 +
56812 +int
56813 +gr_handle_chroot_chmod(const struct dentry *dentry,
56814 + const struct vfsmount *mnt, const int mode)
56815 +{
56816 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
56817 + /* allow chmod +s on directories, but not files */
56818 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
56819 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
56820 + proc_is_chrooted(current)) {
56821 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
56822 + return -EPERM;
56823 + }
56824 +#endif
56825 + return 0;
56826 +}
56827 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
56828 new file mode 100644
56829 index 0000000..213ad8b
56830 --- /dev/null
56831 +++ b/grsecurity/grsec_disabled.c
56832 @@ -0,0 +1,437 @@
56833 +#include <linux/kernel.h>
56834 +#include <linux/module.h>
56835 +#include <linux/sched.h>
56836 +#include <linux/file.h>
56837 +#include <linux/fs.h>
56838 +#include <linux/kdev_t.h>
56839 +#include <linux/net.h>
56840 +#include <linux/in.h>
56841 +#include <linux/ip.h>
56842 +#include <linux/skbuff.h>
56843 +#include <linux/sysctl.h>
56844 +
56845 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
56846 +void
56847 +pax_set_initial_flags(struct linux_binprm *bprm)
56848 +{
56849 + return;
56850 +}
56851 +#endif
56852 +
56853 +#ifdef CONFIG_SYSCTL
56854 +__u32
56855 +gr_handle_sysctl(const struct ctl_table * table, const int op)
56856 +{
56857 + return 0;
56858 +}
56859 +#endif
56860 +
56861 +#ifdef CONFIG_TASKSTATS
56862 +int gr_is_taskstats_denied(int pid)
56863 +{
56864 + return 0;
56865 +}
56866 +#endif
56867 +
56868 +int
56869 +gr_acl_is_enabled(void)
56870 +{
56871 + return 0;
56872 +}
56873 +
56874 +void
56875 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
56876 +{
56877 + return;
56878 +}
56879 +
56880 +int
56881 +gr_handle_rawio(const struct inode *inode)
56882 +{
56883 + return 0;
56884 +}
56885 +
56886 +void
56887 +gr_acl_handle_psacct(struct task_struct *task, const long code)
56888 +{
56889 + return;
56890 +}
56891 +
56892 +int
56893 +gr_handle_ptrace(struct task_struct *task, const long request)
56894 +{
56895 + return 0;
56896 +}
56897 +
56898 +int
56899 +gr_handle_proc_ptrace(struct task_struct *task)
56900 +{
56901 + return 0;
56902 +}
56903 +
56904 +void
56905 +gr_learn_resource(const struct task_struct *task,
56906 + const int res, const unsigned long wanted, const int gt)
56907 +{
56908 + return;
56909 +}
56910 +
56911 +int
56912 +gr_set_acls(const int type)
56913 +{
56914 + return 0;
56915 +}
56916 +
56917 +int
56918 +gr_check_hidden_task(const struct task_struct *tsk)
56919 +{
56920 + return 0;
56921 +}
56922 +
56923 +int
56924 +gr_check_protected_task(const struct task_struct *task)
56925 +{
56926 + return 0;
56927 +}
56928 +
56929 +int
56930 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
56931 +{
56932 + return 0;
56933 +}
56934 +
56935 +void
56936 +gr_copy_label(struct task_struct *tsk)
56937 +{
56938 + return;
56939 +}
56940 +
56941 +void
56942 +gr_set_pax_flags(struct task_struct *task)
56943 +{
56944 + return;
56945 +}
56946 +
56947 +int
56948 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
56949 + const int unsafe_share)
56950 +{
56951 + return 0;
56952 +}
56953 +
56954 +void
56955 +gr_handle_delete(const ino_t ino, const dev_t dev)
56956 +{
56957 + return;
56958 +}
56959 +
56960 +void
56961 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
56962 +{
56963 + return;
56964 +}
56965 +
56966 +void
56967 +gr_handle_crash(struct task_struct *task, const int sig)
56968 +{
56969 + return;
56970 +}
56971 +
56972 +int
56973 +gr_check_crash_exec(const struct file *filp)
56974 +{
56975 + return 0;
56976 +}
56977 +
56978 +int
56979 +gr_check_crash_uid(const uid_t uid)
56980 +{
56981 + return 0;
56982 +}
56983 +
56984 +void
56985 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
56986 + struct dentry *old_dentry,
56987 + struct dentry *new_dentry,
56988 + struct vfsmount *mnt, const __u8 replace)
56989 +{
56990 + return;
56991 +}
56992 +
56993 +int
56994 +gr_search_socket(const int family, const int type, const int protocol)
56995 +{
56996 + return 1;
56997 +}
56998 +
56999 +int
57000 +gr_search_connectbind(const int mode, const struct socket *sock,
57001 + const struct sockaddr_in *addr)
57002 +{
57003 + return 0;
57004 +}
57005 +
57006 +void
57007 +gr_handle_alertkill(struct task_struct *task)
57008 +{
57009 + return;
57010 +}
57011 +
57012 +__u32
57013 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
57014 +{
57015 + return 1;
57016 +}
57017 +
57018 +__u32
57019 +gr_acl_handle_hidden_file(const struct dentry * dentry,
57020 + const struct vfsmount * mnt)
57021 +{
57022 + return 1;
57023 +}
57024 +
57025 +__u32
57026 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
57027 + int acc_mode)
57028 +{
57029 + return 1;
57030 +}
57031 +
57032 +__u32
57033 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
57034 +{
57035 + return 1;
57036 +}
57037 +
57038 +__u32
57039 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
57040 +{
57041 + return 1;
57042 +}
57043 +
57044 +int
57045 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
57046 + unsigned int *vm_flags)
57047 +{
57048 + return 1;
57049 +}
57050 +
57051 +__u32
57052 +gr_acl_handle_truncate(const struct dentry * dentry,
57053 + const struct vfsmount * mnt)
57054 +{
57055 + return 1;
57056 +}
57057 +
57058 +__u32
57059 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
57060 +{
57061 + return 1;
57062 +}
57063 +
57064 +__u32
57065 +gr_acl_handle_access(const struct dentry * dentry,
57066 + const struct vfsmount * mnt, const int fmode)
57067 +{
57068 + return 1;
57069 +}
57070 +
57071 +__u32
57072 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
57073 + umode_t *mode)
57074 +{
57075 + return 1;
57076 +}
57077 +
57078 +__u32
57079 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
57080 +{
57081 + return 1;
57082 +}
57083 +
57084 +__u32
57085 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
57086 +{
57087 + return 1;
57088 +}
57089 +
57090 +void
57091 +grsecurity_init(void)
57092 +{
57093 + return;
57094 +}
57095 +
57096 +umode_t gr_acl_umask(void)
57097 +{
57098 + return 0;
57099 +}
57100 +
57101 +__u32
57102 +gr_acl_handle_mknod(const struct dentry * new_dentry,
57103 + const struct dentry * parent_dentry,
57104 + const struct vfsmount * parent_mnt,
57105 + const int mode)
57106 +{
57107 + return 1;
57108 +}
57109 +
57110 +__u32
57111 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
57112 + const struct dentry * parent_dentry,
57113 + const struct vfsmount * parent_mnt)
57114 +{
57115 + return 1;
57116 +}
57117 +
57118 +__u32
57119 +gr_acl_handle_symlink(const struct dentry * new_dentry,
57120 + const struct dentry * parent_dentry,
57121 + const struct vfsmount * parent_mnt, const char *from)
57122 +{
57123 + return 1;
57124 +}
57125 +
57126 +__u32
57127 +gr_acl_handle_link(const struct dentry * new_dentry,
57128 + const struct dentry * parent_dentry,
57129 + const struct vfsmount * parent_mnt,
57130 + const struct dentry * old_dentry,
57131 + const struct vfsmount * old_mnt, const char *to)
57132 +{
57133 + return 1;
57134 +}
57135 +
57136 +int
57137 +gr_acl_handle_rename(const struct dentry *new_dentry,
57138 + const struct dentry *parent_dentry,
57139 + const struct vfsmount *parent_mnt,
57140 + const struct dentry *old_dentry,
57141 + const struct inode *old_parent_inode,
57142 + const struct vfsmount *old_mnt, const char *newname)
57143 +{
57144 + return 0;
57145 +}
57146 +
57147 +int
57148 +gr_acl_handle_filldir(const struct file *file, const char *name,
57149 + const int namelen, const ino_t ino)
57150 +{
57151 + return 1;
57152 +}
57153 +
57154 +int
57155 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
57156 + const time_t shm_createtime, const uid_t cuid, const int shmid)
57157 +{
57158 + return 1;
57159 +}
57160 +
57161 +int
57162 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
57163 +{
57164 + return 0;
57165 +}
57166 +
57167 +int
57168 +gr_search_accept(const struct socket *sock)
57169 +{
57170 + return 0;
57171 +}
57172 +
57173 +int
57174 +gr_search_listen(const struct socket *sock)
57175 +{
57176 + return 0;
57177 +}
57178 +
57179 +int
57180 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
57181 +{
57182 + return 0;
57183 +}
57184 +
57185 +__u32
57186 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
57187 +{
57188 + return 1;
57189 +}
57190 +
57191 +__u32
57192 +gr_acl_handle_creat(const struct dentry * dentry,
57193 + const struct dentry * p_dentry,
57194 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
57195 + const int imode)
57196 +{
57197 + return 1;
57198 +}
57199 +
57200 +void
57201 +gr_acl_handle_exit(void)
57202 +{
57203 + return;
57204 +}
57205 +
57206 +int
57207 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
57208 +{
57209 + return 1;
57210 +}
57211 +
57212 +void
57213 +gr_set_role_label(const uid_t uid, const gid_t gid)
57214 +{
57215 + return;
57216 +}
57217 +
57218 +int
57219 +gr_acl_handle_procpidmem(const struct task_struct *task)
57220 +{
57221 + return 0;
57222 +}
57223 +
57224 +int
57225 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
57226 +{
57227 + return 0;
57228 +}
57229 +
57230 +int
57231 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
57232 +{
57233 + return 0;
57234 +}
57235 +
57236 +void
57237 +gr_set_kernel_label(struct task_struct *task)
57238 +{
57239 + return;
57240 +}
57241 +
57242 +int
57243 +gr_check_user_change(int real, int effective, int fs)
57244 +{
57245 + return 0;
57246 +}
57247 +
57248 +int
57249 +gr_check_group_change(int real, int effective, int fs)
57250 +{
57251 + return 0;
57252 +}
57253 +
57254 +int gr_acl_enable_at_secure(void)
57255 +{
57256 + return 0;
57257 +}
57258 +
57259 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
57260 +{
57261 + return dentry->d_inode->i_sb->s_dev;
57262 +}
57263 +
57264 +EXPORT_SYMBOL(gr_learn_resource);
57265 +EXPORT_SYMBOL(gr_set_kernel_label);
57266 +#ifdef CONFIG_SECURITY
57267 +EXPORT_SYMBOL(gr_check_user_change);
57268 +EXPORT_SYMBOL(gr_check_group_change);
57269 +#endif
57270 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
57271 new file mode 100644
57272 index 0000000..abfa971
57273 --- /dev/null
57274 +++ b/grsecurity/grsec_exec.c
57275 @@ -0,0 +1,174 @@
57276 +#include <linux/kernel.h>
57277 +#include <linux/sched.h>
57278 +#include <linux/file.h>
57279 +#include <linux/binfmts.h>
57280 +#include <linux/fs.h>
57281 +#include <linux/types.h>
57282 +#include <linux/grdefs.h>
57283 +#include <linux/grsecurity.h>
57284 +#include <linux/grinternal.h>
57285 +#include <linux/capability.h>
57286 +#include <linux/module.h>
57287 +
57288 +#include <asm/uaccess.h>
57289 +
57290 +#ifdef CONFIG_GRKERNSEC_EXECLOG
57291 +static char gr_exec_arg_buf[132];
57292 +static DEFINE_MUTEX(gr_exec_arg_mutex);
57293 +#endif
57294 +
57295 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
57296 +
57297 +void
57298 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
57299 +{
57300 +#ifdef CONFIG_GRKERNSEC_EXECLOG
57301 + char *grarg = gr_exec_arg_buf;
57302 + unsigned int i, x, execlen = 0;
57303 + char c;
57304 +
57305 + if (!((grsec_enable_execlog && grsec_enable_group &&
57306 + in_group_p(grsec_audit_gid))
57307 + || (grsec_enable_execlog && !grsec_enable_group)))
57308 + return;
57309 +
57310 + mutex_lock(&gr_exec_arg_mutex);
57311 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
57312 +
57313 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
57314 + const char __user *p;
57315 + unsigned int len;
57316 +
57317 + p = get_user_arg_ptr(argv, i);
57318 + if (IS_ERR(p))
57319 + goto log;
57320 +
57321 + len = strnlen_user(p, 128 - execlen);
57322 + if (len > 128 - execlen)
57323 + len = 128 - execlen;
57324 + else if (len > 0)
57325 + len--;
57326 + if (copy_from_user(grarg + execlen, p, len))
57327 + goto log;
57328 +
57329 + /* rewrite unprintable characters */
57330 + for (x = 0; x < len; x++) {
57331 + c = *(grarg + execlen + x);
57332 + if (c < 32 || c > 126)
57333 + *(grarg + execlen + x) = ' ';
57334 + }
57335 +
57336 + execlen += len;
57337 + *(grarg + execlen) = ' ';
57338 + *(grarg + execlen + 1) = '\0';
57339 + execlen++;
57340 + }
57341 +
57342 + log:
57343 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
57344 + bprm->file->f_path.mnt, grarg);
57345 + mutex_unlock(&gr_exec_arg_mutex);
57346 +#endif
57347 + return;
57348 +}
57349 +
57350 +#ifdef CONFIG_GRKERNSEC
57351 +extern int gr_acl_is_capable(const int cap);
57352 +extern int gr_acl_is_capable_nolog(const int cap);
57353 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
57354 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
57355 +extern int gr_chroot_is_capable(const int cap);
57356 +extern int gr_chroot_is_capable_nolog(const int cap);
57357 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
57358 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
57359 +#endif
57360 +
57361 +const char *captab_log[] = {
57362 + "CAP_CHOWN",
57363 + "CAP_DAC_OVERRIDE",
57364 + "CAP_DAC_READ_SEARCH",
57365 + "CAP_FOWNER",
57366 + "CAP_FSETID",
57367 + "CAP_KILL",
57368 + "CAP_SETGID",
57369 + "CAP_SETUID",
57370 + "CAP_SETPCAP",
57371 + "CAP_LINUX_IMMUTABLE",
57372 + "CAP_NET_BIND_SERVICE",
57373 + "CAP_NET_BROADCAST",
57374 + "CAP_NET_ADMIN",
57375 + "CAP_NET_RAW",
57376 + "CAP_IPC_LOCK",
57377 + "CAP_IPC_OWNER",
57378 + "CAP_SYS_MODULE",
57379 + "CAP_SYS_RAWIO",
57380 + "CAP_SYS_CHROOT",
57381 + "CAP_SYS_PTRACE",
57382 + "CAP_SYS_PACCT",
57383 + "CAP_SYS_ADMIN",
57384 + "CAP_SYS_BOOT",
57385 + "CAP_SYS_NICE",
57386 + "CAP_SYS_RESOURCE",
57387 + "CAP_SYS_TIME",
57388 + "CAP_SYS_TTY_CONFIG",
57389 + "CAP_MKNOD",
57390 + "CAP_LEASE",
57391 + "CAP_AUDIT_WRITE",
57392 + "CAP_AUDIT_CONTROL",
57393 + "CAP_SETFCAP",
57394 + "CAP_MAC_OVERRIDE",
57395 + "CAP_MAC_ADMIN",
57396 + "CAP_SYSLOG",
57397 + "CAP_WAKE_ALARM"
57398 +};
57399 +
57400 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
57401 +
57402 +int gr_is_capable(const int cap)
57403 +{
57404 +#ifdef CONFIG_GRKERNSEC
57405 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
57406 + return 1;
57407 + return 0;
57408 +#else
57409 + return 1;
57410 +#endif
57411 +}
57412 +
57413 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
57414 +{
57415 +#ifdef CONFIG_GRKERNSEC
57416 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
57417 + return 1;
57418 + return 0;
57419 +#else
57420 + return 1;
57421 +#endif
57422 +}
57423 +
57424 +int gr_is_capable_nolog(const int cap)
57425 +{
57426 +#ifdef CONFIG_GRKERNSEC
57427 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
57428 + return 1;
57429 + return 0;
57430 +#else
57431 + return 1;
57432 +#endif
57433 +}
57434 +
57435 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
57436 +{
57437 +#ifdef CONFIG_GRKERNSEC
57438 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
57439 + return 1;
57440 + return 0;
57441 +#else
57442 + return 1;
57443 +#endif
57444 +}
57445 +
57446 +EXPORT_SYMBOL(gr_is_capable);
57447 +EXPORT_SYMBOL(gr_is_capable_nolog);
57448 +EXPORT_SYMBOL(gr_task_is_capable);
57449 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
57450 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
57451 new file mode 100644
57452 index 0000000..d3ee748
57453 --- /dev/null
57454 +++ b/grsecurity/grsec_fifo.c
57455 @@ -0,0 +1,24 @@
57456 +#include <linux/kernel.h>
57457 +#include <linux/sched.h>
57458 +#include <linux/fs.h>
57459 +#include <linux/file.h>
57460 +#include <linux/grinternal.h>
57461 +
57462 +int
57463 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
57464 + const struct dentry *dir, const int flag, const int acc_mode)
57465 +{
57466 +#ifdef CONFIG_GRKERNSEC_FIFO
57467 + const struct cred *cred = current_cred();
57468 +
57469 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
57470 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
57471 + (dentry->d_inode->i_uid != dir->d_inode->i_uid) &&
57472 + (cred->fsuid != dentry->d_inode->i_uid)) {
57473 + if (!inode_permission(dentry->d_inode, acc_mode))
57474 + gr_log_fs_int2(GR_DONT_AUDIT, GR_FIFO_MSG, dentry, mnt, dentry->d_inode->i_uid, dentry->d_inode->i_gid);
57475 + return -EACCES;
57476 + }
57477 +#endif
57478 + return 0;
57479 +}
57480 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
57481 new file mode 100644
57482 index 0000000..8ca18bf
57483 --- /dev/null
57484 +++ b/grsecurity/grsec_fork.c
57485 @@ -0,0 +1,23 @@
57486 +#include <linux/kernel.h>
57487 +#include <linux/sched.h>
57488 +#include <linux/grsecurity.h>
57489 +#include <linux/grinternal.h>
57490 +#include <linux/errno.h>
57491 +
57492 +void
57493 +gr_log_forkfail(const int retval)
57494 +{
57495 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
57496 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
57497 + switch (retval) {
57498 + case -EAGAIN:
57499 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
57500 + break;
57501 + case -ENOMEM:
57502 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
57503 + break;
57504 + }
57505 + }
57506 +#endif
57507 + return;
57508 +}
57509 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
57510 new file mode 100644
57511 index 0000000..01ddde4
57512 --- /dev/null
57513 +++ b/grsecurity/grsec_init.c
57514 @@ -0,0 +1,277 @@
57515 +#include <linux/kernel.h>
57516 +#include <linux/sched.h>
57517 +#include <linux/mm.h>
57518 +#include <linux/gracl.h>
57519 +#include <linux/slab.h>
57520 +#include <linux/vmalloc.h>
57521 +#include <linux/percpu.h>
57522 +#include <linux/module.h>
57523 +
57524 +int grsec_enable_ptrace_readexec;
57525 +int grsec_enable_setxid;
57526 +int grsec_enable_brute;
57527 +int grsec_enable_link;
57528 +int grsec_enable_dmesg;
57529 +int grsec_enable_harden_ptrace;
57530 +int grsec_enable_fifo;
57531 +int grsec_enable_execlog;
57532 +int grsec_enable_signal;
57533 +int grsec_enable_forkfail;
57534 +int grsec_enable_audit_ptrace;
57535 +int grsec_enable_time;
57536 +int grsec_enable_audit_textrel;
57537 +int grsec_enable_group;
57538 +int grsec_audit_gid;
57539 +int grsec_enable_chdir;
57540 +int grsec_enable_mount;
57541 +int grsec_enable_rofs;
57542 +int grsec_enable_chroot_findtask;
57543 +int grsec_enable_chroot_mount;
57544 +int grsec_enable_chroot_shmat;
57545 +int grsec_enable_chroot_fchdir;
57546 +int grsec_enable_chroot_double;
57547 +int grsec_enable_chroot_pivot;
57548 +int grsec_enable_chroot_chdir;
57549 +int grsec_enable_chroot_chmod;
57550 +int grsec_enable_chroot_mknod;
57551 +int grsec_enable_chroot_nice;
57552 +int grsec_enable_chroot_execlog;
57553 +int grsec_enable_chroot_caps;
57554 +int grsec_enable_chroot_sysctl;
57555 +int grsec_enable_chroot_unix;
57556 +int grsec_enable_tpe;
57557 +int grsec_tpe_gid;
57558 +int grsec_enable_blackhole;
57559 +#ifdef CONFIG_IPV6_MODULE
57560 +EXPORT_SYMBOL(grsec_enable_blackhole);
57561 +#endif
57562 +int grsec_lastack_retries;
57563 +int grsec_enable_tpe_all;
57564 +int grsec_enable_tpe_invert;
57565 +int grsec_enable_socket_all;
57566 +int grsec_socket_all_gid;
57567 +int grsec_enable_socket_client;
57568 +int grsec_socket_client_gid;
57569 +int grsec_enable_socket_server;
57570 +int grsec_socket_server_gid;
57571 +int grsec_resource_logging;
57572 +int grsec_disable_privio;
57573 +int grsec_enable_log_rwxmaps;
57574 +int grsec_lock;
57575 +
57576 +DEFINE_SPINLOCK(grsec_alert_lock);
57577 +unsigned long grsec_alert_wtime = 0;
57578 +unsigned long grsec_alert_fyet = 0;
57579 +
57580 +DEFINE_SPINLOCK(grsec_audit_lock);
57581 +
57582 +DEFINE_RWLOCK(grsec_exec_file_lock);
57583 +
57584 +char *gr_shared_page[4];
57585 +
57586 +char *gr_alert_log_fmt;
57587 +char *gr_audit_log_fmt;
57588 +char *gr_alert_log_buf;
57589 +char *gr_audit_log_buf;
57590 +
57591 +extern struct gr_arg *gr_usermode;
57592 +extern unsigned char *gr_system_salt;
57593 +extern unsigned char *gr_system_sum;
57594 +
57595 +void __init
57596 +grsecurity_init(void)
57597 +{
57598 + int j;
57599 + /* create the per-cpu shared pages */
57600 +
57601 +#ifdef CONFIG_X86
57602 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
57603 +#endif
57604 +
57605 + for (j = 0; j < 4; j++) {
57606 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
57607 + if (gr_shared_page[j] == NULL) {
57608 + panic("Unable to allocate grsecurity shared page");
57609 + return;
57610 + }
57611 + }
57612 +
57613 + /* allocate log buffers */
57614 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
57615 + if (!gr_alert_log_fmt) {
57616 + panic("Unable to allocate grsecurity alert log format buffer");
57617 + return;
57618 + }
57619 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
57620 + if (!gr_audit_log_fmt) {
57621 + panic("Unable to allocate grsecurity audit log format buffer");
57622 + return;
57623 + }
57624 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
57625 + if (!gr_alert_log_buf) {
57626 + panic("Unable to allocate grsecurity alert log buffer");
57627 + return;
57628 + }
57629 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
57630 + if (!gr_audit_log_buf) {
57631 + panic("Unable to allocate grsecurity audit log buffer");
57632 + return;
57633 + }
57634 +
57635 + /* allocate memory for authentication structure */
57636 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
57637 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
57638 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
57639 +
57640 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
57641 + panic("Unable to allocate grsecurity authentication structure");
57642 + return;
57643 + }
57644 +
57645 +
57646 +#ifdef CONFIG_GRKERNSEC_IO
57647 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
57648 + grsec_disable_privio = 1;
57649 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
57650 + grsec_disable_privio = 1;
57651 +#else
57652 + grsec_disable_privio = 0;
57653 +#endif
57654 +#endif
57655 +
57656 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
57657 + /* for backward compatibility, tpe_invert always defaults to on if
57658 + enabled in the kernel
57659 + */
57660 + grsec_enable_tpe_invert = 1;
57661 +#endif
57662 +
57663 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
57664 +#ifndef CONFIG_GRKERNSEC_SYSCTL
57665 + grsec_lock = 1;
57666 +#endif
57667 +
57668 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
57669 + grsec_enable_audit_textrel = 1;
57670 +#endif
57671 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
57672 + grsec_enable_log_rwxmaps = 1;
57673 +#endif
57674 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
57675 + grsec_enable_group = 1;
57676 + grsec_audit_gid = CONFIG_GRKERNSEC_AUDIT_GID;
57677 +#endif
57678 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
57679 + grsec_enable_ptrace_readexec = 1;
57680 +#endif
57681 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
57682 + grsec_enable_chdir = 1;
57683 +#endif
57684 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
57685 + grsec_enable_harden_ptrace = 1;
57686 +#endif
57687 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
57688 + grsec_enable_mount = 1;
57689 +#endif
57690 +#ifdef CONFIG_GRKERNSEC_LINK
57691 + grsec_enable_link = 1;
57692 +#endif
57693 +#ifdef CONFIG_GRKERNSEC_BRUTE
57694 + grsec_enable_brute = 1;
57695 +#endif
57696 +#ifdef CONFIG_GRKERNSEC_DMESG
57697 + grsec_enable_dmesg = 1;
57698 +#endif
57699 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
57700 + grsec_enable_blackhole = 1;
57701 + grsec_lastack_retries = 4;
57702 +#endif
57703 +#ifdef CONFIG_GRKERNSEC_FIFO
57704 + grsec_enable_fifo = 1;
57705 +#endif
57706 +#ifdef CONFIG_GRKERNSEC_EXECLOG
57707 + grsec_enable_execlog = 1;
57708 +#endif
57709 +#ifdef CONFIG_GRKERNSEC_SETXID
57710 + grsec_enable_setxid = 1;
57711 +#endif
57712 +#ifdef CONFIG_GRKERNSEC_SIGNAL
57713 + grsec_enable_signal = 1;
57714 +#endif
57715 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
57716 + grsec_enable_forkfail = 1;
57717 +#endif
57718 +#ifdef CONFIG_GRKERNSEC_TIME
57719 + grsec_enable_time = 1;
57720 +#endif
57721 +#ifdef CONFIG_GRKERNSEC_RESLOG
57722 + grsec_resource_logging = 1;
57723 +#endif
57724 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
57725 + grsec_enable_chroot_findtask = 1;
57726 +#endif
57727 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
57728 + grsec_enable_chroot_unix = 1;
57729 +#endif
57730 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
57731 + grsec_enable_chroot_mount = 1;
57732 +#endif
57733 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
57734 + grsec_enable_chroot_fchdir = 1;
57735 +#endif
57736 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
57737 + grsec_enable_chroot_shmat = 1;
57738 +#endif
57739 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
57740 + grsec_enable_audit_ptrace = 1;
57741 +#endif
57742 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
57743 + grsec_enable_chroot_double = 1;
57744 +#endif
57745 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
57746 + grsec_enable_chroot_pivot = 1;
57747 +#endif
57748 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
57749 + grsec_enable_chroot_chdir = 1;
57750 +#endif
57751 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
57752 + grsec_enable_chroot_chmod = 1;
57753 +#endif
57754 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
57755 + grsec_enable_chroot_mknod = 1;
57756 +#endif
57757 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
57758 + grsec_enable_chroot_nice = 1;
57759 +#endif
57760 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
57761 + grsec_enable_chroot_execlog = 1;
57762 +#endif
57763 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
57764 + grsec_enable_chroot_caps = 1;
57765 +#endif
57766 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
57767 + grsec_enable_chroot_sysctl = 1;
57768 +#endif
57769 +#ifdef CONFIG_GRKERNSEC_TPE
57770 + grsec_enable_tpe = 1;
57771 + grsec_tpe_gid = CONFIG_GRKERNSEC_TPE_GID;
57772 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
57773 + grsec_enable_tpe_all = 1;
57774 +#endif
57775 +#endif
57776 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
57777 + grsec_enable_socket_all = 1;
57778 + grsec_socket_all_gid = CONFIG_GRKERNSEC_SOCKET_ALL_GID;
57779 +#endif
57780 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
57781 + grsec_enable_socket_client = 1;
57782 + grsec_socket_client_gid = CONFIG_GRKERNSEC_SOCKET_CLIENT_GID;
57783 +#endif
57784 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
57785 + grsec_enable_socket_server = 1;
57786 + grsec_socket_server_gid = CONFIG_GRKERNSEC_SOCKET_SERVER_GID;
57787 +#endif
57788 +#endif
57789 +
57790 + return;
57791 +}
57792 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
57793 new file mode 100644
57794 index 0000000..3efe141
57795 --- /dev/null
57796 +++ b/grsecurity/grsec_link.c
57797 @@ -0,0 +1,43 @@
57798 +#include <linux/kernel.h>
57799 +#include <linux/sched.h>
57800 +#include <linux/fs.h>
57801 +#include <linux/file.h>
57802 +#include <linux/grinternal.h>
57803 +
57804 +int
57805 +gr_handle_follow_link(const struct inode *parent,
57806 + const struct inode *inode,
57807 + const struct dentry *dentry, const struct vfsmount *mnt)
57808 +{
57809 +#ifdef CONFIG_GRKERNSEC_LINK
57810 + const struct cred *cred = current_cred();
57811 +
57812 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
57813 + (parent->i_mode & S_ISVTX) && (parent->i_uid != inode->i_uid) &&
57814 + (parent->i_mode & S_IWOTH) && (cred->fsuid != inode->i_uid)) {
57815 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
57816 + return -EACCES;
57817 + }
57818 +#endif
57819 + return 0;
57820 +}
57821 +
57822 +int
57823 +gr_handle_hardlink(const struct dentry *dentry,
57824 + const struct vfsmount *mnt,
57825 + struct inode *inode, const int mode, const char *to)
57826 +{
57827 +#ifdef CONFIG_GRKERNSEC_LINK
57828 + const struct cred *cred = current_cred();
57829 +
57830 + if (grsec_enable_link && cred->fsuid != inode->i_uid &&
57831 + (!S_ISREG(mode) || (mode & S_ISUID) ||
57832 + ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) ||
57833 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
57834 + !capable(CAP_FOWNER) && cred->uid) {
57835 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to);
57836 + return -EPERM;
57837 + }
57838 +#endif
57839 + return 0;
57840 +}
57841 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
57842 new file mode 100644
57843 index 0000000..a45d2e9
57844 --- /dev/null
57845 +++ b/grsecurity/grsec_log.c
57846 @@ -0,0 +1,322 @@
57847 +#include <linux/kernel.h>
57848 +#include <linux/sched.h>
57849 +#include <linux/file.h>
57850 +#include <linux/tty.h>
57851 +#include <linux/fs.h>
57852 +#include <linux/grinternal.h>
57853 +
57854 +#ifdef CONFIG_TREE_PREEMPT_RCU
57855 +#define DISABLE_PREEMPT() preempt_disable()
57856 +#define ENABLE_PREEMPT() preempt_enable()
57857 +#else
57858 +#define DISABLE_PREEMPT()
57859 +#define ENABLE_PREEMPT()
57860 +#endif
57861 +
57862 +#define BEGIN_LOCKS(x) \
57863 + DISABLE_PREEMPT(); \
57864 + rcu_read_lock(); \
57865 + read_lock(&tasklist_lock); \
57866 + read_lock(&grsec_exec_file_lock); \
57867 + if (x != GR_DO_AUDIT) \
57868 + spin_lock(&grsec_alert_lock); \
57869 + else \
57870 + spin_lock(&grsec_audit_lock)
57871 +
57872 +#define END_LOCKS(x) \
57873 + if (x != GR_DO_AUDIT) \
57874 + spin_unlock(&grsec_alert_lock); \
57875 + else \
57876 + spin_unlock(&grsec_audit_lock); \
57877 + read_unlock(&grsec_exec_file_lock); \
57878 + read_unlock(&tasklist_lock); \
57879 + rcu_read_unlock(); \
57880 + ENABLE_PREEMPT(); \
57881 + if (x == GR_DONT_AUDIT) \
57882 + gr_handle_alertkill(current)
57883 +
57884 +enum {
57885 + FLOODING,
57886 + NO_FLOODING
57887 +};
57888 +
57889 +extern char *gr_alert_log_fmt;
57890 +extern char *gr_audit_log_fmt;
57891 +extern char *gr_alert_log_buf;
57892 +extern char *gr_audit_log_buf;
57893 +
57894 +static int gr_log_start(int audit)
57895 +{
57896 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
57897 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
57898 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
57899 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
57900 + unsigned long curr_secs = get_seconds();
57901 +
57902 + if (audit == GR_DO_AUDIT)
57903 + goto set_fmt;
57904 +
57905 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
57906 + grsec_alert_wtime = curr_secs;
57907 + grsec_alert_fyet = 0;
57908 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
57909 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
57910 + grsec_alert_fyet++;
57911 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
57912 + grsec_alert_wtime = curr_secs;
57913 + grsec_alert_fyet++;
57914 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
57915 + return FLOODING;
57916 + }
57917 + else return FLOODING;
57918 +
57919 +set_fmt:
57920 +#endif
57921 + memset(buf, 0, PAGE_SIZE);
57922 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
57923 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
57924 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
57925 + } else if (current->signal->curr_ip) {
57926 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
57927 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
57928 + } else if (gr_acl_is_enabled()) {
57929 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
57930 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
57931 + } else {
57932 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
57933 + strcpy(buf, fmt);
57934 + }
57935 +
57936 + return NO_FLOODING;
57937 +}
57938 +
57939 +static void gr_log_middle(int audit, const char *msg, va_list ap)
57940 + __attribute__ ((format (printf, 2, 0)));
57941 +
57942 +static void gr_log_middle(int audit, const char *msg, va_list ap)
57943 +{
57944 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
57945 + unsigned int len = strlen(buf);
57946 +
57947 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
57948 +
57949 + return;
57950 +}
57951 +
57952 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
57953 + __attribute__ ((format (printf, 2, 3)));
57954 +
57955 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
57956 +{
57957 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
57958 + unsigned int len = strlen(buf);
57959 + va_list ap;
57960 +
57961 + va_start(ap, msg);
57962 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
57963 + va_end(ap);
57964 +
57965 + return;
57966 +}
57967 +
57968 +static void gr_log_end(int audit, int append_default)
57969 +{
57970 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
57971 +
57972 + if (append_default) {
57973 + unsigned int len = strlen(buf);
57974 + snprintf(buf + len, PAGE_SIZE - len - 1, DEFAULTSECMSG, DEFAULTSECARGS(current, current_cred(), __task_cred(current->real_parent)));
57975 + }
57976 +
57977 + printk("%s\n", buf);
57978 +
57979 + return;
57980 +}
57981 +
57982 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
57983 +{
57984 + int logtype;
57985 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
57986 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
57987 + void *voidptr = NULL;
57988 + int num1 = 0, num2 = 0;
57989 + unsigned long ulong1 = 0, ulong2 = 0;
57990 + struct dentry *dentry = NULL;
57991 + struct vfsmount *mnt = NULL;
57992 + struct file *file = NULL;
57993 + struct task_struct *task = NULL;
57994 + const struct cred *cred, *pcred;
57995 + va_list ap;
57996 +
57997 + BEGIN_LOCKS(audit);
57998 + logtype = gr_log_start(audit);
57999 + if (logtype == FLOODING) {
58000 + END_LOCKS(audit);
58001 + return;
58002 + }
58003 + va_start(ap, argtypes);
58004 + switch (argtypes) {
58005 + case GR_TTYSNIFF:
58006 + task = va_arg(ap, struct task_struct *);
58007 + 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);
58008 + break;
58009 + case GR_SYSCTL_HIDDEN:
58010 + str1 = va_arg(ap, char *);
58011 + gr_log_middle_varargs(audit, msg, result, str1);
58012 + break;
58013 + case GR_RBAC:
58014 + dentry = va_arg(ap, struct dentry *);
58015 + mnt = va_arg(ap, struct vfsmount *);
58016 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
58017 + break;
58018 + case GR_RBAC_STR:
58019 + dentry = va_arg(ap, struct dentry *);
58020 + mnt = va_arg(ap, struct vfsmount *);
58021 + str1 = va_arg(ap, char *);
58022 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
58023 + break;
58024 + case GR_STR_RBAC:
58025 + str1 = va_arg(ap, char *);
58026 + dentry = va_arg(ap, struct dentry *);
58027 + mnt = va_arg(ap, struct vfsmount *);
58028 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
58029 + break;
58030 + case GR_RBAC_MODE2:
58031 + dentry = va_arg(ap, struct dentry *);
58032 + mnt = va_arg(ap, struct vfsmount *);
58033 + str1 = va_arg(ap, char *);
58034 + str2 = va_arg(ap, char *);
58035 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
58036 + break;
58037 + case GR_RBAC_MODE3:
58038 + dentry = va_arg(ap, struct dentry *);
58039 + mnt = va_arg(ap, struct vfsmount *);
58040 + str1 = va_arg(ap, char *);
58041 + str2 = va_arg(ap, char *);
58042 + str3 = va_arg(ap, char *);
58043 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
58044 + break;
58045 + case GR_FILENAME:
58046 + dentry = va_arg(ap, struct dentry *);
58047 + mnt = va_arg(ap, struct vfsmount *);
58048 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
58049 + break;
58050 + case GR_STR_FILENAME:
58051 + str1 = va_arg(ap, char *);
58052 + dentry = va_arg(ap, struct dentry *);
58053 + mnt = va_arg(ap, struct vfsmount *);
58054 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
58055 + break;
58056 + case GR_FILENAME_STR:
58057 + dentry = va_arg(ap, struct dentry *);
58058 + mnt = va_arg(ap, struct vfsmount *);
58059 + str1 = va_arg(ap, char *);
58060 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
58061 + break;
58062 + case GR_FILENAME_TWO_INT:
58063 + dentry = va_arg(ap, struct dentry *);
58064 + mnt = va_arg(ap, struct vfsmount *);
58065 + num1 = va_arg(ap, int);
58066 + num2 = va_arg(ap, int);
58067 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
58068 + break;
58069 + case GR_FILENAME_TWO_INT_STR:
58070 + dentry = va_arg(ap, struct dentry *);
58071 + mnt = va_arg(ap, struct vfsmount *);
58072 + num1 = va_arg(ap, int);
58073 + num2 = va_arg(ap, int);
58074 + str1 = va_arg(ap, char *);
58075 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
58076 + break;
58077 + case GR_TEXTREL:
58078 + file = va_arg(ap, struct file *);
58079 + ulong1 = va_arg(ap, unsigned long);
58080 + ulong2 = va_arg(ap, unsigned long);
58081 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
58082 + break;
58083 + case GR_PTRACE:
58084 + task = va_arg(ap, struct task_struct *);
58085 + 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);
58086 + break;
58087 + case GR_RESOURCE:
58088 + task = va_arg(ap, struct task_struct *);
58089 + cred = __task_cred(task);
58090 + pcred = __task_cred(task->real_parent);
58091 + ulong1 = va_arg(ap, unsigned long);
58092 + str1 = va_arg(ap, char *);
58093 + ulong2 = va_arg(ap, unsigned long);
58094 + 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);
58095 + break;
58096 + case GR_CAP:
58097 + task = va_arg(ap, struct task_struct *);
58098 + cred = __task_cred(task);
58099 + pcred = __task_cred(task->real_parent);
58100 + str1 = va_arg(ap, char *);
58101 + 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);
58102 + break;
58103 + case GR_SIG:
58104 + str1 = va_arg(ap, char *);
58105 + voidptr = va_arg(ap, void *);
58106 + gr_log_middle_varargs(audit, msg, str1, voidptr);
58107 + break;
58108 + case GR_SIG2:
58109 + task = va_arg(ap, struct task_struct *);
58110 + cred = __task_cred(task);
58111 + pcred = __task_cred(task->real_parent);
58112 + num1 = va_arg(ap, int);
58113 + 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);
58114 + break;
58115 + case GR_CRASH1:
58116 + task = va_arg(ap, struct task_struct *);
58117 + cred = __task_cred(task);
58118 + pcred = __task_cred(task->real_parent);
58119 + ulong1 = va_arg(ap, unsigned long);
58120 + 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);
58121 + break;
58122 + case GR_CRASH2:
58123 + task = va_arg(ap, struct task_struct *);
58124 + cred = __task_cred(task);
58125 + pcred = __task_cred(task->real_parent);
58126 + ulong1 = va_arg(ap, unsigned long);
58127 + 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);
58128 + break;
58129 + case GR_RWXMAP:
58130 + file = va_arg(ap, struct file *);
58131 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
58132 + break;
58133 + case GR_PSACCT:
58134 + {
58135 + unsigned int wday, cday;
58136 + __u8 whr, chr;
58137 + __u8 wmin, cmin;
58138 + __u8 wsec, csec;
58139 + char cur_tty[64] = { 0 };
58140 + char parent_tty[64] = { 0 };
58141 +
58142 + task = va_arg(ap, struct task_struct *);
58143 + wday = va_arg(ap, unsigned int);
58144 + cday = va_arg(ap, unsigned int);
58145 + whr = va_arg(ap, int);
58146 + chr = va_arg(ap, int);
58147 + wmin = va_arg(ap, int);
58148 + cmin = va_arg(ap, int);
58149 + wsec = va_arg(ap, int);
58150 + csec = va_arg(ap, int);
58151 + ulong1 = va_arg(ap, unsigned long);
58152 + cred = __task_cred(task);
58153 + pcred = __task_cred(task->real_parent);
58154 +
58155 + 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);
58156 + }
58157 + break;
58158 + default:
58159 + gr_log_middle(audit, msg, ap);
58160 + }
58161 + va_end(ap);
58162 + // these don't need DEFAULTSECARGS printed on the end
58163 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
58164 + gr_log_end(audit, 0);
58165 + else
58166 + gr_log_end(audit, 1);
58167 + END_LOCKS(audit);
58168 +}
58169 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
58170 new file mode 100644
58171 index 0000000..f536303
58172 --- /dev/null
58173 +++ b/grsecurity/grsec_mem.c
58174 @@ -0,0 +1,40 @@
58175 +#include <linux/kernel.h>
58176 +#include <linux/sched.h>
58177 +#include <linux/mm.h>
58178 +#include <linux/mman.h>
58179 +#include <linux/grinternal.h>
58180 +
58181 +void
58182 +gr_handle_ioperm(void)
58183 +{
58184 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
58185 + return;
58186 +}
58187 +
58188 +void
58189 +gr_handle_iopl(void)
58190 +{
58191 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
58192 + return;
58193 +}
58194 +
58195 +void
58196 +gr_handle_mem_readwrite(u64 from, u64 to)
58197 +{
58198 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
58199 + return;
58200 +}
58201 +
58202 +void
58203 +gr_handle_vm86(void)
58204 +{
58205 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
58206 + return;
58207 +}
58208 +
58209 +void
58210 +gr_log_badprocpid(const char *entry)
58211 +{
58212 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
58213 + return;
58214 +}
58215 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
58216 new file mode 100644
58217 index 0000000..2131422
58218 --- /dev/null
58219 +++ b/grsecurity/grsec_mount.c
58220 @@ -0,0 +1,62 @@
58221 +#include <linux/kernel.h>
58222 +#include <linux/sched.h>
58223 +#include <linux/mount.h>
58224 +#include <linux/grsecurity.h>
58225 +#include <linux/grinternal.h>
58226 +
58227 +void
58228 +gr_log_remount(const char *devname, const int retval)
58229 +{
58230 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
58231 + if (grsec_enable_mount && (retval >= 0))
58232 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
58233 +#endif
58234 + return;
58235 +}
58236 +
58237 +void
58238 +gr_log_unmount(const char *devname, const int retval)
58239 +{
58240 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
58241 + if (grsec_enable_mount && (retval >= 0))
58242 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
58243 +#endif
58244 + return;
58245 +}
58246 +
58247 +void
58248 +gr_log_mount(const char *from, const char *to, const int retval)
58249 +{
58250 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
58251 + if (grsec_enable_mount && (retval >= 0))
58252 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
58253 +#endif
58254 + return;
58255 +}
58256 +
58257 +int
58258 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
58259 +{
58260 +#ifdef CONFIG_GRKERNSEC_ROFS
58261 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
58262 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
58263 + return -EPERM;
58264 + } else
58265 + return 0;
58266 +#endif
58267 + return 0;
58268 +}
58269 +
58270 +int
58271 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
58272 +{
58273 +#ifdef CONFIG_GRKERNSEC_ROFS
58274 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
58275 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
58276 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
58277 + return -EPERM;
58278 + } else
58279 + return 0;
58280 +#endif
58281 + return 0;
58282 +}
58283 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
58284 new file mode 100644
58285 index 0000000..a3b12a0
58286 --- /dev/null
58287 +++ b/grsecurity/grsec_pax.c
58288 @@ -0,0 +1,36 @@
58289 +#include <linux/kernel.h>
58290 +#include <linux/sched.h>
58291 +#include <linux/mm.h>
58292 +#include <linux/file.h>
58293 +#include <linux/grinternal.h>
58294 +#include <linux/grsecurity.h>
58295 +
58296 +void
58297 +gr_log_textrel(struct vm_area_struct * vma)
58298 +{
58299 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
58300 + if (grsec_enable_audit_textrel)
58301 + gr_log_textrel_ulong_ulong(GR_DO_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
58302 +#endif
58303 + return;
58304 +}
58305 +
58306 +void
58307 +gr_log_rwxmmap(struct file *file)
58308 +{
58309 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
58310 + if (grsec_enable_log_rwxmaps)
58311 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
58312 +#endif
58313 + return;
58314 +}
58315 +
58316 +void
58317 +gr_log_rwxmprotect(struct file *file)
58318 +{
58319 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
58320 + if (grsec_enable_log_rwxmaps)
58321 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, file);
58322 +#endif
58323 + return;
58324 +}
58325 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
58326 new file mode 100644
58327 index 0000000..f7f29aa
58328 --- /dev/null
58329 +++ b/grsecurity/grsec_ptrace.c
58330 @@ -0,0 +1,30 @@
58331 +#include <linux/kernel.h>
58332 +#include <linux/sched.h>
58333 +#include <linux/grinternal.h>
58334 +#include <linux/security.h>
58335 +
58336 +void
58337 +gr_audit_ptrace(struct task_struct *task)
58338 +{
58339 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
58340 + if (grsec_enable_audit_ptrace)
58341 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
58342 +#endif
58343 + return;
58344 +}
58345 +
58346 +int
58347 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
58348 +{
58349 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
58350 + const struct dentry *dentry = file->f_path.dentry;
58351 + const struct vfsmount *mnt = file->f_path.mnt;
58352 +
58353 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
58354 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
58355 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
58356 + return -EACCES;
58357 + }
58358 +#endif
58359 + return 0;
58360 +}
58361 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
58362 new file mode 100644
58363 index 0000000..7a5b2de
58364 --- /dev/null
58365 +++ b/grsecurity/grsec_sig.c
58366 @@ -0,0 +1,207 @@
58367 +#include <linux/kernel.h>
58368 +#include <linux/sched.h>
58369 +#include <linux/delay.h>
58370 +#include <linux/grsecurity.h>
58371 +#include <linux/grinternal.h>
58372 +#include <linux/hardirq.h>
58373 +
58374 +char *signames[] = {
58375 + [SIGSEGV] = "Segmentation fault",
58376 + [SIGILL] = "Illegal instruction",
58377 + [SIGABRT] = "Abort",
58378 + [SIGBUS] = "Invalid alignment/Bus error"
58379 +};
58380 +
58381 +void
58382 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
58383 +{
58384 +#ifdef CONFIG_GRKERNSEC_SIGNAL
58385 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
58386 + (sig == SIGABRT) || (sig == SIGBUS))) {
58387 + if (t->pid == current->pid) {
58388 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
58389 + } else {
58390 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
58391 + }
58392 + }
58393 +#endif
58394 + return;
58395 +}
58396 +
58397 +int
58398 +gr_handle_signal(const struct task_struct *p, const int sig)
58399 +{
58400 +#ifdef CONFIG_GRKERNSEC
58401 + /* ignore the 0 signal for protected task checks */
58402 + if (current->pid > 1 && sig && gr_check_protected_task(p)) {
58403 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
58404 + return -EPERM;
58405 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
58406 + return -EPERM;
58407 + }
58408 +#endif
58409 + return 0;
58410 +}
58411 +
58412 +#ifdef CONFIG_GRKERNSEC
58413 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
58414 +
58415 +int gr_fake_force_sig(int sig, struct task_struct *t)
58416 +{
58417 + unsigned long int flags;
58418 + int ret, blocked, ignored;
58419 + struct k_sigaction *action;
58420 +
58421 + spin_lock_irqsave(&t->sighand->siglock, flags);
58422 + action = &t->sighand->action[sig-1];
58423 + ignored = action->sa.sa_handler == SIG_IGN;
58424 + blocked = sigismember(&t->blocked, sig);
58425 + if (blocked || ignored) {
58426 + action->sa.sa_handler = SIG_DFL;
58427 + if (blocked) {
58428 + sigdelset(&t->blocked, sig);
58429 + recalc_sigpending_and_wake(t);
58430 + }
58431 + }
58432 + if (action->sa.sa_handler == SIG_DFL)
58433 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
58434 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
58435 +
58436 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
58437 +
58438 + return ret;
58439 +}
58440 +#endif
58441 +
58442 +#ifdef CONFIG_GRKERNSEC_BRUTE
58443 +#define GR_USER_BAN_TIME (15 * 60)
58444 +
58445 +static int __get_dumpable(unsigned long mm_flags)
58446 +{
58447 + int ret;
58448 +
58449 + ret = mm_flags & MMF_DUMPABLE_MASK;
58450 + return (ret >= 2) ? 2 : ret;
58451 +}
58452 +#endif
58453 +
58454 +void gr_handle_brute_attach(struct task_struct *p, unsigned long mm_flags)
58455 +{
58456 +#ifdef CONFIG_GRKERNSEC_BRUTE
58457 + uid_t uid = 0;
58458 +
58459 + if (!grsec_enable_brute)
58460 + return;
58461 +
58462 + rcu_read_lock();
58463 + read_lock(&tasklist_lock);
58464 + read_lock(&grsec_exec_file_lock);
58465 + if (p->real_parent && p->real_parent->exec_file == p->exec_file)
58466 + p->real_parent->brute = 1;
58467 + else {
58468 + const struct cred *cred = __task_cred(p), *cred2;
58469 + struct task_struct *tsk, *tsk2;
58470 +
58471 + if (!__get_dumpable(mm_flags) && cred->uid) {
58472 + struct user_struct *user;
58473 +
58474 + uid = cred->uid;
58475 +
58476 + /* this is put upon execution past expiration */
58477 + user = find_user(uid);
58478 + if (user == NULL)
58479 + goto unlock;
58480 + user->banned = 1;
58481 + user->ban_expires = get_seconds() + GR_USER_BAN_TIME;
58482 + if (user->ban_expires == ~0UL)
58483 + user->ban_expires--;
58484 +
58485 + do_each_thread(tsk2, tsk) {
58486 + cred2 = __task_cred(tsk);
58487 + if (tsk != p && cred2->uid == uid)
58488 + gr_fake_force_sig(SIGKILL, tsk);
58489 + } while_each_thread(tsk2, tsk);
58490 + }
58491 + }
58492 +unlock:
58493 + read_unlock(&grsec_exec_file_lock);
58494 + read_unlock(&tasklist_lock);
58495 + rcu_read_unlock();
58496 +
58497 + if (uid)
58498 + printk(KERN_ALERT "grsec: bruteforce prevention initiated against uid %u, banning for %d minutes\n", uid, GR_USER_BAN_TIME / 60);
58499 +
58500 +#endif
58501 + return;
58502 +}
58503 +
58504 +void gr_handle_brute_check(void)
58505 +{
58506 +#ifdef CONFIG_GRKERNSEC_BRUTE
58507 + if (current->brute)
58508 + msleep(30 * 1000);
58509 +#endif
58510 + return;
58511 +}
58512 +
58513 +void gr_handle_kernel_exploit(void)
58514 +{
58515 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
58516 + const struct cred *cred;
58517 + struct task_struct *tsk, *tsk2;
58518 + struct user_struct *user;
58519 + uid_t uid;
58520 +
58521 + if (in_irq() || in_serving_softirq() || in_nmi())
58522 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
58523 +
58524 + uid = current_uid();
58525 +
58526 + if (uid == 0)
58527 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
58528 + else {
58529 + /* kill all the processes of this user, hold a reference
58530 + to their creds struct, and prevent them from creating
58531 + another process until system reset
58532 + */
58533 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n", uid);
58534 + /* we intentionally leak this ref */
58535 + user = get_uid(current->cred->user);
58536 + if (user) {
58537 + user->banned = 1;
58538 + user->ban_expires = ~0UL;
58539 + }
58540 +
58541 + read_lock(&tasklist_lock);
58542 + do_each_thread(tsk2, tsk) {
58543 + cred = __task_cred(tsk);
58544 + if (cred->uid == uid)
58545 + gr_fake_force_sig(SIGKILL, tsk);
58546 + } while_each_thread(tsk2, tsk);
58547 + read_unlock(&tasklist_lock);
58548 + }
58549 +#endif
58550 +}
58551 +
58552 +int __gr_process_user_ban(struct user_struct *user)
58553 +{
58554 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
58555 + if (unlikely(user->banned)) {
58556 + if (user->ban_expires != ~0UL && time_after_eq(get_seconds(), user->ban_expires)) {
58557 + user->banned = 0;
58558 + user->ban_expires = 0;
58559 + free_uid(user);
58560 + } else
58561 + return -EPERM;
58562 + }
58563 +#endif
58564 + return 0;
58565 +}
58566 +
58567 +int gr_process_user_ban(void)
58568 +{
58569 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
58570 + return __gr_process_user_ban(current->cred->user);
58571 +#endif
58572 + return 0;
58573 +}
58574 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
58575 new file mode 100644
58576 index 0000000..4030d57
58577 --- /dev/null
58578 +++ b/grsecurity/grsec_sock.c
58579 @@ -0,0 +1,244 @@
58580 +#include <linux/kernel.h>
58581 +#include <linux/module.h>
58582 +#include <linux/sched.h>
58583 +#include <linux/file.h>
58584 +#include <linux/net.h>
58585 +#include <linux/in.h>
58586 +#include <linux/ip.h>
58587 +#include <net/sock.h>
58588 +#include <net/inet_sock.h>
58589 +#include <linux/grsecurity.h>
58590 +#include <linux/grinternal.h>
58591 +#include <linux/gracl.h>
58592 +
58593 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
58594 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
58595 +
58596 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
58597 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
58598 +
58599 +#ifdef CONFIG_UNIX_MODULE
58600 +EXPORT_SYMBOL(gr_acl_handle_unix);
58601 +EXPORT_SYMBOL(gr_acl_handle_mknod);
58602 +EXPORT_SYMBOL(gr_handle_chroot_unix);
58603 +EXPORT_SYMBOL(gr_handle_create);
58604 +#endif
58605 +
58606 +#ifdef CONFIG_GRKERNSEC
58607 +#define gr_conn_table_size 32749
58608 +struct conn_table_entry {
58609 + struct conn_table_entry *next;
58610 + struct signal_struct *sig;
58611 +};
58612 +
58613 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
58614 +DEFINE_SPINLOCK(gr_conn_table_lock);
58615 +
58616 +extern const char * gr_socktype_to_name(unsigned char type);
58617 +extern const char * gr_proto_to_name(unsigned char proto);
58618 +extern const char * gr_sockfamily_to_name(unsigned char family);
58619 +
58620 +static __inline__ int
58621 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
58622 +{
58623 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
58624 +}
58625 +
58626 +static __inline__ int
58627 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
58628 + __u16 sport, __u16 dport)
58629 +{
58630 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
58631 + sig->gr_sport == sport && sig->gr_dport == dport))
58632 + return 1;
58633 + else
58634 + return 0;
58635 +}
58636 +
58637 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
58638 +{
58639 + struct conn_table_entry **match;
58640 + unsigned int index;
58641 +
58642 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
58643 + sig->gr_sport, sig->gr_dport,
58644 + gr_conn_table_size);
58645 +
58646 + newent->sig = sig;
58647 +
58648 + match = &gr_conn_table[index];
58649 + newent->next = *match;
58650 + *match = newent;
58651 +
58652 + return;
58653 +}
58654 +
58655 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
58656 +{
58657 + struct conn_table_entry *match, *last = NULL;
58658 + unsigned int index;
58659 +
58660 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
58661 + sig->gr_sport, sig->gr_dport,
58662 + gr_conn_table_size);
58663 +
58664 + match = gr_conn_table[index];
58665 + while (match && !conn_match(match->sig,
58666 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
58667 + sig->gr_dport)) {
58668 + last = match;
58669 + match = match->next;
58670 + }
58671 +
58672 + if (match) {
58673 + if (last)
58674 + last->next = match->next;
58675 + else
58676 + gr_conn_table[index] = NULL;
58677 + kfree(match);
58678 + }
58679 +
58680 + return;
58681 +}
58682 +
58683 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
58684 + __u16 sport, __u16 dport)
58685 +{
58686 + struct conn_table_entry *match;
58687 + unsigned int index;
58688 +
58689 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
58690 +
58691 + match = gr_conn_table[index];
58692 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
58693 + match = match->next;
58694 +
58695 + if (match)
58696 + return match->sig;
58697 + else
58698 + return NULL;
58699 +}
58700 +
58701 +#endif
58702 +
58703 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
58704 +{
58705 +#ifdef CONFIG_GRKERNSEC
58706 + struct signal_struct *sig = task->signal;
58707 + struct conn_table_entry *newent;
58708 +
58709 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
58710 + if (newent == NULL)
58711 + return;
58712 + /* no bh lock needed since we are called with bh disabled */
58713 + spin_lock(&gr_conn_table_lock);
58714 + gr_del_task_from_ip_table_nolock(sig);
58715 + sig->gr_saddr = inet->inet_rcv_saddr;
58716 + sig->gr_daddr = inet->inet_daddr;
58717 + sig->gr_sport = inet->inet_sport;
58718 + sig->gr_dport = inet->inet_dport;
58719 + gr_add_to_task_ip_table_nolock(sig, newent);
58720 + spin_unlock(&gr_conn_table_lock);
58721 +#endif
58722 + return;
58723 +}
58724 +
58725 +void gr_del_task_from_ip_table(struct task_struct *task)
58726 +{
58727 +#ifdef CONFIG_GRKERNSEC
58728 + spin_lock_bh(&gr_conn_table_lock);
58729 + gr_del_task_from_ip_table_nolock(task->signal);
58730 + spin_unlock_bh(&gr_conn_table_lock);
58731 +#endif
58732 + return;
58733 +}
58734 +
58735 +void
58736 +gr_attach_curr_ip(const struct sock *sk)
58737 +{
58738 +#ifdef CONFIG_GRKERNSEC
58739 + struct signal_struct *p, *set;
58740 + const struct inet_sock *inet = inet_sk(sk);
58741 +
58742 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
58743 + return;
58744 +
58745 + set = current->signal;
58746 +
58747 + spin_lock_bh(&gr_conn_table_lock);
58748 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
58749 + inet->inet_dport, inet->inet_sport);
58750 + if (unlikely(p != NULL)) {
58751 + set->curr_ip = p->curr_ip;
58752 + set->used_accept = 1;
58753 + gr_del_task_from_ip_table_nolock(p);
58754 + spin_unlock_bh(&gr_conn_table_lock);
58755 + return;
58756 + }
58757 + spin_unlock_bh(&gr_conn_table_lock);
58758 +
58759 + set->curr_ip = inet->inet_daddr;
58760 + set->used_accept = 1;
58761 +#endif
58762 + return;
58763 +}
58764 +
58765 +int
58766 +gr_handle_sock_all(const int family, const int type, const int protocol)
58767 +{
58768 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
58769 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
58770 + (family != AF_UNIX)) {
58771 + if (family == AF_INET)
58772 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
58773 + else
58774 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
58775 + return -EACCES;
58776 + }
58777 +#endif
58778 + return 0;
58779 +}
58780 +
58781 +int
58782 +gr_handle_sock_server(const struct sockaddr *sck)
58783 +{
58784 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
58785 + if (grsec_enable_socket_server &&
58786 + in_group_p(grsec_socket_server_gid) &&
58787 + sck && (sck->sa_family != AF_UNIX) &&
58788 + (sck->sa_family != AF_LOCAL)) {
58789 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
58790 + return -EACCES;
58791 + }
58792 +#endif
58793 + return 0;
58794 +}
58795 +
58796 +int
58797 +gr_handle_sock_server_other(const struct sock *sck)
58798 +{
58799 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
58800 + if (grsec_enable_socket_server &&
58801 + in_group_p(grsec_socket_server_gid) &&
58802 + sck && (sck->sk_family != AF_UNIX) &&
58803 + (sck->sk_family != AF_LOCAL)) {
58804 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
58805 + return -EACCES;
58806 + }
58807 +#endif
58808 + return 0;
58809 +}
58810 +
58811 +int
58812 +gr_handle_sock_client(const struct sockaddr *sck)
58813 +{
58814 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
58815 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
58816 + sck && (sck->sa_family != AF_UNIX) &&
58817 + (sck->sa_family != AF_LOCAL)) {
58818 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
58819 + return -EACCES;
58820 + }
58821 +#endif
58822 + return 0;
58823 +}
58824 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
58825 new file mode 100644
58826 index 0000000..a1aedd7
58827 --- /dev/null
58828 +++ b/grsecurity/grsec_sysctl.c
58829 @@ -0,0 +1,451 @@
58830 +#include <linux/kernel.h>
58831 +#include <linux/sched.h>
58832 +#include <linux/sysctl.h>
58833 +#include <linux/grsecurity.h>
58834 +#include <linux/grinternal.h>
58835 +
58836 +int
58837 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
58838 +{
58839 +#ifdef CONFIG_GRKERNSEC_SYSCTL
58840 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
58841 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
58842 + return -EACCES;
58843 + }
58844 +#endif
58845 + return 0;
58846 +}
58847 +
58848 +#ifdef CONFIG_GRKERNSEC_ROFS
58849 +static int __maybe_unused one = 1;
58850 +#endif
58851 +
58852 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
58853 +struct ctl_table grsecurity_table[] = {
58854 +#ifdef CONFIG_GRKERNSEC_SYSCTL
58855 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
58856 +#ifdef CONFIG_GRKERNSEC_IO
58857 + {
58858 + .procname = "disable_priv_io",
58859 + .data = &grsec_disable_privio,
58860 + .maxlen = sizeof(int),
58861 + .mode = 0600,
58862 + .proc_handler = &proc_dointvec,
58863 + },
58864 +#endif
58865 +#endif
58866 +#ifdef CONFIG_GRKERNSEC_LINK
58867 + {
58868 + .procname = "linking_restrictions",
58869 + .data = &grsec_enable_link,
58870 + .maxlen = sizeof(int),
58871 + .mode = 0600,
58872 + .proc_handler = &proc_dointvec,
58873 + },
58874 +#endif
58875 +#ifdef CONFIG_GRKERNSEC_BRUTE
58876 + {
58877 + .procname = "deter_bruteforce",
58878 + .data = &grsec_enable_brute,
58879 + .maxlen = sizeof(int),
58880 + .mode = 0600,
58881 + .proc_handler = &proc_dointvec,
58882 + },
58883 +#endif
58884 +#ifdef CONFIG_GRKERNSEC_FIFO
58885 + {
58886 + .procname = "fifo_restrictions",
58887 + .data = &grsec_enable_fifo,
58888 + .maxlen = sizeof(int),
58889 + .mode = 0600,
58890 + .proc_handler = &proc_dointvec,
58891 + },
58892 +#endif
58893 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
58894 + {
58895 + .procname = "ptrace_readexec",
58896 + .data = &grsec_enable_ptrace_readexec,
58897 + .maxlen = sizeof(int),
58898 + .mode = 0600,
58899 + .proc_handler = &proc_dointvec,
58900 + },
58901 +#endif
58902 +#ifdef CONFIG_GRKERNSEC_SETXID
58903 + {
58904 + .procname = "consistent_setxid",
58905 + .data = &grsec_enable_setxid,
58906 + .maxlen = sizeof(int),
58907 + .mode = 0600,
58908 + .proc_handler = &proc_dointvec,
58909 + },
58910 +#endif
58911 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
58912 + {
58913 + .procname = "ip_blackhole",
58914 + .data = &grsec_enable_blackhole,
58915 + .maxlen = sizeof(int),
58916 + .mode = 0600,
58917 + .proc_handler = &proc_dointvec,
58918 + },
58919 + {
58920 + .procname = "lastack_retries",
58921 + .data = &grsec_lastack_retries,
58922 + .maxlen = sizeof(int),
58923 + .mode = 0600,
58924 + .proc_handler = &proc_dointvec,
58925 + },
58926 +#endif
58927 +#ifdef CONFIG_GRKERNSEC_EXECLOG
58928 + {
58929 + .procname = "exec_logging",
58930 + .data = &grsec_enable_execlog,
58931 + .maxlen = sizeof(int),
58932 + .mode = 0600,
58933 + .proc_handler = &proc_dointvec,
58934 + },
58935 +#endif
58936 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
58937 + {
58938 + .procname = "rwxmap_logging",
58939 + .data = &grsec_enable_log_rwxmaps,
58940 + .maxlen = sizeof(int),
58941 + .mode = 0600,
58942 + .proc_handler = &proc_dointvec,
58943 + },
58944 +#endif
58945 +#ifdef CONFIG_GRKERNSEC_SIGNAL
58946 + {
58947 + .procname = "signal_logging",
58948 + .data = &grsec_enable_signal,
58949 + .maxlen = sizeof(int),
58950 + .mode = 0600,
58951 + .proc_handler = &proc_dointvec,
58952 + },
58953 +#endif
58954 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
58955 + {
58956 + .procname = "forkfail_logging",
58957 + .data = &grsec_enable_forkfail,
58958 + .maxlen = sizeof(int),
58959 + .mode = 0600,
58960 + .proc_handler = &proc_dointvec,
58961 + },
58962 +#endif
58963 +#ifdef CONFIG_GRKERNSEC_TIME
58964 + {
58965 + .procname = "timechange_logging",
58966 + .data = &grsec_enable_time,
58967 + .maxlen = sizeof(int),
58968 + .mode = 0600,
58969 + .proc_handler = &proc_dointvec,
58970 + },
58971 +#endif
58972 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
58973 + {
58974 + .procname = "chroot_deny_shmat",
58975 + .data = &grsec_enable_chroot_shmat,
58976 + .maxlen = sizeof(int),
58977 + .mode = 0600,
58978 + .proc_handler = &proc_dointvec,
58979 + },
58980 +#endif
58981 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
58982 + {
58983 + .procname = "chroot_deny_unix",
58984 + .data = &grsec_enable_chroot_unix,
58985 + .maxlen = sizeof(int),
58986 + .mode = 0600,
58987 + .proc_handler = &proc_dointvec,
58988 + },
58989 +#endif
58990 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
58991 + {
58992 + .procname = "chroot_deny_mount",
58993 + .data = &grsec_enable_chroot_mount,
58994 + .maxlen = sizeof(int),
58995 + .mode = 0600,
58996 + .proc_handler = &proc_dointvec,
58997 + },
58998 +#endif
58999 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
59000 + {
59001 + .procname = "chroot_deny_fchdir",
59002 + .data = &grsec_enable_chroot_fchdir,
59003 + .maxlen = sizeof(int),
59004 + .mode = 0600,
59005 + .proc_handler = &proc_dointvec,
59006 + },
59007 +#endif
59008 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
59009 + {
59010 + .procname = "chroot_deny_chroot",
59011 + .data = &grsec_enable_chroot_double,
59012 + .maxlen = sizeof(int),
59013 + .mode = 0600,
59014 + .proc_handler = &proc_dointvec,
59015 + },
59016 +#endif
59017 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
59018 + {
59019 + .procname = "chroot_deny_pivot",
59020 + .data = &grsec_enable_chroot_pivot,
59021 + .maxlen = sizeof(int),
59022 + .mode = 0600,
59023 + .proc_handler = &proc_dointvec,
59024 + },
59025 +#endif
59026 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
59027 + {
59028 + .procname = "chroot_enforce_chdir",
59029 + .data = &grsec_enable_chroot_chdir,
59030 + .maxlen = sizeof(int),
59031 + .mode = 0600,
59032 + .proc_handler = &proc_dointvec,
59033 + },
59034 +#endif
59035 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
59036 + {
59037 + .procname = "chroot_deny_chmod",
59038 + .data = &grsec_enable_chroot_chmod,
59039 + .maxlen = sizeof(int),
59040 + .mode = 0600,
59041 + .proc_handler = &proc_dointvec,
59042 + },
59043 +#endif
59044 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
59045 + {
59046 + .procname = "chroot_deny_mknod",
59047 + .data = &grsec_enable_chroot_mknod,
59048 + .maxlen = sizeof(int),
59049 + .mode = 0600,
59050 + .proc_handler = &proc_dointvec,
59051 + },
59052 +#endif
59053 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
59054 + {
59055 + .procname = "chroot_restrict_nice",
59056 + .data = &grsec_enable_chroot_nice,
59057 + .maxlen = sizeof(int),
59058 + .mode = 0600,
59059 + .proc_handler = &proc_dointvec,
59060 + },
59061 +#endif
59062 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
59063 + {
59064 + .procname = "chroot_execlog",
59065 + .data = &grsec_enable_chroot_execlog,
59066 + .maxlen = sizeof(int),
59067 + .mode = 0600,
59068 + .proc_handler = &proc_dointvec,
59069 + },
59070 +#endif
59071 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
59072 + {
59073 + .procname = "chroot_caps",
59074 + .data = &grsec_enable_chroot_caps,
59075 + .maxlen = sizeof(int),
59076 + .mode = 0600,
59077 + .proc_handler = &proc_dointvec,
59078 + },
59079 +#endif
59080 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
59081 + {
59082 + .procname = "chroot_deny_sysctl",
59083 + .data = &grsec_enable_chroot_sysctl,
59084 + .maxlen = sizeof(int),
59085 + .mode = 0600,
59086 + .proc_handler = &proc_dointvec,
59087 + },
59088 +#endif
59089 +#ifdef CONFIG_GRKERNSEC_TPE
59090 + {
59091 + .procname = "tpe",
59092 + .data = &grsec_enable_tpe,
59093 + .maxlen = sizeof(int),
59094 + .mode = 0600,
59095 + .proc_handler = &proc_dointvec,
59096 + },
59097 + {
59098 + .procname = "tpe_gid",
59099 + .data = &grsec_tpe_gid,
59100 + .maxlen = sizeof(int),
59101 + .mode = 0600,
59102 + .proc_handler = &proc_dointvec,
59103 + },
59104 +#endif
59105 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
59106 + {
59107 + .procname = "tpe_invert",
59108 + .data = &grsec_enable_tpe_invert,
59109 + .maxlen = sizeof(int),
59110 + .mode = 0600,
59111 + .proc_handler = &proc_dointvec,
59112 + },
59113 +#endif
59114 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
59115 + {
59116 + .procname = "tpe_restrict_all",
59117 + .data = &grsec_enable_tpe_all,
59118 + .maxlen = sizeof(int),
59119 + .mode = 0600,
59120 + .proc_handler = &proc_dointvec,
59121 + },
59122 +#endif
59123 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
59124 + {
59125 + .procname = "socket_all",
59126 + .data = &grsec_enable_socket_all,
59127 + .maxlen = sizeof(int),
59128 + .mode = 0600,
59129 + .proc_handler = &proc_dointvec,
59130 + },
59131 + {
59132 + .procname = "socket_all_gid",
59133 + .data = &grsec_socket_all_gid,
59134 + .maxlen = sizeof(int),
59135 + .mode = 0600,
59136 + .proc_handler = &proc_dointvec,
59137 + },
59138 +#endif
59139 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
59140 + {
59141 + .procname = "socket_client",
59142 + .data = &grsec_enable_socket_client,
59143 + .maxlen = sizeof(int),
59144 + .mode = 0600,
59145 + .proc_handler = &proc_dointvec,
59146 + },
59147 + {
59148 + .procname = "socket_client_gid",
59149 + .data = &grsec_socket_client_gid,
59150 + .maxlen = sizeof(int),
59151 + .mode = 0600,
59152 + .proc_handler = &proc_dointvec,
59153 + },
59154 +#endif
59155 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
59156 + {
59157 + .procname = "socket_server",
59158 + .data = &grsec_enable_socket_server,
59159 + .maxlen = sizeof(int),
59160 + .mode = 0600,
59161 + .proc_handler = &proc_dointvec,
59162 + },
59163 + {
59164 + .procname = "socket_server_gid",
59165 + .data = &grsec_socket_server_gid,
59166 + .maxlen = sizeof(int),
59167 + .mode = 0600,
59168 + .proc_handler = &proc_dointvec,
59169 + },
59170 +#endif
59171 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
59172 + {
59173 + .procname = "audit_group",
59174 + .data = &grsec_enable_group,
59175 + .maxlen = sizeof(int),
59176 + .mode = 0600,
59177 + .proc_handler = &proc_dointvec,
59178 + },
59179 + {
59180 + .procname = "audit_gid",
59181 + .data = &grsec_audit_gid,
59182 + .maxlen = sizeof(int),
59183 + .mode = 0600,
59184 + .proc_handler = &proc_dointvec,
59185 + },
59186 +#endif
59187 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
59188 + {
59189 + .procname = "audit_chdir",
59190 + .data = &grsec_enable_chdir,
59191 + .maxlen = sizeof(int),
59192 + .mode = 0600,
59193 + .proc_handler = &proc_dointvec,
59194 + },
59195 +#endif
59196 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
59197 + {
59198 + .procname = "audit_mount",
59199 + .data = &grsec_enable_mount,
59200 + .maxlen = sizeof(int),
59201 + .mode = 0600,
59202 + .proc_handler = &proc_dointvec,
59203 + },
59204 +#endif
59205 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
59206 + {
59207 + .procname = "audit_textrel",
59208 + .data = &grsec_enable_audit_textrel,
59209 + .maxlen = sizeof(int),
59210 + .mode = 0600,
59211 + .proc_handler = &proc_dointvec,
59212 + },
59213 +#endif
59214 +#ifdef CONFIG_GRKERNSEC_DMESG
59215 + {
59216 + .procname = "dmesg",
59217 + .data = &grsec_enable_dmesg,
59218 + .maxlen = sizeof(int),
59219 + .mode = 0600,
59220 + .proc_handler = &proc_dointvec,
59221 + },
59222 +#endif
59223 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
59224 + {
59225 + .procname = "chroot_findtask",
59226 + .data = &grsec_enable_chroot_findtask,
59227 + .maxlen = sizeof(int),
59228 + .mode = 0600,
59229 + .proc_handler = &proc_dointvec,
59230 + },
59231 +#endif
59232 +#ifdef CONFIG_GRKERNSEC_RESLOG
59233 + {
59234 + .procname = "resource_logging",
59235 + .data = &grsec_resource_logging,
59236 + .maxlen = sizeof(int),
59237 + .mode = 0600,
59238 + .proc_handler = &proc_dointvec,
59239 + },
59240 +#endif
59241 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
59242 + {
59243 + .procname = "audit_ptrace",
59244 + .data = &grsec_enable_audit_ptrace,
59245 + .maxlen = sizeof(int),
59246 + .mode = 0600,
59247 + .proc_handler = &proc_dointvec,
59248 + },
59249 +#endif
59250 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
59251 + {
59252 + .procname = "harden_ptrace",
59253 + .data = &grsec_enable_harden_ptrace,
59254 + .maxlen = sizeof(int),
59255 + .mode = 0600,
59256 + .proc_handler = &proc_dointvec,
59257 + },
59258 +#endif
59259 + {
59260 + .procname = "grsec_lock",
59261 + .data = &grsec_lock,
59262 + .maxlen = sizeof(int),
59263 + .mode = 0600,
59264 + .proc_handler = &proc_dointvec,
59265 + },
59266 +#endif
59267 +#ifdef CONFIG_GRKERNSEC_ROFS
59268 + {
59269 + .procname = "romount_protect",
59270 + .data = &grsec_enable_rofs,
59271 + .maxlen = sizeof(int),
59272 + .mode = 0600,
59273 + .proc_handler = &proc_dointvec_minmax,
59274 + .extra1 = &one,
59275 + .extra2 = &one,
59276 + },
59277 +#endif
59278 + { }
59279 +};
59280 +#endif
59281 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
59282 new file mode 100644
59283 index 0000000..0dc13c3
59284 --- /dev/null
59285 +++ b/grsecurity/grsec_time.c
59286 @@ -0,0 +1,16 @@
59287 +#include <linux/kernel.h>
59288 +#include <linux/sched.h>
59289 +#include <linux/grinternal.h>
59290 +#include <linux/module.h>
59291 +
59292 +void
59293 +gr_log_timechange(void)
59294 +{
59295 +#ifdef CONFIG_GRKERNSEC_TIME
59296 + if (grsec_enable_time)
59297 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
59298 +#endif
59299 + return;
59300 +}
59301 +
59302 +EXPORT_SYMBOL(gr_log_timechange);
59303 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
59304 new file mode 100644
59305 index 0000000..07e0dc0
59306 --- /dev/null
59307 +++ b/grsecurity/grsec_tpe.c
59308 @@ -0,0 +1,73 @@
59309 +#include <linux/kernel.h>
59310 +#include <linux/sched.h>
59311 +#include <linux/file.h>
59312 +#include <linux/fs.h>
59313 +#include <linux/grinternal.h>
59314 +
59315 +extern int gr_acl_tpe_check(void);
59316 +
59317 +int
59318 +gr_tpe_allow(const struct file *file)
59319 +{
59320 +#ifdef CONFIG_GRKERNSEC
59321 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
59322 + const struct cred *cred = current_cred();
59323 + char *msg = NULL;
59324 + char *msg2 = NULL;
59325 +
59326 + // never restrict root
59327 + if (!cred->uid)
59328 + return 1;
59329 +
59330 + if (grsec_enable_tpe) {
59331 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
59332 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
59333 + msg = "not being in trusted group";
59334 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
59335 + msg = "being in untrusted group";
59336 +#else
59337 + if (in_group_p(grsec_tpe_gid))
59338 + msg = "being in untrusted group";
59339 +#endif
59340 + }
59341 + if (!msg && gr_acl_tpe_check())
59342 + msg = "being in untrusted role";
59343 +
59344 + // not in any affected group/role
59345 + if (!msg)
59346 + goto next_check;
59347 +
59348 + if (inode->i_uid)
59349 + msg2 = "file in non-root-owned directory";
59350 + else if (inode->i_mode & S_IWOTH)
59351 + msg2 = "file in world-writable directory";
59352 + else if (inode->i_mode & S_IWGRP)
59353 + msg2 = "file in group-writable directory";
59354 +
59355 + if (msg && msg2) {
59356 + char fullmsg[70] = {0};
59357 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
59358 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
59359 + return 0;
59360 + }
59361 + msg = NULL;
59362 +next_check:
59363 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
59364 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
59365 + return 1;
59366 +
59367 + if (inode->i_uid && (inode->i_uid != cred->uid))
59368 + msg = "directory not owned by user";
59369 + else if (inode->i_mode & S_IWOTH)
59370 + msg = "file in world-writable directory";
59371 + else if (inode->i_mode & S_IWGRP)
59372 + msg = "file in group-writable directory";
59373 +
59374 + if (msg) {
59375 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
59376 + return 0;
59377 + }
59378 +#endif
59379 +#endif
59380 + return 1;
59381 +}
59382 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
59383 new file mode 100644
59384 index 0000000..9f7b1ac
59385 --- /dev/null
59386 +++ b/grsecurity/grsum.c
59387 @@ -0,0 +1,61 @@
59388 +#include <linux/err.h>
59389 +#include <linux/kernel.h>
59390 +#include <linux/sched.h>
59391 +#include <linux/mm.h>
59392 +#include <linux/scatterlist.h>
59393 +#include <linux/crypto.h>
59394 +#include <linux/gracl.h>
59395 +
59396 +
59397 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
59398 +#error "crypto and sha256 must be built into the kernel"
59399 +#endif
59400 +
59401 +int
59402 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
59403 +{
59404 + char *p;
59405 + struct crypto_hash *tfm;
59406 + struct hash_desc desc;
59407 + struct scatterlist sg;
59408 + unsigned char temp_sum[GR_SHA_LEN];
59409 + volatile int retval = 0;
59410 + volatile int dummy = 0;
59411 + unsigned int i;
59412 +
59413 + sg_init_table(&sg, 1);
59414 +
59415 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
59416 + if (IS_ERR(tfm)) {
59417 + /* should never happen, since sha256 should be built in */
59418 + return 1;
59419 + }
59420 +
59421 + desc.tfm = tfm;
59422 + desc.flags = 0;
59423 +
59424 + crypto_hash_init(&desc);
59425 +
59426 + p = salt;
59427 + sg_set_buf(&sg, p, GR_SALT_LEN);
59428 + crypto_hash_update(&desc, &sg, sg.length);
59429 +
59430 + p = entry->pw;
59431 + sg_set_buf(&sg, p, strlen(p));
59432 +
59433 + crypto_hash_update(&desc, &sg, sg.length);
59434 +
59435 + crypto_hash_final(&desc, temp_sum);
59436 +
59437 + memset(entry->pw, 0, GR_PW_LEN);
59438 +
59439 + for (i = 0; i < GR_SHA_LEN; i++)
59440 + if (sum[i] != temp_sum[i])
59441 + retval = 1;
59442 + else
59443 + dummy = 1; // waste a cycle
59444 +
59445 + crypto_free_hash(tfm);
59446 +
59447 + return retval;
59448 +}
59449 diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
59450 index 6cd5b64..f620d2d 100644
59451 --- a/include/acpi/acpi_bus.h
59452 +++ b/include/acpi/acpi_bus.h
59453 @@ -107,7 +107,7 @@ struct acpi_device_ops {
59454 acpi_op_bind bind;
59455 acpi_op_unbind unbind;
59456 acpi_op_notify notify;
59457 -};
59458 +} __no_const;
59459
59460 #define ACPI_DRIVER_ALL_NOTIFY_EVENTS 0x1 /* system AND device events */
59461
59462 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
59463 index b7babf0..71e4e74 100644
59464 --- a/include/asm-generic/atomic-long.h
59465 +++ b/include/asm-generic/atomic-long.h
59466 @@ -22,6 +22,12 @@
59467
59468 typedef atomic64_t atomic_long_t;
59469
59470 +#ifdef CONFIG_PAX_REFCOUNT
59471 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
59472 +#else
59473 +typedef atomic64_t atomic_long_unchecked_t;
59474 +#endif
59475 +
59476 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
59477
59478 static inline long atomic_long_read(atomic_long_t *l)
59479 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
59480 return (long)atomic64_read(v);
59481 }
59482
59483 +#ifdef CONFIG_PAX_REFCOUNT
59484 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
59485 +{
59486 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
59487 +
59488 + return (long)atomic64_read_unchecked(v);
59489 +}
59490 +#endif
59491 +
59492 static inline void atomic_long_set(atomic_long_t *l, long i)
59493 {
59494 atomic64_t *v = (atomic64_t *)l;
59495 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
59496 atomic64_set(v, i);
59497 }
59498
59499 +#ifdef CONFIG_PAX_REFCOUNT
59500 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
59501 +{
59502 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
59503 +
59504 + atomic64_set_unchecked(v, i);
59505 +}
59506 +#endif
59507 +
59508 static inline void atomic_long_inc(atomic_long_t *l)
59509 {
59510 atomic64_t *v = (atomic64_t *)l;
59511 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
59512 atomic64_inc(v);
59513 }
59514
59515 +#ifdef CONFIG_PAX_REFCOUNT
59516 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
59517 +{
59518 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
59519 +
59520 + atomic64_inc_unchecked(v);
59521 +}
59522 +#endif
59523 +
59524 static inline void atomic_long_dec(atomic_long_t *l)
59525 {
59526 atomic64_t *v = (atomic64_t *)l;
59527 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
59528 atomic64_dec(v);
59529 }
59530
59531 +#ifdef CONFIG_PAX_REFCOUNT
59532 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
59533 +{
59534 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
59535 +
59536 + atomic64_dec_unchecked(v);
59537 +}
59538 +#endif
59539 +
59540 static inline void atomic_long_add(long i, atomic_long_t *l)
59541 {
59542 atomic64_t *v = (atomic64_t *)l;
59543 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
59544 atomic64_add(i, v);
59545 }
59546
59547 +#ifdef CONFIG_PAX_REFCOUNT
59548 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
59549 +{
59550 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
59551 +
59552 + atomic64_add_unchecked(i, v);
59553 +}
59554 +#endif
59555 +
59556 static inline void atomic_long_sub(long i, atomic_long_t *l)
59557 {
59558 atomic64_t *v = (atomic64_t *)l;
59559 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
59560 atomic64_sub(i, v);
59561 }
59562
59563 +#ifdef CONFIG_PAX_REFCOUNT
59564 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
59565 +{
59566 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
59567 +
59568 + atomic64_sub_unchecked(i, v);
59569 +}
59570 +#endif
59571 +
59572 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
59573 {
59574 atomic64_t *v = (atomic64_t *)l;
59575 @@ -115,6 +175,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
59576 return (long)atomic64_inc_return(v);
59577 }
59578
59579 +#ifdef CONFIG_PAX_REFCOUNT
59580 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
59581 +{
59582 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
59583 +
59584 + return (long)atomic64_inc_return_unchecked(v);
59585 +}
59586 +#endif
59587 +
59588 static inline long atomic_long_dec_return(atomic_long_t *l)
59589 {
59590 atomic64_t *v = (atomic64_t *)l;
59591 @@ -140,6 +209,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
59592
59593 typedef atomic_t atomic_long_t;
59594
59595 +#ifdef CONFIG_PAX_REFCOUNT
59596 +typedef atomic_unchecked_t atomic_long_unchecked_t;
59597 +#else
59598 +typedef atomic_t atomic_long_unchecked_t;
59599 +#endif
59600 +
59601 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
59602 static inline long atomic_long_read(atomic_long_t *l)
59603 {
59604 @@ -148,6 +223,15 @@ static inline long atomic_long_read(atomic_long_t *l)
59605 return (long)atomic_read(v);
59606 }
59607
59608 +#ifdef CONFIG_PAX_REFCOUNT
59609 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
59610 +{
59611 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
59612 +
59613 + return (long)atomic_read_unchecked(v);
59614 +}
59615 +#endif
59616 +
59617 static inline void atomic_long_set(atomic_long_t *l, long i)
59618 {
59619 atomic_t *v = (atomic_t *)l;
59620 @@ -155,6 +239,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
59621 atomic_set(v, i);
59622 }
59623
59624 +#ifdef CONFIG_PAX_REFCOUNT
59625 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
59626 +{
59627 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
59628 +
59629 + atomic_set_unchecked(v, i);
59630 +}
59631 +#endif
59632 +
59633 static inline void atomic_long_inc(atomic_long_t *l)
59634 {
59635 atomic_t *v = (atomic_t *)l;
59636 @@ -162,6 +255,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
59637 atomic_inc(v);
59638 }
59639
59640 +#ifdef CONFIG_PAX_REFCOUNT
59641 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
59642 +{
59643 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
59644 +
59645 + atomic_inc_unchecked(v);
59646 +}
59647 +#endif
59648 +
59649 static inline void atomic_long_dec(atomic_long_t *l)
59650 {
59651 atomic_t *v = (atomic_t *)l;
59652 @@ -169,6 +271,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
59653 atomic_dec(v);
59654 }
59655
59656 +#ifdef CONFIG_PAX_REFCOUNT
59657 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
59658 +{
59659 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
59660 +
59661 + atomic_dec_unchecked(v);
59662 +}
59663 +#endif
59664 +
59665 static inline void atomic_long_add(long i, atomic_long_t *l)
59666 {
59667 atomic_t *v = (atomic_t *)l;
59668 @@ -176,6 +287,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
59669 atomic_add(i, v);
59670 }
59671
59672 +#ifdef CONFIG_PAX_REFCOUNT
59673 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
59674 +{
59675 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
59676 +
59677 + atomic_add_unchecked(i, v);
59678 +}
59679 +#endif
59680 +
59681 static inline void atomic_long_sub(long i, atomic_long_t *l)
59682 {
59683 atomic_t *v = (atomic_t *)l;
59684 @@ -183,6 +303,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
59685 atomic_sub(i, v);
59686 }
59687
59688 +#ifdef CONFIG_PAX_REFCOUNT
59689 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
59690 +{
59691 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
59692 +
59693 + atomic_sub_unchecked(i, v);
59694 +}
59695 +#endif
59696 +
59697 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
59698 {
59699 atomic_t *v = (atomic_t *)l;
59700 @@ -232,6 +361,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
59701 return (long)atomic_inc_return(v);
59702 }
59703
59704 +#ifdef CONFIG_PAX_REFCOUNT
59705 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
59706 +{
59707 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
59708 +
59709 + return (long)atomic_inc_return_unchecked(v);
59710 +}
59711 +#endif
59712 +
59713 static inline long atomic_long_dec_return(atomic_long_t *l)
59714 {
59715 atomic_t *v = (atomic_t *)l;
59716 @@ -255,4 +393,49 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
59717
59718 #endif /* BITS_PER_LONG == 64 */
59719
59720 +#ifdef CONFIG_PAX_REFCOUNT
59721 +static inline void pax_refcount_needs_these_functions(void)
59722 +{
59723 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
59724 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
59725 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
59726 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
59727 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
59728 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
59729 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
59730 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
59731 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
59732 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
59733 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
59734 +
59735 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
59736 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
59737 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
59738 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
59739 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
59740 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
59741 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
59742 +}
59743 +#else
59744 +#define atomic_read_unchecked(v) atomic_read(v)
59745 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
59746 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
59747 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
59748 +#define atomic_inc_unchecked(v) atomic_inc(v)
59749 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
59750 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
59751 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
59752 +#define atomic_dec_unchecked(v) atomic_dec(v)
59753 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
59754 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
59755 +
59756 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
59757 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
59758 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
59759 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
59760 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
59761 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
59762 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
59763 +#endif
59764 +
59765 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
59766 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
59767 index b18ce4f..2ee2843 100644
59768 --- a/include/asm-generic/atomic64.h
59769 +++ b/include/asm-generic/atomic64.h
59770 @@ -16,6 +16,8 @@ typedef struct {
59771 long long counter;
59772 } atomic64_t;
59773
59774 +typedef atomic64_t atomic64_unchecked_t;
59775 +
59776 #define ATOMIC64_INIT(i) { (i) }
59777
59778 extern long long atomic64_read(const atomic64_t *v);
59779 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
59780 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
59781 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
59782
59783 +#define atomic64_read_unchecked(v) atomic64_read(v)
59784 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
59785 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
59786 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
59787 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
59788 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
59789 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
59790 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
59791 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
59792 +
59793 #endif /* _ASM_GENERIC_ATOMIC64_H */
59794 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
59795 index 1bfcfe5..e04c5c9 100644
59796 --- a/include/asm-generic/cache.h
59797 +++ b/include/asm-generic/cache.h
59798 @@ -6,7 +6,7 @@
59799 * cache lines need to provide their own cache.h.
59800 */
59801
59802 -#define L1_CACHE_SHIFT 5
59803 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
59804 +#define L1_CACHE_SHIFT 5UL
59805 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
59806
59807 #endif /* __ASM_GENERIC_CACHE_H */
59808 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
59809 index 0d68a1e..b74a761 100644
59810 --- a/include/asm-generic/emergency-restart.h
59811 +++ b/include/asm-generic/emergency-restart.h
59812 @@ -1,7 +1,7 @@
59813 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
59814 #define _ASM_GENERIC_EMERGENCY_RESTART_H
59815
59816 -static inline void machine_emergency_restart(void)
59817 +static inline __noreturn void machine_emergency_restart(void)
59818 {
59819 machine_restart(NULL);
59820 }
59821 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
59822 index 0232ccb..13d9165 100644
59823 --- a/include/asm-generic/kmap_types.h
59824 +++ b/include/asm-generic/kmap_types.h
59825 @@ -29,10 +29,11 @@ KMAP_D(16) KM_IRQ_PTE,
59826 KMAP_D(17) KM_NMI,
59827 KMAP_D(18) KM_NMI_PTE,
59828 KMAP_D(19) KM_KDB,
59829 +KMAP_D(20) KM_CLEARPAGE,
59830 /*
59831 * Remember to update debug_kmap_atomic() when adding new kmap types!
59832 */
59833 -KMAP_D(20) KM_TYPE_NR
59834 +KMAP_D(21) KM_TYPE_NR
59835 };
59836
59837 #undef KMAP_D
59838 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
59839 index 9ceb03b..2efbcbd 100644
59840 --- a/include/asm-generic/local.h
59841 +++ b/include/asm-generic/local.h
59842 @@ -39,6 +39,7 @@ typedef struct
59843 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
59844 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
59845 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
59846 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
59847
59848 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
59849 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
59850 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
59851 index 725612b..9cc513a 100644
59852 --- a/include/asm-generic/pgtable-nopmd.h
59853 +++ b/include/asm-generic/pgtable-nopmd.h
59854 @@ -1,14 +1,19 @@
59855 #ifndef _PGTABLE_NOPMD_H
59856 #define _PGTABLE_NOPMD_H
59857
59858 -#ifndef __ASSEMBLY__
59859 -
59860 #include <asm-generic/pgtable-nopud.h>
59861
59862 -struct mm_struct;
59863 -
59864 #define __PAGETABLE_PMD_FOLDED
59865
59866 +#define PMD_SHIFT PUD_SHIFT
59867 +#define PTRS_PER_PMD 1
59868 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
59869 +#define PMD_MASK (~(PMD_SIZE-1))
59870 +
59871 +#ifndef __ASSEMBLY__
59872 +
59873 +struct mm_struct;
59874 +
59875 /*
59876 * Having the pmd type consist of a pud gets the size right, and allows
59877 * us to conceptually access the pud entry that this pmd is folded into
59878 @@ -16,11 +21,6 @@ struct mm_struct;
59879 */
59880 typedef struct { pud_t pud; } pmd_t;
59881
59882 -#define PMD_SHIFT PUD_SHIFT
59883 -#define PTRS_PER_PMD 1
59884 -#define PMD_SIZE (1UL << PMD_SHIFT)
59885 -#define PMD_MASK (~(PMD_SIZE-1))
59886 -
59887 /*
59888 * The "pud_xxx()" functions here are trivial for a folded two-level
59889 * setup: the pmd is never bad, and a pmd always exists (as it's folded
59890 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
59891 index 810431d..0ec4804f 100644
59892 --- a/include/asm-generic/pgtable-nopud.h
59893 +++ b/include/asm-generic/pgtable-nopud.h
59894 @@ -1,10 +1,15 @@
59895 #ifndef _PGTABLE_NOPUD_H
59896 #define _PGTABLE_NOPUD_H
59897
59898 -#ifndef __ASSEMBLY__
59899 -
59900 #define __PAGETABLE_PUD_FOLDED
59901
59902 +#define PUD_SHIFT PGDIR_SHIFT
59903 +#define PTRS_PER_PUD 1
59904 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
59905 +#define PUD_MASK (~(PUD_SIZE-1))
59906 +
59907 +#ifndef __ASSEMBLY__
59908 +
59909 /*
59910 * Having the pud type consist of a pgd gets the size right, and allows
59911 * us to conceptually access the pgd entry that this pud is folded into
59912 @@ -12,11 +17,6 @@
59913 */
59914 typedef struct { pgd_t pgd; } pud_t;
59915
59916 -#define PUD_SHIFT PGDIR_SHIFT
59917 -#define PTRS_PER_PUD 1
59918 -#define PUD_SIZE (1UL << PUD_SHIFT)
59919 -#define PUD_MASK (~(PUD_SIZE-1))
59920 -
59921 /*
59922 * The "pgd_xxx()" functions here are trivial for a folded two-level
59923 * setup: the pud is never bad, and a pud always exists (as it's folded
59924 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
59925 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
59926
59927 #define pgd_populate(mm, pgd, pud) do { } while (0)
59928 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
59929 /*
59930 * (puds are folded into pgds so this doesn't get actually called,
59931 * but the define is needed for a generic inline function.)
59932 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
59933 index a03c098..19751cf 100644
59934 --- a/include/asm-generic/pgtable.h
59935 +++ b/include/asm-generic/pgtable.h
59936 @@ -445,6 +445,18 @@ static inline int pmd_write(pmd_t pmd)
59937 #endif /* __HAVE_ARCH_PMD_WRITE */
59938 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
59939
59940 +#ifndef __HAVE_ARCH_READ_PMD_ATOMIC
59941 +static inline pmd_t read_pmd_atomic(pmd_t *pmdp)
59942 +{
59943 + /*
59944 + * Depend on compiler for an atomic pmd read. NOTE: this is
59945 + * only going to work, if the pmdval_t isn't larger than
59946 + * an unsigned long.
59947 + */
59948 + return *pmdp;
59949 +}
59950 +#endif /* __HAVE_ARCH_READ_PMD_ATOMIC */
59951 +
59952 /*
59953 * This function is meant to be used by sites walking pagetables with
59954 * the mmap_sem hold in read mode to protect against MADV_DONTNEED and
59955 @@ -458,11 +470,17 @@ static inline int pmd_write(pmd_t pmd)
59956 * undefined so behaving like if the pmd was none is safe (because it
59957 * can return none anyway). The compiler level barrier() is critically
59958 * important to compute the two checks atomically on the same pmdval.
59959 + *
59960 + * For 32bit kernels with a 64bit large pmd_t this automatically takes
59961 + * care of reading the pmd atomically to avoid SMP race conditions
59962 + * against pmd_populate() when the mmap_sem is hold for reading by the
59963 + * caller (a special atomic read not done by "gcc" as in the generic
59964 + * version above, is also needed when THP is disabled because the page
59965 + * fault can populate the pmd from under us).
59966 */
59967 static inline int pmd_none_or_trans_huge_or_clear_bad(pmd_t *pmd)
59968 {
59969 - /* depend on compiler for an atomic pmd read */
59970 - pmd_t pmdval = *pmd;
59971 + pmd_t pmdval = read_pmd_atomic(pmd);
59972 /*
59973 * The barrier will stabilize the pmdval in a register or on
59974 * the stack so that it will stop changing under the code.
59975 @@ -502,6 +520,14 @@ static inline int pmd_trans_unstable(pmd_t *pmd)
59976 #endif
59977 }
59978
59979 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
59980 +static inline unsigned long pax_open_kernel(void) { return 0; }
59981 +#endif
59982 +
59983 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
59984 +static inline unsigned long pax_close_kernel(void) { return 0; }
59985 +#endif
59986 +
59987 #endif /* CONFIG_MMU */
59988
59989 #endif /* !__ASSEMBLY__ */
59990 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
59991 index b5e2e4c..6a5373e 100644
59992 --- a/include/asm-generic/vmlinux.lds.h
59993 +++ b/include/asm-generic/vmlinux.lds.h
59994 @@ -217,6 +217,7 @@
59995 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
59996 VMLINUX_SYMBOL(__start_rodata) = .; \
59997 *(.rodata) *(.rodata.*) \
59998 + *(.data..read_only) \
59999 *(__vermagic) /* Kernel version magic */ \
60000 . = ALIGN(8); \
60001 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
60002 @@ -722,17 +723,18 @@
60003 * section in the linker script will go there too. @phdr should have
60004 * a leading colon.
60005 *
60006 - * Note that this macros defines __per_cpu_load as an absolute symbol.
60007 + * Note that this macros defines per_cpu_load as an absolute symbol.
60008 * If there is no need to put the percpu section at a predetermined
60009 * address, use PERCPU_SECTION.
60010 */
60011 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
60012 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
60013 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
60014 + per_cpu_load = .; \
60015 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
60016 - LOAD_OFFSET) { \
60017 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
60018 PERCPU_INPUT(cacheline) \
60019 } phdr \
60020 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
60021 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
60022
60023 /**
60024 * PERCPU_SECTION - define output section for percpu area, simple version
60025 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
60026 index 92f0981..d44a37c 100644
60027 --- a/include/drm/drmP.h
60028 +++ b/include/drm/drmP.h
60029 @@ -72,6 +72,7 @@
60030 #include <linux/workqueue.h>
60031 #include <linux/poll.h>
60032 #include <asm/pgalloc.h>
60033 +#include <asm/local.h>
60034 #include "drm.h"
60035
60036 #include <linux/idr.h>
60037 @@ -1038,7 +1039,7 @@ struct drm_device {
60038
60039 /** \name Usage Counters */
60040 /*@{ */
60041 - int open_count; /**< Outstanding files open */
60042 + local_t open_count; /**< Outstanding files open */
60043 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
60044 atomic_t vma_count; /**< Outstanding vma areas open */
60045 int buf_use; /**< Buffers in use -- cannot alloc */
60046 @@ -1049,7 +1050,7 @@ struct drm_device {
60047 /*@{ */
60048 unsigned long counters;
60049 enum drm_stat_type types[15];
60050 - atomic_t counts[15];
60051 + atomic_unchecked_t counts[15];
60052 /*@} */
60053
60054 struct list_head filelist;
60055 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
60056 index 37515d1..34fa8b0 100644
60057 --- a/include/drm/drm_crtc_helper.h
60058 +++ b/include/drm/drm_crtc_helper.h
60059 @@ -74,7 +74,7 @@ struct drm_crtc_helper_funcs {
60060
60061 /* disable crtc when not in use - more explicit than dpms off */
60062 void (*disable)(struct drm_crtc *crtc);
60063 -};
60064 +} __no_const;
60065
60066 struct drm_encoder_helper_funcs {
60067 void (*dpms)(struct drm_encoder *encoder, int mode);
60068 @@ -95,7 +95,7 @@ struct drm_encoder_helper_funcs {
60069 struct drm_connector *connector);
60070 /* disable encoder when not in use - more explicit than dpms off */
60071 void (*disable)(struct drm_encoder *encoder);
60072 -};
60073 +} __no_const;
60074
60075 struct drm_connector_helper_funcs {
60076 int (*get_modes)(struct drm_connector *connector);
60077 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
60078 index 26c1f78..6722682 100644
60079 --- a/include/drm/ttm/ttm_memory.h
60080 +++ b/include/drm/ttm/ttm_memory.h
60081 @@ -47,7 +47,7 @@
60082
60083 struct ttm_mem_shrink {
60084 int (*do_shrink) (struct ttm_mem_shrink *);
60085 -};
60086 +} __no_const;
60087
60088 /**
60089 * struct ttm_mem_global - Global memory accounting structure.
60090 diff --git a/include/linux/a.out.h b/include/linux/a.out.h
60091 index e86dfca..40cc55f 100644
60092 --- a/include/linux/a.out.h
60093 +++ b/include/linux/a.out.h
60094 @@ -39,6 +39,14 @@ enum machine_type {
60095 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
60096 };
60097
60098 +/* Constants for the N_FLAGS field */
60099 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
60100 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
60101 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
60102 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
60103 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
60104 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
60105 +
60106 #if !defined (N_MAGIC)
60107 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
60108 #endif
60109 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
60110 index f4ff882..84b53a6 100644
60111 --- a/include/linux/atmdev.h
60112 +++ b/include/linux/atmdev.h
60113 @@ -237,7 +237,7 @@ struct compat_atm_iobuf {
60114 #endif
60115
60116 struct k_atm_aal_stats {
60117 -#define __HANDLE_ITEM(i) atomic_t i
60118 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
60119 __AAL_STAT_ITEMS
60120 #undef __HANDLE_ITEM
60121 };
60122 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
60123 index 0092102..8a801b4 100644
60124 --- a/include/linux/binfmts.h
60125 +++ b/include/linux/binfmts.h
60126 @@ -89,6 +89,7 @@ struct linux_binfmt {
60127 int (*load_binary)(struct linux_binprm *, struct pt_regs * regs);
60128 int (*load_shlib)(struct file *);
60129 int (*core_dump)(struct coredump_params *cprm);
60130 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
60131 unsigned long min_coredump; /* minimal dump size */
60132 };
60133
60134 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
60135 index 606cf33..b72c577 100644
60136 --- a/include/linux/blkdev.h
60137 +++ b/include/linux/blkdev.h
60138 @@ -1379,7 +1379,7 @@ struct block_device_operations {
60139 /* this callback is with swap_lock and sometimes page table lock held */
60140 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
60141 struct module *owner;
60142 -};
60143 +} __do_const;
60144
60145 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
60146 unsigned long);
60147 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
60148 index 4d1a074..88f929a 100644
60149 --- a/include/linux/blktrace_api.h
60150 +++ b/include/linux/blktrace_api.h
60151 @@ -162,7 +162,7 @@ struct blk_trace {
60152 struct dentry *dir;
60153 struct dentry *dropped_file;
60154 struct dentry *msg_file;
60155 - atomic_t dropped;
60156 + atomic_unchecked_t dropped;
60157 };
60158
60159 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
60160 diff --git a/include/linux/byteorder/little_endian.h b/include/linux/byteorder/little_endian.h
60161 index 83195fb..0b0f77d 100644
60162 --- a/include/linux/byteorder/little_endian.h
60163 +++ b/include/linux/byteorder/little_endian.h
60164 @@ -42,51 +42,51 @@
60165
60166 static inline __le64 __cpu_to_le64p(const __u64 *p)
60167 {
60168 - return (__force __le64)*p;
60169 + return (__force const __le64)*p;
60170 }
60171 static inline __u64 __le64_to_cpup(const __le64 *p)
60172 {
60173 - return (__force __u64)*p;
60174 + return (__force const __u64)*p;
60175 }
60176 static inline __le32 __cpu_to_le32p(const __u32 *p)
60177 {
60178 - return (__force __le32)*p;
60179 + return (__force const __le32)*p;
60180 }
60181 static inline __u32 __le32_to_cpup(const __le32 *p)
60182 {
60183 - return (__force __u32)*p;
60184 + return (__force const __u32)*p;
60185 }
60186 static inline __le16 __cpu_to_le16p(const __u16 *p)
60187 {
60188 - return (__force __le16)*p;
60189 + return (__force const __le16)*p;
60190 }
60191 static inline __u16 __le16_to_cpup(const __le16 *p)
60192 {
60193 - return (__force __u16)*p;
60194 + return (__force const __u16)*p;
60195 }
60196 static inline __be64 __cpu_to_be64p(const __u64 *p)
60197 {
60198 - return (__force __be64)__swab64p(p);
60199 + return (__force const __be64)__swab64p(p);
60200 }
60201 static inline __u64 __be64_to_cpup(const __be64 *p)
60202 {
60203 - return __swab64p((__u64 *)p);
60204 + return __swab64p((const __u64 *)p);
60205 }
60206 static inline __be32 __cpu_to_be32p(const __u32 *p)
60207 {
60208 - return (__force __be32)__swab32p(p);
60209 + return (__force const __be32)__swab32p(p);
60210 }
60211 static inline __u32 __be32_to_cpup(const __be32 *p)
60212 {
60213 - return __swab32p((__u32 *)p);
60214 + return __swab32p((const __u32 *)p);
60215 }
60216 static inline __be16 __cpu_to_be16p(const __u16 *p)
60217 {
60218 - return (__force __be16)__swab16p(p);
60219 + return (__force const __be16)__swab16p(p);
60220 }
60221 static inline __u16 __be16_to_cpup(const __be16 *p)
60222 {
60223 - return __swab16p((__u16 *)p);
60224 + return __swab16p((const __u16 *)p);
60225 }
60226 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
60227 #define __le64_to_cpus(x) do { (void)(x); } while (0)
60228 diff --git a/include/linux/cache.h b/include/linux/cache.h
60229 index 4c57065..4307975 100644
60230 --- a/include/linux/cache.h
60231 +++ b/include/linux/cache.h
60232 @@ -16,6 +16,10 @@
60233 #define __read_mostly
60234 #endif
60235
60236 +#ifndef __read_only
60237 +#define __read_only __read_mostly
60238 +#endif
60239 +
60240 #ifndef ____cacheline_aligned
60241 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
60242 #endif
60243 diff --git a/include/linux/capability.h b/include/linux/capability.h
60244 index 12d52de..b5f7fa7 100644
60245 --- a/include/linux/capability.h
60246 +++ b/include/linux/capability.h
60247 @@ -548,6 +548,8 @@ extern bool has_ns_capability_noaudit(struct task_struct *t,
60248 extern bool capable(int cap);
60249 extern bool ns_capable(struct user_namespace *ns, int cap);
60250 extern bool nsown_capable(int cap);
60251 +extern bool capable_nolog(int cap);
60252 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
60253
60254 /* audit system wants to get cap info from files as well */
60255 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
60256 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
60257 index 04ffb2e..6799180 100644
60258 --- a/include/linux/cleancache.h
60259 +++ b/include/linux/cleancache.h
60260 @@ -31,7 +31,7 @@ struct cleancache_ops {
60261 void (*flush_page)(int, struct cleancache_filekey, pgoff_t);
60262 void (*flush_inode)(int, struct cleancache_filekey);
60263 void (*flush_fs)(int);
60264 -};
60265 +} __no_const;
60266
60267 extern struct cleancache_ops
60268 cleancache_register_ops(struct cleancache_ops *ops);
60269 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
60270 index 2f40791..a62d196 100644
60271 --- a/include/linux/compiler-gcc4.h
60272 +++ b/include/linux/compiler-gcc4.h
60273 @@ -32,6 +32,16 @@
60274 #define __linktime_error(message) __attribute__((__error__(message)))
60275
60276 #if __GNUC_MINOR__ >= 5
60277 +
60278 +#ifdef CONSTIFY_PLUGIN
60279 +#define __no_const __attribute__((no_const))
60280 +#define __do_const __attribute__((do_const))
60281 +#endif
60282 +
60283 +#ifdef SIZE_OVERFLOW_PLUGIN
60284 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
60285 +#endif
60286 +
60287 /*
60288 * Mark a position in code as unreachable. This can be used to
60289 * suppress control flow warnings after asm blocks that transfer
60290 @@ -47,6 +57,11 @@
60291 #define __noclone __attribute__((__noclone__))
60292
60293 #endif
60294 +
60295 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
60296 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
60297 +#define __bos0(ptr) __bos((ptr), 0)
60298 +#define __bos1(ptr) __bos((ptr), 1)
60299 #endif
60300
60301 #if __GNUC_MINOR__ > 0
60302 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
60303 index 4a24354..7149ac2 100644
60304 --- a/include/linux/compiler.h
60305 +++ b/include/linux/compiler.h
60306 @@ -5,31 +5,62 @@
60307
60308 #ifdef __CHECKER__
60309 # define __user __attribute__((noderef, address_space(1)))
60310 +# define __force_user __force __user
60311 # define __kernel __attribute__((address_space(0)))
60312 +# define __force_kernel __force __kernel
60313 # define __safe __attribute__((safe))
60314 # define __force __attribute__((force))
60315 # define __nocast __attribute__((nocast))
60316 # define __iomem __attribute__((noderef, address_space(2)))
60317 +# define __force_iomem __force __iomem
60318 # define __acquires(x) __attribute__((context(x,0,1)))
60319 # define __releases(x) __attribute__((context(x,1,0)))
60320 # define __acquire(x) __context__(x,1)
60321 # define __release(x) __context__(x,-1)
60322 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
60323 # define __percpu __attribute__((noderef, address_space(3)))
60324 +# define __force_percpu __force __percpu
60325 #ifdef CONFIG_SPARSE_RCU_POINTER
60326 # define __rcu __attribute__((noderef, address_space(4)))
60327 +# define __force_rcu __force __rcu
60328 #else
60329 # define __rcu
60330 +# define __force_rcu
60331 #endif
60332 extern void __chk_user_ptr(const volatile void __user *);
60333 extern void __chk_io_ptr(const volatile void __iomem *);
60334 +#elif defined(CHECKER_PLUGIN)
60335 +//# define __user
60336 +//# define __force_user
60337 +//# define __kernel
60338 +//# define __force_kernel
60339 +# define __safe
60340 +# define __force
60341 +# define __nocast
60342 +# define __iomem
60343 +# define __force_iomem
60344 +# define __chk_user_ptr(x) (void)0
60345 +# define __chk_io_ptr(x) (void)0
60346 +# define __builtin_warning(x, y...) (1)
60347 +# define __acquires(x)
60348 +# define __releases(x)
60349 +# define __acquire(x) (void)0
60350 +# define __release(x) (void)0
60351 +# define __cond_lock(x,c) (c)
60352 +# define __percpu
60353 +# define __force_percpu
60354 +# define __rcu
60355 +# define __force_rcu
60356 #else
60357 # define __user
60358 +# define __force_user
60359 # define __kernel
60360 +# define __force_kernel
60361 # define __safe
60362 # define __force
60363 # define __nocast
60364 # define __iomem
60365 +# define __force_iomem
60366 # define __chk_user_ptr(x) (void)0
60367 # define __chk_io_ptr(x) (void)0
60368 # define __builtin_warning(x, y...) (1)
60369 @@ -39,7 +70,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
60370 # define __release(x) (void)0
60371 # define __cond_lock(x,c) (c)
60372 # define __percpu
60373 +# define __force_percpu
60374 # define __rcu
60375 +# define __force_rcu
60376 #endif
60377
60378 #ifdef __KERNEL__
60379 @@ -264,6 +297,18 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
60380 # define __attribute_const__ /* unimplemented */
60381 #endif
60382
60383 +#ifndef __no_const
60384 +# define __no_const
60385 +#endif
60386 +
60387 +#ifndef __do_const
60388 +# define __do_const
60389 +#endif
60390 +
60391 +#ifndef __size_overflow
60392 +# define __size_overflow(...)
60393 +#endif
60394 +
60395 /*
60396 * Tell gcc if a function is cold. The compiler will assume any path
60397 * directly leading to the call is unlikely.
60398 @@ -273,6 +318,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
60399 #define __cold
60400 #endif
60401
60402 +#ifndef __alloc_size
60403 +#define __alloc_size(...)
60404 +#endif
60405 +
60406 +#ifndef __bos
60407 +#define __bos(ptr, arg)
60408 +#endif
60409 +
60410 +#ifndef __bos0
60411 +#define __bos0(ptr)
60412 +#endif
60413 +
60414 +#ifndef __bos1
60415 +#define __bos1(ptr)
60416 +#endif
60417 +
60418 /* Simple shorthand for a section definition */
60419 #ifndef __section
60420 # define __section(S) __attribute__ ((__section__(#S)))
60421 @@ -308,6 +369,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
60422 * use is to mediate communication between process-level code and irq/NMI
60423 * handlers, all running on the same CPU.
60424 */
60425 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
60426 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
60427 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
60428
60429 #endif /* __LINUX_COMPILER_H */
60430 diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
60431 index e9eaec5..bfeb9bb 100644
60432 --- a/include/linux/cpuset.h
60433 +++ b/include/linux/cpuset.h
60434 @@ -118,7 +118,7 @@ static inline void put_mems_allowed(void)
60435 * nodemask.
60436 */
60437 smp_mb();
60438 - --ACCESS_ONCE(current->mems_allowed_change_disable);
60439 + --ACCESS_ONCE_RW(current->mems_allowed_change_disable);
60440 }
60441
60442 static inline void set_mems_allowed(nodemask_t nodemask)
60443 diff --git a/include/linux/cred.h b/include/linux/cred.h
60444 index adadf71..6af5560 100644
60445 --- a/include/linux/cred.h
60446 +++ b/include/linux/cred.h
60447 @@ -207,6 +207,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
60448 static inline void validate_process_creds(void)
60449 {
60450 }
60451 +static inline void validate_task_creds(struct task_struct *task)
60452 +{
60453 +}
60454 #endif
60455
60456 /**
60457 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
60458 index 8a94217..15d49e3 100644
60459 --- a/include/linux/crypto.h
60460 +++ b/include/linux/crypto.h
60461 @@ -365,7 +365,7 @@ struct cipher_tfm {
60462 const u8 *key, unsigned int keylen);
60463 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
60464 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
60465 -};
60466 +} __no_const;
60467
60468 struct hash_tfm {
60469 int (*init)(struct hash_desc *desc);
60470 @@ -386,13 +386,13 @@ struct compress_tfm {
60471 int (*cot_decompress)(struct crypto_tfm *tfm,
60472 const u8 *src, unsigned int slen,
60473 u8 *dst, unsigned int *dlen);
60474 -};
60475 +} __no_const;
60476
60477 struct rng_tfm {
60478 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
60479 unsigned int dlen);
60480 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
60481 -};
60482 +} __no_const;
60483
60484 #define crt_ablkcipher crt_u.ablkcipher
60485 #define crt_aead crt_u.aead
60486 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
60487 index 7925bf0..d5143d2 100644
60488 --- a/include/linux/decompress/mm.h
60489 +++ b/include/linux/decompress/mm.h
60490 @@ -77,7 +77,7 @@ static void free(void *where)
60491 * warnings when not needed (indeed large_malloc / large_free are not
60492 * needed by inflate */
60493
60494 -#define malloc(a) kmalloc(a, GFP_KERNEL)
60495 +#define malloc(a) kmalloc((a), GFP_KERNEL)
60496 #define free(a) kfree(a)
60497
60498 #define large_malloc(a) vmalloc(a)
60499 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
60500 index e13117c..e9fc938 100644
60501 --- a/include/linux/dma-mapping.h
60502 +++ b/include/linux/dma-mapping.h
60503 @@ -46,7 +46,7 @@ struct dma_map_ops {
60504 u64 (*get_required_mask)(struct device *dev);
60505 #endif
60506 int is_phys;
60507 -};
60508 +} __do_const;
60509
60510 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
60511
60512 diff --git a/include/linux/efi.h b/include/linux/efi.h
60513 index 7cce0ea..c2085e4 100644
60514 --- a/include/linux/efi.h
60515 +++ b/include/linux/efi.h
60516 @@ -591,7 +591,7 @@ struct efivar_operations {
60517 efi_get_variable_t *get_variable;
60518 efi_get_next_variable_t *get_next_variable;
60519 efi_set_variable_t *set_variable;
60520 -};
60521 +} __no_const;
60522
60523 struct efivars {
60524 /*
60525 diff --git a/include/linux/elf.h b/include/linux/elf.h
60526 index 999b4f5..57753b4 100644
60527 --- a/include/linux/elf.h
60528 +++ b/include/linux/elf.h
60529 @@ -40,6 +40,17 @@ typedef __s64 Elf64_Sxword;
60530 #define PT_GNU_EH_FRAME 0x6474e550
60531
60532 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
60533 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
60534 +
60535 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
60536 +
60537 +/* Constants for the e_flags field */
60538 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
60539 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
60540 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
60541 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
60542 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
60543 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
60544
60545 /*
60546 * Extended Numbering
60547 @@ -97,6 +108,8 @@ typedef __s64 Elf64_Sxword;
60548 #define DT_DEBUG 21
60549 #define DT_TEXTREL 22
60550 #define DT_JMPREL 23
60551 +#define DT_FLAGS 30
60552 + #define DF_TEXTREL 0x00000004
60553 #define DT_ENCODING 32
60554 #define OLD_DT_LOOS 0x60000000
60555 #define DT_LOOS 0x6000000d
60556 @@ -243,6 +256,19 @@ typedef struct elf64_hdr {
60557 #define PF_W 0x2
60558 #define PF_X 0x1
60559
60560 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
60561 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
60562 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
60563 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
60564 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
60565 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
60566 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
60567 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
60568 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
60569 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
60570 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
60571 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
60572 +
60573 typedef struct elf32_phdr{
60574 Elf32_Word p_type;
60575 Elf32_Off p_offset;
60576 @@ -335,6 +361,8 @@ typedef struct elf64_shdr {
60577 #define EI_OSABI 7
60578 #define EI_PAD 8
60579
60580 +#define EI_PAX 14
60581 +
60582 #define ELFMAG0 0x7f /* EI_MAG */
60583 #define ELFMAG1 'E'
60584 #define ELFMAG2 'L'
60585 @@ -421,6 +449,7 @@ extern Elf32_Dyn _DYNAMIC [];
60586 #define elf_note elf32_note
60587 #define elf_addr_t Elf32_Off
60588 #define Elf_Half Elf32_Half
60589 +#define elf_dyn Elf32_Dyn
60590
60591 #else
60592
60593 @@ -431,6 +460,7 @@ extern Elf64_Dyn _DYNAMIC [];
60594 #define elf_note elf64_note
60595 #define elf_addr_t Elf64_Off
60596 #define Elf_Half Elf64_Half
60597 +#define elf_dyn Elf64_Dyn
60598
60599 #endif
60600
60601 diff --git a/include/linux/filter.h b/include/linux/filter.h
60602 index 8eeb205..d59bfa2 100644
60603 --- a/include/linux/filter.h
60604 +++ b/include/linux/filter.h
60605 @@ -134,6 +134,7 @@ struct sock_fprog { /* Required for SO_ATTACH_FILTER. */
60606
60607 struct sk_buff;
60608 struct sock;
60609 +struct bpf_jit_work;
60610
60611 struct sk_filter
60612 {
60613 @@ -141,6 +142,9 @@ struct sk_filter
60614 unsigned int len; /* Number of filter blocks */
60615 unsigned int (*bpf_func)(const struct sk_buff *skb,
60616 const struct sock_filter *filter);
60617 +#ifdef CONFIG_BPF_JIT
60618 + struct bpf_jit_work *work;
60619 +#endif
60620 struct rcu_head rcu;
60621 struct sock_filter insns[0];
60622 };
60623 diff --git a/include/linux/firewire.h b/include/linux/firewire.h
60624 index 84ccf8e..2e9b14c 100644
60625 --- a/include/linux/firewire.h
60626 +++ b/include/linux/firewire.h
60627 @@ -428,7 +428,7 @@ struct fw_iso_context {
60628 union {
60629 fw_iso_callback_t sc;
60630 fw_iso_mc_callback_t mc;
60631 - } callback;
60632 + } __no_const callback;
60633 void *callback_data;
60634 };
60635
60636 diff --git a/include/linux/fs.h b/include/linux/fs.h
60637 index f4b6e06..d6ba573 100644
60638 --- a/include/linux/fs.h
60639 +++ b/include/linux/fs.h
60640 @@ -1628,7 +1628,8 @@ struct file_operations {
60641 int (*setlease)(struct file *, long, struct file_lock **);
60642 long (*fallocate)(struct file *file, int mode, loff_t offset,
60643 loff_t len);
60644 -};
60645 +} __do_const;
60646 +typedef struct file_operations __no_const file_operations_no_const;
60647
60648 struct inode_operations {
60649 struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *);
60650 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
60651 index 003dc0f..3c4ea97 100644
60652 --- a/include/linux/fs_struct.h
60653 +++ b/include/linux/fs_struct.h
60654 @@ -6,7 +6,7 @@
60655 #include <linux/seqlock.h>
60656
60657 struct fs_struct {
60658 - int users;
60659 + atomic_t users;
60660 spinlock_t lock;
60661 seqcount_t seq;
60662 int umask;
60663 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
60664 index ce31408..b1ad003 100644
60665 --- a/include/linux/fscache-cache.h
60666 +++ b/include/linux/fscache-cache.h
60667 @@ -102,7 +102,7 @@ struct fscache_operation {
60668 fscache_operation_release_t release;
60669 };
60670
60671 -extern atomic_t fscache_op_debug_id;
60672 +extern atomic_unchecked_t fscache_op_debug_id;
60673 extern void fscache_op_work_func(struct work_struct *work);
60674
60675 extern void fscache_enqueue_operation(struct fscache_operation *);
60676 @@ -122,7 +122,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
60677 {
60678 INIT_WORK(&op->work, fscache_op_work_func);
60679 atomic_set(&op->usage, 1);
60680 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
60681 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
60682 op->processor = processor;
60683 op->release = release;
60684 INIT_LIST_HEAD(&op->pend_link);
60685 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
60686 index 2a53f10..0187fdf 100644
60687 --- a/include/linux/fsnotify.h
60688 +++ b/include/linux/fsnotify.h
60689 @@ -314,7 +314,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
60690 */
60691 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
60692 {
60693 - return kstrdup(name, GFP_KERNEL);
60694 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
60695 }
60696
60697 /*
60698 diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
60699 index 91d0e0a3..035666b 100644
60700 --- a/include/linux/fsnotify_backend.h
60701 +++ b/include/linux/fsnotify_backend.h
60702 @@ -105,6 +105,7 @@ struct fsnotify_ops {
60703 void (*freeing_mark)(struct fsnotify_mark *mark, struct fsnotify_group *group);
60704 void (*free_event_priv)(struct fsnotify_event_private_data *priv);
60705 };
60706 +typedef struct fsnotify_ops __no_const fsnotify_ops_no_const;
60707
60708 /*
60709 * A group is a "thing" that wants to receive notification about filesystem
60710 diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
60711 index c3da42d..c70e0df 100644
60712 --- a/include/linux/ftrace_event.h
60713 +++ b/include/linux/ftrace_event.h
60714 @@ -97,7 +97,7 @@ struct trace_event_functions {
60715 trace_print_func raw;
60716 trace_print_func hex;
60717 trace_print_func binary;
60718 -};
60719 +} __no_const;
60720
60721 struct trace_event {
60722 struct hlist_node node;
60723 @@ -254,7 +254,7 @@ extern int trace_define_field(struct ftrace_event_call *call, const char *type,
60724 extern int trace_add_event_call(struct ftrace_event_call *call);
60725 extern void trace_remove_event_call(struct ftrace_event_call *call);
60726
60727 -#define is_signed_type(type) (((type)(-1)) < 0)
60728 +#define is_signed_type(type) (((type)(-1)) < (type)1)
60729
60730 int trace_set_clr_event(const char *system, const char *event, int set);
60731
60732 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
60733 index e61d319..0da8505 100644
60734 --- a/include/linux/genhd.h
60735 +++ b/include/linux/genhd.h
60736 @@ -185,7 +185,7 @@ struct gendisk {
60737 struct kobject *slave_dir;
60738
60739 struct timer_rand_state *random;
60740 - atomic_t sync_io; /* RAID */
60741 + atomic_unchecked_t sync_io; /* RAID */
60742 struct disk_events *ev;
60743 #ifdef CONFIG_BLK_DEV_INTEGRITY
60744 struct blk_integrity *integrity;
60745 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
60746 new file mode 100644
60747 index 0000000..8a130b6
60748 --- /dev/null
60749 +++ b/include/linux/gracl.h
60750 @@ -0,0 +1,319 @@
60751 +#ifndef GR_ACL_H
60752 +#define GR_ACL_H
60753 +
60754 +#include <linux/grdefs.h>
60755 +#include <linux/resource.h>
60756 +#include <linux/capability.h>
60757 +#include <linux/dcache.h>
60758 +#include <asm/resource.h>
60759 +
60760 +/* Major status information */
60761 +
60762 +#define GR_VERSION "grsecurity 2.9"
60763 +#define GRSECURITY_VERSION 0x2900
60764 +
60765 +enum {
60766 + GR_SHUTDOWN = 0,
60767 + GR_ENABLE = 1,
60768 + GR_SPROLE = 2,
60769 + GR_RELOAD = 3,
60770 + GR_SEGVMOD = 4,
60771 + GR_STATUS = 5,
60772 + GR_UNSPROLE = 6,
60773 + GR_PASSSET = 7,
60774 + GR_SPROLEPAM = 8,
60775 +};
60776 +
60777 +/* Password setup definitions
60778 + * kernel/grhash.c */
60779 +enum {
60780 + GR_PW_LEN = 128,
60781 + GR_SALT_LEN = 16,
60782 + GR_SHA_LEN = 32,
60783 +};
60784 +
60785 +enum {
60786 + GR_SPROLE_LEN = 64,
60787 +};
60788 +
60789 +enum {
60790 + GR_NO_GLOB = 0,
60791 + GR_REG_GLOB,
60792 + GR_CREATE_GLOB
60793 +};
60794 +
60795 +#define GR_NLIMITS 32
60796 +
60797 +/* Begin Data Structures */
60798 +
60799 +struct sprole_pw {
60800 + unsigned char *rolename;
60801 + unsigned char salt[GR_SALT_LEN];
60802 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
60803 +};
60804 +
60805 +struct name_entry {
60806 + __u32 key;
60807 + ino_t inode;
60808 + dev_t device;
60809 + char *name;
60810 + __u16 len;
60811 + __u8 deleted;
60812 + struct name_entry *prev;
60813 + struct name_entry *next;
60814 +};
60815 +
60816 +struct inodev_entry {
60817 + struct name_entry *nentry;
60818 + struct inodev_entry *prev;
60819 + struct inodev_entry *next;
60820 +};
60821 +
60822 +struct acl_role_db {
60823 + struct acl_role_label **r_hash;
60824 + __u32 r_size;
60825 +};
60826 +
60827 +struct inodev_db {
60828 + struct inodev_entry **i_hash;
60829 + __u32 i_size;
60830 +};
60831 +
60832 +struct name_db {
60833 + struct name_entry **n_hash;
60834 + __u32 n_size;
60835 +};
60836 +
60837 +struct crash_uid {
60838 + uid_t uid;
60839 + unsigned long expires;
60840 +};
60841 +
60842 +struct gr_hash_struct {
60843 + void **table;
60844 + void **nametable;
60845 + void *first;
60846 + __u32 table_size;
60847 + __u32 used_size;
60848 + int type;
60849 +};
60850 +
60851 +/* Userspace Grsecurity ACL data structures */
60852 +
60853 +struct acl_subject_label {
60854 + char *filename;
60855 + ino_t inode;
60856 + dev_t device;
60857 + __u32 mode;
60858 + kernel_cap_t cap_mask;
60859 + kernel_cap_t cap_lower;
60860 + kernel_cap_t cap_invert_audit;
60861 +
60862 + struct rlimit res[GR_NLIMITS];
60863 + __u32 resmask;
60864 +
60865 + __u8 user_trans_type;
60866 + __u8 group_trans_type;
60867 + uid_t *user_transitions;
60868 + gid_t *group_transitions;
60869 + __u16 user_trans_num;
60870 + __u16 group_trans_num;
60871 +
60872 + __u32 sock_families[2];
60873 + __u32 ip_proto[8];
60874 + __u32 ip_type;
60875 + struct acl_ip_label **ips;
60876 + __u32 ip_num;
60877 + __u32 inaddr_any_override;
60878 +
60879 + __u32 crashes;
60880 + unsigned long expires;
60881 +
60882 + struct acl_subject_label *parent_subject;
60883 + struct gr_hash_struct *hash;
60884 + struct acl_subject_label *prev;
60885 + struct acl_subject_label *next;
60886 +
60887 + struct acl_object_label **obj_hash;
60888 + __u32 obj_hash_size;
60889 + __u16 pax_flags;
60890 +};
60891 +
60892 +struct role_allowed_ip {
60893 + __u32 addr;
60894 + __u32 netmask;
60895 +
60896 + struct role_allowed_ip *prev;
60897 + struct role_allowed_ip *next;
60898 +};
60899 +
60900 +struct role_transition {
60901 + char *rolename;
60902 +
60903 + struct role_transition *prev;
60904 + struct role_transition *next;
60905 +};
60906 +
60907 +struct acl_role_label {
60908 + char *rolename;
60909 + uid_t uidgid;
60910 + __u16 roletype;
60911 +
60912 + __u16 auth_attempts;
60913 + unsigned long expires;
60914 +
60915 + struct acl_subject_label *root_label;
60916 + struct gr_hash_struct *hash;
60917 +
60918 + struct acl_role_label *prev;
60919 + struct acl_role_label *next;
60920 +
60921 + struct role_transition *transitions;
60922 + struct role_allowed_ip *allowed_ips;
60923 + uid_t *domain_children;
60924 + __u16 domain_child_num;
60925 +
60926 + umode_t umask;
60927 +
60928 + struct acl_subject_label **subj_hash;
60929 + __u32 subj_hash_size;
60930 +};
60931 +
60932 +struct user_acl_role_db {
60933 + struct acl_role_label **r_table;
60934 + __u32 num_pointers; /* Number of allocations to track */
60935 + __u32 num_roles; /* Number of roles */
60936 + __u32 num_domain_children; /* Number of domain children */
60937 + __u32 num_subjects; /* Number of subjects */
60938 + __u32 num_objects; /* Number of objects */
60939 +};
60940 +
60941 +struct acl_object_label {
60942 + char *filename;
60943 + ino_t inode;
60944 + dev_t device;
60945 + __u32 mode;
60946 +
60947 + struct acl_subject_label *nested;
60948 + struct acl_object_label *globbed;
60949 +
60950 + /* next two structures not used */
60951 +
60952 + struct acl_object_label *prev;
60953 + struct acl_object_label *next;
60954 +};
60955 +
60956 +struct acl_ip_label {
60957 + char *iface;
60958 + __u32 addr;
60959 + __u32 netmask;
60960 + __u16 low, high;
60961 + __u8 mode;
60962 + __u32 type;
60963 + __u32 proto[8];
60964 +
60965 + /* next two structures not used */
60966 +
60967 + struct acl_ip_label *prev;
60968 + struct acl_ip_label *next;
60969 +};
60970 +
60971 +struct gr_arg {
60972 + struct user_acl_role_db role_db;
60973 + unsigned char pw[GR_PW_LEN];
60974 + unsigned char salt[GR_SALT_LEN];
60975 + unsigned char sum[GR_SHA_LEN];
60976 + unsigned char sp_role[GR_SPROLE_LEN];
60977 + struct sprole_pw *sprole_pws;
60978 + dev_t segv_device;
60979 + ino_t segv_inode;
60980 + uid_t segv_uid;
60981 + __u16 num_sprole_pws;
60982 + __u16 mode;
60983 +};
60984 +
60985 +struct gr_arg_wrapper {
60986 + struct gr_arg *arg;
60987 + __u32 version;
60988 + __u32 size;
60989 +};
60990 +
60991 +struct subject_map {
60992 + struct acl_subject_label *user;
60993 + struct acl_subject_label *kernel;
60994 + struct subject_map *prev;
60995 + struct subject_map *next;
60996 +};
60997 +
60998 +struct acl_subj_map_db {
60999 + struct subject_map **s_hash;
61000 + __u32 s_size;
61001 +};
61002 +
61003 +/* End Data Structures Section */
61004 +
61005 +/* Hash functions generated by empirical testing by Brad Spengler
61006 + Makes good use of the low bits of the inode. Generally 0-1 times
61007 + in loop for successful match. 0-3 for unsuccessful match.
61008 + Shift/add algorithm with modulus of table size and an XOR*/
61009 +
61010 +static __inline__ unsigned int
61011 +rhash(const uid_t uid, const __u16 type, const unsigned int sz)
61012 +{
61013 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
61014 +}
61015 +
61016 + static __inline__ unsigned int
61017 +shash(const struct acl_subject_label *userp, const unsigned int sz)
61018 +{
61019 + return ((const unsigned long)userp % sz);
61020 +}
61021 +
61022 +static __inline__ unsigned int
61023 +fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
61024 +{
61025 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
61026 +}
61027 +
61028 +static __inline__ unsigned int
61029 +nhash(const char *name, const __u16 len, const unsigned int sz)
61030 +{
61031 + return full_name_hash((const unsigned char *)name, len) % sz;
61032 +}
61033 +
61034 +#define FOR_EACH_ROLE_START(role) \
61035 + role = role_list; \
61036 + while (role) {
61037 +
61038 +#define FOR_EACH_ROLE_END(role) \
61039 + role = role->prev; \
61040 + }
61041 +
61042 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
61043 + subj = NULL; \
61044 + iter = 0; \
61045 + while (iter < role->subj_hash_size) { \
61046 + if (subj == NULL) \
61047 + subj = role->subj_hash[iter]; \
61048 + if (subj == NULL) { \
61049 + iter++; \
61050 + continue; \
61051 + }
61052 +
61053 +#define FOR_EACH_SUBJECT_END(subj,iter) \
61054 + subj = subj->next; \
61055 + if (subj == NULL) \
61056 + iter++; \
61057 + }
61058 +
61059 +
61060 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
61061 + subj = role->hash->first; \
61062 + while (subj != NULL) {
61063 +
61064 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
61065 + subj = subj->next; \
61066 + }
61067 +
61068 +#endif
61069 +
61070 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
61071 new file mode 100644
61072 index 0000000..323ecf2
61073 --- /dev/null
61074 +++ b/include/linux/gralloc.h
61075 @@ -0,0 +1,9 @@
61076 +#ifndef __GRALLOC_H
61077 +#define __GRALLOC_H
61078 +
61079 +void acl_free_all(void);
61080 +int acl_alloc_stack_init(unsigned long size);
61081 +void *acl_alloc(unsigned long len);
61082 +void *acl_alloc_num(unsigned long num, unsigned long len);
61083 +
61084 +#endif
61085 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
61086 new file mode 100644
61087 index 0000000..b30e9bc
61088 --- /dev/null
61089 +++ b/include/linux/grdefs.h
61090 @@ -0,0 +1,140 @@
61091 +#ifndef GRDEFS_H
61092 +#define GRDEFS_H
61093 +
61094 +/* Begin grsecurity status declarations */
61095 +
61096 +enum {
61097 + GR_READY = 0x01,
61098 + GR_STATUS_INIT = 0x00 // disabled state
61099 +};
61100 +
61101 +/* Begin ACL declarations */
61102 +
61103 +/* Role flags */
61104 +
61105 +enum {
61106 + GR_ROLE_USER = 0x0001,
61107 + GR_ROLE_GROUP = 0x0002,
61108 + GR_ROLE_DEFAULT = 0x0004,
61109 + GR_ROLE_SPECIAL = 0x0008,
61110 + GR_ROLE_AUTH = 0x0010,
61111 + GR_ROLE_NOPW = 0x0020,
61112 + GR_ROLE_GOD = 0x0040,
61113 + GR_ROLE_LEARN = 0x0080,
61114 + GR_ROLE_TPE = 0x0100,
61115 + GR_ROLE_DOMAIN = 0x0200,
61116 + GR_ROLE_PAM = 0x0400,
61117 + GR_ROLE_PERSIST = 0x0800
61118 +};
61119 +
61120 +/* ACL Subject and Object mode flags */
61121 +enum {
61122 + GR_DELETED = 0x80000000
61123 +};
61124 +
61125 +/* ACL Object-only mode flags */
61126 +enum {
61127 + GR_READ = 0x00000001,
61128 + GR_APPEND = 0x00000002,
61129 + GR_WRITE = 0x00000004,
61130 + GR_EXEC = 0x00000008,
61131 + GR_FIND = 0x00000010,
61132 + GR_INHERIT = 0x00000020,
61133 + GR_SETID = 0x00000040,
61134 + GR_CREATE = 0x00000080,
61135 + GR_DELETE = 0x00000100,
61136 + GR_LINK = 0x00000200,
61137 + GR_AUDIT_READ = 0x00000400,
61138 + GR_AUDIT_APPEND = 0x00000800,
61139 + GR_AUDIT_WRITE = 0x00001000,
61140 + GR_AUDIT_EXEC = 0x00002000,
61141 + GR_AUDIT_FIND = 0x00004000,
61142 + GR_AUDIT_INHERIT= 0x00008000,
61143 + GR_AUDIT_SETID = 0x00010000,
61144 + GR_AUDIT_CREATE = 0x00020000,
61145 + GR_AUDIT_DELETE = 0x00040000,
61146 + GR_AUDIT_LINK = 0x00080000,
61147 + GR_PTRACERD = 0x00100000,
61148 + GR_NOPTRACE = 0x00200000,
61149 + GR_SUPPRESS = 0x00400000,
61150 + GR_NOLEARN = 0x00800000,
61151 + GR_INIT_TRANSFER= 0x01000000
61152 +};
61153 +
61154 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
61155 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
61156 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
61157 +
61158 +/* ACL subject-only mode flags */
61159 +enum {
61160 + GR_KILL = 0x00000001,
61161 + GR_VIEW = 0x00000002,
61162 + GR_PROTECTED = 0x00000004,
61163 + GR_LEARN = 0x00000008,
61164 + GR_OVERRIDE = 0x00000010,
61165 + /* just a placeholder, this mode is only used in userspace */
61166 + GR_DUMMY = 0x00000020,
61167 + GR_PROTSHM = 0x00000040,
61168 + GR_KILLPROC = 0x00000080,
61169 + GR_KILLIPPROC = 0x00000100,
61170 + /* just a placeholder, this mode is only used in userspace */
61171 + GR_NOTROJAN = 0x00000200,
61172 + GR_PROTPROCFD = 0x00000400,
61173 + GR_PROCACCT = 0x00000800,
61174 + GR_RELAXPTRACE = 0x00001000,
61175 + GR_NESTED = 0x00002000,
61176 + GR_INHERITLEARN = 0x00004000,
61177 + GR_PROCFIND = 0x00008000,
61178 + GR_POVERRIDE = 0x00010000,
61179 + GR_KERNELAUTH = 0x00020000,
61180 + GR_ATSECURE = 0x00040000,
61181 + GR_SHMEXEC = 0x00080000
61182 +};
61183 +
61184 +enum {
61185 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
61186 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
61187 + GR_PAX_ENABLE_MPROTECT = 0x0004,
61188 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
61189 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
61190 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
61191 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
61192 + GR_PAX_DISABLE_MPROTECT = 0x0400,
61193 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
61194 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
61195 +};
61196 +
61197 +enum {
61198 + GR_ID_USER = 0x01,
61199 + GR_ID_GROUP = 0x02,
61200 +};
61201 +
61202 +enum {
61203 + GR_ID_ALLOW = 0x01,
61204 + GR_ID_DENY = 0x02,
61205 +};
61206 +
61207 +#define GR_CRASH_RES 31
61208 +#define GR_UIDTABLE_MAX 500
61209 +
61210 +/* begin resource learning section */
61211 +enum {
61212 + GR_RLIM_CPU_BUMP = 60,
61213 + GR_RLIM_FSIZE_BUMP = 50000,
61214 + GR_RLIM_DATA_BUMP = 10000,
61215 + GR_RLIM_STACK_BUMP = 1000,
61216 + GR_RLIM_CORE_BUMP = 10000,
61217 + GR_RLIM_RSS_BUMP = 500000,
61218 + GR_RLIM_NPROC_BUMP = 1,
61219 + GR_RLIM_NOFILE_BUMP = 5,
61220 + GR_RLIM_MEMLOCK_BUMP = 50000,
61221 + GR_RLIM_AS_BUMP = 500000,
61222 + GR_RLIM_LOCKS_BUMP = 2,
61223 + GR_RLIM_SIGPENDING_BUMP = 5,
61224 + GR_RLIM_MSGQUEUE_BUMP = 10000,
61225 + GR_RLIM_NICE_BUMP = 1,
61226 + GR_RLIM_RTPRIO_BUMP = 1,
61227 + GR_RLIM_RTTIME_BUMP = 1000000
61228 +};
61229 +
61230 +#endif
61231 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
61232 new file mode 100644
61233 index 0000000..da390f1
61234 --- /dev/null
61235 +++ b/include/linux/grinternal.h
61236 @@ -0,0 +1,221 @@
61237 +#ifndef __GRINTERNAL_H
61238 +#define __GRINTERNAL_H
61239 +
61240 +#ifdef CONFIG_GRKERNSEC
61241 +
61242 +#include <linux/fs.h>
61243 +#include <linux/mnt_namespace.h>
61244 +#include <linux/nsproxy.h>
61245 +#include <linux/gracl.h>
61246 +#include <linux/grdefs.h>
61247 +#include <linux/grmsg.h>
61248 +
61249 +void gr_add_learn_entry(const char *fmt, ...)
61250 + __attribute__ ((format (printf, 1, 2)));
61251 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
61252 + const struct vfsmount *mnt);
61253 +__u32 gr_check_create(const struct dentry *new_dentry,
61254 + const struct dentry *parent,
61255 + const struct vfsmount *mnt, const __u32 mode);
61256 +int gr_check_protected_task(const struct task_struct *task);
61257 +__u32 to_gr_audit(const __u32 reqmode);
61258 +int gr_set_acls(const int type);
61259 +int gr_apply_subject_to_task(struct task_struct *task);
61260 +int gr_acl_is_enabled(void);
61261 +char gr_roletype_to_char(void);
61262 +
61263 +void gr_handle_alertkill(struct task_struct *task);
61264 +char *gr_to_filename(const struct dentry *dentry,
61265 + const struct vfsmount *mnt);
61266 +char *gr_to_filename1(const struct dentry *dentry,
61267 + const struct vfsmount *mnt);
61268 +char *gr_to_filename2(const struct dentry *dentry,
61269 + const struct vfsmount *mnt);
61270 +char *gr_to_filename3(const struct dentry *dentry,
61271 + const struct vfsmount *mnt);
61272 +
61273 +extern int grsec_enable_ptrace_readexec;
61274 +extern int grsec_enable_harden_ptrace;
61275 +extern int grsec_enable_link;
61276 +extern int grsec_enable_fifo;
61277 +extern int grsec_enable_execve;
61278 +extern int grsec_enable_shm;
61279 +extern int grsec_enable_execlog;
61280 +extern int grsec_enable_signal;
61281 +extern int grsec_enable_audit_ptrace;
61282 +extern int grsec_enable_forkfail;
61283 +extern int grsec_enable_time;
61284 +extern int grsec_enable_rofs;
61285 +extern int grsec_enable_chroot_shmat;
61286 +extern int grsec_enable_chroot_mount;
61287 +extern int grsec_enable_chroot_double;
61288 +extern int grsec_enable_chroot_pivot;
61289 +extern int grsec_enable_chroot_chdir;
61290 +extern int grsec_enable_chroot_chmod;
61291 +extern int grsec_enable_chroot_mknod;
61292 +extern int grsec_enable_chroot_fchdir;
61293 +extern int grsec_enable_chroot_nice;
61294 +extern int grsec_enable_chroot_execlog;
61295 +extern int grsec_enable_chroot_caps;
61296 +extern int grsec_enable_chroot_sysctl;
61297 +extern int grsec_enable_chroot_unix;
61298 +extern int grsec_enable_tpe;
61299 +extern int grsec_tpe_gid;
61300 +extern int grsec_enable_tpe_all;
61301 +extern int grsec_enable_tpe_invert;
61302 +extern int grsec_enable_socket_all;
61303 +extern int grsec_socket_all_gid;
61304 +extern int grsec_enable_socket_client;
61305 +extern int grsec_socket_client_gid;
61306 +extern int grsec_enable_socket_server;
61307 +extern int grsec_socket_server_gid;
61308 +extern int grsec_audit_gid;
61309 +extern int grsec_enable_group;
61310 +extern int grsec_enable_audit_textrel;
61311 +extern int grsec_enable_log_rwxmaps;
61312 +extern int grsec_enable_mount;
61313 +extern int grsec_enable_chdir;
61314 +extern int grsec_resource_logging;
61315 +extern int grsec_enable_blackhole;
61316 +extern int grsec_lastack_retries;
61317 +extern int grsec_enable_brute;
61318 +extern int grsec_lock;
61319 +
61320 +extern spinlock_t grsec_alert_lock;
61321 +extern unsigned long grsec_alert_wtime;
61322 +extern unsigned long grsec_alert_fyet;
61323 +
61324 +extern spinlock_t grsec_audit_lock;
61325 +
61326 +extern rwlock_t grsec_exec_file_lock;
61327 +
61328 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
61329 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
61330 + (tsk)->exec_file->f_vfsmnt) : "/")
61331 +
61332 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
61333 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
61334 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
61335 +
61336 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
61337 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
61338 + (tsk)->exec_file->f_vfsmnt) : "/")
61339 +
61340 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
61341 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
61342 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
61343 +
61344 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
61345 +
61346 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
61347 +
61348 +#define DEFAULTSECARGS(task, cred, pcred) gr_task_fullpath(task), (task)->comm, \
61349 + (task)->pid, (cred)->uid, \
61350 + (cred)->euid, (cred)->gid, (cred)->egid, \
61351 + gr_parent_task_fullpath(task), \
61352 + (task)->real_parent->comm, (task)->real_parent->pid, \
61353 + (pcred)->uid, (pcred)->euid, \
61354 + (pcred)->gid, (pcred)->egid
61355 +
61356 +#define GR_CHROOT_CAPS {{ \
61357 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
61358 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
61359 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
61360 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
61361 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
61362 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
61363 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
61364 +
61365 +#define security_learn(normal_msg,args...) \
61366 +({ \
61367 + read_lock(&grsec_exec_file_lock); \
61368 + gr_add_learn_entry(normal_msg "\n", ## args); \
61369 + read_unlock(&grsec_exec_file_lock); \
61370 +})
61371 +
61372 +enum {
61373 + GR_DO_AUDIT,
61374 + GR_DONT_AUDIT,
61375 + /* used for non-audit messages that we shouldn't kill the task on */
61376 + GR_DONT_AUDIT_GOOD
61377 +};
61378 +
61379 +enum {
61380 + GR_TTYSNIFF,
61381 + GR_RBAC,
61382 + GR_RBAC_STR,
61383 + GR_STR_RBAC,
61384 + GR_RBAC_MODE2,
61385 + GR_RBAC_MODE3,
61386 + GR_FILENAME,
61387 + GR_SYSCTL_HIDDEN,
61388 + GR_NOARGS,
61389 + GR_ONE_INT,
61390 + GR_ONE_INT_TWO_STR,
61391 + GR_ONE_STR,
61392 + GR_STR_INT,
61393 + GR_TWO_STR_INT,
61394 + GR_TWO_INT,
61395 + GR_TWO_U64,
61396 + GR_THREE_INT,
61397 + GR_FIVE_INT_TWO_STR,
61398 + GR_TWO_STR,
61399 + GR_THREE_STR,
61400 + GR_FOUR_STR,
61401 + GR_STR_FILENAME,
61402 + GR_FILENAME_STR,
61403 + GR_FILENAME_TWO_INT,
61404 + GR_FILENAME_TWO_INT_STR,
61405 + GR_TEXTREL,
61406 + GR_PTRACE,
61407 + GR_RESOURCE,
61408 + GR_CAP,
61409 + GR_SIG,
61410 + GR_SIG2,
61411 + GR_CRASH1,
61412 + GR_CRASH2,
61413 + GR_PSACCT,
61414 + GR_RWXMAP
61415 +};
61416 +
61417 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
61418 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
61419 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
61420 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
61421 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
61422 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
61423 +#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)
61424 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
61425 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
61426 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
61427 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
61428 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
61429 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
61430 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
61431 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
61432 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
61433 +#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)
61434 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
61435 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
61436 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
61437 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
61438 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
61439 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
61440 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
61441 +#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)
61442 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
61443 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
61444 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
61445 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
61446 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
61447 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
61448 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
61449 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
61450 +#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)
61451 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
61452 +
61453 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
61454 +
61455 +#endif
61456 +
61457 +#endif
61458 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
61459 new file mode 100644
61460 index 0000000..ae576a1
61461 --- /dev/null
61462 +++ b/include/linux/grmsg.h
61463 @@ -0,0 +1,109 @@
61464 +#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"
61465 +#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"
61466 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
61467 +#define GR_STOPMOD_MSG "denied modification of module state by "
61468 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
61469 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
61470 +#define GR_IOPERM_MSG "denied use of ioperm() by "
61471 +#define GR_IOPL_MSG "denied use of iopl() by "
61472 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
61473 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
61474 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
61475 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
61476 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
61477 +#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"
61478 +#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"
61479 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
61480 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
61481 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
61482 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
61483 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
61484 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
61485 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
61486 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
61487 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
61488 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
61489 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
61490 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
61491 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
61492 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
61493 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
61494 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
61495 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
61496 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
61497 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
61498 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
61499 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
61500 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
61501 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
61502 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
61503 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
61504 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
61505 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
61506 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
61507 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
61508 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
61509 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
61510 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
61511 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
61512 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
61513 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
61514 +#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"
61515 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
61516 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
61517 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
61518 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
61519 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
61520 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
61521 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
61522 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
61523 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
61524 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
61525 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
61526 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
61527 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
61528 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
61529 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
61530 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
61531 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
61532 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
61533 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
61534 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
61535 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
61536 +#define GR_NICE_CHROOT_MSG "denied priority change by "
61537 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
61538 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
61539 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
61540 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
61541 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
61542 +#define GR_TIME_MSG "time set by "
61543 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
61544 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
61545 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
61546 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
61547 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
61548 +#define GR_BIND_MSG "denied bind() by "
61549 +#define GR_CONNECT_MSG "denied connect() by "
61550 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
61551 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
61552 +#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"
61553 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
61554 +#define GR_CAP_ACL_MSG "use of %s denied for "
61555 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
61556 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
61557 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
61558 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
61559 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
61560 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
61561 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
61562 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
61563 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
61564 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
61565 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
61566 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
61567 +#define GR_TEXTREL_AUDIT_MSG "text relocation in %s, VMA:0x%08lx 0x%08lx by "
61568 +#define GR_VM86_MSG "denied use of vm86 by "
61569 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
61570 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
61571 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
61572 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
61573 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
61574 new file mode 100644
61575 index 0000000..acd05db
61576 --- /dev/null
61577 +++ b/include/linux/grsecurity.h
61578 @@ -0,0 +1,232 @@
61579 +#ifndef GR_SECURITY_H
61580 +#define GR_SECURITY_H
61581 +#include <linux/fs.h>
61582 +#include <linux/fs_struct.h>
61583 +#include <linux/binfmts.h>
61584 +#include <linux/gracl.h>
61585 +
61586 +/* notify of brain-dead configs */
61587 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61588 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
61589 +#endif
61590 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
61591 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
61592 +#endif
61593 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
61594 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
61595 +#endif
61596 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
61597 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
61598 +#endif
61599 +
61600 +#include <linux/compat.h>
61601 +
61602 +struct user_arg_ptr {
61603 +#ifdef CONFIG_COMPAT
61604 + bool is_compat;
61605 +#endif
61606 + union {
61607 + const char __user *const __user *native;
61608 +#ifdef CONFIG_COMPAT
61609 + compat_uptr_t __user *compat;
61610 +#endif
61611 + } ptr;
61612 +};
61613 +
61614 +void gr_handle_brute_attach(struct task_struct *p, unsigned long mm_flags);
61615 +void gr_handle_brute_check(void);
61616 +void gr_handle_kernel_exploit(void);
61617 +int gr_process_user_ban(void);
61618 +
61619 +char gr_roletype_to_char(void);
61620 +
61621 +int gr_acl_enable_at_secure(void);
61622 +
61623 +int gr_check_user_change(int real, int effective, int fs);
61624 +int gr_check_group_change(int real, int effective, int fs);
61625 +
61626 +void gr_del_task_from_ip_table(struct task_struct *p);
61627 +
61628 +int gr_pid_is_chrooted(struct task_struct *p);
61629 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
61630 +int gr_handle_chroot_nice(void);
61631 +int gr_handle_chroot_sysctl(const int op);
61632 +int gr_handle_chroot_setpriority(struct task_struct *p,
61633 + const int niceval);
61634 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
61635 +int gr_handle_chroot_chroot(const struct dentry *dentry,
61636 + const struct vfsmount *mnt);
61637 +void gr_handle_chroot_chdir(struct path *path);
61638 +int gr_handle_chroot_chmod(const struct dentry *dentry,
61639 + const struct vfsmount *mnt, const int mode);
61640 +int gr_handle_chroot_mknod(const struct dentry *dentry,
61641 + const struct vfsmount *mnt, const int mode);
61642 +int gr_handle_chroot_mount(const struct dentry *dentry,
61643 + const struct vfsmount *mnt,
61644 + const char *dev_name);
61645 +int gr_handle_chroot_pivot(void);
61646 +int gr_handle_chroot_unix(const pid_t pid);
61647 +
61648 +int gr_handle_rawio(const struct inode *inode);
61649 +
61650 +void gr_handle_ioperm(void);
61651 +void gr_handle_iopl(void);
61652 +
61653 +umode_t gr_acl_umask(void);
61654 +
61655 +int gr_tpe_allow(const struct file *file);
61656 +
61657 +void gr_set_chroot_entries(struct task_struct *task, struct path *path);
61658 +void gr_clear_chroot_entries(struct task_struct *task);
61659 +
61660 +void gr_log_forkfail(const int retval);
61661 +void gr_log_timechange(void);
61662 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
61663 +void gr_log_chdir(const struct dentry *dentry,
61664 + const struct vfsmount *mnt);
61665 +void gr_log_chroot_exec(const struct dentry *dentry,
61666 + const struct vfsmount *mnt);
61667 +void gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv);
61668 +void gr_log_remount(const char *devname, const int retval);
61669 +void gr_log_unmount(const char *devname, const int retval);
61670 +void gr_log_mount(const char *from, const char *to, const int retval);
61671 +void gr_log_textrel(struct vm_area_struct *vma);
61672 +void gr_log_rwxmmap(struct file *file);
61673 +void gr_log_rwxmprotect(struct file *file);
61674 +
61675 +int gr_handle_follow_link(const struct inode *parent,
61676 + const struct inode *inode,
61677 + const struct dentry *dentry,
61678 + const struct vfsmount *mnt);
61679 +int gr_handle_fifo(const struct dentry *dentry,
61680 + const struct vfsmount *mnt,
61681 + const struct dentry *dir, const int flag,
61682 + const int acc_mode);
61683 +int gr_handle_hardlink(const struct dentry *dentry,
61684 + const struct vfsmount *mnt,
61685 + struct inode *inode,
61686 + const int mode, const char *to);
61687 +
61688 +int gr_is_capable(const int cap);
61689 +int gr_is_capable_nolog(const int cap);
61690 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
61691 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
61692 +
61693 +void gr_learn_resource(const struct task_struct *task, const int limit,
61694 + const unsigned long wanted, const int gt);
61695 +void gr_copy_label(struct task_struct *tsk);
61696 +void gr_handle_crash(struct task_struct *task, const int sig);
61697 +int gr_handle_signal(const struct task_struct *p, const int sig);
61698 +int gr_check_crash_uid(const uid_t uid);
61699 +int gr_check_protected_task(const struct task_struct *task);
61700 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
61701 +int gr_acl_handle_mmap(const struct file *file,
61702 + const unsigned long prot);
61703 +int gr_acl_handle_mprotect(const struct file *file,
61704 + const unsigned long prot);
61705 +int gr_check_hidden_task(const struct task_struct *tsk);
61706 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
61707 + const struct vfsmount *mnt);
61708 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
61709 + const struct vfsmount *mnt);
61710 +__u32 gr_acl_handle_access(const struct dentry *dentry,
61711 + const struct vfsmount *mnt, const int fmode);
61712 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
61713 + const struct vfsmount *mnt, umode_t *mode);
61714 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
61715 + const struct vfsmount *mnt);
61716 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
61717 + const struct vfsmount *mnt);
61718 +int gr_handle_ptrace(struct task_struct *task, const long request);
61719 +int gr_handle_proc_ptrace(struct task_struct *task);
61720 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
61721 + const struct vfsmount *mnt);
61722 +int gr_check_crash_exec(const struct file *filp);
61723 +int gr_acl_is_enabled(void);
61724 +void gr_set_kernel_label(struct task_struct *task);
61725 +void gr_set_role_label(struct task_struct *task, const uid_t uid,
61726 + const gid_t gid);
61727 +int gr_set_proc_label(const struct dentry *dentry,
61728 + const struct vfsmount *mnt,
61729 + const int unsafe_flags);
61730 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
61731 + const struct vfsmount *mnt);
61732 +__u32 gr_acl_handle_open(const struct dentry *dentry,
61733 + const struct vfsmount *mnt, int acc_mode);
61734 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
61735 + const struct dentry *p_dentry,
61736 + const struct vfsmount *p_mnt,
61737 + int open_flags, int acc_mode, const int imode);
61738 +void gr_handle_create(const struct dentry *dentry,
61739 + const struct vfsmount *mnt);
61740 +void gr_handle_proc_create(const struct dentry *dentry,
61741 + const struct inode *inode);
61742 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
61743 + const struct dentry *parent_dentry,
61744 + const struct vfsmount *parent_mnt,
61745 + const int mode);
61746 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
61747 + const struct dentry *parent_dentry,
61748 + const struct vfsmount *parent_mnt);
61749 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
61750 + const struct vfsmount *mnt);
61751 +void gr_handle_delete(const ino_t ino, const dev_t dev);
61752 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
61753 + const struct vfsmount *mnt);
61754 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
61755 + const struct dentry *parent_dentry,
61756 + const struct vfsmount *parent_mnt,
61757 + const char *from);
61758 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
61759 + const struct dentry *parent_dentry,
61760 + const struct vfsmount *parent_mnt,
61761 + const struct dentry *old_dentry,
61762 + const struct vfsmount *old_mnt, const char *to);
61763 +int gr_acl_handle_rename(struct dentry *new_dentry,
61764 + struct dentry *parent_dentry,
61765 + const struct vfsmount *parent_mnt,
61766 + struct dentry *old_dentry,
61767 + struct inode *old_parent_inode,
61768 + struct vfsmount *old_mnt, const char *newname);
61769 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
61770 + struct dentry *old_dentry,
61771 + struct dentry *new_dentry,
61772 + struct vfsmount *mnt, const __u8 replace);
61773 +__u32 gr_check_link(const struct dentry *new_dentry,
61774 + const struct dentry *parent_dentry,
61775 + const struct vfsmount *parent_mnt,
61776 + const struct dentry *old_dentry,
61777 + const struct vfsmount *old_mnt);
61778 +int gr_acl_handle_filldir(const struct file *file, const char *name,
61779 + const unsigned int namelen, const ino_t ino);
61780 +
61781 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
61782 + const struct vfsmount *mnt);
61783 +void gr_acl_handle_exit(void);
61784 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
61785 +int gr_acl_handle_procpidmem(const struct task_struct *task);
61786 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
61787 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
61788 +void gr_audit_ptrace(struct task_struct *task);
61789 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
61790 +
61791 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
61792 +
61793 +#ifdef CONFIG_GRKERNSEC
61794 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
61795 +void gr_handle_vm86(void);
61796 +void gr_handle_mem_readwrite(u64 from, u64 to);
61797 +
61798 +void gr_log_badprocpid(const char *entry);
61799 +
61800 +extern int grsec_enable_dmesg;
61801 +extern int grsec_disable_privio;
61802 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
61803 +extern int grsec_enable_chroot_findtask;
61804 +#endif
61805 +#ifdef CONFIG_GRKERNSEC_SETXID
61806 +extern int grsec_enable_setxid;
61807 +#endif
61808 +#endif
61809 +
61810 +#endif
61811 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
61812 new file mode 100644
61813 index 0000000..e7ffaaf
61814 --- /dev/null
61815 +++ b/include/linux/grsock.h
61816 @@ -0,0 +1,19 @@
61817 +#ifndef __GRSOCK_H
61818 +#define __GRSOCK_H
61819 +
61820 +extern void gr_attach_curr_ip(const struct sock *sk);
61821 +extern int gr_handle_sock_all(const int family, const int type,
61822 + const int protocol);
61823 +extern int gr_handle_sock_server(const struct sockaddr *sck);
61824 +extern int gr_handle_sock_server_other(const struct sock *sck);
61825 +extern int gr_handle_sock_client(const struct sockaddr *sck);
61826 +extern int gr_search_connect(struct socket * sock,
61827 + struct sockaddr_in * addr);
61828 +extern int gr_search_bind(struct socket * sock,
61829 + struct sockaddr_in * addr);
61830 +extern int gr_search_listen(struct socket * sock);
61831 +extern int gr_search_accept(struct socket * sock);
61832 +extern int gr_search_socket(const int domain, const int type,
61833 + const int protocol);
61834 +
61835 +#endif
61836 diff --git a/include/linux/hid.h b/include/linux/hid.h
61837 index 3a95da6..51986f1 100644
61838 --- a/include/linux/hid.h
61839 +++ b/include/linux/hid.h
61840 @@ -696,7 +696,7 @@ struct hid_ll_driver {
61841 unsigned int code, int value);
61842
61843 int (*parse)(struct hid_device *hdev);
61844 -};
61845 +} __no_const;
61846
61847 #define PM_HINT_FULLON 1<<5
61848 #define PM_HINT_NORMAL 1<<1
61849 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
61850 index 3a93f73..b19d0b3 100644
61851 --- a/include/linux/highmem.h
61852 +++ b/include/linux/highmem.h
61853 @@ -185,6 +185,18 @@ static inline void clear_highpage(struct page *page)
61854 kunmap_atomic(kaddr, KM_USER0);
61855 }
61856
61857 +static inline void sanitize_highpage(struct page *page)
61858 +{
61859 + void *kaddr;
61860 + unsigned long flags;
61861 +
61862 + local_irq_save(flags);
61863 + kaddr = kmap_atomic(page, KM_CLEARPAGE);
61864 + clear_page(kaddr);
61865 + kunmap_atomic(kaddr, KM_CLEARPAGE);
61866 + local_irq_restore(flags);
61867 +}
61868 +
61869 static inline void zero_user_segments(struct page *page,
61870 unsigned start1, unsigned end1,
61871 unsigned start2, unsigned end2)
61872 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
61873 index 8e25a91..551b161 100644
61874 --- a/include/linux/i2c.h
61875 +++ b/include/linux/i2c.h
61876 @@ -364,6 +364,7 @@ struct i2c_algorithm {
61877 /* To determine what the adapter supports */
61878 u32 (*functionality) (struct i2c_adapter *);
61879 };
61880 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
61881
61882 /*
61883 * i2c_adapter is the structure used to identify a physical i2c bus along
61884 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
61885 index a6deef4..c56a7f2 100644
61886 --- a/include/linux/i2o.h
61887 +++ b/include/linux/i2o.h
61888 @@ -564,7 +564,7 @@ struct i2o_controller {
61889 struct i2o_device *exec; /* Executive */
61890 #if BITS_PER_LONG == 64
61891 spinlock_t context_list_lock; /* lock for context_list */
61892 - atomic_t context_list_counter; /* needed for unique contexts */
61893 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
61894 struct list_head context_list; /* list of context id's
61895 and pointers */
61896 #endif
61897 diff --git a/include/linux/if_team.h b/include/linux/if_team.h
61898 index 58404b0..439ed95 100644
61899 --- a/include/linux/if_team.h
61900 +++ b/include/linux/if_team.h
61901 @@ -64,6 +64,7 @@ struct team_mode_ops {
61902 void (*port_leave)(struct team *team, struct team_port *port);
61903 void (*port_change_mac)(struct team *team, struct team_port *port);
61904 };
61905 +typedef struct team_mode_ops __no_const team_mode_ops_no_const;
61906
61907 enum team_option_type {
61908 TEAM_OPTION_TYPE_U32,
61909 @@ -112,7 +113,7 @@ struct team {
61910 struct list_head option_list;
61911
61912 const struct team_mode *mode;
61913 - struct team_mode_ops ops;
61914 + team_mode_ops_no_const ops;
61915 long mode_priv[TEAM_MODE_PRIV_LONGS];
61916 };
61917
61918 diff --git a/include/linux/init.h b/include/linux/init.h
61919 index 6b95109..4aca62c 100644
61920 --- a/include/linux/init.h
61921 +++ b/include/linux/init.h
61922 @@ -294,13 +294,13 @@ void __init parse_early_options(char *cmdline);
61923
61924 /* Each module must use one module_init(). */
61925 #define module_init(initfn) \
61926 - static inline initcall_t __inittest(void) \
61927 + static inline __used initcall_t __inittest(void) \
61928 { return initfn; } \
61929 int init_module(void) __attribute__((alias(#initfn)));
61930
61931 /* This is only required if you want to be unloadable. */
61932 #define module_exit(exitfn) \
61933 - static inline exitcall_t __exittest(void) \
61934 + static inline __used exitcall_t __exittest(void) \
61935 { return exitfn; } \
61936 void cleanup_module(void) __attribute__((alias(#exitfn)));
61937
61938 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
61939 index 9c66b1a..a3fdded 100644
61940 --- a/include/linux/init_task.h
61941 +++ b/include/linux/init_task.h
61942 @@ -127,6 +127,12 @@ extern struct cred init_cred;
61943
61944 #define INIT_TASK_COMM "swapper"
61945
61946 +#ifdef CONFIG_X86
61947 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
61948 +#else
61949 +#define INIT_TASK_THREAD_INFO
61950 +#endif
61951 +
61952 /*
61953 * INIT_TASK is used to set up the first task table, touch at
61954 * your own risk!. Base=0, limit=0x1fffff (=2MB)
61955 @@ -165,6 +171,7 @@ extern struct cred init_cred;
61956 RCU_INIT_POINTER(.cred, &init_cred), \
61957 .comm = INIT_TASK_COMM, \
61958 .thread = INIT_THREAD, \
61959 + INIT_TASK_THREAD_INFO \
61960 .fs = &init_fs, \
61961 .files = &init_files, \
61962 .signal = &init_signals, \
61963 diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h
61964 index e6ca56d..8583707 100644
61965 --- a/include/linux/intel-iommu.h
61966 +++ b/include/linux/intel-iommu.h
61967 @@ -296,7 +296,7 @@ struct iommu_flush {
61968 u8 fm, u64 type);
61969 void (*flush_iotlb)(struct intel_iommu *iommu, u16 did, u64 addr,
61970 unsigned int size_order, u64 type);
61971 -};
61972 +} __no_const;
61973
61974 enum {
61975 SR_DMAR_FECTL_REG,
61976 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
61977 index a64b00e..464d8bc 100644
61978 --- a/include/linux/interrupt.h
61979 +++ b/include/linux/interrupt.h
61980 @@ -441,7 +441,7 @@ enum
61981 /* map softirq index to softirq name. update 'softirq_to_name' in
61982 * kernel/softirq.c when adding a new softirq.
61983 */
61984 -extern char *softirq_to_name[NR_SOFTIRQS];
61985 +extern const char * const softirq_to_name[NR_SOFTIRQS];
61986
61987 /* softirq mask and active fields moved to irq_cpustat_t in
61988 * asm/hardirq.h to get better cache usage. KAO
61989 @@ -449,12 +449,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
61990
61991 struct softirq_action
61992 {
61993 - void (*action)(struct softirq_action *);
61994 + void (*action)(void);
61995 };
61996
61997 asmlinkage void do_softirq(void);
61998 asmlinkage void __do_softirq(void);
61999 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
62000 +extern void open_softirq(int nr, void (*action)(void));
62001 extern void softirq_init(void);
62002 static inline void __raise_softirq_irqoff(unsigned int nr)
62003 {
62004 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
62005 index 3875719..4cd454c 100644
62006 --- a/include/linux/kallsyms.h
62007 +++ b/include/linux/kallsyms.h
62008 @@ -15,7 +15,8 @@
62009
62010 struct module;
62011
62012 -#ifdef CONFIG_KALLSYMS
62013 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
62014 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
62015 /* Lookup the address for a symbol. Returns 0 if not found. */
62016 unsigned long kallsyms_lookup_name(const char *name);
62017
62018 @@ -99,6 +100,16 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
62019 /* Stupid that this does nothing, but I didn't create this mess. */
62020 #define __print_symbol(fmt, addr)
62021 #endif /*CONFIG_KALLSYMS*/
62022 +#else /* when included by kallsyms.c, vsnprintf.c, or
62023 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
62024 +extern void __print_symbol(const char *fmt, unsigned long address);
62025 +extern int sprint_backtrace(char *buffer, unsigned long address);
62026 +extern int sprint_symbol(char *buffer, unsigned long address);
62027 +const char *kallsyms_lookup(unsigned long addr,
62028 + unsigned long *symbolsize,
62029 + unsigned long *offset,
62030 + char **modname, char *namebuf);
62031 +#endif
62032
62033 /* This macro allows us to keep printk typechecking */
62034 static __printf(1, 2)
62035 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
62036 index c4d2fc1..5df9c19 100644
62037 --- a/include/linux/kgdb.h
62038 +++ b/include/linux/kgdb.h
62039 @@ -53,7 +53,7 @@ extern int kgdb_connected;
62040 extern int kgdb_io_module_registered;
62041
62042 extern atomic_t kgdb_setting_breakpoint;
62043 -extern atomic_t kgdb_cpu_doing_single_step;
62044 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
62045
62046 extern struct task_struct *kgdb_usethread;
62047 extern struct task_struct *kgdb_contthread;
62048 @@ -252,7 +252,7 @@ struct kgdb_arch {
62049 void (*disable_hw_break)(struct pt_regs *regs);
62050 void (*remove_all_hw_break)(void);
62051 void (*correct_hw_break)(void);
62052 -};
62053 +} __do_const;
62054
62055 /**
62056 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
62057 @@ -277,7 +277,7 @@ struct kgdb_io {
62058 void (*pre_exception) (void);
62059 void (*post_exception) (void);
62060 int is_console;
62061 -};
62062 +} __do_const;
62063
62064 extern struct kgdb_arch arch_kgdb_ops;
62065
62066 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
62067 index 0fb48ef..1b680b2 100644
62068 --- a/include/linux/kmod.h
62069 +++ b/include/linux/kmod.h
62070 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
62071 * usually useless though. */
62072 extern __printf(2, 3)
62073 int __request_module(bool wait, const char *name, ...);
62074 +extern __printf(3, 4)
62075 +int ___request_module(bool wait, char *param_name, const char *name, ...);
62076 #define request_module(mod...) __request_module(true, mod)
62077 #define request_module_nowait(mod...) __request_module(false, mod)
62078 #define try_then_request_module(x, mod...) \
62079 diff --git a/include/linux/kref.h b/include/linux/kref.h
62080 index 9c07dce..a92fa71 100644
62081 --- a/include/linux/kref.h
62082 +++ b/include/linux/kref.h
62083 @@ -63,7 +63,7 @@ static inline void kref_get(struct kref *kref)
62084 static inline int kref_sub(struct kref *kref, unsigned int count,
62085 void (*release)(struct kref *kref))
62086 {
62087 - WARN_ON(release == NULL);
62088 + BUG_ON(release == NULL);
62089
62090 if (atomic_sub_and_test((int) count, &kref->refcount)) {
62091 release(kref);
62092 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
62093 index 4c4e83d..695674f 100644
62094 --- a/include/linux/kvm_host.h
62095 +++ b/include/linux/kvm_host.h
62096 @@ -326,7 +326,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
62097 void vcpu_load(struct kvm_vcpu *vcpu);
62098 void vcpu_put(struct kvm_vcpu *vcpu);
62099
62100 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
62101 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
62102 struct module *module);
62103 void kvm_exit(void);
62104
62105 @@ -485,7 +485,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
62106 struct kvm_guest_debug *dbg);
62107 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
62108
62109 -int kvm_arch_init(void *opaque);
62110 +int kvm_arch_init(const void *opaque);
62111 void kvm_arch_exit(void);
62112
62113 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
62114 diff --git a/include/linux/libata.h b/include/linux/libata.h
62115 index cafc09a..d7e7829 100644
62116 --- a/include/linux/libata.h
62117 +++ b/include/linux/libata.h
62118 @@ -909,7 +909,7 @@ struct ata_port_operations {
62119 * fields must be pointers.
62120 */
62121 const struct ata_port_operations *inherits;
62122 -};
62123 +} __do_const;
62124
62125 struct ata_port_info {
62126 unsigned long flags;
62127 diff --git a/include/linux/mca.h b/include/linux/mca.h
62128 index 3797270..7765ede 100644
62129 --- a/include/linux/mca.h
62130 +++ b/include/linux/mca.h
62131 @@ -80,7 +80,7 @@ struct mca_bus_accessor_functions {
62132 int region);
62133 void * (*mca_transform_memory)(struct mca_device *,
62134 void *memory);
62135 -};
62136 +} __no_const;
62137
62138 struct mca_bus {
62139 u64 default_dma_mask;
62140 diff --git a/include/linux/memory.h b/include/linux/memory.h
62141 index 1ac7f6e..a5794d0 100644
62142 --- a/include/linux/memory.h
62143 +++ b/include/linux/memory.h
62144 @@ -143,7 +143,7 @@ struct memory_accessor {
62145 size_t count);
62146 ssize_t (*write)(struct memory_accessor *, const char *buf,
62147 off_t offset, size_t count);
62148 -};
62149 +} __no_const;
62150
62151 /*
62152 * Kernel text modification mutex, used for code patching. Users of this lock
62153 diff --git a/include/linux/mfd/abx500.h b/include/linux/mfd/abx500.h
62154 index 9970337..9444122 100644
62155 --- a/include/linux/mfd/abx500.h
62156 +++ b/include/linux/mfd/abx500.h
62157 @@ -188,6 +188,7 @@ struct abx500_ops {
62158 int (*event_registers_startup_state_get) (struct device *, u8 *);
62159 int (*startup_irq_enabled) (struct device *, unsigned int);
62160 };
62161 +typedef struct abx500_ops __no_const abx500_ops_no_const;
62162
62163 int abx500_register_ops(struct device *core_dev, struct abx500_ops *ops);
62164 void abx500_remove_ops(struct device *dev);
62165 diff --git a/include/linux/mm.h b/include/linux/mm.h
62166 index 17b27cd..baea141 100644
62167 --- a/include/linux/mm.h
62168 +++ b/include/linux/mm.h
62169 @@ -115,7 +115,14 @@ extern unsigned int kobjsize(const void *objp);
62170
62171 #define VM_CAN_NONLINEAR 0x08000000 /* Has ->fault & does nonlinear pages */
62172 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
62173 +
62174 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
62175 +#define VM_SAO 0x00000000 /* Strong Access Ordering (powerpc) */
62176 +#define VM_PAGEEXEC 0x20000000 /* vma->vm_page_prot needs special handling */
62177 +#else
62178 #define VM_SAO 0x20000000 /* Strong Access Ordering (powerpc) */
62179 +#endif
62180 +
62181 #define VM_PFN_AT_MMAP 0x40000000 /* PFNMAP vma that is fully mapped at mmap time */
62182 #define VM_MERGEABLE 0x80000000 /* KSM may merge identical pages */
62183
62184 @@ -1012,34 +1019,6 @@ int set_page_dirty(struct page *page);
62185 int set_page_dirty_lock(struct page *page);
62186 int clear_page_dirty_for_io(struct page *page);
62187
62188 -/* Is the vma a continuation of the stack vma above it? */
62189 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
62190 -{
62191 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
62192 -}
62193 -
62194 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
62195 - unsigned long addr)
62196 -{
62197 - return (vma->vm_flags & VM_GROWSDOWN) &&
62198 - (vma->vm_start == addr) &&
62199 - !vma_growsdown(vma->vm_prev, addr);
62200 -}
62201 -
62202 -/* Is the vma a continuation of the stack vma below it? */
62203 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
62204 -{
62205 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
62206 -}
62207 -
62208 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
62209 - unsigned long addr)
62210 -{
62211 - return (vma->vm_flags & VM_GROWSUP) &&
62212 - (vma->vm_end == addr) &&
62213 - !vma_growsup(vma->vm_next, addr);
62214 -}
62215 -
62216 extern unsigned long move_page_tables(struct vm_area_struct *vma,
62217 unsigned long old_addr, struct vm_area_struct *new_vma,
62218 unsigned long new_addr, unsigned long len);
62219 @@ -1134,6 +1113,15 @@ static inline void sync_mm_rss(struct task_struct *task, struct mm_struct *mm)
62220 }
62221 #endif
62222
62223 +#ifdef CONFIG_MMU
62224 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
62225 +#else
62226 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
62227 +{
62228 + return __pgprot(0);
62229 +}
62230 +#endif
62231 +
62232 int vma_wants_writenotify(struct vm_area_struct *vma);
62233
62234 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
62235 @@ -1152,8 +1140,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
62236 {
62237 return 0;
62238 }
62239 +
62240 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
62241 + unsigned long address)
62242 +{
62243 + return 0;
62244 +}
62245 #else
62246 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
62247 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
62248 #endif
62249
62250 #ifdef __PAGETABLE_PMD_FOLDED
62251 @@ -1162,8 +1157,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
62252 {
62253 return 0;
62254 }
62255 +
62256 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
62257 + unsigned long address)
62258 +{
62259 + return 0;
62260 +}
62261 #else
62262 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
62263 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
62264 #endif
62265
62266 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
62267 @@ -1181,11 +1183,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
62268 NULL: pud_offset(pgd, address);
62269 }
62270
62271 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
62272 +{
62273 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
62274 + NULL: pud_offset(pgd, address);
62275 +}
62276 +
62277 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
62278 {
62279 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
62280 NULL: pmd_offset(pud, address);
62281 }
62282 +
62283 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
62284 +{
62285 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
62286 + NULL: pmd_offset(pud, address);
62287 +}
62288 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
62289
62290 #if USE_SPLIT_PTLOCKS
62291 @@ -1409,6 +1423,7 @@ out:
62292 }
62293
62294 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
62295 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
62296
62297 extern unsigned long do_brk(unsigned long, unsigned long);
62298
62299 @@ -1466,6 +1481,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
62300 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
62301 struct vm_area_struct **pprev);
62302
62303 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
62304 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
62305 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
62306 +
62307 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
62308 NULL if none. Assume start_addr < end_addr. */
62309 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
62310 @@ -1494,15 +1513,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
62311 return vma;
62312 }
62313
62314 -#ifdef CONFIG_MMU
62315 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
62316 -#else
62317 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
62318 -{
62319 - return __pgprot(0);
62320 -}
62321 -#endif
62322 -
62323 struct vm_area_struct *find_extend_vma(struct mm_struct *, unsigned long addr);
62324 int remap_pfn_range(struct vm_area_struct *, unsigned long addr,
62325 unsigned long pfn, unsigned long size, pgprot_t);
62326 @@ -1606,7 +1616,7 @@ extern int unpoison_memory(unsigned long pfn);
62327 extern int sysctl_memory_failure_early_kill;
62328 extern int sysctl_memory_failure_recovery;
62329 extern void shake_page(struct page *p, int access);
62330 -extern atomic_long_t mce_bad_pages;
62331 +extern atomic_long_unchecked_t mce_bad_pages;
62332 extern int soft_offline_page(struct page *page, int flags);
62333
62334 extern void dump_page(struct page *page);
62335 @@ -1637,5 +1647,11 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
62336 static inline bool page_is_guard(struct page *page) { return false; }
62337 #endif /* CONFIG_DEBUG_PAGEALLOC */
62338
62339 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
62340 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
62341 +#else
62342 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
62343 +#endif
62344 +
62345 #endif /* __KERNEL__ */
62346 #endif /* _LINUX_MM_H */
62347 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
62348 index 3cc3062..efeaeb7 100644
62349 --- a/include/linux/mm_types.h
62350 +++ b/include/linux/mm_types.h
62351 @@ -252,6 +252,8 @@ struct vm_area_struct {
62352 #ifdef CONFIG_NUMA
62353 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
62354 #endif
62355 +
62356 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
62357 };
62358
62359 struct core_thread {
62360 @@ -326,7 +328,7 @@ struct mm_struct {
62361 unsigned long def_flags;
62362 unsigned long nr_ptes; /* Page table pages */
62363 unsigned long start_code, end_code, start_data, end_data;
62364 - unsigned long start_brk, brk, start_stack;
62365 + unsigned long brk_gap, start_brk, brk, start_stack;
62366 unsigned long arg_start, arg_end, env_start, env_end;
62367
62368 unsigned long saved_auxv[AT_VECTOR_SIZE]; /* for /proc/PID/auxv */
62369 @@ -388,6 +390,24 @@ struct mm_struct {
62370 #ifdef CONFIG_CPUMASK_OFFSTACK
62371 struct cpumask cpumask_allocation;
62372 #endif
62373 +
62374 +#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)
62375 + unsigned long pax_flags;
62376 +#endif
62377 +
62378 +#ifdef CONFIG_PAX_DLRESOLVE
62379 + unsigned long call_dl_resolve;
62380 +#endif
62381 +
62382 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
62383 + unsigned long call_syscall;
62384 +#endif
62385 +
62386 +#ifdef CONFIG_PAX_ASLR
62387 + unsigned long delta_mmap; /* randomized offset */
62388 + unsigned long delta_stack; /* randomized offset */
62389 +#endif
62390 +
62391 };
62392
62393 static inline void mm_init_cpumask(struct mm_struct *mm)
62394 diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h
62395 index 1d1b1e1..2a13c78 100644
62396 --- a/include/linux/mmu_notifier.h
62397 +++ b/include/linux/mmu_notifier.h
62398 @@ -255,12 +255,12 @@ static inline void mmu_notifier_mm_destroy(struct mm_struct *mm)
62399 */
62400 #define ptep_clear_flush_notify(__vma, __address, __ptep) \
62401 ({ \
62402 - pte_t __pte; \
62403 + pte_t ___pte; \
62404 struct vm_area_struct *___vma = __vma; \
62405 unsigned long ___address = __address; \
62406 - __pte = ptep_clear_flush(___vma, ___address, __ptep); \
62407 + ___pte = ptep_clear_flush(___vma, ___address, __ptep); \
62408 mmu_notifier_invalidate_page(___vma->vm_mm, ___address); \
62409 - __pte; \
62410 + ___pte; \
62411 })
62412
62413 #define pmdp_clear_flush_notify(__vma, __address, __pmdp) \
62414 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
62415 index 650ba2f..af0a58c 100644
62416 --- a/include/linux/mmzone.h
62417 +++ b/include/linux/mmzone.h
62418 @@ -379,7 +379,7 @@ struct zone {
62419 unsigned long flags; /* zone flags, see below */
62420
62421 /* Zone statistics */
62422 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
62423 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
62424
62425 /*
62426 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
62427 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
62428 index 83ac071..2656e0e 100644
62429 --- a/include/linux/mod_devicetable.h
62430 +++ b/include/linux/mod_devicetable.h
62431 @@ -12,7 +12,7 @@
62432 typedef unsigned long kernel_ulong_t;
62433 #endif
62434
62435 -#define PCI_ANY_ID (~0)
62436 +#define PCI_ANY_ID ((__u16)~0)
62437
62438 struct pci_device_id {
62439 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
62440 @@ -131,7 +131,7 @@ struct usb_device_id {
62441 #define USB_DEVICE_ID_MATCH_INT_SUBCLASS 0x0100
62442 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
62443
62444 -#define HID_ANY_ID (~0)
62445 +#define HID_ANY_ID (~0U)
62446
62447 struct hid_device_id {
62448 __u16 bus;
62449 diff --git a/include/linux/module.h b/include/linux/module.h
62450 index 4598bf0..e069d7f 100644
62451 --- a/include/linux/module.h
62452 +++ b/include/linux/module.h
62453 @@ -17,6 +17,7 @@
62454 #include <linux/moduleparam.h>
62455 #include <linux/tracepoint.h>
62456 #include <linux/export.h>
62457 +#include <linux/fs.h>
62458
62459 #include <linux/percpu.h>
62460 #include <asm/module.h>
62461 @@ -275,19 +276,16 @@ struct module
62462 int (*init)(void);
62463
62464 /* If this is non-NULL, vfree after init() returns */
62465 - void *module_init;
62466 + void *module_init_rx, *module_init_rw;
62467
62468 /* Here is the actual code + data, vfree'd on unload. */
62469 - void *module_core;
62470 + void *module_core_rx, *module_core_rw;
62471
62472 /* Here are the sizes of the init and core sections */
62473 - unsigned int init_size, core_size;
62474 + unsigned int init_size_rw, core_size_rw;
62475
62476 /* The size of the executable code in each section. */
62477 - unsigned int init_text_size, core_text_size;
62478 -
62479 - /* Size of RO sections of the module (text+rodata) */
62480 - unsigned int init_ro_size, core_ro_size;
62481 + unsigned int init_size_rx, core_size_rx;
62482
62483 /* Arch-specific module values */
62484 struct mod_arch_specific arch;
62485 @@ -343,6 +341,10 @@ struct module
62486 #ifdef CONFIG_EVENT_TRACING
62487 struct ftrace_event_call **trace_events;
62488 unsigned int num_trace_events;
62489 + struct file_operations trace_id;
62490 + struct file_operations trace_enable;
62491 + struct file_operations trace_format;
62492 + struct file_operations trace_filter;
62493 #endif
62494 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
62495 unsigned int num_ftrace_callsites;
62496 @@ -390,16 +392,46 @@ bool is_module_address(unsigned long addr);
62497 bool is_module_percpu_address(unsigned long addr);
62498 bool is_module_text_address(unsigned long addr);
62499
62500 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
62501 +{
62502 +
62503 +#ifdef CONFIG_PAX_KERNEXEC
62504 + if (ktla_ktva(addr) >= (unsigned long)start &&
62505 + ktla_ktva(addr) < (unsigned long)start + size)
62506 + return 1;
62507 +#endif
62508 +
62509 + return ((void *)addr >= start && (void *)addr < start + size);
62510 +}
62511 +
62512 +static inline int within_module_core_rx(unsigned long addr, struct module *mod)
62513 +{
62514 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
62515 +}
62516 +
62517 +static inline int within_module_core_rw(unsigned long addr, struct module *mod)
62518 +{
62519 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
62520 +}
62521 +
62522 +static inline int within_module_init_rx(unsigned long addr, struct module *mod)
62523 +{
62524 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
62525 +}
62526 +
62527 +static inline int within_module_init_rw(unsigned long addr, struct module *mod)
62528 +{
62529 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
62530 +}
62531 +
62532 static inline int within_module_core(unsigned long addr, struct module *mod)
62533 {
62534 - return (unsigned long)mod->module_core <= addr &&
62535 - addr < (unsigned long)mod->module_core + mod->core_size;
62536 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
62537 }
62538
62539 static inline int within_module_init(unsigned long addr, struct module *mod)
62540 {
62541 - return (unsigned long)mod->module_init <= addr &&
62542 - addr < (unsigned long)mod->module_init + mod->init_size;
62543 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
62544 }
62545
62546 /* Search for module by name: must hold module_mutex. */
62547 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
62548 index b2be02e..0a61daa 100644
62549 --- a/include/linux/moduleloader.h
62550 +++ b/include/linux/moduleloader.h
62551 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
62552 sections. Returns NULL on failure. */
62553 void *module_alloc(unsigned long size);
62554
62555 +#ifdef CONFIG_PAX_KERNEXEC
62556 +void *module_alloc_exec(unsigned long size) __size_overflow(1);
62557 +#else
62558 +#define module_alloc_exec(x) module_alloc(x)
62559 +#endif
62560 +
62561 /* Free memory returned from module_alloc. */
62562 void module_free(struct module *mod, void *module_region);
62563
62564 +#ifdef CONFIG_PAX_KERNEXEC
62565 +void module_free_exec(struct module *mod, void *module_region);
62566 +#else
62567 +#define module_free_exec(x, y) module_free((x), (y))
62568 +#endif
62569 +
62570 /* Apply the given relocation to the (simplified) ELF. Return -error
62571 or 0. */
62572 int apply_relocate(Elf_Shdr *sechdrs,
62573 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
62574 index c47f4d6..23f9bdb 100644
62575 --- a/include/linux/moduleparam.h
62576 +++ b/include/linux/moduleparam.h
62577 @@ -260,7 +260,7 @@ static inline void __kernel_param_unlock(void)
62578 * @len is usually just sizeof(string).
62579 */
62580 #define module_param_string(name, string, len, perm) \
62581 - static const struct kparam_string __param_string_##name \
62582 + static const struct kparam_string __param_string_##name __used \
62583 = { len, string }; \
62584 __module_param_call(MODULE_PARAM_PREFIX, name, \
62585 &param_ops_string, \
62586 @@ -396,7 +396,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
62587 */
62588 #define module_param_array_named(name, array, type, nump, perm) \
62589 param_check_##type(name, &(array)[0]); \
62590 - static const struct kparam_array __param_arr_##name \
62591 + static const struct kparam_array __param_arr_##name __used \
62592 = { .max = ARRAY_SIZE(array), .num = nump, \
62593 .ops = &param_ops_##type, \
62594 .elemsize = sizeof(array[0]), .elem = array }; \
62595 diff --git a/include/linux/namei.h b/include/linux/namei.h
62596 index ffc0213..2c1f2cb 100644
62597 --- a/include/linux/namei.h
62598 +++ b/include/linux/namei.h
62599 @@ -24,7 +24,7 @@ struct nameidata {
62600 unsigned seq;
62601 int last_type;
62602 unsigned depth;
62603 - char *saved_names[MAX_NESTED_LINKS + 1];
62604 + const char *saved_names[MAX_NESTED_LINKS + 1];
62605
62606 /* Intent data */
62607 union {
62608 @@ -94,12 +94,12 @@ extern int follow_up(struct path *);
62609 extern struct dentry *lock_rename(struct dentry *, struct dentry *);
62610 extern void unlock_rename(struct dentry *, struct dentry *);
62611
62612 -static inline void nd_set_link(struct nameidata *nd, char *path)
62613 +static inline void nd_set_link(struct nameidata *nd, const char *path)
62614 {
62615 nd->saved_names[nd->depth] = path;
62616 }
62617
62618 -static inline char *nd_get_link(struct nameidata *nd)
62619 +static inline const char *nd_get_link(const struct nameidata *nd)
62620 {
62621 return nd->saved_names[nd->depth];
62622 }
62623 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
62624 index 7e472b7..212d381 100644
62625 --- a/include/linux/netdevice.h
62626 +++ b/include/linux/netdevice.h
62627 @@ -1002,6 +1002,7 @@ struct net_device_ops {
62628 int (*ndo_neigh_construct)(struct neighbour *n);
62629 void (*ndo_neigh_destroy)(struct neighbour *n);
62630 };
62631 +typedef struct net_device_ops __no_const net_device_ops_no_const;
62632
62633 /*
62634 * The DEVICE structure.
62635 @@ -1063,7 +1064,7 @@ struct net_device {
62636 int iflink;
62637
62638 struct net_device_stats stats;
62639 - atomic_long_t rx_dropped; /* dropped packets by core network
62640 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
62641 * Do not use this in drivers.
62642 */
62643
62644 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
62645 new file mode 100644
62646 index 0000000..33f4af8
62647 --- /dev/null
62648 +++ b/include/linux/netfilter/xt_gradm.h
62649 @@ -0,0 +1,9 @@
62650 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
62651 +#define _LINUX_NETFILTER_XT_GRADM_H 1
62652 +
62653 +struct xt_gradm_mtinfo {
62654 + __u16 flags;
62655 + __u16 invflags;
62656 +};
62657 +
62658 +#endif
62659 diff --git a/include/linux/of_pdt.h b/include/linux/of_pdt.h
62660 index c65a18a..0c05f3a 100644
62661 --- a/include/linux/of_pdt.h
62662 +++ b/include/linux/of_pdt.h
62663 @@ -32,7 +32,7 @@ struct of_pdt_ops {
62664
62665 /* return 0 on success; fill in 'len' with number of bytes in path */
62666 int (*pkg2path)(phandle node, char *buf, const int buflen, int *len);
62667 -};
62668 +} __no_const;
62669
62670 extern void *prom_early_alloc(unsigned long size);
62671
62672 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
62673 index a4c5624..79d6d88 100644
62674 --- a/include/linux/oprofile.h
62675 +++ b/include/linux/oprofile.h
62676 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
62677 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
62678 char const * name, ulong * val);
62679
62680 -/** Create a file for read-only access to an atomic_t. */
62681 +/** Create a file for read-only access to an atomic_unchecked_t. */
62682 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
62683 - char const * name, atomic_t * val);
62684 + char const * name, atomic_unchecked_t * val);
62685
62686 /** create a directory */
62687 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
62688 diff --git a/include/linux/padata.h b/include/linux/padata.h
62689 index 4633b2f..988bc08 100644
62690 --- a/include/linux/padata.h
62691 +++ b/include/linux/padata.h
62692 @@ -129,7 +129,7 @@ struct parallel_data {
62693 struct padata_instance *pinst;
62694 struct padata_parallel_queue __percpu *pqueue;
62695 struct padata_serial_queue __percpu *squeue;
62696 - atomic_t seq_nr;
62697 + atomic_unchecked_t seq_nr;
62698 atomic_t reorder_objects;
62699 atomic_t refcnt;
62700 unsigned int max_seq_nr;
62701 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
62702 index abb2776..d8b8e15 100644
62703 --- a/include/linux/perf_event.h
62704 +++ b/include/linux/perf_event.h
62705 @@ -750,8 +750,8 @@ struct perf_event {
62706
62707 enum perf_event_active_state state;
62708 unsigned int attach_state;
62709 - local64_t count;
62710 - atomic64_t child_count;
62711 + local64_t count; /* PaX: fix it one day */
62712 + atomic64_unchecked_t child_count;
62713
62714 /*
62715 * These are the total time in nanoseconds that the event
62716 @@ -802,8 +802,8 @@ struct perf_event {
62717 * These accumulate total time (in nanoseconds) that children
62718 * events have been enabled and running, respectively.
62719 */
62720 - atomic64_t child_total_time_enabled;
62721 - atomic64_t child_total_time_running;
62722 + atomic64_unchecked_t child_total_time_enabled;
62723 + atomic64_unchecked_t child_total_time_running;
62724
62725 /*
62726 * Protect attach/detach and child_list:
62727 diff --git a/include/linux/personality.h b/include/linux/personality.h
62728 index 8fc7dd1a..c19d89e 100644
62729 --- a/include/linux/personality.h
62730 +++ b/include/linux/personality.h
62731 @@ -44,6 +44,7 @@ enum {
62732 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
62733 ADDR_NO_RANDOMIZE | \
62734 ADDR_COMPAT_LAYOUT | \
62735 + ADDR_LIMIT_3GB | \
62736 MMAP_PAGE_ZERO)
62737
62738 /*
62739 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
62740 index 0072a53..c5dcca5 100644
62741 --- a/include/linux/pipe_fs_i.h
62742 +++ b/include/linux/pipe_fs_i.h
62743 @@ -47,9 +47,9 @@ struct pipe_buffer {
62744 struct pipe_inode_info {
62745 wait_queue_head_t wait;
62746 unsigned int nrbufs, curbuf, buffers;
62747 - unsigned int readers;
62748 - unsigned int writers;
62749 - unsigned int waiting_writers;
62750 + atomic_t readers;
62751 + atomic_t writers;
62752 + atomic_t waiting_writers;
62753 unsigned int r_counter;
62754 unsigned int w_counter;
62755 struct page *tmp_page;
62756 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
62757 index 609daae..5392427 100644
62758 --- a/include/linux/pm_runtime.h
62759 +++ b/include/linux/pm_runtime.h
62760 @@ -97,7 +97,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
62761
62762 static inline void pm_runtime_mark_last_busy(struct device *dev)
62763 {
62764 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
62765 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
62766 }
62767
62768 #else /* !CONFIG_PM_RUNTIME */
62769 diff --git a/include/linux/poison.h b/include/linux/poison.h
62770 index 2110a81..13a11bb 100644
62771 --- a/include/linux/poison.h
62772 +++ b/include/linux/poison.h
62773 @@ -19,8 +19,8 @@
62774 * under normal circumstances, used to verify that nobody uses
62775 * non-initialized list entries.
62776 */
62777 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
62778 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
62779 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
62780 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
62781
62782 /********** include/linux/timer.h **********/
62783 /*
62784 diff --git a/include/linux/preempt.h b/include/linux/preempt.h
62785 index 58969b2..ead129b 100644
62786 --- a/include/linux/preempt.h
62787 +++ b/include/linux/preempt.h
62788 @@ -123,7 +123,7 @@ struct preempt_ops {
62789 void (*sched_in)(struct preempt_notifier *notifier, int cpu);
62790 void (*sched_out)(struct preempt_notifier *notifier,
62791 struct task_struct *next);
62792 -};
62793 +} __no_const;
62794
62795 /**
62796 * preempt_notifier - key for installing preemption notifiers
62797 diff --git a/include/linux/printk.h b/include/linux/printk.h
62798 index f0e22f7..82dd544 100644
62799 --- a/include/linux/printk.h
62800 +++ b/include/linux/printk.h
62801 @@ -94,6 +94,8 @@ void early_printk(const char *fmt, ...);
62802 extern int printk_needs_cpu(int cpu);
62803 extern void printk_tick(void);
62804
62805 +extern int kptr_restrict;
62806 +
62807 #ifdef CONFIG_PRINTK
62808 asmlinkage __printf(1, 0)
62809 int vprintk(const char *fmt, va_list args);
62810 @@ -112,7 +114,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
62811
62812 extern int printk_delay_msec;
62813 extern int dmesg_restrict;
62814 -extern int kptr_restrict;
62815
62816 void log_buf_kexec_setup(void);
62817 void __init setup_log_buf(int early);
62818 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
62819 index 85c5073..51fac8b 100644
62820 --- a/include/linux/proc_fs.h
62821 +++ b/include/linux/proc_fs.h
62822 @@ -155,6 +155,18 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
62823 return proc_create_data(name, mode, parent, proc_fops, NULL);
62824 }
62825
62826 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
62827 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
62828 +{
62829 +#ifdef CONFIG_GRKERNSEC_PROC_USER
62830 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
62831 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62832 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
62833 +#else
62834 + return proc_create_data(name, mode, parent, proc_fops, NULL);
62835 +#endif
62836 +}
62837 +
62838 static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
62839 umode_t mode, struct proc_dir_entry *base,
62840 read_proc_t *read_proc, void * data)
62841 @@ -258,7 +270,7 @@ union proc_op {
62842 int (*proc_show)(struct seq_file *m,
62843 struct pid_namespace *ns, struct pid *pid,
62844 struct task_struct *task);
62845 -};
62846 +} __no_const;
62847
62848 struct ctl_table_header;
62849 struct ctl_table;
62850 diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
62851 index c2f1f6a..6fdb196 100644
62852 --- a/include/linux/ptrace.h
62853 +++ b/include/linux/ptrace.h
62854 @@ -199,9 +199,10 @@ static inline void ptrace_event(int event, unsigned long message)
62855 if (unlikely(ptrace_event_enabled(current, event))) {
62856 current->ptrace_message = message;
62857 ptrace_notify((event << 8) | SIGTRAP);
62858 - } else if (event == PTRACE_EVENT_EXEC && unlikely(current->ptrace)) {
62859 + } else if (event == PTRACE_EVENT_EXEC) {
62860 /* legacy EXEC report via SIGTRAP */
62861 - send_sig(SIGTRAP, current, 0);
62862 + if ((current->ptrace & (PT_PTRACED|PT_SEIZED)) == PT_PTRACED)
62863 + send_sig(SIGTRAP, current, 0);
62864 }
62865 }
62866
62867 diff --git a/include/linux/random.h b/include/linux/random.h
62868 index 8f74538..02a1012 100644
62869 --- a/include/linux/random.h
62870 +++ b/include/linux/random.h
62871 @@ -69,12 +69,17 @@ void srandom32(u32 seed);
62872
62873 u32 prandom32(struct rnd_state *);
62874
62875 +static inline unsigned long pax_get_random_long(void)
62876 +{
62877 + return random32() + (sizeof(long) > 4 ? (unsigned long)random32() << 32 : 0);
62878 +}
62879 +
62880 /*
62881 * Handle minimum values for seeds
62882 */
62883 static inline u32 __seed(u32 x, u32 m)
62884 {
62885 - return (x < m) ? x + m : x;
62886 + return (x <= m) ? x + m + 1 : x;
62887 }
62888
62889 /**
62890 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
62891 index e0879a7..a12f962 100644
62892 --- a/include/linux/reboot.h
62893 +++ b/include/linux/reboot.h
62894 @@ -52,9 +52,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
62895 * Architecture-specific implementations of sys_reboot commands.
62896 */
62897
62898 -extern void machine_restart(char *cmd);
62899 -extern void machine_halt(void);
62900 -extern void machine_power_off(void);
62901 +extern void machine_restart(char *cmd) __noreturn;
62902 +extern void machine_halt(void) __noreturn;
62903 +extern void machine_power_off(void) __noreturn;
62904
62905 extern void machine_shutdown(void);
62906 struct pt_regs;
62907 @@ -65,9 +65,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
62908 */
62909
62910 extern void kernel_restart_prepare(char *cmd);
62911 -extern void kernel_restart(char *cmd);
62912 -extern void kernel_halt(void);
62913 -extern void kernel_power_off(void);
62914 +extern void kernel_restart(char *cmd) __noreturn;
62915 +extern void kernel_halt(void) __noreturn;
62916 +extern void kernel_power_off(void) __noreturn;
62917
62918 extern int C_A_D; /* for sysctl */
62919 void ctrl_alt_del(void);
62920 @@ -81,7 +81,7 @@ extern int orderly_poweroff(bool force);
62921 * Emergency restart, callable from an interrupt handler.
62922 */
62923
62924 -extern void emergency_restart(void);
62925 +extern void emergency_restart(void) __noreturn;
62926 #include <asm/emergency-restart.h>
62927
62928 #endif
62929 diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
62930 index 2213ddc..650212a 100644
62931 --- a/include/linux/reiserfs_fs.h
62932 +++ b/include/linux/reiserfs_fs.h
62933 @@ -1406,7 +1406,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
62934 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
62935
62936 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
62937 -#define get_generation(s) atomic_read (&fs_generation(s))
62938 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
62939 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
62940 #define __fs_changed(gen,s) (gen != get_generation (s))
62941 #define fs_changed(gen,s) \
62942 diff --git a/include/linux/reiserfs_fs_sb.h b/include/linux/reiserfs_fs_sb.h
62943 index 8c9e85c..1698e9a 100644
62944 --- a/include/linux/reiserfs_fs_sb.h
62945 +++ b/include/linux/reiserfs_fs_sb.h
62946 @@ -386,7 +386,7 @@ struct reiserfs_sb_info {
62947 /* Comment? -Hans */
62948 wait_queue_head_t s_wait;
62949 /* To be obsoleted soon by per buffer seals.. -Hans */
62950 - atomic_t s_generation_counter; // increased by one every time the
62951 + atomic_unchecked_t s_generation_counter; // increased by one every time the
62952 // tree gets re-balanced
62953 unsigned long s_properties; /* File system properties. Currently holds
62954 on-disk FS format */
62955 diff --git a/include/linux/relay.h b/include/linux/relay.h
62956 index a822fd7..62b70f6 100644
62957 --- a/include/linux/relay.h
62958 +++ b/include/linux/relay.h
62959 @@ -159,7 +159,7 @@ struct rchan_callbacks
62960 * The callback should return 0 if successful, negative if not.
62961 */
62962 int (*remove_buf_file)(struct dentry *dentry);
62963 -};
62964 +} __no_const;
62965
62966 /*
62967 * CONFIG_RELAY kernel API, kernel/relay.c
62968 diff --git a/include/linux/rfkill.h b/include/linux/rfkill.h
62969 index c6c6084..5bf1212 100644
62970 --- a/include/linux/rfkill.h
62971 +++ b/include/linux/rfkill.h
62972 @@ -147,6 +147,7 @@ struct rfkill_ops {
62973 void (*query)(struct rfkill *rfkill, void *data);
62974 int (*set_block)(void *data, bool blocked);
62975 };
62976 +typedef struct rfkill_ops __no_const rfkill_ops_no_const;
62977
62978 #if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)
62979 /**
62980 diff --git a/include/linux/rio.h b/include/linux/rio.h
62981 index 4d50611..c6858a2 100644
62982 --- a/include/linux/rio.h
62983 +++ b/include/linux/rio.h
62984 @@ -315,7 +315,7 @@ struct rio_ops {
62985 int mbox, void *buffer, size_t len);
62986 int (*add_inb_buffer)(struct rio_mport *mport, int mbox, void *buf);
62987 void *(*get_inb_message)(struct rio_mport *mport, int mbox);
62988 -};
62989 +} __no_const;
62990
62991 #define RIO_RESOURCE_MEM 0x00000100
62992 #define RIO_RESOURCE_DOORBELL 0x00000200
62993 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
62994 index 1cdd62a..e399f0d 100644
62995 --- a/include/linux/rmap.h
62996 +++ b/include/linux/rmap.h
62997 @@ -119,9 +119,9 @@ static inline void anon_vma_unlock(struct anon_vma *anon_vma)
62998 void anon_vma_init(void); /* create anon_vma_cachep */
62999 int anon_vma_prepare(struct vm_area_struct *);
63000 void unlink_anon_vmas(struct vm_area_struct *);
63001 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
63002 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
63003 void anon_vma_moveto_tail(struct vm_area_struct *);
63004 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
63005 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
63006 void __anon_vma_link(struct vm_area_struct *);
63007
63008 static inline void anon_vma_merge(struct vm_area_struct *vma,
63009 diff --git a/include/linux/sched.h b/include/linux/sched.h
63010 index 0657368..765f70f 100644
63011 --- a/include/linux/sched.h
63012 +++ b/include/linux/sched.h
63013 @@ -101,6 +101,7 @@ struct bio_list;
63014 struct fs_struct;
63015 struct perf_event_context;
63016 struct blk_plug;
63017 +struct linux_binprm;
63018
63019 /*
63020 * List of flags we want to share for kernel threads,
63021 @@ -382,10 +383,13 @@ struct user_namespace;
63022 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
63023
63024 extern int sysctl_max_map_count;
63025 +extern unsigned long sysctl_heap_stack_gap;
63026
63027 #include <linux/aio.h>
63028
63029 #ifdef CONFIG_MMU
63030 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len);
63031 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len);
63032 extern void arch_pick_mmap_layout(struct mm_struct *mm);
63033 extern unsigned long
63034 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
63035 @@ -631,6 +635,17 @@ struct signal_struct {
63036 #ifdef CONFIG_TASKSTATS
63037 struct taskstats *stats;
63038 #endif
63039 +
63040 +#ifdef CONFIG_GRKERNSEC
63041 + u32 curr_ip;
63042 + u32 saved_ip;
63043 + u32 gr_saddr;
63044 + u32 gr_daddr;
63045 + u16 gr_sport;
63046 + u16 gr_dport;
63047 + u8 used_accept:1;
63048 +#endif
63049 +
63050 #ifdef CONFIG_AUDIT
63051 unsigned audit_tty;
63052 struct tty_audit_buf *tty_audit_buf;
63053 @@ -714,6 +729,11 @@ struct user_struct {
63054 struct key *session_keyring; /* UID's default session keyring */
63055 #endif
63056
63057 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
63058 + unsigned int banned;
63059 + unsigned long ban_expires;
63060 +#endif
63061 +
63062 /* Hash table maintenance information */
63063 struct hlist_node uidhash_node;
63064 uid_t uid;
63065 @@ -1354,8 +1374,8 @@ struct task_struct {
63066 struct list_head thread_group;
63067
63068 struct completion *vfork_done; /* for vfork() */
63069 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
63070 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
63071 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
63072 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
63073
63074 cputime_t utime, stime, utimescaled, stimescaled;
63075 cputime_t gtime;
63076 @@ -1371,13 +1391,6 @@ struct task_struct {
63077 struct task_cputime cputime_expires;
63078 struct list_head cpu_timers[3];
63079
63080 -/* process credentials */
63081 - const struct cred __rcu *real_cred; /* objective and real subjective task
63082 - * credentials (COW) */
63083 - const struct cred __rcu *cred; /* effective (overridable) subjective task
63084 - * credentials (COW) */
63085 - struct cred *replacement_session_keyring; /* for KEYCTL_SESSION_TO_PARENT */
63086 -
63087 char comm[TASK_COMM_LEN]; /* executable name excluding path
63088 - access with [gs]et_task_comm (which lock
63089 it with task_lock())
63090 @@ -1394,8 +1407,16 @@ struct task_struct {
63091 #endif
63092 /* CPU-specific state of this task */
63093 struct thread_struct thread;
63094 +/* thread_info moved to task_struct */
63095 +#ifdef CONFIG_X86
63096 + struct thread_info tinfo;
63097 +#endif
63098 /* filesystem information */
63099 struct fs_struct *fs;
63100 +
63101 + const struct cred __rcu *cred; /* effective (overridable) subjective task
63102 + * credentials (COW) */
63103 +
63104 /* open file information */
63105 struct files_struct *files;
63106 /* namespaces */
63107 @@ -1442,6 +1463,11 @@ struct task_struct {
63108 struct rt_mutex_waiter *pi_blocked_on;
63109 #endif
63110
63111 +/* process credentials */
63112 + const struct cred __rcu *real_cred; /* objective and real subjective task
63113 + * credentials (COW) */
63114 + struct cred *replacement_session_keyring; /* for KEYCTL_SESSION_TO_PARENT */
63115 +
63116 #ifdef CONFIG_DEBUG_MUTEXES
63117 /* mutex deadlock detection */
63118 struct mutex_waiter *blocked_on;
63119 @@ -1558,6 +1584,27 @@ struct task_struct {
63120 unsigned long default_timer_slack_ns;
63121
63122 struct list_head *scm_work_list;
63123 +
63124 +#ifdef CONFIG_GRKERNSEC
63125 + /* grsecurity */
63126 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
63127 + u64 exec_id;
63128 +#endif
63129 +#ifdef CONFIG_GRKERNSEC_SETXID
63130 + const struct cred *delayed_cred;
63131 +#endif
63132 + struct dentry *gr_chroot_dentry;
63133 + struct acl_subject_label *acl;
63134 + struct acl_role_label *role;
63135 + struct file *exec_file;
63136 + u16 acl_role_id;
63137 + /* is this the task that authenticated to the special role */
63138 + u8 acl_sp_role;
63139 + u8 is_writable;
63140 + u8 brute;
63141 + u8 gr_is_chrooted;
63142 +#endif
63143 +
63144 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
63145 /* Index of current stored address in ret_stack */
63146 int curr_ret_stack;
63147 @@ -1592,6 +1639,51 @@ struct task_struct {
63148 #endif
63149 };
63150
63151 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
63152 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
63153 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
63154 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
63155 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
63156 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
63157 +
63158 +#ifdef CONFIG_PAX_SOFTMODE
63159 +extern int pax_softmode;
63160 +#endif
63161 +
63162 +extern int pax_check_flags(unsigned long *);
63163 +
63164 +/* if tsk != current then task_lock must be held on it */
63165 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
63166 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
63167 +{
63168 + if (likely(tsk->mm))
63169 + return tsk->mm->pax_flags;
63170 + else
63171 + return 0UL;
63172 +}
63173 +
63174 +/* if tsk != current then task_lock must be held on it */
63175 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
63176 +{
63177 + if (likely(tsk->mm)) {
63178 + tsk->mm->pax_flags = flags;
63179 + return 0;
63180 + }
63181 + return -EINVAL;
63182 +}
63183 +#endif
63184 +
63185 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
63186 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
63187 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
63188 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
63189 +#endif
63190 +
63191 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
63192 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
63193 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
63194 +extern __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to, const char *type);
63195 +
63196 /* Future-safe accessor for struct task_struct's cpus_allowed. */
63197 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
63198
63199 @@ -2104,7 +2196,9 @@ void yield(void);
63200 extern struct exec_domain default_exec_domain;
63201
63202 union thread_union {
63203 +#ifndef CONFIG_X86
63204 struct thread_info thread_info;
63205 +#endif
63206 unsigned long stack[THREAD_SIZE/sizeof(long)];
63207 };
63208
63209 @@ -2137,6 +2231,7 @@ extern struct pid_namespace init_pid_ns;
63210 */
63211
63212 extern struct task_struct *find_task_by_vpid(pid_t nr);
63213 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
63214 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
63215 struct pid_namespace *ns);
63216
63217 @@ -2280,7 +2375,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
63218 extern void exit_itimers(struct signal_struct *);
63219 extern void flush_itimer_signals(void);
63220
63221 -extern void do_group_exit(int);
63222 +extern __noreturn void do_group_exit(int);
63223
63224 extern void daemonize(const char *, ...);
63225 extern int allow_signal(int);
63226 @@ -2478,13 +2573,17 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
63227
63228 #endif
63229
63230 -static inline int object_is_on_stack(void *obj)
63231 +static inline int object_starts_on_stack(void *obj)
63232 {
63233 - void *stack = task_stack_page(current);
63234 + const void *stack = task_stack_page(current);
63235
63236 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
63237 }
63238
63239 +#ifdef CONFIG_PAX_USERCOPY
63240 +extern int object_is_on_stack(const void *obj, unsigned long len);
63241 +#endif
63242 +
63243 extern void thread_info_cache_init(void);
63244
63245 #ifdef CONFIG_DEBUG_STACK_USAGE
63246 diff --git a/include/linux/screen_info.h b/include/linux/screen_info.h
63247 index 899fbb4..1cb4138 100644
63248 --- a/include/linux/screen_info.h
63249 +++ b/include/linux/screen_info.h
63250 @@ -43,7 +43,8 @@ struct screen_info {
63251 __u16 pages; /* 0x32 */
63252 __u16 vesa_attributes; /* 0x34 */
63253 __u32 capabilities; /* 0x36 */
63254 - __u8 _reserved[6]; /* 0x3a */
63255 + __u16 vesapm_size; /* 0x3a */
63256 + __u8 _reserved[4]; /* 0x3c */
63257 } __attribute__((packed));
63258
63259 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
63260 diff --git a/include/linux/security.h b/include/linux/security.h
63261 index 83c18e8..2d98860 100644
63262 --- a/include/linux/security.h
63263 +++ b/include/linux/security.h
63264 @@ -37,6 +37,7 @@
63265 #include <linux/xfrm.h>
63266 #include <linux/slab.h>
63267 #include <linux/xattr.h>
63268 +#include <linux/grsecurity.h>
63269 #include <net/flow.h>
63270
63271 /* Maximum number of letters for an LSM name string */
63272 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
63273 index 44f1514..2bbf6c1 100644
63274 --- a/include/linux/seq_file.h
63275 +++ b/include/linux/seq_file.h
63276 @@ -24,6 +24,9 @@ struct seq_file {
63277 struct mutex lock;
63278 const struct seq_operations *op;
63279 int poll_event;
63280 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
63281 + u64 exec_id;
63282 +#endif
63283 void *private;
63284 };
63285
63286 @@ -33,6 +36,7 @@ struct seq_operations {
63287 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
63288 int (*show) (struct seq_file *m, void *v);
63289 };
63290 +typedef struct seq_operations __no_const seq_operations_no_const;
63291
63292 #define SEQ_SKIP 1
63293
63294 diff --git a/include/linux/shm.h b/include/linux/shm.h
63295 index 92808b8..c28cac4 100644
63296 --- a/include/linux/shm.h
63297 +++ b/include/linux/shm.h
63298 @@ -98,6 +98,10 @@ struct shmid_kernel /* private to the kernel */
63299
63300 /* The task created the shm object. NULL if the task is dead. */
63301 struct task_struct *shm_creator;
63302 +#ifdef CONFIG_GRKERNSEC
63303 + time_t shm_createtime;
63304 + pid_t shm_lapid;
63305 +#endif
63306 };
63307
63308 /* shm_mode upper byte flags */
63309 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
63310 index 42854ce..3b7d3c8 100644
63311 --- a/include/linux/skbuff.h
63312 +++ b/include/linux/skbuff.h
63313 @@ -655,7 +655,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
63314 */
63315 static inline int skb_queue_empty(const struct sk_buff_head *list)
63316 {
63317 - return list->next == (struct sk_buff *)list;
63318 + return list->next == (const struct sk_buff *)list;
63319 }
63320
63321 /**
63322 @@ -668,7 +668,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
63323 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
63324 const struct sk_buff *skb)
63325 {
63326 - return skb->next == (struct sk_buff *)list;
63327 + return skb->next == (const struct sk_buff *)list;
63328 }
63329
63330 /**
63331 @@ -681,7 +681,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
63332 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
63333 const struct sk_buff *skb)
63334 {
63335 - return skb->prev == (struct sk_buff *)list;
63336 + return skb->prev == (const struct sk_buff *)list;
63337 }
63338
63339 /**
63340 @@ -1558,7 +1558,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
63341 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
63342 */
63343 #ifndef NET_SKB_PAD
63344 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
63345 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
63346 #endif
63347
63348 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
63349 diff --git a/include/linux/slab.h b/include/linux/slab.h
63350 index 573c809..eaaf6ea 100644
63351 --- a/include/linux/slab.h
63352 +++ b/include/linux/slab.h
63353 @@ -11,12 +11,20 @@
63354
63355 #include <linux/gfp.h>
63356 #include <linux/types.h>
63357 +#include <linux/err.h>
63358
63359 /*
63360 * Flags to pass to kmem_cache_create().
63361 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
63362 */
63363 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
63364 +
63365 +#ifdef CONFIG_PAX_USERCOPY
63366 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
63367 +#else
63368 +#define SLAB_USERCOPY 0x00000000UL
63369 +#endif
63370 +
63371 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
63372 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
63373 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
63374 @@ -87,10 +95,13 @@
63375 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
63376 * Both make kfree a no-op.
63377 */
63378 -#define ZERO_SIZE_PTR ((void *)16)
63379 +#define ZERO_SIZE_PTR \
63380 +({ \
63381 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
63382 + (void *)(-MAX_ERRNO-1L); \
63383 +})
63384
63385 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
63386 - (unsigned long)ZERO_SIZE_PTR)
63387 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
63388
63389 /*
63390 * struct kmem_cache related prototypes
63391 @@ -161,6 +172,7 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
63392 void kfree(const void *);
63393 void kzfree(const void *);
63394 size_t ksize(const void *);
63395 +void check_object_size(const void *ptr, unsigned long n, bool to);
63396
63397 /*
63398 * Allocator specific definitions. These are mainly used to establish optimized
63399 @@ -287,7 +299,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
63400 */
63401 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
63402 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING))
63403 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
63404 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
63405 #define kmalloc_track_caller(size, flags) \
63406 __kmalloc_track_caller(size, flags, _RET_IP_)
63407 #else
63408 @@ -306,7 +318,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
63409 */
63410 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
63411 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING))
63412 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
63413 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
63414 #define kmalloc_node_track_caller(size, flags, node) \
63415 __kmalloc_node_track_caller(size, flags, node, \
63416 _RET_IP_)
63417 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
63418 index fbd1117..d4d8ef8 100644
63419 --- a/include/linux/slab_def.h
63420 +++ b/include/linux/slab_def.h
63421 @@ -66,10 +66,10 @@ struct kmem_cache {
63422 unsigned long node_allocs;
63423 unsigned long node_frees;
63424 unsigned long node_overflow;
63425 - atomic_t allochit;
63426 - atomic_t allocmiss;
63427 - atomic_t freehit;
63428 - atomic_t freemiss;
63429 + atomic_unchecked_t allochit;
63430 + atomic_unchecked_t allocmiss;
63431 + atomic_unchecked_t freehit;
63432 + atomic_unchecked_t freemiss;
63433
63434 /*
63435 * If debugging is enabled, then the allocator can add additional
63436 @@ -107,7 +107,7 @@ struct cache_sizes {
63437 extern struct cache_sizes malloc_sizes[];
63438
63439 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
63440 -void *__kmalloc(size_t size, gfp_t flags);
63441 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
63442
63443 #ifdef CONFIG_TRACING
63444 extern void *kmem_cache_alloc_trace(size_t size,
63445 @@ -160,7 +160,7 @@ found:
63446 }
63447
63448 #ifdef CONFIG_NUMA
63449 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
63450 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
63451 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
63452
63453 #ifdef CONFIG_TRACING
63454 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
63455 index 0ec00b3..39cb7fc 100644
63456 --- a/include/linux/slob_def.h
63457 +++ b/include/linux/slob_def.h
63458 @@ -9,7 +9,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
63459 return kmem_cache_alloc_node(cachep, flags, -1);
63460 }
63461
63462 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
63463 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
63464
63465 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
63466 {
63467 @@ -29,6 +29,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
63468 return __kmalloc_node(size, flags, -1);
63469 }
63470
63471 +static __always_inline void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
63472 static __always_inline void *__kmalloc(size_t size, gfp_t flags)
63473 {
63474 return kmalloc(size, flags);
63475 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
63476 index a32bcfd..a80ed70 100644
63477 --- a/include/linux/slub_def.h
63478 +++ b/include/linux/slub_def.h
63479 @@ -89,7 +89,7 @@ struct kmem_cache {
63480 struct kmem_cache_order_objects max;
63481 struct kmem_cache_order_objects min;
63482 gfp_t allocflags; /* gfp flags to use on each alloc */
63483 - int refcount; /* Refcount for slab cache destroy */
63484 + atomic_t refcount; /* Refcount for slab cache destroy */
63485 void (*ctor)(void *);
63486 int inuse; /* Offset to metadata */
63487 int align; /* Alignment */
63488 @@ -150,6 +150,7 @@ extern struct kmem_cache *kmalloc_caches[SLUB_PAGE_SHIFT];
63489 * Sorry that the following has to be that ugly but some versions of GCC
63490 * have trouble with constant propagation and loops.
63491 */
63492 +static __always_inline int kmalloc_index(size_t size) __size_overflow(1);
63493 static __always_inline int kmalloc_index(size_t size)
63494 {
63495 if (!size)
63496 @@ -215,7 +216,7 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
63497 }
63498
63499 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
63500 -void *__kmalloc(size_t size, gfp_t flags);
63501 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
63502
63503 static __always_inline void *
63504 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
63505 @@ -256,6 +257,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
63506 }
63507 #endif
63508
63509 +static __always_inline void *kmalloc_large(size_t size, gfp_t flags) __size_overflow(1);
63510 static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
63511 {
63512 unsigned int order = get_order(size);
63513 @@ -281,7 +283,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
63514 }
63515
63516 #ifdef CONFIG_NUMA
63517 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
63518 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
63519 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
63520
63521 #ifdef CONFIG_TRACING
63522 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
63523 index de8832d..0147b46 100644
63524 --- a/include/linux/sonet.h
63525 +++ b/include/linux/sonet.h
63526 @@ -61,7 +61,7 @@ struct sonet_stats {
63527 #include <linux/atomic.h>
63528
63529 struct k_sonet_stats {
63530 -#define __HANDLE_ITEM(i) atomic_t i
63531 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
63532 __SONET_ITEMS
63533 #undef __HANDLE_ITEM
63534 };
63535 diff --git a/include/linux/stddef.h b/include/linux/stddef.h
63536 index 6a40c76..1747b67 100644
63537 --- a/include/linux/stddef.h
63538 +++ b/include/linux/stddef.h
63539 @@ -3,14 +3,10 @@
63540
63541 #include <linux/compiler.h>
63542
63543 +#ifdef __KERNEL__
63544 +
63545 #undef NULL
63546 -#if defined(__cplusplus)
63547 -#define NULL 0
63548 -#else
63549 #define NULL ((void *)0)
63550 -#endif
63551 -
63552 -#ifdef __KERNEL__
63553
63554 enum {
63555 false = 0,
63556 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
63557 index 2c5993a..b0e79f0 100644
63558 --- a/include/linux/sunrpc/clnt.h
63559 +++ b/include/linux/sunrpc/clnt.h
63560 @@ -172,9 +172,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
63561 {
63562 switch (sap->sa_family) {
63563 case AF_INET:
63564 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
63565 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
63566 case AF_INET6:
63567 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
63568 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
63569 }
63570 return 0;
63571 }
63572 @@ -207,7 +207,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
63573 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
63574 const struct sockaddr *src)
63575 {
63576 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
63577 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
63578 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
63579
63580 dsin->sin_family = ssin->sin_family;
63581 @@ -310,7 +310,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
63582 if (sa->sa_family != AF_INET6)
63583 return 0;
63584
63585 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
63586 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
63587 }
63588
63589 #endif /* __KERNEL__ */
63590 diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h
63591 index e775689..9e206d9 100644
63592 --- a/include/linux/sunrpc/sched.h
63593 +++ b/include/linux/sunrpc/sched.h
63594 @@ -105,6 +105,7 @@ struct rpc_call_ops {
63595 void (*rpc_call_done)(struct rpc_task *, void *);
63596 void (*rpc_release)(void *);
63597 };
63598 +typedef struct rpc_call_ops __no_const rpc_call_ops_no_const;
63599
63600 struct rpc_task_setup {
63601 struct rpc_task *task;
63602 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
63603 index c14fe86..393245e 100644
63604 --- a/include/linux/sunrpc/svc_rdma.h
63605 +++ b/include/linux/sunrpc/svc_rdma.h
63606 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
63607 extern unsigned int svcrdma_max_requests;
63608 extern unsigned int svcrdma_max_req_size;
63609
63610 -extern atomic_t rdma_stat_recv;
63611 -extern atomic_t rdma_stat_read;
63612 -extern atomic_t rdma_stat_write;
63613 -extern atomic_t rdma_stat_sq_starve;
63614 -extern atomic_t rdma_stat_rq_starve;
63615 -extern atomic_t rdma_stat_rq_poll;
63616 -extern atomic_t rdma_stat_rq_prod;
63617 -extern atomic_t rdma_stat_sq_poll;
63618 -extern atomic_t rdma_stat_sq_prod;
63619 +extern atomic_unchecked_t rdma_stat_recv;
63620 +extern atomic_unchecked_t rdma_stat_read;
63621 +extern atomic_unchecked_t rdma_stat_write;
63622 +extern atomic_unchecked_t rdma_stat_sq_starve;
63623 +extern atomic_unchecked_t rdma_stat_rq_starve;
63624 +extern atomic_unchecked_t rdma_stat_rq_poll;
63625 +extern atomic_unchecked_t rdma_stat_rq_prod;
63626 +extern atomic_unchecked_t rdma_stat_sq_poll;
63627 +extern atomic_unchecked_t rdma_stat_sq_prod;
63628
63629 #define RPCRDMA_VERSION 1
63630
63631 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
63632 index bb9127d..34ab358 100644
63633 --- a/include/linux/sysctl.h
63634 +++ b/include/linux/sysctl.h
63635 @@ -155,7 +155,11 @@ enum
63636 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
63637 };
63638
63639 -
63640 +#ifdef CONFIG_PAX_SOFTMODE
63641 +enum {
63642 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
63643 +};
63644 +#endif
63645
63646 /* CTL_VM names: */
63647 enum
63648 @@ -968,6 +972,8 @@ typedef int proc_handler (struct ctl_table *ctl, int write,
63649
63650 extern int proc_dostring(struct ctl_table *, int,
63651 void __user *, size_t *, loff_t *);
63652 +extern int proc_dostring_modpriv(struct ctl_table *, int,
63653 + void __user *, size_t *, loff_t *);
63654 extern int proc_dointvec(struct ctl_table *, int,
63655 void __user *, size_t *, loff_t *);
63656 extern int proc_dointvec_minmax(struct ctl_table *, int,
63657 diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h
63658 index a71a292..51bd91d 100644
63659 --- a/include/linux/tracehook.h
63660 +++ b/include/linux/tracehook.h
63661 @@ -54,12 +54,12 @@ struct linux_binprm;
63662 /*
63663 * ptrace report for syscall entry and exit looks identical.
63664 */
63665 -static inline void ptrace_report_syscall(struct pt_regs *regs)
63666 +static inline int ptrace_report_syscall(struct pt_regs *regs)
63667 {
63668 int ptrace = current->ptrace;
63669
63670 if (!(ptrace & PT_PTRACED))
63671 - return;
63672 + return 0;
63673
63674 ptrace_notify(SIGTRAP | ((ptrace & PT_TRACESYSGOOD) ? 0x80 : 0));
63675
63676 @@ -72,6 +72,8 @@ static inline void ptrace_report_syscall(struct pt_regs *regs)
63677 send_sig(current->exit_code, current, 1);
63678 current->exit_code = 0;
63679 }
63680 +
63681 + return fatal_signal_pending(current);
63682 }
63683
63684 /**
63685 @@ -96,8 +98,7 @@ static inline void ptrace_report_syscall(struct pt_regs *regs)
63686 static inline __must_check int tracehook_report_syscall_entry(
63687 struct pt_regs *regs)
63688 {
63689 - ptrace_report_syscall(regs);
63690 - return 0;
63691 + return ptrace_report_syscall(regs);
63692 }
63693
63694 /**
63695 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
63696 index ff7dc08..893e1bd 100644
63697 --- a/include/linux/tty_ldisc.h
63698 +++ b/include/linux/tty_ldisc.h
63699 @@ -148,7 +148,7 @@ struct tty_ldisc_ops {
63700
63701 struct module *owner;
63702
63703 - int refcount;
63704 + atomic_t refcount;
63705 };
63706
63707 struct tty_ldisc {
63708 diff --git a/include/linux/types.h b/include/linux/types.h
63709 index e5fa503..df6e8a4 100644
63710 --- a/include/linux/types.h
63711 +++ b/include/linux/types.h
63712 @@ -214,10 +214,26 @@ typedef struct {
63713 int counter;
63714 } atomic_t;
63715
63716 +#ifdef CONFIG_PAX_REFCOUNT
63717 +typedef struct {
63718 + int counter;
63719 +} atomic_unchecked_t;
63720 +#else
63721 +typedef atomic_t atomic_unchecked_t;
63722 +#endif
63723 +
63724 #ifdef CONFIG_64BIT
63725 typedef struct {
63726 long counter;
63727 } atomic64_t;
63728 +
63729 +#ifdef CONFIG_PAX_REFCOUNT
63730 +typedef struct {
63731 + long counter;
63732 +} atomic64_unchecked_t;
63733 +#else
63734 +typedef atomic64_t atomic64_unchecked_t;
63735 +#endif
63736 #endif
63737
63738 struct list_head {
63739 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
63740 index 5ca0951..ab496a5 100644
63741 --- a/include/linux/uaccess.h
63742 +++ b/include/linux/uaccess.h
63743 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
63744 long ret; \
63745 mm_segment_t old_fs = get_fs(); \
63746 \
63747 - set_fs(KERNEL_DS); \
63748 pagefault_disable(); \
63749 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
63750 - pagefault_enable(); \
63751 + set_fs(KERNEL_DS); \
63752 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
63753 set_fs(old_fs); \
63754 + pagefault_enable(); \
63755 ret; \
63756 })
63757
63758 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
63759 index 99c1b4d..bb94261 100644
63760 --- a/include/linux/unaligned/access_ok.h
63761 +++ b/include/linux/unaligned/access_ok.h
63762 @@ -6,32 +6,32 @@
63763
63764 static inline u16 get_unaligned_le16(const void *p)
63765 {
63766 - return le16_to_cpup((__le16 *)p);
63767 + return le16_to_cpup((const __le16 *)p);
63768 }
63769
63770 static inline u32 get_unaligned_le32(const void *p)
63771 {
63772 - return le32_to_cpup((__le32 *)p);
63773 + return le32_to_cpup((const __le32 *)p);
63774 }
63775
63776 static inline u64 get_unaligned_le64(const void *p)
63777 {
63778 - return le64_to_cpup((__le64 *)p);
63779 + return le64_to_cpup((const __le64 *)p);
63780 }
63781
63782 static inline u16 get_unaligned_be16(const void *p)
63783 {
63784 - return be16_to_cpup((__be16 *)p);
63785 + return be16_to_cpup((const __be16 *)p);
63786 }
63787
63788 static inline u32 get_unaligned_be32(const void *p)
63789 {
63790 - return be32_to_cpup((__be32 *)p);
63791 + return be32_to_cpup((const __be32 *)p);
63792 }
63793
63794 static inline u64 get_unaligned_be64(const void *p)
63795 {
63796 - return be64_to_cpup((__be64 *)p);
63797 + return be64_to_cpup((const __be64 *)p);
63798 }
63799
63800 static inline void put_unaligned_le16(u16 val, void *p)
63801 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
63802 index 0d3f988..000f101 100644
63803 --- a/include/linux/usb/renesas_usbhs.h
63804 +++ b/include/linux/usb/renesas_usbhs.h
63805 @@ -39,7 +39,7 @@ enum {
63806 */
63807 struct renesas_usbhs_driver_callback {
63808 int (*notify_hotplug)(struct platform_device *pdev);
63809 -};
63810 +} __no_const;
63811
63812 /*
63813 * callback functions for platform
63814 @@ -97,7 +97,7 @@ struct renesas_usbhs_platform_callback {
63815 * VBUS control is needed for Host
63816 */
63817 int (*set_vbus)(struct platform_device *pdev, int enable);
63818 -};
63819 +} __no_const;
63820
63821 /*
63822 * parameters for renesas usbhs
63823 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
63824 index 6f8fbcf..8259001 100644
63825 --- a/include/linux/vermagic.h
63826 +++ b/include/linux/vermagic.h
63827 @@ -25,9 +25,35 @@
63828 #define MODULE_ARCH_VERMAGIC ""
63829 #endif
63830
63831 +#ifdef CONFIG_PAX_REFCOUNT
63832 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
63833 +#else
63834 +#define MODULE_PAX_REFCOUNT ""
63835 +#endif
63836 +
63837 +#ifdef CONSTIFY_PLUGIN
63838 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
63839 +#else
63840 +#define MODULE_CONSTIFY_PLUGIN ""
63841 +#endif
63842 +
63843 +#ifdef STACKLEAK_PLUGIN
63844 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
63845 +#else
63846 +#define MODULE_STACKLEAK_PLUGIN ""
63847 +#endif
63848 +
63849 +#ifdef CONFIG_GRKERNSEC
63850 +#define MODULE_GRSEC "GRSEC "
63851 +#else
63852 +#define MODULE_GRSEC ""
63853 +#endif
63854 +
63855 #define VERMAGIC_STRING \
63856 UTS_RELEASE " " \
63857 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
63858 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
63859 - MODULE_ARCH_VERMAGIC
63860 + MODULE_ARCH_VERMAGIC \
63861 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
63862 + MODULE_GRSEC
63863
63864 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
63865 index dcdfc2b..ec79ab5 100644
63866 --- a/include/linux/vmalloc.h
63867 +++ b/include/linux/vmalloc.h
63868 @@ -14,6 +14,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
63869 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
63870 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
63871 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
63872 +
63873 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
63874 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
63875 +#endif
63876 +
63877 /* bits [20..32] reserved for arch specific ioremap internals */
63878
63879 /*
63880 @@ -62,7 +67,7 @@ extern void *vmalloc_32_user(unsigned long size);
63881 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
63882 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
63883 unsigned long start, unsigned long end, gfp_t gfp_mask,
63884 - pgprot_t prot, int node, void *caller);
63885 + pgprot_t prot, int node, void *caller) __size_overflow(1);
63886 extern void vfree(const void *addr);
63887
63888 extern void *vmap(struct page **pages, unsigned int count,
63889 @@ -123,8 +128,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
63890 extern void free_vm_area(struct vm_struct *area);
63891
63892 /* for /dev/kmem */
63893 -extern long vread(char *buf, char *addr, unsigned long count);
63894 -extern long vwrite(char *buf, char *addr, unsigned long count);
63895 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
63896 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
63897
63898 /*
63899 * Internals. Dont't use..
63900 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
63901 index 65efb92..137adbb 100644
63902 --- a/include/linux/vmstat.h
63903 +++ b/include/linux/vmstat.h
63904 @@ -87,18 +87,18 @@ static inline void vm_events_fold_cpu(int cpu)
63905 /*
63906 * Zone based page accounting with per cpu differentials.
63907 */
63908 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
63909 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
63910
63911 static inline void zone_page_state_add(long x, struct zone *zone,
63912 enum zone_stat_item item)
63913 {
63914 - atomic_long_add(x, &zone->vm_stat[item]);
63915 - atomic_long_add(x, &vm_stat[item]);
63916 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
63917 + atomic_long_add_unchecked(x, &vm_stat[item]);
63918 }
63919
63920 static inline unsigned long global_page_state(enum zone_stat_item item)
63921 {
63922 - long x = atomic_long_read(&vm_stat[item]);
63923 + long x = atomic_long_read_unchecked(&vm_stat[item]);
63924 #ifdef CONFIG_SMP
63925 if (x < 0)
63926 x = 0;
63927 @@ -109,7 +109,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
63928 static inline unsigned long zone_page_state(struct zone *zone,
63929 enum zone_stat_item item)
63930 {
63931 - long x = atomic_long_read(&zone->vm_stat[item]);
63932 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
63933 #ifdef CONFIG_SMP
63934 if (x < 0)
63935 x = 0;
63936 @@ -126,7 +126,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
63937 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
63938 enum zone_stat_item item)
63939 {
63940 - long x = atomic_long_read(&zone->vm_stat[item]);
63941 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
63942
63943 #ifdef CONFIG_SMP
63944 int cpu;
63945 @@ -221,8 +221,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
63946
63947 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
63948 {
63949 - atomic_long_inc(&zone->vm_stat[item]);
63950 - atomic_long_inc(&vm_stat[item]);
63951 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
63952 + atomic_long_inc_unchecked(&vm_stat[item]);
63953 }
63954
63955 static inline void __inc_zone_page_state(struct page *page,
63956 @@ -233,8 +233,8 @@ static inline void __inc_zone_page_state(struct page *page,
63957
63958 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
63959 {
63960 - atomic_long_dec(&zone->vm_stat[item]);
63961 - atomic_long_dec(&vm_stat[item]);
63962 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
63963 + atomic_long_dec_unchecked(&vm_stat[item]);
63964 }
63965
63966 static inline void __dec_zone_page_state(struct page *page,
63967 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
63968 index e5d1220..ef6e406 100644
63969 --- a/include/linux/xattr.h
63970 +++ b/include/linux/xattr.h
63971 @@ -57,6 +57,11 @@
63972 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
63973 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
63974
63975 +/* User namespace */
63976 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
63977 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
63978 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
63979 +
63980 #ifdef __KERNEL__
63981
63982 #include <linux/types.h>
63983 diff --git a/include/media/saa7146_vv.h b/include/media/saa7146_vv.h
63984 index 4aeff96..b378cdc 100644
63985 --- a/include/media/saa7146_vv.h
63986 +++ b/include/media/saa7146_vv.h
63987 @@ -163,7 +163,7 @@ struct saa7146_ext_vv
63988 int (*std_callback)(struct saa7146_dev*, struct saa7146_standard *);
63989
63990 /* the extension can override this */
63991 - struct v4l2_ioctl_ops ops;
63992 + v4l2_ioctl_ops_no_const ops;
63993 /* pointer to the saa7146 core ops */
63994 const struct v4l2_ioctl_ops *core_ops;
63995
63996 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
63997 index c7c40f1..4f01585 100644
63998 --- a/include/media/v4l2-dev.h
63999 +++ b/include/media/v4l2-dev.h
64000 @@ -56,7 +56,7 @@ int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority local);
64001
64002
64003 struct v4l2_file_operations {
64004 - struct module *owner;
64005 + struct module * const owner;
64006 ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
64007 ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
64008 unsigned int (*poll) (struct file *, struct poll_table_struct *);
64009 @@ -68,6 +68,7 @@ struct v4l2_file_operations {
64010 int (*open) (struct file *);
64011 int (*release) (struct file *);
64012 };
64013 +typedef struct v4l2_file_operations __no_const v4l2_file_operations_no_const;
64014
64015 /*
64016 * Newer version of video_device, handled by videodev2.c
64017 diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
64018 index 3f5d60f..44210ed 100644
64019 --- a/include/media/v4l2-ioctl.h
64020 +++ b/include/media/v4l2-ioctl.h
64021 @@ -278,7 +278,7 @@ struct v4l2_ioctl_ops {
64022 long (*vidioc_default) (struct file *file, void *fh,
64023 bool valid_prio, int cmd, void *arg);
64024 };
64025 -
64026 +typedef struct v4l2_ioctl_ops __no_const v4l2_ioctl_ops_no_const;
64027
64028 /* v4l debugging and diagnostics */
64029
64030 diff --git a/include/net/caif/caif_hsi.h b/include/net/caif/caif_hsi.h
64031 index 8d55251..dfe5b0a 100644
64032 --- a/include/net/caif/caif_hsi.h
64033 +++ b/include/net/caif/caif_hsi.h
64034 @@ -98,7 +98,7 @@ struct cfhsi_drv {
64035 void (*rx_done_cb) (struct cfhsi_drv *drv);
64036 void (*wake_up_cb) (struct cfhsi_drv *drv);
64037 void (*wake_down_cb) (struct cfhsi_drv *drv);
64038 -};
64039 +} __no_const;
64040
64041 /* Structure implemented by HSI device. */
64042 struct cfhsi_dev {
64043 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
64044 index 9e5425b..8136ffc 100644
64045 --- a/include/net/caif/cfctrl.h
64046 +++ b/include/net/caif/cfctrl.h
64047 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
64048 void (*radioset_rsp)(void);
64049 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
64050 struct cflayer *client_layer);
64051 -};
64052 +} __no_const;
64053
64054 /* Link Setup Parameters for CAIF-Links. */
64055 struct cfctrl_link_param {
64056 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
64057 struct cfctrl {
64058 struct cfsrvl serv;
64059 struct cfctrl_rsp res;
64060 - atomic_t req_seq_no;
64061 - atomic_t rsp_seq_no;
64062 + atomic_unchecked_t req_seq_no;
64063 + atomic_unchecked_t rsp_seq_no;
64064 struct list_head list;
64065 /* Protects from simultaneous access to first_req list */
64066 spinlock_t info_list_lock;
64067 diff --git a/include/net/flow.h b/include/net/flow.h
64068 index 6c469db..7743b8e 100644
64069 --- a/include/net/flow.h
64070 +++ b/include/net/flow.h
64071 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
64072
64073 extern void flow_cache_flush(void);
64074 extern void flow_cache_flush_deferred(void);
64075 -extern atomic_t flow_cache_genid;
64076 +extern atomic_unchecked_t flow_cache_genid;
64077
64078 #endif
64079 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
64080 index b94765e..053f68b 100644
64081 --- a/include/net/inetpeer.h
64082 +++ b/include/net/inetpeer.h
64083 @@ -48,8 +48,8 @@ struct inet_peer {
64084 */
64085 union {
64086 struct {
64087 - atomic_t rid; /* Frag reception counter */
64088 - atomic_t ip_id_count; /* IP ID for the next packet */
64089 + atomic_unchecked_t rid; /* Frag reception counter */
64090 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
64091 __u32 tcp_ts;
64092 __u32 tcp_ts_stamp;
64093 };
64094 @@ -115,11 +115,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
64095 more++;
64096 inet_peer_refcheck(p);
64097 do {
64098 - old = atomic_read(&p->ip_id_count);
64099 + old = atomic_read_unchecked(&p->ip_id_count);
64100 new = old + more;
64101 if (!new)
64102 new = 1;
64103 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
64104 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
64105 return new;
64106 }
64107
64108 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
64109 index 10422ef..662570f 100644
64110 --- a/include/net/ip_fib.h
64111 +++ b/include/net/ip_fib.h
64112 @@ -146,7 +146,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
64113
64114 #define FIB_RES_SADDR(net, res) \
64115 ((FIB_RES_NH(res).nh_saddr_genid == \
64116 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
64117 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
64118 FIB_RES_NH(res).nh_saddr : \
64119 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
64120 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
64121 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
64122 index ebe517f..1bd286b 100644
64123 --- a/include/net/ip_vs.h
64124 +++ b/include/net/ip_vs.h
64125 @@ -509,7 +509,7 @@ struct ip_vs_conn {
64126 struct ip_vs_conn *control; /* Master control connection */
64127 atomic_t n_control; /* Number of controlled ones */
64128 struct ip_vs_dest *dest; /* real server */
64129 - atomic_t in_pkts; /* incoming packet counter */
64130 + atomic_unchecked_t in_pkts; /* incoming packet counter */
64131
64132 /* packet transmitter for different forwarding methods. If it
64133 mangles the packet, it must return NF_DROP or better NF_STOLEN,
64134 @@ -647,7 +647,7 @@ struct ip_vs_dest {
64135 __be16 port; /* port number of the server */
64136 union nf_inet_addr addr; /* IP address of the server */
64137 volatile unsigned flags; /* dest status flags */
64138 - atomic_t conn_flags; /* flags to copy to conn */
64139 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
64140 atomic_t weight; /* server weight */
64141
64142 atomic_t refcnt; /* reference counter */
64143 diff --git a/include/net/irda/ircomm_core.h b/include/net/irda/ircomm_core.h
64144 index 69b610a..fe3962c 100644
64145 --- a/include/net/irda/ircomm_core.h
64146 +++ b/include/net/irda/ircomm_core.h
64147 @@ -51,7 +51,7 @@ typedef struct {
64148 int (*connect_response)(struct ircomm_cb *, struct sk_buff *);
64149 int (*disconnect_request)(struct ircomm_cb *, struct sk_buff *,
64150 struct ircomm_info *);
64151 -} call_t;
64152 +} __no_const call_t;
64153
64154 struct ircomm_cb {
64155 irda_queue_t queue;
64156 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
64157 index 59ba38bc..d515662 100644
64158 --- a/include/net/irda/ircomm_tty.h
64159 +++ b/include/net/irda/ircomm_tty.h
64160 @@ -35,6 +35,7 @@
64161 #include <linux/termios.h>
64162 #include <linux/timer.h>
64163 #include <linux/tty.h> /* struct tty_struct */
64164 +#include <asm/local.h>
64165
64166 #include <net/irda/irias_object.h>
64167 #include <net/irda/ircomm_core.h>
64168 @@ -105,8 +106,8 @@ struct ircomm_tty_cb {
64169 unsigned short close_delay;
64170 unsigned short closing_wait; /* time to wait before closing */
64171
64172 - int open_count;
64173 - int blocked_open; /* # of blocked opens */
64174 + local_t open_count;
64175 + local_t blocked_open; /* # of blocked opens */
64176
64177 /* Protect concurent access to :
64178 * o self->open_count
64179 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
64180 index 0954ec9..7413562 100644
64181 --- a/include/net/iucv/af_iucv.h
64182 +++ b/include/net/iucv/af_iucv.h
64183 @@ -138,7 +138,7 @@ struct iucv_sock {
64184 struct iucv_sock_list {
64185 struct hlist_head head;
64186 rwlock_t lock;
64187 - atomic_t autobind_name;
64188 + atomic_unchecked_t autobind_name;
64189 };
64190
64191 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
64192 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
64193 index 34c996f..bb3b4d4 100644
64194 --- a/include/net/neighbour.h
64195 +++ b/include/net/neighbour.h
64196 @@ -123,7 +123,7 @@ struct neigh_ops {
64197 void (*error_report)(struct neighbour *, struct sk_buff *);
64198 int (*output)(struct neighbour *, struct sk_buff *);
64199 int (*connected_output)(struct neighbour *, struct sk_buff *);
64200 -};
64201 +} __do_const;
64202
64203 struct pneigh_entry {
64204 struct pneigh_entry *next;
64205 diff --git a/include/net/netlink.h b/include/net/netlink.h
64206 index cb1f350..3279d2c 100644
64207 --- a/include/net/netlink.h
64208 +++ b/include/net/netlink.h
64209 @@ -569,7 +569,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
64210 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
64211 {
64212 if (mark)
64213 - skb_trim(skb, (unsigned char *) mark - skb->data);
64214 + skb_trim(skb, (const unsigned char *) mark - skb->data);
64215 }
64216
64217 /**
64218 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
64219 index bbd023a..97c6d0d 100644
64220 --- a/include/net/netns/ipv4.h
64221 +++ b/include/net/netns/ipv4.h
64222 @@ -57,8 +57,8 @@ struct netns_ipv4 {
64223 unsigned int sysctl_ping_group_range[2];
64224 long sysctl_tcp_mem[3];
64225
64226 - atomic_t rt_genid;
64227 - atomic_t dev_addr_genid;
64228 + atomic_unchecked_t rt_genid;
64229 + atomic_unchecked_t dev_addr_genid;
64230
64231 #ifdef CONFIG_IP_MROUTE
64232 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
64233 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
64234 index d368561..96aaa17 100644
64235 --- a/include/net/sctp/sctp.h
64236 +++ b/include/net/sctp/sctp.h
64237 @@ -318,9 +318,9 @@ do { \
64238
64239 #else /* SCTP_DEBUG */
64240
64241 -#define SCTP_DEBUG_PRINTK(whatever...)
64242 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
64243 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
64244 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
64245 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
64246 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
64247 #define SCTP_ENABLE_DEBUG
64248 #define SCTP_DISABLE_DEBUG
64249 #define SCTP_ASSERT(expr, str, func)
64250 diff --git a/include/net/sock.h b/include/net/sock.h
64251 index 91c1c8b..15ae923 100644
64252 --- a/include/net/sock.h
64253 +++ b/include/net/sock.h
64254 @@ -299,7 +299,7 @@ struct sock {
64255 #ifdef CONFIG_RPS
64256 __u32 sk_rxhash;
64257 #endif
64258 - atomic_t sk_drops;
64259 + atomic_unchecked_t sk_drops;
64260 int sk_rcvbuf;
64261
64262 struct sk_filter __rcu *sk_filter;
64263 @@ -1660,7 +1660,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
64264 }
64265
64266 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
64267 - char __user *from, char *to,
64268 + char __user *from, unsigned char *to,
64269 int copy, int offset)
64270 {
64271 if (skb->ip_summed == CHECKSUM_NONE) {
64272 diff --git a/include/net/tcp.h b/include/net/tcp.h
64273 index 2d80c29..aa07caf 100644
64274 --- a/include/net/tcp.h
64275 +++ b/include/net/tcp.h
64276 @@ -1426,7 +1426,7 @@ struct tcp_seq_afinfo {
64277 char *name;
64278 sa_family_t family;
64279 const struct file_operations *seq_fops;
64280 - struct seq_operations seq_ops;
64281 + seq_operations_no_const seq_ops;
64282 };
64283
64284 struct tcp_iter_state {
64285 diff --git a/include/net/udp.h b/include/net/udp.h
64286 index e39592f..fef9680 100644
64287 --- a/include/net/udp.h
64288 +++ b/include/net/udp.h
64289 @@ -243,7 +243,7 @@ struct udp_seq_afinfo {
64290 sa_family_t family;
64291 struct udp_table *udp_table;
64292 const struct file_operations *seq_fops;
64293 - struct seq_operations seq_ops;
64294 + seq_operations_no_const seq_ops;
64295 };
64296
64297 struct udp_iter_state {
64298 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
64299 index 89174e2..1f82598 100644
64300 --- a/include/net/xfrm.h
64301 +++ b/include/net/xfrm.h
64302 @@ -505,7 +505,7 @@ struct xfrm_policy {
64303 struct timer_list timer;
64304
64305 struct flow_cache_object flo;
64306 - atomic_t genid;
64307 + atomic_unchecked_t genid;
64308 u32 priority;
64309 u32 index;
64310 struct xfrm_mark mark;
64311 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
64312 index 1a046b1..ee0bef0 100644
64313 --- a/include/rdma/iw_cm.h
64314 +++ b/include/rdma/iw_cm.h
64315 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
64316 int backlog);
64317
64318 int (*destroy_listen)(struct iw_cm_id *cm_id);
64319 -};
64320 +} __no_const;
64321
64322 /**
64323 * iw_create_cm_id - Create an IW CM identifier.
64324 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
64325 index 6a3922f..0b73022 100644
64326 --- a/include/scsi/libfc.h
64327 +++ b/include/scsi/libfc.h
64328 @@ -748,6 +748,7 @@ struct libfc_function_template {
64329 */
64330 void (*disc_stop_final) (struct fc_lport *);
64331 };
64332 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
64333
64334 /**
64335 * struct fc_disc - Discovery context
64336 @@ -851,7 +852,7 @@ struct fc_lport {
64337 struct fc_vport *vport;
64338
64339 /* Operational Information */
64340 - struct libfc_function_template tt;
64341 + libfc_function_template_no_const tt;
64342 u8 link_up;
64343 u8 qfull;
64344 enum fc_lport_state state;
64345 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
64346 index 77273f2..dd4031f 100644
64347 --- a/include/scsi/scsi_device.h
64348 +++ b/include/scsi/scsi_device.h
64349 @@ -161,9 +161,9 @@ struct scsi_device {
64350 unsigned int max_device_blocked; /* what device_blocked counts down from */
64351 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
64352
64353 - atomic_t iorequest_cnt;
64354 - atomic_t iodone_cnt;
64355 - atomic_t ioerr_cnt;
64356 + atomic_unchecked_t iorequest_cnt;
64357 + atomic_unchecked_t iodone_cnt;
64358 + atomic_unchecked_t ioerr_cnt;
64359
64360 struct device sdev_gendev,
64361 sdev_dev;
64362 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
64363 index 2a65167..91e01f8 100644
64364 --- a/include/scsi/scsi_transport_fc.h
64365 +++ b/include/scsi/scsi_transport_fc.h
64366 @@ -711,7 +711,7 @@ struct fc_function_template {
64367 unsigned long show_host_system_hostname:1;
64368
64369 unsigned long disable_target_scan:1;
64370 -};
64371 +} __do_const;
64372
64373
64374 /**
64375 diff --git a/include/sound/ak4xxx-adda.h b/include/sound/ak4xxx-adda.h
64376 index 030b87c..98a6954 100644
64377 --- a/include/sound/ak4xxx-adda.h
64378 +++ b/include/sound/ak4xxx-adda.h
64379 @@ -35,7 +35,7 @@ struct snd_ak4xxx_ops {
64380 void (*write)(struct snd_akm4xxx *ak, int chip, unsigned char reg,
64381 unsigned char val);
64382 void (*set_rate_val)(struct snd_akm4xxx *ak, unsigned int rate);
64383 -};
64384 +} __no_const;
64385
64386 #define AK4XXX_IMAGE_SIZE (AK4XXX_MAX_CHIPS * 16) /* 64 bytes */
64387
64388 diff --git a/include/sound/hwdep.h b/include/sound/hwdep.h
64389 index 8c05e47..2b5df97 100644
64390 --- a/include/sound/hwdep.h
64391 +++ b/include/sound/hwdep.h
64392 @@ -49,7 +49,7 @@ struct snd_hwdep_ops {
64393 struct snd_hwdep_dsp_status *status);
64394 int (*dsp_load)(struct snd_hwdep *hw,
64395 struct snd_hwdep_dsp_image *image);
64396 -};
64397 +} __no_const;
64398
64399 struct snd_hwdep {
64400 struct snd_card *card;
64401 diff --git a/include/sound/info.h b/include/sound/info.h
64402 index 9ca1a49..aba1728 100644
64403 --- a/include/sound/info.h
64404 +++ b/include/sound/info.h
64405 @@ -44,7 +44,7 @@ struct snd_info_entry_text {
64406 struct snd_info_buffer *buffer);
64407 void (*write)(struct snd_info_entry *entry,
64408 struct snd_info_buffer *buffer);
64409 -};
64410 +} __no_const;
64411
64412 struct snd_info_entry_ops {
64413 int (*open)(struct snd_info_entry *entry,
64414 diff --git a/include/sound/pcm.h b/include/sound/pcm.h
64415 index 0cf91b2..b70cae4 100644
64416 --- a/include/sound/pcm.h
64417 +++ b/include/sound/pcm.h
64418 @@ -81,6 +81,7 @@ struct snd_pcm_ops {
64419 int (*mmap)(struct snd_pcm_substream *substream, struct vm_area_struct *vma);
64420 int (*ack)(struct snd_pcm_substream *substream);
64421 };
64422 +typedef struct snd_pcm_ops __no_const snd_pcm_ops_no_const;
64423
64424 /*
64425 *
64426 diff --git a/include/sound/sb16_csp.h b/include/sound/sb16_csp.h
64427 index af1b49e..a5d55a5 100644
64428 --- a/include/sound/sb16_csp.h
64429 +++ b/include/sound/sb16_csp.h
64430 @@ -146,7 +146,7 @@ struct snd_sb_csp_ops {
64431 int (*csp_start) (struct snd_sb_csp * p, int sample_width, int channels);
64432 int (*csp_stop) (struct snd_sb_csp * p);
64433 int (*csp_qsound_transfer) (struct snd_sb_csp * p);
64434 -};
64435 +} __no_const;
64436
64437 /*
64438 * CSP private data
64439 diff --git a/include/sound/soc.h b/include/sound/soc.h
64440 index 0992dff..bb366fe 100644
64441 --- a/include/sound/soc.h
64442 +++ b/include/sound/soc.h
64443 @@ -682,7 +682,7 @@ struct snd_soc_platform_driver {
64444 /* platform IO - used for platform DAPM */
64445 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
64446 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
64447 -};
64448 +} __do_const;
64449
64450 struct snd_soc_platform {
64451 const char *name;
64452 @@ -852,7 +852,7 @@ struct snd_soc_pcm_runtime {
64453 struct snd_soc_dai_link *dai_link;
64454 struct mutex pcm_mutex;
64455 enum snd_soc_pcm_subclass pcm_subclass;
64456 - struct snd_pcm_ops ops;
64457 + snd_pcm_ops_no_const ops;
64458
64459 unsigned int complete:1;
64460 unsigned int dev_registered:1;
64461 diff --git a/include/sound/ymfpci.h b/include/sound/ymfpci.h
64462 index 444cd6b..3327cc5 100644
64463 --- a/include/sound/ymfpci.h
64464 +++ b/include/sound/ymfpci.h
64465 @@ -358,7 +358,7 @@ struct snd_ymfpci {
64466 spinlock_t reg_lock;
64467 spinlock_t voice_lock;
64468 wait_queue_head_t interrupt_sleep;
64469 - atomic_t interrupt_sleep_count;
64470 + atomic_unchecked_t interrupt_sleep_count;
64471 struct snd_info_entry *proc_entry;
64472 const struct firmware *dsp_microcode;
64473 const struct firmware *controller_microcode;
64474 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
64475 index fe73eb8..56388b1 100644
64476 --- a/include/target/target_core_base.h
64477 +++ b/include/target/target_core_base.h
64478 @@ -443,7 +443,7 @@ struct t10_reservation_ops {
64479 int (*t10_seq_non_holder)(struct se_cmd *, unsigned char *, u32);
64480 int (*t10_pr_register)(struct se_cmd *);
64481 int (*t10_pr_clear)(struct se_cmd *);
64482 -};
64483 +} __no_const;
64484
64485 struct t10_reservation {
64486 /* Reservation effects all target ports */
64487 @@ -561,8 +561,8 @@ struct se_cmd {
64488 atomic_t t_se_count;
64489 atomic_t t_task_cdbs_left;
64490 atomic_t t_task_cdbs_ex_left;
64491 - atomic_t t_task_cdbs_sent;
64492 - atomic_t t_transport_aborted;
64493 + atomic_unchecked_t t_task_cdbs_sent;
64494 + atomic_unchecked_t t_transport_aborted;
64495 atomic_t t_transport_active;
64496 atomic_t t_transport_complete;
64497 atomic_t t_transport_queue_active;
64498 @@ -799,7 +799,7 @@ struct se_device {
64499 spinlock_t stats_lock;
64500 /* Active commands on this virtual SE device */
64501 atomic_t simple_cmds;
64502 - atomic_t dev_ordered_id;
64503 + atomic_unchecked_t dev_ordered_id;
64504 atomic_t execute_tasks;
64505 atomic_t dev_ordered_sync;
64506 atomic_t dev_qf_count;
64507 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
64508 index 1c09820..7f5ec79 100644
64509 --- a/include/trace/events/irq.h
64510 +++ b/include/trace/events/irq.h
64511 @@ -36,7 +36,7 @@ struct softirq_action;
64512 */
64513 TRACE_EVENT(irq_handler_entry,
64514
64515 - TP_PROTO(int irq, struct irqaction *action),
64516 + TP_PROTO(int irq, const struct irqaction *action),
64517
64518 TP_ARGS(irq, action),
64519
64520 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
64521 */
64522 TRACE_EVENT(irq_handler_exit,
64523
64524 - TP_PROTO(int irq, struct irqaction *action, int ret),
64525 + TP_PROTO(int irq, const struct irqaction *action, int ret),
64526
64527 TP_ARGS(irq, action, ret),
64528
64529 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
64530 index c41f308..6918de3 100644
64531 --- a/include/video/udlfb.h
64532 +++ b/include/video/udlfb.h
64533 @@ -52,10 +52,10 @@ struct dlfb_data {
64534 u32 pseudo_palette[256];
64535 int blank_mode; /*one of FB_BLANK_ */
64536 /* blit-only rendering path metrics, exposed through sysfs */
64537 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
64538 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
64539 - atomic_t bytes_sent; /* to usb, after compression including overhead */
64540 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
64541 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
64542 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
64543 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
64544 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
64545 };
64546
64547 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
64548 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
64549 index 0993a22..32ba2fe 100644
64550 --- a/include/video/uvesafb.h
64551 +++ b/include/video/uvesafb.h
64552 @@ -177,6 +177,7 @@ struct uvesafb_par {
64553 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
64554 u8 pmi_setpal; /* PMI for palette changes */
64555 u16 *pmi_base; /* protected mode interface location */
64556 + u8 *pmi_code; /* protected mode code location */
64557 void *pmi_start;
64558 void *pmi_pal;
64559 u8 *vbe_state_orig; /*
64560 diff --git a/init/Kconfig b/init/Kconfig
64561 index 3f42cd6..613f41d 100644
64562 --- a/init/Kconfig
64563 +++ b/init/Kconfig
64564 @@ -799,6 +799,7 @@ endif # CGROUPS
64565
64566 config CHECKPOINT_RESTORE
64567 bool "Checkpoint/restore support" if EXPERT
64568 + depends on !GRKERNSEC
64569 default n
64570 help
64571 Enables additional kernel features in a sake of checkpoint/restore.
64572 @@ -1249,7 +1250,7 @@ config SLUB_DEBUG
64573
64574 config COMPAT_BRK
64575 bool "Disable heap randomization"
64576 - default y
64577 + default n
64578 help
64579 Randomizing heap placement makes heap exploits harder, but it
64580 also breaks ancient binaries (including anything libc5 based).
64581 diff --git a/init/do_mounts.c b/init/do_mounts.c
64582 index bf6edbf..4e5809c 100644
64583 --- a/init/do_mounts.c
64584 +++ b/init/do_mounts.c
64585 @@ -326,11 +326,11 @@ static void __init get_fs_names(char *page)
64586 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
64587 {
64588 struct super_block *s;
64589 - int err = sys_mount(name, "/root", fs, flags, data);
64590 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
64591 if (err)
64592 return err;
64593
64594 - sys_chdir((const char __user __force *)"/root");
64595 + sys_chdir((const char __force_user *)"/root");
64596 s = current->fs->pwd.dentry->d_sb;
64597 ROOT_DEV = s->s_dev;
64598 printk(KERN_INFO
64599 @@ -450,18 +450,18 @@ void __init change_floppy(char *fmt, ...)
64600 va_start(args, fmt);
64601 vsprintf(buf, fmt, args);
64602 va_end(args);
64603 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
64604 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
64605 if (fd >= 0) {
64606 sys_ioctl(fd, FDEJECT, 0);
64607 sys_close(fd);
64608 }
64609 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
64610 - fd = sys_open("/dev/console", O_RDWR, 0);
64611 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
64612 if (fd >= 0) {
64613 sys_ioctl(fd, TCGETS, (long)&termios);
64614 termios.c_lflag &= ~ICANON;
64615 sys_ioctl(fd, TCSETSF, (long)&termios);
64616 - sys_read(fd, &c, 1);
64617 + sys_read(fd, (char __user *)&c, 1);
64618 termios.c_lflag |= ICANON;
64619 sys_ioctl(fd, TCSETSF, (long)&termios);
64620 sys_close(fd);
64621 @@ -555,6 +555,6 @@ void __init prepare_namespace(void)
64622 mount_root();
64623 out:
64624 devtmpfs_mount("dev");
64625 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
64626 - sys_chroot((const char __user __force *)".");
64627 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
64628 + sys_chroot((const char __force_user *)".");
64629 }
64630 diff --git a/init/do_mounts.h b/init/do_mounts.h
64631 index f5b978a..69dbfe8 100644
64632 --- a/init/do_mounts.h
64633 +++ b/init/do_mounts.h
64634 @@ -15,15 +15,15 @@ extern int root_mountflags;
64635
64636 static inline int create_dev(char *name, dev_t dev)
64637 {
64638 - sys_unlink(name);
64639 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
64640 + sys_unlink((char __force_user *)name);
64641 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
64642 }
64643
64644 #if BITS_PER_LONG == 32
64645 static inline u32 bstat(char *name)
64646 {
64647 struct stat64 stat;
64648 - if (sys_stat64(name, &stat) != 0)
64649 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
64650 return 0;
64651 if (!S_ISBLK(stat.st_mode))
64652 return 0;
64653 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
64654 static inline u32 bstat(char *name)
64655 {
64656 struct stat stat;
64657 - if (sys_newstat(name, &stat) != 0)
64658 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
64659 return 0;
64660 if (!S_ISBLK(stat.st_mode))
64661 return 0;
64662 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
64663 index 3098a38..253064e 100644
64664 --- a/init/do_mounts_initrd.c
64665 +++ b/init/do_mounts_initrd.c
64666 @@ -44,13 +44,13 @@ static void __init handle_initrd(void)
64667 create_dev("/dev/root.old", Root_RAM0);
64668 /* mount initrd on rootfs' /root */
64669 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
64670 - sys_mkdir("/old", 0700);
64671 - root_fd = sys_open("/", 0, 0);
64672 - old_fd = sys_open("/old", 0, 0);
64673 + sys_mkdir((const char __force_user *)"/old", 0700);
64674 + root_fd = sys_open((const char __force_user *)"/", 0, 0);
64675 + old_fd = sys_open((const char __force_user *)"/old", 0, 0);
64676 /* move initrd over / and chdir/chroot in initrd root */
64677 - sys_chdir("/root");
64678 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
64679 - sys_chroot(".");
64680 + sys_chdir((const char __force_user *)"/root");
64681 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
64682 + sys_chroot((const char __force_user *)".");
64683
64684 /*
64685 * In case that a resume from disk is carried out by linuxrc or one of
64686 @@ -67,15 +67,15 @@ static void __init handle_initrd(void)
64687
64688 /* move initrd to rootfs' /old */
64689 sys_fchdir(old_fd);
64690 - sys_mount("/", ".", NULL, MS_MOVE, NULL);
64691 + sys_mount((char __force_user *)"/", (char __force_user *)".", NULL, MS_MOVE, NULL);
64692 /* switch root and cwd back to / of rootfs */
64693 sys_fchdir(root_fd);
64694 - sys_chroot(".");
64695 + sys_chroot((const char __force_user *)".");
64696 sys_close(old_fd);
64697 sys_close(root_fd);
64698
64699 if (new_decode_dev(real_root_dev) == Root_RAM0) {
64700 - sys_chdir("/old");
64701 + sys_chdir((const char __force_user *)"/old");
64702 return;
64703 }
64704
64705 @@ -83,17 +83,17 @@ static void __init handle_initrd(void)
64706 mount_root();
64707
64708 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
64709 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
64710 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
64711 if (!error)
64712 printk("okay\n");
64713 else {
64714 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
64715 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
64716 if (error == -ENOENT)
64717 printk("/initrd does not exist. Ignored.\n");
64718 else
64719 printk("failed\n");
64720 printk(KERN_NOTICE "Unmounting old root\n");
64721 - sys_umount("/old", MNT_DETACH);
64722 + sys_umount((char __force_user *)"/old", MNT_DETACH);
64723 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
64724 if (fd < 0) {
64725 error = fd;
64726 @@ -116,11 +116,11 @@ int __init initrd_load(void)
64727 * mounted in the normal path.
64728 */
64729 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
64730 - sys_unlink("/initrd.image");
64731 + sys_unlink((const char __force_user *)"/initrd.image");
64732 handle_initrd();
64733 return 1;
64734 }
64735 }
64736 - sys_unlink("/initrd.image");
64737 + sys_unlink((const char __force_user *)"/initrd.image");
64738 return 0;
64739 }
64740 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
64741 index 32c4799..c27ee74 100644
64742 --- a/init/do_mounts_md.c
64743 +++ b/init/do_mounts_md.c
64744 @@ -170,7 +170,7 @@ static void __init md_setup_drive(void)
64745 partitioned ? "_d" : "", minor,
64746 md_setup_args[ent].device_names);
64747
64748 - fd = sys_open(name, 0, 0);
64749 + fd = sys_open((char __force_user *)name, 0, 0);
64750 if (fd < 0) {
64751 printk(KERN_ERR "md: open failed - cannot start "
64752 "array %s\n", name);
64753 @@ -233,7 +233,7 @@ static void __init md_setup_drive(void)
64754 * array without it
64755 */
64756 sys_close(fd);
64757 - fd = sys_open(name, 0, 0);
64758 + fd = sys_open((char __force_user *)name, 0, 0);
64759 sys_ioctl(fd, BLKRRPART, 0);
64760 }
64761 sys_close(fd);
64762 @@ -283,7 +283,7 @@ static void __init autodetect_raid(void)
64763
64764 wait_for_device_probe();
64765
64766 - fd = sys_open((const char __user __force *) "/dev/md0", 0, 0);
64767 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
64768 if (fd >= 0) {
64769 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
64770 sys_close(fd);
64771 diff --git a/init/initramfs.c b/init/initramfs.c
64772 index 8216c30..25e8e32 100644
64773 --- a/init/initramfs.c
64774 +++ b/init/initramfs.c
64775 @@ -74,7 +74,7 @@ static void __init free_hash(void)
64776 }
64777 }
64778
64779 -static long __init do_utime(char __user *filename, time_t mtime)
64780 +static long __init do_utime(__force char __user *filename, time_t mtime)
64781 {
64782 struct timespec t[2];
64783
64784 @@ -109,7 +109,7 @@ static void __init dir_utime(void)
64785 struct dir_entry *de, *tmp;
64786 list_for_each_entry_safe(de, tmp, &dir_list, list) {
64787 list_del(&de->list);
64788 - do_utime(de->name, de->mtime);
64789 + do_utime((char __force_user *)de->name, de->mtime);
64790 kfree(de->name);
64791 kfree(de);
64792 }
64793 @@ -271,7 +271,7 @@ static int __init maybe_link(void)
64794 if (nlink >= 2) {
64795 char *old = find_link(major, minor, ino, mode, collected);
64796 if (old)
64797 - return (sys_link(old, collected) < 0) ? -1 : 1;
64798 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
64799 }
64800 return 0;
64801 }
64802 @@ -280,11 +280,11 @@ static void __init clean_path(char *path, umode_t mode)
64803 {
64804 struct stat st;
64805
64806 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
64807 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
64808 if (S_ISDIR(st.st_mode))
64809 - sys_rmdir(path);
64810 + sys_rmdir((char __force_user *)path);
64811 else
64812 - sys_unlink(path);
64813 + sys_unlink((char __force_user *)path);
64814 }
64815 }
64816
64817 @@ -305,7 +305,7 @@ static int __init do_name(void)
64818 int openflags = O_WRONLY|O_CREAT;
64819 if (ml != 1)
64820 openflags |= O_TRUNC;
64821 - wfd = sys_open(collected, openflags, mode);
64822 + wfd = sys_open((char __force_user *)collected, openflags, mode);
64823
64824 if (wfd >= 0) {
64825 sys_fchown(wfd, uid, gid);
64826 @@ -317,17 +317,17 @@ static int __init do_name(void)
64827 }
64828 }
64829 } else if (S_ISDIR(mode)) {
64830 - sys_mkdir(collected, mode);
64831 - sys_chown(collected, uid, gid);
64832 - sys_chmod(collected, mode);
64833 + sys_mkdir((char __force_user *)collected, mode);
64834 + sys_chown((char __force_user *)collected, uid, gid);
64835 + sys_chmod((char __force_user *)collected, mode);
64836 dir_add(collected, mtime);
64837 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
64838 S_ISFIFO(mode) || S_ISSOCK(mode)) {
64839 if (maybe_link() == 0) {
64840 - sys_mknod(collected, mode, rdev);
64841 - sys_chown(collected, uid, gid);
64842 - sys_chmod(collected, mode);
64843 - do_utime(collected, mtime);
64844 + sys_mknod((char __force_user *)collected, mode, rdev);
64845 + sys_chown((char __force_user *)collected, uid, gid);
64846 + sys_chmod((char __force_user *)collected, mode);
64847 + do_utime((char __force_user *)collected, mtime);
64848 }
64849 }
64850 return 0;
64851 @@ -336,15 +336,15 @@ static int __init do_name(void)
64852 static int __init do_copy(void)
64853 {
64854 if (count >= body_len) {
64855 - sys_write(wfd, victim, body_len);
64856 + sys_write(wfd, (char __force_user *)victim, body_len);
64857 sys_close(wfd);
64858 - do_utime(vcollected, mtime);
64859 + do_utime((char __force_user *)vcollected, mtime);
64860 kfree(vcollected);
64861 eat(body_len);
64862 state = SkipIt;
64863 return 0;
64864 } else {
64865 - sys_write(wfd, victim, count);
64866 + sys_write(wfd, (char __force_user *)victim, count);
64867 body_len -= count;
64868 eat(count);
64869 return 1;
64870 @@ -355,9 +355,9 @@ static int __init do_symlink(void)
64871 {
64872 collected[N_ALIGN(name_len) + body_len] = '\0';
64873 clean_path(collected, 0);
64874 - sys_symlink(collected + N_ALIGN(name_len), collected);
64875 - sys_lchown(collected, uid, gid);
64876 - do_utime(collected, mtime);
64877 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
64878 + sys_lchown((char __force_user *)collected, uid, gid);
64879 + do_utime((char __force_user *)collected, mtime);
64880 state = SkipIt;
64881 next_state = Reset;
64882 return 0;
64883 diff --git a/init/main.c b/init/main.c
64884 index ff49a6d..5fa0429 100644
64885 --- a/init/main.c
64886 +++ b/init/main.c
64887 @@ -96,6 +96,8 @@ static inline void mark_rodata_ro(void) { }
64888 extern void tc_init(void);
64889 #endif
64890
64891 +extern void grsecurity_init(void);
64892 +
64893 /*
64894 * Debug helper: via this flag we know that we are in 'early bootup code'
64895 * where only the boot processor is running with IRQ disabled. This means
64896 @@ -149,6 +151,49 @@ static int __init set_reset_devices(char *str)
64897
64898 __setup("reset_devices", set_reset_devices);
64899
64900 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
64901 +extern char pax_enter_kernel_user[];
64902 +extern char pax_exit_kernel_user[];
64903 +extern pgdval_t clone_pgd_mask;
64904 +#endif
64905 +
64906 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
64907 +static int __init setup_pax_nouderef(char *str)
64908 +{
64909 +#ifdef CONFIG_X86_32
64910 + unsigned int cpu;
64911 + struct desc_struct *gdt;
64912 +
64913 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
64914 + gdt = get_cpu_gdt_table(cpu);
64915 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
64916 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
64917 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
64918 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
64919 + }
64920 + asm("mov %0, %%ds; mov %0, %%es; mov %0, %%ss" : : "r" (__KERNEL_DS) : "memory");
64921 +#else
64922 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
64923 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
64924 + clone_pgd_mask = ~(pgdval_t)0UL;
64925 +#endif
64926 +
64927 + return 0;
64928 +}
64929 +early_param("pax_nouderef", setup_pax_nouderef);
64930 +#endif
64931 +
64932 +#ifdef CONFIG_PAX_SOFTMODE
64933 +int pax_softmode;
64934 +
64935 +static int __init setup_pax_softmode(char *str)
64936 +{
64937 + get_option(&str, &pax_softmode);
64938 + return 1;
64939 +}
64940 +__setup("pax_softmode=", setup_pax_softmode);
64941 +#endif
64942 +
64943 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
64944 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
64945 static const char *panic_later, *panic_param;
64946 @@ -675,6 +720,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
64947 {
64948 int count = preempt_count();
64949 int ret;
64950 + const char *msg1 = "", *msg2 = "";
64951
64952 if (initcall_debug)
64953 ret = do_one_initcall_debug(fn);
64954 @@ -687,15 +733,15 @@ int __init_or_module do_one_initcall(initcall_t fn)
64955 sprintf(msgbuf, "error code %d ", ret);
64956
64957 if (preempt_count() != count) {
64958 - strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
64959 + msg1 = " preemption imbalance";
64960 preempt_count() = count;
64961 }
64962 if (irqs_disabled()) {
64963 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
64964 + msg2 = " disabled interrupts";
64965 local_irq_enable();
64966 }
64967 - if (msgbuf[0]) {
64968 - printk("initcall %pF returned with %s\n", fn, msgbuf);
64969 + if (msgbuf[0] || *msg1 || *msg2) {
64970 + printk("initcall %pF returned with %s%s%s\n", fn, msgbuf, msg1, msg2);
64971 }
64972
64973 return ret;
64974 @@ -814,7 +860,7 @@ static int __init kernel_init(void * unused)
64975 do_basic_setup();
64976
64977 /* Open the /dev/console on the rootfs, this should never fail */
64978 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
64979 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
64980 printk(KERN_WARNING "Warning: unable to open an initial console.\n");
64981
64982 (void) sys_dup(0);
64983 @@ -827,11 +873,13 @@ static int __init kernel_init(void * unused)
64984 if (!ramdisk_execute_command)
64985 ramdisk_execute_command = "/init";
64986
64987 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
64988 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
64989 ramdisk_execute_command = NULL;
64990 prepare_namespace();
64991 }
64992
64993 + grsecurity_init();
64994 +
64995 /*
64996 * Ok, we have completed the initial bootup, and
64997 * we're essentially up and running. Get rid of the
64998 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
64999 index 86ee272..773d937 100644
65000 --- a/ipc/mqueue.c
65001 +++ b/ipc/mqueue.c
65002 @@ -156,6 +156,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
65003 mq_bytes = (mq_msg_tblsz +
65004 (info->attr.mq_maxmsg * info->attr.mq_msgsize));
65005
65006 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
65007 spin_lock(&mq_lock);
65008 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
65009 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
65010 diff --git a/ipc/msg.c b/ipc/msg.c
65011 index 7385de2..a8180e08 100644
65012 --- a/ipc/msg.c
65013 +++ b/ipc/msg.c
65014 @@ -309,18 +309,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
65015 return security_msg_queue_associate(msq, msgflg);
65016 }
65017
65018 +static struct ipc_ops msg_ops = {
65019 + .getnew = newque,
65020 + .associate = msg_security,
65021 + .more_checks = NULL
65022 +};
65023 +
65024 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
65025 {
65026 struct ipc_namespace *ns;
65027 - struct ipc_ops msg_ops;
65028 struct ipc_params msg_params;
65029
65030 ns = current->nsproxy->ipc_ns;
65031
65032 - msg_ops.getnew = newque;
65033 - msg_ops.associate = msg_security;
65034 - msg_ops.more_checks = NULL;
65035 -
65036 msg_params.key = key;
65037 msg_params.flg = msgflg;
65038
65039 diff --git a/ipc/sem.c b/ipc/sem.c
65040 index 5215a81..cfc0cac 100644
65041 --- a/ipc/sem.c
65042 +++ b/ipc/sem.c
65043 @@ -364,10 +364,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
65044 return 0;
65045 }
65046
65047 +static struct ipc_ops sem_ops = {
65048 + .getnew = newary,
65049 + .associate = sem_security,
65050 + .more_checks = sem_more_checks
65051 +};
65052 +
65053 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
65054 {
65055 struct ipc_namespace *ns;
65056 - struct ipc_ops sem_ops;
65057 struct ipc_params sem_params;
65058
65059 ns = current->nsproxy->ipc_ns;
65060 @@ -375,10 +380,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
65061 if (nsems < 0 || nsems > ns->sc_semmsl)
65062 return -EINVAL;
65063
65064 - sem_ops.getnew = newary;
65065 - sem_ops.associate = sem_security;
65066 - sem_ops.more_checks = sem_more_checks;
65067 -
65068 sem_params.key = key;
65069 sem_params.flg = semflg;
65070 sem_params.u.nsems = nsems;
65071 diff --git a/ipc/shm.c b/ipc/shm.c
65072 index b76be5b..859e750 100644
65073 --- a/ipc/shm.c
65074 +++ b/ipc/shm.c
65075 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
65076 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
65077 #endif
65078
65079 +#ifdef CONFIG_GRKERNSEC
65080 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
65081 + const time_t shm_createtime, const uid_t cuid,
65082 + const int shmid);
65083 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
65084 + const time_t shm_createtime);
65085 +#endif
65086 +
65087 void shm_init_ns(struct ipc_namespace *ns)
65088 {
65089 ns->shm_ctlmax = SHMMAX;
65090 @@ -508,6 +516,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
65091 shp->shm_lprid = 0;
65092 shp->shm_atim = shp->shm_dtim = 0;
65093 shp->shm_ctim = get_seconds();
65094 +#ifdef CONFIG_GRKERNSEC
65095 + {
65096 + struct timespec timeval;
65097 + do_posix_clock_monotonic_gettime(&timeval);
65098 +
65099 + shp->shm_createtime = timeval.tv_sec;
65100 + }
65101 +#endif
65102 shp->shm_segsz = size;
65103 shp->shm_nattch = 0;
65104 shp->shm_file = file;
65105 @@ -559,18 +575,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
65106 return 0;
65107 }
65108
65109 +static struct ipc_ops shm_ops = {
65110 + .getnew = newseg,
65111 + .associate = shm_security,
65112 + .more_checks = shm_more_checks
65113 +};
65114 +
65115 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
65116 {
65117 struct ipc_namespace *ns;
65118 - struct ipc_ops shm_ops;
65119 struct ipc_params shm_params;
65120
65121 ns = current->nsproxy->ipc_ns;
65122
65123 - shm_ops.getnew = newseg;
65124 - shm_ops.associate = shm_security;
65125 - shm_ops.more_checks = shm_more_checks;
65126 -
65127 shm_params.key = key;
65128 shm_params.flg = shmflg;
65129 shm_params.u.size = size;
65130 @@ -988,6 +1005,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr)
65131 f_mode = FMODE_READ | FMODE_WRITE;
65132 }
65133 if (shmflg & SHM_EXEC) {
65134 +
65135 +#ifdef CONFIG_PAX_MPROTECT
65136 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
65137 + goto out;
65138 +#endif
65139 +
65140 prot |= PROT_EXEC;
65141 acc_mode |= S_IXUGO;
65142 }
65143 @@ -1011,9 +1034,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr)
65144 if (err)
65145 goto out_unlock;
65146
65147 +#ifdef CONFIG_GRKERNSEC
65148 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
65149 + shp->shm_perm.cuid, shmid) ||
65150 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
65151 + err = -EACCES;
65152 + goto out_unlock;
65153 + }
65154 +#endif
65155 +
65156 path = shp->shm_file->f_path;
65157 path_get(&path);
65158 shp->shm_nattch++;
65159 +#ifdef CONFIG_GRKERNSEC
65160 + shp->shm_lapid = current->pid;
65161 +#endif
65162 size = i_size_read(path.dentry->d_inode);
65163 shm_unlock(shp);
65164
65165 diff --git a/kernel/acct.c b/kernel/acct.c
65166 index 02e6167..54824f7 100644
65167 --- a/kernel/acct.c
65168 +++ b/kernel/acct.c
65169 @@ -550,7 +550,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
65170 */
65171 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
65172 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
65173 - file->f_op->write(file, (char *)&ac,
65174 + file->f_op->write(file, (char __force_user *)&ac,
65175 sizeof(acct_t), &file->f_pos);
65176 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
65177 set_fs(fs);
65178 diff --git a/kernel/audit.c b/kernel/audit.c
65179 index bb0eb5b..cf2a03a 100644
65180 --- a/kernel/audit.c
65181 +++ b/kernel/audit.c
65182 @@ -115,7 +115,7 @@ u32 audit_sig_sid = 0;
65183 3) suppressed due to audit_rate_limit
65184 4) suppressed due to audit_backlog_limit
65185 */
65186 -static atomic_t audit_lost = ATOMIC_INIT(0);
65187 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
65188
65189 /* The netlink socket. */
65190 static struct sock *audit_sock;
65191 @@ -237,7 +237,7 @@ void audit_log_lost(const char *message)
65192 unsigned long now;
65193 int print;
65194
65195 - atomic_inc(&audit_lost);
65196 + atomic_inc_unchecked(&audit_lost);
65197
65198 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
65199
65200 @@ -256,7 +256,7 @@ void audit_log_lost(const char *message)
65201 printk(KERN_WARNING
65202 "audit: audit_lost=%d audit_rate_limit=%d "
65203 "audit_backlog_limit=%d\n",
65204 - atomic_read(&audit_lost),
65205 + atomic_read_unchecked(&audit_lost),
65206 audit_rate_limit,
65207 audit_backlog_limit);
65208 audit_panic(message);
65209 @@ -689,7 +689,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
65210 status_set.pid = audit_pid;
65211 status_set.rate_limit = audit_rate_limit;
65212 status_set.backlog_limit = audit_backlog_limit;
65213 - status_set.lost = atomic_read(&audit_lost);
65214 + status_set.lost = atomic_read_unchecked(&audit_lost);
65215 status_set.backlog = skb_queue_len(&audit_skb_queue);
65216 audit_send_reply(NETLINK_CB(skb).pid, seq, AUDIT_GET, 0, 0,
65217 &status_set, sizeof(status_set));
65218 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
65219 index af1de0f..06dfe57 100644
65220 --- a/kernel/auditsc.c
65221 +++ b/kernel/auditsc.c
65222 @@ -2288,7 +2288,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
65223 }
65224
65225 /* global counter which is incremented every time something logs in */
65226 -static atomic_t session_id = ATOMIC_INIT(0);
65227 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
65228
65229 /**
65230 * audit_set_loginuid - set current task's audit_context loginuid
65231 @@ -2312,7 +2312,7 @@ int audit_set_loginuid(uid_t loginuid)
65232 return -EPERM;
65233 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
65234
65235 - sessionid = atomic_inc_return(&session_id);
65236 + sessionid = atomic_inc_return_unchecked(&session_id);
65237 if (context && context->in_syscall) {
65238 struct audit_buffer *ab;
65239
65240 diff --git a/kernel/capability.c b/kernel/capability.c
65241 index 3f1adb6..c564db0 100644
65242 --- a/kernel/capability.c
65243 +++ b/kernel/capability.c
65244 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
65245 * before modification is attempted and the application
65246 * fails.
65247 */
65248 + if (tocopy > ARRAY_SIZE(kdata))
65249 + return -EFAULT;
65250 +
65251 if (copy_to_user(dataptr, kdata, tocopy
65252 * sizeof(struct __user_cap_data_struct))) {
65253 return -EFAULT;
65254 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
65255 int ret;
65256
65257 rcu_read_lock();
65258 - ret = security_capable(__task_cred(t), ns, cap);
65259 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
65260 + gr_task_is_capable(t, __task_cred(t), cap);
65261 rcu_read_unlock();
65262
65263 - return (ret == 0);
65264 + return ret;
65265 }
65266
65267 /**
65268 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
65269 int ret;
65270
65271 rcu_read_lock();
65272 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
65273 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
65274 rcu_read_unlock();
65275
65276 - return (ret == 0);
65277 + return ret;
65278 }
65279
65280 /**
65281 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
65282 BUG();
65283 }
65284
65285 - if (security_capable(current_cred(), ns, cap) == 0) {
65286 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
65287 current->flags |= PF_SUPERPRIV;
65288 return true;
65289 }
65290 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
65291 }
65292 EXPORT_SYMBOL(ns_capable);
65293
65294 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
65295 +{
65296 + if (unlikely(!cap_valid(cap))) {
65297 + printk(KERN_CRIT "capable() called with invalid cap=%u\n", cap);
65298 + BUG();
65299 + }
65300 +
65301 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
65302 + current->flags |= PF_SUPERPRIV;
65303 + return true;
65304 + }
65305 + return false;
65306 +}
65307 +EXPORT_SYMBOL(ns_capable_nolog);
65308 +
65309 /**
65310 * capable - Determine if the current task has a superior capability in effect
65311 * @cap: The capability to be tested for
65312 @@ -408,6 +427,12 @@ bool capable(int cap)
65313 }
65314 EXPORT_SYMBOL(capable);
65315
65316 +bool capable_nolog(int cap)
65317 +{
65318 + return ns_capable_nolog(&init_user_ns, cap);
65319 +}
65320 +EXPORT_SYMBOL(capable_nolog);
65321 +
65322 /**
65323 * nsown_capable - Check superior capability to one's own user_ns
65324 * @cap: The capability in question
65325 diff --git a/kernel/compat.c b/kernel/compat.c
65326 index a6d0649..f44fb27 100644
65327 --- a/kernel/compat.c
65328 +++ b/kernel/compat.c
65329 @@ -13,6 +13,7 @@
65330
65331 #include <linux/linkage.h>
65332 #include <linux/compat.h>
65333 +#include <linux/module.h>
65334 #include <linux/errno.h>
65335 #include <linux/time.h>
65336 #include <linux/signal.h>
65337 @@ -168,7 +169,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
65338 mm_segment_t oldfs;
65339 long ret;
65340
65341 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
65342 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
65343 oldfs = get_fs();
65344 set_fs(KERNEL_DS);
65345 ret = hrtimer_nanosleep_restart(restart);
65346 @@ -200,7 +201,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
65347 oldfs = get_fs();
65348 set_fs(KERNEL_DS);
65349 ret = hrtimer_nanosleep(&tu,
65350 - rmtp ? (struct timespec __user *)&rmt : NULL,
65351 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
65352 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
65353 set_fs(oldfs);
65354
65355 @@ -309,7 +310,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
65356 mm_segment_t old_fs = get_fs();
65357
65358 set_fs(KERNEL_DS);
65359 - ret = sys_sigpending((old_sigset_t __user *) &s);
65360 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
65361 set_fs(old_fs);
65362 if (ret == 0)
65363 ret = put_user(s, set);
65364 @@ -399,7 +400,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
65365 mm_segment_t old_fs = get_fs();
65366
65367 set_fs(KERNEL_DS);
65368 - ret = sys_old_getrlimit(resource, &r);
65369 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
65370 set_fs(old_fs);
65371
65372 if (!ret) {
65373 @@ -471,7 +472,7 @@ asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)
65374 mm_segment_t old_fs = get_fs();
65375
65376 set_fs(KERNEL_DS);
65377 - ret = sys_getrusage(who, (struct rusage __user *) &r);
65378 + ret = sys_getrusage(who, (struct rusage __force_user *) &r);
65379 set_fs(old_fs);
65380
65381 if (ret)
65382 @@ -498,8 +499,8 @@ compat_sys_wait4(compat_pid_t pid, compat_uint_t __user *stat_addr, int options,
65383 set_fs (KERNEL_DS);
65384 ret = sys_wait4(pid,
65385 (stat_addr ?
65386 - (unsigned int __user *) &status : NULL),
65387 - options, (struct rusage __user *) &r);
65388 + (unsigned int __force_user *) &status : NULL),
65389 + options, (struct rusage __force_user *) &r);
65390 set_fs (old_fs);
65391
65392 if (ret > 0) {
65393 @@ -524,8 +525,8 @@ asmlinkage long compat_sys_waitid(int which, compat_pid_t pid,
65394 memset(&info, 0, sizeof(info));
65395
65396 set_fs(KERNEL_DS);
65397 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
65398 - uru ? (struct rusage __user *)&ru : NULL);
65399 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
65400 + uru ? (struct rusage __force_user *)&ru : NULL);
65401 set_fs(old_fs);
65402
65403 if ((ret < 0) || (info.si_signo == 0))
65404 @@ -655,8 +656,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
65405 oldfs = get_fs();
65406 set_fs(KERNEL_DS);
65407 err = sys_timer_settime(timer_id, flags,
65408 - (struct itimerspec __user *) &newts,
65409 - (struct itimerspec __user *) &oldts);
65410 + (struct itimerspec __force_user *) &newts,
65411 + (struct itimerspec __force_user *) &oldts);
65412 set_fs(oldfs);
65413 if (!err && old && put_compat_itimerspec(old, &oldts))
65414 return -EFAULT;
65415 @@ -673,7 +674,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
65416 oldfs = get_fs();
65417 set_fs(KERNEL_DS);
65418 err = sys_timer_gettime(timer_id,
65419 - (struct itimerspec __user *) &ts);
65420 + (struct itimerspec __force_user *) &ts);
65421 set_fs(oldfs);
65422 if (!err && put_compat_itimerspec(setting, &ts))
65423 return -EFAULT;
65424 @@ -692,7 +693,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
65425 oldfs = get_fs();
65426 set_fs(KERNEL_DS);
65427 err = sys_clock_settime(which_clock,
65428 - (struct timespec __user *) &ts);
65429 + (struct timespec __force_user *) &ts);
65430 set_fs(oldfs);
65431 return err;
65432 }
65433 @@ -707,7 +708,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
65434 oldfs = get_fs();
65435 set_fs(KERNEL_DS);
65436 err = sys_clock_gettime(which_clock,
65437 - (struct timespec __user *) &ts);
65438 + (struct timespec __force_user *) &ts);
65439 set_fs(oldfs);
65440 if (!err && put_compat_timespec(&ts, tp))
65441 return -EFAULT;
65442 @@ -727,7 +728,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
65443
65444 oldfs = get_fs();
65445 set_fs(KERNEL_DS);
65446 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
65447 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
65448 set_fs(oldfs);
65449
65450 err = compat_put_timex(utp, &txc);
65451 @@ -747,7 +748,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
65452 oldfs = get_fs();
65453 set_fs(KERNEL_DS);
65454 err = sys_clock_getres(which_clock,
65455 - (struct timespec __user *) &ts);
65456 + (struct timespec __force_user *) &ts);
65457 set_fs(oldfs);
65458 if (!err && tp && put_compat_timespec(&ts, tp))
65459 return -EFAULT;
65460 @@ -759,9 +760,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
65461 long err;
65462 mm_segment_t oldfs;
65463 struct timespec tu;
65464 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
65465 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
65466
65467 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
65468 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
65469 oldfs = get_fs();
65470 set_fs(KERNEL_DS);
65471 err = clock_nanosleep_restart(restart);
65472 @@ -793,8 +794,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
65473 oldfs = get_fs();
65474 set_fs(KERNEL_DS);
65475 err = sys_clock_nanosleep(which_clock, flags,
65476 - (struct timespec __user *) &in,
65477 - (struct timespec __user *) &out);
65478 + (struct timespec __force_user *) &in,
65479 + (struct timespec __force_user *) &out);
65480 set_fs(oldfs);
65481
65482 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
65483 diff --git a/kernel/configs.c b/kernel/configs.c
65484 index 42e8fa0..9e7406b 100644
65485 --- a/kernel/configs.c
65486 +++ b/kernel/configs.c
65487 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
65488 struct proc_dir_entry *entry;
65489
65490 /* create the current config file */
65491 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
65492 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
65493 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
65494 + &ikconfig_file_ops);
65495 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
65496 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
65497 + &ikconfig_file_ops);
65498 +#endif
65499 +#else
65500 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
65501 &ikconfig_file_ops);
65502 +#endif
65503 +
65504 if (!entry)
65505 return -ENOMEM;
65506
65507 diff --git a/kernel/cred.c b/kernel/cred.c
65508 index 48c6fd3..8398912 100644
65509 --- a/kernel/cred.c
65510 +++ b/kernel/cred.c
65511 @@ -204,6 +204,15 @@ void exit_creds(struct task_struct *tsk)
65512 validate_creds(cred);
65513 put_cred(cred);
65514 }
65515 +
65516 +#ifdef CONFIG_GRKERNSEC_SETXID
65517 + cred = (struct cred *) tsk->delayed_cred;
65518 + if (cred) {
65519 + tsk->delayed_cred = NULL;
65520 + validate_creds(cred);
65521 + put_cred(cred);
65522 + }
65523 +#endif
65524 }
65525
65526 /**
65527 @@ -472,7 +481,7 @@ error_put:
65528 * Always returns 0 thus allowing this function to be tail-called at the end
65529 * of, say, sys_setgid().
65530 */
65531 -int commit_creds(struct cred *new)
65532 +static int __commit_creds(struct cred *new)
65533 {
65534 struct task_struct *task = current;
65535 const struct cred *old = task->real_cred;
65536 @@ -491,6 +500,8 @@ int commit_creds(struct cred *new)
65537
65538 get_cred(new); /* we will require a ref for the subj creds too */
65539
65540 + gr_set_role_label(task, new->uid, new->gid);
65541 +
65542 /* dumpability changes */
65543 if (old->euid != new->euid ||
65544 old->egid != new->egid ||
65545 @@ -540,6 +551,101 @@ int commit_creds(struct cred *new)
65546 put_cred(old);
65547 return 0;
65548 }
65549 +#ifdef CONFIG_GRKERNSEC_SETXID
65550 +extern int set_user(struct cred *new);
65551 +
65552 +void gr_delayed_cred_worker(void)
65553 +{
65554 + const struct cred *new = current->delayed_cred;
65555 + struct cred *ncred;
65556 +
65557 + current->delayed_cred = NULL;
65558 +
65559 + if (current_uid() && new != NULL) {
65560 + // from doing get_cred on it when queueing this
65561 + put_cred(new);
65562 + return;
65563 + } else if (new == NULL)
65564 + return;
65565 +
65566 + ncred = prepare_creds();
65567 + if (!ncred)
65568 + goto die;
65569 + // uids
65570 + ncred->uid = new->uid;
65571 + ncred->euid = new->euid;
65572 + ncred->suid = new->suid;
65573 + ncred->fsuid = new->fsuid;
65574 + // gids
65575 + ncred->gid = new->gid;
65576 + ncred->egid = new->egid;
65577 + ncred->sgid = new->sgid;
65578 + ncred->fsgid = new->fsgid;
65579 + // groups
65580 + if (set_groups(ncred, new->group_info) < 0) {
65581 + abort_creds(ncred);
65582 + goto die;
65583 + }
65584 + // caps
65585 + ncred->securebits = new->securebits;
65586 + ncred->cap_inheritable = new->cap_inheritable;
65587 + ncred->cap_permitted = new->cap_permitted;
65588 + ncred->cap_effective = new->cap_effective;
65589 + ncred->cap_bset = new->cap_bset;
65590 +
65591 + if (set_user(ncred)) {
65592 + abort_creds(ncred);
65593 + goto die;
65594 + }
65595 +
65596 + // from doing get_cred on it when queueing this
65597 + put_cred(new);
65598 +
65599 + __commit_creds(ncred);
65600 + return;
65601 +die:
65602 + // from doing get_cred on it when queueing this
65603 + put_cred(new);
65604 + do_group_exit(SIGKILL);
65605 +}
65606 +#endif
65607 +
65608 +int commit_creds(struct cred *new)
65609 +{
65610 +#ifdef CONFIG_GRKERNSEC_SETXID
65611 + int ret;
65612 + int schedule_it = 0;
65613 + struct task_struct *t;
65614 +
65615 + /* we won't get called with tasklist_lock held for writing
65616 + and interrupts disabled as the cred struct in that case is
65617 + init_cred
65618 + */
65619 + if (grsec_enable_setxid && !current_is_single_threaded() &&
65620 + !current_uid() && new->uid) {
65621 + schedule_it = 1;
65622 + }
65623 + ret = __commit_creds(new);
65624 + if (schedule_it) {
65625 + rcu_read_lock();
65626 + read_lock(&tasklist_lock);
65627 + for (t = next_thread(current); t != current;
65628 + t = next_thread(t)) {
65629 + if (t->delayed_cred == NULL) {
65630 + t->delayed_cred = get_cred(new);
65631 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
65632 + set_tsk_need_resched(t);
65633 + }
65634 + }
65635 + read_unlock(&tasklist_lock);
65636 + rcu_read_unlock();
65637 + }
65638 + return ret;
65639 +#else
65640 + return __commit_creds(new);
65641 +#endif
65642 +}
65643 +
65644 EXPORT_SYMBOL(commit_creds);
65645
65646 /**
65647 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
65648 index 7fda904..59f620c 100644
65649 --- a/kernel/debug/debug_core.c
65650 +++ b/kernel/debug/debug_core.c
65651 @@ -119,7 +119,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
65652 */
65653 static atomic_t masters_in_kgdb;
65654 static atomic_t slaves_in_kgdb;
65655 -static atomic_t kgdb_break_tasklet_var;
65656 +static atomic_unchecked_t kgdb_break_tasklet_var;
65657 atomic_t kgdb_setting_breakpoint;
65658
65659 struct task_struct *kgdb_usethread;
65660 @@ -129,7 +129,7 @@ int kgdb_single_step;
65661 static pid_t kgdb_sstep_pid;
65662
65663 /* to keep track of the CPU which is doing the single stepping*/
65664 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
65665 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
65666
65667 /*
65668 * If you are debugging a problem where roundup (the collection of
65669 @@ -537,7 +537,7 @@ return_normal:
65670 * kernel will only try for the value of sstep_tries before
65671 * giving up and continuing on.
65672 */
65673 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
65674 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
65675 (kgdb_info[cpu].task &&
65676 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
65677 atomic_set(&kgdb_active, -1);
65678 @@ -631,8 +631,8 @@ cpu_master_loop:
65679 }
65680
65681 kgdb_restore:
65682 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
65683 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
65684 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
65685 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
65686 if (kgdb_info[sstep_cpu].task)
65687 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
65688 else
65689 @@ -829,18 +829,18 @@ static void kgdb_unregister_callbacks(void)
65690 static void kgdb_tasklet_bpt(unsigned long ing)
65691 {
65692 kgdb_breakpoint();
65693 - atomic_set(&kgdb_break_tasklet_var, 0);
65694 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
65695 }
65696
65697 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
65698
65699 void kgdb_schedule_breakpoint(void)
65700 {
65701 - if (atomic_read(&kgdb_break_tasklet_var) ||
65702 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
65703 atomic_read(&kgdb_active) != -1 ||
65704 atomic_read(&kgdb_setting_breakpoint))
65705 return;
65706 - atomic_inc(&kgdb_break_tasklet_var);
65707 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
65708 tasklet_schedule(&kgdb_tasklet_breakpoint);
65709 }
65710 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
65711 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
65712 index e2ae734..08a4c5c 100644
65713 --- a/kernel/debug/kdb/kdb_main.c
65714 +++ b/kernel/debug/kdb/kdb_main.c
65715 @@ -1980,7 +1980,7 @@ static int kdb_lsmod(int argc, const char **argv)
65716 list_for_each_entry(mod, kdb_modules, list) {
65717
65718 kdb_printf("%-20s%8u 0x%p ", mod->name,
65719 - mod->core_size, (void *)mod);
65720 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
65721 #ifdef CONFIG_MODULE_UNLOAD
65722 kdb_printf("%4ld ", module_refcount(mod));
65723 #endif
65724 @@ -1990,7 +1990,7 @@ static int kdb_lsmod(int argc, const char **argv)
65725 kdb_printf(" (Loading)");
65726 else
65727 kdb_printf(" (Live)");
65728 - kdb_printf(" 0x%p", mod->module_core);
65729 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
65730
65731 #ifdef CONFIG_MODULE_UNLOAD
65732 {
65733 diff --git a/kernel/events/core.c b/kernel/events/core.c
65734 index 1b5c081..c375f83 100644
65735 --- a/kernel/events/core.c
65736 +++ b/kernel/events/core.c
65737 @@ -173,7 +173,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
65738 return 0;
65739 }
65740
65741 -static atomic64_t perf_event_id;
65742 +static atomic64_unchecked_t perf_event_id;
65743
65744 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
65745 enum event_type_t event_type);
65746 @@ -2581,7 +2581,7 @@ static void __perf_event_read(void *info)
65747
65748 static inline u64 perf_event_count(struct perf_event *event)
65749 {
65750 - return local64_read(&event->count) + atomic64_read(&event->child_count);
65751 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
65752 }
65753
65754 static u64 perf_event_read(struct perf_event *event)
65755 @@ -2897,9 +2897,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
65756 mutex_lock(&event->child_mutex);
65757 total += perf_event_read(event);
65758 *enabled += event->total_time_enabled +
65759 - atomic64_read(&event->child_total_time_enabled);
65760 + atomic64_read_unchecked(&event->child_total_time_enabled);
65761 *running += event->total_time_running +
65762 - atomic64_read(&event->child_total_time_running);
65763 + atomic64_read_unchecked(&event->child_total_time_running);
65764
65765 list_for_each_entry(child, &event->child_list, child_list) {
65766 total += perf_event_read(child);
65767 @@ -3306,10 +3306,10 @@ void perf_event_update_userpage(struct perf_event *event)
65768 userpg->offset -= local64_read(&event->hw.prev_count);
65769
65770 userpg->time_enabled = enabled +
65771 - atomic64_read(&event->child_total_time_enabled);
65772 + atomic64_read_unchecked(&event->child_total_time_enabled);
65773
65774 userpg->time_running = running +
65775 - atomic64_read(&event->child_total_time_running);
65776 + atomic64_read_unchecked(&event->child_total_time_running);
65777
65778 barrier();
65779 ++userpg->lock;
65780 @@ -3738,11 +3738,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
65781 values[n++] = perf_event_count(event);
65782 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
65783 values[n++] = enabled +
65784 - atomic64_read(&event->child_total_time_enabled);
65785 + atomic64_read_unchecked(&event->child_total_time_enabled);
65786 }
65787 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
65788 values[n++] = running +
65789 - atomic64_read(&event->child_total_time_running);
65790 + atomic64_read_unchecked(&event->child_total_time_running);
65791 }
65792 if (read_format & PERF_FORMAT_ID)
65793 values[n++] = primary_event_id(event);
65794 @@ -4393,12 +4393,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
65795 * need to add enough zero bytes after the string to handle
65796 * the 64bit alignment we do later.
65797 */
65798 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
65799 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
65800 if (!buf) {
65801 name = strncpy(tmp, "//enomem", sizeof(tmp));
65802 goto got_name;
65803 }
65804 - name = d_path(&file->f_path, buf, PATH_MAX);
65805 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
65806 if (IS_ERR(name)) {
65807 name = strncpy(tmp, "//toolong", sizeof(tmp));
65808 goto got_name;
65809 @@ -5765,7 +5765,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
65810 event->parent = parent_event;
65811
65812 event->ns = get_pid_ns(current->nsproxy->pid_ns);
65813 - event->id = atomic64_inc_return(&perf_event_id);
65814 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
65815
65816 event->state = PERF_EVENT_STATE_INACTIVE;
65817
65818 @@ -6287,10 +6287,10 @@ static void sync_child_event(struct perf_event *child_event,
65819 /*
65820 * Add back the child's count to the parent's count:
65821 */
65822 - atomic64_add(child_val, &parent_event->child_count);
65823 - atomic64_add(child_event->total_time_enabled,
65824 + atomic64_add_unchecked(child_val, &parent_event->child_count);
65825 + atomic64_add_unchecked(child_event->total_time_enabled,
65826 &parent_event->child_total_time_enabled);
65827 - atomic64_add(child_event->total_time_running,
65828 + atomic64_add_unchecked(child_event->total_time_running,
65829 &parent_event->child_total_time_running);
65830
65831 /*
65832 diff --git a/kernel/exit.c b/kernel/exit.c
65833 index 46c8b14..d868958 100644
65834 --- a/kernel/exit.c
65835 +++ b/kernel/exit.c
65836 @@ -58,6 +58,10 @@
65837 #include <asm/pgtable.h>
65838 #include <asm/mmu_context.h>
65839
65840 +#ifdef CONFIG_GRKERNSEC
65841 +extern rwlock_t grsec_exec_file_lock;
65842 +#endif
65843 +
65844 static void exit_mm(struct task_struct * tsk);
65845
65846 static void __unhash_process(struct task_struct *p, bool group_dead)
65847 @@ -169,6 +173,10 @@ void release_task(struct task_struct * p)
65848 struct task_struct *leader;
65849 int zap_leader;
65850 repeat:
65851 +#ifdef CONFIG_NET
65852 + gr_del_task_from_ip_table(p);
65853 +#endif
65854 +
65855 /* don't need to get the RCU readlock here - the process is dead and
65856 * can't be modifying its own credentials. But shut RCU-lockdep up */
65857 rcu_read_lock();
65858 @@ -381,7 +389,7 @@ int allow_signal(int sig)
65859 * know it'll be handled, so that they don't get converted to
65860 * SIGKILL or just silently dropped.
65861 */
65862 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
65863 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
65864 recalc_sigpending();
65865 spin_unlock_irq(&current->sighand->siglock);
65866 return 0;
65867 @@ -417,6 +425,17 @@ void daemonize(const char *name, ...)
65868 vsnprintf(current->comm, sizeof(current->comm), name, args);
65869 va_end(args);
65870
65871 +#ifdef CONFIG_GRKERNSEC
65872 + write_lock(&grsec_exec_file_lock);
65873 + if (current->exec_file) {
65874 + fput(current->exec_file);
65875 + current->exec_file = NULL;
65876 + }
65877 + write_unlock(&grsec_exec_file_lock);
65878 +#endif
65879 +
65880 + gr_set_kernel_label(current);
65881 +
65882 /*
65883 * If we were started as result of loading a module, close all of the
65884 * user space pages. We don't need them, and if we didn't close them
65885 @@ -873,6 +892,8 @@ void do_exit(long code)
65886 struct task_struct *tsk = current;
65887 int group_dead;
65888
65889 + set_fs(USER_DS);
65890 +
65891 profile_task_exit(tsk);
65892
65893 WARN_ON(blk_needs_flush_plug(tsk));
65894 @@ -889,7 +910,6 @@ void do_exit(long code)
65895 * mm_release()->clear_child_tid() from writing to a user-controlled
65896 * kernel address.
65897 */
65898 - set_fs(USER_DS);
65899
65900 ptrace_event(PTRACE_EVENT_EXIT, code);
65901
65902 @@ -950,6 +970,9 @@ void do_exit(long code)
65903 tsk->exit_code = code;
65904 taskstats_exit(tsk, group_dead);
65905
65906 + gr_acl_handle_psacct(tsk, code);
65907 + gr_acl_handle_exit();
65908 +
65909 exit_mm(tsk);
65910
65911 if (group_dead)
65912 @@ -1066,7 +1089,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
65913 * Take down every thread in the group. This is called by fatal signals
65914 * as well as by sys_exit_group (below).
65915 */
65916 -void
65917 +__noreturn void
65918 do_group_exit(int exit_code)
65919 {
65920 struct signal_struct *sig = current->signal;
65921 diff --git a/kernel/fork.c b/kernel/fork.c
65922 index 423d5a4..881923e 100644
65923 --- a/kernel/fork.c
65924 +++ b/kernel/fork.c
65925 @@ -285,7 +285,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
65926 *stackend = STACK_END_MAGIC; /* for overflow detection */
65927
65928 #ifdef CONFIG_CC_STACKPROTECTOR
65929 - tsk->stack_canary = get_random_int();
65930 + tsk->stack_canary = pax_get_random_long();
65931 #endif
65932
65933 /*
65934 @@ -309,13 +309,77 @@ out:
65935 }
65936
65937 #ifdef CONFIG_MMU
65938 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct vm_area_struct *mpnt)
65939 +{
65940 + struct vm_area_struct *tmp;
65941 + unsigned long charge;
65942 + struct mempolicy *pol;
65943 + struct file *file;
65944 +
65945 + charge = 0;
65946 + if (mpnt->vm_flags & VM_ACCOUNT) {
65947 + unsigned long len = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT;
65948 + if (security_vm_enough_memory(len))
65949 + goto fail_nomem;
65950 + charge = len;
65951 + }
65952 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
65953 + if (!tmp)
65954 + goto fail_nomem;
65955 + *tmp = *mpnt;
65956 + tmp->vm_mm = mm;
65957 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
65958 + pol = mpol_dup(vma_policy(mpnt));
65959 + if (IS_ERR(pol))
65960 + goto fail_nomem_policy;
65961 + vma_set_policy(tmp, pol);
65962 + if (anon_vma_fork(tmp, mpnt))
65963 + goto fail_nomem_anon_vma_fork;
65964 + tmp->vm_flags &= ~VM_LOCKED;
65965 + tmp->vm_next = tmp->vm_prev = NULL;
65966 + tmp->vm_mirror = NULL;
65967 + file = tmp->vm_file;
65968 + if (file) {
65969 + struct inode *inode = file->f_path.dentry->d_inode;
65970 + struct address_space *mapping = file->f_mapping;
65971 +
65972 + get_file(file);
65973 + if (tmp->vm_flags & VM_DENYWRITE)
65974 + atomic_dec(&inode->i_writecount);
65975 + mutex_lock(&mapping->i_mmap_mutex);
65976 + if (tmp->vm_flags & VM_SHARED)
65977 + mapping->i_mmap_writable++;
65978 + flush_dcache_mmap_lock(mapping);
65979 + /* insert tmp into the share list, just after mpnt */
65980 + vma_prio_tree_add(tmp, mpnt);
65981 + flush_dcache_mmap_unlock(mapping);
65982 + mutex_unlock(&mapping->i_mmap_mutex);
65983 + }
65984 +
65985 + /*
65986 + * Clear hugetlb-related page reserves for children. This only
65987 + * affects MAP_PRIVATE mappings. Faults generated by the child
65988 + * are not guaranteed to succeed, even if read-only
65989 + */
65990 + if (is_vm_hugetlb_page(tmp))
65991 + reset_vma_resv_huge_pages(tmp);
65992 +
65993 + return tmp;
65994 +
65995 +fail_nomem_anon_vma_fork:
65996 + mpol_put(pol);
65997 +fail_nomem_policy:
65998 + kmem_cache_free(vm_area_cachep, tmp);
65999 +fail_nomem:
66000 + vm_unacct_memory(charge);
66001 + return NULL;
66002 +}
66003 +
66004 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
66005 {
66006 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
66007 struct rb_node **rb_link, *rb_parent;
66008 int retval;
66009 - unsigned long charge;
66010 - struct mempolicy *pol;
66011
66012 down_write(&oldmm->mmap_sem);
66013 flush_cache_dup_mm(oldmm);
66014 @@ -327,8 +391,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
66015 mm->locked_vm = 0;
66016 mm->mmap = NULL;
66017 mm->mmap_cache = NULL;
66018 - mm->free_area_cache = oldmm->mmap_base;
66019 - mm->cached_hole_size = ~0UL;
66020 + mm->free_area_cache = oldmm->free_area_cache;
66021 + mm->cached_hole_size = oldmm->cached_hole_size;
66022 mm->map_count = 0;
66023 cpumask_clear(mm_cpumask(mm));
66024 mm->mm_rb = RB_ROOT;
66025 @@ -344,8 +408,6 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
66026
66027 prev = NULL;
66028 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
66029 - struct file *file;
66030 -
66031 if (mpnt->vm_flags & VM_DONTCOPY) {
66032 long pages = vma_pages(mpnt);
66033 mm->total_vm -= pages;
66034 @@ -353,53 +415,11 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
66035 -pages);
66036 continue;
66037 }
66038 - charge = 0;
66039 - if (mpnt->vm_flags & VM_ACCOUNT) {
66040 - unsigned int len = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT;
66041 - if (security_vm_enough_memory(len))
66042 - goto fail_nomem;
66043 - charge = len;
66044 + tmp = dup_vma(mm, mpnt);
66045 + if (!tmp) {
66046 + retval = -ENOMEM;
66047 + goto out;
66048 }
66049 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
66050 - if (!tmp)
66051 - goto fail_nomem;
66052 - *tmp = *mpnt;
66053 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
66054 - pol = mpol_dup(vma_policy(mpnt));
66055 - retval = PTR_ERR(pol);
66056 - if (IS_ERR(pol))
66057 - goto fail_nomem_policy;
66058 - vma_set_policy(tmp, pol);
66059 - tmp->vm_mm = mm;
66060 - if (anon_vma_fork(tmp, mpnt))
66061 - goto fail_nomem_anon_vma_fork;
66062 - tmp->vm_flags &= ~VM_LOCKED;
66063 - tmp->vm_next = tmp->vm_prev = NULL;
66064 - file = tmp->vm_file;
66065 - if (file) {
66066 - struct inode *inode = file->f_path.dentry->d_inode;
66067 - struct address_space *mapping = file->f_mapping;
66068 -
66069 - get_file(file);
66070 - if (tmp->vm_flags & VM_DENYWRITE)
66071 - atomic_dec(&inode->i_writecount);
66072 - mutex_lock(&mapping->i_mmap_mutex);
66073 - if (tmp->vm_flags & VM_SHARED)
66074 - mapping->i_mmap_writable++;
66075 - flush_dcache_mmap_lock(mapping);
66076 - /* insert tmp into the share list, just after mpnt */
66077 - vma_prio_tree_add(tmp, mpnt);
66078 - flush_dcache_mmap_unlock(mapping);
66079 - mutex_unlock(&mapping->i_mmap_mutex);
66080 - }
66081 -
66082 - /*
66083 - * Clear hugetlb-related page reserves for children. This only
66084 - * affects MAP_PRIVATE mappings. Faults generated by the child
66085 - * are not guaranteed to succeed, even if read-only
66086 - */
66087 - if (is_vm_hugetlb_page(tmp))
66088 - reset_vma_resv_huge_pages(tmp);
66089
66090 /*
66091 * Link in the new vma and copy the page table entries.
66092 @@ -422,6 +442,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
66093 if (retval)
66094 goto out;
66095 }
66096 +
66097 +#ifdef CONFIG_PAX_SEGMEXEC
66098 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
66099 + struct vm_area_struct *mpnt_m;
66100 +
66101 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
66102 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
66103 +
66104 + if (!mpnt->vm_mirror)
66105 + continue;
66106 +
66107 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
66108 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
66109 + mpnt->vm_mirror = mpnt_m;
66110 + } else {
66111 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
66112 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
66113 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
66114 + mpnt->vm_mirror->vm_mirror = mpnt;
66115 + }
66116 + }
66117 + BUG_ON(mpnt_m);
66118 + }
66119 +#endif
66120 +
66121 /* a new mm has just been created */
66122 arch_dup_mmap(oldmm, mm);
66123 retval = 0;
66124 @@ -430,14 +475,6 @@ out:
66125 flush_tlb_mm(oldmm);
66126 up_write(&oldmm->mmap_sem);
66127 return retval;
66128 -fail_nomem_anon_vma_fork:
66129 - mpol_put(pol);
66130 -fail_nomem_policy:
66131 - kmem_cache_free(vm_area_cachep, tmp);
66132 -fail_nomem:
66133 - retval = -ENOMEM;
66134 - vm_unacct_memory(charge);
66135 - goto out;
66136 }
66137
66138 static inline int mm_alloc_pgd(struct mm_struct *mm)
66139 @@ -659,8 +696,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
66140 return ERR_PTR(err);
66141
66142 mm = get_task_mm(task);
66143 - if (mm && mm != current->mm &&
66144 - !ptrace_may_access(task, mode)) {
66145 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
66146 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
66147 mmput(mm);
66148 mm = ERR_PTR(-EACCES);
66149 }
66150 @@ -882,13 +919,14 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
66151 spin_unlock(&fs->lock);
66152 return -EAGAIN;
66153 }
66154 - fs->users++;
66155 + atomic_inc(&fs->users);
66156 spin_unlock(&fs->lock);
66157 return 0;
66158 }
66159 tsk->fs = copy_fs_struct(fs);
66160 if (!tsk->fs)
66161 return -ENOMEM;
66162 + gr_set_chroot_entries(tsk, &tsk->fs->root);
66163 return 0;
66164 }
66165
66166 @@ -1152,6 +1190,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
66167 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
66168 #endif
66169 retval = -EAGAIN;
66170 +
66171 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
66172 +
66173 if (atomic_read(&p->real_cred->user->processes) >=
66174 task_rlimit(p, RLIMIT_NPROC)) {
66175 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
66176 @@ -1307,6 +1348,8 @@ static struct task_struct *copy_process(unsigned long clone_flags,
66177 if (clone_flags & CLONE_THREAD)
66178 p->tgid = current->tgid;
66179
66180 + gr_copy_label(p);
66181 +
66182 p->set_child_tid = (clone_flags & CLONE_CHILD_SETTID) ? child_tidptr : NULL;
66183 /*
66184 * Clear TID on mm_release()?
66185 @@ -1475,6 +1518,8 @@ bad_fork_cleanup_count:
66186 bad_fork_free:
66187 free_task(p);
66188 fork_out:
66189 + gr_log_forkfail(retval);
66190 +
66191 return ERR_PTR(retval);
66192 }
66193
66194 @@ -1575,6 +1620,8 @@ long do_fork(unsigned long clone_flags,
66195 if (clone_flags & CLONE_PARENT_SETTID)
66196 put_user(nr, parent_tidptr);
66197
66198 + gr_handle_brute_check();
66199 +
66200 if (clone_flags & CLONE_VFORK) {
66201 p->vfork_done = &vfork;
66202 init_completion(&vfork);
66203 @@ -1673,7 +1720,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
66204 return 0;
66205
66206 /* don't need lock here; in the worst case we'll do useless copy */
66207 - if (fs->users == 1)
66208 + if (atomic_read(&fs->users) == 1)
66209 return 0;
66210
66211 *new_fsp = copy_fs_struct(fs);
66212 @@ -1762,7 +1809,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
66213 fs = current->fs;
66214 spin_lock(&fs->lock);
66215 current->fs = new_fs;
66216 - if (--fs->users)
66217 + gr_set_chroot_entries(current, &current->fs->root);
66218 + if (atomic_dec_return(&fs->users))
66219 new_fs = NULL;
66220 else
66221 new_fs = fs;
66222 diff --git a/kernel/futex.c b/kernel/futex.c
66223 index 866c9d5..5c5f828 100644
66224 --- a/kernel/futex.c
66225 +++ b/kernel/futex.c
66226 @@ -54,6 +54,7 @@
66227 #include <linux/mount.h>
66228 #include <linux/pagemap.h>
66229 #include <linux/syscalls.h>
66230 +#include <linux/ptrace.h>
66231 #include <linux/signal.h>
66232 #include <linux/export.h>
66233 #include <linux/magic.h>
66234 @@ -239,6 +240,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
66235 struct page *page, *page_head;
66236 int err, ro = 0;
66237
66238 +#ifdef CONFIG_PAX_SEGMEXEC
66239 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
66240 + return -EFAULT;
66241 +#endif
66242 +
66243 /*
66244 * The futex address must be "naturally" aligned.
66245 */
66246 @@ -2721,6 +2727,7 @@ static int __init futex_init(void)
66247 {
66248 u32 curval;
66249 int i;
66250 + mm_segment_t oldfs;
66251
66252 /*
66253 * This will fail and we want it. Some arch implementations do
66254 @@ -2732,8 +2739,11 @@ static int __init futex_init(void)
66255 * implementation, the non-functional ones will return
66256 * -ENOSYS.
66257 */
66258 + oldfs = get_fs();
66259 + set_fs(USER_DS);
66260 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
66261 futex_cmpxchg_enabled = 1;
66262 + set_fs(oldfs);
66263
66264 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
66265 plist_head_init(&futex_queues[i].chain);
66266 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
66267 index 9b22d03..6295b62 100644
66268 --- a/kernel/gcov/base.c
66269 +++ b/kernel/gcov/base.c
66270 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
66271 }
66272
66273 #ifdef CONFIG_MODULES
66274 -static inline int within(void *addr, void *start, unsigned long size)
66275 -{
66276 - return ((addr >= start) && (addr < start + size));
66277 -}
66278 -
66279 /* Update list and generate events when modules are unloaded. */
66280 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
66281 void *data)
66282 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
66283 prev = NULL;
66284 /* Remove entries located in module from linked list. */
66285 for (info = gcov_info_head; info; info = info->next) {
66286 - if (within(info, mod->module_core, mod->core_size)) {
66287 + if (within_module_core_rw((unsigned long)info, mod)) {
66288 if (prev)
66289 prev->next = info->next;
66290 else
66291 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
66292 index ae34bf5..4e2f3d0 100644
66293 --- a/kernel/hrtimer.c
66294 +++ b/kernel/hrtimer.c
66295 @@ -1393,7 +1393,7 @@ void hrtimer_peek_ahead_timers(void)
66296 local_irq_restore(flags);
66297 }
66298
66299 -static void run_hrtimer_softirq(struct softirq_action *h)
66300 +static void run_hrtimer_softirq(void)
66301 {
66302 hrtimer_peek_ahead_timers();
66303 }
66304 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
66305 index 01d3b70..9e4d098 100644
66306 --- a/kernel/jump_label.c
66307 +++ b/kernel/jump_label.c
66308 @@ -55,7 +55,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
66309
66310 size = (((unsigned long)stop - (unsigned long)start)
66311 / sizeof(struct jump_entry));
66312 + pax_open_kernel();
66313 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
66314 + pax_close_kernel();
66315 }
66316
66317 static void jump_label_update(struct jump_label_key *key, int enable);
66318 @@ -340,10 +342,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
66319 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
66320 struct jump_entry *iter;
66321
66322 + pax_open_kernel();
66323 for (iter = iter_start; iter < iter_stop; iter++) {
66324 if (within_module_init(iter->code, mod))
66325 iter->code = 0;
66326 }
66327 + pax_close_kernel();
66328 }
66329
66330 static int
66331 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
66332 index 079f1d3..a407562 100644
66333 --- a/kernel/kallsyms.c
66334 +++ b/kernel/kallsyms.c
66335 @@ -11,6 +11,9 @@
66336 * Changed the compression method from stem compression to "table lookup"
66337 * compression (see scripts/kallsyms.c for a more complete description)
66338 */
66339 +#ifdef CONFIG_GRKERNSEC_HIDESYM
66340 +#define __INCLUDED_BY_HIDESYM 1
66341 +#endif
66342 #include <linux/kallsyms.h>
66343 #include <linux/module.h>
66344 #include <linux/init.h>
66345 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
66346
66347 static inline int is_kernel_inittext(unsigned long addr)
66348 {
66349 + if (system_state != SYSTEM_BOOTING)
66350 + return 0;
66351 +
66352 if (addr >= (unsigned long)_sinittext
66353 && addr <= (unsigned long)_einittext)
66354 return 1;
66355 return 0;
66356 }
66357
66358 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
66359 +#ifdef CONFIG_MODULES
66360 +static inline int is_module_text(unsigned long addr)
66361 +{
66362 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
66363 + return 1;
66364 +
66365 + addr = ktla_ktva(addr);
66366 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
66367 +}
66368 +#else
66369 +static inline int is_module_text(unsigned long addr)
66370 +{
66371 + return 0;
66372 +}
66373 +#endif
66374 +#endif
66375 +
66376 static inline int is_kernel_text(unsigned long addr)
66377 {
66378 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
66379 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
66380
66381 static inline int is_kernel(unsigned long addr)
66382 {
66383 +
66384 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
66385 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
66386 + return 1;
66387 +
66388 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
66389 +#else
66390 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
66391 +#endif
66392 +
66393 return 1;
66394 return in_gate_area_no_mm(addr);
66395 }
66396
66397 static int is_ksym_addr(unsigned long addr)
66398 {
66399 +
66400 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
66401 + if (is_module_text(addr))
66402 + return 0;
66403 +#endif
66404 +
66405 if (all_var)
66406 return is_kernel(addr);
66407
66408 @@ -454,7 +493,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
66409
66410 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
66411 {
66412 - iter->name[0] = '\0';
66413 iter->nameoff = get_symbol_offset(new_pos);
66414 iter->pos = new_pos;
66415 }
66416 @@ -502,6 +540,11 @@ static int s_show(struct seq_file *m, void *p)
66417 {
66418 struct kallsym_iter *iter = m->private;
66419
66420 +#ifdef CONFIG_GRKERNSEC_HIDESYM
66421 + if (current_uid())
66422 + return 0;
66423 +#endif
66424 +
66425 /* Some debugging symbols have no name. Ignore them. */
66426 if (!iter->name[0])
66427 return 0;
66428 @@ -540,7 +583,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
66429 struct kallsym_iter *iter;
66430 int ret;
66431
66432 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
66433 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
66434 if (!iter)
66435 return -ENOMEM;
66436 reset_iter(iter, 0);
66437 diff --git a/kernel/kexec.c b/kernel/kexec.c
66438 index 7b08867..3bac516 100644
66439 --- a/kernel/kexec.c
66440 +++ b/kernel/kexec.c
66441 @@ -1047,7 +1047,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
66442 unsigned long flags)
66443 {
66444 struct compat_kexec_segment in;
66445 - struct kexec_segment out, __user *ksegments;
66446 + struct kexec_segment out;
66447 + struct kexec_segment __user *ksegments;
66448 unsigned long i, result;
66449
66450 /* Don't allow clients that don't understand the native
66451 diff --git a/kernel/kmod.c b/kernel/kmod.c
66452 index a3a46cb..f2e42f8 100644
66453 --- a/kernel/kmod.c
66454 +++ b/kernel/kmod.c
66455 @@ -75,13 +75,12 @@ char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe";
66456 * If module auto-loading support is disabled then this function
66457 * becomes a no-operation.
66458 */
66459 -int __request_module(bool wait, const char *fmt, ...)
66460 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
66461 {
66462 - va_list args;
66463 char module_name[MODULE_NAME_LEN];
66464 unsigned int max_modprobes;
66465 int ret;
66466 - char *argv[] = { modprobe_path, "-q", "--", module_name, NULL };
66467 + char *argv[] = { modprobe_path, "-q", "--", module_name, module_param, NULL };
66468 static char *envp[] = { "HOME=/",
66469 "TERM=linux",
66470 "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
66471 @@ -90,9 +89,7 @@ int __request_module(bool wait, const char *fmt, ...)
66472 #define MAX_KMOD_CONCURRENT 50 /* Completely arbitrary value - KAO */
66473 static int kmod_loop_msg;
66474
66475 - va_start(args, fmt);
66476 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
66477 - va_end(args);
66478 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
66479 if (ret >= MODULE_NAME_LEN)
66480 return -ENAMETOOLONG;
66481
66482 @@ -100,6 +97,20 @@ int __request_module(bool wait, const char *fmt, ...)
66483 if (ret)
66484 return ret;
66485
66486 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
66487 + if (!current_uid()) {
66488 + /* hack to workaround consolekit/udisks stupidity */
66489 + read_lock(&tasklist_lock);
66490 + if (!strcmp(current->comm, "mount") &&
66491 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
66492 + read_unlock(&tasklist_lock);
66493 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
66494 + return -EPERM;
66495 + }
66496 + read_unlock(&tasklist_lock);
66497 + }
66498 +#endif
66499 +
66500 /* If modprobe needs a service that is in a module, we get a recursive
66501 * loop. Limit the number of running kmod threads to max_threads/2 or
66502 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
66503 @@ -135,6 +146,47 @@ int __request_module(bool wait, const char *fmt, ...)
66504 atomic_dec(&kmod_concurrent);
66505 return ret;
66506 }
66507 +
66508 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
66509 +{
66510 + va_list args;
66511 + int ret;
66512 +
66513 + va_start(args, fmt);
66514 + ret = ____request_module(wait, module_param, fmt, args);
66515 + va_end(args);
66516 +
66517 + return ret;
66518 +}
66519 +
66520 +int __request_module(bool wait, const char *fmt, ...)
66521 +{
66522 + va_list args;
66523 + int ret;
66524 +
66525 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
66526 + if (current_uid()) {
66527 + char module_param[MODULE_NAME_LEN];
66528 +
66529 + memset(module_param, 0, sizeof(module_param));
66530 +
66531 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", current_uid());
66532 +
66533 + va_start(args, fmt);
66534 + ret = ____request_module(wait, module_param, fmt, args);
66535 + va_end(args);
66536 +
66537 + return ret;
66538 + }
66539 +#endif
66540 +
66541 + va_start(args, fmt);
66542 + ret = ____request_module(wait, NULL, fmt, args);
66543 + va_end(args);
66544 +
66545 + return ret;
66546 +}
66547 +
66548 EXPORT_SYMBOL(__request_module);
66549 #endif /* CONFIG_MODULES */
66550
66551 @@ -224,7 +276,7 @@ static int wait_for_helper(void *data)
66552 *
66553 * Thus the __user pointer cast is valid here.
66554 */
66555 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
66556 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
66557
66558 /*
66559 * If ret is 0, either ____call_usermodehelper failed and the
66560 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
66561 index c62b854..cb67968 100644
66562 --- a/kernel/kprobes.c
66563 +++ b/kernel/kprobes.c
66564 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
66565 * kernel image and loaded module images reside. This is required
66566 * so x86_64 can correctly handle the %rip-relative fixups.
66567 */
66568 - kip->insns = module_alloc(PAGE_SIZE);
66569 + kip->insns = module_alloc_exec(PAGE_SIZE);
66570 if (!kip->insns) {
66571 kfree(kip);
66572 return NULL;
66573 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
66574 */
66575 if (!list_is_singular(&kip->list)) {
66576 list_del(&kip->list);
66577 - module_free(NULL, kip->insns);
66578 + module_free_exec(NULL, kip->insns);
66579 kfree(kip);
66580 }
66581 return 1;
66582 @@ -1955,7 +1955,7 @@ static int __init init_kprobes(void)
66583 {
66584 int i, err = 0;
66585 unsigned long offset = 0, size = 0;
66586 - char *modname, namebuf[128];
66587 + char *modname, namebuf[KSYM_NAME_LEN];
66588 const char *symbol_name;
66589 void *addr;
66590 struct kprobe_blackpoint *kb;
66591 @@ -2081,7 +2081,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
66592 const char *sym = NULL;
66593 unsigned int i = *(loff_t *) v;
66594 unsigned long offset = 0;
66595 - char *modname, namebuf[128];
66596 + char *modname, namebuf[KSYM_NAME_LEN];
66597
66598 head = &kprobe_table[i];
66599 preempt_disable();
66600 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
66601 index 4e316e1..5501eef 100644
66602 --- a/kernel/ksysfs.c
66603 +++ b/kernel/ksysfs.c
66604 @@ -47,6 +47,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
66605 {
66606 if (count+1 > UEVENT_HELPER_PATH_LEN)
66607 return -ENOENT;
66608 + if (!capable(CAP_SYS_ADMIN))
66609 + return -EPERM;
66610 memcpy(uevent_helper, buf, count);
66611 uevent_helper[count] = '\0';
66612 if (count && uevent_helper[count-1] == '\n')
66613 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
66614 index 8889f7d..95319b7 100644
66615 --- a/kernel/lockdep.c
66616 +++ b/kernel/lockdep.c
66617 @@ -590,6 +590,10 @@ static int static_obj(void *obj)
66618 end = (unsigned long) &_end,
66619 addr = (unsigned long) obj;
66620
66621 +#ifdef CONFIG_PAX_KERNEXEC
66622 + start = ktla_ktva(start);
66623 +#endif
66624 +
66625 /*
66626 * static variable?
66627 */
66628 @@ -730,6 +734,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
66629 if (!static_obj(lock->key)) {
66630 debug_locks_off();
66631 printk("INFO: trying to register non-static key.\n");
66632 + printk("lock:%pS key:%pS.\n", lock, lock->key);
66633 printk("the code is fine but needs lockdep annotation.\n");
66634 printk("turning off the locking correctness validator.\n");
66635 dump_stack();
66636 @@ -3042,7 +3047,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
66637 if (!class)
66638 return 0;
66639 }
66640 - atomic_inc((atomic_t *)&class->ops);
66641 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
66642 if (very_verbose(class)) {
66643 printk("\nacquire class [%p] %s", class->key, class->name);
66644 if (class->name_version > 1)
66645 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
66646 index 91c32a0..b2c71c5 100644
66647 --- a/kernel/lockdep_proc.c
66648 +++ b/kernel/lockdep_proc.c
66649 @@ -39,7 +39,7 @@ static void l_stop(struct seq_file *m, void *v)
66650
66651 static void print_name(struct seq_file *m, struct lock_class *class)
66652 {
66653 - char str[128];
66654 + char str[KSYM_NAME_LEN];
66655 const char *name = class->name;
66656
66657 if (!name) {
66658 diff --git a/kernel/module.c b/kernel/module.c
66659 index 3d56b6f..2a22bd0 100644
66660 --- a/kernel/module.c
66661 +++ b/kernel/module.c
66662 @@ -58,6 +58,7 @@
66663 #include <linux/jump_label.h>
66664 #include <linux/pfn.h>
66665 #include <linux/bsearch.h>
66666 +#include <linux/grsecurity.h>
66667
66668 #define CREATE_TRACE_POINTS
66669 #include <trace/events/module.h>
66670 @@ -113,7 +114,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
66671
66672 /* Bounds of module allocation, for speeding __module_address.
66673 * Protected by module_mutex. */
66674 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
66675 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
66676 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
66677
66678 int register_module_notifier(struct notifier_block * nb)
66679 {
66680 @@ -277,7 +279,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
66681 return true;
66682
66683 list_for_each_entry_rcu(mod, &modules, list) {
66684 - struct symsearch arr[] = {
66685 + struct symsearch modarr[] = {
66686 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
66687 NOT_GPL_ONLY, false },
66688 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
66689 @@ -299,7 +301,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
66690 #endif
66691 };
66692
66693 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
66694 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
66695 return true;
66696 }
66697 return false;
66698 @@ -431,7 +433,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
66699 static int percpu_modalloc(struct module *mod,
66700 unsigned long size, unsigned long align)
66701 {
66702 - if (align > PAGE_SIZE) {
66703 + if (align-1 >= PAGE_SIZE) {
66704 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
66705 mod->name, align, PAGE_SIZE);
66706 align = PAGE_SIZE;
66707 @@ -1001,7 +1003,7 @@ struct module_attribute module_uevent =
66708 static ssize_t show_coresize(struct module_attribute *mattr,
66709 struct module_kobject *mk, char *buffer)
66710 {
66711 - return sprintf(buffer, "%u\n", mk->mod->core_size);
66712 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
66713 }
66714
66715 static struct module_attribute modinfo_coresize =
66716 @@ -1010,7 +1012,7 @@ static struct module_attribute modinfo_coresize =
66717 static ssize_t show_initsize(struct module_attribute *mattr,
66718 struct module_kobject *mk, char *buffer)
66719 {
66720 - return sprintf(buffer, "%u\n", mk->mod->init_size);
66721 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
66722 }
66723
66724 static struct module_attribute modinfo_initsize =
66725 @@ -1224,7 +1226,7 @@ resolve_symbol_wait(struct module *mod,
66726 */
66727 #ifdef CONFIG_SYSFS
66728
66729 -#ifdef CONFIG_KALLSYMS
66730 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
66731 static inline bool sect_empty(const Elf_Shdr *sect)
66732 {
66733 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
66734 @@ -1690,21 +1692,21 @@ static void set_section_ro_nx(void *base,
66735
66736 static void unset_module_core_ro_nx(struct module *mod)
66737 {
66738 - set_page_attributes(mod->module_core + mod->core_text_size,
66739 - mod->module_core + mod->core_size,
66740 + set_page_attributes(mod->module_core_rw,
66741 + mod->module_core_rw + mod->core_size_rw,
66742 set_memory_x);
66743 - set_page_attributes(mod->module_core,
66744 - mod->module_core + mod->core_ro_size,
66745 + set_page_attributes(mod->module_core_rx,
66746 + mod->module_core_rx + mod->core_size_rx,
66747 set_memory_rw);
66748 }
66749
66750 static void unset_module_init_ro_nx(struct module *mod)
66751 {
66752 - set_page_attributes(mod->module_init + mod->init_text_size,
66753 - mod->module_init + mod->init_size,
66754 + set_page_attributes(mod->module_init_rw,
66755 + mod->module_init_rw + mod->init_size_rw,
66756 set_memory_x);
66757 - set_page_attributes(mod->module_init,
66758 - mod->module_init + mod->init_ro_size,
66759 + set_page_attributes(mod->module_init_rx,
66760 + mod->module_init_rx + mod->init_size_rx,
66761 set_memory_rw);
66762 }
66763
66764 @@ -1715,14 +1717,14 @@ void set_all_modules_text_rw(void)
66765
66766 mutex_lock(&module_mutex);
66767 list_for_each_entry_rcu(mod, &modules, list) {
66768 - if ((mod->module_core) && (mod->core_text_size)) {
66769 - set_page_attributes(mod->module_core,
66770 - mod->module_core + mod->core_text_size,
66771 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
66772 + set_page_attributes(mod->module_core_rx,
66773 + mod->module_core_rx + mod->core_size_rx,
66774 set_memory_rw);
66775 }
66776 - if ((mod->module_init) && (mod->init_text_size)) {
66777 - set_page_attributes(mod->module_init,
66778 - mod->module_init + mod->init_text_size,
66779 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
66780 + set_page_attributes(mod->module_init_rx,
66781 + mod->module_init_rx + mod->init_size_rx,
66782 set_memory_rw);
66783 }
66784 }
66785 @@ -1736,14 +1738,14 @@ void set_all_modules_text_ro(void)
66786
66787 mutex_lock(&module_mutex);
66788 list_for_each_entry_rcu(mod, &modules, list) {
66789 - if ((mod->module_core) && (mod->core_text_size)) {
66790 - set_page_attributes(mod->module_core,
66791 - mod->module_core + mod->core_text_size,
66792 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
66793 + set_page_attributes(mod->module_core_rx,
66794 + mod->module_core_rx + mod->core_size_rx,
66795 set_memory_ro);
66796 }
66797 - if ((mod->module_init) && (mod->init_text_size)) {
66798 - set_page_attributes(mod->module_init,
66799 - mod->module_init + mod->init_text_size,
66800 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
66801 + set_page_attributes(mod->module_init_rx,
66802 + mod->module_init_rx + mod->init_size_rx,
66803 set_memory_ro);
66804 }
66805 }
66806 @@ -1789,16 +1791,19 @@ static void free_module(struct module *mod)
66807
66808 /* This may be NULL, but that's OK */
66809 unset_module_init_ro_nx(mod);
66810 - module_free(mod, mod->module_init);
66811 + module_free(mod, mod->module_init_rw);
66812 + module_free_exec(mod, mod->module_init_rx);
66813 kfree(mod->args);
66814 percpu_modfree(mod);
66815
66816 /* Free lock-classes: */
66817 - lockdep_free_key_range(mod->module_core, mod->core_size);
66818 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
66819 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
66820
66821 /* Finally, free the core (containing the module structure) */
66822 unset_module_core_ro_nx(mod);
66823 - module_free(mod, mod->module_core);
66824 + module_free_exec(mod, mod->module_core_rx);
66825 + module_free(mod, mod->module_core_rw);
66826
66827 #ifdef CONFIG_MPU
66828 update_protections(current->mm);
66829 @@ -1867,10 +1872,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
66830 unsigned int i;
66831 int ret = 0;
66832 const struct kernel_symbol *ksym;
66833 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
66834 + int is_fs_load = 0;
66835 + int register_filesystem_found = 0;
66836 + char *p;
66837 +
66838 + p = strstr(mod->args, "grsec_modharden_fs");
66839 + if (p) {
66840 + char *endptr = p + strlen("grsec_modharden_fs");
66841 + /* copy \0 as well */
66842 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
66843 + is_fs_load = 1;
66844 + }
66845 +#endif
66846
66847 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
66848 const char *name = info->strtab + sym[i].st_name;
66849
66850 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
66851 + /* it's a real shame this will never get ripped and copied
66852 + upstream! ;(
66853 + */
66854 + if (is_fs_load && !strcmp(name, "register_filesystem"))
66855 + register_filesystem_found = 1;
66856 +#endif
66857 +
66858 switch (sym[i].st_shndx) {
66859 case SHN_COMMON:
66860 /* We compiled with -fno-common. These are not
66861 @@ -1891,7 +1917,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
66862 ksym = resolve_symbol_wait(mod, info, name);
66863 /* Ok if resolved. */
66864 if (ksym && !IS_ERR(ksym)) {
66865 + pax_open_kernel();
66866 sym[i].st_value = ksym->value;
66867 + pax_close_kernel();
66868 break;
66869 }
66870
66871 @@ -1910,11 +1938,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
66872 secbase = (unsigned long)mod_percpu(mod);
66873 else
66874 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
66875 + pax_open_kernel();
66876 sym[i].st_value += secbase;
66877 + pax_close_kernel();
66878 break;
66879 }
66880 }
66881
66882 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
66883 + if (is_fs_load && !register_filesystem_found) {
66884 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
66885 + ret = -EPERM;
66886 + }
66887 +#endif
66888 +
66889 return ret;
66890 }
66891
66892 @@ -2018,22 +2055,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
66893 || s->sh_entsize != ~0UL
66894 || strstarts(sname, ".init"))
66895 continue;
66896 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
66897 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
66898 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
66899 + else
66900 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
66901 pr_debug("\t%s\n", sname);
66902 }
66903 - switch (m) {
66904 - case 0: /* executable */
66905 - mod->core_size = debug_align(mod->core_size);
66906 - mod->core_text_size = mod->core_size;
66907 - break;
66908 - case 1: /* RO: text and ro-data */
66909 - mod->core_size = debug_align(mod->core_size);
66910 - mod->core_ro_size = mod->core_size;
66911 - break;
66912 - case 3: /* whole core */
66913 - mod->core_size = debug_align(mod->core_size);
66914 - break;
66915 - }
66916 }
66917
66918 pr_debug("Init section allocation order:\n");
66919 @@ -2047,23 +2074,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
66920 || s->sh_entsize != ~0UL
66921 || !strstarts(sname, ".init"))
66922 continue;
66923 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
66924 - | INIT_OFFSET_MASK);
66925 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
66926 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
66927 + else
66928 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
66929 + s->sh_entsize |= INIT_OFFSET_MASK;
66930 pr_debug("\t%s\n", sname);
66931 }
66932 - switch (m) {
66933 - case 0: /* executable */
66934 - mod->init_size = debug_align(mod->init_size);
66935 - mod->init_text_size = mod->init_size;
66936 - break;
66937 - case 1: /* RO: text and ro-data */
66938 - mod->init_size = debug_align(mod->init_size);
66939 - mod->init_ro_size = mod->init_size;
66940 - break;
66941 - case 3: /* whole init */
66942 - mod->init_size = debug_align(mod->init_size);
66943 - break;
66944 - }
66945 }
66946 }
66947
66948 @@ -2235,7 +2252,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
66949
66950 /* Put symbol section at end of init part of module. */
66951 symsect->sh_flags |= SHF_ALLOC;
66952 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
66953 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
66954 info->index.sym) | INIT_OFFSET_MASK;
66955 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
66956
66957 @@ -2250,13 +2267,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
66958 }
66959
66960 /* Append room for core symbols at end of core part. */
66961 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
66962 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
66963 - mod->core_size += strtab_size;
66964 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
66965 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
66966 + mod->core_size_rx += strtab_size;
66967
66968 /* Put string table section at end of init part of module. */
66969 strsect->sh_flags |= SHF_ALLOC;
66970 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
66971 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
66972 info->index.str) | INIT_OFFSET_MASK;
66973 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
66974 }
66975 @@ -2274,12 +2291,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
66976 /* Make sure we get permanent strtab: don't use info->strtab. */
66977 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
66978
66979 + pax_open_kernel();
66980 +
66981 /* Set types up while we still have access to sections. */
66982 for (i = 0; i < mod->num_symtab; i++)
66983 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
66984
66985 - mod->core_symtab = dst = mod->module_core + info->symoffs;
66986 - mod->core_strtab = s = mod->module_core + info->stroffs;
66987 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
66988 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
66989 src = mod->symtab;
66990 *dst = *src;
66991 *s++ = 0;
66992 @@ -2292,6 +2311,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
66993 s += strlcpy(s, &mod->strtab[src->st_name], KSYM_NAME_LEN) + 1;
66994 }
66995 mod->core_num_syms = ndst;
66996 +
66997 + pax_close_kernel();
66998 }
66999 #else
67000 static inline void layout_symtab(struct module *mod, struct load_info *info)
67001 @@ -2325,17 +2346,33 @@ void * __weak module_alloc(unsigned long size)
67002 return size == 0 ? NULL : vmalloc_exec(size);
67003 }
67004
67005 -static void *module_alloc_update_bounds(unsigned long size)
67006 +static void *module_alloc_update_bounds_rw(unsigned long size)
67007 {
67008 void *ret = module_alloc(size);
67009
67010 if (ret) {
67011 mutex_lock(&module_mutex);
67012 /* Update module bounds. */
67013 - if ((unsigned long)ret < module_addr_min)
67014 - module_addr_min = (unsigned long)ret;
67015 - if ((unsigned long)ret + size > module_addr_max)
67016 - module_addr_max = (unsigned long)ret + size;
67017 + if ((unsigned long)ret < module_addr_min_rw)
67018 + module_addr_min_rw = (unsigned long)ret;
67019 + if ((unsigned long)ret + size > module_addr_max_rw)
67020 + module_addr_max_rw = (unsigned long)ret + size;
67021 + mutex_unlock(&module_mutex);
67022 + }
67023 + return ret;
67024 +}
67025 +
67026 +static void *module_alloc_update_bounds_rx(unsigned long size)
67027 +{
67028 + void *ret = module_alloc_exec(size);
67029 +
67030 + if (ret) {
67031 + mutex_lock(&module_mutex);
67032 + /* Update module bounds. */
67033 + if ((unsigned long)ret < module_addr_min_rx)
67034 + module_addr_min_rx = (unsigned long)ret;
67035 + if ((unsigned long)ret + size > module_addr_max_rx)
67036 + module_addr_max_rx = (unsigned long)ret + size;
67037 mutex_unlock(&module_mutex);
67038 }
67039 return ret;
67040 @@ -2512,8 +2549,14 @@ static struct module *setup_load_info(struct load_info *info)
67041 static int check_modinfo(struct module *mod, struct load_info *info)
67042 {
67043 const char *modmagic = get_modinfo(info, "vermagic");
67044 + const char *license = get_modinfo(info, "license");
67045 int err;
67046
67047 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
67048 + if (!license || !license_is_gpl_compatible(license))
67049 + return -ENOEXEC;
67050 +#endif
67051 +
67052 /* This is allowed: modprobe --force will invalidate it. */
67053 if (!modmagic) {
67054 err = try_to_force_load(mod, "bad vermagic");
67055 @@ -2536,7 +2579,7 @@ static int check_modinfo(struct module *mod, struct load_info *info)
67056 }
67057
67058 /* Set up license info based on the info section */
67059 - set_license(mod, get_modinfo(info, "license"));
67060 + set_license(mod, license);
67061
67062 return 0;
67063 }
67064 @@ -2630,7 +2673,7 @@ static int move_module(struct module *mod, struct load_info *info)
67065 void *ptr;
67066
67067 /* Do the allocs. */
67068 - ptr = module_alloc_update_bounds(mod->core_size);
67069 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
67070 /*
67071 * The pointer to this block is stored in the module structure
67072 * which is inside the block. Just mark it as not being a
67073 @@ -2640,23 +2683,50 @@ static int move_module(struct module *mod, struct load_info *info)
67074 if (!ptr)
67075 return -ENOMEM;
67076
67077 - memset(ptr, 0, mod->core_size);
67078 - mod->module_core = ptr;
67079 + memset(ptr, 0, mod->core_size_rw);
67080 + mod->module_core_rw = ptr;
67081
67082 - ptr = module_alloc_update_bounds(mod->init_size);
67083 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
67084 /*
67085 * The pointer to this block is stored in the module structure
67086 * which is inside the block. This block doesn't need to be
67087 * scanned as it contains data and code that will be freed
67088 * after the module is initialized.
67089 */
67090 - kmemleak_ignore(ptr);
67091 - if (!ptr && mod->init_size) {
67092 - module_free(mod, mod->module_core);
67093 + kmemleak_not_leak(ptr);
67094 + if (!ptr && mod->init_size_rw) {
67095 + module_free(mod, mod->module_core_rw);
67096 return -ENOMEM;
67097 }
67098 - memset(ptr, 0, mod->init_size);
67099 - mod->module_init = ptr;
67100 + memset(ptr, 0, mod->init_size_rw);
67101 + mod->module_init_rw = ptr;
67102 +
67103 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
67104 + kmemleak_not_leak(ptr);
67105 + if (!ptr) {
67106 + module_free(mod, mod->module_init_rw);
67107 + module_free(mod, mod->module_core_rw);
67108 + return -ENOMEM;
67109 + }
67110 +
67111 + pax_open_kernel();
67112 + memset(ptr, 0, mod->core_size_rx);
67113 + pax_close_kernel();
67114 + mod->module_core_rx = ptr;
67115 +
67116 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
67117 + kmemleak_not_leak(ptr);
67118 + if (!ptr && mod->init_size_rx) {
67119 + module_free_exec(mod, mod->module_core_rx);
67120 + module_free(mod, mod->module_init_rw);
67121 + module_free(mod, mod->module_core_rw);
67122 + return -ENOMEM;
67123 + }
67124 +
67125 + pax_open_kernel();
67126 + memset(ptr, 0, mod->init_size_rx);
67127 + pax_close_kernel();
67128 + mod->module_init_rx = ptr;
67129
67130 /* Transfer each section which specifies SHF_ALLOC */
67131 pr_debug("final section addresses:\n");
67132 @@ -2667,16 +2737,45 @@ static int move_module(struct module *mod, struct load_info *info)
67133 if (!(shdr->sh_flags & SHF_ALLOC))
67134 continue;
67135
67136 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
67137 - dest = mod->module_init
67138 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
67139 - else
67140 - dest = mod->module_core + shdr->sh_entsize;
67141 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
67142 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
67143 + dest = mod->module_init_rw
67144 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
67145 + else
67146 + dest = mod->module_init_rx
67147 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
67148 + } else {
67149 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
67150 + dest = mod->module_core_rw + shdr->sh_entsize;
67151 + else
67152 + dest = mod->module_core_rx + shdr->sh_entsize;
67153 + }
67154 +
67155 + if (shdr->sh_type != SHT_NOBITS) {
67156 +
67157 +#ifdef CONFIG_PAX_KERNEXEC
67158 +#ifdef CONFIG_X86_64
67159 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
67160 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
67161 +#endif
67162 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
67163 + pax_open_kernel();
67164 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
67165 + pax_close_kernel();
67166 + } else
67167 +#endif
67168
67169 - if (shdr->sh_type != SHT_NOBITS)
67170 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
67171 + }
67172 /* Update sh_addr to point to copy in image. */
67173 - shdr->sh_addr = (unsigned long)dest;
67174 +
67175 +#ifdef CONFIG_PAX_KERNEXEC
67176 + if (shdr->sh_flags & SHF_EXECINSTR)
67177 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
67178 + else
67179 +#endif
67180 +
67181 + shdr->sh_addr = (unsigned long)dest;
67182 pr_debug("\t0x%lx %s\n",
67183 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
67184 }
67185 @@ -2727,12 +2826,12 @@ static void flush_module_icache(const struct module *mod)
67186 * Do it before processing of module parameters, so the module
67187 * can provide parameter accessor functions of its own.
67188 */
67189 - if (mod->module_init)
67190 - flush_icache_range((unsigned long)mod->module_init,
67191 - (unsigned long)mod->module_init
67192 - + mod->init_size);
67193 - flush_icache_range((unsigned long)mod->module_core,
67194 - (unsigned long)mod->module_core + mod->core_size);
67195 + if (mod->module_init_rx)
67196 + flush_icache_range((unsigned long)mod->module_init_rx,
67197 + (unsigned long)mod->module_init_rx
67198 + + mod->init_size_rx);
67199 + flush_icache_range((unsigned long)mod->module_core_rx,
67200 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
67201
67202 set_fs(old_fs);
67203 }
67204 @@ -2802,8 +2901,10 @@ out:
67205 static void module_deallocate(struct module *mod, struct load_info *info)
67206 {
67207 percpu_modfree(mod);
67208 - module_free(mod, mod->module_init);
67209 - module_free(mod, mod->module_core);
67210 + module_free_exec(mod, mod->module_init_rx);
67211 + module_free_exec(mod, mod->module_core_rx);
67212 + module_free(mod, mod->module_init_rw);
67213 + module_free(mod, mod->module_core_rw);
67214 }
67215
67216 int __weak module_finalize(const Elf_Ehdr *hdr,
67217 @@ -2867,9 +2968,38 @@ static struct module *load_module(void __user *umod,
67218 if (err)
67219 goto free_unload;
67220
67221 + /* Now copy in args */
67222 + mod->args = strndup_user(uargs, ~0UL >> 1);
67223 + if (IS_ERR(mod->args)) {
67224 + err = PTR_ERR(mod->args);
67225 + goto free_unload;
67226 + }
67227 +
67228 /* Set up MODINFO_ATTR fields */
67229 setup_modinfo(mod, &info);
67230
67231 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
67232 + {
67233 + char *p, *p2;
67234 +
67235 + if (strstr(mod->args, "grsec_modharden_netdev")) {
67236 + 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);
67237 + err = -EPERM;
67238 + goto free_modinfo;
67239 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
67240 + p += strlen("grsec_modharden_normal");
67241 + p2 = strstr(p, "_");
67242 + if (p2) {
67243 + *p2 = '\0';
67244 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
67245 + *p2 = '_';
67246 + }
67247 + err = -EPERM;
67248 + goto free_modinfo;
67249 + }
67250 + }
67251 +#endif
67252 +
67253 /* Fix up syms, so that st_value is a pointer to location. */
67254 err = simplify_symbols(mod, &info);
67255 if (err < 0)
67256 @@ -2885,13 +3015,6 @@ static struct module *load_module(void __user *umod,
67257
67258 flush_module_icache(mod);
67259
67260 - /* Now copy in args */
67261 - mod->args = strndup_user(uargs, ~0UL >> 1);
67262 - if (IS_ERR(mod->args)) {
67263 - err = PTR_ERR(mod->args);
67264 - goto free_arch_cleanup;
67265 - }
67266 -
67267 /* Mark state as coming so strong_try_module_get() ignores us. */
67268 mod->state = MODULE_STATE_COMING;
67269
67270 @@ -2948,11 +3071,10 @@ static struct module *load_module(void __user *umod,
67271 unlock:
67272 mutex_unlock(&module_mutex);
67273 synchronize_sched();
67274 - kfree(mod->args);
67275 - free_arch_cleanup:
67276 module_arch_cleanup(mod);
67277 free_modinfo:
67278 free_modinfo(mod);
67279 + kfree(mod->args);
67280 free_unload:
67281 module_unload_free(mod);
67282 free_module:
67283 @@ -2993,16 +3115,16 @@ SYSCALL_DEFINE3(init_module, void __user *, umod,
67284 MODULE_STATE_COMING, mod);
67285
67286 /* Set RO and NX regions for core */
67287 - set_section_ro_nx(mod->module_core,
67288 - mod->core_text_size,
67289 - mod->core_ro_size,
67290 - mod->core_size);
67291 + set_section_ro_nx(mod->module_core_rx,
67292 + mod->core_size_rx,
67293 + mod->core_size_rx,
67294 + mod->core_size_rx);
67295
67296 /* Set RO and NX regions for init */
67297 - set_section_ro_nx(mod->module_init,
67298 - mod->init_text_size,
67299 - mod->init_ro_size,
67300 - mod->init_size);
67301 + set_section_ro_nx(mod->module_init_rx,
67302 + mod->init_size_rx,
67303 + mod->init_size_rx,
67304 + mod->init_size_rx);
67305
67306 do_mod_ctors(mod);
67307 /* Start the module */
67308 @@ -3048,11 +3170,12 @@ SYSCALL_DEFINE3(init_module, void __user *, umod,
67309 mod->strtab = mod->core_strtab;
67310 #endif
67311 unset_module_init_ro_nx(mod);
67312 - module_free(mod, mod->module_init);
67313 - mod->module_init = NULL;
67314 - mod->init_size = 0;
67315 - mod->init_ro_size = 0;
67316 - mod->init_text_size = 0;
67317 + module_free(mod, mod->module_init_rw);
67318 + module_free_exec(mod, mod->module_init_rx);
67319 + mod->module_init_rw = NULL;
67320 + mod->module_init_rx = NULL;
67321 + mod->init_size_rw = 0;
67322 + mod->init_size_rx = 0;
67323 mutex_unlock(&module_mutex);
67324
67325 return 0;
67326 @@ -3083,10 +3206,16 @@ static const char *get_ksymbol(struct module *mod,
67327 unsigned long nextval;
67328
67329 /* At worse, next value is at end of module */
67330 - if (within_module_init(addr, mod))
67331 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
67332 + if (within_module_init_rx(addr, mod))
67333 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
67334 + else if (within_module_init_rw(addr, mod))
67335 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
67336 + else if (within_module_core_rx(addr, mod))
67337 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
67338 + else if (within_module_core_rw(addr, mod))
67339 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
67340 else
67341 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
67342 + return NULL;
67343
67344 /* Scan for closest preceding symbol, and next symbol. (ELF
67345 starts real symbols at 1). */
67346 @@ -3321,7 +3450,7 @@ static int m_show(struct seq_file *m, void *p)
67347 char buf[8];
67348
67349 seq_printf(m, "%s %u",
67350 - mod->name, mod->init_size + mod->core_size);
67351 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
67352 print_unload_info(m, mod);
67353
67354 /* Informative for users. */
67355 @@ -3330,7 +3459,7 @@ static int m_show(struct seq_file *m, void *p)
67356 mod->state == MODULE_STATE_COMING ? "Loading":
67357 "Live");
67358 /* Used by oprofile and other similar tools. */
67359 - seq_printf(m, " 0x%pK", mod->module_core);
67360 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
67361
67362 /* Taints info */
67363 if (mod->taints)
67364 @@ -3366,7 +3495,17 @@ static const struct file_operations proc_modules_operations = {
67365
67366 static int __init proc_modules_init(void)
67367 {
67368 +#ifndef CONFIG_GRKERNSEC_HIDESYM
67369 +#ifdef CONFIG_GRKERNSEC_PROC_USER
67370 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
67371 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
67372 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
67373 +#else
67374 proc_create("modules", 0, NULL, &proc_modules_operations);
67375 +#endif
67376 +#else
67377 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
67378 +#endif
67379 return 0;
67380 }
67381 module_init(proc_modules_init);
67382 @@ -3425,12 +3564,12 @@ struct module *__module_address(unsigned long addr)
67383 {
67384 struct module *mod;
67385
67386 - if (addr < module_addr_min || addr > module_addr_max)
67387 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
67388 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
67389 return NULL;
67390
67391 list_for_each_entry_rcu(mod, &modules, list)
67392 - if (within_module_core(addr, mod)
67393 - || within_module_init(addr, mod))
67394 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
67395 return mod;
67396 return NULL;
67397 }
67398 @@ -3464,11 +3603,20 @@ bool is_module_text_address(unsigned long addr)
67399 */
67400 struct module *__module_text_address(unsigned long addr)
67401 {
67402 - struct module *mod = __module_address(addr);
67403 + struct module *mod;
67404 +
67405 +#ifdef CONFIG_X86_32
67406 + addr = ktla_ktva(addr);
67407 +#endif
67408 +
67409 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
67410 + return NULL;
67411 +
67412 + mod = __module_address(addr);
67413 +
67414 if (mod) {
67415 /* Make sure it's within the text section. */
67416 - if (!within(addr, mod->module_init, mod->init_text_size)
67417 - && !within(addr, mod->module_core, mod->core_text_size))
67418 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
67419 mod = NULL;
67420 }
67421 return mod;
67422 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
67423 index 7e3443f..b2a1e6b 100644
67424 --- a/kernel/mutex-debug.c
67425 +++ b/kernel/mutex-debug.c
67426 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
67427 }
67428
67429 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
67430 - struct thread_info *ti)
67431 + struct task_struct *task)
67432 {
67433 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
67434
67435 /* Mark the current thread as blocked on the lock: */
67436 - ti->task->blocked_on = waiter;
67437 + task->blocked_on = waiter;
67438 }
67439
67440 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
67441 - struct thread_info *ti)
67442 + struct task_struct *task)
67443 {
67444 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
67445 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
67446 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
67447 - ti->task->blocked_on = NULL;
67448 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
67449 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
67450 + task->blocked_on = NULL;
67451
67452 list_del_init(&waiter->list);
67453 waiter->task = NULL;
67454 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
67455 index 0799fd3..d06ae3b 100644
67456 --- a/kernel/mutex-debug.h
67457 +++ b/kernel/mutex-debug.h
67458 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
67459 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
67460 extern void debug_mutex_add_waiter(struct mutex *lock,
67461 struct mutex_waiter *waiter,
67462 - struct thread_info *ti);
67463 + struct task_struct *task);
67464 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
67465 - struct thread_info *ti);
67466 + struct task_struct *task);
67467 extern void debug_mutex_unlock(struct mutex *lock);
67468 extern void debug_mutex_init(struct mutex *lock, const char *name,
67469 struct lock_class_key *key);
67470 diff --git a/kernel/mutex.c b/kernel/mutex.c
67471 index 89096dd..f91ebc5 100644
67472 --- a/kernel/mutex.c
67473 +++ b/kernel/mutex.c
67474 @@ -198,7 +198,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
67475 spin_lock_mutex(&lock->wait_lock, flags);
67476
67477 debug_mutex_lock_common(lock, &waiter);
67478 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
67479 + debug_mutex_add_waiter(lock, &waiter, task);
67480
67481 /* add waiting tasks to the end of the waitqueue (FIFO): */
67482 list_add_tail(&waiter.list, &lock->wait_list);
67483 @@ -227,8 +227,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
67484 * TASK_UNINTERRUPTIBLE case.)
67485 */
67486 if (unlikely(signal_pending_state(state, task))) {
67487 - mutex_remove_waiter(lock, &waiter,
67488 - task_thread_info(task));
67489 + mutex_remove_waiter(lock, &waiter, task);
67490 mutex_release(&lock->dep_map, 1, ip);
67491 spin_unlock_mutex(&lock->wait_lock, flags);
67492
67493 @@ -249,7 +248,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
67494 done:
67495 lock_acquired(&lock->dep_map, ip);
67496 /* got the lock - rejoice! */
67497 - mutex_remove_waiter(lock, &waiter, current_thread_info());
67498 + mutex_remove_waiter(lock, &waiter, task);
67499 mutex_set_owner(lock);
67500
67501 /* set it to 0 if there are no waiters left: */
67502 diff --git a/kernel/padata.c b/kernel/padata.c
67503 index b452599..5d68f4e 100644
67504 --- a/kernel/padata.c
67505 +++ b/kernel/padata.c
67506 @@ -132,10 +132,10 @@ int padata_do_parallel(struct padata_instance *pinst,
67507 padata->pd = pd;
67508 padata->cb_cpu = cb_cpu;
67509
67510 - if (unlikely(atomic_read(&pd->seq_nr) == pd->max_seq_nr))
67511 - atomic_set(&pd->seq_nr, -1);
67512 + if (unlikely(atomic_read_unchecked(&pd->seq_nr) == pd->max_seq_nr))
67513 + atomic_set_unchecked(&pd->seq_nr, -1);
67514
67515 - padata->seq_nr = atomic_inc_return(&pd->seq_nr);
67516 + padata->seq_nr = atomic_inc_return_unchecked(&pd->seq_nr);
67517
67518 target_cpu = padata_cpu_hash(padata);
67519 queue = per_cpu_ptr(pd->pqueue, target_cpu);
67520 @@ -444,7 +444,7 @@ static struct parallel_data *padata_alloc_pd(struct padata_instance *pinst,
67521 padata_init_pqueues(pd);
67522 padata_init_squeues(pd);
67523 setup_timer(&pd->timer, padata_reorder_timer, (unsigned long)pd);
67524 - atomic_set(&pd->seq_nr, -1);
67525 + atomic_set_unchecked(&pd->seq_nr, -1);
67526 atomic_set(&pd->reorder_objects, 0);
67527 atomic_set(&pd->refcnt, 0);
67528 pd->pinst = pinst;
67529 diff --git a/kernel/panic.c b/kernel/panic.c
67530 index 8ed89a1..e83856a 100644
67531 --- a/kernel/panic.c
67532 +++ b/kernel/panic.c
67533 @@ -402,7 +402,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
67534 const char *board;
67535
67536 printk(KERN_WARNING "------------[ cut here ]------------\n");
67537 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
67538 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
67539 board = dmi_get_system_info(DMI_PRODUCT_NAME);
67540 if (board)
67541 printk(KERN_WARNING "Hardware name: %s\n", board);
67542 @@ -457,7 +457,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
67543 */
67544 void __stack_chk_fail(void)
67545 {
67546 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
67547 + dump_stack();
67548 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
67549 __builtin_return_address(0));
67550 }
67551 EXPORT_SYMBOL(__stack_chk_fail);
67552 diff --git a/kernel/pid.c b/kernel/pid.c
67553 index 9f08dfa..6765c40 100644
67554 --- a/kernel/pid.c
67555 +++ b/kernel/pid.c
67556 @@ -33,6 +33,7 @@
67557 #include <linux/rculist.h>
67558 #include <linux/bootmem.h>
67559 #include <linux/hash.h>
67560 +#include <linux/security.h>
67561 #include <linux/pid_namespace.h>
67562 #include <linux/init_task.h>
67563 #include <linux/syscalls.h>
67564 @@ -45,7 +46,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
67565
67566 int pid_max = PID_MAX_DEFAULT;
67567
67568 -#define RESERVED_PIDS 300
67569 +#define RESERVED_PIDS 500
67570
67571 int pid_max_min = RESERVED_PIDS + 1;
67572 int pid_max_max = PID_MAX_LIMIT;
67573 @@ -420,10 +421,18 @@ EXPORT_SYMBOL(pid_task);
67574 */
67575 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
67576 {
67577 + struct task_struct *task;
67578 +
67579 rcu_lockdep_assert(rcu_read_lock_held(),
67580 "find_task_by_pid_ns() needs rcu_read_lock()"
67581 " protection");
67582 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
67583 +
67584 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
67585 +
67586 + if (gr_pid_is_chrooted(task))
67587 + return NULL;
67588 +
67589 + return task;
67590 }
67591
67592 struct task_struct *find_task_by_vpid(pid_t vnr)
67593 @@ -431,6 +440,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
67594 return find_task_by_pid_ns(vnr, current->nsproxy->pid_ns);
67595 }
67596
67597 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
67598 +{
67599 + rcu_lockdep_assert(rcu_read_lock_held(),
67600 + "find_task_by_pid_ns() needs rcu_read_lock()"
67601 + " protection");
67602 + return pid_task(find_pid_ns(vnr, current->nsproxy->pid_ns), PIDTYPE_PID);
67603 +}
67604 +
67605 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
67606 {
67607 struct pid *pid;
67608 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
67609 index 125cb67..a4d1c30 100644
67610 --- a/kernel/posix-cpu-timers.c
67611 +++ b/kernel/posix-cpu-timers.c
67612 @@ -6,6 +6,7 @@
67613 #include <linux/posix-timers.h>
67614 #include <linux/errno.h>
67615 #include <linux/math64.h>
67616 +#include <linux/security.h>
67617 #include <asm/uaccess.h>
67618 #include <linux/kernel_stat.h>
67619 #include <trace/events/timer.h>
67620 @@ -1578,14 +1579,14 @@ struct k_clock clock_posix_cpu = {
67621
67622 static __init int init_posix_cpu_timers(void)
67623 {
67624 - struct k_clock process = {
67625 + static struct k_clock process = {
67626 .clock_getres = process_cpu_clock_getres,
67627 .clock_get = process_cpu_clock_get,
67628 .timer_create = process_cpu_timer_create,
67629 .nsleep = process_cpu_nsleep,
67630 .nsleep_restart = process_cpu_nsleep_restart,
67631 };
67632 - struct k_clock thread = {
67633 + static struct k_clock thread = {
67634 .clock_getres = thread_cpu_clock_getres,
67635 .clock_get = thread_cpu_clock_get,
67636 .timer_create = thread_cpu_timer_create,
67637 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
67638 index 69185ae..cc2847a 100644
67639 --- a/kernel/posix-timers.c
67640 +++ b/kernel/posix-timers.c
67641 @@ -43,6 +43,7 @@
67642 #include <linux/idr.h>
67643 #include <linux/posix-clock.h>
67644 #include <linux/posix-timers.h>
67645 +#include <linux/grsecurity.h>
67646 #include <linux/syscalls.h>
67647 #include <linux/wait.h>
67648 #include <linux/workqueue.h>
67649 @@ -129,7 +130,7 @@ static DEFINE_SPINLOCK(idr_lock);
67650 * which we beg off on and pass to do_sys_settimeofday().
67651 */
67652
67653 -static struct k_clock posix_clocks[MAX_CLOCKS];
67654 +static struct k_clock *posix_clocks[MAX_CLOCKS];
67655
67656 /*
67657 * These ones are defined below.
67658 @@ -227,7 +228,7 @@ static int posix_get_boottime(const clockid_t which_clock, struct timespec *tp)
67659 */
67660 static __init int init_posix_timers(void)
67661 {
67662 - struct k_clock clock_realtime = {
67663 + static struct k_clock clock_realtime = {
67664 .clock_getres = hrtimer_get_res,
67665 .clock_get = posix_clock_realtime_get,
67666 .clock_set = posix_clock_realtime_set,
67667 @@ -239,7 +240,7 @@ static __init int init_posix_timers(void)
67668 .timer_get = common_timer_get,
67669 .timer_del = common_timer_del,
67670 };
67671 - struct k_clock clock_monotonic = {
67672 + static struct k_clock clock_monotonic = {
67673 .clock_getres = hrtimer_get_res,
67674 .clock_get = posix_ktime_get_ts,
67675 .nsleep = common_nsleep,
67676 @@ -249,19 +250,19 @@ static __init int init_posix_timers(void)
67677 .timer_get = common_timer_get,
67678 .timer_del = common_timer_del,
67679 };
67680 - struct k_clock clock_monotonic_raw = {
67681 + static struct k_clock clock_monotonic_raw = {
67682 .clock_getres = hrtimer_get_res,
67683 .clock_get = posix_get_monotonic_raw,
67684 };
67685 - struct k_clock clock_realtime_coarse = {
67686 + static struct k_clock clock_realtime_coarse = {
67687 .clock_getres = posix_get_coarse_res,
67688 .clock_get = posix_get_realtime_coarse,
67689 };
67690 - struct k_clock clock_monotonic_coarse = {
67691 + static struct k_clock clock_monotonic_coarse = {
67692 .clock_getres = posix_get_coarse_res,
67693 .clock_get = posix_get_monotonic_coarse,
67694 };
67695 - struct k_clock clock_boottime = {
67696 + static struct k_clock clock_boottime = {
67697 .clock_getres = hrtimer_get_res,
67698 .clock_get = posix_get_boottime,
67699 .nsleep = common_nsleep,
67700 @@ -473,7 +474,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
67701 return;
67702 }
67703
67704 - posix_clocks[clock_id] = *new_clock;
67705 + posix_clocks[clock_id] = new_clock;
67706 }
67707 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
67708
67709 @@ -519,9 +520,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
67710 return (id & CLOCKFD_MASK) == CLOCKFD ?
67711 &clock_posix_dynamic : &clock_posix_cpu;
67712
67713 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
67714 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
67715 return NULL;
67716 - return &posix_clocks[id];
67717 + return posix_clocks[id];
67718 }
67719
67720 static int common_timer_create(struct k_itimer *new_timer)
67721 @@ -959,6 +960,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
67722 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
67723 return -EFAULT;
67724
67725 + /* only the CLOCK_REALTIME clock can be set, all other clocks
67726 + have their clock_set fptr set to a nosettime dummy function
67727 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
67728 + call common_clock_set, which calls do_sys_settimeofday, which
67729 + we hook
67730 + */
67731 +
67732 return kc->clock_set(which_clock, &new_tp);
67733 }
67734
67735 diff --git a/kernel/power/poweroff.c b/kernel/power/poweroff.c
67736 index d523593..68197a4 100644
67737 --- a/kernel/power/poweroff.c
67738 +++ b/kernel/power/poweroff.c
67739 @@ -37,7 +37,7 @@ static struct sysrq_key_op sysrq_poweroff_op = {
67740 .enable_mask = SYSRQ_ENABLE_BOOT,
67741 };
67742
67743 -static int pm_sysrq_init(void)
67744 +static int __init pm_sysrq_init(void)
67745 {
67746 register_sysrq_key('o', &sysrq_poweroff_op);
67747 return 0;
67748 diff --git a/kernel/power/process.c b/kernel/power/process.c
67749 index 7aac07a..2d3c6dc 100644
67750 --- a/kernel/power/process.c
67751 +++ b/kernel/power/process.c
67752 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
67753 u64 elapsed_csecs64;
67754 unsigned int elapsed_csecs;
67755 bool wakeup = false;
67756 + bool timedout = false;
67757
67758 do_gettimeofday(&start);
67759
67760 @@ -43,6 +44,8 @@ static int try_to_freeze_tasks(bool user_only)
67761
67762 while (true) {
67763 todo = 0;
67764 + if (time_after(jiffies, end_time))
67765 + timedout = true;
67766 read_lock(&tasklist_lock);
67767 do_each_thread(g, p) {
67768 if (p == current || !freeze_task(p))
67769 @@ -60,9 +63,13 @@ static int try_to_freeze_tasks(bool user_only)
67770 * try_to_stop() after schedule() in ptrace/signal
67771 * stop sees TIF_FREEZE.
67772 */
67773 - if (!task_is_stopped_or_traced(p) &&
67774 - !freezer_should_skip(p))
67775 + if (!task_is_stopped_or_traced(p) && !freezer_should_skip(p)) {
67776 todo++;
67777 + if (timedout) {
67778 + printk(KERN_ERR "Task refusing to freeze:\n");
67779 + sched_show_task(p);
67780 + }
67781 + }
67782 } while_each_thread(g, p);
67783 read_unlock(&tasklist_lock);
67784
67785 @@ -71,7 +78,7 @@ static int try_to_freeze_tasks(bool user_only)
67786 todo += wq_busy;
67787 }
67788
67789 - if (!todo || time_after(jiffies, end_time))
67790 + if (!todo || timedout)
67791 break;
67792
67793 if (pm_wakeup_pending()) {
67794 diff --git a/kernel/printk.c b/kernel/printk.c
67795 index 32690a0..cd7c798 100644
67796 --- a/kernel/printk.c
67797 +++ b/kernel/printk.c
67798 @@ -313,6 +313,11 @@ static int check_syslog_permissions(int type, bool from_file)
67799 if (from_file && type != SYSLOG_ACTION_OPEN)
67800 return 0;
67801
67802 +#ifdef CONFIG_GRKERNSEC_DMESG
67803 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
67804 + return -EPERM;
67805 +#endif
67806 +
67807 if (syslog_action_restricted(type)) {
67808 if (capable(CAP_SYSLOG))
67809 return 0;
67810 diff --git a/kernel/profile.c b/kernel/profile.c
67811 index 76b8e77..a2930e8 100644
67812 --- a/kernel/profile.c
67813 +++ b/kernel/profile.c
67814 @@ -39,7 +39,7 @@ struct profile_hit {
67815 /* Oprofile timer tick hook */
67816 static int (*timer_hook)(struct pt_regs *) __read_mostly;
67817
67818 -static atomic_t *prof_buffer;
67819 +static atomic_unchecked_t *prof_buffer;
67820 static unsigned long prof_len, prof_shift;
67821
67822 int prof_on __read_mostly;
67823 @@ -281,7 +281,7 @@ static void profile_flip_buffers(void)
67824 hits[i].pc = 0;
67825 continue;
67826 }
67827 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
67828 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
67829 hits[i].hits = hits[i].pc = 0;
67830 }
67831 }
67832 @@ -342,9 +342,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
67833 * Add the current hit(s) and flush the write-queue out
67834 * to the global buffer:
67835 */
67836 - atomic_add(nr_hits, &prof_buffer[pc]);
67837 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
67838 for (i = 0; i < NR_PROFILE_HIT; ++i) {
67839 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
67840 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
67841 hits[i].pc = hits[i].hits = 0;
67842 }
67843 out:
67844 @@ -419,7 +419,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
67845 {
67846 unsigned long pc;
67847 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
67848 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
67849 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
67850 }
67851 #endif /* !CONFIG_SMP */
67852
67853 @@ -517,7 +517,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
67854 return -EFAULT;
67855 buf++; p++; count--; read++;
67856 }
67857 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
67858 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
67859 if (copy_to_user(buf, (void *)pnt, count))
67860 return -EFAULT;
67861 read += count;
67862 @@ -548,7 +548,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
67863 }
67864 #endif
67865 profile_discard_flip_buffers();
67866 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
67867 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
67868 return count;
67869 }
67870
67871 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
67872 index 00ab2ca..d237f61 100644
67873 --- a/kernel/ptrace.c
67874 +++ b/kernel/ptrace.c
67875 @@ -285,7 +285,7 @@ static int ptrace_attach(struct task_struct *task, long request,
67876 task->ptrace = PT_PTRACED;
67877 if (seize)
67878 task->ptrace |= PT_SEIZED;
67879 - if (ns_capable(task_user_ns(task), CAP_SYS_PTRACE))
67880 + if (ns_capable_nolog(task_user_ns(task), CAP_SYS_PTRACE))
67881 task->ptrace |= PT_PTRACE_CAP;
67882
67883 __ptrace_link(task, current);
67884 @@ -491,7 +491,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
67885 break;
67886 return -EIO;
67887 }
67888 - if (copy_to_user(dst, buf, retval))
67889 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
67890 return -EFAULT;
67891 copied += retval;
67892 src += retval;
67893 @@ -688,7 +688,7 @@ int ptrace_request(struct task_struct *child, long request,
67894 bool seized = child->ptrace & PT_SEIZED;
67895 int ret = -EIO;
67896 siginfo_t siginfo, *si;
67897 - void __user *datavp = (void __user *) data;
67898 + void __user *datavp = (__force void __user *) data;
67899 unsigned long __user *datalp = datavp;
67900 unsigned long flags;
67901
67902 @@ -890,14 +890,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
67903 goto out;
67904 }
67905
67906 + if (gr_handle_ptrace(child, request)) {
67907 + ret = -EPERM;
67908 + goto out_put_task_struct;
67909 + }
67910 +
67911 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
67912 ret = ptrace_attach(child, request, data);
67913 /*
67914 * Some architectures need to do book-keeping after
67915 * a ptrace attach.
67916 */
67917 - if (!ret)
67918 + if (!ret) {
67919 arch_ptrace_attach(child);
67920 + gr_audit_ptrace(child);
67921 + }
67922 goto out_put_task_struct;
67923 }
67924
67925 @@ -923,7 +930,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
67926 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
67927 if (copied != sizeof(tmp))
67928 return -EIO;
67929 - return put_user(tmp, (unsigned long __user *)data);
67930 + return put_user(tmp, (__force unsigned long __user *)data);
67931 }
67932
67933 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
67934 @@ -1033,14 +1040,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
67935 goto out;
67936 }
67937
67938 + if (gr_handle_ptrace(child, request)) {
67939 + ret = -EPERM;
67940 + goto out_put_task_struct;
67941 + }
67942 +
67943 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
67944 ret = ptrace_attach(child, request, data);
67945 /*
67946 * Some architectures need to do book-keeping after
67947 * a ptrace attach.
67948 */
67949 - if (!ret)
67950 + if (!ret) {
67951 arch_ptrace_attach(child);
67952 + gr_audit_ptrace(child);
67953 + }
67954 goto out_put_task_struct;
67955 }
67956
67957 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
67958 index 977296d..c4744dc 100644
67959 --- a/kernel/rcutiny.c
67960 +++ b/kernel/rcutiny.c
67961 @@ -46,7 +46,7 @@
67962 struct rcu_ctrlblk;
67963 static void invoke_rcu_callbacks(void);
67964 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
67965 -static void rcu_process_callbacks(struct softirq_action *unused);
67966 +static void rcu_process_callbacks(void);
67967 static void __call_rcu(struct rcu_head *head,
67968 void (*func)(struct rcu_head *rcu),
67969 struct rcu_ctrlblk *rcp);
67970 @@ -297,7 +297,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
67971 rcu_is_callbacks_kthread()));
67972 }
67973
67974 -static void rcu_process_callbacks(struct softirq_action *unused)
67975 +static void rcu_process_callbacks(void)
67976 {
67977 __rcu_process_callbacks(&rcu_sched_ctrlblk);
67978 __rcu_process_callbacks(&rcu_bh_ctrlblk);
67979 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
67980 index 9cb1ae4..aac7d3e 100644
67981 --- a/kernel/rcutiny_plugin.h
67982 +++ b/kernel/rcutiny_plugin.h
67983 @@ -920,7 +920,7 @@ static int rcu_kthread(void *arg)
67984 have_rcu_kthread_work = morework;
67985 local_irq_restore(flags);
67986 if (work)
67987 - rcu_process_callbacks(NULL);
67988 + rcu_process_callbacks();
67989 schedule_timeout_interruptible(1); /* Leave CPU for others. */
67990 }
67991
67992 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
67993 index a58ac28..196a3d8 100644
67994 --- a/kernel/rcutorture.c
67995 +++ b/kernel/rcutorture.c
67996 @@ -148,12 +148,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
67997 { 0 };
67998 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
67999 { 0 };
68000 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
68001 -static atomic_t n_rcu_torture_alloc;
68002 -static atomic_t n_rcu_torture_alloc_fail;
68003 -static atomic_t n_rcu_torture_free;
68004 -static atomic_t n_rcu_torture_mberror;
68005 -static atomic_t n_rcu_torture_error;
68006 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
68007 +static atomic_unchecked_t n_rcu_torture_alloc;
68008 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
68009 +static atomic_unchecked_t n_rcu_torture_free;
68010 +static atomic_unchecked_t n_rcu_torture_mberror;
68011 +static atomic_unchecked_t n_rcu_torture_error;
68012 static long n_rcu_torture_boost_ktrerror;
68013 static long n_rcu_torture_boost_rterror;
68014 static long n_rcu_torture_boost_failure;
68015 @@ -243,11 +243,11 @@ rcu_torture_alloc(void)
68016
68017 spin_lock_bh(&rcu_torture_lock);
68018 if (list_empty(&rcu_torture_freelist)) {
68019 - atomic_inc(&n_rcu_torture_alloc_fail);
68020 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
68021 spin_unlock_bh(&rcu_torture_lock);
68022 return NULL;
68023 }
68024 - atomic_inc(&n_rcu_torture_alloc);
68025 + atomic_inc_unchecked(&n_rcu_torture_alloc);
68026 p = rcu_torture_freelist.next;
68027 list_del_init(p);
68028 spin_unlock_bh(&rcu_torture_lock);
68029 @@ -260,7 +260,7 @@ rcu_torture_alloc(void)
68030 static void
68031 rcu_torture_free(struct rcu_torture *p)
68032 {
68033 - atomic_inc(&n_rcu_torture_free);
68034 + atomic_inc_unchecked(&n_rcu_torture_free);
68035 spin_lock_bh(&rcu_torture_lock);
68036 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
68037 spin_unlock_bh(&rcu_torture_lock);
68038 @@ -380,7 +380,7 @@ rcu_torture_cb(struct rcu_head *p)
68039 i = rp->rtort_pipe_count;
68040 if (i > RCU_TORTURE_PIPE_LEN)
68041 i = RCU_TORTURE_PIPE_LEN;
68042 - atomic_inc(&rcu_torture_wcount[i]);
68043 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
68044 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
68045 rp->rtort_mbtest = 0;
68046 rcu_torture_free(rp);
68047 @@ -427,7 +427,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
68048 i = rp->rtort_pipe_count;
68049 if (i > RCU_TORTURE_PIPE_LEN)
68050 i = RCU_TORTURE_PIPE_LEN;
68051 - atomic_inc(&rcu_torture_wcount[i]);
68052 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
68053 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
68054 rp->rtort_mbtest = 0;
68055 list_del(&rp->rtort_free);
68056 @@ -916,7 +916,7 @@ rcu_torture_writer(void *arg)
68057 i = old_rp->rtort_pipe_count;
68058 if (i > RCU_TORTURE_PIPE_LEN)
68059 i = RCU_TORTURE_PIPE_LEN;
68060 - atomic_inc(&rcu_torture_wcount[i]);
68061 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
68062 old_rp->rtort_pipe_count++;
68063 cur_ops->deferred_free(old_rp);
68064 }
68065 @@ -997,7 +997,7 @@ static void rcu_torture_timer(unsigned long unused)
68066 return;
68067 }
68068 if (p->rtort_mbtest == 0)
68069 - atomic_inc(&n_rcu_torture_mberror);
68070 + atomic_inc_unchecked(&n_rcu_torture_mberror);
68071 spin_lock(&rand_lock);
68072 cur_ops->read_delay(&rand);
68073 n_rcu_torture_timers++;
68074 @@ -1061,7 +1061,7 @@ rcu_torture_reader(void *arg)
68075 continue;
68076 }
68077 if (p->rtort_mbtest == 0)
68078 - atomic_inc(&n_rcu_torture_mberror);
68079 + atomic_inc_unchecked(&n_rcu_torture_mberror);
68080 cur_ops->read_delay(&rand);
68081 preempt_disable();
68082 pipe_count = p->rtort_pipe_count;
68083 @@ -1123,10 +1123,10 @@ rcu_torture_printk(char *page)
68084 rcu_torture_current,
68085 rcu_torture_current_version,
68086 list_empty(&rcu_torture_freelist),
68087 - atomic_read(&n_rcu_torture_alloc),
68088 - atomic_read(&n_rcu_torture_alloc_fail),
68089 - atomic_read(&n_rcu_torture_free),
68090 - atomic_read(&n_rcu_torture_mberror),
68091 + atomic_read_unchecked(&n_rcu_torture_alloc),
68092 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
68093 + atomic_read_unchecked(&n_rcu_torture_free),
68094 + atomic_read_unchecked(&n_rcu_torture_mberror),
68095 n_rcu_torture_boost_ktrerror,
68096 n_rcu_torture_boost_rterror,
68097 n_rcu_torture_boost_failure,
68098 @@ -1136,7 +1136,7 @@ rcu_torture_printk(char *page)
68099 n_online_attempts,
68100 n_offline_successes,
68101 n_offline_attempts);
68102 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
68103 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
68104 n_rcu_torture_boost_ktrerror != 0 ||
68105 n_rcu_torture_boost_rterror != 0 ||
68106 n_rcu_torture_boost_failure != 0)
68107 @@ -1144,7 +1144,7 @@ rcu_torture_printk(char *page)
68108 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
68109 if (i > 1) {
68110 cnt += sprintf(&page[cnt], "!!! ");
68111 - atomic_inc(&n_rcu_torture_error);
68112 + atomic_inc_unchecked(&n_rcu_torture_error);
68113 WARN_ON_ONCE(1);
68114 }
68115 cnt += sprintf(&page[cnt], "Reader Pipe: ");
68116 @@ -1158,7 +1158,7 @@ rcu_torture_printk(char *page)
68117 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
68118 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
68119 cnt += sprintf(&page[cnt], " %d",
68120 - atomic_read(&rcu_torture_wcount[i]));
68121 + atomic_read_unchecked(&rcu_torture_wcount[i]));
68122 }
68123 cnt += sprintf(&page[cnt], "\n");
68124 if (cur_ops->stats)
68125 @@ -1600,7 +1600,7 @@ rcu_torture_cleanup(void)
68126
68127 if (cur_ops->cleanup)
68128 cur_ops->cleanup();
68129 - if (atomic_read(&n_rcu_torture_error))
68130 + if (atomic_read_unchecked(&n_rcu_torture_error))
68131 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
68132 else
68133 rcu_torture_print_module_parms(cur_ops, "End of test: SUCCESS");
68134 @@ -1664,17 +1664,17 @@ rcu_torture_init(void)
68135
68136 rcu_torture_current = NULL;
68137 rcu_torture_current_version = 0;
68138 - atomic_set(&n_rcu_torture_alloc, 0);
68139 - atomic_set(&n_rcu_torture_alloc_fail, 0);
68140 - atomic_set(&n_rcu_torture_free, 0);
68141 - atomic_set(&n_rcu_torture_mberror, 0);
68142 - atomic_set(&n_rcu_torture_error, 0);
68143 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
68144 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
68145 + atomic_set_unchecked(&n_rcu_torture_free, 0);
68146 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
68147 + atomic_set_unchecked(&n_rcu_torture_error, 0);
68148 n_rcu_torture_boost_ktrerror = 0;
68149 n_rcu_torture_boost_rterror = 0;
68150 n_rcu_torture_boost_failure = 0;
68151 n_rcu_torture_boosts = 0;
68152 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
68153 - atomic_set(&rcu_torture_wcount[i], 0);
68154 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
68155 for_each_possible_cpu(cpu) {
68156 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
68157 per_cpu(rcu_torture_count, cpu)[i] = 0;
68158 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
68159 index 6c4a672..70f3202 100644
68160 --- a/kernel/rcutree.c
68161 +++ b/kernel/rcutree.c
68162 @@ -363,9 +363,9 @@ static void rcu_idle_enter_common(struct rcu_dynticks *rdtp, long long oldval)
68163 rcu_prepare_for_idle(smp_processor_id());
68164 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
68165 smp_mb__before_atomic_inc(); /* See above. */
68166 - atomic_inc(&rdtp->dynticks);
68167 + atomic_inc_unchecked(&rdtp->dynticks);
68168 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
68169 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
68170 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
68171 }
68172
68173 /**
68174 @@ -438,10 +438,10 @@ void rcu_irq_exit(void)
68175 static void rcu_idle_exit_common(struct rcu_dynticks *rdtp, long long oldval)
68176 {
68177 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
68178 - atomic_inc(&rdtp->dynticks);
68179 + atomic_inc_unchecked(&rdtp->dynticks);
68180 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
68181 smp_mb__after_atomic_inc(); /* See above. */
68182 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
68183 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
68184 rcu_cleanup_after_idle(smp_processor_id());
68185 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
68186 if (!is_idle_task(current)) {
68187 @@ -531,14 +531,14 @@ void rcu_nmi_enter(void)
68188 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
68189
68190 if (rdtp->dynticks_nmi_nesting == 0 &&
68191 - (atomic_read(&rdtp->dynticks) & 0x1))
68192 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
68193 return;
68194 rdtp->dynticks_nmi_nesting++;
68195 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
68196 - atomic_inc(&rdtp->dynticks);
68197 + atomic_inc_unchecked(&rdtp->dynticks);
68198 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
68199 smp_mb__after_atomic_inc(); /* See above. */
68200 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
68201 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
68202 }
68203
68204 /**
68205 @@ -557,9 +557,9 @@ void rcu_nmi_exit(void)
68206 return;
68207 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
68208 smp_mb__before_atomic_inc(); /* See above. */
68209 - atomic_inc(&rdtp->dynticks);
68210 + atomic_inc_unchecked(&rdtp->dynticks);
68211 smp_mb__after_atomic_inc(); /* Force delay to next write. */
68212 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
68213 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
68214 }
68215
68216 #ifdef CONFIG_PROVE_RCU
68217 @@ -575,7 +575,7 @@ int rcu_is_cpu_idle(void)
68218 int ret;
68219
68220 preempt_disable();
68221 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
68222 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
68223 preempt_enable();
68224 return ret;
68225 }
68226 @@ -604,7 +604,7 @@ int rcu_is_cpu_rrupt_from_idle(void)
68227 */
68228 static int dyntick_save_progress_counter(struct rcu_data *rdp)
68229 {
68230 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
68231 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
68232 return (rdp->dynticks_snap & 0x1) == 0;
68233 }
68234
68235 @@ -619,7 +619,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
68236 unsigned int curr;
68237 unsigned int snap;
68238
68239 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
68240 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
68241 snap = (unsigned int)rdp->dynticks_snap;
68242
68243 /*
68244 @@ -1667,7 +1667,7 @@ __rcu_process_callbacks(struct rcu_state *rsp, struct rcu_data *rdp)
68245 /*
68246 * Do RCU core processing for the current CPU.
68247 */
68248 -static void rcu_process_callbacks(struct softirq_action *unused)
68249 +static void rcu_process_callbacks(void)
68250 {
68251 trace_rcu_utilization("Start RCU core");
68252 __rcu_process_callbacks(&rcu_sched_state,
68253 @@ -2030,7 +2030,7 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
68254 rdp->qlen = 0;
68255 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
68256 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_NESTING);
68257 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
68258 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
68259 rdp->cpu = cpu;
68260 rdp->rsp = rsp;
68261 raw_spin_unlock_irqrestore(&rnp->lock, flags);
68262 @@ -2058,8 +2058,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
68263 rdp->n_force_qs_snap = rsp->n_force_qs;
68264 rdp->blimit = blimit;
68265 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_NESTING;
68266 - atomic_set(&rdp->dynticks->dynticks,
68267 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
68268 + atomic_set_unchecked(&rdp->dynticks->dynticks,
68269 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
68270 rcu_prepare_for_idle_init(cpu);
68271 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
68272
68273 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
68274 index fddff92..2c08359 100644
68275 --- a/kernel/rcutree.h
68276 +++ b/kernel/rcutree.h
68277 @@ -87,7 +87,7 @@ struct rcu_dynticks {
68278 long long dynticks_nesting; /* Track irq/process nesting level. */
68279 /* Process level is worth LLONG_MAX/2. */
68280 int dynticks_nmi_nesting; /* Track NMI nesting level. */
68281 - atomic_t dynticks; /* Even value for idle, else odd. */
68282 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
68283 };
68284
68285 /* RCU's kthread states for tracing. */
68286 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
68287 index 8bb35d7..6ea0a463 100644
68288 --- a/kernel/rcutree_plugin.h
68289 +++ b/kernel/rcutree_plugin.h
68290 @@ -850,7 +850,7 @@ void synchronize_rcu_expedited(void)
68291
68292 /* Clean up and exit. */
68293 smp_mb(); /* ensure expedited GP seen before counter increment. */
68294 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
68295 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
68296 unlock_mb_ret:
68297 mutex_unlock(&sync_rcu_preempt_exp_mutex);
68298 mb_ret:
68299 @@ -1833,8 +1833,8 @@ EXPORT_SYMBOL_GPL(synchronize_sched_expedited);
68300
68301 #else /* #ifndef CONFIG_SMP */
68302
68303 -static atomic_t sync_sched_expedited_started = ATOMIC_INIT(0);
68304 -static atomic_t sync_sched_expedited_done = ATOMIC_INIT(0);
68305 +static atomic_unchecked_t sync_sched_expedited_started = ATOMIC_INIT(0);
68306 +static atomic_unchecked_t sync_sched_expedited_done = ATOMIC_INIT(0);
68307
68308 static int synchronize_sched_expedited_cpu_stop(void *data)
68309 {
68310 @@ -1889,7 +1889,7 @@ void synchronize_sched_expedited(void)
68311 int firstsnap, s, snap, trycount = 0;
68312
68313 /* Note that atomic_inc_return() implies full memory barrier. */
68314 - firstsnap = snap = atomic_inc_return(&sync_sched_expedited_started);
68315 + firstsnap = snap = atomic_inc_return_unchecked(&sync_sched_expedited_started);
68316 get_online_cpus();
68317
68318 /*
68319 @@ -1910,7 +1910,7 @@ void synchronize_sched_expedited(void)
68320 }
68321
68322 /* Check to see if someone else did our work for us. */
68323 - s = atomic_read(&sync_sched_expedited_done);
68324 + s = atomic_read_unchecked(&sync_sched_expedited_done);
68325 if (UINT_CMP_GE((unsigned)s, (unsigned)firstsnap)) {
68326 smp_mb(); /* ensure test happens before caller kfree */
68327 return;
68328 @@ -1925,7 +1925,7 @@ void synchronize_sched_expedited(void)
68329 * grace period works for us.
68330 */
68331 get_online_cpus();
68332 - snap = atomic_read(&sync_sched_expedited_started);
68333 + snap = atomic_read_unchecked(&sync_sched_expedited_started);
68334 smp_mb(); /* ensure read is before try_stop_cpus(). */
68335 }
68336
68337 @@ -1936,12 +1936,12 @@ void synchronize_sched_expedited(void)
68338 * than we did beat us to the punch.
68339 */
68340 do {
68341 - s = atomic_read(&sync_sched_expedited_done);
68342 + s = atomic_read_unchecked(&sync_sched_expedited_done);
68343 if (UINT_CMP_GE((unsigned)s, (unsigned)snap)) {
68344 smp_mb(); /* ensure test happens before caller kfree */
68345 break;
68346 }
68347 - } while (atomic_cmpxchg(&sync_sched_expedited_done, s, snap) != s);
68348 + } while (atomic_cmpxchg_unchecked(&sync_sched_expedited_done, s, snap) != s);
68349
68350 put_online_cpus();
68351 }
68352 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
68353 index 654cfe6..c0b28e2 100644
68354 --- a/kernel/rcutree_trace.c
68355 +++ b/kernel/rcutree_trace.c
68356 @@ -68,7 +68,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
68357 rdp->passed_quiesce, rdp->passed_quiesce_gpnum,
68358 rdp->qs_pending);
68359 seq_printf(m, " dt=%d/%llx/%d df=%lu",
68360 - atomic_read(&rdp->dynticks->dynticks),
68361 + atomic_read_unchecked(&rdp->dynticks->dynticks),
68362 rdp->dynticks->dynticks_nesting,
68363 rdp->dynticks->dynticks_nmi_nesting,
68364 rdp->dynticks_fqs);
68365 @@ -140,7 +140,7 @@ static void print_one_rcu_data_csv(struct seq_file *m, struct rcu_data *rdp)
68366 rdp->passed_quiesce, rdp->passed_quiesce_gpnum,
68367 rdp->qs_pending);
68368 seq_printf(m, ",%d,%llx,%d,%lu",
68369 - atomic_read(&rdp->dynticks->dynticks),
68370 + atomic_read_unchecked(&rdp->dynticks->dynticks),
68371 rdp->dynticks->dynticks_nesting,
68372 rdp->dynticks->dynticks_nmi_nesting,
68373 rdp->dynticks_fqs);
68374 diff --git a/kernel/resource.c b/kernel/resource.c
68375 index 7640b3a..5879283 100644
68376 --- a/kernel/resource.c
68377 +++ b/kernel/resource.c
68378 @@ -141,8 +141,18 @@ static const struct file_operations proc_iomem_operations = {
68379
68380 static int __init ioresources_init(void)
68381 {
68382 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
68383 +#ifdef CONFIG_GRKERNSEC_PROC_USER
68384 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
68385 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
68386 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
68387 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
68388 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
68389 +#endif
68390 +#else
68391 proc_create("ioports", 0, NULL, &proc_ioports_operations);
68392 proc_create("iomem", 0, NULL, &proc_iomem_operations);
68393 +#endif
68394 return 0;
68395 }
68396 __initcall(ioresources_init);
68397 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
68398 index 98ec494..4241d6d 100644
68399 --- a/kernel/rtmutex-tester.c
68400 +++ b/kernel/rtmutex-tester.c
68401 @@ -20,7 +20,7 @@
68402 #define MAX_RT_TEST_MUTEXES 8
68403
68404 static spinlock_t rttest_lock;
68405 -static atomic_t rttest_event;
68406 +static atomic_unchecked_t rttest_event;
68407
68408 struct test_thread_data {
68409 int opcode;
68410 @@ -61,7 +61,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
68411
68412 case RTTEST_LOCKCONT:
68413 td->mutexes[td->opdata] = 1;
68414 - td->event = atomic_add_return(1, &rttest_event);
68415 + td->event = atomic_add_return_unchecked(1, &rttest_event);
68416 return 0;
68417
68418 case RTTEST_RESET:
68419 @@ -74,7 +74,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
68420 return 0;
68421
68422 case RTTEST_RESETEVENT:
68423 - atomic_set(&rttest_event, 0);
68424 + atomic_set_unchecked(&rttest_event, 0);
68425 return 0;
68426
68427 default:
68428 @@ -91,9 +91,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
68429 return ret;
68430
68431 td->mutexes[id] = 1;
68432 - td->event = atomic_add_return(1, &rttest_event);
68433 + td->event = atomic_add_return_unchecked(1, &rttest_event);
68434 rt_mutex_lock(&mutexes[id]);
68435 - td->event = atomic_add_return(1, &rttest_event);
68436 + td->event = atomic_add_return_unchecked(1, &rttest_event);
68437 td->mutexes[id] = 4;
68438 return 0;
68439
68440 @@ -104,9 +104,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
68441 return ret;
68442
68443 td->mutexes[id] = 1;
68444 - td->event = atomic_add_return(1, &rttest_event);
68445 + td->event = atomic_add_return_unchecked(1, &rttest_event);
68446 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
68447 - td->event = atomic_add_return(1, &rttest_event);
68448 + td->event = atomic_add_return_unchecked(1, &rttest_event);
68449 td->mutexes[id] = ret ? 0 : 4;
68450 return ret ? -EINTR : 0;
68451
68452 @@ -115,9 +115,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
68453 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
68454 return ret;
68455
68456 - td->event = atomic_add_return(1, &rttest_event);
68457 + td->event = atomic_add_return_unchecked(1, &rttest_event);
68458 rt_mutex_unlock(&mutexes[id]);
68459 - td->event = atomic_add_return(1, &rttest_event);
68460 + td->event = atomic_add_return_unchecked(1, &rttest_event);
68461 td->mutexes[id] = 0;
68462 return 0;
68463
68464 @@ -164,7 +164,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
68465 break;
68466
68467 td->mutexes[dat] = 2;
68468 - td->event = atomic_add_return(1, &rttest_event);
68469 + td->event = atomic_add_return_unchecked(1, &rttest_event);
68470 break;
68471
68472 default:
68473 @@ -184,7 +184,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
68474 return;
68475
68476 td->mutexes[dat] = 3;
68477 - td->event = atomic_add_return(1, &rttest_event);
68478 + td->event = atomic_add_return_unchecked(1, &rttest_event);
68479 break;
68480
68481 case RTTEST_LOCKNOWAIT:
68482 @@ -196,7 +196,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
68483 return;
68484
68485 td->mutexes[dat] = 1;
68486 - td->event = atomic_add_return(1, &rttest_event);
68487 + td->event = atomic_add_return_unchecked(1, &rttest_event);
68488 return;
68489
68490 default:
68491 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
68492 index e8a1f83..363d17d 100644
68493 --- a/kernel/sched/auto_group.c
68494 +++ b/kernel/sched/auto_group.c
68495 @@ -11,7 +11,7 @@
68496
68497 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
68498 static struct autogroup autogroup_default;
68499 -static atomic_t autogroup_seq_nr;
68500 +static atomic_unchecked_t autogroup_seq_nr;
68501
68502 void __init autogroup_init(struct task_struct *init_task)
68503 {
68504 @@ -78,7 +78,7 @@ static inline struct autogroup *autogroup_create(void)
68505
68506 kref_init(&ag->kref);
68507 init_rwsem(&ag->lock);
68508 - ag->id = atomic_inc_return(&autogroup_seq_nr);
68509 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
68510 ag->tg = tg;
68511 #ifdef CONFIG_RT_GROUP_SCHED
68512 /*
68513 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
68514 index 478a04c..e16339a 100644
68515 --- a/kernel/sched/core.c
68516 +++ b/kernel/sched/core.c
68517 @@ -3851,6 +3851,8 @@ int can_nice(const struct task_struct *p, const int nice)
68518 /* convert nice value [19,-20] to rlimit style value [1,40] */
68519 int nice_rlim = 20 - nice;
68520
68521 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
68522 +
68523 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
68524 capable(CAP_SYS_NICE));
68525 }
68526 @@ -3884,7 +3886,8 @@ SYSCALL_DEFINE1(nice, int, increment)
68527 if (nice > 19)
68528 nice = 19;
68529
68530 - if (increment < 0 && !can_nice(current, nice))
68531 + if (increment < 0 && (!can_nice(current, nice) ||
68532 + gr_handle_chroot_nice()))
68533 return -EPERM;
68534
68535 retval = security_task_setnice(current, nice);
68536 @@ -4041,6 +4044,7 @@ recheck:
68537 unsigned long rlim_rtprio =
68538 task_rlimit(p, RLIMIT_RTPRIO);
68539
68540 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
68541 /* can't set/change the rt policy */
68542 if (policy != p->policy && !rlim_rtprio)
68543 return -EPERM;
68544 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
68545 index aca16b8..8e3acc4 100644
68546 --- a/kernel/sched/fair.c
68547 +++ b/kernel/sched/fair.c
68548 @@ -5147,7 +5147,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
68549 * run_rebalance_domains is triggered when needed from the scheduler tick.
68550 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
68551 */
68552 -static void run_rebalance_domains(struct softirq_action *h)
68553 +static void run_rebalance_domains(void)
68554 {
68555 int this_cpu = smp_processor_id();
68556 struct rq *this_rq = cpu_rq(this_cpu);
68557 diff --git a/kernel/signal.c b/kernel/signal.c
68558 index b09cf3b..b291c66 100644
68559 --- a/kernel/signal.c
68560 +++ b/kernel/signal.c
68561 @@ -46,12 +46,12 @@ static struct kmem_cache *sigqueue_cachep;
68562
68563 int print_fatal_signals __read_mostly;
68564
68565 -static void __user *sig_handler(struct task_struct *t, int sig)
68566 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
68567 {
68568 return t->sighand->action[sig - 1].sa.sa_handler;
68569 }
68570
68571 -static int sig_handler_ignored(void __user *handler, int sig)
68572 +static int sig_handler_ignored(__sighandler_t handler, int sig)
68573 {
68574 /* Is it explicitly or implicitly ignored? */
68575 return handler == SIG_IGN ||
68576 @@ -61,7 +61,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
68577 static int sig_task_ignored(struct task_struct *t, int sig,
68578 int from_ancestor_ns)
68579 {
68580 - void __user *handler;
68581 + __sighandler_t handler;
68582
68583 handler = sig_handler(t, sig);
68584
68585 @@ -365,6 +365,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
68586 atomic_inc(&user->sigpending);
68587 rcu_read_unlock();
68588
68589 + if (!override_rlimit)
68590 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
68591 +
68592 if (override_rlimit ||
68593 atomic_read(&user->sigpending) <=
68594 task_rlimit(t, RLIMIT_SIGPENDING)) {
68595 @@ -489,7 +492,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
68596
68597 int unhandled_signal(struct task_struct *tsk, int sig)
68598 {
68599 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
68600 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
68601 if (is_global_init(tsk))
68602 return 1;
68603 if (handler != SIG_IGN && handler != SIG_DFL)
68604 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
68605 }
68606 }
68607
68608 + /* allow glibc communication via tgkill to other threads in our
68609 + thread group */
68610 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
68611 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
68612 + && gr_handle_signal(t, sig))
68613 + return -EPERM;
68614 +
68615 return security_task_kill(t, info, sig, 0);
68616 }
68617
68618 @@ -1197,7 +1207,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
68619 return send_signal(sig, info, p, 1);
68620 }
68621
68622 -static int
68623 +int
68624 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
68625 {
68626 return send_signal(sig, info, t, 0);
68627 @@ -1234,6 +1244,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
68628 unsigned long int flags;
68629 int ret, blocked, ignored;
68630 struct k_sigaction *action;
68631 + int is_unhandled = 0;
68632
68633 spin_lock_irqsave(&t->sighand->siglock, flags);
68634 action = &t->sighand->action[sig-1];
68635 @@ -1248,9 +1259,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
68636 }
68637 if (action->sa.sa_handler == SIG_DFL)
68638 t->signal->flags &= ~SIGNAL_UNKILLABLE;
68639 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
68640 + is_unhandled = 1;
68641 ret = specific_send_sig_info(sig, info, t);
68642 spin_unlock_irqrestore(&t->sighand->siglock, flags);
68643
68644 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
68645 + normal operation */
68646 + if (is_unhandled) {
68647 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
68648 + gr_handle_crash(t, sig);
68649 + }
68650 +
68651 return ret;
68652 }
68653
68654 @@ -1317,8 +1337,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
68655 ret = check_kill_permission(sig, info, p);
68656 rcu_read_unlock();
68657
68658 - if (!ret && sig)
68659 + if (!ret && sig) {
68660 ret = do_send_sig_info(sig, info, p, true);
68661 + if (!ret)
68662 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
68663 + }
68664
68665 return ret;
68666 }
68667 @@ -2829,7 +2852,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
68668 int error = -ESRCH;
68669
68670 rcu_read_lock();
68671 - p = find_task_by_vpid(pid);
68672 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68673 + /* allow glibc communication via tgkill to other threads in our
68674 + thread group */
68675 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
68676 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
68677 + p = find_task_by_vpid_unrestricted(pid);
68678 + else
68679 +#endif
68680 + p = find_task_by_vpid(pid);
68681 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
68682 error = check_kill_permission(sig, info, p);
68683 /*
68684 diff --git a/kernel/smp.c b/kernel/smp.c
68685 index db197d6..17aef0b 100644
68686 --- a/kernel/smp.c
68687 +++ b/kernel/smp.c
68688 @@ -580,22 +580,22 @@ int smp_call_function(smp_call_func_t func, void *info, int wait)
68689 }
68690 EXPORT_SYMBOL(smp_call_function);
68691
68692 -void ipi_call_lock(void)
68693 +void ipi_call_lock(void) __acquires(call_function.lock)
68694 {
68695 raw_spin_lock(&call_function.lock);
68696 }
68697
68698 -void ipi_call_unlock(void)
68699 +void ipi_call_unlock(void) __releases(call_function.lock)
68700 {
68701 raw_spin_unlock(&call_function.lock);
68702 }
68703
68704 -void ipi_call_lock_irq(void)
68705 +void ipi_call_lock_irq(void) __acquires(call_function.lock)
68706 {
68707 raw_spin_lock_irq(&call_function.lock);
68708 }
68709
68710 -void ipi_call_unlock_irq(void)
68711 +void ipi_call_unlock_irq(void) __releases(call_function.lock)
68712 {
68713 raw_spin_unlock_irq(&call_function.lock);
68714 }
68715 diff --git a/kernel/softirq.c b/kernel/softirq.c
68716 index 4eb3a0f..6f1fa81 100644
68717 --- a/kernel/softirq.c
68718 +++ b/kernel/softirq.c
68719 @@ -56,7 +56,7 @@ static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp
68720
68721 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
68722
68723 -char *softirq_to_name[NR_SOFTIRQS] = {
68724 +const char * const softirq_to_name[NR_SOFTIRQS] = {
68725 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
68726 "TASKLET", "SCHED", "HRTIMER", "RCU"
68727 };
68728 @@ -235,7 +235,7 @@ restart:
68729 kstat_incr_softirqs_this_cpu(vec_nr);
68730
68731 trace_softirq_entry(vec_nr);
68732 - h->action(h);
68733 + h->action();
68734 trace_softirq_exit(vec_nr);
68735 if (unlikely(prev_count != preempt_count())) {
68736 printk(KERN_ERR "huh, entered softirq %u %s %p"
68737 @@ -385,9 +385,11 @@ void raise_softirq(unsigned int nr)
68738 local_irq_restore(flags);
68739 }
68740
68741 -void open_softirq(int nr, void (*action)(struct softirq_action *))
68742 +void open_softirq(int nr, void (*action)(void))
68743 {
68744 - softirq_vec[nr].action = action;
68745 + pax_open_kernel();
68746 + *(void **)&softirq_vec[nr].action = action;
68747 + pax_close_kernel();
68748 }
68749
68750 /*
68751 @@ -441,7 +443,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
68752
68753 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
68754
68755 -static void tasklet_action(struct softirq_action *a)
68756 +static void tasklet_action(void)
68757 {
68758 struct tasklet_struct *list;
68759
68760 @@ -476,7 +478,7 @@ static void tasklet_action(struct softirq_action *a)
68761 }
68762 }
68763
68764 -static void tasklet_hi_action(struct softirq_action *a)
68765 +static void tasklet_hi_action(void)
68766 {
68767 struct tasklet_struct *list;
68768
68769 diff --git a/kernel/sys.c b/kernel/sys.c
68770 index 888d227..f04b318 100644
68771 --- a/kernel/sys.c
68772 +++ b/kernel/sys.c
68773 @@ -158,6 +158,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
68774 error = -EACCES;
68775 goto out;
68776 }
68777 +
68778 + if (gr_handle_chroot_setpriority(p, niceval)) {
68779 + error = -EACCES;
68780 + goto out;
68781 + }
68782 +
68783 no_nice = security_task_setnice(p, niceval);
68784 if (no_nice) {
68785 error = no_nice;
68786 @@ -572,6 +578,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
68787 goto error;
68788 }
68789
68790 + if (gr_check_group_change(new->gid, new->egid, -1))
68791 + goto error;
68792 +
68793 if (rgid != (gid_t) -1 ||
68794 (egid != (gid_t) -1 && egid != old->gid))
68795 new->sgid = new->egid;
68796 @@ -601,6 +610,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
68797 old = current_cred();
68798
68799 retval = -EPERM;
68800 +
68801 + if (gr_check_group_change(gid, gid, gid))
68802 + goto error;
68803 +
68804 if (nsown_capable(CAP_SETGID))
68805 new->gid = new->egid = new->sgid = new->fsgid = gid;
68806 else if (gid == old->gid || gid == old->sgid)
68807 @@ -618,7 +631,7 @@ error:
68808 /*
68809 * change the user struct in a credentials set to match the new UID
68810 */
68811 -static int set_user(struct cred *new)
68812 +int set_user(struct cred *new)
68813 {
68814 struct user_struct *new_user;
68815
68816 @@ -688,6 +701,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
68817 goto error;
68818 }
68819
68820 + if (gr_check_user_change(new->uid, new->euid, -1))
68821 + goto error;
68822 +
68823 if (new->uid != old->uid) {
68824 retval = set_user(new);
68825 if (retval < 0)
68826 @@ -732,6 +748,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
68827 old = current_cred();
68828
68829 retval = -EPERM;
68830 +
68831 + if (gr_check_crash_uid(uid))
68832 + goto error;
68833 + if (gr_check_user_change(uid, uid, uid))
68834 + goto error;
68835 +
68836 if (nsown_capable(CAP_SETUID)) {
68837 new->suid = new->uid = uid;
68838 if (uid != old->uid) {
68839 @@ -786,6 +808,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
68840 goto error;
68841 }
68842
68843 + if (gr_check_user_change(ruid, euid, -1))
68844 + goto error;
68845 +
68846 if (ruid != (uid_t) -1) {
68847 new->uid = ruid;
68848 if (ruid != old->uid) {
68849 @@ -850,6 +875,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
68850 goto error;
68851 }
68852
68853 + if (gr_check_group_change(rgid, egid, -1))
68854 + goto error;
68855 +
68856 if (rgid != (gid_t) -1)
68857 new->gid = rgid;
68858 if (egid != (gid_t) -1)
68859 @@ -896,6 +924,9 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
68860 old = current_cred();
68861 old_fsuid = old->fsuid;
68862
68863 + if (gr_check_user_change(-1, -1, uid))
68864 + goto error;
68865 +
68866 if (uid == old->uid || uid == old->euid ||
68867 uid == old->suid || uid == old->fsuid ||
68868 nsown_capable(CAP_SETUID)) {
68869 @@ -906,6 +937,7 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
68870 }
68871 }
68872
68873 +error:
68874 abort_creds(new);
68875 return old_fsuid;
68876
68877 @@ -932,12 +964,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
68878 if (gid == old->gid || gid == old->egid ||
68879 gid == old->sgid || gid == old->fsgid ||
68880 nsown_capable(CAP_SETGID)) {
68881 + if (gr_check_group_change(-1, -1, gid))
68882 + goto error;
68883 +
68884 if (gid != old_fsgid) {
68885 new->fsgid = gid;
68886 goto change_okay;
68887 }
68888 }
68889
68890 +error:
68891 abort_creds(new);
68892 return old_fsgid;
68893
68894 @@ -1189,7 +1225,10 @@ static int override_release(char __user *release, int len)
68895 }
68896 v = ((LINUX_VERSION_CODE >> 8) & 0xff) + 40;
68897 snprintf(buf, len, "2.6.%u%s", v, rest);
68898 - ret = copy_to_user(release, buf, len);
68899 + if (len > sizeof(buf))
68900 + ret = -EFAULT;
68901 + else
68902 + ret = copy_to_user(release, buf, len);
68903 }
68904 return ret;
68905 }
68906 @@ -1243,19 +1282,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
68907 return -EFAULT;
68908
68909 down_read(&uts_sem);
68910 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
68911 + error = __copy_to_user(name->sysname, &utsname()->sysname,
68912 __OLD_UTS_LEN);
68913 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
68914 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
68915 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
68916 __OLD_UTS_LEN);
68917 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
68918 - error |= __copy_to_user(&name->release, &utsname()->release,
68919 + error |= __copy_to_user(name->release, &utsname()->release,
68920 __OLD_UTS_LEN);
68921 error |= __put_user(0, name->release + __OLD_UTS_LEN);
68922 - error |= __copy_to_user(&name->version, &utsname()->version,
68923 + error |= __copy_to_user(name->version, &utsname()->version,
68924 __OLD_UTS_LEN);
68925 error |= __put_user(0, name->version + __OLD_UTS_LEN);
68926 - error |= __copy_to_user(&name->machine, &utsname()->machine,
68927 + error |= __copy_to_user(name->machine, &utsname()->machine,
68928 __OLD_UTS_LEN);
68929 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
68930 up_read(&uts_sem);
68931 @@ -1838,7 +1877,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
68932 error = get_dumpable(me->mm);
68933 break;
68934 case PR_SET_DUMPABLE:
68935 - if (arg2 < 0 || arg2 > 1) {
68936 + if (arg2 > 1) {
68937 error = -EINVAL;
68938 break;
68939 }
68940 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
68941 index f03a6ef..735d95c 100644
68942 --- a/kernel/sysctl.c
68943 +++ b/kernel/sysctl.c
68944 @@ -86,6 +86,13 @@
68945
68946
68947 #if defined(CONFIG_SYSCTL)
68948 +#include <linux/grsecurity.h>
68949 +#include <linux/grinternal.h>
68950 +
68951 +extern __u32 gr_handle_sysctl(const ctl_table *table, const int op);
68952 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
68953 + const int op);
68954 +extern int gr_handle_chroot_sysctl(const int op);
68955
68956 /* External variables not in a header file. */
68957 extern int sysctl_overcommit_memory;
68958 @@ -165,10 +172,8 @@ static int proc_taint(struct ctl_table *table, int write,
68959 void __user *buffer, size_t *lenp, loff_t *ppos);
68960 #endif
68961
68962 -#ifdef CONFIG_PRINTK
68963 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
68964 void __user *buffer, size_t *lenp, loff_t *ppos);
68965 -#endif
68966
68967 #ifdef CONFIG_MAGIC_SYSRQ
68968 /* Note: sysrq code uses it's own private copy */
68969 @@ -191,6 +196,7 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
68970 }
68971
68972 #endif
68973 +extern struct ctl_table grsecurity_table[];
68974
68975 static struct ctl_table root_table[];
68976 static struct ctl_table_root sysctl_table_root;
68977 @@ -220,6 +226,20 @@ extern struct ctl_table epoll_table[];
68978 int sysctl_legacy_va_layout;
68979 #endif
68980
68981 +#ifdef CONFIG_PAX_SOFTMODE
68982 +static ctl_table pax_table[] = {
68983 + {
68984 + .procname = "softmode",
68985 + .data = &pax_softmode,
68986 + .maxlen = sizeof(unsigned int),
68987 + .mode = 0600,
68988 + .proc_handler = &proc_dointvec,
68989 + },
68990 +
68991 + { }
68992 +};
68993 +#endif
68994 +
68995 /* The default sysctl tables: */
68996
68997 static struct ctl_table root_table[] = {
68998 @@ -266,6 +286,22 @@ static int max_extfrag_threshold = 1000;
68999 #endif
69000
69001 static struct ctl_table kern_table[] = {
69002 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
69003 + {
69004 + .procname = "grsecurity",
69005 + .mode = 0500,
69006 + .child = grsecurity_table,
69007 + },
69008 +#endif
69009 +
69010 +#ifdef CONFIG_PAX_SOFTMODE
69011 + {
69012 + .procname = "pax",
69013 + .mode = 0500,
69014 + .child = pax_table,
69015 + },
69016 +#endif
69017 +
69018 {
69019 .procname = "sched_child_runs_first",
69020 .data = &sysctl_sched_child_runs_first,
69021 @@ -550,7 +586,7 @@ static struct ctl_table kern_table[] = {
69022 .data = &modprobe_path,
69023 .maxlen = KMOD_PATH_LEN,
69024 .mode = 0644,
69025 - .proc_handler = proc_dostring,
69026 + .proc_handler = proc_dostring_modpriv,
69027 },
69028 {
69029 .procname = "modules_disabled",
69030 @@ -717,16 +753,20 @@ static struct ctl_table kern_table[] = {
69031 .extra1 = &zero,
69032 .extra2 = &one,
69033 },
69034 +#endif
69035 {
69036 .procname = "kptr_restrict",
69037 .data = &kptr_restrict,
69038 .maxlen = sizeof(int),
69039 .mode = 0644,
69040 .proc_handler = proc_dointvec_minmax_sysadmin,
69041 +#ifdef CONFIG_GRKERNSEC_HIDESYM
69042 + .extra1 = &two,
69043 +#else
69044 .extra1 = &zero,
69045 +#endif
69046 .extra2 = &two,
69047 },
69048 -#endif
69049 {
69050 .procname = "ngroups_max",
69051 .data = &ngroups_max,
69052 @@ -1225,6 +1265,13 @@ static struct ctl_table vm_table[] = {
69053 .proc_handler = proc_dointvec_minmax,
69054 .extra1 = &zero,
69055 },
69056 + {
69057 + .procname = "heap_stack_gap",
69058 + .data = &sysctl_heap_stack_gap,
69059 + .maxlen = sizeof(sysctl_heap_stack_gap),
69060 + .mode = 0644,
69061 + .proc_handler = proc_doulongvec_minmax,
69062 + },
69063 #else
69064 {
69065 .procname = "nr_trim_pages",
69066 @@ -1729,6 +1776,17 @@ static int test_perm(int mode, int op)
69067 int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
69068 {
69069 int mode;
69070 + int error;
69071 +
69072 + if (table->parent != NULL && table->parent->procname != NULL &&
69073 + table->procname != NULL &&
69074 + gr_handle_sysctl_mod(table->parent->procname, table->procname, op))
69075 + return -EACCES;
69076 + if (gr_handle_chroot_sysctl(op))
69077 + return -EACCES;
69078 + error = gr_handle_sysctl(table, op);
69079 + if (error)
69080 + return error;
69081
69082 if (root->permissions)
69083 mode = root->permissions(root, current->nsproxy, table);
69084 @@ -2133,6 +2191,16 @@ int proc_dostring(struct ctl_table *table, int write,
69085 buffer, lenp, ppos);
69086 }
69087
69088 +int proc_dostring_modpriv(struct ctl_table *table, int write,
69089 + void __user *buffer, size_t *lenp, loff_t *ppos)
69090 +{
69091 + if (write && !capable(CAP_SYS_MODULE))
69092 + return -EPERM;
69093 +
69094 + return _proc_do_string(table->data, table->maxlen, write,
69095 + buffer, lenp, ppos);
69096 +}
69097 +
69098 static size_t proc_skip_spaces(char **buf)
69099 {
69100 size_t ret;
69101 @@ -2238,6 +2306,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
69102 len = strlen(tmp);
69103 if (len > *size)
69104 len = *size;
69105 + if (len > sizeof(tmp))
69106 + len = sizeof(tmp);
69107 if (copy_to_user(*buf, tmp, len))
69108 return -EFAULT;
69109 *size -= len;
69110 @@ -2430,7 +2500,6 @@ static int proc_taint(struct ctl_table *table, int write,
69111 return err;
69112 }
69113
69114 -#ifdef CONFIG_PRINTK
69115 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
69116 void __user *buffer, size_t *lenp, loff_t *ppos)
69117 {
69118 @@ -2439,7 +2508,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
69119
69120 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
69121 }
69122 -#endif
69123
69124 struct do_proc_dointvec_minmax_conv_param {
69125 int *min;
69126 @@ -2554,8 +2622,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
69127 *i = val;
69128 } else {
69129 val = convdiv * (*i) / convmul;
69130 - if (!first)
69131 + if (!first) {
69132 err = proc_put_char(&buffer, &left, '\t');
69133 + if (err)
69134 + break;
69135 + }
69136 err = proc_put_long(&buffer, &left, val, false);
69137 if (err)
69138 break;
69139 @@ -2950,6 +3021,12 @@ int proc_dostring(struct ctl_table *table, int write,
69140 return -ENOSYS;
69141 }
69142
69143 +int proc_dostring_modpriv(struct ctl_table *table, int write,
69144 + void __user *buffer, size_t *lenp, loff_t *ppos)
69145 +{
69146 + return -ENOSYS;
69147 +}
69148 +
69149 int proc_dointvec(struct ctl_table *table, int write,
69150 void __user *buffer, size_t *lenp, loff_t *ppos)
69151 {
69152 @@ -3006,6 +3083,7 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
69153 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
69154 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
69155 EXPORT_SYMBOL(proc_dostring);
69156 +EXPORT_SYMBOL(proc_dostring_modpriv);
69157 EXPORT_SYMBOL(proc_doulongvec_minmax);
69158 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
69159 EXPORT_SYMBOL(register_sysctl_table);
69160 diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c
69161 index a650694..aaeeb20 100644
69162 --- a/kernel/sysctl_binary.c
69163 +++ b/kernel/sysctl_binary.c
69164 @@ -989,7 +989,7 @@ static ssize_t bin_intvec(struct file *file,
69165 int i;
69166
69167 set_fs(KERNEL_DS);
69168 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
69169 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
69170 set_fs(old_fs);
69171 if (result < 0)
69172 goto out_kfree;
69173 @@ -1034,7 +1034,7 @@ static ssize_t bin_intvec(struct file *file,
69174 }
69175
69176 set_fs(KERNEL_DS);
69177 - result = vfs_write(file, buffer, str - buffer, &pos);
69178 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
69179 set_fs(old_fs);
69180 if (result < 0)
69181 goto out_kfree;
69182 @@ -1067,7 +1067,7 @@ static ssize_t bin_ulongvec(struct file *file,
69183 int i;
69184
69185 set_fs(KERNEL_DS);
69186 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
69187 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
69188 set_fs(old_fs);
69189 if (result < 0)
69190 goto out_kfree;
69191 @@ -1112,7 +1112,7 @@ static ssize_t bin_ulongvec(struct file *file,
69192 }
69193
69194 set_fs(KERNEL_DS);
69195 - result = vfs_write(file, buffer, str - buffer, &pos);
69196 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
69197 set_fs(old_fs);
69198 if (result < 0)
69199 goto out_kfree;
69200 @@ -1138,7 +1138,7 @@ static ssize_t bin_uuid(struct file *file,
69201 int i;
69202
69203 set_fs(KERNEL_DS);
69204 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
69205 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
69206 set_fs(old_fs);
69207 if (result < 0)
69208 goto out;
69209 @@ -1185,7 +1185,7 @@ static ssize_t bin_dn_node_address(struct file *file,
69210 __le16 dnaddr;
69211
69212 set_fs(KERNEL_DS);
69213 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
69214 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
69215 set_fs(old_fs);
69216 if (result < 0)
69217 goto out;
69218 @@ -1233,7 +1233,7 @@ static ssize_t bin_dn_node_address(struct file *file,
69219 le16_to_cpu(dnaddr) & 0x3ff);
69220
69221 set_fs(KERNEL_DS);
69222 - result = vfs_write(file, buf, len, &pos);
69223 + result = vfs_write(file, (const char __force_user *)buf, len, &pos);
69224 set_fs(old_fs);
69225 if (result < 0)
69226 goto out;
69227 diff --git a/kernel/sysctl_check.c b/kernel/sysctl_check.c
69228 index 362da65..ab8ef8c 100644
69229 --- a/kernel/sysctl_check.c
69230 +++ b/kernel/sysctl_check.c
69231 @@ -129,6 +129,7 @@ int sysctl_check_table(struct nsproxy *namespaces, struct ctl_table *table)
69232 set_fail(&fail, table, "Directory with extra2");
69233 } else {
69234 if ((table->proc_handler == proc_dostring) ||
69235 + (table->proc_handler == proc_dostring_modpriv) ||
69236 (table->proc_handler == proc_dointvec) ||
69237 (table->proc_handler == proc_dointvec_minmax) ||
69238 (table->proc_handler == proc_dointvec_jiffies) ||
69239 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
69240 index e660464..c8b9e67 100644
69241 --- a/kernel/taskstats.c
69242 +++ b/kernel/taskstats.c
69243 @@ -27,9 +27,12 @@
69244 #include <linux/cgroup.h>
69245 #include <linux/fs.h>
69246 #include <linux/file.h>
69247 +#include <linux/grsecurity.h>
69248 #include <net/genetlink.h>
69249 #include <linux/atomic.h>
69250
69251 +extern int gr_is_taskstats_denied(int pid);
69252 +
69253 /*
69254 * Maximum length of a cpumask that can be specified in
69255 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
69256 @@ -556,6 +559,9 @@ err:
69257
69258 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
69259 {
69260 + if (gr_is_taskstats_denied(current->pid))
69261 + return -EACCES;
69262 +
69263 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
69264 return cmd_attr_register_cpumask(info);
69265 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
69266 diff --git a/kernel/time.c b/kernel/time.c
69267 index 73e416d..cfc6f69 100644
69268 --- a/kernel/time.c
69269 +++ b/kernel/time.c
69270 @@ -163,6 +163,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
69271 return error;
69272
69273 if (tz) {
69274 + /* we log in do_settimeofday called below, so don't log twice
69275 + */
69276 + if (!tv)
69277 + gr_log_timechange();
69278 +
69279 /* SMP safe, global irq locking makes it work. */
69280 sys_tz = *tz;
69281 update_vsyscall_tz();
69282 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
69283 index 8a46f5d..bbe6f9c 100644
69284 --- a/kernel/time/alarmtimer.c
69285 +++ b/kernel/time/alarmtimer.c
69286 @@ -773,7 +773,7 @@ static int __init alarmtimer_init(void)
69287 struct platform_device *pdev;
69288 int error = 0;
69289 int i;
69290 - struct k_clock alarm_clock = {
69291 + static struct k_clock alarm_clock = {
69292 .clock_getres = alarm_clock_getres,
69293 .clock_get = alarm_clock_get,
69294 .timer_create = alarm_timer_create,
69295 diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
69296 index fd4a7b1..fae5c2a 100644
69297 --- a/kernel/time/tick-broadcast.c
69298 +++ b/kernel/time/tick-broadcast.c
69299 @@ -115,7 +115,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
69300 * then clear the broadcast bit.
69301 */
69302 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
69303 - int cpu = smp_processor_id();
69304 + cpu = smp_processor_id();
69305
69306 cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
69307 tick_broadcast_clear_oneshot(cpu);
69308 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
69309 index 0c63581..e25dcb6 100644
69310 --- a/kernel/time/timekeeping.c
69311 +++ b/kernel/time/timekeeping.c
69312 @@ -14,6 +14,7 @@
69313 #include <linux/init.h>
69314 #include <linux/mm.h>
69315 #include <linux/sched.h>
69316 +#include <linux/grsecurity.h>
69317 #include <linux/syscore_ops.h>
69318 #include <linux/clocksource.h>
69319 #include <linux/jiffies.h>
69320 @@ -365,6 +366,8 @@ int do_settimeofday(const struct timespec *tv)
69321 if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
69322 return -EINVAL;
69323
69324 + gr_log_timechange();
69325 +
69326 write_seqlock_irqsave(&xtime_lock, flags);
69327
69328 timekeeping_forward_now();
69329 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
69330 index 3258455..f35227d 100644
69331 --- a/kernel/time/timer_list.c
69332 +++ b/kernel/time/timer_list.c
69333 @@ -38,12 +38,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
69334
69335 static void print_name_offset(struct seq_file *m, void *sym)
69336 {
69337 +#ifdef CONFIG_GRKERNSEC_HIDESYM
69338 + SEQ_printf(m, "<%p>", NULL);
69339 +#else
69340 char symname[KSYM_NAME_LEN];
69341
69342 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
69343 SEQ_printf(m, "<%pK>", sym);
69344 else
69345 SEQ_printf(m, "%s", symname);
69346 +#endif
69347 }
69348
69349 static void
69350 @@ -112,7 +116,11 @@ next_one:
69351 static void
69352 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
69353 {
69354 +#ifdef CONFIG_GRKERNSEC_HIDESYM
69355 + SEQ_printf(m, " .base: %p\n", NULL);
69356 +#else
69357 SEQ_printf(m, " .base: %pK\n", base);
69358 +#endif
69359 SEQ_printf(m, " .index: %d\n",
69360 base->index);
69361 SEQ_printf(m, " .resolution: %Lu nsecs\n",
69362 @@ -293,7 +301,11 @@ static int __init init_timer_list_procfs(void)
69363 {
69364 struct proc_dir_entry *pe;
69365
69366 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
69367 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
69368 +#else
69369 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
69370 +#endif
69371 if (!pe)
69372 return -ENOMEM;
69373 return 0;
69374 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
69375 index 0b537f2..9e71eca 100644
69376 --- a/kernel/time/timer_stats.c
69377 +++ b/kernel/time/timer_stats.c
69378 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
69379 static unsigned long nr_entries;
69380 static struct entry entries[MAX_ENTRIES];
69381
69382 -static atomic_t overflow_count;
69383 +static atomic_unchecked_t overflow_count;
69384
69385 /*
69386 * The entries are in a hash-table, for fast lookup:
69387 @@ -140,7 +140,7 @@ static void reset_entries(void)
69388 nr_entries = 0;
69389 memset(entries, 0, sizeof(entries));
69390 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
69391 - atomic_set(&overflow_count, 0);
69392 + atomic_set_unchecked(&overflow_count, 0);
69393 }
69394
69395 static struct entry *alloc_entry(void)
69396 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
69397 if (likely(entry))
69398 entry->count++;
69399 else
69400 - atomic_inc(&overflow_count);
69401 + atomic_inc_unchecked(&overflow_count);
69402
69403 out_unlock:
69404 raw_spin_unlock_irqrestore(lock, flags);
69405 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
69406
69407 static void print_name_offset(struct seq_file *m, unsigned long addr)
69408 {
69409 +#ifdef CONFIG_GRKERNSEC_HIDESYM
69410 + seq_printf(m, "<%p>", NULL);
69411 +#else
69412 char symname[KSYM_NAME_LEN];
69413
69414 if (lookup_symbol_name(addr, symname) < 0)
69415 seq_printf(m, "<%p>", (void *)addr);
69416 else
69417 seq_printf(m, "%s", symname);
69418 +#endif
69419 }
69420
69421 static int tstats_show(struct seq_file *m, void *v)
69422 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
69423
69424 seq_puts(m, "Timer Stats Version: v0.2\n");
69425 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
69426 - if (atomic_read(&overflow_count))
69427 + if (atomic_read_unchecked(&overflow_count))
69428 seq_printf(m, "Overflow: %d entries\n",
69429 - atomic_read(&overflow_count));
69430 + atomic_read_unchecked(&overflow_count));
69431
69432 for (i = 0; i < nr_entries; i++) {
69433 entry = entries + i;
69434 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
69435 {
69436 struct proc_dir_entry *pe;
69437
69438 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
69439 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
69440 +#else
69441 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
69442 +#endif
69443 if (!pe)
69444 return -ENOMEM;
69445 return 0;
69446 diff --git a/kernel/timer.c b/kernel/timer.c
69447 index a297ffc..5e16b0b 100644
69448 --- a/kernel/timer.c
69449 +++ b/kernel/timer.c
69450 @@ -1354,7 +1354,7 @@ void update_process_times(int user_tick)
69451 /*
69452 * This function runs timers and the timer-tq in bottom half context.
69453 */
69454 -static void run_timer_softirq(struct softirq_action *h)
69455 +static void run_timer_softirq(void)
69456 {
69457 struct tvec_base *base = __this_cpu_read(tvec_bases);
69458
69459 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
69460 index cdea7b5..9b820d4 100644
69461 --- a/kernel/trace/blktrace.c
69462 +++ b/kernel/trace/blktrace.c
69463 @@ -324,7 +324,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
69464 struct blk_trace *bt = filp->private_data;
69465 char buf[16];
69466
69467 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
69468 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
69469
69470 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
69471 }
69472 @@ -389,7 +389,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
69473 return 1;
69474
69475 bt = buf->chan->private_data;
69476 - atomic_inc(&bt->dropped);
69477 + atomic_inc_unchecked(&bt->dropped);
69478 return 0;
69479 }
69480
69481 @@ -490,7 +490,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
69482
69483 bt->dir = dir;
69484 bt->dev = dev;
69485 - atomic_set(&bt->dropped, 0);
69486 + atomic_set_unchecked(&bt->dropped, 0);
69487
69488 ret = -EIO;
69489 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
69490 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
69491 index 683d559..d70d914 100644
69492 --- a/kernel/trace/ftrace.c
69493 +++ b/kernel/trace/ftrace.c
69494 @@ -1726,12 +1726,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
69495 if (unlikely(ftrace_disabled))
69496 return 0;
69497
69498 + ret = ftrace_arch_code_modify_prepare();
69499 + FTRACE_WARN_ON(ret);
69500 + if (ret)
69501 + return 0;
69502 +
69503 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
69504 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
69505 if (ret) {
69506 ftrace_bug(ret, ip);
69507 - return 0;
69508 }
69509 - return 1;
69510 + return ret ? 0 : 1;
69511 }
69512
69513 /*
69514 @@ -2843,7 +2848,7 @@ static void ftrace_free_entry_rcu(struct rcu_head *rhp)
69515
69516 int
69517 register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
69518 - void *data)
69519 + void *data)
69520 {
69521 struct ftrace_func_probe *entry;
69522 struct ftrace_page *pg;
69523 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
69524 index c4579f1..6a439da 100644
69525 --- a/kernel/trace/trace.c
69526 +++ b/kernel/trace/trace.c
69527 @@ -4258,10 +4258,9 @@ static const struct file_operations tracing_dyn_info_fops = {
69528 };
69529 #endif
69530
69531 -static struct dentry *d_tracer;
69532 -
69533 struct dentry *tracing_init_dentry(void)
69534 {
69535 + static struct dentry *d_tracer;
69536 static int once;
69537
69538 if (d_tracer)
69539 @@ -4281,10 +4280,9 @@ struct dentry *tracing_init_dentry(void)
69540 return d_tracer;
69541 }
69542
69543 -static struct dentry *d_percpu;
69544 -
69545 struct dentry *tracing_dentry_percpu(void)
69546 {
69547 + static struct dentry *d_percpu;
69548 static int once;
69549 struct dentry *d_tracer;
69550
69551 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
69552 index c212a7f..7b02394 100644
69553 --- a/kernel/trace/trace_events.c
69554 +++ b/kernel/trace/trace_events.c
69555 @@ -1299,10 +1299,6 @@ static LIST_HEAD(ftrace_module_file_list);
69556 struct ftrace_module_file_ops {
69557 struct list_head list;
69558 struct module *mod;
69559 - struct file_operations id;
69560 - struct file_operations enable;
69561 - struct file_operations format;
69562 - struct file_operations filter;
69563 };
69564
69565 static struct ftrace_module_file_ops *
69566 @@ -1323,17 +1319,12 @@ trace_create_file_ops(struct module *mod)
69567
69568 file_ops->mod = mod;
69569
69570 - file_ops->id = ftrace_event_id_fops;
69571 - file_ops->id.owner = mod;
69572 -
69573 - file_ops->enable = ftrace_enable_fops;
69574 - file_ops->enable.owner = mod;
69575 -
69576 - file_ops->filter = ftrace_event_filter_fops;
69577 - file_ops->filter.owner = mod;
69578 -
69579 - file_ops->format = ftrace_event_format_fops;
69580 - file_ops->format.owner = mod;
69581 + pax_open_kernel();
69582 + *(void **)&mod->trace_id.owner = mod;
69583 + *(void **)&mod->trace_enable.owner = mod;
69584 + *(void **)&mod->trace_filter.owner = mod;
69585 + *(void **)&mod->trace_format.owner = mod;
69586 + pax_close_kernel();
69587
69588 list_add(&file_ops->list, &ftrace_module_file_list);
69589
69590 @@ -1357,8 +1348,8 @@ static void trace_module_add_events(struct module *mod)
69591
69592 for_each_event(call, start, end) {
69593 __trace_add_event_call(*call, mod,
69594 - &file_ops->id, &file_ops->enable,
69595 - &file_ops->filter, &file_ops->format);
69596 + &mod->trace_id, &mod->trace_enable,
69597 + &mod->trace_filter, &mod->trace_format);
69598 }
69599 }
69600
69601 diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
69602 index 00d527c..7c5b1a3 100644
69603 --- a/kernel/trace/trace_kprobe.c
69604 +++ b/kernel/trace/trace_kprobe.c
69605 @@ -217,7 +217,7 @@ static __kprobes void FETCH_FUNC_NAME(memory, string)(struct pt_regs *regs,
69606 long ret;
69607 int maxlen = get_rloc_len(*(u32 *)dest);
69608 u8 *dst = get_rloc_data(dest);
69609 - u8 *src = addr;
69610 + const u8 __user *src = (const u8 __force_user *)addr;
69611 mm_segment_t old_fs = get_fs();
69612 if (!maxlen)
69613 return;
69614 @@ -229,7 +229,7 @@ static __kprobes void FETCH_FUNC_NAME(memory, string)(struct pt_regs *regs,
69615 pagefault_disable();
69616 do
69617 ret = __copy_from_user_inatomic(dst++, src++, 1);
69618 - while (dst[-1] && ret == 0 && src - (u8 *)addr < maxlen);
69619 + while (dst[-1] && ret == 0 && src - (const u8 __force_user *)addr < maxlen);
69620 dst[-1] = '\0';
69621 pagefault_enable();
69622 set_fs(old_fs);
69623 @@ -238,7 +238,7 @@ static __kprobes void FETCH_FUNC_NAME(memory, string)(struct pt_regs *regs,
69624 ((u8 *)get_rloc_data(dest))[0] = '\0';
69625 *(u32 *)dest = make_data_rloc(0, get_rloc_offs(*(u32 *)dest));
69626 } else
69627 - *(u32 *)dest = make_data_rloc(src - (u8 *)addr,
69628 + *(u32 *)dest = make_data_rloc(src - (const u8 __force_user *)addr,
69629 get_rloc_offs(*(u32 *)dest));
69630 }
69631 /* Return the length of string -- including null terminal byte */
69632 @@ -252,7 +252,7 @@ static __kprobes void FETCH_FUNC_NAME(memory, string_size)(struct pt_regs *regs,
69633 set_fs(KERNEL_DS);
69634 pagefault_disable();
69635 do {
69636 - ret = __copy_from_user_inatomic(&c, (u8 *)addr + len, 1);
69637 + ret = __copy_from_user_inatomic(&c, (const u8 __force_user *)addr + len, 1);
69638 len++;
69639 } while (c && ret == 0 && len < MAX_STRING_SIZE);
69640 pagefault_enable();
69641 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
69642 index fd3c8aa..5f324a6 100644
69643 --- a/kernel/trace/trace_mmiotrace.c
69644 +++ b/kernel/trace/trace_mmiotrace.c
69645 @@ -24,7 +24,7 @@ struct header_iter {
69646 static struct trace_array *mmio_trace_array;
69647 static bool overrun_detected;
69648 static unsigned long prev_overruns;
69649 -static atomic_t dropped_count;
69650 +static atomic_unchecked_t dropped_count;
69651
69652 static void mmio_reset_data(struct trace_array *tr)
69653 {
69654 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
69655
69656 static unsigned long count_overruns(struct trace_iterator *iter)
69657 {
69658 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
69659 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
69660 unsigned long over = ring_buffer_overruns(iter->tr->buffer);
69661
69662 if (over > prev_overruns)
69663 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
69664 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
69665 sizeof(*entry), 0, pc);
69666 if (!event) {
69667 - atomic_inc(&dropped_count);
69668 + atomic_inc_unchecked(&dropped_count);
69669 return;
69670 }
69671 entry = ring_buffer_event_data(event);
69672 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
69673 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
69674 sizeof(*entry), 0, pc);
69675 if (!event) {
69676 - atomic_inc(&dropped_count);
69677 + atomic_inc_unchecked(&dropped_count);
69678 return;
69679 }
69680 entry = ring_buffer_event_data(event);
69681 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
69682 index d9c07f0..c1eeceb 100644
69683 --- a/kernel/trace/trace_output.c
69684 +++ b/kernel/trace/trace_output.c
69685 @@ -278,7 +278,7 @@ int trace_seq_path(struct trace_seq *s, struct path *path)
69686
69687 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
69688 if (!IS_ERR(p)) {
69689 - p = mangle_path(s->buffer + s->len, p, "\n");
69690 + p = mangle_path(s->buffer + s->len, p, "\n\\");
69691 if (p) {
69692 s->len = p - s->buffer;
69693 return 1;
69694 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
69695 index d4545f4..a9010a1 100644
69696 --- a/kernel/trace/trace_stack.c
69697 +++ b/kernel/trace/trace_stack.c
69698 @@ -53,7 +53,7 @@ static inline void check_stack(void)
69699 return;
69700
69701 /* we do not handle interrupt stacks yet */
69702 - if (!object_is_on_stack(&this_size))
69703 + if (!object_starts_on_stack(&this_size))
69704 return;
69705
69706 local_irq_save(flags);
69707 diff --git a/kernel/trace/trace_workqueue.c b/kernel/trace/trace_workqueue.c
69708 index 209b379..7f76423 100644
69709 --- a/kernel/trace/trace_workqueue.c
69710 +++ b/kernel/trace/trace_workqueue.c
69711 @@ -22,7 +22,7 @@ struct cpu_workqueue_stats {
69712 int cpu;
69713 pid_t pid;
69714 /* Can be inserted from interrupt or user context, need to be atomic */
69715 - atomic_t inserted;
69716 + atomic_unchecked_t inserted;
69717 /*
69718 * Don't need to be atomic, works are serialized in a single workqueue thread
69719 * on a single CPU.
69720 @@ -60,7 +60,7 @@ probe_workqueue_insertion(void *ignore,
69721 spin_lock_irqsave(&workqueue_cpu_stat(cpu)->lock, flags);
69722 list_for_each_entry(node, &workqueue_cpu_stat(cpu)->list, list) {
69723 if (node->pid == wq_thread->pid) {
69724 - atomic_inc(&node->inserted);
69725 + atomic_inc_unchecked(&node->inserted);
69726 goto found;
69727 }
69728 }
69729 @@ -210,7 +210,7 @@ static int workqueue_stat_show(struct seq_file *s, void *p)
69730 tsk = get_pid_task(pid, PIDTYPE_PID);
69731 if (tsk) {
69732 seq_printf(s, "%3d %6d %6u %s\n", cws->cpu,
69733 - atomic_read(&cws->inserted), cws->executed,
69734 + atomic_read_unchecked(&cws->inserted), cws->executed,
69735 tsk->comm);
69736 put_task_struct(tsk);
69737 }
69738 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
69739 index 8745ac7..d144e37 100644
69740 --- a/lib/Kconfig.debug
69741 +++ b/lib/Kconfig.debug
69742 @@ -1103,6 +1103,7 @@ config LATENCYTOP
69743 depends on DEBUG_KERNEL
69744 depends on STACKTRACE_SUPPORT
69745 depends on PROC_FS
69746 + depends on !GRKERNSEC_HIDESYM
69747 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
69748 select KALLSYMS
69749 select KALLSYMS_ALL
69750 diff --git a/lib/bitmap.c b/lib/bitmap.c
69751 index 0d4a127..33a06c7 100644
69752 --- a/lib/bitmap.c
69753 +++ b/lib/bitmap.c
69754 @@ -419,7 +419,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
69755 {
69756 int c, old_c, totaldigits, ndigits, nchunks, nbits;
69757 u32 chunk;
69758 - const char __user __force *ubuf = (const char __user __force *)buf;
69759 + const char __user *ubuf = (const char __force_user *)buf;
69760
69761 bitmap_zero(maskp, nmaskbits);
69762
69763 @@ -504,7 +504,7 @@ int bitmap_parse_user(const char __user *ubuf,
69764 {
69765 if (!access_ok(VERIFY_READ, ubuf, ulen))
69766 return -EFAULT;
69767 - return __bitmap_parse((const char __force *)ubuf,
69768 + return __bitmap_parse((const char __force_kernel *)ubuf,
69769 ulen, 1, maskp, nmaskbits);
69770
69771 }
69772 @@ -596,7 +596,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
69773 {
69774 unsigned a, b;
69775 int c, old_c, totaldigits;
69776 - const char __user __force *ubuf = (const char __user __force *)buf;
69777 + const char __user *ubuf = (const char __force_user *)buf;
69778 int exp_digit, in_range;
69779
69780 totaldigits = c = 0;
69781 @@ -696,7 +696,7 @@ int bitmap_parselist_user(const char __user *ubuf,
69782 {
69783 if (!access_ok(VERIFY_READ, ubuf, ulen))
69784 return -EFAULT;
69785 - return __bitmap_parselist((const char __force *)ubuf,
69786 + return __bitmap_parselist((const char __force_kernel *)ubuf,
69787 ulen, 1, maskp, nmaskbits);
69788 }
69789 EXPORT_SYMBOL(bitmap_parselist_user);
69790 diff --git a/lib/bug.c b/lib/bug.c
69791 index a28c141..2bd3d95 100644
69792 --- a/lib/bug.c
69793 +++ b/lib/bug.c
69794 @@ -133,6 +133,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
69795 return BUG_TRAP_TYPE_NONE;
69796
69797 bug = find_bug(bugaddr);
69798 + if (!bug)
69799 + return BUG_TRAP_TYPE_NONE;
69800
69801 file = NULL;
69802 line = 0;
69803 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
69804 index 0ab9ae8..f01ceca 100644
69805 --- a/lib/debugobjects.c
69806 +++ b/lib/debugobjects.c
69807 @@ -288,7 +288,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
69808 if (limit > 4)
69809 return;
69810
69811 - is_on_stack = object_is_on_stack(addr);
69812 + is_on_stack = object_starts_on_stack(addr);
69813 if (is_on_stack == onstack)
69814 return;
69815
69816 diff --git a/lib/devres.c b/lib/devres.c
69817 index 9676617..5149e15 100644
69818 --- a/lib/devres.c
69819 +++ b/lib/devres.c
69820 @@ -80,7 +80,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
69821 void devm_iounmap(struct device *dev, void __iomem *addr)
69822 {
69823 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
69824 - (void *)addr));
69825 + (void __force *)addr));
69826 iounmap(addr);
69827 }
69828 EXPORT_SYMBOL(devm_iounmap);
69829 @@ -192,7 +192,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
69830 {
69831 ioport_unmap(addr);
69832 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
69833 - devm_ioport_map_match, (void *)addr));
69834 + devm_ioport_map_match, (void __force *)addr));
69835 }
69836 EXPORT_SYMBOL(devm_ioport_unmap);
69837
69838 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
69839 index fea790a..ebb0e82 100644
69840 --- a/lib/dma-debug.c
69841 +++ b/lib/dma-debug.c
69842 @@ -925,7 +925,7 @@ out:
69843
69844 static void check_for_stack(struct device *dev, void *addr)
69845 {
69846 - if (object_is_on_stack(addr))
69847 + if (object_starts_on_stack(addr))
69848 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
69849 "stack [addr=%p]\n", addr);
69850 }
69851 diff --git a/lib/extable.c b/lib/extable.c
69852 index 4cac81e..63e9b8f 100644
69853 --- a/lib/extable.c
69854 +++ b/lib/extable.c
69855 @@ -13,6 +13,7 @@
69856 #include <linux/init.h>
69857 #include <linux/sort.h>
69858 #include <asm/uaccess.h>
69859 +#include <asm/pgtable.h>
69860
69861 #ifndef ARCH_HAS_SORT_EXTABLE
69862 /*
69863 @@ -36,8 +37,10 @@ static int cmp_ex(const void *a, const void *b)
69864 void sort_extable(struct exception_table_entry *start,
69865 struct exception_table_entry *finish)
69866 {
69867 + pax_open_kernel();
69868 sort(start, finish - start, sizeof(struct exception_table_entry),
69869 cmp_ex, NULL);
69870 + pax_close_kernel();
69871 }
69872
69873 #ifdef CONFIG_MODULES
69874 diff --git a/lib/inflate.c b/lib/inflate.c
69875 index 013a761..c28f3fc 100644
69876 --- a/lib/inflate.c
69877 +++ b/lib/inflate.c
69878 @@ -269,7 +269,7 @@ static void free(void *where)
69879 malloc_ptr = free_mem_ptr;
69880 }
69881 #else
69882 -#define malloc(a) kmalloc(a, GFP_KERNEL)
69883 +#define malloc(a) kmalloc((a), GFP_KERNEL)
69884 #define free(a) kfree(a)
69885 #endif
69886
69887 diff --git a/lib/ioremap.c b/lib/ioremap.c
69888 index da4e2ad..6373b5f 100644
69889 --- a/lib/ioremap.c
69890 +++ b/lib/ioremap.c
69891 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
69892 unsigned long next;
69893
69894 phys_addr -= addr;
69895 - pmd = pmd_alloc(&init_mm, pud, addr);
69896 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
69897 if (!pmd)
69898 return -ENOMEM;
69899 do {
69900 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
69901 unsigned long next;
69902
69903 phys_addr -= addr;
69904 - pud = pud_alloc(&init_mm, pgd, addr);
69905 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
69906 if (!pud)
69907 return -ENOMEM;
69908 do {
69909 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
69910 index bd2bea9..6b3c95e 100644
69911 --- a/lib/is_single_threaded.c
69912 +++ b/lib/is_single_threaded.c
69913 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
69914 struct task_struct *p, *t;
69915 bool ret;
69916
69917 + if (!mm)
69918 + return true;
69919 +
69920 if (atomic_read(&task->signal->live) != 1)
69921 return false;
69922
69923 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
69924 index dc63d08..95ae14a 100644
69925 --- a/lib/radix-tree.c
69926 +++ b/lib/radix-tree.c
69927 @@ -78,7 +78,7 @@ struct radix_tree_preload {
69928 int nr;
69929 struct radix_tree_node *nodes[RADIX_TREE_MAX_PATH];
69930 };
69931 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
69932 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
69933
69934 static inline void *ptr_to_indirect(void *ptr)
69935 {
69936 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
69937 index 38e612e..4fb99a8 100644
69938 --- a/lib/vsprintf.c
69939 +++ b/lib/vsprintf.c
69940 @@ -16,6 +16,9 @@
69941 * - scnprintf and vscnprintf
69942 */
69943
69944 +#ifdef CONFIG_GRKERNSEC_HIDESYM
69945 +#define __INCLUDED_BY_HIDESYM 1
69946 +#endif
69947 #include <stdarg.h>
69948 #include <linux/module.h>
69949 #include <linux/types.h>
69950 @@ -413,7 +416,7 @@ char *symbol_string(char *buf, char *end, void *ptr,
69951 char sym[KSYM_SYMBOL_LEN];
69952 if (ext == 'B')
69953 sprint_backtrace(sym, value);
69954 - else if (ext != 'f' && ext != 's')
69955 + else if (ext != 'f' && ext != 's' && ext != 'a')
69956 sprint_symbol(sym, value);
69957 else
69958 kallsyms_lookup(value, NULL, NULL, NULL, sym);
69959 @@ -789,7 +792,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
69960 return number(buf, end, *(const netdev_features_t *)addr, spec);
69961 }
69962
69963 +#ifdef CONFIG_GRKERNSEC_HIDESYM
69964 +int kptr_restrict __read_mostly = 2;
69965 +#else
69966 int kptr_restrict __read_mostly;
69967 +#endif
69968
69969 /*
69970 * Show a '%p' thing. A kernel extension is that the '%p' is followed
69971 @@ -803,6 +810,8 @@ int kptr_restrict __read_mostly;
69972 * - 'S' For symbolic direct pointers with offset
69973 * - 's' For symbolic direct pointers without offset
69974 * - 'B' For backtraced symbolic direct pointers with offset
69975 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
69976 + * - 'a' For symbolic direct pointers without offset approved for use with GRKERNSEC_HIDESYM
69977 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
69978 * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]
69979 * - 'M' For a 6-byte MAC address, it prints the address in the
69980 @@ -848,12 +857,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
69981 {
69982 if (!ptr && *fmt != 'K') {
69983 /*
69984 - * Print (null) with the same width as a pointer so it makes
69985 + * Print (nil) with the same width as a pointer so it makes
69986 * tabular output look nice.
69987 */
69988 if (spec.field_width == -1)
69989 spec.field_width = 2 * sizeof(void *);
69990 - return string(buf, end, "(null)", spec);
69991 + return string(buf, end, "(nil)", spec);
69992 }
69993
69994 switch (*fmt) {
69995 @@ -863,6 +872,13 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
69996 /* Fallthrough */
69997 case 'S':
69998 case 's':
69999 +#ifdef CONFIG_GRKERNSEC_HIDESYM
70000 + break;
70001 +#else
70002 + return symbol_string(buf, end, ptr, spec, *fmt);
70003 +#endif
70004 + case 'A':
70005 + case 'a':
70006 case 'B':
70007 return symbol_string(buf, end, ptr, spec, *fmt);
70008 case 'R':
70009 @@ -1633,11 +1649,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
70010 typeof(type) value; \
70011 if (sizeof(type) == 8) { \
70012 args = PTR_ALIGN(args, sizeof(u32)); \
70013 - *(u32 *)&value = *(u32 *)args; \
70014 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
70015 + *(u32 *)&value = *(const u32 *)args; \
70016 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
70017 } else { \
70018 args = PTR_ALIGN(args, sizeof(type)); \
70019 - value = *(typeof(type) *)args; \
70020 + value = *(const typeof(type) *)args; \
70021 } \
70022 args += sizeof(type); \
70023 value; \
70024 @@ -1700,7 +1716,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
70025 case FORMAT_TYPE_STR: {
70026 const char *str_arg = args;
70027 args += strlen(str_arg) + 1;
70028 - str = string(str, end, (char *)str_arg, spec);
70029 + str = string(str, end, str_arg, spec);
70030 break;
70031 }
70032
70033 diff --git a/localversion-grsec b/localversion-grsec
70034 new file mode 100644
70035 index 0000000..7cd6065
70036 --- /dev/null
70037 +++ b/localversion-grsec
70038 @@ -0,0 +1 @@
70039 +-grsec
70040 diff --git a/mm/Kconfig b/mm/Kconfig
70041 index e338407..4210331 100644
70042 --- a/mm/Kconfig
70043 +++ b/mm/Kconfig
70044 @@ -247,10 +247,10 @@ config KSM
70045 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
70046
70047 config DEFAULT_MMAP_MIN_ADDR
70048 - int "Low address space to protect from user allocation"
70049 + int "Low address space to protect from user allocation"
70050 depends on MMU
70051 - default 4096
70052 - help
70053 + default 65536
70054 + help
70055 This is the portion of low virtual memory which should be protected
70056 from userspace allocation. Keeping a user from writing to low pages
70057 can help reduce the impact of kernel NULL pointer bugs.
70058 @@ -280,7 +280,7 @@ config MEMORY_FAILURE
70059
70060 config HWPOISON_INJECT
70061 tristate "HWPoison pages injector"
70062 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
70063 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
70064 select PROC_PAGE_MONITOR
70065
70066 config NOMMU_INITIAL_TRIM_EXCESS
70067 diff --git a/mm/filemap.c b/mm/filemap.c
70068 index b662757..3081ddd 100644
70069 --- a/mm/filemap.c
70070 +++ b/mm/filemap.c
70071 @@ -1770,7 +1770,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
70072 struct address_space *mapping = file->f_mapping;
70073
70074 if (!mapping->a_ops->readpage)
70075 - return -ENOEXEC;
70076 + return -ENODEV;
70077 file_accessed(file);
70078 vma->vm_ops = &generic_file_vm_ops;
70079 vma->vm_flags |= VM_CAN_NONLINEAR;
70080 @@ -2176,6 +2176,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
70081 *pos = i_size_read(inode);
70082
70083 if (limit != RLIM_INFINITY) {
70084 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
70085 if (*pos >= limit) {
70086 send_sig(SIGXFSZ, current, 0);
70087 return -EFBIG;
70088 diff --git a/mm/fremap.c b/mm/fremap.c
70089 index 9ed4fd4..c42648d 100644
70090 --- a/mm/fremap.c
70091 +++ b/mm/fremap.c
70092 @@ -155,6 +155,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
70093 retry:
70094 vma = find_vma(mm, start);
70095
70096 +#ifdef CONFIG_PAX_SEGMEXEC
70097 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
70098 + goto out;
70099 +#endif
70100 +
70101 /*
70102 * Make sure the vma is shared, that it supports prefaulting,
70103 * and that the remapped range is valid and fully within
70104 diff --git a/mm/highmem.c b/mm/highmem.c
70105 index 57d82c6..e9e0552 100644
70106 --- a/mm/highmem.c
70107 +++ b/mm/highmem.c
70108 @@ -125,9 +125,10 @@ static void flush_all_zero_pkmaps(void)
70109 * So no dangers, even with speculative execution.
70110 */
70111 page = pte_page(pkmap_page_table[i]);
70112 + pax_open_kernel();
70113 pte_clear(&init_mm, (unsigned long)page_address(page),
70114 &pkmap_page_table[i]);
70115 -
70116 + pax_close_kernel();
70117 set_page_address(page, NULL);
70118 need_flush = 1;
70119 }
70120 @@ -186,9 +187,11 @@ start:
70121 }
70122 }
70123 vaddr = PKMAP_ADDR(last_pkmap_nr);
70124 +
70125 + pax_open_kernel();
70126 set_pte_at(&init_mm, vaddr,
70127 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
70128 -
70129 + pax_close_kernel();
70130 pkmap_count[last_pkmap_nr] = 1;
70131 set_page_address(page, (void *)vaddr);
70132
70133 diff --git a/mm/huge_memory.c b/mm/huge_memory.c
70134 index 8f7fc39..69bf1e9 100644
70135 --- a/mm/huge_memory.c
70136 +++ b/mm/huge_memory.c
70137 @@ -733,7 +733,7 @@ out:
70138 * run pte_offset_map on the pmd, if an huge pmd could
70139 * materialize from under us from a different thread.
70140 */
70141 - if (unlikely(__pte_alloc(mm, vma, pmd, address)))
70142 + if (unlikely(pmd_none(*pmd) && __pte_alloc(mm, vma, pmd, address)))
70143 return VM_FAULT_OOM;
70144 /* if an huge pmd materialized from under us just retry later */
70145 if (unlikely(pmd_trans_huge(*pmd)))
70146 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
70147 index fece520..e10da7f 100644
70148 --- a/mm/hugetlb.c
70149 +++ b/mm/hugetlb.c
70150 @@ -2146,6 +2146,15 @@ static void hugetlb_vm_op_open(struct vm_area_struct *vma)
70151 kref_get(&reservations->refs);
70152 }
70153
70154 +static void resv_map_put(struct vm_area_struct *vma)
70155 +{
70156 + struct resv_map *reservations = vma_resv_map(vma);
70157 +
70158 + if (!reservations)
70159 + return;
70160 + kref_put(&reservations->refs, resv_map_release);
70161 +}
70162 +
70163 static void hugetlb_vm_op_close(struct vm_area_struct *vma)
70164 {
70165 struct hstate *h = hstate_vma(vma);
70166 @@ -2162,7 +2171,7 @@ static void hugetlb_vm_op_close(struct vm_area_struct *vma)
70167 reserve = (end - start) -
70168 region_count(&reservations->regions, start, end);
70169
70170 - kref_put(&reservations->refs, resv_map_release);
70171 + resv_map_put(vma);
70172
70173 if (reserve) {
70174 hugetlb_acct_memory(h, -reserve);
70175 @@ -2425,6 +2434,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
70176 return 1;
70177 }
70178
70179 +#ifdef CONFIG_PAX_SEGMEXEC
70180 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
70181 +{
70182 + struct mm_struct *mm = vma->vm_mm;
70183 + struct vm_area_struct *vma_m;
70184 + unsigned long address_m;
70185 + pte_t *ptep_m;
70186 +
70187 + vma_m = pax_find_mirror_vma(vma);
70188 + if (!vma_m)
70189 + return;
70190 +
70191 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
70192 + address_m = address + SEGMEXEC_TASK_SIZE;
70193 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
70194 + get_page(page_m);
70195 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
70196 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
70197 +}
70198 +#endif
70199 +
70200 /*
70201 * Hugetlb_cow() should be called with page lock of the original hugepage held.
70202 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
70203 @@ -2537,6 +2567,11 @@ retry_avoidcopy:
70204 make_huge_pte(vma, new_page, 1));
70205 page_remove_rmap(old_page);
70206 hugepage_add_new_anon_rmap(new_page, vma, address);
70207 +
70208 +#ifdef CONFIG_PAX_SEGMEXEC
70209 + pax_mirror_huge_pte(vma, address, new_page);
70210 +#endif
70211 +
70212 /* Make the old page be freed below */
70213 new_page = old_page;
70214 mmu_notifier_invalidate_range_end(mm,
70215 @@ -2691,6 +2726,10 @@ retry:
70216 && (vma->vm_flags & VM_SHARED)));
70217 set_huge_pte_at(mm, address, ptep, new_pte);
70218
70219 +#ifdef CONFIG_PAX_SEGMEXEC
70220 + pax_mirror_huge_pte(vma, address, page);
70221 +#endif
70222 +
70223 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
70224 /* Optimization, do the COW without a second fault */
70225 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
70226 @@ -2720,6 +2759,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
70227 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
70228 struct hstate *h = hstate_vma(vma);
70229
70230 +#ifdef CONFIG_PAX_SEGMEXEC
70231 + struct vm_area_struct *vma_m;
70232 +#endif
70233 +
70234 address &= huge_page_mask(h);
70235
70236 ptep = huge_pte_offset(mm, address);
70237 @@ -2733,6 +2776,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
70238 VM_FAULT_SET_HINDEX(h - hstates);
70239 }
70240
70241 +#ifdef CONFIG_PAX_SEGMEXEC
70242 + vma_m = pax_find_mirror_vma(vma);
70243 + if (vma_m) {
70244 + unsigned long address_m;
70245 +
70246 + if (vma->vm_start > vma_m->vm_start) {
70247 + address_m = address;
70248 + address -= SEGMEXEC_TASK_SIZE;
70249 + vma = vma_m;
70250 + h = hstate_vma(vma);
70251 + } else
70252 + address_m = address + SEGMEXEC_TASK_SIZE;
70253 +
70254 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
70255 + return VM_FAULT_OOM;
70256 + address_m &= HPAGE_MASK;
70257 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
70258 + }
70259 +#endif
70260 +
70261 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
70262 if (!ptep)
70263 return VM_FAULT_OOM;
70264 @@ -2978,12 +3041,16 @@ int hugetlb_reserve_pages(struct inode *inode,
70265 set_vma_resv_flags(vma, HPAGE_RESV_OWNER);
70266 }
70267
70268 - if (chg < 0)
70269 - return chg;
70270 + if (chg < 0) {
70271 + ret = chg;
70272 + goto out_err;
70273 + }
70274
70275 /* There must be enough pages in the subpool for the mapping */
70276 - if (hugepage_subpool_get_pages(spool, chg))
70277 - return -ENOSPC;
70278 + if (hugepage_subpool_get_pages(spool, chg)) {
70279 + ret = -ENOSPC;
70280 + goto out_err;
70281 + }
70282
70283 /*
70284 * Check enough hugepages are available for the reservation.
70285 @@ -2992,7 +3059,7 @@ int hugetlb_reserve_pages(struct inode *inode,
70286 ret = hugetlb_acct_memory(h, chg);
70287 if (ret < 0) {
70288 hugepage_subpool_put_pages(spool, chg);
70289 - return ret;
70290 + goto out_err;
70291 }
70292
70293 /*
70294 @@ -3009,6 +3076,10 @@ int hugetlb_reserve_pages(struct inode *inode,
70295 if (!vma || vma->vm_flags & VM_MAYSHARE)
70296 region_add(&inode->i_mapping->private_list, from, to);
70297 return 0;
70298 +out_err:
70299 + if (vma)
70300 + resv_map_put(vma);
70301 + return ret;
70302 }
70303
70304 void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed)
70305 diff --git a/mm/internal.h b/mm/internal.h
70306 index 2189af4..f2ca332 100644
70307 --- a/mm/internal.h
70308 +++ b/mm/internal.h
70309 @@ -95,6 +95,7 @@ extern void putback_lru_page(struct page *page);
70310 * in mm/page_alloc.c
70311 */
70312 extern void __free_pages_bootmem(struct page *page, unsigned int order);
70313 +extern void free_compound_page(struct page *page);
70314 extern void prep_compound_page(struct page *page, unsigned long order);
70315 #ifdef CONFIG_MEMORY_FAILURE
70316 extern bool is_free_buddy_page(struct page *page);
70317 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
70318 index 45eb621..6ccd8ea 100644
70319 --- a/mm/kmemleak.c
70320 +++ b/mm/kmemleak.c
70321 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
70322
70323 for (i = 0; i < object->trace_len; i++) {
70324 void *ptr = (void *)object->trace[i];
70325 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
70326 + seq_printf(seq, " [<%p>] %pA\n", ptr, ptr);
70327 }
70328 }
70329
70330 diff --git a/mm/maccess.c b/mm/maccess.c
70331 index d53adf9..03a24bf 100644
70332 --- a/mm/maccess.c
70333 +++ b/mm/maccess.c
70334 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
70335 set_fs(KERNEL_DS);
70336 pagefault_disable();
70337 ret = __copy_from_user_inatomic(dst,
70338 - (__force const void __user *)src, size);
70339 + (const void __force_user *)src, size);
70340 pagefault_enable();
70341 set_fs(old_fs);
70342
70343 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
70344
70345 set_fs(KERNEL_DS);
70346 pagefault_disable();
70347 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
70348 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
70349 pagefault_enable();
70350 set_fs(old_fs);
70351
70352 diff --git a/mm/madvise.c b/mm/madvise.c
70353 index 74bf193..feb6fd3 100644
70354 --- a/mm/madvise.c
70355 +++ b/mm/madvise.c
70356 @@ -45,6 +45,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
70357 pgoff_t pgoff;
70358 unsigned long new_flags = vma->vm_flags;
70359
70360 +#ifdef CONFIG_PAX_SEGMEXEC
70361 + struct vm_area_struct *vma_m;
70362 +#endif
70363 +
70364 switch (behavior) {
70365 case MADV_NORMAL:
70366 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
70367 @@ -110,6 +114,13 @@ success:
70368 /*
70369 * vm_flags is protected by the mmap_sem held in write mode.
70370 */
70371 +
70372 +#ifdef CONFIG_PAX_SEGMEXEC
70373 + vma_m = pax_find_mirror_vma(vma);
70374 + if (vma_m)
70375 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
70376 +#endif
70377 +
70378 vma->vm_flags = new_flags;
70379
70380 out:
70381 @@ -168,6 +179,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
70382 struct vm_area_struct ** prev,
70383 unsigned long start, unsigned long end)
70384 {
70385 +
70386 +#ifdef CONFIG_PAX_SEGMEXEC
70387 + struct vm_area_struct *vma_m;
70388 +#endif
70389 +
70390 *prev = vma;
70391 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
70392 return -EINVAL;
70393 @@ -180,6 +196,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
70394 zap_page_range(vma, start, end - start, &details);
70395 } else
70396 zap_page_range(vma, start, end - start, NULL);
70397 +
70398 +#ifdef CONFIG_PAX_SEGMEXEC
70399 + vma_m = pax_find_mirror_vma(vma);
70400 + if (vma_m) {
70401 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
70402 + struct zap_details details = {
70403 + .nonlinear_vma = vma_m,
70404 + .last_index = ULONG_MAX,
70405 + };
70406 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
70407 + } else
70408 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
70409 + }
70410 +#endif
70411 +
70412 return 0;
70413 }
70414
70415 @@ -376,6 +407,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
70416 if (end < start)
70417 goto out;
70418
70419 +#ifdef CONFIG_PAX_SEGMEXEC
70420 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
70421 + if (end > SEGMEXEC_TASK_SIZE)
70422 + goto out;
70423 + } else
70424 +#endif
70425 +
70426 + if (end > TASK_SIZE)
70427 + goto out;
70428 +
70429 error = 0;
70430 if (end == start)
70431 goto out;
70432 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
70433 index 56080ea..115071e 100644
70434 --- a/mm/memory-failure.c
70435 +++ b/mm/memory-failure.c
70436 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
70437
70438 int sysctl_memory_failure_recovery __read_mostly = 1;
70439
70440 -atomic_long_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
70441 +atomic_long_unchecked_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
70442
70443 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
70444
70445 @@ -202,7 +202,7 @@ static int kill_proc_ao(struct task_struct *t, unsigned long addr, int trapno,
70446 si.si_signo = SIGBUS;
70447 si.si_errno = 0;
70448 si.si_code = BUS_MCEERR_AO;
70449 - si.si_addr = (void *)addr;
70450 + si.si_addr = (void __user *)addr;
70451 #ifdef __ARCH_SI_TRAPNO
70452 si.si_trapno = trapno;
70453 #endif
70454 @@ -1010,7 +1010,7 @@ int __memory_failure(unsigned long pfn, int trapno, int flags)
70455 }
70456
70457 nr_pages = 1 << compound_trans_order(hpage);
70458 - atomic_long_add(nr_pages, &mce_bad_pages);
70459 + atomic_long_add_unchecked(nr_pages, &mce_bad_pages);
70460
70461 /*
70462 * We need/can do nothing about count=0 pages.
70463 @@ -1040,7 +1040,7 @@ int __memory_failure(unsigned long pfn, int trapno, int flags)
70464 if (!PageHWPoison(hpage)
70465 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
70466 || (p != hpage && TestSetPageHWPoison(hpage))) {
70467 - atomic_long_sub(nr_pages, &mce_bad_pages);
70468 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
70469 return 0;
70470 }
70471 set_page_hwpoison_huge_page(hpage);
70472 @@ -1098,7 +1098,7 @@ int __memory_failure(unsigned long pfn, int trapno, int flags)
70473 }
70474 if (hwpoison_filter(p)) {
70475 if (TestClearPageHWPoison(p))
70476 - atomic_long_sub(nr_pages, &mce_bad_pages);
70477 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
70478 unlock_page(hpage);
70479 put_page(hpage);
70480 return 0;
70481 @@ -1315,7 +1315,7 @@ int unpoison_memory(unsigned long pfn)
70482 return 0;
70483 }
70484 if (TestClearPageHWPoison(p))
70485 - atomic_long_sub(nr_pages, &mce_bad_pages);
70486 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
70487 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
70488 return 0;
70489 }
70490 @@ -1329,7 +1329,7 @@ int unpoison_memory(unsigned long pfn)
70491 */
70492 if (TestClearPageHWPoison(page)) {
70493 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
70494 - atomic_long_sub(nr_pages, &mce_bad_pages);
70495 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
70496 freeit = 1;
70497 if (PageHuge(page))
70498 clear_page_hwpoison_huge_page(page);
70499 @@ -1442,7 +1442,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
70500 }
70501 done:
70502 if (!PageHWPoison(hpage))
70503 - atomic_long_add(1 << compound_trans_order(hpage), &mce_bad_pages);
70504 + atomic_long_add_unchecked(1 << compound_trans_order(hpage), &mce_bad_pages);
70505 set_page_hwpoison_huge_page(hpage);
70506 dequeue_hwpoisoned_huge_page(hpage);
70507 /* keep elevated page count for bad page */
70508 @@ -1573,7 +1573,7 @@ int soft_offline_page(struct page *page, int flags)
70509 return ret;
70510
70511 done:
70512 - atomic_long_add(1, &mce_bad_pages);
70513 + atomic_long_add_unchecked(1, &mce_bad_pages);
70514 SetPageHWPoison(page);
70515 /* keep elevated page count for bad page */
70516 return ret;
70517 diff --git a/mm/memory.c b/mm/memory.c
70518 index 10b4dda..06857f3 100644
70519 --- a/mm/memory.c
70520 +++ b/mm/memory.c
70521 @@ -457,8 +457,12 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
70522 return;
70523
70524 pmd = pmd_offset(pud, start);
70525 +
70526 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
70527 pud_clear(pud);
70528 pmd_free_tlb(tlb, pmd, start);
70529 +#endif
70530 +
70531 }
70532
70533 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
70534 @@ -489,9 +493,12 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
70535 if (end - 1 > ceiling - 1)
70536 return;
70537
70538 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
70539 pud = pud_offset(pgd, start);
70540 pgd_clear(pgd);
70541 pud_free_tlb(tlb, pud, start);
70542 +#endif
70543 +
70544 }
70545
70546 /*
70547 @@ -1593,12 +1600,6 @@ no_page_table:
70548 return page;
70549 }
70550
70551 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
70552 -{
70553 - return stack_guard_page_start(vma, addr) ||
70554 - stack_guard_page_end(vma, addr+PAGE_SIZE);
70555 -}
70556 -
70557 /**
70558 * __get_user_pages() - pin user pages in memory
70559 * @tsk: task_struct of target task
70560 @@ -1671,10 +1672,10 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
70561 (VM_MAYREAD | VM_MAYWRITE) : (VM_READ | VM_WRITE);
70562 i = 0;
70563
70564 - do {
70565 + while (nr_pages) {
70566 struct vm_area_struct *vma;
70567
70568 - vma = find_extend_vma(mm, start);
70569 + vma = find_vma(mm, start);
70570 if (!vma && in_gate_area(mm, start)) {
70571 unsigned long pg = start & PAGE_MASK;
70572 pgd_t *pgd;
70573 @@ -1722,7 +1723,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
70574 goto next_page;
70575 }
70576
70577 - if (!vma ||
70578 + if (!vma || start < vma->vm_start ||
70579 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
70580 !(vm_flags & vma->vm_flags))
70581 return i ? : -EFAULT;
70582 @@ -1749,11 +1750,6 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
70583 int ret;
70584 unsigned int fault_flags = 0;
70585
70586 - /* For mlock, just skip the stack guard page. */
70587 - if (foll_flags & FOLL_MLOCK) {
70588 - if (stack_guard_page(vma, start))
70589 - goto next_page;
70590 - }
70591 if (foll_flags & FOLL_WRITE)
70592 fault_flags |= FAULT_FLAG_WRITE;
70593 if (nonblocking)
70594 @@ -1827,7 +1823,7 @@ next_page:
70595 start += PAGE_SIZE;
70596 nr_pages--;
70597 } while (nr_pages && start < vma->vm_end);
70598 - } while (nr_pages);
70599 + }
70600 return i;
70601 }
70602 EXPORT_SYMBOL(__get_user_pages);
70603 @@ -2034,6 +2030,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
70604 page_add_file_rmap(page);
70605 set_pte_at(mm, addr, pte, mk_pte(page, prot));
70606
70607 +#ifdef CONFIG_PAX_SEGMEXEC
70608 + pax_mirror_file_pte(vma, addr, page, ptl);
70609 +#endif
70610 +
70611 retval = 0;
70612 pte_unmap_unlock(pte, ptl);
70613 return retval;
70614 @@ -2068,10 +2068,22 @@ out:
70615 int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
70616 struct page *page)
70617 {
70618 +
70619 +#ifdef CONFIG_PAX_SEGMEXEC
70620 + struct vm_area_struct *vma_m;
70621 +#endif
70622 +
70623 if (addr < vma->vm_start || addr >= vma->vm_end)
70624 return -EFAULT;
70625 if (!page_count(page))
70626 return -EINVAL;
70627 +
70628 +#ifdef CONFIG_PAX_SEGMEXEC
70629 + vma_m = pax_find_mirror_vma(vma);
70630 + if (vma_m)
70631 + vma_m->vm_flags |= VM_INSERTPAGE;
70632 +#endif
70633 +
70634 vma->vm_flags |= VM_INSERTPAGE;
70635 return insert_page(vma, addr, page, vma->vm_page_prot);
70636 }
70637 @@ -2157,6 +2169,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
70638 unsigned long pfn)
70639 {
70640 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
70641 + BUG_ON(vma->vm_mirror);
70642
70643 if (addr < vma->vm_start || addr >= vma->vm_end)
70644 return -EFAULT;
70645 @@ -2364,7 +2377,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
70646
70647 BUG_ON(pud_huge(*pud));
70648
70649 - pmd = pmd_alloc(mm, pud, addr);
70650 + pmd = (mm == &init_mm) ?
70651 + pmd_alloc_kernel(mm, pud, addr) :
70652 + pmd_alloc(mm, pud, addr);
70653 if (!pmd)
70654 return -ENOMEM;
70655 do {
70656 @@ -2384,7 +2399,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
70657 unsigned long next;
70658 int err;
70659
70660 - pud = pud_alloc(mm, pgd, addr);
70661 + pud = (mm == &init_mm) ?
70662 + pud_alloc_kernel(mm, pgd, addr) :
70663 + pud_alloc(mm, pgd, addr);
70664 if (!pud)
70665 return -ENOMEM;
70666 do {
70667 @@ -2472,6 +2489,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
70668 copy_user_highpage(dst, src, va, vma);
70669 }
70670
70671 +#ifdef CONFIG_PAX_SEGMEXEC
70672 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
70673 +{
70674 + struct mm_struct *mm = vma->vm_mm;
70675 + spinlock_t *ptl;
70676 + pte_t *pte, entry;
70677 +
70678 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
70679 + entry = *pte;
70680 + if (!pte_present(entry)) {
70681 + if (!pte_none(entry)) {
70682 + BUG_ON(pte_file(entry));
70683 + free_swap_and_cache(pte_to_swp_entry(entry));
70684 + pte_clear_not_present_full(mm, address, pte, 0);
70685 + }
70686 + } else {
70687 + struct page *page;
70688 +
70689 + flush_cache_page(vma, address, pte_pfn(entry));
70690 + entry = ptep_clear_flush(vma, address, pte);
70691 + BUG_ON(pte_dirty(entry));
70692 + page = vm_normal_page(vma, address, entry);
70693 + if (page) {
70694 + update_hiwater_rss(mm);
70695 + if (PageAnon(page))
70696 + dec_mm_counter_fast(mm, MM_ANONPAGES);
70697 + else
70698 + dec_mm_counter_fast(mm, MM_FILEPAGES);
70699 + page_remove_rmap(page);
70700 + page_cache_release(page);
70701 + }
70702 + }
70703 + pte_unmap_unlock(pte, ptl);
70704 +}
70705 +
70706 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
70707 + *
70708 + * the ptl of the lower mapped page is held on entry and is not released on exit
70709 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
70710 + */
70711 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
70712 +{
70713 + struct mm_struct *mm = vma->vm_mm;
70714 + unsigned long address_m;
70715 + spinlock_t *ptl_m;
70716 + struct vm_area_struct *vma_m;
70717 + pmd_t *pmd_m;
70718 + pte_t *pte_m, entry_m;
70719 +
70720 + BUG_ON(!page_m || !PageAnon(page_m));
70721 +
70722 + vma_m = pax_find_mirror_vma(vma);
70723 + if (!vma_m)
70724 + return;
70725 +
70726 + BUG_ON(!PageLocked(page_m));
70727 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
70728 + address_m = address + SEGMEXEC_TASK_SIZE;
70729 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
70730 + pte_m = pte_offset_map(pmd_m, address_m);
70731 + ptl_m = pte_lockptr(mm, pmd_m);
70732 + if (ptl != ptl_m) {
70733 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
70734 + if (!pte_none(*pte_m))
70735 + goto out;
70736 + }
70737 +
70738 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
70739 + page_cache_get(page_m);
70740 + page_add_anon_rmap(page_m, vma_m, address_m);
70741 + inc_mm_counter_fast(mm, MM_ANONPAGES);
70742 + set_pte_at(mm, address_m, pte_m, entry_m);
70743 + update_mmu_cache(vma_m, address_m, entry_m);
70744 +out:
70745 + if (ptl != ptl_m)
70746 + spin_unlock(ptl_m);
70747 + pte_unmap(pte_m);
70748 + unlock_page(page_m);
70749 +}
70750 +
70751 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
70752 +{
70753 + struct mm_struct *mm = vma->vm_mm;
70754 + unsigned long address_m;
70755 + spinlock_t *ptl_m;
70756 + struct vm_area_struct *vma_m;
70757 + pmd_t *pmd_m;
70758 + pte_t *pte_m, entry_m;
70759 +
70760 + BUG_ON(!page_m || PageAnon(page_m));
70761 +
70762 + vma_m = pax_find_mirror_vma(vma);
70763 + if (!vma_m)
70764 + return;
70765 +
70766 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
70767 + address_m = address + SEGMEXEC_TASK_SIZE;
70768 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
70769 + pte_m = pte_offset_map(pmd_m, address_m);
70770 + ptl_m = pte_lockptr(mm, pmd_m);
70771 + if (ptl != ptl_m) {
70772 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
70773 + if (!pte_none(*pte_m))
70774 + goto out;
70775 + }
70776 +
70777 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
70778 + page_cache_get(page_m);
70779 + page_add_file_rmap(page_m);
70780 + inc_mm_counter_fast(mm, MM_FILEPAGES);
70781 + set_pte_at(mm, address_m, pte_m, entry_m);
70782 + update_mmu_cache(vma_m, address_m, entry_m);
70783 +out:
70784 + if (ptl != ptl_m)
70785 + spin_unlock(ptl_m);
70786 + pte_unmap(pte_m);
70787 +}
70788 +
70789 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
70790 +{
70791 + struct mm_struct *mm = vma->vm_mm;
70792 + unsigned long address_m;
70793 + spinlock_t *ptl_m;
70794 + struct vm_area_struct *vma_m;
70795 + pmd_t *pmd_m;
70796 + pte_t *pte_m, entry_m;
70797 +
70798 + vma_m = pax_find_mirror_vma(vma);
70799 + if (!vma_m)
70800 + return;
70801 +
70802 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
70803 + address_m = address + SEGMEXEC_TASK_SIZE;
70804 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
70805 + pte_m = pte_offset_map(pmd_m, address_m);
70806 + ptl_m = pte_lockptr(mm, pmd_m);
70807 + if (ptl != ptl_m) {
70808 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
70809 + if (!pte_none(*pte_m))
70810 + goto out;
70811 + }
70812 +
70813 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
70814 + set_pte_at(mm, address_m, pte_m, entry_m);
70815 +out:
70816 + if (ptl != ptl_m)
70817 + spin_unlock(ptl_m);
70818 + pte_unmap(pte_m);
70819 +}
70820 +
70821 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
70822 +{
70823 + struct page *page_m;
70824 + pte_t entry;
70825 +
70826 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
70827 + goto out;
70828 +
70829 + entry = *pte;
70830 + page_m = vm_normal_page(vma, address, entry);
70831 + if (!page_m)
70832 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
70833 + else if (PageAnon(page_m)) {
70834 + if (pax_find_mirror_vma(vma)) {
70835 + pte_unmap_unlock(pte, ptl);
70836 + lock_page(page_m);
70837 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
70838 + if (pte_same(entry, *pte))
70839 + pax_mirror_anon_pte(vma, address, page_m, ptl);
70840 + else
70841 + unlock_page(page_m);
70842 + }
70843 + } else
70844 + pax_mirror_file_pte(vma, address, page_m, ptl);
70845 +
70846 +out:
70847 + pte_unmap_unlock(pte, ptl);
70848 +}
70849 +#endif
70850 +
70851 /*
70852 * This routine handles present pages, when users try to write
70853 * to a shared page. It is done by copying the page to a new address
70854 @@ -2683,6 +2880,12 @@ gotten:
70855 */
70856 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
70857 if (likely(pte_same(*page_table, orig_pte))) {
70858 +
70859 +#ifdef CONFIG_PAX_SEGMEXEC
70860 + if (pax_find_mirror_vma(vma))
70861 + BUG_ON(!trylock_page(new_page));
70862 +#endif
70863 +
70864 if (old_page) {
70865 if (!PageAnon(old_page)) {
70866 dec_mm_counter_fast(mm, MM_FILEPAGES);
70867 @@ -2734,6 +2937,10 @@ gotten:
70868 page_remove_rmap(old_page);
70869 }
70870
70871 +#ifdef CONFIG_PAX_SEGMEXEC
70872 + pax_mirror_anon_pte(vma, address, new_page, ptl);
70873 +#endif
70874 +
70875 /* Free the old page.. */
70876 new_page = old_page;
70877 ret |= VM_FAULT_WRITE;
70878 @@ -3013,6 +3220,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
70879 swap_free(entry);
70880 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
70881 try_to_free_swap(page);
70882 +
70883 +#ifdef CONFIG_PAX_SEGMEXEC
70884 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
70885 +#endif
70886 +
70887 unlock_page(page);
70888 if (swapcache) {
70889 /*
70890 @@ -3036,6 +3248,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
70891
70892 /* No need to invalidate - it was non-present before */
70893 update_mmu_cache(vma, address, page_table);
70894 +
70895 +#ifdef CONFIG_PAX_SEGMEXEC
70896 + pax_mirror_anon_pte(vma, address, page, ptl);
70897 +#endif
70898 +
70899 unlock:
70900 pte_unmap_unlock(page_table, ptl);
70901 out:
70902 @@ -3055,40 +3272,6 @@ out_release:
70903 }
70904
70905 /*
70906 - * This is like a special single-page "expand_{down|up}wards()",
70907 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
70908 - * doesn't hit another vma.
70909 - */
70910 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
70911 -{
70912 - address &= PAGE_MASK;
70913 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
70914 - struct vm_area_struct *prev = vma->vm_prev;
70915 -
70916 - /*
70917 - * Is there a mapping abutting this one below?
70918 - *
70919 - * That's only ok if it's the same stack mapping
70920 - * that has gotten split..
70921 - */
70922 - if (prev && prev->vm_end == address)
70923 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
70924 -
70925 - expand_downwards(vma, address - PAGE_SIZE);
70926 - }
70927 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
70928 - struct vm_area_struct *next = vma->vm_next;
70929 -
70930 - /* As VM_GROWSDOWN but s/below/above/ */
70931 - if (next && next->vm_start == address + PAGE_SIZE)
70932 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
70933 -
70934 - expand_upwards(vma, address + PAGE_SIZE);
70935 - }
70936 - return 0;
70937 -}
70938 -
70939 -/*
70940 * We enter with non-exclusive mmap_sem (to exclude vma changes,
70941 * but allow concurrent faults), and pte mapped but not yet locked.
70942 * We return with mmap_sem still held, but pte unmapped and unlocked.
70943 @@ -3097,27 +3280,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
70944 unsigned long address, pte_t *page_table, pmd_t *pmd,
70945 unsigned int flags)
70946 {
70947 - struct page *page;
70948 + struct page *page = NULL;
70949 spinlock_t *ptl;
70950 pte_t entry;
70951
70952 - pte_unmap(page_table);
70953 -
70954 - /* Check if we need to add a guard page to the stack */
70955 - if (check_stack_guard_page(vma, address) < 0)
70956 - return VM_FAULT_SIGBUS;
70957 -
70958 - /* Use the zero-page for reads */
70959 if (!(flags & FAULT_FLAG_WRITE)) {
70960 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
70961 vma->vm_page_prot));
70962 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
70963 + ptl = pte_lockptr(mm, pmd);
70964 + spin_lock(ptl);
70965 if (!pte_none(*page_table))
70966 goto unlock;
70967 goto setpte;
70968 }
70969
70970 /* Allocate our own private page. */
70971 + pte_unmap(page_table);
70972 +
70973 if (unlikely(anon_vma_prepare(vma)))
70974 goto oom;
70975 page = alloc_zeroed_user_highpage_movable(vma, address);
70976 @@ -3136,6 +3315,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
70977 if (!pte_none(*page_table))
70978 goto release;
70979
70980 +#ifdef CONFIG_PAX_SEGMEXEC
70981 + if (pax_find_mirror_vma(vma))
70982 + BUG_ON(!trylock_page(page));
70983 +#endif
70984 +
70985 inc_mm_counter_fast(mm, MM_ANONPAGES);
70986 page_add_new_anon_rmap(page, vma, address);
70987 setpte:
70988 @@ -3143,6 +3327,12 @@ setpte:
70989
70990 /* No need to invalidate - it was non-present before */
70991 update_mmu_cache(vma, address, page_table);
70992 +
70993 +#ifdef CONFIG_PAX_SEGMEXEC
70994 + if (page)
70995 + pax_mirror_anon_pte(vma, address, page, ptl);
70996 +#endif
70997 +
70998 unlock:
70999 pte_unmap_unlock(page_table, ptl);
71000 return 0;
71001 @@ -3286,6 +3476,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
71002 */
71003 /* Only go through if we didn't race with anybody else... */
71004 if (likely(pte_same(*page_table, orig_pte))) {
71005 +
71006 +#ifdef CONFIG_PAX_SEGMEXEC
71007 + if (anon && pax_find_mirror_vma(vma))
71008 + BUG_ON(!trylock_page(page));
71009 +#endif
71010 +
71011 flush_icache_page(vma, page);
71012 entry = mk_pte(page, vma->vm_page_prot);
71013 if (flags & FAULT_FLAG_WRITE)
71014 @@ -3305,6 +3501,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
71015
71016 /* no need to invalidate: a not-present page won't be cached */
71017 update_mmu_cache(vma, address, page_table);
71018 +
71019 +#ifdef CONFIG_PAX_SEGMEXEC
71020 + if (anon)
71021 + pax_mirror_anon_pte(vma, address, page, ptl);
71022 + else
71023 + pax_mirror_file_pte(vma, address, page, ptl);
71024 +#endif
71025 +
71026 } else {
71027 if (cow_page)
71028 mem_cgroup_uncharge_page(cow_page);
71029 @@ -3458,6 +3662,12 @@ int handle_pte_fault(struct mm_struct *mm,
71030 if (flags & FAULT_FLAG_WRITE)
71031 flush_tlb_fix_spurious_fault(vma, address);
71032 }
71033 +
71034 +#ifdef CONFIG_PAX_SEGMEXEC
71035 + pax_mirror_pte(vma, address, pte, pmd, ptl);
71036 + return 0;
71037 +#endif
71038 +
71039 unlock:
71040 pte_unmap_unlock(pte, ptl);
71041 return 0;
71042 @@ -3474,6 +3684,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
71043 pmd_t *pmd;
71044 pte_t *pte;
71045
71046 +#ifdef CONFIG_PAX_SEGMEXEC
71047 + struct vm_area_struct *vma_m;
71048 +#endif
71049 +
71050 __set_current_state(TASK_RUNNING);
71051
71052 count_vm_event(PGFAULT);
71053 @@ -3485,6 +3699,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
71054 if (unlikely(is_vm_hugetlb_page(vma)))
71055 return hugetlb_fault(mm, vma, address, flags);
71056
71057 +#ifdef CONFIG_PAX_SEGMEXEC
71058 + vma_m = pax_find_mirror_vma(vma);
71059 + if (vma_m) {
71060 + unsigned long address_m;
71061 + pgd_t *pgd_m;
71062 + pud_t *pud_m;
71063 + pmd_t *pmd_m;
71064 +
71065 + if (vma->vm_start > vma_m->vm_start) {
71066 + address_m = address;
71067 + address -= SEGMEXEC_TASK_SIZE;
71068 + vma = vma_m;
71069 + } else
71070 + address_m = address + SEGMEXEC_TASK_SIZE;
71071 +
71072 + pgd_m = pgd_offset(mm, address_m);
71073 + pud_m = pud_alloc(mm, pgd_m, address_m);
71074 + if (!pud_m)
71075 + return VM_FAULT_OOM;
71076 + pmd_m = pmd_alloc(mm, pud_m, address_m);
71077 + if (!pmd_m)
71078 + return VM_FAULT_OOM;
71079 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
71080 + return VM_FAULT_OOM;
71081 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
71082 + }
71083 +#endif
71084 +
71085 pgd = pgd_offset(mm, address);
71086 pud = pud_alloc(mm, pgd, address);
71087 if (!pud)
71088 @@ -3514,7 +3756,7 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
71089 * run pte_offset_map on the pmd, if an huge pmd could
71090 * materialize from under us from a different thread.
71091 */
71092 - if (unlikely(pmd_none(*pmd)) && __pte_alloc(mm, vma, pmd, address))
71093 + if (unlikely(pmd_none(*pmd) && __pte_alloc(mm, vma, pmd, address)))
71094 return VM_FAULT_OOM;
71095 /* if an huge pmd materialized from under us just retry later */
71096 if (unlikely(pmd_trans_huge(*pmd)))
71097 @@ -3551,6 +3793,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
71098 spin_unlock(&mm->page_table_lock);
71099 return 0;
71100 }
71101 +
71102 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
71103 +{
71104 + pud_t *new = pud_alloc_one(mm, address);
71105 + if (!new)
71106 + return -ENOMEM;
71107 +
71108 + smp_wmb(); /* See comment in __pte_alloc */
71109 +
71110 + spin_lock(&mm->page_table_lock);
71111 + if (pgd_present(*pgd)) /* Another has populated it */
71112 + pud_free(mm, new);
71113 + else
71114 + pgd_populate_kernel(mm, pgd, new);
71115 + spin_unlock(&mm->page_table_lock);
71116 + return 0;
71117 +}
71118 #endif /* __PAGETABLE_PUD_FOLDED */
71119
71120 #ifndef __PAGETABLE_PMD_FOLDED
71121 @@ -3581,6 +3840,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
71122 spin_unlock(&mm->page_table_lock);
71123 return 0;
71124 }
71125 +
71126 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
71127 +{
71128 + pmd_t *new = pmd_alloc_one(mm, address);
71129 + if (!new)
71130 + return -ENOMEM;
71131 +
71132 + smp_wmb(); /* See comment in __pte_alloc */
71133 +
71134 + spin_lock(&mm->page_table_lock);
71135 +#ifndef __ARCH_HAS_4LEVEL_HACK
71136 + if (pud_present(*pud)) /* Another has populated it */
71137 + pmd_free(mm, new);
71138 + else
71139 + pud_populate_kernel(mm, pud, new);
71140 +#else
71141 + if (pgd_present(*pud)) /* Another has populated it */
71142 + pmd_free(mm, new);
71143 + else
71144 + pgd_populate_kernel(mm, pud, new);
71145 +#endif /* __ARCH_HAS_4LEVEL_HACK */
71146 + spin_unlock(&mm->page_table_lock);
71147 + return 0;
71148 +}
71149 #endif /* __PAGETABLE_PMD_FOLDED */
71150
71151 int make_pages_present(unsigned long addr, unsigned long end)
71152 @@ -3618,7 +3901,7 @@ static int __init gate_vma_init(void)
71153 gate_vma.vm_start = FIXADDR_USER_START;
71154 gate_vma.vm_end = FIXADDR_USER_END;
71155 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
71156 - gate_vma.vm_page_prot = __P101;
71157 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
71158 /*
71159 * Make sure the vDSO gets into every core dump.
71160 * Dumping its contents makes post-mortem fully interpretable later
71161 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
71162 index 0a37570..2048346 100644
71163 --- a/mm/mempolicy.c
71164 +++ b/mm/mempolicy.c
71165 @@ -640,6 +640,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
71166 unsigned long vmstart;
71167 unsigned long vmend;
71168
71169 +#ifdef CONFIG_PAX_SEGMEXEC
71170 + struct vm_area_struct *vma_m;
71171 +#endif
71172 +
71173 vma = find_vma(mm, start);
71174 if (!vma || vma->vm_start > start)
71175 return -EFAULT;
71176 @@ -679,6 +683,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
71177 err = policy_vma(vma, new_pol);
71178 if (err)
71179 goto out;
71180 +
71181 +#ifdef CONFIG_PAX_SEGMEXEC
71182 + vma_m = pax_find_mirror_vma(vma);
71183 + if (vma_m) {
71184 + err = policy_vma(vma_m, new_pol);
71185 + if (err)
71186 + goto out;
71187 + }
71188 +#endif
71189 +
71190 }
71191
71192 out:
71193 @@ -1112,6 +1126,17 @@ static long do_mbind(unsigned long start, unsigned long len,
71194
71195 if (end < start)
71196 return -EINVAL;
71197 +
71198 +#ifdef CONFIG_PAX_SEGMEXEC
71199 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
71200 + if (end > SEGMEXEC_TASK_SIZE)
71201 + return -EINVAL;
71202 + } else
71203 +#endif
71204 +
71205 + if (end > TASK_SIZE)
71206 + return -EINVAL;
71207 +
71208 if (end == start)
71209 return 0;
71210
71211 @@ -1330,6 +1355,14 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
71212 if (!mm)
71213 goto out;
71214
71215 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71216 + if (mm != current->mm &&
71217 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
71218 + err = -EPERM;
71219 + goto out;
71220 + }
71221 +#endif
71222 +
71223 /*
71224 * Check if this process has the right to modify the specified
71225 * process. The right exists if the process has administrative
71226 @@ -1339,8 +1372,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
71227 rcu_read_lock();
71228 tcred = __task_cred(task);
71229 if (cred->euid != tcred->suid && cred->euid != tcred->uid &&
71230 - cred->uid != tcred->suid && cred->uid != tcred->uid &&
71231 - !capable(CAP_SYS_NICE)) {
71232 + cred->uid != tcred->suid && !capable(CAP_SYS_NICE)) {
71233 rcu_read_unlock();
71234 err = -EPERM;
71235 goto out;
71236 diff --git a/mm/migrate.c b/mm/migrate.c
71237 index 1503b6b..156c672 100644
71238 --- a/mm/migrate.c
71239 +++ b/mm/migrate.c
71240 @@ -1370,6 +1370,14 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
71241 if (!mm)
71242 return -EINVAL;
71243
71244 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71245 + if (mm != current->mm &&
71246 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
71247 + err = -EPERM;
71248 + goto out;
71249 + }
71250 +#endif
71251 +
71252 /*
71253 * Check if this process has the right to modify the specified
71254 * process. The right exists if the process has administrative
71255 @@ -1379,8 +1387,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
71256 rcu_read_lock();
71257 tcred = __task_cred(task);
71258 if (cred->euid != tcred->suid && cred->euid != tcred->uid &&
71259 - cred->uid != tcred->suid && cred->uid != tcred->uid &&
71260 - !capable(CAP_SYS_NICE)) {
71261 + cred->uid != tcred->suid && !capable(CAP_SYS_NICE)) {
71262 rcu_read_unlock();
71263 err = -EPERM;
71264 goto out;
71265 diff --git a/mm/mlock.c b/mm/mlock.c
71266 index ef726e8..13e0901 100644
71267 --- a/mm/mlock.c
71268 +++ b/mm/mlock.c
71269 @@ -13,6 +13,7 @@
71270 #include <linux/pagemap.h>
71271 #include <linux/mempolicy.h>
71272 #include <linux/syscalls.h>
71273 +#include <linux/security.h>
71274 #include <linux/sched.h>
71275 #include <linux/export.h>
71276 #include <linux/rmap.h>
71277 @@ -385,6 +386,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
71278 return -EINVAL;
71279 if (end == start)
71280 return 0;
71281 + if (end > TASK_SIZE)
71282 + return -EINVAL;
71283 +
71284 vma = find_vma(current->mm, start);
71285 if (!vma || vma->vm_start > start)
71286 return -ENOMEM;
71287 @@ -396,6 +400,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
71288 for (nstart = start ; ; ) {
71289 vm_flags_t newflags;
71290
71291 +#ifdef CONFIG_PAX_SEGMEXEC
71292 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
71293 + break;
71294 +#endif
71295 +
71296 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
71297
71298 newflags = vma->vm_flags | VM_LOCKED;
71299 @@ -501,6 +510,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
71300 lock_limit >>= PAGE_SHIFT;
71301
71302 /* check against resource limits */
71303 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
71304 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
71305 error = do_mlock(start, len, 1);
71306 up_write(&current->mm->mmap_sem);
71307 @@ -524,17 +534,23 @@ SYSCALL_DEFINE2(munlock, unsigned long, start, size_t, len)
71308 static int do_mlockall(int flags)
71309 {
71310 struct vm_area_struct * vma, * prev = NULL;
71311 - unsigned int def_flags = 0;
71312
71313 if (flags & MCL_FUTURE)
71314 - def_flags = VM_LOCKED;
71315 - current->mm->def_flags = def_flags;
71316 + current->mm->def_flags |= VM_LOCKED;
71317 + else
71318 + current->mm->def_flags &= ~VM_LOCKED;
71319 if (flags == MCL_FUTURE)
71320 goto out;
71321
71322 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
71323 vm_flags_t newflags;
71324
71325 +#ifdef CONFIG_PAX_SEGMEXEC
71326 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
71327 + break;
71328 +#endif
71329 +
71330 + BUG_ON(vma->vm_end > TASK_SIZE);
71331 newflags = vma->vm_flags | VM_LOCKED;
71332 if (!(flags & MCL_CURRENT))
71333 newflags &= ~VM_LOCKED;
71334 @@ -567,6 +583,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
71335 lock_limit >>= PAGE_SHIFT;
71336
71337 ret = -ENOMEM;
71338 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
71339 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
71340 capable(CAP_IPC_LOCK))
71341 ret = do_mlockall(flags);
71342 diff --git a/mm/mmap.c b/mm/mmap.c
71343 index da15a79..314aef3 100644
71344 --- a/mm/mmap.c
71345 +++ b/mm/mmap.c
71346 @@ -46,6 +46,16 @@
71347 #define arch_rebalance_pgtables(addr, len) (addr)
71348 #endif
71349
71350 +static inline void verify_mm_writelocked(struct mm_struct *mm)
71351 +{
71352 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
71353 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
71354 + up_read(&mm->mmap_sem);
71355 + BUG();
71356 + }
71357 +#endif
71358 +}
71359 +
71360 static void unmap_region(struct mm_struct *mm,
71361 struct vm_area_struct *vma, struct vm_area_struct *prev,
71362 unsigned long start, unsigned long end);
71363 @@ -71,22 +81,32 @@ static void unmap_region(struct mm_struct *mm,
71364 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
71365 *
71366 */
71367 -pgprot_t protection_map[16] = {
71368 +pgprot_t protection_map[16] __read_only = {
71369 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
71370 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
71371 };
71372
71373 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
71374 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
71375 {
71376 - return __pgprot(pgprot_val(protection_map[vm_flags &
71377 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
71378 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
71379 pgprot_val(arch_vm_get_page_prot(vm_flags)));
71380 +
71381 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
71382 + if (!(__supported_pte_mask & _PAGE_NX) &&
71383 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
71384 + (vm_flags & (VM_READ | VM_WRITE)))
71385 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
71386 +#endif
71387 +
71388 + return prot;
71389 }
71390 EXPORT_SYMBOL(vm_get_page_prot);
71391
71392 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; /* heuristic overcommit */
71393 int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
71394 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
71395 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
71396 /*
71397 * Make sure vm_committed_as in one cacheline and not cacheline shared with
71398 * other variables. It can be updated by several CPUs frequently.
71399 @@ -228,6 +248,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
71400 struct vm_area_struct *next = vma->vm_next;
71401
71402 might_sleep();
71403 + BUG_ON(vma->vm_mirror);
71404 if (vma->vm_ops && vma->vm_ops->close)
71405 vma->vm_ops->close(vma);
71406 if (vma->vm_file) {
71407 @@ -272,6 +293,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
71408 * not page aligned -Ram Gupta
71409 */
71410 rlim = rlimit(RLIMIT_DATA);
71411 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
71412 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
71413 (mm->end_data - mm->start_data) > rlim)
71414 goto out;
71415 @@ -689,6 +711,12 @@ static int
71416 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
71417 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
71418 {
71419 +
71420 +#ifdef CONFIG_PAX_SEGMEXEC
71421 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
71422 + return 0;
71423 +#endif
71424 +
71425 if (is_mergeable_vma(vma, file, vm_flags) &&
71426 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
71427 if (vma->vm_pgoff == vm_pgoff)
71428 @@ -708,6 +736,12 @@ static int
71429 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
71430 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
71431 {
71432 +
71433 +#ifdef CONFIG_PAX_SEGMEXEC
71434 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
71435 + return 0;
71436 +#endif
71437 +
71438 if (is_mergeable_vma(vma, file, vm_flags) &&
71439 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
71440 pgoff_t vm_pglen;
71441 @@ -750,13 +784,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
71442 struct vm_area_struct *vma_merge(struct mm_struct *mm,
71443 struct vm_area_struct *prev, unsigned long addr,
71444 unsigned long end, unsigned long vm_flags,
71445 - struct anon_vma *anon_vma, struct file *file,
71446 + struct anon_vma *anon_vma, struct file *file,
71447 pgoff_t pgoff, struct mempolicy *policy)
71448 {
71449 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
71450 struct vm_area_struct *area, *next;
71451 int err;
71452
71453 +#ifdef CONFIG_PAX_SEGMEXEC
71454 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
71455 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
71456 +
71457 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
71458 +#endif
71459 +
71460 /*
71461 * We later require that vma->vm_flags == vm_flags,
71462 * so this tests vma->vm_flags & VM_SPECIAL, too.
71463 @@ -772,6 +813,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
71464 if (next && next->vm_end == end) /* cases 6, 7, 8 */
71465 next = next->vm_next;
71466
71467 +#ifdef CONFIG_PAX_SEGMEXEC
71468 + if (prev)
71469 + prev_m = pax_find_mirror_vma(prev);
71470 + if (area)
71471 + area_m = pax_find_mirror_vma(area);
71472 + if (next)
71473 + next_m = pax_find_mirror_vma(next);
71474 +#endif
71475 +
71476 /*
71477 * Can it merge with the predecessor?
71478 */
71479 @@ -791,9 +841,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
71480 /* cases 1, 6 */
71481 err = vma_adjust(prev, prev->vm_start,
71482 next->vm_end, prev->vm_pgoff, NULL);
71483 - } else /* cases 2, 5, 7 */
71484 +
71485 +#ifdef CONFIG_PAX_SEGMEXEC
71486 + if (!err && prev_m)
71487 + err = vma_adjust(prev_m, prev_m->vm_start,
71488 + next_m->vm_end, prev_m->vm_pgoff, NULL);
71489 +#endif
71490 +
71491 + } else { /* cases 2, 5, 7 */
71492 err = vma_adjust(prev, prev->vm_start,
71493 end, prev->vm_pgoff, NULL);
71494 +
71495 +#ifdef CONFIG_PAX_SEGMEXEC
71496 + if (!err && prev_m)
71497 + err = vma_adjust(prev_m, prev_m->vm_start,
71498 + end_m, prev_m->vm_pgoff, NULL);
71499 +#endif
71500 +
71501 + }
71502 if (err)
71503 return NULL;
71504 khugepaged_enter_vma_merge(prev);
71505 @@ -807,12 +872,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
71506 mpol_equal(policy, vma_policy(next)) &&
71507 can_vma_merge_before(next, vm_flags,
71508 anon_vma, file, pgoff+pglen)) {
71509 - if (prev && addr < prev->vm_end) /* case 4 */
71510 + if (prev && addr < prev->vm_end) { /* case 4 */
71511 err = vma_adjust(prev, prev->vm_start,
71512 addr, prev->vm_pgoff, NULL);
71513 - else /* cases 3, 8 */
71514 +
71515 +#ifdef CONFIG_PAX_SEGMEXEC
71516 + if (!err && prev_m)
71517 + err = vma_adjust(prev_m, prev_m->vm_start,
71518 + addr_m, prev_m->vm_pgoff, NULL);
71519 +#endif
71520 +
71521 + } else { /* cases 3, 8 */
71522 err = vma_adjust(area, addr, next->vm_end,
71523 next->vm_pgoff - pglen, NULL);
71524 +
71525 +#ifdef CONFIG_PAX_SEGMEXEC
71526 + if (!err && area_m)
71527 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
71528 + next_m->vm_pgoff - pglen, NULL);
71529 +#endif
71530 +
71531 + }
71532 if (err)
71533 return NULL;
71534 khugepaged_enter_vma_merge(area);
71535 @@ -921,14 +1001,11 @@ none:
71536 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
71537 struct file *file, long pages)
71538 {
71539 - const unsigned long stack_flags
71540 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
71541 -
71542 if (file) {
71543 mm->shared_vm += pages;
71544 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
71545 mm->exec_vm += pages;
71546 - } else if (flags & stack_flags)
71547 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
71548 mm->stack_vm += pages;
71549 if (flags & (VM_RESERVED|VM_IO))
71550 mm->reserved_vm += pages;
71551 @@ -955,7 +1032,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
71552 * (the exception is when the underlying filesystem is noexec
71553 * mounted, in which case we dont add PROT_EXEC.)
71554 */
71555 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
71556 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
71557 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
71558 prot |= PROT_EXEC;
71559
71560 @@ -981,7 +1058,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
71561 /* Obtain the address to map to. we verify (or select) it and ensure
71562 * that it represents a valid section of the address space.
71563 */
71564 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
71565 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
71566 if (addr & ~PAGE_MASK)
71567 return addr;
71568
71569 @@ -992,6 +1069,36 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
71570 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
71571 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
71572
71573 +#ifdef CONFIG_PAX_MPROTECT
71574 + if (mm->pax_flags & MF_PAX_MPROTECT) {
71575 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
71576 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
71577 + gr_log_rwxmmap(file);
71578 +
71579 +#ifdef CONFIG_PAX_EMUPLT
71580 + vm_flags &= ~VM_EXEC;
71581 +#else
71582 + return -EPERM;
71583 +#endif
71584 +
71585 + }
71586 +
71587 + if (!(vm_flags & VM_EXEC))
71588 + vm_flags &= ~VM_MAYEXEC;
71589 +#else
71590 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
71591 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
71592 +#endif
71593 + else
71594 + vm_flags &= ~VM_MAYWRITE;
71595 + }
71596 +#endif
71597 +
71598 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
71599 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
71600 + vm_flags &= ~VM_PAGEEXEC;
71601 +#endif
71602 +
71603 if (flags & MAP_LOCKED)
71604 if (!can_do_mlock())
71605 return -EPERM;
71606 @@ -1003,6 +1110,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
71607 locked += mm->locked_vm;
71608 lock_limit = rlimit(RLIMIT_MEMLOCK);
71609 lock_limit >>= PAGE_SHIFT;
71610 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
71611 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
71612 return -EAGAIN;
71613 }
71614 @@ -1073,6 +1181,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
71615 if (error)
71616 return error;
71617
71618 + if (!gr_acl_handle_mmap(file, prot))
71619 + return -EACCES;
71620 +
71621 return mmap_region(file, addr, len, flags, vm_flags, pgoff);
71622 }
71623 EXPORT_SYMBOL(do_mmap_pgoff);
71624 @@ -1153,7 +1264,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
71625 vm_flags_t vm_flags = vma->vm_flags;
71626
71627 /* If it was private or non-writable, the write bit is already clear */
71628 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
71629 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
71630 return 0;
71631
71632 /* The backer wishes to know when pages are first written to? */
71633 @@ -1202,14 +1313,24 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
71634 unsigned long charged = 0;
71635 struct inode *inode = file ? file->f_path.dentry->d_inode : NULL;
71636
71637 +#ifdef CONFIG_PAX_SEGMEXEC
71638 + struct vm_area_struct *vma_m = NULL;
71639 +#endif
71640 +
71641 + /*
71642 + * mm->mmap_sem is required to protect against another thread
71643 + * changing the mappings in case we sleep.
71644 + */
71645 + verify_mm_writelocked(mm);
71646 +
71647 /* Clear old maps */
71648 error = -ENOMEM;
71649 -munmap_back:
71650 vma = find_vma_prepare(mm, addr, &prev, &rb_link, &rb_parent);
71651 if (vma && vma->vm_start < addr + len) {
71652 if (do_munmap(mm, addr, len))
71653 return -ENOMEM;
71654 - goto munmap_back;
71655 + vma = find_vma_prepare(mm, addr, &prev, &rb_link, &rb_parent);
71656 + BUG_ON(vma && vma->vm_start < addr + len);
71657 }
71658
71659 /* Check against address space limit. */
71660 @@ -1258,6 +1379,16 @@ munmap_back:
71661 goto unacct_error;
71662 }
71663
71664 +#ifdef CONFIG_PAX_SEGMEXEC
71665 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
71666 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
71667 + if (!vma_m) {
71668 + error = -ENOMEM;
71669 + goto free_vma;
71670 + }
71671 + }
71672 +#endif
71673 +
71674 vma->vm_mm = mm;
71675 vma->vm_start = addr;
71676 vma->vm_end = addr + len;
71677 @@ -1282,6 +1413,19 @@ munmap_back:
71678 error = file->f_op->mmap(file, vma);
71679 if (error)
71680 goto unmap_and_free_vma;
71681 +
71682 +#ifdef CONFIG_PAX_SEGMEXEC
71683 + if (vma_m && (vm_flags & VM_EXECUTABLE))
71684 + added_exe_file_vma(mm);
71685 +#endif
71686 +
71687 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
71688 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
71689 + vma->vm_flags |= VM_PAGEEXEC;
71690 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
71691 + }
71692 +#endif
71693 +
71694 if (vm_flags & VM_EXECUTABLE)
71695 added_exe_file_vma(mm);
71696
71697 @@ -1319,6 +1463,11 @@ munmap_back:
71698 vma_link(mm, vma, prev, rb_link, rb_parent);
71699 file = vma->vm_file;
71700
71701 +#ifdef CONFIG_PAX_SEGMEXEC
71702 + if (vma_m)
71703 + BUG_ON(pax_mirror_vma(vma_m, vma));
71704 +#endif
71705 +
71706 /* Once vma denies write, undo our temporary denial count */
71707 if (correct_wcount)
71708 atomic_inc(&inode->i_writecount);
71709 @@ -1327,6 +1476,7 @@ out:
71710
71711 mm->total_vm += len >> PAGE_SHIFT;
71712 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
71713 + track_exec_limit(mm, addr, addr + len, vm_flags);
71714 if (vm_flags & VM_LOCKED) {
71715 if (!mlock_vma_pages_range(vma, addr, addr + len))
71716 mm->locked_vm += (len >> PAGE_SHIFT);
71717 @@ -1344,6 +1494,12 @@ unmap_and_free_vma:
71718 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
71719 charged = 0;
71720 free_vma:
71721 +
71722 +#ifdef CONFIG_PAX_SEGMEXEC
71723 + if (vma_m)
71724 + kmem_cache_free(vm_area_cachep, vma_m);
71725 +#endif
71726 +
71727 kmem_cache_free(vm_area_cachep, vma);
71728 unacct_error:
71729 if (charged)
71730 @@ -1351,6 +1507,44 @@ unacct_error:
71731 return error;
71732 }
71733
71734 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len)
71735 +{
71736 + if (!vma) {
71737 +#ifdef CONFIG_STACK_GROWSUP
71738 + if (addr > sysctl_heap_stack_gap)
71739 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
71740 + else
71741 + vma = find_vma(current->mm, 0);
71742 + if (vma && (vma->vm_flags & VM_GROWSUP))
71743 + return false;
71744 +#endif
71745 + return true;
71746 + }
71747 +
71748 + if (addr + len > vma->vm_start)
71749 + return false;
71750 +
71751 + if (vma->vm_flags & VM_GROWSDOWN)
71752 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
71753 +#ifdef CONFIG_STACK_GROWSUP
71754 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
71755 + return addr - vma->vm_prev->vm_end <= sysctl_heap_stack_gap;
71756 +#endif
71757 +
71758 + return true;
71759 +}
71760 +
71761 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len)
71762 +{
71763 + if (vma->vm_start < len)
71764 + return -ENOMEM;
71765 + if (!(vma->vm_flags & VM_GROWSDOWN))
71766 + return vma->vm_start - len;
71767 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
71768 + return vma->vm_start - len - sysctl_heap_stack_gap;
71769 + return -ENOMEM;
71770 +}
71771 +
71772 /* Get an address range which is currently unmapped.
71773 * For shmat() with addr=0.
71774 *
71775 @@ -1377,18 +1571,23 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
71776 if (flags & MAP_FIXED)
71777 return addr;
71778
71779 +#ifdef CONFIG_PAX_RANDMMAP
71780 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
71781 +#endif
71782 +
71783 if (addr) {
71784 addr = PAGE_ALIGN(addr);
71785 - vma = find_vma(mm, addr);
71786 - if (TASK_SIZE - len >= addr &&
71787 - (!vma || addr + len <= vma->vm_start))
71788 - return addr;
71789 + if (TASK_SIZE - len >= addr) {
71790 + vma = find_vma(mm, addr);
71791 + if (check_heap_stack_gap(vma, addr, len))
71792 + return addr;
71793 + }
71794 }
71795 if (len > mm->cached_hole_size) {
71796 - start_addr = addr = mm->free_area_cache;
71797 + start_addr = addr = mm->free_area_cache;
71798 } else {
71799 - start_addr = addr = TASK_UNMAPPED_BASE;
71800 - mm->cached_hole_size = 0;
71801 + start_addr = addr = mm->mmap_base;
71802 + mm->cached_hole_size = 0;
71803 }
71804
71805 full_search:
71806 @@ -1399,34 +1598,40 @@ full_search:
71807 * Start a new search - just in case we missed
71808 * some holes.
71809 */
71810 - if (start_addr != TASK_UNMAPPED_BASE) {
71811 - addr = TASK_UNMAPPED_BASE;
71812 - start_addr = addr;
71813 + if (start_addr != mm->mmap_base) {
71814 + start_addr = addr = mm->mmap_base;
71815 mm->cached_hole_size = 0;
71816 goto full_search;
71817 }
71818 return -ENOMEM;
71819 }
71820 - if (!vma || addr + len <= vma->vm_start) {
71821 - /*
71822 - * Remember the place where we stopped the search:
71823 - */
71824 - mm->free_area_cache = addr + len;
71825 - return addr;
71826 - }
71827 + if (check_heap_stack_gap(vma, addr, len))
71828 + break;
71829 if (addr + mm->cached_hole_size < vma->vm_start)
71830 mm->cached_hole_size = vma->vm_start - addr;
71831 addr = vma->vm_end;
71832 }
71833 +
71834 + /*
71835 + * Remember the place where we stopped the search:
71836 + */
71837 + mm->free_area_cache = addr + len;
71838 + return addr;
71839 }
71840 #endif
71841
71842 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
71843 {
71844 +
71845 +#ifdef CONFIG_PAX_SEGMEXEC
71846 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
71847 + return;
71848 +#endif
71849 +
71850 /*
71851 * Is this a new hole at the lowest possible address?
71852 */
71853 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache) {
71854 + if (addr >= mm->mmap_base && addr < mm->free_area_cache) {
71855 mm->free_area_cache = addr;
71856 mm->cached_hole_size = ~0UL;
71857 }
71858 @@ -1444,7 +1649,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
71859 {
71860 struct vm_area_struct *vma;
71861 struct mm_struct *mm = current->mm;
71862 - unsigned long addr = addr0;
71863 + unsigned long base = mm->mmap_base, addr = addr0;
71864
71865 /* requested length too big for entire address space */
71866 if (len > TASK_SIZE)
71867 @@ -1453,13 +1658,18 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
71868 if (flags & MAP_FIXED)
71869 return addr;
71870
71871 +#ifdef CONFIG_PAX_RANDMMAP
71872 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
71873 +#endif
71874 +
71875 /* requesting a specific address */
71876 if (addr) {
71877 addr = PAGE_ALIGN(addr);
71878 - vma = find_vma(mm, addr);
71879 - if (TASK_SIZE - len >= addr &&
71880 - (!vma || addr + len <= vma->vm_start))
71881 - return addr;
71882 + if (TASK_SIZE - len >= addr) {
71883 + vma = find_vma(mm, addr);
71884 + if (check_heap_stack_gap(vma, addr, len))
71885 + return addr;
71886 + }
71887 }
71888
71889 /* check if free_area_cache is useful for us */
71890 @@ -1474,7 +1684,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
71891 /* make sure it can fit in the remaining address space */
71892 if (addr > len) {
71893 vma = find_vma(mm, addr-len);
71894 - if (!vma || addr <= vma->vm_start)
71895 + if (check_heap_stack_gap(vma, addr - len, len))
71896 /* remember the address as a hint for next time */
71897 return (mm->free_area_cache = addr-len);
71898 }
71899 @@ -1491,7 +1701,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
71900 * return with success:
71901 */
71902 vma = find_vma(mm, addr);
71903 - if (!vma || addr+len <= vma->vm_start)
71904 + if (check_heap_stack_gap(vma, addr, len))
71905 /* remember the address as a hint for next time */
71906 return (mm->free_area_cache = addr);
71907
71908 @@ -1500,8 +1710,8 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
71909 mm->cached_hole_size = vma->vm_start - addr;
71910
71911 /* try just below the current vma->vm_start */
71912 - addr = vma->vm_start-len;
71913 - } while (len < vma->vm_start);
71914 + addr = skip_heap_stack_gap(vma, len);
71915 + } while (!IS_ERR_VALUE(addr));
71916
71917 bottomup:
71918 /*
71919 @@ -1510,13 +1720,21 @@ bottomup:
71920 * can happen with large stack limits and large mmap()
71921 * allocations.
71922 */
71923 + mm->mmap_base = TASK_UNMAPPED_BASE;
71924 +
71925 +#ifdef CONFIG_PAX_RANDMMAP
71926 + if (mm->pax_flags & MF_PAX_RANDMMAP)
71927 + mm->mmap_base += mm->delta_mmap;
71928 +#endif
71929 +
71930 + mm->free_area_cache = mm->mmap_base;
71931 mm->cached_hole_size = ~0UL;
71932 - mm->free_area_cache = TASK_UNMAPPED_BASE;
71933 addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
71934 /*
71935 * Restore the topdown base:
71936 */
71937 - mm->free_area_cache = mm->mmap_base;
71938 + mm->mmap_base = base;
71939 + mm->free_area_cache = base;
71940 mm->cached_hole_size = ~0UL;
71941
71942 return addr;
71943 @@ -1525,6 +1743,12 @@ bottomup:
71944
71945 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
71946 {
71947 +
71948 +#ifdef CONFIG_PAX_SEGMEXEC
71949 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
71950 + return;
71951 +#endif
71952 +
71953 /*
71954 * Is this a new hole at the highest possible address?
71955 */
71956 @@ -1532,8 +1756,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
71957 mm->free_area_cache = addr;
71958
71959 /* dont allow allocations above current base */
71960 - if (mm->free_area_cache > mm->mmap_base)
71961 + if (mm->free_area_cache > mm->mmap_base) {
71962 mm->free_area_cache = mm->mmap_base;
71963 + mm->cached_hole_size = ~0UL;
71964 + }
71965 }
71966
71967 unsigned long
71968 @@ -1629,6 +1855,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
71969 return vma;
71970 }
71971
71972 +#ifdef CONFIG_PAX_SEGMEXEC
71973 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
71974 +{
71975 + struct vm_area_struct *vma_m;
71976 +
71977 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
71978 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
71979 + BUG_ON(vma->vm_mirror);
71980 + return NULL;
71981 + }
71982 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
71983 + vma_m = vma->vm_mirror;
71984 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
71985 + BUG_ON(vma->vm_file != vma_m->vm_file);
71986 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
71987 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
71988 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
71989 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED | VM_RESERVED));
71990 + return vma_m;
71991 +}
71992 +#endif
71993 +
71994 /*
71995 * Verify that the stack growth is acceptable and
71996 * update accounting. This is shared with both the
71997 @@ -1645,6 +1893,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
71998 return -ENOMEM;
71999
72000 /* Stack limit test */
72001 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
72002 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
72003 return -ENOMEM;
72004
72005 @@ -1655,6 +1904,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
72006 locked = mm->locked_vm + grow;
72007 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
72008 limit >>= PAGE_SHIFT;
72009 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
72010 if (locked > limit && !capable(CAP_IPC_LOCK))
72011 return -ENOMEM;
72012 }
72013 @@ -1685,37 +1935,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
72014 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
72015 * vma is the last one with address > vma->vm_end. Have to extend vma.
72016 */
72017 +#ifndef CONFIG_IA64
72018 +static
72019 +#endif
72020 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
72021 {
72022 int error;
72023 + bool locknext;
72024
72025 if (!(vma->vm_flags & VM_GROWSUP))
72026 return -EFAULT;
72027
72028 + /* Also guard against wrapping around to address 0. */
72029 + if (address < PAGE_ALIGN(address+1))
72030 + address = PAGE_ALIGN(address+1);
72031 + else
72032 + return -ENOMEM;
72033 +
72034 /*
72035 * We must make sure the anon_vma is allocated
72036 * so that the anon_vma locking is not a noop.
72037 */
72038 if (unlikely(anon_vma_prepare(vma)))
72039 return -ENOMEM;
72040 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
72041 + if (locknext && anon_vma_prepare(vma->vm_next))
72042 + return -ENOMEM;
72043 vma_lock_anon_vma(vma);
72044 + if (locknext)
72045 + vma_lock_anon_vma(vma->vm_next);
72046
72047 /*
72048 * vma->vm_start/vm_end cannot change under us because the caller
72049 * is required to hold the mmap_sem in read mode. We need the
72050 - * anon_vma lock to serialize against concurrent expand_stacks.
72051 - * Also guard against wrapping around to address 0.
72052 + * anon_vma locks to serialize against concurrent expand_stacks
72053 + * and expand_upwards.
72054 */
72055 - if (address < PAGE_ALIGN(address+4))
72056 - address = PAGE_ALIGN(address+4);
72057 - else {
72058 - vma_unlock_anon_vma(vma);
72059 - return -ENOMEM;
72060 - }
72061 error = 0;
72062
72063 /* Somebody else might have raced and expanded it already */
72064 - if (address > vma->vm_end) {
72065 + 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)
72066 + error = -ENOMEM;
72067 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
72068 unsigned long size, grow;
72069
72070 size = address - vma->vm_start;
72071 @@ -1730,6 +1991,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
72072 }
72073 }
72074 }
72075 + if (locknext)
72076 + vma_unlock_anon_vma(vma->vm_next);
72077 vma_unlock_anon_vma(vma);
72078 khugepaged_enter_vma_merge(vma);
72079 return error;
72080 @@ -1743,6 +2006,8 @@ int expand_downwards(struct vm_area_struct *vma,
72081 unsigned long address)
72082 {
72083 int error;
72084 + bool lockprev = false;
72085 + struct vm_area_struct *prev;
72086
72087 /*
72088 * We must make sure the anon_vma is allocated
72089 @@ -1756,6 +2021,15 @@ int expand_downwards(struct vm_area_struct *vma,
72090 if (error)
72091 return error;
72092
72093 + prev = vma->vm_prev;
72094 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
72095 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
72096 +#endif
72097 + if (lockprev && anon_vma_prepare(prev))
72098 + return -ENOMEM;
72099 + if (lockprev)
72100 + vma_lock_anon_vma(prev);
72101 +
72102 vma_lock_anon_vma(vma);
72103
72104 /*
72105 @@ -1765,9 +2039,17 @@ int expand_downwards(struct vm_area_struct *vma,
72106 */
72107
72108 /* Somebody else might have raced and expanded it already */
72109 - if (address < vma->vm_start) {
72110 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
72111 + error = -ENOMEM;
72112 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
72113 unsigned long size, grow;
72114
72115 +#ifdef CONFIG_PAX_SEGMEXEC
72116 + struct vm_area_struct *vma_m;
72117 +
72118 + vma_m = pax_find_mirror_vma(vma);
72119 +#endif
72120 +
72121 size = vma->vm_end - address;
72122 grow = (vma->vm_start - address) >> PAGE_SHIFT;
72123
72124 @@ -1777,11 +2059,22 @@ int expand_downwards(struct vm_area_struct *vma,
72125 if (!error) {
72126 vma->vm_start = address;
72127 vma->vm_pgoff -= grow;
72128 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
72129 +
72130 +#ifdef CONFIG_PAX_SEGMEXEC
72131 + if (vma_m) {
72132 + vma_m->vm_start -= grow << PAGE_SHIFT;
72133 + vma_m->vm_pgoff -= grow;
72134 + }
72135 +#endif
72136 +
72137 perf_event_mmap(vma);
72138 }
72139 }
72140 }
72141 vma_unlock_anon_vma(vma);
72142 + if (lockprev)
72143 + vma_unlock_anon_vma(prev);
72144 khugepaged_enter_vma_merge(vma);
72145 return error;
72146 }
72147 @@ -1851,6 +2144,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
72148 do {
72149 long nrpages = vma_pages(vma);
72150
72151 +#ifdef CONFIG_PAX_SEGMEXEC
72152 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
72153 + vma = remove_vma(vma);
72154 + continue;
72155 + }
72156 +#endif
72157 +
72158 mm->total_vm -= nrpages;
72159 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
72160 vma = remove_vma(vma);
72161 @@ -1896,6 +2196,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
72162 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
72163 vma->vm_prev = NULL;
72164 do {
72165 +
72166 +#ifdef CONFIG_PAX_SEGMEXEC
72167 + if (vma->vm_mirror) {
72168 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
72169 + vma->vm_mirror->vm_mirror = NULL;
72170 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
72171 + vma->vm_mirror = NULL;
72172 + }
72173 +#endif
72174 +
72175 rb_erase(&vma->vm_rb, &mm->mm_rb);
72176 mm->map_count--;
72177 tail_vma = vma;
72178 @@ -1924,14 +2234,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
72179 struct vm_area_struct *new;
72180 int err = -ENOMEM;
72181
72182 +#ifdef CONFIG_PAX_SEGMEXEC
72183 + struct vm_area_struct *vma_m, *new_m = NULL;
72184 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
72185 +#endif
72186 +
72187 if (is_vm_hugetlb_page(vma) && (addr &
72188 ~(huge_page_mask(hstate_vma(vma)))))
72189 return -EINVAL;
72190
72191 +#ifdef CONFIG_PAX_SEGMEXEC
72192 + vma_m = pax_find_mirror_vma(vma);
72193 +#endif
72194 +
72195 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
72196 if (!new)
72197 goto out_err;
72198
72199 +#ifdef CONFIG_PAX_SEGMEXEC
72200 + if (vma_m) {
72201 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
72202 + if (!new_m) {
72203 + kmem_cache_free(vm_area_cachep, new);
72204 + goto out_err;
72205 + }
72206 + }
72207 +#endif
72208 +
72209 /* most fields are the same, copy all, and then fixup */
72210 *new = *vma;
72211
72212 @@ -1944,6 +2273,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
72213 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
72214 }
72215
72216 +#ifdef CONFIG_PAX_SEGMEXEC
72217 + if (vma_m) {
72218 + *new_m = *vma_m;
72219 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
72220 + new_m->vm_mirror = new;
72221 + new->vm_mirror = new_m;
72222 +
72223 + if (new_below)
72224 + new_m->vm_end = addr_m;
72225 + else {
72226 + new_m->vm_start = addr_m;
72227 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
72228 + }
72229 + }
72230 +#endif
72231 +
72232 pol = mpol_dup(vma_policy(vma));
72233 if (IS_ERR(pol)) {
72234 err = PTR_ERR(pol);
72235 @@ -1969,6 +2314,42 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
72236 else
72237 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
72238
72239 +#ifdef CONFIG_PAX_SEGMEXEC
72240 + if (!err && vma_m) {
72241 + if (anon_vma_clone(new_m, vma_m))
72242 + goto out_free_mpol;
72243 +
72244 + mpol_get(pol);
72245 + vma_set_policy(new_m, pol);
72246 +
72247 + if (new_m->vm_file) {
72248 + get_file(new_m->vm_file);
72249 + if (vma_m->vm_flags & VM_EXECUTABLE)
72250 + added_exe_file_vma(mm);
72251 + }
72252 +
72253 + if (new_m->vm_ops && new_m->vm_ops->open)
72254 + new_m->vm_ops->open(new_m);
72255 +
72256 + if (new_below)
72257 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
72258 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
72259 + else
72260 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
72261 +
72262 + if (err) {
72263 + if (new_m->vm_ops && new_m->vm_ops->close)
72264 + new_m->vm_ops->close(new_m);
72265 + if (new_m->vm_file) {
72266 + if (vma_m->vm_flags & VM_EXECUTABLE)
72267 + removed_exe_file_vma(mm);
72268 + fput(new_m->vm_file);
72269 + }
72270 + mpol_put(pol);
72271 + }
72272 + }
72273 +#endif
72274 +
72275 /* Success. */
72276 if (!err)
72277 return 0;
72278 @@ -1981,10 +2362,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
72279 removed_exe_file_vma(mm);
72280 fput(new->vm_file);
72281 }
72282 - unlink_anon_vmas(new);
72283 out_free_mpol:
72284 mpol_put(pol);
72285 out_free_vma:
72286 +
72287 +#ifdef CONFIG_PAX_SEGMEXEC
72288 + if (new_m) {
72289 + unlink_anon_vmas(new_m);
72290 + kmem_cache_free(vm_area_cachep, new_m);
72291 + }
72292 +#endif
72293 +
72294 + unlink_anon_vmas(new);
72295 kmem_cache_free(vm_area_cachep, new);
72296 out_err:
72297 return err;
72298 @@ -1997,6 +2386,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
72299 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
72300 unsigned long addr, int new_below)
72301 {
72302 +
72303 +#ifdef CONFIG_PAX_SEGMEXEC
72304 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
72305 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
72306 + if (mm->map_count >= sysctl_max_map_count-1)
72307 + return -ENOMEM;
72308 + } else
72309 +#endif
72310 +
72311 if (mm->map_count >= sysctl_max_map_count)
72312 return -ENOMEM;
72313
72314 @@ -2008,11 +2406,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
72315 * work. This now handles partial unmappings.
72316 * Jeremy Fitzhardinge <jeremy@goop.org>
72317 */
72318 +#ifdef CONFIG_PAX_SEGMEXEC
72319 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
72320 {
72321 + int ret = __do_munmap(mm, start, len);
72322 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
72323 + return ret;
72324 +
72325 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
72326 +}
72327 +
72328 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
72329 +#else
72330 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
72331 +#endif
72332 +{
72333 unsigned long end;
72334 struct vm_area_struct *vma, *prev, *last;
72335
72336 + /*
72337 + * mm->mmap_sem is required to protect against another thread
72338 + * changing the mappings in case we sleep.
72339 + */
72340 + verify_mm_writelocked(mm);
72341 +
72342 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
72343 return -EINVAL;
72344
72345 @@ -2087,6 +2504,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
72346 /* Fix up all other VM information */
72347 remove_vma_list(mm, vma);
72348
72349 + track_exec_limit(mm, start, end, 0UL);
72350 +
72351 return 0;
72352 }
72353
72354 @@ -2099,22 +2518,18 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
72355
72356 profile_munmap(addr);
72357
72358 +#ifdef CONFIG_PAX_SEGMEXEC
72359 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
72360 + (len > SEGMEXEC_TASK_SIZE || addr > SEGMEXEC_TASK_SIZE-len))
72361 + return -EINVAL;
72362 +#endif
72363 +
72364 down_write(&mm->mmap_sem);
72365 ret = do_munmap(mm, addr, len);
72366 up_write(&mm->mmap_sem);
72367 return ret;
72368 }
72369
72370 -static inline void verify_mm_writelocked(struct mm_struct *mm)
72371 -{
72372 -#ifdef CONFIG_DEBUG_VM
72373 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
72374 - WARN_ON(1);
72375 - up_read(&mm->mmap_sem);
72376 - }
72377 -#endif
72378 -}
72379 -
72380 /*
72381 * this is really a simplified "do_mmap". it only handles
72382 * anonymous maps. eventually we may be able to do some
72383 @@ -2128,6 +2543,7 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
72384 struct rb_node ** rb_link, * rb_parent;
72385 pgoff_t pgoff = addr >> PAGE_SHIFT;
72386 int error;
72387 + unsigned long charged;
72388
72389 len = PAGE_ALIGN(len);
72390 if (!len)
72391 @@ -2139,16 +2555,30 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
72392
72393 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
72394
72395 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
72396 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
72397 + flags &= ~VM_EXEC;
72398 +
72399 +#ifdef CONFIG_PAX_MPROTECT
72400 + if (mm->pax_flags & MF_PAX_MPROTECT)
72401 + flags &= ~VM_MAYEXEC;
72402 +#endif
72403 +
72404 + }
72405 +#endif
72406 +
72407 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
72408 if (error & ~PAGE_MASK)
72409 return error;
72410
72411 + charged = len >> PAGE_SHIFT;
72412 +
72413 /*
72414 * mlock MCL_FUTURE?
72415 */
72416 if (mm->def_flags & VM_LOCKED) {
72417 unsigned long locked, lock_limit;
72418 - locked = len >> PAGE_SHIFT;
72419 + locked = charged;
72420 locked += mm->locked_vm;
72421 lock_limit = rlimit(RLIMIT_MEMLOCK);
72422 lock_limit >>= PAGE_SHIFT;
72423 @@ -2165,22 +2595,22 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
72424 /*
72425 * Clear old maps. this also does some error checking for us
72426 */
72427 - munmap_back:
72428 vma = find_vma_prepare(mm, addr, &prev, &rb_link, &rb_parent);
72429 if (vma && vma->vm_start < addr + len) {
72430 if (do_munmap(mm, addr, len))
72431 return -ENOMEM;
72432 - goto munmap_back;
72433 + vma = find_vma_prepare(mm, addr, &prev, &rb_link, &rb_parent);
72434 + BUG_ON(vma && vma->vm_start < addr + len);
72435 }
72436
72437 /* Check against address space limits *after* clearing old maps... */
72438 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
72439 + if (!may_expand_vm(mm, charged))
72440 return -ENOMEM;
72441
72442 if (mm->map_count > sysctl_max_map_count)
72443 return -ENOMEM;
72444
72445 - if (security_vm_enough_memory(len >> PAGE_SHIFT))
72446 + if (security_vm_enough_memory(charged))
72447 return -ENOMEM;
72448
72449 /* Can we just expand an old private anonymous mapping? */
72450 @@ -2194,7 +2624,7 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
72451 */
72452 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
72453 if (!vma) {
72454 - vm_unacct_memory(len >> PAGE_SHIFT);
72455 + vm_unacct_memory(charged);
72456 return -ENOMEM;
72457 }
72458
72459 @@ -2208,11 +2638,12 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
72460 vma_link(mm, vma, prev, rb_link, rb_parent);
72461 out:
72462 perf_event_mmap(vma);
72463 - mm->total_vm += len >> PAGE_SHIFT;
72464 + mm->total_vm += charged;
72465 if (flags & VM_LOCKED) {
72466 if (!mlock_vma_pages_range(vma, addr, addr + len))
72467 - mm->locked_vm += (len >> PAGE_SHIFT);
72468 + mm->locked_vm += charged;
72469 }
72470 + track_exec_limit(mm, addr, addr + len, flags);
72471 return addr;
72472 }
72473
72474 @@ -2259,8 +2690,10 @@ void exit_mmap(struct mm_struct *mm)
72475 * Walk the list again, actually closing and freeing it,
72476 * with preemption enabled, without holding any MM locks.
72477 */
72478 - while (vma)
72479 + while (vma) {
72480 + vma->vm_mirror = NULL;
72481 vma = remove_vma(vma);
72482 + }
72483
72484 BUG_ON(mm->nr_ptes > (FIRST_USER_ADDRESS+PMD_SIZE-1)>>PMD_SHIFT);
72485 }
72486 @@ -2274,6 +2707,13 @@ int insert_vm_struct(struct mm_struct * mm, struct vm_area_struct * vma)
72487 struct vm_area_struct * __vma, * prev;
72488 struct rb_node ** rb_link, * rb_parent;
72489
72490 +#ifdef CONFIG_PAX_SEGMEXEC
72491 + struct vm_area_struct *vma_m = NULL;
72492 +#endif
72493 +
72494 + if (security_file_mmap(NULL, 0, 0, 0, vma->vm_start, 1))
72495 + return -EPERM;
72496 +
72497 /*
72498 * The vm_pgoff of a purely anonymous vma should be irrelevant
72499 * until its first write fault, when page's anon_vma and index
72500 @@ -2296,7 +2736,22 @@ int insert_vm_struct(struct mm_struct * mm, struct vm_area_struct * vma)
72501 if ((vma->vm_flags & VM_ACCOUNT) &&
72502 security_vm_enough_memory_mm(mm, vma_pages(vma)))
72503 return -ENOMEM;
72504 +
72505 +#ifdef CONFIG_PAX_SEGMEXEC
72506 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
72507 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
72508 + if (!vma_m)
72509 + return -ENOMEM;
72510 + }
72511 +#endif
72512 +
72513 vma_link(mm, vma, prev, rb_link, rb_parent);
72514 +
72515 +#ifdef CONFIG_PAX_SEGMEXEC
72516 + if (vma_m)
72517 + BUG_ON(pax_mirror_vma(vma_m, vma));
72518 +#endif
72519 +
72520 return 0;
72521 }
72522
72523 @@ -2315,6 +2770,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
72524 struct mempolicy *pol;
72525 bool faulted_in_anon_vma = true;
72526
72527 + BUG_ON(vma->vm_mirror);
72528 +
72529 /*
72530 * If anonymous vma has not yet been faulted, update new pgoff
72531 * to match new location, to increase its chance of merging.
72532 @@ -2382,6 +2839,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
72533 return NULL;
72534 }
72535
72536 +#ifdef CONFIG_PAX_SEGMEXEC
72537 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
72538 +{
72539 + struct vm_area_struct *prev_m;
72540 + struct rb_node **rb_link_m, *rb_parent_m;
72541 + struct mempolicy *pol_m;
72542 +
72543 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
72544 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
72545 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
72546 + *vma_m = *vma;
72547 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
72548 + if (anon_vma_clone(vma_m, vma))
72549 + return -ENOMEM;
72550 + pol_m = vma_policy(vma_m);
72551 + mpol_get(pol_m);
72552 + vma_set_policy(vma_m, pol_m);
72553 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
72554 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
72555 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
72556 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
72557 + if (vma_m->vm_file)
72558 + get_file(vma_m->vm_file);
72559 + if (vma_m->vm_ops && vma_m->vm_ops->open)
72560 + vma_m->vm_ops->open(vma_m);
72561 + find_vma_prepare(vma->vm_mm, vma_m->vm_start, &prev_m, &rb_link_m, &rb_parent_m);
72562 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
72563 + vma_m->vm_mirror = vma;
72564 + vma->vm_mirror = vma_m;
72565 + return 0;
72566 +}
72567 +#endif
72568 +
72569 /*
72570 * Return true if the calling process may expand its vm space by the passed
72571 * number of pages
72572 @@ -2393,6 +2883,12 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
72573
72574 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
72575
72576 +#ifdef CONFIG_PAX_RANDMMAP
72577 + if (mm->pax_flags & MF_PAX_RANDMMAP)
72578 + cur -= mm->brk_gap;
72579 +#endif
72580 +
72581 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
72582 if (cur + npages > lim)
72583 return 0;
72584 return 1;
72585 @@ -2463,6 +2959,22 @@ int install_special_mapping(struct mm_struct *mm,
72586 vma->vm_start = addr;
72587 vma->vm_end = addr + len;
72588
72589 +#ifdef CONFIG_PAX_MPROTECT
72590 + if (mm->pax_flags & MF_PAX_MPROTECT) {
72591 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
72592 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
72593 + return -EPERM;
72594 + if (!(vm_flags & VM_EXEC))
72595 + vm_flags &= ~VM_MAYEXEC;
72596 +#else
72597 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
72598 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
72599 +#endif
72600 + else
72601 + vm_flags &= ~VM_MAYWRITE;
72602 + }
72603 +#endif
72604 +
72605 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
72606 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
72607
72608 diff --git a/mm/mprotect.c b/mm/mprotect.c
72609 index f437d05..e3763f6 100644
72610 --- a/mm/mprotect.c
72611 +++ b/mm/mprotect.c
72612 @@ -23,10 +23,16 @@
72613 #include <linux/mmu_notifier.h>
72614 #include <linux/migrate.h>
72615 #include <linux/perf_event.h>
72616 +
72617 +#ifdef CONFIG_PAX_MPROTECT
72618 +#include <linux/elf.h>
72619 +#endif
72620 +
72621 #include <asm/uaccess.h>
72622 #include <asm/pgtable.h>
72623 #include <asm/cacheflush.h>
72624 #include <asm/tlbflush.h>
72625 +#include <asm/mmu_context.h>
72626
72627 #ifndef pgprot_modify
72628 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
72629 @@ -141,6 +147,48 @@ static void change_protection(struct vm_area_struct *vma,
72630 flush_tlb_range(vma, start, end);
72631 }
72632
72633 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
72634 +/* called while holding the mmap semaphor for writing except stack expansion */
72635 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
72636 +{
72637 + unsigned long oldlimit, newlimit = 0UL;
72638 +
72639 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
72640 + return;
72641 +
72642 + spin_lock(&mm->page_table_lock);
72643 + oldlimit = mm->context.user_cs_limit;
72644 + if ((prot & VM_EXEC) && oldlimit < end)
72645 + /* USER_CS limit moved up */
72646 + newlimit = end;
72647 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
72648 + /* USER_CS limit moved down */
72649 + newlimit = start;
72650 +
72651 + if (newlimit) {
72652 + mm->context.user_cs_limit = newlimit;
72653 +
72654 +#ifdef CONFIG_SMP
72655 + wmb();
72656 + cpus_clear(mm->context.cpu_user_cs_mask);
72657 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
72658 +#endif
72659 +
72660 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
72661 + }
72662 + spin_unlock(&mm->page_table_lock);
72663 + if (newlimit == end) {
72664 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
72665 +
72666 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
72667 + if (is_vm_hugetlb_page(vma))
72668 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
72669 + else
72670 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma));
72671 + }
72672 +}
72673 +#endif
72674 +
72675 int
72676 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
72677 unsigned long start, unsigned long end, unsigned long newflags)
72678 @@ -153,11 +201,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
72679 int error;
72680 int dirty_accountable = 0;
72681
72682 +#ifdef CONFIG_PAX_SEGMEXEC
72683 + struct vm_area_struct *vma_m = NULL;
72684 + unsigned long start_m, end_m;
72685 +
72686 + start_m = start + SEGMEXEC_TASK_SIZE;
72687 + end_m = end + SEGMEXEC_TASK_SIZE;
72688 +#endif
72689 +
72690 if (newflags == oldflags) {
72691 *pprev = vma;
72692 return 0;
72693 }
72694
72695 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
72696 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
72697 +
72698 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
72699 + return -ENOMEM;
72700 +
72701 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
72702 + return -ENOMEM;
72703 + }
72704 +
72705 /*
72706 * If we make a private mapping writable we increase our commit;
72707 * but (without finer accounting) cannot reduce our commit if we
72708 @@ -174,6 +240,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
72709 }
72710 }
72711
72712 +#ifdef CONFIG_PAX_SEGMEXEC
72713 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
72714 + if (start != vma->vm_start) {
72715 + error = split_vma(mm, vma, start, 1);
72716 + if (error)
72717 + goto fail;
72718 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
72719 + *pprev = (*pprev)->vm_next;
72720 + }
72721 +
72722 + if (end != vma->vm_end) {
72723 + error = split_vma(mm, vma, end, 0);
72724 + if (error)
72725 + goto fail;
72726 + }
72727 +
72728 + if (pax_find_mirror_vma(vma)) {
72729 + error = __do_munmap(mm, start_m, end_m - start_m);
72730 + if (error)
72731 + goto fail;
72732 + } else {
72733 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
72734 + if (!vma_m) {
72735 + error = -ENOMEM;
72736 + goto fail;
72737 + }
72738 + vma->vm_flags = newflags;
72739 + error = pax_mirror_vma(vma_m, vma);
72740 + if (error) {
72741 + vma->vm_flags = oldflags;
72742 + goto fail;
72743 + }
72744 + }
72745 + }
72746 +#endif
72747 +
72748 /*
72749 * First try to merge with previous and/or next vma.
72750 */
72751 @@ -204,9 +306,21 @@ success:
72752 * vm_flags and vm_page_prot are protected by the mmap_sem
72753 * held in write mode.
72754 */
72755 +
72756 +#ifdef CONFIG_PAX_SEGMEXEC
72757 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
72758 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
72759 +#endif
72760 +
72761 vma->vm_flags = newflags;
72762 +
72763 +#ifdef CONFIG_PAX_MPROTECT
72764 + if (mm->binfmt && mm->binfmt->handle_mprotect)
72765 + mm->binfmt->handle_mprotect(vma, newflags);
72766 +#endif
72767 +
72768 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
72769 - vm_get_page_prot(newflags));
72770 + vm_get_page_prot(vma->vm_flags));
72771
72772 if (vma_wants_writenotify(vma)) {
72773 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
72774 @@ -248,6 +362,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
72775 end = start + len;
72776 if (end <= start)
72777 return -ENOMEM;
72778 +
72779 +#ifdef CONFIG_PAX_SEGMEXEC
72780 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
72781 + if (end > SEGMEXEC_TASK_SIZE)
72782 + return -EINVAL;
72783 + } else
72784 +#endif
72785 +
72786 + if (end > TASK_SIZE)
72787 + return -EINVAL;
72788 +
72789 if (!arch_validate_prot(prot))
72790 return -EINVAL;
72791
72792 @@ -255,7 +380,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
72793 /*
72794 * Does the application expect PROT_READ to imply PROT_EXEC:
72795 */
72796 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
72797 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
72798 prot |= PROT_EXEC;
72799
72800 vm_flags = calc_vm_prot_bits(prot);
72801 @@ -288,6 +413,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
72802 if (start > vma->vm_start)
72803 prev = vma;
72804
72805 +#ifdef CONFIG_PAX_MPROTECT
72806 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
72807 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
72808 +#endif
72809 +
72810 for (nstart = start ; ; ) {
72811 unsigned long newflags;
72812
72813 @@ -297,6 +427,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
72814
72815 /* newflags >> 4 shift VM_MAY% in place of VM_% */
72816 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
72817 + if (prot & (PROT_WRITE | PROT_EXEC))
72818 + gr_log_rwxmprotect(vma->vm_file);
72819 +
72820 + error = -EACCES;
72821 + goto out;
72822 + }
72823 +
72824 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
72825 error = -EACCES;
72826 goto out;
72827 }
72828 @@ -311,6 +449,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
72829 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
72830 if (error)
72831 goto out;
72832 +
72833 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
72834 +
72835 nstart = tmp;
72836
72837 if (nstart < prev->vm_end)
72838 diff --git a/mm/mremap.c b/mm/mremap.c
72839 index 87bb839..c3bfadb 100644
72840 --- a/mm/mremap.c
72841 +++ b/mm/mremap.c
72842 @@ -106,6 +106,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
72843 continue;
72844 pte = ptep_get_and_clear(mm, old_addr, old_pte);
72845 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
72846 +
72847 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
72848 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
72849 + pte = pte_exprotect(pte);
72850 +#endif
72851 +
72852 set_pte_at(mm, new_addr, new_pte, pte);
72853 }
72854
72855 @@ -299,6 +305,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
72856 if (is_vm_hugetlb_page(vma))
72857 goto Einval;
72858
72859 +#ifdef CONFIG_PAX_SEGMEXEC
72860 + if (pax_find_mirror_vma(vma))
72861 + goto Einval;
72862 +#endif
72863 +
72864 /* We can't remap across vm area boundaries */
72865 if (old_len > vma->vm_end - addr)
72866 goto Efault;
72867 @@ -355,20 +366,25 @@ static unsigned long mremap_to(unsigned long addr,
72868 unsigned long ret = -EINVAL;
72869 unsigned long charged = 0;
72870 unsigned long map_flags;
72871 + unsigned long pax_task_size = TASK_SIZE;
72872
72873 if (new_addr & ~PAGE_MASK)
72874 goto out;
72875
72876 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
72877 +#ifdef CONFIG_PAX_SEGMEXEC
72878 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
72879 + pax_task_size = SEGMEXEC_TASK_SIZE;
72880 +#endif
72881 +
72882 + pax_task_size -= PAGE_SIZE;
72883 +
72884 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
72885 goto out;
72886
72887 /* Check if the location we're moving into overlaps the
72888 * old location at all, and fail if it does.
72889 */
72890 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
72891 - goto out;
72892 -
72893 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
72894 + if (addr + old_len > new_addr && new_addr + new_len > addr)
72895 goto out;
72896
72897 ret = security_file_mmap(NULL, 0, 0, 0, new_addr, 1);
72898 @@ -440,6 +456,7 @@ unsigned long do_mremap(unsigned long addr,
72899 struct vm_area_struct *vma;
72900 unsigned long ret = -EINVAL;
72901 unsigned long charged = 0;
72902 + unsigned long pax_task_size = TASK_SIZE;
72903
72904 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
72905 goto out;
72906 @@ -458,6 +475,17 @@ unsigned long do_mremap(unsigned long addr,
72907 if (!new_len)
72908 goto out;
72909
72910 +#ifdef CONFIG_PAX_SEGMEXEC
72911 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
72912 + pax_task_size = SEGMEXEC_TASK_SIZE;
72913 +#endif
72914 +
72915 + pax_task_size -= PAGE_SIZE;
72916 +
72917 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
72918 + old_len > pax_task_size || addr > pax_task_size-old_len)
72919 + goto out;
72920 +
72921 if (flags & MREMAP_FIXED) {
72922 if (flags & MREMAP_MAYMOVE)
72923 ret = mremap_to(addr, old_len, new_addr, new_len);
72924 @@ -507,6 +535,7 @@ unsigned long do_mremap(unsigned long addr,
72925 addr + new_len);
72926 }
72927 ret = addr;
72928 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
72929 goto out;
72930 }
72931 }
72932 @@ -533,7 +562,13 @@ unsigned long do_mremap(unsigned long addr,
72933 ret = security_file_mmap(NULL, 0, 0, 0, new_addr, 1);
72934 if (ret)
72935 goto out;
72936 +
72937 + map_flags = vma->vm_flags;
72938 ret = move_vma(vma, addr, old_len, new_len, new_addr);
72939 + if (!(ret & ~PAGE_MASK)) {
72940 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
72941 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
72942 + }
72943 }
72944 out:
72945 if (ret & ~PAGE_MASK)
72946 diff --git a/mm/nommu.c b/mm/nommu.c
72947 index f59e170..34e2a2b 100644
72948 --- a/mm/nommu.c
72949 +++ b/mm/nommu.c
72950 @@ -62,7 +62,6 @@ int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
72951 int sysctl_overcommit_ratio = 50; /* default is 50% */
72952 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
72953 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
72954 -int heap_stack_gap = 0;
72955
72956 atomic_long_t mmap_pages_allocated;
72957
72958 @@ -827,15 +826,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
72959 EXPORT_SYMBOL(find_vma);
72960
72961 /*
72962 - * find a VMA
72963 - * - we don't extend stack VMAs under NOMMU conditions
72964 - */
72965 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
72966 -{
72967 - return find_vma(mm, addr);
72968 -}
72969 -
72970 -/*
72971 * expand a stack to a given address
72972 * - not supported under NOMMU conditions
72973 */
72974 @@ -1555,6 +1545,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
72975
72976 /* most fields are the same, copy all, and then fixup */
72977 *new = *vma;
72978 + INIT_LIST_HEAD(&new->anon_vma_chain);
72979 *region = *vma->vm_region;
72980 new->vm_region = region;
72981
72982 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
72983 index a13ded1..b949d15 100644
72984 --- a/mm/page_alloc.c
72985 +++ b/mm/page_alloc.c
72986 @@ -335,7 +335,7 @@ out:
72987 * This usage means that zero-order pages may not be compound.
72988 */
72989
72990 -static void free_compound_page(struct page *page)
72991 +void free_compound_page(struct page *page)
72992 {
72993 __free_pages_ok(page, compound_order(page));
72994 }
72995 @@ -692,6 +692,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
72996 int i;
72997 int bad = 0;
72998
72999 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
73000 + unsigned long index = 1UL << order;
73001 +#endif
73002 +
73003 trace_mm_page_free(page, order);
73004 kmemcheck_free_shadow(page, order);
73005
73006 @@ -707,6 +711,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
73007 debug_check_no_obj_freed(page_address(page),
73008 PAGE_SIZE << order);
73009 }
73010 +
73011 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
73012 + for (; index; --index)
73013 + sanitize_highpage(page + index - 1);
73014 +#endif
73015 +
73016 arch_free_page(page, order);
73017 kernel_map_pages(page, 1 << order, 0);
73018
73019 @@ -830,8 +840,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
73020 arch_alloc_page(page, order);
73021 kernel_map_pages(page, 1 << order, 1);
73022
73023 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
73024 if (gfp_flags & __GFP_ZERO)
73025 prep_zero_page(page, order, gfp_flags);
73026 +#endif
73027
73028 if (order && (gfp_flags & __GFP_COMP))
73029 prep_compound_page(page, order);
73030 @@ -3468,7 +3480,13 @@ static int pageblock_is_reserved(unsigned long start_pfn, unsigned long end_pfn)
73031 unsigned long pfn;
73032
73033 for (pfn = start_pfn; pfn < end_pfn; pfn++) {
73034 +#ifdef CONFIG_X86_32
73035 + /* boot failures in VMware 8 on 32bit vanilla since
73036 + this change */
73037 + if (!pfn_valid(pfn) || PageReserved(pfn_to_page(pfn)))
73038 +#else
73039 if (!pfn_valid_within(pfn) || PageReserved(pfn_to_page(pfn)))
73040 +#endif
73041 return 1;
73042 }
73043 return 0;
73044 diff --git a/mm/percpu.c b/mm/percpu.c
73045 index 317de23..1ba7776 100644
73046 --- a/mm/percpu.c
73047 +++ b/mm/percpu.c
73048 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
73049 static unsigned int pcpu_high_unit_cpu __read_mostly;
73050
73051 /* the address of the first chunk which starts with the kernel static area */
73052 -void *pcpu_base_addr __read_mostly;
73053 +void *pcpu_base_addr __read_only;
73054 EXPORT_SYMBOL_GPL(pcpu_base_addr);
73055
73056 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
73057 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
73058 index c20ff48..137702a 100644
73059 --- a/mm/process_vm_access.c
73060 +++ b/mm/process_vm_access.c
73061 @@ -13,6 +13,7 @@
73062 #include <linux/uio.h>
73063 #include <linux/sched.h>
73064 #include <linux/highmem.h>
73065 +#include <linux/security.h>
73066 #include <linux/ptrace.h>
73067 #include <linux/slab.h>
73068 #include <linux/syscalls.h>
73069 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
73070 size_t iov_l_curr_offset = 0;
73071 ssize_t iov_len;
73072
73073 + return -ENOSYS; // PaX: until properly audited
73074 +
73075 /*
73076 * Work out how many pages of struct pages we're going to need
73077 * when eventually calling get_user_pages
73078 */
73079 for (i = 0; i < riovcnt; i++) {
73080 iov_len = rvec[i].iov_len;
73081 - if (iov_len > 0) {
73082 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
73083 - + iov_len)
73084 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
73085 - / PAGE_SIZE + 1;
73086 - nr_pages = max(nr_pages, nr_pages_iov);
73087 - }
73088 + if (iov_len <= 0)
73089 + continue;
73090 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
73091 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
73092 + nr_pages = max(nr_pages, nr_pages_iov);
73093 }
73094
73095 if (nr_pages == 0)
73096 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
73097 goto free_proc_pages;
73098 }
73099
73100 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
73101 + rc = -EPERM;
73102 + goto put_task_struct;
73103 + }
73104 +
73105 mm = mm_access(task, PTRACE_MODE_ATTACH);
73106 if (!mm || IS_ERR(mm)) {
73107 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
73108 diff --git a/mm/rmap.c b/mm/rmap.c
73109 index c8454e0..b04f3a2 100644
73110 --- a/mm/rmap.c
73111 +++ b/mm/rmap.c
73112 @@ -152,6 +152,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
73113 struct anon_vma *anon_vma = vma->anon_vma;
73114 struct anon_vma_chain *avc;
73115
73116 +#ifdef CONFIG_PAX_SEGMEXEC
73117 + struct anon_vma_chain *avc_m = NULL;
73118 +#endif
73119 +
73120 might_sleep();
73121 if (unlikely(!anon_vma)) {
73122 struct mm_struct *mm = vma->vm_mm;
73123 @@ -161,6 +165,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
73124 if (!avc)
73125 goto out_enomem;
73126
73127 +#ifdef CONFIG_PAX_SEGMEXEC
73128 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
73129 + if (!avc_m)
73130 + goto out_enomem_free_avc;
73131 +#endif
73132 +
73133 anon_vma = find_mergeable_anon_vma(vma);
73134 allocated = NULL;
73135 if (!anon_vma) {
73136 @@ -174,6 +184,21 @@ int anon_vma_prepare(struct vm_area_struct *vma)
73137 /* page_table_lock to protect against threads */
73138 spin_lock(&mm->page_table_lock);
73139 if (likely(!vma->anon_vma)) {
73140 +
73141 +#ifdef CONFIG_PAX_SEGMEXEC
73142 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
73143 +
73144 + if (vma_m) {
73145 + BUG_ON(vma_m->anon_vma);
73146 + vma_m->anon_vma = anon_vma;
73147 + avc_m->anon_vma = anon_vma;
73148 + avc_m->vma = vma;
73149 + list_add(&avc_m->same_vma, &vma_m->anon_vma_chain);
73150 + list_add(&avc_m->same_anon_vma, &anon_vma->head);
73151 + avc_m = NULL;
73152 + }
73153 +#endif
73154 +
73155 vma->anon_vma = anon_vma;
73156 avc->anon_vma = anon_vma;
73157 avc->vma = vma;
73158 @@ -187,12 +212,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
73159
73160 if (unlikely(allocated))
73161 put_anon_vma(allocated);
73162 +
73163 +#ifdef CONFIG_PAX_SEGMEXEC
73164 + if (unlikely(avc_m))
73165 + anon_vma_chain_free(avc_m);
73166 +#endif
73167 +
73168 if (unlikely(avc))
73169 anon_vma_chain_free(avc);
73170 }
73171 return 0;
73172
73173 out_enomem_free_avc:
73174 +
73175 +#ifdef CONFIG_PAX_SEGMEXEC
73176 + if (avc_m)
73177 + anon_vma_chain_free(avc_m);
73178 +#endif
73179 +
73180 anon_vma_chain_free(avc);
73181 out_enomem:
73182 return -ENOMEM;
73183 @@ -243,7 +280,7 @@ static void anon_vma_chain_link(struct vm_area_struct *vma,
73184 * Attach the anon_vmas from src to dst.
73185 * Returns 0 on success, -ENOMEM on failure.
73186 */
73187 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
73188 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
73189 {
73190 struct anon_vma_chain *avc, *pavc;
73191 struct anon_vma *root = NULL;
73192 @@ -321,7 +358,7 @@ void anon_vma_moveto_tail(struct vm_area_struct *dst)
73193 * the corresponding VMA in the parent process is attached to.
73194 * Returns 0 on success, non-zero on failure.
73195 */
73196 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
73197 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
73198 {
73199 struct anon_vma_chain *avc;
73200 struct anon_vma *anon_vma;
73201 diff --git a/mm/shmem.c b/mm/shmem.c
73202 index 269d049..a9d2b50 100644
73203 --- a/mm/shmem.c
73204 +++ b/mm/shmem.c
73205 @@ -31,7 +31,7 @@
73206 #include <linux/export.h>
73207 #include <linux/swap.h>
73208
73209 -static struct vfsmount *shm_mnt;
73210 +struct vfsmount *shm_mnt;
73211
73212 #ifdef CONFIG_SHMEM
73213 /*
73214 @@ -74,7 +74,7 @@ static struct vfsmount *shm_mnt;
73215 #define BOGO_DIRENT_SIZE 20
73216
73217 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
73218 -#define SHORT_SYMLINK_LEN 128
73219 +#define SHORT_SYMLINK_LEN 64
73220
73221 struct shmem_xattr {
73222 struct list_head list; /* anchored by shmem_inode_info->xattr_list */
73223 @@ -2180,8 +2180,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
73224 int err = -ENOMEM;
73225
73226 /* Round up to L1_CACHE_BYTES to resist false sharing */
73227 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
73228 - L1_CACHE_BYTES), GFP_KERNEL);
73229 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
73230 if (!sbinfo)
73231 return -ENOMEM;
73232
73233 diff --git a/mm/slab.c b/mm/slab.c
73234 index f0bd785..348b96a 100644
73235 --- a/mm/slab.c
73236 +++ b/mm/slab.c
73237 @@ -153,7 +153,7 @@
73238
73239 /* Legal flag mask for kmem_cache_create(). */
73240 #if DEBUG
73241 -# define CREATE_MASK (SLAB_RED_ZONE | \
73242 +# define CREATE_MASK (SLAB_USERCOPY | SLAB_RED_ZONE | \
73243 SLAB_POISON | SLAB_HWCACHE_ALIGN | \
73244 SLAB_CACHE_DMA | \
73245 SLAB_STORE_USER | \
73246 @@ -161,7 +161,7 @@
73247 SLAB_DESTROY_BY_RCU | SLAB_MEM_SPREAD | \
73248 SLAB_DEBUG_OBJECTS | SLAB_NOLEAKTRACE | SLAB_NOTRACK)
73249 #else
73250 -# define CREATE_MASK (SLAB_HWCACHE_ALIGN | \
73251 +# define CREATE_MASK (SLAB_USERCOPY | SLAB_HWCACHE_ALIGN | \
73252 SLAB_CACHE_DMA | \
73253 SLAB_RECLAIM_ACCOUNT | SLAB_PANIC | \
73254 SLAB_DESTROY_BY_RCU | SLAB_MEM_SPREAD | \
73255 @@ -290,7 +290,7 @@ struct kmem_list3 {
73256 * Need this for bootstrapping a per node allocator.
73257 */
73258 #define NUM_INIT_LISTS (3 * MAX_NUMNODES)
73259 -static struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS];
73260 +static struct kmem_list3 initkmem_list3[NUM_INIT_LISTS];
73261 #define CACHE_CACHE 0
73262 #define SIZE_AC MAX_NUMNODES
73263 #define SIZE_L3 (2 * MAX_NUMNODES)
73264 @@ -391,10 +391,10 @@ static void kmem_list3_init(struct kmem_list3 *parent)
73265 if ((x)->max_freeable < i) \
73266 (x)->max_freeable = i; \
73267 } while (0)
73268 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
73269 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
73270 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
73271 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
73272 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
73273 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
73274 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
73275 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
73276 #else
73277 #define STATS_INC_ACTIVE(x) do { } while (0)
73278 #define STATS_DEC_ACTIVE(x) do { } while (0)
73279 @@ -542,7 +542,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
73280 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
73281 */
73282 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
73283 - const struct slab *slab, void *obj)
73284 + const struct slab *slab, const void *obj)
73285 {
73286 u32 offset = (obj - slab->s_mem);
73287 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
73288 @@ -568,7 +568,7 @@ struct cache_names {
73289 static struct cache_names __initdata cache_names[] = {
73290 #define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)" },
73291 #include <linux/kmalloc_sizes.h>
73292 - {NULL,}
73293 + {NULL}
73294 #undef CACHE
73295 };
73296
73297 @@ -1588,7 +1588,7 @@ void __init kmem_cache_init(void)
73298 sizes[INDEX_AC].cs_cachep = kmem_cache_create(names[INDEX_AC].name,
73299 sizes[INDEX_AC].cs_size,
73300 ARCH_KMALLOC_MINALIGN,
73301 - ARCH_KMALLOC_FLAGS|SLAB_PANIC,
73302 + ARCH_KMALLOC_FLAGS|SLAB_PANIC|SLAB_USERCOPY,
73303 NULL);
73304
73305 if (INDEX_AC != INDEX_L3) {
73306 @@ -1596,7 +1596,7 @@ void __init kmem_cache_init(void)
73307 kmem_cache_create(names[INDEX_L3].name,
73308 sizes[INDEX_L3].cs_size,
73309 ARCH_KMALLOC_MINALIGN,
73310 - ARCH_KMALLOC_FLAGS|SLAB_PANIC,
73311 + ARCH_KMALLOC_FLAGS|SLAB_PANIC|SLAB_USERCOPY,
73312 NULL);
73313 }
73314
73315 @@ -1614,7 +1614,7 @@ void __init kmem_cache_init(void)
73316 sizes->cs_cachep = kmem_cache_create(names->name,
73317 sizes->cs_size,
73318 ARCH_KMALLOC_MINALIGN,
73319 - ARCH_KMALLOC_FLAGS|SLAB_PANIC,
73320 + ARCH_KMALLOC_FLAGS|SLAB_PANIC|SLAB_USERCOPY,
73321 NULL);
73322 }
73323 #ifdef CONFIG_ZONE_DMA
73324 @@ -4339,10 +4339,10 @@ static int s_show(struct seq_file *m, void *p)
73325 }
73326 /* cpu stats */
73327 {
73328 - unsigned long allochit = atomic_read(&cachep->allochit);
73329 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
73330 - unsigned long freehit = atomic_read(&cachep->freehit);
73331 - unsigned long freemiss = atomic_read(&cachep->freemiss);
73332 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
73333 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
73334 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
73335 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
73336
73337 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
73338 allochit, allocmiss, freehit, freemiss);
73339 @@ -4601,13 +4601,62 @@ static int __init slab_proc_init(void)
73340 {
73341 proc_create("slabinfo",S_IWUSR|S_IRUSR,NULL,&proc_slabinfo_operations);
73342 #ifdef CONFIG_DEBUG_SLAB_LEAK
73343 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
73344 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
73345 #endif
73346 return 0;
73347 }
73348 module_init(slab_proc_init);
73349 #endif
73350
73351 +void check_object_size(const void *ptr, unsigned long n, bool to)
73352 +{
73353 +
73354 +#ifdef CONFIG_PAX_USERCOPY
73355 + struct page *page;
73356 + struct kmem_cache *cachep = NULL;
73357 + struct slab *slabp;
73358 + unsigned int objnr;
73359 + unsigned long offset;
73360 + const char *type;
73361 +
73362 + if (!n)
73363 + return;
73364 +
73365 + type = "<null>";
73366 + if (ZERO_OR_NULL_PTR(ptr))
73367 + goto report;
73368 +
73369 + if (!virt_addr_valid(ptr))
73370 + return;
73371 +
73372 + page = virt_to_head_page(ptr);
73373 +
73374 + type = "<process stack>";
73375 + if (!PageSlab(page)) {
73376 + if (object_is_on_stack(ptr, n) == -1)
73377 + goto report;
73378 + return;
73379 + }
73380 +
73381 + cachep = page_get_cache(page);
73382 + type = cachep->name;
73383 + if (!(cachep->flags & SLAB_USERCOPY))
73384 + goto report;
73385 +
73386 + slabp = page_get_slab(page);
73387 + objnr = obj_to_index(cachep, slabp, ptr);
73388 + BUG_ON(objnr >= cachep->num);
73389 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
73390 + if (offset <= obj_size(cachep) && n <= obj_size(cachep) - offset)
73391 + return;
73392 +
73393 +report:
73394 + pax_report_usercopy(ptr, n, to, type);
73395 +#endif
73396 +
73397 +}
73398 +EXPORT_SYMBOL(check_object_size);
73399 +
73400 /**
73401 * ksize - get the actual amount of memory allocated for a given object
73402 * @objp: Pointer to the object
73403 diff --git a/mm/slob.c b/mm/slob.c
73404 index 8105be4..e045f96 100644
73405 --- a/mm/slob.c
73406 +++ b/mm/slob.c
73407 @@ -29,7 +29,7 @@
73408 * If kmalloc is asked for objects of PAGE_SIZE or larger, it calls
73409 * alloc_pages() directly, allocating compound pages so the page order
73410 * does not have to be separately tracked, and also stores the exact
73411 - * allocation size in page->private so that it can be used to accurately
73412 + * allocation size in slob_page->size so that it can be used to accurately
73413 * provide ksize(). These objects are detected in kfree() because slob_page()
73414 * is false for them.
73415 *
73416 @@ -58,6 +58,7 @@
73417 */
73418
73419 #include <linux/kernel.h>
73420 +#include <linux/sched.h>
73421 #include <linux/slab.h>
73422 #include <linux/mm.h>
73423 #include <linux/swap.h> /* struct reclaim_state */
73424 @@ -102,7 +103,8 @@ struct slob_page {
73425 unsigned long flags; /* mandatory */
73426 atomic_t _count; /* mandatory */
73427 slobidx_t units; /* free units left in page */
73428 - unsigned long pad[2];
73429 + unsigned long pad[1];
73430 + unsigned long size; /* size when >=PAGE_SIZE */
73431 slob_t *free; /* first free slob_t in page */
73432 struct list_head list; /* linked list of free pages */
73433 };
73434 @@ -135,7 +137,7 @@ static LIST_HEAD(free_slob_large);
73435 */
73436 static inline int is_slob_page(struct slob_page *sp)
73437 {
73438 - return PageSlab((struct page *)sp);
73439 + return PageSlab((struct page *)sp) && !sp->size;
73440 }
73441
73442 static inline void set_slob_page(struct slob_page *sp)
73443 @@ -150,7 +152,7 @@ static inline void clear_slob_page(struct slob_page *sp)
73444
73445 static inline struct slob_page *slob_page(const void *addr)
73446 {
73447 - return (struct slob_page *)virt_to_page(addr);
73448 + return (struct slob_page *)virt_to_head_page(addr);
73449 }
73450
73451 /*
73452 @@ -210,7 +212,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
73453 /*
73454 * Return the size of a slob block.
73455 */
73456 -static slobidx_t slob_units(slob_t *s)
73457 +static slobidx_t slob_units(const slob_t *s)
73458 {
73459 if (s->units > 0)
73460 return s->units;
73461 @@ -220,7 +222,7 @@ static slobidx_t slob_units(slob_t *s)
73462 /*
73463 * Return the next free slob block pointer after this one.
73464 */
73465 -static slob_t *slob_next(slob_t *s)
73466 +static slob_t *slob_next(const slob_t *s)
73467 {
73468 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
73469 slobidx_t next;
73470 @@ -235,7 +237,7 @@ static slob_t *slob_next(slob_t *s)
73471 /*
73472 * Returns true if s is the last free block in its page.
73473 */
73474 -static int slob_last(slob_t *s)
73475 +static int slob_last(const slob_t *s)
73476 {
73477 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
73478 }
73479 @@ -254,6 +256,7 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
73480 if (!page)
73481 return NULL;
73482
73483 + set_slob_page(page);
73484 return page_address(page);
73485 }
73486
73487 @@ -370,11 +373,11 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
73488 if (!b)
73489 return NULL;
73490 sp = slob_page(b);
73491 - set_slob_page(sp);
73492
73493 spin_lock_irqsave(&slob_lock, flags);
73494 sp->units = SLOB_UNITS(PAGE_SIZE);
73495 sp->free = b;
73496 + sp->size = 0;
73497 INIT_LIST_HEAD(&sp->list);
73498 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
73499 set_slob_page_free(sp, slob_list);
73500 @@ -476,10 +479,9 @@ out:
73501 * End of slob allocator proper. Begin kmem_cache_alloc and kmalloc frontend.
73502 */
73503
73504 -void *__kmalloc_node(size_t size, gfp_t gfp, int node)
73505 +static void *__kmalloc_node_align(size_t size, gfp_t gfp, int node, int align)
73506 {
73507 - unsigned int *m;
73508 - int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
73509 + slob_t *m;
73510 void *ret;
73511
73512 gfp &= gfp_allowed_mask;
73513 @@ -494,7 +496,10 @@ void *__kmalloc_node(size_t size, gfp_t gfp, int node)
73514
73515 if (!m)
73516 return NULL;
73517 - *m = size;
73518 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
73519 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
73520 + m[0].units = size;
73521 + m[1].units = align;
73522 ret = (void *)m + align;
73523
73524 trace_kmalloc_node(_RET_IP_, ret,
73525 @@ -506,16 +511,25 @@ void *__kmalloc_node(size_t size, gfp_t gfp, int node)
73526 gfp |= __GFP_COMP;
73527 ret = slob_new_pages(gfp, order, node);
73528 if (ret) {
73529 - struct page *page;
73530 - page = virt_to_page(ret);
73531 - page->private = size;
73532 + struct slob_page *sp;
73533 + sp = slob_page(ret);
73534 + sp->size = size;
73535 }
73536
73537 trace_kmalloc_node(_RET_IP_, ret,
73538 size, PAGE_SIZE << order, gfp, node);
73539 }
73540
73541 - kmemleak_alloc(ret, size, 1, gfp);
73542 + return ret;
73543 +}
73544 +
73545 +void *__kmalloc_node(size_t size, gfp_t gfp, int node)
73546 +{
73547 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
73548 + void *ret = __kmalloc_node_align(size, gfp, node, align);
73549 +
73550 + if (!ZERO_OR_NULL_PTR(ret))
73551 + kmemleak_alloc(ret, size, 1, gfp);
73552 return ret;
73553 }
73554 EXPORT_SYMBOL(__kmalloc_node);
73555 @@ -533,13 +547,92 @@ void kfree(const void *block)
73556 sp = slob_page(block);
73557 if (is_slob_page(sp)) {
73558 int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
73559 - unsigned int *m = (unsigned int *)(block - align);
73560 - slob_free(m, *m + align);
73561 - } else
73562 + slob_t *m = (slob_t *)(block - align);
73563 + slob_free(m, m[0].units + align);
73564 + } else {
73565 + clear_slob_page(sp);
73566 + free_slob_page(sp);
73567 + sp->size = 0;
73568 put_page(&sp->page);
73569 + }
73570 }
73571 EXPORT_SYMBOL(kfree);
73572
73573 +void check_object_size(const void *ptr, unsigned long n, bool to)
73574 +{
73575 +
73576 +#ifdef CONFIG_PAX_USERCOPY
73577 + struct slob_page *sp;
73578 + const slob_t *free;
73579 + const void *base;
73580 + unsigned long flags;
73581 + const char *type;
73582 +
73583 + if (!n)
73584 + return;
73585 +
73586 + type = "<null>";
73587 + if (ZERO_OR_NULL_PTR(ptr))
73588 + goto report;
73589 +
73590 + if (!virt_addr_valid(ptr))
73591 + return;
73592 +
73593 + type = "<process stack>";
73594 + sp = slob_page(ptr);
73595 + if (!PageSlab((struct page *)sp)) {
73596 + if (object_is_on_stack(ptr, n) == -1)
73597 + goto report;
73598 + return;
73599 + }
73600 +
73601 + type = "<slob>";
73602 + if (sp->size) {
73603 + base = page_address(&sp->page);
73604 + if (base <= ptr && n <= sp->size - (ptr - base))
73605 + return;
73606 + goto report;
73607 + }
73608 +
73609 + /* some tricky double walking to find the chunk */
73610 + spin_lock_irqsave(&slob_lock, flags);
73611 + base = (void *)((unsigned long)ptr & PAGE_MASK);
73612 + free = sp->free;
73613 +
73614 + while (!slob_last(free) && (void *)free <= ptr) {
73615 + base = free + slob_units(free);
73616 + free = slob_next(free);
73617 + }
73618 +
73619 + while (base < (void *)free) {
73620 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
73621 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
73622 + int offset;
73623 +
73624 + if (ptr < base + align)
73625 + break;
73626 +
73627 + offset = ptr - base - align;
73628 + if (offset >= m) {
73629 + base += size;
73630 + continue;
73631 + }
73632 +
73633 + if (n > m - offset)
73634 + break;
73635 +
73636 + spin_unlock_irqrestore(&slob_lock, flags);
73637 + return;
73638 + }
73639 +
73640 + spin_unlock_irqrestore(&slob_lock, flags);
73641 +report:
73642 + pax_report_usercopy(ptr, n, to, type);
73643 +#endif
73644 +
73645 +}
73646 +EXPORT_SYMBOL(check_object_size);
73647 +
73648 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
73649 size_t ksize(const void *block)
73650 {
73651 @@ -552,10 +645,10 @@ size_t ksize(const void *block)
73652 sp = slob_page(block);
73653 if (is_slob_page(sp)) {
73654 int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
73655 - unsigned int *m = (unsigned int *)(block - align);
73656 - return SLOB_UNITS(*m) * SLOB_UNIT;
73657 + slob_t *m = (slob_t *)(block - align);
73658 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
73659 } else
73660 - return sp->page.private;
73661 + return sp->size;
73662 }
73663 EXPORT_SYMBOL(ksize);
73664
73665 @@ -571,8 +664,13 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size,
73666 {
73667 struct kmem_cache *c;
73668
73669 +#ifdef CONFIG_PAX_USERCOPY
73670 + c = __kmalloc_node_align(sizeof(struct kmem_cache),
73671 + GFP_KERNEL, -1, ARCH_KMALLOC_MINALIGN);
73672 +#else
73673 c = slob_alloc(sizeof(struct kmem_cache),
73674 GFP_KERNEL, ARCH_KMALLOC_MINALIGN, -1);
73675 +#endif
73676
73677 if (c) {
73678 c->name = name;
73679 @@ -614,17 +712,25 @@ void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
73680
73681 lockdep_trace_alloc(flags);
73682
73683 +#ifdef CONFIG_PAX_USERCOPY
73684 + b = __kmalloc_node_align(c->size, flags, node, c->align);
73685 +#else
73686 if (c->size < PAGE_SIZE) {
73687 b = slob_alloc(c->size, flags, c->align, node);
73688 trace_kmem_cache_alloc_node(_RET_IP_, b, c->size,
73689 SLOB_UNITS(c->size) * SLOB_UNIT,
73690 flags, node);
73691 } else {
73692 + struct slob_page *sp;
73693 +
73694 b = slob_new_pages(flags, get_order(c->size), node);
73695 + sp = slob_page(b);
73696 + sp->size = c->size;
73697 trace_kmem_cache_alloc_node(_RET_IP_, b, c->size,
73698 PAGE_SIZE << get_order(c->size),
73699 flags, node);
73700 }
73701 +#endif
73702
73703 if (c->ctor)
73704 c->ctor(b);
73705 @@ -636,10 +742,16 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
73706
73707 static void __kmem_cache_free(void *b, int size)
73708 {
73709 - if (size < PAGE_SIZE)
73710 + struct slob_page *sp = slob_page(b);
73711 +
73712 + if (is_slob_page(sp))
73713 slob_free(b, size);
73714 - else
73715 + else {
73716 + clear_slob_page(sp);
73717 + free_slob_page(sp);
73718 + sp->size = 0;
73719 slob_free_pages(b, get_order(size));
73720 + }
73721 }
73722
73723 static void kmem_rcu_free(struct rcu_head *head)
73724 @@ -652,17 +764,31 @@ static void kmem_rcu_free(struct rcu_head *head)
73725
73726 void kmem_cache_free(struct kmem_cache *c, void *b)
73727 {
73728 + int size = c->size;
73729 +
73730 +#ifdef CONFIG_PAX_USERCOPY
73731 + if (size + c->align < PAGE_SIZE) {
73732 + size += c->align;
73733 + b -= c->align;
73734 + }
73735 +#endif
73736 +
73737 kmemleak_free_recursive(b, c->flags);
73738 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
73739 struct slob_rcu *slob_rcu;
73740 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
73741 - slob_rcu->size = c->size;
73742 + slob_rcu = b + (size - sizeof(struct slob_rcu));
73743 + slob_rcu->size = size;
73744 call_rcu(&slob_rcu->head, kmem_rcu_free);
73745 } else {
73746 - __kmem_cache_free(b, c->size);
73747 + __kmem_cache_free(b, size);
73748 }
73749
73750 +#ifdef CONFIG_PAX_USERCOPY
73751 + trace_kfree(_RET_IP_, b);
73752 +#else
73753 trace_kmem_cache_free(_RET_IP_, b);
73754 +#endif
73755 +
73756 }
73757 EXPORT_SYMBOL(kmem_cache_free);
73758
73759 diff --git a/mm/slub.c b/mm/slub.c
73760 index 0342a5d..8180ae9 100644
73761 --- a/mm/slub.c
73762 +++ b/mm/slub.c
73763 @@ -208,7 +208,7 @@ struct track {
73764
73765 enum track_item { TRACK_ALLOC, TRACK_FREE };
73766
73767 -#ifdef CONFIG_SYSFS
73768 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
73769 static int sysfs_slab_add(struct kmem_cache *);
73770 static int sysfs_slab_alias(struct kmem_cache *, const char *);
73771 static void sysfs_slab_remove(struct kmem_cache *);
73772 @@ -532,7 +532,7 @@ static void print_track(const char *s, struct track *t)
73773 if (!t->addr)
73774 return;
73775
73776 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
73777 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
73778 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
73779 #ifdef CONFIG_STACKTRACE
73780 {
73781 @@ -2571,6 +2571,8 @@ void kmem_cache_free(struct kmem_cache *s, void *x)
73782
73783 page = virt_to_head_page(x);
73784
73785 + BUG_ON(!PageSlab(page));
73786 +
73787 slab_free(s, page, x, _RET_IP_);
73788
73789 trace_kmem_cache_free(_RET_IP_, x);
73790 @@ -2604,7 +2606,7 @@ static int slub_min_objects;
73791 * Merge control. If this is set then no merging of slab caches will occur.
73792 * (Could be removed. This was introduced to pacify the merge skeptics.)
73793 */
73794 -static int slub_nomerge;
73795 +static int slub_nomerge = 1;
73796
73797 /*
73798 * Calculate the order of allocation given an slab object size.
73799 @@ -3057,7 +3059,7 @@ static int kmem_cache_open(struct kmem_cache *s,
73800 else
73801 s->cpu_partial = 30;
73802
73803 - s->refcount = 1;
73804 + atomic_set(&s->refcount, 1);
73805 #ifdef CONFIG_NUMA
73806 s->remote_node_defrag_ratio = 1000;
73807 #endif
73808 @@ -3161,8 +3163,7 @@ static inline int kmem_cache_close(struct kmem_cache *s)
73809 void kmem_cache_destroy(struct kmem_cache *s)
73810 {
73811 down_write(&slub_lock);
73812 - s->refcount--;
73813 - if (!s->refcount) {
73814 + if (atomic_dec_and_test(&s->refcount)) {
73815 list_del(&s->list);
73816 up_write(&slub_lock);
73817 if (kmem_cache_close(s)) {
73818 @@ -3373,6 +3374,50 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
73819 EXPORT_SYMBOL(__kmalloc_node);
73820 #endif
73821
73822 +void check_object_size(const void *ptr, unsigned long n, bool to)
73823 +{
73824 +
73825 +#ifdef CONFIG_PAX_USERCOPY
73826 + struct page *page;
73827 + struct kmem_cache *s = NULL;
73828 + unsigned long offset;
73829 + const char *type;
73830 +
73831 + if (!n)
73832 + return;
73833 +
73834 + type = "<null>";
73835 + if (ZERO_OR_NULL_PTR(ptr))
73836 + goto report;
73837 +
73838 + if (!virt_addr_valid(ptr))
73839 + return;
73840 +
73841 + page = virt_to_head_page(ptr);
73842 +
73843 + type = "<process stack>";
73844 + if (!PageSlab(page)) {
73845 + if (object_is_on_stack(ptr, n) == -1)
73846 + goto report;
73847 + return;
73848 + }
73849 +
73850 + s = page->slab;
73851 + type = s->name;
73852 + if (!(s->flags & SLAB_USERCOPY))
73853 + goto report;
73854 +
73855 + offset = (ptr - page_address(page)) % s->size;
73856 + if (offset <= s->objsize && n <= s->objsize - offset)
73857 + return;
73858 +
73859 +report:
73860 + pax_report_usercopy(ptr, n, to, type);
73861 +#endif
73862 +
73863 +}
73864 +EXPORT_SYMBOL(check_object_size);
73865 +
73866 size_t ksize(const void *object)
73867 {
73868 struct page *page;
73869 @@ -3647,7 +3692,7 @@ static void __init kmem_cache_bootstrap_fixup(struct kmem_cache *s)
73870 int node;
73871
73872 list_add(&s->list, &slab_caches);
73873 - s->refcount = -1;
73874 + atomic_set(&s->refcount, -1);
73875
73876 for_each_node_state(node, N_NORMAL_MEMORY) {
73877 struct kmem_cache_node *n = get_node(s, node);
73878 @@ -3767,17 +3812,17 @@ void __init kmem_cache_init(void)
73879
73880 /* Caches that are not of the two-to-the-power-of size */
73881 if (KMALLOC_MIN_SIZE <= 32) {
73882 - kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, 0);
73883 + kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, SLAB_USERCOPY);
73884 caches++;
73885 }
73886
73887 if (KMALLOC_MIN_SIZE <= 64) {
73888 - kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, 0);
73889 + kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, SLAB_USERCOPY);
73890 caches++;
73891 }
73892
73893 for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) {
73894 - kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, 0);
73895 + kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, SLAB_USERCOPY);
73896 caches++;
73897 }
73898
73899 @@ -3845,7 +3890,7 @@ static int slab_unmergeable(struct kmem_cache *s)
73900 /*
73901 * We may have set a slab to be unmergeable during bootstrap.
73902 */
73903 - if (s->refcount < 0)
73904 + if (atomic_read(&s->refcount) < 0)
73905 return 1;
73906
73907 return 0;
73908 @@ -3904,7 +3949,7 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size,
73909 down_write(&slub_lock);
73910 s = find_mergeable(size, align, flags, name, ctor);
73911 if (s) {
73912 - s->refcount++;
73913 + atomic_inc(&s->refcount);
73914 /*
73915 * Adjust the object sizes so that we clear
73916 * the complete object on kzalloc.
73917 @@ -3913,7 +3958,7 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size,
73918 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
73919
73920 if (sysfs_slab_alias(s, name)) {
73921 - s->refcount--;
73922 + atomic_dec(&s->refcount);
73923 goto err;
73924 }
73925 up_write(&slub_lock);
73926 @@ -4042,7 +4087,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
73927 }
73928 #endif
73929
73930 -#ifdef CONFIG_SYSFS
73931 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
73932 static int count_inuse(struct page *page)
73933 {
73934 return page->inuse;
73935 @@ -4429,12 +4474,12 @@ static void resiliency_test(void)
73936 validate_slab_cache(kmalloc_caches[9]);
73937 }
73938 #else
73939 -#ifdef CONFIG_SYSFS
73940 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
73941 static void resiliency_test(void) {};
73942 #endif
73943 #endif
73944
73945 -#ifdef CONFIG_SYSFS
73946 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
73947 enum slab_stat_type {
73948 SL_ALL, /* All slabs */
73949 SL_PARTIAL, /* Only partially allocated slabs */
73950 @@ -4677,7 +4722,7 @@ SLAB_ATTR_RO(ctor);
73951
73952 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
73953 {
73954 - return sprintf(buf, "%d\n", s->refcount - 1);
73955 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
73956 }
73957 SLAB_ATTR_RO(aliases);
73958
73959 @@ -5244,6 +5289,7 @@ static char *create_unique_id(struct kmem_cache *s)
73960 return name;
73961 }
73962
73963 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
73964 static int sysfs_slab_add(struct kmem_cache *s)
73965 {
73966 int err;
73967 @@ -5306,6 +5352,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
73968 kobject_del(&s->kobj);
73969 kobject_put(&s->kobj);
73970 }
73971 +#endif
73972
73973 /*
73974 * Need to buffer aliases during bootup until sysfs becomes
73975 @@ -5319,6 +5366,7 @@ struct saved_alias {
73976
73977 static struct saved_alias *alias_list;
73978
73979 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
73980 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
73981 {
73982 struct saved_alias *al;
73983 @@ -5341,6 +5389,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
73984 alias_list = al;
73985 return 0;
73986 }
73987 +#endif
73988
73989 static int __init slab_sysfs_init(void)
73990 {
73991 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
73992 index 1b7e22a..3fcd4f3 100644
73993 --- a/mm/sparse-vmemmap.c
73994 +++ b/mm/sparse-vmemmap.c
73995 @@ -128,7 +128,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
73996 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
73997 if (!p)
73998 return NULL;
73999 - pud_populate(&init_mm, pud, p);
74000 + pud_populate_kernel(&init_mm, pud, p);
74001 }
74002 return pud;
74003 }
74004 @@ -140,7 +140,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
74005 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
74006 if (!p)
74007 return NULL;
74008 - pgd_populate(&init_mm, pgd, p);
74009 + pgd_populate_kernel(&init_mm, pgd, p);
74010 }
74011 return pgd;
74012 }
74013 diff --git a/mm/swap.c b/mm/swap.c
74014 index 14380e9..e244704 100644
74015 --- a/mm/swap.c
74016 +++ b/mm/swap.c
74017 @@ -30,6 +30,7 @@
74018 #include <linux/backing-dev.h>
74019 #include <linux/memcontrol.h>
74020 #include <linux/gfp.h>
74021 +#include <linux/hugetlb.h>
74022
74023 #include "internal.h"
74024
74025 @@ -70,6 +71,8 @@ static void __put_compound_page(struct page *page)
74026
74027 __page_cache_release(page);
74028 dtor = get_compound_page_dtor(page);
74029 + if (!PageHuge(page))
74030 + BUG_ON(dtor != free_compound_page);
74031 (*dtor)(page);
74032 }
74033
74034 diff --git a/mm/swapfile.c b/mm/swapfile.c
74035 index f31b29d..8bdcae2 100644
74036 --- a/mm/swapfile.c
74037 +++ b/mm/swapfile.c
74038 @@ -61,7 +61,7 @@ static DEFINE_MUTEX(swapon_mutex);
74039
74040 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
74041 /* Activity counter to indicate that a swapon or swapoff has occurred */
74042 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
74043 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
74044
74045 static inline unsigned char swap_count(unsigned char ent)
74046 {
74047 @@ -1669,7 +1669,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
74048 }
74049 filp_close(swap_file, NULL);
74050 err = 0;
74051 - atomic_inc(&proc_poll_event);
74052 + atomic_inc_unchecked(&proc_poll_event);
74053 wake_up_interruptible(&proc_poll_wait);
74054
74055 out_dput:
74056 @@ -1685,8 +1685,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
74057
74058 poll_wait(file, &proc_poll_wait, wait);
74059
74060 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
74061 - seq->poll_event = atomic_read(&proc_poll_event);
74062 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
74063 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
74064 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
74065 }
74066
74067 @@ -1784,7 +1784,7 @@ static int swaps_open(struct inode *inode, struct file *file)
74068 return ret;
74069
74070 seq = file->private_data;
74071 - seq->poll_event = atomic_read(&proc_poll_event);
74072 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
74073 return 0;
74074 }
74075
74076 @@ -2122,7 +2122,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
74077 (p->flags & SWP_DISCARDABLE) ? "D" : "");
74078
74079 mutex_unlock(&swapon_mutex);
74080 - atomic_inc(&proc_poll_event);
74081 + atomic_inc_unchecked(&proc_poll_event);
74082 wake_up_interruptible(&proc_poll_wait);
74083
74084 if (S_ISREG(inode->i_mode))
74085 diff --git a/mm/util.c b/mm/util.c
74086 index 136ac4f..f917fa9 100644
74087 --- a/mm/util.c
74088 +++ b/mm/util.c
74089 @@ -243,6 +243,12 @@ void __vma_link_list(struct mm_struct *mm, struct vm_area_struct *vma,
74090 void arch_pick_mmap_layout(struct mm_struct *mm)
74091 {
74092 mm->mmap_base = TASK_UNMAPPED_BASE;
74093 +
74094 +#ifdef CONFIG_PAX_RANDMMAP
74095 + if (mm->pax_flags & MF_PAX_RANDMMAP)
74096 + mm->mmap_base += mm->delta_mmap;
74097 +#endif
74098 +
74099 mm->get_unmapped_area = arch_get_unmapped_area;
74100 mm->unmap_area = arch_unmap_area;
74101 }
74102 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
74103 index 86ce9a5..550d03c 100644
74104 --- a/mm/vmalloc.c
74105 +++ b/mm/vmalloc.c
74106 @@ -39,8 +39,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
74107
74108 pte = pte_offset_kernel(pmd, addr);
74109 do {
74110 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
74111 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
74112 +
74113 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
74114 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
74115 + BUG_ON(!pte_exec(*pte));
74116 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
74117 + continue;
74118 + }
74119 +#endif
74120 +
74121 + {
74122 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
74123 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
74124 + }
74125 } while (pte++, addr += PAGE_SIZE, addr != end);
74126 }
74127
74128 @@ -91,6 +102,7 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
74129 unsigned long end, pgprot_t prot, struct page **pages, int *nr)
74130 {
74131 pte_t *pte;
74132 + int ret = -ENOMEM;
74133
74134 /*
74135 * nr is a running index into the array which helps higher level
74136 @@ -100,17 +112,30 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
74137 pte = pte_alloc_kernel(pmd, addr);
74138 if (!pte)
74139 return -ENOMEM;
74140 +
74141 + pax_open_kernel();
74142 do {
74143 struct page *page = pages[*nr];
74144
74145 - if (WARN_ON(!pte_none(*pte)))
74146 - return -EBUSY;
74147 - if (WARN_ON(!page))
74148 - return -ENOMEM;
74149 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
74150 + if (pgprot_val(prot) & _PAGE_NX)
74151 +#endif
74152 +
74153 + if (WARN_ON(!pte_none(*pte))) {
74154 + ret = -EBUSY;
74155 + goto out;
74156 + }
74157 + if (WARN_ON(!page)) {
74158 + ret = -ENOMEM;
74159 + goto out;
74160 + }
74161 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
74162 (*nr)++;
74163 } while (pte++, addr += PAGE_SIZE, addr != end);
74164 - return 0;
74165 + ret = 0;
74166 +out:
74167 + pax_close_kernel();
74168 + return ret;
74169 }
74170
74171 static int vmap_pmd_range(pud_t *pud, unsigned long addr,
74172 @@ -119,7 +144,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
74173 pmd_t *pmd;
74174 unsigned long next;
74175
74176 - pmd = pmd_alloc(&init_mm, pud, addr);
74177 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
74178 if (!pmd)
74179 return -ENOMEM;
74180 do {
74181 @@ -136,7 +161,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
74182 pud_t *pud;
74183 unsigned long next;
74184
74185 - pud = pud_alloc(&init_mm, pgd, addr);
74186 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
74187 if (!pud)
74188 return -ENOMEM;
74189 do {
74190 @@ -191,11 +216,20 @@ int is_vmalloc_or_module_addr(const void *x)
74191 * and fall back on vmalloc() if that fails. Others
74192 * just put it in the vmalloc space.
74193 */
74194 -#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
74195 +#ifdef CONFIG_MODULES
74196 +#ifdef MODULES_VADDR
74197 unsigned long addr = (unsigned long)x;
74198 if (addr >= MODULES_VADDR && addr < MODULES_END)
74199 return 1;
74200 #endif
74201 +
74202 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
74203 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
74204 + return 1;
74205 +#endif
74206 +
74207 +#endif
74208 +
74209 return is_vmalloc_addr(x);
74210 }
74211
74212 @@ -216,8 +250,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
74213
74214 if (!pgd_none(*pgd)) {
74215 pud_t *pud = pud_offset(pgd, addr);
74216 +#ifdef CONFIG_X86
74217 + if (!pud_large(*pud))
74218 +#endif
74219 if (!pud_none(*pud)) {
74220 pmd_t *pmd = pmd_offset(pud, addr);
74221 +#ifdef CONFIG_X86
74222 + if (!pmd_large(*pmd))
74223 +#endif
74224 if (!pmd_none(*pmd)) {
74225 pte_t *ptep, pte;
74226
74227 @@ -332,6 +372,10 @@ static void purge_vmap_area_lazy(void);
74228 static struct vmap_area *alloc_vmap_area(unsigned long size,
74229 unsigned long align,
74230 unsigned long vstart, unsigned long vend,
74231 + int node, gfp_t gfp_mask) __size_overflow(1);
74232 +static struct vmap_area *alloc_vmap_area(unsigned long size,
74233 + unsigned long align,
74234 + unsigned long vstart, unsigned long vend,
74235 int node, gfp_t gfp_mask)
74236 {
74237 struct vmap_area *va;
74238 @@ -1319,6 +1363,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
74239 struct vm_struct *area;
74240
74241 BUG_ON(in_interrupt());
74242 +
74243 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
74244 + if (flags & VM_KERNEXEC) {
74245 + if (start != VMALLOC_START || end != VMALLOC_END)
74246 + return NULL;
74247 + start = (unsigned long)MODULES_EXEC_VADDR;
74248 + end = (unsigned long)MODULES_EXEC_END;
74249 + }
74250 +#endif
74251 +
74252 if (flags & VM_IOREMAP) {
74253 int bit = fls(size);
74254
74255 @@ -1551,6 +1605,11 @@ void *vmap(struct page **pages, unsigned int count,
74256 if (count > totalram_pages)
74257 return NULL;
74258
74259 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
74260 + if (!(pgprot_val(prot) & _PAGE_NX))
74261 + flags |= VM_KERNEXEC;
74262 +#endif
74263 +
74264 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
74265 __builtin_return_address(0));
74266 if (!area)
74267 @@ -1652,6 +1711,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
74268 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
74269 goto fail;
74270
74271 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
74272 + if (!(pgprot_val(prot) & _PAGE_NX))
74273 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
74274 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
74275 + else
74276 +#endif
74277 +
74278 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
74279 start, end, node, gfp_mask, caller);
74280 if (!area)
74281 @@ -1825,10 +1891,9 @@ EXPORT_SYMBOL(vzalloc_node);
74282 * For tight control over page level allocator and protection flags
74283 * use __vmalloc() instead.
74284 */
74285 -
74286 void *vmalloc_exec(unsigned long size)
74287 {
74288 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
74289 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
74290 -1, __builtin_return_address(0));
74291 }
74292
74293 @@ -2123,6 +2188,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
74294 unsigned long uaddr = vma->vm_start;
74295 unsigned long usize = vma->vm_end - vma->vm_start;
74296
74297 + BUG_ON(vma->vm_mirror);
74298 +
74299 if ((PAGE_SIZE-1) & (unsigned long)addr)
74300 return -EINVAL;
74301
74302 @@ -2375,8 +2442,8 @@ struct vm_struct **pcpu_get_vm_areas(const unsigned long *offsets,
74303 return NULL;
74304 }
74305
74306 - vms = kzalloc(sizeof(vms[0]) * nr_vms, GFP_KERNEL);
74307 - vas = kzalloc(sizeof(vas[0]) * nr_vms, GFP_KERNEL);
74308 + vms = kcalloc(nr_vms, sizeof(vms[0]), GFP_KERNEL);
74309 + vas = kcalloc(nr_vms, sizeof(vas[0]), GFP_KERNEL);
74310 if (!vas || !vms)
74311 goto err_free2;
74312
74313 diff --git a/mm/vmstat.c b/mm/vmstat.c
74314 index f600557..1459fc8 100644
74315 --- a/mm/vmstat.c
74316 +++ b/mm/vmstat.c
74317 @@ -78,7 +78,7 @@ void vm_events_fold_cpu(int cpu)
74318 *
74319 * vm_stat contains the global counters
74320 */
74321 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
74322 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
74323 EXPORT_SYMBOL(vm_stat);
74324
74325 #ifdef CONFIG_SMP
74326 @@ -454,7 +454,7 @@ void refresh_cpu_vm_stats(int cpu)
74327 v = p->vm_stat_diff[i];
74328 p->vm_stat_diff[i] = 0;
74329 local_irq_restore(flags);
74330 - atomic_long_add(v, &zone->vm_stat[i]);
74331 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
74332 global_diff[i] += v;
74333 #ifdef CONFIG_NUMA
74334 /* 3 seconds idle till flush */
74335 @@ -492,7 +492,7 @@ void refresh_cpu_vm_stats(int cpu)
74336
74337 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
74338 if (global_diff[i])
74339 - atomic_long_add(global_diff[i], &vm_stat[i]);
74340 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
74341 }
74342
74343 #endif
74344 @@ -1208,10 +1208,20 @@ static int __init setup_vmstat(void)
74345 start_cpu_timer(cpu);
74346 #endif
74347 #ifdef CONFIG_PROC_FS
74348 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
74349 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
74350 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
74351 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
74352 + {
74353 + mode_t gr_mode = S_IRUGO;
74354 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
74355 + gr_mode = S_IRUSR;
74356 +#endif
74357 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
74358 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
74359 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
74360 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
74361 +#else
74362 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
74363 +#endif
74364 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
74365 + }
74366 #endif
74367 return 0;
74368 }
74369 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
74370 index efea35b..9c8dd0b 100644
74371 --- a/net/8021q/vlan.c
74372 +++ b/net/8021q/vlan.c
74373 @@ -554,8 +554,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
74374 err = -EPERM;
74375 if (!capable(CAP_NET_ADMIN))
74376 break;
74377 - if ((args.u.name_type >= 0) &&
74378 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
74379 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
74380 struct vlan_net *vn;
74381
74382 vn = net_generic(net, vlan_net_id);
74383 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
74384 index fccae26..e7ece2f 100644
74385 --- a/net/9p/trans_fd.c
74386 +++ b/net/9p/trans_fd.c
74387 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
74388 oldfs = get_fs();
74389 set_fs(get_ds());
74390 /* The cast to a user pointer is valid due to the set_fs() */
74391 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
74392 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
74393 set_fs(oldfs);
74394
74395 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
74396 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
74397 index 876fbe8..8bbea9f 100644
74398 --- a/net/atm/atm_misc.c
74399 +++ b/net/atm/atm_misc.c
74400 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
74401 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
74402 return 1;
74403 atm_return(vcc, truesize);
74404 - atomic_inc(&vcc->stats->rx_drop);
74405 + atomic_inc_unchecked(&vcc->stats->rx_drop);
74406 return 0;
74407 }
74408 EXPORT_SYMBOL(atm_charge);
74409 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
74410 }
74411 }
74412 atm_return(vcc, guess);
74413 - atomic_inc(&vcc->stats->rx_drop);
74414 + atomic_inc_unchecked(&vcc->stats->rx_drop);
74415 return NULL;
74416 }
74417 EXPORT_SYMBOL(atm_alloc_charge);
74418 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
74419
74420 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
74421 {
74422 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
74423 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
74424 __SONET_ITEMS
74425 #undef __HANDLE_ITEM
74426 }
74427 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
74428
74429 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
74430 {
74431 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
74432 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
74433 __SONET_ITEMS
74434 #undef __HANDLE_ITEM
74435 }
74436 diff --git a/net/atm/lec.h b/net/atm/lec.h
74437 index dfc0719..47c5322 100644
74438 --- a/net/atm/lec.h
74439 +++ b/net/atm/lec.h
74440 @@ -48,7 +48,7 @@ struct lane2_ops {
74441 const u8 *tlvs, u32 sizeoftlvs);
74442 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
74443 const u8 *tlvs, u32 sizeoftlvs);
74444 -};
74445 +} __no_const;
74446
74447 /*
74448 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
74449 diff --git a/net/atm/mpc.h b/net/atm/mpc.h
74450 index 0919a88..a23d54e 100644
74451 --- a/net/atm/mpc.h
74452 +++ b/net/atm/mpc.h
74453 @@ -33,7 +33,7 @@ struct mpoa_client {
74454 struct mpc_parameters parameters; /* parameters for this client */
74455
74456 const struct net_device_ops *old_ops;
74457 - struct net_device_ops new_ops;
74458 + net_device_ops_no_const new_ops;
74459 };
74460
74461
74462 diff --git a/net/atm/proc.c b/net/atm/proc.c
74463 index 0d020de..011c7bb 100644
74464 --- a/net/atm/proc.c
74465 +++ b/net/atm/proc.c
74466 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
74467 const struct k_atm_aal_stats *stats)
74468 {
74469 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
74470 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
74471 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
74472 - atomic_read(&stats->rx_drop));
74473 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
74474 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
74475 + atomic_read_unchecked(&stats->rx_drop));
74476 }
74477
74478 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
74479 diff --git a/net/atm/resources.c b/net/atm/resources.c
74480 index 23f45ce..c748f1a 100644
74481 --- a/net/atm/resources.c
74482 +++ b/net/atm/resources.c
74483 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
74484 static void copy_aal_stats(struct k_atm_aal_stats *from,
74485 struct atm_aal_stats *to)
74486 {
74487 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
74488 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
74489 __AAL_STAT_ITEMS
74490 #undef __HANDLE_ITEM
74491 }
74492 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
74493 static void subtract_aal_stats(struct k_atm_aal_stats *from,
74494 struct atm_aal_stats *to)
74495 {
74496 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
74497 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
74498 __AAL_STAT_ITEMS
74499 #undef __HANDLE_ITEM
74500 }
74501 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
74502 index 3512e25..2b33401 100644
74503 --- a/net/batman-adv/bat_iv_ogm.c
74504 +++ b/net/batman-adv/bat_iv_ogm.c
74505 @@ -541,7 +541,7 @@ void bat_ogm_schedule(struct hard_iface *hard_iface, int tt_num_changes)
74506
74507 /* change sequence number to network order */
74508 batman_ogm_packet->seqno =
74509 - htonl((uint32_t)atomic_read(&hard_iface->seqno));
74510 + htonl((uint32_t)atomic_read_unchecked(&hard_iface->seqno));
74511
74512 batman_ogm_packet->ttvn = atomic_read(&bat_priv->ttvn);
74513 batman_ogm_packet->tt_crc = htons((uint16_t)
74514 @@ -561,7 +561,7 @@ void bat_ogm_schedule(struct hard_iface *hard_iface, int tt_num_changes)
74515 else
74516 batman_ogm_packet->gw_flags = NO_FLAGS;
74517
74518 - atomic_inc(&hard_iface->seqno);
74519 + atomic_inc_unchecked(&hard_iface->seqno);
74520
74521 slide_own_bcast_window(hard_iface);
74522 bat_ogm_queue_add(bat_priv, hard_iface->packet_buff,
74523 @@ -922,7 +922,7 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
74524 return;
74525
74526 /* could be changed by schedule_own_packet() */
74527 - if_incoming_seqno = atomic_read(&if_incoming->seqno);
74528 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->seqno);
74529
74530 has_directlink_flag = (batman_ogm_packet->flags & DIRECTLINK ? 1 : 0);
74531
74532 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
74533 index 7704df4..beb4e16 100644
74534 --- a/net/batman-adv/hard-interface.c
74535 +++ b/net/batman-adv/hard-interface.c
74536 @@ -326,8 +326,8 @@ int hardif_enable_interface(struct hard_iface *hard_iface,
74537 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
74538 dev_add_pack(&hard_iface->batman_adv_ptype);
74539
74540 - atomic_set(&hard_iface->seqno, 1);
74541 - atomic_set(&hard_iface->frag_seqno, 1);
74542 + atomic_set_unchecked(&hard_iface->seqno, 1);
74543 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
74544 bat_info(hard_iface->soft_iface, "Adding interface: %s\n",
74545 hard_iface->net_dev->name);
74546
74547 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
74548 index 987c75a..20d6f36 100644
74549 --- a/net/batman-adv/soft-interface.c
74550 +++ b/net/batman-adv/soft-interface.c
74551 @@ -645,7 +645,7 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
74552
74553 /* set broadcast sequence number */
74554 bcast_packet->seqno =
74555 - htonl(atomic_inc_return(&bat_priv->bcast_seqno));
74556 + htonl(atomic_inc_return_unchecked(&bat_priv->bcast_seqno));
74557
74558 add_bcast_packet_to_list(bat_priv, skb, 1);
74559
74560 @@ -843,7 +843,7 @@ struct net_device *softif_create(const char *name)
74561 atomic_set(&bat_priv->batman_queue_left, BATMAN_QUEUE_LEN);
74562
74563 atomic_set(&bat_priv->mesh_state, MESH_INACTIVE);
74564 - atomic_set(&bat_priv->bcast_seqno, 1);
74565 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
74566 atomic_set(&bat_priv->ttvn, 0);
74567 atomic_set(&bat_priv->tt_local_changes, 0);
74568 atomic_set(&bat_priv->tt_ogm_append_cnt, 0);
74569 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
74570 index e9eb043..d174eeb 100644
74571 --- a/net/batman-adv/types.h
74572 +++ b/net/batman-adv/types.h
74573 @@ -38,8 +38,8 @@ struct hard_iface {
74574 int16_t if_num;
74575 char if_status;
74576 struct net_device *net_dev;
74577 - atomic_t seqno;
74578 - atomic_t frag_seqno;
74579 + atomic_unchecked_t seqno;
74580 + atomic_unchecked_t frag_seqno;
74581 unsigned char *packet_buff;
74582 int packet_len;
74583 struct kobject *hardif_obj;
74584 @@ -154,7 +154,7 @@ struct bat_priv {
74585 atomic_t orig_interval; /* uint */
74586 atomic_t hop_penalty; /* uint */
74587 atomic_t log_level; /* uint */
74588 - atomic_t bcast_seqno;
74589 + atomic_unchecked_t bcast_seqno;
74590 atomic_t bcast_queue_left;
74591 atomic_t batman_queue_left;
74592 atomic_t ttvn; /* translation table version number */
74593 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
74594 index 07d1c1d..7e9bea9 100644
74595 --- a/net/batman-adv/unicast.c
74596 +++ b/net/batman-adv/unicast.c
74597 @@ -264,7 +264,7 @@ int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
74598 frag1->flags = UNI_FRAG_HEAD | large_tail;
74599 frag2->flags = large_tail;
74600
74601 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
74602 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
74603 frag1->seqno = htons(seqno - 1);
74604 frag2->seqno = htons(seqno);
74605
74606 diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
74607 index 280953b..cd219bb 100644
74608 --- a/net/bluetooth/hci_conn.c
74609 +++ b/net/bluetooth/hci_conn.c
74610 @@ -234,7 +234,7 @@ void hci_le_ltk_reply(struct hci_conn *conn, u8 ltk[16])
74611 memset(&cp, 0, sizeof(cp));
74612
74613 cp.handle = cpu_to_le16(conn->handle);
74614 - memcpy(cp.ltk, ltk, sizeof(ltk));
74615 + memcpy(cp.ltk, ltk, sizeof(cp.ltk));
74616
74617 hci_send_cmd(hdev, HCI_OP_LE_LTK_REPLY, sizeof(cp), &cp);
74618 }
74619 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
74620 index 32d338c..d24bcdb 100644
74621 --- a/net/bluetooth/l2cap_core.c
74622 +++ b/net/bluetooth/l2cap_core.c
74623 @@ -2418,8 +2418,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi
74624 break;
74625
74626 case L2CAP_CONF_RFC:
74627 - if (olen == sizeof(rfc))
74628 - memcpy(&rfc, (void *)val, olen);
74629 + if (olen != sizeof(rfc))
74630 + break;
74631 +
74632 + memcpy(&rfc, (void *)val, olen);
74633
74634 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
74635 rfc.mode != chan->mode)
74636 @@ -2537,8 +2539,10 @@ static void l2cap_conf_rfc_get(struct l2cap_chan *chan, void *rsp, int len)
74637
74638 switch (type) {
74639 case L2CAP_CONF_RFC:
74640 - if (olen == sizeof(rfc))
74641 - memcpy(&rfc, (void *)val, olen);
74642 + if (olen != sizeof(rfc))
74643 + break;
74644 +
74645 + memcpy(&rfc, (void *)val, olen);
74646 goto done;
74647 }
74648 }
74649 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
74650 index 5fe2ff3..10968b5 100644
74651 --- a/net/bridge/netfilter/ebtables.c
74652 +++ b/net/bridge/netfilter/ebtables.c
74653 @@ -1523,7 +1523,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
74654 tmp.valid_hooks = t->table->valid_hooks;
74655 }
74656 mutex_unlock(&ebt_mutex);
74657 - if (copy_to_user(user, &tmp, *len) != 0){
74658 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
74659 BUGPRINT("c2u Didn't work\n");
74660 ret = -EFAULT;
74661 break;
74662 diff --git a/net/caif/caif_socket.c b/net/caif/caif_socket.c
74663 index a97d97a..6f679ed 100644
74664 --- a/net/caif/caif_socket.c
74665 +++ b/net/caif/caif_socket.c
74666 @@ -48,19 +48,20 @@ static struct dentry *debugfsdir;
74667 #ifdef CONFIG_DEBUG_FS
74668 struct debug_fs_counter {
74669 atomic_t caif_nr_socks;
74670 - atomic_t caif_sock_create;
74671 - atomic_t num_connect_req;
74672 - atomic_t num_connect_resp;
74673 - atomic_t num_connect_fail_resp;
74674 - atomic_t num_disconnect;
74675 - atomic_t num_remote_shutdown_ind;
74676 - atomic_t num_tx_flow_off_ind;
74677 - atomic_t num_tx_flow_on_ind;
74678 - atomic_t num_rx_flow_off;
74679 - atomic_t num_rx_flow_on;
74680 + atomic_unchecked_t caif_sock_create;
74681 + atomic_unchecked_t num_connect_req;
74682 + atomic_unchecked_t num_connect_resp;
74683 + atomic_unchecked_t num_connect_fail_resp;
74684 + atomic_unchecked_t num_disconnect;
74685 + atomic_unchecked_t num_remote_shutdown_ind;
74686 + atomic_unchecked_t num_tx_flow_off_ind;
74687 + atomic_unchecked_t num_tx_flow_on_ind;
74688 + atomic_unchecked_t num_rx_flow_off;
74689 + atomic_unchecked_t num_rx_flow_on;
74690 };
74691 static struct debug_fs_counter cnt;
74692 #define dbfs_atomic_inc(v) atomic_inc_return(v)
74693 +#define dbfs_atomic_inc_unchecked(v) atomic_inc_return_unchecked(v)
74694 #define dbfs_atomic_dec(v) atomic_dec_return(v)
74695 #else
74696 #define dbfs_atomic_inc(v) 0
74697 @@ -161,7 +162,7 @@ static int caif_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
74698 atomic_read(&cf_sk->sk.sk_rmem_alloc),
74699 sk_rcvbuf_lowwater(cf_sk));
74700 set_rx_flow_off(cf_sk);
74701 - dbfs_atomic_inc(&cnt.num_rx_flow_off);
74702 + dbfs_atomic_inc_unchecked(&cnt.num_rx_flow_off);
74703 caif_flow_ctrl(sk, CAIF_MODEMCMD_FLOW_OFF_REQ);
74704 }
74705
74706 @@ -172,7 +173,7 @@ static int caif_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
74707 set_rx_flow_off(cf_sk);
74708 if (net_ratelimit())
74709 pr_debug("sending flow OFF due to rmem_schedule\n");
74710 - dbfs_atomic_inc(&cnt.num_rx_flow_off);
74711 + dbfs_atomic_inc_unchecked(&cnt.num_rx_flow_off);
74712 caif_flow_ctrl(sk, CAIF_MODEMCMD_FLOW_OFF_REQ);
74713 }
74714 skb->dev = NULL;
74715 @@ -233,14 +234,14 @@ static void caif_ctrl_cb(struct cflayer *layr,
74716 switch (flow) {
74717 case CAIF_CTRLCMD_FLOW_ON_IND:
74718 /* OK from modem to start sending again */
74719 - dbfs_atomic_inc(&cnt.num_tx_flow_on_ind);
74720 + dbfs_atomic_inc_unchecked(&cnt.num_tx_flow_on_ind);
74721 set_tx_flow_on(cf_sk);
74722 cf_sk->sk.sk_state_change(&cf_sk->sk);
74723 break;
74724
74725 case CAIF_CTRLCMD_FLOW_OFF_IND:
74726 /* Modem asks us to shut up */
74727 - dbfs_atomic_inc(&cnt.num_tx_flow_off_ind);
74728 + dbfs_atomic_inc_unchecked(&cnt.num_tx_flow_off_ind);
74729 set_tx_flow_off(cf_sk);
74730 cf_sk->sk.sk_state_change(&cf_sk->sk);
74731 break;
74732 @@ -249,7 +250,7 @@ static void caif_ctrl_cb(struct cflayer *layr,
74733 /* We're now connected */
74734 caif_client_register_refcnt(&cf_sk->layer,
74735 cfsk_hold, cfsk_put);
74736 - dbfs_atomic_inc(&cnt.num_connect_resp);
74737 + dbfs_atomic_inc_unchecked(&cnt.num_connect_resp);
74738 cf_sk->sk.sk_state = CAIF_CONNECTED;
74739 set_tx_flow_on(cf_sk);
74740 cf_sk->sk.sk_state_change(&cf_sk->sk);
74741 @@ -263,7 +264,7 @@ static void caif_ctrl_cb(struct cflayer *layr,
74742
74743 case CAIF_CTRLCMD_INIT_FAIL_RSP:
74744 /* Connect request failed */
74745 - dbfs_atomic_inc(&cnt.num_connect_fail_resp);
74746 + dbfs_atomic_inc_unchecked(&cnt.num_connect_fail_resp);
74747 cf_sk->sk.sk_err = ECONNREFUSED;
74748 cf_sk->sk.sk_state = CAIF_DISCONNECTED;
74749 cf_sk->sk.sk_shutdown = SHUTDOWN_MASK;
74750 @@ -277,7 +278,7 @@ static void caif_ctrl_cb(struct cflayer *layr,
74751
74752 case CAIF_CTRLCMD_REMOTE_SHUTDOWN_IND:
74753 /* Modem has closed this connection, or device is down. */
74754 - dbfs_atomic_inc(&cnt.num_remote_shutdown_ind);
74755 + dbfs_atomic_inc_unchecked(&cnt.num_remote_shutdown_ind);
74756 cf_sk->sk.sk_shutdown = SHUTDOWN_MASK;
74757 cf_sk->sk.sk_err = ECONNRESET;
74758 set_rx_flow_on(cf_sk);
74759 @@ -297,7 +298,7 @@ static void caif_check_flow_release(struct sock *sk)
74760 return;
74761
74762 if (atomic_read(&sk->sk_rmem_alloc) <= sk_rcvbuf_lowwater(cf_sk)) {
74763 - dbfs_atomic_inc(&cnt.num_rx_flow_on);
74764 + dbfs_atomic_inc_unchecked(&cnt.num_rx_flow_on);
74765 set_rx_flow_on(cf_sk);
74766 caif_flow_ctrl(sk, CAIF_MODEMCMD_FLOW_ON_REQ);
74767 }
74768 @@ -856,7 +857,7 @@ static int caif_connect(struct socket *sock, struct sockaddr *uaddr,
74769 /*ifindex = id of the interface.*/
74770 cf_sk->conn_req.ifindex = cf_sk->sk.sk_bound_dev_if;
74771
74772 - dbfs_atomic_inc(&cnt.num_connect_req);
74773 + dbfs_atomic_inc_unchecked(&cnt.num_connect_req);
74774 cf_sk->layer.receive = caif_sktrecv_cb;
74775
74776 err = caif_connect_client(sock_net(sk), &cf_sk->conn_req,
74777 @@ -945,7 +946,7 @@ static int caif_release(struct socket *sock)
74778 spin_unlock_bh(&sk->sk_receive_queue.lock);
74779 sock->sk = NULL;
74780
74781 - dbfs_atomic_inc(&cnt.num_disconnect);
74782 + dbfs_atomic_inc_unchecked(&cnt.num_disconnect);
74783
74784 WARN_ON(IS_ERR(cf_sk->debugfs_socket_dir));
74785 if (cf_sk->debugfs_socket_dir != NULL)
74786 @@ -1124,7 +1125,7 @@ static int caif_create(struct net *net, struct socket *sock, int protocol,
74787 cf_sk->conn_req.protocol = protocol;
74788 /* Increase the number of sockets created. */
74789 dbfs_atomic_inc(&cnt.caif_nr_socks);
74790 - num = dbfs_atomic_inc(&cnt.caif_sock_create);
74791 + num = dbfs_atomic_inc_unchecked(&cnt.caif_sock_create);
74792 #ifdef CONFIG_DEBUG_FS
74793 if (!IS_ERR(debugfsdir)) {
74794
74795 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
74796 index 5cf5222..6f704ad 100644
74797 --- a/net/caif/cfctrl.c
74798 +++ b/net/caif/cfctrl.c
74799 @@ -9,6 +9,7 @@
74800 #include <linux/stddef.h>
74801 #include <linux/spinlock.h>
74802 #include <linux/slab.h>
74803 +#include <linux/sched.h>
74804 #include <net/caif/caif_layer.h>
74805 #include <net/caif/cfpkt.h>
74806 #include <net/caif/cfctrl.h>
74807 @@ -42,8 +43,8 @@ struct cflayer *cfctrl_create(void)
74808 memset(&dev_info, 0, sizeof(dev_info));
74809 dev_info.id = 0xff;
74810 cfsrvl_init(&this->serv, 0, &dev_info, false);
74811 - atomic_set(&this->req_seq_no, 1);
74812 - atomic_set(&this->rsp_seq_no, 1);
74813 + atomic_set_unchecked(&this->req_seq_no, 1);
74814 + atomic_set_unchecked(&this->rsp_seq_no, 1);
74815 this->serv.layer.receive = cfctrl_recv;
74816 sprintf(this->serv.layer.name, "ctrl");
74817 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
74818 @@ -129,8 +130,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
74819 struct cfctrl_request_info *req)
74820 {
74821 spin_lock_bh(&ctrl->info_list_lock);
74822 - atomic_inc(&ctrl->req_seq_no);
74823 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
74824 + atomic_inc_unchecked(&ctrl->req_seq_no);
74825 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
74826 list_add_tail(&req->list, &ctrl->list);
74827 spin_unlock_bh(&ctrl->info_list_lock);
74828 }
74829 @@ -148,7 +149,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
74830 if (p != first)
74831 pr_warn("Requests are not received in order\n");
74832
74833 - atomic_set(&ctrl->rsp_seq_no,
74834 + atomic_set_unchecked(&ctrl->rsp_seq_no,
74835 p->sequence_no);
74836 list_del(&p->list);
74837 goto out;
74838 diff --git a/net/can/gw.c b/net/can/gw.c
74839 index 3d79b12..8de85fa 100644
74840 --- a/net/can/gw.c
74841 +++ b/net/can/gw.c
74842 @@ -96,7 +96,7 @@ struct cf_mod {
74843 struct {
74844 void (*xor)(struct can_frame *cf, struct cgw_csum_xor *xor);
74845 void (*crc8)(struct can_frame *cf, struct cgw_csum_crc8 *crc8);
74846 - } csumfunc;
74847 + } __no_const csumfunc;
74848 };
74849
74850
74851 diff --git a/net/compat.c b/net/compat.c
74852 index 6def90e..c6992fa 100644
74853 --- a/net/compat.c
74854 +++ b/net/compat.c
74855 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
74856 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
74857 __get_user(kmsg->msg_flags, &umsg->msg_flags))
74858 return -EFAULT;
74859 - kmsg->msg_name = compat_ptr(tmp1);
74860 - kmsg->msg_iov = compat_ptr(tmp2);
74861 - kmsg->msg_control = compat_ptr(tmp3);
74862 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
74863 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
74864 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
74865 return 0;
74866 }
74867
74868 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
74869
74870 if (kern_msg->msg_namelen) {
74871 if (mode == VERIFY_READ) {
74872 - int err = move_addr_to_kernel(kern_msg->msg_name,
74873 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
74874 kern_msg->msg_namelen,
74875 kern_address);
74876 if (err < 0)
74877 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
74878 kern_msg->msg_name = NULL;
74879
74880 tot_len = iov_from_user_compat_to_kern(kern_iov,
74881 - (struct compat_iovec __user *)kern_msg->msg_iov,
74882 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
74883 kern_msg->msg_iovlen);
74884 if (tot_len >= 0)
74885 kern_msg->msg_iov = kern_iov;
74886 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
74887
74888 #define CMSG_COMPAT_FIRSTHDR(msg) \
74889 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
74890 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
74891 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
74892 (struct compat_cmsghdr __user *)NULL)
74893
74894 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
74895 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
74896 (ucmlen) <= (unsigned long) \
74897 ((mhdr)->msg_controllen - \
74898 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
74899 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
74900
74901 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
74902 struct compat_cmsghdr __user *cmsg, int cmsg_len)
74903 {
74904 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
74905 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
74906 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
74907 msg->msg_controllen)
74908 return NULL;
74909 return (struct compat_cmsghdr __user *)ptr;
74910 @@ -221,7 +221,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
74911 {
74912 struct compat_timeval ctv;
74913 struct compat_timespec cts[3];
74914 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
74915 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
74916 struct compat_cmsghdr cmhdr;
74917 int cmlen;
74918
74919 @@ -273,7 +273,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
74920
74921 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
74922 {
74923 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
74924 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
74925 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
74926 int fdnum = scm->fp->count;
74927 struct file **fp = scm->fp->fp;
74928 @@ -370,7 +370,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
74929 return -EFAULT;
74930 old_fs = get_fs();
74931 set_fs(KERNEL_DS);
74932 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
74933 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
74934 set_fs(old_fs);
74935
74936 return err;
74937 @@ -431,7 +431,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
74938 len = sizeof(ktime);
74939 old_fs = get_fs();
74940 set_fs(KERNEL_DS);
74941 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
74942 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
74943 set_fs(old_fs);
74944
74945 if (!err) {
74946 @@ -566,7 +566,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
74947 case MCAST_JOIN_GROUP:
74948 case MCAST_LEAVE_GROUP:
74949 {
74950 - struct compat_group_req __user *gr32 = (void *)optval;
74951 + struct compat_group_req __user *gr32 = (void __user *)optval;
74952 struct group_req __user *kgr =
74953 compat_alloc_user_space(sizeof(struct group_req));
74954 u32 interface;
74955 @@ -587,7 +587,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
74956 case MCAST_BLOCK_SOURCE:
74957 case MCAST_UNBLOCK_SOURCE:
74958 {
74959 - struct compat_group_source_req __user *gsr32 = (void *)optval;
74960 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
74961 struct group_source_req __user *kgsr = compat_alloc_user_space(
74962 sizeof(struct group_source_req));
74963 u32 interface;
74964 @@ -608,7 +608,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
74965 }
74966 case MCAST_MSFILTER:
74967 {
74968 - struct compat_group_filter __user *gf32 = (void *)optval;
74969 + struct compat_group_filter __user *gf32 = (void __user *)optval;
74970 struct group_filter __user *kgf;
74971 u32 interface, fmode, numsrc;
74972
74973 @@ -646,7 +646,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
74974 char __user *optval, int __user *optlen,
74975 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
74976 {
74977 - struct compat_group_filter __user *gf32 = (void *)optval;
74978 + struct compat_group_filter __user *gf32 = (void __user *)optval;
74979 struct group_filter __user *kgf;
74980 int __user *koptlen;
74981 u32 interface, fmode, numsrc;
74982 diff --git a/net/core/datagram.c b/net/core/datagram.c
74983 index 68bbf9f..5ef0d12 100644
74984 --- a/net/core/datagram.c
74985 +++ b/net/core/datagram.c
74986 @@ -285,7 +285,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
74987 }
74988
74989 kfree_skb(skb);
74990 - atomic_inc(&sk->sk_drops);
74991 + atomic_inc_unchecked(&sk->sk_drops);
74992 sk_mem_reclaim_partial(sk);
74993
74994 return err;
74995 diff --git a/net/core/dev.c b/net/core/dev.c
74996 index 0336374..659088a 100644
74997 --- a/net/core/dev.c
74998 +++ b/net/core/dev.c
74999 @@ -1138,10 +1138,14 @@ void dev_load(struct net *net, const char *name)
75000 if (no_module && capable(CAP_NET_ADMIN))
75001 no_module = request_module("netdev-%s", name);
75002 if (no_module && capable(CAP_SYS_MODULE)) {
75003 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75004 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
75005 +#else
75006 if (!request_module("%s", name))
75007 pr_err("Loading kernel module for a network device "
75008 "with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s "
75009 "instead\n", name);
75010 +#endif
75011 }
75012 }
75013 EXPORT_SYMBOL(dev_load);
75014 @@ -1605,7 +1609,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
75015 {
75016 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
75017 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
75018 - atomic_long_inc(&dev->rx_dropped);
75019 + atomic_long_inc_unchecked(&dev->rx_dropped);
75020 kfree_skb(skb);
75021 return NET_RX_DROP;
75022 }
75023 @@ -1615,7 +1619,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
75024 nf_reset(skb);
75025
75026 if (unlikely(!is_skb_forwardable(dev, skb))) {
75027 - atomic_long_inc(&dev->rx_dropped);
75028 + atomic_long_inc_unchecked(&dev->rx_dropped);
75029 kfree_skb(skb);
75030 return NET_RX_DROP;
75031 }
75032 @@ -2077,7 +2081,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
75033
75034 struct dev_gso_cb {
75035 void (*destructor)(struct sk_buff *skb);
75036 -};
75037 +} __no_const;
75038
75039 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
75040
75041 @@ -2933,7 +2937,7 @@ enqueue:
75042
75043 local_irq_restore(flags);
75044
75045 - atomic_long_inc(&skb->dev->rx_dropped);
75046 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
75047 kfree_skb(skb);
75048 return NET_RX_DROP;
75049 }
75050 @@ -3005,7 +3009,7 @@ int netif_rx_ni(struct sk_buff *skb)
75051 }
75052 EXPORT_SYMBOL(netif_rx_ni);
75053
75054 -static void net_tx_action(struct softirq_action *h)
75055 +static void net_tx_action(void)
75056 {
75057 struct softnet_data *sd = &__get_cpu_var(softnet_data);
75058
75059 @@ -3293,7 +3297,7 @@ ncls:
75060 if (pt_prev) {
75061 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
75062 } else {
75063 - atomic_long_inc(&skb->dev->rx_dropped);
75064 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
75065 kfree_skb(skb);
75066 /* Jamal, now you will not able to escape explaining
75067 * me how you were going to use this. :-)
75068 @@ -3853,7 +3857,7 @@ void netif_napi_del(struct napi_struct *napi)
75069 }
75070 EXPORT_SYMBOL(netif_napi_del);
75071
75072 -static void net_rx_action(struct softirq_action *h)
75073 +static void net_rx_action(void)
75074 {
75075 struct softnet_data *sd = &__get_cpu_var(softnet_data);
75076 unsigned long time_limit = jiffies + 2;
75077 @@ -5878,7 +5882,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
75078 } else {
75079 netdev_stats_to_stats64(storage, &dev->stats);
75080 }
75081 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
75082 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
75083 return storage;
75084 }
75085 EXPORT_SYMBOL(dev_get_stats);
75086 diff --git a/net/core/flow.c b/net/core/flow.c
75087 index e318c7e..168b1d0 100644
75088 --- a/net/core/flow.c
75089 +++ b/net/core/flow.c
75090 @@ -61,7 +61,7 @@ struct flow_cache {
75091 struct timer_list rnd_timer;
75092 };
75093
75094 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
75095 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
75096 EXPORT_SYMBOL(flow_cache_genid);
75097 static struct flow_cache flow_cache_global;
75098 static struct kmem_cache *flow_cachep __read_mostly;
75099 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
75100
75101 static int flow_entry_valid(struct flow_cache_entry *fle)
75102 {
75103 - if (atomic_read(&flow_cache_genid) != fle->genid)
75104 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
75105 return 0;
75106 if (fle->object && !fle->object->ops->check(fle->object))
75107 return 0;
75108 @@ -259,7 +259,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
75109 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
75110 fcp->hash_count++;
75111 }
75112 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
75113 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
75114 flo = fle->object;
75115 if (!flo)
75116 goto ret_object;
75117 @@ -280,7 +280,7 @@ nocache:
75118 }
75119 flo = resolver(net, key, family, dir, flo, ctx);
75120 if (fle) {
75121 - fle->genid = atomic_read(&flow_cache_genid);
75122 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
75123 if (!IS_ERR(flo))
75124 fle->object = flo;
75125 else
75126 diff --git a/net/core/iovec.c b/net/core/iovec.c
75127 index c40f27e..7f49254 100644
75128 --- a/net/core/iovec.c
75129 +++ b/net/core/iovec.c
75130 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr *address,
75131 if (m->msg_namelen) {
75132 if (mode == VERIFY_READ) {
75133 void __user *namep;
75134 - namep = (void __user __force *) m->msg_name;
75135 + namep = (void __force_user *) m->msg_name;
75136 err = move_addr_to_kernel(namep, m->msg_namelen,
75137 address);
75138 if (err < 0)
75139 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr *address,
75140 }
75141
75142 size = m->msg_iovlen * sizeof(struct iovec);
75143 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
75144 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
75145 return -EFAULT;
75146
75147 m->msg_iov = iov;
75148 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
75149 index 5c30296..ebe7b61 100644
75150 --- a/net/core/rtnetlink.c
75151 +++ b/net/core/rtnetlink.c
75152 @@ -57,7 +57,7 @@ struct rtnl_link {
75153 rtnl_doit_func doit;
75154 rtnl_dumpit_func dumpit;
75155 rtnl_calcit_func calcit;
75156 -};
75157 +} __no_const;
75158
75159 static DEFINE_MUTEX(rtnl_mutex);
75160
75161 diff --git a/net/core/scm.c b/net/core/scm.c
75162 index ff52ad0..aff1c0f 100644
75163 --- a/net/core/scm.c
75164 +++ b/net/core/scm.c
75165 @@ -220,7 +220,7 @@ EXPORT_SYMBOL(__scm_send);
75166 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
75167 {
75168 struct cmsghdr __user *cm
75169 - = (__force struct cmsghdr __user *)msg->msg_control;
75170 + = (struct cmsghdr __force_user *)msg->msg_control;
75171 struct cmsghdr cmhdr;
75172 int cmlen = CMSG_LEN(len);
75173 int err;
75174 @@ -243,7 +243,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
75175 err = -EFAULT;
75176 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
75177 goto out;
75178 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
75179 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
75180 goto out;
75181 cmlen = CMSG_SPACE(len);
75182 if (msg->msg_controllen < cmlen)
75183 @@ -259,7 +259,7 @@ EXPORT_SYMBOL(put_cmsg);
75184 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
75185 {
75186 struct cmsghdr __user *cm
75187 - = (__force struct cmsghdr __user*)msg->msg_control;
75188 + = (struct cmsghdr __force_user *)msg->msg_control;
75189
75190 int fdmax = 0;
75191 int fdnum = scm->fp->count;
75192 @@ -279,7 +279,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
75193 if (fdnum < fdmax)
75194 fdmax = fdnum;
75195
75196 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
75197 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
75198 i++, cmfptr++)
75199 {
75200 int new_fd;
75201 diff --git a/net/core/sock.c b/net/core/sock.c
75202 index 02f8dfe..86dfd4a 100644
75203 --- a/net/core/sock.c
75204 +++ b/net/core/sock.c
75205 @@ -341,7 +341,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
75206 struct sk_buff_head *list = &sk->sk_receive_queue;
75207
75208 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
75209 - atomic_inc(&sk->sk_drops);
75210 + atomic_inc_unchecked(&sk->sk_drops);
75211 trace_sock_rcvqueue_full(sk, skb);
75212 return -ENOMEM;
75213 }
75214 @@ -351,7 +351,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
75215 return err;
75216
75217 if (!sk_rmem_schedule(sk, skb->truesize)) {
75218 - atomic_inc(&sk->sk_drops);
75219 + atomic_inc_unchecked(&sk->sk_drops);
75220 return -ENOBUFS;
75221 }
75222
75223 @@ -371,7 +371,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
75224 skb_dst_force(skb);
75225
75226 spin_lock_irqsave(&list->lock, flags);
75227 - skb->dropcount = atomic_read(&sk->sk_drops);
75228 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
75229 __skb_queue_tail(list, skb);
75230 spin_unlock_irqrestore(&list->lock, flags);
75231
75232 @@ -391,7 +391,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
75233 skb->dev = NULL;
75234
75235 if (sk_rcvqueues_full(sk, skb)) {
75236 - atomic_inc(&sk->sk_drops);
75237 + atomic_inc_unchecked(&sk->sk_drops);
75238 goto discard_and_relse;
75239 }
75240 if (nested)
75241 @@ -409,7 +409,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
75242 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
75243 } else if (sk_add_backlog(sk, skb)) {
75244 bh_unlock_sock(sk);
75245 - atomic_inc(&sk->sk_drops);
75246 + atomic_inc_unchecked(&sk->sk_drops);
75247 goto discard_and_relse;
75248 }
75249
75250 @@ -974,7 +974,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
75251 if (len > sizeof(peercred))
75252 len = sizeof(peercred);
75253 cred_to_ucred(sk->sk_peer_pid, sk->sk_peer_cred, &peercred);
75254 - if (copy_to_user(optval, &peercred, len))
75255 + if (len > sizeof(peercred) || copy_to_user(optval, &peercred, len))
75256 return -EFAULT;
75257 goto lenout;
75258 }
75259 @@ -987,7 +987,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
75260 return -ENOTCONN;
75261 if (lv < len)
75262 return -EINVAL;
75263 - if (copy_to_user(optval, address, len))
75264 + if (len > sizeof(address) || copy_to_user(optval, address, len))
75265 return -EFAULT;
75266 goto lenout;
75267 }
75268 @@ -1024,7 +1024,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
75269
75270 if (len > lv)
75271 len = lv;
75272 - if (copy_to_user(optval, &v, len))
75273 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
75274 return -EFAULT;
75275 lenout:
75276 if (put_user(len, optlen))
75277 @@ -2108,7 +2108,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
75278 */
75279 smp_wmb();
75280 atomic_set(&sk->sk_refcnt, 1);
75281 - atomic_set(&sk->sk_drops, 0);
75282 + atomic_set_unchecked(&sk->sk_drops, 0);
75283 }
75284 EXPORT_SYMBOL(sock_init_data);
75285
75286 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
75287 index b9868e1..849f809 100644
75288 --- a/net/core/sock_diag.c
75289 +++ b/net/core/sock_diag.c
75290 @@ -16,20 +16,27 @@ static DEFINE_MUTEX(sock_diag_table_mutex);
75291
75292 int sock_diag_check_cookie(void *sk, __u32 *cookie)
75293 {
75294 +#ifndef CONFIG_GRKERNSEC_HIDESYM
75295 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
75296 cookie[1] != INET_DIAG_NOCOOKIE) &&
75297 ((u32)(unsigned long)sk != cookie[0] ||
75298 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
75299 return -ESTALE;
75300 else
75301 +#endif
75302 return 0;
75303 }
75304 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
75305
75306 void sock_diag_save_cookie(void *sk, __u32 *cookie)
75307 {
75308 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75309 + cookie[0] = 0;
75310 + cookie[1] = 0;
75311 +#else
75312 cookie[0] = (u32)(unsigned long)sk;
75313 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
75314 +#endif
75315 }
75316 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
75317
75318 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
75319 index 02e75d1..9a57a7c 100644
75320 --- a/net/decnet/sysctl_net_decnet.c
75321 +++ b/net/decnet/sysctl_net_decnet.c
75322 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
75323
75324 if (len > *lenp) len = *lenp;
75325
75326 - if (copy_to_user(buffer, addr, len))
75327 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
75328 return -EFAULT;
75329
75330 *lenp = len;
75331 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
75332
75333 if (len > *lenp) len = *lenp;
75334
75335 - if (copy_to_user(buffer, devname, len))
75336 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
75337 return -EFAULT;
75338
75339 *lenp = len;
75340 diff --git a/net/econet/Kconfig b/net/econet/Kconfig
75341 index 39a2d29..f39c0fe 100644
75342 --- a/net/econet/Kconfig
75343 +++ b/net/econet/Kconfig
75344 @@ -4,7 +4,7 @@
75345
75346 config ECONET
75347 tristate "Acorn Econet/AUN protocols (EXPERIMENTAL)"
75348 - depends on EXPERIMENTAL && INET
75349 + depends on EXPERIMENTAL && INET && BROKEN
75350 ---help---
75351 Econet is a fairly old and slow networking protocol mainly used by
75352 Acorn computers to access file and print servers. It uses native
75353 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
75354 index 92fc5f6..b790d91 100644
75355 --- a/net/ipv4/fib_frontend.c
75356 +++ b/net/ipv4/fib_frontend.c
75357 @@ -970,12 +970,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
75358 #ifdef CONFIG_IP_ROUTE_MULTIPATH
75359 fib_sync_up(dev);
75360 #endif
75361 - atomic_inc(&net->ipv4.dev_addr_genid);
75362 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
75363 rt_cache_flush(dev_net(dev), -1);
75364 break;
75365 case NETDEV_DOWN:
75366 fib_del_ifaddr(ifa, NULL);
75367 - atomic_inc(&net->ipv4.dev_addr_genid);
75368 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
75369 if (ifa->ifa_dev->ifa_list == NULL) {
75370 /* Last address was deleted from this interface.
75371 * Disable IP.
75372 @@ -1011,7 +1011,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
75373 #ifdef CONFIG_IP_ROUTE_MULTIPATH
75374 fib_sync_up(dev);
75375 #endif
75376 - atomic_inc(&net->ipv4.dev_addr_genid);
75377 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
75378 rt_cache_flush(dev_net(dev), -1);
75379 break;
75380 case NETDEV_DOWN:
75381 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
75382 index 80106d8..232e898 100644
75383 --- a/net/ipv4/fib_semantics.c
75384 +++ b/net/ipv4/fib_semantics.c
75385 @@ -699,7 +699,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
75386 nh->nh_saddr = inet_select_addr(nh->nh_dev,
75387 nh->nh_gw,
75388 nh->nh_parent->fib_scope);
75389 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
75390 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
75391
75392 return nh->nh_saddr;
75393 }
75394 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
75395 index 984ec65..97ac518 100644
75396 --- a/net/ipv4/inet_hashtables.c
75397 +++ b/net/ipv4/inet_hashtables.c
75398 @@ -18,12 +18,15 @@
75399 #include <linux/sched.h>
75400 #include <linux/slab.h>
75401 #include <linux/wait.h>
75402 +#include <linux/security.h>
75403
75404 #include <net/inet_connection_sock.h>
75405 #include <net/inet_hashtables.h>
75406 #include <net/secure_seq.h>
75407 #include <net/ip.h>
75408
75409 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
75410 +
75411 /*
75412 * Allocate and initialize a new local port bind bucket.
75413 * The bindhash mutex for snum's hash chain must be held here.
75414 @@ -530,6 +533,8 @@ ok:
75415 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
75416 spin_unlock(&head->lock);
75417
75418 + gr_update_task_in_ip_table(current, inet_sk(sk));
75419 +
75420 if (tw) {
75421 inet_twsk_deschedule(tw, death_row);
75422 while (twrefcnt) {
75423 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
75424 index d4d61b6..b81aec8 100644
75425 --- a/net/ipv4/inetpeer.c
75426 +++ b/net/ipv4/inetpeer.c
75427 @@ -487,8 +487,8 @@ relookup:
75428 if (p) {
75429 p->daddr = *daddr;
75430 atomic_set(&p->refcnt, 1);
75431 - atomic_set(&p->rid, 0);
75432 - atomic_set(&p->ip_id_count,
75433 + atomic_set_unchecked(&p->rid, 0);
75434 + atomic_set_unchecked(&p->ip_id_count,
75435 (daddr->family == AF_INET) ?
75436 secure_ip_id(daddr->addr.a4) :
75437 secure_ipv6_id(daddr->addr.a6));
75438 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
75439 index 1f23a57..7180dfe 100644
75440 --- a/net/ipv4/ip_fragment.c
75441 +++ b/net/ipv4/ip_fragment.c
75442 @@ -316,7 +316,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
75443 return 0;
75444
75445 start = qp->rid;
75446 - end = atomic_inc_return(&peer->rid);
75447 + end = atomic_inc_return_unchecked(&peer->rid);
75448 qp->rid = end;
75449
75450 rc = qp->q.fragments && (end - start) > max;
75451 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
75452 index 8aa87c1..35c3248 100644
75453 --- a/net/ipv4/ip_sockglue.c
75454 +++ b/net/ipv4/ip_sockglue.c
75455 @@ -1112,7 +1112,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
75456 len = min_t(unsigned int, len, opt->optlen);
75457 if (put_user(len, optlen))
75458 return -EFAULT;
75459 - if (copy_to_user(optval, opt->__data, len))
75460 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
75461 + copy_to_user(optval, opt->__data, len))
75462 return -EFAULT;
75463 return 0;
75464 }
75465 @@ -1240,7 +1241,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
75466 if (sk->sk_type != SOCK_STREAM)
75467 return -ENOPROTOOPT;
75468
75469 - msg.msg_control = optval;
75470 + msg.msg_control = (void __force_kernel *)optval;
75471 msg.msg_controllen = len;
75472 msg.msg_flags = flags;
75473
75474 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
75475 index 6e412a6..6640538 100644
75476 --- a/net/ipv4/ipconfig.c
75477 +++ b/net/ipv4/ipconfig.c
75478 @@ -318,7 +318,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
75479
75480 mm_segment_t oldfs = get_fs();
75481 set_fs(get_ds());
75482 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
75483 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
75484 set_fs(oldfs);
75485 return res;
75486 }
75487 @@ -329,7 +329,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
75488
75489 mm_segment_t oldfs = get_fs();
75490 set_fs(get_ds());
75491 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
75492 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
75493 set_fs(oldfs);
75494 return res;
75495 }
75496 @@ -340,7 +340,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
75497
75498 mm_segment_t oldfs = get_fs();
75499 set_fs(get_ds());
75500 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
75501 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
75502 set_fs(oldfs);
75503 return res;
75504 }
75505 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
75506 index b072386..abdebcf 100644
75507 --- a/net/ipv4/ping.c
75508 +++ b/net/ipv4/ping.c
75509 @@ -838,7 +838,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
75510 sk_rmem_alloc_get(sp),
75511 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
75512 atomic_read(&sp->sk_refcnt), sp,
75513 - atomic_read(&sp->sk_drops), len);
75514 + atomic_read_unchecked(&sp->sk_drops), len);
75515 }
75516
75517 static int ping_seq_show(struct seq_file *seq, void *v)
75518 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
75519 index 3ccda5a..3c1e61d 100644
75520 --- a/net/ipv4/raw.c
75521 +++ b/net/ipv4/raw.c
75522 @@ -304,7 +304,7 @@ static int raw_rcv_skb(struct sock * sk, struct sk_buff * skb)
75523 int raw_rcv(struct sock *sk, struct sk_buff *skb)
75524 {
75525 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
75526 - atomic_inc(&sk->sk_drops);
75527 + atomic_inc_unchecked(&sk->sk_drops);
75528 kfree_skb(skb);
75529 return NET_RX_DROP;
75530 }
75531 @@ -742,16 +742,20 @@ static int raw_init(struct sock *sk)
75532
75533 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
75534 {
75535 + struct icmp_filter filter;
75536 +
75537 if (optlen > sizeof(struct icmp_filter))
75538 optlen = sizeof(struct icmp_filter);
75539 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
75540 + if (copy_from_user(&filter, optval, optlen))
75541 return -EFAULT;
75542 + raw_sk(sk)->filter = filter;
75543 return 0;
75544 }
75545
75546 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
75547 {
75548 int len, ret = -EFAULT;
75549 + struct icmp_filter filter;
75550
75551 if (get_user(len, optlen))
75552 goto out;
75553 @@ -761,8 +765,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
75554 if (len > sizeof(struct icmp_filter))
75555 len = sizeof(struct icmp_filter);
75556 ret = -EFAULT;
75557 - if (put_user(len, optlen) ||
75558 - copy_to_user(optval, &raw_sk(sk)->filter, len))
75559 + filter = raw_sk(sk)->filter;
75560 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
75561 goto out;
75562 ret = 0;
75563 out: return ret;
75564 @@ -990,7 +994,13 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
75565 sk_wmem_alloc_get(sp),
75566 sk_rmem_alloc_get(sp),
75567 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
75568 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
75569 + atomic_read(&sp->sk_refcnt),
75570 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75571 + NULL,
75572 +#else
75573 + sp,
75574 +#endif
75575 + atomic_read_unchecked(&sp->sk_drops));
75576 }
75577
75578 static int raw_seq_show(struct seq_file *seq, void *v)
75579 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
75580 index 0197747..7adb0dc 100644
75581 --- a/net/ipv4/route.c
75582 +++ b/net/ipv4/route.c
75583 @@ -311,7 +311,7 @@ static inline unsigned int rt_hash(__be32 daddr, __be32 saddr, int idx,
75584
75585 static inline int rt_genid(struct net *net)
75586 {
75587 - return atomic_read(&net->ipv4.rt_genid);
75588 + return atomic_read_unchecked(&net->ipv4.rt_genid);
75589 }
75590
75591 #ifdef CONFIG_PROC_FS
75592 @@ -935,7 +935,7 @@ static void rt_cache_invalidate(struct net *net)
75593 unsigned char shuffle;
75594
75595 get_random_bytes(&shuffle, sizeof(shuffle));
75596 - atomic_add(shuffle + 1U, &net->ipv4.rt_genid);
75597 + atomic_add_unchecked(shuffle + 1U, &net->ipv4.rt_genid);
75598 inetpeer_invalidate_tree(AF_INET);
75599 }
75600
75601 @@ -3010,7 +3010,7 @@ static int rt_fill_info(struct net *net,
75602 error = rt->dst.error;
75603 if (peer) {
75604 inet_peer_refcheck(rt->peer);
75605 - id = atomic_read(&peer->ip_id_count) & 0xffff;
75606 + id = atomic_read_unchecked(&peer->ip_id_count) & 0xffff;
75607 if (peer->tcp_ts_stamp) {
75608 ts = peer->tcp_ts;
75609 tsage = get_seconds() - peer->tcp_ts_stamp;
75610 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
75611 index fd54c5f..96d6407 100644
75612 --- a/net/ipv4/tcp_ipv4.c
75613 +++ b/net/ipv4/tcp_ipv4.c
75614 @@ -88,6 +88,9 @@ int sysctl_tcp_tw_reuse __read_mostly;
75615 int sysctl_tcp_low_latency __read_mostly;
75616 EXPORT_SYMBOL(sysctl_tcp_low_latency);
75617
75618 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
75619 +extern int grsec_enable_blackhole;
75620 +#endif
75621
75622 #ifdef CONFIG_TCP_MD5SIG
75623 static struct tcp_md5sig_key *tcp_v4_md5_do_lookup(struct sock *sk,
75624 @@ -1638,6 +1641,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
75625 return 0;
75626
75627 reset:
75628 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
75629 + if (!grsec_enable_blackhole)
75630 +#endif
75631 tcp_v4_send_reset(rsk, skb);
75632 discard:
75633 kfree_skb(skb);
75634 @@ -1700,12 +1706,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
75635 TCP_SKB_CB(skb)->sacked = 0;
75636
75637 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
75638 - if (!sk)
75639 + if (!sk) {
75640 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
75641 + ret = 1;
75642 +#endif
75643 goto no_tcp_socket;
75644 -
75645 + }
75646 process:
75647 - if (sk->sk_state == TCP_TIME_WAIT)
75648 + if (sk->sk_state == TCP_TIME_WAIT) {
75649 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
75650 + ret = 2;
75651 +#endif
75652 goto do_time_wait;
75653 + }
75654
75655 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
75656 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
75657 @@ -1755,6 +1768,10 @@ no_tcp_socket:
75658 bad_packet:
75659 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
75660 } else {
75661 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
75662 + if (!grsec_enable_blackhole || (ret == 1 &&
75663 + (skb->dev->flags & IFF_LOOPBACK)))
75664 +#endif
75665 tcp_v4_send_reset(NULL, skb);
75666 }
75667
75668 @@ -2417,7 +2434,11 @@ static void get_openreq4(const struct sock *sk, const struct request_sock *req,
75669 0, /* non standard timer */
75670 0, /* open_requests have no inode */
75671 atomic_read(&sk->sk_refcnt),
75672 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75673 + NULL,
75674 +#else
75675 req,
75676 +#endif
75677 len);
75678 }
75679
75680 @@ -2467,7 +2488,12 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i, int *len)
75681 sock_i_uid(sk),
75682 icsk->icsk_probes_out,
75683 sock_i_ino(sk),
75684 - atomic_read(&sk->sk_refcnt), sk,
75685 + atomic_read(&sk->sk_refcnt),
75686 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75687 + NULL,
75688 +#else
75689 + sk,
75690 +#endif
75691 jiffies_to_clock_t(icsk->icsk_rto),
75692 jiffies_to_clock_t(icsk->icsk_ack.ato),
75693 (icsk->icsk_ack.quick << 1) | icsk->icsk_ack.pingpong,
75694 @@ -2495,7 +2521,13 @@ static void get_timewait4_sock(const struct inet_timewait_sock *tw,
75695 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %pK%n",
75696 i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
75697 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
75698 - atomic_read(&tw->tw_refcnt), tw, len);
75699 + atomic_read(&tw->tw_refcnt),
75700 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75701 + NULL,
75702 +#else
75703 + tw,
75704 +#endif
75705 + len);
75706 }
75707
75708 #define TMPSZ 150
75709 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
75710 index 550e755..25721b3 100644
75711 --- a/net/ipv4/tcp_minisocks.c
75712 +++ b/net/ipv4/tcp_minisocks.c
75713 @@ -27,6 +27,10 @@
75714 #include <net/inet_common.h>
75715 #include <net/xfrm.h>
75716
75717 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
75718 +extern int grsec_enable_blackhole;
75719 +#endif
75720 +
75721 int sysctl_tcp_syncookies __read_mostly = 1;
75722 EXPORT_SYMBOL(sysctl_tcp_syncookies);
75723
75724 @@ -753,6 +757,10 @@ listen_overflow:
75725
75726 embryonic_reset:
75727 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_EMBRYONICRSTS);
75728 +
75729 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
75730 + if (!grsec_enable_blackhole)
75731 +#endif
75732 if (!(flg & TCP_FLAG_RST))
75733 req->rsk_ops->send_reset(sk, skb);
75734
75735 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
75736 index 85ee7eb..53277ab 100644
75737 --- a/net/ipv4/tcp_probe.c
75738 +++ b/net/ipv4/tcp_probe.c
75739 @@ -202,7 +202,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
75740 if (cnt + width >= len)
75741 break;
75742
75743 - if (copy_to_user(buf + cnt, tbuf, width))
75744 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
75745 return -EFAULT;
75746 cnt += width;
75747 }
75748 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
75749 index cd2e072..1fffee2 100644
75750 --- a/net/ipv4/tcp_timer.c
75751 +++ b/net/ipv4/tcp_timer.c
75752 @@ -22,6 +22,10 @@
75753 #include <linux/gfp.h>
75754 #include <net/tcp.h>
75755
75756 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
75757 +extern int grsec_lastack_retries;
75758 +#endif
75759 +
75760 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
75761 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
75762 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
75763 @@ -196,6 +200,13 @@ static int tcp_write_timeout(struct sock *sk)
75764 }
75765 }
75766
75767 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
75768 + if ((sk->sk_state == TCP_LAST_ACK) &&
75769 + (grsec_lastack_retries > 0) &&
75770 + (grsec_lastack_retries < retry_until))
75771 + retry_until = grsec_lastack_retries;
75772 +#endif
75773 +
75774 if (retransmits_timed_out(sk, retry_until,
75775 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
75776 /* Has it gone just too far? */
75777 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
75778 index 5d075b5..d907d5f 100644
75779 --- a/net/ipv4/udp.c
75780 +++ b/net/ipv4/udp.c
75781 @@ -86,6 +86,7 @@
75782 #include <linux/types.h>
75783 #include <linux/fcntl.h>
75784 #include <linux/module.h>
75785 +#include <linux/security.h>
75786 #include <linux/socket.h>
75787 #include <linux/sockios.h>
75788 #include <linux/igmp.h>
75789 @@ -108,6 +109,10 @@
75790 #include <trace/events/udp.h>
75791 #include "udp_impl.h"
75792
75793 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
75794 +extern int grsec_enable_blackhole;
75795 +#endif
75796 +
75797 struct udp_table udp_table __read_mostly;
75798 EXPORT_SYMBOL(udp_table);
75799
75800 @@ -566,6 +571,9 @@ found:
75801 return s;
75802 }
75803
75804 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
75805 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
75806 +
75807 /*
75808 * This routine is called by the ICMP module when it gets some
75809 * sort of error condition. If err < 0 then the socket should
75810 @@ -857,9 +865,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
75811 dport = usin->sin_port;
75812 if (dport == 0)
75813 return -EINVAL;
75814 +
75815 + err = gr_search_udp_sendmsg(sk, usin);
75816 + if (err)
75817 + return err;
75818 } else {
75819 if (sk->sk_state != TCP_ESTABLISHED)
75820 return -EDESTADDRREQ;
75821 +
75822 + err = gr_search_udp_sendmsg(sk, NULL);
75823 + if (err)
75824 + return err;
75825 +
75826 daddr = inet->inet_daddr;
75827 dport = inet->inet_dport;
75828 /* Open fast path for connected socket.
75829 @@ -1100,7 +1117,7 @@ static unsigned int first_packet_length(struct sock *sk)
75830 udp_lib_checksum_complete(skb)) {
75831 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
75832 IS_UDPLITE(sk));
75833 - atomic_inc(&sk->sk_drops);
75834 + atomic_inc_unchecked(&sk->sk_drops);
75835 __skb_unlink(skb, rcvq);
75836 __skb_queue_tail(&list_kill, skb);
75837 }
75838 @@ -1186,6 +1203,10 @@ try_again:
75839 if (!skb)
75840 goto out;
75841
75842 + err = gr_search_udp_recvmsg(sk, skb);
75843 + if (err)
75844 + goto out_free;
75845 +
75846 ulen = skb->len - sizeof(struct udphdr);
75847 copied = len;
75848 if (copied > ulen)
75849 @@ -1489,7 +1510,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
75850
75851 drop:
75852 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
75853 - atomic_inc(&sk->sk_drops);
75854 + atomic_inc_unchecked(&sk->sk_drops);
75855 kfree_skb(skb);
75856 return -1;
75857 }
75858 @@ -1508,7 +1529,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
75859 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
75860
75861 if (!skb1) {
75862 - atomic_inc(&sk->sk_drops);
75863 + atomic_inc_unchecked(&sk->sk_drops);
75864 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
75865 IS_UDPLITE(sk));
75866 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
75867 @@ -1677,6 +1698,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
75868 goto csum_error;
75869
75870 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
75871 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
75872 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
75873 +#endif
75874 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
75875
75876 /*
75877 @@ -2100,8 +2124,13 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
75878 sk_wmem_alloc_get(sp),
75879 sk_rmem_alloc_get(sp),
75880 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp),
75881 - atomic_read(&sp->sk_refcnt), sp,
75882 - atomic_read(&sp->sk_drops), len);
75883 + atomic_read(&sp->sk_refcnt),
75884 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75885 + NULL,
75886 +#else
75887 + sp,
75888 +#endif
75889 + atomic_read_unchecked(&sp->sk_drops), len);
75890 }
75891
75892 int udp4_seq_show(struct seq_file *seq, void *v)
75893 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
75894 index 6b8ebc5..1d624f4 100644
75895 --- a/net/ipv6/addrconf.c
75896 +++ b/net/ipv6/addrconf.c
75897 @@ -2145,7 +2145,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
75898 p.iph.ihl = 5;
75899 p.iph.protocol = IPPROTO_IPV6;
75900 p.iph.ttl = 64;
75901 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
75902 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
75903
75904 if (ops->ndo_do_ioctl) {
75905 mm_segment_t oldfs = get_fs();
75906 diff --git a/net/ipv6/inet6_connection_sock.c b/net/ipv6/inet6_connection_sock.c
75907 index 02dd203..e03fcc9 100644
75908 --- a/net/ipv6/inet6_connection_sock.c
75909 +++ b/net/ipv6/inet6_connection_sock.c
75910 @@ -178,7 +178,7 @@ void __inet6_csk_dst_store(struct sock *sk, struct dst_entry *dst,
75911 #ifdef CONFIG_XFRM
75912 {
75913 struct rt6_info *rt = (struct rt6_info *)dst;
75914 - rt->rt6i_flow_cache_genid = atomic_read(&flow_cache_genid);
75915 + rt->rt6i_flow_cache_genid = atomic_read_unchecked(&flow_cache_genid);
75916 }
75917 #endif
75918 }
75919 @@ -193,7 +193,7 @@ struct dst_entry *__inet6_csk_dst_check(struct sock *sk, u32 cookie)
75920 #ifdef CONFIG_XFRM
75921 if (dst) {
75922 struct rt6_info *rt = (struct rt6_info *)dst;
75923 - if (rt->rt6i_flow_cache_genid != atomic_read(&flow_cache_genid)) {
75924 + if (rt->rt6i_flow_cache_genid != atomic_read_unchecked(&flow_cache_genid)) {
75925 __sk_dst_reset(sk);
75926 dst = NULL;
75927 }
75928 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
75929 index 18a2719..779f36a 100644
75930 --- a/net/ipv6/ipv6_sockglue.c
75931 +++ b/net/ipv6/ipv6_sockglue.c
75932 @@ -960,7 +960,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
75933 if (sk->sk_type != SOCK_STREAM)
75934 return -ENOPROTOOPT;
75935
75936 - msg.msg_control = optval;
75937 + msg.msg_control = (void __force_kernel *)optval;
75938 msg.msg_controllen = len;
75939 msg.msg_flags = flags;
75940
75941 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
75942 index d02f7e4..2d2a0f1 100644
75943 --- a/net/ipv6/raw.c
75944 +++ b/net/ipv6/raw.c
75945 @@ -377,7 +377,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
75946 {
75947 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
75948 skb_checksum_complete(skb)) {
75949 - atomic_inc(&sk->sk_drops);
75950 + atomic_inc_unchecked(&sk->sk_drops);
75951 kfree_skb(skb);
75952 return NET_RX_DROP;
75953 }
75954 @@ -405,7 +405,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
75955 struct raw6_sock *rp = raw6_sk(sk);
75956
75957 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
75958 - atomic_inc(&sk->sk_drops);
75959 + atomic_inc_unchecked(&sk->sk_drops);
75960 kfree_skb(skb);
75961 return NET_RX_DROP;
75962 }
75963 @@ -429,7 +429,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
75964
75965 if (inet->hdrincl) {
75966 if (skb_checksum_complete(skb)) {
75967 - atomic_inc(&sk->sk_drops);
75968 + atomic_inc_unchecked(&sk->sk_drops);
75969 kfree_skb(skb);
75970 return NET_RX_DROP;
75971 }
75972 @@ -602,7 +602,7 @@ out:
75973 return err;
75974 }
75975
75976 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
75977 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
75978 struct flowi6 *fl6, struct dst_entry **dstp,
75979 unsigned int flags)
75980 {
75981 @@ -912,12 +912,15 @@ do_confirm:
75982 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
75983 char __user *optval, int optlen)
75984 {
75985 + struct icmp6_filter filter;
75986 +
75987 switch (optname) {
75988 case ICMPV6_FILTER:
75989 if (optlen > sizeof(struct icmp6_filter))
75990 optlen = sizeof(struct icmp6_filter);
75991 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
75992 + if (copy_from_user(&filter, optval, optlen))
75993 return -EFAULT;
75994 + raw6_sk(sk)->filter = filter;
75995 return 0;
75996 default:
75997 return -ENOPROTOOPT;
75998 @@ -930,6 +933,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
75999 char __user *optval, int __user *optlen)
76000 {
76001 int len;
76002 + struct icmp6_filter filter;
76003
76004 switch (optname) {
76005 case ICMPV6_FILTER:
76006 @@ -941,7 +945,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
76007 len = sizeof(struct icmp6_filter);
76008 if (put_user(len, optlen))
76009 return -EFAULT;
76010 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
76011 + filter = raw6_sk(sk)->filter;
76012 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
76013 return -EFAULT;
76014 return 0;
76015 default:
76016 @@ -1248,7 +1253,13 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
76017 0, 0L, 0,
76018 sock_i_uid(sp), 0,
76019 sock_i_ino(sp),
76020 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
76021 + atomic_read(&sp->sk_refcnt),
76022 +#ifdef CONFIG_GRKERNSEC_HIDESYM
76023 + NULL,
76024 +#else
76025 + sp,
76026 +#endif
76027 + atomic_read_unchecked(&sp->sk_drops));
76028 }
76029
76030 static int raw6_seq_show(struct seq_file *seq, void *v)
76031 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
76032 index a89ca8d..12e66b0 100644
76033 --- a/net/ipv6/tcp_ipv6.c
76034 +++ b/net/ipv6/tcp_ipv6.c
76035 @@ -94,6 +94,10 @@ static struct tcp_md5sig_key *tcp_v6_md5_do_lookup(struct sock *sk,
76036 }
76037 #endif
76038
76039 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
76040 +extern int grsec_enable_blackhole;
76041 +#endif
76042 +
76043 static void tcp_v6_hash(struct sock *sk)
76044 {
76045 if (sk->sk_state != TCP_CLOSE) {
76046 @@ -1654,6 +1658,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
76047 return 0;
76048
76049 reset:
76050 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
76051 + if (!grsec_enable_blackhole)
76052 +#endif
76053 tcp_v6_send_reset(sk, skb);
76054 discard:
76055 if (opt_skb)
76056 @@ -1733,12 +1740,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
76057 TCP_SKB_CB(skb)->sacked = 0;
76058
76059 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
76060 - if (!sk)
76061 + if (!sk) {
76062 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
76063 + ret = 1;
76064 +#endif
76065 goto no_tcp_socket;
76066 + }
76067
76068 process:
76069 - if (sk->sk_state == TCP_TIME_WAIT)
76070 + if (sk->sk_state == TCP_TIME_WAIT) {
76071 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
76072 + ret = 2;
76073 +#endif
76074 goto do_time_wait;
76075 + }
76076
76077 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
76078 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
76079 @@ -1786,6 +1801,10 @@ no_tcp_socket:
76080 bad_packet:
76081 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
76082 } else {
76083 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
76084 + if (!grsec_enable_blackhole || (ret == 1 &&
76085 + (skb->dev->flags & IFF_LOOPBACK)))
76086 +#endif
76087 tcp_v6_send_reset(NULL, skb);
76088 }
76089
76090 @@ -2047,7 +2066,13 @@ static void get_openreq6(struct seq_file *seq,
76091 uid,
76092 0, /* non standard timer */
76093 0, /* open_requests have no inode */
76094 - 0, req);
76095 + 0,
76096 +#ifdef CONFIG_GRKERNSEC_HIDESYM
76097 + NULL
76098 +#else
76099 + req
76100 +#endif
76101 + );
76102 }
76103
76104 static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
76105 @@ -2097,7 +2122,12 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
76106 sock_i_uid(sp),
76107 icsk->icsk_probes_out,
76108 sock_i_ino(sp),
76109 - atomic_read(&sp->sk_refcnt), sp,
76110 + atomic_read(&sp->sk_refcnt),
76111 +#ifdef CONFIG_GRKERNSEC_HIDESYM
76112 + NULL,
76113 +#else
76114 + sp,
76115 +#endif
76116 jiffies_to_clock_t(icsk->icsk_rto),
76117 jiffies_to_clock_t(icsk->icsk_ack.ato),
76118 (icsk->icsk_ack.quick << 1 ) | icsk->icsk_ack.pingpong,
76119 @@ -2132,7 +2162,13 @@ static void get_timewait6_sock(struct seq_file *seq,
76120 dest->s6_addr32[2], dest->s6_addr32[3], destp,
76121 tw->tw_substate, 0, 0,
76122 3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
76123 - atomic_read(&tw->tw_refcnt), tw);
76124 + atomic_read(&tw->tw_refcnt),
76125 +#ifdef CONFIG_GRKERNSEC_HIDESYM
76126 + NULL
76127 +#else
76128 + tw
76129 +#endif
76130 + );
76131 }
76132
76133 static int tcp6_seq_show(struct seq_file *seq, void *v)
76134 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
76135 index 4f96b5c..75543d7 100644
76136 --- a/net/ipv6/udp.c
76137 +++ b/net/ipv6/udp.c
76138 @@ -50,6 +50,10 @@
76139 #include <linux/seq_file.h>
76140 #include "udp_impl.h"
76141
76142 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
76143 +extern int grsec_enable_blackhole;
76144 +#endif
76145 +
76146 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
76147 {
76148 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
76149 @@ -551,7 +555,7 @@ int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
76150
76151 return 0;
76152 drop:
76153 - atomic_inc(&sk->sk_drops);
76154 + atomic_inc_unchecked(&sk->sk_drops);
76155 drop_no_sk_drops_inc:
76156 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
76157 kfree_skb(skb);
76158 @@ -627,7 +631,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
76159 continue;
76160 }
76161 drop:
76162 - atomic_inc(&sk->sk_drops);
76163 + atomic_inc_unchecked(&sk->sk_drops);
76164 UDP6_INC_STATS_BH(sock_net(sk),
76165 UDP_MIB_RCVBUFERRORS, IS_UDPLITE(sk));
76166 UDP6_INC_STATS_BH(sock_net(sk),
76167 @@ -782,6 +786,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
76168 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS,
76169 proto == IPPROTO_UDPLITE);
76170
76171 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
76172 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
76173 +#endif
76174 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
76175
76176 kfree_skb(skb);
76177 @@ -798,7 +805,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
76178 if (!sock_owned_by_user(sk))
76179 udpv6_queue_rcv_skb(sk, skb);
76180 else if (sk_add_backlog(sk, skb)) {
76181 - atomic_inc(&sk->sk_drops);
76182 + atomic_inc_unchecked(&sk->sk_drops);
76183 bh_unlock_sock(sk);
76184 sock_put(sk);
76185 goto discard;
76186 @@ -1410,8 +1417,13 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
76187 0, 0L, 0,
76188 sock_i_uid(sp), 0,
76189 sock_i_ino(sp),
76190 - atomic_read(&sp->sk_refcnt), sp,
76191 - atomic_read(&sp->sk_drops));
76192 + atomic_read(&sp->sk_refcnt),
76193 +#ifdef CONFIG_GRKERNSEC_HIDESYM
76194 + NULL,
76195 +#else
76196 + sp,
76197 +#endif
76198 + atomic_read_unchecked(&sp->sk_drops));
76199 }
76200
76201 int udp6_seq_show(struct seq_file *seq, void *v)
76202 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
76203 index 253695d..9481ce8 100644
76204 --- a/net/irda/ircomm/ircomm_tty.c
76205 +++ b/net/irda/ircomm/ircomm_tty.c
76206 @@ -282,16 +282,16 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
76207 add_wait_queue(&self->open_wait, &wait);
76208
76209 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
76210 - __FILE__,__LINE__, tty->driver->name, self->open_count );
76211 + __FILE__,__LINE__, tty->driver->name, local_read(&self->open_count) );
76212
76213 /* As far as I can see, we protect open_count - Jean II */
76214 spin_lock_irqsave(&self->spinlock, flags);
76215 if (!tty_hung_up_p(filp)) {
76216 extra_count = 1;
76217 - self->open_count--;
76218 + local_dec(&self->open_count);
76219 }
76220 spin_unlock_irqrestore(&self->spinlock, flags);
76221 - self->blocked_open++;
76222 + local_inc(&self->blocked_open);
76223
76224 while (1) {
76225 if (tty->termios->c_cflag & CBAUD) {
76226 @@ -331,7 +331,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
76227 }
76228
76229 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
76230 - __FILE__,__LINE__, tty->driver->name, self->open_count );
76231 + __FILE__,__LINE__, tty->driver->name, local_read(&self->open_count) );
76232
76233 schedule();
76234 }
76235 @@ -342,13 +342,13 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
76236 if (extra_count) {
76237 /* ++ is not atomic, so this should be protected - Jean II */
76238 spin_lock_irqsave(&self->spinlock, flags);
76239 - self->open_count++;
76240 + local_inc(&self->open_count);
76241 spin_unlock_irqrestore(&self->spinlock, flags);
76242 }
76243 - self->blocked_open--;
76244 + local_dec(&self->blocked_open);
76245
76246 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
76247 - __FILE__,__LINE__, tty->driver->name, self->open_count);
76248 + __FILE__,__LINE__, tty->driver->name, local_read(&self->open_count));
76249
76250 if (!retval)
76251 self->flags |= ASYNC_NORMAL_ACTIVE;
76252 @@ -417,14 +417,14 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
76253 }
76254 /* ++ is not atomic, so this should be protected - Jean II */
76255 spin_lock_irqsave(&self->spinlock, flags);
76256 - self->open_count++;
76257 + local_inc(&self->open_count);
76258
76259 tty->driver_data = self;
76260 self->tty = tty;
76261 spin_unlock_irqrestore(&self->spinlock, flags);
76262
76263 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
76264 - self->line, self->open_count);
76265 + self->line, local_read(&self->open_count));
76266
76267 /* Not really used by us, but lets do it anyway */
76268 self->tty->low_latency = (self->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
76269 @@ -510,7 +510,7 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
76270 return;
76271 }
76272
76273 - if ((tty->count == 1) && (self->open_count != 1)) {
76274 + if ((tty->count == 1) && (local_read(&self->open_count) != 1)) {
76275 /*
76276 * Uh, oh. tty->count is 1, which means that the tty
76277 * structure will be freed. state->count should always
76278 @@ -520,16 +520,16 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
76279 */
76280 IRDA_DEBUG(0, "%s(), bad serial port count; "
76281 "tty->count is 1, state->count is %d\n", __func__ ,
76282 - self->open_count);
76283 - self->open_count = 1;
76284 + local_read(&self->open_count));
76285 + local_set(&self->open_count, 1);
76286 }
76287
76288 - if (--self->open_count < 0) {
76289 + if (local_dec_return(&self->open_count) < 0) {
76290 IRDA_ERROR("%s(), bad serial port count for ttys%d: %d\n",
76291 - __func__, self->line, self->open_count);
76292 - self->open_count = 0;
76293 + __func__, self->line, local_read(&self->open_count));
76294 + local_set(&self->open_count, 0);
76295 }
76296 - if (self->open_count) {
76297 + if (local_read(&self->open_count)) {
76298 spin_unlock_irqrestore(&self->spinlock, flags);
76299
76300 IRDA_DEBUG(0, "%s(), open count > 0\n", __func__ );
76301 @@ -561,7 +561,7 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
76302 tty->closing = 0;
76303 self->tty = NULL;
76304
76305 - if (self->blocked_open) {
76306 + if (local_read(&self->blocked_open)) {
76307 if (self->close_delay)
76308 schedule_timeout_interruptible(self->close_delay);
76309 wake_up_interruptible(&self->open_wait);
76310 @@ -1013,7 +1013,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
76311 spin_lock_irqsave(&self->spinlock, flags);
76312 self->flags &= ~ASYNC_NORMAL_ACTIVE;
76313 self->tty = NULL;
76314 - self->open_count = 0;
76315 + local_set(&self->open_count, 0);
76316 spin_unlock_irqrestore(&self->spinlock, flags);
76317
76318 wake_up_interruptible(&self->open_wait);
76319 @@ -1360,7 +1360,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
76320 seq_putc(m, '\n');
76321
76322 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
76323 - seq_printf(m, "Open count: %d\n", self->open_count);
76324 + seq_printf(m, "Open count: %d\n", local_read(&self->open_count));
76325 seq_printf(m, "Max data size: %d\n", self->max_data_size);
76326 seq_printf(m, "Max header size: %d\n", self->max_header_size);
76327
76328 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
76329 index d5c5b8f..33beff0 100644
76330 --- a/net/iucv/af_iucv.c
76331 +++ b/net/iucv/af_iucv.c
76332 @@ -764,10 +764,10 @@ static int iucv_sock_autobind(struct sock *sk)
76333
76334 write_lock_bh(&iucv_sk_list.lock);
76335
76336 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
76337 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
76338 while (__iucv_get_sock_by_name(name)) {
76339 sprintf(name, "%08x",
76340 - atomic_inc_return(&iucv_sk_list.autobind_name));
76341 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
76342 }
76343
76344 write_unlock_bh(&iucv_sk_list.lock);
76345 diff --git a/net/key/af_key.c b/net/key/af_key.c
76346 index 11dbb22..c20f667 100644
76347 --- a/net/key/af_key.c
76348 +++ b/net/key/af_key.c
76349 @@ -3016,10 +3016,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
76350 static u32 get_acqseq(void)
76351 {
76352 u32 res;
76353 - static atomic_t acqseq;
76354 + static atomic_unchecked_t acqseq;
76355
76356 do {
76357 - res = atomic_inc_return(&acqseq);
76358 + res = atomic_inc_return_unchecked(&acqseq);
76359 } while (!res);
76360 return res;
76361 }
76362 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
76363 index 2f0642d..e5c6fba 100644
76364 --- a/net/mac80211/ieee80211_i.h
76365 +++ b/net/mac80211/ieee80211_i.h
76366 @@ -28,6 +28,7 @@
76367 #include <net/ieee80211_radiotap.h>
76368 #include <net/cfg80211.h>
76369 #include <net/mac80211.h>
76370 +#include <asm/local.h>
76371 #include "key.h"
76372 #include "sta_info.h"
76373
76374 @@ -781,7 +782,7 @@ struct ieee80211_local {
76375 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
76376 spinlock_t queue_stop_reason_lock;
76377
76378 - int open_count;
76379 + local_t open_count;
76380 int monitors, cooked_mntrs;
76381 /* number of interfaces with corresponding FIF_ flags */
76382 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
76383 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
76384 index 8e2137b..2974283 100644
76385 --- a/net/mac80211/iface.c
76386 +++ b/net/mac80211/iface.c
76387 @@ -222,7 +222,7 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up)
76388 break;
76389 }
76390
76391 - if (local->open_count == 0) {
76392 + if (local_read(&local->open_count) == 0) {
76393 res = drv_start(local);
76394 if (res)
76395 goto err_del_bss;
76396 @@ -246,7 +246,7 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up)
76397 memcpy(dev->perm_addr, dev->dev_addr, ETH_ALEN);
76398
76399 if (!is_valid_ether_addr(dev->dev_addr)) {
76400 - if (!local->open_count)
76401 + if (!local_read(&local->open_count))
76402 drv_stop(local);
76403 return -EADDRNOTAVAIL;
76404 }
76405 @@ -347,7 +347,7 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up)
76406 mutex_unlock(&local->mtx);
76407
76408 if (coming_up)
76409 - local->open_count++;
76410 + local_inc(&local->open_count);
76411
76412 if (hw_reconf_flags)
76413 ieee80211_hw_config(local, hw_reconf_flags);
76414 @@ -360,7 +360,7 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up)
76415 err_del_interface:
76416 drv_remove_interface(local, sdata);
76417 err_stop:
76418 - if (!local->open_count)
76419 + if (!local_read(&local->open_count))
76420 drv_stop(local);
76421 err_del_bss:
76422 sdata->bss = NULL;
76423 @@ -489,7 +489,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
76424 }
76425
76426 if (going_down)
76427 - local->open_count--;
76428 + local_dec(&local->open_count);
76429
76430 switch (sdata->vif.type) {
76431 case NL80211_IFTYPE_AP_VLAN:
76432 @@ -548,7 +548,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
76433
76434 ieee80211_recalc_ps(local, -1);
76435
76436 - if (local->open_count == 0) {
76437 + if (local_read(&local->open_count) == 0) {
76438 if (local->ops->napi_poll)
76439 napi_disable(&local->napi);
76440 ieee80211_clear_tx_pending(local);
76441 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
76442 index b142bd4..a651749 100644
76443 --- a/net/mac80211/main.c
76444 +++ b/net/mac80211/main.c
76445 @@ -166,7 +166,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
76446 local->hw.conf.power_level = power;
76447 }
76448
76449 - if (changed && local->open_count) {
76450 + if (changed && local_read(&local->open_count)) {
76451 ret = drv_config(local, changed);
76452 /*
76453 * Goal:
76454 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
76455 index 596efaf..8f1911f 100644
76456 --- a/net/mac80211/pm.c
76457 +++ b/net/mac80211/pm.c
76458 @@ -34,7 +34,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
76459 struct ieee80211_sub_if_data *sdata;
76460 struct sta_info *sta;
76461
76462 - if (!local->open_count)
76463 + if (!local_read(&local->open_count))
76464 goto suspend;
76465
76466 ieee80211_scan_cancel(local);
76467 @@ -72,7 +72,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
76468 cancel_work_sync(&local->dynamic_ps_enable_work);
76469 del_timer_sync(&local->dynamic_ps_timer);
76470
76471 - local->wowlan = wowlan && local->open_count;
76472 + local->wowlan = wowlan && local_read(&local->open_count);
76473 if (local->wowlan) {
76474 int err = drv_suspend(local, wowlan);
76475 if (err < 0) {
76476 @@ -129,7 +129,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
76477 }
76478
76479 /* stop hardware - this must stop RX */
76480 - if (local->open_count)
76481 + if (local_read(&local->open_count))
76482 ieee80211_stop_device(local);
76483
76484 suspend:
76485 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
76486 index f9b8e81..bb89b46 100644
76487 --- a/net/mac80211/rate.c
76488 +++ b/net/mac80211/rate.c
76489 @@ -401,7 +401,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
76490
76491 ASSERT_RTNL();
76492
76493 - if (local->open_count)
76494 + if (local_read(&local->open_count))
76495 return -EBUSY;
76496
76497 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
76498 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
76499 index c97a065..ff61928 100644
76500 --- a/net/mac80211/rc80211_pid_debugfs.c
76501 +++ b/net/mac80211/rc80211_pid_debugfs.c
76502 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
76503
76504 spin_unlock_irqrestore(&events->lock, status);
76505
76506 - if (copy_to_user(buf, pb, p))
76507 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
76508 return -EFAULT;
76509
76510 return p;
76511 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
76512 index 9919892..8c49803 100644
76513 --- a/net/mac80211/util.c
76514 +++ b/net/mac80211/util.c
76515 @@ -1143,7 +1143,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
76516 }
76517 #endif
76518 /* everything else happens only if HW was up & running */
76519 - if (!local->open_count)
76520 + if (!local_read(&local->open_count))
76521 goto wake_up;
76522
76523 /*
76524 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
76525 index f8ac4ef..b02560b 100644
76526 --- a/net/netfilter/Kconfig
76527 +++ b/net/netfilter/Kconfig
76528 @@ -806,6 +806,16 @@ config NETFILTER_XT_MATCH_ESP
76529
76530 To compile it as a module, choose M here. If unsure, say N.
76531
76532 +config NETFILTER_XT_MATCH_GRADM
76533 + tristate '"gradm" match support'
76534 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
76535 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
76536 + ---help---
76537 + The gradm match allows to match on grsecurity RBAC being enabled.
76538 + It is useful when iptables rules are applied early on bootup to
76539 + prevent connections to the machine (except from a trusted host)
76540 + while the RBAC system is disabled.
76541 +
76542 config NETFILTER_XT_MATCH_HASHLIMIT
76543 tristate '"hashlimit" match support'
76544 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
76545 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
76546 index 40f4c3d..0d5dd6b 100644
76547 --- a/net/netfilter/Makefile
76548 +++ b/net/netfilter/Makefile
76549 @@ -83,6 +83,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
76550 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
76551 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
76552 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
76553 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
76554 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
76555 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
76556 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
76557 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
76558 index 29fa5ba..8debc79 100644
76559 --- a/net/netfilter/ipvs/ip_vs_conn.c
76560 +++ b/net/netfilter/ipvs/ip_vs_conn.c
76561 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
76562 /* Increase the refcnt counter of the dest */
76563 atomic_inc(&dest->refcnt);
76564
76565 - conn_flags = atomic_read(&dest->conn_flags);
76566 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
76567 if (cp->protocol != IPPROTO_UDP)
76568 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
76569 /* Bind with the destination and its corresponding transmitter */
76570 @@ -869,7 +869,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
76571 atomic_set(&cp->refcnt, 1);
76572
76573 atomic_set(&cp->n_control, 0);
76574 - atomic_set(&cp->in_pkts, 0);
76575 + atomic_set_unchecked(&cp->in_pkts, 0);
76576
76577 atomic_inc(&ipvs->conn_count);
76578 if (flags & IP_VS_CONN_F_NO_CPORT)
76579 @@ -1149,7 +1149,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
76580
76581 /* Don't drop the entry if its number of incoming packets is not
76582 located in [0, 8] */
76583 - i = atomic_read(&cp->in_pkts);
76584 + i = atomic_read_unchecked(&cp->in_pkts);
76585 if (i > 8 || i < 0) return 0;
76586
76587 if (!todrop_rate[i]) return 0;
76588 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
76589 index 2555816..31492d9 100644
76590 --- a/net/netfilter/ipvs/ip_vs_core.c
76591 +++ b/net/netfilter/ipvs/ip_vs_core.c
76592 @@ -562,7 +562,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
76593 ret = cp->packet_xmit(skb, cp, pd->pp);
76594 /* do not touch skb anymore */
76595
76596 - atomic_inc(&cp->in_pkts);
76597 + atomic_inc_unchecked(&cp->in_pkts);
76598 ip_vs_conn_put(cp);
76599 return ret;
76600 }
76601 @@ -1611,7 +1611,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
76602 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
76603 pkts = sysctl_sync_threshold(ipvs);
76604 else
76605 - pkts = atomic_add_return(1, &cp->in_pkts);
76606 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
76607
76608 if ((ipvs->sync_state & IP_VS_STATE_MASTER) &&
76609 cp->protocol == IPPROTO_SCTP) {
76610 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
76611 index b3afe18..08ec940 100644
76612 --- a/net/netfilter/ipvs/ip_vs_ctl.c
76613 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
76614 @@ -788,7 +788,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
76615 ip_vs_rs_hash(ipvs, dest);
76616 write_unlock_bh(&ipvs->rs_lock);
76617 }
76618 - atomic_set(&dest->conn_flags, conn_flags);
76619 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
76620
76621 /* bind the service */
76622 if (!dest->svc) {
76623 @@ -2028,7 +2028,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
76624 " %-7s %-6d %-10d %-10d\n",
76625 &dest->addr.in6,
76626 ntohs(dest->port),
76627 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
76628 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
76629 atomic_read(&dest->weight),
76630 atomic_read(&dest->activeconns),
76631 atomic_read(&dest->inactconns));
76632 @@ -2039,7 +2039,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
76633 "%-7s %-6d %-10d %-10d\n",
76634 ntohl(dest->addr.ip),
76635 ntohs(dest->port),
76636 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
76637 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
76638 atomic_read(&dest->weight),
76639 atomic_read(&dest->activeconns),
76640 atomic_read(&dest->inactconns));
76641 @@ -2509,7 +2509,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
76642
76643 entry.addr = dest->addr.ip;
76644 entry.port = dest->port;
76645 - entry.conn_flags = atomic_read(&dest->conn_flags);
76646 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
76647 entry.weight = atomic_read(&dest->weight);
76648 entry.u_threshold = dest->u_threshold;
76649 entry.l_threshold = dest->l_threshold;
76650 @@ -3042,7 +3042,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
76651 NLA_PUT_U16(skb, IPVS_DEST_ATTR_PORT, dest->port);
76652
76653 NLA_PUT_U32(skb, IPVS_DEST_ATTR_FWD_METHOD,
76654 - atomic_read(&dest->conn_flags) & IP_VS_CONN_F_FWD_MASK);
76655 + atomic_read_unchecked(&dest->conn_flags) & IP_VS_CONN_F_FWD_MASK);
76656 NLA_PUT_U32(skb, IPVS_DEST_ATTR_WEIGHT, atomic_read(&dest->weight));
76657 NLA_PUT_U32(skb, IPVS_DEST_ATTR_U_THRESH, dest->u_threshold);
76658 NLA_PUT_U32(skb, IPVS_DEST_ATTR_L_THRESH, dest->l_threshold);
76659 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
76660 index 8a0d6d6..90ec197 100644
76661 --- a/net/netfilter/ipvs/ip_vs_sync.c
76662 +++ b/net/netfilter/ipvs/ip_vs_sync.c
76663 @@ -649,7 +649,7 @@ control:
76664 * i.e only increment in_pkts for Templates.
76665 */
76666 if (cp->flags & IP_VS_CONN_F_TEMPLATE) {
76667 - int pkts = atomic_add_return(1, &cp->in_pkts);
76668 + int pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
76669
76670 if (pkts % sysctl_sync_period(ipvs) != 1)
76671 return;
76672 @@ -795,7 +795,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
76673
76674 if (opt)
76675 memcpy(&cp->in_seq, opt, sizeof(*opt));
76676 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
76677 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
76678 cp->state = state;
76679 cp->old_state = cp->state;
76680 /*
76681 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
76682 index 7fd66de..e6fb361 100644
76683 --- a/net/netfilter/ipvs/ip_vs_xmit.c
76684 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
76685 @@ -1151,7 +1151,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
76686 else
76687 rc = NF_ACCEPT;
76688 /* do not touch skb anymore */
76689 - atomic_inc(&cp->in_pkts);
76690 + atomic_inc_unchecked(&cp->in_pkts);
76691 goto out;
76692 }
76693
76694 @@ -1272,7 +1272,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
76695 else
76696 rc = NF_ACCEPT;
76697 /* do not touch skb anymore */
76698 - atomic_inc(&cp->in_pkts);
76699 + atomic_inc_unchecked(&cp->in_pkts);
76700 goto out;
76701 }
76702
76703 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
76704 index 66b2c54..c7884e3 100644
76705 --- a/net/netfilter/nfnetlink_log.c
76706 +++ b/net/netfilter/nfnetlink_log.c
76707 @@ -70,7 +70,7 @@ struct nfulnl_instance {
76708 };
76709
76710 static DEFINE_SPINLOCK(instances_lock);
76711 -static atomic_t global_seq;
76712 +static atomic_unchecked_t global_seq;
76713
76714 #define INSTANCE_BUCKETS 16
76715 static struct hlist_head instance_table[INSTANCE_BUCKETS];
76716 @@ -502,7 +502,7 @@ __build_packet_message(struct nfulnl_instance *inst,
76717 /* global sequence number */
76718 if (inst->flags & NFULNL_CFG_F_SEQ_GLOBAL)
76719 NLA_PUT_BE32(inst->skb, NFULA_SEQ_GLOBAL,
76720 - htonl(atomic_inc_return(&global_seq)));
76721 + htonl(atomic_inc_return_unchecked(&global_seq)));
76722
76723 if (data_len) {
76724 struct nlattr *nla;
76725 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
76726 new file mode 100644
76727 index 0000000..6905327
76728 --- /dev/null
76729 +++ b/net/netfilter/xt_gradm.c
76730 @@ -0,0 +1,51 @@
76731 +/*
76732 + * gradm match for netfilter
76733 + * Copyright © Zbigniew Krzystolik, 2010
76734 + *
76735 + * This program is free software; you can redistribute it and/or modify
76736 + * it under the terms of the GNU General Public License; either version
76737 + * 2 or 3 as published by the Free Software Foundation.
76738 + */
76739 +#include <linux/module.h>
76740 +#include <linux/moduleparam.h>
76741 +#include <linux/skbuff.h>
76742 +#include <linux/netfilter/x_tables.h>
76743 +#include <linux/grsecurity.h>
76744 +#include <linux/netfilter/xt_gradm.h>
76745 +
76746 +static bool
76747 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
76748 +{
76749 + const struct xt_gradm_mtinfo *info = par->matchinfo;
76750 + bool retval = false;
76751 + if (gr_acl_is_enabled())
76752 + retval = true;
76753 + return retval ^ info->invflags;
76754 +}
76755 +
76756 +static struct xt_match gradm_mt_reg __read_mostly = {
76757 + .name = "gradm",
76758 + .revision = 0,
76759 + .family = NFPROTO_UNSPEC,
76760 + .match = gradm_mt,
76761 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
76762 + .me = THIS_MODULE,
76763 +};
76764 +
76765 +static int __init gradm_mt_init(void)
76766 +{
76767 + return xt_register_match(&gradm_mt_reg);
76768 +}
76769 +
76770 +static void __exit gradm_mt_exit(void)
76771 +{
76772 + xt_unregister_match(&gradm_mt_reg);
76773 +}
76774 +
76775 +module_init(gradm_mt_init);
76776 +module_exit(gradm_mt_exit);
76777 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
76778 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
76779 +MODULE_LICENSE("GPL");
76780 +MODULE_ALIAS("ipt_gradm");
76781 +MODULE_ALIAS("ip6t_gradm");
76782 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
76783 index 4fe4fb4..87a89e5 100644
76784 --- a/net/netfilter/xt_statistic.c
76785 +++ b/net/netfilter/xt_statistic.c
76786 @@ -19,7 +19,7 @@
76787 #include <linux/module.h>
76788
76789 struct xt_statistic_priv {
76790 - atomic_t count;
76791 + atomic_unchecked_t count;
76792 } ____cacheline_aligned_in_smp;
76793
76794 MODULE_LICENSE("GPL");
76795 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
76796 break;
76797 case XT_STATISTIC_MODE_NTH:
76798 do {
76799 - oval = atomic_read(&info->master->count);
76800 + oval = atomic_read_unchecked(&info->master->count);
76801 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
76802 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
76803 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
76804 if (nval == 0)
76805 ret = !ret;
76806 break;
76807 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
76808 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
76809 if (info->master == NULL)
76810 return -ENOMEM;
76811 - atomic_set(&info->master->count, info->u.nth.count);
76812 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
76813
76814 return 0;
76815 }
76816 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
76817 index 467af9c..8f415cc 100644
76818 --- a/net/netlink/af_netlink.c
76819 +++ b/net/netlink/af_netlink.c
76820 @@ -741,7 +741,7 @@ static void netlink_overrun(struct sock *sk)
76821 sk->sk_error_report(sk);
76822 }
76823 }
76824 - atomic_inc(&sk->sk_drops);
76825 + atomic_inc_unchecked(&sk->sk_drops);
76826 }
76827
76828 static struct sock *netlink_getsockbypid(struct sock *ssk, u32 pid)
76829 @@ -1997,7 +1997,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
76830 sk_wmem_alloc_get(s),
76831 nlk->cb,
76832 atomic_read(&s->sk_refcnt),
76833 - atomic_read(&s->sk_drops),
76834 + atomic_read_unchecked(&s->sk_drops),
76835 sock_i_ino(s)
76836 );
76837
76838 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
76839 index 7dab229..212156f 100644
76840 --- a/net/netrom/af_netrom.c
76841 +++ b/net/netrom/af_netrom.c
76842 @@ -839,6 +839,7 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
76843 struct sock *sk = sock->sk;
76844 struct nr_sock *nr = nr_sk(sk);
76845
76846 + memset(sax, 0, sizeof(*sax));
76847 lock_sock(sk);
76848 if (peer != 0) {
76849 if (sk->sk_state != TCP_ESTABLISHED) {
76850 @@ -853,7 +854,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
76851 *uaddr_len = sizeof(struct full_sockaddr_ax25);
76852 } else {
76853 sax->fsa_ax25.sax25_family = AF_NETROM;
76854 - sax->fsa_ax25.sax25_ndigis = 0;
76855 sax->fsa_ax25.sax25_call = nr->source_addr;
76856 *uaddr_len = sizeof(struct sockaddr_ax25);
76857 }
76858 diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
76859 index 2c03050..5cf68c1 100644
76860 --- a/net/openvswitch/datapath.c
76861 +++ b/net/openvswitch/datapath.c
76862 @@ -322,7 +322,7 @@ static int queue_userspace_packet(int dp_ifindex, struct sk_buff *skb,
76863 return -ENOMEM;
76864
76865 nskb = __vlan_put_tag(nskb, vlan_tx_tag_get(nskb));
76866 - if (!skb)
76867 + if (!nskb)
76868 return -ENOMEM;
76869
76870 nskb->vlan_tci = 0;
76871 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
76872 index 2dbb32b..a1b4722 100644
76873 --- a/net/packet/af_packet.c
76874 +++ b/net/packet/af_packet.c
76875 @@ -1676,7 +1676,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
76876
76877 spin_lock(&sk->sk_receive_queue.lock);
76878 po->stats.tp_packets++;
76879 - skb->dropcount = atomic_read(&sk->sk_drops);
76880 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
76881 __skb_queue_tail(&sk->sk_receive_queue, skb);
76882 spin_unlock(&sk->sk_receive_queue.lock);
76883 sk->sk_data_ready(sk, skb->len);
76884 @@ -1685,7 +1685,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
76885 drop_n_acct:
76886 spin_lock(&sk->sk_receive_queue.lock);
76887 po->stats.tp_drops++;
76888 - atomic_inc(&sk->sk_drops);
76889 + atomic_inc_unchecked(&sk->sk_drops);
76890 spin_unlock(&sk->sk_receive_queue.lock);
76891
76892 drop_n_restore:
76893 @@ -3271,7 +3271,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
76894 case PACKET_HDRLEN:
76895 if (len > sizeof(int))
76896 len = sizeof(int);
76897 - if (copy_from_user(&val, optval, len))
76898 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
76899 return -EFAULT;
76900 switch (val) {
76901 case TPACKET_V1:
76902 @@ -3321,7 +3321,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
76903
76904 if (put_user(len, optlen))
76905 return -EFAULT;
76906 - if (copy_to_user(optval, data, len))
76907 + if (len > sizeof(st) || copy_to_user(optval, data, len))
76908 return -EFAULT;
76909 return 0;
76910 }
76911 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
76912 index d65f699..05aa6ce 100644
76913 --- a/net/phonet/af_phonet.c
76914 +++ b/net/phonet/af_phonet.c
76915 @@ -41,7 +41,7 @@ static struct phonet_protocol *phonet_proto_get(unsigned int protocol)
76916 {
76917 struct phonet_protocol *pp;
76918
76919 - if (protocol >= PHONET_NPROTO)
76920 + if (protocol < 0 || protocol >= PHONET_NPROTO)
76921 return NULL;
76922
76923 rcu_read_lock();
76924 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
76925 {
76926 int err = 0;
76927
76928 - if (protocol >= PHONET_NPROTO)
76929 + if (protocol < 0 || protocol >= PHONET_NPROTO)
76930 return -EINVAL;
76931
76932 err = proto_register(pp->prot, 1);
76933 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
76934 index 9726fe6..fc4e3a4 100644
76935 --- a/net/phonet/pep.c
76936 +++ b/net/phonet/pep.c
76937 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
76938
76939 case PNS_PEP_CTRL_REQ:
76940 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
76941 - atomic_inc(&sk->sk_drops);
76942 + atomic_inc_unchecked(&sk->sk_drops);
76943 break;
76944 }
76945 __skb_pull(skb, 4);
76946 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
76947 }
76948
76949 if (pn->rx_credits == 0) {
76950 - atomic_inc(&sk->sk_drops);
76951 + atomic_inc_unchecked(&sk->sk_drops);
76952 err = -ENOBUFS;
76953 break;
76954 }
76955 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
76956 }
76957
76958 if (pn->rx_credits == 0) {
76959 - atomic_inc(&sk->sk_drops);
76960 + atomic_inc_unchecked(&sk->sk_drops);
76961 err = NET_RX_DROP;
76962 break;
76963 }
76964 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
76965 index 4c7eff3..59c727f 100644
76966 --- a/net/phonet/socket.c
76967 +++ b/net/phonet/socket.c
76968 @@ -613,8 +613,13 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
76969 pn->resource, sk->sk_state,
76970 sk_wmem_alloc_get(sk), sk_rmem_alloc_get(sk),
76971 sock_i_uid(sk), sock_i_ino(sk),
76972 - atomic_read(&sk->sk_refcnt), sk,
76973 - atomic_read(&sk->sk_drops), &len);
76974 + atomic_read(&sk->sk_refcnt),
76975 +#ifdef CONFIG_GRKERNSEC_HIDESYM
76976 + NULL,
76977 +#else
76978 + sk,
76979 +#endif
76980 + atomic_read_unchecked(&sk->sk_drops), &len);
76981 }
76982 seq_printf(seq, "%*s\n", 127 - len, "");
76983 return 0;
76984 diff --git a/net/rds/cong.c b/net/rds/cong.c
76985 index e5b65ac..f3b6fb7 100644
76986 --- a/net/rds/cong.c
76987 +++ b/net/rds/cong.c
76988 @@ -78,7 +78,7 @@
76989 * finds that the saved generation number is smaller than the global generation
76990 * number, it wakes up the process.
76991 */
76992 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
76993 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
76994
76995 /*
76996 * Congestion monitoring
76997 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
76998 rdsdebug("waking map %p for %pI4\n",
76999 map, &map->m_addr);
77000 rds_stats_inc(s_cong_update_received);
77001 - atomic_inc(&rds_cong_generation);
77002 + atomic_inc_unchecked(&rds_cong_generation);
77003 if (waitqueue_active(&map->m_waitq))
77004 wake_up(&map->m_waitq);
77005 if (waitqueue_active(&rds_poll_waitq))
77006 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
77007
77008 int rds_cong_updated_since(unsigned long *recent)
77009 {
77010 - unsigned long gen = atomic_read(&rds_cong_generation);
77011 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
77012
77013 if (likely(*recent == gen))
77014 return 0;
77015 diff --git a/net/rds/ib.h b/net/rds/ib.h
77016 index edfaaaf..8c89879 100644
77017 --- a/net/rds/ib.h
77018 +++ b/net/rds/ib.h
77019 @@ -128,7 +128,7 @@ struct rds_ib_connection {
77020 /* sending acks */
77021 unsigned long i_ack_flags;
77022 #ifdef KERNEL_HAS_ATOMIC64
77023 - atomic64_t i_ack_next; /* next ACK to send */
77024 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
77025 #else
77026 spinlock_t i_ack_lock; /* protect i_ack_next */
77027 u64 i_ack_next; /* next ACK to send */
77028 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
77029 index 51c8689..36c555f 100644
77030 --- a/net/rds/ib_cm.c
77031 +++ b/net/rds/ib_cm.c
77032 @@ -718,7 +718,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
77033 /* Clear the ACK state */
77034 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
77035 #ifdef KERNEL_HAS_ATOMIC64
77036 - atomic64_set(&ic->i_ack_next, 0);
77037 + atomic64_set_unchecked(&ic->i_ack_next, 0);
77038 #else
77039 ic->i_ack_next = 0;
77040 #endif
77041 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
77042 index e29e0ca..fa3a6a3 100644
77043 --- a/net/rds/ib_recv.c
77044 +++ b/net/rds/ib_recv.c
77045 @@ -592,7 +592,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
77046 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
77047 int ack_required)
77048 {
77049 - atomic64_set(&ic->i_ack_next, seq);
77050 + atomic64_set_unchecked(&ic->i_ack_next, seq);
77051 if (ack_required) {
77052 smp_mb__before_clear_bit();
77053 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
77054 @@ -604,7 +604,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
77055 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
77056 smp_mb__after_clear_bit();
77057
77058 - return atomic64_read(&ic->i_ack_next);
77059 + return atomic64_read_unchecked(&ic->i_ack_next);
77060 }
77061 #endif
77062
77063 diff --git a/net/rds/iw.h b/net/rds/iw.h
77064 index 04ce3b1..48119a6 100644
77065 --- a/net/rds/iw.h
77066 +++ b/net/rds/iw.h
77067 @@ -134,7 +134,7 @@ struct rds_iw_connection {
77068 /* sending acks */
77069 unsigned long i_ack_flags;
77070 #ifdef KERNEL_HAS_ATOMIC64
77071 - atomic64_t i_ack_next; /* next ACK to send */
77072 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
77073 #else
77074 spinlock_t i_ack_lock; /* protect i_ack_next */
77075 u64 i_ack_next; /* next ACK to send */
77076 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
77077 index 9556d28..f046d0e 100644
77078 --- a/net/rds/iw_cm.c
77079 +++ b/net/rds/iw_cm.c
77080 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
77081 /* Clear the ACK state */
77082 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
77083 #ifdef KERNEL_HAS_ATOMIC64
77084 - atomic64_set(&ic->i_ack_next, 0);
77085 + atomic64_set_unchecked(&ic->i_ack_next, 0);
77086 #else
77087 ic->i_ack_next = 0;
77088 #endif
77089 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
77090 index 5e57347..3916042 100644
77091 --- a/net/rds/iw_recv.c
77092 +++ b/net/rds/iw_recv.c
77093 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
77094 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
77095 int ack_required)
77096 {
77097 - atomic64_set(&ic->i_ack_next, seq);
77098 + atomic64_set_unchecked(&ic->i_ack_next, seq);
77099 if (ack_required) {
77100 smp_mb__before_clear_bit();
77101 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
77102 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
77103 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
77104 smp_mb__after_clear_bit();
77105
77106 - return atomic64_read(&ic->i_ack_next);
77107 + return atomic64_read_unchecked(&ic->i_ack_next);
77108 }
77109 #endif
77110
77111 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
77112 index edac9ef..16bcb98 100644
77113 --- a/net/rds/tcp.c
77114 +++ b/net/rds/tcp.c
77115 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
77116 int val = 1;
77117
77118 set_fs(KERNEL_DS);
77119 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
77120 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
77121 sizeof(val));
77122 set_fs(oldfs);
77123 }
77124 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
77125 index 1b4fd68..2234175 100644
77126 --- a/net/rds/tcp_send.c
77127 +++ b/net/rds/tcp_send.c
77128 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
77129
77130 oldfs = get_fs();
77131 set_fs(KERNEL_DS);
77132 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
77133 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
77134 sizeof(val));
77135 set_fs(oldfs);
77136 }
77137 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
77138 index 74c064c..fdec26f 100644
77139 --- a/net/rxrpc/af_rxrpc.c
77140 +++ b/net/rxrpc/af_rxrpc.c
77141 @@ -39,7 +39,7 @@ static const struct proto_ops rxrpc_rpc_ops;
77142 __be32 rxrpc_epoch;
77143
77144 /* current debugging ID */
77145 -atomic_t rxrpc_debug_id;
77146 +atomic_unchecked_t rxrpc_debug_id;
77147
77148 /* count of skbs currently in use */
77149 atomic_t rxrpc_n_skbs;
77150 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
77151 index c3126e8..21facc7 100644
77152 --- a/net/rxrpc/ar-ack.c
77153 +++ b/net/rxrpc/ar-ack.c
77154 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
77155
77156 _enter("{%d,%d,%d,%d},",
77157 call->acks_hard, call->acks_unacked,
77158 - atomic_read(&call->sequence),
77159 + atomic_read_unchecked(&call->sequence),
77160 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
77161
77162 stop = 0;
77163 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
77164
77165 /* each Tx packet has a new serial number */
77166 sp->hdr.serial =
77167 - htonl(atomic_inc_return(&call->conn->serial));
77168 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
77169
77170 hdr = (struct rxrpc_header *) txb->head;
77171 hdr->serial = sp->hdr.serial;
77172 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
77173 */
77174 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
77175 {
77176 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
77177 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
77178 }
77179
77180 /*
77181 @@ -629,7 +629,7 @@ process_further:
77182
77183 latest = ntohl(sp->hdr.serial);
77184 hard = ntohl(ack.firstPacket);
77185 - tx = atomic_read(&call->sequence);
77186 + tx = atomic_read_unchecked(&call->sequence);
77187
77188 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
77189 latest,
77190 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
77191 goto maybe_reschedule;
77192
77193 send_ACK_with_skew:
77194 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
77195 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
77196 ntohl(ack.serial));
77197 send_ACK:
77198 mtu = call->conn->trans->peer->if_mtu;
77199 @@ -1173,7 +1173,7 @@ send_ACK:
77200 ackinfo.rxMTU = htonl(5692);
77201 ackinfo.jumbo_max = htonl(4);
77202
77203 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
77204 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
77205 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
77206 ntohl(hdr.serial),
77207 ntohs(ack.maxSkew),
77208 @@ -1191,7 +1191,7 @@ send_ACK:
77209 send_message:
77210 _debug("send message");
77211
77212 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
77213 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
77214 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
77215 send_message_2:
77216
77217 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
77218 index bf656c2..48f9d27 100644
77219 --- a/net/rxrpc/ar-call.c
77220 +++ b/net/rxrpc/ar-call.c
77221 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
77222 spin_lock_init(&call->lock);
77223 rwlock_init(&call->state_lock);
77224 atomic_set(&call->usage, 1);
77225 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
77226 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
77227 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
77228
77229 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
77230 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
77231 index 4106ca9..a338d7a 100644
77232 --- a/net/rxrpc/ar-connection.c
77233 +++ b/net/rxrpc/ar-connection.c
77234 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
77235 rwlock_init(&conn->lock);
77236 spin_lock_init(&conn->state_lock);
77237 atomic_set(&conn->usage, 1);
77238 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
77239 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
77240 conn->avail_calls = RXRPC_MAXCALLS;
77241 conn->size_align = 4;
77242 conn->header_size = sizeof(struct rxrpc_header);
77243 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
77244 index e7ed43a..6afa140 100644
77245 --- a/net/rxrpc/ar-connevent.c
77246 +++ b/net/rxrpc/ar-connevent.c
77247 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
77248
77249 len = iov[0].iov_len + iov[1].iov_len;
77250
77251 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
77252 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
77253 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
77254
77255 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
77256 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
77257 index 1a2b0633..e8d1382 100644
77258 --- a/net/rxrpc/ar-input.c
77259 +++ b/net/rxrpc/ar-input.c
77260 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
77261 /* track the latest serial number on this connection for ACK packet
77262 * information */
77263 serial = ntohl(sp->hdr.serial);
77264 - hi_serial = atomic_read(&call->conn->hi_serial);
77265 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
77266 while (serial > hi_serial)
77267 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
77268 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
77269 serial);
77270
77271 /* request ACK generation for any ACK or DATA packet that requests
77272 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
77273 index 8e22bd3..f66d1c0 100644
77274 --- a/net/rxrpc/ar-internal.h
77275 +++ b/net/rxrpc/ar-internal.h
77276 @@ -272,8 +272,8 @@ struct rxrpc_connection {
77277 int error; /* error code for local abort */
77278 int debug_id; /* debug ID for printks */
77279 unsigned call_counter; /* call ID counter */
77280 - atomic_t serial; /* packet serial number counter */
77281 - atomic_t hi_serial; /* highest serial number received */
77282 + atomic_unchecked_t serial; /* packet serial number counter */
77283 + atomic_unchecked_t hi_serial; /* highest serial number received */
77284 u8 avail_calls; /* number of calls available */
77285 u8 size_align; /* data size alignment (for security) */
77286 u8 header_size; /* rxrpc + security header size */
77287 @@ -346,7 +346,7 @@ struct rxrpc_call {
77288 spinlock_t lock;
77289 rwlock_t state_lock; /* lock for state transition */
77290 atomic_t usage;
77291 - atomic_t sequence; /* Tx data packet sequence counter */
77292 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
77293 u32 abort_code; /* local/remote abort code */
77294 enum { /* current state of call */
77295 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
77296 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
77297 */
77298 extern atomic_t rxrpc_n_skbs;
77299 extern __be32 rxrpc_epoch;
77300 -extern atomic_t rxrpc_debug_id;
77301 +extern atomic_unchecked_t rxrpc_debug_id;
77302 extern struct workqueue_struct *rxrpc_workqueue;
77303
77304 /*
77305 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
77306 index 87f7135..74d3703 100644
77307 --- a/net/rxrpc/ar-local.c
77308 +++ b/net/rxrpc/ar-local.c
77309 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
77310 spin_lock_init(&local->lock);
77311 rwlock_init(&local->services_lock);
77312 atomic_set(&local->usage, 1);
77313 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
77314 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
77315 memcpy(&local->srx, srx, sizeof(*srx));
77316 }
77317
77318 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
77319 index 16ae887..d24f12b 100644
77320 --- a/net/rxrpc/ar-output.c
77321 +++ b/net/rxrpc/ar-output.c
77322 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
77323 sp->hdr.cid = call->cid;
77324 sp->hdr.callNumber = call->call_id;
77325 sp->hdr.seq =
77326 - htonl(atomic_inc_return(&call->sequence));
77327 + htonl(atomic_inc_return_unchecked(&call->sequence));
77328 sp->hdr.serial =
77329 - htonl(atomic_inc_return(&conn->serial));
77330 + htonl(atomic_inc_return_unchecked(&conn->serial));
77331 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
77332 sp->hdr.userStatus = 0;
77333 sp->hdr.securityIndex = conn->security_ix;
77334 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
77335 index 2754f09..b20e38f 100644
77336 --- a/net/rxrpc/ar-peer.c
77337 +++ b/net/rxrpc/ar-peer.c
77338 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
77339 INIT_LIST_HEAD(&peer->error_targets);
77340 spin_lock_init(&peer->lock);
77341 atomic_set(&peer->usage, 1);
77342 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
77343 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
77344 memcpy(&peer->srx, srx, sizeof(*srx));
77345
77346 rxrpc_assess_MTU_size(peer);
77347 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
77348 index 38047f7..9f48511 100644
77349 --- a/net/rxrpc/ar-proc.c
77350 +++ b/net/rxrpc/ar-proc.c
77351 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
77352 atomic_read(&conn->usage),
77353 rxrpc_conn_states[conn->state],
77354 key_serial(conn->key),
77355 - atomic_read(&conn->serial),
77356 - atomic_read(&conn->hi_serial));
77357 + atomic_read_unchecked(&conn->serial),
77358 + atomic_read_unchecked(&conn->hi_serial));
77359
77360 return 0;
77361 }
77362 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
77363 index 92df566..87ec1bf 100644
77364 --- a/net/rxrpc/ar-transport.c
77365 +++ b/net/rxrpc/ar-transport.c
77366 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
77367 spin_lock_init(&trans->client_lock);
77368 rwlock_init(&trans->conn_lock);
77369 atomic_set(&trans->usage, 1);
77370 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
77371 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
77372
77373 if (peer->srx.transport.family == AF_INET) {
77374 switch (peer->srx.transport_type) {
77375 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
77376 index 7635107..4670276 100644
77377 --- a/net/rxrpc/rxkad.c
77378 +++ b/net/rxrpc/rxkad.c
77379 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
77380
77381 len = iov[0].iov_len + iov[1].iov_len;
77382
77383 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
77384 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
77385 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
77386
77387 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
77388 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
77389
77390 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
77391
77392 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
77393 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
77394 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
77395
77396 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
77397 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
77398 index 1e2eee8..ce3967e 100644
77399 --- a/net/sctp/proc.c
77400 +++ b/net/sctp/proc.c
77401 @@ -319,7 +319,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
77402 seq_printf(seq,
77403 "%8pK %8pK %-3d %-3d %-2d %-4d "
77404 "%4d %8d %8d %7d %5lu %-5d %5d ",
77405 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
77406 + assoc, sk,
77407 + sctp_sk(sk)->type, sk->sk_state,
77408 assoc->state, hash,
77409 assoc->assoc_id,
77410 assoc->sndbuf_used,
77411 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
77412 index d043722..6903416 100644
77413 --- a/net/sctp/socket.c
77414 +++ b/net/sctp/socket.c
77415 @@ -4575,7 +4575,7 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
77416 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
77417 if (space_left < addrlen)
77418 return -ENOMEM;
77419 - if (copy_to_user(to, &temp, addrlen))
77420 + if (addrlen > sizeof(temp) || copy_to_user(to, &temp, addrlen))
77421 return -EFAULT;
77422 to += addrlen;
77423 cnt++;
77424 diff --git a/net/socket.c b/net/socket.c
77425 index 0de4131..7e7ddab 100644
77426 --- a/net/socket.c
77427 +++ b/net/socket.c
77428 @@ -88,6 +88,7 @@
77429 #include <linux/nsproxy.h>
77430 #include <linux/magic.h>
77431 #include <linux/slab.h>
77432 +#include <linux/in.h>
77433
77434 #include <asm/uaccess.h>
77435 #include <asm/unistd.h>
77436 @@ -105,6 +106,8 @@
77437 #include <linux/sockios.h>
77438 #include <linux/atalk.h>
77439
77440 +#include <linux/grsock.h>
77441 +
77442 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
77443 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
77444 unsigned long nr_segs, loff_t pos);
77445 @@ -321,7 +324,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
77446 &sockfs_dentry_operations, SOCKFS_MAGIC);
77447 }
77448
77449 -static struct vfsmount *sock_mnt __read_mostly;
77450 +struct vfsmount *sock_mnt __read_mostly;
77451
77452 static struct file_system_type sock_fs_type = {
77453 .name = "sockfs",
77454 @@ -1207,6 +1210,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
77455 return -EAFNOSUPPORT;
77456 if (type < 0 || type >= SOCK_MAX)
77457 return -EINVAL;
77458 + if (protocol < 0)
77459 + return -EINVAL;
77460
77461 /* Compatibility.
77462
77463 @@ -1339,6 +1344,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
77464 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
77465 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
77466
77467 + if(!gr_search_socket(family, type, protocol)) {
77468 + retval = -EACCES;
77469 + goto out;
77470 + }
77471 +
77472 + if (gr_handle_sock_all(family, type, protocol)) {
77473 + retval = -EACCES;
77474 + goto out;
77475 + }
77476 +
77477 retval = sock_create(family, type, protocol, &sock);
77478 if (retval < 0)
77479 goto out;
77480 @@ -1451,6 +1466,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
77481 if (sock) {
77482 err = move_addr_to_kernel(umyaddr, addrlen, (struct sockaddr *)&address);
77483 if (err >= 0) {
77484 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
77485 + err = -EACCES;
77486 + goto error;
77487 + }
77488 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
77489 + if (err)
77490 + goto error;
77491 +
77492 err = security_socket_bind(sock,
77493 (struct sockaddr *)&address,
77494 addrlen);
77495 @@ -1459,6 +1482,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
77496 (struct sockaddr *)
77497 &address, addrlen);
77498 }
77499 +error:
77500 fput_light(sock->file, fput_needed);
77501 }
77502 return err;
77503 @@ -1482,10 +1506,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
77504 if ((unsigned)backlog > somaxconn)
77505 backlog = somaxconn;
77506
77507 + if (gr_handle_sock_server_other(sock->sk)) {
77508 + err = -EPERM;
77509 + goto error;
77510 + }
77511 +
77512 + err = gr_search_listen(sock);
77513 + if (err)
77514 + goto error;
77515 +
77516 err = security_socket_listen(sock, backlog);
77517 if (!err)
77518 err = sock->ops->listen(sock, backlog);
77519
77520 +error:
77521 fput_light(sock->file, fput_needed);
77522 }
77523 return err;
77524 @@ -1529,6 +1563,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
77525 newsock->type = sock->type;
77526 newsock->ops = sock->ops;
77527
77528 + if (gr_handle_sock_server_other(sock->sk)) {
77529 + err = -EPERM;
77530 + sock_release(newsock);
77531 + goto out_put;
77532 + }
77533 +
77534 + err = gr_search_accept(sock);
77535 + if (err) {
77536 + sock_release(newsock);
77537 + goto out_put;
77538 + }
77539 +
77540 /*
77541 * We don't need try_module_get here, as the listening socket (sock)
77542 * has the protocol module (sock->ops->owner) held.
77543 @@ -1567,6 +1613,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
77544 fd_install(newfd, newfile);
77545 err = newfd;
77546
77547 + gr_attach_curr_ip(newsock->sk);
77548 +
77549 out_put:
77550 fput_light(sock->file, fput_needed);
77551 out:
77552 @@ -1599,6 +1647,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
77553 int, addrlen)
77554 {
77555 struct socket *sock;
77556 + struct sockaddr *sck;
77557 struct sockaddr_storage address;
77558 int err, fput_needed;
77559
77560 @@ -1609,6 +1658,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
77561 if (err < 0)
77562 goto out_put;
77563
77564 + sck = (struct sockaddr *)&address;
77565 +
77566 + if (gr_handle_sock_client(sck)) {
77567 + err = -EACCES;
77568 + goto out_put;
77569 + }
77570 +
77571 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
77572 + if (err)
77573 + goto out_put;
77574 +
77575 err =
77576 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
77577 if (err)
77578 @@ -1970,7 +2030,7 @@ static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
77579 * checking falls down on this.
77580 */
77581 if (copy_from_user(ctl_buf,
77582 - (void __user __force *)msg_sys->msg_control,
77583 + (void __force_user *)msg_sys->msg_control,
77584 ctl_len))
77585 goto out_freectl;
77586 msg_sys->msg_control = ctl_buf;
77587 @@ -2140,7 +2200,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
77588 * kernel msghdr to use the kernel address space)
77589 */
77590
77591 - uaddr = (__force void __user *)msg_sys->msg_name;
77592 + uaddr = (void __force_user *)msg_sys->msg_name;
77593 uaddr_len = COMPAT_NAMELEN(msg);
77594 if (MSG_CMSG_COMPAT & flags) {
77595 err = verify_compat_iovec(msg_sys, iov,
77596 @@ -2768,7 +2828,7 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
77597 }
77598
77599 ifr = compat_alloc_user_space(buf_size);
77600 - rxnfc = (void *)ifr + ALIGN(sizeof(struct ifreq), 8);
77601 + rxnfc = (void __user *)ifr + ALIGN(sizeof(struct ifreq), 8);
77602
77603 if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
77604 return -EFAULT;
77605 @@ -2792,12 +2852,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
77606 offsetof(struct ethtool_rxnfc, fs.ring_cookie));
77607
77608 if (copy_in_user(rxnfc, compat_rxnfc,
77609 - (void *)(&rxnfc->fs.m_ext + 1) -
77610 - (void *)rxnfc) ||
77611 + (void __user *)(&rxnfc->fs.m_ext + 1) -
77612 + (void __user *)rxnfc) ||
77613 copy_in_user(&rxnfc->fs.ring_cookie,
77614 &compat_rxnfc->fs.ring_cookie,
77615 - (void *)(&rxnfc->fs.location + 1) -
77616 - (void *)&rxnfc->fs.ring_cookie) ||
77617 + (void __user *)(&rxnfc->fs.location + 1) -
77618 + (void __user *)&rxnfc->fs.ring_cookie) ||
77619 copy_in_user(&rxnfc->rule_cnt, &compat_rxnfc->rule_cnt,
77620 sizeof(rxnfc->rule_cnt)))
77621 return -EFAULT;
77622 @@ -2809,12 +2869,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
77623
77624 if (convert_out) {
77625 if (copy_in_user(compat_rxnfc, rxnfc,
77626 - (const void *)(&rxnfc->fs.m_ext + 1) -
77627 - (const void *)rxnfc) ||
77628 + (const void __user *)(&rxnfc->fs.m_ext + 1) -
77629 + (const void __user *)rxnfc) ||
77630 copy_in_user(&compat_rxnfc->fs.ring_cookie,
77631 &rxnfc->fs.ring_cookie,
77632 - (const void *)(&rxnfc->fs.location + 1) -
77633 - (const void *)&rxnfc->fs.ring_cookie) ||
77634 + (const void __user *)(&rxnfc->fs.location + 1) -
77635 + (const void __user *)&rxnfc->fs.ring_cookie) ||
77636 copy_in_user(&compat_rxnfc->rule_cnt, &rxnfc->rule_cnt,
77637 sizeof(rxnfc->rule_cnt)))
77638 return -EFAULT;
77639 @@ -2884,7 +2944,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
77640 old_fs = get_fs();
77641 set_fs(KERNEL_DS);
77642 err = dev_ioctl(net, cmd,
77643 - (struct ifreq __user __force *) &kifr);
77644 + (struct ifreq __force_user *) &kifr);
77645 set_fs(old_fs);
77646
77647 return err;
77648 @@ -2993,7 +3053,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
77649
77650 old_fs = get_fs();
77651 set_fs(KERNEL_DS);
77652 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
77653 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
77654 set_fs(old_fs);
77655
77656 if (cmd == SIOCGIFMAP && !err) {
77657 @@ -3098,7 +3158,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
77658 ret |= __get_user(rtdev, &(ur4->rt_dev));
77659 if (rtdev) {
77660 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
77661 - r4.rt_dev = (char __user __force *)devname;
77662 + r4.rt_dev = (char __force_user *)devname;
77663 devname[15] = 0;
77664 } else
77665 r4.rt_dev = NULL;
77666 @@ -3324,8 +3384,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
77667 int __user *uoptlen;
77668 int err;
77669
77670 - uoptval = (char __user __force *) optval;
77671 - uoptlen = (int __user __force *) optlen;
77672 + uoptval = (char __force_user *) optval;
77673 + uoptlen = (int __force_user *) optlen;
77674
77675 set_fs(KERNEL_DS);
77676 if (level == SOL_SOCKET)
77677 @@ -3345,7 +3405,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
77678 char __user *uoptval;
77679 int err;
77680
77681 - uoptval = (char __user __force *) optval;
77682 + uoptval = (char __force_user *) optval;
77683
77684 set_fs(KERNEL_DS);
77685 if (level == SOL_SOCKET)
77686 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
77687 index 8efd96c..b492ab2 100644
77688 --- a/net/sunrpc/sched.c
77689 +++ b/net/sunrpc/sched.c
77690 @@ -239,9 +239,9 @@ static int rpc_wait_bit_killable(void *word)
77691 #ifdef RPC_DEBUG
77692 static void rpc_task_set_debuginfo(struct rpc_task *task)
77693 {
77694 - static atomic_t rpc_pid;
77695 + static atomic_unchecked_t rpc_pid;
77696
77697 - task->tk_pid = atomic_inc_return(&rpc_pid);
77698 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
77699 }
77700 #else
77701 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
77702 diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
77703 index 4645709..d41d668 100644
77704 --- a/net/sunrpc/svcsock.c
77705 +++ b/net/sunrpc/svcsock.c
77706 @@ -396,7 +396,7 @@ static int svc_partial_recvfrom(struct svc_rqst *rqstp,
77707 int buflen, unsigned int base)
77708 {
77709 size_t save_iovlen;
77710 - void __user *save_iovbase;
77711 + void *save_iovbase;
77712 unsigned int i;
77713 int ret;
77714
77715 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
77716 index 09af4fa..77110a9 100644
77717 --- a/net/sunrpc/xprtrdma/svc_rdma.c
77718 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
77719 @@ -61,15 +61,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
77720 static unsigned int min_max_inline = 4096;
77721 static unsigned int max_max_inline = 65536;
77722
77723 -atomic_t rdma_stat_recv;
77724 -atomic_t rdma_stat_read;
77725 -atomic_t rdma_stat_write;
77726 -atomic_t rdma_stat_sq_starve;
77727 -atomic_t rdma_stat_rq_starve;
77728 -atomic_t rdma_stat_rq_poll;
77729 -atomic_t rdma_stat_rq_prod;
77730 -atomic_t rdma_stat_sq_poll;
77731 -atomic_t rdma_stat_sq_prod;
77732 +atomic_unchecked_t rdma_stat_recv;
77733 +atomic_unchecked_t rdma_stat_read;
77734 +atomic_unchecked_t rdma_stat_write;
77735 +atomic_unchecked_t rdma_stat_sq_starve;
77736 +atomic_unchecked_t rdma_stat_rq_starve;
77737 +atomic_unchecked_t rdma_stat_rq_poll;
77738 +atomic_unchecked_t rdma_stat_rq_prod;
77739 +atomic_unchecked_t rdma_stat_sq_poll;
77740 +atomic_unchecked_t rdma_stat_sq_prod;
77741
77742 /* Temporary NFS request map and context caches */
77743 struct kmem_cache *svc_rdma_map_cachep;
77744 @@ -109,7 +109,7 @@ static int read_reset_stat(ctl_table *table, int write,
77745 len -= *ppos;
77746 if (len > *lenp)
77747 len = *lenp;
77748 - if (len && copy_to_user(buffer, str_buf, len))
77749 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
77750 return -EFAULT;
77751 *lenp = len;
77752 *ppos += len;
77753 @@ -150,63 +150,63 @@ static ctl_table svcrdma_parm_table[] = {
77754 {
77755 .procname = "rdma_stat_read",
77756 .data = &rdma_stat_read,
77757 - .maxlen = sizeof(atomic_t),
77758 + .maxlen = sizeof(atomic_unchecked_t),
77759 .mode = 0644,
77760 .proc_handler = read_reset_stat,
77761 },
77762 {
77763 .procname = "rdma_stat_recv",
77764 .data = &rdma_stat_recv,
77765 - .maxlen = sizeof(atomic_t),
77766 + .maxlen = sizeof(atomic_unchecked_t),
77767 .mode = 0644,
77768 .proc_handler = read_reset_stat,
77769 },
77770 {
77771 .procname = "rdma_stat_write",
77772 .data = &rdma_stat_write,
77773 - .maxlen = sizeof(atomic_t),
77774 + .maxlen = sizeof(atomic_unchecked_t),
77775 .mode = 0644,
77776 .proc_handler = read_reset_stat,
77777 },
77778 {
77779 .procname = "rdma_stat_sq_starve",
77780 .data = &rdma_stat_sq_starve,
77781 - .maxlen = sizeof(atomic_t),
77782 + .maxlen = sizeof(atomic_unchecked_t),
77783 .mode = 0644,
77784 .proc_handler = read_reset_stat,
77785 },
77786 {
77787 .procname = "rdma_stat_rq_starve",
77788 .data = &rdma_stat_rq_starve,
77789 - .maxlen = sizeof(atomic_t),
77790 + .maxlen = sizeof(atomic_unchecked_t),
77791 .mode = 0644,
77792 .proc_handler = read_reset_stat,
77793 },
77794 {
77795 .procname = "rdma_stat_rq_poll",
77796 .data = &rdma_stat_rq_poll,
77797 - .maxlen = sizeof(atomic_t),
77798 + .maxlen = sizeof(atomic_unchecked_t),
77799 .mode = 0644,
77800 .proc_handler = read_reset_stat,
77801 },
77802 {
77803 .procname = "rdma_stat_rq_prod",
77804 .data = &rdma_stat_rq_prod,
77805 - .maxlen = sizeof(atomic_t),
77806 + .maxlen = sizeof(atomic_unchecked_t),
77807 .mode = 0644,
77808 .proc_handler = read_reset_stat,
77809 },
77810 {
77811 .procname = "rdma_stat_sq_poll",
77812 .data = &rdma_stat_sq_poll,
77813 - .maxlen = sizeof(atomic_t),
77814 + .maxlen = sizeof(atomic_unchecked_t),
77815 .mode = 0644,
77816 .proc_handler = read_reset_stat,
77817 },
77818 {
77819 .procname = "rdma_stat_sq_prod",
77820 .data = &rdma_stat_sq_prod,
77821 - .maxlen = sizeof(atomic_t),
77822 + .maxlen = sizeof(atomic_unchecked_t),
77823 .mode = 0644,
77824 .proc_handler = read_reset_stat,
77825 },
77826 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
77827 index df67211..c354b13 100644
77828 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
77829 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
77830 @@ -499,7 +499,7 @@ next_sge:
77831 svc_rdma_put_context(ctxt, 0);
77832 goto out;
77833 }
77834 - atomic_inc(&rdma_stat_read);
77835 + atomic_inc_unchecked(&rdma_stat_read);
77836
77837 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
77838 chl_map->ch[ch_no].count -= read_wr.num_sge;
77839 @@ -609,7 +609,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
77840 dto_q);
77841 list_del_init(&ctxt->dto_q);
77842 } else {
77843 - atomic_inc(&rdma_stat_rq_starve);
77844 + atomic_inc_unchecked(&rdma_stat_rq_starve);
77845 clear_bit(XPT_DATA, &xprt->xpt_flags);
77846 ctxt = NULL;
77847 }
77848 @@ -629,7 +629,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
77849 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
77850 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
77851 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
77852 - atomic_inc(&rdma_stat_recv);
77853 + atomic_inc_unchecked(&rdma_stat_recv);
77854
77855 /* Build up the XDR from the receive buffers. */
77856 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
77857 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
77858 index 249a835..fb2794b 100644
77859 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
77860 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
77861 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
77862 write_wr.wr.rdma.remote_addr = to;
77863
77864 /* Post It */
77865 - atomic_inc(&rdma_stat_write);
77866 + atomic_inc_unchecked(&rdma_stat_write);
77867 if (svc_rdma_send(xprt, &write_wr))
77868 goto err;
77869 return 0;
77870 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
77871 index 894cb42..cf5bafb 100644
77872 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
77873 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
77874 @@ -300,7 +300,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
77875 return;
77876
77877 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
77878 - atomic_inc(&rdma_stat_rq_poll);
77879 + atomic_inc_unchecked(&rdma_stat_rq_poll);
77880
77881 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
77882 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
77883 @@ -322,7 +322,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
77884 }
77885
77886 if (ctxt)
77887 - atomic_inc(&rdma_stat_rq_prod);
77888 + atomic_inc_unchecked(&rdma_stat_rq_prod);
77889
77890 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
77891 /*
77892 @@ -394,7 +394,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
77893 return;
77894
77895 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
77896 - atomic_inc(&rdma_stat_sq_poll);
77897 + atomic_inc_unchecked(&rdma_stat_sq_poll);
77898 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
77899 if (wc.status != IB_WC_SUCCESS)
77900 /* Close the transport */
77901 @@ -412,7 +412,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
77902 }
77903
77904 if (ctxt)
77905 - atomic_inc(&rdma_stat_sq_prod);
77906 + atomic_inc_unchecked(&rdma_stat_sq_prod);
77907 }
77908
77909 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
77910 @@ -1274,7 +1274,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
77911 spin_lock_bh(&xprt->sc_lock);
77912 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
77913 spin_unlock_bh(&xprt->sc_lock);
77914 - atomic_inc(&rdma_stat_sq_starve);
77915 + atomic_inc_unchecked(&rdma_stat_sq_starve);
77916
77917 /* See if we can opportunistically reap SQ WR to make room */
77918 sq_cq_reap(xprt);
77919 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
77920 index e758139..d29ea47 100644
77921 --- a/net/sysctl_net.c
77922 +++ b/net/sysctl_net.c
77923 @@ -47,7 +47,7 @@ static int net_ctl_permissions(struct ctl_table_root *root,
77924 struct ctl_table *table)
77925 {
77926 /* Allow network administrator to have same access as root. */
77927 - if (capable(CAP_NET_ADMIN)) {
77928 + if (capable_nolog(CAP_NET_ADMIN)) {
77929 int mode = (table->mode >> 6) & 7;
77930 return (mode << 6) | (mode << 3) | mode;
77931 }
77932 diff --git a/net/tipc/link.c b/net/tipc/link.c
77933 index ac1832a..533ed97 100644
77934 --- a/net/tipc/link.c
77935 +++ b/net/tipc/link.c
77936 @@ -1205,7 +1205,7 @@ static int link_send_sections_long(struct tipc_port *sender,
77937 struct tipc_msg fragm_hdr;
77938 struct sk_buff *buf, *buf_chain, *prev;
77939 u32 fragm_crs, fragm_rest, hsz, sect_rest;
77940 - const unchar *sect_crs;
77941 + const unchar __user *sect_crs;
77942 int curr_sect;
77943 u32 fragm_no;
77944
77945 @@ -1249,7 +1249,7 @@ again:
77946
77947 if (!sect_rest) {
77948 sect_rest = msg_sect[++curr_sect].iov_len;
77949 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
77950 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
77951 }
77952
77953 if (sect_rest < fragm_rest)
77954 @@ -1268,7 +1268,7 @@ error:
77955 }
77956 } else
77957 skb_copy_to_linear_data_offset(buf, fragm_crs,
77958 - sect_crs, sz);
77959 + (const void __force_kernel *)sect_crs, sz);
77960 sect_crs += sz;
77961 sect_rest -= sz;
77962 fragm_crs += sz;
77963 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
77964 index 3e4d3e2..27b55dc 100644
77965 --- a/net/tipc/msg.c
77966 +++ b/net/tipc/msg.c
77967 @@ -99,7 +99,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
77968 msg_sect[cnt].iov_len);
77969 else
77970 skb_copy_to_linear_data_offset(*buf, pos,
77971 - msg_sect[cnt].iov_base,
77972 + (const void __force_kernel *)msg_sect[cnt].iov_base,
77973 msg_sect[cnt].iov_len);
77974 pos += msg_sect[cnt].iov_len;
77975 }
77976 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
77977 index 8c49566..14510cb 100644
77978 --- a/net/tipc/subscr.c
77979 +++ b/net/tipc/subscr.c
77980 @@ -101,7 +101,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
77981 {
77982 struct iovec msg_sect;
77983
77984 - msg_sect.iov_base = (void *)&sub->evt;
77985 + msg_sect.iov_base = (void __force_user *)&sub->evt;
77986 msg_sect.iov_len = sizeof(struct tipc_event);
77987
77988 sub->evt.event = htohl(event, sub->swap);
77989 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
77990 index 85d3bb7..79f4487 100644
77991 --- a/net/unix/af_unix.c
77992 +++ b/net/unix/af_unix.c
77993 @@ -770,6 +770,12 @@ static struct sock *unix_find_other(struct net *net,
77994 err = -ECONNREFUSED;
77995 if (!S_ISSOCK(inode->i_mode))
77996 goto put_fail;
77997 +
77998 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
77999 + err = -EACCES;
78000 + goto put_fail;
78001 + }
78002 +
78003 u = unix_find_socket_byinode(inode);
78004 if (!u)
78005 goto put_fail;
78006 @@ -790,6 +796,13 @@ static struct sock *unix_find_other(struct net *net,
78007 if (u) {
78008 struct dentry *dentry;
78009 dentry = unix_sk(u)->dentry;
78010 +
78011 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
78012 + err = -EPERM;
78013 + sock_put(u);
78014 + goto fail;
78015 + }
78016 +
78017 if (dentry)
78018 touch_atime(unix_sk(u)->mnt, dentry);
78019 } else
78020 @@ -872,11 +885,18 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
78021 err = security_path_mknod(&path, dentry, mode, 0);
78022 if (err)
78023 goto out_mknod_drop_write;
78024 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
78025 + err = -EACCES;
78026 + goto out_mknod_drop_write;
78027 + }
78028 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
78029 out_mknod_drop_write:
78030 mnt_drop_write(path.mnt);
78031 if (err)
78032 goto out_mknod_dput;
78033 +
78034 + gr_handle_create(dentry, path.mnt);
78035 +
78036 mutex_unlock(&path.dentry->d_inode->i_mutex);
78037 dput(path.dentry);
78038 path.dentry = dentry;
78039 diff --git a/net/wireless/core.h b/net/wireless/core.h
78040 index 43ad9c8..ab5127c 100644
78041 --- a/net/wireless/core.h
78042 +++ b/net/wireless/core.h
78043 @@ -27,7 +27,7 @@ struct cfg80211_registered_device {
78044 struct mutex mtx;
78045
78046 /* rfkill support */
78047 - struct rfkill_ops rfkill_ops;
78048 + rfkill_ops_no_const rfkill_ops;
78049 struct rfkill *rfkill;
78050 struct work_struct rfkill_sync;
78051
78052 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
78053 index 0af7f54..c916d2f 100644
78054 --- a/net/wireless/wext-core.c
78055 +++ b/net/wireless/wext-core.c
78056 @@ -747,8 +747,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
78057 */
78058
78059 /* Support for very large requests */
78060 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
78061 - (user_length > descr->max_tokens)) {
78062 + if (user_length > descr->max_tokens) {
78063 /* Allow userspace to GET more than max so
78064 * we can support any size GET requests.
78065 * There is still a limit : -ENOMEM.
78066 @@ -785,22 +784,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
78067 }
78068 }
78069
78070 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
78071 - /*
78072 - * If this is a GET, but not NOMAX, it means that the extra
78073 - * data is not bounded by userspace, but by max_tokens. Thus
78074 - * set the length to max_tokens. This matches the extra data
78075 - * allocation.
78076 - * The driver should fill it with the number of tokens it
78077 - * provided, and it may check iwp->length rather than having
78078 - * knowledge of max_tokens. If the driver doesn't change the
78079 - * iwp->length, this ioctl just copies back max_token tokens
78080 - * filled with zeroes. Hopefully the driver isn't claiming
78081 - * them to be valid data.
78082 - */
78083 - iwp->length = descr->max_tokens;
78084 - }
78085 -
78086 err = handler(dev, info, (union iwreq_data *) iwp, extra);
78087
78088 iwp->length += essid_compat;
78089 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
78090 index 7661576..80f7627 100644
78091 --- a/net/xfrm/xfrm_policy.c
78092 +++ b/net/xfrm/xfrm_policy.c
78093 @@ -299,7 +299,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
78094 {
78095 policy->walk.dead = 1;
78096
78097 - atomic_inc(&policy->genid);
78098 + atomic_inc_unchecked(&policy->genid);
78099
78100 if (del_timer(&policy->timer))
78101 xfrm_pol_put(policy);
78102 @@ -583,7 +583,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
78103 hlist_add_head(&policy->bydst, chain);
78104 xfrm_pol_hold(policy);
78105 net->xfrm.policy_count[dir]++;
78106 - atomic_inc(&flow_cache_genid);
78107 + atomic_inc_unchecked(&flow_cache_genid);
78108 if (delpol)
78109 __xfrm_policy_unlink(delpol, dir);
78110 policy->index = delpol ? delpol->index : xfrm_gen_index(net, dir);
78111 @@ -1530,7 +1530,7 @@ free_dst:
78112 goto out;
78113 }
78114
78115 -static int inline
78116 +static inline int
78117 xfrm_dst_alloc_copy(void **target, const void *src, int size)
78118 {
78119 if (!*target) {
78120 @@ -1542,7 +1542,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
78121 return 0;
78122 }
78123
78124 -static int inline
78125 +static inline int
78126 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
78127 {
78128 #ifdef CONFIG_XFRM_SUB_POLICY
78129 @@ -1554,7 +1554,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
78130 #endif
78131 }
78132
78133 -static int inline
78134 +static inline int
78135 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
78136 {
78137 #ifdef CONFIG_XFRM_SUB_POLICY
78138 @@ -1648,7 +1648,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
78139
78140 xdst->num_pols = num_pols;
78141 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
78142 - xdst->policy_genid = atomic_read(&pols[0]->genid);
78143 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
78144
78145 return xdst;
78146 }
78147 @@ -2345,7 +2345,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
78148 if (xdst->xfrm_genid != dst->xfrm->genid)
78149 return 0;
78150 if (xdst->num_pols > 0 &&
78151 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
78152 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
78153 return 0;
78154
78155 mtu = dst_mtu(dst->child);
78156 @@ -2882,7 +2882,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
78157 sizeof(pol->xfrm_vec[i].saddr));
78158 pol->xfrm_vec[i].encap_family = mp->new_family;
78159 /* flush bundles */
78160 - atomic_inc(&pol->genid);
78161 + atomic_inc_unchecked(&pol->genid);
78162 }
78163 }
78164
78165 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
78166 index d2b366c..51ff91ebc 100644
78167 --- a/scripts/Makefile.build
78168 +++ b/scripts/Makefile.build
78169 @@ -109,7 +109,7 @@ endif
78170 endif
78171
78172 # Do not include host rules unless needed
78173 -ifneq ($(hostprogs-y)$(hostprogs-m),)
78174 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m),)
78175 include scripts/Makefile.host
78176 endif
78177
78178 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
78179 index 686cb0d..9d653bf 100644
78180 --- a/scripts/Makefile.clean
78181 +++ b/scripts/Makefile.clean
78182 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
78183 __clean-files := $(extra-y) $(always) \
78184 $(targets) $(clean-files) \
78185 $(host-progs) \
78186 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
78187 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
78188 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
78189
78190 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
78191
78192 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
78193 index 1ac414f..a1c1451 100644
78194 --- a/scripts/Makefile.host
78195 +++ b/scripts/Makefile.host
78196 @@ -31,6 +31,7 @@
78197 # Note: Shared libraries consisting of C++ files are not supported
78198
78199 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
78200 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
78201
78202 # C code
78203 # Executables compiled from a single .c file
78204 @@ -54,6 +55,7 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
78205 # Shared libaries (only .c supported)
78206 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
78207 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
78208 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
78209 # Remove .so files from "xxx-objs"
78210 host-cobjs := $(filter-out %.so,$(host-cobjs))
78211
78212 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
78213 index cb1f50c..cef2a7c 100644
78214 --- a/scripts/basic/fixdep.c
78215 +++ b/scripts/basic/fixdep.c
78216 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
78217 /*
78218 * Lookup a value in the configuration string.
78219 */
78220 -static int is_defined_config(const char *name, int len, unsigned int hash)
78221 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
78222 {
78223 struct item *aux;
78224
78225 @@ -211,10 +211,10 @@ static void clear_config(void)
78226 /*
78227 * Record the use of a CONFIG_* word.
78228 */
78229 -static void use_config(const char *m, int slen)
78230 +static void use_config(const char *m, unsigned int slen)
78231 {
78232 unsigned int hash = strhash(m, slen);
78233 - int c, i;
78234 + unsigned int c, i;
78235
78236 if (is_defined_config(m, slen, hash))
78237 return;
78238 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
78239
78240 static void parse_config_file(const char *map, size_t len)
78241 {
78242 - const int *end = (const int *) (map + len);
78243 + const unsigned int *end = (const unsigned int *) (map + len);
78244 /* start at +1, so that p can never be < map */
78245 - const int *m = (const int *) map + 1;
78246 + const unsigned int *m = (const unsigned int *) map + 1;
78247 const char *p, *q;
78248
78249 for (; m < end; m++) {
78250 @@ -406,7 +406,7 @@ static void print_deps(void)
78251 static void traps(void)
78252 {
78253 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
78254 - int *p = (int *)test;
78255 + unsigned int *p = (unsigned int *)test;
78256
78257 if (*p != INT_CONF) {
78258 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianess? %#x\n",
78259 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
78260 new file mode 100644
78261 index 0000000..8729101
78262 --- /dev/null
78263 +++ b/scripts/gcc-plugin.sh
78264 @@ -0,0 +1,2 @@
78265 +#!/bin/sh
78266 +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"
78267 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
78268 index e047e17..ea646ec 100644
78269 --- a/scripts/mod/file2alias.c
78270 +++ b/scripts/mod/file2alias.c
78271 @@ -128,7 +128,7 @@ static void device_id_check(const char *modname, const char *device_id,
78272 unsigned long size, unsigned long id_size,
78273 void *symval)
78274 {
78275 - int i;
78276 + unsigned int i;
78277
78278 if (size % id_size || size < id_size) {
78279 if (cross_build != 0)
78280 @@ -158,7 +158,7 @@ static void device_id_check(const char *modname, const char *device_id,
78281 /* USB is special because the bcdDevice can be matched against a numeric range */
78282 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipN" */
78283 static void do_usb_entry(struct usb_device_id *id,
78284 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
78285 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
78286 unsigned char range_lo, unsigned char range_hi,
78287 unsigned char max, struct module *mod)
78288 {
78289 @@ -259,7 +259,7 @@ static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod)
78290 {
78291 unsigned int devlo, devhi;
78292 unsigned char chi, clo, max;
78293 - int ndigits;
78294 + unsigned int ndigits;
78295
78296 id->match_flags = TO_NATIVE(id->match_flags);
78297 id->idVendor = TO_NATIVE(id->idVendor);
78298 @@ -501,7 +501,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
78299 for (i = 0; i < count; i++) {
78300 const char *id = (char *)devs[i].id;
78301 char acpi_id[sizeof(devs[0].id)];
78302 - int j;
78303 + unsigned int j;
78304
78305 buf_printf(&mod->dev_table_buf,
78306 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
78307 @@ -531,7 +531,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
78308
78309 for (j = 0; j < PNP_MAX_DEVICES; j++) {
78310 const char *id = (char *)card->devs[j].id;
78311 - int i2, j2;
78312 + unsigned int i2, j2;
78313 int dup = 0;
78314
78315 if (!id[0])
78316 @@ -557,7 +557,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
78317 /* add an individual alias for every device entry */
78318 if (!dup) {
78319 char acpi_id[sizeof(card->devs[0].id)];
78320 - int k;
78321 + unsigned int k;
78322
78323 buf_printf(&mod->dev_table_buf,
78324 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
78325 @@ -882,7 +882,7 @@ static void dmi_ascii_filter(char *d, const char *s)
78326 static int do_dmi_entry(const char *filename, struct dmi_system_id *id,
78327 char *alias)
78328 {
78329 - int i, j;
78330 + unsigned int i, j;
78331
78332 sprintf(alias, "dmi*");
78333
78334 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
78335 index c4e7d15..4241aef 100644
78336 --- a/scripts/mod/modpost.c
78337 +++ b/scripts/mod/modpost.c
78338 @@ -922,6 +922,7 @@ enum mismatch {
78339 ANY_INIT_TO_ANY_EXIT,
78340 ANY_EXIT_TO_ANY_INIT,
78341 EXPORT_TO_INIT_EXIT,
78342 + DATA_TO_TEXT
78343 };
78344
78345 struct sectioncheck {
78346 @@ -1030,6 +1031,12 @@ const struct sectioncheck sectioncheck[] = {
78347 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
78348 .mismatch = EXPORT_TO_INIT_EXIT,
78349 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
78350 +},
78351 +/* Do not reference code from writable data */
78352 +{
78353 + .fromsec = { DATA_SECTIONS, NULL },
78354 + .tosec = { TEXT_SECTIONS, NULL },
78355 + .mismatch = DATA_TO_TEXT
78356 }
78357 };
78358
78359 @@ -1152,10 +1159,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
78360 continue;
78361 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
78362 continue;
78363 - if (sym->st_value == addr)
78364 - return sym;
78365 /* Find a symbol nearby - addr are maybe negative */
78366 d = sym->st_value - addr;
78367 + if (d == 0)
78368 + return sym;
78369 if (d < 0)
78370 d = addr - sym->st_value;
78371 if (d < distance) {
78372 @@ -1434,6 +1441,14 @@ static void report_sec_mismatch(const char *modname,
78373 tosym, prl_to, prl_to, tosym);
78374 free(prl_to);
78375 break;
78376 + case DATA_TO_TEXT:
78377 +/*
78378 + fprintf(stderr,
78379 + "The variable %s references\n"
78380 + "the %s %s%s%s\n",
78381 + fromsym, to, sec2annotation(tosec), tosym, to_p);
78382 +*/
78383 + break;
78384 }
78385 fprintf(stderr, "\n");
78386 }
78387 @@ -1668,7 +1683,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
78388 static void check_sec_ref(struct module *mod, const char *modname,
78389 struct elf_info *elf)
78390 {
78391 - int i;
78392 + unsigned int i;
78393 Elf_Shdr *sechdrs = elf->sechdrs;
78394
78395 /* Walk through all sections */
78396 @@ -1766,7 +1781,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
78397 va_end(ap);
78398 }
78399
78400 -void buf_write(struct buffer *buf, const char *s, int len)
78401 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
78402 {
78403 if (buf->size - buf->pos < len) {
78404 buf->size += len + SZ;
78405 @@ -1984,7 +1999,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
78406 if (fstat(fileno(file), &st) < 0)
78407 goto close_write;
78408
78409 - if (st.st_size != b->pos)
78410 + if (st.st_size != (off_t)b->pos)
78411 goto close_write;
78412
78413 tmp = NOFAIL(malloc(b->pos));
78414 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
78415 index 51207e4..f7d603d 100644
78416 --- a/scripts/mod/modpost.h
78417 +++ b/scripts/mod/modpost.h
78418 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
78419
78420 struct buffer {
78421 char *p;
78422 - int pos;
78423 - int size;
78424 + unsigned int pos;
78425 + unsigned int size;
78426 };
78427
78428 void __attribute__((format(printf, 2, 3)))
78429 buf_printf(struct buffer *buf, const char *fmt, ...);
78430
78431 void
78432 -buf_write(struct buffer *buf, const char *s, int len);
78433 +buf_write(struct buffer *buf, const char *s, unsigned int len);
78434
78435 struct module {
78436 struct module *next;
78437 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
78438 index 9dfcd6d..099068e 100644
78439 --- a/scripts/mod/sumversion.c
78440 +++ b/scripts/mod/sumversion.c
78441 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
78442 goto out;
78443 }
78444
78445 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
78446 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
78447 warn("writing sum in %s failed: %s\n",
78448 filename, strerror(errno));
78449 goto out;
78450 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
78451 index 5c11312..72742b5 100644
78452 --- a/scripts/pnmtologo.c
78453 +++ b/scripts/pnmtologo.c
78454 @@ -237,14 +237,14 @@ static void write_header(void)
78455 fprintf(out, " * Linux logo %s\n", logoname);
78456 fputs(" */\n\n", out);
78457 fputs("#include <linux/linux_logo.h>\n\n", out);
78458 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
78459 + fprintf(out, "static unsigned char %s_data[] = {\n",
78460 logoname);
78461 }
78462
78463 static void write_footer(void)
78464 {
78465 fputs("\n};\n\n", out);
78466 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
78467 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
78468 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
78469 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
78470 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
78471 @@ -374,7 +374,7 @@ static void write_logo_clut224(void)
78472 fputs("\n};\n\n", out);
78473
78474 /* write logo clut */
78475 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
78476 + fprintf(out, "static unsigned char %s_clut[] = {\n",
78477 logoname);
78478 write_hex_cnt = 0;
78479 for (i = 0; i < logo_clutsize; i++) {
78480 diff --git a/scripts/tags.sh b/scripts/tags.sh
78481 index 833813a..0bc8588 100755
78482 --- a/scripts/tags.sh
78483 +++ b/scripts/tags.sh
78484 @@ -116,7 +116,7 @@ docscope()
78485
78486 dogtags()
78487 {
78488 - all_sources | gtags -f -
78489 + all_sources | gtags -i -f -
78490 }
78491
78492 exuberant()
78493 diff --git a/security/Kconfig b/security/Kconfig
78494 index 51bd5a0..c37f5e6 100644
78495 --- a/security/Kconfig
78496 +++ b/security/Kconfig
78497 @@ -4,6 +4,640 @@
78498
78499 menu "Security options"
78500
78501 +source grsecurity/Kconfig
78502 +
78503 +menu "PaX"
78504 +
78505 + config ARCH_TRACK_EXEC_LIMIT
78506 + bool
78507 +
78508 + config PAX_KERNEXEC_PLUGIN
78509 + bool
78510 +
78511 + config PAX_PER_CPU_PGD
78512 + bool
78513 +
78514 + config TASK_SIZE_MAX_SHIFT
78515 + int
78516 + depends on X86_64
78517 + default 47 if !PAX_PER_CPU_PGD
78518 + default 42 if PAX_PER_CPU_PGD
78519 +
78520 + config PAX_ENABLE_PAE
78521 + bool
78522 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
78523 +
78524 +config PAX
78525 + bool "Enable various PaX features"
78526 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
78527 + help
78528 + This allows you to enable various PaX features. PaX adds
78529 + intrusion prevention mechanisms to the kernel that reduce
78530 + the risks posed by exploitable memory corruption bugs.
78531 +
78532 +menu "PaX Control"
78533 + depends on PAX
78534 +
78535 +config PAX_SOFTMODE
78536 + bool 'Support soft mode'
78537 + help
78538 + Enabling this option will allow you to run PaX in soft mode, that
78539 + is, PaX features will not be enforced by default, only on executables
78540 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
78541 + support as they are the only way to mark executables for soft mode use.
78542 +
78543 + Soft mode can be activated by using the "pax_softmode=1" kernel command
78544 + line option on boot. Furthermore you can control various PaX features
78545 + at runtime via the entries in /proc/sys/kernel/pax.
78546 +
78547 +config PAX_EI_PAX
78548 + bool 'Use legacy ELF header marking'
78549 + help
78550 + Enabling this option will allow you to control PaX features on
78551 + a per executable basis via the 'chpax' utility available at
78552 + http://pax.grsecurity.net/. The control flags will be read from
78553 + an otherwise reserved part of the ELF header. This marking has
78554 + numerous drawbacks (no support for soft-mode, toolchain does not
78555 + know about the non-standard use of the ELF header) therefore it
78556 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
78557 + support.
78558 +
78559 + If you have applications not marked by the PT_PAX_FLAGS ELF program
78560 + header and you cannot use XATTR_PAX_FLAGS then you MUST enable this
78561 + option otherwise they will not get any protection.
78562 +
78563 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
78564 + support as well, they will override the legacy EI_PAX marks.
78565 +
78566 +config PAX_PT_PAX_FLAGS
78567 + bool 'Use ELF program header marking'
78568 + help
78569 + Enabling this option will allow you to control PaX features on
78570 + a per executable basis via the 'paxctl' utility available at
78571 + http://pax.grsecurity.net/. The control flags will be read from
78572 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
78573 + has the benefits of supporting both soft mode and being fully
78574 + integrated into the toolchain (the binutils patch is available
78575 + from http://pax.grsecurity.net).
78576 +
78577 + If you have applications not marked by the PT_PAX_FLAGS ELF program
78578 + header then you MUST enable either XATTR_PAX_FLAGS or EI_PAX marking
78579 + support otherwise they will not get any protection.
78580 +
78581 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
78582 + must make sure that the marks are the same if a binary has both marks.
78583 +
78584 + Note that if you enable the legacy EI_PAX marking support as well,
78585 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
78586 +
78587 +config PAX_XATTR_PAX_FLAGS
78588 + bool 'Use filesystem extended attributes marking'
78589 + select CIFS_XATTR if CIFS
78590 + select EXT2_FS_XATTR if EXT2_FS
78591 + select EXT3_FS_XATTR if EXT3_FS
78592 + select EXT4_FS_XATTR if EXT4_FS
78593 + select JFFS2_FS_XATTR if JFFS2_FS
78594 + select REISERFS_FS_XATTR if REISERFS_FS
78595 + select SQUASHFS_XATTR if SQUASHFS
78596 + select TMPFS_XATTR if TMPFS
78597 + select UBIFS_FS_XATTR if UBIFS_FS
78598 + help
78599 + Enabling this option will allow you to control PaX features on
78600 + a per executable basis via the 'setfattr' utility. The control
78601 + flags will be read from the user.pax.flags extended attribute of
78602 + the file. This marking has the benefit of supporting binary-only
78603 + applications that self-check themselves (e.g., skype) and would
78604 + not tolerate chpax/paxctl changes. The main drawback is that
78605 + extended attributes are not supported by some filesystems (e.g.,
78606 + isofs, udf, vfat) so copying files through such filesystems will
78607 + lose the extended attributes and these PaX markings.
78608 +
78609 + If you have applications not marked by the PT_PAX_FLAGS ELF program
78610 + header then you MUST enable either XATTR_PAX_FLAGS or EI_PAX marking
78611 + support otherwise they will not get any protection.
78612 +
78613 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
78614 + must make sure that the marks are the same if a binary has both marks.
78615 +
78616 + Note that if you enable the legacy EI_PAX marking support as well,
78617 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
78618 +
78619 +choice
78620 + prompt 'MAC system integration'
78621 + default PAX_HAVE_ACL_FLAGS
78622 + help
78623 + Mandatory Access Control systems have the option of controlling
78624 + PaX flags on a per executable basis, choose the method supported
78625 + by your particular system.
78626 +
78627 + - "none": if your MAC system does not interact with PaX,
78628 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
78629 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
78630 +
78631 + NOTE: this option is for developers/integrators only.
78632 +
78633 + config PAX_NO_ACL_FLAGS
78634 + bool 'none'
78635 +
78636 + config PAX_HAVE_ACL_FLAGS
78637 + bool 'direct'
78638 +
78639 + config PAX_HOOK_ACL_FLAGS
78640 + bool 'hook'
78641 +endchoice
78642 +
78643 +endmenu
78644 +
78645 +menu "Non-executable pages"
78646 + depends on PAX
78647 +
78648 +config PAX_NOEXEC
78649 + bool "Enforce non-executable pages"
78650 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
78651 + help
78652 + By design some architectures do not allow for protecting memory
78653 + pages against execution or even if they do, Linux does not make
78654 + use of this feature. In practice this means that if a page is
78655 + readable (such as the stack or heap) it is also executable.
78656 +
78657 + There is a well known exploit technique that makes use of this
78658 + fact and a common programming mistake where an attacker can
78659 + introduce code of his choice somewhere in the attacked program's
78660 + memory (typically the stack or the heap) and then execute it.
78661 +
78662 + If the attacked program was running with different (typically
78663 + higher) privileges than that of the attacker, then he can elevate
78664 + his own privilege level (e.g. get a root shell, write to files for
78665 + which he does not have write access to, etc).
78666 +
78667 + Enabling this option will let you choose from various features
78668 + that prevent the injection and execution of 'foreign' code in
78669 + a program.
78670 +
78671 + This will also break programs that rely on the old behaviour and
78672 + expect that dynamically allocated memory via the malloc() family
78673 + of functions is executable (which it is not). Notable examples
78674 + are the XFree86 4.x server, the java runtime and wine.
78675 +
78676 +config PAX_PAGEEXEC
78677 + bool "Paging based non-executable pages"
78678 + 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)
78679 + select S390_SWITCH_AMODE if S390
78680 + select S390_EXEC_PROTECT if S390
78681 + select ARCH_TRACK_EXEC_LIMIT if X86_32
78682 + help
78683 + This implementation is based on the paging feature of the CPU.
78684 + On i386 without hardware non-executable bit support there is a
78685 + variable but usually low performance impact, however on Intel's
78686 + P4 core based CPUs it is very high so you should not enable this
78687 + for kernels meant to be used on such CPUs.
78688 +
78689 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
78690 + with hardware non-executable bit support there is no performance
78691 + impact, on ppc the impact is negligible.
78692 +
78693 + Note that several architectures require various emulations due to
78694 + badly designed userland ABIs, this will cause a performance impact
78695 + but will disappear as soon as userland is fixed. For example, ppc
78696 + userland MUST have been built with secure-plt by a recent toolchain.
78697 +
78698 +config PAX_SEGMEXEC
78699 + bool "Segmentation based non-executable pages"
78700 + depends on PAX_NOEXEC && X86_32
78701 + help
78702 + This implementation is based on the segmentation feature of the
78703 + CPU and has a very small performance impact, however applications
78704 + will be limited to a 1.5 GB address space instead of the normal
78705 + 3 GB.
78706 +
78707 +config PAX_EMUTRAMP
78708 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
78709 + default y if PARISC
78710 + help
78711 + There are some programs and libraries that for one reason or
78712 + another attempt to execute special small code snippets from
78713 + non-executable memory pages. Most notable examples are the
78714 + signal handler return code generated by the kernel itself and
78715 + the GCC trampolines.
78716 +
78717 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
78718 + such programs will no longer work under your kernel.
78719 +
78720 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
78721 + utilities to enable trampoline emulation for the affected programs
78722 + yet still have the protection provided by the non-executable pages.
78723 +
78724 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
78725 + your system will not even boot.
78726 +
78727 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
78728 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
78729 + for the affected files.
78730 +
78731 + NOTE: enabling this feature *may* open up a loophole in the
78732 + protection provided by non-executable pages that an attacker
78733 + could abuse. Therefore the best solution is to not have any
78734 + files on your system that would require this option. This can
78735 + be achieved by not using libc5 (which relies on the kernel
78736 + signal handler return code) and not using or rewriting programs
78737 + that make use of the nested function implementation of GCC.
78738 + Skilled users can just fix GCC itself so that it implements
78739 + nested function calls in a way that does not interfere with PaX.
78740 +
78741 +config PAX_EMUSIGRT
78742 + bool "Automatically emulate sigreturn trampolines"
78743 + depends on PAX_EMUTRAMP && PARISC
78744 + default y
78745 + help
78746 + Enabling this option will have the kernel automatically detect
78747 + and emulate signal return trampolines executing on the stack
78748 + that would otherwise lead to task termination.
78749 +
78750 + This solution is intended as a temporary one for users with
78751 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
78752 + Modula-3 runtime, etc) or executables linked to such, basically
78753 + everything that does not specify its own SA_RESTORER function in
78754 + normal executable memory like glibc 2.1+ does.
78755 +
78756 + On parisc you MUST enable this option, otherwise your system will
78757 + not even boot.
78758 +
78759 + NOTE: this feature cannot be disabled on a per executable basis
78760 + and since it *does* open up a loophole in the protection provided
78761 + by non-executable pages, the best solution is to not have any
78762 + files on your system that would require this option.
78763 +
78764 +config PAX_MPROTECT
78765 + bool "Restrict mprotect()"
78766 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
78767 + help
78768 + Enabling this option will prevent programs from
78769 + - changing the executable status of memory pages that were
78770 + not originally created as executable,
78771 + - making read-only executable pages writable again,
78772 + - creating executable pages from anonymous memory,
78773 + - making read-only-after-relocations (RELRO) data pages writable again.
78774 +
78775 + You should say Y here to complete the protection provided by
78776 + the enforcement of non-executable pages.
78777 +
78778 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
78779 + this feature on a per file basis.
78780 +
78781 +config PAX_MPROTECT_COMPAT
78782 + bool "Use legacy/compat protection demoting (read help)"
78783 + depends on PAX_MPROTECT
78784 + default n
78785 + help
78786 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
78787 + by sending the proper error code to the application. For some broken
78788 + userland, this can cause problems with Python or other applications. The
78789 + current implementation however allows for applications like clamav to
78790 + detect if JIT compilation/execution is allowed and to fall back gracefully
78791 + to an interpreter-based mode if it does not. While we encourage everyone
78792 + to use the current implementation as-is and push upstream to fix broken
78793 + userland (note that the RWX logging option can assist with this), in some
78794 + environments this may not be possible. Having to disable MPROTECT
78795 + completely on certain binaries reduces the security benefit of PaX,
78796 + so this option is provided for those environments to revert to the old
78797 + behavior.
78798 +
78799 +config PAX_ELFRELOCS
78800 + bool "Allow ELF text relocations (read help)"
78801 + depends on PAX_MPROTECT
78802 + default n
78803 + help
78804 + Non-executable pages and mprotect() restrictions are effective
78805 + in preventing the introduction of new executable code into an
78806 + attacked task's address space. There remain only two venues
78807 + for this kind of attack: if the attacker can execute already
78808 + existing code in the attacked task then he can either have it
78809 + create and mmap() a file containing his code or have it mmap()
78810 + an already existing ELF library that does not have position
78811 + independent code in it and use mprotect() on it to make it
78812 + writable and copy his code there. While protecting against
78813 + the former approach is beyond PaX, the latter can be prevented
78814 + by having only PIC ELF libraries on one's system (which do not
78815 + need to relocate their code). If you are sure this is your case,
78816 + as is the case with all modern Linux distributions, then leave
78817 + this option disabled. You should say 'n' here.
78818 +
78819 +config PAX_ETEXECRELOCS
78820 + bool "Allow ELF ET_EXEC text relocations"
78821 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
78822 + select PAX_ELFRELOCS
78823 + default y
78824 + help
78825 + On some architectures there are incorrectly created applications
78826 + that require text relocations and would not work without enabling
78827 + this option. If you are an alpha, ia64 or parisc user, you should
78828 + enable this option and disable it once you have made sure that
78829 + none of your applications need it.
78830 +
78831 +config PAX_EMUPLT
78832 + bool "Automatically emulate ELF PLT"
78833 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
78834 + default y
78835 + help
78836 + Enabling this option will have the kernel automatically detect
78837 + and emulate the Procedure Linkage Table entries in ELF files.
78838 + On some architectures such entries are in writable memory, and
78839 + become non-executable leading to task termination. Therefore
78840 + it is mandatory that you enable this option on alpha, parisc,
78841 + sparc and sparc64, otherwise your system would not even boot.
78842 +
78843 + NOTE: this feature *does* open up a loophole in the protection
78844 + provided by the non-executable pages, therefore the proper
78845 + solution is to modify the toolchain to produce a PLT that does
78846 + not need to be writable.
78847 +
78848 +config PAX_DLRESOLVE
78849 + bool 'Emulate old glibc resolver stub'
78850 + depends on PAX_EMUPLT && SPARC
78851 + default n
78852 + help
78853 + This option is needed if userland has an old glibc (before 2.4)
78854 + that puts a 'save' instruction into the runtime generated resolver
78855 + stub that needs special emulation.
78856 +
78857 +config PAX_KERNEXEC
78858 + bool "Enforce non-executable kernel pages"
78859 + depends on (PPC || X86) && (!X86_32 || X86_WP_WORKS_OK) && !XEN
78860 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
78861 + select PAX_KERNEXEC_PLUGIN if X86_64
78862 + help
78863 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
78864 + that is, enabling this option will make it harder to inject
78865 + and execute 'foreign' code in kernel memory itself.
78866 +
78867 + Note that on x86_64 kernels there is a known regression when
78868 + this feature and KVM/VMX are both enabled in the host kernel.
78869 +
78870 +choice
78871 + prompt "Return Address Instrumentation Method"
78872 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
78873 + depends on PAX_KERNEXEC_PLUGIN
78874 + help
78875 + Select the method used to instrument function pointer dereferences.
78876 + Note that binary modules cannot be instrumented by this approach.
78877 +
78878 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
78879 + bool "bts"
78880 + help
78881 + This method is compatible with binary only modules but has
78882 + a higher runtime overhead.
78883 +
78884 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
78885 + bool "or"
78886 + depends on !PARAVIRT
78887 + help
78888 + This method is incompatible with binary only modules but has
78889 + a lower runtime overhead.
78890 +endchoice
78891 +
78892 +config PAX_KERNEXEC_PLUGIN_METHOD
78893 + string
78894 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
78895 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
78896 + default ""
78897 +
78898 +config PAX_KERNEXEC_MODULE_TEXT
78899 + int "Minimum amount of memory reserved for module code"
78900 + default "4"
78901 + depends on PAX_KERNEXEC && X86_32 && MODULES
78902 + help
78903 + Due to implementation details the kernel must reserve a fixed
78904 + amount of memory for module code at compile time that cannot be
78905 + changed at runtime. Here you can specify the minimum amount
78906 + in MB that will be reserved. Due to the same implementation
78907 + details this size will always be rounded up to the next 2/4 MB
78908 + boundary (depends on PAE) so the actually available memory for
78909 + module code will usually be more than this minimum.
78910 +
78911 + The default 4 MB should be enough for most users but if you have
78912 + an excessive number of modules (e.g., most distribution configs
78913 + compile many drivers as modules) or use huge modules such as
78914 + nvidia's kernel driver, you will need to adjust this amount.
78915 + A good rule of thumb is to look at your currently loaded kernel
78916 + modules and add up their sizes.
78917 +
78918 +endmenu
78919 +
78920 +menu "Address Space Layout Randomization"
78921 + depends on PAX
78922 +
78923 +config PAX_ASLR
78924 + bool "Address Space Layout Randomization"
78925 + help
78926 + Many if not most exploit techniques rely on the knowledge of
78927 + certain addresses in the attacked program. The following options
78928 + will allow the kernel to apply a certain amount of randomization
78929 + to specific parts of the program thereby forcing an attacker to
78930 + guess them in most cases. Any failed guess will most likely crash
78931 + the attacked program which allows the kernel to detect such attempts
78932 + and react on them. PaX itself provides no reaction mechanisms,
78933 + instead it is strongly encouraged that you make use of Nergal's
78934 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
78935 + (http://www.grsecurity.net/) built-in crash detection features or
78936 + develop one yourself.
78937 +
78938 + By saying Y here you can choose to randomize the following areas:
78939 + - top of the task's kernel stack
78940 + - top of the task's userland stack
78941 + - base address for mmap() requests that do not specify one
78942 + (this includes all libraries)
78943 + - base address of the main executable
78944 +
78945 + It is strongly recommended to say Y here as address space layout
78946 + randomization has negligible impact on performance yet it provides
78947 + a very effective protection.
78948 +
78949 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
78950 + this feature on a per file basis.
78951 +
78952 +config PAX_RANDKSTACK
78953 + bool "Randomize kernel stack base"
78954 + depends on X86_TSC && X86
78955 + help
78956 + By saying Y here the kernel will randomize every task's kernel
78957 + stack on every system call. This will not only force an attacker
78958 + to guess it but also prevent him from making use of possible
78959 + leaked information about it.
78960 +
78961 + Since the kernel stack is a rather scarce resource, randomization
78962 + may cause unexpected stack overflows, therefore you should very
78963 + carefully test your system. Note that once enabled in the kernel
78964 + configuration, this feature cannot be disabled on a per file basis.
78965 +
78966 +config PAX_RANDUSTACK
78967 + bool "Randomize user stack base"
78968 + depends on PAX_ASLR
78969 + help
78970 + By saying Y here the kernel will randomize every task's userland
78971 + stack. The randomization is done in two steps where the second
78972 + one may apply a big amount of shift to the top of the stack and
78973 + cause problems for programs that want to use lots of memory (more
78974 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
78975 + For this reason the second step can be controlled by 'chpax' or
78976 + 'paxctl' on a per file basis.
78977 +
78978 +config PAX_RANDMMAP
78979 + bool "Randomize mmap() base"
78980 + depends on PAX_ASLR
78981 + help
78982 + By saying Y here the kernel will use a randomized base address for
78983 + mmap() requests that do not specify one themselves. As a result
78984 + all dynamically loaded libraries will appear at random addresses
78985 + and therefore be harder to exploit by a technique where an attacker
78986 + attempts to execute library code for his purposes (e.g. spawn a
78987 + shell from an exploited program that is running at an elevated
78988 + privilege level).
78989 +
78990 + Furthermore, if a program is relinked as a dynamic ELF file, its
78991 + base address will be randomized as well, completing the full
78992 + randomization of the address space layout. Attacking such programs
78993 + becomes a guess game. You can find an example of doing this at
78994 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
78995 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
78996 +
78997 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
78998 + feature on a per file basis.
78999 +
79000 +endmenu
79001 +
79002 +menu "Miscellaneous hardening features"
79003 +
79004 +config PAX_MEMORY_SANITIZE
79005 + bool "Sanitize all freed memory"
79006 + depends on !HIBERNATION
79007 + help
79008 + By saying Y here the kernel will erase memory pages as soon as they
79009 + are freed. This in turn reduces the lifetime of data stored in the
79010 + pages, making it less likely that sensitive information such as
79011 + passwords, cryptographic secrets, etc stay in memory for too long.
79012 +
79013 + This is especially useful for programs whose runtime is short, long
79014 + lived processes and the kernel itself benefit from this as long as
79015 + they operate on whole memory pages and ensure timely freeing of pages
79016 + that may hold sensitive information.
79017 +
79018 + The tradeoff is performance impact, on a single CPU system kernel
79019 + compilation sees a 3% slowdown, other systems and workloads may vary
79020 + and you are advised to test this feature on your expected workload
79021 + before deploying it.
79022 +
79023 + Note that this feature does not protect data stored in live pages,
79024 + e.g., process memory swapped to disk may stay there for a long time.
79025 +
79026 +config PAX_MEMORY_STACKLEAK
79027 + bool "Sanitize kernel stack"
79028 + depends on X86
79029 + help
79030 + By saying Y here the kernel will erase the kernel stack before it
79031 + returns from a system call. This in turn reduces the information
79032 + that a kernel stack leak bug can reveal.
79033 +
79034 + Note that such a bug can still leak information that was put on
79035 + the stack by the current system call (the one eventually triggering
79036 + the bug) but traces of earlier system calls on the kernel stack
79037 + cannot leak anymore.
79038 +
79039 + The tradeoff is performance impact: on a single CPU system kernel
79040 + compilation sees a 1% slowdown, other systems and workloads may vary
79041 + and you are advised to test this feature on your expected workload
79042 + before deploying it.
79043 +
79044 + Note: full support for this feature requires gcc with plugin support
79045 + so make sure your compiler is at least gcc 4.5.0. Using older gcc
79046 + versions means that functions with large enough stack frames may
79047 + leave uninitialized memory behind that may be exposed to a later
79048 + syscall leaking the stack.
79049 +
79050 +config PAX_MEMORY_UDEREF
79051 + bool "Prevent invalid userland pointer dereference"
79052 + depends on X86 && !UML_X86 && !XEN
79053 + select PAX_PER_CPU_PGD if X86_64
79054 + help
79055 + By saying Y here the kernel will be prevented from dereferencing
79056 + userland pointers in contexts where the kernel expects only kernel
79057 + pointers. This is both a useful runtime debugging feature and a
79058 + security measure that prevents exploiting a class of kernel bugs.
79059 +
79060 + The tradeoff is that some virtualization solutions may experience
79061 + a huge slowdown and therefore you should not enable this feature
79062 + for kernels meant to run in such environments. Whether a given VM
79063 + solution is affected or not is best determined by simply trying it
79064 + out, the performance impact will be obvious right on boot as this
79065 + mechanism engages from very early on. A good rule of thumb is that
79066 + VMs running on CPUs without hardware virtualization support (i.e.,
79067 + the majority of IA-32 CPUs) will likely experience the slowdown.
79068 +
79069 +config PAX_REFCOUNT
79070 + bool "Prevent various kernel object reference counter overflows"
79071 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
79072 + help
79073 + By saying Y here the kernel will detect and prevent overflowing
79074 + various (but not all) kinds of object reference counters. Such
79075 + overflows can normally occur due to bugs only and are often, if
79076 + not always, exploitable.
79077 +
79078 + The tradeoff is that data structures protected by an overflowed
79079 + refcount will never be freed and therefore will leak memory. Note
79080 + that this leak also happens even without this protection but in
79081 + that case the overflow can eventually trigger the freeing of the
79082 + data structure while it is still being used elsewhere, resulting
79083 + in the exploitable situation that this feature prevents.
79084 +
79085 + Since this has a negligible performance impact, you should enable
79086 + this feature.
79087 +
79088 +config PAX_USERCOPY
79089 + bool "Harden heap object copies between kernel and userland"
79090 + depends on X86 || PPC || SPARC || ARM
79091 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
79092 + help
79093 + By saying Y here the kernel will enforce the size of heap objects
79094 + when they are copied in either direction between the kernel and
79095 + userland, even if only a part of the heap object is copied.
79096 +
79097 + Specifically, this checking prevents information leaking from the
79098 + kernel heap during kernel to userland copies (if the kernel heap
79099 + object is otherwise fully initialized) and prevents kernel heap
79100 + overflows during userland to kernel copies.
79101 +
79102 + Note that the current implementation provides the strictest bounds
79103 + checks for the SLUB allocator.
79104 +
79105 + Enabling this option also enables per-slab cache protection against
79106 + data in a given cache being copied into/out of via userland
79107 + accessors. Though the whitelist of regions will be reduced over
79108 + time, it notably protects important data structures like task structs.
79109 +
79110 + If frame pointers are enabled on x86, this option will also restrict
79111 + copies into and out of the kernel stack to local variables within a
79112 + single frame.
79113 +
79114 + Since this has a negligible performance impact, you should enable
79115 + this feature.
79116 +
79117 +config PAX_SIZE_OVERFLOW
79118 + bool "Prevent various integer overflows in function size parameters"
79119 + depends on X86
79120 + help
79121 + By saying Y here the kernel recomputes expressions of function
79122 + arguments marked by a size_overflow attribute with double integer
79123 + precision (DImode/TImode for 32/64 bit integer types).
79124 +
79125 + The recomputed argument is checked against INT_MAX and an event
79126 + is logged on overflow and the triggering process is killed.
79127 +
79128 + Homepage:
79129 + http://www.grsecurity.net/~ephox/overflow_plugin/
79130 +
79131 +endmenu
79132 +
79133 +endmenu
79134 +
79135 config KEYS
79136 bool "Enable access key retention support"
79137 help
79138 @@ -169,7 +803,7 @@ config INTEL_TXT
79139 config LSM_MMAP_MIN_ADDR
79140 int "Low address space for LSM to protect from user allocation"
79141 depends on SECURITY && SECURITY_SELINUX
79142 - default 32768 if ARM
79143 + default 32768 if ALPHA || ARM || PARISC || SPARC32
79144 default 65536
79145 help
79146 This is the portion of low virtual memory which should be protected
79147 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
79148 index 97ce8fa..23dad96 100644
79149 --- a/security/apparmor/lsm.c
79150 +++ b/security/apparmor/lsm.c
79151 @@ -620,7 +620,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
79152 return error;
79153 }
79154
79155 -static struct security_operations apparmor_ops = {
79156 +static struct security_operations apparmor_ops __read_only = {
79157 .name = "apparmor",
79158
79159 .ptrace_access_check = apparmor_ptrace_access_check,
79160 diff --git a/security/commoncap.c b/security/commoncap.c
79161 index b8d2bb9..980069e 100644
79162 --- a/security/commoncap.c
79163 +++ b/security/commoncap.c
79164 @@ -29,6 +29,7 @@
79165 #include <linux/securebits.h>
79166 #include <linux/user_namespace.h>
79167 #include <linux/personality.h>
79168 +#include <net/sock.h>
79169
79170 /*
79171 * If a non-root user executes a setuid-root binary in
79172 @@ -575,6 +576,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
79173 {
79174 const struct cred *cred = current_cred();
79175
79176 + if (gr_acl_enable_at_secure())
79177 + return 1;
79178 +
79179 if (cred->uid != 0) {
79180 if (bprm->cap_effective)
79181 return 1;
79182 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
79183 index 3ccf7ac..d73ad64 100644
79184 --- a/security/integrity/ima/ima.h
79185 +++ b/security/integrity/ima/ima.h
79186 @@ -86,8 +86,8 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
79187 extern spinlock_t ima_queue_lock;
79188
79189 struct ima_h_table {
79190 - atomic_long_t len; /* number of stored measurements in the list */
79191 - atomic_long_t violations;
79192 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
79193 + atomic_long_unchecked_t violations;
79194 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
79195 };
79196 extern struct ima_h_table ima_htable;
79197 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
79198 index 88a2788..581ab92 100644
79199 --- a/security/integrity/ima/ima_api.c
79200 +++ b/security/integrity/ima/ima_api.c
79201 @@ -75,7 +75,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
79202 int result;
79203
79204 /* can overflow, only indicator */
79205 - atomic_long_inc(&ima_htable.violations);
79206 + atomic_long_inc_unchecked(&ima_htable.violations);
79207
79208 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
79209 if (!entry) {
79210 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
79211 index e1aa2b4..52027bf 100644
79212 --- a/security/integrity/ima/ima_fs.c
79213 +++ b/security/integrity/ima/ima_fs.c
79214 @@ -28,12 +28,12 @@
79215 static int valid_policy = 1;
79216 #define TMPBUFLEN 12
79217 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
79218 - loff_t *ppos, atomic_long_t *val)
79219 + loff_t *ppos, atomic_long_unchecked_t *val)
79220 {
79221 char tmpbuf[TMPBUFLEN];
79222 ssize_t len;
79223
79224 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
79225 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
79226 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
79227 }
79228
79229 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
79230 index 55a6271..ad829c3 100644
79231 --- a/security/integrity/ima/ima_queue.c
79232 +++ b/security/integrity/ima/ima_queue.c
79233 @@ -81,7 +81,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
79234 INIT_LIST_HEAD(&qe->later);
79235 list_add_tail_rcu(&qe->later, &ima_measurements);
79236
79237 - atomic_long_inc(&ima_htable.len);
79238 + atomic_long_inc_unchecked(&ima_htable.len);
79239 key = ima_hash_key(entry->digest);
79240 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
79241 return 0;
79242 diff --git a/security/keys/compat.c b/security/keys/compat.c
79243 index 4c48e13..7abdac9 100644
79244 --- a/security/keys/compat.c
79245 +++ b/security/keys/compat.c
79246 @@ -44,7 +44,7 @@ long compat_keyctl_instantiate_key_iov(
79247 if (ret == 0)
79248 goto no_payload_free;
79249
79250 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
79251 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
79252
79253 if (iov != iovstack)
79254 kfree(iov);
79255 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
79256 index 0b3f5d7..892c8a6 100644
79257 --- a/security/keys/keyctl.c
79258 +++ b/security/keys/keyctl.c
79259 @@ -921,7 +921,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
79260 /*
79261 * Copy the iovec data from userspace
79262 */
79263 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
79264 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
79265 unsigned ioc)
79266 {
79267 for (; ioc > 0; ioc--) {
79268 @@ -943,7 +943,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
79269 * If successful, 0 will be returned.
79270 */
79271 long keyctl_instantiate_key_common(key_serial_t id,
79272 - const struct iovec *payload_iov,
79273 + const struct iovec __user *payload_iov,
79274 unsigned ioc,
79275 size_t plen,
79276 key_serial_t ringid)
79277 @@ -1038,7 +1038,7 @@ long keyctl_instantiate_key(key_serial_t id,
79278 [0].iov_len = plen
79279 };
79280
79281 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
79282 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
79283 }
79284
79285 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
79286 @@ -1071,7 +1071,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
79287 if (ret == 0)
79288 goto no_payload_free;
79289
79290 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
79291 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
79292
79293 if (iov != iovstack)
79294 kfree(iov);
79295 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
79296 index d605f75..2bc6be9 100644
79297 --- a/security/keys/keyring.c
79298 +++ b/security/keys/keyring.c
79299 @@ -214,15 +214,15 @@ static long keyring_read(const struct key *keyring,
79300 ret = -EFAULT;
79301
79302 for (loop = 0; loop < klist->nkeys; loop++) {
79303 + key_serial_t serial;
79304 key = klist->keys[loop];
79305 + serial = key->serial;
79306
79307 tmp = sizeof(key_serial_t);
79308 if (tmp > buflen)
79309 tmp = buflen;
79310
79311 - if (copy_to_user(buffer,
79312 - &key->serial,
79313 - tmp) != 0)
79314 + if (copy_to_user(buffer, &serial, tmp))
79315 goto error;
79316
79317 buflen -= tmp;
79318 diff --git a/security/min_addr.c b/security/min_addr.c
79319 index f728728..6457a0c 100644
79320 --- a/security/min_addr.c
79321 +++ b/security/min_addr.c
79322 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
79323 */
79324 static void update_mmap_min_addr(void)
79325 {
79326 +#ifndef SPARC
79327 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
79328 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
79329 mmap_min_addr = dac_mmap_min_addr;
79330 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
79331 #else
79332 mmap_min_addr = dac_mmap_min_addr;
79333 #endif
79334 +#endif
79335 }
79336
79337 /*
79338 diff --git a/security/security.c b/security/security.c
79339 index d754249..8bf426e 100644
79340 --- a/security/security.c
79341 +++ b/security/security.c
79342 @@ -26,8 +26,8 @@
79343 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
79344 CONFIG_DEFAULT_SECURITY;
79345
79346 -static struct security_operations *security_ops;
79347 -static struct security_operations default_security_ops = {
79348 +static struct security_operations *security_ops __read_only;
79349 +static struct security_operations default_security_ops __read_only = {
79350 .name = "default",
79351 };
79352
79353 @@ -68,7 +68,9 @@ int __init security_init(void)
79354
79355 void reset_security_ops(void)
79356 {
79357 + pax_open_kernel();
79358 security_ops = &default_security_ops;
79359 + pax_close_kernel();
79360 }
79361
79362 /* Save user chosen LSM */
79363 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
79364 index 6a3683e..f52f4c0 100644
79365 --- a/security/selinux/hooks.c
79366 +++ b/security/selinux/hooks.c
79367 @@ -94,8 +94,6 @@
79368
79369 #define NUM_SEL_MNT_OPTS 5
79370
79371 -extern struct security_operations *security_ops;
79372 -
79373 /* SECMARK reference count */
79374 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
79375
79376 @@ -5429,7 +5427,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
79377
79378 #endif
79379
79380 -static struct security_operations selinux_ops = {
79381 +static struct security_operations selinux_ops __read_only = {
79382 .name = "selinux",
79383
79384 .ptrace_access_check = selinux_ptrace_access_check,
79385 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
79386 index b43813c..74be837 100644
79387 --- a/security/selinux/include/xfrm.h
79388 +++ b/security/selinux/include/xfrm.h
79389 @@ -48,7 +48,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
79390
79391 static inline void selinux_xfrm_notify_policyload(void)
79392 {
79393 - atomic_inc(&flow_cache_genid);
79394 + atomic_inc_unchecked(&flow_cache_genid);
79395 }
79396 #else
79397 static inline int selinux_xfrm_enabled(void)
79398 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
79399 index e8af5b0b..78527ef 100644
79400 --- a/security/smack/smack_lsm.c
79401 +++ b/security/smack/smack_lsm.c
79402 @@ -3481,7 +3481,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
79403 return 0;
79404 }
79405
79406 -struct security_operations smack_ops = {
79407 +struct security_operations smack_ops __read_only = {
79408 .name = "smack",
79409
79410 .ptrace_access_check = smack_ptrace_access_check,
79411 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
79412 index 620d37c..e2ad89b 100644
79413 --- a/security/tomoyo/tomoyo.c
79414 +++ b/security/tomoyo/tomoyo.c
79415 @@ -501,7 +501,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
79416 * tomoyo_security_ops is a "struct security_operations" which is used for
79417 * registering TOMOYO.
79418 */
79419 -static struct security_operations tomoyo_security_ops = {
79420 +static struct security_operations tomoyo_security_ops __read_only = {
79421 .name = "tomoyo",
79422 .cred_alloc_blank = tomoyo_cred_alloc_blank,
79423 .cred_prepare = tomoyo_cred_prepare,
79424 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
79425 index 762af68..7103453 100644
79426 --- a/sound/aoa/codecs/onyx.c
79427 +++ b/sound/aoa/codecs/onyx.c
79428 @@ -54,7 +54,7 @@ struct onyx {
79429 spdif_locked:1,
79430 analog_locked:1,
79431 original_mute:2;
79432 - int open_count;
79433 + local_t open_count;
79434 struct codec_info *codec_info;
79435
79436 /* mutex serializes concurrent access to the device
79437 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
79438 struct onyx *onyx = cii->codec_data;
79439
79440 mutex_lock(&onyx->mutex);
79441 - onyx->open_count++;
79442 + local_inc(&onyx->open_count);
79443 mutex_unlock(&onyx->mutex);
79444
79445 return 0;
79446 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
79447 struct onyx *onyx = cii->codec_data;
79448
79449 mutex_lock(&onyx->mutex);
79450 - onyx->open_count--;
79451 - if (!onyx->open_count)
79452 + if (local_dec_and_test(&onyx->open_count))
79453 onyx->spdif_locked = onyx->analog_locked = 0;
79454 mutex_unlock(&onyx->mutex);
79455
79456 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
79457 index ffd2025..df062c9 100644
79458 --- a/sound/aoa/codecs/onyx.h
79459 +++ b/sound/aoa/codecs/onyx.h
79460 @@ -11,6 +11,7 @@
79461 #include <linux/i2c.h>
79462 #include <asm/pmac_low_i2c.h>
79463 #include <asm/prom.h>
79464 +#include <asm/local.h>
79465
79466 /* PCM3052 register definitions */
79467
79468 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
79469 index 08fde00..0bf641a 100644
79470 --- a/sound/core/oss/pcm_oss.c
79471 +++ b/sound/core/oss/pcm_oss.c
79472 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
79473 if (in_kernel) {
79474 mm_segment_t fs;
79475 fs = snd_enter_user();
79476 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
79477 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
79478 snd_leave_user(fs);
79479 } else {
79480 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
79481 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
79482 }
79483 if (ret != -EPIPE && ret != -ESTRPIPE)
79484 break;
79485 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
79486 if (in_kernel) {
79487 mm_segment_t fs;
79488 fs = snd_enter_user();
79489 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
79490 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
79491 snd_leave_user(fs);
79492 } else {
79493 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
79494 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
79495 }
79496 if (ret == -EPIPE) {
79497 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
79498 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
79499 struct snd_pcm_plugin_channel *channels;
79500 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
79501 if (!in_kernel) {
79502 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
79503 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
79504 return -EFAULT;
79505 buf = runtime->oss.buffer;
79506 }
79507 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
79508 }
79509 } else {
79510 tmp = snd_pcm_oss_write2(substream,
79511 - (const char __force *)buf,
79512 + (const char __force_kernel *)buf,
79513 runtime->oss.period_bytes, 0);
79514 if (tmp <= 0)
79515 goto err;
79516 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
79517 struct snd_pcm_runtime *runtime = substream->runtime;
79518 snd_pcm_sframes_t frames, frames1;
79519 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
79520 - char __user *final_dst = (char __force __user *)buf;
79521 + char __user *final_dst = (char __force_user *)buf;
79522 if (runtime->oss.plugin_first) {
79523 struct snd_pcm_plugin_channel *channels;
79524 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
79525 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
79526 xfer += tmp;
79527 runtime->oss.buffer_used -= tmp;
79528 } else {
79529 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
79530 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
79531 runtime->oss.period_bytes, 0);
79532 if (tmp <= 0)
79533 goto err;
79534 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
79535 size1);
79536 size1 /= runtime->channels; /* frames */
79537 fs = snd_enter_user();
79538 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
79539 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
79540 snd_leave_user(fs);
79541 }
79542 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
79543 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
79544 index 91cdf94..4085161 100644
79545 --- a/sound/core/pcm_compat.c
79546 +++ b/sound/core/pcm_compat.c
79547 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
79548 int err;
79549
79550 fs = snd_enter_user();
79551 - err = snd_pcm_delay(substream, &delay);
79552 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
79553 snd_leave_user(fs);
79554 if (err < 0)
79555 return err;
79556 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
79557 index 25ed9fe..24c46e9 100644
79558 --- a/sound/core/pcm_native.c
79559 +++ b/sound/core/pcm_native.c
79560 @@ -2765,11 +2765,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
79561 switch (substream->stream) {
79562 case SNDRV_PCM_STREAM_PLAYBACK:
79563 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
79564 - (void __user *)arg);
79565 + (void __force_user *)arg);
79566 break;
79567 case SNDRV_PCM_STREAM_CAPTURE:
79568 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
79569 - (void __user *)arg);
79570 + (void __force_user *)arg);
79571 break;
79572 default:
79573 result = -EINVAL;
79574 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
79575 index 5cf8d65..912a79c 100644
79576 --- a/sound/core/seq/seq_device.c
79577 +++ b/sound/core/seq/seq_device.c
79578 @@ -64,7 +64,7 @@ struct ops_list {
79579 int argsize; /* argument size */
79580
79581 /* operators */
79582 - struct snd_seq_dev_ops ops;
79583 + struct snd_seq_dev_ops *ops;
79584
79585 /* registred devices */
79586 struct list_head dev_list; /* list of devices */
79587 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
79588
79589 mutex_lock(&ops->reg_mutex);
79590 /* copy driver operators */
79591 - ops->ops = *entry;
79592 + ops->ops = entry;
79593 ops->driver |= DRIVER_LOADED;
79594 ops->argsize = argsize;
79595
79596 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
79597 dev->name, ops->id, ops->argsize, dev->argsize);
79598 return -EINVAL;
79599 }
79600 - if (ops->ops.init_device(dev) >= 0) {
79601 + if (ops->ops->init_device(dev) >= 0) {
79602 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
79603 ops->num_init_devices++;
79604 } else {
79605 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
79606 dev->name, ops->id, ops->argsize, dev->argsize);
79607 return -EINVAL;
79608 }
79609 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
79610 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
79611 dev->status = SNDRV_SEQ_DEVICE_FREE;
79612 dev->driver_data = NULL;
79613 ops->num_init_devices--;
79614 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
79615 index 621e60e..f4543f5 100644
79616 --- a/sound/drivers/mts64.c
79617 +++ b/sound/drivers/mts64.c
79618 @@ -29,6 +29,7 @@
79619 #include <sound/initval.h>
79620 #include <sound/rawmidi.h>
79621 #include <sound/control.h>
79622 +#include <asm/local.h>
79623
79624 #define CARD_NAME "Miditerminal 4140"
79625 #define DRIVER_NAME "MTS64"
79626 @@ -67,7 +68,7 @@ struct mts64 {
79627 struct pardevice *pardev;
79628 int pardev_claimed;
79629
79630 - int open_count;
79631 + local_t open_count;
79632 int current_midi_output_port;
79633 int current_midi_input_port;
79634 u8 mode[MTS64_NUM_INPUT_PORTS];
79635 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
79636 {
79637 struct mts64 *mts = substream->rmidi->private_data;
79638
79639 - if (mts->open_count == 0) {
79640 + if (local_read(&mts->open_count) == 0) {
79641 /* We don't need a spinlock here, because this is just called
79642 if the device has not been opened before.
79643 So there aren't any IRQs from the device */
79644 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
79645
79646 msleep(50);
79647 }
79648 - ++(mts->open_count);
79649 + local_inc(&mts->open_count);
79650
79651 return 0;
79652 }
79653 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
79654 struct mts64 *mts = substream->rmidi->private_data;
79655 unsigned long flags;
79656
79657 - --(mts->open_count);
79658 - if (mts->open_count == 0) {
79659 + if (local_dec_return(&mts->open_count) == 0) {
79660 /* We need the spinlock_irqsave here because we can still
79661 have IRQs at this point */
79662 spin_lock_irqsave(&mts->lock, flags);
79663 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
79664
79665 msleep(500);
79666
79667 - } else if (mts->open_count < 0)
79668 - mts->open_count = 0;
79669 + } else if (local_read(&mts->open_count) < 0)
79670 + local_set(&mts->open_count, 0);
79671
79672 return 0;
79673 }
79674 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
79675 index b953fb4..1999c01 100644
79676 --- a/sound/drivers/opl4/opl4_lib.c
79677 +++ b/sound/drivers/opl4/opl4_lib.c
79678 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
79679 MODULE_DESCRIPTION("OPL4 driver");
79680 MODULE_LICENSE("GPL");
79681
79682 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
79683 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
79684 {
79685 int timeout = 10;
79686 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
79687 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
79688 index 3e32bd3..46fc152 100644
79689 --- a/sound/drivers/portman2x4.c
79690 +++ b/sound/drivers/portman2x4.c
79691 @@ -48,6 +48,7 @@
79692 #include <sound/initval.h>
79693 #include <sound/rawmidi.h>
79694 #include <sound/control.h>
79695 +#include <asm/local.h>
79696
79697 #define CARD_NAME "Portman 2x4"
79698 #define DRIVER_NAME "portman"
79699 @@ -85,7 +86,7 @@ struct portman {
79700 struct pardevice *pardev;
79701 int pardev_claimed;
79702
79703 - int open_count;
79704 + local_t open_count;
79705 int mode[PORTMAN_NUM_INPUT_PORTS];
79706 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
79707 };
79708 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
79709 index 87657dd..a8268d4 100644
79710 --- a/sound/firewire/amdtp.c
79711 +++ b/sound/firewire/amdtp.c
79712 @@ -371,7 +371,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
79713 ptr = s->pcm_buffer_pointer + data_blocks;
79714 if (ptr >= pcm->runtime->buffer_size)
79715 ptr -= pcm->runtime->buffer_size;
79716 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
79717 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
79718
79719 s->pcm_period_pointer += data_blocks;
79720 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
79721 @@ -511,7 +511,7 @@ EXPORT_SYMBOL(amdtp_out_stream_start);
79722 */
79723 void amdtp_out_stream_update(struct amdtp_out_stream *s)
79724 {
79725 - ACCESS_ONCE(s->source_node_id_field) =
79726 + ACCESS_ONCE_RW(s->source_node_id_field) =
79727 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
79728 }
79729 EXPORT_SYMBOL(amdtp_out_stream_update);
79730 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
79731 index 537a9cb..8e8c8e9 100644
79732 --- a/sound/firewire/amdtp.h
79733 +++ b/sound/firewire/amdtp.h
79734 @@ -146,7 +146,7 @@ static inline void amdtp_out_stream_pcm_prepare(struct amdtp_out_stream *s)
79735 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
79736 struct snd_pcm_substream *pcm)
79737 {
79738 - ACCESS_ONCE(s->pcm) = pcm;
79739 + ACCESS_ONCE_RW(s->pcm) = pcm;
79740 }
79741
79742 /**
79743 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
79744 index cd094ec..eca1277 100644
79745 --- a/sound/firewire/isight.c
79746 +++ b/sound/firewire/isight.c
79747 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
79748 ptr += count;
79749 if (ptr >= runtime->buffer_size)
79750 ptr -= runtime->buffer_size;
79751 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
79752 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
79753
79754 isight->period_counter += count;
79755 if (isight->period_counter >= runtime->period_size) {
79756 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
79757 if (err < 0)
79758 return err;
79759
79760 - ACCESS_ONCE(isight->pcm_active) = true;
79761 + ACCESS_ONCE_RW(isight->pcm_active) = true;
79762
79763 return 0;
79764 }
79765 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
79766 {
79767 struct isight *isight = substream->private_data;
79768
79769 - ACCESS_ONCE(isight->pcm_active) = false;
79770 + ACCESS_ONCE_RW(isight->pcm_active) = false;
79771
79772 mutex_lock(&isight->mutex);
79773 isight_stop_streaming(isight);
79774 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
79775
79776 switch (cmd) {
79777 case SNDRV_PCM_TRIGGER_START:
79778 - ACCESS_ONCE(isight->pcm_running) = true;
79779 + ACCESS_ONCE_RW(isight->pcm_running) = true;
79780 break;
79781 case SNDRV_PCM_TRIGGER_STOP:
79782 - ACCESS_ONCE(isight->pcm_running) = false;
79783 + ACCESS_ONCE_RW(isight->pcm_running) = false;
79784 break;
79785 default:
79786 return -EINVAL;
79787 diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c
79788 index 7bd5e33..1fcab12 100644
79789 --- a/sound/isa/cmi8330.c
79790 +++ b/sound/isa/cmi8330.c
79791 @@ -172,7 +172,7 @@ struct snd_cmi8330 {
79792
79793 struct snd_pcm *pcm;
79794 struct snd_cmi8330_stream {
79795 - struct snd_pcm_ops ops;
79796 + snd_pcm_ops_no_const ops;
79797 snd_pcm_open_callback_t open;
79798 void *private_data; /* sb or wss */
79799 } streams[2];
79800 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
79801 index 733b014..56ce96f 100644
79802 --- a/sound/oss/sb_audio.c
79803 +++ b/sound/oss/sb_audio.c
79804 @@ -901,7 +901,7 @@ sb16_copy_from_user(int dev,
79805 buf16 = (signed short *)(localbuf + localoffs);
79806 while (c)
79807 {
79808 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
79809 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
79810 if (copy_from_user(lbuf8,
79811 userbuf+useroffs + p,
79812 locallen))
79813 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
79814 index 09d4648..cf234c7 100644
79815 --- a/sound/oss/swarm_cs4297a.c
79816 +++ b/sound/oss/swarm_cs4297a.c
79817 @@ -2606,7 +2606,6 @@ static int __init cs4297a_init(void)
79818 {
79819 struct cs4297a_state *s;
79820 u32 pwr, id;
79821 - mm_segment_t fs;
79822 int rval;
79823 #ifndef CONFIG_BCM_CS4297A_CSWARM
79824 u64 cfg;
79825 @@ -2696,22 +2695,23 @@ static int __init cs4297a_init(void)
79826 if (!rval) {
79827 char *sb1250_duart_present;
79828
79829 +#if 0
79830 + mm_segment_t fs;
79831 fs = get_fs();
79832 set_fs(KERNEL_DS);
79833 -#if 0
79834 val = SOUND_MASK_LINE;
79835 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
79836 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
79837 val = initvol[i].vol;
79838 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
79839 }
79840 + set_fs(fs);
79841 // cs4297a_write_ac97(s, 0x18, 0x0808);
79842 #else
79843 // cs4297a_write_ac97(s, 0x5e, 0x180);
79844 cs4297a_write_ac97(s, 0x02, 0x0808);
79845 cs4297a_write_ac97(s, 0x18, 0x0808);
79846 #endif
79847 - set_fs(fs);
79848
79849 list_add(&s->list, &cs4297a_devs);
79850
79851 diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
79852 index f0f1943..8e1f96c 100644
79853 --- a/sound/pci/hda/hda_codec.h
79854 +++ b/sound/pci/hda/hda_codec.h
79855 @@ -611,7 +611,7 @@ struct hda_bus_ops {
79856 /* notify power-up/down from codec to controller */
79857 void (*pm_notify)(struct hda_bus *bus);
79858 #endif
79859 -};
79860 +} __no_const;
79861
79862 /* template to pass to the bus constructor */
79863 struct hda_bus_template {
79864 @@ -713,6 +713,7 @@ struct hda_codec_ops {
79865 #endif
79866 void (*reboot_notify)(struct hda_codec *codec);
79867 };
79868 +typedef struct hda_codec_ops __no_const hda_codec_ops_no_const;
79869
79870 /* record for amp information cache */
79871 struct hda_cache_head {
79872 @@ -743,7 +744,7 @@ struct hda_pcm_ops {
79873 struct snd_pcm_substream *substream);
79874 int (*cleanup)(struct hda_pcm_stream *info, struct hda_codec *codec,
79875 struct snd_pcm_substream *substream);
79876 -};
79877 +} __no_const;
79878
79879 /* PCM information for each substream */
79880 struct hda_pcm_stream {
79881 @@ -801,7 +802,7 @@ struct hda_codec {
79882 const char *modelname; /* model name for preset */
79883
79884 /* set by patch */
79885 - struct hda_codec_ops patch_ops;
79886 + hda_codec_ops_no_const patch_ops;
79887
79888 /* PCM to create, set by patch_ops.build_pcms callback */
79889 unsigned int num_pcms;
79890 diff --git a/sound/pci/ice1712/ice1712.h b/sound/pci/ice1712/ice1712.h
79891 index 0da778a..bc38b84 100644
79892 --- a/sound/pci/ice1712/ice1712.h
79893 +++ b/sound/pci/ice1712/ice1712.h
79894 @@ -269,7 +269,7 @@ struct snd_ak4xxx_private {
79895 unsigned int mask_flags; /* total mask bits */
79896 struct snd_akm4xxx_ops {
79897 void (*set_rate_val)(struct snd_akm4xxx *ak, unsigned int rate);
79898 - } ops;
79899 + } __no_const ops;
79900 };
79901
79902 struct snd_ice1712_spdif {
79903 @@ -285,7 +285,7 @@ struct snd_ice1712_spdif {
79904 int (*default_put)(struct snd_ice1712 *, struct snd_ctl_elem_value *ucontrol);
79905 void (*stream_get)(struct snd_ice1712 *, struct snd_ctl_elem_value *ucontrol);
79906 int (*stream_put)(struct snd_ice1712 *, struct snd_ctl_elem_value *ucontrol);
79907 - } ops;
79908 + } __no_const ops;
79909 };
79910
79911
79912 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
79913 index 12a9a2b..2b6138f 100644
79914 --- a/sound/pci/ymfpci/ymfpci_main.c
79915 +++ b/sound/pci/ymfpci/ymfpci_main.c
79916 @@ -203,8 +203,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
79917 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
79918 break;
79919 }
79920 - if (atomic_read(&chip->interrupt_sleep_count)) {
79921 - atomic_set(&chip->interrupt_sleep_count, 0);
79922 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
79923 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
79924 wake_up(&chip->interrupt_sleep);
79925 }
79926 __end:
79927 @@ -788,7 +788,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
79928 continue;
79929 init_waitqueue_entry(&wait, current);
79930 add_wait_queue(&chip->interrupt_sleep, &wait);
79931 - atomic_inc(&chip->interrupt_sleep_count);
79932 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
79933 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
79934 remove_wait_queue(&chip->interrupt_sleep, &wait);
79935 }
79936 @@ -826,8 +826,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
79937 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
79938 spin_unlock(&chip->reg_lock);
79939
79940 - if (atomic_read(&chip->interrupt_sleep_count)) {
79941 - atomic_set(&chip->interrupt_sleep_count, 0);
79942 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
79943 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
79944 wake_up(&chip->interrupt_sleep);
79945 }
79946 }
79947 @@ -2389,7 +2389,7 @@ int __devinit snd_ymfpci_create(struct snd_card *card,
79948 spin_lock_init(&chip->reg_lock);
79949 spin_lock_init(&chip->voice_lock);
79950 init_waitqueue_head(&chip->interrupt_sleep);
79951 - atomic_set(&chip->interrupt_sleep_count, 0);
79952 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
79953 chip->card = card;
79954 chip->pci = pci;
79955 chip->irq = -1;
79956 diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
79957 index cdc860a..db34a93 100644
79958 --- a/sound/soc/soc-pcm.c
79959 +++ b/sound/soc/soc-pcm.c
79960 @@ -605,7 +605,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
79961 struct snd_soc_platform *platform = rtd->platform;
79962 struct snd_soc_dai *codec_dai = rtd->codec_dai;
79963 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
79964 - struct snd_pcm_ops *soc_pcm_ops = &rtd->ops;
79965 + snd_pcm_ops_no_const *soc_pcm_ops = &rtd->ops;
79966 struct snd_pcm *pcm;
79967 char new_name[64];
79968 int ret = 0, playback = 0, capture = 0;
79969 diff --git a/sound/usb/card.h b/sound/usb/card.h
79970 index da5fa1a..113cd02 100644
79971 --- a/sound/usb/card.h
79972 +++ b/sound/usb/card.h
79973 @@ -45,6 +45,7 @@ struct snd_urb_ops {
79974 int (*prepare_sync)(struct snd_usb_substream *subs, struct snd_pcm_runtime *runtime, struct urb *u);
79975 int (*retire_sync)(struct snd_usb_substream *subs, struct snd_pcm_runtime *runtime, struct urb *u);
79976 };
79977 +typedef struct snd_urb_ops __no_const snd_urb_ops_no_const;
79978
79979 struct snd_usb_substream {
79980 struct snd_usb_stream *stream;
79981 @@ -94,7 +95,7 @@ struct snd_usb_substream {
79982 struct snd_pcm_hw_constraint_list rate_list; /* limited rates */
79983 spinlock_t lock;
79984
79985 - struct snd_urb_ops ops; /* callbacks (must be filled at init) */
79986 + snd_urb_ops_no_const ops; /* callbacks (must be filled at init) */
79987 int last_frame_number; /* stored frame number */
79988 int last_delay; /* stored delay */
79989 };
79990 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
79991 new file mode 100644
79992 index 0000000..ca64170
79993 --- /dev/null
79994 +++ b/tools/gcc/Makefile
79995 @@ -0,0 +1,26 @@
79996 +#CC := gcc
79997 +#PLUGIN_SOURCE_FILES := pax_plugin.c
79998 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
79999 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
80000 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
80001 +
80002 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -I$(GCCPLUGINS_DIR)/include/c-family -std=gnu99 -ggdb
80003 +CFLAGS_size_overflow_plugin.o := -Wno-missing-initializer
80004 +
80005 +hostlibs-y := constify_plugin.so
80006 +hostlibs-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
80007 +hostlibs-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
80008 +hostlibs-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
80009 +hostlibs-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
80010 +hostlibs-y += colorize_plugin.so
80011 +hostlibs-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
80012 +
80013 +always := $(hostlibs-y)
80014 +
80015 +constify_plugin-objs := constify_plugin.o
80016 +stackleak_plugin-objs := stackleak_plugin.o
80017 +kallocstat_plugin-objs := kallocstat_plugin.o
80018 +kernexec_plugin-objs := kernexec_plugin.o
80019 +checker_plugin-objs := checker_plugin.o
80020 +colorize_plugin-objs := colorize_plugin.o
80021 +size_overflow_plugin-objs := size_overflow_plugin.o
80022 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
80023 new file mode 100644
80024 index 0000000..d41b5af
80025 --- /dev/null
80026 +++ b/tools/gcc/checker_plugin.c
80027 @@ -0,0 +1,171 @@
80028 +/*
80029 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
80030 + * Licensed under the GPL v2
80031 + *
80032 + * Note: the choice of the license means that the compilation process is
80033 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
80034 + * but for the kernel it doesn't matter since it doesn't link against
80035 + * any of the gcc libraries
80036 + *
80037 + * gcc plugin to implement various sparse (source code checker) features
80038 + *
80039 + * TODO:
80040 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
80041 + *
80042 + * BUGS:
80043 + * - none known
80044 + */
80045 +#include "gcc-plugin.h"
80046 +#include "config.h"
80047 +#include "system.h"
80048 +#include "coretypes.h"
80049 +#include "tree.h"
80050 +#include "tree-pass.h"
80051 +#include "flags.h"
80052 +#include "intl.h"
80053 +#include "toplev.h"
80054 +#include "plugin.h"
80055 +//#include "expr.h" where are you...
80056 +#include "diagnostic.h"
80057 +#include "plugin-version.h"
80058 +#include "tm.h"
80059 +#include "function.h"
80060 +#include "basic-block.h"
80061 +#include "gimple.h"
80062 +#include "rtl.h"
80063 +#include "emit-rtl.h"
80064 +#include "tree-flow.h"
80065 +#include "target.h"
80066 +
80067 +extern void c_register_addr_space (const char *str, addr_space_t as);
80068 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
80069 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
80070 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
80071 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
80072 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
80073 +
80074 +extern void print_gimple_stmt(FILE *, gimple, int, int);
80075 +extern rtx emit_move_insn(rtx x, rtx y);
80076 +
80077 +int plugin_is_GPL_compatible;
80078 +
80079 +static struct plugin_info checker_plugin_info = {
80080 + .version = "201111150100",
80081 +};
80082 +
80083 +#define ADDR_SPACE_KERNEL 0
80084 +#define ADDR_SPACE_FORCE_KERNEL 1
80085 +#define ADDR_SPACE_USER 2
80086 +#define ADDR_SPACE_FORCE_USER 3
80087 +#define ADDR_SPACE_IOMEM 0
80088 +#define ADDR_SPACE_FORCE_IOMEM 0
80089 +#define ADDR_SPACE_PERCPU 0
80090 +#define ADDR_SPACE_FORCE_PERCPU 0
80091 +#define ADDR_SPACE_RCU 0
80092 +#define ADDR_SPACE_FORCE_RCU 0
80093 +
80094 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
80095 +{
80096 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
80097 +}
80098 +
80099 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
80100 +{
80101 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
80102 +}
80103 +
80104 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
80105 +{
80106 + return default_addr_space_valid_pointer_mode(mode, as);
80107 +}
80108 +
80109 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
80110 +{
80111 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
80112 +}
80113 +
80114 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
80115 +{
80116 + return default_addr_space_legitimize_address(x, oldx, mode, as);
80117 +}
80118 +
80119 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
80120 +{
80121 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
80122 + return true;
80123 +
80124 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
80125 + return true;
80126 +
80127 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
80128 + return true;
80129 +
80130 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
80131 + return true;
80132 +
80133 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
80134 + return true;
80135 +
80136 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
80137 + return true;
80138 +
80139 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
80140 + return true;
80141 +
80142 + return subset == superset;
80143 +}
80144 +
80145 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
80146 +{
80147 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
80148 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
80149 +
80150 + return op;
80151 +}
80152 +
80153 +static void register_checker_address_spaces(void *event_data, void *data)
80154 +{
80155 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
80156 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
80157 + c_register_addr_space("__user", ADDR_SPACE_USER);
80158 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
80159 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
80160 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
80161 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
80162 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
80163 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
80164 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
80165 +
80166 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
80167 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
80168 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
80169 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
80170 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
80171 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
80172 + targetm.addr_space.convert = checker_addr_space_convert;
80173 +}
80174 +
80175 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
80176 +{
80177 + const char * const plugin_name = plugin_info->base_name;
80178 + const int argc = plugin_info->argc;
80179 + const struct plugin_argument * const argv = plugin_info->argv;
80180 + int i;
80181 +
80182 + if (!plugin_default_version_check(version, &gcc_version)) {
80183 + error(G_("incompatible gcc/plugin versions"));
80184 + return 1;
80185 + }
80186 +
80187 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
80188 +
80189 + for (i = 0; i < argc; ++i)
80190 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
80191 +
80192 + if (TARGET_64BIT == 0)
80193 + return 0;
80194 +
80195 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
80196 +
80197 + return 0;
80198 +}
80199 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
80200 new file mode 100644
80201 index 0000000..ee950d0
80202 --- /dev/null
80203 +++ b/tools/gcc/colorize_plugin.c
80204 @@ -0,0 +1,147 @@
80205 +/*
80206 + * Copyright 2012 by PaX Team <pageexec@freemail.hu>
80207 + * Licensed under the GPL v2
80208 + *
80209 + * Note: the choice of the license means that the compilation process is
80210 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
80211 + * but for the kernel it doesn't matter since it doesn't link against
80212 + * any of the gcc libraries
80213 + *
80214 + * gcc plugin to colorize diagnostic output
80215 + *
80216 + */
80217 +
80218 +#include "gcc-plugin.h"
80219 +#include "config.h"
80220 +#include "system.h"
80221 +#include "coretypes.h"
80222 +#include "tree.h"
80223 +#include "tree-pass.h"
80224 +#include "flags.h"
80225 +#include "intl.h"
80226 +#include "toplev.h"
80227 +#include "plugin.h"
80228 +#include "diagnostic.h"
80229 +#include "plugin-version.h"
80230 +#include "tm.h"
80231 +
80232 +int plugin_is_GPL_compatible;
80233 +
80234 +static struct plugin_info colorize_plugin_info = {
80235 + .version = "201203092200",
80236 +};
80237 +
80238 +#define GREEN "\033[32m\033[2m"
80239 +#define LIGHTGREEN "\033[32m\033[1m"
80240 +#define YELLOW "\033[33m\033[2m"
80241 +#define LIGHTYELLOW "\033[33m\033[1m"
80242 +#define RED "\033[31m\033[2m"
80243 +#define LIGHTRED "\033[31m\033[1m"
80244 +#define BLUE "\033[34m\033[2m"
80245 +#define LIGHTBLUE "\033[34m\033[1m"
80246 +#define BRIGHT "\033[m\033[1m"
80247 +#define NORMAL "\033[m"
80248 +
80249 +static diagnostic_starter_fn old_starter;
80250 +static diagnostic_finalizer_fn old_finalizer;
80251 +
80252 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
80253 +{
80254 + const char *color;
80255 + char *newprefix;
80256 +
80257 + switch (diagnostic->kind) {
80258 + case DK_NOTE:
80259 + color = LIGHTBLUE;
80260 + break;
80261 +
80262 + case DK_PEDWARN:
80263 + case DK_WARNING:
80264 + color = LIGHTYELLOW;
80265 + break;
80266 +
80267 + case DK_ERROR:
80268 + case DK_FATAL:
80269 + case DK_ICE:
80270 + case DK_PERMERROR:
80271 + case DK_SORRY:
80272 + color = LIGHTRED;
80273 + break;
80274 +
80275 + default:
80276 + color = NORMAL;
80277 + }
80278 +
80279 + old_starter(context, diagnostic);
80280 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
80281 + return;
80282 + pp_destroy_prefix(context->printer);
80283 + pp_set_prefix(context->printer, newprefix);
80284 +}
80285 +
80286 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
80287 +{
80288 + old_finalizer(context, diagnostic);
80289 +}
80290 +
80291 +static void colorize_arm(void)
80292 +{
80293 + old_starter = diagnostic_starter(global_dc);
80294 + old_finalizer = diagnostic_finalizer(global_dc);
80295 +
80296 + diagnostic_starter(global_dc) = start_colorize;
80297 + diagnostic_finalizer(global_dc) = finalize_colorize;
80298 +}
80299 +
80300 +static unsigned int execute_colorize_rearm(void)
80301 +{
80302 + if (diagnostic_starter(global_dc) == start_colorize)
80303 + return 0;
80304 +
80305 + colorize_arm();
80306 + return 0;
80307 +}
80308 +
80309 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
80310 + .pass = {
80311 + .type = SIMPLE_IPA_PASS,
80312 + .name = "colorize_rearm",
80313 + .gate = NULL,
80314 + .execute = execute_colorize_rearm,
80315 + .sub = NULL,
80316 + .next = NULL,
80317 + .static_pass_number = 0,
80318 + .tv_id = TV_NONE,
80319 + .properties_required = 0,
80320 + .properties_provided = 0,
80321 + .properties_destroyed = 0,
80322 + .todo_flags_start = 0,
80323 + .todo_flags_finish = 0
80324 + }
80325 +};
80326 +
80327 +static void colorize_start_unit(void *gcc_data, void *user_data)
80328 +{
80329 + colorize_arm();
80330 +}
80331 +
80332 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
80333 +{
80334 + const char * const plugin_name = plugin_info->base_name;
80335 + struct register_pass_info colorize_rearm_pass_info = {
80336 + .pass = &pass_ipa_colorize_rearm.pass,
80337 + .reference_pass_name = "*free_lang_data",
80338 + .ref_pass_instance_number = 0,
80339 + .pos_op = PASS_POS_INSERT_AFTER
80340 + };
80341 +
80342 + if (!plugin_default_version_check(version, &gcc_version)) {
80343 + error(G_("incompatible gcc/plugin versions"));
80344 + return 1;
80345 + }
80346 +
80347 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
80348 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
80349 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
80350 + return 0;
80351 +}
80352 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
80353 new file mode 100644
80354 index 0000000..89b7f56
80355 --- /dev/null
80356 +++ b/tools/gcc/constify_plugin.c
80357 @@ -0,0 +1,328 @@
80358 +/*
80359 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
80360 + * Copyright 2011 by PaX Team <pageexec@freemail.hu>
80361 + * Licensed under the GPL v2, or (at your option) v3
80362 + *
80363 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
80364 + *
80365 + * Homepage:
80366 + * http://www.grsecurity.net/~ephox/const_plugin/
80367 + *
80368 + * Usage:
80369 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
80370 + * $ gcc -fplugin=constify_plugin.so test.c -O2
80371 + */
80372 +
80373 +#include "gcc-plugin.h"
80374 +#include "config.h"
80375 +#include "system.h"
80376 +#include "coretypes.h"
80377 +#include "tree.h"
80378 +#include "tree-pass.h"
80379 +#include "flags.h"
80380 +#include "intl.h"
80381 +#include "toplev.h"
80382 +#include "plugin.h"
80383 +#include "diagnostic.h"
80384 +#include "plugin-version.h"
80385 +#include "tm.h"
80386 +#include "function.h"
80387 +#include "basic-block.h"
80388 +#include "gimple.h"
80389 +#include "rtl.h"
80390 +#include "emit-rtl.h"
80391 +#include "tree-flow.h"
80392 +
80393 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
80394 +
80395 +int plugin_is_GPL_compatible;
80396 +
80397 +static struct plugin_info const_plugin_info = {
80398 + .version = "201205300030",
80399 + .help = "no-constify\tturn off constification\n",
80400 +};
80401 +
80402 +static void deconstify_tree(tree node);
80403 +
80404 +static void deconstify_type(tree type)
80405 +{
80406 + tree field;
80407 +
80408 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
80409 + tree type = TREE_TYPE(field);
80410 +
80411 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
80412 + continue;
80413 + if (!TYPE_READONLY(type))
80414 + continue;
80415 +
80416 + deconstify_tree(field);
80417 + }
80418 + TYPE_READONLY(type) = 0;
80419 + C_TYPE_FIELDS_READONLY(type) = 0;
80420 +}
80421 +
80422 +static void deconstify_tree(tree node)
80423 +{
80424 + tree old_type, new_type, field;
80425 +
80426 + old_type = TREE_TYPE(node);
80427 +
80428 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
80429 +
80430 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
80431 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
80432 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
80433 + DECL_FIELD_CONTEXT(field) = new_type;
80434 +
80435 + deconstify_type(new_type);
80436 +
80437 + TREE_READONLY(node) = 0;
80438 + TREE_TYPE(node) = new_type;
80439 +}
80440 +
80441 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
80442 +{
80443 + tree type;
80444 +
80445 + *no_add_attrs = true;
80446 + if (TREE_CODE(*node) == FUNCTION_DECL) {
80447 + error("%qE attribute does not apply to functions", name);
80448 + return NULL_TREE;
80449 + }
80450 +
80451 + if (TREE_CODE(*node) == VAR_DECL) {
80452 + error("%qE attribute does not apply to variables", name);
80453 + return NULL_TREE;
80454 + }
80455 +
80456 + if (TYPE_P(*node)) {
80457 + if (TREE_CODE(*node) == RECORD_TYPE || TREE_CODE(*node) == UNION_TYPE)
80458 + *no_add_attrs = false;
80459 + else
80460 + error("%qE attribute applies to struct and union types only", name);
80461 + return NULL_TREE;
80462 + }
80463 +
80464 + type = TREE_TYPE(*node);
80465 +
80466 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
80467 + error("%qE attribute applies to struct and union types only", name);
80468 + return NULL_TREE;
80469 + }
80470 +
80471 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
80472 + error("%qE attribute is already applied to the type", name);
80473 + return NULL_TREE;
80474 + }
80475 +
80476 + if (TREE_CODE(*node) == TYPE_DECL && !TYPE_READONLY(type)) {
80477 + error("%qE attribute used on type that is not constified", name);
80478 + return NULL_TREE;
80479 + }
80480 +
80481 + if (TREE_CODE(*node) == TYPE_DECL) {
80482 + deconstify_tree(*node);
80483 + return NULL_TREE;
80484 + }
80485 +
80486 + return NULL_TREE;
80487 +}
80488 +
80489 +static void constify_type(tree type)
80490 +{
80491 + TYPE_READONLY(type) = 1;
80492 + C_TYPE_FIELDS_READONLY(type) = 1;
80493 +}
80494 +
80495 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
80496 +{
80497 + *no_add_attrs = true;
80498 + if (!TYPE_P(*node)) {
80499 + error("%qE attribute applies to types only", name);
80500 + return NULL_TREE;
80501 + }
80502 +
80503 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
80504 + error("%qE attribute applies to struct and union types only", name);
80505 + return NULL_TREE;
80506 + }
80507 +
80508 + *no_add_attrs = false;
80509 + constify_type(*node);
80510 + return NULL_TREE;
80511 +}
80512 +
80513 +static struct attribute_spec no_const_attr = {
80514 + .name = "no_const",
80515 + .min_length = 0,
80516 + .max_length = 0,
80517 + .decl_required = false,
80518 + .type_required = false,
80519 + .function_type_required = false,
80520 + .handler = handle_no_const_attribute,
80521 +#if BUILDING_GCC_VERSION >= 4007
80522 + .affects_type_identity = true
80523 +#endif
80524 +};
80525 +
80526 +static struct attribute_spec do_const_attr = {
80527 + .name = "do_const",
80528 + .min_length = 0,
80529 + .max_length = 0,
80530 + .decl_required = false,
80531 + .type_required = false,
80532 + .function_type_required = false,
80533 + .handler = handle_do_const_attribute,
80534 +#if BUILDING_GCC_VERSION >= 4007
80535 + .affects_type_identity = true
80536 +#endif
80537 +};
80538 +
80539 +static void register_attributes(void *event_data, void *data)
80540 +{
80541 + register_attribute(&no_const_attr);
80542 + register_attribute(&do_const_attr);
80543 +}
80544 +
80545 +static bool is_fptr(tree field)
80546 +{
80547 + tree ptr = TREE_TYPE(field);
80548 +
80549 + if (TREE_CODE(ptr) != POINTER_TYPE)
80550 + return false;
80551 +
80552 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
80553 +}
80554 +
80555 +static bool walk_struct(tree node)
80556 +{
80557 + tree field;
80558 +
80559 + if (TYPE_FIELDS(node) == NULL_TREE)
80560 + return false;
80561 +
80562 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
80563 + gcc_assert(!TYPE_READONLY(node));
80564 + deconstify_type(node);
80565 + return false;
80566 + }
80567 +
80568 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
80569 + tree type = TREE_TYPE(field);
80570 + enum tree_code code = TREE_CODE(type);
80571 + if (code == RECORD_TYPE || code == UNION_TYPE) {
80572 + if (!(walk_struct(type)))
80573 + return false;
80574 + } else if (!is_fptr(field) && !TREE_READONLY(field))
80575 + return false;
80576 + }
80577 + return true;
80578 +}
80579 +
80580 +static void finish_type(void *event_data, void *data)
80581 +{
80582 + tree type = (tree)event_data;
80583 +
80584 + if (type == NULL_TREE)
80585 + return;
80586 +
80587 + if (TYPE_READONLY(type))
80588 + return;
80589 +
80590 + if (walk_struct(type))
80591 + constify_type(type);
80592 +}
80593 +
80594 +static unsigned int check_local_variables(void);
80595 +
80596 +struct gimple_opt_pass pass_local_variable = {
80597 + {
80598 + .type = GIMPLE_PASS,
80599 + .name = "check_local_variables",
80600 + .gate = NULL,
80601 + .execute = check_local_variables,
80602 + .sub = NULL,
80603 + .next = NULL,
80604 + .static_pass_number = 0,
80605 + .tv_id = TV_NONE,
80606 + .properties_required = 0,
80607 + .properties_provided = 0,
80608 + .properties_destroyed = 0,
80609 + .todo_flags_start = 0,
80610 + .todo_flags_finish = 0
80611 + }
80612 +};
80613 +
80614 +static unsigned int check_local_variables(void)
80615 +{
80616 + tree var;
80617 + referenced_var_iterator rvi;
80618 +
80619 +#if BUILDING_GCC_VERSION == 4005
80620 + FOR_EACH_REFERENCED_VAR(var, rvi) {
80621 +#else
80622 + FOR_EACH_REFERENCED_VAR(cfun, var, rvi) {
80623 +#endif
80624 + tree type = TREE_TYPE(var);
80625 +
80626 + if (!DECL_P(var) || TREE_STATIC(var) || DECL_EXTERNAL(var))
80627 + continue;
80628 +
80629 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
80630 + continue;
80631 +
80632 + if (!TYPE_READONLY(type))
80633 + continue;
80634 +
80635 +// if (lookup_attribute("no_const", DECL_ATTRIBUTES(var)))
80636 +// continue;
80637 +
80638 +// if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
80639 +// continue;
80640 +
80641 + if (walk_struct(type)) {
80642 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
80643 + return 1;
80644 + }
80645 + }
80646 + return 0;
80647 +}
80648 +
80649 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
80650 +{
80651 + const char * const plugin_name = plugin_info->base_name;
80652 + const int argc = plugin_info->argc;
80653 + const struct plugin_argument * const argv = plugin_info->argv;
80654 + int i;
80655 + bool constify = true;
80656 +
80657 + struct register_pass_info local_variable_pass_info = {
80658 + .pass = &pass_local_variable.pass,
80659 + .reference_pass_name = "*referenced_vars",
80660 + .ref_pass_instance_number = 0,
80661 + .pos_op = PASS_POS_INSERT_AFTER
80662 + };
80663 +
80664 + if (!plugin_default_version_check(version, &gcc_version)) {
80665 + error(G_("incompatible gcc/plugin versions"));
80666 + return 1;
80667 + }
80668 +
80669 + for (i = 0; i < argc; ++i) {
80670 + if (!(strcmp(argv[i].key, "no-constify"))) {
80671 + constify = false;
80672 + continue;
80673 + }
80674 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
80675 + }
80676 +
80677 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
80678 + if (constify) {
80679 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
80680 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
80681 + }
80682 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
80683 +
80684 + return 0;
80685 +}
80686 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
80687 new file mode 100644
80688 index 0000000..a5eabce
80689 --- /dev/null
80690 +++ b/tools/gcc/kallocstat_plugin.c
80691 @@ -0,0 +1,167 @@
80692 +/*
80693 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
80694 + * Licensed under the GPL v2
80695 + *
80696 + * Note: the choice of the license means that the compilation process is
80697 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
80698 + * but for the kernel it doesn't matter since it doesn't link against
80699 + * any of the gcc libraries
80700 + *
80701 + * gcc plugin to find the distribution of k*alloc sizes
80702 + *
80703 + * TODO:
80704 + *
80705 + * BUGS:
80706 + * - none known
80707 + */
80708 +#include "gcc-plugin.h"
80709 +#include "config.h"
80710 +#include "system.h"
80711 +#include "coretypes.h"
80712 +#include "tree.h"
80713 +#include "tree-pass.h"
80714 +#include "flags.h"
80715 +#include "intl.h"
80716 +#include "toplev.h"
80717 +#include "plugin.h"
80718 +//#include "expr.h" where are you...
80719 +#include "diagnostic.h"
80720 +#include "plugin-version.h"
80721 +#include "tm.h"
80722 +#include "function.h"
80723 +#include "basic-block.h"
80724 +#include "gimple.h"
80725 +#include "rtl.h"
80726 +#include "emit-rtl.h"
80727 +
80728 +extern void print_gimple_stmt(FILE *, gimple, int, int);
80729 +
80730 +int plugin_is_GPL_compatible;
80731 +
80732 +static const char * const kalloc_functions[] = {
80733 + "__kmalloc",
80734 + "kmalloc",
80735 + "kmalloc_large",
80736 + "kmalloc_node",
80737 + "kmalloc_order",
80738 + "kmalloc_order_trace",
80739 + "kmalloc_slab",
80740 + "kzalloc",
80741 + "kzalloc_node",
80742 +};
80743 +
80744 +static struct plugin_info kallocstat_plugin_info = {
80745 + .version = "201111150100",
80746 +};
80747 +
80748 +static unsigned int execute_kallocstat(void);
80749 +
80750 +static struct gimple_opt_pass kallocstat_pass = {
80751 + .pass = {
80752 + .type = GIMPLE_PASS,
80753 + .name = "kallocstat",
80754 + .gate = NULL,
80755 + .execute = execute_kallocstat,
80756 + .sub = NULL,
80757 + .next = NULL,
80758 + .static_pass_number = 0,
80759 + .tv_id = TV_NONE,
80760 + .properties_required = 0,
80761 + .properties_provided = 0,
80762 + .properties_destroyed = 0,
80763 + .todo_flags_start = 0,
80764 + .todo_flags_finish = 0
80765 + }
80766 +};
80767 +
80768 +static bool is_kalloc(const char *fnname)
80769 +{
80770 + size_t i;
80771 +
80772 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
80773 + if (!strcmp(fnname, kalloc_functions[i]))
80774 + return true;
80775 + return false;
80776 +}
80777 +
80778 +static unsigned int execute_kallocstat(void)
80779 +{
80780 + basic_block bb;
80781 +
80782 + // 1. loop through BBs and GIMPLE statements
80783 + FOR_EACH_BB(bb) {
80784 + gimple_stmt_iterator gsi;
80785 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
80786 + // gimple match:
80787 + tree fndecl, size;
80788 + gimple call_stmt;
80789 + const char *fnname;
80790 +
80791 + // is it a call
80792 + call_stmt = gsi_stmt(gsi);
80793 + if (!is_gimple_call(call_stmt))
80794 + continue;
80795 + fndecl = gimple_call_fndecl(call_stmt);
80796 + if (fndecl == NULL_TREE)
80797 + continue;
80798 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
80799 + continue;
80800 +
80801 + // is it a call to k*alloc
80802 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
80803 + if (!is_kalloc(fnname))
80804 + continue;
80805 +
80806 + // is the size arg the result of a simple const assignment
80807 + size = gimple_call_arg(call_stmt, 0);
80808 + while (true) {
80809 + gimple def_stmt;
80810 + expanded_location xloc;
80811 + size_t size_val;
80812 +
80813 + if (TREE_CODE(size) != SSA_NAME)
80814 + break;
80815 + def_stmt = SSA_NAME_DEF_STMT(size);
80816 + if (!def_stmt || !is_gimple_assign(def_stmt))
80817 + break;
80818 + if (gimple_num_ops(def_stmt) != 2)
80819 + break;
80820 + size = gimple_assign_rhs1(def_stmt);
80821 + if (!TREE_CONSTANT(size))
80822 + continue;
80823 + xloc = expand_location(gimple_location(def_stmt));
80824 + if (!xloc.file)
80825 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
80826 + size_val = TREE_INT_CST_LOW(size);
80827 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
80828 + break;
80829 + }
80830 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
80831 +//debug_tree(gimple_call_fn(call_stmt));
80832 +//print_node(stderr, "pax", fndecl, 4);
80833 + }
80834 + }
80835 +
80836 + return 0;
80837 +}
80838 +
80839 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
80840 +{
80841 + const char * const plugin_name = plugin_info->base_name;
80842 + struct register_pass_info kallocstat_pass_info = {
80843 + .pass = &kallocstat_pass.pass,
80844 + .reference_pass_name = "ssa",
80845 + .ref_pass_instance_number = 0,
80846 + .pos_op = PASS_POS_INSERT_AFTER
80847 + };
80848 +
80849 + if (!plugin_default_version_check(version, &gcc_version)) {
80850 + error(G_("incompatible gcc/plugin versions"));
80851 + return 1;
80852 + }
80853 +
80854 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
80855 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
80856 +
80857 + return 0;
80858 +}
80859 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
80860 new file mode 100644
80861 index 0000000..d8a8da2
80862 --- /dev/null
80863 +++ b/tools/gcc/kernexec_plugin.c
80864 @@ -0,0 +1,427 @@
80865 +/*
80866 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
80867 + * Licensed under the GPL v2
80868 + *
80869 + * Note: the choice of the license means that the compilation process is
80870 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
80871 + * but for the kernel it doesn't matter since it doesn't link against
80872 + * any of the gcc libraries
80873 + *
80874 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
80875 + *
80876 + * TODO:
80877 + *
80878 + * BUGS:
80879 + * - none known
80880 + */
80881 +#include "gcc-plugin.h"
80882 +#include "config.h"
80883 +#include "system.h"
80884 +#include "coretypes.h"
80885 +#include "tree.h"
80886 +#include "tree-pass.h"
80887 +#include "flags.h"
80888 +#include "intl.h"
80889 +#include "toplev.h"
80890 +#include "plugin.h"
80891 +//#include "expr.h" where are you...
80892 +#include "diagnostic.h"
80893 +#include "plugin-version.h"
80894 +#include "tm.h"
80895 +#include "function.h"
80896 +#include "basic-block.h"
80897 +#include "gimple.h"
80898 +#include "rtl.h"
80899 +#include "emit-rtl.h"
80900 +#include "tree-flow.h"
80901 +
80902 +extern void print_gimple_stmt(FILE *, gimple, int, int);
80903 +extern rtx emit_move_insn(rtx x, rtx y);
80904 +
80905 +int plugin_is_GPL_compatible;
80906 +
80907 +static struct plugin_info kernexec_plugin_info = {
80908 + .version = "201111291120",
80909 + .help = "method=[bts|or]\tinstrumentation method\n"
80910 +};
80911 +
80912 +static unsigned int execute_kernexec_reload(void);
80913 +static unsigned int execute_kernexec_fptr(void);
80914 +static unsigned int execute_kernexec_retaddr(void);
80915 +static bool kernexec_cmodel_check(void);
80916 +
80917 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
80918 +static void (*kernexec_instrument_retaddr)(rtx);
80919 +
80920 +static struct gimple_opt_pass kernexec_reload_pass = {
80921 + .pass = {
80922 + .type = GIMPLE_PASS,
80923 + .name = "kernexec_reload",
80924 + .gate = kernexec_cmodel_check,
80925 + .execute = execute_kernexec_reload,
80926 + .sub = NULL,
80927 + .next = NULL,
80928 + .static_pass_number = 0,
80929 + .tv_id = TV_NONE,
80930 + .properties_required = 0,
80931 + .properties_provided = 0,
80932 + .properties_destroyed = 0,
80933 + .todo_flags_start = 0,
80934 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
80935 + }
80936 +};
80937 +
80938 +static struct gimple_opt_pass kernexec_fptr_pass = {
80939 + .pass = {
80940 + .type = GIMPLE_PASS,
80941 + .name = "kernexec_fptr",
80942 + .gate = kernexec_cmodel_check,
80943 + .execute = execute_kernexec_fptr,
80944 + .sub = NULL,
80945 + .next = NULL,
80946 + .static_pass_number = 0,
80947 + .tv_id = TV_NONE,
80948 + .properties_required = 0,
80949 + .properties_provided = 0,
80950 + .properties_destroyed = 0,
80951 + .todo_flags_start = 0,
80952 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
80953 + }
80954 +};
80955 +
80956 +static struct rtl_opt_pass kernexec_retaddr_pass = {
80957 + .pass = {
80958 + .type = RTL_PASS,
80959 + .name = "kernexec_retaddr",
80960 + .gate = kernexec_cmodel_check,
80961 + .execute = execute_kernexec_retaddr,
80962 + .sub = NULL,
80963 + .next = NULL,
80964 + .static_pass_number = 0,
80965 + .tv_id = TV_NONE,
80966 + .properties_required = 0,
80967 + .properties_provided = 0,
80968 + .properties_destroyed = 0,
80969 + .todo_flags_start = 0,
80970 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
80971 + }
80972 +};
80973 +
80974 +static bool kernexec_cmodel_check(void)
80975 +{
80976 + tree section;
80977 +
80978 + if (ix86_cmodel != CM_KERNEL)
80979 + return false;
80980 +
80981 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
80982 + if (!section || !TREE_VALUE(section))
80983 + return true;
80984 +
80985 + section = TREE_VALUE(TREE_VALUE(section));
80986 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
80987 + return true;
80988 +
80989 + return false;
80990 +}
80991 +
80992 +/*
80993 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
80994 + */
80995 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
80996 +{
80997 + gimple asm_movabs_stmt;
80998 +
80999 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
81000 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
81001 + gimple_asm_set_volatile(asm_movabs_stmt, true);
81002 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
81003 + update_stmt(asm_movabs_stmt);
81004 +}
81005 +
81006 +/*
81007 + * find all asm() stmts that clobber r10 and add a reload of r10
81008 + */
81009 +static unsigned int execute_kernexec_reload(void)
81010 +{
81011 + basic_block bb;
81012 +
81013 + // 1. loop through BBs and GIMPLE statements
81014 + FOR_EACH_BB(bb) {
81015 + gimple_stmt_iterator gsi;
81016 +
81017 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
81018 + // gimple match: __asm__ ("" : : : "r10");
81019 + gimple asm_stmt;
81020 + size_t nclobbers;
81021 +
81022 + // is it an asm ...
81023 + asm_stmt = gsi_stmt(gsi);
81024 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
81025 + continue;
81026 +
81027 + // ... clobbering r10
81028 + nclobbers = gimple_asm_nclobbers(asm_stmt);
81029 + while (nclobbers--) {
81030 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
81031 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
81032 + continue;
81033 + kernexec_reload_fptr_mask(&gsi);
81034 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
81035 + break;
81036 + }
81037 + }
81038 + }
81039 +
81040 + return 0;
81041 +}
81042 +
81043 +/*
81044 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
81045 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
81046 + */
81047 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
81048 +{
81049 + gimple assign_intptr, assign_new_fptr, call_stmt;
81050 + tree intptr, old_fptr, new_fptr, kernexec_mask;
81051 +
81052 + call_stmt = gsi_stmt(*gsi);
81053 + old_fptr = gimple_call_fn(call_stmt);
81054 +
81055 + // create temporary unsigned long variable used for bitops and cast fptr to it
81056 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
81057 + add_referenced_var(intptr);
81058 + mark_sym_for_renaming(intptr);
81059 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
81060 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
81061 + update_stmt(assign_intptr);
81062 +
81063 + // apply logical or to temporary unsigned long and bitmask
81064 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
81065 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
81066 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
81067 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
81068 + update_stmt(assign_intptr);
81069 +
81070 + // cast temporary unsigned long back to a temporary fptr variable
81071 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
81072 + add_referenced_var(new_fptr);
81073 + mark_sym_for_renaming(new_fptr);
81074 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
81075 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
81076 + update_stmt(assign_new_fptr);
81077 +
81078 + // replace call stmt fn with the new fptr
81079 + gimple_call_set_fn(call_stmt, new_fptr);
81080 + update_stmt(call_stmt);
81081 +}
81082 +
81083 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
81084 +{
81085 + gimple asm_or_stmt, call_stmt;
81086 + tree old_fptr, new_fptr, input, output;
81087 + VEC(tree, gc) *inputs = NULL;
81088 + VEC(tree, gc) *outputs = NULL;
81089 +
81090 + call_stmt = gsi_stmt(*gsi);
81091 + old_fptr = gimple_call_fn(call_stmt);
81092 +
81093 + // create temporary fptr variable
81094 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
81095 + add_referenced_var(new_fptr);
81096 + mark_sym_for_renaming(new_fptr);
81097 +
81098 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
81099 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
81100 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
81101 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
81102 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
81103 + VEC_safe_push(tree, gc, inputs, input);
81104 + VEC_safe_push(tree, gc, outputs, output);
81105 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
81106 + gimple_asm_set_volatile(asm_or_stmt, true);
81107 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
81108 + update_stmt(asm_or_stmt);
81109 +
81110 + // replace call stmt fn with the new fptr
81111 + gimple_call_set_fn(call_stmt, new_fptr);
81112 + update_stmt(call_stmt);
81113 +}
81114 +
81115 +/*
81116 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
81117 + */
81118 +static unsigned int execute_kernexec_fptr(void)
81119 +{
81120 + basic_block bb;
81121 +
81122 + // 1. loop through BBs and GIMPLE statements
81123 + FOR_EACH_BB(bb) {
81124 + gimple_stmt_iterator gsi;
81125 +
81126 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
81127 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
81128 + tree fn;
81129 + gimple call_stmt;
81130 +
81131 + // is it a call ...
81132 + call_stmt = gsi_stmt(gsi);
81133 + if (!is_gimple_call(call_stmt))
81134 + continue;
81135 + fn = gimple_call_fn(call_stmt);
81136 + if (TREE_CODE(fn) == ADDR_EXPR)
81137 + continue;
81138 + if (TREE_CODE(fn) != SSA_NAME)
81139 + gcc_unreachable();
81140 +
81141 + // ... through a function pointer
81142 + fn = SSA_NAME_VAR(fn);
81143 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL)
81144 + continue;
81145 + fn = TREE_TYPE(fn);
81146 + if (TREE_CODE(fn) != POINTER_TYPE)
81147 + continue;
81148 + fn = TREE_TYPE(fn);
81149 + if (TREE_CODE(fn) != FUNCTION_TYPE)
81150 + continue;
81151 +
81152 + kernexec_instrument_fptr(&gsi);
81153 +
81154 +//debug_tree(gimple_call_fn(call_stmt));
81155 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
81156 + }
81157 + }
81158 +
81159 + return 0;
81160 +}
81161 +
81162 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
81163 +static void kernexec_instrument_retaddr_bts(rtx insn)
81164 +{
81165 + rtx btsq;
81166 + rtvec argvec, constraintvec, labelvec;
81167 + int line;
81168 +
81169 + // create asm volatile("btsq $63,(%%rsp)":::)
81170 + argvec = rtvec_alloc(0);
81171 + constraintvec = rtvec_alloc(0);
81172 + labelvec = rtvec_alloc(0);
81173 + line = expand_location(RTL_LOCATION(insn)).line;
81174 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
81175 + MEM_VOLATILE_P(btsq) = 1;
81176 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
81177 + emit_insn_before(btsq, insn);
81178 +}
81179 +
81180 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
81181 +static void kernexec_instrument_retaddr_or(rtx insn)
81182 +{
81183 + rtx orq;
81184 + rtvec argvec, constraintvec, labelvec;
81185 + int line;
81186 +
81187 + // create asm volatile("orq %%r10,(%%rsp)":::)
81188 + argvec = rtvec_alloc(0);
81189 + constraintvec = rtvec_alloc(0);
81190 + labelvec = rtvec_alloc(0);
81191 + line = expand_location(RTL_LOCATION(insn)).line;
81192 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
81193 + MEM_VOLATILE_P(orq) = 1;
81194 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
81195 + emit_insn_before(orq, insn);
81196 +}
81197 +
81198 +/*
81199 + * find all asm level function returns and forcibly set the highest bit of the return address
81200 + */
81201 +static unsigned int execute_kernexec_retaddr(void)
81202 +{
81203 + rtx insn;
81204 +
81205 + // 1. find function returns
81206 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
81207 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
81208 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
81209 + rtx body;
81210 +
81211 + // is it a retn
81212 + if (!JUMP_P(insn))
81213 + continue;
81214 + body = PATTERN(insn);
81215 + if (GET_CODE(body) == PARALLEL)
81216 + body = XVECEXP(body, 0, 0);
81217 + if (GET_CODE(body) != RETURN)
81218 + continue;
81219 + kernexec_instrument_retaddr(insn);
81220 + }
81221 +
81222 +// print_simple_rtl(stderr, get_insns());
81223 +// print_rtl(stderr, get_insns());
81224 +
81225 + return 0;
81226 +}
81227 +
81228 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
81229 +{
81230 + const char * const plugin_name = plugin_info->base_name;
81231 + const int argc = plugin_info->argc;
81232 + const struct plugin_argument * const argv = plugin_info->argv;
81233 + int i;
81234 + struct register_pass_info kernexec_reload_pass_info = {
81235 + .pass = &kernexec_reload_pass.pass,
81236 + .reference_pass_name = "ssa",
81237 + .ref_pass_instance_number = 0,
81238 + .pos_op = PASS_POS_INSERT_AFTER
81239 + };
81240 + struct register_pass_info kernexec_fptr_pass_info = {
81241 + .pass = &kernexec_fptr_pass.pass,
81242 + .reference_pass_name = "ssa",
81243 + .ref_pass_instance_number = 0,
81244 + .pos_op = PASS_POS_INSERT_AFTER
81245 + };
81246 + struct register_pass_info kernexec_retaddr_pass_info = {
81247 + .pass = &kernexec_retaddr_pass.pass,
81248 + .reference_pass_name = "pro_and_epilogue",
81249 + .ref_pass_instance_number = 0,
81250 + .pos_op = PASS_POS_INSERT_AFTER
81251 + };
81252 +
81253 + if (!plugin_default_version_check(version, &gcc_version)) {
81254 + error(G_("incompatible gcc/plugin versions"));
81255 + return 1;
81256 + }
81257 +
81258 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
81259 +
81260 + if (TARGET_64BIT == 0)
81261 + return 0;
81262 +
81263 + for (i = 0; i < argc; ++i) {
81264 + if (!strcmp(argv[i].key, "method")) {
81265 + if (!argv[i].value) {
81266 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
81267 + continue;
81268 + }
81269 + if (!strcmp(argv[i].value, "bts")) {
81270 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
81271 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
81272 + } else if (!strcmp(argv[i].value, "or")) {
81273 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
81274 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
81275 + fix_register("r10", 1, 1);
81276 + } else
81277 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
81278 + continue;
81279 + }
81280 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
81281 + }
81282 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
81283 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
81284 +
81285 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
81286 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
81287 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
81288 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
81289 +
81290 + return 0;
81291 +}
81292 diff --git a/tools/gcc/size_overflow_hash.h b/tools/gcc/size_overflow_hash.h
81293 new file mode 100644
81294 index 0000000..ce7366b
81295 --- /dev/null
81296 +++ b/tools/gcc/size_overflow_hash.h
81297 @@ -0,0 +1,13933 @@
81298 +struct size_overflow_hash _000001_hash = {
81299 + .next = NULL,
81300 + .name = "alloc_dr",
81301 + .file = "drivers/base/devres.c",
81302 + .param2 = 1,
81303 +};
81304 +
81305 +struct size_overflow_hash _000002_hash = {
81306 + .next = NULL,
81307 + .name = "__copy_from_user",
81308 + .file = "arch/x86/include/asm/uaccess_32.h",
81309 + .param3 = 1,
81310 +};
81311 +
81312 +struct size_overflow_hash _000003_hash = {
81313 + .next = NULL,
81314 + .name = "copy_from_user",
81315 + .file = "arch/x86/include/asm/uaccess_32.h",
81316 + .param3 = 1,
81317 +};
81318 +
81319 +struct size_overflow_hash _000004_hash = {
81320 + .next = NULL,
81321 + .name = "__copy_from_user_inatomic",
81322 + .file = "arch/x86/include/asm/uaccess_32.h",
81323 + .param3 = 1,
81324 +};
81325 +
81326 +struct size_overflow_hash _000005_hash = {
81327 + .next = NULL,
81328 + .name = "__copy_from_user_nocache",
81329 + .file = "arch/x86/include/asm/uaccess_32.h",
81330 + .param3 = 1,
81331 +};
81332 +
81333 +struct size_overflow_hash _000006_hash = {
81334 + .next = NULL,
81335 + .name = "__copy_to_user_inatomic",
81336 + .file = "arch/x86/include/asm/uaccess_32.h",
81337 + .param3 = 1,
81338 +};
81339 +
81340 +struct size_overflow_hash _000007_hash = {
81341 + .next = NULL,
81342 + .name = "do_xip_mapping_read",
81343 + .file = "mm/filemap_xip.c",
81344 + .param5 = 1,
81345 +};
81346 +
81347 +struct size_overflow_hash _000008_hash = {
81348 + .next = NULL,
81349 + .name = "hugetlbfs_read",
81350 + .file = "fs/hugetlbfs/inode.c",
81351 + .param3 = 1,
81352 +};
81353 +
81354 +struct size_overflow_hash _000009_hash = {
81355 + .next = NULL,
81356 + .name = "kcalloc",
81357 + .file = "include/linux/slab.h",
81358 + .param1 = 1,
81359 + .param2 = 1,
81360 +};
81361 +
81362 +struct size_overflow_hash _000011_hash = {
81363 + .next = NULL,
81364 + .name = "kmalloc",
81365 + .file = "include/linux/slub_def.h",
81366 + .param1 = 1,
81367 +};
81368 +
81369 +struct size_overflow_hash _000012_hash = {
81370 + .next = NULL,
81371 + .name = "kmalloc_slab",
81372 + .file = "include/linux/slub_def.h",
81373 + .param1 = 1,
81374 +};
81375 +
81376 +struct size_overflow_hash _000013_hash = {
81377 + .next = NULL,
81378 + .name = "kmemdup",
81379 + .file = "include/linux/string.h",
81380 + .param2 = 1,
81381 +};
81382 +
81383 +struct size_overflow_hash _000014_hash = {
81384 + .next = NULL,
81385 + .name = "__krealloc",
81386 + .file = "include/linux/slab.h",
81387 + .param2 = 1,
81388 +};
81389 +
81390 +struct size_overflow_hash _000015_hash = {
81391 + .next = NULL,
81392 + .name = "memdup_user",
81393 + .file = "include/linux/string.h",
81394 + .param2 = 1,
81395 +};
81396 +
81397 +struct size_overflow_hash _000016_hash = {
81398 + .next = NULL,
81399 + .name = "module_alloc",
81400 + .file = "include/linux/moduleloader.h",
81401 + .param1 = 1,
81402 +};
81403 +
81404 +struct size_overflow_hash _000017_hash = {
81405 + .next = NULL,
81406 + .name = "read_default_ldt",
81407 + .file = "arch/x86/kernel/ldt.c",
81408 + .param2 = 1,
81409 +};
81410 +
81411 +struct size_overflow_hash _000018_hash = {
81412 + .next = NULL,
81413 + .name = "read_kcore",
81414 + .file = "fs/proc/kcore.c",
81415 + .param3 = 1,
81416 +};
81417 +
81418 +struct size_overflow_hash _000019_hash = {
81419 + .next = NULL,
81420 + .name = "read_ldt",
81421 + .file = "arch/x86/kernel/ldt.c",
81422 + .param2 = 1,
81423 +};
81424 +
81425 +struct size_overflow_hash _000020_hash = {
81426 + .next = NULL,
81427 + .name = "read_zero",
81428 + .file = "drivers/char/mem.c",
81429 + .param3 = 1,
81430 +};
81431 +
81432 +struct size_overflow_hash _000021_hash = {
81433 + .next = NULL,
81434 + .name = "__vmalloc_node",
81435 + .file = "mm/vmalloc.c",
81436 + .param1 = 1,
81437 +};
81438 +
81439 +struct size_overflow_hash _000022_hash = {
81440 + .next = NULL,
81441 + .name = "vm_map_ram",
81442 + .file = "include/linux/vmalloc.h",
81443 + .param2 = 1,
81444 +};
81445 +
81446 +struct size_overflow_hash _000023_hash = {
81447 + .next = NULL,
81448 + .name = "aa_simple_write_to_buffer",
81449 + .file = "security/apparmor/apparmorfs.c",
81450 + .param4 = 1,
81451 +};
81452 +
81453 +struct size_overflow_hash _000024_hash = {
81454 + .next = NULL,
81455 + .name = "ablkcipher_copy_iv",
81456 + .file = "crypto/ablkcipher.c",
81457 + .param3 = 1,
81458 +};
81459 +
81460 +struct size_overflow_hash _000025_hash = {
81461 + .next = NULL,
81462 + .name = "ablkcipher_next_slow",
81463 + .file = "crypto/ablkcipher.c",
81464 + .param4 = 1,
81465 +};
81466 +
81467 +struct size_overflow_hash _000026_hash = {
81468 + .next = NULL,
81469 + .name = "acpi_os_allocate",
81470 + .file = "include/acpi/platform/aclinux.h",
81471 + .param1 = 1,
81472 +};
81473 +
81474 +struct size_overflow_hash _000027_hash = {
81475 + .next = NULL,
81476 + .name = "acpi_system_write_wakeup_device",
81477 + .file = "drivers/acpi/proc.c",
81478 + .param3 = 1,
81479 +};
81480 +
81481 +struct size_overflow_hash _000028_hash = {
81482 + .next = NULL,
81483 + .name = "ahash_setkey_unaligned",
81484 + .file = "crypto/ahash.c",
81485 + .param3 = 1,
81486 +};
81487 +
81488 +struct size_overflow_hash _000029_hash = {
81489 + .next = NULL,
81490 + .name = "alloc_fdmem",
81491 + .file = "fs/file.c",
81492 + .param1 = 1,
81493 +};
81494 +
81495 +struct size_overflow_hash _000030_hash = {
81496 + .next = NULL,
81497 + .name = "audit_unpack_string",
81498 + .file = "kernel/auditfilter.c",
81499 + .param3 = 1,
81500 +};
81501 +
81502 +struct size_overflow_hash _000031_hash = {
81503 + .next = NULL,
81504 + .name = "bio_alloc_map_data",
81505 + .file = "fs/bio.c",
81506 + .param2 = 1,
81507 +};
81508 +
81509 +struct size_overflow_hash _000032_hash = {
81510 + .next = NULL,
81511 + .name = "bio_kmalloc",
81512 + .file = "include/linux/bio.h",
81513 + .param2 = 1,
81514 +};
81515 +
81516 +struct size_overflow_hash _000033_hash = {
81517 + .next = NULL,
81518 + .name = "blkcipher_copy_iv",
81519 + .file = "crypto/blkcipher.c",
81520 + .param3 = 1,
81521 +};
81522 +
81523 +struct size_overflow_hash _000034_hash = {
81524 + .next = NULL,
81525 + .name = "blkcipher_next_slow",
81526 + .file = "crypto/blkcipher.c",
81527 + .param4 = 1,
81528 +};
81529 +
81530 +struct size_overflow_hash _000035_hash = {
81531 + .next = NULL,
81532 + .name = "cgroup_write_string",
81533 + .file = "kernel/cgroup.c",
81534 + .param5 = 1,
81535 +};
81536 +
81537 +struct size_overflow_hash _000036_hash = {
81538 + .next = NULL,
81539 + .name = "cgroup_write_X64",
81540 + .file = "kernel/cgroup.c",
81541 + .param5 = 1,
81542 +};
81543 +
81544 +struct size_overflow_hash _000037_hash = {
81545 + .next = NULL,
81546 + .name = "clear_refs_write",
81547 + .file = "fs/proc/task_mmu.c",
81548 + .param3 = 1,
81549 +};
81550 +
81551 +struct size_overflow_hash _000038_hash = {
81552 + .next = NULL,
81553 + .name = "comm_write",
81554 + .file = "fs/proc/base.c",
81555 + .param3 = 1,
81556 +};
81557 +
81558 +struct size_overflow_hash _000039_hash = {
81559 + .next = NULL,
81560 + .name = "copy_and_check",
81561 + .file = "kernel/module.c",
81562 + .param3 = 1,
81563 +};
81564 +
81565 +struct size_overflow_hash _000040_hash = {
81566 + .next = NULL,
81567 + .name = "__copy_to_user",
81568 + .file = "arch/x86/include/asm/uaccess_32.h",
81569 + .param3 = 1,
81570 +};
81571 +
81572 +struct size_overflow_hash _000041_hash = {
81573 + .next = NULL,
81574 + .name = "copy_vm86_regs_from_user",
81575 + .file = "arch/x86/kernel/vm86_32.c",
81576 + .param3 = 1,
81577 +};
81578 +
81579 +struct size_overflow_hash _000042_hash = {
81580 + .next = NULL,
81581 + .name = "csum_partial_copy_fromiovecend",
81582 + .file = "include/linux/socket.h",
81583 + .param4 = 1,
81584 +};
81585 +
81586 +struct size_overflow_hash _000043_hash = {
81587 + .next = NULL,
81588 + .name = "ddebug_proc_write",
81589 + .file = "lib/dynamic_debug.c",
81590 + .param3 = 1,
81591 +};
81592 +
81593 +struct size_overflow_hash _000044_hash = {
81594 + .next = NULL,
81595 + .name = "devm_kzalloc",
81596 + .file = "include/linux/device.h",
81597 + .param2 = 1,
81598 +};
81599 +
81600 +struct size_overflow_hash _000045_hash = {
81601 + .next = NULL,
81602 + .name = "devres_alloc",
81603 + .file = "include/linux/device.h",
81604 + .param2 = 1,
81605 +};
81606 +
81607 +struct size_overflow_hash _000046_hash = {
81608 + .next = NULL,
81609 + .name = "do_ip_setsockopt",
81610 + .file = "net/ipv4/ip_sockglue.c",
81611 + .param5 = 1,
81612 +};
81613 +
81614 +struct size_overflow_hash _000047_hash = {
81615 + .next = NULL,
81616 + .name = "do_kimage_alloc",
81617 + .file = "kernel/kexec.c",
81618 + .param3 = 1,
81619 +};
81620 +
81621 +struct size_overflow_hash _000048_hash = {
81622 + .next = NULL,
81623 + .name = "do_tty_write",
81624 + .file = "drivers/tty/tty_io.c",
81625 + .param5 = 1,
81626 +};
81627 +
81628 +struct size_overflow_hash _000049_hash = {
81629 + .next = NULL,
81630 + .name = "fanotify_write",
81631 + .file = "fs/notify/fanotify/fanotify_user.c",
81632 + .param3 = 1,
81633 +};
81634 +
81635 +struct size_overflow_hash _000050_hash = {
81636 + .next = NULL,
81637 + .name = "file_read_actor",
81638 + .file = "include/linux/fs.h",
81639 + .param4 = 1,
81640 +};
81641 +
81642 +struct size_overflow_hash _000051_hash = {
81643 + .next = NULL,
81644 + .name = "fill_write_buffer",
81645 + .file = "fs/sysfs/file.c",
81646 + .param3 = 1,
81647 +};
81648 +
81649 +struct size_overflow_hash _000052_hash = {
81650 + .next = NULL,
81651 + .name = "get_user_cpu_mask",
81652 + .file = "kernel/sched/core.c",
81653 + .param2 = 1,
81654 +};
81655 +
81656 +struct size_overflow_hash _000053_hash = {
81657 + .next = NULL,
81658 + .name = "hashtab_create",
81659 + .file = "security/selinux/ss/hashtab.c",
81660 + .param3 = 1,
81661 +};
81662 +
81663 +struct size_overflow_hash _000054_hash = {
81664 + .next = NULL,
81665 + .name = "heap_init",
81666 + .file = "include/linux/prio_heap.h",
81667 + .param2 = 1,
81668 +};
81669 +
81670 +struct size_overflow_hash _000055_hash = {
81671 + .next = NULL,
81672 + .name = "hest_ghes_dev_register",
81673 + .file = "drivers/acpi/apei/hest.c",
81674 + .param1 = 1,
81675 +};
81676 +
81677 +struct size_overflow_hash _000056_hash = {
81678 + .next = NULL,
81679 + .name = "ima_write_policy",
81680 + .file = "security/integrity/ima/ima_fs.c",
81681 + .param3 = 1,
81682 +};
81683 +
81684 +struct size_overflow_hash _000057_hash = {
81685 + .next = NULL,
81686 + .name = "input_ff_create",
81687 + .file = "include/linux/input.h",
81688 + .param2 = 1,
81689 +};
81690 +
81691 +struct size_overflow_hash _000058_hash = {
81692 + .next = NULL,
81693 + .name = "input_mt_init_slots",
81694 + .file = "include/linux/input/mt.h",
81695 + .param2 = 1,
81696 +};
81697 +
81698 +struct size_overflow_hash _000059_hash = {
81699 + .next = NULL,
81700 + .name = "iov_iter_copy_from_user",
81701 + .file = "include/linux/fs.h",
81702 + .param4 = 1,
81703 +};
81704 +
81705 +struct size_overflow_hash _000060_hash = {
81706 + .next = NULL,
81707 + .name = "iov_iter_copy_from_user_atomic",
81708 + .file = "include/linux/fs.h",
81709 + .param4 = 1,
81710 +};
81711 +
81712 +struct size_overflow_hash _000061_hash = {
81713 + .next = NULL,
81714 + .name = "keyctl_instantiate_key_common",
81715 + .file = "security/keys/keyctl.c",
81716 + .param4 = 1,
81717 +};
81718 +
81719 +struct size_overflow_hash _000062_hash = {
81720 + .next = NULL,
81721 + .name = "keyctl_update_key",
81722 + .file = "security/keys/keyctl.c",
81723 + .param3 = 1,
81724 +};
81725 +
81726 +struct size_overflow_hash _000063_hash = {
81727 + .next = NULL,
81728 + .name = "__kfifo_alloc",
81729 + .file = "include/linux/kfifo.h",
81730 + .param2 = 1,
81731 + .param3 = 1,
81732 +};
81733 +
81734 +struct size_overflow_hash _000065_hash = {
81735 + .next = NULL,
81736 + .name = "kfifo_copy_from_user",
81737 + .file = "kernel/kfifo.c",
81738 + .param3 = 1,
81739 +};
81740 +
81741 +struct size_overflow_hash _000066_hash = {
81742 + .next = NULL,
81743 + .name = "kmalloc_node",
81744 + .file = "include/linux/slab.h",
81745 + .param1 = 1,
81746 +};
81747 +
81748 +struct size_overflow_hash _000067_hash = {
81749 + .next = NULL,
81750 + .name = "kmalloc_parameter",
81751 + .file = "kernel/params.c",
81752 + .param1 = 1,
81753 +};
81754 +
81755 +struct size_overflow_hash _000068_hash = {
81756 + .next = NULL,
81757 + .name = "kobj_map",
81758 + .file = "include/linux/kobj_map.h",
81759 + .param2 = 1,
81760 + .param3 = 1,
81761 +};
81762 +
81763 +struct size_overflow_hash _000070_hash = {
81764 + .next = NULL,
81765 + .name = "krealloc",
81766 + .file = "include/linux/slab.h",
81767 + .param2 = 1,
81768 +};
81769 +
81770 +struct size_overflow_hash _000071_hash = {
81771 + .next = NULL,
81772 + .name = "kvmalloc",
81773 + .file = "security/apparmor/lib.c",
81774 + .param1 = 1,
81775 +};
81776 +
81777 +struct size_overflow_hash _000072_hash = {
81778 + .next = NULL,
81779 + .name = "kzalloc",
81780 + .file = "include/linux/slab.h",
81781 + .param1 = 1,
81782 +};
81783 +
81784 +struct size_overflow_hash _000073_hash = {
81785 + .next = NULL,
81786 + .name = "listxattr",
81787 + .file = "fs/xattr.c",
81788 + .param3 = 1,
81789 +};
81790 +
81791 +struct size_overflow_hash _000074_hash = {
81792 + .next = NULL,
81793 + .name = "mempool_kmalloc",
81794 + .file = "include/linux/mempool.h",
81795 + .param2 = 1,
81796 +};
81797 +
81798 +struct size_overflow_hash _000075_hash = {
81799 + .next = NULL,
81800 + .name = "mem_rw",
81801 + .file = "fs/proc/base.c",
81802 + .param3 = 1,
81803 +};
81804 +
81805 +struct size_overflow_hash _000076_hash = {
81806 + .next = NULL,
81807 + .name = "module_alloc_update_bounds",
81808 + .file = "kernel/module.c",
81809 + .param1 = 1,
81810 +};
81811 +
81812 +struct size_overflow_hash _000077_hash = {
81813 + .next = NULL,
81814 + .name = "mpi_alloc_limb_space",
81815 + .file = "lib/mpi/mpiutil.c",
81816 + .param1 = 1,
81817 +};
81818 +
81819 +struct size_overflow_hash _000078_hash = {
81820 + .next = NULL,
81821 + .name = "mpi_resize",
81822 + .file = "include/linux/mpi.h",
81823 + .param2 = 1,
81824 +};
81825 +
81826 +struct size_overflow_hash _000079_hash = {
81827 + .next = NULL,
81828 + .name = "mtrr_write",
81829 + .file = "arch/x86/kernel/cpu/mtrr/if.c",
81830 + .param3 = 1,
81831 +};
81832 +
81833 +struct size_overflow_hash _000080_hash = {
81834 + .next = NULL,
81835 + .name = "oom_adjust_write",
81836 + .file = "fs/proc/base.c",
81837 + .param3 = 1,
81838 +};
81839 +
81840 +struct size_overflow_hash _000081_hash = {
81841 + .next = NULL,
81842 + .name = "oom_score_adj_write",
81843 + .file = "fs/proc/base.c",
81844 + .param3 = 1,
81845 +};
81846 +
81847 +struct size_overflow_hash _000082_hash = {
81848 + .next = NULL,
81849 + .name = "pipe_iov_copy_from_user",
81850 + .file = "fs/pipe.c",
81851 + .param3 = 1,
81852 +};
81853 +
81854 +struct size_overflow_hash _000083_hash = {
81855 + .next = NULL,
81856 + .name = "pipe_iov_copy_to_user",
81857 + .file = "fs/pipe.c",
81858 + .param3 = 1,
81859 +};
81860 +
81861 +struct size_overflow_hash _000084_hash = {
81862 + .next = NULL,
81863 + .name = "pipe_set_size",
81864 + .file = "fs/pipe.c",
81865 + .param2 = 1,
81866 +};
81867 +
81868 +struct size_overflow_hash _000085_hash = {
81869 + .next = NULL,
81870 + .name = "platform_device_add_data",
81871 + .file = "include/linux/platform_device.h",
81872 + .param3 = 1,
81873 +};
81874 +
81875 +struct size_overflow_hash _000086_hash = {
81876 + .next = NULL,
81877 + .name = "platform_device_add_resources",
81878 + .file = "include/linux/platform_device.h",
81879 + .param3 = 1,
81880 +};
81881 +
81882 +struct size_overflow_hash _000087_hash = {
81883 + .next = NULL,
81884 + .name = "pm_qos_power_write",
81885 + .file = "kernel/power/qos.c",
81886 + .param3 = 1,
81887 +};
81888 +
81889 +struct size_overflow_hash _000088_hash = {
81890 + .next = NULL,
81891 + .name = "pnpbios_proc_write",
81892 + .file = "drivers/pnp/pnpbios/proc.c",
81893 + .param3 = 1,
81894 +};
81895 +
81896 +struct size_overflow_hash _000089_hash = {
81897 + .next = NULL,
81898 + .name = "__probe_kernel_read",
81899 + .file = "include/linux/uaccess.h",
81900 + .param3 = 1,
81901 +};
81902 +
81903 +struct size_overflow_hash _000090_hash = {
81904 + .next = NULL,
81905 + .name = "__probe_kernel_write",
81906 + .file = "include/linux/uaccess.h",
81907 + .param3 = 1,
81908 +};
81909 +
81910 +struct size_overflow_hash _000091_hash = {
81911 + .next = NULL,
81912 + .name = "proc_coredump_filter_write",
81913 + .file = "fs/proc/base.c",
81914 + .param3 = 1,
81915 +};
81916 +
81917 +struct size_overflow_hash _000092_hash = {
81918 + .next = NULL,
81919 + .name = "process_vm_rw_pages",
81920 + .file = "mm/process_vm_access.c",
81921 + .param5 = 1,
81922 + .param6 = 1,
81923 +};
81924 +
81925 +struct size_overflow_hash _000094_hash = {
81926 + .next = NULL,
81927 + .name = "proc_loginuid_write",
81928 + .file = "fs/proc/base.c",
81929 + .param3 = 1,
81930 +};
81931 +
81932 +struct size_overflow_hash _000095_hash = {
81933 + .next = NULL,
81934 + .name = "proc_pid_attr_write",
81935 + .file = "fs/proc/base.c",
81936 + .param3 = 1,
81937 +};
81938 +
81939 +struct size_overflow_hash _000096_hash = {
81940 + .next = NULL,
81941 + .name = "pstore_mkfile",
81942 + .file = "fs/pstore/inode.c",
81943 + .param5 = 1,
81944 +};
81945 +
81946 +struct size_overflow_hash _000097_hash = {
81947 + .next = NULL,
81948 + .name = "qdisc_class_hash_alloc",
81949 + .file = "net/sched/sch_api.c",
81950 + .param1 = 1,
81951 +};
81952 +
81953 +struct size_overflow_hash _000098_hash = {
81954 + .next = NULL,
81955 + .name = "read",
81956 + .file = "fs/sysfs/bin.c",
81957 + .param3 = 1,
81958 +};
81959 +
81960 +struct size_overflow_hash _000099_hash = {
81961 + .next = NULL,
81962 + .name = "regmap_access_read_file",
81963 + .file = "drivers/base/regmap/regmap-debugfs.c",
81964 + .param3 = 1,
81965 +};
81966 +
81967 +struct size_overflow_hash _000100_hash = {
81968 + .next = NULL,
81969 + .name = "regmap_map_read_file",
81970 + .file = "drivers/base/regmap/regmap-debugfs.c",
81971 + .param3 = 1,
81972 +};
81973 +
81974 +struct size_overflow_hash _000101_hash = {
81975 + .next = NULL,
81976 + .name = "_regmap_raw_write",
81977 + .file = "drivers/base/regmap/regmap.c",
81978 + .param4 = 1,
81979 +};
81980 +
81981 +struct size_overflow_hash _000102_hash = {
81982 + .next = NULL,
81983 + .name = "regset_tls_set",
81984 + .file = "arch/x86/kernel/tls.c",
81985 + .param4 = 1,
81986 +};
81987 +
81988 +struct size_overflow_hash _000103_hash = {
81989 + .next = NULL,
81990 + .name = "request_key_auth_new",
81991 + .file = "security/keys/request_key_auth.c",
81992 + .param3 = 1,
81993 +};
81994 +
81995 +struct size_overflow_hash _000104_hash = {
81996 + .next = NULL,
81997 + .name = "restore_i387_fxsave",
81998 + .file = "arch/x86/kernel/i387.c",
81999 + .param2 = 1,
82000 +};
82001 +
82002 +struct size_overflow_hash _000105_hash = {
82003 + .next = NULL,
82004 + .name = "rngapi_reset",
82005 + .file = "crypto/rng.c",
82006 + .param3 = 1,
82007 +};
82008 +
82009 +struct size_overflow_hash _000106_hash = {
82010 + .next = NULL,
82011 + .name = "rw_copy_check_uvector",
82012 + .file = "include/linux/fs.h",
82013 + .param3 = 1,
82014 +};
82015 +
82016 +struct size_overflow_hash _000107_hash = {
82017 + .next = NULL,
82018 + .name = "sched_autogroup_write",
82019 + .file = "fs/proc/base.c",
82020 + .param3 = 1,
82021 +};
82022 +
82023 +struct size_overflow_hash _000108_hash = {
82024 + .next = NULL,
82025 + .name = "security_context_to_sid_core",
82026 + .file = "security/selinux/ss/services.c",
82027 + .param2 = 1,
82028 +};
82029 +
82030 +struct size_overflow_hash _000109_hash = {
82031 + .next = NULL,
82032 + .name = "sel_commit_bools_write",
82033 + .file = "security/selinux/selinuxfs.c",
82034 + .param3 = 1,
82035 +};
82036 +
82037 +struct size_overflow_hash _000110_hash = {
82038 + .next = NULL,
82039 + .name = "sel_write_avc_cache_threshold",
82040 + .file = "security/selinux/selinuxfs.c",
82041 + .param3 = 1,
82042 +};
82043 +
82044 +struct size_overflow_hash _000111_hash = {
82045 + .next = NULL,
82046 + .name = "sel_write_bool",
82047 + .file = "security/selinux/selinuxfs.c",
82048 + .param3 = 1,
82049 +};
82050 +
82051 +struct size_overflow_hash _000112_hash = {
82052 + .next = NULL,
82053 + .name = "sel_write_checkreqprot",
82054 + .file = "security/selinux/selinuxfs.c",
82055 + .param3 = 1,
82056 +};
82057 +
82058 +struct size_overflow_hash _000113_hash = {
82059 + .next = NULL,
82060 + .name = "sel_write_disable",
82061 + .file = "security/selinux/selinuxfs.c",
82062 + .param3 = 1,
82063 +};
82064 +
82065 +struct size_overflow_hash _000114_hash = {
82066 + .next = NULL,
82067 + .name = "sel_write_enforce",
82068 + .file = "security/selinux/selinuxfs.c",
82069 + .param3 = 1,
82070 +};
82071 +
82072 +struct size_overflow_hash _000115_hash = {
82073 + .next = NULL,
82074 + .name = "sel_write_load",
82075 + .file = "security/selinux/selinuxfs.c",
82076 + .param3 = 1,
82077 +};
82078 +
82079 +struct size_overflow_hash _000116_hash = {
82080 + .next = NULL,
82081 + .name = "setkey_unaligned",
82082 + .file = "crypto/ablkcipher.c",
82083 + .param3 = 1,
82084 +};
82085 +
82086 +struct size_overflow_hash _000117_hash = {
82087 + .next = NULL,
82088 + .name = "setkey_unaligned",
82089 + .file = "crypto/blkcipher.c",
82090 + .param3 = 1,
82091 +};
82092 +
82093 +struct size_overflow_hash _000118_hash = {
82094 + .next = NULL,
82095 + .name = "setkey_unaligned",
82096 + .file = "crypto/aead.c",
82097 + .param3 = 1,
82098 +};
82099 +
82100 +struct size_overflow_hash _000119_hash = {
82101 + .next = NULL,
82102 + .name = "setkey_unaligned",
82103 + .file = "crypto/cipher.c",
82104 + .param3 = 1,
82105 +};
82106 +
82107 +struct size_overflow_hash _000120_hash = {
82108 + .next = NULL,
82109 + .name = "setxattr",
82110 + .file = "fs/xattr.c",
82111 + .param4 = 1,
82112 +};
82113 +
82114 +struct size_overflow_hash _000121_hash = {
82115 + .next = NULL,
82116 + .name = "sg_kmalloc",
82117 + .file = "lib/scatterlist.c",
82118 + .param1 = 1,
82119 +};
82120 +
82121 +struct size_overflow_hash _000122_hash = {
82122 + .next = NULL,
82123 + .name = "shash_setkey_unaligned",
82124 + .file = "crypto/shash.c",
82125 + .param3 = 1,
82126 +};
82127 +
82128 +struct size_overflow_hash _000123_hash = {
82129 + .next = NULL,
82130 + .name = "shmem_xattr_set",
82131 + .file = "mm/shmem.c",
82132 + .param4 = 1,
82133 +};
82134 +
82135 +struct size_overflow_hash _000124_hash = {
82136 + .next = NULL,
82137 + .name = "simple_transaction_get",
82138 + .file = "include/linux/fs.h",
82139 + .param3 = 1,
82140 +};
82141 +
82142 +struct size_overflow_hash _000125_hash = {
82143 + .next = NULL,
82144 + .name = "simple_write_to_buffer",
82145 + .file = "include/linux/fs.h",
82146 + .param2 = 1,
82147 + .param5 = 1,
82148 +};
82149 +
82150 +struct size_overflow_hash _000127_hash = {
82151 + .next = NULL,
82152 + .name = "smk_write_ambient",
82153 + .file = "security/smack/smackfs.c",
82154 + .param3 = 1,
82155 +};
82156 +
82157 +struct size_overflow_hash _000128_hash = {
82158 + .next = NULL,
82159 + .name = "smk_write_cipso",
82160 + .file = "security/smack/smackfs.c",
82161 + .param3 = 1,
82162 +};
82163 +
82164 +struct size_overflow_hash _000129_hash = {
82165 + .next = NULL,
82166 + .name = "smk_write_direct",
82167 + .file = "security/smack/smackfs.c",
82168 + .param3 = 1,
82169 +};
82170 +
82171 +struct size_overflow_hash _000130_hash = {
82172 + .next = NULL,
82173 + .name = "smk_write_doi",
82174 + .file = "security/smack/smackfs.c",
82175 + .param3 = 1,
82176 +};
82177 +
82178 +struct size_overflow_hash _000131_hash = {
82179 + .next = NULL,
82180 + .name = "smk_write_load_list",
82181 + .file = "security/smack/smackfs.c",
82182 + .param3 = 1,
82183 +};
82184 +
82185 +struct size_overflow_hash _000132_hash = {
82186 + .next = &_000102_hash,
82187 + .name = "smk_write_logging",
82188 + .file = "security/smack/smackfs.c",
82189 + .param3 = 1,
82190 +};
82191 +
82192 +struct size_overflow_hash _000133_hash = {
82193 + .next = NULL,
82194 + .name = "smk_write_netlbladdr",
82195 + .file = "security/smack/smackfs.c",
82196 + .param3 = 1,
82197 +};
82198 +
82199 +struct size_overflow_hash _000134_hash = {
82200 + .next = NULL,
82201 + .name = "smk_write_onlycap",
82202 + .file = "security/smack/smackfs.c",
82203 + .param3 = 1,
82204 +};
82205 +
82206 +struct size_overflow_hash _000135_hash = {
82207 + .next = NULL,
82208 + .name = "sys_add_key",
82209 + .file = "include/linux/syscalls.h",
82210 + .param4 = 1,
82211 +};
82212 +
82213 +struct size_overflow_hash _000136_hash = {
82214 + .next = NULL,
82215 + .name = "sys_modify_ldt",
82216 + .file = "arch/x86/include/asm/syscalls.h",
82217 + .param3 = 1,
82218 +};
82219 +
82220 +struct size_overflow_hash _000137_hash = {
82221 + .next = NULL,
82222 + .name = "sys_semtimedop",
82223 + .file = "include/linux/syscalls.h",
82224 + .param3 = 1,
82225 +};
82226 +
82227 +struct size_overflow_hash _000138_hash = {
82228 + .next = NULL,
82229 + .name = "tomoyo_write_self",
82230 + .file = "security/tomoyo/securityfs_if.c",
82231 + .param3 = 1,
82232 +};
82233 +
82234 +struct size_overflow_hash _000139_hash = {
82235 + .next = NULL,
82236 + .name = "tpm_write",
82237 + .file = "drivers/char/tpm/tpm.c",
82238 + .param3 = 1,
82239 +};
82240 +
82241 +struct size_overflow_hash _000140_hash = {
82242 + .next = NULL,
82243 + .name = "tty_buffer_alloc",
82244 + .file = "drivers/tty/tty_buffer.c",
82245 + .param2 = 1,
82246 +};
82247 +
82248 +struct size_overflow_hash _000141_hash = {
82249 + .next = NULL,
82250 + .name = "user_instantiate",
82251 + .file = "include/keys/user-type.h",
82252 + .param3 = 1,
82253 +};
82254 +
82255 +struct size_overflow_hash _000142_hash = {
82256 + .next = NULL,
82257 + .name = "user_update",
82258 + .file = "include/keys/user-type.h",
82259 + .param3 = 1,
82260 +};
82261 +
82262 +struct size_overflow_hash _000143_hash = {
82263 + .next = NULL,
82264 + .name = "vc_do_resize",
82265 + .file = "drivers/tty/vt/vt.c",
82266 + .param3 = 1,
82267 + .param4 = 1,
82268 +};
82269 +
82270 +struct size_overflow_hash _000145_hash = {
82271 + .next = NULL,
82272 + .name = "vcs_write",
82273 + .file = "drivers/tty/vt/vc_screen.c",
82274 + .param3 = 1,
82275 +};
82276 +
82277 +struct size_overflow_hash _000146_hash = {
82278 + .next = NULL,
82279 + .name = "vga_arb_write",
82280 + .file = "drivers/gpu/vga/vgaarb.c",
82281 + .param3 = 1,
82282 +};
82283 +
82284 +struct size_overflow_hash _000147_hash = {
82285 + .next = NULL,
82286 + .name = "vga_switcheroo_debugfs_write",
82287 + .file = "drivers/gpu/vga/vga_switcheroo.c",
82288 + .param3 = 1,
82289 +};
82290 +
82291 +struct size_overflow_hash _000148_hash = {
82292 + .next = NULL,
82293 + .name = "__vmalloc",
82294 + .file = "include/linux/vmalloc.h",
82295 + .param1 = 1,
82296 +};
82297 +
82298 +struct size_overflow_hash _000149_hash = {
82299 + .next = NULL,
82300 + .name = "vmalloc_32",
82301 + .file = "include/linux/vmalloc.h",
82302 + .param1 = 1,
82303 +};
82304 +
82305 +struct size_overflow_hash _000150_hash = {
82306 + .next = NULL,
82307 + .name = "vmalloc_32_user",
82308 + .file = "include/linux/vmalloc.h",
82309 + .param1 = 1,
82310 +};
82311 +
82312 +struct size_overflow_hash _000151_hash = {
82313 + .next = NULL,
82314 + .name = "vmalloc_exec",
82315 + .file = "include/linux/vmalloc.h",
82316 + .param1 = 1,
82317 +};
82318 +
82319 +struct size_overflow_hash _000152_hash = {
82320 + .next = NULL,
82321 + .name = "vmalloc_node",
82322 + .file = "include/linux/vmalloc.h",
82323 + .param1 = 1,
82324 +};
82325 +
82326 +struct size_overflow_hash _000153_hash = {
82327 + .next = NULL,
82328 + .name = "__vmalloc_node_flags",
82329 + .file = "mm/vmalloc.c",
82330 + .param1 = 1,
82331 +};
82332 +
82333 +struct size_overflow_hash _000154_hash = {
82334 + .next = NULL,
82335 + .name = "vmalloc_user",
82336 + .file = "include/linux/vmalloc.h",
82337 + .param1 = 1,
82338 +};
82339 +
82340 +struct size_overflow_hash _000155_hash = {
82341 + .next = NULL,
82342 + .name = "write",
82343 + .file = "fs/sysfs/bin.c",
82344 + .param3 = 1,
82345 +};
82346 +
82347 +struct size_overflow_hash _000156_hash = {
82348 + .next = NULL,
82349 + .name = "__xip_file_write",
82350 + .file = "mm/filemap_xip.c",
82351 + .param3 = 1,
82352 +};
82353 +
82354 +struct size_overflow_hash _000157_hash = {
82355 + .next = NULL,
82356 + .name = "acpi_ex_allocate_name_string",
82357 + .file = "drivers/acpi/acpica/exnames.c",
82358 + .param2 = 1,
82359 +};
82360 +
82361 +struct size_overflow_hash _000158_hash = {
82362 + .next = NULL,
82363 + .name = "acpi_os_allocate_zeroed",
82364 + .file = "include/acpi/platform/aclinux.h",
82365 + .param1 = 1,
82366 +};
82367 +
82368 +struct size_overflow_hash _000159_hash = {
82369 + .next = NULL,
82370 + .name = "acpi_ut_initialize_buffer",
82371 + .file = "drivers/acpi/acpica/utalloc.c",
82372 + .param2 = 1,
82373 +};
82374 +
82375 +struct size_overflow_hash _000160_hash = {
82376 + .next = NULL,
82377 + .name = "add_numbered_child",
82378 + .file = "drivers/mfd/twl-core.c",
82379 + .param5 = 1,
82380 +};
82381 +
82382 +struct size_overflow_hash _000161_hash = {
82383 + .next = NULL,
82384 + .name = "___alloc_bootmem_nopanic",
82385 + .file = "mm/nobootmem.c",
82386 + .param1 = 1,
82387 +};
82388 +
82389 +struct size_overflow_hash _000162_hash = {
82390 + .next = NULL,
82391 + .name = "alloc_large_system_hash",
82392 + .file = "include/linux/bootmem.h",
82393 + .param2 = 1,
82394 +};
82395 +
82396 +struct size_overflow_hash _000163_hash = {
82397 + .next = NULL,
82398 + .name = "audit_init_entry",
82399 + .file = "kernel/auditfilter.c",
82400 + .param1 = 1,
82401 +};
82402 +
82403 +struct size_overflow_hash _000164_hash = {
82404 + .next = NULL,
82405 + .name = "__bio_map_kern",
82406 + .file = "fs/bio.c",
82407 + .param2 = 1,
82408 + .param3 = 1,
82409 +};
82410 +
82411 +struct size_overflow_hash _000166_hash = {
82412 + .next = NULL,
82413 + .name = "blk_register_region",
82414 + .file = "include/linux/genhd.h",
82415 + .param1 = 1,
82416 + .param2 = 1,
82417 +};
82418 +
82419 +struct size_overflow_hash _000168_hash = {
82420 + .next = NULL,
82421 + .name = "cdev_add",
82422 + .file = "include/linux/cdev.h",
82423 + .param2 = 1,
82424 + .param3 = 1,
82425 +};
82426 +
82427 +struct size_overflow_hash _000170_hash = {
82428 + .next = NULL,
82429 + .name = "copy_to_user",
82430 + .file = "arch/x86/include/asm/uaccess_32.h",
82431 + .param3 = 1,
82432 +};
82433 +
82434 +struct size_overflow_hash _000171_hash = {
82435 + .next = NULL,
82436 + .name = "crypto_ahash_setkey",
82437 + .file = "include/crypto/hash.h",
82438 + .param3 = 1,
82439 +};
82440 +
82441 +struct size_overflow_hash _000172_hash = {
82442 + .next = NULL,
82443 + .name = "crypto_alloc_instance2",
82444 + .file = "include/crypto/algapi.h",
82445 + .param3 = 1,
82446 +};
82447 +
82448 +struct size_overflow_hash _000173_hash = {
82449 + .next = NULL,
82450 + .name = "crypto_shash_setkey",
82451 + .file = "include/crypto/hash.h",
82452 + .param3 = 1,
82453 +};
82454 +
82455 +struct size_overflow_hash _000174_hash = {
82456 + .next = NULL,
82457 + .name = "dev_set_alias",
82458 + .file = "include/linux/netdevice.h",
82459 + .param3 = 1,
82460 +};
82461 +
82462 +struct size_overflow_hash _000175_hash = {
82463 + .next = NULL,
82464 + .name = "do_readv_writev",
82465 + .file = "fs/read_write.c",
82466 + .param4 = 1,
82467 +};
82468 +
82469 +struct size_overflow_hash _000176_hash = {
82470 + .next = NULL,
82471 + .name = "getxattr",
82472 + .file = "fs/xattr.c",
82473 + .param4 = 1,
82474 +};
82475 +
82476 +struct size_overflow_hash _000177_hash = {
82477 + .next = NULL,
82478 + .name = "hugetlbfs_read_actor",
82479 + .file = "fs/hugetlbfs/inode.c",
82480 + .param2 = 1,
82481 + .param5 = 1,
82482 + .param4 = 1,
82483 +};
82484 +
82485 +struct size_overflow_hash _000180_hash = {
82486 + .next = NULL,
82487 + .name = "keyctl_instantiate_key",
82488 + .file = "security/keys/keyctl.c",
82489 + .param3 = 1,
82490 +};
82491 +
82492 +struct size_overflow_hash _000181_hash = {
82493 + .next = NULL,
82494 + .name = "keyctl_instantiate_key_iov",
82495 + .file = "security/keys/keyctl.c",
82496 + .param3 = 1,
82497 +};
82498 +
82499 +struct size_overflow_hash _000182_hash = {
82500 + .next = NULL,
82501 + .name = "__kfifo_from_user",
82502 + .file = "include/linux/kfifo.h",
82503 + .param3 = 1,
82504 +};
82505 +
82506 +struct size_overflow_hash _000183_hash = {
82507 + .next = NULL,
82508 + .name = "kimage_crash_alloc",
82509 + .file = "kernel/kexec.c",
82510 + .param3 = 1,
82511 +};
82512 +
82513 +struct size_overflow_hash _000184_hash = {
82514 + .next = NULL,
82515 + .name = "kimage_normal_alloc",
82516 + .file = "kernel/kexec.c",
82517 + .param3 = 1,
82518 +};
82519 +
82520 +struct size_overflow_hash _000185_hash = {
82521 + .next = NULL,
82522 + .name = "mpi_alloc",
82523 + .file = "include/linux/mpi.h",
82524 + .param1 = 1,
82525 +};
82526 +
82527 +struct size_overflow_hash _000186_hash = {
82528 + .next = NULL,
82529 + .name = "mpi_set_bit",
82530 + .file = "include/linux/mpi.h",
82531 + .param2 = 1,
82532 +};
82533 +
82534 +struct size_overflow_hash _000187_hash = {
82535 + .next = NULL,
82536 + .name = "mpi_set_highbit",
82537 + .file = "include/linux/mpi.h",
82538 + .param2 = 1,
82539 +};
82540 +
82541 +struct size_overflow_hash _000188_hash = {
82542 + .next = NULL,
82543 + .name = "neigh_hash_alloc",
82544 + .file = "net/core/neighbour.c",
82545 + .param1 = 1,
82546 +};
82547 +
82548 +struct size_overflow_hash _000189_hash = {
82549 + .next = NULL,
82550 + .name = "nl_pid_hash_zalloc",
82551 + .file = "net/netlink/af_netlink.c",
82552 + .param1 = 1,
82553 +};
82554 +
82555 +struct size_overflow_hash _000190_hash = {
82556 + .next = NULL,
82557 + .name = "pci_add_cap_save_buffer",
82558 + .file = "drivers/pci/pci.c",
82559 + .param3 = 1,
82560 +};
82561 +
82562 +struct size_overflow_hash _000191_hash = {
82563 + .next = NULL,
82564 + .name = "pcpu_mem_zalloc",
82565 + .file = "mm/percpu.c",
82566 + .param1 = 1,
82567 +};
82568 +
82569 +struct size_overflow_hash _000192_hash = {
82570 + .next = NULL,
82571 + .name = "platform_create_bundle",
82572 + .file = "include/linux/platform_device.h",
82573 + .param4 = 1,
82574 + .param6 = 1,
82575 +};
82576 +
82577 +struct size_overflow_hash _000194_hash = {
82578 + .next = NULL,
82579 + .name = "process_vm_rw",
82580 + .file = "mm/process_vm_access.c",
82581 + .param3 = 1,
82582 + .param5 = 1,
82583 +};
82584 +
82585 +struct size_overflow_hash _000196_hash = {
82586 + .next = NULL,
82587 + .name = "process_vm_rw_single_vec",
82588 + .file = "mm/process_vm_access.c",
82589 + .param1 = 1,
82590 + .param2 = 1,
82591 +};
82592 +
82593 +struct size_overflow_hash _000198_hash = {
82594 + .next = NULL,
82595 + .name = "profile_load",
82596 + .file = "security/apparmor/apparmorfs.c",
82597 + .param3 = 1,
82598 +};
82599 +
82600 +struct size_overflow_hash _000199_hash = {
82601 + .next = NULL,
82602 + .name = "profile_remove",
82603 + .file = "security/apparmor/apparmorfs.c",
82604 + .param3 = 1,
82605 +};
82606 +
82607 +struct size_overflow_hash _000200_hash = {
82608 + .next = NULL,
82609 + .name = "profile_replace",
82610 + .file = "security/apparmor/apparmorfs.c",
82611 + .param3 = 1,
82612 +};
82613 +
82614 +struct size_overflow_hash _000201_hash = {
82615 + .next = NULL,
82616 + .name = "regcache_rbtree_insert_to_block",
82617 + .file = "drivers/base/regmap/regcache-rbtree.c",
82618 + .param5 = 1,
82619 +};
82620 +
82621 +struct size_overflow_hash _000202_hash = {
82622 + .next = NULL,
82623 + .name = "regmap_raw_write",
82624 + .file = "include/linux/regmap.h",
82625 + .param4 = 1,
82626 +};
82627 +
82628 +struct size_overflow_hash _000203_hash = {
82629 + .next = NULL,
82630 + .name = "relay_alloc_page_array",
82631 + .file = "kernel/relay.c",
82632 + .param1 = 1,
82633 +};
82634 +
82635 +struct size_overflow_hash _000204_hash = {
82636 + .next = NULL,
82637 + .name = "RESIZE_IF_NEEDED",
82638 + .file = "lib/mpi/mpi-internal.h",
82639 + .param2 = 1,
82640 +};
82641 +
82642 +struct size_overflow_hash _000205_hash = {
82643 + .next = NULL,
82644 + .name = "security_context_to_sid",
82645 + .file = "security/selinux/ss/services.c",
82646 + .param2 = 1,
82647 +};
82648 +
82649 +struct size_overflow_hash _000206_hash = {
82650 + .next = NULL,
82651 + .name = "security_context_to_sid_default",
82652 + .file = "security/selinux/ss/services.c",
82653 + .param2 = 1,
82654 +};
82655 +
82656 +struct size_overflow_hash _000207_hash = {
82657 + .next = NULL,
82658 + .name = "security_context_to_sid_force",
82659 + .file = "security/selinux/ss/services.c",
82660 + .param2 = 1,
82661 +};
82662 +
82663 +struct size_overflow_hash _000208_hash = {
82664 + .next = NULL,
82665 + .name = "selinux_transaction_write",
82666 + .file = "security/selinux/selinuxfs.c",
82667 + .param3 = 1,
82668 +};
82669 +
82670 +struct size_overflow_hash _000209_hash = {
82671 + .next = NULL,
82672 + .name = "sel_write_access",
82673 + .file = "security/selinux/selinuxfs.c",
82674 + .param3 = 1,
82675 +};
82676 +
82677 +struct size_overflow_hash _000210_hash = {
82678 + .next = NULL,
82679 + .name = "sel_write_create",
82680 + .file = "security/selinux/selinuxfs.c",
82681 + .param3 = 1,
82682 +};
82683 +
82684 +struct size_overflow_hash _000211_hash = {
82685 + .next = NULL,
82686 + .name = "sel_write_member",
82687 + .file = "security/selinux/selinuxfs.c",
82688 + .param3 = 1,
82689 +};
82690 +
82691 +struct size_overflow_hash _000212_hash = {
82692 + .next = NULL,
82693 + .name = "sel_write_relabel",
82694 + .file = "security/selinux/selinuxfs.c",
82695 + .param3 = 1,
82696 +};
82697 +
82698 +struct size_overflow_hash _000213_hash = {
82699 + .next = NULL,
82700 + .name = "sel_write_user",
82701 + .file = "security/selinux/selinuxfs.c",
82702 + .param3 = 1,
82703 +};
82704 +
82705 +struct size_overflow_hash _000214_hash = {
82706 + .next = NULL,
82707 + .name = "setkey",
82708 + .file = "crypto/cipher.c",
82709 + .param3 = 1,
82710 +};
82711 +
82712 +struct size_overflow_hash _000215_hash = {
82713 + .next = NULL,
82714 + .name = "setkey",
82715 + .file = "crypto/ablkcipher.c",
82716 + .param3 = 1,
82717 +};
82718 +
82719 +struct size_overflow_hash _000216_hash = {
82720 + .next = NULL,
82721 + .name = "setkey",
82722 + .file = "crypto/aead.c",
82723 + .param3 = 1,
82724 +};
82725 +
82726 +struct size_overflow_hash _000217_hash = {
82727 + .next = NULL,
82728 + .name = "setkey",
82729 + .file = "crypto/blkcipher.c",
82730 + .param3 = 1,
82731 +};
82732 +
82733 +struct size_overflow_hash _000218_hash = {
82734 + .next = NULL,
82735 + .name = "smk_write_access",
82736 + .file = "security/smack/smackfs.c",
82737 + .param3 = 1,
82738 +};
82739 +
82740 +struct size_overflow_hash _000219_hash = {
82741 + .next = NULL,
82742 + .name = "snapshot_write",
82743 + .file = "kernel/power/user.c",
82744 + .param3 = 1,
82745 +};
82746 +
82747 +struct size_overflow_hash _000220_hash = {
82748 + .next = NULL,
82749 + .name = "spi_alloc_master",
82750 + .file = "include/linux/spi/spi.h",
82751 + .param2 = 1,
82752 +};
82753 +
82754 +struct size_overflow_hash _000221_hash = {
82755 + .next = NULL,
82756 + .name = "spi_register_board_info",
82757 + .file = "include/linux/spi/spi.h",
82758 + .param2 = 1,
82759 +};
82760 +
82761 +struct size_overflow_hash _000222_hash = {
82762 + .next = NULL,
82763 + .name = "sys_flistxattr",
82764 + .file = "include/linux/syscalls.h",
82765 + .param3 = 1,
82766 +};
82767 +
82768 +struct size_overflow_hash _000223_hash = {
82769 + .next = NULL,
82770 + .name = "sys_fsetxattr",
82771 + .file = "include/linux/syscalls.h",
82772 + .param4 = 1,
82773 +};
82774 +
82775 +struct size_overflow_hash _000224_hash = {
82776 + .next = NULL,
82777 + .name = "sysfs_write_file",
82778 + .file = "fs/sysfs/file.c",
82779 + .param3 = 1,
82780 +};
82781 +
82782 +struct size_overflow_hash _000225_hash = {
82783 + .next = NULL,
82784 + .name = "sys_ipc",
82785 + .file = "include/linux/syscalls.h",
82786 + .param3 = 1,
82787 +};
82788 +
82789 +struct size_overflow_hash _000226_hash = {
82790 + .next = NULL,
82791 + .name = "sys_keyctl",
82792 + .file = "include/linux/syscalls.h",
82793 + .param4 = 1,
82794 +};
82795 +
82796 +struct size_overflow_hash _000227_hash = {
82797 + .next = NULL,
82798 + .name = "sys_listxattr",
82799 + .file = "include/linux/syscalls.h",
82800 + .param3 = 1,
82801 +};
82802 +
82803 +struct size_overflow_hash _000228_hash = {
82804 + .next = NULL,
82805 + .name = "sys_llistxattr",
82806 + .file = "include/linux/syscalls.h",
82807 + .param3 = 1,
82808 +};
82809 +
82810 +struct size_overflow_hash _000229_hash = {
82811 + .next = NULL,
82812 + .name = "sys_lsetxattr",
82813 + .file = "include/linux/syscalls.h",
82814 + .param4 = 1,
82815 +};
82816 +
82817 +struct size_overflow_hash _000230_hash = {
82818 + .next = NULL,
82819 + .name = "sys_sched_setaffinity",
82820 + .file = "include/linux/syscalls.h",
82821 + .param2 = 1,
82822 +};
82823 +
82824 +struct size_overflow_hash _000231_hash = {
82825 + .next = NULL,
82826 + .name = "sys_semop",
82827 + .file = "include/linux/syscalls.h",
82828 + .param3 = 1,
82829 +};
82830 +
82831 +struct size_overflow_hash _000232_hash = {
82832 + .next = NULL,
82833 + .name = "sys_setxattr",
82834 + .file = "include/linux/syscalls.h",
82835 + .param4 = 1,
82836 +};
82837 +
82838 +struct size_overflow_hash _000233_hash = {
82839 + .next = NULL,
82840 + .name = "tnode_alloc",
82841 + .file = "net/ipv4/fib_trie.c",
82842 + .param1 = 1,
82843 +};
82844 +
82845 +struct size_overflow_hash _000234_hash = {
82846 + .next = NULL,
82847 + .name = "tomoyo_commit_ok",
82848 + .file = "security/tomoyo/memory.c",
82849 + .param2 = 1,
82850 +};
82851 +
82852 +struct size_overflow_hash _000235_hash = {
82853 + .next = NULL,
82854 + .name = "tomoyo_scan_bprm",
82855 + .file = "security/tomoyo/condition.c",
82856 + .param2 = 1,
82857 + .param4 = 1,
82858 +};
82859 +
82860 +struct size_overflow_hash _000237_hash = {
82861 + .next = NULL,
82862 + .name = "tty_write",
82863 + .file = "drivers/tty/tty_io.c",
82864 + .param3 = 1,
82865 +};
82866 +
82867 +struct size_overflow_hash _000238_hash = {
82868 + .next = NULL,
82869 + .name = "vc_resize",
82870 + .file = "include/linux/vt_kern.h",
82871 + .param2 = 1,
82872 + .param3 = 1,
82873 +};
82874 +
82875 +struct size_overflow_hash _000240_hash = {
82876 + .next = NULL,
82877 + .name = "vmalloc",
82878 + .file = "include/linux/vmalloc.h",
82879 + .param1 = 1,
82880 +};
82881 +
82882 +struct size_overflow_hash _000241_hash = {
82883 + .next = NULL,
82884 + .name = "vzalloc",
82885 + .file = "include/linux/vmalloc.h",
82886 + .param1 = 1,
82887 +};
82888 +
82889 +struct size_overflow_hash _000242_hash = {
82890 + .next = NULL,
82891 + .name = "vzalloc_node",
82892 + .file = "include/linux/vmalloc.h",
82893 + .param1 = 1,
82894 +};
82895 +
82896 +struct size_overflow_hash _000243_hash = {
82897 + .next = NULL,
82898 + .name = "xfrm_hash_alloc",
82899 + .file = "net/xfrm/xfrm_hash.c",
82900 + .param1 = 1,
82901 +};
82902 +
82903 +struct size_overflow_hash _000244_hash = {
82904 + .next = NULL,
82905 + .name = "acpi_ds_build_internal_package_obj",
82906 + .file = "drivers/acpi/acpica/dsobject.c",
82907 + .param3 = 1,
82908 +};
82909 +
82910 +struct size_overflow_hash _000245_hash = {
82911 + .next = NULL,
82912 + .name = "acpi_system_read_event",
82913 + .file = "drivers/acpi/event.c",
82914 + .param3 = 1,
82915 +};
82916 +
82917 +struct size_overflow_hash _000246_hash = {
82918 + .next = NULL,
82919 + .name = "acpi_ut_create_buffer_object",
82920 + .file = "drivers/acpi/acpica/utobject.c",
82921 + .param1 = 1,
82922 +};
82923 +
82924 +struct size_overflow_hash _000247_hash = {
82925 + .next = NULL,
82926 + .name = "acpi_ut_create_package_object",
82927 + .file = "drivers/acpi/acpica/utobject.c",
82928 + .param1 = 1,
82929 +};
82930 +
82931 +struct size_overflow_hash _000248_hash = {
82932 + .next = NULL,
82933 + .name = "acpi_ut_create_string_object",
82934 + .file = "drivers/acpi/acpica/utobject.c",
82935 + .param1 = 1,
82936 +};
82937 +
82938 +struct size_overflow_hash _000249_hash = {
82939 + .next = NULL,
82940 + .name = "add_child",
82941 + .file = "drivers/mfd/twl-core.c",
82942 + .param4 = 1,
82943 +};
82944 +
82945 +struct size_overflow_hash _000250_hash = {
82946 + .next = NULL,
82947 + .name = "___alloc_bootmem",
82948 + .file = "mm/nobootmem.c",
82949 + .param1 = 1,
82950 +};
82951 +
82952 +struct size_overflow_hash _000251_hash = {
82953 + .next = NULL,
82954 + .name = "__alloc_bootmem_nopanic",
82955 + .file = "include/linux/bootmem.h",
82956 + .param1 = 1,
82957 +};
82958 +
82959 +struct size_overflow_hash _000252_hash = {
82960 + .next = NULL,
82961 + .name = "async_setkey",
82962 + .file = "crypto/blkcipher.c",
82963 + .param3 = 1,
82964 +};
82965 +
82966 +struct size_overflow_hash _000253_hash = {
82967 + .next = NULL,
82968 + .name = "bio_map_kern",
82969 + .file = "include/linux/bio.h",
82970 + .param3 = 1,
82971 +};
82972 +
82973 +struct size_overflow_hash _000254_hash = {
82974 + .next = NULL,
82975 + .name = "copy_oldmem_page",
82976 + .file = "include/linux/crash_dump.h",
82977 + .param3 = 1,
82978 +};
82979 +
82980 +struct size_overflow_hash _000255_hash = {
82981 + .next = NULL,
82982 + .name = "do_sigpending",
82983 + .file = "include/linux/signal.h",
82984 + .param2 = 1,
82985 +};
82986 +
82987 +struct size_overflow_hash _000257_hash = {
82988 + .next = NULL,
82989 + .name = "keyctl_describe_key",
82990 + .file = "security/keys/keyctl.c",
82991 + .param3 = 1,
82992 +};
82993 +
82994 +struct size_overflow_hash _000258_hash = {
82995 + .next = NULL,
82996 + .name = "keyctl_get_security",
82997 + .file = "security/keys/keyctl.c",
82998 + .param3 = 1,
82999 +};
83000 +
83001 +struct size_overflow_hash _000259_hash = {
83002 + .next = NULL,
83003 + .name = "keyring_read",
83004 + .file = "security/keys/keyring.c",
83005 + .param3 = 1,
83006 +};
83007 +
83008 +struct size_overflow_hash _000260_hash = {
83009 + .next = NULL,
83010 + .name = "kfifo_copy_to_user",
83011 + .file = "kernel/kfifo.c",
83012 + .param3 = 1,
83013 +};
83014 +
83015 +struct size_overflow_hash _000261_hash = {
83016 + .next = NULL,
83017 + .name = "mousedev_read",
83018 + .file = "drivers/input/mousedev.c",
83019 + .param3 = 1,
83020 +};
83021 +
83022 +struct size_overflow_hash _000262_hash = {
83023 + .next = NULL,
83024 + .name = "mpi_lshift_limbs",
83025 + .file = "lib/mpi/mpi-bit.c",
83026 + .param2 = 1,
83027 +};
83028 +
83029 +struct size_overflow_hash _000263_hash = {
83030 + .next = NULL,
83031 + .name = "neigh_hash_grow",
83032 + .file = "net/core/neighbour.c",
83033 + .param2 = 1,
83034 +};
83035 +
83036 +struct size_overflow_hash _000264_hash = {
83037 + .next = NULL,
83038 + .name = "posix_clock_register",
83039 + .file = "include/linux/posix-clock.h",
83040 + .param2 = 1,
83041 +};
83042 +
83043 +struct size_overflow_hash _000265_hash = {
83044 + .next = NULL,
83045 + .name = "__proc_file_read",
83046 + .file = "fs/proc/generic.c",
83047 + .param3 = 1,
83048 +};
83049 +
83050 +struct size_overflow_hash _000266_hash = {
83051 + .next = NULL,
83052 + .name = "read_profile",
83053 + .file = "kernel/profile.c",
83054 + .param3 = 1,
83055 +};
83056 +
83057 +struct size_overflow_hash _000267_hash = {
83058 + .next = NULL,
83059 + .name = "read_vmcore",
83060 + .file = "fs/proc/vmcore.c",
83061 + .param3 = 1,
83062 +};
83063 +
83064 +struct size_overflow_hash _000268_hash = {
83065 + .next = NULL,
83066 + .name = "redirected_tty_write",
83067 + .file = "drivers/tty/tty_io.c",
83068 + .param3 = 1,
83069 +};
83070 +
83071 +struct size_overflow_hash _000269_hash = {
83072 + .next = NULL,
83073 + .name = "__register_chrdev",
83074 + .file = "include/linux/fs.h",
83075 + .param2 = 1,
83076 + .param3 = 1,
83077 +};
83078 +
83079 +struct size_overflow_hash _000271_hash = {
83080 + .next = NULL,
83081 + .name = "request_key_auth_read",
83082 + .file = "security/keys/request_key_auth.c",
83083 + .param3 = 1,
83084 +};
83085 +
83086 +struct size_overflow_hash _000272_hash = {
83087 + .next = NULL,
83088 + .name = "shash_async_setkey",
83089 + .file = "crypto/shash.c",
83090 + .param3 = 1,
83091 +};
83092 +
83093 +struct size_overflow_hash _000273_hash = {
83094 + .next = NULL,
83095 + .name = "shash_compat_setkey",
83096 + .file = "crypto/shash.c",
83097 + .param3 = 1,
83098 +};
83099 +
83100 +struct size_overflow_hash _000274_hash = {
83101 + .next = NULL,
83102 + .name = "simple_read_from_buffer",
83103 + .file = "include/linux/fs.h",
83104 + .param2 = 1,
83105 + .param5 = 1,
83106 +};
83107 +
83108 +struct size_overflow_hash _000276_hash = {
83109 + .next = NULL,
83110 + .name = "store_ifalias",
83111 + .file = "net/core/net-sysfs.c",
83112 + .param4 = 1,
83113 +};
83114 +
83115 +struct size_overflow_hash _000277_hash = {
83116 + .next = NULL,
83117 + .name = "subbuf_read_actor",
83118 + .file = "kernel/relay.c",
83119 + .param3 = 1,
83120 +};
83121 +
83122 +struct size_overflow_hash _000278_hash = {
83123 + .next = NULL,
83124 + .name = "sys_fgetxattr",
83125 + .file = "include/linux/syscalls.h",
83126 + .param4 = 1,
83127 +};
83128 +
83129 +struct size_overflow_hash _000279_hash = {
83130 + .next = NULL,
83131 + .name = "sys_getxattr",
83132 + .file = "include/linux/syscalls.h",
83133 + .param4 = 1,
83134 +};
83135 +
83136 +struct size_overflow_hash _000280_hash = {
83137 + .next = NULL,
83138 + .name = "sys_kexec_load",
83139 + .file = "include/linux/syscalls.h",
83140 + .param2 = 1,
83141 +};
83142 +
83143 +struct size_overflow_hash _000281_hash = {
83144 + .next = NULL,
83145 + .name = "sys_lgetxattr",
83146 + .file = "include/linux/syscalls.h",
83147 + .param4 = 1,
83148 +};
83149 +
83150 +struct size_overflow_hash _000282_hash = {
83151 + .next = NULL,
83152 + .name = "sys_process_vm_readv",
83153 + .file = "include/linux/syscalls.h",
83154 + .param3 = 1,
83155 + .param5 = 1,
83156 +};
83157 +
83158 +struct size_overflow_hash _000284_hash = {
83159 + .next = NULL,
83160 + .name = "sys_process_vm_writev",
83161 + .file = "include/linux/syscalls.h",
83162 + .param3 = 1,
83163 + .param5 = 1,
83164 +};
83165 +
83166 +struct size_overflow_hash _000286_hash = {
83167 + .next = NULL,
83168 + .name = "sys_sched_getaffinity",
83169 + .file = "include/linux/syscalls.h",
83170 + .param2 = 1,
83171 +};
83172 +
83173 +struct size_overflow_hash _000287_hash = {
83174 + .next = NULL,
83175 + .name = "tomoyo_read_self",
83176 + .file = "security/tomoyo/securityfs_if.c",
83177 + .param3 = 1,
83178 +};
83179 +
83180 +struct size_overflow_hash _000288_hash = {
83181 + .next = NULL,
83182 + .name = "tpm_read",
83183 + .file = "drivers/char/tpm/tpm.c",
83184 + .param3 = 1,
83185 +};
83186 +
83187 +struct size_overflow_hash _000289_hash = {
83188 + .next = NULL,
83189 + .name = "user_read",
83190 + .file = "include/keys/user-type.h",
83191 + .param3 = 1,
83192 +};
83193 +
83194 +struct size_overflow_hash _000290_hash = {
83195 + .next = NULL,
83196 + .name = "vcs_read",
83197 + .file = "drivers/tty/vt/vc_screen.c",
83198 + .param3 = 1,
83199 +};
83200 +
83201 +struct size_overflow_hash _000291_hash = {
83202 + .next = NULL,
83203 + .name = "vfs_readv",
83204 + .file = "include/linux/fs.h",
83205 + .param3 = 1,
83206 +};
83207 +
83208 +struct size_overflow_hash _000292_hash = {
83209 + .next = NULL,
83210 + .name = "vfs_writev",
83211 + .file = "include/linux/fs.h",
83212 + .param3 = 1,
83213 +};
83214 +
83215 +struct size_overflow_hash _000293_hash = {
83216 + .next = NULL,
83217 + .name = "vga_arb_read",
83218 + .file = "drivers/gpu/vga/vgaarb.c",
83219 + .param3 = 1,
83220 +};
83221 +
83222 +struct size_overflow_hash _000294_hash = {
83223 + .next = NULL,
83224 + .name = "xz_dec_lzma2_create",
83225 + .file = "lib/xz/xz_dec_lzma2.c",
83226 + .param2 = 1,
83227 +};
83228 +
83229 +struct size_overflow_hash _000295_hash = {
83230 + .next = NULL,
83231 + .name = "aat2870_reg_read_file",
83232 + .file = "drivers/mfd/aat2870-core.c",
83233 + .param3 = 1,
83234 +};
83235 +
83236 +struct size_overflow_hash _000296_hash = {
83237 + .next = NULL,
83238 + .name = "__alloc_bootmem",
83239 + .file = "include/linux/bootmem.h",
83240 + .param1 = 1,
83241 +};
83242 +
83243 +struct size_overflow_hash _000297_hash = {
83244 + .next = NULL,
83245 + .name = "__alloc_bootmem_low",
83246 + .file = "include/linux/bootmem.h",
83247 + .param1 = 1,
83248 +};
83249 +
83250 +struct size_overflow_hash _000298_hash = {
83251 + .next = NULL,
83252 + .name = "__alloc_bootmem_node_nopanic",
83253 + .file = "include/linux/bootmem.h",
83254 + .param2 = 1,
83255 +};
83256 +
83257 +struct size_overflow_hash _000299_hash = {
83258 + .next = NULL,
83259 + .name = "blk_rq_map_kern",
83260 + .file = "include/linux/blkdev.h",
83261 + .param4 = 1,
83262 +};
83263 +
83264 +struct size_overflow_hash _000300_hash = {
83265 + .next = NULL,
83266 + .name = "cgroup_read_s64",
83267 + .file = "kernel/cgroup.c",
83268 + .param5 = 1,
83269 +};
83270 +
83271 +struct size_overflow_hash _000301_hash = {
83272 + .next = NULL,
83273 + .name = "cgroup_read_u64",
83274 + .file = "kernel/cgroup.c",
83275 + .param5 = 1,
83276 +};
83277 +
83278 +struct size_overflow_hash _000302_hash = {
83279 + .next = NULL,
83280 + .name = "cpuset_common_file_read",
83281 + .file = "kernel/cpuset.c",
83282 + .param5 = 1,
83283 +};
83284 +
83285 +struct size_overflow_hash _000303_hash = {
83286 + .next = NULL,
83287 + .name = "filter_read",
83288 + .file = "lib/dma-debug.c",
83289 + .param3 = 1,
83290 +};
83291 +
83292 +struct size_overflow_hash _000304_hash = {
83293 + .next = NULL,
83294 + .name = "ima_show_htable_value",
83295 + .file = "security/integrity/ima/ima_fs.c",
83296 + .param2 = 1,
83297 +};
83298 +
83299 +struct size_overflow_hash _000305_hash = {
83300 + .next = NULL,
83301 + .name = "kernel_readv",
83302 + .file = "fs/splice.c",
83303 + .param3 = 1,
83304 +};
83305 +
83306 +struct size_overflow_hash _000306_hash = {
83307 + .next = NULL,
83308 + .name = "__kfifo_to_user",
83309 + .file = "include/linux/kfifo.h",
83310 + .param3 = 1,
83311 +};
83312 +
83313 +struct size_overflow_hash _000307_hash = {
83314 + .next = NULL,
83315 + .name = "__kfifo_to_user_r",
83316 + .file = "include/linux/kfifo.h",
83317 + .param3 = 1,
83318 +};
83319 +
83320 +struct size_overflow_hash _000308_hash = {
83321 + .next = NULL,
83322 + .name = "mqueue_read_file",
83323 + .file = "ipc/mqueue.c",
83324 + .param3 = 1,
83325 +};
83326 +
83327 +struct size_overflow_hash _000309_hash = {
83328 + .next = NULL,
83329 + .name = "oom_adjust_read",
83330 + .file = "fs/proc/base.c",
83331 + .param3 = 1,
83332 +};
83333 +
83334 +struct size_overflow_hash _000310_hash = {
83335 + .next = NULL,
83336 + .name = "oom_score_adj_read",
83337 + .file = "fs/proc/base.c",
83338 + .param3 = 1,
83339 +};
83340 +
83341 +struct size_overflow_hash _000311_hash = {
83342 + .next = NULL,
83343 + .name = "pm_qos_power_read",
83344 + .file = "kernel/power/qos.c",
83345 + .param3 = 1,
83346 +};
83347 +
83348 +struct size_overflow_hash _000312_hash = {
83349 + .next = NULL,
83350 + .name = "proc_coredump_filter_read",
83351 + .file = "fs/proc/base.c",
83352 + .param3 = 1,
83353 +};
83354 +
83355 +struct size_overflow_hash _000313_hash = {
83356 + .next = NULL,
83357 + .name = "proc_fdinfo_read",
83358 + .file = "fs/proc/base.c",
83359 + .param3 = 1,
83360 +};
83361 +
83362 +struct size_overflow_hash _000314_hash = {
83363 + .next = NULL,
83364 + .name = "proc_info_read",
83365 + .file = "fs/proc/base.c",
83366 + .param3 = 1,
83367 +};
83368 +
83369 +struct size_overflow_hash _000315_hash = {
83370 + .next = NULL,
83371 + .name = "proc_loginuid_read",
83372 + .file = "fs/proc/base.c",
83373 + .param3 = 1,
83374 +};
83375 +
83376 +struct size_overflow_hash _000316_hash = {
83377 + .next = NULL,
83378 + .name = "proc_pid_attr_read",
83379 + .file = "fs/proc/base.c",
83380 + .param3 = 1,
83381 +};
83382 +
83383 +struct size_overflow_hash _000317_hash = {
83384 + .next = NULL,
83385 + .name = "proc_sessionid_read",
83386 + .file = "fs/proc/base.c",
83387 + .param3 = 1,
83388 +};
83389 +
83390 +struct size_overflow_hash _000318_hash = {
83391 + .next = NULL,
83392 + .name = "pstore_file_read",
83393 + .file = "fs/pstore/inode.c",
83394 + .param3 = 1,
83395 +};
83396 +
83397 +struct size_overflow_hash _000319_hash = {
83398 + .next = NULL,
83399 + .name = "read_enabled_file_bool",
83400 + .file = "kernel/kprobes.c",
83401 + .param3 = 1,
83402 +};
83403 +
83404 +struct size_overflow_hash _000320_hash = {
83405 + .next = NULL,
83406 + .name = "read_file_blob",
83407 + .file = "fs/debugfs/file.c",
83408 + .param3 = 1,
83409 +};
83410 +
83411 +struct size_overflow_hash _000321_hash = {
83412 + .next = NULL,
83413 + .name = "read_file_bool",
83414 + .file = "fs/debugfs/file.c",
83415 + .param3 = 1,
83416 +};
83417 +
83418 +struct size_overflow_hash _000322_hash = {
83419 + .next = NULL,
83420 + .name = "read_from_oldmem",
83421 + .file = "fs/proc/vmcore.c",
83422 + .param2 = 1,
83423 +};
83424 +
83425 +struct size_overflow_hash _000323_hash = {
83426 + .next = NULL,
83427 + .name = "read_oldmem",
83428 + .file = "drivers/char/mem.c",
83429 + .param3 = 1,
83430 +};
83431 +
83432 +struct size_overflow_hash _000324_hash = {
83433 + .next = NULL,
83434 + .name = "res_counter_read",
83435 + .file = "include/linux/res_counter.h",
83436 + .param4 = 1,
83437 +};
83438 +
83439 +struct size_overflow_hash _000325_hash = {
83440 + .next = NULL,
83441 + .name = "sel_read_avc_cache_threshold",
83442 + .file = "security/selinux/selinuxfs.c",
83443 + .param3 = 1,
83444 +};
83445 +
83446 +struct size_overflow_hash _000326_hash = {
83447 + .next = NULL,
83448 + .name = "sel_read_avc_hash_stats",
83449 + .file = "security/selinux/selinuxfs.c",
83450 + .param3 = 1,
83451 +};
83452 +
83453 +struct size_overflow_hash _000327_hash = {
83454 + .next = NULL,
83455 + .name = "sel_read_bool",
83456 + .file = "security/selinux/selinuxfs.c",
83457 + .param3 = 1,
83458 +};
83459 +
83460 +struct size_overflow_hash _000328_hash = {
83461 + .next = NULL,
83462 + .name = "sel_read_checkreqprot",
83463 + .file = "security/selinux/selinuxfs.c",
83464 + .param3 = 1,
83465 +};
83466 +
83467 +struct size_overflow_hash _000329_hash = {
83468 + .next = NULL,
83469 + .name = "sel_read_class",
83470 + .file = "security/selinux/selinuxfs.c",
83471 + .param3 = 1,
83472 +};
83473 +
83474 +struct size_overflow_hash _000330_hash = {
83475 + .next = NULL,
83476 + .name = "sel_read_enforce",
83477 + .file = "security/selinux/selinuxfs.c",
83478 + .param3 = 1,
83479 +};
83480 +
83481 +struct size_overflow_hash _000331_hash = {
83482 + .next = NULL,
83483 + .name = "sel_read_handle_status",
83484 + .file = "security/selinux/selinuxfs.c",
83485 + .param3 = 1,
83486 +};
83487 +
83488 +struct size_overflow_hash _000332_hash = {
83489 + .next = NULL,
83490 + .name = "sel_read_handle_unknown",
83491 + .file = "security/selinux/selinuxfs.c",
83492 + .param3 = 1,
83493 +};
83494 +
83495 +struct size_overflow_hash _000333_hash = {
83496 + .next = NULL,
83497 + .name = "sel_read_initcon",
83498 + .file = "security/selinux/selinuxfs.c",
83499 + .param3 = 1,
83500 +};
83501 +
83502 +struct size_overflow_hash _000334_hash = {
83503 + .next = NULL,
83504 + .name = "sel_read_mls",
83505 + .file = "security/selinux/selinuxfs.c",
83506 + .param3 = 1,
83507 +};
83508 +
83509 +struct size_overflow_hash _000335_hash = {
83510 + .next = NULL,
83511 + .name = "sel_read_perm",
83512 + .file = "security/selinux/selinuxfs.c",
83513 + .param3 = 1,
83514 +};
83515 +
83516 +struct size_overflow_hash _000336_hash = {
83517 + .next = NULL,
83518 + .name = "sel_read_policy",
83519 + .file = "security/selinux/selinuxfs.c",
83520 + .param3 = 1,
83521 +};
83522 +
83523 +struct size_overflow_hash _000337_hash = {
83524 + .next = NULL,
83525 + .name = "sel_read_policycap",
83526 + .file = "security/selinux/selinuxfs.c",
83527 + .param3 = 1,
83528 +};
83529 +
83530 +struct size_overflow_hash _000338_hash = {
83531 + .next = NULL,
83532 + .name = "sel_read_policyvers",
83533 + .file = "security/selinux/selinuxfs.c",
83534 + .param3 = 1,
83535 +};
83536 +
83537 +struct size_overflow_hash _000339_hash = {
83538 + .next = NULL,
83539 + .name = "simple_attr_read",
83540 + .file = "include/linux/fs.h",
83541 + .param3 = 1,
83542 +};
83543 +
83544 +struct size_overflow_hash _000340_hash = {
83545 + .next = NULL,
83546 + .name = "simple_transaction_read",
83547 + .file = "include/linux/fs.h",
83548 + .param3 = 1,
83549 +};
83550 +
83551 +struct size_overflow_hash _000341_hash = {
83552 + .next = NULL,
83553 + .name = "smk_read_ambient",
83554 + .file = "security/smack/smackfs.c",
83555 + .param3 = 1,
83556 +};
83557 +
83558 +struct size_overflow_hash _000342_hash = {
83559 + .next = NULL,
83560 + .name = "smk_read_direct",
83561 + .file = "security/smack/smackfs.c",
83562 + .param3 = 1,
83563 +};
83564 +
83565 +struct size_overflow_hash _000343_hash = {
83566 + .next = NULL,
83567 + .name = "smk_read_doi",
83568 + .file = "security/smack/smackfs.c",
83569 + .param3 = 1,
83570 +};
83571 +
83572 +struct size_overflow_hash _000344_hash = {
83573 + .next = NULL,
83574 + .name = "smk_read_logging",
83575 + .file = "security/smack/smackfs.c",
83576 + .param3 = 1,
83577 +};
83578 +
83579 +struct size_overflow_hash _000345_hash = {
83580 + .next = NULL,
83581 + .name = "smk_read_onlycap",
83582 + .file = "security/smack/smackfs.c",
83583 + .param3 = 1,
83584 +};
83585 +
83586 +struct size_overflow_hash _000346_hash = {
83587 + .next = NULL,
83588 + .name = "snapshot_read",
83589 + .file = "kernel/power/user.c",
83590 + .param3 = 1,
83591 +};
83592 +
83593 +struct size_overflow_hash _000347_hash = {
83594 + .next = NULL,
83595 + .name = "supply_map_read_file",
83596 + .file = "drivers/regulator/core.c",
83597 + .param3 = 1,
83598 +};
83599 +
83600 +struct size_overflow_hash _000348_hash = {
83601 + .next = NULL,
83602 + .name = "sysfs_read_file",
83603 + .file = "fs/sysfs/file.c",
83604 + .param3 = 1,
83605 +};
83606 +
83607 +struct size_overflow_hash _000349_hash = {
83608 + .next = NULL,
83609 + .name = "sys_preadv",
83610 + .file = "include/linux/syscalls.h",
83611 + .param3 = 1,
83612 +};
83613 +
83614 +struct size_overflow_hash _000350_hash = {
83615 + .next = NULL,
83616 + .name = "sys_pwritev",
83617 + .file = "include/linux/syscalls.h",
83618 + .param3 = 1,
83619 +};
83620 +
83621 +struct size_overflow_hash _000351_hash = {
83622 + .next = NULL,
83623 + .name = "sys_readv",
83624 + .file = "include/linux/syscalls.h",
83625 + .param3 = 1,
83626 +};
83627 +
83628 +struct size_overflow_hash _000352_hash = {
83629 + .next = NULL,
83630 + .name = "sys_rt_sigpending",
83631 + .file = "include/linux/syscalls.h",
83632 + .param2 = 1,
83633 +};
83634 +
83635 +struct size_overflow_hash _000353_hash = {
83636 + .next = NULL,
83637 + .name = "sys_writev",
83638 + .file = "include/linux/syscalls.h",
83639 + .param3 = 1,
83640 +};
83641 +
83642 +struct size_overflow_hash _000354_hash = {
83643 + .next = NULL,
83644 + .name = "ima_show_htable_violations",
83645 + .file = "security/integrity/ima/ima_fs.c",
83646 + .param3 = 1,
83647 +};
83648 +
83649 +struct size_overflow_hash _000355_hash = {
83650 + .next = NULL,
83651 + .name = "ima_show_measurements_count",
83652 + .file = "security/integrity/ima/ima_fs.c",
83653 + .param3 = 1,
83654 +};
83655 +
83656 +struct size_overflow_hash _000356_hash = {
83657 + .next = NULL,
83658 + .name = "alloc_cpu_rmap",
83659 + .file = "include/linux/cpu_rmap.h",
83660 + .param1 = 1,
83661 +};
83662 +
83663 +struct size_overflow_hash _000357_hash = {
83664 + .next = NULL,
83665 + .name = "alloc_page_cgroup",
83666 + .file = "mm/page_cgroup.c",
83667 + .param1 = 1,
83668 +};
83669 +
83670 +struct size_overflow_hash _000358_hash = {
83671 + .next = NULL,
83672 + .name = "alloc_sched_domains",
83673 + .file = "include/linux/sched.h",
83674 + .param1 = 1,
83675 +};
83676 +
83677 +struct size_overflow_hash _000359_hash = {
83678 + .next = NULL,
83679 + .name = "compat_rw_copy_check_uvector",
83680 + .file = "include/linux/compat.h",
83681 + .param3 = 1,
83682 +};
83683 +
83684 +struct size_overflow_hash _000360_hash = {
83685 + .next = NULL,
83686 + .name = "compat_sys_kexec_load",
83687 + .file = "include/linux/kexec.h",
83688 + .param2 = 1,
83689 +};
83690 +
83691 +struct size_overflow_hash _000361_hash = {
83692 + .next = NULL,
83693 + .name = "compat_sys_semtimedop",
83694 + .file = "include/linux/compat.h",
83695 + .param3 = 1,
83696 +};
83697 +
83698 +struct size_overflow_hash _000362_hash = {
83699 + .next = NULL,
83700 + .name = "copy_from_user",
83701 + .file = "arch/x86/include/asm/uaccess_64.h",
83702 + .param3 = 1,
83703 +};
83704 +
83705 +struct size_overflow_hash _000363_hash = {
83706 + .next = NULL,
83707 + .name = "__copy_from_user",
83708 + .file = "arch/x86/include/asm/uaccess_64.h",
83709 + .param3 = 1,
83710 +};
83711 +
83712 +struct size_overflow_hash _000364_hash = {
83713 + .next = NULL,
83714 + .name = "__copy_from_user_inatomic",
83715 + .file = "arch/x86/include/asm/uaccess_64.h",
83716 + .param3 = 1,
83717 +};
83718 +
83719 +struct size_overflow_hash _000365_hash = {
83720 + .next = NULL,
83721 + .name = "__copy_from_user_nocache",
83722 + .file = "arch/x86/include/asm/uaccess_64.h",
83723 + .param3 = 1,
83724 +};
83725 +
83726 +struct size_overflow_hash _000366_hash = {
83727 + .next = NULL,
83728 + .name = "__copy_in_user",
83729 + .file = "arch/x86/include/asm/uaccess_64.h",
83730 + .param3 = 1,
83731 +};
83732 +
83733 +struct size_overflow_hash _000367_hash = {
83734 + .next = NULL,
83735 + .name = "copy_in_user",
83736 + .file = "arch/x86/include/asm/uaccess_64.h",
83737 + .param3 = 1,
83738 +};
83739 +
83740 +struct size_overflow_hash _000368_hash = {
83741 + .next = NULL,
83742 + .name = "__copy_to_user",
83743 + .file = "arch/x86/include/asm/uaccess_64.h",
83744 + .param3 = 1,
83745 +};
83746 +
83747 +struct size_overflow_hash _000369_hash = {
83748 + .next = NULL,
83749 + .name = "copy_to_user",
83750 + .file = "arch/x86/include/asm/uaccess_64.h",
83751 + .param3 = 1,
83752 +};
83753 +
83754 +struct size_overflow_hash _000370_hash = {
83755 + .next = NULL,
83756 + .name = "__copy_to_user_inatomic",
83757 + .file = "arch/x86/include/asm/uaccess_64.h",
83758 + .param3 = 1,
83759 +};
83760 +
83761 +struct size_overflow_hash _000371_hash = {
83762 + .next = NULL,
83763 + .name = "kmalloc_node",
83764 + .file = "include/linux/slub_def.h",
83765 + .param1 = 1,
83766 +};
83767 +
83768 +struct size_overflow_hash _000372_hash = {
83769 + .next = NULL,
83770 + .name = "pcpu_alloc_bootmem",
83771 + .file = "arch/x86/kernel/setup_percpu.c",
83772 + .param2 = 1,
83773 +};
83774 +
83775 +struct size_overflow_hash _000373_hash = {
83776 + .next = NULL,
83777 + .name = "sys32_rt_sigpending",
83778 + .file = "arch/x86/include/asm/sys_ia32.h",
83779 + .param2 = 1,
83780 +};
83781 +
83782 +struct size_overflow_hash _000374_hash = {
83783 + .next = NULL,
83784 + .name = "tunables_read",
83785 + .file = "arch/x86/platform/uv/tlb_uv.c",
83786 + .param3 = 1,
83787 +};
83788 +
83789 +struct size_overflow_hash _000375_hash = {
83790 + .next = NULL,
83791 + .name = "compat_do_readv_writev",
83792 + .file = "fs/compat.c",
83793 + .param4 = 1,
83794 +};
83795 +
83796 +struct size_overflow_hash _000376_hash = {
83797 + .next = NULL,
83798 + .name = "compat_keyctl_instantiate_key_iov",
83799 + .file = "security/keys/compat.c",
83800 + .param3 = 1,
83801 +};
83802 +
83803 +struct size_overflow_hash _000377_hash = {
83804 + .next = NULL,
83805 + .name = "compat_process_vm_rw",
83806 + .file = "mm/process_vm_access.c",
83807 + .param3 = 1,
83808 + .param5 = 1,
83809 +};
83810 +
83811 +struct size_overflow_hash _000379_hash = {
83812 + .next = NULL,
83813 + .name = "do_pages_stat",
83814 + .file = "mm/migrate.c",
83815 + .param2 = 1,
83816 +};
83817 +
83818 +struct size_overflow_hash _000380_hash = {
83819 + .next = NULL,
83820 + .name = "kzalloc_node",
83821 + .file = "include/linux/slab.h",
83822 + .param1 = 1,
83823 +};
83824 +
83825 +struct size_overflow_hash _000381_hash = {
83826 + .next = NULL,
83827 + .name = "pcpu_fc_alloc",
83828 + .file = "arch/x86/kernel/setup_percpu.c",
83829 + .param2 = 1,
83830 +};
83831 +
83832 +struct size_overflow_hash _000382_hash = {
83833 + .next = NULL,
83834 + .name = "ptc_proc_write",
83835 + .file = "arch/x86/platform/uv/tlb_uv.c",
83836 + .param3 = 1,
83837 +};
83838 +
83839 +struct size_overflow_hash _000383_hash = {
83840 + .next = NULL,
83841 + .name = "tunables_write",
83842 + .file = "arch/x86/platform/uv/tlb_uv.c",
83843 + .param3 = 1,
83844 +};
83845 +
83846 +struct size_overflow_hash _000384_hash = {
83847 + .next = NULL,
83848 + .name = "__alloc_bootmem_low_node",
83849 + .file = "include/linux/bootmem.h",
83850 + .param2 = 1,
83851 +};
83852 +
83853 +struct size_overflow_hash _000385_hash = {
83854 + .next = NULL,
83855 + .name = "__alloc_bootmem_node",
83856 + .file = "include/linux/bootmem.h",
83857 + .param2 = 1,
83858 +};
83859 +
83860 +struct size_overflow_hash _000386_hash = {
83861 + .next = NULL,
83862 + .name = "compat_readv",
83863 + .file = "fs/compat.c",
83864 + .param3 = 1,
83865 +};
83866 +
83867 +struct size_overflow_hash _000387_hash = {
83868 + .next = NULL,
83869 + .name = "compat_sys_keyctl",
83870 + .file = "include/linux/compat.h",
83871 + .param4 = 1,
83872 +};
83873 +
83874 +struct size_overflow_hash _000388_hash = {
83875 + .next = NULL,
83876 + .name = "compat_sys_process_vm_readv",
83877 + .file = "include/linux/compat.h",
83878 + .param3 = 1,
83879 + .param5 = 1,
83880 +};
83881 +
83882 +struct size_overflow_hash _000390_hash = {
83883 + .next = NULL,
83884 + .name = "compat_sys_process_vm_writev",
83885 + .file = "include/linux/compat.h",
83886 + .param3 = 1,
83887 + .param5 = 1,
83888 +};
83889 +
83890 +struct size_overflow_hash _000392_hash = {
83891 + .next = NULL,
83892 + .name = "compat_writev",
83893 + .file = "fs/compat.c",
83894 + .param3 = 1,
83895 +};
83896 +
83897 +struct size_overflow_hash _000393_hash = {
83898 + .next = NULL,
83899 + .name = "sys_move_pages",
83900 + .file = "include/linux/syscalls.h",
83901 + .param2 = 1,
83902 +};
83903 +
83904 +struct size_overflow_hash _000394_hash = {
83905 + .next = NULL,
83906 + .name = "__alloc_bootmem_node_high",
83907 + .file = "include/linux/bootmem.h",
83908 + .param2 = 1,
83909 +};
83910 +
83911 +struct size_overflow_hash _000395_hash = {
83912 + .next = NULL,
83913 + .name = "compat_sys_move_pages",
83914 + .file = "include/linux/compat.h",
83915 + .param2 = 1,
83916 +};
83917 +
83918 +struct size_overflow_hash _000396_hash = {
83919 + .next = NULL,
83920 + .name = "compat_sys_preadv",
83921 + .file = "include/linux/compat.h",
83922 + .param3 = 1,
83923 +};
83924 +
83925 +struct size_overflow_hash _000397_hash = {
83926 + .next = NULL,
83927 + .name = "compat_sys_pwritev",
83928 + .file = "include/linux/compat.h",
83929 + .param3 = 1,
83930 +};
83931 +
83932 +struct size_overflow_hash _000398_hash = {
83933 + .next = NULL,
83934 + .name = "compat_sys_readv",
83935 + .file = "include/linux/compat.h",
83936 + .param3 = 1,
83937 +};
83938 +
83939 +struct size_overflow_hash _000399_hash = {
83940 + .next = NULL,
83941 + .name = "compat_sys_writev",
83942 + .file = "include/linux/compat.h",
83943 + .param3 = 1,
83944 +};
83945 +
83946 +struct size_overflow_hash _000400_hash = {
83947 + .next = NULL,
83948 + .name = "sparse_early_usemaps_alloc_node",
83949 + .file = "mm/sparse.c",
83950 + .param4 = 1,
83951 +};
83952 +
83953 +struct size_overflow_hash _000401_hash = {
83954 + .next = NULL,
83955 + .name = "__earlyonly_bootmem_alloc",
83956 + .file = "mm/sparse-vmemmap.c",
83957 + .param2 = 1,
83958 +};
83959 +
83960 +struct size_overflow_hash _000402_hash = {
83961 + .next = NULL,
83962 + .name = "sparse_mem_maps_populate_node",
83963 + .file = "include/linux/mm.h",
83964 + .param4 = 1,
83965 +};
83966 +
83967 +struct size_overflow_hash _000403_hash = {
83968 + .next = NULL,
83969 + .name = "vmemmap_alloc_block",
83970 + .file = "include/linux/mm.h",
83971 + .param1 = 1,
83972 +};
83973 +
83974 +struct size_overflow_hash _000404_hash = {
83975 + .next = NULL,
83976 + .name = "sparse_early_mem_maps_alloc_node",
83977 + .file = "mm/sparse.c",
83978 + .param4 = 1,
83979 +};
83980 +
83981 +struct size_overflow_hash _000405_hash = {
83982 + .next = NULL,
83983 + .name = "vmemmap_alloc_block_buf",
83984 + .file = "include/linux/mm.h",
83985 + .param1 = 1,
83986 +};
83987 +
83988 +struct size_overflow_hash _000406_hash = {
83989 + .next = NULL,
83990 + .name = "acpi_battery_write_alarm",
83991 + .file = "drivers/acpi/battery.c",
83992 + .param3 = 1,
83993 +};
83994 +
83995 +struct size_overflow_hash _000407_hash = {
83996 + .next = NULL,
83997 + .name = "acpi_battery_write_alarm",
83998 + .file = "drivers/acpi/sbs.c",
83999 + .param3 = 1,
84000 +};
84001 +
84002 +struct size_overflow_hash _000408_hash = {
84003 + .next = NULL,
84004 + .name = "ad7879_spi_xfer",
84005 + .file = "drivers/input/touchscreen/ad7879-spi.c",
84006 + .param3 = 1,
84007 +};
84008 +
84009 +struct size_overflow_hash _000409_hash = {
84010 + .next = NULL,
84011 + .name = "add_port",
84012 + .file = "drivers/char/virtio_console.c",
84013 + .param2 = 1,
84014 +};
84015 +
84016 +struct size_overflow_hash _000410_hash = {
84017 + .next = NULL,
84018 + .name = "addtgt",
84019 + .file = "drivers/block/aoe/aoecmd.c",
84020 + .param3 = 1,
84021 +};
84022 +
84023 +struct size_overflow_hash _000411_hash = {
84024 + .next = NULL,
84025 + .name = "adu_read",
84026 + .file = "drivers/usb/misc/adutux.c",
84027 + .param3 = 1,
84028 +};
84029 +
84030 +struct size_overflow_hash _000412_hash = {
84031 + .next = NULL,
84032 + .name = "adu_write",
84033 + .file = "drivers/usb/misc/adutux.c",
84034 + .param3 = 1,
84035 +};
84036 +
84037 +struct size_overflow_hash _000413_hash = {
84038 + .next = NULL,
84039 + .name = "aer_inject_write",
84040 + .file = "drivers/pci/pcie/aer/aer_inject.c",
84041 + .param3 = 1,
84042 +};
84043 +
84044 +struct size_overflow_hash _000414_hash = {
84045 + .next = NULL,
84046 + .name = "aes_decrypt_fail_read",
84047 + .file = "drivers/net/wireless/wl1251/debugfs.c",
84048 + .param3 = 1,
84049 +};
84050 +
84051 +struct size_overflow_hash _000415_hash = {
84052 + .next = NULL,
84053 + .name = "aes_decrypt_interrupt_read",
84054 + .file = "drivers/net/wireless/wl1251/debugfs.c",
84055 + .param3 = 1,
84056 +};
84057 +
84058 +struct size_overflow_hash _000416_hash = {
84059 + .next = NULL,
84060 + .name = "aes_decrypt_packets_read",
84061 + .file = "drivers/net/wireless/wl1251/debugfs.c",
84062 + .param3 = 1,
84063 +};
84064 +
84065 +struct size_overflow_hash _000417_hash = {
84066 + .next = NULL,
84067 + .name = "aes_encrypt_fail_read",
84068 + .file = "drivers/net/wireless/wl1251/debugfs.c",
84069 + .param3 = 1,
84070 +};
84071 +
84072 +struct size_overflow_hash _000418_hash = {
84073 + .next = NULL,
84074 + .name = "aes_encrypt_interrupt_read",
84075 + .file = "drivers/net/wireless/wl1251/debugfs.c",
84076 + .param3 = 1,
84077 +};
84078 +
84079 +struct size_overflow_hash _000419_hash = {
84080 + .next = NULL,
84081 + .name = "aes_encrypt_packets_read",
84082 + .file = "drivers/net/wireless/wl1251/debugfs.c",
84083 + .param3 = 1,
84084 +};
84085 +
84086 +struct size_overflow_hash _000420_hash = {
84087 + .next = NULL,
84088 + .name = "afs_alloc_flat_call",
84089 + .file = "fs/afs/rxrpc.c",
84090 + .param2 = 1,
84091 + .param3 = 1,
84092 +};
84093 +
84094 +struct size_overflow_hash _000422_hash = {
84095 + .next = NULL,
84096 + .name = "afs_cell_alloc",
84097 + .file = "fs/afs/cell.c",
84098 + .param2 = 1,
84099 +};
84100 +
84101 +struct size_overflow_hash _000423_hash = {
84102 + .next = NULL,
84103 + .name = "afs_proc_cells_write",
84104 + .file = "fs/afs/proc.c",
84105 + .param3 = 1,
84106 +};
84107 +
84108 +struct size_overflow_hash _000424_hash = {
84109 + .next = NULL,
84110 + .name = "afs_proc_rootcell_write",
84111 + .file = "fs/afs/proc.c",
84112 + .param3 = 1,
84113 +};
84114 +
84115 +struct size_overflow_hash _000425_hash = {
84116 + .next = NULL,
84117 + .name = "aggr_recv_addba_req_evt",
84118 + .file = "drivers/net/wireless/ath/ath6kl/txrx.c",
84119 + .param4 = 1,
84120 +};
84121 +
84122 +struct size_overflow_hash _000426_hash = {
84123 + .next = NULL,
84124 + .name = "agp_3_5_isochronous_node_enable",
84125 + .file = "drivers/char/agp/isoch.c",
84126 + .param3 = 1,
84127 +};
84128 +
84129 +struct size_overflow_hash _000427_hash = {
84130 + .next = NULL,
84131 + .name = "agp_alloc_page_array",
84132 + .file = "drivers/char/agp/generic.c",
84133 + .param1 = 1,
84134 +};
84135 +
84136 +struct size_overflow_hash _000428_hash = {
84137 + .next = NULL,
84138 + .name = "alg_setkey",
84139 + .file = "crypto/af_alg.c",
84140 + .param3 = 1,
84141 +};
84142 +
84143 +struct size_overflow_hash _000429_hash = {
84144 + .next = NULL,
84145 + .name = "alloc_buf",
84146 + .file = "drivers/char/virtio_console.c",
84147 + .param1 = 1,
84148 +};
84149 +
84150 +struct size_overflow_hash _000430_hash = {
84151 + .next = NULL,
84152 + .name = "alloc_context",
84153 + .file = "drivers/md/dm-raid1.c",
84154 + .param1 = 1,
84155 +};
84156 +
84157 +struct size_overflow_hash _000431_hash = {
84158 + .next = NULL,
84159 + .name = "alloc_context",
84160 + .file = "drivers/md/dm-stripe.c",
84161 + .param1 = 1,
84162 +};
84163 +
84164 +struct size_overflow_hash _000432_hash = {
84165 + .next = NULL,
84166 + .name = "__alloc_dev_table",
84167 + .file = "fs/exofs/super.c",
84168 + .param2 = 1,
84169 +};
84170 +
84171 +struct size_overflow_hash _000433_hash = {
84172 + .next = NULL,
84173 + .name = "alloc_ep_req",
84174 + .file = "drivers/usb/gadget/f_midi.c",
84175 + .param2 = 1,
84176 +};
84177 +
84178 +struct size_overflow_hash _000434_hash = {
84179 + .next = NULL,
84180 + .name = "alloc_flex_gd",
84181 + .file = "fs/ext4/resize.c",
84182 + .param1 = 1,
84183 +};
84184 +
84185 +struct size_overflow_hash _000435_hash = {
84186 + .next = NULL,
84187 + .name = "__alloc_objio_seg",
84188 + .file = "fs/nfs/objlayout/objio_osd.c",
84189 + .param1 = 1,
84190 +};
84191 +
84192 +struct size_overflow_hash _000436_hash = {
84193 + .next = NULL,
84194 + .name = "alloc_one_pg_vec_page",
84195 + .file = "net/packet/af_packet.c",
84196 + .param1 = 1,
84197 +};
84198 +
84199 +struct size_overflow_hash _000437_hash = {
84200 + .next = NULL,
84201 + .name = "alloc_ring",
84202 + .file = "drivers/net/ethernet/chelsio/cxgb3/sge.c",
84203 + .param2 = 1,
84204 + .param4 = 1,
84205 +};
84206 +
84207 +struct size_overflow_hash _000438_hash = {
84208 + .next = NULL,
84209 + .name = "alloc_ring",
84210 + .file = "drivers/net/ethernet/chelsio/cxgb4vf/sge.c",
84211 + .param2 = 1,
84212 + .param4 = 1,
84213 +};
84214 +
84215 +struct size_overflow_hash _000441_hash = {
84216 + .next = NULL,
84217 + .name = "alloc_ts_config",
84218 + .file = "include/linux/textsearch.h",
84219 + .param1 = 1,
84220 +};
84221 +
84222 +struct size_overflow_hash _000442_hash = {
84223 + .next = NULL,
84224 + .name = "altera_drscan",
84225 + .file = "drivers/misc/altera-stapl/altera-jtag.c",
84226 + .param2 = 1,
84227 +};
84228 +
84229 +struct size_overflow_hash _000443_hash = {
84230 + .next = NULL,
84231 + .name = "altera_irscan",
84232 + .file = "drivers/misc/altera-stapl/altera-jtag.c",
84233 + .param2 = 1,
84234 +};
84235 +
84236 +struct size_overflow_hash _000444_hash = {
84237 + .next = &_000066_hash,
84238 + .name = "altera_set_dr_post",
84239 + .file = "drivers/misc/altera-stapl/altera-jtag.c",
84240 + .param2 = 1,
84241 +};
84242 +
84243 +struct size_overflow_hash _000445_hash = {
84244 + .next = NULL,
84245 + .name = "altera_set_dr_pre",
84246 + .file = "drivers/misc/altera-stapl/altera-jtag.c",
84247 + .param2 = 1,
84248 +};
84249 +
84250 +struct size_overflow_hash _000446_hash = {
84251 + .next = NULL,
84252 + .name = "altera_set_ir_post",
84253 + .file = "drivers/misc/altera-stapl/altera-jtag.c",
84254 + .param2 = 1,
84255 +};
84256 +
84257 +struct size_overflow_hash _000447_hash = {
84258 + .next = NULL,
84259 + .name = "altera_set_ir_pre",
84260 + .file = "drivers/misc/altera-stapl/altera-jtag.c",
84261 + .param2 = 1,
84262 +};
84263 +
84264 +struct size_overflow_hash _000448_hash = {
84265 + .next = NULL,
84266 + .name = "altera_swap_dr",
84267 + .file = "drivers/misc/altera-stapl/altera-jtag.c",
84268 + .param2 = 1,
84269 +};
84270 +
84271 +struct size_overflow_hash _000449_hash = {
84272 + .next = NULL,
84273 + .name = "altera_swap_ir",
84274 + .file = "drivers/misc/altera-stapl/altera-jtag.c",
84275 + .param2 = 1,
84276 +};
84277 +
84278 +struct size_overflow_hash _000450_hash = {
84279 + .next = NULL,
84280 + .name = "aoedev_flush",
84281 + .file = "drivers/block/aoe/aoedev.c",
84282 + .param2 = 1,
84283 +};
84284 +
84285 +struct size_overflow_hash _000451_hash = {
84286 + .next = NULL,
84287 + .name = "asd_store_update_bios",
84288 + .file = "drivers/scsi/aic94xx/aic94xx_init.c",
84289 + .param4 = 1,
84290 +};
84291 +
84292 +struct size_overflow_hash _000452_hash = {
84293 + .next = NULL,
84294 + .name = "asix_read_cmd",
84295 + .file = "drivers/net/usb/asix.c",
84296 + .param5 = 1,
84297 +};
84298 +
84299 +struct size_overflow_hash _000453_hash = {
84300 + .next = NULL,
84301 + .name = "asix_write_cmd",
84302 + .file = "drivers/net/usb/asix.c",
84303 + .param5 = 1,
84304 +};
84305 +
84306 +struct size_overflow_hash _000454_hash = {
84307 + .next = NULL,
84308 + .name = "asn1_octets_decode",
84309 + .file = "net/ipv4/netfilter/nf_nat_snmp_basic.c",
84310 + .param2 = 1,
84311 +};
84312 +
84313 +struct size_overflow_hash _000455_hash = {
84314 + .next = NULL,
84315 + .name = "asn1_oid_decode",
84316 + .file = "net/ipv4/netfilter/nf_nat_snmp_basic.c",
84317 + .param2 = 1,
84318 +};
84319 +
84320 +struct size_overflow_hash _000456_hash = {
84321 + .next = NULL,
84322 + .name = "asn1_oid_decode",
84323 + .file = "fs/cifs/asn1.c",
84324 + .param2 = 1,
84325 +};
84326 +
84327 +struct size_overflow_hash _000457_hash = {
84328 + .next = NULL,
84329 + .name = "ath6kl_add_bss_if_needed",
84330 + .file = "drivers/net/wireless/ath/ath6kl/cfg80211.c",
84331 + .param6 = 1,
84332 +};
84333 +
84334 +struct size_overflow_hash _000458_hash = {
84335 + .next = NULL,
84336 + .name = "ath6kl_debug_roam_tbl_event",
84337 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
84338 + .param3 = 1,
84339 +};
84340 +
84341 +struct size_overflow_hash _000459_hash = {
84342 + .next = NULL,
84343 + .name = "ath6kl_disconnect_timeout_read",
84344 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
84345 + .param3 = 1,
84346 +};
84347 +
84348 +struct size_overflow_hash _000460_hash = {
84349 + .next = NULL,
84350 + .name = "ath6kl_endpoint_stats_read",
84351 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
84352 + .param3 = 1,
84353 +};
84354 +
84355 +struct size_overflow_hash _000461_hash = {
84356 + .next = NULL,
84357 + .name = "ath6kl_fwlog_mask_read",
84358 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
84359 + .param3 = 1,
84360 +};
84361 +
84362 +struct size_overflow_hash _000462_hash = {
84363 + .next = NULL,
84364 + .name = "ath6kl_fwlog_read",
84365 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
84366 + .param3 = 1,
84367 +};
84368 +
84369 +struct size_overflow_hash _000463_hash = {
84370 + .next = NULL,
84371 + .name = "ath6kl_keepalive_read",
84372 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
84373 + .param3 = 1,
84374 +};
84375 +
84376 +struct size_overflow_hash _000464_hash = {
84377 + .next = NULL,
84378 + .name = "ath6kl_lrssi_roam_read",
84379 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
84380 + .param3 = 1,
84381 +};
84382 +
84383 +struct size_overflow_hash _000465_hash = {
84384 + .next = NULL,
84385 + .name = "ath6kl_regdump_read",
84386 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
84387 + .param3 = 1,
84388 +};
84389 +
84390 +struct size_overflow_hash _000466_hash = {
84391 + .next = NULL,
84392 + .name = "ath6kl_regread_read",
84393 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
84394 + .param3 = 1,
84395 +};
84396 +
84397 +struct size_overflow_hash _000467_hash = {
84398 + .next = NULL,
84399 + .name = "ath6kl_regwrite_read",
84400 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
84401 + .param3 = 1,
84402 +};
84403 +
84404 +struct size_overflow_hash _000468_hash = {
84405 + .next = NULL,
84406 + .name = "ath6kl_roam_table_read",
84407 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
84408 + .param3 = 1,
84409 +};
84410 +
84411 +struct size_overflow_hash _000469_hash = {
84412 + .next = NULL,
84413 + .name = "ath6kl_send_go_probe_resp",
84414 + .file = "drivers/net/wireless/ath/ath6kl/cfg80211.c",
84415 + .param3 = 1,
84416 +};
84417 +
84418 +struct size_overflow_hash _000470_hash = {
84419 + .next = NULL,
84420 + .name = "ath6kl_set_ap_probe_resp_ies",
84421 + .file = "drivers/net/wireless/ath/ath6kl/cfg80211.c",
84422 + .param3 = 1,
84423 +};
84424 +
84425 +struct size_overflow_hash _000471_hash = {
84426 + .next = NULL,
84427 + .name = "ath6kl_set_assoc_req_ies",
84428 + .file = "drivers/net/wireless/ath/ath6kl/cfg80211.c",
84429 + .param3 = 1,
84430 +};
84431 +
84432 +struct size_overflow_hash _000472_hash = {
84433 + .next = NULL,
84434 + .name = "ath6kl_tm_rx_report_event",
84435 + .file = "drivers/net/wireless/ath/ath6kl/testmode.c",
84436 + .param3 = 1,
84437 +};
84438 +
84439 +struct size_overflow_hash _000473_hash = {
84440 + .next = NULL,
84441 + .name = "ath6kl_wmi_send_action_cmd",
84442 + .file = "drivers/net/wireless/ath/ath6kl/wmi.c",
84443 + .param7 = 1,
84444 +};
84445 +
84446 +struct size_overflow_hash _000474_hash = {
84447 + .next = NULL,
84448 + .name = "ath6kl_wmi_send_mgmt_cmd",
84449 + .file = "drivers/net/wireless/ath/ath6kl/wmi.c",
84450 + .param7 = 1,
84451 +};
84452 +
84453 +struct size_overflow_hash _000475_hash = {
84454 + .next = NULL,
84455 + .name = "ath9k_debugfs_read_buf",
84456 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
84457 + .param3 = 1,
84458 +};
84459 +
84460 +struct size_overflow_hash _000476_hash = {
84461 + .next = NULL,
84462 + .name = "atk_debugfs_ggrp_read",
84463 + .file = "drivers/hwmon/asus_atk0110.c",
84464 + .param3 = 1,
84465 +};
84466 +
84467 +struct size_overflow_hash _000477_hash = {
84468 + .next = NULL,
84469 + .name = "atm_get_addr",
84470 + .file = "net/atm/addr.c",
84471 + .param3 = 1,
84472 +};
84473 +
84474 +struct size_overflow_hash _000478_hash = {
84475 + .next = NULL,
84476 + .name = "attach_hdlc_protocol",
84477 + .file = "include/linux/hdlc.h",
84478 + .param3 = 1,
84479 +};
84480 +
84481 +struct size_overflow_hash _000479_hash = {
84482 + .next = NULL,
84483 + .name = "av7110_vbi_write",
84484 + .file = "drivers/media/dvb/ttpci/av7110_v4l.c",
84485 + .param3 = 1,
84486 +};
84487 +
84488 +struct size_overflow_hash _000480_hash = {
84489 + .next = NULL,
84490 + .name = "ax25_setsockopt",
84491 + .file = "net/ax25/af_ax25.c",
84492 + .param5 = 1,
84493 +};
84494 +
84495 +struct size_overflow_hash _000481_hash = {
84496 + .next = NULL,
84497 + .name = "b43_debugfs_read",
84498 + .file = "drivers/net/wireless/b43/debugfs.c",
84499 + .param3 = 1,
84500 +};
84501 +
84502 +struct size_overflow_hash _000482_hash = {
84503 + .next = NULL,
84504 + .name = "b43_debugfs_write",
84505 + .file = "drivers/net/wireless/b43/debugfs.c",
84506 + .param3 = 1,
84507 +};
84508 +
84509 +struct size_overflow_hash _000483_hash = {
84510 + .next = NULL,
84511 + .name = "b43legacy_debugfs_read",
84512 + .file = "drivers/net/wireless/b43legacy/debugfs.c",
84513 + .param3 = 1,
84514 +};
84515 +
84516 +struct size_overflow_hash _000484_hash = {
84517 + .next = NULL,
84518 + .name = "b43legacy_debugfs_write",
84519 + .file = "drivers/net/wireless/b43legacy/debugfs.c",
84520 + .param3 = 1,
84521 +};
84522 +
84523 +struct size_overflow_hash _000485_hash = {
84524 + .next = NULL,
84525 + .name = "b43_nphy_load_samples",
84526 + .file = "drivers/net/wireless/b43/phy_n.c",
84527 + .param3 = 1,
84528 +};
84529 +
84530 +struct size_overflow_hash _000486_hash = {
84531 + .next = NULL,
84532 + .name = "bch_alloc",
84533 + .file = "lib/bch.c",
84534 + .param1 = 1,
84535 +};
84536 +
84537 +struct size_overflow_hash _000487_hash = {
84538 + .next = NULL,
84539 + .name = "bfad_debugfs_read",
84540 + .file = "drivers/scsi/bfa/bfad_debugfs.c",
84541 + .param3 = 1,
84542 +};
84543 +
84544 +struct size_overflow_hash _000488_hash = {
84545 + .next = NULL,
84546 + .name = "bfad_debugfs_read_regrd",
84547 + .file = "drivers/scsi/bfa/bfad_debugfs.c",
84548 + .param3 = 1,
84549 +};
84550 +
84551 +struct size_overflow_hash _000489_hash = {
84552 + .next = NULL,
84553 + .name = "bfad_debugfs_write_regrd",
84554 + .file = "drivers/scsi/bfa/bfad_debugfs.c",
84555 + .param3 = 1,
84556 +};
84557 +
84558 +struct size_overflow_hash _000490_hash = {
84559 + .next = NULL,
84560 + .name = "bfad_debugfs_write_regwr",
84561 + .file = "drivers/scsi/bfa/bfad_debugfs.c",
84562 + .param3 = 1,
84563 +};
84564 +
84565 +struct size_overflow_hash _000491_hash = {
84566 + .next = NULL,
84567 + .name = "bits_to_user",
84568 + .file = "drivers/input/evdev.c",
84569 + .param3 = 1,
84570 +};
84571 +
84572 +struct size_overflow_hash _000492_hash = {
84573 + .next = NULL,
84574 + .name = "bl_pipe_downcall",
84575 + .file = "fs/nfs/blocklayout/blocklayoutdev.c",
84576 + .param3 = 1,
84577 +};
84578 +
84579 +struct size_overflow_hash _000493_hash = {
84580 + .next = NULL,
84581 + .name = "bm_entry_read",
84582 + .file = "fs/binfmt_misc.c",
84583 + .param3 = 1,
84584 +};
84585 +
84586 +struct size_overflow_hash _000494_hash = {
84587 + .next = NULL,
84588 + .name = "bm_realloc_pages",
84589 + .file = "drivers/block/drbd/drbd_bitmap.c",
84590 + .param2 = 1,
84591 +};
84592 +
84593 +struct size_overflow_hash _000495_hash = {
84594 + .next = NULL,
84595 + .name = "bm_status_read",
84596 + .file = "fs/binfmt_misc.c",
84597 + .param3 = 1,
84598 +};
84599 +
84600 +struct size_overflow_hash _000496_hash = {
84601 + .next = NULL,
84602 + .name = "bnad_debugfs_read",
84603 + .file = "drivers/net/ethernet/brocade/bna/bnad_debugfs.c",
84604 + .param3 = 1,
84605 +};
84606 +
84607 +struct size_overflow_hash _000497_hash = {
84608 + .next = NULL,
84609 + .name = "bnad_debugfs_read_regrd",
84610 + .file = "drivers/net/ethernet/brocade/bna/bnad_debugfs.c",
84611 + .param3 = 1,
84612 +};
84613 +
84614 +struct size_overflow_hash _000498_hash = {
84615 + .next = NULL,
84616 + .name = "bnad_debugfs_write_regrd",
84617 + .file = "drivers/net/ethernet/brocade/bna/bnad_debugfs.c",
84618 + .param3 = 1,
84619 +};
84620 +
84621 +struct size_overflow_hash _000499_hash = {
84622 + .next = NULL,
84623 + .name = "bnad_debugfs_write_regwr",
84624 + .file = "drivers/net/ethernet/brocade/bna/bnad_debugfs.c",
84625 + .param3 = 1,
84626 +};
84627 +
84628 +struct size_overflow_hash _000500_hash = {
84629 + .next = NULL,
84630 + .name = "bnx2fc_cmd_mgr_alloc",
84631 + .file = "drivers/scsi/bnx2fc/bnx2fc_io.c",
84632 + .param2 = 1,
84633 + .param3 = 1,
84634 +};
84635 +
84636 +struct size_overflow_hash _000502_hash = {
84637 + .next = NULL,
84638 + .name = "btmrvl_curpsmode_read",
84639 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84640 + .param3 = 1,
84641 +};
84642 +
84643 +struct size_overflow_hash _000503_hash = {
84644 + .next = NULL,
84645 + .name = "btmrvl_gpiogap_read",
84646 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84647 + .param3 = 1,
84648 +};
84649 +
84650 +struct size_overflow_hash _000504_hash = {
84651 + .next = NULL,
84652 + .name = "btmrvl_gpiogap_write",
84653 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84654 + .param3 = 1,
84655 +};
84656 +
84657 +struct size_overflow_hash _000505_hash = {
84658 + .next = NULL,
84659 + .name = "btmrvl_hscfgcmd_read",
84660 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84661 + .param3 = 1,
84662 +};
84663 +
84664 +struct size_overflow_hash _000506_hash = {
84665 + .next = NULL,
84666 + .name = "btmrvl_hscfgcmd_write",
84667 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84668 + .param3 = 1,
84669 +};
84670 +
84671 +struct size_overflow_hash _000507_hash = {
84672 + .next = &_000006_hash,
84673 + .name = "btmrvl_hscmd_read",
84674 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84675 + .param3 = 1,
84676 +};
84677 +
84678 +struct size_overflow_hash _000508_hash = {
84679 + .next = NULL,
84680 + .name = "btmrvl_hscmd_write",
84681 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84682 + .param3 = 1,
84683 +};
84684 +
84685 +struct size_overflow_hash _000509_hash = {
84686 + .next = NULL,
84687 + .name = "btmrvl_hsmode_read",
84688 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84689 + .param3 = 1,
84690 +};
84691 +
84692 +struct size_overflow_hash _000510_hash = {
84693 + .next = NULL,
84694 + .name = "btmrvl_hsmode_write",
84695 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84696 + .param3 = 1,
84697 +};
84698 +
84699 +struct size_overflow_hash _000511_hash = {
84700 + .next = NULL,
84701 + .name = "btmrvl_hsstate_read",
84702 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84703 + .param3 = 1,
84704 +};
84705 +
84706 +struct size_overflow_hash _000512_hash = {
84707 + .next = NULL,
84708 + .name = "btmrvl_pscmd_read",
84709 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84710 + .param3 = 1,
84711 +};
84712 +
84713 +struct size_overflow_hash _000513_hash = {
84714 + .next = NULL,
84715 + .name = "btmrvl_pscmd_write",
84716 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84717 + .param3 = 1,
84718 +};
84719 +
84720 +struct size_overflow_hash _000514_hash = {
84721 + .next = NULL,
84722 + .name = "btmrvl_psmode_read",
84723 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84724 + .param3 = 1,
84725 +};
84726 +
84727 +struct size_overflow_hash _000515_hash = {
84728 + .next = NULL,
84729 + .name = "btmrvl_psmode_write",
84730 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84731 + .param3 = 1,
84732 +};
84733 +
84734 +struct size_overflow_hash _000516_hash = {
84735 + .next = NULL,
84736 + .name = "btmrvl_psstate_read",
84737 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84738 + .param3 = 1,
84739 +};
84740 +
84741 +struct size_overflow_hash _000517_hash = {
84742 + .next = NULL,
84743 + .name = "btmrvl_txdnldready_read",
84744 + .file = "drivers/bluetooth/btmrvl_debugfs.c",
84745 + .param3 = 1,
84746 +};
84747 +
84748 +struct size_overflow_hash _000518_hash = {
84749 + .next = NULL,
84750 + .name = "btrfs_alloc_delayed_item",
84751 + .file = "fs/btrfs/delayed-inode.c",
84752 + .param1 = 1,
84753 +};
84754 +
84755 +struct size_overflow_hash _000519_hash = {
84756 + .next = NULL,
84757 + .name = "btrfs_copy_from_user",
84758 + .file = "fs/btrfs/file.c",
84759 + .param3 = 1,
84760 +};
84761 +
84762 +struct size_overflow_hash _000520_hash = {
84763 + .next = NULL,
84764 + .name = "__btrfs_map_block",
84765 + .file = "fs/btrfs/volumes.c",
84766 + .param3 = 1,
84767 +};
84768 +
84769 +struct size_overflow_hash _000521_hash = {
84770 + .next = NULL,
84771 + .name = "__c4iw_init_resource_fifo",
84772 + .file = "drivers/infiniband/hw/cxgb4/resource.c",
84773 + .param3 = 1,
84774 +};
84775 +
84776 +struct size_overflow_hash _000522_hash = {
84777 + .next = NULL,
84778 + .name = "cache_do_downcall",
84779 + .file = "net/sunrpc/cache.c",
84780 + .param3 = 1,
84781 +};
84782 +
84783 +struct size_overflow_hash _000523_hash = {
84784 + .next = NULL,
84785 + .name = "cachefiles_daemon_write",
84786 + .file = "fs/cachefiles/daemon.c",
84787 + .param3 = 1,
84788 +};
84789 +
84790 +struct size_overflow_hash _000524_hash = {
84791 + .next = NULL,
84792 + .name = "cache_read",
84793 + .file = "net/sunrpc/cache.c",
84794 + .param3 = 1,
84795 +};
84796 +
84797 +struct size_overflow_hash _000525_hash = {
84798 + .next = NULL,
84799 + .name = "ca_extend",
84800 + .file = "drivers/md/persistent-data/dm-space-map-checker.c",
84801 + .param2 = 1,
84802 +};
84803 +
84804 +struct size_overflow_hash _000526_hash = {
84805 + .next = NULL,
84806 + .name = "calc_hmac",
84807 + .file = "security/keys/encrypted-keys/encrypted.c",
84808 + .param3 = 1,
84809 +};
84810 +
84811 +struct size_overflow_hash _000527_hash = {
84812 + .next = NULL,
84813 + .name = "capi_write",
84814 + .file = "drivers/isdn/capi/capi.c",
84815 + .param3 = 1,
84816 +};
84817 +
84818 +struct size_overflow_hash _000528_hash = {
84819 + .next = NULL,
84820 + .name = "carl9170_cmd_buf",
84821 + .file = "drivers/net/wireless/ath/carl9170/cmd.c",
84822 + .param3 = 1,
84823 +};
84824 +
84825 +struct size_overflow_hash _000529_hash = {
84826 + .next = NULL,
84827 + .name = "carl9170_debugfs_read",
84828 + .file = "drivers/net/wireless/ath/carl9170/debug.c",
84829 + .param3 = 1,
84830 +};
84831 +
84832 +struct size_overflow_hash _000530_hash = {
84833 + .next = NULL,
84834 + .name = "carl9170_debugfs_write",
84835 + .file = "drivers/net/wireless/ath/carl9170/debug.c",
84836 + .param3 = 1,
84837 +};
84838 +
84839 +struct size_overflow_hash _000531_hash = {
84840 + .next = NULL,
84841 + .name = "cciss_proc_write",
84842 + .file = "drivers/block/cciss.c",
84843 + .param3 = 1,
84844 +};
84845 +
84846 +struct size_overflow_hash _000532_hash = {
84847 + .next = NULL,
84848 + .name = "ceph_buffer_new",
84849 + .file = "include/linux/ceph/buffer.h",
84850 + .param1 = 1,
84851 +};
84852 +
84853 +struct size_overflow_hash _000533_hash = {
84854 + .next = NULL,
84855 + .name = "ceph_copy_page_vector_to_user",
84856 + .file = "include/linux/ceph/libceph.h",
84857 + .param4 = 1,
84858 +};
84859 +
84860 +struct size_overflow_hash _000534_hash = {
84861 + .next = NULL,
84862 + .name = "ceph_copy_user_to_page_vector",
84863 + .file = "include/linux/ceph/libceph.h",
84864 + .param4 = 1,
84865 +};
84866 +
84867 +struct size_overflow_hash _000535_hash = {
84868 + .next = NULL,
84869 + .name = "ceph_read_dir",
84870 + .file = "fs/ceph/dir.c",
84871 + .param3 = 1,
84872 +};
84873 +
84874 +struct size_overflow_hash _000536_hash = {
84875 + .next = NULL,
84876 + .name = "ceph_setxattr",
84877 + .file = "fs/ceph/xattr.c",
84878 + .param4 = 1,
84879 +};
84880 +
84881 +struct size_overflow_hash _000537_hash = {
84882 + .next = NULL,
84883 + .name = "cfg80211_connect_result",
84884 + .file = "include/net/cfg80211.h",
84885 + .param4 = 1,
84886 + .param6 = 1,
84887 +};
84888 +
84889 +struct size_overflow_hash _000539_hash = {
84890 + .next = NULL,
84891 + .name = "cfg80211_disconnected",
84892 + .file = "include/net/cfg80211.h",
84893 + .param4 = 1,
84894 +};
84895 +
84896 +struct size_overflow_hash _000540_hash = {
84897 + .next = NULL,
84898 + .name = "cfg80211_inform_bss",
84899 + .file = "include/net/cfg80211.h",
84900 + .param8 = 1,
84901 +};
84902 +
84903 +struct size_overflow_hash _000541_hash = {
84904 + .next = NULL,
84905 + .name = "cfg80211_inform_bss_frame",
84906 + .file = "include/net/cfg80211.h",
84907 + .param4 = 1,
84908 +};
84909 +
84910 +struct size_overflow_hash _000542_hash = {
84911 + .next = NULL,
84912 + .name = "cfg80211_roamed_bss",
84913 + .file = "include/net/cfg80211.h",
84914 + .param4 = 1,
84915 + .param6 = 1,
84916 +};
84917 +
84918 +struct size_overflow_hash _000544_hash = {
84919 + .next = NULL,
84920 + .name = "cfi_read_pri",
84921 + .file = "include/linux/mtd/cfi.h",
84922 + .param3 = 1,
84923 +};
84924 +
84925 +struct size_overflow_hash _000545_hash = {
84926 + .next = NULL,
84927 + .name = "channel_type_read",
84928 + .file = "net/mac80211/debugfs.c",
84929 + .param3 = 1,
84930 +};
84931 +
84932 +struct size_overflow_hash _000546_hash = {
84933 + .next = NULL,
84934 + .name = "cifs_idmap_key_instantiate",
84935 + .file = "fs/cifs/cifsacl.c",
84936 + .param3 = 1,
84937 +};
84938 +
84939 +struct size_overflow_hash _000547_hash = {
84940 + .next = NULL,
84941 + .name = "cifs_readdata_alloc",
84942 + .file = "fs/cifs/cifssmb.c",
84943 + .param1 = 1,
84944 +};
84945 +
84946 +struct size_overflow_hash _000548_hash = {
84947 + .next = NULL,
84948 + .name = "cifs_security_flags_proc_write",
84949 + .file = "fs/cifs/cifs_debug.c",
84950 + .param3 = 1,
84951 +};
84952 +
84953 +struct size_overflow_hash _000549_hash = {
84954 + .next = NULL,
84955 + .name = "cifs_setxattr",
84956 + .file = "fs/cifs/xattr.c",
84957 + .param4 = 1,
84958 +};
84959 +
84960 +struct size_overflow_hash _000550_hash = {
84961 + .next = NULL,
84962 + .name = "cifs_spnego_key_instantiate",
84963 + .file = "fs/cifs/cifs_spnego.c",
84964 + .param3 = 1,
84965 +};
84966 +
84967 +struct size_overflow_hash _000551_hash = {
84968 + .next = NULL,
84969 + .name = "cifs_writedata_alloc",
84970 + .file = "fs/cifs/cifssmb.c",
84971 + .param1 = 1,
84972 +};
84973 +
84974 +struct size_overflow_hash _000552_hash = {
84975 + .next = NULL,
84976 + .name = "ci_ll_write",
84977 + .file = "drivers/media/dvb/ttpci/av7110_ca.c",
84978 + .param4 = 1,
84979 +};
84980 +
84981 +struct size_overflow_hash _000553_hash = {
84982 + .next = NULL,
84983 + .name = "clusterip_proc_write",
84984 + .file = "net/ipv4/netfilter/ipt_CLUSTERIP.c",
84985 + .param3 = 1,
84986 +};
84987 +
84988 +struct size_overflow_hash _000554_hash = {
84989 + .next = &_000108_hash,
84990 + .name = "cm4040_write",
84991 + .file = "drivers/char/pcmcia/cm4040_cs.c",
84992 + .param3 = 1,
84993 +};
84994 +
84995 +struct size_overflow_hash _000555_hash = {
84996 + .next = NULL,
84997 + .name = "cm_copy_private_data",
84998 + .file = "drivers/infiniband/core/cm.c",
84999 + .param2 = 1,
85000 +};
85001 +
85002 +struct size_overflow_hash _000556_hash = {
85003 + .next = NULL,
85004 + .name = "cmm_write",
85005 + .file = "drivers/char/pcmcia/cm4000_cs.c",
85006 + .param3 = 1,
85007 +};
85008 +
85009 +struct size_overflow_hash _000557_hash = {
85010 + .next = NULL,
85011 + .name = "cm_write",
85012 + .file = "drivers/acpi/custom_method.c",
85013 + .param3 = 1,
85014 +};
85015 +
85016 +struct size_overflow_hash _000558_hash = {
85017 + .next = NULL,
85018 + .name = "coda_psdev_read",
85019 + .file = "fs/coda/psdev.c",
85020 + .param3 = 1,
85021 +};
85022 +
85023 +struct size_overflow_hash _000559_hash = {
85024 + .next = NULL,
85025 + .name = "coda_psdev_write",
85026 + .file = "fs/coda/psdev.c",
85027 + .param3 = 1,
85028 +};
85029 +
85030 +struct size_overflow_hash _000560_hash = {
85031 + .next = NULL,
85032 + .name = "codec_list_read_file",
85033 + .file = "sound/soc/soc-core.c",
85034 + .param3 = 1,
85035 +};
85036 +
85037 +struct size_overflow_hash _000561_hash = {
85038 + .next = NULL,
85039 + .name = "codec_reg_read_file",
85040 + .file = "sound/soc/soc-core.c",
85041 + .param3 = 1,
85042 +};
85043 +
85044 +struct size_overflow_hash _000562_hash = {
85045 + .next = NULL,
85046 + .name = "command_file_write",
85047 + .file = "drivers/misc/ibmasm/ibmasmfs.c",
85048 + .param3 = 1,
85049 +};
85050 +
85051 +struct size_overflow_hash _000563_hash = {
85052 + .next = NULL,
85053 + .name = "command_write",
85054 + .file = "drivers/uwb/uwb-debug.c",
85055 + .param3 = 1,
85056 +};
85057 +
85058 +struct size_overflow_hash _000564_hash = {
85059 + .next = NULL,
85060 + .name = "concat_writev",
85061 + .file = "drivers/mtd/mtdconcat.c",
85062 + .param3 = 1,
85063 +};
85064 +
85065 +struct size_overflow_hash _000565_hash = {
85066 + .next = NULL,
85067 + .name = "configfs_read_file",
85068 + .file = "fs/configfs/file.c",
85069 + .param3 = 1,
85070 +};
85071 +
85072 +struct size_overflow_hash _000566_hash = {
85073 + .next = NULL,
85074 + .name = "context_alloc",
85075 + .file = "drivers/md/dm-raid.c",
85076 + .param3 = 1,
85077 +};
85078 +
85079 +struct size_overflow_hash _000567_hash = {
85080 + .next = NULL,
85081 + .name = "copy_counters_to_user",
85082 + .file = "net/bridge/netfilter/ebtables.c",
85083 + .param5 = 1,
85084 +};
85085 +
85086 +struct size_overflow_hash _000568_hash = {
85087 + .next = NULL,
85088 + .name = "copy_entries_to_user",
85089 + .file = "net/ipv6/netfilter/ip6_tables.c",
85090 + .param1 = 1,
85091 +};
85092 +
85093 +struct size_overflow_hash _000569_hash = {
85094 + .next = NULL,
85095 + .name = "copy_entries_to_user",
85096 + .file = "net/ipv4/netfilter/arp_tables.c",
85097 + .param1 = 1,
85098 +};
85099 +
85100 +struct size_overflow_hash _000570_hash = {
85101 + .next = NULL,
85102 + .name = "copy_entries_to_user",
85103 + .file = "net/ipv4/netfilter/ip_tables.c",
85104 + .param1 = 1,
85105 +};
85106 +
85107 +struct size_overflow_hash _000571_hash = {
85108 + .next = NULL,
85109 + .name = "copy_from_user_toio",
85110 + .file = "include/sound/core.h",
85111 + .param3 = 1,
85112 +};
85113 +
85114 +struct size_overflow_hash _000572_hash = {
85115 + .next = NULL,
85116 + .name = "copy_macs",
85117 + .file = "net/atm/mpc.c",
85118 + .param4 = 1,
85119 +};
85120 +
85121 +struct size_overflow_hash _000573_hash = {
85122 + .next = NULL,
85123 + .name = "copy_to_user_fromio",
85124 + .file = "include/sound/core.h",
85125 + .param3 = 1,
85126 +};
85127 +
85128 +struct size_overflow_hash _000574_hash = {
85129 + .next = NULL,
85130 + .name = "cosa_write",
85131 + .file = "drivers/net/wan/cosa.c",
85132 + .param3 = 1,
85133 +};
85134 +
85135 +struct size_overflow_hash _000575_hash = {
85136 + .next = NULL,
85137 + .name = "create_attr_set",
85138 + .file = "drivers/platform/x86/thinkpad_acpi.c",
85139 + .param1 = 1,
85140 +};
85141 +
85142 +struct size_overflow_hash _000576_hash = {
85143 + .next = NULL,
85144 + .name = "create_entry",
85145 + .file = "fs/binfmt_misc.c",
85146 + .param2 = 1,
85147 +};
85148 +
85149 +struct size_overflow_hash _000577_hash = {
85150 + .next = NULL,
85151 + .name = "create_gpadl_header",
85152 + .file = "drivers/hv/channel.c",
85153 + .param2 = 1,
85154 +};
85155 +
85156 +struct size_overflow_hash _000578_hash = {
85157 + .next = NULL,
85158 + .name = "create_queues",
85159 + .file = "drivers/atm/ambassador.c",
85160 + .param2 = 1,
85161 + .param3 = 1,
85162 +};
85163 +
85164 +struct size_overflow_hash _000580_hash = {
85165 + .next = NULL,
85166 + .name = "_create_sg_bios",
85167 + .file = "drivers/scsi/osd/osd_initiator.c",
85168 + .param4 = 1,
85169 +};
85170 +
85171 +struct size_overflow_hash _000581_hash = {
85172 + .next = NULL,
85173 + .name = "cryptd_alloc_instance",
85174 + .file = "crypto/cryptd.c",
85175 + .param2 = 1,
85176 + .param3 = 1,
85177 +};
85178 +
85179 +struct size_overflow_hash _000583_hash = {
85180 + .next = NULL,
85181 + .name = "cryptd_hash_setkey",
85182 + .file = "crypto/cryptd.c",
85183 + .param3 = 1,
85184 +};
85185 +
85186 +struct size_overflow_hash _000584_hash = {
85187 + .next = NULL,
85188 + .name = "crypto_authenc_esn_setkey",
85189 + .file = "crypto/authencesn.c",
85190 + .param3 = 1,
85191 +};
85192 +
85193 +struct size_overflow_hash _000585_hash = {
85194 + .next = NULL,
85195 + .name = "crypto_authenc_setkey",
85196 + .file = "crypto/authenc.c",
85197 + .param3 = 1,
85198 +};
85199 +
85200 +struct size_overflow_hash _000586_hash = {
85201 + .next = NULL,
85202 + .name = "ctrl_out",
85203 + .file = "drivers/usb/misc/usbtest.c",
85204 + .param3 = 1,
85205 + .param5 = 1,
85206 +};
85207 +
85208 +struct size_overflow_hash _000588_hash = {
85209 + .next = NULL,
85210 + .name = "cx18_copy_buf_to_user",
85211 + .file = "drivers/media/video/cx18/cx18-fileops.c",
85212 + .param4 = 1,
85213 +};
85214 +
85215 +struct size_overflow_hash _000589_hash = {
85216 + .next = NULL,
85217 + .name = "cx24116_writeregN",
85218 + .file = "drivers/media/dvb/frontends/cx24116.c",
85219 + .param4 = 1,
85220 +};
85221 +
85222 +struct size_overflow_hash _000590_hash = {
85223 + .next = NULL,
85224 + .name = "cxgb_alloc_mem",
85225 + .file = "drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c",
85226 + .param1 = 1,
85227 +};
85228 +
85229 +struct size_overflow_hash _000591_hash = {
85230 + .next = NULL,
85231 + .name = "cxgbi_alloc_big_mem",
85232 + .file = "drivers/scsi/cxgbi/libcxgbi.h",
85233 + .param1 = 1,
85234 +};
85235 +
85236 +struct size_overflow_hash _000592_hash = {
85237 + .next = NULL,
85238 + .name = "cxgbi_device_register",
85239 + .file = "drivers/scsi/cxgbi/libcxgbi.c",
85240 + .param1 = 1,
85241 + .param2 = 1,
85242 +};
85243 +
85244 +struct size_overflow_hash _000594_hash = {
85245 + .next = NULL,
85246 + .name = "__cxio_init_resource_fifo",
85247 + .file = "drivers/infiniband/hw/cxgb3/cxio_resource.c",
85248 + .param3 = 1,
85249 +};
85250 +
85251 +struct size_overflow_hash _000595_hash = {
85252 + .next = NULL,
85253 + .name = "dac960_user_command_proc_write",
85254 + .file = "drivers/block/DAC960.c",
85255 + .param3 = 1,
85256 +};
85257 +
85258 +struct size_overflow_hash _000596_hash = {
85259 + .next = NULL,
85260 + .name = "dai_list_read_file",
85261 + .file = "sound/soc/soc-core.c",
85262 + .param3 = 1,
85263 +};
85264 +
85265 +struct size_overflow_hash _000597_hash = {
85266 + .next = NULL,
85267 + .name = "dapm_bias_read_file",
85268 + .file = "sound/soc/soc-dapm.c",
85269 + .param3 = 1,
85270 +};
85271 +
85272 +struct size_overflow_hash _000598_hash = {
85273 + .next = NULL,
85274 + .name = "dapm_widget_power_read_file",
85275 + .file = "sound/soc/soc-dapm.c",
85276 + .param3 = 1,
85277 +};
85278 +
85279 +struct size_overflow_hash _000599_hash = {
85280 + .next = NULL,
85281 + .name = "datablob_format",
85282 + .file = "security/keys/encrypted-keys/encrypted.c",
85283 + .param2 = 1,
85284 +};
85285 +
85286 +struct size_overflow_hash _000600_hash = {
85287 + .next = NULL,
85288 + .name = "dbgfs_frame",
85289 + .file = "drivers/net/caif/caif_spi.c",
85290 + .param3 = 1,
85291 +};
85292 +
85293 +struct size_overflow_hash _000601_hash = {
85294 + .next = NULL,
85295 + .name = "dbgfs_state",
85296 + .file = "drivers/net/caif/caif_spi.c",
85297 + .param3 = 1,
85298 +};
85299 +
85300 +struct size_overflow_hash _000602_hash = {
85301 + .next = NULL,
85302 + .name = "dccp_feat_clone_sp_val",
85303 + .file = "net/dccp/feat.c",
85304 + .param3 = 1,
85305 +};
85306 +
85307 +struct size_overflow_hash _000603_hash = {
85308 + .next = NULL,
85309 + .name = "dccp_setsockopt_ccid",
85310 + .file = "net/dccp/proto.c",
85311 + .param4 = 1,
85312 +};
85313 +
85314 +struct size_overflow_hash _000604_hash = {
85315 + .next = NULL,
85316 + .name = "dccp_setsockopt_service",
85317 + .file = "net/dccp/proto.c",
85318 + .param4 = 1,
85319 +};
85320 +
85321 +struct size_overflow_hash _000605_hash = {
85322 + .next = NULL,
85323 + .name = "ddb_input_read",
85324 + .file = "drivers/media/dvb/ddbridge/ddbridge-core.c",
85325 + .param3 = 1,
85326 +};
85327 +
85328 +struct size_overflow_hash _000606_hash = {
85329 + .next = NULL,
85330 + .name = "ddb_output_write",
85331 + .file = "drivers/media/dvb/ddbridge/ddbridge-core.c",
85332 + .param3 = 1,
85333 +};
85334 +
85335 +struct size_overflow_hash _000607_hash = {
85336 + .next = NULL,
85337 + .name = "ddp_make_gl",
85338 + .file = "drivers/scsi/cxgbi/libcxgbi.c",
85339 + .param1 = 1,
85340 +};
85341 +
85342 +struct size_overflow_hash _000608_hash = {
85343 + .next = NULL,
85344 + .name = "debugfs_read",
85345 + .file = "drivers/infiniband/hw/cxgb4/device.c",
85346 + .param3 = 1,
85347 +};
85348 +
85349 +struct size_overflow_hash _000609_hash = {
85350 + .next = NULL,
85351 + .name = "debugfs_read",
85352 + .file = "drivers/char/virtio_console.c",
85353 + .param3 = 1,
85354 +};
85355 +
85356 +struct size_overflow_hash _000610_hash = {
85357 + .next = NULL,
85358 + .name = "debug_output",
85359 + .file = "drivers/usb/host/ohci-dbg.c",
85360 + .param3 = 1,
85361 +};
85362 +
85363 +struct size_overflow_hash _000611_hash = {
85364 + .next = NULL,
85365 + .name = "debug_output",
85366 + .file = "drivers/usb/host/ehci-dbg.c",
85367 + .param3 = 1,
85368 +};
85369 +
85370 +struct size_overflow_hash _000612_hash = {
85371 + .next = NULL,
85372 + .name = "debug_read",
85373 + .file = "fs/ocfs2/dlm/dlmdebug.c",
85374 + .param3 = 1,
85375 +};
85376 +
85377 +struct size_overflow_hash _000613_hash = {
85378 + .next = NULL,
85379 + .name = "dev_config",
85380 + .file = "drivers/usb/gadget/inode.c",
85381 + .param3 = 1,
85382 +};
85383 +
85384 +struct size_overflow_hash _000614_hash = {
85385 + .next = NULL,
85386 + .name = "device_write",
85387 + .file = "fs/dlm/user.c",
85388 + .param3 = 1,
85389 +};
85390 +
85391 +struct size_overflow_hash _000615_hash = {
85392 + .next = NULL,
85393 + .name = "dev_read",
85394 + .file = "drivers/media/video/gspca/gspca.c",
85395 + .param3 = 1,
85396 +};
85397 +
85398 +struct size_overflow_hash _000616_hash = {
85399 + .next = NULL,
85400 + .name = "dfs_file_read",
85401 + .file = "drivers/mtd/ubi/debug.c",
85402 + .param3 = 1,
85403 +};
85404 +
85405 +struct size_overflow_hash _000617_hash = {
85406 + .next = NULL,
85407 + .name = "dfs_file_write",
85408 + .file = "drivers/mtd/ubi/debug.c",
85409 + .param3 = 1,
85410 +};
85411 +
85412 +struct size_overflow_hash _000618_hash = {
85413 + .next = NULL,
85414 + .name = "direct_entry",
85415 + .file = "drivers/misc/lkdtm.c",
85416 + .param3 = 1,
85417 +};
85418 +
85419 +struct size_overflow_hash _000619_hash = {
85420 + .next = NULL,
85421 + .name = "dispatch_proc_write",
85422 + .file = "drivers/platform/x86/thinkpad_acpi.c",
85423 + .param3 = 1,
85424 +};
85425 +
85426 +struct size_overflow_hash _000620_hash = {
85427 + .next = NULL,
85428 + .name = "diva_os_malloc",
85429 + .file = "drivers/isdn/hardware/eicon/platform.h",
85430 + .param2 = 1,
85431 +};
85432 +
85433 +struct size_overflow_hash _000621_hash = {
85434 + .next = NULL,
85435 + .name = "dlmfs_file_read",
85436 + .file = "fs/ocfs2/dlmfs/dlmfs.c",
85437 + .param3 = 1,
85438 +};
85439 +
85440 +struct size_overflow_hash _000622_hash = {
85441 + .next = NULL,
85442 + .name = "dlmfs_file_write",
85443 + .file = "fs/ocfs2/dlmfs/dlmfs.c",
85444 + .param3 = 1,
85445 +};
85446 +
85447 +struct size_overflow_hash _000623_hash = {
85448 + .next = NULL,
85449 + .name = "dma_attach",
85450 + .file = "drivers/net/wireless/brcm80211/brcmsmac/dma.c",
85451 + .param6 = 1,
85452 + .param7 = 1,
85453 +};
85454 +
85455 +struct size_overflow_hash _000625_hash = {
85456 + .next = NULL,
85457 + .name = "dma_rx_errors_read",
85458 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85459 + .param3 = 1,
85460 +};
85461 +
85462 +struct size_overflow_hash _000626_hash = {
85463 + .next = NULL,
85464 + .name = "dma_rx_requested_read",
85465 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85466 + .param3 = 1,
85467 +};
85468 +
85469 +struct size_overflow_hash _000627_hash = {
85470 + .next = NULL,
85471 + .name = "dma_show_regs",
85472 + .file = "drivers/tty/serial/mfd.c",
85473 + .param3 = 1,
85474 +};
85475 +
85476 +struct size_overflow_hash _000628_hash = {
85477 + .next = NULL,
85478 + .name = "dma_tx_errors_read",
85479 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85480 + .param3 = 1,
85481 +};
85482 +
85483 +struct size_overflow_hash _000629_hash = {
85484 + .next = NULL,
85485 + .name = "dma_tx_requested_read",
85486 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85487 + .param3 = 1,
85488 +};
85489 +
85490 +struct size_overflow_hash _000630_hash = {
85491 + .next = NULL,
85492 + .name = "dm_read",
85493 + .file = "drivers/net/usb/dm9601.c",
85494 + .param3 = 1,
85495 +};
85496 +
85497 +struct size_overflow_hash _000631_hash = {
85498 + .next = NULL,
85499 + .name = "dm_vcalloc",
85500 + .file = "include/linux/device-mapper.h",
85501 + .param1 = 1,
85502 + .param2 = 1,
85503 +};
85504 +
85505 +struct size_overflow_hash _000633_hash = {
85506 + .next = NULL,
85507 + .name = "dm_write",
85508 + .file = "drivers/net/usb/dm9601.c",
85509 + .param3 = 1,
85510 +};
85511 +
85512 +struct size_overflow_hash _000634_hash = {
85513 + .next = NULL,
85514 + .name = "__dn_setsockopt",
85515 + .file = "net/decnet/af_decnet.c",
85516 + .param5 = 1,
85517 +};
85518 +
85519 +struct size_overflow_hash _000635_hash = {
85520 + .next = NULL,
85521 + .name = "dns_query",
85522 + .file = "include/linux/dns_resolver.h",
85523 + .param3 = 1,
85524 +};
85525 +
85526 +struct size_overflow_hash _000636_hash = {
85527 + .next = NULL,
85528 + .name = "dns_resolver_instantiate",
85529 + .file = "net/dns_resolver/dns_key.c",
85530 + .param3 = 1,
85531 +};
85532 +
85533 +struct size_overflow_hash _000637_hash = {
85534 + .next = NULL,
85535 + .name = "dns_resolver_read",
85536 + .file = "net/dns_resolver/dns_key.c",
85537 + .param3 = 1,
85538 +};
85539 +
85540 +struct size_overflow_hash _000638_hash = {
85541 + .next = NULL,
85542 + .name = "do_add_counters",
85543 + .file = "net/ipv6/netfilter/ip6_tables.c",
85544 + .param3 = 1,
85545 +};
85546 +
85547 +struct size_overflow_hash _000639_hash = {
85548 + .next = NULL,
85549 + .name = "do_add_counters",
85550 + .file = "net/ipv4/netfilter/ip_tables.c",
85551 + .param3 = 1,
85552 +};
85553 +
85554 +struct size_overflow_hash _000640_hash = {
85555 + .next = NULL,
85556 + .name = "do_add_counters",
85557 + .file = "net/ipv4/netfilter/arp_tables.c",
85558 + .param3 = 1,
85559 +};
85560 +
85561 +struct size_overflow_hash _000641_hash = {
85562 + .next = NULL,
85563 + .name = "__do_config_autodelink",
85564 + .file = "drivers/usb/storage/realtek_cr.c",
85565 + .param3 = 1,
85566 +};
85567 +
85568 +struct size_overflow_hash _000642_hash = {
85569 + .next = NULL,
85570 + .name = "do_ipv6_setsockopt",
85571 + .file = "net/ipv6/ipv6_sockglue.c",
85572 + .param5 = 1,
85573 +};
85574 +
85575 +struct size_overflow_hash _000643_hash = {
85576 + .next = NULL,
85577 + .name = "do_ip_vs_set_ctl",
85578 + .file = "net/netfilter/ipvs/ip_vs_ctl.c",
85579 + .param4 = 1,
85580 +};
85581 +
85582 +struct size_overflow_hash _000644_hash = {
85583 + .next = NULL,
85584 + .name = "do_register_entry",
85585 + .file = "drivers/misc/lkdtm.c",
85586 + .param4 = 1,
85587 +};
85588 +
85589 +struct size_overflow_hash _000645_hash = {
85590 + .next = NULL,
85591 + .name = "__do_replace",
85592 + .file = "net/ipv6/netfilter/ip6_tables.c",
85593 + .param5 = 1,
85594 +};
85595 +
85596 +struct size_overflow_hash _000646_hash = {
85597 + .next = NULL,
85598 + .name = "__do_replace",
85599 + .file = "net/ipv4/netfilter/ip_tables.c",
85600 + .param5 = 1,
85601 +};
85602 +
85603 +struct size_overflow_hash _000647_hash = {
85604 + .next = NULL,
85605 + .name = "__do_replace",
85606 + .file = "net/ipv4/netfilter/arp_tables.c",
85607 + .param5 = 1,
85608 +};
85609 +
85610 +struct size_overflow_hash _000648_hash = {
85611 + .next = NULL,
85612 + .name = "do_sync",
85613 + .file = "fs/gfs2/quota.c",
85614 + .param1 = 1,
85615 +};
85616 +
85617 +struct size_overflow_hash _000649_hash = {
85618 + .next = NULL,
85619 + .name = "do_update_counters",
85620 + .file = "net/bridge/netfilter/ebtables.c",
85621 + .param4 = 1,
85622 +};
85623 +
85624 +struct size_overflow_hash _000650_hash = {
85625 + .next = NULL,
85626 + .name = "driver_state_read",
85627 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
85628 + .param3 = 1,
85629 +};
85630 +
85631 +struct size_overflow_hash _000651_hash = {
85632 + .next = NULL,
85633 + .name = "dsp_write",
85634 + .file = "sound/oss/msnd_pinnacle.c",
85635 + .param2 = 1,
85636 +};
85637 +
85638 +struct size_overflow_hash _000652_hash = {
85639 + .next = NULL,
85640 + .name = "dvb_aplay",
85641 + .file = "drivers/media/dvb/ttpci/av7110_av.c",
85642 + .param3 = 1,
85643 +};
85644 +
85645 +struct size_overflow_hash _000653_hash = {
85646 + .next = NULL,
85647 + .name = "dvb_ca_en50221_io_write",
85648 + .file = "drivers/media/dvb/dvb-core/dvb_ca_en50221.c",
85649 + .param3 = 1,
85650 +};
85651 +
85652 +struct size_overflow_hash _000654_hash = {
85653 + .next = NULL,
85654 + .name = "dvb_dmxdev_set_buffer_size",
85655 + .file = "drivers/media/dvb/dvb-core/dmxdev.c",
85656 + .param2 = 1,
85657 +};
85658 +
85659 +struct size_overflow_hash _000655_hash = {
85660 + .next = NULL,
85661 + .name = "dvbdmx_write",
85662 + .file = "drivers/media/dvb/dvb-core/dvb_demux.c",
85663 + .param3 = 1,
85664 +};
85665 +
85666 +struct size_overflow_hash _000656_hash = {
85667 + .next = NULL,
85668 + .name = "dvb_dvr_set_buffer_size",
85669 + .file = "drivers/media/dvb/dvb-core/dmxdev.c",
85670 + .param2 = 1,
85671 +};
85672 +
85673 +struct size_overflow_hash _000657_hash = {
85674 + .next = NULL,
85675 + .name = "dvb_play",
85676 + .file = "drivers/media/dvb/ttpci/av7110_av.c",
85677 + .param3 = 1,
85678 +};
85679 +
85680 +struct size_overflow_hash _000658_hash = {
85681 + .next = NULL,
85682 + .name = "dvb_ringbuffer_pkt_read_user",
85683 + .file = "drivers/media/dvb/dvb-core/dvb_ringbuffer.c",
85684 + .param5 = 1,
85685 +};
85686 +
85687 +struct size_overflow_hash _000659_hash = {
85688 + .next = NULL,
85689 + .name = "dvb_ringbuffer_read_user",
85690 + .file = "drivers/media/dvb/dvb-core/dvb_ringbuffer.c",
85691 + .param3 = 1,
85692 +};
85693 +
85694 +struct size_overflow_hash _000660_hash = {
85695 + .next = NULL,
85696 + .name = "dw210x_op_rw",
85697 + .file = "drivers/media/dvb/dvb-usb/dw2102.c",
85698 + .param6 = 1,
85699 +};
85700 +
85701 +struct size_overflow_hash _000661_hash = {
85702 + .next = NULL,
85703 + .name = "dwc3_mode_write",
85704 + .file = "drivers/usb/dwc3/debugfs.c",
85705 + .param3 = 1,
85706 +};
85707 +
85708 +struct size_overflow_hash _000662_hash = {
85709 + .next = NULL,
85710 + .name = "econet_sendmsg",
85711 + .file = "net/econet/af_econet.c",
85712 + .param4 = 1,
85713 +};
85714 +
85715 +struct size_overflow_hash _000663_hash = {
85716 + .next = NULL,
85717 + .name = "ecryptfs_copy_filename",
85718 + .file = "fs/ecryptfs/crypto.c",
85719 + .param4 = 1,
85720 +};
85721 +
85722 +struct size_overflow_hash _000664_hash = {
85723 + .next = NULL,
85724 + .name = "ecryptfs_miscdev_write",
85725 + .file = "fs/ecryptfs/miscdev.c",
85726 + .param3 = 1,
85727 +};
85728 +
85729 +struct size_overflow_hash _000665_hash = {
85730 + .next = NULL,
85731 + .name = "ecryptfs_send_miscdev",
85732 + .file = "fs/ecryptfs/miscdev.c",
85733 + .param2 = 1,
85734 +};
85735 +
85736 +struct size_overflow_hash _000666_hash = {
85737 + .next = NULL,
85738 + .name = "edac_device_alloc_ctl_info",
85739 + .file = "drivers/edac/edac_device.c",
85740 + .param1 = 1,
85741 +};
85742 +
85743 +struct size_overflow_hash _000667_hash = {
85744 + .next = NULL,
85745 + .name = "edac_mc_alloc",
85746 + .file = "drivers/edac/edac_mc.c",
85747 + .param1 = 1,
85748 +};
85749 +
85750 +struct size_overflow_hash _000668_hash = {
85751 + .next = NULL,
85752 + .name = "edac_pci_alloc_ctl_info",
85753 + .file = "drivers/edac/edac_pci.c",
85754 + .param1 = 1,
85755 +};
85756 +
85757 +struct size_overflow_hash _000669_hash = {
85758 + .next = NULL,
85759 + .name = "efivar_create_sysfs_entry",
85760 + .file = "drivers/firmware/efivars.c",
85761 + .param2 = 1,
85762 +};
85763 +
85764 +struct size_overflow_hash _000670_hash = {
85765 + .next = NULL,
85766 + .name = "efx_tsoh_heap_alloc",
85767 + .file = "drivers/net/ethernet/sfc/tx.c",
85768 + .param2 = 1,
85769 +};
85770 +
85771 +struct size_overflow_hash _000671_hash = {
85772 + .next = NULL,
85773 + .name = "encrypted_instantiate",
85774 + .file = "security/keys/encrypted-keys/encrypted.c",
85775 + .param3 = 1,
85776 +};
85777 +
85778 +struct size_overflow_hash _000672_hash = {
85779 + .next = NULL,
85780 + .name = "encrypted_update",
85781 + .file = "security/keys/encrypted-keys/encrypted.c",
85782 + .param3 = 1,
85783 +};
85784 +
85785 +struct size_overflow_hash _000673_hash = {
85786 + .next = NULL,
85787 + .name = "ep0_write",
85788 + .file = "drivers/usb/gadget/inode.c",
85789 + .param3 = 1,
85790 +};
85791 +
85792 +struct size_overflow_hash _000674_hash = {
85793 + .next = NULL,
85794 + .name = "ep_read",
85795 + .file = "drivers/usb/gadget/inode.c",
85796 + .param3 = 1,
85797 +};
85798 +
85799 +struct size_overflow_hash _000675_hash = {
85800 + .next = NULL,
85801 + .name = "ep_write",
85802 + .file = "drivers/usb/gadget/inode.c",
85803 + .param3 = 1,
85804 +};
85805 +
85806 +struct size_overflow_hash _000676_hash = {
85807 + .next = NULL,
85808 + .name = "erst_dbg_write",
85809 + .file = "drivers/acpi/apei/erst-dbg.c",
85810 + .param3 = 1,
85811 +};
85812 +
85813 +struct size_overflow_hash _000677_hash = {
85814 + .next = NULL,
85815 + .name = "et61x251_read",
85816 + .file = "drivers/media/video/et61x251/et61x251_core.c",
85817 + .param3 = 1,
85818 +};
85819 +
85820 +struct size_overflow_hash _000678_hash = {
85821 + .next = NULL,
85822 + .name = "event_calibration_read",
85823 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85824 + .param3 = 1,
85825 +};
85826 +
85827 +struct size_overflow_hash _000679_hash = {
85828 + .next = NULL,
85829 + .name = "event_heart_beat_read",
85830 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85831 + .param3 = 1,
85832 +};
85833 +
85834 +struct size_overflow_hash _000680_hash = {
85835 + .next = NULL,
85836 + .name = "event_oom_late_read",
85837 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85838 + .param3 = 1,
85839 +};
85840 +
85841 +struct size_overflow_hash _000681_hash = {
85842 + .next = NULL,
85843 + .name = "event_phy_transmit_error_read",
85844 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85845 + .param3 = 1,
85846 +};
85847 +
85848 +struct size_overflow_hash _000682_hash = {
85849 + .next = NULL,
85850 + .name = "event_rx_mem_empty_read",
85851 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85852 + .param3 = 1,
85853 +};
85854 +
85855 +struct size_overflow_hash _000683_hash = {
85856 + .next = NULL,
85857 + .name = "event_rx_mismatch_read",
85858 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85859 + .param3 = 1,
85860 +};
85861 +
85862 +struct size_overflow_hash _000684_hash = {
85863 + .next = NULL,
85864 + .name = "event_rx_pool_read",
85865 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85866 + .param3 = 1,
85867 +};
85868 +
85869 +struct size_overflow_hash _000685_hash = {
85870 + .next = NULL,
85871 + .name = "event_tx_stuck_read",
85872 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85873 + .param3 = 1,
85874 +};
85875 +
85876 +struct size_overflow_hash _000686_hash = {
85877 + .next = NULL,
85878 + .name = "excessive_retries_read",
85879 + .file = "drivers/net/wireless/wl1251/debugfs.c",
85880 + .param3 = 1,
85881 +};
85882 +
85883 +struct size_overflow_hash _000687_hash = {
85884 + .next = NULL,
85885 + .name = "exofs_read_lookup_dev_table",
85886 + .file = "fs/exofs/super.c",
85887 + .param3 = 1,
85888 +};
85889 +
85890 +struct size_overflow_hash _000688_hash = {
85891 + .next = NULL,
85892 + .name = "ext4_kvmalloc",
85893 + .file = "fs/ext4/super.c",
85894 + .param1 = 1,
85895 +};
85896 +
85897 +struct size_overflow_hash _000689_hash = {
85898 + .next = NULL,
85899 + .name = "ext4_kvzalloc",
85900 + .file = "fs/ext4/super.c",
85901 + .param1 = 1,
85902 +};
85903 +
85904 +struct size_overflow_hash _000690_hash = {
85905 + .next = NULL,
85906 + .name = "extend_netdev_table",
85907 + .file = "net/core/netprio_cgroup.c",
85908 + .param2 = 1,
85909 +};
85910 +
85911 +struct size_overflow_hash _000691_hash = {
85912 + .next = NULL,
85913 + .name = "fd_copyin",
85914 + .file = "drivers/block/floppy.c",
85915 + .param3 = 1,
85916 +};
85917 +
85918 +struct size_overflow_hash _000692_hash = {
85919 + .next = NULL,
85920 + .name = "fd_copyout",
85921 + .file = "drivers/block/floppy.c",
85922 + .param3 = 1,
85923 +};
85924 +
85925 +struct size_overflow_hash _000693_hash = {
85926 + .next = NULL,
85927 + .name = "__ffs_ep0_read_events",
85928 + .file = "drivers/usb/gadget/f_fs.c",
85929 + .param3 = 1,
85930 +};
85931 +
85932 +struct size_overflow_hash _000694_hash = {
85933 + .next = NULL,
85934 + .name = "ffs_epfile_io",
85935 + .file = "drivers/usb/gadget/f_fs.c",
85936 + .param3 = 1,
85937 +};
85938 +
85939 +struct size_overflow_hash _000695_hash = {
85940 + .next = NULL,
85941 + .name = "ffs_prepare_buffer",
85942 + .file = "drivers/usb/gadget/f_fs.c",
85943 + .param2 = 1,
85944 +};
85945 +
85946 +struct size_overflow_hash _000696_hash = {
85947 + .next = NULL,
85948 + .name = "f_hidg_read",
85949 + .file = "drivers/usb/gadget/f_hid.c",
85950 + .param3 = 1,
85951 +};
85952 +
85953 +struct size_overflow_hash _000697_hash = {
85954 + .next = NULL,
85955 + .name = "f_hidg_write",
85956 + .file = "drivers/usb/gadget/f_hid.c",
85957 + .param3 = 1,
85958 +};
85959 +
85960 +struct size_overflow_hash _000698_hash = {
85961 + .next = NULL,
85962 + .name = "fill_write_buffer",
85963 + .file = "fs/configfs/file.c",
85964 + .param3 = 1,
85965 +};
85966 +
85967 +struct size_overflow_hash _000699_hash = {
85968 + .next = NULL,
85969 + .name = "flexcop_device_kmalloc",
85970 + .file = "drivers/media/dvb/b2c2/flexcop.c",
85971 + .param1 = 1,
85972 +};
85973 +
85974 +struct size_overflow_hash _000700_hash = {
85975 + .next = NULL,
85976 + .name = "fops_read",
85977 + .file = "drivers/media/video/saa7164/saa7164-encoder.c",
85978 + .param3 = 1,
85979 +};
85980 +
85981 +struct size_overflow_hash _000701_hash = {
85982 + .next = NULL,
85983 + .name = "fops_read",
85984 + .file = "drivers/media/video/saa7164/saa7164-vbi.c",
85985 + .param3 = 1,
85986 +};
85987 +
85988 +struct size_overflow_hash _000702_hash = {
85989 + .next = NULL,
85990 + .name = "format_devstat_counter",
85991 + .file = "net/mac80211/debugfs.c",
85992 + .param3 = 1,
85993 +};
85994 +
85995 +struct size_overflow_hash _000703_hash = {
85996 + .next = NULL,
85997 + .name = "fragmentation_threshold_read",
85998 + .file = "net/wireless/debugfs.c",
85999 + .param3 = 1,
86000 +};
86001 +
86002 +struct size_overflow_hash _000704_hash = {
86003 + .next = NULL,
86004 + .name = "frame_alloc",
86005 + .file = "drivers/media/video/gspca/gspca.c",
86006 + .param4 = 1,
86007 +};
86008 +
86009 +struct size_overflow_hash _000705_hash = {
86010 + .next = NULL,
86011 + .name = "ftdi_elan_write",
86012 + .file = "drivers/usb/misc/ftdi-elan.c",
86013 + .param3 = 1,
86014 +};
86015 +
86016 +struct size_overflow_hash _000706_hash = {
86017 + .next = NULL,
86018 + .name = "fuse_conn_limit_read",
86019 + .file = "fs/fuse/control.c",
86020 + .param3 = 1,
86021 +};
86022 +
86023 +struct size_overflow_hash _000707_hash = {
86024 + .next = NULL,
86025 + .name = "fuse_conn_limit_write",
86026 + .file = "fs/fuse/control.c",
86027 + .param3 = 1,
86028 +};
86029 +
86030 +struct size_overflow_hash _000708_hash = {
86031 + .next = &_000531_hash,
86032 + .name = "fuse_conn_waiting_read",
86033 + .file = "fs/fuse/control.c",
86034 + .param3 = 1,
86035 +};
86036 +
86037 +struct size_overflow_hash _000709_hash = {
86038 + .next = NULL,
86039 + .name = "garp_attr_create",
86040 + .file = "net/802/garp.c",
86041 + .param3 = 1,
86042 +};
86043 +
86044 +struct size_overflow_hash _000710_hash = {
86045 + .next = NULL,
86046 + .name = "get_alua_req",
86047 + .file = "drivers/scsi/device_handler/scsi_dh_alua.c",
86048 + .param3 = 1,
86049 +};
86050 +
86051 +struct size_overflow_hash _000711_hash = {
86052 + .next = NULL,
86053 + .name = "get_derived_key",
86054 + .file = "security/keys/encrypted-keys/encrypted.c",
86055 + .param4 = 1,
86056 +};
86057 +
86058 +struct size_overflow_hash _000712_hash = {
86059 + .next = NULL,
86060 + .name = "getdqbuf",
86061 + .file = "fs/quota/quota_tree.c",
86062 + .param1 = 1,
86063 +};
86064 +
86065 +struct size_overflow_hash _000713_hash = {
86066 + .next = NULL,
86067 + .name = "get_fdb_entries",
86068 + .file = "net/bridge/br_ioctl.c",
86069 + .param3 = 1,
86070 +};
86071 +
86072 +struct size_overflow_hash _000714_hash = {
86073 + .next = NULL,
86074 + .name = "get_rdac_req",
86075 + .file = "drivers/scsi/device_handler/scsi_dh_rdac.c",
86076 + .param3 = 1,
86077 +};
86078 +
86079 +struct size_overflow_hash _000715_hash = {
86080 + .next = NULL,
86081 + .name = "get_registers",
86082 + .file = "drivers/net/usb/pegasus.c",
86083 + .param3 = 1,
86084 +};
86085 +
86086 +struct size_overflow_hash _000716_hash = {
86087 + .next = NULL,
86088 + .name = "get_server_iovec",
86089 + .file = "fs/cifs/connect.c",
86090 + .param2 = 1,
86091 +};
86092 +
86093 +struct size_overflow_hash _000717_hash = {
86094 + .next = NULL,
86095 + .name = "get_ucode_user",
86096 + .file = "arch/x86/kernel/microcode_intel.c",
86097 + .param3 = 1,
86098 +};
86099 +
86100 +struct size_overflow_hash _000718_hash = {
86101 + .next = NULL,
86102 + .name = "gfs2_alloc_sort_buffer",
86103 + .file = "fs/gfs2/dir.c",
86104 + .param1 = 1,
86105 +};
86106 +
86107 +struct size_overflow_hash _000719_hash = {
86108 + .next = NULL,
86109 + .name = "gfs2_glock_nq_m",
86110 + .file = "fs/gfs2/glock.c",
86111 + .param1 = 1,
86112 +};
86113 +
86114 +struct size_overflow_hash _000720_hash = {
86115 + .next = NULL,
86116 + .name = "gigaset_initdriver",
86117 + .file = "drivers/isdn/gigaset/common.c",
86118 + .param2 = 1,
86119 +};
86120 +
86121 +struct size_overflow_hash _000721_hash = {
86122 + .next = NULL,
86123 + .name = "gpio_power_read",
86124 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
86125 + .param3 = 1,
86126 +};
86127 +
86128 +struct size_overflow_hash _000722_hash = {
86129 + .next = NULL,
86130 + .name = "gs_alloc_req",
86131 + .file = "drivers/usb/gadget/u_serial.c",
86132 + .param2 = 1,
86133 +};
86134 +
86135 +struct size_overflow_hash _000723_hash = {
86136 + .next = NULL,
86137 + .name = "gs_buf_alloc",
86138 + .file = "drivers/usb/gadget/u_serial.c",
86139 + .param2 = 1,
86140 +};
86141 +
86142 +struct size_overflow_hash _000724_hash = {
86143 + .next = NULL,
86144 + .name = "gss_pipe_downcall",
86145 + .file = "net/sunrpc/auth_gss/auth_gss.c",
86146 + .param3 = 1,
86147 +};
86148 +
86149 +struct size_overflow_hash _000725_hash = {
86150 + .next = NULL,
86151 + .name = "handle_request",
86152 + .file = "drivers/firewire/core-cdev.c",
86153 + .param9 = 1,
86154 +};
86155 +
86156 +struct size_overflow_hash _000726_hash = {
86157 + .next = NULL,
86158 + .name = "hash_new",
86159 + .file = "net/batman-adv/hash.c",
86160 + .param1 = 1,
86161 +};
86162 +
86163 +struct size_overflow_hash _000727_hash = {
86164 + .next = NULL,
86165 + .name = "hash_setkey",
86166 + .file = "crypto/algif_hash.c",
86167 + .param3 = 1,
86168 +};
86169 +
86170 +struct size_overflow_hash _000728_hash = {
86171 + .next = NULL,
86172 + .name = "hcd_buffer_alloc",
86173 + .file = "include/linux/usb/hcd.h",
86174 + .param2 = 1,
86175 +};
86176 +
86177 +struct size_overflow_hash _000729_hash = {
86178 + .next = NULL,
86179 + .name = "hci_sock_setsockopt",
86180 + .file = "net/bluetooth/hci_sock.c",
86181 + .param5 = 1,
86182 +};
86183 +
86184 +struct size_overflow_hash _000730_hash = {
86185 + .next = NULL,
86186 + .name = "hdpvr_read",
86187 + .file = "drivers/media/video/hdpvr/hdpvr-video.c",
86188 + .param3 = 1,
86189 +};
86190 +
86191 +struct size_overflow_hash _000731_hash = {
86192 + .next = NULL,
86193 + .name = "hidraw_get_report",
86194 + .file = "drivers/hid/hidraw.c",
86195 + .param3 = 1,
86196 +};
86197 +
86198 +struct size_overflow_hash _000732_hash = {
86199 + .next = NULL,
86200 + .name = "hidraw_read",
86201 + .file = "drivers/hid/hidraw.c",
86202 + .param3 = 1,
86203 +};
86204 +
86205 +struct size_overflow_hash _000733_hash = {
86206 + .next = NULL,
86207 + .name = "hidraw_send_report",
86208 + .file = "drivers/hid/hidraw.c",
86209 + .param3 = 1,
86210 +};
86211 +
86212 +struct size_overflow_hash _000734_hash = {
86213 + .next = NULL,
86214 + .name = "hid_register_field",
86215 + .file = "drivers/hid/hid-core.c",
86216 + .param2 = 1,
86217 + .param3 = 1,
86218 +};
86219 +
86220 +struct size_overflow_hash _000736_hash = {
86221 + .next = NULL,
86222 + .name = "hpfs_translate_name",
86223 + .file = "fs/hpfs/name.c",
86224 + .param3 = 1,
86225 +};
86226 +
86227 +struct size_overflow_hash _000737_hash = {
86228 + .next = NULL,
86229 + .name = "hpi_alloc_control_cache",
86230 + .file = "sound/pci/asihpi/hpicmn.c",
86231 + .param1 = 1,
86232 +};
86233 +
86234 +struct size_overflow_hash _000738_hash = {
86235 + .next = NULL,
86236 + .name = "ht40allow_map_read",
86237 + .file = "net/wireless/debugfs.c",
86238 + .param3 = 1,
86239 +};
86240 +
86241 +struct size_overflow_hash _000739_hash = {
86242 + .next = NULL,
86243 + .name = "__hwahc_dev_set_key",
86244 + .file = "drivers/usb/host/hwa-hc.c",
86245 + .param5 = 1,
86246 +};
86247 +
86248 +struct size_overflow_hash _000740_hash = {
86249 + .next = NULL,
86250 + .name = "hwflags_read",
86251 + .file = "net/mac80211/debugfs.c",
86252 + .param3 = 1,
86253 +};
86254 +
86255 +struct size_overflow_hash _000741_hash = {
86256 + .next = NULL,
86257 + .name = "hysdn_conf_read",
86258 + .file = "drivers/isdn/hysdn/hysdn_procconf.c",
86259 + .param3 = 1,
86260 +};
86261 +
86262 +struct size_overflow_hash _000742_hash = {
86263 + .next = NULL,
86264 + .name = "hysdn_conf_write",
86265 + .file = "drivers/isdn/hysdn/hysdn_procconf.c",
86266 + .param3 = 1,
86267 +};
86268 +
86269 +struct size_overflow_hash _000743_hash = {
86270 + .next = NULL,
86271 + .name = "hysdn_log_write",
86272 + .file = "drivers/isdn/hysdn/hysdn_proclog.c",
86273 + .param3 = 1,
86274 +};
86275 +
86276 +struct size_overflow_hash _000744_hash = {
86277 + .next = NULL,
86278 + .name = "i2400m_rx_stats_read",
86279 + .file = "drivers/net/wimax/i2400m/debugfs.c",
86280 + .param3 = 1,
86281 +};
86282 +
86283 +struct size_overflow_hash _000745_hash = {
86284 + .next = NULL,
86285 + .name = "i2400m_tx_stats_read",
86286 + .file = "drivers/net/wimax/i2400m/debugfs.c",
86287 + .param3 = 1,
86288 +};
86289 +
86290 +struct size_overflow_hash _000746_hash = {
86291 + .next = NULL,
86292 + .name = "__i2400mu_send_barker",
86293 + .file = "drivers/net/wimax/i2400m/usb.c",
86294 + .param3 = 1,
86295 +};
86296 +
86297 +struct size_overflow_hash _000747_hash = {
86298 + .next = NULL,
86299 + .name = "i2400m_zrealloc_2x",
86300 + .file = "drivers/net/wimax/i2400m/fw.c",
86301 + .param3 = 1,
86302 +};
86303 +
86304 +struct size_overflow_hash _000748_hash = {
86305 + .next = NULL,
86306 + .name = "i2cdev_read",
86307 + .file = "drivers/i2c/i2c-dev.c",
86308 + .param3 = 1,
86309 +};
86310 +
86311 +struct size_overflow_hash _000749_hash = {
86312 + .next = &_000459_hash,
86313 + .name = "i2cdev_write",
86314 + .file = "drivers/i2c/i2c-dev.c",
86315 + .param3 = 1,
86316 +};
86317 +
86318 +struct size_overflow_hash _000750_hash = {
86319 + .next = NULL,
86320 + .name = "ib_alloc_device",
86321 + .file = "include/rdma/ib_verbs.h",
86322 + .param1 = 1,
86323 +};
86324 +
86325 +struct size_overflow_hash _000751_hash = {
86326 + .next = NULL,
86327 + .name = "ib_copy_from_udata",
86328 + .file = "include/rdma/ib_verbs.h",
86329 + .param3 = 1,
86330 +};
86331 +
86332 +struct size_overflow_hash _000752_hash = {
86333 + .next = NULL,
86334 + .name = "ib_copy_to_udata",
86335 + .file = "include/rdma/ib_verbs.h",
86336 + .param3 = 1,
86337 +};
86338 +
86339 +struct size_overflow_hash _000753_hash = {
86340 + .next = NULL,
86341 + .name = "ibmasm_new_command",
86342 + .file = "drivers/misc/ibmasm/command.c",
86343 + .param2 = 1,
86344 +};
86345 +
86346 +struct size_overflow_hash _000754_hash = {
86347 + .next = NULL,
86348 + .name = "ib_ucm_alloc_data",
86349 + .file = "drivers/infiniband/core/ucm.c",
86350 + .param3 = 1,
86351 +};
86352 +
86353 +struct size_overflow_hash _000755_hash = {
86354 + .next = NULL,
86355 + .name = "ib_umad_write",
86356 + .file = "drivers/infiniband/core/user_mad.c",
86357 + .param3 = 1,
86358 +};
86359 +
86360 +struct size_overflow_hash _000756_hash = {
86361 + .next = NULL,
86362 + .name = "ib_uverbs_unmarshall_recv",
86363 + .file = "drivers/infiniband/core/uverbs_cmd.c",
86364 + .param5 = 1,
86365 +};
86366 +
86367 +struct size_overflow_hash _000757_hash = {
86368 + .next = NULL,
86369 + .name = "ide_driver_proc_write",
86370 + .file = "drivers/ide/ide-proc.c",
86371 + .param3 = 1,
86372 +};
86373 +
86374 +struct size_overflow_hash _000758_hash = {
86375 + .next = NULL,
86376 + .name = "ide_queue_pc_tail",
86377 + .file = "include/linux/ide.h",
86378 + .param5 = 1,
86379 +};
86380 +
86381 +struct size_overflow_hash _000759_hash = {
86382 + .next = NULL,
86383 + .name = "ide_raw_taskfile",
86384 + .file = "include/linux/ide.h",
86385 + .param4 = 1,
86386 +};
86387 +
86388 +struct size_overflow_hash _000760_hash = {
86389 + .next = NULL,
86390 + .name = "ide_settings_proc_write",
86391 + .file = "drivers/ide/ide-proc.c",
86392 + .param3 = 1,
86393 +};
86394 +
86395 +struct size_overflow_hash _000761_hash = {
86396 + .next = NULL,
86397 + .name = "idetape_chrdev_read",
86398 + .file = "drivers/ide/ide-tape.c",
86399 + .param3 = 1,
86400 +};
86401 +
86402 +struct size_overflow_hash _000762_hash = {
86403 + .next = NULL,
86404 + .name = "idetape_chrdev_write",
86405 + .file = "drivers/ide/ide-tape.c",
86406 + .param3 = 1,
86407 +};
86408 +
86409 +struct size_overflow_hash _000763_hash = {
86410 + .next = NULL,
86411 + .name = "idmouse_read",
86412 + .file = "drivers/usb/misc/idmouse.c",
86413 + .param3 = 1,
86414 +};
86415 +
86416 +struct size_overflow_hash _000764_hash = {
86417 + .next = NULL,
86418 + .name = "ieee80211_build_probe_req",
86419 + .file = "net/mac80211/util.c",
86420 + .param7 = 1,
86421 +};
86422 +
86423 +struct size_overflow_hash _000765_hash = {
86424 + .next = NULL,
86425 + .name = "ieee80211_if_read",
86426 + .file = "net/mac80211/debugfs_netdev.c",
86427 + .param3 = 1,
86428 +};
86429 +
86430 +struct size_overflow_hash _000766_hash = {
86431 + .next = NULL,
86432 + .name = "ieee80211_if_write",
86433 + .file = "net/mac80211/debugfs_netdev.c",
86434 + .param3 = 1,
86435 +};
86436 +
86437 +struct size_overflow_hash _000767_hash = {
86438 + .next = NULL,
86439 + .name = "ieee80211_key_alloc",
86440 + .file = "net/mac80211/key.c",
86441 + .param3 = 1,
86442 +};
86443 +
86444 +struct size_overflow_hash _000768_hash = {
86445 + .next = NULL,
86446 + .name = "ieee80211_mgmt_tx",
86447 + .file = "net/mac80211/cfg.c",
86448 + .param9 = 1,
86449 +};
86450 +
86451 +struct size_overflow_hash _000769_hash = {
86452 + .next = NULL,
86453 + .name = "ikconfig_read_current",
86454 + .file = "kernel/configs.c",
86455 + .param3 = 1,
86456 +};
86457 +
86458 +struct size_overflow_hash _000770_hash = {
86459 + .next = NULL,
86460 + .name = "il3945_sta_dbgfs_stats_table_read",
86461 + .file = "drivers/net/wireless/iwlegacy/3945-rs.c",
86462 + .param3 = 1,
86463 +};
86464 +
86465 +struct size_overflow_hash _000771_hash = {
86466 + .next = NULL,
86467 + .name = "il3945_ucode_general_stats_read",
86468 + .file = "drivers/net/wireless/iwlegacy/3945-debug.c",
86469 + .param3 = 1,
86470 +};
86471 +
86472 +struct size_overflow_hash _000772_hash = {
86473 + .next = NULL,
86474 + .name = "il3945_ucode_rx_stats_read",
86475 + .file = "drivers/net/wireless/iwlegacy/3945-debug.c",
86476 + .param3 = 1,
86477 +};
86478 +
86479 +struct size_overflow_hash _000773_hash = {
86480 + .next = NULL,
86481 + .name = "il3945_ucode_tx_stats_read",
86482 + .file = "drivers/net/wireless/iwlegacy/3945-debug.c",
86483 + .param3 = 1,
86484 +};
86485 +
86486 +struct size_overflow_hash _000774_hash = {
86487 + .next = NULL,
86488 + .name = "il4965_rs_sta_dbgfs_rate_scale_data_read",
86489 + .file = "drivers/net/wireless/iwlegacy/4965-rs.c",
86490 + .param3 = 1,
86491 +};
86492 +
86493 +struct size_overflow_hash _000775_hash = {
86494 + .next = NULL,
86495 + .name = "il4965_rs_sta_dbgfs_scale_table_read",
86496 + .file = "drivers/net/wireless/iwlegacy/4965-rs.c",
86497 + .param3 = 1,
86498 +};
86499 +
86500 +struct size_overflow_hash _000776_hash = {
86501 + .next = NULL,
86502 + .name = "il4965_rs_sta_dbgfs_stats_table_read",
86503 + .file = "drivers/net/wireless/iwlegacy/4965-rs.c",
86504 + .param3 = 1,
86505 +};
86506 +
86507 +struct size_overflow_hash _000777_hash = {
86508 + .next = NULL,
86509 + .name = "il4965_ucode_general_stats_read",
86510 + .file = "drivers/net/wireless/iwlegacy/4965-debug.c",
86511 + .param3 = 1,
86512 +};
86513 +
86514 +struct size_overflow_hash _000778_hash = {
86515 + .next = NULL,
86516 + .name = "il4965_ucode_rx_stats_read",
86517 + .file = "drivers/net/wireless/iwlegacy/4965-debug.c",
86518 + .param3 = 1,
86519 +};
86520 +
86521 +struct size_overflow_hash _000779_hash = {
86522 + .next = NULL,
86523 + .name = "il4965_ucode_tx_stats_read",
86524 + .file = "drivers/net/wireless/iwlegacy/4965-debug.c",
86525 + .param3 = 1,
86526 +};
86527 +
86528 +struct size_overflow_hash _000780_hash = {
86529 + .next = NULL,
86530 + .name = "il_dbgfs_chain_noise_read",
86531 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86532 + .param3 = 1,
86533 +};
86534 +
86535 +struct size_overflow_hash _000781_hash = {
86536 + .next = NULL,
86537 + .name = "il_dbgfs_channels_read",
86538 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86539 + .param3 = 1,
86540 +};
86541 +
86542 +struct size_overflow_hash _000782_hash = {
86543 + .next = NULL,
86544 + .name = "il_dbgfs_disable_ht40_read",
86545 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86546 + .param3 = 1,
86547 +};
86548 +
86549 +struct size_overflow_hash _000783_hash = {
86550 + .next = NULL,
86551 + .name = "il_dbgfs_fh_reg_read",
86552 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86553 + .param3 = 1,
86554 +};
86555 +
86556 +struct size_overflow_hash _000784_hash = {
86557 + .next = NULL,
86558 + .name = "il_dbgfs_force_reset_read",
86559 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86560 + .param3 = 1,
86561 +};
86562 +
86563 +struct size_overflow_hash _000785_hash = {
86564 + .next = NULL,
86565 + .name = "il_dbgfs_interrupt_read",
86566 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86567 + .param3 = 1,
86568 +};
86569 +
86570 +struct size_overflow_hash _000786_hash = {
86571 + .next = NULL,
86572 + .name = "il_dbgfs_missed_beacon_read",
86573 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86574 + .param3 = 1,
86575 +};
86576 +
86577 +struct size_overflow_hash _000787_hash = {
86578 + .next = NULL,
86579 + .name = "il_dbgfs_nvm_read",
86580 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86581 + .param3 = 1,
86582 +};
86583 +
86584 +struct size_overflow_hash _000788_hash = {
86585 + .next = NULL,
86586 + .name = "il_dbgfs_power_save_status_read",
86587 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86588 + .param3 = 1,
86589 +};
86590 +
86591 +struct size_overflow_hash _000789_hash = {
86592 + .next = NULL,
86593 + .name = "il_dbgfs_qos_read",
86594 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86595 + .param3 = 1,
86596 +};
86597 +
86598 +struct size_overflow_hash _000790_hash = {
86599 + .next = &_000221_hash,
86600 + .name = "il_dbgfs_rxon_filter_flags_read",
86601 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86602 + .param3 = 1,
86603 +};
86604 +
86605 +struct size_overflow_hash _000791_hash = {
86606 + .next = NULL,
86607 + .name = "il_dbgfs_rxon_flags_read",
86608 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86609 + .param3 = 1,
86610 +};
86611 +
86612 +struct size_overflow_hash _000792_hash = {
86613 + .next = NULL,
86614 + .name = "il_dbgfs_rx_queue_read",
86615 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86616 + .param3 = 1,
86617 +};
86618 +
86619 +struct size_overflow_hash _000793_hash = {
86620 + .next = NULL,
86621 + .name = "il_dbgfs_rx_stats_read",
86622 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86623 + .param3 = 1,
86624 +};
86625 +
86626 +struct size_overflow_hash _000794_hash = {
86627 + .next = NULL,
86628 + .name = "il_dbgfs_sensitivity_read",
86629 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86630 + .param3 = 1,
86631 +};
86632 +
86633 +struct size_overflow_hash _000795_hash = {
86634 + .next = NULL,
86635 + .name = "il_dbgfs_sram_read",
86636 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86637 + .param3 = 1,
86638 +};
86639 +
86640 +struct size_overflow_hash _000796_hash = {
86641 + .next = NULL,
86642 + .name = "il_dbgfs_stations_read",
86643 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86644 + .param3 = 1,
86645 +};
86646 +
86647 +struct size_overflow_hash _000797_hash = {
86648 + .next = NULL,
86649 + .name = "il_dbgfs_status_read",
86650 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86651 + .param3 = 1,
86652 +};
86653 +
86654 +struct size_overflow_hash _000798_hash = {
86655 + .next = NULL,
86656 + .name = "il_dbgfs_traffic_log_read",
86657 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86658 + .param3 = 1,
86659 +};
86660 +
86661 +struct size_overflow_hash _000799_hash = {
86662 + .next = NULL,
86663 + .name = "il_dbgfs_tx_queue_read",
86664 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86665 + .param3 = 1,
86666 +};
86667 +
86668 +struct size_overflow_hash _000800_hash = {
86669 + .next = NULL,
86670 + .name = "il_dbgfs_tx_stats_read",
86671 + .file = "drivers/net/wireless/iwlegacy/debug.c",
86672 + .param3 = 1,
86673 +};
86674 +
86675 +struct size_overflow_hash _000801_hash = {
86676 + .next = NULL,
86677 + .name = "ilo_read",
86678 + .file = "drivers/misc/hpilo.c",
86679 + .param3 = 1,
86680 +};
86681 +
86682 +struct size_overflow_hash _000802_hash = {
86683 + .next = NULL,
86684 + .name = "ilo_write",
86685 + .file = "drivers/misc/hpilo.c",
86686 + .param3 = 1,
86687 +};
86688 +
86689 +struct size_overflow_hash _000803_hash = {
86690 + .next = NULL,
86691 + .name = "init_data_container",
86692 + .file = "fs/btrfs/backref.c",
86693 + .param1 = 1,
86694 +};
86695 +
86696 +struct size_overflow_hash _000804_hash = {
86697 + .next = NULL,
86698 + .name = "init_list_set",
86699 + .file = "net/netfilter/ipset/ip_set_list_set.c",
86700 + .param2 = 1,
86701 + .param3 = 1,
86702 +};
86703 +
86704 +struct size_overflow_hash _000806_hash = {
86705 + .next = NULL,
86706 + .name = "interpret_user_input",
86707 + .file = "fs/ubifs/debug.c",
86708 + .param2 = 1,
86709 +};
86710 +
86711 +struct size_overflow_hash _000807_hash = {
86712 + .next = NULL,
86713 + .name = "int_proc_write",
86714 + .file = "drivers/net/wireless/ray_cs.c",
86715 + .param3 = 1,
86716 +};
86717 +
86718 +struct size_overflow_hash _000808_hash = {
86719 + .next = NULL,
86720 + .name = "iowarrior_read",
86721 + .file = "drivers/usb/misc/iowarrior.c",
86722 + .param3 = 1,
86723 +};
86724 +
86725 +struct size_overflow_hash _000809_hash = {
86726 + .next = NULL,
86727 + .name = "iowarrior_write",
86728 + .file = "drivers/usb/misc/iowarrior.c",
86729 + .param3 = 1,
86730 +};
86731 +
86732 +struct size_overflow_hash _000810_hash = {
86733 + .next = NULL,
86734 + .name = "ip_set_alloc",
86735 + .file = "include/linux/netfilter/ipset/ip_set.h",
86736 + .param1 = 1,
86737 +};
86738 +
86739 +struct size_overflow_hash _000811_hash = {
86740 + .next = NULL,
86741 + .name = "ip_vs_conn_fill_param_sync",
86742 + .file = "net/netfilter/ipvs/ip_vs_sync.c",
86743 + .param6 = 1,
86744 +};
86745 +
86746 +struct size_overflow_hash _000812_hash = {
86747 + .next = NULL,
86748 + .name = "irda_setsockopt",
86749 + .file = "net/irda/af_irda.c",
86750 + .param5 = 1,
86751 +};
86752 +
86753 +struct size_overflow_hash _000813_hash = {
86754 + .next = NULL,
86755 + .name = "ir_lirc_transmit_ir",
86756 + .file = "drivers/media/rc/ir-lirc-codec.c",
86757 + .param3 = 1,
86758 +};
86759 +
86760 +struct size_overflow_hash _000814_hash = {
86761 + .next = NULL,
86762 + .name = "irnet_ctrl_write",
86763 + .file = "net/irda/irnet/irnet_ppp.c",
86764 + .param3 = 1,
86765 +};
86766 +
86767 +struct size_overflow_hash _000815_hash = {
86768 + .next = NULL,
86769 + .name = "iscsi_decode_text_input",
86770 + .file = "drivers/target/iscsi/iscsi_target_parameters.c",
86771 + .param4 = 1,
86772 +};
86773 +
86774 +struct size_overflow_hash _000816_hash = {
86775 + .next = NULL,
86776 + .name = "iscsit_dump_data_payload",
86777 + .file = "drivers/target/iscsi/iscsi_target_erl1.c",
86778 + .param2 = 1,
86779 +};
86780 +
86781 +struct size_overflow_hash _000817_hash = {
86782 + .next = NULL,
86783 + .name = "isdn_read",
86784 + .file = "drivers/isdn/i4l/isdn_common.c",
86785 + .param3 = 1,
86786 +};
86787 +
86788 +struct size_overflow_hash _000818_hash = {
86789 + .next = NULL,
86790 + .name = "iso_callback",
86791 + .file = "drivers/firewire/core-cdev.c",
86792 + .param3 = 1,
86793 +};
86794 +
86795 +struct size_overflow_hash _000819_hash = {
86796 + .next = NULL,
86797 + .name = "iso_packets_buffer_init",
86798 + .file = "sound/firewire/packets-buffer.c",
86799 + .param3 = 1,
86800 +};
86801 +
86802 +struct size_overflow_hash _000820_hash = {
86803 + .next = NULL,
86804 + .name = "iso_sched_alloc",
86805 + .file = "drivers/usb/host/ehci-sched.c",
86806 + .param1 = 1,
86807 +};
86808 +
86809 +struct size_overflow_hash _000821_hash = {
86810 + .next = NULL,
86811 + .name = "isr_cmd_cmplt_read",
86812 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86813 + .param3 = 1,
86814 +};
86815 +
86816 +struct size_overflow_hash _000822_hash = {
86817 + .next = NULL,
86818 + .name = "isr_commands_read",
86819 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86820 + .param3 = 1,
86821 +};
86822 +
86823 +struct size_overflow_hash _000823_hash = {
86824 + .next = NULL,
86825 + .name = "isr_decrypt_done_read",
86826 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86827 + .param3 = 1,
86828 +};
86829 +
86830 +struct size_overflow_hash _000824_hash = {
86831 + .next = NULL,
86832 + .name = "isr_dma0_done_read",
86833 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86834 + .param3 = 1,
86835 +};
86836 +
86837 +struct size_overflow_hash _000825_hash = {
86838 + .next = NULL,
86839 + .name = "isr_dma1_done_read",
86840 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86841 + .param3 = 1,
86842 +};
86843 +
86844 +struct size_overflow_hash _000826_hash = {
86845 + .next = NULL,
86846 + .name = "isr_fiqs_read",
86847 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86848 + .param3 = 1,
86849 +};
86850 +
86851 +struct size_overflow_hash _000827_hash = {
86852 + .next = NULL,
86853 + .name = "isr_host_acknowledges_read",
86854 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86855 + .param3 = 1,
86856 +};
86857 +
86858 +struct size_overflow_hash _000828_hash = {
86859 + .next = &_000629_hash,
86860 + .name = "isr_hw_pm_mode_changes_read",
86861 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86862 + .param3 = 1,
86863 +};
86864 +
86865 +struct size_overflow_hash _000829_hash = {
86866 + .next = &_000329_hash,
86867 + .name = "isr_irqs_read",
86868 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86869 + .param3 = 1,
86870 +};
86871 +
86872 +struct size_overflow_hash _000830_hash = {
86873 + .next = NULL,
86874 + .name = "isr_low_rssi_read",
86875 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86876 + .param3 = 1,
86877 +};
86878 +
86879 +struct size_overflow_hash _000831_hash = {
86880 + .next = NULL,
86881 + .name = "isr_pci_pm_read",
86882 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86883 + .param3 = 1,
86884 +};
86885 +
86886 +struct size_overflow_hash _000832_hash = {
86887 + .next = NULL,
86888 + .name = "isr_rx_headers_read",
86889 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86890 + .param3 = 1,
86891 +};
86892 +
86893 +struct size_overflow_hash _000833_hash = {
86894 + .next = NULL,
86895 + .name = "isr_rx_mem_overflow_read",
86896 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86897 + .param3 = 1,
86898 +};
86899 +
86900 +struct size_overflow_hash _000834_hash = {
86901 + .next = NULL,
86902 + .name = "isr_rx_procs_read",
86903 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86904 + .param3 = 1,
86905 +};
86906 +
86907 +struct size_overflow_hash _000835_hash = {
86908 + .next = NULL,
86909 + .name = "isr_rx_rdys_read",
86910 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86911 + .param3 = 1,
86912 +};
86913 +
86914 +struct size_overflow_hash _000836_hash = {
86915 + .next = NULL,
86916 + .name = "isr_tx_exch_complete_read",
86917 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86918 + .param3 = 1,
86919 +};
86920 +
86921 +struct size_overflow_hash _000837_hash = {
86922 + .next = NULL,
86923 + .name = "isr_tx_procs_read",
86924 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86925 + .param3 = 1,
86926 +};
86927 +
86928 +struct size_overflow_hash _000838_hash = {
86929 + .next = NULL,
86930 + .name = "isr_wakeups_read",
86931 + .file = "drivers/net/wireless/wl1251/debugfs.c",
86932 + .param3 = 1,
86933 +};
86934 +
86935 +struct size_overflow_hash _000839_hash = {
86936 + .next = NULL,
86937 + .name = "ivtv_copy_buf_to_user",
86938 + .file = "drivers/media/video/ivtv/ivtv-fileops.c",
86939 + .param4 = 1,
86940 +};
86941 +
86942 +struct size_overflow_hash _000840_hash = {
86943 + .next = NULL,
86944 + .name = "iwl_dbgfs_bt_traffic_read",
86945 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
86946 + .param3 = 1,
86947 +};
86948 +
86949 +struct size_overflow_hash _000841_hash = {
86950 + .next = NULL,
86951 + .name = "iwl_dbgfs_chain_noise_read",
86952 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
86953 + .param3 = 1,
86954 +};
86955 +
86956 +struct size_overflow_hash _000842_hash = {
86957 + .next = NULL,
86958 + .name = "iwl_dbgfs_channels_read",
86959 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
86960 + .param3 = 1,
86961 +};
86962 +
86963 +struct size_overflow_hash _000843_hash = {
86964 + .next = NULL,
86965 + .name = "iwl_dbgfs_current_sleep_command_read",
86966 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
86967 + .param3 = 1,
86968 +};
86969 +
86970 +struct size_overflow_hash _000844_hash = {
86971 + .next = NULL,
86972 + .name = "iwl_dbgfs_debug_level_read",
86973 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
86974 + .param3 = 1,
86975 +};
86976 +
86977 +struct size_overflow_hash _000845_hash = {
86978 + .next = NULL,
86979 + .name = "iwl_dbgfs_debug_level_write",
86980 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
86981 + .param3 = 1,
86982 +};
86983 +
86984 +struct size_overflow_hash _000846_hash = {
86985 + .next = NULL,
86986 + .name = "iwl_dbgfs_disable_ht40_read",
86987 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
86988 + .param3 = 1,
86989 +};
86990 +
86991 +struct size_overflow_hash _000847_hash = {
86992 + .next = NULL,
86993 + .name = "iwl_dbgfs_fh_reg_read",
86994 + .file = "drivers/net/wireless/iwlwifi/iwl-trans-pcie.c",
86995 + .param3 = 1,
86996 +};
86997 +
86998 +struct size_overflow_hash _000848_hash = {
86999 + .next = NULL,
87000 + .name = "iwl_dbgfs_force_reset_read",
87001 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87002 + .param3 = 1,
87003 +};
87004 +
87005 +struct size_overflow_hash _000849_hash = {
87006 + .next = NULL,
87007 + .name = "iwl_dbgfs_interrupt_read",
87008 + .file = "drivers/net/wireless/iwlwifi/iwl-trans-pcie.c",
87009 + .param3 = 1,
87010 +};
87011 +
87012 +struct size_overflow_hash _000850_hash = {
87013 + .next = NULL,
87014 + .name = "iwl_dbgfs_log_event_read",
87015 + .file = "drivers/net/wireless/iwlwifi/iwl-trans-pcie.c",
87016 + .param3 = 1,
87017 +};
87018 +
87019 +struct size_overflow_hash _000851_hash = {
87020 + .next = NULL,
87021 + .name = "iwl_dbgfs_missed_beacon_read",
87022 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87023 + .param3 = 1,
87024 +};
87025 +
87026 +struct size_overflow_hash _000852_hash = {
87027 + .next = NULL,
87028 + .name = "iwl_dbgfs_nvm_read",
87029 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87030 + .param3 = 1,
87031 +};
87032 +
87033 +struct size_overflow_hash _000853_hash = {
87034 + .next = NULL,
87035 + .name = "iwl_dbgfs_plcp_delta_read",
87036 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87037 + .param3 = 1,
87038 +};
87039 +
87040 +struct size_overflow_hash _000854_hash = {
87041 + .next = NULL,
87042 + .name = "iwl_dbgfs_power_save_status_read",
87043 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87044 + .param3 = 1,
87045 +};
87046 +
87047 +struct size_overflow_hash _000855_hash = {
87048 + .next = NULL,
87049 + .name = "iwl_dbgfs_protection_mode_read",
87050 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87051 + .param3 = 1,
87052 +};
87053 +
87054 +struct size_overflow_hash _000856_hash = {
87055 + .next = NULL,
87056 + .name = "iwl_dbgfs_qos_read",
87057 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87058 + .param3 = 1,
87059 +};
87060 +
87061 +struct size_overflow_hash _000857_hash = {
87062 + .next = NULL,
87063 + .name = "iwl_dbgfs_reply_tx_error_read",
87064 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87065 + .param3 = 1,
87066 +};
87067 +
87068 +struct size_overflow_hash _000858_hash = {
87069 + .next = NULL,
87070 + .name = "iwl_dbgfs_rx_handlers_read",
87071 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87072 + .param3 = 1,
87073 +};
87074 +
87075 +struct size_overflow_hash _000859_hash = {
87076 + .next = NULL,
87077 + .name = "iwl_dbgfs_rxon_filter_flags_read",
87078 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87079 + .param3 = 1,
87080 +};
87081 +
87082 +struct size_overflow_hash _000860_hash = {
87083 + .next = NULL,
87084 + .name = "iwl_dbgfs_rxon_flags_read",
87085 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87086 + .param3 = 1,
87087 +};
87088 +
87089 +struct size_overflow_hash _000861_hash = {
87090 + .next = NULL,
87091 + .name = "iwl_dbgfs_rx_queue_read",
87092 + .file = "drivers/net/wireless/iwlwifi/iwl-trans-pcie.c",
87093 + .param3 = 1,
87094 +};
87095 +
87096 +struct size_overflow_hash _000862_hash = {
87097 + .next = NULL,
87098 + .name = "iwl_dbgfs_rx_statistics_read",
87099 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87100 + .param3 = 1,
87101 +};
87102 +
87103 +struct size_overflow_hash _000863_hash = {
87104 + .next = NULL,
87105 + .name = "iwl_dbgfs_sensitivity_read",
87106 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87107 + .param3 = 1,
87108 +};
87109 +
87110 +struct size_overflow_hash _000864_hash = {
87111 + .next = NULL,
87112 + .name = "iwl_dbgfs_sleep_level_override_read",
87113 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87114 + .param3 = 1,
87115 +};
87116 +
87117 +struct size_overflow_hash _000865_hash = {
87118 + .next = NULL,
87119 + .name = "iwl_dbgfs_sram_read",
87120 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87121 + .param3 = 1,
87122 +};
87123 +
87124 +struct size_overflow_hash _000866_hash = {
87125 + .next = NULL,
87126 + .name = "iwl_dbgfs_stations_read",
87127 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87128 + .param3 = 1,
87129 +};
87130 +
87131 +struct size_overflow_hash _000867_hash = {
87132 + .next = NULL,
87133 + .name = "iwl_dbgfs_status_read",
87134 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87135 + .param3 = 1,
87136 +};
87137 +
87138 +struct size_overflow_hash _000868_hash = {
87139 + .next = NULL,
87140 + .name = "iwl_dbgfs_temperature_read",
87141 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87142 + .param3 = 1,
87143 +};
87144 +
87145 +struct size_overflow_hash _000869_hash = {
87146 + .next = NULL,
87147 + .name = "iwl_dbgfs_thermal_throttling_read",
87148 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87149 + .param3 = 1,
87150 +};
87151 +
87152 +struct size_overflow_hash _000870_hash = {
87153 + .next = NULL,
87154 + .name = "iwl_dbgfs_traffic_log_read",
87155 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87156 + .param3 = 1,
87157 +};
87158 +
87159 +struct size_overflow_hash _000871_hash = {
87160 + .next = NULL,
87161 + .name = "iwl_dbgfs_tx_queue_read",
87162 + .file = "drivers/net/wireless/iwlwifi/iwl-trans-pcie.c",
87163 + .param3 = 1,
87164 +};
87165 +
87166 +struct size_overflow_hash _000872_hash = {
87167 + .next = NULL,
87168 + .name = "iwl_dbgfs_tx_statistics_read",
87169 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87170 + .param3 = 1,
87171 +};
87172 +
87173 +struct size_overflow_hash _000873_hash = {
87174 + .next = NULL,
87175 + .name = "iwl_dbgfs_ucode_bt_stats_read",
87176 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87177 + .param3 = 1,
87178 +};
87179 +
87180 +struct size_overflow_hash _000874_hash = {
87181 + .next = NULL,
87182 + .name = "iwl_dbgfs_ucode_general_stats_read",
87183 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87184 + .param3 = 1,
87185 +};
87186 +
87187 +struct size_overflow_hash _000875_hash = {
87188 + .next = NULL,
87189 + .name = "iwl_dbgfs_ucode_rx_stats_read",
87190 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87191 + .param3 = 1,
87192 +};
87193 +
87194 +struct size_overflow_hash _000876_hash = {
87195 + .next = NULL,
87196 + .name = "iwl_dbgfs_ucode_tracing_read",
87197 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87198 + .param3 = 1,
87199 +};
87200 +
87201 +struct size_overflow_hash _000877_hash = {
87202 + .next = NULL,
87203 + .name = "iwl_dbgfs_ucode_tx_stats_read",
87204 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87205 + .param3 = 1,
87206 +};
87207 +
87208 +struct size_overflow_hash _000878_hash = {
87209 + .next = NULL,
87210 + .name = "iwl_dbgfs_wowlan_sram_read",
87211 + .file = "drivers/net/wireless/iwlwifi/iwl-debugfs.c",
87212 + .param3 = 1,
87213 +};
87214 +
87215 +struct size_overflow_hash _000879_hash = {
87216 + .next = NULL,
87217 + .name = "iwmct_fw_parser_init",
87218 + .file = "drivers/misc/iwmc3200top/fw-download.c",
87219 + .param4 = 1,
87220 +};
87221 +
87222 +struct size_overflow_hash _000880_hash = {
87223 + .next = NULL,
87224 + .name = "iwm_notif_send",
87225 + .file = "drivers/net/wireless/iwmc3200wifi/main.c",
87226 + .param6 = 1,
87227 +};
87228 +
87229 +struct size_overflow_hash _000881_hash = {
87230 + .next = NULL,
87231 + .name = "iwm_ntf_calib_res",
87232 + .file = "drivers/net/wireless/iwmc3200wifi/rx.c",
87233 + .param3 = 1,
87234 +};
87235 +
87236 +struct size_overflow_hash _000882_hash = {
87237 + .next = NULL,
87238 + .name = "iwm_umac_set_config_var",
87239 + .file = "drivers/net/wireless/iwmc3200wifi/commands.c",
87240 + .param4 = 1,
87241 +};
87242 +
87243 +struct size_overflow_hash _000883_hash = {
87244 + .next = NULL,
87245 + .name = "jbd2_alloc",
87246 + .file = "include/linux/jbd2.h",
87247 + .param1 = 1,
87248 +};
87249 +
87250 +struct size_overflow_hash _000884_hash = {
87251 + .next = NULL,
87252 + .name = "key_algorithm_read",
87253 + .file = "net/mac80211/debugfs_key.c",
87254 + .param3 = 1,
87255 +};
87256 +
87257 +struct size_overflow_hash _000885_hash = {
87258 + .next = NULL,
87259 + .name = "key_icverrors_read",
87260 + .file = "net/mac80211/debugfs_key.c",
87261 + .param3 = 1,
87262 +};
87263 +
87264 +struct size_overflow_hash _000886_hash = {
87265 + .next = NULL,
87266 + .name = "key_key_read",
87267 + .file = "net/mac80211/debugfs_key.c",
87268 + .param3 = 1,
87269 +};
87270 +
87271 +struct size_overflow_hash _000887_hash = {
87272 + .next = NULL,
87273 + .name = "key_replays_read",
87274 + .file = "net/mac80211/debugfs_key.c",
87275 + .param3 = 1,
87276 +};
87277 +
87278 +struct size_overflow_hash _000888_hash = {
87279 + .next = NULL,
87280 + .name = "key_rx_spec_read",
87281 + .file = "net/mac80211/debugfs_key.c",
87282 + .param3 = 1,
87283 +};
87284 +
87285 +struct size_overflow_hash _000889_hash = {
87286 + .next = NULL,
87287 + .name = "key_tx_spec_read",
87288 + .file = "net/mac80211/debugfs_key.c",
87289 + .param3 = 1,
87290 +};
87291 +
87292 +struct size_overflow_hash _000890_hash = {
87293 + .next = NULL,
87294 + .name = "kmem_alloc",
87295 + .file = "fs/xfs/kmem.c",
87296 + .param1 = 1,
87297 +};
87298 +
87299 +struct size_overflow_hash _000891_hash = {
87300 + .next = NULL,
87301 + .name = "kmem_zalloc_large",
87302 + .file = "fs/xfs/kmem.h",
87303 + .param1 = 1,
87304 +};
87305 +
87306 +struct size_overflow_hash _000892_hash = {
87307 + .next = NULL,
87308 + .name = "kone_receive",
87309 + .file = "drivers/hid/hid-roccat-kone.c",
87310 + .param4 = 1,
87311 +};
87312 +
87313 +struct size_overflow_hash _000893_hash = {
87314 + .next = NULL,
87315 + .name = "kone_send",
87316 + .file = "drivers/hid/hid-roccat-kone.c",
87317 + .param4 = 1,
87318 +};
87319 +
87320 +struct size_overflow_hash _000894_hash = {
87321 + .next = NULL,
87322 + .name = "kvm_read_guest_atomic",
87323 + .file = "include/linux/kvm_host.h",
87324 + .param4 = 1,
87325 +};
87326 +
87327 +struct size_overflow_hash _000895_hash = {
87328 + .next = NULL,
87329 + .name = "kvm_read_guest_cached",
87330 + .file = "include/linux/kvm_host.h",
87331 + .param4 = 1,
87332 +};
87333 +
87334 +struct size_overflow_hash _000896_hash = {
87335 + .next = NULL,
87336 + .name = "kvm_set_irq_routing",
87337 + .file = "include/linux/kvm_host.h",
87338 + .param3 = 1,
87339 +};
87340 +
87341 +struct size_overflow_hash _000897_hash = {
87342 + .next = NULL,
87343 + .name = "kvm_write_guest_cached",
87344 + .file = "include/linux/kvm_host.h",
87345 + .param4 = 1,
87346 +};
87347 +
87348 +struct size_overflow_hash _000898_hash = {
87349 + .next = NULL,
87350 + .name = "l2cap_sock_setsockopt",
87351 + .file = "net/bluetooth/l2cap_sock.c",
87352 + .param5 = 1,
87353 +};
87354 +
87355 +struct size_overflow_hash _000899_hash = {
87356 + .next = NULL,
87357 + .name = "l2cap_sock_setsockopt_old",
87358 + .file = "net/bluetooth/l2cap_sock.c",
87359 + .param4 = 1,
87360 +};
87361 +
87362 +struct size_overflow_hash _000900_hash = {
87363 + .next = NULL,
87364 + .name = "lane2_associate_req",
87365 + .file = "net/atm/lec.c",
87366 + .param4 = 1,
87367 +};
87368 +
87369 +struct size_overflow_hash _000901_hash = {
87370 + .next = NULL,
87371 + .name = "lbs_debugfs_read",
87372 + .file = "drivers/net/wireless/libertas/debugfs.c",
87373 + .param3 = 1,
87374 +};
87375 +
87376 +struct size_overflow_hash _000902_hash = {
87377 + .next = NULL,
87378 + .name = "lbs_debugfs_write",
87379 + .file = "drivers/net/wireless/libertas/debugfs.c",
87380 + .param3 = 1,
87381 +};
87382 +
87383 +struct size_overflow_hash _000903_hash = {
87384 + .next = NULL,
87385 + .name = "lbs_dev_info",
87386 + .file = "drivers/net/wireless/libertas/debugfs.c",
87387 + .param3 = 1,
87388 +};
87389 +
87390 +struct size_overflow_hash _000904_hash = {
87391 + .next = NULL,
87392 + .name = "lbs_host_sleep_read",
87393 + .file = "drivers/net/wireless/libertas/debugfs.c",
87394 + .param3 = 1,
87395 +};
87396 +
87397 +struct size_overflow_hash _000905_hash = {
87398 + .next = NULL,
87399 + .name = "lbs_rdbbp_read",
87400 + .file = "drivers/net/wireless/libertas/debugfs.c",
87401 + .param3 = 1,
87402 +};
87403 +
87404 +struct size_overflow_hash _000906_hash = {
87405 + .next = NULL,
87406 + .name = "lbs_rdmac_read",
87407 + .file = "drivers/net/wireless/libertas/debugfs.c",
87408 + .param3 = 1,
87409 +};
87410 +
87411 +struct size_overflow_hash _000907_hash = {
87412 + .next = NULL,
87413 + .name = "lbs_rdrf_read",
87414 + .file = "drivers/net/wireless/libertas/debugfs.c",
87415 + .param3 = 1,
87416 +};
87417 +
87418 +struct size_overflow_hash _000908_hash = {
87419 + .next = NULL,
87420 + .name = "lbs_sleepparams_read",
87421 + .file = "drivers/net/wireless/libertas/debugfs.c",
87422 + .param3 = 1,
87423 +};
87424 +
87425 +struct size_overflow_hash _000909_hash = {
87426 + .next = NULL,
87427 + .name = "lbs_threshold_read",
87428 + .file = "drivers/net/wireless/libertas/debugfs.c",
87429 + .param5 = 1,
87430 +};
87431 +
87432 +struct size_overflow_hash _000910_hash = {
87433 + .next = NULL,
87434 + .name = "lc_create",
87435 + .file = "include/linux/lru_cache.h",
87436 + .param3 = 1,
87437 +};
87438 +
87439 +struct size_overflow_hash _000911_hash = {
87440 + .next = NULL,
87441 + .name = "lcd_write",
87442 + .file = "drivers/usb/misc/usblcd.c",
87443 + .param3 = 1,
87444 +};
87445 +
87446 +struct size_overflow_hash _000912_hash = {
87447 + .next = NULL,
87448 + .name = "leaf_dealloc",
87449 + .file = "fs/gfs2/dir.c",
87450 + .param3 = 1,
87451 +};
87452 +
87453 +struct size_overflow_hash _000913_hash = {
87454 + .next = NULL,
87455 + .name = "__lgread",
87456 + .file = "drivers/lguest/core.c",
87457 + .param4 = 1,
87458 +};
87459 +
87460 +struct size_overflow_hash _000914_hash = {
87461 + .next = NULL,
87462 + .name = "__lgwrite",
87463 + .file = "drivers/lguest/core.c",
87464 + .param4 = 1,
87465 +};
87466 +
87467 +struct size_overflow_hash _000915_hash = {
87468 + .next = NULL,
87469 + .name = "link_send_sections_long",
87470 + .file = "net/tipc/link.c",
87471 + .param4 = 1,
87472 +};
87473 +
87474 +struct size_overflow_hash _000916_hash = {
87475 + .next = NULL,
87476 + .name = "lirc_buffer_init",
87477 + .file = "include/media/lirc_dev.h",
87478 + .param2 = 1,
87479 + .param3 = 1,
87480 +};
87481 +
87482 +struct size_overflow_hash _000918_hash = {
87483 + .next = NULL,
87484 + .name = "lkdtm_debugfs_read",
87485 + .file = "drivers/misc/lkdtm.c",
87486 + .param3 = 1,
87487 +};
87488 +
87489 +struct size_overflow_hash _000919_hash = {
87490 + .next = NULL,
87491 + .name = "LoadBitmap",
87492 + .file = "drivers/media/dvb/ttpci/av7110_hw.c",
87493 + .param2 = 1,
87494 +};
87495 +
87496 +struct size_overflow_hash _000920_hash = {
87497 + .next = NULL,
87498 + .name = "long_retry_limit_read",
87499 + .file = "net/wireless/debugfs.c",
87500 + .param3 = 1,
87501 +};
87502 +
87503 +struct size_overflow_hash _000921_hash = {
87504 + .next = NULL,
87505 + .name = "lpfc_debugfs_dif_err_read",
87506 + .file = "drivers/scsi/lpfc/lpfc_debugfs.c",
87507 + .param3 = 1,
87508 +};
87509 +
87510 +struct size_overflow_hash _000922_hash = {
87511 + .next = NULL,
87512 + .name = "lpfc_debugfs_dif_err_write",
87513 + .file = "drivers/scsi/lpfc/lpfc_debugfs.c",
87514 + .param3 = 1,
87515 +};
87516 +
87517 +struct size_overflow_hash _000923_hash = {
87518 + .next = NULL,
87519 + .name = "lpfc_debugfs_read",
87520 + .file = "drivers/scsi/lpfc/lpfc_debugfs.c",
87521 + .param3 = 1,
87522 +};
87523 +
87524 +struct size_overflow_hash _000924_hash = {
87525 + .next = NULL,
87526 + .name = "lpfc_idiag_baracc_read",
87527 + .file = "drivers/scsi/lpfc/lpfc_debugfs.c",
87528 + .param3 = 1,
87529 +};
87530 +
87531 +struct size_overflow_hash _000925_hash = {
87532 + .next = NULL,
87533 + .name = "lpfc_idiag_ctlacc_read",
87534 + .file = "drivers/scsi/lpfc/lpfc_debugfs.c",
87535 + .param3 = 1,
87536 +};
87537 +
87538 +struct size_overflow_hash _000926_hash = {
87539 + .next = NULL,
87540 + .name = "lpfc_idiag_drbacc_read",
87541 + .file = "drivers/scsi/lpfc/lpfc_debugfs.c",
87542 + .param3 = 1,
87543 +};
87544 +
87545 +struct size_overflow_hash _000927_hash = {
87546 + .next = NULL,
87547 + .name = "lpfc_idiag_extacc_read",
87548 + .file = "drivers/scsi/lpfc/lpfc_debugfs.c",
87549 + .param3 = 1,
87550 +};
87551 +
87552 +struct size_overflow_hash _000928_hash = {
87553 + .next = NULL,
87554 + .name = "lpfc_idiag_mbxacc_read",
87555 + .file = "drivers/scsi/lpfc/lpfc_debugfs.c",
87556 + .param3 = 1,
87557 +};
87558 +
87559 +struct size_overflow_hash _000929_hash = {
87560 + .next = NULL,
87561 + .name = "lpfc_idiag_pcicfg_read",
87562 + .file = "drivers/scsi/lpfc/lpfc_debugfs.c",
87563 + .param3 = 1,
87564 +};
87565 +
87566 +struct size_overflow_hash _000930_hash = {
87567 + .next = NULL,
87568 + .name = "lpfc_idiag_queacc_read",
87569 + .file = "drivers/scsi/lpfc/lpfc_debugfs.c",
87570 + .param3 = 1,
87571 +};
87572 +
87573 +struct size_overflow_hash _000931_hash = {
87574 + .next = NULL,
87575 + .name = "lpfc_idiag_queinfo_read",
87576 + .file = "drivers/scsi/lpfc/lpfc_debugfs.c",
87577 + .param3 = 1,
87578 +};
87579 +
87580 +struct size_overflow_hash _000932_hash = {
87581 + .next = NULL,
87582 + .name = "lpfc_sli4_queue_alloc",
87583 + .file = "drivers/scsi/lpfc/lpfc_sli.c",
87584 + .param3 = 1,
87585 +};
87586 +
87587 +struct size_overflow_hash _000933_hash = {
87588 + .next = NULL,
87589 + .name = "lp_write",
87590 + .file = "drivers/char/lp.c",
87591 + .param3 = 1,
87592 +};
87593 +
87594 +struct size_overflow_hash _000934_hash = {
87595 + .next = NULL,
87596 + .name = "mac80211_format_buffer",
87597 + .file = "net/mac80211/debugfs.c",
87598 + .param2 = 1,
87599 +};
87600 +
87601 +struct size_overflow_hash _000935_hash = {
87602 + .next = NULL,
87603 + .name = "mce_write",
87604 + .file = "arch/x86/kernel/cpu/mcheck/mce-inject.c",
87605 + .param3 = 1,
87606 +};
87607 +
87608 +struct size_overflow_hash _000936_hash = {
87609 + .next = NULL,
87610 + .name = "mcs7830_get_reg",
87611 + .file = "drivers/net/usb/mcs7830.c",
87612 + .param3 = 1,
87613 +};
87614 +
87615 +struct size_overflow_hash _000937_hash = {
87616 + .next = NULL,
87617 + .name = "mcs7830_set_reg",
87618 + .file = "drivers/net/usb/mcs7830.c",
87619 + .param3 = 1,
87620 +};
87621 +
87622 +struct size_overflow_hash _000938_hash = {
87623 + .next = NULL,
87624 + .name = "mdc800_device_read",
87625 + .file = "drivers/usb/image/mdc800.c",
87626 + .param3 = 1,
87627 +};
87628 +
87629 +struct size_overflow_hash _000939_hash = {
87630 + .next = NULL,
87631 + .name = "mdiobus_alloc_size",
87632 + .file = "include/linux/phy.h",
87633 + .param1 = 1,
87634 +};
87635 +
87636 +struct size_overflow_hash _000940_hash = {
87637 + .next = NULL,
87638 + .name = "media_entity_init",
87639 + .file = "include/media/media-entity.h",
87640 + .param2 = 1,
87641 + .param4 = 1,
87642 +};
87643 +
87644 +struct size_overflow_hash _000942_hash = {
87645 + .next = NULL,
87646 + .name = "memstick_alloc_host",
87647 + .file = "include/linux/memstick.h",
87648 + .param1 = 1,
87649 +};
87650 +
87651 +struct size_overflow_hash _000943_hash = {
87652 + .next = NULL,
87653 + .name = "mgmt_control",
87654 + .file = "include/net/bluetooth/hci_core.h",
87655 + .param3 = 1,
87656 +};
87657 +
87658 +struct size_overflow_hash _000944_hash = {
87659 + .next = NULL,
87660 + .name = "mgmt_pending_add",
87661 + .file = "net/bluetooth/mgmt.c",
87662 + .param5 = 1,
87663 +};
87664 +
87665 +struct size_overflow_hash _000945_hash = {
87666 + .next = &_000321_hash,
87667 + .name = "mic_calc_failure_read",
87668 + .file = "drivers/net/wireless/wl1251/debugfs.c",
87669 + .param3 = 1,
87670 +};
87671 +
87672 +struct size_overflow_hash _000946_hash = {
87673 + .next = NULL,
87674 + .name = "mic_rx_pkts_read",
87675 + .file = "drivers/net/wireless/wl1251/debugfs.c",
87676 + .param3 = 1,
87677 +};
87678 +
87679 +struct size_overflow_hash _000947_hash = {
87680 + .next = NULL,
87681 + .name = "minstrel_stats_read",
87682 + .file = "net/mac80211/rc80211_minstrel_debugfs.c",
87683 + .param3 = 1,
87684 +};
87685 +
87686 +struct size_overflow_hash _000948_hash = {
87687 + .next = NULL,
87688 + .name = "mlx4_en_create_rx_ring",
87689 + .file = "drivers/net/ethernet/mellanox/mlx4/en_rx.c",
87690 + .param3 = 1,
87691 +};
87692 +
87693 +struct size_overflow_hash _000949_hash = {
87694 + .next = NULL,
87695 + .name = "mlx4_en_create_tx_ring",
87696 + .file = "drivers/net/ethernet/mellanox/mlx4/en_tx.c",
87697 + .param4 = 1,
87698 +};
87699 +
87700 +struct size_overflow_hash _000950_hash = {
87701 + .next = NULL,
87702 + .name = "mmc_ext_csd_read",
87703 + .file = "drivers/mmc/core/debugfs.c",
87704 + .param3 = 1,
87705 +};
87706 +
87707 +struct size_overflow_hash _000951_hash = {
87708 + .next = NULL,
87709 + .name = "mmc_send_bus_test",
87710 + .file = "drivers/mmc/core/mmc_ops.c",
87711 + .param4 = 1,
87712 +};
87713 +
87714 +struct size_overflow_hash _000952_hash = {
87715 + .next = NULL,
87716 + .name = "mmc_send_cxd_data",
87717 + .file = "drivers/mmc/core/mmc_ops.c",
87718 + .param5 = 1,
87719 +};
87720 +
87721 +struct size_overflow_hash _000953_hash = {
87722 + .next = NULL,
87723 + .name = "mmc_test_alloc_mem",
87724 + .file = "drivers/mmc/card/mmc_test.c",
87725 + .param3 = 1,
87726 +};
87727 +
87728 +struct size_overflow_hash _000954_hash = {
87729 + .next = NULL,
87730 + .name = "mon_bin_get_event",
87731 + .file = "drivers/usb/mon/mon_bin.c",
87732 + .param4 = 1,
87733 +};
87734 +
87735 +struct size_overflow_hash _000955_hash = {
87736 + .next = NULL,
87737 + .name = "mon_stat_read",
87738 + .file = "drivers/usb/mon/mon_stat.c",
87739 + .param3 = 1,
87740 +};
87741 +
87742 +struct size_overflow_hash _000956_hash = {
87743 + .next = NULL,
87744 + .name = "mptctl_getiocinfo",
87745 + .file = "drivers/message/fusion/mptctl.c",
87746 + .param2 = 1,
87747 +};
87748 +
87749 +struct size_overflow_hash _000957_hash = {
87750 + .next = NULL,
87751 + .name = "msnd_fifo_alloc",
87752 + .file = "sound/oss/msnd.c",
87753 + .param2 = 1,
87754 +};
87755 +
87756 +struct size_overflow_hash _000958_hash = {
87757 + .next = NULL,
87758 + .name = "mtdchar_readoob",
87759 + .file = "drivers/mtd/mtdchar.c",
87760 + .param4 = 1,
87761 +};
87762 +
87763 +struct size_overflow_hash _000959_hash = {
87764 + .next = NULL,
87765 + .name = "mtdchar_write",
87766 + .file = "drivers/mtd/mtdchar.c",
87767 + .param3 = 1,
87768 +};
87769 +
87770 +struct size_overflow_hash _000960_hash = {
87771 + .next = NULL,
87772 + .name = "mtdchar_writeoob",
87773 + .file = "drivers/mtd/mtdchar.c",
87774 + .param4 = 1,
87775 +};
87776 +
87777 +struct size_overflow_hash _000961_hash = {
87778 + .next = NULL,
87779 + .name = "mtdswap_init",
87780 + .file = "drivers/mtd/mtdswap.c",
87781 + .param2 = 1,
87782 +};
87783 +
87784 +struct size_overflow_hash _000962_hash = {
87785 + .next = NULL,
87786 + .name = "mtf_test_write",
87787 + .file = "drivers/mmc/card/mmc_test.c",
87788 + .param3 = 1,
87789 +};
87790 +
87791 +struct size_overflow_hash _000963_hash = {
87792 + .next = NULL,
87793 + .name = "musb_test_mode_write",
87794 + .file = "drivers/usb/musb/musb_debugfs.c",
87795 + .param3 = 1,
87796 +};
87797 +
87798 +struct size_overflow_hash _000964_hash = {
87799 + .next = NULL,
87800 + .name = "mvumi_alloc_mem_resource",
87801 + .file = "drivers/scsi/mvumi.c",
87802 + .param3 = 1,
87803 +};
87804 +
87805 +struct size_overflow_hash _000965_hash = {
87806 + .next = NULL,
87807 + .name = "mwifiex_alloc_sdio_mpa_buffers",
87808 + .file = "drivers/net/wireless/mwifiex/sdio.c",
87809 + .param2 = 1,
87810 + .param3 = 1,
87811 +};
87812 +
87813 +struct size_overflow_hash _000967_hash = {
87814 + .next = NULL,
87815 + .name = "mwifiex_debug_read",
87816 + .file = "drivers/net/wireless/mwifiex/debugfs.c",
87817 + .param3 = 1,
87818 +};
87819 +
87820 +struct size_overflow_hash _000968_hash = {
87821 + .next = NULL,
87822 + .name = "mwifiex_get_common_rates",
87823 + .file = "drivers/net/wireless/mwifiex/join.c",
87824 + .param3 = 1,
87825 +};
87826 +
87827 +struct size_overflow_hash _000969_hash = {
87828 + .next = NULL,
87829 + .name = "mwifiex_getlog_read",
87830 + .file = "drivers/net/wireless/mwifiex/debugfs.c",
87831 + .param3 = 1,
87832 +};
87833 +
87834 +struct size_overflow_hash _000970_hash = {
87835 + .next = NULL,
87836 + .name = "mwifiex_info_read",
87837 + .file = "drivers/net/wireless/mwifiex/debugfs.c",
87838 + .param3 = 1,
87839 +};
87840 +
87841 +struct size_overflow_hash _000971_hash = {
87842 + .next = NULL,
87843 + .name = "mwifiex_rdeeprom_read",
87844 + .file = "drivers/net/wireless/mwifiex/debugfs.c",
87845 + .param3 = 1,
87846 +};
87847 +
87848 +struct size_overflow_hash _000972_hash = {
87849 + .next = NULL,
87850 + .name = "mwifiex_regrdwr_read",
87851 + .file = "drivers/net/wireless/mwifiex/debugfs.c",
87852 + .param3 = 1,
87853 +};
87854 +
87855 +struct size_overflow_hash _000973_hash = {
87856 + .next = NULL,
87857 + .name = "mwifiex_update_curr_bss_params",
87858 + .file = "drivers/net/wireless/mwifiex/scan.c",
87859 + .param5 = 1,
87860 +};
87861 +
87862 +struct size_overflow_hash _000974_hash = {
87863 + .next = NULL,
87864 + .name = "nand_bch_init",
87865 + .file = "include/linux/mtd/nand_bch.h",
87866 + .param2 = 1,
87867 + .param3 = 1,
87868 +};
87869 +
87870 +struct size_overflow_hash _000976_hash = {
87871 + .next = NULL,
87872 + .name = "ncp_file_write",
87873 + .file = "fs/ncpfs/file.c",
87874 + .param3 = 1,
87875 +};
87876 +
87877 +struct size_overflow_hash _000977_hash = {
87878 + .next = NULL,
87879 + .name = "ncp__vol2io",
87880 + .file = "fs/ncpfs/ncplib_kernel.c",
87881 + .param5 = 1,
87882 +};
87883 +
87884 +struct size_overflow_hash _000978_hash = {
87885 + .next = NULL,
87886 + .name = "new_bind_ctl",
87887 + .file = "sound/pci/hda/patch_realtek.c",
87888 + .param2 = 1,
87889 +};
87890 +
87891 +struct size_overflow_hash _000979_hash = {
87892 + .next = NULL,
87893 + .name = "nfc_llcp_build_tlv",
87894 + .file = "net/nfc/llcp/commands.c",
87895 + .param3 = 1,
87896 +};
87897 +
87898 +struct size_overflow_hash _000980_hash = {
87899 + .next = NULL,
87900 + .name = "nfs4_alloc_slots",
87901 + .file = "fs/nfs/nfs4proc.c",
87902 + .param1 = 1,
87903 +};
87904 +
87905 +struct size_overflow_hash _000981_hash = {
87906 + .next = NULL,
87907 + .name = "nfs4_write_cached_acl",
87908 + .file = "fs/nfs/nfs4proc.c",
87909 + .param3 = 1,
87910 +};
87911 +
87912 +struct size_overflow_hash _000982_hash = {
87913 + .next = NULL,
87914 + .name = "nfsctl_transaction_read",
87915 + .file = "fs/nfsd/nfsctl.c",
87916 + .param3 = 1,
87917 +};
87918 +
87919 +struct size_overflow_hash _000983_hash = {
87920 + .next = NULL,
87921 + .name = "nfsctl_transaction_write",
87922 + .file = "fs/nfsd/nfsctl.c",
87923 + .param3 = 1,
87924 +};
87925 +
87926 +struct size_overflow_hash _000984_hash = {
87927 + .next = NULL,
87928 + .name = "nfsd_cache_update",
87929 + .file = "fs/nfsd/nfscache.c",
87930 + .param3 = 1,
87931 +};
87932 +
87933 +struct size_overflow_hash _000985_hash = {
87934 + .next = NULL,
87935 + .name = "nfs_idmap_get_desc",
87936 + .file = "fs/nfs/idmap.c",
87937 + .param2 = 1,
87938 + .param4 = 1,
87939 +};
87940 +
87941 +struct size_overflow_hash _000987_hash = {
87942 + .next = NULL,
87943 + .name = "nfs_readdata_alloc",
87944 + .file = "include/linux/nfs_fs.h",
87945 + .param1 = 1,
87946 +};
87947 +
87948 +struct size_overflow_hash _000988_hash = {
87949 + .next = NULL,
87950 + .name = "nfs_readdir_make_qstr",
87951 + .file = "fs/nfs/dir.c",
87952 + .param3 = 1,
87953 +};
87954 +
87955 +struct size_overflow_hash _000989_hash = {
87956 + .next = NULL,
87957 + .name = "nfs_writedata_alloc",
87958 + .file = "include/linux/nfs_fs.h",
87959 + .param1 = 1,
87960 +};
87961 +
87962 +struct size_overflow_hash _000990_hash = {
87963 + .next = NULL,
87964 + .name = "nsm_create_handle",
87965 + .file = "fs/lockd/mon.c",
87966 + .param4 = 1,
87967 +};
87968 +
87969 +struct size_overflow_hash _000991_hash = {
87970 + .next = NULL,
87971 + .name = "ntfs_copy_from_user",
87972 + .file = "fs/ntfs/file.c",
87973 + .param3 = 1,
87974 + .param5 = 1,
87975 +};
87976 +
87977 +struct size_overflow_hash _000993_hash = {
87978 + .next = NULL,
87979 + .name = "__ntfs_copy_from_user_iovec_inatomic",
87980 + .file = "fs/ntfs/file.c",
87981 + .param3 = 1,
87982 + .param4 = 1,
87983 +};
87984 +
87985 +struct size_overflow_hash _000995_hash = {
87986 + .next = NULL,
87987 + .name = "__ntfs_malloc",
87988 + .file = "fs/ntfs/malloc.h",
87989 + .param1 = 1,
87990 +};
87991 +
87992 +struct size_overflow_hash _000996_hash = {
87993 + .next = NULL,
87994 + .name = "nvme_alloc_iod",
87995 + .file = "drivers/block/nvme.c",
87996 + .param1 = 1,
87997 +};
87998 +
87999 +struct size_overflow_hash _000997_hash = {
88000 + .next = NULL,
88001 + .name = "nvram_write",
88002 + .file = "drivers/char/nvram.c",
88003 + .param3 = 1,
88004 +};
88005 +
88006 +struct size_overflow_hash _000998_hash = {
88007 + .next = NULL,
88008 + .name = "o2hb_debug_read",
88009 + .file = "fs/ocfs2/cluster/heartbeat.c",
88010 + .param3 = 1,
88011 +};
88012 +
88013 +struct size_overflow_hash _000999_hash = {
88014 + .next = NULL,
88015 + .name = "o2net_debug_read",
88016 + .file = "fs/ocfs2/cluster/netdebug.c",
88017 + .param3 = 1,
88018 +};
88019 +
88020 +struct size_overflow_hash _001000_hash = {
88021 + .next = NULL,
88022 + .name = "o2net_send_message_vec",
88023 + .file = "fs/ocfs2/cluster/tcp.c",
88024 + .param4 = 1,
88025 +};
88026 +
88027 +struct size_overflow_hash _001001_hash = {
88028 + .next = NULL,
88029 + .name = "ocfs2_control_cfu",
88030 + .file = "fs/ocfs2/stack_user.c",
88031 + .param2 = 1,
88032 +};
88033 +
88034 +struct size_overflow_hash _001002_hash = {
88035 + .next = NULL,
88036 + .name = "ocfs2_control_read",
88037 + .file = "fs/ocfs2/stack_user.c",
88038 + .param3 = 1,
88039 +};
88040 +
88041 +struct size_overflow_hash _001003_hash = {
88042 + .next = NULL,
88043 + .name = "ocfs2_debug_read",
88044 + .file = "fs/ocfs2/super.c",
88045 + .param3 = 1,
88046 +};
88047 +
88048 +struct size_overflow_hash _001004_hash = {
88049 + .next = NULL,
88050 + .name = "opera1_xilinx_rw",
88051 + .file = "drivers/media/dvb/dvb-usb/opera1.c",
88052 + .param5 = 1,
88053 +};
88054 +
88055 +struct size_overflow_hash _001005_hash = {
88056 + .next = NULL,
88057 + .name = "oprofilefs_str_to_user",
88058 + .file = "include/linux/oprofile.h",
88059 + .param3 = 1,
88060 +};
88061 +
88062 +struct size_overflow_hash _001006_hash = {
88063 + .next = NULL,
88064 + .name = "oprofilefs_ulong_from_user",
88065 + .file = "include/linux/oprofile.h",
88066 + .param3 = 1,
88067 +};
88068 +
88069 +struct size_overflow_hash _001007_hash = {
88070 + .next = &_000626_hash,
88071 + .name = "oprofilefs_ulong_to_user",
88072 + .file = "include/linux/oprofile.h",
88073 + .param3 = 1,
88074 +};
88075 +
88076 +struct size_overflow_hash _001008_hash = {
88077 + .next = NULL,
88078 + .name = "_ore_get_io_state",
88079 + .file = "fs/exofs/ore.c",
88080 + .param3 = 1,
88081 +};
88082 +
88083 +struct size_overflow_hash _001009_hash = {
88084 + .next = NULL,
88085 + .name = "_osd_realloc_seg",
88086 + .file = "drivers/scsi/osd/osd_initiator.c",
88087 + .param3 = 1,
88088 +};
88089 +
88090 +struct size_overflow_hash _001010_hash = {
88091 + .next = NULL,
88092 + .name = "_osd_req_list_objects",
88093 + .file = "drivers/scsi/osd/osd_initiator.c",
88094 + .param6 = 1,
88095 +};
88096 +
88097 +struct size_overflow_hash _001011_hash = {
88098 + .next = NULL,
88099 + .name = "osd_req_read_kern",
88100 + .file = "include/scsi/osd_initiator.h",
88101 + .param5 = 1,
88102 +};
88103 +
88104 +struct size_overflow_hash _001012_hash = {
88105 + .next = NULL,
88106 + .name = "osd_req_write_kern",
88107 + .file = "include/scsi/osd_initiator.h",
88108 + .param5 = 1,
88109 +};
88110 +
88111 +struct size_overflow_hash _001013_hash = {
88112 + .next = NULL,
88113 + .name = "osst_execute",
88114 + .file = "drivers/scsi/osst.c",
88115 + .param6 = 1,
88116 +};
88117 +
88118 +struct size_overflow_hash _001014_hash = {
88119 + .next = NULL,
88120 + .name = "otp_read",
88121 + .file = "drivers/mtd/devices/mtd_dataflash.c",
88122 + .param2 = 1,
88123 + .param5 = 1,
88124 +};
88125 +
88126 +struct size_overflow_hash _001016_hash = {
88127 + .next = NULL,
88128 + .name = "packet_buffer_init",
88129 + .file = "drivers/firewire/nosy.c",
88130 + .param2 = 1,
88131 +};
88132 +
88133 +struct size_overflow_hash _001017_hash = {
88134 + .next = NULL,
88135 + .name = "packet_setsockopt",
88136 + .file = "net/packet/af_packet.c",
88137 + .param5 = 1,
88138 +};
88139 +
88140 +struct size_overflow_hash _001018_hash = {
88141 + .next = NULL,
88142 + .name = "parse_arg",
88143 + .file = "drivers/platform/x86/asus_acpi.c",
88144 + .param2 = 1,
88145 +};
88146 +
88147 +struct size_overflow_hash _001019_hash = {
88148 + .next = NULL,
88149 + .name = "parse_command",
88150 + .file = "fs/binfmt_misc.c",
88151 + .param2 = 1,
88152 +};
88153 +
88154 +struct size_overflow_hash _001020_hash = {
88155 + .next = NULL,
88156 + .name = "pcmcia_replace_cis",
88157 + .file = "drivers/pcmcia/cistpl.c",
88158 + .param3 = 1,
88159 +};
88160 +
88161 +struct size_overflow_hash _001021_hash = {
88162 + .next = NULL,
88163 + .name = "pcnet32_realloc_rx_ring",
88164 + .file = "drivers/net/ethernet/amd/pcnet32.c",
88165 + .param3 = 1,
88166 +};
88167 +
88168 +struct size_overflow_hash _001022_hash = {
88169 + .next = NULL,
88170 + .name = "pcnet32_realloc_tx_ring",
88171 + .file = "drivers/net/ethernet/amd/pcnet32.c",
88172 + .param3 = 1,
88173 +};
88174 +
88175 +struct size_overflow_hash _001023_hash = {
88176 + .next = NULL,
88177 + .name = "pgctrl_write",
88178 + .file = "net/core/pktgen.c",
88179 + .param3 = 1,
88180 +};
88181 +
88182 +struct size_overflow_hash _001024_hash = {
88183 + .next = NULL,
88184 + .name = "pg_read",
88185 + .file = "drivers/block/paride/pg.c",
88186 + .param3 = 1,
88187 +};
88188 +
88189 +struct size_overflow_hash _001025_hash = {
88190 + .next = NULL,
88191 + .name = "pg_write",
88192 + .file = "drivers/block/paride/pg.c",
88193 + .param3 = 1,
88194 +};
88195 +
88196 +struct size_overflow_hash _001026_hash = {
88197 + .next = NULL,
88198 + .name = "picolcd_debug_eeprom_read",
88199 + .file = "drivers/hid/hid-picolcd.c",
88200 + .param3 = 1,
88201 +};
88202 +
88203 +struct size_overflow_hash _001027_hash = {
88204 + .next = NULL,
88205 + .name = "pkt_add",
88206 + .file = "drivers/usb/serial/garmin_gps.c",
88207 + .param3 = 1,
88208 +};
88209 +
88210 +struct size_overflow_hash _001028_hash = {
88211 + .next = NULL,
88212 + .name = "pktgen_if_write",
88213 + .file = "net/core/pktgen.c",
88214 + .param3 = 1,
88215 +};
88216 +
88217 +struct size_overflow_hash _001029_hash = {
88218 + .next = NULL,
88219 + .name = "platform_list_read_file",
88220 + .file = "sound/soc/soc-core.c",
88221 + .param3 = 1,
88222 +};
88223 +
88224 +struct size_overflow_hash _001030_hash = {
88225 + .next = NULL,
88226 + .name = "pm8001_store_update_fw",
88227 + .file = "drivers/scsi/pm8001/pm8001_ctl.c",
88228 + .param4 = 1,
88229 +};
88230 +
88231 +struct size_overflow_hash _001031_hash = {
88232 + .next = NULL,
88233 + .name = "port_show_regs",
88234 + .file = "drivers/tty/serial/mfd.c",
88235 + .param3 = 1,
88236 +};
88237 +
88238 +struct size_overflow_hash _001032_hash = {
88239 + .next = NULL,
88240 + .name = "ppp_cp_parse_cr",
88241 + .file = "drivers/net/wan/hdlc_ppp.c",
88242 + .param4 = 1,
88243 +};
88244 +
88245 +struct size_overflow_hash _001033_hash = {
88246 + .next = NULL,
88247 + .name = "ppp_write",
88248 + .file = "drivers/net/ppp/ppp_generic.c",
88249 + .param3 = 1,
88250 +};
88251 +
88252 +struct size_overflow_hash _001034_hash = {
88253 + .next = NULL,
88254 + .name = "pp_read",
88255 + .file = "drivers/char/ppdev.c",
88256 + .param3 = 1,
88257 +};
88258 +
88259 +struct size_overflow_hash _001035_hash = {
88260 + .next = NULL,
88261 + .name = "pp_write",
88262 + .file = "drivers/char/ppdev.c",
88263 + .param3 = 1,
88264 +};
88265 +
88266 +struct size_overflow_hash _001036_hash = {
88267 + .next = NULL,
88268 + .name = "printer_read",
88269 + .file = "drivers/usb/gadget/printer.c",
88270 + .param3 = 1,
88271 +};
88272 +
88273 +struct size_overflow_hash _001037_hash = {
88274 + .next = NULL,
88275 + .name = "printer_req_alloc",
88276 + .file = "drivers/usb/gadget/printer.c",
88277 + .param2 = 1,
88278 +};
88279 +
88280 +struct size_overflow_hash _001038_hash = {
88281 + .next = NULL,
88282 + .name = "printer_write",
88283 + .file = "drivers/usb/gadget/printer.c",
88284 + .param3 = 1,
88285 +};
88286 +
88287 +struct size_overflow_hash _001039_hash = {
88288 + .next = NULL,
88289 + .name = "prism2_set_genericelement",
88290 + .file = "drivers/net/wireless/hostap/hostap_ioctl.c",
88291 + .param3 = 1,
88292 +};
88293 +
88294 +struct size_overflow_hash _001040_hash = {
88295 + .next = NULL,
88296 + .name = "proc_read",
88297 + .file = "drivers/net/wireless/airo.c",
88298 + .param3 = 1,
88299 +};
88300 +
88301 +struct size_overflow_hash _001041_hash = {
88302 + .next = NULL,
88303 + .name = "proc_scsi_devinfo_write",
88304 + .file = "drivers/scsi/scsi_devinfo.c",
88305 + .param3 = 1,
88306 +};
88307 +
88308 +struct size_overflow_hash _001042_hash = {
88309 + .next = NULL,
88310 + .name = "proc_scsi_write",
88311 + .file = "drivers/scsi/scsi_proc.c",
88312 + .param3 = 1,
88313 +};
88314 +
88315 +struct size_overflow_hash _001043_hash = {
88316 + .next = NULL,
88317 + .name = "proc_scsi_write_proc",
88318 + .file = "drivers/scsi/scsi_proc.c",
88319 + .param3 = 1,
88320 +};
88321 +
88322 +struct size_overflow_hash _001044_hash = {
88323 + .next = NULL,
88324 + .name = "proc_write",
88325 + .file = "drivers/net/wireless/airo.c",
88326 + .param3 = 1,
88327 +};
88328 +
88329 +struct size_overflow_hash _001045_hash = {
88330 + .next = NULL,
88331 + .name = "provide_user_output",
88332 + .file = "fs/ubifs/debug.c",
88333 + .param3 = 1,
88334 +};
88335 +
88336 +struct size_overflow_hash _001046_hash = {
88337 + .next = NULL,
88338 + .name = "ps_pspoll_max_apturn_read",
88339 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88340 + .param3 = 1,
88341 +};
88342 +
88343 +struct size_overflow_hash _001047_hash = {
88344 + .next = NULL,
88345 + .name = "ps_pspoll_timeouts_read",
88346 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88347 + .param3 = 1,
88348 +};
88349 +
88350 +struct size_overflow_hash _001048_hash = {
88351 + .next = NULL,
88352 + .name = "ps_pspoll_utilization_read",
88353 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88354 + .param3 = 1,
88355 +};
88356 +
88357 +struct size_overflow_hash _001049_hash = {
88358 + .next = NULL,
88359 + .name = "ps_upsd_max_apturn_read",
88360 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88361 + .param3 = 1,
88362 +};
88363 +
88364 +struct size_overflow_hash _001050_hash = {
88365 + .next = NULL,
88366 + .name = "ps_upsd_max_sptime_read",
88367 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88368 + .param3 = 1,
88369 +};
88370 +
88371 +struct size_overflow_hash _001051_hash = {
88372 + .next = NULL,
88373 + .name = "ps_upsd_timeouts_read",
88374 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88375 + .param3 = 1,
88376 +};
88377 +
88378 +struct size_overflow_hash _001052_hash = {
88379 + .next = NULL,
88380 + .name = "ps_upsd_utilization_read",
88381 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88382 + .param3 = 1,
88383 +};
88384 +
88385 +struct size_overflow_hash _001053_hash = {
88386 + .next = NULL,
88387 + .name = "pti_char_write",
88388 + .file = "drivers/misc/pti.c",
88389 + .param3 = 1,
88390 +};
88391 +
88392 +struct size_overflow_hash _001054_hash = {
88393 + .next = NULL,
88394 + .name = "pt_read",
88395 + .file = "drivers/block/paride/pt.c",
88396 + .param3 = 1,
88397 +};
88398 +
88399 +struct size_overflow_hash _001055_hash = {
88400 + .next = NULL,
88401 + .name = "pt_write",
88402 + .file = "drivers/block/paride/pt.c",
88403 + .param3 = 1,
88404 +};
88405 +
88406 +struct size_overflow_hash _001056_hash = {
88407 + .next = NULL,
88408 + .name = "pvr2_ioread_read",
88409 + .file = "drivers/media/video/pvrusb2/pvrusb2-ioread.c",
88410 + .param3 = 1,
88411 +};
88412 +
88413 +struct size_overflow_hash _001057_hash = {
88414 + .next = NULL,
88415 + .name = "pvr2_ioread_set_sync_key",
88416 + .file = "drivers/media/video/pvrusb2/pvrusb2-ioread.c",
88417 + .param3 = 1,
88418 +};
88419 +
88420 +struct size_overflow_hash _001058_hash = {
88421 + .next = NULL,
88422 + .name = "pvr2_stream_buffer_count",
88423 + .file = "drivers/media/video/pvrusb2/pvrusb2-io.c",
88424 + .param2 = 1,
88425 +};
88426 +
88427 +struct size_overflow_hash _001059_hash = {
88428 + .next = NULL,
88429 + .name = "pwr_disable_ps_read",
88430 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88431 + .param3 = 1,
88432 +};
88433 +
88434 +struct size_overflow_hash _001060_hash = {
88435 + .next = NULL,
88436 + .name = "pwr_elp_enter_read",
88437 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88438 + .param3 = 1,
88439 +};
88440 +
88441 +struct size_overflow_hash _001061_hash = {
88442 + .next = NULL,
88443 + .name = "pwr_enable_ps_read",
88444 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88445 + .param3 = 1,
88446 +};
88447 +
88448 +struct size_overflow_hash _001062_hash = {
88449 + .next = NULL,
88450 + .name = "pwr_fix_tsf_ps_read",
88451 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88452 + .param3 = 1,
88453 +};
88454 +
88455 +struct size_overflow_hash _001063_hash = {
88456 + .next = NULL,
88457 + .name = "pwr_missing_bcns_read",
88458 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88459 + .param3 = 1,
88460 +};
88461 +
88462 +struct size_overflow_hash _001064_hash = {
88463 + .next = NULL,
88464 + .name = "pwr_power_save_off_read",
88465 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88466 + .param3 = 1,
88467 +};
88468 +
88469 +struct size_overflow_hash _001065_hash = {
88470 + .next = NULL,
88471 + .name = "pwr_ps_enter_read",
88472 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88473 + .param3 = 1,
88474 +};
88475 +
88476 +struct size_overflow_hash _001066_hash = {
88477 + .next = NULL,
88478 + .name = "pwr_rcvd_awake_beacons_read",
88479 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88480 + .param3 = 1,
88481 +};
88482 +
88483 +struct size_overflow_hash _001067_hash = {
88484 + .next = NULL,
88485 + .name = "pwr_rcvd_beacons_read",
88486 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88487 + .param3 = 1,
88488 +};
88489 +
88490 +struct size_overflow_hash _001068_hash = {
88491 + .next = NULL,
88492 + .name = "pwr_tx_without_ps_read",
88493 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88494 + .param3 = 1,
88495 +};
88496 +
88497 +struct size_overflow_hash _001069_hash = {
88498 + .next = NULL,
88499 + .name = "pwr_tx_with_ps_read",
88500 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88501 + .param3 = 1,
88502 +};
88503 +
88504 +struct size_overflow_hash _001070_hash = {
88505 + .next = NULL,
88506 + .name = "pwr_wake_on_host_read",
88507 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88508 + .param3 = 1,
88509 +};
88510 +
88511 +struct size_overflow_hash _001071_hash = {
88512 + .next = NULL,
88513 + .name = "pwr_wake_on_timer_exp_read",
88514 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88515 + .param3 = 1,
88516 +};
88517 +
88518 +struct size_overflow_hash _001072_hash = {
88519 + .next = NULL,
88520 + .name = "qc_capture",
88521 + .file = "drivers/media/video/c-qcam.c",
88522 + .param3 = 1,
88523 +};
88524 +
88525 +struct size_overflow_hash _001073_hash = {
88526 + .next = NULL,
88527 + .name = "qla2x00_get_ctx_bsg_sp",
88528 + .file = "drivers/scsi/qla2xxx/qla_bsg.c",
88529 + .param3 = 1,
88530 +};
88531 +
88532 +struct size_overflow_hash _001074_hash = {
88533 + .next = NULL,
88534 + .name = "qla2x00_get_ctx_sp",
88535 + .file = "drivers/scsi/qla2xxx/qla_init.c",
88536 + .param3 = 1,
88537 +};
88538 +
88539 +struct size_overflow_hash _001075_hash = {
88540 + .next = NULL,
88541 + .name = "qlcnic_alloc_msix_entries",
88542 + .file = "drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c",
88543 + .param2 = 1,
88544 +};
88545 +
88546 +struct size_overflow_hash _001076_hash = {
88547 + .next = NULL,
88548 + .name = "queues_read",
88549 + .file = "net/mac80211/debugfs.c",
88550 + .param3 = 1,
88551 +};
88552 +
88553 +struct size_overflow_hash _001077_hash = {
88554 + .next = NULL,
88555 + .name = "r3964_write",
88556 + .file = "drivers/tty/n_r3964.c",
88557 + .param4 = 1,
88558 +};
88559 +
88560 +struct size_overflow_hash _001078_hash = {
88561 + .next = NULL,
88562 + .name = "raw_setsockopt",
88563 + .file = "net/can/raw.c",
88564 + .param5 = 1,
88565 +};
88566 +
88567 +struct size_overflow_hash _001079_hash = {
88568 + .next = NULL,
88569 + .name = "ray_cs_essid_proc_write",
88570 + .file = "drivers/net/wireless/ray_cs.c",
88571 + .param3 = 1,
88572 +};
88573 +
88574 +struct size_overflow_hash _001080_hash = {
88575 + .next = NULL,
88576 + .name = "rbd_snap_add",
88577 + .file = "drivers/block/rbd.c",
88578 + .param4 = 1,
88579 +};
88580 +
88581 +struct size_overflow_hash _001081_hash = {
88582 + .next = NULL,
88583 + .name = "rcname_read",
88584 + .file = "net/mac80211/rate.c",
88585 + .param3 = 1,
88586 +};
88587 +
88588 +struct size_overflow_hash _001082_hash = {
88589 + .next = NULL,
88590 + .name = "rds_message_alloc",
88591 + .file = "net/rds/message.c",
88592 + .param1 = 1,
88593 +};
88594 +
88595 +struct size_overflow_hash _001083_hash = {
88596 + .next = NULL,
88597 + .name = "rds_page_copy_user",
88598 + .file = "net/rds/page.c",
88599 + .param4 = 1,
88600 +};
88601 +
88602 +struct size_overflow_hash _001084_hash = {
88603 + .next = NULL,
88604 + .name = "read",
88605 + .file = "drivers/pci/hotplug/cpqphp_sysfs.c",
88606 + .param3 = 1,
88607 +};
88608 +
88609 +struct size_overflow_hash _001085_hash = {
88610 + .next = NULL,
88611 + .name = "read_4k_modal_eeprom",
88612 + .file = "drivers/net/wireless/ath/ath9k/htc_drv_debug.c",
88613 + .param3 = 1,
88614 +};
88615 +
88616 +struct size_overflow_hash _001086_hash = {
88617 + .next = NULL,
88618 + .name = "read_9287_modal_eeprom",
88619 + .file = "drivers/net/wireless/ath/ath9k/htc_drv_debug.c",
88620 + .param3 = 1,
88621 +};
88622 +
88623 +struct size_overflow_hash _001087_hash = {
88624 + .next = NULL,
88625 + .name = "read_buf",
88626 + .file = "fs/nfsd/nfs4xdr.c",
88627 + .param2 = 1,
88628 +};
88629 +
88630 +struct size_overflow_hash _001088_hash = {
88631 + .next = NULL,
88632 + .name = "read_cis_cache",
88633 + .file = "drivers/pcmcia/cistpl.c",
88634 + .param4 = 1,
88635 +};
88636 +
88637 +struct size_overflow_hash _001089_hash = {
88638 + .next = NULL,
88639 + .name = "read_def_modal_eeprom",
88640 + .file = "drivers/net/wireless/ath/ath9k/htc_drv_debug.c",
88641 + .param3 = 1,
88642 +};
88643 +
88644 +struct size_overflow_hash _001090_hash = {
88645 + .next = NULL,
88646 + .name = "read_file_ani",
88647 + .file = "drivers/net/wireless/ath/ath5k/debug.c",
88648 + .param3 = 1,
88649 +};
88650 +
88651 +struct size_overflow_hash _001091_hash = {
88652 + .next = NULL,
88653 + .name = "read_file_antenna",
88654 + .file = "drivers/net/wireless/ath/ath5k/debug.c",
88655 + .param3 = 1,
88656 +};
88657 +
88658 +struct size_overflow_hash _001092_hash = {
88659 + .next = NULL,
88660 + .name = "read_file_base_eeprom",
88661 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88662 + .param3 = 1,
88663 +};
88664 +
88665 +struct size_overflow_hash _001093_hash = {
88666 + .next = NULL,
88667 + .name = "read_file_base_eeprom",
88668 + .file = "drivers/net/wireless/ath/ath9k/htc_drv_debug.c",
88669 + .param3 = 1,
88670 +};
88671 +
88672 +struct size_overflow_hash _001094_hash = {
88673 + .next = NULL,
88674 + .name = "read_file_beacon",
88675 + .file = "drivers/net/wireless/ath/ath5k/debug.c",
88676 + .param3 = 1,
88677 +};
88678 +
88679 +struct size_overflow_hash _001095_hash = {
88680 + .next = NULL,
88681 + .name = "read_file_credit_dist_stats",
88682 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
88683 + .param3 = 1,
88684 +};
88685 +
88686 +struct size_overflow_hash _001096_hash = {
88687 + .next = NULL,
88688 + .name = "read_file_debug",
88689 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88690 + .param3 = 1,
88691 +};
88692 +
88693 +struct size_overflow_hash _001097_hash = {
88694 + .next = NULL,
88695 + .name = "read_file_debug",
88696 + .file = "drivers/net/wireless/ath/ath9k/htc_drv_debug.c",
88697 + .param3 = 1,
88698 +};
88699 +
88700 +struct size_overflow_hash _001098_hash = {
88701 + .next = NULL,
88702 + .name = "read_file_debug",
88703 + .file = "drivers/net/wireless/ath/ath5k/debug.c",
88704 + .param3 = 1,
88705 +};
88706 +
88707 +struct size_overflow_hash _001099_hash = {
88708 + .next = NULL,
88709 + .name = "read_file_disable_ani",
88710 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88711 + .param3 = 1,
88712 +};
88713 +
88714 +struct size_overflow_hash _001100_hash = {
88715 + .next = NULL,
88716 + .name = "read_file_dma",
88717 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88718 + .param3 = 1,
88719 +};
88720 +
88721 +struct size_overflow_hash _001101_hash = {
88722 + .next = NULL,
88723 + .name = "read_file_dump_nfcal",
88724 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88725 + .param3 = 1,
88726 +};
88727 +
88728 +struct size_overflow_hash _001102_hash = {
88729 + .next = NULL,
88730 + .name = "read_file_frameerrors",
88731 + .file = "drivers/net/wireless/ath/ath5k/debug.c",
88732 + .param3 = 1,
88733 +};
88734 +
88735 +struct size_overflow_hash _001103_hash = {
88736 + .next = NULL,
88737 + .name = "read_file_interrupt",
88738 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88739 + .param3 = 1,
88740 +};
88741 +
88742 +struct size_overflow_hash _001104_hash = {
88743 + .next = NULL,
88744 + .name = "read_file_misc",
88745 + .file = "drivers/net/wireless/ath/ath5k/debug.c",
88746 + .param3 = 1,
88747 +};
88748 +
88749 +struct size_overflow_hash _001105_hash = {
88750 + .next = NULL,
88751 + .name = "read_file_misc",
88752 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88753 + .param3 = 1,
88754 +};
88755 +
88756 +struct size_overflow_hash _001106_hash = {
88757 + .next = NULL,
88758 + .name = "read_file_modal_eeprom",
88759 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88760 + .param3 = 1,
88761 +};
88762 +
88763 +struct size_overflow_hash _001107_hash = {
88764 + .next = NULL,
88765 + .name = "read_file_queue",
88766 + .file = "drivers/net/wireless/ath/ath5k/debug.c",
88767 + .param3 = 1,
88768 +};
88769 +
88770 +struct size_overflow_hash _001108_hash = {
88771 + .next = NULL,
88772 + .name = "read_file_queue",
88773 + .file = "drivers/net/wireless/ath/ath9k/htc_drv_debug.c",
88774 + .param3 = 1,
88775 +};
88776 +
88777 +struct size_overflow_hash _001109_hash = {
88778 + .next = NULL,
88779 + .name = "read_file_rcstat",
88780 + .file = "drivers/net/wireless/ath/ath9k/rc.c",
88781 + .param3 = 1,
88782 +};
88783 +
88784 +struct size_overflow_hash _001110_hash = {
88785 + .next = NULL,
88786 + .name = "read_file_recv",
88787 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88788 + .param3 = 1,
88789 +};
88790 +
88791 +struct size_overflow_hash _001111_hash = {
88792 + .next = NULL,
88793 + .name = "read_file_recv",
88794 + .file = "drivers/net/wireless/ath/ath9k/htc_drv_debug.c",
88795 + .param3 = 1,
88796 +};
88797 +
88798 +struct size_overflow_hash _001112_hash = {
88799 + .next = NULL,
88800 + .name = "read_file_regidx",
88801 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88802 + .param3 = 1,
88803 +};
88804 +
88805 +struct size_overflow_hash _001113_hash = {
88806 + .next = &_001103_hash,
88807 + .name = "read_file_regval",
88808 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88809 + .param3 = 1,
88810 +};
88811 +
88812 +struct size_overflow_hash _001114_hash = {
88813 + .next = NULL,
88814 + .name = "read_file_rx_chainmask",
88815 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88816 + .param3 = 1,
88817 +};
88818 +
88819 +struct size_overflow_hash _001115_hash = {
88820 + .next = NULL,
88821 + .name = "read_file_slot",
88822 + .file = "drivers/net/wireless/ath/ath9k/htc_drv_debug.c",
88823 + .param3 = 1,
88824 +};
88825 +
88826 +struct size_overflow_hash _001116_hash = {
88827 + .next = NULL,
88828 + .name = "read_file_stations",
88829 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88830 + .param3 = 1,
88831 +};
88832 +
88833 +struct size_overflow_hash _001117_hash = {
88834 + .next = NULL,
88835 + .name = "read_file_tgt_int_stats",
88836 + .file = "drivers/net/wireless/ath/ath9k/htc_drv_debug.c",
88837 + .param3 = 1,
88838 +};
88839 +
88840 +struct size_overflow_hash _001118_hash = {
88841 + .next = NULL,
88842 + .name = "read_file_tgt_rx_stats",
88843 + .file = "drivers/net/wireless/ath/ath9k/htc_drv_debug.c",
88844 + .param3 = 1,
88845 +};
88846 +
88847 +struct size_overflow_hash _001119_hash = {
88848 + .next = NULL,
88849 + .name = "read_file_tgt_stats",
88850 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
88851 + .param3 = 1,
88852 +};
88853 +
88854 +struct size_overflow_hash _001120_hash = {
88855 + .next = NULL,
88856 + .name = "read_file_tgt_tx_stats",
88857 + .file = "drivers/net/wireless/ath/ath9k/htc_drv_debug.c",
88858 + .param3 = 1,
88859 +};
88860 +
88861 +struct size_overflow_hash _001121_hash = {
88862 + .next = NULL,
88863 + .name = "read_file_tx_chainmask",
88864 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88865 + .param3 = 1,
88866 +};
88867 +
88868 +struct size_overflow_hash _001122_hash = {
88869 + .next = NULL,
88870 + .name = "read_file_war_stats",
88871 + .file = "drivers/net/wireless/ath/ath6kl/debug.c",
88872 + .param3 = 1,
88873 +};
88874 +
88875 +struct size_overflow_hash _001123_hash = {
88876 + .next = NULL,
88877 + .name = "read_file_wiphy",
88878 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88879 + .param3 = 1,
88880 +};
88881 +
88882 +struct size_overflow_hash _001124_hash = {
88883 + .next = NULL,
88884 + .name = "read_file_xmit",
88885 + .file = "drivers/net/wireless/ath/ath9k/htc_drv_debug.c",
88886 + .param3 = 1,
88887 +};
88888 +
88889 +struct size_overflow_hash _001125_hash = {
88890 + .next = NULL,
88891 + .name = "read_file_xmit",
88892 + .file = "drivers/net/wireless/ath/ath9k/debug.c",
88893 + .param3 = 1,
88894 +};
88895 +
88896 +struct size_overflow_hash _001126_hash = {
88897 + .next = NULL,
88898 + .name = "read_flush",
88899 + .file = "net/sunrpc/cache.c",
88900 + .param3 = 1,
88901 +};
88902 +
88903 +struct size_overflow_hash _001127_hash = {
88904 + .next = NULL,
88905 + .name = "realloc_buffer",
88906 + .file = "drivers/scsi/device_handler/scsi_dh_alua.c",
88907 + .param2 = 1,
88908 +};
88909 +
88910 +struct size_overflow_hash _001128_hash = {
88911 + .next = NULL,
88912 + .name = "receive_DataRequest",
88913 + .file = "drivers/block/drbd/drbd_receiver.c",
88914 + .param3 = 1,
88915 +};
88916 +
88917 +struct size_overflow_hash _001129_hash = {
88918 + .next = NULL,
88919 + .name = "recent_mt_proc_write",
88920 + .file = "net/netfilter/xt_recent.c",
88921 + .param3 = 1,
88922 +};
88923 +
88924 +struct size_overflow_hash _001130_hash = {
88925 + .next = NULL,
88926 + .name = "redrat3_transmit_ir",
88927 + .file = "drivers/media/rc/redrat3.c",
88928 + .param3 = 1,
88929 +};
88930 +
88931 +struct size_overflow_hash _001131_hash = {
88932 + .next = NULL,
88933 + .name = "reg_w_buf",
88934 + .file = "drivers/media/video/gspca/t613.c",
88935 + .param3 = 1,
88936 +};
88937 +
88938 +struct size_overflow_hash _001132_hash = {
88939 + .next = NULL,
88940 + .name = "reg_w_ixbuf",
88941 + .file = "drivers/media/video/gspca/t613.c",
88942 + .param4 = 1,
88943 +};
88944 +
88945 +struct size_overflow_hash _001133_hash = {
88946 + .next = NULL,
88947 + .name = "reiserfs_allocate_list_bitmaps",
88948 + .file = "include/linux/reiserfs_fs.h",
88949 + .param3 = 1,
88950 +};
88951 +
88952 +struct size_overflow_hash _001134_hash = {
88953 + .next = NULL,
88954 + .name = "reiserfs_resize",
88955 + .file = "include/linux/reiserfs_fs_sb.h",
88956 + .param2 = 1,
88957 +};
88958 +
88959 +struct size_overflow_hash _001135_hash = {
88960 + .next = NULL,
88961 + .name = "remote_settings_file_write",
88962 + .file = "drivers/misc/ibmasm/ibmasmfs.c",
88963 + .param3 = 1,
88964 +};
88965 +
88966 +struct size_overflow_hash _001136_hash = {
88967 + .next = NULL,
88968 + .name = "_req_append_segment",
88969 + .file = "drivers/scsi/osd/osd_initiator.c",
88970 + .param2 = 1,
88971 +};
88972 +
88973 +struct size_overflow_hash _001137_hash = {
88974 + .next = NULL,
88975 + .name = "retry_count_read",
88976 + .file = "drivers/net/wireless/wl1251/debugfs.c",
88977 + .param3 = 1,
88978 +};
88979 +
88980 +struct size_overflow_hash _001138_hash = {
88981 + .next = NULL,
88982 + .name = "revalidate",
88983 + .file = "drivers/block/aoe/aoechr.c",
88984 + .param2 = 1,
88985 +};
88986 +
88987 +struct size_overflow_hash _001139_hash = {
88988 + .next = NULL,
88989 + .name = "rfcomm_sock_setsockopt",
88990 + .file = "net/bluetooth/rfcomm/sock.c",
88991 + .param5 = 1,
88992 +};
88993 +
88994 +struct size_overflow_hash _001140_hash = {
88995 + .next = NULL,
88996 + .name = "rfkill_fop_read",
88997 + .file = "net/rfkill/core.c",
88998 + .param3 = 1,
88999 +};
89000 +
89001 +struct size_overflow_hash _001141_hash = {
89002 + .next = NULL,
89003 + .name = "rndis_add_response",
89004 + .file = "drivers/usb/gadget/rndis.c",
89005 + .param2 = 1,
89006 +};
89007 +
89008 +struct size_overflow_hash _001142_hash = {
89009 + .next = NULL,
89010 + .name = "rng_dev_read",
89011 + .file = "drivers/char/hw_random/core.c",
89012 + .param3 = 1,
89013 +};
89014 +
89015 +struct size_overflow_hash _001143_hash = {
89016 + .next = NULL,
89017 + .name = "roccat_common_receive",
89018 + .file = "drivers/hid/hid-roccat-common.c",
89019 + .param4 = 1,
89020 +};
89021 +
89022 +struct size_overflow_hash _001144_hash = {
89023 + .next = NULL,
89024 + .name = "roccat_common_send",
89025 + .file = "drivers/hid/hid-roccat-common.c",
89026 + .param4 = 1,
89027 +};
89028 +
89029 +struct size_overflow_hash _001145_hash = {
89030 + .next = NULL,
89031 + .name = "roccat_read",
89032 + .file = "drivers/hid/hid-roccat.c",
89033 + .param3 = 1,
89034 +};
89035 +
89036 +struct size_overflow_hash _001146_hash = {
89037 + .next = NULL,
89038 + .name = "rpc_malloc",
89039 + .file = "include/linux/sunrpc/sched.h",
89040 + .param2 = 1,
89041 +};
89042 +
89043 +struct size_overflow_hash _001147_hash = {
89044 + .next = NULL,
89045 + .name = "rs_sta_dbgfs_rate_scale_data_read",
89046 + .file = "drivers/net/wireless/iwlwifi/iwl-agn-rs.c",
89047 + .param3 = 1,
89048 +};
89049 +
89050 +struct size_overflow_hash _001148_hash = {
89051 + .next = NULL,
89052 + .name = "rs_sta_dbgfs_scale_table_read",
89053 + .file = "drivers/net/wireless/iwlwifi/iwl-agn-rs.c",
89054 + .param3 = 1,
89055 +};
89056 +
89057 +struct size_overflow_hash _001149_hash = {
89058 + .next = NULL,
89059 + .name = "rs_sta_dbgfs_stats_table_read",
89060 + .file = "drivers/net/wireless/iwlwifi/iwl-agn-rs.c",
89061 + .param3 = 1,
89062 +};
89063 +
89064 +struct size_overflow_hash _001150_hash = {
89065 + .next = NULL,
89066 + .name = "rt2x00debug_write_bbp",
89067 + .file = "drivers/net/wireless/rt2x00/rt2x00debug.c",
89068 + .param3 = 1,
89069 +};
89070 +
89071 +struct size_overflow_hash _001151_hash = {
89072 + .next = NULL,
89073 + .name = "rt2x00debug_write_csr",
89074 + .file = "drivers/net/wireless/rt2x00/rt2x00debug.c",
89075 + .param3 = 1,
89076 +};
89077 +
89078 +struct size_overflow_hash _001152_hash = {
89079 + .next = &_000808_hash,
89080 + .name = "rt2x00debug_write_eeprom",
89081 + .file = "drivers/net/wireless/rt2x00/rt2x00debug.c",
89082 + .param3 = 1,
89083 +};
89084 +
89085 +struct size_overflow_hash _001153_hash = {
89086 + .next = NULL,
89087 + .name = "rt2x00debug_write_rf",
89088 + .file = "drivers/net/wireless/rt2x00/rt2x00debug.c",
89089 + .param3 = 1,
89090 +};
89091 +
89092 +struct size_overflow_hash _001154_hash = {
89093 + .next = NULL,
89094 + .name = "rts51x_read_mem",
89095 + .file = "drivers/usb/storage/realtek_cr.c",
89096 + .param4 = 1,
89097 +};
89098 +
89099 +struct size_overflow_hash _001155_hash = {
89100 + .next = NULL,
89101 + .name = "rts51x_write_mem",
89102 + .file = "drivers/usb/storage/realtek_cr.c",
89103 + .param4 = 1,
89104 +};
89105 +
89106 +struct size_overflow_hash _001156_hash = {
89107 + .next = NULL,
89108 + .name = "rts_threshold_read",
89109 + .file = "net/wireless/debugfs.c",
89110 + .param3 = 1,
89111 +};
89112 +
89113 +struct size_overflow_hash _001157_hash = {
89114 + .next = NULL,
89115 + .name = "rx_dropped_read",
89116 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89117 + .param3 = 1,
89118 +};
89119 +
89120 +struct size_overflow_hash _001158_hash = {
89121 + .next = NULL,
89122 + .name = "rx_fcs_err_read",
89123 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89124 + .param3 = 1,
89125 +};
89126 +
89127 +struct size_overflow_hash _001159_hash = {
89128 + .next = NULL,
89129 + .name = "rx_hdr_overflow_read",
89130 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89131 + .param3 = 1,
89132 +};
89133 +
89134 +struct size_overflow_hash _001160_hash = {
89135 + .next = NULL,
89136 + .name = "rx_hw_stuck_read",
89137 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89138 + .param3 = 1,
89139 +};
89140 +
89141 +struct size_overflow_hash _001161_hash = {
89142 + .next = NULL,
89143 + .name = "rx_out_of_mem_read",
89144 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89145 + .param3 = 1,
89146 +};
89147 +
89148 +struct size_overflow_hash _001162_hash = {
89149 + .next = NULL,
89150 + .name = "rx_path_reset_read",
89151 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89152 + .param3 = 1,
89153 +};
89154 +
89155 +struct size_overflow_hash _001163_hash = {
89156 + .next = NULL,
89157 + .name = "rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read",
89158 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89159 + .param3 = 1,
89160 +};
89161 +
89162 +struct size_overflow_hash _001164_hash = {
89163 + .next = NULL,
89164 + .name = "rxpipe_descr_host_int_trig_rx_data_read",
89165 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89166 + .param3 = 1,
89167 +};
89168 +
89169 +struct size_overflow_hash _001165_hash = {
89170 + .next = NULL,
89171 + .name = "rxpipe_missed_beacon_host_int_trig_rx_data_read",
89172 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89173 + .param3 = 1,
89174 +};
89175 +
89176 +struct size_overflow_hash _001166_hash = {
89177 + .next = NULL,
89178 + .name = "rxpipe_rx_prep_beacon_drop_read",
89179 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89180 + .param3 = 1,
89181 +};
89182 +
89183 +struct size_overflow_hash _001167_hash = {
89184 + .next = NULL,
89185 + .name = "rxpipe_tx_xfr_host_int_trig_rx_data_read",
89186 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89187 + .param3 = 1,
89188 +};
89189 +
89190 +struct size_overflow_hash _001168_hash = {
89191 + .next = NULL,
89192 + .name = "rx_reset_counter_read",
89193 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89194 + .param3 = 1,
89195 +};
89196 +
89197 +struct size_overflow_hash _001169_hash = {
89198 + .next = NULL,
89199 + .name = "rx_xfr_hint_trig_read",
89200 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89201 + .param3 = 1,
89202 +};
89203 +
89204 +struct size_overflow_hash _001170_hash = {
89205 + .next = NULL,
89206 + .name = "saa7164_buffer_alloc_user",
89207 + .file = "drivers/media/video/saa7164/saa7164-buffer.c",
89208 + .param2 = 1,
89209 +};
89210 +
89211 +struct size_overflow_hash _001171_hash = {
89212 + .next = NULL,
89213 + .name = "scsi_execute",
89214 + .file = "include/scsi/scsi_device.h",
89215 + .param5 = 1,
89216 +};
89217 +
89218 +struct size_overflow_hash _001172_hash = {
89219 + .next = NULL,
89220 + .name = "scsi_tgt_copy_sense",
89221 + .file = "drivers/scsi/scsi_tgt_lib.c",
89222 + .param3 = 1,
89223 +};
89224 +
89225 +struct size_overflow_hash _001173_hash = {
89226 + .next = NULL,
89227 + .name = "sctp_auth_create_key",
89228 + .file = "net/sctp/auth.c",
89229 + .param1 = 1,
89230 +};
89231 +
89232 +struct size_overflow_hash _001174_hash = {
89233 + .next = NULL,
89234 + .name = "sctp_make_abort_user",
89235 + .file = "include/net/sctp/sm.h",
89236 + .param3 = 1,
89237 +};
89238 +
89239 +struct size_overflow_hash _001175_hash = {
89240 + .next = NULL,
89241 + .name = "sctpprobe_read",
89242 + .file = "net/sctp/probe.c",
89243 + .param3 = 1,
89244 +};
89245 +
89246 +struct size_overflow_hash _001176_hash = {
89247 + .next = NULL,
89248 + .name = "sctp_setsockopt_active_key",
89249 + .file = "net/sctp/socket.c",
89250 + .param3 = 1,
89251 +};
89252 +
89253 +struct size_overflow_hash _001177_hash = {
89254 + .next = NULL,
89255 + .name = "sctp_setsockopt_adaptation_layer",
89256 + .file = "net/sctp/socket.c",
89257 + .param3 = 1,
89258 +};
89259 +
89260 +struct size_overflow_hash _001178_hash = {
89261 + .next = NULL,
89262 + .name = "sctp_setsockopt_associnfo",
89263 + .file = "net/sctp/socket.c",
89264 + .param3 = 1,
89265 +};
89266 +
89267 +struct size_overflow_hash _001179_hash = {
89268 + .next = NULL,
89269 + .name = "sctp_setsockopt_auth_chunk",
89270 + .file = "net/sctp/socket.c",
89271 + .param3 = 1,
89272 +};
89273 +
89274 +struct size_overflow_hash _001180_hash = {
89275 + .next = NULL,
89276 + .name = "sctp_setsockopt_auth_key",
89277 + .file = "net/sctp/socket.c",
89278 + .param3 = 1,
89279 +};
89280 +
89281 +struct size_overflow_hash _001181_hash = {
89282 + .next = NULL,
89283 + .name = "sctp_setsockopt_autoclose",
89284 + .file = "net/sctp/socket.c",
89285 + .param3 = 1,
89286 +};
89287 +
89288 +struct size_overflow_hash _001182_hash = {
89289 + .next = NULL,
89290 + .name = "sctp_setsockopt_context",
89291 + .file = "net/sctp/socket.c",
89292 + .param3 = 1,
89293 +};
89294 +
89295 +struct size_overflow_hash _001183_hash = {
89296 + .next = NULL,
89297 + .name = "sctp_setsockopt_default_send_param",
89298 + .file = "net/sctp/socket.c",
89299 + .param3 = 1,
89300 +};
89301 +
89302 +struct size_overflow_hash _001184_hash = {
89303 + .next = NULL,
89304 + .name = "sctp_setsockopt_delayed_ack",
89305 + .file = "net/sctp/socket.c",
89306 + .param3 = 1,
89307 +};
89308 +
89309 +struct size_overflow_hash _001185_hash = {
89310 + .next = NULL,
89311 + .name = "sctp_setsockopt_del_key",
89312 + .file = "net/sctp/socket.c",
89313 + .param3 = 1,
89314 +};
89315 +
89316 +struct size_overflow_hash _001186_hash = {
89317 + .next = NULL,
89318 + .name = "sctp_setsockopt_events",
89319 + .file = "net/sctp/socket.c",
89320 + .param3 = 1,
89321 +};
89322 +
89323 +struct size_overflow_hash _001187_hash = {
89324 + .next = NULL,
89325 + .name = "sctp_setsockopt_hmac_ident",
89326 + .file = "net/sctp/socket.c",
89327 + .param3 = 1,
89328 +};
89329 +
89330 +struct size_overflow_hash _001188_hash = {
89331 + .next = NULL,
89332 + .name = "sctp_setsockopt_initmsg",
89333 + .file = "net/sctp/socket.c",
89334 + .param3 = 1,
89335 +};
89336 +
89337 +struct size_overflow_hash _001189_hash = {
89338 + .next = NULL,
89339 + .name = "sctp_setsockopt_maxburst",
89340 + .file = "net/sctp/socket.c",
89341 + .param3 = 1,
89342 +};
89343 +
89344 +struct size_overflow_hash _001190_hash = {
89345 + .next = NULL,
89346 + .name = "sctp_setsockopt_maxseg",
89347 + .file = "net/sctp/socket.c",
89348 + .param3 = 1,
89349 +};
89350 +
89351 +struct size_overflow_hash _001191_hash = {
89352 + .next = NULL,
89353 + .name = "sctp_setsockopt_peer_addr_params",
89354 + .file = "net/sctp/socket.c",
89355 + .param3 = 1,
89356 +};
89357 +
89358 +struct size_overflow_hash _001192_hash = {
89359 + .next = NULL,
89360 + .name = "sctp_setsockopt_peer_primary_addr",
89361 + .file = "net/sctp/socket.c",
89362 + .param3 = 1,
89363 +};
89364 +
89365 +struct size_overflow_hash _001193_hash = {
89366 + .next = NULL,
89367 + .name = "sctp_setsockopt_rtoinfo",
89368 + .file = "net/sctp/socket.c",
89369 + .param3 = 1,
89370 +};
89371 +
89372 +struct size_overflow_hash _001194_hash = {
89373 + .next = NULL,
89374 + .name = "sctp_tsnmap_init",
89375 + .file = "include/net/sctp/tsnmap.h",
89376 + .param2 = 1,
89377 +};
89378 +
89379 +struct size_overflow_hash _001195_hash = {
89380 + .next = NULL,
89381 + .name = "send_control_msg",
89382 + .file = "drivers/media/video/zr364xx.c",
89383 + .param6 = 1,
89384 +};
89385 +
89386 +struct size_overflow_hash _001196_hash = {
89387 + .next = NULL,
89388 + .name = "set_aoe_iflist",
89389 + .file = "drivers/block/aoe/aoenet.c",
89390 + .param2 = 1,
89391 +};
89392 +
89393 +struct size_overflow_hash _001197_hash = {
89394 + .next = NULL,
89395 + .name = "set_registers",
89396 + .file = "drivers/net/usb/pegasus.c",
89397 + .param3 = 1,
89398 +};
89399 +
89400 +struct size_overflow_hash _001198_hash = {
89401 + .next = NULL,
89402 + .name = "setsockopt",
89403 + .file = "net/caif/caif_socket.c",
89404 + .param5 = 1,
89405 +};
89406 +
89407 +struct size_overflow_hash _001199_hash = {
89408 + .next = NULL,
89409 + .name = "setup_req",
89410 + .file = "drivers/usb/gadget/inode.c",
89411 + .param3 = 1,
89412 +};
89413 +
89414 +struct size_overflow_hash _001200_hash = {
89415 + .next = NULL,
89416 + .name = "sfq_alloc",
89417 + .file = "net/sched/sch_sfq.c",
89418 + .param1 = 1,
89419 +};
89420 +
89421 +struct size_overflow_hash _001201_hash = {
89422 + .next = NULL,
89423 + .name = "sgl_map_user_pages",
89424 + .file = "drivers/scsi/st.c",
89425 + .param2 = 1,
89426 +};
89427 +
89428 +struct size_overflow_hash _001202_hash = {
89429 + .next = NULL,
89430 + .name = "short_retry_limit_read",
89431 + .file = "net/wireless/debugfs.c",
89432 + .param3 = 1,
89433 +};
89434 +
89435 +struct size_overflow_hash _001203_hash = {
89436 + .next = NULL,
89437 + .name = "sm501_create_subdev",
89438 + .file = "drivers/mfd/sm501.c",
89439 + .param3 = 1,
89440 + .param4 = 1,
89441 +};
89442 +
89443 +struct size_overflow_hash _001205_hash = {
89444 + .next = NULL,
89445 + .name = "sn9c102_read",
89446 + .file = "drivers/media/video/sn9c102/sn9c102_core.c",
89447 + .param3 = 1,
89448 +};
89449 +
89450 +struct size_overflow_hash _001206_hash = {
89451 + .next = NULL,
89452 + .name = "snd_ac97_pcm_assign",
89453 + .file = "include/sound/ac97_codec.h",
89454 + .param2 = 1,
89455 +};
89456 +
89457 +struct size_overflow_hash _001207_hash = {
89458 + .next = NULL,
89459 + .name = "snd_ctl_elem_user_tlv",
89460 + .file = "sound/core/control.c",
89461 + .param3 = 1,
89462 +};
89463 +
89464 +struct size_overflow_hash _001208_hash = {
89465 + .next = NULL,
89466 + .name = "snd_emu10k1_fx8010_read",
89467 + .file = "sound/pci/emu10k1/emuproc.c",
89468 + .param5 = 1,
89469 +};
89470 +
89471 +struct size_overflow_hash _001209_hash = {
89472 + .next = NULL,
89473 + .name = "snd_es1938_capture_copy",
89474 + .file = "sound/pci/es1938.c",
89475 + .param5 = 1,
89476 +};
89477 +
89478 +struct size_overflow_hash _001210_hash = {
89479 + .next = NULL,
89480 + .name = "snd_gus_dram_peek",
89481 + .file = "sound/isa/gus/gus_dram.c",
89482 + .param4 = 1,
89483 +};
89484 +
89485 +struct size_overflow_hash _001211_hash = {
89486 + .next = NULL,
89487 + .name = "snd_gus_dram_poke",
89488 + .file = "sound/isa/gus/gus_dram.c",
89489 + .param4 = 1,
89490 +};
89491 +
89492 +struct size_overflow_hash _001212_hash = {
89493 + .next = NULL,
89494 + .name = "snd_hdsp_capture_copy",
89495 + .file = "sound/pci/rme9652/hdsp.c",
89496 + .param5 = 1,
89497 +};
89498 +
89499 +struct size_overflow_hash _001213_hash = {
89500 + .next = NULL,
89501 + .name = "snd_hdsp_playback_copy",
89502 + .file = "sound/pci/rme9652/hdsp.c",
89503 + .param5 = 1,
89504 +};
89505 +
89506 +struct size_overflow_hash _001214_hash = {
89507 + .next = NULL,
89508 + .name = "snd_info_entry_write",
89509 + .file = "sound/core/info.c",
89510 + .param3 = 1,
89511 +};
89512 +
89513 +struct size_overflow_hash _001215_hash = {
89514 + .next = NULL,
89515 + .name = "snd_opl4_mem_proc_read",
89516 + .file = "sound/drivers/opl4/opl4_proc.c",
89517 + .param5 = 1,
89518 +};
89519 +
89520 +struct size_overflow_hash _001216_hash = {
89521 + .next = NULL,
89522 + .name = "snd_opl4_mem_proc_write",
89523 + .file = "sound/drivers/opl4/opl4_proc.c",
89524 + .param5 = 1,
89525 +};
89526 +
89527 +struct size_overflow_hash _001217_hash = {
89528 + .next = NULL,
89529 + .name = "snd_pcm_aio_read",
89530 + .file = "sound/core/pcm_native.c",
89531 + .param3 = 1,
89532 +};
89533 +
89534 +struct size_overflow_hash _001218_hash = {
89535 + .next = NULL,
89536 + .name = "snd_pcm_aio_write",
89537 + .file = "sound/core/pcm_native.c",
89538 + .param3 = 1,
89539 +};
89540 +
89541 +struct size_overflow_hash _001219_hash = {
89542 + .next = NULL,
89543 + .name = "snd_pcm_alloc_vmalloc_buffer",
89544 + .file = "drivers/media/video/cx231xx/cx231xx-audio.c",
89545 + .param2 = 1,
89546 +};
89547 +
89548 +struct size_overflow_hash _001220_hash = {
89549 + .next = NULL,
89550 + .name = "snd_pcm_alloc_vmalloc_buffer",
89551 + .file = "drivers/media/video/cx18/cx18-alsa-pcm.c",
89552 + .param2 = 1,
89553 +};
89554 +
89555 +struct size_overflow_hash _001221_hash = {
89556 + .next = NULL,
89557 + .name = "snd_pcm_alloc_vmalloc_buffer",
89558 + .file = "drivers/media/video/em28xx/em28xx-audio.c",
89559 + .param2 = 1,
89560 +};
89561 +
89562 +struct size_overflow_hash _001222_hash = {
89563 + .next = NULL,
89564 + .name = "_snd_pcm_lib_alloc_vmalloc_buffer",
89565 + .file = "include/sound/pcm.h",
89566 + .param2 = 1,
89567 +};
89568 +
89569 +struct size_overflow_hash _001223_hash = {
89570 + .next = NULL,
89571 + .name = "snd_pcm_oss_read1",
89572 + .file = "sound/core/oss/pcm_oss.c",
89573 + .param3 = 1,
89574 +};
89575 +
89576 +struct size_overflow_hash _001224_hash = {
89577 + .next = NULL,
89578 + .name = "snd_pcm_oss_write1",
89579 + .file = "sound/core/oss/pcm_oss.c",
89580 + .param3 = 1,
89581 +};
89582 +
89583 +struct size_overflow_hash _001225_hash = {
89584 + .next = NULL,
89585 + .name = "snd_pcm_oss_write2",
89586 + .file = "sound/core/oss/pcm_oss.c",
89587 + .param3 = 1,
89588 +};
89589 +
89590 +struct size_overflow_hash _001226_hash = {
89591 + .next = NULL,
89592 + .name = "snd_pcm_plugin_build",
89593 + .file = "sound/core/oss/pcm_plugin.c",
89594 + .param5 = 1,
89595 +};
89596 +
89597 +struct size_overflow_hash _001227_hash = {
89598 + .next = NULL,
89599 + .name = "snd_rme9652_capture_copy",
89600 + .file = "sound/pci/rme9652/rme9652.c",
89601 + .param5 = 1,
89602 +};
89603 +
89604 +struct size_overflow_hash _001228_hash = {
89605 + .next = NULL,
89606 + .name = "snd_rme9652_playback_copy",
89607 + .file = "sound/pci/rme9652/rme9652.c",
89608 + .param5 = 1,
89609 +};
89610 +
89611 +struct size_overflow_hash _001229_hash = {
89612 + .next = NULL,
89613 + .name = "snd_soc_hw_bulk_write_raw",
89614 + .file = "sound/soc/soc-io.c",
89615 + .param4 = 1,
89616 +};
89617 +
89618 +struct size_overflow_hash _001230_hash = {
89619 + .next = NULL,
89620 + .name = "snd_usb_ctl_msg",
89621 + .file = "sound/usb/helper.c",
89622 + .param8 = 1,
89623 +};
89624 +
89625 +struct size_overflow_hash _001231_hash = {
89626 + .next = NULL,
89627 + .name = "_sp2d_alloc",
89628 + .file = "fs/exofs/ore_raid.c",
89629 + .param1 = 1,
89630 +};
89631 +
89632 +struct size_overflow_hash _001232_hash = {
89633 + .next = NULL,
89634 + .name = "spidev_message",
89635 + .file = "drivers/spi/spidev.c",
89636 + .param3 = 1,
89637 +};
89638 +
89639 +struct size_overflow_hash _001233_hash = {
89640 + .next = NULL,
89641 + .name = "spidev_write",
89642 + .file = "drivers/spi/spidev.c",
89643 + .param3 = 1,
89644 +};
89645 +
89646 +struct size_overflow_hash _001234_hash = {
89647 + .next = NULL,
89648 + .name = "spi_show_regs",
89649 + .file = "drivers/spi/spi-dw.c",
89650 + .param3 = 1,
89651 +};
89652 +
89653 +struct size_overflow_hash _001235_hash = {
89654 + .next = NULL,
89655 + .name = "srp_alloc_iu",
89656 + .file = "drivers/infiniband/ulp/srp/ib_srp.c",
89657 + .param2 = 1,
89658 +};
89659 +
89660 +struct size_overflow_hash _001236_hash = {
89661 + .next = NULL,
89662 + .name = "srp_iu_pool_alloc",
89663 + .file = "drivers/scsi/libsrp.c",
89664 + .param2 = 1,
89665 +};
89666 +
89667 +struct size_overflow_hash _001237_hash = {
89668 + .next = NULL,
89669 + .name = "srp_ring_alloc",
89670 + .file = "drivers/scsi/libsrp.c",
89671 + .param2 = 1,
89672 +};
89673 +
89674 +struct size_overflow_hash _001238_hash = {
89675 + .next = NULL,
89676 + .name = "sta_agg_status_read",
89677 + .file = "net/mac80211/debugfs_sta.c",
89678 + .param3 = 1,
89679 +};
89680 +
89681 +struct size_overflow_hash _001239_hash = {
89682 + .next = NULL,
89683 + .name = "sta_agg_status_write",
89684 + .file = "net/mac80211/debugfs_sta.c",
89685 + .param3 = 1,
89686 +};
89687 +
89688 +struct size_overflow_hash _001240_hash = {
89689 + .next = NULL,
89690 + .name = "sta_connected_time_read",
89691 + .file = "net/mac80211/debugfs_sta.c",
89692 + .param3 = 1,
89693 +};
89694 +
89695 +struct size_overflow_hash _001241_hash = {
89696 + .next = NULL,
89697 + .name = "sta_flags_read",
89698 + .file = "net/mac80211/debugfs_sta.c",
89699 + .param3 = 1,
89700 +};
89701 +
89702 +struct size_overflow_hash _001242_hash = {
89703 + .next = NULL,
89704 + .name = "sta_ht_capa_read",
89705 + .file = "net/mac80211/debugfs_sta.c",
89706 + .param3 = 1,
89707 +};
89708 +
89709 +struct size_overflow_hash _001243_hash = {
89710 + .next = NULL,
89711 + .name = "sta_last_seq_ctrl_read",
89712 + .file = "net/mac80211/debugfs_sta.c",
89713 + .param3 = 1,
89714 +};
89715 +
89716 +struct size_overflow_hash _001244_hash = {
89717 + .next = NULL,
89718 + .name = "sta_num_ps_buf_frames_read",
89719 + .file = "net/mac80211/debugfs_sta.c",
89720 + .param3 = 1,
89721 +};
89722 +
89723 +struct size_overflow_hash _001245_hash = {
89724 + .next = NULL,
89725 + .name = "stk_prepare_sio_buffers",
89726 + .file = "drivers/media/video/stk-webcam.c",
89727 + .param2 = 1,
89728 +};
89729 +
89730 +struct size_overflow_hash _001246_hash = {
89731 + .next = NULL,
89732 + .name = "store_iwmct_log_level",
89733 + .file = "drivers/misc/iwmc3200top/log.c",
89734 + .param4 = 1,
89735 +};
89736 +
89737 +struct size_overflow_hash _001247_hash = {
89738 + .next = NULL,
89739 + .name = "store_iwmct_log_level_fw",
89740 + .file = "drivers/misc/iwmc3200top/log.c",
89741 + .param4 = 1,
89742 +};
89743 +
89744 +struct size_overflow_hash _001248_hash = {
89745 + .next = NULL,
89746 + .name = "str_to_user",
89747 + .file = "drivers/input/evdev.c",
89748 + .param2 = 1,
89749 +};
89750 +
89751 +struct size_overflow_hash _001249_hash = {
89752 + .next = NULL,
89753 + .name = "svc_pool_map_alloc_arrays",
89754 + .file = "net/sunrpc/svc.c",
89755 + .param2 = 1,
89756 +};
89757 +
89758 +struct size_overflow_hash _001250_hash = {
89759 + .next = NULL,
89760 + .name = "svc_setsockopt",
89761 + .file = "net/atm/svc.c",
89762 + .param5 = 1,
89763 +};
89764 +
89765 +struct size_overflow_hash _001251_hash = {
89766 + .next = NULL,
89767 + .name = "t4_alloc_mem",
89768 + .file = "drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c",
89769 + .param1 = 1,
89770 +};
89771 +
89772 +struct size_overflow_hash _001252_hash = {
89773 + .next = NULL,
89774 + .name = "tda10048_writeregbulk",
89775 + .file = "drivers/media/dvb/frontends/tda10048.c",
89776 + .param4 = 1,
89777 +};
89778 +
89779 +struct size_overflow_hash _001253_hash = {
89780 + .next = NULL,
89781 + .name = "__team_options_register",
89782 + .file = "drivers/net/team/team.c",
89783 + .param3 = 1,
89784 +};
89785 +
89786 +struct size_overflow_hash _001254_hash = {
89787 + .next = NULL,
89788 + .name = "tifm_alloc_adapter",
89789 + .file = "include/linux/tifm.h",
89790 + .param1 = 1,
89791 +};
89792 +
89793 +struct size_overflow_hash _001255_hash = {
89794 + .next = NULL,
89795 + .name = "tipc_subseq_alloc",
89796 + .file = "net/tipc/name_table.c",
89797 + .param1 = 1,
89798 +};
89799 +
89800 +struct size_overflow_hash _001256_hash = {
89801 + .next = NULL,
89802 + .name = "tm6000_read_write_usb",
89803 + .file = "drivers/media/video/tm6000/tm6000-core.c",
89804 + .param7 = 1,
89805 +};
89806 +
89807 +struct size_overflow_hash _001257_hash = {
89808 + .next = NULL,
89809 + .name = "tower_write",
89810 + .file = "drivers/usb/misc/legousbtower.c",
89811 + .param3 = 1,
89812 +};
89813 +
89814 +struct size_overflow_hash _001258_hash = {
89815 + .next = NULL,
89816 + .name = "trusted_instantiate",
89817 + .file = "security/keys/trusted.c",
89818 + .param3 = 1,
89819 +};
89820 +
89821 +struct size_overflow_hash _001259_hash = {
89822 + .next = NULL,
89823 + .name = "trusted_update",
89824 + .file = "security/keys/trusted.c",
89825 + .param3 = 1,
89826 +};
89827 +
89828 +struct size_overflow_hash _001260_hash = {
89829 + .next = NULL,
89830 + .name = "TSS_rawhmac",
89831 + .file = "security/keys/trusted.c",
89832 + .param3 = 1,
89833 +};
89834 +
89835 +struct size_overflow_hash _001261_hash = {
89836 + .next = NULL,
89837 + .name = "tx_internal_desc_overflow_read",
89838 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89839 + .param3 = 1,
89840 +};
89841 +
89842 +struct size_overflow_hash _001262_hash = {
89843 + .next = NULL,
89844 + .name = "tx_queue_len_read",
89845 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89846 + .param3 = 1,
89847 +};
89848 +
89849 +struct size_overflow_hash _001263_hash = {
89850 + .next = NULL,
89851 + .name = "tx_queue_len_read",
89852 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
89853 + .param3 = 1,
89854 +};
89855 +
89856 +struct size_overflow_hash _001264_hash = {
89857 + .next = NULL,
89858 + .name = "tx_queue_status_read",
89859 + .file = "drivers/net/wireless/wl1251/debugfs.c",
89860 + .param3 = 1,
89861 +};
89862 +
89863 +struct size_overflow_hash _001265_hash = {
89864 + .next = NULL,
89865 + .name = "udf_alloc_i_data",
89866 + .file = "fs/udf/inode.c",
89867 + .param2 = 1,
89868 +};
89869 +
89870 +struct size_overflow_hash _001266_hash = {
89871 + .next = NULL,
89872 + .name = "udf_sb_alloc_partition_maps",
89873 + .file = "fs/udf/super.c",
89874 + .param2 = 1,
89875 +};
89876 +
89877 +struct size_overflow_hash _001267_hash = {
89878 + .next = NULL,
89879 + .name = "uea_idma_write",
89880 + .file = "drivers/usb/atm/ueagle-atm.c",
89881 + .param3 = 1,
89882 +};
89883 +
89884 +struct size_overflow_hash _001268_hash = {
89885 + .next = NULL,
89886 + .name = "uea_request",
89887 + .file = "drivers/usb/atm/ueagle-atm.c",
89888 + .param4 = 1,
89889 +};
89890 +
89891 +struct size_overflow_hash _001269_hash = {
89892 + .next = NULL,
89893 + .name = "uea_send_modem_cmd",
89894 + .file = "drivers/usb/atm/ueagle-atm.c",
89895 + .param3 = 1,
89896 +};
89897 +
89898 +struct size_overflow_hash _001270_hash = {
89899 + .next = NULL,
89900 + .name = "uhci_debug_read",
89901 + .file = "drivers/usb/host/uhci-debug.c",
89902 + .param3 = 1,
89903 +};
89904 +
89905 +struct size_overflow_hash _001271_hash = {
89906 + .next = NULL,
89907 + .name = "uio_read",
89908 + .file = "drivers/uio/uio.c",
89909 + .param3 = 1,
89910 +};
89911 +
89912 +struct size_overflow_hash _001272_hash = {
89913 + .next = NULL,
89914 + .name = "uio_write",
89915 + .file = "drivers/uio/uio.c",
89916 + .param3 = 1,
89917 +};
89918 +
89919 +struct size_overflow_hash _001273_hash = {
89920 + .next = NULL,
89921 + .name = "um_idi_write",
89922 + .file = "drivers/isdn/hardware/eicon/divasi.c",
89923 + .param3 = 1,
89924 +};
89925 +
89926 +struct size_overflow_hash _001274_hash = {
89927 + .next = NULL,
89928 + .name = "unlink_queued",
89929 + .file = "drivers/usb/misc/usbtest.c",
89930 + .param3 = 1,
89931 + .param4 = 1,
89932 +};
89933 +
89934 +struct size_overflow_hash _001275_hash = {
89935 + .next = NULL,
89936 + .name = "us122l_ctl_msg",
89937 + .file = "sound/usb/usx2y/us122l.c",
89938 + .param8 = 1,
89939 +};
89940 +
89941 +struct size_overflow_hash _001276_hash = {
89942 + .next = NULL,
89943 + .name = "usbdev_read",
89944 + .file = "drivers/usb/core/devio.c",
89945 + .param3 = 1,
89946 +};
89947 +
89948 +struct size_overflow_hash _001277_hash = {
89949 + .next = NULL,
89950 + .name = "usblp_read",
89951 + .file = "drivers/usb/class/usblp.c",
89952 + .param3 = 1,
89953 +};
89954 +
89955 +struct size_overflow_hash _001278_hash = {
89956 + .next = NULL,
89957 + .name = "usblp_write",
89958 + .file = "drivers/usb/class/usblp.c",
89959 + .param3 = 1,
89960 +};
89961 +
89962 +struct size_overflow_hash _001279_hash = {
89963 + .next = NULL,
89964 + .name = "usbtest_alloc_urb",
89965 + .file = "drivers/usb/misc/usbtest.c",
89966 + .param3 = 1,
89967 + .param5 = 1,
89968 +};
89969 +
89970 +struct size_overflow_hash _001281_hash = {
89971 + .next = NULL,
89972 + .name = "usbtmc_read",
89973 + .file = "drivers/usb/class/usbtmc.c",
89974 + .param3 = 1,
89975 +};
89976 +
89977 +struct size_overflow_hash _001282_hash = {
89978 + .next = NULL,
89979 + .name = "usbtmc_write",
89980 + .file = "drivers/usb/class/usbtmc.c",
89981 + .param3 = 1,
89982 +};
89983 +
89984 +struct size_overflow_hash _001283_hash = {
89985 + .next = NULL,
89986 + .name = "usbvision_v4l2_read",
89987 + .file = "drivers/media/video/usbvision/usbvision-video.c",
89988 + .param3 = 1,
89989 +};
89990 +
89991 +struct size_overflow_hash _001284_hash = {
89992 + .next = NULL,
89993 + .name = "uvc_alloc_buffers",
89994 + .file = "drivers/usb/gadget/uvc_queue.c",
89995 + .param2 = 1,
89996 +};
89997 +
89998 +struct size_overflow_hash _001285_hash = {
89999 + .next = NULL,
90000 + .name = "uvc_alloc_entity",
90001 + .file = "drivers/media/video/uvc/uvc_driver.c",
90002 + .param3 = 1,
90003 +};
90004 +
90005 +struct size_overflow_hash _001286_hash = {
90006 + .next = NULL,
90007 + .name = "uvc_debugfs_stats_read",
90008 + .file = "drivers/media/video/uvc/uvc_debugfs.c",
90009 + .param3 = 1,
90010 +};
90011 +
90012 +struct size_overflow_hash _001287_hash = {
90013 + .next = NULL,
90014 + .name = "uvc_simplify_fraction",
90015 + .file = "drivers/media/video/uvc/uvc_driver.c",
90016 + .param3 = 1,
90017 +};
90018 +
90019 +struct size_overflow_hash _001288_hash = {
90020 + .next = NULL,
90021 + .name = "uwb_rc_neh_grok_event",
90022 + .file = "drivers/uwb/neh.c",
90023 + .param3 = 1,
90024 +};
90025 +
90026 +struct size_overflow_hash _001289_hash = {
90027 + .next = NULL,
90028 + .name = "v4l2_event_subscribe",
90029 + .file = "include/media/v4l2-event.h",
90030 + .param3 = 1,
90031 +};
90032 +
90033 +struct size_overflow_hash _001290_hash = {
90034 + .next = NULL,
90035 + .name = "v4l_stk_read",
90036 + .file = "drivers/media/video/stk-webcam.c",
90037 + .param3 = 1,
90038 +};
90039 +
90040 +struct size_overflow_hash _001291_hash = {
90041 + .next = NULL,
90042 + .name = "__vb2_perform_fileio",
90043 + .file = "drivers/media/video/videobuf2-core.c",
90044 + .param3 = 1,
90045 +};
90046 +
90047 +struct size_overflow_hash _001292_hash = {
90048 + .next = NULL,
90049 + .name = "vdma_mem_alloc",
90050 + .file = "arch/x86/include/asm/floppy.h",
90051 + .param1 = 1,
90052 +};
90053 +
90054 +struct size_overflow_hash _001293_hash = {
90055 + .next = NULL,
90056 + .name = "vfd_write",
90057 + .file = "drivers/media/rc/imon.c",
90058 + .param3 = 1,
90059 +};
90060 +
90061 +struct size_overflow_hash _001294_hash = {
90062 + .next = NULL,
90063 + .name = "vhci_get_user",
90064 + .file = "drivers/bluetooth/hci_vhci.c",
90065 + .param3 = 1,
90066 +};
90067 +
90068 +struct size_overflow_hash _001295_hash = {
90069 + .next = NULL,
90070 + .name = "__vhost_add_used_n",
90071 + .file = "drivers/vhost/vhost.c",
90072 + .param3 = 1,
90073 +};
90074 +
90075 +struct size_overflow_hash _001296_hash = {
90076 + .next = NULL,
90077 + .name = "__videobuf_alloc_vb",
90078 + .file = "drivers/media/video/videobuf-dma-sg.c",
90079 + .param1 = 1,
90080 +};
90081 +
90082 +struct size_overflow_hash _001297_hash = {
90083 + .next = NULL,
90084 + .name = "__videobuf_alloc_vb",
90085 + .file = "drivers/media/video/videobuf-dma-contig.c",
90086 + .param1 = 1,
90087 +};
90088 +
90089 +struct size_overflow_hash _001298_hash = {
90090 + .next = NULL,
90091 + .name = "__videobuf_alloc_vb",
90092 + .file = "drivers/media/video/videobuf-vmalloc.c",
90093 + .param1 = 1,
90094 +};
90095 +
90096 +struct size_overflow_hash _001299_hash = {
90097 + .next = NULL,
90098 + .name = "__videobuf_copy_to_user",
90099 + .file = "drivers/media/video/videobuf-core.c",
90100 + .param4 = 1,
90101 +};
90102 +
90103 +struct size_overflow_hash _001300_hash = {
90104 + .next = NULL,
90105 + .name = "video_proc_write",
90106 + .file = "drivers/platform/x86/toshiba_acpi.c",
90107 + .param3 = 1,
90108 +};
90109 +
90110 +struct size_overflow_hash _001301_hash = {
90111 + .next = NULL,
90112 + .name = "vifs_state_read",
90113 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90114 + .param3 = 1,
90115 +};
90116 +
90117 +struct size_overflow_hash _001302_hash = {
90118 + .next = NULL,
90119 + .name = "vlsi_alloc_ring",
90120 + .file = "drivers/net/irda/vlsi_ir.c",
90121 + .param3 = 1,
90122 + .param4 = 1,
90123 +};
90124 +
90125 +struct size_overflow_hash _001304_hash = {
90126 + .next = NULL,
90127 + .name = "vol_cdev_direct_write",
90128 + .file = "drivers/mtd/ubi/cdev.c",
90129 + .param3 = 1,
90130 +};
90131 +
90132 +struct size_overflow_hash _001305_hash = {
90133 + .next = NULL,
90134 + .name = "vol_cdev_read",
90135 + .file = "drivers/mtd/ubi/cdev.c",
90136 + .param3 = 1,
90137 +};
90138 +
90139 +struct size_overflow_hash _001306_hash = {
90140 + .next = NULL,
90141 + .name = "vring_add_indirect",
90142 + .file = "drivers/virtio/virtio_ring.c",
90143 + .param3 = 1,
90144 + .param4 = 1,
90145 +};
90146 +
90147 +struct size_overflow_hash _001308_hash = {
90148 + .next = NULL,
90149 + .name = "vring_new_virtqueue",
90150 + .file = "include/linux/virtio_ring.h",
90151 + .param1 = 1,
90152 +};
90153 +
90154 +struct size_overflow_hash _001309_hash = {
90155 + .next = NULL,
90156 + .name = "__vxge_hw_channel_allocate",
90157 + .file = "drivers/net/ethernet/neterion/vxge/vxge-config.c",
90158 + .param3 = 1,
90159 +};
90160 +
90161 +struct size_overflow_hash _001310_hash = {
90162 + .next = NULL,
90163 + .name = "vxge_os_dma_malloc",
90164 + .file = "drivers/net/ethernet/neterion/vxge/vxge-config.h",
90165 + .param2 = 1,
90166 +};
90167 +
90168 +struct size_overflow_hash _001311_hash = {
90169 + .next = NULL,
90170 + .name = "vxge_os_dma_malloc_async",
90171 + .file = "drivers/net/ethernet/neterion/vxge/vxge-config.c",
90172 + .param3 = 1,
90173 +};
90174 +
90175 +struct size_overflow_hash _001312_hash = {
90176 + .next = NULL,
90177 + .name = "w9966_v4l_read",
90178 + .file = "drivers/media/video/w9966.c",
90179 + .param3 = 1,
90180 +};
90181 +
90182 +struct size_overflow_hash _001313_hash = {
90183 + .next = NULL,
90184 + .name = "waiters_read",
90185 + .file = "fs/dlm/debug_fs.c",
90186 + .param3 = 1,
90187 +};
90188 +
90189 +struct size_overflow_hash _001314_hash = {
90190 + .next = NULL,
90191 + .name = "wa_nep_queue",
90192 + .file = "drivers/usb/wusbcore/wa-nep.c",
90193 + .param2 = 1,
90194 +};
90195 +
90196 +struct size_overflow_hash _001315_hash = {
90197 + .next = NULL,
90198 + .name = "__wa_xfer_setup_segs",
90199 + .file = "drivers/usb/wusbcore/wa-xfer.c",
90200 + .param2 = 1,
90201 +};
90202 +
90203 +struct size_overflow_hash _001316_hash = {
90204 + .next = NULL,
90205 + .name = "wdm_read",
90206 + .file = "drivers/usb/class/cdc-wdm.c",
90207 + .param3 = 1,
90208 +};
90209 +
90210 +struct size_overflow_hash _001317_hash = {
90211 + .next = NULL,
90212 + .name = "wdm_write",
90213 + .file = "drivers/usb/class/cdc-wdm.c",
90214 + .param3 = 1,
90215 +};
90216 +
90217 +struct size_overflow_hash _001318_hash = {
90218 + .next = NULL,
90219 + .name = "wep_addr_key_count_read",
90220 + .file = "drivers/net/wireless/wl1251/debugfs.c",
90221 + .param3 = 1,
90222 +};
90223 +
90224 +struct size_overflow_hash _001319_hash = {
90225 + .next = &_000480_hash,
90226 + .name = "wep_decrypt_fail_read",
90227 + .file = "drivers/net/wireless/wl1251/debugfs.c",
90228 + .param3 = 1,
90229 +};
90230 +
90231 +struct size_overflow_hash _001320_hash = {
90232 + .next = NULL,
90233 + .name = "wep_default_key_count_read",
90234 + .file = "drivers/net/wireless/wl1251/debugfs.c",
90235 + .param3 = 1,
90236 +};
90237 +
90238 +struct size_overflow_hash _001321_hash = {
90239 + .next = NULL,
90240 + .name = "wep_interrupt_read",
90241 + .file = "drivers/net/wireless/wl1251/debugfs.c",
90242 + .param3 = 1,
90243 +};
90244 +
90245 +struct size_overflow_hash _001322_hash = {
90246 + .next = NULL,
90247 + .name = "wep_key_not_found_read",
90248 + .file = "drivers/net/wireless/wl1251/debugfs.c",
90249 + .param3 = 1,
90250 +};
90251 +
90252 +struct size_overflow_hash _001323_hash = {
90253 + .next = NULL,
90254 + .name = "wep_packets_read",
90255 + .file = "drivers/net/wireless/wl1251/debugfs.c",
90256 + .param3 = 1,
90257 +};
90258 +
90259 +struct size_overflow_hash _001324_hash = {
90260 + .next = NULL,
90261 + .name = "wiimote_hid_send",
90262 + .file = "drivers/hid/hid-wiimote-core.c",
90263 + .param3 = 1,
90264 +};
90265 +
90266 +struct size_overflow_hash _001325_hash = {
90267 + .next = NULL,
90268 + .name = "wl1271_format_buffer",
90269 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90270 + .param2 = 1,
90271 +};
90272 +
90273 +struct size_overflow_hash _001326_hash = {
90274 + .next = NULL,
90275 + .name = "wl1273_fm_fops_write",
90276 + .file = "drivers/media/radio/radio-wl1273.c",
90277 + .param3 = 1,
90278 +};
90279 +
90280 +struct size_overflow_hash _001327_hash = {
90281 + .next = NULL,
90282 + .name = "wlc_phy_loadsampletable_nphy",
90283 + .file = "drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c",
90284 + .param3 = 1,
90285 +};
90286 +
90287 +struct size_overflow_hash _001328_hash = {
90288 + .next = NULL,
90289 + .name = "wpan_phy_alloc",
90290 + .file = "include/net/wpan-phy.h",
90291 + .param1 = 1,
90292 +};
90293 +
90294 +struct size_overflow_hash _001329_hash = {
90295 + .next = NULL,
90296 + .name = "write_flush",
90297 + .file = "net/sunrpc/cache.c",
90298 + .param3 = 1,
90299 +};
90300 +
90301 +struct size_overflow_hash _001330_hash = {
90302 + .next = NULL,
90303 + .name = "write_rio",
90304 + .file = "drivers/usb/misc/rio500.c",
90305 + .param3 = 1,
90306 +};
90307 +
90308 +struct size_overflow_hash _001331_hash = {
90309 + .next = NULL,
90310 + .name = "wusb_ccm_mac",
90311 + .file = "drivers/usb/wusbcore/crypto.c",
90312 + .param7 = 1,
90313 +};
90314 +
90315 +struct size_overflow_hash _001332_hash = {
90316 + .next = NULL,
90317 + .name = "xfs_attrmulti_attr_set",
90318 + .file = "fs/xfs/xfs_ioctl.c",
90319 + .param4 = 1,
90320 +};
90321 +
90322 +struct size_overflow_hash _001333_hash = {
90323 + .next = NULL,
90324 + .name = "xfs_handle_to_dentry",
90325 + .file = "fs/xfs/xfs_ioctl.c",
90326 + .param3 = 1,
90327 +};
90328 +
90329 +struct size_overflow_hash _001334_hash = {
90330 + .next = NULL,
90331 + .name = "xhci_alloc_stream_info",
90332 + .file = "drivers/usb/host/xhci-mem.c",
90333 + .param3 = 1,
90334 +};
90335 +
90336 +struct size_overflow_hash _001335_hash = {
90337 + .next = NULL,
90338 + .name = "xprt_alloc",
90339 + .file = "include/linux/sunrpc/xprt.h",
90340 + .param2 = 1,
90341 +};
90342 +
90343 +struct size_overflow_hash _001336_hash = {
90344 + .next = NULL,
90345 + .name = "xprt_rdma_allocate",
90346 + .file = "net/sunrpc/xprtrdma/transport.c",
90347 + .param2 = 1,
90348 +};
90349 +
90350 +struct size_overflow_hash _001337_hash = {
90351 + .next = NULL,
90352 + .name = "xt_alloc_table_info",
90353 + .file = "include/linux/netfilter/x_tables.h",
90354 + .param1 = 1,
90355 +};
90356 +
90357 +struct size_overflow_hash _001338_hash = {
90358 + .next = NULL,
90359 + .name = "zd_usb_iowrite16v_async",
90360 + .file = "drivers/net/wireless/zd1211rw/zd_usb.c",
90361 + .param3 = 1,
90362 +};
90363 +
90364 +struct size_overflow_hash _001339_hash = {
90365 + .next = NULL,
90366 + .name = "zd_usb_read_fw",
90367 + .file = "drivers/net/wireless/zd1211rw/zd_usb.c",
90368 + .param4 = 1,
90369 +};
90370 +
90371 +struct size_overflow_hash _001340_hash = {
90372 + .next = NULL,
90373 + .name = "zoran_write",
90374 + .file = "drivers/media/video/zoran/zoran_procfs.c",
90375 + .param3 = 1,
90376 +};
90377 +
90378 +struct size_overflow_hash _001341_hash = {
90379 + .next = NULL,
90380 + .name = "ad7879_spi_multi_read",
90381 + .file = "drivers/input/touchscreen/ad7879-spi.c",
90382 + .param3 = 1,
90383 +};
90384 +
90385 +struct size_overflow_hash _001342_hash = {
90386 + .next = NULL,
90387 + .name = "aes_decrypt_fail_read",
90388 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90389 + .param3 = 1,
90390 +};
90391 +
90392 +struct size_overflow_hash _001343_hash = {
90393 + .next = NULL,
90394 + .name = "aes_decrypt_interrupt_read",
90395 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90396 + .param3 = 1,
90397 +};
90398 +
90399 +struct size_overflow_hash _001344_hash = {
90400 + .next = NULL,
90401 + .name = "aes_decrypt_packets_read",
90402 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90403 + .param3 = 1,
90404 +};
90405 +
90406 +struct size_overflow_hash _001345_hash = {
90407 + .next = NULL,
90408 + .name = "aes_encrypt_fail_read",
90409 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90410 + .param3 = 1,
90411 +};
90412 +
90413 +struct size_overflow_hash _001346_hash = {
90414 + .next = NULL,
90415 + .name = "aes_encrypt_interrupt_read",
90416 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90417 + .param3 = 1,
90418 +};
90419 +
90420 +struct size_overflow_hash _001347_hash = {
90421 + .next = NULL,
90422 + .name = "aes_encrypt_packets_read",
90423 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90424 + .param3 = 1,
90425 +};
90426 +
90427 +struct size_overflow_hash _001348_hash = {
90428 + .next = NULL,
90429 + .name = "afs_cell_create",
90430 + .file = "fs/afs/cell.c",
90431 + .param2 = 1,
90432 +};
90433 +
90434 +struct size_overflow_hash _001349_hash = {
90435 + .next = NULL,
90436 + .name = "agp_create_user_memory",
90437 + .file = "drivers/char/agp/generic.c",
90438 + .param1 = 1,
90439 +};
90440 +
90441 +struct size_overflow_hash _001350_hash = {
90442 + .next = NULL,
90443 + .name = "alg_setsockopt",
90444 + .file = "crypto/af_alg.c",
90445 + .param5 = 1,
90446 +};
90447 +
90448 +struct size_overflow_hash _001351_hash = {
90449 + .next = NULL,
90450 + .name = "alloc_targets",
90451 + .file = "drivers/md/dm-table.c",
90452 + .param2 = 1,
90453 +};
90454 +
90455 +struct size_overflow_hash _001352_hash = {
90456 + .next = NULL,
90457 + .name = "aoechr_write",
90458 + .file = "drivers/block/aoe/aoechr.c",
90459 + .param3 = 1,
90460 +};
90461 +
90462 +struct size_overflow_hash _001353_hash = {
90463 + .next = NULL,
90464 + .name = "ath6kl_cfg80211_connect_event",
90465 + .file = "drivers/net/wireless/ath/ath6kl/cfg80211.c",
90466 + .param7 = 1,
90467 + .param9 = 1,
90468 + .param8 = 1,
90469 +};
90470 +
90471 +struct size_overflow_hash _001356_hash = {
90472 + .next = NULL,
90473 + .name = "ath6kl_mgmt_tx",
90474 + .file = "drivers/net/wireless/ath/ath6kl/cfg80211.c",
90475 + .param9 = 1,
90476 +};
90477 +
90478 +struct size_overflow_hash _001357_hash = {
90479 + .next = NULL,
90480 + .name = "atomic_read_file",
90481 + .file = "arch/x86/oprofile/../../../drivers/oprofile/oprofilefs.c",
90482 + .param3 = 1,
90483 +};
90484 +
90485 +struct size_overflow_hash _001358_hash = {
90486 + .next = NULL,
90487 + .name = "beacon_interval_read",
90488 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90489 + .param3 = 1,
90490 +};
90491 +
90492 +struct size_overflow_hash _001359_hash = {
90493 + .next = NULL,
90494 + .name = "bm_entry_write",
90495 + .file = "fs/binfmt_misc.c",
90496 + .param3 = 1,
90497 +};
90498 +
90499 +struct size_overflow_hash _001360_hash = {
90500 + .next = NULL,
90501 + .name = "bm_init",
90502 + .file = "lib/ts_bm.c",
90503 + .param2 = 1,
90504 +};
90505 +
90506 +struct size_overflow_hash _001361_hash = {
90507 + .next = NULL,
90508 + .name = "bm_register_write",
90509 + .file = "fs/binfmt_misc.c",
90510 + .param3 = 1,
90511 +};
90512 +
90513 +struct size_overflow_hash _001362_hash = {
90514 + .next = NULL,
90515 + .name = "bm_status_write",
90516 + .file = "fs/binfmt_misc.c",
90517 + .param3 = 1,
90518 +};
90519 +
90520 +struct size_overflow_hash _001363_hash = {
90521 + .next = NULL,
90522 + .name = "brn_proc_write",
90523 + .file = "drivers/platform/x86/asus_acpi.c",
90524 + .param3 = 1,
90525 +};
90526 +
90527 +struct size_overflow_hash _001364_hash = {
90528 + .next = NULL,
90529 + .name = "btrfs_map_block",
90530 + .file = "fs/btrfs/volumes.c",
90531 + .param3 = 1,
90532 +};
90533 +
90534 +struct size_overflow_hash _001365_hash = {
90535 + .next = NULL,
90536 + .name = "cache_downcall",
90537 + .file = "net/sunrpc/cache.c",
90538 + .param3 = 1,
90539 +};
90540 +
90541 +struct size_overflow_hash _001366_hash = {
90542 + .next = NULL,
90543 + .name = "cache_slow_downcall",
90544 + .file = "net/sunrpc/cache.c",
90545 + .param2 = 1,
90546 +};
90547 +
90548 +struct size_overflow_hash _001367_hash = {
90549 + .next = NULL,
90550 + .name = "ceph_dns_resolve_name",
90551 + .file = "net/ceph/messenger.c",
90552 + .param1 = 1,
90553 +};
90554 +
90555 +struct size_overflow_hash _001368_hash = {
90556 + .next = NULL,
90557 + .name = "cfg80211_roamed",
90558 + .file = "include/net/cfg80211.h",
90559 + .param5 = 1,
90560 + .param7 = 1,
90561 +};
90562 +
90563 +struct size_overflow_hash _001370_hash = {
90564 + .next = NULL,
90565 + .name = "cifs_readv_from_socket",
90566 + .file = "fs/cifs/connect.c",
90567 + .param3 = 1,
90568 +};
90569 +
90570 +struct size_overflow_hash _001371_hash = {
90571 + .next = NULL,
90572 + .name = "configfs_write_file",
90573 + .file = "fs/configfs/file.c",
90574 + .param3 = 1,
90575 +};
90576 +
90577 +struct size_overflow_hash _001372_hash = {
90578 + .next = &_001370_hash,
90579 + .name = "cpu_type_read",
90580 + .file = "arch/x86/oprofile/../../../drivers/oprofile/oprofile_files.c",
90581 + .param3 = 1,
90582 +};
90583 +
90584 +struct size_overflow_hash _001373_hash = {
90585 + .next = NULL,
90586 + .name = "cx18_copy_mdl_to_user",
90587 + .file = "drivers/media/video/cx18/cx18-fileops.c",
90588 + .param4 = 1,
90589 +};
90590 +
90591 +struct size_overflow_hash _001374_hash = {
90592 + .next = NULL,
90593 + .name = "cxgbi_ddp_reserve",
90594 + .file = "drivers/scsi/cxgbi/libcxgbi.c",
90595 + .param4 = 1,
90596 +};
90597 +
90598 +struct size_overflow_hash _001375_hash = {
90599 + .next = NULL,
90600 + .name = "cxgbi_device_portmap_create",
90601 + .file = "drivers/scsi/cxgbi/libcxgbi.c",
90602 + .param3 = 1,
90603 +};
90604 +
90605 +struct size_overflow_hash _001376_hash = {
90606 + .next = NULL,
90607 + .name = "datablob_hmac_append",
90608 + .file = "security/keys/encrypted-keys/encrypted.c",
90609 + .param3 = 1,
90610 +};
90611 +
90612 +struct size_overflow_hash _001377_hash = {
90613 + .next = NULL,
90614 + .name = "datablob_hmac_verify",
90615 + .file = "security/keys/encrypted-keys/encrypted.c",
90616 + .param4 = 1,
90617 +};
90618 +
90619 +struct size_overflow_hash _001378_hash = {
90620 + .next = NULL,
90621 + .name = "dataflash_read_fact_otp",
90622 + .file = "drivers/mtd/devices/mtd_dataflash.c",
90623 + .param3 = 1,
90624 +};
90625 +
90626 +struct size_overflow_hash _001379_hash = {
90627 + .next = NULL,
90628 + .name = "dataflash_read_user_otp",
90629 + .file = "drivers/mtd/devices/mtd_dataflash.c",
90630 + .param3 = 1,
90631 +};
90632 +
90633 +struct size_overflow_hash _001380_hash = {
90634 + .next = NULL,
90635 + .name = "depth_read",
90636 + .file = "arch/x86/oprofile/../../../drivers/oprofile/oprofile_files.c",
90637 + .param3 = 1,
90638 +};
90639 +
90640 +struct size_overflow_hash _001381_hash = {
90641 + .next = NULL,
90642 + .name = "depth_write",
90643 + .file = "arch/x86/oprofile/../../../drivers/oprofile/oprofile_files.c",
90644 + .param3 = 1,
90645 +};
90646 +
90647 +struct size_overflow_hash _001382_hash = {
90648 + .next = NULL,
90649 + .name = "dev_irnet_write",
90650 + .file = "net/irda/irnet/irnet_ppp.c",
90651 + .param3 = 1,
90652 +};
90653 +
90654 +struct size_overflow_hash _001383_hash = {
90655 + .next = NULL,
90656 + .name = "dev_write",
90657 + .file = "sound/oss/msnd_pinnacle.c",
90658 + .param3 = 1,
90659 +};
90660 +
90661 +struct size_overflow_hash _001384_hash = {
90662 + .next = NULL,
90663 + .name = "dfs_file_read",
90664 + .file = "fs/ubifs/debug.c",
90665 + .param3 = 1,
90666 +};
90667 +
90668 +struct size_overflow_hash _001385_hash = {
90669 + .next = NULL,
90670 + .name = "dfs_file_write",
90671 + .file = "fs/ubifs/debug.c",
90672 + .param3 = 1,
90673 +};
90674 +
90675 +struct size_overflow_hash _001386_hash = {
90676 + .next = NULL,
90677 + .name = "dfs_global_file_read",
90678 + .file = "fs/ubifs/debug.c",
90679 + .param3 = 1,
90680 +};
90681 +
90682 +struct size_overflow_hash _001387_hash = {
90683 + .next = NULL,
90684 + .name = "dfs_global_file_write",
90685 + .file = "fs/ubifs/debug.c",
90686 + .param3 = 1,
90687 +};
90688 +
90689 +struct size_overflow_hash _001388_hash = {
90690 + .next = NULL,
90691 + .name = "disconnect",
90692 + .file = "net/bluetooth/mgmt.c",
90693 + .param4 = 1,
90694 +};
90695 +
90696 +struct size_overflow_hash _001389_hash = {
90697 + .next = NULL,
90698 + .name = "disp_proc_write",
90699 + .file = "drivers/platform/x86/asus_acpi.c",
90700 + .param3 = 1,
90701 +};
90702 +
90703 +struct size_overflow_hash _001390_hash = {
90704 + .next = NULL,
90705 + .name = "dma_rx_errors_read",
90706 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90707 + .param3 = 1,
90708 +};
90709 +
90710 +struct size_overflow_hash _001391_hash = {
90711 + .next = NULL,
90712 + .name = "dma_rx_requested_read",
90713 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90714 + .param3 = 1,
90715 +};
90716 +
90717 +struct size_overflow_hash _001392_hash = {
90718 + .next = NULL,
90719 + .name = "dma_tx_errors_read",
90720 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90721 + .param3 = 1,
90722 +};
90723 +
90724 +struct size_overflow_hash _001393_hash = {
90725 + .next = NULL,
90726 + .name = "dma_tx_requested_read",
90727 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90728 + .param3 = 1,
90729 +};
90730 +
90731 +struct size_overflow_hash _001394_hash = {
90732 + .next = NULL,
90733 + .name = "dm_exception_table_init",
90734 + .file = "drivers/md/dm-snap.c",
90735 + .param2 = 1,
90736 +};
90737 +
90738 +struct size_overflow_hash _001395_hash = {
90739 + .next = NULL,
90740 + .name = "do_dccp_setsockopt",
90741 + .file = "net/dccp/proto.c",
90742 + .param5 = 1,
90743 +};
90744 +
90745 +struct size_overflow_hash _001396_hash = {
90746 + .next = NULL,
90747 + .name = "dtim_interval_read",
90748 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90749 + .param3 = 1,
90750 +};
90751 +
90752 +struct size_overflow_hash _001397_hash = {
90753 + .next = NULL,
90754 + .name = "dvb_audio_write",
90755 + .file = "drivers/media/dvb/ttpci/av7110_av.c",
90756 + .param3 = 1,
90757 +};
90758 +
90759 +struct size_overflow_hash _001398_hash = {
90760 + .next = NULL,
90761 + .name = "dvb_demux_do_ioctl",
90762 + .file = "drivers/media/dvb/dvb-core/dmxdev.c",
90763 + .param3 = 1,
90764 +};
90765 +
90766 +struct size_overflow_hash _001399_hash = {
90767 + .next = NULL,
90768 + .name = "dvb_dvr_do_ioctl",
90769 + .file = "drivers/media/dvb/dvb-core/dmxdev.c",
90770 + .param3 = 1,
90771 +};
90772 +
90773 +struct size_overflow_hash _001400_hash = {
90774 + .next = NULL,
90775 + .name = "dvb_video_write",
90776 + .file = "drivers/media/dvb/ttpci/av7110_av.c",
90777 + .param3 = 1,
90778 +};
90779 +
90780 +struct size_overflow_hash _001401_hash = {
90781 + .next = NULL,
90782 + .name = "ecryptfs_decode_and_decrypt_filename",
90783 + .file = "fs/ecryptfs/crypto.c",
90784 + .param5 = 1,
90785 +};
90786 +
90787 +struct size_overflow_hash _001402_hash = {
90788 + .next = NULL,
90789 + .name = "ecryptfs_encrypt_and_encode_filename",
90790 + .file = "fs/ecryptfs/crypto.c",
90791 + .param6 = 1,
90792 +};
90793 +
90794 +struct size_overflow_hash _001403_hash = {
90795 + .next = NULL,
90796 + .name = "enable_read",
90797 + .file = "arch/x86/oprofile/../../../drivers/oprofile/oprofile_files.c",
90798 + .param3 = 1,
90799 +};
90800 +
90801 +struct size_overflow_hash _001404_hash = {
90802 + .next = NULL,
90803 + .name = "enable_write",
90804 + .file = "arch/x86/oprofile/../../../drivers/oprofile/oprofile_files.c",
90805 + .param3 = 1,
90806 +};
90807 +
90808 +struct size_overflow_hash _001405_hash = {
90809 + .next = NULL,
90810 + .name = "event_calibration_read",
90811 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90812 + .param3 = 1,
90813 +};
90814 +
90815 +struct size_overflow_hash _001406_hash = {
90816 + .next = NULL,
90817 + .name = "event_heart_beat_read",
90818 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90819 + .param3 = 1,
90820 +};
90821 +
90822 +struct size_overflow_hash _001407_hash = {
90823 + .next = NULL,
90824 + .name = "event_oom_late_read",
90825 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90826 + .param3 = 1,
90827 +};
90828 +
90829 +struct size_overflow_hash _001408_hash = {
90830 + .next = NULL,
90831 + .name = "event_phy_transmit_error_read",
90832 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90833 + .param3 = 1,
90834 +};
90835 +
90836 +struct size_overflow_hash _001409_hash = {
90837 + .next = NULL,
90838 + .name = "event_rx_mem_empty_read",
90839 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90840 + .param3 = 1,
90841 +};
90842 +
90843 +struct size_overflow_hash _001410_hash = {
90844 + .next = NULL,
90845 + .name = "event_rx_mismatch_read",
90846 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90847 + .param3 = 1,
90848 +};
90849 +
90850 +struct size_overflow_hash _001411_hash = {
90851 + .next = NULL,
90852 + .name = "event_rx_pool_read",
90853 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90854 + .param3 = 1,
90855 +};
90856 +
90857 +struct size_overflow_hash _001412_hash = {
90858 + .next = NULL,
90859 + .name = "event_tx_stuck_read",
90860 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90861 + .param3 = 1,
90862 +};
90863 +
90864 +struct size_overflow_hash _001413_hash = {
90865 + .next = NULL,
90866 + .name = "excessive_retries_read",
90867 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
90868 + .param3 = 1,
90869 +};
90870 +
90871 +struct size_overflow_hash _001414_hash = {
90872 + .next = NULL,
90873 + .name = "exofs_read_kern",
90874 + .file = "fs/exofs/super.c",
90875 + .param6 = 1,
90876 +};
90877 +
90878 +struct size_overflow_hash _001415_hash = {
90879 + .next = NULL,
90880 + .name = "fallback_on_nodma_alloc",
90881 + .file = "drivers/block/floppy.c",
90882 + .param2 = 1,
90883 +};
90884 +
90885 +struct size_overflow_hash _001416_hash = {
90886 + .next = NULL,
90887 + .name = "__feat_register_sp",
90888 + .file = "net/dccp/feat.c",
90889 + .param6 = 1,
90890 +};
90891 +
90892 +struct size_overflow_hash _001417_hash = {
90893 + .next = NULL,
90894 + .name = "ffs_ep0_write",
90895 + .file = "drivers/usb/gadget/f_fs.c",
90896 + .param3 = 1,
90897 +};
90898 +
90899 +struct size_overflow_hash _001418_hash = {
90900 + .next = NULL,
90901 + .name = "ffs_epfile_read",
90902 + .file = "drivers/usb/gadget/f_fs.c",
90903 + .param3 = 1,
90904 +};
90905 +
90906 +struct size_overflow_hash _001419_hash = {
90907 + .next = NULL,
90908 + .name = "ffs_epfile_write",
90909 + .file = "drivers/usb/gadget/f_fs.c",
90910 + .param3 = 1,
90911 +};
90912 +
90913 +struct size_overflow_hash _001420_hash = {
90914 + .next = NULL,
90915 + .name = "frequency_read",
90916 + .file = "net/mac80211/debugfs.c",
90917 + .param3 = 1,
90918 +};
90919 +
90920 +struct size_overflow_hash _001421_hash = {
90921 + .next = NULL,
90922 + .name = "fsm_init",
90923 + .file = "lib/ts_fsm.c",
90924 + .param2 = 1,
90925 +};
90926 +
90927 +struct size_overflow_hash _001422_hash = {
90928 + .next = NULL,
90929 + .name = "garmin_read_process",
90930 + .file = "drivers/usb/serial/garmin_gps.c",
90931 + .param3 = 1,
90932 +};
90933 +
90934 +struct size_overflow_hash _001423_hash = {
90935 + .next = NULL,
90936 + .name = "garp_request_join",
90937 + .file = "include/net/garp.h",
90938 + .param4 = 1,
90939 +};
90940 +
90941 +struct size_overflow_hash _001424_hash = {
90942 + .next = NULL,
90943 + .name = "hcd_alloc_coherent",
90944 + .file = "drivers/usb/core/hcd.c",
90945 + .param5 = 1,
90946 +};
90947 +
90948 +struct size_overflow_hash _001425_hash = {
90949 + .next = NULL,
90950 + .name = "hci_sock_sendmsg",
90951 + .file = "net/bluetooth/hci_sock.c",
90952 + .param4 = 1,
90953 +};
90954 +
90955 +struct size_overflow_hash _001426_hash = {
90956 + .next = NULL,
90957 + .name = "__hwahc_op_set_gtk",
90958 + .file = "drivers/usb/host/hwa-hc.c",
90959 + .param4 = 1,
90960 +};
90961 +
90962 +struct size_overflow_hash _001427_hash = {
90963 + .next = NULL,
90964 + .name = "__hwahc_op_set_ptk",
90965 + .file = "drivers/usb/host/hwa-hc.c",
90966 + .param5 = 1,
90967 +};
90968 +
90969 +struct size_overflow_hash _001428_hash = {
90970 + .next = NULL,
90971 + .name = "ib_send_cm_drep",
90972 + .file = "include/rdma/ib_cm.h",
90973 + .param3 = 1,
90974 +};
90975 +
90976 +struct size_overflow_hash _001429_hash = {
90977 + .next = NULL,
90978 + .name = "ib_send_cm_mra",
90979 + .file = "include/rdma/ib_cm.h",
90980 + .param4 = 1,
90981 +};
90982 +
90983 +struct size_overflow_hash _001430_hash = {
90984 + .next = NULL,
90985 + .name = "ib_send_cm_rtu",
90986 + .file = "include/rdma/ib_cm.h",
90987 + .param3 = 1,
90988 +};
90989 +
90990 +struct size_overflow_hash _001431_hash = {
90991 + .next = NULL,
90992 + .name = "ieee80211_bss_info_update",
90993 + .file = "net/mac80211/scan.c",
90994 + .param4 = 1,
90995 +};
90996 +
90997 +struct size_overflow_hash _001432_hash = {
90998 + .next = NULL,
90999 + .name = "ieee80211_if_read_aid",
91000 + .file = "net/mac80211/debugfs_netdev.c",
91001 + .param3 = 1,
91002 +};
91003 +
91004 +struct size_overflow_hash _001433_hash = {
91005 + .next = NULL,
91006 + .name = "ieee80211_if_read_auto_open_plinks",
91007 + .file = "net/mac80211/debugfs_netdev.c",
91008 + .param3 = 1,
91009 +};
91010 +
91011 +struct size_overflow_hash _001434_hash = {
91012 + .next = NULL,
91013 + .name = "ieee80211_if_read_ave_beacon",
91014 + .file = "net/mac80211/debugfs_netdev.c",
91015 + .param3 = 1,
91016 +};
91017 +
91018 +struct size_overflow_hash _001435_hash = {
91019 + .next = NULL,
91020 + .name = "ieee80211_if_read_bssid",
91021 + .file = "net/mac80211/debugfs_netdev.c",
91022 + .param3 = 1,
91023 +};
91024 +
91025 +struct size_overflow_hash _001436_hash = {
91026 + .next = NULL,
91027 + .name = "ieee80211_if_read_channel_type",
91028 + .file = "net/mac80211/debugfs_netdev.c",
91029 + .param3 = 1,
91030 +};
91031 +
91032 +struct size_overflow_hash _001437_hash = {
91033 + .next = NULL,
91034 + .name = "ieee80211_if_read_dot11MeshConfirmTimeout",
91035 + .file = "net/mac80211/debugfs_netdev.c",
91036 + .param3 = 1,
91037 +};
91038 +
91039 +struct size_overflow_hash _001438_hash = {
91040 + .next = NULL,
91041 + .name = "ieee80211_if_read_dot11MeshGateAnnouncementProtocol",
91042 + .file = "net/mac80211/debugfs_netdev.c",
91043 + .param3 = 1,
91044 +};
91045 +
91046 +struct size_overflow_hash _001439_hash = {
91047 + .next = NULL,
91048 + .name = "ieee80211_if_read_dot11MeshHoldingTimeout",
91049 + .file = "net/mac80211/debugfs_netdev.c",
91050 + .param3 = 1,
91051 +};
91052 +
91053 +struct size_overflow_hash _001440_hash = {
91054 + .next = NULL,
91055 + .name = "ieee80211_if_read_dot11MeshHWMPactivePathTimeout",
91056 + .file = "net/mac80211/debugfs_netdev.c",
91057 + .param3 = 1,
91058 +};
91059 +
91060 +struct size_overflow_hash _001441_hash = {
91061 + .next = NULL,
91062 + .name = "ieee80211_if_read_dot11MeshHWMPmaxPREQretries",
91063 + .file = "net/mac80211/debugfs_netdev.c",
91064 + .param3 = 1,
91065 +};
91066 +
91067 +struct size_overflow_hash _001442_hash = {
91068 + .next = NULL,
91069 + .name = "ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime",
91070 + .file = "net/mac80211/debugfs_netdev.c",
91071 + .param3 = 1,
91072 +};
91073 +
91074 +struct size_overflow_hash _001443_hash = {
91075 + .next = NULL,
91076 + .name = "ieee80211_if_read_dot11MeshHWMPperrMinInterval",
91077 + .file = "net/mac80211/debugfs_netdev.c",
91078 + .param3 = 1,
91079 +};
91080 +
91081 +struct size_overflow_hash _001444_hash = {
91082 + .next = NULL,
91083 + .name = "ieee80211_if_read_dot11MeshHWMPpreqMinInterval",
91084 + .file = "net/mac80211/debugfs_netdev.c",
91085 + .param3 = 1,
91086 +};
91087 +
91088 +struct size_overflow_hash _001445_hash = {
91089 + .next = NULL,
91090 + .name = "ieee80211_if_read_dot11MeshHWMPRannInterval",
91091 + .file = "net/mac80211/debugfs_netdev.c",
91092 + .param3 = 1,
91093 +};
91094 +
91095 +struct size_overflow_hash _001446_hash = {
91096 + .next = NULL,
91097 + .name = "ieee80211_if_read_dot11MeshHWMPRootMode",
91098 + .file = "net/mac80211/debugfs_netdev.c",
91099 + .param3 = 1,
91100 +};
91101 +
91102 +struct size_overflow_hash _001447_hash = {
91103 + .next = NULL,
91104 + .name = "ieee80211_if_read_dot11MeshMaxPeerLinks",
91105 + .file = "net/mac80211/debugfs_netdev.c",
91106 + .param3 = 1,
91107 +};
91108 +
91109 +struct size_overflow_hash _001448_hash = {
91110 + .next = NULL,
91111 + .name = "ieee80211_if_read_dot11MeshMaxRetries",
91112 + .file = "net/mac80211/debugfs_netdev.c",
91113 + .param3 = 1,
91114 +};
91115 +
91116 +struct size_overflow_hash _001449_hash = {
91117 + .next = NULL,
91118 + .name = "ieee80211_if_read_dot11MeshRetryTimeout",
91119 + .file = "net/mac80211/debugfs_netdev.c",
91120 + .param3 = 1,
91121 +};
91122 +
91123 +struct size_overflow_hash _001450_hash = {
91124 + .next = NULL,
91125 + .name = "ieee80211_if_read_dot11MeshTTL",
91126 + .file = "net/mac80211/debugfs_netdev.c",
91127 + .param3 = 1,
91128 +};
91129 +
91130 +struct size_overflow_hash _001451_hash = {
91131 + .next = NULL,
91132 + .name = "ieee80211_if_read_dropped_frames_congestion",
91133 + .file = "net/mac80211/debugfs_netdev.c",
91134 + .param3 = 1,
91135 +};
91136 +
91137 +struct size_overflow_hash _001452_hash = {
91138 + .next = NULL,
91139 + .name = "ieee80211_if_read_dropped_frames_no_route",
91140 + .file = "net/mac80211/debugfs_netdev.c",
91141 + .param3 = 1,
91142 +};
91143 +
91144 +struct size_overflow_hash _001453_hash = {
91145 + .next = NULL,
91146 + .name = "ieee80211_if_read_dropped_frames_ttl",
91147 + .file = "net/mac80211/debugfs_netdev.c",
91148 + .param3 = 1,
91149 +};
91150 +
91151 +struct size_overflow_hash _001454_hash = {
91152 + .next = NULL,
91153 + .name = "ieee80211_if_read_drop_unencrypted",
91154 + .file = "net/mac80211/debugfs_netdev.c",
91155 + .param3 = 1,
91156 +};
91157 +
91158 +struct size_overflow_hash _001455_hash = {
91159 + .next = NULL,
91160 + .name = "ieee80211_if_read_dtim_count",
91161 + .file = "net/mac80211/debugfs_netdev.c",
91162 + .param3 = 1,
91163 +};
91164 +
91165 +struct size_overflow_hash _001456_hash = {
91166 + .next = NULL,
91167 + .name = "ieee80211_if_read_element_ttl",
91168 + .file = "net/mac80211/debugfs_netdev.c",
91169 + .param3 = 1,
91170 +};
91171 +
91172 +struct size_overflow_hash _001457_hash = {
91173 + .next = NULL,
91174 + .name = "ieee80211_if_read_estab_plinks",
91175 + .file = "net/mac80211/debugfs_netdev.c",
91176 + .param3 = 1,
91177 +};
91178 +
91179 +struct size_overflow_hash _001458_hash = {
91180 + .next = NULL,
91181 + .name = "ieee80211_if_read_flags",
91182 + .file = "net/mac80211/debugfs_netdev.c",
91183 + .param3 = 1,
91184 +};
91185 +
91186 +struct size_overflow_hash _001459_hash = {
91187 + .next = NULL,
91188 + .name = "ieee80211_if_read_fwded_frames",
91189 + .file = "net/mac80211/debugfs_netdev.c",
91190 + .param3 = 1,
91191 +};
91192 +
91193 +struct size_overflow_hash _001460_hash = {
91194 + .next = NULL,
91195 + .name = "ieee80211_if_read_fwded_mcast",
91196 + .file = "net/mac80211/debugfs_netdev.c",
91197 + .param3 = 1,
91198 +};
91199 +
91200 +struct size_overflow_hash _001461_hash = {
91201 + .next = NULL,
91202 + .name = "ieee80211_if_read_fwded_unicast",
91203 + .file = "net/mac80211/debugfs_netdev.c",
91204 + .param3 = 1,
91205 +};
91206 +
91207 +struct size_overflow_hash _001462_hash = {
91208 + .next = NULL,
91209 + .name = "ieee80211_if_read_last_beacon",
91210 + .file = "net/mac80211/debugfs_netdev.c",
91211 + .param3 = 1,
91212 +};
91213 +
91214 +struct size_overflow_hash _001463_hash = {
91215 + .next = NULL,
91216 + .name = "ieee80211_if_read_min_discovery_timeout",
91217 + .file = "net/mac80211/debugfs_netdev.c",
91218 + .param3 = 1,
91219 +};
91220 +
91221 +struct size_overflow_hash _001464_hash = {
91222 + .next = NULL,
91223 + .name = "ieee80211_if_read_num_buffered_multicast",
91224 + .file = "net/mac80211/debugfs_netdev.c",
91225 + .param3 = 1,
91226 +};
91227 +
91228 +struct size_overflow_hash _001465_hash = {
91229 + .next = NULL,
91230 + .name = "ieee80211_if_read_num_sta_authorized",
91231 + .file = "net/mac80211/debugfs_netdev.c",
91232 + .param3 = 1,
91233 +};
91234 +
91235 +struct size_overflow_hash _001466_hash = {
91236 + .next = NULL,
91237 + .name = "ieee80211_if_read_num_sta_ps",
91238 + .file = "net/mac80211/debugfs_netdev.c",
91239 + .param3 = 1,
91240 +};
91241 +
91242 +struct size_overflow_hash _001467_hash = {
91243 + .next = NULL,
91244 + .name = "ieee80211_if_read_path_refresh_time",
91245 + .file = "net/mac80211/debugfs_netdev.c",
91246 + .param3 = 1,
91247 +};
91248 +
91249 +struct size_overflow_hash _001468_hash = {
91250 + .next = NULL,
91251 + .name = "ieee80211_if_read_peer",
91252 + .file = "net/mac80211/debugfs_netdev.c",
91253 + .param3 = 1,
91254 +};
91255 +
91256 +struct size_overflow_hash _001469_hash = {
91257 + .next = NULL,
91258 + .name = "ieee80211_if_read_rc_rateidx_mask_2ghz",
91259 + .file = "net/mac80211/debugfs_netdev.c",
91260 + .param3 = 1,
91261 +};
91262 +
91263 +struct size_overflow_hash _001470_hash = {
91264 + .next = NULL,
91265 + .name = "ieee80211_if_read_rc_rateidx_mask_5ghz",
91266 + .file = "net/mac80211/debugfs_netdev.c",
91267 + .param3 = 1,
91268 +};
91269 +
91270 +struct size_overflow_hash _001471_hash = {
91271 + .next = NULL,
91272 + .name = "ieee80211_if_read_smps",
91273 + .file = "net/mac80211/debugfs_netdev.c",
91274 + .param3 = 1,
91275 +};
91276 +
91277 +struct size_overflow_hash _001472_hash = {
91278 + .next = NULL,
91279 + .name = "ieee80211_if_read_state",
91280 + .file = "net/mac80211/debugfs_netdev.c",
91281 + .param3 = 1,
91282 +};
91283 +
91284 +struct size_overflow_hash _001473_hash = {
91285 + .next = NULL,
91286 + .name = "ieee80211_if_read_tkip_mic_test",
91287 + .file = "net/mac80211/debugfs_netdev.c",
91288 + .param3 = 1,
91289 +};
91290 +
91291 +struct size_overflow_hash _001474_hash = {
91292 + .next = NULL,
91293 + .name = "ieee80211_if_read_tsf",
91294 + .file = "net/mac80211/debugfs_netdev.c",
91295 + .param3 = 1,
91296 +};
91297 +
91298 +struct size_overflow_hash _001475_hash = {
91299 + .next = NULL,
91300 + .name = "ieee80211_send_probe_req",
91301 + .file = "net/mac80211/util.c",
91302 + .param6 = 1,
91303 +};
91304 +
91305 +struct size_overflow_hash _001476_hash = {
91306 + .next = NULL,
91307 + .name = "init_map_ipmac",
91308 + .file = "net/netfilter/ipset/ip_set_bitmap_ipmac.c",
91309 + .param3 = 1,
91310 + .param4 = 1,
91311 +};
91312 +
91313 +struct size_overflow_hash _001478_hash = {
91314 + .next = NULL,
91315 + .name = "init_tid_tabs",
91316 + .file = "drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c",
91317 + .param2 = 1,
91318 + .param4 = 1,
91319 + .param3 = 1,
91320 +};
91321 +
91322 +struct size_overflow_hash _001481_hash = {
91323 + .next = NULL,
91324 + .name = "isr_cmd_cmplt_read",
91325 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91326 + .param3 = 1,
91327 +};
91328 +
91329 +struct size_overflow_hash _001482_hash = {
91330 + .next = NULL,
91331 + .name = "isr_commands_read",
91332 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91333 + .param3 = 1,
91334 +};
91335 +
91336 +struct size_overflow_hash _001483_hash = {
91337 + .next = NULL,
91338 + .name = "isr_decrypt_done_read",
91339 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91340 + .param3 = 1,
91341 +};
91342 +
91343 +struct size_overflow_hash _001484_hash = {
91344 + .next = NULL,
91345 + .name = "isr_dma0_done_read",
91346 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91347 + .param3 = 1,
91348 +};
91349 +
91350 +struct size_overflow_hash _001485_hash = {
91351 + .next = NULL,
91352 + .name = "isr_dma1_done_read",
91353 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91354 + .param3 = 1,
91355 +};
91356 +
91357 +struct size_overflow_hash _001486_hash = {
91358 + .next = NULL,
91359 + .name = "isr_fiqs_read",
91360 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91361 + .param3 = 1,
91362 +};
91363 +
91364 +struct size_overflow_hash _001487_hash = {
91365 + .next = NULL,
91366 + .name = "isr_host_acknowledges_read",
91367 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91368 + .param3 = 1,
91369 +};
91370 +
91371 +struct size_overflow_hash _001488_hash = {
91372 + .next = &_001393_hash,
91373 + .name = "isr_hw_pm_mode_changes_read",
91374 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91375 + .param3 = 1,
91376 +};
91377 +
91378 +struct size_overflow_hash _001489_hash = {
91379 + .next = &_001205_hash,
91380 + .name = "isr_irqs_read",
91381 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91382 + .param3 = 1,
91383 +};
91384 +
91385 +struct size_overflow_hash _001490_hash = {
91386 + .next = NULL,
91387 + .name = "isr_low_rssi_read",
91388 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91389 + .param3 = 1,
91390 +};
91391 +
91392 +struct size_overflow_hash _001491_hash = {
91393 + .next = NULL,
91394 + .name = "isr_pci_pm_read",
91395 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91396 + .param3 = 1,
91397 +};
91398 +
91399 +struct size_overflow_hash _001492_hash = {
91400 + .next = NULL,
91401 + .name = "isr_rx_headers_read",
91402 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91403 + .param3 = 1,
91404 +};
91405 +
91406 +struct size_overflow_hash _001493_hash = {
91407 + .next = NULL,
91408 + .name = "isr_rx_mem_overflow_read",
91409 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91410 + .param3 = 1,
91411 +};
91412 +
91413 +struct size_overflow_hash _001494_hash = {
91414 + .next = NULL,
91415 + .name = "isr_rx_procs_read",
91416 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91417 + .param3 = 1,
91418 +};
91419 +
91420 +struct size_overflow_hash _001495_hash = {
91421 + .next = NULL,
91422 + .name = "isr_rx_rdys_read",
91423 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91424 + .param3 = 1,
91425 +};
91426 +
91427 +struct size_overflow_hash _001496_hash = {
91428 + .next = NULL,
91429 + .name = "isr_tx_exch_complete_read",
91430 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91431 + .param3 = 1,
91432 +};
91433 +
91434 +struct size_overflow_hash _001497_hash = {
91435 + .next = NULL,
91436 + .name = "isr_tx_procs_read",
91437 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91438 + .param3 = 1,
91439 +};
91440 +
91441 +struct size_overflow_hash _001498_hash = {
91442 + .next = NULL,
91443 + .name = "isr_wakeups_read",
91444 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91445 + .param3 = 1,
91446 +};
91447 +
91448 +struct size_overflow_hash _001499_hash = {
91449 + .next = NULL,
91450 + .name = "ivtv_read",
91451 + .file = "drivers/media/video/ivtv/ivtv-fileops.c",
91452 + .param3 = 1,
91453 +};
91454 +
91455 +struct size_overflow_hash _001500_hash = {
91456 + .next = NULL,
91457 + .name = "kmem_realloc",
91458 + .file = "fs/xfs/kmem.c",
91459 + .param2 = 1,
91460 +};
91461 +
91462 +struct size_overflow_hash _001501_hash = {
91463 + .next = NULL,
91464 + .name = "kmem_zalloc",
91465 + .file = "fs/xfs/kmem.c",
91466 + .param1 = 1,
91467 +};
91468 +
91469 +struct size_overflow_hash _001502_hash = {
91470 + .next = NULL,
91471 + .name = "kmem_zalloc_greedy",
91472 + .file = "fs/xfs/kmem.c",
91473 + .param2 = 1,
91474 + .param3 = 1,
91475 +};
91476 +
91477 +struct size_overflow_hash _001504_hash = {
91478 + .next = NULL,
91479 + .name = "kmp_init",
91480 + .file = "lib/ts_kmp.c",
91481 + .param2 = 1,
91482 +};
91483 +
91484 +struct size_overflow_hash _001505_hash = {
91485 + .next = NULL,
91486 + .name = "lcd_proc_write",
91487 + .file = "drivers/platform/x86/asus_acpi.c",
91488 + .param3 = 1,
91489 +};
91490 +
91491 +struct size_overflow_hash _001506_hash = {
91492 + .next = NULL,
91493 + .name = "ledd_proc_write",
91494 + .file = "drivers/platform/x86/asus_acpi.c",
91495 + .param3 = 1,
91496 +};
91497 +
91498 +struct size_overflow_hash _001507_hash = {
91499 + .next = NULL,
91500 + .name = "mic_calc_failure_read",
91501 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91502 + .param3 = 1,
91503 +};
91504 +
91505 +struct size_overflow_hash _001508_hash = {
91506 + .next = NULL,
91507 + .name = "mic_rx_pkts_read",
91508 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91509 + .param3 = 1,
91510 +};
91511 +
91512 +struct size_overflow_hash _001509_hash = {
91513 + .next = NULL,
91514 + .name = "nfs4_realloc_slot_table",
91515 + .file = "fs/nfs/nfs4proc.c",
91516 + .param2 = 1,
91517 +};
91518 +
91519 +struct size_overflow_hash _001510_hash = {
91520 + .next = NULL,
91521 + .name = "nfs_idmap_request_key",
91522 + .file = "fs/nfs/idmap.c",
91523 + .param2 = 1,
91524 +};
91525 +
91526 +struct size_overflow_hash _001511_hash = {
91527 + .next = NULL,
91528 + .name = "nsm_get_handle",
91529 + .file = "include/linux/lockd/lockd.h",
91530 + .param4 = 1,
91531 +};
91532 +
91533 +struct size_overflow_hash _001512_hash = {
91534 + .next = NULL,
91535 + .name = "ntfs_copy_from_user_iovec",
91536 + .file = "fs/ntfs/file.c",
91537 + .param3 = 1,
91538 + .param6 = 1,
91539 +};
91540 +
91541 +struct size_overflow_hash _001514_hash = {
91542 + .next = NULL,
91543 + .name = "ntfs_file_buffered_write",
91544 + .file = "fs/ntfs/file.c",
91545 + .param6 = 1,
91546 +};
91547 +
91548 +struct size_overflow_hash _001515_hash = {
91549 + .next = NULL,
91550 + .name = "ntfs_malloc_nofs",
91551 + .file = "fs/ntfs/malloc.h",
91552 + .param1 = 1,
91553 +};
91554 +
91555 +struct size_overflow_hash _001516_hash = {
91556 + .next = NULL,
91557 + .name = "ntfs_malloc_nofs_nofail",
91558 + .file = "fs/ntfs/malloc.h",
91559 + .param1 = 1,
91560 +};
91561 +
91562 +struct size_overflow_hash _001517_hash = {
91563 + .next = NULL,
91564 + .name = "ocfs2_control_message",
91565 + .file = "fs/ocfs2/stack_user.c",
91566 + .param3 = 1,
91567 +};
91568 +
91569 +struct size_overflow_hash _001518_hash = {
91570 + .next = NULL,
91571 + .name = "opera1_usb_i2c_msgxfer",
91572 + .file = "drivers/media/dvb/dvb-usb/opera1.c",
91573 + .param4 = 1,
91574 +};
91575 +
91576 +struct size_overflow_hash _001519_hash = {
91577 + .next = NULL,
91578 + .name = "orinoco_add_extscan_result",
91579 + .file = "drivers/net/wireless/orinoco/scan.c",
91580 + .param3 = 1,
91581 +};
91582 +
91583 +struct size_overflow_hash _001520_hash = {
91584 + .next = NULL,
91585 + .name = "osd_req_list_collection_objects",
91586 + .file = "include/scsi/osd_initiator.h",
91587 + .param5 = 1,
91588 +};
91589 +
91590 +struct size_overflow_hash _001521_hash = {
91591 + .next = NULL,
91592 + .name = "osd_req_list_partition_objects",
91593 + .file = "include/scsi/osd_initiator.h",
91594 + .param5 = 1,
91595 +};
91596 +
91597 +struct size_overflow_hash _001522_hash = {
91598 + .next = NULL,
91599 + .name = "pair_device",
91600 + .file = "net/bluetooth/mgmt.c",
91601 + .param4 = 1,
91602 +};
91603 +
91604 +struct size_overflow_hash _001523_hash = {
91605 + .next = NULL,
91606 + .name = "pccard_store_cis",
91607 + .file = "drivers/pcmcia/cistpl.c",
91608 + .param6 = 1,
91609 +};
91610 +
91611 +struct size_overflow_hash _001524_hash = {
91612 + .next = NULL,
91613 + .name = "pin_code_reply",
91614 + .file = "net/bluetooth/mgmt.c",
91615 + .param4 = 1,
91616 +};
91617 +
91618 +struct size_overflow_hash _001525_hash = {
91619 + .next = NULL,
91620 + .name = "play_iframe",
91621 + .file = "drivers/media/dvb/ttpci/av7110_av.c",
91622 + .param3 = 1,
91623 +};
91624 +
91625 +struct size_overflow_hash _001526_hash = {
91626 + .next = NULL,
91627 + .name = "pointer_size_read",
91628 + .file = "arch/x86/oprofile/../../../drivers/oprofile/oprofile_files.c",
91629 + .param3 = 1,
91630 +};
91631 +
91632 +struct size_overflow_hash _001527_hash = {
91633 + .next = NULL,
91634 + .name = "power_read",
91635 + .file = "net/mac80211/debugfs.c",
91636 + .param3 = 1,
91637 +};
91638 +
91639 +struct size_overflow_hash _001528_hash = {
91640 + .next = NULL,
91641 + .name = "ps_pspoll_max_apturn_read",
91642 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91643 + .param3 = 1,
91644 +};
91645 +
91646 +struct size_overflow_hash _001529_hash = {
91647 + .next = NULL,
91648 + .name = "ps_pspoll_timeouts_read",
91649 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91650 + .param3 = 1,
91651 +};
91652 +
91653 +struct size_overflow_hash _001530_hash = {
91654 + .next = NULL,
91655 + .name = "ps_pspoll_utilization_read",
91656 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91657 + .param3 = 1,
91658 +};
91659 +
91660 +struct size_overflow_hash _001531_hash = {
91661 + .next = NULL,
91662 + .name = "ps_upsd_max_apturn_read",
91663 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91664 + .param3 = 1,
91665 +};
91666 +
91667 +struct size_overflow_hash _001532_hash = {
91668 + .next = NULL,
91669 + .name = "ps_upsd_max_sptime_read",
91670 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91671 + .param3 = 1,
91672 +};
91673 +
91674 +struct size_overflow_hash _001533_hash = {
91675 + .next = NULL,
91676 + .name = "ps_upsd_timeouts_read",
91677 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91678 + .param3 = 1,
91679 +};
91680 +
91681 +struct size_overflow_hash _001534_hash = {
91682 + .next = NULL,
91683 + .name = "ps_upsd_utilization_read",
91684 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91685 + .param3 = 1,
91686 +};
91687 +
91688 +struct size_overflow_hash _001535_hash = {
91689 + .next = NULL,
91690 + .name = "pwr_disable_ps_read",
91691 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91692 + .param3 = 1,
91693 +};
91694 +
91695 +struct size_overflow_hash _001536_hash = {
91696 + .next = NULL,
91697 + .name = "pwr_elp_enter_read",
91698 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91699 + .param3 = 1,
91700 +};
91701 +
91702 +struct size_overflow_hash _001537_hash = {
91703 + .next = NULL,
91704 + .name = "pwr_enable_ps_read",
91705 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91706 + .param3 = 1,
91707 +};
91708 +
91709 +struct size_overflow_hash _001538_hash = {
91710 + .next = NULL,
91711 + .name = "pwr_fix_tsf_ps_read",
91712 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91713 + .param3 = 1,
91714 +};
91715 +
91716 +struct size_overflow_hash _001539_hash = {
91717 + .next = NULL,
91718 + .name = "pwr_missing_bcns_read",
91719 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91720 + .param3 = 1,
91721 +};
91722 +
91723 +struct size_overflow_hash _001540_hash = {
91724 + .next = NULL,
91725 + .name = "pwr_power_save_off_read",
91726 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91727 + .param3 = 1,
91728 +};
91729 +
91730 +struct size_overflow_hash _001541_hash = {
91731 + .next = NULL,
91732 + .name = "pwr_ps_enter_read",
91733 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91734 + .param3 = 1,
91735 +};
91736 +
91737 +struct size_overflow_hash _001542_hash = {
91738 + .next = NULL,
91739 + .name = "pwr_rcvd_awake_beacons_read",
91740 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91741 + .param3 = 1,
91742 +};
91743 +
91744 +struct size_overflow_hash _001543_hash = {
91745 + .next = NULL,
91746 + .name = "pwr_rcvd_beacons_read",
91747 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91748 + .param3 = 1,
91749 +};
91750 +
91751 +struct size_overflow_hash _001544_hash = {
91752 + .next = NULL,
91753 + .name = "pwr_tx_without_ps_read",
91754 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91755 + .param3 = 1,
91756 +};
91757 +
91758 +struct size_overflow_hash _001545_hash = {
91759 + .next = NULL,
91760 + .name = "pwr_tx_with_ps_read",
91761 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91762 + .param3 = 1,
91763 +};
91764 +
91765 +struct size_overflow_hash _001546_hash = {
91766 + .next = NULL,
91767 + .name = "pwr_wake_on_host_read",
91768 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91769 + .param3 = 1,
91770 +};
91771 +
91772 +struct size_overflow_hash _001547_hash = {
91773 + .next = NULL,
91774 + .name = "pwr_wake_on_timer_exp_read",
91775 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91776 + .param3 = 1,
91777 +};
91778 +
91779 +struct size_overflow_hash _001548_hash = {
91780 + .next = NULL,
91781 + .name = "qcam_read",
91782 + .file = "drivers/media/video/c-qcam.c",
91783 + .param3 = 1,
91784 +};
91785 +
91786 +struct size_overflow_hash _001549_hash = {
91787 + .next = NULL,
91788 + .name = "retry_count_read",
91789 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91790 + .param3 = 1,
91791 +};
91792 +
91793 +struct size_overflow_hash _001550_hash = {
91794 + .next = NULL,
91795 + .name = "rx_dropped_read",
91796 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91797 + .param3 = 1,
91798 +};
91799 +
91800 +struct size_overflow_hash _001551_hash = {
91801 + .next = NULL,
91802 + .name = "rx_fcs_err_read",
91803 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91804 + .param3 = 1,
91805 +};
91806 +
91807 +struct size_overflow_hash _001552_hash = {
91808 + .next = NULL,
91809 + .name = "rx_hdr_overflow_read",
91810 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91811 + .param3 = 1,
91812 +};
91813 +
91814 +struct size_overflow_hash _001553_hash = {
91815 + .next = NULL,
91816 + .name = "rx_hw_stuck_read",
91817 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91818 + .param3 = 1,
91819 +};
91820 +
91821 +struct size_overflow_hash _001554_hash = {
91822 + .next = NULL,
91823 + .name = "rx_out_of_mem_read",
91824 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91825 + .param3 = 1,
91826 +};
91827 +
91828 +struct size_overflow_hash _001555_hash = {
91829 + .next = NULL,
91830 + .name = "rx_path_reset_read",
91831 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91832 + .param3 = 1,
91833 +};
91834 +
91835 +struct size_overflow_hash _001556_hash = {
91836 + .next = NULL,
91837 + .name = "rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read",
91838 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91839 + .param3 = 1,
91840 +};
91841 +
91842 +struct size_overflow_hash _001557_hash = {
91843 + .next = NULL,
91844 + .name = "rxpipe_descr_host_int_trig_rx_data_read",
91845 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91846 + .param3 = 1,
91847 +};
91848 +
91849 +struct size_overflow_hash _001558_hash = {
91850 + .next = NULL,
91851 + .name = "rxpipe_missed_beacon_host_int_trig_rx_data_read",
91852 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91853 + .param3 = 1,
91854 +};
91855 +
91856 +struct size_overflow_hash _001559_hash = {
91857 + .next = NULL,
91858 + .name = "rxpipe_rx_prep_beacon_drop_read",
91859 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91860 + .param3 = 1,
91861 +};
91862 +
91863 +struct size_overflow_hash _001560_hash = {
91864 + .next = NULL,
91865 + .name = "rxpipe_tx_xfr_host_int_trig_rx_data_read",
91866 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91867 + .param3 = 1,
91868 +};
91869 +
91870 +struct size_overflow_hash _001561_hash = {
91871 + .next = NULL,
91872 + .name = "rx_reset_counter_read",
91873 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91874 + .param3 = 1,
91875 +};
91876 +
91877 +struct size_overflow_hash _001562_hash = {
91878 + .next = NULL,
91879 + .name = "rx_streaming_always_read",
91880 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91881 + .param3 = 1,
91882 +};
91883 +
91884 +struct size_overflow_hash _001563_hash = {
91885 + .next = NULL,
91886 + .name = "rx_streaming_interval_read",
91887 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91888 + .param3 = 1,
91889 +};
91890 +
91891 +struct size_overflow_hash _001564_hash = {
91892 + .next = NULL,
91893 + .name = "rx_xfr_hint_trig_read",
91894 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
91895 + .param3 = 1,
91896 +};
91897 +
91898 +struct size_overflow_hash _001565_hash = {
91899 + .next = NULL,
91900 + .name = "scsi_execute_req",
91901 + .file = "include/scsi/scsi_device.h",
91902 + .param5 = 1,
91903 +};
91904 +
91905 +struct size_overflow_hash _001566_hash = {
91906 + .next = NULL,
91907 + .name = "scsi_tgt_kspace_exec",
91908 + .file = "drivers/scsi/scsi_tgt_lib.c",
91909 + .param8 = 1,
91910 +};
91911 +
91912 +struct size_overflow_hash _001567_hash = {
91913 + .next = NULL,
91914 + .name = "sctp_sendmsg",
91915 + .file = "net/sctp/socket.c",
91916 + .param4 = 1,
91917 +};
91918 +
91919 +struct size_overflow_hash _001568_hash = {
91920 + .next = NULL,
91921 + .name = "sctp_setsockopt",
91922 + .file = "net/sctp/socket.c",
91923 + .param5 = 1,
91924 +};
91925 +
91926 +struct size_overflow_hash _001569_hash = {
91927 + .next = NULL,
91928 + .name = "set_connectable",
91929 + .file = "net/bluetooth/mgmt.c",
91930 + .param4 = 1,
91931 +};
91932 +
91933 +struct size_overflow_hash _001570_hash = {
91934 + .next = NULL,
91935 + .name = "set_discoverable",
91936 + .file = "net/bluetooth/mgmt.c",
91937 + .param4 = 1,
91938 +};
91939 +
91940 +struct size_overflow_hash _001571_hash = {
91941 + .next = NULL,
91942 + .name = "set_local_name",
91943 + .file = "net/bluetooth/mgmt.c",
91944 + .param4 = 1,
91945 +};
91946 +
91947 +struct size_overflow_hash _001572_hash = {
91948 + .next = NULL,
91949 + .name = "set_powered",
91950 + .file = "net/bluetooth/mgmt.c",
91951 + .param4 = 1,
91952 +};
91953 +
91954 +struct size_overflow_hash _001573_hash = {
91955 + .next = NULL,
91956 + .name = "simple_alloc_urb",
91957 + .file = "drivers/usb/misc/usbtest.c",
91958 + .param3 = 1,
91959 +};
91960 +
91961 +struct size_overflow_hash _001574_hash = {
91962 + .next = NULL,
91963 + .name = "sm_checker_extend",
91964 + .file = "drivers/md/persistent-data/dm-space-map-checker.c",
91965 + .param2 = 1,
91966 +};
91967 +
91968 +struct size_overflow_hash _001575_hash = {
91969 + .next = NULL,
91970 + .name = "snd_cs4281_BA0_read",
91971 + .file = "sound/pci/cs4281.c",
91972 + .param5 = 1,
91973 +};
91974 +
91975 +struct size_overflow_hash _001576_hash = {
91976 + .next = NULL,
91977 + .name = "snd_cs4281_BA1_read",
91978 + .file = "sound/pci/cs4281.c",
91979 + .param5 = 1,
91980 +};
91981 +
91982 +struct size_overflow_hash _001577_hash = {
91983 + .next = NULL,
91984 + .name = "snd_cs46xx_io_read",
91985 + .file = "sound/pci/cs46xx/cs46xx_lib.c",
91986 + .param5 = 1,
91987 +};
91988 +
91989 +struct size_overflow_hash _001578_hash = {
91990 + .next = NULL,
91991 + .name = "snd_gus_dram_read",
91992 + .file = "include/sound/gus.h",
91993 + .param4 = 1,
91994 +};
91995 +
91996 +struct size_overflow_hash _001579_hash = {
91997 + .next = NULL,
91998 + .name = "snd_gus_dram_write",
91999 + .file = "include/sound/gus.h",
92000 + .param4 = 1,
92001 +};
92002 +
92003 +struct size_overflow_hash _001580_hash = {
92004 + .next = NULL,
92005 + .name = "snd_mem_proc_write",
92006 + .file = "sound/core/memalloc.c",
92007 + .param3 = 1,
92008 +};
92009 +
92010 +struct size_overflow_hash _001581_hash = {
92011 + .next = NULL,
92012 + .name = "snd_pcm_oss_read",
92013 + .file = "sound/core/oss/pcm_oss.c",
92014 + .param3 = 1,
92015 +};
92016 +
92017 +struct size_overflow_hash _001582_hash = {
92018 + .next = NULL,
92019 + .name = "snd_pcm_oss_sync1",
92020 + .file = "sound/core/oss/pcm_oss.c",
92021 + .param2 = 1,
92022 +};
92023 +
92024 +struct size_overflow_hash _001583_hash = {
92025 + .next = NULL,
92026 + .name = "snd_pcm_oss_write",
92027 + .file = "sound/core/oss/pcm_oss.c",
92028 + .param3 = 1,
92029 +};
92030 +
92031 +struct size_overflow_hash _001584_hash = {
92032 + .next = NULL,
92033 + .name = "snd_rme32_capture_copy",
92034 + .file = "sound/pci/rme32.c",
92035 + .param5 = 1,
92036 +};
92037 +
92038 +struct size_overflow_hash _001585_hash = {
92039 + .next = NULL,
92040 + .name = "snd_rme32_playback_copy",
92041 + .file = "sound/pci/rme32.c",
92042 + .param5 = 1,
92043 +};
92044 +
92045 +struct size_overflow_hash _001586_hash = {
92046 + .next = NULL,
92047 + .name = "snd_rme96_capture_copy",
92048 + .file = "sound/pci/rme96.c",
92049 + .param5 = 1,
92050 +};
92051 +
92052 +struct size_overflow_hash _001587_hash = {
92053 + .next = NULL,
92054 + .name = "snd_rme96_playback_copy",
92055 + .file = "sound/pci/rme96.c",
92056 + .param5 = 1,
92057 +};
92058 +
92059 +struct size_overflow_hash _001588_hash = {
92060 + .next = NULL,
92061 + .name = "spi_execute",
92062 + .file = "drivers/scsi/scsi_transport_spi.c",
92063 + .param5 = 1,
92064 +};
92065 +
92066 +struct size_overflow_hash _001589_hash = {
92067 + .next = NULL,
92068 + .name = "srp_target_alloc",
92069 + .file = "include/scsi/libsrp.h",
92070 + .param3 = 1,
92071 +};
92072 +
92073 +struct size_overflow_hash _001590_hash = {
92074 + .next = NULL,
92075 + .name = "stats_dot11ACKFailureCount_read",
92076 + .file = "net/mac80211/debugfs.c",
92077 + .param3 = 1,
92078 +};
92079 +
92080 +struct size_overflow_hash _001591_hash = {
92081 + .next = NULL,
92082 + .name = "stats_dot11FCSErrorCount_read",
92083 + .file = "net/mac80211/debugfs.c",
92084 + .param3 = 1,
92085 +};
92086 +
92087 +struct size_overflow_hash _001592_hash = {
92088 + .next = NULL,
92089 + .name = "stats_dot11RTSFailureCount_read",
92090 + .file = "net/mac80211/debugfs.c",
92091 + .param3 = 1,
92092 +};
92093 +
92094 +struct size_overflow_hash _001593_hash = {
92095 + .next = NULL,
92096 + .name = "stats_dot11RTSSuccessCount_read",
92097 + .file = "net/mac80211/debugfs.c",
92098 + .param3 = 1,
92099 +};
92100 +
92101 +struct size_overflow_hash _001594_hash = {
92102 + .next = NULL,
92103 + .name = "stk_allocate_buffers",
92104 + .file = "drivers/media/video/stk-webcam.c",
92105 + .param2 = 1,
92106 +};
92107 +
92108 +struct size_overflow_hash _001595_hash = {
92109 + .next = NULL,
92110 + .name = "submit_inquiry",
92111 + .file = "drivers/scsi/device_handler/scsi_dh_rdac.c",
92112 + .param3 = 1,
92113 +};
92114 +
92115 +struct size_overflow_hash _001596_hash = {
92116 + .next = NULL,
92117 + .name = "team_options_register",
92118 + .file = "include/linux/if_team.h",
92119 + .param3 = 1,
92120 +};
92121 +
92122 +struct size_overflow_hash _001597_hash = {
92123 + .next = NULL,
92124 + .name = "test_unaligned_bulk",
92125 + .file = "drivers/usb/misc/usbtest.c",
92126 + .param3 = 1,
92127 +};
92128 +
92129 +struct size_overflow_hash _001598_hash = {
92130 + .next = NULL,
92131 + .name = "timeout_read",
92132 + .file = "arch/x86/oprofile/../../../drivers/oprofile/oprofile_files.c",
92133 + .param3 = 1,
92134 +};
92135 +
92136 +struct size_overflow_hash _001599_hash = {
92137 + .next = NULL,
92138 + .name = "timeout_write",
92139 + .file = "arch/x86/oprofile/../../../drivers/oprofile/oprofile_files.c",
92140 + .param3 = 1,
92141 +};
92142 +
92143 +struct size_overflow_hash _001600_hash = {
92144 + .next = NULL,
92145 + .name = "tipc_link_send_sections_fast",
92146 + .file = "net/tipc/link.c",
92147 + .param4 = 1,
92148 +};
92149 +
92150 +struct size_overflow_hash _001601_hash = {
92151 + .next = NULL,
92152 + .name = "total_ps_buffered_read",
92153 + .file = "net/mac80211/debugfs.c",
92154 + .param3 = 1,
92155 +};
92156 +
92157 +struct size_overflow_hash _001602_hash = {
92158 + .next = NULL,
92159 + .name = "ts_read",
92160 + .file = "drivers/media/dvb/ddbridge/ddbridge-core.c",
92161 + .param3 = 1,
92162 +};
92163 +
92164 +struct size_overflow_hash _001603_hash = {
92165 + .next = NULL,
92166 + .name = "TSS_authhmac",
92167 + .file = "security/keys/trusted.c",
92168 + .param3 = 1,
92169 +};
92170 +
92171 +struct size_overflow_hash _001604_hash = {
92172 + .next = NULL,
92173 + .name = "TSS_checkhmac1",
92174 + .file = "security/keys/trusted.c",
92175 + .param5 = 1,
92176 +};
92177 +
92178 +struct size_overflow_hash _001605_hash = {
92179 + .next = NULL,
92180 + .name = "TSS_checkhmac2",
92181 + .file = "security/keys/trusted.c",
92182 + .param5 = 1,
92183 + .param7 = 1,
92184 +};
92185 +
92186 +struct size_overflow_hash _001607_hash = {
92187 + .next = NULL,
92188 + .name = "ts_write",
92189 + .file = "drivers/media/dvb/ddbridge/ddbridge-core.c",
92190 + .param3 = 1,
92191 +};
92192 +
92193 +struct size_overflow_hash _001608_hash = {
92194 + .next = NULL,
92195 + .name = "tx_internal_desc_overflow_read",
92196 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
92197 + .param3 = 1,
92198 +};
92199 +
92200 +struct size_overflow_hash _001609_hash = {
92201 + .next = NULL,
92202 + .name = "uapsd_max_sp_len_read",
92203 + .file = "net/mac80211/debugfs.c",
92204 + .param3 = 1,
92205 +};
92206 +
92207 +struct size_overflow_hash _001610_hash = {
92208 + .next = NULL,
92209 + .name = "uapsd_queues_read",
92210 + .file = "net/mac80211/debugfs.c",
92211 + .param3 = 1,
92212 +};
92213 +
92214 +struct size_overflow_hash _001611_hash = {
92215 + .next = NULL,
92216 + .name = "ulong_read_file",
92217 + .file = "arch/x86/oprofile/../../../drivers/oprofile/oprofilefs.c",
92218 + .param3 = 1,
92219 +};
92220 +
92221 +struct size_overflow_hash _001612_hash = {
92222 + .next = NULL,
92223 + .name = "ulong_write_file",
92224 + .file = "arch/x86/oprofile/../../../drivers/oprofile/oprofilefs.c",
92225 + .param3 = 1,
92226 +};
92227 +
92228 +struct size_overflow_hash _001613_hash = {
92229 + .next = NULL,
92230 + .name = "usb_alloc_coherent",
92231 + .file = "include/linux/usb.h",
92232 + .param2 = 1,
92233 +};
92234 +
92235 +struct size_overflow_hash _001614_hash = {
92236 + .next = NULL,
92237 + .name = "user_power_read",
92238 + .file = "net/mac80211/debugfs.c",
92239 + .param3 = 1,
92240 +};
92241 +
92242 +struct size_overflow_hash _001615_hash = {
92243 + .next = NULL,
92244 + .name = "vb2_read",
92245 + .file = "include/media/videobuf2-core.h",
92246 + .param3 = 1,
92247 +};
92248 +
92249 +struct size_overflow_hash _001616_hash = {
92250 + .next = NULL,
92251 + .name = "vb2_write",
92252 + .file = "include/media/videobuf2-core.h",
92253 + .param3 = 1,
92254 +};
92255 +
92256 +struct size_overflow_hash _001617_hash = {
92257 + .next = NULL,
92258 + .name = "vhost_add_used_n",
92259 + .file = "drivers/vhost/vhost.c",
92260 + .param3 = 1,
92261 +};
92262 +
92263 +struct size_overflow_hash _001618_hash = {
92264 + .next = NULL,
92265 + .name = "virtqueue_add_buf",
92266 + .file = "include/linux/virtio.h",
92267 + .param3 = 1,
92268 + .param4 = 1,
92269 +};
92270 +
92271 +struct size_overflow_hash _001620_hash = {
92272 + .next = NULL,
92273 + .name = "vmbus_establish_gpadl",
92274 + .file = "include/linux/hyperv.h",
92275 + .param3 = 1,
92276 +};
92277 +
92278 +struct size_overflow_hash _001621_hash = {
92279 + .next = NULL,
92280 + .name = "wep_addr_key_count_read",
92281 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
92282 + .param3 = 1,
92283 +};
92284 +
92285 +struct size_overflow_hash _001622_hash = {
92286 + .next = NULL,
92287 + .name = "wep_decrypt_fail_read",
92288 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
92289 + .param3 = 1,
92290 +};
92291 +
92292 +struct size_overflow_hash _001623_hash = {
92293 + .next = NULL,
92294 + .name = "wep_default_key_count_read",
92295 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
92296 + .param3 = 1,
92297 +};
92298 +
92299 +struct size_overflow_hash _001624_hash = {
92300 + .next = NULL,
92301 + .name = "wep_interrupt_read",
92302 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
92303 + .param3 = 1,
92304 +};
92305 +
92306 +struct size_overflow_hash _001625_hash = {
92307 + .next = NULL,
92308 + .name = "wep_iv_read",
92309 + .file = "net/mac80211/debugfs.c",
92310 + .param3 = 1,
92311 +};
92312 +
92313 +struct size_overflow_hash _001626_hash = {
92314 + .next = NULL,
92315 + .name = "wep_key_not_found_read",
92316 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
92317 + .param3 = 1,
92318 +};
92319 +
92320 +struct size_overflow_hash _001627_hash = {
92321 + .next = NULL,
92322 + .name = "wep_packets_read",
92323 + .file = "drivers/net/wireless/wl12xx/debugfs.c",
92324 + .param3 = 1,
92325 +};
92326 +
92327 +struct size_overflow_hash _001628_hash = {
92328 + .next = NULL,
92329 + .name = "write_led",
92330 + .file = "drivers/platform/x86/asus_acpi.c",
92331 + .param2 = 1,
92332 +};
92333 +
92334 +struct size_overflow_hash _001629_hash = {
92335 + .next = NULL,
92336 + .name = "wusb_prf",
92337 + .file = "include/linux/usb/wusb.h",
92338 + .param7 = 1,
92339 +};
92340 +
92341 +struct size_overflow_hash _001630_hash = {
92342 + .next = NULL,
92343 + .name = "zd_usb_iowrite16v",
92344 + .file = "drivers/net/wireless/zd1211rw/zd_usb.c",
92345 + .param3 = 1,
92346 +};
92347 +
92348 +struct size_overflow_hash _001631_hash = {
92349 + .next = NULL,
92350 + .name = "afs_cell_lookup",
92351 + .file = "fs/afs/cell.c",
92352 + .param2 = 1,
92353 +};
92354 +
92355 +struct size_overflow_hash _001632_hash = {
92356 + .next = NULL,
92357 + .name = "agp_generic_alloc_user",
92358 + .file = "drivers/char/agp/generic.c",
92359 + .param1 = 1,
92360 +};
92361 +
92362 +struct size_overflow_hash _001634_hash = {
92363 + .next = NULL,
92364 + .name = "bluetooth_proc_write",
92365 + .file = "drivers/platform/x86/asus_acpi.c",
92366 + .param3 = 1,
92367 +};
92368 +
92369 +struct size_overflow_hash _001635_hash = {
92370 + .next = NULL,
92371 + .name = "cache_write",
92372 + .file = "net/sunrpc/cache.c",
92373 + .param3 = 1,
92374 +};
92375 +
92376 +struct size_overflow_hash _001636_hash = {
92377 + .next = NULL,
92378 + .name = "ch_do_scsi",
92379 + .file = "drivers/scsi/ch.c",
92380 + .param4 = 1,
92381 +};
92382 +
92383 +struct size_overflow_hash _001637_hash = {
92384 + .next = NULL,
92385 + .name = "cx18_read",
92386 + .file = "drivers/media/video/cx18/cx18-fileops.c",
92387 + .param3 = 1,
92388 +};
92389 +
92390 +struct size_overflow_hash _001638_hash = {
92391 + .next = NULL,
92392 + .name = "dccp_feat_register_sp",
92393 + .file = "net/dccp/feat.c",
92394 + .param5 = 1,
92395 +};
92396 +
92397 +struct size_overflow_hash _001640_hash = {
92398 + .next = NULL,
92399 + .name = "iso_alloc_urb",
92400 + .file = "drivers/usb/misc/usbtest.c",
92401 + .param5 = 1,
92402 +};
92403 +
92404 +struct size_overflow_hash _001641_hash = {
92405 + .next = NULL,
92406 + .name = "ivtv_read_pos",
92407 + .file = "drivers/media/video/ivtv/ivtv-fileops.c",
92408 + .param3 = 1,
92409 +};
92410 +
92411 +struct size_overflow_hash _001642_hash = {
92412 + .next = NULL,
92413 + .name = "mcam_v4l_read",
92414 + .file = "drivers/media/video/marvell-ccic/mcam-core.c",
92415 + .param3 = 1,
92416 +};
92417 +
92418 +struct size_overflow_hash _001643_hash = {
92419 + .next = NULL,
92420 + .name = "mled_proc_write",
92421 + .file = "drivers/platform/x86/asus_acpi.c",
92422 + .param3 = 1,
92423 +};
92424 +
92425 +struct size_overflow_hash _001644_hash = {
92426 + .next = NULL,
92427 + .name = "nfs_idmap_lookup_id",
92428 + .file = "fs/nfs/idmap.c",
92429 + .param2 = 1,
92430 +};
92431 +
92432 +struct size_overflow_hash _001645_hash = {
92433 + .next = NULL,
92434 + .name = "ocfs2_control_write",
92435 + .file = "fs/ocfs2/stack_user.c",
92436 + .param3 = 1,
92437 +};
92438 +
92439 +struct size_overflow_hash _001646_hash = {
92440 + .next = NULL,
92441 + .name = "osd_req_list_dev_partitions",
92442 + .file = "include/scsi/osd_initiator.h",
92443 + .param4 = 1,
92444 +};
92445 +
92446 +struct size_overflow_hash _001647_hash = {
92447 + .next = NULL,
92448 + .name = "osd_req_list_partition_collections",
92449 + .file = "include/scsi/osd_initiator.h",
92450 + .param5 = 1,
92451 +};
92452 +
92453 +struct size_overflow_hash _001648_hash = {
92454 + .next = NULL,
92455 + .name = "pwc_video_read",
92456 + .file = "drivers/media/video/pwc/pwc-if.c",
92457 + .param3 = 1,
92458 +};
92459 +
92460 +struct size_overflow_hash _001649_hash = {
92461 + .next = NULL,
92462 + .name = "scsi_vpd_inquiry",
92463 + .file = "drivers/scsi/scsi.c",
92464 + .param4 = 1,
92465 +};
92466 +
92467 +struct size_overflow_hash _001650_hash = {
92468 + .next = NULL,
92469 + .name = "snd_gf1_mem_proc_dump",
92470 + .file = "sound/isa/gus/gus_mem_proc.c",
92471 + .param5 = 1,
92472 +};
92473 +
92474 +struct size_overflow_hash _001651_hash = {
92475 + .next = NULL,
92476 + .name = "spi_dv_device_echo_buffer",
92477 + .file = "drivers/scsi/scsi_transport_spi.c",
92478 + .param2 = 1,
92479 + .param3 = 1,
92480 +};
92481 +
92482 +struct size_overflow_hash _001653_hash = {
92483 + .next = NULL,
92484 + .name = "tled_proc_write",
92485 + .file = "drivers/platform/x86/asus_acpi.c",
92486 + .param3 = 1,
92487 +};
92488 +
92489 +struct size_overflow_hash _001655_hash = {
92490 + .next = NULL,
92491 + .name = "usb_allocate_stream_buffers",
92492 + .file = "drivers/media/dvb/dvb-usb/usb-urb.c",
92493 + .param3 = 1,
92494 +};
92495 +
92496 +struct size_overflow_hash _001656_hash = {
92497 + .next = NULL,
92498 + .name = "_usb_writeN_sync",
92499 + .file = "drivers/net/wireless/rtlwifi/usb.c",
92500 + .param4 = 1,
92501 +};
92502 +
92503 +struct size_overflow_hash _001657_hash = {
92504 + .next = NULL,
92505 + .name = "vhost_add_used_and_signal_n",
92506 + .file = "drivers/vhost/vhost.c",
92507 + .param4 = 1,
92508 +};
92509 +
92510 +struct size_overflow_hash _001658_hash = {
92511 + .next = NULL,
92512 + .name = "vmbus_open",
92513 + .file = "include/linux/hyperv.h",
92514 + .param2 = 1,
92515 + .param3 = 1,
92516 +};
92517 +
92518 +struct size_overflow_hash _001660_hash = {
92519 + .next = NULL,
92520 + .name = "wled_proc_write",
92521 + .file = "drivers/platform/x86/asus_acpi.c",
92522 + .param3 = 1,
92523 +};
92524 +
92525 +struct size_overflow_hash _001661_hash = {
92526 + .next = NULL,
92527 + .name = "wusb_prf_256",
92528 + .file = "include/linux/usb/wusb.h",
92529 + .param7 = 1,
92530 +};
92531 +
92532 +struct size_overflow_hash _001662_hash = {
92533 + .next = NULL,
92534 + .name = "wusb_prf_64",
92535 + .file = "include/linux/usb/wusb.h",
92536 + .param7 = 1,
92537 +};
92538 +
92539 +struct size_overflow_hash _001663_hash = {
92540 + .next = NULL,
92541 + .name = "agp_allocate_memory",
92542 + .file = "include/linux/agp_backend.h",
92543 + .param2 = 1,
92544 +};
92545 +
92546 +struct size_overflow_hash _001664_hash = {
92547 + .next = NULL,
92548 + .name = "cx18_read_pos",
92549 + .file = "drivers/media/video/cx18/cx18-fileops.c",
92550 + .param3 = 1,
92551 +};
92552 +
92553 +struct size_overflow_hash _001665_hash = {
92554 + .next = NULL,
92555 + .name = "nfs_map_group_to_gid",
92556 + .file = "include/linux/nfs_idmap.h",
92557 + .param3 = 1,
92558 +};
92559 +
92560 +struct size_overflow_hash _001666_hash = {
92561 + .next = NULL,
92562 + .name = "nfs_map_name_to_uid",
92563 + .file = "include/linux/nfs_idmap.h",
92564 + .param3 = 1,
92565 +};
92566 +
92567 +struct size_overflow_hash _001667_hash = {
92568 + .next = NULL,
92569 + .name = "test_iso_queue",
92570 + .file = "drivers/usb/misc/usbtest.c",
92571 + .param5 = 1,
92572 +};
92573 +
92574 +struct size_overflow_hash _001668_hash = {
92575 + .next = NULL,
92576 + .name = "agp_allocate_memory_wrap",
92577 + .file = "drivers/char/agp/frontend.c",
92578 + .param1 = 1,
92579 +};
92580 +
92581 +struct size_overflow_hash _001669_hash = {
92582 + .next = NULL,
92583 + .name = "alloc_irq_cpu_rmap",
92584 + .file = "include/linux/cpu_rmap.h",
92585 + .param1 = 1,
92586 +};
92587 +
92588 +struct size_overflow_hash _001670_hash = {
92589 + .next = NULL,
92590 + .name = "alloc_ring",
92591 + .file = "drivers/net/ethernet/chelsio/cxgb4/sge.c",
92592 + .param2 = 1,
92593 + .param4 = 1,
92594 +};
92595 +
92596 +struct size_overflow_hash _001672_hash = {
92597 + .next = &_001124_hash,
92598 + .name = "atomic_counters_read",
92599 + .file = "drivers/infiniband/hw/ipath/ipath_fs.c",
92600 + .param3 = 1,
92601 +};
92602 +
92603 +struct size_overflow_hash _001673_hash = {
92604 + .next = NULL,
92605 + .name = "atomic_stats_read",
92606 + .file = "drivers/infiniband/hw/ipath/ipath_fs.c",
92607 + .param3 = 1,
92608 +};
92609 +
92610 +struct size_overflow_hash _001674_hash = {
92611 + .next = NULL,
92612 + .name = "c4iw_init_resource_fifo",
92613 + .file = "drivers/infiniband/hw/cxgb4/resource.c",
92614 + .param3 = 1,
92615 +};
92616 +
92617 +struct size_overflow_hash _001675_hash = {
92618 + .next = NULL,
92619 + .name = "c4iw_init_resource_fifo_random",
92620 + .file = "drivers/infiniband/hw/cxgb4/resource.c",
92621 + .param3 = 1,
92622 +};
92623 +
92624 +struct size_overflow_hash _001676_hash = {
92625 + .next = NULL,
92626 + .name = "compat_do_arpt_set_ctl",
92627 + .file = "net/ipv4/netfilter/arp_tables.c",
92628 + .param4 = 1,
92629 +};
92630 +
92631 +struct size_overflow_hash _001677_hash = {
92632 + .next = NULL,
92633 + .name = "compat_do_ip6t_set_ctl",
92634 + .file = "net/ipv6/netfilter/ip6_tables.c",
92635 + .param4 = 1,
92636 +};
92637 +
92638 +struct size_overflow_hash _001678_hash = {
92639 + .next = NULL,
92640 + .name = "compat_do_ipt_set_ctl",
92641 + .file = "net/ipv4/netfilter/ip_tables.c",
92642 + .param4 = 1,
92643 +};
92644 +
92645 +struct size_overflow_hash _001679_hash = {
92646 + .next = NULL,
92647 + .name = "cxio_init_resource_fifo",
92648 + .file = "drivers/infiniband/hw/cxgb3/cxio_resource.c",
92649 + .param3 = 1,
92650 +};
92651 +
92652 +struct size_overflow_hash _001680_hash = {
92653 + .next = NULL,
92654 + .name = "cxio_init_resource_fifo_random",
92655 + .file = "drivers/infiniband/hw/cxgb3/cxio_resource.c",
92656 + .param3 = 1,
92657 +};
92658 +
92659 +struct size_overflow_hash _001681_hash = {
92660 + .next = NULL,
92661 + .name = "dev_counters_read",
92662 + .file = "drivers/infiniband/hw/qib/qib_fs.c",
92663 + .param3 = 1,
92664 +};
92665 +
92666 +struct size_overflow_hash _001682_hash = {
92667 + .next = NULL,
92668 + .name = "dev_names_read",
92669 + .file = "drivers/infiniband/hw/qib/qib_fs.c",
92670 + .param3 = 1,
92671 +};
92672 +
92673 +struct size_overflow_hash _001683_hash = {
92674 + .next = &_001468_hash,
92675 + .name = "do_arpt_set_ctl",
92676 + .file = "net/ipv4/netfilter/arp_tables.c",
92677 + .param4 = 1,
92678 +};
92679 +
92680 +struct size_overflow_hash _001684_hash = {
92681 + .next = NULL,
92682 + .name = "do_ip6t_set_ctl",
92683 + .file = "net/ipv6/netfilter/ip6_tables.c",
92684 + .param4 = 1,
92685 +};
92686 +
92687 +struct size_overflow_hash _001685_hash = {
92688 + .next = NULL,
92689 + .name = "do_ipt_set_ctl",
92690 + .file = "net/ipv4/netfilter/ip_tables.c",
92691 + .param4 = 1,
92692 +};
92693 +
92694 +struct size_overflow_hash _001686_hash = {
92695 + .next = NULL,
92696 + .name = "drbd_bm_resize",
92697 + .file = "drivers/block/drbd/drbd_bitmap.c",
92698 + .param2 = 1,
92699 +};
92700 +
92701 +struct size_overflow_hash _001687_hash = {
92702 + .next = NULL,
92703 + .name = "driver_names_read",
92704 + .file = "drivers/infiniband/hw/qib/qib_fs.c",
92705 + .param3 = 1,
92706 +};
92707 +
92708 +struct size_overflow_hash _001688_hash = {
92709 + .next = NULL,
92710 + .name = "driver_stats_read",
92711 + .file = "drivers/infiniband/hw/qib/qib_fs.c",
92712 + .param3 = 1,
92713 +};
92714 +
92715 +struct size_overflow_hash _001689_hash = {
92716 + .next = NULL,
92717 + .name = "flash_read",
92718 + .file = "drivers/infiniband/hw/qib/qib_fs.c",
92719 + .param3 = 1,
92720 +};
92721 +
92722 +struct size_overflow_hash _001690_hash = {
92723 + .next = NULL,
92724 + .name = "flash_read",
92725 + .file = "drivers/infiniband/hw/ipath/ipath_fs.c",
92726 + .param3 = 1,
92727 +};
92728 +
92729 +struct size_overflow_hash _001691_hash = {
92730 + .next = NULL,
92731 + .name = "flash_write",
92732 + .file = "drivers/infiniband/hw/qib/qib_fs.c",
92733 + .param3 = 1,
92734 +};
92735 +
92736 +struct size_overflow_hash _001692_hash = {
92737 + .next = NULL,
92738 + .name = "flash_write",
92739 + .file = "drivers/infiniband/hw/ipath/ipath_fs.c",
92740 + .param3 = 1,
92741 +};
92742 +
92743 +struct size_overflow_hash _001693_hash = {
92744 + .next = NULL,
92745 + .name = "ghash_async_setkey",
92746 + .file = "arch/x86/crypto/ghash-clmulni-intel_glue.c",
92747 + .param3 = 1,
92748 +};
92749 +
92750 +struct size_overflow_hash _001694_hash = {
92751 + .next = NULL,
92752 + .name = "handle_eviocgbit",
92753 + .file = "drivers/input/evdev.c",
92754 + .param3 = 1,
92755 +};
92756 +
92757 +struct size_overflow_hash _001695_hash = {
92758 + .next = NULL,
92759 + .name = "hid_parse_report",
92760 + .file = "include/linux/hid.h",
92761 + .param3 = 1,
92762 +};
92763 +
92764 +struct size_overflow_hash _001696_hash = {
92765 + .next = NULL,
92766 + .name = "ipath_get_base_info",
92767 + .file = "drivers/infiniband/hw/ipath/ipath_file_ops.c",
92768 + .param3 = 1,
92769 +};
92770 +
92771 +struct size_overflow_hash _001697_hash = {
92772 + .next = NULL,
92773 + .name = "options_write",
92774 + .file = "drivers/misc/sgi-gru/gruprocfs.c",
92775 + .param3 = 1,
92776 +};
92777 +
92778 +struct size_overflow_hash _001698_hash = {
92779 + .next = NULL,
92780 + .name = "portcntrs_1_read",
92781 + .file = "drivers/infiniband/hw/qib/qib_fs.c",
92782 + .param3 = 1,
92783 +};
92784 +
92785 +struct size_overflow_hash _001699_hash = {
92786 + .next = NULL,
92787 + .name = "portcntrs_2_read",
92788 + .file = "drivers/infiniband/hw/qib/qib_fs.c",
92789 + .param3 = 1,
92790 +};
92791 +
92792 +struct size_overflow_hash _001700_hash = {
92793 + .next = NULL,
92794 + .name = "portnames_read",
92795 + .file = "drivers/infiniband/hw/qib/qib_fs.c",
92796 + .param3 = 1,
92797 +};
92798 +
92799 +struct size_overflow_hash _001701_hash = {
92800 + .next = NULL,
92801 + .name = "qib_alloc_devdata",
92802 + .file = "drivers/infiniband/hw/qib/qib_init.c",
92803 + .param2 = 1,
92804 +};
92805 +
92806 +struct size_overflow_hash _001702_hash = {
92807 + .next = NULL,
92808 + .name = "qib_diag_write",
92809 + .file = "drivers/infiniband/hw/qib/qib_diag.c",
92810 + .param3 = 1,
92811 +};
92812 +
92813 +struct size_overflow_hash _001703_hash = {
92814 + .next = NULL,
92815 + .name = "qib_get_base_info",
92816 + .file = "drivers/infiniband/hw/qib/qib_file_ops.c",
92817 + .param3 = 1,
92818 +};
92819 +
92820 +struct size_overflow_hash _001704_hash = {
92821 + .next = NULL,
92822 + .name = "qsfp_1_read",
92823 + .file = "drivers/infiniband/hw/qib/qib_fs.c",
92824 + .param3 = 1,
92825 +};
92826 +
92827 +struct size_overflow_hash _001705_hash = {
92828 + .next = NULL,
92829 + .name = "qsfp_2_read",
92830 + .file = "drivers/infiniband/hw/qib/qib_fs.c",
92831 + .param3 = 1,
92832 +};
92833 +
92834 +struct size_overflow_hash _001706_hash = {
92835 + .next = NULL,
92836 + .name = "rfc4106_set_key",
92837 + .file = "arch/x86/crypto/aesni-intel_glue.c",
92838 + .param3 = 1,
92839 +};
92840 +
92841 +struct size_overflow_hash _001707_hash = {
92842 + .next = &_000258_hash,
92843 + .name = "stats_read_ul",
92844 + .file = "drivers/idle/i7300_idle.c",
92845 + .param3 = 1,
92846 +};
92847 +
92848 +struct size_overflow_hash _001708_hash = {
92849 + .next = NULL,
92850 + .name = "xpc_kmalloc_cacheline_aligned",
92851 + .file = "drivers/misc/sgi-xp/xpc_partition.c",
92852 + .param1 = 1,
92853 +};
92854 +
92855 +struct size_overflow_hash _001709_hash = {
92856 + .next = NULL,
92857 + .name = "xpc_kzalloc_cacheline_aligned",
92858 + .file = "drivers/misc/sgi-xp/xpc_main.c",
92859 + .param1 = 1,
92860 +};
92861 +
92862 +struct size_overflow_hash _001710_hash = {
92863 + .next = NULL,
92864 + .name = "c4iw_init_resource",
92865 + .file = "drivers/infiniband/hw/cxgb4/resource.c",
92866 + .param2 = 1,
92867 + .param3 = 1,
92868 +};
92869 +
92870 +struct size_overflow_hash _001712_hash = {
92871 + .next = NULL,
92872 + .name = "cxio_hal_init_resource",
92873 + .file = "drivers/infiniband/hw/cxgb3/cxio_resource.c",
92874 + .param2 = 1,
92875 + .param7 = 1,
92876 + .param6 = 1,
92877 +};
92878 +
92879 +struct size_overflow_hash _001715_hash = {
92880 + .next = &_000734_hash,
92881 + .name = "cxio_hal_init_rhdl_resource",
92882 + .file = "drivers/infiniband/hw/cxgb3/cxio_resource.c",
92883 + .param1 = 1,
92884 +};
92885 +
92886 +struct size_overflow_hash _001716_hash = {
92887 + .next = NULL,
92888 + .name = "amthi_read",
92889 + .file = "drivers/staging/mei/iorw.c",
92890 + .param4 = 1,
92891 +};
92892 +
92893 +struct size_overflow_hash _001717_hash = {
92894 + .next = NULL,
92895 + .name = "bcm_char_read",
92896 + .file = "drivers/staging/bcm/Bcmchar.c",
92897 + .param3 = 1,
92898 +};
92899 +
92900 +struct size_overflow_hash _001718_hash = {
92901 + .next = NULL,
92902 + .name = "BcmCopySection",
92903 + .file = "drivers/staging/bcm/nvm.c",
92904 + .param5 = 1,
92905 +};
92906 +
92907 +struct size_overflow_hash _001719_hash = {
92908 + .next = NULL,
92909 + .name = "buffer_from_user",
92910 + .file = "drivers/staging/vme/devices/vme_user.c",
92911 + .param3 = 1,
92912 +};
92913 +
92914 +struct size_overflow_hash _001720_hash = {
92915 + .next = NULL,
92916 + .name = "buffer_to_user",
92917 + .file = "drivers/staging/vme/devices/vme_user.c",
92918 + .param3 = 1,
92919 +};
92920 +
92921 +struct size_overflow_hash _001721_hash = {
92922 + .next = NULL,
92923 + .name = "capabilities_read",
92924 + .file = "drivers/xen/xenfs/super.c",
92925 + .param3 = 1,
92926 +};
92927 +
92928 +struct size_overflow_hash _001722_hash = {
92929 + .next = NULL,
92930 + .name = "chd_dec_fetch_cdata",
92931 + .file = "drivers/staging/crystalhd/crystalhd_lnx.c",
92932 + .param3 = 1,
92933 +};
92934 +
92935 +struct size_overflow_hash _001723_hash = {
92936 + .next = NULL,
92937 + .name = "create_bounce_buffer",
92938 + .file = "drivers/staging/hv/storvsc_drv.c",
92939 + .param3 = 1,
92940 +};
92941 +
92942 +struct size_overflow_hash _001724_hash = {
92943 + .next = NULL,
92944 + .name = "crystalhd_create_dio_pool",
92945 + .file = "drivers/staging/crystalhd/crystalhd_misc.c",
92946 + .param2 = 1,
92947 +};
92948 +
92949 +struct size_overflow_hash _001725_hash = {
92950 + .next = NULL,
92951 + .name = "do_read_log_to_user",
92952 + .file = "drivers/staging/android/logger.c",
92953 + .param4 = 1,
92954 +};
92955 +
92956 +struct size_overflow_hash _001726_hash = {
92957 + .next = NULL,
92958 + .name = "do_write_log_from_user",
92959 + .file = "drivers/staging/android/logger.c",
92960 + .param3 = 1,
92961 +};
92962 +
92963 +struct size_overflow_hash _001727_hash = {
92964 + .next = NULL,
92965 + .name = "dt3155_read",
92966 + .file = "drivers/staging/media/dt3155v4l/dt3155v4l.c",
92967 + .param3 = 1,
92968 +};
92969 +
92970 +struct size_overflow_hash _001728_hash = {
92971 + .next = NULL,
92972 + .name = "easycap_alsa_vmalloc",
92973 + .file = "drivers/staging/media/easycap/easycap_sound.c",
92974 + .param2 = 1,
92975 +};
92976 +
92977 +struct size_overflow_hash _001729_hash = {
92978 + .next = NULL,
92979 + .name = "evm_read_key",
92980 + .file = "security/integrity/evm/evm_secfs.c",
92981 + .param3 = 1,
92982 +};
92983 +
92984 +struct size_overflow_hash _001730_hash = {
92985 + .next = NULL,
92986 + .name = "evm_write_key",
92987 + .file = "security/integrity/evm/evm_secfs.c",
92988 + .param3 = 1,
92989 +};
92990 +
92991 +struct size_overflow_hash _001731_hash = {
92992 + .next = NULL,
92993 + .name = "evtchn_read",
92994 + .file = "drivers/xen/evtchn.c",
92995 + .param3 = 1,
92996 +};
92997 +
92998 +struct size_overflow_hash _001732_hash = {
92999 + .next = NULL,
93000 + .name = "gather_array",
93001 + .file = "drivers/xen/privcmd.c",
93002 + .param3 = 1,
93003 +};
93004 +
93005 +struct size_overflow_hash _001733_hash = {
93006 + .next = NULL,
93007 + .name = "gnttab_map",
93008 + .file = "drivers/xen/grant-table.c",
93009 + .param2 = 1,
93010 +};
93011 +
93012 +struct size_overflow_hash _001734_hash = {
93013 + .next = NULL,
93014 + .name = "iio_read_first_n_kfifo",
93015 + .file = "drivers/staging/iio/kfifo_buf.c",
93016 + .param2 = 1,
93017 +};
93018 +
93019 +struct size_overflow_hash _001735_hash = {
93020 + .next = NULL,
93021 + .name = "iio_read_first_n_sw_rb",
93022 + .file = "drivers/staging/iio/ring_sw.c",
93023 + .param2 = 1,
93024 +};
93025 +
93026 +struct size_overflow_hash _001736_hash = {
93027 + .next = NULL,
93028 + .name = "keymap_store",
93029 + .file = "drivers/staging/speakup/kobjects.c",
93030 + .param4 = 1,
93031 +};
93032 +
93033 +struct size_overflow_hash _001737_hash = {
93034 + .next = NULL,
93035 + .name = "line6_dumpreq_initbuf",
93036 + .file = "drivers/staging/line6/dumprequest.c",
93037 + .param3 = 1,
93038 +};
93039 +
93040 +struct size_overflow_hash _001738_hash = {
93041 + .next = NULL,
93042 + .name = "lirc_write",
93043 + .file = "drivers/staging/media/lirc/lirc_parallel.c",
93044 + .param3 = 1,
93045 +};
93046 +
93047 +struct size_overflow_hash _001739_hash = {
93048 + .next = NULL,
93049 + .name = "lirc_write",
93050 + .file = "drivers/staging/media/lirc/lirc_sir.c",
93051 + .param3 = 1,
93052 +};
93053 +
93054 +struct size_overflow_hash _001740_hash = {
93055 + .next = &_000815_hash,
93056 + .name = "lirc_write",
93057 + .file = "drivers/staging/media/lirc/lirc_serial.c",
93058 + .param3 = 1,
93059 +};
93060 +
93061 +struct size_overflow_hash _001741_hash = {
93062 + .next = &_001021_hash,
93063 + .name = "_malloc",
93064 + .file = "drivers/staging/rtl8712/osdep_service.h",
93065 + .param1 = 1,
93066 +};
93067 +
93068 +struct size_overflow_hash _001742_hash = {
93069 + .next = NULL,
93070 + .name = "mei_read",
93071 + .file = "drivers/staging/mei/main.c",
93072 + .param3 = 1,
93073 +};
93074 +
93075 +struct size_overflow_hash _001743_hash = {
93076 + .next = NULL,
93077 + .name = "mei_write",
93078 + .file = "drivers/staging/mei/main.c",
93079 + .param3 = 1,
93080 +};
93081 +
93082 +struct size_overflow_hash _001744_hash = {
93083 + .next = NULL,
93084 + .name = "msg_set",
93085 + .file = "drivers/staging/speakup/i18n.c",
93086 + .param3 = 1,
93087 +};
93088 +
93089 +struct size_overflow_hash _001745_hash = {
93090 + .next = NULL,
93091 + .name = "OS_kmalloc",
93092 + .file = "drivers/staging/cxt1e1/sbecom_inline_linux.h",
93093 + .param1 = 1,
93094 +};
93095 +
93096 +struct size_overflow_hash _001746_hash = {
93097 + .next = NULL,
93098 + .name = "queue_reply",
93099 + .file = "drivers/xen/xenbus/xenbus_dev_frontend.c",
93100 + .param3 = 1,
93101 +};
93102 +
93103 +struct size_overflow_hash _001747_hash = {
93104 + .next = &_000841_hash,
93105 + .name = "resource_from_user",
93106 + .file = "drivers/staging/vme/devices/vme_user.c",
93107 + .param3 = 1,
93108 +};
93109 +
93110 +struct size_overflow_hash _001748_hash = {
93111 + .next = NULL,
93112 + .name = "sca3000_read_first_n_hw_rb",
93113 + .file = "drivers/staging/iio/accel/sca3000_ring.c",
93114 + .param2 = 1,
93115 +};
93116 +
93117 +struct size_overflow_hash _001749_hash = {
93118 + .next = NULL,
93119 + .name = "sep_lock_user_pages",
93120 + .file = "drivers/staging/sep/sep_driver.c",
93121 + .param2 = 1,
93122 + .param3 = 1,
93123 +};
93124 +
93125 +struct size_overflow_hash _001751_hash = {
93126 + .next = NULL,
93127 + .name = "sep_prepare_input_output_dma_table_in_dcb",
93128 + .file = "drivers/staging/sep/sep_driver.c",
93129 + .param4 = 1,
93130 + .param5 = 1,
93131 + .param2 = 1,
93132 + .param3 = 1,
93133 +};
93134 +
93135 +struct size_overflow_hash _001753_hash = {
93136 + .next = NULL,
93137 + .name = "split",
93138 + .file = "drivers/xen/xenbus/xenbus_xs.c",
93139 + .param2 = 1,
93140 +};
93141 +
93142 +struct size_overflow_hash _001754_hash = {
93143 + .next = NULL,
93144 + .name = "storvsc_connect_to_vsp",
93145 + .file = "drivers/staging/hv/storvsc_drv.c",
93146 + .param2 = 1,
93147 +};
93148 +
93149 +struct size_overflow_hash _001755_hash = {
93150 + .next = NULL,
93151 + .name = "u32_array_read",
93152 + .file = "arch/x86/xen/debugfs.c",
93153 + .param3 = 1,
93154 +};
93155 +
93156 +struct size_overflow_hash _001756_hash = {
93157 + .next = NULL,
93158 + .name = "ValidateDSDParamsChecksum",
93159 + .file = "drivers/staging/bcm/led_control.c",
93160 + .param3 = 1,
93161 +};
93162 +
93163 +struct size_overflow_hash _001757_hash = {
93164 + .next = NULL,
93165 + .name = "vfd_write",
93166 + .file = "drivers/staging/media/lirc/lirc_sasem.c",
93167 + .param3 = 1,
93168 +};
93169 +
93170 +struct size_overflow_hash _001758_hash = {
93171 + .next = NULL,
93172 + .name = "vfd_write",
93173 + .file = "drivers/staging/media/lirc/lirc_imon.c",
93174 + .param3 = 1,
93175 +};
93176 +
93177 +struct size_overflow_hash _001759_hash = {
93178 + .next = NULL,
93179 + .name = "Wb35Reg_BurstWrite",
93180 + .file = "drivers/staging/winbond/wb35reg.c",
93181 + .param4 = 1,
93182 +};
93183 +
93184 +struct size_overflow_hash _001760_hash = {
93185 + .next = NULL,
93186 + .name = "xenbus_file_write",
93187 + .file = "drivers/xen/xenbus/xenbus_dev_frontend.c",
93188 + .param3 = 1,
93189 +};
93190 +
93191 +struct size_overflow_hash _001761_hash = {
93192 + .next = NULL,
93193 + .name = "xsd_read",
93194 + .file = "drivers/xen/xenfs/xenstored.c",
93195 + .param3 = 1,
93196 +};
93197 +
93198 +struct size_overflow_hash _001762_hash = {
93199 + .next = NULL,
93200 + .name = "line6_dumpreq_init",
93201 + .file = "drivers/staging/line6/dumprequest.c",
93202 + .param3 = 1,
93203 +};
93204 +
93205 +struct size_overflow_hash _001763_hash = {
93206 + .next = NULL,
93207 + .name = "r8712_usbctrl_vendorreq",
93208 + .file = "drivers/staging/rtl8712/usb_ops_linux.c",
93209 + .param6 = 1,
93210 +};
93211 +
93212 +struct size_overflow_hash _001764_hash = {
93213 + .next = NULL,
93214 + .name = "r871x_set_wpa_ie",
93215 + .file = "drivers/staging/rtl8712/rtl871x_ioctl_linux.c",
93216 + .param3 = 1,
93217 +};
93218 +
93219 +struct size_overflow_hash _001765_hash = {
93220 + .next = NULL,
93221 + .name = "sep_prepare_input_dma_table",
93222 + .file = "drivers/staging/sep/sep_driver.c",
93223 + .param2 = 1,
93224 + .param3 = 1,
93225 +};
93226 +
93227 +struct size_overflow_hash _001767_hash = {
93228 + .next = NULL,
93229 + .name = "sep_prepare_input_output_dma_table",
93230 + .file = "drivers/staging/sep/sep_driver.c",
93231 + .param2 = 1,
93232 + .param4 = 1,
93233 + .param3 = 1,
93234 +};
93235 +
93236 +struct size_overflow_hash _001770_hash = {
93237 + .next = NULL,
93238 + .name = "vme_user_write",
93239 + .file = "drivers/staging/vme/devices/vme_user.c",
93240 + .param3 = 1,
93241 +};
93242 +
93243 +struct size_overflow_hash _001771_hash = {
93244 + .next = NULL,
93245 + .name = "alloc_ebda_hpc",
93246 + .file = "drivers/pci/hotplug/ibmphp_ebda.c",
93247 + .param1 = 1,
93248 + .param2 = 1,
93249 +};
93250 +
93251 +struct size_overflow_hash _001772_hash = {
93252 + .next = NULL,
93253 + .name = "alloc_apertures",
93254 + .file = "include/linux/fb.h",
93255 + .param1 = 1,
93256 +};
93257 +
93258 +struct size_overflow_hash _001773_hash = {
93259 + .next = NULL,
93260 + .name = "bin_uuid",
93261 + .file = "kernel/sysctl_binary.c",
93262 + .param3 = 1,
93263 +};
93264 +
93265 +struct size_overflow_hash _001774_hash = {
93266 + .next = &_000640_hash,
93267 + .name = "__copy_from_user_inatomic_nocache",
93268 + .file = "arch/x86/include/asm/uaccess_64.h",
93269 + .param3 = 1,
93270 +};
93271 +
93272 +struct size_overflow_hash _001775_hash = {
93273 + .next = NULL,
93274 + .name = "do_dmabuf_dirty_sou",
93275 + .file = "drivers/gpu/drm/vmwgfx/vmwgfx_kms.c",
93276 + .param7 = 1,
93277 +};
93278 +
93279 +struct size_overflow_hash _001776_hash = {
93280 + .next = NULL,
93281 + .name = "do_surface_dirty_sou",
93282 + .file = "drivers/gpu/drm/vmwgfx/vmwgfx_kms.c",
93283 + .param7 = 1,
93284 +};
93285 +
93286 +struct size_overflow_hash _001777_hash = {
93287 + .next = NULL,
93288 + .name = "drm_agp_bind_pages",
93289 + .file = "drivers/gpu/drm/drm_agpsupport.c",
93290 + .param3 = 1,
93291 +};
93292 +
93293 +struct size_overflow_hash _001778_hash = {
93294 + .next = NULL,
93295 + .name = "drm_calloc_large",
93296 + .file = "include/drm/drm_mem_util.h",
93297 + .param1 = 1,
93298 + .param2 = 1,
93299 +};
93300 +
93301 +struct size_overflow_hash _001780_hash = {
93302 + .next = NULL,
93303 + .name = "drm_ht_create",
93304 + .file = "drivers/gpu/drm/drm_hashtab.c",
93305 + .param2 = 1,
93306 +};
93307 +
93308 +struct size_overflow_hash _001781_hash = {
93309 + .next = NULL,
93310 + .name = "drm_malloc_ab",
93311 + .file = "include/drm/drm_mem_util.h",
93312 + .param1 = 1,
93313 + .param2 = 1,
93314 +};
93315 +
93316 +struct size_overflow_hash _001783_hash = {
93317 + .next = NULL,
93318 + .name = "drm_plane_init",
93319 + .file = "drivers/gpu/drm/drm_crtc.c",
93320 + .param6 = 1,
93321 +};
93322 +
93323 +struct size_overflow_hash _001784_hash = {
93324 + .next = NULL,
93325 + .name = "drm_vmalloc_dma",
93326 + .file = "drivers/gpu/drm/drm_scatter.c",
93327 + .param1 = 1,
93328 +};
93329 +
93330 +struct size_overflow_hash _001785_hash = {
93331 + .next = NULL,
93332 + .name = "fb_read",
93333 + .file = "drivers/video/fbmem.c",
93334 + .param3 = 1,
93335 +};
93336 +
93337 +struct size_overflow_hash _001786_hash = {
93338 + .next = NULL,
93339 + .name = "fb_write",
93340 + .file = "drivers/video/fbmem.c",
93341 + .param3 = 1,
93342 +};
93343 +
93344 +struct size_overflow_hash _001787_hash = {
93345 + .next = NULL,
93346 + .name = "framebuffer_alloc",
93347 + .file = "include/linux/fb.h",
93348 + .param1 = 1,
93349 +};
93350 +
93351 +struct size_overflow_hash _001788_hash = {
93352 + .next = NULL,
93353 + .name = "i915_cache_sharing_read",
93354 + .file = "drivers/gpu/drm/i915/i915_debugfs.c",
93355 + .param3 = 1,
93356 +};
93357 +
93358 +struct size_overflow_hash _001789_hash = {
93359 + .next = NULL,
93360 + .name = "i915_cache_sharing_write",
93361 + .file = "drivers/gpu/drm/i915/i915_debugfs.c",
93362 + .param3 = 1,
93363 +};
93364 +
93365 +struct size_overflow_hash _001790_hash = {
93366 + .next = NULL,
93367 + .name = "i915_max_freq_read",
93368 + .file = "drivers/gpu/drm/i915/i915_debugfs.c",
93369 + .param3 = 1,
93370 +};
93371 +
93372 +struct size_overflow_hash _001791_hash = {
93373 + .next = NULL,
93374 + .name = "i915_max_freq_write",
93375 + .file = "drivers/gpu/drm/i915/i915_debugfs.c",
93376 + .param3 = 1,
93377 +};
93378 +
93379 +struct size_overflow_hash _001792_hash = {
93380 + .next = NULL,
93381 + .name = "i915_wedged_read",
93382 + .file = "drivers/gpu/drm/i915/i915_debugfs.c",
93383 + .param3 = 1,
93384 +};
93385 +
93386 +struct size_overflow_hash _001793_hash = {
93387 + .next = NULL,
93388 + .name = "i915_wedged_write",
93389 + .file = "drivers/gpu/drm/i915/i915_debugfs.c",
93390 + .param3 = 1,
93391 +};
93392 +
93393 +struct size_overflow_hash _001794_hash = {
93394 + .next = NULL,
93395 + .name = "__module_alloc",
93396 + .file = "arch/x86/kernel/module.c",
93397 + .param1 = 1,
93398 +};
93399 +
93400 +struct size_overflow_hash _001795_hash = {
93401 + .next = NULL,
93402 + .name = "module_alloc_update_bounds_rw",
93403 + .file = "kernel/module.c",
93404 + .param1 = 1,
93405 +};
93406 +
93407 +struct size_overflow_hash _001796_hash = {
93408 + .next = NULL,
93409 + .name = "module_alloc_update_bounds_rx",
93410 + .file = "kernel/module.c",
93411 + .param1 = 1,
93412 +};
93413 +
93414 +struct size_overflow_hash _001797_hash = {
93415 + .next = NULL,
93416 + .name = "p9_client_read",
93417 + .file = "include/net/9p/client.h",
93418 + .param5 = 1,
93419 +};
93420 +
93421 +struct size_overflow_hash _001798_hash = {
93422 + .next = NULL,
93423 + .name = "probe_kernel_write",
93424 + .file = "include/linux/uaccess.h",
93425 + .param3 = 1,
93426 +};
93427 +
93428 +struct size_overflow_hash _001799_hash = {
93429 + .next = NULL,
93430 + .name = "sched_feat_write",
93431 + .file = "kernel/sched/core.c",
93432 + .param3 = 1,
93433 +};
93434 +
93435 +struct size_overflow_hash _001800_hash = {
93436 + .next = NULL,
93437 + .name = "tstats_write",
93438 + .file = "kernel/time/timer_stats.c",
93439 + .param3 = 1,
93440 +};
93441 +
93442 +struct size_overflow_hash _001801_hash = {
93443 + .next = NULL,
93444 + .name = "ttm_bo_fbdev_io",
93445 + .file = "drivers/gpu/drm/ttm/ttm_bo_vm.c",
93446 + .param4 = 1,
93447 +};
93448 +
93449 +struct size_overflow_hash _001802_hash = {
93450 + .next = NULL,
93451 + .name = "ttm_bo_io",
93452 + .file = "drivers/gpu/drm/ttm/ttm_bo_vm.c",
93453 + .param5 = 1,
93454 +};
93455 +
93456 +struct size_overflow_hash _001803_hash = {
93457 + .next = NULL,
93458 + .name = "ttm_dma_page_pool_free",
93459 + .file = "drivers/gpu/drm/ttm/ttm_page_alloc_dma.c",
93460 + .param2 = 1,
93461 +};
93462 +
93463 +struct size_overflow_hash _001804_hash = {
93464 + .next = NULL,
93465 + .name = "ttm_page_pool_free",
93466 + .file = "drivers/gpu/drm/ttm/ttm_page_alloc.c",
93467 + .param2 = 1,
93468 +};
93469 +
93470 +struct size_overflow_hash _001805_hash = {
93471 + .next = NULL,
93472 + .name = "vmw_execbuf_process",
93473 + .file = "drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c",
93474 + .param5 = 1,
93475 +};
93476 +
93477 +struct size_overflow_hash _001806_hash = {
93478 + .next = NULL,
93479 + .name = "vmw_fifo_reserve",
93480 + .file = "drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c",
93481 + .param2 = 1,
93482 +};
93483 +
93484 +struct size_overflow_hash _001807_hash = {
93485 + .next = NULL,
93486 + .name = "vmw_kms_present",
93487 + .file = "drivers/gpu/drm/vmwgfx/vmwgfx_kms.c",
93488 + .param9 = 1,
93489 +};
93490 +
93491 +struct size_overflow_hash _001808_hash = {
93492 + .next = NULL,
93493 + .name = "vmw_kms_readback",
93494 + .file = "drivers/gpu/drm/vmwgfx/vmwgfx_kms.c",
93495 + .param6 = 1,
93496 +};
93497 +
93498 +struct size_overflow_hash _001809_hash = {
93499 + .next = NULL,
93500 + .name = "acpi_system_write_alarm",
93501 + .file = "drivers/acpi/proc.c",
93502 + .param3 = 1,
93503 +};
93504 +
93505 +struct size_overflow_hash _001810_hash = {
93506 + .next = NULL,
93507 + .name = "kmalloc",
93508 + .file = "include/linux/slab_def.h",
93509 + .param1 = 1,
93510 +};
93511 +
93512 +struct size_overflow_hash _001811_hash = {
93513 + .next = NULL,
93514 + .name = "slabinfo_write",
93515 + .file = "mm/slab.c",
93516 + .param3 = 1,
93517 +};
93518 +
93519 +struct size_overflow_hash *size_overflow_hash[65536] = {
93520 + [56878] = &_000001_hash,
93521 + [11151] = &_000002_hash,
93522 + [17854] = &_000003_hash,
93523 + [4132] = &_000004_hash,
93524 + [39070] = &_000005_hash,
93525 + [35447] = &_000007_hash,
93526 + [47830] = &_000008_hash,
93527 + [65254] = &_000009_hash,
93528 + [17521] = &_000011_hash,
93529 + [41425] = &_000012_hash,
93530 + [5785] = &_000013_hash,
93531 + [19960] = &_000014_hash,
93532 + [26729] = &_000015_hash,
93533 + [7954] = &_000016_hash,
93534 + [22403] = &_000017_hash,
93535 + [23258] = &_000018_hash,
93536 + [55695] = &_000019_hash,
93537 + [38964] = &_000020_hash,
93538 + [64250] = &_000021_hash,
93539 + [31825] = &_000022_hash,
93540 + [47446] = &_000023_hash,
93541 + [61521] = &_000024_hash,
93542 + [64227] = &_000025_hash,
93543 + [53378] = &_000026_hash,
93544 + [8885] = &_000027_hash,
93545 + [62101] = &_000028_hash,
93546 + [18152] = &_000029_hash,
93547 + [37525] = &_000030_hash,
93548 + [25827] = &_000031_hash,
93549 + [1169] = &_000032_hash,
93550 + [11925] = &_000033_hash,
93551 + [20558] = &_000034_hash,
93552 + [44019] = &_000035_hash,
93553 + [21909] = &_000036_hash,
93554 + [63679] = &_000037_hash,
93555 + [39450] = &_000038_hash,
93556 + [25085] = &_000039_hash,
93557 + [17830] = &_000040_hash,
93558 + [14329] = &_000041_hash,
93559 + [31235] = &_000042_hash,
93560 + [48207] = &_000043_hash,
93561 + [34918] = &_000044_hash,
93562 + [46839] = &_000045_hash,
93563 + [57930] = &_000046_hash,
93564 + [41364] = &_000047_hash,
93565 + [17581] = &_000048_hash,
93566 + [45922] = &_000049_hash,
93567 + [49567] = &_000050_hash,
93568 + [18248] = &_000051_hash,
93569 + [25528] = &_000052_hash,
93570 + [61874] = &_000053_hash,
93571 + [22591] = &_000054_hash,
93572 + [48456] = &_000055_hash,
93573 + [8743] = &_000056_hash,
93574 + [39131] = &_000057_hash,
93575 + [48328] = &_000058_hash,
93576 + [47136] = &_000059_hash,
93577 + [6358] = &_000060_hash,
93578 + [12252] = &_000061_hash,
93579 + [49340] = &_000062_hash,
93580 + [45875] = &_000063_hash,
93581 + [52182] = &_000065_hash,
93582 + [31149] = &_000067_hash,
93583 + [20455] = &_000068_hash,
93584 + [19917] = &_000070_hash,
93585 + [64771] = &_000071_hash,
93586 + [25140] = &_000072_hash,
93587 + [34097] = &_000073_hash,
93588 + [58131] = &_000074_hash,
93589 + [65311] = &_000075_hash,
93590 + [60609] = &_000076_hash,
93591 + [1917] = &_000077_hash,
93592 + [15337] = &_000078_hash,
93593 + [4732] = &_000079_hash,
93594 + [38783] = &_000080_hash,
93595 + [37249] = &_000081_hash,
93596 + [9234] = &_000082_hash,
93597 + [33309] = &_000083_hash,
93598 + [22389] = &_000084_hash,
93599 + [56319] = &_000085_hash,
93600 + [21496] = &_000086_hash,
93601 + [8163] = &_000087_hash,
93602 + [58766] = &_000088_hash,
93603 + [21048] = &_000089_hash,
93604 + [51221] = &_000090_hash,
93605 + [21498] = &_000091_hash,
93606 + [42627] = &_000092_hash,
93607 + [53059] = &_000094_hash,
93608 + [52870] = &_000095_hash,
93609 + [1567] = &_000096_hash,
93610 + [38330] = &_000097_hash,
93611 + [30892] = &_000098_hash,
93612 + [16927] = &_000099_hash,
93613 + [16461] = &_000100_hash,
93614 + [5634] = &_000101_hash,
93615 + [16496] = &_000103_hash,
93616 + [40012] = &_000104_hash,
93617 + [46014] = &_000105_hash,
93618 + [39600] = &_000106_hash,
93619 + [7435] = &_000107_hash,
93620 + [13332] = &_000109_hash,
93621 + [36665] = &_000110_hash,
93622 + [12413] = &_000111_hash,
93623 + [27279] = &_000112_hash,
93624 + [44774] = &_000113_hash,
93625 + [14479] = &_000114_hash,
93626 + [32447] = &_000115_hash,
93627 + [15439] = &_000116_hash,
93628 + [17932] = &_000117_hash,
93629 + [26096] = &_000118_hash,
93630 + [50814] = &_000119_hash,
93631 + [22598] = &_000120_hash,
93632 + [48287] = &_000121_hash,
93633 + [15611] = &_000122_hash,
93634 + [13414] = &_000123_hash,
93635 + [40371] = &_000124_hash,
93636 + [284] = &_000125_hash,
93637 + [6293] = &_000127_hash,
93638 + [60587] = &_000128_hash,
93639 + [8181] = &_000129_hash,
93640 + [27451] = &_000130_hash,
93641 + [29259] = &_000131_hash,
93642 + [41172] = &_000132_hash,
93643 + [3315] = &_000133_hash,
93644 + [37550] = &_000134_hash,
93645 + [40395] = &_000135_hash,
93646 + [24124] = &_000136_hash,
93647 + [63535] = &_000137_hash,
93648 + [14981] = &_000138_hash,
93649 + [52008] = &_000139_hash,
93650 + [22091] = &_000140_hash,
93651 + [64800] = &_000141_hash,
93652 + [14919] = &_000142_hash,
93653 + [60340] = &_000143_hash,
93654 + [34205] = &_000145_hash,
93655 + [65246] = &_000146_hash,
93656 + [1299] = &_000147_hash,
93657 + [33165] = &_000148_hash,
93658 + [22394] = &_000149_hash,
93659 + [49562] = &_000150_hash,
93660 + [56881] = &_000151_hash,
93661 + [13870] = &_000152_hash,
93662 + [65074] = &_000153_hash,
93663 + [11553] = &_000154_hash,
93664 + [43222] = &_000155_hash,
93665 + [17984] = &_000156_hash,
93666 + [26811] = &_000157_hash,
93667 + [30848] = &_000158_hash,
93668 + [15627] = &_000159_hash,
93669 + [43101] = &_000160_hash,
93670 + [4082] = &_000161_hash,
93671 + [43692] = &_000162_hash,
93672 + [21622] = &_000163_hash,
93673 + [50734] = &_000164_hash,
93674 + [803] = &_000166_hash,
93675 + [64674] = &_000168_hash,
93676 + [57538] = &_000170_hash,
93677 + [42442] = &_000171_hash,
93678 + [23031] = &_000172_hash,
93679 + [40663] = &_000173_hash,
93680 + [51180] = &_000174_hash,
93681 + [24173] = &_000175_hash,
93682 + [9286] = &_000176_hash,
93683 + [49517] = &_000177_hash,
93684 + [34878] = &_000180_hash,
93685 + [22819] = &_000181_hash,
93686 + [64314] = &_000182_hash,
93687 + [20494] = &_000183_hash,
93688 + [9483] = &_000184_hash,
93689 + [26518] = &_000185_hash,
93690 + [44651] = &_000186_hash,
93691 + [1188] = &_000187_hash,
93692 + [36031] = &_000188_hash,
93693 + [33469] = &_000189_hash,
93694 + [19672] = &_000190_hash,
93695 + [3216] = &_000191_hash,
93696 + [25071] = &_000192_hash,
93697 + [11744] = &_000194_hash,
93698 + [2358] = &_000196_hash,
93699 + [10146] = &_000198_hash,
93700 + [58709] = &_000199_hash,
93701 + [64773] = &_000200_hash,
93702 + [6159] = &_000201_hash,
93703 + [28617] = &_000202_hash,
93704 + [61067] = &_000203_hash,
93705 + [12884] = &_000204_hash,
93706 + [37308] = &_000205_hash,
93707 + [59973] = &_000206_hash,
93708 + [35895] = &_000207_hash,
93709 + [24951] = &_000208_hash,
93710 + [3070] = &_000209_hash,
93711 + [61023] = &_000210_hash,
93712 + [45702] = &_000211_hash,
93713 + [5533] = &_000212_hash,
93714 + [29186] = &_000213_hash,
93715 + [26311] = &_000214_hash,
93716 + [40182] = &_000215_hash,
93717 + [50505] = &_000216_hash,
93718 + [59061] = &_000217_hash,
93719 + [27511] = &_000218_hash,
93720 + [63286] = &_000219_hash,
93721 + [6678] = &_000220_hash,
93722 + [23065] = &_000222_hash,
93723 + [18156] = &_000223_hash,
93724 + [53757] = &_000224_hash,
93725 + [53720] = &_000225_hash,
93726 + [50241] = &_000226_hash,
93727 + [22498] = &_000227_hash,
93728 + [10991] = &_000228_hash,
93729 + [40026] = &_000229_hash,
93730 + [19995] = &_000230_hash,
93731 + [30445] = &_000231_hash,
93732 + [57691] = &_000232_hash,
93733 + [23150] = &_000233_hash,
93734 + [9960] = &_000234_hash,
93735 + [8736] = &_000235_hash,
93736 + [23750] = &_000237_hash,
93737 + [18393] = &_000238_hash,
93738 + [28541] = &_000240_hash,
93739 + [59944] = &_000241_hash,
93740 + [35042] = &_000242_hash,
93741 + [63488] = &_000243_hash,
93742 + [27286] = &_000244_hash,
93743 + [46922] = &_000245_hash,
93744 + [11860] = &_000246_hash,
93745 + [52928] = &_000247_hash,
93746 + [46714] = &_000248_hash,
93747 + [57313] = &_000249_hash,
93748 + [61978] = &_000250_hash,
93749 + [61063] = &_000251_hash,
93750 + [22271] = &_000252_hash,
93751 + [4214] = &_000253_hash,
93752 + [46247] = &_000254_hash,
93753 + [33246] = &_000255_hash,
93754 + [58325] = &_000257_hash,
93755 + [47399] = &_000259_hash,
93756 + [34963] = &_000260_hash,
93757 + [21221] = &_000261_hash,
93758 + [32211] = &_000262_hash,
93759 + [20854] = &_000263_hash,
93760 + [49351] = &_000264_hash,
93761 + [52341] = &_000265_hash,
93762 + [53533] = &_000266_hash,
93763 + [52267] = &_000267_hash,
93764 + [46753] = &_000268_hash,
93765 + [2115] = &_000269_hash,
93766 + [44017] = &_000271_hash,
93767 + [13495] = &_000272_hash,
93768 + [12988] = &_000273_hash,
93769 + [55227] = &_000274_hash,
93770 + [47762] = &_000276_hash,
93771 + [17613] = &_000277_hash,
93772 + [52037] = &_000278_hash,
93773 + [5994] = &_000279_hash,
93774 + [46818] = &_000280_hash,
93775 + [13467] = &_000281_hash,
93776 + [61848] = &_000282_hash,
93777 + [43082] = &_000284_hash,
93778 + [55732] = &_000286_hash,
93779 + [2543] = &_000287_hash,
93780 + [51694] = &_000288_hash,
93781 + [18402] = &_000289_hash,
93782 + [38282] = &_000290_hash,
93783 + [5456] = &_000291_hash,
93784 + [58261] = &_000292_hash,
93785 + [24792] = &_000293_hash,
93786 + [6422] = &_000294_hash,
93787 + [63953] = &_000295_hash,
93788 + [27384] = &_000296_hash,
93789 + [47213] = &_000297_hash,
93790 + [23548] = &_000298_hash,
93791 + [47858] = &_000299_hash,
93792 + [52501] = &_000300_hash,
93793 + [12475] = &_000301_hash,
93794 + [52921] = &_000302_hash,
93795 + [19120] = &_000303_hash,
93796 + [14355] = &_000304_hash,
93797 + [30563] = &_000305_hash,
93798 + [14942] = &_000306_hash,
93799 + [30969] = &_000307_hash,
93800 + [57776] = &_000308_hash,
93801 + [21956] = &_000309_hash,
93802 + [44050] = &_000310_hash,
93803 + [2193] = &_000311_hash,
93804 + [44818] = &_000312_hash,
93805 + [50616] = &_000313_hash,
93806 + [49299] = &_000314_hash,
93807 + [2796] = &_000315_hash,
93808 + [4190] = &_000316_hash,
93809 + [11548] = &_000317_hash,
93810 + [53798] = &_000318_hash,
93811 + [60370] = &_000319_hash,
93812 + [35863] = &_000320_hash,
93813 + [54595] = &_000322_hash,
93814 + [2808] = &_000323_hash,
93815 + [24656] = &_000324_hash,
93816 + [895] = &_000325_hash,
93817 + [32809] = &_000326_hash,
93818 + [55621] = &_000327_hash,
93819 + [1733] = &_000328_hash,
93820 + [36069] = &_000330_hash,
93821 + [23714] = &_000331_hash,
93822 + [26020] = &_000332_hash,
93823 + [63875] = &_000333_hash,
93824 + [58608] = &_000334_hash,
93825 + [8919] = &_000335_hash,
93826 + [23906] = &_000336_hash,
93827 + [59497] = &_000337_hash,
93828 + [34782] = &_000338_hash,
93829 + [40998] = &_000339_hash,
93830 + [33328] = &_000340_hash,
93831 + [17866] = &_000341_hash,
93832 + [38741] = &_000342_hash,
93833 + [53939] = &_000343_hash,
93834 + [14658] = &_000344_hash,
93835 + [42465] = &_000345_hash,
93836 + [49600] = &_000346_hash,
93837 + [7391] = &_000347_hash,
93838 + [43616] = &_000348_hash,
93839 + [16775] = &_000349_hash,
93840 + [41393] = &_000350_hash,
93841 + [10532] = &_000351_hash,
93842 + [50366] = &_000352_hash,
93843 + [33324] = &_000353_hash,
93844 + [38200] = &_000354_hash,
93845 + [59315] = &_000355_hash,
93846 + [33916] = &_000356_hash,
93847 + [36593] = &_000357_hash,
93848 + [63079] = &_000358_hash,
93849 + [379] = &_000359_hash,
93850 + [34248] = &_000360_hash,
93851 + [27251] = &_000361_hash,
93852 + [29460] = &_000362_hash,
93853 + [7461] = &_000363_hash,
93854 + [9870] = &_000364_hash,
93855 + [44596] = &_000365_hash,
93856 + [45157] = &_000366_hash,
93857 + [55069] = &_000367_hash,
93858 + [29452] = &_000368_hash,
93859 + [54888] = &_000369_hash,
93860 + [31885] = &_000370_hash,
93861 + [20206] = &_000371_hash,
93862 + [59852] = &_000372_hash,
93863 + [20325] = &_000373_hash,
93864 + [18488] = &_000374_hash,
93865 + [22017] = &_000375_hash,
93866 + [57485] = &_000376_hash,
93867 + [49827] = &_000377_hash,
93868 + [37770] = &_000379_hash,
93869 + [52668] = &_000380_hash,
93870 + [13724] = &_000381_hash,
93871 + [59701] = &_000382_hash,
93872 + [11954] = &_000383_hash,
93873 + [9890] = &_000384_hash,
93874 + [17684] = &_000385_hash,
93875 + [18158] = &_000386_hash,
93876 + [61318] = &_000387_hash,
93877 + [2760] = &_000388_hash,
93878 + [38444] = &_000390_hash,
93879 + [55856] = &_000392_hash,
93880 + [34762] = &_000393_hash,
93881 + [48360] = &_000394_hash,
93882 + [40885] = &_000395_hash,
93883 + [36032] = &_000396_hash,
93884 + [52057] = &_000397_hash,
93885 + [12463] = &_000398_hash,
93886 + [30616] = &_000399_hash,
93887 + [38680] = &_000400_hash,
93888 + [41742] = &_000401_hash,
93889 + [50662] = &_000402_hash,
93890 + [48440] = &_000403_hash,
93891 + [34418] = &_000404_hash,
93892 + [64275] = &_000405_hash,
93893 + [12231] = &_000406_hash,
93894 + [53530] = &_000407_hash,
93895 + [54723] = &_000408_hash,
93896 + [19490] = &_000409_hash,
93897 + [11595] = &_000410_hash,
93898 + [15277] = &_000411_hash,
93899 + [4811] = &_000412_hash,
93900 + [42017] = &_000413_hash,
93901 + [17238] = &_000414_hash,
93902 + [55439] = &_000415_hash,
93903 + [45794] = &_000416_hash,
93904 + [60027] = &_000417_hash,
93905 + [3750] = &_000418_hash,
93906 + [11091] = &_000419_hash,
93907 + [32935] = &_000420_hash,
93908 + [22809] = &_000422_hash,
93909 + [60193] = &_000423_hash,
93910 + [14396] = &_000424_hash,
93911 + [18101] = &_000425_hash,
93912 + [46395] = &_000426_hash,
93913 + [24339] = &_000427_hash,
93914 + [26065] = &_000428_hash,
93915 + [43016] = &_000429_hash,
93916 + [41996] = &_000430_hash,
93917 + [7371] = &_000431_hash,
93918 + [32968] = &_000432_hash,
93919 + [53082] = &_000433_hash,
93920 + [38798] = &_000434_hash,
93921 + [12726] = &_000435_hash,
93922 + [55018] = &_000436_hash,
93923 + [26114] = &_000437_hash,
93924 + [31697] = &_000438_hash,
93925 + [21401] = &_000441_hash,
93926 + [33193] = &_000442_hash,
93927 + [52271] = &_000443_hash,
93928 + [20847] = &_000444_hash,
93929 + [30754] = &_000445_hash,
93930 + [54440] = &_000446_hash,
93931 + [22059] = &_000447_hash,
93932 + [47566] = &_000448_hash,
93933 + [22926] = &_000449_hash,
93934 + [20788] = &_000450_hash,
93935 + [18162] = &_000451_hash,
93936 + [65006] = &_000452_hash,
93937 + [11523] = &_000453_hash,
93938 + [29207] = &_000454_hash,
93939 + [18071] = &_000455_hash,
93940 + [7601] = &_000456_hash,
93941 + [12773] = &_000457_hash,
93942 + [61543] = &_000458_hash,
93943 + [5578] = &_000460_hash,
93944 + [49050] = &_000461_hash,
93945 + [51965] = &_000462_hash,
93946 + [6807] = &_000463_hash,
93947 + [22982] = &_000464_hash,
93948 + [36769] = &_000465_hash,
93949 + [53892] = &_000466_hash,
93950 + [2547] = &_000467_hash,
93951 + [53678] = &_000468_hash,
93952 + [61439] = &_000469_hash,
93953 + [31287] = &_000470_hash,
93954 + [6125] = &_000471_hash,
93955 + [57511] = &_000472_hash,
93956 + [13001] = &_000473_hash,
93957 + [62932] = &_000474_hash,
93958 + [62284] = &_000475_hash,
93959 + [9472] = &_000476_hash,
93960 + [26260] = &_000477_hash,
93961 + [63065] = &_000478_hash,
93962 + [18949] = &_000479_hash,
93963 + [29891] = &_000481_hash,
93964 + [41916] = &_000482_hash,
93965 + [40474] = &_000483_hash,
93966 + [63551] = &_000484_hash,
93967 + [36557] = &_000485_hash,
93968 + [2994] = &_000486_hash,
93969 + [5521] = &_000487_hash,
93970 + [51016] = &_000488_hash,
93971 + [7644] = &_000489_hash,
93972 + [55103] = &_000490_hash,
93973 + [11488] = &_000491_hash,
93974 + [7184] = &_000492_hash,
93975 + [36934] = &_000493_hash,
93976 + [54855] = &_000494_hash,
93977 + [63193] = &_000495_hash,
93978 + [12369] = &_000496_hash,
93979 + [15828] = &_000497_hash,
93980 + [61322] = &_000498_hash,
93981 + [5412] = &_000499_hash,
93982 + [28089] = &_000500_hash,
93983 + [64306] = &_000502_hash,
93984 + [24071] = &_000503_hash,
93985 + [50308] = &_000504_hash,
93986 + [38790] = &_000505_hash,
93987 + [9838] = &_000506_hash,
93988 + [18983] = &_000507_hash,
93989 + [9656] = &_000508_hash,
93990 + [18950] = &_000509_hash,
93991 + [59749] = &_000510_hash,
93992 + [20465] = &_000511_hash,
93993 + [4765] = &_000512_hash,
93994 + [16169] = &_000513_hash,
93995 + [6930] = &_000514_hash,
93996 + [16926] = &_000515_hash,
93997 + [35218] = &_000516_hash,
93998 + [19956] = &_000517_hash,
93999 + [55255] = &_000518_hash,
94000 + [861] = &_000519_hash,
94001 + [26574] = &_000520_hash,
94002 + [26794] = &_000521_hash,
94003 + [2133] = &_000522_hash,
94004 + [44616] = &_000523_hash,
94005 + [12840] = &_000524_hash,
94006 + [60426] = &_000525_hash,
94007 + [18133] = &_000526_hash,
94008 + [30479] = &_000527_hash,
94009 + [3219] = &_000528_hash,
94010 + [36488] = &_000529_hash,
94011 + [62043] = &_000530_hash,
94012 + [21714] = &_000532_hash,
94013 + [48007] = &_000533_hash,
94014 + [49969] = &_000534_hash,
94015 + [7701] = &_000535_hash,
94016 + [11521] = &_000536_hash,
94017 + [4269] = &_000537_hash,
94018 + [37627] = &_000539_hash,
94019 + [33555] = &_000540_hash,
94020 + [25900] = &_000541_hash,
94021 + [31709] = &_000542_hash,
94022 + [44626] = &_000544_hash,
94023 + [1679] = &_000545_hash,
94024 + [18349] = &_000546_hash,
94025 + [15338] = &_000547_hash,
94026 + [57935] = &_000548_hash,
94027 + [55850] = &_000549_hash,
94028 + [36063] = &_000550_hash,
94029 + [56674] = &_000551_hash,
94030 + [21379] = &_000552_hash,
94031 + [18507] = &_000553_hash,
94032 + [55719] = &_000554_hash,
94033 + [31210] = &_000555_hash,
94034 + [36207] = &_000556_hash,
94035 + [64180] = &_000557_hash,
94036 + [41770] = &_000558_hash,
94037 + [11600] = &_000559_hash,
94038 + [36638] = &_000560_hash,
94039 + [25576] = &_000561_hash,
94040 + [7000] = &_000562_hash,
94041 + [34187] = &_000563_hash,
94042 + [58533] = &_000564_hash,
94043 + [5083] = &_000565_hash,
94044 + [62614] = &_000566_hash,
94045 + [20085] = &_000567_hash,
94046 + [1135] = &_000568_hash,
94047 + [25613] = &_000569_hash,
94048 + [9541] = &_000570_hash,
94049 + [30577] = &_000571_hash,
94050 + [35722] = &_000572_hash,
94051 + [60407] = &_000573_hash,
94052 + [29465] = &_000574_hash,
94053 + [46891] = &_000575_hash,
94054 + [43633] = &_000576_hash,
94055 + [53743] = &_000577_hash,
94056 + [16196] = &_000578_hash,
94057 + [34425] = &_000580_hash,
94058 + [9646] = &_000581_hash,
94059 + [59756] = &_000583_hash,
94060 + [45524] = &_000584_hash,
94061 + [36702] = &_000585_hash,
94062 + [36747] = &_000586_hash,
94063 + [33643] = &_000588_hash,
94064 + [29158] = &_000589_hash,
94065 + [49662] = &_000590_hash,
94066 + [51062] = &_000591_hash,
94067 + [64755] = &_000592_hash,
94068 + [4829] = &_000594_hash,
94069 + [16413] = &_000595_hash,
94070 + [36125] = &_000596_hash,
94071 + [36293] = &_000597_hash,
94072 + [39712] = &_000598_hash,
94073 + [32160] = &_000599_hash,
94074 + [22962] = &_000600_hash,
94075 + [32001] = &_000601_hash,
94076 + [35828] = &_000602_hash,
94077 + [3106] = &_000603_hash,
94078 + [34039] = &_000604_hash,
94079 + [22393] = &_000605_hash,
94080 + [3560] = &_000606_hash,
94081 + [28195] = &_000607_hash,
94082 + [2062] = &_000608_hash,
94083 + [64001] = &_000609_hash,
94084 + [42407] = &_000610_hash,
94085 + [6253] = &_000611_hash,
94086 + [58640] = &_000612_hash,
94087 + [32195] = &_000613_hash,
94088 + [26197] = &_000614_hash,
94089 + [58003] = &_000615_hash,
94090 + [21662] = &_000616_hash,
94091 + [45750] = &_000617_hash,
94092 + [25798] = &_000618_hash,
94093 + [41052] = &_000619_hash,
94094 + [14096] = &_000620_hash,
94095 + [1439] = &_000621_hash,
94096 + [29074] = &_000622_hash,
94097 + [2376] = &_000623_hash,
94098 + [24068] = &_000625_hash,
94099 + [59519] = &_000627_hash,
94100 + [9893] = &_000628_hash,
94101 + [39979] = &_000630_hash,
94102 + [41540] = &_000631_hash,
94103 + [43200] = &_000633_hash,
94104 + [33494] = &_000634_hash,
94105 + [2028] = &_000635_hash,
94106 + [27206] = &_000636_hash,
94107 + [24302] = &_000637_hash,
94108 + [38112] = &_000638_hash,
94109 + [46538] = &_000639_hash,
94110 + [35228] = &_000641_hash,
94111 + [8339] = &_000642_hash,
94112 + [45349] = &_000643_hash,
94113 + [48404] = &_000644_hash,
94114 + [37865] = &_000645_hash,
94115 + [45763] = &_000646_hash,
94116 + [62347] = &_000647_hash,
94117 + [21644] = &_000648_hash,
94118 + [53135] = &_000649_hash,
94119 + [25095] = &_000650_hash,
94120 + [11697] = &_000651_hash,
94121 + [27003] = &_000652_hash,
94122 + [32464] = &_000653_hash,
94123 + [65339] = &_000654_hash,
94124 + [44248] = &_000655_hash,
94125 + [16] = &_000656_hash,
94126 + [29933] = &_000657_hash,
94127 + [34359] = &_000658_hash,
94128 + [3154] = &_000659_hash,
94129 + [59308] = &_000660_hash,
94130 + [61661] = &_000661_hash,
94131 + [23959] = &_000662_hash,
94132 + [6724] = &_000663_hash,
94133 + [54587] = &_000664_hash,
94134 + [28479] = &_000665_hash,
94135 + [56583] = &_000666_hash,
94136 + [64644] = &_000667_hash,
94137 + [23284] = &_000668_hash,
94138 + [61655] = &_000669_hash,
94139 + [20980] = &_000670_hash,
94140 + [19794] = &_000671_hash,
94141 + [30036] = &_000672_hash,
94142 + [25649] = &_000673_hash,
94143 + [47428] = &_000674_hash,
94144 + [47737] = &_000675_hash,
94145 + [8367] = &_000676_hash,
94146 + [2987] = &_000677_hash,
94147 + [50962] = &_000678_hash,
94148 + [10760] = &_000679_hash,
94149 + [31678] = &_000680_hash,
94150 + [48558] = &_000681_hash,
94151 + [2274] = &_000682_hash,
94152 + [831] = &_000683_hash,
94153 + [61833] = &_000684_hash,
94154 + [56864] = &_000685_hash,
94155 + [31040] = &_000686_hash,
94156 + [22196] = &_000687_hash,
94157 + [20076] = &_000688_hash,
94158 + [52821] = &_000689_hash,
94159 + [21896] = &_000690_hash,
94160 + [49367] = &_000691_hash,
94161 + [64731] = &_000692_hash,
94162 + [37110] = &_000693_hash,
94163 + [53694] = &_000694_hash,
94164 + [6175] = &_000695_hash,
94165 + [33048] = &_000696_hash,
94166 + [34746] = &_000697_hash,
94167 + [23777] = &_000698_hash,
94168 + [53828] = &_000699_hash,
94169 + [26539] = &_000700_hash,
94170 + [42628] = &_000701_hash,
94171 + [59115] = &_000702_hash,
94172 + [4456] = &_000703_hash,
94173 + [63619] = &_000704_hash,
94174 + [47329] = &_000705_hash,
94175 + [13534] = &_000706_hash,
94176 + [36955] = &_000707_hash,
94177 + [9841] = &_000708_hash,
94178 + [19308] = &_000709_hash,
94179 + [52439] = &_000710_hash,
94180 + [24680] = &_000711_hash,
94181 + [55652] = &_000712_hash,
94182 + [7842] = &_000713_hash,
94183 + [6500] = &_000714_hash,
94184 + [33485] = &_000715_hash,
94185 + [49920] = &_000716_hash,
94186 + [50750] = &_000717_hash,
94187 + [22318] = &_000718_hash,
94188 + [44599] = &_000719_hash,
94189 + [46403] = &_000720_hash,
94190 + [44534] = &_000721_hash,
94191 + [303] = &_000722_hash,
94192 + [22960] = &_000723_hash,
94193 + [10544] = &_000724_hash,
94194 + [8236] = &_000725_hash,
94195 + [21239] = &_000726_hash,
94196 + [24712] = &_000727_hash,
94197 + [37974] = &_000728_hash,
94198 + [62082] = &_000729_hash,
94199 + [57054] = &_000730_hash,
94200 + [53265] = &_000731_hash,
94201 + [52239] = &_000732_hash,
94202 + [14753] = &_000733_hash,
94203 + [60221] = &_000736_hash,
94204 + [27142] = &_000737_hash,
94205 + [14295] = &_000738_hash,
94206 + [25923] = &_000739_hash,
94207 + [29213] = &_000740_hash,
94208 + [31865] = &_000741_hash,
94209 + [4764] = &_000742_hash,
94210 + [10574] = &_000743_hash,
94211 + [55766] = &_000744_hash,
94212 + [22483] = &_000745_hash,
94213 + [61047] = &_000746_hash,
94214 + [41044] = &_000747_hash,
94215 + [58978] = &_000748_hash,
94216 + [47578] = &_000749_hash,
94217 + [7730] = &_000750_hash,
94218 + [15904] = &_000751_hash,
94219 + [25081] = &_000752_hash,
94220 + [45743] = &_000753_hash,
94221 + [58830] = &_000754_hash,
94222 + [59081] = &_000755_hash,
94223 + [47533] = &_000756_hash,
94224 + [11305] = &_000757_hash,
94225 + [29096] = &_000758_hash,
94226 + [19749] = &_000759_hash,
94227 + [56290] = &_000760_hash,
94228 + [44963] = &_000761_hash,
94229 + [30026] = &_000762_hash,
94230 + [27694] = &_000763_hash,
94231 + [8089] = &_000764_hash,
94232 + [38583] = &_000765_hash,
94233 + [1144] = &_000766_hash,
94234 + [20939] = &_000767_hash,
94235 + [22231] = &_000768_hash,
94236 + [17486] = &_000769_hash,
94237 + [51811] = &_000770_hash,
94238 + [62746] = &_000771_hash,
94239 + [19181] = &_000772_hash,
94240 + [52661] = &_000773_hash,
94241 + [51148] = &_000774_hash,
94242 + [49864] = &_000775_hash,
94243 + [37978] = &_000776_hash,
94244 + [6280] = &_000777_hash,
94245 + [12961] = &_000778_hash,
94246 + [60541] = &_000779_hash,
94247 + [37021] = &_000780_hash,
94248 + [26028] = &_000781_hash,
94249 + [41363] = &_000782_hash,
94250 + [42016] = &_000783_hash,
94251 + [58540] = &_000784_hash,
94252 + [2326] = &_000785_hash,
94253 + [60981] = &_000786_hash,
94254 + [13313] = &_000787_hash,
94255 + [44188] = &_000788_hash,
94256 + [34638] = &_000789_hash,
94257 + [20304] = &_000790_hash,
94258 + [60975] = &_000791_hash,
94259 + [12244] = &_000792_hash,
94260 + [16266] = &_000793_hash,
94261 + [3395] = &_000794_hash,
94262 + [63321] = &_000795_hash,
94263 + [20509] = &_000796_hash,
94264 + [57365] = &_000797_hash,
94265 + [47449] = &_000798_hash,
94266 + [56693] = &_000799_hash,
94267 + [33936] = &_000800_hash,
94268 + [52548] = &_000801_hash,
94269 + [18733] = &_000802_hash,
94270 + [15560] = &_000803_hash,
94271 + [13231] = &_000804_hash,
94272 + [64518] = &_000806_hash,
94273 + [54551] = &_000807_hash,
94274 + [54359] = &_000809_hash,
94275 + [46503] = &_000810_hash,
94276 + [22258] = &_000811_hash,
94277 + [39434] = &_000812_hash,
94278 + [52887] = &_000813_hash,
94279 + [3079] = &_000814_hash,
94280 + [18813] = &_000816_hash,
94281 + [47614] = &_000817_hash,
94282 + [38186] = &_000818_hash,
94283 + [57652] = &_000819_hash,
94284 + [10078] = &_000820_hash,
94285 + [17910] = &_000821_hash,
94286 + [13567] = &_000822_hash,
94287 + [21531] = &_000823_hash,
94288 + [46135] = &_000824_hash,
94289 + [10582] = &_000825_hash,
94290 + [4662] = &_000826_hash,
94291 + [17969] = &_000827_hash,
94292 + [43943] = &_000828_hash,
94293 + [46740] = &_000829_hash,
94294 + [26716] = &_000830_hash,
94295 + [58230] = &_000831_hash,
94296 + [252] = &_000832_hash,
94297 + [15704] = &_000833_hash,
94298 + [59765] = &_000834_hash,
94299 + [7322] = &_000835_hash,
94300 + [43950] = &_000836_hash,
94301 + [53093] = &_000837_hash,
94302 + [21646] = &_000838_hash,
94303 + [57063] = &_000839_hash,
94304 + [17132] = &_000840_hash,
94305 + [53922] = &_000842_hash,
94306 + [49155] = &_000843_hash,
94307 + [16356] = &_000844_hash,
94308 + [60037] = &_000845_hash,
94309 + [17299] = &_000846_hash,
94310 + [25678] = &_000847_hash,
94311 + [15494] = &_000848_hash,
94312 + [15159] = &_000849_hash,
94313 + [28442] = &_000850_hash,
94314 + [3514] = &_000851_hash,
94315 + [38151] = &_000852_hash,
94316 + [4173] = &_000853_hash,
94317 + [7258] = &_000854_hash,
94318 + [65109] = &_000855_hash,
94319 + [58827] = &_000856_hash,
94320 + [33575] = &_000857_hash,
94321 + [33078] = &_000858_hash,
94322 + [47234] = &_000859_hash,
94323 + [39193] = &_000860_hash,
94324 + [10950] = &_000861_hash,
94325 + [15613] = &_000862_hash,
94326 + [16046] = &_000863_hash,
94327 + [50172] = &_000864_hash,
94328 + [26107] = &_000865_hash,
94329 + [60543] = &_000866_hash,
94330 + [56337] = &_000867_hash,
94331 + [47626] = &_000868_hash,
94332 + [24409] = &_000869_hash,
94333 + [11732] = &_000870_hash,
94334 + [30010] = &_000871_hash,
94335 + [51480] = &_000872_hash,
94336 + [28518] = &_000873_hash,
94337 + [2061] = &_000874_hash,
94338 + [10885] = &_000875_hash,
94339 + [29517] = &_000876_hash,
94340 + [45913] = &_000877_hash,
94341 + [51774] = &_000878_hash,
94342 + [62298] = &_000879_hash,
94343 + [8892] = &_000880_hash,
94344 + [64891] = &_000881_hash,
94345 + [64537] = &_000882_hash,
94346 + [38103] = &_000883_hash,
94347 + [55518] = &_000884_hash,
94348 + [27419] = &_000885_hash,
94349 + [13869] = &_000886_hash,
94350 + [53150] = &_000887_hash,
94351 + [2884] = &_000888_hash,
94352 + [10362] = &_000889_hash,
94353 + [6961] = &_000890_hash,
94354 + [56975] = &_000891_hash,
94355 + [12508] = &_000892_hash,
94356 + [54597] = &_000893_hash,
94357 + [60499] = &_000894_hash,
94358 + [50109] = &_000895_hash,
94359 + [944] = &_000896_hash,
94360 + [29229] = &_000897_hash,
94361 + [37648] = &_000898_hash,
94362 + [1568] = &_000899_hash,
94363 + [61793] = &_000900_hash,
94364 + [53395] = &_000901_hash,
94365 + [5519] = &_000902_hash,
94366 + [28637] = &_000903_hash,
94367 + [53687] = &_000904_hash,
94368 + [6783] = &_000905_hash,
94369 + [43312] = &_000906_hash,
94370 + [2373] = &_000907_hash,
94371 + [33482] = &_000908_hash,
94372 + [24886] = &_000909_hash,
94373 + [48154] = &_000910_hash,
94374 + [12838] = &_000911_hash,
94375 + [47012] = &_000912_hash,
94376 + [23691] = &_000913_hash,
94377 + [37924] = &_000914_hash,
94378 + [47346] = &_000915_hash,
94379 + [5624] = &_000916_hash,
94380 + [16842] = &_000918_hash,
94381 + [60399] = &_000919_hash,
94382 + [2312] = &_000920_hash,
94383 + [59212] = &_000921_hash,
94384 + [11923] = &_000922_hash,
94385 + [10805] = &_000923_hash,
94386 + [36577] = &_000924_hash,
94387 + [60948] = &_000925_hash,
94388 + [21711] = &_000926_hash,
94389 + [54830] = &_000927_hash,
94390 + [1822] = &_000928_hash,
94391 + [44573] = &_000929_hash,
94392 + [23805] = &_000930_hash,
94393 + [46061] = &_000931_hash,
94394 + [33996] = &_000932_hash,
94395 + [40856] = &_000933_hash,
94396 + [16299] = &_000934_hash,
94397 + [63446] = &_000935_hash,
94398 + [31205] = &_000936_hash,
94399 + [33100] = &_000937_hash,
94400 + [40843] = &_000938_hash,
94401 + [23712] = &_000939_hash,
94402 + [36962] = &_000940_hash,
94403 + [9845] = &_000942_hash,
94404 + [13738] = &_000943_hash,
94405 + [58099] = &_000944_hash,
94406 + [31869] = &_000945_hash,
94407 + [63501] = &_000946_hash,
94408 + [58188] = &_000947_hash,
94409 + [51338] = &_000948_hash,
94410 + [54999] = &_000949_hash,
94411 + [2434] = &_000950_hash,
94412 + [34958] = &_000951_hash,
94413 + [41487] = &_000952_hash,
94414 + [11941] = &_000953_hash,
94415 + [56728] = &_000954_hash,
94416 + [48150] = &_000955_hash,
94417 + [13905] = &_000956_hash,
94418 + [9054] = &_000957_hash,
94419 + [10758] = &_000958_hash,
94420 + [48056] = &_000959_hash,
94421 + [24231] = &_000960_hash,
94422 + [43748] = &_000961_hash,
94423 + [24237] = &_000962_hash,
94424 + [14899] = &_000963_hash,
94425 + [38652] = &_000964_hash,
94426 + [65013] = &_000965_hash,
94427 + [16645] = &_000967_hash,
94428 + [55031] = &_000968_hash,
94429 + [23978] = &_000969_hash,
94430 + [24208] = &_000970_hash,
94431 + [18098] = &_000971_hash,
94432 + [2303] = &_000972_hash,
94433 + [3338] = &_000973_hash,
94434 + [39219] = &_000974_hash,
94435 + [18609] = &_000976_hash,
94436 + [64412] = &_000977_hash,
94437 + [16962] = &_000978_hash,
94438 + [26346] = &_000979_hash,
94439 + [39380] = &_000980_hash,
94440 + [33020] = &_000981_hash,
94441 + [22639] = &_000982_hash,
94442 + [6453] = &_000983_hash,
94443 + [58602] = &_000984_hash,
94444 + [50920] = &_000985_hash,
94445 + [56471] = &_000987_hash,
94446 + [15378] = &_000988_hash,
94447 + [3589] = &_000989_hash,
94448 + [12558] = &_000990_hash,
94449 + [3201] = &_000991_hash,
94450 + [28175] = &_000993_hash,
94451 + [43888] = &_000995_hash,
94452 + [56010] = &_000996_hash,
94453 + [32456] = &_000997_hash,
94454 + [29036] = &_000998_hash,
94455 + [32330] = &_000999_hash,
94456 + [25603] = &_001000_hash,
94457 + [17675] = &_001001_hash,
94458 + [36271] = &_001002_hash,
94459 + [49814] = &_001003_hash,
94460 + [5693] = &_001004_hash,
94461 + [51009] = &_001005_hash,
94462 + [62835] = &_001006_hash,
94463 + [27139] = &_001007_hash,
94464 + [45155] = &_001008_hash,
94465 + [17186] = &_001009_hash,
94466 + [46734] = &_001010_hash,
94467 + [61957] = &_001011_hash,
94468 + [51389] = &_001012_hash,
94469 + [23687] = &_001013_hash,
94470 + [46825] = &_001014_hash,
94471 + [52287] = &_001016_hash,
94472 + [31408] = &_001017_hash,
94473 + [5396] = &_001018_hash,
94474 + [62247] = &_001019_hash,
94475 + [7946] = &_001020_hash,
94476 + [58210] = &_001022_hash,
94477 + [15618] = &_001023_hash,
94478 + [61225] = &_001024_hash,
94479 + [13163] = &_001025_hash,
94480 + [36882] = &_001026_hash,
94481 + [8719] = &_001027_hash,
94482 + [8539] = &_001028_hash,
94483 + [27134] = &_001029_hash,
94484 + [53335] = &_001030_hash,
94485 + [30381] = &_001031_hash,
94486 + [32336] = &_001032_hash,
94487 + [32867] = &_001033_hash,
94488 + [1238] = &_001034_hash,
94489 + [8174] = &_001035_hash,
94490 + [6368] = &_001036_hash,
94491 + [29170] = &_001037_hash,
94492 + [9687] = &_001038_hash,
94493 + [61116] = &_001039_hash,
94494 + [31681] = &_001040_hash,
94495 + [22119] = &_001041_hash,
94496 + [59885] = &_001042_hash,
94497 + [47789] = &_001043_hash,
94498 + [5796] = &_001044_hash,
94499 + [43376] = &_001045_hash,
94500 + [36706] = &_001046_hash,
94501 + [47945] = &_001047_hash,
94502 + [33208] = &_001048_hash,
94503 + [55431] = &_001049_hash,
94504 + [25291] = &_001050_hash,
94505 + [58805] = &_001051_hash,
94506 + [23708] = &_001052_hash,
94507 + [29278] = &_001053_hash,
94508 + [1272] = &_001054_hash,
94509 + [10199] = &_001055_hash,
94510 + [34666] = &_001056_hash,
94511 + [49317] = &_001057_hash,
94512 + [18604] = &_001058_hash,
94513 + [42545] = &_001059_hash,
94514 + [33157] = &_001060_hash,
94515 + [53343] = &_001061_hash,
94516 + [64842] = &_001062_hash,
94517 + [61865] = &_001063_hash,
94518 + [54010] = &_001064_hash,
94519 + [64638] = &_001065_hash,
94520 + [20480] = &_001066_hash,
94521 + [23341] = &_001067_hash,
94522 + [10350] = &_001068_hash,
94523 + [30970] = &_001069_hash,
94524 + [62360] = &_001070_hash,
94525 + [52537] = &_001071_hash,
94526 + [51386] = &_001072_hash,
94527 + [48731] = &_001073_hash,
94528 + [58061] = &_001074_hash,
94529 + [40405] = &_001075_hash,
94530 + [57198] = &_001076_hash,
94531 + [19290] = &_001077_hash,
94532 + [60403] = &_001078_hash,
94533 + [2738] = &_001079_hash,
94534 + [59721] = &_001080_hash,
94535 + [24980] = &_001081_hash,
94536 + [55896] = &_001082_hash,
94537 + [57055] = &_001083_hash,
94538 + [46010] = &_001084_hash,
94539 + [712] = &_001085_hash,
94540 + [37747] = &_001086_hash,
94541 + [59996] = &_001087_hash,
94542 + [45219] = &_001088_hash,
94543 + [16917] = &_001089_hash,
94544 + [7415] = &_001090_hash,
94545 + [29576] = &_001091_hash,
94546 + [13584] = &_001092_hash,
94547 + [53364] = &_001093_hash,
94548 + [14813] = &_001094_hash,
94549 + [25543] = &_001095_hash,
94550 + [29240] = &_001096_hash,
94551 + [38748] = &_001097_hash,
94552 + [42270] = &_001098_hash,
94553 + [34848] = &_001099_hash,
94554 + [46226] = &_001100_hash,
94555 + [55526] = &_001101_hash,
94556 + [48271] = &_001102_hash,
94557 + [24658] = &_001104_hash,
94558 + [46964] = &_001105_hash,
94559 + [2637] = &_001106_hash,
94560 + [55601] = &_001107_hash,
94561 + [60275] = &_001108_hash,
94562 + [52645] = &_001109_hash,
94563 + [11712] = &_001110_hash,
94564 + [51364] = &_001111_hash,
94565 + [5106] = &_001112_hash,
94566 + [24710] = &_001113_hash,
94567 + [13101] = &_001114_hash,
94568 + [46963] = &_001115_hash,
94569 + [6779] = &_001116_hash,
94570 + [9237] = &_001117_hash,
94571 + [61524] = &_001118_hash,
94572 + [38247] = &_001119_hash,
94573 + [48715] = &_001120_hash,
94574 + [40797] = &_001121_hash,
94575 + [46780] = &_001122_hash,
94576 + [22071] = &_001123_hash,
94577 + [49735] = &_001125_hash,
94578 + [63925] = &_001126_hash,
94579 + [30902] = &_001127_hash,
94580 + [39828] = &_001128_hash,
94581 + [53089] = &_001129_hash,
94582 + [6394] = &_001130_hash,
94583 + [5116] = &_001131_hash,
94584 + [50702] = &_001132_hash,
94585 + [59565] = &_001133_hash,
94586 + [61042] = &_001134_hash,
94587 + [14533] = &_001135_hash,
94588 + [23807] = &_001136_hash,
94589 + [24296] = &_001137_hash,
94590 + [8808] = &_001138_hash,
94591 + [52383] = &_001139_hash,
94592 + [30487] = &_001140_hash,
94593 + [30125] = &_001141_hash,
94594 + [40665] = &_001142_hash,
94595 + [60809] = &_001143_hash,
94596 + [4842] = &_001144_hash,
94597 + [13955] = &_001145_hash,
94598 + [33237] = &_001146_hash,
94599 + [40673] = &_001147_hash,
94600 + [48026] = &_001148_hash,
94601 + [64033] = &_001149_hash,
94602 + [13879] = &_001150_hash,
94603 + [60114] = &_001151_hash,
94604 + [19472] = &_001152_hash,
94605 + [33552] = &_001153_hash,
94606 + [28575] = &_001154_hash,
94607 + [19696] = &_001155_hash,
94608 + [19742] = &_001156_hash,
94609 + [15286] = &_001157_hash,
94610 + [24629] = &_001158_hash,
94611 + [28382] = &_001159_hash,
94612 + [18962] = &_001160_hash,
94613 + [45796] = &_001161_hash,
94614 + [51632] = &_001162_hash,
94615 + [16907] = &_001163_hash,
94616 + [49336] = &_001164_hash,
94617 + [25316] = &_001165_hash,
94618 + [39978] = &_001166_hash,
94619 + [8091] = &_001167_hash,
94620 + [30680] = &_001168_hash,
94621 + [2066] = &_001169_hash,
94622 + [24271] = &_001170_hash,
94623 + [34934] = &_001171_hash,
94624 + [29208] = &_001172_hash,
94625 + [18591] = &_001173_hash,
94626 + [24373] = &_001174_hash,
94627 + [41485] = &_001175_hash,
94628 + [45487] = &_001176_hash,
94629 + [29299] = &_001177_hash,
94630 + [53920] = &_001178_hash,
94631 + [25407] = &_001179_hash,
94632 + [5525] = &_001180_hash,
94633 + [3531] = &_001181_hash,
94634 + [25143] = &_001182_hash,
94635 + [56046] = &_001183_hash,
94636 + [34693] = &_001184_hash,
94637 + [48644] = &_001185_hash,
94638 + [21226] = &_001186_hash,
94639 + [14051] = &_001187_hash,
94640 + [7715] = &_001188_hash,
94641 + [30413] = &_001189_hash,
94642 + [13681] = &_001190_hash,
94643 + [6554] = &_001191_hash,
94644 + [12228] = &_001192_hash,
94645 + [25497] = &_001193_hash,
94646 + [52228] = &_001194_hash,
94647 + [49069] = &_001195_hash,
94648 + [26961] = &_001196_hash,
94649 + [13768] = &_001197_hash,
94650 + [56185] = &_001198_hash,
94651 + [41838] = &_001199_hash,
94652 + [60119] = &_001200_hash,
94653 + [3112] = &_001201_hash,
94654 + [62001] = &_001202_hash,
94655 + [35888] = &_001203_hash,
94656 + [54718] = &_001206_hash,
94657 + [64177] = &_001207_hash,
94658 + [57222] = &_001208_hash,
94659 + [5260] = &_001209_hash,
94660 + [55517] = &_001210_hash,
94661 + [18186] = &_001211_hash,
94662 + [14257] = &_001212_hash,
94663 + [26846] = &_001213_hash,
94664 + [56097] = &_001214_hash,
94665 + [55151] = &_001215_hash,
94666 + [2999] = &_001216_hash,
94667 + [3602] = &_001217_hash,
94668 + [18460] = &_001218_hash,
94669 + [3507] = &_001219_hash,
94670 + [57847] = &_001220_hash,
94671 + [58077] = &_001221_hash,
94672 + [2659] = &_001222_hash,
94673 + [39846] = &_001223_hash,
94674 + [18629] = &_001224_hash,
94675 + [2723] = &_001225_hash,
94676 + [45230] = &_001226_hash,
94677 + [26941] = &_001227_hash,
94678 + [4344] = &_001228_hash,
94679 + [8487] = &_001229_hash,
94680 + [9901] = &_001230_hash,
94681 + [43061] = &_001231_hash,
94682 + [42551] = &_001232_hash,
94683 + [63272] = &_001233_hash,
94684 + [37771] = &_001234_hash,
94685 + [28261] = &_001235_hash,
94686 + [44694] = &_001236_hash,
94687 + [8573] = &_001237_hash,
94688 + [60174] = &_001238_hash,
94689 + [28040] = &_001239_hash,
94690 + [39423] = &_001240_hash,
94691 + [98] = &_001241_hash,
94692 + [62874] = &_001242_hash,
94693 + [38726] = &_001243_hash,
94694 + [55348] = &_001244_hash,
94695 + [10997] = &_001245_hash,
94696 + [88] = &_001246_hash,
94697 + [60639] = &_001247_hash,
94698 + [48159] = &_001248_hash,
94699 + [47899] = &_001249_hash,
94700 + [25367] = &_001250_hash,
94701 + [55681] = &_001251_hash,
94702 + [44716] = &_001252_hash,
94703 + [26161] = &_001253_hash,
94704 + [55347] = &_001254_hash,
94705 + [14518] = &_001255_hash,
94706 + [8887] = &_001256_hash,
94707 + [23009] = &_001257_hash,
94708 + [27962] = &_001258_hash,
94709 + [20004] = &_001259_hash,
94710 + [61750] = &_001260_hash,
94711 + [11661] = &_001261_hash,
94712 + [37118] = &_001262_hash,
94713 + [9370] = &_001263_hash,
94714 + [15099] = &_001264_hash,
94715 + [2404] = &_001265_hash,
94716 + [64074] = &_001266_hash,
94717 + [7538] = &_001267_hash,
94718 + [19736] = &_001268_hash,
94719 + [8199] = &_001269_hash,
94720 + [40711] = &_001270_hash,
94721 + [47859] = &_001271_hash,
94722 + [53925] = &_001272_hash,
94723 + [46888] = &_001273_hash,
94724 + [21783] = &_001274_hash,
94725 + [37305] = &_001275_hash,
94726 + [18414] = &_001276_hash,
94727 + [62423] = &_001277_hash,
94728 + [30371] = &_001278_hash,
94729 + [32617] = &_001279_hash,
94730 + [14530] = &_001281_hash,
94731 + [48623] = &_001282_hash,
94732 + [12845] = &_001283_hash,
94733 + [8895] = &_001284_hash,
94734 + [33661] = &_001285_hash,
94735 + [23178] = &_001286_hash,
94736 + [54706] = &_001287_hash,
94737 + [27133] = &_001288_hash,
94738 + [52745] = &_001289_hash,
94739 + [64420] = &_001290_hash,
94740 + [25617] = &_001291_hash,
94741 + [25414] = &_001292_hash,
94742 + [20445] = &_001293_hash,
94743 + [64006] = &_001294_hash,
94744 + [52646] = &_001295_hash,
94745 + [30281] = &_001296_hash,
94746 + [3761] = &_001297_hash,
94747 + [44345] = &_001298_hash,
94748 + [14713] = &_001299_hash,
94749 + [26043] = &_001300_hash,
94750 + [41679] = &_001301_hash,
94751 + [6267] = &_001302_hash,
94752 + [22247] = &_001304_hash,
94753 + [9440] = &_001305_hash,
94754 + [54676] = &_001306_hash,
94755 + [53982] = &_001308_hash,
94756 + [9467] = &_001309_hash,
94757 + [53419] = &_001310_hash,
94758 + [1424] = &_001311_hash,
94759 + [17561] = &_001312_hash,
94760 + [28161] = &_001313_hash,
94761 + [57262] = &_001314_hash,
94762 + [61071] = &_001315_hash,
94763 + [20067] = &_001316_hash,
94764 + [34321] = &_001317_hash,
94765 + [56199] = &_001318_hash,
94766 + [29070] = &_001319_hash,
94767 + [15698] = &_001320_hash,
94768 + [14173] = &_001321_hash,
94769 + [41224] = &_001322_hash,
94770 + [56438] = &_001323_hash,
94771 + [41894] = &_001324_hash,
94772 + [20885] = &_001325_hash,
94773 + [23275] = &_001326_hash,
94774 + [45043] = &_001327_hash,
94775 + [22143] = &_001328_hash,
94776 + [38029] = &_001329_hash,
94777 + [55343] = &_001330_hash,
94778 + [40624] = &_001331_hash,
94779 + [26476] = &_001332_hash,
94780 + [43128] = &_001333_hash,
94781 + [45115] = &_001334_hash,
94782 + [32958] = &_001335_hash,
94783 + [43091] = &_001336_hash,
94784 + [33299] = &_001337_hash,
94785 + [55021] = &_001338_hash,
94786 + [5509] = &_001339_hash,
94787 + [53012] = &_001340_hash,
94788 + [57849] = &_001341_hash,
94789 + [63282] = &_001342_hash,
94790 + [27883] = &_001343_hash,
94791 + [1670] = &_001344_hash,
94792 + [24095] = &_001345_hash,
94793 + [47810] = &_001346_hash,
94794 + [40759] = &_001347_hash,
94795 + [42139] = &_001348_hash,
94796 + [50484] = &_001349_hash,
94797 + [2305] = &_001350_hash,
94798 + [59832] = &_001351_hash,
94799 + [17662] = &_001352_hash,
94800 + [58943] = &_001353_hash,
94801 + [37417] = &_001356_hash,
94802 + [25127] = &_001357_hash,
94803 + [15006] = &_001358_hash,
94804 + [54292] = &_001359_hash,
94805 + [30642] = &_001360_hash,
94806 + [39939] = &_001361_hash,
94807 + [34818] = &_001362_hash,
94808 + [23378] = &_001363_hash,
94809 + [24090] = &_001364_hash,
94810 + [11111] = &_001365_hash,
94811 + [64141] = &_001366_hash,
94812 + [46457] = &_001367_hash,
94813 + [57927] = &_001368_hash,
94814 + [58877] = &_001371_hash,
94815 + [13880] = &_001372_hash,
94816 + [62888] = &_001373_hash,
94817 + [57962] = &_001374_hash,
94818 + [9117] = &_001375_hash,
94819 + [52012] = &_001376_hash,
94820 + [49246] = &_001377_hash,
94821 + [52701] = &_001378_hash,
94822 + [29857] = &_001379_hash,
94823 + [49420] = &_001380_hash,
94824 + [45897] = &_001381_hash,
94825 + [15141] = &_001382_hash,
94826 + [24177] = &_001383_hash,
94827 + [10325] = &_001384_hash,
94828 + [52861] = &_001385_hash,
94829 + [28922] = &_001386_hash,
94830 + [31089] = &_001387_hash,
94831 + [63084] = &_001388_hash,
94832 + [26245] = &_001389_hash,
94833 + [60000] = &_001390_hash,
94834 + [56935] = &_001391_hash,
94835 + [37569] = &_001392_hash,
94836 + [6446] = &_001394_hash,
94837 + [35883] = &_001395_hash,
94838 + [9123] = &_001396_hash,
94839 + [51457] = &_001397_hash,
94840 + [1787] = &_001398_hash,
94841 + [10135] = &_001399_hash,
94842 + [952] = &_001400_hash,
94843 + [53578] = &_001401_hash,
94844 + [9923] = &_001402_hash,
94845 + [45249] = &_001403_hash,
94846 + [52860] = &_001404_hash,
94847 + [29558] = &_001405_hash,
94848 + [40556] = &_001406_hash,
94849 + [53210] = &_001407_hash,
94850 + [2506] = &_001408_hash,
94851 + [48262] = &_001409_hash,
94852 + [46939] = &_001410_hash,
94853 + [17901] = &_001411_hash,
94854 + [27204] = &_001412_hash,
94855 + [52516] = &_001413_hash,
94856 + [55885] = &_001414_hash,
94857 + [6681] = &_001415_hash,
94858 + [42360] = &_001416_hash,
94859 + [20259] = &_001417_hash,
94860 + [8874] = &_001418_hash,
94861 + [53363] = &_001419_hash,
94862 + [17500] = &_001420_hash,
94863 + [63988] = &_001421_hash,
94864 + [26378] = &_001422_hash,
94865 + [7768] = &_001423_hash,
94866 + [12938] = &_001424_hash,
94867 + [6755] = &_001425_hash,
94868 + [43806] = &_001426_hash,
94869 + [15976] = &_001427_hash,
94870 + [2732] = &_001428_hash,
94871 + [2519] = &_001429_hash,
94872 + [14340] = &_001430_hash,
94873 + [34772] = &_001431_hash,
94874 + [36433] = &_001432_hash,
94875 + [16068] = &_001433_hash,
94876 + [22052] = &_001434_hash,
94877 + [8929] = &_001435_hash,
94878 + [63220] = &_001436_hash,
94879 + [18246] = &_001437_hash,
94880 + [37678] = &_001438_hash,
94881 + [4932] = &_001439_hash,
94882 + [46960] = &_001440_hash,
94883 + [16909] = &_001441_hash,
94884 + [44429] = &_001442_hash,
94885 + [59514] = &_001443_hash,
94886 + [62760] = &_001444_hash,
94887 + [41841] = &_001445_hash,
94888 + [25417] = &_001446_hash,
94889 + [63230] = &_001447_hash,
94890 + [39532] = &_001448_hash,
94891 + [24688] = &_001449_hash,
94892 + [18555] = &_001450_hash,
94893 + [54499] = &_001451_hash,
94894 + [10719] = &_001452_hash,
94895 + [1644] = &_001453_hash,
94896 + [15109] = &_001454_hash,
94897 + [15787] = &_001455_hash,
94898 + [57869] = &_001456_hash,
94899 + [54445] = &_001457_hash,
94900 + [19398] = &_001458_hash,
94901 + [9488] = &_001459_hash,
94902 + [12587] = &_001460_hash,
94903 + [17124] = &_001461_hash,
94904 + [53665] = &_001462_hash,
94905 + [40386] = &_001463_hash,
94906 + [39444] = &_001464_hash,
94907 + [28873] = &_001465_hash,
94908 + [11290] = &_001466_hash,
94909 + [51313] = &_001467_hash,
94910 + [23354] = &_001469_hash,
94911 + [49559] = &_001470_hash,
94912 + [49312] = &_001471_hash,
94913 + [36333] = &_001472_hash,
94914 + [59349] = &_001473_hash,
94915 + [60316] = &_001474_hash,
94916 + [2546] = &_001475_hash,
94917 + [57483] = &_001476_hash,
94918 + [14569] = &_001478_hash,
94919 + [61842] = &_001481_hash,
94920 + [32923] = &_001482_hash,
94921 + [57471] = &_001483_hash,
94922 + [83] = &_001484_hash,
94923 + [40242] = &_001485_hash,
94924 + [42578] = &_001486_hash,
94925 + [62037] = &_001487_hash,
94926 + [8131] = &_001488_hash,
94927 + [752] = &_001489_hash,
94928 + [56376] = &_001490_hash,
94929 + [22290] = &_001491_hash,
94930 + [46232] = &_001492_hash,
94931 + [35132] = &_001493_hash,
94932 + [23825] = &_001494_hash,
94933 + [43262] = &_001495_hash,
94934 + [8138] = &_001496_hash,
94935 + [31489] = &_001497_hash,
94936 + [57578] = &_001498_hash,
94937 + [28007] = &_001499_hash,
94938 + [28688] = &_001500_hash,
94939 + [19319] = &_001501_hash,
94940 + [12575] = &_001502_hash,
94941 + [62762] = &_001504_hash,
94942 + [47450] = &_001505_hash,
94943 + [1869] = &_001506_hash,
94944 + [51225] = &_001507_hash,
94945 + [19561] = &_001508_hash,
94946 + [64894] = &_001509_hash,
94947 + [6829] = &_001510_hash,
94948 + [30644] = &_001511_hash,
94949 + [63391] = &_001512_hash,
94950 + [11655] = &_001514_hash,
94951 + [28229] = &_001515_hash,
94952 + [22382] = &_001516_hash,
94953 + [22649] = &_001517_hash,
94954 + [42619] = &_001518_hash,
94955 + [19761] = &_001519_hash,
94956 + [56990] = &_001520_hash,
94957 + [19531] = &_001521_hash,
94958 + [26514] = &_001522_hash,
94959 + [56773] = &_001523_hash,
94960 + [15563] = &_001524_hash,
94961 + [26212] = &_001525_hash,
94962 + [29203] = &_001526_hash,
94963 + [32768] = &_001527_hash,
94964 + [15110] = &_001528_hash,
94965 + [3885] = &_001529_hash,
94966 + [13788] = &_001530_hash,
94967 + [27875] = &_001531_hash,
94968 + [54959] = &_001532_hash,
94969 + [20945] = &_001533_hash,
94970 + [59640] = &_001534_hash,
94971 + [4693] = &_001535_hash,
94972 + [13793] = &_001536_hash,
94973 + [25659] = &_001537_hash,
94974 + [18734] = &_001538_hash,
94975 + [17869] = &_001539_hash,
94976 + [26270] = &_001540_hash,
94977 + [18458] = &_001541_hash,
94978 + [58468] = &_001542_hash,
94979 + [61257] = &_001543_hash,
94980 + [39946] = &_001544_hash,
94981 + [52382] = &_001545_hash,
94982 + [18428] = &_001546_hash,
94983 + [31069] = &_001547_hash,
94984 + [61614] = &_001548_hash,
94985 + [60044] = &_001549_hash,
94986 + [36818] = &_001550_hash,
94987 + [54353] = &_001551_hash,
94988 + [55994] = &_001552_hash,
94989 + [65142] = &_001553_hash,
94990 + [1664] = &_001554_hash,
94991 + [32212] = &_001555_hash,
94992 + [63087] = &_001556_hash,
94993 + [29916] = &_001557_hash,
94994 + [54912] = &_001558_hash,
94995 + [10318] = &_001559_hash,
94996 + [44031] = &_001560_hash,
94997 + [50108] = &_001561_hash,
94998 + [57812] = &_001562_hash,
94999 + [63190] = &_001563_hash,
95000 + [48246] = &_001564_hash,
95001 + [3744] = &_001565_hash,
95002 + [56321] = &_001566_hash,
95003 + [42691] = &_001567_hash,
95004 + [62052] = &_001568_hash,
95005 + [21999] = &_001569_hash,
95006 + [13672] = &_001570_hash,
95007 + [20648] = &_001571_hash,
95008 + [42500] = &_001572_hash,
95009 + [22795] = &_001573_hash,
95010 + [19496] = &_001574_hash,
95011 + [35556] = &_001575_hash,
95012 + [57144] = &_001576_hash,
95013 + [1019] = &_001577_hash,
95014 + [28818] = &_001578_hash,
95015 + [52880] = &_001579_hash,
95016 + [6543] = &_001580_hash,
95017 + [18895] = &_001581_hash,
95018 + [857] = &_001582_hash,
95019 + [45966] = &_001583_hash,
95020 + [11785] = &_001584_hash,
95021 + [7736] = &_001585_hash,
95022 + [4308] = &_001586_hash,
95023 + [51095] = &_001587_hash,
95024 + [12101] = &_001588_hash,
95025 + [427] = &_001589_hash,
95026 + [4021] = &_001590_hash,
95027 + [54201] = &_001591_hash,
95028 + [5615] = &_001592_hash,
95029 + [16234] = &_001593_hash,
95030 + [51718] = &_001594_hash,
95031 + [42390] = &_001595_hash,
95032 + [55391] = &_001596_hash,
95033 + [28539] = &_001597_hash,
95034 + [943] = &_001598_hash,
95035 + [32683] = &_001599_hash,
95036 + [39182] = &_001600_hash,
95037 + [33198] = &_001601_hash,
95038 + [39446] = &_001602_hash,
95039 + [16394] = &_001603_hash,
95040 + [30791] = &_001604_hash,
95041 + [35530] = &_001605_hash,
95042 + [53193] = &_001607_hash,
95043 + [39401] = &_001608_hash,
95044 + [28624] = &_001609_hash,
95045 + [12066] = &_001610_hash,
95046 + [63492] = &_001611_hash,
95047 + [14897] = &_001612_hash,
95048 + [29641] = &_001613_hash,
95049 + [10165] = &_001614_hash,
95050 + [60046] = &_001615_hash,
95051 + [12429] = &_001616_hash,
95052 + [32788] = &_001617_hash,
95053 + [52698] = &_001618_hash,
95054 + [13130] = &_001620_hash,
95055 + [28643] = &_001621_hash,
95056 + [50666] = &_001622_hash,
95057 + [35126] = &_001623_hash,
95058 + [33593] = &_001624_hash,
95059 + [27547] = &_001625_hash,
95060 + [5484] = &_001626_hash,
95061 + [26642] = &_001627_hash,
95062 + [25586] = &_001628_hash,
95063 + [58757] = &_001629_hash,
95064 + [18701] = &_001630_hash,
95065 + [26271] = &_001631_hash,
95066 + [23829] = &_001632_hash,
95067 + [63659] = &_001634_hash,
95068 + [26603] = &_001635_hash,
95069 + [25704] = &_001636_hash,
95070 + [21149] = &_001637_hash,
95071 + [36900] = &_001638_hash,
95072 + [61577] = &_001640_hash,
95073 + [54095] = &_001641_hash,
95074 + [31650] = &_001642_hash,
95075 + [48970] = &_001643_hash,
95076 + [49357] = &_001644_hash,
95077 + [33835] = &_001645_hash,
95078 + [46861] = &_001646_hash,
95079 + [1428] = &_001647_hash,
95080 + [36247] = &_001648_hash,
95081 + [21600] = &_001649_hash,
95082 + [24747] = &_001650_hash,
95083 + [51012] = &_001651_hash,
95084 + [38974] = &_001653_hash,
95085 + [30549] = &_001655_hash,
95086 + [40146] = &_001656_hash,
95087 + [41756] = &_001657_hash,
95088 + [37010] = &_001658_hash,
95089 + [35072] = &_001660_hash,
95090 + [2114] = &_001661_hash,
95091 + [48424] = &_001662_hash,
95092 + [61522] = &_001663_hash,
95093 + [50633] = &_001664_hash,
95094 + [2283] = &_001665_hash,
95095 + [61763] = &_001666_hash,
95096 + [48195] = &_001667_hash,
95097 + [31000] = &_001668_hash,
95098 + [23856] = &_001669_hash,
95099 + [37421] = &_001670_hash,
95100 + [10019] = &_001672_hash,
95101 + [5148] = &_001673_hash,
95102 + [14363] = &_001674_hash,
95103 + [57354] = &_001675_hash,
95104 + [62460] = &_001676_hash,
95105 + [45174] = &_001677_hash,
95106 + [31054] = &_001678_hash,
95107 + [62195] = &_001679_hash,
95108 + [14976] = &_001680_hash,
95109 + [55676] = &_001681_hash,
95110 + [1025] = &_001682_hash,
95111 + [6921] = &_001683_hash,
95112 + [22158] = &_001684_hash,
95113 + [18050] = &_001685_hash,
95114 + [18612] = &_001686_hash,
95115 + [31107] = &_001687_hash,
95116 + [45212] = &_001688_hash,
95117 + [29599] = &_001689_hash,
95118 + [30827] = &_001690_hash,
95119 + [25086] = &_001691_hash,
95120 + [27146] = &_001692_hash,
95121 + [2467] = &_001693_hash,
95122 + [45786] = &_001694_hash,
95123 + [51909] = &_001695_hash,
95124 + [64604] = &_001696_hash,
95125 + [57819] = &_001697_hash,
95126 + [11001] = &_001698_hash,
95127 + [20326] = &_001699_hash,
95128 + [12682] = &_001700_hash,
95129 + [28932] = &_001701_hash,
95130 + [53491] = &_001702_hash,
95131 + [63894] = &_001703_hash,
95132 + [51191] = &_001704_hash,
95133 + [59759] = &_001705_hash,
95134 + [15691] = &_001706_hash,
95135 + [38786] = &_001707_hash,
95136 + [51546] = &_001708_hash,
95137 + [10121] = &_001709_hash,
95138 + [60786] = &_001710_hash,
95139 + [19952] = &_001712_hash,
95140 + [7271] = &_001715_hash,
95141 + [10729] = &_001716_hash,
95142 + [28883] = &_001717_hash,
95143 + [52042] = &_001718_hash,
95144 + [49606] = &_001719_hash,
95145 + [33243] = &_001720_hash,
95146 + [57341] = &_001721_hash,
95147 + [7978] = &_001722_hash,
95148 + [36330] = &_001723_hash,
95149 + [39035] = &_001724_hash,
95150 + [34498] = &_001725_hash,
95151 + [19789] = &_001726_hash,
95152 + [55685] = &_001727_hash,
95153 + [55419] = &_001728_hash,
95154 + [27798] = &_001729_hash,
95155 + [54599] = &_001730_hash,
95156 + [65522] = &_001731_hash,
95157 + [38111] = &_001732_hash,
95158 + [57077] = &_001733_hash,
95159 + [53053] = &_001734_hash,
95160 + [14190] = &_001735_hash,
95161 + [47037] = &_001736_hash,
95162 + [33296] = &_001737_hash,
95163 + [23803] = &_001738_hash,
95164 + [48773] = &_001739_hash,
95165 + [63014] = &_001740_hash,
95166 + [64392] = &_001741_hash,
95167 + [44203] = &_001742_hash,
95168 + [47717] = &_001743_hash,
95169 + [38399] = &_001744_hash,
95170 + [30385] = &_001745_hash,
95171 + [61693] = &_001746_hash,
95172 + [32049] = &_001747_hash,
95173 + [26133] = &_001748_hash,
95174 + [45038] = &_001749_hash,
95175 + [8582] = &_001751_hash,
95176 + [38182] = &_001753_hash,
95177 + [62457] = &_001754_hash,
95178 + [27937] = &_001755_hash,
95179 + [3795] = &_001756_hash,
95180 + [23228] = &_001757_hash,
95181 + [56511] = &_001758_hash,
95182 + [47807] = &_001759_hash,
95183 + [60528] = &_001760_hash,
95184 + [51858] = &_001761_hash,
95185 + [49183] = &_001762_hash,
95186 + [33807] = &_001763_hash,
95187 + [34791] = &_001764_hash,
95188 + [8150] = &_001765_hash,
95189 + [19691] = &_001767_hash,
95190 + [20519] = &_001770_hash,
95191 + [17144] = &_001771_hash,
95192 + [14000] = &_001772_hash,
95193 + [31148] = &_001773_hash,
95194 + [62594] = &_001774_hash,
95195 + [39210] = &_001775_hash,
95196 + [2077] = &_001776_hash,
95197 + [23497] = &_001777_hash,
95198 + [34512] = &_001778_hash,
95199 + [16268] = &_001780_hash,
95200 + [14562] = &_001781_hash,
95201 + [17606] = &_001783_hash,
95202 + [25654] = &_001784_hash,
95203 + [56078] = &_001785_hash,
95204 + [61088] = &_001786_hash,
95205 + [53442] = &_001787_hash,
95206 + [54456] = &_001788_hash,
95207 + [22038] = &_001789_hash,
95208 + [58394] = &_001790_hash,
95209 + [38953] = &_001791_hash,
95210 + [16109] = &_001792_hash,
95211 + [3812] = &_001793_hash,
95212 + [5084] = &_001794_hash,
95213 + [41893] = &_001795_hash,
95214 + [45486] = &_001796_hash,
95215 + [50226] = &_001797_hash,
95216 + [63694] = &_001798_hash,
95217 + [56763] = &_001799_hash,
95218 + [20905] = &_001800_hash,
95219 + [13080] = &_001801_hash,
95220 + [54700] = &_001802_hash,
95221 + [40947] = &_001803_hash,
95222 + [32645] = &_001804_hash,
95223 + [57462] = &_001805_hash,
95224 + [33853] = &_001806_hash,
95225 + [57940] = &_001807_hash,
95226 + [45583] = &_001808_hash,
95227 + [14237] = &_001809_hash,
95228 + [27495] = &_001810_hash,
95229 + [12489] = &_001811_hash,
95230 +};
95231 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
95232 new file mode 100644
95233 index 0000000..92b8ee6
95234 --- /dev/null
95235 +++ b/tools/gcc/size_overflow_plugin.c
95236 @@ -0,0 +1,1188 @@
95237 +/*
95238 + * Copyright 2011, 2012 by Emese Revfy <re.emese@gmail.com>
95239 + * Licensed under the GPL v2, or (at your option) v3
95240 + *
95241 + * Homepage:
95242 + * http://www.grsecurity.net/~ephox/overflow_plugin/
95243 + *
95244 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
95245 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
95246 + * The recomputed argument is checked against INT_MAX and an event is logged on overflow and the triggering process is killed.
95247 + *
95248 + * Usage:
95249 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o size_overflow_plugin.so size_overflow_plugin.c
95250 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
95251 + */
95252 +
95253 +#include "gcc-plugin.h"
95254 +#include "config.h"
95255 +#include "system.h"
95256 +#include "coretypes.h"
95257 +#include "tree.h"
95258 +#include "tree-pass.h"
95259 +#include "intl.h"
95260 +#include "plugin-version.h"
95261 +#include "tm.h"
95262 +#include "toplev.h"
95263 +#include "function.h"
95264 +#include "tree-flow.h"
95265 +#include "plugin.h"
95266 +#include "gimple.h"
95267 +#include "c-common.h"
95268 +#include "diagnostic.h"
95269 +#include "cfgloop.h"
95270 +
95271 +struct size_overflow_hash {
95272 + struct size_overflow_hash *next;
95273 + const char *name;
95274 + const char *file;
95275 + unsigned short param1:1;
95276 + unsigned short param2:1;
95277 + unsigned short param3:1;
95278 + unsigned short param4:1;
95279 + unsigned short param5:1;
95280 + unsigned short param6:1;
95281 + unsigned short param7:1;
95282 + unsigned short param8:1;
95283 + unsigned short param9:1;
95284 +};
95285 +
95286 +#include "size_overflow_hash.h"
95287 +
95288 +#define __unused __attribute__((__unused__))
95289 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
95290 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
95291 +#define BEFORE_STMT true
95292 +#define AFTER_STMT false
95293 +#define CREATE_NEW_VAR NULL_TREE
95294 +
95295 +int plugin_is_GPL_compatible;
95296 +void debug_gimple_stmt(gimple gs);
95297 +
95298 +static tree expand(struct pointer_set_t *visited, bool *potentionally_overflowed, tree var);
95299 +static tree signed_size_overflow_type;
95300 +static tree unsigned_size_overflow_type;
95301 +static tree report_size_overflow_decl;
95302 +static tree const_char_ptr_type_node;
95303 +static unsigned int handle_function(void);
95304 +static bool file_match = true;
95305 +
95306 +static struct plugin_info size_overflow_plugin_info = {
95307 + .version = "20120521beta",
95308 + .help = "no-size_overflow\tturn off size overflow checking\n",
95309 +};
95310 +
95311 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
95312 +{
95313 + unsigned int arg_count = type_num_arguments(*node);
95314 +
95315 + for (; args; args = TREE_CHAIN(args)) {
95316 + tree position = TREE_VALUE(args);
95317 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_HIGH(position) || TREE_INT_CST_LOW(position) < 1 || TREE_INT_CST_LOW(position) > arg_count ) {
95318 + error("handle_size_overflow_attribute: overflow parameter outside range.");
95319 + *no_add_attrs = true;
95320 + }
95321 + }
95322 + return NULL_TREE;
95323 +}
95324 +
95325 +static struct attribute_spec no_size_overflow_attr = {
95326 + .name = "size_overflow",
95327 + .min_length = 1,
95328 + .max_length = -1,
95329 + .decl_required = false,
95330 + .type_required = true,
95331 + .function_type_required = true,
95332 + .handler = handle_size_overflow_attribute
95333 +};
95334 +
95335 +static void register_attributes(void __unused *event_data, void __unused *data)
95336 +{
95337 + register_attribute(&no_size_overflow_attr);
95338 +}
95339 +
95340 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
95341 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
95342 +{
95343 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
95344 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
95345 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
95346 +
95347 + const unsigned int m = 0x57559429;
95348 + const unsigned int n = 0x5052acdb;
95349 + const unsigned int *key4 = (const unsigned int *)key;
95350 + unsigned int h = len;
95351 + unsigned int k = len + seed + n;
95352 + unsigned long long p;
95353 +
95354 + while (len >= 8) {
95355 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
95356 + len -= 8;
95357 + }
95358 + if (len >= 4) {
95359 + cwmixb(key4[0]) key4 += 1;
95360 + len -= 4;
95361 + }
95362 + if (len)
95363 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
95364 + cwmixb(h ^ (k + n));
95365 + return k ^ h;
95366 +
95367 +#undef cwfold
95368 +#undef cwmixa
95369 +#undef cwmixb
95370 +}
95371 +
95372 +static inline unsigned int get_hash_num(const char *fndecl, const char *loc_file, unsigned int seed)
95373 +{
95374 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
95375 + unsigned int file = CrapWow(loc_file, strlen(loc_file), seed) & 0xffff;
95376 +
95377 + if (file_match)
95378 + return fn ^ file;
95379 + else
95380 + return fn;
95381 +}
95382 +
95383 +static inline tree get_original_function_decl(tree fndecl)
95384 +{
95385 + if (DECL_ABSTRACT_ORIGIN(fndecl))
95386 + return DECL_ABSTRACT_ORIGIN(fndecl);
95387 + return fndecl;
95388 +}
95389 +
95390 +static inline gimple get_def_stmt(tree node)
95391 +{
95392 + gcc_assert(TREE_CODE(node) == SSA_NAME);
95393 + return SSA_NAME_DEF_STMT(node);
95394 +}
95395 +
95396 +static struct size_overflow_hash *get_function_hash(tree fndecl, const char *loc_file)
95397 +{
95398 + unsigned int hash;
95399 + struct size_overflow_hash *entry;
95400 + const char *func_name = NAME(fndecl);
95401 +
95402 + hash = get_hash_num(NAME(fndecl), loc_file, 0);
95403 +
95404 + entry = size_overflow_hash[hash];
95405 + while (entry) {
95406 + if (!strcmp(entry->name, func_name) && (!file_match || !strcmp(entry->file, loc_file)))
95407 + return entry;
95408 + entry = entry->next;
95409 + }
95410 +
95411 + return NULL;
95412 +}
95413 +
95414 +static void check_arg_type(tree var)
95415 +{
95416 + tree type = TREE_TYPE(var);
95417 + enum tree_code code = TREE_CODE(type);
95418 +
95419 + gcc_assert(code == INTEGER_TYPE || code == ENUMERAL_TYPE ||
95420 + (code == POINTER_TYPE && TREE_CODE(TREE_TYPE(type)) == VOID_TYPE) ||
95421 + (code == POINTER_TYPE && TREE_CODE(TREE_TYPE(type)) == INTEGER_TYPE));
95422 +}
95423 +
95424 +static int find_arg_number(tree arg, tree func)
95425 +{
95426 + tree var;
95427 + bool match = false;
95428 + unsigned int argnum = 1;
95429 +
95430 + if (TREE_CODE(arg) == SSA_NAME)
95431 + arg = SSA_NAME_VAR(arg);
95432 +
95433 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var)) {
95434 + if (strcmp(NAME(arg), NAME(var))) {
95435 + argnum++;
95436 + continue;
95437 + }
95438 + check_arg_type(var);
95439 +
95440 + match = true;
95441 + if (!TYPE_UNSIGNED(TREE_TYPE(var)))
95442 + return 0;
95443 + break;
95444 + }
95445 + if (!match) {
95446 + warning(0, "find_arg_number: cannot find the %s argument in %s", NAME(arg), NAME(func));
95447 + return 0;
95448 + }
95449 + return argnum;
95450 +}
95451 +
95452 +static void print_missing_msg(tree func, const char *filename, unsigned int argnum)
95453 +{
95454 + unsigned int new_hash;
95455 + location_t loc = DECL_SOURCE_LOCATION(func);
95456 + const char *curfunc = NAME(func);
95457 +
95458 + new_hash = get_hash_num(curfunc, filename, 0);
95459 +// inform(loc, "Function %s is missing from the size_overflow hash table +%s+%d+%u+%s+", curfunc, curfunc, argnum, new_hash, filename);
95460 +}
95461 +
95462 +static void check_missing_attribute(tree arg)
95463 +{
95464 + tree type, func = get_original_function_decl(current_function_decl);
95465 + unsigned int argnum;
95466 + struct size_overflow_hash *hash;
95467 + const char *filename;
95468 +
95469 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
95470 +
95471 + type = TREE_TYPE(arg);
95472 + // skip function pointers
95473 + if (TREE_CODE(type) == POINTER_TYPE && TREE_CODE(TREE_TYPE(type)) == FUNCTION_TYPE)
95474 + return;
95475 +
95476 + if (lookup_attribute("size_overflow", TYPE_ATTRIBUTES(TREE_TYPE(func))))
95477 + return;
95478 +
95479 + argnum = find_arg_number(arg, func);
95480 + if (argnum == 0)
95481 + return;
95482 +
95483 + filename = DECL_SOURCE_FILE(func);
95484 +
95485 + hash = get_function_hash(func, filename);
95486 + if (!hash) {
95487 + print_missing_msg(func, filename, argnum);
95488 + return;
95489 + }
95490 +
95491 +#define check_param(num) \
95492 + if (num == argnum && hash->param##num) \
95493 + return;
95494 + check_param(1);
95495 + check_param(2);
95496 + check_param(3);
95497 + check_param(4);
95498 + check_param(5);
95499 + check_param(6);
95500 + check_param(7);
95501 + check_param(8);
95502 + check_param(9);
95503 +#undef check_param
95504 +
95505 + print_missing_msg(func, filename, argnum);
95506 +}
95507 +
95508 +static tree create_new_var(tree type)
95509 +{
95510 + tree new_var = create_tmp_var(type, "cicus");
95511 +
95512 + add_referenced_var(new_var);
95513 + mark_sym_for_renaming(new_var);
95514 + return new_var;
95515 +}
95516 +
95517 +static bool is_bool(tree node)
95518 +{
95519 + tree type;
95520 +
95521 + if (node == NULL_TREE)
95522 + return false;
95523 +
95524 + type = TREE_TYPE(node);
95525 + if (!INTEGRAL_TYPE_P(type))
95526 + return false;
95527 + if (TREE_CODE(type) == BOOLEAN_TYPE)
95528 + return true;
95529 + if (TYPE_PRECISION(type) == 1)
95530 + return true;
95531 + return false;
95532 +}
95533 +
95534 +static tree cast_a_tree(tree type, tree var)
95535 +{
95536 + gcc_assert(fold_convertible_p(type, var));
95537 +
95538 + return fold_convert(type, var);
95539 +}
95540 +
95541 +static gimple build_cast_stmt(tree type, tree var, tree new_var, location_t loc)
95542 +{
95543 + gimple assign;
95544 +
95545 + if (new_var == CREATE_NEW_VAR)
95546 + new_var = create_new_var(type);
95547 +
95548 + assign = gimple_build_assign(new_var, cast_a_tree(type, var));
95549 + gimple_set_location(assign, loc);
95550 + gimple_set_lhs(assign, make_ssa_name(new_var, assign));
95551 +
95552 + return assign;
95553 +}
95554 +
95555 +static tree create_assign(struct pointer_set_t *visited, bool *potentionally_overflowed, gimple oldstmt, tree rhs1, bool before)
95556 +{
95557 + tree oldstmt_rhs1;
95558 + enum tree_code code;
95559 + gimple stmt;
95560 + gimple_stmt_iterator gsi;
95561 +
95562 + if (!*potentionally_overflowed)
95563 + return NULL_TREE;
95564 +
95565 + if (rhs1 == NULL_TREE) {
95566 + debug_gimple_stmt(oldstmt);
95567 + error("create_assign: rhs1 is NULL_TREE");
95568 + gcc_unreachable();
95569 + }
95570 +
95571 + oldstmt_rhs1 = gimple_assign_rhs1(oldstmt);
95572 + code = TREE_CODE(oldstmt_rhs1);
95573 + if (code == PARM_DECL || (code == SSA_NAME && gimple_code(get_def_stmt(oldstmt_rhs1)) == GIMPLE_NOP))
95574 + check_missing_attribute(oldstmt_rhs1);
95575 +
95576 + stmt = build_cast_stmt(signed_size_overflow_type, rhs1, CREATE_NEW_VAR, gimple_location(oldstmt));
95577 + gsi = gsi_for_stmt(oldstmt);
95578 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
95579 + basic_block next_bb, cur_bb;
95580 + edge e;
95581 +
95582 + gcc_assert(before == false);
95583 + gcc_assert(stmt_can_throw_internal(oldstmt));
95584 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
95585 + gcc_assert(!gsi_end_p(gsi));
95586 +
95587 + cur_bb = gimple_bb(oldstmt);
95588 + next_bb = cur_bb->next_bb;
95589 + e = find_edge(cur_bb, next_bb);
95590 + gcc_assert(e != NULL);
95591 + gcc_assert(e->flags & EDGE_FALLTHRU);
95592 +
95593 + gsi = gsi_after_labels(next_bb);
95594 + gcc_assert(!gsi_end_p(gsi));
95595 + before = true;
95596 + }
95597 + if (before)
95598 + gsi_insert_before(&gsi, stmt, GSI_NEW_STMT);
95599 + else
95600 + gsi_insert_after(&gsi, stmt, GSI_NEW_STMT);
95601 + update_stmt(stmt);
95602 + pointer_set_insert(visited, oldstmt);
95603 + return gimple_get_lhs(stmt);
95604 +}
95605 +
95606 +static tree dup_assign(struct pointer_set_t *visited, bool *potentionally_overflowed, gimple oldstmt, tree rhs1, tree rhs2, tree __unused rhs3)
95607 +{
95608 + tree new_var, lhs = gimple_get_lhs(oldstmt);
95609 + gimple stmt;
95610 + gimple_stmt_iterator gsi;
95611 +
95612 + if (!*potentionally_overflowed)
95613 + return NULL_TREE;
95614 +
95615 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
95616 + rhs1 = gimple_assign_rhs1(oldstmt);
95617 + rhs1 = create_assign(visited, potentionally_overflowed, oldstmt, rhs1, BEFORE_STMT);
95618 + }
95619 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
95620 + rhs2 = gimple_assign_rhs2(oldstmt);
95621 + rhs2 = create_assign(visited, potentionally_overflowed, oldstmt, rhs2, BEFORE_STMT);
95622 + }
95623 +
95624 + stmt = gimple_copy(oldstmt);
95625 + gimple_set_location(stmt, gimple_location(oldstmt));
95626 +
95627 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
95628 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
95629 +
95630 + if (is_bool(lhs))
95631 + new_var = SSA_NAME_VAR(lhs);
95632 + else
95633 + new_var = create_new_var(signed_size_overflow_type);
95634 + new_var = make_ssa_name(new_var, stmt);
95635 + gimple_set_lhs(stmt, new_var);
95636 +
95637 + if (rhs1 != NULL_TREE) {
95638 + if (!gimple_assign_cast_p(oldstmt))
95639 + rhs1 = cast_a_tree(signed_size_overflow_type, rhs1);
95640 + gimple_assign_set_rhs1(stmt, rhs1);
95641 + }
95642 +
95643 + if (rhs2 != NULL_TREE)
95644 + gimple_assign_set_rhs2(stmt, rhs2);
95645 +#if BUILDING_GCC_VERSION >= 4007
95646 + if (rhs3 != NULL_TREE)
95647 + gimple_assign_set_rhs3(stmt, rhs3);
95648 +#endif
95649 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
95650 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
95651 +
95652 + gsi = gsi_for_stmt(oldstmt);
95653 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
95654 + update_stmt(stmt);
95655 + pointer_set_insert(visited, oldstmt);
95656 + return gimple_get_lhs(stmt);
95657 +}
95658 +
95659 +static gimple overflow_create_phi_node(gimple oldstmt, tree var)
95660 +{
95661 + basic_block bb;
95662 + gimple phi;
95663 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
95664 +
95665 + bb = gsi_bb(gsi);
95666 +
95667 + phi = create_phi_node(var, bb);
95668 + gsi = gsi_last(phi_nodes(bb));
95669 + gsi_remove(&gsi, false);
95670 +
95671 + gsi = gsi_for_stmt(oldstmt);
95672 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
95673 + gimple_set_bb(phi, bb);
95674 + return phi;
95675 +}
95676 +
95677 +static tree signed_cast_constant(tree node)
95678 +{
95679 + gcc_assert(is_gimple_constant(node));
95680 +
95681 + return cast_a_tree(signed_size_overflow_type, node);
95682 +}
95683 +
95684 +static basic_block create_a_first_bb(void)
95685 +{
95686 + basic_block first_bb;
95687 +
95688 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
95689 + if (dom_info_available_p(CDI_DOMINATORS))
95690 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
95691 + return first_bb;
95692 +}
95693 +
95694 +static gimple cast_old_phi_arg(gimple oldstmt, tree arg, tree new_var, unsigned int i)
95695 +{
95696 + basic_block bb;
95697 + gimple newstmt, def_stmt;
95698 + gimple_stmt_iterator gsi;
95699 +
95700 + newstmt = build_cast_stmt(signed_size_overflow_type, arg, new_var, gimple_location(oldstmt));
95701 + if (TREE_CODE(arg) == SSA_NAME) {
95702 + def_stmt = get_def_stmt(arg);
95703 + if (gimple_code(def_stmt) != GIMPLE_NOP) {
95704 + gsi = gsi_for_stmt(def_stmt);
95705 + gsi_insert_after(&gsi, newstmt, GSI_NEW_STMT);
95706 + return newstmt;
95707 + }
95708 + }
95709 +
95710 + bb = gimple_phi_arg_edge(oldstmt, i)->src;
95711 + if (bb->index == 0)
95712 + bb = create_a_first_bb();
95713 + gsi = gsi_after_labels(bb);
95714 + gsi_insert_before(&gsi, newstmt, GSI_NEW_STMT);
95715 + return newstmt;
95716 +}
95717 +
95718 +static gimple handle_new_phi_arg(tree arg, tree new_var, tree new_rhs)
95719 +{
95720 + gimple newstmt;
95721 + gimple_stmt_iterator gsi;
95722 + void (*gsi_insert)(gimple_stmt_iterator *, gimple, enum gsi_iterator_update);
95723 + gimple def_newstmt = get_def_stmt(new_rhs);
95724 +
95725 + gsi_insert = gsi_insert_after;
95726 + gsi = gsi_for_stmt(def_newstmt);
95727 +
95728 + switch (gimple_code(get_def_stmt(arg))) {
95729 + case GIMPLE_PHI:
95730 + newstmt = gimple_build_assign(new_var, new_rhs);
95731 + gsi = gsi_after_labels(gimple_bb(def_newstmt));
95732 + gsi_insert = gsi_insert_before;
95733 + break;
95734 + case GIMPLE_ASM:
95735 + case GIMPLE_CALL:
95736 + newstmt = gimple_build_assign(new_var, new_rhs);
95737 + break;
95738 + case GIMPLE_ASSIGN:
95739 + newstmt = gimple_build_assign(new_var, gimple_get_lhs(def_newstmt));
95740 + break;
95741 + default:
95742 + /* unknown gimple_code (handle_build_new_phi_arg) */
95743 + gcc_unreachable();
95744 + }
95745 +
95746 + gimple_set_lhs(newstmt, make_ssa_name(new_var, newstmt));
95747 + gsi_insert(&gsi, newstmt, GSI_NEW_STMT);
95748 + update_stmt(newstmt);
95749 + return newstmt;
95750 +}
95751 +
95752 +static tree build_new_phi_arg(struct pointer_set_t *visited, bool *potentionally_overflowed, tree arg, tree new_var)
95753 +{
95754 + gimple newstmt;
95755 + tree new_rhs;
95756 +
95757 + new_rhs = expand(visited, potentionally_overflowed, arg);
95758 +
95759 + if (new_rhs == NULL_TREE)
95760 + return NULL_TREE;
95761 +
95762 + newstmt = handle_new_phi_arg(arg, new_var, new_rhs);
95763 + return gimple_get_lhs(newstmt);
95764 +}
95765 +
95766 +static tree build_new_phi(struct pointer_set_t *visited, bool *potentionally_overflowed, gimple oldstmt)
95767 +{
95768 + gimple phi;
95769 + tree new_var = create_new_var(signed_size_overflow_type);
95770 + unsigned int i, n = gimple_phi_num_args(oldstmt);
95771 +
95772 + pointer_set_insert(visited, oldstmt);
95773 + phi = overflow_create_phi_node(oldstmt, new_var);
95774 + for (i = 0; i < n; i++) {
95775 + tree arg, lhs;
95776 +
95777 + arg = gimple_phi_arg_def(oldstmt, i);
95778 + if (is_gimple_constant(arg))
95779 + arg = signed_cast_constant(arg);
95780 + lhs = build_new_phi_arg(visited, potentionally_overflowed, arg, new_var);
95781 + if (lhs == NULL_TREE)
95782 + lhs = gimple_get_lhs(cast_old_phi_arg(oldstmt, arg, new_var, i));
95783 + add_phi_arg(phi, lhs, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
95784 + }
95785 +
95786 + update_stmt(phi);
95787 + return gimple_phi_result(phi);
95788 +}
95789 +
95790 +static tree handle_unary_rhs(struct pointer_set_t *visited, bool *potentionally_overflowed, tree var)
95791 +{
95792 + gimple def_stmt = get_def_stmt(var);
95793 + tree new_rhs1, rhs1 = gimple_assign_rhs1(def_stmt);
95794 +
95795 + *potentionally_overflowed = true;
95796 + new_rhs1 = expand(visited, potentionally_overflowed, rhs1);
95797 + if (new_rhs1 == NULL_TREE) {
95798 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
95799 + return create_assign(visited, potentionally_overflowed, def_stmt, var, AFTER_STMT);
95800 + else
95801 + return create_assign(visited, potentionally_overflowed, def_stmt, rhs1, AFTER_STMT);
95802 + }
95803 + return dup_assign(visited, potentionally_overflowed, def_stmt, new_rhs1, NULL_TREE, NULL_TREE);
95804 +}
95805 +
95806 +static tree handle_unary_ops(struct pointer_set_t *visited, bool *potentionally_overflowed, tree var)
95807 +{
95808 + gimple def_stmt = get_def_stmt(var);
95809 + tree rhs1 = gimple_assign_rhs1(def_stmt);
95810 +
95811 + if (is_gimple_constant(rhs1))
95812 + return dup_assign(visited, potentionally_overflowed, def_stmt, signed_cast_constant(rhs1), NULL_TREE, NULL_TREE);
95813 +
95814 + gcc_assert(TREE_CODE(rhs1) != COND_EXPR);
95815 + switch (TREE_CODE(rhs1)) {
95816 + case SSA_NAME:
95817 + return handle_unary_rhs(visited, potentionally_overflowed, var);
95818 +
95819 + case ARRAY_REF:
95820 + case BIT_FIELD_REF:
95821 + case ADDR_EXPR:
95822 + case COMPONENT_REF:
95823 + case INDIRECT_REF:
95824 +#if BUILDING_GCC_VERSION >= 4006
95825 + case MEM_REF:
95826 +#endif
95827 + case PARM_DECL:
95828 + case TARGET_MEM_REF:
95829 + case VAR_DECL:
95830 + return create_assign(visited, potentionally_overflowed, def_stmt, var, AFTER_STMT);
95831 +
95832 + default:
95833 + debug_gimple_stmt(def_stmt);
95834 + debug_tree(rhs1);
95835 + gcc_unreachable();
95836 + }
95837 +}
95838 +
95839 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
95840 +{
95841 + gimple cond_stmt;
95842 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
95843 +
95844 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
95845 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
95846 + update_stmt(cond_stmt);
95847 +}
95848 +
95849 +static tree create_string_param(tree string)
95850 +{
95851 + tree i_type, a_type;
95852 + int length = TREE_STRING_LENGTH(string);
95853 +
95854 + gcc_assert(length > 0);
95855 +
95856 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
95857 + a_type = build_array_type(char_type_node, i_type);
95858 +
95859 + TREE_TYPE(string) = a_type;
95860 + TREE_CONSTANT(string) = 1;
95861 + TREE_READONLY(string) = 1;
95862 +
95863 + return build1(ADDR_EXPR, ptr_type_node, string);
95864 +}
95865 +
95866 +static void insert_cond_result(basic_block bb_true, gimple stmt, tree arg)
95867 +{
95868 + gimple func_stmt, def_stmt;
95869 + tree current_func, loc_file, loc_line;
95870 + expanded_location xloc;
95871 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
95872 +
95873 + def_stmt = get_def_stmt(arg);
95874 + xloc = expand_location(gimple_location(def_stmt));
95875 +
95876 + if (!gimple_has_location(def_stmt)) {
95877 + xloc = expand_location(gimple_location(stmt));
95878 + if (!gimple_has_location(stmt))
95879 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
95880 + }
95881 +
95882 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
95883 +
95884 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
95885 + loc_file = create_string_param(loc_file);
95886 +
95887 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
95888 + current_func = create_string_param(current_func);
95889 +
95890 + // void report_size_overflow(const char *file, unsigned int line, const char *func)
95891 + func_stmt = gimple_build_call(report_size_overflow_decl, 3, loc_file, loc_line, current_func);
95892 +
95893 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
95894 +}
95895 +
95896 +static void __unused print_the_code_insertions(gimple stmt)
95897 +{
95898 + location_t loc = gimple_location(stmt);
95899 +
95900 + inform(loc, "Integer size_overflow check applied here.");
95901 +}
95902 +
95903 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value)
95904 +{
95905 + basic_block cond_bb, join_bb, bb_true;
95906 + edge e;
95907 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
95908 +
95909 + cond_bb = gimple_bb(stmt);
95910 + gsi_prev(&gsi);
95911 + if (gsi_end_p(gsi))
95912 + e = split_block_after_labels(cond_bb);
95913 + else
95914 + e = split_block(cond_bb, gsi_stmt(gsi));
95915 + cond_bb = e->src;
95916 + join_bb = e->dest;
95917 + e->flags = EDGE_FALSE_VALUE;
95918 + e->probability = REG_BR_PROB_BASE;
95919 +
95920 + bb_true = create_empty_bb(cond_bb);
95921 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
95922 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
95923 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
95924 +
95925 + if (dom_info_available_p(CDI_DOMINATORS)) {
95926 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
95927 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
95928 + }
95929 +
95930 + if (current_loops != NULL) {
95931 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
95932 + add_bb_to_loop(bb_true, cond_bb->loop_father);
95933 + }
95934 +
95935 + insert_cond(cond_bb, arg, cond_code, type_value);
95936 + insert_cond_result(bb_true, stmt, arg);
95937 +
95938 +// print_the_code_insertions(stmt);
95939 +}
95940 +
95941 +static tree get_type_for_check(tree rhs)
95942 +{
95943 + tree def_rhs;
95944 + gimple def_stmt = get_def_stmt(rhs);
95945 +
95946 + if (!gimple_assign_cast_p(def_stmt))
95947 + return TREE_TYPE(rhs);
95948 + def_rhs = gimple_assign_rhs1(def_stmt);
95949 + if (TREE_CODE(TREE_TYPE(def_rhs)) == INTEGER_TYPE)
95950 + return TREE_TYPE(def_rhs);
95951 + return TREE_TYPE(rhs);
95952 +}
95953 +
95954 +static gimple cast_to_unsigned_size_overflow_type(gimple stmt, tree cast_rhs)
95955 +{
95956 + gimple ucast_stmt;
95957 + gimple_stmt_iterator gsi;
95958 + location_t loc = gimple_location(stmt);
95959 +
95960 + ucast_stmt = build_cast_stmt(unsigned_size_overflow_type, cast_rhs, CREATE_NEW_VAR, loc);
95961 + gsi = gsi_for_stmt(stmt);
95962 + gsi_insert_before(&gsi, ucast_stmt, GSI_SAME_STMT);
95963 + return ucast_stmt;
95964 +}
95965 +
95966 +static void check_size_overflow(gimple stmt, tree cast_rhs, tree rhs, bool *potentionally_overflowed)
95967 +{
95968 + tree type_max, type_min, rhs_type;
95969 + gimple ucast_stmt;
95970 +
95971 + if (!*potentionally_overflowed)
95972 + return;
95973 +
95974 + rhs_type = get_type_for_check(rhs);
95975 +
95976 + if (TYPE_UNSIGNED(rhs_type)) {
95977 + ucast_stmt = cast_to_unsigned_size_overflow_type(stmt, cast_rhs);
95978 + type_max = cast_a_tree(unsigned_size_overflow_type, TYPE_MAX_VALUE(rhs_type));
95979 + insert_check_size_overflow(stmt, GT_EXPR, gimple_get_lhs(ucast_stmt), type_max);
95980 + } else {
95981 + type_max = cast_a_tree(signed_size_overflow_type, TYPE_MAX_VALUE(rhs_type));
95982 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max);
95983 +
95984 + type_min = cast_a_tree(signed_size_overflow_type, TYPE_MIN_VALUE(rhs_type));
95985 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min);
95986 + }
95987 +}
95988 +
95989 +static tree change_assign_rhs(struct pointer_set_t *visited, bool *potentionally_overflowed, gimple stmt, tree orig_rhs)
95990 +{
95991 + gimple assign;
95992 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
95993 + tree new_rhs, origtype = TREE_TYPE(orig_rhs);
95994 +
95995 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
95996 +
95997 + new_rhs = expand(visited, potentionally_overflowed, orig_rhs);
95998 + if (new_rhs == NULL_TREE)
95999 + return NULL_TREE;
96000 +
96001 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, gimple_location(stmt));
96002 + gsi_insert_before(&gsi, assign, GSI_SAME_STMT);
96003 + update_stmt(assign);
96004 + return gimple_get_lhs(assign);
96005 +}
96006 +
96007 +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))
96008 +{
96009 + tree new_rhs, cast_rhs;
96010 +
96011 + if (gimple_assign_rhs_code(def_stmt) == MIN_EXPR)
96012 + return dup_assign(visited, potentionally_overflowed, def_stmt, new_rhs1, new_rhs2, NULL_TREE);
96013 +
96014 + new_rhs = change_assign_rhs(visited, potentionally_overflowed, def_stmt, rhs);
96015 + if (new_rhs != NULL_TREE) {
96016 + gimple_assign_set_rhs(def_stmt, new_rhs);
96017 + update_stmt(def_stmt);
96018 +
96019 + cast_rhs = gimple_assign_rhs1(get_def_stmt(new_rhs));
96020 +
96021 + check_size_overflow(def_stmt, cast_rhs, rhs, potentionally_overflowed);
96022 + }
96023 + return create_assign(visited, potentionally_overflowed, def_stmt, var, AFTER_STMT);
96024 +}
96025 +
96026 +static tree handle_binary_ops(struct pointer_set_t *visited, bool *potentionally_overflowed, tree var)
96027 +{
96028 + tree rhs1, rhs2;
96029 + gimple def_stmt = get_def_stmt(var);
96030 + tree new_rhs1 = NULL_TREE;
96031 + tree new_rhs2 = NULL_TREE;
96032 +
96033 + rhs1 = gimple_assign_rhs1(def_stmt);
96034 + rhs2 = gimple_assign_rhs2(def_stmt);
96035 +
96036 + /* no DImode/TImode division in the 32/64 bit kernel */
96037 + switch (gimple_assign_rhs_code(def_stmt)) {
96038 + case RDIV_EXPR:
96039 + case TRUNC_DIV_EXPR:
96040 + case CEIL_DIV_EXPR:
96041 + case FLOOR_DIV_EXPR:
96042 + case ROUND_DIV_EXPR:
96043 + case TRUNC_MOD_EXPR:
96044 + case CEIL_MOD_EXPR:
96045 + case FLOOR_MOD_EXPR:
96046 + case ROUND_MOD_EXPR:
96047 + case EXACT_DIV_EXPR:
96048 + case POINTER_PLUS_EXPR:
96049 + case BIT_AND_EXPR:
96050 + return create_assign(visited, potentionally_overflowed, def_stmt, var, AFTER_STMT);
96051 + default:
96052 + break;
96053 + }
96054 +
96055 + *potentionally_overflowed = true;
96056 +
96057 + if (TREE_CODE(rhs1) == SSA_NAME)
96058 + new_rhs1 = expand(visited, potentionally_overflowed, rhs1);
96059 + if (TREE_CODE(rhs2) == SSA_NAME)
96060 + new_rhs2 = expand(visited, potentionally_overflowed, rhs2);
96061 +
96062 + if (is_gimple_constant(rhs2))
96063 + return handle_const_assign(visited, potentionally_overflowed, def_stmt, var, rhs1, new_rhs1, signed_cast_constant(rhs2), &gimple_assign_set_rhs1);
96064 +
96065 + if (is_gimple_constant(rhs1))
96066 + return handle_const_assign(visited, potentionally_overflowed, def_stmt, var, rhs2, signed_cast_constant(rhs1), new_rhs2, &gimple_assign_set_rhs2);
96067 +
96068 + return dup_assign(visited, potentionally_overflowed, def_stmt, new_rhs1, new_rhs2, NULL_TREE);
96069 +}
96070 +
96071 +#if BUILDING_GCC_VERSION >= 4007
96072 +static tree get_new_rhs(struct pointer_set_t *visited, bool *potentionally_overflowed, tree rhs)
96073 +{
96074 + if (is_gimple_constant(rhs))
96075 + return signed_cast_constant(rhs);
96076 + if (TREE_CODE(rhs) != SSA_NAME)
96077 + return NULL_TREE;
96078 + return expand(visited, potentionally_overflowed, rhs);
96079 +}
96080 +
96081 +static tree handle_ternary_ops(struct pointer_set_t *visited, bool *potentionally_overflowed, tree var)
96082 +{
96083 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3;
96084 + gimple def_stmt = get_def_stmt(var);
96085 +
96086 + *potentionally_overflowed = true;
96087 +
96088 + rhs1 = gimple_assign_rhs1(def_stmt);
96089 + rhs2 = gimple_assign_rhs2(def_stmt);
96090 + rhs3 = gimple_assign_rhs3(def_stmt);
96091 + new_rhs1 = get_new_rhs(visited, potentionally_overflowed, rhs1);
96092 + new_rhs2 = get_new_rhs(visited, potentionally_overflowed, rhs2);
96093 + new_rhs3 = get_new_rhs(visited, potentionally_overflowed, rhs3);
96094 +
96095 + if (new_rhs1 == NULL_TREE && new_rhs2 != NULL_TREE && new_rhs3 != NULL_TREE)
96096 + return dup_assign(visited, potentionally_overflowed, def_stmt, new_rhs1, new_rhs2, new_rhs3);
96097 + error("handle_ternary_ops: unknown rhs");
96098 + gcc_unreachable();
96099 +}
96100 +#endif
96101 +
96102 +static void set_size_overflow_type(tree node)
96103 +{
96104 + switch (TYPE_MODE(TREE_TYPE(node))) {
96105 + case SImode:
96106 + signed_size_overflow_type = intDI_type_node;
96107 + unsigned_size_overflow_type = unsigned_intDI_type_node;
96108 + break;
96109 + case DImode:
96110 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode)) {
96111 + signed_size_overflow_type = intDI_type_node;
96112 + unsigned_size_overflow_type = unsigned_intDI_type_node;
96113 + } else {
96114 + signed_size_overflow_type = intTI_type_node;
96115 + unsigned_size_overflow_type = unsigned_intTI_type_node;
96116 + }
96117 + break;
96118 + default:
96119 + error("set_size_overflow_type: unsupported gcc configuration.");
96120 + gcc_unreachable();
96121 + }
96122 +}
96123 +
96124 +static tree expand_visited(gimple def_stmt)
96125 +{
96126 + gimple tmp;
96127 + gimple_stmt_iterator gsi = gsi_for_stmt(def_stmt);
96128 +
96129 + gsi_next(&gsi);
96130 + tmp = gsi_stmt(gsi);
96131 + switch (gimple_code(tmp)) {
96132 + case GIMPLE_ASSIGN:
96133 + return gimple_get_lhs(tmp);
96134 + case GIMPLE_PHI:
96135 + return gimple_phi_result(tmp);
96136 + case GIMPLE_CALL:
96137 + return gimple_call_lhs(tmp);
96138 + default:
96139 + return NULL_TREE;
96140 + }
96141 +}
96142 +
96143 +static tree expand(struct pointer_set_t *visited, bool *potentionally_overflowed, tree var)
96144 +{
96145 + gimple def_stmt;
96146 + enum tree_code code = TREE_CODE(TREE_TYPE(var));
96147 +
96148 + if (is_gimple_constant(var))
96149 + return NULL_TREE;
96150 +
96151 + if (TREE_CODE(var) == ADDR_EXPR)
96152 + return NULL_TREE;
96153 +
96154 + gcc_assert(code == INTEGER_TYPE || code == POINTER_TYPE || code == BOOLEAN_TYPE || code == ENUMERAL_TYPE);
96155 + if (code != INTEGER_TYPE)
96156 + return NULL_TREE;
96157 +
96158 + if (SSA_NAME_IS_DEFAULT_DEF(var)) {
96159 + check_missing_attribute(var);
96160 + return NULL_TREE;
96161 + }
96162 +
96163 + def_stmt = get_def_stmt(var);
96164 +
96165 + if (!def_stmt)
96166 + return NULL_TREE;
96167 +
96168 + if (pointer_set_contains(visited, def_stmt))
96169 + return expand_visited(def_stmt);
96170 +
96171 + switch (gimple_code(def_stmt)) {
96172 + case GIMPLE_NOP:
96173 + check_missing_attribute(var);
96174 + return NULL_TREE;
96175 + case GIMPLE_PHI:
96176 + return build_new_phi(visited, potentionally_overflowed, def_stmt);
96177 + case GIMPLE_CALL:
96178 + case GIMPLE_ASM:
96179 + return create_assign(visited, potentionally_overflowed, def_stmt, var, AFTER_STMT);
96180 + case GIMPLE_ASSIGN:
96181 + switch (gimple_num_ops(def_stmt)) {
96182 + case 2:
96183 + return handle_unary_ops(visited, potentionally_overflowed, var);
96184 + case 3:
96185 + return handle_binary_ops(visited, potentionally_overflowed, var);
96186 +#if BUILDING_GCC_VERSION >= 4007
96187 + case 4:
96188 + return handle_ternary_ops(visited, potentionally_overflowed, var);
96189 +#endif
96190 + }
96191 + default:
96192 + debug_gimple_stmt(def_stmt);
96193 + error("expand: unknown gimple code");
96194 + gcc_unreachable();
96195 + }
96196 +}
96197 +
96198 +static void change_function_arg(gimple stmt, tree origarg, unsigned int argnum, tree newarg)
96199 +{
96200 + gimple assign;
96201 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
96202 + tree origtype = TREE_TYPE(origarg);
96203 +
96204 + gcc_assert(gimple_code(stmt) == GIMPLE_CALL);
96205 +
96206 + assign = build_cast_stmt(origtype, newarg, CREATE_NEW_VAR, gimple_location(stmt));
96207 + gsi_insert_before(&gsi, assign, GSI_SAME_STMT);
96208 + update_stmt(assign);
96209 +
96210 + gimple_call_set_arg(stmt, argnum, gimple_get_lhs(assign));
96211 + update_stmt(stmt);
96212 +}
96213 +
96214 +static tree get_function_arg(unsigned int argnum, gimple stmt, tree fndecl)
96215 +{
96216 + const char *origid;
96217 + tree arg, origarg;
96218 +
96219 + if (!DECL_ABSTRACT_ORIGIN(fndecl)) {
96220 + gcc_assert(gimple_call_num_args(stmt) > argnum);
96221 + return gimple_call_arg(stmt, argnum);
96222 + }
96223 +
96224 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
96225 + while (origarg && argnum) {
96226 + argnum--;
96227 + origarg = TREE_CHAIN(origarg);
96228 + }
96229 +
96230 + gcc_assert(argnum == 0);
96231 +
96232 + gcc_assert(origarg != NULL_TREE);
96233 + origid = NAME(origarg);
96234 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg)) {
96235 + if (!strcmp(origid, NAME(arg)))
96236 + return arg;
96237 + }
96238 + return NULL_TREE;
96239 +}
96240 +
96241 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
96242 +{
96243 + struct pointer_set_t *visited;
96244 + tree arg, newarg, type_max;
96245 + gimple ucast_stmt;
96246 + bool potentionally_overflowed;
96247 +
96248 + arg = get_function_arg(argnum, stmt, fndecl);
96249 + if (arg == NULL_TREE)
96250 + return;
96251 +
96252 + if (is_gimple_constant(arg))
96253 + return;
96254 + if (TREE_CODE(arg) != SSA_NAME)
96255 + return;
96256 +
96257 + check_arg_type(arg);
96258 +
96259 + set_size_overflow_type(arg);
96260 +
96261 + visited = pointer_set_create();
96262 + potentionally_overflowed = false;
96263 + newarg = expand(visited, &potentionally_overflowed, arg);
96264 + pointer_set_destroy(visited);
96265 +
96266 + if (newarg == NULL_TREE || !potentionally_overflowed)
96267 + return;
96268 +
96269 + change_function_arg(stmt, arg, argnum, newarg);
96270 +
96271 + ucast_stmt = cast_to_unsigned_size_overflow_type(stmt, newarg);
96272 +
96273 + type_max = build_int_cstu(unsigned_size_overflow_type, 0x7fffffff);
96274 + insert_check_size_overflow(stmt, GT_EXPR, gimple_get_lhs(ucast_stmt), type_max);
96275 +}
96276 +
96277 +static void handle_function_by_attribute(gimple stmt, tree attr, tree fndecl)
96278 +{
96279 + tree p = TREE_VALUE(attr);
96280 + do {
96281 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p))-1);
96282 + p = TREE_CHAIN(p);
96283 + } while (p);
96284 +}
96285 +
96286 +static void handle_function_by_hash(gimple stmt, tree fndecl)
96287 +{
96288 + tree orig_fndecl;
96289 + struct size_overflow_hash *hash;
96290 + const char *filename = DECL_SOURCE_FILE(fndecl);
96291 +
96292 + orig_fndecl = get_original_function_decl(fndecl);
96293 + hash = get_function_hash(orig_fndecl, filename);
96294 + if (!hash)
96295 + return;
96296 +
96297 +#define search_param(argnum) \
96298 + if (hash->param##argnum) \
96299 + handle_function_arg(stmt, fndecl, argnum - 1);
96300 +
96301 + search_param(1);
96302 + search_param(2);
96303 + search_param(3);
96304 + search_param(4);
96305 + search_param(5);
96306 + search_param(6);
96307 + search_param(7);
96308 + search_param(8);
96309 + search_param(9);
96310 +#undef search_param
96311 +}
96312 +
96313 +static unsigned int handle_function(void)
96314 +{
96315 + basic_block bb = ENTRY_BLOCK_PTR->next_bb;
96316 + int saved_last_basic_block = last_basic_block;
96317 +
96318 + do {
96319 + gimple_stmt_iterator gsi;
96320 + basic_block next = bb->next_bb;
96321 +
96322 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
96323 + tree fndecl, attr;
96324 + gimple stmt = gsi_stmt(gsi);
96325 +
96326 + if (!(is_gimple_call(stmt)))
96327 + continue;
96328 + fndecl = gimple_call_fndecl(stmt);
96329 + if (fndecl == NULL_TREE)
96330 + continue;
96331 + if (gimple_call_num_args(stmt) == 0)
96332 + continue;
96333 + attr = lookup_attribute("size_overflow", TYPE_ATTRIBUTES(TREE_TYPE(fndecl)));
96334 + if (!attr || !TREE_VALUE(attr))
96335 + handle_function_by_hash(stmt, fndecl);
96336 + else
96337 + handle_function_by_attribute(stmt, attr, fndecl);
96338 + gsi = gsi_for_stmt(stmt);
96339 + }
96340 + bb = next;
96341 + } while (bb && bb->index <= saved_last_basic_block);
96342 + return 0;
96343 +}
96344 +
96345 +static struct gimple_opt_pass size_overflow_pass = {
96346 + .pass = {
96347 + .type = GIMPLE_PASS,
96348 + .name = "size_overflow",
96349 + .gate = NULL,
96350 + .execute = handle_function,
96351 + .sub = NULL,
96352 + .next = NULL,
96353 + .static_pass_number = 0,
96354 + .tv_id = TV_NONE,
96355 + .properties_required = PROP_cfg | PROP_referenced_vars,
96356 + .properties_provided = 0,
96357 + .properties_destroyed = 0,
96358 + .todo_flags_start = 0,
96359 + .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
96360 + }
96361 +};
96362 +
96363 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
96364 +{
96365 + tree fntype;
96366 +
96367 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
96368 +
96369 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func)
96370 + fntype = build_function_type_list(void_type_node,
96371 + const_char_ptr_type_node,
96372 + unsigned_type_node,
96373 + const_char_ptr_type_node,
96374 + NULL_TREE);
96375 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
96376 +
96377 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
96378 + TREE_PUBLIC(report_size_overflow_decl) = 1;
96379 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
96380 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
96381 +}
96382 +
96383 +extern struct gimple_opt_pass pass_dce;
96384 +
96385 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
96386 +{
96387 + int i;
96388 + const char * const plugin_name = plugin_info->base_name;
96389 + const int argc = plugin_info->argc;
96390 + const struct plugin_argument * const argv = plugin_info->argv;
96391 + bool enable = true;
96392 +
96393 + struct register_pass_info size_overflow_pass_info = {
96394 + .pass = &size_overflow_pass.pass,
96395 + .reference_pass_name = "ssa",
96396 + .ref_pass_instance_number = 1,
96397 + .pos_op = PASS_POS_INSERT_AFTER
96398 + };
96399 +
96400 + if (!plugin_default_version_check(version, &gcc_version)) {
96401 + error(G_("incompatible gcc/plugin versions"));
96402 + return 1;
96403 + }
96404 +
96405 + for (i = 0; i < argc; ++i) {
96406 + if (!strcmp(argv[i].key, "no-size-overflow")) {
96407 + enable = false;
96408 + continue;
96409 + } else if (!(strcmp(argv[i].key, "no-file-match"))) {
96410 + file_match = false;
96411 + continue;
96412 + }
96413 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
96414 + }
96415 +
96416 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
96417 + if (enable) {
96418 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
96419 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
96420 + }
96421 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
96422 +
96423 + return 0;
96424 +}
96425 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
96426 new file mode 100644
96427 index 0000000..b87ec9d
96428 --- /dev/null
96429 +++ b/tools/gcc/stackleak_plugin.c
96430 @@ -0,0 +1,313 @@
96431 +/*
96432 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
96433 + * Licensed under the GPL v2
96434 + *
96435 + * Note: the choice of the license means that the compilation process is
96436 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
96437 + * but for the kernel it doesn't matter since it doesn't link against
96438 + * any of the gcc libraries
96439 + *
96440 + * gcc plugin to help implement various PaX features
96441 + *
96442 + * - track lowest stack pointer
96443 + *
96444 + * TODO:
96445 + * - initialize all local variables
96446 + *
96447 + * BUGS:
96448 + * - none known
96449 + */
96450 +#include "gcc-plugin.h"
96451 +#include "config.h"
96452 +#include "system.h"
96453 +#include "coretypes.h"
96454 +#include "tree.h"
96455 +#include "tree-pass.h"
96456 +#include "flags.h"
96457 +#include "intl.h"
96458 +#include "toplev.h"
96459 +#include "plugin.h"
96460 +//#include "expr.h" where are you...
96461 +#include "diagnostic.h"
96462 +#include "plugin-version.h"
96463 +#include "tm.h"
96464 +#include "function.h"
96465 +#include "basic-block.h"
96466 +#include "gimple.h"
96467 +#include "rtl.h"
96468 +#include "emit-rtl.h"
96469 +
96470 +extern void print_gimple_stmt(FILE *, gimple, int, int);
96471 +
96472 +int plugin_is_GPL_compatible;
96473 +
96474 +static int track_frame_size = -1;
96475 +static const char track_function[] = "pax_track_stack";
96476 +static const char check_function[] = "pax_check_alloca";
96477 +static bool init_locals;
96478 +
96479 +static struct plugin_info stackleak_plugin_info = {
96480 + .version = "201203140940",
96481 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
96482 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
96483 +};
96484 +
96485 +static bool gate_stackleak_track_stack(void);
96486 +static unsigned int execute_stackleak_tree_instrument(void);
96487 +static unsigned int execute_stackleak_final(void);
96488 +
96489 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
96490 + .pass = {
96491 + .type = GIMPLE_PASS,
96492 + .name = "stackleak_tree_instrument",
96493 + .gate = gate_stackleak_track_stack,
96494 + .execute = execute_stackleak_tree_instrument,
96495 + .sub = NULL,
96496 + .next = NULL,
96497 + .static_pass_number = 0,
96498 + .tv_id = TV_NONE,
96499 + .properties_required = PROP_gimple_leh | PROP_cfg,
96500 + .properties_provided = 0,
96501 + .properties_destroyed = 0,
96502 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
96503 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
96504 + }
96505 +};
96506 +
96507 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
96508 + .pass = {
96509 + .type = RTL_PASS,
96510 + .name = "stackleak_final",
96511 + .gate = gate_stackleak_track_stack,
96512 + .execute = execute_stackleak_final,
96513 + .sub = NULL,
96514 + .next = NULL,
96515 + .static_pass_number = 0,
96516 + .tv_id = TV_NONE,
96517 + .properties_required = 0,
96518 + .properties_provided = 0,
96519 + .properties_destroyed = 0,
96520 + .todo_flags_start = 0,
96521 + .todo_flags_finish = TODO_dump_func
96522 + }
96523 +};
96524 +
96525 +static bool gate_stackleak_track_stack(void)
96526 +{
96527 + return track_frame_size >= 0;
96528 +}
96529 +
96530 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
96531 +{
96532 + gimple check_alloca;
96533 + tree fntype, fndecl, alloca_size;
96534 +
96535 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
96536 + fndecl = build_fn_decl(check_function, fntype);
96537 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
96538 +
96539 + // insert call to void pax_check_alloca(unsigned long size)
96540 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
96541 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
96542 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
96543 +}
96544 +
96545 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
96546 +{
96547 + gimple track_stack;
96548 + tree fntype, fndecl;
96549 +
96550 + fntype = build_function_type_list(void_type_node, NULL_TREE);
96551 + fndecl = build_fn_decl(track_function, fntype);
96552 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
96553 +
96554 + // insert call to void pax_track_stack(void)
96555 + track_stack = gimple_build_call(fndecl, 0);
96556 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
96557 +}
96558 +
96559 +#if BUILDING_GCC_VERSION == 4005
96560 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
96561 +{
96562 + tree fndecl;
96563 +
96564 + if (!is_gimple_call(stmt))
96565 + return false;
96566 + fndecl = gimple_call_fndecl(stmt);
96567 + if (!fndecl)
96568 + return false;
96569 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
96570 + return false;
96571 +// print_node(stderr, "pax", fndecl, 4);
96572 + return DECL_FUNCTION_CODE(fndecl) == code;
96573 +}
96574 +#endif
96575 +
96576 +static bool is_alloca(gimple stmt)
96577 +{
96578 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
96579 + return true;
96580 +
96581 +#if BUILDING_GCC_VERSION >= 4007
96582 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
96583 + return true;
96584 +#endif
96585 +
96586 + return false;
96587 +}
96588 +
96589 +static unsigned int execute_stackleak_tree_instrument(void)
96590 +{
96591 + basic_block bb, entry_bb;
96592 + bool prologue_instrumented = false, is_leaf = true;
96593 +
96594 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
96595 +
96596 + // 1. loop through BBs and GIMPLE statements
96597 + FOR_EACH_BB(bb) {
96598 + gimple_stmt_iterator gsi;
96599 +
96600 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
96601 + gimple stmt;
96602 +
96603 + stmt = gsi_stmt(gsi);
96604 +
96605 + if (is_gimple_call(stmt))
96606 + is_leaf = false;
96607 +
96608 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
96609 + if (!is_alloca(stmt))
96610 + continue;
96611 +
96612 + // 2. insert stack overflow check before each __builtin_alloca call
96613 + stackleak_check_alloca(&gsi);
96614 +
96615 + // 3. insert track call after each __builtin_alloca call
96616 + stackleak_add_instrumentation(&gsi);
96617 + if (bb == entry_bb)
96618 + prologue_instrumented = true;
96619 + }
96620 + }
96621 +
96622 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
96623 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
96624 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
96625 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
96626 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
96627 + return 0;
96628 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
96629 + return 0;
96630 +
96631 + // 4. insert track call at the beginning
96632 + if (!prologue_instrumented) {
96633 + gimple_stmt_iterator gsi;
96634 +
96635 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
96636 + if (dom_info_available_p(CDI_DOMINATORS))
96637 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
96638 + gsi = gsi_start_bb(bb);
96639 + stackleak_add_instrumentation(&gsi);
96640 + }
96641 +
96642 + return 0;
96643 +}
96644 +
96645 +static unsigned int execute_stackleak_final(void)
96646 +{
96647 + rtx insn;
96648 +
96649 + if (cfun->calls_alloca)
96650 + return 0;
96651 +
96652 + // keep calls only if function frame is big enough
96653 + if (get_frame_size() >= track_frame_size)
96654 + return 0;
96655 +
96656 + // 1. find pax_track_stack calls
96657 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
96658 + // 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))
96659 + rtx body;
96660 +
96661 + if (!CALL_P(insn))
96662 + continue;
96663 + body = PATTERN(insn);
96664 + if (GET_CODE(body) != CALL)
96665 + continue;
96666 + body = XEXP(body, 0);
96667 + if (GET_CODE(body) != MEM)
96668 + continue;
96669 + body = XEXP(body, 0);
96670 + if (GET_CODE(body) != SYMBOL_REF)
96671 + continue;
96672 + if (strcmp(XSTR(body, 0), track_function))
96673 + continue;
96674 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
96675 + // 2. delete call
96676 + insn = delete_insn_and_edges(insn);
96677 +#if BUILDING_GCC_VERSION >= 4007
96678 + if (GET_CODE(insn) == NOTE && NOTE_KIND(insn) == NOTE_INSN_CALL_ARG_LOCATION)
96679 + insn = delete_insn_and_edges(insn);
96680 +#endif
96681 + }
96682 +
96683 +// print_simple_rtl(stderr, get_insns());
96684 +// print_rtl(stderr, get_insns());
96685 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
96686 +
96687 + return 0;
96688 +}
96689 +
96690 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
96691 +{
96692 + const char * const plugin_name = plugin_info->base_name;
96693 + const int argc = plugin_info->argc;
96694 + const struct plugin_argument * const argv = plugin_info->argv;
96695 + int i;
96696 + struct register_pass_info stackleak_tree_instrument_pass_info = {
96697 + .pass = &stackleak_tree_instrument_pass.pass,
96698 +// .reference_pass_name = "tree_profile",
96699 + .reference_pass_name = "optimized",
96700 + .ref_pass_instance_number = 0,
96701 + .pos_op = PASS_POS_INSERT_BEFORE
96702 + };
96703 + struct register_pass_info stackleak_final_pass_info = {
96704 + .pass = &stackleak_final_rtl_opt_pass.pass,
96705 + .reference_pass_name = "final",
96706 + .ref_pass_instance_number = 0,
96707 + .pos_op = PASS_POS_INSERT_BEFORE
96708 + };
96709 +
96710 + if (!plugin_default_version_check(version, &gcc_version)) {
96711 + error(G_("incompatible gcc/plugin versions"));
96712 + return 1;
96713 + }
96714 +
96715 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
96716 +
96717 + for (i = 0; i < argc; ++i) {
96718 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
96719 + if (!argv[i].value) {
96720 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
96721 + continue;
96722 + }
96723 + track_frame_size = atoi(argv[i].value);
96724 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
96725 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
96726 + continue;
96727 + }
96728 + if (!strcmp(argv[i].key, "initialize-locals")) {
96729 + if (argv[i].value) {
96730 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
96731 + continue;
96732 + }
96733 + init_locals = true;
96734 + continue;
96735 + }
96736 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
96737 + }
96738 +
96739 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
96740 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
96741 +
96742 + return 0;
96743 +}
96744 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
96745 index 6789d78..4afd019 100644
96746 --- a/tools/perf/util/include/asm/alternative-asm.h
96747 +++ b/tools/perf/util/include/asm/alternative-asm.h
96748 @@ -5,4 +5,7 @@
96749
96750 #define altinstruction_entry #
96751
96752 + .macro pax_force_retaddr rip=0, reload=0
96753 + .endm
96754 +
96755 #endif
96756 diff --git a/usr/gen_init_cpio.c b/usr/gen_init_cpio.c
96757 index af0f22f..9a7d479 100644
96758 --- a/usr/gen_init_cpio.c
96759 +++ b/usr/gen_init_cpio.c
96760 @@ -303,7 +303,7 @@ static int cpio_mkfile(const char *name, const char *location,
96761 int retval;
96762 int rc = -1;
96763 int namesize;
96764 - int i;
96765 + unsigned int i;
96766
96767 mode |= S_IFREG;
96768
96769 @@ -392,9 +392,10 @@ static char *cpio_replace_env(char *new_location)
96770 *env_var = *expanded = '\0';
96771 strncat(env_var, start + 2, end - start - 2);
96772 strncat(expanded, new_location, start - new_location);
96773 - strncat(expanded, getenv(env_var), PATH_MAX);
96774 - strncat(expanded, end + 1, PATH_MAX);
96775 + strncat(expanded, getenv(env_var), PATH_MAX - strlen(expanded));
96776 + strncat(expanded, end + 1, PATH_MAX - strlen(expanded));
96777 strncpy(new_location, expanded, PATH_MAX);
96778 + new_location[PATH_MAX] = 0;
96779 } else
96780 break;
96781 }
96782 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
96783 index 7858228..2919715 100644
96784 --- a/virt/kvm/kvm_main.c
96785 +++ b/virt/kvm/kvm_main.c
96786 @@ -75,7 +75,7 @@ LIST_HEAD(vm_list);
96787
96788 static cpumask_var_t cpus_hardware_enabled;
96789 static int kvm_usage_count = 0;
96790 -static atomic_t hardware_enable_failed;
96791 +static atomic_unchecked_t hardware_enable_failed;
96792
96793 struct kmem_cache *kvm_vcpu_cache;
96794 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
96795 @@ -2318,7 +2318,7 @@ static void hardware_enable_nolock(void *junk)
96796
96797 if (r) {
96798 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
96799 - atomic_inc(&hardware_enable_failed);
96800 + atomic_inc_unchecked(&hardware_enable_failed);
96801 printk(KERN_INFO "kvm: enabling virtualization on "
96802 "CPU%d failed\n", cpu);
96803 }
96804 @@ -2372,10 +2372,10 @@ static int hardware_enable_all(void)
96805
96806 kvm_usage_count++;
96807 if (kvm_usage_count == 1) {
96808 - atomic_set(&hardware_enable_failed, 0);
96809 + atomic_set_unchecked(&hardware_enable_failed, 0);
96810 on_each_cpu(hardware_enable_nolock, NULL, 1);
96811
96812 - if (atomic_read(&hardware_enable_failed)) {
96813 + if (atomic_read_unchecked(&hardware_enable_failed)) {
96814 hardware_disable_all_nolock();
96815 r = -EBUSY;
96816 }
96817 @@ -2738,7 +2738,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
96818 kvm_arch_vcpu_put(vcpu);
96819 }
96820
96821 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
96822 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
96823 struct module *module)
96824 {
96825 int r;
96826 @@ -2801,7 +2801,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
96827 if (!vcpu_align)
96828 vcpu_align = __alignof__(struct kvm_vcpu);
96829 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
96830 - 0, NULL);
96831 + SLAB_USERCOPY, NULL);
96832 if (!kvm_vcpu_cache) {
96833 r = -ENOMEM;
96834 goto out_free_3;
96835 @@ -2811,9 +2811,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
96836 if (r)
96837 goto out_free;
96838
96839 - kvm_chardev_ops.owner = module;
96840 - kvm_vm_fops.owner = module;
96841 - kvm_vcpu_fops.owner = module;
96842 + pax_open_kernel();
96843 + *(void **)&kvm_chardev_ops.owner = module;
96844 + *(void **)&kvm_vm_fops.owner = module;
96845 + *(void **)&kvm_vcpu_fops.owner = module;
96846 + pax_close_kernel();
96847
96848 r = misc_register(&kvm_dev);
96849 if (r) {