From 10ec3c09f11d0c6e3576c56883ba82f40c1b6df8 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 24 Feb 2020 15:48:47 +0100 Subject: [PATCH] 4.14-stable patches added patches: alsa-hda-use-scnprintf-for-printing-texts-for-sysfs-procfs.patch asoc-sun8i-codec-fix-setting-dai-data-format.patch ecryptfs-fix-a-memory-leak-bug-in-ecryptfs_init_messaging.patch ecryptfs-fix-a-memory-leak-bug-in-parse_tag_1_packet.patch iommu-qcom-fix-bogus-detach-logic.patch --- ...-for-printing-texts-for-sysfs-procfs.patch | 82 ++++++++++++++++++ ...8i-codec-fix-setting-dai-data-format.patch | 43 ++++++++++ ...-leak-bug-in-ecryptfs_init_messaging.patch | 34 ++++++++ ...emory-leak-bug-in-parse_tag_1_packet.patch | 35 ++++++++ .../iommu-qcom-fix-bogus-detach-logic.patch | 83 +++++++++++++++++++ queue-4.14/series | 5 ++ 6 files changed, 282 insertions(+) create mode 100644 queue-4.14/alsa-hda-use-scnprintf-for-printing-texts-for-sysfs-procfs.patch create mode 100644 queue-4.14/asoc-sun8i-codec-fix-setting-dai-data-format.patch create mode 100644 queue-4.14/ecryptfs-fix-a-memory-leak-bug-in-ecryptfs_init_messaging.patch create mode 100644 queue-4.14/ecryptfs-fix-a-memory-leak-bug-in-parse_tag_1_packet.patch create mode 100644 queue-4.14/iommu-qcom-fix-bogus-detach-logic.patch diff --git a/queue-4.14/alsa-hda-use-scnprintf-for-printing-texts-for-sysfs-procfs.patch b/queue-4.14/alsa-hda-use-scnprintf-for-printing-texts-for-sysfs-procfs.patch new file mode 100644 index 00000000000..74f2bc1825f --- /dev/null +++ b/queue-4.14/alsa-hda-use-scnprintf-for-printing-texts-for-sysfs-procfs.patch @@ -0,0 +1,82 @@ +From 44eeb081b8630bb3ad3cd381d1ae1831463e48bb Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 18 Feb 2020 10:14:09 +0100 +Subject: ALSA: hda: Use scnprintf() for printing texts for sysfs/procfs + +From: Takashi Iwai + +commit 44eeb081b8630bb3ad3cd381d1ae1831463e48bb upstream. + +Some code in HD-audio driver calls snprintf() in a loop and still +expects that the return value were actually written size, while +snprintf() returns the expected would-be length instead. When the +given buffer limit were small, this leads to a buffer overflow. + +Use scnprintf() for addressing those issues. It returns the actually +written size unlike snprintf(). + +Cc: +Link: https://lore.kernel.org/r/20200218091409.27162-1-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman + +--- + sound/hda/hdmi_chmap.c | 2 +- + sound/pci/hda/hda_codec.c | 2 +- + sound/pci/hda/hda_eld.c | 2 +- + sound/pci/hda/hda_sysfs.c | 4 ++-- + 4 files changed, 5 insertions(+), 5 deletions(-) + +--- a/sound/hda/hdmi_chmap.c ++++ b/sound/hda/hdmi_chmap.c +@@ -249,7 +249,7 @@ void snd_hdac_print_channel_allocation(i + + for (i = 0, j = 0; i < ARRAY_SIZE(cea_speaker_allocation_names); i++) { + if (spk_alloc & (1 << i)) +- j += snprintf(buf + j, buflen - j, " %s", ++ j += scnprintf(buf + j, buflen - j, " %s", + cea_speaker_allocation_names[i]); + } + buf[j] = '\0'; /* necessary when j == 0 */ +--- a/sound/pci/hda/hda_codec.c ++++ b/sound/pci/hda/hda_codec.c +@@ -4002,7 +4002,7 @@ void snd_print_pcm_bits(int pcm, char *b + + for (i = 0, j = 0; i < ARRAY_SIZE(bits); i++) + if (pcm & (AC_SUPPCM_BITS_8 << i)) +- j += snprintf(buf + j, buflen - j, " %d", bits[i]); ++ j += scnprintf(buf + j, buflen - j, " %d", bits[i]); + + buf[j] = '\0'; /* necessary when j == 0 */ + } +--- a/sound/pci/hda/hda_eld.c ++++ b/sound/pci/hda/hda_eld.c +@@ -373,7 +373,7 @@ static void hdmi_print_pcm_rates(int pcm + + for (i = 0, j = 0; i < ARRAY_SIZE(alsa_rates); i++) + if (pcm & (1 << i)) +- j += snprintf(buf + j, buflen - j, " %d", ++ j += scnprintf(buf + j, buflen - j, " %d", + alsa_rates[i]); + + buf[j] = '\0'; /* necessary when j == 0 */ +--- a/sound/pci/hda/hda_sysfs.c ++++ b/sound/pci/hda/hda_sysfs.c +@@ -221,7 +221,7 @@ static ssize_t init_verbs_show(struct de + mutex_lock(&codec->user_mutex); + for (i = 0; i < codec->init_verbs.used; i++) { + struct hda_verb *v = snd_array_elem(&codec->init_verbs, i); +- len += snprintf(buf + len, PAGE_SIZE - len, ++ len += scnprintf(buf + len, PAGE_SIZE - len, + "0x%02x 0x%03x 0x%04x\n", + v->nid, v->verb, v->param); + } +@@ -271,7 +271,7 @@ static ssize_t hints_show(struct device + mutex_lock(&codec->user_mutex); + for (i = 0; i < codec->hints.used; i++) { + struct hda_hint *hint = snd_array_elem(&codec->hints, i); +- len += snprintf(buf + len, PAGE_SIZE - len, ++ len += scnprintf(buf + len, PAGE_SIZE - len, + "%s = %s\n", hint->key, hint->val); + } + mutex_unlock(&codec->user_mutex); diff --git a/queue-4.14/asoc-sun8i-codec-fix-setting-dai-data-format.patch b/queue-4.14/asoc-sun8i-codec-fix-setting-dai-data-format.patch new file mode 100644 index 00000000000..3d5f4b31c95 --- /dev/null +++ b/queue-4.14/asoc-sun8i-codec-fix-setting-dai-data-format.patch @@ -0,0 +1,43 @@ +From 96781fd941b39e1f78098009344ebcd7af861c67 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Mon, 17 Feb 2020 00:42:22 -0600 +Subject: ASoC: sun8i-codec: Fix setting DAI data format + +From: Samuel Holland + +commit 96781fd941b39e1f78098009344ebcd7af861c67 upstream. + +Use the correct mask for this two-bit field. This fixes setting the DAI +data format to RIGHT_J or DSP_A. + +Fixes: 36c684936fae ("ASoC: Add sun8i digital audio codec") +Signed-off-by: Samuel Holland +Acked-by: Chen-Yu Tsai +Cc: stable@kernel.org +Link: https://lore.kernel.org/r/20200217064250.15516-7-samuel@sholland.org +Signed-off-by: Mark Brown +Signed-off-by: Greg Kroah-Hartman + +--- + sound/soc/sunxi/sun8i-codec.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/sound/soc/sunxi/sun8i-codec.c ++++ b/sound/soc/sunxi/sun8i-codec.c +@@ -71,6 +71,7 @@ + + #define SUN8I_SYS_SR_CTRL_AIF1_FS_MASK GENMASK(15, 12) + #define SUN8I_SYS_SR_CTRL_AIF2_FS_MASK GENMASK(11, 8) ++#define SUN8I_AIF1CLK_CTRL_AIF1_DATA_FMT_MASK GENMASK(3, 2) + #define SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ_MASK GENMASK(5, 4) + #define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_MASK GENMASK(8, 6) + #define SUN8I_AIF1CLK_CTRL_AIF1_BCLK_DIV_MASK GENMASK(12, 9) +@@ -221,7 +222,7 @@ static int sun8i_set_fmt(struct snd_soc_ + return -EINVAL; + } + regmap_update_bits(scodec->regmap, SUN8I_AIF1CLK_CTRL, +- BIT(SUN8I_AIF1CLK_CTRL_AIF1_DATA_FMT), ++ SUN8I_AIF1CLK_CTRL_AIF1_DATA_FMT_MASK, + value << SUN8I_AIF1CLK_CTRL_AIF1_DATA_FMT); + + return 0; diff --git a/queue-4.14/ecryptfs-fix-a-memory-leak-bug-in-ecryptfs_init_messaging.patch b/queue-4.14/ecryptfs-fix-a-memory-leak-bug-in-ecryptfs_init_messaging.patch new file mode 100644 index 00000000000..4ef0de1b4a1 --- /dev/null +++ b/queue-4.14/ecryptfs-fix-a-memory-leak-bug-in-ecryptfs_init_messaging.patch @@ -0,0 +1,34 @@ +From b4a81b87a4cfe2bb26a4a943b748d96a43ef20e8 Mon Sep 17 00:00:00 2001 +From: Wenwen Wang +Date: Tue, 20 Aug 2019 00:33:54 -0500 +Subject: ecryptfs: fix a memory leak bug in ecryptfs_init_messaging() + +From: Wenwen Wang + +commit b4a81b87a4cfe2bb26a4a943b748d96a43ef20e8 upstream. + +In ecryptfs_init_messaging(), if the allocation for 'ecryptfs_msg_ctx_arr' +fails, the previously allocated 'ecryptfs_daemon_hash' is not deallocated, +leading to a memory leak bug. To fix this issue, free +'ecryptfs_daemon_hash' before returning the error. + +Cc: stable@vger.kernel.org +Fixes: 88b4a07e6610 ("[PATCH] eCryptfs: Public key transport mechanism") +Signed-off-by: Wenwen Wang +Signed-off-by: Tyler Hicks +Signed-off-by: Greg Kroah-Hartman + +--- + fs/ecryptfs/messaging.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/fs/ecryptfs/messaging.c ++++ b/fs/ecryptfs/messaging.c +@@ -397,6 +397,7 @@ int __init ecryptfs_init_messaging(void) + * ecryptfs_message_buf_len), + GFP_KERNEL); + if (!ecryptfs_msg_ctx_arr) { ++ kfree(ecryptfs_daemon_hash); + rc = -ENOMEM; + printk(KERN_ERR "%s: Failed to allocate memory\n", __func__); + goto out; diff --git a/queue-4.14/ecryptfs-fix-a-memory-leak-bug-in-parse_tag_1_packet.patch b/queue-4.14/ecryptfs-fix-a-memory-leak-bug-in-parse_tag_1_packet.patch new file mode 100644 index 00000000000..3a0b224c392 --- /dev/null +++ b/queue-4.14/ecryptfs-fix-a-memory-leak-bug-in-parse_tag_1_packet.patch @@ -0,0 +1,35 @@ +From fe2e082f5da5b4a0a92ae32978f81507ef37ec66 Mon Sep 17 00:00:00 2001 +From: Wenwen Wang +Date: Tue, 20 Aug 2019 00:16:40 -0500 +Subject: ecryptfs: fix a memory leak bug in parse_tag_1_packet() + +From: Wenwen Wang + +commit fe2e082f5da5b4a0a92ae32978f81507ef37ec66 upstream. + +In parse_tag_1_packet(), if tag 1 packet contains a key larger than +ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES, no cleanup is executed, leading to a +memory leak on the allocated 'auth_tok_list_item'. To fix this issue, go to +the label 'out_free' to perform the cleanup work. + +Cc: stable@vger.kernel.org +Fixes: dddfa461fc89 ("[PATCH] eCryptfs: Public key; packet management") +Signed-off-by: Wenwen Wang +Signed-off-by: Tyler Hicks +Signed-off-by: Greg Kroah-Hartman + +--- + fs/ecryptfs/keystore.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/fs/ecryptfs/keystore.c ++++ b/fs/ecryptfs/keystore.c +@@ -1285,7 +1285,7 @@ parse_tag_1_packet(struct ecryptfs_crypt + printk(KERN_ERR "Enter w/ first byte != 0x%.2x\n", + ECRYPTFS_TAG_1_PACKET_TYPE); + rc = -EINVAL; +- goto out; ++ goto out_free; + } + /* Released: wipe_auth_tok_list called in ecryptfs_parse_packet_set or + * at end of function upon failure */ diff --git a/queue-4.14/iommu-qcom-fix-bogus-detach-logic.patch b/queue-4.14/iommu-qcom-fix-bogus-detach-logic.patch new file mode 100644 index 00000000000..68d0f80913b --- /dev/null +++ b/queue-4.14/iommu-qcom-fix-bogus-detach-logic.patch @@ -0,0 +1,83 @@ +From faf305c51aeabd1ea2d7131e798ef5f55f4a7750 Mon Sep 17 00:00:00 2001 +From: Robin Murphy +Date: Tue, 18 Feb 2020 18:12:41 +0000 +Subject: iommu/qcom: Fix bogus detach logic + +From: Robin Murphy + +commit faf305c51aeabd1ea2d7131e798ef5f55f4a7750 upstream. + +Currently, the implementation of qcom_iommu_domain_free() is guaranteed +to do one of two things: WARN() and leak everything, or dereference NULL +and crash. That alone is terrible, but in fact the whole idea of trying +to track the liveness of a domain via the qcom_domain->iommu pointer as +a sanity check is full of fundamentally flawed assumptions. Make things +robust and actually functional by not trying to be quite so clever. + +Reported-by: Brian Masney +Tested-by: Brian Masney +Reported-by: Naresh Kamboju +Fixes: 0ae349a0f33f ("iommu/qcom: Add qcom_iommu") +Signed-off-by: Robin Murphy +Tested-by: Stephan Gerhold +Cc: stable@vger.kernel.org # v4.14+ +Signed-off-by: Joerg Roedel +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/iommu/qcom_iommu.c | 28 ++++++++++++---------------- + 1 file changed, 12 insertions(+), 16 deletions(-) + +--- a/drivers/iommu/qcom_iommu.c ++++ b/drivers/iommu/qcom_iommu.c +@@ -327,21 +327,19 @@ static void qcom_iommu_domain_free(struc + { + struct qcom_iommu_domain *qcom_domain = to_qcom_iommu_domain(domain); + +- if (WARN_ON(qcom_domain->iommu)) /* forgot to detach? */ +- return; +- + iommu_put_dma_cookie(domain); + +- /* NOTE: unmap can be called after client device is powered off, +- * for example, with GPUs or anything involving dma-buf. So we +- * cannot rely on the device_link. Make sure the IOMMU is on to +- * avoid unclocked accesses in the TLB inv path: +- */ +- pm_runtime_get_sync(qcom_domain->iommu->dev); +- +- free_io_pgtable_ops(qcom_domain->pgtbl_ops); +- +- pm_runtime_put_sync(qcom_domain->iommu->dev); ++ if (qcom_domain->iommu) { ++ /* ++ * NOTE: unmap can be called after client device is powered ++ * off, for example, with GPUs or anything involving dma-buf. ++ * So we cannot rely on the device_link. Make sure the IOMMU ++ * is on to avoid unclocked accesses in the TLB inv path: ++ */ ++ pm_runtime_get_sync(qcom_domain->iommu->dev); ++ free_io_pgtable_ops(qcom_domain->pgtbl_ops); ++ pm_runtime_put_sync(qcom_domain->iommu->dev); ++ } + + kfree(qcom_domain); + } +@@ -386,7 +384,7 @@ static void qcom_iommu_detach_dev(struct + struct qcom_iommu_domain *qcom_domain = to_qcom_iommu_domain(domain); + unsigned i; + +- if (!qcom_domain->iommu) ++ if (WARN_ON(!qcom_domain->iommu)) + return; + + pm_runtime_get_sync(qcom_iommu->dev); +@@ -397,8 +395,6 @@ static void qcom_iommu_detach_dev(struct + iommu_writel(ctx, ARM_SMMU_CB_SCTLR, 0); + } + pm_runtime_put_sync(qcom_iommu->dev); +- +- qcom_domain->iommu = NULL; + } + + static int qcom_iommu_map(struct iommu_domain *domain, unsigned long iova, diff --git a/queue-4.14/series b/queue-4.14/series index dbba9e422a8..46ecaf63c9e 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -1,3 +1,8 @@ +iommu-qcom-fix-bogus-detach-logic.patch +alsa-hda-use-scnprintf-for-printing-texts-for-sysfs-procfs.patch +asoc-sun8i-codec-fix-setting-dai-data-format.patch +ecryptfs-fix-a-memory-leak-bug-in-parse_tag_1_packet.patch +ecryptfs-fix-a-memory-leak-bug-in-ecryptfs_init_messaging.patch input-synaptics-switch-t470s-to-rmi4-by-default.patch input-synaptics-enable-smbus-on-thinkpad-l470.patch input-synaptics-remove-the-len0049-dmi-id-from-topbuttonpad-list.patch -- 2.47.3