From nobody Sun Jun 26 08:50:58 2022 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 2AA8487539D; Sun, 26 Jun 2022 08:50:59 +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 4LW4MR0lG3z4lPk; Sun, 26 Jun 2022 08:50:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656233459; 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=rBpO+fqJcZSsYJX/OJgmVvklz7u/NLhJ56ptK4h30ik=; b=uZ2byKf7kuYPWw7qsX0cMqAszdOqCLCgSkqJ6sxTiKpCTUFyQrTEnOXgF1VxxW7L5KeXJW BCebDzdfl4igUMNLmgxjd82lWr43eJoa7VQEY61nMSJa5OAocOsiozblumcV04w2QGrn3r 2zcYnF+k/1/RgadEERsDV6tMb2h/6qIGnlLS8DqNL6NHWYNd2igdl3MgdQ0ExgxHYwRLvf AFrkMhygZ0tMyvQdmDx/bEb6X1sPx83wuJ2p+YFa50qrJN2ONTqY8LdMAk5Wm0NTDXEucT BCx3FPY1r9Kn/lBDyZtkcE2lWdrkUOCjO9rjcvfDLy36jW4EGuFU+yaqAKAObw== 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 EE4481421D; Sun, 26 Jun 2022 08:50:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25Q8owho013022; Sun, 26 Jun 2022 08:50:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25Q8owKe013021; Sun, 26 Jun 2022 08:50:58 GMT (envelope-from git) Date: Sun, 26 Jun 2022 08:50:58 GMT Message-Id: <202206260850.25Q8owKe013021@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Toomas Soome Subject: git: 39510c65e376 - stable/13 - test_diskread(): detect end of the disk 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: tsoome X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 39510c65e376dad3948061d658d8290e25b504de Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656233459; 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=rBpO+fqJcZSsYJX/OJgmVvklz7u/NLhJ56ptK4h30ik=; b=ZICN3+Qf6lAUAAH8uEjA3begVf2ewHrUKdyU/TL8siOptG87jAeRRrm2tVP6YtQ2liEZLF c1mUU0jSn/2Nm49z9cYHKJm1CXSgzgPm5rY28sO+jQ2FNvvJRlp7YQFF0ElWvUucopk+G6 yy98EHskDUbQj/Hjme544+3rd3o99I92sy/3Xr5VVfh7mgHad7SFj1r2GUfdWpxqtn5nd7 NXzr5WF3UvmzTko5PE8J+2YKu+xY+VF2qnObgSXeYerqZS2LC+Duo87D+SF+sgLxpbHikm +lLAZ0xBAfsKBcJTotr1NW+AfTm1es/kBObBecUgnDOnQJ+dQlv+w1c9voQt9Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656233459; a=rsa-sha256; cv=none; b=JzaFrzCsoF5XMX5u35cPQvenfsYZcM1Anq8cUoIKiOTEt+ghiAAl+YnLIlE1cNDjuuWSnm JfYtDaeyi3Izt0pbHpv9QFNWozTaSWNE0SgE3ZRGj6X0/mup9aZ54v4/1emZm1CRoKf01n wbxr/OYM/6RNqT41HBmGrGVxD+YwzagQeyIYSLbhIYSicca4DoH9GevyusMARJ81qKLiM0 Io+oqiA7oAv5qXdY3uPdISvqMiw1q/1smf1sHAUL9le0el4th/lqDX1PUNkIhDEosD2T+U mwgHOSJ+SNoz5e+ZFDvVxmrA+fukRx8HJP43OEWil2cu2W4qvrA2L6Y9WjvSFg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=39510c65e376dad3948061d658d8290e25b504de commit 39510c65e376dad3948061d658d8290e25b504de Author: Toomas Soome AuthorDate: 2022-06-01 07:28:43 +0000 Commit: Toomas Soome CommitDate: 2022-06-26 05:28:07 +0000 test_diskread(): detect end of the disk Detect the end of the disk condition. This may happpen when disk image is truncated and the reads are addressing blocks past image end. Differential Revision: https://reviews.freebsd.org/D35432 (cherry picked from commit 942e52f776e6bbe016a3e920c96a1cd4dbddf7e3) --- stand/userboot/test/test.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/stand/userboot/test/test.c b/stand/userboot/test/test.c index baf1b6243c1f..4ad18176ba6e 100644 --- a/stand/userboot/test/test.c +++ b/stand/userboot/test/test.c @@ -254,6 +254,11 @@ test_diskread(void *arg, int unit, uint64_t offset, void *dst, size_t size, if (unit > disk_index || disk_fd[unit] == -1) return (EIO); n = pread(disk_fd[unit], dst, size, offset); + if (n == 0) { + printf("%s: end of disk (%ju)\n", __func__, (intmax_t)offset); + return (EIO); + } + if (n < 0) return (errno); *resid_return = size - n;