GitHub/MotorolaMobilityLLC/kernel-slsi.git
5 years agocompiler: fix conflict related kasan during updating 4.14.113
Youngmin Nam [Thu, 2 May 2019 07:36:42 +0000 (16:36 +0900)]
compiler: fix conflict related kasan during updating 4.14.113

Change-Id: Ia5de6644c02f83bbdb291886bb664f7d921fa59c
Signed-off-by: Youngmin Nam <youngmin.nam@samsung.com>
5 years agoprintk: fix conflict during updating 4.14.113
Youngmin Nam [Thu, 2 May 2019 07:35:15 +0000 (16:35 +0900)]
printk: fix conflict during updating 4.14.113

Change-Id: Icf1b8cad7e1f29f02c4cf16638a1792b9fc9f55e
Signed-off-by: Youngmin Nam <youngmin.nam@samsung.com>
5 years agousb: fix conflict for kernel minor update 4.14.113
Youngmin Nam [Thu, 2 May 2019 07:32:57 +0000 (16:32 +0900)]
usb: fix conflict for kernel minor update 4.14.113

Change-Id: Ic12745e3230499c6ab57cfa51a0ac34ce38d8037
Signed-off-by: Youngmin Nam <youngmin.nam@samsung.com>
5 years ago[COMMON] clocksource: exynos_mct: restore TCNTB value in resume
Hosung Kim [Wed, 28 Jun 2017 13:09:18 +0000 (22:09 +0900)]
[COMMON] clocksource: exynos_mct: restore TCNTB value in resume

This commit restores TCNTB value in resume of CPU0.
Other CPUs are controlled hotplug framework while suspend/resume.
But CPU0 is except in this sequence. So some register setting
is needed like TCNTB value.

Change-Id: I1a0dbf2e8f9e73de778910796e180b493c8441d2
Signed-off-by: Hosung Kim <hosung0.kim@samsung.com>
5 years agoclocksource/drivers/exynos_mct: fix conflict during updating 4.14.113
Youngmin Nam [Thu, 2 May 2019 07:21:28 +0000 (16:21 +0900)]
clocksource/drivers/exynos_mct: fix conflict during updating 4.14.113

Change-Id: I9c7b2d3240fae816785ee026628a63bc94e6ac42
Signed-off-by: Youngmin Nam <youngmin.nam@samsung.com>
5 years agoandroid: binder: fix conflict during updating 4.14.113
Youngmin Nam [Thu, 2 May 2019 07:18:00 +0000 (16:18 +0900)]
android: binder: fix conflict during updating 4.14.113

Change-Id: Icbcd0e8ae58a34677df9bbaa304e477f315f0959
Signed-off-by: Youngmin Nam <youngmin.nam@samsung.com>
5 years ago[COMMON] storage: fix conflict during updating 4.14.113
Youngmin Nam [Thu, 2 May 2019 06:50:31 +0000 (15:50 +0900)]
[COMMON] storage: fix conflict during updating 4.14.113

Change-Id: I8c59808fc9d18eff9c1d89e6cd5d8a89a61ef3a2
Signed-off-by: Youngmin Nam <youngmin.nam@samsung.com>
5 years agoandroid: ion: fix conflict during updating 4.14.113
Youngmin Nam [Thu, 2 May 2019 06:44:38 +0000 (15:44 +0900)]
android: ion: fix conflict during updating 4.14.113

Change-Id: I2ac5747d69e93d42c22e60311ed61d917fd3854f
Signed-off-by: Youngmin Nam <youngmin.nam@samsung.com>
5 years agoMerge branch 'android-4.14-p' into android-exynos-4.14-ww-9610-minor_up-dev
Youngmin Nam [Thu, 2 May 2019 06:37:01 +0000 (15:37 +0900)]
Merge branch 'android-4.14-p' into android-exynos-4.14-ww-9610-minor_up-dev

Change-Id: Ibb00d2fdd553354d3689f7d292a984b39001b9c3
Signed-off-by: Youngmin Nam <youngmin.nam@samsung.com>
5 years agoRevert "Revert "dm verity: switch to using asynchronous hash crypto API""
Youngmin Nam [Tue, 23 Apr 2019 07:54:04 +0000 (16:54 +0900)]
Revert "Revert "dm verity: switch to using asynchronous hash crypto API""

This reverts commit 6ae9d6ee589365676e1ff13eed18a9fe07f89994.

Signed-off-by: Youngmin Nam <youngmin.nam@samsung.com>
5 years agoFix 'Merge 4.14.111 into android-4.14-p'
Alistair Strachan [Thu, 25 Apr 2019 23:47:11 +0000 (16:47 -0700)]
Fix 'Merge 4.14.111 into android-4.14-p'

mutex -> spinlock changes from android-4.14

Change-Id: I7da3ad92a12fc9ba60d7b602e9178d04e0fb5c1d
Signed-off-by: Alistair Strachan <astrachan@google.com>
5 years agoANDROID: cuttlefish_defconfig: Remove non-present options
Alistair Strachan [Thu, 25 Apr 2019 21:58:19 +0000 (14:58 -0700)]
ANDROID: cuttlefish_defconfig: Remove non-present options

Change-Id: I7c0d434a77bb0acb5bae14479a0ca7ca64ff9ffc
Signed-off-by: Alistair Strachan <astrachan@google.com>
5 years agoANDROID: Move from clang r346389b to r349610.
Alistair Strachan [Tue, 12 Feb 2019 21:23:11 +0000 (13:23 -0800)]
ANDROID: Move from clang r346389b to r349610.

Bug: 123635022
Test: make ARCH=arm64 cuttlefish_defconfig && make ARCH=arm64
Test: make ARCH=x86_64 x86_64_cuttlefish_defconfig && make ARCH=x86_64
Change-Id: Icc02ea92c13435fa5a6ecd33d8878629762fd2f7
Signed-off-by: Alistair Strachan <astrachan@google.com>
5 years agoANDROID: Move from clang r328903 to r346389b.
Alistair Strachan [Fri, 7 Dec 2018 19:34:16 +0000 (11:34 -0800)]
ANDROID: Move from clang r328903 to r346389b.

Bug: 120439617
Bug: 120503084
Change-Id: I21bb183cac03753d1ba719a69305e2199c3f3227
Signed-off-by: Alistair Strachan <astrachan@google.com>
5 years agoANDROID: cuttlefish_defconfig: Enable CONFIG_INPUT_MOUSEDEV
Alistair Strachan [Fri, 22 Mar 2019 23:52:47 +0000 (16:52 -0700)]
ANDROID: cuttlefish_defconfig: Enable CONFIG_INPUT_MOUSEDEV

Bug: 120439617
Bug: 128633328
Change-Id: I2186d8070f7885937925a25e85ce7b5722a73d57
Signed-off-by: Alistair Strachan <astrachan@google.com>
5 years agoANDROID: cuttlefish: enable CONFIG_INET_UDP_DIAG=y
Maciej Żenczykowski [Fri, 8 Mar 2019 20:59:15 +0000 (12:59 -0800)]
ANDROID: cuttlefish: enable CONFIG_INET_UDP_DIAG=y

This is to mirror:
  https://android-review.googlesource.com/c/kernel/configs/+/721208
  android-base.cfg: enable CONFIG_INET_UDP_DIAG

Generated via:
  echo 'CONFIG_INET_UDP_DIAG=y' >> arch/x86/configs/x86_64_cuttlefish_defconfig
  echo 'CONFIG_INET_UDP_DIAG=y' >> arch/arm64/configs/cuttlefish_defconfig
  make ARCH=x86_64 x86_64_cuttlefish_defconfig
  make ARCH=x86_64 savedefconfig
  cat defconfig > arch/x86/configs/x86_64_cuttlefish_defconfig
  make ARCH=arm64 cuttlefish_defconfig
  make ARCH=arm64 savedefconfig
  cat defconfig > arch/arm64/configs/cuttlefish_defconfig
  rm defconfig

Bug: 127981801
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I5d4533b7c3b9a11e45e96b0346a70b3f93d4a812

5 years agoANDROID: cuttlefish_defconfig: L2TP/PPTP to OLAC/OPNS
Alistair Strachan [Sat, 20 Apr 2019 01:18:15 +0000 (18:18 -0700)]
ANDROID: cuttlefish_defconfig: L2TP/PPTP to OLAC/OPNS

Change-Id: Idafb69ff5b4ecfe73d2f5b7c46c4e9523ef37c08
Signed-off-by: Alistair Strachan <astrachan@google.com>
5 years agoANDROID: cuttlefish_defconfig: Enable CONFIG_FUSE_FS
Alistair Strachan [Wed, 3 Apr 2019 06:59:58 +0000 (23:59 -0700)]
ANDROID: cuttlefish_defconfig: Enable CONFIG_FUSE_FS

Bug: 120439617
Bug: 129901600
Change-Id: Iff554123147f7761ca639b89612138b82a4a400a
Signed-off-by: Alistair Strachan <astrachan@google.com>
5 years agoANDROID: cuttlefish_defconfig: Add support for AC97 audio
Alistair Strachan [Tue, 5 Mar 2019 19:11:34 +0000 (11:11 -0800)]
ANDROID: cuttlefish_defconfig: Add support for AC97 audio

Enable driver support for the ac97 emulation provided by QEMU and
crosvm. This is for the older 'ac97' soundhw, not 'hda'.

Bug: 126955561
Test: local build and test of sound from cuttlefish
Change-Id: I6c29e352e0be161e2a1dc35fde50b888b7dbf86e
Signed-off-by: Alistair Strachan <astrachan@google.com>
5 years agoANDROID: cuttlefish: enable CONFIG_NETFILTER_XT_TARGET_CT=y
Maciej Żenczykowski [Wed, 6 Mar 2019 07:02:51 +0000 (23:02 -0800)]
ANDROID: cuttlefish: enable CONFIG_NETFILTER_XT_TARGET_CT=y

This is to mirror:
  https://android-review.googlesource.com/c/kernel/configs/+/919855
  android-4.9+: add CONFIG_NETFILTER_XT_TARGET_CT=y to base config

