mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-18 00:58:31 +00:00
fsnotify: More precious error handling
- make sure the alloc_openable is not failed with memory error, so that we should not lookup via irmap - irmap lookup should provide us a copy of the path instead of reference to irmap entry https://github.com/checkpoint-restore/criu/issues/698 Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com> Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com> Signed-off-by: Andrei Vagin <avagin@gmail.com>
This commit is contained in:
parent
6a2cd621cb
commit
ffec568034
1 changed files with 9 additions and 4 deletions
|
|
@ -175,7 +175,7 @@ static char *alloc_openable(unsigned int s_dev, unsigned long i_ino, FhEntry *f_
|
|||
if (st.st_ino == i_ino) {
|
||||
path = xstrdup(buf);
|
||||
if (path == NULL)
|
||||
goto err;
|
||||
return ERR_PTR(-ENOMEM);
|
||||
if (root_ns_mask & CLONE_NEWNS) {
|
||||
f_handle->has_mnt_id = true;
|
||||
f_handle->mnt_id = m->mnt_id;
|
||||
|
|
@ -227,8 +227,8 @@ out:
|
|||
int check_open_handle(unsigned int s_dev, unsigned long i_ino,
|
||||
FhEntry *f_handle)
|
||||
{
|
||||
char *path, *irmap_path;
|
||||
int fd = -1;
|
||||
char *path;
|
||||
|
||||
if (fault_injected(FI_CHECK_OPEN_HANDLE)) {
|
||||
fd = -1;
|
||||
|
|
@ -262,6 +262,8 @@ fault:
|
|||
path = alloc_openable(s_dev, i_ino, f_handle);
|
||||
if (!IS_ERR_OR_NULL(path))
|
||||
goto out;
|
||||
else if (IS_ERR(path) && PTR_ERR(path) == -ENOMEM)
|
||||
goto err;
|
||||
|
||||
if ((mi->fstype->code == FSTYPE__TMPFS) ||
|
||||
(mi->fstype->code == FSTYPE__DEVTMPFS)) {
|
||||
|
|
@ -284,11 +286,14 @@ fault:
|
|||
}
|
||||
|
||||
pr_warn("\tHandle 0x%x:0x%lx cannot be opened\n", s_dev, i_ino);
|
||||
path = irmap_lookup(s_dev, i_ino);
|
||||
if (!path) {
|
||||
irmap_path = irmap_lookup(s_dev, i_ino);
|
||||
if (!irmap_path) {
|
||||
pr_err("\tCan't dump that handle\n");
|
||||
return -1;
|
||||
}
|
||||
path = xstrdup(irmap_path);
|
||||
if (!path)
|
||||
goto err;
|
||||
out:
|
||||
pr_debug("\tDumping %s as path for handle\n", path);
|
||||
f_handle->path = path;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue