Received: by 10.223.176.5 with SMTP id f5csp853168wra; Sat, 3 Feb 2018 11:46:58 -0800 (PST) X-Google-Smtp-Source: AH8x226iQ2jcJbkGQ9aTEODE7aoiUlPnW2q7D1lVtkS4rQ3YZ5svyz1H97AN8F4bd8O4PGsvoxb/ X-Received: by 2002:a17:902:2e03:: with SMTP id q3-v6mr30872031plb.362.1517687218018; Sat, 03 Feb 2018 11:46:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517687217; cv=none; d=google.com; s=arc-20160816; b=YBSeeLjXpR1316fGPEphmMzlhqrNwvj+njh7SvtO6waciLI3sh5vffUfSpnb6wdg/r 8GQxLTfOtUyGGRnJ0/82Dz2YsODO0Wca4acWVDnlE9916jgE5dcNAQOyx9g/dubRK3D6 XMNUwnp8JKx00xdsGU8h6DNcBSv6bLGoycvZEDO8TsqxIaJygY6SBdclmk7WNwjsmz3U t0trVESuB6aIVuyAp3jFMhFIFx/hlqQfv6/YRtZtBLttim1Rf0YiQk6+QMQ+/gs8sARh TPzxdCW3fvwlpT/uEGi7DJxiQRpTgDY1sHCecOePiIqmMVwufEpBontCr6gxMlUMRQZg AgCg== 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=bhgs00KDmlibodSWOvEcVSOaZdgHFWjcmgpcy6oP6xo=; b=RxXyYpUiKeaU6TUAaKLGolUmfRltTdVntys4trbHtPKyvz6NUgAEBmjmvLHJ82T/+K xg6f2bXXcWYNIYSB1KKmFe3QC+qW0gzdaTZb30VGApH4GsF4sS9YyvthD6AeHFWb7Twy 1MAYJUQ3vhybVS2L5LcvRqbFs/qNnw0oBv70Tpd7UeEBbf1J1kOZY8elMK9Ql+u9MwYw q51MX1zG6A9QUmr5lMTGWhtLKmkWjjBa9NN4b+H1xTVLaMEgsWMt6rZco/u2ydEPk08S coumH+arQ0lPeUNpBdAvkxX5vUccSPEcekvF4wdu/oJNaUECW9He54LiiS+UbGMq/tdS Z76Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=b7BlSDhC; 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 y92-v6si4159242plb.137.2018.02.03.11.46.25; Sat, 03 Feb 2018 11:46:57 -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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=b7BlSDhC; 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 S1752414AbeBCSFP (ORCPT + 99 others); Sat, 3 Feb 2018 13:05:15 -0500 Received: from mail-by2nam03on0097.outbound.protection.outlook.com ([104.47.42.97]:1354 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752538AbeBCSCG (ORCPT ); Sat, 3 Feb 2018 13:02:06 -0500 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=bhgs00KDmlibodSWOvEcVSOaZdgHFWjcmgpcy6oP6xo=; b=b7BlSDhCJ6HJ9YEUK4OjG8gYtb25TYXNTB08ethegWMl1aKDbnK337u2KHoHYGj2VVEAUMosdKgIc//LlrBMnBGeldoPbP/1RKKwAefu7bCxqkAQAvWkUH5WiALrodZxIuzB3AX9W9FOMSAOTk9UNMWJpo+7bpB97OEoJJYtJOY= Received: from BL0PR2101MB1027.namprd21.prod.outlook.com (52.132.20.161) by BL0PR2101MB1105.namprd21.prod.outlook.com (52.132.24.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.485.5; Sat, 3 Feb 2018 18:01:32 +0000 Received: from BL0PR2101MB1027.namprd21.prod.outlook.com ([fe80::a8da:b5d9:d710:9bf9]) by BL0PR2101MB1027.namprd21.prod.outlook.com ([fe80::a8da:b5d9:d710:9bf9%3]) with mapi id 15.20.0485.006; Sat, 3 Feb 2018 18:01:32 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Tommi Rantala , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 060/110] tipc: fix tipc_mon_delete() oops in tipc_enable_bearer() error path Thread-Topic: [PATCH AUTOSEL for 4.14 060/110] tipc: fix tipc_mon_delete() oops in tipc_enable_bearer() error path Thread-Index: AQHTnRjx0Z8LVjw9Qky6y03P+tKyvQ== Date: Sat, 3 Feb 2018 18:00:57 +0000 Message-ID: <20180203180015.29073-60-alexander.levin@microsoft.com> References: <20180203180015.29073-1-alexander.levin@microsoft.com> In-Reply-To: <20180203180015.29073-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;BL0PR2101MB1105;7:J1MnC6rQFx2b3SkRsAPEskcNfFEOm9s/xAEln/pXPxaravkldWfHK1pLvu7z6CfQ1vtCYGn6W87DpT00v2JafS1DpWqKw4ePQXjx8SqCi7jTpehfr4SGZ6ZwJF9VdwjHXvYWiNIvX488kTz0ZwWQUYtfAdJ3w4wjCWJqNzSFV3UeG8UEPcpMb3yAHMVxxW04sgtqOggmh5r3UQVccrc9HnrxkaT0vtsw+kHR59D8zzhL5x6004Ey3A5AL1VA9Ak/ x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 29b9fa2a-ff7d-4969-295d-08d56b302855 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(2017052603307)(7193020);SRVR:BL0PR2101MB1105; x-ms-traffictypediagnostic: BL0PR2101MB1105: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(37575265505322)(28532068793085)(89211679590171)(82608151540597); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040501)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231101)(2400082)(944501161)(93006095)(93001095)(6055026)(61426038)(61427038)(6041288)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123558120)(6072148)(201708071742011);SRVR:BL0PR2101MB1105;BCL:0;PCL:0;RULEID:;SRVR:BL0PR2101MB1105; x-forefront-prvs: 05724A8921 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(396003)(39380400002)(39860400002)(346002)(376002)(199004)(189003)(6346003)(97736004)(6512007)(7736002)(26005)(305945005)(102836004)(105586002)(68736007)(5250100002)(8936002)(59450400001)(6486002)(6436002)(106356001)(6506007)(81166006)(81156014)(2501003)(2906002)(10090500001)(99286004)(66066001)(54906003)(6116002)(3846002)(36756003)(1076002)(8656006)(8676002)(110136005)(575784001)(107886003)(72206003)(2950100002)(478600001)(10290500003)(22452003)(6666003)(5660300001)(2900100001)(4326008)(25786009)(14454004)(316002)(86362001)(53936002)(3280700002)(186003)(3660700001)(76176011)(86612001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:BL0PR2101MB1105;H:BL0PR2101MB1027.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: bvZBQ+LnxNuhtk/3Z8ZSIS75VOQeAhNevtUcYsG71DIXPmh2jgrYm0X85PRpIEsl1FtVv5m8TCqgZmUKgaikLw== 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: 29b9fa2a-ff7d-4969-295d-08d56b302855 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Feb 2018 18:00:57.3003 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR2101MB1105 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tommi Rantala [ Upstream commit 642a8439ddd8423b92f2e71960afe21ee1f66bb6 ] Calling tipc_mon_delete() before the monitor has been created will oops. This can happen in tipc_enable_bearer() error path if tipc_disc_create() fails. [ 48.589074] BUG: unable to handle kernel paging request at 0000000000001= 008 [ 48.590266] IP: tipc_mon_delete+0xea/0x270 [tipc] [ 48.591223] PGD 1e60c5067 P4D 1e60c5067 PUD 1eb0cf067 PMD 0 [ 48.592230] Oops: 0000 [#1] SMP KASAN [ 48.595610] CPU: 5 PID: 1199 Comm: tipc Tainted: G B 4.15.= 0-rc4-pc64-dirty #5 [ 48.597176] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS = 1.10.2-2.fc27 04/01/2014 [ 48.598489] RIP: 0010:tipc_mon_delete+0xea/0x270 [tipc] [ 48.599347] RSP: 0018:ffff8801d827f668 EFLAGS: 00010282 [ 48.600705] RAX: ffff8801ee813f00 RBX: 0000000000000204 RCX: 00000000000= 00000 [ 48.602183] RDX: 1ffffffff1de6a75 RSI: 0000000000000297 RDI: 00000000000= 00297 [ 48.604373] RBP: 0000000000000000 R08: 0000000000000000 R09: fffffbfff1d= d1533 [ 48.605607] R10: ffffffff8eafbb05 R11: fffffbfff1dd1534 R12: 00000000000= 00050 [ 48.607082] R13: dead000000000200 R14: ffffffff8e73f310 R15: 00000000000= 01020 [ 48.608228] FS: 00007fc686484800(0000) GS:ffff8801f5540000(0000) knlGS:= 0000000000000000 [ 48.610189] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 48.611459] CR2: 0000000000001008 CR3: 00000001dda70002 CR4: 00000000003= 606e0 [ 48.612759] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 00000000000= 00000 [ 48.613831] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 00000000000= 00400 [ 48.615038] Call Trace: [ 48.615635] tipc_enable_bearer+0x415/0x5e0 [tipc] [ 48.620623] tipc_nl_bearer_enable+0x1ab/0x200 [tipc] [ 48.625118] genl_family_rcv_msg+0x36b/0x570 [ 48.631233] genl_rcv_msg+0x5a/0xa0 [ 48.631867] netlink_rcv_skb+0x1cc/0x220 [ 48.636373] genl_rcv+0x24/0x40 [ 48.637306] netlink_unicast+0x29c/0x350 [ 48.639664] netlink_sendmsg+0x439/0x590 [ 48.642014] SYSC_sendto+0x199/0x250 [ 48.649912] do_syscall_64+0xfd/0x2c0 [ 48.650651] entry_SYSCALL64_slow_path+0x25/0x25 [ 48.651843] RIP: 0033:0x7fc6859848e3 [ 48.652539] RSP: 002b:00007ffd25dff938 EFLAGS: 00000246 ORIG_RAX: 000000= 000000002c [ 48.654003] RAX: ffffffffffffffda RBX: 00007ffd25dff990 RCX: 00007fc6859= 848e3 [ 48.655303] RDX: 0000000000000054 RSI: 00007ffd25dff990 RDI: 00000000000= 00003 [ 48.656512] RBP: 00007ffd25dff980 R08: 00007fc685c35fc0 R09: 00000000000= 0000c [ 48.657697] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000d= 13010 [ 48.658840] R13: 00007ffd25e009c0 R14: 0000000000000000 R15: 00000000000= 00000 [ 48.662972] RIP: tipc_mon_delete+0xea/0x270 [tipc] RSP: ffff8801d827f668 [ 48.664073] CR2: 0000000000001008 [ 48.664576] ---[ end trace e811818d54d5ce88 ]--- Acked-by: Ying Xue Acked-by: Jon Maloy Signed-off-by: Tommi Rantala Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/tipc/monitor.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/tipc/monitor.c b/net/tipc/monitor.c index 9e109bb1a207..0fcfb3916dcf 100644 --- a/net/tipc/monitor.c +++ b/net/tipc/monitor.c @@ -633,9 +633,13 @@ void tipc_mon_delete(struct net *net, int bearer_id) { struct tipc_net *tn =3D tipc_net(net); struct tipc_monitor *mon =3D tipc_monitor(net, bearer_id); - struct tipc_peer *self =3D get_self(net, bearer_id); + struct tipc_peer *self; struct tipc_peer *peer, *tmp; =20 + if (!mon) + return; + + self =3D get_self(net, bearer_id); write_lock_bh(&mon->lock); tn->monitors[bearer_id] =3D NULL; list_for_each_entry_safe(peer, tmp, &self->list, list) { --=20 2.11.0