From 3286203a008cee5b08ea763309eee587e80539b9 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 14 Apr 2020 13:49:27 +0200 Subject: [PATCH] 5.6-stable patches added patches: erofs-correct-the-remaining-shrink-objects.patch keys-reaching-the-keys-quotas-correctly.patch mmc-mmci_sdmmc-fix-clear-busyd0end-irq-flag.patch sched-fair-fix-enqueue_task_fair-warning.patch tpm-don-t-make-log-failures-fatal.patch tpm-tpm1_bios_measurements_next-should-increase-position-index.patch tpm-tpm2_bios_measurements_next-should-increase-position-index.patch --- ...correct-the-remaining-shrink-objects.patch | 34 +++++++ ...s-reaching-the-keys-quotas-correctly.patch | 67 ++++++++++++++ ...i_sdmmc-fix-clear-busyd0end-irq-flag.patch | 40 ++++++++ ...d-fair-fix-enqueue_task_fair-warning.patch | 91 ++++++++++++++++++ queue-5.6/series | 7 ++ .../tpm-don-t-make-log-failures-fatal.patch | 92 +++++++++++++++++++ ..._next-should-increase-position-index.patch | 49 ++++++++++ ..._next-should-increase-position-index.patch | 48 ++++++++++ 8 files changed, 428 insertions(+) create mode 100644 queue-5.6/erofs-correct-the-remaining-shrink-objects.patch create mode 100644 queue-5.6/keys-reaching-the-keys-quotas-correctly.patch create mode 100644 queue-5.6/mmc-mmci_sdmmc-fix-clear-busyd0end-irq-flag.patch create mode 100644 queue-5.6/sched-fair-fix-enqueue_task_fair-warning.patch create mode 100644 queue-5.6/tpm-don-t-make-log-failures-fatal.patch create mode 100644 queue-5.6/tpm-tpm1_bios_measurements_next-should-increase-position-index.patch create mode 100644 queue-5.6/tpm-tpm2_bios_measurements_next-should-increase-position-index.patch diff --git a/queue-5.6/erofs-correct-the-remaining-shrink-objects.patch b/queue-5.6/erofs-correct-the-remaining-shrink-objects.patch new file mode 100644 index 00000000000..3786c067580 --- /dev/null +++ b/queue-5.6/erofs-correct-the-remaining-shrink-objects.patch @@ -0,0 +1,34 @@ +From 9d5a09c6f3b5fb85af20e3a34827b5d27d152b34 Mon Sep 17 00:00:00 2001 +From: Gao Xiang +Date: Wed, 26 Feb 2020 16:10:06 +0800 +Subject: erofs: correct the remaining shrink objects + +From: Gao Xiang + +commit 9d5a09c6f3b5fb85af20e3a34827b5d27d152b34 upstream. + +The remaining count should not include successful +shrink attempts. + +Fixes: e7e9a307be9d ("staging: erofs: introduce workstation for decompression") +Cc: # 4.19+ +Link: https://lore.kernel.org/r/20200226081008.86348-1-gaoxiang25@huawei.com +Reviewed-by: Chao Yu +Signed-off-by: Gao Xiang +Signed-off-by: Greg Kroah-Hartman + +--- + fs/erofs/utils.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/fs/erofs/utils.c ++++ b/fs/erofs/utils.c +@@ -286,7 +286,7 @@ static unsigned long erofs_shrink_scan(s + spin_unlock(&erofs_sb_list_lock); + sbi->shrinker_run_no = run_no; + +- freed += erofs_shrink_workstation(sbi, nr); ++ freed += erofs_shrink_workstation(sbi, nr - freed); + + spin_lock(&erofs_sb_list_lock); + /* Get the next list element before we move this one */ diff --git a/queue-5.6/keys-reaching-the-keys-quotas-correctly.patch b/queue-5.6/keys-reaching-the-keys-quotas-correctly.patch new file mode 100644 index 00000000000..19928705079 --- /dev/null +++ b/queue-5.6/keys-reaching-the-keys-quotas-correctly.patch @@ -0,0 +1,67 @@ +From 2e356101e72ab1361821b3af024d64877d9a798d Mon Sep 17 00:00:00 2001 +From: Yang Xu +Date: Fri, 28 Feb 2020 12:41:51 +0800 +Subject: KEYS: reaching the keys quotas correctly + +From: Yang Xu + +commit 2e356101e72ab1361821b3af024d64877d9a798d upstream. + +Currently, when we add a new user key, the calltrace as below: + +add_key() + key_create_or_update() + key_alloc() + __key_instantiate_and_link + generic_key_instantiate + key_payload_reserve + ...... + +Since commit a08bf91ce28e ("KEYS: allow reaching the keys quotas exactly"), +we can reach max bytes/keys in key_alloc, but we forget to remove this +limit when we reserver space for payload in key_payload_reserve. So we +can only reach max keys but not max bytes when having delta between plen +and type->def_datalen. Remove this limit when instantiating the key, so we +can keep consistent with key_alloc. + +Also, fix the similar problem in keyctl_chown_key(). + +Fixes: 0b77f5bfb45c ("keys: make the keyring quotas controllable through /proc/sys") +Fixes: a08bf91ce28e ("KEYS: allow reaching the keys quotas exactly") +Cc: stable@vger.kernel.org # 5.0.x +Cc: Eric Biggers +Signed-off-by: Yang Xu +Reviewed-by: Jarkko Sakkinen +Reviewed-by: Eric Biggers +Signed-off-by: Jarkko Sakkinen +Signed-off-by: Greg Kroah-Hartman + +--- + security/keys/key.c | 2 +- + security/keys/keyctl.c | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +--- a/security/keys/key.c ++++ b/security/keys/key.c +@@ -382,7 +382,7 @@ int key_payload_reserve(struct key *key, + spin_lock(&key->user->lock); + + if (delta > 0 && +- (key->user->qnbytes + delta >= maxbytes || ++ (key->user->qnbytes + delta > maxbytes || + key->user->qnbytes + delta < key->user->qnbytes)) { + ret = -EDQUOT; + } +--- a/security/keys/keyctl.c ++++ b/security/keys/keyctl.c +@@ -937,8 +937,8 @@ long keyctl_chown_key(key_serial_t id, u + key_quota_root_maxbytes : key_quota_maxbytes; + + spin_lock(&newowner->lock); +- if (newowner->qnkeys + 1 >= maxkeys || +- newowner->qnbytes + key->quotalen >= maxbytes || ++ if (newowner->qnkeys + 1 > maxkeys || ++ newowner->qnbytes + key->quotalen > maxbytes || + newowner->qnbytes + key->quotalen < + newowner->qnbytes) + goto quota_overrun; diff --git a/queue-5.6/mmc-mmci_sdmmc-fix-clear-busyd0end-irq-flag.patch b/queue-5.6/mmc-mmci_sdmmc-fix-clear-busyd0end-irq-flag.patch new file mode 100644 index 00000000000..45983797bef --- /dev/null +++ b/queue-5.6/mmc-mmci_sdmmc-fix-clear-busyd0end-irq-flag.patch @@ -0,0 +1,40 @@ +From d4a384cb563e555ce00255f5f496b503e6cc6358 Mon Sep 17 00:00:00 2001 +From: Ludovic Barre +Date: Wed, 25 Mar 2020 15:34:08 +0100 +Subject: mmc: mmci_sdmmc: Fix clear busyd0end irq flag + +From: Ludovic Barre + +commit d4a384cb563e555ce00255f5f496b503e6cc6358 upstream. + +The busyd0 line transition can be very fast. The busy request may be +completed by busy_d0end, without waiting for the busy_d0 steps. Therefore, +clear the busyd0end irq flag, even if no busy_status. + +Fixes: 0e68de6aa7b1 ("mmc: mmci: sdmmc: add busy_complete callback") +Cc: stable@vger.kernel.org +Signed-off-by: Ludovic Barre +Link: https://lore.kernel.org/r/20200325143409.13005-2-ludovic.barre@st.com +Signed-off-by: Ulf Hansson +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/mmc/host/mmci_stm32_sdmmc.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/mmc/host/mmci_stm32_sdmmc.c ++++ b/drivers/mmc/host/mmci_stm32_sdmmc.c +@@ -315,11 +315,11 @@ complete: + if (host->busy_status) { + writel_relaxed(mask & ~host->variant->busy_detect_mask, + base + MMCIMASK0); +- writel_relaxed(host->variant->busy_detect_mask, +- base + MMCICLEAR); + host->busy_status = 0; + } + ++ writel_relaxed(host->variant->busy_detect_mask, base + MMCICLEAR); ++ + return true; + } + diff --git a/queue-5.6/sched-fair-fix-enqueue_task_fair-warning.patch b/queue-5.6/sched-fair-fix-enqueue_task_fair-warning.patch new file mode 100644 index 00000000000..baf895d197f --- /dev/null +++ b/queue-5.6/sched-fair-fix-enqueue_task_fair-warning.patch @@ -0,0 +1,91 @@ +From fe61468b2cbc2b7ce5f8d3bf32ae5001d4c434e9 Mon Sep 17 00:00:00 2001 +From: Vincent Guittot +Date: Fri, 6 Mar 2020 14:52:57 +0100 +Subject: sched/fair: Fix enqueue_task_fair warning + +From: Vincent Guittot + +commit fe61468b2cbc2b7ce5f8d3bf32ae5001d4c434e9 upstream. + +When a cfs rq is throttled, the latter and its child are removed from the +leaf list but their nr_running is not changed which includes staying higher +than 1. When a task is enqueued in this throttled branch, the cfs rqs must +be added back in order to ensure correct ordering in the list but this can +only happens if nr_running == 1. +When cfs bandwidth is used, we call unconditionnaly list_add_leaf_cfs_rq() +when enqueuing an entity to make sure that the complete branch will be +added. + +Similarly unthrottle_cfs_rq() can stop adding cfs in the list when a parent +is throttled. Iterate the remaining entity to ensure that the complete +branch will be added in the list. + +Reported-by: Christian Borntraeger +Signed-off-by: Vincent Guittot +Signed-off-by: Peter Zijlstra (Intel) +Reviewed-by: Dietmar Eggemann +Tested-by: Christian Borntraeger +Tested-by: Dietmar Eggemann +Cc: stable@vger.kernel.org +Cc: stable@vger.kernel.org #v5.1+ +Link: https://lkml.kernel.org/r/20200306135257.25044-1-vincent.guittot@linaro.org +Signed-off-by: Greg Kroah-Hartman + +--- + kernel/sched/fair.c | 26 ++++++++++++++++++++++---- + 1 file changed, 22 insertions(+), 4 deletions(-) + +--- a/kernel/sched/fair.c ++++ b/kernel/sched/fair.c +@@ -3957,6 +3957,7 @@ static inline void check_schedstat_requi + #endif + } + ++static inline bool cfs_bandwidth_used(void); + + /* + * MIGRATION +@@ -4035,10 +4036,16 @@ enqueue_entity(struct cfs_rq *cfs_rq, st + __enqueue_entity(cfs_rq, se); + se->on_rq = 1; + +- if (cfs_rq->nr_running == 1) { ++ /* ++ * When bandwidth control is enabled, cfs might have been removed ++ * because of a parent been throttled but cfs->nr_running > 1. Try to ++ * add it unconditionnally. ++ */ ++ if (cfs_rq->nr_running == 1 || cfs_bandwidth_used()) + list_add_leaf_cfs_rq(cfs_rq); ++ ++ if (cfs_rq->nr_running == 1) + check_enqueue_throttle(cfs_rq); +- } + } + + static void __clear_buddies_last(struct sched_entity *se) +@@ -4619,11 +4626,22 @@ void unthrottle_cfs_rq(struct cfs_rq *cf + break; + } + +- assert_list_leaf_cfs_rq(rq); +- + if (!se) + add_nr_running(rq, task_delta); + ++ /* ++ * The cfs_rq_throttled() breaks in the above iteration can result in ++ * incomplete leaf list maintenance, resulting in triggering the ++ * assertion below. ++ */ ++ for_each_sched_entity(se) { ++ cfs_rq = cfs_rq_of(se); ++ ++ list_add_leaf_cfs_rq(cfs_rq); ++ } ++ ++ assert_list_leaf_cfs_rq(rq); ++ + /* Determine whether we need to wake up potentially idle CPU: */ + if (rq->curr == rq->idle && rq->cfs.nr_running) + resched_curr(rq); diff --git a/queue-5.6/series b/queue-5.6/series index e082bfd046d..3413ab1852b 100644 --- a/queue-5.6/series +++ b/queue-5.6/series @@ -101,3 +101,10 @@ pci-aspm-clear-the-correct-bits-when-enabling-l1-substates.patch pci-add-boot-interrupt-quirk-mechanism-for-xeon-chipsets.patch pci-qcom-fix-the-fixup-of-pci_vendor_id_qcom.patch pci-endpoint-fix-for-concurrent-memory-allocation-in-ob-address-region.patch +erofs-correct-the-remaining-shrink-objects.patch +sched-fair-fix-enqueue_task_fair-warning.patch +tpm-don-t-make-log-failures-fatal.patch +tpm-tpm1_bios_measurements_next-should-increase-position-index.patch +tpm-tpm2_bios_measurements_next-should-increase-position-index.patch +keys-reaching-the-keys-quotas-correctly.patch +mmc-mmci_sdmmc-fix-clear-busyd0end-irq-flag.patch diff --git a/queue-5.6/tpm-don-t-make-log-failures-fatal.patch b/queue-5.6/tpm-don-t-make-log-failures-fatal.patch new file mode 100644 index 00000000000..fc9b6bdf450 --- /dev/null +++ b/queue-5.6/tpm-don-t-make-log-failures-fatal.patch @@ -0,0 +1,92 @@ +From 805fa88e0780b7ce1cc9b649dd91a0a7164c6eb4 Mon Sep 17 00:00:00 2001 +From: Matthew Garrett +Date: Thu, 2 Jan 2020 13:55:18 -0800 +Subject: tpm: Don't make log failures fatal + +From: Matthew Garrett + +commit 805fa88e0780b7ce1cc9b649dd91a0a7164c6eb4 upstream. + +If a TPM is in disabled state, it's reasonable for it to have an empty +log. Bailing out of probe in this case means that the PPI interface +isn't available, so there's no way to then enable the TPM from the OS. +In general it seems reasonable to ignore log errors - they shouldn't +interfere with any other TPM functionality. + +Signed-off-by: Matthew Garrett +Cc: stable@vger.kernel.org # 4.19.x +Reviewed-by: Jerry Snitselaar +Reviewed-by: Jarkko Sakkinen +Signed-off-by: Jarkko Sakkinen +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/char/tpm/eventlog/common.c | 12 ++++-------- + drivers/char/tpm/tpm-chip.c | 4 +--- + drivers/char/tpm/tpm.h | 2 +- + 3 files changed, 6 insertions(+), 12 deletions(-) + +--- a/drivers/char/tpm/eventlog/common.c ++++ b/drivers/char/tpm/eventlog/common.c +@@ -99,11 +99,8 @@ static int tpm_read_log(struct tpm_chip + * + * If an event log is found then the securityfs files are setup to + * export it to userspace, otherwise nothing is done. +- * +- * Returns -ENODEV if the firmware has no event log or securityfs is not +- * supported. + */ +-int tpm_bios_log_setup(struct tpm_chip *chip) ++void tpm_bios_log_setup(struct tpm_chip *chip) + { + const char *name = dev_name(&chip->dev); + unsigned int cnt; +@@ -112,7 +109,7 @@ int tpm_bios_log_setup(struct tpm_chip * + + rc = tpm_read_log(chip); + if (rc < 0) +- return rc; ++ return; + log_version = rc; + + cnt = 0; +@@ -158,13 +155,12 @@ int tpm_bios_log_setup(struct tpm_chip * + cnt++; + } + +- return 0; ++ return; + + err: +- rc = PTR_ERR(chip->bios_dir[cnt]); + chip->bios_dir[cnt] = NULL; + tpm_bios_log_teardown(chip); +- return rc; ++ return; + } + + void tpm_bios_log_teardown(struct tpm_chip *chip) +--- a/drivers/char/tpm/tpm-chip.c ++++ b/drivers/char/tpm/tpm-chip.c +@@ -596,9 +596,7 @@ int tpm_chip_register(struct tpm_chip *c + + tpm_sysfs_add_device(chip); + +- rc = tpm_bios_log_setup(chip); +- if (rc != 0 && rc != -ENODEV) +- return rc; ++ tpm_bios_log_setup(chip); + + tpm_add_ppi(chip); + +--- a/drivers/char/tpm/tpm.h ++++ b/drivers/char/tpm/tpm.h +@@ -235,7 +235,7 @@ int tpm2_prepare_space(struct tpm_chip * + int tpm2_commit_space(struct tpm_chip *chip, struct tpm_space *space, void *buf, + size_t *bufsiz); + +-int tpm_bios_log_setup(struct tpm_chip *chip); ++void tpm_bios_log_setup(struct tpm_chip *chip); + void tpm_bios_log_teardown(struct tpm_chip *chip); + int tpm_dev_common_init(void); + void tpm_dev_common_exit(void); diff --git a/queue-5.6/tpm-tpm1_bios_measurements_next-should-increase-position-index.patch b/queue-5.6/tpm-tpm1_bios_measurements_next-should-increase-position-index.patch new file mode 100644 index 00000000000..b3afe206237 --- /dev/null +++ b/queue-5.6/tpm-tpm1_bios_measurements_next-should-increase-position-index.patch @@ -0,0 +1,49 @@ +From d7a47b96ed1102551eb7325f97937e276fb91045 Mon Sep 17 00:00:00 2001 +From: Vasily Averin +Date: Tue, 25 Feb 2020 09:26:08 +0300 +Subject: tpm: tpm1_bios_measurements_next should increase position index + +From: Vasily Averin + +commit d7a47b96ed1102551eb7325f97937e276fb91045 upstream. + +If .next function does not change position index, +following .show function will repeat output related +to current position index. + +In case of /sys/kernel/security/tpm0/ascii_bios_measurements +and binary_bios_measurements: +1) read after lseek beyound end of file generates whole last line. +2) read after lseek to middle of last line generates +expected end of last line and unexpected whole last line once again. + +Cc: stable@vger.kernel.org # 4.19.x +Fixes: 1f4aace60b0e ("fs/seq_file.c: simplify seq_file iteration code ...") +Link: https://bugzilla.kernel.org/show_bug.cgi?id=206283 +Signed-off-by: Vasily Averin +Reviewed-by: Jarkko Sakkinen +Signed-off-by: Jarkko Sakkinen +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/char/tpm/eventlog/tpm1.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/char/tpm/eventlog/tpm1.c ++++ b/drivers/char/tpm/eventlog/tpm1.c +@@ -115,6 +115,7 @@ static void *tpm1_bios_measurements_next + u32 converted_event_size; + u32 converted_event_type; + ++ (*pos)++; + converted_event_size = do_endian_conversion(event->event_size); + + v += sizeof(struct tcpa_event) + converted_event_size; +@@ -132,7 +133,6 @@ static void *tpm1_bios_measurements_next + ((v + sizeof(struct tcpa_event) + converted_event_size) > limit)) + return NULL; + +- (*pos)++; + return v; + } + diff --git a/queue-5.6/tpm-tpm2_bios_measurements_next-should-increase-position-index.patch b/queue-5.6/tpm-tpm2_bios_measurements_next-should-increase-position-index.patch new file mode 100644 index 00000000000..0716cd7d252 --- /dev/null +++ b/queue-5.6/tpm-tpm2_bios_measurements_next-should-increase-position-index.patch @@ -0,0 +1,48 @@ +From f9bf8adb55cd5a357b247a16aafddf8c97b276e0 Mon Sep 17 00:00:00 2001 +From: Vasily Averin +Date: Tue, 25 Feb 2020 09:26:22 +0300 +Subject: tpm: tpm2_bios_measurements_next should increase position index + +From: Vasily Averin + +commit f9bf8adb55cd5a357b247a16aafddf8c97b276e0 upstream. + +If .next function does not change position index, +following .show function will repeat output related +to current position index. + +For /sys/kernel/security/tpm0/binary_bios_measurements: +1) read after lseek beyound end of file generates whole last line. +2) read after lseek to middle of last line generates +expected end of last line and unexpected whole last line once again. + +Cc: stable@vger.kernel.org # 4.19.x +Fixes: 1f4aace60b0e ("fs/seq_file.c: simplify seq_file iteration code ...") +Link: https://bugzilla.kernel.org/show_bug.cgi?id=206283 +Signed-off-by: Vasily Averin +Reviewed-by: Jarkko Sakkinen +Signed-off-by: Jarkko Sakkinen +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/char/tpm/eventlog/tpm2.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/char/tpm/eventlog/tpm2.c ++++ b/drivers/char/tpm/eventlog/tpm2.c +@@ -94,6 +94,7 @@ static void *tpm2_bios_measurements_next + size_t event_size; + void *marker; + ++ (*pos)++; + event_header = log->bios_event_log; + + if (v == SEQ_START_TOKEN) { +@@ -118,7 +119,6 @@ static void *tpm2_bios_measurements_next + if (((v + event_size) >= limit) || (event_size == 0)) + return NULL; + +- (*pos)++; + return v; + } + -- 2.47.3