Commit 6af08c33 authored by Pavel Emelyanov's avatar Pavel Emelyanov

fd: Sanitize fd_parms fd_name field

It used to be ulong, but it can be int now (no mapping addresses there). And the
name fd is better than fd_name (reason is the same).
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 9a394828
...@@ -166,8 +166,8 @@ static int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p) ...@@ -166,8 +166,8 @@ static int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p)
} }
big_buffer[len] = '\0'; big_buffer[len] = '\0';
pr_info("Dumping path for %lx fd via self %d [%s]\n", pr_info("Dumping path for %d fd via self %d [%s]\n",
p->fd_name, lfd, big_buffer); p->fd, lfd, big_buffer);
if (p->type == FDINFO_REG && if (p->type == FDINFO_REG &&
!path_accessible(big_buffer, &p->stat)) !path_accessible(big_buffer, &p->stat))
...@@ -303,7 +303,7 @@ static int do_dump_one_fdinfo(const struct fd_parms *p, int lfd, ...@@ -303,7 +303,7 @@ static int do_dump_one_fdinfo(const struct fd_parms *p, int lfd,
int ret = -1; int ret = -1;
e.type = p->type; e.type = p->type;
e.fd = p->fd_name; e.fd = p->fd;
e.id = p->id; e.id = p->id;
ret = fd_id_generate(p->pid, &e); ret = fd_id_generate(p->pid, &e);
...@@ -320,8 +320,8 @@ static int do_dump_one_fdinfo(const struct fd_parms *p, int lfd, ...@@ -320,8 +320,8 @@ static int do_dump_one_fdinfo(const struct fd_parms *p, int lfd,
if (ret < 0) if (ret < 0)
goto err; goto err;
pr_info("fdinfo: type: %2x flags: %4x pos: %8lx addr: %16lx\n", pr_info("fdinfo: type: %2x flags: %4x pos: %8lx fd: %d\n",
p->type, p->flags, p->pos, p->fd_name); p->type, p->flags, p->pos, p->fd);
if (write_img(fdset_fd(cr_fdset, CR_FD_FDINFO), &e)) if (write_img(fdset_fd(cr_fdset, CR_FD_FDINFO), &e))
goto err; goto err;
...@@ -375,7 +375,7 @@ static int fill_fd_params(pid_t pid, int fd, int lfd, struct fd_parms *p) ...@@ -375,7 +375,7 @@ static int fill_fd_params(pid_t pid, int fd, int lfd, struct fd_parms *p)
return -1; return -1;
} }
p->fd_name = fd; p->fd = fd;
p->pos = lseek(lfd, 0, SEEK_CUR); p->pos = lseek(lfd, 0, SEEK_CUR);
p->flags = fcntl(lfd, F_GETFL); p->flags = fcntl(lfd, F_GETFL);
p->pid = pid; p->pid = pid;
...@@ -390,7 +390,7 @@ static int fill_fd_params(pid_t pid, int fd, int lfd, struct fd_parms *p) ...@@ -390,7 +390,7 @@ static int fill_fd_params(pid_t pid, int fd, int lfd, struct fd_parms *p)
static int dump_unsupp_fd(const struct fd_parms *p) static int dump_unsupp_fd(const struct fd_parms *p)
{ {
pr_err("Can't dump file %d of that type [%x]\n", pr_err("Can't dump file %d of that type [%x]\n",
(int)p->fd_name, p->stat.st_mode); p->fd, p->stat.st_mode);
return -1; return -1;
} }
...@@ -402,9 +402,9 @@ static int dump_one_chrdev(struct fd_parms *p, int lfd, const struct cr_fdset *s ...@@ -402,9 +402,9 @@ static int dump_one_chrdev(struct fd_parms *p, int lfd, const struct cr_fdset *s
if (maj == MEM_MAJOR) if (maj == MEM_MAJOR)
return dump_one_fdinfo(p, lfd, set); return dump_one_fdinfo(p, lfd, set);
if (p->fd_name < 3 && (maj == TTY_MAJOR || if (p->fd < 3 && (maj == TTY_MAJOR ||
maj == UNIX98_PTY_SLAVE_MAJOR)) { maj == UNIX98_PTY_SLAVE_MAJOR)) {
pr_info("... Skipping tty ... %d\n", (int)p->fd_name); pr_info("... Skipping tty ... %d\n", p->fd);
return 0; return 0;
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "image.h" #include "image.h"
struct fd_parms { struct fd_parms {
unsigned long fd_name; int fd;
unsigned long pos; unsigned long pos;
unsigned int flags; unsigned int flags;
unsigned int type; unsigned int type;
......
...@@ -475,9 +475,9 @@ int dump_socket(struct fd_parms *p, int lfd, const struct cr_fdset *cr_fdset) ...@@ -475,9 +475,9 @@ int dump_socket(struct fd_parms *p, int lfd, const struct cr_fdset *cr_fdset)
switch (sk->family) { switch (sk->family) {
case AF_UNIX: case AF_UNIX:
return dump_one_unix(sk, p->fd_name, lfd, cr_fdset); return dump_one_unix(sk, p->fd, lfd, cr_fdset);
case AF_INET: case AF_INET:
return dump_one_inet(sk, p->fd_name, cr_fdset); return dump_one_inet(sk, p->fd, cr_fdset);
default: default:
pr_err("BUG! Unknown socket collected\n"); pr_err("BUG! Unknown socket collected\n");
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment