blob: 4b772e33270cb3e10c39b9969bdc5b81cc1d0785 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#include "../config-host.h"
/* SPDX-License-Identifier: MIT */
/*
* 6.10-rc merge window had a bug where the rewritten mmap support caused
* rings allocated with > 1 page, but asking for smaller mappings, would
* cause -EFAULT to be returned rather than a successful map. This hit
* applications either using an ancient liburing with IORING_FEAT_SINGLE_MMAP
* support, or application just ignoring that feature flag and still doing
* 3 mmap operations to map the ring.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "../src/syscall.h"
#include "liburing.h"
#include "helpers.h"
#define ENTRIES 128
int main(int argc, char *argv[])
{
struct io_uring_params p = { };
void *ptr;
int fd;
if (argc > 1)
return T_EXIT_SKIP;
fd = __sys_io_uring_setup(ENTRIES, &p);
if (fd < 0)
return T_EXIT_SKIP;
if (!(p.features & IORING_FEAT_SINGLE_MMAP)) {
close(fd);
return T_EXIT_SKIP;
}
ptr = __sys_mmap(0, ENTRIES * sizeof(unsigned), PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_POPULATE, fd,
IORING_OFF_SQ_RING);
if (!IS_ERR(ptr)) {
close(fd);
return T_EXIT_PASS;
}
fprintf(stderr, "ring sqe array mmap: %d\n", PTR_ERR(ptr));
return T_EXIT_FAIL;
}
|