linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4.4 00/70] 4.4.165-stable review
@ 2018-11-26 10:50 Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 01/70] flow_dissector: do not dissect l4 ports for fragments Greg Kroah-Hartman
                   ` (75 more replies)
  0 siblings, 76 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, torvalds, akpm, linux, shuah, patches,
	ben.hutchings, lkft-triage, stable

This is the start of the stable review cycle for the 4.4.165 release.
There are 70 patches in this series, all will be posted as a response
to this one.  If anyone has any issues with these being applied, please
let me know.

Responses should be made by Wed Nov 28 10:50:16 UTC 2018.
Anything received after that time might be too late.

The whole patch series can be found in one patch at:
	https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.4.165-rc1.gz
or in the git tree and branch at:
	git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.4.y
and the diffstat can be found below.

thanks,

greg k-h

-------------
Pseudo-Shortlog of commits:

Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Linux 4.4.165-rc1

Eric Biggers <ebiggers@google.com>
    HID: uhid: forbid UHID_CREATE under KERNEL_DS or elevated privileges

Al Viro <viro@zeniv.linux.org.uk>
    new helper: uaccess_kernel()

Hans de Goede <hdegoede@redhat.com>
    ACPI / platform: Add SMB0001 HID to forbidden_id_list

Gustavo A. R. Silva <gustavo@embeddedor.com>
    drivers/misc/sgi-gru: fix Spectre v1 vulnerability

Mattias Jacobsson <2pi@mok.nu>
    USB: misc: appledisplay: add 20" Apple Cinema Display

Nathan Chancellor <natechancellor@gmail.com>
    misc: atmel-ssc: Fix section annotation on atmel_ssc_get_driver_data

Emmanuel Pescosta <emmanuelpescosta099@gmail.com>
    usb: quirks: Add delay-init quirk for Corsair K70 LUX RGB

Kai-Heng Feng <kai.heng.feng@canonical.com>
    USB: quirks: Add no-lpm quirk for Raydium touchscreens

Maarten Jacobs <maarten256@outlook.com>
    usb: cdc-acm: add entry for Hiro (Conexant) modem

Dan Carpenter <dan.carpenter@oracle.com>
    uio: Fix an Oops on load

Sakari Ailus <sakari.ailus@linux.intel.com>
    media: v4l: event: Add subscription to list before calling "add" operation

Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Revert "Bluetooth: h5: Fix missing dependency on BT_HCIUART_SERDEV"

Hans Verkuil <hverkuil@xs4all.nl>
    Revert "media: videobuf2-core: don't call memop 'finish' when queueing"

Lu Fengqi <lufq.fnst@cn.fujitsu.com>
    btrfs: fix pinned underflow after transaction aborted

Andreas Gruenbacher <agruenba@redhat.com>
    gfs2: Put bitmap buffers in put_super

YueHaibing <yuehaibing@huawei.com>
    SUNRPC: drop pointless static qualifier in xdr_get_next_encode_buffer()

Minchan Kim <minchan@kernel.org>
    zram: close udev startup race condition as default groups

Vignesh R <vigneshr@ti.com>
    i2c: omap: Enable for ARCH_K3

Jeremy Linton <jeremy.linton@arm.com>
    lib/raid6: Fix arm64 test build

Geert Uytterhoeven <geert@linux-m68k.org>
    hwmon: (ibmpowernv) Remove bogus __init annotations

Taehee Yoo <ap420073@gmail.com>
    netfilter: xt_IDLETIMER: add sysfs filename checking routine

Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
    netfilter: ipset: Correct rcu_dereference() call in ip_set_put_comment()

Justin M. Forbes <jforbes@fedoraproject.org>
    s390/mm: Fix ERROR: "__node_distance" undefined!

Eric Westbrook <eric@westbrook.io>
    netfilter: ipset: actually allow allowable CIDR 0 in hash:net,port,net

Vasily Gorbik <gor@linux.ibm.com>
    s390/vdso: add missing FORCE to build targets

Nathan Chancellor <natechancellor@gmail.com>
    arm64: percpu: Initialize ret in the default case

Paul Gortmaker <paul.gortmaker@windriver.com>
    platform/x86: acerhdf: Add BIOS entry for Gateway LT31 v1.3307

Marek Szyprowski <m.szyprowski@samsung.com>
    clk: samsung: exynos5420: Enable PERIS clocks for suspend

Chengguang Xu <cgxu519@gmx.com>
    fs/exofs: fix potential memory leak in mount option parsing

Richard Weinberger <richard@nod.at>
    um: Give start_idle_thread() a return code

Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
    hfsplus: prevent btree data loss on root split

Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
    hfs: prevent btree data loss on root split

Jann Horn <jannh@google.com>
    reiserfs: propagate errors from fill_with_dentries() properly

Matthias Kaehlcke <mka@chromium.org>
    x86/build: Use cc-option to validate stack alignment parameter

Matthias Kaehlcke <mka@chromium.org>
    x86/build: Fix stack alignment for CLang

Michael Davidson <md@google.com>
    x86/boot: #undef memcpy() et al in string.c

Matthias Kaehlcke <mka@chromium.org>
    x86/build: Specify stack alignment for clang

Matthias Kaehlcke <mka@chromium.org>
    x86/build: Use __cc-option for boot code compiler options

Matthias Kaehlcke <mka@chromium.org>
    kbuild: Add __cc-option macro

Matthias Kaehlcke <mka@chromium.org>
    x86/mm/kaslr: Use the _ASM_MUL macro for multiplication to work around Clang incompatibility

Michael Davidson <md@google.com>
    crypto, x86: aesni - fix token pasting for clang

Matthias Kaehlcke <mka@chromium.org>
    x86/kbuild: Use cc-option to enable -falign-{jumps/loops}

Matthias Kaehlcke <mka@chromium.org>
    arm64: Disable asm-operand-width warning for clang

Stefan Agner <stefan@agner.ch>
    kbuild: allow to use GCC toolchain not in Clang search path

Stefan Agner <stefan@agner.ch>
    kbuild: set no-integrated-as before incl. arch Makefile

Sodagudi Prasad <psodagud@codeaurora.org>
    kbuild: clang: disable unused variable warnings only when constant

Nick Desaulniers <nick.desaulniers@gmail.com>
    kbuild: clang: remove crufty HOSTCFLAGS

David Lin <dtwlin@google.com>
    kbuild: clang: fix build failures with sparse check

Masahiro Yamada <yamada.masahiro@socionext.com>
    kbuild: move cc-option and cc-disable-warning after incl. arch Makefile

Chris Fries <cfries@google.com>
    kbuild: Set KBUILD_CFLAGS before incl. arch Makefile

Nick Desaulniers <ndesaulniers@google.com>
    kbuild: fix linker feature test macros when cross compiling with Clang

Ard Biesheuvel <ard.biesheuvel@linaro.org>
    efi/libstub/arm64: Set -fpie when building the EFI stub

Ard Biesheuvel <ard.biesheuvel@linaro.org>
    efi/libstub/arm64: Force 'hidden' visibility for section markers

Ard Biesheuvel <ard.biesheuvel@linaro.org>
    crypto: arm64/sha - avoid non-standard inline asm tricks

Matthias Kaehlcke <mka@chromium.org>
    kbuild: clang: Disable 'address-of-packed-member' warning

Arnd Bergmann <arnd@arndb.de>
    modules: mark __inittest/__exittest as __maybe_unused

Vinícius Tinti <viniciustinti@gmail.com>
    kbuild: Add support to generate LLVM assembly files

Behan Webster <behanw@converseincode.com>
    kbuild: use -Oz instead of -Os when using clang

Mark Charlebois <charlebm@gmail.com>
    kbuild, LLVMLinux: Add -Werror to cc-option to support clang

Masahiro Yamada <yamada.masahiro@socionext.com>
    kbuild: drop -Wno-unknown-warning-option from clang options

Jeroen Hofstee <jeroen@myspectrum.nl>
    kbuild: fix asm-offset generation to work with clang

Masahiro Yamada <yamada.masahiro@socionext.com>
    kbuild: consolidate redundant sed script ASM offset generation

Matthias Kaehlcke <mka@chromium.org>
    kbuild: Consolidate header generation from ASM offset information

Michael Davidson <md@google.com>
    kbuild: clang: add -no-integrated-as to KBUILD_[AC]FLAGS

Behan Webster <behanw@converseincode.com>
    kbuild: Add better clang cross build support

David Ahern <dsahern@gmail.com>
    ipv6: Fix PMTU updates for UDP/raw sockets in presence of VRF

Siva Reddy Kallam <siva.kallam@broadcom.com>
    tg3: Add PHY reset for 5717/5719/5720 in change ring and flow control paths

Eric Dumazet <edumazet@google.com>
    net-gro: reset skb->pkt_type in napi_reuse_skb()

Sabrina Dubroca <sd@queasysnail.net>
    ip_tunnel: don't force DF when MTU is locked

배석진 <soukjin.bae@samsung.com>
    flow_dissector: do not dissect l4 ports for fragments


-------------

Diffstat:

 .gitignore                                     |  1 +
 Kbuild                                         | 25 ---------------
 Makefile                                       | 41 ++++++++++++++++--------
 arch/arm64/Makefile                            |  4 +++
 arch/arm64/crypto/sha1-ce-core.S               |  6 ++--
 arch/arm64/crypto/sha1-ce-glue.c               | 11 ++-----
 arch/arm64/crypto/sha2-ce-core.S               |  6 ++--
 arch/arm64/crypto/sha2-ce-glue.c               | 13 +++-----
 arch/arm64/include/asm/percpu.h                |  3 ++
 arch/ia64/kernel/Makefile                      | 26 ++--------------
 arch/s390/kernel/vdso32/Makefile               |  6 ++--
 arch/s390/kernel/vdso64/Makefile               |  6 ++--
 arch/s390/numa/numa.c                          |  1 +
 arch/um/os-Linux/skas/process.c                |  5 +++
 arch/x86/Makefile                              | 39 +++++++++++++++++------
 arch/x86/boot/compressed/aslr.c                |  3 +-
 arch/x86/boot/string.c                         |  9 ++++++
 arch/x86/crypto/aes_ctrby8_avx-x86_64.S        |  7 ++---
 arch/x86/include/asm/asm.h                     |  1 +
 drivers/acpi/acpi_platform.c                   |  1 +
 drivers/block/zram/zram_drv.c                  | 26 ++++------------
 drivers/bluetooth/Kconfig                      |  1 -
 drivers/clk/samsung/clk-exynos5420.c           |  1 +
 drivers/firmware/efi/libstub/Makefile          |  2 +-
 drivers/firmware/efi/libstub/arm64-stub.c      | 10 +++++-
 drivers/hid/uhid.c                             | 13 ++++++++
 drivers/hwmon/ibmpowernv.c                     |  7 ++---
 drivers/i2c/busses/Kconfig                     |  2 +-
 drivers/media/v4l2-core/v4l2-event.c           | 43 ++++++++++++++------------
 drivers/media/v4l2-core/videobuf2-core.c       |  9 ++----
 drivers/misc/atmel-ssc.c                       |  2 +-
 drivers/misc/sgi-gru/grukdump.c                |  4 +++
 drivers/net/ethernet/broadcom/tg3.c            | 18 +++++++++--
 drivers/platform/x86/acerhdf.c                 |  1 +
 drivers/uio/uio.c                              |  7 +++--
 drivers/usb/class/cdc-acm.c                    |  3 ++
 drivers/usb/core/quirks.c                      |  8 +++++
 drivers/usb/misc/appledisplay.c                |  1 +
 fs/btrfs/disk-io.c                             | 19 +++++++++---
 fs/exofs/super.c                               |  5 ++-
 fs/gfs2/rgrp.c                                 |  3 +-
 fs/hfs/brec.c                                  |  4 +++
 fs/hfsplus/brec.c                              |  4 +++
 fs/reiserfs/xattr.c                            |  7 +++++
 include/linux/kbuild.h                         |  6 ++--
 include/linux/module.h                         |  4 +--
 include/linux/netfilter/ipset/ip_set_comment.h |  4 +--
 include/linux/uaccess.h                        |  3 ++
 lib/raid6/test/Makefile                        |  4 +--
 net/core/dev.c                                 |  4 +++
 net/core/flow_dissector.c                      |  4 +--
 net/ipv4/ip_tunnel_core.c                      |  2 +-
 net/ipv6/route.c                               |  8 +++--
 net/netfilter/ipset/ip_set_hash_netportnet.c   |  8 ++---
 net/netfilter/xt_IDLETIMER.c                   | 20 ++++++++++++
 net/sunrpc/xdr.c                               |  2 +-
 scripts/Kbuild.include                         | 18 +++++++----
 scripts/Makefile.build                         |  8 +++++
 scripts/Makefile.extrawarn                     |  1 -
 scripts/Makefile.lib                           | 31 +++++++++++++++++++
 scripts/mod/Makefile                           | 28 ++---------------
 61 files changed, 349 insertions(+), 220 deletions(-)



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 01/70] flow_dissector: do not dissect l4 ports for fragments
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 02/70] ip_tunnel: dont force DF when MTU is locked Greg Kroah-Hartman
                   ` (74 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, 배석진,
	Eric Dumazet, David S. Miller

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: 배석진 <soukjin.bae@samsung.com>

[ Upstream commit 62230715fd2453b3ba948c9d83cfb3ada9169169 ]

Only first fragment has the sport/dport information,
not the following ones.

If we want consistent hash for all fragments, we need to
ignore ports even for first fragment.

This bug is visible for IPv6 traffic, if incoming fragments
do not have a flow label, since skb_get_hash() will give
different results for first fragment and following ones.

It is also visible if any routing rule wants dissection
and sport or dport.

See commit 5e5d6fed3741 ("ipv6: route: dissect flow
in input path if fib rules need it") for details.

[edumazet] rewrote the changelog completely.

Fixes: 06635a35d13d ("flow_dissect: use programable dissector in skb_flow_dissect and friends")
Signed-off-by: 배석진 <soukjin.bae@samsung.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/core/flow_dissector.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -480,8 +480,8 @@ ip_proto_again:
 		break;
 	}
 
-	if (dissector_uses_key(flow_dissector,
-			       FLOW_DISSECTOR_KEY_PORTS)) {
+	if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_PORTS) &&
+	    !(key_control->flags & FLOW_DIS_IS_FRAGMENT)) {
 		key_ports = skb_flow_dissector_target(flow_dissector,
 						      FLOW_DISSECTOR_KEY_PORTS,
 						      target_container);



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 02/70] ip_tunnel: dont force DF when MTU is locked
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 01/70] flow_dissector: do not dissect l4 ports for fragments Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 03/70] net-gro: reset skb->pkt_type in napi_reuse_skb() Greg Kroah-Hartman
                   ` (73 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Sabrina Dubroca, Stefano Brivio,
	David S. Miller

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Sabrina Dubroca <sd@queasysnail.net>

[ Upstream commit 16f7eb2b77b55da816c4e207f3f9440a8cafc00a ]

The various types of tunnels running over IPv4 can ask to set the DF
bit to do PMTU discovery. However, PMTU discovery is subject to the
threshold set by the net.ipv4.route.min_pmtu sysctl, and is also
disabled on routes with "mtu lock". In those cases, we shouldn't set
the DF bit.

This patch makes setting the DF bit conditional on the route's MTU
locking state.

This issue seems to be older than git history.

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/ipv4/ip_tunnel_core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/net/ipv4/ip_tunnel_core.c
+++ b/net/ipv4/ip_tunnel_core.c
@@ -71,7 +71,7 @@ int iptunnel_xmit(struct sock *sk, struc
 
 	iph->version	=	4;
 	iph->ihl	=	sizeof(struct iphdr) >> 2;
-	iph->frag_off	=	df;
+	iph->frag_off	=	ip_mtu_locked(&rt->dst) ? 0 : df;
 	iph->protocol	=	proto;
 	iph->tos	=	tos;
 	iph->daddr	=	dst;



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 03/70] net-gro: reset skb->pkt_type in napi_reuse_skb()
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 01/70] flow_dissector: do not dissect l4 ports for fragments Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 02/70] ip_tunnel: dont force DF when MTU is locked Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 04/70] tg3: Add PHY reset for 5717/5719/5720 in change ring and flow control paths Greg Kroah-Hartman
                   ` (72 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Eric Dumazet, David S. Miller

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Eric Dumazet <edumazet@google.com>

[ Upstream commit 33d9a2c72f086cbf1087b2fd2d1a15aa9df14a7f ]

eth_type_trans() assumes initial value for skb->pkt_type
is PACKET_HOST.

This is indeed the value right after a fresh skb allocation.

However, it is possible that GRO merged a packet with a different
value (like PACKET_OTHERHOST in case macvlan is used), so
we need to make sure napi->skb will have pkt_type set back to
PACKET_HOST.

Otherwise, valid packets might be dropped by the stack because
their pkt_type is not PACKET_HOST.

napi_reuse_skb() was added in commit 96e93eab2033 ("gro: Add
internal interfaces for VLAN"), but this bug always has
been there.

Fixes: 96e93eab2033 ("gro: Add internal interfaces for VLAN")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/core/dev.c |    4 ++++
 1 file changed, 4 insertions(+)

--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4481,6 +4481,10 @@ static void napi_reuse_skb(struct napi_s
 	skb->vlan_tci = 0;
 	skb->dev = napi->dev;
 	skb->skb_iif = 0;
+
+	/* eth_type_trans() assumes pkt_type is PACKET_HOST */
+	skb->pkt_type = PACKET_HOST;
+
 	skb->encapsulation = 0;
 	skb_shinfo(skb)->gso_type = 0;
 	skb->truesize = SKB_TRUESIZE(skb_end_offset(skb));



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 04/70] tg3: Add PHY reset for 5717/5719/5720 in change ring and flow control paths
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (2 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 03/70] net-gro: reset skb->pkt_type in napi_reuse_skb() Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 05/70] ipv6: Fix PMTU updates for UDP/raw sockets in presence of VRF Greg Kroah-Hartman
                   ` (71 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Siva Reddy Kallam, Michael Chan,
	David S. Miller

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Siva Reddy Kallam <siva.kallam@broadcom.com>

[ Upstream commit 59663e42199c93d1d7314d1446f6782fc4b1eb81 ]

This patch has the fix to avoid PHY lockup with 5717/5719/5720 in change
ring and flow control paths. This patch solves the RX hang while doing
continuous ring or flow control parameters with heavy traffic from peer.

Signed-off-by: Siva Reddy Kallam <siva.kallam@broadcom.com>
Acked-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/net/ethernet/broadcom/tg3.c |   18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -12379,6 +12379,7 @@ static int tg3_set_ringparam(struct net_
 {
 	struct tg3 *tp = netdev_priv(dev);
 	int i, irq_sync = 0, err = 0;
+	bool reset_phy = false;
 
 	if ((ering->rx_pending > tp->rx_std_ring_mask) ||
 	    (ering->rx_jumbo_pending > tp->rx_jmb_ring_mask) ||
@@ -12410,7 +12411,13 @@ static int tg3_set_ringparam(struct net_
 
 	if (netif_running(dev)) {
 		tg3_halt(tp, RESET_KIND_SHUTDOWN, 1);
-		err = tg3_restart_hw(tp, false);
+		/* Reset PHY to avoid PHY lock up */
+		if (tg3_asic_rev(tp) == ASIC_REV_5717 ||
+		    tg3_asic_rev(tp) == ASIC_REV_5719 ||
+		    tg3_asic_rev(tp) == ASIC_REV_5720)
+			reset_phy = true;
+
+		err = tg3_restart_hw(tp, reset_phy);
 		if (!err)
 			tg3_netif_start(tp);
 	}
@@ -12444,6 +12451,7 @@ static int tg3_set_pauseparam(struct net
 {
 	struct tg3 *tp = netdev_priv(dev);
 	int err = 0;
+	bool reset_phy = false;
 
 	if (tp->link_config.autoneg == AUTONEG_ENABLE)
 		tg3_warn_mgmt_link_flap(tp);
@@ -12534,7 +12542,13 @@ static int tg3_set_pauseparam(struct net
 
 		if (netif_running(dev)) {
 			tg3_halt(tp, RESET_KIND_SHUTDOWN, 1);
-			err = tg3_restart_hw(tp, false);
+			/* Reset PHY to avoid PHY lock up */
+			if (tg3_asic_rev(tp) == ASIC_REV_5717 ||
+			    tg3_asic_rev(tp) == ASIC_REV_5719 ||
+			    tg3_asic_rev(tp) == ASIC_REV_5720)
+				reset_phy = true;
+
+			err = tg3_restart_hw(tp, reset_phy);
 			if (!err)
 				tg3_netif_start(tp);
 		}



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 05/70] ipv6: Fix PMTU updates for UDP/raw sockets in presence of VRF
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (3 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 04/70] tg3: Add PHY reset for 5717/5719/5720 in change ring and flow control paths Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 06/70] kbuild: Add better clang cross build support Greg Kroah-Hartman
                   ` (70 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Preethi Ramachandra, David Ahern,
	David S. Miller

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: David Ahern <dsahern@gmail.com>

[ Upstream commit 7ddacfa564870cdd97275fd87decb6174abc6380 ]

Preethi reported that PMTU discovery for UDP/raw applications is not
working in the presence of VRF when the socket is not bound to a device.
The problem is that ip6_sk_update_pmtu does not consider the L3 domain
of the skb device if the socket is not bound. Update the function to
set oif to the L3 master device if relevant.

Fixes: ca254490c8df ("net: Add VRF support to IPv6 stack")
Reported-by: Preethi Ramachandra <preethir@juniper.net>
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/ipv6/route.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1420,8 +1420,12 @@ EXPORT_SYMBOL_GPL(ip6_update_pmtu);
 
 void ip6_sk_update_pmtu(struct sk_buff *skb, struct sock *sk, __be32 mtu)
 {
-	ip6_update_pmtu(skb, sock_net(sk), mtu,
-			sk->sk_bound_dev_if, sk->sk_mark);
+	int oif = sk->sk_bound_dev_if;
+
+	if (!oif && skb->dev)
+		oif = l3mdev_master_ifindex(skb->dev);
+
+	ip6_update_pmtu(skb, sock_net(sk), mtu, oif, sk->sk_mark);
 }
 EXPORT_SYMBOL_GPL(ip6_sk_update_pmtu);
 



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 06/70] kbuild: Add better clang cross build support
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (4 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 05/70] ipv6: Fix PMTU updates for UDP/raw sockets in presence of VRF Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 07/70] kbuild: clang: add -no-integrated-as to KBUILD_[AC]FLAGS Greg Kroah-Hartman
                   ` (69 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Behan Webster, Jan-Simon Möller,
	Mark Charlebois, Greg Hackmann, Matthias Kaehlcke,
	Masahiro Yamada, Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Behan Webster <behanw@converseincode.com>

commit 785f11aa595bc3d4e74096cbd598ada54ecc0d81 upstream.

Add cross target to CC if using clang. Also add custom gcc toolchain
path for fallback gcc tools.

Clang will fallback to using things like ld, as, and libgcc if
(respectively) one of the llvm linkers isn't available, the integrated
assembler is turned off, or an appropriately cross-compiled version of
compiler-rt isn't available. To this end, you can specify the path to
this fallback gcc toolchain with GCC_TOOLCHAIN.

Signed-off-by: Behan Webster <behanw@converseincode.com>
Reviewed-by: Jan-Simon Möller <dl9pf@gmx.de>
Reviewed-by: Mark Charlebois <charlebm@gmail.com>
Signed-off-by: Greg Hackmann <ghackmann@google.com>
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 Makefile |    9 +++++++++
 1 file changed, 9 insertions(+)

--- a/Makefile
+++ b/Makefile
@@ -698,6 +698,15 @@ endif
 KBUILD_CFLAGS += $(stackp-flag)
 
 ifeq ($(cc-name),clang)
+ifneq ($(CROSS_COMPILE),)
+CLANG_TARGET	:= -target $(notdir $(CROSS_COMPILE:%-=%))
+GCC_TOOLCHAIN	:= $(realpath $(dir $(shell which $(LD)))/..)
+endif
+ifneq ($(GCC_TOOLCHAIN),)
+CLANG_GCC_TC	:= -gcc-toolchain $(GCC_TOOLCHAIN)
+endif
+KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
+KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
 KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
 KBUILD_CPPFLAGS += $(call cc-option,-Wno-unknown-warning-option,)
 KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 07/70] kbuild: clang: add -no-integrated-as to KBUILD_[AC]FLAGS
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (5 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 06/70] kbuild: Add better clang cross build support Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 08/70] kbuild: Consolidate header generation from ASM offset information Greg Kroah-Hartman
                   ` (68 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Michael Davidson, Matthias Kaehlcke,
	Masahiro Yamada, Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Michael Davidson <md@google.com>

commit a37c45cd82e62a361706b9688a984a3a63957321 upstream.

The Linux Kernel relies on GCC's acceptance of inline assembly as an
opaque object which will not have any validation performed on the content.
The current behaviour in LLVM is to perform validation of the contents by
means of parsing the input if the MC layer can handle it.

Disable clangs integrated assembler and use the GNU assembler instead.

Wording-mostly-from: Saleem Abdulrasool <compnerd@compnerd.org>
Signed-off-by: Michael Davidson <md@google.com>
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 Makefile |    2 ++
 1 file changed, 2 insertions(+)

--- a/Makefile
+++ b/Makefile
@@ -719,6 +719,8 @@ KBUILD_CFLAGS += $(call cc-disable-warni
 # See modpost pattern 2
 KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
 KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
+KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
+KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
 else
 
 # These warnings generated too much noise in a regular build.



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 08/70] kbuild: Consolidate header generation from ASM offset information
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (6 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 07/70] kbuild: clang: add -no-integrated-as to KBUILD_[AC]FLAGS Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 09/70] kbuild: consolidate redundant sed script ASM offset generation Greg Kroah-Hartman
                   ` (67 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Matthias Kaehlcke, Masahiro Yamada,
	Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Matthias Kaehlcke <mka@chromium.org>

commit ebf003f0cfb3705e60d40dedc3ec949176c741af upstream.

Largely redundant code is used in different places to generate C headers
from offset information extracted from assembly language output.
Consolidate the code in Makefile.lib and use this instead.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 Kbuild                    |   25 -------------------------
 arch/ia64/kernel/Makefile |   26 ++------------------------
 scripts/Makefile.lib      |   28 ++++++++++++++++++++++++++++
 scripts/mod/Makefile      |   28 ++--------------------------
 4 files changed, 32 insertions(+), 75 deletions(-)

--- a/Kbuild
+++ b/Kbuild
@@ -6,31 +6,6 @@
 # 3) Generate asm-offsets.h (may need bounds.h and timeconst.h)
 # 4) Check for missing system calls
 
-# Default sed regexp - multiline due to syntax constraints
-define sed-y
-	"/^->/{s:->#\(.*\):/* \1 */:; \
-	s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
-	s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
-	s:->::; p;}"
-endef
-
-# Use filechk to avoid rebuilds when a header changes, but the resulting file
-# does not
-define filechk_offsets
-	(set -e; \
-	 echo "#ifndef $2"; \
-	 echo "#define $2"; \
-	 echo "/*"; \
-	 echo " * DO NOT MODIFY."; \
-	 echo " *"; \
-	 echo " * This file was generated by Kbuild"; \
-	 echo " */"; \
-	 echo ""; \
-	 sed -ne $(sed-y); \
-	 echo ""; \
-	 echo "#endif" )
-endef
-
 #####
 # 1) Generate bounds.h
 
--- a/arch/ia64/kernel/Makefile
+++ b/arch/ia64/kernel/Makefile
@@ -50,32 +50,10 @@ CFLAGS_traps.o  += -mfixed-range=f2-f5,f
 # The gate DSO image is built using a special linker script.
 include $(src)/Makefile.gate
 
-# Calculate NR_IRQ = max(IA64_NATIVE_NR_IRQS, XEN_NR_IRQS, ...) based on config
-define sed-y
-	"/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"
-endef
-quiet_cmd_nr_irqs = GEN     $@
-define cmd_nr_irqs
-	(set -e; \
-	 echo "#ifndef __ASM_NR_IRQS_H__"; \
-	 echo "#define __ASM_NR_IRQS_H__"; \
-	 echo "/*"; \
-	 echo " * DO NOT MODIFY."; \
-	 echo " *"; \
-	 echo " * This file was generated by Kbuild"; \
-	 echo " *"; \
-	 echo " */"; \
-	 echo ""; \
-	 sed -ne $(sed-y) $<; \
-	 echo ""; \
-	 echo "#endif" ) > $@
-endef
-
 # We use internal kbuild rules to avoid the "is up to date" message from make
 arch/$(SRCARCH)/kernel/nr-irqs.s: arch/$(SRCARCH)/kernel/nr-irqs.c
 	$(Q)mkdir -p $(dir $@)
 	$(call if_changed_dep,cc_s_c)
 
-include/generated/nr-irqs.h: arch/$(SRCARCH)/kernel/nr-irqs.s
-	$(Q)mkdir -p $(dir $@)
-	$(call cmd,nr_irqs)
+include/generated/nr-irqs.h: arch/$(SRCARCH)/kernel/nr-irqs.s FORCE
+	$(call filechk,offsets,__ASM_NR_IRQS_H__)
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -388,3 +388,31 @@ quiet_cmd_xzmisc = XZMISC  $@
 cmd_xzmisc = (cat $(filter-out FORCE,$^) | \
 	xz --check=crc32 --lzma2=dict=1MiB) > $@ || \
 	(rm -f $@ ; false)
+
+# ASM offsets
+# ---------------------------------------------------------------------------
+
+# Default sed regexp - multiline due to syntax constraints
+define sed-offsets
+	"/^->/{s:->#\(.*\):/* \1 */:; \
+	s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
+	s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
+	s:->::; p;}"
+endef
+
+# Use filechk to avoid rebuilds when a header changes, but the resulting file
+# does not
+define filechk_offsets
+	(set -e; \
+	 echo "#ifndef $2"; \
+	 echo "#define $2"; \
+	 echo "/*"; \
+	 echo " * DO NOT MODIFY."; \
+	 echo " *"; \
+	 echo " * This file was generated by Kbuild"; \
+	 echo " */"; \
+	 echo ""; \
+	 sed -ne $(sed-offsets); \
+	 echo ""; \
+	 echo "#endif" )
+endef
--- a/scripts/mod/Makefile
+++ b/scripts/mod/Makefile
@@ -5,32 +5,8 @@ modpost-objs	:= modpost.o file2alias.o s
 
 devicetable-offsets-file := devicetable-offsets.h
 
-define sed-y
-	"/^->/{s:->#\(.*\):/* \1 */:; \
-	s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
-	s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
-	s:->::; p;}"
-endef
-
-quiet_cmd_offsets = GEN     $@
-define cmd_offsets
-	(set -e; \
-	 echo "#ifndef __DEVICETABLE_OFFSETS_H__"; \
-	 echo "#define __DEVICETABLE_OFFSETS_H__"; \
-	 echo "/*"; \
-	 echo " * DO NOT MODIFY."; \
-	 echo " *"; \
-	 echo " * This file was generated by Kbuild"; \
-	 echo " *"; \
-	 echo " */"; \
-	 echo ""; \
-	 sed -ne $(sed-y) $<; \
-	 echo ""; \
-	 echo "#endif" ) > $@
-endef
-
-$(obj)/$(devicetable-offsets-file): $(obj)/devicetable-offsets.s
-	$(call if_changed,offsets)
+$(obj)/$(devicetable-offsets-file): $(obj)/devicetable-offsets.s FORCE
+	$(call filechk,offsets,__DEVICETABLE_OFFSETS_H__)
 
 targets += $(devicetable-offsets-file) devicetable-offsets.s
 



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 09/70] kbuild: consolidate redundant sed script ASM offset generation
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (7 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 08/70] kbuild: Consolidate header generation from ASM offset information Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 10/70] kbuild: fix asm-offset generation to work with clang Greg Kroah-Hartman
                   ` (66 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Masahiro Yamada, Matthias Kaehlcke,
	Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Masahiro Yamada <yamada.masahiro@socionext.com>

commit 7dd47b95b0f54f2057d40af6e66d477e3fe95d13 upstream.

This part ended up in redundant code after touched by multiple
people.

[1] Commit 3234282f33b2 ("x86, asm: Fix CFI macro invocations to
deal with shortcomings in gas") added parentheses for defined
expressions to support old gas for x86.

[2] Commit a22dcdb0032c ("x86, asm: Fix ancient-GAS workaround")
split the pattern into two to avoid parentheses for non-numeric
expressions.

[3] Commit 95a2f6f72d37 ("Partially revert patch that encloses
asm-offset.h numbers in brackets") removed parentheses from numeric
expressions as well because parentheses in MN10300 assembly have a
special meaning (pointer access).

Apparently, there is a conflict between [1] and [3].  After all,
[3] took precedence, and a long time has passed since then.

Now, merge the two patterns again because the first one is covered
by the other.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 scripts/Makefile.lib |    1 -
 1 file changed, 1 deletion(-)

--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -395,7 +395,6 @@ cmd_xzmisc = (cat $(filter-out FORCE,$^)
 # Default sed regexp - multiline due to syntax constraints
 define sed-offsets
 	"/^->/{s:->#\(.*\):/* \1 */:; \
-	s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
 	s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
 	s:->::; p;}"
 endef



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 10/70] kbuild: fix asm-offset generation to work with clang
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (8 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 09/70] kbuild: consolidate redundant sed script ASM offset generation Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 11/70] kbuild: drop -Wno-unknown-warning-option from clang options Greg Kroah-Hartman
                   ` (65 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Jeroen Hofstee, Masahiro Yamada,
	Matthias Kaehlcke, Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jeroen Hofstee <jeroen@myspectrum.nl>

commit cf0c3e68aa81f992b0301f62e341b710d385bf68 upstream.

KBuild abuses the asm statement to write to a file and
clang chokes about these invalid asm statements. Hack it
even more by fooling this is actual valid asm code.

[masahiro:
 Import Jeroen's work for U-Boot:
 http://patchwork.ozlabs.org/patch/375026/
 Tweak sed script a little to avoid garbage '#' for GCC case, like
 #define NR_PAGEFLAGS 23 /* __NR_PAGEFLAGS       # */ ]

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Tested-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 include/linux/kbuild.h |    6 +++---
 scripts/Makefile.lib   |    8 ++++++--
 2 files changed, 9 insertions(+), 5 deletions(-)

--- a/include/linux/kbuild.h
+++ b/include/linux/kbuild.h
@@ -2,14 +2,14 @@
 #define __LINUX_KBUILD_H
 
 #define DEFINE(sym, val) \
-        asm volatile("\n->" #sym " %0 " #val : : "i" (val))
+	asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i" (val))
 
-#define BLANK() asm volatile("\n->" : : )
+#define BLANK() asm volatile("\n.ascii \"->\"" : : )
 
 #define OFFSET(sym, str, mem) \
 	DEFINE(sym, offsetof(struct str, mem))
 
 #define COMMENT(x) \
-	asm volatile("\n->#" x)
+	asm volatile("\n.ascii \"->#" x "\"")
 
 #endif
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -393,10 +393,14 @@ cmd_xzmisc = (cat $(filter-out FORCE,$^)
 # ---------------------------------------------------------------------------
 
 # Default sed regexp - multiline due to syntax constraints
+#
+# Use [:space:] because LLVM's integrated assembler inserts <tab> around
+# the .ascii directive whereas GCC keeps the <space> as-is.
 define sed-offsets
-	"/^->/{s:->#\(.*\):/* \1 */:; \
+	's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; \
+	/^->/{s:->#\(.*\):/* \1 */:; \
 	s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
-	s:->::; p;}"
+	s:->::; p;}'
 endef
 
 # Use filechk to avoid rebuilds when a header changes, but the resulting file



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 11/70] kbuild: drop -Wno-unknown-warning-option from clang options
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (9 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 10/70] kbuild: fix asm-offset generation to work with clang Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 12/70] kbuild, LLVMLinux: Add -Werror to cc-option to support clang Greg Kroah-Hartman
                   ` (64 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Masahiro Yamada, Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Masahiro Yamada <yamada.masahiro@socionext.com>

commit a0ae981eba8f07dbc74bce38fd3a462b69a5bc8e upstream.

Since commit c3f0d0bc5b01 ("kbuild, LLVMLinux: Add -Werror to
cc-option to support clang"), cc-option and friends work nicely
for clang.

However, -Wno-unknown-warning-option makes clang happy with any
unknown warning options even if -Werror is specified.

Once -Wno-unknown-warning-option is added, any succeeding call of
cc-disable-warning is evaluated positive, then unknown warning
options are accepted.  This should be dropped.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 Makefile                   |    1 -
 scripts/Makefile.extrawarn |    1 -
 2 files changed, 2 deletions(-)

--- a/Makefile
+++ b/Makefile
@@ -708,7 +708,6 @@ endif
 KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
 KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
 KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
-KBUILD_CPPFLAGS += $(call cc-option,-Wno-unknown-warning-option,)
 KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
 KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
 KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -61,7 +61,6 @@ ifeq ($(cc-name),clang)
 KBUILD_CFLAGS += $(call cc-disable-warning, initializer-overrides)
 KBUILD_CFLAGS += $(call cc-disable-warning, unused-value)
 KBUILD_CFLAGS += $(call cc-disable-warning, format)
-KBUILD_CFLAGS += $(call cc-disable-warning, unknown-warning-option)
 KBUILD_CFLAGS += $(call cc-disable-warning, sign-compare)
 KBUILD_CFLAGS += $(call cc-disable-warning, format-zero-length)
 KBUILD_CFLAGS += $(call cc-disable-warning, uninitialized)



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 12/70] kbuild, LLVMLinux: Add -Werror to cc-option to support clang
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (10 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 11/70] kbuild: drop -Wno-unknown-warning-option from clang options Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 13/70] kbuild: use -Oz instead of -Os when using clang Greg Kroah-Hartman
                   ` (63 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Mark Charlebois, Behan Webster,
	Jan-Simon Möller, Arnd Bergmann, Kees Cook, Masahiro Yamada,
	Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Mark Charlebois <charlebm@gmail.com>

commit c3f0d0bc5b01ad90c45276952802455750444b4f upstream.

Clang will warn about unknown warnings but will not return false
unless -Werror is set. GCC will return false if an unknown
warning is passed.

Adding -Werror make both compiler behave the same.

[arnd: it turns out we need the same patch for testing whether -ffunction-sections
       works right with gcc. I've build tested extensively with this patch
       applied, so let's just merge this one now.]

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
Signed-off-by: Behan Webster <behanw@converseincode.com>
Reviewed-by: Jan-Simon Möller <dl9pf@gmx.de>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
[nc: Adjust context due to lack of d26e94149276f]
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 scripts/Kbuild.include |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -112,12 +112,12 @@ as-instr = $(call try-run,\
 # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
 
 cc-option = $(call try-run,\
-	$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
+	$(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
 
 # cc-option-yn
 # Usage: flag := $(call cc-option-yn,-march=winchip-c6)
 cc-option-yn = $(call try-run,\
-	$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
+	$(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
 
 # cc-option-align
 # Prefix align with either -falign or -malign
@@ -127,7 +127,7 @@ cc-option-align = $(subst -functions=0,,
 # cc-disable-warning
 # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
 cc-disable-warning = $(call try-run,\
-	$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
+	$(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
 
 # cc-name
 # Expands to either gcc or clang



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 13/70] kbuild: use -Oz instead of -Os when using clang
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (11 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 12/70] kbuild, LLVMLinux: Add -Werror to cc-option to support clang Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 14/70] kbuild: Add support to generate LLVM assembly files Greg Kroah-Hartman
                   ` (62 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Behan Webster, Matthias Kaehlcke,
	Masahiro Yamada, Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Behan Webster <behanw@converseincode.com>

commit 6748cb3c299de1ffbe56733647b01dbcc398c419 upstream.

This generates smaller resulting object code when compiled with clang.

Signed-off-by: Behan Webster <behanw@converseincode.com>
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
[nc: Adjust context due to lack of commit a76bcf557ef4 in linux-4.4.y]
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 Makefile |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/Makefile
+++ b/Makefile
@@ -628,7 +628,7 @@ KBUILD_CFLAGS	+= $(call cc-disable-warni
 KBUILD_CFLAGS	+= $(call cc-disable-warning, attribute-alias)
 
 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
-KBUILD_CFLAGS	+= -Os
+KBUILD_CFLAGS	+= $(call cc-option,-Oz,-Os)
 else
 ifdef CONFIG_PROFILE_ALL_BRANCHES
 KBUILD_CFLAGS	+= -O2



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 14/70] kbuild: Add support to generate LLVM assembly files
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (12 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 13/70] kbuild: use -Oz instead of -Os when using clang Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 15/70] modules: mark __inittest/__exittest as __maybe_unused Greg Kroah-Hartman
                   ` (61 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Vinícius Tinti, Behan Webster,
	Matthias Kaehlcke, Masahiro Yamada, Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Vinícius Tinti <viniciustinti@gmail.com>

commit 433db3e260bc8134d4a46ddf20b3668937e12556 upstream.

Add rules to kbuild in order to generate LLVM assembly files with the .ll
extension when using clang.

  # from c code
  make CC=clang kernel/pid.ll

Signed-off-by: Vinícius Tinti <viniciustinti@gmail.com>
Signed-off-by: Behan Webster <behanw@converseincode.com>
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
[nc: Fix conflicts due to lack of commit 6b90bd4ba40b3 in linux-4.4.y]
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 .gitignore             |    1 +
 Makefile               |    5 +++++
 scripts/Makefile.build |    8 ++++++++
 3 files changed, 14 insertions(+)

--- a/.gitignore
+++ b/.gitignore
@@ -33,6 +33,7 @@
 *.lzo
 *.patch
 *.gcno
+*.ll
 modules.builtin
 Module.symvers
 *.dwo
--- a/Makefile
+++ b/Makefile
@@ -1307,6 +1307,8 @@ help:
 	@echo  '                    (default: $$(INSTALL_MOD_PATH)/lib/firmware)'
 	@echo  '  dir/            - Build all files in dir and below'
 	@echo  '  dir/file.[ois]  - Build specified target only'
+	@echo  '  dir/file.ll     - Build the LLVM assembly file'
+	@echo  '                    (requires compiler support for LLVM assembly generation)'
 	@echo  '  dir/file.lst    - Build specified mixed source/assembly target only'
 	@echo  '                    (requires a recent binutils and recent build (System.map))'
 	@echo  '  dir/file.ko     - Build module including final link'
@@ -1482,6 +1484,7 @@ clean: $(clean-dirs)
 		-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
 		-o -name '*.symtypes' -o -name 'modules.order' \
 		-o -name modules.builtin -o -name '.tmp_*.o.*' \
+		-o -name '*.ll' \
 		-o -name '*.gcno' \) -type f -print | xargs rm -f
 
 # Generate tags for editors
@@ -1585,6 +1588,8 @@ endif
 	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
 %.symtypes: %.c prepare scripts FORCE
 	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
+%.ll: %.c prepare scripts FORCE
+	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
 
 # Modules
 /: prepare scripts FORCE
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -175,6 +175,14 @@ cmd_cc_symtypes_c =
 $(obj)/%.symtypes : $(src)/%.c FORCE
 	$(call cmd,cc_symtypes_c)
 
+# LLVM assembly
+# Generate .ll files from .c
+quiet_cmd_cc_ll_c = CC $(quiet_modtag)  $@
+      cmd_cc_ll_c = $(CC) $(c_flags) -emit-llvm -S -o $@ $<
+
+$(obj)/%.ll: $(src)/%.c FORCE
+	$(call if_changed_dep,cc_ll_c)
+
 # C (.c) files
 # The C file is compiled and updated dependency information is generated.
 # (See cmd_cc_o_c + relevant part of rule_cc_o_c)



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 15/70] modules: mark __inittest/__exittest as __maybe_unused
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (13 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 14/70] kbuild: Add support to generate LLVM assembly files Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 16/70] kbuild: clang: Disable address-of-packed-member warning Greg Kroah-Hartman
                   ` (60 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Arnd Bergmann, Miroslav Benes,
	Rusty Russell, Jessica Yu, Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Arnd Bergmann <arnd@arndb.de>

commit 1f318a8bafcfba9f0d623f4870c4e890fd22e659 upstream.

clang warns about unused inline functions by default:

arch/arm/crypto/aes-cipher-glue.c:68:1: warning: unused function '__inittest' [-Wunused-function]
arch/arm/crypto/aes-cipher-glue.c:69:1: warning: unused function '__exittest' [-Wunused-function]

As these appear in every single module, let's just disable the warnings by marking the
two functions as __maybe_unused.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Acked-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Jessica Yu <jeyu@redhat.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 include/linux/module.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -125,13 +125,13 @@ extern void cleanup_module(void);
 
 /* Each module must use one module_init(). */
 #define module_init(initfn)					\
-	static inline initcall_t __inittest(void)		\
+	static inline initcall_t __maybe_unused __inittest(void)		\
 	{ return initfn; }					\
 	int init_module(void) __attribute__((alias(#initfn)));
 
 /* This is only required if you want to be unloadable. */
 #define module_exit(exitfn)					\
-	static inline exitcall_t __exittest(void)		\
+	static inline exitcall_t __maybe_unused __exittest(void)		\
 	{ return exitfn; }					\
 	void cleanup_module(void) __attribute__((alias(#exitfn)));
 



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 16/70] kbuild: clang: Disable address-of-packed-member warning
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (14 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 15/70] modules: mark __inittest/__exittest as __maybe_unused Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 17/70] crypto: arm64/sha - avoid non-standard inline asm tricks Greg Kroah-Hartman
                   ` (59 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Matthias Kaehlcke, Douglas Anderson,
	Masahiro Yamada, Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Matthias Kaehlcke <mka@chromium.org>

commit bfb38988c51e440fd7062ddf3157f7d8b1dd5d70 upstream.

clang generates plenty of these warnings in different parts of the code,
to an extent that the warnings are little more than noise. Disable the
'address-of-packed-member' warning.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 Makefile |    1 +
 1 file changed, 1 insertion(+)

--- a/Makefile
+++ b/Makefile
@@ -711,6 +711,7 @@ KBUILD_CPPFLAGS += $(call cc-option,-Qun
 KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
 KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
 KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
+KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
 # Quiet clang warning: comparison of unsigned expression < 0 is always false
 KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
 # CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 17/70] crypto: arm64/sha - avoid non-standard inline asm tricks
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (15 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 16/70] kbuild: clang: Disable address-of-packed-member warning Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2020-11-23 20:49   ` dann frazier
  2018-11-26 10:50 ` [PATCH 4.4 18/70] efi/libstub/arm64: Force hidden visibility for section markers Greg Kroah-Hartman
                   ` (58 subsequent siblings)
  75 siblings, 1 reply; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Ard Biesheuvel, Matthias Kaehlcke,
	Herbert Xu, Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ard Biesheuvel <ard.biesheuvel@linaro.org>

commit f4857f4c2ee9aa4e2aacac1a845352b00197fb57 upstream.

Replace the inline asm which exports struct offsets as ELF symbols
with proper const variables exposing the same values. This works
around an issue with Clang which does not interpret the "i" (or "I")
constraints in the same way as GCC.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/arm64/crypto/sha1-ce-core.S |    6 ++++--
 arch/arm64/crypto/sha1-ce-glue.c |   11 +++--------
 arch/arm64/crypto/sha2-ce-core.S |    6 ++++--
 arch/arm64/crypto/sha2-ce-glue.c |   13 +++++--------
 4 files changed, 16 insertions(+), 20 deletions(-)

--- a/arch/arm64/crypto/sha1-ce-core.S
+++ b/arch/arm64/crypto/sha1-ce-core.S
@@ -82,7 +82,8 @@ ENTRY(sha1_ce_transform)
 	ldr		dgb, [x0, #16]
 
 	/* load sha1_ce_state::finalize */
-	ldr		w4, [x0, #:lo12:sha1_ce_offsetof_finalize]
+	ldr_l		w4, sha1_ce_offsetof_finalize, x4
+	ldr		w4, [x0, x4]
 
 	/* load input */
 0:	ld1		{v8.4s-v11.4s}, [x1], #64
@@ -132,7 +133,8 @@ CPU_LE(	rev32		v11.16b, v11.16b	)
 	 * the padding is handled by the C code in that case.
 	 */
 	cbz		x4, 3f
-	ldr		x4, [x0, #:lo12:sha1_ce_offsetof_count]
+	ldr_l		w4, sha1_ce_offsetof_count, x4
+	ldr		x4, [x0, x4]
 	movi		v9.2d, #0
 	mov		x8, #0x80000000
 	movi		v10.2d, #0
--- a/arch/arm64/crypto/sha1-ce-glue.c
+++ b/arch/arm64/crypto/sha1-ce-glue.c
@@ -17,9 +17,6 @@
 #include <linux/crypto.h>
 #include <linux/module.h>
 
-#define ASM_EXPORT(sym, val) \
-	asm(".globl " #sym "; .set " #sym ", %0" :: "I"(val));
-
 MODULE_DESCRIPTION("SHA1 secure hash using ARMv8 Crypto Extensions");
 MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
 MODULE_LICENSE("GPL v2");
@@ -32,6 +29,9 @@ struct sha1_ce_state {
 asmlinkage void sha1_ce_transform(struct sha1_ce_state *sst, u8 const *src,
 				  int blocks);
 
+const u32 sha1_ce_offsetof_count = offsetof(struct sha1_ce_state, sst.count);
+const u32 sha1_ce_offsetof_finalize = offsetof(struct sha1_ce_state, finalize);
+
 static int sha1_ce_update(struct shash_desc *desc, const u8 *data,
 			  unsigned int len)
 {
@@ -52,11 +52,6 @@ static int sha1_ce_finup(struct shash_de
 	struct sha1_ce_state *sctx = shash_desc_ctx(desc);
 	bool finalize = !sctx->sst.count && !(len % SHA1_BLOCK_SIZE);
 
-	ASM_EXPORT(sha1_ce_offsetof_count,
-		   offsetof(struct sha1_ce_state, sst.count));
-	ASM_EXPORT(sha1_ce_offsetof_finalize,
-		   offsetof(struct sha1_ce_state, finalize));
-
 	/*
 	 * Allow the asm code to perform the finalization if there is no
 	 * partial data and the input is a round multiple of the block size.
--- a/arch/arm64/crypto/sha2-ce-core.S
+++ b/arch/arm64/crypto/sha2-ce-core.S
@@ -88,7 +88,8 @@ ENTRY(sha2_ce_transform)
 	ld1		{dgav.4s, dgbv.4s}, [x0]
 
 	/* load sha256_ce_state::finalize */
-	ldr		w4, [x0, #:lo12:sha256_ce_offsetof_finalize]
+	ldr_l		w4, sha256_ce_offsetof_finalize, x4
+	ldr		w4, [x0, x4]
 
 	/* load input */
 0:	ld1		{v16.4s-v19.4s}, [x1], #64
@@ -136,7 +137,8 @@ CPU_LE(	rev32		v19.16b, v19.16b	)
 	 * the padding is handled by the C code in that case.
 	 */
 	cbz		x4, 3f
-	ldr		x4, [x0, #:lo12:sha256_ce_offsetof_count]
+	ldr_l		w4, sha256_ce_offsetof_count, x4
+	ldr		x4, [x0, x4]
 	movi		v17.2d, #0
 	mov		x8, #0x80000000
 	movi		v18.2d, #0
--- a/arch/arm64/crypto/sha2-ce-glue.c
+++ b/arch/arm64/crypto/sha2-ce-glue.c
@@ -17,9 +17,6 @@
 #include <linux/crypto.h>
 #include <linux/module.h>
 
-#define ASM_EXPORT(sym, val) \
-	asm(".globl " #sym "; .set " #sym ", %0" :: "I"(val));
-
 MODULE_DESCRIPTION("SHA-224/SHA-256 secure hash using ARMv8 Crypto Extensions");
 MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
 MODULE_LICENSE("GPL v2");
@@ -32,6 +29,11 @@ struct sha256_ce_state {
 asmlinkage void sha2_ce_transform(struct sha256_ce_state *sst, u8 const *src,
 				  int blocks);
 
+const u32 sha256_ce_offsetof_count = offsetof(struct sha256_ce_state,
+					      sst.count);
+const u32 sha256_ce_offsetof_finalize = offsetof(struct sha256_ce_state,
+						 finalize);
+
 static int sha256_ce_update(struct shash_desc *desc, const u8 *data,
 			    unsigned int len)
 {
@@ -52,11 +54,6 @@ static int sha256_ce_finup(struct shash_
 	struct sha256_ce_state *sctx = shash_desc_ctx(desc);
 	bool finalize = !sctx->sst.count && !(len % SHA256_BLOCK_SIZE);
 
-	ASM_EXPORT(sha256_ce_offsetof_count,
-		   offsetof(struct sha256_ce_state, sst.count));
-	ASM_EXPORT(sha256_ce_offsetof_finalize,
-		   offsetof(struct sha256_ce_state, finalize));
-
 	/*
 	 * Allow the asm code to perform the finalization if there is no
 	 * partial data and the input is a round multiple of the block size.



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 18/70] efi/libstub/arm64: Force hidden visibility for section markers
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (16 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 17/70] crypto: arm64/sha - avoid non-standard inline asm tricks Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 19/70] efi/libstub/arm64: Set -fpie when building the EFI stub Greg Kroah-Hartman
                   ` (57 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Matthias Kaehlcke, Ard Biesheuvel,
	Linus Torvalds, Matt Fleming, Peter Zijlstra, Thomas Gleixner,
	linux-efi, Ingo Molnar, Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ard Biesheuvel <ard.biesheuvel@linaro.org>

commit 0426a4e68f18d75515414361de9e3e1445d2644e upstream.

To prevent the compiler from emitting absolute references to the section
markers when running in PIC mode, override the visibility to 'hidden' for
all contents of asm/sections.h

Tested-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20170818194947.19347-4-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
[nc: Fix conflict due to lack of commit 42b55734030c1 in linux-4.4.y]
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/firmware/efi/libstub/arm64-stub.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

--- a/drivers/firmware/efi/libstub/arm64-stub.c
+++ b/drivers/firmware/efi/libstub/arm64-stub.c
@@ -9,9 +9,17 @@
  * published by the Free Software Foundation.
  *
  */
+
+/*
+ * To prevent the compiler from emitting GOT-indirected (and thus absolute)
+ * references to the section markers, override their visibility as 'hidden'
+ */
+#pragma GCC visibility push(hidden)
+#include <asm/sections.h>
+#pragma GCC visibility pop
+
 #include <linux/efi.h>
 #include <asm/efi.h>
-#include <asm/sections.h>
 
 efi_status_t __init handle_kernel_image(efi_system_table_t *sys_table_arg,
 					unsigned long *image_addr,



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 19/70] efi/libstub/arm64: Set -fpie when building the EFI stub
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (17 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 18/70] efi/libstub/arm64: Force hidden visibility for section markers Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 20/70] kbuild: fix linker feature test macros when cross compiling with Clang Greg Kroah-Hartman
                   ` (56 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Matthias Kaehlcke, Ard Biesheuvel,
	Linus Torvalds, Matt Fleming, Peter Zijlstra, Thomas Gleixner,
	linux-efi, Ingo Molnar, Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ard Biesheuvel <ard.biesheuvel@linaro.org>

commit 91ee5b21ee026c49e4e7483de69b55b8b47042be upstream.

Clang may emit absolute symbol references when building in non-PIC mode,
even when using the default 'small' code model, which is already mostly
position independent to begin with, due to its use of adrp/add pairs
that have a relative range of +/- 4 GB. The remedy is to pass the -fpie
flag, which can be done safely now that the code has been updated to avoid
GOT indirections (which may be emitted due to the compiler assuming that
the PIC/PIE code may end up in a shared library that is subject to ELF
symbol preemption)

Passing -fpie when building code that needs to execute at an a priori
unknown offset is arguably an improvement in any case, and given that
the recent visibility changes allow the PIC build to pass with GCC as
well, let's add -fpie for all arm64 builds rather than only for Clang.

Tested-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20170818194947.19347-5-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/firmware/efi/libstub/Makefile |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -10,7 +10,7 @@ cflags-$(CONFIG_X86)		+= -m$(BITS) -D__K
 				   -fPIC -fno-strict-aliasing -mno-red-zone \
 				   -mno-mmx -mno-sse -DDISABLE_BRANCH_PROFILING
 
-cflags-$(CONFIG_ARM64)		:= $(subst -pg,,$(KBUILD_CFLAGS))
+cflags-$(CONFIG_ARM64)		:= $(subst -pg,,$(KBUILD_CFLAGS)) -fpie
 cflags-$(CONFIG_ARM)		:= $(subst -pg,,$(KBUILD_CFLAGS)) \
 				   -fno-builtin -fpic -mno-single-pic-base
 



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 20/70] kbuild: fix linker feature test macros when cross compiling with Clang
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (18 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 19/70] efi/libstub/arm64: Set -fpie when building the EFI stub Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 21/70] kbuild: Set KBUILD_CFLAGS before incl. arch Makefile Greg Kroah-Hartman
                   ` (55 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Masahiro Yamada, Nick Desaulniers,
	Matthias Kaehlcke, Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Nick Desaulniers <ndesaulniers@google.com>

commit 86a9df597cdd564d2d29c65897bcad42519e3678 upstream.

I was not seeing my linker flags getting added when using ld-option when
cross compiling with Clang. Upon investigation, this seems to be due to
a difference in how GCC vs Clang handle cross compilation.

GCC is configured at build time to support one backend, that is implicit
when compiling.  Clang is explicit via the use of `-target <triple>` and
ships with all supported backends by default.

GNU Make feature test macros that compile then link will always fail
when cross compiling with Clang unless Clang's triple is passed along to
the compiler. For example:

$ clang -x c /dev/null -c -o temp.o
$ aarch64-linux-android/bin/ld -E temp.o
aarch64-linux-android/bin/ld:
unknown architecture of input file `temp.o' is incompatible with
aarch64 output
aarch64-linux-android/bin/ld:
warning: cannot find entry symbol _start; defaulting to
0000000000400078
$ echo $?
1

$ clang -target aarch64-linux-android- -x c /dev/null -c -o temp.o
$ aarch64-linux-android/bin/ld -E temp.o
aarch64-linux-android/bin/ld:
warning: cannot find entry symbol _start; defaulting to 00000000004002e4
$ echo $?
0

This causes conditional checks that invoke $(CC) without the target
triple, then $(LD) on the result, to always fail.

Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
[nc: Fix conflicts due to lack of commit 3298b690b21cd in linux-4.4.y
     Use KBUILD_CFLAGS instead of CC_OPTION_FLAGS because commit
     d26e94149276f that introduced that variable isn't in 4.4 either]
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 scripts/Kbuild.include |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -147,12 +147,13 @@ cc-ifversion = $(shell [ $(cc-version) $
 # cc-ldoption
 # Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both)
 cc-ldoption = $(call try-run,\
-	$(CC) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
+	$(CC) $(1) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
 
 # ld-option
 # Usage: LDFLAGS += $(call ld-option, -X)
 ld-option = $(call try-run,\
-	$(CC) -x c /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2))
+	$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -x c /dev/null -c -o "$$TMPO"; \
+	$(LD) $(LDFLAGS) $(1) "$$TMPO" -o "$$TMP",$(1),$(2))
 
 # ar-option
 # Usage: KBUILD_ARFLAGS := $(call ar-option,D)



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 21/70] kbuild: Set KBUILD_CFLAGS before incl. arch Makefile
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (19 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 20/70] kbuild: fix linker feature test macros when cross compiling with Clang Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 22/70] kbuild: move cc-option and cc-disable-warning after " Greg Kroah-Hartman
                   ` (54 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Chris Fries, Nick Desaulniers,
	Matthias Kaehlcke, Masahiro Yamada, Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Chris Fries <cfries@google.com>

commit ae6b289a37890909fea0e4a1666e19377fa0ed2c upstream.

Set the clang KBUILD_CFLAGS up before including arch/ Makefiles,
so that ld-options (etc.) can work correctly.

This fixes errors with clang such as ld-options trying to CC
against your host architecture, but LD trying to link against
your target architecture.

Signed-off-by: Chris Fries <cfries@google.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Tested-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
[nc: Adjust context]
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 Makefile |   64 +++++++++++++++++++++++++++++++--------------------------------
 1 file changed, 32 insertions(+), 32 deletions(-)

--- a/Makefile
+++ b/Makefile
@@ -612,6 +612,38 @@ endif # $(dot-config)
 # Defaults to vmlinux, but the arch makefile usually adds further targets
 all: vmlinux
 
+ifeq ($(cc-name),clang)
+ifneq ($(CROSS_COMPILE),)
+CLANG_TARGET	:= -target $(notdir $(CROSS_COMPILE:%-=%))
+GCC_TOOLCHAIN	:= $(realpath $(dir $(shell which $(LD)))/..)
+endif
+ifneq ($(GCC_TOOLCHAIN),)
+CLANG_GCC_TC	:= -gcc-toolchain $(GCC_TOOLCHAIN)
+endif
+KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
+KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
+KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
+KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
+KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
+KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
+KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
+# Quiet clang warning: comparison of unsigned expression < 0 is always false
+KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
+# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
+# source of a reference will be _MergedGlobals and not on of the whitelisted names.
+# See modpost pattern 2
+KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
+KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
+KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
+KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
+else
+
+# These warnings generated too much noise in a regular build.
+# Use make W=1 to enable them (see scripts/Makefile.build)
+KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
+KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
+endif
+
 # The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default
 # values of the respective KBUILD_* variables
 ARCH_CPPFLAGS :=
@@ -697,38 +729,6 @@ endif
 endif
 KBUILD_CFLAGS += $(stackp-flag)
 
-ifeq ($(cc-name),clang)
-ifneq ($(CROSS_COMPILE),)
-CLANG_TARGET	:= -target $(notdir $(CROSS_COMPILE:%-=%))
-GCC_TOOLCHAIN	:= $(realpath $(dir $(shell which $(LD)))/..)
-endif
-ifneq ($(GCC_TOOLCHAIN),)
-CLANG_GCC_TC	:= -gcc-toolchain $(GCC_TOOLCHAIN)
-endif
-KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
-KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
-KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
-KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
-KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
-KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
-KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
-# Quiet clang warning: comparison of unsigned expression < 0 is always false
-KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
-# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
-# source of a reference will be _MergedGlobals and not on of the whitelisted names.
-# See modpost pattern 2
-KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
-KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
-KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
-KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
-else
-
-# These warnings generated too much noise in a regular build.
-# Use make W=1 to enable them (see scripts/Makefile.build)
-KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
-KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
-endif
-
 ifdef CONFIG_FRAME_POINTER
 KBUILD_CFLAGS	+= -fno-omit-frame-pointer -fno-optimize-sibling-calls
 else



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 22/70] kbuild: move cc-option and cc-disable-warning after incl. arch Makefile
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (20 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 21/70] kbuild: Set KBUILD_CFLAGS before incl. arch Makefile Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 23/70] kbuild: clang: fix build failures with sparse check Greg Kroah-Hartman
                   ` (53 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Geert Uytterhoeven, Masahiro Yamada,
	Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Masahiro Yamada <yamada.masahiro@socionext.com>

commit cfe17c9bbe6a673fdafdab179c32b355ed447f66 upstream.

Geert reported commit ae6b289a3789 ("kbuild: Set KBUILD_CFLAGS before
incl. arch Makefile") broke cross-compilation using a cross-compiler
that supports less compiler options than the host compiler.

For example,

  cc1: error: unrecognized command line option "-Wno-unused-but-set-variable"

This problem happens on architectures that setup CROSS_COMPILE in their
arch/*/Makefile.

Move the cc-option and cc-disable-warning back to the original position,
but keep the Clang target options untouched.

Fixes: ae6b289a3789 ("kbuild: Set KBUILD_CFLAGS before incl. arch Makefile")
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>
[nc: Adjust context]
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 Makefile |   43 +++++++++++++++++++++++--------------------
 1 file changed, 23 insertions(+), 20 deletions(-)

--- a/Makefile
+++ b/Makefile
@@ -622,26 +622,6 @@ CLANG_GCC_TC	:= -gcc-toolchain $(GCC_TOO
 endif
 KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
 KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
-KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
-KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
-KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
-KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
-KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
-# Quiet clang warning: comparison of unsigned expression < 0 is always false
-KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
-# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
-# source of a reference will be _MergedGlobals and not on of the whitelisted names.
-# See modpost pattern 2
-KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
-KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
-KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
-KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
-else
-
-# These warnings generated too much noise in a regular build.
-# Use make W=1 to enable them (see scripts/Makefile.build)
-KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
-KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
 endif
 
 # The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default
@@ -729,6 +709,29 @@ endif
 endif
 KBUILD_CFLAGS += $(stackp-flag)
 
+ifeq ($(cc-name),clang)
+KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
+KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
+KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
+KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
+KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
+# Quiet clang warning: comparison of unsigned expression < 0 is always false
+KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
+# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
+# source of a reference will be _MergedGlobals and not on of the whitelisted names.
+# See modpost pattern 2
+KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
+KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
+KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
+KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
+else
+
+# These warnings generated too much noise in a regular build.
+# Use make W=1 to enable them (see scripts/Makefile.extrawarn)
+KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
+KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
+endif
+
 ifdef CONFIG_FRAME_POINTER
 KBUILD_CFLAGS	+= -fno-omit-frame-pointer -fno-optimize-sibling-calls
 else



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 23/70] kbuild: clang: fix build failures with sparse check
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (21 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 22/70] kbuild: move cc-option and cc-disable-warning after " Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 24/70] kbuild: clang: remove crufty HOSTCFLAGS Greg Kroah-Hartman
                   ` (52 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, David Lin, Masahiro Yamada,
	Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: David Lin <dtwlin@google.com>

commit bb3f38c3c5b759163e09b9152629cc789731de47 upstream.

We should avoid using the space character when passing arguments to
clang, because static code analysis check tool such as sparse may
misinterpret the arguments followed by spaces as build targets hence
cause the build to fail.

Signed-off-by: David Lin <dtwlin@google.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 Makefile |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/Makefile
+++ b/Makefile
@@ -614,11 +614,11 @@ all: vmlinux
 
 ifeq ($(cc-name),clang)
 ifneq ($(CROSS_COMPILE),)
-CLANG_TARGET	:= -target $(notdir $(CROSS_COMPILE:%-=%))
+CLANG_TARGET	:= --target=$(notdir $(CROSS_COMPILE:%-=%))
 GCC_TOOLCHAIN	:= $(realpath $(dir $(shell which $(LD)))/..)
 endif
 ifneq ($(GCC_TOOLCHAIN),)
-CLANG_GCC_TC	:= -gcc-toolchain $(GCC_TOOLCHAIN)
+CLANG_GCC_TC	:= --gcc-toolchain=$(GCC_TOOLCHAIN)
 endif
 KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
 KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 24/70] kbuild: clang: remove crufty HOSTCFLAGS
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (22 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 23/70] kbuild: clang: fix build failures with sparse check Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 25/70] kbuild: clang: disable unused variable warnings only when constant Greg Kroah-Hartman
                   ` (51 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Masahiro Yamada, Nick Desaulniers,
	Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Nick Desaulniers <nick.desaulniers@gmail.com>

commit df16aaac26e92e97ab7234d3f93c953466adc4b5 upstream.

When compiling with `make CC=clang HOSTCC=clang`, I was seeing warnings
that clang did not recognize -fno-delete-null-pointer-checks for HOSTCC
targets.  These were added in commit 61163efae020 ("kbuild: LLVMLinux:
Add Kbuild support for building kernel with Clang").

Clang does not support -fno-delete-null-pointer-checks, so adding it to
HOSTCFLAGS if HOSTCC is clang does not make sense.

It's not clear why the other warnings were disabled, and just for
HOSTCFLAGS, but I can remove them, add -Werror to HOSTCFLAGS and compile
with clang just fine.

Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Nick Desaulniers <nick.desaulniers@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
[nc: Adjust context]
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 Makefile |    5 -----
 1 file changed, 5 deletions(-)

--- a/Makefile
+++ b/Makefile
@@ -306,11 +306,6 @@ HOSTCXX      = g++
 HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
 HOSTCXXFLAGS = -O2
 
-ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1)
-HOSTCFLAGS  += -Wno-unused-value -Wno-unused-parameter \
-		-Wno-missing-field-initializers -fno-delete-null-pointer-checks
-endif
-
 # Decide whether to build built-in, modular, or both.
 # Normally, just do built-in.
 



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 25/70] kbuild: clang: disable unused variable warnings only when constant
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (23 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 24/70] kbuild: clang: remove crufty HOSTCFLAGS Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 26/70] kbuild: set no-integrated-as before incl. arch Makefile Greg Kroah-Hartman
                   ` (50 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Prasad Sodagudi, Masahiro Yamada,
	Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Sodagudi Prasad <psodagud@codeaurora.org>

commit 0a5f41767444cc3b4fc5573921ab914b4f78baaa upstream.

Currently, GCC disables -Wunused-const-variable, but not
-Wunused-variable, so warns unused variables if they are
non-constant.

While, Clang does not warn unused variables at all regardless of
the const qualifier because -Wno-unused-const-variable is implied
by the stronger option -Wno-unused-variable.

Disable -Wunused-const-variable instead of -Wunused-variable so that
GCC and Clang work in the same way.

Signed-off-by: Prasad Sodagudi <psodagud@codeaurora.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 Makefile |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/Makefile
+++ b/Makefile
@@ -706,7 +706,6 @@ KBUILD_CFLAGS += $(stackp-flag)
 
 ifeq ($(cc-name),clang)
 KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
-KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
 KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
 KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
 KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
@@ -724,9 +723,9 @@ else
 # These warnings generated too much noise in a regular build.
 # Use make W=1 to enable them (see scripts/Makefile.extrawarn)
 KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
-KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
 endif
 
+KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
 ifdef CONFIG_FRAME_POINTER
 KBUILD_CFLAGS	+= -fno-omit-frame-pointer -fno-optimize-sibling-calls
 else



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 26/70] kbuild: set no-integrated-as before incl. arch Makefile
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (24 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 25/70] kbuild: clang: disable unused variable warnings only when constant Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 27/70] kbuild: allow to use GCC toolchain not in Clang search path Greg Kroah-Hartman
                   ` (49 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Stefan Agner, Masahiro Yamada,
	Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Stefan Agner <stefan@agner.ch>

commit 0f0e8de334c54c38818a4a5390a39aa09deff5bf upstream.

In order to make sure compiler flag detection for ARM works
correctly the no-integrated-as flags need to be set before
including the arch specific Makefile.

Fixes: cfe17c9bbe6a ("kbuild: move cc-option and cc-disable-warning after incl. arch Makefile")
Signed-off-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
[nc: Adjust context]
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 Makefile |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/Makefile
+++ b/Makefile
@@ -617,6 +617,8 @@ CLANG_GCC_TC	:= --gcc-toolchain=$(GCC_TO
 endif
 KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
 KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
+KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
+KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
 endif
 
 # The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default
@@ -716,8 +718,6 @@ KBUILD_CFLAGS += $(call cc-disable-warni
 # See modpost pattern 2
 KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
 KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
-KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
-KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
 else
 
 # These warnings generated too much noise in a regular build.



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 27/70] kbuild: allow to use GCC toolchain not in Clang search path
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (25 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 26/70] kbuild: set no-integrated-as before incl. arch Makefile Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 28/70] arm64: Disable asm-operand-width warning for clang Greg Kroah-Hartman
                   ` (48 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Stefan Agner, Masahiro Yamada,
	Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Stefan Agner <stefan@agner.ch>

commit ef8c4ed9db80261f397f0c0bf723684601ae3b52 upstream.

When using a GCC cross toolchain which is not in a compiled in
Clang search path, Clang reverts to the system assembler and
linker. This leads to assembler or linker errors, depending on
which tool is first used for a given architecture.

It seems that Clang is not searching $PATH for a matching
assembler or linker.

Make sure that Clang picks up the correct assembler or linker by
passing the cross compilers bin directory as search path.

This allows to use Clang provided by distributions with GCC
toolchains not in /usr/bin.

Link: https://github.com/ClangBuiltLinux/linux/issues/78
Signed-off-by: Stefan Agner <stefan@agner.ch>
Reviewed-and-tested-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
[nc: Adjust context]
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 Makefile |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

--- a/Makefile
+++ b/Makefile
@@ -610,13 +610,15 @@ all: vmlinux
 ifeq ($(cc-name),clang)
 ifneq ($(CROSS_COMPILE),)
 CLANG_TARGET	:= --target=$(notdir $(CROSS_COMPILE:%-=%))
-GCC_TOOLCHAIN	:= $(realpath $(dir $(shell which $(LD)))/..)
+GCC_TOOLCHAIN_DIR := $(dir $(shell which $(LD)))
+CLANG_PREFIX	:= --prefix=$(GCC_TOOLCHAIN_DIR)
+GCC_TOOLCHAIN	:= $(realpath $(GCC_TOOLCHAIN_DIR)/..)
 endif
 ifneq ($(GCC_TOOLCHAIN),)
 CLANG_GCC_TC	:= --gcc-toolchain=$(GCC_TOOLCHAIN)
 endif
-KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
-KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
+KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
+KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
 KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
 KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
 endif



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 28/70] arm64: Disable asm-operand-width warning for clang
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (26 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 27/70] kbuild: allow to use GCC toolchain not in Clang search path Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 29/70] x86/kbuild: Use cc-option to enable -falign-{jumps/loops} Greg Kroah-Hartman
                   ` (47 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Matthias Kaehlcke, Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Matthias Kaehlcke <mka@chromium.org>

clang raises 'asm-operand-widths' warnings in inline assembly code when
the size of an operand is < 64 bits and the operand width is unspecified.
Most warnings are raised in macros, i.e. the datatype of the operand may
vary.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>

nc: I trimmed the original commit message since I'm not a part of CrOS
    and can't speak on their behalf.

    To fix these warnings, it requires a fairly intrusive backport of
    the sysreg conversion that Mark Rutland did in 4.9. I think
    disabling the warning is smarter, similar to commit d41d0fe374d4
    ("turn off -Wattribute-alias") in this tree.

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/arm64/Makefile |    4 ++++
 1 file changed, 4 insertions(+)

--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -56,6 +56,10 @@ else
 TEXT_OFFSET := 0x00080000
 endif
 
+ifeq ($(cc-name),clang)
+KBUILD_CFLAGS += $(call cc-disable-warning, asm-operand-widths)
+endif
+
 # KASAN_SHADOW_OFFSET = VA_START + (1 << (VA_BITS - 3)) - (1 << 61)
 # in 32-bit arithmetic
 KASAN_SHADOW_OFFSET := $(shell printf "0x%08x00000000\n" $$(( \



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 29/70] x86/kbuild: Use cc-option to enable -falign-{jumps/loops}
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (27 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 28/70] arm64: Disable asm-operand-width warning for clang Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 30/70] crypto, x86: aesni - fix token pasting for clang Greg Kroah-Hartman
                   ` (46 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Matthias Kaehlcke, Greg Hackmann,
	Linus Torvalds, Masahiro Yamada, Michael Davidson,
	Peter Zijlstra, Thomas Gleixner, grundler, Ingo Molnar,
	Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Matthias Kaehlcke <mka@chromium.org>

commit 2c4fd1ac3ff167c91272dc43c7bfd2269ef61557 upstream.

clang currently does not support these optimizations, only enable them
when they are available.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Cc: Greg Hackmann <ghackmann@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Michael Davidson <md@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: grundler@chromium.org
Link: http://lkml.kernel.org/r/20170413172609.118122-1-mka@chromium.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/x86/Makefile |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -88,10 +88,10 @@ else
         KBUILD_CFLAGS += -m64
 
         # Align jump targets to 1 byte, not the default 16 bytes:
-        KBUILD_CFLAGS += -falign-jumps=1
+        KBUILD_CFLAGS += $(call cc-option,-falign-jumps=1)
 
         # Pack loops tightly as well:
-        KBUILD_CFLAGS += -falign-loops=1
+        KBUILD_CFLAGS += $(call cc-option,-falign-loops=1)
 
         # Don't autogenerate traditional x87 instructions
         KBUILD_CFLAGS += $(call cc-option,-mno-80387)



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 30/70] crypto, x86: aesni - fix token pasting for clang
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (28 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 29/70] x86/kbuild: Use cc-option to enable -falign-{jumps/loops} Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 31/70] x86/mm/kaslr: Use the _ASM_MUL macro for multiplication to work around Clang incompatibility Greg Kroah-Hartman
                   ` (45 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Michael Davidson, Herbert Xu,
	Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Michael Davidson <md@google.com>

commit fdb2726f4e61c5e3abc052f547d5a5f6c0dc5504 upstream.

aes_ctrby8_avx-x86_64.S uses the C preprocessor for token pasting
of character sequences that are not valid preprocessor tokens.
While this is allowed when preprocessing assembler files it exposes
an incompatibilty between the clang and gcc preprocessors where
clang does not strip leading white space from macro parameters,
leading to the CONCAT(%xmm, i) macro expansion on line 96 resulting
in a token with a space character embedded in it.

While this could be resolved by deleting the offending space character,
the assembler is perfectly capable of doing the token pasting correctly
for itself so we can just get rid of the preprocessor macros.

Signed-off-by: Michael Davidson <md@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/x86/crypto/aes_ctrby8_avx-x86_64.S |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

--- a/arch/x86/crypto/aes_ctrby8_avx-x86_64.S
+++ b/arch/x86/crypto/aes_ctrby8_avx-x86_64.S
@@ -65,7 +65,6 @@
 #include <linux/linkage.h>
 #include <asm/inst.h>
 
-#define CONCAT(a,b)	a##b
 #define VMOVDQ		vmovdqu
 
 #define xdata0		%xmm0
@@ -92,8 +91,6 @@
 #define num_bytes	%r8
 
 #define tmp		%r10
-#define	DDQ(i)		CONCAT(ddq_add_,i)
-#define	XMM(i)		CONCAT(%xmm, i)
 #define	DDQ_DATA	0
 #define	XDATA		1
 #define KEY_128		1
@@ -131,12 +128,12 @@ ddq_add_8:
 /* generate a unique variable for ddq_add_x */
 
 .macro setddq n
-	var_ddq_add = DDQ(\n)
+	var_ddq_add = ddq_add_\n
 .endm
 
 /* generate a unique variable for xmm register */
 .macro setxdata n
-	var_xdata = XMM(\n)
+	var_xdata = %xmm\n
 .endm
 
 /* club the numeric 'id' to the symbol 'name' */



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 31/70] x86/mm/kaslr: Use the _ASM_MUL macro for multiplication to work around Clang incompatibility
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (29 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 30/70] crypto, x86: aesni - fix token pasting for clang Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 32/70] kbuild: Add __cc-option macro Greg Kroah-Hartman
                   ` (44 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Matthias Kaehlcke, Grant Grundler,
	Greg Hackmann, Kees Cook, Linus Torvalds, Michael Davidson,
	Peter Zijlstra, Thomas Gleixner, Ingo Molnar, Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Matthias Kaehlcke <mka@chromium.org>

commit 121843eb02a6e2fa30aefab64bfe183c97230c75 upstream.

The constraint "rm" allows the compiler to put mix_const into memory.
When the input operand is a memory location then MUL needs an operand
size suffix, since Clang can't infer the multiplication width from the
operand.

Add and use the _ASM_MUL macro which determines the operand size and
resolves to the NUL instruction with the corresponding suffix.

This fixes the following error when building with clang:

  CC      arch/x86/lib/kaslr.o
  /tmp/kaslr-dfe1ad.s: Assembler messages:
  /tmp/kaslr-dfe1ad.s:182: Error: no instruction mnemonic suffix given and no register operands; can't size instruction

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Cc: Grant Grundler <grundler@chromium.org>
Cc: Greg Hackmann <ghackmann@google.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Michael Davidson <md@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20170501224741.133938-1-mka@chromium.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
[nc: Apply to aslr.c in get_random_long as the kaslr shift didn't happen
     until 4.8 in commit d899a7d146a2]
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/x86/boot/compressed/aslr.c |    3 ++-
 arch/x86/include/asm/asm.h      |    1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

--- a/arch/x86/boot/compressed/aslr.c
+++ b/arch/x86/boot/compressed/aslr.c
@@ -1,5 +1,6 @@
 #include "misc.h"
 
+#include <asm/asm.h>
 #include <asm/msr.h>
 #include <asm/archrandom.h>
 #include <asm/e820.h>
@@ -94,7 +95,7 @@ static unsigned long get_random_long(voi
 	}
 
 	/* Circular multiply for better bit diffusion */
-	asm("mul %3"
+	asm(_ASM_MUL "%3"
 	    : "=a" (random), "=d" (raw)
 	    : "a" (random), "rm" (mix_const));
 	random += raw;
--- a/arch/x86/include/asm/asm.h
+++ b/arch/x86/include/asm/asm.h
@@ -34,6 +34,7 @@
 #define _ASM_ADD	__ASM_SIZE(add)
 #define _ASM_SUB	__ASM_SIZE(sub)
 #define _ASM_XADD	__ASM_SIZE(xadd)
+#define _ASM_MUL	__ASM_SIZE(mul)
 
 #define _ASM_AX		__ASM_REG(ax)
 #define _ASM_BX		__ASM_REG(bx)



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 32/70] kbuild: Add __cc-option macro
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (30 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 31/70] x86/mm/kaslr: Use the _ASM_MUL macro for multiplication to work around Clang incompatibility Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 33/70] x86/build: Use __cc-option for boot code compiler options Greg Kroah-Hartman
                   ` (43 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Arnd Bergmann, Masahiro Yamada,
	Matthias Kaehlcke, Michal Marek, Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Matthias Kaehlcke <mka@chromium.org>

commit 9f3f1fd299768782465cb32cdf0dd4528d11f26b upstream.

cc-option uses KBUILD_CFLAGS and KBUILD_CPPFLAGS when it determines
whether an option is supported or not. This is fine for options used to
build the kernel itself, however some components like the x86 boot code
use a different set of flags.

Add the new macro __cc-option which is a more generic version of
cc-option with additional parameters. One parameter is the compiler
with which the check should be performed, the other the compiler options
to be used instead KBUILD_C*FLAGS.

Refactor cc-option and hostcc-option to use __cc-option and move
hostcc-option to scripts/Kbuild.include.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Michal Marek <mmarek@suse.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
[nc: Fix conflicts due to lack of CC_OPTION_CFLAGS and hostcc-option
     wasn't added until v4.8 so no point including it in this tree]
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 Makefile               |    2 +-
 scripts/Kbuild.include |    9 +++++++--
 2 files changed, 8 insertions(+), 3 deletions(-)

--- a/Makefile
+++ b/Makefile
@@ -303,7 +303,7 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH"
 
 HOSTCC       = gcc
 HOSTCXX      = g++
-HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
+HOSTCFLAGS   := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
 HOSTCXXFLAGS = -O2
 
 # Decide whether to build built-in, modular, or both.
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -108,11 +108,16 @@ as-option = $(call try-run,\
 as-instr = $(call try-run,\
 	printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
 
+# __cc-option
+# Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586)
+__cc-option = $(call try-run,\
+	$(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4))
+
 # cc-option
 # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
 
-cc-option = $(call try-run,\
-	$(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
+cc-option = $(call __cc-option, $(CC),\
+	$(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS),$(1),$(2))
 
 # cc-option-yn
 # Usage: flag := $(call cc-option-yn,-march=winchip-c6)



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 33/70] x86/build: Use __cc-option for boot code compiler options
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (31 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 32/70] kbuild: Add __cc-option macro Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 34/70] x86/build: Specify stack alignment for clang Greg Kroah-Hartman
                   ` (42 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Matthias Kaehlcke, Ingo Molnar,
	Masahiro Yamada, Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Matthias Kaehlcke <mka@chromium.org>

commit 032a2c4f65a2f81c93e161a11197ba19bc14a909 upstream.

cc-option is used to enable compiler options for the boot code if they
are available. The macro uses KBUILD_CFLAGS and KBUILD_CPPFLAGS for the
check, however these flags aren't used to build the boot code, in
consequence cc-option can yield wrong results. For example
-mpreferred-stack-boundary=2 is never set with a 64-bit compiler,
since the setting is only valid for 16 and 32-bit binaries. This
is also the case for 32-bit kernel builds, because the option -m32 is
added to KBUILD_CFLAGS after the assignment of REALMODE_CFLAGS.

Use __cc-option instead of cc-option for the boot mode options.
The macro receives the compiler options as parameter instead of using
KBUILD_C*FLAGS, for the boot code we pass REALMODE_CFLAGS.

Also use separate statements for the __cc-option checks instead
of performing them in the initial assignment of REALMODE_CFLAGS since
the variable is an input of the macro.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Acked-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/x86/Makefile |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -24,10 +24,11 @@ REALMODE_CFLAGS	:= $(M16_CFLAGS) -g -Os
 		   -DDISABLE_BRANCH_PROFILING \
 		   -Wall -Wstrict-prototypes -march=i386 -mregparm=3 \
 		   -fno-strict-aliasing -fomit-frame-pointer -fno-pic \
-		   -mno-mmx -mno-sse \
-		   $(call cc-option, -ffreestanding) \
-		   $(call cc-option, -fno-stack-protector) \
-		   $(call cc-option, -mpreferred-stack-boundary=2)
+		   -mno-mmx -mno-sse
+
+REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -ffreestanding)
+REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -fno-stack-protector)
+REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -mpreferred-stack-boundary=2)
 export REALMODE_CFLAGS
 
 # BITS is used as extension for files which are available in a 32 bit



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 34/70] x86/build: Specify stack alignment for clang
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (32 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 33/70] x86/build: Use __cc-option for boot code compiler options Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 35/70] x86/boot: #undef memcpy() et al in string.c Greg Kroah-Hartman
                   ` (41 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Matthias Kaehlcke, Ingo Molnar,
	Masahiro Yamada, Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Matthias Kaehlcke <mka@chromium.org>

commit d77698df39a512911586834d303275ea5fda74d0 upstream.

For gcc stack alignment is configured with -mpreferred-stack-boundary=N,
clang has the option -mstack-alignment=N for that purpose. Use the same
alignment as with gcc.

If the alignment is not specified clang assumes an alignment of
16 bytes, as required by the standard ABI. However as mentioned in
d9b0cde91c60 ("x86-64, gcc: Use -mpreferred-stack-boundary=3 if
supported") the standard kernel entry on x86-64 leaves the stack
on an 8-byte boundary, as a consequence clang will keep the stack
misaligned.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Acked-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/x86/Makefile |   26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -11,6 +11,14 @@ else
         KBUILD_DEFCONFIG := $(ARCH)_defconfig
 endif
 
+# For gcc stack alignment is specified with -mpreferred-stack-boundary,
+# clang has the option -mstack-alignment for that purpose.
+ifneq ($(call cc-option, -mpreferred-stack-boundary=4),)
+        cc_stack_align_opt := -mpreferred-stack-boundary
+else ifneq ($(call cc-option, -mstack-alignment=4),)
+        cc_stack_align_opt := -mstack-alignment
+endif
+
 # How to compile the 16-bit code.  Note we always compile for -march=i386;
 # that way we can complain to the user if the CPU is insufficient.
 #
@@ -28,7 +36,7 @@ REALMODE_CFLAGS	:= $(M16_CFLAGS) -g -Os
 
 REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -ffreestanding)
 REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -fno-stack-protector)
-REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -mpreferred-stack-boundary=2)
+REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), $(cc_stack_align_opt)=2)
 export REALMODE_CFLAGS
 
 # BITS is used as extension for files which are available in a 32 bit
@@ -65,8 +73,10 @@ ifeq ($(CONFIG_X86_32),y)
         # with nonstandard options
         KBUILD_CFLAGS += -fno-pic
 
-        # prevent gcc from keeping the stack 16 byte aligned
-        KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=2)
+        # Align the stack to the register width instead of using the default
+        # alignment of 16 bytes. This reduces stack usage and the number of
+        # alignment instructions.
+        KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align_opt)=2)
 
         # Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use
         # a lot more stack due to the lack of sharing of stacklots:
@@ -98,8 +108,14 @@ else
         KBUILD_CFLAGS += $(call cc-option,-mno-80387)
         KBUILD_CFLAGS += $(call cc-option,-mno-fp-ret-in-387)
 
-	# Use -mpreferred-stack-boundary=3 if supported.
-	KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=3)
+        # By default gcc and clang use a stack alignment of 16 bytes for x86.
+        # However the standard kernel entry on x86-64 leaves the stack on an
+        # 8-byte boundary. If the compiler isn't informed about the actual
+        # alignment it will generate extra alignment instructions for the
+        # default alignment which keep the stack *mis*aligned.
+        # Furthermore an alignment to the register width reduces stack usage
+        # and the number of alignment instructions.
+        KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align_opt)=3)
 
 	# Use -mskip-rax-setup if supported.
 	KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup)



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 35/70] x86/boot: #undef memcpy() et al in string.c
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (33 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 34/70] x86/build: Specify stack alignment for clang Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 36/70] x86/build: Fix stack alignment for CLang Greg Kroah-Hartman
                   ` (40 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Michael Davidson, Matthias Kaehlcke,
	H. Peter Anvin, Arnd Bergmann, Bernhard.Rosenkranzer,
	Greg Hackmann, Kees Cook, Linus Torvalds, Nick Desaulniers,
	Peter Zijlstra, Thomas Gleixner, Ingo Molnar, Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Michael Davidson <md@google.com>

commit 18d5e6c34a8eda438d5ad8b3b15f42dab01bf05d upstream.

undef memcpy() and friends in boot/string.c so that the functions
defined here will have the correct names, otherwise we end up
up trying to redefine __builtin_memcpy() etc.

Surprisingly, GCC allows this (and, helpfully, discards the
__builtin_ prefix from the function name when compiling it),
but clang does not.

Adding these #undef's appears to preserve what I assume was
the original intent of the code.

Signed-off-by: Michael Davidson <md@google.com>
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Acked-by: H. Peter Anvin <hpa@zytor.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Bernhard.Rosenkranzer@linaro.org
Cc: Greg Hackmann <ghackmann@google.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20170724235155.79255-1-mka@chromium.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/x86/boot/string.c |    9 +++++++++
 1 file changed, 9 insertions(+)

--- a/arch/x86/boot/string.c
+++ b/arch/x86/boot/string.c
@@ -16,6 +16,15 @@
 #include "ctype.h"
 #include "string.h"
 
+/*
+ * Undef these macros so that the functions that we provide
+ * here will have the correct names regardless of how string.h
+ * may have chosen to #define them.
+ */
+#undef memcpy
+#undef memset
+#undef memcmp
+
 int memcmp(const void *s1, const void *s2, size_t len)
 {
 	u8 diff;



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 36/70] x86/build: Fix stack alignment for CLang
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (34 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 35/70] x86/boot: #undef memcpy() et al in string.c Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 37/70] x86/build: Use cc-option to validate stack alignment parameter Greg Kroah-Hartman
                   ` (39 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Matthias Kaehlcke, Arnd Bergmann,
	Bernhard.Rosenkranzer, Greg Hackmann, Kees Cook, Linus Torvalds,
	Masahiro Yamada, Michael Davidson, Nick Desaulniers,
	Peter Zijlstra, Stephen Hines, Thomas Gleixner, dianders,
	Ingo Molnar, Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Matthias Kaehlcke <mka@chromium.org>

commit 8f91869766c00622b2eaa8ee567db4f333b78c1a upstream.

Commit:

  d77698df39a5 ("x86/build: Specify stack alignment for clang")

intended to use the same stack alignment for clang as with gcc.

The two compilers use different options to configure the stack alignment
(gcc: -mpreferred-stack-boundary=n, clang: -mstack-alignment=n).

The above commit assumes that the clang option uses the same parameter
type as gcc, i.e. that the alignment is specified as 2^n. However clang
interprets the value of this option literally to use an alignment of n,
in consequence the stack remains misaligned.

Change the values used with -mstack-alignment to be the actual alignment
instead of a power of two.

cc-option isn't used here with the typical pattern of KBUILD_CFLAGS +=
$(call cc-option ...). The reason is that older gcc versions don't
support the -mpreferred-stack-boundary option, since cc-option doesn't
verify whether the alternative option is valid it would incorrectly
select the clang option -mstack-alignment..

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Bernhard.Rosenkranzer@linaro.org
Cc: Greg Hackmann <ghackmann@google.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Michael Davidson <md@google.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephen Hines <srhines@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: dianders@chromium.org
Link: http://lkml.kernel.org/r/20170817004740.170588-1-mka@chromium.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/x86/Makefile |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -14,9 +14,11 @@ endif
 # For gcc stack alignment is specified with -mpreferred-stack-boundary,
 # clang has the option -mstack-alignment for that purpose.
 ifneq ($(call cc-option, -mpreferred-stack-boundary=4),)
-        cc_stack_align_opt := -mpreferred-stack-boundary
-else ifneq ($(call cc-option, -mstack-alignment=4),)
-        cc_stack_align_opt := -mstack-alignment
+      cc_stack_align4 := -mpreferred-stack-boundary=2
+      cc_stack_align8 := -mpreferred-stack-boundary=3
+else ifneq ($(call cc-option, -mstack-alignment=16),)
+      cc_stack_align4 := -mstack-alignment=4
+      cc_stack_align8 := -mstack-alignment=8
 endif
 
 # How to compile the 16-bit code.  Note we always compile for -march=i386;
@@ -36,7 +38,7 @@ REALMODE_CFLAGS	:= $(M16_CFLAGS) -g -Os
 
 REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -ffreestanding)
 REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -fno-stack-protector)
-REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), $(cc_stack_align_opt)=2)
+REALMODE_CFLAGS += $(cc_stack_align4)
 export REALMODE_CFLAGS
 
 # BITS is used as extension for files which are available in a 32 bit
@@ -76,7 +78,7 @@ ifeq ($(CONFIG_X86_32),y)
         # Align the stack to the register width instead of using the default
         # alignment of 16 bytes. This reduces stack usage and the number of
         # alignment instructions.
-        KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align_opt)=2)
+        KBUILD_CFLAGS += $(cc_stack_align4)
 
         # Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use
         # a lot more stack due to the lack of sharing of stacklots:
@@ -115,7 +117,7 @@ else
         # default alignment which keep the stack *mis*aligned.
         # Furthermore an alignment to the register width reduces stack usage
         # and the number of alignment instructions.
-        KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align_opt)=3)
+        KBUILD_CFLAGS += $(cc_stack_align8)
 
 	# Use -mskip-rax-setup if supported.
 	KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup)



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 37/70] x86/build: Use cc-option to validate stack alignment parameter
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (35 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 36/70] x86/build: Fix stack alignment for CLang Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 38/70] reiserfs: propagate errors from fill_with_dentries() properly Greg Kroah-Hartman
                   ` (38 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, kbuild test robot, Matthias Kaehlcke,
	Arnd Bergmann, Bernhard.Rosenkranzer, Greg Hackmann, Kees Cook,
	Linus Torvalds, Masahiro Yamada, Michael Davidson,
	Nick Desaulniers, Peter Zijlstra, Stephen Hines, Thomas Gleixner,
	dianders, Ingo Molnar, Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Matthias Kaehlcke <mka@chromium.org>

commit 9e8730b178a2472fca3123e909d6e69cc8127778 upstream.

With the following commit:

  8f91869766c0 ("x86/build: Fix stack alignment for CLang")

cc-option is only used to determine the name of the stack alignment option
supported by the compiler, but not to verify that the actual parameter
<option>=N is valid in combination with the other CFLAGS.

This causes problems (as reported by the kbuild robot) with older GCC versions
which only support stack alignment on a boundary of 16 bytes or higher.

Also use (__)cc_option to add the stack alignment option to CFLAGS to
make sure only valid options are added.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Bernhard.Rosenkranzer@linaro.org
Cc: Greg Hackmann <ghackmann@google.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Michael Davidson <md@google.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephen Hines <srhines@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: dianders@chromium.org
Fixes: 8f91869766c0 ("x86/build: Fix stack alignment for CLang")
Link: http://lkml.kernel.org/r/20170817182047.176752-1-mka@chromium.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/x86/Makefile |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -38,7 +38,7 @@ REALMODE_CFLAGS	:= $(M16_CFLAGS) -g -Os
 
 REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -ffreestanding)
 REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -fno-stack-protector)
-REALMODE_CFLAGS += $(cc_stack_align4)
+REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), $(cc_stack_align4))
 export REALMODE_CFLAGS
 
 # BITS is used as extension for files which are available in a 32 bit
@@ -78,7 +78,7 @@ ifeq ($(CONFIG_X86_32),y)
         # Align the stack to the register width instead of using the default
         # alignment of 16 bytes. This reduces stack usage and the number of
         # alignment instructions.
-        KBUILD_CFLAGS += $(cc_stack_align4)
+        KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align4))
 
         # Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use
         # a lot more stack due to the lack of sharing of stacklots:
@@ -117,7 +117,7 @@ else
         # default alignment which keep the stack *mis*aligned.
         # Furthermore an alignment to the register width reduces stack usage
         # and the number of alignment instructions.
-        KBUILD_CFLAGS += $(cc_stack_align8)
+        KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align8))
 
 	# Use -mskip-rax-setup if supported.
 	KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup)



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 38/70] reiserfs: propagate errors from fill_with_dentries() properly
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (36 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 37/70] x86/build: Use cc-option to validate stack alignment parameter Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 39/70] hfs: prevent btree data loss on root split Greg Kroah-Hartman
                   ` (37 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Jann Horn, Andrew Morton,
	Jeff Mahoney, Eric Biggers, Al Viro, Linus Torvalds, Sasha Levin

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

[ Upstream commit b10298d56c9623f9b173f19959732d3184b35f4f ]

fill_with_dentries() failed to propagate errors up to
reiserfs_for_each_xattr() properly.  Plumb them through.

Note that reiserfs_for_each_xattr() is only used by
reiserfs_delete_xattrs() and reiserfs_chown_xattrs().  The result of
reiserfs_delete_xattrs() is discarded anyway, the only difference there is
whether a warning is printed to dmesg.  The result of
reiserfs_chown_xattrs() does matter because it can block chowning of the
file to which the xattrs belong; but either way, the resulting state can
have misaligned ownership, so my patch doesn't improve things greatly.

Credit for making me look at this code goes to Al Viro, who pointed out
that the ->actor calling convention is suboptimal and should be changed.

Link: http://lkml.kernel.org/r/20180802163335.83312-1-jannh@google.com
Signed-off-by: Jann Horn <jannh@google.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Jeff Mahoney <jeffm@suse.com>
Cc: Eric Biggers <ebiggers@google.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/reiserfs/xattr.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index 8b32fdaad468..d424b3d4bf3b 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -184,6 +184,7 @@ struct reiserfs_dentry_buf {
 	struct dir_context ctx;
 	struct dentry *xadir;
 	int count;
+	int err;
 	struct dentry *dentries[8];
 };
 
@@ -206,6 +207,7 @@ fill_with_dentries(struct dir_context *ctx, const char *name, int namelen,
 
 	dentry = lookup_one_len(name, dbuf->xadir, namelen);
 	if (IS_ERR(dentry)) {
+		dbuf->err = PTR_ERR(dentry);
 		return PTR_ERR(dentry);
 	} else if (d_really_is_negative(dentry)) {
 		/* A directory entry exists, but no file? */
@@ -214,6 +216,7 @@ fill_with_dentries(struct dir_context *ctx, const char *name, int namelen,
 			       "not found for file %pd.\n",
 			       dentry, dbuf->xadir);
 		dput(dentry);
+		dbuf->err = -EIO;
 		return -EIO;
 	}
 
@@ -261,6 +264,10 @@ static int reiserfs_for_each_xattr(struct inode *inode,
 		err = reiserfs_readdir_inode(d_inode(dir), &buf.ctx);
 		if (err)
 			break;
+		if (buf.err) {
+			err = buf.err;
+			break;
+		}
 		if (!buf.count)
 			break;
 		for (i = 0; !err && i < buf.count && buf.dentries[i]; i++) {
-- 
2.17.1




^ permalink raw reply related	[flat|nested] 81+ messages in thread

* [PATCH 4.4 39/70] hfs: prevent btree data loss on root split
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (37 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 38/70] reiserfs: propagate errors from fill_with_dentries() properly Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 40/70] hfsplus: " Greg Kroah-Hartman
                   ` (36 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Ernesto A .  Fernández,
	Christoph Hellwig, Andrew Morton, Linus Torvalds, Sasha Levin

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

[ Upstream commit d057c036672f33d43a5f7344acbb08cf3a8a0c09 ]

This bug is triggered whenever hfs_brec_update_parent() needs to split
the root node.  The height of the btree is not increased, which leaves
the new node orphaned and its records lost.  It is not possible for this
to happen on a valid hfs filesystem because the index nodes have fixed
length keys.

For reasons I ignore, the hfs module does have support for a number of
hfsplus features.  A corrupt btree header may report variable length
keys and trigger this bug, so it's better to fix it.

Link: http://lkml.kernel.org/r/9750b1415685c4adca10766895f6d5ef12babdb0.1535682463.git.ernesto.mnd.fernandez@gmail.com
Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
Cc: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/hfs/brec.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/hfs/brec.c b/fs/hfs/brec.c
index 2a6f3c67cb3f..2e713673df42 100644
--- a/fs/hfs/brec.c
+++ b/fs/hfs/brec.c
@@ -424,6 +424,10 @@ skip:
 	if (new_node) {
 		__be32 cnid;
 
+		if (!new_node->parent) {
+			hfs_btree_inc_height(tree);
+			new_node->parent = tree->root;
+		}
 		fd->bnode = hfs_bnode_find(tree, new_node->parent);
 		/* create index key and entry */
 		hfs_bnode_read_key(new_node, fd->search_key, 14);
-- 
2.17.1




^ permalink raw reply related	[flat|nested] 81+ messages in thread

* [PATCH 4.4 40/70] hfsplus: prevent btree data loss on root split
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (38 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 39/70] hfs: prevent btree data loss on root split Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 41/70] um: Give start_idle_thread() a return code Greg Kroah-Hartman
                   ` (35 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Ernesto A .  Fernández,
	Christoph Hellwig, Andrew Morton, Linus Torvalds, Sasha Levin

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

[ Upstream commit 0a3021d4f5295aa073c7bf5c5e4de60a2e292578 ]

Creating, renaming or deleting a file may cause catalog corruption and
data loss.  This bug is randomly triggered by xfstests generic/027, but
here is a faster reproducer:

  truncate -s 50M fs.iso
  mkfs.hfsplus fs.iso
  mount fs.iso /mnt
  i=100
  while [ $i -le 150 ]; do
    touch /mnt/$i &>/dev/null
    ((++i))
  done
  i=100
  while [ $i -le 150 ]; do
    mv /mnt/$i /mnt/$(perl -e "print $i x82") &>/dev/null
    ((++i))
  done
  umount /mnt
  fsck.hfsplus -n fs.iso

The bug is triggered whenever hfs_brec_update_parent() needs to split the
root node.  The height of the btree is not increased, which leaves the new
node orphaned and its records lost.

Link: http://lkml.kernel.org/r/26d882184fc43043a810114258f45277752186c7.1535682461.git.ernesto.mnd.fernandez@gmail.com
Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
Cc: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/hfsplus/brec.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c
index 754fdf8c6356..1002a0c08319 100644
--- a/fs/hfsplus/brec.c
+++ b/fs/hfsplus/brec.c
@@ -427,6 +427,10 @@ skip:
 	if (new_node) {
 		__be32 cnid;
 
+		if (!new_node->parent) {
+			hfs_btree_inc_height(tree);
+			new_node->parent = tree->root;
+		}
 		fd->bnode = hfs_bnode_find(tree, new_node->parent);
 		/* create index key and entry */
 		hfs_bnode_read_key(new_node, fd->search_key, 14);
-- 
2.17.1




^ permalink raw reply related	[flat|nested] 81+ messages in thread

* [PATCH 4.4 41/70] um: Give start_idle_thread() a return code
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (39 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 40/70] hfsplus: " Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 42/70] fs/exofs: fix potential memory leak in mount option parsing Greg Kroah-Hartman
                   ` (34 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Richard Weinberger, Sasha Levin

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

[ Upstream commit 7ff1e34bbdc15acab823b1ee4240e94623d50ee8 ]

Fixes:
arch/um/os-Linux/skas/process.c:613:1: warning: control reaches end of
non-void function [-Wreturn-type]

longjmp() never returns but gcc still warns that the end of the function
can be reached.
Add a return code and debug aid to detect this impossible case.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/um/os-Linux/skas/process.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c
index b856c66ebd3a..6dbf27ffafc8 100644
--- a/arch/um/os-Linux/skas/process.c
+++ b/arch/um/os-Linux/skas/process.c
@@ -585,6 +585,11 @@ int start_idle_thread(void *stack, jmp_buf *switch_buf)
 		fatal_sigsegv();
 	}
 	longjmp(*switch_buf, 1);
+
+	/* unreachable */
+	printk(UM_KERN_ERR "impossible long jump!");
+	fatal_sigsegv();
+	return 0;
 }
 
 void initial_thread_cb_skas(void (*proc)(void *), void *arg)
-- 
2.17.1




^ permalink raw reply related	[flat|nested] 81+ messages in thread

* [PATCH 4.4 42/70] fs/exofs: fix potential memory leak in mount option parsing
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (40 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 41/70] um: Give start_idle_thread() a return code Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 43/70] clk: samsung: exynos5420: Enable PERIS clocks for suspend Greg Kroah-Hartman
                   ` (33 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Chengguang Xu, Al Viro, Sasha Levin

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

[ Upstream commit 515f1867addaba49c1c6ac73abfaffbc192c1db4 ]

There are some cases can cause memory leak when parsing
option 'osdname'.

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/exofs/super.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/exofs/super.c b/fs/exofs/super.c
index b795c567b5e1..360ba74e04e6 100644
--- a/fs/exofs/super.c
+++ b/fs/exofs/super.c
@@ -100,6 +100,7 @@ static int parse_options(char *options, struct exofs_mountopt *opts)
 		token = match_token(p, tokens, args);
 		switch (token) {
 		case Opt_name:
+			kfree(opts->dev_name);
 			opts->dev_name = match_strdup(&args[0]);
 			if (unlikely(!opts->dev_name)) {
 				EXOFS_ERR("Error allocating dev_name");
@@ -868,8 +869,10 @@ static struct dentry *exofs_mount(struct file_system_type *type,
 	int ret;
 
 	ret = parse_options(data, &opts);
-	if (ret)
+	if (ret) {
+		kfree(opts.dev_name);
 		return ERR_PTR(ret);
+	}
 
 	if (!opts.dev_name)
 		opts.dev_name = dev_name;
-- 
2.17.1




^ permalink raw reply related	[flat|nested] 81+ messages in thread

* [PATCH 4.4 43/70] clk: samsung: exynos5420: Enable PERIS clocks for suspend
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (41 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 42/70] fs/exofs: fix potential memory leak in mount option parsing Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:50 ` [PATCH 4.4 44/70] platform/x86: acerhdf: Add BIOS entry for Gateway LT31 v1.3307 Greg Kroah-Hartman
                   ` (32 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Joonyoung Shim, Marek Szyprowski,
	Sylwester Nawrocki, Sasha Levin

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

[ Upstream commit b33228029d842269e17bba591609e83ed422005d ]

Ensure that clocks for core SoC modules (including TZPC0..9 modules)
are enabled for suspend/resume cycle. This fixes suspend/resume
support on Exynos5422-based Odroid XU3/XU4 boards.

Suggested-by: Joonyoung Shim <jy0922.shim@samsung.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Sylwester Nawrocki <snawrocki@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/clk/samsung/clk-exynos5420.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/clk/samsung/clk-exynos5420.c b/drivers/clk/samsung/clk-exynos5420.c
index 389af3c15ec4..bde71b07f15e 100644
--- a/drivers/clk/samsung/clk-exynos5420.c
+++ b/drivers/clk/samsung/clk-exynos5420.c
@@ -273,6 +273,7 @@ static const struct samsung_clk_reg_dump exynos5420_set_clksrc[] = {
 	{ .offset = GATE_BUS_TOP,		.value = 0xffffffff, },
 	{ .offset = GATE_BUS_DISP1,		.value = 0xffffffff, },
 	{ .offset = GATE_IP_PERIC,		.value = 0xffffffff, },
+	{ .offset = GATE_IP_PERIS,		.value = 0xffffffff, },
 };
 
 static int exynos5420_clk_suspend(void)
-- 
2.17.1




^ permalink raw reply related	[flat|nested] 81+ messages in thread

* [PATCH 4.4 44/70] platform/x86: acerhdf: Add BIOS entry for Gateway LT31 v1.3307
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (42 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 43/70] clk: samsung: exynos5420: Enable PERIS clocks for suspend Greg Kroah-Hartman
@ 2018-11-26 10:50 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 45/70] arm64: percpu: Initialize ret in the default case Greg Kroah-Hartman
                   ` (31 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Peter Feuerer, Darren Hart,
	Andy Shevchenko, Paul Gortmaker, Andy Shevchenko, Sasha Levin

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

[ Upstream commit 684238d79ad85c5e19a71bb5818e77e329912fbc ]

To fix:

  acerhdf: unknown (unsupported) BIOS version Gateway  /LT31   /v1.3307 , please report, aborting!

As can be seen in the context, the BIOS registers haven't changed in
the previous versions, so the assumption is they won't have changed
in this last update for this somewhat older platform either.

Cc: Peter Feuerer <peter@piie.net>
Cc: Darren Hart <dvhart@infradead.org>
Cc: Andy Shevchenko <andy@infradead.org>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Peter Feuerer <peter@piie.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/platform/x86/acerhdf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index 460fa6708bfc..3c4b107aba78 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -233,6 +233,7 @@ static const struct bios_settings bios_tbl[] = {
 	{"Gateway", "LT31",   "v1.3201",  0x55, 0x58, {0x9e, 0x00}, 0},
 	{"Gateway", "LT31",   "v1.3302",  0x55, 0x58, {0x9e, 0x00}, 0},
 	{"Gateway", "LT31",   "v1.3303t", 0x55, 0x58, {0x9e, 0x00}, 0},
+	{"Gateway", "LT31",   "v1.3307",  0x55, 0x58, {0x9e, 0x00}, 0},
 	/* Packard Bell */
 	{"Packard Bell", "DOA150",  "v0.3104",  0x55, 0x58, {0x21, 0x00}, 0},
 	{"Packard Bell", "DOA150",  "v0.3105",  0x55, 0x58, {0x20, 0x00}, 0},
-- 
2.17.1




^ permalink raw reply related	[flat|nested] 81+ messages in thread

* [PATCH 4.4 45/70] arm64: percpu: Initialize ret in the default case
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (43 preceding siblings ...)
  2018-11-26 10:50 ` [PATCH 4.4 44/70] platform/x86: acerhdf: Add BIOS entry for Gateway LT31 v1.3307 Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 46/70] s390/vdso: add missing FORCE to build targets Greg Kroah-Hartman
                   ` (30 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Prasad Sodagudi, Nathan Chancellor,
	Nick Desaulniers, Dennis Zhou, Sasha Levin

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

[ Upstream commit b5bb425871186303e6936fa2581521bdd1964a58 ]

Clang warns that if the default case is taken, ret will be
uninitialized.

./arch/arm64/include/asm/percpu.h:196:2: warning: variable 'ret' is used
uninitialized whenever switch default is taken
[-Wsometimes-uninitialized]
        default:
        ^~~~~~~
./arch/arm64/include/asm/percpu.h:200:9: note: uninitialized use occurs
here
        return ret;
               ^~~
./arch/arm64/include/asm/percpu.h:157:19: note: initialize the variable
'ret' to silence this warning
        unsigned long ret, loop;
                         ^
                          = 0

This warning appears several times while building the erofs filesystem.
While it's not strictly wrong, the BUILD_BUG will prevent this from
becoming a true problem. Initialize ret to 0 in the default case right
before the BUILD_BUG to silence all of these warnings.

Reported-by: Prasad Sodagudi <psodagud@codeaurora.org>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Dennis Zhou <dennis@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/arm64/include/asm/percpu.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm64/include/asm/percpu.h b/arch/arm64/include/asm/percpu.h
index 8a336852eeba..aea904713d0f 100644
--- a/arch/arm64/include/asm/percpu.h
+++ b/arch/arm64/include/asm/percpu.h
@@ -84,6 +84,7 @@ static inline unsigned long __percpu_##op(void *ptr,			\
 		: [val] "Ir" (val));					\
 		break;							\
 	default:							\
+		ret = 0;						\
 		BUILD_BUG();						\
 	}								\
 									\
@@ -113,6 +114,7 @@ static inline unsigned long __percpu_read(void *ptr, int size)
 		ret = ACCESS_ONCE(*(u64 *)ptr);
 		break;
 	default:
+		ret = 0;
 		BUILD_BUG();
 	}
 
