Received: by 10.213.65.68 with SMTP id h4csp2119771imn; Sun, 8 Apr 2018 20:11:38 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+YZqrvCRJbY0KQTlrb3D7lc0OXnK3YuVk6WM6dhqynGv+/0bKs7TogHUaarL9fKKoM0qF/ X-Received: by 10.98.71.76 with SMTP id u73mr27945656pfa.4.1523243498168; Sun, 08 Apr 2018 20:11:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243498; cv=none; d=google.com; s=arc-20160816; b=u4sJ+QxPQH4UiDgRzFsM1YKxdAgHq7Rq24TcVluszTg5hNcVU4V4v36ucd2idspyng ABAlcAbrg8Rw7lq88rTyqeXlXK+WYcX/DgKGhM14kC/Gju1+Txul970//7LB5LsWJztg H2CTUXyxVgRMP7g5j9bc294OniEW4A2ugWs2y3YO7tchgjw799jigoq5LbkoNUCJlKs9 n1nSWTqNVGfqPpn5hI8TWuqi1yHNRnhSd8wNAs93EchXJ0MQtR7j4/v8s4mM3Iw77zGc naGMjuJ/0NGcFROaayofsPmg+5ynjU9yWCaKxa26kKKgetWPgNt0CmaOMUiIhgWzp46v Zg7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=0bcP/Y1DGtYTXuQRKKj3u/m9QxjOWfY/hZewRpZS0pA=; b=WkP+olyimKapxAIFAkvA8cg5Vgx8XB+ZXZgyMum3k4rUWQv3xMOz/5BzTLUjOFwJtn aczIHm3s3zDrn99hypbIm98Zsoh1ClIIxB2clwC48pDTmexI9qxOBdOAErP3u60h0N6t 69sMUHz3S9qLlJ0SEhqJk9MLh/CmcvyOuvr6giWJR2dZBfO37Ij8ds+8xyeFxk4jCHJ2 O5Voi9KXfrMCKi5LJysq1MAkD5vEeFCJcmNafU/usTvDA62AQ9l3aoEGHHPxe/qLKFJ8 b70I7q8S4Jz4J6LONONpBeBqV0Qs6J/smGKhydpNrZ8Z07pDRrtoaD61+3aBHpNvnyqe fRug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=LE1tJo7D; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q8-v6si14094041plr.477.2018.04.08.20.11.01; Sun, 08 Apr 2018 20:11:38 -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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=LE1tJo7D; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757412AbeDICXr (ORCPT + 99 others); Sun, 8 Apr 2018 22:23:47 -0400 Received: from mail-by2nam03on0107.outbound.protection.outlook.com ([104.47.42.107]:6816 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756004AbeDIA3h (ORCPT ); Sun, 8 Apr 2018 20:29:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=0bcP/Y1DGtYTXuQRKKj3u/m9QxjOWfY/hZewRpZS0pA=; b=LE1tJo7DvYXroHqk2YP4m6mem8eB8eRqyKrZcPl0rr4ywdU1ZHyQwC2vyV7bysFPIzQSIsv6QAW6OjwIQPWSYlntn8SV0Vm7G/nh3IKfFsYzgsXoUEUFHvxLQqzQaHBDTEZheBZJlst6tLNY/jKiaVQBu/dJ9FzL/4rUz2RhGqE= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0967.namprd21.prod.outlook.com (52.132.133.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:29:34 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:29:34 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Xin Long , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 107/293] dccp: call inet_add_protocol after register_pernet_subsys in dccp_v4_init Thread-Topic: [PATCH AUTOSEL for 4.9 107/293] dccp: call inet_add_protocol after register_pernet_subsys in dccp_v4_init Thread-Index: AQHTz5kYibFtGCXaWUKUWAOWb9Qn1w== Date: Mon, 9 Apr 2018 00:24:17 +0000 Message-ID: <20180409002239.163177-107-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0967;7:MnLlMOO3feO0NTzOqxUlr2HGbQYUGn5RnR9r5IlQpApFlbdeqdlTVYOmvgH8SjNDGla2VIxT/L9xZPMGZPNFDxcpGTmKLLzXahweB1+nfboXB4X2XuJEUiqo0aosZk99AjnoQgCEjd7hE2jYvJoA3YDMIyuYVVqTMmftXjQg/19hUf2M7xdOOI4Wv5NoXtaY6Kji9+UIGcko23qAJvjjGEIw59/boIuKxvQfHh5fsgEHiRFz82N4RGsGhpX50+qS;20:lOQ9PQWi2TZoZJC6Nn/Nry+yd3G/dQZ+wIEPutKe4YXbZC1d1sufnF8niLrbfFC/uWswqeT52ucsv7JxZw8mrrSTPIYH2MpVBzLi2Gw5sbCjn05N3ySoR62uYeMboL6DmiHe+pRttAINyZ4Yv1VSQXetL0FUluLxWur1xTdmMYI= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 7f99f3e7-cc84-4e3b-d9a9-08d59db0f83d x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0967; x-ms-traffictypediagnostic: DM5PR2101MB0967: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(85827821059158); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011);SRVR:DM5PR2101MB0967;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0967; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(39860400002)(366004)(376002)(39380400002)(346002)(199004)(189003)(6506007)(486006)(86362001)(14454004)(59450400001)(68736007)(102836004)(99286004)(26005)(3846002)(6116002)(186003)(476003)(2616005)(1076002)(3280700002)(86612001)(72206003)(4326008)(446003)(54906003)(76176011)(11346002)(2906002)(22452003)(3660700001)(110136005)(97736004)(316002)(6666003)(5660300001)(478600001)(8676002)(6512007)(8936002)(39060400002)(107886003)(6486002)(53936002)(81166006)(36756003)(81156014)(10290500003)(6436002)(10090500001)(25786009)(66066001)(106356001)(305945005)(7736002)(2501003)(5250100002)(105586002)(2900100001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0967;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: pi2zM4wPHSeEa1EjQDd1k/7VTaCMEUZuXgrcYRkVhk9Rf8V68SiWOGdD+36UvDUP3A9YXu0digN16CYqiuargSEvZqMRf3WNa//Azv/zdzGWa7B8XE9zWCxmk5ySjMvUzYw6rOV4RmD1wmHEzEwlXas91JfFKDhmwyQX97XHwNFh1BLCyjdXzyH6ib24ukyxfmfkI7ugFrKKKzE4SrKDUTAqme6jhDo59osZPL3Psq8guUrCDt2nbUw5dKzgq+bPZ+2KXLMYJNIbXnuG5WopVGNK1KyRf7/s9QUa8hgumqtQttYmlIv9i6vYn1z6H/pD1bx7YL1HaQg07WBwM3H5nTcyDA6Tg+C+sdFEWFNLgl1t46iD0xepvT4LRt8aNNahcADP7udrA5R2cvWynJGH8IO99EchzSReTqigmXgWqeE= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7f99f3e7-cc84-4e3b-d9a9-08d59db0f83d X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:24:17.0656 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0967 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xin Long [ Upstream commit d5494acb88aa9dd1325079c9b8855008a52c19b3 ] Now dccp_ipv4 works as a kernel module. During loading this module, if one dccp packet is being recieved after inet_add_protocol but before register_pernet_subsys in which v4_ctl_sk is initialized, a null pointer dereference may be triggered because of init_net.dccp.v4_ctl_sk is 0x0. Jianlin found this issue when the following call trace occurred: [ 171.950177] BUG: unable to handle kernel NULL pointer dereference at 000= 0000000000110 [ 171.951007] IP: [] dccp_v4_ctl_send_reset+0xc4/0x220 [= dccp_ipv4] [...] [ 171.984629] Call Trace: [ 171.984859] [ 171.985061] [ 171.985213] [] dccp_v4_rcv+0x383/0x3f9 [dccp_ipv4] [ 171.985711] [] ip_local_deliver_finish+0xb4/0x1f0 [ 171.986309] [] ip_local_deliver+0x59/0xd0 [ 171.986852] [] ? update_curr+0x104/0x190 [ 171.986956] [] ip_rcv_finish+0x8a/0x350 [ 171.986956] [] ip_rcv+0x2b6/0x410 [ 171.986956] [] ? task_cputime+0x44/0x80 [ 171.986956] [] __netif_receive_skb_core+0x572/0x7c0 [ 171.986956] [] ? trigger_load_balance+0x61/0x1e0 [ 171.986956] [] __netif_receive_skb+0x18/0x60 [ 171.986956] [] process_backlog+0xae/0x180 [ 171.986956] [] net_rx_action+0x16d/0x380 [ 171.986956] [] __do_softirq+0xef/0x280 [ 171.986956] [] call_softirq+0x1c/0x30 This patch is to move inet_add_protocol after register_pernet_subsys in dccp_v4_init, so that v4_ctl_sk is initialized before any incoming dccp packets are processed. Reported-by: Jianlin Shi Signed-off-by: Xin Long Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/dccp/ipv4.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 8c7799cdd3cf..1b455741b750 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c @@ -1038,33 +1038,34 @@ static int __init dccp_v4_init(void) { int err =3D proto_register(&dccp_v4_prot, 1); =20 - if (err !=3D 0) + if (err) goto out; =20 - err =3D inet_add_protocol(&dccp_v4_protocol, IPPROTO_DCCP); - if (err !=3D 0) - goto out_proto_unregister; - inet_register_protosw(&dccp_v4_protosw); =20 err =3D register_pernet_subsys(&dccp_v4_ops); if (err) goto out_destroy_ctl_sock; + + err =3D inet_add_protocol(&dccp_v4_protocol, IPPROTO_DCCP); + if (err) + goto out_proto_unregister; + out: return err; +out_proto_unregister: + unregister_pernet_subsys(&dccp_v4_ops); out_destroy_ctl_sock: inet_unregister_protosw(&dccp_v4_protosw); - inet_del_protocol(&dccp_v4_protocol, IPPROTO_DCCP); -out_proto_unregister: proto_unregister(&dccp_v4_prot); goto out; } =20 static void __exit dccp_v4_exit(void) { + inet_del_protocol(&dccp_v4_protocol, IPPROTO_DCCP); unregister_pernet_subsys(&dccp_v4_ops); inet_unregister_protosw(&dccp_v4_protosw); - inet_del_protocol(&dccp_v4_protocol, IPPROTO_DCCP); proto_unregister(&dccp_v4_prot); } =20 --=20 2.15.1