netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ip/xfrm: Fix deleteall when having many policies installed
@ 2017-01-16 14:09 Alexander Heinlein
  2017-01-17 16:44 ` Stephen Hemminger
  2017-01-18 17:03 ` Stephen Hemminger
  0 siblings, 2 replies; 6+ messages in thread
From: Alexander Heinlein @ 2017-01-16 14:09 UTC (permalink / raw)
  To: netdev; +Cc: shemminger

Fix "Policy buffer overflow" error when trying to use deleteall with
many policies installed.

Signed-off-by: Alexander Heinlein <alexander.heinlein@secunet.com>
---
 ip/xfrm_policy.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/ip/xfrm_policy.c b/ip/xfrm_policy.c
index cc9c0f1..451b982 100644
--- a/ip/xfrm_policy.c
+++ b/ip/xfrm_policy.c
@@ -732,10 +732,8 @@ static int xfrm_policy_keep(const struct
sockaddr_nl *who,
 	if (!xfrm_policy_filter_match(xpinfo, ptype))
 		return 0;

-	if (xb->offset > xb->size) {
-		fprintf(stderr, "Policy buffer overflow\n");
-		return -1;
-	}
+	if (xb->offset + NLMSG_LENGTH(sizeof(*xpid)) > xb->size)
+		return 0;

 	new_n = (struct nlmsghdr *)(xb->buf + xb->offset);
 	new_n->nlmsg_len = NLMSG_LENGTH(sizeof(*xpid));
-- 
2.1.4

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

end of thread, other threads:[~2017-01-20 17:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-16 14:09 [PATCH] ip/xfrm: Fix deleteall when having many policies installed Alexander Heinlein
2017-01-17 16:44 ` Stephen Hemminger
2017-01-18  8:00   ` Alexander Heinlein
2017-01-18 17:03 ` Stephen Hemminger
2017-01-19  7:57   ` Alexander Heinlein
2017-01-20 17:22     ` 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).