From patchwork Tue Jan 12 16:58:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 8019241 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DAD899F3F6 for ; Tue, 12 Jan 2016 16:58:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CDE4D203E3 for ; Tue, 12 Jan 2016 16:58:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2058E20145 for ; Tue, 12 Jan 2016 16:58:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762290AbcALQ6E (ORCPT ); Tue, 12 Jan 2016 11:58:04 -0500 Received: from mail-pa0-f51.google.com ([209.85.220.51]:36120 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761778AbcALQ6D (ORCPT ); Tue, 12 Jan 2016 11:58:03 -0500 Received: by mail-pa0-f51.google.com with SMTP id yy13so249886832pab.3; Tue, 12 Jan 2016 08:58:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:cc:date:in-reply-to:references :content-type:mime-version:content-transfer-encoding; bh=YGkxZ41UZ4A+Ahrr9MEyN3cSoZsIBnvvHZhuLdnoLio=; b=txRGzWrJ5LabtK/S/beCpR/qPCAU3BtVGoBlnvgdiocBLUjJBalMauTV1g5Bmh1INN sDsOoo4/EC2yBIApghtZo2tpV0rJxJgaZm6Z5Vvkeqsw8XDfEugDXwnXvs4lykIIcvAR wHReVjI357Qprf9fl9Tsii4wCfw7MDJIVHXNcx9Hz7eMo245NHi3SR7OSJ97adFvqfJR Xmd2TJZAl3yCGGR2yOnTci3BMgAFnEA9DXdSsKypVs0aSXeIp25aj/38HF95gT7Jwhzf RoIyBy8MfL1LXR2GuiGY8i0Xj+OookraIpXOVUx/8ZBPVLMm7JAiYrXcFphWHjpHpUY9 yo0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:content-type:mime-version:content-transfer-encoding; bh=YGkxZ41UZ4A+Ahrr9MEyN3cSoZsIBnvvHZhuLdnoLio=; b=M4UKwqp/BLUvCV2FA9em6C+IAtSeWo8ZpMJFe9t6FY3ly9Kpn6WmPNsQapjSwcCXK1 rAlmKvqnr1zMjs6Fa7p5FxSZOJOEPmkPL1MMArm/03/6h/sfy2GOCQpu9+NHtnQJI1/v Q4HKCcHMVFIjPb93wReqGjB1XCCX21Xzy3H+eGiJppDpEVBjz3CJra+NoKf6WeMI3WKn lm+QLY0wN5v32W98tCO4Cuqfet7cWPXsjh9hKJrCXOx7nXyNhZBDo5K6ylODMQz8+6Nz 12m5gGIdHVRKuvoFl06XQcnZ6QeAgCPp1SCjmpztAUqarwk27nBl3qxeSslXaUprDJFM AuQA== X-Gm-Message-State: ALoCoQnGN4D74y9O+TcVxm+bqiK6W8IUtpUiLLFrgZ+31VlBzpVB21JJjh2RHZ/en3fOoKFYda8WTYtrrA4GaCY/8Hq2RjsSvw== X-Received: by 10.66.102.70 with SMTP id fm6mr90396182pab.80.1452617881876; Tue, 12 Jan 2016 08:58:01 -0800 (PST) Received: from ?IPv6:2620:0:1000:3e02:c1b5:306f:eecb:c3d2? ([2620:0:1000:3e02:c1b5:306f:eecb:c3d2]) by smtp.gmail.com with ESMTPSA id xi8sm194150267pab.9.2016.01.12.08.58.00 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 12 Jan 2016 08:58:00 -0800 (PST) Message-ID: <1452617880.1223.21.camel@edumazet-glaptop2.roam.corp.google.com> Subject: [PATCH net] phonet: properly unshare skbs in phonet_rcv() From: Eric Dumazet To: Ivaylo Dimitrov , Remi Denis-Courmont Cc: Salam Noureddine , "David S. Miller" , Pali =?ISO-8859-1?Q?Roh=E1r?= , Network Development , LKML , Sebastian Reichel , "linux-omap@vger.kernel.org" Date: Tue, 12 Jan 2016 08:58:00 -0800 In-Reply-To: <1452608377.1223.13.camel@edumazet-glaptop2.roam.corp.google.com> References: <568EA671.7000502@gmail.com> <56929985.3020502@gmail.com> <1452457610.16445.13.camel@edumazet-glaptop2.roam.corp.google.com> <5694188F.80907@gmail.com> <56944DFA.4050002@gmail.com> <1452560786.1223.6.camel@edumazet-glaptop2.roam.corp.google.com> <1452565288.1223.10.camel@edumazet-glaptop2.roam.corp.google.com> <1452565515.1223.11.camel@edumazet-glaptop2.roam.corp.google.com> <5694A840.8030900@gmail.com> <1452608377.1223.13.camel@edumazet-glaptop2.roam.corp.google.com> X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Dumazet Ivaylo Dimitrov reported a regression caused by commit 7866a621043f ("dev: add per net_device packet type chains"). skb->dev becomes NULL and we crash in __netif_receive_skb_core(). Before above commit, different kind of bugs or corruptions could happen without major crash. But the root cause is that phonet_rcv() can queue skb without checking if skb is shared or not. Many thanks to Ivaylo Dimitrov for his help, diagnosis and tests. Reported-by: Ivaylo Dimitrov Tested-by: Ivaylo Dimitrov Signed-off-by: Eric Dumazet Cc: Remi Denis-Courmont --- net/phonet/af_phonet.c | 4 ++++ 1 file changed, 4 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c index 10d42f3220ab..f925753668a7 100644 --- a/net/phonet/af_phonet.c +++ b/net/phonet/af_phonet.c @@ -377,6 +377,10 @@ static int phonet_rcv(struct sk_buff *skb, struct net_device *dev, struct sockaddr_pn sa; u16 len; + skb = skb_share_check(skb, GFP_ATOMIC); + if (!skb) + return NET_RX_DROP; + /* check we have at least a full Phonet header */ if (!pskb_pull(skb, sizeof(struct phonethdr))) goto out;