Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 Jan 2016 22:31:39 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r293647 - stable/9/sys/fs/ext2fs
Message-ID:  <201601102231.u0AMVdiF088561@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pfg
Date: Sun Jan 10 22:31:39 2016
New Revision: 293647
URL: https://svnweb.freebsd.org/changeset/base/293647

Log:
  MFC	r293370:
  ext2fs: reading mmaped file in Ext4 causes panic
  
  Always call brelse(path.ep_bp), fixing reading EXT4 files using mmap().
  
  Patch by Damjan Jovanovic.
  
  PR:		205938

Modified:
  stable/9/sys/fs/ext2fs/ext2_bmap.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/fs/   (props changed)

Modified: stable/9/sys/fs/ext2fs/ext2_bmap.c
==============================================================================
--- stable/9/sys/fs/ext2fs/ext2_bmap.c	Sun Jan 10 22:30:39 2016	(r293646)
+++ stable/9/sys/fs/ext2fs/ext2_bmap.c	Sun Jan 10 22:31:39 2016	(r293647)
@@ -96,6 +96,7 @@ ext4_bmapext(struct vnode *vp, int32_t b
 	struct ext4_extent *ep;
 	struct ext4_extent_path path = { .ep_bp = NULL };
 	daddr_t lbn;
+	int ret = 0;
 
 	ip = VTOI(vp);
 	fs = ip->i_e2fs;
@@ -113,15 +114,21 @@ ext4_bmapext(struct vnode *vp, int32_t b
 	ext4_ext_find_extent(fs, ip, lbn, &path);
 	ep = path.ep_ext;
 	if (ep == NULL)
-		return (EIO);
+		ret = EIO;
+	else {
+		*bnp = fsbtodb(fs, lbn - ep->e_blk +
+		    (ep->e_start_lo | (daddr_t)ep->e_start_hi << 32));
 
-	*bnp = fsbtodb(fs, lbn - ep->e_blk +
-	    (ep->e_start_lo | (daddr_t)ep->e_start_hi << 32));
+		if (*bnp == 0)
+			*bnp = -1;
+	}
 
-	if (*bnp == 0)
-		*bnp = -1;
+	if (path.ep_bp != NULL) {
+		brelse(path.ep_bp);
+		path.ep_bp = NULL;
+	}
 
-	return (0);
+	return (ret);
 }
 
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601102231.u0AMVdiF088561>