netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steffen Klassert <steffen.klassert@secunet.com>
To: David Miller <davem@davemloft.net>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
	Steffen Klassert <steffen.klassert@secunet.com>,
	<netdev@vger.kernel.org>
Subject: [PATCH 1/8] xfrm: make aead_len() return unsigned int
Date: Mon, 30 Oct 2017 09:39:28 +0100	[thread overview]
Message-ID: <1509352775-9563-2-git-send-email-steffen.klassert@secunet.com> (raw)
In-Reply-To: <1509352775-9563-1-git-send-email-steffen.klassert@secunet.com>

From: Alexey Dobriyan <adobriyan@gmail.com>

Key lengths can't be negative.

Comparison with nla_len() is left signed just in case negative value
can sneak in there.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 include/net/xfrm.h   | 2 +-
 net/xfrm/xfrm_user.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index f002a2c..0be4c54 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -1764,7 +1764,7 @@ static inline int xfrm_acquire_is_on(struct net *net)
 }
 #endif
 
-static inline int aead_len(struct xfrm_algo_aead *alg)
+static inline unsigned int aead_len(struct xfrm_algo_aead *alg)
 {
 	return sizeof(*alg) + ((alg->alg_key_len + 7) / 8);
 }
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 2bfbd91..32c67b8 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -84,7 +84,7 @@ static int verify_aead(struct nlattr **attrs)
 		return 0;
 
 	algp = nla_data(rt);
-	if (nla_len(rt) < aead_len(algp))
+	if (nla_len(rt) < (int)aead_len(algp))
 		return -EINVAL;
 
 	algp->alg_name[sizeof(algp->alg_name) - 1] = '\0';
-- 
2.7.4

  reply	other threads:[~2017-10-30  8:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-30  8:39 pull request (net-next): ipsec-next 2017-10-30 Steffen Klassert
2017-10-30  8:39 ` Steffen Klassert [this message]
2017-10-30  8:39 ` [PATCH 2/8] xfrm: make xfrm_alg_len() return unsigned int Steffen Klassert
2017-10-30  8:39 ` [PATCH 3/8] xfrm: make xfrm_alg_auth_len() " Steffen Klassert
2017-10-30  8:39 ` [PATCH 4/8] xfrm: make xfrm_replay_state_esn_len() " Steffen Klassert
2017-10-30  8:39 ` [PATCH 5/8] xfrm: eradicate size_t Steffen Klassert
2017-10-30  8:39 ` [PATCH 6/8] esp6: remove redundant initialization of esph Steffen Klassert
2017-10-30  8:39 ` [PATCH 7/8] net: xfrm_user: use BUG_ON instead of if condition followed by BUG Steffen Klassert
2017-10-30  8:39 ` [PATCH 8/8] ipv6: esp6: " Steffen Klassert
2017-11-01  3:17 ` pull request (net-next): ipsec-next 2017-10-30 David Miller

Reply instructions:

You may reply publicly 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=1509352775-9563-2-git-send-email-steffen.klassert@secunet.com \
    --to=steffen.klassert@secunet.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=netdev@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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).