5.2.16-stable review
Subsystems (2)
Greg Kroah-Hartman
maintainercover 5.2.16-stable review
This is the start of the stable review cycle for the 5.2.16 release. There are 85 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri 20 Sep 2019 06:09:47 AM UTC. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.2.16-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-5.2.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 5.2.16-rc1
Linus Torvalds <[email protected]>
x86/build: Add -Wnoaddress-of-packed-member to REALMODE_CFLAGS, to silence GCC9 build warning
Hui Peng <[email protected]>
rsi: fix a double free bug in rsi_91x_deinit()
Enrico Weigelt <[email protected]>
platform/x86: pcengines-apuv2: use KEY_RESTART for front button
Steffen Dirkwinkel <[email protected]>
platform/x86: pmc_atom: Add CB4063 Beckhoff Automation board to critclk_systems DMI table
Liran Alon <[email protected]>
KVM: SVM: Fix detection of AMD Errata 1096
Jim Mattson <[email protected]>
kvm: nVMX: Remove unnecessary sync_roots from handle_invept
Jessica Yu <[email protected]>
modules: always page-align module section allocations
Yang Yingliang <[email protected]>
modules: fix compile error if don't have strict module rwx
Yang Yingliang <[email protected]>
modules: fix BUG when load module with rodata=n
Olivier Moysan <[email protected]>
iio: adc: stm32-dfsdm: fix data type
Olivier Moysan <[email protected]>
iio: adc: stm32-dfsdm: fix output resolution
Mario Limonciello <[email protected]>
Revert "Bluetooth: btusb: driver to enable the usb-wakeup feature"
Gustavo A. R. Silva <[email protected]>
mm/z3fold.c: fix lock/unlock imbalance in z3fold_page_isolate
Henry Burns <[email protected]>
mm/z3fold.c: remove z3fold_migration trylock
Nishka Dasgupta <[email protected]>
drm/mediatek: mtk_drm_drv.c: Add of_node_put() before goto
Hans de Goede <[email protected]>
drm: panel-orientation-quirks: Add extra quirk table entry for GPD MicroPC
Andrew F. Davis <[email protected]>
firmware: ti_sci: Always request response from firmware
Christophe Leroy <[email protected]>
crypto: talitos - HMAC SNOOP NO AFEU mode requires SW icv checking.
Christophe Leroy <[email protected]>
crypto: talitos - Do not modify req->cryptlen on decryption.
Christophe Leroy <[email protected]>
crypto: talitos - fix ECB algs ivsize
Christophe Leroy <[email protected]>
crypto: talitos - check data blocksize in ablkcipher.
Christophe Leroy <[email protected]>
crypto: talitos - fix CTR alg blocksize
Christophe Leroy <[email protected]>
crypto: talitos - check AES key size
Muchun Song <[email protected]>
driver core: Fix use-after-free and double free on glue directory
Richard Weinberger <[email protected]>
ubifs: Correctly use tnc_next() in search_dh_cookie()
Alex Williamson <[email protected]>
PCI: Always allow probing with driver_override
Xiaolei Li <[email protected]>
mtd: rawnand: mtk: Fix wrongly assigned OOB buffer pointer issue
Douglas Anderson <[email protected]>
clk: rockchip: Don't yell about bad mmc phases when getting
Dan Carpenter <[email protected]>
mt76: mt7615: Use after free in mt7615_mcu_set_bcn()
Dan Carpenter <[email protected]>
mt76: Fix a signedness bug in mt7615_add_interface()
Stephen Boyd <[email protected]>
clk: Simplify debugfs printing and add a newline
Chen-Yu Tsai <[email protected]>
clk: Fix debugfs clk_possible_parents for clks without parent string names
Neil Armstrong <[email protected]>
drm/meson: Add support for XBGR8888 & ABGR8888 formats
Mimi Zohar <[email protected]>
x86/ima: check EFI SetupMode too
Junichi Nomura <[email protected]>
x86/boot: Use efi_setup_data for searching RSDP on kexec-ed kernels
YueHaibing <[email protected]>
kernel/module: Fix mem leak in module_add_modinfo_attrs
Suraj Jitindar Singh <[email protected]>
powerpc: Add barrier_nospec to raw_copy_in_user()
Steve Wahl <[email protected]>
x86/purgatory: Change compiler flags from -mcmodel=kernel to -mcmodel=large to fix kexec relocation errors
Paolo Bonzini <[email protected]>
KVM: nVMX: handle page fault in vmread
Sean Christopherson <[email protected]>
KVM: x86/mmu: Reintroduce fast invalidate/zap for flushing memslot
Fuqian Huang <[email protected]>
KVM: x86: work around leak of uninitialized stack contents
Thomas Huth <[email protected]>
KVM: s390: Do not leak kernel stack data in the KVM_S390_INTERRUPT ioctl
Igor Mammedov <[email protected]>
KVM: s390: kvm_s390_vm_start_migration: check dirty_bitmap before using it as target for memset()
Andreas Kemnade <[email protected]>
regulator: twl: voltage lists for vdd1/2 on twl4030
Yunfeng Ye <[email protected]>
genirq: Prevent NULL pointer dereference in resend_irqs()
Stanislaw Gruszka <[email protected]>
mt76: mt76x0e: disable 5GHz band for MT7630E
Stanislaw Gruszka <[email protected]>
Revert "rt2800: enable TX_PIN_CFG_LNA_PE_ bits per band"
Alexander Duyck <[email protected]>
ixgbe: Prevent u8 wrapping of ITR value to something less than 10us
Ilya Maximets <[email protected]>
ixgbe: fix double clean of Tx descriptors with xdp
Arnd Bergmann <[email protected]>
ipc: fix sparc64 ipc() wrapper
Arnd Bergmann <[email protected]>
ipc: fix semtimedop for generic 32-bit architectures
Chris Wilson <[email protected]>
drm/i915: Restore relaxed padding (OCL_OOB_SUPPRES_ENABLE) for skl+
Ville Syrjälä <[email protected]>
drm/i915: Limit MST to <= 8bpc once again
Vasily Khoruzhick <[email protected]>
drm/lima: fix lima_gem_wait() return value
Ulf Hansson <[email protected]>
mmc: tmio: Fixup runtime PM management during remove
Ulf Hansson <[email protected]>
mmc: tmio: Fixup runtime PM management during probe
Daniel Drake <[email protected]>
Revert "mmc: sdhci: Remove unneeded quirk2 flag of O2 SD host controller"
Stefan Wahren <[email protected]>
Revert "mmc: bcm2835: Terminate timeout work synchronously"
Roman Gushchin <[email protected]>
cgroup: freezer: fix frozen state inheritance
Filipe Manana <[email protected]>
Btrfs: fix assertion failure during fsync and use of stale transaction
Kent Gibson <[email protected]>
gpio: fix line flag validation in lineevent_create
Kent Gibson <[email protected]>
gpio: fix line flag validation in linehandle_create
Wei Yongjun <[email protected]>
gpio: mockup: add missing single_release()
Hans de Goede <[email protected]>
gpiolib: acpi: Add gpiolib_acpi_run_edge_events_on_boot option and blacklist
John Fastabend <[email protected]>
net: sock_map, fix missing ulp check in sock hash case
Xin Long <[email protected]>
sctp: fix the missing put_user when dumping transport thresholds
Moritz Fischer <[email protected]>
net: fixed_phy: Add forward declaration for struct gpio_desc;
Maciej Żenczykowski <[email protected]>
ipv6: addrconf_f6i_alloc - fix non-null pointer check to !IS_ERR()
Maciej Żenczykowski <[email protected]>
net-ipv6: fix excessive RTF_ADDRCONF flag on ::1/128 local route (and others)
Yang Yingliang <[email protected]>
tun: fix use-after-free when register netdev failed
Xin Long <[email protected]>
tipc: add NULL pointer check before calling kfree_rcu
Neal Cardwell <[email protected]>
tcp: fix tcp_ecn_withdraw_cwr() to clear TCP_ECN_QUEUE_CWR
Xin Long <[email protected]>
sctp: use transport pf_retrans in sctp_do_8_2_transport_strike
Christophe JAILLET <[email protected]>
sctp: Fix the link time qualifier of 'sctp_ctrlsock_exit()'
Cong Wang <[email protected]>
sch_hhf: ensure quantum and hhf_non_hh_weight are non-zero
Eric Dumazet <[email protected]>
net: sched: fix reordering issues
Stefan Chulski <[email protected]>
net: phylink: Fix flow control resolution
Shmulik Ladkani <[email protected]>
net: gso: Fix skb_segment splat when splitting gso_size mangled skb having linear-headed frag_list
Subash Abhinov Kasiviswanathan <[email protected]>
net: Fix null de-reference of device refcount
Jeff Kirsher <[email protected]>
ixgbevf: Fix secpath usage for IPsec Tx offload
Steffen Klassert <[email protected]>
ixgbe: Fix secpath usage for IPsec TX offload.
Eric Biggers <[email protected]>
isdn/capi: check message length in capi_write()
Christophe JAILLET <[email protected]>
ipv6: Fix the link time qualifier of 'ping_v6_proc_exit_net()'
Bjørn Mork <[email protected]>
cdc_ether: fix rndis support for Mediatek based smartphones
Nicolas Dichtel <[email protected]>
bridge/mdb: remove wrong use of NLM_F_MULTI
-------------
Diffstat:
Makefile | 4 +- arch/powerpc/include/asm/uaccess.h | 1 + arch/s390/kvm/interrupt.c | 10 ++ arch/s390/kvm/kvm-s390.c | 4 +- arch/sparc/kernel/sys_sparc_64.c | 33 +++-- arch/x86/Makefile | 1 + arch/x86/boot/compressed/acpi.c | 143 +++++++++++++----- arch/x86/include/asm/kvm_host.h | 2 + arch/x86/kernel/ima_arch.c | 12 +- arch/x86/kvm/mmu.c | 101 ++++++++++++- arch/x86/kvm/svm.c | 42 +++++- arch/x86/kvm/vmx/nested.c | 12 +- arch/x86/kvm/x86.c | 7 + arch/x86/purgatory/Makefile | 35 +++-- drivers/base/core.c | 53 ++++++- drivers/bluetooth/btusb.c | 5 - drivers/clk/clk.c | 38 ++++- drivers/clk/rockchip/clk-mmc-phase.c | 4 +- drivers/crypto/talitos.c | 70 ++++++--- drivers/firmware/ti_sci.c | 8 +- drivers/gpio/gpio-mockup.c | 1 + drivers/gpio/gpiolib-acpi.c | 42 +++++- drivers/gpio/gpiolib.c | 16 +- drivers/gpu/drm/drm_panel_orientation_quirks.c | 12 ++ drivers/gpu/drm/i915/intel_dp_mst.c | 10 +- drivers/gpu/drm/i915/intel_workarounds.c | 5 - drivers/gpu/drm/lima/lima_gem.c | 2 +- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 5 +- drivers/gpu/drm/meson/meson_plane.c | 16 ++ drivers/iio/adc/stm32-dfsdm-adc.c | 162 ++++++++++++++++----- drivers/iio/adc/stm32-dfsdm.h | 24 ++- drivers/isdn/capi/capi.c | 10 +- drivers/mmc/host/bcm2835.c | 2 +- drivers/mmc/host/sdhci-pci-o2micro.c | 2 +- drivers/mmc/host/tmio_mmc.h | 1 + drivers/mmc/host/tmio_mmc_core.c | 16 +- drivers/mtd/nand/raw/mtk_nand.c | 21 ++- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 7 +- drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 29 ++-- drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 3 +- drivers/net/phy/phylink.c | 6 +- drivers/net/tun.c | 16 +- drivers/net/usb/cdc_ether.c | 10 +- drivers/net/wireless/mediatek/mt76/mt7615/main.c | 5 +- drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 2 +- drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c | 5 + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 18 +-- drivers/net/wireless/rsi/rsi_91x_usb.c | 1 - drivers/pci/pci-driver.c | 3 +- drivers/platform/x86/pcengines-apuv2.c | 2 +- drivers/platform/x86/pmc_atom.c | 8 + drivers/regulator/twl-regulator.c | 23 ++- fs/btrfs/tree-log.c | 16 +- fs/ubifs/tnc.c | 16 +- include/linux/phy_fixed.h | 1 + include/linux/syscalls.h | 19 +++ include/uapi/asm-generic/unistd.h | 2 +- include/uapi/linux/isdn/capicmd.h | 1 + ipc/util.h | 25 +--- kernel/cgroup/cgroup.c | 10 +- kernel/irq/resend.c | 2 + kernel/module.c | 51 ++++--- mm/z3fold.c | 7 +- net/bridge/br_mdb.c | 2 +- net/core/dev.c | 2 + net/core/skbuff.c | 19 +++ net/core/sock_map.c | 3 + net/ipv4/tcp_input.c | 2 +- net/ipv6/ping.c | 2 +- net/ipv6/route.c | 8 +- net/sched/sch_generic.c | 9 +- net/sched/sch_hhf.c | 2 +- net/sctp/protocol.c | 2 +- net/sctp/sm_sideeffect.c | 2 +- net/sctp/socket.c | 3 +- net/tipc/name_distr.c | 3 +- 76 files changed, 956 insertions(+), 323 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/85 bridge/mdb: remove wrong use of NLM_F_MULTI
From: Nicolas Dichtel <[email protected]>
[ Upstream commit 94a72b3f024fc7e9ab640897a1e38583a470659d ]
NLM_F_MULTI must be used only when a NLMSG_DONE message is sent at the end. In fact, NLMSG_DONE is sent only at the end of a dump.
Libraries like libnl will wait forever for NLMSG_DONE.
--- net/bridge/br_mdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/bridge/br_mdb.c +1 -1
@@ -437,7 +437,7 @@ static int nlmsg_populate_rtr_fill(strucstruct nlmsghdr *nlh;struct nlattr *nest; - nlh =nlmsg_put (skb, pid, seq, type,sizeof (*bpm),NLM_F_MULTI ); + nlh =nlmsg_put (skb, pid, seq, type,sizeof (*bpm),0 );if (!nlh)return -EMSGSIZE ;
Greg Kroah-Hartman
maintainerPATCH 2/85 cdc_ether: fix rndis support for Mediatek based smartphones
In reply to Greg Kroah-HartmanFrom: "Bjørn Mork" <[email protected]>
[ Upstream commit 4d7ffcf3bf1be98d876c570cab8fc31d9fa92725 ]
A Mediatek based smartphone owner reports problems with USB tethering in Linux. The verbose USB listing shows a rndis_host interface pair (e0/01/03 + 10/00/00), but the driver fails to bind with
[ 355.960428] usb 1-4: bad CDC descriptors
The problem is a failsafe test intended to filter out ACM serial functions using the same 02/02/ff class/subclass/protocol as RNDIS. The serial functions are recognized by their non-zero bmCapabilities.
No RNDIS function with non-zero bmCapabilities were known at the time this failsafe was added. But it turns out that some Wireless class RNDIS functions are using the bmCapabilities field. These functions are uniquely identified as RNDIS by their class/subclass/protocol, so the failing test can safely be disabled. The same applies to the two types of Misc class RNDIS functions.
Applying the failsafe to Communication class functions only retains the original functionality, and fixes the problem for the Mediatek based smartphone.
Tow examples of CDC functional descriptors with non-zero bmCapabilities from Wireless class RNDIS functions are:
0e8d:000a Mediatek Crosscall Spider X5 3G Phone
CDC Header:
bcdCDC 1.10
CDC ACM:
bmCapabilities 0x0f
connection notifications
sends break
line coding and serial state
get/set/clear comm features
CDC Union:
bMasterInterface 0
bSlaveInterface 1
CDC Call Management:
bmCapabilities 0x03
call management
use DataInterface
bDataInterface 1
and
19d2:1023 ZTE K4201-z
CDC Header:
bcdCDC 1.10
CDC ACM:
bmCapabilities 0x02
line coding and serial state
CDC Call Management:
bmCapabilities 0x03
call management
use DataInterface
bDataInterface 1
CDC Union:
bMasterInterface 0
bSlaveInterface 1
The Mediatek example is believed to apply to most smartphones with Mediatek firmware. The ZTE example is most likely also part of a larger family of devices/firmwares.
--- drivers/net/usb/cdc_ether.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/usb/cdc_ether.c +9 -1
@@ -206,7 +206,15 @@ int usbnet_generic_cdc_bind(struct usbne goto bad_desc; } skip: -if (rndis && header.usb_cdc_acm_descriptor && +/* Communcation class functions with bmCapabilities are not +* RNDIS. But some Wireless class RNDIS functions use +* bmCapabilities for their own purpose. The failsafe is +* therefore applied only to Communication class RNDIS +* functions. The rndis test is redundant, but a cheap +* optimization. +*/ +if (rndis &&is_rndis (&intf->cur_altsetting->desc) && + header.usb_cdc_acm_descriptor && header.usb_cdc_acm_descriptor->bmCapabilities) { dev_dbg(&intf->dev, "ACM capabilities %02x, not really RNDIS?\n",
Greg Kroah-Hartman
maintainerPATCH 3/85 ipv6: Fix the link time qualifier of ping_v6_proc_exit_net()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit d23dbc479a8e813db4161a695d67da0e36557846 ]
The '.exit' functions from 'pernet_operations' structure should be marked as __net_exit, not __net_init.
--- net/ipv6/ping.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/ping.c +1 -1
@@ -223,7 +223,7 @@ static int __net_init ping_v6_proc_init_return 0 ; } -static void __net_init ping_v6_proc_exit_net (struct net *net) +static void __net_exit ping_v6_proc_exit_net(struct net *net) {remove_proc_entry ("icmp6" , net->proc_net); }
Greg Kroah-Hartman
maintainerPATCH 4/85 isdn/capi: check message length in capi_write()
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
[ Upstream commit fe163e534e5eecdfd7b5920b0dfd24c458ee85d6 ]
syzbot reported:
BUG: KMSAN: uninit-value in capi_write+0x791/0xa90 drivers/isdn/capi/capi.c:700
CPU: 0 PID: 10025 Comm: syz-executor379 Not tainted 4.20.0-rc7+ #2
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x173/0x1d0 lib/dump_stack.c:113
kmsan_report+0x12e/0x2a0 mm/kmsan/kmsan.c:613
__msan_warning+0x82/0xf0 mm/kmsan/kmsan_instr.c:313
capi_write+0x791/0xa90 drivers/isdn/capi/capi.c:700
do_loop_readv_writev fs/read_write.c:703 [inline]
do_iter_write+0x83e/0xd80 fs/read_write.c:961
vfs_writev fs/read_write.c:1004 [inline]
do_writev+0x397/0x840 fs/read_write.c:1039
__do_sys_writev fs/read_write.c:1112 [inline]
__se_sys_writev+0x9b/0xb0 fs/read_write.c:1109
__x64_sys_writev+0x4a/0x70 fs/read_write.c:1109
do_syscall_64+0xbc/0xf0 arch/x86/entry/common.c:291
entry_SYSCALL_64_after_hwframe+0x63/0xe7
[...]The problem is that capi_write() is reading past the end of the message. Fix it by checking the message's length in the needed places.
--- drivers/isdn/capi/capi.c | 10 +++++++++- include/uapi/linux/isdn/capicmd.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-)
drivers/isdn/capi/capi.c +9 -1
@@ -688,6 +688,9 @@ capi_write(struct file *file, const charif (!cdev->ap.applid)return -ENODEV ; +if (count <CAPIMSG_BASELEN ) +return -EINVAL ; + skb =alloc_skb (count,GFP_USER );if (!skb)return -ENOMEM ;
@@ -698,7 +701,8 @@ capi_write(struct file *file, const char } mlen =CAPIMSG_LEN (skb->data);if (CAPIMSG_CMD (skb->data) ==CAPI_DATA_B3_REQ ) { -if ((size_t )(mlen +CAPIMSG_DATALEN (skb->data)) != count) { +if (count <CAPI_DATA_B3_REQ_LEN || + (size_t )(mlen +CAPIMSG_DATALEN (skb->data)) != count) {kfree_skb (skb);return -EINVAL ; }
@@ -711,6 +715,10 @@ capi_write(struct file *file, const charCAPIMSG_SETAPPID (skb->data, cdev->ap.applid);if (CAPIMSG_CMD (skb->data) ==CAPI_DISCONNECT_B3_RESP ) { +if (count <CAPI_DISCONNECT_B3_RESP_LEN ) { +kfree_skb (skb); +return -EINVAL ; + }mutex_lock (&cdev->lock);capincci_free (cdev,CAPIMSG_NCCI (skb->data));mutex_unlock (&cdev->lock);
include/uapi/linux/isdn/capicmd.h +1 -0
@@ -16,6 +16,7 @@#define CAPI_MSG_BASELEN 8#define CAPI_DATA_B3_REQ_LEN (CAPI_MSG_BASELEN+4+4+2+2+2)#define CAPI_DATA_B3_RESP_LEN (CAPI_MSG_BASELEN+4+2) +#define CAPI_DISCONNECT_B3_RESP_LEN (CAPI_MSG_BASELEN+4)/*----- CAPI commands -----*/ #define CAPI_ALERT 0x01
Greg Kroah-Hartman
maintainerPATCH 5/85 ixgbe: Fix secpath usage for IPsec TX offload.
In reply to Greg Kroah-HartmanFrom: Steffen Klassert <[email protected]>
[ Upstream commit f39b683d35dfa93a58f1b400a8ec0ff81296b37c ]
The ixgbe driver currently does IPsec TX offloading based on an existing secpath. However, the secpath can also come from the RX side, in this case it is misinterpreted for TX offload and the packets are dropped with a "bad sa_idx" error. Fix this by using the xfrm_offload() function to test for TX offload.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +2 -1
@@ -36,6 +36,7 @@#include <net/vxlan.h> #include <net/mpls.h> #include <net/xdp_sock.h> +#include <net/xfrm.h> #include "ixgbe.h" #include "ixgbe_common.h"
@@ -8691,7 +8692,7 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct#endif /* IXGBE_FCOE */ #ifdef CONFIG_IXGBE_IPSEC -if (secpath_exists (skb) && +if (xfrm_offload (skb) && !ixgbe_ipsec_tx (tx_ring, first, &ipsec_tx)) goto out_drop;#endif
Greg Kroah-Hartman
maintainerPATCH 6/85 ixgbevf: Fix secpath usage for IPsec Tx offload
In reply to Greg Kroah-HartmanFrom: Jeff Kirsher <[email protected]>
[ Upstream commit 8f6617badcc96a582678ea36ea96490c5ff26eb4 ]
Port the same fix for ixgbe to ixgbevf.
The ixgbevf driver currently does IPsec Tx offloading based on an existing secpath. However, the secpath can also come from the Rx side, in this case it is misinterpreted for Tx offload and the packets are dropped with a "bad sa_idx" error. Fix this by using the xfrm_offload() function to test for Tx offload.
--- drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +2 -1
@@ -30,6 +30,7 @@#include <linux/bpf.h> #include <linux/bpf_trace.h> #include <linux/atomic.h> +#include <net/xfrm.h> #include "ixgbevf.h"
@@ -4158,7 +4159,7 @@ static int ixgbevf_xmit_frame_ring(struc first->protocol =vlan_get_protocol (skb);#ifdef CONFIG_IXGBEVF_IPSEC -if (secpath_exists (skb) && !ixgbevf_ipsec_tx (tx_ring, first, &ipsec_tx)) +if (xfrm_offload (skb) && !ixgbevf_ipsec_tx (tx_ring, first, &ipsec_tx)) goto out_drop;#endif tso =ixgbevf_tso (tx_ring, first, &hdr_len, &ipsec_tx);
Greg Kroah-Hartman
maintainerPATCH 7/85 net: Fix null de-reference of device refcount
In reply to Greg Kroah-HartmanFrom: Subash Abhinov Kasiviswanathan <[email protected]>
[ Upstream commit 10cc514f451a0f239aa34f91bc9dc954a9397840 ]
In event of failure during register_netdevice, free_netdev is invoked immediately. free_netdev assumes that all the netdevice refcounts have been dropped prior to it being called and as a result frees and clears out the refcount pointer.
However, this is not necessarily true as some of the operations in the NETDEV_UNREGISTER notifier handlers queue RCU callbacks for invocation after a grace period. The IPv4 callback in_dev_rcu_put tries to access the refcount after free_netdev is called which leads to a null de-reference-
44837.761523: <6> Unable to handle kernel paging request at
virtual address 0000004a88287000 44837.761651: <2> pc : in_dev_finish_destroy+0x4c/0xc8 44837.761654: <2> lr : in_dev_finish_destroy+0x2c/0xc8 44837.762393: <2> Call trace: 44837.762398: <2> in_dev_finish_destroy+0x4c/0xc8 44837.762404: <2> in_dev_rcu_put+0x24/0x30 44837.762412: <2> rcu_nocb_kthread+0x43c/0x468 44837.762418: <2> kthread+0x118/0x128 44837.762424: <2> ret_from_fork+0x10/0x1c
Fix this by waiting for the completion of the call_rcu() in case of register_netdevice errors.
--- net/core/dev.c | 2 ++ 1 file changed, 2 insertions(+)
net/core/dev.c +2 -0
@@ -8768,6 +8768,8 @@ int register_netdevice(struct net_device ret =notifier_to_errno (ret);if (ret) {rollback_registered (dev); +rcu_barrier (); + dev->reg_state =NETREG_UNREGISTERED ; }/*
Greg Kroah-Hartman
maintainerPATCH 8/85 net: gso: Fix skb_segment splat when splitting gso_size mangled skb having linear-headed frag_list
In reply to Greg Kroah-HartmanFrom: Shmulik Ladkani <[email protected]>
[ Upstream commit 3dcbdb134f329842a38f0e6797191b885ab00a00 ]
Historically, support for frag_list packets entering skb_segment() was limited to frag_list members terminating on exact same gso_size boundaries. This is verified with a BUG_ON since commit 89319d3801d1 ("net: Add frag_list support to skb_segment"), quote:
As such we require all frag_list members terminate on exact MSS boundaries. This is checked using BUG_ON.
As there should only be one producer in the kernel of such packets, namely GRO, this requirement should not be difficult to maintain.
However, since commit 6578171a7ff0 ("bpf: add bpf_skb_change_proto helper"), the "exact MSS boundaries" assumption no longer holds:
An eBPF program using bpf_skb_change_proto() DOES modify 'gso_size', but leaves the frag_list members as originally merged by GRO with the original 'gso_size'. Example of such programs are bpf-based NAT46 or NAT64.
This lead to a kernel BUG_ON for flows involving:
- GRO generating a frag_list skb
- bpf program performing bpf_skb_change_proto() or bpf_skb_adjust_room()
- skb_segment() of the skb
See example BUG_ON reports in [0].
In commit 13acc94eff12 ("net: permit skb_segment on head_frag frag_list skb"), skb_segment() was modified to support the "gso_size mangling" case of a frag_list GRO'ed skb, but *only* for frag_list members having head_frag==true (having a page-fragment head).
Alas, GRO packets having frag_list members with a linear kmalloced head (head_frag==false) still hit the BUG_ON.
This commit adds support to skb_segment() for a 'head_skb' packet having a frag_list whose members are *non* head_frag, with gso_size mangled, by disabling SG and thus falling-back to copying the data from the given 'head_skb' into the generated segmented skbs - as suggested by Willem de Bruijn [1].
Since this approach involves the penalty of skb_copy_and_csum_bits() when building the segments, care was taken in order to enable this solution only when required:
- untrusted gso_size, by testing SKB_GSO_DODGY is set (SKB_GSO_DODGY is set by any gso_size mangling functions in net/core/filter.c)
- the frag_list is non empty, its item is a non head_frag, *and* the headlen of the given 'head_skb' does not match the gso_size.
[0]
https://lore.kernel.org/netdev/20190826170724.25ff616f@pixies/
https://lore.kernel.org/netdev/[email protected]/
[1]
https://lore.kernel.org/netdev/CA+FuTSfVsgNDi7c=GUU8nMg2hWxF2SjCNLXetHeVPdnxAW5K-w@mail.gmail.com/
--- net/core/skbuff.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
net/core/skbuff.c +19 -0
@@ -3531,6 +3531,25 @@ struct sk_buff *skb_segment(struct sk_buint pos;int dummy; +if (list_skb && !list_skb->head_frag &&skb_headlen (list_skb) && + (skb_shinfo (head_skb)->gso_type &SKB_GSO_DODGY )) { +/* gso_size is untrusted, and we have a frag_list with a linear +* non head_frag head. +* +* (we assume checking the first list_skb member suffices; +* i.e if either of the list_skb members have non head_frag +* head, then the first one has too). +* +* If head_skb's headlen does not fit requested gso_size, it +* means that the frag_list members do NOT terminate on exact +* gso_size boundaries. Hence we cannot perform skb_frag_t page +* sharing. Therefore we must fallback to copying the frag_list +* skbs; we do so by disabling SG. +*/ +if (mss !=GSO_BY_FRAGS && mss !=skb_headlen (head_skb)) + features &= ~NETIF_F_SG ; + } +__skb_push (head_skb, doffset); proto =skb_network_protocol (head_skb, &dummy);if (unlikely (!proto))
Greg Kroah-Hartman
maintainerPATCH 9/85 net: phylink: Fix flow control resolution
In reply to Greg Kroah-HartmanFrom: Stefan Chulski <[email protected]>
[ Upstream commit 63b2ed4e10b2e6c913e1d8cdd728e7fba4115a3d ]
Regarding to IEEE 802.3-2015 standard section 2 28B.3 Priority resolution - Table 28-3 - Pause resolution
In case of Local device Pause=1 AsymDir=0, Link partner Pause=1 AsymDir=1, Local device resolution should be enable PAUSE transmit, disable PAUSE receive.
And in case of Local device Pause=1 AsymDir=1, Link partner Pause=1 AsymDir=0, Local device resolution should be enable PAUSE receive, disable PAUSE transmit.
--- drivers/net/phy/phylink.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/phy/phylink.c +3 -3
@@ -356,8 +356,8 @@ static void phylink_get_fixed_state(stru* Local device Link partner * Pause AsymDir Pause AsymDir Result * 1 X 1 X TX+RX -* 0 1 1 1 RX -* 1 1 0 1 TX +* 0 1 1 1 TX +* 1 1 0 1 RX */ static void phylink_resolve_flow (struct phylink *pl,struct phylink_link_state *state)
@@ -378,7 +378,7 @@ static void phylink_resolve_flow(struct new_pause =MLO_PAUSE_TX |MLO_PAUSE_RX ; else if (pause & MLO_PAUSE_ASYM) new_pause = state->pause &MLO_PAUSE_SYM ? -MLO_PAUSE_RX :MLO_PAUSE_TX ; +MLO_PAUSE_TX :MLO_PAUSE_RX ; }else { new_pause = pl->link_config.pause &MLO_PAUSE_TXRX_MASK ; }
Greg Kroah-Hartman
maintainerPATCH 10/85 net: sched: fix reordering issues
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit b88dd52c62bb5c5d58f0963287f41fd084352c57 ]
Whenever MQ is not used on a multiqueue device, we experience serious reordering problems. Bisection found the cited commit.
The issue can be described this way :
- A single qdisc hierarchy is shared by all transmit queues. (eg : tc qdisc replace dev eth0 root fq_codel)
- When/if try_bulk_dequeue_skb_slow() dequeues a packet targetting a different transmit queue than the one used to build a packet train, we stop building the current list and save the 'bad' skb (P1) in a special queue. (bad_txq)
- When dequeue_skb() calls qdisc_dequeue_skb_bad_txq() and finds this skb (P1), it checks if the associated transmit queues is still in frozen state. If the queue is still blocked (by BQL or NIC tx ring full), we leave the skb in bad_txq and return NULL.
- dequeue_skb() calls q->dequeue() to get another packet (P2)
The other packet can target the problematic queue (that we found in frozen state for the bad_txq packet), but another cpu just ran TX completion and made room in the txq that is now ready to accept new packets.
- Packet P2 is sent while P1 is still held in bad_txq, P1 might be sent at next round. In practice P2 is the lead of a big packet train (P2,P3,P4 ...) filling the BQL budget and delaying P1 by many packets :/
To solve this problem, we have to block the dequeue process as long as the first packet in bad_txq can not be sent. Reordering issues disappear and no side effects have been seen.
--- net/sched/sch_generic.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
net/sched/sch_generic.c +7 -2
@@ -46,6 +46,8 @@ EXPORT_SYMBOL(default_qdisc_ops);* - updates to tree and tree walking are only done under the rtnl mutex. */ +#define SKB_XOFF_MAGIC ((struct sk_buff *)1UL) +static inline struct sk_buff *__skb_dequeue_bad_txq (struct Qdisc *q) {const struct netdev_queue *txq = q->dev_queue;
@@ -71,7 +73,7 @@ static inline struct sk_buff *__skb_dequ q->q.qlen--; } }else { - skb =NULL ; + skb =SKB_XOFF_MAGIC ; } }
@@ -253,8 +255,11 @@ validate:return skb; skb =qdisc_dequeue_skb_bad_txq (q); -if (unlikely (skb)) +if (unlikely (skb)) { +if (skb ==SKB_XOFF_MAGIC ) +return NULL ; goto bulk; + } skb = q->dequeue (q);if (skb) { bulk:
Greg Kroah-Hartman
maintainerPATCH 11/85 sch_hhf: ensure quantum and hhf_non_hh_weight are non-zero
In reply to Greg Kroah-HartmanFrom: Cong Wang <[email protected]>
[ Upstream commit d4d6ec6dac07f263f06d847d6f732d6855522845 ]
In case of TCA_HHF_NON_HH_WEIGHT or TCA_HHF_QUANTUM is zero, it would make no progress inside the loop in hhf_dequeue() thus kernel would get stuck.
Fix this by checking this corner case in hhf_change().
--- net/sched/sch_hhf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_hhf.c +1 -1
@@ -531,7 +531,7 @@ static int hhf_change(struct Qdisc *sch, new_hhf_non_hh_weight =nla_get_u32 (tb[TCA_HHF_NON_HH_WEIGHT ]); non_hh_quantum = (u64 )new_quantum * new_hhf_non_hh_weight; -if (non_hh_quantum >INT_MAX ) +if (non_hh_quantum ==0 || non_hh_quantum >INT_MAX )return -EINVAL ;sch_tree_lock (sch);
Greg Kroah-Hartman
maintainerPATCH 12/85 sctp: Fix the link time qualifier of sctp_ctrlsock_exit()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit b456d72412ca8797234449c25815e82f4e1426c0 ]
The '.exit' functions from 'pernet_operations' structure should be marked as __net_exit, not __net_init.
--- net/sctp/protocol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sctp/protocol.c +1 -1
@@ -1336,7 +1336,7 @@ static int __net_init sctp_ctrlsock_initreturn status; } -static void __net_init sctp_ctrlsock_exit (struct net *net) +static void __net_exit sctp_ctrlsock_exit(struct net *net) {/* Free the control endpoint. */ inet_ctl_sock_destroy (net->sctp.ctl_sock);
Greg Kroah-Hartman
maintainerPATCH 13/85 sctp: use transport pf_retrans in sctp_do_8_2_transport_strike
In reply to Greg Kroah-HartmanFrom: Xin Long <[email protected]>
[ Upstream commit 10eb56c582c557c629271f1ee31e15e7a9b2558b ]
Transport should use its own pf_retrans to do the error_count check, instead of asoc's. Otherwise, it's meaningless to make pf_retrans per transport.
--- net/sctp/sm_sideeffect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sctp/sm_sideeffect.c +1 -1
@@ -547,7 +547,7 @@ static void sctp_do_8_2_transport_strikeif (net->sctp.pf_enable && (transport->state ==SCTP_ACTIVE ) && (transport->error_count < transport->pathmaxrxt) && - (transport->error_count > asoc->pf_retrans)) { + (transport->error_count > transport->pf_retrans)) { sctp_assoc_control_transport(asoc, transport, SCTP_TRANSPORT_PF,
Greg Kroah-Hartman
maintainerPATCH 14/85 tcp: fix tcp_ecn_withdraw_cwr() to clear TCP_ECN_QUEUE_CWR
In reply to Greg Kroah-HartmanFrom: Neal Cardwell <[email protected]>
[ Upstream commit af38d07ed391b21f7405fa1f936ca9686787d6d2 ]
Fix tcp_ecn_withdraw_cwr() to clear the correct bit:TCP_ECN_QUEUE_CWR.
Rationale: basically, TCP_ECN_DEMAND_CWR is a bit that is purely about the behavior of data receivers, and deciding whether to reflect incoming IP ECN CE marks as outgoing TCP th->ece marks. The TCP_ECN_QUEUE_CWR bit is purely about the behavior of data senders, and deciding whether to send CWR. The tcp_ecn_withdraw_cwr() function is only called from tcp_undo_cwnd_reduction() by data senders during an undo, so it should zero the sender-side state, TCP_ECN_QUEUE_CWR. It does not make sense to stop the reflection of incoming CE bits on incoming data packets just because outgoing packets were spuriously retransmitted.
The bug has been reproduced with packetdrill to manifest in a scenario with RFC3168 ECN, with an incoming data packet with CE bit set and carrying a TCP timestamp value that causes cwnd undo. Before this fix, the IP CE bit was ignored and not reflected in the TCP ECE header bit, and sender sent a TCP CWR ('W') bit on the next outgoing data packet, even though the cwnd reduction had been undone. After this fix, the sender properly reflects the CE bit and does not set the W bit.
Note: the bug actually predates 2005 git history; this Fixes footer is chosen to be the oldest SHA1 I have tested (from Sep 2007) for which the patch applies cleanly (since before this commit the code was in a .h file).
--- net/ipv4/tcp_input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_input.c +1 -1
@@ -266,7 +266,7 @@ static void tcp_ecn_accept_cwr(struct sostatic void tcp_ecn_withdraw_cwr (struct tcp_sock *tp) { - tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR ; + tp->ecn_flags &= ~TCP_ECN_QUEUE_CWR ; }static void __tcp_ecn_check_ce (struct sock *sk,const struct sk_buff *skb)
Greg Kroah-Hartman
maintainerPATCH 15/85 tipc: add NULL pointer check before calling kfree_rcu
In reply to Greg Kroah-HartmanFrom: Xin Long <[email protected]>
[ Upstream commit 42dec1dbe38239cf91cc1f4df7830c66276ced37 ]
Unlike kfree(p), kfree_rcu(p, rcu) won't do NULL pointer check. When tipc_nametbl_remove_publ returns NULL, the panic below happens:
BUG: unable to handle kernel NULL pointer dereference at 0000000000000068
RIP: 0010:__call_rcu+0x1d/0x290
Call Trace:
<IRQ>
tipc_publ_notify+0xa9/0x170 [tipc]
tipc_node_write_unlock+0x8d/0x100 [tipc]
tipc_node_link_down+0xae/0x1d0 [tipc]
tipc_node_check_dest+0x3ea/0x8f0 [tipc]
? tipc_disc_rcv+0x2c7/0x430 [tipc]
tipc_disc_rcv+0x2c7/0x430 [tipc]
? tipc_rcv+0x6bb/0xf20 [tipc]
tipc_rcv+0x6bb/0xf20 [tipc]
? ip_route_input_slow+0x9cf/0xb10
tipc_udp_recv+0x195/0x1e0 [tipc]
? tipc_udp_is_known_peer+0x80/0x80 [tipc]
udp_queue_rcv_skb+0x180/0x460
udp_unicast_rcv_skb.isra.56+0x75/0x90
__udp4_lib_rcv+0x4ce/0xb90
ip_local_deliver_finish+0x11c/0x210
ip_local_deliver+0x6b/0xe0
? ip_rcv_finish+0xa9/0x410
ip_rcv+0x273/0x362--- net/tipc/name_distr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/tipc/name_distr.c +2 -1
@@ -223,7 +223,8 @@ static void tipc_publ_purge(struct net * publ->key); } -kfree_rcu (p, rcu); +if (p) +kfree_rcu (p, rcu); }/**
Greg Kroah-Hartman
maintainerPATCH 16/85 tun: fix use-after-free when register netdev failed
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 77f22f92dff8e7b45c7786a430626d38071d4670 ]
I got a UAF repport in tun driver when doing fuzzy test:
[ 466.269490] ================================================================== [ 466.271792] BUG: KASAN: use-after-free in tun_chr_read_iter+0x2ca/0x2d0 [ 466.271806] Read of size 8 at addr ffff888372139250 by task tun-test/2699 [ 466.271810] [ 466.271824] CPU: 1 PID: 2699 Comm: tun-test Not tainted 5.3.0-rc1-00001-g5a9433db2614-dirty #427 [ 466.271833] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014 [ 466.271838] Call Trace: [ 466.271858] dump_stack+0xca/0x13e [ 466.271871] ? tun_chr_read_iter+0x2ca/0x2d0 [ 466.271890] print_address_description+0x79/0x440 [ 466.271906] ? vprintk_func+0x5e/0xf0 [ 466.271920] ? tun_chr_read_iter+0x2ca/0x2d0 [ 466.271935] __kasan_report+0x15c/0x1df [ 466.271958] ? tun_chr_read_iter+0x2ca/0x2d0 [ 466.271976] kasan_report+0xe/0x20 [ 466.271987] tun_chr_read_iter+0x2ca/0x2d0 [ 466.272013] do_iter_readv_writev+0x4b7/0x740 [ 466.272032] ? default_llseek+0x2d0/0x2d0 [ 466.272072] do_iter_read+0x1c5/0x5e0 [ 466.272110] vfs_readv+0x108/0x180 [ 466.299007] ? compat_rw_copy_check_uvector+0x440/0x440 [ 466.299020] ? fsnotify+0x888/0xd50 [ 466.299040] ? __fsnotify_parent+0xd0/0x350 [ 466.299064] ? fsnotify_first_mark+0x1e0/0x1e0 [ 466.304548] ? vfs_write+0x264/0x510 [ 466.304569] ? ksys_write+0x101/0x210 [ 466.304591] ? do_preadv+0x116/0x1a0 [ 466.304609] do_preadv+0x116/0x1a0 [ 466.309829] do_syscall_64+0xc8/0x600 [ 466.309849] entry_SYSCALL_64_after_hwframe+0x49/0xbe [ 466.309861] RIP: 0033:0x4560f9 [ 466.309875] Code: 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 [ 466.309889] RSP: 002b:00007ffffa5166e8 EFLAGS: 00000206 ORIG_RAX: 0000000000000127 [ 466.322992] RAX: ffffffffffffffda RBX: 0000000000400460 RCX: 00000000004560f9 [ 466.322999] RDX: 0000000000000003 RSI: 00000000200008c0 RDI: 0000000000000003 [ 466.323007] RBP: 00007ffffa516700 R08: 0000000000000004 R09: 0000000000000000 [ 466.323014] R10: 0000000000000000 R11: 0000000000000206 R12: 000000000040cb10 [ 466.323021] R13: 0000000000000000 R14: 00000000006d7018 R15: 0000000000000000 [ 466.323057] [ 466.323064] Allocated by task 2605: [ 466.335165] save_stack+0x19/0x80 [ 466.336240] __kasan_kmalloc.constprop.8+0xa0/0xd0 [ 466.337755] kmem_cache_alloc+0xe8/0x320 [ 466.339050] getname_flags+0xca/0x560 [ 466.340229] user_path_at_empty+0x2c/0x50 [ 466.341508] vfs_statx+0xe6/0x190 [ 466.342619] __do_sys_newstat+0x81/0x100 [ 466.343908] do_syscall_64+0xc8/0x600 [ 466.345303] entry_SYSCALL_64_after_hwframe+0x49/0xbe [ 466.347034] [ 466.347517] Freed by task 2605: [ 466.348471] save_stack+0x19/0x80 [ 466.349476] __kasan_slab_free+0x12e/0x180 [ 466.350726] kmem_cache_free+0xc8/0x430 [ 466.351874] putname+0xe2/0x120 [ 466.352921] filename_lookup+0x257/0x3e0 [ 466.354319] vfs_statx+0xe6/0x190 [ 466.355498] __do_sys_newstat+0x81/0x100 [ 466.356889] do_syscall_64+0xc8/0x600 [ 466.358037] entry_SYSCALL_64_after_hwframe+0x49/0xbe [ 466.359567] [ 466.360050] The buggy address belongs to the object at ffff888372139100 [ 466.360050] which belongs to the cache names_cache of size 4096 [ 466.363735] The buggy address is located 336 bytes inside of [ 466.363735] 4096-byte region [ffff888372139100, ffff88837213a100) [ 466.367179] The buggy address belongs to the page: [ 466.368604] page:ffffea000dc84e00 refcount:1 mapcount:0 mapping:ffff8883df1b4f00 index:0x0 compound_mapcount: 0 [ 466.371582] flags: 0x2fffff80010200(slab|head) [ 466.372910] raw: 002fffff80010200 dead000000000100 dead000000000122 ffff8883df1b4f00 [ 466.375209] raw: 0000000000000000 0000000000070007 00000001ffffffff 0000000000000000 [ 466.377778] page dumped because: kasan: bad access detected [ 466.379730] [ 466.380288] Memory state around the buggy address: [ 466.381844] ffff888372139100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [ 466.384009] ffff888372139180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [ 466.386131] >ffff888372139200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [ 466.388257] ^ [ 466.390234] ffff888372139280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [ 466.392512] ffff888372139300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [ 466.394667] ==================================================================
tun_chr_read_iter() accessed the memory which freed by free_netdev() called by tun_set_iff():
CPUA CPUB
tun_set_iff()
alloc_netdev_mqs()
tun_attach()
tun_chr_read_iter()
tun_get()
tun_do_read()
tun_ring_recv()
register_netdevice() <-- inject error
goto err_detach
tun_detach_all() <-- set RCV_SHUTDOWN
free_netdev() <-- called from
err_free_dev path
netdev_freemem() <-- free the memory
without check refcount
(In this path, the refcount cannot prevent
freeing the memory of dev, and the memory
will be used by dev_put() called by
tun_chr_read_iter() on CPUB.)
(Break from tun_ring_recv(), because RCV_SHUTDOWN is set)
tun_put()
dev_put() <-- use the memory
freed by netdev_freemem()
Put the publishing of tfile->tun after register_netdevice(), so tun_get() won't get the tun pointer that freed by err_detach path if register_netdevice() failed.
--- drivers/net/tun.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/net/tun.c +11 -5
@@ -788,7 +788,8 @@ static void tun_detach_all(struct net_de }static int tun_attach (struct tun_struct *tun,struct file *file, -bool skip_filter,bool napi,bool napi_frags) +bool skip_filter,bool napi,bool napi_frags, +bool publish_tun) {struct tun_file *tfile = file->private_data;struct net_device *dev = tun->dev;
@@ -871,7 +872,8 @@ static int tun_attach(struct tun_struct* initialized tfile; otherwise we risk using half-initialized * object. */ -rcu_assign_pointer (tfile->tun, tun); +if (publish_tun) +rcu_assign_pointer (tfile->tun, tun);rcu_assign_pointer (tun->tfiles[tun->numqueues], tfile); tun->numqueues++;tun_set_real_num_queues (tun);
@@ -2731,7 +2733,7 @@ static int tun_set_iff(struct net *net, err =tun_attach (tun, file, ifr->ifr_flags &IFF_NOFILTER , ifr->ifr_flags &IFF_NAPI , - ifr->ifr_flags &IFF_NAPI_FRAGS ); + ifr->ifr_flags &IFF_NAPI_FRAGS , true);if (err <0 )return err;
@@ -2830,13 +2832,17 @@ static int tun_set_iff(struct net *net,INIT_LIST_HEAD (&tun->disabled); err =tun_attach (tun, file, false, ifr->ifr_flags &IFF_NAPI , - ifr->ifr_flags &IFF_NAPI_FRAGS ); + ifr->ifr_flags &IFF_NAPI_FRAGS , false);if (err <0 ) goto err_free_flow; err =register_netdevice (tun->dev);if (err <0 ) goto err_detach; +/* free_netdev() won't check refcnt, to aovid race +* with dev_put() we need publish tun after registration. +*/ +rcu_assign_pointer (tfile->tun, tun); }netif_carrier_on (tun->dev);
@@ -2979,7 +2985,7 @@ static int tun_set_queue(struct file *fiif (ret <0 ) goto unlock; ret =tun_attach (tun, file, false, tun->flags &IFF_NAPI , - tun->flags &IFF_NAPI_FRAGS ); + tun->flags &IFF_NAPI_FRAGS , true); }else if (ifr->ifr_flags &IFF_DETACH_QUEUE ) { tun =rtnl_dereference (tfile->tun);if (!tun || !(tun->flags &IFF_MULTI_QUEUE ) || tfile->detached)
Greg Kroah-Hartman
maintainerPATCH 17/85 net-ipv6: fix excessive RTF_ADDRCONF flag on ::1/128 local route (and others)
In reply to Greg Kroah-HartmanFrom: "Maciej Żenczykowski" <[email protected]>
[ Upstream commit d55a2e374a94fa34a3048c6a2be535266e506d97 ]
There is a subtle change in behaviour introduced by:
commit c7a1ce397adacaf5d4bb2eab0a738b5f80dc3e43 'ipv6: Change addrconf_f6i_alloc to use ip6_route_info_create'
Before that patch /proc/net/ipv6_route includes:
00000000000000000000000000000001 80 00000000000000000000000000000000 00 00000000000000000000000000000000 00000000 00000003 00000000 80200001 lo
Afterwards /proc/net/ipv6_route includes:
00000000000000000000000000000001 80 00000000000000000000000000000000 00 00000000000000000000000000000000 00000000 00000002 00000000 80240001 lo
ie. the above commit causes the ::1/128 local (automatic) route to be flagged with RTF_ADDRCONF (0x040000).
AFAICT, this is incorrect since these routes are *not* coming from RA's.
As such, this patch restores the old behaviour.
--- net/ipv6/route.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
net/ipv6/route.c +6 -2
@@ -3841,13 +3841,14 @@ struct fib6_info *addrconf_f6i_alloc(strstruct fib6_config cfg = { .fc_table =l3mdev_fib_table (idev->dev) ? :RT6_TABLE_LOCAL , .fc_ifindex = idev->dev->ifindex, - .fc_flags =RTF_UP |RTF_ADDRCONF |RTF_NONEXTHOP , + .fc_flags =RTF_UP |RTF_NONEXTHOP , .fc_dst = *addr, .fc_dst_len =128 , .fc_protocol =RTPROT_KERNEL , .fc_nlinfo.nl_net = net, .fc_ignore_dev_down = true, }; +struct fib6_info *f6i;if (anycast) { cfg.fc_type =RTN_ANYCAST ;
@@ -3857,7 +3858,10 @@ struct fib6_info *addrconf_f6i_alloc(str cfg.fc_flags |=RTF_LOCAL ; } -return ip6_route_info_create (&cfg, gfp_flags,NULL ); + f6i =ip6_route_info_create (&cfg, gfp_flags,NULL ); +if (f6i) + f6i->dst_nocount = true; +return f6i; }/* remove deleted ip from prefsrc entries */
Greg Kroah-Hartman
maintainerPATCH 18/85 ipv6: addrconf_f6i_alloc - fix non-null pointer check to !IS_ERR()
In reply to Greg Kroah-HartmanFrom: "Maciej Żenczykowski" <[email protected]>
[ Upstream commit 8652f17c658d03f5c87b8dee6e8e52480c6cd37d ]
Fixes a stupid bug I recently introduced... ip6_route_info_create() returns an ERR_PTR(err) and not a NULL on error.
--- net/ipv6/route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/route.c +1 -1
@@ -3859,7 +3859,7 @@ struct fib6_info *addrconf_f6i_alloc(str } f6i =ip6_route_info_create (&cfg, gfp_flags,NULL ); -if (f6i) +if (!IS_ERR (f6i)) f6i->dst_nocount = true;return f6i; }
Greg Kroah-Hartman
maintainerPATCH 19/85 net: fixed_phy: Add forward declaration for struct gpio_desc;
In reply to Greg Kroah-HartmanFrom: Moritz Fischer <[email protected]>
[ Upstream commit ebe26aca98fcf9fbe5017b5cbe216413cee69df5 ]
Add forward declaration for struct gpio_desc in order to address the following:
./include/linux/phy_fixed.h:48:17: error: 'struct gpio_desc' declared inside parameter list [-Werror] ./include/linux/phy_fixed.h:48:17: error: its scope is only this definition or declaration, which is probably not what you want [-Werror]
--- include/linux/phy_fixed.h | 1 + 1 file changed, 1 insertion(+)
include/linux/phy_fixed.h +1 -0
@@ -11,6 +11,7 @@ struct fixed_phy_status { };struct device_node ; +struct gpio_desc ;#if IS_ENABLED (CONFIG_FIXED_PHY )extern int fixed_phy_change_carrier (struct net_device *dev,bool new_carrier);
Greg Kroah-Hartman
maintainerPATCH 20/85 sctp: fix the missing put_user when dumping transport thresholds
In reply to Greg Kroah-HartmanFrom: Xin Long <[email protected]>
[ Upstream commit f794dc2304d83ab998c2eee5bab0549aff5c53a2 ]
This issue causes SCTP_PEER_ADDR_THLDS sockopt not to be able to dump a transport thresholds info.
Fix it by adding 'goto' put_user in sctp_getsockopt_paddr_thresholds.
--- net/sctp/socket.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/sctp/socket.c +2 -1
@@ -7176,7 +7176,7 @@ static int sctp_getsockopt_paddr_thresho val.spt_pathmaxrxt = trans->pathmaxrxt; val.spt_pathpfthld = trans->pf_retrans; -return 0 ; + goto out; } asoc =sctp_id2assoc (sk, val.spt_assoc_id);
@@ -7194,6 +7194,7 @@ static int sctp_getsockopt_paddr_thresho val.spt_pathmaxrxt = sp->pathmaxrxt; } +out:if (put_user (len, optlen) ||copy_to_user (optval, &val, len))return -EFAULT ;
Greg Kroah-Hartman
maintainerPATCH 21/85 net: sock_map, fix missing ulp check in sock hash case
In reply to Greg Kroah-HartmanFrom: John Fastabend <[email protected]>
[ Upstream commit 44580a0118d3ede95fec4dce32df5f75f73cd663 ]
sock_map and ULP only work together when ULP is loaded after the sock map is loaded. In the sock_map case we added a check for this to fail the load if ULP is already set. However, we missed the check on the sock_hash side.
Add a ULP check to the sock_hash update path.
--- net/core/sock_map.c | 3 +++ 1 file changed, 3 insertions(+)
net/core/sock_map.c +3 -0
@@ -661,6 +661,7 @@ static int sock_hash_update_common(struc struct sock *sk, u64 flags) { struct bpf_htab *htab = container_of(map, struct bpf_htab, map); +struct inet_connection_sock *icsk =inet_csk (sk);u32 key_size = map->key_size, hash;struct bpf_htab_elem *elem, *elem_new;struct bpf_htab_bucket *bucket;
@@ -671,6 +672,8 @@ static int sock_hash_update_common(strucWARN_ON_ONCE (!rcu_read_lock_held ());if (unlikely (flags >BPF_EXIST ))return -EINVAL ; +if (unlikely (icsk->icsk_ulp_data)) +return -EINVAL ; link =sk_psock_init_link ();if (!link)
Greg Kroah-Hartman
maintainerPATCH 22/85 gpiolib: acpi: Add gpiolib_acpi_run_edge_events_on_boot option and blacklist
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
commit 61f7f7c8f978b1c0d80e43c83b7d110ca0496eb4 upstream.
Another day; another DSDT bug we need to workaround...
Since commit ca876c7483b6 ("gpiolib-acpi: make sure we trigger edge events at least once on boot") we call _AEI edge handlers at boot.
In some rare cases this causes problems. One example of this is the Minix Neo Z83-4 mini PC, this device has a clear DSDT bug where it has some copy and pasted code for dealing with Micro USB-B connector host/device role switching, while the mini PC does not even have a micro-USB connector. This code, which should not be there, messes with the DDC data pin from the HDMI connector (switching it to GPIO mode) breaking HDMI support.
To avoid problems like this, this commit adds a new gpiolib_acpi.run_edge_events_on_boot kernel commandline option, which allows disabling the running of _AEI edge event handlers at boot.
The default value is -1/auto which uses a DMI based blacklist, the initial version of this blacklist contains the Neo Z83-4 fixing the HDMI breakage.
--- drivers/gpio/gpiolib-acpi.c | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-)
drivers/gpio/gpiolib-acpi.c +38 -4
@@ -7,6 +7,7 @@* Mika Westerberg <[email protected]> */ +#include <linux/dmi.h> #include <linux/errno.h> #include <linux/gpio/consumer.h> #include <linux/gpio/driver.h>
@@ -19,6 +20,11 @@#include "gpiolib.h" +static int run_edge_events_on_boot =-1 ; +module_param (run_edge_events_on_boot, int,0444 ); +MODULE_PARM_DESC (run_edge_events_on_boot, +"Run edge _AEI event-handlers at boot: 0=no, 1=yes, -1=auto" ); +/** * struct acpi_gpio_event - ACPI GPIO event handler data *
@@ -170,10 +176,13 @@ static void acpi_gpiochip_request_irq(st event->irq_requested = true;/* Make sure we trigger the initial state of edge-triggered IRQs */ - value =gpiod_get_raw_value_cansleep (event->desc); -if (((event->irqflags &IRQF_TRIGGER_RISING ) && value ==1 ) || - ((event->irqflags &IRQF_TRIGGER_FALLING ) && value ==0 )) - event->handler (event->irq, event); +if (run_edge_events_on_boot && + (event->irqflags & (IRQF_TRIGGER_RISING |IRQF_TRIGGER_FALLING ))) { + value =gpiod_get_raw_value_cansleep (event->desc); +if (((event->irqflags &IRQF_TRIGGER_RISING ) && value ==1 ) || + ((event->irqflags &IRQF_TRIGGER_FALLING ) && value ==0 )) + event->handler (event->irq, event); + } }static void acpi_gpiochip_request_irqs (struct acpi_gpio_chip *acpi_gpio)
@@ -1283,3 +1292,28 @@ static int acpi_gpio_handle_deferred_req }/* We must use _sync so that this runs after the first deferred_probe run */ late_initcall_sync (acpi_gpio_handle_deferred_request_irqs); + +static const struct dmi_system_id run_edge_events_on_boot_blacklist[] = { + { + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"MINIX" ), +DMI_MATCH (DMI_PRODUCT_NAME ,"Z83-4" ), + } + }, + {}/* Terminating entry */ +}; + +static int acpi_gpio_setup_params (void ) +{ +if (run_edge_events_on_boot <0 ) { +if (dmi_check_system (run_edge_events_on_boot_blacklist)) + run_edge_events_on_boot =0 ; +else + run_edge_events_on_boot =1 ; + } + +return 0 ; +} + +/* Directly after dmi_setup() which runs as core_initcall() */ +postcore_initcall (acpi_gpio_setup_params);
Greg Kroah-Hartman
maintainerPATCH 23/85 gpio: mockup: add missing single_release()
In reply to Greg Kroah-HartmanFrom: Wei Yongjun <[email protected]>
commit 59929d3a2eb6c4abafc5b61a20c98aa8728ec378 upstream.
When using single_open() for opening, single_release() should be used instead of seq_release(), otherwise there is a memory leak.
--- drivers/gpio/gpio-mockup.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpio/gpio-mockup.c +1 -0
@@ -309,6 +309,7 @@ static const struct file_operations gpio .read = gpio_mockup_debugfs_read, .write = gpio_mockup_debugfs_write, .llseek = no_llseek, + .release = single_release, }; static void gpio_mockup_debugfs_setup(struct device *dev,
Greg Kroah-Hartman
maintainerPATCH 24/85 gpio: fix line flag validation in linehandle_create
In reply to Greg Kroah-HartmanFrom: Kent Gibson <[email protected]>
commit e95fbc130a162ba9ad956311b95aa0da269eea48 upstream.
linehandle_create should not allow both GPIOHANDLE_REQUEST_INPUT and GPIOHANDLE_REQUEST_OUTPUT to be set.
--- drivers/gpio/gpiolib.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpio/gpiolib.c +8 -0
@@ -536,6 +536,14 @@ static int linehandle_create(struct gpioreturn -EINVAL ;/* +* Do not allow both INPUT & OUTPUT flags to be set as they are +* contradictory. +*/ +if ((lflags &GPIOHANDLE_REQUEST_INPUT ) && + (lflags &GPIOHANDLE_REQUEST_OUTPUT )) +return -EINVAL ; + +/* * Do not allow OPEN_SOURCE & OPEN_DRAIN flags in a single request. If * the hardware actually supports enabling both at the same time the * electrical result would be disastrous.
Greg Kroah-Hartman
maintainerPATCH 25/85 gpio: fix line flag validation in lineevent_create
In reply to Greg Kroah-HartmanFrom: Kent Gibson <[email protected]>
commit 5ca2f54b597c816df54ff1b28eb99cf7262b955d upstream.
lineevent_create should not allow any of GPIOHANDLE_REQUEST_OUTPUT, GPIOHANDLE_REQUEST_OPEN_DRAIN or GPIOHANDLE_REQUEST_OPEN_SOURCE to be set.
--- drivers/gpio/gpiolib.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/gpio/gpiolib.c +3 -5
@@ -934,7 +934,9 @@ static int lineevent_create(struct gpio_ }/* This is just wrong: we don't look for events on output lines */ -if (lflags &GPIOHANDLE_REQUEST_OUTPUT ) { +if ((lflags &GPIOHANDLE_REQUEST_OUTPUT ) || + (lflags &GPIOHANDLE_REQUEST_OPEN_DRAIN ) || + (lflags &GPIOHANDLE_REQUEST_OPEN_SOURCE )) { ret = -EINVAL ; goto out_free_label; }
@@ -948,10 +950,6 @@ static int lineevent_create(struct gpio_if (lflags &GPIOHANDLE_REQUEST_ACTIVE_LOW )set_bit (FLAG_ACTIVE_LOW , &desc->flags); -if (lflags &GPIOHANDLE_REQUEST_OPEN_DRAIN ) -set_bit (FLAG_OPEN_DRAIN , &desc->flags); -if (lflags &GPIOHANDLE_REQUEST_OPEN_SOURCE ) -set_bit (FLAG_OPEN_SOURCE , &desc->flags); ret =gpiod_direction_input (desc);if (ret)
Greg Kroah-Hartman
maintainerPATCH 26/85 Btrfs: fix assertion failure during fsync and use of stale transaction
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit 410f954cb1d1c79ae485dd83a175f21954fd87cd upstream.
Sometimes when fsync'ing a file we need to log that other inodes exist and when we need to do that we acquire a reference on the inodes and then drop that reference using iput() after logging them.
That generally is not a problem except if we end up doing the final iput() (dropping the last reference) on the inode and that inode has a link count of 0, which can happen in a very short time window if the logging path gets a reference on the inode while it's being unlinked.
In that case we end up getting the eviction callback, btrfs_evict_inode(), invoked through the iput() call chain which needs to drop all of the inode's items from its subvolume btree, and in order to do that, it needs to join a transaction at the helper function evict_refill_and_join(). However because the task previously started a transaction at the fsync handler, btrfs_sync_file(), it has current->journal_info already pointing to a transaction handle and therefore evict_refill_and_join() will get that transaction handle from btrfs_join_transaction(). From this point on, two different problems can happen:
1) evict_refill_and_join() will often change the transaction handle's block reserve (->block_rsv) and set its ->bytes_reserved field to a value greater than 0. If evict_refill_and_join() never commits the transaction, the eviction handler ends up decreasing the reference count (->use_count) of the transaction handle through the call to btrfs_end_transaction(), and after that point we have a transaction handle with a NULL ->block_rsv (which is the value prior to the transaction join from evict_refill_and_join()) and a ->bytes_reserved value greater than 0. If after the eviction/iput completes the inode logging path hits an error or it decides that it must fallback to a transaction commit, the btrfs fsync handle, btrfs_sync_file(), gets a non-zero value from btrfs_log_dentry_safe(), and because of that non-zero value it tries to commit the transaction using a handle with a NULL ->block_rsv and a non-zero ->bytes_reserved value. This makes the transaction commit hit an assertion failure at btrfs_trans_release_metadata() because ->bytes_reserved is not zero but the ->block_rsv is NULL. The produced stack trace for that is like the following:
[192922.917158] assertion failed: !trans->bytes_reserved, file: fs/btrfs/transaction.c, line: 816 [192922.917553] ------------[ cut here ]------------ [192922.917922] kernel BUG at fs/btrfs/ctree.h:3532! [192922.918310] invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC PTI [192922.918666] CPU: 2 PID: 883 Comm: fsstress Tainted: G W 5.1.4-btrfs-next-47 #1 [192922.919035] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.11.2-0-gf9626ccb91-prebuilt.qemu-project.org 04/01/2014 [192922.919801] RIP: 0010:assfail.constprop.25+0x18/0x1a [btrfs] (...) [192922.920925] RSP: 0018:ffffaebdc8a27da8 EFLAGS: 00010286 [192922.921315] RAX: 0000000000000051 RBX: ffff95c9c16a41c0 RCX: 0000000000000000 [192922.921692] RDX: 0000000000000000 RSI: ffff95cab6b16838 RDI: ffff95cab6b16838 [192922.922066] RBP: ffff95c9c16a41c0 R08: 0000000000000000 R09: 0000000000000000 [192922.922442] R10: ffffaebdc8a27e70 R11: 0000000000000000 R12: ffff95ca731a0980 [192922.922820] R13: 0000000000000000 R14: ffff95ca84c73338 R15: ffff95ca731a0ea8 [192922.923200] FS: 00007f337eda4e80(0000) GS:ffff95cab6b00000(0000) knlGS:0000000000000000 [192922.923579] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [192922.923948] CR2: 00007f337edad000 CR3: 00000001e00f6002 CR4: 00000000003606e0 [192922.924329] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [192922.924711] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [192922.925105] Call Trace: [192922.925505] btrfs_trans_release_metadata+0x10c/0x170 [btrfs] [192922.925911] btrfs_commit_transaction+0x3e/0xaf0 [btrfs] [192922.926324] btrfs_sync_file+0x44c/0x490 [btrfs] [192922.926731] do_fsync+0x38/0x60 [192922.927138] __x64_sys_fdatasync+0x13/0x20 [192922.927543] do_syscall_64+0x60/0x1c0 [192922.927939] entry_SYSCALL_64_after_hwframe+0x49/0xbe (...) [192922.934077] ---[ end trace f00808b12068168f ]---
2) If evict_refill_and_join() decides to commit the transaction, it will be able to do it, since the nested transaction join only increments the transaction handle's ->use_count reference counter and it does not prevent the transaction from getting committed. This means that after eviction completes, the fsync logging path will be using a transaction handle that refers to an already committed transaction. What happens when using such a stale transaction can be unpredictable, we are at least having a use-after-free on the transaction handle itself, since the transaction commit will call kmem_cache_free() against the handle regardless of its ->use_count value, or we can end up silently losing all the updates to the log tree after that iput() in the logging path, or using a transaction handle that in the meanwhile was allocated to another task for a new transaction, etc, pretty much unpredictable what can happen.
In order to fix both of them, instead of using iput() during logging, use btrfs_add_delayed_iput(), so that the logging path of fsync never drops the last reference on an inode, that step is offloaded to a safe context (usually the cleaner kthread).
The assertion failure issue was sporadically triggered by the test case generic/475 from fstests, which loads the dm error target while fsstress is running, which lead to fsync failing while logging inodes with -EIO errors and then trying later to commit the transaction, triggering the assertion failure.
--- fs/btrfs/tree-log.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
fs/btrfs/tree-log.c +8 -8
@@ -4985,7 +4985,7 @@ static int log_conflicting_inodes(structBTRFS_I (inode),LOG_OTHER_INODE_ALL , 0, LLONG_MAX, ctx); -iput (inode); +btrfs_add_delayed_iput (inode); } }continue ;
@@ -5000,7 +5000,7 @@ static int log_conflicting_inodes(struct ret =btrfs_log_inode (trans, root,BTRFS_I (inode),LOG_OTHER_INODE ,0 ,LLONG_MAX , ctx);if (ret) { -iput (inode); +btrfs_add_delayed_iput (inode);continue ; }
@@ -5009,7 +5009,7 @@ static int log_conflicting_inodes(struct key.offset =0 ; ret =btrfs_search_slot (NULL , root, &key, path,0 ,0 );if (ret <0 ) { -iput (inode); +btrfs_add_delayed_iput (inode);continue ; }
@@ -5056,7 +5056,7 @@ static int log_conflicting_inodes(struct } path->slots[0 ]++; } -iput (inode); +btrfs_add_delayed_iput (inode); }return ret;
@@ -5689,7 +5689,7 @@ process_leaf: }if (btrfs_inode_in_log (BTRFS_I (di_inode), trans->transid)) { -iput (di_inode); +btrfs_add_delayed_iput (di_inode);break ; }
@@ -5701,7 +5701,7 @@ process_leaf:if (!ret &&btrfs_must_commit_transaction (trans,BTRFS_I (di_inode))) ret =1 ; -iput (di_inode); +btrfs_add_delayed_iput (di_inode);if (ret) goto next_dir_inode;if (ctx->log_new_dentries) {
@@ -5848,7 +5848,7 @@ static int btrfs_log_all_parents(structif (!ret && ctx && ctx->log_new_dentries) ret =log_new_dir_dentries (trans, root,BTRFS_I (dir_inode), ctx); -iput (dir_inode); +btrfs_add_delayed_iput (dir_inode);if (ret) goto out; }
@@ -5891,7 +5891,7 @@ static int log_new_ancestors(struct btrf ret =btrfs_log_inode (trans, root,BTRFS_I (inode),LOG_INODE_EXISTS ,0 ,LLONG_MAX , ctx); -iput (inode); +btrfs_add_delayed_iput (inode);if (ret)return ret;
Greg Kroah-Hartman
maintainerPATCH 27/85 cgroup: freezer: fix frozen state inheritance
In reply to Greg Kroah-HartmanFrom: Roman Gushchin <[email protected]>
commit 97a61369830ab085df5aed0ff9256f35b07d425a upstream.
If a new child cgroup is created in the frozen cgroup hierarchy (one or more of ancestor cgroups is frozen), the CGRP_FREEZE cgroup flag should be set. Otherwise if a process will be attached to the child cgroup, it won't become frozen.
The problem can be reproduced with the test_cgfreezer_mkdir test.
This is the output before this patch:
~/test_freezer
ok 1 test_cgfreezer_simple
ok 2 test_cgfreezer_tree
ok 3 test_cgfreezer_forkbomb
Cgroup /sys/fs/cgroup/cg_test_mkdir_A/cg_test_mkdir_B isn't frozen not ok 4 test_cgfreezer_mkdir
ok 5 test_cgfreezer_rmdir
ok 6 test_cgfreezer_migrate
ok 7 test_cgfreezer_ptrace
ok 8 test_cgfreezer_stopped
ok 9 test_cgfreezer_ptraced
ok 10 test_cgfreezer_vfork
And with this patch:
~/test_freezer
ok 1 test_cgfreezer_simple
ok 2 test_cgfreezer_tree
ok 3 test_cgfreezer_forkbomb
ok 4 test_cgfreezer_mkdir
ok 5 test_cgfreezer_rmdir
ok 6 test_cgfreezer_migrate
ok 7 test_cgfreezer_ptrace
ok 8 test_cgfreezer_stopped
ok 9 test_cgfreezer_ptraced
ok 10 test_cgfreezer_vfork
--- kernel/cgroup/cgroup.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
kernel/cgroup/cgroup.c +9 -1
@@ -5213,8 +5213,16 @@ static struct cgroup *cgroup_create(stru* if the parent has to be frozen, the child has too. */ cgrp->freezer.e_freeze = parent->freezer.e_freeze; -if (cgrp->freezer.e_freeze) +if (cgrp->freezer.e_freeze) { +/* +* Set the CGRP_FREEZE flag, so when a process will be +* attached to the child cgroup, it will become frozen. +* At this point the new cgroup is unpopulated, so we can +* consider it frozen immediately. +*/ +set_bit (CGRP_FREEZE , &cgrp->flags);set_bit (CGRP_FROZEN , &cgrp->flags); + }spin_lock_irq (&css_set_lock);for (tcgrp = cgrp; tcgrp; tcgrp =cgroup_parent (tcgrp)) {
Greg Kroah-Hartman
maintainerPATCH 28/85 Revert "mmc: bcm2835: Terminate timeout work synchronously"
In reply to Greg Kroah-HartmanFrom: Stefan Wahren <[email protected]>
commit aea64b583601aa5e0d6ea51a0420e46e43710bd4 upstream.
The commit 37fefadee8bb ("mmc: bcm2835: Terminate timeout work synchronously") causes lockups in case of hardware timeouts due the timeout work also calling cancel_delayed_work_sync() on its own. So revert it.
--- drivers/mmc/host/bcm2835.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/bcm2835.c +1 -1
@@ -597,7 +597,7 @@ static void bcm2835_finish_request(strucstruct dma_chan *terminate_chan =NULL ;struct mmc_request *mrq; -cancel_delayed_work_sync (&host->timeout_work); +cancel_delayed_work (&host->timeout_work); mrq = host->mrq;
Greg Kroah-Hartman
maintainerPATCH 29/85 Revert "mmc: sdhci: Remove unneeded quirk2 flag of O2 SD host controller"
In reply to Greg Kroah-HartmanFrom: Daniel Drake <[email protected]>
commit 49baa01c8b99ef92958e18fb58ebeb5dfdcde8af upstream.
This reverts commit 414126f9e5abf1973c661d24229543a9458fa8ce.
This commit broke eMMC storage access on a new consumer MiniPC based on AMD SoC, which has eMMC connected to:
02:00.0 SD Host controller: O2 Micro, Inc. Device 8620 (rev 01) (prog-if 01)
Subsystem: O2 Micro, Inc. Device 0002
During probe, several errors are seen including:
mmc1: Got data interrupt 0x02000000 even though no data operation was in progress.
mmc1: Timeout waiting for hardware interrupt.
mmc1: error -110 whilst initialising MMC card
Reverting this commit allows the eMMC storage to be detected & usable again.
controller")
--- drivers/mmc/host/sdhci-pci-o2micro.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci-pci-o2micro.c +1 -1
@@ -432,7 +432,6 @@ int sdhci_pci_o2_probe_slot(struct sdhci mmc_hostname(host->mmc)); host->flags &= ~SDHCI_SIGNALING_330 ; host->flags |=SDHCI_SIGNALING_180 ; - host->quirks2 |=SDHCI_QUIRK2_CLEAR_TRANSFERMODE_REG_BEFORE_CMD ; host->mmc->caps2 |=MMC_CAP2_NO_SD ; host->mmc->caps2 |=MMC_CAP2_NO_SDIO ; pci_write_config_dword(chip->pdev,
@@ -682,6 +681,7 @@ static const struct sdhci_ops sdhci_pci_const struct sdhci_pci_fixes sdhci_o2 = { .probe = sdhci_pci_o2_probe, .quirks =SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC , + .quirks2 =SDHCI_QUIRK2_CLEAR_TRANSFERMODE_REG_BEFORE_CMD , .probe_slot = sdhci_pci_o2_probe_slot, #ifdef CONFIG_PM_SLEEP .resume = sdhci_pci_o2_resume,
Greg Kroah-Hartman
maintainerPATCH 30/85 mmc: tmio: Fixup runtime PM management during probe
In reply to Greg Kroah-HartmanFrom: Ulf Hansson <[email protected]>
commit aa86f1a3887523d78bfadd1c4e4df8f919336511 upstream.
The tmio_mmc_host_probe() calls pm_runtime_set_active() to update the runtime PM status of the device, as to make it reflect the current status of the HW. This works fine for most cases, but unfortunate not for all. Especially, there is a generic problem when the device has a genpd attached and that genpd have the ->start|stop() callbacks assigned.
More precisely, if the driver calls pm_runtime_set_active() during ->probe(), genpd does not get to invoke the ->start() callback for it, which means the HW isn't really fully powered on. Furthermore, in the next phase, when the device becomes runtime suspended, genpd will invoke the ->stop() callback for it, potentially leading to usage count imbalance problems, depending on what's implemented behind the callbacks of course.
To fix this problem, convert to call pm_runtime_get_sync() from tmio_mmc_host_probe() rather than pm_runtime_set_active(). Additionally, to avoid bumping usage counters and unnecessary re-initializing the HW the first time the tmio driver's ->runtime_resume() callback is called, introduce a state flag to keeping track of this.
--- drivers/mmc/host/tmio_mmc.h | 1 + drivers/mmc/host/tmio_mmc_core.c | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/mmc/host/tmio_mmc.h +1 -0
@@ -163,6 +163,7 @@ struct tmio_mmc_host {unsigned long last_req_ts;struct mutex ios_lock;/* protect set_ios() context */ bool native_hotplug; +bool runtime_synced;bool sdio_irq_enabled;/* Mandatory callback */
drivers/mmc/host/tmio_mmc_core.c +8 -1
@@ -1258,20 +1258,22 @@ int tmio_mmc_host_probe(struct tmio_mmc_/* See if we also get DMA */ tmio_mmc_request_dma (_host, pdata); -pm_runtime_set_active (&pdev->dev);pm_runtime_set_autosuspend_delay (&pdev->dev,50 );pm_runtime_use_autosuspend (&pdev->dev);pm_runtime_enable (&pdev->dev); +pm_runtime_get_sync (&pdev->dev); ret =mmc_add_host (mmc);if (ret) goto remove_host;dev_pm_qos_expose_latency_limit (&pdev->dev,100 ); +pm_runtime_put (&pdev->dev);return 0 ; remove_host: +pm_runtime_put_noidle (&pdev->dev);tmio_mmc_host_remove (_host);return ret; }
@@ -1340,6 +1342,11 @@ int tmio_mmc_host_runtime_resume(struct {struct tmio_mmc_host *host =dev_get_drvdata (dev); +if (!host->runtime_synced) { + host->runtime_synced = true; +return 0 ; + } +tmio_mmc_clk_enable (host);tmio_mmc_hw_reset (host->mmc);
Greg Kroah-Hartman
maintainerPATCH 31/85 mmc: tmio: Fixup runtime PM management during remove
In reply to Greg Kroah-HartmanFrom: Ulf Hansson <[email protected]>
commit 87b5d602a1cc76169b8d81ec2c74c8d95d9350dc upstream.
Accessing the device when it may be runtime suspended is a bug, which is the case in tmio_mmc_host_remove(). Let's fix the behaviour.
--- drivers/mmc/host/tmio_mmc_core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/mmc/host/tmio_mmc_core.c +4 -3
@@ -1284,12 +1284,11 @@ void tmio_mmc_host_remove(struct tmio_mmstruct platform_device *pdev = host->pdev;struct mmc_host *mmc = host->mmc; +pm_runtime_get_sync (&pdev->dev); +if (host->pdata->flags &TMIO_MMC_SDIO_IRQ )sd_ctrl_write16 (host,CTL_TRANSACTION_CTL ,0x0000 ); -if (!host->native_hotplug) -pm_runtime_get_sync (&pdev->dev); -dev_pm_qos_hide_latency_limit (&pdev->dev);mmc_remove_host (mmc);
@@ -1298,6 +1297,8 @@ void tmio_mmc_host_remove(struct tmio_mmtmio_mmc_release_dma (host);pm_runtime_dont_use_autosuspend (&pdev->dev); +if (host->native_hotplug) +pm_runtime_put_noidle (&pdev->dev);pm_runtime_put_sync (&pdev->dev);pm_runtime_disable (&pdev->dev); }
Greg Kroah-Hartman
maintainerPATCH 32/85 drm/lima: fix lima_gem_wait() return value
In reply to Greg Kroah-HartmanFrom: Vasily Khoruzhick <[email protected]>
commit 21670bd78a25001cf8ef2679b378c73fb73b904f upstream.
drm_gem_reservation_object_wait() returns 0 if it succeeds and -ETIME if it timeouts, but lima driver assumed that 0 is error.
--- drivers/gpu/drm/lima/lima_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/lima/lima_gem.c +1 -1
@@ -342,7 +342,7 @@ int lima_gem_wait(struct drm_file *file, timeout =drm_timeout_abs_to_jiffies (timeout_ns); ret =drm_gem_reservation_object_wait (file, handle, write, timeout); -if (ret ==0 ) +if (ret == -ETIME ) ret = timeout ? -ETIMEDOUT : -EBUSY ;return ret;
Greg Kroah-Hartman
maintainerPATCH 33/85 drm/i915: Limit MST to <= 8bpc once again
In reply to Greg Kroah-HartmanFrom: Ville Syrjälä <[email protected]>
commit bb1a71f9c4672fbfcf2158fd57d0c5c0cdae5612 upstream.
My attempt at allowing MST to use the higher color depths has regressed some configurations. Apparently people have setups where all MST streams will fit into the DP link with 8bpc but won't fit with higher color depths.
What we really should be doing is reducing the bpc for all the streams on the same link until they start to fit. But that requires a bit more work, so in the meantime let's revert back closer to the old behavior and limit MST to at most 8bpc.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111505
--- drivers/gpu/drm/i915/intel_dp_mst.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_dp_mst.c +9 -1
@@ -125,7 +125,15 @@ static int intel_dp_mst_compute_config(s limits.max_lane_count =intel_dp_max_lane_count (intel_dp); limits.min_bpp =intel_dp_min_bpp (pipe_config); - limits.max_bpp = pipe_config->pipe_bpp; +/* +* FIXME: If all the streams can't fit into the link with +* their current pipe_bpp we should reduce pipe_bpp across +* the board until things start to fit. Until then we +* limit to <= 8bpc since that's what was hardcoded for all +* MST streams previously. This hack should be removed once +* we have the proper retry logic in place. +*/ + limits.max_bpp =min (pipe_config->pipe_bpp,24 );intel_dp_adjust_compliance_config (intel_dp, pipe_config, &limits);
Greg Kroah-Hartman
maintainerPATCH 34/85 drm/i915: Restore relaxed padding (OCL_OOB_SUPPRES_ENABLE) for skl+
In reply to Greg Kroah-HartmanFrom: Chris Wilson <[email protected]>
commit 2eb0964eec5f1d99f9eaf4963eee267acc72b615 upstream.
This bit was fliped on for "syncing dependencies between camera and graphics". BSpec has no recollection why, and it is causing unrecoverable GPU hangs with Vulkan compute workloads.
Quoted 1 line
From BSpec, setting bit5 to 0 enables relaxed padding requirements for
buffers, 1D and 2D non-array, non-MSAA, non-mip-mapped linear surfaces; and *must* be set to 0h on skl+ to ensure "Out of Bounds" case is suppressed.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110998
--- drivers/gpu/drm/i915/intel_workarounds.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/gpu/drm/i915/intel_workarounds.c +0 -5
@@ -294,11 +294,6 @@ static void gen9_ctx_workarounds_init(stFLOW_CONTROL_ENABLE | PARTIAL_INSTRUCTION_SHOOTDOWN_DISABLE); -/* Syncing dependencies between camera and graphics:skl,bxt,kbl */ -if (!IS_COFFEELAKE (i915)) -WA_SET_BIT_MASKED (HALF_SLICE_CHICKEN3 , -GEN9_DISABLE_OCL_OOB_SUPPRESS_LOGIC ); -/* WaEnableYV12BugFixInHalfSliceChicken7:skl,bxt,kbl,glk,cfl */ /* WaEnableSamplerGPGPUPreemptionSupport:skl,bxt,kbl,cfl */ WA_SET_BIT_MASKED(GEN9_HALF_SLICE_CHICKEN7,
Greg Kroah-Hartman
maintainerPATCH 35/85 ipc: fix semtimedop for generic 32-bit architectures
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
commit 78e05972c5e6c8e9ca4c00ccc6985409da69f904 upstream.
As Vincent noticed, the y2038 conversion of semtimedop in linux-5.1 broke when commit 00bf25d693e7 ("y2038: use time32 syscall names on 32-bit") changed all system calls on all architectures that take a 32-bit time_t to point to the _time32 implementation, but left out semtimedop in the asm-generic header.
This affects all 32-bit architectures using asm-generic/unistd.h:
h8300, unicore32, openrisc, nios2, hexagon, c6x, arc, nds32 and csky.
The notable exception is riscv32, which has dropped support for the time32 system calls entirely.
--- include/uapi/asm-generic/unistd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/asm-generic/unistd.h +1 -1
@@ -569,7 +569,7 @@ __SYSCALL(__NR_semget, sys_semget) __SC_COMP(__NR_semctl, sys_semctl, compat_sys_semctl)#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG !=32 #define __NR_semtimedop 192 -__SC_COMP(__NR_semtimedop, sys_semtimedop, sys_semtimedop_time32) +__SC_3264(__NR_semtimedop, sys_semtimedop_time32, sys_semtimedop)#endif #define __NR_semop 193__SYSCALL (__NR_semop, sys_semop)
Greg Kroah-Hartman
maintainerPATCH 36/85 ipc: fix sparc64 ipc() wrapper
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
commit fb377eb80c80339b580831a3c0fcce34a4c9d1ad upstream.
Matt bisected a sparc64 specific issue with semctl, shmctl and msgctl to a commit from my y2038 series in linux-5.1, as I missed the custom sys_ipc() wrapper that sparc64 uses in place of the generic version that I patched.
The problem is that the sys_{sem,shm,msg}ctl() functions in the kernel now do not allow being called with the IPC_64 flag any more, resulting in a -EINVAL error when they don't recognize the command.
Instead, the correct way to do this now is to call the internal ksys_old_{sem,shm,msg}ctl() functions to select the API version.
As we generally move towards these functions anyway, change all of sparc_ipc() to consistently use those in place of the sys_*() versions, and move the required ksys_*() declarations into linux/syscalls.h
The IS_ENABLED(CONFIG_SYSVIPC) check is required to avoid link errors when ipc is disabled.
--- arch/sparc/kernel/sys_sparc_64.c | 33 ++++++++++++++++++--------------- include/linux/syscalls.h | 19 +++++++++++++++++++ ipc/util.h | 25 ++----------------------- 3 files changed, 39 insertions(+), 38 deletions(-)
arch/sparc/kernel/sys_sparc_64.c +18 -15
@@ -336,25 +336,28 @@ SYSCALL_DEFINE6(sparc_ipc, unsigned int, {long err; +if (!IS_ENABLED (CONFIG_SYSVIPC )) +return -ENOSYS ; +/* No need for backward compatibility. We can start fresh... */ if (call <=SEMTIMEDOP ) {switch (call) {case SEMOP : - err =sys_semtimedop (first, ptr, - (unsigned int )second,NULL ); + err =ksys_semtimedop (first, ptr, + (unsigned int )second,NULL ); goto out;case SEMTIMEDOP : - err =sys_semtimedop (first, ptr, (unsigned int )second, + err =ksys_semtimedop (first, ptr, (unsigned int )second, (const struct __kernel_timespec __user *) - (unsigned long ) fifth); + (unsigned long ) fifth); goto out;case SEMGET : - err =sys_semget (first, (int )second, (int )third); + err =ksys_semget (first, (int )second, (int )third); goto out;case SEMCTL : { - err =sys_semctl (first, second, - (int )third |IPC_64 , - (unsigned long ) ptr); + err =ksys_old_semctl (first, second, + (int )third |IPC_64 , + (unsigned long ) ptr); goto out; }default :
@@ -365,18 +368,18 @@ SYSCALL_DEFINE6(sparc_ipc, unsigned int,if (call <=MSGCTL ) {switch (call) {case MSGSND : - err =sys_msgsnd (first, ptr, (size_t )second, + err =ksys_msgsnd (first, ptr, (size_t )second, (int )third); goto out;case MSGRCV : - err =sys_msgrcv (first, ptr, (size_t )second, fifth, + err =ksys_msgrcv (first, ptr, (size_t )second, fifth, (int )third); goto out;case MSGGET : - err =sys_msgget ((key_t )first, (int )second); + err =ksys_msgget ((key_t )first, (int )second); goto out;case MSGCTL : - err =sys_msgctl (first, (int )second |IPC_64 , ptr); + err =ksys_old_msgctl (first, (int )second |IPC_64 , ptr); goto out;default : err = -ENOSYS ;
@@ -396,13 +399,13 @@ SYSCALL_DEFINE6(sparc_ipc, unsigned int, goto out; }case SHMDT : - err =sys_shmdt (ptr); + err =ksys_shmdt (ptr); goto out;case SHMGET : - err =sys_shmget (first, (size_t )second, (int )third); + err =ksys_shmget (first, (size_t )second, (int )third); goto out;case SHMCTL : - err =sys_shmctl (first, (int )second |IPC_64 , ptr); + err =ksys_old_shmctl (first, (int )second |IPC_64 , ptr); goto out;default : err = -ENOSYS ;
include/linux/syscalls.h +19 -0
@@ -1397,4 +1397,23 @@ static inline unsigned int ksys_personal return old; } +/* for __ARCH_WANT_SYS_IPC */ +long ksys_semtimedop (int semid,struct sembuf __user *tsops, +unsigned int nsops, +const struct __kernel_timespec __user *timeout); +long ksys_semget (key_t key,int nsems,int semflg); +long ksys_old_semctl (int semid,int semnum,int cmd,unsigned long arg); +long ksys_msgget (key_t key,int msgflg); +long ksys_old_msgctl (int msqid,int cmd,struct msqid_ds __user *buf); +long ksys_msgrcv (int msqid,struct msgbuf __user *msgp,size_t msgsz, +long msgtyp,int msgflg); +long ksys_msgsnd (int msqid,struct msgbuf __user *msgp,size_t msgsz, +int msgflg); +long ksys_shmget (key_t key,size_t size,int shmflg); +long ksys_shmdt (char __user *shmaddr); +long ksys_old_shmctl (int shmid,int cmd,struct shmid_ds __user *buf); +long compat_ksys_semtimedop (int semid,struct sembuf __user *tsems, +unsigned int nsops, +const struct old_timespec32 __user *timeout); +#endif
ipc/util.h +2 -23
@@ -276,29 +276,7 @@ static inline int compat_ipc_parse_versi *cmd &= ~IPC_64 ;return version; } -#endif - -/* for __ARCH_WANT_SYS_IPC */ -long ksys_semtimedop (int semid,struct sembuf __user *tsops, -unsigned int nsops, -const struct __kernel_timespec __user *timeout); -long ksys_semget (key_t key,int nsems,int semflg); -long ksys_old_semctl (int semid,int semnum,int cmd,unsigned long arg); -long ksys_msgget (key_t key,int msgflg); -long ksys_old_msgctl (int msqid,int cmd,struct msqid_ds __user *buf); -long ksys_msgrcv (int msqid,struct msgbuf __user *msgp,size_t msgsz, -long msgtyp,int msgflg); -long ksys_msgsnd (int msqid,struct msgbuf __user *msgp,size_t msgsz, -int msgflg); -long ksys_shmget (key_t key,size_t size,int shmflg); -long ksys_shmdt (char __user *shmaddr); -long ksys_old_shmctl (int shmid,int cmd,struct shmid_ds __user *buf); -/* for CONFIG_ARCH_WANT_OLD_COMPAT_IPC */ -long compat_ksys_semtimedop (int semid,struct sembuf __user *tsems, -unsigned int nsops, -const struct old_timespec32 __user *timeout); -#ifdef CONFIG_COMPAT long compat_ksys_old_semctl (int semid,int semnum,int cmd,int arg);long compat_ksys_old_msgctl (int msqid,int cmd,void __user *uptr); long compat_ksys_msgrcv(int msqid, compat_uptr_t msgp, compat_ssize_t msgsz,
@@ -306,6 +284,7 @@ long compat_ksys_msgrcv(int msqid, compalong compat_ksys_msgsnd (int msqid,compat_uptr_t msgp,compat_ssize_t msgsz,int msgflg);long compat_ksys_old_shmctl (int shmid,int cmd,void __user *uptr); -#endif /* CONFIG_COMPAT */ + +#endif #endif
Greg Kroah-Hartman
maintainerPATCH 37/85 ixgbe: fix double clean of Tx descriptors with xdp
In reply to Greg Kroah-HartmanFrom: Ilya Maximets <[email protected]>
commit bf280c0387ebbf8eebad1036fca8f7b85ebfde32 upstream.
Tx code doesn't clear the descriptors' status after cleaning. So, if the budget is larger than number of used elems in a ring, some descriptors will be accounted twice and xsk_umem_complete_tx will move prod_tail far beyond the prod_head breaking the completion queue ring.
Fix that by limiting the number of descriptors to clean by the number of used descriptors in the Tx ring.
'ixgbe_clean_xdp_tx_irq()' function refactored to look more like 'ixgbe_xsk_clean_tx_ring()' since we're allowed to directly use 'next_to_clean' and 'next_to_use' indexes.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 29 ++++++++++----------------- 1 file changed, 11 insertions(+), 18 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +11 -18
@@ -679,19 +679,17 @@ static void ixgbe_clean_xdp_tx_buffer(stbool ixgbe_clean_xdp_tx_irq (struct ixgbe_q_vector *q_vector,struct ixgbe_ring *tx_ring,int napi_budget) { +u16 ntc = tx_ring->next_to_clean, ntu = tx_ring->next_to_use;unsigned int total_packets =0 , total_bytes =0 ; -u32 i = tx_ring->next_to_clean, xsk_frames =0 ; -unsigned int budget = q_vector->tx.work_limit;struct xdp_umem *umem = tx_ring->xsk_umem;union ixgbe_adv_tx_desc *tx_desc;struct ixgbe_tx_buffer *tx_bi; -bool xmit_done; +u32 xsk_frames =0 ; - tx_bi = &tx_ring->tx_buffer_info[i]; - tx_desc =IXGBE_TX_DESC (tx_ring, i); - i -= tx_ring->count; + tx_bi = &tx_ring->tx_buffer_info[ntc]; + tx_desc =IXGBE_TX_DESC (tx_ring, ntc); - do { +while (ntc != ntu) {if (!(tx_desc->wb.status &cpu_to_le32 (IXGBE_TXD_STAT_DD )))break ;
@@ -708,22 +706,18 @@ bool ixgbe_clean_xdp_tx_irq(struct ixgbe tx_bi++; tx_desc++; - i++; -if (unlikely (!i)) { - i -= tx_ring->count; + ntc++; +if (unlikely (ntc == tx_ring->count)) { + ntc =0 ; tx_bi = tx_ring->tx_buffer_info; tx_desc =IXGBE_TX_DESC (tx_ring,0 ); }/* issue prefetch for next Tx descriptor */ prefetch (tx_desc); + } -/* update budget accounting */ - budget--; - }while (likely (budget)); - - i += tx_ring->count; - tx_ring->next_to_clean = i; + tx_ring->next_to_clean = ntc;u64_stats_update_begin (&tx_ring->syncp); tx_ring->stats.bytes += total_bytes;
@@ -735,8 +729,7 @@ bool ixgbe_clean_xdp_tx_irq(struct ixgbeif (xsk_frames)xsk_umem_complete_tx (umem, xsk_frames); - xmit_done =ixgbe_xmit_zc (tx_ring, q_vector->tx.work_limit); -return budget >0 && xmit_done; +return ixgbe_xmit_zc (tx_ring, q_vector->tx.work_limit); }int ixgbe_xsk_async_xmit (struct net_device *dev,u32 qid)
Greg Kroah-Hartman
maintainerPATCH 38/85 ixgbe: Prevent u8 wrapping of ITR value to something less than 10us
In reply to Greg Kroah-HartmanFrom: Alexander Duyck <[email protected]>
commit 377228accbbb8b9738f615d791aa803f41c067e0 upstream.
There were a couple cases where the ITR value generated via the adaptive ITR scheme could exceed 126. This resulted in the value becoming either 0 or something less than 10. Switching back and forth between a value less than 10 and a value greater than 10 can cause issues as certain hardware features such as RSC to not function well when the ITR value has dropped that low.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +3 -1
@@ -2622,7 +2622,7 @@ adjust_by_size:/* 16K ints/sec to 9.2K ints/sec */ avg_wire_size *=15 ; avg_wire_size +=11452 ; - }else if (avg_wire_size <=1980 ) { + }else if (avg_wire_size <1968 ) {/* 9.2K ints/sec to 8K ints/sec */ avg_wire_size *=5 ; avg_wire_size +=22420 ;
@@ -2655,6 +2655,8 @@ adjust_by_size:case IXGBE_LINK_SPEED_2_5GB_FULL :case IXGBE_LINK_SPEED_1GB_FULL :case IXGBE_LINK_SPEED_10_FULL : +if (avg_wire_size >8064 ) + avg_wire_size =8064 ; itr +=DIV_ROUND_UP (avg_wire_size,IXGBE_ITR_ADAPTIVE_MIN_INC *64 ) *IXGBE_ITR_ADAPTIVE_MIN_INC ;
Greg Kroah-Hartman
maintainerPATCH 39/85 Revert "rt2800: enable TX_PIN_CFG_LNA_PE_ bits per band"
In reply to Greg Kroah-HartmanFrom: Stanislaw Gruszka <[email protected]>
commit 13fa451568ab9e8b3074ef741477c7938c713c42 upstream.
This reverts commit 9ad3b55654455258a9463384edb40077439d879f.
As reported by Sergey:
"I got some problem after upgrade kernel to 5.2 version (debian testing linux-image-5.2.0-2-amd64). 5Ghz client stopped to see AP. Some tests with 1metre distance between client-AP: 2.4Ghz -22dBm, for 5Ghz - 53dBm !, for longer distance (8m + walls) 2.4 - 61dBm, 5Ghz not visible."
It was identified that rx signal level degradation was caused by 9ad3b5565445 ("rt2800: enable TX_PIN_CFG_LNA_PE_ bits per band"). So revert this commit.
--- drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/net/wireless/ralink/rt2x00/rt2800lib.c +6 -12
@@ -4156,24 +4156,18 @@ static void rt2800_config_channel(structswitch (rt2x00dev->default_ant.rx_chain_num) {case 3 :/* Turn on tertiary LNAs */ -rt2x00_set_field32 (&tx_pin,TX_PIN_CFG_LNA_PE_A2_EN , - rf->channel >14 ); -rt2x00_set_field32 (&tx_pin,TX_PIN_CFG_LNA_PE_G2_EN , - rf->channel <=14 ); +rt2x00_set_field32 (&tx_pin,TX_PIN_CFG_LNA_PE_A2_EN ,1 ); +rt2x00_set_field32 (&tx_pin,TX_PIN_CFG_LNA_PE_G2_EN ,1 );/* fall-through */ case 2 :/* Turn on secondary LNAs */ -rt2x00_set_field32 (&tx_pin,TX_PIN_CFG_LNA_PE_A1_EN , - rf->channel >14 ); -rt2x00_set_field32 (&tx_pin,TX_PIN_CFG_LNA_PE_G1_EN , - rf->channel <=14 ); +rt2x00_set_field32 (&tx_pin,TX_PIN_CFG_LNA_PE_A1_EN ,1 ); +rt2x00_set_field32 (&tx_pin,TX_PIN_CFG_LNA_PE_G1_EN ,1 );/* fall-through */ case 1 :/* Turn on primary LNAs */ -rt2x00_set_field32 (&tx_pin,TX_PIN_CFG_LNA_PE_A0_EN , - rf->channel >14 ); -rt2x00_set_field32 (&tx_pin,TX_PIN_CFG_LNA_PE_G0_EN , - rf->channel <=14 ); +rt2x00_set_field32 (&tx_pin,TX_PIN_CFG_LNA_PE_A0_EN ,1 ); +rt2x00_set_field32 (&tx_pin,TX_PIN_CFG_LNA_PE_G0_EN ,1 );break ; }
Greg Kroah-Hartman
maintainerPATCH 40/85 mt76: mt76x0e: disable 5GHz band for MT7630E
In reply to Greg Kroah-HartmanFrom: Stanislaw Gruszka <[email protected]>
commit 70702265a04aa0ce5a7bde77d13456209992b32f upstream.
MT7630E hardware does support 5GHz, but we do not properly configure phy for 5GHz channels. Scanning at this band not only do not show any APs but also can hang the firmware.
Since vendor reference driver do not support 5GHz we don't know how properly configure 5GHz channels. So disable this band for MT7630E .
--- drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c +5 -0
@@ -59,6 +59,11 @@ static void mt76x0_set_chip_cap(struct mdev_dbg (dev->mt76.dev,"mask out 2GHz support\n" ); } +if (is_mt7630 (dev)) { + dev->mt76.cap.has_5ghz = false; +dev_dbg (dev->mt76.dev,"mask out 5GHz support\n" ); + } +if (!mt76x02_field_valid (nic_conf1 &0xff )) nic_conf1 &=0xff00 ;
Greg Kroah-Hartman
maintainerPATCH 41/85 genirq: Prevent NULL pointer dereference in resend_irqs()
In reply to Greg Kroah-HartmanFrom: Yunfeng Ye <[email protected]>
commit eddf3e9c7c7e4d0707c68d1bb22cc6ec8aef7d4a upstream.
The following crash was observed:
Unable to handle kernel NULL pointer dereference at 0000000000000158 Internal error: Oops: 96000004 [#1] SMP pc : resend_irqs+0x68/0xb0 lr : resend_irqs+0x64/0xb0 ... Call trace: resend_irqs+0x68/0xb0 tasklet_action_common.isra.6+0x84/0x138 tasklet_action+0x2c/0x38 __do_softirq+0x120/0x324 run_ksoftirqd+0x44/0x60 smpboot_thread_fn+0x1ac/0x1e8 kthread+0x134/0x138 ret_from_fork+0x10/0x18
The reason for this is that the interrupt resend mechanism happens in soft interrupt context, which is a asynchronous mechanism versus other operations on interrupts. free_irq() does not take resend handling into account. Thus, the irq descriptor might be already freed before the resend tasklet is executed. resend_irqs() does not check the return value of the interrupt descriptor lookup and derefences the return value unconditionally.
1):
__setup_irq
irq_startup
check_irq_resend // activate softirq to handle resend irq
2):
irq_domain_free_irqs
irq_free_descs
free_desc
call_rcu(&desc->rcu, delayed_free_desc) 3):
__do_softirq
tasklet_action
resend_irqs
desc = irq_to_desc(irq) desc->handle_irq(desc) // desc is NULL --> Ooops
Fix this by adding a NULL pointer check in resend_irqs() before derefencing the irq descriptor.
--- kernel/irq/resend.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/irq/resend.c +2 -0
@@ -36,6 +36,8 @@ static void resend_irqs(unsigned long ar irq =find_first_bit (irqs_resend, nr_irqs);clear_bit (irq, irqs_resend); desc =irq_to_desc (irq); +if (!desc) +continue ;local_irq_disable (); desc->handle_irq (desc);local_irq_enable ();
Greg Kroah-Hartman
maintainerPATCH 42/85 regulator: twl: voltage lists for vdd1/2 on twl4030
In reply to Greg Kroah-HartmanFrom: Andreas Kemnade <[email protected]>
commit 3829100a63724f6dbf264b2a7f06e7f638ed952d upstream.
_opp_supported_by_regulators() wrongly ignored errors from regulator_is_supported_voltage(), so it considered errors as
success. Since
commit 498209445124 ("regulator: core: simplify return value on suported_voltage") regulator_is_supported_voltage() returns a real boolean, so
errors make _opp_supported_by_regulators() return false.
That reveals a problem with the declaration of the VDD1/2 regulators on twl4030.
The VDD1/VDD2 regulators on twl4030 are neither defined with voltage lists nor with the continuous flag set, so regulator_is_supported_voltage() returns false and an error before above mentioned commit (which was considered success) The result is that after the above mentioned commit cpufreq does not work properly e.g. dm3730.
[ 2.490997] core: _opp_supported_by_regulators: OPP minuV: 1012500 maxuV: 1012500, not supported by regulator [ 2.501617] cpu cpu0: _opp_add: OPP not supported by regulators (300000000) [ 2.509246] core: _opp_supported_by_regulators: OPP minuV: 1200000 maxuV: 1200000, not supported by regulator [ 2.519775] cpu cpu0: _opp_add: OPP not supported by regulators (600000000) [ 2.527313] core: _opp_supported_by_regulators: OPP minuV: 1325000 maxuV: 1325000, not supported by regulator [ 2.537750] cpu cpu0: _opp_add: OPP not supported by regulators (800000000)
The patch fixes declaration of VDD1/2 regulators by adding proper voltage lists.
--- drivers/regulator/twl-regulator.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/regulator/twl-regulator.c +20 -3
@@ -359,6 +359,17 @@ static const u16 VINTANA2_VSEL_table[] = 2500, 2750, }; +/* 600mV to 1450mV in 12.5 mV steps */ +static const struct regulator_linear_range VDD1_ranges[] = { +REGULATOR_LINEAR_RANGE (600000 ,0 ,68 ,12500 ) +}; + +/* 600mV to 1450mV in 12.5 mV steps, everything above = 1500mV */ +static const struct regulator_linear_range VDD2_ranges[] = { +REGULATOR_LINEAR_RANGE (600000 ,0 ,68 ,12500 ), +REGULATOR_LINEAR_RANGE (1500000 ,69 ,69 ,12500 ) +}; +static int twl4030ldo_list_voltage (struct regulator_dev *rdev,unsigned index) {struct twlreg_info *info =rdev_get_drvdata (rdev);
@@ -427,6 +438,8 @@ static int twl4030smps_get_voltage(struc }static const struct regulator_ops twl4030smps_ops = { + .list_voltage = regulator_list_voltage_linear_range, + .set_voltage = twl4030smps_set_voltage, .get_voltage = twl4030smps_get_voltage, };
@@ -466,7 +479,8 @@ static const struct twlreg_info TWL4030_ }, \ } -#define TWL4030_ADJUSTABLE_SMPS (label, offset, num, turnon_delay, remap_conf) \ +#define TWL4030_ADJUSTABLE_SMPS (label, offset, num, turnon_delay, remap_conf, \ + n_volt) \ static const struct twlreg_info TWL4030_INFO_##label = { \ .base = offset, \ .id = num, \
@@ -479,6 +493,9 @@ static const struct twlreg_info TWL4030_ .owner = THIS_MODULE, \ .enable_time = turnon_delay, \ .of_map_mode = twl4030reg_map_mode, \ + .n_voltages = n_volt, \ + .n_linear_ranges = ARRAY_SIZE(label ## _ranges), \ + .linear_ranges = label ## _ranges, \ }, \ }
@@ -518,8 +535,8 @@ TWL4030_ADJUSTABLE_LDO(VSIM, 0x37, 9, 10TWL4030_ADJUSTABLE_LDO (VDAC ,0x3b ,10 ,100 ,0x08 );TWL4030_ADJUSTABLE_LDO (VINTANA2 ,0x43 ,12 ,100 ,0x08 );TWL4030_ADJUSTABLE_LDO (VIO ,0x4b ,14 ,1000 ,0x08 ); -TWL4030_ADJUSTABLE_SMPS (VDD1 ,0x55 ,15 ,1000 ,0x08 ); -TWL4030_ADJUSTABLE_SMPS (VDD2 ,0x63 ,16 ,1000 ,0x08 ); +TWL4030_ADJUSTABLE_SMPS (VDD1 ,0x55 ,15 ,1000 ,0x08 ,68 ); +TWL4030_ADJUSTABLE_SMPS (VDD2 ,0x63 ,16 ,1000 ,0x08 ,69 );/* VUSBCP is managed *only* by the USB subchip */ TWL4030_FIXED_LDO (VINTANA1 ,0x3f ,1500 ,11 ,100 ,0x08 );TWL4030_FIXED_LDO (VINTDIG ,0x47 ,1500 ,13 ,100 ,0x08 );
Greg Kroah-Hartman
maintainerPATCH 43/85 KVM: s390: kvm_s390_vm_start_migration: check dirty_bitmap before using it as target for memset()
In reply to Greg Kroah-HartmanFrom: Igor Mammedov <[email protected]>
commit 13a17cc0526f08d1df9507f7484176371cd263a0 upstream.
If userspace doesn't set KVM_MEM_LOG_DIRTY_PAGES on memslot before calling kvm_s390_vm_start_migration(), kernel will oops with:
Unable to handle kernel pointer dereference in virtual kernel address space Failing address: 0000000000000000 TEID: 0000000000000483 Fault in home space mode while using kernel ASCE. AS:0000000002a2000b R2:00000001bff8c00b R3:00000001bff88007 S:00000001bff91000 P:000000000000003d Oops: 0004 ilc:2 [#1] SMP ... Call Trace: ([<001fffff804ec552>] kvm_s390_vm_set_attr+0x347a/0x3828 [kvm]) [<001fffff804ecfc0>] kvm_arch_vm_ioctl+0x6c0/0x1998 [kvm] [<001fffff804b67e4>] kvm_vm_ioctl+0x51c/0x11a8 [kvm] [<00000000008ba572>] do_vfs_ioctl+0x1d2/0xe58 [<00000000008bb284>] ksys_ioctl+0x8c/0xb8 [<00000000008bb2e2>] sys_ioctl+0x32/0x40 [<000000000175552c>] system_call+0x2b8/0x2d8 INFO: lockdep is turned off. Last Breaking-Event-Address: [<0000000000dbaf60>] __memset+0xc/0xa0
due to ms->dirty_bitmap being NULL, which might crash the host.
Make sure that ms->dirty_bitmap is set before using it or return -EINVAL otherwise.
--- arch/s390/kvm/kvm-s390.c | 2 ++ 1 file changed, 2 insertions(+)
arch/s390/kvm/kvm-s390.c +2 -0
@@ -1013,6 +1013,8 @@ static int kvm_s390_vm_start_migration(s/* mark all the pages in active slots as dirty */ for (slotnr =0 ; slotnr < slots->used_slots; slotnr++) { ms = slots->memslots + slotnr; +if (!ms->dirty_bitmap) +return -EINVAL ;/* * The second half of the bitmap is only used on x86, * and would be wasted otherwise, so we put it to good
Greg Kroah-Hartman
maintainerPATCH 44/85 KVM: s390: Do not leak kernel stack data in the KVM_S390_INTERRUPT ioctl
In reply to Greg Kroah-HartmanFrom: Thomas Huth <[email protected]>
commit 53936b5bf35e140ae27e4bbf0447a61063f400da upstream.
When the userspace program runs the KVM_S390_INTERRUPT ioctl to inject an interrupt, we convert them from the legacy struct kvm_s390_interrupt to the new struct kvm_s390_irq via the s390int_to_s390irq() function. However, this function does not take care of all types of interrupts that we can inject into the guest later (see do_inject_vcpu()). Since we do not clear out the s390irq values before calling s390int_to_s390irq(), there is a chance that we copy random data from the kernel stack which could be leaked to the userspace later.
Specifically, the problem exists with the KVM_S390_INT_PFAULT_INIT
interrupt: s390int_to_s390irq() does not handle it, and the function __inject_pfault_init() later copies irq->u.ext which contains the random kernel stack data. This data can then be leaked either to the guest memory in __deliver_pfault_init(), or the userspace might retrieve it directly with the KVM_S390_GET_IRQ_STATE ioctl.
Fix it by handling that interrupt type in s390int_to_s390irq(), too, and by making sure that the s390irq struct is properly pre-initialized. And while we're at it, make sure that s390int_to_s390irq() now directly returns -EINVAL for unknown interrupt types, so that we immediately get a proper error code in case we add more interrupt types to do_inject_vcpu() without updating s390int_to_s390irq() sometime in the future.
--- arch/s390/kvm/interrupt.c | 10 ++++++++++ arch/s390/kvm/kvm-s390.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-)
arch/s390/kvm/interrupt.c +10 -0
@@ -1978,6 +1978,16 @@ int s390int_to_s390irq(struct kvm_s390_icase KVM_S390_MCHK : irq->u.mchk.mcic = s390int->parm64;break ; +case KVM_S390_INT_PFAULT_INIT : + irq->u.ext.ext_params = s390int->parm; + irq->u.ext.ext_params2 = s390int->parm64; +break ; +case KVM_S390_RESTART : +case KVM_S390_INT_CLOCK_COMP : +case KVM_S390_INT_CPU_TIMER : +break ; +default : +return -EINVAL ; }return 0 ; }
arch/s390/kvm/kvm-s390.c +1 -1
@@ -4327,7 +4327,7 @@ long kvm_arch_vcpu_async_ioctl(struct fi }case KVM_S390_INTERRUPT : {struct kvm_s390_interrupt s390int; -struct kvm_s390_irq s390irq; +struct kvm_s390_irq s390irq = {};if (copy_from_user (&s390int, argp,sizeof (s390int)))return -EFAULT ;
Greg Kroah-Hartman
maintainerPATCH 45/85 KVM: x86: work around leak of uninitialized stack contents
In reply to Greg Kroah-HartmanFrom: Fuqian Huang <[email protected]>
commit 541ab2aeb28251bf7135c7961f3a6080eebcc705 upstream.
Emulation of VMPTRST can incorrectly inject a page fault when passed an operand that points to an MMIO address. The page fault will use uninitialized kernel stack memory as the CR2 and error code.
The right behavior would be to abort the VM with a KVM_EXIT_INTERNAL_ERROR exit to userspace; however, it is not an easy fix, so for now just ensure that the error code and CR2 are zero.
--- arch/x86/kvm/x86.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/x86/kvm/x86.c +7 -0
@@ -5265,6 +5265,13 @@ int kvm_write_guest_virt_system(struct k/* kvm_write_guest_virt_system can pull in tons of pages. */ vcpu->arch.l1tf_flush_l1d = true; +/* +* FIXME: this should call handle_emulation_failure if X86EMUL_IO_NEEDED +* is returned, but our callers are not ready for that and they blindly +* call kvm_inject_page_fault. Ensure that they at least do not leak +* uninitialized kernel stack memory into cr2 and error code. +*/ +memset (exception,0 ,sizeof (*exception));return kvm_write_guest_virt_helper (addr, val, bytes, vcpu,PFERR_WRITE_MASK , exception); }
Greg Kroah-Hartman
maintainerPATCH 46/85 KVM: x86/mmu: Reintroduce fast invalidate/zap for flushing memslot
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit 002c5f73c508f7df5681bda339831c27f3c1aef4 upstream.
James Harvey reported a livelock that was introduced by commit d012a06ab1d23 ("Revert "KVM: x86/mmu: Zap only the relevant pages when removing a memslot"").
The livelock occurs because kvm_mmu_zap_all() as it exists today will voluntarily reschedule and drop KVM's mmu_lock, which allows other vCPUs to add shadow pages. With enough vCPUs, kvm_mmu_zap_all() can get stuck in an infinite loop as it can never zap all pages before observing lock contention or the need to reschedule. The equivalent of kvm_mmu_zap_all() that was in use at the time of the reverted commit (4e103134b8623, "KVM:
x86/mmu: Zap only the relevant pages when removing a memslot") employed a fast invalidate mechanism and was not susceptible to the above livelock.
There are three ways to fix the livelock:
- Reverting the revert (commit d012a06ab1d23) is not a viable option as the revert is needed to fix a regression that occurs when the guest has one or more assigned devices. It's unlikely we'll root cause the device assignment regression soon enough to fix the regression timely.
- Remove the conditional reschedule from kvm_mmu_zap_all(). However, although removing the reschedule would be a smaller code change, it's less safe in the sense that the resulting kvm_mmu_zap_all() hasn't been used in the wild for flushing memslots since the fast invalidate mechanism was introduced by commit 6ca18b6950f8d ("KVM: x86: use the fast way to invalidate all pages"), back in 2013.
- Reintroduce the fast invalidate mechanism and use it when zapping shadow pages in response to a memslot being deleted/moved, which is what this patch does.
For all intents and purposes, this is a revert of commit ea145aacf4ae8 ("Revert "KVM: MMU: fast invalidate all pages"") and a partial revert of commit 7390de1e99a70 ("Revert "KVM: x86: use the fast way to invalidate all pages""), i.e. restores the behavior of commit 5304b8d37c2a5 ("KVM:
MMU: fast invalidate all pages") and commit 6ca18b6950f8d ("KVM: x86:
use the fast way to invalidate all pages") respectively.
--- arch/x86/include/asm/kvm_host.h | 2 arch/x86/kvm/mmu.c | 101 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 101 insertions(+), 2 deletions(-)
arch/x86/include/asm/kvm_host.h +2 -0
@@ -333,6 +333,7 @@ struct kvm_mmu_page {int root_count;/* Currently serving as active root */ unsigned int unsync_children;struct kvm_rmap_head parent_ptes;/* rmap pointers to parent sptes */ +unsigned long mmu_valid_gen;DECLARE_BITMAP (unsync_child_bitmap,512 );#ifdef CONFIG_X86_32
@@ -851,6 +852,7 @@ struct kvm_arch {unsigned long n_requested_mmu_pages;unsigned long n_max_mmu_pages;unsigned int indirect_shadow_pages; +unsigned long mmu_valid_gen;struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES ];/* * Hash table of struct kvm_mmu_page.
arch/x86/kvm/mmu.c +99 -2
141 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 47/85 KVM: nVMX: handle page fault in vmread
In reply to Greg Kroah-HartmanFrom: Paolo Bonzini <[email protected]>
commit f7eea636c3d505fe6f1d1066234f1aaf7171b681 upstream.
The implementation of vmread to memory is still incomplete, as it lacks the ability to do vmread to I/O memory just like vmptrst.
--- arch/x86/kvm/vmx/nested.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kvm/vmx/nested.c +3 -1
@@ -4411,6 +4411,7 @@ static int handle_vmread(struct kvm_vcpuint len;gva_t gva =0 ;struct vmcs12 *vmcs12; +struct x86_exception e;if (!nested_vmx_check_permission (vcpu))return 1 ;
@@ -4451,7 +4452,8 @@ static int handle_vmread(struct kvm_vcpu vmx_instruction_info, true, len, &gva))return 1 ;/* _system ok, nested_vmx_check_permission has verified cpl=0 */ -kvm_write_guest_virt_system (vcpu, gva, &field_value, len,NULL ); +if (kvm_write_guest_virt_system (vcpu, gva, &field_value, len, &e)) +kvm_inject_page_fault (vcpu, &e); }return nested_vmx_succeed (vcpu);
Greg Kroah-Hartman
maintainerPATCH 48/85 x86/purgatory: Change compiler flags from -mcmodel=kernel to -mcmodel=large to fix kexec relocation errors
In reply to Greg Kroah-HartmanFrom: Steve Wahl <[email protected]>
commit e16c2983fba0fa6763e43ad10916be35e3d8dc05 upstream.
The last change to this Makefile caused relocation errors when loading a kdump kernel. Restore -mcmodel=large (not -mcmodel=kernel), -ffreestanding, and -fno-zero-initialized-bsss, without reverting to the former practice of resetting KBUILD_CFLAGS.
Purgatory.ro is a standalone binary that is not linked against the rest of the kernel. Its image is copied into an array that is linked to the kernel, and from there kexec relocates it wherever it desires.
With the previous change to compiler flags, the error "kexec: Overflow in relocation type 11 value 0x11fffd000" was encountered when trying to load the crash kernel. This is from kexec code trying to relocate the purgatory.ro object.
Quoted 1 line
From the error message, relocation type 11 is
R_X86_64_32S. The
x86_64 ABI says:
"The R_X86_64_32 and R_X86_64_32S relocations truncate the
computed value to 32-bits. The linker must verify that the generated value for the R_X86_64_32 (R_X86_64_32S) relocation zero-extends (sign-extends) to the original 64-bit value."
This type of relocation doesn't work when kexec chooses to place the purgatory binary in memory that is not reachable with 32 bit addresses.
The compiler flag -mcmodel=kernel allows those type of relocations to be emitted, so revert to using -mcmodel=large as was done before.
Also restore the -ffreestanding and -fno-zero-initialized-bss flags because they are appropriate for a stand alone piece of object code which doesn't explicitly zero the bss, and one other report has said undefined symbols are encountered without -ffreestanding.
These identical compiler flag changes need to happen for every object that becomes part of the purgatory.ro object, so gather them together first into PURGATORY_CFLAGS_REMOVE and PURGATORY_CFLAGS, and then apply them to each of the objects that have C source. Do not apply any of these flags to kexec-purgatory.o, which is not part of the standalone object but part of the kernel proper.
--- arch/x86/purgatory/Makefile | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-)
arch/x86/purgatory/Makefile +19 -16
@@ -18,37 +18,40 @@ targets += purgatory.ro KASAN_SANITIZE := n KCOV_INSTRUMENT := n +# These are adjustments to the compiler flags used for objects that +# make up the standalone purgatory.ro + +PURGATORY_CFLAGS_REMOVE := -mcmodel=kernel +PURGATORY_CFLAGS := -mcmodel=large -ffreestanding -fno-zero-initialized-in-bss + # Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That # in turn leaves some undefined symbols like __fentry__ in purgatory and not # sure how to relocate those. ifdef CONFIG_FUNCTION_TRACER -CFLAGS_REMOVE_sha256.o += $(CC_FLAGS_FTRACE) -CFLAGS_REMOVE_purgatory.o += $(CC_FLAGS_FTRACE) -CFLAGS_REMOVE_string.o += $(CC_FLAGS_FTRACE) -CFLAGS_REMOVE_kexec-purgatory.o += $(CC_FLAGS_FTRACE) +PURGATORY_CFLAGS_REMOVE += $(CC_FLAGS_FTRACE) endif ifdef CONFIG_STACKPROTECTOR -CFLAGS_REMOVE_sha256.o += -fstack-protector -CFLAGS_REMOVE_purgatory.o += -fstack-protector -CFLAGS_REMOVE_string.o += -fstack-protector -CFLAGS_REMOVE_kexec-purgatory.o += -fstack-protector +PURGATORY_CFLAGS_REMOVE += -fstack-protector endif ifdef CONFIG_STACKPROTECTOR_STRONG -CFLAGS_REMOVE_sha256.o += -fstack-protector-strong -CFLAGS_REMOVE_purgatory.o += -fstack-protector-strong -CFLAGS_REMOVE_string.o += -fstack-protector-strong -CFLAGS_REMOVE_kexec-purgatory.o += -fstack-protector-strong +PURGATORY_CFLAGS_REMOVE += -fstack-protector-strong endif ifdef CONFIG_RETPOLINE -CFLAGS_REMOVE_sha256.o += $(RETPOLINE_CFLAGS) -CFLAGS_REMOVE_purgatory.o += $(RETPOLINE_CFLAGS) -CFLAGS_REMOVE_string.o += $(RETPOLINE_CFLAGS) -CFLAGS_REMOVE_kexec-purgatory.o += $(RETPOLINE_CFLAGS) +PURGATORY_CFLAGS_REMOVE += $(RETPOLINE_CFLAGS) endif +CFLAGS_REMOVE_purgatory.o += $(PURGATORY_CFLAGS_REMOVE) +CFLAGS_purgatory.o += $(PURGATORY_CFLAGS) + +CFLAGS_REMOVE_sha256.o += $(PURGATORY_CFLAGS_REMOVE) +CFLAGS_sha256.o += $(PURGATORY_CFLAGS) + +CFLAGS_REMOVE_string.o += $(PURGATORY_CFLAGS_REMOVE) +CFLAGS_string.o += $(PURGATORY_CFLAGS) + $(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE $(call if_changed,ld)
Greg Kroah-Hartman
maintainerPATCH 49/85 powerpc: Add barrier_nospec to raw_copy_in_user()
In reply to Greg Kroah-HartmanFrom: Suraj Jitindar Singh <[email protected]>
commit 6fbcdd59094ade30db63f32316e9502425d7b256 upstream.
Commit ddf35cf3764b ("powerpc: Use barrier_nospec in copy_from_user()") Added barrier_nospec before loading from user-controlled pointers. The intention was to order the load from the potentially user-controlled pointer vs a previous branch based on an access_ok() check or similar.
In order to achieve the same result, add a barrier_nospec to the raw_copy_in_user() function before loading from such a user-controlled pointer.
--- arch/powerpc/include/asm/uaccess.h | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/include/asm/uaccess.h +1 -0
@@ -312,6 +312,7 @@ raw_copy_in_user(void __user *to, const {unsigned long ret; +barrier_nospec ();allow_user_access (to, from, n); ret =__copy_tofrom_user (to, from, n);prevent_user_access (to, from, n);
Greg Kroah-Hartman
maintainerPATCH 50/85 kernel/module: Fix mem leak in module_add_modinfo_attrs
In reply to Greg Kroah-HartmanFrom: YueHaibing <[email protected]>
commit bc6f2a757d525e001268c3658bd88822e768f8db upstream.
In module_add_modinfo_attrs if sysfs_create_file
fails, we forget to free allocated modinfo_attrs
and roll back the sysfs files.
--- kernel/module.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
kernel/module.c +17 -5
@@ -1697,6 +1697,8 @@ static int add_usage_links(struct modulereturn ret; } +static void module_remove_modinfo_attrs (struct module *mod,int end); +static int module_add_modinfo_attrs (struct module *mod) {struct module_attribute *attr;
@@ -1711,24 +1713,34 @@ static int module_add_modinfo_attrs(strureturn -ENOMEM ; temp_attr = mod->modinfo_attrs; -for (i =0 ; (attr = modinfo_attrs[i]) && !error; i++) { +for (i =0 ; (attr = modinfo_attrs[i]); i++) {if (!attr->test || attr->test (mod)) {memcpy (temp_attr, attr,sizeof (*temp_attr));sysfs_attr_init (&temp_attr->attr); error =sysfs_create_file (&mod->mkobj.kobj, &temp_attr->attr); +if (error) + goto error_out; ++temp_attr; } } + +return 0 ; + +error_out: +if (i >0 ) +module_remove_modinfo_attrs (mod, --i);return error; } -static void module_remove_modinfo_attrs (struct module *mod) +static void module_remove_modinfo_attrs (struct module *mod,int end) {struct module_attribute *attr;int i;for (i =0 ; (attr = &mod->modinfo_attrs[i]); i++) { +if (end >=0 && i > end) +break ;/* pick a field to test for end of list */ if (!attr->attr.name)break ;
@@ -1816,7 +1828,7 @@ static int mod_sysfs_setup(struct modulereturn 0 ; out_unreg_modinfo_attrs: -module_remove_modinfo_attrs (mod); +module_remove_modinfo_attrs (mod,-1 ); out_unreg_param:module_param_sysfs_remove (mod); out_unreg_holders:
@@ -1852,7 +1864,7 @@ static void mod_sysfs_fini(struct module { } -static void module_remove_modinfo_attrs (struct module *mod) +static void module_remove_modinfo_attrs (struct module *mod,int end) { }
@@ -1868,7 +1880,7 @@ static void init_param_lock(struct modulstatic void mod_sysfs_teardown (struct module *mod) {del_usage_links (mod); -module_remove_modinfo_attrs (mod); +module_remove_modinfo_attrs (mod,-1 );module_param_sysfs_remove (mod);kobject_put (mod->mkobj.drivers_dir);kobject_put (mod->holders_dir);
Greg Kroah-Hartman
maintainerPATCH 51/85 x86/boot: Use efi_setup_data for searching RSDP on kexec-ed kernels
In reply to Greg Kroah-HartmanFrom: Junichi Nomura <[email protected]>
commit 0a23ebc66a46786769dd68bfdaa3102345819b9c upstream.
Commit
3a63f70bf4c3a ("x86/boot: Early parse RSDP and save it in boot_params")
broke kexec boot on EFI systems. efi_get_rsdp_addr() in the early parsing code tries to search RSDP from the EFI tables but that will crash because the table address is virtual when the kernel was booted by kexec (set_virtual_address_map() has run in the first kernel and cannot be run again in the second kernel).
In the case of kexec, the physical address of EFI tables is provided via efi_setup_data in boot_params, which is set up by kexec(1).
Factor out the table parsing code and use different pointers depending on whether the kernel is booted by kexec or not.
[ bp: Massage. ]
--- arch/x86/boot/compressed/acpi.c | 143 +++++++++++++++++++++++++++++----------- 1 file changed, 107 insertions(+), 36 deletions(-)
arch/x86/boot/compressed/acpi.c +107 -36
@@ -44,17 +44,109 @@ static acpi_physical_address get_acpi_rsreturn addr; } -/* Search EFI system tables for RSDP. */ -static acpi_physical_address efi_get_rsdp_addr (void ) +/* +* Search EFI system tables for RSDP. If both ACPI_20_TABLE_GUID and +* ACPI_TABLE_GUID are found, take the former, which has more features. +*/ +static acpi_physical_address +__efi_get_rsdp_addr (unsigned long config_tables,unsigned int nr_tables, +bool efi_64) {acpi_physical_address rsdp_addr =0 ;#ifdef CONFIG_EFI -unsigned long systab, systab_tables, config_tables; +int i; + +/* Get EFI tables from systab. */ +for (i =0 ; i < nr_tables; i++) { +acpi_physical_address table; +efi_guid_t guid; + +if (efi_64) { +efi_config_table_64_t *tbl = (efi_config_table_64_t *)config_tables + i; + + guid = tbl->guid; + table = tbl->table; + +if (!IS_ENABLED (CONFIG_X86_64 ) && table >>32 ) { +debug_putstr ("Error getting RSDP address: EFI config table located above 4GB.\n" ); +return 0 ; + } + }else { +efi_config_table_32_t *tbl = (efi_config_table_32_t *)config_tables + i; + + guid = tbl->guid; + table = tbl->table; + } + +if (!(efi_guidcmp (guid,ACPI_TABLE_GUID ))) + rsdp_addr = table; +else if (!(efi_guidcmp (guid,ACPI_20_TABLE_GUID ))) +return table; + } +#endif +return rsdp_addr; +} + +/* EFI/kexec support is 64-bit only. */ +#ifdef CONFIG_X86_64 +static struct efi_setup_data *get_kexec_setup_data_addr (void ) +{ +struct setup_data *data; +u64 pa_data; + + pa_data = boot_params->hdr.setup_data; +while (pa_data) { + data = (struct setup_data *)pa_data; +if (data->type ==SETUP_EFI ) +return (struct efi_setup_data *)(pa_data +sizeof (struct setup_data )); + + pa_data = data->next; + } +return NULL ; +} + +static acpi_physical_address kexec_get_rsdp_addr (void ) +{ +efi_system_table_64_t *systab; +struct efi_setup_data *esd; +struct efi_info *ei; +char *sig; + + esd = (struct efi_setup_data *)get_kexec_setup_data_addr (); +if (!esd) +return 0 ; + +if (!esd->tables) { +debug_putstr ("Wrong kexec SETUP_EFI data.\n" ); +return 0 ; + } + + ei = &boot_params->efi_info; + sig = (char *)&ei->efi_loader_signature; +if (strncmp (sig,EFI64_LOADER_SIGNATURE ,4 )) { +debug_putstr ("Wrong kexec EFI loader signature.\n" ); +return 0 ; + } + +/* Get systab from boot params. */ + systab = (efi_system_table_64_t *) (ei->efi_systab | ((__u64 )ei->efi_systab_hi <<32 )); +if (!systab) +error ("EFI system table not found in kexec boot_params." ); + +return __efi_get_rsdp_addr ((unsigned long )esd->tables, systab->nr_tables, true); +} +#else +static acpi_physical_address kexec_get_rsdp_addr (void ) {return 0 ; } +#endif /* CONFIG_X86_64 */ + +static acpi_physical_address efi_get_rsdp_addr (void ) +{ +#ifdef CONFIG_EFI +unsigned long systab, config_tables;unsigned int nr_tables;struct efi_info *ei;bool efi_64; -int size, i;char *sig; ei = &boot_params->efi_info;
@@ -88,49 +180,20 @@ static acpi_physical_address efi_get_rsd config_tables = stbl->tables; nr_tables = stbl->nr_tables; - size = sizeof(efi_config_table_64_t); }else {efi_system_table_32_t *stbl = (efi_system_table_32_t *)systab; config_tables = stbl->tables; nr_tables = stbl->nr_tables; - size =sizeof (efi_config_table_32_t); }if (!config_tables)error ("EFI config tables not found." ); -/* Get EFI tables from systab. */ -for (i =0 ; i < nr_tables; i++) { -acpi_physical_address table; -efi_guid_t guid; - - config_tables += size; - -if (efi_64) { -efi_config_table_64_t *tbl = (efi_config_table_64_t *)config_tables; - - guid = tbl->guid; - table = tbl->table; - -if (!IS_ENABLED (CONFIG_X86_64 ) && table >>32 ) { -debug_putstr ("Error getting RSDP address: EFI config table located above 4GB.\n" ); -return 0 ; - } - }else { -efi_config_table_32_t *tbl = (efi_config_table_32_t *)config_tables; - - guid = tbl->guid; - table = tbl->table; - } - -if (!(efi_guidcmp (guid,ACPI_TABLE_GUID ))) - rsdp_addr = table; -else if (!(efi_guidcmp (guid,ACPI_20_TABLE_GUID ))) -return table; - } +return __efi_get_rsdp_addr (config_tables, nr_tables, efi_64); +#else +return 0 ;#endif -return rsdp_addr; }static u8 compute_checksum (u8 *buffer,u32 length)
@@ -220,6 +283,14 @@ acpi_physical_address get_rsdp_addr(voidif (!pa) pa = boot_params->acpi_rsdp_addr; +/* +* Try to get EFI data from setup_data. This can happen when we're a +* kexec'ed kernel and kexec(1) has passed all the required EFI info to +* us. +*/ +if (!pa) + pa =kexec_get_rsdp_addr (); +if (!pa) pa =efi_get_rsdp_addr ();
Greg Kroah-Hartman
maintainerPATCH 52/85 x86/ima: check EFI SetupMode too
In reply to Greg Kroah-HartmanFrom: Mimi Zohar <[email protected]>
commit 980ef4d22a95a3cd84a9b8ffaa7b81b391d173c6 upstream.
Checking "SecureBoot" mode is not sufficient, also check "SetupMode".
--- arch/x86/kernel/ima_arch.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
arch/x86/kernel/ima_arch.c +10 -2
@@ -11,10 +11,11 @@ extern struct boot_params boot_params;static enum efi_secureboot_mode get_sb_mode (void ) {efi_char16_t efi_SecureBoot_name[] =L"SecureBoot" ; +efi_char16_t efi_SetupMode_name[] =L"SecureBoot" ;efi_guid_t efi_variable_guid =EFI_GLOBAL_VARIABLE_GUID ;efi_status_t status;unsigned long size; -u8 secboot; +u8 secboot, setupmode; size =sizeof (secboot);
@@ -36,7 +37,14 @@ static enum efi_secureboot_mode get_sb_mreturn efi_secureboot_mode_unknown; } -if (secboot ==0 ) { + size =sizeof (setupmode); + status = efi.get_variable (efi_SetupMode_name, &efi_variable_guid, +NULL , &size, &setupmode); + +if (status !=EFI_SUCCESS )/* ignore unknown SetupMode */ + setupmode =0 ; + +if (secboot ==0 || setupmode ==1 ) {pr_info ("ima: secureboot mode disabled\n" );return efi_secureboot_mode_disabled; }
Greg Kroah-Hartman
maintainerPATCH 53/85 drm/meson: Add support for XBGR8888 & ABGR8888 formats
In reply to Greg Kroah-HartmanFrom: Neil Armstrong <[email protected]>
commit 5ffff4415f9eeae834960226770963e2947e17eb upstream.
Add missing XBGR8888 & ABGR8888 formats variants from the primary plane.
--- drivers/gpu/drm/meson/meson_plane.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/gpu/drm/meson/meson_plane.c +16 -0
@@ -153,6 +153,13 @@ static void meson_plane_atomic_update(st priv->viu.osd1_blk0_cfg[0 ] |=OSD_BLK_MODE_32 |OSD_COLOR_MATRIX_32_ARGB ;break ; +case DRM_FORMAT_XBGR8888 : +/* For XRGB, replace the pixel's alpha by 0xFF */ +writel_bits_relaxed (OSD_REPLACE_EN ,OSD_REPLACE_EN , + priv->io_base +_REG (VIU_OSD1_CTRL_STAT2 )); + priv->viu.osd1_blk0_cfg[0 ] |=OSD_BLK_MODE_32 | +OSD_COLOR_MATRIX_32_ABGR ; +break ;case DRM_FORMAT_ARGB8888 :/* For ARGB, use the pixel's alpha */ writel_bits_relaxed(OSD_REPLACE_EN, 0,
@@ -160,6 +167,13 @@ static void meson_plane_atomic_update(st priv->viu.osd1_blk0_cfg[0 ] |=OSD_BLK_MODE_32 |OSD_COLOR_MATRIX_32_ARGB ;break ; +case DRM_FORMAT_ABGR8888 : +/* For ARGB, use the pixel's alpha */ +writel_bits_relaxed (OSD_REPLACE_EN ,0 , + priv->io_base +_REG (VIU_OSD1_CTRL_STAT2 )); + priv->viu.osd1_blk0_cfg[0 ] |=OSD_BLK_MODE_32 | +OSD_COLOR_MATRIX_32_ABGR ; +break ;case DRM_FORMAT_RGB888 : priv->viu.osd1_blk0_cfg[0 ] |=OSD_BLK_MODE_24 |OSD_COLOR_MATRIX_24_RGB ;
@@ -346,7 +360,9 @@ static const struct drm_plane_funcs mesostatic const uint32_t supported_drm_formats[] = {DRM_FORMAT_ARGB8888 , +DRM_FORMAT_ABGR8888 ,DRM_FORMAT_XRGB8888 , +DRM_FORMAT_XBGR8888 ,DRM_FORMAT_RGB888 ,DRM_FORMAT_RGB565 , };
Greg Kroah-Hartman
maintainerPATCH 54/85 clk: Fix debugfs clk_possible_parents for clks without parent string names
In reply to Greg Kroah-HartmanFrom: Chen-Yu Tsai <[email protected]>
commit 2d156b78ce8febf15cd58a025d7d9d7b7577126a upstream.
Following the commit fc0c209c147f ("clk: Allow parents to be specified without string names"), the parent name string is not always populated.
Instead, fetch the parents clk_core struct using the appropriate helper, and read its name directly. If that fails, go through the possible sources of parent names. The order in which they are used is different from how parents are looked up, with the global name having precedence over local fw_name and indices. This makes more sense as a) the parent_maps structure does not differentiate between legacy global names and fallback global names, and b) global names likely provide more information than local fw_names.
--- drivers/clk/clk.c | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-)
drivers/clk/clk.c +41 -3
@@ -3023,12 +3023,50 @@ DEFINE_SHOW_ATTRIBUTE(clk_flags);static int possible_parents_show (struct seq_file *s,void *data) {struct clk_core *core = s->private; +struct clk_core *parent;int i; -for (i =0 ; i < core->num_parents -1 ; i++) -seq_printf (s,"%s " , core->parents[i].name); +/* +* Go through the following options to fetch a parent's name. +* +* 1. Fetch the registered parent clock and use its name +* 2. Use the global (fallback) name if specified +* 3. Use the local fw_name if provided +* 4. Fetch parent clock's clock-output-name if DT index was set +* +* This may still fail in some cases, such as when the parent is +* specified directly via a struct clk_hw pointer, but it isn't +* registered (yet). +*/ +for (i =0 ; i < core->num_parents -1 ; i++) { + parent =clk_core_get_parent_by_index (core, i); +if (parent) +seq_printf (s,"%s " , parent->name); +else if (core->parents[i].name) +seq_printf (s,"%s " , core->parents[i].name); +else if (core->parents[i].fw_name) +seq_printf (s,"<%s>(fw) " , core->parents[i].fw_name); +else if (core->parents[i].index >=0 ) +seq_printf (s,"%s " , +of_clk_get_parent_name (core->of_node, + core->parents[i].index)); +else +seq_puts (s,"(missing) " ); + } -seq_printf (s,"%s\n" , core->parents[i].name); + parent =clk_core_get_parent_by_index (core, i); +if (parent) +seq_printf (s,"%s" , parent->name); +else if (core->parents[i].name) +seq_printf (s,"%s" , core->parents[i].name); +else if (core->parents[i].fw_name) +seq_printf (s,"<%s>(fw)" , core->parents[i].fw_name); +else if (core->parents[i].index >=0 ) +seq_printf (s,"%s" , +of_clk_get_parent_name (core->of_node, + core->parents[i].index)); +else +seq_puts (s,"(missing)" );return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 55/85 clk: Simplify debugfs printing and add a newline
In reply to Greg Kroah-HartmanFrom: Stephen Boyd <[email protected]>
commit 11f6c2307caee89370d7752eb6f404f1ed73faaf upstream.
The possible parent printing function duplicates a bunch of if conditions. Pull that into another function so we can print an extra character at the end, either a space or a newline. This way we can add the required newline that got lost here and also shorten the code.
--- drivers/clk/clk.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-)
drivers/clk/clk.c +15 -19
@@ -3020,11 +3020,10 @@ static int clk_flags_show(struct seq_fil }DEFINE_SHOW_ATTRIBUTE (clk_flags); -static int possible_parents_show (struct seq_file *s,void *data) +static void possible_parent_show (struct seq_file *s,struct clk_core *core, +unsigned int i,char terminator) { -struct clk_core *core = s->private;struct clk_core *parent; -int i;/* * Go through the following options to fetch a parent's name.
@@ -3038,22 +3037,6 @@ static int possible_parents_show(struct* specified directly via a struct clk_hw pointer, but it isn't * registered (yet). */ -for (i =0 ; i < core->num_parents -1 ; i++) { - parent =clk_core_get_parent_by_index (core, i); -if (parent) -seq_printf (s,"%s " , parent->name); -else if (core->parents[i].name) -seq_printf (s,"%s " , core->parents[i].name); -else if (core->parents[i].fw_name) -seq_printf (s,"<%s>(fw) " , core->parents[i].fw_name); -else if (core->parents[i].index >=0 ) -seq_printf (s,"%s " , -of_clk_get_parent_name (core->of_node, - core->parents[i].index)); -else -seq_puts (s,"(missing) " ); - } - parent =clk_core_get_parent_by_index (core, i);if (parent)seq_printf (s,"%s" , parent->name);
@@ -3068,6 +3051,19 @@ static int possible_parents_show(structelse seq_puts (s,"(missing)" ); +seq_putc (s, terminator); +} + +static int possible_parents_show (struct seq_file *s,void *data) +{ +struct clk_core *core = s->private; +int i; + +for (i =0 ; i < core->num_parents -1 ; i++) +possible_parent_show (s, core, i,' ' ); + +possible_parent_show (s, core, i,'\n' ); +return 0 ; }DEFINE_SHOW_ATTRIBUTE (possible_parents);
Greg Kroah-Hartman
maintainerPATCH 56/85 mt76: Fix a signedness bug in mt7615_add_interface()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
commit b1571a0e77d8cef14227af293c6dda1464a57270 upstream.
The problem is that "mvif->omac_idx" is a u8 so it can't be negative and the error handling won't work. The get_omac_idx() function returns -1 on error.
--- drivers/net/wireless/mediatek/mt76/mt7615/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/main.c +3 -2
@@ -77,11 +77,12 @@ static int mt7615_add_interface(struct i goto out; } - mvif->omac_idx =get_omac_idx (vif->type, dev->omac_mask); -if (mvif->omac_idx <0 ) { + idx =get_omac_idx (vif->type, dev->omac_mask); +if (idx <0 ) { ret = -ENOSPC ; goto out; } + mvif->omac_idx = idx;/* TODO: DBDC support. Use band 0 and wmm 0 for now */ mvif->band_idx =0 ;
Greg Kroah-Hartman
maintainerPATCH 57/85 mt76: mt7615: Use after free in mt7615_mcu_set_bcn()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
commit 9db1aec0c2d72a3b7b115ba56e8dbb5b46855333 upstream.
We dereference "skb" when we assign:
req.pkt_len = cpu_to_le16(MT_TXD_SIZE + skb->len);
^^^^^^^^So this patch just moves the dev_kfree_skb() down a bit to avoid the use after free.
--- drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +1 -1
@@ -1270,7 +1270,6 @@ int mt7615_mcu_set_bcn(struct mt7615_devmt7615_mac_write_txwi (dev, (__le32 *)(req.pkt), skb, wcid,NULL ,0 ,NULL );memcpy (req.pkt +MT_TXD_SIZE , skb->data, skb->len); -dev_kfree_skb (skb); req.omac_idx = mvif->omac_idx; req.enable = en;
@@ -1281,6 +1280,7 @@ int mt7615_mcu_set_bcn(struct mt7615_dev req.pkt_len =cpu_to_le16 (MT_TXD_SIZE + skb->len); req.tim_ie_pos =cpu_to_le16 (MT_TXD_SIZE + tim_off); +dev_kfree_skb (skb); skb =mt7615_mcu_msg_alloc (&req,sizeof (req)); return mt7615_mcu_msg_send(dev, skb, MCU_EXT_CMD_BCN_OFFLOAD,
Greg Kroah-Hartman
maintainerPATCH 58/85 clk: rockchip: Dont yell about bad mmc phases when getting
In reply to Greg Kroah-HartmanFrom: Douglas Anderson <[email protected]>
commit 6943b839721ad4a31ad2bacf6e71b21f2dfe3134 upstream.
At boot time, my rk3288-veyron devices yell with 8 lines that look like this:
[ 0.000000] rockchip_mmc_get_phase: invalid clk rate
This is because the clock framework at clk_register() time tries to get the phase but we don't have a parent yet.
While the errors appear to be harmless they are still ugly and, in general, we don't want yells like this in the log unless they are important.
There's no real reason to be yelling here. We can still return -EINVAL to indicate that the phase makes no sense without a parent. If someone really tries to do tuning and the clock is reported as 0 then we'll see the yells in rockchip_mmc_set_phase().
--- drivers/clk/rockchip/clk-mmc-phase.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/clk/rockchip/clk-mmc-phase.c +1 -3
@@ -52,10 +52,8 @@ static int rockchip_mmc_get_phase(structu32 delay_num =0 ;/* See the comment for rockchip_mmc_set_phase below */ -if (!rate) { -pr_err ("%s: invalid clk rate\n" , __func__); +if (!rate)return -EINVAL ; - } raw_value =readl (mmc_clock->reg) >> (mmc_clock->shift);
Greg Kroah-Hartman
maintainerPATCH 59/85 mtd: rawnand: mtk: Fix wrongly assigned OOB buffer pointer issue
In reply to Greg Kroah-HartmanFrom: Xiaolei Li <[email protected]>
commit 336d4b138be2dad372b67a2388e42805c48aaa38 upstream.
One main goal of the function mtk_nfc_update_ecc_stats is to check whether sectors are all empty. If they are empty, set these sectors's data buffer and OOB buffer as 0xff.
But now, the sector OOB buffer pointer is wrongly assigned. We always do memset from sector 0.
To fix this issue, pass start sector number to make OOB buffer pointer be properly assigned.
--- drivers/mtd/nand/raw/mtk_nand.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/mtd/nand/raw/mtk_nand.c +10 -11
@@ -853,19 +853,21 @@ static int mtk_nfc_write_oob_std(structreturn mtk_nfc_write_page_raw (chip,NULL ,1 , page); } -static int mtk_nfc_update_ecc_stats (struct mtd_info *mtd,u8 *buf,u32 sectors) +static int mtk_nfc_update_ecc_stats (struct mtd_info *mtd,u8 *buf,u32 start, +u32 sectors) {struct nand_chip *chip =mtd_to_nand (mtd);struct mtk_nfc *nfc =nand_get_controller_data (chip);struct mtk_nfc_nand_chip *mtk_nand =to_mtk_nand (chip);struct mtk_ecc_stats stats; +u32 reg_size = mtk_nand->fdm.reg_size;int rc, i; rc =nfi_readl (nfc,NFI_STA ) &STA_EMP_PAGE ;if (rc) {memset (buf,0xff , sectors * chip->ecc.size);for (i =0 ; i < sectors; i++) -memset (oob_ptr (chip, i),0xff , mtk_nand->fdm.reg_size); +memset (oob_ptr (chip, start + i),0xff , reg_size);return 0 ; }
@@ -885,7 +887,7 @@ static int mtk_nfc_read_subpage(struct mu32 spare = mtk_nand->spare_per_sector;u32 column, sectors, start, end, reg;dma_addr_t addr; -int bitflips; +int bitflips =0 ;size_t len;u8 *buf;int rc;
@@ -952,14 +954,11 @@ static int mtk_nfc_read_subpage(struct mif (rc <0 ) {dev_err (nfc->dev,"subpage done timeout\n" ); bitflips = -EIO ; - }else { - bitflips =0 ; -if (!raw) { - rc =mtk_ecc_wait_done (nfc->ecc,ECC_DECODE ); - bitflips = rc <0 ? -ETIMEDOUT : -mtk_nfc_update_ecc_stats (mtd, buf, sectors); -mtk_nfc_read_fdm (chip, start, sectors); - } + }else if (!raw) { + rc =mtk_ecc_wait_done (nfc->ecc,ECC_DECODE ); + bitflips = rc <0 ? -ETIMEDOUT : +mtk_nfc_update_ecc_stats (mtd, buf, start, sectors); +mtk_nfc_read_fdm (chip, start, sectors); }dma_unmap_single (nfc->dev, addr, len,DMA_FROM_DEVICE );
Greg Kroah-Hartman
maintainerPATCH 60/85 PCI: Always allow probing with driver_override
In reply to Greg Kroah-HartmanFrom: Alex Williamson <[email protected]>
commit 2d2f4273cbe9058d1f5a518e5e880d27d7b3b30f upstream.
Commit 0e7df22401a3 ("PCI: Add sysfs sriov_drivers_autoprobe to control VF driver binding") introduced the sriov_drivers_autoprobe attribute which allows users to prevent the kernel from automatically probing a driver for new VFs as they are created. This allows VFs to be spawned without automatically binding the new device to a host driver, such as in cases where the user intends to use the device only with a meta driver like vfio-pci. However, the current implementation prevents any use of drivers_probe with the VF while sriov_drivers_autoprobe=0. This blocks the now current general practice of setting driver_override followed by using drivers_probe to bind a device to a specified driver.
The kernel never automatically sets a driver_override therefore it seems we can assume a driver_override reflects the intent of the user. Also, probing a device using a driver_override match seems outside the scope of the 'auto' part of sriov_drivers_autoprobe. Therefore, let's allow driver_override matches regardless of sriov_drivers_autoprobe, which we can do by simply testing if a driver_override is set for a device as a 'can probe' condition.
--- drivers/pci/pci-driver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/pci-driver.c +2 -1
@@ -399,7 +399,8 @@ void __weak pcibios_free_irq(struct pci_#ifdef CONFIG_PCI_IOV static inline bool pci_device_can_probe (struct pci_dev *pdev) { -return (!pdev->is_virtfn || pdev->physfn->sriov->drivers_autoprobe); +return (!pdev->is_virtfn || pdev->physfn->sriov->drivers_autoprobe || + pdev->driver_override); }#else static inline bool pci_device_can_probe (struct pci_dev *pdev)
Greg Kroah-Hartman
maintainerPATCH 61/85 ubifs: Correctly use tnc_next() in search_dh_cookie()
In reply to Greg Kroah-HartmanFrom: Richard Weinberger <[email protected]>
commit bacfa94b08027b9f66ede7044972e3b066766b3e upstream.
Commit c877154d307f fixed an uninitialized variable and optimized the function to not call tnc_next() in the first iteration of the loop. While this seemed perfectly legit and wise, it turned out to be illegal.
If the lookup function does not find an exact match it will rewind the cursor by 1.
The rewinded cursor will not match the name hash we are looking for and this results in a spurious -ENOENT.
So we need to move to the next entry in case of an non-exact match, but not if the match was exact.
While we are here, update the documentation to avoid further confusion.
--- fs/ubifs/tnc.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
fs/ubifs/tnc.c +11 -5
@@ -1158,8 +1158,8 @@ static struct ubifs_znode *dirty_cow_bot* o exact match, i.e. the found zero-level znode contains key @key, then %1 * is returned and slot number of the matched branch is stored in @n; * o not exact match, which means that zero-level znode does not contain -* @key, then %0 is returned and slot number of the closest branch is stored -* in @n; +* @key, then %0 is returned and slot number of the closest branch or %-1 +* is stored in @n; In this case calling tnc_next() is mandatory. * o @key is so small that it is even less than the lowest key of the * leftmost zero-level node, then %0 is returned and %0 is stored in @n. *
@@ -1882,13 +1882,19 @@ int ubifs_tnc_lookup_nm(struct ubifs_infstatic int search_dh_cookie (struct ubifs_info *c,const union ubifs_key *key,struct ubifs_dent_node *dent,uint32_t cookie, -struct ubifs_znode **zn,int *n) +struct ubifs_znode **zn,int *n,int exact) {int err;struct ubifs_znode *znode = *zn;struct ubifs_zbranch *zbr;union ubifs_key *dkey; +if (!exact) { + err =tnc_next (c, &znode, n); +if (err) +return err; + } +for (;;) { zbr = &znode->zbranch[*n]; dkey = &zbr->key;
@@ -1930,7 +1936,7 @@ static int do_lookup_dh(struct ubifs_infif (unlikely (err <0 )) goto out_unlock; - err =search_dh_cookie (c, key, dent, cookie, &znode, &n); + err =search_dh_cookie (c, key, dent, cookie, &znode, &n, err); out_unlock:mutex_unlock (&c->tnc_mutex);
@@ -2723,7 +2729,7 @@ int ubifs_tnc_remove_dh(struct ubifs_infif (unlikely (err <0 )) goto out_free; - err =search_dh_cookie (c, key, dent, cookie, &znode, &n); + err =search_dh_cookie (c, key, dent, cookie, &znode, &n, err);if (err) goto out_free; }
Greg Kroah-Hartman
maintainerPATCH 62/85 driver core: Fix use-after-free and double free on glue directory
In reply to Greg Kroah-HartmanFrom: Muchun Song <[email protected]>
commit ac43432cb1f5c2950408534987e57c2071e24d8f upstream.
There is a race condition between removing glue directory and adding a new device under the glue dir. It can be reproduced in following test:
CPU1: CPU2:
device_add()
get_device_parent()
class_dir_create_and_add()
kobject_add_internal()
create_dir() // create glue_dir
device_add()
get_device_parent()
kobject_get() // get glue_dir
device_del()
cleanup_glue_dir()
kobject_del(glue_dir)
kobject_add()
kobject_add_internal()
create_dir() // in glue_dir
sysfs_create_dir_ns()
kernfs_create_dir_ns(sd)
sysfs_remove_dir() // glue_dir->sd=NULL
sysfs_put() // free glue_dir->sd
// sd is freed
kernfs_new_node(sd)
kernfs_get(glue_dir)
kernfs_add_one()
kernfs_put()Before CPU1 remove last child device under glue dir, if CPU2 add a new device under glue dir, the glue_dir kobject reference count will be increase to 2 via kobject_get() in get_device_parent(). And CPU2 has been called kernfs_create_dir_ns(), but not call kernfs_new_node(). Meanwhile, CPU1 call sysfs_remove_dir() and sysfs_put(). This result in glue_dir->sd is freed and it's reference count will be 0. Then CPU2 call kernfs_get(glue_dir) will trigger a warning in kernfs_get() and increase it's reference count to 1. Because glue_dir->sd is freed by CPU1, the next call kernfs_add_one() by CPU2 will fail(This is also use-after-free) and call kernfs_put() to decrease reference count. Because the reference count is decremented to 0, it will also call kmem_cache_free() to free the glue_dir->sd again. This will result in double free.
In order to avoid this happening, we also should make sure that kernfs_node for glue_dir is released in CPU1 only when refcount for glue_dir kobj is 1 to fix this race.
The following calltrace is captured in kernel 4.14 with the following patch applied:
commit 726e41097920 ("drivers: core: Remove glue dirs from sysfs earlier")
--------------------------------------------------------------------------
[ 3.633703] WARNING: CPU: 4 PID: 513 at .../fs/kernfs/dir.c:494
Here is WARN_ON(!atomic_read(&kn->count) in kernfs_get().
....
[ 3.633986] Call trace:
[ 3.633991] kernfs_create_dir_ns+0xa8/0xb0
[ 3.633994] sysfs_create_dir_ns+0x54/0xe8
[ 3.634001] kobject_add_internal+0x22c/0x3f0
[ 3.634005] kobject_add+0xe4/0x118
[ 3.634011] device_add+0x200/0x870
[ 3.634017] _request_firmware+0x958/0xc38
[ 3.634020] request_firmware_into_buf+0x4c/0x70
....
[ 3.634064] kernel BUG at .../mm/slub.c:294!
Here is BUG_ON(object == fp) in set_freepointer().
....
[ 3.634346] Call trace:
[ 3.634351] kmem_cache_free+0x504/0x6b8
[ 3.634355] kernfs_put+0x14c/0x1d8
[ 3.634359] kernfs_create_dir_ns+0x88/0xb0
[ 3.634362] sysfs_create_dir_ns+0x54/0xe8
[ 3.634366] kobject_add_internal+0x22c/0x3f0
[ 3.634370] kobject_add+0xe4/0x118
[ 3.634374] device_add+0x200/0x870
[ 3.634378] _request_firmware+0x958/0xc38
[ 3.634381] request_firmware_into_buf+0x4c/0x70--------------------------------------------------------------------------
--- drivers/base/core.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-)
drivers/base/core.c +52 -1
@@ -1820,12 +1820,63 @@ static inline struct kobject *get_glue_d*/ static void cleanup_glue_dir (struct device *dev,struct kobject *glue_dir) { +unsigned int ref; +/* see if we live in a "glue" directory */ if (!live_in_glue_dir (glue_dir, dev))return ;mutex_lock (&gdp_mutex); -if (!kobject_has_children (glue_dir)) +/** +* There is a race condition between removing glue directory +* and adding a new device under the glue directory. +* +* CPU1: CPU2: +* +* device_add() +* get_device_parent() +* class_dir_create_and_add() +* kobject_add_internal() +* create_dir() // create glue_dir +* +* device_add() +* get_device_parent() +* kobject_get() // get glue_dir +* +* device_del() +* cleanup_glue_dir() +* kobject_del(glue_dir) +* +* kobject_add() +* kobject_add_internal() +* create_dir() // in glue_dir +* sysfs_create_dir_ns() +* kernfs_create_dir_ns(sd) +* +* sysfs_remove_dir() // glue_dir->sd=NULL +* sysfs_put() // free glue_dir->sd +* +* // sd is freed +* kernfs_new_node(sd) +* kernfs_get(glue_dir) +* kernfs_add_one() +* kernfs_put() +* +* Before CPU1 remove last child device under glue dir, if CPU2 add +* a new device under glue dir, the glue_dir kobject reference count +* will be increase to 2 in kobject_get(k). And CPU2 has been called +* kernfs_create_dir_ns(). Meanwhile, CPU1 call sysfs_remove_dir() +* and sysfs_put(). This result in glue_dir->sd is freed. +* +* Then the CPU2 will see a stale "empty" but still potentially used +* glue dir around in kernfs_new_node(). +* +* In order to avoid this happening, we also should make sure that +* kernfs_node for glue_dir is released in CPU1 only when refcount +* for glue_dir kobj is 1. +*/ + ref =kref_read (&glue_dir->kref); +if (!kobject_has_children (glue_dir) && !--ref)kobject_del (glue_dir);kobject_put (glue_dir);mutex_unlock (&gdp_mutex);
Greg Kroah-Hartman
maintainerPATCH 63/85 crypto: talitos - check AES key size
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit 1ba34e71e9e56ac29a52e0d42b6290f3dc5bfd90 upstream.
Although the HW accepts any size and silently truncates it to the correct length, the extra tests expects EINVAL to be returned when the key size is not valid.
--- drivers/crypto/talitos.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/crypto/talitos.c +15 -0
@@ -1591,6 +1591,18 @@ static int ablkcipher_des3_setkey(structreturn ablkcipher_setkey (cipher, key, keylen); } +static int ablkcipher_aes_setkey (struct crypto_ablkcipher *cipher, +const u8 *key,unsigned int keylen) +{ +if (keylen ==AES_KEYSIZE_128 || keylen ==AES_KEYSIZE_192 || + keylen ==AES_KEYSIZE_256 ) +return ablkcipher_setkey (cipher, key, keylen); + +crypto_ablkcipher_set_flags (cipher,CRYPTO_TFM_RES_BAD_KEY_LEN ); + +return -EINVAL ; +} +static void common_nonsnoop_unmap (struct device *dev,struct talitos_edesc *edesc,struct ablkcipher_request *areq)
@@ -2752,6 +2764,7 @@ static struct talitos_alg_template drive .min_keysize = AES_MIN_KEY_SIZE, .max_keysize = AES_MAX_KEY_SIZE, .ivsize = AES_BLOCK_SIZE, + .setkey = ablkcipher_aes_setkey, } }, .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
@@ -2768,6 +2781,7 @@ static struct talitos_alg_template drive .min_keysize = AES_MIN_KEY_SIZE, .max_keysize = AES_MAX_KEY_SIZE, .ivsize = AES_BLOCK_SIZE, + .setkey = ablkcipher_aes_setkey, } }, .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
@@ -2785,6 +2799,7 @@ static struct talitos_alg_template drive .min_keysize = AES_MIN_KEY_SIZE, .max_keysize = AES_MAX_KEY_SIZE, .ivsize = AES_BLOCK_SIZE, + .setkey = ablkcipher_aes_setkey, } }, .desc_hdr_template = DESC_HDR_TYPE_AESU_CTR_NONSNOOP |
Greg Kroah-Hartman
maintainerPATCH 64/85 crypto: talitos - fix CTR alg blocksize
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit b9a05b6041cb9810a291315569b2af0d63c3680a upstream.
CTR has a blocksize of 1.
--- drivers/crypto/talitos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/talitos.c +1 -1
@@ -2792,7 +2792,7 @@ static struct talitos_alg_template drive .alg.crypto = { .cra_name = "ctr(aes)", .cra_driver_name = "ctr-aes-talitos", - .cra_blocksize = AES_BLOCK_SIZE, + .cra_blocksize = 1, .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, .cra_ablkcipher = {
Greg Kroah-Hartman
maintainerPATCH 65/85 crypto: talitos - check data blocksize in ablkcipher.
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit ee483d32ee1a1a7f7d7e918fbc350c790a5af64a upstream.
When data size is not a multiple of the alg's block size, the SEC generates an error interrupt and dumps the registers. And for NULL size, the SEC does just nothing and the interrupt is awaited forever.
This patch ensures the data size is correct before submitting the request to the SEC engine.
--- drivers/crypto/talitos.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/crypto/talitos.c +16 -0
@@ -1725,6 +1725,14 @@ static int ablkcipher_encrypt(struct ablstruct crypto_ablkcipher *cipher =crypto_ablkcipher_reqtfm (areq);struct talitos_ctx *ctx =crypto_ablkcipher_ctx (cipher);struct talitos_edesc *edesc; +unsigned int blocksize = +crypto_tfm_alg_blocksize (crypto_ablkcipher_tfm (cipher)); + +if (!areq->nbytes) +return 0 ; + +if (areq->nbytes % blocksize) +return -EINVAL ;/* allocate extended descriptor */ edesc =ablkcipher_edesc_alloc (areq, true);
@@ -1742,6 +1750,14 @@ static int ablkcipher_decrypt(struct ablstruct crypto_ablkcipher *cipher =crypto_ablkcipher_reqtfm (areq);struct talitos_ctx *ctx =crypto_ablkcipher_ctx (cipher);struct talitos_edesc *edesc; +unsigned int blocksize = +crypto_tfm_alg_blocksize (crypto_ablkcipher_tfm (cipher)); + +if (!areq->nbytes) +return 0 ; + +if (areq->nbytes % blocksize) +return -EINVAL ;/* allocate extended descriptor */ edesc =ablkcipher_edesc_alloc (areq, false);
Greg Kroah-Hartman
maintainerPATCH 66/85 crypto: talitos - fix ECB algs ivsize
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit d84cc9c9524ec5973a337533e6d8ccd3e5f05f2b upstream.
ECB's ivsize must be 0.
--- drivers/crypto/talitos.c | 3 --- 1 file changed, 3 deletions(-)
drivers/crypto/talitos.c +0 -3
@@ -2814,7 +2814,6 @@ static struct talitos_alg_template drive .cra_ablkcipher = { .min_keysize = AES_MIN_KEY_SIZE, .max_keysize = AES_MAX_KEY_SIZE, - .ivsize = AES_BLOCK_SIZE, .setkey = ablkcipher_aes_setkey, } },
@@ -2849,7 +2848,6 @@ static struct talitos_alg_template drive .cra_ablkcipher = { .min_keysize = DES_KEY_SIZE, .max_keysize = DES_KEY_SIZE, - .ivsize = DES_BLOCK_SIZE, .setkey = ablkcipher_des_setkey, } },
@@ -2885,7 +2883,6 @@ static struct talitos_alg_template drive .cra_ablkcipher = { .min_keysize = DES3_EDE_KEY_SIZE, .max_keysize = DES3_EDE_KEY_SIZE, - .ivsize = DES3_EDE_BLOCK_SIZE, .setkey = ablkcipher_des3_setkey, } },
Greg Kroah-Hartman
maintainerPATCH 67/85 crypto: talitos - Do not modify req->cryptlen on decryption.
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit 7ede4c36cf7c6516986ee9d75b197c8bf73ea96f upstream.
For decrypt, req->cryptlen includes the size of the authentication part while all functions of the driver expect cryptlen to be the size of the encrypted data.
As it is not expected to change req->cryptlen, this patch implements local calculation of cryptlen.
--- drivers/crypto/talitos.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)
drivers/crypto/talitos.c +17 -14
@@ -994,11 +994,13 @@ static void talitos_sg_unmap(struct devistatic void ipsec_esp_unmap (struct device *dev,struct talitos_edesc *edesc, -struct aead_request *areq) +struct aead_request *areq,bool encrypt) {struct crypto_aead *aead =crypto_aead_reqtfm (areq);struct talitos_ctx *ctx =crypto_aead_ctx (aead);unsigned int ivsize =crypto_aead_ivsize (aead); +unsigned int authsize =crypto_aead_authsize (aead); +unsigned int cryptlen = areq->cryptlen - (encrypt ?0 : authsize);bool is_ipsec_esp = edesc->desc.hdr &DESC_HDR_TYPE_IPSEC_ESP ;struct talitos_ptr *civ_ptr = &edesc->desc.ptr[is_ipsec_esp ?2 :3 ];
@@ -1007,7 +1009,7 @@ static void ipsec_esp_unmap(struct devic DMA_FROM_DEVICE);unmap_single_talitos_ptr (dev, civ_ptr,DMA_TO_DEVICE ); -talitos_sg_unmap (dev, edesc, areq->src, areq->dst, areq->cryptlen, +talitos_sg_unmap (dev, edesc, areq->src, areq->dst, cryptlen, areq->assoclen);if (edesc->dma_len)
@@ -1018,7 +1020,7 @@ static void ipsec_esp_unmap(struct devicunsigned int dst_nents = edesc->dst_nents ? :1 ;sg_pcopy_to_buffer (areq->dst, dst_nents, ctx->iv, ivsize, - areq->assoclen + areq->cryptlen - ivsize); + areq->assoclen + cryptlen - ivsize); } }
@@ -1040,7 +1042,7 @@ static void ipsec_esp_encrypt_done(struc edesc = container_of(desc, struct talitos_edesc, desc); -ipsec_esp_unmap (dev, edesc, areq); +ipsec_esp_unmap (dev, edesc, areq, true);/* copy the generated ICV to dst */ if (edesc->icv_ool) {
@@ -1074,7 +1076,7 @@ static void ipsec_esp_decrypt_swauth_don edesc = container_of(desc, struct talitos_edesc, desc); -ipsec_esp_unmap (dev, edesc, req); +ipsec_esp_unmap (dev, edesc, req, false);if (!err) {char icvdata[SHA512_DIGEST_SIZE ];
@@ -1120,7 +1122,7 @@ static void ipsec_esp_decrypt_hwauth_don edesc = container_of(desc, struct talitos_edesc, desc); -ipsec_esp_unmap (dev, edesc, req); +ipsec_esp_unmap (dev, edesc, req, false);/* check ICV auth status */ if (!err && ((desc->hdr_lo & DESC_HDR_LO_ICCR1_MASK) !=
@@ -1223,6 +1225,7 @@ static int talitos_sg_map(struct device* fill in and submit ipsec_esp descriptor */ static int ipsec_esp (struct talitos_edesc *edesc,struct aead_request *areq, +bool encrypt,void (*callback)(struct device *dev,struct talitos_desc *desc,void *context,int error))
@@ -1232,7 +1235,7 @@ static int ipsec_esp(struct talitos_edesstruct talitos_ctx *ctx =crypto_aead_ctx (aead);struct device *dev = ctx->dev;struct talitos_desc *desc = &edesc->desc; -unsigned int cryptlen = areq->cryptlen; +unsigned int cryptlen = areq->cryptlen - (encrypt ?0 : authsize);unsigned int ivsize =crypto_aead_ivsize (aead);int tbl_off =0 ;int sg_count, ret;
@@ -1359,7 +1362,7 @@ static int ipsec_esp(struct talitos_edes ret =talitos_submit (dev, ctx->ch, desc, callback, areq);if (ret != -EINPROGRESS ) { -ipsec_esp_unmap (dev, edesc, areq); +ipsec_esp_unmap (dev, edesc, areq, encrypt);kfree (edesc); }return ret;
@@ -1473,9 +1476,10 @@ static struct talitos_edesc *aead_edesc_unsigned int authsize =crypto_aead_authsize (authenc);struct talitos_ctx *ctx =crypto_aead_ctx (authenc);unsigned int ivsize =crypto_aead_ivsize (authenc); +unsigned int cryptlen = areq->cryptlen - (encrypt ?0 : authsize);return talitos_edesc_alloc (ctx->dev, areq->src, areq->dst, - iv, areq->assoclen, areq->cryptlen, + iv, areq->assoclen, cryptlen, authsize, ivsize, icv_stashing, areq->base.flags, encrypt); }
@@ -1494,7 +1498,7 @@ static int aead_encrypt(struct aead_requ/* set encrypt */ edesc->desc.hdr = ctx->desc_hdr_template |DESC_HDR_MODE0_ENCRYPT ; -return ipsec_esp (edesc, req, ipsec_esp_encrypt_done); +return ipsec_esp (edesc, req, true, ipsec_esp_encrypt_done); }static int aead_decrypt (struct aead_request *req)
@@ -1506,8 +1510,6 @@ static int aead_decrypt(struct aead_requstruct talitos_edesc *edesc;void *icvdata; - req->cryptlen -= authsize; -/* allocate extended descriptor */ edesc =aead_edesc_alloc (req, req->iv,1 , false);if (IS_ERR (edesc))
@@ -1524,7 +1526,8 @@ static int aead_decrypt(struct aead_requ/* reset integrity check result bits */ -return ipsec_esp (edesc, req, ipsec_esp_decrypt_hwauth_done); +return ipsec_esp (edesc, req, false, + ipsec_esp_decrypt_hwauth_done); }/* Have to check the ICV with software */
@@ -1540,7 +1543,7 @@ static int aead_decrypt(struct aead_requsg_pcopy_to_buffer (req->src, edesc->src_nents ? :1 , icvdata, authsize, req->assoclen + req->cryptlen - authsize); -return ipsec_esp (edesc, req, ipsec_esp_decrypt_swauth_done); +return ipsec_esp (edesc, req, false, ipsec_esp_decrypt_swauth_done); } static int ablkcipher_setkey(struct crypto_ablkcipher *cipher,
Greg Kroah-Hartman
maintainerPATCH 68/85 crypto: talitos - HMAC SNOOP NO AFEU mode requires SW icv checking.
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit 4bbfb839259a9c96a0be872e16f7471b7136aee5 upstream.
In that mode, hardware ICV verification is not supported.
--- drivers/crypto/talitos.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/crypto/talitos.c +2 -1
@@ -1515,7 +1515,8 @@ static int aead_decrypt(struct aead_requif (IS_ERR (edesc))return PTR_ERR (edesc); -if ((priv->features &TALITOS_FTR_HW_AUTH_CHECK ) && +if ((edesc->desc.hdr &DESC_HDR_TYPE_IPSEC_ESP ) && + (priv->features &TALITOS_FTR_HW_AUTH_CHECK ) && ((!edesc->src_nents && !edesc->dst_nents) || priv->features &TALITOS_FTR_SRC_LINK_TBL_LEN_INCLUDES_EXTENT )) {
Greg Kroah-Hartman
maintainerPATCH 69/85 firmware: ti_sci: Always request response from firmware
In reply to Greg Kroah-HartmanFrom: Andrew F. Davis <[email protected]>
commit 66f030eac257a572fbedab3d9646d87d647351fd upstream.
TI-SCI firmware will only respond to messages when the TI_SCI_FLAG_REQ_ACK_ON_PROCESSED flag is set. Most messages already do this, set this for the ones that do not.
This will be enforced in future firmware that better match the TI-SCI specifications, this patch will not break users of existing firmware.
--- drivers/firmware/ti_sci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/firmware/ti_sci.c +4 -4
@@ -466,9 +466,9 @@ static int ti_sci_cmd_get_revision(strucstruct ti_sci_xfer *xfer;int ret; -/* No need to setup flags since it is expected to respond */ xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_VERSION , -0x0 ,sizeof (struct ti_sci_msg_hdr ), +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , +sizeof (struct ti_sci_msg_hdr ),sizeof (*rev_info));if (IS_ERR (xfer)) { ret =PTR_ERR (xfer);
@@ -596,9 +596,9 @@ static int ti_sci_get_device_state(const info =handle_to_ti_sci_info (handle); dev = info->dev; -/* Response is expected, so need of any flags */ xfer =ti_sci_get_one_xfer (info,TI_SCI_MSG_GET_DEVICE_STATE , -0 ,sizeof (*req),sizeof (*resp)); +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED , +sizeof (*req),sizeof (*resp));if (IS_ERR (xfer)) { ret =PTR_ERR (xfer);dev_err (dev,"Message alloc failed(%d)\n" , ret);
Greg Kroah-Hartman
maintainerPATCH 70/85 drm: panel-orientation-quirks: Add extra quirk table entry for GPD MicroPC
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
commit dae1ccee012ea7514af8e4a88429844157aca7dc upstream.
Newer GPD MicroPC BIOS versions have proper DMI strings, add an extra quirk table entry for these new strings. This is good news, as this means that we no longer have to update the BIOS dates list with every BIOS update.
--- drivers/gpu/drm/drm_panel_orientation_quirks.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/gpu/drm/drm_panel_orientation_quirks.c +12 -0
@@ -90,6 +90,12 @@ static const struct drm_dmi_panel_orient .orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP, }; +static const struct drm_dmi_panel_orientation_data lcd720x1280_rightside_up = { + .width =720 , + .height =1280 , + .orientation =DRM_MODE_PANEL_ORIENTATION_RIGHT_UP , +}; +static const struct drm_dmi_panel_orientation_data lcd800x1280_rightside_up = { .width =800 , .height =1280 ,
@@ -123,6 +129,12 @@ static const struct dmi_system_id orient DMI_EXACT_MATCH(DMI_BOARD_NAME, "Default string"), }, .driver_data = (void *)&gpd_micropc, + }, { /* GPD MicroPC (later BIOS versions with proper DMI strings) */ + .matches = { +DMI_EXACT_MATCH (DMI_SYS_VENDOR ,"GPD" ), + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "MicroPC"), + }, + .driver_data = (void *)&lcd720x1280_rightside_up, }, { /** GPD Pocket, note that the the DMI data is less generic then * it seems, devices with a board-vendor of "AMI Corporation"
Greg Kroah-Hartman
maintainerPATCH 71/85 drm/mediatek: mtk_drm_drv.c: Add of_node_put() before goto
In reply to Greg Kroah-HartmanFrom: Nishka Dasgupta <[email protected]>
commit 165d42c012be69900f0e2f8545626cb9e7d4a832 upstream.
Each iteration of for_each_child_of_node puts the previous node, but in the case of a goto from the middle of the loop, there is no put, thus causing a memory leak. Hence add an of_node_put before the goto in two places.
Issue found with Coccinelle.
--- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_drm_drv.c +4 -1
@@ -567,12 +567,15 @@ static int mtk_drm_probe(struct platform comp =devm_kzalloc (dev,sizeof (*comp),GFP_KERNEL );if (!comp) { ret = -ENOMEM ; +of_node_put (node); goto err_node; } ret =mtk_ddp_comp_init (dev, node, comp, comp_id,NULL ); -if (ret) +if (ret) { +of_node_put (node); goto err_node; + } private->ddp_comp[comp_id] = comp; }
Greg Kroah-Hartman
maintainerPATCH 72/85 mm/z3fold.c: remove z3fold_migration trylock
In reply to Greg Kroah-HartmanFrom: Henry Burns <[email protected]>
commit be03074c9af25d06cf8e9ebddfcd284c0bf7f947 upstream.
z3fold_page_migrate() will never succeed because it attempts to acquire a lock that has already been taken by migrate.c in __unmap_and_move().
__unmap_and_move() migrate.c
trylock_page(oldpage)
move_to_new_page(oldpage_newpage)
a_ops->migrate_page(oldpage, newpage)
z3fold_page_migrate(oldpage, newpage)
trylock_page(oldpage)--- mm/z3fold.c | 6 ------ 1 file changed, 6 deletions(-)
mm/z3fold.c +0 -6
@@ -1439,16 +1439,11 @@ static int z3fold_page_migrate(struct ad zhdr =page_address (page); pool =zhdr_to_pool (zhdr); -if (!trylock_page (page)) -return -EAGAIN ; -if (!z3fold_page_trylock (zhdr)) { -unlock_page (page);return -EAGAIN ; }if (zhdr->mapped_count !=0 ) {z3fold_page_unlock (zhdr); -unlock_page (page);return -EBUSY ; }if (work_pending (&zhdr->work)) {
@@ -1494,7 +1489,6 @@ static int z3fold_page_migrate(struct adspin_unlock (&pool->lock);page_mapcount_reset (page); -unlock_page (page);put_page (page);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 73/85 mm/z3fold.c: fix lock/unlock imbalance in z3fold_page_isolate
In reply to Greg Kroah-HartmanFrom: Gustavo A. R. Silva <[email protected]>
commit 14108b9131a47ff18a3c640f583eb2d625c75c0d upstream.
Fix lock/unlock imbalance by unlocking *zhdr* before return.
Addresses Coverity ID 1452811 ("Missing unlock")
--- mm/z3fold.c | 1 + 1 file changed, 1 insertion(+)
mm/z3fold.c +1 -0
@@ -1408,6 +1408,7 @@ static bool z3fold_page_isolate(struct p* should freak out. */ WARN (1 ,"Z3fold is experiencing kref problems\n" ); +z3fold_page_unlock (zhdr);return false; }z3fold_page_unlock (zhdr);
Greg Kroah-Hartman
maintainerPATCH 74/85 Revert "Bluetooth: btusb: driver to enable the usb-wakeup feature"
In reply to Greg Kroah-HartmanFrom: Mario Limonciello <[email protected]>
commit 1ffdb51f28e8ec6be0a2b812c1765b5cf5c44a8f upstream.
This reverts commit a0085f2510e8976614ad8f766b209448b385492f.
This commit has caused regressions in notebooks that support suspend to idle such as the XPS 9360, XPS 9370 and XPS 9380.
These notebooks will wakeup from suspend to idle from an unsolicited advertising packet from an unpaired BLE device.
In a bug report it was sugggested that this is caused by a generic lack of LE privacy support. Revert this commit until that behavior can be avoided by the kernel.
--- drivers/bluetooth/btusb.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/bluetooth/btusb.c +0 -5
@@ -1162,10 +1162,6 @@ static int btusb_open(struct hci_dev *hd } data->intf->needs_remote_wakeup =1 ; -/* device specific wakeup source enabled and required for USB -* remote wakeup while host is suspended -*/ -device_wakeup_enable (&data->udev->dev);if (test_and_set_bit (BTUSB_INTR_RUNNING , &data->flags)) goto done;
@@ -1229,7 +1225,6 @@ static int btusb_close(struct hci_dev *h goto failed; data->intf->needs_remote_wakeup =0 ; -device_wakeup_disable (&data->udev->dev);usb_autopm_put_interface (data->intf); failed:
Greg Kroah-Hartman
maintainerPATCH 75/85 iio: adc: stm32-dfsdm: fix output resolution
In reply to Greg Kroah-HartmanFrom: Olivier Moysan <[email protected]>
commit 12c8398d8012ead3d3d68422067ab2f9a66ae76a upstream.
In buffered mode, output samples are shifted left unconditionally. This works for filter order 3, but this shift is not adapted for other filter orders. Compute required shift, left or right, and shift output data accordingly.
Add also saturation management to avoid wrap-around when maximum positive sample is reached.
--- drivers/iio/adc/stm32-dfsdm-adc.c | 158 +++++++++++++++++++++++++++++--------- drivers/iio/adc/stm32-dfsdm.h | 24 ++++- 2 files changed, 142 insertions(+), 40 deletions(-)
drivers/iio/adc/stm32-dfsdm-adc.c +123 -35
@@ -39,9 +39,16 @@#define DFSDM_MAX_INT_OVERSAMPLING 256#define DFSDM_MAX_FL_OVERSAMPLING 1024 -/* Max sample resolutions */ -#define DFSDM_MAX_RES BIT(31) -#define DFSDM_DATA_RES BIT(23) +/* Limit filter output resolution to 31 bits. (i.e. sample range is +/-2^30) */ +#define DFSDM_DATA_MAX BIT(30) +/* +* Data are output as two's complement data in a 24 bit field. +* Data from filters are in the range +/-2^(n-1) +* 2^(n-1) maximum positive value cannot be coded in 2's complement n bits +* An extra bit is required to avoid wrap-around of the binary code for 2^(n-1) +* So, the resolution of samples from filter is actually limited to 23 bits +*/ +#define DFSDM_DATA_RES 24/* Filter configuration */ #define DFSDM_CR1_CFG_MASK (DFSDM_CR1_RCH_MASK | DFSDM_CR1_RCONT_MASK | \
@@ -181,14 +188,15 @@ static int stm32_dfsdm_get_jextsel(strucreturn -EINVAL ; } -static int stm32_dfsdm_set_osrs (struct stm32_dfsdm_filter *fl, -unsigned int fast,unsigned int oversamp) +static int stm32_dfsdm_compute_osrs (struct stm32_dfsdm_filter *fl, +unsigned int fast,unsigned int oversamp) {unsigned int i, d, fosr, iosr; -u64 res; -s64 delta; +u64 res, max; +int bits, shift;unsigned int m =1 ;/* multiplication factor */ unsigned int p = fl->ford;/* filter order (ford) */ +struct stm32_dfsdm_filter_osr *flo = &fl->flo;pr_debug ("%s: Requested oversampling: %d\n" , __func__, oversamp);/*
@@ -207,11 +215,9 @@ static int stm32_dfsdm_set_osrs(struct s/* * Look for filter and integrator oversampling ratios which allows -* to reach 24 bits data output resolution. -* Leave as soon as if exact resolution if reached. -* Otherwise the higher resolution below 32 bits is kept. +* to maximize data output resolution. */ - fl->res =0 ; + flo->res =0 ;for (fosr =1 ; fosr <=DFSDM_MAX_FL_OVERSAMPLING ; fosr++) {for (iosr =1 ; iosr <=DFSDM_MAX_INT_OVERSAMPLING ; iosr++) {if (fast)
@@ -236,32 +242,68 @@ static int stm32_dfsdm_set_osrs(struct s res = fosr;for (i = p -1 ; i >0 ; i--) { res = res * (u64 )fosr; -if (res >DFSDM_MAX_RES ) +if (res >DFSDM_DATA_MAX )break ; } -if (res >DFSDM_MAX_RES ) +if (res >DFSDM_DATA_MAX )continue ; + res = res * (u64 )m * (u64 )iosr; -if (res >DFSDM_MAX_RES ) +if (res >DFSDM_DATA_MAX )continue ; - delta = res -DFSDM_DATA_RES ; - -if (res >= fl->res) { - fl->res = res; - fl->fosr = fosr; - fl->iosr = iosr; - fl->fast = fast; -pr_debug ("%s: fosr = %d, iosr = %d\n" , - __func__, fl->fosr, fl->iosr); +if (res >= flo->res) { + flo->res = res; + flo->fosr = fosr; + flo->iosr = iosr; + + bits =fls (flo->res); +/* 8 LBSs in data register contain chan info */ + max = flo->res <<8 ; + +/* if resolution is not a power of two */ +if (flo->res >BIT (bits -1 )) + bits++; +else + max--; + + shift =DFSDM_DATA_RES - bits; +/* +* Compute right/left shift +* Right shift is performed by hardware +* when transferring samples to data register. +* Left shift is done by software on buffer +*/ +if (shift >0 ) { +/* Resolution is lower than 24 bits */ + flo->rshift =0 ; + flo->lshift = shift; + }else { +/* +* If resolution is 24 bits or more, +* max positive value may be ambiguous +* (equal to max negative value as sign +* bit is dropped). +* Reduce resolution to 23 bits (rshift) +* to keep the sign on bit 23 and treat +* saturation before rescaling on 24 +* bits (lshift). +*/ + flo->rshift =1 - shift; + flo->lshift =1 ; + max >>= flo->rshift; + } + flo->max = (s32 )max; + +pr_debug ("%s: fast %d, fosr %d, iosr %d, res 0x%llx/%d bits, rshift %d, lshift %d\n" , + __func__, fast, flo->fosr, flo->iosr, + flo->res, bits, flo->rshift, + flo->lshift); } - -if (!delta) -return 0 ; } } -if (!fl->res) +if (!flo->res)return -EINVAL ;return 0 ;
@@ -384,6 +426,36 @@ static int stm32_dfsdm_filter_set_trig(sreturn 0 ; } +static int stm32_dfsdm_channels_configure (struct stm32_dfsdm_adc *adc, +unsigned int fl_id, +struct iio_trigger *trig) +{ +struct iio_dev *indio_dev =iio_priv_to_dev (adc); +struct regmap *regmap = adc->dfsdm->regmap; +struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[fl_id]; +struct stm32_dfsdm_filter_osr *flo = &fl->flo; +const struct iio_chan_spec *chan; +unsigned int bit; +int ret; + +if (!flo->res) +return -EINVAL ; + +for_each_set_bit (bit, &adc->smask, +sizeof (adc->smask) *BITS_PER_BYTE ) { + chan = indio_dev->channels + bit; + + ret =regmap_update_bits (regmap, +DFSDM_CHCFGR2 (chan->channel), +DFSDM_CHCFGR2_DTRBS_MASK , +DFSDM_CHCFGR2_DTRBS (flo->rshift)); +if (ret) +return ret; + } + +return 0 ; +} +static int stm32_dfsdm_filter_configure (struct stm32_dfsdm_adc *adc,unsigned int fl_id,struct iio_trigger *trig)
@@ -391,6 +463,7 @@ static int stm32_dfsdm_filter_configure(struct iio_dev *indio_dev =iio_priv_to_dev (adc);struct regmap *regmap = adc->dfsdm->regmap;struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[fl_id]; +struct stm32_dfsdm_filter_osr *flo = &fl->flo;u32 cr1;const struct iio_chan_spec *chan;unsigned int bit, jchg =0 ;
@@ -398,13 +471,13 @@ static int stm32_dfsdm_filter_configure(/* Average integrator oversampling */ ret =regmap_update_bits (regmap,DFSDM_FCR (fl_id),DFSDM_FCR_IOSR_MASK , -DFSDM_FCR_IOSR (fl->iosr -1 )); +DFSDM_FCR_IOSR (flo->iosr -1 ));if (ret)return ret;/* Filter order and Oversampling */ ret =regmap_update_bits (regmap,DFSDM_FCR (fl_id),DFSDM_FCR_FOSR_MASK , -DFSDM_FCR_FOSR (fl->fosr -1 )); +DFSDM_FCR_FOSR (flo->fosr -1 ));if (ret)return ret;
@@ -573,7 +646,7 @@ static int dfsdm_adc_set_samp_freq(struc"Rate not accurate. requested (%u), actual (%u)\n" , sample_freq, spi_freq / oversamp); - ret =stm32_dfsdm_set_osrs (fl,0 , oversamp); + ret =stm32_dfsdm_compute_osrs (fl,0 , oversamp);if (ret <0 ) {dev_err (&indio_dev->dev,"No filter parameters that match!\n" );return ret;
@@ -623,6 +696,10 @@ static int stm32_dfsdm_start_conv(structstruct regmap *regmap = adc->dfsdm->regmap;int ret; + ret =stm32_dfsdm_channels_configure (adc, adc->fl_id, trig); +if (ret <0 ) +return ret; + ret =stm32_dfsdm_start_channel (adc);if (ret <0 )return ret;
@@ -729,6 +806,8 @@ static void stm32_dfsdm_dma_buffer_done( {struct iio_dev *indio_dev = data;struct stm32_dfsdm_adc *adc =iio_priv (indio_dev); +struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[adc->fl_id]; +struct stm32_dfsdm_filter_osr *flo = &fl->flo;int available =stm32_dfsdm_adc_dma_residue (adc);size_t old_pos;
@@ -751,10 +830,19 @@ static void stm32_dfsdm_dma_buffer_done( old_pos = adc->bufi;while (available >= indio_dev->scan_bytes) { -u32 *buffer = (u32 *)&adc->rx_buf[adc->bufi]; +s32 *buffer = (s32 *)&adc->rx_buf[adc->bufi];/* Mask 8 LSB that contains the channel ID */ - *buffer = (*buffer &0xFFFFFF00 ) <<8 ; + *buffer &=0xFFFFFF00 ; +/* Convert 2^(n-1) sample to 2^(n-1)-1 to avoid wrap-around */ +if (*buffer > flo->max) + *buffer -=1 ; +/* +* Samples from filter are retrieved with 23 bits resolution +* or less. Shift left to align MSB on 24 bits. +*/ + *buffer <<= flo->lshift; + available -= indio_dev->scan_bytes; adc->bufi += indio_dev->scan_bytes;if (adc->bufi >= adc->buf_sz) {
@@ -1078,7 +1166,7 @@ static int stm32_dfsdm_write_raw(struct ret =iio_device_claim_direct_mode (indio_dev);if (ret)return ret; - ret =stm32_dfsdm_set_osrs (fl,0 , val); + ret =stm32_dfsdm_compute_osrs (fl,0 , val);if (!ret) adc->oversamp = val;iio_device_release_direct_mode (indio_dev);
@@ -1327,8 +1415,8 @@ static int stm32_dfsdm_adc_init(struct iint ret, chan_idx; adc->oversamp =DFSDM_DEFAULT_OVERSAMPLING ; - ret =stm32_dfsdm_set_osrs (&adc->dfsdm->fl_list[adc->fl_id],0 , - adc->oversamp); + ret =stm32_dfsdm_compute_osrs (&adc->dfsdm->fl_list[adc->fl_id],0 , + adc->oversamp);if (ret <0 )return ret;
drivers/iio/adc/stm32-dfsdm.h +19 -5
@@ -243,19 +243,33 @@ enum stm32_dfsdm_sinc_order { };/** -* struct stm32_dfsdm_filter - structure relative to stm32 FDSDM filter +* struct stm32_dfsdm_filter_osr - DFSDM filter settings linked to oversampling * @iosr: integrator oversampling * @fosr: filter oversampling -* @ford: filter order +* @rshift: output sample right shift (hardware shift) +* @lshift: output sample left shift (software shift) * @res: output sample resolution +* @max: output sample maximum positive value +*/ +struct stm32_dfsdm_filter_osr { +unsigned int iosr; +unsigned int fosr; +unsigned int rshift; +unsigned int lshift; +u64 res; +s32 max; +}; + +/** +* struct stm32_dfsdm_filter - structure relative to stm32 FDSDM filter +* @ford: filter order +* @flo: filter oversampling structure * @sync_mode: filter synchronized with filter 0 * @fast: filter fast mode */ struct stm32_dfsdm_filter { -unsigned int iosr; -unsigned int fosr;enum stm32_dfsdm_sinc_order ford; -u64 res; +struct stm32_dfsdm_filter_osr flo;unsigned int sync_mode;unsigned int fast; };
Greg Kroah-Hartman
maintainerPATCH 76/85 iio: adc: stm32-dfsdm: fix data type
In reply to Greg Kroah-HartmanFrom: Olivier Moysan <[email protected]>
commit c6013bf50e2a2a94ab3d012e191096432aa50c6f upstream.
Fix the data type as DFSDM raw output is complements 2, 24bits left aligned in a 32-bit register.
This change does not affect AUDIO path
- Set data as signed for IIO (as for AUDIO)
- Set 8 bit right shift for IIO.
The 8 LSBs bits of data contains channel info and are masked.
--- drivers/iio/adc/stm32-dfsdm-adc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/adc/stm32-dfsdm-adc.c +2 -2
@@ -1365,11 +1365,11 @@ static int stm32_dfsdm_adc_chan_init_oneBIT (IIO_CHAN_INFO_SAMP_FREQ );if (adc->dev_data->type ==DFSDM_AUDIO ) { - ch->scan_type.sign ='s' ; ch->ext_info = dfsdm_adc_audio_ext_info; }else { - ch->scan_type.sign ='u' ; + ch->scan_type.shift =8 ; } + ch->scan_type.sign ='s' ; ch->scan_type.realbits =24 ; ch->scan_type.storagebits =32 ;
Greg Kroah-Hartman
maintainerPATCH 77/85 modules: fix BUG when load module with rodata=n
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
commit 2eef1399a866c57687962e15142b141a4f8e7862 upstream.
When loading a module with rodata=n, it causes an executing NX-protected page BUG.
[ 32.379191] kernel tried to execute NX-protected page - exploit attempt? (uid: 0) [ 32.382917] BUG: unable to handle page fault for address: ffffffffc0005000 [ 32.385947] #PF: supervisor instruction fetch in kernel mode [ 32.387662] #PF: error_code(0x0011) - permissions violation [ 32.389352] PGD 240c067 P4D 240c067 PUD 240e067 PMD 421a52067 PTE 8000000421a53063 [ 32.391396] Oops: 0011 [#1] SMP PTI [ 32.392478] CPU: 7 PID: 2697 Comm: insmod Tainted: G O 5.2.0-rc5+ #202 [ 32.394588] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014 [ 32.398157] RIP: 0010:ko_test_init+0x0/0x1000 [ko_test] [ 32.399662] Code: Bad RIP value. [ 32.400621] RSP: 0018:ffffc900029f3ca8 EFLAGS: 00010246 [ 32.402171] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000 [ 32.404332] RDX: 00000000000004c7 RSI: 0000000000000cc0 RDI: ffffffffc0005000 [ 32.406347] RBP: ffffffffc0005000 R08: ffff88842fbebc40 R09: ffffffff810ede4a [ 32.408392] R10: ffffea00108e3480 R11: 0000000000000000 R12: ffff88842bee21a0 [ 32.410472] R13: 0000000000000001 R14: 0000000000000001 R15: ffffc900029f3e78 [ 32.412609] FS: 00007fb4f0c0a700(0000) GS:ffff88842fbc0000(0000) knlGS:0000000000000000 [ 32.414722] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 32.416290] CR2: ffffffffc0004fd6 CR3: 0000000421a90004 CR4: 0000000000020ee0 [ 32.418471] Call Trace: [ 32.419136] do_one_initcall+0x41/0x1df [ 32.420199] ? _cond_resched+0x10/0x40 [ 32.421433] ? kmem_cache_alloc_trace+0x36/0x160 [ 32.422827] do_init_module+0x56/0x1f7 [ 32.423946] load_module+0x1e67/0x2580 [ 32.424947] ? __alloc_pages_nodemask+0x150/0x2c0 [ 32.426413] ? map_vm_area+0x2d/0x40 [ 32.427530] ? __vmalloc_node_range+0x1ef/0x260 [ 32.428850] ? __do_sys_init_module+0x135/0x170 [ 32.430060] ? _cond_resched+0x10/0x40 [ 32.431249] __do_sys_init_module+0x135/0x170 [ 32.432547] do_syscall_64+0x43/0x120 [ 32.433853] entry_SYSCALL_64_after_hwframe+0x44/0xa9
Because if rodata=n, set_memory_x() can't be called, fix this by calling set_memory_x in complete_formation();
--- kernel/module.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
kernel/module.c +7 -4
@@ -1961,13 +1961,9 @@ void module_enable_ro(const struct modulset_vm_flush_reset_perms (mod->core_layout.base);set_vm_flush_reset_perms (mod->init_layout.base);frob_text (&mod->core_layout, set_memory_ro); -frob_text (&mod->core_layout, set_memory_x);frob_rodata (&mod->core_layout, set_memory_ro); -frob_text (&mod->init_layout, set_memory_ro); -frob_text (&mod->init_layout, set_memory_x); -frob_rodata (&mod->init_layout, set_memory_ro);if (after_init)
@@ -2030,6 +2026,12 @@ void set_all_modules_text_ro(void)static void module_enable_nx (const struct module *mod) { }#endif +static void module_enable_x (const struct module *mod) +{ +frob_text (&mod->core_layout, set_memory_x); +frob_text (&mod->init_layout, set_memory_x); +} +#ifdef CONFIG_LIVEPATCH /* * Persist Elf information about a module. Copy the Elf header,
@@ -3626,6 +3628,7 @@ static int complete_formation(struct modmodule_enable_ro (mod, false);module_enable_nx (mod); +module_enable_x (mod);/* Mark state as coming so strong_try_module_get() ignores us, * but kallsyms etc. can see us. */
Greg Kroah-Hartman
maintainerPATCH 78/85 modules: fix compile error if dont have strict module rwx
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
commit 93651f80dcb616b8c9115cdafc8e57a781af22d0 upstream.
If CONFIG_ARCH_HAS_STRICT_MODULE_RWX is not defined, we need stub for module_enable_nx() and module_enable_x().
If CONFIG_ARCH_HAS_STRICT_MODULE_RWX is defined, but CONFIG_STRICT_MODULE_RWX is disabled, we need stub for module_enable_nx.
Move frob_text() outside of the CONFIG_STRICT_MODULE_RWX, because it is needed anyway.
--- kernel/module.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
kernel/module.c +9 -4
@@ -1887,7 +1887,7 @@ static void mod_sysfs_teardown(struct momod_sysfs_fini (mod); } -#ifdef CONFIG_STRICT_MODULE_RWX +#ifdef CONFIG_ARCH_HAS_STRICT_MODULE_RWX /* * LKM RO/NX protection: protect module's text/ro-data * from modification and any data from execution.
@@ -1910,6 +1910,7 @@ static void frob_text(const struct modul layout->text_size >> PAGE_SHIFT); } +#ifdef CONFIG_STRICT_MODULE_RWX static void frob_rodata (const struct module_layout *layout,int (*set_memory)(unsigned long start,int num_pages)) {
@@ -2022,15 +2023,19 @@ void set_all_modules_text_ro(void) }mutex_unlock (&module_mutex); } -#else +#else /* !CONFIG_STRICT_MODULE_RWX */ static void module_enable_nx (const struct module *mod) { } -#endif - +#endif /* CONFIG_STRICT_MODULE_RWX */ static void module_enable_x (const struct module *mod) {frob_text (&mod->core_layout, set_memory_x);frob_text (&mod->init_layout, set_memory_x); } +#else /* !CONFIG_ARCH_HAS_STRICT_MODULE_RWX */ +static void module_enable_nx (const struct module *mod) { } +static void module_enable_x (const struct module *mod) { } +#endif /* CONFIG_ARCH_HAS_STRICT_MODULE_RWX */ +#ifdef CONFIG_LIVEPATCH /*
Greg Kroah-Hartman
maintainerPATCH 79/85 modules: always page-align module section allocations
In reply to Greg Kroah-HartmanFrom: Jessica Yu <[email protected]>
commit 38f054d549a869f22a02224cd276a27bf14b6171 upstream.
Some arches (e.g., arm64, x86) have moved towards non-executable module_alloc() allocations for security hardening reasons. That means that the module loader will need to set the text section of a module to executable, regardless of whether or not CONFIG_STRICT_MODULE_RWX is set.
When CONFIG_STRICT_MODULE_RWX=y, module section allocations are always page-aligned to handle memory rwx permissions. On some arches with CONFIG_STRICT_MODULE_RWX=n however, when setting the module text to executable, the BUG_ON() in frob_text() gets triggered since module section allocations are not page-aligned when CONFIG_STRICT_MODULE_RWX=n. Since the set_memory_* API works with pages, and since we need to call set_memory_x() regardless of whether CONFIG_STRICT_MODULE_RWX is set, we might as well page-align all module section allocations for ease of managing rwx permissions of module sections (text, rodata, etc).
--- kernel/module.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
kernel/module.c +1 -6
@@ -64,14 +64,9 @@/* * Modules' sections will be aligned on page boundaries -* to ensure complete separation of code and data, but -* only when CONFIG_STRICT_MODULE_RWX=y +* to ensure complete separation of code and data */ -#ifdef CONFIG_STRICT_MODULE_RWX # define debug_align (X ) ALIGN(X, PAGE_SIZE) -#else -# define debug_align (X ) (X) -#endif /* If this is set, the section belongs in the init part of the module */ #define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG-1))
Greg Kroah-Hartman
maintainerPATCH 80/85 kvm: nVMX: Remove unnecessary sync_roots from handle_invept
In reply to Greg Kroah-HartmanFrom: Jim Mattson <[email protected]>
commit b119019847fbcac36ed1384f166c91f177d070e7 upstream.
When L0 is executing handle_invept(), the TDP MMU is active. Emulating an L1 INVEPT does require synchronizing the appropriate shadow EPT root(s), but a call to kvm_mmu_sync_roots in this context won't do that. Similarly, the hardware TLB and paging-structure-cache entries associated with the appropriate shadow EPT root(s) must be flushed, but requesting a TLB_FLUSH from this context won't do that either.
How did this ever work? KVM always does a sync_roots and TLB flush (in the correct context) when transitioning from L1 to L2. That isn't the best choice for nested VM performance, but it effectively papers over the mistakes here.
Remove the unnecessary operations and leave a comment to try to do better in the future.
Reviewed-by Peter Shier <[email protected]>
--- arch/x86/kvm/vmx/nested.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
arch/x86/kvm/vmx/nested.c +3 -5
@@ -4708,13 +4708,11 @@ static int handle_invept(struct kvm_vcpuswitch (type) {case VMX_EPT_EXTENT_GLOBAL : +case VMX_EPT_EXTENT_CONTEXT :/* -* TODO: track mappings and invalidate -* single context requests appropriately +* TODO: Sync the necessary shadow EPT roots here, rather than +* at the next emulated VM-entry. */ -case VMX_EPT_EXTENT_CONTEXT : -kvm_mmu_sync_roots (vcpu); -kvm_make_request (KVM_REQ_TLB_FLUSH , vcpu);break ;default :BUG_ON (1 );
Greg Kroah-Hartman
maintainerPATCH 81/85 KVM: SVM: Fix detection of AMD Errata 1096
In reply to Greg Kroah-HartmanFrom: Liran Alon <[email protected]>
commit 118154bdf54ca79e4b5f3ce6d4a8a7c6b7c2c76f upstream.
When CPU raise #NPF on guest data access and guest CR4.SMAP=1, it is possible that CPU microcode implementing DecodeAssist will fail to read bytes of instruction which caused #NPF. This is AMD errata 1096 and it happens because CPU microcode reading instruction bytes incorrectly attempts to read code as implicit supervisor-mode data accesses (that is, just like it would read e.g. a TSS), which are susceptible to SMAP faults. The microcode reads CS:RIP and if it is a user-mode address according to the page tables, the processor gives up and returns no instruction bytes. In this case, GuestIntrBytes field of the VMCB on a VMEXIT will incorrectly return 0 instead of the correct guest instruction bytes.
Current KVM code attemps to detect and workaround this errata, but it has multiple issues:
1) It mistakenly checks if guest CR4.SMAP=0 instead of guest CR4.SMAP=1, which is required for encountering a SMAP fault.
2) It assumes SMAP faults can only occur when guest CPL==3. However, in case guest CR4.SMEP=0, the guest can execute an instruction which reside in a user-accessible page with CPL<3 priviledge. If this instruction raise a #NPF on it's data access, then CPU DecodeAssist microcode will still encounter a SMAP violation. Even though no sane OS will do so (as it's an obvious priviledge escalation vulnerability), we still need to handle this semanticly correct in KVM side.
Note that (2) *is* a useful optimization, because CR4.SMAP=1 is an easy triggerable condition and guests usually enable SMAP together with SMEP. If the vCPU has CR4.SMEP=1, the errata could indeed be encountered onlt at guest CPL==3; otherwise, the CPU would raise a SMEP fault to guest instead of #NPF. We keep this condition to avoid false positives in the detection of the errata.
In addition, to avoid future confusion and improve code readbility, include details of the errata in code and not just in commit message.
--- arch/x86/kvm/svm.c | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-)
arch/x86/kvm/svm.c +35 -7
@@ -7116,13 +7116,41 @@ static int nested_enable_evmcs(struct kvstatic bool svm_need_emulation_on_page_fault (struct kvm_vcpu *vcpu) { -bool is_user, smap; - - is_user =svm_get_cpl (vcpu) ==3 ; - smap = !kvm_read_cr4_bits (vcpu,X86_CR4_SMAP ); +unsigned long cr4 =kvm_read_cr4 (vcpu); +bool smep = cr4 &X86_CR4_SMEP ; +bool smap = cr4 &X86_CR4_SMAP ; +bool is_user =svm_get_cpl (vcpu) ==3 ;/* -* Detect and workaround Errata 1096 Fam_17h_00_0Fh +* Detect and workaround Errata 1096 Fam_17h_00_0Fh. +* +* Errata: +* When CPU raise #NPF on guest data access and vCPU CR4.SMAP=1, it is +* possible that CPU microcode implementing DecodeAssist will fail +* to read bytes of instruction which caused #NPF. In this case, +* GuestIntrBytes field of the VMCB on a VMEXIT will incorrectly +* return 0 instead of the correct guest instruction bytes. +* +* This happens because CPU microcode reading instruction bytes +* uses a special opcode which attempts to read data using CPL=0 +* priviledges. The microcode reads CS:RIP and if it hits a SMAP +* fault, it gives up and returns no instruction bytes. +* +* Detection: +* We reach here in case CPU supports DecodeAssist, raised #NPF and +* returned 0 in GuestIntrBytes field of the VMCB. +* First, errata can only be triggered in case vCPU CR4.SMAP=1. +* Second, if vCPU CR4.SMEP=1, errata could only be triggered +* in case vCPU CPL==3 (Because otherwise guest would have triggered +* a SMEP fault instead of #NPF). +* Otherwise, vCPU CR4.SMEP=0, errata could be triggered by any vCPU CPL. +* As most guests enable SMAP if they have also enabled SMEP, use above +* logic in order to attempt minimize false-positive of detecting errata +* while still preserving all cases semantic correctness. +* +* Workaround: +* To determine what instruction the guest was executing, the hypervisor +* will have to decode the instruction at the instruction pointer. * * In non SEV guest, hypervisor will be able to read the guest * memory to decode the instruction pointer when insn_len is zero
@@ -7133,11 +7161,11 @@ static bool svm_need_emulation_on_page_f* instruction pointer so we will not able to workaround it. Lets * print the error and request to kill the guest. */ -if (is_user && smap) { +if (smap && (!smep || is_user)) {if (!sev_guest (vcpu->kvm))return true; -pr_err_ratelimited ("KVM: Guest triggered AMD Erratum 1096\n" ); +pr_err_ratelimited ("KVM: SEV Guest triggered AMD Erratum 1096\n" );kvm_make_request (KVM_REQ_TRIPLE_FAULT , vcpu); }
Greg Kroah-Hartman
maintainerPATCH 82/85 platform/x86: pmc_atom: Add CB4063 Beckhoff Automation board to critclk_systems DMI table
In reply to Greg Kroah-HartmanFrom: Steffen Dirkwinkel <[email protected]>
commit 9452fbf5c6cf5f470e0748fe7a14a683e7765f7a upstream.
The CB4063 board uses pmc_plt_clk* clocks for ethernet controllers. This adds it to the critclk_systems DMI table so the clocks are marked as CLK_CRITICAL and not turned off.
--- drivers/platform/x86/pmc_atom.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/platform/x86/pmc_atom.c +8 -0
@@ -414,6 +414,14 @@ static const struct dmi_system_id critcl }, {/* pmc_plt_clk* - are used for ethernet controllers */ + .ident = "Beckhoff CB4063", + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Beckhoff Automation" ), + DMI_MATCH(DMI_BOARD_NAME, "CB4063"), + }, + }, + { +/* pmc_plt_clk* - are used for ethernet controllers */ .ident ="Beckhoff CB6263" , .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Beckhoff Automation"),
Greg Kroah-Hartman
maintainerPATCH 83/85 platform/x86: pcengines-apuv2: use KEY_RESTART for front button
In reply to Greg Kroah-HartmanFrom: Enrico Weigelt <[email protected]>
commit f14312a93b34b9350dc33ff0b4215c24f4c82617 upstream.
The keycode KEY_RESTART is more appropriate for the front button, as most people use it for things like restart or factory reset.
--- drivers/platform/x86/pcengines-apuv2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/pcengines-apuv2.c +1 -1
@@ -93,7 +93,7 @@ struct gpiod_lookup_table gpios_led_tablstatic struct gpio_keys_button apu2_keys_buttons[] = { { - .code =KEY_SETUP , + .code =KEY_RESTART , .active_low =1 , .desc ="front button" , .type =EV_KEY ,
Greg Kroah-Hartman
maintainerPATCH 84/85 rsi: fix a double free bug in rsi_91x_deinit()
In reply to Greg Kroah-HartmanFrom: Hui Peng <[email protected]>
commit 8b51dc7291473093c821195c4b6af85fadedbc2f upstream.
dev (struct rsi_91x_usbdev *) field of adapter (struct rsi_91x_usbdev *) is allocated and initialized in rsi_init_usb_interface. If any error is detected in information read from the device side, rsi_init_usb_interface will be freed. However, in the higher level error handling code in rsi_probe, if error is detected, rsi_91x_deinit is called again, in which dev will be freed again, resulting double free.
This patch fixes the double free by removing the free operation on dev in rsi_init_usb_interface, because rsi_91x_deinit is also used in rsi_disconnect, in that code path, the dev field is not
(and thus needs to be) freed.
This bug was found in v4.19, but is also present in the latest version of kernel. Fixes CVE-2019-15504.
--- drivers/net/wireless/rsi/rsi_91x_usb.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/wireless/rsi/rsi_91x_usb.c +0 -1
@@ -645,7 +645,6 @@ fail_rx:kfree (rsi_dev->tx_buffer); fail_eps: -kfree (rsi_dev);return status; }
Greg Kroah-Hartman
maintainerPATCH 85/85 x86/build: Add -Wnoaddress-of-packed-member to REALMODE_CFLAGS, to silence GCC9 build warning
In reply to Greg Kroah-HartmanFrom: Linus Torvalds <[email protected]>
commit 42e0e95474fc6076b5cd68cab8fa0340a1797a72 upstream.
One of the very few warnings I have in the current build comes from arch/x86/boot/edd.c, where I get the following with a gcc9 build:
arch/x86/boot/edd.c: In function ‘query_edd’:
arch/x86/boot/edd.c:148:11: warning: taking address of packed member of ‘struct boot_params’ may result in an unaligned pointer value [-Waddress-of-packed-member]
148 | mbrptr = boot_params.edd_mbr_sig_buffer;
| ^~~~~~~~~~~This warning triggers because we throw away all the CFLAGS and then make a new set for REALMODE_CFLAGS, so the -Wno-address-of-packed-member we added in the following commit is not present:
6f303d60534c ("gcc-9: silence 'address-of-packed-member' warning")
The simplest solution for now is to adjust the warning for this version of CFLAGS as well, but it would definitely make sense to examine whether REALMODE_CFLAGS could be derived from CFLAGS, so that it picks up changes in the compiler flags environment automatically.
--- arch/x86/Makefile | 1 + 1 file changed, 1 insertion(+)
arch/x86/Makefile +1 -0
@@ -38,6 +38,7 @@ REALMODE_CFLAGS := $(M16_CFLAGS) -g -Os REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -ffreestanding) REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -fno-stack-protector) +REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -Wno-address-of-packed-member) REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), $(cc_stack_align4)) export REALMODE_CFLAGS
stable-rc/linux-5.2.y boot: 145 boots: 1 failed, 135 passed with 8 offline, 1 conflict (v5.2.15-86-g2f63f02ef506)
stable-rc/linux-5.2.y boot: 145 boots: 1 failed, 135 passed with 8 offline, 1 conflict (v5.2.15-86-g2f63f02ef506)
Full Boot Summary: https://kernelci.org/boot/all/job/stable-rc/branch/linux-5.2.y/kernel/v5.2.15-86-g2f63f02ef506/
Full Build Summary: https://kernelci.org/build/stable-rc/branch/linux-5.2.y/kernel/v5.2.15-86-g2f63f02ef506/
Tree: stable-rc
Branch: linux-5.2.y
Git Describe: v5.2.15-86-g2f63f02ef506
Git Commit: 2f63f02ef5061324ba168b1cb01c89fd89a0c593
Git URL: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
Tested: 82 unique boards, 28 SoC families, 17 builds out of 209
Boot Failure Detected:
arm64:
defconfig:
gcc-8:
rk3399-firefly: 1 failed lab
Offline Platforms:
arm64:
defconfig:
gcc-8
apq8016-sbc: 1 offline labarm:
multi_v7_defconfig:
gcc-8
qcom-apq8064-cm-qs600: 1 offline lab
qcom-apq8064-ifc6410: 1 offline lab
sun5i-r8-chip: 1 offline lab
davinci_all_defconfig:
gcc-8
dm365evm,legacy: 1 offline lab
qcom_defconfig:
gcc-8
qcom-apq8064-cm-qs600: 1 offline lab
qcom-apq8064-ifc6410: 1 offline lab
sunxi_defconfig:
gcc-8
sun5i-r8-chip: 1 offline labConflicting Boot Failure Detected: (These likely are not failures as other labs are reporting PASS. Needs review.)
arm:
omap2plus_defconfig:
omap4-panda:
lab-baylibre: FAIL (gcc-8)
lab-baylibre-seattle: PASS (gcc-8)
lab-collabora: PASS (gcc-8)
---
For more info write to <[email protected]>
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.2.16 release. There are 85 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri 20 Sep 2019 06:09:47 AM UTC. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.2.16-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.2.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.
Summary
------------------------------------------------------------------------
kernel: 5.2.16-rc1
git repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
git branch: linux-5.2.y
git commit: 2f63f02ef5061324ba168b1cb01c89fd89a0c593
git describe: v5.2.15-86-g2f63f02ef506
Test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-5.2-oe/build/v5.2.15-86-g2f63f02ef506
No regressions (compared to build v5.2.15)
No fixes (compared to build v5.2.15)
Ran 22511 total tests in the following environments and test suites.
Environments
--------------
- dragonboard-410c
- hi6220-hikey
- i386
- juno-r2
- qemu_arm
- qemu_arm64
- qemu_i386
- qemu_x86_64
- x15
- x86
Test Suites
-----------
* build
* install-android-platform-tools-r2600
* kselftest
* libgpiod
* libhugetlbfs
* ltp-cap_bounds-tests
* ltp-commands-tests
* ltp-containers-tests
* ltp-cpuhotplug-tests
* ltp-cve-tests
* ltp-dio-tests
* ltp-fcntl-locktests-tests
* ltp-filecaps-tests
* ltp-fs_bind-tests
* ltp-fs_perms_simple-tests
* ltp-fsx-tests
* ltp-hugetlb-tests
* ltp-io-tests
* ltp-ipc-tests
* ltp-math-tests
* ltp-mm-tests
* ltp-nptl-tests
* ltp-pty-tests
* ltp-sched-tests
* ltp-securebits-tests
* ltp-syscalls-tests
* ltp-timers-tests
* network-basic-tests
* perf
* spectre-meltdown-checker-test
* v4l2-compliance
* ltp-fs-tests
* ltp-open-posix-tests
* kvm-unit-tests
* ssuite
* kselftest-vsyscall-mode-native
* kselftest-vsyscall-mode-none
Signature · 2 lines
Linaro LKFT https://lkft.linaro.org
Greg Kroah-Hartman
maintainerQuoted 17 lines · Naresh Kamboju
Quoted 15 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.2.16 release. There are 85 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri 20 Sep 2019 06:09:47 AM UTC. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.2.16-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.2.y
and the diffstat can be found below.
Quoted 7 lines
Quoted 4 lines
thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm,x86_64, and i386.
Great, thanks for testing all of these and letting me know.
greg k-h
Jon Hunter
maintainerQuoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.2.16 release. There are 85 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri 20 Sep 2019 06:09:47 AM UTC. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.2.16-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.2.y
and the diffstat can be found below.thanks,
greg k-h
All tests are passing for Tegra ...
Test results for stable-v5.2:
12 builds: 12 pass, 0 fail
22 boots: 22 pass, 0 fail
38 tests: 38 pass, 0 failLinux version: 5.2.16-rc1-g2f63f02ef506
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,
tegra194-p2972-0000, tegra20-ventana,
tegra210-p2371-2180, tegra30-cardhu-a04Cheers
Jon
Signature · 1 line
nvpublic
Greg Kroah-Hartman
maintainerQuoted 23 lines · Jon Hunter
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.2.16 release. There are 85 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri 20 Sep 2019 06:09:47 AM UTC. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.2.16-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.2.y
and the diffstat can be found below.thanks,
greg k-h
All tests are passing for Tegra ...
Test results for stable-v5.2:
Quoted 8 lines
12 builds: 12 pass, 0 fail 22 boots: 22 pass, 0 fail 38 tests: 38 pass, 0 failLinux version: 5.2.16-rc1-g2f63f02ef506
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,tegra194-p2972-0000, tegra20-ventana, tegra210-p2371-2180, tegra30-cardhu-a04
Thanks for testing all of these and letting me know.
greg k-h
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.2.16 release. There are 85 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri 20 Sep 2019 06:09:47 AM UTC. Anything received after that time might be too late.
Build results:
total: 159 pass: 159 fail: 0 Qemu test results: total: 390 pass: 390 fail: 0
Guenter
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.2.16 release. There are 85 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri 20 Sep 2019 06:09:47 AM UTC. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.2.16-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.2.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Greg Kroah-Hartman
maintainerQuoted 15 lines · shuah
Quoted 14 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.2.16 release. There are 85 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri 20 Sep 2019 06:09:47 AM UTC. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.2.16-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.2.y
and the diffstat can be found below.
Quoted 6 lines
Quoted 4 lines
thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
Thanks for testing all of these and letting me know.
greg k-h