Generated via:
  echo 'CONFIG_NETFILTER_XT_TARGET_CT=y' >> arch/x86/configs/x86_64_cuttlefish_defconfig
  echo 'CONFIG_NETFILTER_XT_TARGET_CT=y' >> arch/arm64/configs/cuttlefish_defconfig
  make ARCH=x86_64 x86_64_cuttlefish_defconfig
  make ARCH=x86_64 savedefconfig
  cat defconfig > arch/x86/configs/x86_64_cuttlefish_defconfig
  make ARCH=arm64 cuttlefish_defconfig
  make ARCH=arm64 savedefconfig
  cat defconfig > arch/arm64/configs/cuttlefish_defconfig
  rm defconfig

Bug: 124361845
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I6035ef8e75f9daada706a9233999368a22904c4e

5 years agoMake arm64 serial port config compatible with crosvm
Greg Hartman [Wed, 17 Apr 2019 19:58:54 +0000 (12:58 -0700)]
Make arm64 serial port config compatible with crosvm

BUG: 118442619
Test: Ran ~/bin/crosvm run --disable-sandbox ~/image, saw output
Change-Id: If086af28b69eca5353a101228ae986653bc1465e
Signed-off-by: Greg Hartman <ghartman@google.com>
(cherry picked from commit 2860dfe869a94c8c1950effb55da116f83ebc740)

5 years agoANDROID: cuttlefish_defconfig: Enable CONFIG_RTC_HCTOSYS
Matthias Maennich [Mon, 4 Feb 2019 17:33:19 +0000 (17:33 +0000)]
ANDROID: cuttlefish_defconfig: Enable CONFIG_RTC_HCTOSYS

This configuration is required for the VTS test
VtsKernelApiSysfsTest#testRtcHctosys to pass.

Bug: 123860857
Test: run vts-kernel -m VtsKernelApiSysfsTest
Signed-off-by: Matthias Maennich <maennich@google.com>
Change-Id: Icae17c74460bcd2aef4cf4e3ec5381de9ea0a66c

5 years agoANDROID: cuttlefish_defconfig: Enable vsock options
Cody Schuffelen [Tue, 15 Jan 2019 02:37:28 +0000 (18:37 -0800)]
ANDROID: cuttlefish_defconfig: Enable vsock options

Bug: 121166534
Test: Ran cuttlefish with common kernel + vsock adb tunnel
Signed-off-by: Cody Schuffelen <schuffelen@google.com>
Change-Id: I8168a710052c7daada306a915c56230c961accd4

5 years agoANDROID: cuttlefish_defconfig: Enable VIRTIO_INPUT
Alistair Strachan [Wed, 2 Jan 2019 23:24:37 +0000 (15:24 -0800)]
ANDROID: cuttlefish_defconfig: Enable VIRTIO_INPUT

Bug: 120439617
Change-Id: I83fdb2088f17e71f377e5864d217655b47839267
Signed-off-by: Alistair Strachan <astrachan@google.com>
5 years agoANDROID: cuttlefish_defconfig: Enable VIRT_WIFI
Alistair Strachan [Sat, 8 Dec 2018 00:40:23 +0000 (16:40 -0800)]
ANDROID: cuttlefish_defconfig: Enable VIRT_WIFI

Bug: 120439617
Bug: 120682817
Change-Id: Ia1b66528bd9cb1e6e95bd75ac60f393978caa582
Signed-off-by: Alistair Strachan <astrachan@google.com>
5 years agoANDROID: cuttlefish_defconfig: Enable CONFIG_ARM64_LSE_ATOMICS
Alistair Strachan [Fri, 7 Dec 2018 19:50:07 +0000 (11:50 -0800)]
ANDROID: cuttlefish_defconfig: Enable CONFIG_ARM64_LSE_ATOMICS

Enabling this was previously blocked by a lack of support for this
feature in clang, but that problem has been resolved in a newer version
of the compiler.

Bug: 120439617
Change-Id: I0f5fd2439c5a71ee0988648970576b46b2c4d20b
Signed-off-by: Alistair Strachan <astrachan@google.com>
5 years agoANDROID: arm64 defconfig / build config for cuttlefish
Alistair Strachan [Thu, 25 Oct 2018 00:24:14 +0000 (17:24 -0700)]
ANDROID: arm64 defconfig / build config for cuttlefish

Add an arm64 defconfig with the Android and cuttlefish feature sets
merged in. This has been boot tested only on the QEMU virt model for
AArch64.

$ qemu-system-aarch64 -M virt -cpu cortex-a57 \
    -kernel arch/arm64/boot/Image.gz -serial stdio

Bug: 118442619
Change-Id: I99f3b78af85de8d051226f202351bd852a032248
Signed-off-by: Alistair Strachan <astrachan@google.com>
5 years agoUPSTREAM: virt_wifi: Remove REGULATORY_WIPHY_SELF_MANAGED
Cody Schuffelen [Wed, 6 Feb 2019 23:54:15 +0000 (15:54 -0800)]
UPSTREAM: virt_wifi: Remove REGULATORY_WIPHY_SELF_MANAGED

REGULATORY_WIPHY_SELF_MANAGED as set here breaks NL80211_CMD_GET_REG,
because it expects the wiphy to do regulatory management. Since
virt_wifi does not do regulatory management, this triggers a WARN_ON in
NL80211_CMD_GET_REG and fails the netlink command.

Removing REGULATORY_WIPHY_SELF_MANAGED fixes the problem and the virtual
wireless network continues to work.

Signed-off-by: Cody Schuffelen <schuffelen@google.com>
Acked-by: Alistair Strachan <astrachan@google.com>
Acked-by: Greg Hartman <ghartman@google.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
(cherry picked from commit f440b125450dfc65ce0386eb231da2f663c45ca0)
Bug: 119771992
Change-Id: Ida660b77a2f091e7aaabcecf8a60e66cc2f1f91d
Signed-off-by: Alistair Strachan <astrachan@google.com>
5 years agoUPSTREAM: virt_wifi: fix error return code in virt_wifi_newlink()
Wei Yongjun [Fri, 18 Jan 2019 07:29:52 +0000 (07:29 +0000)]
UPSTREAM: virt_wifi: fix error return code in virt_wifi_newlink()

Fix to return a negative error code from the error handling
case instead of 0, as done elsewhere in this function.

Fixes: c7cdba31ed8b ("mac80211-next: rtnetlink wifi simulation device")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
(cherry picked from commit f9d672f1c2ca36b788511bbd773d650c744e109a)
Change-Id: Ia6290ab996afca7b33e1a8e9b8bcfc0ecbe252f4
Signed-off-by: Cody Schuffelen <schuffelen@google.com>
5 years agoFROMGIT, BACKPORT: mac80211-next: rtnetlink wifi simulation device
Cody Schuffelen [Wed, 21 Nov 2018 03:14:49 +0000 (19:14 -0800)]
FROMGIT, BACKPORT: mac80211-next: rtnetlink wifi simulation device

This device takes over an existing network device and produces a
new one that appears like a wireless connection, returning enough canned
responses to nl80211 to satisfy a standard connection manager. If
necessary, it can also be set up one step removed from an existing
network device, such as through a vlan/80211Q or macvlan connection to
not disrupt the existing network interface.

To use it to wrap a bare ethernet connection:

ip link add link eth0 name wlan0 type virt_wifi

You may have to rename or otherwise hide the eth0 from your connection
manager, as the original network link will become unusuable and only
the wireless wrapper will be functional. This can also be combined with
vlan or macvlan links on top of eth0 to share the network between
distinct links, but that requires support outside the machine for
accepting vlan-tagged packets or packets from multiple MAC addresses.

This is being used for Google's Remote Android Virtual Device project,
which runs Android devices in virtual machines. The standard network
interfaces provided inside the virtual machines are all ethernet.
However, Android is not interested in ethernet devices and would rather
connect to a wireless interface. This patch allows the virtual machine
guest to treat one of its network connections as wireless rather than
ethernet, satisfying Android's network connection requirements.

We believe this is a generally useful driver for simulating wireless
network connections in other environments where a wireless connection is
desired by some userspace process but is not available.

This is distinct from other testing efforts such as mac80211_hwsim by
being a cfg80211 device instead of mac80211 device, allowing straight
pass-through on the data plane instead of forcing packaging of ethernet
data into mac80211 frames.

Signed-off-by: A. Cody Schuffelen <schuffelen@google.com>
Acked-by: Alistair Strachan <astrachan@google.com>
Acked-by: Greg Hartman <ghartman@google.com>
Acked-by: Tristan Muntsinger <muntsinger@google.com>
[make it a tristate]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
(cherry picked from commit c7cdba31ed8b87526db978976392802d3f93110c)
[astrachan: taken from mac80211-next/master]
[astrachan: removed 'extack' from call to netdev_upper_dev_link()]
Bug: 120682817
Test: boot tested cuttlefish and enabled wifi, saw AndroidWifi
Change-Id: I726ec28617574c0217d937da049089f0ab8e0da8
Signed-off-by: Alistair Strachan <astrachan@google.com>
5 years ago[RAMEN9610-14520] [COMMON] arm64: defconfig: enable SAMSUNG COMPOSITE
Kisang Lee [Thu, 18 Apr 2019 11:28:08 +0000 (20:28 +0900)]
[RAMEN9610-14520] [COMMON] arm64: defconfig: enable SAMSUNG COMPOSITE

Change-Id: I2a044fc9b1830506dd8b7f3cbac2d25181f2403b
Signed-off-by: Kisang Lee <kisang80.lee@samsung.com>
5 years ago[RAMEN9610-14520] [COMMON] usb: ignore USB disconnect message at reset
Kisang Lee [Thu, 18 Apr 2019 08:01:13 +0000 (17:01 +0900)]
[RAMEN9610-14520] [COMMON] usb: ignore USB disconnect message at reset

Change-Id: I5ecee0ab18945062ac2518e23c48f2146ddf9627
Signed-off-by: Kisang Lee <kisang80.lee@samsung.com>
5 years ago[RAMEN9610-14503] [COMMON] scsi: ufs: Remove debug dump for UIC error.
JaeHun Jung [Wed, 17 Apr 2019 07:06:51 +0000 (16:06 +0900)]
[RAMEN9610-14503] [COMMON] scsi: ufs: Remove debug dump for UIC error.

UIC_ERROR registers are can make ITMON timeout by race condition.
When ufshcd_abort was working at other cores. And ufshcd_intr can work core0.
In case of when other core read UIC_ERROR register and if core0 execute regiseter write.
It can be make BUS hang in FSYS.(timeout)

Change-Id: I26e3c8c5f6a79d076b9d98c6e588e55f8951c519
Signed-off-by: JaeHun Jung <jh0801.jung@samsung.com>
5 years ago[RAMEN9610-14503] [COMMON] Revert "[COMMON] scsi: ufs: Add delay for UIC_ERROR access."
JaeHun Jung [Thu, 18 Apr 2019 06:32:55 +0000 (15:32 +0900)]
[RAMEN9610-14503] [COMMON] Revert "[COMMON] scsi: ufs: Add delay for UIC_ERROR access."

This reverts commit 3d4959596cfd2a020fd539ea9dbb63fb00531666.

Change-Id: Ib02d70f07f5e0b7ff65749205424e1ed67137526
Signed-off-by: JaeHun Jung <jh0801.jung@samsung.com>
5 years ago[RAMEN9610-14499][common][9610] wlbt: fix completion and use completion_done API
Youngsoo [Thu, 18 Apr 2019 04:50:23 +0000 (13:50 +0900)]
[RAMEN9610-14499][common][9610] wlbt: fix completion and use completion_done API

When we get rapid requests for SABLE generation, to serialise while processing current request,
we ignore requests other than "fw_panic" in wlbtd and send a msg "ignoring" back to kernel.
We must complete in this case as well.

We must complete one completion upon message from wlbtdi, which has
waiter(s). completion_done() API does the check without modifying
the completion in anyway and returns false if there are waiters and
true otherwise

SCSC-Bug-Id: ssb-51156
previous patch :
-Change-Id: Ieabcd8377a3040bdcfe51e4310eb55d84c693446
-Signed-off-by: Purnendu Kapadia <p.kapadia@samsung.com>

Change-Id: Id6ff01e96b2e1e3de7f940c9e2ef1a75211ae5dd
Signed-off-by: Youngsoo <youngss.kim@samsung.com>
5 years ago[RAMEN9610-14474] [COMMON] usb: remove W/A code to avoid kernel panic
Kisang Lee [Wed, 17 Apr 2019 01:18:28 +0000 (10:18 +0900)]
[RAMEN9610-14474] [COMMON] usb: remove W/A code to avoid kernel panic

The W/A code for other AP could make kernel panic rarely.

Change-Id: Ic0b44fdcfc4d9c189d0fc37da2398043720424e7
Signed-off-by: Kisang Lee <kisang80.lee@samsung.com>
5 years ago[ERD][APR-125] Camera code sync to latest.
Wooyeon Kim [Tue, 7 Aug 2018 10:57:02 +0000 (19:57 +0900)]
[ERD][APR-125] Camera code sync to latest.

Change-Id: Ia58c0082b2b7b882c6945c8fc6acda055e0c506e
Signed-off-by: Wooyeon Kim <wooy88.kim@samsung.com>
5 years ago[RAMEN9610-14454] [COMMON] sched: ems: Fix possibility of slab-out-of-bounds error
Daeyeong Lee [Tue, 20 Nov 2018 07:13:33 +0000 (16:13 +0900)]
[RAMEN9610-14454] [COMMON] sched: ems: Fix possibility of slab-out-of-bounds error

Change-Id: Ieeecdd4d811479d3e23d2638ff93069e75c5cedf
Signed-off-by: Daeyeong Lee <daeyeong.lee@samsung.com>
5 years ago[RAMEN9610-14444] [COMMON] scsi: ufs: Add delay for UIC_ERROR access.
JaeHun Jung [Tue, 16 Apr 2019 04:16:14 +0000 (13:16 +0900)]
[RAMEN9610-14444] [COMMON] scsi: ufs: Add delay for UIC_ERROR access.

It can be make ITMON timeout.

Change-Id: Ifbaf2f3213be12fb6f853d314746fccb8b7624ec
Signed-off-by: JaeHun Jung <jh0801.jung@samsung.com>
5 years ago[RAMEN9610-14440] ANDROID: kbuild: disable LTO_CLANG with KASAN
Sami Tolvanen [Fri, 14 Sep 2018 16:17:55 +0000 (09:17 -0700)]
[RAMEN9610-14440] ANDROID: kbuild: disable LTO_CLANG with KASAN

Using LTO with KASAN currently results in "inlinable function call
in a function with debug info must have a !dbg location" errors for
memset and several of the __asan_report_* functions.

As combining these options doesn't provide significant benefits,
this change disables LTO_CLANG when KASAN is selected.

Bug: 113246877
Change-Id: I06cd27d1e9ab74627de4771548453abe3593fcb5
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
5 years ago[RAMEN9610-14440] UPSTREAM: kasan: add functions for unpoisoning stack variables
Alexander Potapenko [Tue, 6 Feb 2018 23:36:20 +0000 (15:36 -0800)]
[RAMEN9610-14440] UPSTREAM: kasan: add functions for unpoisoning stack variables

As a code-size optimization, LLVM builds since r279383 may bulk-manipulate
the shadow region when (un)poisoning large memory blocks.  This requires
new callbacks that simply do an uninstrumented memset().

This fixes linking the Clang-built kernel when using KASAN.

[arnd@arndb.de: add declarations for internal functions]
Link: http://lkml.kernel.org/r/20180105094112.2690475-1-arnd@arndb.de
[fengguang.wu@intel.com: __asan_set_shadow_00 can be static]
Link: http://lkml.kernel.org/r/20171223125943.GA74341@lkp-ib03
[ghackmann@google.com: fix memset() parameters, and tweak commit message to describe new callbacks]
Link: http://lkml.kernel.org/r/20171204191735.132544-6-paullawrence@google.com
Signed-off-by: Alexander Potapenko <glider@google.com>
Signed-off-by: Greg Hackmann <ghackmann@google.com>
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(Cherry-picked from d321599cf6b861beefe92327476b617435c7fc4a)

Change-Id: I001286850420109547c7d6defefe2fbd6915170d
Signed-off-by: Paul Lawrence <paullawrence@google.com>
5 years ago[RAMEN9610-14440] UPSTREAM: kasan: add tests for alloca poisoning
Paul Lawrence [Tue, 6 Feb 2018 23:36:16 +0000 (15:36 -0800)]
[RAMEN9610-14440] UPSTREAM: kasan: add tests for alloca poisoning

Link: http://lkml.kernel.org/r/20171204191735.132544-5-paullawrence@google.com
Signed-off-by: Greg Hackmann <ghackmann@google.com>
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(Cherry-picked from 00a14294bb33af533f7ac002fb20623fdd8ea0d7)

Change-Id: Ibefa500b2f3d7eca9cdbb3ea58b65743700f19ab
Signed-off-by: Paul Lawrence <paullawrence@google.com>
5 years ago[RAMEN9610-14440] UPSTREAM: kasan: support alloca() poisoning
Paul Lawrence [Tue, 6 Feb 2018 23:36:11 +0000 (15:36 -0800)]
[RAMEN9610-14440] UPSTREAM: kasan: support alloca() poisoning

clang's AddressSanitizer implementation adds redzones on either side of
alloca()ed buffers.  These redzones are 32-byte aligned and at least 32
bytes long.

__asan_alloca_poison() is passed the size and address of the allocated
buffer, *excluding* the redzones on either side.  The left redzone will
always be to the immediate left of this buffer; but AddressSanitizer may
need to add padding between the end of the buffer and the right redzone.
If there are any 8-byte chunks inside this padding, we should poison
those too.

__asan_allocas_unpoison() is just passed the top and bottom of the dynamic
stack area, so unpoisoning is simpler.

Link: http://lkml.kernel.org/r/20171204191735.132544-4-paullawrence@google.com
Signed-off-by: Greg Hackmann <ghackmann@google.com>
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(Cherry-picked from 342061ee4ef3d80001d1ae494378f3979c861dba)

Change-Id: I3da748cd5aa5190b2b40deab9d32da0030f4d465
Signed-off-by: Paul Lawrence <paullawrence@google.com>
5 years ago[RAMEN9610-14440] UPSTREAM: kasan/Makefile: support LLVM style asan parameters
Andrey Ryabinin [Tue, 6 Feb 2018 23:36:08 +0000 (15:36 -0800)]
[RAMEN9610-14440] UPSTREAM: kasan/Makefile: support LLVM style asan parameters

LLVM doesn't understand GCC-style paramters ("--param asan-foo=bar"), thus
we currently we don't use inline/globals/stack instrumentation when
building the kernel with clang.

Add support for LLVM-style parameters ("-mllvm -asan-foo=bar") to enable
all KASAN features.

Link: http://lkml.kernel.org/r/20171204191735.132544-3-paullawrence@google.com
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Reviewed-by: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Greg Hackmann <ghackmann@google.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(Cherry-picked from 1a69e7ce8391a8bc808baf04e06d88ab4024ca47)

Change-Id: I6cf05bf35de7caff85a2f46b9f8581468ba9703e
Signed-off-by: Paul Lawrence <paullawrence@google.com>
5 years ago[RAMEN9610-14440] BACKPORT: kasan: add compiler support for clang
Paul Lawrence [Tue, 6 Feb 2018 23:36:03 +0000 (15:36 -0800)]
[RAMEN9610-14440] BACKPORT: kasan: add compiler support for clang

Patch series "kasan: support alloca, LLVM", v4.

This patch (of 5):

For now we can hard-code ASAN ABI level 5, since historical clang builds
can't build the kernel anyway.  We also need to emulate gcc's
__SANITIZE_ADDRESS__ flag, or memset() calls won't be instrumented.

Link: http://lkml.kernel.org/r/20171204191735.132544-2-paullawrence@google.com
Signed-off-by: Greg Hackmann <ghackmann@google.com>
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(Cherry-picked from 53a98ed73b848432a51631346b02049bb7fa039d)

