netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2 1/7] ip/xfrm: Extend SPI validity checking
@ 2013-03-25 14:23 David Ward
  2013-03-25 14:23 ` [PATCH iproute2 2/7] ip/xfrm: Do not allow redundant algorithm combinations to be specified David Ward
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: David Ward @ 2013-03-25 14:23 UTC (permalink / raw)
  To: netdev; +Cc: David Ward

A Security Policy Index (SPI) is not used with Mobile IPv6. IPComp
uses a smaller 16-bit Compression Parameter Index (CPI) which is
passed as the SPI value. Perform checks whenever specifying an ID.

Signed-off-by: David Ward <david.ward@ll.mit.edu>
---
 ip/ipxfrm.c     |   12 ++++++++++++
 ip/xfrm_state.c |    5 -----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/ip/ipxfrm.c b/ip/ipxfrm.c
index db51918..2576938 100644
--- a/ip/ipxfrm.c
+++ b/ip/ipxfrm.c
@@ -1067,6 +1067,18 @@ int xfrm_id_parse(xfrm_address_t *saddr, struct xfrm_id *id, __u16 *family,
 	if (src.family && dst.family && (src.family != dst.family))
 		invarg("the same address family is required between \"src\" and \"dst\"", *argv);
 
+	if (id->spi && id->proto) {
+		if (xfrm_xfrmproto_is_ro(id->proto)) {
+			fprintf(stderr, "\"spi\" is invalid with XFRM-PROTO value \"%s\"\n",
+			        strxf_xfrmproto(id->proto));
+			exit(1);
+		} else if (id->proto == IPPROTO_COMP && ntohl(id->spi) >= 0x10000) {
+			fprintf(stderr, "SPI value is too large with XFRM-PROTO value \"%s\"\n",
+			        strxf_xfrmproto(id->proto));
+			exit(1);
+		}
+	}
+
 	if (loose == 0 && id->proto == 0)
 		missarg("XFRM-PROTO");
 	if (argc == *argcp)
diff --git a/ip/xfrm_state.c b/ip/xfrm_state.c
index c0cf88c..3c01ec5 100644
--- a/ip/xfrm_state.c
+++ b/ip/xfrm_state.c
@@ -502,11 +502,6 @@ static int xfrm_state_modify(int cmd, unsigned flags, int argc, char **argv)
 				strxf_xfrmproto(req.xsinfo.id.proto));
 			exit(1);
 		}
-		if (req.xsinfo.id.spi != 0) {
-			fprintf(stderr, "\"spi\" must be 0 with proto=%s\n",
-				strxf_xfrmproto(req.xsinfo.id.proto));
-			exit(1);
-		}
 		break;
 	default:
 		break;
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-03-28 21:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-25 14:23 [PATCH iproute2 1/7] ip/xfrm: Extend SPI validity checking David Ward
2013-03-25 14:23 ` [PATCH iproute2 2/7] ip/xfrm: Do not allow redundant algorithm combinations to be specified David Ward
2013-03-25 14:23 ` [PATCH iproute2 3/7] ip/xfrm: Improve transform protocol-specific parameter checking David Ward
2013-03-25 14:23 ` [PATCH iproute2 4/7] ip/xfrm: Do not print a zero-length algorithm key David Ward
2013-03-25 14:23 ` [PATCH iproute2 5/7] ip/xfrm: Command syntax should not expect a key for compression David Ward
2013-03-25 14:23 ` [PATCH iproute2 6/7] ip/xfrm: Improve usage text and documentation David Ward
2013-03-25 14:23 ` [PATCH iproute2 7/7] ip/xfrm: Improve error strings David Ward
2013-03-28 21:47   ` Stephen Hemminger
2013-03-25 15:03 ` [PATCH iproute2 1/7] ip/xfrm: Extend SPI validity checking Stephen Hemminger

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).