[PATCH 28/35] cifs: Fix smb2_unlink() to fail on directory

Pali Rohár posted 35 patches 1 month ago
[PATCH 28/35] cifs: Fix smb2_unlink() to fail on directory
Posted by Pali Rohár 1 month ago
unlink() should fail on the directory with ENOTDIR error code.
Flag CREATE_NOT_DIR handles that.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 fs/smb/client/smb2inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/smb/client/smb2inode.c b/fs/smb/client/smb2inode.c
index c8b0e9b2438f..c69293fcf26c 100644
--- a/fs/smb/client/smb2inode.c
+++ b/fs/smb/client/smb2inode.c
@@ -1348,7 +1348,7 @@ smb2_unlink(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
 
 	oparms = CIFS_OPARMS(cifs_sb, tcon, name,
 			     DELETE, FILE_OPEN,
-			     CREATE_DELETE_ON_CLOSE | OPEN_REPARSE_POINT,
+			     CREATE_DELETE_ON_CLOSE | CREATE_NOT_DIR | OPEN_REPARSE_POINT,
 			     ACL_NO_MODE);
 	int rc = smb2_compound_op(xid, tcon, cifs_sb, name, &oparms,
 				  NULL, &(int){SMB2_OP_DELETE}, 1,
-- 
2.20.1