Jiapeng Zhong
f0b16e4670
FROMGIT: drivers/usb/gadget/udc: Assign boolean values to a bool variable
...
Fix the following coccicheck warnings:
./drivers/usb/gadget/udc/udc-xilinx.c:1957:2-18: WARNING:
Assignment of 0/1 to bool variable.
Reported-by: Abaci Robot <abaci@linux.alibaba.com >
Acked-by: Felipe Balbi <balbi@kernel.org >
Signed-off-by: Jiapeng Zhong <abaci-bugfix@linux.alibaba.com >
Link: https://lore.kernel.org/r/1610615002-66235-1-git-send-email-abaci-bugfix@linux.alibaba.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
(cherry picked from commit c86cad04dc
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com >
Change-Id: I148300582c77999e4e859ce68dfea426c513718b
2021-01-20 15:30:28 +01:00
Mauro Carvalho Chehab
857bfabcaa
FROMGIT: USB: dwc3: document gadget_max_speed
...
This new field was added to struct dwc3_scratchpad_array, but
a documentation for it was missed:
../drivers/usb/dwc3/core.h:1259: warning: Function parameter or member 'gadget_max_speed' not described in 'dwc3'
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au >
Acked-by: Felipe Balbi <balbi@kernel.org >
Link: https://lore.kernel.org/r/e9332e31bec9bcead2c7ced2b25462120488ca85.1610610444.git.mchehab+huawei@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
(cherry picked from commit 5dc71f1eb8
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com >
Change-Id: I284073e4b654c441853baf6d41c420030518326d
2021-01-20 15:30:01 +01:00
Thinh Nguyen
98a0696b7e
FROMGIT: usb: dwc3: gadget: Disable Vendor Test LMP Received event
...
Some users questioned why Vendor Test LMP Received event was enabled.
The driver currently doesn't handle this event. Let's disable it to
avoid confusion.
Acked-by: Felipe Balbi <balbi@kernel.org >
Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com >
Link: https://lore.kernel.org/r/4e785ba5d5e95801b6fcf96116f6090216e70760.1610596478.git.Thinh.Nguyen@synopsys.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
(cherry picked from commit 132ee0da6e
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com >
Change-Id: I9c9ca7c84a07cc48fefc07491b2879d3d24a4aef
2021-01-20 15:29:56 +01:00
Amelie Delaunay
7c3a4e6024
FROMGIT: usb: dwc2: disable Link Power Management on STM32MP15 HS OTG
...
Link Power Management (LPM) on STM32MP15 OTG HS encounters instabilities
with some Host controllers. OTG core fails to exit L1 state in 200us:
"dwc2 49000000.usb-otg: Failed to exit L1 sleep state in 200us."
Then the device is still not enumerated.
To avoid this issue, disable Link Power Management on STM32MP15 HS OTG.
Acked-by: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com >
Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com >
Link: https://lore.kernel.org/r/20210105094855.30763-4-amelie.delaunay@foss.st.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
(cherry picked from commit 53febc9569
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com >
Change-Id: I3fabc7ac3fc555d9e526a1ecda6dab3a20206162
2021-01-20 15:28:10 +01:00
Amelie Delaunay
d19c6bfe52
FROMGIT: usb: dwc2: enable FS/LS PHY clock select on STM32MP15 FS OTG
...
When the core is in FS host mode, using the FS transceiver, and a Low-Speed
device is connected, transceiver clock is 6Mhz.
So, to support Low-Speed devices, enable support of FS/LS Low Power mode,
so that the PHY supplies a 6 MHz clock during Low-Speed mode.
Acked-by: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com >
Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com >
Link: https://lore.kernel.org/r/20210105094855.30763-3-amelie.delaunay@foss.st.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
(cherry picked from commit f228cb27c5
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com >
Change-Id: I2afe995aa0eb3b2c3f1e271f86bb44784a26dda8
2021-01-20 15:27:59 +01:00
Amelie Delaunay
c62ddeeac8
FROMGIT: usb: dwc2: set ahbcfg parameter for STM32MP15 OTG HS and FS
...
STM32MP15 ahbcfg register default value sets Burst length/type (HBSTLEN)
to Single (32-bit accesses on AHB), which is not recommended, according
to STM32MP157 Reference manual [1].
This patch sets Burst length/type (HBSTLEN) so that bus transactions
target 16x32 bit accesses. This improves OTG controller performance.
[1] https://www.st.com/resource/en/reference_manual/dm00327659.pdf , p.3149
Acked-by: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com >
Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com >
Link: https://lore.kernel.org/r/20210105094855.30763-2-amelie.delaunay@foss.st.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
(cherry picked from commit 2979ee7a91
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com >
Change-Id: I88c6bc4e866ec5f44dc178cadde59bba447f3cca
2021-01-20 15:27:44 +01:00
Andy Shevchenko
56840bcddd
FROMGIT: usb: dwc3: Simplify with dev_err_probe()
...
Common pattern of handling deferred probe can be simplified with
dev_err_probe(). Less code and the error value gets printed.
Acked-by: Felipe Balbi <balbi@kernel.org >
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com >
Link: https://lore.kernel.org/r/20210111135458.57084-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
(cherry picked from commit 0c0a20f6da
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com >
Change-Id: I5a9d1b5c5bda75a153681cf64690242ee9a0a7bf
2021-01-20 15:27:36 +01:00
Andy Shevchenko
ca08536f9b
FROMGIT: usb: dwc3: keystone: Simplify with dev_err_probe()
...
Common pattern of handling deferred probe can be simplified with
dev_err_probe(). Less code and the error value gets printed.
Acked-by: Felipe Balbi <balbi@kernel.org >
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com >
Link: https://lore.kernel.org/r/20210111135539.57234-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
(cherry picked from commit 370e3d5b71
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com >
Change-Id: I239315c1ad463e6fc0660adc788a6ec4f6057d1f
2021-01-20 15:27:26 +01:00
Thinh Nguyen
b013254308
FROMGIT: usb: udc: core: Introduce started state
...
For some UDCs, the initialization sequence by udc_start() should not be
repeated until it is properly cleaned up with udc_stop() and vise versa.
We may run into some cleanup failure as seen with the DWC3 driver during
the irq cleanup. This issue can occur when the user triggers
soft-connect/soft-disconnect from the soft_connect sysfs. To avoid
adding checks to every UDC driver, at the UDC framework, introduce a
"started" state to track and prevent the UDC from repeating the
udc_start() and udc_stop() if it had already started/stopped.
Acked-by: Felipe Balbi <balbi@kernel.org >
Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com >
Link: https://lore.kernel.org/r/a7c4112fcd4dc2f0169af94a24f5685ca77f09fd.1610395599.git.Thinh.Nguyen@synopsys.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
(cherry picked from commit 49d08cfc78
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com >
Change-Id: Ifc92710e1d1b2ed6e3dfe0768efcb30a14a9a2ff
2021-01-20 15:27:11 +01:00
Yejune Deng
af76098432
FROMGIT: usb: dwc3: core: Replace devm_reset_control_array_get()
...
devm_reset_control_array_get_optional_shared() looks more readable
Reviewed-by: Dmitry Osipenko <digetx@gmail.com >
Acked-by: Felipe Balbi <balbi@kernel.org >
Signed-off-by: Yejune Deng <yejune.deng@gmail.com >
Link: https://lore.kernel.org/r/1604375863-6649-1-git-send-email-yejune.deng@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
(cherry picked from commit babbdfc9d2
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com >
Change-Id: Ibf16b9add396078bdde9d5e67a239b5df135fcdc
2021-01-20 15:26:15 +01:00
Michael R Sweet
2b37563a82
FROMGIT: USB: gadget: f_printer: set a default q_len
...
The usb_f_printer gadget driver uses a default q_len value of *0* which prevents
any IO from occurring. Moreover, once the driver is instantiated it is
impossible to change the q_len value.
The following patch uses a default q_len value of 10 which matches the legacy
g_printer gadget driver. This minimizes the possibility that you end up with a
non-working printer gadget. It is still possible to set the q_len to a
different value using the configfs path of the same name.
Signed-off-by: Michael R Sweet <msweet@msweet.org >
Link: https://lore.kernel.org/r/9DFB1605-63A5-46DB-A5A4-B59B315D8115@msweet.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
(cherry picked from commit ed054e4e95
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com >
Change-Id: I7d693fe9e39ba74acee11d54f4fc32d0d08b1afb
2021-01-20 15:25:58 +01:00
Wesley Cheng
7ee2c49fa9
FROMGIT: usb: dwc3: gadget: Preserve UDC max speed setting
...
The USB gadget/UDC driver can restrict the DWC3 controller speed using
dwc3_gadget_set_speed(). Store this setting into a variable, in order for
this setting to persist across controller resets due to runtime PM.
Signed-off-by: Wesley Cheng <wcheng@codeaurora.org >
Link: https://lore.kernel.org/r/1609283136-22140-3-git-send-email-wcheng@codeaurora.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
(cherry picked from commit 77adb8bdf4
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com >
Change-Id: I6780ac920eafff86e817b62528c4f16e35147ee2
2021-01-20 15:25:51 +01:00
Wesley Cheng
24c9628132
FROMGIT: usb: gadget: composite: Split composite reset and disconnect
...
Add a specific composite reset API to differentiate between disconnect and
reset events. This is needed for adjusting the current draw accordingly
based on the USB battery charging specification. The device is only allowed
to draw the 500/900 mA (HS/SS) while in the CONFIGURED state, and only 100 mA
in the connected and UNCONFIGURED state.
Reviewed-by: Peter Chen <peter.chen@nxp.com >
Signed-off-by: Wesley Cheng <wcheng@codeaurora.org >
Link: https://lore.kernel.org/r/1609283011-21997-3-git-send-email-wcheng@codeaurora.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
(cherry picked from commit 8280de6ab0
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com >
Change-Id: Ied00cca19025bc7c0e14f2376b4d6f2ace4beea6
2021-01-20 15:25:36 +01:00
Wesley Cheng
e2724acdda
FROMGIT: usb: dwc3: gadget: Introduce a DWC3 VBUS draw callback
...
Some devices support charging while in device mode. In these situations,
the USB gadget will notify the DWC3 gadget driver to modify the current
based on the enumeration and device state. The usb_phy_set_power() API
will allow external charger entities to adjust the charge current through
the notifier block.
Reviewed-by: Peter Chen <peter.chen@nxp.com >
Signed-off-by: Wesley Cheng <wcheng@codeaurora.org >
Link: https://lore.kernel.org/r/1609283011-21997-2-git-send-email-wcheng@codeaurora.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
(cherry picked from commit 82c46b8ed9
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com >
Change-Id: Ie24eec6d69a27e0de62d85a1dfacb225b6d6973f
2021-01-20 15:25:13 +01:00
Andy Shevchenko
ea1f75fb9f
FROMGIT: usb: gadget: u_serial: use %*ph to print small buffer
...
Use %*ph format to print small buffer as hex string.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com >
Link: https://lore.kernel.org/r/20201228200203.58525-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
(cherry picked from commit 9b3bd89842
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com >
Change-Id: I4d4adce9f9d453ba8ac4dd4607eea5fd2fbe732a
2021-01-20 15:24:54 +01:00
Li Jun
1af36b7299
FROMGIT: usb: dwc3: add imx8mp dwc3 glue layer driver
...
imx8mp SoC integrate dwc3 3.30b IP and has some customizations to
support low power, which has a seprated wakeup irq and additional
logic to wakeup usb from low power mode both for host mode and
device mode.
Signed-off-by: Li Jun <jun.li@nxp.com >
Link: https://lore.kernel.org/r/1609241866-9508-3-git-send-email-jun.li@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
(cherry picked from commit 6dd2565989
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com >
Change-Id: I326e7c9b5fe576f09f00539061531979001646b4
2021-01-20 15:24:43 +01:00
Li Jun
a3f57250db
FROMGIT: dt-bindings: usb: dwc3-imx8mp: add imx8mp dwc3 glue bindings
...
NXP imx8mp integrates 2 dwc3 3.30b IP and add some wakeup logic
to support low power mode, the glue layer is for this wakeup
functionality, which has a separated interrupt, can support
wakeup from U3 and connect events for host, and vbus wakeup for
device.
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org >
Reviewed-by: Rob Herring <robh@kernel.org >
Signed-off-by: Li Jun <jun.li@nxp.com >
Link: https://lore.kernel.org/r/1609241866-9508-2-git-send-email-jun.li@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
(cherry picked from commit d2a704e297
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com >
Change-Id: I050aec273c61527799551ec327c395b81025d88b
2021-01-20 15:24:16 +01:00
Sam Protsenko
59bf581f51
FROMGIT: usb: dwc3: drd: Improve dwc3_get_extcon() style
...
The previous change ("usb: dwc3: drd: Avoid error when extcon is
missing") changed the code flow in dwc3_get_extcon() function, leading
to unnecessary if-branch. This patch does housekeeping by reworking the
code for obtaining an extcon device from the "port" node.
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com >
Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org >
Link: https://lore.kernel.org/r/20201214110741.8512-3-semen.protsenko@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
(cherry picked from commit cb4d9b52ec
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com >
Change-Id: I6380571972975a022123b1915565a9e3728d1a05
2021-01-20 15:24:13 +01:00
Sam Protsenko
9efc9d0eb4
FROMGIT: usb: dwc3: drd: Avoid error when extcon is missing
...
If "port" node is missing in PHY controller node, dwc3_get_extcon()
isn't able to find extcon devices. This is perfectly fine in case when
"usb-role-switch" or OTG is used, but next misleading error message is
printed in that case, from of_graph_get_remote_node():
OF: graph: no port node found in /phy@1234abcd
Avoid printing that message by checking if the port node exists in PHY
node before calling of_graph_get_remote_node(). While at it, add the
comment from mentioned code block, explaining how checking the port
availability helps to avoid the misleading error.
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com >
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com >
Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org >
Link: https://lore.kernel.org/r/20201214110741.8512-2-semen.protsenko@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
(cherry picked from commit c824c73a5e
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com >
Change-Id: Icc9c4720b78d4c1bee56af8168e155f0f9dca4ec
2021-01-20 15:21:04 +01:00
Quentin Perret
1b73d0b49d
Revert "ANDROID: arm64: gki_defconfig: Disable VHE"
...
This reverts commit 65f5ed41f6 .
We need to bring VHE back to allow partners to use SVE. The Protected
KVM work will make use of [1] once it lands to force the kernel in nVHE
mode on VHE hardware.
[1] https://lore.kernel.org/r/20210118094533.2874082-1-maz@kernel.org
Bug: 177680998
Change-Id: I9d793724a05157285f439c42c9594a61b731b974
Signed-off-by: Quentin Perret <qperret@google.com >
2021-01-20 06:04:59 +00:00
Peter Collingbourne
c88c78c2d2
UPSTREAM: arm64: mte: optimize asynchronous tag check fault flag check
...
[ Upstream commit 739003c642 ]
We don't need to check for MTE support before checking the flag
because it can only be set if the hardware supports MTE. As a result
we can unconditionally check the flag bit which is expected to be in
a register and therefore the check can be done in a single instruction
instead of first needing to load the hwcaps.
On a DragonBoard 845c with a kernel built with CONFIG_ARM64_MTE=y with
the powersave governor this reduces the cost of a kernel entry/exit
(invalid syscall) from 465.1ns to 463.8ns.
Signed-off-by: Peter Collingbourne <pcc@google.com >
Link: https://lore.kernel.org/r/20201118032051.1405907-1-pcc@google.com
[catalin.marinas@arm.com: remove IS_ENABLED(CONFIG_ARM64_MTE)]
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Change-Id: Ifed200a8614e4c790cae1c7471439b12b4d4f8a0
2021-01-20 06:03:37 +00:00
Walter Wu
6a361ab4ec
UPSTREAM: kasan: fix null pointer dereference in kasan_record_aux_stack
...
[ Upstream commit 13384f6125 ]
Syzbot reported the following [1]:
BUG: kernel NULL pointer dereference, address: 0000000000000008
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
PGD 2d993067 P4D 2d993067 PUD 19a3c067 PMD 0
Oops: 0000 [#1 ] PREEMPT SMP KASAN
CPU: 1 PID: 3852 Comm: kworker/1:2 Not tainted 5.10.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events free_ipc
RIP: 0010:kasan_record_aux_stack+0x77/0xb0
Add null checking slab object from kasan_get_alloc_meta() in order to
avoid null pointer dereference.
[1] https://syzkaller.appspot.com/x/log.txt?x=10a82a50d00000
Link: https://lkml.kernel.org/r/20201228080018.23041-1-walter-zh.wu@mediatek.com
Signed-off-by: Walter Wu <walter-zh.wu@mediatek.com >
Suggested-by: Dmitry Vyukov <dvyukov@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Andrey Konovalov <andreyknvl@google.com >
Cc: Alexander Potapenko <glider@google.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: I7acca99b7bd58256843c7c4047fb84fe873bb9a1
2021-01-20 05:48:47 +00:00
Andrey Konovalov
26038d5d9d
UPSTREAM: kasan: update documentation
...
[ Upstream commit 625d867347 ]
This change updates KASAN documentation to reflect the addition of boot
parameters and also reworks and clarifies some of the existing sections,
in particular: defines what a memory granule is, mentions quarantine,
makes Kunit section more readable.
Link: https://lkml.kernel.org/r/748daf013e17d925b0fe00c1c3b5dce726dd2430.1606162397.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Reviewed-by: Dmitry Vyukov <dvyukov@google.com >
Reviewed-by: Marco Elver <elver@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Catalin Marinas <catalin.marinas@arm.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: I1a5c740910bba813ebd9ba055c6ff248387d872e
2021-01-19 21:47:32 -08:00
Andrey Konovalov
6d847f846e
UPSTREAM: kasan, mm: allow cache merging with no metadata
...
[ Upstream commit e86f8b09f2 ]
The reason cache merging is disabled with KASAN is because KASAN puts its
metadata right after the allocated object. When the merged caches have
slightly different sizes, the metadata ends up in different places, which
KASAN doesn't support.
It might be possible to adjust the metadata allocation algorithm and make
it friendly to the cache merging code. Instead this change takes a simpler
approach and allows merging caches when no metadata is present. Which is
the case for hardware tag-based KASAN with kasan.mode=prod.
Link: https://lkml.kernel.org/r/37497e940bfd4b32c0a93a702a9ae4cf061d5392.1606162397.git.andreyknvl@google.com
Co-developed-by: Vincenzo Frascino <Vincenzo.Frascino@arm.com >
Signed-off-by: Vincenzo Frascino <Vincenzo.Frascino@arm.com >
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Reviewed-by: Dmitry Vyukov <dvyukov@google.com >
Reviewed-by: Marco Elver <elver@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Catalin Marinas <catalin.marinas@arm.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: I11e722c583fbaa6d08bb726f2da684106859b86e
2021-01-19 21:47:32 -08:00
Andrey Konovalov
c5eb933f68
UPSTREAM: kasan: sanitize objects when metadata doesn't fit
...
[ Upstream commit 97593cad00 ]
KASAN marks caches that are sanitized with the SLAB_KASAN cache flag.
Currently if the metadata that is appended after the object (stores e.g.
stack trace ids) doesn't fit into KMALLOC_MAX_SIZE (can only happen with
SLAB, see the comment in the patch), KASAN turns off sanitization
completely.
With this change sanitization of the object data is always enabled.
However the metadata is only stored when it fits. Instead of checking for
SLAB_KASAN flag accross the code to find out whether the metadata is
there, use cache->kasan_info.alloc/free_meta_offset. As 0 can be a valid
value for free_meta_offset, introduce KASAN_NO_FREE_META as an indicator
that the free metadata is missing.
Without this change all sanitized KASAN objects would be put into
quarantine with generic KASAN. With this change, only the objects that
have metadata (i.e. when it fits) are put into quarantine, the rest is
freed right away.
Along the way rework __kasan_cache_create() and add claryfying comments.
Link: https://lkml.kernel.org/r/aee34b87a5e4afe586c2ac6a0b32db8dc4dcc2dc.1606162397.git.andreyknvl@google.com
Co-developed-by: Vincenzo Frascino <Vincenzo.Frascino@arm.com >
Signed-off-by: Vincenzo Frascino <Vincenzo.Frascino@arm.com >
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Reviewed-by: Marco Elver <elver@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Catalin Marinas <catalin.marinas@arm.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: I7b795bb1b84bf216a722e9250e63a89805835ead
2021-01-19 21:47:32 -08:00
Andrey Konovalov
36c5b4d631
UPSTREAM: kasan: clarify comment in __kasan_kfree_large
...
[ Upstream commit 3933c17571 ]
Currently it says that the memory gets poisoned by page_alloc code.
Clarify this by mentioning the specific callback that poisons the memory.
Link: https://lkml.kernel.org/r/1c8380fe0332a3bcc720fe29f1e0bef2e2974416.1606162397.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Reviewed-by: Dmitry Vyukov <dvyukov@google.com >
Reviewed-by: Marco Elver <elver@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Catalin Marinas <catalin.marinas@arm.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: I370123e69ce735ad0226866fbde266f555475b75
2021-01-19 21:47:31 -08:00
Andrey Konovalov
ac067eb9c0
UPSTREAM: kasan: simplify assign_tag and set_tag calls
...
[ Upstream commit 1ef3133bd3 ]
set_tag() already ignores the tag for the generic mode, so just call it
as is. Add a check for the generic mode to assign_tag(), and simplify its
call in ____kasan_kmalloc().
Link: https://lkml.kernel.org/r/121eeab245f98555862b289d2ba9269c868fbbcf.1606162397.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Reviewed-by: Dmitry Vyukov <dvyukov@google.com >
Reviewed-by: Marco Elver <elver@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Catalin Marinas <catalin.marinas@arm.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: I6e983b20213f0d66696882bd2ed389ed637ec93a
2021-01-19 21:47:31 -08:00
Andrey Konovalov
c761aed906
UPSTREAM: kasan: don't round_up too much
...
[ Upstream commit d99f6a10c1 ]
For hardware tag-based mode kasan_poison_memory() already rounds up the
size. Do the same for software modes and remove round_up() from the common
code.
Link: https://lkml.kernel.org/r/47b232474f1f89dc072aeda0fa58daa6efade377.1606162397.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Reviewed-by: Dmitry Vyukov <dvyukov@google.com >
Reviewed-by: Marco Elver <elver@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Catalin Marinas <catalin.marinas@arm.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: Ibeef44ca27cf2c84f3c42ba238067502e5f2aea0
2021-01-19 21:47:31 -08:00
Andrey Konovalov
1d986f3458
UPSTREAM: kasan, mm: rename kasan_poison_kfree
...
[ Upstream commit eeb3160c24 ]
Rename kasan_poison_kfree() to kasan_slab_free_mempool() as it better
reflects what this annotation does. Also add a comment that explains the
PageSlab() check.
No functional changes.
Link: https://lkml.kernel.org/r/141675fb493555e984c5dca555e9d9f768c7bbaa.1606162397.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Reviewed-by: Marco Elver <elver@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Catalin Marinas <catalin.marinas@arm.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: I5d8c84899fe81aaebe67fdd5985418d8ecaf56c9
2021-01-19 21:47:31 -08:00
Andrey Konovalov
4e35a81bd8
UPSTREAM: kasan, mm: check kasan_enabled in annotations
...
[ Upstream commit 34303244f2 ]
Declare the kasan_enabled static key in include/linux/kasan.h and in
include/linux/mm.h and check it in all kasan annotations. This allows to
avoid any slowdown caused by function calls when kasan_enabled is
disabled.
Link: https://lkml.kernel.org/r/9f90e3c0aa840dbb4833367c2335193299f69023.1606162397.git.andreyknvl@google.com
Co-developed-by: Vincenzo Frascino <Vincenzo.Frascino@arm.com >
Signed-off-by: Vincenzo Frascino <Vincenzo.Frascino@arm.com >
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Reviewed-by: Marco Elver <elver@google.com >
Reviewed-by: Dmitry Vyukov <dvyukov@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Catalin Marinas <catalin.marinas@arm.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: I2fd783303872cb87b447dbcc97d5654b293fa080
2021-01-19 21:47:31 -08:00
Andrey Konovalov
604db99647
UPSTREAM: kasan: add and integrate kasan boot parameters
...
[ Upstream commit 8028caaca7 ]
Hardware tag-based KASAN mode is intended to eventually be used in
production as a security mitigation. Therefore there's a need for finer
control over KASAN features and for an existence of a kill switch.
This change adds a few boot parameters for hardware tag-based KASAN that
allow to disable or otherwise control particular KASAN features.
The features that can be controlled are:
1. Whether KASAN is enabled at all.
2. Whether KASAN collects and saves alloc/free stacks.
3. Whether KASAN panics on a detected bug or not.
With this change a new boot parameter kasan.mode allows to choose one of
three main modes:
- kasan.mode=off - KASAN is disabled, no tag checks are performed
- kasan.mode=prod - only essential production features are enabled
- kasan.mode=full - all KASAN features are enabled
The chosen mode provides default control values for the features mentioned
above. However it's also possible to override the default values by
providing:
- kasan.stacktrace=off/on - enable alloc/free stack collection
(default: on for mode=full, otherwise off)
- kasan.fault=report/panic - only report tag fault or also panic
(default: report)
If kasan.mode parameter is not provided, it defaults to full when
CONFIG_DEBUG_KERNEL is enabled, and to prod otherwise.
It is essential that switching between these modes doesn't require
rebuilding the kernel with different configs, as this is required by
the Android GKI (Generic Kernel Image) initiative [1].
[1] https://source.android.com/devices/architecture/kernel/generic-kernel-image
[andreyknvl@google.com: don't use read-only static keys]
Link: https://lkml.kernel.org/r/f2ded589eba1597f7360a972226083de9afd86e2.1607537948.git.andreyknvl@google.com
Link: https://lkml.kernel.org/r/cb093613879d8d8841173f090133eddeb4c35f1f.1606162397.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Reviewed-by: Marco Elver <elver@google.com >
Reviewed-by: Dmitry Vyukov <dvyukov@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Catalin Marinas <catalin.marinas@arm.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: I7c7b0f8f67bd27f9a9de5ede95dd6c74ee827994
2021-01-19 21:47:31 -08:00
Andrey Konovalov
c9e9df3264
UPSTREAM: kasan: inline (un)poison_range and check_invalid_free
...
[ Upstream commit 57345fa68a ]
Using (un)poison_range() or check_invalid_free() currently results in
function calls. Move their definitions to mm/kasan/kasan.h and turn them
into static inline functions for hardware tag-based mode to avoid
unneeded function calls.
Link: https://lkml.kernel.org/r/7007955b69eb31b5376a7dc1e0f4ac49138504f2.1606162397.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Reviewed-by: Marco Elver <elver@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Catalin Marinas <catalin.marinas@arm.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: I5db5530f619160bb858f2a88c9ddc6280c04b0b3
2021-01-19 21:47:31 -08:00
Andrey Konovalov
a060305363
UPSTREAM: kasan: open-code kasan_unpoison_slab
...
[ Upstream commit bffe690708 ]
There's the external annotation kasan_unpoison_slab() that is currently
defined as static inline and uses kasan_unpoison_range(). Open-code this
function in mempool.c. Otherwise with an upcoming change this function
will result in an unnecessary function call.
Link: https://lkml.kernel.org/r/131a6694a978a9a8b150187e539eecc8bcbf759b.1606162397.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Reviewed-by: Marco Elver <elver@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Catalin Marinas <catalin.marinas@arm.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: Ifa2f5726be869c90101f44baad4b90b1e6ff1249
2021-01-19 21:47:31 -08:00
Andrey Konovalov
42a780b89a
UPSTREAM: kasan: inline random_tag for HW_TAGS
...
[ Upstream commit d8dd397120 ]
Using random_tag() currently results in a function call. Move its
definition to mm/kasan/kasan.h and turn it into a static inline function
for hardware tag-based mode to avoid uneeded function calls.
Link: https://lkml.kernel.org/r/be438471690e351e1d792e6bb432e8c03ccb15d3.1606162397.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Reviewed-by: Marco Elver <elver@google.com >
Reviewed-by: Dmitry Vyukov <dvyukov@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Catalin Marinas <catalin.marinas@arm.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: Ibd6c5381c57cfebd851c6070d92bf421fe62c5c3
2021-01-19 21:47:31 -08:00
Andrey Konovalov
1e8a05e3c0
UPSTREAM: kasan: inline kasan_reset_tag for tag-based modes
...
[ Upstream commit c0054c565a ]
Using kasan_reset_tag() currently results in a function call. As it's
called quite often from the allocator code, this leads to a noticeable
slowdown. Move it to include/linux/kasan.h and turn it into a static
inline function. Also remove the now unneeded reset_tag() internal KASAN
macro and use kasan_reset_tag() instead.
Link: https://lkml.kernel.org/r/6940383a3a9dfb416134d338d8fac97a9ebb8686.1606162397.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Reviewed-by: Marco Elver <elver@google.com >
Reviewed-by: Dmitry Vyukov <dvyukov@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Catalin Marinas <catalin.marinas@arm.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: I714a464d99cbd6b5a9b25c041310e730ec7da5e2
2021-01-19 21:47:31 -08:00
Andrey Konovalov
9655455b9e
UPSTREAM: kasan: remove __kasan_unpoison_stack
...
[ Upstream commit 77f57c9830 ]
There's no need for __kasan_unpoison_stack() helper, as it's only
currently used in a single place. Removing it also removes unneeded
arithmetic.
No functional changes.
Link: https://lkml.kernel.org/r/93e78948704a42ea92f6248ff8a725613d721161.1606162397.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Reviewed-by: Dmitry Vyukov <dvyukov@google.com >
Reviewed-by: Marco Elver <elver@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Catalin Marinas <catalin.marinas@arm.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: I2e9435e4517ad3c6600f18a2da7c29f00b889706
2021-01-19 21:47:31 -08:00
Andrey Konovalov
f3a6301925
UPSTREAM: kasan: allow VMAP_STACK for HW_TAGS mode
...
[ Upstream commit 38dd767dae ]
Even though hardware tag-based mode currently doesn't support checking
vmalloc allocations, it doesn't use shadow memory and works with
VMAP_STACK as is. Change VMAP_STACK definition accordingly.
Link: https://lkml.kernel.org/r/ecdb2a1658ebd88eb276dee2493518ac0e82de41.1606162397.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Reviewed-by: Marco Elver <elver@google.com >
Acked-by: Catalin Marinas <catalin.marinas@arm.com >
Reviewed-by: Dmitry Vyukov <dvyukov@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: If249b8cae30451eaf52e22c489fdf81b807f3aa1
2021-01-19 21:47:31 -08:00
Andrey Konovalov
36c15efc62
UPSTREAM: kasan, arm64: unpoison stack only with CONFIG_KASAN_STACK
...
[ Upstream commit d56a9ef84b ]
There's a config option CONFIG_KASAN_STACK that has to be enabled for
KASAN to use stack instrumentation and perform validity checks for
stack variables.
There's no need to unpoison stack when CONFIG_KASAN_STACK is not enabled.
Only call kasan_unpoison_task_stack[_below]() when CONFIG_KASAN_STACK is
enabled.
Note, that CONFIG_KASAN_STACK is an option that is currently always
defined when CONFIG_KASAN is enabled, and therefore has to be tested
with #if instead of #ifdef.
Link: https://lkml.kernel.org/r/d09dd3f8abb388da397fd11598c5edeaa83fe559.1606162397.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Reviewed-by: Marco Elver <elver@google.com >
Acked-by: Catalin Marinas <catalin.marinas@arm.com >
Reviewed-by: Dmitry Vyukov <dvyukov@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: I776d0e42a0b7238e1c810838f37d549a07af4582
2021-01-19 21:47:31 -08:00
Andrey Konovalov
2dbb829143
UPSTREAM: kasan: introduce set_alloc_info
...
[ Upstream commit 8bb0009b19 ]
Add set_alloc_info() helper and move kasan_set_track() into it. This will
simplify the code for one of the upcoming changes.
No functional changes.
Link: https://lkml.kernel.org/r/b2393e8f1e311a70fc3aaa2196461b6acdee7d21.1606162397.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Reviewed-by: Dmitry Vyukov <dvyukov@google.com >
Reviewed-by: Marco Elver <elver@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Catalin Marinas <catalin.marinas@arm.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: I53a1611acaf239fae63caa8e043039f9e56801b6
2021-01-19 21:47:30 -08:00
Andrey Konovalov
54597d5563
UPSTREAM: kasan: rename get_alloc/free_info
...
[ Upstream commit 6476792f10 ]
Rename get_alloc_info() and get_free_info() to kasan_get_alloc_meta() and
kasan_get_free_meta() to better reflect what those do and avoid confusion
with kasan_set_free_info().
No functional changes.
Link: https://lkml.kernel.org/r/27b7c036b754af15a2839e945f6d8bfce32b4c2f.1606162397.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Reviewed-by: Dmitry Vyukov <dvyukov@google.com >
Reviewed-by: Marco Elver <elver@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Catalin Marinas <catalin.marinas@arm.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: I772cab3faf6396314d4cb9f7df5d908df992588e
2021-01-19 21:47:30 -08:00
Andrey Konovalov
bc653c3b74
UPSTREAM: kasan: simplify quarantine_put call site
...
[ Upstream commit c696de9f12 ]
Patch series "kasan: boot parameters for hardware tag-based mode", v4.
=== Overview
Hardware tag-based KASAN mode [1] is intended to eventually be used in
production as a security mitigation. Therefore there's a need for finer
control over KASAN features and for an existence of a kill switch.
This patchset adds a few boot parameters for hardware tag-based KASAN that
allow to disable or otherwise control particular KASAN features, as well
as provides some initial optimizations for running KASAN in production.
There's another planned patchset what will further optimize hardware
tag-based KASAN, provide proper benchmarking and tests, and will fully
enable tag-based KASAN for production use.
Hardware tag-based KASAN relies on arm64 Memory Tagging Extension (MTE)
[2] to perform memory and pointer tagging. Please see [3] and [4] for
detailed analysis of how MTE helps to fight memory safety problems.
The features that can be controlled are:
1. Whether KASAN is enabled at all.
2. Whether KASAN collects and saves alloc/free stacks.
3. Whether KASAN panics on a detected bug or not.
The patch titled "kasan: add and integrate kasan boot parameters" of this
series adds a few new boot parameters.
kasan.mode allows to choose one of three main modes:
- kasan.mode=off - KASAN is disabled, no tag checks are performed
- kasan.mode=prod - only essential production features are enabled
- kasan.mode=full - all KASAN features are enabled
The chosen mode provides default control values for the features mentioned
above. However it's also possible to override the default values by
providing:
- kasan.stacktrace=off/on - enable stacks collection
(default: on for mode=full, otherwise off)
- kasan.fault=report/panic - only report tag fault or also panic
(default: report)
If kasan.mode parameter is not provided, it defaults to full when
CONFIG_DEBUG_KERNEL is enabled, and to prod otherwise.
It is essential that switching between these modes doesn't require
rebuilding the kernel with different configs, as this is required by
the Android GKI (Generic Kernel Image) initiative.
=== Benchmarks
For now I've only performed a few simple benchmarks such as measuring
kernel boot time and slab memory usage after boot. There's an upcoming
patchset which will optimize KASAN further and include more detailed
benchmarking results.
The benchmarks were performed in QEMU and the results below exclude the
slowdown caused by QEMU memory tagging emulation (as it's different from
the slowdown that will be introduced by hardware and is therefore
irrelevant).
KASAN_HW_TAGS=y + kasan.mode=off introduces no performance or memory
impact compared to KASAN_HW_TAGS=n.
kasan.mode=prod (manually excluding tagging) introduces 3% of performance
and no memory impact (except memory used by hardware to store tags)
compared to kasan.mode=off.
kasan.mode=full has about 40% performance and 30% memory impact over
kasan.mode=prod. Both come from alloc/free stack collection.
=== Notes
This patchset is available here:
https://github.com/xairy/linux/tree/up-boot-mte-v4
This patchset is based on v11 of "kasan: add hardware tag-based mode for
arm64" patchset [1].
For testing in QEMU hardware tag-based KASAN requires:
1. QEMU built from master [6] (use "-machine virt,mte=on -cpu max" arguments
to run).
2. GCC version 10.
[1] https://lore.kernel.org/linux-arm-kernel/cover.1606161801.git.andreyknvl@google.com/T/#t
[2] https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/enhancing-memory-safety
[3] https://arxiv.org/pdf/1802.09517.pdf
[4] https://github.com/microsoft/MSRC-Security-Research/blob/master/papers/2020/Security%20analysis%20of%20memory%20tagging.pdf
[5] https://source.android.com/devices/architecture/kernel/generic-kernel-image
[6] https://github.com/qemu/qemu
=== Tags
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
This patch (of 19):
Move get_free_info() call into quarantine_put() to simplify the call site.
No functional changes.
Link: https://lkml.kernel.org/r/cover.1606162397.git.andreyknvl@google.com
Link: https://lkml.kernel.org/r/312d0a3ef92cc6dc4fa5452cbc1714f9393ca239.1606162397.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Reviewed-by: Dmitry Vyukov <dvyukov@google.com >
Reviewed-by: Marco Elver <elver@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Catalin Marinas <catalin.marinas@arm.com >
Cc: Will Deacon <will.deacon@arm.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Alexander Potapenko <glider@google.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: I16d0738e3a1db7367a43a9b0f52365ba323da504
2021-01-19 21:47:30 -08:00
Vincenzo Frascino
43fe730804
UPSTREAM: kselftest/arm64: check GCR_EL1 after context switch
...
[ Upstream commit 29f0808816 ]
This test is specific to MTE and verifies that the GCR_EL1 register is
context switched correctly.
It spawns 1024 processes and each process spawns 5 threads. Each thread
writes a random setting of GCR_EL1 through the prctl() system call and
reads it back verifying that it is the same. If the values are not the
same it reports a failure.
Note: The test has been extended to verify that even SYNC and ASYNC mode
setting is preserved correctly over context switching.
Link: https://lkml.kernel.org/r/b51a165426e906e7ec8a68d806ef3f8cd92581a6.1606161801.git.andreyknvl@google.com
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Acked-by: Catalin Marinas <catalin.marinas@arm.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Marco Elver <elver@google.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: I19b3e8558a5a9e3672ef87ccef678a298063bd2f
2021-01-19 21:47:30 -08:00
Andrey Konovalov
9c79ff1e23
UPSTREAM: kasan: add documentation for hardware tag-based mode
...
[ Upstream commit 948e32539f ]
Add documentation for hardware tag-based KASAN mode and also add some
clarifications for software tag-based mode.
Link: https://lkml.kernel.org/r/20ed1d387685e89fc31be068f890f070ef9fd5d5.1606161801.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Reviewed-by: Marco Elver <elver@google.com >
Reviewed-by: Alexander Potapenko <glider@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Catalin Marinas <catalin.marinas@arm.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: Ia6919bee081bb691d36f47e806cee23d1c7acd71
2021-01-19 21:47:30 -08:00
Andrey Konovalov
ceb619b1dc
UPSTREAM: kasan, arm64: enable CONFIG_KASAN_HW_TAGS
...
[ Upstream commit 94ab5b61ee ]
Hardware tag-based KASAN is now ready, enable the configuration option.
Link: https://lkml.kernel.org/r/a6fa50d3bb6b318e05c6389a44095be96442b8b0.1606161801.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Acked-by: Catalin Marinas <catalin.marinas@arm.com >
Reviewed-by: Alexander Potapenko <glider@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Marco Elver <elver@google.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: I6342b3bc2df86d4c9759d8e609aa6b5ad8e79aff
2021-01-19 21:47:30 -08:00
Andrey Konovalov
8d4b6fc236
UPSTREAM: kasan, mm: reset tags when accessing metadata
...
[ Upstream commit aa1ef4d7b3 ]
Kernel allocator code accesses metadata for slab objects, that may lie
out-of-bounds of the object itself, or be accessed when an object is
freed. Such accesses trigger tag faults and lead to false-positive
reports with hardware tag-based KASAN.
Software KASAN modes disable instrumentation for allocator code via
KASAN_SANITIZE Makefile macro, and rely on kasan_enable/disable_current()
annotations which are used to ignore KASAN reports.
With hardware tag-based KASAN neither of those options are available, as
it doesn't use compiler instrumetation, no tag faults are ignored, and MTE
is disabled after the first one.
Instead, reset tags when accessing metadata (currently only for SLUB).
Link: https://lkml.kernel.org/r/a0f3cefbc49f34c843b664110842de4db28179d0.1606161801.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Acked-by: Marco Elver <elver@google.com >
Reviewed-by: Alexander Potapenko <glider@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Catalin Marinas <catalin.marinas@arm.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: I9e465a2b11b96938d2dc4d45d31a15b1c6c1d129
2021-01-19 21:47:30 -08:00
Andrey Konovalov
cadd7c8b25
UPSTREAM: kasan, arm64: print report from tag fault handler
...
[ Upstream commit 4291e9ee61 ]
Add error reporting for hardware tag-based KASAN. When
CONFIG_KASAN_HW_TAGS is enabled, print KASAN report from the arm64 tag
fault handler.
SAS bits aren't set in ESR for all faults reported in EL1, so it's
impossible to find out the size of the access the caused the fault. Adapt
KASAN reporting code to handle this case.
Link: https://lkml.kernel.org/r/b559c82b6a969afedf53b4694b475f0234067a1a.1606161801.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Co-developed-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com >
Reviewed-by: Alexander Potapenko <glider@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Marco Elver <elver@google.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: I1eb30d4a38f98fee4ba6a503a96afb8e89c58c14
2021-01-19 21:47:30 -08:00
Andrey Konovalov
11167161e5
UPSTREAM: kasan, arm64: implement HW_TAGS runtime
...
[ Upstream commit 2e903b9147 ]
Provide implementation of KASAN functions required for the hardware
tag-based mode. Those include core functions for memory and pointer
tagging (tags_hw.c) and bug reporting (report_tags_hw.c). Also adapt
common KASAN code to support the new mode.
Link: https://lkml.kernel.org/r/cfd0fbede579a6b66755c98c88c108e54f9c56bf.1606161801.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Acked-by: Catalin Marinas <catalin.marinas@arm.com >
Reviewed-by: Alexander Potapenko <glider@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Marco Elver <elver@google.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: I01f73c7dad50345aa95272fa93eb26cbb1d6bf83
2021-01-19 21:47:30 -08:00
Andrey Konovalov
67e914b607
BACKPORT: kasan, arm64: expand CONFIG_KASAN checks
...
[ Upstream commit 0fea6e9af8 ]
[ Conflict: no real conflict, adjacent lines changed ]
Some #ifdef CONFIG_KASAN checks are only relevant for software KASAN modes
(either related to shadow memory or compiler instrumentation). Expand
those into CONFIG_KASAN_GENERIC || CONFIG_KASAN_SW_TAGS.
Link: https://lkml.kernel.org/r/e6971e432dbd72bb897ff14134ebb7e169bdcf0c.1606161801.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com >
Reviewed-by: Alexander Potapenko <glider@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Marco Elver <elver@google.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: If98ea492b3523c950d46c81c616eb284859482b5
2021-01-19 21:47:30 -08:00
Andrey Konovalov
b243efc9b4
UPSTREAM: kasan, x86, s390: update undef CONFIG_KASAN
...
[ Upstream commit 8a494023b8 ]
With the intoduction of hardware tag-based KASAN some kernel checks of
this kind:
ifdef CONFIG_KASAN
will be updated to:
if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
x86 and s390 use a trick to #undef CONFIG_KASAN for some of the code
that isn't linked with KASAN runtime and shouldn't have any KASAN
annotations.
Also #undef CONFIG_KASAN_GENERIC with CONFIG_KASAN.
Link: https://lkml.kernel.org/r/9d84bfaaf8fabe0fc89f913c9e420a30bd31a260.1606161801.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Reviewed-by: Marco Elver <elver@google.com >
Acked-by: Vasily Gorbik <gor@linux.ibm.com >
Reviewed-by: Alexander Potapenko <glider@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Catalin Marinas <catalin.marinas@arm.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: I5cf77ddb7725f71a69cf08dec139b988e59a7386
2021-01-19 21:47:29 -08:00
Andrey Konovalov
b5982bb106
UPSTREAM: kasan: define KASAN_GRANULE_SIZE for HW_TAGS
...
[ Upstream commit 6c6a04fe36 ]
Hardware tag-based KASAN has granules of MTE_GRANULE_SIZE. Define
KASAN_GRANULE_SIZE to MTE_GRANULE_SIZE for CONFIG_KASAN_HW_TAGS.
Link: https://lkml.kernel.org/r/3d15794b3d1b27447fd7fdf862c073192ba657bd.1606161801.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Reviewed-by: Marco Elver <elver@google.com >
Reviewed-by: Alexander Potapenko <glider@google.com >
Tested-by: Vincenzo Frascino <vincenzo.frascino@arm.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Branislav Rankov <Branislav.Rankov@arm.com >
Cc: Catalin Marinas <catalin.marinas@arm.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Evgenii Stepanov <eugenis@google.com >
Cc: Kevin Brodsky <kevin.brodsky@arm.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Will Deacon <will.deacon@arm.com >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
Bug: 172318110
Signed-off-by: Andrey Konovalov <andreyknvl@google.com >
Change-Id: Id0add4dda3cd0ab41e08071aa856abb470c529bc
2021-01-19 21:47:29 -08:00