BugLink: https://bugs.launchpad.net/bugs/1775165
[Note to upstream]
I understand that this patch is a little long for -stable, but this patch series
fixes a real issue, seen by real users, is testable, and is made up from
upstream commits. Please consider it.
[Impact]
When userspace tasks which are processing fanotify permission events act
incorrectly, the fsnotify_mark_srcu SRCU is held indefinitely which causes
the whole notification subsystem to hang.
This has been seen in production, and it can also be seen when running the
Linux Test Project testsuite, specifically fanotify07.
[Fix]
Instead of holding the SRCU lock while waiting for userspace to respond,
which may never happen, or not in the order we are expecting, we drop the
fsnotify_mark_srcu SRCU lock before waiting for userspace response, and then
reacquire the lock again when userspace responds.
The fixes are from a series of upstream commits:
05f0e38724e8449184acd8fbf0473ee5a07adc6c (cherry-pick)
9385a84d7e1f658bb2d96ab798393e4b16268aaa (backport)
abc77577a669f424c5d0c185b9994f2621c52aa4 (backport)
The following are upstream commits necessary for the fixes to function:
35e481761cdc688dbee0ef552a13f49af8eba6cc (backport)
0918f1c309b86301605650c836ddd2021d311ae2 (cherry-pick)
[Testcase]
You can reproduce the problem pretty quickly with the Linux Test Project:
Steps (with root):
1. sudo apt-get install git xfsprogs -y
2. git clone --depth=1 https://github.com/linux-test-project/ltp.git
3. cd ltp
4. make autotools
5. ./configure
6. make; make install
7. cd /opt/ltp
8. echo -e "fanotify07 fanotify07 \nfanotify08 fanotify08" > /tmp/jobs
9. ./runltp -f /tmp/jobs
On a stock Xenial kernel, the system will hang, and the testcase will look like:
<<<test_start>>>
tag=fanotify07 stime=1554326200
cmdline="fanotify07 "
contacts=""
analysis=exit
<<<test_output>>>
tst_test.c:1096: INFO: Timeout per run is 0h 05m 00s
Test timeouted, sending SIGKILL!
Test timeouted, sending SIGKILL!
Test timeouted, sending SIGKILL!
Test timeouted, sending SIGKILL!
Test timeouted, sending SIGKILL!
Test timeouted, sending SIGKILL!
Test timeouted, sending SIGKILL!
Test timeouted, sending SIGKILL!
Test timeouted, sending SIGKILL!
Test timeouted, sending SIGKILL!
Test timeouted, sending SIGKILL!
Cannot kill test processes!
Congratulation, likely test hit a kernel bug.
Exitting uncleanly...
<<<execution_status>>>
initiation_status="ok"
duration=350 termination_type=exited termination_id=1 corefile=no
cutime=0 cstime=0
<<<test_end>>>
Looking at dmesg, we see the following call stack
[ 790.772792] LTP: starting fanotify07 (fanotify07 )
[ 960.140455] INFO: task fsnotify_mark:36 blocked for more than 120 seconds.
[ 960.140867] Not tainted 4.4.0-142-generic #168-Ubuntu
[ 960.141185] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 960.141498] fsnotify_mark D ffff8800b6703c98 0 36 2 0x00000000
[ 960.141516] ffff8800b6703c98 ffff88013a558a00 ffff8800b7797000 ffff8800b66f8000
[ 960.141524] ffff8800b6704000 7fffffffffffffff ffff8800b6703de0 ffff8800b66f8000
[ 960.141528] 0000000000000000 ffff8800b6703cb0 ffffffff8185cb45 ffff8800b6703de8
[ 960.141532] Call Trace:
[ 960.141580] [<ffffffff8185cb45>] schedule+0x35/0x80
[ 960.141588] [<ffffffff818600f4>] schedule_timeout+0x1b4/0x270
[ 960.141617] [<ffffffff810f57ac>] ? mod_timer+0x10c/0x240
[ 960.141621] [<ffffffff8185c60d>] ? __schedule+0x30d/0x810
[ 960.141625] [<ffffffff8185d652>] wait_for_completion+0xb2/0x190
[ 960.141636] [<ffffffff810b1f10>] ? wake_up_q+0x70/0x70
[ 960.141641] [<ffffffff810eb140>] __synchronize_srcu+0x100/0x1a0
[ 960.141645] [<ffffffff810ea400>] ? trace_raw_output_rcu_utilization+0x60/0x60
[ 960.141664] [<ffffffff81260870>] ? fsnotify_put_mark+0x40/0x40
[ 960.141669] [<ffffffff810eb204>] synchronize_srcu+0x24/0x30
[ 960.141672] [<ffffffff812608f4>] fsnotify_mark_destroy+0x84/0x130
[ 960.141680] [<ffffffff810ca000>] ? wake_atomic_t_function+0x60/0x60
[ 960.141691] [<ffffffff810a6227>] kthread+0xe7/0x100
[ 960.141694] [<ffffffff8185c601>] ? __schedule+0x301/0x810
[ 960.141699] [<ffffffff810a6140>] ? kthread_create_on_node+0x1e0/0x1e0
[ 960.141703] [<ffffffff818618e5>] ret_from_fork+0x55/0x80
[ 960.141706] [<ffffffff810a6140>] ? kthread_create_on_node+0x1e0/0x1e0
The vanilla 4.4 kernel also shows the same call stack.
On a patched kernel, the test will pass successfully, and there will be no
messages in dmesg.
[Regression Potential]
This makes modifications to how locking is performed in fsnotify / fanotify and
there may be some cause for regression. Running all fanotify Linux Test Project
tests shows that there are no extra failures caused by the patches, and instead
fewer failures are seen due to the bugfix.
Running the entire Linux Test Project testsuite actually works and runs to
completion, something which doesn't happen in a unpatched kernel since it will
hang on the fanotify07 test.
The patches are taken from upstream, and all necessary commits have been taken
into account, so I am happy with the potential risks and that testing has been
completed.
Jan Kara (4):
fsnotify: avoid spurious EMFILE errors from inotify_init()
fsnotify: Provide framework for dropping SRCU lock in ->handle_event
fsnotify: Pass fsnotify_iter_info into handle_event handler
fanotify: Release SRCU lock when waiting for userspace response
Jeff Layton (1):
fsnotify: turn fsnotify reaper thread into a workqueue job
fs/notify/dnotify/dnotify.c | 3 +-
fs/notify/fanotify/fanotify.c | 20 ++-
fs/notify/fsnotify.c | 19 ++-
fs/notify/fsnotify.h | 13 ++
fs/notify/group.c | 18 ++-
fs/notify/inotify/inotify.h | 3 +-
fs/notify/inotify/inotify_fsnotify.c | 3 +-
fs/notify/inotify/inotify_user.c | 2 +-
fs/notify/mark.c | 194 +++++++++++++++++++++------
include/linux/fsnotify_backend.h | 10 +-
kernel/audit_fsnotify.c | 3 +-
kernel/audit_tree.c | 3 +-
kernel/audit_watch.c | 3 +-
13 files changed, 230 insertions(+), 64 deletions(-)
--
2.19.1
Hi,
On Wed, Apr 10, 2019 at 4:20 PM Sasha Levin <sashal(a)kernel.org> wrote:
>
> Hi,
>
> [This is an automated email]
>
> This commit has been processed because it contains a -stable tag.
> The stable tag indicates that it's relevant for the following trees: all
>
> The bot has tested the following trees: v5.0.7, v4.19.34, v4.14.111, v4.9.168, v4.4.178, v3.18.138.
>
> v5.0.7: Build OK!
> v4.19.34: Build OK!
> v4.14.111: Build OK!
> v4.9.168: Failed to apply! Possible dependencies:
> 0f21c58c63ad ("mmc: dw_mmc: Remove the public dw_mmc header file")
> 1f5c51d76e8f ("mmc: dw_mmc: disable biu clk if possible")
> 32dba73772f8 ("mmc: dw_mmc: Convert to use MMC_CAP2_SDIO_IRQ_NOTHREAD for SDIO IRQs")
> 58870241a674 ("mmc: dw_mmc: remove the loop about finding slots")
> a4cc7eb4416f ("mmc: dw_mmc: use the cookie's enum values for post/pre_req()")
> ca8971ca5753 ("mmc: dw_mmc: Prevent runtime PM suspend when SDIO IRQs are enabled")
> d30a8f7bdf64 ("mmc: dw_mmc: deprecated the "num-slots" property")
> df9bcc2bc0a1 ("mmc: dw_mmc: add missing codes for runtime resume")
> e9748e0364fe ("mmc: dw_mmc: force setup bus if active slots exist")
> e9ed8835e990 ("mmc: dw_mmc: add runtime PM callback")
> ed24e1ff5ae3 ("mmc: dw_mmc: remove system PM callback")
> f90142683f04 ("mmc: dw_mmc-rockchip: add runtime PM support")
>
> v4.4.178: Failed to apply! Possible dependencies:
> 01a999e48995 ("mmc: dw_mmc: remove the unused quirks")
> 267b62a96951 ("clk: tegra: pll: Update PLLM handling")
> 287980e49ffc ("remove lots of IS_ERR_VALUE abuses")
> 32dba73772f8 ("mmc: dw_mmc: Convert to use MMC_CAP2_SDIO_IRQ_NOTHREAD for SDIO IRQs")
> 3706b43629f5 ("clk: tegra: pll: Don't unconditionally set LOCK flags")
> 407254da291c ("clk: tegra: pll: Add logic for out-of-table rates for T210")
> 58870241a674 ("mmc: dw_mmc: remove the loop about finding slots")
> 6583a6309e83 ("clk: tegra: pll: Add tegra_pll_wait_for_lock to clk header")
> 6929715cf6b9 ("clk: tegra: pll: Add support for PLLMB for Tegra210")
> 6b301a059eb2 ("clk: tegra: Add support for Tegra210 clocks")
> 7db864c9deb2 ("clk: tegra: pll: Simplify clk_enable_path")
> 86c679a52294 ("clk: tegra: pll: Fix _pll_ramp_calc_pll logic and _calc_dynamic_ramp_rate")
> 8cfb0cdf07e2 ("ACPI / debugger: Add IO interface to access debugger functionalities")
> 8d99704fde54 ("clk: tegra: Format tables consistently")
> c4947e364b50 ("clk: tegra: Fix 26 MHz oscillator frequency")
> ca8971ca5753 ("mmc: dw_mmc: Prevent runtime PM suspend when SDIO IRQs are enabled")
> d907f4b4a178 ("clk: tegra: pll: Add logic for handling SDM data")
> dd322f047d22 ("clk: tegra: pll: Add specialized logic for Tegra210")
> e52d7c04bb39 ("clk: tegra: Miscellaneous coding style cleanups")
> e8cc37b8fc3a ("mmc: dw_mmc: remove DW_MCI_QUIRK_BROKEN_CARD_DETECTION quirk")
> f8d31489629c ("ACPICA: Debugger: Convert some mechanisms to OSPM specific")
>
> v3.18.138: Failed to apply! Possible dependencies:
> 1a25b1b4199c ("mmc: dw_mmc: fix the max_blk_count in IDMAC")
> 2b708df2b3ed ("mmc: dw_mmc: remove the unused blk_setting")
> 32dba73772f8 ("mmc: dw_mmc: Convert to use MMC_CAP2_SDIO_IRQ_NOTHREAD for SDIO IRQs")
> 575c319dfe87 ("mmc: dw_mmc: fix pio mode when internal dmac is enabled")
> 58870241a674 ("mmc: dw_mmc: remove the loop about finding slots")
> 5959b32e3636 ("mmc: dw_mmc: handle data blocks > than 4kB if IDMAC is used")
> 6130e7a9c34d ("mmc: dw_mmc: Remove old card detect infrastructure")
> 6687c42fa71a ("mmc: dw_mmc: change idmac descriptor files to __le32")
> 69d99fdcfd78 ("mmc: dw_mmc: Add IDMAC 64-bit address mode support")
> 767562348b72 ("mmc: dw_mmc: add support for the other bit of sdio interrupt")
> b24c8b260189 ("mmc: dw_mmc: Cleanup disable of low power mode w/ SDIO interrupts")
> ca8971ca5753 ("mmc: dw_mmc: Prevent runtime PM suspend when SDIO IRQs are enabled")
> ed2540effa70 ("mmc: dw_mmc: Don't crash if we get an interrupt before slot has initted")
> f8c58c113634 ("mmc: dw_mmc: Protect read-modify-write of INTMASK with a lock")
> fa0c328343c6 ("mmc: dw_mmc: Only enable CD after setup and only if needed")
>
>
> How should we proceed with this patch?
This is discussed "after the cut" in my commit message. The
low-hanging fruit is to just pick it to 5.0 and 4.19. If folks are
interested I can spin a 4.14 build back up again and test the patch
there, but likely if it applies / builds then it'll just work. For
older that 4.14 I'd say to just drop this but an interested party
could try if they really wanted. Given (for me) ~1/3 of my
suspend/resumes were failing presumably anyone on an old kernel has
already come up with some sort of solution themselves.
Hrm, I guess I could have just added a versioning tag to my "Cc".
I'll do that next time.
I guess first we should see if MMC maintainers think the patch looks OK.
-Doug
From: Eric Biggers <ebiggers(a)google.com>
If the user-provided IV needs to be aligned to the algorithm's
alignmask, then skcipher_walk_virt() copies the IV into a new aligned
buffer walk.iv. But skcipher_walk_virt() can fail afterwards, and then
if the caller unconditionally accesses walk.iv, it's a use-after-free.
arm32 xts-aes-neonbs doesn't set an alignmask, so currently it isn't
affected by this despite unconditionally accessing walk.iv. However
this is more subtle than desired, and it was actually broken prior to
the alignmask being removed by commit cc477bf64573 ("crypto: arm/aes -
replace bit-sliced OpenSSL NEON code"). Thus, update xts-aes-neonbs to
start checking the return value of skcipher_walk_virt().
Fixes: e4e7f10bfc40 ("ARM: add support for bit sliced AES using NEON instructions")
Cc: <stable(a)vger.kernel.org> # v3.13+
Signed-off-by: Eric Biggers <ebiggers(a)google.com>
---
arch/arm/crypto/aes-neonbs-glue.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/arm/crypto/aes-neonbs-glue.c b/arch/arm/crypto/aes-neonbs-glue.c
index 07e31941dc674..617c2c99ebfb3 100644
--- a/arch/arm/crypto/aes-neonbs-glue.c
+++ b/arch/arm/crypto/aes-neonbs-glue.c
@@ -278,6 +278,8 @@ static int __xts_crypt(struct skcipher_request *req,
int err;
err = skcipher_walk_virt(&walk, req, true);
+ if (err)
+ return err;
crypto_cipher_encrypt_one(ctx->tweak_tfm, walk.iv, walk.iv);
--
2.21.0
From: Eric Biggers <ebiggers(a)google.com>
GCM instances can be created by either the "gcm" template, which only
allows choosing the block cipher, e.g. "gcm(aes)"; or by "gcm_base",
which allows choosing the ctr and ghash implementations, e.g.
"gcm_base(ctr(aes-generic),ghash-generic)".
However, a "gcm_base" instance prevents a "gcm" instance from being
registered using the same implementations. Nor will the instance be
found by lookups of "gcm". This can be used as a denial of service.
Moreover, "gcm_base" instances are never tested by the crypto
self-tests, even if there are compatible "gcm" tests.
The root cause of these problems is that instances of the two templates
use different cra_names. Therefore, fix these problems by making
"gcm_base" instances set the same cra_name as "gcm" instances, e.g.
"gcm(aes)" instead of "gcm_base(ctr(aes-generic),ghash-generic)".
This requires extracting the block cipher name from the name of the ctr
algorithm. It also requires starting to verify that the algorithms are
really ctr and ghash, not something else entirely. But it would be
bizarre if anyone were actually using non-gcm-compatible algorithms with
gcm_base, so this shouldn't break anyone in practice.
Fixes: d00aa19b507b ("[CRYPTO] gcm: Allow block cipher parameter")
Cc: stable(a)vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers(a)google.com>
---
crypto/gcm.c | 32 +++++++++-----------------------
1 file changed, 9 insertions(+), 23 deletions(-)
diff --git a/crypto/gcm.c b/crypto/gcm.c
index e1a11f529d257..c7354ed1fa4d4 100644
--- a/crypto/gcm.c
+++ b/crypto/gcm.c
@@ -597,7 +597,6 @@ static void crypto_gcm_free(struct aead_instance *inst)
static int crypto_gcm_create_common(struct crypto_template *tmpl,
struct rtattr **tb,
- const char *full_name,
const char *ctr_name,
const char *ghash_name)
{
@@ -638,7 +637,7 @@ static int crypto_gcm_create_common(struct crypto_template *tmpl,
goto err_free_inst;
err = -EINVAL;
- if (ghash->digestsize != 16)
+ if (strcmp(ghash->base.cra_name, "ghash") != 0)
goto err_drop_ghash;
crypto_set_skcipher_spawn(&ctx->ctr, aead_crypto_instance(inst));
@@ -650,24 +649,23 @@ static int crypto_gcm_create_common(struct crypto_template *tmpl,
ctr = crypto_spawn_skcipher_alg(&ctx->ctr);
- /* We only support 16-byte blocks. */
+ /* The skcipher algorithm must be CTR mode, using 16-byte blocks. */
err = -EINVAL;
- if (crypto_skcipher_alg_ivsize(ctr) != 16)
+ if (strncmp(ctr->base.cra_name, "ctr(", 4) != 0 ||
+ crypto_skcipher_alg_ivsize(ctr) != 16)
goto out_put_ctr;
- /* Not a stream cipher? */
- if (ctr->base.cra_blocksize != 1)
+ err = -ENAMETOOLONG;
+ if (snprintf(inst->alg.base.cra_name, CRYPTO_MAX_ALG_NAME,
+ "gcm(%s", ctr->base.cra_name + 4) >= CRYPTO_MAX_ALG_NAME)
goto out_put_ctr;
- err = -ENAMETOOLONG;
if (snprintf(inst->alg.base.cra_driver_name, CRYPTO_MAX_ALG_NAME,
"gcm_base(%s,%s)", ctr->base.cra_driver_name,
ghash_alg->cra_driver_name) >=
CRYPTO_MAX_ALG_NAME)
goto out_put_ctr;
- memcpy(inst->alg.base.cra_name, full_name, CRYPTO_MAX_ALG_NAME);
-
inst->alg.base.cra_flags = (ghash->base.cra_flags |
ctr->base.cra_flags) & CRYPTO_ALG_ASYNC;
inst->alg.base.cra_priority = (ghash->base.cra_priority +
@@ -709,7 +707,6 @@ static int crypto_gcm_create(struct crypto_template *tmpl, struct rtattr **tb)
{
const char *cipher_name;
char ctr_name[CRYPTO_MAX_ALG_NAME];
- char full_name[CRYPTO_MAX_ALG_NAME];
cipher_name = crypto_attr_alg_name(tb[1]);
if (IS_ERR(cipher_name))
@@ -719,12 +716,7 @@ static int crypto_gcm_create(struct crypto_template *tmpl, struct rtattr **tb)
CRYPTO_MAX_ALG_NAME)
return -ENAMETOOLONG;
- if (snprintf(full_name, CRYPTO_MAX_ALG_NAME, "gcm(%s)", cipher_name) >=
- CRYPTO_MAX_ALG_NAME)
- return -ENAMETOOLONG;
-
- return crypto_gcm_create_common(tmpl, tb, full_name,
- ctr_name, "ghash");
+ return crypto_gcm_create_common(tmpl, tb, ctr_name, "ghash");
}
static int crypto_gcm_base_create(struct crypto_template *tmpl,
@@ -732,7 +724,6 @@ static int crypto_gcm_base_create(struct crypto_template *tmpl,
{
const char *ctr_name;
const char *ghash_name;
- char full_name[CRYPTO_MAX_ALG_NAME];
ctr_name = crypto_attr_alg_name(tb[1]);
if (IS_ERR(ctr_name))
@@ -742,12 +733,7 @@ static int crypto_gcm_base_create(struct crypto_template *tmpl,
if (IS_ERR(ghash_name))
return PTR_ERR(ghash_name);
- if (snprintf(full_name, CRYPTO_MAX_ALG_NAME, "gcm_base(%s,%s)",
- ctr_name, ghash_name) >= CRYPTO_MAX_ALG_NAME)
- return -ENAMETOOLONG;
-
- return crypto_gcm_create_common(tmpl, tb, full_name,
- ctr_name, ghash_name);
+ return crypto_gcm_create_common(tmpl, tb, ctr_name, ghash_name);
}
static int crypto_rfc4106_setkey(struct crypto_aead *parent, const u8 *key,
--
2.21.0
From: Eric Biggers <ebiggers(a)google.com>
CCM instances can be created by either the "ccm" template, which only
allows choosing the block cipher, e.g. "ccm(aes)"; or by "ccm_base",
which allows choosing the ctr and cbcmac implementations, e.g.
"ccm_base(ctr(aes-generic),cbcmac(aes-generic))".
However, a "ccm_base" instance prevents a "ccm" instance from being
registered using the same implementations. Nor will the instance be
found by lookups of "ccm". This can be used as a denial of service.
Moreover, "ccm_base" instances are never tested by the crypto
self-tests, even if there are compatible "ccm" tests.
The root cause of these problems is that instances of the two templates
use different cra_names. Therefore, fix these problems by making
"ccm_base" instances set the same cra_name as "ccm" instances, e.g.
"ccm(aes)" instead of "ccm_base(ctr(aes-generic),cbcmac(aes-generic))".
This requires extracting the block cipher name from the name of the ctr
and cbcmac algorithms. It also requires starting to verify that the
algorithms are really ctr and cbcmac using the same block cipher, not
something else entirely. But it would be bizarre if anyone were
actually using non-ccm-compatible algorithms with ccm_base, so this
shouldn't break anyone in practice.
Fixes: 4a49b499dfa0 ("[CRYPTO] ccm: Added CCM mode")
Cc: stable(a)vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers(a)google.com>
---
crypto/ccm.c | 43 +++++++++++++++++--------------------------
1 file changed, 17 insertions(+), 26 deletions(-)
diff --git a/crypto/ccm.c b/crypto/ccm.c
index 50df8f001c1c9..dbb3b6d8e6136 100644
--- a/crypto/ccm.c
+++ b/crypto/ccm.c
@@ -458,7 +458,6 @@ static void crypto_ccm_free(struct aead_instance *inst)
static int crypto_ccm_create_common(struct crypto_template *tmpl,
struct rtattr **tb,
- const char *full_name,
const char *ctr_name,
const char *mac_name)
{
@@ -486,7 +485,8 @@ static int crypto_ccm_create_common(struct crypto_template *tmpl,
mac = __crypto_hash_alg_common(mac_alg);
err = -EINVAL;
- if (mac->digestsize != 16)
+ if (strncmp(mac->base.cra_name, "cbcmac(", 7) != 0 ||
+ mac->digestsize != 16)
goto out_put_mac;
inst = kzalloc(sizeof(*inst) + sizeof(*ictx), GFP_KERNEL);
@@ -509,23 +509,26 @@ static int crypto_ccm_create_common(struct crypto_template *tmpl,
ctr = crypto_spawn_skcipher_alg(&ictx->ctr);
- /* Not a stream cipher? */
+ /* The skcipher algorithm must be CTR mode, using 16-byte blocks. */
err = -EINVAL;
- if (ctr->base.cra_blocksize != 1)
+ if (strncmp(ctr->base.cra_name, "ctr(", 4) != 0 ||
+ crypto_skcipher_alg_ivsize(ctr) != 16)
goto err_drop_ctr;
- /* We want the real thing! */
- if (crypto_skcipher_alg_ivsize(ctr) != 16)
+ /* ctr and cbcmac must use the same underlying block cipher. */
+ if (strcmp(ctr->base.cra_name + 4, mac->base.cra_name + 7) != 0)
goto err_drop_ctr;
err = -ENAMETOOLONG;
+ if (snprintf(inst->alg.base.cra_name, CRYPTO_MAX_ALG_NAME,
+ "ccm(%s", ctr->base.cra_name + 4) >= CRYPTO_MAX_ALG_NAME)
+ goto err_drop_ctr;
+
if (snprintf(inst->alg.base.cra_driver_name, CRYPTO_MAX_ALG_NAME,
"ccm_base(%s,%s)", ctr->base.cra_driver_name,
mac->base.cra_driver_name) >= CRYPTO_MAX_ALG_NAME)
goto err_drop_ctr;
- memcpy(inst->alg.base.cra_name, full_name, CRYPTO_MAX_ALG_NAME);
-
inst->alg.base.cra_flags = ctr->base.cra_flags & CRYPTO_ALG_ASYNC;
inst->alg.base.cra_priority = (mac->base.cra_priority +
ctr->base.cra_priority) / 2;
@@ -567,7 +570,6 @@ static int crypto_ccm_create(struct crypto_template *tmpl, struct rtattr **tb)
const char *cipher_name;
char ctr_name[CRYPTO_MAX_ALG_NAME];
char mac_name[CRYPTO_MAX_ALG_NAME];
- char full_name[CRYPTO_MAX_ALG_NAME];
cipher_name = crypto_attr_alg_name(tb[1]);
if (IS_ERR(cipher_name))
@@ -581,35 +583,24 @@ static int crypto_ccm_create(struct crypto_template *tmpl, struct rtattr **tb)
cipher_name) >= CRYPTO_MAX_ALG_NAME)
return -ENAMETOOLONG;
- if (snprintf(full_name, CRYPTO_MAX_ALG_NAME, "ccm(%s)", cipher_name) >=
- CRYPTO_MAX_ALG_NAME)
- return -ENAMETOOLONG;
-
- return crypto_ccm_create_common(tmpl, tb, full_name, ctr_name,
- mac_name);
+ return crypto_ccm_create_common(tmpl, tb, ctr_name, mac_name);
}
static int crypto_ccm_base_create(struct crypto_template *tmpl,
struct rtattr **tb)
{
const char *ctr_name;
- const char *cipher_name;
- char full_name[CRYPTO_MAX_ALG_NAME];
+ const char *mac_name;
ctr_name = crypto_attr_alg_name(tb[1]);
if (IS_ERR(ctr_name))
return PTR_ERR(ctr_name);
- cipher_name = crypto_attr_alg_name(tb[2]);
- if (IS_ERR(cipher_name))
- return PTR_ERR(cipher_name);
-
- if (snprintf(full_name, CRYPTO_MAX_ALG_NAME, "ccm_base(%s,%s)",
- ctr_name, cipher_name) >= CRYPTO_MAX_ALG_NAME)
- return -ENAMETOOLONG;
+ mac_name = crypto_attr_alg_name(tb[2]);
+ if (IS_ERR(mac_name))
+ return PTR_ERR(mac_name);
- return crypto_ccm_create_common(tmpl, tb, full_name, ctr_name,
- cipher_name);
+ return crypto_ccm_create_common(tmpl, tb, ctr_name, mac_name);
}
static int crypto_rfc4309_setkey(struct crypto_aead *parent, const u8 *key,
--
2.21.0
From: Eric Biggers <ebiggers(a)google.com>
If the user-provided IV needs to be aligned to the algorithm's
alignmask, then skcipher_walk_virt() copies the IV into a new aligned
buffer walk.iv. But skcipher_walk_virt() can fail afterwards, and then
if the caller unconditionally accesses walk.iv, it's a use-after-free.
salsa20-generic doesn't set an alignmask, so currently it isn't affected
by this despite unconditionally accessing walk.iv. However this is more
subtle than desired, and it was actually broken prior to the alignmask
being removed by commit b62b3db76f73 ("crypto: salsa20-generic - cleanup
and convert to skcipher API").
Since salsa20-generic does not update the IV and does not need any IV
alignment, update it to use req->iv instead of walk.iv.
Fixes: 2407d60872dd ("[CRYPTO] salsa20: Salsa20 stream cipher")
Cc: stable(a)vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers(a)google.com>
---
crypto/salsa20_generic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/crypto/salsa20_generic.c b/crypto/salsa20_generic.c
index 443fba09cbed7..faed244be316f 100644
--- a/crypto/salsa20_generic.c
+++ b/crypto/salsa20_generic.c
@@ -160,7 +160,7 @@ static int salsa20_crypt(struct skcipher_request *req)
err = skcipher_walk_virt(&walk, req, false);
- salsa20_init(state, ctx, walk.iv);
+ salsa20_init(state, ctx, req->iv);
while (walk.nbytes > 0) {
unsigned int nbytes = walk.nbytes;
--
2.21.0
From: Eric Biggers <ebiggers(a)google.com>
If the user-provided IV needs to be aligned to the algorithm's
alignmask, then skcipher_walk_virt() copies the IV into a new aligned
buffer walk.iv. But skcipher_walk_virt() can fail afterwards, and then
if the caller unconditionally accesses walk.iv, it's a use-after-free.
xts-aes-neonbs doesn't set an alignmask, so currently it isn't affected
by this despite unconditionally accessing walk.iv. However this is more
subtle than desired, and unconditionally accessing walk.iv has caused a
real problem in other algorithms. Thus, update xts-aes-neonbs to start
checking the return value of skcipher_walk_virt().
Fixes: 1abee99eafab ("crypto: arm64/aes - reimplement bit-sliced ARM/NEON implementation for arm64")
Cc: <stable(a)vger.kernel.org> # v4.11+
Signed-off-by: Eric Biggers <ebiggers(a)google.com>
---
arch/arm64/crypto/aes-neonbs-glue.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/arm64/crypto/aes-neonbs-glue.c b/arch/arm64/crypto/aes-neonbs-glue.c
index 4737b6c6c5cf5..5144551177334 100644
--- a/arch/arm64/crypto/aes-neonbs-glue.c
+++ b/arch/arm64/crypto/aes-neonbs-glue.c
@@ -304,6 +304,8 @@ static int __xts_crypt(struct skcipher_request *req,
int err;
err = skcipher_walk_virt(&walk, req, false);
+ if (err)
+ return err;
kernel_neon_begin();
neon_aes_ecb_encrypt(walk.iv, walk.iv, ctx->twkey, ctx->key.rounds, 1);
--
2.21.0
Hello,
We ran automated tests on a patchset that was proposed for merging into this
kernel tree. The patches were applied to:
Kernel repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Commit: 8b298d3a0bd5 - Linux 5.0.7
The results of these automated tests are provided below.
Overall result: PASSED
Merge: OK
Compile: OK
Tests: OK
Please reply to this email if you have any questions about the tests that we
ran or if you have any suggestions on how to make future tests more effective.
,-. ,-.
( C ) ( K ) Continuous
`-',-.`-' Kernel
( I ) Integration
`-'
______________________________________________________________________________
Merge testing
-------------
We cloned this repository and checked out a ref:
Repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Ref: 8b298d3a0bd5 - Linux 5.0.7
We then merged the patchset with `git am`:
drm-i915-gvt-do-not-let-pin-count-of-shadow-mm-go-ne.patch
kbuild-pkg-use-f-srctree-makefile-to-recurse-to-top-.patch
netfilter-nft_compat-use-.release_ops-and-remove-lis.patch
netfilter-nf_tables-use-after-free-in-dynamic-operat.patch
netfilter-nf_tables-add-missing-release_ops-in-error.patch
hv_netvsc-fix-unwanted-wakeup-after-tx_disable.patch
ibmvnic-fix-completion-structure-initialization.patch
ip6_tunnel-match-to-arphrd_tunnel6-for-dev-type.patch
ipv6-fix-dangling-pointer-when-ipv6-fragment.patch
ipv6-sit-reset-ip-header-pointer-in-ipip6_rcv.patch
kcm-switch-order-of-device-registration-to-fix-a-cra.patch
net-ethtool-not-call-vzalloc-for-zero-sized-memory-r.patch
net-gro-fix-gro-flush-when-receiving-a-gso-packet.patch
net-mlx5-decrease-default-mr-cache-size.patch
netns-provide-pure-entropy-for-net_hash_mix.patch
net-rds-force-to-destroy-connection-if-t_sock-is-nul.patch
net-sched-act_sample-fix-divide-by-zero-in-the-traff.patch
net-sched-fix-get-helper-of-the-matchall-cls.patch
openvswitch-fix-flow-actions-reallocation.patch
qmi_wwan-add-olicard-600.patch
r8169-disable-aspm-again.patch
sctp-initialize-_pad-of-sockaddr_in-before-copying-t.patch
tcp-ensure-dctcp-reacts-to-losses.patch
tcp-fix-a-potential-null-pointer-dereference-in-tcp_.patch
vrf-check-accept_source_route-on-the-original-netdev.patch
net-mlx5e-fix-error-handling-when-refreshing-tirs.patch
net-mlx5e-add-a-lock-on-tir-list.patch
nfp-validate-the-return-code-from-dev_queue_xmit.patch
nfp-disable-netpoll-on-representors.patch
bnxt_en-improve-rx-consumer-index-validity-check.patch
bnxt_en-reset-device-on-rx-buffer-errors.patch
net-ip_gre-fix-possible-use-after-free-in-erspan_rcv.patch
net-ip6_gre-fix-possible-use-after-free-in-ip6erspan.patch
net-bridge-always-clear-mcast-matching-struct-on-rep.patch
net-thunderx-fix-null-pointer-dereference-in-nicvf_o.patch
net-vrf-fix-ping-failed-when-vrf-mtu-is-set-to-0.patch
net-core-netif_receive_skb_list-unlist-skb-before-pa.patch
r8169-disable-default-rx-interrupt-coalescing-on-rtl.patch
net-mlx5-add-a-missing-check-on-idr_find-free-buf.patch
net-mlx5e-update-xoff-formula.patch
net-mlx5e-update-xon-formula.patch
Compile testing
---------------
We compiled the kernel for 3 architectures:
aarch64:
make options: -j20 INSTALL_MOD_STRIP=1 targz-pkg
configuration: https://artifacts.cki-project.org/builds/aarch64/kernel-stable_queue-aarch6…
kernel build: https://artifacts.cki-project.org/builds/aarch64/kernel-stable_queue-aarch6…
ppc64le:
make options: -j20 INSTALL_MOD_STRIP=1 targz-pkg
configuration: https://artifacts.cki-project.org/builds/ppc64le/kernel-stable_queue-ppc64l…
kernel build: https://artifacts.cki-project.org/builds/ppc64le/kernel-stable_queue-ppc64l…
x86_64:
make options: -j20 INSTALL_MOD_STRIP=1 targz-pkg
configuration: https://artifacts.cki-project.org/builds/x86_64/kernel-stable_queue-x86_64-…
kernel build: https://artifacts.cki-project.org/builds/x86_64/kernel-stable_queue-x86_64-…
Hardware testing
----------------
We booted each kernel and ran the following tests:
aarch64:
✅ Boot test [0]
✅ /kernel/distribution/ltp/lite
✅ AMTU (Abstract Machine Test Utility) [1]
🚧 ✅ audit: audit testsuite test [2]
✅ httpd: mod_ssl smoke sanity [3]
✅ httpd: php sanity [4]
🚧 ✅ iotop: sanity [5]
🚧 ✅ /CoreOS/net-snmp/Regression/bz251332-tcp-transport
🚧 ✅ tuned: tune-processes-through-perf [6]
🚧 ✅ stress: stress-ng [7]
ppc64le:
✅ Boot test [0]
✅ /kernel/distribution/ltp/lite
✅ AMTU (Abstract Machine Test Utility) [1]
🚧 ✅ audit: audit testsuite test [2]
✅ httpd: mod_ssl smoke sanity [3]
✅ httpd: php sanity [4]
🚧 ✅ iotop: sanity [5]
🚧 ✅ /CoreOS/net-snmp/Regression/bz251332-tcp-transport
🚧 ✅ selinux-policy: serge-testsuite [8]
🚧 ✅ tuned: tune-processes-through-perf [6]
🚧 ✅ stress: stress-ng [7]
x86_64:
✅ Boot test [0]
✅ /kernel/distribution/ltp/lite
✅ AMTU (Abstract Machine Test Utility) [1]
🚧 ✅ audit: audit testsuite test [2]
✅ httpd: mod_ssl smoke sanity [3]
✅ httpd: php sanity [4]
🚧 ✅ iotop: sanity [5]
🚧 ✅ /CoreOS/net-snmp/Regression/bz251332-tcp-transport
🚧 ✅ selinux-policy: serge-testsuite [8]
🚧 ✅ tuned: tune-processes-through-perf [6]
🚧 ✅ stress: stress-ng [7]
Test source:
[0]: https://github.com/CKI-project/tests-beaker/archive/master.zip#distribution…
[1]: https://github.com/CKI-project/tests-beaker/archive/master.zip#misc/amtu
[2]: https://github.com/CKI-project/tests-beaker/archive/master.zip#packages/aud…
[3]: https://github.com/CKI-project/tests-beaker/archive/master.zip#packages/htt…
[4]: https://github.com/CKI-project/tests-beaker/archive/master.zip#packages/htt…
[5]: https://github.com/CKI-project/tests-beaker/archive/master.zip#packages/iot…
[6]: https://github.com/CKI-project/tests-beaker/archive/master.zip#packages/tun…
[7]: https://github.com/CKI-project/tests-beaker/archive/master.zip#stress/stres…
[8]: https://github.com/CKI-project/tests-beaker/archive/master.zip#/packages/se…
Waived tests (marked with 🚧)
-----------------------------
This test run included waived tests. Such tests are executed but their results
are not taken into account. Tests are waived when their results are not
reliable enough, e.g. when they're just introduced or are being fixed.
Commit 7769db588384 ("drm/i915/dp: optimize eDP 1.4+ link config fast
and narrow") started to optize the eDP 1.4+ link config, both per spec
and as preparation for display stream compression support.
Sadly, we again face panels that flat out fail with parameters they
claim to support. Revert, and go back to the drawing board.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=109959
Fixes: 7769db588384 ("drm/i915/dp: optimize eDP 1.4+ link config fast and narrow")
Cc: Ville Syrjälä <ville.syrjala(a)linux.intel.com>
Cc: Manasi Navare <manasi.d.navare(a)intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi(a)intel.com>
Cc: Matt Atwood <matthew.s.atwood(a)intel.com>
Cc: "Lee, Shawn C" <shawn.c.lee(a)intel.com>
Cc: Dave Airlie <airlied(a)gmail.com>
Cc: intel-gfx(a)lists.freedesktop.org
Cc: <stable(a)vger.kernel.org> # v5.0+
Signed-off-by: Jani Nikula <jani.nikula(a)intel.com>
---
drivers/gpu/drm/i915/intel_dp.c | 67 +++++----------------------------
1 file changed, 9 insertions(+), 58 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 72c490..fd0f53 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -1856,42 +1856,6 @@ intel_dp_compute_link_config_wide(struct intel_dp *intel_dp,
return -EINVAL;
}
-/* Optimize link config in order: max bpp, min lanes, min clock */
-static int
-intel_dp_compute_link_config_fast(struct intel_dp *intel_dp,
- struct intel_crtc_state *pipe_config,
- const struct link_config_limits *limits)
-{
- struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode;
- int bpp, clock, lane_count;
- int mode_rate, link_clock, link_avail;
-
- for (bpp = limits->max_bpp; bpp >= limits->min_bpp; bpp -= 2 * 3) {
- mode_rate = intel_dp_link_required(adjusted_mode->crtc_clock,
- bpp);
-
- for (lane_count = limits->min_lane_count;
- lane_count <= limits->max_lane_count;
- lane_count <<= 1) {
- for (clock = limits->min_clock; clock <= limits->max_clock; clock++) {
- link_clock = intel_dp->common_rates[clock];
- link_avail = intel_dp_max_data_rate(link_clock,
- lane_count);
-
- if (mode_rate <= link_avail) {
- pipe_config->lane_count = lane_count;
- pipe_config->pipe_bpp = bpp;
- pipe_config->port_clock = link_clock;
-
- return 0;
- }
- }
- }
- }
-
- return -EINVAL;
-}
-
static int intel_dp_dsc_compute_bpp(struct intel_dp *intel_dp, u8 dsc_max_bpc)
{
int i, num_bpc;
@@ -2031,12 +1995,10 @@ intel_dp_compute_link_config(struct intel_encoder *encoder,
if (intel_dp_is_edp(intel_dp) && intel_dp->edp_dpcd[0] < DP_EDP_14) {
/*
* Use the maximum clock and number of lanes the eDP panel
- * advertizes being capable of. The eDP 1.3 and earlier panels
- * are generally designed to support only a single clock and
- * lane configuration, and typically these values correspond to
- * the native resolution of the panel. With eDP 1.4 rate select
- * and DSC, this is decreasingly the case, and we need to be
- * able to select less than maximum link config.
+ * advertizes being capable of. The panels are generally
+ * designed to support only a single clock and lane
+ * configuration, and typically these values correspond to the
+ * native resolution of the panel.
*/
limits.min_lane_count = limits.max_lane_count;
limits.min_clock = limits.max_clock;
@@ -2050,22 +2012,11 @@ intel_dp_compute_link_config(struct intel_encoder *encoder,
intel_dp->common_rates[limits.max_clock],
limits.max_bpp, adjusted_mode->crtc_clock);
- if (intel_dp_is_edp(intel_dp))
- /*
- * Optimize for fast and narrow. eDP 1.3 section 3.3 and eDP 1.4
- * section A.1: "It is recommended that the minimum number of
- * lanes be used, using the minimum link rate allowed for that
- * lane configuration."
- *
- * Note that we use the max clock and lane count for eDP 1.3 and
- * earlier, and fast vs. wide is irrelevant.
- */
- ret = intel_dp_compute_link_config_fast(intel_dp, pipe_config,
- &limits);
- else
- /* Optimize for slow and wide. */
- ret = intel_dp_compute_link_config_wide(intel_dp, pipe_config,
- &limits);
+ /*
+ * Optimize for slow and wide. This is the place to add alternative
+ * optimization policy.
+ */
+ ret = intel_dp_compute_link_config_wide(intel_dp, pipe_config, &limits);
/* enable compression if the mode doesn't fit available BW */
DRM_DEBUG_KMS("Force DSC en = %d\n", intel_dp->force_dsc_en);
--
2.20.1