From: Sasha Levin Date: Mon, 27 Apr 2020 13:11:45 +0000 (-0400) Subject: Fixes for 4.19 X-Git-Tag: v4.19.119~32 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6b046a213036e5dc7f176f15171c606b041fbc1c;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 4.19 Signed-off-by: Sasha Levin --- diff --git a/queue-4.19/alsa-hda-remove-asus-rog-zenith-from-the-blacklist.patch b/queue-4.19/alsa-hda-remove-asus-rog-zenith-from-the-blacklist.patch new file mode 100644 index 00000000000..661202c3756 --- /dev/null +++ b/queue-4.19/alsa-hda-remove-asus-rog-zenith-from-the-blacklist.patch @@ -0,0 +1,48 @@ +From e74117c122704652f6ffdcaaac20ea8c0b287b46 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 19 Apr 2020 09:19:26 +0200 +Subject: ALSA: hda: Remove ASUS ROG Zenith from the blacklist + +From: Takashi Iwai + +[ Upstream commit a8cf44f085ac12c0b5b8750ebb3b436c7f455419 ] + +The commit 3c6fd1f07ed0 ("ALSA: hda: Add driver blacklist") added a +new blacklist for the devices that are known to have empty codecs, and +one of the entries was ASUS ROG Zenith II (PCI SSID 1043:874f). +However, it turned out that the very same PCI SSID is used for the +previous model that does have the valid HD-audio codecs and the change +broke the sound on it. + +This patch reverts the corresponding entry as a temporary solution. +Although Zenith II and co will see get the empty HD-audio bus again, +it'd be merely resource wastes and won't affect the functionality, +so it's no end of the world. We'll need to address this later, +e.g. by either switching to DMI string matching or using PCI ID & +SSID pairs. + +Fixes: 3c6fd1f07ed0 ("ALSA: hda: Add driver blacklist") +Reported-by: Johnathan Smithinovic +Cc: +Link: https://lore.kernel.org/r/20200419071926.22683-1-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/pci/hda/hda_intel.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c +index 54a9b391ecce0..0502042c16163 100644 +--- a/sound/pci/hda/hda_intel.c ++++ b/sound/pci/hda/hda_intel.c +@@ -2215,7 +2215,6 @@ static const struct hdac_io_ops pci_hda_io_ops = { + * should be ignored from the beginning. + */ + static const struct snd_pci_quirk driver_blacklist[] = { +- SND_PCI_QUIRK(0x1043, 0x874f, "ASUS ROG Zenith II / Strix", 0), + SND_PCI_QUIRK(0x1462, 0xcb59, "MSI TRX40 Creator", 0), + SND_PCI_QUIRK(0x1462, 0xcb60, "MSI TRX40", 0), + {} +-- +2.20.1 + diff --git a/queue-4.19/alsa-usb-audio-add-connector-notifier-delegation.patch b/queue-4.19/alsa-usb-audio-add-connector-notifier-delegation.patch new file mode 100644 index 00000000000..43d5138a0f5 --- /dev/null +++ b/queue-4.19/alsa-usb-audio-add-connector-notifier-delegation.patch @@ -0,0 +1,170 @@ +From 6e5d48b338dc4a1885730e267102a7cc760dd1dd Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 22 Apr 2020 13:33:20 +0200 +Subject: ALSA: usb-audio: Add connector notifier delegation + +From: Takashi Iwai + +[ Upstream commit fef66ae73a611e84c8b4b74ff6f805ec5f113477 ] + +It turned out that ALC1220-VB USB-audio device gives the interrupt +event to some PCM terminals while those don't allow the connector +state request but only the actual I/O terminals return the request. +The recent commit 7dc3c5a0172e ("ALSA: usb-audio: Don't create jack +controls for PCM terminals") excluded those phantom terminals, so +those events are ignored, too. + +My first thought was that this could be easily deduced from the +associated terminals, but some of them have even no associate terminal +ID, hence it's not too trivial to figure out. + +Since the number of such terminals are small and limited, this patch +implements another quirk table for the simple mapping of the +connectors. It's not really scalable, but let's hope that there will +be not many such funky devices in future. + +Fixes: 7dc3c5a0172e ("ALSA: usb-audio: Don't create jack controls for PCM terminals") +BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=206873 +Link: https://lore.kernel.org/r/20200422113320.26664-1-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/usb/mixer.c | 25 +++++++++++++++++++++++++ + sound/usb/mixer.h | 10 ++++++++++ + sound/usb/mixer_maps.c | 13 +++++++++++++ + 3 files changed, 48 insertions(+) + +diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c +index 2638bd2e41f31..7a5c665cf4e44 100644 +--- a/sound/usb/mixer.c ++++ b/sound/usb/mixer.c +@@ -3115,6 +3115,7 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer) + if (map->id == state.chip->usb_id) { + state.map = map->map; + state.selector_map = map->selector_map; ++ mixer->connector_map = map->connector_map; + mixer->ignore_ctl_error |= map->ignore_ctl_error; + break; + } +@@ -3196,10 +3197,32 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer) + return 0; + } + ++static int delegate_notify(struct usb_mixer_interface *mixer, int unitid, ++ u8 *control, u8 *channel) ++{ ++ const struct usbmix_connector_map *map = mixer->connector_map; ++ ++ if (!map) ++ return unitid; ++ ++ for (; map->id; map++) { ++ if (map->id == unitid) { ++ if (control && map->control) ++ *control = map->control; ++ if (channel && map->channel) ++ *channel = map->channel; ++ return map->delegated_id; ++ } ++ } ++ return unitid; ++} ++ + void snd_usb_mixer_notify_id(struct usb_mixer_interface *mixer, int unitid) + { + struct usb_mixer_elem_list *list; + ++ unitid = delegate_notify(mixer, unitid, NULL, NULL); ++ + for_each_mixer_elem(list, mixer, unitid) { + struct usb_mixer_elem_info *info = + mixer_elem_list_to_info(list); +@@ -3269,6 +3292,8 @@ static void snd_usb_mixer_interrupt_v2(struct usb_mixer_interface *mixer, + return; + } + ++ unitid = delegate_notify(mixer, unitid, &control, &channel); ++ + for_each_mixer_elem(list, mixer, unitid) + count++; + +diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h +index 3d12af8bf1917..15ec90e96d4d9 100644 +--- a/sound/usb/mixer.h ++++ b/sound/usb/mixer.h +@@ -4,6 +4,13 @@ + + #include + ++struct usbmix_connector_map { ++ u8 id; ++ u8 delegated_id; ++ u8 control; ++ u8 channel; ++}; ++ + struct usb_mixer_interface { + struct snd_usb_audio *chip; + struct usb_host_interface *hostif; +@@ -16,6 +23,9 @@ struct usb_mixer_interface { + /* the usb audio specification version this interface complies to */ + int protocol; + ++ /* optional connector delegation map */ ++ const struct usbmix_connector_map *connector_map; ++ + /* Sound Blaster remote control stuff */ + const struct rc_config *rc_cfg; + u32 rc_code; +diff --git a/sound/usb/mixer_maps.c b/sound/usb/mixer_maps.c +index 3c14ef8fd5a2b..1689e4f242dfd 100644 +--- a/sound/usb/mixer_maps.c ++++ b/sound/usb/mixer_maps.c +@@ -41,6 +41,7 @@ struct usbmix_ctl_map { + u32 id; + const struct usbmix_name_map *map; + const struct usbmix_selector_map *selector_map; ++ const struct usbmix_connector_map *connector_map; + int ignore_ctl_error; + }; + +@@ -391,6 +392,15 @@ static const struct usbmix_name_map trx40_mobo_map[] = { + {} + }; + ++static const struct usbmix_connector_map trx40_mobo_connector_map[] = { ++ { 10, 16 }, /* (Back) Speaker */ ++ { 11, 17 }, /* Front Headphone */ ++ { 13, 7 }, /* Line */ ++ { 14, 8 }, /* Mic */ ++ { 15, 9 }, /* Front Mic */ ++ {} ++}; ++ + /* + * Control map entries + */ +@@ -513,6 +523,7 @@ static struct usbmix_ctl_map usbmix_ctl_maps[] = { + { /* Gigabyte TRX40 Aorus Pro WiFi */ + .id = USB_ID(0x0414, 0xa002), + .map = trx40_mobo_map, ++ .connector_map = trx40_mobo_connector_map, + }, + { /* ASUS ROG Zenith II */ + .id = USB_ID(0x0b05, 0x1916), +@@ -525,10 +536,12 @@ static struct usbmix_ctl_map usbmix_ctl_maps[] = { + { /* MSI TRX40 Creator */ + .id = USB_ID(0x0db0, 0x0d64), + .map = trx40_mobo_map, ++ .connector_map = trx40_mobo_connector_map, + }, + { /* MSI TRX40 */ + .id = USB_ID(0x0db0, 0x543d), + .map = trx40_mobo_map, ++ .connector_map = trx40_mobo_connector_map, + }, + { 0 } /* terminator */ + }; +-- +2.20.1 + diff --git a/queue-4.19/alsa-usb-audio-add-static-mapping-table-for-alc1220-.patch b/queue-4.19/alsa-usb-audio-add-static-mapping-table-for-alc1220-.patch new file mode 100644 index 00000000000..719692468a7 --- /dev/null +++ b/queue-4.19/alsa-usb-audio-add-static-mapping-table-for-alc1220-.patch @@ -0,0 +1,139 @@ +From ea9c7836ca5335a88950df347c71c6611e0477b8 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 20 Apr 2020 08:20:36 +0200 +Subject: ALSA: usb-audio: Add static mapping table for ALC1220-VB-based mobos + +From: Takashi Iwai + +[ Upstream commit a43c1c41bc5145971d06edc42a6b1e8faa0e2bc3 ] + +TRX40 mobos from MSI and others with ALC1220-VB USB-audio device need +yet more quirks for the proper control names. + +This patch provides the mapping table for those boards, correcting the +FU names for volume and mute controls as well as the terminal names +for jack controls. It also improves build_connector_control() not to +add the directional suffix blindly if the string is given from the +mapping table. + +With this patch applied, the new UCM profiles will be effective. + +BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=206873 +Link: https://lore.kernel.org/r/20200420062036.28567-1-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/usb/mixer.c | 12 +++++++++--- + sound/usb/mixer_maps.c | 24 +++++++++++++++++++++--- + sound/usb/quirks-table.h | 14 ++++++++++++++ + 3 files changed, 44 insertions(+), 6 deletions(-) + +diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c +index 257da95a4ea6a..2638bd2e41f31 100644 +--- a/sound/usb/mixer.c ++++ b/sound/usb/mixer.c +@@ -1770,8 +1770,10 @@ static void build_connector_control(struct usb_mixer_interface *mixer, + { + struct snd_kcontrol *kctl; + struct usb_mixer_elem_info *cval; ++ const struct usbmix_name_map *map; + +- if (check_ignored_ctl(find_map(imap, term->id, 0))) ++ map = find_map(imap, term->id, 0); ++ if (check_ignored_ctl(map)) + return; + + cval = kzalloc(sizeof(*cval), GFP_KERNEL); +@@ -1803,8 +1805,12 @@ static void build_connector_control(struct usb_mixer_interface *mixer, + usb_mixer_elem_info_free(cval); + return; + } +- get_connector_control_name(mixer, term, is_input, kctl->id.name, +- sizeof(kctl->id.name)); ++ ++ if (check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name))) ++ strlcat(kctl->id.name, " Jack", sizeof(kctl->id.name)); ++ else ++ get_connector_control_name(mixer, term, is_input, kctl->id.name, ++ sizeof(kctl->id.name)); + kctl->private_free = snd_usb_mixer_elem_free; + snd_usb_mixer_add_control(&cval->head, kctl); + } +diff --git a/sound/usb/mixer_maps.c b/sound/usb/mixer_maps.c +index bf000e54461b1..3c14ef8fd5a2b 100644 +--- a/sound/usb/mixer_maps.c ++++ b/sound/usb/mixer_maps.c +@@ -373,6 +373,24 @@ static const struct usbmix_name_map asus_rog_map[] = { + {} + }; + ++/* TRX40 mobos with Realtek ALC1220-VB */ ++static const struct usbmix_name_map trx40_mobo_map[] = { ++ { 18, NULL }, /* OT, IEC958 - broken response, disabled */ ++ { 19, NULL, 12 }, /* FU, Input Gain Pad - broken response, disabled */ ++ { 16, "Speaker" }, /* OT */ ++ { 22, "Speaker Playback" }, /* FU */ ++ { 7, "Line" }, /* IT */ ++ { 19, "Line Capture" }, /* FU */ ++ { 17, "Front Headphone" }, /* OT */ ++ { 23, "Front Headphone Playback" }, /* FU */ ++ { 8, "Mic" }, /* IT */ ++ { 20, "Mic Capture" }, /* FU */ ++ { 9, "Front Mic" }, /* IT */ ++ { 21, "Front Mic Capture" }, /* FU */ ++ { 24, "IEC958 Playback" }, /* FU */ ++ {} ++}; ++ + /* + * Control map entries + */ +@@ -494,7 +512,7 @@ static struct usbmix_ctl_map usbmix_ctl_maps[] = { + }, + { /* Gigabyte TRX40 Aorus Pro WiFi */ + .id = USB_ID(0x0414, 0xa002), +- .map = asus_rog_map, ++ .map = trx40_mobo_map, + }, + { /* ASUS ROG Zenith II */ + .id = USB_ID(0x0b05, 0x1916), +@@ -506,11 +524,11 @@ static struct usbmix_ctl_map usbmix_ctl_maps[] = { + }, + { /* MSI TRX40 Creator */ + .id = USB_ID(0x0db0, 0x0d64), +- .map = asus_rog_map, ++ .map = trx40_mobo_map, + }, + { /* MSI TRX40 */ + .id = USB_ID(0x0db0, 0x543d), +- .map = asus_rog_map, ++ .map = trx40_mobo_map, + }, + { 0 } /* terminator */ + }; +diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h +index 90d4f61cc2308..774aeedde0717 100644 +--- a/sound/usb/quirks-table.h ++++ b/sound/usb/quirks-table.h +@@ -3400,4 +3400,18 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"), + } + }, + ++#define ALC1220_VB_DESKTOP(vend, prod) { \ ++ USB_DEVICE(vend, prod), \ ++ .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { \ ++ .vendor_name = "Realtek", \ ++ .product_name = "ALC1220-VB-DT", \ ++ .profile_name = "Realtek-ALC1220-VB-Desktop", \ ++ .ifnum = QUIRK_NO_INTERFACE \ ++ } \ ++} ++ALC1220_VB_DESKTOP(0x0414, 0xa002), /* Gigabyte TRX40 Aorus Pro WiFi */ ++ALC1220_VB_DESKTOP(0x0db0, 0x0d64), /* MSI TRX40 Creator */ ++ALC1220_VB_DESKTOP(0x0db0, 0x543d), /* MSI TRX40 */ ++#undef ALC1220_VB_DESKTOP ++ + #undef USB_DEVICE_VENDOR_SPEC +-- +2.20.1 + diff --git a/queue-4.19/keys-avoid-false-positive-enomem-error-on-key-read.patch b/queue-4.19/keys-avoid-false-positive-enomem-error-on-key-read.patch new file mode 100644 index 00000000000..10ae1d893af --- /dev/null +++ b/queue-4.19/keys-avoid-false-positive-enomem-error-on-key-read.patch @@ -0,0 +1,169 @@ +From 9541031b4d119755b3385c4281cfc1c5d2a68332 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 21 Mar 2020 21:11:25 -0400 +Subject: KEYS: Avoid false positive ENOMEM error on key read + +From: Waiman Long + +[ Upstream commit 4f0882491a148059a52480e753b7f07fc550e188 ] + +By allocating a kernel buffer with a user-supplied buffer length, it +is possible that a false positive ENOMEM error may be returned because +the user-supplied length is just too large even if the system do have +enough memory to hold the actual key data. + +Moreover, if the buffer length is larger than the maximum amount of +memory that can be returned by kmalloc() (2^(MAX_ORDER-1) number of +pages), a warning message will also be printed. + +To reduce this possibility, we set a threshold (PAGE_SIZE) over which we +do check the actual key length first before allocating a buffer of the +right size to hold it. The threshold is arbitrary, it is just used to +trigger a buffer length check. It does not limit the actual key length +as long as there is enough memory to satisfy the memory request. + +To further avoid large buffer allocation failure due to page +fragmentation, kvmalloc() is used to allocate the buffer so that vmapped +pages can be used when there is not a large enough contiguous set of +pages available for allocation. + +In the extremely unlikely scenario that the key keeps on being changed +and made longer (still <= buflen) in between 2 __keyctl_read_key() +calls, the __keyctl_read_key() calling loop in keyctl_read_key() may +have to be iterated a large number of times, but definitely not infinite. + +Signed-off-by: Waiman Long +Signed-off-by: David Howells +Signed-off-by: Sasha Levin +--- + security/keys/internal.h | 12 +++++++++ + security/keys/keyctl.c | 58 +++++++++++++++++++++++++++++----------- + 2 files changed, 55 insertions(+), 15 deletions(-) + +diff --git a/security/keys/internal.h b/security/keys/internal.h +index a02742621c8d3..eb50212fbbf84 100644 +--- a/security/keys/internal.h ++++ b/security/keys/internal.h +@@ -20,6 +20,8 @@ + #include + #include + #include ++#include ++#include + + struct iovec; + +@@ -305,4 +307,14 @@ static inline void key_check(const struct key *key) + + #endif + ++/* ++ * Helper function to clear and free a kvmalloc'ed memory object. ++ */ ++static inline void __kvzfree(const void *addr, size_t len) ++{ ++ if (addr) { ++ memset((void *)addr, 0, len); ++ kvfree(addr); ++ } ++} + #endif /* _INTERNAL_H */ +diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c +index 4b6a084e323b5..c07c2e2b24783 100644 +--- a/security/keys/keyctl.c ++++ b/security/keys/keyctl.c +@@ -330,7 +330,7 @@ long keyctl_update_key(key_serial_t id, + payload = NULL; + if (plen) { + ret = -ENOMEM; +- payload = kmalloc(plen, GFP_KERNEL); ++ payload = kvmalloc(plen, GFP_KERNEL); + if (!payload) + goto error; + +@@ -351,7 +351,7 @@ long keyctl_update_key(key_serial_t id, + + key_ref_put(key_ref); + error2: +- kzfree(payload); ++ __kvzfree(payload, plen); + error: + return ret; + } +@@ -772,7 +772,8 @@ long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen) + struct key *key; + key_ref_t key_ref; + long ret; +- char *key_data; ++ char *key_data = NULL; ++ size_t key_data_len; + + /* find the key first */ + key_ref = lookup_user_key(keyid, 0, 0); +@@ -823,24 +824,51 @@ can_read_key: + * Allocating a temporary buffer to hold the keys before + * transferring them to user buffer to avoid potential + * deadlock involving page fault and mmap_sem. ++ * ++ * key_data_len = (buflen <= PAGE_SIZE) ++ * ? buflen : actual length of key data ++ * ++ * This prevents allocating arbitrary large buffer which can ++ * be much larger than the actual key length. In the latter case, ++ * at least 2 passes of this loop is required. + */ +- key_data = kmalloc(buflen, GFP_KERNEL); ++ key_data_len = (buflen <= PAGE_SIZE) ? buflen : 0; ++ for (;;) { ++ if (key_data_len) { ++ key_data = kvmalloc(key_data_len, GFP_KERNEL); ++ if (!key_data) { ++ ret = -ENOMEM; ++ goto key_put_out; ++ } ++ } + +- if (!key_data) { +- ret = -ENOMEM; +- goto key_put_out; +- } +- ret = __keyctl_read_key(key, key_data, buflen); ++ ret = __keyctl_read_key(key, key_data, key_data_len); ++ ++ /* ++ * Read methods will just return the required length without ++ * any copying if the provided length isn't large enough. ++ */ ++ if (ret <= 0 || ret > buflen) ++ break; ++ ++ /* ++ * The key may change (unlikely) in between 2 consecutive ++ * __keyctl_read_key() calls. In this case, we reallocate ++ * a larger buffer and redo the key read when ++ * key_data_len < ret <= buflen. ++ */ ++ if (ret > key_data_len) { ++ if (unlikely(key_data)) ++ __kvzfree(key_data, key_data_len); ++ key_data_len = ret; ++ continue; /* Allocate buffer */ ++ } + +- /* +- * Read methods will just return the required length without +- * any copying if the provided length isn't large enough. +- */ +- if (ret > 0 && ret <= buflen) { + if (copy_to_user(buffer, key_data, ret)) + ret = -EFAULT; ++ break; + } +- kzfree(key_data); ++ __kvzfree(key_data, key_data_len); + + key_put_out: + key_put(key); +-- +2.20.1 + diff --git a/queue-4.19/series b/queue-4.19/series index fdd84a48016..0f03763c69b 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -70,3 +70,7 @@ net-dsa-b53-b53_arl_rw_op-needs-to-select-ivl-or-svl.patch xfrm-always-set-xfrm_transformed-in-xfrm-4-6-_output_finish.patch vrf-check-skb-for-xfrm_transformed-flag.patch mlxsw-fix-some-is_err-vs-null-bugs.patch +keys-avoid-false-positive-enomem-error-on-key-read.patch +alsa-hda-remove-asus-rog-zenith-from-the-blacklist.patch +alsa-usb-audio-add-static-mapping-table-for-alc1220-.patch +alsa-usb-audio-add-connector-notifier-delegation.patch