[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <499B1ECF.2020809@numericable.fr>
Date: Tue, 17 Feb 2009 21:32:15 +0100
From: etienne <etienne.basset@...ericable.fr>
To: Casey Schaufler <casey@...aufler-ca.com>
CC: Linux-Kernel <linux-kernel@...r.kernel.org>,
linux-security-module@...r.kernel.org
Subject: [PATCH] SMACK smacklabel : apply &MASK to IP inserted in /smack/netlabel
hello,
with current code it is possible to insert inconsistent IP/mask in /smack/netlabel
before patch :
==============
root@...enne-desktop:/home/etienne/linux-2.6# cat /smack/netlabel
12.67.3.2/15 @
12.67.3.1/15 @
12.67.2.1/15 @
12.67.2.1/16 @
12.67.1.1/16 @
0.0.0.0/0 @
the solution is to apply the mask to the IP inserted in /smack/netlabel
after the patch:
================
root@...enne-desktop:/home/etienne/linux-2.6# echo 12.67.3.2/15 @ > /smack/netlabel
root@...enne-desktop:/home/etienne/linux-2.6# cat /smack/netlabel
12.67.0.0/15 @
root@...enne-desktop:/home/etienne/linux-2.6# echo 12.67.3.1/15 @ > /smack/netlabel
root@...enne-desktop:/home/etienne/linux-2.6# cat /smack/netlabel
12.67.0.0/15 @
root@...enne-desktop:/home/etienne/linux-2.6# echo 12.67.3.3/15 @ > /smack/netlabel
root@...enne-desktop:/home/etienne/linux-2.6# cat /smack/netlabel
12.67.0.0/15 @
regards,
Etienne
Signed-off-by: <etienen.basset@...ericable.fr>
----
diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
index 8e42800..5717150 100644
--- a/security/smack/smackfs.c
+++ b/security/smack/smackfs.c
@@ -765,6 +765,7 @@ static ssize_t smk_write_netlbladdr(struct file *file, const char __user *buf,
mask.s_addr |= bebits;
bebits <<= 1;
}
+ newname.sin_addr.s_addr &= mask.s_addr;
/*
* Only allow one writer at a time. Writes should be
* quite rare and small in any case.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists