---
name: "UFFDIO_RWPROTECT"
section: "2const"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/UFFDIO_RWPROTECT"
---

# UFFDIO\_RWPROTECT(2const)

read-write-protect or un-protect a userfaultfd-registered memory range

## NAME

UFFDIO\_RWPROTECT - read-write-protect or un-protect a userfaultfd-registered memory range

## LIBRARY

Standard C library (*libc*, *-lc*)

## SYNOPSIS

```
#include <linux/userfaultfd.h>  /* Definition of UFFD* constants */
#include <sys/ioctl.h>
```

**int ioctl(int** *fd***, UFFDIO\_RWPROTECT, struct uffdio\_rwprotect \****argp***);**

**#include \<linux/userfaultfd.h\>**

```
struct uffdio_rwprotect {
    struct uffdio_range  range;  /* Range to change RWP on */
    __u64                mode;   /* Mode flags */
};
```

## DESCRIPTION

Read-write-protect or un-protect a userfaultfd-registered memory range registered with mode **UFFDIO\_REGISTER\_MODE\_RWP**.

The following mode bits are supported:

- **UFFDIO\_RWPROTECT\_MODE\_RWP**

  When this mode bit is set, the ioctl installs read-write protection on every page present in the range specified by *.range*. Otherwise the ioctl removes read-write protection from the range, which is also how a fault handler resolves an **UFFD\_PAGEFAULT\_FLAG\_RWP** notification.

- **UFFDIO\_RWPROTECT\_MODE\_DONTWAKE**

  When this mode bit is set, do not wake up any thread that waits for page-fault resolution after the operation. This can be specified only if **UFFDIO\_RWPROTECT\_MODE\_RWP** is not specified.

Read-write protection only affects pages that are currently populated in the range; unmapped addresses are left untouched. For anonymous mappings, protection is preserved across page reclaim (the marker rides on the swap entry) and migration. For shmem and file-backed mappings, protection is dropped when the backing page is reclaimed. Callers must also re-arm a range with **UFFDIO\_RWPROTECT** after any operation that explicitly drops the underlying page: **MADV\_DONTNEED** on anonymous memory, hole-punch on shmem, truncation of a file mapping.

## RETURN VALUE

On success, 0 is returned. On error, -1 is returned and *errno* is set to indicate the error.

## ERRORS

- **EINVAL**

  The *start* or the *len* field of the *uffdio\_range* structure was not a multiple of the system page size, or *len* was zero, or the specified range was otherwise invalid, or an invalid mode bit was specified, or **UFFDIO\_RWPROTECT\_MODE\_DONTWAKE** was specified together with **UFFDIO\_RWPROTECT\_MODE\_RWP**.

- **EAGAIN**

  The process was interrupted; retry this call.

- **ENOENT**

  The range specified in *.range* is not valid; for example, the virtual address does not exist, or part of the range is not registered with **UFFDIO\_REGISTER\_MODE\_RWP**.

- **EFAULT**

  Encountered a generic fault during processing.

## STANDARDS

Linux.

## HISTORY

Linux 7.2.

## EXAMPLES

See [**userfaultfd**(2)](/userfaultfd/2.md).

## SEE ALSO

[**ioctl**(2)](/ioctl/2.md), [**ioctl\_userfaultfd**(2)](/ioctl_userfaultfd/2.md), [**userfaultfd**(2)](/userfaultfd/2.md)

*linux.git/Documentation/admin-guide/mm/userfaultfd.rst*
