From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752203AbcAFULq (ORCPT ); Wed, 6 Jan 2016 15:11:46 -0500 Received: from mail-lf0-f50.google.com ([209.85.215.50]:35341 "EHLO mail-lf0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751971AbcAFULn (ORCPT ); Wed, 6 Jan 2016 15:11:43 -0500 MIME-Version: 1.0 In-Reply-To: References: Date: Wed, 6 Jan 2016 23:11:41 +0300 Message-ID: Subject: Re: [BUG] skb corruption and kernel panic at forwarding with fragmentation From: Konstantin Khlebnikov To: Cong Wang Cc: Linux Kernel Network Developers , David Miller , Eric Dumazet , Linux Kernel Mailing List Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 6, 2016 at 10:59 PM, Cong Wang wrote: > On Wed, Jan 6, 2016 at 11:15 AM, Konstantin Khlebnikov wrote: >> Looks like this happens because ip_options_fragment() relies on >> correct ip options length in ip control block in skb. But in >> ip_finish_output_gso() control block in segments is reused by >> skb_gso_segment(). following ip_fragment() sees some garbage. >> >> In my case there was no ip options but length becomes non-zero and >> ip_options_fragment() picked some bytes from payload and decides to >> fill huge range with IPOPT_NOOP (1). One of that ones flipped nr_frags >> in skb_shared_info at the end of data =) >> > > Hmm, it looks like SKB_GSO_CB should be cleared after skb_gso_segment() > since all the gso information should be saved in shared_info after it finishes. > > Does a memset(0) on SKB_GSO_CB after skb_gso_segment() work as well? This will break present logic around ip_options_fragment() - it clears options from second and following fragments. With zeroed cb it will do nothing. ip_options_fragment() can get required information directly from ip header but it also resets fields in IPCB -- probably it should stay valid here and somebody else will use it later.