mbox series

[0/2] dm: mpath dm_get_device fix

Message ID 20240517004129.139615-1-bmarzins@redhat.com (mailing list archive)
Headers show
Series dm: mpath dm_get_device fix | expand

Message

Benjamin Marzinski May 17, 2024, 12:41 a.m. UTC
dm-mpath shouldn't be calling dm_get_device() in multipath_message().
If you run:

# dmsetup message <mpath_dev> 0 "fail_path <device_not_in_multipath>"

the dm_get_device() call in multipath_message() will add that incorrect
device to the devices list, fail to find a matching pgpath, and then
remove it.  multipath shouldn't be messing with the devices table
outside of its constructor and destructor.

To fix it, this patchset factors out a helper function from
dm_get_device() to turn the device path string into a dev_t.
multipath_message() calls that helper function and uses the dev_t to
find the correct pgpath instead.

Benjamin Marzinski (2):
  dm: factor out helper function from dm_get_device
  dm mpath: don't call dm_get_device in multipath_message

 drivers/md/dm-mpath.c         | 11 ++++-------
 drivers/md/dm-table.c         | 33 ++++++++++++++++++++++++---------
 include/linux/device-mapper.h |  5 +++++
 3 files changed, 33 insertions(+), 16 deletions(-)

Comments

Benjamin Marzinski June 10, 2024, 6:12 p.m. UTC | #1
On Thu, May 16, 2024 at 08:41:27PM -0400, Benjamin Marzinski wrote:

ping.

> dm-mpath shouldn't be calling dm_get_device() in multipath_message().
> If you run:
> 
> # dmsetup message <mpath_dev> 0 "fail_path <device_not_in_multipath>"
> 
> the dm_get_device() call in multipath_message() will add that incorrect
> device to the devices list, fail to find a matching pgpath, and then
> remove it.  multipath shouldn't be messing with the devices table
> outside of its constructor and destructor.
> 
> To fix it, this patchset factors out a helper function from
> dm_get_device() to turn the device path string into a dev_t.
> multipath_message() calls that helper function and uses the dev_t to
> find the correct pgpath instead.
> 
> Benjamin Marzinski (2):
>   dm: factor out helper function from dm_get_device
>   dm mpath: don't call dm_get_device in multipath_message
> 
>  drivers/md/dm-mpath.c         | 11 ++++-------
>  drivers/md/dm-table.c         | 33 ++++++++++++++++++++++++---------
>  include/linux/device-mapper.h |  5 +++++
>  3 files changed, 33 insertions(+), 16 deletions(-)
> 
> -- 
> 2.45.0
>
Mikulas Patocka July 4, 2024, 3:06 p.m. UTC | #2
On Mon, 10 Jun 2024, Benjamin Marzinski wrote:

> On Thu, May 16, 2024 at 08:41:27PM -0400, Benjamin Marzinski wrote:
> 
> ping.

I staged these patches for 6.11.

Mikulas

> > dm-mpath shouldn't be calling dm_get_device() in multipath_message().
> > If you run:
> > 
> > # dmsetup message <mpath_dev> 0 "fail_path <device_not_in_multipath>"
> > 
> > the dm_get_device() call in multipath_message() will add that incorrect
> > device to the devices list, fail to find a matching pgpath, and then
> > remove it.  multipath shouldn't be messing with the devices table
> > outside of its constructor and destructor.
> > 
> > To fix it, this patchset factors out a helper function from
> > dm_get_device() to turn the device path string into a dev_t.
> > multipath_message() calls that helper function and uses the dev_t to
> > find the correct pgpath instead.
> > 
> > Benjamin Marzinski (2):
> >   dm: factor out helper function from dm_get_device
> >   dm mpath: don't call dm_get_device in multipath_message
> > 
> >  drivers/md/dm-mpath.c         | 11 ++++-------
> >  drivers/md/dm-table.c         | 33 ++++++++++++++++++++++++---------
> >  include/linux/device-mapper.h |  5 +++++
> >  3 files changed, 33 insertions(+), 16 deletions(-)
> > 
> > -- 
> > 2.45.0
> > 
>