Hi Tadeusz,
Looking at places like these: https://elixir.bootlin.com/linux/v6.0-rc5/source/drivers/infiniband/hw/qib/q... https://elixir.bootlin.com/linux/v6.0-rc5/source/drivers/infiniband/hw/mlx5/... I think we also need to remove VM_MAYWRITE, otherwise it's still possible to turn it into a writable mapping with mprotect.
It's also probably better to return an error if VM_WRITE (or VM_EXEC?) is set rather than silently fix it up.