All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/9] memfd: add sealing to hugetlb-backed memory
@ 2017-11-07 12:27 ` Marc-André Lureau
  0 siblings, 0 replies; 34+ messages in thread
From: Marc-André Lureau @ 2017-11-07 12:27 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: aarcange, hughd, nyc, mike.kravetz, Marc-André Lureau

Hi,

Recently, Mike Kravetz added hugetlbfs support to memfd. However, he
didn't add sealing support. One of the reasons to use memfd is to have
shared memory sealing when doing IPC or sharing memory with another
process with some extra safety. qemu uses shared memory & hugetables
with vhost-user (used by dpdk), so it is reasonable to use memfd
now instead for convenience and security reasons.

Thanks!

v3:
- do remaining MFD_DEF_SIZE/mfd_def_size substitutions
- fix missing unistd.h include in common.c
- tweaked a bit commit message prefixes
- added reviewed-by tags

v2:
- add "memfd-hugetlb:" prefix in memfd-test
- run fuse test on hugetlb backend memory
- rename function memfd_file_get_seals() -> memfd_file_seals_ptr()
- update commit messages
- added reviewed-by tags

RFC->v1:
- split rfc patch, after early review feedback
- added patch for memfd-test changes
- fix build with hugetlbfs disabled
- small code and commit messages improvements

Marc-André Lureau (9):
  shmem: unexport shmem_add_seals()/shmem_get_seals()
  shmem: rename functions that are memfd-related
  hugetlb: expose hugetlbfs_inode_info in header
  hugetlb: implement memfd sealing
  shmem: add sealing support to hugetlb-backed memfd
  memfd-test: test hugetlbfs sealing
  memfd-test: add 'memfd-hugetlb:' prefix when testing hugetlbfs
  memfd-test: move common code to a shared unit
  memfd-test: run fuse test on hugetlb backend memory

 fs/fcntl.c                                     |   2 +-
 fs/hugetlbfs/inode.c                           |  39 +++--
 include/linux/hugetlb.h                        |  11 ++
 include/linux/shmem_fs.h                       |   6 +-
 mm/shmem.c                                     |  59 ++++---
 tools/testing/selftests/memfd/Makefile         |   5 +
 tools/testing/selftests/memfd/common.c         |  46 ++++++
 tools/testing/selftests/memfd/common.h         |   9 ++
 tools/testing/selftests/memfd/fuse_test.c      |  44 +++--
 tools/testing/selftests/memfd/memfd_test.c     | 212 ++++---------------------
 tools/testing/selftests/memfd/run_fuse_test.sh |   2 +-
 tools/testing/selftests/memfd/run_tests.sh     |   1 +
 12 files changed, 200 insertions(+), 236 deletions(-)
 create mode 100644 tools/testing/selftests/memfd/common.c
 create mode 100644 tools/testing/selftests/memfd/common.h

-- 
2.15.0.125.g8f49766d64

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v3 0/9] memfd: add sealing to hugetlb-backed memory
@ 2017-11-07 12:27 ` Marc-André Lureau
  0 siblings, 0 replies; 34+ messages in thread
From: Marc-André Lureau @ 2017-11-07 12:27 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: aarcange, hughd, nyc, mike.kravetz, Marc-André Lureau

Hi,

Recently, Mike Kravetz added hugetlbfs support to memfd. However, he
didn't add sealing support. One of the reasons to use memfd is to have
shared memory sealing when doing IPC or sharing memory with another
process with some extra safety. qemu uses shared memory & hugetables
with vhost-user (used by dpdk), so it is reasonable to use memfd
now instead for convenience and security reasons.

Thanks!

v3:
- do remaining MFD_DEF_SIZE/mfd_def_size substitutions
- fix missing unistd.h include in common.c
- tweaked a bit commit message prefixes
- added reviewed-by tags

v2:
- add "memfd-hugetlb:" prefix in memfd-test
- run fuse test on hugetlb backend memory
- rename function memfd_file_get_seals() -> memfd_file_seals_ptr()
- update commit messages
- added reviewed-by tags

RFC->v1:
- split rfc patch, after early review feedback
- added patch for memfd-test changes
- fix build with hugetlbfs disabled
- small code and commit messages improvements

Marc-AndrA(C) Lureau (9):
  shmem: unexport shmem_add_seals()/shmem_get_seals()
  shmem: rename functions that are memfd-related
  hugetlb: expose hugetlbfs_inode_info in header
  hugetlb: implement memfd sealing
  shmem: add sealing support to hugetlb-backed memfd
  memfd-test: test hugetlbfs sealing
  memfd-test: add 'memfd-hugetlb:' prefix when testing hugetlbfs
  memfd-test: move common code to a shared unit
  memfd-test: run fuse test on hugetlb backend memory

 fs/fcntl.c                                     |   2 +-
 fs/hugetlbfs/inode.c                           |  39 +++--
 include/linux/hugetlb.h                        |  11 ++
 include/linux/shmem_fs.h                       |   6 +-
 mm/shmem.c                                     |  59 ++++---
 tools/testing/selftests/memfd/Makefile         |   5 +
 tools/testing/selftests/memfd/common.c         |  46 ++++++
 tools/testing/selftests/memfd/common.h         |   9 ++
 tools/testing/selftests/memfd/fuse_test.c      |  44 +++--
 tools/testing/selftests/memfd/memfd_test.c     | 212 ++++---------------------
 tools/testing/selftests/memfd/run_fuse_test.sh |   2 +-
 tools/testing/selftests/memfd/run_tests.sh     |   1 +
 12 files changed, 200 insertions(+), 236 deletions(-)
 create mode 100644 tools/testing/selftests/memfd/common.c
 create mode 100644 tools/testing/selftests/memfd/common.h

-- 
2.15.0.125.g8f49766d64

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v3 1/9] shmem: unexport shmem_add_seals()/shmem_get_seals()
  2017-11-07 12:27 ` Marc-André Lureau
@ 2017-11-07 12:27   ` Marc-André Lureau
  -1 siblings, 0 replies; 34+ messages in thread
From: Marc-André Lureau @ 2017-11-07 12:27 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: aarcange, hughd, nyc, mike.kravetz, Marc-André Lureau

The functions are called through shmem_fcntl() only.  And no danger in
removing the EXPORTs as the routines only work with shmem file
structs.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
---
 include/linux/shmem_fs.h | 2 --
 mm/shmem.c               | 6 ++----
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index ed91ce57c428..1f5bf07cb8be 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -110,8 +110,6 @@ extern void shmem_uncharge(struct inode *inode, long pages);
 
 #ifdef CONFIG_TMPFS
 
-extern int shmem_add_seals(struct file *file, unsigned int seals);
-extern int shmem_get_seals(struct file *file);
 extern long shmem_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
 
 #else
diff --git a/mm/shmem.c b/mm/shmem.c
index 07a1d22807be..37260c5e12fa 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2722,7 +2722,7 @@ static int shmem_wait_for_pins(struct address_space *mapping)
 		     F_SEAL_GROW | \
 		     F_SEAL_WRITE)
 
-int shmem_add_seals(struct file *file, unsigned int seals)
+static int shmem_add_seals(struct file *file, unsigned int seals)
 {
 	struct inode *inode = file_inode(file);
 	struct shmem_inode_info *info = SHMEM_I(inode);
@@ -2791,16 +2791,14 @@ int shmem_add_seals(struct file *file, unsigned int seals)
 	inode_unlock(inode);
 	return error;
 }
-EXPORT_SYMBOL_GPL(shmem_add_seals);
 
-int shmem_get_seals(struct file *file)
+static int shmem_get_seals(struct file *file)
 {
 	if (file->f_op != &shmem_file_operations)
 		return -EINVAL;
 
 	return SHMEM_I(file_inode(file))->seals;
 }
-EXPORT_SYMBOL_GPL(shmem_get_seals);
 
 long shmem_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
 {
-- 
2.15.0.125.g8f49766d64

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v3 1/9] shmem: unexport shmem_add_seals()/shmem_get_seals()
@ 2017-11-07 12:27   ` Marc-André Lureau
  0 siblings, 0 replies; 34+ messages in thread
From: Marc-André Lureau @ 2017-11-07 12:27 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: aarcange, hughd, nyc, mike.kravetz, Marc-André Lureau

The functions are called through shmem_fcntl() only.  And no danger in
removing the EXPORTs as the routines only work with shmem file
structs.

Signed-off-by: Marc-AndrA(C) Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
---
 include/linux/shmem_fs.h | 2 --
 mm/shmem.c               | 6 ++----
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index ed91ce57c428..1f5bf07cb8be 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -110,8 +110,6 @@ extern void shmem_uncharge(struct inode *inode, long pages);
 
 #ifdef CONFIG_TMPFS
 
-extern int shmem_add_seals(struct file *file, unsigned int seals);
-extern int shmem_get_seals(struct file *file);
 extern long shmem_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
 
 #else
diff --git a/mm/shmem.c b/mm/shmem.c
index 07a1d22807be..37260c5e12fa 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2722,7 +2722,7 @@ static int shmem_wait_for_pins(struct address_space *mapping)
 		     F_SEAL_GROW | \
 		     F_SEAL_WRITE)
 
-int shmem_add_seals(struct file *file, unsigned int seals)
+static int shmem_add_seals(struct file *file, unsigned int seals)
 {
 	struct inode *inode = file_inode(file);
 	struct shmem_inode_info *info = SHMEM_I(inode);
@@ -2791,16 +2791,14 @@ int shmem_add_seals(struct file *file, unsigned int seals)
 	inode_unlock(inode);
 	return error;
 }
-EXPORT_SYMBOL_GPL(shmem_add_seals);
 
-int shmem_get_seals(struct file *file)
+static int shmem_get_seals(struct file *file)
 {
 	if (file->f_op != &shmem_file_operations)
 		return -EINVAL;
 
 	return SHMEM_I(file_inode(file))->seals;
 }
-EXPORT_SYMBOL_GPL(shmem_get_seals);
 
 long shmem_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
 {
-- 
2.15.0.125.g8f49766d64

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v3 2/9] shmem: rename functions that are memfd-related
  2017-11-07 12:27 ` Marc-André Lureau
@ 2017-11-07 12:27   ` Marc-André Lureau
  -1 siblings, 0 replies; 34+ messages in thread
From: Marc-André Lureau @ 2017-11-07 12:27 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: aarcange, hughd, nyc, mike.kravetz, Marc-André Lureau

Those functions are called for memfd files, backed by shmem or
hugetlb (the next patches will handle hugetlb).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
---
 fs/fcntl.c               |  2 +-
 include/linux/shmem_fs.h |  4 ++--
 mm/shmem.c               | 10 +++++-----
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/fcntl.c b/fs/fcntl.c
index 8d78ffd7b399..ad7995c64370 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -418,7 +418,7 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
 		break;
 	case F_ADD_SEALS:
 	case F_GET_SEALS:
-		err = shmem_fcntl(filp, cmd, arg);
+		err = memfd_fcntl(filp, cmd, arg);
 		break;
 	case F_GET_RW_HINT:
 	case F_SET_RW_HINT:
diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index 1f5bf07cb8be..33b659f62c2b 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -110,11 +110,11 @@ extern void shmem_uncharge(struct inode *inode, long pages);
 
 #ifdef CONFIG_TMPFS
 
-extern long shmem_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
+extern long memfd_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
 
 #else
 
-static inline long shmem_fcntl(struct file *f, unsigned int c, unsigned long a)
+static inline long memfd_fcntl(struct file *f, unsigned int c, unsigned long a)
 {
 	return -EINVAL;
 }
diff --git a/mm/shmem.c b/mm/shmem.c
index 37260c5e12fa..b7811979611f 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2722,7 +2722,7 @@ static int shmem_wait_for_pins(struct address_space *mapping)
 		     F_SEAL_GROW | \
 		     F_SEAL_WRITE)
 
-static int shmem_add_seals(struct file *file, unsigned int seals)
+static int memfd_add_seals(struct file *file, unsigned int seals)
 {
 	struct inode *inode = file_inode(file);
 	struct shmem_inode_info *info = SHMEM_I(inode);
@@ -2792,7 +2792,7 @@ static int shmem_add_seals(struct file *file, unsigned int seals)
 	return error;
 }
 
-static int shmem_get_seals(struct file *file)
+static int memfd_get_seals(struct file *file)
 {
 	if (file->f_op != &shmem_file_operations)
 		return -EINVAL;
@@ -2800,7 +2800,7 @@ static int shmem_get_seals(struct file *file)
 	return SHMEM_I(file_inode(file))->seals;
 }
 
-long shmem_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
+long memfd_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
 {
 	long error;
 
@@ -2810,10 +2810,10 @@ long shmem_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
 		if (arg > UINT_MAX)
 			return -EINVAL;
 
-		error = shmem_add_seals(file, arg);
+		error = memfd_add_seals(file, arg);
 		break;
 	case F_GET_SEALS:
-		error = shmem_get_seals(file);
+		error = memfd_get_seals(file);
 		break;
 	default:
 		error = -EINVAL;
-- 
2.15.0.125.g8f49766d64

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v3 2/9] shmem: rename functions that are memfd-related
@ 2017-11-07 12:27   ` Marc-André Lureau
  0 siblings, 0 replies; 34+ messages in thread
From: Marc-André Lureau @ 2017-11-07 12:27 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: aarcange, hughd, nyc, mike.kravetz, Marc-André Lureau

Those functions are called for memfd files, backed by shmem or
hugetlb (the next patches will handle hugetlb).

Signed-off-by: Marc-AndrA(C) Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
---
 fs/fcntl.c               |  2 +-
 include/linux/shmem_fs.h |  4 ++--
 mm/shmem.c               | 10 +++++-----
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/fcntl.c b/fs/fcntl.c
index 8d78ffd7b399..ad7995c64370 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -418,7 +418,7 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
 		break;
 	case F_ADD_SEALS:
 	case F_GET_SEALS:
-		err = shmem_fcntl(filp, cmd, arg);
+		err = memfd_fcntl(filp, cmd, arg);
 		break;
 	case F_GET_RW_HINT:
 	case F_SET_RW_HINT:
diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index 1f5bf07cb8be..33b659f62c2b 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -110,11 +110,11 @@ extern void shmem_uncharge(struct inode *inode, long pages);
 
 #ifdef CONFIG_TMPFS
 
-extern long shmem_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
+extern long memfd_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
 
 #else
 
-static inline long shmem_fcntl(struct file *f, unsigned int c, unsigned long a)
+static inline long memfd_fcntl(struct file *f, unsigned int c, unsigned long a)
 {
 	return -EINVAL;
 }
diff --git a/mm/shmem.c b/mm/shmem.c
index 37260c5e12fa..b7811979611f 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2722,7 +2722,7 @@ static int shmem_wait_for_pins(struct address_space *mapping)
 		     F_SEAL_GROW | \
 		     F_SEAL_WRITE)
 
-static int shmem_add_seals(struct file *file, unsigned int seals)
+static int memfd_add_seals(struct file *file, unsigned int seals)
 {
 	struct inode *inode = file_inode(file);
 	struct shmem_inode_info *info = SHMEM_I(inode);
@@ -2792,7 +2792,7 @@ static int shmem_add_seals(struct file *file, unsigned int seals)
 	return error;
 }
 
-static int shmem_get_seals(struct file *file)
+static int memfd_get_seals(struct file *file)
 {
 	if (file->f_op != &shmem_file_operations)
 		return -EINVAL;
@@ -2800,7 +2800,7 @@ static int shmem_get_seals(struct file *file)
 	return SHMEM_I(file_inode(file))->seals;
 }
 
-long shmem_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
+long memfd_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
 {
 	long error;
 
@@ -2810,10 +2810,10 @@ long shmem_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
 		if (arg > UINT_MAX)
 			return -EINVAL;
 
-		error = shmem_add_seals(file, arg);
+		error = memfd_add_seals(file, arg);
 		break;
 	case F_GET_SEALS:
-		error = shmem_get_seals(file);
+		error = memfd_get_seals(file);
 		break;
 	default:
 		error = -EINVAL;
-- 
2.15.0.125.g8f49766d64

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v3 3/9] hugetlb: expose hugetlbfs_inode_info in header
  2017-11-07 12:27 ` Marc-André Lureau
@ 2017-11-07 12:27   ` Marc-André Lureau
  -1 siblings, 0 replies; 34+ messages in thread
From: Marc-André Lureau @ 2017-11-07 12:27 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: aarcange, hughd, nyc, mike.kravetz, Marc-André Lureau

hugetlbfs inode information will need to be accessed by code in mm/shmem.c
for file sealing operations.  Move inode information definition from .c
file to header for needed access.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
---
 fs/hugetlbfs/inode.c    | 10 ----------
 include/linux/hugetlb.h | 10 ++++++++++
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index ed113ea17aff..f57aab929e41 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -55,16 +55,6 @@ struct hugetlbfs_config {
 	umode_t			mode;
 };
 
-struct hugetlbfs_inode_info {
-	struct shared_policy policy;
-	struct inode vfs_inode;
-};
-
-static inline struct hugetlbfs_inode_info *HUGETLBFS_I(struct inode *inode)
-{
-	return container_of(inode, struct hugetlbfs_inode_info, vfs_inode);
-}
-
 int sysctl_hugetlb_shm_group;
 
 enum {
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index fbf5b31d47ee..590a77433a14 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -279,6 +279,16 @@ static inline struct hugetlbfs_sb_info *HUGETLBFS_SB(struct super_block *sb)
 	return sb->s_fs_info;
 }
 
