Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3181734pxa; Tue, 18 Aug 2020 08:34:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNTvwgL1EPew5y2d9S8NYr0pRDmrUy2z5YT+YEX5IoZX0fND2S14YJd0uqvfMo3oaS5qTB X-Received: by 2002:a17:906:8d8:: with SMTP id o24mr20316664eje.384.1597764883339; Tue, 18 Aug 2020 08:34:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597764883; cv=none; d=google.com; s=arc-20160816; b=VDJD6DjFJxaQnnIezFZCq83hSrPtojRkL2gycOEDm4XvCJMsKOnBsHchrJTpSPFB0y l5P8Roi0CrfIMAu0o6Dzyy48AWnZnDm4AzaT1Xx2IekKyGaLFGlW4KqUu/yj9k3msQ6S HwyJB3EzkdDF8Pxi6nlVu7vJPU/est7EtXM0wJqhnn4EIVsTRPX5/UTOELyzgZM7KvJP 2s5iX9Wu7GlhC0AC7//Dn5GRPe/bSdGDf0dMcWdvBzH/C7qBDwK4LEBP3C2VBx6vFQKr 14pZ9I9AZU31DoOJLA3ltCWhe8+I8wSP2OhleMj+dIs0VyuMHk3yGYnA7Gf93bC+lOKK vgyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=a6JBuZhVYWp23R6HGvWW9nRcBBE4mX5ykNxzEwYLGKc=; b=dwmdcjHX7hy2UZtCwwlo08k0HvdUKZJkOy7o4a+t/xwoUdW2WbB6TeIi36r3NNuEYH u9lDawbgK9cLGXYSTud3a+2TenFi4TGR0nTyNsH0JFSigC/cqavKf56CGo59T5jI28/v kIFt6vLt5RdxFamTxTjBzNF4R1AwgHfTKvTxTqcNU4Gxi6zvAjsilfX5cUX7UfNRCcO2 I+ZfjP7Yc771qcLFUFT/vrrOAkRkKfxeaHEEt+4aYT1RsxSUqSUDV2U6tBCaMrPGEr9e sUmIqU6oOYOvMvZadyiBFJbc8mokvQE/AJqltT9y+WKocb54pDyl8YC8Qzz0V/G+i2+m RzmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="Ac/Dzu3F"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a14si16469222edb.100.2020.08.18.08.34.17; Tue, 18 Aug 2020 08:34:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="Ac/Dzu3F"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727932AbgHRPdh (ORCPT + 99 others); Tue, 18 Aug 2020 11:33:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727020AbgHRPdc (ORCPT ); Tue, 18 Aug 2020 11:33:32 -0400 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A1FAC061389 for ; Tue, 18 Aug 2020 08:33:32 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id di22so15572657edb.12 for ; Tue, 18 Aug 2020 08:33:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=a6JBuZhVYWp23R6HGvWW9nRcBBE4mX5ykNxzEwYLGKc=; b=Ac/Dzu3FoXOA6oUvQv+5yd66VJmRWG0TPTYZXLVCZhZ4XGLWHKfhHvYLK89FQ+LGKK bU8jBb9tSJU/9bNKH2g389dVKDn23kZ3IeUw0+p9c6iVLightb+zUKKgg7pN6l8WM7XN dTrSvLt5iuvwFupu3p0EAeJnaCYoYuw/Vn51w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=a6JBuZhVYWp23R6HGvWW9nRcBBE4mX5ykNxzEwYLGKc=; b=NOs0o9X4YwtUdxfbk8DB6lJdBsYQqrYGb8TUd2N7HDk5GzmlAjQ3pD/hajvPIjax22 iBcxbvuX1GBErRQ8fP8VWIRdsEgu9mXXH8ef2AR4hsLr2yoUpvkiaVzK+5ZG0HyKZwER vfF5bQ7kXXb+oA5823TqFQLCZukGiT2lM7GOsfJakPv3t0lHcsrEuV6zV2wVfaIsXzo5 5QbuqjcWy6yeZF3uveM+ovw6+yQr3SptUVUACfj31DD8YQvnokrCBKz9X30hfA/kb/Xe +2HOkNQKNvTx8Zk7QA4d9oDgjQOd8mdS33prCnjOEgmkdMjuu75ZRZJ4UhQR505bo+Ca nfrg== X-Gm-Message-State: AOAM532eBKwEgIQnAR9ZjIzrY90MBZcyhKoZETNegF8J9ATebODDnQ0B xD/zTwmOMn73/9/XjX86rA9i8g== X-Received: by 2002:a05:6402:3070:: with SMTP id bs16mr20055627edb.269.1597764810834; Tue, 18 Aug 2020 08:33:30 -0700 (PDT) Received: from [192.168.2.66] ([81.6.44.51]) by smtp.gmail.com with ESMTPSA id q2sm17169535edb.82.2020.08.18.08.33.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 Aug 2020 08:33:30 -0700 (PDT) Subject: Re: [PATCH bpf-next v8 5/7] bpf: Implement bpf_local_storage for inodes To: Martin KaFai Lau Cc: linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-security-module@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Paul Turner , Jann Horn , Florent Revest References: <20200803164655.1924498-1-kpsingh@chromium.org> <20200803164655.1924498-6-kpsingh@chromium.org> <20200818012758.4666zlknkr4x6cbl@kafai-mbp.dhcp.thefacebook.com> <60344fad-f761-0fee-a6ef-4880c45c3e52@chromium.org> <20200818152316.pkyko6gcpzeqp5sn@kafai-mbp.dhcp.thefacebook.com> From: KP Singh Message-ID: <9a1544ac-309b-4c16-3f6a-e34d90b275b8@chromium.org> Date: Tue, 18 Aug 2020 17:33:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200818152316.pkyko6gcpzeqp5sn@kafai-mbp.dhcp.thefacebook.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/18/20 5:23 PM, Martin KaFai Lau wrote: > On Tue, Aug 18, 2020 at 05:10:34PM +0200, KP Singh wrote: >> >> >> On 8/18/20 3:27 AM, Martin KaFai Lau wrote:>>> On Mon, Aug 03, 2020 at 06:46:53PM +0200, KP Singh wrote: [...] a get_file >> rather fcheck followed by get_file_rcu: >> >> #define get_file_rcu_many(x, cnt) \ >> atomic_long_add_unless(&(x)->f_count, (cnt), 0) >> #define get_file_rcu(x) get_file_rcu_many((x), 1) >> #define file_count(x) atomic_long_read(&(x)->f_count) >> >> But there is an easier way than all of this and this is to use >> fget_raw which also calls get_file_rcu_many >> and ensures a non-zero count before getting a reference. > ic. Make sense. > > There are fdget() and fdput() also which are used in bpf/syscall.c. Yeah we could use fdget_raw but we don't really need the struct fd but just the struct file. he non-raw versions masks away FMODE_PATH (O_PATH) files, we should still be able to access blobs on the O_PATH files, thus the _raw version here. - KP >