From: Casey Schaufler <casey@schaufler-ca.com>
To: Casey Schaufler <casey@schaufler-ca.com>
Cc: LKLM <linux-kernel@vger.kernel.org>,
LSM <linux-security-module@vger.kernel.org>
Subject: Re: [PATCH] Smack: user access check bounds
Date: Wed, 20 Jun 2012 15:02:21 -0700 [thread overview]
Message-ID: <4FE2486D.9030404@schaufler-ca.com> (raw)
In-Reply-To: <4FDFDD80.9010007@schaufler-ca.com>
On 6/18/2012 7:01 PM, Casey Schaufler wrote:
> From: Casey Schaufler <casey@schaufler-ca.com>
> Subject: [PATCH] Smack: user access check bounds
>
> Some of the bounds checking used on the /smack/access
> interface was lost when support for long labels was
> added. No kernel access checks are affected, however
> this is a case where /smack/access could be used
> incorrectly and fail to detect the error. This patch
> reintroduces the original checks.
>
> Targeted for git://git.gitorious.org/smack-next/kernel.git
>
> Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Applied to git://git.gitorious.org/smack-next/kernel.git
>
> ---
>
> security/smack/smackfs.c | 26 ++++++++++++--------------
> 1 files changed, 12 insertions(+), 14 deletions(-)
>
> diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
> index 2152965..29b760d 100644
> --- a/security/smack/smackfs.c
> +++ b/security/smack/smackfs.c
> @@ -215,28 +215,27 @@ static int smk_set_access(struct smack_rule *srp, struct list_head *rule_list,
> * @access: access string
> * @rule: Smack rule
> * @import: if non-zero, import labels
> + * @len: label length limit
> *
> * Returns 0 on success, -1 on failure
> */
> static int smk_fill_rule(const char *subject, const char *object,
> const char *access, struct smack_rule *rule,
> - int import)
> + int import, int len)
> {
> - int rc = -1;
> - int done;
> const char *cp;
> struct smack_known *skp;
>
> if (import) {
> - rule->smk_subject = smk_import(subject, 0);
> + rule->smk_subject = smk_import(subject, len);
> if (rule->smk_subject == NULL)
> return -1;
>
> - rule->smk_object = smk_import(object, 0);
> + rule->smk_object = smk_import(object, len);
> if (rule->smk_object == NULL)
> return -1;
> } else {
> - cp = smk_parse_smack(subject, 0);
> + cp = smk_parse_smack(subject, len);
> if (cp == NULL)
> return -1;
> skp = smk_find_entry(cp);
> @@ -245,7 +244,7 @@ static int smk_fill_rule(const char *subject, const char *object,
> return -1;
> rule->smk_subject = skp->smk_known;
>
> - cp = smk_parse_smack(object, 0);
> + cp = smk_parse_smack(object, len);
> if (cp == NULL)
> return -1;
> skp = smk_find_entry(cp);
> @@ -257,7 +256,7 @@ static int smk_fill_rule(const char *subject, const char *object,
>
> rule->smk_access = 0;
>
> - for (cp = access, done = 0; *cp && !done; cp++) {
> + for (cp = access; *cp != '\0'; cp++) {
> switch (*cp) {
> case '-':
> break;
> @@ -282,13 +281,11 @@ static int smk_fill_rule(const char *subject, const char *object,
> rule->smk_access |= MAY_TRANSMUTE;
> break;
> default:
> - done = 1;
> - break;
> + return 0;
> }
> }
> - rc = 0;
>
> - return rc;
> + return 0;
> }
>
> /**
> @@ -304,7 +301,8 @@ static int smk_parse_rule(const char *data, struct smack_rule *rule, int import)
> int rc;
>
> rc = smk_fill_rule(data, data + SMK_LABELLEN,
> - data + SMK_LABELLEN + SMK_LABELLEN, rule, import);
> + data + SMK_LABELLEN + SMK_LABELLEN, rule, import,
> + SMK_LABELLEN);
> return rc;
> }
>
> @@ -340,7 +338,7 @@ static int smk_parse_long_rule(const char *data, struct smack_rule *rule,
> goto free_out_o;
>
> if (sscanf(data, "%s %s %s", subject, object, access) == 3)
> - rc = smk_fill_rule(subject, object, access, rule, import);
> + rc = smk_fill_rule(subject, object, access, rule, import, 0);
>
> kfree(access);
> free_out_o:
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
prev parent reply other threads:[~2012-06-20 22:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-19 2:01 [PATCH] Smack: user access check bounds Casey Schaufler
2012-06-20 22:02 ` Casey Schaufler [this message]
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=4FE2486D.9030404@schaufler-ca.com \
--to=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