1. 22 Nov, 2019 5 commits
  2. 20 Nov, 2019 6 commits
  3. 19 Nov, 2019 3 commits
    • Kuninori Morimoto's avatar
      ASoC: soc-pcm: remove soc_pcm_private_free() · 0ced7b05
      Kuninori Morimoto authored
      soc-topology adds extra dai_link by using snd_soc_add_dai_link(),
      and removes it by snd_soc_romove_dai_link().
      
      This snd_soc_add/remove_dai_link() and/or its related
      functions are unbalanced before, and now, these are balance-uped.
      But, it finds the random operation issue, and it is reported by
      Pierre-Louis.
      
      When card was released, topology will call snd_soc_remove_dai_link()
      via (A).
      
      	static void soc_cleanup_card_resources(struct snd_soc_card *card)
      	{
      		struct snd_soc_dai_link *link, *_link;
      
      		/* This should be called before snd_card_free() */
      	(A)	soc_remove_link_components(card);
      
      		/* free the ALSA card at first; this syncs with pending operations */
      		if (card->snd_card) {
      	(B)		snd_card_free(card->snd_card);
      			card->snd_card = NULL;
      		}
      
      		/* remove and free each DAI */
      	(X)	soc_remove_link_dais(card);
      
      		for_each_card_links_safe(card, link, _link)
      	(C)		snd_soc_remove_dai_link(card, link);
      
      		...
      	}
      
      At (A), topology calls snd_soc_remove_dai_link().
      Then topology rtd, and its related all data are freed.
      
      Next, (B) is called, and then, pcm->private_free = soc_pcm_private_free()
      is called.
      
      	static void soc_pcm_private_free(struct snd_pcm *pcm)
      	{
      		struct snd_soc_pcm_runtime *rtd = pcm->private_data;
      
      		/* need to sync the delayed work before releasing resources */
      		flush_delayed_work(&rtd->delayed_work);
      		snd_soc_pcm_component_free(rtd);
      	}
      
      Here, it gets rtd via pcm->private_data.
      But, topology related rtd are already freed at (A).
      Normal sound card has no damage, becase it frees rtd at (C).
      
      These are finalizing rtd related data.
      Thus, these should be called when rtd was freed, not sound card
      was freed. It is very natural and understandable.
      
      In other words, pcm->private_free = soc_pcm_private_free()
      is no longer needed.
      
      Extra issue is that there is zero chance to call
      soc_remove_dai() for topology related dai at (X).
      Because (A) removes rtd connection from card too, and,
      (X) is based on card connected rtd.
      
      This means, (X) need to be called before (C) (= for normal sound)
      and (A) (= for topology).
      
      Now, I want to focus this patch which is the reason why
      snd_card_free() = (B) is located there.
      
      	commit 4efda5f2
      	("ASoC: Fix use-after-free at card unregistration")
      
      Original snd_card_free() was called last of this function.
      But moved to top to avoid use-after-free issue.
      The issue was happen at soc_pcm_free() which was pcm->private_free,
      today it is updated/renamed to soc_pcm_private_free().
      
      In other words, (B) need to be called before (C) (= for normal sound)
      and (A) (= for topology), because it needs (not yet freed) rtd.
      But, (A) need to be called before (B),
      because it needs card->snd_card pointer.
      
      If we call flush_delayed_work() and snd_soc_pcm_component_free()
      (= same as soc_pcm_private_free()) when rtd was freed (= (C), (A)),
      there is no reason to call snd_card_free() at top of this function.
      It can be called end of this function, again.
      
      But, in such case, it will likely break unbind again, as Takashi-san
      reported. When unbind is performed in a busy state, the code may
      release still-in-use resources.
      At least we need to call snd_card_disconnect_sync() at the first place.
      
      The final code will be...
      
      	static void soc_cleanup_card_resources(struct snd_soc_card *card)
      	{
      		struct snd_soc_dai_link *link, *_link;
      
      		if (card->snd_card)
      	(Z)		snd_card_disconnect_sync(card->snd_card);
      
      	(X)	soc_remove_link_dais(card);
      	(A)	soc_remove_link_components(card);
      
      		for_each_card_links_safe(card, link, _link)
      	(C)		snd_soc_remove_dai_link(card, link);
      
      		...
      		if (card->snd_card) {
      	(B)		snd_card_free(card->snd_card);
      			card->snd_card = NULL;
      		}
      	}
      
      To avoid release still-in-use resources,
      call snd_card_disconnect_sync() at (Z).
      
      (X) is needed for both non-topology and topology.
      
          topology removes rtd via (A), and
      non topology removes rtd via (C).
      
      snd_card_free() is no longer related to use-after-free issue.
      Thus, locating (B) is no problem.
      
      Fixes: df95a16d ("ASoC: soc-core: fix RIP warning on card removal")
      Fixes: bc7a9091 ("ASoC: soc-core: add soc_unbind_dai_link()")
      Reported-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
      Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
      Tested-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
      Link: https://lore.kernel.org/r/87o8xax88g.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      0ced7b05
    • Kuninori Morimoto's avatar
      ASoC: soc-component: tidyup snd_soc_pcm_component_new/free() parameter · b2b2afbb
      Kuninori Morimoto authored
      This patch uses rtd instead of pcm at snd_soc_pcm_component_new/free()
      parameter.
      This is prepare for dai_link remove bug fix on topology.
      Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
      Link: https://lore.kernel.org/r/87pnhqx89j.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      b2b2afbb
    • Hans de Goede's avatar
      ASoC: Intel: bytcr_rt5640: Update quirk for Acer Switch 10 SW5-012 2-in-1 · 0bb88770
      Hans de Goede authored
      When the Acer Switch 10 SW5-012 quirk was added we did not have
      jack-detection support yet; and the builtin microphone selection of
      the original quirk is wrong too.
      
      Fix the microphone-input quirk and add jack-detection info so that the
      internal-microphone and headphone/set jack on the Switch 10 work properly.
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Acked-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
      Link: https://lore.kernel.org/r/20191119145138.59162-1-hdegoede@redhat.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      0bb88770
  4. 18 Nov, 2019 13 commits
  5. 17 Nov, 2019 8 commits
  6. 16 Nov, 2019 5 commits
    • Linus Torvalds's avatar
      Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 5ffaf037
      Linus Torvalds authored
      Pull perf fixes from Ingo Molnar:
       "Misc fixes: a handful of AUX event handling related fixes, a Sparse
        fix and two ABI fixes"
      
      * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        perf/core: Fix missing static inline on perf_cgroup_switch()
        perf/core: Consistently fail fork on allocation failures
        perf/aux: Disallow aux_output for kernel events
        perf/core: Reattach a misplaced comment
        perf/aux: Fix the aux_output group inheritance fix
        perf/core: Disallow uncore-cgroup events
      5ffaf037
    • Linus Torvalds's avatar
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net · 8be636dd
      Linus Torvalds authored
      Pull networking fixes from David Miller:
      
       1) Fix memory leak in xfrm_state code, from Steffen Klassert.
      
       2) Fix races between devlink reload operations and device
          setup/cleanup, from Jiri Pirko.
      
       3) Null deref in NFC code, from Stephan Gerhold.
      
       4) Refcount fixes in SMC, from Ursula Braun.
      
       5) Memory leak in slcan open error paths, from Jouni Hogander.
      
       6) Fix ETS bandwidth validation in hns3, from Yonglong Liu.
      
       7) Info leak on short USB request answers in ax88172a driver, from
          Oliver Neukum.
      
       8) Release mem region properly in ep93xx_eth, from Chuhong Yuan.
      
       9) PTP config timestamp flags validation, from Richard Cochran.
      
      10) Dangling pointers after SKB data realloc in seg6, from Andrea Mayer.
      
      11) Missing free_netdev() in gemini driver, from Chuhong Yuan.
      
      * git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (56 commits)
        ipmr: Fix skb headroom in ipmr_get_route().
        net: hns3: cleanup of stray struct hns3_link_mode_mapping
        net/smc: fix fastopen for non-blocking connect()
        rds: ib: update WR sizes when bringing up connection
        net: gemini: add missed free_netdev
        net: dsa: tag_8021q: Fix dsa_8021q_restore_pvid for an absent pvid
        seg6: fix skb transport_header after decap_and_validate()
        seg6: fix srh pointer in get_srh()
        net: stmmac: Use the correct style for SPDX License Identifier
        octeontx2-af: Use the correct style for SPDX License Identifier
        ptp: Extend the test program to check the external time stamp flags.
        mlx5: Reject requests to enable time stamping on both edges.
        igb: Reject requests that fail to enable time stamping on both edges.
        dp83640: Reject requests to enable time stamping on both edges.
        mv88e6xxx: Reject requests to enable time stamping on both edges.
        ptp: Introduce strict checking of external time stamp options.
        renesas: reject unsupported external timestamp flags
        mlx5: reject unsupported external timestamp flags
        igb: reject unsupported external timestamp flags
        dp83640: reject unsupported external timestamp flags
        ...
      8be636dd
    • Guillaume Nault's avatar
      ipmr: Fix skb headroom in ipmr_get_route(). · 7901cd97
      Guillaume Nault authored
      In route.c, inet_rtm_getroute_build_skb() creates an skb with no
      headroom. This skb is then used by inet_rtm_getroute() which may pass
      it to rt_fill_info() and, from there, to ipmr_get_route(). The later
      might try to reuse this skb by cloning it and prepending an IPv4
      header. But since the original skb has no headroom, skb_push() triggers
      skb_under_panic():
      
      skbuff: skb_under_panic: text:00000000ca46ad8a len:80 put:20 head:00000000cd28494e data:000000009366fd6b tail:0x3c end:0xec0 dev:veth0
      ------------[ cut here ]------------
      kernel BUG at net/core/skbuff.c:108!
      invalid opcode: 0000 [#1] SMP KASAN PTI
      CPU: 6 PID: 587 Comm: ip Not tainted 5.4.0-rc6+ #1
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-2.fc30 04/01/2014
      RIP: 0010:skb_panic+0xbf/0xd0
      Code: 41 a2 ff 8b 4b 70 4c 8b 4d d0 48 c7 c7 20 76 f5 8b 44 8b 45 bc 48 8b 55 c0 48 8b 75 c8 41 54 41 57 41 56 41 55 e8 75 dc 7a ff <0f> 0b 0f 1f 44 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00
      RSP: 0018:ffff888059ddf0b0 EFLAGS: 00010286
      RAX: 0000000000000086 RBX: ffff888060a315c0 RCX: ffffffff8abe4822
      RDX: 0000000000000000 RSI: 0000000000000008 RDI: ffff88806c9a79cc
      RBP: ffff888059ddf118 R08: ffffed100d9361b1 R09: ffffed100d9361b0
      R10: ffff88805c68aee3 R11: ffffed100d9361b1 R12: ffff88805d218000
      R13: ffff88805c689fec R14: 000000000000003c R15: 0000000000000ec0
      FS:  00007f6af184b700(0000) GS:ffff88806c980000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007ffc8204a000 CR3: 0000000057b40006 CR4: 0000000000360ee0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       skb_push+0x7e/0x80
       ipmr_get_route+0x459/0x6fa
       rt_fill_info+0x692/0x9f0
       inet_rtm_getroute+0xd26/0xf20
       rtnetlink_rcv_msg+0x45d/0x630
       netlink_rcv_skb+0x1a5/0x220
       rtnetlink_rcv+0x15/0x20
       netlink_unicast+0x305/0x3a0
       netlink_sendmsg+0x575/0x730
       sock_sendmsg+0xb5/0xc0
       ___sys_sendmsg+0x497/0x4f0
       __sys_sendmsg+0xcb/0x150
       __x64_sys_sendmsg+0x48/0x50
       do_syscall_64+0xd2/0xac0
       entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
      Actually the original skb used to have enough headroom, but the
      reserve_skb() call was lost with the introduction of
      inet_rtm_getroute_build_skb() by commit 404eb77e ("ipv4: support
      sport, dport and ip_proto in RTM_GETROUTE").
      
      We could reserve some headroom again in inet_rtm_getroute_build_skb(),
      but this function shouldn't be responsible for handling the special
      case of ipmr_get_route(). Let's handle that directly in
      ipmr_get_route() by calling skb_realloc_headroom() instead of
      skb_clone().
      
      Fixes: 404eb77e ("ipv4: support sport, dport and ip_proto in RTM_GETROUTE")
      Signed-off-by: default avatarGuillaume Nault <gnault@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7901cd97
    • Salil Mehta's avatar
      net: hns3: cleanup of stray struct hns3_link_mode_mapping · b696083d
      Salil Mehta authored
      This patch cleans-up the stray left over code. It has no
      functionality impact.
      Signed-off-by: default avatarSalil Mehta <salil.mehta@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b696083d
    • Ursula Braun's avatar
      net/smc: fix fastopen for non-blocking connect() · 8204df72
      Ursula Braun authored
      FASTOPEN does not work with SMC-sockets. Since SMC allows fallback to
      TCP native during connection start, the FASTOPEN setsockopts trigger
      this fallback, if the SMC-socket is still in state SMC_INIT.
      But if a FASTOPEN setsockopt is called after a non-blocking connect(),
      this is broken, and fallback does not make sense.
      This change complements
      commit cd206360 ("net/smc: avoid fallback in case of non-blocking connect")
      and fixes the syzbot reported problem "WARNING in smc_unhash_sk".
      
      Reported-by: syzbot+8488cc4cf1c9e09b8b86@syzkaller.appspotmail.com
      Fixes: e1bbdd57 ("net/smc: reduce sock_put() for fallback sockets")
      Signed-off-by: default avatarUrsula Braun <ubraun@linux.ibm.com>
      Signed-off-by: default avatarKarsten Graul <kgraul@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8204df72