Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2024507rwe; Fri, 2 Sep 2022 07:30:20 -0700 (PDT) X-Google-Smtp-Source: AA6agR55+3uByYljRoYoHUbfL6q8pCdJp+pUJnaKT+oAIaJFKseopu7blwBnmtFRmdR1nT4OLMO+ X-Received: by 2002:a17:90a:cb87:b0:1fd:d261:f87c with SMTP id a7-20020a17090acb8700b001fdd261f87cmr5227024pju.43.1662129020087; Fri, 02 Sep 2022 07:30:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662129020; cv=none; d=google.com; s=arc-20160816; b=b3I/ujJlVnbPESMIl6oU2/hH7mGCS/9tlyObdGj2Fg8+0TilmXBT1GzmxVjjGRO+aO vBpKiffrUeVCM7kPsZDrJF3rRLU4u2Ai78sEM02fvX2PT7c+aSJzyvTPD8JG3h42pwkB FOkyeFuWfR6evjs17Grrf2xxPEsAwrFGVOuF3k43xDYTD8mNBM/iQdh8dFn4ndNN4hSE D/ZngRjSRopwt0E3CW2cGQCcja2umxOkmde53ZhTeXK0aoshevRmAUfHNtKcQAkYoeey xOuazjZs6w7KzyQOhOzKpstAJhwIG34ag8WsY7XKGqBExYYOJhmv8H06QzetOjhNHB7h +JlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lhB/GfeGzGawJ5wmvGGlM8pJFK//jz9LPKP2ZZjZmzU=; b=Ppid/JE7iSEbZmO5CjG5OQFsOcPZ4+4BUinyRVLvlUS+ukXro3qF9FJ1s68sIL/POw fXXENggxc5Is/5Wh1Hhjc39oAYI5yeeVbfKo3HySWRvhTFjKBGGv3NnaPzP5KwsivarR 5PZei40nzjG4iIp2WwlDWgTNm/cz93RR3Te9iv/AdPIkJF1q6V6z92G52f4LgXFjonT9 Prx/5HRsbWPY78MOcdMjEOAlYLj+iAqIjjAsHyHzgB7q6MCKI9SzfG/Vd/Xrw03tDAN2 i9GF1ZXBhh4CQTz8iFPvnNY3BsKvsiMX882m3C4HNTb0DSxjEYHUErVOZr8Q/m6r5TZP vvtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kEyHwzie; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b18-20020a170902d89200b0016ef6b7e298si2177581plz.157.2022.09.02.07.30.07; Fri, 02 Sep 2022 07:30:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kEyHwzie; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238247AbiIBM4w (ORCPT + 99 others); Fri, 2 Sep 2022 08:56:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238049AbiIBMxk (ORCPT ); Fri, 2 Sep 2022 08:53:40 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E794CFAC56; Fri, 2 Sep 2022 05:38:09 -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 37D7AB82AC5; Fri, 2 Sep 2022 12:37:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9865BC433C1; Fri, 2 Sep 2022 12:37:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662122223; bh=2gkOyJHEOnhy8KuSVDxmg+uLWkfhEMajGgSqFWI+bi4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kEyHwzieAe1li/IrzoObLuUpyZBUW2Bi7KC+gtsaOTiHJQ9UssRsKmm/RraGCWPHJ TNoecoK+XsWw6nKRKMmwqVzwSB4ShOYuQX/2KhPqBjfQ91ZSd0Uhsalty3OPVYsLm/ rpk5t2RTZaW5qEjtIelw9yquviCEpOfPd0pD1i10= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Namjae Jeon , Hyunchul Lee , Steve French , Sasha Levin Subject: [PATCH 5.19 51/72] ksmbd: dont remove dos attribute xattr on O_TRUNC open Date: Fri, 2 Sep 2022 14:19:27 +0200 Message-Id: <20220902121406.446240162@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220902121404.772492078@linuxfoundation.org> References: <20220902121404.772492078@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Namjae Jeon [ Upstream commit 17661ecf6a64eb11ae7f1108fe88686388b2acd5 ] When smb client open file in ksmbd share with O_TRUNC, dos attribute xattr is removed as well as data in file. This cause the FSCTL_SET_SPARSE request from the client fails because ksmbd can't update the dos attribute after setting ATTR_SPARSE_FILE. And this patch fix xfstests generic/469 test also. Signed-off-by: Namjae Jeon Reviewed-by: Hyunchul Lee Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/ksmbd/smb2pdu.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c index bbb3958b6469d..35f5ea1c9dfcd 100644 --- a/fs/ksmbd/smb2pdu.c +++ b/fs/ksmbd/smb2pdu.c @@ -2315,15 +2315,15 @@ static int smb2_remove_smb_xattrs(struct path *path) name += strlen(name) + 1) { ksmbd_debug(SMB, "%s, len %zd\n", name, strlen(name)); - if (strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN) && - strncmp(&name[XATTR_USER_PREFIX_LEN], DOS_ATTRIBUTE_PREFIX, - DOS_ATTRIBUTE_PREFIX_LEN) && - strncmp(&name[XATTR_USER_PREFIX_LEN], STREAM_PREFIX, STREAM_PREFIX_LEN)) - continue; - - err = ksmbd_vfs_remove_xattr(user_ns, path->dentry, name); - if (err) - ksmbd_debug(SMB, "remove xattr failed : %s\n", name); + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN) && + !strncmp(&name[XATTR_USER_PREFIX_LEN], STREAM_PREFIX, + STREAM_PREFIX_LEN)) { + err = ksmbd_vfs_remove_xattr(user_ns, path->dentry, + name); + if (err) + ksmbd_debug(SMB, "remove xattr failed : %s\n", + name); + } } out: kvfree(xattr_list); -- 2.35.1