Bug #13866
closedlibipadm ipadm_addr_info not 64bit safe
100%
Description
Using a 64bit libipadm (#13863) breaks ipadm_addr_info().
libipadm uses a door to get the address information from ipmgmtd, which is a 32bit process. The data passed through the door is a ipmgmt_get_rval_t followed by a packed nvlist. The definition of ipmgmt_get_rval_t in ipadm_ipmgmt.h is as follows:
typedef struct ipmgmt_get_rval_s { int32_t ir_err; size_t ir_nvlsize; /* packed nvl follows */ } ipmgmt_get_rval_t;
Obviously size_t is 4 bytes in a 32bit process and 8 bytes in a 64bit process. Additionally, 64bit compiler will usually add 4 bytes of padding between ir_err and ir_nvlsize to align the latter to a 64bit boundary. Hence the 64bit libipadm will misinterpret what the 32bit ipmgmtd is sending, confusing nvlist_unpack() which is subsequently called. It works the other way around, but only by accident.
This can be fixed easily by changing the definition like this:
typedef struct ipmgmt_get_rval_s { int64_t ir_err; uint64_t ir_nvlsize; /* packed nvl follows */ } ipmgmt_get_rval_t;
Testing: I rebuilt both 32bit and 64bit libipadm and a 32bit ipmgmtd with this change. The problem observed previously disappeared.
Updated by Hans Rosenfeld over 1 year ago
Additional testing: I've verified that the ipadm commands show-addr and create-addr still work as expected in non-global zones as well as the global zone.
Updated by Electric Monk over 1 year ago
- Status changed from In Progress to Closed
- % Done changed from 0 to 100
git commit 0a8fc1cbac5c0b540cc1948761e1ea321879e522
commit 0a8fc1cbac5c0b540cc1948761e1ea321879e522 Author: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org> Date: 2021-07-22T15:08:04.000Z 13866 libipadm ipadm_addr_info not 64bit safe Reviewed by: Robert Mustacchi <rm+illumos@fingolfin.org> Reviewed by: Andy Fiddaman <andy@omnios.org> Reviewed by: Toomas Soome <tsoome@me.com> Approved by: Dan McDonald <danmcd@joyent.com>