@@ -182,6 +184,7 @@ static inline unsigned long __percpu_xchg(void *ptr, unsigned long val,
 		: [val] "r" (val));
 		break;
 	default:
+		ret = 0;
 		BUILD_BUG();
 	}
 
-- 
2.17.1




^ permalink raw reply related	[flat|nested] 81+ messages in thread

* [PATCH 4.4 46/70] s390/vdso: add missing FORCE to build targets
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (44 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 45/70] arm64: percpu: Initialize ret in the default case Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 47/70] netfilter: ipset: actually allow allowable CIDR 0 in hash:net,port,net Greg Kroah-Hartman
                   ` (29 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Philipp Rudo, Vasily Gorbik,
	Martin Schwidefsky, Sasha Levin

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

[ Upstream commit b44b136a3773d8a9c7853f8df716bd1483613cbb ]

According to Documentation/kbuild/makefiles.txt all build targets using
if_changed should use FORCE as well. Add missing FORCE to make sure
vdso targets are rebuild properly when not just immediate prerequisites
have changed but also when build command differs.

Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/s390/kernel/vdso32/Makefile | 6 +++---
 arch/s390/kernel/vdso64/Makefile | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/s390/kernel/vdso32/Makefile b/arch/s390/kernel/vdso32/Makefile
index ee8a18e50a25..29b72c46284d 100644
--- a/arch/s390/kernel/vdso32/Makefile
+++ b/arch/s390/kernel/vdso32/Makefile
@@ -29,7 +29,7 @@ GCOV_PROFILE := n
 $(obj)/vdso32_wrapper.o : $(obj)/vdso32.so
 
 # link rule for the .so file, .lds has to be first
-$(obj)/vdso32.so.dbg: $(src)/vdso32.lds $(obj-vdso32)
+$(obj)/vdso32.so.dbg: $(src)/vdso32.lds $(obj-vdso32) FORCE
 	$(call if_changed,vdso32ld)
 
 # strip rule for the .so file
@@ -38,12 +38,12 @@ $(obj)/%.so: $(obj)/%.so.dbg FORCE
 	$(call if_changed,objcopy)
 
 # assembly rules for the .S files
-$(obj-vdso32): %.o: %.S
+$(obj-vdso32): %.o: %.S FORCE
 	$(call if_changed_dep,vdso32as)
 
 # actual build commands
 quiet_cmd_vdso32ld = VDSO32L $@
-      cmd_vdso32ld = $(CC) $(c_flags) -Wl,-T $^ -o $@
+      cmd_vdso32ld = $(CC) $(c_flags) -Wl,-T $(filter %.lds %.o,$^) -o $@
 quiet_cmd_vdso32as = VDSO32A $@
       cmd_vdso32as = $(CC) $(a_flags) -c -o $@ $<
 
diff --git a/arch/s390/kernel/vdso64/Makefile b/arch/s390/kernel/vdso64/Makefile
index c4b03f9ed228..1b083d80de50 100644
--- a/arch/s390/kernel/vdso64/Makefile
+++ b/arch/s390/kernel/vdso64/Makefile
@@ -29,7 +29,7 @@ GCOV_PROFILE := n
 $(obj)/vdso64_wrapper.o : $(obj)/vdso64.so
 
 # link rule for the .so file, .lds has to be first
-$(obj)/vdso64.so.dbg: $(src)/vdso64.lds $(obj-vdso64)
+$(obj)/vdso64.so.dbg: $(src)/vdso64.lds $(obj-vdso64) FORCE
 	$(call if_changed,vdso64ld)
 
 # strip rule for the .so file
@@ -38,12 +38,12 @@ $(obj)/%.so: $(obj)/%.so.dbg FORCE
 	$(call if_changed,objcopy)
 
 # assembly rules for the .S files
-$(obj-vdso64): %.o: %.S
+$(obj-vdso64): %.o: %.S FORCE
 	$(call if_changed_dep,vdso64as)
 
 # actual build commands
 quiet_cmd_vdso64ld = VDSO64L $@
-      cmd_vdso64ld = $(CC) $(c_flags) -Wl,-T $^ -o $@
+      cmd_vdso64ld = $(CC) $(c_flags) -Wl,-T $(filter %.lds %.o,$^) -o $@
 quiet_cmd_vdso64as = VDSO64A $@
       cmd_vdso64as = $(CC) $(a_flags) -c -o $@ $<
 
-- 
2.17.1




^ permalink raw reply related	[flat|nested] 81+ messages in thread

* [PATCH 4.4 47/70] netfilter: ipset: actually allow allowable CIDR 0 in hash:net,port,net
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (45 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 46/70] s390/vdso: add missing FORCE to build targets Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 48/70] s390/mm: Fix ERROR: "__node_distance" undefined! Greg Kroah-Hartman
                   ` (28 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Eric Westbrook, Jozsef Kadlecsik,
	Pablo Neira Ayuso, Sasha Levin

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

[ Upstream commit 886503f34d63e681662057448819edb5b1057a97 ]

Allow /0 as advertised for hash:net,port,net sets.

For "hash:net,port,net", ipset(8) says that "either subnet
is permitted to be a /0 should you wish to match port
between all destinations."

Make that statement true.

Before:

    # ipset create cidrzero hash:net,port,net
    # ipset add cidrzero 0.0.0.0/0,12345,0.0.0.0/0
    ipset v6.34: The value of the CIDR parameter of the IP address is invalid

    # ipset create cidrzero6 hash:net,port,net family inet6
    # ipset add cidrzero6 ::/0,12345,::/0
    ipset v6.34: The value of the CIDR parameter of the IP address is invalid

After:

    # ipset create cidrzero hash:net,port,net
    # ipset add cidrzero 0.0.0.0/0,12345,0.0.0.0/0
    # ipset test cidrzero 192.168.205.129,12345,172.16.205.129
    192.168.205.129,tcp:12345,172.16.205.129 is in set cidrzero.

    # ipset create cidrzero6 hash:net,port,net family inet6
    # ipset add cidrzero6 ::/0,12345,::/0
    # ipset test cidrzero6 fe80::1,12345,ff00::1
    fe80::1,tcp:12345,ff00::1 is in set cidrzero6.

See also:

  https://bugzilla.kernel.org/show_bug.cgi?id=200897
  https://github.com/ewestbrook/linux/commit/df7ff6efb0934ab6acc11f003ff1a7580d6c1d9c

Signed-off-by: Eric Westbrook <linux@westbrook.io>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/netfilter/ipset/ip_set_hash_netportnet.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/netfilter/ipset/ip_set_hash_netportnet.c b/net/netfilter/ipset/ip_set_hash_netportnet.c
index 9a14c237830f..b259a5814965 100644
--- a/net/netfilter/ipset/ip_set_hash_netportnet.c
+++ b/net/netfilter/ipset/ip_set_hash_netportnet.c
@@ -213,13 +213,13 @@ hash_netportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
 
 	if (tb[IPSET_ATTR_CIDR]) {
 		e.cidr[0] = nla_get_u8(tb[IPSET_ATTR_CIDR]);
-		if (!e.cidr[0] || e.cidr[0] > HOST_MASK)
+		if (e.cidr[0] > HOST_MASK)
 			return -IPSET_ERR_INVALID_CIDR;
 	}
 
 	if (tb[IPSET_ATTR_CIDR2]) {
 		e.cidr[1] = nla_get_u8(tb[IPSET_ATTR_CIDR2]);
-		if (!e.cidr[1] || e.cidr[1] > HOST_MASK)
+		if (e.cidr[1] > HOST_MASK)
 			return -IPSET_ERR_INVALID_CIDR;
 	}
 
@@ -492,13 +492,13 @@ hash_netportnet6_uadt(struct ip_set *set, struct nlattr *tb[],
 
 	if (tb[IPSET_ATTR_CIDR]) {
 		e.cidr[0] = nla_get_u8(tb[IPSET_ATTR_CIDR]);
-		if (!e.cidr[0] || e.cidr[0] > HOST_MASK)
+		if (e.cidr[0] > HOST_MASK)
 			return -IPSET_ERR_INVALID_CIDR;
 	}
 
 	if (tb[IPSET_ATTR_CIDR2]) {
 		e.cidr[1] = nla_get_u8(tb[IPSET_ATTR_CIDR2]);
-		if (!e.cidr[1] || e.cidr[1] > HOST_MASK)
+		if (e.cidr[1] > HOST_MASK)
 			return -IPSET_ERR_INVALID_CIDR;
 	}
 
-- 
2.17.1




^ permalink raw reply related	[flat|nested] 81+ messages in thread

* [PATCH 4.4 48/70] s390/mm: Fix ERROR: "__node_distance" undefined!
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (46 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 47/70] netfilter: ipset: actually allow allowable CIDR 0 in hash:net,port,net Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 49/70] netfilter: ipset: Correct rcu_dereference() call in ip_set_put_comment() Greg Kroah-Hartman
                   ` (27 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Justin M. Forbes, Heiko Carstens,
	Martin Schwidefsky, Sasha Levin

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

[ Upstream commit a541f0ebcc08ed8bc0cc492eec9a86cb280a9f24 ]

Fixes:
ERROR: "__node_distance" [drivers/nvme/host/nvme-core.ko] undefined!
make[1]: *** [scripts/Makefile.modpost:92: __modpost] Error 1
make: *** [Makefile:1275: modules] Error 2
+ exit 1

Signed-off-by: Justin M. Forbes <jforbes@fedoraproject.org>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/s390/numa/numa.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/s390/numa/numa.c b/arch/s390/numa/numa.c
index 43f32ce60aa3..734f56d774bb 100644
--- a/arch/s390/numa/numa.c
+++ b/arch/s390/numa/numa.c
@@ -47,6 +47,7 @@ int __node_distance(int a, int b)
 {
 	return mode->distance ? mode->distance(a, b) : 0;
 }
+EXPORT_SYMBOL(__node_distance);
 
 int numa_debug_enabled;
 
-- 
2.17.1




^ permalink raw reply related	[flat|nested] 81+ messages in thread

* [PATCH 4.4 49/70] netfilter: ipset: Correct rcu_dereference() call in ip_set_put_comment()
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (47 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 48/70] s390/mm: Fix ERROR: "__node_distance" undefined! Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 50/70] netfilter: xt_IDLETIMER: add sysfs filename checking routine Greg Kroah-Hartman
                   ` (26 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Jozsef Kadlecsik, Pablo Neira Ayuso,
	Sasha Levin

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

[ Upstream commit 17b8b74c0f8dbf9b9e3301f9ca5b65dd1c079951 ]

The function is called when rcu_read_lock() is held and not
when rcu_read_lock_bh() is held.

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/linux/netfilter/ipset/ip_set_comment.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/netfilter/ipset/ip_set_comment.h b/include/linux/netfilter/ipset/ip_set_comment.h
index 8d0248525957..9f34204978e4 100644
--- a/include/linux/netfilter/ipset/ip_set_comment.h
+++ b/include/linux/netfilter/ipset/ip_set_comment.h
@@ -41,11 +41,11 @@ ip_set_init_comment(struct ip_set_comment *comment,
 	rcu_assign_pointer(comment->c, c);
 }
 
-/* Used only when dumping a set, protected by rcu_read_lock_bh() */
+/* Used only when dumping a set, protected by rcu_read_lock() */
 static inline int
 ip_set_put_comment(struct sk_buff *skb, struct ip_set_comment *comment)
 {
-	struct ip_set_comment_rcu *c = rcu_dereference_bh(comment->c);
+	struct ip_set_comment_rcu *c = rcu_dereference(comment->c);
 
 	if (!c)
 		return 0;
-- 
2.17.1




^ permalink raw reply related	[flat|nested] 81+ messages in thread

* [PATCH 4.4 50/70] netfilter: xt_IDLETIMER: add sysfs filename checking routine
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (48 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 49/70] netfilter: ipset: Correct rcu_dereference() call in ip_set_put_comment() Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 51/70] hwmon: (ibmpowernv) Remove bogus __init annotations Greg Kroah-Hartman
                   ` (25 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Taehee Yoo, Pablo Neira Ayuso, Sasha Levin

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

[ Upstream commit 54451f60c8fa061af9051a53be9786393947367c ]

When IDLETIMER rule is added, sysfs file is created under
/sys/class/xt_idletimer/timers/
But some label name shouldn't be used.
".", "..", "power", "uevent", "subsystem", etc...
So that sysfs filename checking routine is needed.

test commands:
   %iptables -I INPUT -j IDLETIMER --timeout 1 --label "power"

splat looks like:
[95765.423132] sysfs: cannot create duplicate filename '/devices/virtual/xt_idletimer/timers/power'
[95765.433418] CPU: 0 PID: 8446 Comm: iptables Not tainted 4.19.0-rc6+ #20
[95765.449755] Call Trace:
[95765.449755]  dump_stack+0xc9/0x16b
[95765.449755]  ? show_regs_print_info+0x5/0x5
[95765.449755]  sysfs_warn_dup+0x74/0x90
[95765.449755]  sysfs_add_file_mode_ns+0x352/0x500
[95765.449755]  sysfs_create_file_ns+0x179/0x270
[95765.449755]  ? sysfs_add_file_mode_ns+0x500/0x500
[95765.449755]  ? idletimer_tg_checkentry+0x3e5/0xb1b [xt_IDLETIMER]
[95765.449755]  ? rcu_read_lock_sched_held+0x114/0x130
[95765.449755]  ? __kmalloc_track_caller+0x211/0x2b0
[95765.449755]  ? memcpy+0x34/0x50
[95765.449755]  idletimer_tg_checkentry+0x4e2/0xb1b [xt_IDLETIMER]
[ ... ]

Fixes: 0902b469bd25 ("netfilter: xtables: idletimer target implementation")
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/netfilter/xt_IDLETIMER.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/net/netfilter/xt_IDLETIMER.c b/net/netfilter/xt_IDLETIMER.c
index 1718f536689f..8a1d2af3eed0 100644
--- a/net/netfilter/xt_IDLETIMER.c
+++ b/net/netfilter/xt_IDLETIMER.c
@@ -116,6 +116,22 @@ static void idletimer_tg_expired(unsigned long data)
 	schedule_work(&timer->work);
 }
 
+static int idletimer_check_sysfs_name(const char *name, unsigned int size)
+{
+	int ret;
+
+	ret = xt_check_proc_name(name, size);
+	if (ret < 0)
+		return ret;
+
+	if (!strcmp(name, "power") ||
+	    !strcmp(name, "subsystem") ||
+	    !strcmp(name, "uevent"))
+		return -EINVAL;
+
+	return 0;
+}
+
 static int idletimer_tg_create(struct idletimer_tg_info *info)
 {
 	int ret;
@@ -126,6 +142,10 @@ static int idletimer_tg_create(struct idletimer_tg_info *info)
 		goto out;
 	}
 
+	ret = idletimer_check_sysfs_name(info->label, sizeof(info->label));
+	if (ret < 0)
+		goto out_free_timer;
+
 	sysfs_attr_init(&info->timer->attr.attr);
 	info->timer->attr.attr.name = kstrdup(info->label, GFP_KERNEL);
 	if (!info->timer->attr.attr.name) {
-- 
2.17.1




^ permalink raw reply related	[flat|nested] 81+ messages in thread

* [PATCH 4.4 51/70] hwmon: (ibmpowernv) Remove bogus __init annotations
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (49 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 50/70] netfilter: xt_IDLETIMER: add sysfs filename checking routine Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 52/70] lib/raid6: Fix arm64 test build Greg Kroah-Hartman
                   ` (24 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Geert Uytterhoeven, Guenter Roeck,
	Sasha Levin

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

[ Upstream commit e3e61f01d755188cb6c2dcf5a244b9c0937c258e ]

If gcc decides not to inline make_sensor_label():

    WARNING: vmlinux.o(.text+0x4df549c): Section mismatch in reference from the function .create_device_attrs() to the function .init.text:.make_sensor_label()
    The function .create_device_attrs() references
    the function __init .make_sensor_label().
    This is often because .create_device_attrs lacks a __init
    annotation or the annotation of .make_sensor_label is wrong.

As .probe() can be called after freeing of __init memory, all __init
annotiations in the driver are bogus, and should be removed.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/hwmon/ibmpowernv.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/hwmon/ibmpowernv.c b/drivers/hwmon/ibmpowernv.c
index 55b5a8ff1cfe..ca3aa28977bc 100644
--- a/drivers/hwmon/ibmpowernv.c
+++ b/drivers/hwmon/ibmpowernv.c
@@ -114,7 +114,7 @@ static ssize_t show_label(struct device *dev, struct device_attribute *devattr,
 	return sprintf(buf, "%s\n", sdata->label);
 }
 
-static int __init get_logical_cpu(int hwcpu)
+static int get_logical_cpu(int hwcpu)
 {
 	int cpu;
 
@@ -125,9 +125,8 @@ static int __init get_logical_cpu(int hwcpu)
 	return -ENOENT;
 }
 
-static void __init make_sensor_label(struct device_node *np,
-				     struct sensor_data *sdata,
-				     const char *label)
+static void make_sensor_label(struct device_node *np,
+			      struct sensor_data *sdata, const char *label)
 {
 	u32 id;
 	size_t n;
-- 
2.17.1




^ permalink raw reply related	[flat|nested] 81+ messages in thread

* [PATCH 4.4 52/70] lib/raid6: Fix arm64 test build
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (50 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 51/70] hwmon: (ibmpowernv) Remove bogus __init annotations Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 53/70] i2c: omap: Enable for ARCH_K3 Greg Kroah-Hartman
                   ` (23 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Ard Biesheuvel, Jeremy Linton,
	Catalin Marinas, Sasha Levin

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

[ Upstream commit 313a06e636808387822af24c507cba92703568b1 ]

The lib/raid6/test fails to build the neon objects
on arm64 because the correct machine type is 'aarch64'.

Once this is correctly enabled, the neon recovery objects
need to be added to the build.

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 lib/raid6/test/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/raid6/test/Makefile b/lib/raid6/test/Makefile
index 29090f3db677..28c089cb13f1 100644
--- a/lib/raid6/test/Makefile
+++ b/lib/raid6/test/Makefile
@@ -26,7 +26,7 @@ ifeq ($(ARCH),arm)
         CFLAGS += -I../../../arch/arm/include -mfpu=neon
         HAS_NEON = yes
 endif
-ifeq ($(ARCH),arm64)
+ifeq ($(ARCH),aarch64)
         CFLAGS += -I../../../arch/arm64/include
         HAS_NEON = yes
 endif
@@ -37,7 +37,7 @@ ifeq ($(IS_X86),yes)
                     gcc -c -x assembler - >&/dev/null &&	\
                     rm ./-.o && echo -DCONFIG_AS_AVX2=1)
 else ifeq ($(HAS_NEON),yes)
-        OBJS   += neon.o neon1.o neon2.o neon4.o neon8.o
+        OBJS   += neon.o neon1.o neon2.o neon4.o neon8.o recov_neon.o recov_neon_inner.o
         CFLAGS += -DCONFIG_KERNEL_MODE_NEON=1
 else
         HAS_ALTIVEC := $(shell printf '\#include <altivec.h>\nvector int a;\n' |\
-- 
2.17.1




^ permalink raw reply related	[flat|nested] 81+ messages in thread

* [PATCH 4.4 53/70] i2c: omap: Enable for ARCH_K3
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (51 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 52/70] lib/raid6: Fix arm64 test build Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 54/70] zram: close udev startup race condition as default groups Greg Kroah-Hartman
                   ` (22 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Vignesh R, Grygorii Strashko,
	Wolfram Sang, Sasha Levin

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

[ Upstream commit 5b277402deac0691226a947df71c581686bd4020 ]

Allow I2C_OMAP to be built for K3 platforms.

Signed-off-by: Vignesh R <vigneshr@ti.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/i2c/busses/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 7b0aa82ea38b..b6a692677eea 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -702,7 +702,7 @@ config I2C_OCORES
 
 config I2C_OMAP
 	tristate "OMAP I2C adapter"
-	depends on ARCH_OMAP
+	depends on ARCH_OMAP || ARCH_K3
 	default y if MACH_OMAP_H3 || MACH_OMAP_OSK
 	help
 	  If you say yes to this option, support will be included for the
-- 
2.17.1




^ permalink raw reply related	[flat|nested] 81+ messages in thread

* [PATCH 4.4 54/70] zram: close udev startup race condition as default groups
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (52 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 53/70] i2c: omap: Enable for ARCH_K3 Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 55/70] SUNRPC: drop pointless static qualifier in xdr_get_next_encode_buffer() Greg Kroah-Hartman
                   ` (21 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Sergey Senozhatsky, Hannes Reinecke,
	Howard Chen, Minchan Kim, Sasha Levin

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

commit fef912bf860e upstream.
commit 98af4d4df889 upstream.

I got a report from Howard Chen that he saw zram and sysfs race(ie,
zram block device file is created but sysfs for it isn't yet)
when he tried to create new zram devices via hotadd knob.

v4.20 kernel fixes it by [1, 2] but it's too large size to merge
into -stable so this patch fixes the problem by registering defualt
group by Greg KH's approach[3].

This patch should be applied to every stable tree [3.16+] currently
existing from kernel.org because the problem was introduced at 2.6.37
by [4].

[1] fef912bf860e, block: genhd: add 'groups' argument to device_add_disk
[2] 98af4d4df889, zram: register default groups with device_add_disk()
[3] http://kroah.com/log/blog/2013/06/26/how-to-create-a-sysfs-file-correctly/
[4] 33863c21e69e9, Staging: zram: Replace ioctls with sysfs interface

Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Hannes Reinecke <hare@suse.com>
Tested-by: Howard Chen <howardsoc@google.com>
Signed-off-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/block/zram/zram_drv.c | 26 ++++++--------------------
 1 file changed, 6 insertions(+), 20 deletions(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 502406c9e6e1..616ee4f9c233 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1184,6 +1184,11 @@ static struct attribute_group zram_disk_attr_group = {
 	.attrs = zram_disk_attrs,
 };
 
+static const struct attribute_group *zram_disk_attr_groups[] = {
+	&zram_disk_attr_group,
+	NULL,
+};
+
 /*
  * Allocate and initialize new zram device. the function returns
  * '>= 0' device_id upon success, and negative value otherwise.
@@ -1264,15 +1269,9 @@ static int zram_add(void)
 		zram->disk->queue->limits.discard_zeroes_data = 0;
 	queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, zram->disk->queue);
 
+	disk_to_dev(zram->disk)->groups = zram_disk_attr_groups;
 	add_disk(zram->disk);
 
-	ret = sysfs_create_group(&disk_to_dev(zram->disk)->kobj,
-				&zram_disk_attr_group);
-	if (ret < 0) {
-		pr_err("Error creating sysfs group for device %d\n",
-				device_id);
-		goto out_free_disk;
-	}
 	strlcpy(zram->compressor, default_compressor, sizeof(zram->compressor));
 	zram->meta = NULL;
 	zram->max_comp_streams = 1;
@@ -1280,9 +1279,6 @@ static int zram_add(void)
 	pr_info("Added device: %s\n", zram->disk->disk_name);
 	return device_id;
 
-out_free_disk:
-	del_gendisk(zram->disk);
-	put_disk(zram->disk);
 out_free_queue:
 	blk_cleanup_queue(queue);
 out_free_idr:
@@ -1310,16 +1306,6 @@ static int zram_remove(struct zram *zram)
 	zram->claim = true;
 	mutex_unlock(&bdev->bd_mutex);
 
-	/*
-	 * Remove sysfs first, so no one will perform a disksize
-	 * store while we destroy the devices. This also helps during
-	 * hot_remove -- zram_reset_device() is the last holder of
-	 * ->init_lock, no later/concurrent disksize_store() or any
-	 * other sysfs handlers are possible.
-	 */
-	sysfs_remove_group(&disk_to_dev(zram->disk)->kobj,
-			&zram_disk_attr_group);
-
 	/* Make sure all the pending I/O are finished */
 	fsync_bdev(bdev);
 	zram_reset_device(zram);
-- 
2.17.1




^ permalink raw reply related	[flat|nested] 81+ messages in thread

* [PATCH 4.4 55/70] SUNRPC: drop pointless static qualifier in xdr_get_next_encode_buffer()
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (53 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 54/70] zram: close udev startup race condition as default groups Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 56/70] gfs2: Put bitmap buffers in put_super Greg Kroah-Hartman
                   ` (20 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, YueHaibing, J. Bruce Fields, Sasha Levin

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

[ Upstream commit 025911a5f4e36955498ed50806ad1b02f0f76288 ]

There is no need to have the '__be32 *p' variable static since new value
always be assigned before use it.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Cc: stable@vger.kernel.org
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/sunrpc/xdr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index 9b8d855e4a87..ed9bbd383f7d 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -512,7 +512,7 @@ EXPORT_SYMBOL_GPL(xdr_commit_encode);
 static __be32 *xdr_get_next_encode_buffer(struct xdr_stream *xdr,
 		size_t nbytes)
 {
-	static __be32 *p;
+	__be32 *p;
 	int space_left;
 	int frag1bytes, frag2bytes;
 
-- 
2.17.1




^ permalink raw reply related	[flat|nested] 81+ messages in thread

* [PATCH 4.4 56/70] gfs2: Put bitmap buffers in put_super
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (54 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 55/70] SUNRPC: drop pointless static qualifier in xdr_get_next_encode_buffer() Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 57/70] btrfs: fix pinned underflow after transaction aborted Greg Kroah-Hartman
                   ` (19 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Andreas Gruenbacher, Sasha Levin

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

commit 10283ea525d30f2e99828978fd04d8427876a7ad upstream.

gfs2_put_super calls gfs2_clear_rgrpd to destroy the gfs2_rgrpd objects
attached to the resource group glocks.  That function should release the
buffers attached to the gfs2_bitmap objects (bi_bh), but the call to
gfs2_rgrp_brelse for doing that is missing.

When gfs2_releasepage later runs across these buffers which are still
referenced, it refuses to free them.  This causes the pages the buffers
are attached to to remain referenced as well.  With enough mount/unmount
cycles, the system will eventually run out of memory.

Fix this by adding the missing call to gfs2_rgrp_brelse in
gfs2_clear_rgrpd.

(Also fix a gfs2_rgrp_relse -> gfs2_rgrp_brelse typo in a comment.)

Fixes: 39b0f1e92908 ("GFS2: Don't brelse rgrp buffer_heads every allocation")
Cc: stable@vger.kernel.org # v4.4
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/gfs2/rgrp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index c134c0462cee..ef24894edecc 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -732,6 +732,7 @@ void gfs2_clear_rgrpd(struct gfs2_sbd *sdp)
 			spin_lock(&gl->gl_lockref.lock);
 			gl->gl_object = NULL;
 			spin_unlock(&gl->gl_lockref.lock);
+			gfs2_rgrp_brelse(rgd);
 			gfs2_glock_add_to_lru(gl);
 			gfs2_glock_put(gl);
 		}
@@ -1139,7 +1140,7 @@ static u32 count_unlinked(struct gfs2_rgrpd *rgd)
  * @rgd: the struct gfs2_rgrpd describing the RG to read in
  *
  * Read in all of a Resource Group's header and bitmap blocks.
- * Caller must eventually call gfs2_rgrp_relse() to free the bitmaps.
+ * Caller must eventually call gfs2_rgrp_brelse() to free the bitmaps.
  *
  * Returns: errno
  */
-- 
2.17.1




^ permalink raw reply related	[flat|nested] 81+ messages in thread

* [PATCH 4.4 57/70] btrfs: fix pinned underflow after transaction aborted
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (55 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 56/70] gfs2: Put bitmap buffers in put_super Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 58/70] Revert "media: videobuf2-core: dont call memop finish when queueing" Greg Kroah-Hartman
                   ` (18 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Josef Bacik, Lu Fengqi, David Sterba,
	Sasha Levin

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

commit fcd5e74288f7d36991b1f0fb96b8c57079645e38 upstream.

When running generic/475, we may get the following warning in dmesg:

[ 6902.102154] WARNING: CPU: 3 PID: 18013 at fs/btrfs/extent-tree.c:9776 btrfs_free_block_groups+0x2af/0x3b0 [btrfs]
[ 6902.109160] CPU: 3 PID: 18013 Comm: umount Tainted: G        W  O      4.19.0-rc8+ #8
[ 6902.110971] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015
[ 6902.112857] RIP: 0010:btrfs_free_block_groups+0x2af/0x3b0 [btrfs]
[ 6902.118921] RSP: 0018:ffffc9000459bdb0 EFLAGS: 00010286
[ 6902.120315] RAX: ffff880175050bb0 RBX: ffff8801124a8000 RCX: 0000000000170007
[ 6902.121969] RDX: 0000000000000002 RSI: 0000000000170007 RDI: ffffffff8125fb74
[ 6902.123716] RBP: ffff880175055d10 R08: 0000000000000000 R09: 0000000000000000
[ 6902.125417] R10: 0000000000000000 R11: 0000000000000000 R12: ffff880175055d88
[ 6902.127129] R13: ffff880175050bb0 R14: 0000000000000000 R15: dead000000000100
[ 6902.129060] FS:  00007f4507223780(0000) GS:ffff88017ba00000(0000) knlGS:0000000000000000
[ 6902.130996] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 6902.132558] CR2: 00005623599cac78 CR3: 000000014b700001 CR4: 00000000003606e0
[ 6902.134270] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 6902.135981] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[ 6902.137836] Call Trace:
[ 6902.138939]  close_ctree+0x171/0x330 [btrfs]
[ 6902.140181]  ? kthread_stop+0x146/0x1f0
[ 6902.141277]  generic_shutdown_super+0x6c/0x100
[ 6902.142517]  kill_anon_super+0x14/0x30
[ 6902.143554]  btrfs_kill_super+0x13/0x100 [btrfs]
[ 6902.144790]  deactivate_locked_super+0x2f/0x70
[ 6902.146014]  cleanup_mnt+0x3b/0x70
[ 6902.147020]  task_work_run+0x9e/0xd0
[ 6902.148036]  do_syscall_64+0x470/0x600
[ 6902.149142]  ? trace_hardirqs_off_thunk+0x1a/0x1c
[ 6902.150375]  entry_SYSCALL_64_after_hwframe+0x49/0xbe
[ 6902.151640] RIP: 0033:0x7f45077a6a7b
[ 6902.157324] RSP: 002b:00007ffd589f3e68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6
[ 6902.159187] RAX: 0000000000000000 RBX: 000055e8eec732b0 RCX: 00007f45077a6a7b
[ 6902.160834] RDX: 0000000000000001 RSI: 0000000000000000 RDI: 000055e8eec73490
[ 6902.162526] RBP: 0000000000000000 R08: 000055e8eec734b0 R09: 00007ffd589f26c0
[ 6902.164141] R10: 0000000000000000 R11: 0000000000000246 R12: 000055e8eec73490
[ 6902.165815] R13: 00007f4507ac61a4 R14: 0000000000000000 R15: 00007ffd589f40d8
[ 6902.167553] irq event stamp: 0
[ 6902.168998] hardirqs last  enabled at (0): [<0000000000000000>]           (null)
[ 6902.170731] hardirqs last disabled at (0): [<ffffffff810cd810>] copy_process.part.55+0x3b0/0x1f00
[ 6902.172773] softirqs last  enabled at (0): [<ffffffff810cd810>] copy_process.part.55+0x3b0/0x1f00
[ 6902.174671] softirqs last disabled at (0): [<0000000000000000>]           (null)
[ 6902.176407] ---[ end trace 463138c2986b275c ]---
[ 6902.177636] BTRFS info (device dm-3): space_info 4 has 273465344 free, is not full
[ 6902.179453] BTRFS info (device dm-3): space_info total=276824064, used=4685824, pinned=18446744073708158976, reserved=0, may_use=0, readonly=65536

In the above line there's "pinned=18446744073708158976" which is an
unsigned u64 value of -1392640, an obvious underflow.

When transaction_kthread is running cleanup_transaction(), another
fsstress is running btrfs_commit_transaction(). The
btrfs_finish_extent_commit() may get the same range as
btrfs_destroy_pinned_extent() got, which causes the pinned underflow.

Fixes: d4b450cd4b33 ("Btrfs: fix race between transaction commit and empty block group removal")
CC: stable@vger.kernel.org # 4.4+
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/btrfs/disk-io.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 8dbb00fbb00b..b0875ef48522 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -4333,6 +4333,7 @@ static int btrfs_destroy_marked_extents(struct btrfs_root *root,
 static int btrfs_destroy_pinned_extent(struct btrfs_root *root,
 				       struct extent_io_tree *pinned_extents)
 {
+	struct btrfs_fs_info *fs_info = root->fs_info;
 	struct extent_io_tree *unpin;
 	u64 start;
 	u64 end;
@@ -4342,21 +4343,31 @@ static int btrfs_destroy_pinned_extent(struct btrfs_root *root,
 	unpin = pinned_extents;
 again:
 	while (1) {
+		/*
+		 * The btrfs_finish_extent_commit() may get the same range as
+		 * ours between find_first_extent_bit and clear_extent_dirty.
+		 * Hence, hold the unused_bg_unpin_mutex to avoid double unpin
+		 * the same extent range.
+		 */
+		mutex_lock(&fs_info->unused_bg_unpin_mutex);
 		ret = find_first_extent_bit(unpin, 0, &start, &end,
 					    EXTENT_DIRTY, NULL);
-		if (ret)
+		if (ret) {
+			mutex_unlock(&fs_info->unused_bg_unpin_mutex);
 			break;
+		}
 
 		clear_extent_dirty(unpin, start, end, GFP_NOFS);
 		btrfs_error_unpin_extent_range(root, start, end);
+		mutex_unlock(&fs_info->unused_bg_unpin_mutex);
 		cond_resched();
 	}
 
 	if (loop) {
-		if (unpin == &root->fs_info->freed_extents[0])
-			unpin = &root->fs_info->freed_extents[1];
+		if (unpin == &fs_info->freed_extents[0])
+			unpin = &fs_info->freed_extents[1];
 		else
-			unpin = &root->fs_info->freed_extents[0];
+			unpin = &fs_info->freed_extents[0];
 		loop = false;
 		goto again;
 	}
-- 
2.17.1




^ permalink raw reply related	[flat|nested] 81+ messages in thread

* [PATCH 4.4 58/70] Revert "media: videobuf2-core: dont call memop finish when queueing"
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (56 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 57/70] btrfs: fix pinned underflow after transaction aborted Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 59/70] Revert "Bluetooth: h5: Fix missing dependency on BT_HCIUART_SERDEV" Greg Kroah-Hartman
                   ` (17 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Hans Verkuil, Sasha Levin

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

This reverts commit 46431d9c28f6859f8e568ac7db92137f1da31100.

This commit fixes a bug in upstream commit a136f59c0a1f ("vb2: Move
buffer cache synchronisation to prepare from queue") which isn't
present in 4.4.

So as a result you get an UNBALANCED message in the kernel log if
this patch is applied:

vb2:   counters for queue ffffffc0f3687478, buffer 3: UNBALANCED!
vb2:     buf_init: 1 buf_cleanup: 1 buf_prepare: 805 buf_finish: 805
vb2:     buf_queue: 806 buf_done: 806
vb2:     alloc: 0 put: 0 prepare: 806 finish: 805 mmap: 0
vb2:     get_userptr: 0 put_userptr: 0
vb2:     attach_dmabuf: 1 detach_dmabuf: 1 map_dmabuf: 805 unmap_dmabuf: 805
vb2:     get_dmabuf: 0 num_users: 1609 vaddr: 0 cookie: 805

Reverting this patch solves this regression.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/media/v4l2-core/videobuf2-core.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index 1c37d5a78822..8ce9c63dfc59 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -870,12 +870,9 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state)
 	dprintk(4, "done processing on buffer %d, state: %d\n",
 			vb->index, state);
 
-	if (state != VB2_BUF_STATE_QUEUED &&
-	    state != VB2_BUF_STATE_REQUEUEING) {
-		/* sync buffers */
-		for (plane = 0; plane < vb->num_planes; ++plane)
-			call_void_memop(vb, finish, vb->planes[plane].mem_priv);
-	}
+	/* sync buffers */
+	for (plane = 0; plane < vb->num_planes; ++plane)
+		call_void_memop(vb, finish, vb->planes[plane].mem_priv);
 
 	spin_lock_irqsave(&q->done_lock, flags);
 	if (state == VB2_BUF_STATE_QUEUED ||
-- 
2.17.1




^ permalink raw reply related	[flat|nested] 81+ messages in thread

* [PATCH 4.4 59/70] Revert "Bluetooth: h5: Fix missing dependency on BT_HCIUART_SERDEV"
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (57 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 58/70] Revert "media: videobuf2-core: dont call memop finish when queueing" Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 60/70] media: v4l: event: Add subscription to list before calling "add" operation Greg Kroah-Hartman
                   ` (16 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, youling 257, Johan Hedberg,
	Marcel Holtmann, Sasha Levin

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

This reverts commit 5824d86b50b8c5f9ecd725f2d74381a23ab1c63b which is
commit 6c3711ec64fd23a9abc8aaf59a9429569a6282df upstream.

You Ling writes that this config option isn't even in 4.4.y yet, so it
causes a regression.  Revert the patch because of this.

Reported-by: youling 257 <youling257@gmail.com>
Cc: Johan Hedberg <johan.hedberg@intel.com>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/bluetooth/Kconfig |    1 -
 1 file changed, 1 deletion(-)

--- a/drivers/bluetooth/Kconfig
+++ b/drivers/bluetooth/Kconfig
@@ -125,7 +125,6 @@ config BT_HCIUART_LL
 config BT_HCIUART_3WIRE
 	bool "Three-wire UART (H5) protocol support"
 	depends on BT_HCIUART
-	depends on BT_HCIUART_SERDEV
 	help
 	  The HCI Three-wire UART Transport Layer makes it possible to
 	  user the Bluetooth HCI over a serial port interface. The HCI



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 60/70] media: v4l: event: Add subscription to list before calling "add" operation
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (58 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 59/70] Revert "Bluetooth: h5: Fix missing dependency on BT_HCIUART_SERDEV" Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 61/70] uio: Fix an Oops on load Greg Kroah-Hartman
                   ` (15 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Dave Stevenson, Sakari Ailus,
	Hans Verkuil, Mauro Carvalho Chehab

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Sakari Ailus <sakari.ailus@linux.intel.com>

commit 92539d3eda2c090b382699bbb896d4b54e9bdece upstream.

Patch ad608fbcf166 changed how events were subscribed to address an issue
elsewhere. As a side effect of that change, the "add" callback was called
before the event subscription was added to the list of subscribed events,
causing the first event queued by the add callback (and possibly other
events arriving soon afterwards) to be lost.

Fix this by adding the subscription to the list before calling the "add"
callback, and clean up afterwards if that fails.

Fixes: ad608fbcf166 ("media: v4l: event: Prevent freeing event subscriptions while accessed")

Reported-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
Reviewed-by: Hans Verkuil <hans.verkuil@cisco.com>
Tested-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: stable@vger.kernel.org (for 4.14 and up)
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
[Sakari Ailus: Backported to v4.9 stable]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/media/v4l2-core/v4l2-event.c |   43 +++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 19 deletions(-)

--- a/drivers/media/v4l2-core/v4l2-event.c
+++ b/drivers/media/v4l2-core/v4l2-event.c
@@ -197,6 +197,22 @@ int v4l2_event_pending(struct v4l2_fh *f
 }
 EXPORT_SYMBOL_GPL(v4l2_event_pending);
 
+static void __v4l2_event_unsubscribe(struct v4l2_subscribed_event *sev)
+{
+	struct v4l2_fh *fh = sev->fh;
+	unsigned int i;
+
+	lockdep_assert_held(&fh->subscribe_lock);
+	assert_spin_locked(&fh->vdev->fh_lock);
+
+	/* Remove any pending events for this subscription */
+	for (i = 0; i < sev->in_use; i++) {
+		list_del(&sev->events[sev_pos(sev, i)].list);
+		fh->navailable--;
+	}
+	list_del(&sev->list);
+}
+
 int v4l2_event_subscribe(struct v4l2_fh *fh,
 			 const struct v4l2_event_subscription *sub, unsigned elems,
 			 const struct v4l2_subscribed_event_ops *ops)
@@ -228,27 +244,23 @@ int v4l2_event_subscribe(struct v4l2_fh
 
 	spin_lock_irqsave(&fh->vdev->fh_lock, flags);
 	found_ev = v4l2_event_subscribed(fh, sub->type, sub->id);
+	if (!found_ev)
+		list_add(&sev->list, &fh->subscribed);
 	spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
 
 	if (found_ev) {
 		/* Already listening */
 		kfree(sev);
-		goto out_unlock;
-	}
-
-	if (sev->ops && sev->ops->add) {
+	} else if (sev->ops && sev->ops->add) {
 		ret = sev->ops->add(sev, elems);
 		if (ret) {
+			spin_lock_irqsave(&fh->vdev->fh_lock, flags);
+			__v4l2_event_unsubscribe(sev);
+			spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
 			kfree(sev);
-			goto out_unlock;
 		}
 	}
 
-	spin_lock_irqsave(&fh->vdev->fh_lock, flags);
-	list_add(&sev->list, &fh->subscribed);
-	spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
-
-out_unlock:
 	mutex_unlock(&fh->subscribe_lock);
 
 	return ret;
@@ -283,7 +295,6 @@ int v4l2_event_unsubscribe(struct v4l2_f
 {
 	struct v4l2_subscribed_event *sev;
 	unsigned long flags;
-	int i;
 
 	if (sub->type == V4L2_EVENT_ALL) {
 		v4l2_event_unsubscribe_all(fh);
@@ -295,14 +306,8 @@ int v4l2_event_unsubscribe(struct v4l2_f
 	spin_lock_irqsave(&fh->vdev->fh_lock, flags);
 
 	sev = v4l2_event_subscribed(fh, sub->type, sub->id);
-	if (sev != NULL) {
-		/* Remove any pending events for this subscription */
-		for (i = 0; i < sev->in_use; i++) {
-			list_del(&sev->events[sev_pos(sev, i)].list);
-			fh->navailable--;
-		}
-		list_del(&sev->list);
-	}
+	if (sev != NULL)
+		__v4l2_event_unsubscribe(sev);
 
 	spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
 



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 61/70] uio: Fix an Oops on load
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (59 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 60/70] media: v4l: event: Add subscription to list before calling "add" operation Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 62/70] usb: cdc-acm: add entry for Hiro (Conexant) modem Greg Kroah-Hartman
                   ` (14 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Mathias Thore, Dan Carpenter

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Dan Carpenter <dan.carpenter@oracle.com>

commit 432798195bbce1f8cd33d1c0284d0538835e25fb upstream.

I was trying to solve a double free but I introduced a more serious
NULL dereference bug.  The problem is that if there is an IRQ which
triggers immediately, then we need "info->uio_dev" but it's not set yet.

This patch puts the original initialization back to how it was and just
sets info->uio_dev to NULL on the error path so it should solve both
the Oops and the double free.

Fixes: f019f07ecf6a ("uio: potential double frees if __uio_register_device() fails")
Reported-by: Mathias Thore <Mathias.Thore@infinera.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: stable <stable@vger.kernel.org>
Tested-by: Mathias Thore <Mathias.Thore@infinera.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/uio/uio.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -842,6 +842,8 @@ int __uio_register_device(struct module
 	if (ret)
 		goto err_uio_dev_add_attributes;
 
+	info->uio_dev = idev;
+
 	if (info->irq && (info->irq != UIO_IRQ_CUSTOM)) {
 		/*
 		 * Note that we deliberately don't use devm_request_irq
@@ -853,11 +855,12 @@ int __uio_register_device(struct module
 		 */
 		ret = request_irq(info->irq, uio_interrupt,
 				  info->irq_flags, info->name, idev);
-		if (ret)
+		if (ret) {
+			info->uio_dev = NULL;
 			goto err_request_irq;
+		}
 	}
 
-	info->uio_dev = idev;
 	return 0;
 
 err_request_irq:



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 62/70] usb: cdc-acm: add entry for Hiro (Conexant) modem
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (60 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 61/70] uio: Fix an Oops on load Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 63/70] USB: quirks: Add no-lpm quirk for Raydium touchscreens Greg Kroah-Hartman
                   ` (13 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Maarten Jacobs, Oliver Neukum

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Maarten Jacobs <maarten256@outlook.com>

commit 63529eaa6164ef7ab4b907b25ac3648177e5e78f upstream.

The cdc-acm kernel module currently does not support the Hiro (Conexant)
H05228 USB modem. The patch below adds the device specific information:
	idVendor	0x0572
	idProduct	0x1349

Signed-off-by: Maarten Jacobs <maarten256@outlook.com>
Acked-by: Oliver Neukum <oneukum@suse.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/class/cdc-acm.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1716,6 +1716,9 @@ static const struct usb_device_id acm_id
 	{ USB_DEVICE(0x0572, 0x1328), /* Shiro / Aztech USB MODEM UM-3100 */
 	.driver_info = NO_UNION_NORMAL, /* has no union descriptor */
 	},
+	{ USB_DEVICE(0x0572, 0x1349), /* Hiro (Conexant) USB MODEM H50228 */
+	.driver_info = NO_UNION_NORMAL, /* has no union descriptor */
+	},
 	{ USB_DEVICE(0x20df, 0x0001), /* Simtec Electronics Entropy Key */
 	.driver_info = QUIRK_CONTROL_LINE_STATE, },
 	{ USB_DEVICE(0x2184, 0x001c) },	/* GW Instek AFG-2225 */



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 63/70] USB: quirks: Add no-lpm quirk for Raydium touchscreens
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (61 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 62/70] usb: cdc-acm: add entry for Hiro (Conexant) modem Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 64/70] usb: quirks: Add delay-init quirk for Corsair K70 LUX RGB Greg Kroah-Hartman
                   ` (12 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Kai-Heng Feng

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Kai-Heng Feng <kai.heng.feng@canonical.com>

commit deefd24228a172d1b27d4a9adbfd2cdacd60ae64 upstream.

Raydium USB touchscreen fails to set config if LPM is enabled:
[    2.030658] usb 1-8: New USB device found, idVendor=2386, idProduct=3119
[    2.030659] usb 1-8: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[    2.030660] usb 1-8: Product: Raydium Touch System
[    2.030661] usb 1-8: Manufacturer: Raydium Corporation
[    7.132209] usb 1-8: can't set config #1, error -110

Same behavior can be observed on 2386:3114.

Raydium claims the touchscreen supports LPM under Windows, so I used
Microsoft USB Test Tools (MUTT) [1] to check its LPM status. MUTT shows
that the LPM doesn't work under Windows, either. So let's just disable LPM
for Raydium touchscreens.

[1] https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/usb-test-tools

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/core/quirks.c |    5 +++++
 1 file changed, 5 insertions(+)

--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -263,6 +263,11 @@ static const struct usb_device_id usb_qu
 	{ USB_DEVICE(0x2040, 0x7200), .driver_info =
 			USB_QUIRK_CONFIG_INTF_STRINGS },
 
+	/* Raydium Touchscreen */
+	{ USB_DEVICE(0x2386, 0x3114), .driver_info = USB_QUIRK_NO_LPM },
+
+	{ USB_DEVICE(0x2386, 0x3119), .driver_info = USB_QUIRK_NO_LPM },
+
 	/* DJI CineSSD */
 	{ USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM },
 



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 64/70] usb: quirks: Add delay-init quirk for Corsair K70 LUX RGB
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (62 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 63/70] USB: quirks: Add no-lpm quirk for Raydium touchscreens Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 65/70] misc: atmel-ssc: Fix section annotation on atmel_ssc_get_driver_data Greg Kroah-Hartman
                   ` (11 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Emmanuel Pescosta

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Emmanuel Pescosta <emmanuelpescosta099@gmail.com>

commit a77112577667cbda7c6292c52d909636aef31fd9 upstream.

Following on from this patch: https://lkml.org/lkml/2017/11/3/516,
Corsair K70 LUX RGB keyboards also require the DELAY_INIT quirk to
start correctly at boot.

Dmesg output:
usb 1-6: string descriptor 0 read error: -110
usb 1-6: New USB device found, idVendor=1b1c, idProduct=1b33
usb 1-6: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-6: can't set config #1, error -110

Signed-off-by: Emmanuel Pescosta <emmanuelpescosta099@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/core/quirks.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -243,6 +243,9 @@ static const struct usb_device_id usb_qu
 	{ USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT |
 	  USB_QUIRK_DELAY_CTRL_MSG },
 
+	/* Corsair K70 LUX RGB */
+	{ USB_DEVICE(0x1b1c, 0x1b33), .driver_info = USB_QUIRK_DELAY_INIT },
+
 	/* Corsair K70 LUX */
 	{ USB_DEVICE(0x1b1c, 0x1b36), .driver_info = USB_QUIRK_DELAY_INIT },
 



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 65/70] misc: atmel-ssc: Fix section annotation on atmel_ssc_get_driver_data
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (63 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 64/70] usb: quirks: Add delay-init quirk for Corsair K70 LUX RGB Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 66/70] USB: misc: appledisplay: add 20" Apple Cinema Display Greg Kroah-Hartman
                   ` (10 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Nathan Chancellor

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Nathan Chancellor <natechancellor@gmail.com>

commit 7c97301285b62a41d6bceded7d964085fc8cc50f upstream.

After building the kernel with Clang, the following section mismatch
warning appears:

WARNING: vmlinux.o(.text+0x3bf19a6): Section mismatch in reference from
the function ssc_probe() to the function
.init.text:atmel_ssc_get_driver_data()
The function ssc_probe() references
the function __init atmel_ssc_get_driver_data().
This is often because ssc_probe lacks a __init
annotation or the annotation of atmel_ssc_get_driver_data is wrong.

Remove __init from atmel_ssc_get_driver_data to get rid of the mismatch.

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/misc/atmel-ssc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/misc/atmel-ssc.c
+++ b/drivers/misc/atmel-ssc.c
@@ -129,7 +129,7 @@ static const struct of_device_id atmel_s
 MODULE_DEVICE_TABLE(of, atmel_ssc_dt_ids);
 #endif
 
-static inline const struct atmel_ssc_platform_data * __init
+static inline const struct atmel_ssc_platform_data *
 	atmel_ssc_get_driver_data(struct platform_device *pdev)
 {
 	if (pdev->dev.of_node) {



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 66/70] USB: misc: appledisplay: add 20" Apple Cinema Display
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (64 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 65/70] misc: atmel-ssc: Fix section annotation on atmel_ssc_get_driver_data Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 67/70] drivers/misc/sgi-gru: fix Spectre v1 vulnerability Greg Kroah-Hartman
                   ` (9 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Mattias Jacobsson

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Mattias Jacobsson <2pi@mok.nu>

commit f6501f49199097b99e4e263644d88c90d1ec1060 upstream.

Add another Apple Cinema Display to the list of supported displays

Signed-off-by: Mattias Jacobsson <2pi@mok.nu>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/misc/appledisplay.c |    1 +
 1 file changed, 1 insertion(+)

--- a/drivers/usb/misc/appledisplay.c
+++ b/drivers/usb/misc/appledisplay.c
@@ -63,6 +63,7 @@ static const struct usb_device_id appled
 	{ APPLEDISPLAY_DEVICE(0x9219) },
 	{ APPLEDISPLAY_DEVICE(0x921c) },
 	{ APPLEDISPLAY_DEVICE(0x921d) },
+	{ APPLEDISPLAY_DEVICE(0x9222) },
 	{ APPLEDISPLAY_DEVICE(0x9236) },
 
 	/* Terminating entry */



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 67/70] drivers/misc/sgi-gru: fix Spectre v1 vulnerability
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (65 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 66/70] USB: misc: appledisplay: add 20" Apple Cinema Display Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 68/70] ACPI / platform: Add SMB0001 HID to forbidden_id_list Greg Kroah-Hartman
                   ` (8 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Gustavo A. R. Silva

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Gustavo A. R. Silva <gustavo@embeddedor.com>

commit fee05f455ceb5c670cbe48e2f9454ebc4a388554 upstream.

req.gid can be indirectly controlled by user-space, hence leading to
a potential exploitation of the Spectre variant 1 vulnerability.

This issue was detected with the help of Smatch:

vers/misc/sgi-gru/grukdump.c:200 gru_dump_chiplet_request() warn:
potential spectre issue 'gru_base' [w]

Fix this by sanitizing req.gid before calling macro GID_TO_GRU, which
uses it to index gru_base.

Notice that given that speculation windows are large, the policy is
to kill the speculation on the first load and not worry if it can be
completed with a dependent load/store [1].

[1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2

Cc: stable@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/misc/sgi-gru/grukdump.c |    4 ++++
 1 file changed, 4 insertions(+)

--- a/drivers/misc/sgi-gru/grukdump.c
+++ b/drivers/misc/sgi-gru/grukdump.c
@@ -27,6 +27,9 @@
 #include <linux/delay.h>
 #include <linux/bitops.h>
 #include <asm/uv/uv_hub.h>
+
+#include <linux/nospec.h>
+
 #include "gru.h"
 #include "grutables.h"
 #include "gruhandles.h"
@@ -196,6 +199,7 @@ int gru_dump_chiplet_request(unsigned lo
 	/* Currently, only dump by gid is implemented */
 	if (req.gid >= gru_max_gids)
 		return -EINVAL;
+	req.gid = array_index_nospec(req.gid, gru_max_gids);
 
 	gru = GID_TO_GRU(req.gid);
 	ubuf = req.buf;



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 68/70] ACPI / platform: Add SMB0001 HID to forbidden_id_list
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (66 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 67/70] drivers/misc/sgi-gru: fix Spectre v1 vulnerability Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 69/70] new helper: uaccess_kernel() Greg Kroah-Hartman
                   ` (7 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Lukas Kahnert, Marc, Hans de Goede,
	Rafael J. Wysocki

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Hans de Goede <hdegoede@redhat.com>

commit 2bbb5fa37475d7aa5fa62f34db1623f3da2dfdfa upstream.

Many HP AMD based laptops contain an SMB0001 device like this:

Device (SMBD)
{
    Name (_HID, "SMB0001")  // _HID: Hardware ID
    Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
    {
        IO (Decode16,
            0x0B20,             // Range Minimum
            0x0B20,             // Range Maximum
            0x20,               // Alignment
            0x20,               // Length
            )
        IRQ (Level, ActiveLow, Shared, )
            {7}
    })
}

The legacy style IRQ resource here causes acpi_dev_get_irqresource() to
be called with legacy=true and this message to show in dmesg:
ACPI: IRQ 7 override to edge, high

This causes issues when later on the AMD0030 GPIO device gets enumerated:

Device (GPIO)
{
    Name (_HID, "AMDI0030")  // _HID: Hardware ID
    Name (_CID, "AMDI0030")  // _CID: Compatible ID
    Name (_UID, Zero)  // _UID: Unique ID
    Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
    {
	Name (RBUF, ResourceTemplate ()
	{
	    Interrupt (ResourceConsumer, Level, ActiveLow, Shared, ,, )
	    {
		0x00000007,
	    }
	    Memory32Fixed (ReadWrite,
		0xFED81500,         // Address Base
		0x00000400,         // Address Length
		)
	})
	Return (RBUF) /* \_SB_.GPIO._CRS.RBUF */
    }
}

Now acpi_dev_get_irqresource() gets called with legacy=false, but because
of the earlier override of the trigger-type acpi_register_gsi() returns
-EBUSY (because we try to register the same interrupt with a different
trigger-type) and we end up setting IORESOURCE_DISABLED in the flags.

The setting of IORESOURCE_DISABLED causes platform_get_irq() to call
acpi_irq_get() which is not implemented on x86 and returns -EINVAL.
resulting in the following in dmesg:

amd_gpio AMDI0030:00: Failed to get gpio IRQ: -22
amd_gpio: probe of AMDI0030:00 failed with error -22

The SMB0001 is a "virtual" device in the sense that the only way the OS
interacts with it is through calling a couple of methods to do SMBus
transfers. As such it is weird that it has IO and IRQ resources at all,
because the driver for it is not expected to ever access the hardware
directly.

The Linux driver for the SMB0001 device directly binds to the acpi_device
through the acpi_bus, so we do not need to instantiate a platform_device
for this ACPI device. This commit adds the SMB0001 HID to the
forbidden_id_list, avoiding the instantiating of a platform_device for it.
Not instantiating a platform_device means we will no longer call
acpi_dev_get_irqresource() for the legacy IRQ resource fixing the probe of
the AMDI0030 device failing.

BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1644013
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=198715
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=199523
Reported-by: Lukas Kahnert <openproggerfreak@gmail.com>
Tested-by: Marc <suaefar@googlemail.com>
Cc: All applicable <stable@vger.kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/acpi/acpi_platform.c |    1 +
 1 file changed, 1 insertion(+)

--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -29,6 +29,7 @@ static const struct acpi_device_id forbi
 	{"PNP0200",  0},	/* AT DMA Controller */
 	{"ACPI0009", 0},	/* IOxAPIC */
 	{"ACPI000A", 0},	/* IOAPIC */
+	{"SMB0001",  0},	/* ACPI SMBUS virtual device */
 	{"", 0},
 };
 



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 69/70] new helper: uaccess_kernel()
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (67 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 68/70] ACPI / platform: Add SMB0001 HID to forbidden_id_list Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 10:51 ` [PATCH 4.4 70/70] HID: uhid: forbid UHID_CREATE under KERNEL_DS or elevated privileges Greg Kroah-Hartman
                   ` (6 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, stable, Al Viro

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Al Viro <viro@zeniv.linux.org.uk>

commit db68ce10c4f0a27c1ff9fa0e789e5c41f8c4ea63 upstream.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
[only take the include/linux/uaccess.h portion - gregkh]
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 include/linux/uaccess.h |    3 +++
 1 file changed, 3 insertions(+)

--- a/include/linux/uaccess.h
+++ b/include/linux/uaccess.h
@@ -2,6 +2,9 @@
 #define __LINUX_UACCESS_H__
 
 #include <linux/sched.h>
+
+#define uaccess_kernel() segment_eq(get_fs(), KERNEL_DS)
+
 #include <asm/uaccess.h>
 
 static __always_inline void pagefault_disabled_inc(void)



^ permalink raw reply	[flat|nested] 81+ messages in thread

* [PATCH 4.4 70/70] HID: uhid: forbid UHID_CREATE under KERNEL_DS or elevated privileges
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (68 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 69/70] new helper: uaccess_kernel() Greg Kroah-Hartman
@ 2018-11-26 10:51 ` Greg Kroah-Hartman
  2018-11-26 16:29 ` [PATCH 4.4 00/70] 4.4.165-stable review kernelci.org bot
                   ` (5 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-26 10:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, syzbot+72473edc9bf4eb1c6556,
	Jann Horn, Andy Lutomirski, Eric Biggers, Jiri Kosina

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Eric Biggers <ebiggers@google.com>

commit 8c01db7619f07c85c5cd81ec5eb83608b56c88f5 upstream.

When a UHID_CREATE command is written to the uhid char device, a
copy_from_user() is done from a user pointer embedded in the command.
When the address limit is KERNEL_DS, e.g. as is the case during
sys_sendfile(), this can read from kernel memory.  Alternatively,
information can be leaked from a setuid binary that is tricked to write
to the file descriptor.  Therefore, forbid UHID_CREATE in these cases.

No other commands in uhid_char_write() are affected by this bug and
UHID_CREATE is marked as "obsolete", so apply the restriction to
UHID_CREATE only rather than to uhid_char_write() entirely.

Thanks to Dmitry Vyukov for adding uhid definitions to syzkaller and to
Jann Horn for commit 9da3f2b740544 ("x86/fault: BUG() when uaccess
helpers fault on kernel addresses"), allowing this bug to be found.

Reported-by: syzbot+72473edc9bf4eb1c6556@syzkaller.appspotmail.com
Fixes: d365c6cfd337 ("HID: uhid: add UHID_CREATE and UHID_DESTROY events")
Cc: <stable@vger.kernel.org> # v3.6+
Cc: Jann Horn <jannh@google.com>
Cc: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Jann Horn <jannh@google.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/hid/uhid.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)

--- a/drivers/hid/uhid.c
+++ b/drivers/hid/uhid.c
@@ -12,6 +12,7 @@
 
 #include <linux/atomic.h>
 #include <linux/compat.h>
+#include <linux/cred.h>
 #include <linux/device.h>
 #include <linux/fs.h>
 #include <linux/hid.h>
@@ -24,6 +25,7 @@
 #include <linux/spinlock.h>
 #include <linux/uhid.h>
 #include <linux/wait.h>
+#include <linux/uaccess.h>
 
 #define UHID_NAME	"uhid"
 #define UHID_BUFSIZE	32
@@ -721,6 +723,17 @@ static ssize_t uhid_char_write(struct fi
 
 	switch (uhid->input_buf.type) {
 	case UHID_CREATE:
+		/*
+		 * 'struct uhid_create_req' contains a __user pointer which is
+		 * copied from, so it's unsafe to allow this with elevated
+		 * privileges (e.g. from a setuid binary) or via kernel_write().
+		 */
+		if (file->f_cred != current_cred() || uaccess_kernel()) {
+			pr_err_once("UHID_CREATE from different security context by process %d (%s), this is not allowed.\n",
+				    task_tgid_vnr(current), current->comm);
+			ret = -EACCES;
+			goto unlock;
+		}
 		ret = uhid_dev_create(uhid, &uhid->input_buf);
 		break;
 	case UHID_CREATE2:



^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: [PATCH 4.4 00/70] 4.4.165-stable review
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (69 preceding siblings ...)
  2018-11-26 10:51 ` [PATCH 4.4 70/70] HID: uhid: forbid UHID_CREATE under KERNEL_DS or elevated privileges Greg Kroah-Hartman
@ 2018-11-26 16:29 ` kernelci.org bot
  2018-11-26 23:49 ` Guenter Roeck
                   ` (4 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: kernelci.org bot @ 2018-11-26 16:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: Greg Kroah-Hartman, torvalds, akpm, linux, shuah, patches,
	ben.hutchings, lkft-triage, stable

stable-rc/linux-4.4.y boot: 47 boots: 1 failed, 46 passed (v4.4.164-71-g2646be341868)

Full Boot Summary: https://kernelci.org/boot/all/job/stable-rc/branch/linux-4.4.y/kernel/v4.4.164-71-g2646be341868/
Full Build Summary: https://kernelci.org/build/stable-rc/branch/linux-4.4.y/kernel/v4.4.164-71-g2646be341868/

Tree: stable-rc
Branch: linux-4.4.y
Git Describe: v4.4.164-71-g2646be341868
Git Commit: 2646be341868dced4199335842b6642b8a01aa0c
Git URL: http://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
Tested: 30 unique boards, 11 SoC families, 13 builds out of 187

Boot Failure Detected:

arm64:

    defconfig
        qcom-qdf2400: 1 failed lab

---
For more info write to <info@kernelci.org>

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: [PATCH 4.4 00/70] 4.4.165-stable review
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (70 preceding siblings ...)
  2018-11-26 16:29 ` [PATCH 4.4 00/70] 4.4.165-stable review kernelci.org bot
@ 2018-11-26 23:49 ` Guenter Roeck
  2018-11-26 23:54 ` shuah
                   ` (3 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: Guenter Roeck @ 2018-11-26 23:49 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: torvalds, akpm, shuah, patches, ben.hutchings, lkft-triage, stable

On 11/26/18 2:50 AM, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.4.165 release.
> There are 70 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Wed Nov 28 10:50:16 UTC 2018.
> Anything received after that time might be too late.
> 

For v4.4.164-71-g4209bc7270f7:

Build results:
	total: 150 pass: 150 fail: 0
Qemu test results:
	total: 264 pass: 264 fail: 0

Details are available at https://kerneltests.org/builders/.

Guenter

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: [PATCH 4.4 00/70] 4.4.165-stable review
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (71 preceding siblings ...)
  2018-11-26 23:49 ` Guenter Roeck
@ 2018-11-26 23:54 ` shuah
  2018-11-27  9:56 ` Harsh Shandilya
                   ` (2 subsequent siblings)
  75 siblings, 0 replies; 81+ messages in thread
From: shuah @ 2018-11-26 23:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: torvalds, akpm, linux, patches, ben.hutchings, lkft-triage,
	stable, shuah

On 11/26/18 3:50 AM, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.4.165 release.
> There are 70 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Wed Nov 28 10:50:16 UTC 2018.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
> 	https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.4.165-rc1.gz
> or in the git tree and branch at:
> 	git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.4.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h
> 
>

Compiled and booted on my test system. No dmesg regressions.

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: [PATCH 4.4 00/70] 4.4.165-stable review
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (72 preceding siblings ...)
  2018-11-26 23:54 ` shuah
@ 2018-11-27  9:56 ` Harsh Shandilya
  2018-11-27 14:39   ` Greg Kroah-Hartman
  2018-11-27 13:09 ` Naresh Kamboju
  2018-11-27 13:29 ` Jon Hunter
  75 siblings, 1 reply; 81+ messages in thread
From: Harsh Shandilya @ 2018-11-27  9:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: torvalds, akpm, linux, shuah, patches, ben.hutchings,
	lkft-triage, stable

On 26 November 2018 4:20:15 PM IST, Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:
>This is the start of the stable review cycle for the 4.4.165 release.
>There are 70 patches in this series, all will be posted as a response
>to this one.  If anyone has any issues with these being applied, please
>let me know.
>
>Responses should be made by Wed Nov 28 10:50:16 UTC 2018.
>Anything received after that time might be too late.
>
>The whole patch series can be found in one patch at:
>	https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.4.165-rc1.gz
>or in the git tree and branch at:
>	git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
>linux-4.4.y
>and the diffstat can be found below.
>
>thanks,
>
>greg k-h
A rather painful merge into the Pixel 2 tree but I'm glad to report I have noticed no regressions over the past couple hours of testing.
-- 
Harsh Shandilya
PRJKT Development LLC

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: [PATCH 4.4 00/70] 4.4.165-stable review
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (73 preceding siblings ...)
  2018-11-27  9:56 ` Harsh Shandilya
@ 2018-11-27 13:09 ` Naresh Kamboju
  2018-11-27 13:29 ` Jon Hunter
  75 siblings, 0 replies; 81+ messages in thread
From: Naresh Kamboju @ 2018-11-27 13:09 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: open list, Linus Torvalds, Andrew Morton, Guenter Roeck,
	Shuah Khan, patches, Ben Hutchings, lkft-triage, linux- stable

On Mon, 26 Nov 2018 at 16:23, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> This is the start of the stable review cycle for the 4.4.165 release.
> There are 70 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
>
> Responses should be made by Wed Nov 28 10:50:16 UTC 2018.
> Anything received after that time might be too late.
>
> The whole patch series can be found in one patch at:
>         https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.4.165-rc1.gz
> or in the git tree and branch at:
>         git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.4.y
> and the diffstat can be found below.
>
> thanks,
>
> greg k-h

Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.

Summary
------------------------------------------------------------------------
kernel: 4.4.165-rc2
git repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
git branch: linux-4.4.y
git commit: 4209bc7270f7d3a9daba39179d100aed0e025ef0
git describe: v4.4.164-71-g4209bc7270f7
Test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-4.4-oe/build/v4.4.164-71-g4209bc7270f7

No regressions (compared to build v4.4.164-71-gb01da71bcd07)

No fixes (compared to build v4.4.164-71-gb01da71bcd07)

Environments
--------------
- dragonboard-410c - arm64
- hi6220-hikey - arm64
- i386
- juno-r2 - arm64
- qemu_arm
- qemu_arm64
- qemu_i386
- qemu_x86_64
- x15 - arm
- x86_64

Test Suites
-----------
* boot
* install-android-platform-tools-r2600
* kselftest
* libhugetlbfs
* ltp-cap_bounds-tests
* ltp-containers-tests
* ltp-cve-tests
* ltp-fcntl-locktests-tests
* ltp-filecaps-tests
* ltp-fs-tests
* ltp-fs_bind-tests
* ltp-fs_perms_simple-tests
* ltp-fsx-tests
* ltp-hugetlb-tests
* ltp-io-tests
* ltp-ipc-tests
* ltp-math-tests
* ltp-nptl-tests
* ltp-pty-tests
* ltp-sched-tests
* ltp-securebits-tests
* ltp-syscalls-tests
* ltp-timers-tests
* ltp-open-posix-tests
* kselftest-vsyscall-mode-native
* kselftest-vsyscall-mode-none

-- 
Linaro LKFT
https://lkft.linaro.org

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: [PATCH 4.4 00/70] 4.4.165-stable review
  2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
                   ` (74 preceding siblings ...)
  2018-11-27 13:09 ` Naresh Kamboju
@ 2018-11-27 13:29 ` Jon Hunter
  75 siblings, 0 replies; 81+ messages in thread
From: Jon Hunter @ 2018-11-27 13:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: torvalds, akpm, linux, shuah, patches, ben.hutchings,
	lkft-triage, stable, linux-tegra


On 26/11/2018 10:50, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.4.165 release.
> There are 70 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Wed Nov 28 10:50:16 UTC 2018.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
> 	https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.4.165-rc1.gz
> or in the git tree and branch at:
> 	git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.4.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h

Looks like this has been updated to -rc2 now, but regardless, all tests
are passing for Tegra ...

Test results for stable-v4.4:
    6 builds:	6 pass, 0 fail
    12 boots:	12 pass, 0 fail
    12 tests:	12 pass, 0 fail

Linux version:	4.4.165-rc2-g4209bc7
Boards tested:	tegra124-jetson-tk1, tegra20-ventana,
                tegra30-cardhu-a04

Cheers
Jon

-- 
nvpublic

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: [PATCH 4.4 00/70] 4.4.165-stable review
  2018-11-27  9:56 ` Harsh Shandilya
@ 2018-11-27 14:39   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2018-11-27 14:39 UTC (permalink / raw)
  To: Harsh Shandilya
  Cc: linux-kernel, torvalds, akpm, linux, shuah, patches,
	ben.hutchings, lkft-triage, stable

On Tue, Nov 27, 2018 at 03:26:32PM +0530, Harsh Shandilya wrote:
> On 26 November 2018 4:20:15 PM IST, Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:
> >This is the start of the stable review cycle for the 4.4.165 release.
> >There are 70 patches in this series, all will be posted as a response
> >to this one.  If anyone has any issues with these being applied, please
> >let me know.
> >
> >Responses should be made by Wed Nov 28 10:50:16 UTC 2018.
> >Anything received after that time might be too late.
> >
> >The whole patch series can be found in one patch at:
> >	https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.4.165-rc1.gz
> >or in the git tree and branch at:
> >	git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
> >linux-4.4.y
> >and the diffstat can be found below.
> >
> >thanks,
> >
> >greg k-h
> A rather painful merge into the Pixel 2 tree but I'm glad to report I
> have noticed no regressions over the past couple hours of testing.  -- 

What was tough about the merge?

Anyway, thanks for testing and letting me know.

greg k-h

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: [PATCH 4.4 17/70] crypto: arm64/sha - avoid non-standard inline asm tricks
  2018-11-26 10:50 ` [PATCH 4.4 17/70] crypto: arm64/sha - avoid non-standard inline asm tricks Greg Kroah-Hartman
@ 2020-11-23 20:49   ` dann frazier
  2020-12-05 20:39     ` dann frazier
  0 siblings, 1 reply; 81+ messages in thread
From: dann frazier @ 2020-11-23 20:49 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, stable, Ard Biesheuvel, Matthias Kaehlcke,
	Herbert Xu, Nathan Chancellor

On Mon, Nov 26, 2018 at 11:50:32AM +0100, Greg Kroah-Hartman wrote:
> 4.4-stable review patch.  If anyone has any objections, please let me know.

fyi, I bisected a regression down to this commit. This apparently
causes an ADR_PREL_PG_HI21 relocation to be added to the sha{1,2}_ce
modules. Back in 4.4 ADR_PREL_PG_HI21 relocations were forbidden if
built with CONFIG_ARM64_ERRATUM_843419=y, so now the sha{1,2}_ce modules
fail to load:

[   37.866250] module sha1_ce: unsupported RELA relocation: 275

Looks like it should be an issue for 4.14.y as well, but I haven't yet
tested it.

  -dann

> From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> 
> commit f4857f4c2ee9aa4e2aacac1a845352b00197fb57 upstream.
> 
> Replace the inline asm which exports struct offsets as ELF symbols
> with proper const variables exposing the same values. This works
> around an issue with Clang which does not interpret the "i" (or "I")
> constraints in the same way as GCC.
> 
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Tested-by: Matthias Kaehlcke <mka@chromium.org>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  arch/arm64/crypto/sha1-ce-core.S |    6 ++++--
>  arch/arm64/crypto/sha1-ce-glue.c |   11 +++--------
>  arch/arm64/crypto/sha2-ce-core.S |    6 ++++--
>  arch/arm64/crypto/sha2-ce-glue.c |   13 +++++--------
>  4 files changed, 16 insertions(+), 20 deletions(-)
> 
> --- a/arch/arm64/crypto/sha1-ce-core.S
> +++ b/arch/arm64/crypto/sha1-ce-core.S
> @@ -82,7 +82,8 @@ ENTRY(sha1_ce_transform)
>  	ldr		dgb, [x0, #16]
>  
>  	/* load sha1_ce_state::finalize */
> -	ldr		w4, [x0, #:lo12:sha1_ce_offsetof_finalize]
> +	ldr_l		w4, sha1_ce_offsetof_finalize, x4
> +	ldr		w4, [x0, x4]
>  
>  	/* load input */
>  0:	ld1		{v8.4s-v11.4s}, [x1], #64
> @@ -132,7 +133,8 @@ CPU_LE(	rev32		v11.16b, v11.16b	)
>  	 * the padding is handled by the C code in that case.
>  	 */
>  	cbz		x4, 3f
> -	ldr		x4, [x0, #:lo12:sha1_ce_offsetof_count]
> +	ldr_l		w4, sha1_ce_offsetof_count, x4
> +	ldr		x4, [x0, x4]
>  	movi		v9.2d, #0
>  	mov		x8, #0x80000000
>  	movi		v10.2d, #0
> --- a/arch/arm64/crypto/sha1-ce-glue.c
> +++ b/arch/arm64/crypto/sha1-ce-glue.c
> @@ -17,9 +17,6 @@
>  #include <linux/crypto.h>
>  #include <linux/module.h>
>  
> -#define ASM_EXPORT(sym, val) \
> -	asm(".globl " #sym "; .set " #sym ", %0" :: "I"(val));
> -
>  MODULE_DESCRIPTION("SHA1 secure hash using ARMv8 Crypto Extensions");
>  MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
>  MODULE_LICENSE("GPL v2");
> @@ -32,6 +29,9 @@ struct sha1_ce_state {
>  asmlinkage void sha1_ce_transform(struct sha1_ce_state *sst, u8 const *src,
>  				  int blocks);
>  
> +const u32 sha1_ce_offsetof_count = offsetof(struct sha1_ce_state, sst.count);
> +const u32 sha1_ce_offsetof_finalize = offsetof(struct sha1_ce_state, finalize);
> +
>  static int sha1_ce_update(struct shash_desc *desc, const u8 *data,
>  			  unsigned int len)
>  {
> @@ -52,11 +52,6 @@ static int sha1_ce_finup(struct shash_de
>  	struct sha1_ce_state *sctx = shash_desc_ctx(desc);
>  	bool finalize = !sctx->sst.count && !(len % SHA1_BLOCK_SIZE);
>  
> -	ASM_EXPORT(sha1_ce_offsetof_count,
> -		   offsetof(struct sha1_ce_state, sst.count));
> -	ASM_EXPORT(sha1_ce_offsetof_finalize,
> -		   offsetof(struct sha1_ce_state, finalize));
> -
>  	/*
>  	 * Allow the asm code to perform the finalization if there is no
>  	 * partial data and the input is a round multiple of the block size.
> --- a/arch/arm64/crypto/sha2-ce-core.S
> +++ b/arch/arm64/crypto/sha2-ce-core.S
> @@ -88,7 +88,8 @@ ENTRY(sha2_ce_transform)
>  	ld1		{dgav.4s, dgbv.4s}, [x0]
>  
>  	/* load sha256_ce_state::finalize */
> -	ldr		w4, [x0, #:lo12:sha256_ce_offsetof_finalize]
> +	ldr_l		w4, sha256_ce_offsetof_finalize, x4
> +	ldr		w4, [x0, x4]
>  
>  	/* load input */
>  0:	ld1		{v16.4s-v19.4s}, [x1], #64
> @@ -136,7 +137,8 @@ CPU_LE(	rev32		v19.16b, v19.16b	)
>  	 * the padding is handled by the C code in that case.
>  	 */
>  	cbz		x4, 3f
> -	ldr		x4, [x0, #:lo12:sha256_ce_offsetof_count]
> +	ldr_l		w4, sha256_ce_offsetof_count, x4
> +	ldr		x4, [x0, x4]
>  	movi		v17.2d, #0
>  	mov		x8, #0x80000000
>  	movi		v18.2d, #0
> --- a/arch/arm64/crypto/sha2-ce-glue.c
> +++ b/arch/arm64/crypto/sha2-ce-glue.c
> @@ -17,9 +17,6 @@
>  #include <linux/crypto.h>
>  #include <linux/module.h>
>  
> -#define ASM_EXPORT(sym, val) \
> -	asm(".globl " #sym "; .set " #sym ", %0" :: "I"(val));
> -
>  MODULE_DESCRIPTION("SHA-224/SHA-256 secure hash using ARMv8 Crypto Extensions");
>  MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
>  MODULE_LICENSE("GPL v2");
> @@ -32,6 +29,11 @@ struct sha256_ce_state {
>  asmlinkage void sha2_ce_transform(struct sha256_ce_state *sst, u8 const *src,
>  				  int blocks);
>  
> +const u32 sha256_ce_offsetof_count = offsetof(struct sha256_ce_state,
> +					      sst.count);
> +const u32 sha256_ce_offsetof_finalize = offsetof(struct sha256_ce_state,
> +						 finalize);
> +
>  static int sha256_ce_update(struct shash_desc *desc, const u8 *data,
>  			    unsigned int len)
>  {
> @@ -52,11 +54,6 @@ static int sha256_ce_finup(struct shash_
>  	struct sha256_ce_state *sctx = shash_desc_ctx(desc);
>  	bool finalize = !sctx->sst.count && !(len % SHA256_BLOCK_SIZE);
>  
> -	ASM_EXPORT(sha256_ce_offsetof_count,
> -		   offsetof(struct sha256_ce_state, sst.count));
> -	ASM_EXPORT(sha256_ce_offsetof_finalize,
> -		   offsetof(struct sha256_ce_state, finalize));
> -
>  	/*
>  	 * Allow the asm code to perform the finalization if there is no
>  	 * partial data and the input is a round multiple of the block size.
> 
> 

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: [PATCH 4.4 17/70] crypto: arm64/sha - avoid non-standard inline asm tricks
  2020-11-23 20:49   ` dann frazier
@ 2020-12-05 20:39     ` dann frazier
  2020-12-06  9:46       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 81+ messages in thread
From: dann frazier @ 2020-12-05 20:39 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, stable, Ard Biesheuvel, Matthias Kaehlcke,
	Herbert Xu, Nathan Chancellor

On Mon, Nov 23, 2020 at 01:49:07PM -0700, dann frazier wrote:
> On Mon, Nov 26, 2018 at 11:50:32AM +0100, Greg Kroah-Hartman wrote:
> > 4.4-stable review patch.  If anyone has any objections, please let me know.
> 
> fyi, I bisected a regression down to this commit. This apparently
> causes an ADR_PREL_PG_HI21 relocation to be added to the sha{1,2}_ce
> modules. Back in 4.4 ADR_PREL_PG_HI21 relocations were forbidden if
> built with CONFIG_ARM64_ERRATUM_843419=y, so now the sha{1,2}_ce modules
> fail to load:
> 
> [   37.866250] module sha1_ce: unsupported RELA relocation: 275
> 
> Looks like it should be an issue for 4.14.y as well, but I haven't yet
> tested it.

This regression appears to be limited to 4.4.y. I didn't find it when
testing 4.9.y, and a 2nd bisection determined that it is because
4.9.y+ also contains a backport of commit 41c066f ("arm64: assembler:
make adr_l work in modules under KASLR"). That was pulled from 4.4.y
because it caused a build failure:

  https://www.spinics.net/lists/stable/msg179709.html

Shall I submit a revert of this patch for 4.4.y, or is it worth trying
to get a backport of 41c066f to work?

  -dann
  
> > From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> > 
> > commit f4857f4c2ee9aa4e2aacac1a845352b00197fb57 upstream.
> > 
> > Replace the inline asm which exports struct offsets as ELF symbols
> > with proper const variables exposing the same values. This works
> > around an issue with Clang which does not interpret the "i" (or "I")
> > constraints in the same way as GCC.
> > 
> > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> > Tested-by: Matthias Kaehlcke <mka@chromium.org>
> > Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > ---
> >  arch/arm64/crypto/sha1-ce-core.S |    6 ++++--
> >  arch/arm64/crypto/sha1-ce-glue.c |   11 +++--------
> >  arch/arm64/crypto/sha2-ce-core.S |    6 ++++--
> >  arch/arm64/crypto/sha2-ce-glue.c |   13 +++++--------
> >  4 files changed, 16 insertions(+), 20 deletions(-)
> > 
> > --- a/arch/arm64/crypto/sha1-ce-core.S
> > +++ b/arch/arm64/crypto/sha1-ce-core.S
> > @@ -82,7 +82,8 @@ ENTRY(sha1_ce_transform)
> >  	ldr		dgb, [x0, #16]
> >  
> >  	/* load sha1_ce_state::finalize */
> > -	ldr		w4, [x0, #:lo12:sha1_ce_offsetof_finalize]
> > +	ldr_l		w4, sha1_ce_offsetof_finalize, x4
> > +	ldr		w4, [x0, x4]
> >  
> >  	/* load input */
> >  0:	ld1		{v8.4s-v11.4s}, [x1], #64
> > @@ -132,7 +133,8 @@ CPU_LE(	rev32		v11.16b, v11.16b	)
> >  	 * the padding is handled by the C code in that case.
> >  	 */
> >  	cbz		x4, 3f
> > -	ldr		x4, [x0, #:lo12:sha1_ce_offsetof_count]
> > +	ldr_l		w4, sha1_ce_offsetof_count, x4
> > +	ldr		x4, [x0, x4]
> >  	movi		v9.2d, #0
> >  	mov		x8, #0x80000000
> >  	movi		v10.2d, #0
> > --- a/arch/arm64/crypto/sha1-ce-glue.c
> > +++ b/arch/arm64/crypto/sha1-ce-glue.c
> > @@ -17,9 +17,6 @@
> >  #include <linux/crypto.h>
> >  #include <linux/module.h>
> >  
> > -#define ASM_EXPORT(sym, val) \
> > -	asm(".globl " #sym "; .set " #sym ", %0" :: "I"(val));
> > -
> >  MODULE_DESCRIPTION("SHA1 secure hash using ARMv8 Crypto Extensions");
> >  MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
> >  MODULE_LICENSE("GPL v2");
> > @@ -32,6 +29,9 @@ struct sha1_ce_state {
> >  asmlinkage void sha1_ce_transform(struct sha1_ce_state *sst, u8 const *src,
> >  				  int blocks);
> >  
> > +const u32 sha1_ce_offsetof_count = offsetof(struct sha1_ce_state, sst.count);
> > +const u32 sha1_ce_offsetof_finalize = offsetof(struct sha1_ce_state, finalize);
> > +
> >  static int sha1_ce_update(struct shash_desc *desc, const u8 *data,
> >  			  unsigned int len)
> >  {
> > @@ -52,11 +52,6 @@ static int sha1_ce_finup(struct shash_de
> >  	struct sha1_ce_state *sctx = shash_desc_ctx(desc);
> >  	bool finalize = !sctx->sst.count && !(len % SHA1_BLOCK_SIZE);
> >  
> > -	ASM_EXPORT(sha1_ce_offsetof_count,
> > -		   offsetof(struct sha1_ce_state, sst.count));
> > -	ASM_EXPORT(sha1_ce_offsetof_finalize,
> > -		   offsetof(struct sha1_ce_state, finalize));
> > -
> >  	/*
> >  	 * Allow the asm code to perform the finalization if there is no
> >  	 * partial data and the input is a round multiple of the block size.
> > --- a/arch/arm64/crypto/sha2-ce-core.S
> > +++ b/arch/arm64/crypto/sha2-ce-core.S
> > @@ -88,7 +88,8 @@ ENTRY(sha2_ce_transform)
> >  	ld1		{dgav.4s, dgbv.4s}, [x0]
> >  
> >  	/* load sha256_ce_state::finalize */
> > -	ldr		w4, [x0, #:lo12:sha256_ce_offsetof_finalize]
> > +	ldr_l		w4, sha256_ce_offsetof_finalize, x4
> > +	ldr		w4, [x0, x4]
> >  
> >  	/* load input */
> >  0:	ld1		{v16.4s-v19.4s}, [x1], #64
> > @@ -136,7 +137,8 @@ CPU_LE(	rev32		v19.16b, v19.16b	)
> >  	 * the padding is handled by the C code in that case.
> >  	 */
> >  	cbz		x4, 3f
> > -	ldr		x4, [x0, #:lo12:sha256_ce_offsetof_count]
> > +	ldr_l		w4, sha256_ce_offsetof_count, x4
> > +	ldr		x4, [x0, x4]
> >  	movi		v17.2d, #0
> >  	mov		x8, #0x80000000
> >  	movi		v18.2d, #0
> > --- a/arch/arm64/crypto/sha2-ce-glue.c
> > +++ b/arch/arm64/crypto/sha2-ce-glue.c
> > @@ -17,9 +17,6 @@
> >  #include <linux/crypto.h>
> >  #include <linux/module.h>
> >  
> > -#define ASM_EXPORT(sym, val) \
> > -	asm(".globl " #sym "; .set " #sym ", %0" :: "I"(val));
> > -
> >  MODULE_DESCRIPTION("SHA-224/SHA-256 secure hash using ARMv8 Crypto Extensions");
> >  MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
> >  MODULE_LICENSE("GPL v2");
> > @@ -32,6 +29,11 @@ struct sha256_ce_state {
> >  asmlinkage void sha2_ce_transform(struct sha256_ce_state *sst, u8 const *src,
> >  				  int blocks);
> >  
> > +const u32 sha256_ce_offsetof_count = offsetof(struct sha256_ce_state,
> > +					      sst.count);
> > +const u32 sha256_ce_offsetof_finalize = offsetof(struct sha256_ce_state,
> > +						 finalize);
> > +
> >  static int sha256_ce_update(struct shash_desc *desc, const u8 *data,
> >  			    unsigned int len)
> >  {
> > @@ -52,11 +54,6 @@ static int sha256_ce_finup(struct shash_
> >  	struct sha256_ce_state *sctx = shash_desc_ctx(desc);
> >  	bool finalize = !sctx->sst.count && !(len % SHA256_BLOCK_SIZE);
> >  
> > -	ASM_EXPORT(sha256_ce_offsetof_count,
> > -		   offsetof(struct sha256_ce_state, sst.count));
> > -	ASM_EXPORT(sha256_ce_offsetof_finalize,
> > -		   offsetof(struct sha256_ce_state, finalize));
> > -
> >  	/*
> >  	 * Allow the asm code to perform the finalization if there is no
> >  	 * partial data and the input is a round multiple of the block size.
> > 
> > 

^ permalink raw reply	[flat|nested] 81+ messages in thread

* Re: [PATCH 4.4 17/70] crypto: arm64/sha - avoid non-standard inline asm tricks
  2020-12-05 20:39     ` dann frazier
@ 2020-12-06  9:46       ` Greg Kroah-Hartman
  0 siblings, 0 replies; 81+ messages in thread
From: Greg Kroah-Hartman @ 2020-12-06  9:46 UTC (permalink / raw)
  To: dann frazier
  Cc: linux-kernel, stable, Ard Biesheuvel, Matthias Kaehlcke,
	Herbert Xu, Nathan Chancellor

On Sat, Dec 05, 2020 at 01:39:28PM -0700, dann frazier wrote:
> On Mon, Nov 23, 2020 at 01:49:07PM -0700, dann frazier wrote:
> > On Mon, Nov 26, 2018 at 11:50:32AM +0100, Greg Kroah-Hartman wrote:
> > > 4.4-stable review patch.  If anyone has any objections, please let me know.
> > 
> > fyi, I bisected a regression down to this commit. This apparently
> > causes an ADR_PREL_PG_HI21 relocation to be added to the sha{1,2}_ce
> > modules. Back in 4.4 ADR_PREL_PG_HI21 relocations were forbidden if
> > built with CONFIG_ARM64_ERRATUM_843419=y, so now the sha{1,2}_ce modules
> > fail to load:
> > 
> > [   37.866250] module sha1_ce: unsupported RELA relocation: 275
> > 
> > Looks like it should be an issue for 4.14.y as well, but I haven't yet
> > tested it.
> 
> This regression appears to be limited to 4.4.y. I didn't find it when
> testing 4.9.y, and a 2nd bisection determined that it is because
> 4.9.y+ also contains a backport of commit 41c066f ("arm64: assembler:
> make adr_l work in modules under KASLR"). That was pulled from 4.4.y
> because it caused a build failure:
> 
>   https://www.spinics.net/lists/stable/msg179709.html
> 
> Shall I submit a revert of this patch for 4.4.y, or is it worth trying
> to get a backport of 41c066f to work?

Which ever you think would be best is fine.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 81+ messages in thread

end of thread, other threads:[~2020-12-06  9:45 UTC | newest]

Thread overview: 81+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-26 10:50 [PATCH 4.4 00/70] 4.4.165-stable review Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 01/70] flow_dissector: do not dissect l4 ports for fragments Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 02/70] ip_tunnel: dont force DF when MTU is locked Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 03/70] net-gro: reset skb->pkt_type in napi_reuse_skb() Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 04/70] tg3: Add PHY reset for 5717/5719/5720 in change ring and flow control paths Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 05/70] ipv6: Fix PMTU updates for UDP/raw sockets in presence of VRF Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 06/70] kbuild: Add better clang cross build support Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 07/70] kbuild: clang: add -no-integrated-as to KBUILD_[AC]FLAGS Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 08/70] kbuild: Consolidate header generation from ASM offset information Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 09/70] kbuild: consolidate redundant sed script ASM offset generation Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 10/70] kbuild: fix asm-offset generation to work with clang Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 11/70] kbuild: drop -Wno-unknown-warning-option from clang options Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 12/70] kbuild, LLVMLinux: Add -Werror to cc-option to support clang Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 13/70] kbuild: use -Oz instead of -Os when using clang Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 14/70] kbuild: Add support to generate LLVM assembly files Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 15/70] modules: mark __inittest/__exittest as __maybe_unused Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 16/70] kbuild: clang: Disable address-of-packed-member warning Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 17/70] crypto: arm64/sha - avoid non-standard inline asm tricks Greg Kroah-Hartman
2020-11-23 20:49   ` dann frazier
2020-12-05 20:39     ` dann frazier
2020-12-06  9:46       ` Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 18/70] efi/libstub/arm64: Force hidden visibility for section markers Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 19/70] efi/libstub/arm64: Set -fpie when building the EFI stub Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 20/70] kbuild: fix linker feature test macros when cross compiling with Clang Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 21/70] kbuild: Set KBUILD_CFLAGS before incl. arch Makefile Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 22/70] kbuild: move cc-option and cc-disable-warning after " Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 23/70] kbuild: clang: fix build failures with sparse check Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 24/70] kbuild: clang: remove crufty HOSTCFLAGS Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 25/70] kbuild: clang: disable unused variable warnings only when constant Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 26/70] kbuild: set no-integrated-as before incl. arch Makefile Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 27/70] kbuild: allow to use GCC toolchain not in Clang search path Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 28/70] arm64: Disable asm-operand-width warning for clang Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 29/70] x86/kbuild: Use cc-option to enable -falign-{jumps/loops} Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 30/70] crypto, x86: aesni - fix token pasting for clang Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 31/70] x86/mm/kaslr: Use the _ASM_MUL macro for multiplication to work around Clang incompatibility Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 32/70] kbuild: Add __cc-option macro Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 33/70] x86/build: Use __cc-option for boot code compiler options Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 34/70] x86/build: Specify stack alignment for clang Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 35/70] x86/boot: #undef memcpy() et al in string.c Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 36/70] x86/build: Fix stack alignment for CLang Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 37/70] x86/build: Use cc-option to validate stack alignment parameter Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 38/70] reiserfs: propagate errors from fill_with_dentries() properly Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 39/70] hfs: prevent btree data loss on root split Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 40/70] hfsplus: " Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 41/70] um: Give start_idle_thread() a return code Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 42/70] fs/exofs: fix potential memory leak in mount option parsing Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 43/70] clk: samsung: exynos5420: Enable PERIS clocks for suspend Greg Kroah-Hartman
2018-11-26 10:50 ` [PATCH 4.4 44/70] platform/x86: acerhdf: Add BIOS entry for Gateway LT31 v1.3307 Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 45/70] arm64: percpu: Initialize ret in the default case Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 46/70] s390/vdso: add missing FORCE to build targets Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 47/70] netfilter: ipset: actually allow allowable CIDR 0 in hash:net,port,net Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 48/70] s390/mm: Fix ERROR: "__node_distance" undefined! Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 49/70] netfilter: ipset: Correct rcu_dereference() call in ip_set_put_comment() Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 50/70] netfilter: xt_IDLETIMER: add sysfs filename checking routine Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 51/70] hwmon: (ibmpowernv) Remove bogus __init annotations Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 52/70] lib/raid6: Fix arm64 test build Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 53/70] i2c: omap: Enable for ARCH_K3 Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 54/70] zram: close udev startup race condition as default groups Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 55/70] SUNRPC: drop pointless static qualifier in xdr_get_next_encode_buffer() Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 56/70] gfs2: Put bitmap buffers in put_super Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 57/70] btrfs: fix pinned underflow after transaction aborted Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 58/70] Revert "media: videobuf2-core: dont call memop finish when queueing" Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 59/70] Revert "Bluetooth: h5: Fix missing dependency on BT_HCIUART_SERDEV" Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 60/70] media: v4l: event: Add subscription to list before calling "add" operation Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 61/70] uio: Fix an Oops on load Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 62/70] usb: cdc-acm: add entry for Hiro (Conexant) modem Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 63/70] USB: quirks: Add no-lpm quirk for Raydium touchscreens Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 64/70] usb: quirks: Add delay-init quirk for Corsair K70 LUX RGB Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 65/70] misc: atmel-ssc: Fix section annotation on atmel_ssc_get_driver_data Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 66/70] USB: misc: appledisplay: add 20" Apple Cinema Display Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 67/70] drivers/misc/sgi-gru: fix Spectre v1 vulnerability Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 68/70] ACPI / platform: Add SMB0001 HID to forbidden_id_list Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 69/70] new helper: uaccess_kernel() Greg Kroah-Hartman
2018-11-26 10:51 ` [PATCH 4.4 70/70] HID: uhid: forbid UHID_CREATE under KERNEL_DS or elevated privileges Greg Kroah-Hartman
2018-11-26 16:29 ` [PATCH 4.4 00/70] 4.4.165-stable review kernelci.org bot
2018-11-26 23:49 ` Guenter Roeck
2018-11-26 23:54 ` shuah
2018-11-27  9:56 ` Harsh Shandilya
2018-11-27 14:39   ` Greg Kroah-Hartman
2018-11-27 13:09 ` Naresh Kamboju
2018-11-27 13:29 ` Jon Hunter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).