Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2453700rwb; Fri, 2 Dec 2022 09:58:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf7ek0tqcwfewHrxagTd65vpJxa41CJhR4YsVgDulgOMIKhPzMM2PZBChIdVNMFxt/VHjd8N X-Received: by 2002:a17:902:e849:b0:186:898a:f33d with SMTP id t9-20020a170902e84900b00186898af33dmr54290196plg.33.1670003936937; Fri, 02 Dec 2022 09:58:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1670003936; cv=pass; d=google.com; s=arc-20160816; b=TClzijvnySC8H8M1kkFIaOC0QoW4z/nBzZL6RNcLM1bhOu0hR+zMJf3nFxtCoaVpSp ljY8l9rls1r9tRicvK6/a+xXdLTNRMdXhBTWYKj21mzFEXbKRPQTFnDbb0d/gy+t1Wac 4Qyp2K16Fr7UpRWklvldD1Jtk5kWVPHko8SmZOcrazjcfqBeBUTxFYP5TAxjuF7rhjdx BSNzg+Y5Zefto9jzTgITP+bnVMWNUelAkRNlQdqiJJHFU3lbhHEz6uU8quoAbFR52ZRG 55vSeO+VjwBgVIlfRuT50uhElZGLvkzdRLFN6fZXAGNG+ZDx7Fuy9PR6eEEzTHAwfnsU j4vw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=gB3WI+kY2EdrfAsx3eK7GyxVFSRbYxd1mNrRaZIuIO4=; b=jbBVaMX+wjUZF0tz8Ux1Xz+hFQHW/nCD6yP8pYAJz1nC1+QRNV10FoX/Z32QRCOfBq Jf0Vm8+n3VkoDzgwx52JabvriLJl16wyrmwFWQv4yEaP5/Mt300JcBLgzL8/58PYPdGK oACNXoQKjOODXEIVXbabUbdu0Ui/+8fgZVRjctYAgUQieSDe6N+kVREV/iYE1c9QbiHz iFbGgWx9iTkLqkvq/eQelBzSTbLsoWCQb86DCWHbsLXdOGlg4zjkHH/VT3r6+ay9l9fn 03Sb/AV1uk3DxEX8YyFsMBjtDQ66SSl/a+3hTOP4Ic42RWaYt0EL6wezKjh57aIytr8E 7g/A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=OYrsRjc0; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z39-20020a056a001da700b005767cb3a67fsi1081790pfw.270.2022.12.02.09.58.46; Fri, 02 Dec 2022 09:58:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=OYrsRjc0; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233663AbiLBRjf (ORCPT + 82 others); Fri, 2 Dec 2022 12:39:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232993AbiLBRjb (ORCPT ); Fri, 2 Dec 2022 12:39:31 -0500 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02olkn2079.outbound.protection.outlook.com [40.92.49.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 179CED827E; Fri, 2 Dec 2022 09:39:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ImZJTIGBjAgHSH+eAnWReGW+lDoSCHqSUzrdRsdLa/eCy5KkVRf8rcDWypJqUoPZThEXGgIu6yLdF43FQ8dIH3vIMIqjhQLptApKF6W0m+IbMOt0VKobaY5p0c9LQxFpN3cj1XXhFNfKSqBpAoI/7Ks88qpfwVLiM65u4Fl5KOcJ0HlAQXaeQQUkeUO2FWJvvC+YqoEy+QU52ZdWZ7MM4FGjQGQMfr0OO1bqkQ5rwM2ZikHZq6IsH6IGVnKrmlBeOeLqiW6kh/EZ32nNA9JliUcnrRLYfQo+I/uw/gLysOa+2c43gctdJdVPnt7XKF8KdTQecN7ogQ4YoIMwCuX9Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gB3WI+kY2EdrfAsx3eK7GyxVFSRbYxd1mNrRaZIuIO4=; b=na5OITDPXj3GaRVr16am8hDj5tt6fUbEaLBTlsa1yWyCS1QkgxkTQgBzX/iGCj4MvD/CoabZqNYNeoVkMq5r9MMhBc7ss2J3UJyCGRCqMJrbtqYcqXu3IJMdThPIeqfwlg8LXuUXGfhtqQLEAWz9GoebClYokdiRsdEsWONlLWx+LUeDg5gQSA7fPMJxHDC1Gg4m2CuFZ7GR4SIuzWhA9RVMqsR0Oqlp4UDi5TXfjQP3ifCX8Yk5VslAEuC1F0IezPWKGOlMlDkST8oBLLDeura6auXQTUxbjrgsM+eDhH1n5nZDIlzt1aYkX33gn9Pfet5wWVf8Slx41244uycMPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gB3WI+kY2EdrfAsx3eK7GyxVFSRbYxd1mNrRaZIuIO4=; b=OYrsRjc0Q7NXjQRHX310bKoF+iWgVbIWP5R391K25D2d0sz7r8Kt57s9Aa8twk7NabwJyKa9RZGXQ0N6y60r95yB5DcyDZtoBxDGbilpAkUDm0mmDUeNS+rx6h1I8UNYcllzojJZ1y1tdV4728LcWPCb8wtWoIoZECU3vn1eAdW0/B+36jijLfqHdcksArJoGpcpa7wkY7rYUtUS7gkMPPXqHBhWF2aJJ9jjAdgJEwjTojOAocg8lxUg3x27xqXUsiE8z/MUtjQNuhfw47jFgBwhS/3Jh9ztJOr4WEsMnaHT4RyXkfD9cBybAR2DS2Nk1bkSbsU51euPhgO63ue/GA== Received: from DU0P192MB1547.EURP192.PROD.OUTLOOK.COM (2603:10a6:10:34b::15) by PR3P192MB0571.EURP192.PROD.OUTLOOK.COM (2603:10a6:102:43::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.10; Fri, 2 Dec 2022 17:39:27 +0000 Received: from DU0P192MB1547.EURP192.PROD.OUTLOOK.COM ([fe80::a67b:5da2:88f8:f28b]) by DU0P192MB1547.EURP192.PROD.OUTLOOK.COM ([fe80::a67b:5da2:88f8:f28b%9]) with mapi id 15.20.5857.023; Fri, 2 Dec 2022 17:39:27 +0000 From: Ji Rongfeng To: bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: martin.lau@linux.dev, daniel@iogearbox.net, john.fastabend@gmail.com, ast@kernel.org, andrii@kernel.org, song@kernel.org, yhs@fb.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, Ji Rongfeng Subject: [PATCH bpf-next v2] bpf: Upgrade bpf_{g,s}etsockopt return values Date: Sat, 3 Dec 2022 01:39:10 +0800 Message-ID: X-Mailer: git-send-email 2.30.2 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-TMN: [DnY83tEvg6Pw9ly1i7loIYJ9eCexNFj/] X-ClientProxiedBy: SG2PR06CA0190.apcprd06.prod.outlook.com (2603:1096:4:1::22) To DU0P192MB1547.EURP192.PROD.OUTLOOK.COM (2603:10a6:10:34b::15) X-Microsoft-Original-Message-ID: <20221202173910.11601-1-SikoJobs@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0P192MB1547:EE_|PR3P192MB0571:EE_ X-MS-Office365-Filtering-Correlation-Id: a11e5515-d7e6-4637-1bdb-08dad48c28d8 X-MS-Exchange-SLBlob-MailProps: 70qbaZjg4ms0xzfAGVOuKXynl8t5bcZkmjml5R49hQJeKseRJSf+ksbNRryIv/WNfr88IhuSzMaEf+Abh2HsSlfgxYwRjPRYRe2audmJyEuA7vFdmxZuKlWVBFn1ofBDvtqYphmYehbznu7g0Pko7A3WbtlK1zRc2Tm+cco+h5HP7GVp+TxdUP4RDOnGWEbBv7OgBZY9c6an8dAjbS3bouA3R/bi0+puU9c+x7hO7OEtJLpBUDx+pzJnfIlIfnQIBuLle3th3Z1jbTaRN0O9dgoMVmxAitIrBQD5PvQJJN0lQ/e0ASUjMjomgjr7wLsf4byyy/tNquBLs9yvPOmFxvkh4TsSofE6h0IVMOUwYeedHIl0bEBddLtmhu9KYyZqihOUEHM52JfVvKlz4dEuBdgeZkHmRn5w4DVnW7xyYNhdlvPVP/MecKO9Dfq0pmWuGOej+4gYzLU89mFv7Tv+zClwdyVjvVbJZNQ0ENwO0dj9JMp/GjilsE2+IHVwc1NpwUsA12Slny96krGNmSz8EvPIqD6B3OGTJRu0HAaTqupJpbDMpJM9ZF6XFJYVwHQ+LVI2Sr4JVpJrP5dpNd9NMJEy93nVQuwBNjrbQIM/A4neA+AIjrYRJvUd+h/x7Tl3oj0QyH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?Q?YNQPaT6xjwI0Iz+JoJD6n4c+PYiw+rKSR8IHrbTRV+LMVk8IZaNBvXPCJGKp?= =?us-ascii?Q?OKW5zMZP9B+jhRAvE6u1uNbLLjXxGRYKkQiObwFLdZn8RfWDqrOlWqYmUArB?= =?us-ascii?Q?M6ow+G3Fe8oTc16Yd6cPHP966Tfg8oLImOXSiGh7jly/+OX49N7OHHhyJkZu?= =?us-ascii?Q?BbnHCkeFgqUqXjhiwBp4ADEKHfvylkawZ7SUQ4p4sihlEy1dKv6NqVfxX3pW?= =?us-ascii?Q?+qLLeBgUm2erDgPJu9qCSUJdW6q0c70zrXjrYCJdJg=3D=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a11e5515-d7e6-4637-1bdb-08dad48c28d8 X-MS-Exchange-CrossTenant-AuthSource: DU0P192MB1547.EURP192.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2022 17:39:27.5718 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P192MB0571 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Returning -EINVAL almost all the time when error occurs is not very helpful for the bpf prog to figure out what is wrong. This patch upgrades some return values so that they will be much more helpful. * return -ENOPROTOOPT when optname is unsupported The same as {g,s}etsockopt() syscall does. Before this patch, bpf_setsockopt(TCP_SAVED_SYN) already returns -ENOPROTOOPT, which may confuse the user, as -EINVAL is returned on other unsupported optnames. This patch also rejects TCP_SAVED_SYN right in sol_tcp_sockopt() when getopt is false, since do_tcp_setsockopt() is just the executor and it's not its duty to discover such error in bpf. We should maintain a precise allowlist to control whether an optname is supported and allowed to enter the executor or not. Functions like do_tcp_setsockopt(), their behaviour are not fully controllable by bpf. Imagine we let an optname pass, expecting -ENOPROTOOPT will be returned, but someday that optname is actually processed and unfortunately causes deadlock when calling from bpf. Thus, precise access control is essential. * return -EOPNOTSUPP on level-related errors In do_ip_getsockopt(), -EOPNOTSUPP will be returned if level != SOL_IP. In ipv6_getsockopt(), -ENOPROTOOPT will be returned if level != SOL_IPV6. To be distinguishable, the former is chosen. * return -EBADFD when sk is not a full socket -EPERM or -EBUSY was an option, but in many cases one of them will be returned, especially under level SOL_TCP. -EBADFD is the better choice, since it is hardly returned in all cases. The bpf prog will be able to recognize it and decide what to do next. Signed-off-by: Ji Rongfeng From my point of view, changing these return values is acceptable, because most of them are designed to be shown to the bpf prog developer only and rarely shown in production environment. I'll send another patch to update documentation in a proper way after this patch is accepted, and add some tests if necessary. --- net/core/filter.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/net/core/filter.c b/net/core/filter.c index 37baaa6b8fc3..44440b7d430c 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -5050,12 +5050,12 @@ static int sol_socket_sockopt(struct sock *sk, int optname, case SO_BINDTODEVICE: break; default: - return -EINVAL; + return -ENOPROTOOPT; } if (getopt) { if (optname == SO_BINDTODEVICE) - return -EINVAL; + return -ENOPROTOOPT; return sk_getsockopt(sk, SOL_SOCKET, optname, KERNEL_SOCKPTR(optval), KERNEL_SOCKPTR(optlen)); @@ -5105,7 +5105,7 @@ static int bpf_sol_tcp_setsockopt(struct sock *sk, int optname, inet_csk(sk)->icsk_rto_min = timeout; break; default: - return -EINVAL; + return -ENOPROTOOPT; } return 0; @@ -5169,7 +5169,7 @@ static int sol_tcp_sockopt(struct sock *sk, int optname, bool getopt) { if (sk->sk_prot->setsockopt != tcp_setsockopt) - return -EINVAL; + return -EOPNOTSUPP; switch (optname) { case TCP_NODELAY: @@ -5194,7 +5194,7 @@ static int sol_tcp_sockopt(struct sock *sk, int optname, break; default: if (getopt) - return -EINVAL; + return -ENOPROTOOPT; return bpf_sol_tcp_setsockopt(sk, optname, optval, *optlen); } @@ -5215,6 +5215,9 @@ static int sol_tcp_sockopt(struct sock *sk, int optname, return do_tcp_getsockopt(sk, SOL_TCP, optname, KERNEL_SOCKPTR(optval), KERNEL_SOCKPTR(optlen)); + } else { + if (optname == TCP_SAVED_SYN) + return -ENOPROTOOPT; } return do_tcp_setsockopt(sk, SOL_TCP, optname, @@ -5226,7 +5229,7 @@ static int sol_ip_sockopt(struct sock *sk, int optname, bool getopt) { if (sk->sk_family != AF_INET) - return -EINVAL; + return -EOPNOTSUPP; switch (optname) { case IP_TOS: @@ -5234,7 +5237,7 @@ static int sol_ip_sockopt(struct sock *sk, int optname, return -EINVAL; break; default: - return -EINVAL; + return -ENOPROTOOPT; } if (getopt) @@ -5251,7 +5254,7 @@ static int sol_ipv6_sockopt(struct sock *sk, int optname, bool getopt) { if (sk->sk_family != AF_INET6) - return -EINVAL; + return -EOPNOTSUPP; switch (optname) { case IPV6_TCLASS: @@ -5260,7 +5263,7 @@ static int sol_ipv6_sockopt(struct sock *sk, int optname, return -EINVAL; break; default: - return -EINVAL; + return -ENOPROTOOPT; } if (getopt) @@ -5276,7 +5279,7 @@ static int __bpf_setsockopt(struct sock *sk, int level, int optname, char *optval, int optlen) { if (!sk_fullsock(sk)) - return -EINVAL; + return -EBADFD; if (level == SOL_SOCKET) return sol_socket_sockopt(sk, optname, optval, &optlen, false); @@ -5287,7 +5290,7 @@ static int __bpf_setsockopt(struct sock *sk, int level, int optname, else if (IS_ENABLED(CONFIG_INET) && level == SOL_TCP) return sol_tcp_sockopt(sk, optname, optval, &optlen, false); - return -EINVAL; + return -EOPNOTSUPP; } static int _bpf_setsockopt(struct sock *sk, int level, int optname, @@ -5304,7 +5307,7 @@ static int __bpf_getsockopt(struct sock *sk, int level, int optname, int err, saved_optlen = optlen; if (!sk_fullsock(sk)) { - err = -EINVAL; + err = -EBADFD; goto done; } @@ -5317,7 +5320,7 @@ static int __bpf_getsockopt(struct sock *sk, int level, int optname, else if (IS_ENABLED(CONFIG_IPV6) && level == SOL_IPV6) err = sol_ipv6_sockopt(sk, optname, optval, &optlen, true); else - err = -EINVAL; + err = -EOPNOTSUPP; done: if (err) -- 2.30.2