Skip to content

Commit 2e40ed2

Browse files
committed
Merge tag 'io_uring-6.5-2023-08-11' of git://git.kernel.dk/linux
Pull io_uring fixes from Jens Axboe: "A followup fix for the parisc/SHM_COLOUR fix, also from Helge, which is heading to stable. And then just the io_uring equivalent of the RESOLVE_CACHED fix in commit a0fc452 from last week for build_open_flags()" * tag 'io_uring-6.5-2023-08-11' of git://git.kernel.dk/linux: io_uring/parisc: Adjust pgoff in io_uring mmap() for parisc io_uring: correct check for O_TMPFILE
2 parents 9106536 + 56675f8 commit 2e40ed2

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
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

io_uring/openclose.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ static bool io_openat_force_async(struct io_open *open)
3535
{
3636
/*
3737
* Don't bother trying for O_TRUNC, O_CREAT, or O_TMPFILE open,
38-
* it'll always -EAGAIN
38+
* it'll always -EAGAIN. Note that we test for __O_TMPFILE because
39+
* O_TMPFILE includes O_DIRECTORY, which isn't a flag we need to force
40+
* async for.
3941
*/
40-
return open->how.flags & (O_TRUNC | O_CREAT | O_TMPFILE);
42+
return open->how.flags & (O_TRUNC | O_CREAT | __O_TMPFILE);
4143
}
4244

4345
static int __io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)

0 commit comments

Comments
 (0)