On Thu, 2026-10-29 at 17:27 -0400, Benjamin Marzinski wrote:
> On Thu, Oct 29, 2026 at 10:57:27AM -0700, Brian Bunker wrote:
> > multipathd takes a path's WWID from udev. When a change uevent
> > reports
> > a different WWID, uev_update_path() removes the path from its map
> > and
> > re-adds it through uev_add_path(), which places it in whatever map
> > owns
> > the new WWID. Nothing checks the new value against the device
> > itself;
> > recheck_wwid only covers paths coming back up in the checker and
> > "multipathd add path". If udev reports the wrong WWID, or the
> > uevent is
> > stale by the time it is processed, the path goes into the map of a
> > different LUN and I/O for one LUN is silently sent to another.
> > 
> > Use SG_IO to read VPD page 0x83 from the device in two places, for
> > paths where can_recheck_wwid() is true:
> > 
> > - In uev_update_path(), if the device still reports the cached
> > WWID,
> >   ignore the udev value and leave the path where it is.
> > 
> > - In ev_add_path(), refuse to add a path whose WWID the device
> > doesn't
> >   confirm. The path is orphaned, its WWID is cleared and it is
> > marked
> >   INIT_MISSING_UDEV, so the checker retriggers udev (bounded by
> >   retrigger_tries) and the path is re-added from fresh data.
> > 
> > ev_add_path() is the common point for uevent, CLI and checker adds,
> > so
> > the second check holds even when the udev data is stale by the time
> > it
> > is used. If the SG_IO read fails, behavior is unchanged.
> > 
> > Split the SG_IO read out of check_path_wwid_change() into
> > get_sgio_wwid() so all three checks share it.
> 
> The code all looks good to me. I must admit, I'm a little paranoid
> about
> forcing perfectly normal ev_add_path() calls to double-check the
> wwid.
> Currently, that only happens if you enable "recheck_wwid", or if
> something is going wrong with initializing the path. The issue is
> that
> scsi devices can have multiple wwids, and the multipath code has to
> be
> in sync with the code that udev runs to the wwid, otherwise they can
> be
> different. I don't think these functions differ. I know I've checked
> them in the past. But unless there is a problem getting the wwid from
> udev or someone turns on recheck_wwid (I don't know how common that
> is)
> paths don't ever run this code. 
> 
> We could avoid this by hijacking the need_do_map argument to
> uev_add_path() and ev_add_path(). If, instead of just being 0 or 1,
> it
> could also be a third value for reinits (we should probably use an
> enum
> in this case), we could only double-check the wwid on reinits, which
> only happen when there is an issue getting the wwid from udev.
> 
> Thoughts? Am I just being paranoid here?

Sorry for jumping onto this thread late, I was out of office and then
busy. I don't think you're paranoid.

Our primary source of the WWID is udev, by design, and udev rules are
modifiable by users, also by design. The algorithm we implemented in
parse_vpd_pg83() mimics the default logic in the rules shipped by
systemd/udev and sg3_utils, respectively, if and only if all udev rules
and configuration settings (e.g. uid_attribute) have default values.
For that reason, we use get_vpd_sgio() only as the fallback if udev
fails, and that's really a last resort measure.

This design can of course be debated. The udev-based design was created
a long time ago, when there were less useful sysfs attributes to rely
on. It's certainly showing its age, be it only by the historic variable
name ID_SERIAL. udev rules read VPD pages from sysfs rather than from
the devices themselves, which might return stale data in certain
situations. But we have moved from explicit SG_IO to cached kernel data
for a reason - SG_IO ioctls may hang, and are thus best avoided if
possible. 

OTOH, to a certain extent we have to rely on udev. We do rely on it for
a lot of information that we retrieve about devices. If we can't trust
udev, we need to re-write a large part of multipath-tools (and
honestly, I would be clueless what we can trust if we can't trust udev.
Can we trust the kernel?).

Anyway, if we deliberately mix udev, sysfs, and SG_IO methods to
retrieve the WWID, we are on a very dangerous path.

I'll look at the v2 now.

Martin

-- 
Dr. Martin Wilck <[email protected]>
SUSE Software Solutions Germany GmbH, Frankenstr. 146, 90461 Nürnberg,
Germany
Geschäftsführer: Stefan Gaiser, Jochen Jaser, Abhinav Puri (HRB
36809,AG Nürnberg)

Reply via email to