]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
rxrpc: Be more selective about the types of received packets we accept
authorDavid Howells <dhowells@redhat.com>
Fri, 4 Mar 2016 15:56:06 +0000 (15:56 +0000)
committerDavid Howells <dhowells@redhat.com>
Fri, 4 Mar 2016 15:56:06 +0000 (15:56 +0000)
Currently, received RxRPC packets outside the range 1-13 are rejected.
There are, however, holes in the range that should also be rejected - plus
at least one type we don't yet support - so reject these also.

Signed-off-by: David Howells <dhowells@redhat.com>
include/rxrpc/packet.h
net/rxrpc/ar-input.c

index de1e67988ada771ab51b8c2a12a7f7a8e747fb53..9ebab3a8cf0aa2f566fda02a9b3e4e42561ca42c 100644 (file)
@@ -70,6 +70,17 @@ struct rxrpc_wire_header {
 
 extern const char *rxrpc_pkts[];
 
+#define RXRPC_SUPPORTED_PACKET_TYPES (                 \
+               (1 << RXRPC_PACKET_TYPE_DATA) |         \
+               (1 << RXRPC_PACKET_TYPE_ACK) |          \
+               (1 << RXRPC_PACKET_TYPE_BUSY) |         \
+               (1 << RXRPC_PACKET_TYPE_ABORT) |        \
+               (1 << RXRPC_PACKET_TYPE_ACKALL) |       \
+               (1 << RXRPC_PACKET_TYPE_CHALLENGE) |    \
+               (1 << RXRPC_PACKET_TYPE_RESPONSE) |     \
+               /*(1 << RXRPC_PACKET_TYPE_DEBUG) | */   \
+               (1 << RXRPC_PACKET_TYPE_VERSION))
+
 /*****************************************************************************/
 /*
  * jumbo packet secondary header
index e6396a8c969f2f3579d29b8ba4b2d09d6234f9ac..63ed75c40e29a1739470f90e21d5f60d1bab8fe1 100644 (file)
@@ -728,7 +728,8 @@ void rxrpc_data_ready(struct sock *sk)
             sp->hdr.flags & RXRPC_CLIENT_INITIATED ? "ToServer" : "ToClient",
             sp->hdr.epoch, sp->hdr.cid, sp->hdr.callNumber);
 
-       if (sp->hdr.type == 0 || sp->hdr.type >= RXRPC_N_PACKET_TYPES) {
+       if (sp->hdr.type >= RXRPC_N_PACKET_TYPES ||
+           !((RXRPC_SUPPORTED_PACKET_TYPES >> sp->hdr.type) & 1)) {
                _proto("Rx Bad Packet Type %u", sp->hdr.type);
                goto bad_message;
        }