lkml.org 
[lkml]   [2017]   [Mar]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Date
    Subject[PATCH 3.2 178/199] net/dccp: fix use-after-free in dccp_invalid_packet
    3.2.87-rc1 review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Eric Dumazet <edumazet@google.com>

    [ Upstream commit 648f0c28df282636c0c8a7a19ca3ce5fc80a39c3 ]

    pskb_may_pull() can reallocate skb->head, we need to reload dh pointer
    in dccp_invalid_packet() or risk use after free.

    Bug found by Andrey Konovalov using syzkaller.

    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: Andrey Konovalov <andreyknvl@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
    ---
    net/dccp/ipv4.c | 12 +++++++-----
    1 file changed, 7 insertions(+), 5 deletions(-)

    --- a/net/dccp/ipv4.c
    +++ b/net/dccp/ipv4.c
    @@ -730,6 +730,7 @@ int dccp_invalid_packet(struct sk_buff *
    {
    const struct dccp_hdr *dh;
    unsigned int cscov;
    + u8 dccph_doff;

    if (skb->pkt_type != PACKET_HOST)
    return 1;
    @@ -751,18 +752,19 @@ int dccp_invalid_packet(struct sk_buff *
    /*
    * If P.Data Offset is too small for packet type, drop packet and return
    */
    - if (dh->dccph_doff < dccp_hdr_len(skb) / sizeof(u32)) {
    - DCCP_WARN("P.Data Offset(%u) too small\n", dh->dccph_doff);
    + dccph_doff = dh->dccph_doff;
    + if (dccph_doff < dccp_hdr_len(skb) / sizeof(u32)) {
    + DCCP_WARN("P.Data Offset(%u) too small\n", dccph_doff);
    return 1;
    }
    /*
    * If P.Data Offset is too too large for packet, drop packet and return
    */
    - if (!pskb_may_pull(skb, dh->dccph_doff * sizeof(u32))) {
    - DCCP_WARN("P.Data Offset(%u) too large\n", dh->dccph_doff);
    + if (!pskb_may_pull(skb, dccph_doff * sizeof(u32))) {
    + DCCP_WARN("P.Data Offset(%u) too large\n", dccph_doff);
    return 1;
    }
    -
    + dh = dccp_hdr(skb);
    /*
    * If P.type is not Data, Ack, or DataAck and P.X == 0 (the packet
    * has short sequence numbers), drop packet and return
    \
     
     \ /
      Last update: 2017-03-10 12:59    [W:6.203 / U:0.016 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site