]> git.ipfire.org Git - thirdparty/xtables-addons.git/commitdiff
xt_SYSRQ: use SHASH_DESC_ON_STACK
authorMatt Lawson <mlawson27@live.com>
Wed, 13 Mar 2024 16:21:19 +0000 (12:21 -0400)
committerJan Engelhardt <jengelh@inai.de>
Fri, 22 Mar 2024 16:02:11 +0000 (17:02 +0100)
Similar to https://codeberg.org/jengelh/xtables-addons/issues/11, the
use of the crypto library in the xt_SYSRQ causes memory corruption
and in my case, causes the kernel to lock up.

Declaring the struct shash_desc variable using the
SHASH_DESC_ON_STACK macro appears to fix the issue at least for me.

extensions/xt_SYSRQ.c

index 6461e6d74f1c8634db9022c1bc1f865f78b68a6a..998a5b92be36e0158e67adb17292e0d84e2aac62 100644 (file)
@@ -74,7 +74,7 @@ static unsigned int sysrq_tg(const void *pdata, uint16_t len)
 {
        const char *data = pdata;
        int i, n;
-       struct shash_desc desc;
+       SHASH_DESC_ON_STACK(desc, 0);
        int ret;
        long new_seqno = 0;
 
@@ -113,16 +113,16 @@ static unsigned int sysrq_tg(const void *pdata, uint16_t len)
                return NF_DROP;
        }
 
-       desc.tfm   = sysrq_tfm;
-       ret = crypto_shash_init(&desc);
+       desc->tfm   = sysrq_tfm;
+       ret = crypto_shash_init(desc);
        if (ret != 0)
                goto hash_fail;
-       if (crypto_shash_update(&desc, data, n) != 0)
+       if (crypto_shash_update(desc, data, n) != 0)
                goto hash_fail;
-       if (crypto_shash_update(&desc, sysrq_digest_password,
+       if (crypto_shash_update(desc, sysrq_digest_password,
            strlen(sysrq_digest_password)) != 0)
                goto hash_fail;
-       if (crypto_shash_final(&desc, sysrq_digest) != 0)
+       if (crypto_shash_final(desc, sysrq_digest) != 0)
                goto hash_fail;
 
        for (i = 0; i < sysrq_digest_size; ++i) {