linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Ben Hutchings <ben@decadent.org.uk>
Cc: Prarit Bhargava <prarit@redhat.com>,
	linuxppc-dev@lists.ozlabs.org, stable@vger.kernel.org
Subject: Re: [PATCH] powerpc/vio: Fix modalias_show return values
Date: Thu, 17 Oct 2013 00:49:28 -0500	[thread overview]
Message-ID: <1381988968.17841.87.camel@pasglop> (raw)
In-Reply-To: <1381982024.3267.14.camel@deadeye.wl.decadent.org.uk>

On Thu, 2013-10-17 at 04:53 +0100, Ben Hutchings wrote:
> Commit e82b89a6f19bae73fb064d1b3dd91fcefbb478f4 introduces a trivial
> local denial of service.

Oops. Prarit, please send a fix asap ! I'm travelling right now.

Thanks !
Ben.

> > --- a/arch/powerpc/kernel/vio.c
> > +++ b/arch/powerpc/kernel/vio.c
> > @@ -1351,11 +1351,15 @@ static ssize_t modalias_show(struct devi
> >  	const char *cp;
> >  
> >  	dn = dev->of_node;
> > -	if (!dn)
> > -		return -ENODEV;
> > +	if (!dn) {
> > +		strcat(buf, "\n");
> 
> Every read from the same sysfs file handle uses the same buffer, which
> gets zero-initialised just once.  So if I open the file, read it and
> seek back to 0 repeatedly, I can make modalias_show() write arbitrary
> numbers of newlines into *and beyond* that page-sized buffer.
> 
> Obviously strcat() should be strcpy().
> 
> Ben.
> 
> > +		return strlen(buf);
> > +	}
> >  	cp = of_get_property(dn, "compatible", NULL);
> > -	if (!cp)
> > -		return -ENODEV;
> > +	if (!cp) {
> > +		strcat(buf, "\n");
> > +		return strlen(buf);
> > +	}
> >  
> >  	return sprintf(buf, "vio:T%sS%s\n", vio_dev->type, cp);
> >  }
> 

  reply	other threads:[~2013-10-17  5:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-17  3:53 [PATCH] powerpc/vio: Fix modalias_show return values Ben Hutchings
2013-10-17  5:49 ` Benjamin Herrenschmidt [this message]
2013-10-17 11:50 ` Prarit Bhargava

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=1381988968.17841.87.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=ben@decadent.org.uk \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=prarit@redhat.com \
    --cc=stable@vger.kernel.org \
    /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).