Change-Id: I76b74e70633abadfe430f5cdc397b77abcaab382
Signed-off-by: Paul Lawrence <paullawrence@google.com>
5 years ago[RAMEN9610-14414][9610] dtsi: added audio extra binary
ShinHyung [Mon, 15 Apr 2019 06:02:04 +0000 (15:02 +0900)]
[RAMEN9610-14414][9610] dtsi: added audio extra binary

Change-Id: I251c098cd2fb845e644daff16a1f41cb13324502
Signed-off-by: ShinHyung <s47.kang@samsung.com>
5 years ago[RAMEN9610-14365][9610] media: radio: Add register r/w for debugging
Yunsu Kim [Thu, 11 Apr 2019 06:00:26 +0000 (15:00 +0900)]
[RAMEN9610-14365][9610] media: radio: Add register r/w for debugging

Change-Id: I401e3b3e824adbfd73d88caeafc76e7ecea17b70
Signed-off-by: Yunsu Kim <iamyunsu.kim@samsung.com>
5 years ago[RAMEN9610-14284][COMMON][Bug Fix]s2mcs02 wrong probe
mingliang.lv [Tue, 9 Apr 2019 06:44:52 +0000 (14:44 +0800)]
[RAMEN9610-14284][COMMON][Bug Fix]s2mcs02 wrong probe

Change-Id: I9649ab2663858dd7e9eb33a829f1488a34a1ee26

5 years ago[RAMEN9610-13839] [COMMON]initialize partner before first used
major.chen [Tue, 26 Mar 2019 01:38:44 +0000 (09:38 +0800)]
[RAMEN9610-13839] [COMMON]initialize partner before first used

one kernel panic issue found in product_show , due to
dwc3_otg_init() use uninitialized local variable partner to call typec_register_partner,
it result in partner->identity is setted with unexpected value.
reproduce steps: adb shell cat /sys/class/typec/port0-partner/identity/product

Change-Id: Id0e2d04c20b510563b8b0a0ef786ba4e89d6a50c

5 years ago[ERD][RAMEN9610-13779] arm64: dts: remove fm elna
Yunsu Kim [Tue, 19 Mar 2019 09:53:13 +0000 (18:53 +0900)]
[ERD][RAMEN9610-13779] arm64: dts: remove fm elna

Change-Id: Ife31d8e44fa37e4ecbea0d9381e66ae7decd360e
Signed-off-by: Yunsu Kim <iamyunsu.kim@samsung.com>
5 years ago[RAMEN9610-14378][COMMON] scsi: ufs: Revert "single ton pointer"
JaeHun Jung [Thu, 11 Apr 2019 08:20:15 +0000 (17:20 +0900)]
[RAMEN9610-14378][COMMON] scsi: ufs: Revert "single ton pointer"

Change-Id: Ic171ca4f8809c70cdccb41aba2c7248ddf148b79
Signed-off-by: JaeHun Jung <jh0801.jung@samsung.com>
5 years ago[RAMEN9610-14333][COMMON][9610] drivers : fix typec role swap
Junhan Bae [Fri, 22 Mar 2019 12:14:31 +0000 (21:14 +0900)]
[RAMEN9610-14333][COMMON][9610] drivers : fix typec role swap

Change-Id: Iee22d39b30a81864c77fee2b555eee0cef11b634
Signed-off-by: Junhan Bae <junhan84.bae@samsung.com>
5 years ago[RAMEN9610-14324] [9610] gpu: tHEx: r16p0: fix the prevent defect
Jaewoong, Han [Wed, 10 Apr 2019 05:38:57 +0000 (14:38 +0900)]
[RAMEN9610-14324] [9610] gpu: tHEx: r16p0: fix the prevent defect

Change-Id: I557043dffbb9c1d9c03475248e96081851a845bc
Signed-off-by: Jaewoong, Han <ssm20.han@samsung.com>
5 years ago[RAMEN9610-14313] [COMMON] scsi: ufs: Prevent bug fix.
JaeHun Jung [Wed, 10 Apr 2019 06:34:36 +0000 (15:34 +0900)]
[RAMEN9610-14313] [COMMON] scsi: ufs: Prevent bug fix.

Change-Id: I3d6ac23bdaef1123ac82f9b6cbb22428c917a606
Signed-off-by: JaeHun Jung <jh0801.jung@samsung.com>
5 years ago[RAMEN9610-14257] [COMMON] scsi: ufs: Disable UFS UIC interrupt when UIC error.
JaeHun Jung [Thu, 4 Apr 2019 12:20:24 +0000 (21:20 +0900)]
[RAMEN9610-14257] [COMMON] scsi: ufs: Disable UFS UIC interrupt when UIC error.

Sometimes UFS interrupts storm was occur when UIC error.
So, Disable interrupts for recovery.

Change-Id: I8639995be9e2a537c05b809c73af89578dc00ba2
Signed-off-by: JaeHun Jung <jh0801.jung@samsung.com>
5 years ago[RAMEN9610-14257] [COMMON] scsi: ufs: Move SFR dump to workqueue from ISR.
JaeHun Jung [Thu, 4 Apr 2019 10:51:09 +0000 (19:51 +0900)]
[RAMEN9610-14257] [COMMON] scsi: ufs: Move SFR dump to workqueue from ISR.

Too many prints in the ISR when UFS error case.
So, Move to workqueue for system.

Change-Id: I213f265c0024b75220ce594c271f68a43c28e4dd
Signed-off-by: JaeHun Jung <jh0801.jung@samsung.com>
5 years ago[RAMEN9610-14252] [9610] usb: phy: add iounmap and NULL check of ioremap
Daehwan Jung [Mon, 11 Mar 2019 07:50:03 +0000 (16:50 +0900)]
[RAMEN9610-14252] [9610] usb: phy: add iounmap and NULL check of ioremap

Change-Id: Ieb62e64bfd9ff925740b02197cdbe8b0d0928899
Signed-off-by: Daehwan Jung <dh10.jung@samsung.com>
5 years ago[RAMEN9610-14249][9610] drivers: battery: update pre-processor for small charger
Keunho Hwang [Mon, 8 Apr 2019 02:14:56 +0000 (11:14 +0900)]
[RAMEN9610-14249][9610] drivers: battery: update pre-processor for small charger

Change-Id: Ie83dd4460dc8efc87abbf666f3ce699d06f6e181
Signed-off-by: Keunho Hwang <keunho.hwang@samsung.com>
5 years ago[RAMEN9610-14248] [9610] extcon: madera: Changed the order of the jack detection...
ShinHyung [Mon, 8 Apr 2019 02:40:58 +0000 (11:40 +0900)]
[RAMEN9610-14248] [9610] extcon: madera: Changed the order of the jack detection event reporting.

-Problem: Disconnecting the headset during music playback causes noise.

-Reason:  The problem is caused by the difference between the Audio Codec jack detection reporting
and the implementation of the Android wiredaccessary manager.

-Solution: Changed the order of the jack detection event reporting.

Change-Id: Ifc1cbfdac3abe199f2740135d31669cbc6241a18
Signed-off-by: ShinHyung <s47.kang@samsung.com>
5 years ago[RAMEN9610-14248][9610] extcon: madera: modified the impedence of LINE OUT
ShinHyung [Thu, 7 Mar 2019 02:01:04 +0000 (11:01 +0900)]
[RAMEN9610-14248][9610] extcon: madera: modified the impedence of LINE OUT

Change-Id: I30038c65cceac7bb338f250d0cadd0de637d7b5c
Signed-off-by: ShinHyung <s47.kang@samsung.com>
5 years ago[RAMEN9610-14248] extcon: line out support
Satish Kumar Reddy [Sat, 23 Feb 2019 04:06:21 +0000 (13:06 +0900)]
[RAMEN9610-14248] extcon: line out  support

Change-Id: Ic5ea097aa97305a093076ce5ebc5e36ad926fabb
Signed-off-by: Satish Kumar Reddy <palli.satish@samsung.com>
5 years ago[RAMEN9610-14248] abox: lineout device added in sound type
Satish Kumar Reddy [Sat, 23 Feb 2019 04:08:02 +0000 (13:08 +0900)]
[RAMEN9610-14248] abox: lineout device added in sound type

Change-Id: Iaf4bf28ed0ff8d5d824e5cac2f5484739181e458
Signed-off-by: Satish Kumar Reddy <palli.satish@samsung.com>
5 years ago[RAMEN9610-14247] [COMMON][9610] drivers : fix sink vbus from 4.5v to 3.5v
Junhan Bae [Mon, 8 Apr 2019 03:38:59 +0000 (12:38 +0900)]
[RAMEN9610-14247] [COMMON][9610] drivers : fix sink vbus from 4.5v to 3.5v

Change-Id: I3103b616d0abc7b98a2f3b0ecc642fd3d2bfd3da
Signed-off-by: Junhan Bae <junhan84.bae@samsung.com>
5 years ago[ERD][APR-103] [COMMON]Modify DT for multi-os
Sukmin Kang [Tue, 26 Mar 2019 04:46:08 +0000 (13:46 +0900)]
[ERD][APR-103] [COMMON]Modify DT for multi-os

Change-Id: Id23c028336dea47d4026172f1b757d9d3838f2c4

5 years ago[ERD][APR-103] [COMMON]chub: fix sendCmd error
Boojin Kim [Fri, 22 Feb 2019 13:59:55 +0000 (22:59 +0900)]
[ERD][APR-103] [COMMON]chub: fix sendCmd error

This patch fix sendCmd error by wakelock timeout

Change-Id: I32679e13dbee9446cb4b5d124ca2713f28a1f008
Signed-off-by: Boojin Kim <boojin.kim@samsung.com>
5 years ago[ERD][APR-103] [COMMON]chub: fix kernel panic by runtime error
Boojin Kim [Tue, 12 Feb 2019 07:38:06 +0000 (16:38 +0900)]
[ERD][APR-103] [COMMON]chub: fix kernel panic by runtime error

