linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <edumazet@google.com>
To: Joe Damato <jdamato@fastly.com>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	dhowells@redhat.com,  alexander@mihalicyn.com, leitao@debian.org,
	wuyun.abel@bytedance.com,  kuniyu@amazon.com, pabeni@redhat.com,
	kuba@kernel.org, davem@davemloft.net
Subject: Re: [PATCH net-next] net: print error if SO_BUSY_POLL_BUDGET is large
Date: Thu, 25 Jan 2024 20:33:56 +0100	[thread overview]
Message-ID: <CANn89i+uXsdSVFiQT9fDfGw+h_5QOcuHwPdWi9J=5U6oLXkQTA@mail.gmail.com> (raw)
In-Reply-To: <20240125191840.6740-1-jdamato@fastly.com>

On Thu, Jan 25, 2024 at 8:18 PM Joe Damato <jdamato@fastly.com> wrote:
>
> When drivers call netif_napi_add_weight with a weight that is larger
> than NAPI_POLL_WEIGHT, the networking code allows the larger weight, but
> prints an error.
>
> Replicate this check for SO_BUSY_POLL_BUDGET; check if the user
> specified amount exceeds NAPI_POLL_WEIGHT, allow it anyway, but print an
> error.
>
> Signed-off-by: Joe Damato <jdamato@fastly.com>
> ---
>  net/core/sock.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/net/core/sock.c b/net/core/sock.c
> index 158dbdebce6a..ed243bd0dd77 100644
> --- a/net/core/sock.c
> +++ b/net/core/sock.c
> @@ -1153,6 +1153,9 @@ int sk_setsockopt(struct sock *sk, int level, int optname,
>                         return -EPERM;
>                 if (val < 0 || val > U16_MAX)
>                         return -EINVAL;
> +               if (val > NAPI_POLL_WEIGHT)
> +                       pr_err("SO_BUSY_POLL_BUDGET %u exceeds suggested maximum %u\n", val,
> +                              NAPI_POLL_WEIGHT);
>                 WRITE_ONCE(sk->sk_busy_poll_budget, val);
>                 return 0;

This is code run by privileged (CAP_NET_ADMIN) users,
please do not spam the console with such a message.

My point was : Do not allow an unpriv user to set an arbitrary value.

netif_napi_add_weight() is used from kernel drivers, we network
maintainers usually object
if a driver attempts to use a big value, at code review time.

  reply	other threads:[~2024-01-25 19:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-25 19:18 [PATCH net-next] net: print error if SO_BUSY_POLL_BUDGET is large Joe Damato
2024-01-25 19:33 ` Eric Dumazet [this message]
2024-01-26  9:11 ` Breno Leitao

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='CANn89i+uXsdSVFiQT9fDfGw+h_5QOcuHwPdWi9J=5U6oLXkQTA@mail.gmail.com' \
    --to=edumazet@google.com \
    --cc=alexander@mihalicyn.com \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=jdamato@fastly.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@amazon.com \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=wuyun.abel@bytedance.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).