+struct hugetlbfs_inode_info {
+	struct shared_policy policy;
+	struct inode vfs_inode;
+};
+
+static inline struct hugetlbfs_inode_info *HUGETLBFS_I(struct inode *inode)
+{
+	return container_of(inode, struct hugetlbfs_inode_info, vfs_inode);
+}
+
 extern const struct file_operations hugetlbfs_file_operations;
 extern const struct vm_operations_struct hugetlb_vm_ops;
 struct file *hugetlb_file_setup(const char *name, size_t size, vm_flags_t acct,
-- 
2.15.0.125.g8f49766d64

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v3 3/9] hugetlb: expose hugetlbfs_inode_info in header
@ 2017-11-07 12:27   ` Marc-André Lureau
  0 siblings, 0 replies; 34+ messages in thread
From: Marc-André Lureau @ 2017-11-07 12:27 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: aarcange, hughd, nyc, mike.kravetz, Marc-André Lureau

hugetlbfs inode information will need to be accessed by code in mm/shmem.c
for file sealing operations.  Move inode information definition from .c
file to header for needed access.

Signed-off-by: Marc-AndrA(C) Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
---
 fs/hugetlbfs/inode.c    | 10 ----------
 include/linux/hugetlb.h | 10 ++++++++++
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index ed113ea17aff..f57aab929e41 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -55,16 +55,6 @@ struct hugetlbfs_config {
 	umode_t			mode;
 };
 
-struct hugetlbfs_inode_info {
-	struct shared_policy policy;
-	struct inode vfs_inode;
-};
-
-static inline struct hugetlbfs_inode_info *HUGETLBFS_I(struct inode *inode)
-{
-	return container_of(inode, struct hugetlbfs_inode_info, vfs_inode);
-}
-
 int sysctl_hugetlb_shm_group;
 
 enum {
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index fbf5b31d47ee..590a77433a14 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -279,6 +279,16 @@ static inline struct hugetlbfs_sb_info *HUGETLBFS_SB(struct super_block *sb)
 	return sb->s_fs_info;
 }
 
+struct hugetlbfs_inode_info {
+	struct shared_policy policy;
+	struct inode vfs_inode;
+};
+
+static inline struct hugetlbfs_inode_info *HUGETLBFS_I(struct inode *inode)
+{
+	return container_of(inode, struct hugetlbfs_inode_info, vfs_inode);
+}
+
 extern const struct file_operations hugetlbfs_file_operations;
 extern const struct vm_operations_struct hugetlb_vm_ops;
 struct file *hugetlb_file_setup(const char *name, size_t size, vm_flags_t acct,
-- 
2.15.0.125.g8f49766d64

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v3 4/9] hugetlb: implement memfd sealing
  2017-11-07 12:27 ` Marc-André Lureau
@ 2017-11-07 12:27   ` Marc-André Lureau
  -1 siblings, 0 replies; 34+ messages in thread
From: Marc-André Lureau @ 2017-11-07 12:27 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: aarcange, hughd, nyc, mike.kravetz, Marc-André Lureau

Implements memfd sealing, similar to shmem:
- WRITE: deny fallocate(PUNCH_HOLE). mmap() write is denied in
  memfd_add_seals(). write() doesn't exist for hugetlbfs.
- SHRINK: added similar check as shmem_setattr()
- GROW: added similar check as shmem_setattr() & shmem_fallocate()

Except write() operation that doesn't exist with hugetlbfs, that
should make sealing as close as it can be to shmem support.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
---
 fs/hugetlbfs/inode.c    | 29 +++++++++++++++++++++++++++--
 include/linux/hugetlb.h |  1 +
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index f57aab929e41..01f5aa6ea57a 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -510,8 +510,16 @@ static long hugetlbfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
 
 	if (hole_end > hole_start) {
 		struct address_space *mapping = inode->i_mapping;
+		struct hugetlbfs_inode_info *info = HUGETLBFS_I(inode);
 
 		inode_lock(inode);
+
+		/* protected by i_mutex */
+		if (info->seals & F_SEAL_WRITE) {
+			inode_unlock(inode);
+			return -EPERM;
+		}
+
 		i_mmap_lock_write(mapping);
 		if (!RB_EMPTY_ROOT(&mapping->i_mmap.rb_root))
 			hugetlb_vmdelete_list(&mapping->i_mmap,
@@ -529,6 +537,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
 				loff_t len)
 {
 	struct inode *inode = file_inode(file);
+	struct hugetlbfs_inode_info *info = HUGETLBFS_I(inode);
 	struct address_space *mapping = inode->i_mapping;
 	struct hstate *h = hstate_inode(inode);
 	struct vm_area_struct pseudo_vma;
@@ -560,6 +569,11 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
 	if (error)
 		goto out;
 
+	if ((info->seals & F_SEAL_GROW) && offset + len > inode->i_size) {
+		error = -EPERM;
+		goto out;
+	}
+
 	/*
 	 * Initialize a pseudo vma as this is required by the huge page
 	 * allocation routines.  If NUMA is configured, use page index
@@ -650,6 +664,7 @@ static int hugetlbfs_setattr(struct dentry *dentry, struct iattr *attr)
 	struct hstate *h = hstate_inode(inode);
 	int error;
 	unsigned int ia_valid = attr->ia_valid;
+	struct hugetlbfs_inode_info *info = HUGETLBFS_I(inode);
 
 	BUG_ON(!inode);
 
@@ -658,10 +673,17 @@ static int hugetlbfs_setattr(struct dentry *dentry, struct iattr *attr)
 		return error;
 
 	if (ia_valid & ATTR_SIZE) {
+		loff_t oldsize = inode->i_size;
+		loff_t newsize = attr->ia_size;
+
 		error = -EINVAL;
-		if (attr->ia_size & ~huge_page_mask(h))
+		if (newsize & ~huge_page_mask(h))
 			return -EINVAL;
-		error = hugetlb_vmtruncate(inode, attr->ia_size);
+		/* protected by i_mutex */
+		if ((newsize < oldsize && (info->seals & F_SEAL_SHRINK)) ||
+		    (newsize > oldsize && (info->seals & F_SEAL_GROW)))
+			return -EPERM;
+		error = hugetlb_vmtruncate(inode, newsize);
 		if (error)
 			return error;
 	}
@@ -713,6 +735,8 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb,
 
 	inode = new_inode(sb);
 	if (inode) {
+		struct hugetlbfs_inode_info *info = HUGETLBFS_I(inode);
+
 		inode->i_ino = get_next_ino();
 		inode_init_owner(inode, dir, mode);
 		lockdep_set_class(&inode->i_mapping->i_mmap_rwsem,
@@ -720,6 +744,7 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb,
 		inode->i_mapping->a_ops = &hugetlbfs_aops;
 		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
 		inode->i_mapping->private_data = resv_map;
+		info->seals = F_SEAL_SEAL;
 		switch (mode & S_IFMT) {
 		default:
 			init_special_inode(inode, mode, dev);
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 590a77433a14..2a21c59a9952 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -282,6 +282,7 @@ static inline struct hugetlbfs_sb_info *HUGETLBFS_SB(struct super_block *sb)
 struct hugetlbfs_inode_info {
 	struct shared_policy policy;
 	struct inode vfs_inode;
+	unsigned int seals;
 };
 
 static inline struct hugetlbfs_inode_info *HUGETLBFS_I(struct inode *inode)
-- 
2.15.0.125.g8f49766d64

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v3 4/9] hugetlb: implement memfd sealing
@ 2017-11-07 12:27   ` Marc-André Lureau
  0 siblings, 0 replies; 34+ messages in thread
From: Marc-André Lureau @ 2017-11-07 12:27 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: aarcange, hughd, nyc, mike.kravetz, Marc-André Lureau

Implements memfd sealing, similar to shmem:
- WRITE: deny fallocate(PUNCH_HOLE). mmap() write is denied in
  memfd_add_seals(). write() doesn't exist for hugetlbfs.
- SHRINK: added similar check as shmem_setattr()
- GROW: added similar check as shmem_setattr() & shmem_fallocate()

Except write() operation that doesn't exist with hugetlbfs, that
should make sealing as close as it can be to shmem support.