Change-Id: Iec832588624a88bebbfb2231c3f2988c6ebe0dd9
Signed-off-by: Boojin Kim <boojin.kim@samsung.com>
5 years ago[ERD][APR-103] [COMMON]chub: ipc: fix ipc loss issue with ipc_read timeout
Boojin Kim [Thu, 7 Feb 2019 13:15:34 +0000 (22:15 +0900)]
[ERD][APR-103] [COMMON]chub: ipc: fix ipc loss issue with ipc_read timeout

Change-Id: I713acad026f9dbc1af401c24603ea9c74099ff84
Signed-off-by: Boojin Kim <boojin.kim@samsung.com>
5 years ago[ERD][APR-103] [COMMON]chub: ipc: change irq allocation scheme from round robin to...
Boojin Kim [Mon, 28 Jan 2019 01:50:28 +0000 (10:50 +0900)]
[ERD][APR-103] [COMMON]chub: ipc: change irq allocation scheme from round robin to scan

Change-Id: I5f66c936aa7bf482dd6b58e1fdfd73a131b7f365
Signed-off-by: Boojin Kim <boojin.kim@samsung.com>
5 years ago[ERD][APR-103] [COMMON]prevent copying ack signal into event packet
Sukwon Ryoo [Mon, 28 Jan 2019 09:24:16 +0000 (18:24 +0900)]
[ERD][APR-103] [COMMON]prevent copying ack signal into event packet

Change-Id: I04a9b94b1cd7e934e0d13a739753eca1236f65db
Signed-off-by: Sukwon Ryoo <sw.ryoo@samsung.com>
5 years ago[ERD][APR-103] [COMMON]chub: runtimelog supports newline
Boojin Kim [Thu, 17 Jan 2019 15:20:22 +0000 (00:20 +0900)]
[ERD][APR-103] [COMMON]chub: runtimelog supports newline

Change-Id: I89bd8cf65e36c3cc3786b840c4dd6e9e77f968d3
Signed-off-by: Boojin Kim <boojin.kim@samsung.com>
5 years ago[ERD][APR-103] [COMMON]chub: sensorlist fail fix
Boojin Kim [Sun, 6 Jan 2019 06:52:44 +0000 (15:52 +0900)]
[ERD][APR-103] [COMMON]chub: sensorlist fail fix

Change-Id: Ie7dc50179b1fe53fca82adcfb31ed77cd4e8db4c
Signed-off-by: Boojin Kim <boojin.kim@samsung.com>
5 years ago[ERD][APR-103] [COMMON]chub: update runtimelog
Boojin Kim [Fri, 28 Dec 2018 06:12:28 +0000 (15:12 +0900)]
[ERD][APR-103] [COMMON]chub: update runtimelog

Change-Id: If46dc6e92bfc6504d77eddf3052260354499a43e
Signed-off-by: Boojin Kim <boojin.kim@samsung.com>
5 years ago[ERD][APR-103] [COMMON]chub: ipc: don't use printf before logbuf setup
Boojin Kim [Thu, 27 Dec 2018 08:34:08 +0000 (17:34 +0900)]
[ERD][APR-103] [COMMON]chub: ipc: don't use printf before logbuf setup

Change-Id: I28bd553b93dee0f4a8a5927bb8210ed18889f68d
Signed-off-by: Boojin Kim <boojin.kim@samsung.com>
5 years ago[ERD][APR-103] [COMMON]chub: support runtimelog
Boojin Kim [Thu, 20 Dec 2018 04:14:38 +0000 (13:14 +0900)]
[ERD][APR-103] [COMMON]chub: support runtimelog

Change-Id: I4f67cdc83e86f9994e233dceb517ae00161343f0
Signed-off-by: Boojin Kim <boojin.kim@samsung.com>
5 years ago[ERD][APR-103] [COMMON]CHUB: skip os select after 1st boot
Sukwon Ryoo [Wed, 19 Dec 2018 04:41:12 +0000 (13:41 +0900)]
[ERD][APR-103] [COMMON]CHUB: skip os select after 1st boot

add character driver
get os number and modify os_name
if os_name is 0th or invalid, go to os select

Change-Id: If19182f1f2c1bd9a8ea022b6aee9263d240fb77a
Signed-off-by: Sukwon Ryoo <sw.ryoo@samsung.com>
5 years ago[ERD][APR-103] [COMMON]chub: enable force reset by sensor driver request
Boojin Kim [Wed, 12 Dec 2018 01:37:50 +0000 (10:37 +0900)]
[ERD][APR-103] [COMMON]chub: enable force reset by sensor driver request

Change-Id: Id7c3d4f764281b3a025dba08be3882dc521f7f12
Signed-off-by: Boojin Kim <boojin.kim@samsung.com>
5 years ago[ERD][APR-103] [COMMON]chub: synchronize the nanohub_open and chub poweron
Boojin Kim [Wed, 19 Dec 2018 05:24:40 +0000 (14:24 +0900)]
[ERD][APR-103] [COMMON]chub: synchronize the nanohub_open and chub poweron

Change-Id: I7e80c3ca80de63d4eccb690b146c483269ad6df0
Signed-off-by: Boojin Kim <boojin.kim@samsung.com>
5 years ago[ERD][APR-103] [COMMON]chub: add ipc magic
Boojin Kim [Tue, 11 Dec 2018 03:44:52 +0000 (12:44 +0900)]
[ERD][APR-103] [COMMON]chub: add ipc magic

Change-Id: I577b4e3d2e9cfcda3cfd30e3ded150b4d0b16a53
Signed-off-by: Boojin Kim <boojin.kim@samsung.com>
5 years ago[ERD][APR-103] [COMMON]chub: add slient reset for chub error
Boyoung [Mon, 10 Dec 2018 23:07:20 +0000 (08:07 +0900)]
[ERD][APR-103] [COMMON]chub: add slient reset for chub error

Change-Id: I18bdbc2ee03bde8cd7992e50c367db4652971fa1
Signed-off-by: Boyoung <eric.by.kim@samsung.com>
5 years ago[ERD][APR-103] [COMMON]chub: change name of kernel log flag to wake flag
Boojin Kim [Thu, 6 Dec 2018 04:17:56 +0000 (13:17 +0900)]
[ERD][APR-103] [COMMON]chub: change name of kernel log flag to wake flag

Change-Id: I6f5e1e936e8ea451695a7750c522d925669019b3
Signed-off-by: Sukwon Ryoo <sw.ryoo@samsung.com>
5 years ago[ERD][APR-103] chub: support active sensor
Boyoung [Thu, 6 Dec 2018 14:32:26 +0000 (23:32 +0900)]
[ERD][APR-103] chub: support active sensor

Change-Id: I87143d7dcd7685061e60f4989192e34f6e5eb2eb
Signed-off-by: Boojin Kim <boojin.kim@samsung.com>
5 years ago[ERD][APR-103] [COMMON]chub: ipc: add error handling
Boojin Kim [Wed, 28 Nov 2018 00:34:41 +0000 (09:34 +0900)]
[ERD][APR-103] [COMMON]chub: ipc: add error handling

Change-Id: Ic5dbf550e72d937386bd8884b811a6cb8f13582f
Signed-off-by: Boojin Kim <boojin.kim@samsung.com>
5 years ago[ERD][APR-103] [COMMON]chub: use chrehal io
Boyoung [Fri, 7 Dec 2018 12:58:07 +0000 (21:58 +0900)]
[ERD][APR-103] [COMMON]chub: use chrehal io

Change-Id: Ia99e73a31d98d4739efeac143a1cea34ae9a7f69
Signed-off-by: Boyoung <eric.by.kim@samsung.com>
5 years ago[ERD][APR-103] [COMMON]chub: increase chub fw error threshold
Boyoung [Fri, 7 Dec 2018 11:08:22 +0000 (20:08 +0900)]
[ERD][APR-103] [COMMON]chub: increase chub fw error threshold

chub sensor driver detects invalid error
if chub fw booting is delaied with multi-os booting

Change-Id: Ie3712367ad39b6b25062d605380b222017ce76b5
Signed-off-by: Boyoung <eric.by.kim@samsung.com>
5 years ago[ERD][APR-103] [COMMON]chub: ipc: add to check irq pending
Boojin Kim [Tue, 20 Nov 2018 05:15:37 +0000 (14:15 +0900)]
[ERD][APR-103] [COMMON]chub: ipc: add to check irq pending

Change-Id: Iaf4561cd3d0ed789f480b59ab4fdf39bc6345900
Signed-off-by: Boojin Kim <boojin.kim@samsung.com>
5 years ago[ERD][APR-103] [COMMON]chub: stop send message to AP in suspend mode
Boojin Kim [Fri, 16 Nov 2018 08:09:46 +0000 (17:09 +0900)]
[ERD][APR-103] [COMMON]chub: stop send message to AP in suspend mode

Change-Id: I4ce8006221e7ffe4c9db6f4a074d0609f185b1e4
Signed-off-by: Sukwon Ryoo <sw.ryoo@samsung.com>
5 years ago[ERD][APR-103] [COMMON]chub: suppport dump on reset
Boojin Kim [Mon, 12 Nov 2018 09:35:12 +0000 (18:35 +0900)]
[ERD][APR-103] [COMMON]chub: suppport dump on reset

chub driver requests to dump to sensor hal

Change-Id: I97650a22c686ae72e932311d2db973c09c4b9167
Signed-off-by: Boojin Kim <boojin.kim@samsung.com>
5 years ago[ERD][APR-103] [COMMON]chub: fix wrong confict fix
Boojin Kim [Wed, 21 Nov 2018 01:53:51 +0000 (10:53 +0900)]
[ERD][APR-103] [COMMON]chub: fix wrong confict fix

This patch recoveries '[9610] chub: ipc: version 181024' patch
that is removed by 'chub : support multi-os for various sensors' patch confict.

Change-Id: I5ae5f6ad21c2af3ddf75382ca5576e05518b5ea2
Signed-off-by: Boojin Kim <boojin.kim@samsung.com>
5 years ago[ERD][APR-103] [COMMON]chub : support multi-os for various sensors
Boyoung [Tue, 23 Oct 2018 10:54:46 +0000 (19:54 +0900)]
[ERD][APR-103] [COMMON]chub : support multi-os for various sensors

