summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2019-08-13 11:06:57 +0000
committerDmitry V. Levin <ldv@altlinux.org>2019-08-13 11:06:57 +0000
commit98cec8b0cd5ba6ebd45292ed5696d3e1db8dece5 (patch)
treed837ba8acbd5c66fbb7c48cd77bb52a455a61a2c
parent0f94363a7d578c73e6866b2affc2f9c3de041245 (diff)
downloadstrace-98cec8b0cd5ba6ebd45292ed5696d3e1db8dece5.tar.gz
netlink_unix_diag: implement UDIAG_SHOW_UID/UNIX_DIAG_UID decoding
... introduced by Linux kernel commit v5.3-rc1~140^2~467. * linux/unix_diag.h (UDIAG_SHOW_UID, UNIX_DIAG_FIRST_UNUSED): New macro constants. (UNIX_DIAG_UID): New enum constant. * xlat/unix_diag_attrs.in: Add UNIX_DIAG_UID. * xlat/unix_diag_show.in: Add UDIAG_SHOW_UID. * netlink_unix_diag.c (unix_diag_msg_nla_decoders): Handle UNIX_DIAG_UID. * NEWS: Mention this. * tests/nlattr.c (test_nlattr, test_nla_type): Replace UNIX_DIAG_SHUTDOWN + 1 with UNIX_DIAG_FIRST_UNUSED.
-rw-r--r--NEWS1
-rw-r--r--linux/unix_diag.h3
-rw-r--r--netlink_unix_diag.c3
-rw-r--r--tests/nlattr.c12
-rw-r--r--xlat/unix_diag_attrs.in1
-rw-r--r--xlat/unix_diag_show.in1
6 files changed, 14 insertions, 7 deletions
diff --git a/NEWS b/NEWS
index 93ae07f59..87c628347 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ Noteworthy changes in release ?.? (????-??-??)
* Improvements
* Enhanced decoding of NETLINK_ROUTE protocol.
+ * Implemented decoding of UNIX_DIAG_UID netlink attribute.
* Updated lists of BPF_*, ETH_*, KEYCTL_*, KVM_*, MAP_*, SO_*, TCP_*, V4L2_*,
XDP_*, and *_MAGIC constants.
diff --git a/linux/unix_diag.h b/linux/unix_diag.h
index 1d15a0ce0..8f1f62b12 100644
--- a/linux/unix_diag.h
+++ b/linux/unix_diag.h
@@ -24,6 +24,7 @@ struct unix_diag_req {
# define UDIAG_SHOW_ICONS 0x08
# define UDIAG_SHOW_RQLEN 0x10
# define UDIAG_SHOW_MEMINFO 0x20
+# define UDIAG_SHOW_UID 0x40
struct unix_diag_msg {
uint8_t udiag_family;
@@ -42,6 +43,8 @@ enum {
UNIX_DIAG_RQLEN,
UNIX_DIAG_MEMINFO,
UNIX_DIAG_SHUTDOWN,
+ UNIX_DIAG_UID,
+ UNIX_DIAG_FIRST_UNUSED
};
struct unix_diag_vfs {
diff --git a/netlink_unix_diag.c b/netlink_unix_diag.c
index 5a9099634..920ac558c 100644
--- a/netlink_unix_diag.c
+++ b/netlink_unix_diag.c
@@ -119,7 +119,8 @@ static const nla_decoder_t unix_diag_msg_nla_decoders[] = {
[UNIX_DIAG_ICONS] = decode_unix_diag_inode,
[UNIX_DIAG_RQLEN] = decode_unix_diag_rqlen,
[UNIX_DIAG_MEMINFO] = decode_nla_meminfo,
- [UNIX_DIAG_SHUTDOWN] = decode_nla_u8
+ [UNIX_DIAG_SHUTDOWN] = decode_nla_u8,
+ [UNIX_DIAG_UID] = decode_nla_uid
};
DECL_NETLINK_DIAG_DECODER(decode_unix_diag_msg)
diff --git a/tests/nlattr.c b/tests/nlattr.c
index 2c5927b23..204b3672c 100644
--- a/tests/nlattr.c
+++ b/tests/nlattr.c
@@ -105,7 +105,7 @@ test_nlattr(const int fd)
nla = NLMSG_ATTR(msg, sizeof(msg->udm));
*nla = (struct nlattr) {
.nla_len = NLA_HDRLEN + 4,
- .nla_type = UNIX_DIAG_SHUTDOWN + 1
+ .nla_type = UNIX_DIAG_FIRST_UNUSED
};
memcpy(RTA_DATA(nla), "1234", 4);
rc = sendto(fd, msg, msg_len, MSG_DONTWAIT, NULL, 0);
@@ -116,7 +116,7 @@ test_nlattr(const int fd)
", nla_type=%#x /* UNIX_DIAG_??? */}"
", \"\\x31\\x32\\x33\\x34\"}}"
", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
- fd, msg_len, nla->nla_len, UNIX_DIAG_SHUTDOWN + 1,
+ fd, msg_len, nla->nla_len, UNIX_DIAG_FIRST_UNUSED,
msg_len, sprintrc(rc));
/* print one struct nlattr and fetch fail second struct nlattr */
@@ -201,7 +201,7 @@ test_nlattr(const int fd)
for (i = 0; i < ABBREV_LEN; ++i) {
nla[i * 2] = (struct nlattr) {
.nla_len = NLA_HDRLEN * 2 - 1,
- .nla_type = UNIX_DIAG_SHUTDOWN + 1 + i
+ .nla_type = UNIX_DIAG_FIRST_UNUSED + i
};
fill_memory_ex(&nla[i * 2 + 1], NLA_HDRLEN,
'0' + i, '~' - '0' - i);
@@ -218,7 +218,7 @@ test_nlattr(const int fd)
if (i)
printf(", ");
printf("{{nla_len=%u, nla_type=%#x /* UNIX_DIAG_??? */}, ",
- nla->nla_len, UNIX_DIAG_SHUTDOWN + 1 + i);
+ nla->nla_len, UNIX_DIAG_FIRST_UNUSED + i);
print_quoted_hex(&nla[i * 2 + 1], NLA_HDRLEN - 1);
printf("}");
}
@@ -286,7 +286,7 @@ test_nla_type(const int fd)
", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
fd, msg_len, nla->nla_len, msg_len, sprintrc(rc));
- nla->nla_type = NLA_F_NESTED | (UNIX_DIAG_SHUTDOWN + 1);
+ nla->nla_type = NLA_F_NESTED | (UNIX_DIAG_FIRST_UNUSED);
rc = sendto(fd, msg, msg->nlh.nlmsg_len, MSG_DONTWAIT, NULL, 0);
printf("sendto(%d, {{len=%u, type=SOCK_DIAG_BY_FAMILY"
", flags=NLM_F_DUMP, seq=0, pid=0}, {udiag_family=AF_UNIX"
@@ -294,7 +294,7 @@ test_nla_type(const int fd)
", udiag_ino=0, udiag_cookie=[0, 0]}, {nla_len=%u"
", nla_type=NLA_F_NESTED|%#x /* UNIX_DIAG_??? */}}"
", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
- fd, msg->nlh.nlmsg_len, nla->nla_len, UNIX_DIAG_SHUTDOWN + 1,
+ fd, msg->nlh.nlmsg_len, nla->nla_len, UNIX_DIAG_FIRST_UNUSED,
msg->nlh.nlmsg_len, sprintrc(rc));
}
diff --git a/xlat/unix_diag_attrs.in b/xlat/unix_diag_attrs.in
index 4c3d9b2e3..fb2838cc9 100644
--- a/xlat/unix_diag_attrs.in
+++ b/xlat/unix_diag_attrs.in
@@ -6,3 +6,4 @@ UNIX_DIAG_ICONS
UNIX_DIAG_RQLEN
UNIX_DIAG_MEMINFO
UNIX_DIAG_SHUTDOWN
+UNIX_DIAG_UID
diff --git a/xlat/unix_diag_show.in b/xlat/unix_diag_show.in
index c7dbdfbc6..5f50887fc 100644
--- a/xlat/unix_diag_show.in
+++ b/xlat/unix_diag_show.in
@@ -4,3 +4,4 @@ UDIAG_SHOW_PEER
UDIAG_SHOW_ICONS
UDIAG_SHOW_RQLEN
UDIAG_SHOW_MEMINFO
+UDIAG_SHOW_UID