5.4.69-rc1 review
Subsystems (10)
Greg Kroah-Hartman
maintainerPATCH 381/388 mm/gup: fix gup_fast with dynamic page table folding
In reply to Greg Kroah-HartmanFrom: Vasily Gorbik <[email protected]>
commit d3f7b1bb204099f2f7306318896223e8599bb6a2 upstream.
Currently to make sure that every page table entry is read just once gup_fast walks perform READ_ONCE and pass pXd value down to the next gup_pXd_range function by value e.g.:
static int gup_pud_range(p4d_t p4d, unsigned long addr, unsigned long end,
unsigned int flags, struct page **pages, int *nr)
...
pudp = pud_offset(&p4d, addr);
This function passes a reference on that local value copy to pXd_offset, and might get the very same pointer in return. This happens when the level is folded (on most arches), and that pointer should not be iterated.
On s390 due to the fact that each task might have different 5,4 or 3-level address translation and hence different levels folded the logic is more complex and non-iteratable pointer to a local copy leads to severe problems.
Here is an example of what happens with gup_fast on s390, for a task with 3-level paging, crossing a 2 GB pud boundary:
// addr = 0x1007ffff000, end = 0x10080001000
static int gup_pud_range(p4d_t p4d, unsigned long addr, unsigned long end,
unsigned int flags, struct page **pages, int *nr)
{
unsigned long next;
pud_t *pudp;
// pud_offset returns &p4d itself (a pointer to a value on stack)
pudp = pud_offset(&p4d, addr);
do {
// on second iteratation reading "random" stack value
pud_t pud = READ_ONCE(*pudp);
// next = 0x10080000000, due to PUD_SIZE/MASK != PGDIR_SIZE/MASK on s390
next = pud_addr_end(addr, end);
...
} while (pudp++, addr = next, addr != end); // pudp++ iterating over stack
return 1;}
This happens since s390 moved to common gup code with commit d1874a0c2805 ("s390/mm: make the pxd_offset functions more robust") and commit 1a42010cdc26 ("s390/mm: convert to the generic get_user_pages_fast code").
s390 tried to mimic static level folding by changing pXd_offset primitives to always calculate top level page table offset in pgd_offset and just return the value passed when pXd_offset has to act as folded.
What is crucial for gup_fast and what has been overlooked is that PxD_SIZE/MASK and thus pXd_addr_end should also change correspondingly. And the latter is not possible with dynamic folding.
To fix the issue in addition to pXd values pass original pXdp pointers down to gup_pXd_range functions. And introduce pXd_offset_lockless helpers, which take an additional pXd entry value parameter. This has already been discussed in
https://lkml.kernel.org/r/20190418100218.0a4afd51@mschwideX1
--- arch/s390/include/asm/pgtable.h | 44 +++++++++++++++++++++++++++++----------- include/asm-generic/pgtable.h | 10 +++++++++ mm/gup.c | 18 ++++++++-------- 3 files changed, 51 insertions(+), 21 deletions(-)
arch/s390/include/asm/pgtable.h +32 -12
@@ -1247,26 +1247,46 @@ static inline pgd_t *pgd_offset_raw(pgd_#define pgd_offset (mm, address) pgd_offset_raw(READ_ONCE((mm)->pgd), address)#define pgd_offset_k (address) pgd_offset(&init_mm, address) -static inline p4d_t *p4d_offset (pgd_t *pgd,unsigned long address) +static inline p4d_t *p4d_offset_lockless (pgd_t *pgdp,pgd_t pgd,unsigned long address) { -if ((pgd_val (*pgd) & _REGION_ENTRY_TYPE_MASK) >= _REGION_ENTRY_TYPE_R1) -return (p4d_t *)pgd_deref (*pgd) +p4d_index (address); -return (p4d_t *) pgd; +if ((pgd_val (pgd) & _REGION_ENTRY_TYPE_MASK) >= _REGION_ENTRY_TYPE_R1) +return (p4d_t *)pgd_deref (pgd) +p4d_index (address); +return (p4d_t *) pgdp; } +#define p4d_offset_lockless p4d_offset_lockless -static inline pud_t *pud_offset (p4d_t *p4d,unsigned long address) +static inline p4d_t *p4d_offset (pgd_t *pgdp,unsigned long address) { -if ((p4d_val (*p4d) & _REGION_ENTRY_TYPE_MASK) >= _REGION_ENTRY_TYPE_R2) -return (pud_t *)p4d_deref (*p4d) +pud_index (address); -return (pud_t *) p4d; +return p4d_offset_lockless (pgdp, *pgdp, address); } -static inline pmd_t *pmd_offset (pud_t *pud,unsigned long address) +static inline pud_t *pud_offset_lockless (p4d_t *p4dp,p4d_t p4d,unsigned long address) { -if ((pud_val (*pud) & _REGION_ENTRY_TYPE_MASK) >= _REGION_ENTRY_TYPE_R3) -return (pmd_t *)pud_deref (*pud) +pmd_index (address); -return (pmd_t *) pud; +if ((p4d_val (p4d) & _REGION_ENTRY_TYPE_MASK) >= _REGION_ENTRY_TYPE_R2) +return (pud_t *)p4d_deref (p4d) +pud_index (address); +return (pud_t *) p4dp; } +#define pud_offset_lockless pud_offset_lockless + +static inline pud_t *pud_offset (p4d_t *p4dp,unsigned long address) +{ +return pud_offset_lockless (p4dp, *p4dp, address); +} +#define pud_offset pud_offset + +static inline pmd_t *pmd_offset_lockless (pud_t *pudp,pud_t pud,unsigned long address) +{ +if ((pud_val (pud) & _REGION_ENTRY_TYPE_MASK) >= _REGION_ENTRY_TYPE_R3) +return (pmd_t *)pud_deref (pud) +pmd_index (address); +return (pmd_t *) pudp; +} +#define pmd_offset_lockless pmd_offset_lockless + +static inline pmd_t *pmd_offset (pud_t *pudp,unsigned long address) +{ +return pmd_offset_lockless (pudp, *pudp, address); +} +#define pmd_offset pmd_offsetstatic inline pte_t *pte_offset (pmd_t *pmd,unsigned long address) {
include/asm-generic/pgtable.h +10 -0
@@ -1171,6 +1171,16 @@ static inline bool arch_has_pfn_modify_c#endif #endif +#ifndef p4d_offset_lockless +#define p4d_offset_lockless (pgdp, pgd, address) p4d_offset(&(pgd), address) +#endif +#ifndef pud_offset_lockless +#define pud_offset_lockless (p4dp, p4d, address) pud_offset(&(p4d), address) +#endif +#ifndef pmd_offset_lockless +#define pmd_offset_lockless (pudp, pud, address) pmd_offset(&(pud), address) +#endif +/* * On some architectures it depends on the mm if the p4d/pud or pmd * layer of the page table hierarchy is folded or not.
mm/gup.c +9 -9
@@ -2184,13 +2184,13 @@ static int gup_huge_pgd(pgd_t orig, pgd_return 1 ; } -static int gup_pmd_range (pud_t pud,unsigned long addr,unsigned long end, +static int gup_pmd_range (pud_t *pudp,pud_t pud,unsigned long addr,unsigned long end,unsigned int flags,struct page **pages,int *nr) {unsigned long next;pmd_t *pmdp; - pmdp =pmd_offset (&pud, addr); + pmdp =pmd_offset_lockless (pudp, pud, addr); do { pmd_t pmd = READ_ONCE(*pmdp);
@@ -2227,13 +2227,13 @@ static int gup_pmd_range(pud_t pud, unsireturn 1 ; } -static int gup_pud_range (p4d_t p4d,unsigned long addr,unsigned long end, +static int gup_pud_range (p4d_t *p4dp,p4d_t p4d,unsigned long addr,unsigned long end,unsigned int flags,struct page **pages,int *nr) {unsigned long next;pud_t *pudp; - pudp =pud_offset (&p4d, addr); + pudp =pud_offset_lockless (p4dp, p4d, addr); do { pud_t pud = READ_ONCE(*pudp);
@@ -2248,20 +2248,20 @@ static int gup_pud_range(p4d_t p4d, unsiif (!gup_huge_pd (__hugepd (pud_val (pud)), addr,PUD_SHIFT , next, flags, pages, nr))return 0 ; - }else if (!gup_pmd_range (pud, addr, next, flags, pages, nr)) + }else if (!gup_pmd_range (pudp, pud, addr, next, flags, pages, nr))return 0 ; }while (pudp++, addr = next, addr != end);return 1 ; } -static int gup_p4d_range (pgd_t pgd,unsigned long addr,unsigned long end, +static int gup_p4d_range (pgd_t *pgdp,pgd_t pgd,unsigned long addr,unsigned long end,unsigned int flags,struct page **pages,int *nr) {unsigned long next;p4d_t *p4dp; - p4dp =p4d_offset (&pgd, addr); + p4dp =p4d_offset_lockless (pgdp, pgd, addr); do { p4d_t p4d = READ_ONCE(*p4dp);
@@ -2273,7 +2273,7 @@ static int gup_p4d_range(pgd_t pgd, unsiif (!gup_huge_pd (__hugepd (p4d_val (p4d)), addr,P4D_SHIFT , next, flags, pages, nr))return 0 ; - }else if (!gup_pud_range (p4d, addr, next, flags, pages, nr)) + }else if (!gup_pud_range (p4dp, p4d, addr, next, flags, pages, nr))return 0 ; }while (p4dp++, addr = next, addr != end);
@@ -2301,7 +2301,7 @@ static void gup_pgd_range(unsigned longif (!gup_huge_pd (__hugepd (pgd_val (pgd)), addr,PGDIR_SHIFT , next, flags, pages, nr))return ; - }else if (!gup_p4d_range (pgd, addr, next, flags, pages, nr)) + }else if (!gup_p4d_range (pgdp, pgd, addr, next, flags, pages, nr))return ; }while (pgdp++, addr = next, addr != end); }
Greg Kroah-Hartman
maintainerPATCH 380/388 mm, THP, swap: fix allocating cluster for swapfile by mistake
In reply to Greg Kroah-HartmanFrom: Gao Xiang <[email protected]>
commit 41663430588c737dd735bad5a0d1ba325dcabd59 upstream.
SWP_FS is used to make swap_{read,write}page() go through the filesystem, and it's only used for swap files over NFS. So, !SWP_FS means non NFS for now, it could be either file backed or device backed. Something similar goes with legacy SWP_FILE.
So in order to achieve the goal of the original patch, SWP_BLKDEV should be used instead.
FS corruption can be observed with SSD device + XFS + fragmented swapfile due to CONFIG_THP_SWAP=y.
I reproduced the issue with the following details:
Environment:
QEMU + upstream kernel + buildroot + NVMe (2 GB)
Kernel config:
CONFIG_BLK_DEV_NVME=y
CONFIG_THP_SWAP=y
Some reproducible steps:
mkfs.xfs -f /dev/nvme0n1
mkdir /tmp/mnt
mount /dev/nvme0n1 /tmp/mnt
bs="32k"
sz="1024m" # doesn't matter too much, I also tried 16m
xfs_io -f -c "pwrite -R -b $bs 0 $sz" -c "fdatasync" /tmp/mnt/sw xfs_io -f -c "pwrite -R -b $bs 0 $sz" -c "fdatasync" /tmp/mnt/sw xfs_io -f -c "pwrite -R -b $bs 0 $sz" -c "fdatasync" /tmp/mnt/sw xfs_io -f -c "pwrite -F -S 0 -b $bs 0 $sz" -c "fdatasync" /tmp/mnt/sw xfs_io -f -c "pwrite -R -b $bs 0 $sz" -c "fsync" /tmp/mnt/sw
mkswap /tmp/mnt/sw
swapon /tmp/mnt/sw
stress --vm 2 --vm-bytes 600M # doesn't matter too much as well
Symptoms:
- FS corruption (e.g. checksum failure)
- memory corruption at: 0xd2808010
- segfault
--- mm/swapfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/swapfile.c +1 -1
@@ -1038,7 +1038,7 @@ start_over: goto nextsi; }if (size ==SWAPFILE_CLUSTER ) { -if (!(si->flags &SWP_FS )) +if (si->flags &SWP_BLKDEV ) n_ret =swap_alloc_cluster (si, swp_entries); }else n_ret = scan_swap_map_slots(si, SWAP_HAS_CACHE,
Greg Kroah-Hartman
maintainerPATCH 347/388 drm/vc4/vc4_hdmi: fill ASoC card owner
In reply to Greg Kroah-HartmanFrom: Marek Szyprowski <[email protected]>
[ Upstream commit ec653df2a0cbc306a4bfcb0e3484d318fa779002 ]
card->owner is a required property and since commit 81033c6b584b ("ALSA:
core: Warn on empty module") a warning is issued if it is empty. Fix lack of it. This fixes following warning observed on RaspberryPi 3B board with ARM 32bit kernel and multi_v7_defconfig:
------------[ cut here ]------------ WARNING: CPU: 1 PID: 210 at sound/core/init.c:207 snd_card_new+0x378/0x398 [snd] Modules linked in: vc4(+) snd_soc_core ac97_bus snd_pcm_dmaengine bluetooth snd_pcm snd_timer crc32_arm_ce raspberrypi_hwmon snd soundcore ecdh_generic ecc bcm2835_thermal phy_generic CPU: 1 PID: 210 Comm: systemd-udevd Not tainted 5.8.0-rc1-00027-g81033c6b584b #1087 Hardware name: BCM2835 [<c03113c0>] (unwind_backtrace) from [<c030bcb4>] (show_stack+0x10/0x14) [<c030bcb4>] (show_stack) from [<c071cef8>] (dump_stack+0xd4/0xe8) [<c071cef8>] (dump_stack) from [<c0345bfc>] (__warn+0xdc/0xf4) [<c0345bfc>] (__warn) from [<c0345cc4>] (warn_slowpath_fmt+0xb0/0xb8) [<c0345cc4>] (warn_slowpath_fmt) from [<bf02ff74>] (snd_card_new+0x378/0x398 [snd]) [<bf02ff74>] (snd_card_new [snd]) from [<bf11f0b4>] (snd_soc_bind_card+0x280/0x99c [snd_soc_core]) [<bf11f0b4>] (snd_soc_bind_card [snd_soc_core]) from [<bf12f000>] (devm_snd_soc_register_card+0x34/0x6c [snd_soc_core]) [<bf12f000>] (devm_snd_soc_register_card [snd_soc_core]) from [<bf165654>] (vc4_hdmi_bind+0x43c/0x5f4 [vc4]) [<bf165654>] (vc4_hdmi_bind [vc4]) from [<c09d660c>] (component_bind_all+0xec/0x24c) [<c09d660c>] (component_bind_all) from [<bf15c44c>] (vc4_drm_bind+0xd4/0x174 [vc4]) [<bf15c44c>] (vc4_drm_bind [vc4]) from [<c09d6ac0>] (try_to_bring_up_master+0x160/0x1b0) [<c09d6ac0>] (try_to_bring_up_master) from [<c09d6f38>] (component_master_add_with_match+0xd0/0x104) [<c09d6f38>] (component_master_add_with_match) from [<bf15c588>] (vc4_platform_drm_probe+0x9c/0xbc [vc4]) [<bf15c588>] (vc4_platform_drm_probe [vc4]) from [<c09df740>] (platform_drv_probe+0x6c/0xa4) [<c09df740>] (platform_drv_probe) from [<c09dd6f0>] (really_probe+0x210/0x350) [<c09dd6f0>] (really_probe) from [<c09dd940>] (driver_probe_device+0x5c/0xb4) [<c09dd940>] (driver_probe_device) from [<c09ddb38>] (device_driver_attach+0x58/0x60) [<c09ddb38>] (device_driver_attach) from [<c09ddbc0>] (__driver_attach+0x80/0xbc) [<c09ddbc0>] (__driver_attach) from [<c09db820>] (bus_for_each_dev+0x68/0xb4) [<c09db820>] (bus_for_each_dev) from [<c09dc9f8>] (bus_add_driver+0x130/0x1e8) [<c09dc9f8>] (bus_add_driver) from [<c09de648>] (driver_register+0x78/0x110) [<c09de648>] (driver_register) from [<c0302038>] (do_one_initcall+0x50/0x220) [<c0302038>] (do_one_initcall) from [<c03db544>] (do_init_module+0x60/0x210) [<c03db544>] (do_init_module) from [<c03da4f8>] (load_module+0x1e34/0x2338) [<c03da4f8>] (load_module) from [<c03dac00>] (sys_finit_module+0xac/0xbc) [<c03dac00>] (sys_finit_module) from [<c03000c0>] (ret_fast_syscall+0x0/0x54) Exception stack(0xeded9fa8 to 0xeded9ff0) ... ---[ end trace 6414689569c2bc08 ]---
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/vc4/vc4_hdmi.c +1 -0
@@ -1125,6 +1125,7 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *hdmi) card->num_links =1 ; card->name ="vc4-hdmi" ; card->dev = dev; + card->owner =THIS_MODULE ;/* * Be careful, snd_soc_register_card() calls dev_set_drvdata() and
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 356/388 batman-adv: mcast: fix duplicate mcast packets from BLA backbone to mesh
In reply to Greg Kroah-HartmanFrom: Linus Lüssing <[email protected]>
[ Upstream commit 2369e827046920ef0599e6a36b975ac5c0a359c2 ]
Scenario:
* Multicast frame send from BLA backbone gateways (multiple nodes with their bat0 bridged together, with BLA enabled) sharing the same LAN to nodes in the mesh
Issue:
* Nodes receive the frame multiple times on bat0 from the mesh, once from each foreign BLA backbone gateway which shares the same LAN with another
For multicast frames via batman-adv broadcast packets coming from the same BLA backbone but from different backbone gateways duplicates are currently detected via a CRC history of previously received packets.
However this CRC so far was not performed for multicast frames received via batman-adv unicast packets. Fixing this by appyling the same check for such packets, too.
Room for improvements in the future: Ideally we would introduce the possibility to not only claim a client, but a complete originator, too. This would allow us to only send a multicast-in-unicast packet from a BLA backbone gateway claiming the node and by that avoid potential redundant transmissions in the first place.
--- net/batman-adv/bridge_loop_avoidance.c | 103 +++++++++++++++++++++---- 1 file changed, 87 insertions(+), 16 deletions(-)
net/batman-adv/bridge_loop_avoidance.c +87 -16
@@ -1581,13 +1581,16 @@ int batadv_bla_init(struct batadv_priv *bat_priv) }/** -* batadv_bla_check_bcast_duplist() - Check if a frame is in the broadcast dup. +* batadv_bla_check_duplist() - Check if a frame is in the broadcast dup. * @bat_priv: the bat priv with all the soft interface information -* @skb: contains the bcast_packet to be checked +* @skb: contains the multicast packet to be checked +* @payload_ptr: pointer to position inside the head buffer of the skb +* marking the start of the data to be CRC'ed +* @orig: originator mac address, NULL if unknown * -* check if it is on our broadcast list. Another gateway might -* have sent the same packet because it is connected to the same backbone, -* so we have to remove this duplicate. +* Check if it is on our broadcast list. Another gateway might have sent the +* same packet because it is connected to the same backbone, so we have to +* remove this duplicate. * * This is performed by checking the CRC, which will tell us * with a good chance that it is the same packet. If it is furthermore
@@ -1596,19 +1599,17 @@ int batadv_bla_init(struct batadv_priv *bat_priv)* * Return: true if a packet is in the duplicate list, false otherwise. */ -bool batadv_bla_check_bcast_duplist (struct batadv_priv *bat_priv, -struct sk_buff *skb) +static bool batadv_bla_check_duplist (struct batadv_priv *bat_priv, +struct sk_buff *skb,u8 *payload_ptr, +const u8 *orig) { -int i, curr; -__be32 crc; -struct batadv_bcast_packet *bcast_packet;struct batadv_bcast_duplist_entry *entry;bool ret = false; - - bcast_packet = (struct batadv_bcast_packet *)skb->data; +int i, curr; +__be32 crc;/* calculate the crc ... */ - crc =batadv_skb_crc32 (skb, (u8 *)(bcast_packet +1 )); + crc =batadv_skb_crc32 (skb, payload_ptr);spin_lock_bh (&bat_priv->bla.bcast_duplist_lock);
@@ -1627,8 +1628,21 @@ bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,if (entry->crc != crc)continue ; -if (batadv_compare_eth (entry->orig, bcast_packet->orig)) -continue ; +/* are the originators both known and not anonymous? */ +if (orig && !is_zero_ether_addr (orig) && + !is_zero_ether_addr (entry->orig)) { +/* If known, check if the new frame came from +* the same originator: +* We are safe to take identical frames from the +* same orig, if known, as multiplications in +* the mesh are detected via the (orig, seqno) pair. +* So we can be a bit more liberal here and allow +* identical frames from the same orig which the source +* host might have sent multiple times on purpose. +*/ +if (batadv_compare_eth (entry->orig, orig)) +continue ; + }/* this entry seems to match: same crc, not too old, * and from another gw. therefore return true to forbid it.
@@ -1644,7 +1658,14 @@ bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, entry = &bat_priv->bla.bcast_duplist[curr]; entry->crc = crc; entry->entrytime = jiffies; -ether_addr_copy (entry->orig, bcast_packet->orig); + +/* known originator */ +if (orig) +ether_addr_copy (entry->orig, orig); +/* anonymous originator */ +else +eth_zero_addr (entry->orig); + bat_priv->bla.bcast_duplist_curr = curr; out:
@@ -1653,6 +1674,48 @@ bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,return ret; } +/** +* batadv_bla_check_ucast_duplist() - Check if a frame is in the broadcast dup. +* @bat_priv: the bat priv with all the soft interface information +* @skb: contains the multicast packet to be checked, decapsulated from a +* unicast_packet +* +* Check if it is on our broadcast list. Another gateway might have sent the +* same packet because it is connected to the same backbone, so we have to +* remove this duplicate. +* +* Return: true if a packet is in the duplicate list, false otherwise. +*/ +static bool batadv_bla_check_ucast_duplist (struct batadv_priv *bat_priv, +struct sk_buff *skb) +{ +return batadv_bla_check_duplist (bat_priv, skb, (u8 *)skb->data,NULL ); +} + +/** +* batadv_bla_check_bcast_duplist() - Check if a frame is in the broadcast dup. +* @bat_priv: the bat priv with all the soft interface information +* @skb: contains the bcast_packet to be checked +* +* Check if it is on our broadcast list. Another gateway might have sent the +* same packet because it is connected to the same backbone, so we have to +* remove this duplicate. +* +* Return: true if a packet is in the duplicate list, false otherwise. +*/ +bool batadv_bla_check_bcast_duplist (struct batadv_priv *bat_priv, +struct sk_buff *skb) +{ +struct batadv_bcast_packet *bcast_packet; +u8 *payload_ptr; + + bcast_packet = (struct batadv_bcast_packet *)skb->data; + payload_ptr = (u8 *)(bcast_packet +1 ); + +return batadv_bla_check_duplist (bat_priv, skb, payload_ptr, + bcast_packet->orig); +} +/** * batadv_bla_is_backbone_gw_orig() - Check if the originator is a gateway for * the VLAN identified by vid.
@@ -1867,6 +1930,14 @@ bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, packet_type == BATADV_UNICAST) goto handled; +/* potential duplicates from foreign BLA backbone gateways via +* multicast-in-unicast packets +*/ +if (is_multicast_ether_addr (ethhdr->h_dest) && + packet_type ==BATADV_UNICAST && +batadv_bla_check_ucast_duplist (bat_priv, skb)) + goto handled; +ether_addr_copy (search_claim.addr, ethhdr->h_source); search_claim.vid = vid; claim =batadv_claim_hash_find (bat_priv, &search_claim);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 350/388 net: qed: RDMA personality shouldnt fail VF load
In reply to Greg Kroah-HartmanFrom: Dmitry Bogdanov <[email protected]>
[ Upstream commit ce1cf9e5025f4e2d2198728391f1847b3e168bc6 ]
Fix the assert during VF driver installation when the personality is iWARP
--- drivers/net/ethernet/qlogic/qed/qed_sriov.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/qlogic/qed/qed_sriov.c +1 -0
@@ -96,6 +96,7 @@ static int qed_sp_vf_start(struct qed_hwfn *p_hwfn, struct qed_vf_info *p_vf) p_ramrod->personality =PERSONALITY_ETH ;break ;case QED_PCI_ETH_ROCE : +case QED_PCI_ETH_IWARP : p_ramrod->personality =PERSONALITY_RDMA_AND_ETH ;break ;default :
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 370/388 ALSA: usb-audio: Add delay quirk for H570e USB headsets
In reply to Greg Kroah-HartmanFrom: Joakim Tjernlund <[email protected]>
commit 315c7ad7a701baba28c628c4c5426b3d9617ceed upstream.
Needs the same delay as H650e
--- sound/usb/quirks.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
sound/usb/quirks.c +4 -3
@@ -1604,12 +1604,13 @@ void snd_usb_ctl_msg_quirk(struct usb_de && (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)msleep (20 ); -/* Zoom R16/24, Logitech H650e, Jabra 550a, Kingston HyperX needs a tiny -* delay here, otherwise requests like get/set frequency return as -* failed despite actually succeeding. +/* Zoom R16/24, Logitech H650e/H570e, Jabra 550a, Kingston HyperX +* needs a tiny delay here, otherwise requests like get/set +* frequency return as failed despite actually succeeding. */ if ((chip->usb_id ==USB_ID (0x1686 ,0x00dd ) || chip->usb_id ==USB_ID (0x046d ,0x0a46 ) || + chip->usb_id ==USB_ID (0x046d ,0x0a56 ) || chip->usb_id ==USB_ID (0x0b0e ,0x0349 ) || chip->usb_id ==USB_ID (0x0951 ,0x16ad )) && (requesttype &USB_TYPE_MASK ) ==USB_TYPE_CLASS )
Greg Kroah-Hartman
maintainerPATCH 355/388 batman-adv: mcast: fix duplicate mcast packets in BLA backbone from mesh
In reply to Greg Kroah-HartmanFrom: Linus Lüssing <[email protected]>
[ Upstream commit 74c09b7275126da1b642b90c9cdc3ae8b729ad4b ]
Scenario:
* Multicast frame send from mesh to a BLA backbone (multiple nodes with their bat0 bridged together, with BLA enabled)
Issue:
* BLA backbone nodes receive the frame multiple times on bat0, once from mesh->bat0 and once from each backbone_gw from LAN
For unicast, a node will send only to the best backbone gateway according to the TQ. However for multicast we currently cannot determine if multiple destination nodes share the same backbone if they don't share the same backbone with us. So we need to keep sending the unicasts to all backbone gateways and let the backbone gateways decide which one will forward the frame. We can use the CLAIM mechanism to make this decision.
One catch: The batman-adv gateway feature for DHCP packets potentially sends multicast packets in the same batman-adv unicast header as the multicast optimizations code. And we are not allowed to drop those even if we did not claim the source address of the sender, as for such packets there is only this one multicast-in-unicast packet.
How can we distinguish the two cases?
The gateway feature uses a batman-adv unicast 4 address header. While the multicast-to-unicasts feature uses a simple, 3 address batman-adv unicast header. So let's use this to distinguish.
--- net/batman-adv/bridge_loop_avoidance.c | 34 +++++++++++++++++++------- net/batman-adv/bridge_loop_avoidance.h | 4 +-- net/batman-adv/soft-interface.c | 6 ++--- 3 files changed, 30 insertions(+), 14 deletions(-)
net/batman-adv/bridge_loop_avoidance.c +25 -9
@@ -1814,7 +1814,7 @@ batadv_bla_loopdetect_check(struct batadv_priv *bat_priv, struct sk_buff *skb,* @bat_priv: the bat priv with all the soft interface information * @skb: the frame to be checked * @vid: the VLAN ID of the frame -* @is_bcast: the packet came in a broadcast packet type. +* @packet_type: the batman packet type this frame came in * * batadv_bla_rx avoidance checks if: * * we have to race for a claim
@@ -1826,7 +1826,7 @@ batadv_bla_loopdetect_check(struct batadv_priv *bat_priv, struct sk_buff *skb,* further process the skb. */ bool batadv_bla_rx (struct batadv_priv *bat_priv,struct sk_buff *skb, -unsigned short vid,bool is_bcast) +unsigned short vid,int packet_type) {struct batadv_bla_backbone_gw *backbone_gw;struct ethhdr *ethhdr;
@@ -1848,9 +1848,24 @@ bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, goto handled;if (unlikely (atomic_read (&bat_priv->bla.num_requests))) -/* don't allow broadcasts while requests are in flight */ -if (is_multicast_ether_addr (ethhdr->h_dest) && is_bcast) - goto handled; +/* don't allow multicast packets while requests are in flight */ +if (is_multicast_ether_addr (ethhdr->h_dest)) +/* Both broadcast flooding or multicast-via-unicasts +* delivery might send to multiple backbone gateways +* sharing the same LAN and therefore need to coordinate +* which backbone gateway forwards into the LAN, +* by claiming the payload source address. +* +* Broadcast flooding and multicast-via-unicasts +* delivery use the following two batman packet types. +* Note: explicitly exclude BATADV_UNICAST_4ADDR, +* as the DHCP gateway feature will send explicitly +* to only one BLA gateway, so the claiming process +* should be avoided there. +*/ +if (packet_type ==BATADV_BCAST || + packet_type ==BATADV_UNICAST ) + goto handled;ether_addr_copy (search_claim.addr, ethhdr->h_source); search_claim.vid = vid;
@@ -1885,13 +1900,14 @@ bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, goto allow; } -/* if it is a broadcast ... */ -if (is_multicast_ether_addr (ethhdr->h_dest) && is_bcast) { +/* if it is a multicast ... */ +if (is_multicast_ether_addr (ethhdr->h_dest) && + (packet_type ==BATADV_BCAST || packet_type ==BATADV_UNICAST )) {/* ... drop it. the responsible gateway is in charge. * -* We need to check is_bcast because with the gateway +* We need to check packet type because with the gateway * feature, broadcasts (like DHCP requests) may be sent -* using a unicast packet type. +* using a unicast 4 address packet type. See comment above. */ goto handled; }else {
net/batman-adv/bridge_loop_avoidance.h +2 -2
@@ -35,7 +35,7 @@ static inline bool batadv_bla_is_loopdetect_mac(const uint8_t *mac)#ifdef CONFIG_BATMAN_ADV_BLA bool batadv_bla_rx (struct batadv_priv *bat_priv,struct sk_buff *skb, -unsigned short vid,bool is_bcast); +unsigned short vid,int packet_type);bool batadv_bla_tx (struct batadv_priv *bat_priv,struct sk_buff *skb,unsigned short vid); bool batadv_bla_is_backbone_gw(struct sk_buff *skb,
@@ -66,7 +66,7 @@ bool batadv_bla_check_claim(struct batadv_priv *bat_priv, u8 *addr,static inline bool batadv_bla_rx (struct batadv_priv *bat_priv,struct sk_buff *skb,unsigned short vid, -bool is_bcast) +int packet_type) {return false; }
net/batman-adv/soft-interface.c +3 -3
@@ -424,10 +424,10 @@ void batadv_interface_rx(struct net_device *soft_iface,struct vlan_ethhdr *vhdr;struct ethhdr *ethhdr;unsigned short vid; -bool is_bcast; +int packet_type; batadv_bcast_packet = (struct batadv_bcast_packet *)skb->data; - is_bcast = (batadv_bcast_packet->packet_type ==BATADV_BCAST ); + packet_type = batadv_bcast_packet->packet_type;skb_pull_rcsum (skb, hdr_size);skb_reset_mac_header (skb);
@@ -470,7 +470,7 @@ void batadv_interface_rx(struct net_device *soft_iface,/* Let the bridge loop avoidance check the packet. If will * not handle it, we can safely push it up. */ -if (batadv_bla_rx (bat_priv, skb, vid, is_bcast)) +if (batadv_bla_rx (bat_priv, skb, vid, packet_type)) goto out;if (orig_node)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 354/388 batman-adv: mcast: fix duplicate mcast packets in BLA backbone from LAN
In reply to Greg Kroah-HartmanFrom: Linus Lüssing <[email protected]>
[ Upstream commit 3236d215ad38a3f5372e65cd1e0a52cf93d3c6a2 ]
Scenario:
* Multicast frame send from a BLA backbone (multiple nodes with their bat0 bridged together, with BLA enabled)
Issue:
* BLA backbone nodes receive the frame multiple times on bat0
For multicast frames received via batman-adv broadcast packets the originator of the broadcast packet is checked before decapsulating and forwarding the frame to bat0 (batadv_bla_is_backbone_gw()-> batadv_recv_bcast_packet()). If it came from a node which shares the same BLA backbone with us then it is not forwarded to bat0 to avoid a loop.
When sending a multicast frame in a non-4-address batman-adv unicast packet we are currently missing this check - and cannot do so because the batman-adv unicast packet has no originator address field.
However, we can simply fix this on the sender side by only sending the multicast frame via unicasts to interested nodes which do not share the same BLA backbone with us. This also nicely avoids some unnecessary transmissions on mesh side.
Note that no infinite loop was observed, probably because of dropping via batadv_interface_tx()->batadv_bla_tx(). However the duplicates still utterly confuse switches/bridges, ICMPv6 duplicate address detection and neighbor discovery and therefore leads to long delays before being able to establish TCP connections, for instance. And it also leads to the Linux bridge printing messages like:
"br-lan: received packet on eth1 with own address as source address ..."
--- net/batman-adv/multicast.c | 46 ++++++++++++++++++++++++++------- net/batman-adv/multicast.h | 15 +++++++++++ net/batman-adv/soft-interface.c | 5 ++-- 3 files changed, 53 insertions(+), 13 deletions(-)
net/batman-adv/multicast.c +36 -10
@@ -51,6 +51,7 @@#include <uapi/linux/batadv_packet.h> #include <uapi/linux/batman_adv.h> +#include "bridge_loop_avoidance.h" #include "hard-interface.h" #include "hash.h" #include "log.h"
@@ -1434,6 +1435,35 @@ batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,return BATADV_FORW_ALL ; } +/** +* batadv_mcast_forw_send_orig() - send a multicast packet to an originator +* @bat_priv: the bat priv with all the soft interface information +* @skb: the multicast packet to send +* @vid: the vlan identifier +* @orig_node: the originator to send the packet to +* +* Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise. +*/ +int batadv_mcast_forw_send_orig (struct batadv_priv *bat_priv, +struct sk_buff *skb, +unsigned short vid, +struct batadv_orig_node *orig_node) +{ +/* Avoid sending multicast-in-unicast packets to other BLA +* gateways - they already got the frame from the LAN side +* we share with them. +* TODO: Refactor to take BLA into account earlier, to avoid +* reducing the mcast_fanout count. +*/ +if (batadv_bla_is_backbone_gw_orig (bat_priv, orig_node->orig, vid)) { +dev_kfree_skb (skb); +return NET_XMIT_SUCCESS ; + } + +return batadv_send_skb_unicast (bat_priv, skb,BATADV_UNICAST ,0 , + orig_node, vid); +} +/** * batadv_mcast_forw_tt() - forwards a packet to multicast listeners * @bat_priv: the bat priv with all the soft interface information
@@ -1471,8 +1501,8 @@ batadv_mcast_forw_tt(struct batadv_priv *bat_priv, struct sk_buff *skb,break ; } -batadv_send_skb_unicast (bat_priv, newskb,BATADV_UNICAST ,0 , - orig_entry->orig_node, vid); +batadv_mcast_forw_send_orig (bat_priv, newskb, vid, + orig_entry->orig_node); }rcu_read_unlock ();
@@ -1513,8 +1543,7 @@ batadv_mcast_forw_want_all_ipv4(struct batadv_priv *bat_priv,break ; } -batadv_send_skb_unicast (bat_priv, newskb,BATADV_UNICAST ,0 , - orig_node, vid); +batadv_mcast_forw_send_orig (bat_priv, newskb, vid, orig_node); }rcu_read_unlock ();return ret;
@@ -1551,8 +1580,7 @@ batadv_mcast_forw_want_all_ipv6(struct batadv_priv *bat_priv,break ; } -batadv_send_skb_unicast (bat_priv, newskb,BATADV_UNICAST ,0 , - orig_node, vid); +batadv_mcast_forw_send_orig (bat_priv, newskb, vid, orig_node); }rcu_read_unlock ();return ret;
@@ -1618,8 +1646,7 @@ batadv_mcast_forw_want_all_rtr4(struct batadv_priv *bat_priv,break ; } -batadv_send_skb_unicast (bat_priv, newskb,BATADV_UNICAST ,0 , - orig_node, vid); +batadv_mcast_forw_send_orig (bat_priv, newskb, vid, orig_node); }rcu_read_unlock ();return ret;
@@ -1656,8 +1683,7 @@ batadv_mcast_forw_want_all_rtr6(struct batadv_priv *bat_priv,break ; } -batadv_send_skb_unicast (bat_priv, newskb,BATADV_UNICAST ,0 , - orig_node, vid); +batadv_mcast_forw_send_orig (bat_priv, newskb, vid, orig_node); }rcu_read_unlock ();return ret;
net/batman-adv/multicast.h +15 -0
@@ -46,6 +46,11 @@ enum batadv_forw_mode batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb, struct batadv_orig_node **mcast_single_orig); +int batadv_mcast_forw_send_orig (struct batadv_priv *bat_priv, +struct sk_buff *skb, +unsigned short vid, +struct batadv_orig_node *orig_node); +int batadv_mcast_forw_send (struct batadv_priv *bat_priv,struct sk_buff *skb,unsigned short vid);
@@ -71,6 +76,16 @@ batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,return BATADV_FORW_ALL ; } +static inline int +batadv_mcast_forw_send_orig (struct batadv_priv *bat_priv, +struct sk_buff *skb, +unsigned short vid, +struct batadv_orig_node *orig_node) +{ +kfree_skb (skb); +return NET_XMIT_DROP ; +} +static inline int batadv_mcast_forw_send (struct batadv_priv *bat_priv,struct sk_buff *skb,unsigned short vid)
net/batman-adv/soft-interface.c +2 -3
@@ -364,9 +364,8 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb, goto dropped; ret =batadv_send_skb_via_gw (bat_priv, skb, vid); }else if (mcast_single_orig) { - ret =batadv_send_skb_unicast (bat_priv, skb, -BATADV_UNICAST ,0 , - mcast_single_orig, vid); + ret =batadv_mcast_forw_send_orig (bat_priv, skb, vid, + mcast_single_orig); }else if (forw_mode ==BATADV_FORW_SOME ) { ret =batadv_mcast_forw_send (bat_priv, skb, vid); }else {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 376/388 kprobes: Fix to check probe enabled before disarm_kprobe_ftrace()
In reply to Greg Kroah-HartmanFrom: Masami Hiramatsu <[email protected]>
commit 3031313eb3d549b7ad6f9fbcc52ba04412e3eb9e upstream.
Commit 0cb2f1372baa ("kprobes: Fix NULL pointer dereference at kprobe_ftrace_handler") fixed one bug but not completely fixed yet. If we run a kprobe_module.tc of ftracetest, kernel showed a warning as below.
# ./ftracetest test.d/kprobe/kprobe_module.tc === Ftrace unit tests === [1] Kprobe dynamic event - probing module ... [ 22.400215] ------------[ cut here ]------------ [ 22.400962] Failed to disarm kprobe-ftrace at trace_printk_irq_work+0x0/0x7e [trace_printk] (-2) [ 22.402139] WARNING: CPU: 7 PID: 200 at kernel/kprobes.c:1091 __disarm_kprobe_ftrace.isra.0+0x7e/0xa0 [ 22.403358] Modules linked in: trace_printk(-) [ 22.404028] CPU: 7 PID: 200 Comm: rmmod Not tainted 5.9.0-rc2+ #66 [ 22.404870] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1 04/01/2014 [ 22.406139] RIP: 0010:__disarm_kprobe_ftrace.isra.0+0x7e/0xa0 [ 22.406947] Code: 30 8b 03 eb c9 80 3d e5 09 1f 01 00 75 dc 49 8b 34 24 89 c2 48 c7 c7 a0 c2 05 82 89 45 e4 c6 05 cc 09 1f 01 01 e8 a9 c7 f0 ff <0f> 0b 8b 45 e4 eb b9 89 c6 48 c7 c7 70 c2 05 82 89 45 e4 e8 91 c7 [ 22.409544] RSP: 0018:ffffc90000237df0 EFLAGS: 00010286 [ 22.410385] RAX: 0000000000000000 RBX: ffffffff83066024 RCX: 0000000000000000 [ 22.411434] RDX: 0000000000000001 RSI: ffffffff810de8d3 RDI: ffffffff810de8d3 [ 22.412687] RBP: ffffc90000237e10 R08: 0000000000000001 R09: 0000000000000001 [ 22.413762] R10: 0000000000000000 R11: 0000000000000001 R12: ffff88807c478640 [ 22.414852] R13: ffffffff8235ebc0 R14: ffffffffa00060c0 R15: 0000000000000000 [ 22.415941] FS: 00000000019d48c0(0000) GS:ffff88807d7c0000(0000) knlGS:0000000000000000 [ 22.417264] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 22.418176] CR2: 00000000005bb7e3 CR3: 0000000078f7a000 CR4: 00000000000006a0 [ 22.419309] Call Trace: [ 22.419990] kill_kprobe+0x94/0x160 [ 22.420652] kprobes_module_callback+0x64/0x230 [ 22.421470] notifier_call_chain+0x4f/0x70 [ 22.422184] blocking_notifier_call_chain+0x49/0x70 [ 22.422979] __x64_sys_delete_module+0x1ac/0x240 [ 22.423733] do_syscall_64+0x38/0x50 [ 22.424366] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 22.425176] RIP: 0033:0x4bb81d [ 22.425741] Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 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 e0 ff ff ff f7 d8 64 89 01 48 [ 22.428726] RSP: 002b:00007ffc70fef008 EFLAGS: 00000246 ORIG_RAX: 00000000000000b0 [ 22.430169] RAX: ffffffffffffffda RBX: 00000000019d48a0 RCX: 00000000004bb81d [ 22.431375] RDX: 0000000000000000 RSI: 0000000000000880 RDI: 00007ffc70fef028 [ 22.432543] RBP: 0000000000000880 R08: 00000000ffffffff R09: 00007ffc70fef320 [ 22.433692] R10: 0000000000656300 R11: 0000000000000246 R12: 00007ffc70fef028 [ 22.434635] R13: 0000000000000000 R14: 0000000000000002 R15: 0000000000000000 [ 22.435682] irq event stamp: 1169 [ 22.436240] hardirqs last enabled at (1179): [<ffffffff810df542>] console_unlock+0x422/0x580 [ 22.437466] hardirqs last disabled at (1188): [<ffffffff810df19b>] console_unlock+0x7b/0x580 [ 22.438608] softirqs last enabled at (866): [<ffffffff81c0038e>] __do_softirq+0x38e/0x490 [ 22.439637] softirqs last disabled at (859): [<ffffffff81a00f42>] asm_call_on_stack+0x12/0x20 [ 22.440690] ---[ end trace 1e7ce7e1e4567276 ]--- [ 22.472832] trace_kprobe: This probe might be able to register after target module is loaded. Continue.
This is because the kill_kprobe() calls disarm_kprobe_ftrace() even if the given probe is not enabled. In that case, ftrace_set_filter_ip() fails because the given probe point is not registered to ftrace.
Fix to check the given (going) probe is enabled before invoking disarm_kprobe_ftrace().
--- kernel/kprobes.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/kprobes.c +3 -2
@@ -2110,9 +2110,10 @@ static void kill_kprobe(struct kprobe *p/* * The module is going away. We should disarm the kprobe which -* is using ftrace. +* is using ftrace, because ftrace framework is still available at +* MODULE_STATE_GOING notification. */ -if (kprobe_ftrace (p)) +if (kprobe_ftrace (p) && !kprobe_disabled (p) && !kprobes_all_disarmed)disarm_kprobe_ftrace (p); }
Greg Kroah-Hartman
maintainerPATCH 368/388 x86/ioapic: Unbreak check_timer()
In reply to Greg Kroah-HartmanFrom: Thomas Gleixner <[email protected]>
commit 86a82ae0b5095ea24c55898a3f025791e7958b21 upstream.
Several people reported in the kernel bugzilla that between v4.12 and v4.13 the magic which works around broken hardware and BIOSes to find the proper timer interrupt delivery mode stopped working for some older affected platforms which need to fall back to ExtINT delivery mode.
The reason is that the core code changed to keep track of the masked and disabled state of an interrupt line more accurately to avoid the expensive hardware operations.
That broke an assumption in i8259_make_irq() which invokes
disable_irq_nosync();
irq_set_chip_and_handler();
enable_irq();Up to v4.12 this worked because enable_irq() unconditionally unmasked the interrupt line, but after the state tracking improvements this is not longer the case because the IO/APIC uses lazy disabling. So the line state is unmasked which means that enable_irq() does not call into the new irq chip to unmask it.
In principle this is a shortcoming of the core code, but it's more than unclear whether the core code should try to reset state. At least this cannot be done unconditionally as that would break other existing use cases where the chip type is changed, e.g. when changing the trigger type, but the callers expect the state to be preserved.
As the way how check_timer() is switching the delivery modes is truly unique, the obvious fix is to simply unmask the i8259 manually after changing the mode to ExtINT delivery and switching the irq chip to the legacy PIC.
Note, that the fixes tag is not really precise, but identifies the commit which broke the assumptions in the IO/APIC and i8259 code and that's the kernel version to which this needs to be backported.
--- arch/x86/kernel/apic/io_apic.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/kernel/apic/io_apic.c +1 -0
@@ -2256,6 +2256,7 @@ static inline void __init check_timer(vo legacy_pic->init (0 ); legacy_pic->make_irq (0 );apic_write (APIC_LVT0 ,APIC_DM_EXTINT ); + legacy_pic->unmask (0 );unlock_ExtINT_logic ();
Greg Kroah-Hartman
maintainerPATCH 367/388 arch/x86/lib/usercopy_64.c: fix __copy_user_flushcache() cache writeback
In reply to Greg Kroah-HartmanFrom: Mikulas Patocka <[email protected]>
commit a1cd6c2ae47ee10ff21e62475685d5b399e2ed4a upstream.
If we copy less than 8 bytes and if the destination crosses a cache line, __copy_user_flushcache would invalidate only the first cache line.
This patch makes it invalidate the second cache line as well.
--- arch/x86/lib/usercopy_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/lib/usercopy_64.c +1 -1
@@ -120,7 +120,7 @@ long __copy_user_flushcache(void *dst, c*/ if (size <8 ) {if (!IS_ALIGNED (dest,4 ) || size !=4 ) -clean_cache_range (dst,1 ); +clean_cache_range (dst, size); }else {if (!IS_ALIGNED (dest,8 )) { dest =ALIGN (dest, boot_cpu_data.x86_clflush_size);
Greg Kroah-Hartman
maintainerPATCH 365/388 KVM: SVM: Add a dedicated INVD intercept routine
In reply to Greg Kroah-HartmanFrom: Tom Lendacky <[email protected]>
[ Upstream commit 4bb05f30483fd21ea5413eaf1182768f251cf625 ]
The INVD instruction intercept performs emulation. Emulation can't be done on an SEV guest because the guest memory is encrypted.
Provide a dedicated intercept routine for the INVD intercept. And since the instruction is emulated as a NOP, just skip it instead.
Message-Id: <a0b9a19ffa7fef86a3cc700c7ea01cb2731e04e5.1600972918.git.thomas.lendacky@amd.com>
--- arch/x86/kvm/svm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
arch/x86/kvm/svm.c +7 -1
@@ -3967,6 +3967,12 @@ static int iret_interception(struct vcpu_svm *svm)return 1 ; } +static int invd_interception (struct vcpu_svm *svm) +{ +/* Treat an INVD instruction as a NOP and just skip it. */ +return kvm_skip_emulated_instruction (&svm->vcpu); +} +static int invlpg_interception (struct vcpu_svm *svm) {if (!static_cpu_has (X86_FEATURE_DECODEASSISTS ))
@@ -4819,7 +4825,7 @@ static int (*const svm_exit_handlers[])(struct vcpu_svm *svm) = { [SVM_EXIT_RDPMC] = rdpmc_interception, [SVM_EXIT_CPUID] = cpuid_interception, [SVM_EXIT_IRET] = iret_interception, - [SVM_EXIT_INVD] = emulate_on_interception, + [SVM_EXIT_INVD] = invd_interception, [SVM_EXIT_PAUSE] = pause_interception, [SVM_EXIT_HLT] = halt_interception, [SVM_EXIT_INVLPG] = invlpg_interception,
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 366/388 mm: validate pmd after splitting
In reply to Greg Kroah-HartmanFrom: Minchan Kim <[email protected]>
[ Upstream commit ce2684254bd4818ca3995c0d021fb62c4cf10a19 ]
syzbot reported the following KASAN splat:
general protection fault, probably for non-canonical address 0xdffffc0000000003: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000018-0x000000000000001f]
CPU: 1 PID: 6826 Comm: syz-executor142 Not tainted 5.9.0-rc4-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:__lock_acquire+0x84/0x2ae0 kernel/locking/lockdep.c:4296
Code: ff df 8a 04 30 84 c0 0f 85 e3 16 00 00 83 3d 56 58 35 08 00 0f 84 0e 17 00 00 83 3d 25 c7 f5 07 00 74 2c 4c 89 e8 48 c1 e8 03 <80> 3c 30 00 74 12 4c 89 ef e8 3e d1 5a 00 48 be 00 00 00 00 00 fc
RSP: 0018:ffffc90004b9f850 EFLAGS: 00010006
Call Trace:
lock_acquire+0x140/0x6f0 kernel/locking/lockdep.c:5006
__raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline]
_raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:151
spin_lock include/linux/spinlock.h:354 [inline]
madvise_cold_or_pageout_pte_range+0x52f/0x25c0 mm/madvise.c:389
walk_pmd_range mm/pagewalk.c:89 [inline]
walk_pud_range mm/pagewalk.c:160 [inline]
walk_p4d_range mm/pagewalk.c:193 [inline]
walk_pgd_range mm/pagewalk.c:229 [inline]
__walk_page_range+0xe7b/0x1da0 mm/pagewalk.c:331
walk_page_range+0x2c3/0x5c0 mm/pagewalk.c:427
madvise_pageout_page_range mm/madvise.c:521 [inline]
madvise_pageout mm/madvise.c:557 [inline]
madvise_vma mm/madvise.c:946 [inline]
do_madvise+0x12d0/0x2090 mm/madvise.c:1145
__do_sys_madvise mm/madvise.c:1171 [inline]
__se_sys_madvise mm/madvise.c:1169 [inline]
__x64_sys_madvise+0x76/0x80 mm/madvise.c:1169
do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x44/0xa9The backing vma was shmem.
In case of split page of file-backed THP, madvise zaps the pmd instead of remapping of sub-pages. So we need to check pmd validity after split.
--- mm/madvise.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/madvise.c +1 -1
@@ -380,9 +380,9 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, return 0; } +regular_page:if (pmd_trans_unstable (pmd))return 0 ; -regular_page:#endif tlb_change_page_size (tlb,PAGE_SIZE ); orig_pte = pte =pte_offset_map_lock (vma->vm_mm, pmd, addr, &ptl);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 363/388 regulator: axp20x: fix LDO2/4 description
In reply to Greg Kroah-HartmanFrom: Icenowy Zheng <[email protected]>
[ Upstream commit fbb5a79d2fe7b01c6424fbbc04368373b1672d61 ]
Currently we wrongly set the mask of value of LDO2/4 both to the mask of LDO2, and the LDO4 voltage configuration is left untouched. This leads to conflict when LDO2/4 are both in use.
Fix this issue by setting different vsel_mask to both regulators.
--- drivers/regulator/axp20x-regulator.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/regulator/axp20x-regulator.c +4 -3
@@ -42,8 +42,9 @@#define AXP20X_DCDC2_V_OUT_MASK GENMASK(5, 0)#define AXP20X_DCDC3_V_OUT_MASK GENMASK(7, 0) -#define AXP20X_LDO24_V_OUT_MASK GENMASK(7, 4) +#define AXP20X_LDO2_V_OUT_MASK GENMASK(7, 4)#define AXP20X_LDO3_V_OUT_MASK GENMASK(6, 0) +#define AXP20X_LDO4_V_OUT_MASK GENMASK(3, 0)#define AXP20X_LDO5_V_OUT_MASK GENMASK(7, 4)#define AXP20X_PWR_OUT_EXTEN_MASK BIT_MASK(0)
@@ -544,14 +545,14 @@ static const struct regulator_desc axp20x_regulators[] = { AXP20X_PWR_OUT_CTRL, AXP20X_PWR_OUT_DCDC3_MASK),AXP_DESC_FIXED (AXP20X ,LDO1 ,"ldo1" ,"acin" ,1300 ),AXP_DESC (AXP20X ,LDO2 ,"ldo2" ,"ldo24in" ,1800 ,3300 ,100 , -AXP20X_LDO24_V_OUT ,AXP20X_LDO24_V_OUT_MASK , +AXP20X_LDO24_V_OUT ,AXP20X_LDO2_V_OUT_MASK ,AXP20X_PWR_OUT_CTRL ,AXP20X_PWR_OUT_LDO2_MASK ),AXP_DESC (AXP20X ,LDO3 ,"ldo3" ,"ldo3in" ,700 ,3500 ,25 ,AXP20X_LDO3_V_OUT ,AXP20X_LDO3_V_OUT_MASK ,AXP20X_PWR_OUT_CTRL ,AXP20X_PWR_OUT_LDO3_MASK ),AXP_DESC_RANGES (AXP20X ,LDO4 ,"ldo4" ,"ldo24in" , axp20x_ldo4_ranges,AXP20X_LDO4_V_OUT_NUM_VOLTAGES , -AXP20X_LDO24_V_OUT ,AXP20X_LDO24_V_OUT_MASK , +AXP20X_LDO24_V_OUT ,AXP20X_LDO4_V_OUT_MASK ,AXP20X_PWR_OUT_CTRL ,AXP20X_PWR_OUT_LDO4_MASK ), AXP_DESC_IO(AXP20X, LDO5, "ldo5", "ldo5in", 1800, 3300, 100, AXP20X_LDO5_V_OUT, AXP20X_LDO5_V_OUT_MASK,
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 362/388 MIPS: Add the missing CPU_1074K into __get_cpu_type()
In reply to Greg Kroah-HartmanFrom: Wei Li <[email protected]>
[ Upstream commit e393fbe6fa27af23f78df6e16a8fd2963578a8c4 ]
Commit 442e14a2c55e ("MIPS: Add 1074K CPU support explicitly.") split 1074K from the 74K as an unique CPU type, while it missed to add the 'CPU_1074K' in __get_cpu_type(). So let's add it back.
--- arch/mips/include/asm/cpu-type.h | 1 + 1 file changed, 1 insertion(+)
arch/mips/include/asm/cpu-type.h +1 -0
@@ -47,6 +47,7 @@ static inline int __pure __get_cpu_type(const int cpu_type)case CPU_34K :case CPU_1004K :case CPU_74K : +case CPU_1074K :case CPU_M14KC :case CPU_M14KEC :case CPU_INTERAPTIV :
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 361/388 regmap: fix page selection for noinc writes
In reply to Greg Kroah-HartmanFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit 05669b63170771d554854c0e465b76dc98fc7c84 ]
Non-incrementing writes can fail if register + length crosses page border. However for non-incrementing writes we should not check for page border crossing. Fix this by passing additional flag to _regmap_raw_write and passing length to _regmap_select_page basing on the flag.
--- drivers/base/regmap/internal.h | 2 +- drivers/base/regmap/regcache.c | 2 +- drivers/base/regmap/regmap.c | 21 +++++++++++---------- 3 files changed, 13 insertions(+), 12 deletions(-)
drivers/base/regmap/internal.h +1 -1
@@ -259,7 +259,7 @@ bool regcache_set_val(struct regmap *map, void *base, unsigned int idx,int regcache_lookup_reg (struct regmap *map,unsigned int reg);int _regmap_raw_write (struct regmap *map,unsigned int reg, -const void *val,size_t val_len); +const void *val,size_t val_len,bool noinc);void regmap_async_complete_cb (struct regmap_async *async,int ret);
drivers/base/regmap/regcache.c +1 -1
@@ -717,7 +717,7 @@ static int regcache_sync_block_raw_flush(struct regmap *map, const void **data, map->cache_bypass = true; - ret =_regmap_raw_write (map, base, *data, count * val_bytes); + ret =_regmap_raw_write (map, base, *data, count * val_bytes, false);if (ret)dev_err (map->dev,"Unable to sync registers %#x-%#x. %d\n" , base, cur - map->reg_stride, ret);
drivers/base/regmap/regmap.c +11 -10
@@ -1468,7 +1468,7 @@ static void regmap_set_work_buf_flag_mask(struct regmap *map, int max_bytes, }static int _regmap_raw_write_impl (struct regmap *map,unsigned int reg, -const void *val,size_t val_len) +const void *val,size_t val_len,bool noinc) {struct regmap_range_node *range;unsigned long flags;
@@ -1527,7 +1527,7 @@ static int _regmap_raw_write_impl(struct regmap *map, unsigned int reg, win_residue, val_len / map->format.val_bytes); ret =_regmap_raw_write_impl (map, reg, val, win_residue * - map->format.val_bytes); + map->format.val_bytes, noinc);if (ret !=0 )return ret;
@@ -1541,7 +1541,7 @@ static int _regmap_raw_write_impl(struct regmap *map, unsigned int reg, win_residue = range->window_len - win_offset; } - ret =_regmap_select_page (map, ®, range, val_num); + ret =_regmap_select_page (map, ®, range, noinc ?1 : val_num);if (ret !=0 )return ret; }
@@ -1749,7 +1749,8 @@ static int _regmap_bus_raw_write(void *context, unsigned int reg, map->work_buf + map->format.reg_bytes + map->format.pad_bytes, - map->format.val_bytes); + map->format.val_bytes, + false); }static inline void *_regmap_map_get_context (struct regmap *map)
@@ -1843,7 +1844,7 @@ int regmap_write_async(struct regmap *map, unsigned int reg, unsigned int val)EXPORT_SYMBOL_GPL (regmap_write_async);int _regmap_raw_write (struct regmap *map,unsigned int reg, -const void *val,size_t val_len) +const void *val,size_t val_len,bool noinc) {size_t val_bytes = map->format.val_bytes;size_t val_count = val_len / val_bytes;
@@ -1864,7 +1865,7 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg,/* Write as many bytes as possible with chunk_size */ for (i =0 ; i < chunk_count; i++) { - ret =_regmap_raw_write_impl (map, reg, val, chunk_bytes); + ret =_regmap_raw_write_impl (map, reg, val, chunk_bytes, noinc);if (ret)return ret;
@@ -1875,7 +1876,7 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg,/* Write remaining bytes */ if (val_len) - ret =_regmap_raw_write_impl (map, reg, val, val_len); + ret =_regmap_raw_write_impl (map, reg, val, val_len, noinc);return ret; }
@@ -1908,7 +1909,7 @@ int regmap_raw_write(struct regmap *map, unsigned int reg, map->lock (map->lock_arg); - ret =_regmap_raw_write (map, reg, val, val_len); + ret =_regmap_raw_write (map, reg, val, val_len, false); map->unlock (map->lock_arg);
@@ -1966,7 +1967,7 @@ int regmap_noinc_write(struct regmap *map, unsigned int reg, write_len = map->max_raw_write; else write_len = val_len; - ret =_regmap_raw_write (map, reg, val, write_len); + ret =_regmap_raw_write (map, reg, val, write_len, true);if (ret) goto out_unlock; val = ((u8 *)val) + write_len;
@@ -2443,7 +2444,7 @@ int regmap_raw_write_async(struct regmap *map, unsigned int reg, map->async = true; - ret =_regmap_raw_write (map, reg, val, val_len); + ret =_regmap_raw_write (map, reg, val, val_len, false); map->async = false;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 357/388 bpf: Fix a rcu warning for bpffs map pretty-print
In reply to Greg Kroah-HartmanFrom: Yonghong Song <[email protected]>
[ Upstream commit ce880cb825fcc22d4e39046a6c3a3a7f6603883d ]
Running selftest
./btf_btf -p
the kernel had the following warning:
[ 51.528185] WARNING: CPU: 3 PID: 1756 at kernel/bpf/hashtab.c:717 htab_map_get_next_key+0x2eb/0x300 [ 51.529217] Modules linked in: [ 51.529583] CPU: 3 PID: 1756 Comm: test_btf Not tainted 5.9.0-rc1+ #878 [ 51.530346] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.9.3-1.el7.centos 04/01/2014 [ 51.531410] RIP: 0010:htab_map_get_next_key+0x2eb/0x300 ... [ 51.542826] Call Trace: [ 51.543119] map_seq_next+0x53/0x80 [ 51.543528] seq_read+0x263/0x400 [ 51.543932] vfs_read+0xad/0x1c0 [ 51.544311] ksys_read+0x5f/0xe0 [ 51.544689] do_syscall_64+0x33/0x40 [ 51.545116] entry_SYSCALL_64_after_hwframe+0x44/0xa9
The related source code in kernel/bpf/hashtab.c:
709 static int htab_map_get_next_key(struct bpf_map *map, void *key, void *next_key) 710 {
711 struct bpf_htab *htab = container_of(map, struct bpf_htab, map); 712 struct hlist_nulls_head *head; 713 struct htab_elem *l, *next_l; 714 u32 hash, key_size; 715 int i = 0;
716
717 WARN_ON_ONCE(!rcu_read_lock_held());
In kernel/bpf/inode.c, bpffs map pretty print calls map->ops->map_get_next_key() without holding a rcu_read_lock(), hence causing the above warning.
To fix the issue, just surrounding map->ops->map_get_next_key() with rcu read lock.
--- kernel/bpf/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/bpf/inode.c +3 -1
@@ -205,10 +205,12 @@ static void *map_seq_next(struct seq_file *m, void *v, loff_t *pos)else prev_key = key; +rcu_read_lock ();if (map->ops->map_get_next_key (map, prev_key, key)) {map_iter (m)->done = true; -return NULL ; + key =NULL ; } +rcu_read_unlock ();return key; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 323/388 ASoC: pcm3168a: ignore 0 Hz settings
In reply to Greg Kroah-HartmanFrom: Kuninori Morimoto <[email protected]>
[ Upstream commit 7ad26d6671db758c959d7e1d100b138a38483612 ]
Some sound card try to set 0 Hz as reset, but it is impossible. This patch ignores it to avoid error return.
--- sound/soc/codecs/pcm3168a.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/soc/codecs/pcm3168a.c +7 -0
@@ -302,6 +302,13 @@ static int pcm3168a_set_dai_sysclk(struct snd_soc_dai *dai,struct pcm3168a_priv *pcm3168a =snd_soc_component_get_drvdata (dai->component);int ret; +/* +* Some sound card sets 0 Hz as reset, +* but it is impossible to set. Ignore it here +*/ +if (freq ==0 ) +return 0 ; +if (freq >PCM3168A_MAX_SYSCLK )return -EINVAL ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 314/388 ubi: fastmap: Free unused fastmap anchor peb during detach
In reply to Greg Kroah-HartmanFrom: Hou Tao <[email protected]>
[ Upstream commit c16f39d14a7e0ec59881fbdb22ae494907534384 ]
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_wl_entry(struct rb_root *root)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(struct ubi_device *ubi,for (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 ubi_device *ubi)return_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]);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 345/388 mac802154: tx: fix use-after-free
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 0ff4628f4c6c1ab87eef9f16b25355cadc426d64 ]
syzbot reported a bug in ieee802154_tx() [1]
A similar issue in ieee802154_xmit_worker() is also fixed in this patch.
[1]
BUG: KASAN: use-after-free in ieee802154_tx+0x3d2/0x480 net/mac802154/tx.c:88
Read of size 4 at addr ffff8880251a8c70 by task syz-executor.3/928
CPU: 0 PID: 928 Comm: syz-executor.3 Not tainted 5.9.0-rc3-syzkaller #0
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+0x198/0x1fd lib/dump_stack.c:118
print_address_description.constprop.0.cold+0xae/0x497 mm/kasan/report.c:383
__kasan_report mm/kasan/report.c:513 [inline]
kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530
ieee802154_tx+0x3d2/0x480 net/mac802154/tx.c:88
ieee802154_subif_start_xmit+0xbe/0xe4 net/mac802154/tx.c:130
__netdev_start_xmit include/linux/netdevice.h:4634 [inline]
netdev_start_xmit include/linux/netdevice.h:4648 [inline]
dev_direct_xmit+0x4e9/0x6e0 net/core/dev.c:4203
packet_snd net/packet/af_packet.c:2989 [inline]
packet_sendmsg+0x2413/0x5290 net/packet/af_packet.c:3014
sock_sendmsg_nosec net/socket.c:651 [inline]
sock_sendmsg+0xcf/0x120 net/socket.c:671
____sys_sendmsg+0x6e8/0x810 net/socket.c:2353
___sys_sendmsg+0xf3/0x170 net/socket.c:2407
__sys_sendmsg+0xe5/0x1b0 net/socket.c:2440
do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x45d5b9
Code: 5d b4 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 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 0f 83 2b b4 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fc98e749c78 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 000000000002ccc0 RCX: 000000000045d5b9
RDX: 0000000000000000 RSI: 0000000020007780 RDI: 000000000000000b
RBP: 000000000118d020 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000118cfec
R13: 00007fff690c720f R14: 00007fc98e74a9c0 R15: 000000000118cfec
Allocated by task 928:
kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48
kasan_set_track mm/kasan/common.c:56 [inline]
__kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:461
slab_post_alloc_hook mm/slab.h:518 [inline]
slab_alloc_node mm/slab.c:3254 [inline]
kmem_cache_alloc_node+0x136/0x3e0 mm/slab.c:3574
__alloc_skb+0x71/0x550 net/core/skbuff.c:198
alloc_skb include/linux/skbuff.h:1094 [inline]
alloc_skb_with_frags+0x92/0x570 net/core/skbuff.c:5771
sock_alloc_send_pskb+0x72a/0x880 net/core/sock.c:2348
packet_alloc_skb net/packet/af_packet.c:2837 [inline]
packet_snd net/packet/af_packet.c:2932 [inline]
packet_sendmsg+0x19fb/0x5290 net/packet/af_packet.c:3014
sock_sendmsg_nosec net/socket.c:651 [inline]
sock_sendmsg+0xcf/0x120 net/socket.c:671
____sys_sendmsg+0x6e8/0x810 net/socket.c:2353
___sys_sendmsg+0xf3/0x170 net/socket.c:2407
__sys_sendmsg+0xe5/0x1b0 net/socket.c:2440
do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x44/0xa9
Freed by task 928:
kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48
kasan_set_track+0x1c/0x30 mm/kasan/common.c:56
kasan_set_free_info+0x1b/0x30 mm/kasan/generic.c:355
__kasan_slab_free+0xd8/0x120 mm/kasan/common.c:422
__cache_free mm/slab.c:3418 [inline]
kmem_cache_free.part.0+0x74/0x1e0 mm/slab.c:3693
kfree_skbmem+0xef/0x1b0 net/core/skbuff.c:622
__kfree_skb net/core/skbuff.c:679 [inline]
consume_skb net/core/skbuff.c:838 [inline]
consume_skb+0xcf/0x160 net/core/skbuff.c:832
__dev_kfree_skb_any+0x9c/0xc0 net/core/dev.c:3107
fakelb_hw_xmit+0x20e/0x2a0 drivers/net/ieee802154/fakelb.c:81
drv_xmit_async net/mac802154/driver-ops.h:16 [inline]
ieee802154_tx+0x282/0x480 net/mac802154/tx.c:81
ieee802154_subif_start_xmit+0xbe/0xe4 net/mac802154/tx.c:130
__netdev_start_xmit include/linux/netdevice.h:4634 [inline]
netdev_start_xmit include/linux/netdevice.h:4648 [inline]
dev_direct_xmit+0x4e9/0x6e0 net/core/dev.c:4203
packet_snd net/packet/af_packet.c:2989 [inline]
packet_sendmsg+0x2413/0x5290 net/packet/af_packet.c:3014
sock_sendmsg_nosec net/socket.c:651 [inline]
sock_sendmsg+0xcf/0x120 net/socket.c:671
____sys_sendmsg+0x6e8/0x810 net/socket.c:2353
___sys_sendmsg+0xf3/0x170 net/socket.c:2407
__sys_sendmsg+0xe5/0x1b0 net/socket.c:2440
do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x44/0xa9
The buggy address belongs to the object at ffff8880251a8c00
which belongs to the cache skbuff_head_cache of size 224
The buggy address is located 112 bytes inside of
224-byte region [ffff8880251a8c00, ffff8880251a8ce0)
The buggy address belongs to the page:
page:0000000062b6a4f1 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x251a8
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea0000435c88 ffffea00028b6c08 ffff8880a9055d00
raw: 0000000000000000 ffff8880251a80c0 000000010000000c 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff8880251a8b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880251a8b80: fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880251a8c00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880251a8c80: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
ffff8880251a8d00: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb--- net/mac802154/tx.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
net/mac802154/tx.c +5 -3
@@ -34,11 +34,11 @@ void ieee802154_xmit_worker(struct work_struct *work)if (res) goto err_tx; -ieee802154_xmit_complete (&local->hw, skb, false); - dev->stats.tx_packets++; dev->stats.tx_bytes += skb->len; +ieee802154_xmit_complete (&local->hw, skb, false); +return ; err_tx:
@@ -78,6 +78,8 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb)/* async is priority, otherwise sync is fallback */ if (local->ops->xmit_async) { +unsigned int len = skb->len; + ret =drv_xmit_async (local, skb);if (ret) {ieee802154_wake_queue (&local->hw);
@@ -85,7 +87,7 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb) } dev->stats.tx_packets++; - dev->stats.tx_bytes += skb->len; + dev->stats.tx_bytes += len; }else { local->tx_skb = skb;queue_work (local->workqueue, &local->tx_work);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 346/388 bpf: Fix clobbering of r2 in bpf_gen_ld_abs
In reply to Greg Kroah-HartmanFrom: Daniel Borkmann <[email protected]>
[ Upstream commit e6a18d36118bea3bf497c9df4d9988b6df120689 ]
Bryce reported that he saw the following with:
0: r6 = r1 1: r1 = 12 2: r0 = *(u16 *)skb[r1]
The xlated sequence was incorrectly clobbering r2 with pointer value of r6 ...
0: (bf) r6 = r1
1: (b7) r1 = 12
2: (bf) r1 = r6
3: (bf) r2 = r1
4: (85) call bpf_skb_load_helper_16_no_cache#7692160
... and hence call to the load helper never succeeded given the offset was too high. Fix it by reordering the load of r6 to r1.
Other than that the insn has similar calling convention than BPF helpers, that is, r0 - r5 are scratch regs, so nothing else affected after the insn.
--- net/core/filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/core/filter.c +2 -2
@@ -6791,8 +6791,6 @@ static int bpf_gen_ld_abs(const struct bpf_insn *orig,bool indirect =BPF_MODE (orig->code) ==BPF_IND ;struct bpf_insn *insn = insn_buf; -/* We're guaranteed here that CTX is in R6. */ - *insn++ =BPF_MOV64_REG (BPF_REG_1 ,BPF_REG_CTX );if (!indirect) { *insn++ =BPF_MOV64_IMM (BPF_REG_2 , orig->imm); }else {
@@ -6800,6 +6798,8 @@ static int bpf_gen_ld_abs(const struct bpf_insn *orig,if (orig->imm) *insn++ =BPF_ALU64_IMM (BPF_ADD ,BPF_REG_2 , orig->imm); } +/* We're guaranteed here that CTX is in R6. */ + *insn++ =BPF_MOV64_REG (BPF_REG_1 ,BPF_REG_CTX );switch (BPF_SIZE (orig->code)) {case BPF_B :
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 342/388 atm: eni: fix the missed pci_disable_device() for eni_init_one()
In reply to Greg Kroah-HartmanFrom: Jing Xiangfeng <[email protected]>
[ Upstream commit c2b947879ca320ac5505c6c29a731ff17da5e805 ]
eni_init_one() misses to call pci_disable_device() in an error path. Jump to err_disable to fix it.
--- drivers/atm/eni.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/atm/eni.c +1 -1
@@ -2245,7 +2245,7 @@ static int eni_init_one(struct pci_dev *pci_dev, rc =dma_set_mask_and_coherent (&pci_dev->dev,DMA_BIT_MASK (32 ));if (rc <0 ) - goto out; + goto err_disable; rc = -ENOMEM ; eni_dev =kmalloc (sizeof (struct eni_dev ),GFP_KERNEL );
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 343/388 batman-adv: mcast/TT: fix wrongly dropped or rerouted packets
In reply to Greg Kroah-HartmanFrom: Linus Lüssing <[email protected]>
[ Upstream commit 7dda5b3384121181c4e79f6eaeac2b94c0622c8d ]
The unicast packet rerouting code makes several assumptions. For instance it assumes that there is always exactly one destination in the TT. This breaks for multicast frames in a unicast packets in several ways:
For one thing if there is actually no TT entry and the destination node was selected due to the multicast tvlv flags it announced. Then an intermediate node will wrongly drop the packet.
For another thing if there is a TT entry but the TTVN of this entry is newer than the originally addressed destination node: Then the intermediate node will wrongly redirect the packet, leading to duplicated multicast packets at a multicast listener and missing packets at other multicast listeners or multicast routers.
Fixing this by not applying the unicast packet rerouting to batman-adv unicast packets with a multicast payload. We are not able to detect a roaming multicast listener at the moment and will just continue to send the multicast frame to both the new and old destination for a while in case of such a roaming multicast listener.
--- net/batman-adv/routing.c | 4 ++++ 1 file changed, 4 insertions(+)
net/batman-adv/routing.c +4 -0
@@ -826,6 +826,10 @@ static bool batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, vid =batadv_get_vid (skb, hdr_len); ethhdr = (struct ethhdr *)(skb->data + hdr_len); +/* do not reroute multicast frames in a unicast header */ +if (is_multicast_ether_addr (ethhdr->h_dest)) +return true; +/* check if the destination client was served by this node and it is now * roaming. In this case, it means that the node has got a ROAM_ADV * message and that it knows the new destination in the mesh to re-route
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 341/388 batman-adv: bla: fix type misuse for backbone_gw hash indexing
In reply to Greg Kroah-HartmanFrom: Linus Lüssing <[email protected]>
[ Upstream commit 097930e85f90f252c44dc0d084598265dd44ca48 ]
It seems that due to a copy & paste error the void pointer in batadv_choose_backbone_gw() is cast to the wrong type.
Fixing this by using "struct batadv_bla_backbone_gw" instead of "struct batadv_bla_claim" which better matches the caller's side.
For now it seems that we were lucky because the two structs both have their orig/vid and addr/vid in the beginning. However I stumbled over this issue when I was trying to add some debug variables in front of "orig" in batadv_backbone_gw, which caused hash lookups to fail.
--- net/batman-adv/bridge_loop_avoidance.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/batman-adv/bridge_loop_avoidance.c +4 -3
@@ -83,11 +83,12 @@ static inline u32 batadv_choose_claim(const void *data, u32 size)*/ static inline u32 batadv_choose_backbone_gw (const void *data,u32 size) { -const struct batadv_bla_claim *claim = (struct batadv_bla_claim *)data; +const struct batadv_bla_backbone_gw *gw;u32 hash =0 ; - hash =jhash (&claim->addr,sizeof (claim->addr), hash); - hash =jhash (&claim->vid,sizeof (claim->vid), hash); + gw = (struct batadv_bla_backbone_gw *)data; + hash =jhash (&gw->orig,sizeof (gw->orig), hash); + hash =jhash (&gw->vid,sizeof (gw->vid), hash);return hash % size; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 334/388 drm/amdgpu/dc: Require primary plane to be enabled whenever the CRTC is
In reply to Greg Kroah-HartmanFrom: Michel Dänzer <[email protected]>
[ Upstream commit 2f228aab21bbc74e90e267a721215ec8be51daf7 ]
Don't check drm_crtc_state::active for this either, per its documentation in include/drm/drm_crtc.h:
* Hence drivers must not consult @active in their various
* &drm_mode_config_funcs.atomic_check callback to reject an atomic
* commit.
atomic_remove_fb disables the CRTC as needed for disabling the primary plane.
This prevents at least the following problems if the primary plane gets disabled (e.g. due to destroying the FB assigned to the primary plane, as happens e.g. with mutter in Wayland mode):
* The legacy cursor ioctl returned EINVAL for a non-0 cursor FB ID (which enables the cursor plane).
* If the cursor plane was enabled, changing the legacy DPMS property value from off to on returned EINVAL.
v2:
* Minor changes to code comment and commit log, per review feedback.
GitLab: https://gitlab.gnome.org/GNOME/mutter/-/issues/1108
GitLab: https://gitlab.gnome.org/GNOME/mutter/-/issues/1165
GitLab: https://gitlab.gnome.org/GNOME/mutter/-/issues/1344
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 32 ++++++------------- 1 file changed, 10 insertions(+), 22 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +10 -22
@@ -4299,19 +4299,6 @@ static void dm_crtc_helper_disable(struct drm_crtc *crtc) { } -static bool does_crtc_have_active_cursor (struct drm_crtc_state *new_crtc_state) -{ -struct drm_device *dev = new_crtc_state->crtc->dev; -struct drm_plane *plane; - -drm_for_each_plane_mask (plane, dev, new_crtc_state->plane_mask) { -if (plane->type ==DRM_PLANE_TYPE_CURSOR ) -return true; - } - -return false; -} -static int count_crtc_active_planes (struct drm_crtc_state *new_crtc_state) {struct drm_atomic_state *state = new_crtc_state->state;
@@ -4391,19 +4378,20 @@ static int dm_crtc_helper_atomic_check(struct drm_crtc *crtc,return ret; } -/* In some use cases, like reset, no stream is attached */ -if (!dm_crtc_state->stream) -return 0 ; -/* -* We want at least one hardware plane enabled to use -* the stream with a cursor enabled. +* We require the primary plane to be enabled whenever the CRTC is, otherwise +* drm_mode_cursor_universal may end up trying to enable the cursor plane while all other +* planes are disabled, which is not supported by the hardware. And there is legacy +* userspace which stops using the HW cursor altogether in response to the resulting EINVAL. */ -if (state->enable && state->active && -does_crtc_have_active_cursor (state) && - dm_crtc_state->active_planes ==0 ) +if (state->enable && + !(state->plane_mask &drm_plane_mask (crtc->primary)))return -EINVAL ; +/* In some use cases, like reset, no stream is attached */ +if (!dm_crtc_state->stream) +return 0 ; +if (dc_validate_stream (dc, dm_crtc_state->stream) ==DC_OK )return 0 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 316/388 opp: Increase parsed_static_opps in _of_add_opp_table_v1()
In reply to Greg Kroah-HartmanFrom: Walter Lozano <[email protected]>
[ Upstream commit 6544abc520f0fff701e9da382110dc29676c683a ]
Currently, when using _of_add_opp_table_v2 parsed_static_opps is increased and this value is used in _opp_remove_all_static() to check if there are static opp entries that need to be freed. Unfortunately this does not happen when using _of_add_opp_table_v1(), which leads to warnings.
This patch increases parsed_static_opps in _of_add_opp_table_v1() in a similar way as in _of_add_opp_table_v2().
[ Viresh: Do the operation with lock held and set the value to 1 instead
of incrementing it ]
--- drivers/opp/of.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/opp/of.c +4 -0
@@ -733,6 +733,10 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table)return -EINVAL ; } +mutex_lock (&opp_table->lock); + opp_table->parsed_static_opps =1 ; +mutex_unlock (&opp_table->lock); + val = prop->value;while (nr) {unsigned long freq =be32_to_cpup (val++) *1000 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 329/388 s390/init: add missing __init annotations
In reply to Greg Kroah-HartmanFrom: Ilya Leoshkevich <[email protected]>
[ Upstream commit fcb2b70cdb194157678fb1a75f9ff499aeba3d2a ]
Add __init to reserve_memory_end, reserve_oldmem and remove_oldmem. Sometimes these functions are not inlined, and then the build complains about section mismatch.
--- arch/s390/kernel/setup.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/s390/kernel/setup.c +3 -3
@@ -627,7 +627,7 @@ static struct notifier_block kdump_mem_nb = {/* * Make sure that the area behind memory_end is protected */ -static void reserve_memory_end (void ) +static void __init reserve_memory_end (void ) {if (memory_end_set)memblock_reserve (memory_end,ULONG_MAX );
@@ -636,7 +636,7 @@ static void reserve_memory_end(void)/* * Make sure that oldmem, where the dump is stored, is protected */ -static void reserve_oldmem (void ) +static void __init reserve_oldmem (void ) {#ifdef CONFIG_CRASH_DUMP if (OLDMEM_BASE )
@@ -648,7 +648,7 @@ static void reserve_oldmem(void)/* * Make sure that oldmem, where the dump is stored, is protected */ -static void remove_oldmem (void ) +static void __init remove_oldmem (void ) {#ifdef CONFIG_CRASH_DUMP if (OLDMEM_BASE )
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 333/388 drm/amd/display: update nv1x stutter latencies
In reply to Greg Kroah-HartmanFrom: Jun Lei <[email protected]>
[ Upstream commit c4790a8894232f39c25c7c546c06efe074e63384 ]
[why]
Recent characterization shows increased stutter latencies on some SKUs, leading to underflow.
[how]
Update SOC params to account for this worst case latency.
--- drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c +2 -2
@@ -340,8 +340,8 @@ struct _vcs_dpi_soc_bounding_box_st dcn2_0_nv14_soc = { }, }, .num_states = 5, - .sr_exit_time_us = 8.6, - .sr_enter_plus_exit_time_us = 10.9, + .sr_exit_time_us = 11.6, + .sr_enter_plus_exit_time_us = 13.9, .urgent_latency_us = 4.0, .urgent_latency_pixel_data_only_us = 4.0, .urgent_latency_pixel_mixed_with_vm_data_us = 4.0,
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 331/388 EDAC/ghes: Check whether the driver is on the safe list correctly
In reply to Greg Kroah-HartmanFrom: Borislav Petkov <[email protected]>
[ Upstream commit 251c54ea26fa6029b01a76161a37a12fde5124e4 ]
With CONFIG_DEBUG_TEST_DRIVER_REMOVE=y, a system would try to probe, unregister and probe again a driver.
When ghes_edac is attempted to be loaded on a system which is not on the safe platforms list, ghes_edac_register() would return early. The unregister counterpart ghes_edac_unregister() would still attempt to unregister and exit early at the refcount test, leading to the refcount underflow below.
In order to not do *anything* on the unregister path too, reuse the force_load parameter and check it on that path too, before fumbling with the refcount.
ghes_edac: ghes_edac_register: entry
ghes_edac: ghes_edac_register: return -ENODEV
------------[ cut here ]------------ refcount_t: underflow; use-after-free. WARNING: CPU: 10 PID: 1 at lib/refcount.c:28 refcount_warn_saturate+0xb9/0x100 Modules linked in: CPU: 10 PID: 1 Comm: swapper/0 Not tainted 5.9.0-rc4+ #12 Hardware name: GIGABYTE MZ01-CE1-00/MZ01-CE1-00, BIOS F02 08/29/2018 RIP: 0010:refcount_warn_saturate+0xb9/0x100 Code: 82 e8 fb 8f 4d 00 90 0f 0b 90 90 c3 80 3d 55 4c f5 00 00 75 88 c6 05 4c 4c f5 00 01 90 48 c7 c7 d0 8a 10 82 e8 d8 8f 4d 00 90 <0f> 0b 90 90 c3 80 3d 30 4c f5 00 00 0f 85 61 ff ff ff c6 05 23 4c RSP: 0018:ffffc90000037d58 EFLAGS: 00010292 RAX: 0000000000000026 RBX: ffff88840b8da000 RCX: 0000000000000000 RDX: 0000000000000001 RSI: ffffffff8216b24f RDI: 00000000ffffffff RBP: ffff88840c662e00 R08: 0000000000000001 R09: 0000000000000001 R10: 0000000000000001 R11: 0000000000000046 R12: 0000000000000000 R13: 0000000000000001 R14: 0000000000000000 R15: 0000000000000000 FS: 0000000000000000(0000) GS:ffff88840ee80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 0000800002211000 CR4: 00000000003506e0 Call Trace: ghes_edac_unregister ghes_remove platform_drv_remove really_probe driver_probe_device device_driver_attach __driver_attach ? device_driver_attach ? device_driver_attach bus_for_each_dev bus_add_driver driver_register ? bert_init ghes_init do_one_initcall ? rcu_read_lock_sched_held kernel_init_freeable ? rest_init kernel_init ret_from_fork ... ghes_edac: ghes_edac_unregister: FALSE, refcount: -1073741824
--- drivers/edac/ghes_edac.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/edac/ghes_edac.c +4 -0
@@ -488,6 +488,7 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev)if (!force_load && idx <0 )return -ENODEV ; }else { + force_load = true; idx =0 ; }
@@ -586,6 +587,9 @@ void ghes_edac_unregister(struct ghes *ghes)struct mem_ctl_info *mci;unsigned long flags; +if (!force_load) +return ; +mutex_lock (&ghes_reg_mutex);if (!refcount_dec_and_test (&ghes_refcount))
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 330/388 lockdep: fix order in trace_hardirqs_off_caller()
In reply to Greg Kroah-HartmanFrom: Sven Schnelle <[email protected]>
[ Upstream commit 73ac74c7d489756d2313219a108809921dbfaea1 ]
Switch order so that locking state is consistent even if the IRQ tracer calls into lockdep again.
--- kernel/trace/trace_preemptirq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/trace_preemptirq.c +2 -2
@@ -63,14 +63,14 @@ NOKPROBE_SYMBOL(trace_hardirqs_on_caller); __visible void trace_hardirqs_off_caller(unsigned long caller_addr) { +lockdep_hardirqs_off (CALLER_ADDR0 ); +if (!this_cpu_read (tracing_irq_cpu)) {this_cpu_write (tracing_irq_cpu,1 );tracer_hardirqs_off (CALLER_ADDR0 , caller_addr);if (!in_nmi ())trace_irq_disable_rcuidle (CALLER_ADDR0 , caller_addr); } - -lockdep_hardirqs_off (CALLER_ADDR0 ); }EXPORT_SYMBOL (trace_hardirqs_off_caller);NOKPROBE_SYMBOL (trace_hardirqs_off_caller);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 326/388 ASoC: Intel: bytcr_rt5640: Add quirk for MPMAN Converter9 2-in-1
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit 6a0137101f47301fff2da6ba4b9048383d569909 ]
The MPMAN Converter9 2-in-1 almost fully works with out default settings. The only problem is that it has only 1 speaker so any sounds only playing on the right channel get lost.
Add a quirk for this model using the default settings + MONO_SPEAKER.
--- sound/soc/intel/boards/bytcr_rt5640.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
sound/soc/intel/boards/bytcr_rt5640.c +10 -0
@@ -591,6 +591,16 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = {BYT_RT5640_SSP0_AIF1 | BYT_RT5640_MCLK_EN), }, + { /* MPMAN Converter 9, similar hw as the I.T.Works TW891 2-in-1 */ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"MPMAN" ), + DMI_MATCH(DMI_PRODUCT_NAME, "Converter9"), + }, + .driver_data = (void *)(BYTCR_INPUT_DEFAULTS | +BYT_RT5640_MONO_SPEAKER | +BYT_RT5640_SSP0_AIF1 | + BYT_RT5640_MCLK_EN), + }, {/* MPMAN MPWIN895CL */ .matches = {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 328/388 i2c: aspeed: Mask IRQ status to relevant bits
In reply to Greg Kroah-HartmanFrom: Eddie James <[email protected]>
[ Upstream commit 1a1d6db23ddacde0b15ea589e9103373e05af8de ]
Mask the IRQ status to only the bits that the driver checks. This prevents excessive driver warnings when operating in slave mode when additional bits are set that the driver doesn't handle.
--- drivers/i2c/busses/i2c-aspeed.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/i2c/busses/i2c-aspeed.c +2 -0
@@ -69,6 +69,7 @@* These share bit definitions, so use the same values for the enable & * status bits. */ +#define ASPEED_I2CD_INTR_RECV_MASK 0xf000ffff#define ASPEED_I2CD_INTR_SDA_DL_TIMEOUT BIT(14)#define ASPEED_I2CD_INTR_BUS_RECOVER_DONE BIT(13)#define ASPEED_I2CD_INTR_SLAVE_MATCH BIT(7)
@@ -604,6 +605,7 @@ static irqreturn_t aspeed_i2c_bus_irq(int irq, void *dev_id)writel (irq_received & ~ASPEED_I2CD_INTR_RX_DONE , bus->base +ASPEED_I2C_INTR_STS_REG );readl (bus->base +ASPEED_I2C_INTR_STS_REG ); + irq_received &=ASPEED_I2CD_INTR_RECV_MASK ; irq_remaining = irq_received;#if IS_ENABLED (CONFIG_I2C_SLAVE )
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 327/388 RISC-V: Take text_mutex in ftrace_init_nop()
In reply to Greg Kroah-HartmanFrom: Palmer Dabbelt <[email protected]>
[ Upstream commit 66d18dbda8469a944dfec6c49d26d5946efba218 ]
Without this we get lockdep failures. They're spurious failures as SMP isn't up when ftrace_init_nop() is called. As far as I can tell the easiest fix is to just take the lock, which also seems like the safest fix.
--- arch/riscv/include/asm/ftrace.h | 7 +++++++ arch/riscv/kernel/ftrace.c | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+)
arch/riscv/include/asm/ftrace.h +7 -0
@@ -63,4 +63,11 @@ do { \* Let auipc+jalr be the basic *mcount unit*, so we make it 8 bytes here. */ #define MCOUNT_INSN_SIZE 8 + +#ifndef __ASSEMBLY__ +struct dyn_ftrace ; +int ftrace_init_nop (struct module *mod,struct dyn_ftrace *rec); +#define ftrace_init_nop ftrace_init_nop +#endif +#endif
arch/riscv/kernel/ftrace.c +19 -0
@@ -88,6 +88,25 @@ int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec,return __ftrace_modify_call (rec->ip, addr, false); } + +/* +* This is called early on, and isn't wrapped by +* ftrace_arch_code_modify_{prepare,post_process}() and therefor doesn't hold +* text_mutex, which triggers a lockdep failure. SMP isn't running so we could +* just directly poke the text, but it's simpler to just take the lock +* ourselves. +*/ +int ftrace_init_nop (struct module *mod,struct dyn_ftrace *rec) +{ +int out; + +ftrace_arch_code_modify_prepare (); + out =ftrace_make_nop (mod, rec,MCOUNT_ADDR ); +ftrace_arch_code_modify_post_process (); + +return out; +} +int ftrace_update_ftrace_func (ftrace_func_t func) { int ret = __ftrace_modify_call((unsigned long)&ftrace_call,
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 325/388 ASoC: wm8994: Ensure the device is resumed in wm89xx_mic_detect functions
In reply to Greg Kroah-HartmanFrom: Sylwester Nawrocki <[email protected]>
[ Upstream commit f5a2cda4f1db89776b64c4f0f2c2ac609527ac70 ]
When the wm8958_mic_detect, wm8994_mic_detect functions get called from the machine driver, e.g. from the card's late_probe() callback, the CODEC device may be PM runtime suspended and any regmap writes have no effect. Add PM runtime calls to these functions to ensure the device registers are updated as expected.
This suppresses an error during boot
"wm8994-codec: ASoC: error at snd_soc_component_update_bits on wm8994-codec" caused by the regmap access error due to the cache_only flag being set.
--- sound/soc/codecs/wm8994.c | 8 ++++++++ 1 file changed, 8 insertions(+)
sound/soc/codecs/wm8994.c +8 -0
@@ -3372,6 +3372,8 @@ int wm8994_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *return -EINVAL ; } +pm_runtime_get_sync (component->dev); +switch (micbias) {case 1 : micdet = &wm8994->micdet[0 ];
@@ -3419,6 +3421,8 @@ int wm8994_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *snd_soc_dapm_sync (dapm); +pm_runtime_put (component->dev); +return 0 ; }EXPORT_SYMBOL_GPL (wm8994_mic_detect);
@@ -3786,6 +3790,8 @@ int wm8958_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *return -EINVAL ; } +pm_runtime_get_sync (component->dev); +if (jack) {snd_soc_dapm_force_enable_pin (dapm,"CLK_SYS" );snd_soc_dapm_sync (dapm);
@@ -3854,6 +3860,8 @@ int wm8958_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *snd_soc_dapm_sync (dapm); } +pm_runtime_put (component->dev); +return 0 ; }EXPORT_SYMBOL_GPL (wm8958_mic_detect);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 324/388 ASoC: wm8994: Skip setting of the WM8994_MICBIAS register for WM1811
In reply to Greg Kroah-HartmanFrom: Sylwester Nawrocki <[email protected]>
[ Upstream commit 811c5494436789e7149487c06e0602b507ce274b ]
The WM8994_MICBIAS register is not available in the WM1811 CODEC so skip initialization of that register for that device.
This suppresses an error during boot:
"wm8994-codec: ASoC: error at snd_soc_component_update_bits on wm8994-codec"
--- sound/soc/codecs/wm8994.c | 2 ++ sound/soc/codecs/wm_hubs.c | 3 +++ sound/soc/codecs/wm_hubs.h | 1 + 3 files changed, 6 insertions(+)
sound/soc/codecs/wm8994.c +2 -0
@@ -4047,11 +4047,13 @@ static int wm8994_component_probe(struct snd_soc_component *component) wm8994->hubs.dcs_readback_mode =2 ;break ; } + wm8994->hubs.micd_scthr = true;break ;case WM8958 : wm8994->hubs.dcs_readback_mode =1 ; wm8994->hubs.hp_startup_mode =1 ; + wm8994->hubs.micd_scthr = true;switch (control->revision) {case 0 :
sound/soc/codecs/wm_hubs.c +3 -0
@@ -1223,6 +1223,9 @@ int wm_hubs_handle_analogue_pdata(struct snd_soc_component *component,snd_soc_component_update_bits (component,WM8993_ADDITIONAL_CONTROL ,WM8993_LINEOUT2_FB ,WM8993_LINEOUT2_FB ); +if (!hubs->micd_scthr) +return 0 ; + snd_soc_component_update_bits(component, WM8993_MICBIAS, WM8993_JD_SCTHR_MASK | WM8993_JD_THR_MASK | WM8993_MICB1_LVL | WM8993_MICB2_LVL,
sound/soc/codecs/wm_hubs.h +1 -0
@@ -27,6 +27,7 @@ struct wm_hubs_data {int hp_startup_mode;int series_startup;int no_series_update; +bool micd_scthr;bool no_cache_dac_hp_direct;struct list_head dcs_cache;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 313/388 scsi: qla2xxx: Retry PLOGI on FC-NVMe PRLI failure
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
[ Upstream commit 983f127603fac650fa34ee69db363e4615eaf9e7 ]
Current code will send PRLI with FC-NVMe bit set for the targets which support only FCP. This may result into issue with targets which do not understand NVMe and will go into a strange state. This patch would restart the login process by going back to PLOGI state. The PLOGI state will force the target to respond to correct PRLI request.
--- drivers/scsi/qla2xxx/qla_init.c | 28 ++++------------------------ drivers/scsi/qla2xxx/qla_iocb.c | 6 +++++- 2 files changed, 9 insertions(+), 25 deletions(-)
drivers/scsi/qla2xxx/qla_init.c +4 -24
@@ -1911,33 +1911,13 @@ qla24xx_handle_prli_done_event(struct scsi_qla_host *vha, struct event_arg *ea)"%s %d %8phC post fc4 prli\n" , __func__, __LINE__, ea->fcport->port_name); ea->fcport->fc4f_nvme =0 ; -qla24xx_post_prli_work (vha, ea->fcport);return ; } -/* at this point both PRLI NVME & PRLI FCP failed */ -if (N2N_TOPO (vha->hw)) { -if (ea->fcport->n2n_link_reset_cnt <3 ) { - ea->fcport->n2n_link_reset_cnt++; -/* -* remote port is not sending Plogi. Reset -* link to kick start his state machine -*/ -set_bit (N2N_LINK_RESET , &vha->dpc_flags); - }else { -ql_log (ql_log_warn, vha,0x2119 , -"%s %d %8phC Unable to reconnect\n" , - __func__, __LINE__, ea->fcport->port_name); - } - }else { -/* -* switch connect. login failed. Take connection -* down and allow relogin to retrigger -*/ - ea->fcport->flags &= ~FCF_ASYNC_SENT ; - ea->fcport->keep_nport_handle =0 ; -qlt_schedule_sess_for_deletion (ea->fcport); - } + ea->fcport->flags &= ~FCF_ASYNC_SENT ; + ea->fcport->keep_nport_handle =0 ; + ea->fcport->logout_on_delete =1 ; +qlt_schedule_sess_for_deletion (ea->fcport);break ; } }
drivers/scsi/qla2xxx/qla_iocb.c +5 -1
@@ -2773,6 +2773,7 @@ static void qla2x00_els_dcmd2_sp_done(srb_t *sp, int res) ea.sp = sp;qla24xx_handle_plogi_done_event (vha, &ea);break ; +case CS_IOCB_ERROR :switch (fw_status[1 ]) {case LSC_SCODE_PORTID_USED :
@@ -2843,6 +2844,7 @@ static void qla2x00_els_dcmd2_sp_done(srb_t *sp, int res) fw_status[0], fw_status[1], fw_status[2]); fcport->flags &= ~FCF_ASYNC_SENT ; + fcport->disc_state =DSC_LOGIN_FAILED ;set_bit (RELOGIN_NEEDED , &vha->dpc_flags);break ; }
@@ -2855,6 +2857,7 @@ static void qla2x00_els_dcmd2_sp_done(srb_t *sp, int res) fw_status[0], fw_status[1], fw_status[2]); sp->fcport->flags &= ~FCF_ASYNC_SENT ; + sp->fcport->disc_state =DSC_LOGIN_FAILED ;set_bit (RELOGIN_NEEDED , &vha->dpc_flags);break ; }
@@ -2890,11 +2893,12 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *vha, int els_opcode,return -ENOMEM ; } + fcport->flags |=FCF_ASYNC_SENT ; + fcport->disc_state =DSC_LOGIN_PEND ; elsio = &sp->u.iocb_cmd;ql_dbg (ql_dbg_io, vha,0x3073 ,"Enter: PLOGI portid=%06x\n" , fcport->d_id.b24); - fcport->flags |=FCF_ASYNC_SENT ; sp->type =SRB_ELS_DCMD ; sp->name ="ELS_DCMD" ; sp->fcport = fcport;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 285/388 perf stat: Fix duration_time value for higher intervals
In reply to Greg Kroah-HartmanFrom: Jiri Olsa <[email protected]>
[ Upstream commit ea9eb1f456a08c18feb485894185f7a4e31cc8a4 ]
Joakim reported wrong duration_time value for interval bigger than 4000 [1].
The problem is in the interval value we pass to update_stats function, which is typed as 'unsigned int' and overflows when we get over 2^32 (happens between intervals 4000 and 5000).
Retyping the passed value to unsigned long long.
[1] https://www.spinics.net/lists/linux-perf-users/msg11777.html
--- tools/perf/builtin-stat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-stat.c +1 -1
@@ -351,7 +351,7 @@ static void process_interval(void) }init_stats (&walltime_nsecs_stats); -update_stats (&walltime_nsecs_stats, stat_config.interval *1000000 ); +update_stats (&walltime_nsecs_stats, stat_config.interval *1000000ULL );print_counters (&rs,0 ,NULL ); }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 312/388 perf tests: Fix test 68 zstd compression for s390
In reply to Greg Kroah-HartmanFrom: Thomas Richter <[email protected]>
[ Upstream commit 463538a383a27337cb83ae195e432a839a52d639 ]
Commit 5aa98879efe7 ("s390/cpum_sf: prohibit callchain data collection") prohibits call graph sampling for hardware events on s390. The information recorded is out of context and does not match.
On s390 this commit now breaks test case 68 Zstd perf.data compression/decompression.
Therefore omit call graph sampling on s390 in this test.
Output before:
[root@t35lp46 perf]# ./perf test -Fv 68
68: Zstd perf.data compression/decompression :
--- start ---
Collecting compressed record file:
Error:
cycles: PMU Hardware doesn't support sampling/overflow-interrupts.
Try 'perf stat'
---- end ----
Zstd perf.data compression/decompression: FAILED! [root@t35lp46 perf]#
Output after:
[root@t35lp46 perf]# ./perf test -Fv 68
68: Zstd perf.data compression/decompression :
--- start ---
Collecting compressed record file:
500+0 records in
500+0 records out
256000 bytes (256 kB, 250 KiB) copied, 0.00615638 s, 41.6 MB/s [ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.004 MB /tmp/perf.data.X3M,
compressed (original 0.002 MB, ratio is 3.609) ]
Checking compressed events stats:
# compressed : Zstd, level = 1, ratio = 4
COMPRESSED events: 1
2ELIFREPh---- end ----
Zstd perf.data compression/decompression: Ok
[root@t35lp46 perf]#--- tools/perf/tests/shell/record+zstd_comp_decomp.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/tests/shell/record+zstd_comp_decomp.sh +2 -1
@@ -12,7 +12,8 @@ skip_if_no_z_record() { collect_z_record() { echo "Collecting compressed record file:" - $perf_tool record -o $trace_file -g -z -F 5000 -- \ + [[ "$(uname -m)" != s390x ]] && gflag='-g' + $perf_tool record -o $trace_file $gflag -z -F 5000 -- \ dd count=500 if=/dev/urandom of=/dev/null }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 310/388 vfio/pci: fix racy on error and request eventfd ctx
In reply to Greg Kroah-HartmanFrom: Zeng Tao <[email protected]>
[ Upstream commit b872d0640840018669032b20b6375a478ed1f923 ]
The vfio_pci_release call will free and clear the error and request eventfd ctx while these ctx could be in use at the same time in the function like vfio_pci_request, and it's expected to protect them under the vdev->igate mutex, which is missing in vfio_pci_release.
This issue is introduced since commit 1518ac272e78 ("vfio/pci: fix memory leaks of eventfd ctx"),and since commit 5c5866c593bb ("vfio/pci: Clear error and request eventfd ctx after releasing"), it's very easily to trigger the kernel panic like this:
[ 9513.904346] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008 [ 9513.913091] Mem abort info: [ 9513.915871] ESR = 0x96000006 [ 9513.918912] EC = 0x25: DABT (current EL), IL = 32 bits [ 9513.924198] SET = 0, FnV = 0 [ 9513.927238] EA = 0, S1PTW = 0 [ 9513.930364] Data abort info: [ 9513.933231] ISV = 0, ISS = 0x00000006 [ 9513.937048] CM = 0, WnR = 0 [ 9513.940003] user pgtable: 4k pages, 48-bit VAs, pgdp=0000007ec7d12000 [ 9513.946414] [0000000000000008] pgd=0000007ec7d13003, p4d=0000007ec7d13003, pud=0000007ec728c003, pmd=0000000000000000 [ 9513.956975] Internal error: Oops: 96000006 [#1] PREEMPT SMP [ 9513.962521] Modules linked in: vfio_pci vfio_virqfd vfio_iommu_type1 vfio hclge hns3 hnae3 [last unloaded: vfio_pci] [ 9513.972998] CPU: 4 PID: 1327 Comm: bash Tainted: G W 5.8.0-rc4+ #3 [ 9513.980443] Hardware name: Huawei TaiShan 2280 V2/BC82AMDC, BIOS 2280-V2 CS V3.B270.01 05/08/2020 [ 9513.989274] pstate: 80400089 (Nzcv daIf +PAN -UAO BTYPE=--) [ 9513.994827] pc : _raw_spin_lock_irqsave+0x48/0x88 [ 9513.999515] lr : eventfd_signal+0x6c/0x1b0 [ 9514.003591] sp : ffff800038a0b960 [ 9514.006889] x29: ffff800038a0b960 x28: ffff007ef7f4da10 [ 9514.012175] x27: ffff207eefbbfc80 x26: ffffbb7903457000 [ 9514.017462] x25: ffffbb7912191000 x24: ffff007ef7f4d400 [ 9514.022747] x23: ffff20be6e0e4c00 x22: 0000000000000008 [ 9514.028033] x21: 0000000000000000 x20: 0000000000000000 [ 9514.033321] x19: 0000000000000008 x18: 0000000000000000 [ 9514.038606] x17: 0000000000000000 x16: ffffbb7910029328 [ 9514.043893] x15: 0000000000000000 x14: 0000000000000001 [ 9514.049179] x13: 0000000000000000 x12: 0000000000000002 [ 9514.054466] x11: 0000000000000000 x10: 0000000000000a00 [ 9514.059752] x9 : ffff800038a0b840 x8 : ffff007ef7f4de60 [ 9514.065038] x7 : ffff007fffc96690 x6 : fffffe01faffb748 [ 9514.070324] x5 : 0000000000000000 x4 : 0000000000000000 [ 9514.075609] x3 : 0000000000000000 x2 : 0000000000000001 [ 9514.080895] x1 : ffff007ef7f4d400 x0 : 0000000000000000 [ 9514.086181] Call trace: [ 9514.088618] _raw_spin_lock_irqsave+0x48/0x88 [ 9514.092954] eventfd_signal+0x6c/0x1b0 [ 9514.096691] vfio_pci_request+0x84/0xd0 [vfio_pci] [ 9514.101464] vfio_del_group_dev+0x150/0x290 [vfio] [ 9514.106234] vfio_pci_remove+0x30/0x128 [vfio_pci] [ 9514.111007] pci_device_remove+0x48/0x108 [ 9514.115001] device_release_driver_internal+0x100/0x1b8 [ 9514.120200] device_release_driver+0x28/0x38 [ 9514.124452] pci_stop_bus_device+0x68/0xa8 [ 9514.128528] pci_stop_and_remove_bus_device+0x20/0x38 [ 9514.133557] pci_iov_remove_virtfn+0xb4/0x128 [ 9514.137893] sriov_disable+0x3c/0x108 [ 9514.141538] pci_disable_sriov+0x28/0x38 [ 9514.145445] hns3_pci_sriov_configure+0x48/0xb8 [hns3] [ 9514.150558] sriov_numvfs_store+0x110/0x198 [ 9514.154724] dev_attr_store+0x44/0x60 [ 9514.158373] sysfs_kf_write+0x5c/0x78 [ 9514.162018] kernfs_fop_write+0x104/0x210 [ 9514.166010] __vfs_write+0x48/0x90 [ 9514.169395] vfs_write+0xbc/0x1c0 [ 9514.172694] ksys_write+0x74/0x100 [ 9514.176079] __arm64_sys_write+0x24/0x30 [ 9514.179987] el0_svc_common.constprop.4+0x110/0x200 [ 9514.184842] do_el0_svc+0x34/0x98 [ 9514.188144] el0_svc+0x14/0x40 [ 9514.191185] el0_sync_handler+0xb0/0x2d0 [ 9514.195088] el0_sync+0x140/0x180 [ 9514.198389] Code: b9001020 d2800000 52800022 f9800271 (885ffe61) [ 9514.204455] ---[ end trace 648de00c8406465f ]--- [ 9514.212308] note: bash[1327] exited with preempt_count 1
--- drivers/vfio/pci/vfio_pci.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/vfio/pci/vfio_pci.c +5 -0
@@ -474,14 +474,19 @@ static void vfio_pci_release(void *device_data)if (!(--vdev->refcnt)) {vfio_spapr_pci_eeh_release (vdev->pdev);vfio_pci_disable (vdev); +mutex_lock (&vdev->igate);if (vdev->err_trigger) {eventfd_ctx_put (vdev->err_trigger); vdev->err_trigger =NULL ; } +mutex_unlock (&vdev->igate); + +mutex_lock (&vdev->igate);if (vdev->req_trigger) {eventfd_ctx_put (vdev->req_trigger); vdev->req_trigger =NULL ; } +mutex_unlock (&vdev->igate); }mutex_unlock (&vdev->reflck->lock);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 308/388 scsi: libfc: Skip additional kref updating work event
In reply to Greg Kroah-HartmanFrom: Javed Hasan <[email protected]>
[ Upstream commit 823a65409c8990f64c5693af98ce0e7819975cba ]
When an rport event (RPORT_EV_READY) is updated without work being queued, avoid taking an additional reference.
This issue was leading to memory leak. Trace from KMEMLEAK tool:
unreferenced object 0xffff8888259e8780 (size 512):
comm "kworker/2:1", jiffies 4433237386 (age 113021.971s)
hex dump (first 32 bytes): 58 0a ec cf 83 88 ff ff 00 00 00 00 00 00 00 00 01 00 00 00 08 00 00 00 13 7d f0 1e 0e 00 00 10 backtrace: [<000000006b25760f>] fc_rport_recv_req+0x3c6/0x18f0 [libfc] [<00000000f208d994>] fc_lport_recv_els_req+0x120/0x8a0 [libfc] [<00000000a9c437b8>] fc_lport_recv+0xb9/0x130 [libfc] [<00000000a9c437b8>] fc_lport_recv+0xb9/0x130 [libfc] [<00000000ad5be37b>] qedf_ll2_process_skb+0x73d/0xad0 [qedf] [<00000000e0eb6893>] process_one_work+0x382/0x6c0 [<000000002dfd9e21>] worker_thread+0x57/0x5c0 [<00000000b648204f>] kthread+0x1a0/0x1c0 [<0000000072f5ab20>] ret_from_fork+0x35/0x40 [<000000001d5c05d8>] 0xffffffffffffffff
Below is the log sequence which leads to memory leak. Here we get the RPORT_EV_READY and RPORT_EV_STOP back to back, which lead to overwrite the event RPORT_EV_READY by event RPORT_EV_STOP. Because of this, kref_count gets incremented by 1.
kernel: host0: rport fffce5: Received PLOGI request
kernel: host0: rport fffce5: Received PLOGI in INIT state
kernel: host0: rport fffce5: Port is Ready
kernel: host0: rport fffce5: Received PRLI request while in state Ready
kernel: host0: rport fffce5: PRLI rspp type 8 active 1 passive 0
kernel: host0: rport fffce5: Received LOGO request while in state Ready
kernel: host0: rport fffce5: Delete port
kernel: host0: rport fffce5: Received PLOGI request
kernel: host0: rport fffce5: Received PLOGI in state Delete - send busy
kernel: host0: rport fffce5: work event 3
kernel: host0: rport fffce5: lld callback ev 3
kernel: host0: rport fffce5: work delete
--- drivers/scsi/libfc/fc_rport.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/scsi/libfc/fc_rport.c +5 -4
@@ -483,10 +483,11 @@ static void fc_rport_enter_delete(struct fc_rport_priv *rdata,fc_rport_state_enter (rdata,RPORT_ST_DELETE ); -kref_get (&rdata->kref); -if (rdata->event ==RPORT_EV_NONE && - !queue_work (rport_event_queue, &rdata->event_work)) -kref_put (&rdata->kref, fc_rport_destroy); +if (rdata->event ==RPORT_EV_NONE ) { +kref_get (&rdata->kref); +if (!queue_work (rport_event_queue, &rdata->event_work)) +kref_put (&rdata->kref, fc_rport_destroy); + } rdata->event = event; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 309/388 selftests/x86/syscall_nt: Clear weird flags after each test
In reply to Greg Kroah-HartmanFrom: Andy Lutomirski <[email protected]>
[ Upstream commit a61fa2799ef9bf6c4f54cf7295036577cececc72 ]
Clear the weird flags before logging to improve strace output -- logging results while, say, TF is set does no one any favors.
--- tools/testing/selftests/x86/syscall_nt.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/x86/syscall_nt.c +1 -0
@@ -59,6 +59,7 @@ static void do_it(unsigned long extraflags)set_eflags (get_eflags () | extraflags);syscall (SYS_getpid); flags =get_eflags (); +set_eflags (X86_EFLAGS_IF |X86_EFLAGS_FIXED );if ((flags & extraflags) == extraflags) {printf ("[OK]\tThe syscall worked and flags are still set\n" ); }else {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 304/388 cifs: Fix double add page to memcg when cifs_readpages
In reply to Greg Kroah-HartmanFrom: Zhang Xiaoxu <[email protected]>
[ Upstream commit 95a3d8f3af9b0d63b43f221b630beaab9739d13a ]
When xfstests generic/451, there is an BUG at mm/memcontrol.c:
page:ffffea000560f2c0 refcount:2 mapcount:0 mapping:000000008544e0ea
index:0xf
mapping->aops:cifs_addr_ops dentry name:"tst-aio-dio-cycle-write.451"
flags: 0x2fffff80000001(locked)
raw: 002fffff80000001 ffffc90002023c50 ffffea0005280088 ffff88815cda0210
raw: 000000000000000f 0000000000000000 00000002ffffffff ffff88817287d000
page dumped because: VM_BUG_ON_PAGE(page->mem_cgroup)
page->mem_cgroup:ffff88817287d000
------------[ cut here ]------------
kernel BUG at mm/memcontrol.c:2659!
invalid opcode: 0000 [#1] SMP
CPU: 2 PID: 2038 Comm: xfs_io Not tainted 5.8.0-rc1 #44
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20190727_
073836-buildvm-ppc64le-16.ppc.4
RIP: 0010:commit_charge+0x35/0x50
Code: 0d 48 83 05 54 b2 02 05 01 48 89 77 38 c3 48 c7
c6 78 4a ea ba 48 83 05 38 b2 02 05 01 e8 63 0d9
RSP: 0018:ffffc90002023a50 EFLAGS: 00010202
RAX: 0000000000000000 RBX: ffff88817287d000 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffff88817ac97ea0 RDI: ffff88817ac97ea0
RBP: ffffea000560f2c0 R08: 0000000000000203 R09: 0000000000000005
R10: 0000000000000030 R11: ffffc900020237a8 R12: 0000000000000000
R13: 0000000000000001 R14: 0000000000000001 R15: ffff88815a1272c0
FS: 00007f5071ab0800(0000) GS:ffff88817ac80000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055efcd5ca000 CR3: 000000015d312000 CR4: 00000000000006e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
mem_cgroup_charge+0x166/0x4f0
__add_to_page_cache_locked+0x4a9/0x710
add_to_page_cache_locked+0x15/0x20
cifs_readpages+0x217/0x1270
read_pages+0x29a/0x670
page_cache_readahead_unbounded+0x24f/0x390
__do_page_cache_readahead+0x3f/0x60
ondemand_readahead+0x1f1/0x470
page_cache_async_readahead+0x14c/0x170
generic_file_buffered_read+0x5df/0x1100
generic_file_read_iter+0x10c/0x1d0
cifs_strict_readv+0x139/0x170
new_sync_read+0x164/0x250
__vfs_read+0x39/0x60
vfs_read+0xb5/0x1e0
ksys_pread64+0x85/0xf0
__x64_sys_pread64+0x22/0x30
do_syscall_64+0x69/0x150
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7f5071fcb1af
Code: Bad RIP value.
RSP: 002b:00007ffde2cdb8e0 EFLAGS: 00000293 ORIG_RAX: 0000000000000011
RAX: ffffffffffffffda RBX: 00007ffde2cdb990 RCX: 00007f5071fcb1af
RDX: 0000000000001000 RSI: 000055efcd5ca000 RDI: 0000000000000003
RBP: 0000000000000003 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000001000 R11: 0000000000000293 R12: 0000000000000001
R13: 000000000009f000 R14: 0000000000000000 R15: 0000000000001000
Modules linked in:
---[ end trace 725fa14a3e1af65c ]---Since commit 3fea5a499d57 ("mm: memcontrol: convert page cache to a new mem_cgroup_charge() API") not cancel the page charge, the pages maybe double add to pagecache:
thread1 | thread2cifs_readpagesreadpages_get_pages
add_to_page_cache_locked(head,index=n)=0
| readpages_get_pages
| add_to_page_cache_locked(head,index=n+1)=0 add_to_page_cache_locked(head, index=n+1)=-EEXIST then, will next loop with list head page's index=n+1 and the page->mapping not NULLreadpages_get_pages add_to_page_cache_locked(head, index=n+1)
commit_charge
VM_BUG_ON_PAGE
So, we should not do the next loop when any page add to page cache failed.
--- fs/cifs/file.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
fs/cifs/file.c +7 -4
@@ -4269,7 +4269,8 @@ readpages_get_pages(struct address_space *mapping, struct list_head *page_list,break ;__SetPageLocked (page); -if (add_to_page_cache_locked (page, mapping, page->index, gfp)) { + rc =add_to_page_cache_locked (page, mapping, page->index, gfp); +if (rc) {__ClearPageLocked (page);break ; }
@@ -4285,6 +4286,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, struct list_head *page_list, unsigned num_pages) { int rc; +int err =0 ;struct list_head tmplist;struct cifsFileInfo *open_file = file->private_data;struct cifs_sb_info *cifs_sb =CIFS_FILE_SB (file);
@@ -4329,7 +4331,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,* the order of declining indexes. When we put the pages in * the rdata->pages, then we want them in increasing order. */ -while (!list_empty (page_list)) { +while (!list_empty (page_list) && !err) {unsigned int i, nr_pages, bytes, rsize;loff_t offset;struct page *page, *tpage;
@@ -4362,9 +4364,10 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,return 0 ; } - rc =readpages_get_pages (mapping, page_list, rsize, &tmplist, + nr_pages =0 ; + err =readpages_get_pages (mapping, page_list, rsize, &tmplist, &nr_pages, &offset, &bytes); -if (rc) { +if (!nr_pages) {add_credits_and_wake_if (server, credits,0 );break ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 305/388 nvme: fix possible deadlock when I/O is blocked
In reply to Greg Kroah-HartmanFrom: Sagi Grimberg <[email protected]>
[ Upstream commit 3b4b19721ec652ad2c4fe51dfbe5124212b5f581 ]
Revert fab7772bfbcf ("nvme-multipath: revalidate nvme_ns_head gendisk in nvme_validate_ns")
When adding a new namespace to the head disk (via nvme_mpath_set_live) we will see partition scan which triggers I/O on the mpath device node. This process will usually be triggered from the scan_work which holds the scan_lock. If I/O blocks (if we got ana change currently have only available paths but none are accessible) this can deadlock on the head disk bd_mutex as both partition scan I/O takes it, and head disk revalidation takes it to check for resize (also triggered from scan_work on a different path). See trace [1].
The mpath disk revalidation was originally added to detect online disk size change, but this is no longer needed since commit cb224c3af4df ("nvme: Convert to use set_capacity_revalidate_and_notify") which already updates resize info without unnecessarily revalidating the disk (the mpath disk doesn't even implement .revalidate_disk fop).
[1]:
--
kernel: INFO: task kworker/u65:9:494 blocked for more than 241 seconds. kernel: Tainted: G OE 5.3.5-050305-generic #201910071830 kernel: "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. kernel: kworker/u65:9 D 0 494 2 0x80004000 kernel: Workqueue: nvme-wq nvme_scan_work [nvme_core] kernel: Call Trace: kernel: __schedule+0x2b9/0x6c0 kernel: schedule+0x42/0xb0 kernel: schedule_preempt_disabled+0xe/0x10 kernel: __mutex_lock.isra.0+0x182/0x4f0 kernel: __mutex_lock_slowpath+0x13/0x20 kernel: mutex_lock+0x2e/0x40 kernel: revalidate_disk+0x63/0xa0 kernel: __nvme_revalidate_disk+0xfe/0x110 [nvme_core] kernel: nvme_revalidate_disk+0xa4/0x160 [nvme_core] kernel: ? evict+0x14c/0x1b0 kernel: revalidate_disk+0x2b/0xa0 kernel: nvme_validate_ns+0x49/0x940 [nvme_core] kernel: ? blk_mq_free_request+0xd2/0x100 kernel: ? __nvme_submit_sync_cmd+0xbe/0x1e0 [nvme_core] kernel: nvme_scan_work+0x24f/0x380 [nvme_core] kernel: process_one_work+0x1db/0x380 kernel: worker_thread+0x249/0x400 kernel: kthread+0x104/0x140 kernel: ? process_one_work+0x380/0x380 kernel: ? kthread_park+0x80/0x80 kernel: ret_from_fork+0x1f/0x40 ... kernel: INFO: task kworker/u65:1:2630 blocked for more than 241 seconds. kernel: Tainted: G OE 5.3.5-050305-generic #201910071830 kernel: "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. kernel: kworker/u65:1 D 0 2630 2 0x80004000 kernel: Workqueue: nvme-wq nvme_scan_work [nvme_core] kernel: Call Trace: kernel: __schedule+0x2b9/0x6c0 kernel: schedule+0x42/0xb0 kernel: io_schedule+0x16/0x40 kernel: do_read_cache_page+0x438/0x830 kernel: ? __switch_to_asm+0x34/0x70 kernel: ? file_fdatawait_range+0x30/0x30 kernel: read_cache_page+0x12/0x20 kernel: read_dev_sector+0x27/0xc0 kernel: read_lba+0xc1/0x220 kernel: ? kmem_cache_alloc_trace+0x19c/0x230 kernel: efi_partition+0x1e6/0x708 kernel: ? vsnprintf+0x39e/0x4e0 kernel: ? snprintf+0x49/0x60 kernel: check_partition+0x154/0x244 kernel: rescan_partitions+0xae/0x280 kernel: __blkdev_get+0x40f/0x560 kernel: blkdev_get+0x3d/0x140 kernel: __device_add_disk+0x388/0x480 kernel: device_add_disk+0x13/0x20 kernel: nvme_mpath_set_live+0x119/0x140 [nvme_core] kernel: nvme_update_ns_ana_state+0x5c/0x60 [nvme_core] kernel: nvme_set_ns_ana_state+0x1e/0x30 [nvme_core] kernel: nvme_parse_ana_log+0xa1/0x180 [nvme_core] kernel: ? nvme_update_ns_ana_state+0x60/0x60 [nvme_core] kernel: nvme_mpath_add_disk+0x47/0x90 [nvme_core] kernel: nvme_validate_ns+0x396/0x940 [nvme_core] kernel: ? blk_mq_free_request+0xd2/0x100 kernel: nvme_scan_work+0x24f/0x380 [nvme_core] kernel: process_one_work+0x1db/0x380 kernel: worker_thread+0x249/0x400 kernel: kthread+0x104/0x140 kernel: ? process_one_work+0x380/0x380 kernel: ? kthread_park+0x80/0x80 kernel: ret_from_fork+0x1f/0x40
--
in nvme_validate_ns")
--- drivers/nvme/host/core.c | 1 - 1 file changed, 1 deletion(-)
drivers/nvme/host/core.c +0 -1
@@ -1864,7 +1864,6 @@ static void __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id)if (ns->head->disk) {nvme_update_disk_info (ns->head->disk, ns, id);blk_queue_stack_limits (ns->head->disk->queue, ns->queue); -revalidate_disk (ns->head->disk); }#endif }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 306/388 mac80211: skip mpath lookup also for control port tx
In reply to Greg Kroah-HartmanFrom: Markus Theil <[email protected]>
[ Upstream commit 5af7fef39d7952c0f5551afa7b821ee7b6c9dd3d ]
When using 802.1X over mesh networks, at first an ordinary mesh peering is established, then the 802.1X EAPOL dialog happens, afterwards an authenticated mesh peering exchange (AMPE) happens, finally the peering is complete and we can set the STA authorized flag.
As 802.1X is an intermediate step here and key material is not yet exchanged for stations we have to skip mesh path lookup for these EAPOL frames. Otherwise the already configure mesh group encryption key would be used to send a mesh path request which no one can decipher, because we didn't already establish key material on both peers, like with SAE and directly using AMPE.
[remove pointless braces, remove unnecessary local variable,
the list can only process one such frame (or its fragments)]
--- net/mac80211/tx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/mac80211/tx.c +5 -1
@@ -3913,6 +3913,9 @@ void __ieee80211_subif_start_xmit(struct sk_buff *skb, skb->prev =NULL ; skb->next =NULL ; +if (skb->protocol == sdata->control_port_protocol) + ctrl_flags |=IEEE80211_TX_CTRL_SKIP_MPATH_LOOKUP ; + skb =ieee80211_build_hdr (sdata, skb, info_flags, sta, ctrl_flags);if (IS_ERR (skb))
@@ -5096,7 +5099,8 @@ int ieee80211_tx_control_port(struct wiphy *wiphy, struct net_device *dev,return -EINVAL ;if (proto == sdata->control_port_protocol) - ctrl_flags |=IEEE80211_TX_CTRL_PORT_CTRL_PROTO ; + ctrl_flags |=IEEE80211_TX_CTRL_PORT_CTRL_PROTO | +IEEE80211_TX_CTRL_SKIP_MPATH_LOOKUP ;if (unencrypted) flags =IEEE80211_TX_INTFL_DONT_ENCRYPT ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 307/388 scsi: libfc: Handling of extra kref
In reply to Greg Kroah-HartmanFrom: Javed Hasan <[email protected]>
[ Upstream commit 71f2bf85e90d938d4a9ef9dd9bfa8d9b0b6a03f7 ]
Handling of extra kref which is done by lookup table in case rdata is already present in list.
This issue was leading to memory leak. Trace from KMEMLEAK tool:
unreferenced object 0xffff8888259e8780 (size 512):
comm "kworker/2:1", pid 182614, jiffies 4433237386 (age 113021.971s)
hex dump (first 32 bytes):
58 0a ec cf 83 88 ff ff 00 00 00 00 00 00 00 00
01 00 00 00 08 00 00 00 13 7d f0 1e 0e 00 00 10
backtrace:
[<000000006b25760f>] fc_rport_recv_req+0x3c6/0x18f0 [libfc]
[<00000000f208d994>] fc_lport_recv_els_req+0x120/0x8a0 [libfc]
[<00000000a9c437b8>] fc_lport_recv+0xb9/0x130 [libfc]
[<00000000ad5be37b>] qedf_ll2_process_skb+0x73d/0xad0 [qedf]
[<00000000e0eb6893>] process_one_work+0x382/0x6c0
[<000000002dfd9e21>] worker_thread+0x57/0x5c0
[<00000000b648204f>] kthread+0x1a0/0x1c0
[<0000000072f5ab20>] ret_from_fork+0x35/0x40
[<000000001d5c05d8>] 0xffffffffffffffffBelow is the log sequence which leads to memory leak. Here we get the nested "Received PLOGI request" for same port and this request leads to call the fc_rport_create() twice for the same rport.
kernel: host1: rport fffce5: Received PLOGI request
kernel: host1: rport fffce5: Received PLOGI in INIT state
kernel: host1: rport fffce5: Port is Ready
kernel: host1: rport fffce5: Received PRLI request while in state Ready
kernel: host1: rport fffce5: PRLI rspp type 8 active 1 passive 0
kernel: host1: rport fffce5: Received LOGO request while in state Ready
kernel: host1: rport fffce5: Delete port
kernel: host1: rport fffce5: Received PLOGI request
kernel: host1: rport fffce5: Received PLOGI in state Delete - send busy
--- drivers/scsi/libfc/fc_rport.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/libfc/fc_rport.c +3 -1
@@ -133,8 +133,10 @@ struct fc_rport_priv *fc_rport_create(struct fc_lport *lport, u32 port_id)lockdep_assert_held (&lport->disc.disc_mutex); rdata =fc_rport_lookup (lport, port_id); -if (rdata) +if (rdata) { +kref_put (&rdata->kref, fc_rport_destroy);return rdata; + }if (lport->rport_priv_size >0 ) rport_priv_size = lport->rport_priv_size;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 298/388 mm: memcontrol: fix stat-corrupting race in charge moving
In reply to Greg Kroah-HartmanFrom: Johannes Weiner <[email protected]>
[ Upstream commit abb242f57196dbaa108271575353a0453f6834ef ]
The move_lock is a per-memcg lock, but the VM accounting code that needs to acquire it comes from the page and follows page->mem_cgroup under RCU protection. That means that the page becomes unlocked not when we drop the move_lock, but when we update page->mem_cgroup. And that assignment doesn't imply any memory ordering. If that pointer write gets reordered against the reads of the page state - page_mapped, PageDirty etc. the state may change while we rely on it being stable and we can end up corrupting the counters.
Place an SMP memory barrier to make sure we're done with all page state by the time the new page->mem_cgroup becomes visible.
Also replace the open-coded move_lock with a lock_page_memcg() to make it more obvious what we're serializing against.
--- mm/memcontrol.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
mm/memcontrol.c +14 -12
@@ -5489,7 +5489,6 @@ static int mem_cgroup_move_account(struct page *page, {struct lruvec *from_vec, *to_vec;struct pglist_data *pgdat; -unsigned long flags;unsigned int nr_pages = compound ?hpage_nr_pages (page) :1 ;int ret;bool anon;
@@ -5516,18 +5515,13 @@ static int mem_cgroup_move_account(struct page *page, from_vec =mem_cgroup_lruvec (pgdat, from); to_vec =mem_cgroup_lruvec (pgdat, to); -spin_lock_irqsave (&from->move_lock, flags); +lock_page_memcg (page);if (!anon &&page_mapped (page)) {__mod_lruvec_state (from_vec,NR_FILE_MAPPED , -nr_pages);__mod_lruvec_state (to_vec,NR_FILE_MAPPED , nr_pages); } -/* -* move_lock grabbed above and caller set from->moving_account, so -* mod_memcg_page_state will serialize updates to PageDirty. -* So mapping should be stable for dirty pages. -*/ if (!anon &&PageDirty (page)) {struct address_space *mapping =page_mapping (page);
@@ -5543,15 +5537,23 @@ static int mem_cgroup_move_account(struct page *page, }/* +* All state has been migrated, let's switch to the new memcg. +* * It is safe to change page->mem_cgroup here because the page -* is referenced, charged, and isolated - we can't race with -* uncharging, charging, migration, or LRU putback. +* is referenced, charged, isolated, and locked: we can't race +* with (un)charging, migration, LRU putback, or anything else +* that would rely on a stable page->mem_cgroup. +* +* Note that lock_page_memcg is a memcg lock, not a page lock, +* to save space. As soon as we switch page->mem_cgroup to a +* new memcg that isn't locked, the above state can change +* concurrently again. Make sure we're truly done with it. */ +smp_mb (); -/* caller should have done css_get */ - page->mem_cgroup = to; + page->mem_cgroup = to;/* caller should have done css_get */ -spin_unlock_irqrestore (&from->move_lock, flags); +__unlock_page_memcg (from); ret =0 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 282/388 KVM: PPC: Book3S HV: Close race with page faults around memslot flushes
In reply to Greg Kroah-HartmanFrom: Paul Mackerras <[email protected]>
[ Upstream commit 11362b1befeadaae4d159a8cddcdaf6b8afe08f9 ]
There is a potential race condition between hypervisor page faults and flushing a memslot. It is possible for a page fault to read the memslot before a memslot is updated and then write a PTE to the partition-scoped page tables after kvmppc_radix_flush_memslot has completed. (Note that this race has never been explicitly observed.)
To close this race, it is sufficient to increment the MMU sequence number while the kvm->mmu_lock is held. That will cause mmu_notifier_retry() to return true, and the page fault will then return to the guest without inserting a PTE.
--- arch/powerpc/kvm/book3s_64_mmu_radix.c | 5 +++++ 1 file changed, 5 insertions(+)
arch/powerpc/kvm/book3s_64_mmu_radix.c +5 -0
@@ -1104,6 +1104,11 @@ void kvmppc_radix_flush_memslot(struct kvm *kvm, kvm->arch.lpid); gpa +=PAGE_SIZE ; } +/* +* Increase the mmu notifier sequence number to prevent any page +* fault that read the memslot earlier from writing a PTE. +*/ + kvm->mmu_notifier_seq++;spin_unlock (&kvm->mmu_lock); }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 293/388 mtd: rawnand: gpmi: Fix runtime PM imbalance on error
In reply to Greg Kroah-HartmanFrom: Dinghao Liu <[email protected]>
[ Upstream commit 550e68ea36a6671a96576c0531685ce6e6c0d19d ]
pm_runtime_get_sync() increments the runtime PM usage counter even when it returns an error code. Thus a pairing decrement is needed on the error handling path to keep the counter balanced.
--- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +3 -1
@@ -540,8 +540,10 @@ static int bch_set_geometry(struct gpmi_nand_data *this)return ret; ret =pm_runtime_get_sync (this->dev); -if (ret <0 ) +if (ret <0 ) { +pm_runtime_put_autosuspend (this->dev);return ret; + }/* * Due to erratum #2847 of the MX23, the BCH cannot be soft reset on this
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 292/388 wlcore: fix runtime pm imbalance in wlcore_regdomain_config
In reply to Greg Kroah-HartmanFrom: Dinghao Liu <[email protected]>
[ Upstream commit 282a04bf1d8029eb98585cb5db3fd70fe8bc91f7 ]
pm_runtime_get_sync() increments the runtime PM usage counter even the call returns an error code. Thus a pairing decrement is needed on the error handling path to keep the counter balanced.
--- drivers/net/wireless/ti/wlcore/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/ti/wlcore/main.c +3 -1
@@ -3658,8 +3658,10 @@ void wlcore_regdomain_config(struct wl1271 *wl) goto out; ret =pm_runtime_get_sync (wl->dev); -if (ret <0 ) +if (ret <0 ) { +pm_runtime_put_autosuspend (wl->dev); goto out; + } ret =wlcore_cmd_regdomain_config_locked (wl);if (ret <0 ) {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 291/388 wlcore: fix runtime pm imbalance in wl1271_tx_work
In reply to Greg Kroah-HartmanFrom: Dinghao Liu <[email protected]>
[ Upstream commit 9604617e998b49f7695fea1479ed82421ef8c9f0 ]
There are two error handling paths in this functon. When wlcore_tx_work_locked() returns an error code, we should decrease the runtime PM usage counter the same way as the error handling path beginning from pm_runtime_get_sync().
--- drivers/net/wireless/ti/wlcore/tx.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/ti/wlcore/tx.c +1 -0
@@ -863,6 +863,7 @@ void wl1271_tx_work(struct work_struct *work) ret =wlcore_tx_work_locked (wl);if (ret <0 ) { +pm_runtime_put_noidle (wl->dev);wl12xx_queue_recovery_work (wl); goto out; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 255/388 USB: EHCI: ehci-mv: fix error handling in mv_ehci_probe()
In reply to Greg Kroah-HartmanFrom: Tang Bin <[email protected]>
[ Upstream commit c856b4b0fdb5044bca4c0acf9a66f3b5cc01a37a ]
If the function platform_get_irq() failed, the negative value returned will not be detected here. So fix error handling in mv_ehci_probe(). And when get irq failed, the function platform_get_irq() logs an error message, so remove redundant message here.
--- drivers/usb/host/ehci-mv.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/usb/host/ehci-mv.c +2 -3
@@ -157,9 +157,8 @@ static int mv_ehci_probe(struct platform_device *pdev) hcd->regs = ehci_mv->op_regs; hcd->irq =platform_get_irq (pdev,0 ); -if (!hcd->irq) { -dev_err (&pdev->dev,"Cannot get irq." ); - retval = -ENODEV ; +if (hcd->irq <0 ) { + retval = hcd->irq; goto err_disable_clk; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 254/388 Bluetooth: Handle Inquiry Cancel error after Inquiry Complete
In reply to Greg Kroah-HartmanFrom: Sonny Sasaka <[email protected]>
[ Upstream commit adf1d6926444029396861413aba8a0f2a805742a ]
After sending Inquiry Cancel command to the controller, it is possible that Inquiry Complete event comes before Inquiry Cancel command complete event. In this case the Inquiry Cancel command will have status of Command Disallowed since there is no Inquiry session to be cancelled. This case should not be treated as error, otherwise we can reach an inconsistent state.
Example of a btmon trace when this happened:
< HCI Command: Inquiry Cancel (0x01|0x0002) plen 0
Quoted 1 line
HCI Event: Inquiry Complete (
0x01) plen 1
Status: Success (0x00)
Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 4
Inquiry Cancel (0x01|0x0002) ncmd 1
Status: Command Disallowed (0x0c)--- net/bluetooth/hci_event.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
net/bluetooth/hci_event.c +17 -2
@@ -41,12 +41,27 @@/* Handle HCI Event packets */ -static void hci_cc_inquiry_cancel (struct hci_dev *hdev,struct sk_buff *skb) +static void hci_cc_inquiry_cancel (struct hci_dev *hdev,struct sk_buff *skb, +u8 *new_status) {__u8 status = *((__u8 *) skb->data);BT_DBG ("%s status 0x%2.2x" , hdev->name, status); +/* It is possible that we receive Inquiry Complete event right +* before we receive Inquiry Cancel Command Complete event, in +* which case the latter event should have status of Command +* Disallowed (0x0c). This should not be treated as error, since +* we actually achieve what Inquiry Cancel wants to achieve, +* which is to end the last Inquiry session. +*/ +if (status ==0x0c && !test_bit (HCI_INQUIRY , &hdev->flags)) { +bt_dev_warn (hdev,"Ignoring error of Inquiry Cancel command" ); + status =0x00 ; + } + + *new_status = status; +if (status)return ;
@@ -3142,7 +3157,7 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb,switch (*opcode) {case HCI_OP_INQUIRY_CANCEL : -hci_cc_inquiry_cancel (hdev, skb); +hci_cc_inquiry_cancel (hdev, skb, status);break ;case HCI_OP_PERIODIC_INQ :
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 252/388 power: supply: max17040: Correct voltage reading
In reply to Greg Kroah-HartmanFrom: Jonathan Bakker <[email protected]>
[ Upstream commit 0383024f811aa469df258039807810fc3793a105 ]
According to the datasheet available at (1), the bottom four bits are always zero and the actual voltage is 1.25x this value in mV. Since the kernel API specifies that voltages should be in uV, it should report 1250x the shifted value.
1) https://datasheets.maximintegrated.com/en/ds/MAX17040-MAX17041.pdf
--- drivers/power/supply/max17040_battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/max17040_battery.c +1 -1
@@ -105,7 +105,7 @@ static void max17040_get_vcell(struct i2c_client *client) vcell =max17040_read_reg (client,MAX17040_VCELL ); - chip->vcell = vcell; + chip->vcell = (vcell >>4 ) *1250 ; }static void max17040_get_soc (struct i2c_client *client)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 275/388 drm/nouveau/dispnv50: fix runtime pm imbalance on error
In reply to Greg Kroah-HartmanFrom: Dinghao Liu <[email protected]>
[ Upstream commit dc455f4c888365595c0a13da445e092422d55b8d ]
pm_runtime_get_sync() increments the runtime PM usage counter even the call returns an error code. Thus a pairing decrement is needed on the error handling path to keep the counter balanced.
--- drivers/gpu/drm/nouveau/dispnv50/disp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/dispnv50/disp.c +3 -1
@@ -1032,8 +1032,10 @@ nv50_mstc_detect(struct drm_connector *connector, bool force)return connector_status_disconnected; ret =pm_runtime_get_sync (connector->dev->dev); -if (ret <0 && ret != -EACCES ) +if (ret <0 && ret != -EACCES ) { +pm_runtime_put_autosuspend (connector->dev->dev);return connector_status_disconnected; + } conn_status =drm_dp_mst_detect_port (connector, mstc->port->mgr, mstc->port);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 253/388 phy: samsung: s5pv210-usb2: Add delay after reset
In reply to Greg Kroah-HartmanFrom: Jonathan Bakker <[email protected]>
[ Upstream commit 05942b8c36c7eb5d3fc5e375d4b0d0c49562e85d ]
The USB phy takes some time to reset, so make sure we give it to it. The delay length was taken from the 4x12 phy driver.
This manifested in issues with the DWC2 driver since commit fe369e1826b3 ("usb: dwc2: Make dwc2_readl/writel functions endianness-agnostic.") where the endianness check would read the DWC ID as 0 due to the phy still resetting, resulting in the wrong endian mode being chosen.
--- drivers/phy/samsung/phy-s5pv210-usb2.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/phy/samsung/phy-s5pv210-usb2.c +4 -0
@@ -139,6 +139,10 @@ static void s5pv210_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on)udelay (10 ); rst &= ~rstbits;writel (rst, drv->reg_phy +S5PV210_UPHYRST ); +/* The following delay is necessary for the reset sequence to be +* completed +*/ +udelay (80 ); }else { pwr =readl (drv->reg_phy +S5PV210_UPHYPWR ); pwr |= phypwr;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 276/388 printk: handle blank console arguments passed in.
In reply to Greg Kroah-HartmanFrom: Shreyas Joshi <[email protected]>
[ Upstream commit 48021f98130880dd74286459a1ef48b5e9bc374f ]
If uboot passes a blank string to console_setup then it results in a trashed memory. Ultimately, the kernel crashes during freeing up the memory.
This fix checks if there is a blank parameter being passed to console_setup from uboot. In case it detects that the console parameter is blank then it doesn't setup the serial device and it gracefully exits.
--- kernel/printk/printk.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/printk/printk.c +3 -0
@@ -2193,6 +2193,9 @@ static int __init console_setup(char *str)char *s, *options, *brl_options =NULL ;int idx; +if (str[0 ] ==0 ) +return 1 ; +if (_braille_console_setup (&str, &brl_options))return 1 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 274/388 drm/nouveau: fix runtime pm imbalance on error
In reply to Greg Kroah-HartmanFrom: Dinghao Liu <[email protected]>
[ Upstream commit d7372dfb3f7f1602b87e0663e8b8646da23ebca7 ]
pm_runtime_get_sync() increments the runtime PM usage counter even the call returns an error code. Thus a pairing decrement is needed on the error handling path to keep the counter balanced.
--- drivers/gpu/drm/nouveau/nouveau_gem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_gem.c +3 -1
@@ -78,8 +78,10 @@ nouveau_gem_object_open(struct drm_gem_object *gem, struct drm_file *file_priv)return ret; ret =pm_runtime_get_sync (dev); -if (ret <0 && ret != -EACCES ) +if (ret <0 && ret != -EACCES ) { +pm_runtime_put_autosuspend (dev); goto out; + } ret =nouveau_vma_new (nvbo, vmm, &vma);pm_runtime_mark_last_busy (dev);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 273/388 drm/nouveau/debugfs: fix runtime pm imbalance on error
In reply to Greg Kroah-HartmanFrom: Dinghao Liu <[email protected]>
[ Upstream commit 00583fbe8031f69bba8b0a9a861efb75fb7131af ]
pm_runtime_get_sync() increments the runtime PM usage counter even the call returns an error code. Thus a pairing decrement is needed on the error handling path to keep the counter balanced.
--- drivers/gpu/drm/nouveau/nouveau_debugfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_debugfs.c +4 -1
@@ -183,8 +183,11 @@ nouveau_debugfs_pstate_set(struct file *file, const char __user *ubuf, } ret =pm_runtime_get_sync (drm->dev); -if (ret <0 && ret != -EACCES ) +if (ret <0 && ret != -EACCES ) { +pm_runtime_put_autosuspend (drm->dev);return ret; + } + ret =nvif_mthd (ctrl,NVIF_CONTROL_PSTATE_USER , &args,sizeof (args));pm_runtime_put_autosuspend (drm->dev);if (ret <0 )
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 272/388 e1000: Do not perform reset in reset_task if we are already down
In reply to Greg Kroah-HartmanFrom: Alexander Duyck <[email protected]>
[ Upstream commit 49ee3c2ab5234757bfb56a0b3a3cb422f427e3a3 ]
We are seeing a deadlock in e1000 down when NAPI is being disabled. Looking over the kernel function trace of the system it appears that the interface is being closed and then a reset is hitting which deadlocks the interface as the NAPI interface is already disabled.
To prevent this from happening I am disabling the reset task when __E1000_DOWN is already set. In addition code has been added so that we set the __E1000_DOWN while holding the __E1000_RESET flag in e1000_close in order to guarantee that the reset task will not run after we have started the close call.
--- drivers/net/ethernet/intel/e1000/e1000_main.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/e1000/e1000_main.c +14 -4
@@ -542,8 +542,13 @@ void e1000_reinit_locked(struct e1000_adapter *adapter)WARN_ON (in_interrupt ());while (test_and_set_bit (__E1000_RESETTING, &adapter->flags))msleep (1 ); -e1000_down (adapter); -e1000_up (adapter); + +/* only run the task if not already down */ +if (!test_bit (__E1000_DOWN, &adapter->flags)) { +e1000_down (adapter); +e1000_up (adapter); + } +clear_bit (__E1000_RESETTING, &adapter->flags); }
@@ -1433,10 +1438,15 @@ int e1000_close(struct net_device *netdev)struct e1000_hw *hw = &adapter->hw;int count =E1000_CHECK_RESET_COUNT ; -while (test_bit (__E1000_RESETTING, &adapter->flags) && count--) +while (test_and_set_bit (__E1000_RESETTING, &adapter->flags) && count--)usleep_range (10000 ,20000 ); -WARN_ON (test_bit (__E1000_RESETTING, &adapter->flags)); +WARN_ON (count <0 ); + +/* signal that we're down so that the reset task will no longer run */ +set_bit (__E1000_DOWN, &adapter->flags); +clear_bit (__E1000_RESETTING, &adapter->flags); +e1000_down (adapter);e1000_power_down_phy (adapter);e1000_free_irq (adapter);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 271/388 drm/amdkfd: fix restore worker race condition
In reply to Greg Kroah-HartmanFrom: Philip Yang <[email protected]>
[ Upstream commit f7646585a30ed8ef5ab300d4dc3b0c1d6afbe71d ]
In free memory of gpu path, remove bo from validate_list to make sure restore worker don't access the BO any more, then unregister bo MMU interval notifier. Otherwise, the restore worker will crash in the middle of validating BO user pages if MMU interval notifer is gone.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +3 -3
@@ -1247,15 +1247,15 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(* be freed anyway */ -/* No more MMU notifiers */ -amdgpu_mn_unregister (mem->bo); -/* Make sure restore workers don't access the BO any more */ bo_list_entry = &mem->validate_list;mutex_lock (&process_info->lock);list_del (&bo_list_entry->head);mutex_unlock (&process_info->lock); +/* No more MMU notifiers */ +amdgpu_mn_unregister (mem->bo); + ret =reserve_bo_and_cond_vms (mem,NULL ,BO_VM_ALL , &ctx);if (unlikely (ret))return ret;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 261/388 ipmi:bt-bmc: Fix error handling and status check
In reply to Greg Kroah-HartmanFrom: Tang Bin <[email protected]>
[ Upstream commit 49826937e7c7917140515aaf10c17bedcc4acaad ]
If the function platform_get_irq() failed, the negative value returned will not be detected here. So fix error handling in bt_bmc_config_irq(). And in the function bt_bmc_probe(), when get irq failed, it will print error message. So use platform_get_irq_optional() to simplify code. Finally in the function bt_bmc_remove() should make the right status check if get irq failed.
Message-Id: <[email protected]>
--- drivers/char/ipmi/bt-bmc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/char/ipmi/bt-bmc.c +6 -6
@@ -399,15 +399,15 @@ static int bt_bmc_config_irq(struct bt_bmc *bt_bmc,struct device *dev = &pdev->dev;int rc; - bt_bmc->irq =platform_get_irq (pdev,0 ); -if (!bt_bmc->irq) -return -ENODEV ; + bt_bmc->irq =platform_get_irq_optional (pdev,0 ); +if (bt_bmc->irq <0 ) +return bt_bmc->irq; rc =devm_request_irq (dev, bt_bmc->irq, bt_bmc_irq,IRQF_SHARED ,DEVICE_NAME , bt_bmc);if (rc <0 ) {dev_warn (dev,"Unable to request IRQ %d\n" , bt_bmc->irq); - bt_bmc->irq =0 ; + bt_bmc->irq = rc;return rc; }
@@ -479,7 +479,7 @@ static int bt_bmc_probe(struct platform_device *pdev)bt_bmc_config_irq (bt_bmc, pdev); -if (bt_bmc->irq) { +if (bt_bmc->irq >=0 ) {dev_info (dev,"Using IRQ %d\n" , bt_bmc->irq); }else {dev_info (dev,"No IRQ; using timer\n" );
@@ -505,7 +505,7 @@ static int bt_bmc_remove(struct platform_device *pdev)struct bt_bmc *bt_bmc =dev_get_drvdata (&pdev->dev);misc_deregister (&bt_bmc->miscdev); -if (!bt_bmc->irq) +if (bt_bmc->irq <0 )del_timer_sync (&bt_bmc->poll_timer);return 0 ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 250/388 mm/slub: fix incorrect interpretation of s->offset
In reply to Greg Kroah-HartmanFrom: Waiman Long <[email protected]>
[ Upstream commit cbfc35a48609ceac978791e3ab9dde0c01f8cb20 ]
In a couple of places in the slub memory allocator, the code uses "s->offset" as a check to see if the free pointer is put right after the object. That check is no longer true with commit 3202fa62fb43 ("slub:
relocate freelist pointer to middle of object").
As a result, echoing "1" into the validate sysfs file, e.g. of dentry, may cause a bunch of "Freepointer corrupt" error reports like the following to appear with the system in panic afterwards.
=============================================================================
BUG dentry(666:pmcd.service) (Tainted: G B): Freepointer corrupt
-----------------------------------------------------------------------------
To fix it, use the check "s->offset == s->inuse" in the new helper function freeptr_outside_object() instead. Also add another helper function get_info_end() to return the end of info block (inuse + free pointer if not overlapping with object).
--- mm/slub.c | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-)
mm/slub.c +30 -15
@@ -533,15 +533,32 @@ static void print_section(char *level, char *text, u8 *addr,metadata_access_disable (); } +/* +* See comment in calculate_sizes(). +*/ +static inline bool freeptr_outside_object (struct kmem_cache *s) +{ +return s->offset >= s->inuse; +} + +/* +* Return offset of the end of info block which is inuse + free pointer if +* not overlapping with object. +*/ +static inline unsigned int get_info_end (struct kmem_cache *s) +{ +if (freeptr_outside_object (s)) +return s->inuse +sizeof (void *); +else +return s->inuse; +} +static struct track *get_track (struct kmem_cache *s,void *object,enum track_item alloc) {struct track *p; -if (s->offset) - p = object + s->offset +sizeof (void *); -else - p = object + s->inuse; + p = object +get_info_end (s);return p + alloc; }
@@ -682,10 +699,7 @@ static void print_trailer(struct kmem_cache *s, struct page *page, u8 *p)print_section (KERN_ERR ,"Redzone " , p + s->object_size, s->inuse - s->object_size); -if (s->offset) - off = s->offset +sizeof (void *); -else - off = s->inuse; + off =get_info_end (s);if (s->flags &SLAB_STORE_USER ) off +=2 *sizeof (struct track );
@@ -776,7 +790,7 @@ static int check_bytes_and_report(struct kmem_cache *s, struct page *page,* object address * Bytes of the object to be managed. * If the freepointer may overlay the object then the free -* pointer is the first word of the object. +* pointer is at the middle of the object. * * Poisoning uses 0x6b (POISON_FREE) and the last byte is * 0xa5 (POISON_END)
@@ -810,11 +824,7 @@ static int check_bytes_and_report(struct kmem_cache *s, struct page *page,static int check_pad_bytes (struct kmem_cache *s,struct page *page,u8 *p) { -unsigned long off = s->inuse;/* The end of info */ - -if (s->offset) -/* Freepointer is placed after the object. */ - off +=sizeof (void *); +unsigned long off =get_info_end (s);/* The end of info */ if (s->flags &SLAB_STORE_USER )/* We also have user information there */
@@ -900,7 +910,7 @@ static int check_object(struct kmem_cache *s, struct page *page,check_pad_bytes (s, page, p); } -if (!s->offset && val ==SLUB_RED_ACTIVE ) +if (!freeptr_outside_object (s) && val ==SLUB_RED_ACTIVE )/* * Object and freepointer overlap. Cannot check * freepointer while object is allocated.
@@ -3585,6 +3595,11 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)* * This is the case if we do RCU, have a constructor or * destructor or are poisoning the objects. +* +* The assumption that s->offset >= s->inuse means free +* pointer is outside of the object is used in the +* freeptr_outside_object() function. If that is no +* longer true, the function needs to be modified. */ s->offset = size; size +=sizeof (void *);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 220/388 mm/filemap.c: clear page error before actual read
In reply to Greg Kroah-HartmanFrom: Xianting Tian <[email protected]>
[ Upstream commit faffdfa04fa11ccf048cebdde73db41ede0679e0 ]
Mount failure issue happens under the scenario: Application forked dozens of threads to mount the same number of cramfs images separately in docker, but several mounts failed with high probability. Mount failed due to the checking result of the page(read from the superblock of loop dev) is not uptodate after wait_on_page_locked(page) returned in function cramfs_read:
wait_on_page_locked(page);
if (!PageUptodate(page)) {
...
}The reason of the checking result of the page not uptodate: systemd-udevd read the loopX dev before mount, because the status of loopX is Lo_unbound at this time, so loop_make_request directly trigger the calling of io_end handler end_buffer_async_read, which called SetPageError(page). So It caused the page can't be set to uptodate in function end_buffer_async_read:
if(page_uptodate && !PageError(page)) {
SetPageUptodate(page);
}Then mount operation is performed, it used the same page which is just accessed by systemd-udevd above, Because this page is not uptodate, it will launch a actual read via submit_bh, then wait on this page by calling wait_on_page_locked(page). When the I/O of the page done, io_end handler end_buffer_async_read is called, because no one cleared the page error(during the whole read path of mount), which is caused by systemd-udevd reading, so this page is still in "PageError" status, which can't be set to uptodate in function end_buffer_async_read, then caused mount failure.
But sometimes mount succeed even through systemd-udeved read loopX dev just before, The reason is systemd-udevd launched other loopX read just between step 3.1 and 3.2, the steps as below:
1, loopX dev default status is Lo_unbound;
2, systemd-udved read loopX dev (page is set to PageError); 3, mount operation
1) set loopX status to Lo_bound; ==>systemd-udevd read loopX dev<==
2) read loopX dev(page has no error)
3) mount succeed
As the loopX dev status is set to Lo_bound after step 3.1, so the other loopX dev read by systemd-udevd will go through the whole I/O stack, part of the call trace as below:
SYS_read
vfs_read
do_sync_read
blkdev_aio_read
generic_file_aio_read
do_generic_file_read:
ClearPageError(page);
mapping->a_ops->readpage(filp, page);here, mapping->a_ops->readpage() is blkdev_readpage. In latest kernel, some function name changed, the call trace as below:
blkdev_read_iter
generic_file_read_iter
generic_file_buffered_read:
/*
* A previous I/O error may have been due to temporary
* failures, eg. mutipath errors.
* Pg_error will be set again if readpage fails.
*/
ClearPageError(page);
/* Start the actual read. The read will unlock the page*/
error=mapping->a_ops->readpage(flip, page);We can see ClearPageError(page) is called before the actual read, then the read in step 3.2 succeed.
This patch is to add the calling of ClearPageError just before the actual read of read path of cramfs mount. Without the patch, the call trace as below when performing cramfs mount:
do_mount
cramfs_read
cramfs_blkdev_read
read_cache_page
do_read_cache_page:
filler(data, page);
or
mapping->a_ops->readpage(data, page);With the patch, the call trace as below when performing mount:
do_mount
cramfs_read
cramfs_blkdev_read
read_cache_page:
do_read_cache_page:
ClearPageError(page); <== new add
filler(data, page);
or
mapping->a_ops->readpage(data, page);With the patch, mount operation trigger the calling of ClearPageError(page) before the actual read, the page has no error if no additional page error happen when I/O done.
--- mm/filemap.c | 8 ++++++++ 1 file changed, 8 insertions(+)
mm/filemap.c +8 -0
@@ -2845,6 +2845,14 @@ filler:unlock_page (page); goto out; } + +/* +* A previous I/O error may have been due to temporary +* failures. +* Clear page error before actual read, PG_error will be +* set again if read page fails. +*/ +ClearPageError (page); goto filler; out:
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 222/388 mm/vmscan.c: fix data races using kswapd_classzone_idx
In reply to Greg Kroah-HartmanFrom: Qian Cai <[email protected]>
[ Upstream commit 5644e1fbbfe15ad06785502bbfe5751223e5841d ]
pgdat->kswapd_classzone_idx could be accessed concurrently in wakeup_kswapd(). Plain writes and reads without any lock protection result in data races. Fix them by adding a pair of READ|WRITE_ONCE() as well as saving a branch (compilers might well optimize the original code in an unintentional way anyway). While at it, also take care of pgdat->kswapd_order and non-kswapd threads in allow_direct_reclaim(). The data races were reported by KCSAN,
BUG: KCSAN: data-race in wakeup_kswapd / wakeup_kswapd
write to 0xffff9f427ffff2dc of 4 bytes by task 7454 on cpu 13:
wakeup_kswapd+0xf1/0x400 wakeup_kswapd at mm/vmscan.c:3967 wake_all_kswapds+0x59/0xc0 wake_all_kswapds at mm/page_alloc.c:4241 __alloc_pages_slowpath+0xdcc/0x1290 __alloc_pages_slowpath at mm/page_alloc.c:4512 __alloc_pages_nodemask+0x3bb/0x450 alloc_pages_vma+0x8a/0x2c0 do_anonymous_page+0x16e/0x6f0 __handle_mm_fault+0xcd5/0xd40 handle_mm_fault+0xfc/0x2f0 do_page_fault+0x263/0x6f9 page_fault+0x34/0x40
1 lock held by mtest01/7454:
#0: ffff9f425afe8808 (&mm->mmap_sem#2){++++}, at:
do_page_fault+0x143/0x6f9 do_user_addr_fault at arch/x86/mm/fault.c:1405 (inlined by) do_page_fault at arch/x86/mm/fault.c:1539 irq event stamp: 6944085 count_memcg_event_mm+0x1a6/0x270 count_memcg_event_mm+0x119/0x270 __do_softirq+0x34c/0x57c irq_exit+0xa2/0xc0
read to 0xffff9f427ffff2dc of 4 bytes by task 7472 on cpu 38:
wakeup_kswapd+0xc8/0x400 wake_all_kswapds+0x59/0xc0 __alloc_pages_slowpath+0xdcc/0x1290 __alloc_pages_nodemask+0x3bb/0x450 alloc_pages_vma+0x8a/0x2c0 do_anonymous_page+0x16e/0x6f0 __handle_mm_fault+0xcd5/0xd40 handle_mm_fault+0xfc/0x2f0 do_page_fault+0x263/0x6f9 page_fault+0x34/0x40
1 lock held by mtest01/7472:
#0: ffff9f425a9ac148 (&mm->mmap_sem#2){++++}, at:
do_page_fault+0x143/0x6f9 irq event stamp: 6793561 count_memcg_event_mm+0x1a6/0x270 count_memcg_event_mm+0x119/0x270 __do_softirq+0x34c/0x57c irq_exit+0xa2/0xc0 BUG: KCSAN: data-race in kswapd / wakeup_kswapd
write to 0xffff90973ffff2dc of 4 bytes by task 820 on cpu 6:
kswapd+0x27c/0x8d0 kthread+0x1e0/0x200 ret_from_fork+0x27/0x50
read to 0xffff90973ffff2dc of 4 bytes by task 6299 on cpu 0:
wakeup_kswapd+0xf3/0x450 wake_all_kswapds+0x59/0xc0 __alloc_pages_slowpath+0xdcc/0x1290 __alloc_pages_nodemask+0x3bb/0x450 alloc_pages_vma+0x8a/0x2c0 do_anonymous_page+0x170/0x700 __handle_mm_fault+0xc9f/0xd00 handle_mm_fault+0xfc/0x2f0 do_page_fault+0x263/0x6f9 page_fault+0x34/0x40
--- mm/vmscan.c | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-)
mm/vmscan.c +26 -19
@@ -3168,8 +3168,9 @@ static bool allow_direct_reclaim(pg_data_t *pgdat)/* kswapd must be awake if processes are being throttled */ if (!wmark_ok &&waitqueue_active (&pgdat->kswapd_wait)) { - pgdat->kswapd_classzone_idx =min (pgdat->kswapd_classzone_idx, - (enum zone_type )ZONE_NORMAL ); +if (READ_ONCE (pgdat->kswapd_classzone_idx) >ZONE_NORMAL ) +WRITE_ONCE (pgdat->kswapd_classzone_idx,ZONE_NORMAL ); +wake_up_interruptible (&pgdat->kswapd_wait); }
@@ -3801,9 +3802,9 @@ out:static enum zone_type kswapd_classzone_idx (pg_data_t *pgdat,enum zone_type prev_classzone_idx) { -if (pgdat->kswapd_classzone_idx ==MAX_NR_ZONES ) -return prev_classzone_idx; -return pgdat->kswapd_classzone_idx; +enum zone_type curr_idx =READ_ONCE (pgdat->kswapd_classzone_idx); + +return curr_idx ==MAX_NR_ZONES ? prev_classzone_idx : curr_idx; } static void kswapd_try_to_sleep(pg_data_t *pgdat, int alloc_order, int reclaim_order,
@@ -3847,8 +3848,11 @@ static void kswapd_try_to_sleep(pg_data_t *pgdat, int alloc_order, int reclaim_o* the previous request that slept prematurely. */ if (remaining) { - pgdat->kswapd_classzone_idx =kswapd_classzone_idx (pgdat, classzone_idx); - pgdat->kswapd_order =max (pgdat->kswapd_order, reclaim_order); +WRITE_ONCE (pgdat->kswapd_classzone_idx, +kswapd_classzone_idx (pgdat, classzone_idx)); + +if (READ_ONCE (pgdat->kswapd_order) < reclaim_order) +WRITE_ONCE (pgdat->kswapd_order, reclaim_order); }finish_wait (&pgdat->kswapd_wait, &wait);
@@ -3925,12 +3929,12 @@ static int kswapd(void *p) tsk->flags |=PF_MEMALLOC |PF_SWAPWRITE |PF_KSWAPD ;set_freezable (); - pgdat->kswapd_order =0 ; - pgdat->kswapd_classzone_idx =MAX_NR_ZONES ; +WRITE_ONCE (pgdat->kswapd_order,0 ); +WRITE_ONCE (pgdat->kswapd_classzone_idx,MAX_NR_ZONES );for ( ; ; ) {bool ret; - alloc_order = reclaim_order = pgdat->kswapd_order; + alloc_order = reclaim_order =READ_ONCE (pgdat->kswapd_order); classzone_idx =kswapd_classzone_idx (pgdat, classzone_idx); kswapd_try_sleep:
@@ -3938,10 +3942,10 @@ kswapd_try_sleep: classzone_idx);/* Read the new order and classzone_idx */ - alloc_order = reclaim_order = pgdat->kswapd_order; + alloc_order = reclaim_order =READ_ONCE (pgdat->kswapd_order); classzone_idx =kswapd_classzone_idx (pgdat, classzone_idx); - pgdat->kswapd_order =0 ; - pgdat->kswapd_classzone_idx =MAX_NR_ZONES ; +WRITE_ONCE (pgdat->kswapd_order,0 ); +WRITE_ONCE (pgdat->kswapd_classzone_idx,MAX_NR_ZONES ); ret =try_to_freeze ();if (kthread_should_stop ())
@@ -3985,20 +3989,23 @@ void wakeup_kswapd(struct zone *zone, gfp_t gfp_flags, int order, enum zone_type classzone_idx) {pg_data_t *pgdat; +enum zone_type curr_idx;if (!managed_zone (zone))return ;if (!cpuset_zone_allowed (zone, gfp_flags))return ; + pgdat = zone->zone_pgdat; + curr_idx =READ_ONCE (pgdat->kswapd_classzone_idx); + +if (curr_idx ==MAX_NR_ZONES || curr_idx < classzone_idx) +WRITE_ONCE (pgdat->kswapd_classzone_idx, classzone_idx); + +if (READ_ONCE (pgdat->kswapd_order) < order) +WRITE_ONCE (pgdat->kswapd_order, order); -if (pgdat->kswapd_classzone_idx ==MAX_NR_ZONES ) - pgdat->kswapd_classzone_idx = classzone_idx; -else - pgdat->kswapd_classzone_idx =max (pgdat->kswapd_classzone_idx, - classzone_idx); - pgdat->kswapd_order =max (pgdat->kswapd_order, order);if (!waitqueue_active (&pgdat->kswapd_wait))return ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 260/388 drm/exynos: dsi: Remove bridge node reference in error handling path in probe function
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 547a7348633b1f9923551f94ac3157a613d2c9f2 ]
'exynos_dsi_parse_dt()' takes a reference to 'dsi->in_bridge_node'. This must be released in the error handling path.
In order to do that, add an error handling path and move the 'exynos_dsi_parse_dt()' call from the beginning to the end of the probe function to ease the error handling path.
This function only sets some variables which are used only in the 'transfer' function.
The call chain is:
.transfer
--> exynos_dsi_host_transfer
--> exynos_dsi_init
--> exynos_dsi_enable_clock (use burst_clk_rate and esc_clk_rate)
--> exynos_dsi_set_pll (use pll_clk_rate)While at it, also handle cases where 'component_add()' fails.
This patch is similar to commit 70505c2ef94b ("drm/exynos: dsi: Remove bridge node reference in removal") which fixed the issue in the remove function.
--- drivers/gpu/drm/exynos/exynos_drm_dsi.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_dsi.c +15 -5
@@ -1741,10 +1741,6 @@ static int exynos_dsi_probe(struct platform_device *pdev) dsi->dev = dev; dsi->driver_data =of_device_get_match_data (dev); - ret =exynos_dsi_parse_dt (dsi); -if (ret) -return ret; - dsi->supplies[0 ].supply ="vddcore" ; dsi->supplies[1 ].supply ="vddio" ; ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(dsi->supplies),
@@ -1805,11 +1801,25 @@ static int exynos_dsi_probe(struct platform_device *pdev)return ret; } + ret =exynos_dsi_parse_dt (dsi); +if (ret) +return ret; +platform_set_drvdata (pdev, &dsi->encoder);pm_runtime_enable (dev); -return component_add (dev, &exynos_dsi_component_ops); + ret =component_add (dev, &exynos_dsi_component_ops); +if (ret) + goto err_disable_runtime; + +return 0 ; + +err_disable_runtime: +pm_runtime_disable (dev); +of_node_put (dsi->in_bridge_node); + +return ret; }static int exynos_dsi_remove (struct platform_device *pdev)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 259/388 ALSA: hda: Fix potential race in unsol event handler
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
[ Upstream commit c637fa151259c0f74665fde7cba5b7eac1417ae5 ]
The unsol event handling code has a loop retrieving the read/write indices and the arrays without locking while the append to the array may happen concurrently. This may lead to some inconsistency. Although there hasn't been any proof of this bad results, it's still safer to protect the racy accesses.
This patch adds the spinlock protection around the unsol handling loop for addressing it. Here we take bus->reg_lock as the writer side snd_hdac_bus_queue_event() is also protected by that lock.
--- sound/hda/hdac_bus.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/hda/hdac_bus.c +4 -0
@@ -158,6 +158,7 @@ static void snd_hdac_bus_process_unsol_events(struct work_struct *work)struct hdac_driver *drv;unsigned int rp, caddr, res; +spin_lock_irq (&bus->reg_lock);while (bus->unsol_rp != bus->unsol_wp) { rp = (bus->unsol_rp +1 ) %HDA_UNSOL_QUEUE_SIZE ; bus->unsol_rp = rp;
@@ -169,10 +170,13 @@ static void snd_hdac_bus_process_unsol_events(struct work_struct *work) codec = bus->caddr_tbl[caddr &0x0f ];if (!codec || !codec->dev.driver)continue ; +spin_unlock_irq (&bus->reg_lock); drv =drv_to_hdac_driver (codec->dev.driver);if (drv->unsol_event) drv->unsol_event (codec, res); +spin_lock_irq (&bus->reg_lock); } +spin_unlock_irq (&bus->reg_lock); }/**
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 216/388 NFS: Fix races nfs_page_group_destroy() vs nfs_destroy_unlinked_subrequests()
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit 08ca8b21f760c0ed5034a5c122092eec22ccf8f4 ]
When a subrequest is being detached from the subgroup, we want to ensure that it is not holding the group lock, or in the process of waiting for the group lock.
--- fs/nfs/pagelist.c | 67 +++++++++++++++++++++++++++------------- fs/nfs/write.c | 10 ++++-- include/linux/nfs_page.h | 2 ++ 3 files changed, 55 insertions(+), 24 deletions(-)
fs/nfs/pagelist.c +45 -22
@@ -133,47 +133,70 @@ nfs_async_iocounter_wait(struct rpc_task *task, struct nfs_lock_context *l_ctx)EXPORT_SYMBOL_GPL (nfs_async_iocounter_wait);/* -* nfs_page_group_lock - lock the head of the page group -* @req - request in group that is to be locked +* nfs_page_set_headlock - set the request PG_HEADLOCK +* @req: request that is to be locked * -* this lock must be held when traversing or modifying the page -* group list +* this lock must be held when modifying req->wb_head * * return 0 on success, < 0 on error */ int -nfs_page_group_lock (struct nfs_page *req) +nfs_page_set_headlock (struct nfs_page *req) { -struct nfs_page *head = req->wb_head; - -WARN_ON_ONCE (head != head->wb_head); - -if (!test_and_set_bit (PG_HEADLOCK , &head->wb_flags)) +if (!test_and_set_bit (PG_HEADLOCK , &req->wb_flags))return 0 ; -set_bit (PG_CONTENDED1 , &head->wb_flags); +set_bit (PG_CONTENDED1 , &req->wb_flags);smp_mb__after_atomic (); -return wait_on_bit_lock (&head->wb_flags,PG_HEADLOCK , +return wait_on_bit_lock (&req->wb_flags,PG_HEADLOCK ,TASK_UNINTERRUPTIBLE ); }/* -* nfs_page_group_unlock - unlock the head of the page group -* @req - request in group that is to be unlocked +* nfs_page_clear_headlock - clear the request PG_HEADLOCK +* @req: request that is to be locked */ void -nfs_page_group_unlock (struct nfs_page *req) +nfs_page_clear_headlock (struct nfs_page *req) { -struct nfs_page *head = req->wb_head; - -WARN_ON_ONCE (head != head->wb_head); -smp_mb__before_atomic (); -clear_bit (PG_HEADLOCK , &head->wb_flags); +clear_bit (PG_HEADLOCK , &req->wb_flags);smp_mb__after_atomic (); -if (!test_bit (PG_CONTENDED1 , &head->wb_flags)) +if (!test_bit (PG_CONTENDED1 , &req->wb_flags))return ; -wake_up_bit (&head->wb_flags,PG_HEADLOCK ); +wake_up_bit (&req->wb_flags,PG_HEADLOCK ); +} + +/* +* nfs_page_group_lock - lock the head of the page group +* @req: request in group that is to be locked +* +* this lock must be held when traversing or modifying the page +* group list +* +* return 0 on success, < 0 on error +*/ +int +nfs_page_group_lock (struct nfs_page *req) +{ +int ret; + + ret =nfs_page_set_headlock (req); +if (ret || req->wb_head == req) +return ret; +return nfs_page_set_headlock (req->wb_head); +} + +/* +* nfs_page_group_unlock - unlock the head of the page group +* @req: request in group that is to be unlocked +*/ +void +nfs_page_group_unlock (struct nfs_page *req) +{ +if (req != req->wb_head) +nfs_page_clear_headlock (req->wb_head); +nfs_page_clear_headlock (req); }/*
fs/nfs/write.c +8 -2
@@ -425,22 +425,28 @@ nfs_destroy_unlinked_subrequests(struct nfs_page *destroy_list, destroy_list = (subreq->wb_this_page == old_head) ?NULL : subreq->wb_this_page; +/* Note: lock subreq in order to change subreq->wb_head */ +nfs_page_set_headlock (subreq);WARN_ON_ONCE (old_head != subreq->wb_head);/* make sure old group is not used */ subreq->wb_this_page = subreq; + subreq->wb_head = subreq;clear_bit (PG_REMOVE , &subreq->wb_flags);/* Note: races with nfs_page_group_destroy() */ if (!kref_read (&subreq->wb_kref)) {/* Check if we raced with nfs_page_group_destroy() */ -if (test_and_clear_bit (PG_TEARDOWN , &subreq->wb_flags)) +if (test_and_clear_bit (PG_TEARDOWN , &subreq->wb_flags)) { +nfs_page_clear_headlock (subreq);nfs_free_request (subreq); + }else +nfs_page_clear_headlock (subreq);continue ; } +nfs_page_clear_headlock (subreq); - subreq->wb_head = subreq;nfs_release_request (old_head);if (test_and_clear_bit (PG_INODE_REF , &subreq->wb_flags)) {
include/linux/nfs_page.h +2 -0
@@ -142,6 +142,8 @@ extern void nfs_unlock_and_release_request(struct nfs_page *);extern int nfs_page_group_lock (struct nfs_page *);extern void nfs_page_group_unlock (struct nfs_page *);extern bool nfs_page_group_sync_on_bit (struct nfs_page *,unsigned int ); +extern int nfs_page_set_headlock (struct nfs_page *req); +extern void nfs_page_clear_headlock (struct nfs_page *req);extern bool nfs_async_iocounter_wait (struct rpc_task *,struct nfs_lock_context *);/*
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 224/388 nvmet-rdma: fix double free of rdma queue
In reply to Greg Kroah-HartmanFrom: Israel Rukshin <[email protected]>
[ Upstream commit 21f9024355e58772ec5d7fc3534aa5e29d72a8b6 ]
In case rdma accept fails at nvmet_rdma_queue_connect(), release work is scheduled. Later on, a new RDMA CM event may arrive since we didn't destroy the cm-id and call nvmet_rdma_queue_connect_fail(), which schedule another release work. This will cause calling nvmet_rdma_free_queue twice. To fix this we implicitly destroy the cm_id with non-zero ret code, which guarantees that new rdma_cm events will not arrive afterwards. Also add a qp pointer to nvmet_rdma_queue structure, so we can use it when the cm_id pointer is NULL or was destroyed.
--- drivers/nvme/target/rdma.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-)
drivers/nvme/target/rdma.c +18 -12
@@ -75,6 +75,7 @@ enum nvmet_rdma_queue_state {struct nvmet_rdma_queue {struct rdma_cm_id *cm_id; +struct ib_qp *qp;struct nvmet_port *port;struct ib_cq *cq;atomic_t sq_wr_avail;
@@ -464,7 +465,7 @@ static int nvmet_rdma_post_recv(struct nvmet_rdma_device *ndev,if (ndev->srq) ret =ib_post_srq_recv (ndev->srq, &cmd->wr,NULL );else - ret =ib_post_recv (cmd->queue->cm_id->qp, &cmd->wr,NULL ); + ret =ib_post_recv (cmd->queue->qp, &cmd->wr,NULL );if (unlikely (ret))pr_err ("post_recv cmd failed\n" );
@@ -503,7 +504,7 @@ static void nvmet_rdma_release_rsp(struct nvmet_rdma_rsp *rsp)atomic_add (1 + rsp->n_rdma, &queue->sq_wr_avail);if (rsp->n_rdma) { -rdma_rw_ctx_destroy (&rsp->rw, queue->cm_id->qp, +rdma_rw_ctx_destroy (&rsp->rw, queue->qp, queue->cm_id->port_num, rsp->req.sg, rsp->req.sg_cnt,nvmet_data_dir (&rsp->req)); }
@@ -587,7 +588,7 @@ static void nvmet_rdma_read_data_done(struct ib_cq *cq, struct ib_wc *wc)WARN_ON (rsp->n_rdma <=0 );atomic_add (rsp->n_rdma, &queue->sq_wr_avail); -rdma_rw_ctx_destroy (&rsp->rw, queue->cm_id->qp, +rdma_rw_ctx_destroy (&rsp->rw, queue->qp, queue->cm_id->port_num, rsp->req.sg, rsp->req.sg_cnt,nvmet_data_dir (&rsp->req)); rsp->n_rdma =0 ;
@@ -742,7 +743,7 @@ static bool nvmet_rdma_execute_command(struct nvmet_rdma_rsp *rsp) }if (nvmet_rdma_need_data_in (rsp)) { -if (rdma_rw_ctx_post (&rsp->rw, queue->cm_id->qp, +if (rdma_rw_ctx_post (&rsp->rw, queue->qp, queue->cm_id->port_num, &rsp->read_cqe,NULL ))nvmet_req_complete (&rsp->req,NVME_SC_DATA_XFER_ERROR ); }else {
@@ -1025,6 +1026,7 @@ static int nvmet_rdma_create_queue_ib(struct nvmet_rdma_queue *queue)pr_err ("failed to create_qp ret= %d\n" , ret); goto err_destroy_cq; } + queue->qp = queue->cm_id->qp;atomic_set (&queue->sq_wr_avail, qp_attr.cap.max_send_wr);
@@ -1053,11 +1055,10 @@ err_destroy_cq:static void nvmet_rdma_destroy_queue_ib (struct nvmet_rdma_queue *queue) { -struct ib_qp *qp = queue->cm_id->qp; - -ib_drain_qp (qp); -rdma_destroy_id (queue->cm_id); -ib_destroy_qp (qp); +ib_drain_qp (queue->qp); +if (queue->cm_id) +rdma_destroy_id (queue->cm_id); +ib_destroy_qp (queue->qp);ib_free_cq (queue->cq); }
@@ -1291,9 +1292,12 @@ static int nvmet_rdma_queue_connect(struct rdma_cm_id *cm_id, ret =nvmet_rdma_cm_accept (cm_id, queue, &event->param.conn);if (ret) { -schedule_work (&queue->release_work); -/* Destroying rdma_cm id is not needed here */ -return 0 ; +/* +* Don't destroy the cm_id in free path, as we implicitly +* destroy the cm_id here with non-zero ret code. +*/ + queue->cm_id =NULL ; + goto free_queue; }mutex_lock (&nvmet_rdma_queue_mutex);
@@ -1302,6 +1306,8 @@ static int nvmet_rdma_queue_connect(struct rdma_cm_id *cm_id,return 0 ; +free_queue: +nvmet_rdma_free_queue (queue); put_device:kref_put (&ndev->ref, nvmet_rdma_free_dev);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 221/388 mm/swapfile: fix data races in try_to_unuse()
In reply to Greg Kroah-HartmanFrom: Qian Cai <[email protected]>
[ Upstream commit 218209487c3da2f6d861b236c11226b6eca7b7b7 ]
si->inuse_pages could be accessed concurrently as noticed by KCSAN,
write to 0xffff98b00ebd04dc of 4 bytes by task 82262 on cpu 92:
swap_range_free+0xbe/0x230 swap_range_free at mm/swapfile.c:719 swapcache_free_entries+0x1be/0x250 free_swap_slot+0x1c8/0x220 __swap_entry_free.constprop.19+0xa3/0xb0 free_swap_and_cache+0x53/0xa0 unmap_page_range+0x7e0/0x1ce0 unmap_single_vma+0xcd/0x170 unmap_vmas+0x18b/0x220 exit_mmap+0xee/0x220 mmput+0xe7/0x240 do_exit+0x598/0xfd0 do_group_exit+0x8b/0x180 get_signal+0x293/0x13d0 do_signal+0x37/0x5d0 prepare_exit_to_usermode+0x1b7/0x2c0 ret_from_intr+0x32/0x42
read to 0xffff98b00ebd04dc of 4 bytes by task 82499 on cpu 46:
try_to_unuse+0x86b/0xc80 try_to_unuse at mm/swapfile.c:2185 __x64_sys_swapoff+0x372/0xd40 do_syscall_64+0x91/0xb05 entry_SYSCALL_64_after_hwframe+0x49/0xbe
The plain reads in try_to_unuse() are outside si->lock critical section which result in data races that could be dangerous to be used in a loop. Fix them by adding READ_ONCE().
--- mm/swapfile.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
mm/swapfile.c +4 -4
@@ -2132,7 +2132,7 @@ int try_to_unuse(unsigned int type, bool frontswap,swp_entry_t entry;unsigned int i; -if (!si->inuse_pages) +if (!READ_ONCE (si->inuse_pages))return 0 ;if (!frontswap)
@@ -2148,7 +2148,7 @@ retry:spin_lock (&mmlist_lock); p = &init_mm.mmlist; -while (si->inuse_pages && +while (READ_ONCE (si->inuse_pages) && !signal_pending (current) && (p = p->next) != &init_mm.mmlist) {
@@ -2177,7 +2177,7 @@ retry:mmput (prev_mm); i =0 ; -while (si->inuse_pages && +while (READ_ONCE (si->inuse_pages) && !signal_pending (current) && (i =find_next_to_unuse (si, i, frontswap)) !=0 ) {
@@ -2219,7 +2219,7 @@ retry:* been preempted after get_swap_page(), temporarily hiding that swap. * It's easy and robust (though cpu-intensive) just to keep retrying. */ -if (si->inuse_pages) { +if (READ_ONCE (si->inuse_pages)) {if (!signal_pending (current)) goto retry; retval = -EINTR ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 225/388 workqueue: Remove the warning in wq_worker_sleeping()
In reply to Greg Kroah-HartmanFrom: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit 62849a9612924a655c67cf6962920544aa5c20db ]
The kernel test robot triggered a warning with the following race:
task-ctx A interrupt-ctx B
worker
-> process_one_work()
-> work_item()
-> schedule();
-> sched_submit_work()
-> wq_worker_sleeping()
-> ->sleeping = 1
atomic_dec_and_test(nr_running)
__schedule(); *interrupt*
async_page_fault()
-> local_irq_enable();
-> schedule();
-> sched_submit_work()
-> wq_worker_sleeping()
-> if (WARN_ON(->sleeping)) return
-> __schedule()
-> sched_update_worker()
-> wq_worker_running()
-> atomic_inc(nr_running);
-> ->sleeping = 0;
-> sched_update_worker()
-> wq_worker_running()
if (!->sleeping) returnIn this context the warning is pointless everything is fine. An interrupt before wq_worker_sleeping() will perform the ->sleeping assignment (0 -> 1 > 0) twice.
An interrupt after wq_worker_sleeping() will trigger the warning and nr_running will be decremented (by A) and incremented once (only by B, A will skip it). This is the case until the ->sleeping is zeroed again in wq_worker_running().
Remove the WARN statement because this condition may happen. Document that preemption around wq_worker_sleeping() needs to be disabled to protect ->sleeping and not just as an optimisation.
--- kernel/sched/core.c | 3 ++- kernel/workqueue.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-)
kernel/sched/core.c +2 -1
@@ -4199,7 +4199,8 @@ static inline void sched_submit_work(struct task_struct *tsk)* it wants to wake up a task to maintain concurrency. * As this function is called inside the schedule() context, * we disable preemption to avoid it calling schedule() again -* in the possible wakeup of a kworker. +* in the possible wakeup of a kworker and because wq_worker_sleeping() +* requires it. */ if (tsk->flags &PF_WQ_WORKER ) {preempt_disable ();
kernel/workqueue.c +4 -2
@@ -864,7 +864,8 @@ void wq_worker_running(struct task_struct *task)* @task: task going to sleep * * This function is called from schedule() when a busy worker is -* going to sleep. +* going to sleep. Preemption needs to be disabled to protect ->sleeping +* assignment. */ void wq_worker_sleeping (struct task_struct *task) {
@@ -881,7 +882,8 @@ void wq_worker_sleeping(struct task_struct *task) pool = worker->pool; -if (WARN_ON_ONCE (worker->sleeping)) +/* Return if preempted before wq_worker_running() was reached */ +if (worker->sleeping)return ; worker->sleeping =1 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 223/388 SUNRPC: Dont start a timer on an already queued rpc task
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit 1fab7dc477241c12f977955aa6baea7938b6f08d ]
Move the test for whether a task is already queued to prevent corruption of the timer list in __rpc_sleep_on_priority_timeout().
--- net/sunrpc/sched.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
net/sunrpc/sched.c +13 -6
@@ -204,10 +204,6 @@ static void __rpc_add_wait_queue(struct rpc_wait_queue *queue,struct rpc_task *task, unsigned char queue_priority) { -WARN_ON_ONCE (RPC_IS_QUEUED (task )); -if (RPC_IS_QUEUED (task)) -return ; - INIT_LIST_HEAD(&task->u.tk_wait.timer_list);if (RPC_IS_PRIORITY (queue))__rpc_add_wait_queue_priority (queue, task, queue_priority);
@@ -382,7 +378,7 @@ static void rpc_make_runnable(struct workqueue_struct *wq,* NB: An RPC task will only receive interrupt-driven events as long * as it's on a wait queue. */ -static void __rpc_sleep_on_priority (struct rpc_wait_queue *q, +static void __rpc_do_sleep_on_priority (struct rpc_wait_queue *q,struct rpc_task *task,unsigned char queue_priority) {
@@ -395,12 +391,23 @@ static void __rpc_sleep_on_priority(struct rpc_wait_queue *q, } +static void __rpc_sleep_on_priority (struct rpc_wait_queue *q, +struct rpc_task *task, +unsigned char queue_priority) +{ +if (WARN_ON_ONCE (RPC_IS_QUEUED (task))) +return ; +__rpc_do_sleep_on_priority (q, task, queue_priority); +} +static void __rpc_sleep_on_priority_timeout (struct rpc_wait_queue *q,struct rpc_task *task,unsigned long timeout,unsigned char queue_priority) { +if (WARN_ON_ONCE (RPC_IS_QUEUED (task))) +return ;if (time_is_after_jiffies (timeout)) { -__rpc_sleep_on_priority (q, task, queue_priority); +__rpc_do_sleep_on_priority (q, task, queue_priority);__rpc_add_timer (q, task, timeout); }else task->tk_status = -ETIMEDOUT ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 247/388 atm: fix a memory leak of vcc->user_back
In reply to Greg Kroah-HartmanFrom: Cong Wang <[email protected]>
[ Upstream commit 8d9f73c0ad2f20e9fed5380de0a3097825859d03 ]
In lec_arp_clear_vccs() only entry->vcc is freed, but vcc could be installed on entry->recv_vcc too in lec_vcc_added().
This fixes the following memory leak:
unreferenced object 0xffff8880d9266b90 (size 16):
comm "atm2", pid 425, jiffies 4294907980 (age 23.488s) hex dump (first 16 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 6b 6b 6b a5 ............kkk.
backtrace:
[<(____ptrval____)>] kmem_cache_alloc_trace+0x10e/0x151
[<(____ptrval____)>] lane_ioctl+0x4b3/0x569
[<(____ptrval____)>] do_vcc_ioctl+0x1ea/0x236
[<(____ptrval____)>] svc_ioctl+0x17d/0x198
[<(____ptrval____)>] sock_do_ioctl+0x47/0x12f
[<(____ptrval____)>] sock_ioctl+0x2f9/0x322
[<(____ptrval____)>] vfs_ioctl+0x1e/0x2b
[<(____ptrval____)>] ksys_ioctl+0x61/0x80
[<(____ptrval____)>] __x64_sys_ioctl+0x16/0x19
[<(____ptrval____)>] do_syscall_64+0x57/0x65
[<(____ptrval____)>] entry_SYSCALL_64_after_hwframe+0x49/0xb3--- net/atm/lec.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/atm/lec.c +6 -0
@@ -1269,6 +1269,12 @@ static void lec_arp_clear_vccs(struct lec_arp_table *entry) entry->vcc =NULL ; }if (entry->recv_vcc) { +struct atm_vcc *vcc = entry->recv_vcc; +struct lec_vcc_priv *vpriv =LEC_VCC_PRIV (vcc); + +kfree (vpriv); + vcc->user_back =NULL ; + entry->recv_vcc->push = entry->old_recv_push;vcc_release_async (entry->recv_vcc, -EPIPE ); entry->recv_vcc =NULL ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 246/388 devlink: Fix reporters recovery condition
In reply to Greg Kroah-HartmanFrom: Aya Levin <[email protected]>
[ Upstream commit bea0c5c942d3b4e9fb6ed45f6a7de74c6b112437 ]
Devlink health core conditions the reporter's recovery with the expiration of the grace period. This is not relevant for the first recovery. Explicitly demand that the grace period will only apply to recoveries other than the first.
--- net/core/devlink.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/core/devlink.c +5 -2
@@ -4823,6 +4823,7 @@ int devlink_health_report(struct devlink_health_reporter *reporter, {enum devlink_health_reporter_state prev_health_state;struct devlink *devlink = reporter->devlink; +unsigned long recover_ts_threshold;/* write a log message of the current error */ WARN_ON (!msg);
@@ -4832,10 +4833,12 @@ int devlink_health_report(struct devlink_health_reporter *reporter, reporter->health_state =DEVLINK_HEALTH_REPORTER_STATE_ERROR ;/* abort if the previous error wasn't recovered */ + recover_ts_threshold = reporter->last_recovery_ts + +msecs_to_jiffies (reporter->graceful_period);if (reporter->auto_recover && (prev_health_state !=DEVLINK_HEALTH_REPORTER_STATE_HEALTHY || - jiffies - reporter->last_recovery_ts < -msecs_to_jiffies (reporter->graceful_period))) { + (reporter->last_recovery_ts && reporter->recovery_count && +time_is_after_jiffies (recover_ts_threshold)))) { trace_devlink_health_recover_aborted(devlink, reporter->ops->name, reporter->health_state,
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 242/388 arm64: cpufeature: Relax checks for AArch32 support at EL[0-2]
In reply to Greg Kroah-HartmanFrom: Will Deacon <[email protected]>
[ Upstream commit 98448cdfe7060dd5491bfbd3f7214ffe1395d58e ]
We don't need to be quite as strict about mismatched AArch32 support, which is good because the friendly hardware folks have been busy mismatching this to their hearts' content.
* We don't care about EL2 or EL3 (there are silly comments concerning the latter, so remove those)
* EL1 support is gated by the ARM64_HAS_32BIT_EL1 capability and handled gracefully when a mismatch occurs
* EL0 support is gated by the ARM64_HAS_32BIT_EL0 capability and handled gracefully when a mismatch occurs
Relax the AArch32 checks to FTR_NONSTRICT.
--- arch/arm64/kernel/cpufeature.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
arch/arm64/kernel/cpufeature.c +3 -7
@@ -160,11 +160,10 @@ static const struct arm64_ftr_bits ftr_id_aa64pfr0[] = {ARM64_FTR_BITS (FTR_HIDDEN ,FTR_STRICT ,FTR_LOWER_SAFE ,ID_AA64PFR0_GIC_SHIFT ,4 ,0 ),S_ARM64_FTR_BITS (FTR_VISIBLE ,FTR_STRICT ,FTR_LOWER_SAFE ,ID_AA64PFR0_ASIMD_SHIFT ,4 ,ID_AA64PFR0_ASIMD_NI ),S_ARM64_FTR_BITS (FTR_VISIBLE ,FTR_STRICT ,FTR_LOWER_SAFE ,ID_AA64PFR0_FP_SHIFT ,4 ,ID_AA64PFR0_FP_NI ), -/* Linux doesn't care about the EL3 */ ARM64_FTR_BITS (FTR_HIDDEN ,FTR_NONSTRICT ,FTR_LOWER_SAFE ,ID_AA64PFR0_EL3_SHIFT ,4 ,0 ), -ARM64_FTR_BITS (FTR_HIDDEN ,FTR_STRICT ,FTR_LOWER_SAFE ,ID_AA64PFR0_EL2_SHIFT ,4 ,0 ), -ARM64_FTR_BITS (FTR_HIDDEN ,FTR_STRICT ,FTR_LOWER_SAFE ,ID_AA64PFR0_EL1_SHIFT ,4 ,ID_AA64PFR0_EL1_64BIT_ONLY ), -ARM64_FTR_BITS (FTR_HIDDEN ,FTR_STRICT ,FTR_LOWER_SAFE ,ID_AA64PFR0_EL0_SHIFT ,4 ,ID_AA64PFR0_EL0_64BIT_ONLY ), +ARM64_FTR_BITS (FTR_HIDDEN ,FTR_NONSTRICT ,FTR_LOWER_SAFE ,ID_AA64PFR0_EL2_SHIFT ,4 ,0 ), +ARM64_FTR_BITS (FTR_HIDDEN ,FTR_NONSTRICT ,FTR_LOWER_SAFE ,ID_AA64PFR0_EL1_SHIFT ,4 ,ID_AA64PFR0_EL1_64BIT_ONLY ), +ARM64_FTR_BITS (FTR_HIDDEN ,FTR_NONSTRICT ,FTR_LOWER_SAFE ,ID_AA64PFR0_EL0_SHIFT ,4 ,ID_AA64PFR0_EL0_64BIT_ONLY ), ARM64_FTR_END, };
@@ -719,9 +718,6 @@ void update_cpu_features(int cpu, taint |=check_update_ftr_reg (SYS_ID_AA64MMFR2_EL1 , cpu, info->reg_id_aa64mmfr2, boot->reg_id_aa64mmfr2); -/* -* EL3 is not our concern. -*/ taint |=check_update_ftr_reg (SYS_ID_AA64PFR0_EL1 , cpu, info->reg_id_aa64pfr0, boot->reg_id_aa64pfr0); taint |= check_update_ftr_reg(SYS_ID_AA64PFR1_EL1, cpu,
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 219/388 mm/kmemleak.c: use address-of operator on section symbols
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit b0d14fc43d39203ae025f20ef4d5d25d9ccf4be1 ]
Clang warns:
mm/kmemleak.c:1955:28: warning: array comparison always evaluates to a constant [-Wtautological-compare]
if (__start_ro_after_init < _sdata || __end_ro_after_init > _edata)
^
mm/kmemleak.c:1955:60: warning: array comparison always evaluates to a constant [-Wtautological-compare]
if (__start_ro_after_init < _sdata || __end_ro_after_init > _edata)These are not true arrays, they are linker defined symbols, which are just addresses. Using the address of operator silences the warning and does not change the resulting assembly with either clang/ld.lld or gcc/ld (tested with diff + objdump -Dr).
--- mm/kmemleak.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/kmemleak.c +1 -1
@@ -1947,7 +1947,7 @@ void __init kmemleak_init(void)create_object ((unsigned long )__bss_start, __bss_stop - __bss_start,KMEMLEAK_GREY ,GFP_ATOMIC );/* only register .data..ro_after_init if not within .data */ -if (__start_ro_after_init < _sdata || __end_ro_after_init > _edata) +if (&__start_ro_after_init < &_sdata || &__end_ro_after_init > &_edata)create_object ((unsigned long )__start_ro_after_init, __end_ro_after_init - __start_ro_after_init,KMEMLEAK_GREY ,GFP_ATOMIC );
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 243/388 sched/fair: Eliminate bandwidth race between throttling and distribution
In reply to Greg Kroah-HartmanFrom: Paul Turner <[email protected]>
[ Upstream commit e98fa02c4f2ea4991dae422ac7e34d102d2f0599 ]
There is a race window in which an entity begins throttling before quota is added to the pool, but does not finish throttling until after we have finished with distribute_cfs_runtime(). This entity is not observed by distribute_cfs_runtime() because it was not on the throttled list at the time that distribution was running. This race manifests as rare period-length statlls for such entities.
Rather than heavy-weight the synchronization with the progress of distribution, we can fix this by aborting throttling if bandwidth has become available. Otherwise, we immediately add the entity to the throttled list so that it can be observed by a subsequent distribution.
Additionally, we can remove the case of adding the throttled entity to the head of the throttled list, and simply always add to the tail. Thanks to 26a8b12747c97, distribute_cfs_runtime() no longer holds onto its own pool of runtime. This means that if we do hit the !assign and distribute_running case, we know that distribution is about to end.
--- kernel/sched/fair.c | 79 +++++++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 32 deletions(-)
kernel/sched/fair.c +47 -32
@@ -4383,16 +4383,16 @@ static inline struct cfs_bandwidth *tg_cfs_bandwidth(struct task_group *tg) }/* returns 0 on failure to allocate runtime */ -static int assign_cfs_rq_runtime (struct cfs_rq *cfs_rq) +static int __assign_cfs_rq_runtime (struct cfs_bandwidth *cfs_b, +struct cfs_rq *cfs_rq,u64 target_runtime) { -struct task_group *tg = cfs_rq->tg; -struct cfs_bandwidth *cfs_b =tg_cfs_bandwidth (tg); -u64 amount =0 , min_amount; +u64 min_amount, amount =0 ; + +lockdep_assert_held (&cfs_b->lock);/* note: this is a positive sum as runtime_remaining <= 0 */ - min_amount =sched_cfs_bandwidth_slice () - cfs_rq->runtime_remaining; + min_amount = target_runtime - cfs_rq->runtime_remaining; -raw_spin_lock (&cfs_b->lock);if (cfs_b->quota ==RUNTIME_INF ) amount = min_amount;else {
@@ -4404,13 +4404,25 @@ static int assign_cfs_rq_runtime(struct cfs_rq *cfs_rq) cfs_b->idle =0 ; } } -raw_spin_unlock (&cfs_b->lock); cfs_rq->runtime_remaining += amount;return cfs_rq->runtime_remaining >0 ; } +/* returns 0 on failure to allocate runtime */ +static int assign_cfs_rq_runtime (struct cfs_rq *cfs_rq) +{ +struct cfs_bandwidth *cfs_b =tg_cfs_bandwidth (cfs_rq->tg); +int ret; + +raw_spin_lock (&cfs_b->lock); + ret =__assign_cfs_rq_runtime (cfs_b, cfs_rq,sched_cfs_bandwidth_slice ()); +raw_spin_unlock (&cfs_b->lock); + +return ret; +} +static void __account_cfs_rq_runtime (struct cfs_rq *cfs_rq,u64 delta_exec) {/* dock delta_exec before expiring quota (as it could span periods) */
@@ -4499,13 +4511,33 @@ static int tg_throttle_down(struct task_group *tg, void *data)return 0 ; } -static void throttle_cfs_rq (struct cfs_rq *cfs_rq) +static bool throttle_cfs_rq (struct cfs_rq *cfs_rq) {struct rq *rq =rq_of (cfs_rq);struct cfs_bandwidth *cfs_b =tg_cfs_bandwidth (cfs_rq->tg);struct sched_entity *se;long task_delta, idle_task_delta, dequeue =1 ; -bool empty; + +raw_spin_lock (&cfs_b->lock); +/* This will start the period timer if necessary */ +if (__assign_cfs_rq_runtime (cfs_b, cfs_rq,1 )) { +/* +* We have raced with bandwidth becoming available, and if we +* actually throttled the timer might not unthrottle us for an +* entire period. We additionally needed to make sure that any +* subsequent check_cfs_rq_runtime calls agree not to throttle +* us, as we may commit to do cfs put_prev+pick_next, so we ask +* for 1ns of runtime rather than just check cfs_b. +*/ + dequeue =0 ; + }else { +list_add_tail_rcu (&cfs_rq->throttled_list, + &cfs_b->throttled_cfs_rq); + } +raw_spin_unlock (&cfs_b->lock); + +if (!dequeue) +return false;/* Throttle no longer required. */ se = cfs_rq->tg->se[cpu_of (rq_of (cfs_rq))];
@@ -4534,29 +4566,13 @@ static void throttle_cfs_rq(struct cfs_rq *cfs_rq)if (!se)sub_nr_running (rq, task_delta); - cfs_rq->throttled =1 ; - cfs_rq->throttled_clock =rq_clock (rq); -raw_spin_lock (&cfs_b->lock); - empty =list_empty (&cfs_b->throttled_cfs_rq); - -/* -* Add to the _head_ of the list, so that an already-started -* distribute_cfs_runtime will not see us. If disribute_cfs_runtime is -* not running add to the tail so that later runqueues don't get starved. -*/ -if (cfs_b->distribute_running) -list_add_rcu (&cfs_rq->throttled_list, &cfs_b->throttled_cfs_rq); -else -list_add_tail_rcu (&cfs_rq->throttled_list, &cfs_b->throttled_cfs_rq); -/* -* If we're the first throttled task, make sure the bandwidth -* timer is running. +* Note: distribution will already see us throttled via the +* throttled-list. rq->lock protects completion. */ -if (empty) -start_cfs_bandwidth (cfs_b); - -raw_spin_unlock (&cfs_b->lock); + cfs_rq->throttled =1 ; + cfs_rq->throttled_clock =rq_clock (rq); +return true; }void unthrottle_cfs_rq (struct cfs_rq *cfs_rq)
@@ -4915,8 +4931,7 @@ static bool check_cfs_rq_runtime(struct cfs_rq *cfs_rq)if (cfs_rq_throttled (cfs_rq))return true; -throttle_cfs_rq (cfs_rq); -return true; +return throttle_cfs_rq (cfs_rq); }static enum hrtimer_restart sched_cfs_slack_timer (struct hrtimer *timer)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 237/388 KVM: arm64: vgic-its: Fix memory leak on the error path of vgic_add_lpi()
In reply to Greg Kroah-HartmanFrom: Zenghui Yu <[email protected]>
[ Upstream commit 57bdb436ce869a45881d8aa4bc5dac8e072dd2b6 ]
If we're going to fail out the vgic_add_lpi(), let's make sure the allocated vgic_irq memory is also freed. Though it seems that both cases are unlikely to fail.
--- virt/kvm/arm/vgic/vgic-its.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
virt/kvm/arm/vgic/vgic-its.c +9 -2
@@ -96,14 +96,21 @@ out_unlock:* We "cache" the configuration table entries in our struct vgic_irq's. * However we only have those structs for mapped IRQs, so we read in * the respective config data from memory here upon mapping the LPI. +* +* Should any of these fail, behave as if we couldn't create the LPI +* by dropping the refcount and returning the error. */ ret =update_lpi_config (kvm, irq,NULL , false); -if (ret) +if (ret) { +vgic_put_irq (kvm, irq);return ERR_PTR (ret); + } ret =vgic_v3_lpi_sync_pending_status (kvm, irq); -if (ret) +if (ret) { +vgic_put_irq (kvm, irq);return ERR_PTR (ret); + }return irq; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 238/388 net: openvswitch: use u64 for meter bucket
In reply to Greg Kroah-HartmanFrom: Tonghao Zhang <[email protected]>
[ Upstream commit e57358873bb5d6caa882b9684f59140912b37dde ]
When setting the meter rate to 4+Gbps, there is an overflow, the meters don't work as expected.
--- net/openvswitch/meter.c | 2 +- net/openvswitch/meter.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
net/openvswitch/meter.c +1 -1
@@ -251,7 +251,7 @@ static struct dp_meter *dp_meter_create(struct nlattr **a)* * Start with a full bucket. */ - band->bucket = (band->burst_size + band->rate) *1000 ; + band->bucket = (band->burst_size + band->rate) *1000ULL ; band_max_delta_t = band->bucket / band->rate;if (band_max_delta_t > meter->max_delta_t) meter->max_delta_t = band_max_delta_t;
net/openvswitch/meter.h +1 -1
@@ -23,7 +23,7 @@ struct dp_meter_band {u32 type;u32 rate;u32 burst_size; -u32 bucket;/* 1/1000 packets, or in bits */ +u64 bucket;/* 1/1000 packets, or in bits */ struct ovs_flow_stats stats; };
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 239/388 scsi: aacraid: Fix error handling paths in aac_probe_one()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit f7854c382240c1686900b2f098b36430c6f5047e ]
If 'scsi_host_alloc()' or 'kcalloc()' fail, 'error' is known to be 0. Set it explicitly to -ENOMEM before branching to the error handling path.
While at it, remove 2 useless assignments to 'error'. These values are overwridden a few lines later.
--- drivers/scsi/aacraid/linit.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/scsi/aacraid/linit.c +8 -4
@@ -1607,7 +1607,7 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)struct Scsi_Host *shost;struct aac_dev *aac;struct list_head *insert = &aac_devices; -int error = -ENODEV ; +int error;int unique_id =0 ;u64 dmamask;int mask_bits =0 ;
@@ -1632,7 +1632,6 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) error =pci_enable_device (pdev);if (error) goto out; - error = -ENODEV ;if (!(aac_drivers[index].quirks &AAC_QUIRK_SRC )) { error =pci_set_dma_mask (pdev,DMA_BIT_MASK (32 ));
@@ -1664,8 +1663,10 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)pci_set_master (pdev); shost =scsi_host_alloc (&aac_driver_template,sizeof (struct aac_dev )); -if (!shost) +if (!shost) { + error = -ENOMEM ; goto out_disable_pdev; + } shost->irq = pdev->irq; shost->unique_id = unique_id;
@@ -1690,8 +1691,11 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) aac->fibs =kcalloc (shost->can_queue +AAC_NUM_MGT_FIB ,sizeof (struct fib ),GFP_KERNEL ); -if (!aac->fibs) +if (!aac->fibs) { + error = -ENOMEM ; goto out_free_host; + } +spin_lock_init (&aac->fib_lock);mutex_init (&aac->ioctl_mutex);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 240/388 staging:r8188eu: avoid skb_clone for amsdu to msdu conversion
In reply to Greg Kroah-HartmanFrom: Ivan Safonov <[email protected]>
[ Upstream commit 628cbd971a927abe6388d44320e351c337b331e4 ]
skb clones use same data buffer,
so tail of one skb is corrupted by beginning of next skb.
--- drivers/staging/rtl8188eu/core/rtw_recv.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-)
drivers/staging/rtl8188eu/core/rtw_recv.c +6 -13
@@ -1525,21 +1525,14 @@ static int amsdu_to_msdu(struct adapter *padapter, struct recv_frame *prframe)/* Allocate new skb for releasing to upper layer */ sub_skb =dev_alloc_skb (nSubframe_Length +12 ); -if (sub_skb) { -skb_reserve (sub_skb,12 ); -skb_put_data (sub_skb, pdata, nSubframe_Length); - }else { - sub_skb =skb_clone (prframe->pkt,GFP_ATOMIC ); -if (sub_skb) { - sub_skb->data = pdata; - sub_skb->len = nSubframe_Length; -skb_set_tail_pointer (sub_skb, nSubframe_Length); - }else { -DBG_88E ("skb_clone() Fail!!! , nr_subframes=%d\n" , nr_subframes); -break ; - } +if (!sub_skb) { +DBG_88E ("dev_alloc_skb() Fail!!! , nr_subframes=%d\n" , nr_subframes); +break ; } +skb_reserve (sub_skb,12 ); +skb_put_data (sub_skb, pdata, nSubframe_Length); + subframes[nr_subframes++] = sub_skb;if (nr_subframes >=MAX_SUBFRAME_COUNT ) {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 241/388 sparc64: vcc: Fix error return code in vcc_probe()
In reply to Greg Kroah-HartmanFrom: Wei Yongjun <[email protected]>
[ Upstream commit ff62255a2a5c1228a28f2bb063646f948115a309 ]
Fix to return negative error code -ENOMEM from the error handling case instead of 0, as done elsewhere in this function.
--- drivers/tty/vcc.c | 1 + 1 file changed, 1 insertion(+)
drivers/tty/vcc.c +1 -0
@@ -605,6 +605,7 @@ static int vcc_probe(struct vio_dev *vdev, const struct vio_device_id *id) port->index =vcc_table_add (port);if (port->index ==-1 ) {pr_err ("VCC: no more TTY indices left for allocation\n" ); + rv = -ENOMEM ; goto free_ldc; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 227/388 mm/mmap.c: initialize align_offset explicitly for vm_unmapped_area
In reply to Greg Kroah-HartmanFrom: Jaewon Kim <[email protected]>
[ Upstream commit 09ef5283fd96ac424ef0e569626f359bf9ab86c9 ]
On passing requirement to vm_unmapped_area, arch_get_unmapped_area and arch_get_unmapped_area_topdown did not set align_offset. Internally on both unmapped_area and unmapped_area_topdown, if info->align_mask is 0, then info->align_offset was meaningless.
But commit df529cabb7a2 ("mm: mmap: add trace point of vm_unmapped_area") always prints info->align_offset even though it is uninitialized.
Fix this uninitialized value issue by setting it to 0 explicitly.
Before:
vm_unmapped_area: addr=0x755b155000 err=0 total_vm=0x15aaf0 flags=0x1 len=0x109000 lo=0x8000 hi=0x75eed48000 mask=0x0 ofs=0x4022
After:
vm_unmapped_area: addr=0x74a4ca1000 err=0 total_vm=0x168ab1 flags=0x1 len=0x9000 lo=0x8000 hi=0x753d94b000 mask=0x0 ofs=0x0
--- mm/mmap.c | 2 ++ 1 file changed, 2 insertions(+)
mm/mmap.c +2 -0
@@ -2126,6 +2126,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, info.low_limit = mm->mmap_base; info.high_limit = mmap_end; info.align_mask =0 ; + info.align_offset =0 ; return vm_unmapped_area(&info); }#endif
@@ -2167,6 +2168,7 @@ arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr, info.low_limit =max (PAGE_SIZE , mmap_min_addr); info.high_limit =arch_get_mmap_base (addr, mm->mmap_base); info.align_mask =0 ; + info.align_offset =0 ; addr =vm_unmapped_area (&info);/*
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 228/388 ALSA: hda: Skip controller resume if not needed
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
[ Upstream commit c4c8dd6ef807663e42a5f04ea77cd62029eb99fa ]
The HD-audio controller does system-suspend and resume operations by directly calling its helpers __azx_runtime_suspend() and __azx_runtime_resume(). However, in general, we don't have to resume always the device fully at the system resume; typically, if a device has been runtime-suspended, we can leave it to runtime resume.
Usually for achieving this, the driver would call pm_runtime_force_suspend() and pm_runtime_force_resume() pairs in the system suspend and resume ops. Unfortunately, this doesn't work for the resume path in our case. For handling the jack detection at the system resume, a child codec device may need the (literally) forcibly resume even if it's been runtime-suspended, and for that, the controller device must be also resumed even if it's been suspended.
This patch is an attempt to improve the situation. It replaces the direct __azx_runtime_suspend()/_resume() calls with with pm_runtime_force_suspend() and pm_runtime_force_resume() with a slight trick as we've done for the codec side. More exactly:
- azx_has_pm_runtime() check is dropped from azx_runtime_suspend() and azx_runtime_resume(), so that it can be properly executed from the system-suspend/resume path
- The WAKEEN handling depends on the card's power state now; it's set and cleared only for the runtime-suspend
- azx_resume() checks whether any codec may need the forcible resume beforehand. If the forcible resume is required, it does temporary PM refcount up/down for actually triggering the runtime resume.
- A new helper function, hda_codec_need_resume(), is introduced for checking whether the codec needs a forcible runtime-resume, and the existing code is rewritten with that.
--- include/sound/hda_codec.h | 5 +++++ sound/pci/hda/hda_codec.c | 2 +- sound/pci/hda/hda_intel.c | 38 +++++++++++++++++++++++++++----------- 3 files changed, 33 insertions(+), 12 deletions(-)
include/sound/hda_codec.h +5 -0
@@ -494,6 +494,11 @@ void snd_hda_update_power_acct(struct hda_codec *codec);static inline void snd_hda_set_power_save (struct hda_bus *bus,int delay) {}#endif +static inline bool hda_codec_need_resume (struct hda_codec *codec) +{ +return !codec->relaxed_resume && codec->jacktbl.used; +} +#ifdef CONFIG_SND_HDA_PATCH_LOADER /* * patch firmware
sound/pci/hda/hda_codec.c +1 -1
@@ -2958,7 +2958,7 @@ static int hda_codec_runtime_resume(struct device *dev)static int hda_codec_force_resume (struct device *dev) {struct hda_codec *codec =dev_to_hda_codec (dev); -bool forced_resume = !codec->relaxed_resume && codec->jacktbl.used; +bool forced_resume =hda_codec_need_resume (codec);int ret;/* The get/put pair below enforces the runtime resume even if the
sound/pci/hda/hda_intel.c +27 -11
@@ -1025,7 +1025,7 @@ static int azx_suspend(struct device *dev) chip = card->private_data; bus =azx_bus (chip);snd_power_change_state (card, SNDRV_CTL_POWER_D3hot); -__azx_runtime_suspend (chip); +pm_runtime_force_suspend (dev);if (bus->irq >=0 ) {free_irq (bus->irq, chip); bus->irq =-1 ;
@@ -1041,7 +1041,9 @@ static int azx_suspend(struct device *dev)static int azx_resume (struct device *dev) {struct snd_card *card =dev_get_drvdata (dev); +struct hda_codec *codec;struct azx *chip; +bool forced_resume = false;if (!azx_is_pm_ready (card))return 0 ;
@@ -1052,7 +1054,20 @@ static int azx_resume(struct device *dev) chip->msi =0 ;if (azx_acquire_irq (chip,1 ) <0 )return -EIO ; -__azx_runtime_resume (chip, false); + +/* check for the forced resume */ +list_for_each_codec (codec, &chip->bus) { +if (hda_codec_need_resume (codec)) { + forced_resume = true; +break ; + } + } + +if (forced_resume) +pm_runtime_get_noresume (dev); +pm_runtime_force_resume (dev); +if (forced_resume) +pm_runtime_put (dev);snd_power_change_state (card,SNDRV_CTL_POWER_D0 );trace_azx_resume (chip);
@@ -1099,12 +1114,12 @@ static int azx_runtime_suspend(struct device *dev)if (!azx_is_pm_ready (card))return 0 ; chip = card->private_data; -if (!azx_has_pm_runtime (chip)) -return 0 ;/* enable controller wake up event */ -azx_writew (chip,WAKEEN ,azx_readw (chip,WAKEEN ) | -STATESTS_INT_MASK ); +if (snd_power_get_state (card) ==SNDRV_CTL_POWER_D0 ) { +azx_writew (chip,WAKEEN ,azx_readw (chip,WAKEEN ) | +STATESTS_INT_MASK ); + }__azx_runtime_suspend (chip);trace_azx_runtime_suspend (chip);
@@ -1115,17 +1130,18 @@ static int azx_runtime_resume(struct device *dev) {struct snd_card *card =dev_get_drvdata (dev);struct azx *chip; +bool from_rt =snd_power_get_state (card) ==SNDRV_CTL_POWER_D0 ;if (!azx_is_pm_ready (card))return 0 ; chip = card->private_data; -if (!azx_has_pm_runtime (chip)) -return 0 ; -__azx_runtime_resume (chip, true); +__azx_runtime_resume (chip, from_rt);/* disable controller Wake Up event*/ -azx_writew (chip,WAKEEN ,azx_readw (chip,WAKEEN ) & - ~STATESTS_INT_MASK ); +if (from_rt) { +azx_writew (chip,WAKEEN ,azx_readw (chip,WAKEEN ) & + ~STATESTS_INT_MASK ); + }trace_azx_runtime_resume (chip);return 0 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 188/388 net: axienet: Convert DMA error handler to a work queue
In reply to Greg Kroah-HartmanFrom: Andre Przywara <[email protected]>
[ Upstream commit 24201a64770afe2e17050b2ab9e8c0e24e9c23b2 ]
The DMA error handler routine is currently a tasklet, scheduled to run after the DMA error IRQ was handled.
However it needs to take the MDIO mutex, which is not allowed to do in a tasklet. A kernel (with debug options) complains consequently:
[ 614.050361] net eth0: DMA Tx error 0x174019
[ 614.064002] net eth0: Current BD is at: 0x8f84aa0ce
[ 614.080195] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:935
[ 614.109484] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 40, name: kworker/u4:4
[ 614.135428] 3 locks held by kworker/u4:4/40:
[ 614.149075] #0: ffff000879863328 ((wq_completion)rpciod){....}, at: process_one_work+0x1f0/0x6a8
[ 614.177528] #1: ffff80001251bdf8 ((work_completion)(&task->u.tk_work)){....}, at: process_one_work+0x1f0/0x6a8
[ 614.209033] #2: ffff0008784e0110 (sk_lock-AF_INET-RPC){....}, at: tcp_sendmsg+0x24/0x58
[ 614.235429] CPU: 0 PID: 40 Comm: kworker/u4:4 Not tainted 5.6.0-rc3-00926-g4a165a9d5921 #26
[ 614.260854] Hardware name: ARM Test FPGA (DT)
[ 614.274734] Workqueue: rpciod rpc_async_schedule
[ 614.289022] Call trace:
[ 614.296871] dump_backtrace+0x0/0x1a0
[ 614.308311] show_stack+0x14/0x20
[ 614.318751] dump_stack+0xbc/0x100
[ 614.329403] ___might_sleep+0xf0/0x140
[ 614.341018] __might_sleep+0x4c/0x80
[ 614.352201] __mutex_lock+0x5c/0x8a8
[ 614.363348] mutex_lock_nested+0x1c/0x28
[ 614.375654] axienet_dma_err_handler+0x38/0x388
[ 614.389999] tasklet_action_common.isra.15+0x160/0x1a8
[ 614.405894] tasklet_action+0x24/0x30
[ 614.417297] efi_header_end+0xe0/0x494
[ 614.429020] irq_exit+0xd0/0xd8
[ 614.439047] __handle_domain_irq+0x60/0xb0
[ 614.451877] gic_handle_irq+0xdc/0x2d0
[ 614.463486] el1_irq+0xcc/0x180
[ 614.473451] __tcp_transmit_skb+0x41c/0xb58
[ 614.486513] tcp_write_xmit+0x224/0x10a0
[ 614.498792] __tcp_push_pending_frames+0x38/0xc8
[ 614.513126] tcp_rcv_established+0x41c/0x820
[ 614.526301] tcp_v4_do_rcv+0x8c/0x218
[ 614.537784] __release_sock+0x5c/0x108
[ 614.549466] release_sock+0x34/0xa0
[ 614.560318] tcp_sendmsg+0x40/0x58
[ 614.571053] inet_sendmsg+0x40/0x68
[ 614.582061] sock_sendmsg+0x18/0x30
[ 614.593074] xs_sendpages+0x218/0x328
[ 614.604506] xs_tcp_send_request+0xa0/0x1b8
[ 614.617461] xprt_transmit+0xc8/0x4f0
[ 614.628943] call_transmit+0x8c/0xa0
[ 614.640028] __rpc_execute+0xbc/0x6f8
[ 614.651380] rpc_async_schedule+0x28/0x48
[ 614.663846] process_one_work+0x298/0x6a8
[ 614.676299] worker_thread+0x40/0x490
[ 614.687687] kthread+0x134/0x138
[ 614.697804] ret_from_fork+0x10/0x18
[ 614.717319] xilinx_axienet 7fe00000.ethernet eth0: Link is Down
[ 615.748343] xilinx_axienet 7fe00000.ethernet eth0: Link is Up - 1Gbps/Full - flow control offSince tasklets are not really popular anymore anyway, lets convert this over to a work queue, which can sleep and thus can take the MDIO mutex.
--- drivers/net/ethernet/xilinx/xilinx_axienet.h | 2 +- .../net/ethernet/xilinx/xilinx_axienet_main.c | 24 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet.h +1 -1
@@ -435,7 +435,7 @@ struct axienet_local {void __iomem *regs;void __iomem *dma_regs; -struct tasklet_struct dma_err_tasklet; +struct work_struct dma_err_task;int tx_irq;int rx_irq;
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +12 -12
@@ -806,7 +806,7 @@ static irqreturn_t axienet_tx_irq(int irq, void *_ndev)/* Write to the Rx channel control register */ axienet_dma_out32 (lp,XAXIDMA_RX_CR_OFFSET , cr); -tasklet_schedule (&lp->dma_err_tasklet); +schedule_work (&lp->dma_err_task);axienet_dma_out32 (lp,XAXIDMA_TX_SR_OFFSET , status); } out:
@@ -855,7 +855,7 @@ static irqreturn_t axienet_rx_irq(int irq, void *_ndev)/* write to the Rx channel control register */ axienet_dma_out32 (lp,XAXIDMA_RX_CR_OFFSET , cr); -tasklet_schedule (&lp->dma_err_tasklet); +schedule_work (&lp->dma_err_task);axienet_dma_out32 (lp,XAXIDMA_RX_SR_OFFSET , status); } out:
@@ -891,7 +891,7 @@ static irqreturn_t axienet_eth_irq(int irq, void *_ndev)return IRQ_HANDLED ; } -static void axienet_dma_err_handler (unsigned long data); +static void axienet_dma_err_handler (struct work_struct *work);/** * axienet_open - Driver open routine.
@@ -935,9 +935,8 @@ static int axienet_open(struct net_device *ndev)phylink_start (lp->phylink); -/* Enable tasklets for Axi DMA error handling */ -tasklet_init (&lp->dma_err_tasklet, axienet_dma_err_handler, - (unsigned long ) lp); +/* Enable worker thread for Axi DMA error handling */ +INIT_WORK (&lp->dma_err_task, axienet_dma_err_handler);/* Enable interrupts for Axi DMA Tx */ ret = request_irq(lp->tx_irq, axienet_tx_irq, IRQF_SHARED,
@@ -966,7 +965,7 @@ err_rx_irq: err_tx_irq:phylink_stop (lp->phylink);phylink_disconnect_phy (lp->phylink); -tasklet_kill (&lp->dma_err_tasklet); +cancel_work_sync (&lp->dma_err_task);dev_err (lp->dev,"request_irq() failed\n" );return ret; }
@@ -1025,7 +1024,7 @@ static int axienet_stop(struct net_device *ndev)axienet_mdio_enable (lp);mutex_unlock (&lp->mii_bus->mdio_lock); -tasklet_kill (&lp->dma_err_tasklet); +cancel_work_sync (&lp->dma_err_task);if (lp->eth_irq >0 )free_irq (lp->eth_irq, ndev);
@@ -1505,17 +1504,18 @@ static const struct phylink_mac_ops axienet_phylink_ops = { };/** -* axienet_dma_err_handler - Tasklet handler for Axi DMA Error -* @data: Data passed +* axienet_dma_err_handler - Work queue task for Axi DMA Error +* @work: pointer to work_struct * * Resets the Axi DMA and Axi Ethernet devices, and reconfigures the * Tx/Rx BDs. */ -static void axienet_dma_err_handler (unsigned long data) +static void axienet_dma_err_handler (struct work_struct *work) {u32 axienet_status;u32 cr, i; -struct axienet_local *lp = (struct axienet_local *) data; + struct axienet_local *lp = container_of(work, struct axienet_local, + dma_err_task);struct net_device *ndev = lp->ndev;struct axidma_bd *cur_p;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 215/388 PCI: pciehp: Fix MSI interrupt race
In reply to Greg Kroah-HartmanFrom: Stuart Hayes <[email protected]>
[ Upstream commit 8edf5332c39340b9583cf9cba659eb7ec71f75b5 ]
Without this commit, a PCIe hotplug port can stop generating interrupts on hotplug events, so device adds and removals will not be seen:
The pciehp interrupt handler pciehp_isr() reads the Slot Status register and then writes back to it to clear the bits that caused the interrupt. If a different interrupt event bit gets set between the read and the write, pciehp_isr() returns without having cleared all of the interrupt event bits. If this happens when the MSI isn't masked (which by default it isn't in handle_edge_irq(), and which it will never be when MSI per-vector masking is not supported), we won't get any more hotplug interrupts from that device.
That is expected behavior, according to the PCIe Base Spec r5.0, section 6.7.3.4, "Software Notification of Hot-Plug Events".
Because the Presence Detect Changed and Data Link Layer State Changed event bits can both get set at nearly the same time when a device is added or removed, this is more likely to happen than it might seem. The issue was found (and can be reproduced rather easily) by connecting and disconnecting an NVMe storage device on at least one system model where the NVMe devices were being connected to an AMD PCIe port (PCI device 0x1022/0x1483).
Fix the issue by modifying pciehp_isr() to loop back and re-read the Slot Status register immediately after writing to it, until it sees that all of the event status bits have been cleared.
[lukas: drop loop count limitation, write "events" instead of "status", don't loop back in INTx and poll modes, tweak code comment & commit msg]
--- drivers/pci/hotplug/pciehp_hpc.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
drivers/pci/hotplug/pciehp_hpc.c +20 -6
@@ -529,7 +529,7 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id)struct controller *ctrl = (struct controller *)dev_id;struct pci_dev *pdev =ctrl_dev (ctrl);struct device *parent = pdev->dev.parent; -u16 status, events; +u16 status, events =0 ;/* * Interrupts only occur in D3hot or shallower and only if enabled
@@ -554,6 +554,7 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id) } } +read_status:pcie_capability_read_word (pdev,PCI_EXP_SLTSTA , &status);if (status == (u16 ) ~0 ) {ctrl_info (ctrl,"%s: no response from device\n" , __func__);
@@ -566,24 +567,37 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id)* Slot Status contains plain status bits as well as event * notification bits; right now we only want the event bits. */ - events = status & (PCI_EXP_SLTSTA_ABP |PCI_EXP_SLTSTA_PFD | -PCI_EXP_SLTSTA_PDC |PCI_EXP_SLTSTA_CC | -PCI_EXP_SLTSTA_DLLSC ); + status &=PCI_EXP_SLTSTA_ABP |PCI_EXP_SLTSTA_PFD | +PCI_EXP_SLTSTA_PDC |PCI_EXP_SLTSTA_CC | +PCI_EXP_SLTSTA_DLLSC ;/* * If we've already reported a power fault, don't report it again * until we've done something to handle it. */ if (ctrl->power_fault_detected) - events &= ~PCI_EXP_SLTSTA_PFD ; + status &= ~PCI_EXP_SLTSTA_PFD ; + events |= status;if (!events) {if (parent)pm_runtime_put (parent);return IRQ_NONE ; } -pcie_capability_write_word (pdev,PCI_EXP_SLTSTA , events); +if (status) { +pcie_capability_write_word (pdev,PCI_EXP_SLTSTA , events); + +/* +* In MSI mode, all event bits must be zero before the port +* will send a new interrupt (PCIe Base Spec r5.0 sec 6.7.3.4). +* So re-read the Slot Status register in case a bit was set +* between read and write. +*/ +if (pci_dev_msi_enabled (pdev) && !pciehp_poll_mode) + goto read_status; + } +ctrl_dbg (ctrl,"pending interrupts %#06x from Slot Status\n" , events);if (parent)pm_runtime_put (parent);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 214/388 ALSA: usb-audio: Fix case when USB MIDI interface has more than one extra endpoint descriptor
In reply to Greg Kroah-HartmanFrom: Andreas Steinmetz <[email protected]>
[ Upstream commit 5c6cd7021a05a02fcf37f360592d7c18d4d807fb ]
The Miditech MIDIFACE 16x16 (USB ID 1290:1749) has more than one extra endpoint descriptor.
The first extra descriptor is: 0x06 0x30 0x00 0x00 0x00 0x00
As the code in snd_usbmidi_get_ms_info() looks only at the first extra descriptor to find USB_DT_CS_ENDPOINT the device as such is recognized but there is neither input nor output configured.
The patch iterates through the extra descriptors to find the proper one. With this patch the device is correctly configured.
--- sound/usb/midi.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-)
sound/usb/midi.c +24 -5
@@ -1827,6 +1827,28 @@ static int snd_usbmidi_create_endpoints(struct snd_usb_midi *umidi,return 0 ; } +static struct usb_ms_endpoint_descriptor *find_usb_ms_endpoint_descriptor ( +struct usb_host_endpoint *hostep) +{ +unsigned char *extra = hostep->extra; +int extralen = hostep->extralen; + +while (extralen >3 ) { +struct usb_ms_endpoint_descriptor *ms_ep = + (struct usb_ms_endpoint_descriptor *)extra; + +if (ms_ep->bLength >3 && + ms_ep->bDescriptorType ==USB_DT_CS_ENDPOINT && + ms_ep->bDescriptorSubtype ==UAC_MS_GENERAL ) +return ms_ep; +if (!extra[0 ]) +break ; + extralen -= extra[0 ]; + extra += extra[0 ]; + } +return NULL ; +} +/* * Returns MIDIStreaming device capabilities. */
@@ -1864,11 +1886,8 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi *umidi, ep =get_ep_desc (hostep);if (!usb_endpoint_xfer_bulk (ep) && !usb_endpoint_xfer_int (ep))continue ; - ms_ep = (struct usb_ms_endpoint_descriptor *)hostep->extra; -if (hostep->extralen <4 || - ms_ep->bLength <4 || - ms_ep->bDescriptorType !=USB_DT_CS_ENDPOINT || - ms_ep->bDescriptorSubtype !=UAC_MS_GENERAL ) + ms_ep =find_usb_ms_endpoint_descriptor (hostep); +if (!ms_ep)continue ;if (usb_endpoint_dir_out (ep)) {if (endpoints[epidx].out_ep) {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 213/388 ubifs: Fix out-of-bounds memory access caused by abnormal value of node_len
In reply to Greg Kroah-HartmanFrom: Liu Song <[email protected]>
[ Upstream commit acc5af3efa303d5f36cc8c0f61716161f6ca1384 ]
In “ubifs_check_node”, when the value of "node_len" is abnormal, the code will goto label of "out_len" for execution. Then, in the following "ubifs_dump_node", if inode type is "UBIFS_DATA_NODE", in "print_hex_dump", an out-of-bounds access may occur due to the wrong "ch->len".
Therefore, when the value of "node_len" is abnormal, data length should to be adjusted to a reasonable safe range. At this time, structured data is not credible, so dump the corrupted data directly for analysis.
--- fs/ubifs/io.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
fs/ubifs/io.c +14 -2
@@ -225,7 +225,7 @@ int ubifs_is_mapped(const struct ubifs_info *c, int lnum)int ubifs_check_node (const struct ubifs_info *c,const void *buf,int lnum,int offs,int quiet,int must_chk_crc) { -int err = -EINVAL , type, node_len; +int err = -EINVAL , type, node_len, dump_node =1 ;uint32_t crc, node_crc, magic;const struct ubifs_ch *ch = buf;
@@ -278,10 +278,22 @@ int ubifs_check_node(const struct ubifs_info *c, const void *buf, int lnum, out_len:if (!quiet)ubifs_err (c,"bad node length %d" , node_len); +if (type ==UBIFS_DATA_NODE && node_len >UBIFS_DATA_NODE_SZ ) + dump_node =0 ; out:if (!quiet) {ubifs_err (c,"bad node at LEB %d:%d" , lnum, offs); -ubifs_dump_node (c, buf); +if (dump_node) { +ubifs_dump_node (c, buf); + }else { +int safe_len =min3 (node_len, c->leb_size - offs, + (int )UBIFS_MAX_DATA_NODE_SZ ); +pr_err ("\tprevent out-of-bounds memory access\n" ); +pr_err ("\ttruncated data node length %d\n" , safe_len); +pr_err ("\tcorrupted data node:\n" ); +print_hex_dump (KERN_ERR ,"\t" ,DUMP_PREFIX_OFFSET ,32 ,1 , + buf, safe_len,0 ); + }dump_stack (); }return err;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 207/388 SUNRPC: Fix a potential buffer overflow in svc_print_xprts()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit b25b60d7bfb02a74bc3c2d998e09aab159df8059 ]
'maxlen' is the total size of the destination buffer. There is only one caller and this value is 256.
When we compute the size already used and what we would like to add in the buffer, the trailling NULL character is not taken into account. However, this trailling character will be added by the 'strcat' once we have checked that we have enough place.
So, there is a off-by-one issue and 1 byte of the stack could be erroneously overwridden.
Take into account the trailling NULL, when checking if there is enough place in the destination buffer.
While at it, also replace a 'sprintf' by a safer 'snprintf', check for output truncation and avoid a superfluous 'strlen'.
[ cel: very minor fix to documenting comment
--- net/sunrpc/svc_xprt.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
net/sunrpc/svc_xprt.c +14 -5
@@ -104,8 +104,17 @@ void svc_unreg_xprt_class(struct svc_xprt_class *xcl) }EXPORT_SYMBOL_GPL (svc_unreg_xprt_class); -/* -* Format the transport list for printing +/** +* svc_print_xprts - Format the transport list for printing +* @buf: target buffer for formatted address +* @maxlen: length of target buffer +* +* Fills in @buf with a string containing a list of transport names, each name +* terminated with '\n'. If the buffer is too small, some entries may be +* missing, but it is guaranteed that all lines in the output buffer are +* complete. +* +* Returns positive length of the filled-in string. */ int svc_print_xprts (char *buf,int maxlen) {
@@ -118,9 +127,9 @@ int svc_print_xprts(char *buf, int maxlen)list_for_each_entry (xcl, &svc_xprt_class_list, xcl_list) {int slen; -sprintf (tmpstr,"%s %d\n" , xcl->xcl_name, xcl->xcl_max_payload); - slen =strlen (tmpstr); -if (len + slen > maxlen) + slen =snprintf (tmpstr,sizeof (tmpstr),"%s %d\n" , + xcl->xcl_name, xcl->xcl_max_payload); +if (slen >=sizeof (tmpstr) || len + slen >= maxlen)break ; len += slen;strcat (buf, tmpstr);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 205/388 IB/iser: Always check sig MR before putting it to the free pool
In reply to Greg Kroah-HartmanFrom: Sergey Gorenko <[email protected]>
[ Upstream commit 26e28deb813eed908cf31a6052870b6493ec0e86 ]
libiscsi calls the check_protection transport handler only if SCSI-Respose is received. So, the handler is never called if iSCSI task is completed for some other reason like a timeout or error handling. And this behavior looks correct. But the iSER does not handle this case properly because it puts a non-checked signature MR to the free pool. Then the error occurs at reusing the MR because it is not allowed to invalidate a signature MR without checking.
This commit adds an extra check to iser_unreg_mem_fastreg(), which is a part of the task cleanup flow. Now the signature MR is checked there if it is needed.
--- drivers/infiniband/ulp/iser/iser_memory.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
drivers/infiniband/ulp/iser/iser_memory.c +18 -3
@@ -292,12 +292,27 @@ void iser_unreg_mem_fastreg(struct iscsi_iser_task *iser_task, {struct iser_device *device = iser_task->iser_conn->ib_conn.device;struct iser_mem_reg *reg = &iser_task->rdma_reg[cmd_dir]; +struct iser_fr_desc *desc; +struct ib_mr_status mr_status; -if (!reg->mem_h) + desc = reg->mem_h; +if (!desc)return ; - device->reg_ops->reg_desc_put (&iser_task->iser_conn->ib_conn, - reg->mem_h); +/* +* The signature MR cannot be invalidated and reused without checking. +* libiscsi calls the check_protection transport handler only if +* SCSI-Response is received. And the signature MR is not checked if +* the task is completed for some other reason like a timeout or error +* handling. That's why we must check the signature MR here before +* putting it to the free pool. +*/ +if (unlikely (desc->sig_protected)) { + desc->sig_protected = false; +ib_check_mr_status (desc->rsc.sig_mr,IB_MR_CHECK_SIG_STATUS , + &mr_status); + } + device->reg_ops->reg_desc_put (&iser_task->iser_conn->ib_conn, desc); reg->mem_h =NULL ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 204/388 RDMA/rxe: Set sys_image_guid to be aligned with HW IB devices
In reply to Greg Kroah-HartmanFrom: Zhu Yanjun <[email protected]>
[ Upstream commit d0ca2c35dd15a3d989955caec02beea02f735ee6 ]
The RXE driver doesn't set sys_image_guid and user space applications see zeros. This causes to pyverbs tests to fail with the following traceback, because the IBTA spec requires to have valid sys_image_guid.
Traceback (most recent call last):
File "./tests/test_device.py", line 51, in test_query_device
self.verify_device_attr(attr)
File "./tests/test_device.py", line 74, in verify_device_attr
assert attr.sys_image_guid != 0
In order to fix it, set sys_image_guid to be equal to node_guid.
Before:
5: rxe0: ... node_guid 5054:00ff:feaa:5363 sys_image_guid 0000:0000:0000:0000
After:
5: rxe0: ... node_guid 5054:00ff:feaa:5363 sys_image_guid 5054:00ff:feaa:5363
--- drivers/infiniband/sw/rxe/rxe.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/sw/rxe/rxe.c +2 -0
@@ -118,6 +118,8 @@ static void rxe_init_device_param(struct rxe_dev *rxe) rxe->attr.max_fast_reg_page_list_len =RXE_MAX_FMR_PAGE_LIST_LEN ; rxe->attr.max_pkeys =RXE_MAX_PKEYS ; rxe->attr.local_ca_ack_delay =RXE_LOCAL_CA_ACK_DELAY ; +addrconf_addr_eui48 ((unsigned char *)&rxe->attr.sys_image_guid, + rxe->ndev->dev_addr); rxe->max_ucontext =RXE_MAX_UCONTEXT ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 201/388 nvme: Fix controller creation races with teardown flow
In reply to Greg Kroah-HartmanFrom: Israel Rukshin <[email protected]>
[ Upstream commit ce1518139e6976cf19c133b555083354fdb629b8 ]
Calling nvme_sysfs_delete() when the controller is in the middle of creation may cause several bugs. If the controller is in NEW state we remove delete_controller file and don't delete the controller. The user will not be able to use nvme disconnect command on that controller again, although the controller may be active. Other bugs may happen if the controller is in the middle of create_ctrl callback and nvme_do_delete_ctrl() starts. For example, freeing I/O tagset at nvme_do_delete_ctrl() before it was allocated at create_ctrl callback.
To fix all those races don't allow the user to delete the controller before it was fully created.
--- drivers/nvme/host/core.c | 5 +++++ drivers/nvme/host/nvme.h | 1 + 2 files changed, 6 insertions(+)
drivers/nvme/host/core.c +5 -0
@@ -3197,6 +3197,10 @@ static ssize_t nvme_sysfs_delete(struct device *dev, {struct nvme_ctrl *ctrl =dev_get_drvdata (dev); +/* Can't delete non-created controllers */ +if (!ctrl->created) +return -EBUSY ; +if (device_remove_file_self (dev, attr))nvme_delete_ctrl_sync (ctrl);return count;
@@ -3992,6 +3996,7 @@ void nvme_start_ctrl(struct nvme_ctrl *ctrl)nvme_queue_scan (ctrl);nvme_start_queues (ctrl); } + ctrl->created = true; }EXPORT_SYMBOL_GPL (nvme_start_ctrl);
drivers/nvme/host/nvme.h +1 -0
@@ -253,6 +253,7 @@ struct nvme_ctrl {struct nvme_command ka_cmd;struct work_struct fw_act_work;unsigned long events; +bool created;#ifdef CONFIG_NVME_MULTIPATH /* asymmetric namespace access: */
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 199/388 nvme-multipath: do not reset on unknown status
In reply to Greg Kroah-HartmanFrom: John Meneghini <[email protected]>
[ Upstream commit 764e9332098c0e60251386a507fe46ac91276120 ]
The nvme multipath error handling defaults to controller reset if the error is unknown. There are, however, no existing nvme status codes that indicate a reset should be used, and resetting causes unnecessary disruption to the rest of IO.
Change nvme's error handling to first check if failover should happen. If not, let the normal error handling take over rather than reset the controller.
--- drivers/nvme/host/core.c | 5 +---- drivers/nvme/host/multipath.c | 21 +++++++++------------ drivers/nvme/host/nvme.h | 5 +++-- 3 files changed, 13 insertions(+), 18 deletions(-)
drivers/nvme/host/core.c +1 -4
@@ -288,11 +288,8 @@ void nvme_complete_rq(struct request *req)nvme_req (req)->ctrl->comp_seen = true;if (unlikely (status !=BLK_STS_OK &&nvme_req_needs_retry (req))) { -if ((req->cmd_flags &REQ_NVME_MPATH ) && -blk_path_error (status)) { -nvme_failover_req (req); +if ((req->cmd_flags &REQ_NVME_MPATH ) &&nvme_failover_req (req))return ; - }if (!blk_queue_dying (req->q)) {nvme_retry_req (req);
drivers/nvme/host/multipath.c +9 -12
@@ -65,17 +65,12 @@ void nvme_set_disk_name(char *disk_name, struct nvme_ns *ns, } } -void nvme_failover_req (struct request *req) +bool nvme_failover_req (struct request *req) {struct nvme_ns *ns = req->q->queuedata;u16 status =nvme_req (req)->status;unsigned long flags; -spin_lock_irqsave (&ns->head->requeue_lock, flags); -blk_steal_bios (&ns->head->requeue_list, req); -spin_unlock_irqrestore (&ns->head->requeue_lock, flags); -blk_mq_end_request (req,0 ); -switch (status &0x7ff ) {case NVME_SC_ANA_TRANSITION :case NVME_SC_ANA_INACCESSIBLE :
@@ -104,15 +99,17 @@ void nvme_failover_req(struct request *req)nvme_mpath_clear_current_path (ns);break ;default : -/* -* Reset the controller for any non-ANA error as we don't know -* what caused the error. -*/ -nvme_reset_ctrl (ns->ctrl); -break ; +/* This was a non-ANA error so follow the normal error path. */ +return false; } +spin_lock_irqsave (&ns->head->requeue_lock, flags); +blk_steal_bios (&ns->head->requeue_list, req); +spin_unlock_irqrestore (&ns->head->requeue_lock, flags); +blk_mq_end_request (req,0 ); +kblockd_schedule_work (&ns->head->requeue_work); +return true; }void nvme_kick_requeue_lists (struct nvme_ctrl *ctrl)
drivers/nvme/host/nvme.h +3 -2
@@ -530,7 +530,7 @@ void nvme_mpath_wait_freeze(struct nvme_subsystem *subsys);void nvme_mpath_start_freeze (struct nvme_subsystem *subsys);void nvme_set_disk_name (char *disk_name,struct nvme_ns *ns,struct nvme_ctrl *ctrl,int *flags); -void nvme_failover_req (struct request *req); +bool nvme_failover_req (struct request *req);void nvme_kick_requeue_lists (struct nvme_ctrl *ctrl);int nvme_mpath_alloc_disk (struct nvme_ctrl *ctrl,struct nvme_ns_head *head);void nvme_mpath_add_disk (struct nvme_ns *ns,struct nvme_id_ns *id);
@@ -579,8 +579,9 @@ static inline void nvme_set_disk_name(char *disk_name, struct nvme_ns *ns,sprintf (disk_name,"nvme%dn%d" , ctrl->instance, ns->head->instance); } -static inline void nvme_failover_req (struct request *req) +static inline bool nvme_failover_req (struct request *req) { +return false; }static inline void nvme_kick_requeue_lists (struct nvme_ctrl *ctrl) {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 198/388 perf: Use new infrastructure to fix deadlocks in execve
In reply to Greg Kroah-HartmanFrom: Bernd Edlinger <[email protected]>
[ Upstream commit 6914303824bb572278568330d72fc1f8f9814e67 ]
This changes perf_event_set_clock to use the new exec_update_mutex instead of cred_guard_mutex.
This should be safe, as the credentials are only used for reading.
--- kernel/events/core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
kernel/events/core.c +6 -6
@@ -1253,7 +1253,7 @@ static void put_ctx(struct perf_event_context *ctx)* function. * * Lock order: -* cred_guard_mutex +* exec_update_mutex * task_struct::perf_event_mutex * perf_event_context::mutex * perf_event::child_mutex;
@@ -11002,14 +11002,14 @@ SYSCALL_DEFINE5(perf_event_open, }if (task) { - err =mutex_lock_interruptible (&task->signal->cred_guard_mutex); + err =mutex_lock_interruptible (&task->signal->exec_update_mutex);if (err) goto err_task;/* * Reuse ptrace permission checks for now. * -* We must hold cred_guard_mutex across this and any potential +* We must hold exec_update_mutex across this and any potential * perf_install_in_context() call for this new event to * serialize against exec() altering our credentials (and the * perf_event_exit_task() that could imply).
@@ -11298,7 +11298,7 @@ SYSCALL_DEFINE5(perf_event_open,mutex_unlock (&ctx->mutex);if (task) { -mutex_unlock (&task->signal->cred_guard_mutex); +mutex_unlock (&task->signal->exec_update_mutex);put_task_struct (task); }
@@ -11334,7 +11334,7 @@ err_alloc:free_event (event); err_cred:if (task) -mutex_unlock (&task->signal->cred_guard_mutex); +mutex_unlock (&task->signal->exec_update_mutex); err_task:if (task)put_task_struct (task);
@@ -11639,7 +11639,7 @@ static void perf_event_exit_task_context(struct task_struct *child, int ctxn)/* * When a child task exits, feed back event values to parent events. * -* Can be called with cred_guard_mutex held when called from +* Can be called with exec_update_mutex held when called from * install_exec_creds(). */ void perf_event_exit_task (struct task_struct *child)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 161/388 scsi: aacraid: Disabling TM path and only processing IOP reset
In reply to Greg Kroah-HartmanFrom: Sagar Biradar <[email protected]>
[ Upstream commit bef18d308a2215eff8c3411a23d7f34604ce56c3 ]
Fixes the occasional adapter panic when sg_reset is issued with -d, -t, -b and -H flags. Removal of command type HBA_IU_TYPE_SCSI_TM_REQ in aac_hba_send since iu_type, request_id and fib_flags are not populated. Device and target reset handlers are made to send TMF commands only when reset_state is 0.
--- drivers/scsi/aacraid/commsup.c | 2 +- drivers/scsi/aacraid/linit.c | 34 +++++++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 10 deletions(-)
drivers/scsi/aacraid/commsup.c +1 -1
@@ -728,7 +728,7 @@ int aac_hba_send(u8 command, struct fib *fibptr, fib_callback callback, hbacmd->request_id =cpu_to_le32 ((((u32)(fibptr - dev->fibs)) <<2 ) +1 ); fibptr->flags |=FIB_CONTEXT_FLAG_SCSI_CMD ; - }else if (command !=HBA_IU_TYPE_SCSI_TM_REQ ) + }else return -EINVAL ;
drivers/scsi/aacraid/linit.c +25 -9
@@ -723,7 +723,11 @@ static int aac_eh_abort(struct scsi_cmnd* cmd) status =aac_hba_send (HBA_IU_TYPE_SCSI_TM_REQ , fib, (fib_callback ) aac_hba_callback, (void *) cmd); - +if (status != -EINPROGRESS ) { +aac_fib_complete (fib); +aac_fib_free (fib); +return ret; + }/* Wait up to 15 secs for completion */ for (count =0 ; count <15 ; ++count) {if (cmd->SCp.sent_command) {
@@ -902,11 +906,11 @@ static int aac_eh_dev_reset(struct scsi_cmnd *cmd) info = &aac->hba_map[bus][cid]; -if (info->devtype !=AAC_DEVTYPE_NATIVE_RAW && - info->reset_state >0 ) +if (!(info->devtype ==AAC_DEVTYPE_NATIVE_RAW && + !(info->reset_state >0 )))return FAILED ; -pr_err ("%s: Host adapter reset request. SCSI hang ?\n" , +pr_err ("%s: Host device reset request. SCSI hang ?\n" ,AAC_DRIVERNAME ); fib =aac_fib_alloc (aac);
@@ -921,7 +925,12 @@ static int aac_eh_dev_reset(struct scsi_cmnd *cmd) status =aac_hba_send (command, fib, (fib_callback ) aac_tmf_callback, (void *) info); - +if (status != -EINPROGRESS ) { + info->reset_state =0 ; +aac_fib_complete (fib); +aac_fib_free (fib); +return ret; + }/* Wait up to 15 seconds for completion */ for (count =0 ; count <15 ; ++count) {if (info->reset_state ==0 ) {
@@ -960,11 +969,11 @@ static int aac_eh_target_reset(struct scsi_cmnd *cmd) info = &aac->hba_map[bus][cid]; -if (info->devtype !=AAC_DEVTYPE_NATIVE_RAW && - info->reset_state >0 ) +if (!(info->devtype ==AAC_DEVTYPE_NATIVE_RAW && + !(info->reset_state >0 )))return FAILED ; -pr_err ("%s: Host adapter reset request. SCSI hang ?\n" , +pr_err ("%s: Host target reset request. SCSI hang ?\n" ,AAC_DRIVERNAME ); fib =aac_fib_alloc (aac);
@@ -981,6 +990,13 @@ static int aac_eh_target_reset(struct scsi_cmnd *cmd) (fib_callback ) aac_tmf_callback, (void *) info); +if (status != -EINPROGRESS ) { + info->reset_state =0 ; +aac_fib_complete (fib); +aac_fib_free (fib); +return ret; + } +/* Wait up to 15 seconds for completion */ for (count =0 ; count <15 ; ++count) {if (info->reset_state <=0 ) {
@@ -1033,7 +1049,7 @@ static int aac_eh_bus_reset(struct scsi_cmnd* cmd) } } -pr_err ("%s: Host adapter reset request. SCSI hang ?\n" ,AAC_DRIVERNAME ); +pr_err ("%s: Host bus reset request. SCSI hang ?\n" ,AAC_DRIVERNAME );/* * Check the health of the controller
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 157/388 s390/irq: replace setup_irq() by request_irq()
In reply to Greg Kroah-HartmanFrom: afzal mohammed <[email protected]>
[ Upstream commit 8719b6d29d2851fa84c4074bb2e5adc022911ab8 ]
request_irq() is preferred over setup_irq(). Invocations of setup_irq() occur after memory allocators are ready.
Per tglx[1], setup_irq() existed in olden days when allocators were not ready by the time early interrupts were initialized.
Hence replace setup_irq() by request_irq().
[1] https://lkml.kernel.org/r/alpine.DEB.2.20.1710191609480.1971@nanos
Message-Id: <[email protected]>
--- arch/s390/kernel/irq.c | 8 ++------ drivers/s390/cio/airq.c | 8 ++------ drivers/s390/cio/cio.c | 8 ++------ 3 files changed, 6 insertions(+), 18 deletions(-)
arch/s390/kernel/irq.c +2 -6
@@ -294,11 +294,6 @@ static irqreturn_t do_ext_interrupt(int irq, void *dummy)return IRQ_HANDLED ; } -static struct irqaction external_interrupt = { - .name ="EXT" , - .handler = do_ext_interrupt, -}; -void __init init_ext_interrupts (void ) {int idx;
@@ -308,7 +303,8 @@ void __init init_ext_interrupts(void)irq_set_chip_and_handler (EXT_INTERRUPT , &dummy_irq_chip, handle_percpu_irq); -setup_irq (EXT_INTERRUPT , &external_interrupt); +if (request_irq (EXT_INTERRUPT , do_ext_interrupt,0 ,"EXT" ,NULL )) +panic ("Failed to register EXT interrupt\n" ); }static DEFINE_SPINLOCK (irq_subclass_lock);
drivers/s390/cio/airq.c +2 -6
@@ -105,16 +105,12 @@ static irqreturn_t do_airq_interrupt(int irq, void *dummy)return IRQ_HANDLED ; } -static struct irqaction airq_interrupt = { - .name ="AIO" , - .handler = do_airq_interrupt, -}; -void __init init_airq_interrupts (void ) {irq_set_chip_and_handler (THIN_INTERRUPT , &dummy_irq_chip, handle_percpu_irq); -setup_irq (THIN_INTERRUPT , &airq_interrupt); +if (request_irq (THIN_INTERRUPT , do_airq_interrupt,0 ,"AIO" ,NULL )) +panic ("Failed to register AIO interrupt\n" ); }static inline unsigned long iv_size (unsigned long bits)
drivers/s390/cio/cio.c +2 -6
@@ -563,16 +563,12 @@ static irqreturn_t do_cio_interrupt(int irq, void *dummy)return IRQ_HANDLED ; } -static struct irqaction io_interrupt = { - .name ="I/O" , - .handler = do_cio_interrupt, -}; -void __init init_cio_interrupts (void ) {irq_set_chip_and_handler (IO_INTERRUPT , &dummy_irq_chip, handle_percpu_irq); -setup_irq (IO_INTERRUPT , &io_interrupt); +if (request_irq (IO_INTERRUPT , do_cio_interrupt,0 ,"I/O" ,NULL )) +panic ("Failed to register I/O interrupt\n" ); }#ifdef CONFIG_CCW_CONSOLE
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 197/388 proc: io_accounting: Use new infrastructure to fix deadlocks in execve
In reply to Greg Kroah-HartmanFrom: Bernd Edlinger <[email protected]>
[ Upstream commit 76518d3798855242817e8a8ed76b2d72f4415624 ]
This changes do_io_accounting to use the new exec_update_mutex instead of cred_guard_mutex.
This fixes possible deadlocks when the trace is accessing /proc/$pid/io for instance.
This should be safe, as the credentials are only used for reading.
--- fs/proc/base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/proc/base.c +2 -2
@@ -2770,7 +2770,7 @@ static int do_io_accounting(struct task_struct *task, struct seq_file *m, int whunsigned long flags;int result; - result =mutex_lock_killable (&task->signal->cred_guard_mutex); + result =mutex_lock_killable (&task->signal->exec_update_mutex);if (result)return result;
@@ -2806,7 +2806,7 @@ static int do_io_accounting(struct task_struct *task, struct seq_file *m, int wh result =0 ; out_unlock: -mutex_unlock (&task->signal->cred_guard_mutex); +mutex_unlock (&task->signal->exec_update_mutex);return result; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 194/388 selftests/ptrace: add test cases for dead-locks
In reply to Greg Kroah-HartmanFrom: Bernd Edlinger <[email protected]>
[ Upstream commit 2de4e82318c7f9d34f4b08599a612cd4cd10bf0b ]
This adds test cases for ptrace deadlocks.
Additionally fixes a compile problem in get_syscall_info.c, observed with gcc-4.8.4:
get_syscall_info.c: In function 'get_syscall_info':
get_syscall_info.c:93:3: error: 'for' loop initial declarations are only
allowed in C99 mode
for (unsigned int i = 0; i < ARRAY_SIZE(args); ++i) {
^
get_syscall_info.c:93:3: note: use option -std=c99 or -std=gnu99 to compile
your code
--- tools/testing/selftests/ptrace/Makefile | 4 +- tools/testing/selftests/ptrace/vmaccess.c | 86 +++++++++++++++++++++++ 2 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/ptrace/vmaccess.c
tools/testing/selftests/ptrace/Makefile +2 -2
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only -CFLAGS += -iquote../../../../include/uapi -Wall +CFLAGS += -std=c99 -pthread -iquote../../../../include/uapi -Wall -TEST_GEN_PROGS := get_syscall_info peeksiginfo +TEST_GEN_PROGS := get_syscall_info peeksiginfo vmaccess include ../lib.mk
tools/testing/selftests/ptrace/vmaccess.c new file +86 -0
86 lines not on this page · raw message
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 185/388 serial: 8250_omap: Fix sleeping function called from invalid context during probe
In reply to Greg Kroah-HartmanFrom: Peter Ujfalusi <[email protected]>
[ Upstream commit 4ce35a3617c0ac758c61122b2218b6c8c9ac9398 ]
When booting j721e the following bug is printed:
[ 1.154821] BUG: sleeping function called from invalid context at kernel/sched/completion.c:99
[ 1.154827] in_atomic(): 0, irqs_disabled(): 128, non_block: 0, pid: 12, name: kworker/0:1
[ 1.154832] 3 locks held by kworker/0:1/12:
[ 1.154836] #0: ffff000840030728 ((wq_completion)events){+.+.}, at: process_one_work+0x1d4/0x6e8
[ 1.154852] #1: ffff80001214fdd8 (deferred_probe_work){+.+.}, at: process_one_work+0x1d4/0x6e8
[ 1.154860] #2: ffff00084060b170 (&dev->mutex){....}, at: __device_attach+0x38/0x138
[ 1.154872] irq event stamp: 63096
[ 1.154881] hardirqs last enabled at (63095): [<ffff800010b74318>] _raw_spin_unlock_irqrestore+0x70/0x78
[ 1.154887] hardirqs last disabled at (63096): [<ffff800010b740d8>] _raw_spin_lock_irqsave+0x28/0x80
[ 1.154893] softirqs last enabled at (62254): [<ffff800010080c88>] _stext+0x488/0x564
[ 1.154899] softirqs last disabled at (62247): [<ffff8000100fdb3c>] irq_exit+0x114/0x140
[ 1.154906] CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.6.0-rc6-next-20200318-00094-g45e4089b0bd3 #221
[ 1.154911] Hardware name: Texas Instruments K3 J721E SoC (DT)
[ 1.154917] Workqueue: events deferred_probe_work_func
[ 1.154923] Call trace:
[ 1.154928] dump_backtrace+0x0/0x190
[ 1.154933] show_stack+0x14/0x20
[ 1.154940] dump_stack+0xe0/0x148
[ 1.154946] ___might_sleep+0x150/0x1f0
[ 1.154952] __might_sleep+0x4c/0x80
[ 1.154957] wait_for_completion_timeout+0x40/0x140
[ 1.154964] ti_sci_set_device_state+0xa0/0x158
[ 1.154969] ti_sci_cmd_get_device_exclusive+0x14/0x20
[ 1.154977] ti_sci_dev_start+0x34/0x50
[ 1.154984] genpd_runtime_resume+0x78/0x1f8
[ 1.154991] __rpm_callback+0x3c/0x140
[ 1.154996] rpm_callback+0x20/0x80
[ 1.155001] rpm_resume+0x568/0x758
[ 1.155007] __pm_runtime_resume+0x44/0xb0
[ 1.155013] omap8250_probe+0x2b4/0x508
[ 1.155019] platform_drv_probe+0x50/0xa0
[ 1.155023] really_probe+0xd4/0x318
[ 1.155028] driver_probe_device+0x54/0xe8
[ 1.155033] __device_attach_driver+0x80/0xb8
[ 1.155039] bus_for_each_drv+0x74/0xc0
[ 1.155044] __device_attach+0xdc/0x138
[ 1.155049] device_initial_probe+0x10/0x18
[ 1.155053] bus_probe_device+0x98/0xa0
[ 1.155058] deferred_probe_work_func+0x74/0xb0
[ 1.155063] process_one_work+0x280/0x6e8
[ 1.155068] worker_thread+0x48/0x430
[ 1.155073] kthread+0x108/0x138
[ 1.155079] ret_from_fork+0x10/0x18To fix the bug we need to first call pm_runtime_enable() prior to any pm_runtime calls.
--- drivers/tty/serial/8250/8250_omap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/8250/8250_omap.c +1 -1
@@ -1234,6 +1234,7 @@ static int omap8250_probe(struct platform_device *pdev)spin_lock_init (&priv->rx_dma_lock);device_init_wakeup (&pdev->dev, true); +pm_runtime_enable (&pdev->dev);pm_runtime_use_autosuspend (&pdev->dev);/*
@@ -1247,7 +1248,6 @@ static int omap8250_probe(struct platform_device *pdev)pm_runtime_set_autosuspend_delay (&pdev->dev,-1 );pm_runtime_irq_safe (&pdev->dev); -pm_runtime_enable (&pdev->dev);pm_runtime_get_sync (&pdev->dev);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 156/388 cpu-topology: Fix the potential data corruption
In reply to Greg Kroah-HartmanFrom: Zeng Tao <[email protected]>
[ Upstream commit 4a33691c4cea9eb0a7c66e87248be4637e14b180 ]
Currently there are only 10 bytes to store the cpu-topology 'name' information. Only 10 bytes copied into cluster/thread/core names.
If the cluster ID exceeds 2-digit number, it will result in the data corruption, and ending up in a dead loop in the parsing routines. The same applies to the thread names with more that 3-digit number.
This issue was found using the boundary tests under virtualised environment like QEMU.
Let us increase the buffer to fix such potential issues.
--- drivers/base/arch_topology.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/base/arch_topology.c +2 -2
@@ -270,7 +270,7 @@ static int __init get_cpu_for_node(struct device_node *node)static int __init parse_core (struct device_node *core,int package_id,int core_id) { -char name[10 ]; +char name[20 ];bool leaf = true;int i =0 ;int cpu;
@@ -317,7 +317,7 @@ static int __init parse_core(struct device_node *core, int package_id,static int __init parse_cluster (struct device_node *cluster,int depth) { -char name[10 ]; +char name[20 ];bool leaf = true;bool has_cores = false;struct device_node *c;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 183/388 r8169: improve RTL8168b FIFO overflow workaround
In reply to Greg Kroah-HartmanFrom: Heiner Kallweit <[email protected]>
[ Upstream commit 6b02e407cbf8d421477ebb7792cd6380affcd313 ]
So far only the reset bit it set, but the handler executing the reset is not scheduled. Therefore nothing will happen until some other action schedules the handler. Improve this by ensuring that the handler is scheduled.
--- drivers/net/ethernet/realtek/r8169_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +1 -2
@@ -6256,8 +6256,7 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance)if (unlikely (status & RxFIFOOver && tp->mac_version ==RTL_GIGA_MAC_VER_11 )) {netif_stop_queue (tp->dev); -/* XXX - Hack alert. See rtl_task(). */ -set_bit (RTL_FLAG_TASK_RESET_PENDING , tp->wk.flags); +rtl_schedule_task (tp,RTL_FLAG_TASK_RESET_PENDING ); }rtl_irq_disable (tp);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 155/388 clk: imx: Fix division by zero warning on pfdv2
In reply to Greg Kroah-HartmanFrom: Anson Huang <[email protected]>
[ Upstream commit 28b2f82e0383e27476be8a5e13d2aea07ebeb275 ]
Fix below division by zero warning:
[ 3.176443] Division by zero in kernel. [ 3.181809] CPU: 0 PID: 88 Comm: kworker/0:2 Not tainted 5.3.0-rc2-next-20190730-63758-ge08da51-dirty #124 [ 3.191817] Hardware name: Freescale i.MX7ULP (Device Tree) [ 3.197821] Workqueue: events dbs_work_handler [ 3.202849] [<c01127d8>] (unwind_backtrace) from [<c010cd80>] (show_stack+0x10/0x14) [ 3.211058] [<c010cd80>] (show_stack) from [<c0c77e68>] (dump_stack+0xd8/0x110) [ 3.218820] [<c0c77e68>] (dump_stack) from [<c0c753c0>] (Ldiv0_64+0x8/0x18) [ 3.226263] [<c0c753c0>] (Ldiv0_64) from [<c05984b4>] (clk_pfdv2_set_rate+0x54/0xac) [ 3.234487] [<c05984b4>] (clk_pfdv2_set_rate) from [<c059192c>] (clk_change_rate+0x1a4/0x698) [ 3.243468] [<c059192c>] (clk_change_rate) from [<c0591a08>] (clk_change_rate+0x280/0x698) [ 3.252180] [<c0591a08>] (clk_change_rate) from [<c0591fc0>] (clk_core_set_rate_nolock+0x1a0/0x278) [ 3.261679] [<c0591fc0>] (clk_core_set_rate_nolock) from [<c05920c8>] (clk_set_rate+0x30/0x64) [ 3.270743] [<c05920c8>] (clk_set_rate) from [<c089cb88>] (imx7ulp_set_target+0x184/0x2a4) [ 3.279501] [<c089cb88>] (imx7ulp_set_target) from [<c0896358>] (__cpufreq_driver_target+0x188/0x514) [ 3.289196] [<c0896358>] (__cpufreq_driver_target) from [<c0899b0c>] (od_dbs_update+0x130/0x15c) [ 3.298438] [<c0899b0c>] (od_dbs_update) from [<c089a5d0>] (dbs_work_handler+0x2c/0x5c) [ 3.306914] [<c089a5d0>] (dbs_work_handler) from [<c0156858>] (process_one_work+0x2ac/0x704) [ 3.315826] [<c0156858>] (process_one_work) from [<c0156cdc>] (worker_thread+0x2c/0x574) [ 3.324404] [<c0156cdc>] (worker_thread) from [<c015cfe8>] (kthread+0x134/0x148) [ 3.332278] [<c015cfe8>] (kthread) from [<c01010b4>] (ret_from_fork+0x14/0x20) [ 3.339858] Exception stack(0xe82d5fb0 to 0xe82d5ff8) [ 3.345314] 5fa0: 00000000 00000000 00000000 00000000 [ 3.353926] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 3.362519] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000
--- drivers/clk/imx/clk-pfdv2.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/clk/imx/clk-pfdv2.c +6 -0
@@ -139,6 +139,12 @@ static int clk_pfdv2_set_rate(struct clk_hw *hw, unsigned long rate,u32 val;u8 frac; +if (!rate) +return -EINVAL ; + +/* PFD can NOT change rate without gating */ +WARN_ON (clk_pfdv2_is_enabled (hw)); + tmp = tmp *18 + rate /2 ;do_div (tmp, rate); frac = tmp;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 180/388 perf parse-events: Fix 3 use after frees found with clang ASAN
In reply to Greg Kroah-HartmanFrom: Ian Rogers <[email protected]>
[ Upstream commit d4953f7ef1a2e87ef732823af35361404d13fea8 ]
Reproducible with a clang asan build and then running perf test in particular 'Parse event definition strings'.
--- tools/perf/util/evsel.c | 1 + tools/perf/util/parse-events.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-)
tools/perf/util/evsel.c +1 -0
@@ -1254,6 +1254,7 @@ void perf_evsel__exit(struct evsel *evsel)perf_thread_map__put (evsel->core.threads);zfree (&evsel->group_name);zfree (&evsel->name); +zfree (&evsel->pmu_name); perf_evsel__object.fini (evsel); }
tools/perf/util/parse-events.c +2 -2
@@ -1344,7 +1344,7 @@ int parse_events_add_pmu(struct parse_events_state *parse_state, evsel =__add_event (list, &parse_state->idx, &attr,NULL , pmu,NULL , auto_merge_stats,NULL );if (evsel) { - evsel->pmu_name = name; + evsel->pmu_name = name ?strdup (name) :NULL ; evsel->use_uncore_alias = use_uncore_alias;return 0 ; }else {
@@ -1385,7 +1385,7 @@ int parse_events_add_pmu(struct parse_events_state *parse_state, evsel->snapshot = info.snapshot; evsel->metric_expr = info.metric_expr; evsel->metric_name = info.metric_name; - evsel->pmu_name = name; + evsel->pmu_name = name ?strdup (name) :NULL ; evsel->use_uncore_alias = use_uncore_alias; evsel->percore =config_term_percore (&evsel->config_terms); }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 181/388 btrfs: do not init a reloc root if we arent relocating
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
[ Upstream commit 2abc726ab4b83db774e315c660ab8da21477092f ]
We previously were checking if the root had a dead root before accessing root->reloc_root in order to avoid a use-after-free type bug. However this scenario happens after we've unset the reloc control, so we would have been saved if we'd simply checked for fs_info->reloc_control. At this point during relocation we no longer need to be creating new reloc roots, so simply move this check above the reloc_root checks to avoid any future races and confusion.
--- fs/btrfs/relocation.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
fs/btrfs/relocation.c +16 -4
@@ -1468,6 +1468,10 @@ int btrfs_init_reloc_root(struct btrfs_trans_handle *trans,int clear_rsv =0 ;int ret; +if (!rc || !rc->create_reloc_tree || + root->root_key.objectid ==BTRFS_TREE_RELOC_OBJECTID ) +return 0 ; +/* * The subvolume has reloc tree but the swap is finished, no need to * create/update the dead reloc tree
@@ -1481,10 +1485,6 @@ int btrfs_init_reloc_root(struct btrfs_trans_handle *trans,return 0 ; } -if (!rc || !rc->create_reloc_tree || - root->root_key.objectid ==BTRFS_TREE_RELOC_OBJECTID ) -return 0 ; -if (!trans->reloc_reserved) { rsv = trans->block_rsv; trans->block_rsv = rc->block_rsv;
@@ -2336,6 +2336,18 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc, trans =NULL ; goto out; } + +/* +* At this point we no longer have a reloc_control, so we can't +* depend on btrfs_init_reloc_root to update our last_trans. +* +* But that's ok, we started the trans handle on our +* corresponding fs_root, which means it's been added to the +* dirty list. At commit time we'll still call +* btrfs_update_reloc_root() and update our root item +* appropriately. +*/ + reloc_root->last_trans = trans->transid; trans->block_rsv = rc->block_rsv; replaced =0 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 178/388 thermal: rcar_thermal: Handle probe error gracefully
In reply to Greg Kroah-HartmanFrom: Niklas Söderlund <[email protected]>
[ Upstream commit 39056e8a989ef52486e063e34b4822b341e47b0e ]
If the common register memory resource is not available the driver needs to fail gracefully to disable PM. Instead of returning the error directly store it in ret and use the already existing error path.
--- drivers/thermal/rcar_thermal.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/thermal/rcar_thermal.c +4 -2
@@ -526,8 +526,10 @@ static int rcar_thermal_probe(struct platform_device *pdev) res =platform_get_resource (pdev,IORESOURCE_MEM , mres++); common->base =devm_ioremap_resource (dev, res); -if (IS_ERR (common->base)) -return PTR_ERR (common->base); +if (IS_ERR (common->base)) { + ret =PTR_ERR (common->base); + goto error_unregister; + } idle =0 ;/* polling delay is not needed */ }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 179/388 KVM: LAPIC: Mark hrtimer for period or oneshot mode to expire in hard interrupt context
In reply to Greg Kroah-HartmanFrom: He Zhe <[email protected]>
[ Upstream commit edec6e015a02003c2af0ce82c54ea016b5a9e3f0 ]
apic->lapic_timer.timer was initialized with HRTIMER_MODE_ABS_HARD but started later with HRTIMER_MODE_ABS, which may cause the following warning in PREEMPT_RT kernel.
WARNING: CPU: 1 PID: 2957 at kernel/time/hrtimer.c:1129 hrtimer_start_range_ns+0x348/0x3f0
CPU: 1 PID: 2957 Comm: qemu-system-x86 Not tainted 5.4.23-rt11 #1
Hardware name: Supermicro SYS-E300-9A-8C/A2SDi-8C-HLN4F, BIOS 1.1a 09/18/2018
RIP: 0010:hrtimer_start_range_ns+0x348/0x3f0
Code: 4d b8 0f 94 c1 0f b6 c9 e8 35 f1 ff ff 4c 8b 45
b0 e9 3b fd ff ff e8 d7 3f fa ff 48 98 4c 03 34
c5 a0 26 bf 93 e9 a1 fd ff ff <0f> 0b e9 fd fc ff
ff 65 8b 05 fa b7 90 6d 89 c0 48 0f a3 05 60 91
RSP: 0018:ffffbc60026ffaf8 EFLAGS: 00010202
RAX: 0000000000000001 RBX: ffff9d81657d4110 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000006cc7987bcf RDI: ffff9d81657d4110
RBP: ffffbc60026ffb58 R08: 0000000000000001 R09: 0000000000000010
R10: 0000000000000000 R11: 0000000000000000 R12: 0000006cc7987bcf
R13: 0000000000000000 R14: 0000006cc7987bcf R15: ffffbc60026d6a00
FS: 00007f401daed700(0000) GS:ffff9d81ffa40000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00000000ffffffff CR3: 0000000fa7574000 CR4: 00000000003426e0
Call Trace:
? kvm_release_pfn_clean+0x22/0x60 [kvm]
start_sw_timer+0x85/0x230 [kvm]
? vmx_vmexit+0x1b/0x30 [kvm_intel]
kvm_lapic_switch_to_sw_timer+0x72/0x80 [kvm]
vmx_pre_block+0x1cb/0x260 [kvm_intel]
? vmx_vmexit+0xf/0x30 [kvm_intel]
? vmx_vmexit+0x1b/0x30 [kvm_intel]
? vmx_vmexit+0xf/0x30 [kvm_intel]
? vmx_vmexit+0x1b/0x30 [kvm_intel]
? vmx_vmexit+0xf/0x30 [kvm_intel]
? vmx_vmexit+0x1b/0x30 [kvm_intel]
? vmx_vmexit+0xf/0x30 [kvm_intel]
? vmx_vmexit+0xf/0x30 [kvm_intel]
? vmx_vmexit+0x1b/0x30 [kvm_intel]
? vmx_vmexit+0xf/0x30 [kvm_intel]
? vmx_vmexit+0x1b/0x30 [kvm_intel]
? vmx_vmexit+0xf/0x30 [kvm_intel]
? vmx_vmexit+0x1b/0x30 [kvm_intel]
? vmx_vmexit+0xf/0x30 [kvm_intel]
? vmx_vmexit+0x1b/0x30 [kvm_intel]
? vmx_vmexit+0xf/0x30 [kvm_intel]
? vmx_sync_pir_to_irr+0x9e/0x100 [kvm_intel]
? kvm_apic_has_interrupt+0x46/0x80 [kvm]
kvm_arch_vcpu_ioctl_run+0x85b/0x1fa0 [kvm]
? _raw_spin_unlock_irqrestore+0x18/0x50
? _copy_to_user+0x2c/0x30
kvm_vcpu_ioctl+0x235/0x660 [kvm]
? rt_spin_unlock+0x2c/0x50
do_vfs_ioctl+0x3e4/0x650
? __fget+0x7a/0xa0
ksys_ioctl+0x67/0x90
__x64_sys_ioctl+0x1a/0x20
do_syscall_64+0x4d/0x120
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7f4027cc54a7
Code: 00 00 90 48 8b 05 e9 59 0c 00 64 c7 00 26 00 00
00 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00
00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff
73 01 c3 48 8b 0d b9 59 0c 00 f7 d8 64 89 01 48
RSP: 002b:00007f401dae9858 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00005558bd029690 RCX: 00007f4027cc54a7
RDX: 0000000000000000 RSI: 000000000000ae80 RDI: 000000000000000d
RBP: 00007f4028b72000 R08: 00005558bc829ad0 R09: 00000000ffffffff
R10: 00005558bcf90ca0 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 00005558bce1c840--[ end trace 0000000000000002 ]--
Message-Id: <[email protected]>
--- arch/x86/kvm/lapic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/lapic.c +1 -1
@@ -1684,7 +1684,7 @@ static void start_sw_period(struct kvm_lapic *apic)hrtimer_start (&apic->lapic_timer.timer, apic->lapic_timer.target_expiration, -HRTIMER_MODE_ABS ); +HRTIMER_MODE_ABS_HARD ); }bool kvm_lapic_hv_timer_in_use (struct kvm_vcpu *vcpu)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 177/388 tracing: Use address-of operator on section symbols
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit bf2cbe044da275021b2de5917240411a19e5c50d ]
Clang warns:
../kernel/trace/trace.c:9335:33: warning: array comparison always evaluates to true [-Wtautological-compare]
if (__stop___trace_bprintk_fmt != __start___trace_bprintk_fmt)
^1 warning generated.
These are not true arrays, they are linker defined symbols, which are just addresses. Using the address of operator silences the warning and does not change the runtime result of the check (tested with some print statements compiled in with clang + ld.lld and gcc + ld.bfd in QEMU).
--- kernel/trace/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace.c +1 -1
@@ -9146,7 +9146,7 @@ __init static int tracer_alloc_buffers(void) goto out_free_buffer_mask;/* Only allocate trace_printk buffers if a trace_printk exists */ -if (__stop___trace_bprintk_fmt != __start___trace_bprintk_fmt) +if (&__stop___trace_bprintk_fmt != &__start___trace_bprintk_fmt)/* Must be called before global_trace.buffer is allocated */ trace_printk_init_buffers ();
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 175/388 drm/msm: fix leaks if initialization fails
In reply to Greg Kroah-HartmanFrom: Pavel Machek <[email protected]>
[ Upstream commit 66be340f827554cb1c8a1ed7dea97920b4085af2 ]
We should free resources in unlikely case of allocation failure.
--- drivers/gpu/drm/msm/msm_drv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/msm_drv.c +4 -2
@@ -444,8 +444,10 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv)if (!dev->dma_parms) { dev->dma_parms =devm_kzalloc (dev,sizeof (*dev->dma_parms),GFP_KERNEL ); -if (!dev->dma_parms) -return -ENOMEM ; +if (!dev->dma_parms) { + ret = -ENOMEM ; + goto err_msm_uninit; + } }dma_set_max_seg_size (dev,DMA_BIT_MASK (32 ));
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 174/388 KVM: PPC: Book3S HV: Treat TM-related invalid form instructions on P9 like the valid ones
In reply to Greg Kroah-HartmanFrom: Gustavo Romero <[email protected]>
[ Upstream commit 1dff3064c764b5a51c367b949b341d2e38972bec ]
On P9 DD2.2 due to a CPU defect some TM instructions need to be emulated by KVM. This is handled at first by the hardware raising a softpatch interrupt when certain TM instructions that need KVM assistance are executed in the guest. Althought some TM instructions per Power ISA are invalid forms they can raise a softpatch interrupt too. For instance, 'tresume.' instruction as defined in the ISA must have bit 31 set (1), but an instruction that matches 'tresume.' PO and XO opcode fields but has bit 31 not set (0), like 0x7cfe9ddc, also raises a softpatch interrupt. Similarly for 'treclaim.' and 'trechkpt.' instructions with bit 31 = 0, i.e. 0x7c00075c and 0x7c0007dc, respectively. Hence, if a code like the following is executed in the guest it will raise a softpatch interrupt just like a 'tresume.' when the TM facility is enabled ('tabort. 0' in the example is used only to enable the TM facility):
int main() { asm("tabort. 0; .long 0x7cfe9ddc;"); }
Currently in such a case KVM throws a complete trace like:
[345523.705984] WARNING: CPU: 24 PID: 64413 at arch/powerpc/kvm/book3s_hv_tm.c:211 kvmhv_p9_tm_emulation+0x68/0x620 [kvm_hv] [345523.705985] Modules linked in: kvm_hv(E) xt_conntrack ipt_REJECT nf_reject_ipv4 xt_tcpudp ip6table_mangle ip6table_nat
iptable_mangle iptable_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 ebtable_filter ebtables ip6table_filter ip6_tables iptable_filter bridge stp llc sch_fq_codel ipmi_powernv at24 vmx_crypto ipmi_devintf ipmi_msghandler ibmpowernv uio_pdrv_genirq kvm opal_prd uio leds_powernv ib_iser rdma_cm iw_cm ib_cm ib_core iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi ip_tables x_tables autofs4 btrfs blake2b_generic zstd_compress raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx libcrc32c xor raid6_pq raid1 raid0 multipath linear tg3 crct10dif_vpmsum crc32c_vpmsum ipr [last unloaded: kvm_hv]
[345523.706030] CPU: 24 PID: 64413 Comm: CPU 0/KVM Tainted: G W E 5.5.0+ #1
[345523.706031] NIP: c0080000072cb9c0 LR: c0080000072b5e80 CTR: c0080000085c7850
[345523.706034] REGS: c000000399467680 TRAP: 0700 Tainted: G W E (5.5.0+)
[345523.706034] MSR: 900000010282b033 <SF,HV,VEC,VSX,EE,FP,ME,IR,DR,RI,LE,TM[E]> CR: 24022428 XER: 00000000
[345523.706042] CFAR: c0080000072b5e7c IRQMASK: 0
GPR00: c0080000072b5e80 c000000399467910 c0080000072db500 c000000375ccc720
GPR04: c000000375ccc720 00000003fbec0000 0000a10395dda5a6 0000000000000000
GPR08: 000000007cfe9ddc 7cfe9ddc000005dc 7cfe9ddc7c0005dc c0080000072cd530
GPR12: c0080000085c7850 c0000003fffeb800 0000000000000001 00007dfb737f0000
GPR16: c0002001edcca558 0000000000000000 0000000000000000 0000000000000001
GPR20: c000000001b21258 c0002001edcca558 0000000000000018 0000000000000000
GPR24: 0000000001000000 ffffffffffffffff 0000000000000001 0000000000001500
GPR28: c0002001edcc4278 c00000037dd80000 800000050280f033 c000000375ccc720
[345523.706062] NIP [c0080000072cb9c0] kvmhv_p9_tm_emulation+0x68/0x620 [kvm_hv]
[345523.706065] LR [c0080000072b5e80] kvmppc_handle_exit_hv.isra.53+0x3e8/0x798 [kvm_hv]
[345523.706066] Call Trace:
[345523.706069] [c000000399467910] [c000000399467940] 0xc000000399467940 (unreliable)
[345523.706071] [c000000399467950] [c000000399467980] 0xc000000399467980
[345523.706075] [c0000003994679f0] [c0080000072bd1c4] kvmhv_run_single_vcpu+0xa1c/0xb80 [kvm_hv]
[345523.706079] [c000000399467ac0] [c0080000072bd8e0] kvmppc_vcpu_run_hv+0x5b8/0xb00 [kvm_hv]
[345523.706087] [c000000399467b90] [c0080000085c93cc] kvmppc_vcpu_run+0x34/0x48 [kvm]
[345523.706095] [c000000399467bb0] [c0080000085c582c] kvm_arch_vcpu_ioctl_run+0x244/0x420 [kvm]
[345523.706101] [c000000399467c40] [c0080000085b7498] kvm_vcpu_ioctl+0x3d0/0x7b0 [kvm]
[345523.706105] [c000000399467db0] [c0000000004adf9c] ksys_ioctl+0x13c/0x170
[345523.706107] [c000000399467e00] [c0000000004adff8] sys_ioctl+0x28/0x80
[345523.706111] [c000000399467e20] [c00000000000b278] system_call+0x5c/0x68
[345523.706112] Instruction dump:
[345523.706114] 419e0390 7f8a4840 409d0048 6d497c00 2f89075d 419e021c 6d497c00 2f8907dd
[345523.706119] 419e01c0 6d497c00 2f8905dd 419e00a4 <0fe00000> 38210040 38600000 ebc1fff0and then treats the executed instruction as a 'nop'.
However the POWER9 User's Manual, in section "4.6.10 Book II Invalid Forms", informs that for TM instructions bit 31 is in fact ignored, thus for the TM-related invalid forms ignoring bit 31 and handling them like the valid forms is an acceptable way to handle them. POWER8 behaves the same way too.
This commit changes the handling of the cases here described by treating the TM-related invalid forms that can generate a softpatch interrupt just like their valid forms (w/ bit 31 = 1) instead of as a 'nop' and by gently reporting any other unrecognized case to the host and treating it as illegal instruction instead of throwing a trace and treating it as a 'nop'.
--- arch/powerpc/include/asm/kvm_asm.h | 3 +++ arch/powerpc/kvm/book3s_hv_tm.c | 28 ++++++++++++++++++++----- arch/powerpc/kvm/book3s_hv_tm_builtin.c | 16 ++++++++++++-- 3 files changed, 40 insertions(+), 7 deletions(-)
arch/powerpc/include/asm/kvm_asm.h +3 -0
@@ -150,4 +150,7 @@#define KVM_INST_FETCH_FAILED -1 +/* Extract PO and XOP opcode fields */ +#define PO_XOP_OPCODE_MASK 0xfc0007fe +#endif /* __POWERPC_KVM_ASM_H__ */
arch/powerpc/kvm/book3s_hv_tm.c +23 -5
@@ -3,6 +3,8 @@* Copyright 2017 Paul Mackerras, IBM Corp. <[email protected]> */ +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/kvm_host.h> #include <asm/kvm_ppc.h>
@@ -44,7 +46,18 @@ int kvmhv_p9_tm_emulation(struct kvm_vcpu *vcpu)u64 newmsr, bescr;int ra, rs; -switch (instr &0xfc0007ff ) { +/* +* rfid, rfebb, and mtmsrd encode bit 31 = 0 since it's a reserved bit +* in these instructions, so masking bit 31 out doesn't change these +* instructions. For treclaim., tsr., and trechkpt. instructions if bit +* 31 = 0 then they are per ISA invalid forms, however P9 UM, in section +* 4.6.10 Book II Invalid Forms, informs specifically that ignoring bit +* 31 is an acceptable way to handle these invalid forms that have +* bit 31 = 0. Moreover, for emulation purposes both forms (w/ and wo/ +* bit 31 set) can generate a softpatch interrupt. Hence both forms +* are handled below for these instructions so they behave the same way. +*/ +switch (instr &PO_XOP_OPCODE_MASK ) {case PPC_INST_RFID :/* XXX do we need to check for PR=0 here? */ newmsr = vcpu->arch.shregs.srr1;
@@ -105,7 +118,8 @@ int kvmhv_p9_tm_emulation(struct kvm_vcpu *vcpu) vcpu->arch.shregs.msr = newmsr;return RESUME_GUEST ; -case PPC_INST_TSR : +/* ignore bit 31, see comment above */ +case (PPC_INST_TSR &PO_XOP_OPCODE_MASK ):/* check for PR=1 and arch 2.06 bit set in PCR */ if ((msr &MSR_PR ) && (vcpu->arch.vcore->pcr &PCR_ARCH_206 )) {/* generate an illegal instruction interrupt */
@@ -140,7 +154,8 @@ int kvmhv_p9_tm_emulation(struct kvm_vcpu *vcpu) vcpu->arch.shregs.msr = msr;return RESUME_GUEST ; -case PPC_INST_TRECLAIM : +/* ignore bit 31, see comment above */ +case (PPC_INST_TRECLAIM &PO_XOP_OPCODE_MASK ):/* check for TM disabled in the HFSCR or MSR */ if (!(vcpu->arch.hfscr &HFSCR_TM )) {/* generate an illegal instruction interrupt */
@@ -176,7 +191,8 @@ int kvmhv_p9_tm_emulation(struct kvm_vcpu *vcpu) vcpu->arch.shregs.msr &= ~MSR_TS_MASK ;return RESUME_GUEST ; -case PPC_INST_TRECHKPT : +/* ignore bit 31, see comment above */ +case (PPC_INST_TRECHKPT &PO_XOP_OPCODE_MASK ):/* XXX do we need to check for PR=0 here? */ /* check for TM disabled in the HFSCR or MSR */ if (!(vcpu->arch.hfscr &HFSCR_TM )) {
@@ -208,6 +224,8 @@ int kvmhv_p9_tm_emulation(struct kvm_vcpu *vcpu) }/* What should we do here? We didn't recognize the instruction */ -WARN_ON_ONCE (1 ); +kvmppc_core_queue_program (vcpu,SRR1_PROGILL ); +pr_warn_ratelimited ("Unrecognized TM-related instruction %#x for emulation" , instr); +return RESUME_GUEST ; }
arch/powerpc/kvm/book3s_hv_tm_builtin.c +14 -2
@@ -23,7 +23,18 @@ int kvmhv_p9_tm_emulation_early(struct kvm_vcpu *vcpu)u64 newmsr, msr, bescr;int rs; -switch (instr &0xfc0007ff ) { +/* +* rfid, rfebb, and mtmsrd encode bit 31 = 0 since it's a reserved bit +* in these instructions, so masking bit 31 out doesn't change these +* instructions. For the tsr. instruction if bit 31 = 0 then it is per +* ISA an invalid form, however P9 UM, in section 4.6.10 Book II Invalid +* Forms, informs specifically that ignoring bit 31 is an acceptable way +* to handle TM-related invalid forms that have bit 31 = 0. Moreover, +* for emulation purposes both forms (w/ and wo/ bit 31 set) can +* generate a softpatch interrupt. Hence both forms are handled below +* for tsr. to make them behave the same way. +*/ +switch (instr &PO_XOP_OPCODE_MASK ) {case PPC_INST_RFID :/* XXX do we need to check for PR=0 here? */ newmsr = vcpu->arch.shregs.srr1;
@@ -73,7 +84,8 @@ int kvmhv_p9_tm_emulation_early(struct kvm_vcpu *vcpu) vcpu->arch.shregs.msr = newmsr;return 1 ; -case PPC_INST_TSR : +/* ignore bit 31, see comment above */ +case (PPC_INST_TSR &PO_XOP_OPCODE_MASK ):/* we know the MSR has the TS field = S (0b01) here */ msr = vcpu->arch.shregs.msr;/* check for PR=1 and arch 2.06 bit set in PCR */
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 173/388 intel_th: Disallow multi mode on devices where its broken
In reply to Greg Kroah-HartmanFrom: Alexander Shishkin <[email protected]>
[ Upstream commit 397c7729665a3b07a7b4ce7215173df8e9112809 ]
Some versions of Intel TH have an issue that prevents the multi mode of MSU from working correctly, resulting in no trace data and potentially stuck MSU pipeline.
Disable multi mode on such devices.
--- drivers/hwtracing/intel_th/intel_th.h | 2 ++ drivers/hwtracing/intel_th/msu.c | 11 +++++++++-- drivers/hwtracing/intel_th/pci.c | 8 ++++++-- 3 files changed, 17 insertions(+), 4 deletions(-)
drivers/hwtracing/intel_th/intel_th.h +2 -0
@@ -47,11 +47,13 @@ struct intel_th_output {/** * struct intel_th_drvdata - describes hardware capabilities and quirks * @tscu_enable: device needs SW to enable time stamping unit +* @multi_is_broken: device has multiblock mode is broken * @has_mintctl: device has interrupt control (MINTCTL) register * @host_mode_only: device can only operate in 'host debugger' mode */ struct intel_th_drvdata {unsigned int tscu_enable :1 , + multi_is_broken :1 , has_mintctl :1 , host_mode_only :1 ; };
drivers/hwtracing/intel_th/msu.c +9 -2
@@ -157,7 +157,8 @@ struct msc {/* config */ unsigned int enabled : 1, wrap : 1, - do_irq : 1; + do_irq : 1, + multi_is_broken : 1;unsigned int mode;unsigned int burst_len;unsigned int index;
@@ -1665,7 +1666,7 @@ static int intel_th_msc_init(struct msc *msc) {atomic_set (&msc->user_count,-1 ); - msc->mode =MSC_MODE_MULTI ; + msc->mode = msc->multi_is_broken ?MSC_MODE_SINGLE :MSC_MODE_MULTI ;mutex_init (&msc->buf_mutex);INIT_LIST_HEAD (&msc->win_list);INIT_LIST_HEAD (&msc->iter_list);
@@ -1877,6 +1878,9 @@ mode_store(struct device *dev, struct device_attribute *attr, const char *buf,return -EINVAL ; found: +if (i ==MSC_MODE_MULTI && msc->multi_is_broken) +return -EOPNOTSUPP ; +mutex_lock (&msc->buf_mutex); ret =0 ;
@@ -2083,6 +2087,9 @@ static int intel_th_msc_probe(struct intel_th_device *thdev)if (!res) msc->do_irq =1 ; +if (INTEL_TH_CAP (to_intel_th (thdev), multi_is_broken)) + msc->multi_is_broken =1 ; + msc->index = thdev->id; msc->thdev = thdev;
drivers/hwtracing/intel_th/pci.c +6 -2
@@ -120,6 +120,10 @@ static void intel_th_pci_remove(struct pci_dev *pdev)pci_free_irq_vectors (pdev); } +static const struct intel_th_drvdata intel_th_1x_multi_is_broken = { + .multi_is_broken =1 , +}; +static const struct intel_th_drvdata intel_th_2x = { .tscu_enable =1 , .has_mintctl =1 ,
@@ -152,7 +156,7 @@ static const struct pci_device_id intel_th_pci_id_table[] = { {/* Kaby Lake PCH-H */ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa2a6), - .driver_data = (kernel_ulong_t)0, + .driver_data = (kernel_ulong_t)&intel_th_1x_multi_is_broken, }, {/* Denverton */
@@ -207,7 +211,7 @@ static const struct pci_device_id intel_th_pci_id_table[] = { {/* Comet Lake PCH-V */ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa3a6), - .driver_data = (kernel_ulong_t)&intel_th_2x, + .driver_data = (kernel_ulong_t)&intel_th_1x_multi_is_broken, }, {/* Ice Lake NNPI */
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 172/388 RDMA/cm: Remove a race freeing timewait_info
In reply to Greg Kroah-HartmanFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit bede86a39d9dc3387ac00dcb8e1ac221676b2f25 ]
When creating a cm_id during REQ the id immediately becomes visible to the other MAD handlers, and shortly after the state is moved to IB_CM_REQ_RCVD
This allows cm_rej_handler() to run concurrently and free the work:
CPU 0 CPU1
cm_req_handler()
ib_create_cm_id()
cm_match_req()
id_priv->state = IB_CM_REQ_RCVD
cm_rej_handler()
cm_acquire_id()
spin_lock(&id_priv->lock)
switch (id_priv->state)
case IB_CM_REQ_RCVD:
cm_reset_to_idle()
kfree(id_priv->timewait_info);
goto destroy
destroy:
kfree(id_priv->timewait_info);
id_priv->timewait_info = NULLCausing a double free or worse.
Do not free the timewait_info without also holding the id_priv->lock. Simplify this entire flow by making the free unconditional during cm_destroy_id() and removing the confusing special case error unwind during creation of the timewait_info.
This also fixes a leak of the timewait if cm_destroy_id() is called in IB_CM_ESTABLISHED with an XRC TGT QP. The state machine will be left in ESTABLISHED while it needed to transition through IB_CM_TIMEWAIT to release the timewait pointer.
Also fix a leak of the timewait_info if the caller mis-uses the API and does ib_send_cm_reqs().
--- drivers/infiniband/core/cm.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
drivers/infiniband/core/cm.c +15 -10
@@ -1092,14 +1092,22 @@ retest:break ; } -spin_lock_irq (&cm.lock); +spin_lock_irq (&cm_id_priv->lock); +spin_lock (&cm.lock); +/* Required for cleanup paths related cm_req_handler() */ +if (cm_id_priv->timewait_info) { +cm_cleanup_timewait (cm_id_priv->timewait_info); +kfree (cm_id_priv->timewait_info); + cm_id_priv->timewait_info =NULL ; + }if (!list_empty (&cm_id_priv->altr_list) && (!cm_id_priv->altr_send_port_not_ready))list_del (&cm_id_priv->altr_list);if (!list_empty (&cm_id_priv->prim_list) && (!cm_id_priv->prim_send_port_not_ready))list_del (&cm_id_priv->prim_list); -spin_unlock_irq (&cm.lock); +spin_unlock (&cm.lock); +spin_unlock_irq (&cm_id_priv->lock);cm_free_id (cm_id->local_id);cm_deref_id (cm_id_priv);
@@ -1416,7 +1424,7 @@ int ib_send_cm_req(struct ib_cm_id *cm_id,/* Verify that we're not in timewait. */ cm_id_priv = container_of(cm_id, struct cm_id_private, id);spin_lock_irqsave (&cm_id_priv->lock, flags); -if (cm_id->state !=IB_CM_IDLE ) { +if (cm_id->state !=IB_CM_IDLE ||WARN_ON (cm_id_priv->timewait_info)) {spin_unlock_irqrestore (&cm_id_priv->lock, flags); ret = -EINVAL ; goto out;
@@ -1434,12 +1442,12 @@ int ib_send_cm_req(struct ib_cm_id *cm_id, param->ppath_sgid_attr, &cm_id_priv->av, cm_id_priv);if (ret) - goto error1; + goto out;if (param->alternate_path) { ret =cm_init_av_by_path (param->alternate_path,NULL , &cm_id_priv->alt_av, cm_id_priv);if (ret) - goto error1; + goto out; } cm_id->service_id = param->service_id; cm_id->service_mask = ~cpu_to_be64 (0 );
@@ -1457,7 +1465,7 @@ int ib_send_cm_req(struct ib_cm_id *cm_id, ret =cm_alloc_msg (cm_id_priv, &cm_id_priv->msg);if (ret) - goto error1; + goto out; req_msg = (struct cm_req_msg *) cm_id_priv->msg->mad;cm_format_req (req_msg, cm_id_priv, param);
@@ -1480,7 +1488,6 @@ int ib_send_cm_req(struct ib_cm_id *cm_id,return 0 ; error2:cm_free_msg (cm_id_priv->msg); -error1:kfree (cm_id_priv->timewait_info); out:return ret; }EXPORT_SYMBOL (ib_send_cm_req);
@@ -1965,7 +1972,7 @@ static int cm_req_handler(struct cm_work *work)pr_debug ("%s: local_id %d, no listen_cm_id_priv\n" , __func__,be32_to_cpu (cm_id->local_id)); ret = -EINVAL ; - goto free_timeinfo; + goto destroy; } cm_id_priv->id.cm_handler = listen_cm_id_priv->id.cm_handler;
@@ -2050,8 +2057,6 @@ static int cm_req_handler(struct cm_work *work) rejected:atomic_dec (&cm_id_priv->refcount);cm_deref_id (listen_cm_id_priv); -free_timeinfo: -kfree (cm_id_priv->timewait_info); destroy:ib_destroy_cm_id (cm_id);return ret;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 154/388 drm/amd/display: Stop if retimer is not available
In reply to Greg Kroah-HartmanFrom: Rodrigo Siqueira <[email protected]>
[ Upstream commit a0e40018dcc3f59a10ca21d58f8ea8ceb1b035ac ]
Raven provides retimer feature support that requires i2c interaction in order to make it work well, all settings required for this configuration are loaded from the Atom bios which include the i2c address. If the retimer feature is not available, we should abort the attempt to set this feature, otherwise, it makes the following line return I2C_CHANNEL_OPERATION_NO_RESPONSE:
i2c_success = i2c_write(pipe_ctx, slave_address, buffer, sizeof(buffer));
...
if (!i2c_success)
ASSERT(i2c_success);
This ends up causing problems with hotplugging HDMI displays on Raven, and causes retimer settings to warn like so:
WARNING: CPU: 1 PID: 429 at
drivers/gpu/drm/amd/amdgpu/../dal/dc/core/dc_link.c:1998 write_i2c_retimer_setting+0xc2/0x3c0 [amdgpu] Modules linked in:edac_mce_amd ccp kvm irqbypass binfmt_misc crct10dif_pclmul crc32_pclmul ghash_clmulni_intel snd_hda_codec_realtek snd_hda_codec_generic ledtrig_audio snd_hda_codec_hdmi snd_hda_intel amdgpu(+) snd_hda_codec snd_hda_core snd_hwdep snd_pcm snd_seq_midi snd_seq_midi_event snd_rawmidi aesni_intel snd_seq amd_iommu_v2 gpu_sched aes_x86_64 crypto_simd cryptd glue_helper snd_seq_device ttm drm_kms_helper snd_timer eeepc_wmi wmi_bmof asus_wmi sparse_keymap drm mxm_wmi snd k10temp fb_sys_fops syscopyarea sysfillrect sysimgblt soundcore joydev input_leds mac_hid sch_fq_codel parport_pc ppdev lp parport ip_tables x_tables autofs4 igb i2c_algo_bit hid_generic usbhid i2c_piix4 dca ahci hid libahci video wmi gpio_amdpt gpio_generic CPU: 1 PID: 429 Comm:
systemd-udevd Tainted: G W 5.2.0-rc1sept162019+ #1
Hardware name: System manufacturer System Product Name/ROG STRIX B450-F GAMING, BIOS 2605 08/06/2019 RIP: 0010:write_i2c_retimer_setting+0xc2/0x3c0 [amdgpu] Code: ff 0f b6 4d ce 44 0f b6 45 cf 44 0f b6 c8 45 89 cf 44 89 e2 48 c7 c6 f0 34 bc c0 bf 04 00 00 00 e8 63 b0 90 ff 45 84 ff 75 02 <0f> 0b 42 0f b6 04 73 8d 50 f6 80 fa 02 77 8c 3c 0a 0f 85 c8 00 00 RSP: 0018:ffffa99d02726fd0 EFLAGS: 00010246 RAX: 0000000000000000 RBX: ffffa99d02727035 RCX: 0000000000000006 RDX: 0000000000000000 RSI: 0000000000000002 RDI: ffff976acc857440 RBP: ffffa99d02727018 R08: 0000000000000002 R09: 000000000002a600 R10: ffffe90610193680 R11: 00000000000005e3 R12: 000000000000005d R13: ffff976ac4b201b8 R14: 0000000000000001 R15: 0000000000000000 FS: 00007f14f99e1680(0000) GS:ffff976acc840000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fdf212843b8 CR3: 0000000408906000 CR4: 00000000003406e0 Call Trace: core_link_enable_stream+0x626/0x680 [amdgpu] dce110_apply_ctx_to_hw+0x414/0x4e0 [amdgpu] dc_commit_state+0x331/0x5e0 [amdgpu] ? drm_calc_timestamping_constants+0xf9/0x150 [drm] amdgpu_dm_atomic_commit_tail+0x395/0x1e00 [amdgpu] ? dm_plane_helper_prepare_fb+0x20c/0x280 [amdgpu] commit_tail+0x42/0x70 [drm_kms_helper] drm_atomic_helper_commit+0x10c/0x120 [drm_kms_helper] amdgpu_dm_atomic_commit+0x95/0xa0 [amdgpu] drm_atomic_commit+0x4a/0x50 [drm] restore_fbdev_mode_atomic+0x1c0/0x1e0 [drm_kms_helper] restore_fbdev_mode+0x4c/0x160 [drm_kms_helper] ? _cond_resched+0x19/0x40 drm_fb_helper_restore_fbdev_mode_unlocked+0x4e/0xa0 [drm_kms_helper] drm_fb_helper_set_par+0x2d/0x50 [drm_kms_helper] fbcon_init+0x471/0x630 visual_init+0xd5/0x130 do_bind_con_driver+0x20a/0x430 do_take_over_console+0x7d/0x1b0 do_fbcon_takeover+0x5c/0xb0 fbcon_event_notify+0x6cd/0x8a0 notifier_call_chain+0x4c/0x70 blocking_notifier_call_chain+0x43/0x60 fb_notifier_call_chain+0x1b/0x20 register_framebuffer+0x254/0x360 __drm_fb_helper_initial_config_and_unlock+0x2c5/0x510 [drm_kms_helper] drm_fb_helper_initial_config+0x35/0x40 [drm_kms_helper] amdgpu_fbdev_init+0xcd/0x100 [amdgpu] amdgpu_device_init+0x1156/0x1930 [amdgpu] amdgpu_driver_load_kms+0x8d/0x2e0 [amdgpu] drm_dev_register+0x12b/0x1c0 [drm] amdgpu_pci_probe+0xd3/0x160 [amdgpu] local_pci_probe+0x47/0xa0 pci_device_probe+0x142/0x1b0 really_probe+0xf5/0x3d0 driver_probe_device+0x11b/0x130 device_driver_attach+0x58/0x60 __driver_attach+0xa3/0x140 ? device_driver_attach+0x60/0x60 ? device_driver_attach+0x60/0x60 bus_for_each_dev+0x74/0xb0 ? kmem_cache_alloc_trace+0x1a3/0x1c0 driver_attach+0x1e/0x20 bus_add_driver+0x147/0x220 ? 0xffffffffc0cb9000 driver_register+0x60/0x100 ? 0xffffffffc0cb9000 __pci_register_driver+0x5a/0x60 amdgpu_init+0x74/0x83 [amdgpu] do_one_initcall+0x4a/0x1fa ? _cond_resched+0x19/0x40 ? kmem_cache_alloc_trace+0x3f/0x1c0 ? __vunmap+0x1cc/0x200 do_init_module+0x5f/0x227 load_module+0x2330/0x2b40 __do_sys_finit_module+0xfc/0x120 ? __do_sys_finit_module+0xfc/0x120 __x64_sys_finit_module+0x1a/0x20 do_syscall_64+0x5a/0x130 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7f14f9500839 Code: 00 f3 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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 8b 0d 1f f6 2c 00 f7 d8 64 89 01 48
RSP: 002b:00007fff9bc4f5a8 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
RAX: ffffffffffffffda RBX: 000055afb5abce30 RCX: 00007f14f9500839
RDX: 0000000000000000 RSI: 000055afb5ace0f0 RDI: 0000000000000017
RBP: 000055afb5ace0f0 R08: 0000000000000000 R09: 000000000000000a
R10: 0000000000000017 R11: 0000000000000246 R12: 0000000000000000
R13: 000055afb5aad800 R14: 0000000000020000 R15: 0000000000000000
---[ end trace c286e96563966f08 ]---
This commit reworks the way that we handle i2c write for retimer in the way that we abort this configuration if the feature is not available in the device. For debug sake, we kept a simple log message in case the retimer is not available.
--- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 67 ++++++++----------- 1 file changed, 29 insertions(+), 38 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc_link.c +29 -38
@@ -1733,8 +1733,7 @@ static void write_i2c_retimer_setting( slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail;/* Based on DP159 specs, APPLY_RX_TX_CHANGE bit in 0x0A * needs to be set to 1 on every 0xA-0xC write.
@@ -1752,8 +1751,7 @@ static void write_i2c_retimer_setting( pipe_ctx->stream->link->ddc, slave_address, &offset, 1, &value, 1);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail; } buffer[0 ] = offset;
@@ -1765,8 +1763,7 @@ static void write_i2c_retimer_setting( offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail; } } }
@@ -1786,8 +1783,7 @@ static void write_i2c_retimer_setting( slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail;/* Based on DP159 specs, APPLY_RX_TX_CHANGE bit in 0x0A * needs to be set to 1 on every 0xA-0xC write.
@@ -1805,8 +1801,7 @@ static void write_i2c_retimer_setting( pipe_ctx->stream->link->ddc, slave_address, &offset, 1, &value, 1);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail; } buffer[0 ] = offset;
@@ -1818,8 +1813,7 @@ static void write_i2c_retimer_setting( offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail; } } }
@@ -1837,8 +1831,7 @@ static void write_i2c_retimer_setting( offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail;/* Write offset 0x00 to 0x23 */ buffer[0 ] =0x00 ;
@@ -1849,8 +1842,7 @@ static void write_i2c_retimer_setting( offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail;/* Write offset 0xff to 0x00 */ buffer[0 ] =0xff ;
@@ -1861,10 +1853,14 @@ static void write_i2c_retimer_setting( offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail; } + +return ; + +i2c_write_fail: +DC_LOG_DEBUG ("Set retimer failed" ); } static void write_i2c_default_retimer_setting(
@@ -1889,8 +1885,7 @@ static void write_i2c_default_retimer_setting( offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail;/* Write offset 0x0A to 0x17 */ buffer[0 ] =0x0A ;
@@ -1901,8 +1896,7 @@ static void write_i2c_default_retimer_setting( offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail;/* Write offset 0x0B to 0xDA or 0xD8 */ buffer[0 ] =0x0B ;
@@ -1913,8 +1907,7 @@ static void write_i2c_default_retimer_setting( offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail;/* Write offset 0x0A to 0x17 */ buffer[0 ] =0x0A ;
@@ -1925,8 +1918,7 @@ static void write_i2c_default_retimer_setting( offset = 0x%x, reg_val= 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail;/* Write offset 0x0C to 0x1D or 0x91 */ buffer[0 ] =0x0C ;
@@ -1937,8 +1929,7 @@ static void write_i2c_default_retimer_setting( offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail;/* Write offset 0x0A to 0x17 */ buffer[0 ] =0x0A ;
@@ -1949,8 +1940,7 @@ static void write_i2c_default_retimer_setting( offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail;if (is_vga_mode) {
@@ -1965,8 +1955,7 @@ static void write_i2c_default_retimer_setting( offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail;/* Write offset 0x00 to 0x23 */ buffer[0 ] =0x00 ;
@@ -1977,8 +1966,7 @@ static void write_i2c_default_retimer_setting( offset = 0x%x, reg_val= 0x%x, i2c_success = %d\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail;/* Write offset 0xff to 0x00 */ buffer[0 ] =0xff ;
@@ -1989,9 +1977,13 @@ static void write_i2c_default_retimer_setting( offset = 0x%x, reg_val= 0x%x, i2c_success = %d end here\n", slave_address, buffer[0], buffer[1], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); + goto i2c_write_fail; } + +return ; + +i2c_write_fail: +DC_LOG_DEBUG ("Set default retimer failed" ); } static void write_i2c_redriver_setting(
@@ -2020,8 +2012,7 @@ static void write_i2c_redriver_setting( slave_address, buffer[3], buffer[4], buffer[5], buffer[6], i2c_success?1:0);if (!i2c_success) -/* Write failure */ -ASSERT (i2c_success); +DC_LOG_DEBUG ("Set redriver failed" ); }static void enable_link_hdmi (struct pipe_ctx *pipe_ctx)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 162/388 Bluetooth: L2CAP: handle l2cap config request during open state
In reply to Greg Kroah-HartmanFrom: Howard Chung <[email protected]>
[ Upstream commit 96298f640104e4cd9a913a6e50b0b981829b94ff ]
According to Core Spec Version 5.2 | Vol 3, Part A 6.1.5, the incoming L2CAP_ConfigReq should be handled during OPEN state.
The section below shows the btmon trace when running L2CAP/COS/CFD/BV-12-C before and after this change.
=== Before ===
...
Quoted 1 line
ACL Data RX: Handle 256 flags
0x02dlen 12 #22
L2CAP: Connection Request (0x02) ident 2 len 4
PSM: 1 (0x0001)
Source CID: 65
< ACL Data TX: Handle 256 flags 0x00 dlen 16 #23
L2CAP: Connection Response (0x03) ident 2 len 8
Destination CID: 64
Source CID: 65
Result: Connection successful (0x0000)
Status: No further information available (0x0000)
< ACL Data TX: Handle 256 flags 0x00 dlen 12 #24
L2CAP: Configure Request (0x04) ident 2 len 4
Destination CID: 65
Flags: 0x0000Quoted 1 line
HCI Event: Number of Completed Packets (
0x13) plen 5 #25
Num handles: 1
Handle: 256
Count: 1
Quoted 1 line
HCI Event: Number of Completed Packets (
0x13) plen 5 #26
Num handles: 1
Handle: 256
Count: 1
Quoted 1 line
ACL Data RX: Handle 256 flags
0x02dlen 16 #27
L2CAP: Configure Request (0x04) ident 3 len 8
Destination CID: 64
Flags: 0x0000
Option: Unknown (0x10) [hint]
01 00 ..
< ACL Data TX: Handle 256 flags 0x00 dlen 18 #28
L2CAP: Configure Response (0x05) ident 3 len 10
Source CID: 65
Flags: 0x0000
Result: Success (0x0000)
Option: Maximum Transmission Unit (0x01) [mandatory]
MTU: 672Quoted 1 line
HCI Event: Number of Completed Packets (
0x13) plen 5 #29
Num handles: 1
Handle: 256
Count: 1
Quoted 1 line
ACL Data RX: Handle 256 flags
0x02dlen 14 #30
L2CAP: Configure Response (0x05) ident 2 len 6
Source CID: 64
Flags: 0x0000
Result: Success (0x0000)Quoted 1 line
ACL Data RX: Handle 256 flags
0x02dlen 20 #31
L2CAP: Configure Request (0x04) ident 3 len 12
Destination CID: 64
Flags: 0x0000
Option: Unknown (0x10) [hint]
01 00 91 02 11 11 ......< ACL Data TX: Handle 256 flags 0x00 dlen 14 #32
L2CAP: Command Reject (0x01) ident 3 len 6
Reason: Invalid CID in request (0x0002) Destination CID: 64
Source CID: 65
Quoted 1 line
HCI Event: Number of Completed Packets (
0x13) plen 5 #33
Num handles: 1
Handle: 256
Count: 1
...
=== After ===
...
Quoted 1 line
ACL Data RX: Handle 256 flags
0x02dlen 12 #22
L2CAP: Connection Request (0x02) ident 2 len 4
PSM: 1 (0x0001)
Source CID: 65
< ACL Data TX: Handle 256 flags 0x00 dlen 16 #23
L2CAP: Connection Response (0x03) ident 2 len 8
Destination CID: 64
Source CID: 65
Result: Connection successful (0x0000)
Status: No further information available (0x0000)
< ACL Data TX: Handle 256 flags 0x00 dlen 12 #24
L2CAP: Configure Request (0x04) ident 2 len 4
Destination CID: 65
Flags: 0x0000Quoted 1 line
HCI Event: Number of Completed Packets (
0x13) plen 5 #25
Num handles: 1
Handle: 256
Count: 1
Quoted 1 line
HCI Event: Number of Completed Packets (
0x13) plen 5 #26
Num handles: 1
Handle: 256
Count: 1
Quoted 1 line
ACL Data RX: Handle 256 flags
0x02dlen 16 #27
L2CAP: Configure Request (0x04) ident 3 len 8
Destination CID: 64
Flags: 0x0000
Option: Unknown (0x10) [hint]
01 00 ..
< ACL Data TX: Handle 256 flags 0x00 dlen 18 #28
L2CAP: Configure Response (0x05) ident 3 len 10
Source CID: 65
Flags: 0x0000
Result: Success (0x0000)
Option: Maximum Transmission Unit (0x01) [mandatory]
MTU: 672Quoted 1 line
HCI Event: Number of Completed Packets (
0x13) plen 5 #29
Num handles: 1
Handle: 256
Count: 1
Quoted 1 line
ACL Data RX: Handle 256 flags
0x02dlen 14 #30
L2CAP: Configure Response (0x05) ident 2 len 6
Source CID: 64
Flags: 0x0000
Result: Success (0x0000)Quoted 1 line
ACL Data RX: Handle 256 flags
0x02dlen 20 #31
L2CAP: Configure Request (0x04) ident 3 len 12
Destination CID: 64
Flags: 0x0000
Option: Unknown (0x10) [hint]
01 00 91 02 11 11 .....
< ACL Data TX: Handle 256 flags 0x00 dlen 18 #32
L2CAP: Configure Response (0x05) ident 3 len 10
Source CID: 65
Flags: 0x0000
Result: Success (0x0000)
Option: Maximum Transmission Unit (0x01) [mandatory]
MTU: 672
< ACL Data TX: Handle 256 flags 0x00 dlen 12 #33
L2CAP: Configure Request (0x04) ident 3 len 4
Destination CID: 65
Flags: 0x0000Quoted 1 line
HCI Event: Number of Completed Packets (
0x13) plen 5 #34
Num handles: 1
Handle: 256
Count: 1
Quoted 1 line
HCI Event: Number of Completed Packets (
0x13) plen 5 #35
Num handles: 1
Handle: 256
Count: 1
...
--- net/bluetooth/l2cap_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/bluetooth/l2cap_core.c +2 -1
@@ -4134,7 +4134,8 @@ static inline int l2cap_config_req(struct l2cap_conn *conn,return 0 ; } -if (chan->state !=BT_CONFIG && chan->state !=BT_CONNECT2 ) { +if (chan->state !=BT_CONFIG && chan->state !=BT_CONNECT2 && + chan->state !=BT_CONNECTED ) {cmd_reject_invalid_cid (conn, cmd->ident, chan->scid, chan->dcid); goto unlock;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 164/388 tty: sifive: Finish transmission before changing the clock
In reply to Greg Kroah-HartmanFrom: Palmer Dabbelt <[email protected]>
[ Upstream commit 4cbd7814bbd595061fcb6d6355d63f04179161cd ]
SiFive's UART has a software controller clock divider that produces the final baud rate clock. Whenever the clock that drives the UART is changed this divider must be updated accordingly, and given that these two events are controlled by software they cannot be done atomically. During the period between updating the UART's driving clock and internal divider the UART will transmit a different baud rate than what the user has configured, which will probably result in a corrupted transmission stream.
The SiFive UART has a FIFO, but due to an issue with the programming interface there is no way to directly determine when the UART has finished transmitting. We're essentially restricted to dead reckoning in order to figure that out: we can use the FIFO's TX busy register to figure out when the last frame has begun transmission and just delay for a long enough that the last frame is guaranteed to get out.
As far as the actual implementation goes: I've modified the existing existing clock notifier function to drain both the FIFO and the shift register in on PRE_RATE_CHANGE. As far as I know there is no hardware flow control in this UART, so there's no good way to ask the other end to stop transmission while we can't receive (inserting software flow control messages seems like a bad idea here).
--- drivers/tty/serial/sifive.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-)
drivers/tty/serial/sifive.c +24 -4
@@ -618,10 +618,10 @@ static void sifive_serial_shutdown(struct uart_port *port)* * On the V0 SoC, the UART IP block is derived from the CPU clock source * after a synchronous divide-by-two divider, so any CPU clock rate change -* requires the UART baud rate to be updated. This presumably could corrupt any -* serial word currently being transmitted or received. It would probably -* be better to stop receives and transmits, then complete the baud rate -* change, then re-enable them. +* requires the UART baud rate to be updated. This presumably corrupts any +* serial word currently being transmitted or received. In order to avoid +* corrupting the output data stream, we drain the transmit queue before +* allowing the clock's rate to be changed. */ static int sifive_serial_clk_notifier (struct notifier_block *nb,unsigned long event,void *data)
@@ -629,6 +629,26 @@ static int sifive_serial_clk_notifier(struct notifier_block *nb,struct clk_notifier_data *cnd = data;struct sifive_serial_port *ssp =notifier_to_sifive_serial_port (nb); +if (event ==PRE_RATE_CHANGE ) { +/* +* The TX watermark is always set to 1 by this driver, which +* means that the TX busy bit will lower when there are 0 bytes +* left in the TX queue -- in other words, when the TX FIFO is +* empty. +*/ +__ssp_wait_for_xmitr (ssp); +/* +* On the cycle the TX FIFO goes empty there is still a full +* UART frame left to be transmitted in the shift register. +* The UART provides no way for software to directly determine +* when that last frame has been transmitted, so we just sleep +* here instead. As we're not tracking the number of stop bits +* they're just worst cased here. The rest of the serial +* framing parameters aren't configurable by software. +*/ +udelay (DIV_ROUND_UP (12 *1000 *1000 , ssp->baud_rate)); + } +if (event ==POST_RATE_CHANGE && ssp->clkin_rate != cnd->new_rate) { ssp->clkin_rate = cnd->new_rate;__ssp_update_div (ssp);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 171/388 nfsd: Dont add locks to closed or closing open stateids
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit a451b12311aa8c96c6f6e01c783a86995dc3ec6b ]
In NFSv4, the lock stateids are tied to the lockowner, and the open stateid, so that the action of closing the file also results in either an automatic loss of the locks, or an error of the form NFS4ERR_LOCKS_HELD.
In practice this means we must not add new locks to the open stateid after the close process has been invoked. In fact doing so, can result in the following panic:
kernel BUG at lib/list_debug.c:51!
invalid opcode: 0000 [#1] SMP NOPTI
CPU: 2 PID: 1085 Comm: nfsd Not tainted 5.6.0-rc3+ #2 Hardware name: VMware, Inc. VMware7,1/440BX Desktop Reference Platform, BIOS VMW71.00V.14410784.B64.1908150010 08/15/2019 RIP: 0010:__list_del_entry_valid.cold+0x31/0x55 Code: 1a 3d 9b e8 74 10 c2 ff 0f 0b 48 c7 c7 f0 1a 3d 9b e8 66 10 c2 ff 0f 0b 48 89 f2 48 89 fe 48 c7 c7 b0 1a 3d 9b e8 52 10 c2 ff <0f> 0b 48 89 fe 4c 89 c2 48 c7 c7 78 1a 3d 9b e8 3e 10 c2 ff 0f 0b RSP: 0018:ffffb296c1d47d90 EFLAGS: 00010246 RAX: 0000000000000054 RBX: ffff8ba032456ec8 RCX: 0000000000000000 RDX: 0000000000000000 RSI: ffff8ba039e99cc8 RDI: ffff8ba039e99cc8 RBP: ffff8ba032456e60 R08: 0000000000000781 R09: 0000000000000003 R10: 0000000000000000 R11: 0000000000000001 R12: ffff8ba009a4abe0 R13: ffff8ba032456e8c R14: 0000000000000000 R15: ffff8ba00adb01d8 FS: 0000000000000000(0000) GS:ffff8ba039e80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fb213f0b008 CR3: 00000001347de006 CR4: 00000000003606e0 Call Trace: release_lock_stateid+0x2b/0x80 [nfsd] nfsd4_free_stateid+0x1e9/0x210 [nfsd] nfsd4_proc_compound+0x414/0x700 [nfsd] ? nfs4svc_decode_compoundargs+0x407/0x4c0 [nfsd] nfsd_dispatch+0xc1/0x200 [nfsd] svc_process_common+0x476/0x6f0 [sunrpc] ? svc_sock_secure_port+0x12/0x30 [sunrpc] ? svc_recv+0x313/0x9c0 [sunrpc] ? nfsd_svc+0x2d0/0x2d0 [nfsd] svc_process+0xd4/0x110 [sunrpc] nfsd+0xe3/0x140 [nfsd] kthread+0xf9/0x130 ? nfsd_destroy+0x50/0x50 [nfsd] ? kthread_park+0x90/0x90 ret_from_fork+0x1f/0x40
The fix is to ensure that lock creation tests for whether or not the open stateid is unhashed, and to fail if that is the case.
--- fs/nfsd/nfs4state.c | 73 ++++++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 30 deletions(-)
fs/nfsd/nfs4state.c +43 -30
@@ -495,6 +495,8 @@ find_any_file(struct nfs4_file *f) {struct nfsd_file *ret; +if (!f) +return NULL ;spin_lock (&f->fi_lock); ret =__nfs4_get_fd (f,O_RDWR );if (!ret) {
@@ -1273,6 +1275,12 @@ static void nfs4_put_stateowner(struct nfs4_stateowner *sop)nfs4_free_stateowner (sop); } +static bool +nfs4_ol_stateid_unhashed (const struct nfs4_ol_stateid *stp) +{ +return list_empty (&stp->st_perfile); +} +static bool unhash_ol_stateid (struct nfs4_ol_stateid *stp) {struct nfs4_file *fp = stp->st_stid.sc_file;
@@ -1343,9 +1351,11 @@ static bool unhash_lock_stateid(struct nfs4_ol_stateid *stp) {lockdep_assert_held (&stp->st_stid.sc_client->cl_lock); +if (!unhash_ol_stateid (stp)) +return false;list_del_init (&stp->st_locks);nfs4_unhash_stid (&stp->st_stid); -return unhash_ol_stateid (stp); +return true; }static void release_lock_stateid (struct nfs4_ol_stateid *stp)
@@ -1410,13 +1420,12 @@ static void release_open_stateid_locks(struct nfs4_ol_stateid *open_stp,static bool unhash_open_stateid (struct nfs4_ol_stateid *stp,struct list_head *reaplist) { -bool unhashed; -lockdep_assert_held (&stp->st_stid.sc_client->cl_lock); - unhashed =unhash_ol_stateid (stp); +if (!unhash_ol_stateid (stp)) +return false;release_open_stateid_locks (stp, reaplist); -return unhashed; +return true; }static void release_open_stateid (struct nfs4_ol_stateid *stp)
@@ -6267,21 +6276,21 @@ alloc_init_lock_stateowner(unsigned int strhashval, struct nfs4_client *clp, }static struct nfs4_ol_stateid * -find_lock_stateid (struct nfs4_lockowner *lo,struct nfs4_file *fp) +find_lock_stateid (const struct nfs4_lockowner *lo, +const struct nfs4_ol_stateid *ost) {struct nfs4_ol_stateid *lst; -struct nfs4_client *clp = lo->lo_owner.so_client; -lockdep_assert_held (&clp->cl_lock); +lockdep_assert_held (&ost->st_stid.sc_client->cl_lock); -list_for_each_entry (lst, &lo->lo_owner.so_stateids, st_perstateowner) { -if (lst->st_stid.sc_type !=NFS4_LOCK_STID ) -continue ; -if (lst->st_stid.sc_file == fp) { -refcount_inc (&lst->st_stid.sc_count); -return lst; +/* If ost is not hashed, ost->st_locks will not be valid */ +if (!nfs4_ol_stateid_unhashed (ost)) +list_for_each_entry (lst, &ost->st_locks, st_locks) { +if (lst->st_stateowner == &lo->lo_owner) { +refcount_inc (&lst->st_stid.sc_count); +return lst; + } } - }return NULL ; }
@@ -6297,11 +6306,11 @@ init_lock_stateid(struct nfs4_ol_stateid *stp, struct nfs4_lockowner *lo,mutex_lock_nested (&stp->st_mutex,OPEN_STATEID_MUTEX ); retry:spin_lock (&clp->cl_lock); -spin_lock (&fp->fi_lock); - retstp =find_lock_stateid (lo, fp); +if (nfs4_ol_stateid_unhashed (open_stp)) + goto out_close; + retstp =find_lock_stateid (lo, open_stp);if (retstp) - goto out_unlock; - + goto out_found;refcount_inc (&stp->st_stid.sc_count); stp->st_stid.sc_type =NFS4_LOCK_STID ; stp->st_stateowner =nfs4_get_stateowner (&lo->lo_owner);
@@ -6310,22 +6319,26 @@ retry: stp->st_access_bmap =0 ; stp->st_deny_bmap = open_stp->st_deny_bmap; stp->st_openstp = open_stp; +spin_lock (&fp->fi_lock);list_add (&stp->st_locks, &open_stp->st_locks);list_add (&stp->st_perstateowner, &lo->lo_owner.so_stateids);list_add (&stp->st_perfile, &fp->fi_stateids); -out_unlock:spin_unlock (&fp->fi_lock);spin_unlock (&clp->cl_lock); -if (retstp) { -if (nfsd4_lock_ol_stateid (retstp) != nfs_ok) { -nfs4_put_stid (&retstp->st_stid); - goto retry; - } -/* To keep mutex tracking happy */ -mutex_unlock (&stp->st_mutex); - stp = retstp; - }return stp; +out_found: +spin_unlock (&clp->cl_lock); +if (nfsd4_lock_ol_stateid (retstp) != nfs_ok) { +nfs4_put_stid (&retstp->st_stid); + goto retry; + } +/* To keep mutex tracking happy */ +mutex_unlock (&stp->st_mutex); +return retstp; +out_close: +spin_unlock (&clp->cl_lock); +mutex_unlock (&stp->st_mutex); +return NULL ; } static struct nfs4_ol_stateid *
@@ -6340,7 +6353,7 @@ find_or_create_lock_stateid(struct nfs4_lockowner *lo, struct nfs4_file *fi, *new = false;spin_lock (&clp->cl_lock); - lst =find_lock_stateid (lo, fi); + lst =find_lock_stateid (lo, ost);spin_unlock (&clp->cl_lock);if (lst !=NULL ) {if (nfsd4_lock_ol_stateid (lst) == nfs_ok)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 153/388 ARM: OMAP2+: Handle errors for cpu_pm
In reply to Greg Kroah-HartmanFrom: Tony Lindgren <[email protected]>
[ Upstream commit 55be2f50336f67800513b46c5ba6270e4ed0e784 ]
We need to check for errors when calling cpu_pm_enter() and cpu_cluster_pm_enter(). And we need to bail out on errors as otherwise we can enter a deeper idle state when not desired.
I'm not aware of the lack of error handling causing issues yet, but we need this at least for blocking deeper idle states when a GPIO instance has pending interrupts.
--- arch/arm/mach-omap2/cpuidle34xx.c | 9 +++++++-- arch/arm/mach-omap2/cpuidle44xx.c | 26 +++++++++++++++++--------- arch/arm/mach-omap2/pm34xx.c | 8 ++++++-- 3 files changed, 30 insertions(+), 13 deletions(-)
arch/arm/mach-omap2/cpuidle34xx.c +7 -2
@@ -109,6 +109,7 @@ static int omap3_enter_idle(struct cpuidle_device *dev, int index) {struct omap3_idle_statedata *cx = &omap3_idle_data[index]; +int error;if (omap_irq_pending () ||need_resched ()) goto return_sleep_time;
@@ -125,8 +126,11 @@ static int omap3_enter_idle(struct cpuidle_device *dev,* Call idle CPU PM enter notifier chain so that * VFP context is saved. */ -if (cx->mpu_state ==PWRDM_POWER_OFF ) -cpu_pm_enter (); +if (cx->mpu_state ==PWRDM_POWER_OFF ) { + error =cpu_pm_enter (); +if (error) + goto out_clkdm_set; + }/* Execute ARM wfi */ omap_sram_idle ();
@@ -139,6 +143,7 @@ static int omap3_enter_idle(struct cpuidle_device *dev, pwrdm_read_prev_pwrst(mpu_pd) == PWRDM_POWER_OFF)cpu_pm_exit (); +out_clkdm_set:/* Re-allow idle for C1 */ if (cx->flags &OMAP_CPUIDLE_CX_NO_CLKDM_IDLE )clkdm_allow_idle (mpu_pd->pwrdm_clkdms[0 ]);
arch/arm/mach-omap2/cpuidle44xx.c +17 -9
@@ -122,6 +122,7 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev, {struct idle_statedata *cx = state_ptr + index;u32 mpuss_can_lose_context =0 ; +int error;/* * CPU0 has to wait and stay ON until CPU1 is OFF state.
@@ -159,7 +160,9 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev,* Call idle CPU PM enter notifier chain so that * VFP and per CPU interrupt context is saved. */ -cpu_pm_enter (); + error =cpu_pm_enter (); +if (error) + goto cpu_pm_out;if (dev->cpu ==0 ) {pwrdm_set_logic_retst (mpu_pd, cx->mpu_logic_state);
@@ -169,13 +172,17 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev,* Call idle CPU cluster PM enter notifier chain * to save GIC and wakeupgen context. */ -if (mpuss_can_lose_context) -cpu_cluster_pm_enter (); +if (mpuss_can_lose_context) { + error =cpu_cluster_pm_enter (); +if (error) + goto cpu_cluster_pm_out; + } }omap4_enter_lowpower (dev->cpu, cx->cpu_state); cpu_done[dev->cpu] = true; +cpu_cluster_pm_out:/* Wakeup CPU1 only if it is not offlined */ if (dev->cpu ==0 &&cpumask_test_cpu (1 , cpu_online_mask)) {
@@ -197,12 +204,6 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev, } } -/* -* Call idle CPU PM exit notifier chain to restore -* VFP and per CPU IRQ context. -*/ -cpu_pm_exit (); -/* * Call idle CPU cluster PM exit notifier chain * to restore GIC and wakeupgen context.
@@ -210,6 +211,13 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev,if (dev->cpu ==0 && mpuss_can_lose_context)cpu_cluster_pm_exit (); +/* +* Call idle CPU PM exit notifier chain to restore +* VFP and per CPU IRQ context. +*/ +cpu_pm_exit (); + +cpu_pm_out:tick_broadcast_exit (); fail:
arch/arm/mach-omap2/pm34xx.c +6 -2
@@ -194,6 +194,7 @@ void omap_sram_idle(void)int per_next_state =PWRDM_POWER_ON ;int core_next_state =PWRDM_POWER_ON ;u32 sdrc_pwr =0 ; +int error; mpu_next_state =pwrdm_read_next_pwrst (mpu_pwrdm);switch (mpu_next_state) {
@@ -222,8 +223,11 @@ void omap_sram_idle(void)pwrdm_pre_transition (NULL );/* PER */ -if (per_next_state ==PWRDM_POWER_OFF ) -cpu_cluster_pm_enter (); +if (per_next_state ==PWRDM_POWER_OFF ) { + error =cpu_cluster_pm_enter (); +if (error) +return ; + }/* CORE */ if (core_next_state <PWRDM_POWER_ON ) {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 166/388 xfs: mark dir corrupt when lookup-by-hash fails
In reply to Greg Kroah-HartmanFrom: Darrick J. Wong <[email protected]>
[ Upstream commit 2e107cf869eecc770e3f630060bb4e5f547d0fd8 ]
In xchk_dir_actor, we attempt to validate the directory hash structures by performing a directory entry lookup by (hashed) name. If the lookup returns ENOENT, that means that the hash information is corrupt. The _process_error functions don't catch this, so we have to add that explicitly.
--- fs/xfs/scrub/dir.c | 3 +++ 1 file changed, 3 insertions(+)
fs/xfs/scrub/dir.c +3 -0
@@ -152,6 +152,9 @@ xchk_dir_actor( xname.type =XFS_DIR3_FT_UNKNOWN ; error =xfs_dir_lookup (sdc->sc->tp, ip, &xname, &lookup_ino,NULL ); +/* ENOENT means the hash lookup failed and the dir is corrupt */ +if (error == -ENOENT ) + error = -EFSCORRUPTED ;if (!xchk_fblock_process_error (sdc->sc,XFS_DATA_FORK , offset, &error)) goto out;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 126/388 perf test: Fix test trace+probe_vfs_getname.sh on s390
In reply to Greg Kroah-HartmanFrom: Thomas Richter <[email protected]>
[ Upstream commit 2bbc83537614517730e9f2811195004b712de207 ]
This test places a kprobe to function getname_flags() in the kernel which has the following prototype:
struct filename *getname_flags(const char __user *filename, int flags, int *empty)
The 'filename' argument points to a filename located in user space memory.
Looking at commit 88903c464321c ("tracing/probe: Add ustring type for user-space string") the kprobe should indicate that user space memory is accessed.
Output before:
[root@m35lp76 perf]# ./perf test 66 67
66: Use vfs_getname probe to get syscall args filenames : FAILED!
67: Check open filename arg using perf trace + vfs_getname: FAILED! [root@m35lp76 perf]#
Output after:
[root@m35lp76 perf]# ./perf test 66 67
66: Use vfs_getname probe to get syscall args filenames : Ok
67: Check open filename arg using perf trace + vfs_getname: Ok [root@m35lp76 perf]#
Comments from Masami Hiramatsu:
This bug doesn't happen on x86 or other archs on which user address space and kernel address space is the same. On some arches (ppc64 in this case?) user address space is partially or completely the same as kernel address space.
(Yes, they switch the world when running into the kernel) In this case, we need to use different data access functions for each space.
That is why I introduced the "ustring" type for kprobe events.
As far as I can see, Thomas's patch is sane. Thomas, could you show us your result on your test environment?
Comments from Thomas Richter:
Test results for s/390 included above.
--- tools/perf/tests/shell/lib/probe_vfs_getname.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/shell/lib/probe_vfs_getname.sh +1 -1
@@ -14,7 +14,7 @@ add_probe_vfs_getname() { if [ $had_vfs_getname -eq 1 ] ; then line=$(perf probe -L getname_flags 2>&1 | egrep 'result.*=.*filename;' | sed -r 's/[[:space:]]+([[:digit:]]+)[[:space:]]+result->uptr.*/\1/') perf probe -q "vfs_getname=getname_flags:${line} pathname=result->name:string" || \ - perf probe $verbose "vfs_getname=getname_flags:${line} pathname=filename:string" + perf probe $verbose "vfs_getname=getname_flags:${line} pathname=filename:ustring" fi }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 169/388 rtc: sa1100: fix possible race condition
In reply to Greg Kroah-HartmanFrom: Alexandre Belloni <[email protected]>
[ Upstream commit f2997775b111c6d660c32a18d5d44d37cb7361b1 ]
Both RTC IRQs are requested before the struct rtc_device is allocated, this may lead to a NULL pointer dereference in the IRQ handler.
To fix this issue, allocating the rtc_device struct before requesting the IRQs using devm_rtc_allocate_device, and use rtc_register_device to register the RTC device.
--- drivers/rtc/rtc-sa1100.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/rtc/rtc-sa1100.c +10 -8
@@ -182,7 +182,6 @@ static const struct rtc_class_ops sa1100_rtc_ops = {int sa1100_rtc_init (struct platform_device *pdev,struct sa1100_rtc *info) { -struct rtc_device *rtc;int ret;spin_lock_init (&info->lock);
@@ -211,15 +210,14 @@ int sa1100_rtc_init(struct platform_device *pdev, struct sa1100_rtc *info)writel_relaxed (0 , info->rcnr); } - rtc =devm_rtc_device_register (&pdev->dev, pdev->name, &sa1100_rtc_ops, -THIS_MODULE ); -if (IS_ERR (rtc)) { + info->rtc->ops = &sa1100_rtc_ops; + info->rtc->max_user_freq =RTC_FREQ ; + + ret =rtc_register_device (info->rtc); +if (ret) {clk_disable_unprepare (info->clk); -return PTR_ERR (rtc); +return ret; } - info->rtc = rtc; - - rtc->max_user_freq =RTC_FREQ ;/* Fix for a nasty initialization problem the in SA11xx RTSR register. * See also the comments in sa1100_rtc_interrupt().
@@ -268,6 +266,10 @@ static int sa1100_rtc_probe(struct platform_device *pdev) info->irq_1hz = irq_1hz; info->irq_alarm = irq_alarm; + info->rtc =devm_rtc_allocate_device (&pdev->dev); +if (IS_ERR (info->rtc)) +return PTR_ERR (info->rtc); + ret =devm_request_irq (&pdev->dev, irq_1hz, sa1100_rtc_interrupt,0 ,"rtc 1Hz" , &pdev->dev);if (ret) {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 170/388 rtc: ds1374: fix possible race condition
In reply to Greg Kroah-HartmanFrom: Alexandre Belloni <[email protected]>
[ Upstream commit c11af8131a4e7ba1960faed731ee7e84c2c13c94 ]
The RTC IRQ is requested before the struct rtc_device is allocated, this may lead to a NULL pointer dereference in the IRQ handler.
To fix this issue, allocating the rtc_device struct before requesting the RTC IRQ using devm_rtc_allocate_device, and use rtc_register_device to register the RTC device.
--- drivers/rtc/rtc-ds1374.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/rtc/rtc-ds1374.c +9 -6
@@ -620,6 +620,10 @@ static int ds1374_probe(struct i2c_client *client,if (!ds1374)return -ENOMEM ; + ds1374->rtc =devm_rtc_allocate_device (&client->dev); +if (IS_ERR (ds1374->rtc)) +return PTR_ERR (ds1374->rtc); + ds1374->client = client;i2c_set_clientdata (client, ds1374);
@@ -641,12 +645,11 @@ static int ds1374_probe(struct i2c_client *client,device_set_wakeup_capable (&client->dev,1 ); } - ds1374->rtc =devm_rtc_device_register (&client->dev, client->name, - &ds1374_rtc_ops,THIS_MODULE ); -if (IS_ERR (ds1374->rtc)) { -dev_err (&client->dev,"unable to register the class device\n" ); -return PTR_ERR (ds1374->rtc); - } + ds1374->rtc->ops = &ds1374_rtc_ops; + + ret =rtc_register_device (ds1374->rtc); +if (ret) +return ret;#ifdef CONFIG_RTC_DRV_DS1374_WDT save_client = client;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 163/388 media: tda10071: fix unsigned sign extension overflow
In reply to Greg Kroah-HartmanFrom: Colin Ian King <[email protected]>
[ Upstream commit a7463e2dc698075132de9905b89f495df888bb79 ]
The shifting of buf[3] by 24 bits to the left will be promoted to a 32 bit signed int and then sign-extended to an unsigned long. In the unlikely event that the the top bit of buf[3] is set then all then all the upper bits end up as also being set because of the sign-extension and this affect the ev->post_bit_error sum. Fix this by using the temporary u32 variable bit_error to avoid the sign-extension promotion. This also removes the need to do the computation twice.
Addresses-Coverity: ("Unintended sign extension")
--- drivers/media/dvb-frontends/tda10071.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/media/dvb-frontends/tda10071.c +5 -4
@@ -470,10 +470,11 @@ static int tda10071_read_status(struct dvb_frontend *fe, enum fe_status *status) goto error;if (dev->delivery_system ==SYS_DVBS ) { - dev->dvbv3_ber = buf[0 ] <<24 | buf[1 ] <<16 | - buf[2 ] <<8 | buf[3 ] <<0 ; - dev->post_bit_error += buf[0 ] <<24 | buf[1 ] <<16 | - buf[2 ] <<8 | buf[3 ] <<0 ; +u32 bit_error = buf[0 ] <<24 | buf[1 ] <<16 | + buf[2 ] <<8 | buf[3 ] <<0 ; + + dev->dvbv3_ber = bit_error; + dev->post_bit_error += bit_error; c->post_bit_error.stat[0 ].scale =FE_SCALE_COUNTER ; c->post_bit_error.stat[0 ].uvalue = dev->post_bit_error; dev->block_error += buf[4 ] <<8 | buf[5 ] <<0 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 168/388 tpm: ibmvtpm: Wait for buffer to be set before proceeding
In reply to Greg Kroah-HartmanFrom: Stefan Berger <[email protected]>
[ Upstream commit d8d74ea3c00214aee1e1826ca18e77944812b9b4 ]
Synchronize with the results from the CRQs before continuing with the initialization. This avoids trying to send TPM commands while the rtce buffer has not been allocated, yet.
This patch fixes an existing race condition that may occurr if the hypervisor does not quickly respond to the VTPM_GET_RTCE_BUFFER_SIZE request sent during initialization and therefore the ibmvtpm->rtce_buf has not been allocated at the time the first TPM command is sent.
--- drivers/char/tpm/tpm_ibmvtpm.c | 9 +++++++++ drivers/char/tpm/tpm_ibmvtpm.h | 1 + 2 files changed, 10 insertions(+)
drivers/char/tpm/tpm_ibmvtpm.c +9 -0
@@ -581,6 +581,7 @@ static irqreturn_t ibmvtpm_interrupt(int irq, void *vtpm_instance)*/ while ((crq =ibmvtpm_crq_get_next (ibmvtpm)) !=NULL ) {ibmvtpm_crq_process (crq, ibmvtpm); +wake_up_interruptible (&ibmvtpm->crq_queue.wq); crq->valid =0 ;smp_wmb (); }
@@ -628,6 +629,7 @@ static int tpm_ibmvtpm_probe(struct vio_dev *vio_dev, } crq_q->num_entry =CRQ_RES_BUF_SIZE /sizeof (*crq_q->crq_addr); +init_waitqueue_head (&crq_q->wq); ibmvtpm->crq_dma_handle =dma_map_single (dev, crq_q->crq_addr,CRQ_RES_BUF_SIZE ,DMA_BIDIRECTIONAL );
@@ -680,6 +682,13 @@ static int tpm_ibmvtpm_probe(struct vio_dev *vio_dev,if (rc) goto init_irq_cleanup; +if (!wait_event_timeout (ibmvtpm->crq_queue.wq, + ibmvtpm->rtce_buf !=NULL , +HZ )) { +dev_err (dev,"CRQ response timed out\n" ); + goto init_irq_cleanup; + } +return tpm_chip_register (chip); init_irq_cleanup: do {
drivers/char/tpm/tpm_ibmvtpm.h +1 -0
@@ -26,6 +26,7 @@ struct ibmvtpm_crq_queue {struct ibmvtpm_crq *crq_addr;u32 index;u32 num_entry; +wait_queue_head_t wq; };struct ibmvtpm_dev {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 123/388 mt76: clear skb pointers from rx aggregation reorder buffer during cleanup
In reply to Greg Kroah-HartmanFrom: Felix Fietkau <[email protected]>
[ Upstream commit 9379df2fd9234e3b67a23101c2370c99f6af6d77 ]
During the cleanup of the aggregation session, a rx handler (or release timer) on another CPU might still hold a pointer to the reorder buffer and could attempt to release some packets.
Clearing pointers during cleanup avoids a theoretical use-after-free bug here.
--- drivers/net/wireless/mediatek/mt76/agg-rx.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/mediatek/mt76/agg-rx.c +1 -0
@@ -268,6 +268,7 @@ static void mt76_rx_aggr_shutdown(struct mt76_dev *dev, struct mt76_rx_tid *tid)if (!skb)continue ; + tid->reorder_buf[i] =NULL ; tid->nframes--;dev_kfree_skb (skb); }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 165/388 xfs: dont ever return a stale pointer from __xfs_dir3_free_read
In reply to Greg Kroah-HartmanFrom: Darrick J. Wong <[email protected]>
[ Upstream commit 1cb5deb5bc095c070c09a4540c45f9c9ba24be43 ]
If we decide that a directory free block is corrupt, we must take care not to leak a buffer pointer to the caller. After xfs_trans_brelse returns, the buffer can be freed or reused, which means that we have to set *bpp back to NULL.
Callers are supposed to notice the nonzero return value and not use the buffer pointer, but we should code more defensively, even if all current callers handle this situation correctly.
--- fs/xfs/libxfs/xfs_dir2_node.c | 1 + 1 file changed, 1 insertion(+)
fs/xfs/libxfs/xfs_dir2_node.c +1 -0
@@ -210,6 +210,7 @@ __xfs_dir3_free_read(if (fa) {xfs_verifier_error (*bpp, -EFSCORRUPTED , fa);xfs_trans_brelse (tp, *bpp); + *bpp =NULL ;return -EFSCORRUPTED ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 127/388 RDMA/rxe: Fix configuration of atomic queue pair attributes
In reply to Greg Kroah-HartmanFrom: Bart Van Assche <[email protected]>
[ Upstream commit fb3063d31995cc4cf1d47a406bb61d6fb1b1d58d ]
Quoted 1 line
From the comment above the definition of the
roundup_pow_of_two()macro:
The result is undefined when n == 0.
Hence only pass positive values to roundup_pow_of_two(). This patch fixes the following UBSAN complaint:
UBSAN: Undefined behaviour in ./include/linux/log2.h:57:13 shift exponent 64 is too large for 64-bit type 'long unsigned int' Call Trace: dump_stack+0xa5/0xe6 ubsan_epilogue+0x9/0x26 __ubsan_handle_shift_out_of_bounds.cold+0x4c/0xf9 rxe_qp_from_attr.cold+0x37/0x5d [rdma_rxe] rxe_modify_qp+0x59/0x70 [rdma_rxe] _ib_modify_qp+0x5aa/0x7c0 [ib_core] ib_modify_qp+0x3b/0x50 [ib_core] cma_modify_qp_rtr+0x234/0x260 [rdma_cm] __rdma_accept+0x1a7/0x650 [rdma_cm] nvmet_rdma_cm_handler+0x1286/0x14cd [nvmet_rdma] cma_cm_event_handler+0x6b/0x330 [rdma_cm] cma_ib_req_handler+0xe60/0x22d0 [rdma_cm] cm_process_work+0x30/0x140 [ib_cm] cm_req_handler+0x11f4/0x1cd0 [ib_cm] cm_work_handler+0xb8/0x344e [ib_cm] process_one_work+0x569/0xb60 worker_thread+0x7a/0x5d0 kthread+0x1e6/0x210 ret_from_fork+0x24/0x30
--- drivers/infiniband/sw/rxe/rxe_qp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/infiniband/sw/rxe/rxe_qp.c +4 -3
@@ -592,15 +592,16 @@ int rxe_qp_from_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask,int err;if (mask &IB_QP_MAX_QP_RD_ATOMIC ) { -int max_rd_atomic =__roundup_pow_of_two (attr->max_rd_atomic); +int max_rd_atomic = attr->max_rd_atomic ? +roundup_pow_of_two (attr->max_rd_atomic) :0 ; qp->attr.max_rd_atomic = max_rd_atomic;atomic_set (&qp->req.rd_atomic, max_rd_atomic); }if (mask &IB_QP_MAX_DEST_RD_ATOMIC ) { -int max_dest_rd_atomic = -__roundup_pow_of_two (attr->max_dest_rd_atomic); +int max_dest_rd_atomic = attr->max_dest_rd_atomic ? +roundup_pow_of_two (attr->max_dest_rd_atomic) :0 ; qp->attr.max_dest_rd_atomic = max_dest_rd_atomic;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 167/388 ext4: mark block bitmap corrupted when found instead of BUGON
In reply to Greg Kroah-HartmanFrom: Dmitry Monakhov <[email protected]>
[ Upstream commit eb5760863fc28feab28b567ddcda7e667e638da0 ]
We already has similar code in ext4_mb_complex_scan_group(), but ext4_mb_simple_scan_group() still affected.
Other reports: https://www.spinics.net/lists/linux-ext4/msg60231.html
--- fs/ext4/mballoc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
fs/ext4/mballoc.c +9 -2
@@ -1901,8 +1901,15 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,BUG_ON (buddy ==NULL ); k =mb_find_next_zero_bit (buddy, max,0 ); -BUG_ON (k >= max); - +if (k >= max) { +ext4_grp_locked_error (ac->ac_sb, e4b->bd_group,0 ,0 , +"%d free clusters of order %d. But found 0" , + grp->bb_counters[i], i); +ext4_mark_group_bitmap_corrupted (ac->ac_sb, + e4b->bd_group, +EXT4_GROUP_INFO_BBITMAP_CORRUPT ); +break ; + } ac->ac_found++; ac->ac_b_ex.fe_len =1 << i;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 141/388 random: fix data races at timer_rand_state
In reply to Greg Kroah-HartmanFrom: Qian Cai <[email protected]>
[ Upstream commit e00d996a4317aff5351c4338dd97d390225412c2 ]
Fields in "struct timer_rand_state" could be accessed concurrently. Lockless plain reads and writes result in data races. Fix them by adding pairs of READ|WRITE_ONCE(). The data races were reported by KCSAN,
BUG: KCSAN: data-race in add_timer_randomness / add_timer_randomness
write to 0xffff9f320a0a01d0 of 8 bytes by interrupt on cpu 22:
add_timer_randomness+0x100/0x190 add_timer_randomness at drivers/char/random.c:1152 add_disk_randomness+0x85/0x280 scsi_end_request+0x43a/0x4a0 scsi_io_completion+0xb7/0x7e0 scsi_finish_command+0x1ed/0x2a0 scsi_softirq_done+0x1c9/0x1d0 blk_done_softirq+0x181/0x1d0 __do_softirq+0xd9/0x57c irq_exit+0xa2/0xc0 do_IRQ+0x8b/0x190 ret_from_intr+0x0/0x42 cpuidle_enter_state+0x15e/0x980 cpuidle_enter+0x69/0xc0 call_cpuidle+0x23/0x40 do_idle+0x248/0x280 cpu_startup_entry+0x1d/0x1f start_secondary+0x1b2/0x230 secondary_startup_64+0xb6/0xc0
no locks held by swapper/22/0.
irq event stamp: 32871382 _raw_spin_unlock_irqrestore+0x53/0x60 _raw_spin_lock_irqsave+0x21/0x60 _local_bh_enable+0x21/0x30 irq_exit+0xa2/0xc0
read to 0xffff9f320a0a01d0 of 8 bytes by interrupt on cpu 2:
add_timer_randomness+0xe8/0x190 add_disk_randomness+0x85/0x280 scsi_end_request+0x43a/0x4a0 scsi_io_completion+0xb7/0x7e0 scsi_finish_command+0x1ed/0x2a0 scsi_softirq_done+0x1c9/0x1d0 blk_done_softirq+0x181/0x1d0 __do_softirq+0xd9/0x57c irq_exit+0xa2/0xc0 do_IRQ+0x8b/0x190 ret_from_intr+0x0/0x42 cpuidle_enter_state+0x15e/0x980 cpuidle_enter+0x69/0xc0 call_cpuidle+0x23/0x40 do_idle+0x248/0x280 cpu_startup_entry+0x1d/0x1f start_secondary+0x1b2/0x230 secondary_startup_64+0xb6/0xc0
no locks held by swapper/2/0.
irq event stamp: 37846304 _raw_spin_unlock_irqrestore+0x53/0x60 _raw_spin_lock_irqsave+0x21/0x60 _local_bh_enable+0x21/0x30 irq_exit+0xa2/0xc0
Reported by Kernel Concurrency Sanitizer on:
Hardware name: HP ProLiant BL660c Gen9, BIOS I38 10/17/2018
--- drivers/char/random.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/char/random.c +6 -6
@@ -1223,14 +1223,14 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num)* We take into account the first, second and third-order deltas * in order to make our estimate. */ - delta = sample.jiffies - state->last_time; - state->last_time = sample.jiffies; + delta = sample.jiffies -READ_ONCE (state->last_time); +WRITE_ONCE (state->last_time, sample.jiffies); - delta2 = delta - state->last_delta; - state->last_delta = delta; + delta2 = delta -READ_ONCE (state->last_delta); +WRITE_ONCE (state->last_delta, delta); - delta3 = delta2 - state->last_delta2; - state->last_delta2 = delta2; + delta3 = delta2 -READ_ONCE (state->last_delta2); +WRITE_ONCE (state->last_delta2, delta2);if (delta <0 ) delta = -delta;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 142/388 bus: hisi_lpc: Fixup IO ports addresses to avoid use-after-free in host removal
In reply to Greg Kroah-HartmanFrom: John Garry <[email protected]>
[ Upstream commit a6dd255bdd7d00bbdbf78ba00bde9fc64f86c3a7 ]
Some released ACPI FW for Huawei boards describes incorrect the port IO address range for child devices, in that it tells us the IO port max range is 0x3fff for each child device, which is not correct. The address range should be [e4:e8) or similar. With this incorrect upper range, the child device IO port resources overlap.
As such, the kernel thinks that the LPC host serial device is a child of the IPMI device:
root@(none)$ more /proc/ioports
[...]
00ffc0e3-00ffffff : hisi-lpc-ipmi.0.auto
00ffc0e3-00ffc0e3 : ipmi_si
00ffc0e4-00ffc0e4 : ipmi_si
00ffc0e5-00ffc0e5 : ipmi_si
00ffc2f7-00ffffff : serial8250.1.auto
00ffc2f7-00ffc2fe : serial
root@(none)$They should both be siblings. Note that these are logical PIO addresses, which have a direct mapping from the FW IO port ranges.
This shows up as a real issue when we enable CONFIG_KASAN and CONFIG_DEBUG_TEST_DRIVER_REMOVE - we see use-after-free warnings in the host removal path:
==================================================================
BUG: KASAN: use-after-free in release_resource+0x38/0xc8 Read of size 8 at addr ffff0026accdbc38 by task swapper/0/1 CPU: 2 PID: 1 Comm: swapper/0 Not tainted 5.5.0-rc6-00001-g68e186e77b5c-dirty #1593 Hardware name: Huawei Taishan 2180 /D03, BIOS Hisilicon D03 IT20 Nemo 2.0 RC0 03/30/2018 Call trace: dump_backtrace+0x0/0x290 show_stack+0x14/0x20 dump_stack+0xf0/0x14c print_address_description.isra.9+0x6c/0x3b8 __kasan_report+0x12c/0x23c kasan_report+0xc/0x18 __asan_load8+0x94/0xb8 release_resource+0x38/0xc8 platform_device_del.part.10+0x80/0xe0 platform_device_unregister+0x20/0x38 hisi_lpc_acpi_remove_subdev+0x10/0x20 device_for_each_child+0xc8/0x128 hisi_lpc_acpi_remove+0x4c/0xa8 hisi_lpc_remove+0xbc/0xc0 platform_drv_remove+0x3c/0x68 really_probe+0x174/0x548 driver_probe_device+0x7c/0x148 device_driver_attach+0x94/0xa0 __driver_attach+0xa4/0x110 bus_for_each_dev+0xe8/0x158 driver_attach+0x30/0x40 bus_add_driver+0x234/0x2f0 driver_register+0xbc/0x1d0 __platform_driver_register+0x7c/0x88 hisi_lpc_driver_init+0x18/0x20 do_one_initcall+0xb4/0x258 kernel_init_freeable+0x248/0x2c0 kernel_init+0x10/0x118 ret_from_fork+0x10/0x1c
...
The issue here is that the kernel created an incorrect parent-child resource dependency between two devices, and references the false parent node when deleting the second child device, when it had been deleted already.
Fix up the child device resources from FW to create proper IO port resource relationships for broken FW.
With this, the IO port layout looks more healthy:
root@(none)$ more /proc/ioports [...] 00ffc0e3-00ffc0e7 : hisi-lpc-ipmi.0.auto 00ffc0e3-00ffc0e3 : ipmi_si 00ffc0e4-00ffc0e4 : ipmi_si 00ffc0e5-00ffc0e5 : ipmi_si 00ffc2f7-00ffc2ff : serial8250.1.auto 00ffc2f7-00ffc2fe : serial
--- drivers/bus/hisi_lpc.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)
drivers/bus/hisi_lpc.c +25 -2
@@ -358,6 +358,26 @@ static int hisi_lpc_acpi_xlat_io_res(struct acpi_device *adev,return 0 ; } +/* +* Released firmware describes the IO port max address as 0x3fff, which is +* the max host bus address. Fixup to a proper range. This will probably +* never be fixed in firmware. +*/ +static void hisi_lpc_acpi_fixup_child_resource (struct device *hostdev, +struct resource *r) +{ +if (r->end !=0x3fff ) +return ; + +if (r->start ==0xe4 ) + r->end =0xe4 +0x04 -1 ; +else if (r->start ==0x2f8 ) + r->end =0x2f8 +0x08 -1 ; +else +dev_warn (hostdev,"unrecognised resource %pR to fixup, ignoring\n" , + r); +} +/* * hisi_lpc_acpi_set_io_res - set the resources for a child * @child: the device node to be updated the I/O resource
@@ -419,8 +439,11 @@ static int hisi_lpc_acpi_set_io_res(struct device *child,return -ENOMEM ; } count =0 ; -list_for_each_entry (rentry, &resource_list, node) - resources[count++] = *rentry->res; +list_for_each_entry (rentry, &resource_list, node) { + resources[count] = *rentry->res; +hisi_lpc_acpi_fixup_child_resource (hostdev, &resources[count]); + count++; + }acpi_dev_free_resource_list (&resource_list);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 151/388 mm: avoid data corruption on CoW fault into PFN-mapped VMA
In reply to Greg Kroah-HartmanFrom: Kirill A. Shutemov <[email protected]>
[ Upstream commit c3e5ea6ee574ae5e845a40ac8198de1fb63bb3ab ]
Jeff Moyer has reported that one of xfstests triggers a warning when run on DAX-enabled filesystem:
WARNING: CPU: 76 PID: 51024 at mm/memory.c:2317 wp_page_copy+0xc40/0xd50 ... wp_page_copy+0x98c/0xd50 (unreliable) do_wp_page+0xd8/0xad0 __handle_mm_fault+0x748/0x1b90 handle_mm_fault+0x120/0x1f0 __do_page_fault+0x240/0xd70 do_page_fault+0x38/0xd0 handle_page_fault+0x10/0x30
The warning happens on failed __copy_from_user_inatomic() which tries to copy data into a CoW page.
This happens because of race between MADV_DONTNEED and CoW page fault:
CPU0 CPU1
handle_mm_fault()
do_wp_page()
wp_page_copy()
do_wp_page()
madvise(MADV_DONTNEED)
zap_page_range()
zap_pte_range()
ptep_get_and_clear_full()
<TLB flush>
__copy_from_user_inatomic()
sees empty PTE and fails
WARN_ON_ONCE(1)
clear_page()The solution is to re-try __copy_from_user_inatomic() under PTL after checking that PTE is matches the orig_pte.
The second copy attempt can still fail, like due to non-readable PTE, but there's nothing reasonable we can do about, except clearing the CoW page.
--- mm/memory.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-)
mm/memory.c +27 -8
@@ -2163,7 +2163,7 @@ static inline bool cow_user_page(struct page *dst, struct page *src,bool ret;void *kaddr;void __user *uaddr; -bool force_mkyoung; +bool locked = false;struct vm_area_struct *vma = vmf->vma;struct mm_struct *mm = vma->vm_mm;unsigned long addr = vmf->address;
@@ -2188,11 +2188,11 @@ static inline bool cow_user_page(struct page *dst, struct page *src,* On architectures with software "accessed" bits, we would * take a double page fault, so mark it accessed here. */ - force_mkyoung =arch_faults_on_old_pte () && !pte_young (vmf->orig_pte); -if (force_mkyoung) { +if (arch_faults_on_old_pte () && !pte_young (vmf->orig_pte)) {pte_t entry; vmf->pte =pte_offset_map_lock (mm, vmf->pmd, addr, &vmf->ptl); + locked = true;if (!likely (pte_same (*vmf->pte, vmf->orig_pte))) {/* * Other thread has already handled the fault
@@ -2216,18 +2216,37 @@ static inline bool cow_user_page(struct page *dst, struct page *src,* zeroes. */ if (__copy_from_user_inatomic (kaddr, uaddr,PAGE_SIZE )) { +if (locked) + goto warn; + +/* Re-validate under PTL if the page is still mapped */ + vmf->pte =pte_offset_map_lock (mm, vmf->pmd, addr, &vmf->ptl); + locked = true; +if (!likely (pte_same (*vmf->pte, vmf->orig_pte))) { +/* The PTE changed under us. Retry page fault. */ + ret = false; + goto pte_unlock; + } +/* -* Give a warn in case there can be some obscure -* use-case +* The same page can be mapped back since last copy attampt. +* Try to copy again under PTL. */ -WARN_ON_ONCE (1 ); -clear_page (kaddr); +if (__copy_from_user_inatomic (kaddr, uaddr,PAGE_SIZE )) { +/* +* Give a warn in case there can be some obscure +* use-case +*/ +warn: +WARN_ON_ONCE (1 ); +clear_page (kaddr); + } } ret = true; pte_unlock: -if (force_mkyoung) +if (locked)pte_unmap_unlock (vmf->pte, vmf->ptl);kunmap_atomic (kaddr);flush_dcache_page (dst);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 122/388 crypto: chelsio - This fixes the kernel panic which occurs during a libkcapi test
In reply to Greg Kroah-HartmanFrom: Ayush Sawal <[email protected]>
[ Upstream commit 9195189e00a7db55e7d448cee973cae87c5a3c71 ]
The libkcapi test which causes kernel panic is
aead asynchronous vmsplice multiple test.
./bin/kcapi -v -d 4 -x 10 -c "ccm(aes)"
-q 4edb58e8d5eb6bc711c43a6f3693daebde2e5524f1b55297abb29f003236e43d -t a7877c99 -n 674742abd0f5ba -k 2861fd0253705d7875c95ba8a53171b4 -a fb7bc304a3909e66e2e0c5ef952712dd884ce3e7324171369f2c5db1adc48c7d
This patch avoids dma_mapping of a zero length sg which causes the panic, by using sg_nents_for_len which maps only upto a specific length
--- drivers/crypto/chelsio/chcr_algo.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/crypto/chelsio/chcr_algo.c +3 -2
@@ -2480,8 +2480,9 @@ int chcr_aead_dma_map(struct device *dev,else reqctx->b0_dma =0 ;if (req->src == req->dst) { - error =dma_map_sg (dev, req->src,sg_nents (req->src), -DMA_BIDIRECTIONAL ); + error =dma_map_sg (dev, req->src, +sg_nents_for_len (req->src, dst_size), +DMA_BIDIRECTIONAL );if (!error) goto err; }else {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 140/388 firmware: arm_sdei: Use cpus_read_lock() to avoid races with cpuhp
In reply to Greg Kroah-HartmanFrom: James Morse <[email protected]>
[ Upstream commit 54f529a6806c9710947a4f2cdc15d6ea54121ccd ]
SDEI has private events that need registering and enabling on each CPU. CPUs can come and go while we are trying to do this. SDEI tries to avoid these problems by setting the reregister flag before the register call, so any CPUs that come online register the event too. Sticking plaster like this doesn't work, as if the register call fails, a CPU that subsequently comes online will register the event before reregister is cleared.
Take cpus_read_lock() around the register and enable calls. We don't want surprise CPUs to do the wrong thing if they race with these calls failing.
--- drivers/firmware/arm_sdei.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
drivers/firmware/arm_sdei.c +14 -12
@@ -412,14 +412,19 @@ int sdei_event_enable(u32 event_num)return -ENOENT ; } -spin_lock (&sdei_list_lock); - event->reenable = true; -spin_unlock (&sdei_list_lock); +cpus_read_lock ();if (event->type ==SDEI_EVENT_TYPE_SHARED ) err =sdei_api_event_enable (event->event_num);else err =sdei_do_cross_call (_local_event_enable, event); + +if (!err) { +spin_lock (&sdei_list_lock); + event->reenable = true; +spin_unlock (&sdei_list_lock); + } +cpus_read_unlock ();mutex_unlock (&sdei_events_lock);return err;
@@ -621,21 +626,18 @@ int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg)break ; } -spin_lock (&sdei_list_lock); - event->reregister = true; -spin_unlock (&sdei_list_lock); - +cpus_read_lock (); err =_sdei_event_register (event);if (err) { -spin_lock (&sdei_list_lock); - event->reregister = false; - event->reenable = false; -spin_unlock (&sdei_list_lock); -sdei_event_destroy (event);pr_warn ("Failed to register event %u: %d\n" , event_num, err); + }else { +spin_lock (&sdei_list_lock); + event->reregister = true; +spin_unlock (&sdei_list_lock); } +cpus_read_unlock (); }while (0 );mutex_unlock (&sdei_events_lock);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 125/388 ALSA: usb-audio: Dont create a mixer element with bogus volume range
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
[ Upstream commit e9a0ef0b5ddcbc0d56c65aefc0f18d16e6f71207 ]
Some USB-audio descriptors provide a bogus volume range (e.g. volume min and max are identical), which confuses user-space. This patch makes the driver skipping such a control element.
--- sound/usb/mixer.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
sound/usb/mixer.c +10 -0
@@ -1684,6 +1684,16 @@ static void __build_feature_ctl(struct usb_mixer_interface *mixer,/* get min/max values */ get_min_max_with_quirks (cval,0 , kctl); +/* skip a bogus volume range */ +if (cval->max <= cval->min) { +usb_audio_dbg (mixer->chip, +"[%d] FU [%s] skipped due to invalid volume\n" , + cval->head.id, kctl->id.name); +snd_ctl_free_one (kctl); +return ; + } + +if (control ==UAC_FU_VOLUME ) {check_mapped_dB (map, cval);if (cval->dBmin < cval->dBmax || !cval->initialized) {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 146/388 timekeeping: Prevent 32bit truncation in scale64_check_overflow()
In reply to Greg Kroah-HartmanFrom: Wen Yang <[email protected]>
[ Upstream commit 4cbbc3a0eeed675449b1a4d080008927121f3da3 ]
While unlikely the divisor in scale64_check_overflow() could be >= 32bit in scale64_check_overflow(). do_div() truncates the divisor to 32bit at least on 32bit platforms.
Use div64_u64() instead to avoid the truncation to 32-bit.
[ tglx: Massaged changelog ]
--- kernel/time/timekeeping.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/time/timekeeping.c +1 -2
@@ -1005,9 +1005,8 @@ static int scale64_check_overflow(u64 mult, u64 div, u64 *base) ((int)sizeof(u64)*8 - fls64(mult) < fls64(rem))) return -EOVERFLOW; tmp *= mult; - rem *= mult; -do_div (rem, div); + rem =div64_u64 (rem * mult, div); *base = tmp + rem;return 0 ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 128/388 KVM: x86: fix incorrect comparison in trace event
In reply to Greg Kroah-HartmanFrom: Paolo Bonzini <[email protected]>
[ Upstream commit 147f1a1fe5d7e6b01b8df4d0cbd6f9eaf6b6c73b ]
The "u" field in the event has three states, -1/0/1. Using u8 however means that comparison with -1 will always fail, so change to signed char.
--- arch/x86/kvm/mmutrace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/mmutrace.h +1 -1
@@ -339,7 +339,7 @@ TRACE_EVENT(/* These depend on page entry type, so compute them now. */ __field(bool, r) __field(bool, x) -__field (u8, u) + __field(signed char, u) ), TP_fast_assign(
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 147/388 powerpc/book3s64: Fix error handling in mm_iommu_do_alloc()
In reply to Greg Kroah-HartmanFrom: Alexey Kardashevskiy <[email protected]>
[ Upstream commit c4b78169e3667413184c9a20e11b5832288a109f ]
The last jump to free_exit in mm_iommu_do_alloc() happens after page pointers in struct mm_iommu_table_group_mem_t were already converted to physical addresses. Thus calling put_page() on these physical addresses will likely crash.
This moves the loop which calculates the pageshift and converts page struct pointers to physical addresses later after the point when we cannot fail; thus eliminating the need to convert pointers back.
--- arch/powerpc/mm/book3s64/iommu_api.c | 39 +++++++++++++++------------- 1 file changed, 21 insertions(+), 18 deletions(-)
arch/powerpc/mm/book3s64/iommu_api.c +21 -18
@@ -121,24 +121,6 @@ static long mm_iommu_do_alloc(struct mm_struct *mm, unsigned long ua, goto free_exit; } - pageshift =PAGE_SHIFT ; -for (i =0 ; i < entries; ++i) { -struct page *page = mem->hpages[i]; - -/* -* Allow to use larger than 64k IOMMU pages. Only do that -* if we are backed by hugetlb. -*/ -if ((mem->pageshift >PAGE_SHIFT ) &&PageHuge (page)) - pageshift =page_shift (compound_head (page)); - mem->pageshift =min (mem->pageshift, pageshift); -/* -* We don't need struct page reference any more, switch -* to physical address. -*/ - mem->hpas[i] =page_to_pfn (page) <<PAGE_SHIFT ; - } - good_exit:atomic64_set (&mem->mapped,1 ); mem->used =1 ;
@@ -158,6 +140,27 @@ good_exit: } } +if (mem->dev_hpa ==MM_IOMMU_TABLE_INVALID_HPA ) { +/* +* Allow to use larger than 64k IOMMU pages. Only do that +* if we are backed by hugetlb. Skip device memory as it is not +* backed with page structs. +*/ + pageshift =PAGE_SHIFT ; +for (i =0 ; i < entries; ++i) { +struct page *page = mem->hpages[i]; + +if ((mem->pageshift >PAGE_SHIFT ) &&PageHuge (page)) + pageshift =page_shift (compound_head (page)); + mem->pageshift =min (mem->pageshift, pageshift); +/* +* We don't need struct page reference any more, switch +* to physical address. +*/ + mem->hpas[i] =page_to_pfn (page) <<PAGE_SHIFT ; + } + } +list_add_rcu (&mem->next, &mm->context.iommu_group_mem_list);mutex_unlock (&mem_list_mutex);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 130/388 dmaengine: stm32-mdma: use vchan_terminate_vdesc() in .terminate_all
In reply to Greg Kroah-HartmanFrom: Amelie Delaunay <[email protected]>
[ Upstream commit dfc708812a2acfc0ca56f56233b3c3e7b0d4ffe7 ]
To avoid race with vchan_complete, use the race free way to terminate running transfer.
Move vdesc->node list_del in stm32_mdma_start_transfer instead of in stm32_mdma_xfer_end to avoid another race in vchan_dma_desc_free_list.
--- drivers/dma/stm32-mdma.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/dma/stm32-mdma.c +6 -3
@@ -1127,6 +1127,8 @@ static void stm32_mdma_start_transfer(struct stm32_mdma_chan *chan)return ; } +list_del (&vdesc->node); + chan->desc =to_stm32_mdma_desc (vdesc); hwdesc = chan->desc->node[0 ].hwdesc; chan->curr_hwdesc =0 ;
@@ -1242,8 +1244,10 @@ static int stm32_mdma_terminate_all(struct dma_chan *c)LIST_HEAD (head);spin_lock_irqsave (&chan->vchan.lock, flags); -if (chan->busy) { -stm32_mdma_stop (chan); +if (chan->desc) { +vchan_terminate_vdesc (&chan->desc->vdesc); +if (chan->busy) +stm32_mdma_stop (chan); chan->desc =NULL ; }vchan_get_all_descriptors (&chan->vchan, &head);
@@ -1331,7 +1335,6 @@ static enum dma_status stm32_mdma_tx_status(struct dma_chan *c,static void stm32_mdma_xfer_end (struct stm32_mdma_chan *chan) { -list_del (&chan->desc->vdesc.node);vchan_cookie_complete (&chan->desc->vdesc); chan->desc =NULL ; chan->busy = false;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 121/388 clk: stratix10: use do_div() for 64-bit calculation
In reply to Greg Kroah-HartmanFrom: Dinh Nguyen <[email protected]>
[ Upstream commit cc26ed7be46c5f5fa45f3df8161ed7ca3c4d318c ]
do_div() macro to perform u64 division and guards against overflow if the result is too large for the unsigned long return type.
--- drivers/clk/socfpga/clk-pll-s10.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/socfpga/clk-pll-s10.c +3 -1
@@ -39,7 +39,9 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hwclk,/* read VCO1 reg for numerator and denominator */ reg =readl (socfpgaclk->hw.reg); refdiv = (reg &SOCFPGA_PLL_REFDIV_MASK ) >>SOCFPGA_PLL_REFDIV_SHIFT ; - vco_freq = (unsigned long long )parent_rate / refdiv; + + vco_freq = parent_rate; +do_div (vco_freq, refdiv);/* Read mdiv and fdiv from the fdbck register */ reg =readl (socfpgaclk->hw.reg +0x4 );
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 148/388 drm/amd/display: fix image corruption with ODM 2:1 DSC 2 slice
In reply to Greg Kroah-HartmanFrom: Wenjing Liu <[email protected]>
[ Upstream commit df8e34ac27e8a0d8dce364628226c5619693c3fd ]
[why]
When combining two or more pipes in DSC mode, there will always be more than 1 slice per line. In this case, as per DSC rules, the sink device is expecting that the ICH is reset at the end of each slice line (i.e. ICH_RESET_AT_END_OF_LINE must be configured based on the number of slices at the output of ODM). It is recommended that software set ICH_RESET_AT_END_OF_LINE = 0xF for each DSC in the ODM combine. However the current code only set ICH_RESET_AT_END_OF_LINE = 0xF when number of slice per DSC engine is greater than 1 instead of number of slice per output after ODM combine.
[how]
Add is_odm in dsc config. Set ICH_RESET_AT_END_OF_LINE = 0xF if either is_odm or number of slice per DSC engine is greater than 1.
--- drivers/gpu/drm/amd/display/dc/core/dc_link_hwss.c | 2 ++ drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c | 2 +- drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c | 1 + drivers/gpu/drm/amd/display/dc/inc/hw/dsc.h | 1 + 4 files changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_link_hwss.c +2 -0
@@ -400,6 +400,7 @@ void dp_set_dsc_on_stream(struct pipe_ctx *pipe_ctx, bool enable) dsc_cfg.pic_height = stream->timing.v_addressable + stream->timing.v_border_top + stream->timing.v_border_bottom; dsc_cfg.pixel_encoding = stream->timing.pixel_encoding; dsc_cfg.color_depth = stream->timing.display_color_depth; + dsc_cfg.is_odm = pipe_ctx->next_odm_pipe ? true : false; dsc_cfg.dc_dsc_cfg = stream->timing.dsc_cfg;ASSERT (dsc_cfg.dc_dsc_cfg.num_slices_h % opp_cnt ==0 ); dsc_cfg.dc_dsc_cfg.num_slices_h /= opp_cnt;
@@ -504,6 +505,7 @@ bool dp_set_dsc_pps_sdp(struct pipe_ctx *pipe_ctx, bool enable) dsc_cfg.pic_height = stream->timing.v_addressable + stream->timing.v_border_top + stream->timing.v_border_bottom; dsc_cfg.pixel_encoding = stream->timing.pixel_encoding; dsc_cfg.color_depth = stream->timing.display_color_depth; + dsc_cfg.is_odm = pipe_ctx->next_odm_pipe ? true : false; dsc_cfg.dc_dsc_cfg = stream->timing.dsc_cfg;DC_LOG_DSC (" " );
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c +1 -1
@@ -351,6 +351,7 @@ static bool dsc_prepare_config(const struct dsc_config *dsc_cfg, struct dsc_reg_ dsc_reg_vals->pps.block_pred_enable = dsc_cfg->dc_dsc_cfg.block_pred_enable; dsc_reg_vals->pps.line_buf_depth = dsc_cfg->dc_dsc_cfg.linebuf_depth; dsc_reg_vals->alternate_ich_encoding_en = dsc_reg_vals->pps.dsc_version_minor ==1 ?0 :1 ; + dsc_reg_vals->ich_reset_at_eol = (dsc_cfg->is_odm || dsc_reg_vals->num_slices_h >1 ) ?0xF :0 ;// TODO: in addition to validating slice height (pic height must be divisible by slice height), // see what happens when the same condition doesn't apply for slice_width/pic_width.
@@ -513,7 +514,6 @@ static void dsc_update_from_dsc_parameters(struct dsc_reg_values *reg_vals, cons reg_vals->pps.rc_buf_thresh[i] = reg_vals->pps.rc_buf_thresh[i] >>6 ; reg_vals->rc_buffer_model_size = dsc_params->rc_buffer_model_size; - reg_vals->ich_reset_at_eol = reg_vals->num_slices_h ==1 ?0 :0xf ; }static void dsc_write_to_registers (struct display_stream_compressor *dsc,const struct dsc_reg_values *reg_vals)
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c +1 -0
@@ -2275,6 +2275,7 @@ static bool dcn20_validate_dsc(struct dc *dc, struct dc_state *new_ctx) + stream->timing.v_border_bottom; dsc_cfg.pixel_encoding = stream->timing.pixel_encoding; dsc_cfg.color_depth = stream->timing.display_color_depth; + dsc_cfg.is_odm = pipe_ctx->next_odm_pipe ? true : false; dsc_cfg.dc_dsc_cfg = stream->timing.dsc_cfg; dsc_cfg.dc_dsc_cfg.num_slices_h /= opp_cnt;
drivers/gpu/drm/amd/display/dc/inc/hw/dsc.h +1 -0
@@ -36,6 +36,7 @@ struct dsc_config {uint32_t pic_height;enum dc_pixel_encoding pixel_encoding;enum dc_color_depth color_depth;/* Bits per component */ +bool is_odm;struct dc_dsc_config dc_dsc_cfg; };
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 150/388 perf jevents: Fix leak of mapfile memory
In reply to Greg Kroah-HartmanFrom: John Garry <[email protected]>
[ Upstream commit 3f5777fbaf04c58d940526a22a2e0c813c837936 ]
The memory for global pointer is never freed during normal program execution, so let's do that in the main function exit as a good programming practice.
A stray blank line is also removed.
--- tools/perf/pmu-events/jevents.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
tools/perf/pmu-events/jevents.c +9 -6
@@ -1068,10 +1068,9 @@ static int process_one_file(const char *fpath, const struct stat *sb,*/ int main (int argc,char *argv[]) { -int rc; +int rc, ret =0 ;int maxfds;char ldirname[PATH_MAX ]; -const char *arch;const char *output_file;const char *start_dirname;
@@ -1142,7 +1141,8 @@ int main(int argc, char *argv[])/* Make build fail */ fclose (eventsfp);free_arch_std_events (); -return 1 ; + ret =1 ; + goto out_free_mapfile; }else if (rc) { goto empty_map; }
@@ -1160,14 +1160,17 @@ int main(int argc, char *argv[])/* Make build fail */ fclose (eventsfp);free_arch_std_events (); -return 1 ; + ret =1 ; } -return 0 ; + + goto out_free_mapfile; empty_map:fclose (eventsfp);create_empty_mapping (output_file);free_arch_std_events (); -return 0 ; +out_free_mapfile: +free (mapfile); +return ret; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 143/388 ASoC: SOF: ipc: check ipc return value before data copy
In reply to Greg Kroah-HartmanFrom: Jaska Uimonen <[email protected]>
[ Upstream commit 1919b42ca4ad75a2397081164661af3ce5a7b8f4 ]
In tx_wait_done the ipc payload is copied before the DSP transaction error code is checked. This might lead to corrupted data in kernel side even though the error would be handled later. It is also pointless to copy the data in case of error. So change the order of error check and copy.
--- sound/soc/sof/ipc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
sound/soc/sof/ipc.c +7 -5
@@ -215,15 +215,17 @@ static int tx_wait_done(struct snd_sof_ipc *ipc, struct snd_sof_ipc_msg *msg,snd_sof_trace_notify_for_error (ipc->sdev); ret = -ETIMEDOUT ; }else { -/* copy the data returned from DSP */ ret = msg->reply_error; -if (msg->reply_size) -memcpy (reply_data, msg->reply_data, msg->reply_size); -if (ret <0 ) +if (ret <0 ) {dev_err (sdev->dev,"error: ipc error for 0x%x size %zu\n" , hdr->cmd, msg->reply_size); -else + }else {ipc_log_header (sdev->dev,"ipc tx succeeded" , hdr->cmd); +if (msg->reply_size) +/* copy the data returned from DSP */ +memcpy (reply_data, msg->reply_data, + msg->reply_size); + } }return ret;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 145/388 Bluetooth: guard against controllers sending zerod events
In reply to Greg Kroah-HartmanFrom: Alain Michaud <[email protected]>
[ Upstream commit 08bb4da90150e2a225f35e0f642cdc463958d696 ]
Some controllers have been observed to send zero'd events under some conditions. This change guards against this condition as well as adding a trace to facilitate diagnosability of this condition.
--- net/bluetooth/hci_event.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/bluetooth/hci_event.c +6 -0
@@ -5853,6 +5853,11 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)u8 status =0 , event = hdr->evt, req_evt =0 ;u16 opcode =HCI_OP_NOP ; +if (!event) { +bt_dev_warn (hdev,"Received unexpected HCI Event 00000000" ); + goto done; + } +if (hdev->sent_cmd &&bt_cb (hdev->sent_cmd)->hci.req_event == event) {struct hci_command_hdr *cmd_hdr = (void *) hdev->sent_cmd->data; opcode =__le16_to_cpu (cmd_hdr->opcode);
@@ -6064,6 +6069,7 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)req_complete_skb (hdev, status, opcode, orig_skb); } +done:kfree_skb (orig_skb);kfree_skb (skb); hdev->stat.evt_rx++;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 93/388 btrfs: tree-checker: Check leaf chunk item size
In reply to Greg Kroah-HartmanFrom: Qu Wenruo <[email protected]>
[ Upstream commit f6d2a5c263afca84646cf3300dc13061bedbd99e ]
Inspired by btrfs-progs github issue #208, where chunk item in chunk tree has invalid num_stripes (0).
Although that can already be caught by current btrfs_check_chunk_valid(), that function doesn't really check item size as it needs to handle chunk item in super block sys_chunk_array().
This patch will add two extra checks for chunk items in chunk tree:
- Basic chunk item size
If the item is smaller than btrfs_chunk (which already contains one stripe), exit right now as reading num_stripes may even go beyond eb boundary.
- Item size check against num_stripes
If item size doesn't match with calculated chunk size, then either the item size or the num_stripes is corrupted. Error out anyway.
--- fs/btrfs/tree-checker.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-)
fs/btrfs/tree-checker.c +39 -1
@@ -674,6 +674,44 @@ int btrfs_check_chunk_valid(struct extent_buffer *leaf,return 0 ; } +/* +* Enhanced version of chunk item checker. +* +* The common btrfs_check_chunk_valid() doesn't check item size since it needs +* to work on super block sys_chunk_array which doesn't have full item ptr. +*/ +static int check_leaf_chunk_item (struct extent_buffer *leaf, +struct btrfs_chunk *chunk, +struct btrfs_key *key,int slot) +{ +int num_stripes; + +if (btrfs_item_size_nr (leaf, slot) <sizeof (struct btrfs_chunk )) { +chunk_err (leaf, chunk, key->offset, +"invalid chunk item size: have %u expect [%zu, %u)" , +btrfs_item_size_nr (leaf, slot), +sizeof (struct btrfs_chunk ), +BTRFS_LEAF_DATA_SIZE (leaf->fs_info)); +return -EUCLEAN ; + } + + num_stripes =btrfs_chunk_num_stripes (leaf, chunk); +/* Let btrfs_check_chunk_valid() handle this error type */ +if (num_stripes ==0 ) + goto out; + +if (btrfs_chunk_item_size (num_stripes) != +btrfs_item_size_nr (leaf, slot)) { +chunk_err (leaf, chunk, key->offset, +"invalid chunk item size: have %u expect %lu" , +btrfs_item_size_nr (leaf, slot), +btrfs_chunk_item_size (num_stripes)); +return -EUCLEAN ; + } +out: +return btrfs_check_chunk_valid (leaf, chunk, key->offset); +} + __printf(3, 4)__cold static void dev_item_err(const struct extent_buffer *eb, int slot,
@@ -1265,7 +1303,7 @@ static int check_leaf_item(struct extent_buffer *leaf,break ;case BTRFS_CHUNK_ITEM_KEY : chunk = btrfs_item_ptr(leaf, slot, struct btrfs_chunk); - ret =btrfs_check_chunk_valid (leaf, chunk, key->offset); + ret =check_leaf_chunk_item (leaf, chunk, key, slot);break ;case BTRFS_DEV_ITEM_KEY : ret =check_dev_item (leaf, key, slot);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 138/388 drm/omap: dss: Cleanup DSS ports on initialisation failure
In reply to Greg Kroah-HartmanFrom: Laurent Pinchart <[email protected]>
[ Upstream commit 2a0a3ae17d36fa86dcf7c8e8d7b7f056ebd6c064 ]
When the DSS initialises its output DPI and SDI ports, failures don't clean up previous successfully initialised ports. This can lead to resource leak or memory corruption. Fix it.
--- drivers/gpu/drm/omapdrm/dss/dss.c | 43 +++++++++++++++++++------------ 1 file changed, 26 insertions(+), 17 deletions(-)
drivers/gpu/drm/omapdrm/dss/dss.c +26 -17
@@ -1151,46 +1151,38 @@ static const struct dss_features dra7xx_dss_feats = { .has_lcd_clk_src = true, }; -static int dss_init_ports (struct dss_device *dss) +static void __dss_uninit_ports (struct dss_device *dss,unsigned int num_ports) {struct platform_device *pdev = dss->pdev;struct device_node *parent = pdev->dev.of_node;struct device_node *port;unsigned int i; -int r; -for (i =0 ; i < dss->feat->num_ports; i++) { +for (i =0 ; i < num_ports; i++) { port =of_graph_get_port_by_id (parent, i);if (!port)continue ;switch (dss->feat->ports[i]) {case OMAP_DISPLAY_TYPE_DPI : - r =dpi_init_port (dss, pdev, port, dss->feat->model); -if (r) -return r; +dpi_uninit_port (port);break ; -case OMAP_DISPLAY_TYPE_SDI : - r =sdi_init_port (dss, pdev, port); -if (r) -return r; +sdi_uninit_port (port);break ; -default :break ; } } - -return 0 ; } -static void dss_uninit_ports (struct dss_device *dss) +static int dss_init_ports (struct dss_device *dss) {struct platform_device *pdev = dss->pdev;struct device_node *parent = pdev->dev.of_node;struct device_node *port; -int i; +unsigned int i; +int r;for (i =0 ; i < dss->feat->num_ports; i++) { port =of_graph_get_port_by_id (parent, i);
@@ -1199,15 +1191,32 @@ static void dss_uninit_ports(struct dss_device *dss)switch (dss->feat->ports[i]) {case OMAP_DISPLAY_TYPE_DPI : -dpi_uninit_port (port); + r =dpi_init_port (dss, pdev, port, dss->feat->model); +if (r) + goto error;break ; +case OMAP_DISPLAY_TYPE_SDI : -sdi_uninit_port (port); + r =sdi_init_port (dss, pdev, port); +if (r) + goto error;break ; +default :break ; } } + +return 0 ; + +error: +__dss_uninit_ports (dss, i); +return r; +} + +static void dss_uninit_ports (struct dss_device *dss) +{ +__dss_uninit_ports (dss, dss->feat->num_ports); }static int dss_video_pll_probe (struct dss_device *dss)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 149/388 ext4: fix a data race at inode->i_disksize
In reply to Greg Kroah-HartmanFrom: Qiujun Huang <[email protected]>
[ Upstream commit dce8e237100f60c28cc66effb526ba65a01d8cb3 ]
KCSAN find inode->i_disksize could be accessed concurrently.
BUG: KCSAN: data-race in ext4_mark_iloc_dirty / ext4_write_end
write (marked) to 0xffff8b8932f40090 of 8 bytes by task 66792 on cpu 0:
ext4_write_end+0x53f/0x5b0 ext4_da_write_end+0x237/0x510 generic_perform_write+0x1c4/0x2a0 ext4_buffered_write_iter+0x13a/0x210 ext4_file_write_iter+0xe2/0x9b0 new_sync_write+0x29c/0x3a0 __vfs_write+0x92/0xa0 vfs_write+0xfc/0x2a0 ksys_write+0xe8/0x140 __x64_sys_write+0x4c/0x60 do_syscall_64+0x8a/0x2a0 entry_SYSCALL_64_after_hwframe+0x44/0xa9
read to 0xffff8b8932f40090 of 8 bytes by task 14414 on cpu 1:
ext4_mark_iloc_dirty+0x716/0x1190 ext4_mark_inode_dirty+0xc9/0x360 ext4_convert_unwritten_extents+0x1bc/0x2a0 ext4_convert_unwritten_io_end_vec+0xc5/0x150 ext4_put_io_end+0x82/0x130 ext4_writepages+0xae7/0x16f0 do_writepages+0x64/0x120 __writeback_single_inode+0x7d/0x650 writeback_sb_inodes+0x3a4/0x860 __writeback_inodes_wb+0xc4/0x150 wb_writeback+0x43f/0x510 wb_workfn+0x3b2/0x8a0 process_one_work+0x39b/0x7e0 worker_thread+0x88/0x650 kthread+0x1d4/0x1f0 ret_from_fork+0x35/0x40
The plain read is outside of inode->i_data_sem critical section which results in a data race. Fix it by adding READ_ONCE().
--- fs/ext4/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/inode.c +1 -1
@@ -5315,7 +5315,7 @@ static int ext4_do_update_inode(handle_t *handle, raw_inode->i_file_acl_high =cpu_to_le16 (ei->i_file_acl >>32 ); raw_inode->i_file_acl_lo =cpu_to_le32 (ei->i_file_acl); -if (ei->i_disksize !=ext4_isize (inode->i_sb, raw_inode)) { +if (READ_ONCE (ei->i_disksize) !=ext4_isize (inode->i_sb, raw_inode)) {ext4_isize_set (raw_inode, ei->i_disksize); need_datasync =1 ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 144/388 media: go7007: Fix URB type for interrupt handling
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
[ Upstream commit a3ea410cac41b19a5490aad7fe6d9a9a772e646e ]
Josef reported that his old-and-good Plextor ConvertX M402U video converter spews lots of WARNINGs on the recent kernels, and it turned out that the device uses a bulk endpoint for interrupt handling just like 2250 board.
For fixing it, generalize the check with the proper verification of the endpoint instead of hard-coded board type check.
--- drivers/media/usb/go7007/go7007-usb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/usb/go7007/go7007-usb.c +3 -1
@@ -1044,6 +1044,7 @@ static int go7007_usb_probe(struct usb_interface *intf,struct go7007_usb *usb;const struct go7007_usb_board *board;struct usb_device *usbdev =interface_to_usbdev (intf); +struct usb_host_endpoint *ep;unsigned num_i2c_devs;char *name;int video_pipe, i, v_urb_len;
@@ -1140,7 +1141,8 @@ static int go7007_usb_probe(struct usb_interface *intf,if (usb->intr_urb->transfer_buffer ==NULL ) goto allocfail; -if (go->board_id ==GO7007_BOARDID_SENSORAY_2250 ) + ep = usb->usbdev->ep_in[4 ]; +if (usb_endpoint_type (&ep->desc) ==USB_ENDPOINT_XFER_BULK ) usb_fill_bulk_urb(usb->intr_urb, usb->usbdev, usb_rcvbulkpipe(usb->usbdev, 4), usb->intr_urb->transfer_buffer, 2*sizeof(u16),
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 137/388 drm/amd/display: dal_ddc_i2c_payloads_create can fail causing panic
In reply to Greg Kroah-HartmanFrom: Aric Cyr <[email protected]>
[ Upstream commit 6a6c4a4d459ecacc9013c45dcbf2bc9747fdbdbd ]
[Why]
Since the i2c payload allocation can fail need to check return codes
[How]
Clean up i2c payload allocations and check for errors
--- .../gpu/drm/amd/display/dc/core/dc_link_ddc.c | 52 +++++++++---------- 1 file changed, 25 insertions(+), 27 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c +25 -27
@@ -126,22 +126,16 @@ struct aux_payloads {struct vector payloads; }; -static struct i2c_payloads *dal_ddc_i2c_payloads_create (struct dc_context *ctx,uint32_t count) +static bool dal_ddc_i2c_payloads_create ( +struct dc_context *ctx, +struct i2c_payloads *payloads, +uint32_t count) { -struct i2c_payloads *payloads; - - payloads =kzalloc (sizeof (struct i2c_payloads ),GFP_KERNEL ); - -if (!payloads) -return NULL ; -if (dal_vector_construct ( &payloads->payloads, ctx, count,sizeof (struct i2c_payload ))) -return payloads; - -kfree (payloads); -return NULL ; +return true; +return false; }static struct i2c_payload *dal_ddc_i2c_payloads_get (struct i2c_payloads *p)
@@ -154,14 +148,12 @@ static uint32_t dal_ddc_i2c_payloads_get_count(struct i2c_payloads *p)return p->payloads.count; } -static void dal_ddc_i2c_payloads_destroy (struct i2c_payloads **p) +static void dal_ddc_i2c_payloads_destroy (struct i2c_payloads *p) { -if (!p || !*p) +if (!p)return ; -dal_vector_destruct (&(*p)->payloads); -kfree (*p); - *p =NULL ; +dal_vector_destruct (&p->payloads); }#define DDC_MIN (a, b) (((a) < (b)) ? (a) : (b))
@@ -521,9 +513,13 @@ bool dal_ddc_service_query_ddc_data(uint32_t payloads_num = write_payloads + read_payloads; +if (write_size >EDID_SEGMENT_SIZE || read_size >EDID_SEGMENT_SIZE )return false; +if (!payloads_num) +return false; +/*TODO: len of payload data for i2c and aux is uint8!!!!, * but we want to read 256 over i2c!!!!*/ if (dal_ddc_service_is_in_aux_transaction_mode (ddc)) {
@@ -556,23 +552,25 @@ bool dal_ddc_service_query_ddc_data( ret =dc_link_aux_transfer_with_retries (ddc, &read_payload); }else { -struct i2c_payloads *payloads = -dal_ddc_i2c_payloads_create (ddc->ctx, payloads_num); +struct i2c_command command = {0 }; +struct i2c_payloads payloads; + +if (!dal_ddc_i2c_payloads_create (ddc->ctx, &payloads, payloads_num)) +return false; -struct i2c_command command = { - .payloads =dal_ddc_i2c_payloads_get (payloads), - .number_of_payloads =0 , - .engine =DDC_I2C_COMMAND_ENGINE , - .speed = ddc->ctx->dc->caps.i2c_speed_in_khz }; + command.payloads =dal_ddc_i2c_payloads_get (&payloads); + command.number_of_payloads =0 ; + command.engine =DDC_I2C_COMMAND_ENGINE ; + command.speed = ddc->ctx->dc->caps.i2c_speed_in_khz;dal_ddc_i2c_payloads_add ( - payloads, address, write_size, write_buf, true); + &payloads, address, write_size, write_buf, true);dal_ddc_i2c_payloads_add ( - payloads, address, read_size, read_buf, false); + &payloads, address, read_size, read_buf, false); command.number_of_payloads = -dal_ddc_i2c_payloads_get_count (payloads); +dal_ddc_i2c_payloads_get_count (&payloads); ret = dm_helpers_submit_i2c( ddc->ctx,
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 131/388 media: staging/imx: Missing assignment in imx_media_capture_device_register()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit ef0ed05dcef8a74178a8b480cce23a377b1de2b8 ]
There was supposed to be a "ret = " assignment here, otherwise the error handling on the next line won't work.
--- drivers/staging/media/imx/imx-media-capture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/imx/imx-media-capture.c +1 -1
@@ -785,7 +785,7 @@ int imx_media_capture_device_register(struct imx_media_video_dev *vdev)/* setup default format */ fmt_src.pad = priv->src_sd_pad; fmt_src.which =V4L2_SUBDEV_FORMAT_ACTIVE ; -v4l2_subdev_call (sd, pad, get_fmt,NULL , &fmt_src); + ret =v4l2_subdev_call (sd, pad, get_fmt,NULL , &fmt_src);if (ret) {v4l2_err (sd,"failed to get src_sd format\n" ); goto unreg;
Signature · 1 line
2.25.1