From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: 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