public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: etienne <etienne.basset@numericable.fr>
To: Casey Schaufler <casey@schaufler-ca.com>
Cc: Linux-Kernel <linux-kernel@vger.kernel.org>,
	linux-security-module@vger.kernel.org
Subject: [PATCH] SMACK smacklabel : apply &MASK to IP inserted in /smack/netlabel
Date: Tue, 17 Feb 2009 21:32:15 +0100	[thread overview]
Message-ID: <499B1ECF.2020809@numericable.fr> (raw)
In-Reply-To: <499B178B.9090601@numericable.fr>

hello,

with current code it is possible to insert inconsistent IP/mask in /smack/netlabel

before patch :
==============

root@etienne-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@etienne-desktop:/home/etienne/linux-2.6# echo 12.67.3.2/15 @ > /smack/netlabel           
root@etienne-desktop:/home/etienne/linux-2.6# cat /smack/netlabel                             
12.67.0.0/15 @                                                                                
root@etienne-desktop:/home/etienne/linux-2.6# echo 12.67.3.1/15 @ > /smack/netlabel                             
root@etienne-desktop:/home/etienne/linux-2.6# cat /smack/netlabel                             
12.67.0.0/15 @                                                                                
root@etienne-desktop:/home/etienne/linux-2.6# echo 12.67.3.3/15 @ > /smack/netlabel                             
root@etienne-desktop:/home/etienne/linux-2.6# cat /smack/netlabel                             
12.67.0.0/15 @                                                  

regards,
Etienne

Signed-off-by: <etienen.basset@numericable.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.



  reply	other threads:[~2009-02-17 20:32 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <fa.O38YY4pVfLlMFJNBI3mhgn+qOcQ@ifi.uio.no>
     [not found] ` <fa.c87eBVWyCqqi9h1c54QlwKDAIbg@ifi.uio.no>
     [not found]   ` <fa.f7jv/+EnhNJziduAqQS3XHiU6/A@ifi.uio.no>
     [not found]     ` <fa.1A5YyyPb1uCn//vnk7baNJGI0IM@ifi.uio.no>
     [not found]       ` <fa.HFpMNTzIQ1+pODZB3+XkfnipCfo@ifi.uio.no>
     [not found]         ` <fa.3IBoeBnwT1eZcqeO6DAE1tHBYc4@ifi.uio.no>
2009-02-17 20:01           ` [PATCH] SMACK netfilter smacklabel socket match etienne
2009-02-17 20:32             ` etienne [this message]
2009-02-17 23:54               ` [PATCH] SMACK smacklabel : apply &MASK to IP inserted in /smack/netlabel Paul Moore
2009-02-18  6:01                 ` Casey Schaufler
2009-02-18  7:25                 ` etienne
2009-02-17 22:39             ` [PATCH] SMACK netfilter smacklabel socket match David Miller
2009-02-17 23:52             ` Paul Moore
2009-02-18  7:23               ` etienne
2009-02-18 15:05                 ` Paul Moore
2009-02-18 17:09                   ` Casey Schaufler
2009-02-18 19:35                     ` etienne
2009-02-18 20:55                       ` Paul Moore
2009-02-20  4:36                       ` Casey Schaufler
2009-02-20 18:26                         ` etienne
2009-02-18 18:29                   ` etienne
2009-02-18 19:06                     ` Casey Schaufler
2009-02-18 21:16                       ` [PATCH] SMACK netlabel fixes etienne
2009-02-19  5:50                         ` Casey Schaufler
2009-02-19 15:24                         ` Paul Moore
2009-02-19 23:22                           ` [PATCH] SMACK netlabel fixes v2 etienne
2009-02-20 16:11                             ` Paul Moore
2009-02-18 19:18                     ` [PATCH] SMACK netfilter smacklabel socket match Paul Moore

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=499B1ECF.2020809@numericable.fr \
    --to=etienne.basset@numericable.fr \
    --cc=casey@schaufler-ca.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox