<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux.git/net, branch v3.6-rc4</title>
<subtitle>Linux kernel source tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/'/>
<entry>
<title>Merge branch 'for-3.6' of git://linux-nfs.org/~bfields/linux</title>
<updated>2012-08-25T18:43:41+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2012-08-25T18:43:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=8497ae61d0e7f30ae9f20c5fcea94c957b6c3b83'/>
<id>8497ae61d0e7f30ae9f20c5fcea94c957b6c3b83</id>
<content type='text'>
Pull nfsd bugfixes from J. Bruce Fields:
 "Particular thanks to Michael Tokarev, Malahal Naineni, and Jamie
  Heilman for their testing and debugging help."

* 'for-3.6' of git://linux-nfs.org/~bfields/linux:
  svcrpc: fix svc_xprt_enqueue/svc_recv busy-looping
  svcrpc: sends on closed socket should stop immediately
  svcrpc: fix BUG() in svc_tcp_clear_pages
  nfsd4: fix security flavor of NFSv4.0 callback
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Pull nfsd bugfixes from J. Bruce Fields:
 "Particular thanks to Michael Tokarev, Malahal Naineni, and Jamie
  Heilman for their testing and debugging help."

* 'for-3.6' of git://linux-nfs.org/~bfields/linux:
  svcrpc: fix svc_xprt_enqueue/svc_recv busy-looping
  svcrpc: sends on closed socket should stop immediately
  svcrpc: fix BUG() in svc_tcp_clear_pages
  nfsd4: fix security flavor of NFSv4.0 callback
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client</title>
<updated>2012-08-22T16:58:05+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2012-08-22T16:58:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=f753c4ec151c5c385fa0508a29aa793dee966325'/>
<id>f753c4ec151c5c385fa0508a29aa793dee966325</id>
<content type='text'>
Pull ceph fixes from Sage Weil:
 "Jim's fix closes a narrow race introduced with the msgr changes.  One
  fix resolves problems with debugfs initialization that Yan found when
  multiple client instances are created (e.g., two clusters mounted, or
  rbd + cephfs), another one fixes problems with mounting a nonexistent
  server subdirectory, and the last one fixes a divide by zero error
  from unsanitized ioctl input that Dan Carpenter found."

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client:
  ceph: avoid divide by zero in __validate_layout()
  libceph: avoid truncation due to racing banners
  ceph: tolerate (and warn on) extraneous dentry from mds
  libceph: delay debugfs initialization until we learn global_id
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Pull ceph fixes from Sage Weil:
 "Jim's fix closes a narrow race introduced with the msgr changes.  One
  fix resolves problems with debugfs initialization that Yan found when
  multiple client instances are created (e.g., two clusters mounted, or
  rbd + cephfs), another one fixes problems with mounting a nonexistent
  server subdirectory, and the last one fixes a divide by zero error
  from unsanitized ioctl input that Dan Carpenter found."

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client:
  ceph: avoid divide by zero in __validate_layout()
  libceph: avoid truncation due to racing banners
  ceph: tolerate (and warn on) extraneous dentry from mds
  libceph: delay debugfs initialization until we learn global_id
</pre>
</div>
</content>
</entry>
<entry>
<title>libceph: avoid truncation due to racing banners</title>
<updated>2012-08-21T22:55:27+00:00</updated>
<author>
<name>Jim Schutt</name>
<email>jaschut@sandia.gov</email>
</author>
<published>2012-08-10T17:37:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=6d4221b53707486dfad3f5bfe568d2ce7f4c9863'/>
<id>6d4221b53707486dfad3f5bfe568d2ce7f4c9863</id>
<content type='text'>
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 &lt;jaschut@sandia.gov&gt;
Reviewed-by: Alex Elder &lt;elder@inktank.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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 &lt;jaschut@sandia.gov&gt;
Reviewed-by: Alex Elder &lt;elder@inktank.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>af_netlink: force credentials passing [CVE-2012-3520]</title>
<updated>2012-08-21T21:53:01+00:00</updated>
<author>
<name>Eric Dumazet</name>
<email>edumazet@google.com</email>
</author>
<published>2012-08-21T06:21:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=e0e3cea46d31d23dc40df0a49a7a2c04fe8edfea'/>
<id>e0e3cea46d31d23dc40df0a49a7a2c04fe8edfea</id>
<content type='text'>
Pablo Neira Ayuso discovered that avahi and
potentially NetworkManager accept spoofed Netlink messages because of a
kernel bug.  The kernel passes all-zero SCM_CREDENTIALS ancillary data
to the receiver if the sender did not provide such data, instead of not
including any such data at all or including the correct data from the
peer (as it is the case with AF_UNIX).