Change-Id: I0768a2ba0d87fed58ce7e18877e60d5583f53529
Signed-off-by: Boyoung <eric.by.kim@samsung.com>
5 years agoMerge 4.14.113 into android-4.14-p
Greg Kroah-Hartman [Sat, 20 Apr 2019 13:56:13 +0000 (15:56 +0200)]
Merge 4.14.113 into android-4.14-p

Changes in 4.14.113
ARC: u-boot args: check that magic number is correct
arc: hsdk_defconfig: Enable CONFIG_BLK_DEV_RAM
perf/core: Restore mmap record type correctly
ext4: add missing brelse() in add_new_gdb_meta_bg()
ext4: report real fs size after failed resize
ALSA: echoaudio: add a check for ioremap_nocache
ALSA: sb8: add a check for request_region
auxdisplay: hd44780: Fix memory leak on ->remove()
IB/mlx4: Fix race condition between catas error reset and aliasguid flows
mmc: davinci: remove extraneous __init annotation
ALSA: opl3: fix mismatch between snd_opl3_drum_switch definition and declaration
thermal/intel_powerclamp: fix __percpu declaration of worker_data
thermal: bcm2835: Fix crash in bcm2835_thermal_debugfs
thermal/int340x_thermal: Add additional UUIDs
thermal/int340x_thermal: fix mode setting
thermal/intel_powerclamp: fix truncated kthread name
scsi: iscsi: flush running unbind operations when removing a session
x86/mm: Don't leak kernel addresses
tools/power turbostat: return the exit status of a command
perf list: Don't forget to drop the reference to the allocated thread_map
perf config: Fix an error in the config template documentation
perf config: Fix a memory leak in collect_config()
perf build-id: Fix memory leak in print_sdt_events()
perf top: Fix error handling in cmd_top()
perf hist: Add missing map__put() in error case
perf evsel: Free evsel->counts in perf_evsel__exit()
perf tests: Fix a memory leak of cpu_map object in the openat_syscall_event_on_all_cpus test
perf tests: Fix memory leak by expr__find_other() in test__expr()
perf tests: Fix a memory leak in test__perf_evsel__tp_sched_test()
irqchip/mbigen: Don't clear eventid when freeing an MSI
x86/hpet: Prevent potential NULL pointer dereference
x86/cpu/cyrix: Use correct macros for Cyrix calls on Geode processors
drm/nouveau/debugfs: Fix check of pm_runtime_get_sync failure
iommu/vt-d: Check capability before disabling protected memory
x86/hw_breakpoints: Make default case in hw_breakpoint_arch_parse() return an error
fix incorrect error code mapping for OBJECTID_NOT_FOUND
ext4: prohibit fstrim in norecovery mode
gpio: pxa: handle corner case of unprobed device
rsi: improve kernel thread handling to fix kernel panic
9p: do not trust pdu content for stat item size
9p locks: add mount option for lock retry interval
f2fs: fix to do sanity check with current segment number
netfilter: xt_cgroup: shrink size of v2 path
serial: uartps: console_setup() can't be placed to init section
powerpc/pseries: Remove prrn_work workqueue
media: au0828: cannot kfree dev before usb disconnect
HID: i2c-hid: override HID descriptors for certain devices
ARM: samsung: Limit SAMSUNG_PM_CHECK config option to non-Exynos platforms
usbip: fix vhci_hcd controller counting
ACPI / SBS: Fix GPE storm on recent MacBookPro's
KVM: nVMX: restore host state in nested_vmx_vmexit for VMFail
compiler.h: update definition of unreachable()
cifs: fallback to older infolevels on findfirst queryinfo retry
kernel: hung_task.c: disable on suspend
crypto: sha256/arm - fix crash bug in Thumb2 build
crypto: sha512/arm - fix crash bug in Thumb2 build
iommu/dmar: Fix buffer overflow during PCI bus notification
soc/tegra: pmc: Drop locking from tegra_powergate_is_powered()
lkdtm: Print real addresses
lkdtm: Add tests for NULL pointer dereference
drm/panel: panel-innolux: set display off in innolux_panel_unprepare
crypto: axis - fix for recursive locking from bottom half
Revert "ACPI / EC: Remove old CLEAR_ON_RESUME quirk"
coresight: cpu-debug: Support for CA73 CPUs
drm/nouveau/volt/gf117: fix speedo readout register
ARM: 8839/1: kprobe: make patch_lock a raw_spinlock_t
drm/amdkfd: use init_mqd function to allocate object for hid_mqd (CI)
appletalk: Fix use-after-free in atalk_proc_exit
lib/div64.c: off by one in shift
include/linux/swap.h: use offsetof() instead of custom __swapoffset macro
bpf: fix use after free in bpf_evict_inode
dm: disable CRYPTO_TFM_REQ_MAY_SLEEP to fix a GFP_KERNEL recursion deadlock
bpf: reduce verifier memory consumption
bpf: fix verifier memory leaks
bpf: fix verifier NULL pointer dereference
bpf: fix stack state printing in verifier log
bpf: move {prev_,}insn_idx into verifier env
bpf: move tmp variable into ax register in interpreter
bpf: enable access to ax register also from verifier rewrite
bpf: restrict map value pointer arithmetic for unprivileged
bpf: restrict stack pointer arithmetic for unprivileged
bpf: restrict unknown scalars of mixed signed bounds for unprivileged
bpf: fix check_map_access smin_value test when pointer contains offset
bpf: prevent out of bounds speculation on pointer arithmetic
bpf: fix sanitation of alu op with pointer / scalar type from different paths
bpf: fix inner map masking to prevent oob under speculation
bpf: do not restore dst_reg when cur_state is freed
bpf: fix sanitation rewrite in case of non-pointers
bpf: Fix selftests are changes for CVE 2019-7308
net: stmmac: Set dma ring length before enabling the DMA
mm: hide incomplete nr_indirectly_reclaimable in sysfs
appletalk: Fix compile regression
Linux 4.14.113

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
5 years agoLinux 4.14.113
Greg Kroah-Hartman [Sat, 20 Apr 2019 07:15:10 +0000 (09:15 +0200)]
Linux 4.14.113

5 years agoappletalk: Fix compile regression
Arnd Bergmann [Wed, 6 Mar 2019 10:52:36 +0000 (11:52 +0100)]
appletalk: Fix compile regression

[ Upstream commit 27da0d2ef998e222a876c0cec72aa7829a626266 ]

A bugfix just broke compilation of appletalk when CONFIG_SYSCTL
is disabled:

In file included from net/appletalk/ddp.c:65:
net/appletalk/ddp.c: In function 'atalk_init':
include/linux/atalk.h:164:34: error: expected expression before 'do'
 #define atalk_register_sysctl()  do { } while(0)
                                  ^~
net/appletalk/ddp.c:1934:7: note: in expansion of macro 'atalk_register_sysctl'
  rc = atalk_register_sysctl();

This is easier to avoid by using conventional inline functions
as stubs rather than macros. The header already has inline
functions for other purposes, so I'm changing over all the
macros for consistency.

Fixes: 6377f787aeb9 ("appletalk: Fix use-after-free in atalk_proc_exit")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
5 years agomm: hide incomplete nr_indirectly_reclaimable in sysfs
Konstantin Khlebnikov [Tue, 9 Apr 2019 17:05:43 +0000 (20:05 +0300)]
mm: hide incomplete nr_indirectly_reclaimable in sysfs

