mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
dmfilemapd: ensure path argument is absolute
Require that the path argument to dmfilemapd be an absolute path and document this in tool output, libdevmapper.h and dmfilemapd.8. The check is also enforced by dm_stats_start_filemapd() to avoid forking a new process with an invalid path argument.
This commit is contained in:
parent
9b0aba5fe9
commit
77a7ed065f
@ -62,7 +62,7 @@ struct filemap_monitor {
|
|||||||
static int _foreground;
|
static int _foreground;
|
||||||
static int _verbose;
|
static int _verbose;
|
||||||
|
|
||||||
const char *const _usage = "dmfilemapd <fd> <group_id> <path> <mode> "
|
const char *const _usage = "dmfilemapd <fd> <group_id> <abs_path> <mode> "
|
||||||
"[<foreground>[<log_level>]]";
|
"[<foreground>[<log_level>]]";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -296,6 +296,12 @@ static int _parse_args(int argc, char **argv, struct filemap_monitor *fm)
|
|||||||
_early_log("Path argument is required.");
|
_early_log("Path argument is required.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (argv[0] != '/') {
|
||||||
|
_early_log("Path argument must specify an absolute path.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
fm->path = dm_strdup(argv[0]);
|
fm->path = dm_strdup(argv[0]);
|
||||||
if (!fm->path) {
|
if (!fm->path) {
|
||||||
_early_log("Could not allocate memory for path argument.");
|
_early_log("Could not allocate memory for path argument.");
|
||||||
|
@ -1421,6 +1421,10 @@ dm_filemapd_mode_t dm_filemapd_mode_from_string(const char *mode_str);
|
|||||||
* detected, call dm_stats_update_regions_from_fd() to update the
|
* detected, call dm_stats_update_regions_from_fd() to update the
|
||||||
* mapped regions for the file.
|
* mapped regions for the file.
|
||||||
*
|
*
|
||||||
|
* The path provided to dm_stats_start_filemapd() must be an absolute
|
||||||
|
* path, and should reflect the path of 'fd' at the time that it was
|
||||||
|
* opened.
|
||||||
|
*
|
||||||
* The mode parameter controls the behaviour of the daemon when the
|
* The mode parameter controls the behaviour of the daemon when the
|
||||||
* file being monitored is unlinked or moved: see the comments for
|
* file being monitored is unlinked or moved: see the comments for
|
||||||
* dm_filemapd_mode_t for a full description and possible values.
|
* dm_filemapd_mode_t for a full description and possible values.
|
||||||
|
@ -4951,6 +4951,11 @@ int dm_stats_start_filemapd(int fd, uint64_t group_id, const char *path,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (path[0] != '/') {
|
||||||
|
log_error("Path argument must specify an absolute path.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (mode > DM_FILEMAPD_FOLLOW_PATH) {
|
if (mode > DM_FILEMAPD_FOLLOW_PATH) {
|
||||||
log_error("Invalid dmfilemapd mode argument: "
|
log_error("Invalid dmfilemapd mode argument: "
|
||||||
"Must be DM_FILEMAPD_FOLLOW_INODE or "
|
"Must be DM_FILEMAPD_FOLLOW_INODE or "
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
. RB [ group_id ]
|
. RB [ group_id ]
|
||||||
..
|
..
|
||||||
.de OPT_PATH
|
.de OPT_PATH
|
||||||
. RB [ path ]
|
. RB [ abs_path ]
|
||||||
..
|
..
|
||||||
.
|
.
|
||||||
.de OPT_MODE
|
.de OPT_MODE
|
||||||
@ -73,12 +73,12 @@ should update. The group must exist and it should correspond to
|
|||||||
a set of regions created by a previous filemap operation.
|
a set of regions created by a previous filemap operation.
|
||||||
.
|
.
|
||||||
.HP
|
.HP
|
||||||
.BR path
|
.BR abs_path
|
||||||
.br
|
.br
|
||||||
The path to the file being monitored, at the time that it was
|
The absolute path to the file being monitored, at the time that
|
||||||
opened. The use of \fBpath\fP by the daemon differs, depending
|
it was opened. The use of \fBpath\fP by the daemon differs,
|
||||||
on the filemap following mode in use; see \fBMODES\fP and the
|
depending on the filemap following mode in use; see \fBMODES\fP
|
||||||
\fBmode\fP option for more information.
|
and the \fBmode\fP option for more information.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
.HP
|
.HP
|
||||||
@ -167,16 +167,16 @@ manually for debugging or testing purposes.
|
|||||||
Start the daemon in the background, in follow-path mode
|
Start the daemon in the background, in follow-path mode
|
||||||
.br
|
.br
|
||||||
#
|
#
|
||||||
.B dmfilemapd 3 0 vm.img path 0 0 3< vm.img
|
.B dmfilemapd 3 0 /srv/images/vm.img path 0 0 3< /srv/images/vm.img
|
||||||
.br
|
.br
|
||||||
.P
|
.P
|
||||||
Start the daemon in follow-inode mode, disable forking and enable
|
Start the daemon in follow-inode mode, disable forking and enable
|
||||||
verbose logging
|
verbose logging
|
||||||
.br
|
.br
|
||||||
#
|
#
|
||||||
.B dmfilemapd 3 0 vm.img inode 1 3 3< vm.img
|
.B dmfilemapd 3 0 /var/tmp/data inode 1 3 3< /var/tmp/data
|
||||||
.br
|
.br
|
||||||
Starting dmfilemapd with fd=3, group_id=0 mode=inode, path=vm.img
|
Starting dmfilemapd with fd=3, group_id=0 mode=inode, path=/var/tmp/data
|
||||||
.br
|
.br
|
||||||
dm version [ opencount flush ] [16384] (*1)
|
dm version [ opencount flush ] [16384] (*1)
|
||||||
.br
|
.br
|
||||||
@ -184,9 +184,9 @@ dm info (253:0) [ opencount flush ] [16384] (*1)
|
|||||||
.br
|
.br
|
||||||
dm message (253:0) [ opencount flush ] @stats_list dmstats [16384] (*1)
|
dm message (253:0) [ opencount flush ] @stats_list dmstats [16384] (*1)
|
||||||
.br
|
.br
|
||||||
Read alias 'vm.img' from aux_data
|
Read alias 'data' from aux_data
|
||||||
.br
|
.br
|
||||||
Found group_id 0: alias="vm.img"
|
Found group_id 0: alias="data"
|
||||||
.br
|
.br
|
||||||
dm_stats_walk_init: initialised flags to 4000000000000
|
dm_stats_walk_init: initialised flags to 4000000000000
|
||||||
.br
|
.br
|
||||||
@ -194,7 +194,7 @@ starting stats walk with GROUP
|
|||||||
.br
|
.br
|
||||||
exiting _filemap_monitor_get_events() with deleted=0, check=0
|
exiting _filemap_monitor_get_events() with deleted=0, check=0
|
||||||
.br
|
.br
|
||||||
waiting for FILEMAPD_WAIT
|
Waiting for check interval
|
||||||
.br
|
.br
|
||||||
.P
|
.P
|
||||||
.
|
.
|
||||||
|
Loading…
Reference in New Issue
Block a user