Re: [PATCH xtables-addons v2 1/2] xt_pknock, xt_SYSRQ: don't set shash_desc::flags.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2019-08-12, at 23:17:52 +0800, Jan Engelhardt wrote:
> On Monday 2019-08-12 19:57, Jeremy Sowden wrote:
> >shash_desc::flags was removed from the kernel in 5.1.
> >
> >Signed-off-by: Jeremy Sowden <jeremy@xxxxxxxxxx>
> >---
> > extensions/pknock/xt_pknock.c | 1 -
> > extensions/xt_SYSRQ.c         | 1 -
> > 2 files changed, 2 deletions(-)
> >
> >diff --git a/extensions/pknock/xt_pknock.c b/extensions/pknock/xt_pknock.c
> >index c76901ac4c1a..8021ea07e1b9 100644
> >--- a/extensions/pknock/xt_pknock.c
> >+++ b/extensions/pknock/xt_pknock.c
> >@@ -1125,7 +1125,6 @@ static int __init xt_pknock_mt_init(void)
> >
> > 	crypto.size = crypto_shash_digestsize(crypto.tfm);
> > 	crypto.desc.tfm = crypto.tfm;
> >-	crypto.desc.flags = 0;
>
> But this will still be needed for 5.0 I guess, so it cannot just be
> unconditionally removed.

That assignment was actually superfluous anyway, because crypto.desc is
zero-initialized when crypto is initialized (xt_pknock.c, ll. 110ff.):

  static struct {
          const char *algo;
          struct crypto_shash *tfm;
          unsigned int size;
          struct shash_desc desc;
  } crypto = {
          .algo	= "hmac(sha256)",
          .tfm	= NULL,
          .size	= 0
  };

In fact the explicit zero-initialization of .tfm and .size is also
superfluous and can be removed:

  static struct {
          const char *algo;
          struct crypto_shash *tfm;
          unsigned int size;
          struct shash_desc desc;
  } crypto = {
          .algo	= "hmac(sha256)",
  };

Adding an initializer to the variable declaration in xt_SYSRQ.c will do
the same thing.  Patch attached.

J.
From ea440005076686ba946da433049d4e68c4672984 Mon Sep 17 00:00:00 2001
From: Jeremy Sowden <jeremy@xxxxxxxxxx>
Date: Sun, 11 Aug 2019 14:08:42 +0100
Subject: [PATCH] xt_pknock, xt_SYSRQ: don't set shash_desc::flags.

shash_desc::flags was removed from the kernel in 5.1, so removed the
explicit assignment of zero to it.

In the case of xt_pknock.c, the change is backwards-compatible because
the shash_desc was already zero-initialized when the enclosing crypto
struct was initialized.  In the case of xt_SYSRQ.c, we add an
initializer for the shash_desc which will ensure that all members which
are not explicitly initialized will be initialized to zero, including
.flags in the case of older kernels.

Signed-off-by: Jeremy Sowden <jeremy@xxxxxxxxxx>
---
 extensions/pknock/xt_pknock.c | 1 -
 extensions/xt_SYSRQ.c         | 4 +---
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/extensions/pknock/xt_pknock.c b/extensions/pknock/xt_pknock.c
index c76901ac4c1a..8021ea07e1b9 100644
--- a/extensions/pknock/xt_pknock.c
+++ b/extensions/pknock/xt_pknock.c
@@ -1125,7 +1125,6 @@ static int __init xt_pknock_mt_init(void)
 
 	crypto.size = crypto_shash_digestsize(crypto.tfm);
 	crypto.desc.tfm = crypto.tfm;
-	crypto.desc.flags = 0;
 
 	pde = proc_mkdir("xt_pknock", init_net.proc_net);
 	if (pde == NULL) {
diff --git a/extensions/xt_SYSRQ.c b/extensions/xt_SYSRQ.c
index c386c7e2db5d..f04bd2cdc0f2 100644
--- a/extensions/xt_SYSRQ.c
+++ b/extensions/xt_SYSRQ.c
@@ -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;
+	struct shash_desc desc = { .tfm = sysrq_tfm };
 	int ret;
 	long new_seqno = 0;
 
@@ -113,8 +113,6 @@ static unsigned int sysrq_tg(const void *pdata, uint16_t len)
 		return NF_DROP;
 	}
 
-	desc.tfm   = sysrq_tfm;
-	desc.flags = 0;
 	ret = crypto_shash_init(&desc);
 	if (ret != 0)
 		goto hash_fail;
-- 
2.20.1

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux