From nobody Wed Sep 6 21:57:01 2023 X-Original-To: dev-commits-src-branches@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 4Rgx6j75P2z4sJPB; Wed, 6 Sep 2023 21:57:01 +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 4Rgx6j6LV6z3ccW; Wed, 6 Sep 2023 21:57:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694037421; 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=/VMfFO796Z/cj4bOlXVfxPil3Suyp0zvuRpbX0jKndo=; b=tF7C4g4NBPozf1jG4SkOCi8nCHMI5T8ASRBxDLK16rciETyHaGaZPmlkySnq7CKp5dHhGn biwNZ/nEHU2Jf0AsOMDI8Vg8CsJVjYt0Y9/esqMYqDLivfnqaiqcd6PCVZZVwMPsq+OrfQ JvuGkpFC25Y5ApBGZQ5UOTShLdtcsZeYlTN+sp/jVsP7kEMSaMn1a3Em2yyOncrU3Fj+IG iG4I9iqFxaG1nJutuA5wMo76bey0oH3y16uRXAHFhMR6JkqXo8qBbKCxlSP3QF5qRYJqtN PFg0WNLPsDuLN5R/enRy/TA+Er7ULNctzgREOJuCd/fJ3bo/LLgVyTanB44XKw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694037421; a=rsa-sha256; cv=none; b=lEQhDvu649HRbqT4flSvSmcfJI0ecjcJzqOhQBKoo6SuipLBZphrOTq4ohNAqHs+q0XLnH nP79O0RHmA4/7qjz+097Nb74SP4lxHh0pZ1rhtvFhMbkPlaY5P7UsNxSz5YMjh0NFtI3r4 MpvmrxmrMSoJhekIqI0qGCQ1dtMAWBAek+JoZdfqzQXCv9z1b4FtqQCX/5xoYIKlA6Ux0b mDWLdaHRXiFMgdarc9NWULrhsrwl9fufb0z8s9oSA3Q3v7bJz8KgOCA8zp7NGfEUiqRuep whPIM0c9RlY+3LBKNFId+L1aYyf8ofK1dNaix5RPMCk1QH4N4tzwtAgjJ/c3xA== 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=1694037421; 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=/VMfFO796Z/cj4bOlXVfxPil3Suyp0zvuRpbX0jKndo=; b=a3jf+Bx6s0M7+I3Q5Fb4fewAudCrvgGevLelwerUUkEq65Krgc6HAFX5P3fLVndb+7weYj mJKQPXVze2Bzpq81zbM1LoYZcLPx8nfi8NW5m6Vst1QBT3JZC+W7/ZYN6AqXP6OGDKv3e1 +8WDHoKxT+dTYqGsQ+UvORYwEbddbdmegZhjQANF/xkI66/U5t1rOKrupxz9jNRcD557Xu 9H2Anwii29Eu7VxlAfM1p9N9K95j22H+i0cKiwPlzMpGS3bF0WQnA/1Slxzup+Ntuq+Ymp CazcJb2Ez1ExU3QVv/QPxv3lgM2ipVKdmUFk7enYX1+Ko3xg+Qbash/2sObs4Q== 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 4Rgx6j5DCMzZ6J; Wed, 6 Sep 2023 21:57:01 +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 386Lv1Ub023673; Wed, 6 Sep 2023 21:57:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 386Lv1Nm023670; Wed, 6 Sep 2023 21:57:01 GMT (envelope-from git) Date: Wed, 6 Sep 2023 21:57:01 GMT Message-Id: <202309062157.386Lv1Nm023670@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: 0db7f4b419db - stable/12 - udf: Reject read requests with an invalid length List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/12 X-Git-Reftype: branch X-Git-Commit: 0db7f4b419dbaa2c23a737393d35564cd0b2f35a Auto-Submitted: auto-generated The branch stable/12 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=0db7f4b419dbaa2c23a737393d35564cd0b2f35a commit 0db7f4b419dbaa2c23a737393d35564cd0b2f35a Author: John Baldwin AuthorDate: 2023-08-04 23:40:19 +0000 Commit: John Baldwin CommitDate: 2023-09-06 20:02:33 +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 33bf4539c41b..507c75692433 100644 --- a/sys/fs/udf/udf.h +++ b/sys/fs/udf/udf.h @@ -97,8 +97,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 af249e91ed9d..0e450da83808 100644 --- a/sys/fs/udf/udf_vfsops.c +++ b/sys/fs/udf/udf_vfsops.c @@ -478,6 +478,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;