mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Liam Howlett <liam.howlett@oracle.com>
To: Carlos Llamas <cmllamas@google.com>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Arve Hjønnevåg" <arve@android.com>,
	"Todd Kjos" <tkjos@android.com>,
	"Martijn Coenen" <maco@android.com>,
	"Joel Fernandes" <joel@joelfernandes.org>,
	"Christian Brauner" <brauner@kernel.org>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"kernel-team@android.com" <kernel-team@android.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 4/7] binder: remove binder_alloc_set_vma()
Date: Tue, 30 Aug 2022 18:57:59 +0000	[thread overview]
Message-ID: <20220830185751.gpudzi2pv3jpjoib@revolver> (raw)
In-Reply-To: <20220829201254.1814484-5-cmllamas@google.com>

* Carlos Llamas <cmllamas@google.com> [220829 16:13]:
> The mmap_locked asserts here are not needed since this is only called
> back from the mmap stack in ->mmap() and ->close() which always acquire
> the lock first. Remove these asserts along with binder_alloc_set_vma()
> altogether since it's trivial enough to be consumed by callers.

I agree that it is not called anywhere else today.  I think it's still
worth while since these asserts do nothing if you don't build with
lockdep and/or debug_vm enabled.  I was hoping having these here would
avoid future mistakes a lot like what we have in the mm code's
find_vma() (mm/mmap.c ~L2297).


> 
> Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
> Signed-off-by: Carlos Llamas <cmllamas@google.com>
> ---
>  drivers/android/binder_alloc.c | 25 ++-----------------------
>  1 file changed, 2 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c
> index 749a4cd30a83..1c39cfce32fa 100644
> --- a/drivers/android/binder_alloc.c
> +++ b/drivers/android/binder_alloc.c
> @@ -309,27 +309,6 @@ static int binder_update_page_range(struct binder_alloc *alloc, int allocate,
>  	return vma ? -ENOMEM : -ESRCH;
>  }
>  
> -
> -static inline void binder_alloc_set_vma(struct binder_alloc *alloc,
> -		struct vm_area_struct *vma)
> -{
> -	unsigned long vm_start = 0;
> -
> -	/*
> -	 * Allow clearing the vma with holding just the read lock to allow
> -	 * munmapping downgrade of the write lock before freeing and closing the
> -	 * file using binder_alloc_vma_close().
> -	 */
> -	if (vma) {
> -		vm_start = vma->vm_start;
> -		mmap_assert_write_locked(alloc->mm);
> -	} else {
> -		mmap_assert_locked(alloc->mm);
> -	}
> -
> -	alloc->vma_addr = vm_start;
> -}
> -
>  static inline struct vm_area_struct *binder_alloc_get_vma(
>  		struct binder_alloc *alloc)
>  {
> @@ -793,7 +772,7 @@ int binder_alloc_mmap_handler(struct binder_alloc *alloc,
>  	buffer->free = 1;
>  	binder_insert_free_buffer(alloc, buffer);
>  	alloc->free_async_space = alloc->buffer_size / 2;
> -	binder_alloc_set_vma(alloc, vma);
> +	alloc->vma_addr = vma->vm_start;
>  
>  	return 0;
>  
> @@ -983,7 +962,7 @@ int binder_alloc_get_allocated_count(struct binder_alloc *alloc)
>   */
>  void binder_alloc_vma_close(struct binder_alloc *alloc)
>  {
> -	binder_alloc_set_vma(alloc, NULL);
> +	alloc->vma_addr = 0;
>  }
>  
>  /**
> -- 
> 2.37.2.672.g94769d06f0-goog
> 

  reply	other threads:[~2022-08-30 18:58 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-29 20:12 [PATCH 0/7] fix null-ptr-deref in binder_alloc and others Carlos Llamas
2022-08-29 20:12 ` [PATCH 1/7] binder: fix alloc->vma_vm_mm null-ptr dereference Carlos Llamas
2022-08-29 20:34   ` Andrew Morton
2022-08-29 21:20     ` Carlos Llamas
2022-08-30 19:06   ` Liam Howlett
2022-08-30 19:40     ` Carlos Llamas
2022-08-30 20:30       ` Liam Howlett
2022-08-30 22:26   ` Todd Kjos
2022-08-29 20:12 ` [PATCH 2/7] binder: fix trivial kernel-doc typo Carlos Llamas
2022-08-30  7:53   ` Christian Brauner
2022-08-30 22:20   ` Todd Kjos
2022-08-29 20:12 ` [PATCH 3/7] binder: rename alloc->vma_vm_mm to alloc->mm Carlos Llamas
2022-08-30  7:56   ` Christian Brauner
2022-08-30 22:20   ` Todd Kjos
2022-08-29 20:12 ` [PATCH 4/7] binder: remove binder_alloc_set_vma() Carlos Llamas
2022-08-30 18:57   ` Liam Howlett [this message]
2022-08-30 21:08     ` Carlos Llamas
2022-08-29 20:12 ` [PATCH 5/7] binder: remove unused binder_alloc->buffer_free Carlos Llamas
2022-08-30  7:57   ` Christian Brauner
2022-08-30 22:21   ` Todd Kjos
2022-08-29 20:12 ` [PATCH 6/7] binder: fix binder_alloc kernel-doc warnings Carlos Llamas
2022-08-30  7:53   ` Christian Brauner
2022-08-30 22:22   ` Todd Kjos
2022-08-29 20:12 ` [PATCH 7/7] binderfs: remove unused INTSTRLEN macro Carlos Llamas
2022-08-30  7:53   ` Christian Brauner
2022-09-01 14:18 ` [PATCH 0/7] fix null-ptr-deref in binder_alloc and others Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220830185751.gpudzi2pv3jpjoib@revolver \
    --to=liam.howlett@oracle.com \
    --cc=arve@android.com \
    --cc=brauner@kernel.org \
    --cc=cmllamas@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=joel@joelfernandes.org \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maco@android.com \
    --cc=surenb@google.com \
    --cc=tkjos@android.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®