• D
    kcm: remove any offset before parsing messages · 072222b4
    Dominique Martinet 提交于
    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: NDominique Martinet <asmadeus@codewreck.org>
    Signed-off-by: NDavid S. Miller <davem@davemloft.net>
    072222b4
kcmsock.c 45.6 KB