Skip to contentSkip to conversation

memfd_secret: use unsigned int rather than long as syscall flags type

PATCH In review Mike Rapoport 3 participants 3 messages Mar 31, 2021

Subsystems (8)
lore
Share & tools
lore

Mike Rapoport

author maintainer
#0 lore raw

PATCH 1/1 memfd_secret: use unsigned int rather than long as syscall flags type

From: Mike Rapoport <[email protected]>

Yuri Norov says:

If parameter size is the same for native and compat ABIs, we may wire a syscall made by compat client to native handler. This is true for unsigned int, but not true for unsigned long or pointer.

That's why I suggest using unsigned int and so avoid creating compat entry point.

Use unsigned int as the type of the flags parameter in memfd_secret() system call.

---

@Andrew,
The patch is vs v5.12-rc5-mmots-2021-03-30-23, I'd appreciate if it would be added as a fixup to the memfd_secret series.

 include/linux/syscalls.h                  | 2 +-
 mm/secretmem.c                            | 2 +-
 tools/testing/selftests/vm/memfd_secret.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
include/linux/syscalls.h +1 -1
index 49c93c906893..1a1b5d724497 100644
@@ -1050,7 +1050,7 @@ asmlinkage long sys_landlock_create_ruleset(const struct landlock_ruleset_attr _
 asmlinkage long sys_landlock_add_rule(int ruleset_fd, enum landlock_rule_type rule_type,
 		const void __user *rule_attr, __u32 flags);
 asmlinkage long sys_landlock_restrict_self(int ruleset_fd, __u32 flags);
-asmlinkage long sys_memfd_secret(unsigned long flags);
+asmlinkage long sys_memfd_secret(unsigned int flags);
 
 /*
  * Architecture-specific system calls
mm/secretmem.c +1 -1
index f2ae3f32a193..3b1ba3991964 100644
@@ -199,7 +199,7 @@ static struct file *secretmem_file_create(unsigned long flags)
 	return file;
 }
 
-SYSCALL_DEFINE1(memfd_secret, unsigned long, flags)
+SYSCALL_DEFINE1(memfd_secret, unsigned int, flags)
 {
 	struct file *file;
 	int fd, err;
tools/testing/selftests/vm/memfd_secret.c +1 -1
index c878c2b841fc..2462f52e9c96 100644
@@ -38,7 +38,7 @@ static unsigned long page_size;
 static unsigned long mlock_limit_cur;
 static unsigned long mlock_limit_max;
 
-static int memfd_secret(unsigned long flags)
+static int memfd_secret(unsigned int flags)
 {
 	return syscall(__NR_memfd_secret, flags);
 }
Signature · 1 line
2.28.0
#1 lore raw
Quoted 58 lines · Mike Rapoport

From: Mike Rapoport <[email protected]>

Yuri Norov says:

If parameter size is the same for native and compat ABIs, we may wire a syscall made by compat client to native handler. This is true for unsigned int, but not true for unsigned long or pointer.

That's why I suggest using unsigned int and so avoid creating compat entry point.

Use unsigned int as the type of the flags parameter in memfd_secret() system call.

---

@Andrew,
The patch is vs v5.12-rc5-mmots-2021-03-30-23, I'd appreciate if it would be added as a fixup to the memfd_secret series.

  include/linux/syscalls.h                  | 2 +-
  mm/secretmem.c                            | 2 +-
  tools/testing/selftests/vm/memfd_secret.c | 2 +-
  3 files changed, 3 insertions(+), 3 deletions(-)
include/linux/syscalls.h +1 -1
index 49c93c906893..1a1b5d724497 100644
@@ -1050,7 +1050,7 @@ asmlinkage long sys_landlock_create_ruleset(const struct landlock_ruleset_attr _
  asmlinkage long sys_landlock_add_rule(int ruleset_fd, enum landlock_rule_type rule_type,
  		const void __user *rule_attr, __u32 flags);
  asmlinkage long sys_landlock_restrict_self(int ruleset_fd, __u32 flags);
-asmlinkage long sys_memfd_secret(unsigned long flags);
+asmlinkage long sys_memfd_secret(unsigned int flags);
 
  /*
   * Architecture-specific system calls
mm/secretmem.c +1 -1
index f2ae3f32a193..3b1ba3991964 100644
@@ -199,7 +199,7 @@ static struct file *secretmem_file_create(unsigned long flags)
  	return file;
  }
 
-SYSCALL_DEFINE1(memfd_secret, unsigned long, flags)
+SYSCALL_DEFINE1(memfd_secret, unsigned int, flags)
  {
  	struct file *file;
  	int fd, err;
tools/testing/selftests/vm/memfd_secret.c +0 -0
index c878c2b841fc..2462f52e9c96 100644

tools/testing/selftests/vm/memfd_secret.c static unsigned long page_size; · line 44

Quoted 8 lines
tools/testing/selftests/vm/memfd_secret.c +1 -1
@@ -38,7 +38,7 @@ static unsigned long page_size;
  static unsigned long mlock_limit_cur;
  static unsigned long mlock_limit_max;
 
-static int memfd_secret(unsigned long flags)
+static int memfd_secret(unsigned int flags)
  {
  	return syscall(__NR_memfd_secret, flags);
  }

LGTM

Signature · 3 lines
Thanks,

David / dhildenb
Acked-by on v1 1/1
#2 lore raw
In reply to Mike Rapoport
Quoted 8 lines · Mike Rapoport

From: Mike Rapoport <[email protected]>

Yuri Norov says:

If parameter size is the same for native and compat ABIs, we may wire a syscall made by compat client to native handler. This is true for unsigned int, but not true for unsigned long or pointer.

Quoted 7 lines

That's why I suggest using unsigned int and so avoid creating compat entry point.

Use unsigned int as the type of the flags parameter in memfd_secret() system call.