From patchwork Thu Dec 7 08:37:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khalid Elmously X-Patchwork-Id: 845462 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3yspm03nfPz9s71; Thu, 7 Dec 2017 19:38:24 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1eMrhE-0005Cx-RV; Thu, 07 Dec 2017 08:38:20 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1eMrhC-0005AP-HZ for kernel-team@lists.ubuntu.com; Thu, 07 Dec 2017 08:38:18 +0000 Received: from mail-it0-f69.google.com ([209.85.214.69]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1eMrhC-0006xS-6t for kernel-team@lists.ubuntu.com; Thu, 07 Dec 2017 08:38:18 +0000 Received: by mail-it0-f69.google.com with SMTP id k186so9922330ith.1 for ; Thu, 07 Dec 2017 00:38:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=nZqMRYKqLe0AQh4rJNCNB9jOafc9A+SUJpq6s/vttZ0=; b=UUsd7NFQ2sfq1jeLnOGlrn6/DxMcCBSaqi1XqQjE6OWTzThe1PMdMosJCccwkVf2HB aABCLgkusckF4EZEZ3Is5QjTQ5VTiblZcFQ5tQqTBNQb32AscezGR6PXRwODLpXyRFVe dCayFlJ4FMGMtdXyfsmNnedQnjUgoQNXqMYYqsnsM4LNDCxlfhJ/Gu1RJr+wCF4Bn799 8a2k5RQDha0waccyIU0c7EqlNXnuvcFwx9odWEupUfxOsNKKmIBbiDx4ow7W9CG+jS5D rU+rS9h50bmGw0g+dazzXMGRSLUBs0cQdVjMjov1Cs62LrGL6rFe48wD8CSPPAFAaAHf Qklw== X-Gm-Message-State: AKGB3mJcll8aB+YIvsd7L6aJ8cfEedSQJQE+KuJpRneN1ffD322xhrqJ jQzvKFnAyQ4SVnhm6jF9yA2vE3BsYFv2S5ijTEssfkTQM/EAO9C70musR08ZtGCuSi1gAjDsb4g GpB2vXPLSRO+33QCTo1z0N7KNynclFWq1+NUI2bng7Q== X-Received: by 10.36.218.6 with SMTP id z6mr448409itg.24.1512635897002; Thu, 07 Dec 2017 00:38:17 -0800 (PST) X-Google-Smtp-Source: AGs4zMb8T67N3HdiDr4C3rUpOp5rZqqYo7qtQkLh8x1YzgsQ3aoJ8YGj++OjThXiYANB6R5r0yEoZw== X-Received: by 10.36.218.6 with SMTP id z6mr448403itg.24.1512635896816; Thu, 07 Dec 2017 00:38:16 -0800 (PST) Received: from kbuntu.fuzzbuzz.org (198-84-180-157.cpe.teksavvy.com. [198.84.180.157]) by smtp.gmail.com with ESMTPSA id i203sm2551981itb.40.2017.12.07.00.38.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 00:38:15 -0800 (PST) From: Khalid Elmously To: kernel-team@lists.ubuntu.com Subject: [Xenial][PATCH 6/9] ceph: Propagate dentry down to inode_change_ok() Date: Thu, 7 Dec 2017 03:37:54 -0500 Message-Id: <82ea3ab113849578f6cb4851a9dd179cf03a8e2d.1512634014.git.khalid.elmously@canonical.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: References: In-Reply-To: References: X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: http://bugs.launchpad.net/bugs/1415636 commit fd5472ed44683cf593322a2ef54b9a7675dc780a upstream. To avoid clearing of capabilities or security related extended attributes too early, inode_change_ok() will need to take dentry instead of inode. ceph_setattr() has the dentry easily available but __ceph_setattr() is also called from ceph_set_acl() where dentry is not easily available. Luckily that call path does not need inode_change_ok() to be called anyway. So reorganize functions a bit so that inode_change_ok() is called only from paths where dentry is available. Reviewed-by: Christoph Hellwig Acked-by: Jeff Layton Signed-off-by: Jan Kara Signed-off-by: Khalid Elmously --- fs/ceph/acl.c | 5 +++++ fs/ceph/inode.c | 15 +++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c index 722c93f84ef4..b2f248fa2724 100644 --- a/fs/ceph/acl.c +++ b/fs/ceph/acl.c @@ -123,6 +123,11 @@ int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type) goto out_free; } + if (ceph_snap(inode) != CEPH_NOSNAP) { + ret = -EROFS; + goto out_free; + } + if (new_mode != old_mode) { newattrs.ia_mode = new_mode; newattrs.ia_valid = ATTR_MODE; diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 5db076410d23..4e544cf34cc1 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -1787,13 +1787,6 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr) int inode_dirty_flags = 0; bool lock_snap_rwsem = false; - if (ceph_snap(inode) != CEPH_NOSNAP) - return -EROFS; - - err = inode_change_ok(inode, attr); - if (err != 0) - return err; - prealloc_cf = ceph_alloc_cap_flush(); if (!prealloc_cf) return -ENOMEM; @@ -1998,9 +1991,15 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr) int ceph_setattr(struct dentry *dentry, struct iattr *attr) { struct inode *inode = d_inode(dentry); - int err; + if (ceph_snap(inode) != CEPH_NOSNAP) + return -EROFS; + + err = inode_change_ok(inode, attr); + if (err != 0) + return err; + err = __ceph_setattr(inode, attr); if (err >= 0 && (attr->ia_valid & ATTR_MODE))