From: Andreas Gruenbacher <agruenba-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> To: Al Viro <viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org> Cc: Steve French <sfrench-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>, linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, ceph-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, cluster-devel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org Subject: [PATCH 1/8] cifs: Fix xattr name checks Date: Thu, 14 Apr 2016 00:30:13 +0200 [thread overview] Message-ID: <1460586620-5717-2-git-send-email-agruenba@redhat.com> (raw) In-Reply-To: <1460586620-5717-1-git-send-email-agruenba-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> In-Reply-To: <20160413182026.GR25498-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org> Use strcmp(str, name) instead of strncmp(str, name, strlen(name)) for checking if str and name are the same (as opposed to name being a prefix of str) in the gexattr and setxattr inode operations. Signed-off-by: Andreas Gruenbacher <agruenba-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> --- fs/cifs/xattr.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c index 5d57c85..6e73ba9 100644 --- a/fs/cifs/xattr.c +++ b/fs/cifs/xattr.c @@ -129,7 +129,7 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name, == 0) { if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) goto set_ea_exit; - if (strncmp(ea_name, CIFS_XATTR_DOS_ATTRIB, 14) == 0) + if (strcmp(ea_name, CIFS_XATTR_DOS_ATTRIB) == 0) cifs_dbg(FYI, "attempt to set cifs inode metadata\n"); ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */ @@ -147,8 +147,7 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name, rc = pTcon->ses->server->ops->set_EA(xid, pTcon, full_path, ea_name, ea_value, (__u16)value_size, cifs_sb->local_nls, cifs_remap(cifs_sb)); - } else if (strncmp(ea_name, CIFS_XATTR_CIFS_ACL, - strlen(CIFS_XATTR_CIFS_ACL)) == 0) { + } else if (strcmp(ea_name, CIFS_XATTR_CIFS_ACL) == 0) { #ifdef CONFIG_CIFS_ACL struct cifs_ntsd *pacl; pacl = kmalloc(value_size, GFP_KERNEL); @@ -170,10 +169,7 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name, cifs_dbg(FYI, "Set CIFS ACL not supported yet\n"); #endif /* CONFIG_CIFS_ACL */ } else { - int temp; - temp = strncmp(ea_name, XATTR_NAME_POSIX_ACL_ACCESS, - strlen(XATTR_NAME_POSIX_ACL_ACCESS)); - if (temp == 0) { + if (strcmp(ea_name, XATTR_NAME_POSIX_ACL_ACCESS) == 0) { #ifdef CONFIG_CIFS_POSIX if (sb->s_flags & MS_POSIXACL) rc = CIFSSMBSetPosixACL(xid, pTcon, full_path, @@ -184,8 +180,7 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name, #else cifs_dbg(FYI, "set POSIX ACL not supported\n"); #endif - } else if (strncmp(ea_name, XATTR_NAME_POSIX_ACL_DEFAULT, - strlen(XATTR_NAME_POSIX_ACL_DEFAULT)) == 0) { + } else if (strcmp(ea_name, XATTR_NAME_POSIX_ACL_DEFAULT) == 0) { #ifdef CONFIG_CIFS_POSIX if (sb->s_flags & MS_POSIXACL) rc = CIFSSMBSetPosixACL(xid, pTcon, full_path, @@ -246,7 +241,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, struct inode *inode, if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) goto get_ea_exit; - if (strncmp(ea_name, CIFS_XATTR_DOS_ATTRIB, 14) == 0) { + if (strcmp(ea_name, CIFS_XATTR_DOS_ATTRIB) == 0) { cifs_dbg(FYI, "attempt to query cifs inode metadata\n"); /* revalidate/getattr then populate from inode */ } /* BB add else when above is implemented */ @@ -264,8 +259,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, struct inode *inode, rc = pTcon->ses->server->ops->query_all_EAs(xid, pTcon, full_path, ea_name, ea_value, buf_size, cifs_sb->local_nls, cifs_remap(cifs_sb)); - } else if (strncmp(ea_name, XATTR_NAME_POSIX_ACL_ACCESS, - strlen(XATTR_NAME_POSIX_ACL_ACCESS)) == 0) { + } else if (strcmp(ea_name, XATTR_NAME_POSIX_ACL_ACCESS) == 0) { #ifdef CONFIG_CIFS_POSIX if (sb->s_flags & MS_POSIXACL) rc = CIFSSMBGetPosixACL(xid, pTcon, full_path, @@ -275,8 +269,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, struct inode *inode, #else cifs_dbg(FYI, "Query POSIX ACL not supported yet\n"); #endif /* CONFIG_CIFS_POSIX */ - } else if (strncmp(ea_name, XATTR_NAME_POSIX_ACL_DEFAULT, - strlen(XATTR_NAME_POSIX_ACL_DEFAULT)) == 0) { + } else if (strcmp(ea_name, XATTR_NAME_POSIX_ACL_DEFAULT) == 0) { #ifdef CONFIG_CIFS_POSIX if (sb->s_flags & MS_POSIXACL) rc = CIFSSMBGetPosixACL(xid, pTcon, full_path, @@ -286,8 +279,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, struct inode *inode, #else cifs_dbg(FYI, "Query POSIX default ACL not supported yet\n"); #endif /* CONFIG_CIFS_POSIX */ - } else if (strncmp(ea_name, CIFS_XATTR_CIFS_ACL, - strlen(CIFS_XATTR_CIFS_ACL)) == 0) { + } else if (strcmp(ea_name, CIFS_XATTR_CIFS_ACL) == 0) { #ifdef CONFIG_CIFS_ACL u32 acllen; struct cifs_ntsd *pacl; -- 2.4.11
WARNING: multiple messages have this Message-ID (diff)
From: Andreas Gruenbacher <agruenba@redhat.com> To: cluster-devel.redhat.com Subject: [Cluster-devel] [PATCH 1/8] cifs: Fix xattr name checks Date: Thu, 14 Apr 2016 00:30:13 +0200 [thread overview] Message-ID: <1460586620-5717-2-git-send-email-agruenba@redhat.com> (raw) In-Reply-To: <1460586620-5717-1-git-send-email-agruenba@redhat.com> Use strcmp(str, name) instead of strncmp(str, name, strlen(name)) for checking if str and name are the same (as opposed to name being a prefix of str) in the gexattr and setxattr inode operations. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> --- fs/cifs/xattr.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c index 5d57c85..6e73ba9 100644 --- a/fs/cifs/xattr.c +++ b/fs/cifs/xattr.c @@ -129,7 +129,7 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name, == 0) { if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) goto set_ea_exit; - if (strncmp(ea_name, CIFS_XATTR_DOS_ATTRIB, 14) == 0) + if (strcmp(ea_name, CIFS_XATTR_DOS_ATTRIB) == 0) cifs_dbg(FYI, "attempt to set cifs inode metadata\n"); ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */ @@ -147,8 +147,7 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name, rc = pTcon->ses->server->ops->set_EA(xid, pTcon, full_path, ea_name, ea_value, (__u16)value_size, cifs_sb->local_nls, cifs_remap(cifs_sb)); - } else if (strncmp(ea_name, CIFS_XATTR_CIFS_ACL, - strlen(CIFS_XATTR_CIFS_ACL)) == 0) { + } else if (strcmp(ea_name, CIFS_XATTR_CIFS_ACL) == 0) { #ifdef CONFIG_CIFS_ACL struct cifs_ntsd *pacl; pacl = kmalloc(value_size, GFP_KERNEL); @@ -170,10 +169,7 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name, cifs_dbg(FYI, "Set CIFS ACL not supported yet\n"); #endif /* CONFIG_CIFS_ACL */ } else { - int temp; - temp = strncmp(ea_name, XATTR_NAME_POSIX_ACL_ACCESS, - strlen(XATTR_NAME_POSIX_ACL_ACCESS)); - if (temp == 0) { + if (strcmp(ea_name, XATTR_NAME_POSIX_ACL_ACCESS) == 0) { #ifdef CONFIG_CIFS_POSIX if (sb->s_flags & MS_POSIXACL) rc = CIFSSMBSetPosixACL(xid, pTcon, full_path, @@ -184,8 +180,7 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name, #else cifs_dbg(FYI, "set POSIX ACL not supported\n"); #endif - } else if (strncmp(ea_name, XATTR_NAME_POSIX_ACL_DEFAULT, - strlen(XATTR_NAME_POSIX_ACL_DEFAULT)) == 0) { + } else if (strcmp(ea_name, XATTR_NAME_POSIX_ACL_DEFAULT) == 0) { #ifdef CONFIG_CIFS_POSIX if (sb->s_flags & MS_POSIXACL) rc = CIFSSMBSetPosixACL(xid, pTcon, full_path, @@ -246,7 +241,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, struct inode *inode, if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) goto get_ea_exit; - if (strncmp(ea_name, CIFS_XATTR_DOS_ATTRIB, 14) == 0) { + if (strcmp(ea_name, CIFS_XATTR_DOS_ATTRIB) == 0) { cifs_dbg(FYI, "attempt to query cifs inode metadata\n"); /* revalidate/getattr then populate from inode */ } /* BB add else when above is implemented */ @@ -264,8 +259,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, struct inode *inode, rc = pTcon->ses->server->ops->query_all_EAs(xid, pTcon, full_path, ea_name, ea_value, buf_size, cifs_sb->local_nls, cifs_remap(cifs_sb)); - } else if (strncmp(ea_name, XATTR_NAME_POSIX_ACL_ACCESS, - strlen(XATTR_NAME_POSIX_ACL_ACCESS)) == 0) { + } else if (strcmp(ea_name, XATTR_NAME_POSIX_ACL_ACCESS) == 0) { #ifdef CONFIG_CIFS_POSIX if (sb->s_flags & MS_POSIXACL) rc = CIFSSMBGetPosixACL(xid, pTcon, full_path, @@ -275,8 +269,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, struct inode *inode, #else cifs_dbg(FYI, "Query POSIX ACL not supported yet\n"); #endif /* CONFIG_CIFS_POSIX */ - } else if (strncmp(ea_name, XATTR_NAME_POSIX_ACL_DEFAULT, - strlen(XATTR_NAME_POSIX_ACL_DEFAULT)) == 0) { + } else if (strcmp(ea_name, XATTR_NAME_POSIX_ACL_DEFAULT) == 0) { #ifdef CONFIG_CIFS_POSIX if (sb->s_flags & MS_POSIXACL) rc = CIFSSMBGetPosixACL(xid, pTcon, full_path, @@ -286,8 +279,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, struct inode *inode, #else cifs_dbg(FYI, "Query POSIX default ACL not supported yet\n"); #endif /* CONFIG_CIFS_POSIX */ - } else if (strncmp(ea_name, CIFS_XATTR_CIFS_ACL, - strlen(CIFS_XATTR_CIFS_ACL)) == 0) { + } else if (strcmp(ea_name, CIFS_XATTR_CIFS_ACL) == 0) { #ifdef CONFIG_CIFS_ACL u32 acllen; struct cifs_ntsd *pacl; -- 2.4.11
next prev parent reply other threads:[~2016-04-13 22:30 UTC|newest] Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-04-13 12:57 [PATCH] xattr: Fail with -EINVAL for NULL attribute names Andreas Gruenbacher 2016-04-13 15:40 ` [PATCH] xattr: Export xattr_resolve_name Andreas Gruenbacher 2016-04-13 18:20 ` Al Viro [not found] ` <20160413182026.GR25498-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org> 2016-04-13 22:27 ` Andreas Gruenbacher 2016-04-13 22:27 ` [Cluster-devel] " Andreas Gruenbacher 2016-04-13 22:27 ` Andreas Gruenbacher [not found] ` <1460586466-5518-1-git-send-email-agruenba-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2016-04-13 22:27 ` [PATCH 2/8] cifs: Check for equality with ACL_TYPE_ACCESS and ACL_TYPE_DEFAULT Andreas Gruenbacher 2016-04-13 22:27 ` [Cluster-devel] " Andreas Gruenbacher 2016-04-13 22:27 ` Andreas Gruenbacher 2016-04-13 22:27 ` [PATCH 3/8] cifs: Fix removexattr for os2.* xattrs Andreas Gruenbacher 2016-04-13 22:27 ` [Cluster-devel] " Andreas Gruenbacher 2016-04-13 22:27 ` Andreas Gruenbacher 2016-04-13 22:27 ` [PATCH 6/8] ceph: kill __ceph_removexattr() Andreas Gruenbacher 2016-04-13 22:27 ` [Cluster-devel] " Andreas Gruenbacher 2016-04-13 22:27 ` Andreas Gruenbacher 2016-04-13 22:30 ` [PATCH] xattr: Export xattr_resolve_name Andreas Gruenbacher 2016-04-13 22:30 ` [Cluster-devel] " Andreas Gruenbacher [not found] ` <1460586620-5717-1-git-send-email-agruenba-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2016-04-13 22:30 ` Andreas Gruenbacher [this message] 2016-04-13 22:30 ` [Cluster-devel] [PATCH 1/8] cifs: Fix xattr name checks Andreas Gruenbacher [not found] ` <1460586620-5717-2-git-send-email-agruenba-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2016-04-14 4:26 ` Steve French 2016-04-14 4:26 ` [Cluster-devel] " Steve French [not found] ` <CAH2r5mumJ22+Q0bASFcXp5fK39Ubh+sznfOpVUtSJ94_c5gkxA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2016-04-14 4:37 ` Al Viro 2016-04-14 4:37 ` [Cluster-devel] " Al Viro 2016-04-14 4:43 ` Steve French 2016-04-14 4:43 ` [Cluster-devel] " Steve French [not found] ` <CAH2r5ms6USEO3a_EPUpgsnvTZgSHB2QqJnUnCSCQdFmvV0yPDg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2016-04-14 4:49 ` Steve French 2016-04-14 4:49 ` [Cluster-devel] " Steve French 2016-04-14 4:59 ` Al Viro 2016-04-14 4:59 ` [Cluster-devel] " Al Viro [not found] ` <20160414045920.GT25498-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org> 2016-04-15 3:01 ` Steve French 2016-04-15 3:01 ` [Cluster-devel] " Steve French 2016-04-13 22:30 ` [PATCH 3/8] cifs: Fix removexattr for os2.* xattrs Andreas Gruenbacher 2016-04-13 22:30 ` [Cluster-devel] " Andreas Gruenbacher [not found] ` <1460586620-5717-4-git-send-email-agruenba-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2016-04-14 4:27 ` Steve French 2016-04-14 4:27 ` [Cluster-devel] " Steve French 2016-04-13 22:30 ` [PATCH 8/8] gfs2: Switch to generic xattr handlers Andreas Gruenbacher 2016-04-13 22:30 ` [Cluster-devel] " Andreas Gruenbacher 2016-04-13 22:27 ` [PATCH 1/8] cifs: Fix xattr name checks Andreas Gruenbacher 2016-04-13 22:27 ` [Cluster-devel] " Andreas Gruenbacher 2016-04-13 22:27 ` Andreas Gruenbacher 2016-04-13 22:27 ` [PATCH 4/8] ceph: Get rid of d_find_alias in ceph_set_acl Andreas Gruenbacher 2016-04-13 22:27 ` [Cluster-devel] " Andreas Gruenbacher 2016-04-13 22:27 ` Andreas Gruenbacher 2016-04-13 22:27 ` [PATCH 5/8] ceph: Switch to generic xattr handlers Andreas Gruenbacher 2016-04-13 22:27 ` [Cluster-devel] " Andreas Gruenbacher 2016-04-13 22:27 ` Andreas Gruenbacher 2016-04-13 22:27 ` [PATCH 7/8] posix acls: Export xattr_handler functions Andreas Gruenbacher 2016-04-13 22:27 ` [Cluster-devel] " Andreas Gruenbacher 2016-04-13 22:27 ` Andreas Gruenbacher 2016-04-13 22:27 ` [PATCH 8/8] gfs2: Switch to generic xattr handlers Andreas Gruenbacher 2016-04-13 22:27 ` [Cluster-devel] " Andreas Gruenbacher 2016-04-13 22:27 ` Andreas Gruenbacher 2016-04-13 22:30 ` [PATCH 2/8] cifs: Check for equality with ACL_TYPE_ACCESS and ACL_TYPE_DEFAULT Andreas Gruenbacher 2016-04-13 22:30 ` [Cluster-devel] " Andreas Gruenbacher 2016-04-14 4:26 ` Steve French 2016-04-14 4:26 ` [Cluster-devel] " Steve French 2016-04-13 22:30 ` [PATCH 4/8] ceph: Get rid of d_find_alias in ceph_set_acl Andreas Gruenbacher 2016-04-13 22:30 ` [Cluster-devel] " Andreas Gruenbacher 2016-04-13 22:30 ` [PATCH 5/8] ceph: Switch to generic xattr handlers Andreas Gruenbacher 2016-04-13 22:30 ` [Cluster-devel] " Andreas Gruenbacher 2016-04-13 22:30 ` [PATCH 6/8] ceph: kill __ceph_removexattr() Andreas Gruenbacher 2016-04-13 22:30 ` [Cluster-devel] " Andreas Gruenbacher 2016-04-13 22:30 ` [PATCH 7/8] posix acls: Export xattr_handler functions Andreas Gruenbacher 2016-04-13 22:30 ` [Cluster-devel] " Andreas Gruenbacher
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1460586620-5717-2-git-send-email-agruenba@redhat.com \ --to=agruenba-h+wxahxf7alqt0dzr+alfa@public.gmane.org \ --cc=ceph-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \ --cc=cluster-devel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \ --cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \ --cc=sfrench-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org \ --cc=viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.