diff mbox series

[v4,15/49] ipc/shm: Use the vma iterator for munmap calls

Message ID 20230120162650.984577-16-Liam.Howlett@oracle.com (mailing list archive)
State New
Headers show
Series VMA tree type safety and remove __vma_adjust() | expand

Commit Message

Liam R. Howlett Jan. 20, 2023, 4:26 p.m. UTC
From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>

Pass through the vma iterator to do_vmi_munmap() to handle the iterator
state internally

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
---
 ipc/shm.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

Comments

Sven Schnelle Jan. 25, 2023, 11 a.m. UTC | #1
Hi Liam,

"Liam R. Howlett" <Liam.Howlett@oracle.com> writes:

> From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>
>
> Pass through the vma iterator to do_vmi_munmap() to handle the iterator
> state internally
>
> Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
> ---
>  ipc/shm.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)

git bisect says this breaks the shm* testcase in ltp on (at least) s390:

# ./test.sh
tst_test.c:1558: TINFO: Timeout per run is 0h 00m 30s
shmat01.c:124: TPASS: shmat() succeeded to attach NULL address
shmat01.c:92: TFAIL: shmat() failed: EINVAL (22)
shmat01.c:92: TFAIL: shmat() failed: EINVAL (22)
shmat01.c:92: TFAIL: shmat() failed: EINVAL (22)

Summary:
passed   1
failed   3
broken   0
skipped  0
warnings 0

#

Can you take a look? Thanks!

reverting the above commit fixes the issue.

Thanks,
Sven
Liam R. Howlett Jan. 25, 2023, 1:53 p.m. UTC | #2
* Sven Schnelle <svens@linux.ibm.com> [230125 06:00]:
> Hi Liam,
> 
> "Liam R. Howlett" <Liam.Howlett@oracle.com> writes:
> 
> > From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>
> >
> > Pass through the vma iterator to do_vmi_munmap() to handle the iterator
> > state internally
> >
> > Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
> > ---
> >  ipc/shm.c | 11 +++++------
> >  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> git bisect says this breaks the shm* testcase in ltp on (at least) s390:
> 
> # ./test.sh
> tst_test.c:1558: TINFO: Timeout per run is 0h 00m 30s
> shmat01.c:124: TPASS: shmat() succeeded to attach NULL address
> shmat01.c:92: TFAIL: shmat() failed: EINVAL (22)
> shmat01.c:92: TFAIL: shmat() failed: EINVAL (22)
> shmat01.c:92: TFAIL: shmat() failed: EINVAL (22)
> 
> Summary:
> passed   1
> failed   3
> broken   0
> skipped  0
> warnings 0
> 
> #
> 
> Can you take a look? Thanks!
> 
> reverting the above commit fixes the issue.

Thanks for testing this and letting me know.

I'll have a look.

Regards,
Liam
diff mbox series

Patch

diff --git a/ipc/shm.c b/ipc/shm.c
index bd2fcc4d454e..1c6a6b319a49 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -1786,8 +1786,8 @@  long ksys_shmdt(char __user *shmaddr)
 			 */
 			file = vma->vm_file;
 			size = i_size_read(file_inode(vma->vm_file));
-			do_munmap(mm, vma->vm_start, vma->vm_end - vma->vm_start, NULL);
-			mas_pause(&vmi.mas);
+			do_vmi_munmap(&vmi, mm, vma->vm_start,
+			      vma->vm_end - vma->vm_start, NULL, false);
 			/*
 			 * We discovered the size of the shm segment, so
 			 * break out of here and fall through to the next
@@ -1810,10 +1810,9 @@  long ksys_shmdt(char __user *shmaddr)
 		/* finding a matching vma now does not alter retval */
 		if ((vma->vm_ops == &shm_vm_ops) &&
 		    ((vma->vm_start - addr)/PAGE_SIZE == vma->vm_pgoff) &&
-		    (vma->vm_file == file)) {
-			do_munmap(mm, vma->vm_start, vma->vm_end - vma->vm_start, NULL);
-			mas_pause(&vmi.mas);
-		}
+		    (vma->vm_file == file))
+			do_vmi_munmap(&vmi, mm, vma->vm_start,
+			      vma->vm_end - vma->vm_start, NULL, false);
 
 		vma = vma_next(&vmi);
 	}