Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp663334ybi; Fri, 2 Aug 2019 02:12:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqzH7O3BfsFHF52Kn26Q61XRdf7H4Zvka2PfLzmjY45nM0b13HyiUxQbdSB3CaCGAJOhrE9D X-Received: by 2002:a62:f202:: with SMTP id m2mr60489812pfh.6.1564737156735; Fri, 02 Aug 2019 02:12:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564737156; cv=none; d=google.com; s=arc-20160816; b=RQUKCR7YAs/rzvv8hOdSeTYrvCk85pV41v1YOd7T8aKPEIegjiOYTXPjqjS/30vL5q SpDlSASTZUCTN8DBYJ1zgwpsK9oM0e//xyIudyiX2jL5Hxe5F8I3UxK9RBqqAfoemv8H oWm+n/RbZpLIRZN4PD5WuSMaGizFGwi2AWl26sho8gkrPnk3q5fyHRXn2BwoKDDEZiq2 ZszDA/c3Wesh5G2bzn8qoTbAoy9vmLxUbJZtVgntcRXVTiY3ENwNx4Ypn6kEiVJFbpyx mvaAAXJx/2UrJ0BkxJGQ6lbKqsGAl+2o3Hwk7rBcyIc33E1UVfHf+uW9hbZNCSWuEg/R k3BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=KuJpN56DpMb+o7ZqGW5GTCfVakZKQ9jaNdHGo3dOzw0=; b=t6h9C4GDdF37llV5ohKXNF6p5TlVDBgnEipS//VRjSlERtl1Q/9W2t+NTSJ32GlhiE Q+LJ9od5kFauJt/x3ooNQm5gIBRFF1YqJqQ+/O5oz+zlW9MUi//EAfz5/bQpgFrIaC71 XMfApOnVZeTk0AcXbf4/dEMyQIMs5XlXYWPg3zB7H3ShQl+9Q0QyM0DhLz7nvEOFe0ev baiK7sJ6tgBfpvXDzGgIKJ9T0ymR42VQHpx9l+Mz8jrG+kWLIRuq8otqmRvUhH/dVQGx 8ewAgo4ucCsqSF4cRRikTvNIBDDukc2SKKAJnv93J0FXmVi9c2GdFXLXPjwAd+SVlJ37 E58Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wt2hZUnB; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f139si67796408pfa.2.2019.08.02.02.12.20; Fri, 02 Aug 2019 02:12:36 -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=@kernel.org header.s=default header.b=wt2hZUnB; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730453AbfHBGSm (ORCPT + 99 others); Fri, 2 Aug 2019 02:18:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:55016 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726667AbfHBGSm (ORCPT ); Fri, 2 Aug 2019 02:18:42 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B53C2206A3; Fri, 2 Aug 2019 06:18:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564726721; bh=S2K3wR2YDF5jGxl+ayK0HwksDCL5fZX4E5bkNRkkw6w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=wt2hZUnBBuDeU0ylH1gYzOMkO4yaW+uABg2cFnjUn+tsd/HWksAiDtDVZ0+/EUIgy JNYSiv1BEA8r9iewfHHSg3Z0lIBLnXlLOUVn9kFHtfthFrprIMCJEAnLgnw6TOeZ7j AwG0fVWgtT6LV87aqZ4NHRslk6GvazxhCpnFG+CQ= Date: Fri, 2 Aug 2019 08:18:38 +0200 From: Greg Kroah-Hartman To: Hridya Valsaraju Cc: Arve =?iso-8859-1?B?SGr4bm5lduVn?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-team@android.com, Christian Brauner Subject: Re: [PATCH] Add default binder devices through binderfs when configured Message-ID: <20190802061838.GA10844@kroah.com> References: <20190801223556.209184-1-hridya@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190801223556.209184-1-hridya@google.com> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 :( > /** > * 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. thanks, greg k-h