Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp693992imi; Thu, 21 Jul 2022 09:07:59 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tzVlZsfk9rYO8C4Y7ylbirhcfpF5jj5qm4urRLAzN4Y1b2iObaZJR117yrpnotea4Q2AGi X-Received: by 2002:aa7:d74a:0:b0:43b:a51d:4c3c with SMTP id a10-20020aa7d74a000000b0043ba51d4c3cmr14542676eds.127.1658419678833; Thu, 21 Jul 2022 09:07:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658419678; cv=pass; d=google.com; s=arc-20160816; b=AfvPXfZTJm5CtuplpshCz15gozYgG6BeKnhZsJcGLW1NwWhUHzb0YxrfD9vVF91Cm3 Qs6AolSSdRKw4z1XYZghDHJyiyTjpozW2dCC/+IpA9m5G7Cl0zdUrNq4qruWaR9uJcf2 q7SbKyCUAcitlHKBgJGYdCVIQ8IaJBfAMKgLTg5FO2dfdUjUXVeHU0WeqnlnoREHGk+x SuBnLXPvgG//sDmcg4Cd4Z7qLETk90okiGsKdRVeoAg0MOzBNGH7/bcdY7cYqCORW0j6 c7cC26B1+dOY6gZZtuS/7eNTDFg6nD78CBh/7IV/whXJNMr2gzqXLijAxQm1FErhrQQl jKyg== 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 :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=S3dRuRQ1C/imn1Ijk3JIDKR/xiaHtGA9ZVnqq0Q+7wk=; b=GArxD/E/kP6OCmWuXp6JD1UpSMLvDyBhBtV/drzh28yYOiTGk/jjj6fz41UstwWoYq +5TSAh5VlLIWNyK2cDAU5OQATEnBmYiKhXoaxm2IbEt9r2sxpu9D+RpUcCAbrS2/WclZ Ww3WUAHVvhrWibDyMruHI3/6BFUA+cYPMpwJLMuRm1PYDdcwN+5wPwJRMkzgBJW1ymQX iDxk/FlP0+gEJ44InIWoOxFs2O+q+KWgKYq9skytSzsShG8digsNZC0QuIH0YOs0OZDR lBx489BV2XH8dzUlIbGi1sbhUony9EXV3bNoEOwJxG0ewfZPumWsVIi7eWB3wjQyQ72e TPKQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=LT+d1e94; arc=pass (i=1 spf=pass spfdomain=fb.com dkim=pass dkdomain=fb.com dmarc=pass fromdomain=fb.com); 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=REJECT sp=REJECT dis=NONE) header.from=fb.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i2-20020a170906698200b00712210a96a4si2717159ejr.226.2022.07.21.09.07.30; Thu, 21 Jul 2022 09:07:58 -0700 (PDT) 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=@fb.com header.s=facebook header.b=LT+d1e94; arc=pass (i=1 spf=pass spfdomain=fb.com dkim=pass dkdomain=fb.com dmarc=pass fromdomain=fb.com); 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=REJECT sp=REJECT dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233446AbiGUPxn (ORCPT + 99 others); Thu, 21 Jul 2022 11:53:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230161AbiGUPxj (ORCPT ); Thu, 21 Jul 2022 11:53:39 -0400 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48B66474CC; Thu, 21 Jul 2022 08:53:38 -0700 (PDT) Received: from pps.filterd (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26LCAGTC023612; Thu, 21 Jul 2022 08:53:17 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=message-id : date : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding : mime-version; s=facebook; bh=S3dRuRQ1C/imn1Ijk3JIDKR/xiaHtGA9ZVnqq0Q+7wk=; b=LT+d1e94hjb+zgKrWI1uuwm8zv7iNB6CBX/SHXyDXdGPgr8pRwequZ67OGdIZRQ2jsLT QZvPw4wlzF6ET2UT7BpqMHbKfgn8NAac4U+JW2nwKuUvPWTpMuZW8+tWvuxjyhtuqdk0 ETey1iAqvPKtZFXOGThPF/qEH7SIxq7sSAQ= Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3hf6jjse6x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Jul 2022 08:53:17 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hml/XnhkNqbl6NAZJJnAltLeK1Z79uwhSg2jpO1r/1PND6QVron9XBzica+Qpjqgl/zg6wc8i7SwiDVpaWjhk1Et2BfR7g7c+DjI2YLotEQDWPW5Zm0AkD4h5+uBb3e4/ABOSFhfNV4L2VIgdaKrCRT//+FA8tisAU0dvhPCzdE8XmUWh6fSrNwAfF7brZgggrr/JO1mHxkOiU/FZBkOTBAT6eZmpKsVLSeN5tfhrYLGf+5IwpmUobaXD0MgcGPGW9YBCPcEgj0dTQPPrrDJGguOogRH1bGKPjPscHgi1PFA6yLb6a2kPnBp3to6wiyoeix9Y9dRDkYlhujLw8XvTw== 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=S3dRuRQ1C/imn1Ijk3JIDKR/xiaHtGA9ZVnqq0Q+7wk=; b=df6zEiOhJ4rmrJH1mNRTDzfYFr1AJUt1U6lcQB2uimWmDWijY4ttz/OuQOQCUNsV67RLsYXcZm6Hd7KNoKyjynAQaLLPr+eloh/8gqzM3n3UVIu9R+wLmrETjR8C9UMWeoUBPvtHd1M1x6DdzZMZskZdP3JfZlZMO8YuXpGJCVgMbuIhIJ+ZO0J9DJFEXcwRDjxpbE9pn1s0PaFkCTM+OLq3siOYHhRq7wjOEiZtUwiQTMifKeUrf7YWboNvU7b/3egQ+ppqFRODV0yWhWXtuZ25wdQ8f19DrGq+W3a1Nu3svHLO1No1sfNNBuvkCd2QdOix6EwKq5URhHMi5UhMaQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=fb.com; dmarc=pass action=none header.from=fb.com; dkim=pass header.d=fb.com; arc=none Received: from SN6PR1501MB2064.namprd15.prod.outlook.com (2603:10b6:805:d::27) by SN6PR1501MB4126.namprd15.prod.outlook.com (2603:10b6:805:5e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.19; Thu, 21 Jul 2022 15:53:13 +0000 Received: from SN6PR1501MB2064.namprd15.prod.outlook.com ([fe80::9568:e5d9:b8ab:bb23]) by SN6PR1501MB2064.namprd15.prod.outlook.com ([fe80::9568:e5d9:b8ab:bb23%6]) with mapi id 15.20.5458.019; Thu, 21 Jul 2022 15:53:13 +0000 Message-ID: Date: Thu, 21 Jul 2022 08:53:08 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH 1/1] bpf: Drop unprotected find_vpid() in favour of find_get_pid() Content-Language: en-US To: Jiri Olsa , Lee Jones Cc: linux-kernel@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , KP Singh , Stanislav Fomichev , Hao Luo , bpf@vger.kernel.org References: <20220721111430.416305-1-lee@kernel.org> From: Yonghong Song In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed X-ClientProxiedBy: BLAP220CA0019.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:32c::24) To SN6PR1501MB2064.namprd15.prod.outlook.com (2603:10b6:805:d::27) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dac499a8-ae66-4c3f-4d75-08da6b311e09 X-MS-TrafficTypeDiagnostic: SN6PR1501MB4126:EE_ X-FB-Source: Internal X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LuXiXU75K+FfnaR/MKdnJc8D77kPDYM6agXqwUuhcvMmzQ/O8DVb/0KvDpKsMwfBLx1DHrTi2ZPZ+HqOh6I6tXJLiD7DvGLpe338FSZ98c+1SO3URfCMKqj5TdPgIairTylcw79NmkvrzOoAGR9N2Okhe3jOOLNyyoKw+83p5NIBqZXzuFBatQHYKN7yGK6X3G3bWX3g2/PEzrTOQXbD+Is6F7qYSezh6OAUpSljv6kOiT7He9vqslyyhtSDMnHfqPc3KdiSuOeyudDGwqLFFje3MsOuzhoeWw4ZHT6GQehPpJILYkI8hWDWAFNNzWymQZbyN3ot8n1ebLbrukMWBFoRiPzjvzrJ8ZRXhLG+napQfKjAwMAGuKqShzCrzFoLSQxhM3G8ZufeRR3VEyhtJOhOEinggl+8etMWrx3CIZ0ri0uIT/acg4LPWe//FZPRewZTn/ylGW/Ay2TquzOBJwEJRTZC8Zy07bRRkChiUu7x70jeG3XluZIDCs4GmLl8tdKdrfvWNWhGg4EZg2Be4f3QRTpznCStgaLXzuRV0wnGWJ3yjTR35B1TNN24b0dfOTb8T7c3YTzj5ifmCaP0QUL0swc/Lam9HqAeWsB3ucRs7PN8TY1OZELnETfhGvh1F6xARRPh/ipUbdMPtzk+Tb1L3nGtO+iQzvbuMszTafgSC8WT8+RNohD0wfCBLW5BYtexhIoAg/7h6oMVctH7cXxuFkAtApfpovgbVHS43Udx4tQZ1GTIai4zldfZHRe1BSxEWEHby05yjaD+H2Q8zzDMaaidiikuB4HavGBcNRoEx+xcLd7IKuTz3rtjcAG9CP/s0uWMCmHgEn5O7pTLbyAjqMxrrdsj+q1GY57EfpI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR1501MB2064.namprd15.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(396003)(366004)(39860400002)(136003)(346002)(376002)(6506007)(6512007)(53546011)(186003)(2616005)(38100700002)(83380400001)(8936002)(7416002)(2906002)(5660300002)(110136005)(478600001)(966005)(6666004)(6486002)(41300700001)(66556008)(8676002)(66476007)(4326008)(316002)(54906003)(31696002)(36756003)(86362001)(31686004)(66946007)(43740500002)(45980500001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?NG1XOVJ3UGR6aGZBYnUvektXRFBXbXQvSUE2MGc3ZVcxdldUWlQrRWVFV2VT?= =?utf-8?B?VTFScGhIMkJkY3pncncxK2o3UVNNZ1VJeDJ2Qk5uZko3TXlkK21JUmdJNVR2?= =?utf-8?B?bkNWSHZsamZFN1Zac3lzc0lUcmFRcHd3K2h4bzlCbnJqdyszM0lSeGRuMC9I?= =?utf-8?B?cGpYVVhaWjY5eWZwcTdOdjM3MysrK2N4c05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?= =?utf-8?B?VysrTEd3NmtTK3FLcitNaEZnS2txZTNnM2ZxdGJLQWYyMlNuUG14SHlNd2ta?= =?utf-8?B?ditsT1dvT2Z6dUxhSEY5MnAvV1Z3eVJaWXlBZU5GL2MrYWhOeitld0NwZm9O?= =?utf-8?Q?IDmSQ4T+ZaUiI7aEOWkARh5Oi?= X-OriginatorOrg: fb.com X-MS-Exchange-CrossTenant-Network-Message-Id: dac499a8-ae66-4c3f-4d75-08da6b311e09 X-MS-Exchange-CrossTenant-AuthSource: SN6PR1501MB2064.namprd15.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2022 15:53:12.9560 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: eYrwzhBAUj7SheS6Q3KXEqgjWIla9+tnyq7i9BB9urRW1lHuuOnzp797bLBjlJul X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR1501MB4126 X-Proofpoint-GUID: nbHQ6H4D1oqpSEjqzrb3gaf7xkqNkeKV X-Proofpoint-ORIG-GUID: nbHQ6H4D1oqpSEjqzrb3gaf7xkqNkeKV Content-Transfer-Encoding: 8bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-21_22,2022-07-20_01,2022-06-22_01 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE 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 On 7/21/22 5:14 AM, Jiri Olsa wrote: > On Thu, Jul 21, 2022 at 12:59:09PM +0100, Lee Jones wrote: >> On Thu, 21 Jul 2022, Jiri Olsa wrote: >> >>> On Thu, Jul 21, 2022 at 12:14:30PM +0100, Lee Jones wrote: >>>> The documentation for find_pid() clearly states: > > typo find_vpid > >>>> >>>> "Must be called with the tasklist_lock or rcu_read_lock() held." >>>> >>>> Presently we do neither. > > just curious, did you see crash related to this or you just spot that > >>>> >>>> In an ideal world we would wrap the in-lined call to find_vpid() along >>>> with get_pid_task() in the suggested rcu_read_lock() and have done. >>>> However, looking at get_pid_task()'s internals, it already does that >>>> independently, so this would lead to deadlock. >>> >>> hm, we can have nested rcu_read_lock calls, right? >> >> I assumed not, but that might be an oversight on my part. From kernel documentation, nested rcu_read_lock is allowed. https://www.kernel.org/doc/Documentation/RCU/Design/Requirements/Requirements.html RCU's grace-period guarantee allows updaters to wait for the completion of all pre-existing RCU read-side critical sections. An RCU read-side critical section begins with the marker rcu_read_lock() and ends with the marker rcu_read_unlock(). These markers may be nested, and RCU treats a nested set as one big RCU read-side critical section. Production-quality implementations of rcu_read_lock() and rcu_read_unlock() are extremely lightweight, and in fact have exactly zero overhead in Linux kernels built for production use with CONFIG_PREEMPT=n. >> >> Would that be your preference? > > seems simpler than calling get/put for ppid The current implementation seems okay since we can hide rcu_read_lock() inside find_get_pid(). We can also avoid nested rcu_read_lock(), which is although allowed but not pretty. > > jirka > >> >>>> Instead, we'll use find_get_pid() which searches for the vpid, then >>>> takes a reference to it preventing early free, all within the safety >>>> of rcu_read_lock(). Once we have our reference we can safely make use >>>> of it up until the point it is put. >>>> >>>> Cc: Alexei Starovoitov >>>> Cc: Daniel Borkmann >>>> Cc: John Fastabend >>>> Cc: Andrii Nakryiko >>>> Cc: Martin KaFai Lau >>>> Cc: Song Liu >>>> Cc: Yonghong Song >>>> Cc: KP Singh >>>> Cc: Stanislav Fomichev >>>> Cc: Hao Luo >>>> Cc: Jiri Olsa >>>> Cc: bpf@vger.kernel.org >>>> Fixes: 41bdc4b40ed6f ("bpf: introduce bpf subcommand BPF_TASK_FD_QUERY") >>>> Signed-off-by: Lee Jones >>>> --- >>>> kernel/bpf/syscall.c | 5 ++++- >>>> 1 file changed, 4 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c >>>> index 83c7136c5788d..c20cff30581c4 100644 >>>> --- a/kernel/bpf/syscall.c >>>> +++ b/kernel/bpf/syscall.c >>>> @@ -4385,6 +4385,7 @@ static int bpf_task_fd_query(const union bpf_attr *attr, >>>> const struct perf_event *event; >>>> struct task_struct *task; >>>> struct file *file; >>>> + struct pid *ppid; >>>> int err; >>>> >>>> if (CHECK_ATTR(BPF_TASK_FD_QUERY)) >>>> @@ -4396,7 +4397,9 @@ static int bpf_task_fd_query(const union bpf_attr *attr, >>>> if (attr->task_fd_query.flags != 0) >>>> return -EINVAL; >>>> >>>> - task = get_pid_task(find_vpid(pid), PIDTYPE_PID); >>>> + ppid = find_get_pid(pid); >>>> + task = get_pid_task(ppid, PIDTYPE_PID); >>>> + put_pid(ppid); >>>> if (!task) >>>> return -ENOENT; >>>> >> >> -- >> Lee Jones [李琼斯]