Re: [PATCH] md: add mddev->pers to avoid potential NULL pointer dereference

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,


On 2019/4/2 11:42, NeilBrown wrote:
On Tue, Apr 02 2019, Yufen Yu wrote:

We add rdev->mddev->pers to avoid potential NULL pointer derefence
in fallowing add_bound_rdev().

Cc: Xiao Ni <xni@xxxxxxxxxx>
Cc: NeilBrown <neilb@xxxxxxxx>
Signed-off-by: Yufen Yu <yuyufen@xxxxxxxxxx>
Thanks.
I think the driver does need this fix, however:
  - with your patch it will return -EBUSY if an error is found.  I think
    it should return -EINVAL (as nothing is busy).
  - It would be good to include
     Fixes: a6da4ef85cef ("md: re-add a failed disk")

in the commit message.

Thanks a lot for your review and good suggestion. I will send v2 including these suggestion.
In addition, I think this fix need to Cc stable.

Yufen
Thanks

Thanks,
NeilBrown


---
  drivers/md/md.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 875b29ba5926..96cdad28a0d2 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2859,8 +2859,8 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len)
  			err = 0;
  		}
  	} else if (cmd_match(buf, "re-add")) {
-		if (test_bit(Faulty, &rdev->flags) && (rdev->raid_disk == -1) &&
-			rdev->saved_raid_disk >= 0) {
+		if (rdev->mddev->pers && test_bit(Faulty, &rdev->flags) &&
+			(rdev->raid_disk == -1) && rdev->saved_raid_disk >= 0) {
  			/* clear_bit is performed _after_ all the devices
  			 * have their local Faulty bit cleared. If any writes
  			 * happen in the meantime in the local node, they
--
2.16.2.dirty





[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux