2003-02-27 19:36:37

by Valdis Klētnieks

[permalink] [raw]
Subject: 2.5.63 - if/ifdef janitor work - actual bug found..

The previous patches cleaned things up enough that -Wundef doesn't trigger
a lot of false positives.. which made this one visible. There's no other
occurrence of MAX_OWNER_OVERRIDE in the tree, and it's obviously not
MAY_OWNER_OVERRIDE either. Looks like just remaindered cruft that I've
cleaned up....

--- include/linux/nfsd/nfsd.h.dist 2003-02-24 14:06:01.000000000 -0500
+++ include/linux/nfsd/nfsd.h 2003-02-27 00:21:53.957428476 -0500
@@ -39,7 +39,7 @@
#define MAY_LOCK 32
#define MAY_OWNER_OVERRIDE 64
#define MAY_LOCAL_ACCESS 128 /* IRIX doing local access check on device special file*/
-#if (MAY_SATTR | MAY_TRUNC | MAY_LOCK | MAX_OWNER_OVERRIDE | MAY_LOCAL_ACCESS) & (MAY_READ | MAY_WRITE | MAY_EXEC | MAY_OWNER_OVERRIDE)
+#if (MAY_SATTR | MAY_TRUNC | MAY_LOCK | MAY_LOCAL_ACCESS) & (MAY_READ | MAY_WRITE | MAY_EXEC | MAY_OWNER_OVERRIDE)
# error "please use a different value for MAY_SATTR or MAY_TRUNC or MAY_LOCK or MAY_OWNER_OVERRIDE."
#endif
#define MAY_CREATE (MAY_EXEC|MAY_WRITE)



Attachments:
(No filename) (226.00 B)

2003-02-27 20:32:39

by Thomas Molina

[permalink] [raw]
Subject: Re: 2.5.63 - if/ifdef janitor work - actual bug found..

On Thu, 27 Feb 2003 [email protected] wrote:

> The previous patches cleaned things up enough that -Wundef doesn't trigger
> a lot of false positives.. which made this one visible. There's no other
> occurrence of MAX_OWNER_OVERRIDE in the tree, and it's obviously not
> MAY_OWNER_OVERRIDE either. Looks like just remaindered cruft that I've
> cleaned up....
>
> --- include/linux/nfsd/nfsd.h.dist 2003-02-24 14:06:01.000000000 -0500
> +++ include/linux/nfsd/nfsd.h 2003-02-27 00:21:53.957428476 -0500
> @@ -39,7 +39,7 @@
> #define MAY_LOCK 32
> #define MAY_OWNER_OVERRIDE 64
> #define MAY_LOCAL_ACCESS 128 /* IRIX doing local access check on device special file*/
> -#if (MAY_SATTR | MAY_TRUNC | MAY_LOCK | MAX_OWNER_OVERRIDE | MAY_LOCAL_ACCESS) & (MAY_READ | MAY_WRITE | MAY_EXEC | MAY_OWNER_OVERRIDE)
> +#if (MAY_SATTR | MAY_TRUNC | MAY_LOCK | MAY_LOCAL_ACCESS) & (MAY_READ | MAY_WRITE | MAY_EXEC | MAY_OWNER_OVERRIDE)
> # error "please use a different value for MAY_SATTR or MAY_TRUNC or MAY_LOCK or MAY_OWNER_OVERRIDE."
> #endif
> #define MAY_CREATE (MAY_EXEC|MAY_WRITE)


Why couldn't it be MAY_OWNER_OVERRIDE??? There are occurrences of
MAY_OWNER_OVERRIDE
What about the following in fs/nfsd/vfs.c ??

/*
* Set various file attributes.
* N.B. After this call fhp needs an fh_put
*/
int
nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr
*iap,
int check_guard, time_t guardtime)
{
struct dentry *dentry;
struct inode *inode;
int accmode = MAY_SATTR;
int ftype = 0;
int imode;
int err;
int size_change = 0;

if (iap->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_SIZE))
accmode |= MAY_WRITE|MAY_OWNER_OVERRIDE;
if (iap->ia_valid & ATTR_SIZE)
ftype = S_IFREG;


Or this ???

