netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: YueHaibing <yuehaibing@huawei.com>,
	Steffen Klassert <steffen.klassert@secunet.com>,
	Sasha Levin <sashal@kernel.org>,
	netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 4.9 066/107] xfrm6_tunnel: Fix spi check in __xfrm6_tunnel_alloc_spi
Date: Mon, 28 Jan 2019 11:19:06 -0500	[thread overview]
Message-ID: <20190128161947.57405-66-sashal@kernel.org> (raw)
In-Reply-To: <20190128161947.57405-1-sashal@kernel.org>

From: YueHaibing <yuehaibing@huawei.com>

[ Upstream commit fa89a4593b927b3f59c3b69379f31d3b22272e4e ]

gcc warn this:

net/ipv6/xfrm6_tunnel.c:143 __xfrm6_tunnel_alloc_spi() warn:
 always true condition '(spi <= 4294967295) => (0-u32max <= u32max)'

'spi' is u32, which always not greater than XFRM6_TUNNEL_SPI_MAX
because of wrap around. So the second forloop will never reach.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/ipv6/xfrm6_tunnel.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c
index e1c0bbe7996c..3a2701d42f47 100644
--- a/net/ipv6/xfrm6_tunnel.c
+++ b/net/ipv6/xfrm6_tunnel.c
@@ -144,6 +144,9 @@ static u32 __xfrm6_tunnel_alloc_spi(struct net *net, xfrm_address_t *saddr)
 		index = __xfrm6_tunnel_spi_check(net, spi);
 		if (index >= 0)
 			goto alloc_spi;
+
+		if (spi == XFRM6_TUNNEL_SPI_MAX)
+			break;
 	}
 	for (spi = XFRM6_TUNNEL_SPI_MIN; spi < xfrm6_tn->spi; spi++) {
 		index = __xfrm6_tunnel_spi_check(net, spi);
-- 
2.19.1


  parent reply	other threads:[~2019-01-28 16:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190128161947.57405-1-sashal@kernel.org>
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 005/107] ath9k: dynack: use authentication messages for 'late' ack Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 015/107] ptp: check gettime64 return code in PTP_SYS_OFFSET ioctl Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 065/107] mac80211: fix radiotap vendor presence bitmap handling Sasha Levin
2019-01-28 16:19 ` Sasha Levin [this message]
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 067/107] Bluetooth: Fix unnecessary error message for HCI request completion Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 070/107] cw1200: Fix concurrency use-after-free bugs in cw1200_hw_scan() Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 077/107] i40e: define proper net_device::neigh_priv_len Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 078/107] igb: Fix an issue that PME is not enabled during runtime suspend Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 092/107] niu: fix missing checks of niu_pci_eeprom_read Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 097/107] isdn: hisax: hfc_pci: Fix a possible concurrency use-after-free bug in HFCPCI_l1hw() Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 099/107] fsl/fman: Use GFP_ATOMIC in {memac,tgec}_add_hash_mac_address() Sasha Levin

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=20190128161947.57405-66-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=steffen.klassert@secunet.com \
    --cc=yuehaibing@huawei.com \
    /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).