[PATCH 1/1] fscaps: fix cap sanity check

From: Serge E . Hallyn
Date: Wed Nov 08 2006 - 00:16:06 EST


When checking for valid capabilities on files, we want to
make sure that unused bits are not set. Fix the calculation
of the highest bit checked.

Signed-off-by: Serge E. Hallyn <serue@xxxxxxxxxx>
---
security/commoncap.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/security/commoncap.c b/security/commoncap.c
index 6a0d033..6f5e46c 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -133,15 +133,15 @@ static int check_cap_sanity(struct vfs_c
if (cap->version != _LINUX_CAPABILITY_VERSION)
return -EPERM;

- for (i=CAP_NUMCAPS; i<sizeof(cap->effective); i++) {
+ for (i=CAP_NUMCAPS; i<8*sizeof(cap->effective); i++) {
if (cap->effective & CAP_TO_MASK(i))
return -EPERM;
}
- for (i=CAP_NUMCAPS; i<sizeof(cap->permitted); i++) {
+ for (i=CAP_NUMCAPS; i<8*sizeof(cap->permitted); i++) {
if (cap->permitted & CAP_TO_MASK(i))
return -EPERM;
}
- for (i=CAP_NUMCAPS; i<sizeof(cap->inheritable); i++) {
+ for (i=CAP_NUMCAPS; i<8*sizeof(cap->inheritable); i++) {
if (cap->inheritable & CAP_TO_MASK(i))
return -EPERM;
}
--
1.4.3.3

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/