Add file descriptor argument to decode_netlink
* defs.h (decode_netlink): Add file descriptor argument. * io.c (print_iovec): Specify file descriptor to decode_netlink. * net.c (decode_sockbuf): Likewise. * netlink.c (print_nlmsghdr, decode_nlmsghdr_with_payload, decode_nlmsgerr, decode_payload, decode_nlmsghdr_with_payload, decode_netlink): Likewise. All callers updated. Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
This commit is contained in:
parent
f26c22d8b2
commit
8240e4e983
2
defs.h
2
defs.h
@ -621,7 +621,7 @@ tprint_iov_upto(struct tcb *, kernel_ulong_t len, kernel_ulong_t addr,
|
||||
enum iov_decode, kernel_ulong_t data_size);
|
||||
|
||||
extern void
|
||||
decode_netlink(struct tcb *, kernel_ulong_t addr, kernel_ulong_t len);
|
||||
decode_netlink(struct tcb *, int fd, kernel_ulong_t addr, kernel_ulong_t len);
|
||||
|
||||
extern void tprint_open_modes(unsigned int);
|
||||
extern const char *sprint_open_modes(unsigned int);
|
||||
|
3
io.c
3
io.c
@ -95,7 +95,8 @@ print_iovec(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
|
||||
len = c->data_size;
|
||||
if (c->data_size != (kernel_ulong_t) -1)
|
||||
c->data_size -= len;
|
||||
decode_netlink(tcp, iov[0], len);
|
||||
/* assume that the descriptor is 1st syscall argument */
|
||||
decode_netlink(tcp, tcp->u_arg[0], iov[0], len);
|
||||
break;
|
||||
default:
|
||||
printaddr(iov[0]);
|
||||
|
2
net.c
2
net.c
@ -110,7 +110,7 @@ decode_sockbuf(struct tcb *const tcp, const int fd, const kernel_ulong_t addr,
|
||||
|
||||
switch (verbose(tcp) ? getfdproto(tcp, fd) : SOCK_PROTO_UNKNOWN) {
|
||||
case SOCK_PROTO_NETLINK:
|
||||
decode_netlink(tcp, addr, addrlen);
|
||||
decode_netlink(tcp, fd, addr, addrlen);
|
||||
break;
|
||||
default:
|
||||
printstrn(tcp, addr, addrlen);
|
||||
|
30
netlink.c
30
netlink.c
@ -56,7 +56,9 @@ fetch_nlmsghdr(struct tcb *const tcp, struct nlmsghdr *const nlmsghdr,
|
||||
}
|
||||
|
||||
static void
|
||||
print_nlmsghdr(struct tcb *tcp, const struct nlmsghdr *const nlmsghdr)
|
||||
print_nlmsghdr(struct tcb *tcp,
|
||||
const int fd,
|
||||
const struct nlmsghdr *const nlmsghdr)
|
||||
{
|
||||
/* print the whole structure regardless of its nlmsg_len */
|
||||
|
||||
@ -73,14 +75,16 @@ print_nlmsghdr(struct tcb *tcp, const struct nlmsghdr *const nlmsghdr)
|
||||
|
||||
static void
|
||||
decode_nlmsghdr_with_payload(struct tcb *const tcp,
|
||||
const int fd,
|
||||
const struct nlmsghdr *const nlmsghdr,
|
||||
const kernel_ulong_t addr,
|
||||
const kernel_ulong_t len);
|
||||
|
||||
static void
|
||||
decode_nlmsgerr(struct tcb *const tcp,
|
||||
kernel_ulong_t addr,
|
||||
kernel_ulong_t len)
|
||||
const int fd,
|
||||
kernel_ulong_t addr,
|
||||
kernel_ulong_t len)
|
||||
{
|
||||
struct nlmsgerr err;
|
||||
|
||||
@ -105,7 +109,8 @@ decode_nlmsgerr(struct tcb *const tcp,
|
||||
if (len) {
|
||||
tprints(", msg=");
|
||||
if (fetch_nlmsghdr(tcp, &err.msg, addr, len)) {
|
||||
decode_nlmsghdr_with_payload(tcp, &err.msg, addr, len);
|
||||
decode_nlmsghdr_with_payload(tcp, fd, &err.msg,
|
||||
addr, len);
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,12 +119,13 @@ decode_nlmsgerr(struct tcb *const tcp,
|
||||
|
||||
static void
|
||||
decode_payload(struct tcb *const tcp,
|
||||
const int fd,
|
||||
const struct nlmsghdr *const nlmsghdr,
|
||||
const kernel_ulong_t addr,
|
||||
const kernel_ulong_t len)
|
||||
{
|
||||
if (nlmsghdr->nlmsg_type == NLMSG_ERROR) {
|
||||
decode_nlmsgerr(tcp, addr, len);
|
||||
decode_nlmsgerr(tcp, fd, addr, len);
|
||||
return;
|
||||
} else if (nlmsghdr->nlmsg_type == NLMSG_DONE && len == sizeof(int)) {
|
||||
int num;
|
||||
@ -134,27 +140,31 @@ decode_payload(struct tcb *const tcp,
|
||||
|
||||
static void
|
||||
decode_nlmsghdr_with_payload(struct tcb *const tcp,
|
||||
const int fd,
|
||||
const struct nlmsghdr *const nlmsghdr,
|
||||
const kernel_ulong_t addr,
|
||||
const kernel_ulong_t len)
|
||||
{
|
||||
tprints("{");
|
||||
|
||||
print_nlmsghdr(tcp, nlmsghdr);
|
||||
print_nlmsghdr(tcp, fd, nlmsghdr);
|
||||
|
||||
unsigned int nlmsg_len =
|
||||
nlmsghdr->nlmsg_len > len ? len : nlmsghdr->nlmsg_len;
|
||||
if (nlmsg_len > NLMSG_HDRLEN) {
|
||||
tprints(", ");
|
||||
decode_payload(tcp, nlmsghdr, addr + NLMSG_HDRLEN,
|
||||
nlmsg_len - NLMSG_HDRLEN);
|
||||
decode_payload(tcp, fd, nlmsghdr, addr + NLMSG_HDRLEN,
|
||||
nlmsg_len - NLMSG_HDRLEN);
|
||||
}
|
||||
|
||||
tprints("}");
|
||||
}
|
||||
|
||||
void
|
||||
decode_netlink(struct tcb *const tcp, kernel_ulong_t addr, kernel_ulong_t len)
|
||||
decode_netlink(struct tcb *const tcp,
|
||||
const int fd,
|
||||
kernel_ulong_t addr,
|
||||
kernel_ulong_t len)
|
||||
{
|
||||
struct nlmsghdr nlmsghdr;
|
||||
bool print_array = false;
|
||||
@ -182,7 +192,7 @@ decode_netlink(struct tcb *const tcp, kernel_ulong_t addr, kernel_ulong_t len)
|
||||
print_array = true;
|
||||
}
|
||||
|
||||
decode_nlmsghdr_with_payload(tcp, &nlmsghdr, addr, len);
|
||||
decode_nlmsghdr_with_payload(tcp, fd, &nlmsghdr, addr, len);
|
||||
|
||||
if (!next_addr)
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user