All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiaxun Yang <jiaxun.yang@flygoat.com>
To: Oleg Nesterov <oleg@redhat.com>,
	 Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	 Andrew Morton <akpm@linux-foundation.org>,
	 Ben Hutchings <ben@decadent.org.uk>
Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-mips@vger.kernel.org, linux-mm@kvack.org,
	 Jiaxun Yang <jiaxun.yang@flygoat.com>,
	Xi Ruoyao <xry111@xry111.site>,
	 Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 3/3] mm/memory: Use exception ip to search exception tables
Date: Thu, 01 Feb 2024 15:46:29 +0000	[thread overview]
Message-ID: <20240201-exception_ip-v1-3-aa26ab3ee0b5@flygoat.com> (raw)
In-Reply-To: <20240201-exception_ip-v1-0-aa26ab3ee0b5@flygoat.com>

On architectures with delay slot, instruction_pointer() may differ
from where exception was triggered.

Use exception_ip we just introduced to search exception tables to
get rid of the problem.

Fixes: 4bce37a68ff8 ("mips/mm: Convert to using lock_mm_and_find_vma()")
Reported-by: Xi Ruoyao <xry111@xry111.site>
Link: https://lore.kernel.org/r/75e9fd7b08562ad9b456a5bdaacb7cc220311cc9.camel@xry111.site/
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 mm/memory.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index 8d14ba440929..49433612444a 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -5481,7 +5481,7 @@ static inline bool get_mmap_lock_carefully(struct mm_struct *mm, struct pt_regs
 		return true;
 
 	if (regs && !user_mode(regs)) {
-		unsigned long ip = instruction_pointer(regs);
+		unsigned long ip = exception_ip(regs);
 		if (!search_exception_tables(ip))
 			return false;
 	}
@@ -5506,7 +5506,7 @@ static inline bool upgrade_mmap_lock_carefully(struct mm_struct *mm, struct pt_r
 {
 	mmap_read_unlock(mm);
 	if (regs && !user_mode(regs)) {
-		unsigned long ip = instruction_pointer(regs);
+		unsigned long ip = exception_ip(regs);
 		if (!search_exception_tables(ip))
 			return false;
 	}

-- 
2.43.0


  parent reply	other threads:[~2024-02-01 15:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01 15:46 [PATCH 0/3] Handle delay slot for extable lookup Jiaxun Yang
2024-02-01 15:46 ` [PATCH 1/3] ptrace: Introduce exception_ip arch hook Jiaxun Yang
2024-02-01 16:35   ` Xi Ruoyao
2024-02-01 17:13     ` Jiaxun Yang
2024-02-01 15:46 ` [PATCH 2/3] MIPS: Clear Cause.BD in instruction_pointer_set Jiaxun Yang
2024-02-01 15:46 ` Jiaxun Yang [this message]
2024-02-03 13:15   ` [PATCH 3/3] mm/memory: Use exception ip to search exception tables kernel test robot
2024-02-03 13:37   ` kernel test robot
2024-02-01 17:48 ` [PATCH 0/3] Handle delay slot for extable lookup Linus Torvalds

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=20240201-exception_ip-v1-3-aa26ab3ee0b5@flygoat.com \
    --to=jiaxun.yang@flygoat.com \
    --cc=akpm@linux-foundation.org \
    --cc=ben@decadent.org.uk \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=oleg@redhat.com \
    --cc=torvalds@linux-foundation.org \
    --cc=tsbogend@alpha.franken.de \
    --cc=xry111@xry111.site \
    /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 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.