OSDN Git Service

kcm: remove any offset before parsing messages
authorDominique Martinet <asmadeus@codewreck.org>
Tue, 11 Sep 2018 09:21:43 +0000 (11:21 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 18 Sep 2018 01:42:39 +0000 (18:42 -0700)
commit072222b488bc55cce92ff246bdc10115fd57d3ab
tree103b4fd1e7b66f4135ef9ecac1918ace9fd81147
parentc73480910e9686a5c25155cb4d418d594b678196
kcm: remove any offset before parsing messages

The current code assumes kcm users know they need to look for the
strparser offset within their bpf program, which is not documented
anywhere and examples laying around do not do.

The actual recv function does handle the offset well, so we can create a
temporary clone of the skb and pull that one up as required for parsing.

The pull itself has a cost if we are pulling beyond the head data,
measured to 2-3% latency in a noisy VM with a local client stressing
that path. The clone's impact seemed too small to measure.

This bug can be exhibited easily by implementing a "trivial" kcm parser
taking the first bytes as size, and on the client sending at least two
such packets in a single write().

Note that bpf sockmap has the same problem, both for parse and for recv,
so it would pulling twice or a real pull within the strparser logic if
anyone cares about that.

Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/kcm/kcmsock.c