Skip to content

Commit bb592ec

Browse files
committed
Merge remote-tracking branch 'stable/linux-6.1.y' into rpi-6.1.y
2 parents dc41960 + 0f4ac6b commit bb592ec

File tree

67 files changed

+688
-553
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+688
-553
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22
VERSION = 6
33
PATCHLEVEL = 1
4-
SUBLEVEL = 36
4+
SUBLEVEL = 37
55
EXTRAVERSION =
66
NAME = Curry Ramen
77

arch/alpha/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ config ALPHA
2828
select GENERIC_SMP_IDLE_THREAD
2929
select HAVE_ARCH_AUDITSYSCALL
3030
select HAVE_MOD_ARCH_SPECIFIC
31+
select LOCK_MM_AND_FIND_VMA
3132
select MODULES_USE_ELF_RELA
3233
select ODD_RT_SIGACTION
3334
select OLD_SIGSUSPEND

arch/alpha/mm/fault.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,20 +119,12 @@ do_page_fault(unsigned long address, unsigned long mmcsr,
119119
flags |= FAULT_FLAG_USER;
120120
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
121121
retry:
122-
mmap_read_lock(mm);
123-
vma = find_vma(mm, address);
122+
vma = lock_mm_and_find_vma(mm, address, regs);
124123
if (!vma)
125-
goto bad_area;
126-
if (vma->vm_start <= address)
127-
goto good_area;
128-
if (!(vma->vm_flags & VM_GROWSDOWN))
129-
goto bad_area;
130-
if (expand_stack(vma, address))
131-
goto bad_area;
124+
goto bad_area_nosemaphore;
132125

133126
/* Ok, we have a good vm_area for this memory access, so
134127
we can handle it. */
135-
good_area:
136128
si_code = SEGV_ACCERR;
137129
if (cause < 0) {
138130
if (!(vma->vm_flags & VM_EXEC))
@@ -189,6 +181,7 @@ do_page_fault(unsigned long address, unsigned long mmcsr,
189181
bad_area:
190182
mmap_read_unlock(mm);
191183

184+
bad_area_nosemaphore:
192185
if (user_mode(regs))
193186
goto do_sigsegv;
194187

arch/arc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ config ARC
4141
select HAVE_PERF_EVENTS
4242
select HAVE_SYSCALL_TRACEPOINTS
4343
select IRQ_DOMAIN
44+
select LOCK_MM_AND_FIND_VMA
4445
select MODULES_USE_ELF_RELA
4546
select OF
4647
select OF_EARLY_FLATTREE

arch/arc/mm/fault.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,9 @@ void do_page_fault(unsigned long address, struct pt_regs *regs)
113113

114114
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
115115
retry:
116-
mmap_read_lock(mm);
117-
118-
vma = find_vma(mm, address);
116+
vma = lock_mm_and_find_vma(mm, address, regs);
119117
if (!vma)
120-
goto bad_area;
121-
if (unlikely(address < vma->vm_start)) {
122-
if (!(vma->vm_flags & VM_GROWSDOWN) || expand_stack(vma, address))
123-
goto bad_area;
124-
}
118+
goto bad_area_nosemaphore;
125119

126120
/*
127121
* vm_area is good, now check permissions for this memory access
@@ -161,6 +155,7 @@ void do_page_fault(unsigned long address, struct pt_regs *regs)
161155
bad_area:
162156
mmap_read_unlock(mm);
163157

158+
bad_area_nosemaphore:
164159
/*
165160
* Major/minor page fault accounting
166161
* (in case of retry we only land here once)

arch/arm/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ config ARM
122122
select HAVE_UID16
123123
select HAVE_VIRT_CPU_ACCOUNTING_GEN
124124
select IRQ_FORCED_THREADING
125+
select LOCK_MM_AND_FIND_VMA
125126
select MODULES_USE_ELF_REL
126127
select NEED_DMA_MAP_STATE
127128
select OF_EARLY_FLATTREE if OF

arch/arm/mm/fault.c

Lines changed: 14 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -231,37 +231,11 @@ static inline bool is_permission_fault(unsigned int fsr)
231231
return false;
232232
}
233233

234-
static vm_fault_t __kprobes
235-
__do_page_fault(struct mm_struct *mm, unsigned long addr, unsigned int flags,
236-
unsigned long vma_flags, struct pt_regs *regs)
237-
{
238-
struct vm_area_struct *vma = find_vma(mm, addr);
239-
if (unlikely(!vma))
240-
return VM_FAULT_BADMAP;
241-
242-
if (unlikely(vma->vm_start > addr)) {
243-
if (!(vma->vm_flags & VM_GROWSDOWN))
244-
return VM_FAULT_BADMAP;
245-
if (addr < FIRST_USER_ADDRESS)
246-
return VM_FAULT_BADMAP;
247-
if (expand_stack(vma, addr))
248-
return VM_FAULT_BADMAP;
249-
}
250-
251-
/*
252-
* ok, we have a good vm_area for this memory access, check the
253-
* permissions on the VMA allow for the fault which occurred.
254-
*/
255-
if (!(vma->vm_flags & vma_flags))
256-
return VM_FAULT_BADACCESS;
257-
258-
return handle_mm_fault(vma, addr & PAGE_MASK, flags, regs);
259-
}
260-
261234
static int __kprobes
262235
do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
263236
{
264237
struct mm_struct *mm = current->mm;
238+
struct vm_area_struct *vma;
265239
int sig, code;
266240
vm_fault_t fault;
267241
unsigned int flags = FAULT_FLAG_DEFAULT;
@@ -300,31 +274,21 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
300274

301275
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr);
302276

303-
/*
304-
* As per x86, we may deadlock here. However, since the kernel only
305-
* validly references user space from well defined areas of the code,
306-
* we can bug out early if this is from code which shouldn't.
307-
*/
308-
if (!mmap_read_trylock(mm)) {
309-
if (!user_mode(regs) && !search_exception_tables(regs->ARM_pc))
310-
goto no_context;
311277
retry:
312-
mmap_read_lock(mm);
313-
} else {
314-
/*
315-
* The above down_read_trylock() might have succeeded in
316-
* which case, we'll have missed the might_sleep() from
317-
* down_read()
318-
*/
319-
might_sleep();
320-
#ifdef CONFIG_DEBUG_VM
321-
if (!user_mode(regs) &&
322-
!search_exception_tables(regs->ARM_pc))
323-
goto no_context;
324-
#endif
278+
vma = lock_mm_and_find_vma(mm, addr, regs);
279+
if (unlikely(!vma)) {
280+
fault = VM_FAULT_BADMAP;
281+
goto bad_area;
325282
}
326283

327-
fault = __do_page_fault(mm, addr, flags, vm_flags, regs);
284+
/*
285+
* ok, we have a good vm_area for this memory access, check the
286+
* permissions on the VMA allow for the fault which occurred.
287+
*/
288+
if (!(vma->vm_flags & vm_flags))
289+
fault = VM_FAULT_BADACCESS;
290+
else
291+
fault = handle_mm_fault(vma, addr & PAGE_MASK, flags, regs);
328292

329293
/* If we need to retry but a fatal signal is pending, handle the
330294
* signal first. We do not need to release the mmap_lock because
@@ -355,6 +319,7 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
355319
if (likely(!(fault & (VM_FAULT_ERROR | VM_FAULT_BADMAP | VM_FAULT_BADACCESS))))
356320
return 0;
357321

322+
bad_area:
358323
/*
359324
* If we are in kernel mode at this point, we
360325
* have no context to handle this fault with.

arch/arm64/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ config ARM64
211211
select IRQ_DOMAIN
212212
select IRQ_FORCED_THREADING
213213
select KASAN_VMALLOC if KASAN
214+
select LOCK_MM_AND_FIND_VMA
214215
select MODULES_USE_ELF_RELA
215216
select NEED_DMA_MAP_STATE
216217
select NEED_SG_DMA_LENGTH

arch/arm64/mm/fault.c

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -483,27 +483,14 @@ static void do_bad_area(unsigned long far, unsigned long esr,
483483
#define VM_FAULT_BADMAP ((__force vm_fault_t)0x010000)
484484
#define VM_FAULT_BADACCESS ((__force vm_fault_t)0x020000)
485485

486-
static vm_fault_t __do_page_fault(struct mm_struct *mm, unsigned long addr,
486+
static vm_fault_t __do_page_fault(struct mm_struct *mm,
487+
struct vm_area_struct *vma, unsigned long addr,
487488
unsigned int mm_flags, unsigned long vm_flags,
488489
struct pt_regs *regs)
489490
{
490-
struct vm_area_struct *vma = find_vma(mm, addr);
491-
492-
if (unlikely(!vma))
493-
return VM_FAULT_BADMAP;
494-
495491
/*
496492
* Ok, we have a good vm_area for this memory access, so we can handle
497493
* it.
498-
*/
499-
if (unlikely(vma->vm_start > addr)) {
500-
if (!(vma->vm_flags & VM_GROWSDOWN))
501-
return VM_FAULT_BADMAP;
502-
if (expand_stack(vma, addr))
503-
return VM_FAULT_BADMAP;
504-
}
505-
506-
/*
507494
* Check that the permissions on the VMA allow for the fault which
508495
* occurred.
509496
*/
@@ -535,6 +522,7 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr,
535522
unsigned long vm_flags;
536523
unsigned int mm_flags = FAULT_FLAG_DEFAULT;
537524
unsigned long addr = untagged_addr(far);
525+
struct vm_area_struct *vma;
538526

539527
if (kprobe_page_fault(regs, esr))
540528
return 0;
@@ -585,31 +573,14 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr,
585573

586574
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr);
587575

588-
/*
589-
* As per x86, we may deadlock here. However, since the kernel only
590-
* validly references user space from well defined areas of the code,
591-
* we can bug out early if this is from code which shouldn't.
592-
*/
593-
if (!mmap_read_trylock(mm)) {
594-
if (!user_mode(regs) && !search_exception_tables(regs->pc))
595-
goto no_context;
596576
retry:
597-
mmap_read_lock(mm);
598-
} else {
599-
/*
600-
* The above mmap_read_trylock() might have succeeded in which
601-
* case, we'll have missed the might_sleep() from down_read().
602-
*/
603-
might_sleep();
604-
#ifdef CONFIG_DEBUG_VM
605-
if (!user_mode(regs) && !search_exception_tables(regs->pc)) {
606-
mmap_read_unlock(mm);
607-
goto no_context;
608-
}
609-
#endif
577+
vma = lock_mm_and_find_vma(mm, addr, regs);
578+
if (unlikely(!vma)) {
579+
fault = VM_FAULT_BADMAP;
580+
goto done;
610581
}
611582

612-
fault = __do_page_fault(mm, addr, mm_flags, vm_flags, regs);
583+
fault = __do_page_fault(mm, vma, addr, mm_flags, vm_flags, regs);
613584

614585
/* Quick path to respond to signals */
615586
if (fault_signal_pending(fault, regs)) {
@@ -628,6 +599,7 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr,
628599
}
629600
mmap_read_unlock(mm);
630601

602+
done:
631603
/*
632604
* Handle the "normal" (no error) case first.
633605
*/

arch/csky/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ config CSKY
9696
select HAVE_RSEQ
9797
select HAVE_STACKPROTECTOR
9898
select HAVE_SYSCALL_TRACEPOINTS
99+
select LOCK_MM_AND_FIND_VMA
99100
select MAY_HAVE_SPARSE_IRQ
100101
select MODULES_USE_ELF_RELA if MODULES
101102
select OF

0 commit comments

Comments
 (0)