Skip to contentSkip to conversation

linux-next: manual merge of the char-misc.current tree with the mm-hotfixes tree

DISCUSSION Stephen Rothwell 4 participants 9 messages Aug 18, 2022 – Aug 19, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi all,

Today's linux-next merge of the char-misc.current tree got a conflict in:

drivers/android/binder_alloc.c

between commit:

b3bb668f3dc6 ("binder_alloc: add missing mmap_lock calls when using the VMA")

from the mm-hotfixes tree and commit:

d6f35446d076 ("binder_alloc: Add missing mmap_lock calls when using the VMA")

from the char-misc.current tree.

I fixed it up (I used the latter as it was committed later even though the author times were the same) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.

Signature · 2 lines
Cheers,
Stephen Rothwell
#1 lore raw
Quoted 16 lines · Stephen Rothwell

Hi all,

Today's linux-next merge of the char-misc.current tree got a conflict in:

drivers/android/binder_alloc.c

between commit:

b3bb668f3dc6 ("binder_alloc: add missing mmap_lock calls when using the VMA")

from the mm-hotfixes tree and commit:

d6f35446d076 ("binder_alloc: Add missing mmap_lock calls when using the VMA")

from the char-misc.current tree.

Quoted 7 lines

I fixed it up (I used the latter as it was committed later even though the author times were the same) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.

