mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-18 00:58:31 +00:00
fsnotify: Fix mnt_id type to avoid undefined behavior with -1 sentinel
mnt_id was declared as uint32_t but assigned -1 when absent, which yields UINT32_MAX. When passed to mntns_get_root_by_mnt_id(int), the conversion from UINT32_MAX to int is implementation-defined and can become a large positive value, potentially causing lookup_nsid_by_mnt_id() to return NULL and trigger BUG_ON(). Change mnt_id to int with an explicit cast from f_handle->mnt_id when present, so the sentinel -1 is preserved reliably across platforms. Signed-off-by: 3idey <elaidya225@gmail.com>
This commit is contained in:
parent
859924c2f6
commit
cff99dbcc2
1 changed files with 2 additions and 2 deletions
|
|
@ -529,12 +529,12 @@ static char *get_mark_path(const char *who, struct file_remap *remap, FhEntry *f
|
|||
} else if (f_handle->path) {
|
||||
int mntns_root;
|
||||
char *fpath = ".";
|
||||
uint32_t mnt_id = f_handle->has_mnt_id ? f_handle->mnt_id : -1;
|
||||
int mnt_id = f_handle->has_mnt_id ? (int)f_handle->mnt_id : -1;
|
||||
|
||||
/* irmap cache is collected in the root namespaces. */
|
||||
mntns_root = mntns_get_root_by_mnt_id(mnt_id);
|
||||
if (mntns_root < 0) {
|
||||
pr_err("Failed to get mount namespace root for path hint (mnt_id %#x path %s)\n",
|
||||
pr_err("Failed to get mount namespace root for path hint (mnt_id %d path %s)\n",
|
||||
mnt_id, f_handle->path);
|
||||
goto err;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue