All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: roy.qing.li@gmail.com
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH net-next 1/2] ipv6: remove unnecessary codes in tcp_ipv6.c
Date: Sun, 01 Jul 2012 22:37:36 -0700 (PDT)	[thread overview]
Message-ID: <20120701.223736.2073666097053189601.davem@davemloft.net> (raw)
In-Reply-To: <CAJFZqHxyR0PErHV8cqLLe6eqL0fCYS9gjPRc9zpthpevsU7wkA@mail.gmail.com>

From: RongQing Li <roy.qing.li@gmail.com>
Date: Mon, 2 Jul 2012 13:23:09 +0800

> 2012/7/2 David Miller <davem@davemloft.net>:
>> From: roy.qing.li@gmail.com
>> Date: Mon,  2 Jul 2012 11:18:59 +0800
>>
>>> -     if (opt) {
>>> -             newnp->opt = ipv6_dup_options(newsk, opt);
>>> -             if (opt != np->opt)
>>> -                     sock_kfree_s(sk, opt, opt->tot_len);
>>
>> This is bogus, if we copy the options into a new copy in
>> ipv6_dup_options() we have to free the old one or else we
>> leak it.
> 
> Do you mean I should free newnp->opt firstly ?
> 
> If I understand it right, I think we do not need to free it. the
> process is below:
> 
> newsk = tcp_v4_syn_recv_sock(sk, skb, req, dst);
> ..
> newnp = inet6_sk(newsk);
> ..
> memcpy(newnp, np, sizeof(struct ipv6_pinfo));
> ..
> newnp->opt         = NULL;
> 
> So newnp->opt is not a effective memory.

ipv6_dup_options() allocates new memory for the options and this call
statement assigns that new pointer to np->opt.

If you do not free the old (before ipv6_dup_options()) np->opt memory
here, it is lost forever.

  reply	other threads:[~2012-07-02  5:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-02  3:18 [PATCH net-next 1/2] ipv6: remove unnecessary codes in tcp_ipv6.c roy.qing.li
2012-07-02  3:19 ` [PATCH net-next 2/2] dccp: remove unnecessary codes in ipv6.c roy.qing.li
2012-07-02  3:26   ` David Miller
2012-07-02  9:08   ` Eric Dumazet
2012-07-05 10:13     ` David Miller
2012-07-02  3:26 ` [PATCH net-next 1/2] ipv6: remove unnecessary codes in tcp_ipv6.c David Miller
2012-07-02  5:23   ` RongQing Li
2012-07-02  5:37     ` David Miller [this message]
2012-07-02  8:13   ` Eric Dumazet
2012-07-02  8:54     ` Eric Dumazet
2012-07-02  9:07 ` Eric Dumazet
2012-07-05 10:13   ` David Miller

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=20120701.223736.2073666097053189601.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=roy.qing.li@gmail.com \
    /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.