From nobody Sat May 6 21:00:50 2023 X-Original-To: bugs@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 4QDKhg5vtVz497YC for ; Sat, 6 May 2023 21:00:51 +0000 (UTC) (envelope-from bugzilla-noreply@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 4QDKhg2rsgz434t for ; Sat, 6 May 2023 21:00:51 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683406851; 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=FPCMi2HujewBJBsR2daisD9myj1B/7dn21yE6GIAbpE=; b=FwdZ28QXkEjSUhQLTRSspHH80GJb/VawUUpzmoEZhbDNWb2TvEORVSCoMSx9bkZ6MAEQbx AQBpO0JYPPJnzj01HIuEqEoZkrnVvatlfWxQ8z+9jx5B6owi6DOE1ZAOJrRcwYEnp29/d6 jwjy2WPqSHrHHgnYMsBeB5/ej2NKoV+jCvmHwpDCNus6c/X3IdI/iLnJevfOnk6JkLx6ik AguenzZSgRF44CoEOadriBaJlc3FF37Xd2FDR2TaFwwMoI8kGWB/btgJZxqEJWm7WAaHWu LgaQWb2G3llhQLmrtmhdnW7Jss4azHvtf0WGTF26FmH8QRPZYXHs4UcwW7AYbw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1683406851; a=rsa-sha256; cv=none; b=riHRuadoO4rvqDSwCTPPHYLf3/AG+ZnoxPKdYThJBwehVIpg3YBvANKP3VihHAU+18/n9b fjQc2na62QIaYmVFmWOrD6/k9pXFIxXwF2vPu4OEmw5DVw25wgn4L5s96+GEFWPo9GW5rz okuEuXCMirzUCG1JsRoGQp+ZOTdE5e+H4DpzUTK9QKcR6fIPWuSXp7Y4q2J1QtA+p6IsR3 UMNx5UtVvvT+u24g+dMPVz19mggu7bi0T0VofR6l11H9hlvtMalMR+kEt8w1vxng/MuOt4 fC9OQdhs3vSySonzHWFCO47IIQ6oNiwiBmcawG7cxhqnBxglse08SL7Bco96gA== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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 4QDKhg1yDRzrLw for ; Sat, 6 May 2023 21:00:51 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 346L0p2A014556 for ; Sat, 6 May 2023 21:00:51 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 346L0peD014555 for bugs@FreeBSD.org; Sat, 6 May 2023 21:00:51 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 271289] off-by-one error in fsck_ffs chkrange() block-number check Date: Sat, 06 May 2023 21:00:50 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: rtm@lcs.mit.edu X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D271289 Bug ID: 271289 Summary: off-by-one error in fsck_ffs chkrange() block-number check Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: rtm@lcs.mit.edu Created attachment 242024 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D242024&action= =3Dedit broken ffs image that causes off-by-one block-number check error in fsck In this code in src/sbin/fsck_ffs/inode.c, I think the "blk > maxfsblock" should be >=3D. The cnt - 1 ... check also looks off by one. int chkrange(ufs2_daddr_t blk, int cnt) { int c; if (cnt <=3D 0 || blk <=3D 0 || blk > maxfsblock || cnt - 1 > maxfsblock - blk) { if (debug) printf("out of range: blk %ld, offset %i, size %d\n= ", (long)blk, (int)fragnum(&sblock, blk), cnt); return (1); } I've attached a broken file-system image with an i-node that refers to a block number that's one too large (64): % cp fsck4b.img junk % fsck_ffs -y junk On my CURRENT amd64 machine this yields a core dump, due to writing beyond the end of blockmap[] and corrupting the next heap block, which happens to contain a struct inoinfo in inphash[]. valgrind catches the blockmap[] access. --=20 You are receiving this mail because: You are the assignee for the bug.=