diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2014-01-17 12:34:34 -0500 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2014-01-17 12:34:34 -0500 |
commit | 2692170fcef8753937e6219ded744a4a52d2a5e1 (patch) | |
tree | 37e94d196764edcbad8f1d4e6f5d2893fffcbdfa /3.2.54 | |
parent | Grsec/PaX: 3.0-{3.2.54,3.12.7}-201401091837 (diff) | |
download | hardened-patchset-2692170fcef8753937e6219ded744a4a52d2a5e1.tar.gz hardened-patchset-2692170fcef8753937e6219ded744a4a52d2a5e1.tar.bz2 hardened-patchset-2692170fcef8753937e6219ded744a4a52d2a5e1.zip |
Grsec/PaX: 3.0-{3.2.54,3.12.7}-201401131812
Diffstat (limited to '3.2.54')
-rw-r--r-- | 3.2.54/0000_README | 2 | ||||
-rw-r--r-- | 3.2.54/4420_grsecurity-3.0-3.2.54-201401160931.patch (renamed from 3.2.54/4420_grsecurity-3.0-3.2.54-201401091839.patch) | 373 |
2 files changed, 259 insertions, 116 deletions
diff --git a/3.2.54/0000_README b/3.2.54/0000_README index d65044f..155b184 100644 --- a/3.2.54/0000_README +++ b/3.2.54/0000_README @@ -134,7 +134,7 @@ Patch: 1053_linux-3.2.54.patch From: http://www.kernel.org Desc: Linux 3.2.54 -Patch: 4420_grsecurity-3.0-3.2.54-201401091839.patch +Patch: 4420_grsecurity-3.0-3.2.54-201401160931.patch From: http://www.grsecurity.net Desc: hardened-sources base patch from upstream grsecurity diff --git a/3.2.54/4420_grsecurity-3.0-3.2.54-201401091839.patch b/3.2.54/4420_grsecurity-3.0-3.2.54-201401160931.patch index 5e87908..6d2be70 100644 --- a/3.2.54/4420_grsecurity-3.0-3.2.54-201401091839.patch +++ b/3.2.54/4420_grsecurity-3.0-3.2.54-201401160931.patch @@ -270,7 +270,7 @@ index 88fd7f5..b318a78 100644 ============================================================== diff --git a/Makefile b/Makefile -index 848be26..3deab0e 100644 +index 848be26..67efb38f 100644 --- a/Makefile +++ b/Makefile @@ -245,8 +245,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ @@ -389,7 +389,13 @@ index 848be26..3deab0e 100644 $(Q)$(MAKE) $(build)=$@ # Store (new) KERNELRELASE string in include/config/kernel.release -@@ -985,6 +1047,7 @@ prepare0: archprepare FORCE +@@ -981,10 +1043,13 @@ prepare1: prepare2 include/linux/version.h include/generated/utsrelease.h \ + + archprepare: archscripts prepare1 scripts_basic + ++prepare0: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS) ++prepare0: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS) + prepare0: archprepare FORCE $(Q)$(MAKE) $(build)=. # All the preparing.. @@ -397,7 +403,7 @@ index 848be26..3deab0e 100644 prepare: prepare0 # Generate some files -@@ -1089,6 +1152,8 @@ all: modules +@@ -1089,6 +1154,8 @@ all: modules # using awk while concatenating to the final file. PHONY += modules @@ -406,7 +412,7 @@ index 848be26..3deab0e 100644 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order @$(kecho) ' Building modules, stage 2.'; -@@ -1104,7 +1169,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin) +@@ -1104,7 +1171,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin) # Target to prepare building external modules PHONY += modules_prepare @@ -415,7 +421,7 @@ index 848be26..3deab0e 100644 # Target to install modules PHONY += modules_install -@@ -1163,7 +1228,7 @@ CLEAN_FILES += vmlinux System.map \ +@@ -1163,7 +1230,7 @@ CLEAN_FILES += vmlinux System.map \ MRPROPER_DIRS += include/config usr/include include/generated \ arch/*/include/generated MRPROPER_FILES += .config .config.old .version .old_version \ @@ -424,7 +430,7 @@ index 848be26..3deab0e 100644 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS # clean - Delete most, but leave enough to build external modules -@@ -1201,6 +1266,7 @@ distclean: mrproper +@@ -1201,6 +1268,7 @@ distclean: mrproper \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ -o -name '.*.rej' \ @@ -432,7 +438,7 @@ index 848be26..3deab0e 100644 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \ -type f -print | xargs rm -f -@@ -1361,6 +1427,8 @@ PHONY += $(module-dirs) modules +@@ -1361,6 +1429,8 @@ PHONY += $(module-dirs) modules $(module-dirs): crmodverdir $(objtree)/Module.symvers $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@) @@ -441,7 +447,7 @@ index 848be26..3deab0e 100644 modules: $(module-dirs) @$(kecho) ' Building modules, stage 2.'; $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost -@@ -1487,17 +1555,21 @@ else +@@ -1487,17 +1557,21 @@ else target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@)) endif @@ -467,7 +473,7 @@ index 848be26..3deab0e 100644 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) %.symtypes: %.c prepare scripts FORCE $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -@@ -1507,11 +1579,15 @@ endif +@@ -1507,11 +1581,15 @@ endif $(cmd_crmodverdir) $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ $(build)=$(build-dir) @@ -5315,7 +5321,7 @@ index 745c1e7..59d97a6 100644 break; } diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c -index 2e3200c..72095ce 100644 +index 2e3200c..7118986 100644 --- a/arch/powerpc/kernel/module_32.c +++ b/arch/powerpc/kernel/module_32.c @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr, @@ -5347,6 +5353,15 @@ index 2e3200c..72095ce 100644 /* Find this entry, or if that fails, the next avail. entry */ while (entry->jump[0]) { +@@ -300,7 +305,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, + } + #ifdef CONFIG_DYNAMIC_FTRACE + module->arch.tramp = +- do_plt_call(module->module_core, ++ do_plt_call(module->module_core_rx, + (unsigned long)ftrace_caller, + sechdrs, module); + #endif diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index d687e3f..074a8cd 100644 --- a/arch/powerpc/kernel/process.c @@ -37067,18 +37082,9 @@ index 2581202..f230a8d9 100644 *sequence = cur_fence; diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c -index 5fc201b..7b032b9 100644 +index 5fc201b..20b6980 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c -@@ -201,7 +201,7 @@ struct methods { - const char desc[8]; - void (*loadbios)(struct drm_device *, uint8_t *); - const bool rw; --}; -+} __do_const; - - static struct methods shadow_methods[] = { - { "PRAMIN", load_vbios_pramin, true }, @@ -5474,7 +5474,7 @@ parse_bit_U_tbl_entry(struct drm_device *dev, struct nvbios *bios, struct bit_table { const char id; @@ -41249,6 +41255,21 @@ index 639abee..e2336f4 100644 *kernel_ptr = (void *)&ctrls->controls; *array_size = sizeof(struct v4l2_ext_control) * ctrls->count; +diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c +index 7d754fb..474273b 100644 +--- a/drivers/media/video/vivi.c ++++ b/drivers/media/video/vivi.c +@@ -51,8 +51,8 @@ MODULE_AUTHOR("Mauro Carvalho Chehab, Ted Walther and John Sokol"); + MODULE_LICENSE("Dual BSD/GPL"); + MODULE_VERSION(VIVI_VERSION); + +-static unsigned video_nr = -1; +-module_param(video_nr, uint, 0644); ++static int video_nr = -1; ++module_param(video_nr, int, 0644); + MODULE_PARM_DESC(video_nr, "videoX start number, -1 is autodetect"); + + static unsigned n_devs = 1; diff --git a/drivers/memstick/host/r592.c b/drivers/memstick/host/r592.c index 668f5c6..65df5f2 100644 --- a/drivers/memstick/host/r592.c @@ -47335,7 +47356,7 @@ index 3440812..2a4ef1f 100644 file->f_version = event_count; return POLLIN | POLLRDNORM; diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c -index 49257b3..de27d93 100644 +index 49257b3..13133cd 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -147,7 +147,7 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes, @@ -47347,7 +47368,7 @@ index 49257b3..de27d93 100644 loff_t pos; int i; -@@ -189,16 +189,16 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes, +@@ -189,22 +189,22 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes, for (i = 0; nbytes && i < dev->descriptor.bNumConfigurations; i++) { struct usb_config_descriptor *config = (struct usb_config_descriptor *)dev->rawdescriptors[i]; @@ -47367,6 +47388,13 @@ index 49257b3..de27d93 100644 if (len > nbytes) len = nbytes; + /* Simply don't write (skip over) unallocated parts */ + if (alloclen > (*ppos - pos)) { +- alloclen -= (*ppos - pos); ++ alloclen = alloclen + pos - *ppos; + if (copy_to_user(buf, + dev->rawdescriptors[i] + (*ppos - pos), + min(len, alloclen))) { diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 032e5a6..bc422e4 100644 --- a/drivers/usb/core/hcd.c @@ -73987,19 +74015,6 @@ index 7925bf0..d5143d2 100644 #define free(a) kfree(a) #define large_malloc(a) vmalloc(a) -diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h -index 98ce812..9afa76d 100644 ---- a/include/linux/devfreq.h -+++ b/include/linux/devfreq.h -@@ -100,7 +100,7 @@ struct devfreq_governor { - int (*init)(struct devfreq *this); - void (*exit)(struct devfreq *this); - const bool no_central_polling; --}; -+} __do_const; - - /** - * struct devfreq - Device devfreq structure diff --git a/include/linux/device.h b/include/linux/device.h index 3136ede..9a589c5 100644 --- a/include/linux/device.h @@ -76948,19 +76963,6 @@ index 857f502..350a113 100644 /* Function to register/unregister hook points. */ int nf_register_hook(struct nf_hook_ops *reg); -diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h -index 3540c6e..83adb6c 100644 ---- a/include/linux/netfilter/ipset/ip_set.h -+++ b/include/linux/netfilter/ipset/ip_set.h -@@ -274,7 +274,7 @@ struct ip_set_type_variant { - /* Return true if "b" set is the same as "a" - * according to the create set parameters */ - bool (*same_set)(const struct ip_set *a, const struct ip_set *b); --}; -+} __do_const; - - /* The core set type structure */ - struct ip_set_type { diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h index 74d3386..e800dbf 100644 --- a/include/linux/netfilter/nfnetlink.h @@ -101813,10 +101815,10 @@ index 38f6617..e70b72b 100755 exuberant() diff --git a/security/Kconfig b/security/Kconfig -index 51bd5a0..ce4aad0 100644 +index 51bd5a0..62953d6 100644 --- a/security/Kconfig +++ b/security/Kconfig -@@ -4,6 +4,954 @@ +@@ -4,6 +4,953 @@ menu "Security options" @@ -102126,7 +102128,6 @@ index 51bd5a0..ce4aad0 100644 + select CIFS_XATTR if CIFS + select EXT2_FS_XATTR if EXT2_FS + select EXT3_FS_XATTR if EXT3_FS -+ select EXT4_FS_XATTR if EXT4_FS + select JFFS2_FS_XATTR if JFFS2_FS + select REISERFS_FS_XATTR if REISERFS_FS + select SQUASHFS_XATTR if SQUASHFS @@ -102771,7 +102772,7 @@ index 51bd5a0..ce4aad0 100644 config KEYS bool "Enable access key retention support" help -@@ -169,7 +1117,7 @@ config INTEL_TXT +@@ -169,7 +1116,7 @@ config INTEL_TXT config LSM_MMAP_MIN_ADDR int "Low address space for LSM to protect from user allocation" depends on SECURITY && SECURITY_SELINUX @@ -105287,10 +105288,10 @@ index 0000000..414fe5e +} diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c new file mode 100644 -index 0000000..c17312d +index 0000000..3e46b2f --- /dev/null +++ b/tools/gcc/constify_plugin.c -@@ -0,0 +1,560 @@ +@@ -0,0 +1,559 @@ +/* + * Copyright 2011 by Emese Revfy <re.emese@gmail.com> + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu> @@ -105337,7 +105338,7 @@ index 0000000..c17312d +int plugin_is_GPL_compatible; + +static struct plugin_info const_plugin_info = { -+ .version = "201305231310", ++ .version = "201401121315", + .help = "no-constify\tturn off constification\n", +}; + @@ -105502,22 +105503,21 @@ index 0000000..c17312d + + *no_add_attrs = true; + if (TREE_CODE(*node) == FUNCTION_DECL) { -+ error("%qE attribute does not apply to functions", name); ++ error("%qE attribute does not apply to functions (%qF)", name, *node); + return NULL_TREE; + } + + if (TREE_CODE(*node) == PARM_DECL) { -+ error("%qE attribute does not apply to function parameters", name); ++ error("%qE attribute does not apply to function parameters (%qD)", name, *node); + return NULL_TREE; + } + + if (TREE_CODE(*node) == VAR_DECL) { -+ error("%qE attribute does not apply to variables", name); ++ error("%qE attribute does not apply to variables (%qD)", name, *node); + return NULL_TREE; + } + + if (TYPE_P(*node)) { -+ *no_add_attrs = false; + type = *node; + } else { + gcc_assert(TREE_CODE(*node) == TYPE_DECL); @@ -105525,18 +105525,20 @@ index 0000000..c17312d + } + + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) { -+ error("%qE attribute applies to struct and union types only", name); ++ error("%qE attribute used on %qT applies to struct and union types only", name, type); + return NULL_TREE; + } + + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) { -+ error("%qE attribute is already applied to the type", name); ++ error("%qE attribute is already applied to the type %qT", name, type); + return NULL_TREE; + } + + if (TYPE_P(*node)) { + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) -+ error("%qE attribute is incompatible with 'do_const'", name); ++ error("%qE attribute used on type %qT is incompatible with 'do_const'", name, type); ++ else ++ *no_add_attrs = false; + return NULL_TREE; + } + @@ -105547,7 +105549,7 @@ index 0000000..c17312d + return NULL_TREE; + } + -+ error("%qE attribute used on type that is not constified", name); ++ error("%qE attribute used on type %qT that is not constified", name, type); + return NULL_TREE; +} + @@ -105563,22 +105565,22 @@ index 0000000..c17312d +{ + *no_add_attrs = true; + if (!TYPE_P(*node)) { -+ error("%qE attribute applies to types only", name); ++ error("%qE attribute applies to types only (%qD)", name, *node); + return NULL_TREE; + } + + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) { -+ error("%qE attribute applies to struct and union types only", name); ++ error("%qE attribute used on %qT applies to struct and union types only", name, *node); + return NULL_TREE; + } + + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) { -+ error("%qE attribute is already applied to the type", name); ++ error("%qE attribute used on %qT is already applied to the type", name, *node); + return NULL_TREE; + } + + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) { -+ error("%qE attribute is incompatible with 'no_const'", name); ++ error("%qE attribute used on %qT is incompatible with 'no_const'", name, *node); + return NULL_TREE; + } + @@ -105636,30 +105638,29 @@ index 0000000..c17312d + + constifiable(type, &cinfo); + -+ if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) { -+ if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) -+ return; -+ if (cinfo.has_writable_field) -+ return; -+ error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not "); -+ return; -+ } -+ + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) { + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) { + deconstify_type(type); + TYPE_CONSTIFY_VISITED(type) = 1; + } else -+ error("'no_const' attribute used on type that is not constified"); ++ error("'no_const' attribute used on type %qT that is not constified", type); + return; + } + + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) { ++ if (!cinfo.has_writable_field) { ++ error("'do_const' attribute used on type %qT that is%sconstified", type, cinfo.has_fptr_field ? " " : " not "); ++ return; ++ } + constify_type(type); + return; + } + + if (cinfo.has_fptr_field && !cinfo.has_writable_field) { ++ if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) { ++ error("'do_const' attribute used on type %qT that is constified", type); ++ return; ++ } + constify_type(type); + return; + } @@ -105747,7 +105748,6 @@ index 0000000..c17312d + return check_local_variables(); +} + -+ unsigned int ret = 0; +static struct gimple_opt_pass pass_local_variable = { + { + .type = GIMPLE_PASS, @@ -112954,12 +112954,12 @@ index 0000000..2d131cc +selnl_msglen_65499 selnl_msglen 0 65499 NULL diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c new file mode 100644 -index 0000000..5515dcb +index 0000000..62a1ae8 --- /dev/null +++ b/tools/gcc/size_overflow_plugin.c -@@ -0,0 +1,3927 @@ +@@ -0,0 +1,4050 @@ +/* -+ * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com> ++ * Copyright 2011, 2012, 2013, 2014 by Emese Revfy <re.emese@gmail.com> + * Licensed under the GPL v2, or (at your option) v3 + * + * Homepage: @@ -113087,7 +113087,7 @@ index 0000000..5515dcb +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3); + +static struct plugin_info size_overflow_plugin_info = { -+ .version = "20131214beta", ++ .version = "20140102beta", + .help = "no-size-overflow\tturn off size overflow checking\n", +}; + @@ -116534,6 +116534,141 @@ index 0000000..5515dcb + create_asm_stmt(str, build_string(1, "0"), build_string(3, "=rm"), &asm_data); +} + ++// Insert an asm stmt with "MARK_TURN_OFF", "MARK_YES" or "MARK_NOT_INTENTIONAL". ++static bool create_mark_asm(gimple stmt, enum mark mark) ++{ ++ struct asm_data asm_data; ++ const char *asm_str; ++ ++ switch (mark) { ++ case MARK_TURN_OFF: ++ asm_str = TURN_OFF_ASM_STR; ++ break; ++ case MARK_NOT_INTENTIONAL: ++ case MARK_YES: ++ asm_str = YES_ASM_STR; ++ break; ++ default: ++ gcc_unreachable(); ++ } ++ ++ asm_data.def_stmt = stmt; ++ asm_data.output = gimple_call_lhs(stmt); ++ ++ if (asm_data.output == NULL_TREE) { ++ asm_data.input = gimple_call_arg(stmt, 0); ++ if (is_gimple_constant(asm_data.input)) ++ return false; ++ asm_data.output = NULL; ++ create_asm_stmt(asm_str, build_string(2, "rm"), NULL, &asm_data); ++ return true; ++ } ++ ++ create_asm_input(stmt, 0, &asm_data); ++ gcc_assert(asm_data.input != NULL_TREE); ++ ++ create_asm_stmt(asm_str, build_string(1, "0"), build_string(3, "=rm"), &asm_data); ++ return true; ++} ++ ++static bool is_from_cast(const_tree node) ++{ ++ gimple def_stmt = get_def_stmt(node); ++ ++ if (!def_stmt) ++ return false; ++ ++ if (gimple_assign_cast_p(def_stmt)) ++ return true; ++ ++ return false; ++} ++ ++// Skip duplication when there is a minus expr and the type of rhs1 or rhs2 is a pointer_type. ++static bool skip_ptr_minus(gimple stmt) ++{ ++ const_tree rhs1, rhs2, ptr1_rhs, ptr2_rhs; ++ ++ if (gimple_assign_rhs_code(stmt) != MINUS_EXPR) ++ return false; ++ ++ rhs1 = gimple_assign_rhs1(stmt); ++ if (!is_from_cast(rhs1)) ++ return false; ++ ++ rhs2 = gimple_assign_rhs2(stmt); ++ if (!is_from_cast(rhs2)) ++ return false; ++ ++ ptr1_rhs = gimple_assign_rhs1(get_def_stmt(rhs1)); ++ ptr2_rhs = gimple_assign_rhs1(get_def_stmt(rhs2)); ++ ++ if (TREE_CODE(TREE_TYPE(ptr1_rhs)) != POINTER_TYPE && TREE_CODE(TREE_TYPE(ptr2_rhs)) != POINTER_TYPE) ++ return false; ++ ++ create_mark_asm(stmt, MARK_YES); ++ return true; ++} ++ ++static void walk_use_def_ptr(struct pointer_set_t *visited, const_tree lhs) ++{ ++ gimple def_stmt; ++ ++ def_stmt = get_def_stmt(lhs); ++ if (!def_stmt) ++ return; ++ ++ if (pointer_set_insert(visited, def_stmt)) ++ return; ++ ++ switch (gimple_code(def_stmt)) { ++ case GIMPLE_NOP: ++ case GIMPLE_ASM: ++ case GIMPLE_CALL: ++ break; ++ case GIMPLE_PHI: { ++ unsigned int i, n = gimple_phi_num_args(def_stmt); ++ ++ pointer_set_insert(visited, def_stmt); ++ ++ for (i = 0; i < n; i++) { ++ tree arg = gimple_phi_arg_def(def_stmt, i); ++ ++ walk_use_def_ptr(visited, arg); ++ } ++ } ++ case GIMPLE_ASSIGN: ++ switch (gimple_num_ops(def_stmt)) { ++ case 2: ++ walk_use_def_ptr(visited, gimple_assign_rhs1(def_stmt)); ++ return; ++ case 3: ++ if (skip_ptr_minus(def_stmt)) ++ return; ++ ++ walk_use_def_ptr(visited, gimple_assign_rhs1(def_stmt)); ++ walk_use_def_ptr(visited, gimple_assign_rhs2(def_stmt)); ++ return; ++ default: ++ return; ++ } ++ default: ++ debug_gimple_stmt((gimple)def_stmt); ++ error("%s: unknown gimple code", __func__); ++ gcc_unreachable(); ++ } ++} ++ ++// Look for a ptr - ptr expression (e.g., cpuset_common_file_read() s - page) ++static void insert_mark_not_intentional_asm_at_ptr(const_tree arg) ++{ ++ struct pointer_set_t *visited; ++ ++ visited = pointer_set_create(); ++ walk_use_def_ptr(visited, arg); ++ pointer_set_destroy(visited); ++} ++ +// Determine the return value and insert the asm stmt to mark the return stmt. +static void insert_asm_ret(gimple stmt) +{ @@ -116556,6 +116691,10 @@ index 0000000..5515dcb + + arg = gimple_call_arg(stmt, argnum - 1); + gcc_assert(arg != NULL_TREE); ++ ++ // skip all ptr - ptr expressions ++ insert_mark_not_intentional_asm_at_ptr(arg); ++ + create_size_overflow_asm(stmt, arg, argnum); +} + @@ -116615,35 +116754,17 @@ index 0000000..5515dcb + +/* + * Look up the intentional_overflow attribute that turns off ipa based duplication -+ * on the callee function, if found insert an asm stmt with "MARK_TURN_OFF". ++ * on the callee function. + */ -+static bool create_mark_turn_off_asm(gimple stmt) ++static bool is_mark_turn_off_attribute(gimple stmt) +{ + enum mark mark; -+ struct asm_data asm_data; + const_tree fndecl = gimple_call_fndecl(stmt); + + mark = get_intentional_attr_type(DECL_ORIGIN(fndecl)); -+ if (mark != MARK_TURN_OFF) -+ return false; -+ -+ asm_data.def_stmt = stmt; -+ asm_data.output = gimple_call_lhs(stmt); -+ -+ if (asm_data.output == NULL_TREE) { -+ asm_data.input = gimple_call_arg(stmt, 0); -+ if (is_gimple_constant(asm_data.input)) -+ return false; -+ asm_data.output = NULL; -+ create_asm_stmt(TURN_OFF_ASM_STR, build_string(2, "rm"), NULL, &asm_data); ++ if (mark == MARK_TURN_OFF) + return true; -+ } -+ -+ create_asm_input(stmt, 0, &asm_data); -+ gcc_assert(asm_data.input != NULL_TREE); -+ -+ create_asm_stmt(TURN_OFF_ASM_STR, build_string(1, "0"), build_string(3, "=rm"), &asm_data); -+ return true; ++ return false; +} + +// If the argument(s) of the callee function is/are in the hash table or are marked by an attribute then mark the call stmt with an asm stmt @@ -116660,8 +116781,10 @@ index 0000000..5515dcb + return; + fndecl = DECL_ORIGIN(fndecl); + -+ if (create_mark_turn_off_asm(stmt)) ++ if (is_mark_turn_off_attribute(stmt)) { ++ create_mark_asm(stmt, MARK_TURN_OFF); + return; ++ } + + search_interesting_args(fndecl, orig_argnums); + @@ -117531,7 +117654,7 @@ index 547628e..74de9f2 100644 + #endif diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c -index d83aa5e..e097f17 100644 +index d83aa5e..76e9c92 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -75,12 +75,17 @@ LIST_HEAD(vm_list); @@ -117563,7 +117686,27 @@ index d83aa5e..e097f17 100644 (void __user *)(unsigned long)mem->userspace_addr, mem->memory_size))) goto out; -@@ -1660,7 +1665,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp) +@@ -1493,8 +1498,17 @@ EXPORT_SYMBOL_GPL(kvm_read_guest_cached); + + int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len) + { +- return kvm_write_guest_page(kvm, gfn, (const void *) empty_zero_page, +- offset, len); ++ int r; ++ unsigned long addr; ++ ++ addr = gfn_to_hva(kvm, gfn); ++ if (kvm_is_error_hva(addr)) ++ return -EFAULT; ++ r = __clear_user((void __user *)addr + offset, len); ++ if (r) ++ return -EFAULT; ++ mark_page_dirty(kvm, gfn); ++ return 0; + } + EXPORT_SYMBOL_GPL(kvm_clear_guest_page); + +@@ -1660,7 +1674,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp) return 0; } @@ -117572,7 +117715,7 @@ index d83aa5e..e097f17 100644 .release = kvm_vcpu_release, .unlocked_ioctl = kvm_vcpu_ioctl, #ifdef CONFIG_COMPAT -@@ -2183,7 +2188,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma) +@@ -2183,7 +2197,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma) return 0; } @@ -117581,7 +117724,7 @@ index d83aa5e..e097f17 100644 .release = kvm_vm_release, .unlocked_ioctl = kvm_vm_ioctl, #ifdef CONFIG_COMPAT -@@ -2281,7 +2286,7 @@ out: +@@ -2281,7 +2295,7 @@ out: return r; } @@ -117590,7 +117733,7 @@ index d83aa5e..e097f17 100644 .unlocked_ioctl = kvm_dev_ioctl, .compat_ioctl = kvm_dev_ioctl, .llseek = noop_llseek, -@@ -2307,7 +2312,7 @@ static void hardware_enable_nolock(void *junk) +@@ -2307,7 +2321,7 @@ static void hardware_enable_nolock(void *junk) if (r) { cpumask_clear_cpu(cpu, cpus_hardware_enabled); @@ -117599,7 +117742,7 @@ index d83aa5e..e097f17 100644 printk(KERN_INFO "kvm: enabling virtualization on " "CPU%d failed\n", cpu); } -@@ -2361,10 +2366,10 @@ static int hardware_enable_all(void) +@@ -2361,10 +2375,10 @@ static int hardware_enable_all(void) kvm_usage_count++; if (kvm_usage_count == 1) { @@ -117612,7 +117755,7 @@ index d83aa5e..e097f17 100644 hardware_disable_all_nolock(); r = -EBUSY; } -@@ -2715,7 +2720,7 @@ static void kvm_sched_out(struct preempt_notifier *pn, +@@ -2715,7 +2729,7 @@ static void kvm_sched_out(struct preempt_notifier *pn, kvm_arch_vcpu_put(vcpu); } @@ -117621,7 +117764,7 @@ index d83aa5e..e097f17 100644 struct module *module) { int r; -@@ -2778,7 +2783,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, +@@ -2778,7 +2792,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, if (!vcpu_align) vcpu_align = __alignof__(struct kvm_vcpu); kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align, @@ -117630,7 +117773,7 @@ index d83aa5e..e097f17 100644 if (!kvm_vcpu_cache) { r = -ENOMEM; goto out_free_3; -@@ -2788,9 +2793,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, +@@ -2788,9 +2802,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, if (r) goto out_free; @@ -117642,7 +117785,7 @@ index d83aa5e..e097f17 100644 r = misc_register(&kvm_dev); if (r) { -@@ -2800,9 +2807,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, +@@ -2800,9 +2816,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, register_syscore_ops(&kvm_syscore_ops); |