All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladislav Yasevich <vladislav.yasevich@hp.com>
To: linux-sctp@vger.kernel.org
Subject: Re: question about net/sctp/socket.c
Date: Mon, 02 Apr 2012 13:49:33 +0000	[thread overview]
Message-ID: <4F79AE6D.8060203@hp.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1204021521460.1959@hadrien>

On 04/02/2012 09:24 AM, Julia Lawall wrote:
> In the file net/sctp/socket.c, the function sctp_getsockopt_peeloff ends with:
> 
>        retval = sock_map_fd(newsock, 0);
>         if (retval < 0) {
>                 sock_release(newsock);
>                 goto out;
>         }
> 
>         SCTP_DEBUG_PRINTK("%s: sk: %p newsk: %p sd: %d\n",
>                           __func__, sk, newsock->sk, retval);
> 
>         /* Return the fd mapped to the new socket.  */
>         peeloff.sd = retval;
>         if (put_user(len, optlen))
>                 return -EFAULT;
>         if (copy_to_user(optval, &peeloff, len))
>                 retval = -EFAULT;
> 
> Should there be a call to sock_release in the final two error cases as well?  I don't see anything that removes the need for it.  And is some cleanup of the effect of sock_map_fd needed as well?
> 
> thanks,
> julia
> 

Hi Julia

This is an interesting case.  The possible issue I see calling sock_release here as well as after sock_map_fd
call is that if the peeloff call fails in these 3 instances, the association is terminated.  There is no
graceful recovery at all.

It may make sense to re-arrange the code so that failures here are recoverable. By that I mean, that if a
call to peeloff() fails, the original socket and association lists aren't touched. That would allow
a repeated call to peeloff to potentially succeed.

-vlad

  reply	other threads:[~2012-04-02 13:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-02 13:24 question about net/sctp/socket.c Julia Lawall
2012-04-02 13:49 ` Vladislav Yasevich [this message]
2012-04-02 14:59 ` Julia Lawall
2012-04-02 15:26 ` Vladislav Yasevich
2012-04-02 16:31 ` Julia Lawall
2012-04-02 18:19 ` Vladislav Yasevich
2012-04-02 21:01 ` Julia Lawall

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=4F79AE6D.8060203@hp.com \
    --to=vladislav.yasevich@hp.com \
    --cc=linux-sctp@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.