diff mbox series

[3/3] ptrace,syscall_user_dispatch: add a getter/setter for sud configuration

Message ID 20230118201055.147228-4-gregory.price@memverge.com (mailing list archive)
State New
Headers show
Series Checkpoint Support for Syscall User Dispatch | expand

Commit Message

Gregory Price Jan. 18, 2023, 8:10 p.m. UTC
This patch implements ptrace getter and setter interface for syscall
syscall user dispatch configuration info.

Presently, these settings are write-only via prctl, making it impossible
to implement transparent checkpoint.

This is modeled after a similar interface for SECCOMP, which can have
its configuration dumped by ptrace for software like CRIU.

Signed-off-by: Gregory Price <gregory.price@memverge.com>
---
 .../admin-guide/syscall-user-dispatch.rst     |  5 +-
 include/linux/syscall_user_dispatch.h         | 19 +++++++
 include/uapi/linux/ptrace.h                   | 10 ++++
 kernel/entry/syscall_user_dispatch.c          | 49 +++++++++++++++++++
 kernel/ptrace.c                               |  9 ++++
 5 files changed, 91 insertions(+), 1 deletion(-)

Comments

kernel test robot Jan. 18, 2023, 11:43 p.m. UTC | #1
Hi Gregory,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v6.2-rc4 next-20230118]
[cannot apply to tip/core/entry]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Gregory-Price/ptrace-syscall_user_dispatch-Implement-Syscall-User-Dispatch-Suspension/20230119-041259
patch link:    https://lore.kernel.org/r/20230118201055.147228-4-gregory.price%40memverge.com
patch subject: [PATCH 3/3] ptrace,syscall_user_dispatch: add a getter/setter for sud configuration
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230119/202301190722.ouyr6mLZ-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/bd6833b41ed48c444c09346f695efe229deec2e9
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Gregory-Price/ptrace-syscall_user_dispatch-Implement-Syscall-User-Dispatch-Suspension/20230119-041259
        git checkout bd6833b41ed48c444c09346f695efe229deec2e9
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k prepare

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from include/linux/sched.h:31,
                    from arch/m68k/kernel/asm-offsets.c:15:
