From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECB2FC43331 for ; Tue, 24 Mar 2020 13:18:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C67DC20775 for ; Tue, 24 Mar 2020 13:18:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585055926; bh=3xKCGL/877hOHYYGSIi4/wtE52CtmJLcJjSARUxwV4I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=XmKi5QNoAHt1jaf1WdnQwI0b9EC/Sl1qgqDBaEtnuSLTwcGVDsmAATjNxd3uOhyAt n58EmHd38FLzEv24kKTkKpSajmwscavLKyl32w8jywpVytyZBX9diYzDjEFZZvnTUU NzRwaZK7PG7m5I/OiLL4YL8J0G+sE4ol6jwTADYE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728366AbgCXNSp (ORCPT ); Tue, 24 Mar 2020 09:18:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:38994 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728750AbgCXNSm (ORCPT ); Tue, 24 Mar 2020 09:18:42 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 59EB6208CA; Tue, 24 Mar 2020 13:18:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585055921; bh=3xKCGL/877hOHYYGSIi4/wtE52CtmJLcJjSARUxwV4I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uKOZTK024uRLe744YfAMoYwdB93khYKWQV57LGWuOfRhtrfG/q+y2rdf2FZaO4hNG d7sofPwOgJMngreWxEo7RuZF4OVzBHo4cjx3ATYH6eSF0ntsOOlJ/6sN157VbHFuB8 LyMF8Dq8bLzTOWqi5lF/+x09/eB7nSEprdSzz3Hw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Murphy Zhou , Steve French , Pavel Shilovsky Subject: [PATCH 5.4 068/102] CIFS: fiemap: do not return EINVAL if get nothing Date: Tue, 24 Mar 2020 14:11:00 +0100 Message-Id: <20200324130813.491114667@linuxfoundation.org> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200324130806.544601211@linuxfoundation.org> References: <20200324130806.544601211@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Murphy Zhou commit 979a2665eb6c603ddce0ab374041ab101827b2e7 upstream. If we call fiemap on a truncated file with none blocks allocated, it makes sense we get nothing from this call. No output means no blocks have been counted, but the call succeeded. It's a valid response. Simple example reproducer: xfs_io -f 'truncate 2M' -c 'fiemap -v' /cifssch/testfile xfs_io: ioctl(FS_IOC_FIEMAP) ["/cifssch/testfile"]: Invalid argument Signed-off-by: Murphy Zhou Signed-off-by: Steve French Reviewed-by: Pavel Shilovsky CC: Stable Signed-off-by: Greg Kroah-Hartman --- fs/cifs/smb2ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -3252,7 +3252,7 @@ static int smb3_fiemap(struct cifs_tcon if (rc) goto out; - if (out_data_len < sizeof(struct file_allocated_range_buffer)) { + if (out_data_len && out_data_len < sizeof(struct file_allocated_range_buffer)) { rc = -EINVAL; goto out; }