From patchwork Thu Jul 6 04:08:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13303164 X-Patchwork-Delegate: bpf@iogearbox.net Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B42AED7 for ; Thu, 6 Jul 2023 04:09:22 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2062.outbound.protection.outlook.com [40.107.21.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 688BD1BCB for ; Wed, 5 Jul 2023 21:09:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d3PMZ+I0UP2pmupyTVdhCjqarvifdsG9JRfRyro47rGVVUkLwbfgmIhPHoc+RTS+0TrDZwuQoC3ngBh5DOSM/Lp5DHNGeiodHxufZI5Up9FJ1iBKJX8If02B2tcipbMn0K9E9/KJZY3kZzaSw2UBqvGb26cG3uIDWZLbqY0SRr1xdgGneGTFI89c1+hGOaFTh0+SBHvt/6wp44DYqY4m2ictojMIlQxqW8bBsVD1v1GCXNNszNQOimWKeNBj9eJJuf7QW7gqIfqvybY8S0VD/eJ+Fonyic19t5yl2rAKlkWOdeN63W+Kn/ekuSkehOlQ2PE0w4wXjKZivFJHqJ4Nqg== 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=lY3Pgk1uh4FXkQ6a+2ml9sNjR4idpzfAMSUu5Wzp0tY=; b=icXieuQW1ol7a4sGY2tDvz8i/Tstgea4O3Uq3veqpPFbOYVb4PdLp61zhriK8UI9XtqBkMu738YFUqr59NMGT9ci82GoV++05EJfsyutgy208kZLTdS3MbTD0drPk4ADzQh7UwdXfVcXzcGoRph9yLITM8oomVXxQCvvkUyl6drmDcHO0j19q4TLl7V4SG2T8S2sY6zB8KbPxA99e7v70Dhqa1hagXSumLcFoQlfo4IO+/2Hau8h2tpu3Isj1udVM9KjSSNDT8h2hiqgwbv7SQnStj3Uuofyfu6eIHxGpMBsAZhbAlTHcIUWRT/qfXu3gg5BRJuIhmnTO7b3SAqvAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lY3Pgk1uh4FXkQ6a+2ml9sNjR4idpzfAMSUu5Wzp0tY=; b=cIiFRlodTxi8CbZ5wfU2/pGOAZi7hZQxBu8AMZI7R+fqj5fky5/GstpA+4MDlLsV9/3OANcYSn3xIFmyx+PCTrANBXDAY+seEMjKb3Q1q2csBjEH2D4//6KK+JuzMyd8yrVcSkHr4Z9Y8kUHNcYk8gbJwLqbKRU0CJp6AZW4v9tsZQLcTt8tF4gMGJXGIsBeq3MRtuW137k8fu6tu8glblkZA2/lFr83vgrRPvqYpdRdhSVuqN6QI+tfGNh++kBpROP1SyxzqCZo4pduKqbC38V1JZtkFgJ5RZTWD155EJv5g3YXCZfJCLYxaIn6eOGyDQzfK17e9sdSO4cvDNUZ/g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by AM9PR04MB8828.eurprd04.prod.outlook.com (2603:10a6:20b:40b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.17; Thu, 6 Jul 2023 04:09:17 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::423a:a30f:5342:9d35]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::423a:a30f:5342:9d35%6]) with mapi id 15.20.6565.016; Thu, 6 Jul 2023 04:09:17 +0000 From: Geliang Tang To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa Cc: Geliang Tang , bpf@vger.kernel.org, mptcp@lists.linux.dev Subject: [RFC bpf-next 3/8] net: socket: run sockinit hooks Date: Thu, 6 Jul 2023 12:08:47 +0800 Message-Id: <5f76da0bea3453db04bb07399b4b1c9ce4859e31.1688616142.git.geliang.tang@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: SG2PR06CA0249.apcprd06.prod.outlook.com (2603:1096:4:ac::33) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|AM9PR04MB8828:EE_ X-MS-Office365-Filtering-Correlation-Id: 608c740e-f5ba-4537-4ac6-08db7dd6c41d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dRSuJYurGFtB/5wXoJdXHEuPtuNXDwZHUjrZvJCklhJ/kmkpmJHV////+6qT2ZDNLDvph4akJHWC66OFPEwkFuzJMtS+gq3+tdr4qiRxTkJk8BGNrRfouPhLL4lQPiKMlzMWQI+YiQanoYvbZlmIqiHBYfRrS41wAOHKXeB6ZIkV/vw3BwMBraJnjAS2YI85DahOcBLMpmf8aGR49ta7G/aQD3gpOcsAg30CKLG5okQUi+k5SFUu2ad4xcg+hep+r6urY+rOohZo0Xecx9q4Rp4eQrrYcTGn2Ip/5Rtmrh6RG1sPpIzLR2HcqsoZGHj2onUl/WqW85H5lokn/AaGBJbt0eNpU+l6hWd/VYDrrpr3m6FZX6/dUmY8k/sTJAcJQ0xNMHmo+Ccfiny7Sd81gxfsE23Tw4JtMpb4cIQnvKp/b6NVk1vxGpkMzAvtgrfH50BbdyhPFLQr/2YPqjuYzNDBVQ9nHWcOoPxhTSFhV6Ap2b+6UaOyNsiIcRfndi/fr1pozxGsz9ZxVg45zdL9OkA6YoyboKXofuHYSz1R2IMQDzvGQGK+k+Cz48/iHYtjlxcsXsborPqlzuBj7sht7N64aaybNyZeC6QON214rG2+ZPhyVCXds5rMw23B/xyK X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(136003)(396003)(366004)(376002)(346002)(39860400002)(451199021)(2616005)(38100700002)(66556008)(66946007)(66476007)(4326008)(921005)(186003)(36756003)(6486002)(6512007)(6666004)(110136005)(6506007)(26005)(478600001)(86362001)(41300700001)(8936002)(8676002)(44832011)(4744005)(5660300002)(7416002)(316002)(2906002)(13296009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AcBj1x2O1hgkB4Rdc+hIV1R7OQhdvOeu/jh53tSDY2B2sMSAHny/O6q7HKIKr6kEmZv3KeWOTOtOa1dQArNc4bZA8nOvvUWMLG5Cx5KQJ/AMxdg6jjLNQttl2S5NbW/V8cTBwOxGcjjrXnXpxWm/GPq4DtFmDFNedjhb9fVrZ4qg5vCYZ2rUp3SN32SpxUbiNzCMzz8LDgBDra7FAcNGatGipX21LnBGd3g2VUQAa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7joEAZY0Lc6zeVRb3NgzFdMuWWOioT2hudph5U3sHhtbEuyaxkWAU0VoDo5k3guRPHls/Tu5RWApsBZ258niG59ibCfLbpr93GVqEpKOf4swA5wapWL3hSMEGiQB/ky3ePdjInFkvbTqG2AdH9tqRxRuDzwt+v5y4eSd/lODxPDb63VnCuxnCaYQ6LVBxgBbyG7rpItD2sOsKJ+TgnNMHdIB60Bn7OdOu7Ab3KrEqIpPNnoM0+RqvdWrRX045xGAypVRPqrSORcywuAx0yYEFe4y2vn5Tt X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 608c740e-f5ba-4537-4ac6-08db7dd6c41d X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2023 04:09:17.0788 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hD22LYQOGSoDzdRnWJZVg2JXORYZPzTwz20g0jGy9nuFBSJiU93WPPsFyjsSMbesd9ZFjN/wUXaWpKfGvp7bdg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8828 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: bpf@iogearbox.net X-Patchwork-State: RFC The arguments of socket() need to be changed sometimes like the MPTCP case in the next commits. It's too late to add the BPF hooks in BPF_CGROUP_RUN_PROG_INET_SOCK() in inet_create(). So this patch invokes BPF_CGROUP_RUN_PROG_SOCKINIT() in __socket_create() to change the arguments. Signed-off-by: Geliang Tang --- net/socket.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/socket.c b/net/socket.c index 2b0e54b2405c..27b423e1800f 100644 --- a/net/socket.c +++ b/net/socket.c @@ -1469,6 +1469,12 @@ int __sock_create(struct net *net, int family, int type, int protocol, struct socket *sock; const struct net_proto_family *pf; + if (!kern) { + err = BPF_CGROUP_RUN_PROG_SOCKINIT(&family, &type, &protocol); + if (err) + return err; + } + /* * Check protocol is in range */