From nobody Sun Jun 19 15:26:37 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 51C0D878757; Sun, 19 Jun 2022 15:26:38 +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 4LQxTB1gr6z3Cqt; Sun, 19 Jun 2022 15:26:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655652398; 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=3xyX0ZFf6ipskfsiwwv3iviOQBGOJjEV5bbxvZMVcI4=; b=UQxJYes0z2/lR+JxpIqJIu2ajGvSWWzuesuKmlH7HyM2dYb9Zn8ZPYi/6Afx6ikcDAH8Bt W4ZLT7qxbU1Gog8aqBp8+K3XjwboSACH+9tFZpYogzALzeCUTmJ7qxh6k9lyo0FwlZXv4u wfFzbW5tvipa3iA1l+CqNdSpmAAhYPgzPaFWjFWy4BdRp+b8lbLNtSpHQ8K5LEYuoe2HG4 RpNuAftw0Wra4aRX1e97EleCAY32pB9VlSXcUlOBjF1ZO0fQliJAlSuufBVD/qiJS6Q+ef 9CPrEEN/VMoyAm31YSocD/xpSB+u7oZhJtqLQxWvQMz3p6qcGZ5ThoJb2R76JA== 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 146963406; Sun, 19 Jun 2022 15:26:38 +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 25JFQbq7072898; Sun, 19 Jun 2022 15:26:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25JFQbRL072897; Sun, 19 Jun 2022 15:26:37 GMT (envelope-from git) Date: Sun, 19 Jun 2022 15:26:37 GMT Message-Id: <202206191526.25JFQbRL072897@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Toomas Soome Subject: git: 942e52f776e6 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 942e52f776e6bbe016a3e920c96a1cd4dbddf7e3 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655652398; 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=3xyX0ZFf6ipskfsiwwv3iviOQBGOJjEV5bbxvZMVcI4=; b=s44VAC+AVgmxyfecCIBbDn4z9aJ5FRdGOG28J8lfRNOpZqaGGFzCP1JRoproxXpn8xkrsY 30sqZ/fnz66EqNT5j1U3M0GjbZExuGICoKVlavn5Qa/t4IDXAsfavPWUX9LU9fOYVs0/zP Lx3Rwzvc0B2UyLKfHmRqybrkHNf5J18LMAgLdU/ECTeOhXOTkBwBx3aR04fxEzAz28OlSv Uy9SujqAvAFi+432vYOp33tWIugIF1jpElB9lizcBaPSyvnlJP9XC0OkUX1L6/zBGqMgLr 9LSiwfw67AgqxXlF4tN6pvibK8zqc0hjEM5kz5VEtXj7EbhGHwYW851ul1+Asw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655652398; a=rsa-sha256; cv=none; b=SlUD0U0+XTyqde5MAGLu3Gi088+0PbB+ISWd9Lj94UPl1AIYv85BJejZBtETrtpsAev/WN 79OHV/HaKcJg5e3A9DJQJYvL4J3+Q+8HU0o7aGtxT1wWEepY9yfTCfsvVLuYCY0ghFp3NV kFA58AAN7imn0D/HYslxAJqhos9R59LSa++K7uAQ9uC8jxB7tjiEyKnwOwQUcFxbv1E1BF MhRlfXNypsvMSl5CqDhJcR6TgvMytqBm4Pf4Odgzc+O25VJ051C89LNjJIYvv9JTVXc0zZ AD7Gr77msFW12uts9g48SGTHk59N3ggLu4NaHmyUNnjcalLkadwI/ng8kCMEfA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=942e52f776e6bbe016a3e920c96a1cd4dbddf7e3 commit 942e52f776e6bbe016a3e920c96a1cd4dbddf7e3 Author: Toomas Soome AuthorDate: 2022-06-01 07:28:43 +0000 Commit: Toomas Soome CommitDate: 2022-06-19 15:26:22 +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. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D35432 --- 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;