Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp454300pxv; Fri, 9 Jul 2021 01:40:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDUFTZcBgwp1fB0GN+gCBXr/TuNYUMsD9kyqgZ88+9A03eyctTW8iWE3ciYISyH650ewdr X-Received: by 2002:a50:c111:: with SMTP id l17mr31089946edf.56.1625820051779; Fri, 09 Jul 2021 01:40:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625820051; cv=none; d=google.com; s=arc-20160816; b=oVrtMg2MVGySPN22wKVfUlcaofU0y2t8/WTSj62b0YBeOnIdS5qlHLGJsMhB+MNBMQ W0ic/CRp2ByDu4d0GoA5O/z1V9yJT8zT9IvJmcFkC9uwEeuGDXT9dwigo8TgoobOxwXT lF51EZwMqM7JT6F2urbYTvfG6sZlRK/QYbeq3J8x0jfMD0stWXPGy53hGY2yOG6+LoD1 SV5+iUqI6BDuE0rzqt9fzrTR5ocOgTJgXBpqMNHYDktMbFsgW4IuJ62qIpJP7m5NnIqr rlJ6kXR6GVK9XJ+rojU4OUXIDG0/c6iHdRn4gHjquTptIZHqKcomjfN4MlWzcgfi3SH1 mevQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=8bEj019jrvnwdGkglI6E5CzUSpy76wRvciEMeizMMhM=; b=K9UbwjS7r/RIrlqdwNeqx9pPY+K6DDjBycDZDw8+VJEFNEzoRKnKweNnWc6L7rCLmr w7ureakxbL2bjzr88M2UB37vfMLznOm1k3caBNaVLKLbAls8Y/Z58CPkMVWYq6FesKLf 2mc4DUPizXSfsl8S9HOhLMAiQKaOTW9vJLrmTt48TynHcKBJhEgP55oBST+nMX6L52KO yzDi9DFKV9n0KmD2LqvurmDHjHYmSs7bhZ55jup3vIbQvOAyn0+929n+q/OXQjq/8BCw vh6k304R1rKhB36TodeVCYgu3npZaXB/bt+KU97UCyfAL0igY824ggDwCfOEGbgNVTu+ 9SIw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o19si4962193ejm.312.2021.07.09.01.40.27; Fri, 09 Jul 2021 01:40:51 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231573AbhGIImW (ORCPT + 99 others); Fri, 9 Jul 2021 04:42:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:49986 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231361AbhGIImW (ORCPT ); Fri, 9 Jul 2021 04:42:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A6F9B6127C; Fri, 9 Jul 2021 08:39:36 +0000 (UTC) Date: Fri, 9 Jul 2021 10:39:34 +0200 From: Christian Brauner To: Greg Kroah-Hartman Cc: Carlos Llamas , Arve =?utf-8?B?SGrDuG5uZXbDpWc=?= , Todd Kjos , Martijn Coenen , Christian Brauner , Joel Fernandes , Steven Moreland , kernel-team@android.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ANDROID: binderfs: add capabilities support Message-ID: <20210709083934.ghkohnqq4x23rs7d@wittgenstein> References: <20210707162419.15510-1-cmllamas@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 07, 2021 at 06:59:46PM +0200, Greg Kroah-Hartman wrote: > On Wed, Jul 07, 2021 at 04:24:19PM +0000, Carlos Llamas wrote: > > Provide userspace with a mechanism to discover binder driver > > capabilities to refrain from using these unsupported features > > in the first place. Note that older capabilities are assumed > > to be supported and only new ones will be added. > > What defines "new" vs. "old"? Where was the line drawn? > > > Signed-off-by: Carlos Llamas > > --- > > drivers/android/binderfs.c | 45 ++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 45 insertions(+) > > > > diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c > > index e80ba93c62a9..f793887f6dc8 100644 > > --- a/drivers/android/binderfs.c > > +++ b/drivers/android/binderfs.c > > @@ -58,6 +58,10 @@ enum binderfs_stats_mode { > > binderfs_stats_mode_global, > > }; > > > > +struct binder_capabilities { > > + bool oneway_spam; > > +}; > > + > > static const struct constant_table binderfs_param_stats[] = { > > { "global", binderfs_stats_mode_global }, > > {} > > @@ -69,6 +73,10 @@ static const struct fs_parameter_spec binderfs_fs_parameters[] = { > > {} > > }; > > > > +static struct binder_capabilities binder_caps = { > > + .oneway_spam = true, > > +}; > > + > > static inline struct binderfs_info *BINDERFS_SB(const struct super_block *sb) > > { > > return sb->s_fs_info; > > @@ -583,6 +591,39 @@ static struct dentry *binderfs_create_dir(struct dentry *parent, > > return dentry; > > } > > > > +static int binder_caps_show(struct seq_file *m, void *unused) > > +{ > > + bool *cap = m->private; > > + > > + seq_printf(m, "%d\n", *cap); > > + > > + return 0; > > +} > > +DEFINE_SHOW_ATTRIBUTE(binder_caps); > > + > > +static int init_binder_caps(struct super_block *sb) > > +{ > > + struct dentry *dentry, *root; > > + int ret = 0; > > + > > + root = binderfs_create_dir(sb->s_root, "caps"); > > + if (IS_ERR(root)) { > > + ret = PTR_ERR(root); > > + goto out; > > + } > > + > > + dentry = binderfs_create_file(root, "oneway_spam", > > + &binder_caps_fops, > > + &binder_caps.oneway_spam); > > + if (IS_ERR(dentry)) { > > + ret = PTR_ERR(dentry); > > + goto out; > > If this fails, you still report that an error happened, yet you do not > remove the directory? Is that intended? > > And where is this new file documented? Where are the existing binderfs > files documented? When I wrote it I added documentation to: Documentation/admin-guide/binderfs.rst So the new caps directory and file should be documented there. I would also suggest to add a simple test reading this new caps directory and the new file in there to: tools/testing/selftests/filesystems/binderfs_test.c Christian