Bug 139304 - acl_get_link_np() fails with "Invalid argument" on ZFS
Summary: acl_get_link_np() fails with "Invalid argument" on ZFS
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: sparc64 (show other bugs)
Version: 9.0-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: Edward Tomasz Napierala
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-02 09:20 UTC by Dmitry Afanasiev
Modified: 2009-11-06 11:30 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Afanasiev 2009-10-02 09:20:01 UTC
acl_get_link_np(name, ACL_TYPE_NFS4) on any ZFS returns NULL with errno=EINVAL.

As result I have errors in ls -l output like this:
# /bin/ls -ld /
ls: /: Invalid argument
drwxr-xr-x  19 root  wheel  - 25 Sep 29 14:59 /

Also cp -p return 1 and buildworld fails with following messages:
===> share/zoneinfo (all)
cp -p /usr/src/share/zoneinfo/yearistype.sh yearistype
cp: failed to get acl entries while setting yearistype: Invalid argument
*** Error code 1

Also this breaks building of some ports like www/apache22:
configure.in:190: the top level
rebuilding rpm spec file
rebuilding srclib/apr-util/configure

Looking for apr source in /var/ports/usr/ports/www/apache22/work/httpd-2.2.13/srclib/apr
cp: failed to get acl entries while setting build/get-version.sh: Invalid argument
cp: failed to get acl entries while setting build/config.sub: Invalid argument
cp: failed to get acl entries while setting build/config.guess: Invalid argument
cp: failed to get acl entries while setting build/install.sh: Invalid argument
cp: failed to get acl entries while setting build/find_apr.m4: Invalid argument
cp: failed to get acl entries while setting build/apr_common.m4: Invalid argument
./buildconf failed for apr-util
*** Error code 1

How-To-Repeat: # zpool create tank `mdconfig -a -t swap -s 64m`
# ls -ld /tank
ls: /tank: Invalid argument
drwxr-xr-x  2 root  wheel  - 2 Oct  2 12:09 /tank/
Comment 1 Edward Tomasz Napierala freebsd_committer freebsd_triage 2009-10-02 11:23:28 UTC
Responsible Changed
From-To: freebsd-sparc64->trasz

I'll take it.
Comment 2 Dmitry Afanasiev 2009-10-05 08:39:01 UTC
In sys/kern/vfs_acl.c around line 164 I have added this check:

         default:
+printf("%li != %i\n", fuword((char *)user_acl + offsetof(struct acl, 
acl_maxcnt)), ACL_MAX_ENTRIES);
                 if (fuword((char *)user_acl +
                     offsetof(struct acl, acl_maxcnt)) != ACL_MAX_ENTRIES)
                         return (EINVAL);

And I got many messages with:
1090921693184 != 254

I think here is a type conversion or address arithmetic error or a
problem with not considered difference in byte order.

IMHO, also same problem may affect NFSv4.
Comment 3 dfilter service freebsd_committer freebsd_triage 2009-10-05 20:57:06 UTC
Author: trasz
Date: Mon Oct  5 19:56:56 2009
New Revision: 197789
URL: http://svn.freebsd.org/changeset/base/197789

Log:
  Fix NFSv4 ACLs on sparc64.  Turns out that fuword(9) fetches 64 bits
  instead of sizeof(int), and on sparc64 that resulted in fetching wrong
  value for acl_maxcnt, which in turn caused __acl_get_link(2) to fail
  with EINVAL.
  
  PR:		sparc64/139304
  Submitted by:	Dmitry Afanasiev <KOT at MATPOCKuH.Ru>

Modified:
  head/sys/kern/vfs_acl.c

Modified: head/sys/kern/vfs_acl.c
==============================================================================
--- head/sys/kern/vfs_acl.c	Mon Oct  5 19:29:49 2009	(r197788)
+++ head/sys/kern/vfs_acl.c	Mon Oct  5 19:56:56 2009	(r197789)
@@ -161,7 +161,7 @@ acl_copyout(struct acl *kernel_acl, void
 		break;
 
 	default:
-		if (fuword((char *)user_acl +
+		if (fuword32((char *)user_acl +
 		    offsetof(struct acl, acl_maxcnt)) != ACL_MAX_ENTRIES)
 			return (EINVAL);
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 4 Edward Tomasz Napierala freebsd_committer freebsd_triage 2009-10-05 20:57:14 UTC
State Changed
From-To: open->closed

Committed. Thanks!
Comment 5 dfilter service freebsd_committer freebsd_triage 2009-11-06 09:39:50 UTC
Author: trasz
Date: Fri Nov  6 09:39:35 2009
New Revision: 198975
URL: http://svn.freebsd.org/changeset/base/198975

Log:
  MFC r197789:
  
  Fix ACL support on sparc64.  Turns out that fuword(9) fetches 64 bits
  instead of sizeof(int), and on sparc64 that resulted in fetching wrong
  value for acl_maxcnt, which in turn caused __acl_get_link(2) to fail
  with EINVAL.
  
  PR:		sparc64/139304
  Submitted by:	Dmitry Afanasiev <KOT at MATPOCKuH.Ru>

Modified:
  stable/8/sys/kern/vfs_acl.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/kern/vfs_acl.c
==============================================================================
--- stable/8/sys/kern/vfs_acl.c	Fri Nov  6 08:08:47 2009	(r198974)
+++ stable/8/sys/kern/vfs_acl.c	Fri Nov  6 09:39:35 2009	(r198975)
@@ -161,7 +161,7 @@ acl_copyout(struct acl *kernel_acl, void
 		break;
 
 	default:
-		if (fuword((char *)user_acl +
+		if (fuword32((char *)user_acl +
 		    offsetof(struct acl, acl_maxcnt)) != ACL_MAX_ENTRIES)
 			return (EINVAL);
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 6 dfilter service freebsd_committer freebsd_triage 2009-11-06 11:29:24 UTC
Author: trasz
Date: Fri Nov  6 11:29:10 2009
New Revision: 198984
URL: http://svn.freebsd.org/changeset/base/198984

Log:
  MFC r197789:
  
  Fix ACL support on sparc64.  Turns out that fuword(9) fetches 64 bits
  instead of sizeof(int), and on sparc64 that resulted in fetching wrong
  value for acl_maxcnt, which in turn caused __acl_get_link(2) to fail
  with EINVAL.
  
  PR:		sparc64/139304
  Submitted by:	Dmitry Afanasiev <KOT at MATPOCKuH.Ru>
  Approved by:	re (kib)

Modified:
  releng/8.0/sys/kern/vfs_acl.c
Directory Properties:
  releng/8.0/sys/   (props changed)
  releng/8.0/sys/amd64/include/xen/   (props changed)
  releng/8.0/sys/cddl/contrib/opensolaris/   (props changed)
  releng/8.0/sys/contrib/dev/acpica/   (props changed)
  releng/8.0/sys/contrib/pf/   (props changed)
  releng/8.0/sys/dev/xen/xenpci/   (props changed)

Modified: releng/8.0/sys/kern/vfs_acl.c
==============================================================================
--- releng/8.0/sys/kern/vfs_acl.c	Fri Nov  6 11:17:33 2009	(r198983)
+++ releng/8.0/sys/kern/vfs_acl.c	Fri Nov  6 11:29:10 2009	(r198984)
@@ -161,7 +161,7 @@ acl_copyout(struct acl *kernel_acl, void
 		break;
 
 	default:
-		if (fuword((char *)user_acl +
+		if (fuword32((char *)user_acl +
 		    offsetof(struct acl, acl_maxcnt)) != ACL_MAX_ENTRIES)
 			return (EINVAL);
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"