/* The size case is special. It changes the file as well as the
attributes. */
if (iap->ia_valid & ATTR_SIZE) {
if (iap->ia_size < inode->i_size) {
err = nfsd_permission(fhp->fh_export, dentry,
MAY_TRUNC|MAY_OWNER_OVERRIDE);
if (err)
goto out;
}


Or this ???

/*
* If we get here, then the client has already done an "open",
* and (hopefully) checked permission - so allow OWNER_OVERRIDE
* in case a chmod has now revoked permission.
*/
err = fh_verify(rqstp, fhp, type, access | MAY_OWNER_OVERRIDE);
if (err)
goto out;




2003-02-27 20:52:43

by Valdis Klētnieks

[permalink] [raw]
Subject: [UPDATED PATCH] Re: 2.5.63 - if/ifdef janitor work - actual bug found..

On Thu, 27 Feb 2003 14:42:50 CST, Thomas Molina said:

> Why couldn't it be MAY_OWNER_OVERRIDE??? There are occurrences of
> MAY_OWNER_OVERRIDE

Yes, but then the logic becomes:

#if (a | b | MAY_OWNER_OVERRIDE) & (c | d | MAY_OWNER_OVERRIDE)
#error ....
#endif

so it will *alway* error out. Tried it, it #errored, I looked at it
more closely. The logic there is that it wants to have the two sets
(SATTR, TRUNC, LOCK, LOCAL_ACCESS) and (READ, WRITE, EXEC, OVERRIDE)
as disjoint sets of bits.

And yes, somebody else pointed out that the #error test probably needs
to be cleaned up too..

/Valdis

--- include/linux/nfsd/nfsd.h.dist 2003-02-24 14:06:01.000000000 -0500
+++ include/linux/nfsd/nfsd.h 2003-02-27 16:01:59.000000000 -0500
@@ -39,8 +39,8 @@
#define MAY_LOCK 32
#define MAY_OWNER_OVERRIDE 64
#define MAY_LOCAL_ACCESS 128 /* IRIX doing local access check on device special file*/
-#if (MAY_SATTR | MAY_TRUNC | MAY_LOCK | MAX_OWNER_OVERRIDE | MAY_LOCAL_ACCESS) & (MAY_READ | MAY_WRITE | MAY_EXEC | MAY_OWNER_OVERRIDE)
-# error "please use a different value for MAY_SATTR or MAY_TRUNC or MAY_LOCK or MAY_OWNER_OVERRIDE."
+#if (MAY_SATTR | MAY_TRUNC | MAY_LOCK | MAY_LOCAL_ACCESS) & (MAY_READ | MAY_WRITE | MAY_EXEC | MAY_OWNER_OVERRIDE)
+# error "please use a different value for MAY_SATTR or MAY_TRUNC or MAY_LOCK or MAY_LOCAL_ACCESS."
#endif
#define MAY_CREATE (MAY_EXEC|MAY_WRITE)
#define MAY_REMOVE (MAY_EXEC|MAY_WRITE|MAY_TRUNC)


Attachments:
(No filename) (226.00 B)

2003-02-28 14:11:13

by Bill Davidsen

[permalink] [raw]
Subject: Re: [UPDATED PATCH] Re: 2.5.63 - if/ifdef janitor work - actual bug found..

On Thu, 27 Feb 2003 [email protected] wrote:

> On Thu, 27 Feb 2003 14:42:50 CST, Thomas Molina said:
>
> > Why couldn't it be MAY_OWNER_OVERRIDE??? There are occurrences of
> > MAY_OWNER_OVERRIDE
>
> Yes, but then the logic becomes:
>
> #if (a | b | MAY_OWNER_OVERRIDE) & (c | d | MAY_OWNER_OVERRIDE)
> #error ....
> #endif
>
> so it will *alway* error out. Tried it, it #errored, I looked at it
> more closely. The logic there is that it wants to have the two sets
> (SATTR, TRUNC, LOCK, LOCAL_ACCESS) and (READ, WRITE, EXEC, OVERRIDE)
> as disjoint sets of bits.

Thanks for that clarification, I had kept the original message to ask the
same question. Actually, while you are fixing this, how about putting in a
comment line saying what you just told us? It makes reading the code much
easier!

--
bill davidsen <[email protected]>
CTO, TMR Associates, Inc
Doing interesting things with little computers since 1979.