mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 13:58:34 +00:00
criu: shstk: add VMA_AREA_SHSTK flag
The shadow stack VMAs require special care because they can only be created and populated using special system calls. Add VMA_AREA_SHSTK flag and set it for VMAs that are marked as "ss" in /proc/pid/smaps Signed-off-by: Mike Rapoport (IBM) <rppt@kernel.org>
This commit is contained in:
committed by
Andrei Vagin
parent
a09a0eb081
commit
dbab276601
@@ -35,6 +35,8 @@
|
|||||||
* - stack
|
* - stack
|
||||||
* the memory area is used in application stack so we
|
* the memory area is used in application stack so we
|
||||||
* should be careful about guard page here
|
* should be careful about guard page here
|
||||||
|
* - shadow stack
|
||||||
|
* the memory area is used by shadow stack
|
||||||
* - vsyscall
|
* - vsyscall
|
||||||
* special memory area injected into the task memory
|
* special memory area injected into the task memory
|
||||||
* space by the kernel itself, represent virtual syscall
|
* space by the kernel itself, represent virtual syscall
|
||||||
@@ -84,6 +86,7 @@
|
|||||||
#define VMA_AREA_VVAR (1 << 12)
|
#define VMA_AREA_VVAR (1 << 12)
|
||||||
#define VMA_AREA_AIORING (1 << 13)
|
#define VMA_AREA_AIORING (1 << 13)
|
||||||
#define VMA_AREA_MEMFD (1 << 14)
|
#define VMA_AREA_MEMFD (1 << 14)
|
||||||
|
#define VMA_AREA_SHSTK (1 << 15)
|
||||||
|
|
||||||
#define VMA_EXT_PLUGIN (1 << 27)
|
#define VMA_EXT_PLUGIN (1 << 27)
|
||||||
#define VMA_CLOSE (1 << 28)
|
#define VMA_CLOSE (1 << 28)
|
||||||
|
@@ -118,7 +118,8 @@ bool handle_vma_plugin(int *fd, struct stat *stat)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __parse_vmflags(char *buf, u32 *flags, u64 *madv, int *io_pf)
|
static void __parse_vmflags(char *buf, u32 *flags, u64 *madv, int *io_pf,
|
||||||
|
int *shstk)
|
||||||
{
|
{
|
||||||
char *tok;
|
char *tok;
|
||||||
|
|
||||||
@@ -162,6 +163,9 @@ static void __parse_vmflags(char *buf, u32 *flags, u64 *madv, int *io_pf)
|
|||||||
if (_vmflag_match(tok, "io") || _vmflag_match(tok, "pf"))
|
if (_vmflag_match(tok, "io") || _vmflag_match(tok, "pf"))
|
||||||
*io_pf = 1;
|
*io_pf = 1;
|
||||||
|
|
||||||
|
if (_vmflag_match(tok, "ss"))
|
||||||
|
*shstk = 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Anything else is just ignored.
|
* Anything else is just ignored.
|
||||||
*/
|
*/
|
||||||
@@ -172,14 +176,21 @@ static void __parse_vmflags(char *buf, u32 *flags, u64 *madv, int *io_pf)
|
|||||||
|
|
||||||
void parse_vmflags(char *buf, u32 *flags, u64 *madv, int *io_pf)
|
void parse_vmflags(char *buf, u32 *flags, u64 *madv, int *io_pf)
|
||||||
{
|
{
|
||||||
__parse_vmflags(buf, flags, madv, io_pf);
|
int shstk = 0;
|
||||||
|
|
||||||
|
__parse_vmflags(buf, flags, madv, io_pf, &shstk);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_vma_vmflags(char *buf, struct vma_area *vma_area)
|
static void parse_vma_vmflags(char *buf, struct vma_area *vma_area)
|
||||||
{
|
{
|
||||||
int io_pf = 0;
|
int io_pf = 0;
|
||||||
|
int shstk = 0;
|
||||||
|
|
||||||
__parse_vmflags(buf, &vma_area->e->flags, &vma_area->e->madv, &io_pf);
|
__parse_vmflags(buf, &vma_area->e->flags, &vma_area->e->madv, &io_pf,
|
||||||
|
&shstk);
|
||||||
|
|
||||||
|
if (shstk)
|
||||||
|
vma_area->e->status |= VMA_AREA_SHSTK;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* vmsplice doesn't work for VM_IO and VM_PFNMAP mappings, the
|
* vmsplice doesn't work for VM_IO and VM_PFNMAP mappings, the
|
||||||
|
@@ -103,6 +103,7 @@ mmap_status_map = [
|
|||||||
('VMA_AREA_VVAR', 1 << 12),
|
('VMA_AREA_VVAR', 1 << 12),
|
||||||
('VMA_AREA_AIORING', 1 << 13),
|
('VMA_AREA_AIORING', 1 << 13),
|
||||||
('VMA_AREA_MEMFD', 1 << 14),
|
('VMA_AREA_MEMFD', 1 << 14),
|
||||||
|
('VMA_AREA_SHSTK', 1 << 15),
|
||||||
('VMA_UNSUPP', 1 << 31),
|
('VMA_UNSUPP', 1 << 31),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user