Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp181875rdb; Thu, 25 Jan 2024 11:47:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IHFsdqRx9tPcG6aqRcYR/kvRs+xxBwnfz6TrjoGKdAVdmV54DX863gW8vwskwuy4BHGdQOl X-Received: by 2002:a17:906:4147:b0:a31:9381:4b00 with SMTP id l7-20020a170906414700b00a3193814b00mr55566ejk.78.1706212056134; Thu, 25 Jan 2024 11:47:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706212056; cv=pass; d=google.com; s=arc-20160816; b=ye9bgqHtdxUe7NR3PWFgWiG9aVwUvzrwiSHWdPe+FgWoYYs5fWdRPL10F6LGwxLIQI QJW7V8NqoBYcLUjoO1m/gZONPevxUtts+o4v7PV9fX8YqjajFN2TMhT7iRHx686XV4fi i5urjCYjzo4srLkuZhnzVUuENSbxwwXC/RGZOZb0Aa0DbOGDKBa6WU8qZcRRRbC9Y4Yz 6inDtL8Xo14yyNNnPJue3Bo5tRUpSH3q+UaRh8zn0v6fAKWkgiBSeugPZzTNO5c3TxRb pU6S9D4eRNyj8XFDAR2oxT32xZl0vc2haDL80sNBWQgGonuVT5hEbR1oPdTcgrfwVem4 9tTQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=L8aKo14reNbBvflPUZQ5aXL5UqBMo2rfTkLL7mrvQHA=; fh=kB/pc9QHghI8Bu45AWXpxjud1eF3Kuy44OxuUf2s0CA=; b=Qnhr9bsE6kkj/OidhGk35HMJUUyuluLJthB9acOSnImwsP6yBB8MUu6JMhFqBpUFWg VVkc+uOARBii5+iGi5kmWFrWpcI8UDf4y2qQFzcdgimm4jkXMSCkyMdCkUQPoQ+BC+k/ +WlikoKRNXskVieP9+024WqlRLZwvbfL2TkdnOISaUlxyI+wvJtyiI16ANI+KXJug9uC 7HiPuTet7GedclkNa5t5dYB8OcgE6NWEAbqWxDi7/KIV1jC3Xf3dzbth4ML5DZ/iOFVW R8HEqwSW+a4jH9Ixs35EW2K7rfkZuporT5YNr7Ql7W9qaKkh8rpdBJ8/S0aBtjs4XE4O rE2g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=MjVIobPd; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-39196-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39196-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gu10-20020a170906f28a00b00a318e54aa7fsi659425ejb.566.2024.01.25.11.47.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 11:47:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-39196-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=MjVIobPd; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-39196-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39196-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3823B1F26DBB for ; Thu, 25 Jan 2024 19:36:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 15EA513B7A4; Thu, 25 Jan 2024 19:34:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="MjVIobPd" Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9989713AA5E for ; Thu, 25 Jan 2024 19:34:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706211254; cv=none; b=Lr3IBoFjiuzqc2J7MXuRV7UrVzmCKb9wq3lFkmM3+qhVycsCiB2Zyvnrb20zMa4+gbYihJ/bjk+wcIaFsm6CeLUeduldMKCc/8P4Lz/30RKb6Sn+DSAwYK1iPHnOg1cWA4IoxRquBJyVSXp7gBjxcLYDTGbpPXET2se3JPDsFmk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706211254; c=relaxed/simple; bh=euenOEJWbKMReqmGzBSFxRmeY7+pAw/n2DDD6pBCMOk=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=hbaJXYULBaKX3D6lYG4mY0q0IDnXqkwcisRltmHPerbWwwM5ec00kfJ1apKG1a3A/jgqnnArvi6UCkbAgc0W/96ozNlbLYmHbGkcitRTXyT/22jwH1XEzSvH7HorW7sTTV6XCD3f7g/RTys6Ctd2oO1G7ZK0aD4t/GpLsHIvKDQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=MjVIobPd; arc=none smtp.client-ip=209.85.208.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-55d1d32d781so2454a12.1 for ; Thu, 25 Jan 2024 11:34:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706211251; x=1706816051; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=L8aKo14reNbBvflPUZQ5aXL5UqBMo2rfTkLL7mrvQHA=; b=MjVIobPdwgdRBT64fxSRe/sJ0dK95M5Tw6uFkt+S2bgOhAsx+x3PWWYer0XvxcyR3K bKtXWbzTTwcUFhb9GBNtdKZJ/7lJXpiqC5+qQ6klkKXkOdENAqmkU3pRo6bPZRP5axZi Yekzy7tFU3lG0M6loSRir2FgOr6IClQpSGd/m/p/gb93wm7JhUFK1mka4UWkVeDXb5ve HOOY6T3Op4Izp55MgUNsfxeU79gTJ526yT/Uk6+j6WEr8lTUI2co9jXhu81syMGS4ST5 vMzLHshzpNegXEvzAPsIRLVcZBBIuFC8pi4ny1XeBCEdJAAZ9+CBd5MADcffABHUlQK9 adrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706211251; x=1706816051; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L8aKo14reNbBvflPUZQ5aXL5UqBMo2rfTkLL7mrvQHA=; b=a/ky4XzLKpVH+qiQzo2brG4u2Krithe7LfNbnf0OjqnRkLVTmud0rQp1ZYjI4L66f/ s/E7SfklTOVieNPeiZCm3qla5N2hlBY8maGn5hiRhvFTUWRoDBdqqSasz/HZxKVYIUJB GaZzpFXYkHrSbMlOSPiOwf3xhx/t7EeBO3s2exS/pc0fN/3zfFnIw7979G3bbeEvRYRd DkC/g/bHlSV0Tstu5QgaKdqlBgGLqtiLoSxcaC6E3s4sKhBjbVZBKqQhgZng9BC8kiTl uqSRgeAGsvOpfwvP0j1GHnyi1uUPz0g2xO2PNIHkg8SDYdcv1i51WSg8hyOzTpIyf6U7 fx4g== X-Gm-Message-State: AOJu0YyVoHD6zcEQMlBzpu60/LRaIiSYJ47Weo9Gra1TI2E5TuscM5vx eMqtFnwP3BCcYWBZTkKlQRcijoDUXUmXcC1P0Im8Ae+/2ThvjiVQgkXk7iH6WyYmvVWg++dMOOq XUevP780KGveHf0KAYHlWmciGDgR6kEIihBbj X-Received: by 2002:a05:6402:b57:b0:55d:2163:7ed1 with SMTP id bx23-20020a0564020b5700b0055d21637ed1mr14684edb.1.1706211250620; Thu, 25 Jan 2024 11:34:10 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240125191840.6740-1-jdamato@fastly.com> In-Reply-To: <20240125191840.6740-1-jdamato@fastly.com> From: Eric Dumazet Date: Thu, 25 Jan 2024 20:33:56 +0100 Message-ID: Subject: Re: [PATCH net-next] net: print error if SO_BUSY_POLL_BUDGET is large To: Joe Damato 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jan 25, 2024 at 8:18=E2=80=AFPM Joe Damato wro= te: > > 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 > --- > 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 o= ptname, > 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.