Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'io_uring-6.5-2023-07-21' of git://git.kernel.dk/linux

Pull io_uring fixes from Jens Axboe:

- Fix for io-wq not always honoring REQ_F_NOWAIT, if it was set and
punted directly (eg via DRAIN) (me)

- Capability check fix (Ondrej)

- Regression fix for the mmap changes that went into 6.4, which
apparently broke IA64 (Helge)

* tag 'io_uring-6.5-2023-07-21' of git://git.kernel.dk/linux:
ia64: mmap: Consider pgoff when searching for free mapping
io_uring: Fix io_uring mmap() by using architecture-provided get_unmapped_area()
io_uring: treat -EAGAIN for REQ_F_NOWAIT as final for io-wq
io_uring: don't audit the capability check in io_uring_create()

+38 -33
+1 -1
arch/ia64/kernel/sys_ia64.c
··· 63 63 info.low_limit = addr; 64 64 info.high_limit = TASK_SIZE; 65 65 info.align_mask = align_mask; 66 - info.align_offset = 0; 66 + info.align_offset = pgoff << PAGE_SHIFT; 67 67 return vm_unmapped_area(&info); 68 68 } 69 69
+10 -5
arch/parisc/kernel/sys_parisc.c
··· 27 27 #include <linux/elf-randomize.h> 28 28 29 29 /* 30 - * Construct an artificial page offset for the mapping based on the physical 30 + * Construct an artificial page offset for the mapping based on the virtual 31 31 * 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. 32 36 */ 33 - #define GET_FILP_PGOFF(filp) \ 34 - (filp ? (((unsigned long) filp->f_mapping) >> 8) \ 35 - & ((SHM_COLOUR-1) >> PAGE_SHIFT) : 0UL) 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)) 36 41 37 42 static unsigned long shared_align_offset(unsigned long filp_pgoff, 38 43 unsigned long pgoff) ··· 117 112 do_color_align = 0; 118 113 if (filp || (flags & MAP_SHARED)) 119 114 do_color_align = 1; 120 - filp_pgoff = GET_FILP_PGOFF(filp); 115 + filp_pgoff = GET_FILP_PGOFF(filp, addr); 121 116 122 117 if (flags & MAP_FIXED) { 123 118 /* Even MAP_FIXED mappings must reside within TASK_SIZE */
+27 -27
io_uring/io_uring.c
··· 1948 1948 ret = io_issue_sqe(req, issue_flags); 1949 1949 if (ret != -EAGAIN) 1950 1950 break; 1951 + 1952 + /* 1953 + * If REQ_F_NOWAIT is set, then don't wait or retry with 1954 + * poll. -EAGAIN is final for that case. 1955 + */ 1956 + if (req->flags & REQ_F_NOWAIT) 1957 + break; 1958 + 1951 1959 /* 1952 1960 * We can get EAGAIN for iopolled IO even though we're 1953 1961 * forcing a sync submission from here, since we can't ··· 3437 3429 unsigned long addr, unsigned long len, 3438 3430 unsigned long pgoff, unsigned long flags) 3439 3431 { 3440 - const unsigned long mmap_end = arch_get_mmap_end(addr, len, flags); 3441 - struct vm_unmapped_area_info info; 3442 3432 void *ptr; 3443 3433 3444 3434 /* ··· 3451 3445 if (IS_ERR(ptr)) 3452 3446 return -ENOMEM; 3453 3447 3454 - info.flags = VM_UNMAPPED_AREA_TOPDOWN; 3455 - info.length = len; 3456 - info.low_limit = max(PAGE_SIZE, mmap_min_addr); 3457 - info.high_limit = arch_get_mmap_base(addr, current->mm->mmap_base); 3458 - #ifdef SHM_COLOUR 3459 - info.align_mask = PAGE_MASK & (SHM_COLOUR - 1UL); 3460 - #else 3461 - info.align_mask = PAGE_MASK & (SHMLBA - 1UL); 3462 - #endif 3463 - info.align_offset = (unsigned long) ptr; 3464 - 3465 3448 /* 3466 - * A failed mmap() very likely causes application failure, 3467 - * so fall back to the bottom-up function here. This scenario 3468 - * can happen with large stack limits and large mmap() 3469 - * allocations. 3449 + * Some architectures have strong cache aliasing requirements. 3450 + * For such architectures we need a coherent mapping which aliases 3451 + * kernel memory *and* userspace memory. To achieve that: 3452 + * - use a NULL file pointer to reference physical memory, and 3453 + * - use the kernel virtual address of the shared io_uring context 3454 + * (instead of the userspace-provided address, which has to be 0UL 3455 + * anyway). 3456 + * For architectures without such aliasing requirements, the 3457 + * architecture will return any suitable mapping because addr is 0. 3470 3458 */ 3471 - addr = vm_unmapped_area(&info); 3472 - if (offset_in_page(addr)) { 3473 - info.flags = 0; 3474 - info.low_limit = TASK_UNMAPPED_BASE; 3475 - info.high_limit = mmap_end; 3476 - addr = vm_unmapped_area(&info); 3477 - } 3478 - 3479 - return addr; 3459 + filp = NULL; 3460 + flags |= MAP_SHARED; 3461 + pgoff = 0; /* has been translated to ptr above */ 3462 + #ifdef SHM_COLOUR 3463 + addr = (uintptr_t) ptr; 3464 + #else 3465 + addr = 0UL; 3466 + #endif 3467 + return current->mm->get_unmapped_area(filp, addr, len, pgoff, flags); 3480 3468 } 3481 3469 3482 3470 #else /* !CONFIG_MMU */ ··· 3870 3870 ctx->syscall_iopoll = 1; 3871 3871 3872 3872 ctx->compat = in_compat_syscall(); 3873 - if (!capable(CAP_IPC_LOCK)) 3873 + if (!ns_capable_noaudit(&init_user_ns, CAP_IPC_LOCK)) 3874 3874 ctx->user = get_uid(current_user()); 3875 3875 3876 3876 /*