Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:43796 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754161AbcFEWDP (ORCPT ); Sun, 5 Jun 2016 18:03:15 -0400 Subject: Patch "Btrfs: fix unexpected return value of fiemap" has been added to the 4.5-stable tree To: bo.li.liu@oracle.com, dsterba@suse.com, gregkh@linuxfoundation.org Cc: , From: Date: Sun, 05 Jun 2016 14:48:36 -0700 Message-ID: <1465163316218135@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org List-ID: This is a note to let you know that I've just added the patch titled Btrfs: fix unexpected return value of fiemap to the 4.5-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: btrfs-fix-unexpected-return-value-of-fiemap.patch and it can be found in the queue-4.5 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >From 2d324f59f343967a03eeb2690f0ff178304d0687 Mon Sep 17 00:00:00 2001 From: Liu Bo Date: Tue, 17 May 2016 17:21:48 -0700 Subject: Btrfs: fix unexpected return value of fiemap From: Liu Bo commit 2d324f59f343967a03eeb2690f0ff178304d0687 upstream. btrfs's fiemap is supposed to return 0 on success and return < 0 on error. however, ret becomes 1 after looking up the last file extent: btrfs_lookup_file_extent -> btrfs_search_slot(..., ins_len=0, cow=0) and if the offset is beyond EOF, we'll get 'path' pointed to the place of potentail insertion, and ret == 1. This may confuse applications using ioctl(FIEL_IOC_FIEMAP). Signed-off-by: Liu Bo Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/extent_io.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -4385,8 +4385,12 @@ int extent_fiemap(struct inode *inode, s if (ret < 0) { btrfs_free_path(path); return ret; + } else { + WARN_ON(!ret); + if (ret == 1) + ret = 0; } - WARN_ON(!ret); + path->slots[0]--; btrfs_item_key_to_cpu(path->nodes[0], &found_key, path->slots[0]); found_type = found_key.type; Patches currently in stable-queue which might be from bo.li.liu@oracle.com are queue-4.5/btrfs-fix-unexpected-return-value-of-fiemap.patch queue-4.5/btrfs-do-not-create-empty-block-group-if-we-have-allocated-data.patch queue-4.5/btrfs-fix-divide-error-upon-chunk-s-stripe_len.patch