diff mbox series

[38/36] xfs_io: don't read garbage stack contents if INUMBERS goes nuts

Message ID 20190320193444.GB1183@magnolia (mailing list archive)
State Accepted, archived
Headers show
Series xfsprogs-5.0: fix various problems | expand

Commit Message

Darrick J. Wong March 20, 2019, 7:34 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

In theory INUMBERS will never return an ocount of zero, but on the off
chance it ever does we'll negative index the igroup array and return
stack contents for an inode number.  Don't do that.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 io/open.c |    3 +++
 1 file changed, 3 insertions(+)

Comments

Eric Sandeen April 4, 2019, 9:12 p.m. UTC | #1
On 3/20/19 2:34 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> In theory INUMBERS will never return an ocount of zero, but on the off
> chance it ever does we'll negative index the igroup array and return
> stack contents for an inode number.  Don't do that.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Is there more of a story behind this?  ;)

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
>  io/open.c |    3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/io/open.c b/io/open.c
> index f5fbd2c4..a406ea54 100644
> --- a/io/open.c
> +++ b/io/open.c
> @@ -698,6 +698,9 @@ get_last_inode(void)
>  		lastgrp = ocount;
>  	}
>  
> +	if (lastgrp == 0)
> +		return 0;
> +
>  	lastgrp--;
>  
>  	/* The last inode number in use */
>
Darrick J. Wong April 4, 2019, 9:39 p.m. UTC | #2
On Thu, Apr 04, 2019 at 04:12:18PM -0500, Eric Sandeen wrote:
> On 3/20/19 2:34 PM, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > In theory INUMBERS will never return an ocount of zero, but on the off
> > chance it ever does we'll negative index the igroup array and return
> > stack contents for an inode number.  Don't do that.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Is there more of a story behind this?  ;)

/me can't remember, I think it was just shutting up coverity complaints.

--D

> Reviewed-by: Eric Sandeen <sandeen@redhat.com>
> 
> > ---
> >  io/open.c |    3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/io/open.c b/io/open.c
> > index f5fbd2c4..a406ea54 100644
> > --- a/io/open.c
> > +++ b/io/open.c
> > @@ -698,6 +698,9 @@ get_last_inode(void)
> >  		lastgrp = ocount;
> >  	}
> >  
> > +	if (lastgrp == 0)
> > +		return 0;
> > +
> >  	lastgrp--;
> >  
> >  	/* The last inode number in use */
> >
diff mbox series

Patch

diff --git a/io/open.c b/io/open.c
index f5fbd2c4..a406ea54 100644
--- a/io/open.c
+++ b/io/open.c
@@ -698,6 +698,9 @@  get_last_inode(void)
 		lastgrp = ocount;
 	}
 
+	if (lastgrp == 0)
+		return 0;
+
 	lastgrp--;
 
 	/* The last inode number in use */