linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] rxrpc: Fixes
@ 2017-11-29 15:33 David Howells
  2017-11-29 15:33 ` [PATCH net 1/3] rxrpc: Clean up whitespace David Howells
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: David Howells @ 2017-11-29 15:33 UTC (permalink / raw)
  To: netdev; +Cc: dhowells, linux-afs, linux-kernel


Here are three patches for AF_RXRPC.  One removes some whitespace, one
fixes terminal ACK generation and the third makes a couple of places
actually use the timeout value just determined rather than ignoring it.

The patches can be found here also:

	http://git.kernel.org/cgit/linux/kernel/git/dhowells/linux-fs.git/log/?h=rxrpc-fixes

Tagged thusly:

	git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git
	rxrpc-fixes-20171129

David
---
David Howells (2):
      rxrpc: Clean up whitespace
      rxrpc: Fix ACK generation from the connection event processor

Gustavo A. R. Silva (1):
      rxrpc: Fix variable overwrite


 net/rxrpc/call_event.c  |    4 ++--
 net/rxrpc/conn_event.c  |   50 +++++++++++++++++++++++++++--------------------
 net/rxrpc/conn_object.c |    2 +-
 net/rxrpc/input.c       |    4 ++--
 net/rxrpc/sendmsg.c     |    2 +-
 5 files changed, 35 insertions(+), 27 deletions(-)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH net 1/3] rxrpc: Clean up whitespace
  2017-11-29 15:33 [PATCH net-next 0/3] rxrpc: Fixes David Howells
@ 2017-11-29 15:33 ` David Howells
  2017-11-29 15:33 ` [PATCH net 2/3] rxrpc: Fix ACK generation from the connection event processor David Howells
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: David Howells @ 2017-11-29 15:33 UTC (permalink / raw)
  To: netdev; +Cc: dhowells, linux-afs, linux-kernel

Clean up some whitespace from rxrpc.

Signed-off-by: David Howells <dhowells@redhat.com>
---

 net/rxrpc/call_event.c  |    2 +-
 net/rxrpc/conn_object.c |    2 +-
 net/rxrpc/input.c       |    4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/rxrpc/call_event.c b/net/rxrpc/call_event.c
index bda952ffe6a6..555274ddc514 100644
--- a/net/rxrpc/call_event.c
+++ b/net/rxrpc/call_event.c
@@ -426,7 +426,7 @@ void rxrpc_process_call(struct work_struct *work)
 	next = call->expect_rx_by;
 
 #define set(T) { t = READ_ONCE(T); if (time_before(t, next)) next = t; }
-	
+
 	set(call->expect_req_by);
 	set(call->expect_term_by);
 	set(call->ack_at);
diff --git a/net/rxrpc/conn_object.c b/net/rxrpc/conn_object.c
index 1aad04a32d5e..c628351eb900 100644
--- a/net/rxrpc/conn_object.c
+++ b/net/rxrpc/conn_object.c
@@ -424,7 +424,7 @@ void rxrpc_service_connection_reaper(struct work_struct *work)
 	if (earliest != now + MAX_JIFFY_OFFSET) {
 		_debug("reschedule reaper %ld", (long)earliest - (long)now);
 		ASSERT(time_after(earliest, now));
-		rxrpc_set_service_reap_timer(rxnet, earliest);		
+		rxrpc_set_service_reap_timer(rxnet, earliest);
 	}
 
 	while (!list_empty(&graveyard)) {
diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
index 23a5e61d8f79..6fc61400337f 100644
--- a/net/rxrpc/input.c
+++ b/net/rxrpc/input.c
@@ -976,7 +976,7 @@ static void rxrpc_input_call_packet(struct rxrpc_call *call,
 		rxrpc_reduce_call_timer(call, expect_rx_by, now,
 					rxrpc_timer_set_for_normal);
 	}
-	
+
 	switch (sp->hdr.type) {
 	case RXRPC_PACKET_TYPE_DATA:
 		rxrpc_input_data(call, skb, skew);
@@ -1213,7 +1213,7 @@ void rxrpc_data_ready(struct sock *udp_sk)
 				goto reupgrade;
 			conn->service_id = sp->hdr.serviceId;
 		}
-		
+
 		if (sp->hdr.callNumber == 0) {
 			/* Connection-level packet */
 			_debug("CONN %p {%d}", conn, conn->debug_id);

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net 2/3] rxrpc: Fix ACK generation from the connection event processor
  2017-11-29 15:33 [PATCH net-next 0/3] rxrpc: Fixes David Howells
  2017-11-29 15:33 ` [PATCH net 1/3] rxrpc: Clean up whitespace David Howells
