Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2988951imu; Sun, 9 Dec 2018 14:25:10 -0800 (PST) X-Google-Smtp-Source: AFSGD/WXt/J4lUq5zfxYyU0c7m5x38sd7ZU0fKmkn01+ZhajxFLG4qwpZH8cmRMUFI1KyhlTce31 X-Received: by 2002:aa7:8045:: with SMTP id y5mr10042074pfm.62.1544394310848; Sun, 09 Dec 2018 14:25:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544394310; cv=none; d=google.com; s=arc-20160816; b=wInKlh0llPDWXnMpiIY3sPMiXCOG7kWnw6JaIZIxpMcvsXFlBlXwixMRdCZ3MunHtu xCGjTjoNYWSNLajZS+RVa1Rc35WnX/+aFLx7HuWT4WvOBtusuyz9/scrbPxfhBYoEKJw xw/lmwYfwVPCQCT/7W9g0xGZHxiVh2RpNi3ZGs3Hf9MivOmAhEgxZLpBUyZrKqQNxW6+ 0+R6HTKkuSxqZ3bfujfIdAVtnWYCEQR0BfXS6iavUe09LRmjzjdX4/jDwTQVYO0jCZy6 hTjdaM7lSLUUt91l9mFySRaWiWLqiNbxWi6VMxF4XLTrACzP+cCdY5wf/WPPZ/SEPmHB NAjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=TXhLWIkRRi4vVpewj65wc7AkO7H6bQfa6T3BDjUd51Y=; b=FLrh0Xm/1sWzOXLNdiBp3QURTjrYiHrfSDVO9Ho0u+jXNfLd+f3HDb+DXI/YDvGETB J4a7HGHWxMEeJmZ2PdtsCKxnlDdecFhWy9W/1z82kQwr7ivulUkw/C1Ur0B4RgESgwan 3jX1OjPq7u3F1nTAT5Ch47lvL8hWFOI8P5KKudMBaIxhvA7XupRLeINRi0YR+zcbBvJa msZ9AJTtQYq0XWwjdfeBcNBzF0Qff1pc0J8OOIqOBJJK63mHiAdYL/K0PjoGDKvNtac0 SkL0co0Kvb0jZ8V4Haf7rLXVf5ryG9PBkSXyK8yIqhQRctisXDIwCslD6IfJ9HdTsrJz TIrQ== 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 92si8777278pld.84.2018.12.09.14.24.55; Sun, 09 Dec 2018 14:25:10 -0800 (PST) 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 S1728597AbeLIWXh (ORCPT + 99 others); Sun, 9 Dec 2018 17:23:37 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:35070 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726488AbeLIVzS (ORCPT ); Sun, 9 Dec 2018 16:55:18 -0500 Received: from pub.yeoldevic.com ([81.174.156.145] helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gW72h-0002if-Pf; Sun, 09 Dec 2018 21:55:16 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gW72e-0003SA-Q8; Sun, 09 Dec 2018 21:55:12 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "David S. Miller" , "Sabrina Dubroca" Date: Sun, 09 Dec 2018 21:50:33 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 173/328] ipv6: fix cleanup ordering for pingv6 registration In-Reply-To: X-SA-Exim-Connect-IP: 81.174.156.145 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.62-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Sabrina Dubroca commit a03dc36bdca6b614651fedfcd8559cf914d2d21d upstream. Commit 6d0bfe226116 ("net: ipv6: Add IPv6 support to the ping socket.") contains an error in the cleanup path of inet6_init(): when proto_register(&pingv6_prot, 1) fails, we try to unregister &pingv6_prot. When rawv6_init() fails, we skip unregistering &pingv6_prot. Example of panic (triggered by faking a failure of proto_register(&pingv6_prot, 1)): general protection fault: 0000 [#1] PREEMPT SMP KASAN PTI [...] RIP: 0010:__list_del_entry_valid+0x79/0x160 [...] Call Trace: proto_unregister+0xbb/0x550 ? trace_preempt_on+0x6f0/0x6f0 ? sock_no_shutdown+0x10/0x10 inet6_init+0x153/0x1b8 Fixes: 6d0bfe226116 ("net: ipv6: Add IPv6 support to the ping socket.") Signed-off-by: Sabrina Dubroca Signed-off-by: David S. Miller Signed-off-by: Ben Hutchings --- net/ipv6/af_inet6.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -860,14 +860,14 @@ static int __init inet6_init(void) err = proto_register(&pingv6_prot, 1); if (err) - goto out_unregister_ping_proto; + goto out_unregister_raw_proto; /* We MUST register RAW sockets before we create the ICMP6, * IGMP6, or NDISC control sockets. */ err = rawv6_init(); if (err) - goto out_unregister_raw_proto; + goto out_unregister_ping_proto; /* Register the family here so that the init calls below will * be able to create sockets. (?? is this dangerous ??)