These should be identical, if not, something went wrong :(

thanks,

greg k-h

author Tested-by Ondrej Mosnacek
#2 lore raw

Hi Greg,

Quoted 25 lines · On Fri, 19 Aug 2022 08:36:21 +0200 Greg KH <[email protected]> wrote:
Quoted 15 lines · Stephen Rothwell

Today's linux-next merge of the char-misc.current tree got a conflict in:

drivers/android/binder_alloc.c

between commit:

b3bb668f3dc6 ("binder_alloc: add missing mmap_lock calls when using the VMA")

from the mm-hotfixes tree and commit:

d6f35446d076 ("binder_alloc: Add missing mmap_lock calls when using the VMA")

from the char-misc.current tree.

Quoted 7 lines

I fixed it up (I used the latter as it was committed later even though the author times were the same) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.

Quoted 1 line

These should be identical, if not, something went wrong :(

Something went wrong :-)

$ git range-diff b3bb668f3dc6^..b3bb668f3dc6 d6f35446d076^..d6f35446d076
1:  b3bb668f3dc6 ! 1:  d6f35446d076 binder_alloc: add missing mmap_lock calls when using the VMA
    @@ Metadata
     Author: Liam Howlett <[email protected]>

## Commit message ##
- binder_alloc: add missing mmap_lock calls when using the VMA
+ binder_alloc: Add missing mmap_lock calls when using the VMA

- Take the mmap_read_lock() when using the VMA in binder_alloc_print_pages()
- and when checking for a VMA in binder_alloc_new_buf_locked().
+ Take the mmap_read_lock() when using the VMA in
+ binder_alloc_print_pages() and when checking for a VMA in
+ binder_alloc_new_buf_locked().

It is worth noting binder_alloc_new_buf_locked() drops the VMA read lock
- after it verifies a VMA exists, but may be taken again deeper in the call
- stack, if necessary.
+ after it verifies a VMA exists, but may be taken again deeper in the
+ call stack, if necessary.

- Link: https://lkml.kernel.org/r/[email protected]
- Fixes: a43cfc87caaf ("android: binder: stop saving a pointer to the VMA")
- Signed-off-by: Liam R. Howlett <[email protected]>
+ Fixes: a43cfc87caaf (android: binder: stop saving a pointer to the VMA)
+ Cc: stable <[email protected]>

- Reported-by: <[email protected]>
- Acked-by: Carlos Llamas <[email protected]>
+ Reported-by: [email protected]

- Cc: Minchan Kim <[email protected]>
- Cc: Christian Brauner (Microsoft) <[email protected]>
- Cc: Greg Kroah-Hartman <[email protected]>
- Cc: Hridya Valsaraju <[email protected]>
- Cc: Joel Fernandes <[email protected]>
- Cc: Martijn Coenen <[email protected]>
- Cc: Suren Baghdasaryan <[email protected]>
- Cc: Todd Kjos <[email protected]>
- Cc: Matthew Wilcox (Oracle) <[email protected]>
- Cc: "Arve Hjønnevåg" <[email protected]>
- Signed-off-by: Andrew Morton <[email protected]>
+ Acked-by: Carlos Llamas <[email protected]>
+ Signed-off-by: Liam R. Howlett <[email protected]>
+ Link: https://lore.kernel.org/r/[email protected]
+ Signed-off-by: Greg Kroah-Hartman <[email protected]>

## drivers/android/binder_alloc.c ##
@@ drivers/android/binder_alloc.c: static struct binder_buffer *binder_alloc_new_buf_locked(
@@ drivers/android/binder_alloc.c: void binder_alloc_print_pages(struct seq_file *m
- }
+
+ mmap_read_lock(alloc->vma_vm_mm);
-+ if (binder_alloc_get_vma(alloc) == NULL)
++ if (binder_alloc_get_vma(alloc) == NULL) {
++ mmap_read_unlock(alloc->vma_vm_mm);
+ goto uninitialized;
+ }
+
++ mmap_read_unlock(alloc->vma_vm_mm);
+ for (i = 0; i < alloc->buffer_size / PAGE_SIZE; i++) {
+ page = &alloc->pages[i];
+ if (!page->page_ptr)
@@ drivers/android/binder_alloc.c: void binder_alloc_print_pages(struct seq_file *m
+ active++;
+ else
+ lru++;
- }
++ }
+
+uninitialized:
-+ mmap_read_unlock(alloc->vma_vm_mm);
mutex_unlock(&alloc->mutex);
seq_printf(m, " pages: %d:%d:%d\n", active, lru, free);
seq_printf(m, " pages high watermark: %zu\n", alloc->pages_high);

Signature · 2 lines
Cheers,
Stephen Rothwell
#3 lore raw
Quoted 99 lines · Stephen Rothwell

Hi Greg,

Quoted 25 lines · On Fri, 19 Aug 2022 08:36:21 +0200 Greg KH <[email protected]> wrote:
Quoted 15 lines · Stephen Rothwell

Today's linux-next merge of the char-misc.current tree got a conflict in:

drivers/android/binder_alloc.c

between commit:

b3bb668f3dc6 ("binder_alloc: add missing mmap_lock calls when using the VMA")

from the mm-hotfixes tree and commit:

d6f35446d076 ("binder_alloc: Add missing mmap_lock calls when using the VMA")

from the char-misc.current tree.

Quoted 7 lines

I fixed it up (I used the latter as it was committed later even though the author times were the same) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.

Quoted 1 line

These should be identical, if not, something went wrong :(

Something went wrong :-)

$ git range-diff b3bb668f3dc6^..b3bb668f3dc6 d6f35446d076^..d6f35446d076
1:  b3bb668f3dc6 ! 1:  d6f35446d076 binder_alloc: add missing mmap_lock calls when using the VMA
    @@ Metadata
     Author: Liam Howlett <[email protected]>

## Commit message ##
- binder_alloc: add missing mmap_lock calls when using the VMA
+ binder_alloc: Add missing mmap_lock calls when using the VMA

- Take the mmap_read_lock() when using the VMA in binder_alloc_print_pages()
- and when checking for a VMA in binder_alloc_new_buf_locked().
+ Take the mmap_read_lock() when using the VMA in
+ binder_alloc_print_pages() and when checking for a VMA in
+ binder_alloc_new_buf_locked().

It is worth noting binder_alloc_new_buf_locked() drops the VMA read lock
- after it verifies a VMA exists, but may be taken again deeper in the call
- stack, if necessary.
+ after it verifies a VMA exists, but may be taken again deeper in the
+ call stack, if necessary.

- Link: https://lkml.kernel.org/r/[email protected]
- Fixes: a43cfc87caaf ("android: binder: stop saving a pointer to the VMA")
- Signed-off-by: Liam R. Howlett <[email protected]>
+ Fixes: a43cfc87caaf (android: binder: stop saving a pointer to the VMA)
+ Cc: stable <[email protected]>

- Reported-by: <[email protected]>
- Acked-by: Carlos Llamas <[email protected]>
+ Reported-by: [email protected]

- Cc: Minchan Kim <[email protected]>
- Cc: Christian Brauner (Microsoft) <[email protected]>
- Cc: Greg Kroah-Hartman <[email protected]>
- Cc: Hridya Valsaraju <[email protected]>
- Cc: Joel Fernandes <[email protected]>
- Cc: Martijn Coenen <[email protected]>
- Cc: Suren Baghdasaryan <[email protected]>
- Cc: Todd Kjos <[email protected]>
- Cc: Matthew Wilcox (Oracle) <[email protected]>
- Cc: "Arve Hjønnevåg" <[email protected]>
- Signed-off-by: Andrew Morton <[email protected]>
+ Acked-by: Carlos Llamas <[email protected]>
+ Signed-off-by: Liam R. Howlett <[email protected]>
+ Link: https://lore.kernel.org/r/[email protected]
+ Signed-off-by: Greg Kroah-Hartman <[email protected]>

## drivers/android/binder_alloc.c ##
@@ drivers/android/binder_alloc.c: static struct binder_buffer *binder_alloc_new_buf_locked(
@@ drivers/android/binder_alloc.c: void binder_alloc_print_pages(struct seq_file *m
- }
+
+ mmap_read_lock(alloc->vma_vm_mm);
-+ if (binder_alloc_get_vma(alloc) == NULL)
++ if (binder_alloc_get_vma(alloc) == NULL) {
++ mmap_read_unlock(alloc->vma_vm_mm);
+ goto uninitialized;
+ }
+
++ mmap_read_unlock(alloc->vma_vm_mm);
+ for (i = 0; i < alloc->buffer_size / PAGE_SIZE; i++) {
+ page = &alloc->pages[i];
+ if (!page->page_ptr)
@@ drivers/android/binder_alloc.c: void binder_alloc_print_pages(struct seq_file *m
+ active++;
+ else
+ lru++;

Quoted 9 lines

- }
++ }
+
+uninitialized:
-+ mmap_read_unlock(alloc->vma_vm_mm);
mutex_unlock(&alloc->mutex);
seq_printf(m, " pages: %d:%d:%d\n", active, lru, free); seq_printf(m, " pages high watermark: %zu\n", alloc->pages_high);

Oh wow, ok, I'll go drop my version and assume that Andrew's is the more correct one and let it come through his tree.

thanks,

greg k-h

#4 lore raw
Quoted 110 lines · Greg KH
Quoted 99 lines · Stephen Rothwell

Hi Greg,

Quoted 25 lines · On Fri, 19 Aug 2022 08:36:21 +0200 Greg KH <[email protected]> wrote:
Quoted 15 lines · Stephen Rothwell

Today's linux-next merge of the char-misc.current tree got a conflict in:

drivers/android/binder_alloc.c

between commit:

b3bb668f3dc6 ("binder_alloc: add missing mmap_lock calls when using the VMA")

from the mm-hotfixes tree and commit:

d6f35446d076 ("binder_alloc: Add missing mmap_lock calls when using the VMA")

from the char-misc.current tree.

Quoted 7 lines

I fixed it up (I used the latter as it was committed later even though the author times were the same) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.

Quoted 1 line

These should be identical, if not, something went wrong :(

Something went wrong :-)

$ git range-diff b3bb668f3dc6^..b3bb668f3dc6 d6f35446d076^..d6f35446d076
1:  b3bb668f3dc6 ! 1:  d6f35446d076 binder_alloc: add missing mmap_lock calls when using the VMA
    @@ Metadata
     Author: Liam Howlett <[email protected]>

## Commit message ##
- binder_alloc: add missing mmap_lock calls when using the VMA
+ binder_alloc: Add missing mmap_lock calls when using the VMA

- Take the mmap_read_lock() when using the VMA in binder_alloc_print_pages()
- and when checking for a VMA in binder_alloc_new_buf_locked().
+ Take the mmap_read_lock() when using the VMA in
+ binder_alloc_print_pages() and when checking for a VMA in
+ binder_alloc_new_buf_locked().

It is worth noting binder_alloc_new_buf_locked() drops the VMA read lock
- after it verifies a VMA exists, but may be taken again deeper in the call
- stack, if necessary.
+ after it verifies a VMA exists, but may be taken again deeper in the
+ call stack, if necessary.

- Link: https://lkml.kernel.org/r/[email protected]
- Fixes: a43cfc87caaf ("android: binder: stop saving a pointer to the VMA")
- Signed-off-by: Liam R. Howlett <[email protected]>
+ Fixes: a43cfc87caaf (android: binder: stop saving a pointer to the VMA)
+ Cc: stable <[email protected]>

- Reported-by: <[email protected]>
- Acked-by: Carlos Llamas <[email protected]>
+ Reported-by: [email protected]

- Cc: Minchan Kim <[email protected]>
- Cc: Christian Brauner (Microsoft) <[email protected]>
- Cc: Greg Kroah-Hartman <[email protected]>
- Cc: Hridya Valsaraju <[email protected]>
- Cc: Joel Fernandes <[email protected]>
- Cc: Martijn Coenen <[email protected]>
- Cc: Suren Baghdasaryan <[email protected]>
- Cc: Todd Kjos <[email protected]>
- Cc: Matthew Wilcox (Oracle) <[email protected]>
- Cc: "Arve Hjønnevåg" <[email protected]>
- Signed-off-by: Andrew Morton <[email protected]>
+ Acked-by: Carlos Llamas <[email protected]>
+ Signed-off-by: Liam R. Howlett <[email protected]>
+ Link: https://lore.kernel.org/r/[email protected]
+ Signed-off-by: Greg Kroah-Hartman <[email protected]>

## drivers/android/binder_alloc.c ##
@@ drivers/android/binder_alloc.c: static struct binder_buffer *binder_alloc_new_buf_locked(
@@ drivers/android/binder_alloc.c: void binder_alloc_print_pages(struct seq_file *m
- }
+
+ mmap_read_lock(alloc->vma_vm_mm);
-+ if (binder_alloc_get_vma(alloc) == NULL)
++ if (binder_alloc_get_vma(alloc) == NULL) {
++ mmap_read_unlock(alloc->vma_vm_mm);
+ goto uninitialized;
+ }
+
++ mmap_read_unlock(alloc->vma_vm_mm);
+ for (i = 0; i < alloc->buffer_size / PAGE_SIZE; i++) {
+ page = &alloc->pages[i];
+ if (!page->page_ptr)
@@ drivers/android/binder_alloc.c: void binder_alloc_print_pages(struct seq_file *m
+ active++;
+ else
+ lru++;

Quoted 9 lines

- }
++ }
+
+uninitialized:
-+ mmap_read_unlock(alloc->vma_vm_mm);
mutex_unlock(&alloc->mutex);
seq_printf(m, " pages: %d:%d:%d\n", active, lru, free); seq_printf(m, " pages high watermark: %zu\n", alloc->pages_high);

Quoted 3 lines

Oh wow, ok, I'll go drop my version and assume that Andrew's is the more correct one and let it come through his tree.

b3bb668f3dc6 is the older v1 of the patch [1]. d6f35446d076 from mm-hotfixes is the correct v2 version [2], although I don't think that's currently in mm-hotfixes-unstable. It looks like version 1 is now in mm-hotfixes-unstable as well.

1: https://lore.kernel.org/linux-mm/[email protected]/
2: https://lore.kernel.org/linux-mm/[email protected]/

Thanks,
Liam

#5 lore raw
Quoted 115 lines · Liam Howlett
Quoted 110 lines · Greg KH
Quoted 99 lines · Stephen Rothwell

Hi Greg,

Quoted 25 lines · On Fri, 19 Aug 2022 08:36:21 +0200 Greg KH <[email protected]> wrote:
Quoted 15 lines · Stephen Rothwell

Today's linux-next merge of the char-misc.current tree got a conflict in:

drivers/android/binder_alloc.c

between commit:

b3bb668f3dc6 ("binder_alloc: add missing mmap_lock calls when using the VMA")

from the mm-hotfixes tree and commit:

d6f35446d076 ("binder_alloc: Add missing mmap_lock calls when using the VMA")

from the char-misc.current tree.

Quoted 7 lines

I fixed it up (I used the latter as it was committed later even though the author times were the same) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.

Quoted 1 line

These should be identical, if not, something went wrong :(

Something went wrong :-)

$ git range-diff b3bb668f3dc6^..b3bb668f3dc6 d6f35446d076^..d6f35446d076
1:  b3bb668f3dc6 ! 1:  d6f35446d076 binder_alloc: add missing mmap_lock calls when using the VMA
    @@ Metadata
     Author: Liam Howlett <[email protected]>

## Commit message ##
- binder_alloc: add missing mmap_lock calls when using the VMA
+ binder_alloc: Add missing mmap_lock calls when using the VMA

- Take the mmap_read_lock() when using the VMA in binder_alloc_print_pages()
- and when checking for a VMA in binder_alloc_new_buf_locked().
+ Take the mmap_read_lock() when using the VMA in
+ binder_alloc_print_pages() and when checking for a VMA in
+ binder_alloc_new_buf_locked().

It is worth noting binder_alloc_new_buf_locked() drops the VMA read lock
- after it verifies a VMA exists, but may be taken again deeper in the call
- stack, if necessary.
+ after it verifies a VMA exists, but may be taken again deeper in the
+ call stack, if necessary.

- Link: https://lkml.kernel.org/r/[email protected]
- Fixes: a43cfc87caaf ("android: binder: stop saving a pointer to the VMA")
- Signed-off-by: Liam R. Howlett <[email protected]>
+ Fixes: a43cfc87caaf (android: binder: stop saving a pointer to the VMA)
+ Cc: stable <[email protected]>

- Reported-by: <[email protected]>
- Acked-by: Carlos Llamas <[email protected]>
+ Reported-by: [email protected]

- Cc: Minchan Kim <[email protected]>
- Cc: Christian Brauner (Microsoft) <[email protected]>
- Cc: Greg Kroah-Hartman <[email protected]>
- Cc: Hridya Valsaraju <[email protected]>
- Cc: Joel Fernandes <[email protected]>
- Cc: Martijn Coenen <[email protected]>
- Cc: Suren Baghdasaryan <[email protected]>
- Cc: Todd Kjos <[email protected]>
- Cc: Matthew Wilcox (Oracle) <[email protected]>
- Cc: "Arve Hjønnevåg" <[email protected]>
- Signed-off-by: Andrew Morton <[email protected]>
+ Acked-by: Carlos Llamas <[email protected]>
+ Signed-off-by: Liam R. Howlett <[email protected]>
+ Link: https://lore.kernel.org/r/[email protected]
+ Signed-off-by: Greg Kroah-Hartman <[email protected]>

## drivers/android/binder_alloc.c ##
@@ drivers/android/binder_alloc.c: static struct binder_buffer *binder_alloc_new_buf_locked(
@@ drivers/android/binder_alloc.c: void binder_alloc_print_pages(struct seq_file *m
- }
+
+ mmap_read_lock(alloc->vma_vm_mm);
-+ if (binder_alloc_get_vma(alloc) == NULL)
++ if (binder_alloc_get_vma(alloc) == NULL) {
++ mmap_read_unlock(alloc->vma_vm_mm);
+ goto uninitialized;
+ }
+
++ mmap_read_unlock(alloc->vma_vm_mm);
+ for (i = 0; i < alloc->buffer_size / PAGE_SIZE; i++) {
+ page = &alloc->pages[i];
+ if (!page->page_ptr)
@@ drivers/android/binder_alloc.c: void binder_alloc_print_pages(struct seq_file *m
+ active++;
+ else
+ lru++;

Quoted 9 lines

- }
++ }
+
+uninitialized:
-+ mmap_read_unlock(alloc->vma_vm_mm);
mutex_unlock(&alloc->mutex);
seq_printf(m, " pages: %d:%d:%d\n", active, lru, free); seq_printf(m, " pages high watermark: %zu\n", alloc->pages_high);

Quoted 3 lines

Oh wow, ok, I'll go drop my version and assume that Andrew's is the more correct one and let it come through his tree.

Quoted 7 lines

b3bb668f3dc6 is the older v1 of the patch [1]. d6f35446d076 from mm-hotfixes is the correct v2 version [2], although I don't think that's currently in mm-hotfixes-unstable. It looks like version 1 is now in mm-hotfixes-unstable as well.

1: https://lore.kernel.org/linux-mm/[email protected]/
2: https://lore.kernel.org/linux-mm/[email protected]/

I'll let you and Andrew fight this one out :)

Acked-by Carlos Llamas Tested-by Ondrej Mosnacek
#6 lore raw
In reply to Liam Howlett
Quoted 7 lines · On Fri, 19 Aug 2022 13:35:04 +0000 Liam Howlett <[email protected]> wrote:

b3bb668f3dc6 is the older v1 of the patch [1]. d6f35446d076 from mm-hotfixes is the correct v2 version [2], although I don't think that's currently in mm-hotfixes-unstable. It looks like version 1 is now in mm-hotfixes-unstable as well.

1: https://lore.kernel.org/linux-mm/[email protected]/
2: https://lore.kernel.org/linux-mm/[email protected]/

I moved "binder_alloc: add missing mmap_lock calls when using the VMA" into mm-hotfixes-stable this week.

It's the v2. I intend to send this Linuswards today or tomorrow. Below.

So I think we're all good.

commit b3bb668f3dc6a97a91c47a4cebb0e3f33554c08c

Author: Liam Howlett <[email protected]>
Date:   Wed Aug 10 16:02:25 2022 +0000

binder_alloc: add missing mmap_lock calls when using the VMA

Take the mmap_read_lock() when using the VMA in binder_alloc_print_pages() and when checking for a VMA in binder_alloc_new_buf_locked().

It is worth noting binder_alloc_new_buf_locked() drops the VMA read lock after it verifies a VMA exists, but may be taken again deeper in the call stack, if necessary.

Fixes a43cfc87caaf ("android: binder: stop saving a pointer to the VMA")
Cc Minchan Kim <[email protected]>
Cc Christian Brauner (Microsoft) <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Hridya Valsaraju <[email protected]>
Cc Joel Fernandes <[email protected]>
Cc Martijn Coenen <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
Cc Todd Kjos <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>
Cc "Arve Hjønnevåg" <[email protected]>
drivers/android/binder_alloc.c +19 -10
index 1014beb12802..d247742bb42e 100644
@@ -402,12 +402,15 @@ static struct binder_buffer *binder_alloc_new_buf_locked(
 	size_t size, data_offsets_size;
 	int ret;
 
+	mmap_read_lock(alloc->vma_vm_mm);
 	if (!binder_alloc_get_vma(alloc)) {
+		mmap_read_unlock(alloc->vma_vm_mm);
 		binder_alloc_debug(BINDER_DEBUG_USER_ERROR,
 				   "%d: binder_alloc_buf, no vma\n",
 				   alloc->pid);
 		return ERR_PTR(-ESRCH);
 	}
+	mmap_read_unlock(alloc->vma_vm_mm);
 
 	data_offsets_size = ALIGN(data_size, sizeof(void *)) +
 		ALIGN(offsets_size, sizeof(void *));
@@ -929,17 +932,23 @@ void binder_alloc_print_pages(struct seq_file *m,
 	 * Make sure the binder_alloc is fully initialized, otherwise we might
 	 * read inconsistent state.
 	 */
-	if (binder_alloc_get_vma(alloc) != NULL) {
-		for (i = 0; i < alloc->buffer_size / PAGE_SIZE; i++) {
-			page = &alloc->pages[i];
-			if (!page->page_ptr)
-				free++;
-			else if (list_empty(&page->lru))
-				active++;
-			else
-				lru++;
-		}
+
+	mmap_read_lock(alloc->vma_vm_mm);
+	if (binder_alloc_get_vma(alloc) == NULL)
+		goto uninitialized;
+
+	for (i = 0; i < alloc->buffer_size / PAGE_SIZE; i++) {
+		page = &alloc->pages[i];
+		if (!page->page_ptr)
+			free++;
+		else if (list_empty(&page->lru))
+			active++;
+		else
+			lru++;
 	}
+
+uninitialized:
+	mmap_read_unlock(alloc->vma_vm_mm);
 	mutex_unlock(&alloc->mutex);
 	seq_printf(m, "  pages: %d:%d:%d\n", active, lru, free);
 	seq_printf(m, "  pages high watermark: %zu\n", alloc->pages_high);
#7 lore raw
Quoted 13 lines · Andrew Morton
Quoted 7 lines · On Fri, 19 Aug 2022 13:35:04 +0000 Liam Howlett <[email protected]> wrote:

b3bb668f3dc6 is the older v1 of the patch [1]. d6f35446d076 from mm-hotfixes is the correct v2 version [2], although I don't think that's currently in mm-hotfixes-unstable. It looks like version 1 is now in mm-hotfixes-unstable as well.

1: https://lore.kernel.org/linux-mm/[email protected]/
2: https://lore.kernel.org/linux-mm/[email protected]/

I moved "binder_alloc: add missing mmap_lock calls when using the VMA" into mm-hotfixes-stable this week.

Quoted 6 lines

It's the v2. I intend to send this Linuswards today or tomorrow. Below.

So I think we're all good.

commit b3bb668f3dc6a97a91c47a4cebb0e3f33554c08c

...

Sounds good, as long as it isn't the above commit which is v1, but d6f35446d076 which is v2 :)

Thanks,
Liam

#8 lore raw
Quoted 8 lines · On Fri, 19 Aug 2022 22:02:53 +0000 Liam Howlett <[email protected]> wrote:
Quoted 8 lines

I moved "binder_alloc: add missing mmap_lock calls when using the VMA" into mm-hotfixes-stable this week.

It's the v2. I intend to send this Linuswards today or tomorrow. Below.

So I think we're all good.

Quoted 6 lines
Quoted 1 line

commit b3bb668f3dc6a97a91c47a4cebb0e3f33554c08c

...

Sounds good, as long as it isn't the above commit which is v1, but d6f35446d076 which is v2 :)

Well dang, I somehow messed that up. I have the v2 now.