>> include/linux/syscall_user_dispatch.h:45:5: warning: no previous prototype for 'syscall_user_dispatch_get_config' [-Wmissing-prototypes]
      45 | int syscall_user_dispatch_get_config(struct task_struct *task, unsigned long size,
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/syscall_user_dispatch.h:51:5: warning: no previous prototype for 'syscall_user_dispatch_set_config' [-Wmissing-prototypes]
      51 | int syscall_user_dispatch_set_config(struct task_struct *task, unsigned long size,
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
   scripts/genksyms/parse.y: warning: 9 shift/reduce conflicts [-Wconflicts-sr]
   scripts/genksyms/parse.y: warning: 5 reduce/reduce conflicts [-Wconflicts-rr]
   scripts/genksyms/parse.y: note: rerun with option '-Wcounterexamples' to generate conflict counterexamples
   In file included from include/linux/sched.h:31,
                    from arch/m68k/kernel/asm-offsets.c:15:
>> include/linux/syscall_user_dispatch.h:45:5: warning: no previous prototype for 'syscall_user_dispatch_get_config' [-Wmissing-prototypes]
      45 | int syscall_user_dispatch_get_config(struct task_struct *task, unsigned long size,
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/syscall_user_dispatch.h:51:5: warning: no previous prototype for 'syscall_user_dispatch_set_config' [-Wmissing-prototypes]
      51 | int syscall_user_dispatch_set_config(struct task_struct *task, unsigned long size,
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/syscall_user_dispatch_get_config +45 include/linux/syscall_user_dispatch.h

    44	
  > 45	int syscall_user_dispatch_get_config(struct task_struct *task, unsigned long size,
    46		void __user *data)
    47	{
    48		return -EINVAL;
    49	}
    50	
  > 51	int syscall_user_dispatch_set_config(struct task_struct *task, unsigned long size,
    52		void __user *data)
    53	{
    54		return -EINVAL;
    55	}
    56
kernel test robot Jan. 19, 2023, 1:06 a.m. UTC | #2
Hi Gregory,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.2-rc4 next-20230118]
[cannot apply to tip/core/entry]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Gregory-Price/ptrace-syscall_user_dispatch-Implement-Syscall-User-Dispatch-Suspension/20230119-041259
patch link:    https://lore.kernel.org/r/20230118201055.147228-4-gregory.price%40memverge.com
patch subject: [PATCH 3/3] ptrace,syscall_user_dispatch: add a getter/setter for sud configuration
config: sparc-buildonly-randconfig-r005-20230118 (https://download.01.org/0day-ci/archive/20230119/202301190817.vjgEwo3J-lkp@intel.com/config)
compiler: sparc64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/bd6833b41ed48c444c09346f695efe229deec2e9
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Gregory-Price/ptrace-syscall_user_dispatch-Implement-Syscall-User-Dispatch-Suspension/20230119-041259
        git checkout bd6833b41ed48c444c09346f695efe229deec2e9
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sparc olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sparc SHELL=/bin/bash arch/sparc/mm/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from include/linux/sched.h:31,
                    from include/linux/mm.h:28,
                    from arch/sparc/mm/tlb.c:9:
>> include/linux/syscall_user_dispatch.h:45:5: error: no previous prototype for 'syscall_user_dispatch_get_config' [-Werror=missing-prototypes]
      45 | int syscall_user_dispatch_get_config(struct task_struct *task, unsigned long size,
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/syscall_user_dispatch.h:51:5: error: no previous prototype for 'syscall_user_dispatch_set_config' [-Werror=missing-prototypes]
      51 | int syscall_user_dispatch_set_config(struct task_struct *task, unsigned long size,
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   cc1: all warnings being treated as errors
--
   In file included from include/linux/sched.h:31,
                    from arch/sparc/mm/init_64.c:11:
>> include/linux/syscall_user_dispatch.h:45:5: error: no previous prototype for 'syscall_user_dispatch_get_config' [-Werror=missing-prototypes]
      45 | int syscall_user_dispatch_get_config(struct task_struct *task, unsigned long size,
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/syscall_user_dispatch.h:51:5: error: no previous prototype for 'syscall_user_dispatch_set_config' [-Werror=missing-prototypes]
      51 | int syscall_user_dispatch_set_config(struct task_struct *task, unsigned long size,
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/sparc/mm/init_64.c: In function 'arch_hugetlb_valid_size':
   arch/sparc/mm/init_64.c:355:24: error: variable 'hv_pgsz_idx' set but not used [-Werror=unused-but-set-variable]
     355 |         unsigned short hv_pgsz_idx;
         |                        ^~~~~~~~~~~
   arch/sparc/mm/init_64.c: At top level:
   arch/sparc/mm/init_64.c:2630:6: error: no previous prototype for 'vmemmap_free' [-Werror=missing-prototypes]
    2630 | void vmemmap_free(unsigned long start, unsigned long end,
         |      ^~~~~~~~~~~~
   cc1: all warnings being treated as errors


vim +/syscall_user_dispatch_get_config +45 include/linux/syscall_user_dispatch.h

    44	
  > 45	int syscall_user_dispatch_get_config(struct task_struct *task, unsigned long size,
    46		void __user *data)
    47	{
    48		return -EINVAL;
    49	}
    50	
  > 51	int syscall_user_dispatch_set_config(struct task_struct *task, unsigned long size,
    52		void __user *data)
    53	{
    54		return -EINVAL;
    55	}
    56
kernel test robot Jan. 19, 2023, 1:16 a.m. UTC | #3
Hi Gregory,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.2-rc4 next-20230118]
[cannot apply to tip/core/entry]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Gregory-Price/ptrace-syscall_user_dispatch-Implement-Syscall-User-Dispatch-Suspension/20230119-041259
patch link:    https://lore.kernel.org/r/20230118201055.147228-4-gregory.price%40memverge.com
patch subject: [PATCH 3/3] ptrace,syscall_user_dispatch: add a getter/setter for sud configuration
config: um-i386_defconfig (https://download.01.org/0day-ci/archive/20230119/202301190907.YBfaBhHB-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/bd6833b41ed48c444c09346f695efe229deec2e9
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Gregory-Price/ptrace-syscall_user_dispatch-Implement-Syscall-User-Dispatch-Suspension/20230119-041259
        git checkout bd6833b41ed48c444c09346f695efe229deec2e9
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=um SUBARCH=i386 olddefconfig
        make W=1 O=build_dir ARCH=um SUBARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   ld: fs/isofs/inode.o: in function `syscall_user_dispatch_get_config':
>> include/linux/syscall_user_dispatch.h:49: multiple definition of `syscall_user_dispatch_get_config'; fs/isofs/namei.o:include/linux/syscall_user_dispatch.h:49: first defined here
   ld: fs/isofs/inode.o: in function `syscall_user_dispatch_set_config':
>> include/linux/syscall_user_dispatch.h:49: multiple definition of `syscall_user_dispatch_set_config'; fs/isofs/namei.o:include/linux/syscall_user_dispatch.h:49: first defined here
   ld: fs/isofs/dir.o: in function `syscall_user_dispatch_get_config':
>> include/linux/syscall_user_dispatch.h:49: multiple definition of `syscall_user_dispatch_get_config'; fs/isofs/namei.o:include/linux/syscall_user_dispatch.h:49: first defined here
   ld: fs/isofs/dir.o: in function `syscall_user_dispatch_set_config':
>> include/linux/syscall_user_dispatch.h:49: multiple definition of `syscall_user_dispatch_set_config'; fs/isofs/namei.o:include/linux/syscall_user_dispatch.h:49: first defined here
   ld: fs/isofs/util.o: in function `syscall_user_dispatch_get_config':
   fs/isofs/util.c:49: multiple definition of `syscall_user_dispatch_get_config'; fs/isofs/namei.o:include/linux/syscall_user_dispatch.h:49: first defined here
   ld: fs/isofs/util.o: in function `syscall_user_dispatch_set_config':
   fs/isofs/util.c:49: multiple definition of `syscall_user_dispatch_set_config'; fs/isofs/namei.o:include/linux/syscall_user_dispatch.h:49: first defined here
   ld: fs/isofs/rock.o: in function `syscall_user_dispatch_get_config':
>> include/linux/syscall_user_dispatch.h:49: multiple definition of `syscall_user_dispatch_get_config'; fs/isofs/namei.o:include/linux/syscall_user_dispatch.h:49: first defined here
   ld: fs/isofs/rock.o: in function `syscall_user_dispatch_set_config':
>> include/linux/syscall_user_dispatch.h:49: multiple definition of `syscall_user_dispatch_set_config'; fs/isofs/namei.o:include/linux/syscall_user_dispatch.h:49: first defined here
   ld: fs/isofs/export.o: in function `syscall_user_dispatch_get_config':
>> include/linux/syscall_user_dispatch.h:49: multiple definition of `syscall_user_dispatch_get_config'; fs/isofs/namei.o:include/linux/syscall_user_dispatch.h:49: first defined here
   ld: fs/isofs/export.o: in function `syscall_user_dispatch_set_config':
>> include/linux/syscall_user_dispatch.h:49: multiple definition of `syscall_user_dispatch_set_config'; fs/isofs/namei.o:include/linux/syscall_user_dispatch.h:49: first defined here
   ld: fs/isofs/joliet.o: in function `syscall_user_dispatch_get_config':
   fs/isofs/joliet.c:49: multiple definition of `syscall_user_dispatch_get_config'; fs/isofs/namei.o:include/linux/syscall_user_dispatch.h:49: first defined here
   ld: fs/isofs/joliet.o: in function `syscall_user_dispatch_set_config':
   fs/isofs/joliet.c:49: multiple definition of `syscall_user_dispatch_set_config'; fs/isofs/namei.o:include/linux/syscall_user_dispatch.h:49: first defined here
--
   ld: fs/autofs/inode.o: in function `syscall_user_dispatch_get_config':
>> include/linux/syscall_user_dispatch.h:49: multiple definition of `syscall_user_dispatch_get_config'; fs/autofs/init.o:include/linux/syscall_user_dispatch.h:49: first defined here
   ld: fs/autofs/inode.o: in function `syscall_user_dispatch_set_config':
>> include/linux/syscall_user_dispatch.h:49: multiple definition of `syscall_user_dispatch_set_config'; fs/autofs/init.o:include/linux/syscall_user_dispatch.h:49: first defined here
   ld: fs/autofs/root.o: in function `syscall_user_dispatch_get_config':
>> include/linux/syscall_user_dispatch.h:49: multiple definition of `syscall_user_dispatch_get_config'; fs/autofs/init.o:include/linux/syscall_user_dispatch.h:49: first defined here
   ld: fs/autofs/root.o: in function `syscall_user_dispatch_set_config':
>> include/linux/syscall_user_dispatch.h:49: multiple definition of `syscall_user_dispatch_set_config'; fs/autofs/init.o:include/linux/syscall_user_dispatch.h:49: first defined here
   ld: fs/autofs/symlink.o: in function `syscall_user_dispatch_get_config':
>> include/linux/syscall_user_dispatch.h:49: multiple definition of `syscall_user_dispatch_get_config'; fs/autofs/init.o:include/linux/syscall_user_dispatch.h:49: first defined here
   ld: fs/autofs/symlink.o: in function `syscall_user_dispatch_set_config':
>> include/linux/syscall_user_dispatch.h:49: multiple definition of `syscall_user_dispatch_set_config'; fs/autofs/init.o:include/linux/syscall_user_dispatch.h:49: first defined here
   ld: fs/autofs/waitq.o: in function `syscall_user_dispatch_get_config':
>> include/linux/syscall_user_dispatch.h:49: multiple definition of `syscall_user_dispatch_get_config'; fs/autofs/init.o:include/linux/syscall_user_dispatch.h:49: first defined here
   ld: fs/autofs/waitq.o: in function `syscall_user_dispatch_set_config':
>> include/linux/syscall_user_dispatch.h:49: multiple definition of `syscall_user_dispatch_set_config'; fs/autofs/init.o:include/linux/syscall_user_dispatch.h:49: first defined here
   ld: fs/autofs/expire.o: in function `syscall_user_dispatch_get_config':
>> include/linux/syscall_user_dispatch.h:49: multiple definition of `syscall_user_dispatch_get_config'; fs/autofs/init.o:include/linux/syscall_user_dispatch.h:49: first defined here
   ld: fs/autofs/expire.o: in function `syscall_user_dispatch_set_config':
>> include/linux/syscall_user_dispatch.h:49: multiple definition of `syscall_user_dispatch_set_config'; fs/autofs/init.o:include/linux/syscall_user_dispatch.h:49: first defined here
   ld: fs/autofs/dev-ioctl.o: in function `syscall_user_dispatch_get_config':
>> include/linux/syscall_user_dispatch.h:49: multiple definition of `syscall_user_dispatch_get_config'; fs/autofs/init.o:include/linux/syscall_user_dispatch.h:49: first defined here
   ld: fs/autofs/dev-ioctl.o: in function `syscall_user_dispatch_set_config':
>> include/linux/syscall_user_dispatch.h:49: multiple definition of `syscall_user_dispatch_set_config'; fs/autofs/init.o:include/linux/syscall_user_dispatch.h:49: first defined here


vim +49 include/linux/syscall_user_dispatch.h

    44	
    45	int syscall_user_dispatch_get_config(struct task_struct *task, unsigned long size,
    46		void __user *data)
    47	{
    48		return -EINVAL;
  > 49	}
    50
kernel test robot Jan. 19, 2023, 2:39 a.m. UTC | #4
Hi Gregory,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v6.2-rc4 next-20230118]
[cannot apply to tip/core/entry]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Gregory-Price/ptrace-syscall_user_dispatch-Implement-Syscall-User-Dispatch-Suspension/20230119-041259
patch link:    https://lore.kernel.org/r/20230118201055.147228-4-gregory.price%40memverge.com
patch subject: [PATCH 3/3] ptrace,syscall_user_dispatch: add a getter/setter for sud configuration
config: x86_64-randconfig-s022 (https://download.01.org/0day-ci/archive/20230119/202301191010.U5yAKr05-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.4-39-gce1a6720-dirty
        # https://github.com/intel-lab-lkp/linux/commit/bd6833b41ed48c444c09346f695efe229deec2e9
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Gregory-Price/ptrace-syscall_user_dispatch-Implement-Syscall-User-Dispatch-Suspension/20230119-041259
        git checkout bd6833b41ed48c444c09346f695efe229deec2e9
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=x86_64 olddefconfig
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=x86_64 SHELL=/bin/bash kernel/entry/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

sparse warnings: (new ones prefixed by >>)
>> kernel/entry/syscall_user_dispatch.c:128:33: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected signed char [usertype] *[assigned] selector @@     got char [noderef] __user *selector @@
   kernel/entry/syscall_user_dispatch.c:128:33: sparse:     expected signed char [usertype] *[assigned] selector
   kernel/entry/syscall_user_dispatch.c:128:33: sparse:     got char [noderef] __user *selector
>> kernel/entry/syscall_user_dispatch.c:156:31: sparse: sparse: incorrect type in argument 4 (different address spaces) @@     expected char [noderef] __user *selector @@     got signed char [usertype] *[addressable] selector @@
   kernel/entry/syscall_user_dispatch.c:156:31: sparse:     expected char [noderef] __user *selector
   kernel/entry/syscall_user_dispatch.c:156:31: sparse:     got signed char [usertype] *[addressable] selector

vim +128 kernel/entry/syscall_user_dispatch.c

   114	
   115	int syscall_user_dispatch_get_config(struct task_struct *task, unsigned long size,
   116			void __user *data)
   117	{
   118		struct syscall_user_dispatch *sd = &task->syscall_dispatch;
   119		struct syscall_user_dispatch_config config;
   120	
   121		if (size != sizeof(struct syscall_user_dispatch_config))
   122			return -EINVAL;
   123	
   124		if (sd->selector) {
   125			config.mode = PR_SYS_DISPATCH_ON;
   126			config.offset = sd->offset;
   127			config.len = sd->len;
 > 128			config.selector = sd->selector;
   129			config.on_dispatch = sd->on_dispatch;
   130		} else {
   131			config.mode = PR_SYS_DISPATCH_OFF;
   132			config.offset = 0;
   133			config.len = 0;
   134			config.selector = NULL;
   135			config.on_dispatch = false;
   136		}
   137		if (copy_to_user(data, &config, sizeof(config)))
   138			return -EFAULT;
   139	
   140		return 0;
   141	}
   142	
   143	int syscall_user_dispatch_set_config(struct task_struct *task, unsigned long size,
   144			void __user *data)
   145	{
   146		struct syscall_user_dispatch_config config;
   147		int ret;
   148	
   149		if (size != sizeof(struct syscall_user_dispatch_config))
   150			return -EINVAL;
   151	
   152		if (copy_from_user(&config, data, sizeof(config)))
   153			return -EFAULT;
   154	
   155		ret = set_syscall_user_dispatch(config.mode, config.offset, config.len,
 > 156				config.selector);
diff mbox series

Patch

diff --git a/Documentation/admin-guide/syscall-user-dispatch.rst b/Documentation/admin-guide/syscall-user-dispatch.rst
index 60314953c728..a23ae21a1d5b 100644
--- a/Documentation/admin-guide/syscall-user-dispatch.rst
+++ b/Documentation/admin-guide/syscall-user-dispatch.rst
@@ -43,7 +43,10 @@  doesn't rely on any of the syscall ABI to make the filtering.  It uses
 only the syscall dispatcher address and the userspace key.
 
 As the ABI of these intercepted syscalls is unknown to Linux, these
-syscalls are not instrumentable via ptrace or the syscall tracepoints.
+syscalls are not instrumentable via ptrace or the syscall tracepoints,
+however an interfaces to suspend, checkpoint, and restore syscall user
+dispatch configuration has been added to ptrace to assist userland
+checkpoint/restart software.
 
 Interface
 ---------
diff --git a/include/linux/syscall_user_dispatch.h b/include/linux/syscall_user_dispatch.h
index a0ae443fb7df..dbf384b7a26e 100644
--- a/include/linux/syscall_user_dispatch.h
+++ b/include/linux/syscall_user_dispatch.h
@@ -22,6 +22,13 @@  int set_syscall_user_dispatch(unsigned long mode, unsigned long offset,
 #define clear_syscall_work_syscall_user_dispatch(tsk) \
 	clear_task_syscall_work(tsk, SYSCALL_USER_DISPATCH)
 
+int syscall_user_dispatch_get_config(struct task_struct *task, unsigned long size,
+	void __user *data);
+
+int syscall_user_dispatch_set_config(struct task_struct *task, unsigned long size,
+	void __user *data);
+
+
 #else
 struct syscall_user_dispatch {};
 
@@ -35,6 +42,18 @@  static inline void clear_syscall_work_syscall_user_dispatch(struct task_struct *
 {
 }
 
+int syscall_user_dispatch_get_config(struct task_struct *task, unsigned long size,
+	void __user *data)
+{
+	return -EINVAL;
+}
+
+int syscall_user_dispatch_set_config(struct task_struct *task, unsigned long size,
+	void __user *data)
+{
+	return -EINVAL;
+}
+
 #endif /* CONFIG_GENERIC_ENTRY */
 
 #endif /* _SYSCALL_USER_DISPATCH_H */
diff --git a/include/uapi/linux/ptrace.h b/include/uapi/linux/ptrace.h
index ba9e3f19a22c..8b93c78189b5 100644
--- a/include/uapi/linux/ptrace.h
+++ b/include/uapi/linux/ptrace.h
@@ -112,6 +112,16 @@  struct ptrace_rseq_configuration {
 	__u32 pad;
 };
 
+#define PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG 0x4210
+#define PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG 0x4211
+struct syscall_user_dispatch_config {
+	__u64 mode;
+	__s8 *selector;
+	__u64 offset;
+	__u64 len;
+	__u8 on_dispatch;
+};
+
 /*
  * These values are stored in task->ptrace_message
  * by ptrace_stop to describe the current syscall-stop.
diff --git a/kernel/entry/syscall_user_dispatch.c b/kernel/entry/syscall_user_dispatch.c
index 7607f4598dd8..ae4f9a4b96ac 100644
--- a/kernel/entry/syscall_user_dispatch.c
+++ b/kernel/entry/syscall_user_dispatch.c
@@ -111,3 +111,52 @@  int set_syscall_user_dispatch(unsigned long mode, unsigned long offset,
 
 	return 0;
 }
+
+int syscall_user_dispatch_get_config(struct task_struct *task, unsigned long size,
+		void __user *data)
+{
+	struct syscall_user_dispatch *sd = &task->syscall_dispatch;
+	struct syscall_user_dispatch_config config;
+
+	if (size != sizeof(struct syscall_user_dispatch_config))
+		return -EINVAL;
+
+	if (sd->selector) {
+		config.mode = PR_SYS_DISPATCH_ON;
+		config.offset = sd->offset;
+		config.len = sd->len;
+		config.selector = sd->selector;
+		config.on_dispatch = sd->on_dispatch;
+	} else {
+		config.mode = PR_SYS_DISPATCH_OFF;
+		config.offset = 0;
+		config.len = 0;
+		config.selector = NULL;
+		config.on_dispatch = false;
+	}
+	if (copy_to_user(data, &config, sizeof(config)))
+		return -EFAULT;
+
+	return 0;
+}
+
+int syscall_user_dispatch_set_config(struct task_struct *task, unsigned long size,
+		void __user *data)
+{
+	struct syscall_user_dispatch_config config;
+	int ret;
+
+	if (size != sizeof(struct syscall_user_dispatch_config))
+		return -EINVAL;
+
+	if (copy_from_user(&config, data, sizeof(config)))
+		return -EFAULT;
+
+	ret = set_syscall_user_dispatch(config.mode, config.offset, config.len,
+			config.selector);
+	if (ret)
+		return ret;
+
+	task->syscall_dispatch.on_dispatch = config.on_dispatch;
+	return 0;
+}
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index a6ad815bd4be..0b210a1450e7 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -32,6 +32,7 @@ 
 #include <linux/compat.h>
 #include <linux/sched/signal.h>
 #include <linux/minmax.h>
+#include <linux/syscall_user_dispatch.h>
 
 #include <asm/syscall.h>	/* for syscall_get_* */
 
@@ -1264,6 +1265,14 @@  int ptrace_request(struct task_struct *child, long request,
 		break;
 #endif
 
+	case PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG:
+		ret = syscall_user_dispatch_set_config(child, addr, datavp);
+		break;
+
+	case PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG:
+		ret = syscall_user_dispatch_get_config(child, addr, datavp);
+		break;
+
 	default:
 		break;
 	}