linux-sctp.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
To: Vegard Nossum <vegard.nossum@oracle.com>
Cc: Vlad Yasevich <vyasevich@gmail.com>,
	Neil Horman <nhorman@tuxdriver.com>,
	linux-sctp@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, Xin Long <lucien.xin@gmail.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH] net/sctp: always initialise sctp_ht_iter::start_fail
Date: Sat, 23 Jul 2016 14:15:33 +0000	[thread overview]
Message-ID: <20160723141532.GH9950@localhost.localdomain> (raw)
In-Reply-To: <57937887.6030204@oracle.com>

On Sat, Jul 23, 2016 at 04:00:39PM +0200, Vegard Nossum wrote:
> On 07/23/2016 03:39 PM, Marcelo Ricardo Leitner wrote:
> > On Sat, Jul 23, 2016 at 11:52:23AM +0200, Vegard Nossum wrote:
> > > seq_read() can call ->start() twice on the same iterator more than once
> > > (e.g. once through traverse() and once in seq_read() itself).
> > 
> > But when traverse() returns the error, it goes to Done label, skipping
> > the call to ->start() from seq_read(), or am I missing something?
> 
> I think you're right.
> 
> > Though yes, if sctp_ht_iter memory is actually re-used without
> > initializting between seq_read()s, it triggers the issue you described.
> 
> The sctp_ht_iter is allocated in
> sctp_assocs_seq_open()/sctp_remaddr_seq_open(), so I assume it's
> allocated on open().
> 
> > How did you trigger this, reading after an error on the file descriptor?
> 
> I was using trinity, so I'm not quite sure a priori, but the problem was
> 100% reproducible before I applied the patch and seeing that it gets
> allocated on open() and is never cleared anywhere else, your suggestion
> sounds like the most plausible explanation :-)
> 
> How about rewording the first paragraph as:
> 
> """
> sctp_transport_seq_start() does not currently clear iter->start_fail on
> success, but relies on it being zero when it is allocated (by
> seq_open_net()).
> 
> This can be a problem in the following sequence:
> 
> open() -- allocates iter (and implicitly sets iter->start_fail = 0)
> read()
>  iter->start() -- fails and sets iter->start_fail = 1
>  iter->stop() -- doesn't call sctp_transport_walk_stop() (correct)
> read() again
>  iter->start() -- succeeds, but doesn't change iter->start_fail
>  iter->stop() -- doesn't call sctp_transport_walk_stop() (wrong)
> """
> 
> Let me know how that sounds.

LGTM, thanks!

  Marcelo

> 
> Thanks for looking so closely at it!
> 
> 
> Vegard
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

      reply	other threads:[~2016-07-23 14:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-23  9:52 [PATCH] net/sctp: always initialise sctp_ht_iter::start_fail Vegard Nossum
2016-07-23 13:39 ` Marcelo Ricardo Leitner
2016-07-23 14:00   ` Vegard Nossum
2016-07-23 14:15     ` Marcelo Ricardo Leitner [this message]

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=20160723141532.GH9950@localhost.localdomain \
    --to=marcelo.leitner@gmail.com \
    --cc=davem@davemloft.net \
    --cc=ebiederm@xmission.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-sctp@vger.kernel.org \
    --cc=lucien.xin@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=stable@vger.kernel.org \
    --cc=vegard.nossum@oracle.com \
    --cc=vyasevich@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 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).