diff options
author | Jim Schutt <jaschut@sandia.gov> | 2012-08-10 10:37:38 -0700 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2012-08-21 15:55:27 -0700 |
commit | 6d4221b53707486dfad3f5bfe568d2ce7f4c9863 (patch) | |
tree | 9c7bf7471219c98fb47faa3dbb68b8f31fedf3c3 /include/net/dn_nsp.h | |
parent | 6c5e50fa614fea5325a2973be06f7ec6f1055316 (diff) | |
download | op-kernel-dev-6d4221b53707486dfad3f5bfe568d2ce7f4c9863.zip op-kernel-dev-6d4221b53707486dfad3f5bfe568d2ce7f4c9863.tar.gz |
libceph: avoid truncation due to racing banners
Because the Ceph client messenger uses a non-blocking connect, it is
possible for the sending of the client banner to race with the
arrival of the banner sent by the peer.
When ceph_sock_state_change() notices the connect has completed, it
schedules work to process the socket via con_work(). During this
time the peer is writing its banner, and arrival of the peer banner
races with con_work().
If con_work() calls try_read() before the peer banner arrives, there
is nothing for it to do, after which con_work() calls try_write() to
send the client's banner. In this case Ceph's protocol negotiation
can complete succesfully.
The server-side messenger immediately sends its banner and addresses
after accepting a connect request, *before* actually attempting to
read or verify the banner from the client. As a result, it is
possible for the banner from the server to arrive before con_work()
calls try_read(). If that happens, try_read() will read the banner
and prepare protocol negotiation info via prepare_write_connect().
prepare_write_connect() calls con_out_kvec_reset(), which discards
the as-yet-unsent client banner. Next, con_work() calls
try_write(), which sends the protocol negotiation info rather than
the banner that the peer is expecting.
The result is that the peer sees an invalid banner, and the client
reports "negotiation failed".
Fix this by moving con_out_kvec_reset() out of
prepare_write_connect() to its callers at all locations except the
one where the banner might still need to be sent.
[elder@inktak.com: added note about server-side behavior]
Signed-off-by: Jim Schutt <jaschut@sandia.gov>
Reviewed-by: Alex Elder <elder@inktank.com>
Diffstat (limited to 'include/net/dn_nsp.h')
0 files changed, 0 insertions, 0 deletions