This bug was introduced in commit 16e572626961
(af_unix: dont send SCM_CREDENTIALS by default)

This patch forces passing credentials for netlink, as
before the regression.

Another fix would be to not add SCM_CREDENTIALS in
netlink messages if not provided by the sender, but it
might break some programs.

With help from Florian Weimer &amp; Petr Matousek

This issue is designated as CVE-2012-3520

Signed-off-by: Eric Dumazet &lt;edumazet@google.com&gt;
Cc: Petr Matousek &lt;pmatouse@redhat.com&gt;
Cc: Florian Weimer &lt;fweimer@redhat.com&gt;
Cc: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Pablo Neira Ayuso discovered that avahi and
potentially NetworkManager accept spoofed Netlink messages because of a
kernel bug.  The kernel passes all-zero SCM_CREDENTIALS ancillary data
to the receiver if the sender did not provide such data, instead of not
including any such data at all or including the correct data from the
peer (as it is the case with AF_UNIX).

This bug was introduced in commit 16e572626961
(af_unix: dont send SCM_CREDENTIALS by default)

This patch forces passing credentials for netlink, as
before the regression.

Another fix would be to not add SCM_CREDENTIALS in
netlink messages if not provided by the sender, but it
might break some programs.

With help from Florian Weimer &amp; Petr Matousek

This issue is designated as CVE-2012-3520

Signed-off-by: Eric Dumazet &lt;edumazet@google.com&gt;
Cc: Petr Matousek &lt;pmatouse@redhat.com&gt;
Cc: Florian Weimer &lt;fweimer@redhat.com&gt;
Cc: Pablo Neira Ayuso &lt;pablo@netfilter.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>ipv4: fix ip header ident selection in __ip_make_skb()</title>
<updated>2012-08-21T21:51:06+00:00</updated>
<author>
<name>Eric Dumazet</name>
<email>edumazet@google.com</email>
</author>
<published>2012-08-20T07:26:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=a9915a1b52df52ad87f3b33422da95cf25372f09'/>
<id>a9915a1b52df52ad87f3b33422da95cf25372f09</id>
<content type='text'>
Christian Casteyde reported a kmemcheck 32-bit read from uninitialized
memory in __ip_select_ident().

It turns out that __ip_make_skb() called ip_select_ident() before
properly initializing iph-&gt;daddr.

This is a bug uncovered by commit 1d861aa4b3fb (inet: Minimize use of
cached route inetpeer.)

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=46131

Reported-by: Christian Casteyde &lt;casteyde.christian@free.fr&gt;
Signed-off-by: Eric Dumazet &lt;edumazet@google.com&gt;
Cc: Stephen Hemminger &lt;shemminger@vyatta.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Christian Casteyde reported a kmemcheck 32-bit read from uninitialized
memory in __ip_select_ident().

It turns out that __ip_make_skb() called ip_select_ident() before
properly initializing iph-&gt;daddr.

This is a bug uncovered by commit 1d861aa4b3fb (inet: Minimize use of
cached route inetpeer.)

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=46131

