linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Smalley <sds@tycho.nsa.gov>
To: liuyang34 <yangliuxm34@gmail.com>,
	Paul Moore <paul@paul-moore.com>,
	Eric Paris <eparis@parisplace.org>,
	selinux@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: liuyang34 <liuyang34@xiaomi.com>
Subject: Re: [PATCH] selinuxfs: use scnprinft to get real length in sel_read_class
Date: Mon, 6 Jan 2020 15:49:16 -0500	[thread overview]
Message-ID: <f6dab965-b248-41e0-4cc2-06e140174f68@tycho.nsa.gov> (raw)
In-Reply-To: <ba3290e18f9867e110b77d058c3f8c7015bd868b.1578274288.git.liuyang34@xiaomi.com>

On 1/5/20 8:56 PM, liuyang34 wrote:
> as the return value of snprintf maybe over the size of TMPBUFLEN,
> use scnprintf to instead of it

Is there a reason you didn't make the same change to sel_read_perm()?

> 
> Signed-off-by: liuyang34 <liuyang34@xiaomi.com>
> ---
>   security/selinux/selinuxfs.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
> index ee94fa4..977c32d 100644
> --- a/security/selinux/selinuxfs.c
> +++ b/security/selinux/selinuxfs.c
> @@ -1672,7 +1672,7 @@ static ssize_t sel_read_class(struct file *file, char __user *buf,
>   {
>   	unsigned long ino = file_inode(file)->i_ino;
>   	char res[TMPBUFLEN];
> -	ssize_t len = snprintf(res, sizeof(res), "%d", sel_ino_to_class(ino));
> +	ssize_t len = scnprintf(res, sizeof(res), "%d", sel_ino_to_class(ino));
>   	return simple_read_from_buffer(buf, count, ppos, res, len);
>   }
>   
> 


  reply	other threads:[~2020-01-06 20:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1578274288.git.liuyang34@xiaomi.com>
2020-01-06  1:56 ` [PATCH] selinuxfs: use scnprinft to get real length in sel_read_class liuyang34
2020-01-06 20:49   ` Stephen Smalley [this message]
2020-01-09 13:42   ` [PATCH] selinuxfs: use scnprintf " Markus Elfring

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=f6dab965-b248-41e0-4cc2-06e140174f68@tycho.nsa.gov \
    --to=sds@tycho.nsa.gov \
    --cc=eparis@parisplace.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuyang34@xiaomi.com \
    --cc=paul@paul-moore.com \
    --cc=selinux@vger.kernel.org \
    --cc=yangliuxm34@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;
as well as URLs for NNTP newsgroup(s).