Skip to contentSkip to conversation

userfaultfd: fix UFFDIO_CONTINUE ioctl request definition

PATCH Superseded Gleb Fotengauer-Malinovskiy 3 participants 3 messages Jun 1, 2021 – Jun 23, 2021 userfaultfd

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 userfaultfd: fix UFFDIO_CONTINUE ioctl request definition

This ioctl request reads from uffdio_continue structure which justifies _IOC_READ flag.
See NOTEs in include/uapi/asm-generic/ioctl.h for more information.

Fixes f619147104c8 ("userfaultfd: add UFFDIO_CONTINUE ioctl")
---
 include/uapi/linux/userfaultfd.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

v2 fix commit message

include/uapi/linux/userfaultfd.h +2 -2
index bafbeb1a2624..650480f41f1d 100644
@@ -80,8 +80,8 @@
 				      struct uffdio_zeropage)
 #define UFFDIO_WRITEPROTECT	_IOWR(UFFDIO, _UFFDIO_WRITEPROTECT, \
 				      struct uffdio_writeprotect)
-#define UFFDIO_CONTINUE		_IOR(UFFDIO, _UFFDIO_CONTINUE,	\
-				     struct uffdio_continue)
+#define UFFDIO_CONTINUE		_IOWR(UFFDIO, _UFFDIO_CONTINUE,	\
+				      struct uffdio_continue)
 
 /* read() structure */
 struct uffd_msg {
Signature · 1 line
glebfm
Reviewed-by on v2 1/1
#1 lore raw

Thanks for catching this!

Quoted 32 lines · Gleb Fotengauer-Malinovskiy

This ioctl request reads from uffdio_continue structure which justifies _IOC_READ flag.
See NOTEs in include/uapi/asm-generic/ioctl.h for more information.

Fixes f619147104c8 ("userfaultfd: add UFFDIO_CONTINUE ioctl")
---
 include/uapi/linux/userfaultfd.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

v2 fix commit message

include/uapi/linux/userfaultfd.h +2 -3
index bafbeb1a2624..650480f41f1d 100644
@@ -80,8 +80,8 @@
                                      struct uffdio_zeropage)
 #define UFFDIO_WRITEPROTECT    _IOWR(UFFDIO, _UFFDIO_WRITEPROTECT, \
                                      struct uffdio_writeprotect)
-#define UFFDIO_CONTINUE                _IOR(UFFDIO, _UFFDIO_CONTINUE,  \
-                                    struct uffdio_continue)
+#define UFFDIO_CONTINUE                _IOWR(UFFDIO, _UFFDIO_CONTINUE, \
+                                     struct uffdio_continue)
 
 /* read() structure */
 struct uffd_msg {
--

glebfm

Reviewed-by on v2 1/1
#2 lore raw
In reply to Gleb Fotengauer-Malinovskiy

Hi,

Quoted 3 lines · Gleb Fotengauer-Malinovskiy

This ioctl request reads from uffdio_continue structure which justifies _IOC_READ flag.
See NOTEs in include/uapi/asm-generic/ioctl.h for more information.

These ioctl flag usage rules seem to be a perpetual source of mistakes. I suggest a slightly different wording of the commit message which is hopefully a bit easier to follow:

"This ioctl request reads from uffdio_continue structure written by userspace which justifies _IOC_WRITE flag. It also writes back to that structure which justifies _IOC_READ flag.

See NOTEs in include/uapi/asm-generic/ioctl.h for more information."

Please make sure this patch is merged before v5.13 is released, otherwise the UAPI bug would have to stay for backwards ABI compatibility.

Quoted 14 lines
Fixes f619147104c8 ("userfaultfd: add UFFDIO_CONTINUE ioctl")
---
 include/uapi/linux/userfaultfd.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

v2 fix commit message

include/uapi/linux/userfaultfd.h +0 -0
index bafbeb1a2624..650480f41f1d 100644

include/uapi/linux/userfaultfd.h line 87

Quoted 10 lines
include/uapi/linux/userfaultfd.h +2 -2
@@ -80,8 +80,8 @@
 				      struct uffdio_zeropage)
 #define UFFDIO_WRITEPROTECT	_IOWR(UFFDIO, _UFFDIO_WRITEPROTECT, \
 				      struct uffdio_writeprotect)
-#define UFFDIO_CONTINUE		_IOR(UFFDIO, _UFFDIO_CONTINUE,	\
-				     struct uffdio_continue)
+#define UFFDIO_CONTINUE		_IOWR(UFFDIO, _UFFDIO_CONTINUE,	\
+				      struct uffdio_continue)
 
 /* read() structure */
 struct uffd_msg {
Signature · 1 line
ldv