From patchwork Tue Jan 31 08:34:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9546717 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0870860236 for ; Tue, 31 Jan 2017 08:35:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF3272811E for ; Tue, 31 Jan 2017 08:35:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E411528210; Tue, 31 Jan 2017 08:35:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DE472811E for ; Tue, 31 Jan 2017 08:35:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751070AbdAaIfh (ORCPT ); Tue, 31 Jan 2017 03:35:37 -0500 Received: from mail-wj0-f195.google.com ([209.85.210.195]:34176 "EHLO mail-wj0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750776AbdAaIf2 (ORCPT ); Tue, 31 Jan 2017 03:35:28 -0500 Received: by mail-wj0-f195.google.com with SMTP id ip10so9873445wjb.1; Tue, 31 Jan 2017 00:35:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=B8ySqHM+4/bXOrOHVXamnxp8zmCWFekhYTMofmD7/K8=; b=UMaMF+s+fGZK5uEczBIaHK7U2Av8VsPQ9+G5VyiWTp/Xpj0piJyyn9iuOfFnHf1es1 2Q5rnAF0IFS8x8WN8hJwkK9dQQeiJ4qSPSAvKMvSdzBCxrNBynWNpQ2JZ1vN0/TAr+CD UeDYcMkmshX9DEvhkWUG5ACW7D0dbsPgFMxQSbwUripPlU4wpoH4Ffb/DjWSuVFNBnh9 PRcaXbFuIUI5AcnZA8HnMuT201UMZg9qRuojQ4fjYs371onPUu1fH4HeOkAwfyzE4fuu Y/wGIs6/uxDp8fKmcuiVlfrXQOACQz0o0yst7dNKsnjDjkLipA1zMIkveTEzWrdwXENU ACMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=B8ySqHM+4/bXOrOHVXamnxp8zmCWFekhYTMofmD7/K8=; b=RqyI3C8e8DIba8Whv1p/5swDgFgIsm6Gc8kYgD1X1Yxt1s+iuCWxuYaMyuFEYlMESN BmzSZh/SaU2fU4+4Gysc3uFIxXbGqJNhlxThkKeBlaHh0e5+zumuwrPEwTn08TsDN2d2 gAaAbMcKNaIZn0N+ZvYfCNm12sIR2mGnT7h9kBXuuzPwlt23yjaaH6iXyyEZUhsA12Lb zf6fzf5PwBOQZGkB+bLgwughvmglbVzkC1gBI61fJfmiMa2SdWUXnCFyOcEJldWqzbqX 6n+mdxHWV477V5UYPL2fDcXLseRhVeiUbjxVmDC8Pjpwalw5KykCcj80kSiNVpK7YciK PoBA== X-Gm-Message-State: AIkVDXIP01q8+PjfA3zS+eUZPXaeWpMAuxGyLUuuF6KMXCFJRgVsFvIfcGs1Fv1wxWVifg== X-Received: by 10.223.171.12 with SMTP id q12mr2991332wrc.74.1485851714913; Tue, 31 Jan 2017 00:35:14 -0800 (PST) Received: from amir-VirtualBox.ctera.local (bzq-79-176-143-83.red.bezeqint.net. [79.176.143.83]) by smtp.gmail.com with ESMTPSA id i189sm22752140wmg.7.2017.01.31.00.35.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 31 Jan 2017 00:35:14 -0800 (PST) From: Amir Goldstein To: Miklos Szeredi Cc: Jan Kara , Christoph Hellwig , Al Viro , linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org Subject: [PATCH v3 1/5] vfs: deny fallocate() on directory Date: Tue, 31 Jan 2017 10:34:55 +0200 Message-Id: <1485851699-25313-2-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485851699-25313-1-git-send-email-amir73il@gmail.com> References: <1485851699-25313-1-git-send-email-amir73il@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There was an obscure use case of fallocate of directory inode in the vfs helper with the comment: "Let individual file system decide if it supports preallocation for directories or not." But there is no in-tree file system that implements fallocate for directory operations. Deny an attempt to fallocate a directory with EISDIR error. This change is needed prior to converting sb_start_write() to file_start_write(), so freeze protection is correctly handled for cases of fallocate file and blockdev. Cc: linux-api@vger.kernel.org Cc: Al Viro Signed-off-by: Amir Goldstein Reviewed-by: Christoph Hellwig --- fs/open.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/open.c b/fs/open.c index 9921f70..f9118f4 100644 --- a/fs/open.c +++ b/fs/open.c @@ -301,12 +301,10 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len) if (S_ISFIFO(inode->i_mode)) return -ESPIPE; - /* - * Let individual file system decide if it supports preallocation - * for directories or not. - */ - if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode) && - !S_ISBLK(inode->i_mode)) + if (S_ISDIR(inode->i_mode)) + return -EISDIR; + + if (!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode)) return -ENODEV; /* Check for wrap through zero too */