From patchwork Fri Jul 21 17:29:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 9857443 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 ACA5C600F5 for ; Fri, 21 Jul 2017 17:30:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9382028684 for ; Fri, 21 Jul 2017 17:30:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87D66286A2; Fri, 21 Jul 2017 17:30:47 +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_SIGNED, 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 2BFA528684 for ; Fri, 21 Jul 2017 17:30:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754688AbdGUR3l (ORCPT ); Fri, 21 Jul 2017 13:29:41 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:34743 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754231AbdGUR3N (ORCPT ); Fri, 21 Jul 2017 13:29:13 -0400 Received: by mail-qt0-f194.google.com with SMTP id o3so3120247qto.1 for ; Fri, 21 Jul 2017 10:29:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=uQKdEqv2yM94W+1UckDhzsXYao1Sc6U7vQvxLFVwx1M=; b=o4lgWf5SW2oxEaok+TWwh303FulQ8a6JnBBPslAR8u3lxCpcPxrJFcw1aLvq0D+/je bFpnWuDgILV1R/LRJ0G9stpFL4Ux1JymyJTaj9jDGOw2Fo1PZBQX+pDARlu2yOW5idh9 R7yw1tjv/kcV64tj4KRlpygMQgwu15FfBIEwH0/7QmdtMAGSbDq3mNCRljbG7QI7TuG3 Yq9TSScHVIpjoe2ZrJW1LrciW0quVXx0Dhy5GE+Fzh5E9PW2rubeQVfe3kHUDBTqRowr AM8Q4Uf1yYNUBiOjG9ZvIAgd+mS4eq8wlhGfBCkRN4O0AGt+sZMcVCNvBjVeLHYg4vtv 50Ew== 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; bh=uQKdEqv2yM94W+1UckDhzsXYao1Sc6U7vQvxLFVwx1M=; b=dNhrOcm+LVrCI6fYp1DRCz41FaDhE1LhmX2KeRLeyu2fM27rqE3ItGPuM23AejOwwF NxlUpNM6KD353j1fM1Y/nKN5vhfPVSQAx3aQFEcmQCZ4xqmoo/4Bf2/C5VREWeWbGOu9 YmhWqA0vXM2y5YucskuvyimQy6tqQ81vfaxqDzm+OaR7E63mM0pZW9lrbjANqUnUDqZt kalF51Wh2iUTGMxz4zdYyKzF/Z92O7VXpJ3x+a7vPa2dtR7KJtCEk+1GOvFFk5Vr+yXa 6x1ya72fsvq3/LfyWnoZlD9XhVLil5wOgFZ3Fu0W2qdAllYckH5LxNyDG+gvQHv7/Ehc Em4Q== X-Gm-Message-State: AIVw111w0RtwL8x3MGFnK4fpI8nXN8gdvYkoFkCsQ0jU7nb4MqHjXc5h 7x2X3HLnvhVyl3of8QiA1w== X-Received: by 10.237.40.69 with SMTP id r63mr10970288qtd.72.1500658150986; Fri, 21 Jul 2017 10:29:10 -0700 (PDT) Received: from localhost ([2606:a000:4381:1201:225:22ff:feb3:e51a]) by smtp.gmail.com with ESMTPSA id s2sm3649604qkh.31.2017.07.21.10.29.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Jul 2017 10:29:10 -0700 (PDT) From: josef@toxicpanda.com X-Google-Original-From: jbacik@fb.com To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Cc: Josef Bacik Subject: [PATCH 1/3] btrfs: don't allow trans ioctl on a directory Date: Fri, 21 Jul 2017 13:29:07 -0400 Message-Id: <1500658149-20410-1-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 2.7.4 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Josef Bacik We need to use file->private_data for readdir on directories, so just don't allow user space transactions on directories. Signed-off-by: Josef Bacik --- fs/btrfs/ioctl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index bedeec6..ddb3811 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -3968,6 +3968,9 @@ static long btrfs_ioctl_trans_start(struct file *file) struct btrfs_trans_handle *trans; int ret; + if (S_ISDIR(inode->i_mode)) + return -EINVAL; + ret = -EPERM; if (!capable(CAP_SYS_ADMIN)) goto out;