Bug 202007

Summary: CIFS: return successfully if remove non-existent EA
Product: File System Reporter: Xiaoli Feng (fengxiaoli0714)
Component: CIFSAssignee: fs_cifs (fs_cifs)
Status: RESOLVED CODE_FIX    
Severity: normal CC: lsahlber
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 4.20.0-rc6+ Subsystem:
Regression: No Bisected commit-id:

Description Xiaoli Feng 2018-12-17 05:52:24 UTC
When remove a non-existent EA, the cifs return successfully.

# mount //localhost/cifs cifs -o user=root,password=redhat
# touch cifs/file
# setfattr -x user.test cifs/file
# echo $?
0

It should be like this.

# touch file
# setfattr -x user.test file
setfattr: file: No such attribute
# echo $?
1
Comment 1 Ronnie Sahlberg 2019-02-07 04:56:37 UTC
The problem is that we do not check if the attribute exists before we try to delete it.

If we delete an attribute using SMB2 SET_INFO the server will return STATUS_SUCCESS even if the attribute did not exist.

What we need to do here is to first check if the attribute exists in cifs.ko before we decide if we should try to delete it.
Comment 2 Ronnie Sahlberg 2019-03-11 02:22:01 UTC
Fixed in commit 2109464184919f81efd593b4008291448c522815
Author: Ronnie Sahlberg <lsahlber@redhat.com>
Date:   Thu Feb 7 15:48:44 2019 +1000

    cifs: return -ENODATA when deleting an xattr that does not exist
    
    BUGZILLA: https://bugzilla.kernel.org/show_bug.cgi?id=202007
    
    When deleting an xattr/EA:
    SMB2/3 servers will return SUCCESS when clients delete non-existing EAs.
    This means that we need to first QUERY the server and check if the EA
    exists or not so that we can return -ENODATA correctly when this happens.
    
    Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
    Signed-off-by: Steve French <stfrench@microsoft.com>