Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp284312ybz; Fri, 17 Apr 2020 00:51:18 -0700 (PDT) X-Google-Smtp-Source: APiQypJ3i1X+OBUWN4itZH/pv4dgOMJ2S35xPRpfzbBARQA7rAY4kWZS4Wh+bQHZJoffO+tDYuth X-Received: by 2002:a17:906:68cf:: with SMTP id y15mr1743933ejr.260.1587109878443; Fri, 17 Apr 2020 00:51:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587109878; cv=none; d=google.com; s=arc-20160816; b=dFB3ydQsC4YnxzLVzTz9CUDpx7xj2oDaN/fADc0fzYP6C6dWKMdSoxueZS8Vj9NQg3 uSiqqtBxpvSmdiiIsLcuVtJgY5jXJsJphQZ7VVIPWxb7SlIfC/9Dh1pA7l7l00sSkB4/ gIKVIKj/efJb8jw484hc8UB5jzEFhzoc/tElhQUmwWnOIE0p8SS4PllVoyXnw1IaTrFP JlId3/HfHrFw1iXvzLvZj7G8c3FDklc63wm18zy9NA3CAoDGEvddy+wR7KByBTDK0ekg zSRo3Vapzd45aBzcfWSX1W7KGTVjmn1+smLi5ICIrQps5ugE5ASm/lIAeVWMjwQF9HhY m0mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=IbtRDHeXY7VovT/RwD90Ly8E9e+8aBda8njkL5CwpAc=; b=oZICHjn6YG11X2tlXNbpchJJh1LLIfMlxyG1VH9yAJmvd9Pjt8yPtYj9/z05Co28u0 BOhSTvLK0gYHku+pS45L61YRWA3EI13mkvXbuL66cVpSkzIYjTysJ3mZDEJV5ixMkiAK jLftl9mS5XiitoAQAlJG6mtpCm2oXKTDs46AXFz28Chni4Oe3jkeX8eGfLFQ7lVF7GIw dRxRvp+qG7g9mR7fJjcwUwUXLR1ea/5aW2SUrIFXJlcLlmNM0d3CElKV4uesgzR4PSGB 8gHs4i4+8lyRtBgPHYxOWBW9oMIkejM3sKkCB8NEusO7Zz+SI53snhShtSm/4n9+sPcM 5Q0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=SUqGLpxh; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cm6si341872edb.71.2020.04.17.00.50.45; Fri, 17 Apr 2020 00:51:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=SUqGLpxh; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729093AbgDQHuE (ORCPT + 99 others); Fri, 17 Apr 2020 03:50:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728543AbgDQHuD (ORCPT ); Fri, 17 Apr 2020 03:50:03 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9C77C061A0C; Fri, 17 Apr 2020 00:50:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=IbtRDHeXY7VovT/RwD90Ly8E9e+8aBda8njkL5CwpAc=; b=SUqGLpxhIqfIeRMBzoRt936Zlh bg9S/0G2P1ihadANO26/GThhpUVq1tCYjo+STsS6x8iRVOVjGe/17r7zRm8TPb9lKHT7aOi4hGmbn TFNPu4U598fw6FjRgUnfIG9BL/bvZwI+w3fQ+6l4pFEk/94cW0kGDSXFq9PdZORQaEpsg1venTxOl 97bMicFbdvsxGTEXcnyJv0RL40L1tr+gsOoXMfiAh9zl0C9ohjzWIrExIuPSgGRZC+yUpC0MugT4c mEmjIUB6U06WzSB+cgVH1sjiiDtCU5a9IhDYsKYQxcjPDpTFx91xQSdhgVVzZm+o7Hfom7+rTUbxy n7uZGdBg==; Received: from hch by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPLlC-0005no-T7; Fri, 17 Apr 2020 07:50:02 +0000 Date: Fri, 17 Apr 2020 00:50:02 -0700 From: Christoph Hellwig To: Max Kellermann Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, trond.myklebust@hammerspace.com, bfields@redhat.com, tytso@mit.edu, viro@zeniv.linux.org.uk, agruenba@redhat.com, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v3 2/4] fs/ext4/acl: apply umask if ACL support is disabled Message-ID: <20200417075002.GB598@infradead.org> References: <20200407142243.2032-1-mk@cm4all.com> <20200407142243.2032-2-mk@cm4all.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200407142243.2032-2-mk@cm4all.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org This looks correct (modulo some minor coding style derivations), but I think the better fix is to reuse the poix_acl_create functionality rather than duplicating it. Something like this: diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c index 8c7bbf3e566d..6cff7cc31866 100644 --- a/fs/ext4/acl.c +++ b/fs/ext4/acl.c @@ -268,33 +268,17 @@ ext4_set_acl(struct inode *inode, struct posix_acl *acl, int type) /* * Initialize the ACLs of a new inode. Called from ext4_new_inode. * - * dir->i_mutex: down * inode->i_mutex: up (access to inode is still exclusive) */ int -ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir) +ext4_init_acl(handle_t *handle, struct inode *inode, int type, + struct posix_acl *acl) { - struct posix_acl *default_acl, *acl; - int error; + int error = 0; - error = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl); - if (error) - return error; - - if (default_acl) { - error = __ext4_set_acl(handle, inode, ACL_TYPE_DEFAULT, - default_acl, XATTR_CREATE); - posix_acl_release(default_acl); - } else { - inode->i_default_acl = NULL; - } if (acl) { - if (!error) - error = __ext4_set_acl(handle, inode, ACL_TYPE_ACCESS, - acl, XATTR_CREATE); + error = __ext4_set_acl(handle, inode, type, acl, XATTR_CREATE); posix_acl_release(acl); - } else { - inode->i_acl = NULL; } return error; } diff --git a/fs/ext4/acl.h b/fs/ext4/acl.h index 9b63f5416a2f..1e2927d14238 100644 --- a/fs/ext4/acl.h +++ b/fs/ext4/acl.h @@ -57,15 +57,16 @@ static inline int ext4_acl_count(size_t size) /* acl.c */ struct posix_acl *ext4_get_acl(struct inode *inode, int type); int ext4_set_acl(struct inode *inode, struct posix_acl *acl, int type); -extern int ext4_init_acl(handle_t *, struct inode *, struct inode *); +int ext4_init_acl(handle_t *handle, struct inode *inode, int type, + struct posix_acl *acl); #else /* CONFIG_EXT4_FS_POSIX_ACL */ #include #define ext4_get_acl NULL #define ext4_set_acl NULL -static inline int -ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir) +static inline int ext4_init_acl(handle_t *handle, struct inode *inode, int type, + struct posix_acl *acl) { return 0; } diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index b420c9dc444d..32b03f6277c1 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c @@ -1168,7 +1168,17 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir, } if (!(ei->i_flags & EXT4_EA_INODE_FL)) { - err = ext4_init_acl(handle, inode, dir); + struct posix_acl *default_acl, *acl; + + cache_no_acl(inode); + err = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl); + if (err) + goto fail_free_drop; + err = ext4_init_acl(handle, inode, ACL_TYPE_DEFAULT, + default_acl); + if (err) + goto fail_free_drop; + err = ext4_init_acl(handle, inode, ACL_TYPE_ACCESS, acl); if (err) goto fail_free_drop;