All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] mm/gup: pass flags by value in faultin_page
@ 2024-03-17 12:46 yorha.op
  2024-03-18 12:29 ` David Hildenbrand
  0 siblings, 1 reply; 2+ messages in thread
From: yorha.op @ 2024-03-17 12:46 UTC (permalink / raw)
  To: linux-mm, linux-kernel; +Cc: Alex Rusuf

From: Alex Rusuf <yorha.op@gmail.com>

There's no need to pass flags as a pointer,
because it's not expected to be changed now.

Signed-off-by: Alex Rusuf <yorha.op@gmail.com>
---
 mm/gup.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/mm/gup.c b/mm/gup.c
index 231711efa390..f308785fa530 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -915,19 +915,19 @@ static int get_gate_page(struct mm_struct *mm, unsigned long address,
  * to 0 and -EBUSY returned.
  */
 static int faultin_page(struct vm_area_struct *vma,
-		unsigned long address, unsigned int *flags, bool unshare,
+		unsigned long address, unsigned int flags, bool unshare,
 		int *locked)
 {
 	unsigned int fault_flags = 0;
 	vm_fault_t ret;
 
-	if (*flags & FOLL_NOFAULT)
+	if (flags & FOLL_NOFAULT)
 		return -EFAULT;
-	if (*flags & FOLL_WRITE)
+	if (flags & FOLL_WRITE)
 		fault_flags |= FAULT_FLAG_WRITE;
-	if (*flags & FOLL_REMOTE)
+	if (flags & FOLL_REMOTE)
 		fault_flags |= FAULT_FLAG_REMOTE;
-	if (*flags & FOLL_UNLOCKABLE) {
+	if (flags & FOLL_UNLOCKABLE) {
 		fault_flags |= FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
 		/*
 		 * FAULT_FLAG_INTERRUPTIBLE is opt-in. GUP callers must set
@@ -935,12 +935,12 @@ static int faultin_page(struct vm_area_struct *vma,
 		 * That's because some callers may not be prepared to
 		 * handle early exits caused by non-fatal signals.
 		 */
-		if (*flags & FOLL_INTERRUPTIBLE)
+		if (flags & FOLL_INTERRUPTIBLE)
 			fault_flags |= FAULT_FLAG_INTERRUPTIBLE;
 	}
-	if (*flags & FOLL_NOWAIT)
+	if (flags & FOLL_NOWAIT)
 		fault_flags |= FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_RETRY_NOWAIT;
-	if (*flags & FOLL_TRIED) {
+	if (flags & FOLL_TRIED) {
 		/*
 		 * Note: FAULT_FLAG_ALLOW_RETRY and FAULT_FLAG_TRIED
 		 * can co-exist
@@ -974,7 +974,7 @@ static int faultin_page(struct vm_area_struct *vma,
 	}
 
 	if (ret & VM_FAULT_ERROR) {
-		int err = vm_fault_to_errno(ret, *flags);
+		int err = vm_fault_to_errno(ret, flags);
 
 		if (err)
 			return err;
@@ -1236,7 +1236,7 @@ static long __get_user_pages(struct mm_struct *mm,
 
 		page = follow_page_mask(vma, start, foll_flags, &ctx);
 		if (!page || PTR_ERR(page) == -EMLINK) {
-			ret = faultin_page(vma, start, &foll_flags,
+			ret = faultin_page(vma, start, foll_flags,
 					   PTR_ERR(page) == -EMLINK, locked);
 			switch (ret) {
 			case 0:
-- 
2.42.0


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

* Re: [PATCH 1/1] mm/gup: pass flags by value in faultin_page
  2024-03-17 12:46 [PATCH 1/1] mm/gup: pass flags by value in faultin_page yorha.op
@ 2024-03-18 12:29 ` David Hildenbrand
  0 siblings, 0 replies; 2+ messages in thread
From: David Hildenbrand @ 2024-03-18 12:29 UTC (permalink / raw)
  To: yorha.op, linux-mm, linux-kernel

On 17.03.24 13:46, yorha.op@gmail.com wrote:
> From: Alex Rusuf <yorha.op@gmail.com>
> 
> There's no need to pass flags as a pointer,
> because it's not expected to be changed now.
> 
> Signed-off-by: Alex Rusuf <yorha.op@gmail.com>
> ---
>   mm/gup.c | 20 ++++++++++----------
>   1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/mm/gup.c b/mm/gup.c
> index 231711efa390..f308785fa530 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -915,19 +915,19 @@ static int get_gate_page(struct mm_struct *mm, unsigned long address,
>    * to 0 and -EBUSY returned.
>    */
>   static int faultin_page(struct vm_area_struct *vma,
> -		unsigned long address, unsigned int *flags, bool unshare,
> +		unsigned long address, unsigned int flags, bool unshare,
>   		int *locked)
>   {
>   	unsigned int fault_flags = 0;
>   	vm_fault_t ret;
>   
> -	if (*flags & FOLL_NOFAULT)
> +	if (flags & FOLL_NOFAULT)
>   		return -EFAULT;
> -	if (*flags & FOLL_WRITE)
> +	if (flags & FOLL_WRITE)
>   		fault_flags |= FAULT_FLAG_WRITE;
> -	if (*flags & FOLL_REMOTE)
> +	if (flags & FOLL_REMOTE)
>   		fault_flags |= FAULT_FLAG_REMOTE;
> -	if (*flags & FOLL_UNLOCKABLE) {
> +	if (flags & FOLL_UNLOCKABLE) {
>   		fault_flags |= FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
>   		/*
>   		 * FAULT_FLAG_INTERRUPTIBLE is opt-in. GUP callers must set
> @@ -935,12 +935,12 @@ static int faultin_page(struct vm_area_struct *vma,
>   		 * That's because some callers may not be prepared to
>   		 * handle early exits caused by non-fatal signals.
>   		 */
> -		if (*flags & FOLL_INTERRUPTIBLE)
> +		if (flags & FOLL_INTERRUPTIBLE)
>   			fault_flags |= FAULT_FLAG_INTERRUPTIBLE;
>   	}
> -	if (*flags & FOLL_NOWAIT)
> +	if (flags & FOLL_NOWAIT)
>   		fault_flags |= FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_RETRY_NOWAIT;
> -	if (*flags & FOLL_TRIED) {
> +	if (flags & FOLL_TRIED) {
>   		/*
>   		 * Note: FAULT_FLAG_ALLOW_RETRY and FAULT_FLAG_TRIED
>   		 * can co-exist
> @@ -974,7 +974,7 @@ static int faultin_page(struct vm_area_struct *vma,
>   	}
>   
>   	if (ret & VM_FAULT_ERROR) {
> -		int err = vm_fault_to_errno(ret, *flags);
> +		int err = vm_fault_to_errno(ret, flags);
>   
>   		if (err)
>   			return err;
> @@ -1236,7 +1236,7 @@ static long __get_user_pages(struct mm_struct *mm,
>   
>   		page = follow_page_mask(vma, start, foll_flags, &ctx);
>   		if (!page || PTR_ERR(page) == -EMLINK) {
> -			ret = faultin_page(vma, start, &foll_flags,
> +			ret = faultin_page(vma, start, foll_flags,
>   					   PTR_ERR(page) == -EMLINK, locked);
>   			switch (ret) {
>   			case 0:

Right, possibly my commit

commit 5535be3099717646781ce1540cf725965d680e7b
Author: David Hildenbrand <david@redhat.com>
Date:   Tue Aug 9 22:56:40 2022 +0200

     mm/gup: fix FOLL_FORCE COW security issue and remove FOLL_COW


Removed the last modifications.

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb


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

end of thread, other threads:[~2024-03-18 12:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-17 12:46 [PATCH 1/1] mm/gup: pass flags by value in faultin_page yorha.op
2024-03-18 12:29 ` David Hildenbrand

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.