Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp463154pxv; Fri, 9 Jul 2021 01:56:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyE/b7RxBhSKac/HhFDezaeewSHo6djpvHhodtAEf3fiaz3JtV5MislTUnx96zxpOkfFRih X-Received: by 2002:a5e:c905:: with SMTP id z5mr2658614iol.85.1625821008666; Fri, 09 Jul 2021 01:56:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625821008; cv=none; d=google.com; s=arc-20160816; b=sRNt4kYpzFsiGdHLHwUQlvD8Du1QMAm5CSDYOYZjIRDiOfgsDjIwrBliPuJ5AFFloT z0BoM/hRuAmIDyNtMSocyszXrpE2gNtGxtcyMs8qrIScDz3NhgerBjykS556fFU2Zf5n eVGcRfjxJ+W+7Hgl4WFI1EZbFJLHVgVPoWlPqubWj7lz27irF1xgVuyWgfWuvFxUEKwy +n/naSnoAwtWprE92Syaa5/9r1rhztJe4QNVG2jRMr+nhVYb0Za77TeuxmQm8Kgz96Fi TOfSJmOeYr1IoL0ZwHEyBZlmS5SBNZpV4d8WVaK1NzBmP16kFrHXpGKHwJJXqalEA+St N8OA== 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=hIB6da8cNjKkrR7NgkY1krhObD9TTt/n8Kyo2vzMpVw=; b=ZfmhIrJ4norb9EAuf33V1unaex3UrEHPjlQVB7kOzaBzKGfy03KwehMUu6ZajO6WjY pqqAHlEn7vq24Ka45EOBWfuWptih1WUSS4NKquICwOuYMqCODYjAMYxdh80khWfKU58z xYtAXQXGJml5LWtG3CYbg3+QYTF7k5gDrDYAgCToBISAenDreEd4+7fL8ESRMROn7rhN 71tBB25gAqNyr9FmBv8rZj6GKYZsARLXfVlwHWPV0K3187xnLmMtZFDufQaVccWRvNM+ rMF1n1Z4gyChxWu67wk9uts+vYDHyi1eAYHUlKIPy6sqt+IZHdChkPwrfv78NbiYBzae mz4g== 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 g17si5006119ilc.133.2021.07.09.01.56.36; Fri, 09 Jul 2021 01:56:48 -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 S231573AbhGII6q (ORCPT + 99 others); Fri, 9 Jul 2021 04:58:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:52244 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231494AbhGII6q (ORCPT ); Fri, 9 Jul 2021 04:58:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6DE9161375; Fri, 9 Jul 2021 08:56:00 +0000 (UTC) Date: Fri, 9 Jul 2021 10:55:57 +0200 From: Christian Brauner To: Carlos Llamas Cc: Greg Kroah-Hartman , 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: <20210709085557.2bx2vojtyw23jzch@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: <20210707162419.15510-1-cmllamas@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Hey Carlos, The model will be one file per feature? Instead of calling the directory "caps" should this maybe be called "features"? I'm not fuzzed about it and if you want to keep "caps" that's fine. The term is just a bit overused and makes me think of other things than this. > in the first place. Note that older capabilities are assumed > to be supported and only new ones will be added. What if you ever want to deprecate one? :) > > 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, I know this is the oneway spam _detection_ feature but this file makes it sound like the binder driver has the capability to generate one-way spam. :) Maybe name at least name the file "oneway_spam_detection". > +}; > + > 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) You can drop the goto here and just always return directly. > +{ > + struct dentry *dentry, *root; Please name this "dir" instead of "root". "root" is conventionally used for sb->s_root and especially here in this file I only ever used it to indicate s_root. > + int ret = 0; > + > + root = binderfs_create_dir(sb->s_root, "caps"); > + if (IS_ERR(root)) { > + ret = PTR_ERR(root); return 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); return PTR_ERR(root); > + goto out; > + } > + > +out: > + return ret; > +} > + > static int init_binder_logs(struct super_block *sb) > { > struct dentry *binder_logs_root_dir, *dentry, *proc_log_dir; > @@ -723,6 +764,10 @@ static int binderfs_fill_super(struct super_block *sb, struct fs_context *fc) > name++; > } > > + ret = init_binder_caps(sb); > + if (ret) > + return ret; > + > if (info->mount_opts.stats_mode == binderfs_stats_mode_global) > return init_binder_logs(sb); > > -- > 2.32.0.93.g670b81a890-goog >