Message ID | 20231224002820.20234-1-colyli@suse.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-10613-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp1920917dyi; Sat, 23 Dec 2023 16:28:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IFRGHr6iqjaXCPwmnDZv7iBr+CIYi+u3BvKoEESLQppKt5iRX/1JfuYewEGpB20PRhAJVnV X-Received: by 2002:a05:6808:6407:b0:3bb:a3f0:ec86 with SMTP id fg7-20020a056808640700b003bba3f0ec86mr342800oib.6.1703377733174; Sat, 23 Dec 2023 16:28:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703377733; cv=none; d=google.com; s=arc-20160816; b=WAgLgyGrppvnWcOTt8tsXrXAeXc7rFU4xJ2I3e6ex16QDNHmamVdKNXFQpEdREkHu5 gqqHgx49MxawpKbWPCtNIDPa6hTbSOBUvCeTi3RU4S48BHLsANRzSN2MydTG4xZdNyZk A+acTZefZ8ykkQD8QtLcmnk+SUI8oL5FgfnOpLxjhSkTj22AAi46UprFYOs4QOyYuu5M jeWS2PCy3bN51h9+vq911a58Q29iIM5aqaPd/gCEvyaQWqeF/KN8bBmexeZjr22g7fcX sos45BxQRLDB9YrdnuYtJMjXgK7BnjSc2wXMJ+JHTxCjXXD7CDvAmvRuwXPWvZny/h7l s3mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature:dkim-signature:dkim-signature:dkim-signature; bh=GRwt3rxs+HdNwBEMSM31p2jJ2iR9ZpXVHm+b/grQRjM=; fh=+cEl+rY5FBFS8OpKUcW1wfCvWXCSJJnJNZqZ+gIjmkQ=; b=qY6fJKmJ3PAMOa5YntrSfK7BWD9iP2x6eB4McAmU2q/+ArDLwAjklIZ+MI/JeXv7qd csFJD7dU3nijqltnB+CaGAbfGlnke3uLfnC/PQc/JHiPL8JRChxTo8jis7uhdXPfy3ju 9+4E7j4Y3Q8XWcOayzouJupkoAmE0UjqGlpeZEjiTA2AGp0S/GpqwQO06eAJuGkvIY03 kF1MAcItVikn/ukIfGbMuL138pA8HcTSM76isdytksB863AatLC+GYUqkbqVzzyH+ye8 chMEDth9DesTW6QxRAM04DCWOpag/GGZ/KxTgR4D4BLAzs+YF/5vO2PINpwJOSbs3Y04 bfRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=OBiZeFuR; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=B4RioCQ6; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=OBiZeFuR; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel+bounces-10613-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10613-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id i18-20020aa79092000000b006cbd40b46basi5524339pfa.133.2023.12.23.16.28.52 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Dec 2023 16:28:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10613-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=OBiZeFuR; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=B4RioCQ6; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=OBiZeFuR; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel+bounces-10613-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10613-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id BA3E8282409 for <ouuuleilei@gmail.com>; Sun, 24 Dec 2023 00:28:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A05B5EBB; Sun, 24 Dec 2023 00:28:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="OBiZeFuR"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="B4RioCQ6"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="OBiZeFuR"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="B4RioCQ6" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D6E719E; Sun, 24 Dec 2023 00:28:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from suse-arm.lan (unknown [10.149.192.130]) by smtp-out1.suse.de (Postfix) with ESMTP id B587321C43; Sun, 24 Dec 2023 00:28:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1703377709; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=GRwt3rxs+HdNwBEMSM31p2jJ2iR9ZpXVHm+b/grQRjM=; b=OBiZeFuRcCkVYk0dCDw+30EvT2LT4rNwYreEfvzl/G1gvFuBzST8lYkXQwQS8ZsxmsxEac 4Il0dFEvkaWCXVk28c/FFSv/yBDn4Vu1J8DeV90u2WDfnpWO3ohx+rPXxi3BFStT2Yd5GG RrZ+lFlYdylGtDKM+6S+2tQ1pPbRsvk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1703377709; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=GRwt3rxs+HdNwBEMSM31p2jJ2iR9ZpXVHm+b/grQRjM=; b=B4RioCQ63zFPioBvVUArxH93MhqIL1hDCL5ZF1vbxNCY1K/LjS2WWk8T7RtMtZz2Mi3E0h 1c7zpVNIFvTj0zDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1703377709; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=GRwt3rxs+HdNwBEMSM31p2jJ2iR9ZpXVHm+b/grQRjM=; b=OBiZeFuRcCkVYk0dCDw+30EvT2LT4rNwYreEfvzl/G1gvFuBzST8lYkXQwQS8ZsxmsxEac 4Il0dFEvkaWCXVk28c/FFSv/yBDn4Vu1J8DeV90u2WDfnpWO3ohx+rPXxi3BFStT2Yd5GG RrZ+lFlYdylGtDKM+6S+2tQ1pPbRsvk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1703377709; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=GRwt3rxs+HdNwBEMSM31p2jJ2iR9ZpXVHm+b/grQRjM=; b=B4RioCQ63zFPioBvVUArxH93MhqIL1hDCL5ZF1vbxNCY1K/LjS2WWk8T7RtMtZz2Mi3E0h 1c7zpVNIFvTj0zDw== From: Coly Li <colyli@suse.de> To: axboe@kernel.dk Cc: nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Coly Li <colyli@suse.de>, Ira Weiny <ira.weiny@intel.com>, Dan Williams <dan.j.williams@intel.com>, Geliang Tang <geliang.tang@suse.com>, Hannes Reinecke <hare@suse.de>, NeilBrown <neilb@suse.de>, Vishal L Verma <vishal.l.verma@intel.com>, Xiao Ni <xni@redhat.com> Subject: [PATCH] badblocks: avoid checking invalid range in badblocks_check() Date: Sun, 24 Dec 2023 08:28:20 +0800 Message-Id: <20231224002820.20234-1-colyli@suse.de> X-Mailer: git-send-email 2.35.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: ********** X-Spam-Score: 10.12 X-Spamd-Result: default: False [10.12 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_SPAM_SHORT(2.86)[0.953]; BROKEN_CONTENT_TYPE(1.50)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_SPAM_LONG(2.36)[0.674]; RCPT_COUNT_TWELVE(0.00)[12]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.com:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-0.00)[28.29%] X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786121009941119132 X-GMAIL-MSGID: 1786121009941119132 |
Series |
badblocks: avoid checking invalid range in badblocks_check()
|
|
Commit Message
Coly Li
Dec. 24, 2023, 12:28 a.m. UTC
If prev_badblocks() returns '-1', it means no valid badblocks record
before the checking range. It doesn't make sense to check whether
the input checking range is overlapped with the non-existed invalid
front range.
This patch checkes whether 'prev >= 0' is true before calling
overlap_front(), to void such invalid operations.
Fixes: 3ea3354cb9f0 ("badblocks: improve badblocks_check() for multiple ranges handling")
Reported-and-tested-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Coly Li <colyli@suse.de>
Link: https://lore.kernel.org/nvdimm/3035e75a-9be0-4bc3-8d4a-6e52c207f277@leemhuis.info/
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Geliang Tang <geliang.tang@suse.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: NeilBrown <neilb@suse.de>
Cc: Vishal L Verma <vishal.l.verma@intel.com>
Cc: Xiao Ni <xni@redhat.com>
---
block/badblocks.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
Comments
> 2023年12月24日 08:28,Coly Li <colyli@suse.de> 写道: > > If prev_badblocks() returns '-1', it means no valid badblocks record > before the checking range. It doesn't make sense to check whether > the input checking range is overlapped with the non-existed invalid > front range. > > This patch checkes whether 'prev >= 0' is true before calling > overlap_front(), to void such invalid operations. > > Fixes: 3ea3354cb9f0 ("badblocks: improve badblocks_check() for multiple ranges handling") > Reported-and-tested-by: Ira Weiny <ira.weiny@intel.com> > Signed-off-by: Coly Li <colyli@suse.de> > Link: https://lore.kernel.org/nvdimm/3035e75a-9be0-4bc3-8d4a-6e52c207f277@leemhuis.info/ > Cc: Dan Williams <dan.j.williams@intel.com> > Cc: Geliang Tang <geliang.tang@suse.com> > Cc: Hannes Reinecke <hare@suse.de> > Cc: Jens Axboe <axboe@kernel.dk> > Cc: NeilBrown <neilb@suse.de> > Cc: Vishal L Verma <vishal.l.verma@intel.com> > Cc: Xiao Ni <xni@redhat.com> > --- > block/badblocks.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) Hi Jens, Is it possible to take this fix into 6.7 still? Thanks in advance. Coly Li [snipped]
On Sun, 24 Dec 2023 08:28:20 +0800, Coly Li wrote: > If prev_badblocks() returns '-1', it means no valid badblocks record > before the checking range. It doesn't make sense to check whether > the input checking range is overlapped with the non-existed invalid > front range. > > This patch checkes whether 'prev >= 0' is true before calling > overlap_front(), to void such invalid operations. > > [...] Applied, thanks! [1/1] badblocks: avoid checking invalid range in badblocks_check() commit: 146e843f6b09271233c021b1677e561b7dc16303 Best regards,
On 12/23/23 5:32 PM, Coly Li wrote: >> 2023?12?24? 08:28?Coly Li <colyli@suse.de> ??? >> >> If prev_badblocks() returns '-1', it means no valid badblocks record >> before the checking range. It doesn't make sense to check whether >> the input checking range is overlapped with the non-existed invalid >> front range. >> >> This patch checkes whether 'prev >= 0' is true before calling >> overlap_front(), to void such invalid operations. >> >> Fixes: 3ea3354cb9f0 ("badblocks: improve badblocks_check() for multiple ranges handling") >> Reported-and-tested-by: Ira Weiny <ira.weiny@intel.com> >> Signed-off-by: Coly Li <colyli@suse.de> >> Link: https://lore.kernel.org/nvdimm/3035e75a-9be0-4bc3-8d4a-6e52c207f277@leemhuis.info/ >> Cc: Dan Williams <dan.j.williams@intel.com> >> Cc: Geliang Tang <geliang.tang@suse.com> >> Cc: Hannes Reinecke <hare@suse.de> >> Cc: Jens Axboe <axboe@kernel.dk> >> Cc: NeilBrown <neilb@suse.de> >> Cc: Vishal L Verma <vishal.l.verma@intel.com> >> Cc: Xiao Ni <xni@redhat.com> >> --- >> block/badblocks.c | 6 ++++-- >> 1 file changed, 4 insertions(+), 2 deletions(-) > > Hi Jens, > > Is it possible to take this fix into 6.7 still? Thanks in advance. Yep, we're still a few weeks out, so not a problem.
> 2023年12月24日 09:38,Jens Axboe <axboe@kernel.dk> 写道: > > On 12/23/23 5:32 PM, Coly Li wrote: >>> 2023?12?24? 08:28?Coly Li <colyli@suse.de> ??? >>> >>> If prev_badblocks() returns '-1', it means no valid badblocks record >>> before the checking range. It doesn't make sense to check whether >>> the input checking range is overlapped with the non-existed invalid >>> front range. >>> >>> This patch checkes whether 'prev >= 0' is true before calling >>> overlap_front(), to void such invalid operations. >>> >>> Fixes: 3ea3354cb9f0 ("badblocks: improve badblocks_check() for multiple ranges handling") >>> Reported-and-tested-by: Ira Weiny <ira.weiny@intel.com> >>> Signed-off-by: Coly Li <colyli@suse.de> >>> Link: https://lore.kernel.org/nvdimm/3035e75a-9be0-4bc3-8d4a-6e52c207f277@leemhuis.info/ >>> Cc: Dan Williams <dan.j.williams@intel.com> >>> Cc: Geliang Tang <geliang.tang@suse.com> >>> Cc: Hannes Reinecke <hare@suse.de> >>> Cc: Jens Axboe <axboe@kernel.dk> >>> Cc: NeilBrown <neilb@suse.de> >>> Cc: Vishal L Verma <vishal.l.verma@intel.com> >>> Cc: Xiao Ni <xni@redhat.com> >>> --- >>> block/badblocks.c | 6 ++++-- >>> 1 file changed, 4 insertions(+), 2 deletions(-) >> >> Hi Jens, >> >> Is it possible to take this fix into 6.7 still? Thanks in advance. > > Yep, we're still a few weeks out, so not a problem. Jes and Ira, Thank you all for fast response during holidays. Happy holidays and merry Christmas! Coly Li
diff --git a/block/badblocks.c b/block/badblocks.c index fc92d4e18aa3..db4ec8b9b2a8 100644 --- a/block/badblocks.c +++ b/block/badblocks.c @@ -1312,12 +1312,14 @@ static int _badblocks_check(struct badblocks *bb, sector_t s, int sectors, prev = prev_badblocks(bb, &bad, hint); /* start after all badblocks */ - if ((prev + 1) >= bb->count && !overlap_front(bb, prev, &bad)) { + if ((prev >= 0) && + ((prev + 1) >= bb->count) && !overlap_front(bb, prev, &bad)) { len = sectors; goto update_sectors; } - if (overlap_front(bb, prev, &bad)) { + /* Overlapped with front badblocks record */ + if ((prev >= 0) && overlap_front(bb, prev, &bad)) { if (BB_ACK(p[prev])) acked_badblocks++; else