In upstream branch this fixed by commit b29940c1abd7 ("mm: rename and
change semantics of nr_indirectly_reclaimable_bytes").

This fixes /sys/devices/system/node/node*/vmstat format:

...
nr_dirtied 6613155
nr_written 5796802
 11089216
...

Cc: <stable@vger.kernel.org> # 4.19.y
Fixes: 7aaf77272358 ("mm: don't show nr_indirectly_reclaimable in /proc/vmstat")
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Cc: Roman Gushchin <guro@fb.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agonet: stmmac: Set dma ring length before enabling the DMA
Lars Persson [Mon, 15 Apr 2019 07:49:47 +0000 (09:49 +0200)]
net: stmmac: Set dma ring length before enabling the DMA

This was fixed in upstream by commit 7d9e6c5afab6 ("net: stmmac: Integrate
XGMAC into main driver flow") that is a new feature commit.

We found a race condition in the DMA init sequence that hits if the
PHY already has link up during stmmac_hw_setup. Since the ring length
was programmed after enabling the RX path, we might receive a packet
before the correct ring length is programmed. When that happened we
could not get reliable interrupts for DMA RX and the MTL complained
about RX FIFO overrun.

Signed-off-by: Lars Persson <larper@axis.com>
Cc: stable@vger.kernel.org # 4.14.x
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Cc: Jose Abreu <joabreu@synopsys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agobpf: Fix selftests are changes for CVE 2019-7308
Balbir Singh [Wed, 3 Apr 2019 18:39:17 +0000 (18:39 +0000)]
bpf: Fix selftests are changes for CVE 2019-7308

The changes to fix the CVE 2019-7308 make the bpf verifier stricter
with respect to operations that were allowed earlier in unprivileged
mode. Fixup the test cases so that the error messages now correctly
reflect pointer arithmetic going out of range for tests.

Signed-off-by: Balbir Singh <sblbir@amzn.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agobpf: fix sanitation rewrite in case of non-pointers
Daniel Borkmann [Wed, 3 Apr 2019 18:39:16 +0000 (18:39 +0000)]
bpf: fix sanitation rewrite in case of non-pointers

commit 3612af783cf52c74a031a2f11b82247b2599d3cd upstream.

Marek reported that he saw an issue with the below snippet in that
timing measurements where off when loaded as unpriv while results
were reasonable when loaded as privileged:

    [...]
    uint64_t a = bpf_ktime_get_ns();
    uint64_t b = bpf_ktime_get_ns();
    uint64_t delta = b - a;
    if ((int64_t)delta > 0) {
    [...]

Turns out there is a bug where a corner case is missing in the fix
d3bd7413e0ca ("bpf: fix sanitation of alu op with pointer / scalar
type from different paths"), namely fixup_bpf_calls() only checks
whether aux has a non-zero alu_state, but it also needs to test for
the case of BPF_ALU_NON_POINTER since in both occasions we need to
skip the masking rewrite (as there is nothing to mask).

Fixes: d3bd7413e0ca ("bpf: fix sanitation of alu op with pointer / scalar type from different paths")
Reported-by: Marek Majkowski <marek@cloudflare.com>
Reported-by: Arthur Fabre <afabre@cloudflare.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/netdev/CAJPywTJqP34cK20iLM5YmUMz9KXQOdu1-+BZrGMAGgLuBWz7fg@mail.gmail.com/T/
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Balbir Singh <sblbir@amzn.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agobpf: do not restore dst_reg when cur_state is freed
Xu Yu [Wed, 3 Apr 2019 18:39:15 +0000 (18:39 +0000)]
bpf: do not restore dst_reg when cur_state is freed

commit 0803278b0b4d8eeb2b461fb698785df65a725d9e upstream.

Syzkaller hit 'KASAN: use-after-free Write in sanitize_ptr_alu' bug.

Call trace:

  dump_stack+0xbf/0x12e
  print_address_description+0x6a/0x280
  kasan_report+0x237/0x360
  sanitize_ptr_alu+0x85a/0x8d0
  adjust_ptr_min_max_vals+0x8f2/0x1ca0
  adjust_reg_min_max_vals+0x8ed/0x22e0
  do_check+0x1ca6/0x5d00
  bpf_check+0x9ca/0x2570
  bpf_prog_load+0xc91/0x1030
  __se_sys_bpf+0x61e/0x1f00
  do_syscall_64+0xc8/0x550
  entry_SYSCALL_64_after_hwframe+0x49/0xbe

Fault injection trace:

  kfree+0xea/0x290
  free_func_state+0x4a/0x60
  free_verifier_state+0x61/0xe0
  push_stack+0x216/0x2f0           <- inject failslab
  sanitize_ptr_alu+0x2b1/0x8d0
  adjust_ptr_min_max_vals+0x8f2/0x1ca0
  adjust_reg_min_max_vals+0x8ed/0x22e0
  do_check+0x1ca6/0x5d00
  bpf_check+0x9ca/0x2570
  bpf_prog_load+0xc91/0x1030
  __se_sys_bpf+0x61e/0x1f00
  do_syscall_64+0xc8/0x550
  entry_SYSCALL_64_after_hwframe+0x49/0xbe

When kzalloc() fails in push_stack(), free_verifier_state() will free
current verifier state. As push_stack() returns, dst_reg was restored
if ptr_is_dst_reg is false. However, as member of the cur_state,
dst_reg is also freed, and error occurs when dereferencing dst_reg.
Simply fix it by testing ret of push_stack() before restoring dst_reg.

Fixes: 979d63d50c0c ("bpf: prevent out of bounds speculation on pointer arithmetic")
Signed-off-by: Xu Yu <xuyu@linux.alibaba.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agobpf: fix inner map masking to prevent oob under speculation
Daniel Borkmann [Wed, 3 Apr 2019 18:39:14 +0000 (18:39 +0000)]
bpf: fix inner map masking to prevent oob under speculation

commit 9d5564ddcf2a0f5ba3fa1c3a1f8a1b59ad309553 upstream.

During review I noticed that inner meta map setup for map in
map is buggy in that it does not propagate all needed data
from the reference map which the verifier is later accessing.

In particular one such case is index masking to prevent out of
bounds access under speculative execution due to missing the
map's unpriv_array/index_mask field propagation. Fix this such
that the verifier is generating the correct code for inlined
lookups in case of unpriviledged use.

Before patch (test_verifier's 'map in map access' dump):

  # bpftool prog dump xla id 3
     0: (62) *(u32 *)(r10 -4) = 0
     1: (bf) r2 = r10
     2: (07) r2 += -4
     3: (18) r1 = map[id:4]
     5: (07) r1 += 272                |
     6: (61) r0 = *(u32 *)(r2 +0)     |
     7: (35) if r0 >= 0x1 goto pc+6   | Inlined map in map lookup
     8: (54) (u32) r0 &= (u32) 0      | with index masking for
     9: (67) r0 <<= 3                 | map->unpriv_array.
    10: (0f) r0 += r1                 |
    11: (79) r0 = *(u64 *)(r0 +0)     |
    12: (15) if r0 == 0x0 goto pc+1   |
    13: (05) goto pc+1                |
    14: (b7) r0 = 0                   |
    15: (15) if r0 == 0x0 goto pc+11
    16: (62) *(u32 *)(r10 -4) = 0
    17: (bf) r2 = r10
    18: (07) r2 += -4
    19: (bf) r1 = r0
    20: (07) r1 += 272                |
    21: (61) r0 = *(u32 *)(r2 +0)     | Index masking missing (!)
    22: (35) if r0 >= 0x1 goto pc+3   | for inner map despite
    23: (67) r0 <<= 3                 | map->unpriv_array set.
    24: (0f) r0 += r1                 |
    25: (05) goto pc+1                |
    26: (b7) r0 = 0                   |
    27: (b7) r0 = 0
    28: (95) exit

After patch:

  # bpftool prog dump xla id 1
     0: (62) *(u32 *)(r10 -4) = 0
     1: (bf) r2 = r10
     2: (07) r2 += -4
     3: (18) r1 = map[id:2]
     5: (07) r1 += 272                |
     6: (61) r0 = *(u32 *)(r2 +0)     |
     7: (35) if r0 >= 0x1 goto pc+6   | Same inlined map in map lookup
     8: (54) (u32) r0 &= (u32) 0      | with index masking due to
     9: (67) r0 <<= 3                 | map->unpriv_array.
    10: (0f) r0 += r1                 |
    11: (79) r0 = *(u64 *)(r0 +0)     |
    12: (15) if r0 == 0x0 goto pc+1   |
    13: (05) goto pc+1                |
    14: (b7) r0 = 0                   |
    15: (15) if r0 == 0x0 goto pc+12
    16: (62) *(u32 *)(r10 -4) = 0
    17: (bf) r2 = r10
    18: (07) r2 += -4
    19: (bf) r1 = r0
    20: (07) r1 += 272                |
    21: (61) r0 = *(u32 *)(r2 +0)     |
    22: (35) if r0 >= 0x1 goto pc+4   | Now fixed inlined inner map
    23: (54) (u32) r0 &= (u32) 0      | lookup with proper index masking
    24: (67) r0 <<= 3                 | for map->unpriv_array.
    25: (0f) r0 += r1                 |
    26: (05) goto pc+1                |
    27: (b7) r0 = 0                   |
    28: (b7) r0 = 0
    29: (95) exit

Fixes: b2157399cc98 ("bpf: prevent out-of-bounds speculation")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Vallish Vaidyeshwara <vallish@amazon.com>
Signed-off-by: Balbir Singh <sblbir@amzn.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agobpf: fix sanitation of alu op with pointer / scalar type from different paths
Daniel Borkmann [Wed, 3 Apr 2019 18:39:13 +0000 (18:39 +0000)]
bpf: fix sanitation of alu op with pointer / scalar type from different paths

commit d3bd7413e0ca40b60cf60d4003246d067cafdeda upstream.

While 979d63d50c0c ("bpf: prevent out of bounds speculation on pointer
arithmetic") took care of rejecting alu op on pointer when e.g. pointer
came from two different map values with different map properties such as
value size, Jann reported that a case was not covered yet when a given
alu op is used in both "ptr_reg += reg" and "numeric_reg += reg" from
different branches where we would incorrectly try to sanitize based
on the pointer's limit. Catch this corner case and reject the program
instead.

Fixes: 979d63d50c0c ("bpf: prevent out of bounds speculation on pointer arithmetic")
Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Vallish Vaidyeshwara <vallish@amazon.com>
Signed-off-by: Balbir Singh <sblbir@amzn.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agobpf: prevent out of bounds speculation on pointer arithmetic
Daniel Borkmann [Wed, 3 Apr 2019 18:39:12 +0000 (18:39 +0000)]
bpf: prevent out of bounds speculation on pointer arithmetic

commit 979d63d50c0c0f7bc537bf821e056cc9fe5abd38 upstream.

Jann reported that the original commit back in b2157399cc98
("bpf: prevent out-of-bounds speculation") was not sufficient
to stop CPU from speculating out of bounds memory access:
While b2157399cc98 only focussed on masking array map access
for unprivileged users for tail calls and data access such
that the user provided index gets sanitized from BPF program
and syscall side, there is still a more generic form affected
from BPF programs that applies to most maps that hold user
data in relation to dynamic map access when dealing with
unknown scalars or "slow" known scalars as access offset, for
example:

  - Load a map value pointer into R6
  - Load an index into R7
  - Do a slow computation (e.g. with a memory dependency) that
    loads a limit into R8 (e.g. load the limit from a map for
    high latency, then mask it to make the verifier happy)
  - Exit if R7 >= R8 (mispredicted branch)
  - Load R0 = R6[R7]
  - Load R0 = R6[R0]

For unknown scalars there are two options in the BPF verifier
where we could derive knowledge from in order to guarantee
safe access to the memory: i) While </>/<=/>= variants won't
allow to derive any lower or upper bounds from the unknown
scalar where it would be safe to add it to the map value
pointer, it is possible through ==/!= test however. ii) another
option is to transform the unknown scalar into a known scalar,
for example, through ALU ops combination such as R &= <imm>
followed by R |= <imm> or any similar combination where the
original information from the unknown scalar would be destroyed
entirely leaving R with a constant. The initial slow load still
precedes the latter ALU ops on that register, so the CPU
executes speculatively from that point. Once we have the known
scalar, any compare operation would work then. A third option
only involving registers with known scalars could be crafted
as described in [0] where a CPU port (e.g. Slow Int unit)
would be filled with many dependent computations such that
the subsequent condition depending on its outcome has to wait
for evaluation on its execution port and thereby executing
speculatively if the speculated code can be scheduled on a
different execution port, or any other form of mistraining
as described in [1], for example. Given this is not limited
to only unknown scalars, not only map but also stack access
is affected since both is accessible for unprivileged users
and could potentially be used for out of bounds access under
speculation.

In order to prevent any of these cases, the verifier is now
sanitizing pointer arithmetic on the offset such that any
out of bounds speculation would be masked in a way where the
pointer arithmetic result in the destination register will
stay unchanged, meaning offset masked into zero similar as
in array_index_nospec() case. With regards to implementation,
there are three options that were considered: i) new insn
for sanitation, ii) push/pop insn and sanitation as inlined
BPF, iii) reuse of ax register and sanitation as inlined BPF.

Option i) has the downside that we end up using from reserved
bits in the opcode space, but also that we would require
each JIT to emit masking as native arch opcodes meaning
mitigation would have slow adoption till everyone implements
it eventually which is counter-productive. Option ii) and iii)
have both in common that a temporary register is needed in
order to implement the sanitation as inlined BPF since we
are not allowed to modify the source register. While a push /
pop insn in ii) would be useful to have in any case, it
requires once again that every JIT needs to implement it
first. While possible, amount of changes needed would also
be unsuitable for a -stable patch. Therefore, the path which
has fewer changes, less BPF instructions for the mitigation
and does not require anything to be changed in the JITs is
option iii) which this work is pursuing. The ax register is
already mapped to a register in all JITs (modulo arm32 where
it's mapped to stack as various other BPF registers there)
and used in constant blinding for JITs-only so far. It can
be reused for verifier rewrites under certain constraints.
The interpreter's tmp "register" has therefore been remapped
into extending the register set with hidden ax register and
reusing that for a number of instructions that needed the
prior temporary variable internally (e.g. div, mod). This
allows for zero increase in stack space usage in the interpreter,
and enables (restricted) generic use in rewrites otherwise as
long as such a patchlet does not make use of these instructions.
The sanitation mask is dynamic and relative to the offset the
map value or stack pointer currently holds.

There are various cases that need to be taken under consideration
for the masking, e.g. such operation could look as follows:
ptr += val or val += ptr or ptr -= val. Thus, the value to be
sanitized could reside either in source or in destination
register, and the limit is different depending on whether
the ALU op is addition or subtraction and depending on the
current known and bounded offset. The limit is derived as
follows: limit := max_value_size - (smin_value + off). For
subtraction: limit := umax_value + off. This holds because
we do not allow any pointer arithmetic that would
temporarily go out of bounds or would have an unknown
value with mixed signed bounds where it is unclear at
verification time whether the actual runtime value would
be either negative or positive. For example, we have a
derived map pointer value with constant offset and bounded
one, so limit based on smin_value works because the verifier
requires that statically analyzed arithmetic on the pointer
must be in bounds, and thus it checks if resulting
smin_value + off and umax_value + off is still within map
value bounds at time of arithmetic in addition to time of
access. Similarly, for the case of stack access we derive
the limit as follows: MAX_BPF_STACK + off for subtraction
and -off for the case of addition where off := ptr_reg->off +
ptr_reg->var_off.value. Subtraction is a special case for
the masking which can be in form of ptr += -val, ptr -= -val,
or ptr -= val. In the first two cases where we know that
the value is negative, we need to temporarily negate the
value in order to do the sanitation on a positive value
where we later swap the ALU op, and restore original source
register if the value was in source.

The sanitation of pointer arithmetic alone is still not fully
sufficient as is, since a scenario like the following could
happen ...

  PTR += 0x1000 (e.g. K-based imm)
  PTR -= BIG_NUMBER_WITH_SLOW_COMPARISON
  PTR += 0x1000
  PTR -= BIG_NUMBER_WITH_SLOW_COMPARISON
  [...]

... which under speculation could end up as ...

  PTR += 0x1000
  PTR -= 0 [ truncated by mitigation ]
  PTR += 0x1000
  PTR -= 0 [ truncated by mitigation ]
  [...]

... and therefore still access out of bounds. To prevent such
case, the verifier is also analyzing safety for potential out
of bounds access under speculative execution. Meaning, it is
also simulating pointer access under truncation. We therefore
"branch off" and push the current verification state after the
ALU operation with known 0 to the verification stack for later
analysis. Given the current path analysis succeeded it is
likely that the one under speculation can be pruned. In any
case, it is also subject to existing complexity limits and
therefore anything beyond this point will be rejected. In
terms of pruning, it needs to be ensured that the verification
state from speculative execution simulation must never prune
a non-speculative execution path, therefore, we mark verifier
state accordingly at the time of push_stack(). If verifier
detects out of bounds access under speculative execution from
one of the possible paths that includes a truncation, it will
reject such program.

Given we mask every reg-based pointer arithmetic for
unprivileged programs, we've been looking into how it could
affect real-world programs in terms of size increase. As the
majority of programs are targeted for privileged-only use
case, we've unconditionally enabled masking (with its alu
restrictions on top of it) for privileged programs for the
sake of testing in order to check i) whether they get rejected
in its current form, and ii) by how much the number of
instructions and size will increase. We've tested this by
using Katran, Cilium and test_l4lb from the kernel selftests.
For Katran we've evaluated balancer_kern.o, Cilium bpf_lxc.o
and an older test object bpf_lxc_opt_-DUNKNOWN.o and l4lb
we've used test_l4lb.o as well as test_l4lb_noinline.o. We
found that none of the programs got rejected by the verifier
with this change, and that impact is rather minimal to none.
balancer_kern.o had 13,904 bytes (1,738 insns) xlated and
7,797 bytes JITed before and after the change. Most complex
program in bpf_lxc.o had 30,544 bytes (3,817 insns) xlated
and 18,538 bytes JITed before and after and none of the other
tail call programs in bpf_lxc.o had any changes either. For
the older bpf_lxc_opt_-DUNKNOWN.o object we found a small
increase from 20,616 bytes (2,576 insns) and 12,536 bytes JITed
before to 20,664 bytes (2,582 insns) and 12,558 bytes JITed
after the change. Other programs from that object file had
similar small increase. Both test_l4lb.o had no change and
remained at 6,544 bytes (817 insns) xlated and 3,401 bytes
JITed and for test_l4lb_noinline.o constant at 5,080 bytes
(634 insns) xlated and 3,313 bytes JITed. This can be explained
in that LLVM typically optimizes stack based pointer arithmetic
by using K-based operations and that use of dynamic map access
is not overly frequent. However, in future we may decide to
optimize the algorithm further under known guarantees from
branch and value speculation. Latter seems also unclear in
terms of prediction heuristics that today's CPUs apply as well
as whether there could be collisions in e.g. the predictor's
Value History/Pattern Table for triggering out of bounds access,
thus masking is performed unconditionally at this point but could
be subject to relaxation later on. We were generally also
brainstorming various other approaches for mitigation, but the
blocker was always lack of available registers at runtime and/or
overhead for runtime tracking of limits belonging to a specific
pointer. Thus, we found this to be minimally intrusive under
given constraints.

With that in place, a simple example with sanitized access on
unprivileged load at post-verification time looks as follows:

  # bpftool prog dump xlated id 282
  [...]
  28: (79) r1 = *(u64 *)(r7 +0)
  29: (79) r2 = *(u64 *)(r7 +8)
  30: (57) r1 &= 15
  31: (79) r3 = *(u64 *)(r0 +4608)
  32: (57) r3 &= 1
  33: (47) r3 |= 1
  34: (2d) if r2 > r3 goto pc+19
  35: (b4) (u32) r11 = (u32) 20479  |
  36: (1f) r11 -= r2                | Dynamic sanitation for pointer
  37: (4f) r11 |= r2                | arithmetic with registers
  38: (87) r11 = -r11               | containing bounded or known
  39: (c7) r11 s>>= 63              | scalars in order to prevent
  40: (5f) r11 &= r2                | out of bounds speculation.
  41: (0f) r4 += r11                |
  42: (71) r4 = *(u8 *)(r4 +0)
  43: (6f) r4 <<= r1
  [...]

For the case where the scalar sits in the destination register
as opposed to the source register, the following code is emitted
for the above example:

  [...]
  16: (b4) (u32) r11 = (u32) 20479
  17: (1f) r11 -= r2
  18: (4f) r11 |= r2
  19: (87) r11 = -r11
  20: (c7) r11 s>>= 63
  21: (5f) r2 &= r11
  22: (0f) r2 += r0
  23: (61) r0 = *(u32 *)(r2 +0)
  [...]

JIT blinding example with non-conflicting use of r10:

  [...]
   d5: je     0x0000000000000106    _
   d7: mov    0x0(%rax),%edi       |
   da: mov    $0xf153246,%r10d     | Index load from map value and
   e0: xor    $0xf153259,%r10      | (const blinded) mask with 0x1f.
   e7: and    %r10,%rdi            |_
   ea: mov    $0x2f,%r10d          |
   f0: sub    %rdi,%r10            | Sanitized addition. Both use r10
   f3: or     %rdi,%r10            | but do not interfere with each
   f6: neg    %r10                 | other. (Neither do these instructions
   f9: sar    $0x3f,%r10           | interfere with the use of ax as temp
   fd: and    %r10,%rdi            | in interpreter.)
  100: add    %rax,%rdi            |_
  103: mov    0x0(%rdi),%eax
 [...]

Tested that it fixes Jann's reproducer, and also checked that test_verifier
and test_progs suite with interpreter, JIT and JIT with hardening enabled
on x86-64 and arm64 runs successfully.

  [0] Speculose: Analyzing the Security Implications of Speculative
      Execution in CPUs, Giorgi Maisuradze and Christian Rossow,
      https://arxiv.org/pdf/1801.04084.pdf

  [1] A Systematic Evaluation of Transient Execution Attacks and
      Defenses, Claudio Canella, Jo Van Bulck, Michael Schwarz,
      Moritz Lipp, Benjamin von Berg, Philipp Ortner, Frank Piessens,
      Dmitry Evtyushkin, Daniel Gruss,
      https://arxiv.org/pdf/1811.05441.pdf

Fixes: b2157399cc98 ("bpf: prevent out-of-bounds speculation")
Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Vallish Vaidyeshwara <vallish@amazon.com>
[some checkpatch cleanups and backported to 4.14 by sblbir]
Signed-off-by: Balbir Singh <sblbir@amzn.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>