Signed-off-by: Marc-AndrA(C) Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
---
 fs/hugetlbfs/inode.c    | 29 +++++++++++++++++++++++++++--
 include/linux/hugetlb.h |  1 +
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index f57aab929e41..01f5aa6ea57a 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -510,8 +510,16 @@ static long hugetlbfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
 
 	if (hole_end > hole_start) {
 		struct address_space *mapping = inode->i_mapping;
+		struct hugetlbfs_inode_info *info = HUGETLBFS_I(inode);
 
 		inode_lock(inode);
+
+		/* protected by i_mutex */
+		if (info->seals & F_SEAL_WRITE) {
+			inode_unlock(inode);
+			return -EPERM;
+		}
+
 		i_mmap_lock_write(mapping);
 		if (!RB_EMPTY_ROOT(&mapping->i_mmap.rb_root))
 			hugetlb_vmdelete_list(&mapping->i_mmap,
@@ -529,6 +537,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
 				loff_t len)
 {
 	struct inode *inode = file_inode(file);
+	struct hugetlbfs_inode_info *info = HUGETLBFS_I(inode);
 	struct address_space *mapping = inode->i_mapping;
 	struct hstate *h = hstate_inode(inode);
 	struct vm_area_struct pseudo_vma;
@@ -560,6 +569,11 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
 	if (error)
 		goto out;
 
+	if ((info->seals & F_SEAL_GROW) && offset + len > inode->i_size) {
+		error = -EPERM;
+		goto out;
+	}
+
 	/*
 	 * Initialize a pseudo vma as this is required by the huge page
 	 * allocation routines.  If NUMA is configured, use page index
@@ -650,6 +664,7 @@ static int hugetlbfs_setattr(struct dentry *dentry, struct iattr *attr)
 	struct hstate *h = hstate_inode(inode);
 	int error;
 	unsigned int ia_valid = attr->ia_valid;
+	struct hugetlbfs_inode_info *info = HUGETLBFS_I(inode);
 
 	BUG_ON(!inode);
 
@@ -658,10 +673,17 @@ static int hugetlbfs_setattr(struct dentry *dentry, struct iattr *attr)
 		return error;
 
 	if (ia_valid & ATTR_SIZE) {
+		loff_t oldsize = inode->i_size;
+		loff_t newsize = attr->ia_size;
+
 		error = -EINVAL;
-		if (attr->ia_size & ~huge_page_mask(h))
+		if (newsize & ~huge_page_mask(h))
 			return -EINVAL;
-		error = hugetlb_vmtruncate(inode, attr->ia_size);
+		/* protected by i_mutex */
+		if ((newsize < oldsize && (info->seals & F_SEAL_SHRINK)) ||
+		    (newsize > oldsize && (info->seals & F_SEAL_GROW)))
+			return -EPERM;
+		error = hugetlb_vmtruncate(inode, newsize);
 		if (error)
 			return error;
 	}
@@ -713,6 +735,8 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb,
 
 	inode = new_inode(sb);
 	if (inode) {
+		struct hugetlbfs_inode_info *info = HUGETLBFS_I(inode);
+
 		inode->i_ino = get_next_ino();
 		inode_init_owner(inode, dir, mode);
 		lockdep_set_class(&inode->i_mapping->i_mmap_rwsem,
@@ -720,6 +744,7 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb,
 		inode->i_mapping->a_ops = &hugetlbfs_aops;
 		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
 		inode->i_mapping->private_data = resv_map;
+		info->seals = F_SEAL_SEAL;
 		switch (mode & S_IFMT) {
 		default:
 			init_special_inode(inode, mode, dev);
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 590a77433a14..2a21c59a9952 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -282,6 +282,7 @@ static inline struct hugetlbfs_sb_info *HUGETLBFS_SB(struct super_block *sb)
 struct hugetlbfs_inode_info {
 	struct shared_policy policy;
 	struct inode vfs_inode;
+	unsigned int seals;
 };
 
 static inline struct hugetlbfs_inode_info *HUGETLBFS_I(struct inode *inode)
-- 
2.15.0.125.g8f49766d64

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v3 5/9] shmem: add sealing support to hugetlb-backed memfd
  2017-11-07 12:27 ` Marc-André Lureau
@ 2017-11-07 12:27   ` Marc-André Lureau
  -1 siblings, 0 replies; 34+ messages in thread
From: Marc-André Lureau @ 2017-11-07 12:27 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: aarcange, hughd, nyc, mike.kravetz, Marc-André Lureau

Adapt add_seals()/get_seals() to work with hugetbfs-backed memory.

Teach memfd_create() to allow sealing operations on MFD_HUGETLB.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
---
 mm/shmem.c | 47 ++++++++++++++++++++++++++++-------------------
 1 file changed, 28 insertions(+), 19 deletions(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index b7811979611f..b08ba5d84d84 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2717,6 +2717,19 @@ static int shmem_wait_for_pins(struct address_space *mapping)
 	return error;
 }
 
+static unsigned int *memfd_file_seals_ptr(struct file *file)
+{
+	if (file->f_op == &shmem_file_operations)
+		return &SHMEM_I(file_inode(file))->seals;
+
+#ifdef CONFIG_HUGETLBFS
+	if (file->f_op == &hugetlbfs_file_operations)
+		return &HUGETLBFS_I(file_inode(file))->seals;
+#endif
+
+	return NULL;
+}
+
 #define F_ALL_SEALS (F_SEAL_SEAL | \
 		     F_SEAL_SHRINK | \
 		     F_SEAL_GROW | \
@@ -2725,7 +2738,7 @@ static int shmem_wait_for_pins(struct address_space *mapping)
 static int memfd_add_seals(struct file *file, unsigned int seals)
 {
 	struct inode *inode = file_inode(file);
-	struct shmem_inode_info *info = SHMEM_I(inode);
+	unsigned int *file_seals;
 	int error;
 
 	/*
@@ -2758,8 +2771,6 @@ static int memfd_add_seals(struct file *file, unsigned int seals)
 	 * other file types.
 	 */
 
-	if (file->f_op != &shmem_file_operations)
-		return -EINVAL;
 	if (!(file->f_mode & FMODE_WRITE))
 		return -EPERM;
 	if (seals & ~(unsigned int)F_ALL_SEALS)
@@ -2767,12 +2778,18 @@ static int memfd_add_seals(struct file *file, unsigned int seals)
 
 	inode_lock(inode);
 
-	if (info->seals & F_SEAL_SEAL) {
+	file_seals = memfd_file_seals_ptr(file);
+	if (!file_seals) {
+		error = -EINVAL;
+		goto unlock;
+	}
+
+	if (*file_seals & F_SEAL_SEAL) {
 		error = -EPERM;
 		goto unlock;
 	}
 
-	if ((seals & F_SEAL_WRITE) && !(info->seals & F_SEAL_WRITE)) {
+	if ((seals & F_SEAL_WRITE) && !(*file_seals & F_SEAL_WRITE)) {
 		error = mapping_deny_writable(file->f_mapping);
 		if (error)
 			goto unlock;
@@ -2784,7 +2801,7 @@ static int memfd_add_seals(struct file *file, unsigned int seals)
 		}
 	}
 
-	info->seals |= seals;
+	*file_seals |= seals;
 	error = 0;
 
 unlock:
@@ -2794,10 +2811,9 @@ static int memfd_add_seals(struct file *file, unsigned int seals)
 
 static int memfd_get_seals(struct file *file)
 {
-	if (file->f_op != &shmem_file_operations)
-		return -EINVAL;
+	unsigned int *seals = memfd_file_seals_ptr(file);
 
-	return SHMEM_I(file_inode(file))->seals;
+	return seals ? *seals : -EINVAL;
 }
 
 long memfd_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
@@ -3657,7 +3673,7 @@ SYSCALL_DEFINE2(memfd_create,
 		const char __user *, uname,
 		unsigned int, flags)
 {
-	struct shmem_inode_info *info;
+	unsigned int *file_seals;
 	struct file *file;
 	int fd, error;
 	char *name;
@@ -3667,9 +3683,6 @@ SYSCALL_DEFINE2(memfd_create,
 		if (flags & ~(unsigned int)MFD_ALL_FLAGS)
 			return -EINVAL;
 	} else {
-		/* Sealing not supported in hugetlbfs (MFD_HUGETLB) */
-		if (flags & MFD_ALLOW_SEALING)
-			return -EINVAL;
 		/* Allow huge page size encoding in flags. */
 		if (flags & ~(unsigned int)(MFD_ALL_FLAGS |
 				(MFD_HUGE_MASK << MFD_HUGE_SHIFT)))
@@ -3722,12 +3735,8 @@ SYSCALL_DEFINE2(memfd_create,
 	file->f_flags |= O_RDWR | O_LARGEFILE;
 
 	if (flags & MFD_ALLOW_SEALING) {
-		/*
-		 * flags check at beginning of function ensures
-		 * this is not a hugetlbfs (MFD_HUGETLB) file.
-		 */
-		info = SHMEM_I(file_inode(file));
-		info->seals &= ~F_SEAL_SEAL;
+		file_seals = memfd_file_seals_ptr(file);
+		*file_seals &= ~F_SEAL_SEAL;
 	}
 
 	fd_install(fd, file);
-- 
2.15.0.125.g8f49766d64

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v3 5/9] shmem: add sealing support to hugetlb-backed memfd
@ 2017-11-07 12:27   ` Marc-André Lureau
  0 siblings, 0 replies; 34+ messages in thread
From: Marc-André Lureau @ 2017-11-07 12:27 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: aarcange, hughd, nyc, mike.kravetz, Marc-André Lureau

Adapt add_seals()/get_seals() to work with hugetbfs-backed memory.

Teach memfd_create() to allow sealing operations on MFD_HUGETLB.

Signed-off-by: Marc-AndrA(C) Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
---
 mm/shmem.c | 47 ++++++++++++++++++++++++++++-------------------
 1 file changed, 28 insertions(+), 19 deletions(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index b7811979611f..b08ba5d84d84 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2717,6 +2717,19 @@ static int shmem_wait_for_pins(struct address_space *mapping)
 	return error;
 }
 
+static unsigned int *memfd_file_seals_ptr(struct file *file)
+{
+	if (file->f_op == &shmem_file_operations)
+		return &SHMEM_I(file_inode(file))->seals;
+
+#ifdef CONFIG_HUGETLBFS
+	if (file->f_op == &hugetlbfs_file_operations)
+		return &HUGETLBFS_I(file_inode(file))->seals;
+#endif
+
+	return NULL;
+}
+
 #define F_ALL_SEALS (F_SEAL_SEAL | \
 		     F_SEAL_SHRINK | \
 		     F_SEAL_GROW | \
@@ -2725,7 +2738,7 @@ static int shmem_wait_for_pins(struct address_space *mapping)
 static int memfd_add_seals(struct file *file, unsigned int seals)
 {
 	struct inode *inode = file_inode(file);
-	struct shmem_inode_info *info = SHMEM_I(inode);
+	unsigned int *file_seals;
 	int error;
 
 	/*
@@ -2758,8 +2771,6 @@ static int memfd_add_seals(struct file *file, unsigned int seals)
 	 * other file types.
 	 */
 
-	if (file->f_op != &shmem_file_operations)
-		return -EINVAL;
 	if (!(file->f_mode & FMODE_WRITE))
 		return -EPERM;
 	if (seals & ~(unsigned int)F_ALL_SEALS)
@@ -2767,12 +2778,18 @@ static int memfd_add_seals(struct file *file, unsigned int seals)
 
 	inode_lock(inode);
 
-	if (info->seals & F_SEAL_SEAL) {
+	file_seals = memfd_file_seals_ptr(file);
+	if (!file_seals) {
+		error = -EINVAL;
+		goto unlock;
+	}
+
+	if (*file_seals & F_SEAL_SEAL) {
 		error = -EPERM;
 		goto unlock;
 	}
 
-	if ((seals & F_SEAL_WRITE) && !(info->seals & F_SEAL_WRITE)) {
+	if ((seals & F_SEAL_WRITE) && !(*file_seals & F_SEAL_WRITE)) {
 		error = mapping_deny_writable(file->f_mapping);
 		if (error)
 			goto unlock;
@@ -2784,7 +2801,7 @@ static int memfd_add_seals(struct file *file, unsigned int seals)
 		}
 	}
 
-	info->seals |= seals;
+	*file_seals |= seals;
 	error = 0;
 
 unlock:
@@ -2794,10 +2811,9 @@ static int memfd_add_seals(struct file *file, unsigned int seals)
 
 static int memfd_get_seals(struct file *file)
 {
-	if (file->f_op != &shmem_file_operations)
-		return -EINVAL;
+	unsigned int *seals = memfd_file_seals_ptr(file);
 
-	return SHMEM_I(file_inode(file))->seals;
+	return seals ? *seals : -EINVAL;
 }
 
 long memfd_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
@@ -3657,7 +3673,7 @@ SYSCALL_DEFINE2(memfd_create,
 		const char __user *, uname,
 		unsigned int, flags)
 {
-	struct shmem_inode_info *info;
+	unsigned int *file_seals;
 	struct file *file;
 	int fd, error;
 	char *name;
@@ -3667,9 +3683,6 @@ SYSCALL_DEFINE2(memfd_create,
 		if (flags & ~(unsigned int)MFD_ALL_FLAGS)
 			return -EINVAL;
 	} else {
-		/* Sealing not supported in hugetlbfs (MFD_HUGETLB) */
-		if (flags & MFD_ALLOW_SEALING)
-			return -EINVAL;
 		/* Allow huge page size encoding in flags. */
 		if (flags & ~(unsigned int)(MFD_ALL_FLAGS |
 				(MFD_HUGE_MASK << MFD_HUGE_SHIFT)))
@@ -3722,12 +3735,8 @@ SYSCALL_DEFINE2(memfd_create,
 	file->f_flags |= O_RDWR | O_LARGEFILE;
 
 	if (flags & MFD_ALLOW_SEALING) {
-		/*
-		 * flags check at beginning of function ensures
-		 * this is not a hugetlbfs (MFD_HUGETLB) file.
-		 */
-		info = SHMEM_I(file_inode(file));
-		info->seals &= ~F_SEAL_SEAL;
+		file_seals = memfd_file_seals_ptr(file);
+		*file_seals &= ~F_SEAL_SEAL;
 	}
 
 	fd_install(fd, file);
-- 
2.15.0.125.g8f49766d64

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v3 6/9] memfd-test: test hugetlbfs sealing
  2017-11-07 12:27 ` Marc-André Lureau
@ 2017-11-07 12:27   ` Marc-André Lureau
  -1 siblings, 0 replies; 34+ messages in thread
From: Marc-André Lureau @ 2017-11-07 12:27 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: aarcange, hughd, nyc, mike.kravetz, Marc-André Lureau

Remove most of the special-casing of hugetlbfs now that sealing
is supported.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
---
 tools/testing/selftests/memfd/memfd_test.c | 150 +++--------------------------
 1 file changed, 15 insertions(+), 135 deletions(-)

diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c
index 845e5f67b6f0..cca957a06525 100644
--- a/tools/testing/selftests/memfd/memfd_test.c
+++ b/tools/testing/selftests/memfd/memfd_test.c
@@ -513,6 +513,10 @@ static void mfd_assert_grow_write(int fd)
 	static char *buf;
 	ssize_t l;
 
+	/* hugetlbfs does not support write */
+	if (hugetlbfs_test)
+		return;
+
 	buf = malloc(mfd_def_size * 8);
 	if (!buf) {
 		printf("malloc(%d) failed: %m\n", mfd_def_size * 8);
@@ -533,6 +537,10 @@ static void mfd_fail_grow_write(int fd)
 	static char *buf;
 	ssize_t l;
 
+	/* hugetlbfs does not support write */
+	if (hugetlbfs_test)
+		return;
+
 	buf = malloc(mfd_def_size * 8);
 	if (!buf) {
 		printf("malloc(%d) failed: %m\n", mfd_def_size * 8);
@@ -627,18 +635,13 @@ static void test_create(void)
 	fd = mfd_assert_new("", 0, MFD_CLOEXEC);
 	close(fd);
 
-	if (!hugetlbfs_test) {
-		/* verify MFD_ALLOW_SEALING is allowed */
-		fd = mfd_assert_new("", 0, MFD_ALLOW_SEALING);
-		close(fd);
-
-		/* verify MFD_ALLOW_SEALING | MFD_CLOEXEC is allowed */
-		fd = mfd_assert_new("", 0, MFD_ALLOW_SEALING | MFD_CLOEXEC);
-		close(fd);
-	} else {
-		/* sealing is not supported on hugetlbfs */
-		mfd_fail_new("", MFD_ALLOW_SEALING);
-	}
+	/* verify MFD_ALLOW_SEALING is allowed */
+	fd = mfd_assert_new("", 0, MFD_ALLOW_SEALING);
+	close(fd);
+
+	/* verify MFD_ALLOW_SEALING | MFD_CLOEXEC is allowed */
+	fd = mfd_assert_new("", 0, MFD_ALLOW_SEALING | MFD_CLOEXEC);
+	close(fd);
 }
 
 /*
@@ -649,10 +652,6 @@ static void test_basic(void)
 {
 	int fd;
 
-	/* hugetlbfs does not contain sealing support */
-	if (hugetlbfs_test)
-		return;
-
 	printf("%s BASIC\n", MEMFD_STR);
 
 	fd = mfd_assert_new("kern_memfd_basic",
@@ -697,28 +696,6 @@ static void test_basic(void)
 	close(fd);
 }
 
-/*
- * hugetlbfs doesn't support seals or write, so just verify grow and shrink
- * on a hugetlbfs file created via memfd_create.
- */
-static void test_hugetlbfs_grow_shrink(void)
-{
-	int fd;
-
-	printf("%s HUGETLBFS-GROW-SHRINK\n", MEMFD_STR);
-
-	fd = mfd_assert_new("kern_memfd_seal_write",
-			    mfd_def_size,
-			    MFD_CLOEXEC);
-
-	mfd_assert_read(fd);
-	mfd_assert_write(fd);
-	mfd_assert_shrink(fd);
-	mfd_assert_grow(fd);
-
-	close(fd);
-}
-
 /*
  * Test SEAL_WRITE
  * Test whether SEAL_WRITE actually prevents modifications.
@@ -727,13 +704,6 @@ static void test_seal_write(void)
 {
 	int fd;
 
-	/*
-	 * hugetlbfs does not contain sealing or write support.  Just test
-	 * basic grow and shrink via test_hugetlbfs_grow_shrink.
-	 */
-	if (hugetlbfs_test)
-		return test_hugetlbfs_grow_shrink();
-
 	printf("%s SEAL-WRITE\n", MEMFD_STR);
 
 	fd = mfd_assert_new("kern_memfd_seal_write",
@@ -760,10 +730,6 @@ static void test_seal_shrink(void)
 {
 	int fd;
 
-	/* hugetlbfs does not contain sealing support */
-	if (hugetlbfs_test)
-		return;
-
 	printf("%s SEAL-SHRINK\n", MEMFD_STR);
 
 	fd = mfd_assert_new("kern_memfd_seal_shrink",
@@ -790,10 +756,6 @@ static void test_seal_grow(void)
 {
 	int fd;
 
-	/* hugetlbfs does not contain sealing support */
-	if (hugetlbfs_test)
-		return;
-
 	printf("%s SEAL-GROW\n", MEMFD_STR);
 
 	fd = mfd_assert_new("kern_memfd_seal_grow",
@@ -820,10 +782,6 @@ static void test_seal_resize(void)
 {
 	int fd;
 
-	/* hugetlbfs does not contain sealing support */
-	if (hugetlbfs_test)
-		return;
-
 	printf("%s SEAL-RESIZE\n", MEMFD_STR);
 
 	fd = mfd_assert_new("kern_memfd_seal_resize",
@@ -842,32 +800,6 @@ static void test_seal_resize(void)
 	close(fd);
 }
 
-/*
- * hugetlbfs does not support seals.  Basic test to dup the memfd created
- * fd and perform some basic operations on it.
- */
-static void hugetlbfs_dup(char *b_suffix)
-{
-	int fd, fd2;
-
-	printf("%s HUGETLBFS-DUP %s\n", MEMFD_STR, b_suffix);
-
-	fd = mfd_assert_new("kern_memfd_share_dup",
-			    mfd_def_size,
-			    MFD_CLOEXEC);
-
-	fd2 = mfd_assert_dup(fd);
-
-	mfd_assert_read(fd);
-	mfd_assert_write(fd);
-
-	mfd_assert_shrink(fd2);
-	mfd_assert_grow(fd2);
-
-	close(fd2);
-	close(fd);
-}
-
 /*
  * Test sharing via dup()
  * Test that seals are shared between dupped FDs and they're all equal.
@@ -876,15 +808,6 @@ static void test_share_dup(char *banner, char *b_suffix)
 {
 	int fd, fd2;
 
-	/*
-	 * hugetlbfs does not contain sealing support.  Perform some
-	 * basic testing on dup'ed fd instead via hugetlbfs_dup.
-	 */
-	if (hugetlbfs_test) {
-		hugetlbfs_dup(b_suffix);
-		return;
-	}
-
 	printf("%s %s %s\n", MEMFD_STR, banner, b_suffix);
 
 	fd = mfd_assert_new("kern_memfd_share_dup",
@@ -927,10 +850,6 @@ static void test_share_mmap(char *banner, char *b_suffix)
 	int fd;
 	void *p;
 
-	/* hugetlbfs does not contain sealing support */
-	if (hugetlbfs_test)
-		return;
-
 	printf("%s %s %s\n", MEMFD_STR,  banner, b_suffix);
 
 	fd = mfd_assert_new("kern_memfd_share_mmap",
@@ -955,32 +874,6 @@ static void test_share_mmap(char *banner, char *b_suffix)
 	close(fd);
 }
 
-/*
- * Basic test to make sure we can open the hugetlbfs fd via /proc and
- * perform some simple operations on it.
- */
-static void hugetlbfs_proc_open(char *b_suffix)
-{
-	int fd, fd2;
-
-	printf("%s HUGETLBFS-PROC-OPEN %s\n", MEMFD_STR, b_suffix);
-
-	fd = mfd_assert_new("kern_memfd_share_open",
-			    mfd_def_size,
-			    MFD_CLOEXEC);
-
-	fd2 = mfd_assert_open(fd, O_RDWR, 0);
-
-	mfd_assert_read(fd);
-	mfd_assert_write(fd);
-
-	mfd_assert_shrink(fd2);
-	mfd_assert_grow(fd2);
-
-	close(fd2);
-	close(fd);
-}
-
 /*
  * Test sealing with open(/proc/self/fd/%d)
  * Via /proc we can get access to a separate file-context for the same memfd.
@@ -991,15 +884,6 @@ static void test_share_open(char *banner, char *b_suffix)
 {
 	int fd, fd2;
 
-	/*
-	 * hugetlbfs does not contain sealing support.  So test basic
-	 * functionality of using /proc fd via hugetlbfs_proc_open
-	 */
-	if (hugetlbfs_test) {
-		hugetlbfs_proc_open(b_suffix);
-		return;
-	}
-
 	printf("%s %s %s\n", MEMFD_STR, banner, b_suffix);
 
 	fd = mfd_assert_new("kern_memfd_share_open",
@@ -1043,10 +927,6 @@ static void test_share_fork(char *banner, char *b_suffix)
 	int fd;
 	pid_t pid;
 
-	/* hugetlbfs does not contain sealing support */
-	if (hugetlbfs_test)
-		return;
-
 	printf("%s %s %s\n", MEMFD_STR, banner, b_suffix);
 
 	fd = mfd_assert_new("kern_memfd_share_fork",
-- 
2.15.0.125.g8f49766d64

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v3 6/9] memfd-test: test hugetlbfs sealing
@ 2017-11-07 12:27   ` Marc-André Lureau
  0 siblings, 0 replies; 34+ messages in thread
From: Marc-André Lureau @ 2017-11-07 12:27 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: aarcange, hughd, nyc, mike.kravetz, Marc-André Lureau

Remove most of the special-casing of hugetlbfs now that sealing
is supported.

Signed-off-by: Marc-AndrA(C) Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
---
 tools/testing/selftests/memfd/memfd_test.c | 150 +++--------------------------
 1 file changed, 15 insertions(+), 135 deletions(-)

diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c
index 845e5f67b6f0..cca957a06525 100644
--- a/tools/testing/selftests/memfd/memfd_test.c
+++ b/tools/testing/selftests/memfd/memfd_test.c
@@ -513,6 +513,10 @@ static void mfd_assert_grow_write(int fd)
 	static char *buf;
 	ssize_t l;
 
+	/* hugetlbfs does not support write */
+	if (hugetlbfs_test)
+		return;
+
 	buf = malloc(mfd_def_size * 8);
 	if (!buf) {
 		printf("malloc(%d) failed: %m\n", mfd_def_size * 8);
@@ -533,6 +537,10 @@ static void mfd_fail_grow_write(int fd)
 	static char *buf;
 	ssize_t l;
 
+	/* hugetlbfs does not support write */
+	if (hugetlbfs_test)
+		return;
+
 	buf = malloc(mfd_def_size * 8);
 	if (!buf) {
 		printf("malloc(%d) failed: %m\n", mfd_def_size * 8);
@@ -627,18 +635,13 @@ static void test_create(void)
 	fd = mfd_assert_new("", 0, MFD_CLOEXEC);
 	close(fd);
 
-	if (!hugetlbfs_test) {
-		/* verify MFD_ALLOW_SEALING is allowed */
-		fd = mfd_assert_new("", 0, MFD_ALLOW_SEALING);
-		close(fd);
-
-		/* verify MFD_ALLOW_SEALING | MFD_CLOEXEC is allowed */
-		fd = mfd_assert_new("", 0, MFD_ALLOW_SEALING | MFD_CLOEXEC);
-		close(fd);
-	} else {
-		/* sealing is not supported on hugetlbfs */
-		mfd_fail_new("", MFD_ALLOW_SEALING);
-	}
+	/* verify MFD_ALLOW_SEALING is allowed */
+	fd = mfd_assert_new("", 0, MFD_ALLOW_SEALING);
+	close(fd);
+
+	/* verify MFD_ALLOW_SEALING | MFD_CLOEXEC is allowed */
+	fd = mfd_assert_new("", 0, MFD_ALLOW_SEALING | MFD_CLOEXEC);
+	close(fd);
 }
 
 /*
@@ -649,10 +652,6 @@ static void test_basic(void)
 {
 	int fd;
 
-	/* hugetlbfs does not contain sealing support */
-	if (hugetlbfs_test)
-		return;
-
 	printf("%s BASIC\n", MEMFD_STR);
 
 	fd = mfd_assert_new("kern_memfd_basic",
@@ -697,28 +696,6 @@ static void test_basic(void)
 	close(fd);
 }
 
-/*
- * hugetlbfs doesn't support seals or write, so just verify grow and shrink
- * on a hugetlbfs file created via memfd_create.
- */
-static void test_hugetlbfs_grow_shrink(void)
-{
-	int fd;
-
-	printf("%s HUGETLBFS-GROW-SHRINK\n", MEMFD_STR);
-
-	fd = mfd_assert_new("kern_memfd_seal_write",
-			    mfd_def_size,
-			    MFD_CLOEXEC);
-
-	mfd_assert_read(fd);
-	mfd_assert_write(fd);
-	mfd_assert_shrink(fd);
-	mfd_assert_grow(fd);
-
-	close(fd);
-}
-
 /*
  * Test SEAL_WRITE
  * Test whether SEAL_WRITE actually prevents modifications.
@@ -727,13 +704,6 @@ static void test_seal_write(void)
 {
 	int fd;
 
-	/*
-	 * hugetlbfs does not contain sealing or write support.  Just test
-	 * basic grow and shrink via test_hugetlbfs_grow_shrink.
-	 */
-	if (hugetlbfs_test)
-		return test_hugetlbfs_grow_shrink();
-
 	printf("%s SEAL-WRITE\n", MEMFD_STR);
 
 	fd = mfd_assert_new("kern_memfd_seal_write",
@@ -760,10 +730,6 @@ static void test_seal_shrink(void)
 {
 	int fd;
 
-	/* hugetlbfs does not contain sealing support */
-	if (hugetlbfs_test)
-		return;
-
 	printf("%s SEAL-SHRINK\n", MEMFD_STR);
 
 	fd = mfd_assert_new("kern_memfd_seal_shrink",
@@ -790,10 +756,6 @@ static void test_seal_grow(void)
 {
 	int fd;
 
-	/* hugetlbfs does not contain sealing support */
-	if (hugetlbfs_test)
-		return;
-
 	printf("%s SEAL-GROW\n", MEMFD_STR);
 
 	fd = mfd_assert_new("kern_memfd_seal_grow",
@@ -820,10 +782,6 @@ static void test_seal_resize(void)
 {
 	int fd;
 
-	/* hugetlbfs does not contain sealing support */
-	if (hugetlbfs_test)
-		return;
-
 	printf("%s SEAL-RESIZE\n", MEMFD_STR);
 
 	fd = mfd_assert_new("kern_memfd_seal_resize",
@@ -842,32 +800,6 @@ static void test_seal_resize(void)
 	close(fd);
 }
 
-/*
- * hugetlbfs does not support seals.  Basic test to dup the memfd created
- * fd and perform some basic operations on it.
- */
-static void hugetlbfs_dup(char *b_suffix)
-{
-	int fd, fd2;
-
-	printf("%s HUGETLBFS-DUP %s\n", MEMFD_STR, b_suffix);
-
-	fd = mfd_assert_new("kern_memfd_share_dup",
-			    mfd_def_size,
-			    MFD_CLOEXEC);
-
-	fd2 = mfd_assert_dup(fd);
-
-	mfd_assert_read(fd);
-	mfd_assert_write(fd);
-
-	mfd_assert_shrink(fd2);
-	mfd_assert_grow(fd2);
-
-	close(fd2);
-	close(fd);
-}
-
 /*
  * Test sharing via dup()
  * Test that seals are shared between dupped FDs and they're all equal.
@@ -876,15 +808,6 @@ static void test_share_dup(char *banner, char *b_suffix)
 {
 	int fd, fd2;
 
-	/*
-	 * hugetlbfs does not contain sealing support.  Perform some
-	 * basic testing on dup'ed fd instead via hugetlbfs_dup.
-	 */
-	if (hugetlbfs_test) {
-		hugetlbfs_dup(b_suffix);
-		return;
-	}
-
 	printf("%s %s %s\n", MEMFD_STR, banner, b_suffix);
 
 	fd = mfd_assert_new("kern_memfd_share_dup",
@@ -927,10 +850,6 @@ static void test_share_mmap(char *banner, char *b_suffix)
 	int fd;
 	void *p;
 
-	/* hugetlbfs does not contain sealing support */
-	if (hugetlbfs_test)
-		return;
-
 	printf("%s %s %s\n", MEMFD_STR,  banner, b_suffix);
 
 	fd = mfd_assert_new("kern_memfd_share_mmap",
@@ -955,32 +874,6 @@ static void test_share_mmap(char *banner, char *b_suffix)
 	close(fd);
 }
 
-/*
- * Basic test to make sure we can open the hugetlbfs fd via /proc and
- * perform some simple operations on it.
- */
-static void hugetlbfs_proc_open(char *b_suffix)
-{
-	int fd, fd2;
-
-	printf("%s HUGETLBFS-PROC-OPEN %s\n", MEMFD_STR, b_suffix);
-
-	fd = mfd_assert_new("kern_memfd_share_open",
-			    mfd_def_size,
-			    MFD_CLOEXEC);
-
-	fd2 = mfd_assert_open(fd, O_RDWR, 0);
-
-	mfd_assert_read(fd);
-	mfd_assert_write(fd);
-
-	mfd_assert_shrink(fd2);
-	mfd_assert_grow(fd2);
-
-	close(fd2);
-	close(fd);
-}
-
 /*
  * Test sealing with open(/proc/self/fd/%d)
  * Via /proc we can get access to a separate file-context for the same memfd.
@@ -991,15 +884,6 @@ static void test_share_open(char *banner, char *b_suffix)
 {
 	int fd, fd2;
 
-	/*
-	 * hugetlbfs does not contain sealing support.  So test basic
-	 * functionality of using /proc fd via hugetlbfs_proc_open
-	 */
-	if (hugetlbfs_test) {
-		hugetlbfs_proc_open(b_suffix);
-		return;
-	}
-
 	printf("%s %s %s\n", MEMFD_STR, banner, b_suffix);
 
 	fd = mfd_assert_new("kern_memfd_share_open",
@@ -1043,10 +927,6 @@ static void test_share_fork(char *banner, char *b_suffix)
 	int fd;
 	pid_t pid;
 
-	/* hugetlbfs does not contain sealing support */
-	if (hugetlbfs_test)
-		return;
-
 	printf("%s %s %s\n", MEMFD_STR, banner, b_suffix);
 
 	fd = mfd_assert_new("kern_memfd_share_fork",
-- 
2.15.0.125.g8f49766d64

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v3 7/9] memfd-test: add 'memfd-hugetlb:' prefix when testing hugetlbfs
  2017-11-07 12:27 ` Marc-André Lureau
@ 2017-11-07 12:27   ` Marc-André Lureau
  -1 siblings, 0 replies; 34+ messages in thread
From: Marc-André Lureau @ 2017-11-07 12:27 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: aarcange, hughd, nyc, mike.kravetz, Marc-André Lureau

Suggested-by: Mike Kravetz <mike.kravetz@oracle.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
---
 tools/testing/selftests/memfd/memfd_test.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c
index cca957a06525..955d09ee16ca 100644
--- a/tools/testing/selftests/memfd/memfd_test.c
+++ b/tools/testing/selftests/memfd/memfd_test.c
@@ -20,6 +20,7 @@
 #include <unistd.h>
 
 #define MEMFD_STR	"memfd:"
+#define MEMFD_HUGE_STR	"memfd-hugetlb:"
 #define SHARED_FT_STR	"(shared file-table)"
 
 #define MFD_DEF_SIZE 8192
@@ -30,6 +31,7 @@
  */
 static int hugetlbfs_test;
 static size_t mfd_def_size = MFD_DEF_SIZE;
+static const char *memfd_str = MEMFD_STR;
 
 /*
  * Copied from mlock2-tests.c
@@ -606,7 +608,7 @@ static void test_create(void)
 	char buf[2048];
 	int fd;
 
-	printf("%s CREATE\n", MEMFD_STR);
+	printf("%s CREATE\n", memfd_str);
 
 	/* test NULL name */
 	mfd_fail_new(NULL, 0);
@@ -652,7 +654,7 @@ static void test_basic(void)
 {
 	int fd;
 
-	printf("%s BASIC\n", MEMFD_STR);
+	printf("%s BASIC\n", memfd_str);
 
 	fd = mfd_assert_new("kern_memfd_basic",
 			    mfd_def_size,
@@ -704,7 +706,7 @@ static void test_seal_write(void)
 {
 	int fd;
 
-	printf("%s SEAL-WRITE\n", MEMFD_STR);
+	printf("%s SEAL-WRITE\n", memfd_str);
 
 	fd = mfd_assert_new("kern_memfd_seal_write",
 			    mfd_def_size,
@@ -730,7 +732,7 @@ static void test_seal_shrink(void)
 {
 	int fd;
 
-	printf("%s SEAL-SHRINK\n", MEMFD_STR);
+	printf("%s SEAL-SHRINK\n", memfd_str);
 
 	fd = mfd_assert_new("kern_memfd_seal_shrink",
 			    mfd_def_size,
@@ -756,7 +758,7 @@ static void test_seal_grow(void)
 {
 	int fd;
 
-	printf("%s SEAL-GROW\n", MEMFD_STR);
+	printf("%s SEAL-GROW\n", memfd_str);
 
 	fd = mfd_assert_new("kern_memfd_seal_grow",
 			    mfd_def_size,
@@ -782,7 +784,7 @@ static void test_seal_resize(void)
 {
 	int fd;
 
-	printf("%s SEAL-RESIZE\n", MEMFD_STR);
+	printf("%s SEAL-RESIZE\n", memfd_str);
 
 	fd = mfd_assert_new("kern_memfd_seal_resize",
 			    mfd_def_size,
@@ -808,7 +810,7 @@ static void test_share_dup(char *banner, char *b_suffix)
 {
 	int fd, fd2;
 
-	printf("%s %s %s\n", MEMFD_STR, banner, b_suffix);
+	printf("%s %s %s\n", memfd_str, banner, b_suffix);
 
 	fd = mfd_assert_new("kern_memfd_share_dup",
 			    mfd_def_size,
@@ -850,7 +852,7 @@ static void test_share_mmap(char *banner, char *b_suffix)
 	int fd;
 	void *p;
 
-	printf("%s %s %s\n", MEMFD_STR,  banner, b_suffix);
+	printf("%s %s %s\n", memfd_str,  banner, b_suffix);
 
 	fd = mfd_assert_new("kern_memfd_share_mmap",
 			    mfd_def_size,
@@ -884,7 +886,7 @@ static void test_share_open(char *banner, char *b_suffix)
 {
 	int fd, fd2;
 
-	printf("%s %s %s\n", MEMFD_STR, banner, b_suffix);
+	printf("%s %s %s\n", memfd_str, banner, b_suffix);
 
 	fd = mfd_assert_new("kern_memfd_share_open",
 			    mfd_def_size,
@@ -927,7 +929,7 @@ static void test_share_fork(char *banner, char *b_suffix)
 	int fd;
 	pid_t pid;
 
-	printf("%s %s %s\n", MEMFD_STR, banner, b_suffix);
+	printf("%s %s %s\n", memfd_str, banner, b_suffix);
 
 	fd = mfd_assert_new("kern_memfd_share_fork",
 			    mfd_def_size,
@@ -963,7 +965,11 @@ int main(int argc, char **argv)
 			}
 
 			hugetlbfs_test = 1;
+			memfd_str = MEMFD_HUGE_STR;
 			mfd_def_size = hpage_size * 2;
+		} else {
+			printf("Unknown option: %s\n", argv[1]);
+			abort();
 		}
 	}
 
-- 
2.15.0.125.g8f49766d64

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v3 7/9] memfd-test: add 'memfd-hugetlb:' prefix when testing hugetlbfs
@ 2017-11-07 12:27   ` Marc-André Lureau
  0 siblings, 0 replies; 34+ messages in thread
From: Marc-André Lureau @ 2017-11-07 12:27 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: aarcange, hughd, nyc, mike.kravetz, Marc-André Lureau

Suggested-by: Mike Kravetz <mike.kravetz@oracle.com>
Signed-off-by: Marc-AndrA(C) Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
---
 tools/testing/selftests/memfd/memfd_test.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c
index cca957a06525..955d09ee16ca 100644
--- a/tools/testing/selftests/memfd/memfd_test.c
+++ b/tools/testing/selftests/memfd/memfd_test.c
@@ -20,6 +20,7 @@
 #include <unistd.h>
 
 #define MEMFD_STR	"memfd:"
+#define MEMFD_HUGE_STR	"memfd-hugetlb:"
 #define SHARED_FT_STR	"(shared file-table)"
 
 #define MFD_DEF_SIZE 8192
@@ -30,6 +31,7 @@
  */
 static int hugetlbfs_test;
 static size_t mfd_def_size = MFD_DEF_SIZE;
+static const char *memfd_str = MEMFD_STR;
 
 /*
  * Copied from mlock2-tests.c
@@ -606,7 +608,7 @@ static void test_create(void)
 	char buf[2048];
 	int fd;
 
-	printf("%s CREATE\n", MEMFD_STR);
+	printf("%s CREATE\n", memfd_str);
 
 	/* test NULL name */
 	mfd_fail_new(NULL, 0);
@@ -652,7 +654,7 @@ static void test_basic(void)
 {
 	int fd;
 
-	printf("%s BASIC\n", MEMFD_STR);
+	printf("%s BASIC\n", memfd_str);
 
 	fd = mfd_assert_new("kern_memfd_basic",
 			    mfd_def_size,
@@ -704,7 +706,7 @@ static void test_seal_write(void)
 {
 	int fd;
 
-	printf("%s SEAL-WRITE\n", MEMFD_STR);
+	printf("%s SEAL-WRITE\n", memfd_str);
 
 	fd = mfd_assert_new("kern_memfd_seal_write",
 			    mfd_def_size,
@@ -730,7 +732,7 @@ static void test_seal_shrink(void)
 {
 	int fd;
 
-	printf("%s SEAL-SHRINK\n", MEMFD_STR);
+	printf("%s SEAL-SHRINK\n", memfd_str);
 
 	fd = mfd_assert_new("kern_memfd_seal_shrink",
 			    mfd_def_size,
@@ -756,7 +758,7 @@ static void test_seal_grow(void)
 {
 	int fd;
 
-	printf("%s SEAL-GROW\n", MEMFD_STR);
+	printf("%s SEAL-GROW\n", memfd_str);
 
 	fd = mfd_assert_new("kern_memfd_seal_grow",
 			    mfd_def_size,
@@ -782,7 +784,7 @@ static void test_seal_resize(void)
 {
 	int fd;
 
-	printf("%s SEAL-RESIZE\n", MEMFD_STR);
+	printf("%s SEAL-RESIZE\n", memfd_str);
 
 	fd = mfd_assert_new("kern_memfd_seal_resize",
 			    mfd_def_size,
@@ -808,7 +810,7 @@ static void test_share_dup(char *banner, char *b_suffix)
 {
 	int fd, fd2;
 
-	printf("%s %s %s\n", MEMFD_STR, banner, b_suffix);
+	printf("%s %s %s\n", memfd_str, banner, b_suffix);
 
 	fd = mfd_assert_new("kern_memfd_share_dup",
 			    mfd_def_size,
@@ -850,7 +852,7 @@ static void test_share_mmap(char *banner, char *b_suffix)
 	int fd;
 	void *p;
 
-	printf("%s %s %s\n", MEMFD_STR,  banner, b_suffix);
+	printf("%s %s %s\n", memfd_str,  banner, b_suffix);
 
 	fd = mfd_assert_new("kern_memfd_share_mmap",
 			    mfd_def_size,
@@ -884,7 +886,7 @@ static void test_share_open(char *banner, char *b_suffix)
 {
 	int fd, fd2;
 
-	printf("%s %s %s\n", MEMFD_STR, banner, b_suffix);
+	printf("%s %s %s\n", memfd_str, banner, b_suffix);
 
 	fd = mfd_assert_new("kern_memfd_share_open",
 			    mfd_def_size,
@@ -927,7 +929,7 @@ static void test_share_fork(char *banner, char *b_suffix)
 	int fd;
 	pid_t pid;
 
-	printf("%s %s %s\n", MEMFD_STR, banner, b_suffix);
+	printf("%s %s %s\n", memfd_str, banner, b_suffix);
 
 	fd = mfd_assert_new("kern_memfd_share_fork",
 			    mfd_def_size,
@@ -963,7 +965,11 @@ int main(int argc, char **argv)
 			}
 
 			hugetlbfs_test = 1;
+			memfd_str = MEMFD_HUGE_STR;
 			mfd_def_size = hpage_size * 2;
+		} else {
+			printf("Unknown option: %s\n", argv[1]);
+			abort();
 		}
 	}
 
-- 
2.15.0.125.g8f49766d64

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v3 8/9] memfd-test: move common code to a shared unit
  2017-11-07 12:27 ` Marc-André Lureau
@ 2017-11-07 12:27   ` Marc-André Lureau
  -1 siblings, 0 replies; 34+ messages in thread
From: Marc-André Lureau @ 2017-11-07 12:27 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: aarcange, hughd, nyc, mike.kravetz, Marc-André Lureau

The memfd & fuse tests will share more common code in the following
commits to test hugetlb support.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
---
 tools/testing/selftests/memfd/Makefile     |  5 ++++
 tools/testing/selftests/memfd/common.c     | 46 ++++++++++++++++++++++++++++++
 tools/testing/selftests/memfd/common.h     |  9 ++++++
 tools/testing/selftests/memfd/fuse_test.c  |  8 ++----
 tools/testing/selftests/memfd/memfd_test.c | 36 ++---------------------
 5 files changed, 64 insertions(+), 40 deletions(-)
 create mode 100644 tools/testing/selftests/memfd/common.c
 create mode 100644 tools/testing/selftests/memfd/common.h

diff --git a/tools/testing/selftests/memfd/Makefile b/tools/testing/selftests/memfd/Makefile
index 3926a0409dda..a5276a91dfbf 100644
--- a/tools/testing/selftests/memfd/Makefile
+++ b/tools/testing/selftests/memfd/Makefile
@@ -12,3 +12,8 @@ fuse_mnt.o: CFLAGS += $(shell pkg-config fuse --cflags)
 include ../lib.mk
 
 $(OUTPUT)/fuse_mnt: LDLIBS += $(shell pkg-config fuse --libs)
+
+$(OUTPUT)/memfd_test: memfd_test.c common.o
+$(OUTPUT)/fuse_test: fuse_test.c common.o
+
+EXTRA_CLEAN = common.o
diff --git a/tools/testing/selftests/memfd/common.c b/tools/testing/selftests/memfd/common.c
new file mode 100644
index 000000000000..8eb3d75f6e60
--- /dev/null
+++ b/tools/testing/selftests/memfd/common.c
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-2.0
+#define _GNU_SOURCE
+#define __EXPORTED_HEADERS__
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/fcntl.h>
+#include <linux/memfd.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+
+#include "common.h"
+
+int hugetlbfs_test = 0;
+
+/*
+ * Copied from mlock2-tests.c
+ */
+unsigned long default_huge_page_size(void)
+{
+	unsigned long hps = 0;
+	char *line = NULL;
+	size_t linelen = 0;
+	FILE *f = fopen("/proc/meminfo", "r");
+
+	if (!f)
+		return 0;
+	while (getline(&line, &linelen, f) > 0) {
+		if (sscanf(line, "Hugepagesize:       %lu kB", &hps) == 1) {
+			hps <<= 10;
+			break;
+		}
+	}
+
+	free(line);
+	fclose(f);
+	return hps;
+}
+
+int sys_memfd_create(const char *name, unsigned int flags)
+{
+	if (hugetlbfs_test)
+		flags |= MFD_HUGETLB;
+
+	return syscall(__NR_memfd_create, name, flags);
+}
diff --git a/tools/testing/selftests/memfd/common.h b/tools/testing/selftests/memfd/common.h
new file mode 100644
index 000000000000..522d2c630bd8
--- /dev/null
+++ b/tools/testing/selftests/memfd/common.h
@@ -0,0 +1,9 @@
+#ifndef COMMON_H_
+#define COMMON_H_
+
+extern int hugetlbfs_test;
+
+unsigned long default_huge_page_size(void);
+int sys_memfd_create(const char *name, unsigned int flags);
+
+#endif
diff --git a/tools/testing/selftests/memfd/fuse_test.c b/tools/testing/selftests/memfd/fuse_test.c
index 1ccb7a3eb14b..795a25ba8521 100644
--- a/tools/testing/selftests/memfd/fuse_test.c
+++ b/tools/testing/selftests/memfd/fuse_test.c
@@ -33,15 +33,11 @@
 #include <sys/wait.h>
 #include <unistd.h>
 
+#include "common.h"
+
 #define MFD_DEF_SIZE 8192
 #define STACK_SIZE 65536
 
-static int sys_memfd_create(const char *name,
-			    unsigned int flags)
-{
-	return syscall(__NR_memfd_create, name, flags);
-}
-
 static int mfd_assert_new(const char *name, loff_t sz, unsigned int flags)
 {
 	int r, fd;
diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c
index 955d09ee16ca..4c049b6b6985 100644
--- a/tools/testing/selftests/memfd/memfd_test.c
+++ b/tools/testing/selftests/memfd/memfd_test.c
@@ -19,6 +19,8 @@
 #include <sys/wait.h>
 #include <unistd.h>
 
+#include "common.h"
+
 #define MEMFD_STR	"memfd:"
 #define MEMFD_HUGE_STR	"memfd-hugetlb:"
 #define SHARED_FT_STR	"(shared file-table)"
@@ -29,43 +31,9 @@
 /*
  * Default is not to test hugetlbfs
  */
-static int hugetlbfs_test;
 static size_t mfd_def_size = MFD_DEF_SIZE;
 static const char *memfd_str = MEMFD_STR;
 
-/*
- * Copied from mlock2-tests.c
- */
-static unsigned long default_huge_page_size(void)
-{
-	unsigned long hps = 0;
-	char *line = NULL;
-	size_t linelen = 0;
-	FILE *f = fopen("/proc/meminfo", "r");
-
-	if (!f)
-		return 0;
-	while (getline(&line, &linelen, f) > 0) {
-		if (sscanf(line, "Hugepagesize:       %lu kB", &hps) == 1) {
-			hps <<= 10;
-			break;
-		}
-	}
-
-	free(line);
-	fclose(f);
-	return hps;
-}
-
-static int sys_memfd_create(const char *name,
-			    unsigned int flags)
-{
-	if (hugetlbfs_test)
-		flags |= MFD_HUGETLB;
-
-	return syscall(__NR_memfd_create, name, flags);
-}
-
 static int mfd_assert_new(const char *name, loff_t sz, unsigned int flags)
 {
 	int r, fd;
-- 
2.15.0.125.g8f49766d64

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v3 8/9] memfd-test: move common code to a shared unit
@ 2017-11-07 12:27   ` Marc-André Lureau
  0 siblings, 0 replies; 34+ messages in thread
From: Marc-André Lureau @ 2017-11-07 12:27 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: aarcange, hughd, nyc, mike.kravetz, Marc-André Lureau

The memfd & fuse tests will share more common code in the following
commits to test hugetlb support.

Signed-off-by: Marc-AndrA(C) Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
---
 tools/testing/selftests/memfd/Makefile     |  5 ++++
 tools/testing/selftests/memfd/common.c     | 46 ++++++++++++++++++++++++++++++
 tools/testing/selftests/memfd/common.h     |  9 ++++++
 tools/testing/selftests/memfd/fuse_test.c  |  8 ++----
 tools/testing/selftests/memfd/memfd_test.c | 36 ++---------------------
 5 files changed, 64 insertions(+), 40 deletions(-)
 create mode 100644 tools/testing/selftests/memfd/common.c
 create mode 100644 tools/testing/selftests/memfd/common.h

diff --git a/tools/testing/selftests/memfd/Makefile b/tools/testing/selftests/memfd/Makefile
index 3926a0409dda..a5276a91dfbf 100644
--- a/tools/testing/selftests/memfd/Makefile
+++ b/tools/testing/selftests/memfd/Makefile
@@ -12,3 +12,8 @@ fuse_mnt.o: CFLAGS += $(shell pkg-config fuse --cflags)
 include ../lib.mk
 
 $(OUTPUT)/fuse_mnt: LDLIBS += $(shell pkg-config fuse --libs)
+
+$(OUTPUT)/memfd_test: memfd_test.c common.o
+$(OUTPUT)/fuse_test: fuse_test.c common.o
+
+EXTRA_CLEAN = common.o
diff --git a/tools/testing/selftests/memfd/common.c b/tools/testing/selftests/memfd/common.c
new file mode 100644
index 000000000000..8eb3d75f6e60
--- /dev/null
+++ b/tools/testing/selftests/memfd/common.c
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-2.0
+#define _GNU_SOURCE
+#define __EXPORTED_HEADERS__
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/fcntl.h>
+#include <linux/memfd.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+
+#include "common.h"
+
+int hugetlbfs_test = 0;
+
+/*
+ * Copied from mlock2-tests.c
+ */
+unsigned long default_huge_page_size(void)
+{
+	unsigned long hps = 0;
+	char *line = NULL;
+	size_t linelen = 0;
+	FILE *f = fopen("/proc/meminfo", "r");
+
+	if (!f)
+		return 0;
+	while (getline(&line, &linelen, f) > 0) {
+		if (sscanf(line, "Hugepagesize:       %lu kB", &hps) == 1) {
+			hps <<= 10;
+			break;
+		}
+	}
+
+	free(line);
+	fclose(f);
+	return hps;
+}
+
+int sys_memfd_create(const char *name, unsigned int flags)
+{
+	if (hugetlbfs_test)
+		flags |= MFD_HUGETLB;
+
+	return syscall(__NR_memfd_create, name, flags);
+}
diff --git a/tools/testing/selftests/memfd/common.h b/tools/testing/selftests/memfd/common.h
new file mode 100644
index 000000000000..522d2c630bd8
--- /dev/null
+++ b/tools/testing/selftests/memfd/common.h
@@ -0,0 +1,9 @@
+#ifndef COMMON_H_
+#define COMMON_H_
+
+extern int hugetlbfs_test;
+
+unsigned long default_huge_page_size(void);
+int sys_memfd_create(const char *name, unsigned int flags);
+
+#endif
diff --git a/tools/testing/selftests/memfd/fuse_test.c b/tools/testing/selftests/memfd/fuse_test.c
index 1ccb7a3eb14b..795a25ba8521 100644
--- a/tools/testing/selftests/memfd/fuse_test.c
+++ b/tools/testing/selftests/memfd/fuse_test.c
@@ -33,15 +33,11 @@
 #include <sys/wait.h>
 #include <unistd.h>
 
+#include "common.h"
+
 #define MFD_DEF_SIZE 8192
 #define STACK_SIZE 65536
 
-static int sys_memfd_create(const char *name,
-			    unsigned int flags)
-{
-	return syscall(__NR_memfd_create, name, flags);
-}
-
 static int mfd_assert_new(const char *name, loff_t sz, unsigned int flags)
 {
 	int r, fd;
diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c
index 955d09ee16ca..4c049b6b6985 100644
--- a/tools/testing/selftests/memfd/memfd_test.c
+++ b/tools/testing/selftests/memfd/memfd_test.c
@@ -19,6 +19,8 @@
 #include <sys/wait.h>
 #include <unistd.h>
 
+#include "common.h"
+
 #define MEMFD_STR	"memfd:"
 #define MEMFD_HUGE_STR	"memfd-hugetlb:"
 #define SHARED_FT_STR	"(shared file-table)"
@@ -29,43 +31,9 @@
 /*
  * Default is not to test hugetlbfs
  */
-static int hugetlbfs_test;
 static size_t mfd_def_size = MFD_DEF_SIZE;
 static const char *memfd_str = MEMFD_STR;
 
-/*
- * Copied from mlock2-tests.c
- */
-static unsigned long default_huge_page_size(void)
-{
-	unsigned long hps = 0;
-	char *line = NULL;
-	size_t linelen = 0;
-	FILE *f = fopen("/proc/meminfo", "r");
-
-	if (!f)
-		return 0;
-	while (getline(&line, &linelen, f) > 0) {
-		if (sscanf(line, "Hugepagesize:       %lu kB", &hps) == 1) {
-			hps <<= 10;
-			break;
-		}
-	}
-
-	free(line);
-	fclose(f);
-	return hps;
-}
-
-static int sys_memfd_create(const char *name,
-			    unsigned int flags)
-{
-	if (hugetlbfs_test)
-		flags |= MFD_HUGETLB;
-
-	return syscall(__NR_memfd_create, name, flags);
-}
-
 static int mfd_assert_new(const char *name, loff_t sz, unsigned int flags)
 {
 	int r, fd;
-- 
2.15.0.125.g8f49766d64

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v3 9/9] memfd-test: run fuse test on hugetlb backend memory
  2017-11-07 12:27 ` Marc-André Lureau
@ 2017-11-07 12:28   ` Marc-André Lureau
  -1 siblings, 0 replies; 34+ messages in thread
From: Marc-André Lureau @ 2017-11-07 12:28 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: aarcange, hughd, nyc, mike.kravetz, Marc-André Lureau

Suggested-by: Mike Kravetz <mike.kravetz@oracle.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 tools/testing/selftests/memfd/fuse_test.c      | 38 ++++++++++++++++++++------
 tools/testing/selftests/memfd/run_fuse_test.sh |  2 +-
 tools/testing/selftests/memfd/run_tests.sh     |  1 +
 3 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/tools/testing/selftests/memfd/fuse_test.c b/tools/testing/selftests/memfd/fuse_test.c
index 795a25ba8521..b018e835737d 100644
--- a/tools/testing/selftests/memfd/fuse_test.c
+++ b/tools/testing/selftests/memfd/fuse_test.c
@@ -38,6 +38,8 @@
 #define MFD_DEF_SIZE 8192
 #define STACK_SIZE 65536
 
+static size_t mfd_def_size = MFD_DEF_SIZE;
+
 static int mfd_assert_new(const char *name, loff_t sz, unsigned int flags)
 {
 	int r, fd;
@@ -123,7 +125,7 @@ static void *mfd_assert_mmap_shared(int fd)
 	void *p;
 
 	p = mmap(NULL,
-		 MFD_DEF_SIZE,
+		 mfd_def_size,
 		 PROT_READ | PROT_WRITE,
 		 MAP_SHARED,
 		 fd,
@@ -141,7 +143,7 @@ static void *mfd_assert_mmap_private(int fd)
 	void *p;
 
 	p = mmap(NULL,
-		 MFD_DEF_SIZE,
+		 mfd_def_size,
 		 PROT_READ | PROT_WRITE,
 		 MAP_PRIVATE,
 		 fd,
@@ -174,7 +176,7 @@ static int sealing_thread_fn(void *arg)
 	usleep(200000);
 
 	/* unmount mapping before sealing to avoid i_mmap_writable failures */
-	munmap(global_p, MFD_DEF_SIZE);
+	munmap(global_p, mfd_def_size);
 
 	/* Try sealing the global file; expect EBUSY or success. Current
 	 * kernels will never succeed, but in the future, kernels might
@@ -224,7 +226,7 @@ static void join_sealing_thread(pid_t pid)
 
 int main(int argc, char **argv)
 {
-	static const char zero[MFD_DEF_SIZE];
+	char *zero;
 	int fd, mfd, r;
 	void *p;
 	int was_sealed;
@@ -235,6 +237,25 @@ int main(int argc, char **argv)
 		abort();
 	}
 
+	if (argc >= 3) {
+		if (!strcmp(argv[2], "hugetlbfs")) {
+			unsigned long hpage_size = default_huge_page_size();
+
+			if (!hpage_size) {
+				printf("Unable to determine huge page size\n");
+				abort();
+			}
+
+			hugetlbfs_test = 1;
+			mfd_def_size = hpage_size * 2;
+		} else {
+			printf("Unknown option: %s\n", argv[2]);
+			abort();
+		}
+	}
+
+	zero = calloc(sizeof(*zero), mfd_def_size);
+
 	/* open FUSE memfd file for GUP testing */
 	printf("opening: %s\n", argv[1]);
 	fd = open(argv[1], O_RDONLY | O_CLOEXEC);
@@ -245,7 +266,7 @@ int main(int argc, char **argv)
 
 	/* create new memfd-object */
 	mfd = mfd_assert_new("kern_memfd_fuse",
-			     MFD_DEF_SIZE,
+			     mfd_def_size,
 			     MFD_CLOEXEC | MFD_ALLOW_SEALING);
 
 	/* mmap memfd-object for writing */
@@ -264,7 +285,7 @@ int main(int argc, char **argv)
 	 * This guarantees that the receive-buffer is pinned for 1s until the
 	 * data is written into it. The racing ADD_SEALS should thus fail as
 	 * the pages are still pinned. */
-	r = read(fd, p, MFD_DEF_SIZE);
+	r = read(fd, p, mfd_def_size);
 	if (r < 0) {
 		printf("read() failed: %m\n");
 		abort();
@@ -291,10 +312,10 @@ int main(int argc, char **argv)
 	 * enough to avoid any in-flight writes. */
 
 	p = mfd_assert_mmap_private(mfd);
-	if (was_sealed && memcmp(p, zero, MFD_DEF_SIZE)) {
+	if (was_sealed && memcmp(p, zero, mfd_def_size)) {
 		printf("memfd sealed during read() but data not discarded\n");
 		abort();
-	} else if (!was_sealed && !memcmp(p, zero, MFD_DEF_SIZE)) {
+	} else if (!was_sealed && !memcmp(p, zero, mfd_def_size)) {
 		printf("memfd sealed after read() but data discarded\n");
 		abort();
 	}
@@ -303,6 +324,7 @@ int main(int argc, char **argv)
 	close(fd);
 
 	printf("fuse: DONE\n");
+	free(zero);
 
 	return 0;
 }
diff --git a/tools/testing/selftests/memfd/run_fuse_test.sh b/tools/testing/selftests/memfd/run_fuse_test.sh
index 407df68dfe27..22e572e2d66a 100755
--- a/tools/testing/selftests/memfd/run_fuse_test.sh
+++ b/tools/testing/selftests/memfd/run_fuse_test.sh
@@ -10,6 +10,6 @@ set -e
 
 mkdir mnt
 ./fuse_mnt ./mnt
-./fuse_test ./mnt/memfd
+./fuse_test ./mnt/memfd $@
 fusermount -u ./mnt
 rmdir ./mnt
diff --git a/tools/testing/selftests/memfd/run_tests.sh b/tools/testing/selftests/memfd/run_tests.sh
index daabb350697c..c2d41ed81b24 100755
--- a/tools/testing/selftests/memfd/run_tests.sh
+++ b/tools/testing/selftests/memfd/run_tests.sh
@@ -60,6 +60,7 @@ fi
 # Run the hugetlbfs test
 #
 ./memfd_test hugetlbfs
+./run_fuse_test.sh hugetlbfs
 
 #
 # Give back any huge pages allocated for the test
-- 
2.15.0.125.g8f49766d64

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v3 9/9] memfd-test: run fuse test on hugetlb backend memory
@ 2017-11-07 12:28   ` Marc-André Lureau
  0 siblings, 0 replies; 34+ messages in thread
From: Marc-André Lureau @ 2017-11-07 12:28 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: aarcange, hughd, nyc, mike.kravetz, Marc-André Lureau

Suggested-by: Mike Kravetz <mike.kravetz@oracle.com>
Signed-off-by: Marc-AndrA(C) Lureau <marcandre.lureau@redhat.com>
---
 tools/testing/selftests/memfd/fuse_test.c      | 38 ++++++++++++++++++++------
 tools/testing/selftests/memfd/run_fuse_test.sh |  2 +-
 tools/testing/selftests/memfd/run_tests.sh     |  1 +
 3 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/tools/testing/selftests/memfd/fuse_test.c b/tools/testing/selftests/memfd/fuse_test.c
index 795a25ba8521..b018e835737d 100644
--- a/tools/testing/selftests/memfd/fuse_test.c
+++ b/tools/testing/selftests/memfd/fuse_test.c
@@ -38,6 +38,8 @@
 #define MFD_DEF_SIZE 8192
 #define STACK_SIZE 65536
 
+static size_t mfd_def_size = MFD_DEF_SIZE;
+
 static int mfd_assert_new(const char *name, loff_t sz, unsigned int flags)
 {
 	int r, fd;
@@ -123,7 +125,7 @@ static void *mfd_assert_mmap_shared(int fd)
 	void *p;
 
 	p = mmap(NULL,
-		 MFD_DEF_SIZE,
+		 mfd_def_size,
 		 PROT_READ | PROT_WRITE,
 		 MAP_SHARED,
 		 fd,
@@ -141,7 +143,7 @@ static void *mfd_assert_mmap_private(int fd)
 	void *p;
 
 	p = mmap(NULL,
-		 MFD_DEF_SIZE,
+		 mfd_def_size,
 		 PROT_READ | PROT_WRITE,
 		 MAP_PRIVATE,
 		 fd,
@@ -174,7 +176,7 @@ static int sealing_thread_fn(void *arg)
 	usleep(200000);
 
 	/* unmount mapping before sealing to avoid i_mmap_writable failures */
-	munmap(global_p, MFD_DEF_SIZE);
+	munmap(global_p, mfd_def_size);
 
 	/* Try sealing the global file; expect EBUSY or success. Current
 	 * kernels will never succeed, but in the future, kernels might
@@ -224,7 +226,7 @@ static void join_sealing_thread(pid_t pid)
 
 int main(int argc, char **argv)
 {
-	static const char zero[MFD_DEF_SIZE];
+	char *zero;
 	int fd, mfd, r;
 	void *p;
 	int was_sealed;
@@ -235,6 +237,25 @@ int main(int argc, char **argv)
 		abort();
 	}
 
+	if (argc >= 3) {
+		if (!strcmp(argv[2], "hugetlbfs")) {
+			unsigned long hpage_size = default_huge_page_size();
+
+			if (!hpage_size) {
+				printf("Unable to determine huge page size\n");
+				abort();
+			}
+
+			hugetlbfs_test = 1;
+			mfd_def_size = hpage_size * 2;
+		} else {
+			printf("Unknown option: %s\n", argv[2]);
+			abort();
+		}
+	}
+
+	zero = calloc(sizeof(*zero), mfd_def_size);
+
 	/* open FUSE memfd file for GUP testing */
 	printf("opening: %s\n", argv[1]);
 	fd = open(argv[1], O_RDONLY | O_CLOEXEC);
@@ -245,7 +266,7 @@ int main(int argc, char **argv)
 
 	/* create new memfd-object */
 	mfd = mfd_assert_new("kern_memfd_fuse",
-			     MFD_DEF_SIZE,
+			     mfd_def_size,
 			     MFD_CLOEXEC | MFD_ALLOW_SEALING);
 
 	/* mmap memfd-object for writing */
@@ -264,7 +285,7 @@ int main(int argc, char **argv)
 	 * This guarantees that the receive-buffer is pinned for 1s until the
 	 * data is written into it. The racing ADD_SEALS should thus fail as
 	 * the pages are still pinned. */
-	r = read(fd, p, MFD_DEF_SIZE);
+	r = read(fd, p, mfd_def_size);
 	if (r < 0) {
 		printf("read() failed: %m\n");
 		abort();
@@ -291,10 +312,10 @@ int main(int argc, char **argv)
 	 * enough to avoid any in-flight writes. */
 
 	p = mfd_assert_mmap_private(mfd);
-	if (was_sealed && memcmp(p, zero, MFD_DEF_SIZE)) {
+	if (was_sealed && memcmp(p, zero, mfd_def_size)) {
 		printf("memfd sealed during read() but data not discarded\n");
 		abort();
-	} else if (!was_sealed && !memcmp(p, zero, MFD_DEF_SIZE)) {
+	} else if (!was_sealed && !memcmp(p, zero, mfd_def_size)) {
 		printf("memfd sealed after read() but data discarded\n");
 		abort();
 	}
@@ -303,6 +324,7 @@ int main(int argc, char **argv)
 	close(fd);
 
 	printf("fuse: DONE\n");
+	free(zero);
 
 	return 0;
 }
diff --git a/tools/testing/selftests/memfd/run_fuse_test.sh b/tools/testing/selftests/memfd/run_fuse_test.sh
index 407df68dfe27..22e572e2d66a 100755
--- a/tools/testing/selftests/memfd/run_fuse_test.sh
+++ b/tools/testing/selftests/memfd/run_fuse_test.sh
@@ -10,6 +10,6 @@ set -e
 
 mkdir mnt
 ./fuse_mnt ./mnt
-./fuse_test ./mnt/memfd
+./fuse_test ./mnt/memfd $@
 fusermount -u ./mnt
 rmdir ./mnt
diff --git a/tools/testing/selftests/memfd/run_tests.sh b/tools/testing/selftests/memfd/run_tests.sh
index daabb350697c..c2d41ed81b24 100755
--- a/tools/testing/selftests/memfd/run_tests.sh
+++ b/tools/testing/selftests/memfd/run_tests.sh
@@ -60,6 +60,7 @@ fi
 # Run the hugetlbfs test
 #
 ./memfd_test hugetlbfs
+./run_fuse_test.sh hugetlbfs
 
 #
 # Give back any huge pages allocated for the test
-- 
2.15.0.125.g8f49766d64

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 9/9] memfd-test: run fuse test on hugetlb backend memory
  2017-11-07 12:28   ` Marc-André Lureau
@ 2017-11-07 21:35     ` Mike Kravetz
  -1 siblings, 0 replies; 34+ messages in thread
From: Mike Kravetz @ 2017-11-07 21:35 UTC (permalink / raw)
  To: Marc-André Lureau, linux-mm, linux-kernel; +Cc: aarcange, hughd, nyc

On 11/07/2017 04:28 AM, Marc-André Lureau wrote:
> Suggested-by: Mike Kravetz <mike.kravetz@oracle.com>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>

-- 
Mike Kravetz

> ---
>  tools/testing/selftests/memfd/fuse_test.c      | 38 ++++++++++++++++++++------
>  tools/testing/selftests/memfd/run_fuse_test.sh |  2 +-
>  tools/testing/selftests/memfd/run_tests.sh     |  1 +
>  3 files changed, 32 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/testing/selftests/memfd/fuse_test.c b/tools/testing/selftests/memfd/fuse_test.c
> index 795a25ba8521..b018e835737d 100644
> --- a/tools/testing/selftests/memfd/fuse_test.c
> +++ b/tools/testing/selftests/memfd/fuse_test.c
> @@ -38,6 +38,8 @@
>  #define MFD_DEF_SIZE 8192
>  #define STACK_SIZE 65536
>  
> +static size_t mfd_def_size = MFD_DEF_SIZE;
> +
>  static int mfd_assert_new(const char *name, loff_t sz, unsigned int flags)
>  {
>  	int r, fd;
> @@ -123,7 +125,7 @@ static void *mfd_assert_mmap_shared(int fd)
>  	void *p;
>  
>  	p = mmap(NULL,
> -		 MFD_DEF_SIZE,
> +		 mfd_def_size,
>  		 PROT_READ | PROT_WRITE,
>  		 MAP_SHARED,
>  		 fd,
> @@ -141,7 +143,7 @@ static void *mfd_assert_mmap_private(int fd)
>  	void *p;
>  
>  	p = mmap(NULL,
> -		 MFD_DEF_SIZE,
> +		 mfd_def_size,
>  		 PROT_READ | PROT_WRITE,
>  		 MAP_PRIVATE,
>  		 fd,
> @@ -174,7 +176,7 @@ static int sealing_thread_fn(void *arg)
>  	usleep(200000);
>  
>  	/* unmount mapping before sealing to avoid i_mmap_writable failures */
> -	munmap(global_p, MFD_DEF_SIZE);
> +	munmap(global_p, mfd_def_size);
>  
>  	/* Try sealing the global file; expect EBUSY or success. Current
>  	 * kernels will never succeed, but in the future, kernels might
> @@ -224,7 +226,7 @@ static void join_sealing_thread(pid_t pid)
>  
>  int main(int argc, char **argv)
>  {
> -	static const char zero[MFD_DEF_SIZE];
> +	char *zero;
>  	int fd, mfd, r;
>  	void *p;
>  	int was_sealed;
> @@ -235,6 +237,25 @@ int main(int argc, char **argv)
>  		abort();
>  	}
>  
> +	if (argc >= 3) {
> +		if (!strcmp(argv[2], "hugetlbfs")) {
> +			unsigned long hpage_size = default_huge_page_size();
> +
> +			if (!hpage_size) {
> +				printf("Unable to determine huge page size\n");
> +				abort();
> +			}
> +
> +			hugetlbfs_test = 1;
> +			mfd_def_size = hpage_size * 2;
> +		} else {
> +			printf("Unknown option: %s\n", argv[2]);
> +			abort();
> +		}
> +	}
> +
> +	zero = calloc(sizeof(*zero), mfd_def_size);
> +
>  	/* open FUSE memfd file for GUP testing */
>  	printf("opening: %s\n", argv[1]);
>  	fd = open(argv[1], O_RDONLY | O_CLOEXEC);
> @@ -245,7 +266,7 @@ int main(int argc, char **argv)
>  
>  	/* create new memfd-object */
>  	mfd = mfd_assert_new("kern_memfd_fuse",
> -			     MFD_DEF_SIZE,
> +			     mfd_def_size,
>  			     MFD_CLOEXEC | MFD_ALLOW_SEALING);
>  
>  	/* mmap memfd-object for writing */
> @@ -264,7 +285,7 @@ int main(int argc, char **argv)
>  	 * This guarantees that the receive-buffer is pinned for 1s until the
>  	 * data is written into it. The racing ADD_SEALS should thus fail as
>  	 * the pages are still pinned. */
> -	r = read(fd, p, MFD_DEF_SIZE);
> +	r = read(fd, p, mfd_def_size);
>  	if (r < 0) {
>  		printf("read() failed: %m\n");
>  		abort();
> @@ -291,10 +312,10 @@ int main(int argc, char **argv)
>  	 * enough to avoid any in-flight writes. */
>  
>  	p = mfd_assert_mmap_private(mfd);
> -	if (was_sealed && memcmp(p, zero, MFD_DEF_SIZE)) {
> +	if (was_sealed && memcmp(p, zero, mfd_def_size)) {
>  		printf("memfd sealed during read() but data not discarded\n");
>  		abort();
> -	} else if (!was_sealed && !memcmp(p, zero, MFD_DEF_SIZE)) {
> +	} else if (!was_sealed && !memcmp(p, zero, mfd_def_size)) {
>  		printf("memfd sealed after read() but data discarded\n");
>  		abort();
>  	}
> @@ -303,6 +324,7 @@ int main(int argc, char **argv)
>  	close(fd);
>  
>  	printf("fuse: DONE\n");
> +	free(zero);
>  
>  	return 0;
>  }
> diff --git a/tools/testing/selftests/memfd/run_fuse_test.sh b/tools/testing/selftests/memfd/run_fuse_test.sh
> index 407df68dfe27..22e572e2d66a 100755
> --- a/tools/testing/selftests/memfd/run_fuse_test.sh
> +++ b/tools/testing/selftests/memfd/run_fuse_test.sh
> @@ -10,6 +10,6 @@ set -e
>  
>  mkdir mnt
>  ./fuse_mnt ./mnt
> -./fuse_test ./mnt/memfd
> +./fuse_test ./mnt/memfd $@
>  fusermount -u ./mnt
>  rmdir ./mnt
> diff --git a/tools/testing/selftests/memfd/run_tests.sh b/tools/testing/selftests/memfd/run_tests.sh
> index daabb350697c..c2d41ed81b24 100755
> --- a/tools/testing/selftests/memfd/run_tests.sh
> +++ b/tools/testing/selftests/memfd/run_tests.sh
> @@ -60,6 +60,7 @@ fi
>  # Run the hugetlbfs test
>  #
>  ./memfd_test hugetlbfs
> +./run_fuse_test.sh hugetlbfs
>  
>  #
>  # Give back any huge pages allocated for the test
> 

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 9/9] memfd-test: run fuse test on hugetlb backend memory
@ 2017-11-07 21:35     ` Mike Kravetz
  0 siblings, 0 replies; 34+ messages in thread
From: Mike Kravetz @ 2017-11-07 21:35 UTC (permalink / raw)
  To: Marc-André Lureau, linux-mm, linux-kernel; +Cc: aarcange, hughd, nyc

On 11/07/2017 04:28 AM, Marc-AndrA(C) Lureau wrote:
> Suggested-by: Mike Kravetz <mike.kravetz@oracle.com>
> Signed-off-by: Marc-AndrA(C) Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>

-- 
Mike Kravetz

> ---
>  tools/testing/selftests/memfd/fuse_test.c      | 38 ++++++++++++++++++++------
>  tools/testing/selftests/memfd/run_fuse_test.sh |  2 +-
>  tools/testing/selftests/memfd/run_tests.sh     |  1 +
>  3 files changed, 32 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/testing/selftests/memfd/fuse_test.c b/tools/testing/selftests/memfd/fuse_test.c
> index 795a25ba8521..b018e835737d 100644
> --- a/tools/testing/selftests/memfd/fuse_test.c
> +++ b/tools/testing/selftests/memfd/fuse_test.c
> @@ -38,6 +38,8 @@
>  #define MFD_DEF_SIZE 8192
>  #define STACK_SIZE 65536
>  
> +static size_t mfd_def_size = MFD_DEF_SIZE;
> +
>  static int mfd_assert_new(const char *name, loff_t sz, unsigned int flags)
>  {
>  	int r, fd;
> @@ -123,7 +125,7 @@ static void *mfd_assert_mmap_shared(int fd)
>  	void *p;
>  
>  	p = mmap(NULL,
> -		 MFD_DEF_SIZE,
> +		 mfd_def_size,
>  		 PROT_READ | PROT_WRITE,
>  		 MAP_SHARED,
>  		 fd,
> @@ -141,7 +143,7 @@ static void *mfd_assert_mmap_private(int fd)
>  	void *p;
>  
>  	p = mmap(NULL,
> -		 MFD_DEF_SIZE,
> +		 mfd_def_size,
>  		 PROT_READ | PROT_WRITE,
>  		 MAP_PRIVATE,
>  		 fd,
> @@ -174,7 +176,7 @@ static int sealing_thread_fn(void *arg)
>  	usleep(200000);
>  
>  	/* unmount mapping before sealing to avoid i_mmap_writable failures */
> -	munmap(global_p, MFD_DEF_SIZE);
> +	munmap(global_p, mfd_def_size);
>  
>  	/* Try sealing the global file; expect EBUSY or success. Current
>  	 * kernels will never succeed, but in the future, kernels might
> @@ -224,7 +226,7 @@ static void join_sealing_thread(pid_t pid)
>  
>  int main(int argc, char **argv)
>  {
> -	static const char zero[MFD_DEF_SIZE];
> +	char *zero;
>  	int fd, mfd, r;
>  	void *p;
>  	int was_sealed;
> @@ -235,6 +237,25 @@ int main(int argc, char **argv)
>  		abort();
>  	}
>  
> +	if (argc >= 3) {
> +		if (!strcmp(argv[2], "hugetlbfs")) {
> +			unsigned long hpage_size = default_huge_page_size();
> +
> +			if (!hpage_size) {
> +				printf("Unable to determine huge page size\n");
> +				abort();
> +			}
> +
> +			hugetlbfs_test = 1;
> +			mfd_def_size = hpage_size * 2;
> +		} else {
> +			printf("Unknown option: %s\n", argv[2]);
> +			abort();
> +		}
> +	}
> +
> +	zero = calloc(sizeof(*zero), mfd_def_size);
> +
>  	/* open FUSE memfd file for GUP testing */
>  	printf("opening: %s\n", argv[1]);
>  	fd = open(argv[1], O_RDONLY | O_CLOEXEC);
> @@ -245,7 +266,7 @@ int main(int argc, char **argv)
>  
>  	/* create new memfd-object */
>  	mfd = mfd_assert_new("kern_memfd_fuse",
> -			     MFD_DEF_SIZE,
> +			     mfd_def_size,
>  			     MFD_CLOEXEC | MFD_ALLOW_SEALING);
>  
>  	/* mmap memfd-object for writing */
> @@ -264,7 +285,7 @@ int main(int argc, char **argv)
>  	 * This guarantees that the receive-buffer is pinned for 1s until the
>  	 * data is written into it. The racing ADD_SEALS should thus fail as
>  	 * the pages are still pinned. */
> -	r = read(fd, p, MFD_DEF_SIZE);
> +	r = read(fd, p, mfd_def_size);
>  	if (r < 0) {
>  		printf("read() failed: %m\n");
>  		abort();
> @@ -291,10 +312,10 @@ int main(int argc, char **argv)
>  	 * enough to avoid any in-flight writes. */
>  
>  	p = mfd_assert_mmap_private(mfd);
> -	if (was_sealed && memcmp(p, zero, MFD_DEF_SIZE)) {
> +	if (was_sealed && memcmp(p, zero, mfd_def_size)) {
>  		printf("memfd sealed during read() but data not discarded\n");
>  		abort();
> -	} else if (!was_sealed && !memcmp(p, zero, MFD_DEF_SIZE)) {
> +	} else if (!was_sealed && !memcmp(p, zero, mfd_def_size)) {
>  		printf("memfd sealed after read() but data discarded\n");
>  		abort();
>  	}
> @@ -303,6 +324,7 @@ int main(int argc, char **argv)
>  	close(fd);
>  
>  	printf("fuse: DONE\n");
> +	free(zero);
>  
>  	return 0;
>  }
> diff --git a/tools/testing/selftests/memfd/run_fuse_test.sh b/tools/testing/selftests/memfd/run_fuse_test.sh
> index 407df68dfe27..22e572e2d66a 100755
> --- a/tools/testing/selftests/memfd/run_fuse_test.sh
> +++ b/tools/testing/selftests/memfd/run_fuse_test.sh
> @@ -10,6 +10,6 @@ set -e
>  
>  mkdir mnt
>  ./fuse_mnt ./mnt
> -./fuse_test ./mnt/memfd
> +./fuse_test ./mnt/memfd $@
>  fusermount -u ./mnt
>  rmdir ./mnt
> diff --git a/tools/testing/selftests/memfd/run_tests.sh b/tools/testing/selftests/memfd/run_tests.sh
> index daabb350697c..c2d41ed81b24 100755
> --- a/tools/testing/selftests/memfd/run_tests.sh
> +++ b/tools/testing/selftests/memfd/run_tests.sh
> @@ -60,6 +60,7 @@ fi
>  # Run the hugetlbfs test
>  #
>  ./memfd_test hugetlbfs
> +./run_fuse_test.sh hugetlbfs
>  
>  #
>  # Give back any huge pages allocated for the test
> 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 0/9] memfd: add sealing to hugetlb-backed memory
  2017-11-07 12:27 ` Marc-André Lureau
@ 2017-11-15  3:13   ` Mike Kravetz
  -1 siblings, 0 replies; 34+ messages in thread
From: Mike Kravetz @ 2017-11-15  3:13 UTC (permalink / raw)
  To: Marc-André Lureau, linux-mm, linux-kernel
  Cc: aarcange, hughd, nyc, Andrew Morton, Michal Hocko, David Herrmann

+Cc: Andrew, Michal, David

Are there any other comments on this patch series from Marc-André?  Is anything
else needed to move forward?

I have reviewed the patches in the series.  David Herrmann (the original
memfd_create/file sealing author) has also taken a look at the patches.

One outstanding issue is sorting out the config option dependencies.  Although,
IMO this is not a strict requirement for this series.  I have addressed this
issue in a follow on series:
http://lkml.kernel.org/r/20171109014109.21077-1-mike.kravetz@oracle.com

-- 
Mike Kravetz


On 11/07/2017 04:27 AM, Marc-André Lureau wrote:
> Hi,
> 
> Recently, Mike Kravetz added hugetlbfs support to memfd. However, he
> didn't add sealing support. One of the reasons to use memfd is to have
> shared memory sealing when doing IPC or sharing memory with another
> process with some extra safety. qemu uses shared memory & hugetables
> with vhost-user (used by dpdk), so it is reasonable to use memfd
> now instead for convenience and security reasons.
> 
> Thanks!
> 
> v3:
> - do remaining MFD_DEF_SIZE/mfd_def_size substitutions
> - fix missing unistd.h include in common.c
> - tweaked a bit commit message prefixes
> - added reviewed-by tags
> 
> v2:
> - add "memfd-hugetlb:" prefix in memfd-test
> - run fuse test on hugetlb backend memory
> - rename function memfd_file_get_seals() -> memfd_file_seals_ptr()
> - update commit messages
> - added reviewed-by tags
> 
> RFC->v1:
> - split rfc patch, after early review feedback
> - added patch for memfd-test changes
> - fix build with hugetlbfs disabled
> - small code and commit messages improvements
> 
> Marc-André Lureau (9):
>   shmem: unexport shmem_add_seals()/shmem_get_seals()
>   shmem: rename functions that are memfd-related
>   hugetlb: expose hugetlbfs_inode_info in header
>   hugetlb: implement memfd sealing
>   shmem: add sealing support to hugetlb-backed memfd
>   memfd-test: test hugetlbfs sealing
>   memfd-test: add 'memfd-hugetlb:' prefix when testing hugetlbfs
>   memfd-test: move common code to a shared unit
>   memfd-test: run fuse test on hugetlb backend memory
> 
>  fs/fcntl.c                                     |   2 +-
>  fs/hugetlbfs/inode.c                           |  39 +++--
>  include/linux/hugetlb.h                        |  11 ++
>  include/linux/shmem_fs.h                       |   6 +-
>  mm/shmem.c                                     |  59 ++++---
>  tools/testing/selftests/memfd/Makefile         |   5 +
>  tools/testing/selftests/memfd/common.c         |  46 ++++++
>  tools/testing/selftests/memfd/common.h         |   9 ++
>  tools/testing/selftests/memfd/fuse_test.c      |  44 +++--
>  tools/testing/selftests/memfd/memfd_test.c     | 212 ++++---------------------
>  tools/testing/selftests/memfd/run_fuse_test.sh |   2 +-
>  tools/testing/selftests/memfd/run_tests.sh     |   1 +
>  12 files changed, 200 insertions(+), 236 deletions(-)
>  create mode 100644 tools/testing/selftests/memfd/common.c
>  create mode 100644 tools/testing/selftests/memfd/common.h
> 

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 0/9] memfd: add sealing to hugetlb-backed memory
@ 2017-11-15  3:13   ` Mike Kravetz
  0 siblings, 0 replies; 34+ messages in thread
From: Mike Kravetz @ 2017-11-15  3:13 UTC (permalink / raw)
  To: Marc-André Lureau, linux-mm, linux-kernel
  Cc: aarcange, hughd, nyc, Andrew Morton, Michal Hocko, David Herrmann

+Cc: Andrew, Michal, David

Are there any other comments on this patch series from Marc-AndrA(C)?  Is anything
else needed to move forward?

I have reviewed the patches in the series.  David Herrmann (the original
memfd_create/file sealing author) has also taken a look at the patches.

One outstanding issue is sorting out the config option dependencies.  Although,
IMO this is not a strict requirement for this series.  I have addressed this
issue in a follow on series:
http://lkml.kernel.org/r/20171109014109.21077-1-mike.kravetz@oracle.com

-- 
Mike Kravetz


On 11/07/2017 04:27 AM, Marc-AndrA(C) Lureau wrote:
> Hi,
> 
> Recently, Mike Kravetz added hugetlbfs support to memfd. However, he
> didn't add sealing support. One of the reasons to use memfd is to have
> shared memory sealing when doing IPC or sharing memory with another
> process with some extra safety. qemu uses shared memory & hugetables
> with vhost-user (used by dpdk), so it is reasonable to use memfd
> now instead for convenience and security reasons.
> 
> Thanks!
> 
> v3:
> - do remaining MFD_DEF_SIZE/mfd_def_size substitutions
> - fix missing unistd.h include in common.c
> - tweaked a bit commit message prefixes
> - added reviewed-by tags
> 
> v2:
> - add "memfd-hugetlb:" prefix in memfd-test
> - run fuse test on hugetlb backend memory
> - rename function memfd_file_get_seals() -> memfd_file_seals_ptr()
> - update commit messages
> - added reviewed-by tags
> 
> RFC->v1:
> - split rfc patch, after early review feedback
> - added patch for memfd-test changes
> - fix build with hugetlbfs disabled
> - small code and commit messages improvements
> 
> Marc-AndrA(C) Lureau (9):
>   shmem: unexport shmem_add_seals()/shmem_get_seals()
>   shmem: rename functions that are memfd-related
>   hugetlb: expose hugetlbfs_inode_info in header
>   hugetlb: implement memfd sealing
>   shmem: add sealing support to hugetlb-backed memfd
>   memfd-test: test hugetlbfs sealing
>   memfd-test: add 'memfd-hugetlb:' prefix when testing hugetlbfs
>   memfd-test: move common code to a shared unit
>   memfd-test: run fuse test on hugetlb backend memory
> 
>  fs/fcntl.c                                     |   2 +-
>  fs/hugetlbfs/inode.c                           |  39 +++--
>  include/linux/hugetlb.h                        |  11 ++
>  include/linux/shmem_fs.h                       |   6 +-
>  mm/shmem.c                                     |  59 ++++---
>  tools/testing/selftests/memfd/Makefile         |   5 +
>  tools/testing/selftests/memfd/common.c         |  46 ++++++
>  tools/testing/selftests/memfd/common.h         |   9 ++
>  tools/testing/selftests/memfd/fuse_test.c      |  44 +++--
>  tools/testing/selftests/memfd/memfd_test.c     | 212 ++++---------------------
>  tools/testing/selftests/memfd/run_fuse_test.sh |   2 +-
>  tools/testing/selftests/memfd/run_tests.sh     |   1 +
>  12 files changed, 200 insertions(+), 236 deletions(-)
>  create mode 100644 tools/testing/selftests/memfd/common.c
>  create mode 100644 tools/testing/selftests/memfd/common.h
> 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 0/9] memfd: add sealing to hugetlb-backed memory
  2017-11-15  3:13   ` Mike Kravetz
@ 2017-12-20 14:15     ` Marc-André Lureau
  -1 siblings, 0 replies; 34+ messages in thread
From: Marc-André Lureau @ 2017-12-20 14:15 UTC (permalink / raw)
  To: Mike Kravetz
  Cc: linux-mm, open list, Andrea Arcangeli, Hugh Dickins, nyc,
	Andrew Morton, Michal Hocko, David Herrmann

Hi

On Wed, Nov 15, 2017 at 4:13 AM, Mike Kravetz <mike.kravetz@oracle.com> wrote:
> +Cc: Andrew, Michal, David
>
> Are there any other comments on this patch series from Marc-André?  Is anything
> else needed to move forward?
>
> I have reviewed the patches in the series.  David Herrmann (the original
> memfd_create/file sealing author) has also taken a look at the patches.
>
> One outstanding issue is sorting out the config option dependencies.  Although,
> IMO this is not a strict requirement for this series.  I have addressed this
> issue in a follow on series:
> http://lkml.kernel.org/r/20171109014109.21077-1-mike.kravetz@oracle.com

Are we good for the next merge window? Is Hugh Dickins the maintainer
with the final word, and doing the pull request? (sorry, I am not very
familiar with kernel development)

thanks!

>> Hi,
>>
>> Recently, Mike Kravetz added hugetlbfs support to memfd. However, he
>> didn't add sealing support. One of the reasons to use memfd is to have
>> shared memory sealing when doing IPC or sharing memory with another
>> process with some extra safety. qemu uses shared memory & hugetables
>> with vhost-user (used by dpdk), so it is reasonable to use memfd
>> now instead for convenience and security reasons.
>>
>> Thanks!
>>
>> v3:
>> - do remaining MFD_DEF_SIZE/mfd_def_size substitutions
>> - fix missing unistd.h include in common.c
>> - tweaked a bit commit message prefixes
>> - added reviewed-by tags
>>
>> v2:
>> - add "memfd-hugetlb:" prefix in memfd-test
>> - run fuse test on hugetlb backend memory
>> - rename function memfd_file_get_seals() -> memfd_file_seals_ptr()
>> - update commit messages
>> - added reviewed-by tags
>>
>> RFC->v1:
>> - split rfc patch, after early review feedback
>> - added patch for memfd-test changes
>> - fix build with hugetlbfs disabled
>> - small code and commit messages improvements
>>
>> Marc-André Lureau (9):
>>   shmem: unexport shmem_add_seals()/shmem_get_seals()
>>   shmem: rename functions that are memfd-related
>>   hugetlb: expose hugetlbfs_inode_info in header
>>   hugetlb: implement memfd sealing
>>   shmem: add sealing support to hugetlb-backed memfd
>>   memfd-test: test hugetlbfs sealing
>>   memfd-test: add 'memfd-hugetlb:' prefix when testing hugetlbfs
>>   memfd-test: move common code to a shared unit
>>   memfd-test: run fuse test on hugetlb backend memory
>>
>>  fs/fcntl.c                                     |   2 +-
>>  fs/hugetlbfs/inode.c                           |  39 +++--
>>  include/linux/hugetlb.h                        |  11 ++
>>  include/linux/shmem_fs.h                       |   6 +-
>>  mm/shmem.c                                     |  59 ++++---
>>  tools/testing/selftests/memfd/Makefile         |   5 +
>>  tools/testing/selftests/memfd/common.c         |  46 ++++++
>>  tools/testing/selftests/memfd/common.h         |   9 ++
>>  tools/testing/selftests/memfd/fuse_test.c      |  44 +++--
>>  tools/testing/selftests/memfd/memfd_test.c     | 212 ++++---------------------
>>  tools/testing/selftests/memfd/run_fuse_test.sh |   2 +-
>>  tools/testing/selftests/memfd/run_tests.sh     |   1 +
>>  12 files changed, 200 insertions(+), 236 deletions(-)
>>  create mode 100644 tools/testing/selftests/memfd/common.c
>>  create mode 100644 tools/testing/selftests/memfd/common.h
>>



-- 
Marc-André Lureau

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 0/9] memfd: add sealing to hugetlb-backed memory
@ 2017-12-20 14:15     ` Marc-André Lureau
  0 siblings, 0 replies; 34+ messages in thread
From: Marc-André Lureau @ 2017-12-20 14:15 UTC (permalink / raw)
  To: Mike Kravetz
  Cc: linux-mm, open list, Andrea Arcangeli, Hugh Dickins, nyc,
	Andrew Morton, Michal Hocko, David Herrmann

Hi

On Wed, Nov 15, 2017 at 4:13 AM, Mike Kravetz <mike.kravetz@oracle.com> wrote:
> +Cc: Andrew, Michal, David
>
> Are there any other comments on this patch series from Marc-André?  Is anything
> else needed to move forward?
>
> I have reviewed the patches in the series.  David Herrmann (the original
> memfd_create/file sealing author) has also taken a look at the patches.
>
> One outstanding issue is sorting out the config option dependencies.  Although,
> IMO this is not a strict requirement for this series.  I have addressed this
> issue in a follow on series:
> http://lkml.kernel.org/r/20171109014109.21077-1-mike.kravetz@oracle.com

Are we good for the next merge window? Is Hugh Dickins the maintainer
with the final word, and doing the pull request? (sorry, I am not very
familiar with kernel development)

thanks!

>> Hi,
>>
>> Recently, Mike Kravetz added hugetlbfs support to memfd. However, he
>> didn't add sealing support. One of the reasons to use memfd is to have
>> shared memory sealing when doing IPC or sharing memory with another
>> process with some extra safety. qemu uses shared memory & hugetables
>> with vhost-user (used by dpdk), so it is reasonable to use memfd
>> now instead for convenience and security reasons.
>>
>> Thanks!
>>
>> v3:
>> - do remaining MFD_DEF_SIZE/mfd_def_size substitutions
>> - fix missing unistd.h include in common.c
>> - tweaked a bit commit message prefixes
>> - added reviewed-by tags
>>
>> v2:
>> - add "memfd-hugetlb:" prefix in memfd-test
>> - run fuse test on hugetlb backend memory
>> - rename function memfd_file_get_seals() -> memfd_file_seals_ptr()
>> - update commit messages
>> - added reviewed-by tags
>>
>> RFC->v1:
>> - split rfc patch, after early review feedback
>> - added patch for memfd-test changes
>> - fix build with hugetlbfs disabled
>> - small code and commit messages improvements
>>
>> Marc-André Lureau (9):
>>   shmem: unexport shmem_add_seals()/shmem_get_seals()
>>   shmem: rename functions that are memfd-related
>>   hugetlb: expose hugetlbfs_inode_info in header
>>   hugetlb: implement memfd sealing
>>   shmem: add sealing support to hugetlb-backed memfd
>>   memfd-test: test hugetlbfs sealing
>>   memfd-test: add 'memfd-hugetlb:' prefix when testing hugetlbfs
>>   memfd-test: move common code to a shared unit
>>   memfd-test: run fuse test on hugetlb backend memory
>>
>>  fs/fcntl.c                                     |   2 +-
>>  fs/hugetlbfs/inode.c                           |  39 +++--
>>  include/linux/hugetlb.h                        |  11 ++
>>  include/linux/shmem_fs.h                       |   6 +-
>>  mm/shmem.c                                     |  59 ++++---
>>  tools/testing/selftests/memfd/Makefile         |   5 +
>>  tools/testing/selftests/memfd/common.c         |  46 ++++++
>>  tools/testing/selftests/memfd/common.h         |   9 ++
>>  tools/testing/selftests/memfd/fuse_test.c      |  44 +++--
>>  tools/testing/selftests/memfd/memfd_test.c     | 212 ++++---------------------
>>  tools/testing/selftests/memfd/run_fuse_test.sh |   2 +-
>>  tools/testing/selftests/memfd/run_tests.sh     |   1 +
>>  12 files changed, 200 insertions(+), 236 deletions(-)
>>  create mode 100644 tools/testing/selftests/memfd/common.c
>>  create mode 100644 tools/testing/selftests/memfd/common.h
>>



-- 
Marc-André Lureau

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 0/9] memfd: add sealing to hugetlb-backed memory
  2017-12-20 14:15     ` Marc-André Lureau
@ 2017-12-20 15:10       ` Michal Hocko
  -1 siblings, 0 replies; 34+ messages in thread
From: Michal Hocko @ 2017-12-20 15:10 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Mike Kravetz, linux-mm, open list, Andrea Arcangeli,
	Hugh Dickins, nyc, Andrew Morton, David Herrmann

On Wed 20-12-17 15:15:50, Marc-André Lureau wrote:
> Hi
> 
> On Wed, Nov 15, 2017 at 4:13 AM, Mike Kravetz <mike.kravetz@oracle.com> wrote:
> > +Cc: Andrew, Michal, David
> >
> > Are there any other comments on this patch series from Marc-André?  Is anything
> > else needed to move forward?
> >
> > I have reviewed the patches in the series.  David Herrmann (the original
> > memfd_create/file sealing author) has also taken a look at the patches.
> >
> > One outstanding issue is sorting out the config option dependencies.  Although,
> > IMO this is not a strict requirement for this series.  I have addressed this
> > issue in a follow on series:
> > http://lkml.kernel.org/r/20171109014109.21077-1-mike.kravetz@oracle.com
> 
> Are we good for the next merge window? Is Hugh Dickins the maintainer
> with the final word, and doing the pull request? (sorry, I am not very
> familiar with kernel development)

Andrew will pick it up, I assume. I will try to get and review this but
there is way too much going on before holiday.

If Mieke feels sufficiently confident about this then I won't object to
the go ahead.
-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 0/9] memfd: add sealing to hugetlb-backed memory
@ 2017-12-20 15:10       ` Michal Hocko
  0 siblings, 0 replies; 34+ messages in thread
From: Michal Hocko @ 2017-12-20 15:10 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Mike Kravetz, linux-mm, open list, Andrea Arcangeli,
	Hugh Dickins, nyc, Andrew Morton, David Herrmann

On Wed 20-12-17 15:15:50, Marc-Andre Lureau wrote:
> Hi
> 
> On Wed, Nov 15, 2017 at 4:13 AM, Mike Kravetz <mike.kravetz@oracle.com> wrote:
> > +Cc: Andrew, Michal, David
> >
> > Are there any other comments on this patch series from Marc-Andre?  Is anything
> > else needed to move forward?
> >
> > I have reviewed the patches in the series.  David Herrmann (the original
> > memfd_create/file sealing author) has also taken a look at the patches.
> >
> > One outstanding issue is sorting out the config option dependencies.  Although,
> > IMO this is not a strict requirement for this series.  I have addressed this
> > issue in a follow on series:
> > http://lkml.kernel.org/r/20171109014109.21077-1-mike.kravetz@oracle.com
> 
> Are we good for the next merge window? Is Hugh Dickins the maintainer
> with the final word, and doing the pull request? (sorry, I am not very
> familiar with kernel development)

Andrew will pick it up, I assume. I will try to get and review this but
there is way too much going on before holiday.

If Mieke feels sufficiently confident about this then I won't object to
the go ahead.
-- 
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 0/9] memfd: add sealing to hugetlb-backed memory
  2017-12-20 15:10       ` Michal Hocko
@ 2017-12-21  0:26         ` Andrew Morton
  -1 siblings, 0 replies; 34+ messages in thread
From: Andrew Morton @ 2017-12-21  0:26 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Marc-André Lureau, Mike Kravetz, linux-mm, open list,
	Andrea Arcangeli, Hugh Dickins, nyc, David Herrmann

On Wed, 20 Dec 2017 16:10:51 +0100 Michal Hocko <mhocko@kernel.org> wrote:

> On Wed 20-12-17 15:15:50, Marc-André Lureau wrote:
> > Hi
> > 
> > On Wed, Nov 15, 2017 at 4:13 AM, Mike Kravetz <mike.kravetz@oracle.com> wrote:
> > > +Cc: Andrew, Michal, David
> > >
> > > Are there any other comments on this patch series from Marc-André?  Is anything
> > > else needed to move forward?
> > >
> > > I have reviewed the patches in the series.  David Herrmann (the original
> > > memfd_create/file sealing author) has also taken a look at the patches.
> > >
> > > One outstanding issue is sorting out the config option dependencies.  Although,
> > > IMO this is not a strict requirement for this series.  I have addressed this
> > > issue in a follow on series:
> > > http://lkml.kernel.org/r/20171109014109.21077-1-mike.kravetz@oracle.com
> > 
> > Are we good for the next merge window? Is Hugh Dickins the maintainer
> > with the final word, and doing the pull request? (sorry, I am not very
> > familiar with kernel development)
> 
> Andrew will pick it up, I assume. I will try to get and review this but
> there is way too much going on before holiday.

Yup, things are quiet at present.

I'll suck these up for a bit of testing - please let me know if you'd
prefer them to be held back for a cycle (ie: for 4.17-rc1)

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 0/9] memfd: add sealing to hugetlb-backed memory
@ 2017-12-21  0:26         ` Andrew Morton
  0 siblings, 0 replies; 34+ messages in thread
From: Andrew Morton @ 2017-12-21  0:26 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Marc-André Lureau, Mike Kravetz, linux-mm, open list,
	Andrea Arcangeli, Hugh Dickins, nyc, David Herrmann

On Wed, 20 Dec 2017 16:10:51 +0100 Michal Hocko <mhocko@kernel.org> wrote:

> On Wed 20-12-17 15:15:50, Marc-André Lureau wrote:
> > Hi
> > 
> > On Wed, Nov 15, 2017 at 4:13 AM, Mike Kravetz <mike.kravetz@oracle.com> wrote:
> > > +Cc: Andrew, Michal, David
> > >
> > > Are there any other comments on this patch series from Marc-André?  Is anything
> > > else needed to move forward?
> > >
> > > I have reviewed the patches in the series.  David Herrmann (the original
> > > memfd_create/file sealing author) has also taken a look at the patches.
> > >
> > > One outstanding issue is sorting out the config option dependencies.  Although,
> > > IMO this is not a strict requirement for this series.  I have addressed this
> > > issue in a follow on series:
> > > http://lkml.kernel.org/r/20171109014109.21077-1-mike.kravetz@oracle.com
> > 
> > Are we good for the next merge window? Is Hugh Dickins the maintainer
> > with the final word, and doing the pull request? (sorry, I am not very
> > familiar with kernel development)
> 
> Andrew will pick it up, I assume. I will try to get and review this but
> there is way too much going on before holiday.

Yup, things are quiet at present.

I'll suck these up for a bit of testing - please let me know if you'd
prefer them to be held back for a cycle (ie: for 4.17-rc1)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 0/9] memfd: add sealing to hugetlb-backed memory
  2017-12-21  0:26         ` Andrew Morton
@ 2017-12-21  0:40           ` Mike Kravetz
  -1 siblings, 0 replies; 34+ messages in thread
From: Mike Kravetz @ 2017-12-21  0:40 UTC (permalink / raw)
  To: Andrew Morton, Michal Hocko
  Cc: Marc-André Lureau, linux-mm, open list, Andrea Arcangeli,
	Hugh Dickins, nyc, David Herrmann

On 12/20/2017 04:26 PM, Andrew Morton wrote:
> On Wed, 20 Dec 2017 16:10:51 +0100 Michal Hocko <mhocko@kernel.org> wrote:
> 
>> On Wed 20-12-17 15:15:50, Marc-André Lureau wrote:
>>> Hi
>>>
>>> On Wed, Nov 15, 2017 at 4:13 AM, Mike Kravetz <mike.kravetz@oracle.com> wrote:
>>>> +Cc: Andrew, Michal, David
>>>>
>>>> Are there any other comments on this patch series from Marc-André?  Is anything
>>>> else needed to move forward?
>>>>
>>>> I have reviewed the patches in the series.  David Herrmann (the original
>>>> memfd_create/file sealing author) has also taken a look at the patches.
>>>>
>>>> One outstanding issue is sorting out the config option dependencies.  Although,
>>>> IMO this is not a strict requirement for this series.  I have addressed this
>>>> issue in a follow on series:
>>>> http://lkml.kernel.org/r/20171109014109.21077-1-mike.kravetz@oracle.com
>>>
>>> Are we good for the next merge window? Is Hugh Dickins the maintainer
>>> with the final word, and doing the pull request? (sorry, I am not very
>>> familiar with kernel development)
>>
>> Andrew will pick it up, I assume. I will try to get and review this but
>> there is way too much going on before holiday.
> 
> Yup, things are quiet at present.
> 
> I'll suck these up for a bit of testing - please let me know if you'd
> prefer them to be held back for a cycle (ie: for 4.17-rc1)

Thanks Andrew,

As mentioned above there is one issue related to this series that we may
want to address.  It is described in the series at:
http://lkml.kernel.org/r/20171109014109.21077-1-mike.kravetz@oracle.com

I did not get many comments on this series/issue.  If we want to do
something like this, now might be a good time.
-- 
Mike Kravetz

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 0/9] memfd: add sealing to hugetlb-backed memory
@ 2017-12-21  0:40           ` Mike Kravetz
  0 siblings, 0 replies; 34+ messages in thread
From: Mike Kravetz @ 2017-12-21  0:40 UTC (permalink / raw)
  To: Andrew Morton, Michal Hocko
  Cc: Marc-André Lureau, linux-mm, open list, Andrea Arcangeli,
	Hugh Dickins, nyc, David Herrmann

On 12/20/2017 04:26 PM, Andrew Morton wrote:
> On Wed, 20 Dec 2017 16:10:51 +0100 Michal Hocko <mhocko@kernel.org> wrote:
> 
>> On Wed 20-12-17 15:15:50, Marc-AndrA(C) Lureau wrote:
>>> Hi
>>>
>>> On Wed, Nov 15, 2017 at 4:13 AM, Mike Kravetz <mike.kravetz@oracle.com> wrote:
>>>> +Cc: Andrew, Michal, David
>>>>
>>>> Are there any other comments on this patch series from Marc-AndrA(C)?  Is anything
>>>> else needed to move forward?
>>>>
>>>> I have reviewed the patches in the series.  David Herrmann (the original
>>>> memfd_create/file sealing author) has also taken a look at the patches.
>>>>
>>>> One outstanding issue is sorting out the config option dependencies.  Although,
>>>> IMO this is not a strict requirement for this series.  I have addressed this
>>>> issue in a follow on series:
>>>> http://lkml.kernel.org/r/20171109014109.21077-1-mike.kravetz@oracle.com
>>>
>>> Are we good for the next merge window? Is Hugh Dickins the maintainer
>>> with the final word, and doing the pull request? (sorry, I am not very
>>> familiar with kernel development)
>>
>> Andrew will pick it up, I assume. I will try to get and review this but
>> there is way too much going on before holiday.
> 
> Yup, things are quiet at present.
> 
> I'll suck these up for a bit of testing - please let me know if you'd
> prefer them to be held back for a cycle (ie: for 4.17-rc1)

Thanks Andrew,

As mentioned above there is one issue related to this series that we may
want to address.  It is described in the series at:
http://lkml.kernel.org/r/20171109014109.21077-1-mike.kravetz@oracle.com

I did not get many comments on this series/issue.  If we want to do
something like this, now might be a good time.
-- 
Mike Kravetz

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 0/9] memfd: add sealing to hugetlb-backed memory
  2017-12-21  0:40           ` Mike Kravetz
@ 2017-12-22 18:30             ` Marc-André Lureau
  -1 siblings, 0 replies; 34+ messages in thread
From: Marc-André Lureau @ 2017-12-22 18:30 UTC (permalink / raw)
  To: Mike Kravetz
  Cc: Andrew Morton, Michal Hocko, linux-mm, open list,
	Andrea Arcangeli, Hugh Dickins, nyc, David Herrmann

Hi Mike

On Thu, Dec 21, 2017 at 1:40 AM, Mike Kravetz <mike.kravetz@oracle.com> wrote:
> On 12/20/2017 04:26 PM, Andrew Morton wrote:
>> On Wed, 20 Dec 2017 16:10:51 +0100 Michal Hocko <mhocko@kernel.org> wrote:
>>
>>> On Wed 20-12-17 15:15:50, Marc-André Lureau wrote:
>>>> Hi
>>>>
>>>> On Wed, Nov 15, 2017 at 4:13 AM, Mike Kravetz <mike.kravetz@oracle.com> wrote:
>>>>> +Cc: Andrew, Michal, David
>>>>>
>>>>> Are there any other comments on this patch series from Marc-André?  Is anything
>>>>> else needed to move forward?
>>>>>
>>>>> I have reviewed the patches in the series.  David Herrmann (the original
>>>>> memfd_create/file sealing author) has also taken a look at the patches.
>>>>>
>>>>> One outstanding issue is sorting out the config option dependencies.  Although,
>>>>> IMO this is not a strict requirement for this series.  I have addressed this
>>>>> issue in a follow on series:
>>>>> http://lkml.kernel.org/r/20171109014109.21077-1-mike.kravetz@oracle.com
>>>>
>>>> Are we good for the next merge window? Is Hugh Dickins the maintainer
>>>> with the final word, and doing the pull request? (sorry, I am not very
>>>> familiar with kernel development)
>>>
>>> Andrew will pick it up, I assume. I will try to get and review this but
>>> there is way too much going on before holiday.
>>
>> Yup, things are quiet at present.
>>
>> I'll suck these up for a bit of testing - please let me know if you'd
>> prefer them to be held back for a cycle (ie: for 4.17-rc1)
>
> Thanks Andrew,
>
> As mentioned above there is one issue related to this series that we may
> want to address.  It is described in the series at:
> http://lkml.kernel.org/r/20171109014109.21077-1-mike.kravetz@oracle.com
>
> I did not get many comments on this series/issue.  If we want to do
> something like this, now might be a good time.

I am not the best person to say, but I think that series makes a lot
of sense (and looks good to me). However, I don't think we need to
wait for it to get the sealing support added (furthermore, your rfc
series is on top).

Thanks!


-- 
Marc-André Lureau

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 0/9] memfd: add sealing to hugetlb-backed memory
@ 2017-12-22 18:30             ` Marc-André Lureau
  0 siblings, 0 replies; 34+ messages in thread
From: Marc-André Lureau @ 2017-12-22 18:30 UTC (permalink / raw)
  To: Mike Kravetz
  Cc: Andrew Morton, Michal Hocko, linux-mm, open list,
	Andrea Arcangeli, Hugh Dickins, nyc, David Herrmann

Hi Mike

On Thu, Dec 21, 2017 at 1:40 AM, Mike Kravetz <mike.kravetz@oracle.com> wrote:
> On 12/20/2017 04:26 PM, Andrew Morton wrote:
>> On Wed, 20 Dec 2017 16:10:51 +0100 Michal Hocko <mhocko@kernel.org> wrote:
>>
>>> On Wed 20-12-17 15:15:50, Marc-André Lureau wrote:
>>>> Hi
>>>>
>>>> On Wed, Nov 15, 2017 at 4:13 AM, Mike Kravetz <mike.kravetz@oracle.com> wrote:
>>>>> +Cc: Andrew, Michal, David
>>>>>
>>>>> Are there any other comments on this patch series from Marc-André?  Is anything
>>>>> else needed to move forward?
>>>>>
>>>>> I have reviewed the patches in the series.  David Herrmann (the original
>>>>> memfd_create/file sealing author) has also taken a look at the patches.
>>>>>
>>>>> One outstanding issue is sorting out the config option dependencies.  Although,
>>>>> IMO this is not a strict requirement for this series.  I have addressed this
>>>>> issue in a follow on series:
>>>>> http://lkml.kernel.org/r/20171109014109.21077-1-mike.kravetz@oracle.com
>>>>
>>>> Are we good for the next merge window? Is Hugh Dickins the maintainer
>>>> with the final word, and doing the pull request? (sorry, I am not very
>>>> familiar with kernel development)
>>>
>>> Andrew will pick it up, I assume. I will try to get and review this but
>>> there is way too much going on before holiday.
>>
>> Yup, things are quiet at present.
>>
>> I'll suck these up for a bit of testing - please let me know if you'd
>> prefer them to be held back for a cycle (ie: for 4.17-rc1)
>
> Thanks Andrew,
>
> As mentioned above there is one issue related to this series that we may
> want to address.  It is described in the series at:
> http://lkml.kernel.org/r/20171109014109.21077-1-mike.kravetz@oracle.com
>
> I did not get many comments on this series/issue.  If we want to do
> something like this, now might be a good time.

I am not the best person to say, but I think that series makes a lot
of sense (and looks good to me). However, I don't think we need to
wait for it to get the sealing support added (furthermore, your rfc
series is on top).

Thanks!


-- 
Marc-André Lureau

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2017-12-22 18:30 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-07 12:27 [PATCH v3 0/9] memfd: add sealing to hugetlb-backed memory Marc-André Lureau
2017-11-07 12:27 ` Marc-André Lureau
2017-11-07 12:27 ` [PATCH v3 1/9] shmem: unexport shmem_add_seals()/shmem_get_seals() Marc-André Lureau
2017-11-07 12:27   ` Marc-André Lureau
2017-11-07 12:27 ` [PATCH v3 2/9] shmem: rename functions that are memfd-related Marc-André Lureau
2017-11-07 12:27   ` Marc-André Lureau
2017-11-07 12:27 ` [PATCH v3 3/9] hugetlb: expose hugetlbfs_inode_info in header Marc-André Lureau
2017-11-07 12:27   ` Marc-André Lureau
2017-11-07 12:27 ` [PATCH v3 4/9] hugetlb: implement memfd sealing Marc-André Lureau
2017-11-07 12:27   ` Marc-André Lureau
2017-11-07 12:27 ` [PATCH v3 5/9] shmem: add sealing support to hugetlb-backed memfd Marc-André Lureau
2017-11-07 12:27   ` Marc-André Lureau
2017-11-07 12:27 ` [PATCH v3 6/9] memfd-test: test hugetlbfs sealing Marc-André Lureau
2017-11-07 12:27   ` Marc-André Lureau
2017-11-07 12:27 ` [PATCH v3 7/9] memfd-test: add 'memfd-hugetlb:' prefix when testing hugetlbfs Marc-André Lureau
2017-11-07 12:27   ` Marc-André Lureau
2017-11-07 12:27 ` [PATCH v3 8/9] memfd-test: move common code to a shared unit Marc-André Lureau
2017-11-07 12:27   ` Marc-André Lureau
2017-11-07 12:28 ` [PATCH v3 9/9] memfd-test: run fuse test on hugetlb backend memory Marc-André Lureau
2017-11-07 12:28   ` Marc-André Lureau
2017-11-07 21:35   ` Mike Kravetz
2017-11-07 21:35     ` Mike Kravetz
2017-11-15  3:13 ` [PATCH v3 0/9] memfd: add sealing to hugetlb-backed memory Mike Kravetz
2017-11-15  3:13   ` Mike Kravetz
2017-12-20 14:15   ` Marc-André Lureau
2017-12-20 14:15     ` Marc-André Lureau
2017-12-20 15:10     ` Michal Hocko
2017-12-20 15:10       ` Michal Hocko
2017-12-21  0:26       ` Andrew Morton
2017-12-21  0:26         ` Andrew Morton
2017-12-21  0:40         ` Mike Kravetz
2017-12-21  0:40           ` Mike Kravetz
2017-12-22 18:30           ` Marc-André Lureau
2017-12-22 18:30             ` Marc-André Lureau

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.