linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xfs: Initialize label array properly
@ 2019-08-30  5:37 Austin Kim
  2019-08-30  5:39 ` Darrick J. Wong
  2019-08-30  7:31 ` Dave Chinner
  0 siblings, 2 replies; 4+ messages in thread
From: Austin Kim @ 2019-08-30  5:37 UTC (permalink / raw)
  To: darrick.wong; +Cc: linux-xfs, linux-kernel, austindh.kim

In case kernel stack variable is not initialized properly,
there is a risk of kernel information disclosure.

So, initialize 'char label[]' array with null characters.

Signed-off-by: Austin Kim <austindh.kim@gmail.com>
---
 fs/xfs/xfs_ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 9ea5166..09b3bee 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -2037,7 +2037,7 @@ xfs_ioc_setlabel(
 	char			__user *newlabel)
 {
 	struct xfs_sb		*sbp = &mp->m_sb;
-	char			label[XFSLABEL_MAX + 1];
+	char			label[XFSLABEL_MAX + 1] = {0};
 	size_t			len;
 	int			error;
 
-- 
2.6.2


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

* Re: [PATCH] xfs: Initialize label array properly
  2019-08-30  5:37 [PATCH] xfs: Initialize label array properly Austin Kim
@ 2019-08-30  5:39 ` Darrick J. Wong
  2019-08-30 14:53   ` Austin Kim
  2019-08-30  7:31 ` Dave Chinner
  1 sibling, 1 reply; 4+ messages in thread
From: Darrick J. Wong @ 2019-08-30  5:39 UTC (permalink / raw)
  To: Austin Kim; +Cc: linux-xfs, linux-kernel

On Fri, Aug 30, 2019 at 02:37:07PM +0900, Austin Kim wrote:
> In case kernel stack variable is not initialized properly,
> there is a risk of kernel information disclosure.
> 
> So, initialize 'char label[]' array with null characters.

Got a testcase for this?  At least a couple other filesystems implement
this ioctl too, which means they all should be checked/tested on a
regular basis.

--D

> Signed-off-by: Austin Kim <austindh.kim@gmail.com>
> ---
>  fs/xfs/xfs_ioctl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index 9ea5166..09b3bee 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -2037,7 +2037,7 @@ xfs_ioc_setlabel(
>  	char			__user *newlabel)
>  {
>  	struct xfs_sb		*sbp = &mp->m_sb;
> -	char			label[XFSLABEL_MAX + 1];
> +	char			label[XFSLABEL_MAX + 1] = {0};
>  	size_t			len;
>  	int			error;
>  
> -- 
> 2.6.2
> 

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

* Re: [PATCH] xfs: Initialize label array properly
  2019-08-30  5:37 [PATCH] xfs: Initialize label array properly Austin Kim
  2019-08-30  5:39 ` Darrick J. Wong
@ 2019-08-30  7:31 ` Dave Chinner
  1 sibling, 0 replies; 4+ messages in thread
From: Dave Chinner @ 2019-08-30  7:31 UTC (permalink / raw)
  To: Austin Kim; +Cc: darrick.wong, linux-xfs, linux-kernel

On Fri, Aug 30, 2019 at 02:37:07PM +0900, Austin Kim wrote:
> In case kernel stack variable is not initialized properly,
> there is a risk of kernel information disclosure.
> 
> So, initialize 'char label[]' array with null characters.

Can you describe the information disclosure vector here? I can't see
any, mostly because this is the "set label" function and that
doesn't return anything to userspace.

We also zero the on-disk label before we copy the user label into
it, so I don't see that anything can leak onto disk, either...

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

* Re: [PATCH] xfs: Initialize label array properly
  2019-08-30  5:39 ` Darrick J. Wong
@ 2019-08-30 14:53   ` Austin Kim
  0 siblings, 0 replies; 4+ messages in thread
From: Austin Kim @ 2019-08-30 14:53 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs, linux-kernel

2019년 8월 30일 (금) 오후 2:39, Darrick J. Wong <darrick.wong@oracle.com>님이 작성:
>
> On Fri, Aug 30, 2019 at 02:37:07PM +0900, Austin Kim wrote:
> > In case kernel stack variable is not initialized properly,
> > there is a risk of kernel information disclosure.
> >
> > So, initialize 'char label[]' array with null characters.
>
> Got a testcase for this?  At least a couple other filesystems implement
> this ioctl too, which means they all should be checked/tested on a
> regular basis.

Thanks for feedback.
As you pointed out, I figured out ioctl(e.g: ext4_ioctl, f2fs_ioctl)
of other file system is implemented with the same ways.
Please ignore the patch in this mail thread.

BR,
Austin Kim

>
> --D
>
> > Signed-off-by: Austin Kim <austindh.kim@gmail.com>
> > ---
> >  fs/xfs/xfs_ioctl.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> > index 9ea5166..09b3bee 100644
> > --- a/fs/xfs/xfs_ioctl.c
> > +++ b/fs/xfs/xfs_ioctl.c
> > @@ -2037,7 +2037,7 @@ xfs_ioc_setlabel(
> >       char                    __user *newlabel)
> >  {
> >       struct xfs_sb           *sbp = &mp->m_sb;
> > -     char                    label[XFSLABEL_MAX + 1];
> > +     char                    label[XFSLABEL_MAX + 1] = {0};
> >       size_t                  len;
> >       int                     error;
> >
> > --
> > 2.6.2
> >

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

end of thread, other threads:[~2019-08-30 14:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-30  5:37 [PATCH] xfs: Initialize label array properly Austin Kim
2019-08-30  5:39 ` Darrick J. Wong
2019-08-30 14:53   ` Austin Kim
2019-08-30  7:31 ` Dave Chinner

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