Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp1185729ybh; Sat, 3 Aug 2019 20:04:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxSYGZwvPE0j8uimFo4YY6THm0BrZC5850DW78dWme04VxILKTJowZcypCYQrNJRTxAdcQ/ X-Received: by 2002:a62:3895:: with SMTP id f143mr66218337pfa.116.1564887877464; Sat, 03 Aug 2019 20:04:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564887877; cv=none; d=google.com; s=arc-20160816; b=yZMIr/si9e15KABdwrLUs+7OkkBXU/ntO5/N9+jc5azGIDg0lbKrvQALvxNrIi8q5/ jPAirSeT8bRUut7DnHyvwLot+tl4PZAkbgvhlWiEeanAVgo74HkIbUxQ3Conq6VqtM8Z cdruCoqYTleXq60y+NmGb7jma3xauYEZt0CJ5huGVcEO1t1XYJMwdpU4HAF9LGxbcX6H a6fouf+fq/Bdy9HGw8BgyXTS6OrxxTsY74rpC/CO8+a/njhltWbEXK4g/jVqQie6c3X1 CyySLiPP5F7wTJ+syB5VDyBJt0udMUD1kiP9TbhcfUH6U1BbZ/tCPPRzKgs6bgwxe8to ea2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=rGuW4tG7YREvM0Tkwd56d78mTsuSaz2wZqP3WJdbo78=; b=kY2HDDfP7w0MrMqQxnsag67zpzDiq+IvvGEjQS93MznfFTE5SAFkLRVPl2zVjNzHur +T48MDVkbqF80nu8cH9n3aYQmgRFjqV9r2cvL03wG9lzwoVxzwOrELIjxVW2x5yd9cqj EsOw52a0rkBwAYnoZfL9lroZRNnP2v84Cb2yt+Ahyvn3V8DpooJHwlnrFeAMrIPJX9W7 UdEDLhHhBJZ9LIyInYsuyUiooF39a6mzU6RV1+LfYQX58LWXkBd66PlmoR8345BXR7yW Uytk44vfTr0wAN6eAOEM7lBwAtuGyYTAYri/rDXzVyh1ikbrGLmYqjOW/Au+T0G86kd8 TTDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JS5WCbbg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t27si39893440pgk.502.2019.08.03.20.04.22; Sat, 03 Aug 2019 20:04:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JS5WCbbg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395220AbfHBV5o (ORCPT + 99 others); Fri, 2 Aug 2019 17:57:44 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:40955 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730163AbfHBV5o (ORCPT ); Fri, 2 Aug 2019 17:57:44 -0400 Received: by mail-oi1-f193.google.com with SMTP id w196so36571942oie.7 for ; Fri, 02 Aug 2019 14:57:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rGuW4tG7YREvM0Tkwd56d78mTsuSaz2wZqP3WJdbo78=; b=JS5WCbbgJ3urA3aE1jNreeG23PyNNrBu5EuDNauGNuCJrtFegQgUqeLFkSkbsKGOYH pvh9Sen+L9CA7iU0/uPc80Y2VrIGgThDoLA9CWPkMmK9zdDHBUyTKJUE2udzdFxpGdzH q3yX2kbeXOppHH36whi5FbxLvQsF1RvceEhIOZIbxjrOQ1IdStcU8n5Kj+1kPfNncxGO C5k7qxldqyCJ3InOq1iLhKCfwEXH7CTG4aw77tgJCBPFmd7GzaEVD17Myl5tX60I/1II pIfFxOYWJWxXH7fg2UtPQ6Ix2nYObRj08Gu1jFUel6COnkLdKzCuj+KtRHmWA/P3QRXp ZChA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rGuW4tG7YREvM0Tkwd56d78mTsuSaz2wZqP3WJdbo78=; b=kgRN0op7fFOEjb4QA2AbDhFXJMKpsz+tWM58Dt5Jo/2lFL8jRtYGgMxd8tn4O6BQmF jeNwRXate7v0tyO/vSJkKfmauVIo7qsJiWUvOBDNXheKNqFOYkwy8zYQOVwtPozEy4FF HT//lvUe5hPVF6J4Gd+tn/N0wLIL5uV0r8L4xlPAIKwYwYqQFVOXrn4TS8PsI/8untbK TpFVHJtD23Ojv+ZftMheWqwE+mTuZx0UdkdRhGB/4kGTZSFlM5V+JvjA32JEmsrQmIG0 X/R9bBPLkaJmvaveO5he3DOlYotzzIjtnpkV+YUMQZrY1Qz7P5NAsemJBnb+CGhFbKOm gH+g== X-Gm-Message-State: APjAAAWHwOXhr5IbNFTmKiMaaszS7o2Y7HgaG+ryfKBApVvdzdjPShPr CVVw/vr2zSvl1ETCamfibOkbSkhIxZiM/+NKLE420w== X-Received: by 2002:a54:4f95:: with SMTP id g21mr4070854oiy.23.1564783062470; Fri, 02 Aug 2019 14:57:42 -0700 (PDT) MIME-Version: 1.0 References: <20190801223556.209184-1-hridya@google.com> <20190802061838.GA10844@kroah.com> <20190802150612.eff7t42256pvxuja@brauner.io> In-Reply-To: <20190802150612.eff7t42256pvxuja@brauner.io> From: Hridya Valsaraju Date: Fri, 2 Aug 2019 14:57:06 -0700 Message-ID: Subject: Re: [PATCH] Add default binder devices through binderfs when configured To: Christian Brauner Cc: Greg Kroah-Hartman , =?UTF-8?B?QXJ2ZSBIasO4bm5ldsOlZw==?= , Todd Kjos , Martijn Coenen , Joel Fernandes , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-team@android.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 2, 2019 at 8:06 AM Christian Brauner wrote: > > On Fri, Aug 02, 2019 at 08:18:38AM +0200, Greg Kroah-Hartman wrote: > > On Thu, Aug 01, 2019 at 03:35:56PM -0700, Hridya Valsaraju wrote: > > > If CONFIG_ANDROID_BINDERFS is set, the default binder devices > > > specified by CONFIG_ANDROID_BINDER_DEVICES are created in each > > > binderfs instance instead of global devices being created by > > > the binder driver. > > > > > > Co-developed-by: Christian Brauner > > > Signed-off-by: Christian Brauner > > > Signed-off-by: Hridya Valsaraju > > > --- > > > drivers/android/binder.c | 3 ++- > > > drivers/android/binderfs.c | 46 ++++++++++++++++++++++++++++++++++---- > > > 2 files changed, 44 insertions(+), 5 deletions(-) > > > > > > diff --git a/drivers/android/binder.c b/drivers/android/binder.c > > > index 466b6a7f8ab7..65a99ac26711 100644 > > > --- a/drivers/android/binder.c > > > +++ b/drivers/android/binder.c > > > @@ -6279,7 +6279,8 @@ static int __init binder_init(void) > > > &transaction_log_fops); > > > } > > > > > > - if (strcmp(binder_devices_param, "") != 0) { > > > + if (!IS_ENABLED(CONFIG_ANDROID_BINDERFS) && > > > + strcmp(binder_devices_param, "") != 0) { > > > /* > > > * Copy the module_parameter string, because we don't want to > > > * tokenize it in-place. > > > diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c > > > index e773f45d19d9..9f5ed50ffd70 100644 > > > --- a/drivers/android/binderfs.c > > > +++ b/drivers/android/binderfs.c > > > @@ -48,6 +48,10 @@ static dev_t binderfs_dev; > > > static DEFINE_MUTEX(binderfs_minors_mutex); > > > static DEFINE_IDA(binderfs_minors); > > > > > > +static char *binder_devices_param = CONFIG_ANDROID_BINDER_DEVICES; > > > +module_param_named(devices, binder_devices_param, charp, 0444); > > > +MODULE_PARM_DESC(devices, "Binder devices to be created by default"); > > > + > > > > Why are you creating a module parameter? That was not in your changelog > > :( > > Yeah, you don't need an additional module parameter. You can just move > > static char *binder_devices_param = CONFIG_ANDROID_BINDER_DEVICES; > module_param_named(devices, binder_devices_param, charp, 0444); > > from binder.c to binder_internal.h and expose it to binder.c and > binderfs.c this way. This will work just fine since binderfs.c doesn't > modify the parameter and binder.c makes a copy of it before doing so. > > > > > > > > > > /** > > > * binderfs_mount_opts - mount options for binderfs > > > * @max: maximum number of allocatable binderfs binder devices > > > @@ -135,7 +139,6 @@ static int binderfs_binder_device_create(struct inode *ref_inode, > > > #else > > > bool use_reserve = true; > > > #endif > > > - > > > /* Reserve new minor number for the new device. */ > > > mutex_lock(&binderfs_minors_mutex); > > > if (++info->device_count <= info->mount_opts.max) > > > @@ -186,8 +189,7 @@ static int binderfs_binder_device_create(struct inode *ref_inode, > > > req->major = MAJOR(binderfs_dev); > > > req->minor = minor; > > > > > > - ret = copy_to_user(userp, req, sizeof(*req)); > > > - if (ret) { > > > + if (userp && copy_to_user(userp, req, sizeof(*req))) { > > > ret = -EFAULT; > > > goto err; > > > } > > > @@ -467,6 +469,9 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent) > > > int ret; > > > struct binderfs_info *info; > > > struct inode *inode = NULL; > > > + struct binderfs_device device_info = { 0 }; > > > + const char *name; > > > + size_t len; > > > > > > sb->s_blocksize = PAGE_SIZE; > > > sb->s_blocksize_bits = PAGE_SHIFT; > > > @@ -521,7 +526,28 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent) > > > if (!sb->s_root) > > > return -ENOMEM; > > > > > > - return binderfs_binder_ctl_create(sb); > > > + ret = binderfs_binder_ctl_create(sb); > > > + if (ret) > > > + return ret; > > > + > > > + name = binder_devices_param; > > > + for (len = strcspn(name, ","); len > 0; len = strcspn(name, ",")) { > > > + /* > > > + * init_binderfs() has already checked that the length of > > > + * device_name_entry->name is not greater than device_info.name. > > > + */ > > > + strscpy(device_info.name, name, len + 1); > > > + ret = binderfs_binder_device_create(inode, NULL, &device_info); > > > + if (ret) > > > + return ret; > > > + name += len; > > > + if (*name == ',') > > > + name++; > > > + > > > + } > > > + > > > + return 0; > > > + > > > } > > > > > > static struct dentry *binderfs_mount(struct file_system_type *fs_type, > > > @@ -553,6 +579,18 @@ static struct file_system_type binder_fs_type = { > > > int __init init_binderfs(void) > > > { > > > int ret; > > > + const char *name; > > > + size_t len; > > > + > > > + /* Verify that the default binderfs device names are valid. */ > > > + name = binder_devices_param; > > > + for (len = strcspn(name, ","); len > 0; len = strcspn(name, ",")) { > > > + if (len > BINDERFS_MAX_NAME) > > > + return -E2BIG; > > > + name += len; > > > + if (*name == ',') > > > + name++; > > > + } > > > > This verification should be a separate patch, right? > > > > But the real issue here is I have no idea _why_ you are wanting this > > patch. The changelog text says _what_ you are doing only, which isn't > > ok. > > > > Please provide more information as to why this is needed, what problem > > it is solving, and break this up into a patch series and resend. Thank you Greg and Christian, I will address all issues in v2 and resend. > > > > thanks, > > > > greg k-h > > -- > To unsubscribe from this group and stop receiving emails from it, send an email to kernel-team+unsubscribe@android.com. >