From: Greg Kroah-Hartman Date: Fri, 15 Dec 2017 07:54:09 +0000 (+0100) Subject: 4.9-stable patches X-Git-Tag: v3.18.88~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c75c5a070c6d37298a17b22c0b42e4299295b74c;p=thirdparty%2Fkernel%2Fstable-queue.git 4.9-stable patches added patches: audit-ensure-that-audit-1-actually-enables-audit-for-pid-1.patch ipvlan-fix-ipv6-outbound-device.patch kbuild-do-not-call-cc-option-before-kbuild_cflags-initialization.patch md-free-unused-memory-after-bitmap-resize.patch powerpc-64-fix-checksum-folding-in-csum_tcpudp_nofold-and-ip_fast_csum_nofold.patch rdma-cxgb4-annotate-r2-and-stag-as-__be32.patch --- diff --git a/queue-4.9/audit-ensure-that-audit-1-actually-enables-audit-for-pid-1.patch b/queue-4.9/audit-ensure-that-audit-1-actually-enables-audit-for-pid-1.patch new file mode 100644 index 00000000000..403405429ac --- /dev/null +++ b/queue-4.9/audit-ensure-that-audit-1-actually-enables-audit-for-pid-1.patch @@ -0,0 +1,64 @@ +From foo@baz Tue Dec 12 13:26:17 CET 2017 +From: Paul Moore +Date: Fri, 1 Sep 2017 09:44:34 -0400 +Subject: audit: ensure that 'audit=1' actually enables audit for PID 1 + +From: Paul Moore + + +[ Upstream commit 173743dd99a49c956b124a74c8aacb0384739a4c ] + +Prior to this patch we enabled audit in audit_init(), which is too +late for PID 1 as the standard initcalls are run after the PID 1 task +is forked. This means that we never allocate an audit_context (see +audit_alloc()) for PID 1 and therefore miss a lot of audit events +generated by PID 1. + +This patch enables audit as early as possible to help ensure that when +PID 1 is forked it can allocate an audit_context if required. + +Reviewed-by: Richard Guy Briggs +Signed-off-by: Paul Moore +Signed-off-by: Sasha Levin +Signed-off-by: Greg Kroah-Hartman +--- + kernel/audit.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +--- a/kernel/audit.c ++++ b/kernel/audit.c +@@ -79,13 +79,13 @@ static int audit_initialized; + #define AUDIT_OFF 0 + #define AUDIT_ON 1 + #define AUDIT_LOCKED 2 +-u32 audit_enabled; +-u32 audit_ever_enabled; ++u32 audit_enabled = AUDIT_OFF; ++u32 audit_ever_enabled = !!AUDIT_OFF; + + EXPORT_SYMBOL_GPL(audit_enabled); + + /* Default state when kernel boots without any parameters. */ +-static u32 audit_default; ++static u32 audit_default = AUDIT_OFF; + + /* If auditing cannot proceed, audit_failure selects what happens. */ + static u32 audit_failure = AUDIT_FAIL_PRINTK; +@@ -1199,8 +1199,6 @@ static int __init audit_init(void) + skb_queue_head_init(&audit_skb_queue); + skb_queue_head_init(&audit_skb_hold_queue); + audit_initialized = AUDIT_INITIALIZED; +- audit_enabled = audit_default; +- audit_ever_enabled |= !!audit_default; + + audit_log(NULL, GFP_KERNEL, AUDIT_KERNEL, "initialized"); + +@@ -1217,6 +1215,8 @@ static int __init audit_enable(char *str + audit_default = !!simple_strtol(str, NULL, 0); + if (!audit_default) + audit_initialized = AUDIT_DISABLED; ++ audit_enabled = audit_default; ++ audit_ever_enabled = !!audit_enabled; + + pr_info("%s\n", audit_default ? + "enabled (after initialization)" : "disabled (until reboot)"); diff --git a/queue-4.9/ipvlan-fix-ipv6-outbound-device.patch b/queue-4.9/ipvlan-fix-ipv6-outbound-device.patch new file mode 100644 index 00000000000..d2dd9a2d243 --- /dev/null +++ b/queue-4.9/ipvlan-fix-ipv6-outbound-device.patch @@ -0,0 +1,33 @@ +From foo@baz Tue Dec 12 13:26:17 CET 2017 +From: Keefe Liu +Date: Thu, 9 Nov 2017 20:09:31 +0800 +Subject: ipvlan: fix ipv6 outbound device + +From: Keefe Liu + + +[ Upstream commit ca29fd7cce5a6444d57fb86517589a1a31c759e1 ] + +When process the outbound packet of ipv6, we should assign the master +device to output device other than input device. + +Signed-off-by: Keefe Liu +Acked-by: Mahesh Bandewar +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/ipvlan/ipvlan_core.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/ipvlan/ipvlan_core.c ++++ b/drivers/net/ipvlan/ipvlan_core.c +@@ -404,7 +404,7 @@ static int ipvlan_process_v6_outbound(st + struct dst_entry *dst; + int err, ret = NET_XMIT_DROP; + struct flowi6 fl6 = { +- .flowi6_iif = dev->ifindex, ++ .flowi6_oif = dev->ifindex, + .daddr = ip6h->daddr, + .saddr = ip6h->saddr, + .flowi6_flags = FLOWI_FLAG_ANYSRC, diff --git a/queue-4.9/kbuild-do-not-call-cc-option-before-kbuild_cflags-initialization.patch b/queue-4.9/kbuild-do-not-call-cc-option-before-kbuild_cflags-initialization.patch new file mode 100644 index 00000000000..b1dffdfe102 --- /dev/null +++ b/queue-4.9/kbuild-do-not-call-cc-option-before-kbuild_cflags-initialization.patch @@ -0,0 +1,101 @@ +From foo@baz Tue Dec 12 13:26:17 CET 2017 +From: Masahiro Yamada +Date: Thu, 12 Oct 2017 18:22:25 +0900 +Subject: kbuild: do not call cc-option before KBUILD_CFLAGS initialization + +From: Masahiro Yamada + + +[ Upstream commit 433dc2ebe7d17dd21cba7ad5c362d37323592236 ] + +Some $(call cc-option,...) are invoked very early, even before +KBUILD_CFLAGS, etc. are initialized. + +The returned string from $(call cc-option,...) depends on +KBUILD_CPPFLAGS, KBUILD_CFLAGS, and GCC_PLUGINS_CFLAGS. + +Since they are exported, they are not empty when the top Makefile +is recursively invoked. + +The recursion occurs in several places. For example, the top +Makefile invokes itself for silentoldconfig. "make tinyconfig", +"make rpm-pkg" are the cases, too. + +In those cases, the second call of cc-option from the same line +runs a different shell command due to non-pristine KBUILD_CFLAGS. + +To get the same result all the time, KBUILD_* and GCC_PLUGINS_CFLAGS +must be initialized before any call of cc-option. This avoids +garbage data in the .cache.mk file. + +Move all calls of cc-option below the config targets because target +compiler flags are unnecessary for Kconfig. + +Signed-off-by: Masahiro Yamada +Reviewed-by: Douglas Anderson +Signed-off-by: Sasha Levin +Signed-off-by: Greg Kroah-Hartman +--- + Makefile | 21 +++++++++++---------- + 1 file changed, 11 insertions(+), 10 deletions(-) + +--- a/Makefile ++++ b/Makefile +@@ -370,9 +370,6 @@ LDFLAGS_MODULE = + CFLAGS_KERNEL = + AFLAGS_KERNEL = + LDFLAGS_vmlinux = +-CFLAGS_GCOV := -fprofile-arcs -ftest-coverage -fno-tree-loop-im $(call cc-disable-warning,maybe-uninitialized,) +-CFLAGS_KCOV := $(call cc-option,-fsanitize-coverage=trace-pc,) +- + + # Use USERINCLUDE when you must reference the UAPI directories only. + USERINCLUDE := \ +@@ -393,21 +390,19 @@ LINUXINCLUDE := \ + + LINUXINCLUDE += $(filter-out $(LINUXINCLUDE),$(USERINCLUDE)) + +-KBUILD_CPPFLAGS := -D__KERNEL__ +- ++KBUILD_AFLAGS := -D__ASSEMBLY__ + KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ + -fno-strict-aliasing -fno-common \ + -Werror-implicit-function-declaration \ + -Wno-format-security \ +- -std=gnu89 $(call cc-option,-fno-PIE) +- +- ++ -std=gnu89 ++KBUILD_CPPFLAGS := -D__KERNEL__ + KBUILD_AFLAGS_KERNEL := + KBUILD_CFLAGS_KERNEL := +-KBUILD_AFLAGS := -D__ASSEMBLY__ $(call cc-option,-fno-PIE) + KBUILD_AFLAGS_MODULE := -DMODULE + KBUILD_CFLAGS_MODULE := -DMODULE + KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds ++GCC_PLUGINS_CFLAGS := + + # Read KERNELRELEASE from include/config/kernel.release (if it exists) + KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) +@@ -420,7 +415,7 @@ export MAKE AWK GENKSYMS INSTALLKERNEL P + export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS + + export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS +-export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV CFLAGS_KCOV CFLAGS_KASAN CFLAGS_UBSAN ++export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_KASAN CFLAGS_UBSAN + export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE + export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE + export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL +@@ -620,6 +615,12 @@ endif + # Defaults to vmlinux, but the arch makefile usually adds further targets + all: vmlinux + ++KBUILD_CFLAGS += $(call cc-option,-fno-PIE) ++KBUILD_AFLAGS += $(call cc-option,-fno-PIE) ++CFLAGS_GCOV := -fprofile-arcs -ftest-coverage -fno-tree-loop-im $(call cc-disable-warning,maybe-uninitialized,) ++CFLAGS_KCOV := $(call cc-option,-fsanitize-coverage=trace-pc,) ++export CFLAGS_GCOV CFLAGS_KCOV ++ + # The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default + # values of the respective KBUILD_* variables + ARCH_CPPFLAGS := diff --git a/queue-4.9/md-free-unused-memory-after-bitmap-resize.patch b/queue-4.9/md-free-unused-memory-after-bitmap-resize.patch new file mode 100644 index 00000000000..10a2847a610 --- /dev/null +++ b/queue-4.9/md-free-unused-memory-after-bitmap-resize.patch @@ -0,0 +1,71 @@ +From foo@baz Tue Dec 12 13:26:17 CET 2017 +From: Zdenek Kabelac +Date: Wed, 8 Nov 2017 13:44:56 +0100 +Subject: md: free unused memory after bitmap resize + +From: Zdenek Kabelac + + +[ Upstream commit 0868b99c214a3d55486c700de7c3f770b7243e7c ] + +When bitmap is resized, the old kalloced chunks just are not released +once the resized bitmap starts to use new space. + +This fixes in particular kmemleak reports like this one: + +unreferenced object 0xffff8f4311e9c000 (size 4096): + comm "lvm", pid 19333, jiffies 4295263268 (age 528.265s) + hex dump (first 32 bytes): + 02 80 02 80 02 80 02 80 02 80 02 80 02 80 02 80 ................ + 02 80 02 80 02 80 02 80 02 80 02 80 02 80 02 80 ................ + backtrace: + [] kmemleak_alloc+0x4a/0xa0 + [] kmem_cache_alloc_trace+0x14e/0x2e0 + [] bitmap_checkpage+0x7c/0x110 + [] bitmap_get_counter+0x45/0xd0 + [] bitmap_set_memory_bits+0x43/0xe0 + [] bitmap_init_from_disk+0x23c/0x530 + [] bitmap_load+0xbe/0x160 + [] raid_preresume+0x203/0x2f0 [dm_raid] + [] dm_table_resume_targets+0x4f/0xe0 + [] dm_resume+0x122/0x140 + [] dev_suspend+0x18f/0x290 + [] ctl_ioctl+0x287/0x560 + [] dm_ctl_ioctl+0x13/0x20 + [] do_vfs_ioctl+0xa6/0x750 + [] SyS_ioctl+0x79/0x90 + [] entry_SYSCALL_64_fastpath+0x1f/0xc2 + +Signed-off-by: Zdenek Kabelac +Signed-off-by: Shaohua Li +Signed-off-by: Sasha Levin +Signed-off-by: Greg Kroah-Hartman +--- + drivers/md/bitmap.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +--- a/drivers/md/bitmap.c ++++ b/drivers/md/bitmap.c +@@ -2084,6 +2084,7 @@ int bitmap_resize(struct bitmap *bitmap, + for (k = 0; k < page; k++) { + kfree(new_bp[k].map); + } ++ kfree(new_bp); + + /* restore some fields from old_counts */ + bitmap->counts.bp = old_counts.bp; +@@ -2134,6 +2135,14 @@ int bitmap_resize(struct bitmap *bitmap, + block += old_blocks; + } + ++ if (bitmap->counts.bp != old_counts.bp) { ++ unsigned long k; ++ for (k = 0; k < old_counts.pages; k++) ++ if (!old_counts.bp[k].hijacked) ++ kfree(old_counts.bp[k].map); ++ kfree(old_counts.bp); ++ } ++ + if (!init) { + int i; + while (block < (chunks << chunkshift)) { diff --git a/queue-4.9/powerpc-64-fix-checksum-folding-in-csum_tcpudp_nofold-and-ip_fast_csum_nofold.patch b/queue-4.9/powerpc-64-fix-checksum-folding-in-csum_tcpudp_nofold-and-ip_fast_csum_nofold.patch new file mode 100644 index 00000000000..33e9fdbcab2 --- /dev/null +++ b/queue-4.9/powerpc-64-fix-checksum-folding-in-csum_tcpudp_nofold-and-ip_fast_csum_nofold.patch @@ -0,0 +1,68 @@ +From b492f7e4e07a28e706db26cf4943bb0911435426 Mon Sep 17 00:00:00 2001 +From: Paul Mackerras +Date: Thu, 3 Nov 2016 16:10:55 +1100 +Subject: powerpc/64: Fix checksum folding in csum_tcpudp_nofold and ip_fast_csum_nofold + +From: Paul Mackerras + +commit b492f7e4e07a28e706db26cf4943bb0911435426 upstream. + +These functions compute an IP checksum by computing a 64-bit sum and +folding it to 32 bits (the "nofold" in their names refers to folding +down to 16 bits). However, doing (u32) (s + (s >> 32)) is not +sufficient to fold a 64-bit sum to 32 bits correctly. The addition +can produce a carry out from bit 31, which needs to be added in to +the sum to produce the correct result. + +To fix this, we copy the from64to32() function from lib/checksum.c +and use that. + +Signed-off-by: Paul Mackerras +Signed-off-by: Michael Ellerman +Signed-off-by: Greg Kroah-Hartman + +--- + arch/powerpc/include/asm/checksum.h | 17 ++++++++++++----- + 1 file changed, 12 insertions(+), 5 deletions(-) + +--- a/arch/powerpc/include/asm/checksum.h ++++ b/arch/powerpc/include/asm/checksum.h +@@ -53,17 +53,25 @@ static inline __sum16 csum_fold(__wsum s + return (__force __sum16)(~((__force u32)sum + tmp) >> 16); + } + ++static inline u32 from64to32(u64 x) ++{ ++ /* add up 32-bit and 32-bit for 32+c bit */ ++ x = (x & 0xffffffff) + (x >> 32); ++ /* add up carry.. */ ++ x = (x & 0xffffffff) + (x >> 32); ++ return (u32)x; ++} ++ + static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, __u32 len, + __u8 proto, __wsum sum) + { + #ifdef __powerpc64__ +- unsigned long s = (__force u32)sum; ++ u64 s = (__force u32)sum; + + s += (__force u32)saddr; + s += (__force u32)daddr; + s += proto + len; +- s += (s >> 32); +- return (__force __wsum) s; ++ return (__force __wsum) from64to32(s); + #else + __asm__("\n\ + addc %0,%0,%1 \n\ +@@ -123,8 +131,7 @@ static inline __wsum ip_fast_csum_nofold + + for (i = 0; i < ihl - 1; i++, ptr++) + s += *ptr; +- s += (s >> 32); +- return (__force __wsum)s; ++ return (__force __wsum)from64to32(s); + #else + __wsum sum, tmp; + diff --git a/queue-4.9/rdma-cxgb4-annotate-r2-and-stag-as-__be32.patch b/queue-4.9/rdma-cxgb4-annotate-r2-and-stag-as-__be32.patch new file mode 100644 index 00000000000..613785f422e --- /dev/null +++ b/queue-4.9/rdma-cxgb4-annotate-r2-and-stag-as-__be32.patch @@ -0,0 +1,46 @@ +From foo@baz Tue Dec 12 13:26:17 CET 2017 +From: Leon Romanovsky +Date: Wed, 25 Oct 2017 23:10:19 +0300 +Subject: RDMA/cxgb4: Annotate r2 and stag as __be32 + +From: Leon Romanovsky + + +[ Upstream commit 7d7d065a5eec7e218174d5c64a9f53f99ffdb119 ] + +Chelsio cxgb4 HW is big-endian, hence there is need to properly +annotate r2 and stag fields as __be32 and not __u32 to fix the +following sparse warnings. + + drivers/infiniband/hw/cxgb4/qp.c:614:16: + warning: incorrect type in assignment (different base types) + expected unsigned int [unsigned] [usertype] r2 + got restricted __be32 [usertype] + drivers/infiniband/hw/cxgb4/qp.c:615:18: + warning: incorrect type in assignment (different base types) + expected unsigned int [unsigned] [usertype] stag + got restricted __be32 [usertype] + +Cc: Steve Wise +Signed-off-by: Leon Romanovsky +Reviewed-by: Steve Wise +Signed-off-by: Doug Ledford +Signed-off-by: Sasha Levin +Signed-off-by: Greg Kroah-Hartman +--- + drivers/infiniband/hw/cxgb4/t4fw_ri_api.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/infiniband/hw/cxgb4/t4fw_ri_api.h ++++ b/drivers/infiniband/hw/cxgb4/t4fw_ri_api.h +@@ -675,8 +675,8 @@ struct fw_ri_fr_nsmr_tpte_wr { + __u16 wrid; + __u8 r1[3]; + __u8 len16; +- __u32 r2; +- __u32 stag; ++ __be32 r2; ++ __be32 stag; + struct fw_ri_tpte tpte; + __u64 pbl[2]; + }; diff --git a/queue-4.9/series b/queue-4.9/series index 8e6aff427c6..831afa35654 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -19,3 +19,9 @@ s390-always-save-and-restore-all-registers-on-context-switch.patch usb-gadget-ffs-forbid-usb_ep_alloc_request-from-sleeping.patch fix-kcm_clone.patch kvm-arm-arm64-vgic-its-preserve-the-revious-read-from-the-pending-table.patch +powerpc-64-fix-checksum-folding-in-csum_tcpudp_nofold-and-ip_fast_csum_nofold.patch +kbuild-do-not-call-cc-option-before-kbuild_cflags-initialization.patch +ipvlan-fix-ipv6-outbound-device.patch +audit-ensure-that-audit-1-actually-enables-audit-for-pid-1.patch +md-free-unused-memory-after-bitmap-resize.patch +rdma-cxgb4-annotate-r2-and-stag-as-__be32.patch