• Jens Axboe's avatar
    io_uring: don't attempt to mmap larger than what the user asks for · 06fe9b1d
    Jens Axboe authored
    If IORING_FEAT_SINGLE_MMAP is ignored, as can happen if an application
    uses an ancient liburing or does setup manually, then 3 mmap's are
    required to map the ring into userspace. The kernel will still have
    collapsed the mappings, however userspace may ask for mapping them
    individually. If so, then we should not use the full number of ring
    pages, as it may exceed the partial mapping. Doing so will yield an
    -EFAULT from vm_insert_pages(), as we pass in more pages than what the
    application asked for.
    
    Cap the number of pages to match what the application asked for, for
    the particular mapping operation.
    Reported-by: default avatarLucas Mülling <lmulling@proton.me>
    Link: https://github.com/axboe/liburing/issues/1157
    Fixes: 3ab1db3c ("io_uring: get rid of remap_pfn_range() for mapping rings/sqes")
    Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
    06fe9b1d
memmap.c 7.78 KB