5.6.4-rc1 review
Subsystems (5)
Greg Kroah-Hartman
maintainercover 5.6.4-rc1 review
This is the start of the stable review cycle for the 5.6.4 release. There are 38 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 Mon, 13 Apr 2020 11:51:28 +0000. 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.6.4-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.6.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 5.6.4-rc1
Saravana Kannan <[email protected]>
driver core: Reevaluate dev->links.need_for_probe as suppliers are added
Hillf Danton <[email protected]>
io-uring: drop completion when removing file
Qiujun Huang <[email protected]>
fbcon: fix null-ptr-deref in fbcon_switch
Bart Van Assche <[email protected]>
blk-mq: Keep set->nr_hw_queues and set->map[].nr_queues in sync
Avihai Horon <[email protected]>
RDMA/cm: Update num_paths in cma_resolve_iboe_route error flow
Qiujun Huang <[email protected]>
Bluetooth: RFCOMM: fix ODEBUG bug in rfcomm_dev_ioctl
Bernard Metzler <[email protected]>
RDMA/siw: Fix passive connection establishment
Jason Gunthorpe <[email protected]>
RDMA/cma: Teach lockdep about the order of rtnl and lock
Jason Gunthorpe <[email protected]>
RDMA/ucma: Put a lock around every call to the rdma_cm layer
Hou Tao <[email protected]>
ubi: fastmap: Free unused fastmap anchor peb during detach
Alex Vesker <[email protected]>
IB/mlx5: Replace tunnel mpls capability bits for tunnel_offloads
Kaike Wan <[email protected]>
IB/hfi1: Fix memory leaks in sysfs registration and unregistration
Kaike Wan <[email protected]>
IB/hfi1: Call kobject_put() when kobject_init_and_add() fails
Paul Cercueil <[email protected]>
ASoC: jz4740-i2s: Fix divider written at incorrect offset in register
Jonghwan Choi <[email protected]>
ASoC: tas2562: Fixed incorrect amp_level setting.
Hans de Goede <[email protected]>
platform/x86: intel_int0002_vgpio: Use acpi_register_wakeup_handler()
Hans de Goede <[email protected]>
ACPI: PM: Add acpi_[un]register_wakeup_handler()
Martin Kaiser <[email protected]>
hwrng: imx-rngc - fix an error path
David Ahern <[email protected]>
tools/accounting/getdelays.c: fix netlink attribute length
Kees Cook <[email protected]>
slub: improve bit diffusion for freelist ptr obfuscation
Thinh Nguyen <[email protected]>
usb: dwc3: gadget: Wrap around when skip TRBs
Jason A. Donenfeld <[email protected]>
random: always use batched entropy for get_random_u{32,64}Sven Schnelle <[email protected]>
s390: prevent leaking kernel address in BEAR
Oleksij Rempel <[email protected]>
net: phy: at803x: fix clock sink configuration on ATH8030 and ATH8035
Rahul Lakkireddy <[email protected]>
cxgb4: free MQPRIO resources in shutdown path
Heiner Kallweit <[email protected]>
r8169: change back SG and TSO to be disabled by default
Petr Machata <[email protected]>
mlxsw: spectrum_flower: Do not stop at FLOW_ACTION_VLAN_MANGLE
Will Deacon <[email protected]>
tun: Don't put_page() for all negative return values from XDP program
Richard Palethorpe <[email protected]>
slcan: Don't transmit uninitialized stack data in padding
Jisheng Zhang <[email protected]>
net: stmmac: dwmac1000: fix out-of-bounds mac address reg setting
Cong Wang <[email protected]>
net_sched: fix a missing refcnt in tcindex_init()
Cong Wang <[email protected]>
net_sched: add a temporary refcnt for struct tcindex_data
Oleksij Rempel <[email protected]>
net: phy: micrel: kszphy_resume(): add delay after genphy_resume() before accessing PHY registers
Chuanhong Guo <[email protected]>
net: dsa: mt7530: fix null pointer dereferencing in port5 setup
Florian Fainelli <[email protected]>
net: dsa: bcm_sf2: Ensure correct sub-node is parsed
Florian Fainelli <[email protected]>
net: dsa: bcm_sf2: Do not register slave MDIO bus with OF
Jarod Wilson <[email protected]>
ipv6: don't auto-add link-local address to lag ports
Herat Ramani <[email protected]>
cxgb4: fix MPS index overwrite when setting MAC address
-------------
Diffstat:
Makefile | 4 +- arch/s390/include/asm/lowcore.h | 4 +- arch/s390/include/asm/processor.h | 1 + arch/s390/include/asm/setup.h | 7 ++ arch/s390/kernel/asm-offsets.c | 2 + arch/s390/kernel/entry.S | 65 ++++++---- arch/s390/kernel/process.c | 1 + arch/s390/kernel/setup.c | 3 + arch/s390/kernel/smp.c | 2 + arch/s390/mm/vmem.c | 4 + block/blk-mq.c | 8 ++ drivers/acpi/sleep.c | 4 + drivers/acpi/sleep.h | 1 + drivers/acpi/wakeup.c | 81 ++++++++++++ drivers/base/core.c | 8 +- drivers/char/hw_random/imx-rngc.c | 4 +- drivers/char/random.c | 20 +-- drivers/infiniband/core/cma.c | 14 +++ drivers/infiniband/core/ucma.c | 49 +++++++- drivers/infiniband/hw/hfi1/sysfs.c | 26 ++-- drivers/infiniband/hw/mlx5/main.c | 6 +- drivers/infiniband/sw/siw/siw_cm.c | 137 +++++---------------- drivers/mtd/ubi/fastmap-wl.c | 15 ++- drivers/net/can/slcan.c | 4 +- drivers/net/dsa/bcm_sf2.c | 9 +- drivers/net/dsa/mt7530.c | 3 + drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 5 +- .../net/ethernet/chelsio/cxgb4/cxgb4_tc_mqprio.c | 23 ++++ .../net/ethernet/chelsio/cxgb4/cxgb4_tc_mqprio.h | 1 + .../net/ethernet/mellanox/mlxsw/spectrum_flower.c | 9 +- drivers/net/ethernet/realtek/r8169_main.c | 34 +++-- .../net/ethernet/stmicro/stmmac/dwmac1000_core.c | 2 +- drivers/net/phy/at803x.c | 4 +- drivers/net/phy/micrel.c | 7 ++ drivers/net/tun.c | 10 +- drivers/platform/x86/intel_int0002_vgpio.c | 10 ++ drivers/usb/dwc3/gadget.c | 2 +- drivers/video/fbdev/core/fbcon.c | 3 + fs/io_uring.c | 13 +- include/linux/acpi.h | 5 + include/linux/mlx5/mlx5_ifc.h | 6 +- mm/slub.c | 2 +- net/bluetooth/rfcomm/tty.c | 4 +- net/ipv6/addrconf.c | 4 + net/sched/cls_tcindex.c | 45 ++++++- sound/soc/codecs/tas2562.c | 2 +- sound/soc/jz4740/jz4740-i2s.c | 2 +- tools/accounting/getdelays.c | 2 +- 48 files changed, 451 insertions(+), 226 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/38 cxgb4: fix MPS index overwrite when setting MAC address
From: Herat Ramani <[email protected]>
[ Upstream commit 41aa8561ca3fc5748391f08cc5f3e561923da52c ]
cxgb4_update_mac_filt() earlier requests firmware to add a new MAC address into MPS TCAM. The MPS TCAM index returned by firmware is stored in pi->xact_addr_filt. However, the saved MPS TCAM index gets overwritten again with the return value of cxgb4_update_mac_filt(), which is wrong.
When trying to update to another MAC address later, the wrong MPS TCAM index is sent to firmware, which causes firmware to return error, because it's not the same MPS TCAM index that firmware had sent earlier to driver.
So, fix by removing the wrong overwrite being done after call to cxgb4_update_mac_filt().
--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +0 -1
@@ -3138,7 +3138,6 @@ static int cxgb_set_mac_addr(struct net_return ret;memcpy (dev->dev_addr, addr->sa_data, dev->addr_len); - pi->xact_addr_filt = ret;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 2/38 ipv6: dont auto-add link-local address to lag ports
In reply to Greg Kroah-HartmanFrom: Jarod Wilson <[email protected]>
[ Upstream commit 744fdc8233f6aa9582ce08a51ca06e59796a3196 ]
Bonding slave and team port devices should not have link-local addresses automatically added to them, as it can interfere with openvswitch being able to properly add tc ingress.
Basic reproducer, courtesy of Marcelo:
$ ip link add name bond0 type bond
$ ip link set dev ens2f0np0 master bond0
$ ip link set dev ens2f1np2 master bond0
$ ip link set dev bond0 up
$ ip a s
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens2f0np0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc
mq master bond0 state UP group default qlen 1000
link/ether 00:0f:53:2f:ea:40 brd ff:ff:ff:ff:ff:ff
5: ens2f1np2: <NO-CARRIER,BROADCAST,MULTICAST,SLAVE,UP> mtu 1500 qdisc
mq master bond0 state DOWN group default qlen 1000
link/ether 00:0f:53:2f:ea:40 brd ff:ff:ff:ff:ff:ff
11: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc
noqueue state UP group default qlen 1000
link/ether 00:0f:53:2f:ea:40 brd ff:ff:ff:ff:ff:ff
inet6 fe80::20f:53ff:fe2f:ea40/64 scope link
valid_lft forever preferred_lft forever(above trimmed to relevant entries, obviously)
$ sysctl net.ipv6.conf.ens2f0np0.addr_gen_mode=0 net.ipv6.conf.ens2f0np0.addr_gen_mode = 0 $ sysctl net.ipv6.conf.ens2f1np2.addr_gen_mode=0 net.ipv6.conf.ens2f1np2.addr_gen_mode = 0
$ ip a l ens2f0np0
2: ens2f0np0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc
mq master bond0 state UP group default qlen 1000
link/ether 00:0f:53:2f:ea:40 brd ff:ff:ff:ff:ff:ff
inet6 fe80::20f:53ff:fe2f:ea40/64 scope link tentative
valid_lft forever preferred_lft forever
$ ip a l ens2f1np2
5: ens2f1np2: <NO-CARRIER,BROADCAST,MULTICAST,SLAVE,UP> mtu 1500 qdisc
mq master bond0 state DOWN group default qlen 1000
link/ether 00:0f:53:2f:ea:40 brd ff:ff:ff:ff:ff:ff
inet6 fe80::20f:53ff:fe2f:ea40/64 scope link tentative
valid_lft forever preferred_lft foreverLooks like addrconf_sysctl_addr_gen_mode() bypasses the original "is this a slave interface?" check added by commit c2edacf80e15, and results in an address getting added, while w/the proposed patch added, no address gets added. This simply adds the same gating check to another code path, and thus should prevent the same devices from erroneously obtaining an ipv6 link-local address.
--- net/ipv6/addrconf.c | 4 ++++ 1 file changed, 4 insertions(+)
net/ipv6/addrconf.c +4 -0
@@ -3296,6 +3296,10 @@ static void addrconf_addr_gen(struct ineif (netif_is_l3_master (idev->dev))return ; +/* no link local addresses on devices flagged as slaves */ +if (idev->dev->flags &IFF_SLAVE ) +return ; +ipv6_addr_set (&addr,htonl (0xFE800000 ),0 ,0 ,0 );switch (idev->cnf.addr_gen_mode) {
Greg Kroah-Hartman
maintainerPATCH 3/38 net: dsa: bcm_sf2: Do not register slave MDIO bus with OF
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
[ Upstream commit 536fab5bf5826404534a6c271f622ad2930d9119 ]
We were registering our slave MDIO bus with OF and doing so with assigning the newly created slave_mii_bus of_node to the master MDIO bus controller node. This is a bad thing to do for a number of reasons:
- we are completely lying about the slave MII bus is arranged and yet we still want to control which MDIO devices it probes. It was attempted before to play tricks with the bus_mask to perform that:
https://www.spinics.net/lists/netdev/msg429420.html but the approach was rightfully rejected
- the device_node reference counting is messed up and we are effectively doing a double probe on the devices we already probed using the master, this messes up all resources reference counts (such as clocks)
The proper fix for this as indicated by David in his reply to the thread above is to use a platform data style registration so as to control exactly which devices we probe:
https://www.spinics.net/lists/netdev/msg430083.html
By using mdiobus_register(), our slave_mii_bus->phy_mask value is used as intended, and all the PHY addresses that must be redirected towards our slave MDIO bus is happening while other addresses get redirected towards the master MDIO bus.
--- drivers/net/dsa/bcm_sf2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/bcm_sf2.c +1 -1
@@ -472,7 +472,7 @@ static int bcm_sf2_mdio_register(struct priv->slave_mii_bus->parent = ds->dev->parent; priv->slave_mii_bus->phy_mask = ~priv->indir_phy_mask; - err =of_mdiobus_register (priv->slave_mii_bus, dn); + err =mdiobus_register (priv->slave_mii_bus);if (err && dn)of_node_put (dn);
Greg Kroah-Hartman
maintainerPATCH 4/38 net: dsa: bcm_sf2: Ensure correct sub-node is parsed
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
[ Upstream commit afa3b592953bfaecfb4f2f335ec5f935cff56804 ]
When the bcm_sf2 was converted into a proper platform device driver and used the new dsa_register_switch() interface, we would still be parsing the legacy DSA node that contained all the port information since the platform firmware has intentionally maintained backward and forward compatibility to client programs. Ensure that we do parse the correct node, which is "ports" per the revised DSA binding.
--- drivers/net/dsa/bcm_sf2.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/dsa/bcm_sf2.c +6 -1
@@ -1069,6 +1069,7 @@ static int bcm_sf2_sw_probe(struct platfconst struct bcm_sf2_of_data *data;struct b53_platform_data *pdata;struct dsa_switch_ops *ops; +struct device_node *ports;struct bcm_sf2_priv *priv;struct b53_device *dev;struct dsa_switch *ds;
@@ -1136,7 +1137,11 @@ static int bcm_sf2_sw_probe(struct platfset_bit (0 , priv->cfp.used);set_bit (0 , priv->cfp.unique); -bcm_sf2_identify_ports (priv, dn->child); + ports =of_find_node_by_name (dn,"ports" ); +if (ports) { +bcm_sf2_identify_ports (priv, ports); +of_node_put (ports); + } priv->irq0 =irq_of_parse_and_map (dn,0 ); priv->irq1 =irq_of_parse_and_map (dn,1 );
Greg Kroah-Hartman
maintainerPATCH 5/38 net: dsa: mt7530: fix null pointer dereferencing in port5 setup
In reply to Greg Kroah-HartmanFrom: Chuanhong Guo <[email protected]>
[ Upstream commit 0452800f6db4ed0a42ffb15867c0acfd68829f6a ]
The 2nd gmac of mediatek soc ethernet may not be connected to a PHY and a phy-handle isn't always available.
Unfortunately, mt7530 dsa driver assumes that the 2nd gmac is always connected to switch port 5 and setup mt7530 according to phy address of 2nd gmac node, causing null pointer dereferencing when phy-handle isn't defined in dts.
This commit fix this setup code by checking return value of of_parse_phandle before using it.
--- drivers/net/dsa/mt7530.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/dsa/mt7530.c +3 -0
@@ -1356,6 +1356,9 @@ mt7530_setup(struct dsa_switch *ds)continue ; phy_node =of_parse_phandle (mac_np,"phy-handle" ,0 ); +if (!phy_node) +continue ; +if (phy_node->parent == priv->dev->of_node->parent) { ret =of_get_phy_mode (mac_np, &interface);if (ret && ret != -ENODEV )
Greg Kroah-Hartman
maintainerPATCH 6/38 net: phy: micrel: kszphy_resume(): add delay after genphy_resume() before accessing PHY registers
In reply to Greg Kroah-HartmanFrom: Oleksij Rempel <[email protected]>
[ Upstream commit 6110dff776f7fa65c35850ef65b41d3b39e2fac2 ]
After the power-down bit is cleared, the chip internally triggers a global reset. According to the KSZ9031 documentation, we have to wait at least 1ms for the reset to finish.
If the chip is accessed during reset, read will return 0xffff, while write will be ignored. Depending on the system performance and MDIO bus speed, we may or may not run in to this issue.
This bug was discovered on an iMX6QP system with KSZ9031 PHY and attached PHY interrupt line. If IRQ was used, the link status update was lost. In polling mode, the link status update was always correct.
The investigation showed, that during a read-modify-write access, the read returned 0xffff (while the chip was still in reset) and corresponding write hit the chip _after_ reset and triggered (due to the 0xffff) another reset in an undocumented bit (register 0x1f, bit 1), resulting in the next write being lost due to the new reset cycle.
This patch fixes the issue by adding a 1...2 ms sleep after the genphy_resume().
--- drivers/net/phy/micrel.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/phy/micrel.c +7 -0
@@ -25,6 +25,7 @@#include <linux/micrel_phy.h> #include <linux/of.h> #include <linux/clk.h> +#include <linux/delay.h> /* Operation Mode Strap Override */ #define MII_KSZPHY_OMSO 0x16
@@ -902,6 +903,12 @@ static int kszphy_resume(struct phy_devigenphy_resume (phydev); +/* After switching from power-down to normal mode, an internal global +* reset is automatically generated. Wait a minimum of 1 ms before +* read/write access to the PHY registers. +*/ +usleep_range (1000 ,2000 ); + ret =kszphy_config_reset (phydev);if (ret)return ret;
Greg Kroah-Hartman
maintainerPATCH 7/38 net_sched: add a temporary refcnt for struct tcindex_data
In reply to Greg Kroah-HartmanFrom: Cong Wang <[email protected]>
[ Upstream commit 304e024216a802a7dc8ba75d36de82fa136bbf3e ]
Although we intentionally use an ordered workqueue for all tc filter works, the ordering is not guaranteed by RCU work, given that tcf_queue_work() is esstenially a call_rcu().
This problem is demostrated by Thomas:
CPU 0:
tcf_queue_work()
tcf_queue_work(&r->rwork, tcindex_destroy_rexts_work);-> Migration to CPU 1
CPU 1:
tcf_queue_work(&p->rwork, tcindex_destroy_work);so the 2nd work could be queued before the 1st one, which leads to a free-after-free.
Enforcing this order in RCU work is hard as it requires to change RCU code too. Fortunately we can workaround this problem in tcindex filter by taking a temporary refcnt, we only refcnt it right before we begin to destroy it. This simplifies the code a lot as a full refcnt requires much more changes in tcindex_set_parms().
--- net/sched/cls_tcindex.c | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-)
net/sched/cls_tcindex.c +38 -6
@@ -11,6 +11,7 @@#include <linux/skbuff.h> #include <linux/errno.h> #include <linux/slab.h> +#include <linux/refcount.h> #include <net/act_api.h> #include <net/netlink.h> #include <net/pkt_cls.h>
@@ -26,9 +27,12 @@#define DEFAULT_HASH_SIZE 64/* optimized for diffserv */ +struct tcindex_data ; +struct tcindex_filter_result {struct tcf_exts exts;struct tcf_result res; +struct tcindex_data *p;struct rcu_work rwork; };
@@ -49,6 +53,7 @@ struct tcindex_data {u32 hash;/* hash table size; 0 if undefined */ u32 alloc_hash;/* allocated size */ u32 fall_through;/* 0: only classify if explicit match */ +refcount_t refcnt;/* a temporary refcnt for perfect hash */ struct rcu_work rwork; };
@@ -57,6 +62,20 @@ static inline int tcindex_filter_is_set(return tcf_exts_has_actions (&r->exts) || r->res.classid; } +static void tcindex_data_get (struct tcindex_data *p) +{ +refcount_inc (&p->refcnt); +} + +static void tcindex_data_put (struct tcindex_data *p) +{ +if (refcount_dec_and_test (&p->refcnt)) { +kfree (p->perfect); +kfree (p->h); +kfree (p); + } +} +static struct tcindex_filter_result *tcindex_lookup (struct tcindex_data *p,u16 key) {
@@ -141,6 +160,7 @@ static void __tcindex_destroy_rexts(stru {tcf_exts_destroy (&r->exts);tcf_exts_put_net (&r->exts); +tcindex_data_put (r->p); }static void tcindex_destroy_rexts_work (struct work_struct *work)
@@ -212,6 +232,8 @@ found:else __tcindex_destroy_fexts (f); }else { +tcindex_data_get (p); +if (tcf_exts_get_net (&r->exts))tcf_queue_work (&r->rwork, tcindex_destroy_rexts_work);else
@@ -228,9 +250,7 @@ static void tcindex_destroy_work(struct struct tcindex_data, rwork); -kfree (p->perfect); -kfree (p->h); -kfree (p); +tcindex_data_put (p); } static inline int
@@ -248,9 +268,11 @@ static const struct nla_policy tcindex_p };static int tcindex_filter_result_init (struct tcindex_filter_result *r, +struct tcindex_data *p,struct net *net) {memset (r,0 ,sizeof (*r)); + r->p = p;return tcf_exts_init (&r->exts, net,TCA_TCINDEX_ACT ,TCA_TCINDEX_POLICE ); }
@@ -290,6 +312,7 @@ static int tcindex_alloc_perfect_hash(st TCA_TCINDEX_ACT, TCA_TCINDEX_POLICE);if (err <0 ) goto errout; + cp->perfect[i].p = cp; }return 0 ;
@@ -334,6 +357,7 @@ tcindex_set_parms(struct net *net, struc cp->alloc_hash = p->alloc_hash; cp->fall_through = p->fall_through; cp->tp = tp; +refcount_set (&cp->refcnt,1 );/* Paired with tcindex_destroy_work() */ if (tb[TCA_TCINDEX_HASH ]) cp->hash =nla_get_u32 (tb[TCA_TCINDEX_HASH ]);
@@ -366,7 +390,7 @@ tcindex_set_parms(struct net *net, struc } cp->h = p->h; - err =tcindex_filter_result_init (&new_filter_result, net); + err =tcindex_filter_result_init (&new_filter_result, cp, net);if (err <0 ) goto errout_alloc;if (old_r)
@@ -434,7 +458,7 @@ tcindex_set_parms(struct net *net, struc goto errout_alloc; f->key = handle; f->next =NULL ; - err =tcindex_filter_result_init (&f->result, net); + err =tcindex_filter_result_init (&f->result, cp, net);if (err <0 ) {kfree (f); goto errout_alloc;
@@ -447,7 +471,7 @@ tcindex_set_parms(struct net *net, struc }if (old_r && old_r != r) { - err =tcindex_filter_result_init (old_r, net); + err =tcindex_filter_result_init (old_r, cp, net);if (err <0 ) {kfree (f); goto errout_alloc;
@@ -571,6 +595,14 @@ static void tcindex_destroy(struct tcf_pfor (i =0 ; i < p->hash; i++) {struct tcindex_filter_result *r = p->perfect + i; +/* tcf_queue_work() does not guarantee the ordering we +* want, so we have to take this refcnt temporarily to +* ensure 'p' is freed after all tcindex_filter_result +* here. Imperfect hash does not need this, because it +* uses linked lists rather than an array. +*/ +tcindex_data_get (p); +tcf_unbind_filter (tp, &r->res);if (tcf_exts_get_net (&r->exts)) tcf_queue_work(&r->rwork,
Greg Kroah-Hartman
maintainerPATCH 8/38 net_sched: fix a missing refcnt in tcindex_init()
In reply to Greg Kroah-HartmanFrom: Cong Wang <[email protected]>
[ Upstream commit a8eab6d35e22f4f21471f16147be79529cd6aaf7 ]
The initial refcnt of struct tcindex_data should be 1, it is clear that I forgot to set it to 1 in tcindex_init(). This leads to a dec-after-zero warning.
--- net/sched/cls_tcindex.c | 1 + 1 file changed, 1 insertion(+)
net/sched/cls_tcindex.c +1 -0
@@ -151,6 +151,7 @@ static int tcindex_init(struct tcf_proto p->mask =0xffff ; p->hash =DEFAULT_HASH_SIZE ; p->fall_through =1 ; +refcount_set (&p->refcnt,1 );/* Paired with tcindex_destroy_work() */ rcu_assign_pointer (tp->root, p);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 9/38 net: stmmac: dwmac1000: fix out-of-bounds mac address reg setting
In reply to Greg Kroah-HartmanFrom: Jisheng Zhang <[email protected]>
[ Upstream commit 3e1221acf6a8f8595b5ce354bab4327a69d54d18 ]
Commit 9463c4455900 ("net: stmmac: dwmac1000: Clear unused address entries") cleared the unused mac address entries, but introduced an out-of bounds mac address register programming bug -- After setting the secondary unicast mac addresses, the "reg" value has reached netdev_uc_count() + 1, thus we should only clear address entries if (addr < perfect_addr_number)
--- drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +1 -1
@@ -207,7 +207,7 @@ static void dwmac1000_set_filter(struct reg++; } -while (reg <= perfect_addr_number) { +while (reg < perfect_addr_number) {writel (0 , ioaddr +GMAC_ADDR_HIGH (reg));writel (0 , ioaddr +GMAC_ADDR_LOW (reg)); reg++;
Greg Kroah-Hartman
maintainerPATCH 10/38 slcan: Dont transmit uninitialized stack data in padding
In reply to Greg Kroah-HartmanFrom: Richard Palethorpe <[email protected]>
[ Upstream commit b9258a2cece4ec1f020715fe3554bc2e360f6264 ]
struct can_frame contains some padding which is not explicitly zeroed in slc_bump. This uninitialized data will then be transmitted if the stack initialization hardening feature is not enabled (CONFIG_INIT_STACK_ALL).
This commit just zeroes the whole struct including the padding.
--- drivers/net/can/slcan.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/can/slcan.c +1 -3
@@ -148,7 +148,7 @@ static void slc_bump(struct slcan *sl)u32 tmpid;char *cmd = sl->rbuff; - cf.can_id =0 ; +memset (&cf,0 ,sizeof (cf));switch (*cmd) {case 'r' :
@@ -187,8 +187,6 @@ static void slc_bump(struct slcan *sl)else return ; - *(u64 *) (&cf.data) =0 ;/* clear payload */ -/* RTR frames may have a dlc > 0 but they never have any data bytes */ if (!(cf.can_id &CAN_RTR_FLAG )) {for (i =0 ; i < cf.can_dlc; i++) {
Greg Kroah-Hartman
maintainerPATCH 11/38 tun: Dont put_page() for all negative return values from XDP program
In reply to Greg Kroah-HartmanFrom: Will Deacon <[email protected]>
[ Upstream commit bee348907d19d654e8524d3a946dcd25b693aa7e ]
When an XDP program is installed, tun_build_skb() grabs a reference to the current page fragment page if the program returns XDP_REDIRECT or XDP_TX. However, since tun_xdp_act() passes through negative return values from the XDP program, it is possible to trigger the error path by mistake and accidentally drop a reference to the fragments page without taking one, leading to a spurious free. This is believed to be the cause of some KASAN use-after-free reports from syzbot [1], although without a reproducer it is not possible to confirm whether this patch fixes the problem.
Ensure that we only drop a reference to the fragments page if the XDP transmit or redirect operations actually fail.
[1] https://syzkaller.appspot.com/bug?id=e76a6af1be4acd727ff6bbca669833f98cbf5d95
--- drivers/net/tun.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/tun.c +6 -4
@@ -1715,8 +1715,12 @@ static struct sk_buff *tun_build_skb(str alloc_frag->offset += buflen; } err =tun_xdp_act (tun, xdp_prog, &xdp, act); -if (err <0 ) - goto err_xdp; +if (err <0 ) { +if (act ==XDP_REDIRECT || act ==XDP_TX ) +put_page (alloc_frag->page); + goto out; + } +if (err ==XDP_REDIRECT )xdp_do_flush ();if (err !=XDP_PASS )
@@ -1730,8 +1734,6 @@ static struct sk_buff *tun_build_skb(strreturn __tun_build_skb (tfile, alloc_frag, buf, buflen, len, pad); -err_xdp: -put_page (alloc_frag->page); out:rcu_read_unlock ();local_bh_enable ();
Greg Kroah-Hartman
maintainerPATCH 12/38 mlxsw: spectrum_flower: Do not stop at FLOW_ACTION_VLAN_MANGLE
In reply to Greg Kroah-HartmanFrom: Petr Machata <[email protected]>
[ Upstream commit ccfc569347f870830e7c7cf854679a06cf9c45b5 ]
The handler for FLOW_ACTION_VLAN_MANGLE ends by returning whatever the lower-level function that it calls returns. If there are more actions lined up after this action, those are never offloaded. Fix by only bailing out when the called function returns an error.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c +6 -3
@@ -123,9 +123,12 @@ static int mlxsw_sp_flower_parse_actionsu8 prio = act->vlan.prio;u16 vid = act->vlan.vid; -return mlxsw_sp_acl_rulei_act_vlan (mlxsw_sp, rulei, - act->id, vid, - proto, prio, extack); + err =mlxsw_sp_acl_rulei_act_vlan (mlxsw_sp, rulei, + act->id, vid, + proto, prio, extack); +if (err) +return err; +break ; }default :NL_SET_ERR_MSG_MOD (extack,"Unsupported action" );
Greg Kroah-Hartman
maintainerPATCH 13/38 r8169: change back SG and TSO to be disabled by default
In reply to Greg Kroah-HartmanFrom: Heiner Kallweit <[email protected]>
[ Upstream commit 95099c569a9fdbe186a27447dfa8a5a0562d4b7f ]
There has been a number of reports that using SG/TSO on different chip versions results in tx timeouts. However for a lot of people SG/TSO works fine. Therefore disable both features by default, but allow users to enable them. Use at own risk!
--- drivers/net/ethernet/realtek/r8169_main.c | 34 ++++++++++++++---------------- 1 file changed, 16 insertions(+), 18 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +16 -18
@@ -5549,12 +5549,10 @@ static int rtl_init_one(struct pci_dev *netif_napi_add (dev, &tp->napi, rtl8169_poll,NAPI_POLL_WEIGHT ); - dev->features |=NETIF_F_SG |NETIF_F_IP_CSUM |NETIF_F_TSO | -NETIF_F_RXCSUM |NETIF_F_HW_VLAN_CTAG_TX | -NETIF_F_HW_VLAN_CTAG_RX ; - dev->hw_features =NETIF_F_SG |NETIF_F_IP_CSUM |NETIF_F_TSO | -NETIF_F_RXCSUM |NETIF_F_HW_VLAN_CTAG_TX | -NETIF_F_HW_VLAN_CTAG_RX ; + dev->features |=NETIF_F_IP_CSUM |NETIF_F_RXCSUM | +NETIF_F_HW_VLAN_CTAG_TX |NETIF_F_HW_VLAN_CTAG_RX ; + dev->hw_features =NETIF_F_IP_CSUM |NETIF_F_RXCSUM | +NETIF_F_HW_VLAN_CTAG_TX |NETIF_F_HW_VLAN_CTAG_RX ; dev->vlan_features =NETIF_F_SG |NETIF_F_IP_CSUM |NETIF_F_TSO |NETIF_F_HIGHDMA ; dev->priv_flags |=IFF_LIVE_ADDR_CHANGE ;
@@ -5572,25 +5570,25 @@ static int rtl_init_one(struct pci_dev * dev->hw_features &= ~NETIF_F_HW_VLAN_CTAG_RX ;if (rtl_chip_supports_csum_v2 (tp)) { - dev->hw_features |=NETIF_F_IPV6_CSUM |NETIF_F_TSO6 ; - dev->features |=NETIF_F_IPV6_CSUM |NETIF_F_TSO6 ; + dev->hw_features |=NETIF_F_IPV6_CSUM ; + dev->features |=NETIF_F_IPV6_CSUM ; + } + +/* There has been a number of reports that using SG/TSO results in +* tx timeouts. However for a lot of people SG/TSO works fine. +* Therefore disable both features by default, but allow users to +* enable them. Use at own risk! +*/ +if (rtl_chip_supports_csum_v2 (tp)) { + dev->hw_features |=NETIF_F_SG |NETIF_F_TSO |NETIF_F_TSO6 ; dev->gso_max_size =RTL_GSO_MAX_SIZE_V2 ; dev->gso_max_segs =RTL_GSO_MAX_SEGS_V2 ; }else { + dev->hw_features |=NETIF_F_SG |NETIF_F_TSO ; dev->gso_max_size =RTL_GSO_MAX_SIZE_V1 ; dev->gso_max_segs =RTL_GSO_MAX_SEGS_V1 ; } -/* RTL8168e-vl and one RTL8168c variant are known to have a -* HW issue with TSO. -*/ -if (tp->mac_version ==RTL_GIGA_MAC_VER_34 || - tp->mac_version ==RTL_GIGA_MAC_VER_22 ) { - dev->vlan_features &= ~(NETIF_F_ALL_TSO |NETIF_F_SG ); - dev->hw_features &= ~(NETIF_F_ALL_TSO |NETIF_F_SG ); - dev->features &= ~(NETIF_F_ALL_TSO |NETIF_F_SG ); - } - dev->hw_features |=NETIF_F_RXALL ; dev->hw_features |=NETIF_F_RXFCS ;
Greg Kroah-Hartman
maintainerPATCH 14/38 cxgb4: free MQPRIO resources in shutdown path
In reply to Greg Kroah-HartmanFrom: Rahul Lakkireddy <[email protected]>
[ Upstream commit cef8dac96bc108633f5090bb3a9988d734dc1ee0 ]
Perform missing MQPRIO resource cleanup in PCI shutdown path. Also, fix MQPRIO MSIX bitmap leak in resource cleanup.
--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 4 +++ drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_mqprio.c | 23 +++++++++++++++++++ drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_mqprio.h | 1 3 files changed, 28 insertions(+)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +4 -0
@@ -6681,6 +6681,10 @@ static void shutdown_one(struct pci_devif (adapter->port[i]->reg_state ==NETREG_REGISTERED )cxgb_close (adapter->port[i]); +rtnl_lock (); +cxgb4_mqprio_stop_offload (adapter); +rtnl_unlock (); +if (is_uld (adapter)) {detach_ulds (adapter);t4_uld_clean_up (adapter);
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_mqprio.c +23 -0
@@ -301,6 +301,7 @@ static void cxgb4_mqprio_free_hw_resourccxgb4_clear_msix_aff (eorxq->msix->vec, eorxq->msix->aff_mask);free_irq (eorxq->msix->vec, &eorxq->rspq); +cxgb4_free_msix_idx_in_bmap (adap, eorxq->msix->idx); }free_rspq_fl (adap, &eorxq->rspq, &eorxq->fl);
@@ -611,6 +612,28 @@ out:return ret; } +void cxgb4_mqprio_stop_offload (struct adapter *adap) +{ +struct cxgb4_tc_port_mqprio *tc_port_mqprio; +struct net_device *dev; +u8 i; + +if (!adap->tc_mqprio || !adap->tc_mqprio->port_mqprio) +return ; + +for_each_port (adap, i) { + dev = adap->port[i]; +if (!dev) +continue ; + + tc_port_mqprio = &adap->tc_mqprio->port_mqprio[i]; +if (!tc_port_mqprio->mqprio.qopt.num_tc) +continue ; + +cxgb4_mqprio_disable_offload (dev); + } +} +int cxgb4_init_tc_mqprio (struct adapter *adap) {struct cxgb4_tc_port_mqprio *tc_port_mqprio, *port_mqprio;
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_mqprio.h +1 -0
@@ -38,6 +38,7 @@ struct cxgb4_tc_mqprio {int cxgb4_setup_tc_mqprio (struct net_device *dev,struct tc_mqprio_qopt_offload *mqprio); +void cxgb4_mqprio_stop_offload (struct adapter *adap);int cxgb4_init_tc_mqprio (struct adapter *adap);void cxgb4_cleanup_tc_mqprio (struct adapter *adap);#endif /* __CXGB4_TC_MQPRIO_H__ */
Greg Kroah-Hartman
maintainerPATCH 15/38 net: phy: at803x: fix clock sink configuration on ATH8030 and ATH8035
In reply to Greg Kroah-HartmanFrom: Oleksij Rempel <[email protected]>
[ Upstream commit b1f4c209d84057b6d40b939b6e4404854271d797 ]
The masks in priv->clk_25m_reg and priv->clk_25m_mask are one-bits-set for the values that comprise the fields, not zero-bits-set.
This patch fixes the clock frequency configuration for ATH8030 and ATH8035 Atheros PHYs by removing the erroneous "~".
To reproduce this bug, configure the PHY with the device tree binding "qca,clk-out-frequency" and remove the machine specific PHY fixups.
--- drivers/net/phy/at803x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/phy/at803x.c +2 -2
@@ -425,8 +425,8 @@ static int at803x_parse_dt(struct phy_de*/ if (at803x_match_phy_id (phydev,ATH8030_PHY_ID ) ||at803x_match_phy_id (phydev,ATH8035_PHY_ID )) { - priv->clk_25m_reg &= ~AT8035_CLK_OUT_MASK ; - priv->clk_25m_mask &= ~AT8035_CLK_OUT_MASK ; + priv->clk_25m_reg &=AT8035_CLK_OUT_MASK ; + priv->clk_25m_mask &=AT8035_CLK_OUT_MASK ; } }
Greg Kroah-Hartman
maintainerPATCH 16/38 s390: prevent leaking kernel address in BEAR
In reply to Greg Kroah-HartmanFrom: Sven Schnelle <[email protected]>
commit 0b38b5e1d0e2f361e418e05c179db05bb688bbd6 upstream.
When userspace executes a syscall or gets interrupted, BEAR contains a kernel address when returning to userspace. This make it pretty easy to figure out where the kernel is mapped even with KASLR enabled. To fix this, add lpswe to lowcore and always execute it there, so userspace sees only the lowcore address of lpswe. For this we have to extend both critical_cleanup and the SWITCH_ASYNC macro to also check for lpswe addresses in lowcore.
--- arch/s390/include/asm/lowcore.h | 4 +- arch/s390/include/asm/processor.h | 1 arch/s390/include/asm/setup.h | 7 ++++ arch/s390/kernel/asm-offsets.c | 2 + arch/s390/kernel/entry.S | 65 ++++++++++++++++++++++---------------- arch/s390/kernel/process.c | 1 arch/s390/kernel/setup.c | 3 + arch/s390/kernel/smp.c | 2 + arch/s390/mm/vmem.c | 4 ++ 9 files changed, 62 insertions(+), 27 deletions(-)
arch/s390/include/asm/lowcore.h +3 -1
@@ -141,7 +141,9 @@ struct lowcore {/* br %r1 trampoline */ __u16 br_r1_trampoline;/* 0x0400 */ -__u8 pad_0x0402[0x0e00 -0x0402 ];/* 0x0402 */ +__u32 return_lpswe;/* 0x0402 */ +__u32 return_mcck_lpswe;/* 0x0406 */ +__u8 pad_0x040a[0x0e00 -0x040a ];/* 0x040a */ /* * 0xe00 contains the address of the IPL Parameter Information
arch/s390/include/asm/processor.h +1 -0
@@ -161,6 +161,7 @@ typedef struct thread_struct thread_stru#define INIT_THREAD { \ .ksp = sizeof(init_stack) + (unsigned long) &init_stack, \ .fpu.regs = (void *) init_task.thread.fpu.fprs, \ + .last_break = 1, \ }/*
arch/s390/include/asm/setup.h +7 -0
@@ -8,6 +8,7 @@#include <linux/bits.h> #include <uapi/asm/setup.h> +#include <linux/build_bug.h> #define EP_OFFSET 0x10008#define EP_STRING "S390EP"
@@ -162,6 +163,12 @@ static inline unsigned long kaslr_offset return __kaslr_offset; } +static inline u32 gen_lpswe (unsigned long addr) +{ +BUILD_BUG_ON (addr >0xfff ); +return 0xb2b20000 | addr; +} +#else /* __ASSEMBLY__ */ #define IPL_DEVICE (IPL_DEVICE_OFFSET)
arch/s390/kernel/asm-offsets.c +2 -0
@@ -124,6 +124,8 @@ int main(void)OFFSET (__LC_EXT_DAMAGE_CODE, lowcore, external_damage_code);OFFSET (__LC_MCCK_FAIL_STOR_ADDR, lowcore, failing_storage_address);OFFSET (__LC_LAST_BREAK, lowcore, breaking_event_addr); +OFFSET (__LC_RETURN_LPSWE, lowcore, return_lpswe); +OFFSET (__LC_RETURN_MCCK_LPSWE, lowcore, return_mcck_lpswe);OFFSET (__LC_RST_OLD_PSW, lowcore, restart_old_psw);OFFSET (__LC_EXT_OLD_PSW, lowcore, external_old_psw);OFFSET (__LC_SVC_OLD_PSW, lowcore, svc_old_psw);
arch/s390/kernel/entry.S +39 -26
155 lines not on this page · raw message
arch/s390/kernel/process.c +1 -0
@@ -106,6 +106,7 @@ int copy_thread_tls(unsigned long clone_ p->thread.system_timer =0 ; p->thread.hardirq_timer =0 ; p->thread.softirq_timer =0 ; + p->thread.last_break =1 ; frame->sf.back_chain =0 ;/* new return point is ret_from_fork */
arch/s390/kernel/setup.c +3 -0
@@ -73,6 +73,7 @@#include <asm/nospec-branch.h> #include <asm/mem_detect.h> #include <asm/uv.h> +#include <asm/asm-offsets.h> #include "entry.h" /*
@@ -450,6 +451,8 @@ static void __init setup_lowcore_dat_off lc->spinlock_index =0 ;arch_spin_lock_setup (0 ); lc->br_r1_trampoline =0x07f1 ;/* br %r1 */ + lc->return_lpswe =gen_lpswe (__LC_RETURN_PSW); + lc->return_mcck_lpswe =gen_lpswe (__LC_RETURN_MCCK_PSW);set_prefix ((u32 )(unsigned long ) lc); lowcore_ptr[0 ] = lc;
arch/s390/kernel/smp.c +2 -0
@@ -212,6 +212,8 @@ static int pcpu_alloc_lowcore(struct pcp lc->spinlock_lockval =arch_spin_lockval (cpu); lc->spinlock_index =0 ; lc->br_r1_trampoline =0x07f1 ;/* br %r1 */ + lc->return_lpswe =gen_lpswe (__LC_RETURN_PSW); + lc->return_mcck_lpswe =gen_lpswe (__LC_RETURN_MCCK_PSW);if (nmi_alloc_per_cpu (lc)) goto out_async;if (vdso_alloc_per_cpu (lc))
arch/s390/mm/vmem.c +4 -0
@@ -415,6 +415,10 @@ void __init vmem_map_init(void) SET_MEMORY_RO | SET_MEMORY_X);__set_memory (__stext_dma, (__etext_dma - __stext_dma) >>PAGE_SHIFT ,SET_MEMORY_RO |SET_MEMORY_X ); + +/* we need lowcore executable for our LPSWE instructions */ +set_memory_x (0 ,1 ); +pr_info ("Write protected kernel read-only data: %luk\n" , (unsigned long )(__end_rodata - _stext) >>10 ); }
Greg Kroah-Hartman
maintainerPATCH 17/38 random: always use batched entropy for get_random_u{32,64}
In reply to Greg Kroah-HartmanFrom: Jason A. Donenfeld <[email protected]>
commit 69efea712f5b0489e67d07565aad5c94e09a3e52 upstream.
It turns out that RDRAND is pretty slow. Comparing these two constructions:
for (i = 0; i < CHACHA_BLOCK_SIZE; i += sizeof(ret))
arch_get_random_long(&ret);and
long buf[CHACHA_BLOCK_SIZE / sizeof(long)]; extract_crng((u8 *)buf);
it amortizes out to 352 cycles per long for the top one and 107 cycles per long for the bottom one, on Coffee Lake Refresh, Intel Core i9-9880H.
And importantly, the top one has the drawback of not benefiting from the real rng, whereas the bottom one has all the nice benefits of using our own chacha rng. As get_random_u{32,64} gets used in more places (perhaps beyond what it was originally intended for when it was introduced as get_random_{int,long} back in the md5 monstrosity era), it seems like it might be a good thing to strengthen its posture a tiny bit. Doing this should only be stronger and not any weaker because that pool is already initialized with a bunch of rdrand data (when available). This way, we get the benefits of the hardware rng as well as our own rng.
Another benefit of this is that we no longer hit pitfalls of the recent stream of AMD bugs in RDRAND. One often used code pattern for various things is:
do {
val = get_random_u32();
} while (hash_table_contains_key(val));That recent AMD bug rendered that pattern useless, whereas we're really very certain that chacha20 output will give pretty distributed numbers, no matter what.
So, this simplification seems better both from a security perspective and from a performance perspective.
--- drivers/char/random.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)
drivers/char/random.c +4 -16
@@ -2149,11 +2149,11 @@ struct batched_entropy {/* * Get a random word for internal kernel use only. The quality of the random -* number is either as good as RDRAND or as good as /dev/urandom, with the -* goal of being quite fast and not depleting entropy. In order to ensure +* number is good as /dev/urandom, but there is no backtrack protection, with +* the goal of being quite fast and not depleting entropy. In order to ensure * that the randomness provided by this function is okay, the function -* wait_for_random_bytes() should be called and return 0 at least once -* at any point prior. +* wait_for_random_bytes() should be called and return 0 at least once at any +* point prior. */ static DEFINE_PER_CPU(struct batched_entropy, batched_entropy_u64) = { .batch_lock =__SPIN_LOCK_UNLOCKED (batched_entropy_u64.lock),
@@ -2166,15 +2166,6 @@ u64 get_random_u64(void)struct batched_entropy *batch;static void *previous; -#if BITS_PER_LONG ==64 -if (arch_get_random_long ((unsigned long *)&ret)) -return ret; -#else -if (arch_get_random_long ((unsigned long *)&ret) && -arch_get_random_long ((unsigned long *)&ret +1 )) -return ret; -#endif -warn_unseeded_randomness (&previous); batch =raw_cpu_ptr (&batched_entropy_u64);
@@ -2199,9 +2190,6 @@ u32 get_random_u32(void)struct batched_entropy *batch;static void *previous; -if (arch_get_random_int (&ret)) -return ret; -warn_unseeded_randomness (&previous); batch =raw_cpu_ptr (&batched_entropy_u32);
Greg Kroah-Hartman
maintainerPATCH 18/38 usb: dwc3: gadget: Wrap around when skip TRBs
In reply to Greg Kroah-HartmanFrom: Thinh Nguyen <[email protected]>
commit 2dedea035ae82c5af0595637a6eda4655532b21e upstream.
When skipping TRBs, we need to account for wrapping around the ring buffer and not modifying some invalid TRBs. Without this fix, dwc3 won't be able to check for available TRBs.
--- drivers/usb/dwc3/gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/dwc3/gadget.c +1 -1
@@ -1521,7 +1521,7 @@ static void dwc3_gadget_ep_skip_trbs(strfor (i =0 ; i < req->num_trbs; i++) {struct dwc3_trb *trb; - trb = req->trb + i; + trb = &dep->trb_pool[dep->trb_dequeue]; trb->ctrl &= ~DWC3_TRB_CTRL_HWO ;dwc3_ep_inc_deq (dep); }
Greg Kroah-Hartman
maintainerPATCH 19/38 slub: improve bit diffusion for freelist ptr obfuscation
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
commit 1ad53d9fa3f6168ebcf48a50e08b170432da2257 upstream.
Under CONFIG_SLAB_FREELIST_HARDENED=y, the obfuscation was relatively weak in that the ptr and ptr address were usually so close that the first XOR would result in an almost entirely 0-byte value[1], leaving most of the "secret" number ultimately being stored after the third XOR. A single blind memory content exposure of the freelist was generally sufficient to learn the secret.
Add a swab() call to mix bits a little more. This is a cheap way (1 cycle) to make attacks need more than a single exposure to learn the secret (or to know _where_ the exposure is in memory).
kmalloc-32 freelist walk, before:
ptr ptr_addr stored value secret
ffff90c22e019020@ffff90c22e019000 is 86528eb656b3b5bd (86528eb656b3b59d) ffff90c22e019040@ffff90c22e019020 is 86528eb656b3b5fd (86528eb656b3b59d) ffff90c22e019060@ffff90c22e019040 is 86528eb656b3b5bd (86528eb656b3b59d) ffff90c22e019080@ffff90c22e019060 is 86528eb656b3b57d (86528eb656b3b59d) ffff90c22e0190a0@ffff90c22e019080 is 86528eb656b3b5bd (86528eb656b3b59d)
...
after:
ptr ptr_addr stored value secret
ffff9eed6e019020@ffff9eed6e019000 is 793d1135d52cda42 (86528eb656b3b59d) ffff9eed6e019040@ffff9eed6e019020 is 593d1135d52cda22 (86528eb656b3b59d) ffff9eed6e019060@ffff9eed6e019040 is 393d1135d52cda02 (86528eb656b3b59d) ffff9eed6e019080@ffff9eed6e019060 is 193d1135d52cdae2 (86528eb656b3b59d) ffff9eed6e0190a0@ffff9eed6e019080 is f93d1135d52cdac2 (86528eb656b3b59d)
[1] https://blog.infosectcbr.com.au/2020/03/weaknesses-in-linux-kernel-heap.html
--- mm/slub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/slub.c +1 -1
@@ -259,7 +259,7 @@ static inline void *freelist_ptr(const s* freepointer to be restored incorrectly. */ return (void *)((unsigned long )ptr ^ s->random ^ - (unsigned long )kasan_reset_tag ((void *)ptr_addr)); +swab ((unsigned long )kasan_reset_tag ((void *)ptr_addr)));#else return ptr;#endif
Greg Kroah-Hartman
maintainerPATCH 20/38 tools/accounting/getdelays.c: fix netlink attribute length
In reply to Greg Kroah-HartmanFrom: David Ahern <[email protected]>
commit 4054ab64e29bb05b3dfe758fff3c38a74ba753bb upstream.
A recent change to the netlink code: 6e237d099fac ("netlink: Relax attr validation for fixed length types") logs a warning when programs send messages with invalid attributes (e.g., wrong length for a u32). Yafang reported this error message for tools/accounting/getdelays.c.
send_cmd() is wrongly adding 1 to the attribute length. As noted in include/uapi/linux/netlink.h nla_len should be NLA_HDRLEN + payload length, so drop the +1.
--- tools/accounting/getdelays.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/accounting/getdelays.c +1 -1
@@ -136,7 +136,7 @@ static int send_cmd(int sd, __u16 nlmsg_ msg.g.version =0x1 ; na = (struct nlattr *)GENLMSG_DATA (&msg); na->nla_type = nla_type; - na->nla_len = nla_len +1 +NLA_HDRLEN ; + na->nla_len = nla_len +NLA_HDRLEN ;memcpy (NLA_DATA (na), nla_data, nla_len); msg.n.nlmsg_len +=NLMSG_ALIGN (na->nla_len);
Greg Kroah-Hartman
maintainerPATCH 21/38 hwrng: imx-rngc - fix an error path
In reply to Greg Kroah-HartmanFrom: Martin Kaiser <[email protected]>
commit 47a1f8e8b3637ff5f7806587883d7d94068d9ee8 upstream.
Make sure that the rngc interrupt is masked if the rngc self test fails. Self test failure means that probe fails as well. Interrupts should be masked in this case, regardless of the error.
--- drivers/char/hw_random/imx-rngc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/char/hw_random/imx-rngc.c +3 -1
@@ -105,8 +105,10 @@ static int imx_rngc_self_test(struct imxreturn -ETIMEDOUT ; } -if (rngc->err_reg !=0 ) +if (rngc->err_reg !=0 ) { +imx_rngc_irq_mask_clear (rngc);return -EIO ; + }return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 22/38 ACPI: PM: Add acpi_[un]register_wakeup_handler()
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
commit ddfd9dcf270ce23ed1985b66fcfa163920e2e1b8 upstream.
Since commit fdde0ff8590b ("ACPI: PM: s2idle: Prevent spurious SCIs from waking up the system") the SCI triggering without there being a wakeup cause recognized by the ACPI sleep code will no longer wakeup the system.
This works as intended, but this is a problem for devices where the SCI is shared with another device which is also a wakeup source.
In the past these, from the pov of the ACPI sleep code, spurious SCIs would still cause a wakeup so the wakeup from the device sharing the interrupt would actually wakeup the system. This now no longer works.
This is a problem on e.g. Bay Trail-T and Cherry Trail devices where some peripherals (typically the XHCI controller) can signal a Power Management Event (PME) to the Power Management Controller (PMC) to wakeup the system, this uses the same interrupt as the SCI. These wakeups are handled through a special INT0002 ACPI device which checks for events in the GPE0a_STS for this and takes care of acking the PME so that the shared interrupt stops triggering.
The change to the ACPI sleep code to ignore the spurious SCI, causes the system to no longer wakeup on these PME events. To make things worse this means that the INT0002 device driver interrupt handler will no longer run, causing the PME to not get cleared and resulting in the system hanging. Trying to wakeup the system after such a PME through e.g. the power button no longer works.
Add an acpi_register_wakeup_handler() function which registers a handler to be called from acpi_s2idle_wake() and when the handler returns true, return true from acpi_s2idle_wake().
The INT0002 driver will use this mechanism to check the GPE0a_STS register from acpi_s2idle_wake() and to tell the system to wakeup if a PME is signaled in the register.
--- drivers/acpi/sleep.c | 4 ++ drivers/acpi/sleep.h | 1 drivers/acpi/wakeup.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/acpi.h | 5 +++ 4 files changed, 91 insertions(+)
drivers/acpi/sleep.c +4 -0
@@ -1012,6 +1012,10 @@ static bool acpi_s2idle_wake(void)if (acpi_any_fixed_event_status_set ())return true; +/* Check wakeups from drivers sharing the SCI. */ +if (acpi_check_wakeup_handlers ()) +return true; +/* * If there are no EC events to process and at least one of the * other enabled GPEs is active, the wakeup is regarded as a
drivers/acpi/sleep.h +1 -0
@@ -2,6 +2,7 @@extern void acpi_enable_wakeup_devices (u8 sleep_state);extern void acpi_disable_wakeup_devices (u8 sleep_state); +extern bool acpi_check_wakeup_handlers (void );extern struct list_head acpi_wakeup_device_list;extern struct mutex acpi_device_lock;
drivers/acpi/wakeup.c +81 -0
90 lines not on this page · raw message
include/linux/acpi.h +5 -0
@@ -488,6 +488,11 @@ void __init acpi_nvs_nosave_s3(void);void __init acpi_sleep_no_blacklist (void );#endif /* CONFIG_PM_SLEEP */ +int acpi_register_wakeup_handler ( +int wake_irq,bool (*wakeup)(void *context),void *context); +void acpi_unregister_wakeup_handler ( +bool (*wakeup)(void *context),void *context); +struct acpi_osc_context {char *uuid_str;/* UUID string */ int rev;
Greg Kroah-Hartman
maintainerPATCH 23/38 platform/x86: intel_int0002_vgpio: Use acpi_register_wakeup_handler()
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
commit 767191db8220db29f78c031f4d27375173c336d5 upstream.
The Power Management Events (PMEs) the INT0002 driver listens for get signalled by the Power Management Controller (PMC) using the same IRQ as used for the ACPI SCI.
Since commit fdde0ff8590b ("ACPI: PM: s2idle: Prevent spurious SCIs from waking up the system") the SCI triggering, without there being a wakeup cause recognized by the ACPI sleep code, will no longer wakeup the system.
This breaks PMEs / wakeups signalled to the INT0002 driver, the system never leaves the s2idle_loop() now.
Use acpi_register_wakeup_handler() to register a function which checks the GPE0a_STS register for a PME and trigger a wakeup when a PME has been signalled.
--- drivers/platform/x86/intel_int0002_vgpio.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/platform/x86/intel_int0002_vgpio.c +10 -0
@@ -127,6 +127,14 @@ static irqreturn_t int0002_irq(int irq,return IRQ_HANDLED ; } +static bool int0002_check_wake (void *data) +{ +u32 gpe_sts_reg; + + gpe_sts_reg =inl (GPE0A_STS_PORT ); +return (gpe_sts_reg &GPE0A_PME_B0_STS_BIT ); +} +static struct irq_chip int0002_byt_irqchip = { .name =DRV_NAME , .irq_ack = int0002_irq_ack,
@@ -220,6 +228,7 @@ static int int0002_probe(struct platformreturn ret; } +acpi_register_wakeup_handler (irq, int0002_check_wake,NULL );device_init_wakeup (dev, true);return 0 ; }
@@ -227,6 +236,7 @@ static int int0002_probe(struct platformstatic int int0002_remove (struct platform_device *pdev) {device_init_wakeup (&pdev->dev, false); +acpi_unregister_wakeup_handler (int0002_check_wake,NULL );return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 24/38 ASoC: tas2562: Fixed incorrect amp_level setting.
In reply to Greg Kroah-HartmanFrom: Jonghwan Choi <[email protected]>
commit eedf8a126629bf9db8ad3a2a5dc9dc1798fb2302 upstream.
According to the tas2562 datasheet,the bits[5:1] represents the amp_level value. So to set the amp_level value correctly,the shift value should be set to 1.
--- sound/soc/codecs/tas2562.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/tas2562.c +1 -1
@@ -409,7 +409,7 @@ static const struct snd_kcontrol_new vse 1, 1);static const struct snd_kcontrol_new tas2562_snd_controls[] = { -SOC_SINGLE_TLV ("Amp Gain Volume" ,TAS2562_PB_CFG1 ,0 ,0x1c ,0 , +SOC_SINGLE_TLV ("Amp Gain Volume" ,TAS2562_PB_CFG1 ,1 ,0x1c ,0 , tas2562_dac_tlv), };
Greg Kroah-Hartman
maintainerPATCH 25/38 ASoC: jz4740-i2s: Fix divider written at incorrect offset in register
In reply to Greg Kroah-HartmanFrom: Paul Cercueil <[email protected]>
commit 9401d5aa328e64617d87abd59af1c91cace4c3e4 upstream.
The 4-bit divider value was written at offset 8, while the jz4740 programming manual locates it at offset 0.
--- sound/soc/jz4740/jz4740-i2s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/jz4740/jz4740-i2s.c +1 -1
@@ -83,7 +83,7 @@#define JZ_AIC_I2S_STATUS_BUSY BIT(2)#define JZ_AIC_CLK_DIV_MASK 0xf -#define I2SDIV_DV_SHIFT 8 +#define I2SDIV_DV_SHIFT 0#define I2SDIV_DV_MASK (0xf << I2SDIV_DV_SHIFT)#define I2SDIV_IDV_SHIFT 8#define I2SDIV_IDV_MASK (0xf << I2SDIV_IDV_SHIFT)
Greg Kroah-Hartman
maintainerPATCH 26/38 IB/hfi1: Call kobject_put() when kobject_init_and_add() fails
In reply to Greg Kroah-HartmanFrom: Kaike Wan <[email protected]>
commit dfb5394f804ed4fcea1fc925be275a38d66712ab upstream.
When kobject_init_and_add() returns an error in the function hfi1_create_port_files(), the function kobject_put() is not called for the corresponding kobject, which potentially leads to memory leak.
This patch fixes the issue by calling kobject_put() even if kobject_init_and_add() fails.
--- drivers/infiniband/hw/hfi1/sysfs.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/infiniband/hw/hfi1/sysfs.c +8 -5
@@ -674,7 +674,11 @@ int hfi1_create_port_files(struct ib_devdd_dev_err (dd,"Skipping sc2vl sysfs info, (err %d) port %u\n" , ret, port_num); - goto bail; +/* +* Based on the documentation for kobject_init_and_add(), the +* caller should call kobject_put even if this call fails. +*/ + goto bail_sc2vl; }kobject_uevent (&ppd->sc2vl_kobj,KOBJ_ADD );
@@ -684,7 +688,7 @@ int hfi1_create_port_files(struct ib_devdd_dev_err (dd,"Skipping sl2sc sysfs info, (err %d) port %u\n" , ret, port_num); - goto bail_sc2vl; + goto bail_sl2sc; }kobject_uevent (&ppd->sl2sc_kobj,KOBJ_ADD );
@@ -694,7 +698,7 @@ int hfi1_create_port_files(struct ib_devdd_dev_err (dd,"Skipping vl2mtu sysfs info, (err %d) port %u\n" , ret, port_num); - goto bail_sl2sc; + goto bail_vl2mtu; }kobject_uevent (&ppd->vl2mtu_kobj,KOBJ_ADD );
@@ -704,7 +708,7 @@ int hfi1_create_port_files(struct ib_devdd_dev_err (dd,"Skipping Congestion Control sysfs info, (err %d) port %u\n" , ret, port_num); - goto bail_vl2mtu; + goto bail_cc; }kobject_uevent (&ppd->pport_cc_kobj,KOBJ_ADD );
@@ -742,7 +746,6 @@ bail_sl2sc:kobject_put (&ppd->sl2sc_kobj); bail_sc2vl:kobject_put (&ppd->sc2vl_kobj); -bail:return ret; }
Greg Kroah-Hartman
maintainerPATCH 27/38 IB/hfi1: Fix memory leaks in sysfs registration and unregistration
In reply to Greg Kroah-HartmanFrom: Kaike Wan <[email protected]>
commit 5c15abc4328ad696fa61e2f3604918ed0c207755 upstream.
When the hfi1 driver is unloaded, kmemleak will report the following issue:
unreferenced object 0xffff8888461a4c08 (size 8):
comm "kworker/0:0", pid 5, jiffies 4298601264 (age 2047.134s) hex dump (first 8 bytes):
73 64 6d 61 30 00 ff ff sdma0...
backtrace:
[<00000000311a6ef5>] kvasprintf+0x62/0xd0 [<00000000ade94d9f>] kobject_set_name_vargs+0x1c/0x90 [<0000000060657dbb>] kobject_init_and_add+0x5d/0xb0 [<00000000346fe72b>] 0xffffffffa0c5ecba [<000000006cfc5819>] 0xffffffffa0c866b9 [<0000000031c65580>] 0xffffffffa0c38e87 [<00000000e9739b3f>] local_pci_probe+0x41/0x80 [<000000006c69911d>] work_for_cpu_fn+0x16/0x20 [<00000000601267b5>] process_one_work+0x171/0x380 [<0000000049a0eefa>] worker_thread+0x1d1/0x3f0 [<00000000909cf2b9>] kthread+0xf8/0x130 [<0000000058f5f874>] ret_from_fork+0x35/0x40
This patch fixes the issue by:
- Releasing dd->per_sdma[i].kobject in hfi1_unregister_sysfs().
- This will fix the memory leak.
- Calling kobject_put() to unwind operations only for those entries in dd->per_sdma[] whose operations have succeeded (including the current one that has just failed) in hfi1_verbs_register_sysfs().
--- drivers/infiniband/hw/hfi1/sysfs.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/infiniband/hw/hfi1/sysfs.c +11 -2
@@ -856,8 +856,13 @@ int hfi1_verbs_register_sysfs(struct hfireturn 0 ; bail: -for (i =0 ; i < dd->num_sdma; i++) -kobject_del (&dd->per_sdma[i].kobj); +/* +* The function kobject_put() will call kobject_del() if the kobject +* has been added successfully. The sysfs files created under the +* kobject directory will also be removed during the process. +*/ +for (; i >=0 ; i--) +kobject_put (&dd->per_sdma[i].kobj);return ret; }
@@ -870,6 +875,10 @@ void hfi1_verbs_unregister_sysfs(structstruct hfi1_pportdata *ppd;int i; +/* Unwind operations in hfi1_verbs_register_sysfs() */ +for (i =0 ; i < dd->num_sdma; i++) +kobject_put (&dd->per_sdma[i].kobj); +for (i =0 ; i < dd->num_pports; i++) { ppd = &dd->pport[i];
Greg Kroah-Hartman
maintainerPATCH 28/38 IB/mlx5: Replace tunnel mpls capability bits for tunnel_offloads
In reply to Greg Kroah-HartmanFrom: Alex Vesker <[email protected]>
commit 41e684ef3f37ce6e5eac3fb5b9c7c1853f4b0447 upstream.
Until now the flex parser capability was used in ib_query_device() to indicate tunnel_offloads_caps support for mpls_over_gre/mpls_over_udp.
Newer devices and firmware will have configurations with the flexparser but without mpls support.
Testing for the flex parser capability was a mistake, the tunnel_stateless capability was intended for detecting mpls and was introduced at the same time as the flex parser capability.
Otherwise userspace will be incorrectly informed that a future device supports MPLS when it does not.
--- drivers/infiniband/hw/mlx5/main.c | 6 ++---- include/linux/mlx5/mlx5_ifc.h | 6 +++++- 2 files changed, 7 insertions(+), 5 deletions(-)
drivers/infiniband/hw/mlx5/main.c +2 -4
@@ -1192,12 +1192,10 @@ static int mlx5_ib_query_device(struct iif (MLX5_CAP_ETH (mdev, tunnel_stateless_gre)) resp.tunnel_offloads_caps |=MLX5_IB_TUNNELED_OFFLOADS_GRE ; -if (MLX5_CAP_GEN (mdev, flex_parser_protocols) & -MLX5_FLEX_PROTO_CW_MPLS_GRE ) +if (MLX5_CAP_ETH (mdev, tunnel_stateless_mpls_over_gre)) resp.tunnel_offloads_caps |=MLX5_IB_TUNNELED_OFFLOADS_MPLS_GRE ; -if (MLX5_CAP_GEN (mdev, flex_parser_protocols) & -MLX5_FLEX_PROTO_CW_MPLS_UDP ) +if (MLX5_CAP_ETH (mdev, tunnel_stateless_mpls_over_udp)) resp.tunnel_offloads_caps |=MLX5_IB_TUNNELED_OFFLOADS_MPLS_UDP ; }
include/linux/mlx5/mlx5_ifc.h +5 -1
@@ -875,7 +875,11 @@ struct mlx5_ifc_per_protocol_networking_u8 swp_csum[0x1 ];u8 swp_lso[0x1 ];u8 cqe_checksum_full[0x1 ]; -u8 reserved_at_24[0x5 ]; +u8 tunnel_stateless_geneve_tx[0x1 ]; +u8 tunnel_stateless_mpls_over_udp[0x1 ]; +u8 tunnel_stateless_mpls_over_gre[0x1 ]; +u8 tunnel_stateless_vxlan_gpe[0x1 ]; +u8 tunnel_stateless_ipv4_over_vxlan[0x1 ];u8 tunnel_stateless_ip_over_ip[0x1 ];u8 reserved_at_2a[0x6 ];u8 max_vxlan_udp_ports[0x8 ];
Greg Kroah-Hartman
maintainerPATCH 29/38 ubi: fastmap: Free unused fastmap anchor peb during detach
In reply to Greg Kroah-HartmanFrom: Hou Tao <[email protected]>
commit c16f39d14a7e0ec59881fbdb22ae494907534384 upstream.
When CONFIG_MTD_UBI_FASTMAP is enabled, fm_anchor will be assigned a free PEB during ubi_wl_init() or ubi_update_fastmap(). However if fastmap is not used or disabled on the MTD device, ubi_wl_entry related with the PEB will not be freed during detach.
So Fix it by freeing the unused fastmap anchor during detach.
--- drivers/mtd/ubi/fastmap-wl.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/mtd/ubi/fastmap-wl.c +13 -2
@@ -39,6 +39,13 @@ static struct ubi_wl_entry *find_anchor_return victim; } +static inline void return_unused_peb (struct ubi_device *ubi, +struct ubi_wl_entry *e) +{ +wl_tree_add (e, &ubi->free); + ubi->free_count++; +} +/** * return_unused_pool_pebs - returns unused PEB to the free tree. * @ubi: UBI device description object
@@ -52,8 +59,7 @@ static void return_unused_pool_pebs(strufor (i = pool->used; i < pool->size; i++) { e = ubi->lookuptbl[pool->pebs[i]]; -wl_tree_add (e, &ubi->free); - ubi->free_count++; +return_unused_peb (ubi, e); } }
@@ -361,6 +367,11 @@ static void ubi_fastmap_close(struct ubireturn_unused_pool_pebs (ubi, &ubi->fm_pool);return_unused_pool_pebs (ubi, &ubi->fm_wl_pool); +if (ubi->fm_anchor) { +return_unused_peb (ubi, ubi->fm_anchor); + ubi->fm_anchor =NULL ; + } +if (ubi->fm) {for (i =0 ; i < ubi->fm->used_blocks; i++)kfree (ubi->fm->e[i]);
Greg Kroah-Hartman
maintainerPATCH 30/38 RDMA/ucma: Put a lock around every call to the rdma_cm layer
In reply to Greg Kroah-HartmanFrom: Jason Gunthorpe <[email protected]>
commit 7c11910783a1ea17e88777552ef146cace607b3c upstream.
The rdma_cm must be used single threaded.
This appears to be a bug in the design, as it does have lots of locking that seems like it should allow concurrency. However, when it is all said and done every single place that uses the cma_exch() scheme is broken, and all the unlocked reads from the ucma of the cm_id data are wrong too.
syzkaller has been finding endless bugs related to this.
Fixing this in any elegant way is some enormous amount of work. Take a very big hammer and put a mutex around everything to do with the ucma_context at the top of every syscall.
--- drivers/infiniband/core/ucma.c | 49 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-)
drivers/infiniband/core/ucma.c +47 -2
@@ -91,6 +91,7 @@ struct ucma_context {struct ucma_file *file;struct rdma_cm_id *cm_id; +struct mutex mutex;u64 uid;struct list_head list;
@@ -216,6 +217,7 @@ static struct ucma_context *ucma_alloc_cinit_completion (&ctx->comp);INIT_LIST_HEAD (&ctx->mc_list); ctx->file = file; +mutex_init (&ctx->mutex);if (xa_alloc (&ctx_table, &ctx->id, ctx, xa_limit_32b,GFP_KERNEL )) goto error;
@@ -589,6 +591,7 @@ static int ucma_free_ctx(struct ucma_con } events_reported = ctx->events_reported; +mutex_destroy (&ctx->mutex);kfree (ctx);return events_reported; }
@@ -658,7 +661,10 @@ static ssize_t ucma_bind_ip(struct ucma_if (IS_ERR (ctx))return PTR_ERR (ctx); +mutex_lock (&ctx->mutex); ret =rdma_bind_addr (ctx->cm_id, (struct sockaddr *) &cmd.addr); +mutex_unlock (&ctx->mutex); +ucma_put_ctx (ctx);return ret; }
@@ -681,7 +687,9 @@ static ssize_t ucma_bind(struct ucma_filif (IS_ERR (ctx))return PTR_ERR (ctx); +mutex_lock (&ctx->mutex); ret =rdma_bind_addr (ctx->cm_id, (struct sockaddr *) &cmd.addr); +mutex_unlock (&ctx->mutex);ucma_put_ctx (ctx);return ret; }
@@ -705,8 +713,10 @@ static ssize_t ucma_resolve_ip(struct ucif (IS_ERR (ctx))return PTR_ERR (ctx); +mutex_lock (&ctx->mutex); ret =rdma_resolve_addr (ctx->cm_id, (struct sockaddr *) &cmd.src_addr, (struct sockaddr *) &cmd.dst_addr, cmd.timeout_ms); +mutex_unlock (&ctx->mutex);ucma_put_ctx (ctx);return ret; }
@@ -731,8 +741,10 @@ static ssize_t ucma_resolve_addr(structif (IS_ERR (ctx))return PTR_ERR (ctx); +mutex_lock (&ctx->mutex); ret =rdma_resolve_addr (ctx->cm_id, (struct sockaddr *) &cmd.src_addr, (struct sockaddr *) &cmd.dst_addr, cmd.timeout_ms); +mutex_unlock (&ctx->mutex);ucma_put_ctx (ctx);return ret; }
@@ -752,7 +764,9 @@ static ssize_t ucma_resolve_route(structif (IS_ERR (ctx))return PTR_ERR (ctx); +mutex_lock (&ctx->mutex); ret =rdma_resolve_route (ctx->cm_id, cmd.timeout_ms); +mutex_unlock (&ctx->mutex);ucma_put_ctx (ctx);return ret; }
@@ -841,6 +855,7 @@ static ssize_t ucma_query_route(struct uif (IS_ERR (ctx))return PTR_ERR (ctx); +mutex_lock (&ctx->mutex);memset (&resp,0 ,sizeof resp); addr = (struct sockaddr *) &ctx->cm_id->route.addr.src_addr; memcpy(&resp.src_addr, addr, addr->sa_family == AF_INET ?
@@ -864,6 +879,7 @@ static ssize_t ucma_query_route(struct uucma_copy_iw_route (&resp, &ctx->cm_id->route); out: +mutex_unlock (&ctx->mutex);if (copy_to_user (u64_to_user_ptr (cmd.response), &resp,sizeof (resp))) ret = -EFAULT ;
@@ -1014,6 +1030,7 @@ static ssize_t ucma_query(struct ucma_fiif (IS_ERR (ctx))return PTR_ERR (ctx); +mutex_lock (&ctx->mutex);switch (cmd.option) {case RDMA_USER_CM_QUERY_ADDR : ret =ucma_query_addr (ctx, response, out_len);
@@ -1028,6 +1045,7 @@ static ssize_t ucma_query(struct ucma_fi ret = -ENOSYS ;break ; } +mutex_unlock (&ctx->mutex);ucma_put_ctx (ctx);return ret;
@@ -1068,7 +1086,9 @@ static ssize_t ucma_connect(struct ucma_return PTR_ERR (ctx);ucma_copy_conn_param (ctx->cm_id, &conn_param, &cmd.conn_param); +mutex_lock (&ctx->mutex); ret =rdma_connect (ctx->cm_id, &conn_param); +mutex_unlock (&ctx->mutex);ucma_put_ctx (ctx);return ret; }
@@ -1089,7 +1109,9 @@ static ssize_t ucma_listen(struct ucma_f ctx->backlog = cmd.backlog >0 && cmd.backlog < max_backlog ? cmd.backlog : max_backlog; +mutex_lock (&ctx->mutex); ret =rdma_listen (ctx->cm_id, ctx->backlog); +mutex_unlock (&ctx->mutex);ucma_put_ctx (ctx);return ret; }
@@ -1112,13 +1134,17 @@ static ssize_t ucma_accept(struct ucma_fif (cmd.conn_param.valid) {ucma_copy_conn_param (ctx->cm_id, &conn_param, &cmd.conn_param);mutex_lock (&file->mut); +mutex_lock (&ctx->mutex); ret =__rdma_accept (ctx->cm_id, &conn_param,NULL ); +mutex_unlock (&ctx->mutex);if (!ret) ctx->uid = cmd.uid;mutex_unlock (&file->mut); - }else + }else { +mutex_lock (&ctx->mutex); ret =__rdma_accept (ctx->cm_id,NULL ,NULL ); - +mutex_unlock (&ctx->mutex); + }ucma_put_ctx (ctx);return ret; }
@@ -1137,7 +1163,9 @@ static ssize_t ucma_reject(struct ucma_fif (IS_ERR (ctx))return PTR_ERR (ctx); +mutex_lock (&ctx->mutex); ret =rdma_reject (ctx->cm_id, cmd.private_data, cmd.private_data_len); +mutex_unlock (&ctx->mutex);ucma_put_ctx (ctx);return ret; }
@@ -1156,7 +1184,9 @@ static ssize_t ucma_disconnect(struct ucif (IS_ERR (ctx))return PTR_ERR (ctx); +mutex_lock (&ctx->mutex); ret =rdma_disconnect (ctx->cm_id); +mutex_unlock (&ctx->mutex);ucma_put_ctx (ctx);return ret; }
@@ -1187,7 +1217,9 @@ static ssize_t ucma_init_qp_attr(struct resp.qp_attr_mask =0 ;memset (&qp_attr,0 ,sizeof qp_attr); qp_attr.qp_state = cmd.qp_state; +mutex_lock (&ctx->mutex); ret =rdma_init_qp_attr (ctx->cm_id, &qp_attr, &resp.qp_attr_mask); +mutex_unlock (&ctx->mutex);if (ret) goto out;
@@ -1273,9 +1305,13 @@ static int ucma_set_ib_path(struct ucma_struct sa_path_rec opa;sa_convert_path_ib_to_opa (&opa, &sa_path); +mutex_lock (&ctx->mutex); ret =rdma_set_ib_path (ctx->cm_id, &opa); +mutex_unlock (&ctx->mutex); }else { +mutex_lock (&ctx->mutex); ret =rdma_set_ib_path (ctx->cm_id, &sa_path); +mutex_unlock (&ctx->mutex); }if (ret)return ret;
@@ -1308,7 +1344,9 @@ static int ucma_set_option_level(structswitch (level) {case RDMA_OPTION_ID : +mutex_lock (&ctx->mutex); ret =ucma_set_option_id (ctx, optname, optval, optlen); +mutex_unlock (&ctx->mutex);break ;case RDMA_OPTION_IB : ret =ucma_set_option_ib (ctx, optname, optval, optlen);
@@ -1368,8 +1406,10 @@ static ssize_t ucma_notify(struct ucma_fif (IS_ERR (ctx))return PTR_ERR (ctx); +mutex_lock (&ctx->mutex);if (ctx->cm_id->device) ret =rdma_notify (ctx->cm_id, (enum ib_event_type )cmd.event); +mutex_unlock (&ctx->mutex);ucma_put_ctx (ctx);return ret;
@@ -1412,8 +1452,10 @@ static ssize_t ucma_process_join(struct mc->join_state = join_state; mc->uid = cmd->uid;memcpy (&mc->addr, addr, cmd->addr_size); +mutex_lock (&ctx->mutex); ret =rdma_join_multicast (ctx->cm_id, (struct sockaddr *)&mc->addr, join_state, mc); +mutex_unlock (&ctx->mutex);if (ret) goto err2;
@@ -1513,7 +1555,10 @@ static ssize_t ucma_leave_multicast(stru goto out; } +mutex_lock (&mc->ctx->mutex);rdma_leave_multicast (mc->ctx->cm_id, (struct sockaddr *) &mc->addr); +mutex_unlock (&mc->ctx->mutex); +mutex_lock (&mc->ctx->file->mut);ucma_cleanup_mc_events (mc);list_del (&mc->list);
Greg Kroah-Hartman
maintainerPATCH 31/38 RDMA/cma: Teach lockdep about the order of rtnl and lock
In reply to Greg Kroah-HartmanFrom: Jason Gunthorpe <[email protected]>
commit 32ac9e4399b12d3e54d312a0e0e30ed5cd19bd4e upstream.
This lock ordering only happens when bonding is enabled and a certain bonding related event fires. However, since it can happen this is a global restriction on lock ordering.
Teach lockdep about the order directly and unconditionally so bugs here are found quickly.
See https://syzkaller.appspot.com/bug?extid=55de90ab5f44172b0c90
--- drivers/infiniband/core/cma.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/infiniband/core/cma.c +13 -0
@@ -4790,6 +4790,19 @@ static int __init cma_init(void) {int ret; +/* +* There is a rare lock ordering dependency in cma_netdev_callback() +* that only happens when bonding is enabled. Teach lockdep that rtnl +* must never be nested under lock so it can find these without having +* to test with bonding. +*/ +if (IS_ENABLED (CONFIG_LOCKDEP )) { +rtnl_lock (); +mutex_lock (&lock); +mutex_unlock (&lock); +rtnl_unlock (); + } + cma_wq =alloc_ordered_workqueue ("rdma_cm" ,WQ_MEM_RECLAIM );if (!cma_wq)return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 32/38 RDMA/siw: Fix passive connection establishment
In reply to Greg Kroah-HartmanFrom: Bernard Metzler <[email protected]>
commit 33fb27fd54465c74cbffba6315b2f043e90cec4c upstream.
Holding the rtnl_lock while iterating a devices interface address list potentially causes deadlocks with the cma_netdev_callback. While this was implemented to limit the scope of a wildcard listen to addresses of the current device only, a better solution limits the scope of the socket to the device. This completely avoiding locking, and also results in significant code simplification.
--- drivers/infiniband/sw/siw/siw_cm.c | 137 ++++++++----------------------------- 1 file changed, 31 insertions(+), 106 deletions(-)
drivers/infiniband/sw/siw/siw_cm.c +31 -106
@@ -1769,14 +1769,23 @@ int siw_reject(struct iw_cm_id *id, consreturn 0 ; } -static int siw_listen_address (struct iw_cm_id *id,int backlog, -struct sockaddr *laddr,int addr_family) +/* +* siw_create_listen - Create resources for a listener's IWCM ID @id +* +* Starts listen on the socket address id->local_addr. +* +*/ +int siw_create_listen (struct iw_cm_id *id,int backlog) {struct socket *s;struct siw_cep *cep =NULL ;struct siw_device *sdev =to_siw_dev (id->device); +int addr_family = id->local_addr.ss_family;int rv =0 , s_val; +if (addr_family !=AF_INET && addr_family !=AF_INET6 ) +return -EAFNOSUPPORT ; + rv =sock_create (addr_family,SOCK_STREAM ,IPPROTO_TCP , &s);if (rv <0 )return rv;
@@ -1791,9 +1800,25 @@ static int siw_listen_address(struct iw_siw_dbg (id->device,"setsockopt error: %d\n" , rv); goto error; } - rv = s->ops->bind (s, laddr, addr_family ==AF_INET ? -sizeof (struct sockaddr_in ) : -sizeof (struct sockaddr_in6 )); +if (addr_family ==AF_INET ) { +struct sockaddr_in *laddr = &to_sockaddr_in (id->local_addr); + +/* For wildcard addr, limit binding to current device only */ +if (ipv4_is_zeronet (laddr->sin_addr.s_addr)) + s->sk->sk_bound_dev_if = sdev->netdev->ifindex; + + rv = s->ops->bind (s, (struct sockaddr *)laddr, +sizeof (struct sockaddr_in )); + }else { +struct sockaddr_in6 *laddr = &to_sockaddr_in6 (id->local_addr); + +/* For wildcard addr, limit binding to current device only */ +if (ipv6_addr_any (&laddr->sin6_addr)) + s->sk->sk_bound_dev_if = sdev->netdev->ifindex; + + rv = s->ops->bind (s, (struct sockaddr *)laddr, +sizeof (struct sockaddr_in6 )); + }if (rv) {siw_dbg (id->device,"socket bind error: %d\n" , rv); goto error;
@@ -1852,7 +1877,7 @@ static int siw_listen_address(struct iw_list_add_tail (&cep->listenq, (struct list_head *)id->provider_data); cep->state =SIW_EPSTATE_LISTENING ; -siw_dbg (id->device,"Listen at laddr %pISp\n" , laddr); +siw_dbg (id->device,"Listen at laddr %pISp\n" , &id->local_addr);return 0 ;
@@ -1910,106 +1935,6 @@ static void siw_drop_listeners(struct iw } } -/* -* siw_create_listen - Create resources for a listener's IWCM ID @id -* -* Listens on the socket address id->local_addr. -* -* If the listener's @id provides a specific local IP address, at most one -* listening socket is created and associated with @id. -* -* If the listener's @id provides the wildcard (zero) local IP address, -* a separate listen is performed for each local IP address of the device -* by creating a listening socket and binding to that local IP address. -* -*/ -int siw_create_listen (struct iw_cm_id *id,int backlog) -{ -struct net_device *dev =to_siw_dev (id->device)->netdev; -int rv =0 , listeners =0 ; - -siw_dbg (id->device,"backlog %d\n" , backlog); - -/* -* For each attached address of the interface, create a -* listening socket, if id->local_addr is the wildcard -* IP address or matches the IP address. -*/ -if (id->local_addr.ss_family ==AF_INET ) { -struct in_device *in_dev =in_dev_get (dev); -struct sockaddr_in s_laddr; -const struct in_ifaddr *ifa; - -if (!in_dev) { - rv = -ENODEV ; - goto out; - } -memcpy (&s_laddr, &id->local_addr,sizeof (s_laddr)); - -siw_dbg (id->device,"laddr %pISp\n" , &s_laddr); - -rtnl_lock (); -in_dev_for_each_ifa_rtnl (ifa, in_dev) { -if (ipv4_is_zeronet (s_laddr.sin_addr.s_addr) || - s_laddr.sin_addr.s_addr == ifa->ifa_address) { - s_laddr.sin_addr.s_addr = ifa->ifa_address; - - rv =siw_listen_address (id, backlog, - (struct sockaddr *)&s_laddr, -AF_INET ); -if (!rv) - listeners++; - } - } -rtnl_unlock (); -in_dev_put (in_dev); - }else if (id->local_addr.ss_family ==AF_INET6 ) { -struct inet6_dev *in6_dev =in6_dev_get (dev); -struct inet6_ifaddr *ifp; -struct sockaddr_in6 *s_laddr = &to_sockaddr_in6 (id->local_addr); - -if (!in6_dev) { - rv = -ENODEV ; - goto out; - } -siw_dbg (id->device,"laddr %pISp\n" , &s_laddr); - -rtnl_lock (); -list_for_each_entry (ifp, &in6_dev->addr_list, if_list) { -if (ifp->flags & (IFA_F_TENTATIVE |IFA_F_DEPRECATED )) -continue ; -if (ipv6_addr_any (&s_laddr->sin6_addr) || -ipv6_addr_equal (&s_laddr->sin6_addr, &ifp->addr)) { -struct sockaddr_in6 bind_addr = { - .sin6_family =AF_INET6 , - .sin6_port = s_laddr->sin6_port, - .sin6_flowinfo =0 , - .sin6_addr = ifp->addr, - .sin6_scope_id = dev->ifindex }; - - rv =siw_listen_address (id, backlog, - (struct sockaddr *)&bind_addr, -AF_INET6 ); -if (!rv) - listeners++; - } - } -rtnl_unlock (); -in6_dev_put (in6_dev); - }else { - rv = -EAFNOSUPPORT ; - } -out: -if (listeners) - rv =0 ; -else if (!rv) - rv = -EINVAL ; - -siw_dbg (id->device,"%s\n" , rv ?"FAIL" :"OK" ); - -return rv; -} -int siw_destroy_listen (struct iw_cm_id *id) {if (!id->provider_data) {
Greg Kroah-Hartman
maintainerPATCH 33/38 Bluetooth: RFCOMM: fix ODEBUG bug in rfcomm_dev_ioctl
In reply to Greg Kroah-HartmanFrom: Qiujun Huang <[email protected]>
commit 71811cac8532b2387b3414f7cd8fe9e497482864 upstream.
Needn't call 'rfcomm_dlc_put' here, because 'rfcomm_dlc_exists' didn't increase dlc->refcnt.
--- net/bluetooth/rfcomm/tty.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
net/bluetooth/rfcomm/tty.c +1 -3
@@ -413,10 +413,8 @@ static int __rfcomm_create_dev(struct so dlc =rfcomm_dlc_exists (&req.src, &req.dst, req.channel);if (IS_ERR (dlc))return PTR_ERR (dlc); -else if (dlc) { -rfcomm_dlc_put (dlc); +if (dlc)return -EBUSY ; - } dlc =rfcomm_dlc_alloc (GFP_KERNEL );if (!dlc)return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 34/38 RDMA/cm: Update num_paths in cma_resolve_iboe_route error flow
In reply to Greg Kroah-HartmanFrom: Avihai Horon <[email protected]>
commit 987914ab841e2ec281a35b54348ab109b4c0bb4e upstream.
After a successful allocation of path_rec, num_paths is set to 1, but any error after such allocation will leave num_paths uncleared.
This causes to de-referencing a NULL pointer later on. Hence, num_paths needs to be set back to 0 if such an error occurs.
The following crash from syzkaller revealed it.
kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN PTI CPU: 0 PID: 357 Comm: syz-executor060 Not tainted 4.18.0+ #311 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.11.0-0-g63451fca13-prebuilt.qemu-project.org 04/01/2014 RIP: 0010:ib_copy_path_rec_to_user+0x94/0x3e0 Code: f1 f1 f1 f1 c7 40 0c 00 00 f4 f4 65 48 8b 04 25 28 00 00 00 48 89 45 c8 31 c0 e8 d7 60 24 ff 48 8d 7b 4c 48 89 f8 48 c1 e8 03 <42> 0f b6 14 30 48 89 f8 83 e0 07 83 c0 03 38 d0 7c 08 84 d2 0f 85 RSP: 0018:ffff88006586f980 EFLAGS: 00010207 RAX: 0000000000000009 RBX: 0000000000000000 RCX: 1ffff1000d5fe475 RDX: ffff8800621e17c0 RSI: ffffffff820d45f9 RDI: 000000000000004c RBP: ffff88006586fa50 R08: ffffed000cb0df73 R09: ffffed000cb0df72 R10: ffff88006586fa70 R11: ffffed000cb0df73 R12: 1ffff1000cb0df30 R13: ffff88006586fae8 R14: dffffc0000000000 R15: ffff88006aff2200 FS: 00000000016fc880(0000) GS:ffff88006d000000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000020000040 CR3: 0000000063fec000 CR4: 00000000000006b0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: ? ib_copy_path_rec_from_user+0xcc0/0xcc0 ? __mutex_unlock_slowpath+0xfc/0x670 ? wait_for_completion+0x3b0/0x3b0 ? ucma_query_route+0x818/0xc60 ucma_query_route+0x818/0xc60 ? ucma_listen+0x1b0/0x1b0 ? sched_clock_cpu+0x18/0x1d0 ? sched_clock_cpu+0x18/0x1d0 ? ucma_listen+0x1b0/0x1b0 ? ucma_write+0x292/0x460 ucma_write+0x292/0x460 ? ucma_close_id+0x60/0x60 ? sched_clock_cpu+0x18/0x1d0 ? sched_clock_cpu+0x18/0x1d0 __vfs_write+0xf7/0x620 ? ucma_close_id+0x60/0x60 ? kernel_read+0x110/0x110 ? time_hardirqs_on+0x19/0x580 ? lock_acquire+0x18b/0x3a0 ? finish_task_switch+0xf3/0x5d0 ? _raw_spin_unlock_irq+0x29/0x40 ? _raw_spin_unlock_irq+0x29/0x40 ? finish_task_switch+0x1be/0x5d0 ? __switch_to_asm+0x34/0x70 ? __switch_to_asm+0x40/0x70 ? security_file_permission+0x172/0x1e0 vfs_write+0x192/0x460 ksys_write+0xc6/0x1a0 ? __ia32_sys_read+0xb0/0xb0 ? entry_SYSCALL_64_after_hwframe+0x3e/0xbe ? do_syscall_64+0x1d/0x470 do_syscall_64+0x9e/0x470 entry_SYSCALL_64_after_hwframe+0x49/0xbe
--- drivers/infiniband/core/cma.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/core/cma.c +1 -0
@@ -2968,6 +2968,7 @@ static int cma_resolve_iboe_route(struct err2:kfree (route->path_rec); route->path_rec =NULL ; + route->num_paths =0 ; err1:kfree (work);return ret;
Greg Kroah-Hartman
maintainerPATCH 35/38 blk-mq: Keep set->nr_hw_queues and set->map[].nr_queues in sync
In reply to Greg Kroah-HartmanFrom: Bart Van Assche <[email protected]>
commit 6e66b49392419f3fe134e1be583323ef75da1e4b upstream.
blk_mq_map_queues() and multiple .map_queues() implementations expect that set->map[HCTX_TYPE_DEFAULT].nr_queues is set to the number of hardware queues. Hence set .nr_queues before calling these functions. This patch fixes the following kernel warning:
WARNING: CPU: 0 PID: 2501 at include/linux/cpumask.h:137 Call Trace: blk_mq_run_hw_queue+0x19d/0x350 block/blk-mq.c:1508 blk_mq_run_hw_queues+0x112/0x1a0 block/blk-mq.c:1525 blk_mq_requeue_work+0x502/0x780 block/blk-mq.c:775 process_one_work+0x9af/0x1740 kernel/workqueue.c:2269 worker_thread+0x98/0xe40 kernel/workqueue.c:2415 kthread+0x361/0x430 kernel/kthread.c:255
--- block/blk-mq.c | 8 ++++++++ 1 file changed, 8 insertions(+)
block/blk-mq.c +8 -0
@@ -3023,6 +3023,14 @@ static int blk_mq_alloc_rq_maps(struct bstatic int blk_mq_update_queue_map (struct blk_mq_tag_set *set) { +/* +* blk_mq_map_queues() and multiple .map_queues() implementations +* expect that set->map[HCTX_TYPE_DEFAULT].nr_queues is set to the +* number of hardware queues. +*/ +if (set->nr_maps ==1 ) + set->map[HCTX_TYPE_DEFAULT ].nr_queues = set->nr_hw_queues; +if (set->ops->map_queues && !is_kdump_kernel ()) {int i;
Greg Kroah-Hartman
maintainerPATCH 36/38 fbcon: fix null-ptr-deref in fbcon_switch
In reply to Greg Kroah-HartmanFrom: Qiujun Huang <[email protected]>
commit b139f8b00db4a8ea75a4174346eafa48041aa489 upstream.
Set logo_shown to FBCON_LOGO_CANSHOW when the vc was deallocated.
syzkaller report: https://lkml.org/lkml/2020/3/27/403
general protection fault, probably for non-canonical address 0xdffffc000000006c: 0000 [#1] SMP KASAN KASAN: null-ptr-deref in range [0x0000000000000360-0x0000000000000367] RIP: 0010:fbcon_switch+0x28f/0x1740
drivers/video/fbdev/core/fbcon.c:2260
Call Trace: redraw_screen+0x2a8/0x770 drivers/tty/vt/vt.c:1008 vc_do_resize+0xfe7/0x1360 drivers/tty/vt/vt.c:1295 fbcon_init+0x1221/0x1ab0 drivers/video/fbdev/core/fbcon.c:1219 visual_init+0x305/0x5c0 drivers/tty/vt/vt.c:1062 do_bind_con_driver+0x536/0x890 drivers/tty/vt/vt.c:3542 do_take_over_console+0x453/0x5b0 drivers/tty/vt/vt.c:4122 do_fbcon_takeover+0x10b/0x210 drivers/video/fbdev/core/fbcon.c:588 fbcon_fb_registered+0x26b/0x340 drivers/video/fbdev/core/fbcon.c:3259 do_register_framebuffer drivers/video/fbdev/core/fbmem.c:1664 [inline] register_framebuffer+0x56e/0x980 drivers/video/fbdev/core/fbmem.c:1832 dlfb_usb_probe.cold+0x1743/0x1ba3 drivers/video/fbdev/udlfb.c:1735 usb_probe_interface+0x310/0x800 drivers/usb/core/driver.c:374
accessing vc_cons[logo_shown].d->vc_top causes the bug.
--- drivers/video/fbdev/core/fbcon.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/video/fbdev/core/fbcon.c +3 -0
@@ -1283,6 +1283,9 @@ finished:if (!con_is_bound (&fb_con))fbcon_exit (); +if (vc->vc_num == logo_shown) + logo_shown =FBCON_LOGO_CANSHOW ; +return ; }
Greg Kroah-Hartman
maintainerPATCH 37/38 io-uring: drop completion when removing file
In reply to Greg Kroah-HartmanFrom: Hillf Danton <[email protected]>
commit 4afdb733b1606c6cb86e7833f9335f4870cf7ddd upstream.
A case of task hung was reported by syzbot,
INFO: task syz-executor975:9880 blocked for more than 143 seconds.
Not tainted 5.6.0-rc6-syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
syz-executor975 D27576 9880 9878 0x80004000
Call Trace:
schedule+0xd0/0x2a0 kernel/sched/core.c:4154
schedule_timeout+0x6db/0xba0 kernel/time/timer.c:1871
do_wait_for_common kernel/sched/completion.c:83 [inline]
__wait_for_common kernel/sched/completion.c:104 [inline]
wait_for_common kernel/sched/completion.c:115 [inline]
wait_for_completion+0x26a/0x3c0 kernel/sched/completion.c:136
io_queue_file_removal+0x1af/0x1e0 fs/io_uring.c:5826
__io_sqe_files_update.isra.0+0x3a1/0xb00 fs/io_uring.c:5867
io_sqe_files_update fs/io_uring.c:5918 [inline]
__io_uring_register+0x377/0x2c00 fs/io_uring.c:7131
__do_sys_io_uring_register fs/io_uring.c:7202 [inline]
__se_sys_io_uring_register fs/io_uring.c:7184 [inline]
__x64_sys_io_uring_register+0x192/0x560 fs/io_uring.c:7184
do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:294
entry_SYSCALL_64_after_hwframe+0x49/0xbeand bisect pointed to 05f3fb3c5397 ("io_uring: avoid ring quiesce for fixed file set unregister and update").
It is down to the order that we wait for work done before flushing it while nobody is likely going to wake us up.
We can drop that completion on stack as flushing work itself is a sync operation we need and no more is left behind it.
To that end, io_file_put::done is re-used for indicating if it can be freed in the workqueue worker context.
Rename ->done to ->free_pfile
--- fs/io_uring.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
fs/io_uring.c +5 -8
@@ -5607,7 +5607,7 @@ static void io_ring_file_put(struct io_rstruct io_file_put {struct llist_node llist;struct file *file; -struct completion *done; +bool free_pfile; };static void io_ring_file_ref_flush (struct fixed_file_data *data)
@@ -5618,9 +5618,7 @@ static void io_ring_file_ref_flush(strucwhile ((node =llist_del_all (&data->put_llist)) !=NULL ) {llist_for_each_entry_safe (pfile, tmp, node, llist) {io_ring_file_put (data->ctx, pfile->file); -if (pfile->done) -complete (pfile->done); -else +if (pfile->free_pfile)kfree (pfile); } }
@@ -5820,7 +5818,6 @@ static bool io_queue_file_removal(struct struct file *file) {struct io_file_put *pfile, pfile_stack; -DECLARE_COMPLETION_ONSTACK (done);/* * If we fail allocating the struct we need for doing async reomval
@@ -5829,15 +5826,15 @@ static bool io_queue_file_removal(struct pfile =kzalloc (sizeof (*pfile),GFP_KERNEL );if (!pfile) { pfile = &pfile_stack; - pfile->done = &done; - } + pfile->free_pfile = false; + }else + pfile->free_pfile = true; pfile->file = file;llist_add (&pfile->llist, &data->put_llist);if (pfile == &pfile_stack) {percpu_ref_switch_to_atomic (&data->refs, io_atomic_switch); -wait_for_completion (&done);flush_work (&data->ref_work);return false; }
Greg Kroah-Hartman
maintainerPATCH 38/38 driver core: Reevaluate dev->links.need_for_probe as suppliers are added
In reply to Greg Kroah-HartmanFrom: Saravana Kannan <[email protected]>
commit 1745d299af5b373abad08fa29bff0d31dc6aff21 upstream.
A previous patch 03324507e66c ("driver core: Allow fwnode_operations.add_links to differentiate errors") forgot to update all call sites to fwnode_operations.add_links. This patch fixes that.
Legend:
-> Denotes RHS is an optional/potential supplier for LHS => Denotes RHS is a mandatory supplier for LHS
Example:
Device A => Device X
Device A -> Device Y
Before this patch:
1. Device A is added.
2. Device A is marked as waiting for mandatory suppliers
3. Device X is added
4. Device A is left marked as waiting for mandatory suppliers
Step 4 is wrong since all mandatory suppliers of Device A have been added.
After this patch:
1. Device A is added.
2. Device A is marked as waiting for mandatory suppliers
3. Device X is added
4. Device A is no longer considered as waiting for mandatory suppliers
This is the correct behavior.
--- drivers/base/core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/base/core.c +6 -2
@@ -523,9 +523,13 @@ static void device_link_add_missing_suppmutex_lock (&wfs_lock);list_for_each_entry_safe (dev, tmp, &wait_for_suppliers, - links.needs_suppliers) -if (!fwnode_call_int_op (dev->fwnode, add_links, dev)) + links.needs_suppliers) { +int ret =fwnode_call_int_op (dev->fwnode, add_links, dev); +if (!ret)list_del_init (&dev->links.needs_suppliers); +else if (ret != -ENODEV ) + dev->links.need_for_probe = false; + }mutex_unlock (&wfs_lock); }
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.6.4 release. There are 38 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 Mon, 13 Apr 2020 11:51:28 +0000. Anything received after that time might be too late.
Build results:
total: 155 pass: 155 fail: 0 Qemu test results: total: 428 pass: 428 fail: 0
Guenter
Greg Kroah-Hartman
maintainerQuoted 6 lines · Guenter Roeck
Quoted 5 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.6.4 release. There are 38 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.
Quoted 8 lines
Quoted 3 lines
Responses should be made by Mon, 13 Apr 2020 11:51:28 +0000. Anything received after that time might be too late.
Build results:
total: 155 pass: 155 fail: 0 Qemu test results: total: 428 pass: 428 fail: 0
THanks for testing all of these and letting me know.
greg k-h
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.6.4 release. There are 38 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 Mon, 13 Apr 2020 11:51:28 +0000. 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.6.4-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.6.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.6.4-rc1
git repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
git branch: linux-5.6.y
git commit: 62251e4703ac6d416aeeec0bfe2af46dfa423a7b
git describe: v5.6.3-39-g62251e4703ac
Test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-5.6-oe/build/v5.6.3-39-g62251e4703ac
No regressions (compared to build v5.6.2-47-g4491f12cfc6a)
No fixes (compared to build v5.6.2-47-g4491f12cfc6a)
Ran 31688 total tests in the following environments and test suites.
Environments
--------------
- dragonboard-410c
- hi6220-hikey
- i386
- juno-r2
- juno-r2-compat
- juno-r2-kasan
- nxp-ls2088
- qemu_arm
- qemu_arm64
- qemu_i386
- qemu_x86_64
- x15
- x86
- x86-kasan
Test Suites
-----------
* build
* install-android-platform-tools-r2600
* install-android-platform-tools-r2800
* kselftest
* libgpiod
* libhugetlbfs
* linux-log-parser
* ltp-cap_bounds-tests
* ltp-containers-tests
* ltp-cpuhotplug-tests
* ltp-crypto-tests
* ltp-fcntl-locktests-tests
* ltp-filecaps-tests
* ltp-fs-tests
* ltp-fs_bind-tests
* ltp-fs_perms_simple-tests
* ltp-fsx-tests
* ltp-hugetlb-tests
* ltp-ipc-tests
* ltp-mm-tests
* ltp-nptl-tests
* ltp-pty-tests
* ltp-sched-tests
* ltp-securebits-tests
* ltp-syscalls-tests
* perf
* v4l2-compliance
* network-basic-tests
* kvm-unit-tests
* ltp-commands-tests
* ltp-cve-tests
* ltp-dio-tests
* ltp-io-tests
* ltp-math-tests
* ltp-open-posix-tests
* spectre-meltdown-checker-test
* 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.6.4 release. There are 38 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 Mon, 13 Apr 2020 11:51:28 +0000. 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.6.4-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.6.y
and the diffstat can be found below.
Quoted 6 lines
Quoted 3 lines
thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm,x86_64, and i386.
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.6.4 release. There are 38 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 Mon, 13 Apr 2020 11:51:28 +0000. 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.6.4-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.6.y
and the diffstat can be found below.thanks,
greg k-h
All tests are passing for Tegra ...
Test results for stable-v5.6:
13 builds: 13 pass, 0 fail
24 boots: 24 pass, 0 fail
40 tests: 40 pass, 0 failLinux version: 5.6.4-rc1-g62251e4703ac
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,
tegra194-p2972-0000, tegra20-ventana,
tegra210-p2371-2180, tegra210-p3450-0000,
tegra30-cardhu-a04Cheers
Jon
Signature · 1 line
nvpublic