From nobody Wed Sep 6 21:56:46 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Rgx6Q4nNSz4sJGd; Wed, 6 Sep 2023 21:56:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Rgx6Q3wXPz3bN6; Wed, 6 Sep 2023 21:56:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694037406; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gUFjpx+9RO0gGnnRFKWOgSy8rBFlbaBqD796XoKUqas=; b=FrEQ354lZjpcY0aRo+LrILwdBKnIFYTzIakonR46ERVEvs+p1x5QhwF32IXkehXmSrXmUs xwvazjjrDwuAZ2rhZ4IXwDr3nle+bnd7z7PSY5SfDU5TIyyBVX/C9u/Tf8lvSEx95h/R3p irPxEqIo/PKe7YnbAYcFuKE5MuEGuj3cTABbczyIEzn8QYoS5LCalr5kXZNkIuVmyTeA+P Uig35WxcwURfAnqYzDFVgj1BO8qkamHSrypMgS9atxm3pdtntSvceA+eFVCxGBoq2BSn1P I85nRkz4UuB80TOHGYh9SA2cxV+e7XTUdZUIISzjzYUe2FxWO17A3IW/ARw2CA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694037406; a=rsa-sha256; cv=none; b=jkzR/j9nTrIxPZbbg6x5PGmsb65SIQp8xwvuCLw/Wdq5d0rI45ijkAVccHHpdRd8v3IqtH KoamnFl7PlAtoqqaH17+1cvLlaxNyXq7y7V4aqo+6/t9fAZ+//QgJuu5gZbfm2STjbWEzY i7BRx/PfTwwGMIp/Z/B6jQLstev4ehxZEkJbHkUVM1tEFndoozveZdz+BRPYSv6L0IlUIg FguU7YlvT3aKpOPhXI10RHzR2TV4EdargZt2mrOO3OWtW+Pfhv7lt7TxvBWn/Kh59mqp2C WsMxl+H5n0H9bbd3vw8MdoxROnTU7rbkUFfbL+NrJzvT1scWjWvGNWN9DmpETw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694037406; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gUFjpx+9RO0gGnnRFKWOgSy8rBFlbaBqD796XoKUqas=; b=ubL6BWbAwg0v1PWJhE/ZTNJMswj87ntFs/tlpKgo31akpwU0wK8u1yp9EGJprYX850jtmp H9nGkXXf6xoDX9JY5t/q91l4BfeIqEOsi8M7zgMhVsRKDR1YZb0yOFC5mxtMj7yFF9euvI 6COJ14OQjvObVJNxnfpQyMwWCzcPMc8Bud2omzGKEyZGZ5oLAHIB87IFNaKfcyAvaOifpP sQ5RMNFZp7pwHaE4vdLEwll260XGTLz7oCrtZRUrvUGzjkpeeyQgY9u+c/kVBupLZwEYjp 8L0NwUMkpR4jvrQrAfmuHIUQTMRJZJPg4Kmdo9MJk54ZJtSp2X1ViWmcGNrWgQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Rgx6Q30kGzZ4v; Wed, 6 Sep 2023 21:56:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 386LukEb023019; Wed, 6 Sep 2023 21:56:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 386Luklj023016; Wed, 6 Sep 2023 21:56:46 GMT (envelope-from git) Date: Wed, 6 Sep 2023 21:56:46 GMT Message-Id: <202309062156.386Luklj023016@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 63f07c05de4e - stable/13 - g_raid concat: Fail requests to read beyond the end of the volume List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 63f07c05de4eed513054c5b3d1981eb4fffe5ae6 Auto-Submitted: auto-generated The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=63f07c05de4eed513054c5b3d1981eb4fffe5ae6 commit 63f07c05de4eed513054c5b3d1981eb4fffe5ae6 Author: John Baldwin AuthorDate: 2023-08-04 23:41:05 +0000 Commit: John Baldwin CommitDate: 2023-09-06 21:56:10 +0000 g_raid concat: Fail requests to read beyond the end of the volume Previously a debug kernel would trigger an assertion failure if an I/O request attempted to read off the end of a concat volume, but a non-debug kernel would use an invalid sub-disk to try to complete the request eventually resulting in some sort of fault in the kernel. Instead, turn the assertions into explicit checks that fail requests beyond the end of the volume with EIO. For requests which run over the end of the volume, return a short request. PR: 257838 Reported by: Robert Morris Reviewed by: emaste MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D41222 (cherry picked from commit 4c89c0127dcadaa0d337c23d028f3fea5e76317a) --- sys/geom/raid/tr_concat.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/sys/geom/raid/tr_concat.c b/sys/geom/raid/tr_concat.c index 159d1d76f688..9bdd37526d6a 100644 --- a/sys/geom/raid/tr_concat.c +++ b/sys/geom/raid/tr_concat.c @@ -238,8 +238,10 @@ g_raid_tr_iostart_concat(struct g_raid_tr_object *tr, struct bio *bp) offset -= vol->v_subdisks[no].sd_size; no++; } - KASSERT(no < vol->v_disks_count, - ("Request starts after volume end (%ju)", bp->bio_offset)); + if (no >= vol->v_disks_count) { + g_raid_iodone(bp, EIO); + return; + } bioq_init(&queue); do { sd = &vol->v_subdisks[no]; @@ -265,10 +267,8 @@ g_raid_tr_iostart_concat(struct g_raid_tr_object *tr, struct bio *bp) addr += length; offset = 0; no++; - KASSERT(no < vol->v_disks_count || remain == 0, - ("Request ends after volume end (%ju, %ju)", - bp->bio_offset, bp->bio_length)); - } while (remain > 0); + } while (remain > 0 && no < vol->v_disks_count); + bp->bio_completed = bp->bio_length - remain; while ((cbp = bioq_takefirst(&queue)) != NULL) { sd = cbp->bio_caller1; cbp->bio_caller1 = NULL; @@ -306,8 +306,8 @@ g_raid_tr_kerneldump_concat(struct g_raid_tr_object *tr, void *virtual, offset -= vol->v_subdisks[no].sd_size; no++; } - KASSERT(no < vol->v_disks_count, - ("Request starts after volume end (%ju)", boffset)); + if (no >= vol->v_disks_count) + return (EIO); do { sd = &vol->v_subdisks[no]; length = MIN(sd->sd_size - offset, remain); @@ -319,10 +319,9 @@ g_raid_tr_kerneldump_concat(struct g_raid_tr_object *tr, void *virtual, addr += length; offset = 0; no++; - KASSERT(no < vol->v_disks_count || remain == 0, - ("Request ends after volume end (%ju, %zu)", - boffset, blength)); - } while (remain > 0); + } while (remain > 0 && no < vol->v_disks_count); + if (remain > 0) + return (EIO); return (0); } @@ -338,7 +337,6 @@ g_raid_tr_iodone_concat(struct g_raid_tr_object *tr, g_destroy_bio(bp); pbp->bio_inbed++; if (pbp->bio_children == pbp->bio_inbed) { - pbp->bio_completed = pbp->bio_length; g_raid_iodone(pbp, pbp->bio_error); } }