Received: by 2002:a05:6359:322:b0:b3:69d0:12d8 with SMTP id ef34csp311706rwb; Wed, 10 Aug 2022 08:38:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR6fo8mrXPSkIKhs7F0TRtsA/WmXceGRW2u3NoJuAJULjsC6FVdKe4TI0ij4eNJynVT/fVsp X-Received: by 2002:a63:224a:0:b0:41e:1d36:5063 with SMTP id t10-20020a63224a000000b0041e1d365063mr1389774pgm.568.1660145921490; Wed, 10 Aug 2022 08:38:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1660145921; cv=pass; d=google.com; s=arc-20160816; b=SIevYEDNhAcaZItWwNxjYwQLNOf0PE0sk04hpdDLOhGPitSOpiObGkj7n11zy6aTDe ZLr+gWuw6rhGaPM+mkReW9ld5jUuknEPRsRZ7SnyiimcC/mRzy4K8bT6QzQzagv3O5Ig dy8U479GW/SlvUZKnN0YIoZU0Mbnd0UsHrhHksHrfJWKGYtW5Ca8BJGWAxHBy6e1DF1b XywMDrx6QlMeoFK6UC0URrH6l+ZbJ5Pd/bAbvQzWfM4CPys7oJPEZDYCWFZcG3kYA1dl wBY8TmOzAXB1SfNEyVdijEzunyWL07WIfxjokAh8cnvNzfogzGcVNK0LDzLIDqRsfTl6 QK3Q== 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=N9l01EkwY/9kgvBGXWUNtTyLtqRY1nIxJTVllHQIiFM=; b=ipwfiHDc7AgXim2SnJSsJcUtM244cEVWhZw6MlkJsL/rgdukXoZhiN/dC+c6kvo0PY uWX/saSj3ahcHndFiiDIEhW6ydzUpi8KG6ac3FfYJ5kSxfgkk5jy9wnkDkWOdQL/kVWE aLImbt3tcTWJf7sMhsCbX5Io7F8cnsKnKB76QVHFM6rDcEbdYKajAfRQQJAlwnAqVKMf KMXs7XfiaFZRvZiQ7muvsYhsYQpQvk5oIHnFXWRtRuaae56gv2Db+FKifiPJVjedx2aP SIkySWp4qhE9h6C+SDclU0DfzqbqbIyV93AhheDbOHUHRocwkw4V88qxNszmDBkrOeyh l2XQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=rn4wwbTI; 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 w6-20020a170902e88600b0016360b6cec1si20458395plg.230.2022.08.10.08.38.24; Wed, 10 Aug 2022 08:38:41 -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=rn4wwbTI; 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 S232536AbiHJPJj (ORCPT + 99 others); Wed, 10 Aug 2022 11:09:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232990AbiHJPJd (ORCPT ); Wed, 10 Aug 2022 11:09:33 -0400 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEEBF73338; Wed, 10 Aug 2022 08:09:32 -0700 (PDT) Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.17.1.5/8.17.1.5) with ESMTP id 27ADBWWE006645; Wed, 10 Aug 2022 08:09:15 -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=N9l01EkwY/9kgvBGXWUNtTyLtqRY1nIxJTVllHQIiFM=; b=rn4wwbTIBLWTZg9Uovn2JNvY7NPHDO5L8sGQwP8zPhUPGihLrmkgNoHlp0MSqN7hm8bt n+8vKIJSZwojwjSqAQzwn1js4bz2pTwhSZWugvi0bcmR7lh4uZGmK59OwY0FDFsFMbGK 3vQZBh0vCUGZQPuR6Qk+OLgiOTG7ocXNvVA= Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2044.outbound.protection.outlook.com [104.47.66.44]) by m0089730.ppops.net (PPS) with ESMTPS id 3hvdb5rwj8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Aug 2022 08:09:15 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cv5MYXQN9K6E9DfjK+Lcb30piP/KGyyDRhxb82+qq6xgtKP7WR7aRyJgWNT5QkqI/MzwXOVJVjuOJKl8tpj6FVL39F1fsIRxGytdvArWhjG29Wf64ebrT/ncQCbkheowoJ3gQ8J8la2BPq6TrqJiDa3R94fIGjRGa5/JpNmqmA2l93fP4J20mgJDuX7gTOYZEwXLnxbyvYBaIfT0//G9j/t8sRmS2tdCFWe/xzTgrZE+4w5V8Tcc1eNppIYGzdB+a1QvriFOm24Fi7FQAYAsF/CWjCloz0Ij1DdGg6NAotiKTDDh4yd82sKA7Qv7dJWUbwVwupBQKhItV7JxVZfOnw== 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=N9l01EkwY/9kgvBGXWUNtTyLtqRY1nIxJTVllHQIiFM=; b=koYKI09T1xf+5Iu+b6rCATqy0Ce8D/9RJyMY+c9AzNa9dajzGIc8u0ExC5enNAIK9j2rmVxFDYoRg9dv+OfsOg7fbUz+BUe7bOE0iuocJf/SxTKn5LyNbPYe7JuWaFcX7HXx2rcSYL/Ly926JgsMss434PLfpIoWqSdLrKcMIm88AkaHoDFAAXNRrOVP658jWUTVAXmauNUAjtGk6XQVIghIvwqMUM0UrM2f3oAIV4VDFHsbSo4b1whmU6zYGVbJUewvJ2+kPXiW/rYOsXca/TffA1IUE0pBAD1kqAg8H75wuCImBN/md8rAj86auPuEy9oNQnUBpp28GiIcaiwy0A== 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 BYAPR15MB3510.namprd15.prod.outlook.com (2603:10b6:a03:112::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10; Wed, 10 Aug 2022 15:09:12 +0000 Received: from SN6PR1501MB2064.namprd15.prod.outlook.com ([fe80::dde5:25a3:a125:7bc7]) by SN6PR1501MB2064.namprd15.prod.outlook.com ([fe80::dde5:25a3:a125:7bc7%2]) with mapi id 15.20.5525.010; Wed, 10 Aug 2022 15:09:12 +0000 Message-ID: <5aa15b12-d193-b505-5786-3e187751323e@fb.com> Date: Wed, 10 Aug 2022 08:09:09 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH v2 1/1] bpf: Drop unprotected find_vpid() in favour of find_get_pid() Content-Language: en-US To: Lee Jones , Alexei Starovoitov Cc: LKML , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , bpf References: <20220803134821.425334-1-lee@kernel.org> From: Yonghong Song In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed X-ClientProxiedBy: BYAPR06CA0034.namprd06.prod.outlook.com (2603:10b6:a03:d4::47) To SN6PR1501MB2064.namprd15.prod.outlook.com (2603:10b6:805:d::27) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 46a88c04-a1b3-4763-7538-08da7ae24845 X-MS-TrafficTypeDiagnostic: BYAPR15MB3510: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: rP9LoIr3mh2P6+UdhiOOOpyGSVWCbFhJDIfAsqB3Xrraxhn1+IAUgzKQZO9BflwrZQg26nX8JD21AqRkpeTlZXyCXJUjF4ybibgTYpU/VHiOvjoawNug/UdRQSjnnVHnjINP4RrT5rhssa+/7hj2go7IOtIsjlNK6PAmfbgbzESxaTmIEhRWuvYL3b7D/aEiNKGEYfqWLJVIMmvetAWywsC0t0cIG0Zg9J49cj8YM4Fz0xrPK2itU54dWYTBIO+oU1UOFre2ucbT9gquQn6TthrL4Ko3U0MlnDd1hhzlZ+LWush84r/QwtAUdvtboDRjl9Oc8sDGBzU4qR5XBcTSF22+h6lpy4SY+PGA47S0k4mQRaj0hbk+ZDJB73+LR+uA0mRZgxafgPa6y290IHund8cFI7WcNvbuas0NKv+FZz3WDaxR6fn2tnBygmlPkRoBcOdZ8KHYZ+qgvF5IpiWBhNxFe9vOT+MGgVwBf9VkRnbxywROiWJHZUZ0zhxP/35t823j2e/I74558jtJg2M5uHt0J6FONykQCeWwPO8ydCgxc8odSc4vvSJJUMVdHwOYp9OZIgH+ZVG+QCxMpSo3L/0SmUpM5Q3DHw7gkQ4tOX4erx0i/4RPdlPJX9TsjeJm6ALyDffWmdtQ5wxDXKDsuQKyBzv0uWlOUjpZm/FPwtRVhkOogwT6YrRE2n6qK8HDgmENNIpF5L382bXoT29xMp5uA9NVl+zoM13jwzDdg/lOGXCeQyA0nhZlCDqDo0O+mXKLJmMqTtDej7iOxwdlcLTJt+m4vBUMNbPccy5HG8llyQ2DDqhFeRTWmKY2OlfIDdQQXSSzUDnj7WTJgG9I6wqh6IEN3gfY6WNX8jXNg3s= 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)(376002)(366004)(346002)(136003)(39860400002)(53546011)(6506007)(83380400001)(2616005)(186003)(6512007)(38100700002)(5660300002)(8936002)(8676002)(66476007)(66946007)(7416002)(4326008)(66556008)(966005)(2906002)(6486002)(6666004)(478600001)(41300700001)(31696002)(316002)(110136005)(54906003)(31686004)(86362001)(36756003)(45980500001)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?U1NDN3VJU1J5TXdndFREaWNjMXRpOU1CZXQyOGZkeE1JSmhtNWxlUXZJWEVS?= =?utf-8?B?b1BsRVExZldGcUJzMjNTY2JQQVJaY0Y2NWpaQWxTNThQYTl0RkdHQlFBelFq?= =?utf-8?B?Y0xBb0NBcE9BaStvalM1SCt2MHZSV1gzdk9Dc1B5UVdBZm5ncXhrOWFUQzM4?= =?utf-8?B?Zlg2MHJtbWlVQzBjMUlDOWVFQ1cxVzN0VWIxb3pFTWh3Tm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B?c3grM2FVRHZtR2NHNGo3dG1sVHlVYkd5KzF2VEZSUEd6T2RFYkhHeDlNWkRz?= =?utf-8?B?a0p6YVg4czdIVzVxV0VXamZLYi85MTIrVVFNR2xLSVIwZkdSNXdUc0cxaXdP?= =?utf-8?Q?ntQDtkakW+bbmkw/DB3WSkk59?= X-OriginatorOrg: fb.com X-MS-Exchange-CrossTenant-Network-Message-Id: 46a88c04-a1b3-4763-7538-08da7ae24845 X-MS-Exchange-CrossTenant-AuthSource: SN6PR1501MB2064.namprd15.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2022 15:09:12.2711 (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: 3fGCtwb9GHf+Y2/PQmn+yzYbfLHj9G82GNnMuVypAQkWalG1TMk7An30xxpfo1FN X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR15MB3510 X-Proofpoint-GUID: qGDiUzLqS7oNlkqu7OOlRUQLQZxEtL_R X-Proofpoint-ORIG-GUID: qGDiUzLqS7oNlkqu7OOlRUQLQZxEtL_R Content-Transfer-Encoding: 7bit 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-08-10_08,2022-08-10_01,2022-06-22_01 X-Spam-Status: No, score=-2.7 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,T_SCC_BODY_TEXT_LINE 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 8/10/22 4:03 AM, Lee Jones wrote: > On Tue, 09 Aug 2022, Alexei Starovoitov wrote: > >> On Mon, Aug 8, 2022 at 11:50 PM Lee Jones wrote: >>> >>> On Thu, 04 Aug 2022, Alexei Starovoitov wrote: >>> >>>> On Wed, Aug 3, 2022 at 6:48 AM Lee Jones wrote: >>>>> >>>>> The documentation for find_pid() clearly states: >>>>> >>>>> "Must be called with the tasklist_lock or rcu_read_lock() held." >>>>> >>>>> Presently we do neither. >>>>> >>>>> Let's 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 >>>>> --- >>>>> >>>>> v1 => v2: >>>>> * Commit log update - no code differences >>>>> >>>>> 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); >>>> >>>> rcu_read_lock/unlock around this line >>>> would be a cheaper and faster alternative than pid's >>>> refcount inc/dec. >>> >>> This was already discussed here: >>> >>> https://lore.kernel.org/all/YtsFT1yFtb7UW2Xu@krava/ >> >> Since several people thought about rcu_read_lock instead of your >> approach it means that it's preferred. >> Sooner or later somebody will send a patch to optimize >> refcnt into rcu_read_lock. >> So let's avoid the churn and do it now. > > I'm not wed to either approach. Please discuss it with Yonghong and > Jiri and I'll do whatever is agreed upon. Hi, Lee, Let us just do rcu_read_lock() approach then. I am okay with that. Thanks! >