selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selinuxfs: use scnprinft to get real length in sel_read_class
       [not found] <cover.1578274288.git.liuyang34@xiaomi.com>
@ 2020-01-06  1:56 ` liuyang34
  2020-01-06 20:49   ` Stephen Smalley
  2020-01-09 13:42   ` [PATCH] selinuxfs: use scnprintf " Markus Elfring
  0 siblings, 2 replies; 3+ messages in thread
From: liuyang34 @ 2020-01-06  1:56 UTC (permalink / raw)
  To: Paul Moore, Stephen Smalley, Eric Paris, selinux, linux-kernel; +Cc: liuyang34

as the return value of snprintf maybe over the size of TMPBUFLEN, 
use scnprintf to instead of it

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);
 }
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] selinuxfs: use scnprinft to get real length in sel_read_class
  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
  2020-01-09 13:42   ` [PATCH] selinuxfs: use scnprintf " Markus Elfring
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Smalley @ 2020-01-06 20:49 UTC (permalink / raw)
  To: liuyang34, Paul Moore, Eric Paris, selinux, linux-kernel; +Cc: liuyang34

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);
>   }
>   
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] selinuxfs: use scnprintf to get real length in sel_read_class
  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
@ 2020-01-09 13:42   ` Markus Elfring
  1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2020-01-09 13:42 UTC (permalink / raw)
  To: yangliuxm34, selinux, kernel-janitors
  Cc: linux-kernel, liuyang34, Eric Paris, Paul Moore, Stephen Smalley

> as the return value of snprintf maybe over the size of TMPBUFLEN,
> use scnprintf to instead of it

Please improve your commit message.


> Signed-off-by: liuyang34 …

Will this information need also an adjustment for the desired specification
of a real name?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=b07f636fca1c8fbba124b0082487c0b3890a0e0c#n458

Regards,
Markus

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-09 13:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [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
2020-01-09 13:42   ` [PATCH] selinuxfs: use scnprintf " Markus Elfring

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).