vfs_extattr: Allow extattr names up to the full max
Extattr names are allowed to be 255 bytes -- not 254 bytes plus trailing NUL. Provide a 256 buffer so that copyinstr() has room for the trailing NUL. Re-enable test for maximal name lengths. PR: 208965 Reported by: asomers Reviewed by: asomers Differential Revision: https://reviews.freebsd.org/D24584
This commit is contained in:
parent
b18e0a534f
commit
b21ae0ff6f
@ -82,7 +82,7 @@ sys_extattrctl(struct thread *td, struct extattrctl_args *uap)
|
||||
struct vnode *filename_vp;
|
||||
struct nameidata nd;
|
||||
struct mount *mp, *mp_writable;
|
||||
char attrname[EXTATTR_MAXNAMELEN];
|
||||
char attrname[EXTATTR_MAXNAMELEN + 1];
|
||||
int error;
|
||||
|
||||
AUDIT_ARG_CMD(uap->cmd);
|
||||
@ -92,7 +92,7 @@ sys_extattrctl(struct thread *td, struct extattrctl_args *uap)
|
||||
* invoke the VFS call so as to pass in NULL there if needed.
|
||||
*/
|
||||
if (uap->attrname != NULL) {
|
||||
error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN,
|
||||
error = copyinstr(uap->attrname, attrname, sizeof(attrname),
|
||||
NULL);
|
||||
if (error)
|
||||
return (error);
|
||||
@ -231,13 +231,13 @@ int
|
||||
sys_extattr_set_fd(struct thread *td, struct extattr_set_fd_args *uap)
|
||||
{
|
||||
struct file *fp;
|
||||
char attrname[EXTATTR_MAXNAMELEN];
|
||||
char attrname[EXTATTR_MAXNAMELEN + 1];
|
||||
cap_rights_t rights;
|
||||
int error;
|
||||
|
||||
AUDIT_ARG_FD(uap->fd);
|
||||
AUDIT_ARG_VALUE(uap->attrnamespace);
|
||||
error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL);
|
||||
error = copyinstr(uap->attrname, attrname, sizeof(attrname), NULL);
|
||||
if (error)
|
||||
return (error);
|
||||
AUDIT_ARG_TEXT(attrname);
|
||||
@ -293,11 +293,11 @@ kern_extattr_set_path(struct thread *td, const char *path, int attrnamespace,
|
||||
const char *uattrname, void *data, size_t nbytes, int follow)
|
||||
{
|
||||
struct nameidata nd;
|
||||
char attrname[EXTATTR_MAXNAMELEN];
|
||||
char attrname[EXTATTR_MAXNAMELEN + 1];
|
||||
int error;
|
||||
|
||||
AUDIT_ARG_VALUE(attrnamespace);
|
||||
error = copyinstr(uattrname, attrname, EXTATTR_MAXNAMELEN, NULL);
|
||||
error = copyinstr(uattrname, attrname, sizeof(attrname), NULL);
|
||||
if (error)
|
||||
return (error);
|
||||
AUDIT_ARG_TEXT(attrname);
|
||||
@ -398,13 +398,13 @@ int
|
||||
sys_extattr_get_fd(struct thread *td, struct extattr_get_fd_args *uap)
|
||||
{
|
||||
struct file *fp;
|
||||
char attrname[EXTATTR_MAXNAMELEN];
|
||||
char attrname[EXTATTR_MAXNAMELEN + 1];
|
||||
cap_rights_t rights;
|
||||
int error;
|
||||
|
||||
AUDIT_ARG_FD(uap->fd);
|
||||
AUDIT_ARG_VALUE(uap->attrnamespace);
|
||||
error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL);
|
||||
error = copyinstr(uap->attrname, attrname, sizeof(attrname), NULL);
|
||||
if (error)
|
||||
return (error);
|
||||
AUDIT_ARG_TEXT(attrname);
|
||||
@ -458,11 +458,11 @@ kern_extattr_get_path(struct thread *td, const char *path, int attrnamespace,
|
||||
const char *uattrname, void *data, size_t nbytes, int follow)
|
||||
{
|
||||
struct nameidata nd;
|
||||
char attrname[EXTATTR_MAXNAMELEN];
|
||||
char attrname[EXTATTR_MAXNAMELEN + 1];
|
||||
int error;
|
||||
|
||||
AUDIT_ARG_VALUE(attrnamespace);
|
||||
error = copyinstr(uattrname, attrname, EXTATTR_MAXNAMELEN, NULL);
|
||||
error = copyinstr(uattrname, attrname, sizeof(attrname), NULL);
|
||||
if (error)
|
||||
return (error);
|
||||
AUDIT_ARG_TEXT(attrname);
|
||||
@ -533,13 +533,13 @@ int
|
||||
sys_extattr_delete_fd(struct thread *td, struct extattr_delete_fd_args *uap)
|
||||
{
|
||||
struct file *fp;
|
||||
char attrname[EXTATTR_MAXNAMELEN];
|
||||
char attrname[EXTATTR_MAXNAMELEN + 1];
|
||||
cap_rights_t rights;
|
||||
int error;
|
||||
|
||||
AUDIT_ARG_FD(uap->fd);
|
||||
AUDIT_ARG_VALUE(uap->attrnamespace);
|
||||
error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL);
|
||||
error = copyinstr(uap->attrname, attrname, sizeof(attrname), NULL);
|
||||
if (error)
|
||||
return (error);
|
||||
AUDIT_ARG_TEXT(attrname);
|
||||
@ -590,11 +590,11 @@ kern_extattr_delete_path(struct thread *td, const char *path, int attrnamespace,
|
||||
const char *uattrname, int follow)
|
||||
{
|
||||
struct nameidata nd;
|
||||
char attrname[EXTATTR_MAXNAMELEN];
|
||||
char attrname[EXTATTR_MAXNAMELEN + 1];
|
||||
int error;
|
||||
|
||||
AUDIT_ARG_VALUE(attrnamespace);
|
||||
error = copyinstr(uattrname, attrname, EXTATTR_MAXNAMELEN, NULL);
|
||||
error = copyinstr(uattrname, attrname, sizeof(attrname), NULL);
|
||||
if (error)
|
||||
return(error);
|
||||
AUDIT_ARG_TEXT(attrname);
|
||||
|
@ -75,9 +75,6 @@ long_name_body() {
|
||||
atf_skip "Filesystem not reporting NAME_MAX; skipping testcase"
|
||||
fi
|
||||
|
||||
# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=208965
|
||||
atf_expect_fail "BUG 208965 extattr(2) doesn't allow maxlen attr names"
|
||||
|
||||
ATTRNAME=`jot -b X -s "" $NAME_MAX 0`
|
||||
touch foo
|
||||
atf_check -s exit:0 -o empty setextattr user $ATTRNAME myvalue foo
|
||||
|
Loading…
Reference in New Issue
Block a user