From patchwork Mon May 16 03:31:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12850229 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69E58C433F5 for ; Mon, 16 May 2022 03:32:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239662AbiEPDcD (ORCPT ); Sun, 15 May 2022 23:32:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232759AbiEPDcA (ORCPT ); Sun, 15 May 2022 23:32:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 514F21FCC7 for ; Sun, 15 May 2022 20:31:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D661060ECC for ; Mon, 16 May 2022 03:31:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43362C385B8; Mon, 16 May 2022 03:31:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652671918; bh=4vI1ILqU9B3zi1i0JbBzjAtvBpOYE9mEo2tctI5mRqI=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=uiKlDCAacWtitnUUNWKpDzEtidQK73ZdG2/yGUu8wCfjgvN2Qnuiv89odFvvhXUgJ E0CN9hkeLsTobY3X/NDXdcawgCpnEb/l4QBVSVFroLB9+zE33NlNf0VZrS4kDetHKS fQlnAvjzxW6aJOhjXEBeddAOFm453lCui/raUjgNUmHS7FzG/6rdxpfRlpHf5+YxpI FqYo7rDLbwBSqMFuDUomBdHv3ARpI1D7/6L1SYvYCGgp8VoriN4uaEv2j6q/NkVTBr 9nQk1wKCgQpYMZzSJFSMtGzRczUw06Qm2Wc/Lor1UlQ09rYcmOe+0Fhx+e+/VyDtRJ x48FA39i7dI0g== Subject: [PATCH 1/4] xfs: don't leak da state when freeing the attr intent item From: "Darrick J. Wong" To: djwong@kernel.org Cc: linux-xfs@vger.kernel.org, david@fromorbit.com, allison.henderson@oracle.com Date: Sun, 15 May 2022 20:31:57 -0700 Message-ID: <165267191771.625255.3595054157709968327.stgit@magnolia> In-Reply-To: <165267191199.625255.12173648515376165187.stgit@magnolia> References: <165267191199.625255.12173648515376165187.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong kmemleak reported that we lost an xfs_da_state while removing xattrs in generic/020: unreferenced object 0xffff88801c0e4b40 (size 480): comm "attr", pid 30515, jiffies 4294931061 (age 5.960s) hex dump (first 32 bytes): 78 bc 65 07 00 c9 ff ff 00 30 60 1c 80 88 ff ff x.e......0`..... 02 00 00 00 00 00 00 00 80 18 83 4e 80 88 ff ff ...........N.... backtrace: [] xfs_da_state_alloc+0x1a/0x30 [xfs] [] xfs_attr_node_hasname+0x23/0x90 [xfs] [] xfs_attr_set_iter+0x441/0xa30 [xfs] [] xfs_xattri_finish_update+0x44/0x80 [xfs] [] xfs_attr_finish_item+0x1e/0x40 [xfs] [] xfs_defer_finish_noroll+0x184/0x740 [xfs] [] __xfs_trans_commit+0x153/0x3e0 [xfs] [] xfs_attr_set+0x469/0x7e0 [xfs] [] xfs_xattr_set+0x89/0xd0 [xfs] [] __vfs_removexattr+0x52/0x70 [] __vfs_removexattr_locked+0xb8/0x150 [] vfs_removexattr+0x56/0x100 [] removexattr+0x58/0x90 [] path_removexattr+0x9e/0xc0 [] __x64_sys_lremovexattr+0x14/0x20 [] do_syscall_64+0x35/0x80 I think this is a consequence of xfs_attr_node_removename_setup attaching a new da(btree) state to xfs_attr_item and never freeing it. I /think/ it's the case that the remove paths could detach the da state earlier in the remove state machine since nothing else accesses the state. However, let's future-proof the new xattr code by adding a catch-all when we free the xfs_attr_item to make sure we never leak the da state. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Henderson --- fs/xfs/libxfs/xfs_attr.c | 22 ++++++++++++++-------- fs/xfs/xfs_attr_item.c | 15 ++++++++++++--- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 14ae0826bc15..2da24954b2d7 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -604,26 +604,29 @@ int xfs_attr_node_removename_setup( struct xfs_attr_item *attr) { struct xfs_da_args *args = attr->xattri_da_args; - struct xfs_da_state **state = &attr->xattri_da_state; + struct xfs_da_state *state; int error; - error = xfs_attr_node_hasname(args, state); + error = xfs_attr_node_hasname(args, &attr->xattri_da_state); if (error != -EEXIST) goto out; error = 0; - ASSERT((*state)->path.blk[(*state)->path.active - 1].bp != NULL); - ASSERT((*state)->path.blk[(*state)->path.active - 1].magic == + state = attr->xattri_da_state; + ASSERT(state->path.blk[state->path.active - 1].bp != NULL); + ASSERT(state->path.blk[state->path.active - 1].magic == XFS_ATTR_LEAF_MAGIC); - error = xfs_attr_leaf_mark_incomplete(args, *state); + error = xfs_attr_leaf_mark_incomplete(args, state); if (error) goto out; if (args->rmtblkno > 0) error = xfs_attr_rmtval_invalidate(args); out: - if (error) - xfs_da_state_free(*state); + if (error) { + xfs_da_state_free(state); + attr->xattri_da_state = NULL; + } return error; } @@ -1456,8 +1459,10 @@ xfs_attr_node_addname_find_attr( return 0; error: - if (attr->xattri_da_state) + if (attr->xattri_da_state) { xfs_da_state_free(attr->xattri_da_state); + attr->xattri_da_state = NULL; + } return error; } @@ -1511,6 +1516,7 @@ xfs_attr_node_try_addname( out: xfs_da_state_free(state); + attr->xattri_da_state = NULL; return error; } diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index e8ac88d9fd14..687cf517841a 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -396,6 +396,15 @@ xfs_attr_create_intent( return &attrip->attri_item; } +static inline void +xfs_attr_free_item( + struct xfs_attr_item *attr) +{ + if (attr->xattri_da_state) + xfs_da_state_free(attr->xattri_da_state); + kmem_free(attr); +} + /* Process an attr. */ STATIC int xfs_attr_finish_item( @@ -420,7 +429,7 @@ xfs_attr_finish_item( error = xfs_xattri_finish_update(attr, done_item); if (error != -EAGAIN) - kmem_free(attr); + xfs_attr_free_item(attr); return error; } @@ -441,7 +450,7 @@ xfs_attr_cancel_item( struct xfs_attr_item *attr; attr = container_of(item, struct xfs_attr_item, xattri_list); - kmem_free(attr); + xfs_attr_free_item(attr); } STATIC xfs_lsn_t @@ -613,7 +622,7 @@ xfs_attri_item_recover( xfs_irele(ip); out: if (ret != -EAGAIN) - kmem_free(attr); + xfs_attr_free_item(attr); return error; } From patchwork Mon May 16 03:32:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12850230 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC9DFC433F5 for ; Mon, 16 May 2022 03:32:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232759AbiEPDcJ (ORCPT ); Sun, 15 May 2022 23:32:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239665AbiEPDcI (ORCPT ); Sun, 15 May 2022 23:32:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F28F1FCC4 for ; Sun, 15 May 2022 20:32:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 20AB2B80D2C for ; Mon, 16 May 2022 03:32:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC9EBC385AA; Mon, 16 May 2022 03:32:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652671923; bh=wjhQDDxUEWVl+wq8/HogUZ5eor/mfW5Y35gIqidtJ8g=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=iqTLbOXaL5sNUiFSDIh1szqFcxscAk/xSDI2S3eg/7lFIgInZnphRjNKK8AihFAtj Tf3MwGhIK0h7zhMpPioy0NxW8NcqZZarOi3uX8QvAxZTPAHoJf3alvjwgtyQJS/Xsx BLuHmFinQr8lWF4tbpdUDFUjvJWWZMKoV/zf1iRKHvJGQHVjA3YFT4w1X+60v9MAO6 Ep4fgewmwr3Mtrp7H/VYR+0cBVVo04jE8PumBPsKVYrDdTDRPe/Td2nSJUbVx67Nlz /7frvCmi5qiP2LiHzuTSetsWW+4oIcNtbBRmsROyihLGYwOWY7MOB4lGIEV1YiTuXv a98iGJ51cJvmg== Subject: [PATCH 2/4] xfs: don't leak the retained da state when doing a leaf to node conversion From: "Darrick J. Wong" To: djwong@kernel.org Cc: linux-xfs@vger.kernel.org, david@fromorbit.com, allison.henderson@oracle.com Date: Sun, 15 May 2022 20:32:03 -0700 Message-ID: <165267192341.625255.6169607924858686457.stgit@magnolia> In-Reply-To: <165267191199.625255.12173648515376165187.stgit@magnolia> References: <165267191199.625255.12173648515376165187.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong If a setxattr operation finds an xattr structure in leaf format, adding the attr can fail due to lack of space and hence requires an upgrade to node format. After this happens, we'll roll the transaction and re-enter the state machine, at which time we need to perform a second lookup of the attribute name to find its new location. This lookup attaches a new da state structure to the xfs_attr_item but doesn't free the old one (from the leaf lookup) and leaks it. Fix that. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Henderson --- fs/xfs/libxfs/xfs_attr.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 2da24954b2d7..499a15480b57 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -1401,8 +1401,10 @@ xfs_attr_node_hasname( int retval, error; state = xfs_da_state_alloc(args); - if (statep != NULL) + if (statep != NULL) { + ASSERT(*statep == NULL); *statep = state; + } /* * Search to see if name exists, and get back a pointer to it. @@ -1428,6 +1430,10 @@ xfs_attr_node_addname_find_attr( struct xfs_da_args *args = attr->xattri_da_args; int error; + if (attr->xattri_da_state) + xfs_da_state_free(attr->xattri_da_state); + attr->xattri_da_state = NULL; + /* * Search to see if name already exists, and get back a pointer * to where it should go. @@ -1593,7 +1599,7 @@ STATIC int xfs_attr_node_get( struct xfs_da_args *args) { - struct xfs_da_state *state; + struct xfs_da_state *state = NULL; struct xfs_da_state_blk *blk; int i; int error; From patchwork Mon May 16 03:32:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12850231 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0FA7DC433EF for ; Mon, 16 May 2022 03:32:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239666AbiEPDcL (ORCPT ); Sun, 15 May 2022 23:32:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239665AbiEPDcL (ORCPT ); Sun, 15 May 2022 23:32:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9101C1FCC1 for ; Sun, 15 May 2022 20:32:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 344D960EBE for ; Mon, 16 May 2022 03:32:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 983A9C385AA; Mon, 16 May 2022 03:32:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652671929; bh=H8zxR5o5TKCkoOOg45UVdKqu+zQR50zSJVlQ4o+bTL8=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=WO0P3PklTj8Gh3RdnPdUoik0Gn2gVLmG/FhT6T5uDPTMnrd67K/8m5QU5xoZZZXq0 ogU4MY+dFBsaj6BpFE14n2fvZWpzEHqkzYERw2bBFZ7B+Agpcqv/Fj24d6tr2rPjoF ESyn+9cFiUEGekYVc7+W9rMMSTifLgDEhdXwhjLXKSIBY6kdmS7lCQQjf3ShOke2nA 2IwYJhwr1aAAUvCj4Hgub27L40RoJWCZB3QlrMULCnqEQikEz/p+vSsv0BQGX4Vf0G 9cGT26WprpxMNkqjg4uM2kA3MmB3HHbZbS36nLYFb/DeKzdZLXdSKepuXQeRfdDfPY +8G03ss0D4wcQ== Subject: [PATCH 3/4] xfs: reject unknown xattri log item operation flags during recovery From: "Darrick J. Wong" To: djwong@kernel.org Cc: linux-xfs@vger.kernel.org, david@fromorbit.com, allison.henderson@oracle.com Date: Sun, 15 May 2022 20:32:09 -0700 Message-ID: <165267192904.625255.1227477138553372618.stgit@magnolia> In-Reply-To: <165267191199.625255.12173648515376165187.stgit@magnolia> References: <165267191199.625255.12173648515376165187.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Make sure we screen the op flags field of recovered xattr intent log items to reject flag bits that we don't know about. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Henderson --- fs/xfs/xfs_attr_item.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 687cf517841a..459b6c93b40b 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -349,7 +349,8 @@ xfs_attr_log_item( */ attrp = &attrip->attri_format; attrp->alfi_ino = attr->xattri_da_args->dp->i_ino; - attrp->alfi_op_flags = attr->xattri_op_flags; + attrp->alfi_op_flags = attr->xattri_op_flags & + XFS_ATTR_OP_FLAGS_TYPE_MASK; attrp->alfi_value_len = attr->xattri_da_args->valuelen; attrp->alfi_name_len = attr->xattri_da_args->namelen; attrp->alfi_attr_flags = attr->xattri_da_args->attr_filter; @@ -496,6 +497,9 @@ xfs_attri_validate( if (attrp->__pad != 0) return false; + if (attrp->alfi_op_flags & ~XFS_ATTR_OP_FLAGS_TYPE_MASK) + return false; + /* alfi_op_flags should be either a set or remove */ switch (op) { case XFS_ATTR_OP_FLAGS_SET: @@ -556,7 +560,8 @@ xfs_attri_item_recover( args = (struct xfs_da_args *)(attr + 1); attr->xattri_da_args = args; - attr->xattri_op_flags = attrp->alfi_op_flags; + attr->xattri_op_flags = attrp->alfi_op_flags & + XFS_ATTR_OP_FLAGS_TYPE_MASK; args->dp = ip; args->geo = mp->m_attr_geo; @@ -567,7 +572,7 @@ xfs_attri_item_recover( args->attr_filter = attrp->alfi_attr_flags; args->op_flags = XFS_DA_OP_RECOVERY | XFS_DA_OP_OKNOENT; - switch (attrp->alfi_op_flags & XFS_ATTR_OP_FLAGS_TYPE_MASK) { + switch (attr->xattri_op_flags) { case XFS_ATTR_OP_FLAGS_SET: case XFS_ATTR_OP_FLAGS_REPLACE: args->value = attrip->attri_value; From patchwork Mon May 16 03:32:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 12850232 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67DC2C433EF for ; Mon, 16 May 2022 03:32:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238146AbiEPDcT (ORCPT ); Sun, 15 May 2022 23:32:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239667AbiEPDcT (ORCPT ); Sun, 15 May 2022 23:32:19 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 528481FCC1 for ; Sun, 15 May 2022 20:32:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 763E5B80E16 for ; Mon, 16 May 2022 03:32:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36A72C385AA; Mon, 16 May 2022 03:32:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652671935; bh=m1AhM4TuoVTHsGUBd9W/j+19m2kp13L0BHWojQSBkc8=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=igUjCGQ/Bf/GhFvjUi8BMGAugn2LqHVbcWajMkrUDkQEsfK/AdWqL/g7SLUNy1XuY LF654yN1IUDitv3m96T9ZpDfqDunwdaANI93dtJTDIPeO0gXcmRI4MAxPQ8QWM9InB j9CVNpYdRDl5HeclVYxVM7T/3XXVSNJ8vnRhOE8C1dY/pG6K0P9oDhxGXPAUknyipC QYXmejo7q1W+M/fTELpTpFqePD2XVYxo+zG7BOomG0fkOZf5bBOwp41F1Mhnm2Otqb giyXMkHakgK3tfoqqbnQ2y8et0fZYJ3jJpQgOzJVLoxAQU6m8p+Y0Lrt1lcNZMhwpx rOnZl13Dys5kw== Subject: [PATCH 4/4] xfs: reject unknown xattri log item filter flags during recovery From: "Darrick J. Wong" To: djwong@kernel.org Cc: linux-xfs@vger.kernel.org, david@fromorbit.com, allison.henderson@oracle.com Date: Sun, 15 May 2022 20:32:14 -0700 Message-ID: <165267193475.625255.2721960601959913094.stgit@magnolia> In-Reply-To: <165267191199.625255.12173648515376165187.stgit@magnolia> References: <165267191199.625255.12173648515376165187.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Make sure we screen the "attr flags" field of recovered xattr intent log items to reject flag bits that we don't know about. This is really the attr *filter* flags, so rename the field and create properly namespaced flags to fill it. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_log_format.h | 9 ++++++++- fs/xfs/xfs_attr_item.c | 10 +++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h index f7edd1ecf6d9..5017500bfd8b 100644 --- a/fs/xfs/libxfs/xfs_log_format.h +++ b/fs/xfs/libxfs/xfs_log_format.h @@ -911,6 +911,13 @@ struct xfs_icreate_log { #define XFS_ATTR_OP_FLAGS_REPLACE 3 /* Replace the attribute */ #define XFS_ATTR_OP_FLAGS_TYPE_MASK 0xFF /* Flags type mask */ +#define XFS_ATTRI_FILTER_ROOT (1u << XFS_ATTR_ROOT_BIT) +#define XFS_ATTRI_FILTER_SECURE (1u << XFS_ATTR_SECURE_BIT) +#define XFS_ATTRI_FILTER_INCOMPLETE (1u << XFS_ATTR_INCOMPLETE_BIT) +#define XFS_ATTRI_FILTER_MASK (XFS_ATTRI_FILTER_ROOT | \ + XFS_ATTRI_FILTER_SECURE | \ + XFS_ATTRI_FILTER_INCOMPLETE) + /* * This is the structure used to lay out an attr log item in the * log. @@ -924,7 +931,7 @@ struct xfs_attri_log_format { uint32_t alfi_op_flags; /* marks the op as a set or remove */ uint32_t alfi_name_len; /* attr name length */ uint32_t alfi_value_len; /* attr value length */ - uint32_t alfi_attr_flags;/* attr flags */ + uint32_t alfi_attr_filter;/* attr filter flags */ }; struct xfs_attrd_log_format { diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 459b6c93b40b..7cbb640d7856 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -353,7 +353,8 @@ xfs_attr_log_item( XFS_ATTR_OP_FLAGS_TYPE_MASK; attrp->alfi_value_len = attr->xattri_da_args->valuelen; attrp->alfi_name_len = attr->xattri_da_args->namelen; - attrp->alfi_attr_flags = attr->xattri_da_args->attr_filter; + attrp->alfi_attr_filter = attr->xattri_da_args->attr_filter & + XFS_ATTRI_FILTER_MASK; memcpy(attrip->attri_name, attr->xattri_da_args->name, attr->xattri_da_args->namelen); @@ -500,6 +501,9 @@ xfs_attri_validate( if (attrp->alfi_op_flags & ~XFS_ATTR_OP_FLAGS_TYPE_MASK) return false; + if (attrp->alfi_attr_filter & ~XFS_ATTRI_FILTER_MASK) + return false; + /* alfi_op_flags should be either a set or remove */ switch (op) { case XFS_ATTR_OP_FLAGS_SET: @@ -569,7 +573,7 @@ xfs_attri_item_recover( args->name = attrip->attri_name; args->namelen = attrp->alfi_name_len; args->hashval = xfs_da_hashname(args->name, args->namelen); - args->attr_filter = attrp->alfi_attr_flags; + args->attr_filter = attrp->alfi_attr_filter & XFS_ATTRI_FILTER_MASK; args->op_flags = XFS_DA_OP_RECOVERY | XFS_DA_OP_OKNOENT; switch (attr->xattri_op_flags) { @@ -658,7 +662,7 @@ xfs_attri_item_relog( new_attrp->alfi_op_flags = old_attrp->alfi_op_flags; new_attrp->alfi_value_len = old_attrp->alfi_value_len; new_attrp->alfi_name_len = old_attrp->alfi_name_len; - new_attrp->alfi_attr_flags = old_attrp->alfi_attr_flags; + new_attrp->alfi_attr_filter = old_attrp->alfi_attr_filter; memcpy(new_attrip->attri_name, old_attrip->attri_name, new_attrip->attri_name_len);