selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Smalley <sds@tycho.nsa.gov>
To: Dan Carpenter <dan.carpenter@oracle.com>, viro@zeniv.linux.org.uk
Cc: selinux@vger.kernel.org, Paul Moore <paul@paul-moore.com>
Subject: Re: [bug report] selinux: kill selinux_sb_get_mnt_opts()
Date: Tue, 5 Feb 2019 08:37:41 -0500	[thread overview]
Message-ID: <817f3005-1639-5e33-8fcf-8d43cc602a7e@tycho.nsa.gov> (raw)
In-Reply-To: <20190205102006.GA6230@kadam>

On 2/5/19 5:20 AM, Dan Carpenter wrote:
> Hello Al Viro,
> 
> The patch e3489f8974e1: "selinux: kill selinux_sb_get_mnt_opts()"
> from Dec 13, 2018, leads to the following static checker warning:
> 
> 	security/selinux/hooks.c:1075 show_sid()
> 	error: we previously assumed 'context' could be null (see line 1070)
> 
> security/selinux/hooks.c
>      1061 static int show_sid(struct seq_file *m, u32 sid)
>      1062 {
>      1063 	char *context = NULL;
>      1064 	u32 len;
>      1065 	int rc;
>      1066
>      1067 	rc = security_sid_to_context(&selinux_state, sid,
>      1068 					     &context, &len);
>      1069 	if (!rc) {
>      1070 		bool has_comma = context && strchr(context, ',');
>                                           ^^^^^^^
> Can context be NULL?

No, security_sid_to_context() should only return 0 if it has set context 
to a non-NULL value.

> 
>      1071
>      1072 		seq_putc(m, '=');
>      1073 		if (has_comma)
>      1074 			seq_putc(m, '\"');
> --> 1075 		seq_escape(m, context, "\"\n\\");
>                                        ^^^^^^^
> Because if it is, then we're toasted when we pass it to seq_escape().
> 
>      1076 		if (has_comma)
>      1077 			seq_putc(m, '\"');
>      1078 	}
>      1079 	kfree(context);
>      1080 	return rc;
>      1081 }
> 
> regards,
> dan carpenter
> 


      reply	other threads:[~2019-02-05 13:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-05 10:20 [bug report] selinux: kill selinux_sb_get_mnt_opts() Dan Carpenter
2019-02-05 13:37 ` Stephen Smalley [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=817f3005-1639-5e33-8fcf-8d43cc602a7e@tycho.nsa.gov \
    --to=sds@tycho.nsa.gov \
    --cc=dan.carpenter@oracle.com \
    --cc=paul@paul-moore.com \
    --cc=selinux@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).