public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Eric Sandeen <sandeen@sandeen.net>, linux-xfs@vger.kernel.org
Subject: Re: [PATCH] xfs_logprint: Fix buffer overflow printing quotaoff
Date: Tue, 16 Mar 2021 08:36:04 -0700	[thread overview]
Message-ID: <20210316153604.GH22100@magnolia> (raw)
In-Reply-To: <20210316141044.4myelroxkotnq57h@andromeda.lan>

On Tue, Mar 16, 2021 at 03:10:44PM +0100, Carlos Maiolino wrote:
> On Tue, Mar 16, 2021 at 08:45:20AM -0500, Eric Sandeen wrote:
> > On 3/16/21 4:04 AM, Carlos Maiolino wrote:
> > > xlog_recover_print_quotaoff() was using a static buffer to aggregate
> > > quota option strings to be printed at the end. The buffer size was
> > > miscalculated and when printing all 3 flags, a buffer overflow occurs
> > > crashing xfs_logprint, like:
> > > 
> > > QOFF: cnt:1 total:1 a:0x560530ff3bb0 len:160
> > > *** buffer overflow detected ***: terminated
> > > Aborted (core dumped)
> > > 
> > > Fix this by removing the static buffer and using printf() directly to
> > > print each flag. 
> > 
> > Yeah, that makes sense. Not sure why it was using a static buffer,
> > unless I was missing something?
> > 
> > > Also add a trailling space before each flag, so they
> > 
> > "trailing space before?" :) I can fix that up on commit.
> 
> Maybe I slipped into my words here... The current printed format, did something
> like this:
> 
> type: USER QUOTAGROUP QUOTAPROJECT QUOTA
> 
> I just added a space before each flag string, to print like this:
> 
> type: USER QUOTA GROUP QUOTA PROJECT QUOTA

Any reason we can't just shorten this to "type: USER GROUP PUOTA" ?

--D

> 
> 
> > >  	if (qoff_f->qf_flags & XFS_UQUOTA_ACCT)
> > > -		strcat(str, "USER QUOTA");
> > > +		printf(" USER QUOTA");
> 			^ here (an in the remaining ones)
> 
> > >  	if (qoff_f->qf_flags & XFS_GQUOTA_ACCT)
> > > -		strcat(str, "GROUP QUOTA");
> > > +		printf(" GROUP QUOTA");
> > >  	if (qoff_f->qf_flags & XFS_PQUOTA_ACCT)
> > > -		strcat(str, "PROJECT QUOTA");
> > > -	printf(_("\tQUOTAOFF: #regs:%d   type:%s\n"),
> > > -	       qoff_f->qf_size, str);
> > > +		printf(" PROJECT QUOTA");
> > 
> > Seems like a clean solution, thanks.
> > 
> > Reviewed-by: Eric Sandeen <sandeen@redhat.com>
> > 
> > > +	printf("\n");
> > >  }
> > >  
> > >  STATIC void
> > > 
> > 
> 
> -- 
> Carlos
> 

  reply	other threads:[~2021-03-16 15:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-16  9:04 [PATCH] xfs_logprint: Fix buffer overflow printing quotaoff Carlos Maiolino
2021-03-16 13:45 ` Eric Sandeen
2021-03-16 14:10   ` Carlos Maiolino
2021-03-16 15:36     ` Darrick J. Wong [this message]
2021-03-16 16:11       ` Eric Sandeen
2021-03-23  9:08         ` Carlos Maiolino

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=20210316153604.GH22100@magnolia \
    --to=djwong@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@sandeen.net \
    /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