@ 2017-11-29 15:33 ` David Howells
  2017-11-29 15:34 ` [PATCH net 3/3] rxrpc: Fix variable overwrite David Howells
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: David Howells @ 2017-11-29 15:33 UTC (permalink / raw)
  To: netdev; +Cc: dhowells, linux-kernel, Jeffrey Altman, linux-afs

Repeat terminal ACKs and now terminal ACKs are now generated from the
connection event processor rather from call handling as this allows us to
discard client call structures as soon as possible and free up the channel
for a follow on call.

However, in ACKs so generated, the additional information trailer is
malformed because the padding that's meant to be in the middle isn't
included in what's transmitted.

Fix it so that the 3 bytes of padding are included in the transmission.

Further, the trailer is misaligned because of the padding, so assigment to
the u16 and u32 fields inside it might cause problems on some arches, so
fix this by breaking the padding and the trailer out of the packed struct.

(This also deals with potential compiler weirdies where some of the nested
structs are packed and some aren't).

The symptoms can be seen in wireshark as terminal DUPLICATE or IDLE ACK
packets in which the Max MTU, Interface MTU and rwind fields have weird
values and the Max Packets field is apparently missing.

Reported-by: Jeffrey Altman <jaltman@auristor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
---

 net/rxrpc/conn_event.c |   50 ++++++++++++++++++++++++++++--------------------
 1 file changed, 29 insertions(+), 21 deletions(-)

diff --git a/net/rxrpc/conn_event.c b/net/rxrpc/conn_event.c
index 9e9a8db1bc9c..4ca11be6be3c 100644
--- a/net/rxrpc/conn_event.c
+++ b/net/rxrpc/conn_event.c
@@ -30,22 +30,18 @@ static void rxrpc_conn_retransmit_call(struct rxrpc_connection *conn,
 	struct rxrpc_skb_priv *sp = skb ? rxrpc_skb(skb) : NULL;
 	struct rxrpc_channel *chan;
 	struct msghdr msg;
-	struct kvec iov;
+	struct kvec iov[3];
 	struct {
 		struct rxrpc_wire_header whdr;
 		union {
-			struct {
-				__be32 code;
-			} abort;
-			struct {
-				struct rxrpc_ackpacket ack;
-				u8 padding[3];
-				struct rxrpc_ackinfo info;
-			};
+			__be32 abort_code;
+			struct rxrpc_ackpacket ack;
 		};
 	} __attribute__((packed)) pkt;
+	struct rxrpc_ackinfo ack_info;
 	size_t len;
-	u32 serial, mtu, call_id;
+	int ioc;
+	u32 serial, mtu, call_id, padding;
 
 	_enter("%d", conn->debug_id);
 
@@ -66,6 +62,13 @@ static void rxrpc_conn_retransmit_call(struct rxrpc_connection *conn,
 	msg.msg_controllen = 0;
 	msg.msg_flags	= 0;
 
+	iov[0].iov_base	= &pkt;
+	iov[0].iov_len	= sizeof(pkt.whdr);
+	iov[1].iov_base	= &padding;
+	iov[1].iov_len	= 3;
+	iov[2].iov_base	= &ack_info;
+	iov[2].iov_len	= sizeof(ack_info);
+
 	pkt.whdr.epoch		= htonl(conn->proto.epoch);
 	pkt.whdr.cid		= htonl(conn->proto.cid);
 	pkt.whdr.callNumber	= htonl(call_id);
@@ -80,8 +83,10 @@ static void rxrpc_conn_retransmit_call(struct rxrpc_connection *conn,
 	len = sizeof(pkt.whdr);
 	switch (chan->last_type) {
 	case RXRPC_PACKET_TYPE_ABORT:
-		pkt.abort.code	= htonl(chan->last_abort);
-		len += sizeof(pkt.abort);
+		pkt.abort_code	= htonl(chan->last_abort);
+		iov[0].iov_len += sizeof(pkt.abort_code);
+		len += sizeof(pkt.abort_code);
+		ioc = 1;
 		break;
 
 	case RXRPC_PACKET_TYPE_ACK:
@@ -94,13 +99,19 @@ static void rxrpc_conn_retransmit_call(struct rxrpc_connection *conn,
 		pkt.ack.serial		= htonl(skb ? sp->hdr.serial : 0);
 		pkt.ack.reason		= skb ? RXRPC_ACK_DUPLICATE : RXRPC_ACK_IDLE;
 		pkt.ack.nAcks		= 0;
-		pkt.info.rxMTU		= htonl(rxrpc_rx_mtu);
-		pkt.info.maxMTU		= htonl(mtu);
-		pkt.info.rwind		= htonl(rxrpc_rx_window_size);
-		pkt.info.jumbo_max	= htonl(rxrpc_rx_jumbo_max);
+		ack_info.rxMTU		= htonl(rxrpc_rx_mtu);
+		ack_info.maxMTU		= htonl(mtu);
+		ack_info.rwind		= htonl(rxrpc_rx_window_size);
+		ack_info.jumbo_max	= htonl(rxrpc_rx_jumbo_max);
 		pkt.whdr.flags		|= RXRPC_SLOW_START_OK;
-		len += sizeof(pkt.ack) + sizeof(pkt.info);
+		padding			= 0;
+		iov[0].iov_len += sizeof(pkt.ack);
+		len += sizeof(pkt.ack) + 3 + sizeof(ack_info);
+		ioc = 3;
 		break;
+
+	default:
+		return;
 	}
 
 	/* Resync with __rxrpc_disconnect_call() and check that the last call
@@ -110,9 +121,6 @@ static void rxrpc_conn_retransmit_call(struct rxrpc_connection *conn,
 	if (READ_ONCE(chan->last_call) != call_id)
 		return;
 
-	iov.iov_base	= &pkt;
-	iov.iov_len	= len;
-
 	serial = atomic_inc_return(&conn->serial);
 	pkt.whdr.serial = htonl(serial);
 
@@ -127,7 +135,7 @@ static void rxrpc_conn_retransmit_call(struct rxrpc_connection *conn,
 		break;
 	}
 
-	kernel_sendmsg(conn->params.local->socket, &msg, &iov, 1, len);
+	kernel_sendmsg(conn->params.local->socket, &msg, iov, ioc, len);
 	_leave("");
 	return;
 }

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net 3/3] rxrpc: Fix variable overwrite
  2017-11-29 15:33 [PATCH net-next 0/3] rxrpc: Fixes David Howells
  2017-11-29 15:33 ` [PATCH net 1/3] rxrpc: Clean up whitespace David Howells
  2017-11-29 15:33 ` [PATCH net 2/3] rxrpc: Fix ACK generation from the connection event processor David Howells
@ 2017-11-29 15:34 ` David Howells
  2017-11-29 15:39 ` [PATCH net-next 0/3] rxrpc: Fixes David Miller
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: David Howells @ 2017-11-29 15:34 UTC (permalink / raw)
  To: netdev; +Cc: dhowells, Gustavo A. R. Silva, linux-afs, linux-kernel

From: Gustavo A. R. Silva <garsilva@embeddedor.com>

Values assigned to both variable resend_at and ack_at are overwritten
before they can be used.

The correct fix here is to add 'now' to the previously computed value in
resend_at and ack_at.

Addresses-Coverity-ID: 1462262
Addresses-Coverity-ID: 1462263
Addresses-Coverity-ID: 1462264
Fixes: beb8e5e4f38c ("rxrpc: Express protocol timeouts in terms of RTT")
Link: https://marc.info/?i=17004.1511808959%40warthog.procyon.org.uk
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
---

 net/rxrpc/call_event.c |    2 +-
 net/rxrpc/sendmsg.c    |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/rxrpc/call_event.c b/net/rxrpc/call_event.c
index 555274ddc514..ad2ab1103189 100644
--- a/net/rxrpc/call_event.c
+++ b/net/rxrpc/call_event.c
@@ -123,7 +123,7 @@ static void __rxrpc_propose_ACK(struct rxrpc_call *call, u8 ack_reason,
 		else
 			ack_at = expiry;
 
-		ack_at = jiffies + expiry;
+		ack_at += now;
 		if (time_before(ack_at, call->ack_at)) {
 			WRITE_ONCE(call->ack_at, ack_at);
 			rxrpc_reduce_call_timer(call, ack_at, now,
diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c
index a1c53ac066a1..09f2a3e05221 100644
--- a/net/rxrpc/sendmsg.c
+++ b/net/rxrpc/sendmsg.c
@@ -233,7 +233,7 @@ static void rxrpc_queue_packet(struct rxrpc_sock *rx, struct rxrpc_call *call,
 		if (resend_at < 1)
 			resend_at = 1;
 
-		resend_at = now + rxrpc_resend_timeout;
+		resend_at += now;
 		WRITE_ONCE(call->resend_at, resend_at);
 		rxrpc_reduce_call_timer(call, resend_at, now,
 					rxrpc_timer_set_for_send);

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 0/3] rxrpc: Fixes
  2017-11-29 15:33 [PATCH net-next 0/3] rxrpc: Fixes David Howells
                   ` (2 preceding siblings ...)
  2017-11-29 15:34 ` [PATCH net 3/3] rxrpc: Fix variable overwrite David Howells
@ 2017-11-29 15:39 ` David Miller
  2017-11-29 17:25 ` David Howells
  2017-11-30 15:08 ` David Miller
  5 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2017-11-29 15:39 UTC (permalink / raw)
  To: dhowells; +Cc: netdev, linux-afs, linux-kernel

From: David Howells <dhowells@redhat.com>
Date: Wed, 29 Nov 2017 15:33:43 +0000

> 
> Here are three patches for AF_RXRPC.  One removes some whitespace, one
> fixes terminal ACK generation and the third makes a couple of places
> actually use the timeout value just determined rather than ignoring it.
> 
> The patches can be found here also:
> 
> 	http://git.kernel.org/cgit/linux/kernel/git/dhowells/linux-fs.git/log/?h=rxrpc-fixes
> 
> Tagged thusly:
> 
> 	git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git
> 	rxrpc-fixes-20171129

This email says "net-next", yet your patches say "net".

net-next is closed, but if these are real fixes they should go to 'net'.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 0/3] rxrpc: Fixes
  2017-11-29 15:33 [PATCH net-next 0/3] rxrpc: Fixes David Howells
                   ` (3 preceding siblings ...)
  2017-11-29 15:39 ` [PATCH net-next 0/3] rxrpc: Fixes David Miller
@ 2017-11-29 17:25 ` David Howells
  2017-11-29 18:09   ` David Miller
  2017-11-30 15:08 ` David Miller
  5 siblings, 1 reply; 8+ messages in thread
From: David Howells @ 2017-11-29 17:25 UTC (permalink / raw)
  To: David Miller; +Cc: dhowells, netdev, linux-afs, linux-kernel

David Miller <davem@davemloft.net> wrote:

> This email says "net-next", yet your patches say "net".

Sorry about that - it should be 'net'.  I copied an old cover note.  All the
patches have a macro substitution, but the cover note does not.  Do you want
me to repost?

David

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 0/3] rxrpc: Fixes
  2017-11-29 17:25 ` David Howells
@ 2017-11-29 18:09   ` David Miller
  0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2017-11-29 18:09 UTC (permalink / raw)
  To: dhowells; +Cc: netdev, linux-afs, linux-kernel

From: David Howells <dhowells@redhat.com>
Date: Wed, 29 Nov 2017 17:25:41 +0000

> David Miller <davem@davemloft.net> wrote:
> 
>> This email says "net-next", yet your patches say "net".
> 
> Sorry about that - it should be 'net'.  I copied an old cover note.  All the
> patches have a macro substitution, but the cover note does not.  Do you want
> me to repost?

It is not necessary to repost, thanks.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 0/3] rxrpc: Fixes
  2017-11-29 15:33 [PATCH net-next 0/3] rxrpc: Fixes David Howells
                   ` (4 preceding siblings ...)
  2017-11-29 17:25 ` David Howells
@ 2017-11-30 15:08 ` David Miller
  5 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2017-11-30 15:08 UTC (permalink / raw)
  To: dhowells; +Cc: netdev, linux-afs, linux-kernel

From: David Howells <dhowells@redhat.com>
Date: Wed, 29 Nov 2017 15:33:43 +0000

> Here are three patches for AF_RXRPC.  One removes some whitespace, one
> fixes terminal ACK generation and the third makes a couple of places
> actually use the timeout value just determined rather than ignoring it.
> 
> The patches can be found here also:
> 
> 	http://git.kernel.org/cgit/linux/kernel/git/dhowells/linux-fs.git/log/?h=rxrpc-fixes
> 
> Tagged thusly:
> 
> 	git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git
> 	rxrpc-fixes-20171129

Pulled into 'net', thanks David.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-11-30 15:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-29 15:33 [PATCH net-next 0/3] rxrpc: Fixes David Howells
2017-11-29 15:33 ` [PATCH net 1/3] rxrpc: Clean up whitespace David Howells
2017-11-29 15:33 ` [PATCH net 2/3] rxrpc: Fix ACK generation from the connection event processor David Howells
2017-11-29 15:34 ` [PATCH net 3/3] rxrpc: Fix variable overwrite David Howells
2017-11-29 15:39 ` [PATCH net-next 0/3] rxrpc: Fixes David Miller
2017-11-29 17:25 ` David Howells
2017-11-29 18:09   ` David Miller
2017-11-30 15:08 ` David Miller

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).