Netfilter-Devel Archive on lore.kernel.org
 help / color / Atom feed
From: Jeremy Sowden <jeremy@azazel.net>
To: Jan Engelhardt <jengelh@inai.de>
Cc: "Netfilter Devel" <netfilter-devel@vger.kernel.org>,
	"Franta Hanzlík" <franta@hanzlici.cz>
Subject: Re: [PATCH xtables-addons v2 1/2] xt_pknock, xt_SYSRQ: don't set shash_desc::flags.
Date: Mon, 12 Aug 2019 17:57:31 +0100
Message-ID: <20190812165731.GC5190@azazel.net> (raw)
In-Reply-To: <nycvar.YFH.7.76.1908122317330.19510@n3.vanv.qr>

[-- Attachment #1.1: Type: text/plain, Size: 1632 bytes --]

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@azazel.net>
> >---
> > 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.

[-- Attachment #1.2: 0001-xt_pknock-xt_SYSRQ-don-t-set-shash_desc-flags.patch --]
[-- Type: text/x-diff, Size: 2001 bytes --]

From ea440005076686ba946da433049d4e68c4672984 Mon Sep 17 00:00:00 2001
From: Jeremy Sowden <jeremy@azazel.net>
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@azazel.net>
---
 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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply index

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-11  9:40 xtables addons build on 5.2.6 ends with error: 'struct shash_desc' has no member named 'flags' Franta Hanzlík
2019-08-11 12:42 ` Jeremy Sowden
2019-08-11 13:16 ` [PATCH xtables-addons 1/2] xt_pknock, xt_SYSRQ: don't set shash_desc::flags Jeremy Sowden
2019-08-11 13:16   ` [PATCH xtables-addons 2/2] xt_DHCPMAC: replaced skb_make_writable with skb_ensure_writable Jeremy Sowden
2019-08-11 18:42     ` Florian Westphal
2019-08-12 11:06       ` Jeremy Sowden
2019-08-12 11:57 ` [PATCH xtables-addons v2 0/2] Kernel API updates Jeremy Sowden
2019-08-12 11:57   ` [PATCH xtables-addons v2 1/2] xt_pknock, xt_SYSRQ: don't set shash_desc::flags Jeremy Sowden
2019-08-12 15:17     ` Jan Engelhardt
2019-08-12 16:57       ` Jeremy Sowden [this message]
2019-08-19 19:34         ` Franta Hanzlík
2019-09-01 17:04           ` Jeremy Sowden
2019-09-06  8:38     ` Jan Engelhardt
2019-08-12 11:57   ` [PATCH xtables-addons v2 2/2] xt_DHCPMAC: replaced skb_make_writable with skb_ensure_writable Jeremy Sowden
2019-08-12 14:54   ` [PATCH xtables-addons v2 0/2] Kernel API updates Jeremy Sowden

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190812165731.GC5190@azazel.net \
    --to=jeremy@azazel.net \
    --cc=franta@hanzlici.cz \
    --cc=jengelh@inai.de \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Netfilter-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/netfilter-devel/0 netfilter-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netfilter-devel netfilter-devel/ https://lore.kernel.org/netfilter-devel \
		netfilter-devel@vger.kernel.org netfilter-devel@archiver.kernel.org
	public-inbox-index netfilter-devel


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.netfilter-devel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox