All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND PATCH] binderfs: reserve devices for initial mount
@ 2019-01-11 10:19 Christian Brauner
  2019-01-11 10:20 ` Christian Brauner
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Brauner @ 2019-01-11 10:19 UTC (permalink / raw)
  To: gregkh, tkjos, devel, linux-kernel
  Cc: arve, maco, joel, tkjos, Christian Brauner

The binderfs instance in the initial ipc namespace will always have a
reserve of 4 binder devices unless explicitly capped by specifying a lower
value via the "max" mount option.
This ensures when binder devices are removed (on accident or on purpose)
they can always be recreated without risking that all minor numbers have
already been used up.

Cc: Todd Kjos <tkjos@google.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
---
v2:
- patch unchanged
v1:
- patch introduced
v0:
- patch not present
---
 drivers/android/binderfs.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c
index f6341893b5ba..ad3ad2f7f9f4 100644
--- a/drivers/android/binderfs.c
+++ b/drivers/android/binderfs.c
@@ -40,6 +40,8 @@
 #define INODE_OFFSET 3
 #define INTSTRLEN 21
 #define BINDERFS_MAX_MINOR (1U << MINORBITS)
+/* Ensure that the initial ipc namespace always has devices available. */
+#define BINDERFS_MAX_MINOR_CAPPED (BINDERFS_MAX_MINOR - 4)
 
 static dev_t binderfs_dev;
 static DEFINE_MUTEX(binderfs_minors_mutex);
@@ -127,11 +129,14 @@ static int binderfs_binder_device_create(struct inode *ref_inode,
 	struct inode *inode = NULL;
 	struct super_block *sb = ref_inode->i_sb;
 	struct binderfs_info *info = sb->s_fs_info;
+	bool use_reserve = (info->ipc_ns == &init_ipc_ns);
 
 	/* Reserve new minor number for the new device. */
 	mutex_lock(&binderfs_minors_mutex);
 	if (++info->device_count <= info->mount_opts.max)
-		minor = ida_alloc_max(&binderfs_minors, BINDERFS_MAX_MINOR,
+		minor = ida_alloc_max(&binderfs_minors,
+				      use_reserve ? BINDERFS_MAX_MINOR :
+						    BINDERFS_MAX_MINOR_CAPPED,
 				      GFP_KERNEL);
 	else
 		minor = -ENOSPC;
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RESEND PATCH] binderfs: reserve devices for initial mount
  2019-01-11 10:19 [RESEND PATCH] binderfs: reserve devices for initial mount Christian Brauner
@ 2019-01-11 10:20 ` Christian Brauner
  2019-01-11 12:46   ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Brauner @ 2019-01-11 10:20 UTC (permalink / raw)
  To: gregkh, tkjos, devel, linux-kernel; +Cc: arve, maco, joel, tkjos

On Fri, Jan 11, 2019 at 11:19:40AM +0100, Christian Brauner wrote:
> The binderfs instance in the initial ipc namespace will always have a
> reserve of 4 binder devices unless explicitly capped by specifying a lower
> value via the "max" mount option.
> This ensures when binder devices are removed (on accident or on purpose)
> they can always be recreated without risking that all minor numbers have
> already been used up.
> 
> Cc: Todd Kjos <tkjos@google.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>

Cherry-picked this commit on top of char-misc-linus and it applied
cleanly. I hope I took the right branch?

Thanks!
Christian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RESEND PATCH] binderfs: reserve devices for initial mount
  2019-01-11 10:20 ` Christian Brauner
@ 2019-01-11 12:46   ` Greg KH
  0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2019-01-11 12:46 UTC (permalink / raw)
  To: Christian Brauner; +Cc: tkjos, devel, linux-kernel, arve, maco, joel, tkjos

On Fri, Jan 11, 2019 at 11:20:56AM +0100, Christian Brauner wrote:
> On Fri, Jan 11, 2019 at 11:19:40AM +0100, Christian Brauner wrote:
> > The binderfs instance in the initial ipc namespace will always have a
> > reserve of 4 binder devices unless explicitly capped by specifying a lower
> > value via the "max" mount option.
> > This ensures when binder devices are removed (on accident or on purpose)
> > they can always be recreated without risking that all minor numbers have
> > already been used up.
> > 
> > Cc: Todd Kjos <tkjos@google.com>
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
> 
> Cherry-picked this commit on top of char-misc-linus and it applied
> cleanly. I hope I took the right branch?

Yes, that was the right one, and the patch worked just fine, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-01-11 12:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-11 10:19 [RESEND PATCH] binderfs: reserve devices for initial mount Christian Brauner
2019-01-11 10:20 ` Christian Brauner
2019-01-11 12:46   ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.