Skip to content

Commit 56675f8

Browse files
hdelleraxboe
authored andcommitted
io_uring/parisc: Adjust pgoff in io_uring mmap() for parisc
The changes from commit 32832a4 ("io_uring: Fix io_uring mmap() by using architecture-provided get_unmapped_area()") to the parisc implementation of get_unmapped_area() broke glibc's locale-gen executable when running on parisc. This patch reverts those architecture-specific changes, and instead adjusts in io_uring_mmu_get_unmapped_area() the pgoff offset which is then given to parisc's get_unmapped_area() function. This is much cleaner than the previous approach, and we still will get a coherent addresss. This patch has no effect on other architectures (SHM_COLOUR is only defined on parisc), and the liburing testcase stil passes on parisc. Cc: stable@vger.kernel.org # 6.4 Signed-off-by: Helge Deller <deller@gmx.de> Reported-by: Christoph Biedl <linux-kernel.bfrz@manchmal.in-ulm.de> Fixes: 32832a4 ("io_uring: Fix io_uring mmap() by using architecture-provided get_unmapped_area()") Fixes: d808459 ("io_uring: Adjust mapping wrt architecture aliasing requirements") Link: https://lore.kernel.org/r/ZNEyGV0jyI8kOOfz@p100 Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 72dbde0 commit 56675f8

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

arch/parisc/kernel/sys_parisc.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,12 @@
2727
#include <linux/elf-randomize.h>
2828

2929
/*
30-
* Construct an artificial page offset for the mapping based on the virtual
30+
* Construct an artificial page offset for the mapping based on the physical
3131
* address of the kernel file mapping variable.
32-
* If filp is zero the calculated pgoff value aliases the memory of the given
33-
* address. This is useful for io_uring where the mapping shall alias a kernel
34-
* address and a userspace adress where both the kernel and the userspace
35-
* access the same memory region.
3632
*/
37-
#define GET_FILP_PGOFF(filp, addr) \
38-
((filp ? (((unsigned long) filp->f_mapping) >> 8) \
39-
& ((SHM_COLOUR-1) >> PAGE_SHIFT) : 0UL) \
40-
+ (addr >> PAGE_SHIFT))
33+
#define GET_FILP_PGOFF(filp) \
34+
(filp ? (((unsigned long) filp->f_mapping) >> 8) \
35+
& ((SHM_COLOUR-1) >> PAGE_SHIFT) : 0UL)
4136

4237
static unsigned long shared_align_offset(unsigned long filp_pgoff,
4338
unsigned long pgoff)
@@ -117,7 +112,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
117112
do_color_align = 0;
118113
if (filp || (flags & MAP_SHARED))
119114
do_color_align = 1;
120-
filp_pgoff = GET_FILP_PGOFF(filp, addr);
115+
filp_pgoff = GET_FILP_PGOFF(filp);
121116

122117
if (flags & MAP_FIXED) {
123118
/* Even MAP_FIXED mappings must reside within TASK_SIZE */

io_uring/io_uring.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3470,6 +3470,8 @@ static unsigned long io_uring_mmu_get_unmapped_area(struct file *filp,
34703470
* - use the kernel virtual address of the shared io_uring context
34713471
* (instead of the userspace-provided address, which has to be 0UL
34723472
* anyway).
3473+
* - use the same pgoff which the get_unmapped_area() uses to
3474+
* calculate the page colouring.
34733475
* For architectures without such aliasing requirements, the
34743476
* architecture will return any suitable mapping because addr is 0.
34753477
*/
@@ -3478,6 +3480,7 @@ static unsigned long io_uring_mmu_get_unmapped_area(struct file *filp,
34783480
pgoff = 0; /* has been translated to ptr above */
34793481
#ifdef SHM_COLOUR
34803482
addr = (uintptr_t) ptr;
3483+
pgoff = addr >> PAGE_SHIFT;
34813484
#else
34823485
addr = 0UL;
34833486
#endif

0 commit comments

Comments
 (0)