[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230414152459.816046-5-Luca.Vizzarro@arm.com>
Date: Fri, 14 Apr 2023 16:24:58 +0100
From: Luca Vizzarro <Luca.Vizzarro@....com>
To: linux-kernel@...r.kernel.org
Cc: Luca Vizzarro <Luca.Vizzarro@....com>,
Andrew Morton <akpm@...ux-foundation.org>,
Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>,
Jeff Layton <jlayton@...nel.org>,
Chuck Lever <chuck.lever@...cle.com>,
Kevin Brodsky <Kevin.Brodsky@....com>,
Vincenzo Frascino <Vincenzo.Frascino@....com>,
Szabolcs Nagy <Szabolcs.Nagy@....com>,
"Theodore Ts'o" <tytso@....edu>,
David Laight <David.Laight@...LAB.com>,
Mark Rutland <Mark.Rutland@....com>,
linux-fsdevel@...r.kernel.org, linux-mm@...ck.org,
linux-morello@...lists.linaro.org
Subject: [PATCH v2 4/5] memfd: Pass argument of memfd_fcntl as int
The interface for fcntl expects the argument passed for the command
F_ADD_SEALS to be of type int. The current code wrongly treats it as
a long. In order to avoid access to undefined bits, we should explicitly
cast the argument to int.
This commit changes the signature of all the related and helper
functions so that they treat the argument as int instead of long.
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Alexander Viro <viro@...iv.linux.org.uk>
Cc: Christian Brauner <brauner@...nel.org>
Cc: Jeff Layton <jlayton@...nel.org>
Cc: Chuck Lever <chuck.lever@...cle.com>
Cc: Kevin Brodsky <Kevin.Brodsky@....com>
Cc: Vincenzo Frascino <Vincenzo.Frascino@....com>
Cc: Szabolcs Nagy <Szabolcs.Nagy@....com>
Cc: "Theodore Ts'o" <tytso@....edu>
Cc: David Laight <David.Laight@...LAB.com>
Cc: Mark Rutland <Mark.Rutland@....com>
Cc: linux-fsdevel@...r.kernel.org
Cc: linux-mm@...ck.org
Cc: linux-morello@...lists.linaro.org
Signed-off-by: Luca Vizzarro <Luca.Vizzarro@....com>
---
include/linux/memfd.h | 4 ++--
mm/memfd.c | 6 +-----
2 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/include/linux/memfd.h b/include/linux/memfd.h
index 4f1600413f91..e7abf6fa4c52 100644
--- a/include/linux/memfd.h
+++ b/include/linux/memfd.h
@@ -5,9 +5,9 @@
#include <linux/file.h>
#ifdef CONFIG_MEMFD_CREATE
-extern long memfd_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
+extern long memfd_fcntl(struct file *file, unsigned int cmd, unsigned int arg);
#else
-static inline long memfd_fcntl(struct file *f, unsigned int c, unsigned long a)
+static inline long memfd_fcntl(struct file *f, unsigned int c, unsigned int a)
{
return -EINVAL;
}
diff --git a/mm/memfd.c b/mm/memfd.c
index a0a7a37e8177..69b90c31d38c 100644
--- a/mm/memfd.c
+++ b/mm/memfd.c
@@ -243,16 +243,12 @@ static int memfd_get_seals(struct file *file)
return seals ? *seals : -EINVAL;
}
-long memfd_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
+long memfd_fcntl(struct file *file, unsigned int cmd, unsigned int arg)
{
long error;
switch (cmd) {
case F_ADD_SEALS:
- /* disallow upper 32bit */
- if (arg > UINT_MAX)
- return -EINVAL;
-
error = memfd_add_seals(file, arg);
break;
case F_GET_SEALS:
--
2.34.1
Powered by blists - more mailing lists