From nobody Wed Sep 06 21:56:45 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 4Rgx6P3JKzz4sJK3; Wed, 6 Sep 2023 21:56:45 +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 4Rgx6P2qvFz3bb4; Wed, 6 Sep 2023 21:56:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694037405; 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=RoASV7r5l4x1PooNoWKBg2Vf8ahxhLQ0w71n1gLDieI=; b=tpVefrMKO4mUYjBIUKVo6hHYbZ6e1HMsFtmpkEP6//sXD52T/Bl4GvQ6PM2DikVbGsi1yV 3zU4bgikkuJbezGA94b1Kagx4d6iz5AqN8ylWMASwz5I0OYVSLKVHCGG2HpnPPcFqpEeZU 7wF6tg298saI/yuc3tdE37JcXxBJNDGwphCyqaKXqGpPcWlJbWITRjiRDcYbRmDEvCBwf4 J5LmVJ3f79X+Ei3s/8aMMWO4n8Ddlq3wXVhnaPMP2qhqodlo8OTqzOkPOuRSXNw0vFh4hO LgJ3gXwyZfUErcvs7BcQJ4K77udow9XLdTvoxtNqQUirVJUT+4nSFdlcO4jzQQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694037405; a=rsa-sha256; cv=none; b=ijZutYCbxGoIW+9A0uVGKjCbxbv+yJjCUDWrjr6fZVYRBcpem7/9UZJTSYId133/Srmv6r BHODfP0TJM8mfMlgW0S5RjgAtESX/BtXNs5fqwcTv+zsfGV8N+0cuxGEw5fpDw8GnXoQ3I pAdZad37YVavcScanjAiwgwRh/DIMsTanrHEOfXjJftzQOaFYiMuJuKQvWuZhMBlW22y8w dIjWqPjCBM4dJMYhYWY1KJPJusp1vXbsEuKkzvBtXiF0jmh6KaxklWVpiTIbSEZOfadKSi StTSs2fYIAjKhBdUVNzkoL1W2zL9Oq1LeZBGacIyGOvUijUhYfaXB1yrwsYIPg== 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=1694037405; 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=RoASV7r5l4x1PooNoWKBg2Vf8ahxhLQ0w71n1gLDieI=; b=A8Anigt++ikd9o6NdraiqpvacJvvw8l376kkw4uNn/flSXO286Del6RnGEtOSnaBuFfz7/ Da8BGcWDMbzMxMNlIA+KJiOuO8UITtYPmFOc7k6c5IJBPHuisXmHXR7eQ63fnyjFOxccXi VhVkFm0dEa3CEOnSJTSdJXo1+GiUuQnxCR6lTIq7JVCT+/90WUSQqgOXyS/RKorC/B2y7p J1uRmeqM5P+TpTQ/CDY2hw6rvLvVIerkVblpgWcYOvO/9G3zGcEzt+8SpM/W8k7euguG4j ib1iu2UhK/Pi0/XWPdXGtH45ALNVvNWp7nAURoU4VH2IQ/YoI/N74GQOcDQQRA== 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 4Rgx6P1xYWzYrv; Wed, 6 Sep 2023 21:56:45 +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 386LujRt022955; Wed, 6 Sep 2023 21:56:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 386LujPm022952; Wed, 6 Sep 2023 21:56:45 GMT (envelope-from git) Date: Wed, 6 Sep 2023 21:56:45 GMT Message-Id: <202309062156.386LujPm022952@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: 202c1d762186 - stable/13 - udf: Reject read requests with an invalid length 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: 202c1d76218695ec094f289dbb23e96310eae2c1 Auto-Submitted: auto-generated The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=202c1d76218695ec094f289dbb23e96310eae2c1 commit 202c1d76218695ec094f289dbb23e96310eae2c1 Author: John Baldwin AuthorDate: 2023-08-04 23:40:19 +0000 Commit: John Baldwin CommitDate: 2023-09-06 21:56:09 +0000 udf: Reject read requests with an invalid length - If the size is negative or if rounding it up to a multiple of the block size overflows, fail the read request with ERANGE. - While here, add a sanity check that the ICB length for the root directory is at least as long as a minimum-sized file entry. PR: 257768 Reported by: Robert Morris MFC after: 1 week Sponsored by: FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D41220 (cherry picked from commit c70e615051b00671d54651d99af5cdec4b091d92) --- sys/fs/udf/udf.h | 4 +++- sys/fs/udf/udf_vfsops.c | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/fs/udf/udf.h b/sys/fs/udf/udf.h index 31e63f1ffb05..c8f5191546c2 100644 --- a/sys/fs/udf/udf.h +++ b/sys/fs/udf/udf.h @@ -95,8 +95,10 @@ struct ifid { MALLOC_DECLARE(M_UDFFENTRY); static __inline int -udf_readdevblks(struct udf_mnt *udfmp, int sector, int size, struct buf **bp) +udf_readdevblks(struct udf_mnt *udfmp, daddr_t sector, int size, struct buf **bp) { + if (size < 0 || size + udfmp->bmask < size) + return (ERANGE); return (RDSECTOR(udfmp->im_devvp, sector, (size + udfmp->bmask) & ~udfmp->bmask, bp)); } diff --git a/sys/fs/udf/udf_vfsops.c b/sys/fs/udf/udf_vfsops.c index eb9e6f3fc370..efc216bc7635 100644 --- a/sys/fs/udf/udf_vfsops.c +++ b/sys/fs/udf/udf_vfsops.c @@ -480,6 +480,11 @@ udf_mountfs(struct vnode *devvp, struct mount *mp) */ sector = le32toh(udfmp->root_icb.loc.lb_num) + udfmp->part_start; size = le32toh(udfmp->root_icb.len); + if (size < UDF_FENTRY_SIZE) { + printf("Invalid root directory file entry length %u\n", + size); + goto bail; + } if ((error = udf_readdevblks(udfmp, sector, size, &bp)) != 0) { printf("Cannot read sector %d\n", sector); goto bail;