All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Serge E. Hallyn" <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: Dan Smith <danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Cc: containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org
Subject: Re: [PATCH] Avoid capable() call in UNIX buffer check unless necessary
Date: Wed, 18 Nov 2009 09:35:48 -0600	[thread overview]
Message-ID: <20091118153548.GC23694@us.ibm.com> (raw)
In-Reply-To: <1258557477-28642-1-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

Quoting Dan Smith (danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org):
> As pointed out by Serge, we shouldn't call capable() unless we know we'll
> need to exercise the ability.
> 
> Signed-off-by: Dan Smith <danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
> Cc: serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org

thanks

Acked-by: Serge Hallyn <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

> ---
>  net/unix/checkpoint.c |   11 ++++++++++-
>  1 files changed, 10 insertions(+), 1 deletions(-)
> 
> diff --git a/net/unix/checkpoint.c b/net/unix/checkpoint.c
> index 23040ce..55dfac1 100644
> --- a/net/unix/checkpoint.c
> +++ b/net/unix/checkpoint.c
> @@ -278,9 +278,18 @@ static int sock_read_buffer_sendmsg(struct ckpt_ctx *ctx,
>  		unix_sk(sk)->peer->sk_shutdown &= ~SHUTDOWN_MASK;
>  	}
> 
> -	/* Make sure there's room in the send buffer */
> +	/* Make sure there's room in the send buffer: Worst case, we
> +	 * give them the benefit of the doubt and set the buffer limit
> +	 * to the system default.  This should cover the case where
> +	 * the user set the limit low after loading up the buffer.
> +	 *
> +	 * However, if there isn't room in the buffer and the system
> +	 * default won't accommodate them either, then increase the
> +	 * limit as needed, only if they have CAP_NET_ADMIN.
> +	 */
>  	sndbuf = sk->sk_sndbuf;
>  	if (((sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc)) < h->lin_len) &&
> +	    (h->lin_len > sysctl_wmem_max) &&
>  	    capable(CAP_NET_ADMIN))
>  		sk->sk_sndbuf += h->lin_len;
>  	else
> -- 
> 1.6.2.5

  parent reply	other threads:[~2009-11-18 15:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-18 15:17 [PATCH] Avoid capable() call in UNIX buffer check unless necessary Dan Smith
     [not found] ` <1258557477-28642-1-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-11-18 15:35   ` Serge E. Hallyn [this message]
2009-11-25 18:52   ` Oren Laadan

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=20091118153548.GC23694@us.ibm.com \
    --to=serue-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
    --cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
    --cc=danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.