netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Alexander Heinlein <alexander.heinlein@secunet.com>
Cc: <netdev@vger.kernel.org>
Subject: Re: [PATCH] ip/xfrm: Fix deleteall when having many policies installed
Date: Tue, 17 Jan 2017 08:44:12 -0800	[thread overview]
Message-ID: <20170117084412.0bff48bb@xeon-e3> (raw)
In-Reply-To: <d056322e-7c23-7e19-3bdb-4afa5f04e409@secunet.com>

On Mon, 16 Jan 2017 15:09:01 +0100
Alexander Heinlein <alexander.heinlein@secunet.com> wrote:

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


What happens when many many policies are installed?
It looks like your patch would silently stop deleting.
Does the the code flush all of them?

  reply	other threads:[~2017-01-17 16:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-16 14:09 [PATCH] ip/xfrm: Fix deleteall when having many policies installed Alexander Heinlein
2017-01-17 16:44 ` Stephen Hemminger [this message]
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

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=20170117084412.0bff48bb@xeon-e3 \
    --to=stephen@networkplumber.org \
    --cc=alexander.heinlein@secunet.com \
    --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).