LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Jarek Poplawski <jarkao2@o2.pl>
To: Jean Tourrilhes <jt@hpl.hp.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>,
	"David S\. Miller" <davem@davemloft.net>,
	Linux kernel mailing list <linux-kernel@vger.kernel.org>,
	netdev@vger.kernel.org
Subject: Re: [PATCH 2.6.20] kobject net ifindex + rename
Date: Fri, 2 Mar 2007 10:18:52 +0100	[thread overview]
Message-ID: <20070302091852.GA1913@ff.dom.local> (raw)
In-Reply-To: <20070301192734.GB9098@bougret.hpl.hp.com>

On Thu, Mar 01, 2007 at 11:27:34AM -0800, Jean Tourrilhes wrote:
> On Thu, Mar 01, 2007 at 08:42:09AM +0100, Jarek Poplawski wrote:
> > On Wed, Feb 28, 2007 at 10:45:41AM -0800, Jean Tourrilhes wrote:
> > > > > +
> > > > > +	if ((size <= 0) || (i >= num_envp))
> > > > 
> > > > Btw.:
> > > > 1. if size == 10 and snprintf returns 9 (without NULL)
> > > >    then n == 10 (with NULL), so isn't it enough (here and above):
> > > >  
> > > > 	if ((size < 0) || (i >= num_envp))
> > > 
> > > 	I just cut'n'pasted the code a few line above. If the original
> > > code is incorrect, it need fixing. And it will need fixing in probably
> > > a lot of places.
> > 
> > I think you're kind of responsible for your part, at least.
> 
> 	I personally don't go fixing stuff without having a full
> undersunding of the context and why it was done this way. To me it
> look this test was intentionally done this way, so there may be
> something I don't know about. I guess I would need to double check
> more closely what weid calculation the caller does with the buffer
> size.
> 	That's why I would prefer a separate patch about those issues
> that give the opportunity for the stakeholder to really talk about
> this, rather than slipping it under the carpet.

Sure, but adding a functionality is a kind of fixing, too.

I don't blame you - I simply think that the patch like yours
is an occasion for people reading this list to look at the
adjacent code too. So I wrote about my doubts here hoping
somebody with a better knowledge of this place could verify
them.

> 	In the worse case, this is not a bug, this just means that we
> may not use the last char of the buffer.

Sorry, I can't agree with this.

> 
> > > > 2. shouldn't there be (here and above):
> > > >  
> > > > 		envp[--i] = NULL;
> > > > 
> > > 
> > > 	No, envp is local, so who cares.
> > 
> > But envp[i] isn't (at least here). So, I guess, a caller
> > of this function could care.
> 
> 	Check the full source code of the caller, and you will see
> that the caller does not care (and it's local to the caller).

I can't agree with this, too. There is no reason to leave
a bad pointer there - you need to analyze more than one
caller to verify this now, and any changes in the future
are endangered, too.

> 
> > > > > + 	if ((size <= 0) || (i >= num_envp))
> > > > > + 		return -ENOMEM;
> > 
> > And one more thing (not necessarily for you):
> > ENOBUFS is probably more adequate here.
> 
> 	This error should never happen. If it happens, the caller need
> to be fixed.

Yes, but an error handling should be correct or removed,
if unnecessary.

...
> 	Note that there are various other things that are puzzling in
> this function. The internal object name and the symlinks are changed
> even if the kcore rename returns an error. That does not seem right.
> 	But, this is separate from this patch...

So, I hope somebody will help to make this code perfect!

Best regards,
Jarek P.

  reply	other threads:[~2007-03-02  9:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-28  1:27 Jean Tourrilhes
2007-02-28  9:16 ` Johannes Berg
2007-02-28 18:51   ` Jean Tourrilhes
2007-02-28 19:03     ` Johannes Berg
2007-02-28  9:34 ` Jarek Poplawski
2007-02-28  9:52   ` Jarek Poplawski
2007-02-28 18:45   ` Jean Tourrilhes
2007-03-01  7:42     ` Jarek Poplawski
2007-03-01 19:27       ` Jean Tourrilhes
2007-03-02  9:18         ` Jarek Poplawski [this message]
2007-02-28 15:36 ` Greg KH
2007-02-28 18:43   ` Jean Tourrilhes
2007-03-01  0:26   ` Jean Tourrilhes
2007-03-01  0:37     ` Johannes Berg
2007-03-01  0:51       ` Jean Tourrilhes
2007-03-01  0:57         ` Johannes Berg

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=20070302091852.GA1913@ff.dom.local \
    --to=jarkao2@o2.pl \
    --cc=davem@davemloft.net \
    --cc=gregkh@suse.de \
    --cc=jt@hpl.hp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --subject='Re: [PATCH 2.6.20] kobject net ifindex + rename' \
    /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

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