lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240816220604.2688389-1-stephen.s.brennan@oracle.com>
Date: Fri, 16 Aug 2024 15:05:59 -0700
From: Stephen Brennan <stephen.s.brennan@...cle.com>
To: Trond Myklebust <trondmy@...nel.org>, Anna Schumaker <anna@...nel.org>
Cc: Tom Talpey <tom@...pey.com>, linux-kernel@...r.kernel.org,
        linux-nfs@...r.kernel.org, linux-debuggers@...r.kernel.org,
        Dai Ngo <Dai.Ngo@...cle.com>, Jeff Layton <jlayton@...nel.org>,
        Olga Kornievskaia <kolga@...app.com>,
        Chuck Lever <chuck.lever@...cle.com>, Neil Brown <neilb@...e.de>,
        Stephen Brennan <stephen.s.brennan@...cle.com>
Subject: [PATCH 0/1] SUNRPC: convert RPC_TASK_* constants to enum

Hi folks,

For context on this change, I work on the drgn debugger [1] and also
maintain a growing set of helpers [2] that can examine live systems & core
dumps and give detailed information about the state of different
subsystems. One such helper (not written by me) shows all RPC tasks and
their states. For example:

=============================== RPC_TASK =================================
---- <rpc_task: 0xffff8dc383548a00>  tk_op: nfs4_delegreturn_ops  tk_action: call_status
     tk_client: 0xffff8dc385c0fe00  tk_client.cl_xprt: 0xffff8dc4f79f9000
     tk_xprt: 0xffff8dc4f79f9000
     tk_status: 0 (OK) tk_rpc_status[0] (OK)
     tk_runstate: 0x16  (RPC_TASK_QUEUED|RPC_TASK_ACTIVE|RPC_TASK_MSG_RECV_WAIT)
     tk_priority: 1  tk_timeout(ticks): 6095245983  tk_timeouts(major): 0
     <tk_rqstp: 0xffff8dc47025d000>  rq_xid: 0x96143ed3  rq_retries: 0

---- <rpc_task: 0xffff8dc383548400>  tk_op: nfs4_close_ops  tk_action: call_status
     tk_client: 0xffff8dc385c0fe00  tk_client.cl_xprt: 0xffff8dc4f79f9000
     tk_xprt: 0xffff8dc4f79f9000
     tk_status: 0 (OK) tk_rpc_status[0] (OK)
     tk_runstate: 0x16  (RPC_TASK_QUEUED|RPC_TASK_ACTIVE|RPC_TASK_MSG_RECV_WAIT)
     tk_priority: 1  tk_timeout(ticks): 6095245983  tk_timeouts(major): 0
     <tk_rqstp: 0xffff8dc47025ca00>  rq_xid: 0x96143ed4  rq_retries: 0

To do that it needs to be able to interpret the RPC_TASK_* constants back
to their human readable names. Of course these can be hard-coded and this
has been done, but in this particular case, the RPC state codes have been
updated and changed several times:

729749bb8da1 ("SUNRPC: Don't hold the transport lock across socket copy operations")
7ebbbc6e7bd0 ("SUNRPC: Simplify identification of when the message send/receive is complete")
cf9946cd6144 ("SUNRPC: Refactor the transport request pinning")
ae67bd3821bb ("SUNRPC: Fix up task signalling")

Most of these simply add to the end of the list, but at least one (7ebbbc6e7bd0)
shuffles around existing codes. Creating maintainable debugging scripts that can
be used over a range of kernel versions is difficult when you need to detect
these sorts of shuffles. We *can* do this by detecting the presence or existence
of other code changes that occurred in the same commit, but this tends to get
tedious, and it's not very reliable. It certainly won't help in case a similar
change happens in the future.

Converting constants from macros to enums is a great way to avoid this for the
future. While macros aren't typically encoded in debuginfo, enum definitions
are. Of course macros aren't always suitable for 64-bit constants. But in this
case, the RPC_TASK_* constants are bit numbers, so they aren't impacted by this
limitation. So this change shouldn't have any impact except making the code
easier to debug.

Thanks,
Stephen

[1]: https://drgn.readthedocs.io/en/latest/
[2]: https://github.com/oracle-samples/drgn-tools

Stephen Brennan (1):
  SUNRPC: convert RPC_TASK_* constants to enum

 include/linux/sunrpc/sched.h | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

-- 
2.43.5


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