All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ryan O'Hara" <rohara@redhat.com>
To: Julian Anastasov <ja@ssi.bg>
Cc: Simon Horman <horms@verge.net.au>, lvs-devel@vger.kernel.org
Subject: Re: [PATCH] ipvsadm: Fix svc->pe_name conditional
Date: Mon, 19 Aug 2013 15:40:44 -0500	[thread overview]
Message-ID: <20130819204043.GB14857@redhat.com> (raw)
In-Reply-To: <alpine.LFD.2.00.1308191817200.1606@ja.ssi.bg>

On Mon, Aug 19, 2013 at 06:27:21PM +0300, Julian Anastasov wrote:
> 
> 	Hello,
> 
> On Mon, 19 Aug 2013, Ryan O'Hara wrote:
> 
> > On Sun, Aug 18, 2013 at 09:13:39PM +0300, Julian Anastasov wrote:
> > 
> > > - CHECK_PE and CHECK_IPV4 as part of CHECK_COMPAT_SVC use
> > > 'return' and we can leak svc in ipvs_get_service()
> > >
> > > - in ipvs_get_service() CHECK_PE does not need to be called,
> > > it is already part of CHECK_COMPAT_SVC
> > 
> > Yes. I'm tempted to remove these macros due to the 'return'
> > issue. Thoughts?
> 
> 	May be they can use 'goto' instead of 'return':
> 
> 	if (condition) {
> 		errno = XXX;
> 		goto out_err;
> 	}
> 
> 	and funcs can have such exit point:
> 
> out_err:
> 	free stuff on error
> 	return ret;

OK. It looks like ipvs_get_service() is the only function with a
potential leak. The other functions that call any of the CHECK_*
macros will just get an 'out_err: return -1'.

I also noticed that CHECK_COMPAT_DEST can be removed. This macro
simply calls CHECK_IPV4, which is also called by CHECK_COMPAT_SVC. I
noticed that CHECK_COMPAT_DEST is only called after CHECK_COMPAT_SVC,
so this macro can be removed entirely. Agree?

> > > - ipvs_get_service uses malloc but later calls CHECK_PE, may be
> > > malloc should be changed with calloc
> > 
> > Aside from the fact that CHECK_PE could return without freeing memory,
> > I don't see the problem here.
> 
> 	malloc does not initialize the memory and checking of
> svc->pe_name[0] in CHECK_PE would give random results.

I see. Thanks.

Ryan


  reply	other threads:[~2013-08-19 20:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-18 16:41 [PATCH] ipvsadm: Fix svc->pe_name conditional Ryan O'Hara
2013-08-18 18:13 ` Julian Anastasov
2013-08-19 14:52   ` Ryan O'Hara
2013-08-19 15:27     ` Julian Anastasov
2013-08-19 20:40       ` Ryan O'Hara [this message]
2013-08-20  0:28         ` Simon Horman
2013-08-20  6:35         ` Julian Anastasov
2013-08-20 14:00           ` Ryan O'Hara

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=20130819204043.GB14857@redhat.com \
    --to=rohara@redhat.com \
    --cc=horms@verge.net.au \
    --cc=ja@ssi.bg \
    --cc=lvs-devel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.