libmultipath: make sure sscanf sets a max field width for strings
Benjamin Marzinski
maintainerPATCH 1/2 libmultipath: make sure sscanf sets a max field width for strings
In the iet and datacore prioritizers, multipath was using sscanf to get a string for a 255 byte buffer, without limiting the size of the string. This could result in a buffer overflow, if there was a bad value in multipath.conf.
---
Note:
This patch applies on top of Martin's ("libmultipath: iet prioritizer:
obtain PATH_ID from udev") commit, from the "tip" branch.
libmultipath/prioritizers/datacore.c | 6 +++--- libmultipath/prioritizers/iet.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
libmultipath/prioritizers/datacore.c +3 -3
@@ -49,11 +49,11 @@ int datacore_prio (const char *dev, int sg_fd, char * args,return 0 ; } -if (sscanf (args,"timeout=%i preferredsds=%s" , +if (sscanf (args,"timeout=%i preferredsds=%254s" , (int *)&timeout_ms, preferredsds) ==2 ) {} -else if (sscanf (args,"preferredsds=%s timeout=%i" , +else if (sscanf (args,"preferredsds=%254s timeout=%i" , preferredsds, (int *)&timeout_ms) ==2 ) {} -else if (sscanf (args,"preferredsds=%s" , +else if (sscanf (args,"preferredsds=%254s" , preferredsds) ==1 ) {}else {dc_log (0 ,"unexpected prio_args format" );
libmultipath/prioritizers/iet.c +1 -1
@@ -101,7 +101,7 @@ int iet_prio(struct udev_device *udev, char *args)return 0 ; }// check if args format is OK -if (sscanf (args,"preferredip=%s" , preferredip) !=1 ) { +if (sscanf (args,"preferredip=%254s" , preferredip) !=1 ) {if (!arg_logged) {dc_log (2 ,"unexpected prio_args format" ); arg_logged = true;
Signature · 1 line
2.53.0
Benjamin Marzinski
maintainerPATCH 2/2 Remove unsed DEFAULT_DISABLE_CHANGED_WWIDS define
disable_changed_wwids is deprecated and unused.
--- libmultipath/defaults.h | 1 - 1 file changed, 1 deletion(-)
libmultipath/defaults.h +0 -1
@@ -49,7 +49,6 @@#define UNSET_PARTITION_DELIM "/UNSET/"#define DEFAULT_PARTITION_DELIM NULL#define DEFAULT_SKIP_KPARTX SKIP_KPARTX_OFF -#define DEFAULT_DISABLE_CHANGED_WWIDS 1#define DEFAULT_MAX_SECTORS_KB MAX_SECTORS_KB_UNDEF#define DEFAULT_GHOST_DELAY GHOST_DELAY_OFF#define DEFAULT_FIND_MULTIPATHS_TIMEOUT -10
Signature · 1 line
2.53.0
Re: [PATCH 2/2] Remove unsed DEFAULT_DISABLE_CHANGED_WWIDS define
Quoted 4 lines · Benjamin Marzinski
disable_changed_wwidsis deprecated and unused.Suggested-by Xose Vazquez Perez <[email protected]>Signed-off-by Benjamin Marzinski <[email protected]>
Quoted 3 lines · Benjamin Marzinski
Note:
This patch applies on top of Martin's ("libmultipath: iet prioritizer:
obtainPATH_IDfrom udev") commit, from the "tip" branch.
Martin, this should be removed from iet.c:
"// Uses /dev/disk/by-path to find the IP of the device."
Quoted 8 lines · Xose Vazquez Perez
Quoted 4 lines · Benjamin Marzinski
Note:
This patch applies on top of Martin's ("libmultipath: iet prioritizer:
obtainPATH_IDfrom udev") commit, from the "tip" branch.Martin, this should be removed from
iet.c:
"// Uses/dev/disk/by-pathto find the IP of the device."
I'm working on a fix. See my "tip" branch.
Signature · 4 lines
Dr. Martin Wilck <[email protected]> SUSE Software Solutions Germany GmbH, Frankenstr. 146, 90461 Nürnberg, Germany Geschäftsführer: Jochen Jaser, Andrew McDonald (HRB 36809,AG Nürnberg)
Quoted 6 lines · Martin Wilck
Quoted 2 lines · Xose Vazquez Perez
Martin, this should be removed from
iet.c:
"// Uses/dev/disk/by-pathto find the IP of the device."I'm working on a fix. See my "tip" branch.
I mean this:
libmultipath/prioritizers/iet.c +0 -1
@@ -21,7 +21,6 @@// prio "iet" // prio_args "preferredip=10.11.12.13" // -// Uses /dev/disk/by-path to find the IP of the device. // Assigns prio 20 (high) to the preferred IP and prio 10 (low) to the rest. // // by Olivier Lambert <lambert.olivier.gmail.com>
Quoted 8 lines · Benjamin Marzinski
In the iet and datacore prioritizers, multipath was using sscanf to get
a string for a 255 byte buffer, without limiting the size of the string.
This could result in a buffer overflow, if there was a bad value in multipath.conf.Signed-off-by Benjamin Marzinski <[email protected]>
Quoted 7 lines · Benjamin Marzinski
In the iet and datacore prioritizers, multipath was using sscanf to get
a string for a 255 byte buffer, without limiting the size of the string.
This could result in a buffer overflow, if there was a bad value in multipath.conf.
Quoted 7 lines
Signed-off-by Benjamin Marzinski <[email protected]>---
Note:
This patch applies on top of Martin's ("libmultipath: iet prioritizer:
obtainPATH_IDfrom udev") commit, from the "tip" branch.
As that patch hasn't been verified yet, I'm going to apply your patch on the "queue" branch for now.
Regards
Martin
Signature · 4 lines
Dr. Martin Wilck <[email protected]> SUSE Software Solutions Germany GmbH, Frankenstr. 146, 90461 Nürnberg, Germany Geschäftsführer: Jochen Jaser, Andrew McDonald (HRB 36809,AG Nürnberg)