Reported-by: Christian Casteyde &lt;casteyde.christian@free.fr&gt;
Signed-off-by: Eric Dumazet &lt;edumazet@google.com&gt;
Cc: Stephen Hemminger &lt;shemminger@vyatta.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>ipv4: Use newinet-&gt;inet_opt in inet_csk_route_child_sock()</title>
<updated>2012-08-21T21:49:11+00:00</updated>
<author>
<name>Christoph Paasch</name>
<email>christoph.paasch@uclouvain.be</email>
</author>
<published>2012-08-20T02:52:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=1a7b27c97ce675b42eeb7bfaf6e15c34f35c8f95'/>
<id>1a7b27c97ce675b42eeb7bfaf6e15c34f35c8f95</id>
<content type='text'>
Since 0e734419923bd ("ipv4: Use inet_csk_route_child_sock() in DCCP and
TCP."), inet_csk_route_child_sock() is called instead of
inet_csk_route_req().

However, after creating the child-sock in tcp/dccp_v4_syn_recv_sock(),
ireq-&gt;opt is set to NULL, before calling inet_csk_route_child_sock().
Thus, inside inet_csk_route_child_sock() opt is always NULL and the
SRR-options are not respected anymore.
Packets sent by the server won't have the correct destination-IP.

This patch fixes it by accessing newinet-&gt;inet_opt instead of ireq-&gt;opt
inside inet_csk_route_child_sock().

Reported-by: Luca Boccassi &lt;luca.boccassi@gmail.com&gt;
Signed-off-by: Christoph Paasch &lt;christoph.paasch@uclouvain.be&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Since 0e734419923bd ("ipv4: Use inet_csk_route_child_sock() in DCCP and
TCP."), inet_csk_route_child_sock() is called instead of
inet_csk_route_req().

However, after creating the child-sock in tcp/dccp_v4_syn_recv_sock(),
ireq-&gt;opt is set to NULL, before calling inet_csk_route_child_sock().
Thus, inside inet_csk_route_child_sock() opt is always NULL and the
SRR-options are not respected anymore.
Packets sent by the server won't have the correct destination-IP.

This patch fixes it by accessing newinet-&gt;inet_opt instead of ireq-&gt;opt
inside inet_csk_route_child_sock().

Reported-by: Luca Boccassi &lt;luca.boccassi@gmail.com&gt;
Signed-off-by: Christoph Paasch &lt;christoph.paasch@uclouvain.be&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tcp: fix possible socket refcount problem</title>
<updated>2012-08-21T21:42:23+00:00</updated>
<author>
<name>Eric Dumazet</name>
<email>edumazet@google.com</email>
</author>
<published>2012-08-20T00:22:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=144d56e91044181ec0ef67aeca91e9a8b5718348'/>
<id>144d56e91044181ec0ef67aeca91e9a8b5718348</id>
<content type='text'>
Commit 6f458dfb40 (tcp: improve latencies of timer triggered events)
added bug leading to following trace :

[ 2866.131281] IPv4: Attempt to release TCP socket in state 1 ffff880019ec0000
[ 2866.131726]
[ 2866.132188] =========================
[ 2866.132281] [ BUG: held lock freed! ]
[ 2866.132281] 3.6.0-rc1+ #622 Not tainted
[ 2866.132281] -------------------------
[ 2866.132281] kworker/0:1/652 is freeing memory ffff880019ec0000-ffff880019ec0a1f, with a lock still held there!
[ 2866.132281]  (sk_lock-AF_INET-RPC){+.+...}, at: [&lt;ffffffff81903619&gt;] tcp_sendmsg+0x29/0xcc6
[ 2866.132281] 4 locks held by kworker/0:1/652:
[ 2866.132281]  #0:  (rpciod){.+.+.+}, at: [&lt;ffffffff81083567&gt;] process_one_work+0x1de/0x47f
[ 2866.132281]  #1:  ((&amp;task-&gt;u.tk_work)){+.+.+.}, at: [&lt;ffffffff81083567&gt;] process_one_work+0x1de/0x47f
[ 2866.132281]  #2:  (sk_lock-AF_INET-RPC){+.+...}, at: [&lt;ffffffff81903619&gt;] tcp_sendmsg+0x29/0xcc6
[ 2866.132281]  #3:  (&amp;icsk-&gt;icsk_retransmit_timer){+.-...}, at: [&lt;ffffffff81078017&gt;] run_timer_softirq+0x1ad/0x35f
[ 2866.132281]
[ 2866.132281] stack backtrace:
[ 2866.132281] Pid: 652, comm: kworker/0:1 Not tainted 3.6.0-rc1+ #622
[ 2866.132281] Call Trace:
[ 2866.132281]  &lt;IRQ&gt;  [&lt;ffffffff810bc527&gt;] debug_check_no_locks_freed+0x112/0x159
[ 2866.132281]  [&lt;ffffffff818a0839&gt;] ? __sk_free+0xfd/0x114
[ 2866.132281]  [&lt;ffffffff811549fa&gt;] kmem_cache_free+0x6b/0x13a
[ 2866.132281]  [&lt;ffffffff818a0839&gt;] __sk_free+0xfd/0x114
[ 2866.132281]  [&lt;ffffffff818a08c0&gt;] sk_free+0x1c/0x1e
[ 2866.132281]  [&lt;ffffffff81911e1c&gt;] tcp_write_timer+0x51/0x56
[ 2866.132281]  [&lt;ffffffff81078082&gt;] run_timer_softirq+0x218/0x35f
[ 2866.132281]  [&lt;ffffffff81078017&gt;] ? run_timer_softirq+0x1ad/0x35f
[ 2866.132281]  [&lt;ffffffff810f5831&gt;] ? rb_commit+0x58/0x85
[ 2866.132281]  [&lt;ffffffff81911dcb&gt;] ? tcp_write_timer_handler+0x148/0x148
[ 2866.132281]  [&lt;ffffffff81070bd6&gt;] __do_softirq+0xcb/0x1f9
[ 2866.132281]  [&lt;ffffffff81a0a00c&gt;] ? _raw_spin_unlock+0x29/0x2e
[ 2866.132281]  [&lt;ffffffff81a1227c&gt;] call_softirq+0x1c/0x30
[ 2866.132281]  [&lt;ffffffff81039f38&gt;] do_softirq+0x4a/0xa6
[ 2866.132281]  [&lt;ffffffff81070f2b&gt;] irq_exit+0x51/0xad
[ 2866.132281]  [&lt;ffffffff81a129cd&gt;] do_IRQ+0x9d/0xb4
[ 2866.132281]  [&lt;ffffffff81a0a3ef&gt;] common_interrupt+0x6f/0x6f
[ 2866.132281]  &lt;EOI&gt;  [&lt;ffffffff8109d006&gt;] ? sched_clock_cpu+0x58/0xd1
[ 2866.132281]  [&lt;ffffffff81a0a172&gt;] ? _raw_spin_unlock_irqrestore+0x4c/0x56
[ 2866.132281]  [&lt;ffffffff81078692&gt;] mod_timer+0x178/0x1a9
[ 2866.132281]  [&lt;ffffffff818a00aa&gt;] sk_reset_timer+0x19/0x26
[ 2866.132281]  [&lt;ffffffff8190b2cc&gt;] tcp_rearm_rto+0x99/0xa4
[ 2866.132281]  [&lt;ffffffff8190dfba&gt;] tcp_event_new_data_sent+0x6e/0x70
[ 2866.132281]  [&lt;ffffffff8190f7ea&gt;] tcp_write_xmit+0x7de/0x8e4
[ 2866.132281]  [&lt;ffffffff818a565d&gt;] ? __alloc_skb+0xa0/0x1a1
[ 2866.132281]  [&lt;ffffffff8190f952&gt;] __tcp_push_pending_frames+0x2e/0x8a
[ 2866.132281]  [&lt;ffffffff81904122&gt;] tcp_sendmsg+0xb32/0xcc6
[ 2866.132281]  [&lt;ffffffff819229c2&gt;] inet_sendmsg+0xaa/0xd5
[ 2866.132281]  [&lt;ffffffff81922918&gt;] ? inet_autobind+0x5f/0x5f
[ 2866.132281]  [&lt;ffffffff810ee7f1&gt;] ? trace_clock_local+0x9/0xb
[ 2866.132281]  [&lt;ffffffff8189adab&gt;] sock_sendmsg+0xa3/0xc4
[ 2866.132281]  [&lt;ffffffff810f5de6&gt;] ? rb_reserve_next_event+0x26f/0x2d5
[ 2866.132281]  [&lt;ffffffff8103e6a9&gt;] ? native_sched_clock+0x29/0x6f
[ 2866.132281]  [&lt;ffffffff8103e6f8&gt;] ? sched_clock+0x9/0xd
[ 2866.132281]  [&lt;ffffffff810ee7f1&gt;] ? trace_clock_local+0x9/0xb
[ 2866.132281]  [&lt;ffffffff8189ae03&gt;] kernel_sendmsg+0x37/0x43
[ 2866.132281]  [&lt;ffffffff8199ce49&gt;] xs_send_kvec+0x77/0x80
[ 2866.132281]  [&lt;ffffffff8199cec1&gt;] xs_sendpages+0x6f/0x1a0
[ 2866.132281]  [&lt;ffffffff8107826d&gt;] ? try_to_del_timer_sync+0x55/0x61
[ 2866.132281]  [&lt;ffffffff8199d0d2&gt;] xs_tcp_send_request+0x55/0xf1
[ 2866.132281]  [&lt;ffffffff8199bb90&gt;] xprt_transmit+0x89/0x1db
[ 2866.132281]  [&lt;ffffffff81999bcd&gt;] ? call_connect+0x3c/0x3c
[ 2866.132281]  [&lt;ffffffff81999d92&gt;] call_transmit+0x1c5/0x20e
[ 2866.132281]  [&lt;ffffffff819a0d55&gt;] __rpc_execute+0x6f/0x225
[ 2866.132281]  [&lt;ffffffff81999bcd&gt;] ? call_connect+0x3c/0x3c
[ 2866.132281]  [&lt;ffffffff819a0f33&gt;] rpc_async_schedule+0x28/0x34
[ 2866.132281]  [&lt;ffffffff810835d6&gt;] process_one_work+0x24d/0x47f
[ 2866.132281]  [&lt;ffffffff81083567&gt;] ? process_one_work+0x1de/0x47f
[ 2866.132281]  [&lt;ffffffff819a0f0b&gt;] ? __rpc_execute+0x225/0x225
[ 2866.132281]  [&lt;ffffffff81083a6d&gt;] worker_thread+0x236/0x317
[ 2866.132281]  [&lt;ffffffff81083837&gt;] ? process_scheduled_works+0x2f/0x2f
[ 2866.132281]  [&lt;ffffffff8108b7b8&gt;] kthread+0x9a/0xa2
[ 2866.132281]  [&lt;ffffffff81a12184&gt;] kernel_thread_helper+0x4/0x10
[ 2866.132281]  [&lt;ffffffff81a0a4b0&gt;] ? retint_restore_args+0x13/0x13
[ 2866.132281]  [&lt;ffffffff8108b71e&gt;] ? __init_kthread_worker+0x5a/0x5a
[ 2866.132281]  [&lt;ffffffff81a12180&gt;] ? gs_change+0x13/0x13
[ 2866.308506] IPv4: Attempt to release TCP socket in state 1 ffff880019ec0000
[ 2866.309689] =============================================================================
[ 2866.310254] BUG TCP (Not tainted): Object already free
[ 2866.310254] -----------------------------------------------------------------------------
[ 2866.310254]

The bug comes from the fact that timer set in sk_reset_timer() can run
before we actually do the sock_hold(). socket refcount reaches zero and
we free the socket too soon.

timer handler is not allowed to reduce socket refcnt if socket is owned
by the user, or we need to change sk_reset_timer() implementation.

We should take a reference on the socket in case TCP_DELACK_TIMER_DEFERRED
or TCP_DELACK_TIMER_DEFERRED bit are set in tsq_flags

Also fix a typo in tcp_delack_timer(), where TCP_WRITE_TIMER_DEFERRED
was used instead of TCP_DELACK_TIMER_DEFERRED.

For consistency, use same socket refcount change for TCP_MTU_REDUCED_DEFERRED,
even if not fired from a timer.

Reported-by: Fengguang Wu &lt;fengguang.wu@intel.com&gt;
Tested-by: Fengguang Wu &lt;fengguang.wu@intel.com&gt;
Signed-off-by: Eric Dumazet &lt;edumazet@google.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Commit 6f458dfb40 (tcp: improve latencies of timer triggered events)
added bug leading to following trace :

[ 2866.131281] IPv4: Attempt to release TCP socket in state 1 ffff880019ec0000
[ 2866.131726]
[ 2866.132188] =========================
[ 2866.132281] [ BUG: held lock freed! ]
[ 2866.132281] 3.6.0-rc1+ #622 Not tainted
[ 2866.132281] -------------------------
[ 2866.132281] kworker/0:1/652 is freeing memory ffff880019ec0000-ffff880019ec0a1f, with a lock still held there!
[ 2866.132281]  (sk_lock-AF_INET-RPC){+.+...}, at: [&lt;ffffffff81903619&gt;] tcp_sendmsg+0x29/0xcc6
[ 2866.132281] 4 locks held by kworker/0:1/652:
[ 2866.132281]  #0:  (rpciod){.+.+.+}, at: [&lt;ffffffff81083567&gt;] process_one_work+0x1de/0x47f
[ 2866.132281]  #1:  ((&amp;task-&gt;u.tk_work)){+.+.+.}, at: [&lt;ffffffff81083567&gt;] process_one_work+0x1de/0x47f
[ 2866.132281]  #2:  (sk_lock-AF_INET-RPC){+.+...}, at: [&lt;ffffffff81903619&gt;] tcp_sendmsg+0x29/0xcc6
[ 2866.132281]  #3:  (&amp;icsk-&gt;icsk_retransmit_timer){+.-...}, at: [&lt;ffffffff81078017&gt;] run_timer_softirq+0x1ad/0x35f
[ 2866.132281]
[ 2866.132281] stack backtrace:
[ 2866.132281] Pid: 652, comm: kworker/0:1 Not tainted 3.6.0-rc1+ #622
[ 2866.132281] Call Trace:
[ 2866.132281]  &lt;IRQ&gt;  [&lt;ffffffff810bc527&gt;] debug_check_no_locks_freed+0x112/0x159
[ 2866.132281]  [&lt;ffffffff818a0839&gt;] ? __sk_free+0xfd/0x114
[ 2866.132281]  [&lt;ffffffff811549fa&gt;] kmem_cache_free+0x6b/0x13a
[ 2866.132281]  [&lt;ffffffff818a0839&gt;] __sk_free+0xfd/0x114
[ 2866.132281]  [&lt;ffffffff818a08c0&gt;] sk_free+0x1c/0x1e
[ 2866.132281]  [&lt;ffffffff81911e1c&gt;] tcp_write_timer+0x51/0x56
[ 2866.132281]  [&lt;ffffffff81078082&gt;] run_timer_softirq+0x218/0x35f
[ 2866.132281]  [&lt;ffffffff81078017&gt;] ? run_timer_softirq+0x1ad/0x35f
[ 2866.132281]  [&lt;ffffffff810f5831&gt;] ? rb_commit+0x58/0x85
[ 2866.132281]  [&lt;ffffffff81911dcb&gt;] ? tcp_write_timer_handler+0x148/0x148
[ 2866.132281]  [&lt;ffffffff81070bd6&gt;] __do_softirq+0xcb/0x1f9
[ 2866.132281]  [&lt;ffffffff81a0a00c&gt;] ? _raw_spin_unlock+0x29/0x2e
[ 2866.132281]  [&lt;ffffffff81a1227c&gt;] call_softirq+0x1c/0x30
[ 2866.132281]  [&lt;ffffffff81039f38&gt;] do_softirq+0x4a/0xa6
[ 2866.132281]  [&lt;ffffffff81070f2b&gt;] irq_exit+0x51/0xad
[ 2866.132281]  [&lt;ffffffff81a129cd&gt;] do_IRQ+0x9d/0xb4
[ 2866.132281]  [&lt;ffffffff81a0a3ef&gt;] common_interrupt+0x6f/0x6f
[ 2866.132281]  &lt;EOI&gt;  [&lt;ffffffff8109d006&gt;] ? sched_clock_cpu+0x58/0xd1
[ 2866.132281]  [&lt;ffffffff81a0a172&gt;] ? _raw_spin_unlock_irqrestore+0x4c/0x56
[ 2866.132281]  [&lt;ffffffff81078692&gt;] mod_timer+0x178/0x1a9
[ 2866.132281]  [&lt;ffffffff818a00aa&gt;] sk_reset_timer+0x19/0x26
[ 2866.132281]  [&lt;ffffffff8190b2cc&gt;] tcp_rearm_rto+0x99/0xa4
[ 2866.132281]  [&lt;ffffffff8190dfba&gt;] tcp_event_new_data_sent+0x6e/0x70
[ 2866.132281]  [&lt;ffffffff8190f7ea&gt;] tcp_write_xmit+0x7de/0x8e4
[ 2866.132281]  [&lt;ffffffff818a565d&gt;] ? __alloc_skb+0xa0/0x1a1
[ 2866.132281]  [&lt;ffffffff8190f952&gt;] __tcp_push_pending_frames+0x2e/0x8a
[ 2866.132281]  [&lt;ffffffff81904122&gt;] tcp_sendmsg+0xb32/0xcc6
[ 2866.132281]  [&lt;ffffffff819229c2&gt;] inet_sendmsg+0xaa/0xd5
[ 2866.132281]  [&lt;ffffffff81922918&gt;] ? inet_autobind+0x5f/0x5f
[ 2866.132281]  [&lt;ffffffff810ee7f1&gt;] ? trace_clock_local+0x9/0xb
[ 2866.132281]  [&lt;ffffffff8189adab&gt;] sock_sendmsg+0xa3/0xc4
[ 2866.132281]  [&lt;ffffffff810f5de6&gt;] ? rb_reserve_next_event+0x26f/0x2d5
[ 2866.132281]  [&lt;ffffffff8103e6a9&gt;] ? native_sched_clock+0x29/0x6f
[ 2866.132281]  [&lt;ffffffff8103e6f8&gt;] ? sched_clock+0x9/0xd
[ 2866.132281]  [&lt;ffffffff810ee7f1&gt;] ? trace_clock_local+0x9/0xb
[ 2866.132281]  [&lt;ffffffff8189ae03&gt;] kernel_sendmsg+0x37/0x43
[ 2866.132281]  [&lt;ffffffff8199ce49&gt;] xs_send_kvec+0x77/0x80
[ 2866.132281]  [&lt;ffffffff8199cec1&gt;] xs_sendpages+0x6f/0x1a0
[ 2866.132281]  [&lt;ffffffff8107826d&gt;] ? try_to_del_timer_sync+0x55/0x61
[ 2866.132281]  [&lt;ffffffff8199d0d2&gt;] xs_tcp_send_request+0x55/0xf1
[ 2866.132281]  [&lt;ffffffff8199bb90&gt;] xprt_transmit+0x89/0x1db
[ 2866.132281]  [&lt;ffffffff81999bcd&gt;] ? call_connect+0x3c/0x3c
[ 2866.132281]  [&lt;ffffffff81999d92&gt;] call_transmit+0x1c5/0x20e
[ 2866.132281]  [&lt;ffffffff819a0d55&gt;] __rpc_execute+0x6f/0x225
[ 2866.132281]  [&lt;ffffffff81999bcd&gt;] ? call_connect+0x3c/0x3c
[ 2866.132281]  [&lt;ffffffff819a0f33&gt;] rpc_async_schedule+0x28/0x34
[ 2866.132281]  [&lt;ffffffff810835d6&gt;] process_one_work+0x24d/0x47f
[ 2866.132281]  [&lt;ffffffff81083567&gt;] ? process_one_work+0x1de/0x47f
[ 2866.132281]  [&lt;ffffffff819a0f0b&gt;] ? __rpc_execute+0x225/0x225
[ 2866.132281]  [&lt;ffffffff81083a6d&gt;] worker_thread+0x236/0x317
[ 2866.132281]  [&lt;ffffffff81083837&gt;] ? process_scheduled_works+0x2f/0x2f
[ 2866.132281]  [&lt;ffffffff8108b7b8&gt;] kthread+0x9a/0xa2
[ 2866.132281]  [&lt;ffffffff81a12184&gt;] kernel_thread_helper+0x4/0x10
[ 2866.132281]  [&lt;ffffffff81a0a4b0&gt;] ? retint_restore_args+0x13/0x13
[ 2866.132281]  [&lt;ffffffff8108b71e&gt;] ? __init_kthread_worker+0x5a/0x5a
[ 2866.132281]  [&lt;ffffffff81a12180&gt;] ? gs_change+0x13/0x13
[ 2866.308506] IPv4: Attempt to release TCP socket in state 1 ffff880019ec0000
[ 2866.309689] =============================================================================
[ 2866.310254] BUG TCP (Not tainted): Object already free
[ 2866.310254] -----------------------------------------------------------------------------
[ 2866.310254]

The bug comes from the fact that timer set in sk_reset_timer() can run
before we actually do the sock_hold(). socket refcount reaches zero and
we free the socket too soon.

timer handler is not allowed to reduce socket refcnt if socket is owned
by the user, or we need to change sk_reset_timer() implementation.

We should take a reference on the socket in case TCP_DELACK_TIMER_DEFERRED
or TCP_DELACK_TIMER_DEFERRED bit are set in tsq_flags

Also fix a typo in tcp_delack_timer(), where TCP_WRITE_TIMER_DEFERRED
was used instead of TCP_DELACK_TIMER_DEFERRED.

For consistency, use same socket refcount change for TCP_MTU_REDUCED_DEFERRED,
even if not fired from a timer.

Reported-by: Fengguang Wu &lt;fengguang.wu@intel.com&gt;
Tested-by: Fengguang Wu &lt;fengguang.wu@intel.com&gt;
Signed-off-by: Eric Dumazet &lt;edumazet@google.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>svcrpc: fix svc_xprt_enqueue/svc_recv busy-looping</title>
<updated>2012-08-20T22:39:19+00:00</updated>
<author>
<name>J. Bruce Fields</name>
<email>bfields@redhat.com</email>
</author>
<published>2012-08-17T21:31:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=d10f27a750312ed5638c876e4bd6aa83664cccd8'/>
<id>d10f27a750312ed5638c876e4bd6aa83664cccd8</id>
<content type='text'>
The rpc server tries to ensure that there will be room to send a reply
before it receives a request.

It does this by tracking, in xpt_reserved, an upper bound on the total
size of the replies that is has already committed to for the socket.

Currently it is adding in the estimate for a new reply *before* it
checks whether there is space available.  If it finds that there is not
space, it then subtracts the estimate back out.

This may lead the subsequent svc_xprt_enqueue to decide that there is
space after all.

The results is a svc_recv() that will repeatedly return -EAGAIN, causing
server threads to loop without doing any actual work.

Cc: stable@vger.kernel.org
Reported-by: Michael Tokarev &lt;mjt@tls.msk.ru&gt;
Tested-by: Michael Tokarev &lt;mjt@tls.msk.ru&gt;
Signed-off-by: J. Bruce Fields &lt;bfields@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The rpc server tries to ensure that there will be room to send a reply
before it receives a request.

It does this by tracking, in xpt_reserved, an upper bound on the total
size of the replies that is has already committed to for the socket.

Currently it is adding in the estimate for a new reply *before* it
checks whether there is space available.  If it finds that there is not
space, it then subtracts the estimate back out.

This may lead the subsequent svc_xprt_enqueue to decide that there is
space after all.

The results is a svc_recv() that will repeatedly return -EAGAIN, causing
server threads to loop without doing any actual work.

Cc: stable@vger.kernel.org
Reported-by: Michael Tokarev &lt;mjt@tls.msk.ru&gt;
Tested-by: Michael Tokarev &lt;mjt@tls.msk.ru&gt;
Signed-off-by: J. Bruce Fields &lt;bfields@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>svcrpc: sends on closed socket should stop immediately</title>
<updated>2012-08-20T22:38:59+00:00</updated>
<author>
<name>J. Bruce Fields</name>
<email>bfields@redhat.com</email>
</author>
<published>2012-08-20T20:04:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=f06f00a24d76e168ecb38d352126fd203937b601'/>
<id>f06f00a24d76e168ecb38d352126fd203937b601</id>
<content type='text'>
svc_tcp_sendto sets XPT_CLOSE if we fail to transmit the entire reply.
However, the XPT_CLOSE won't be acted on immediately.  Meanwhile other
threads could send further replies before the socket is really shut
down.  This can manifest as data corruption: for example, if a truncated
read reply is followed by another rpc reply, that second reply will look
to the client like further read data.

Symptoms were data corruption preceded by svc_tcp_sendto logging
something like

	kernel: rpc-srv/tcp: nfsd: sent only 963696 when sending 1048708 bytes - shutting down socket

Cc: stable@vger.kernel.org
Reported-by: Malahal Naineni &lt;malahal@us.ibm.com&gt;
Tested-by: Malahal Naineni &lt;malahal@us.ibm.com&gt;
Signed-off-by: J. Bruce Fields &lt;bfields@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
svc_tcp_sendto sets XPT_CLOSE if we fail to transmit the entire reply.
However, the XPT_CLOSE won't be acted on immediately.  Meanwhile other
threads could send further replies before the socket is really shut
down.  This can manifest as data corruption: for example, if a truncated
read reply is followed by another rpc reply, that second reply will look
to the client like further read data.

Symptoms were data corruption preceded by svc_tcp_sendto logging
something like

	kernel: rpc-srv/tcp: nfsd: sent only 963696 when sending 1048708 bytes - shutting down socket

Cc: stable@vger.kernel.org
Reported-by: Malahal Naineni &lt;malahal@us.ibm.com&gt;
Tested-by: Malahal Naineni &lt;malahal@us.ibm.com&gt;
Signed-off-by: J. Bruce Fields &lt;bfields@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>svcrpc: fix BUG() in svc_tcp_clear_pages</title>
<updated>2012-08-20T22:38:44+00:00</updated>
<author>
<name>J. Bruce Fields</name>
<email>bfields@redhat.com</email>
</author>
<published>2012-08-09T22:12:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=be1e44441a560c43c136a562d49a1c9623c91197'/>
<id>be1e44441a560c43c136a562d49a1c9623c91197</id>
<content type='text'>
Examination of svc_tcp_clear_pages shows that it assumes sk_tcplen is
consistent with sk_pages[] (in particular, sk_pages[n] can't be NULL if
sk_tcplen would lead us to expect n pages of data).

svc_tcp_restore_pages zeroes out sk_pages[] while leaving sk_tcplen.
This is OK, since both functions are serialized by XPT_BUSY.  However,
that means the inconsistency must be repaired before dropping XPT_BUSY.

Therefore we should be ensuring that svc_tcp_save_pages repairs the
problem before exiting svc_tcp_recv_record on error.

Symptoms were a BUG() in svc_tcp_clear_pages.

Cc: stable@vger.kernel.org
Signed-off-by: J. Bruce Fields &lt;bfields@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Examination of svc_tcp_clear_pages shows that it assumes sk_tcplen is
consistent with sk_pages[] (in particular, sk_pages[n] can't be NULL if
sk_tcplen would lead us to expect n pages of data).

svc_tcp_restore_pages zeroes out sk_pages[] while leaving sk_tcplen.
This is OK, since both functions are serialized by XPT_BUSY.  However,
that means the inconsistency must be repaired before dropping XPT_BUSY.

Therefore we should be ensuring that svc_tcp_save_pages repairs the
problem before exiting svc_tcp_recv_record on error.

Symptoms were a BUG() in svc_tcp_clear_pages.

Cc: stable@vger.kernel.org
Signed-off-by: J. Bruce Fields &lt;bfields@redhat.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
