]> granicus.if.org Git - strace/commitdiff
netlink_unix_diag: implement UDIAG_SHOW_UID/UNIX_DIAG_UID decoding
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 13 Aug 2019 11:06:57 +0000 (11:06 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 13 Aug 2019 11:06:57 +0000 (11:06 +0000)
... 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.

NEWS
linux/unix_diag.h
netlink_unix_diag.c
tests/nlattr.c
xlat/unix_diag_attrs.in
xlat/unix_diag_show.in

diff --git a/NEWS b/NEWS
index 93ae07f59817cb340c1705034d79b7362c6efcf6..87c628347e641661d70b2fe4fe4ba495d14dee02 100644 (file)
--- 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.
 
index 1d15a0ce047a5d090311b992d2455a00f8130119..8f1f62b127f96fdcb9dd66fec7a3173ca4adcd4d 100644 (file)
@@ -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 {
index 5a9099634e7da0d86bab859bb0299c340779a399..920ac558c336623539853361eec6eadc349d1b93 100644 (file)
@@ -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)
index 2c5927b23055a197d3f0ad8163fc1c5187094e4f..204b3672c9b52360e0e26f54e2c364c329f965a3 100644 (file)
@@ -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));
 }
 
index 4c3d9b2e33493f350d44c0f72fcc9fbfdbbbf442..fb2838cc92b59249f5b3f484db83a9ee8b4c91b6 100644 (file)
@@ -6,3 +6,4 @@ UNIX_DIAG_ICONS
 UNIX_DIAG_RQLEN
 UNIX_DIAG_MEMINFO
 UNIX_DIAG_SHUTDOWN
+UNIX_DIAG_UID
index c7dbdfbc6972945ae056dab0b02644d06e04dcd2..5f50887fc74e642c814d64679058e05a2a5b2a11 100644 (file)
@@ -4,3 +4,4 @@ UDIAG_SHOW_PEER
 UDIAG_SHOW_ICONS
 UDIAG_SHOW_RQLEN
 UDIAG_SHOW_MEMINFO
+UDIAG_SHOW_UID