Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2202199pxb; Fri, 25 Mar 2022 12:58:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyL4m8bNK+KdqcKwsWz3DKuf7GzCizzJLCWt0OJ7k/rY/oqx7reGs4vGFF79cRScyTGCQey X-Received: by 2002:a17:90b:3d1:b0:1c6:af7a:3268 with SMTP id go17-20020a17090b03d100b001c6af7a3268mr26400266pjb.55.1648238280543; Fri, 25 Mar 2022 12:58:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648238280; cv=none; d=google.com; s=arc-20160816; b=sP+IywPYpN8eolrc0uHpnsFm0fy7iA3eDGzKk2JbLK+R70FVRvlqmpxMq44INNtuI5 SD+rcUK1KnuUrjOiUcWv3Z0cP4f5Xi2jW0niyVKf89uHX5Kr0gXLG6tZiOq2j2mQm5/C tK9uSW1Ja1OoiZ12Mk8yN3GrXUxZL+lnMGsKcNEfLVvF5dY0mBxbPp3vbEVxb2+4Qrjx vxI1aTVyS0XPxRfGJkc83wUschaudzwhIdfti5EGVe83n1gQi93rqjDMJAsNt7qQUABR y0T4XYqz4VFpYAjQE0/VqsPNeqtYqrJCKmZSY6/T6ROT35ZE2B4PCZDhHmfI79dL/3AE fbcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=f+3Is/7vPs25CO1Vsd9z8JwbuBII5c7vt4xlc7Oxs7A=; b=GlH66WSSHH5HEs6CszRgguywU4AZLxfwlC5nJcbKDSfeZnboW3xHtudJptWnb6wcZE ba6yhPFT5OCZRbSDEeMOiHp9ArpxtpqzNlPU8ozEg9Wms4ng/Sh8dInwmvv15yy3QWE1 UbgaiHNQ5+4SzLEkBmmSGtoAt0J4ZskPP/lW7YMjlLV+57oAK/UvqYsCIsSQ05FBdsRq lOp3PTcRI9VPhsCrHd15fW2ALDA/1OvxnRLCXAFqbJ8vb0SklRbPCNU4v4OuwXfAjvYT Ebz55rQnrJjRXE6tKUc5hz8LKJ6NX8+H0wimenD1sFx771yogxv3pSZ3l1MaptKGyGVe 88RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KgY1vDwT; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id y20-20020a17090abd1400b001bfa1ab8030si3273734pjr.119.2022.03.25.12.58.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 12:58:00 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KgY1vDwT; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 02FE93458C9; Fri, 25 Mar 2022 11:46:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359652AbiCYPHo (ORCPT + 99 others); Fri, 25 Mar 2022 11:07:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359536AbiCYPG5 (ORCPT ); Fri, 25 Mar 2022 11:06:57 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 583B5A7741; Fri, 25 Mar 2022 08:05:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id C9B56CE2A4D; Fri, 25 Mar 2022 15:05:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9DFAC340E9; Fri, 25 Mar 2022 15:05:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1648220708; bh=icrGwmOK25UYFgQgo3z+S451MUlw67RZWzfCemRAJsc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KgY1vDwTkew94qwfYNhTh0GW9Q8OifhNievdN8Y8aTAnyJaHdSfvgZk6ZjSEfY2yf w3k7gkgEi10QJQZJekdS/EOcDHzcmjF+kc4XZeqr13+X2Al9r1D0P0NYy3OrduZd6k Q9Ote3s7vThDkEqQQyfbLavVU+bU/fG0yx3fxDU0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+e223cf47ec8ae183f2a0@syzkaller.appspotmail.com, Tadeusz Struk , Willem de Bruijn , Jakub Kicinski Subject: [PATCH 4.9 02/14] net: ipv6: fix skb_over_panic in __ip6_append_data Date: Fri, 25 Mar 2022 16:04:30 +0100 Message-Id: <20220325150415.769462574@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220325150415.694544076@linuxfoundation.org> References: <20220325150415.694544076@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tadeusz Struk commit 5e34af4142ffe68f01c8a9acae83300f8911e20c upstream. Syzbot found a kernel bug in the ipv6 stack: LINK: https://syzkaller.appspot.com/bug?id=205d6f11d72329ab8d62a610c44c5e7e25415580 The reproducer triggers it by sending a crafted message via sendmmsg() call, which triggers skb_over_panic, and crashes the kernel: skbuff: skb_over_panic: text:ffffffff84647fb4 len:65575 put:65575 head:ffff888109ff0000 data:ffff888109ff0088 tail:0x100af end:0xfec0 dev: Update the check that prevents an invalid packet with MTU equal to the fregment header size to eat up all the space for payload. The reproducer can be found here: LINK: https://syzkaller.appspot.com/text?tag=ReproC&x=1648c83fb00000 Reported-by: syzbot+e223cf47ec8ae183f2a0@syzkaller.appspotmail.com Signed-off-by: Tadeusz Struk Acked-by: Willem de Bruijn Link: https://lore.kernel.org/r/20220310232538.1044947-1-tadeusz.struk@linaro.org Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/ipv6/ip6_output.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -1329,8 +1329,8 @@ static int __ip6_append_data(struct sock sizeof(struct frag_hdr) : 0) + rt->rt6i_nfheader_len; - if (mtu < fragheaderlen || - ((mtu - fragheaderlen) & ~7) + fragheaderlen < sizeof(struct frag_hdr)) + if (mtu <= fragheaderlen || + ((mtu - fragheaderlen) & ~7) + fragheaderlen <= sizeof(struct frag_hdr)) goto emsgsize; maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen -