public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Casey Schaufler <casey@schaufler-ca.com>
To: Roel Kluin <roel.kluin@gmail.com>
Cc: jmorris@namei.org, lkml <linux-kernel@vger.kernel.org>,
	linux-security-module@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] smack:beyond ARRAY_SIZE of data
Date: Thu, 21 May 2009 19:30:00 -0700	[thread overview]
Message-ID: <4A160E28.1010306@schaufler-ca.com> (raw)
In-Reply-To: <4A15848E.5030403@gmail.com>

Roel Kluin wrote:
> Do not go beyond ARRAY_SIZE of data
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
>   

Acked-by: Casey Schaufler <casey@schaufler-ca.com>

Thank you. The fix is appreciated.


> ---
>   
>>> -	if (count < SMK_NETLBLADDRMIN || count > SMK_NETLBLADDRMAX)
>>> +	if (count < SMK_NETLBLADDRMIN || count >= SMK_NETLBLADDRMAX)
>>>   
>>>       
>> There is a problem here, but this won't fix it. The buffer needs to be
>> allocated bigger than the potential contents (should be
>> SMK_NETLBLADDRMAX + 1 instead of SMK_NETLBLADDRMAX. Your patch will clip
>> the last byte off of a maximum length specification.
>>     
>
> Ok, how about this?
>
> diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
> index e03a7e1..10a4604 100644
> --- a/security/smack/smackfs.c
> +++ b/security/smack/smackfs.c
> @@ -775,7 +775,7 @@ static ssize_t smk_write_netlbladdr(struct file *file, const char __user *buf,
>  	struct sockaddr_in newname;
>  	char smack[SMK_LABELLEN];
>  	char *sp;
> -	char data[SMK_NETLBLADDRMAX];
> +	char data[SMK_NETLBLADDRMAX + 1];
>  	char *host = (char *)&newname.sin_addr.s_addr;
>  	int rc;
>  	struct netlbl_audit audit_info;
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>
>
>   

  reply	other threads:[~2009-05-22  2:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-20 15:19 [PATCH] smack:beyond ARRAY_SIZE of data Roel Kluin
2009-05-20 22:27 ` Casey Schaufler
2009-05-21 16:42   ` Roel Kluin
2009-05-22  2:30     ` Casey Schaufler [this message]
2009-05-22  2:42       ` James Morris
2009-05-22  4:35         ` Casey Schaufler

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=4A160E28.1010306@schaufler-ca.com \
    --to=casey@schaufler-ca.com \
    --cc=akpm@linux-foundation.org \
    --cc=jmorris@namei.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=roel.kluin@gmail.com \
    /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