Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2565549yba; Sun, 7 Apr 2019 23:07:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqym18Ar8PNAAtHgh/5vVhrv6KNKZbeQYC3R/BFuEexT3Qmzohw05bIWMQKa15iv8JYXGvRr X-Received: by 2002:a63:5854:: with SMTP id i20mr25924710pgm.171.1554703678468; Sun, 07 Apr 2019 23:07:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554703678; cv=none; d=google.com; s=arc-20160816; b=0AtxABu/17RraMRS5X46EH4luKi6ztErXtdbwZnlX5Twr8KLqZCmQNHCWB3Pdia+VK BlGF33JrSkij1dTI2I112OTBEfr6Fw/pI0mGbvmvd54b/wOjR2tEVy/Cn7YqRXPtmSaT +17pQV4rRWB9HZArWvNFLkffNlm1R5WgNe6+a1NTg0BFJPNurCkIoHZ8Z4vSn1VvUD0g S7x2SE+1A8Ono4DsGdw/BHmURw8Jlu+KPQMHARanlFVW3e8/7qFrhy161CtcZA34Gynh OyloPnXbhzC1Od1kSEmxFMMD/IXcm8pv81iOKX80gcq+JbdzPrCc17vCEN4fWijqGKT7 i8tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:organization:subject:cc:to:from:date :content-transfer-encoding:mime-version; bh=4IVT8qV1tLi7ptLVHLpXnwM0djYFaEU9CaSVKMVGKl4=; b=mRLgIg7C0cE7MZeoUkBYWJ0L8XOHm9sJYL+j7AP2+w2/zPfCR3Wye8XK3fwIoG7QAn MTHET+DnpFRTWnQepP23FnheTK1vcaucGa/Y6VFLXWWjs6dBdo3JDSFc1/NnSAPxvkMB RYpFsh65fjzadc9cwKzekIxO7Y/2mdCbUzJSh2EHxGkNtKZazTuRRmpICZ3DUxjEea8s dvmX8Ztu9DVO8qpPoP3YFjhGOrmfwOo7Z/9pkygIeV00TcLAZMLh5nvCHwnih5Hf8k1o Is31BG6xmlCqx5w4gGX9c7fKClLzH2BzP8qsDAB2n+UVpuFdQh+lpKryrZhzzcLCmj9u uYmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z12si22005952pln.248.2019.04.07.23.07.42; Sun, 07 Apr 2019 23:07:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726050AbfDHGHG (ORCPT + 99 others); Mon, 8 Apr 2019 02:07:06 -0400 Received: from host-88-217-225-28.customer.m-online.net ([88.217.225.28]:33505 "EHLO mail.dev.tdt.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725854AbfDHGHF (ORCPT ); Mon, 8 Apr 2019 02:07:05 -0400 Received: from mail.dev.tdt.de (localhost [IPv6:::1]) by mail.dev.tdt.de (Postfix) with ESMTP id 80F3820405; Mon, 8 Apr 2019 06:07:02 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 08 Apr 2019 08:07:02 +0200 From: Martin Schiller To: David Miller Cc: andrew.hendry@gmail.com, khc@pm.waw.pl, isdn@linux-pingi.de, edumazet@google.com, linux-x25@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/4] wan/hdlc_x25: fix skb handling Organization: TDT GmbH In-Reply-To: <20190405.121529.675930084772235847.davem@davemloft.net> References: <20190403050118.12785-2-ms@dev.tdt.de> <20190404.173240.1338878948110207179.davem@davemloft.net> <20190405.121529.675930084772235847.davem@davemloft.net> Message-ID: <33a61588eabfb433dcf03a61d218a81a@dev.tdt.de> X-Sender: ms@dev.tdt.de User-Agent: Roundcube Webmail/1.1.5 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dev.tdt.de Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-04-05 21:15, David Miller wrote: > From: Martin Schiller > Date: Fri, 05 Apr 2019 08:56:44 +0200 > >> On 2019-04-05 02:32, David Miller wrote: >>> From: Martin Schiller >>> Date: Wed, 3 Apr 2019 07:01:16 +0200 >>> >>>> /* X.25 to LAPB */ >>>> switch (skb->data[0]) { >>>> case X25_IFACE_DATA: /* Data to be transmitted */ >>>> - skb_pull(skb, 1); >>>> - if ((result = lapb_data_request(dev, skb)) != LAPB_OK) >>>> - dev_kfree_skb(skb); >>>> - return NETDEV_TX_OK; >>>> + skbn = skb_copy(skb, GFP_ATOMIC); >>>> + skb_pull(skbn, 1); >>>> + skb_reset_network_header(skbn); >>>> + if ((result = lapb_data_request(dev, skbn)) != LAPB_OK) >>>> + dev_kfree_skb(skbn); >>> This leaks 'skb'. >> >> What exactly do you mean? >> 'skb' will get freed at the end of x25_xmit() function: >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/wan/hdlc_x25.c#n129 > > Then why was it freed here in the original code? In the original code, 'skb' is only freed here if lapb_data_request() return a value != LAPB_OK, which is the case when the skb can't be queued for transmission. Otherwise 'skb' won't be freed here in the "X25_IFACE_DATA" case. What my change do is, that 'skb' is copied to 'skbn' before the skb_pull of the first byte, to fix the problem that tracing layer3 (ETH_P_X25) packets results in a malformed first byte of the packets, because the original "skb" will get modified before the frame reaches the tcpdump output. Everything else works like before.