From 79c9d23690ce1962999ae6187c2aa936e4ee9657 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 25 Mar 2022 10:49:32 +0100 Subject: [PATCH] 4.9-stable patches added patches: alsa-cmipci-restore-aux-vol-on-suspend-resume.patch alsa-pci-fix-reading-of-swapped-values-from-pcmreg-in-ac97-codec.patch alsa-pcm-add-stream-lock-during-pcm-reset-ioctl-operations.patch alsa-usb-audio-add-mute-tlv-for-playback-volumes-on-rode-nt-usb.patch llc-fix-netdevice-reference-leaks-in-llc_ui_bind.patch netfilter-nf_tables-initialize-registers-in-nft_do_chain.patch --- ...ci-restore-aux-vol-on-suspend-resume.patch | 43 ++++++++++++++ ...ped-values-from-pcmreg-in-ac97-codec.patch | 56 +++++++++++++++++++ ...ck-during-pcm-reset-ioctl-operations.patch | 53 ++++++++++++++++++ ...-for-playback-volumes-on-rode-nt-usb.patch | 41 ++++++++++++++ ...evice-reference-leaks-in-llc_ui_bind.patch | 55 ++++++++++++++++++ ...initialize-registers-in-nft_do_chain.patch | 29 ++++++++++ queue-4.9/series | 6 ++ 7 files changed, 283 insertions(+) create mode 100644 queue-4.9/alsa-cmipci-restore-aux-vol-on-suspend-resume.patch create mode 100644 queue-4.9/alsa-pci-fix-reading-of-swapped-values-from-pcmreg-in-ac97-codec.patch create mode 100644 queue-4.9/alsa-pcm-add-stream-lock-during-pcm-reset-ioctl-operations.patch create mode 100644 queue-4.9/alsa-usb-audio-add-mute-tlv-for-playback-volumes-on-rode-nt-usb.patch create mode 100644 queue-4.9/llc-fix-netdevice-reference-leaks-in-llc_ui_bind.patch create mode 100644 queue-4.9/netfilter-nf_tables-initialize-registers-in-nft_do_chain.patch diff --git a/queue-4.9/alsa-cmipci-restore-aux-vol-on-suspend-resume.patch b/queue-4.9/alsa-cmipci-restore-aux-vol-on-suspend-resume.patch new file mode 100644 index 00000000000..e75c35cd6c3 --- /dev/null +++ b/queue-4.9/alsa-cmipci-restore-aux-vol-on-suspend-resume.patch @@ -0,0 +1,43 @@ +From c14231cc04337c2c2a937db084af342ce704dbde Mon Sep 17 00:00:00 2001 +From: Jonathan Teh +Date: Sun, 13 Mar 2022 19:56:17 +0000 +Subject: ALSA: cmipci: Restore aux vol on suspend/resume + +From: Jonathan Teh + +commit c14231cc04337c2c2a937db084af342ce704dbde upstream. + +Save and restore CM_REG_AUX_VOL instead of register 0x24 twice on +suspend/resume. + +Tested on CMI8738LX. + +Fixes: cb60e5f5b2b1 ("[ALSA] cmipci - Add PM support") +Signed-off-by: Jonathan Teh +Cc: +Link: https://lore.kernel.org/r/DBAPR04MB7366CB3EA9C8521C35C56E8B920E9@DBAPR04MB7366.eurprd04.prod.outlook.com +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/cmipci.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +--- a/sound/pci/cmipci.c ++++ b/sound/pci/cmipci.c +@@ -315,7 +315,6 @@ MODULE_PARM_DESC(joystick_port, "Joystic + #define CM_MICGAINZ 0x01 /* mic boost */ + #define CM_MICGAINZ_SHIFT 0 + +-#define CM_REG_MIXER3 0x24 + #define CM_REG_AUX_VOL 0x26 + #define CM_VAUXL_MASK 0xf0 + #define CM_VAUXR_MASK 0x0f +@@ -3323,7 +3322,7 @@ static void snd_cmipci_remove(struct pci + */ + static unsigned char saved_regs[] = { + CM_REG_FUNCTRL1, CM_REG_CHFORMAT, CM_REG_LEGACY_CTRL, CM_REG_MISC_CTRL, +- CM_REG_MIXER0, CM_REG_MIXER1, CM_REG_MIXER2, CM_REG_MIXER3, CM_REG_PLL, ++ CM_REG_MIXER0, CM_REG_MIXER1, CM_REG_MIXER2, CM_REG_AUX_VOL, CM_REG_PLL, + CM_REG_CH0_FRAME1, CM_REG_CH0_FRAME2, + CM_REG_CH1_FRAME1, CM_REG_CH1_FRAME2, CM_REG_EXT_MISC, + CM_REG_INT_STATUS, CM_REG_INT_HLDCLR, CM_REG_FUNCTRL0, diff --git a/queue-4.9/alsa-pci-fix-reading-of-swapped-values-from-pcmreg-in-ac97-codec.patch b/queue-4.9/alsa-pci-fix-reading-of-swapped-values-from-pcmreg-in-ac97-codec.patch new file mode 100644 index 00000000000..0a03d76eada --- /dev/null +++ b/queue-4.9/alsa-pci-fix-reading-of-swapped-values-from-pcmreg-in-ac97-codec.patch @@ -0,0 +1,56 @@ +From 17aaf0193392cb3451bf0ac75ba396ec4cbded6e Mon Sep 17 00:00:00 2001 +From: Giacomo Guiduzzi +Date: Tue, 22 Mar 2022 21:06:54 +0100 +Subject: ALSA: pci: fix reading of swapped values from pcmreg in AC97 codec + +From: Giacomo Guiduzzi + +commit 17aaf0193392cb3451bf0ac75ba396ec4cbded6e upstream. + +Tests 72 and 78 for ALSA in kselftest fail due to reading +inconsistent values from some devices on a VirtualBox +Virtual Machine using the snd_intel8x0 driver for the AC'97 +Audio Controller device. +Taking for example test number 72, this is what the test reports: +"Surround Playback Volume.0 expected 1 but read 0, is_volatile 0" +"Surround Playback Volume.1 expected 0 but read 1, is_volatile 0" +These errors repeat for each value from 0 to 31. + +Taking a look at these error messages it is possible to notice +that the written values are read back swapped. +When the write is performed, these values are initially stored in +an array used to sanity-check them and write them in the pcmreg +array. To write them, the two one-byte values are packed together +in a two-byte variable through bitwise operations: the first +value is shifted left by one byte and the second value is stored in the +right byte through a bitwise OR. When reading the values back, +right shifts are performed to retrieve the previously stored +bytes. These shifts are executed in the wrong order, thus +reporting the values swapped as shown above. + +This patch fixes this mistake by reversing the read +operations' order. + +Signed-off-by: Giacomo Guiduzzi +Signed-off-by: Paolo Valente +Cc: +Link: https://lore.kernel.org/r/20220322200653.15862-1-guiduzzi.giacomo@gmail.com +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/ac97/ac97_codec.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/sound/pci/ac97/ac97_codec.c ++++ b/sound/pci/ac97/ac97_codec.c +@@ -958,8 +958,8 @@ static int snd_ac97_ad18xx_pcm_get_volum + int codec = kcontrol->private_value & 3; + + mutex_lock(&ac97->page_mutex); +- ucontrol->value.integer.value[0] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 0) & 31); +- ucontrol->value.integer.value[1] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 8) & 31); ++ ucontrol->value.integer.value[0] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 8) & 31); ++ ucontrol->value.integer.value[1] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 0) & 31); + mutex_unlock(&ac97->page_mutex); + return 0; + } diff --git a/queue-4.9/alsa-pcm-add-stream-lock-during-pcm-reset-ioctl-operations.patch b/queue-4.9/alsa-pcm-add-stream-lock-during-pcm-reset-ioctl-operations.patch new file mode 100644 index 00000000000..9f3c9886557 --- /dev/null +++ b/queue-4.9/alsa-pcm-add-stream-lock-during-pcm-reset-ioctl-operations.patch @@ -0,0 +1,53 @@ +From 1f68915b2efd0d6bfd6e124aa63c94b3c69f127c Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 22 Mar 2022 18:13:25 +0100 +Subject: ALSA: pcm: Add stream lock during PCM reset ioctl operations + +From: Takashi Iwai + +commit 1f68915b2efd0d6bfd6e124aa63c94b3c69f127c upstream. + +snd_pcm_reset() is a non-atomic operation, and it's allowed to run +during the PCM stream running. It implies that the manipulation of +hw_ptr and other parameters might be racy. + +This patch adds the PCM stream lock at appropriate places in +snd_pcm_*_reset() actions for covering that. + +Cc: +Reviewed-by: Jaroslav Kysela +Link: https://lore.kernel.org/r/20220322171325.4355-1-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/core/pcm_native.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/sound/core/pcm_native.c ++++ b/sound/core/pcm_native.c +@@ -1489,21 +1489,25 @@ static int snd_pcm_do_reset(struct snd_p + int err = substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_RESET, NULL); + if (err < 0) + return err; ++ snd_pcm_stream_lock_irq(substream); + runtime->hw_ptr_base = 0; + runtime->hw_ptr_interrupt = runtime->status->hw_ptr - + runtime->status->hw_ptr % runtime->period_size; + runtime->silence_start = runtime->status->hw_ptr; + runtime->silence_filled = 0; ++ snd_pcm_stream_unlock_irq(substream); + return 0; + } + + static void snd_pcm_post_reset(struct snd_pcm_substream *substream, int state) + { + struct snd_pcm_runtime *runtime = substream->runtime; ++ snd_pcm_stream_lock_irq(substream); + runtime->control->appl_ptr = runtime->status->hw_ptr; + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && + runtime->silence_size > 0) + snd_pcm_playback_silence(substream, ULONG_MAX); ++ snd_pcm_stream_unlock_irq(substream); + } + + static const struct action_ops snd_pcm_action_reset = { diff --git a/queue-4.9/alsa-usb-audio-add-mute-tlv-for-playback-volumes-on-rode-nt-usb.patch b/queue-4.9/alsa-usb-audio-add-mute-tlv-for-playback-volumes-on-rode-nt-usb.patch new file mode 100644 index 00000000000..4d4e8c08337 --- /dev/null +++ b/queue-4.9/alsa-usb-audio-add-mute-tlv-for-playback-volumes-on-rode-nt-usb.patch @@ -0,0 +1,41 @@ +From 0f306cca42fe879694fb5e2382748c43dc9e0196 Mon Sep 17 00:00:00 2001 +From: Lars-Peter Clausen +Date: Fri, 11 Mar 2022 21:14:00 +0100 +Subject: ALSA: usb-audio: Add mute TLV for playback volumes on RODE NT-USB + +From: Lars-Peter Clausen + +commit 0f306cca42fe879694fb5e2382748c43dc9e0196 upstream. + +For the RODE NT-USB the lowest Playback mixer volume setting mutes the +audio output. But it is not reported as such causing e.g. PulseAudio to +accidentally mute the device when selecting a low volume. + +Fix this by applying the existing quirk for this kind of issue when the +device is detected. + +Signed-off-by: Lars-Peter Clausen +Cc: +Link: https://lore.kernel.org/r/20220311201400.235892-1-lars@metafoo.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/usb/mixer_quirks.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +--- a/sound/usb/mixer_quirks.c ++++ b/sound/usb/mixer_quirks.c +@@ -1879,9 +1879,10 @@ void snd_usb_mixer_fu_apply_quirk(struct + if (unitid == 7 && cval->control == UAC_FU_VOLUME) + snd_dragonfly_quirk_db_scale(mixer, cval, kctl); + break; +- /* lowest playback value is muted on C-Media devices */ +- case USB_ID(0x0d8c, 0x000c): +- case USB_ID(0x0d8c, 0x0014): ++ /* lowest playback value is muted on some devices */ ++ case USB_ID(0x0d8c, 0x000c): /* C-Media */ ++ case USB_ID(0x0d8c, 0x0014): /* C-Media */ ++ case USB_ID(0x19f7, 0x0003): /* RODE NT-USB */ + if (strstr(kctl->id.name, "Playback")) + cval->min_mute = 1; + break; diff --git a/queue-4.9/llc-fix-netdevice-reference-leaks-in-llc_ui_bind.patch b/queue-4.9/llc-fix-netdevice-reference-leaks-in-llc_ui_bind.patch new file mode 100644 index 00000000000..6acefbb2dfa --- /dev/null +++ b/queue-4.9/llc-fix-netdevice-reference-leaks-in-llc_ui_bind.patch @@ -0,0 +1,55 @@ +From 764f4eb6846f5475f1244767d24d25dd86528a4a Mon Sep 17 00:00:00 2001 +From: Eric Dumazet +Date: Tue, 22 Mar 2022 17:41:47 -0700 +Subject: llc: fix netdevice reference leaks in llc_ui_bind() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Eric Dumazet + +commit 764f4eb6846f5475f1244767d24d25dd86528a4a upstream. + +Whenever llc_ui_bind() and/or llc_ui_autobind() +took a reference on a netdevice but subsequently fail, +they must properly release their reference +or risk the infamous message from unregister_netdevice() +at device dismantle. + +unregister_netdevice: waiting for eth0 to become free. Usage count = 3 + +Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") +Signed-off-by: Eric Dumazet +Reported-by: 赵子轩 +Reported-by: Stoyan Manolov +Link: https://lore.kernel.org/r/20220323004147.1990845-1-eric.dumazet@gmail.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + net/llc/af_llc.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +--- a/net/llc/af_llc.c ++++ b/net/llc/af_llc.c +@@ -309,6 +309,10 @@ static int llc_ui_autobind(struct socket + sock_reset_flag(sk, SOCK_ZAPPED); + rc = 0; + out: ++ if (rc) { ++ dev_put(llc->dev); ++ llc->dev = NULL; ++ } + return rc; + } + +@@ -408,6 +412,10 @@ static int llc_ui_bind(struct socket *so + out_put: + llc_sap_put(sap); + out: ++ if (rc) { ++ dev_put(llc->dev); ++ llc->dev = NULL; ++ } + release_sock(sk); + return rc; + } diff --git a/queue-4.9/netfilter-nf_tables-initialize-registers-in-nft_do_chain.patch b/queue-4.9/netfilter-nf_tables-initialize-registers-in-nft_do_chain.patch new file mode 100644 index 00000000000..7714080dc8d --- /dev/null +++ b/queue-4.9/netfilter-nf_tables-initialize-registers-in-nft_do_chain.patch @@ -0,0 +1,29 @@ +From 4c905f6740a365464e91467aa50916555b28213d Mon Sep 17 00:00:00 2001 +From: Pablo Neira Ayuso +Date: Thu, 17 Mar 2022 12:04:42 +0100 +Subject: netfilter: nf_tables: initialize registers in nft_do_chain() + +From: Pablo Neira Ayuso + +commit 4c905f6740a365464e91467aa50916555b28213d upstream. + +Initialize registers to avoid stack leak into userspace. + +Fixes: 96518518cc41 ("netfilter: add nftables") +Signed-off-by: Pablo Neira Ayuso +Signed-off-by: Greg Kroah-Hartman +--- + net/netfilter/nf_tables_core.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/net/netfilter/nf_tables_core.c ++++ b/net/netfilter/nf_tables_core.c +@@ -127,7 +127,7 @@ nft_do_chain(struct nft_pktinfo *pkt, vo + const struct net *net = pkt->net; + const struct nft_rule *rule; + const struct nft_expr *expr, *last; +- struct nft_regs regs; ++ struct nft_regs regs = {}; + unsigned int stackptr = 0; + struct nft_jumpstack jumpstack[NFT_JUMP_STACK_SIZE]; + struct nft_stats *stats; diff --git a/queue-4.9/series b/queue-4.9/series index 8df2c63b9c5..bc36ec35be5 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -1,3 +1,9 @@ nfc-st21nfca-fix-potential-buffer-overflows-in-evt_transaction.patch net-ipv6-fix-skb_over_panic-in-__ip6_append_data.patch staging-fbtft-fb_st7789v-reset-display-before-initialization.patch +llc-fix-netdevice-reference-leaks-in-llc_ui_bind.patch +alsa-pcm-add-stream-lock-during-pcm-reset-ioctl-operations.patch +alsa-usb-audio-add-mute-tlv-for-playback-volumes-on-rode-nt-usb.patch +alsa-cmipci-restore-aux-vol-on-suspend-resume.patch +alsa-pci-fix-reading-of-swapped-values-from-pcmreg-in-ac97-codec.patch +netfilter-nf_tables-initialize-registers-in-nft_do_chain.patch -- 2.47.3