From: Stephen Smalley <sds@tycho.nsa.gov>
To: Eric Paris <eparis@redhat.com>
Cc: selinux@tycho.nsa.gov, jmorris@namei.org
Subject: Re: [PATCH 3/3] SELinux: better printk when file with invalid label found
Date: Tue, 10 Feb 2009 09:14:43 -0500 [thread overview]
Message-ID: <1234275283.4642.29.camel@localhost.localdomain> (raw)
In-Reply-To: <20090209213724.9537.35275.stgit@paris.rdu.redhat.com>
On Mon, 2009-02-09 at 16:37 -0500, Eric Paris wrote:
> Currently when an inode is read into the kernel with an invalid label
> string (can often happen with removable media) we output a string like:
>
> SELinux: inode_doinit_with_dentry: context_to_sid([SOME INVALID LABEL])
> returned -22 dor dev=[blah] ino=[blah]
>
> Which is all but incomprehensible to all but a couple of us. Instead, on
> EINVAL only, I plan to output a much more user friendly string and I plan to
> ratelimit the printk since many of these could be generated very rapidly.
>
> Signed-off-by: Eric Paris <eparis@redhat.com>
You could likely further drop the function name in all cases, and maybe
even the error code (is there no strerror() equivalent in the kernel?).
> ---
>
> security/selinux/hooks.c | 17 +++++++++++++----
> 1 files changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
> index e2bdb28..7fe870d 100644
> --- a/security/selinux/hooks.c
> +++ b/security/selinux/hooks.c
> @@ -1335,10 +1335,19 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
> sbsec->def_sid,
> GFP_NOFS);
> if (rc) {
> - printk(KERN_WARNING "SELinux: %s: context_to_sid(%s) "
> - "returned %d for dev=%s ino=%ld\n",
> - __func__, context, -rc,
> - inode->i_sb->s_id, inode->i_ino);
> + char *dev = inode->i_sb->s_id;
> + unsigned long ino = inode->i_ino;
> +
> + if (rc == -EINVAL) {
> + if (printk_ratelimit())
> + printk(KERN_NOTICE "SELinux: inode=%lu on dev=%s was found to have an invalid "
> + "context=%s. This indicates you may need to relabel the inode or the "
> + "filesystem in question.\n", ino, dev, context);
> + } else {
> + printk(KERN_WARNING "SELinux: %s: context_to_sid(%s) "
> + "returned %d for dev=%s ino=%ld\n",
> + __func__, context, -rc, dev, ino);
> + }
> kfree(context);
> /* Leave with the unlabeled SID */
> rc = 0;
--
Stephen Smalley
National Security Agency
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
next prev parent reply other threads:[~2009-02-10 14:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-09 21:37 [PATCH 1/3] SELinux: fix selinux to safely handle any bugs even when not CONFIG_BUG Eric Paris
2009-02-09 21:37 ` [PATCH 2/3] SELinux: call capabilities code directory Eric Paris
2009-02-10 14:06 ` Stephen Smalley
2009-02-10 14:30 ` Eric Paris
2009-02-09 21:37 ` [PATCH 3/3] SELinux: better printk when file with invalid label found Eric Paris
2009-02-10 14:14 ` Stephen Smalley [this message]
2009-02-10 14:30 ` Eric Paris
2009-02-10 14:59 ` Stephen Smalley
2009-02-10 14:00 ` [PATCH 1/3] SELinux: fix selinux to safely handle any bugs even when not CONFIG_BUG Stephen Smalley
2009-02-10 14:39 ` Eric Paris
2009-02-10 14:52 ` James Morris
2009-02-10 15:05 ` Stephen Smalley
2009-02-10 16:37 ` Paul Moore
2009-02-12 22:56 ` James Morris
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=1234275283.4642.29.camel@localhost.localdomain \
--to=sds@tycho.nsa.gov \
--cc=eparis@redhat.com \
--cc=jmorris@namei.org \
--cc=selinux@tycho.nsa.gov \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.