From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D53A9C169C4 for ; Thu, 31 Jan 2019 17:15:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A946520881 for ; Thu, 31 Jan 2019 17:15:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="JLVgNiNx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732000AbfAaRPx (ORCPT ); Thu, 31 Jan 2019 12:15:53 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:60716 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726355AbfAaRPx (ORCPT ); Thu, 31 Jan 2019 12:15:53 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x0VHE1T7193455; Thu, 31 Jan 2019 17:15:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=b/a++lWtvnbzLXd3UblCAE1pn0WnVTSgXfgb31VDfcE=; b=JLVgNiNxGMAADqgCpcTY/1BsO5drhH2i0z3QVF4xom7+79JUFrJbr5B5iCkt32v4XvZn D2HdvVPcUPDsxG0HrNkaw+C4eOZjJxQ0z1E/EHvCEQcMqhEnaV/+rZ/jPWPff/3kOYl0 1VRjnS3UBb63qOYqhzeL8gPNob6Qtk/OD64yQlFdsFyCO29lgLK3Ym1SfKo0GhiKaSoR jzqgXeVWxaH5UGD+DWva4n0tjoqO++uYe5xvpeOlmNXR2jnchCIgL92H7aCQq/Wj2krg ht8G2sjQBF8JGbDvzhcEcSs+V5nbJQM25fCrMsTLy3LQjiVz6yH9+u+tEnDC7mDbCvcO qQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2q8eyut33k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 31 Jan 2019 17:15:43 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x0VHFfWi006325 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 31 Jan 2019 17:15:42 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x0VHFf6C010263; Thu, 31 Jan 2019 17:15:41 GMT Received: from [10.209.243.127] (/10.209.243.127) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 31 Jan 2019 09:15:41 -0800 Subject: Re: [PATCH net] rds: fix refcount bug in rds_sock_addref To: Eric Dumazet Cc: "David S . Miller" , netdev , Eric Dumazet , syzbot , Sowmini Varadhan , rds-devel@oss.oracle.com, Cong Wang References: <20190131164710.230590-1-edumazet@google.com> From: Santosh Shilimkar Organization: Oracle Corporation Message-ID: <12b133cc-ae9f-dfde-48fc-4f4ba8b5cdd8@oracle.com> Date: Thu, 31 Jan 2019 09:16:21 -0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190131164710.230590-1-edumazet@google.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9152 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=947 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901310133 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 1/31/2019 8:47 AM, Eric Dumazet wrote: > syzbot was able to catch a bug in rds [1] > > The issue here is that the socket might be found in a hash table > but that its refcount has already be set to 0 by another cpu. > > We need to use refcount_inc_not_zero() to be safe here. > > [1] > > refcount_t: increment on 0; use-after-free. > WARNING: CPU: 1 PID: 23129 at lib/refcount.c:153 refcount_inc_checked lib/refcount.c:153 [inline] > WARNING: CPU: 1 PID: 23129 at lib/refcount.c:153 refcount_inc_checked+0x61/0x70 lib/refcount.c:151 > Kernel panic - not syncing: panic_on_warn set ... > CPU: 1 PID: 23129 Comm: syz-executor3 Not tainted 5.0.0-rc4+ #53 > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 > Call Trace: > __dump_stack lib/dump_stack.c:77 [inline] > dump_stack+0x1db/0x2d0 lib/dump_stack.c:113 > panic+0x2cb/0x65c kernel/panic.c:214 > __warn.cold+0x20/0x48 kernel/panic.c:571 > report_bug+0x263/0x2b0 lib/bug.c:186 > fixup_bug arch/x86/kernel/traps.c:178 [inline] > fixup_bug arch/x86/kernel/traps.c:173 [inline] > do_error_trap+0x11b/0x200 arch/x86/kernel/traps.c:271 > do_invalid_op+0x37/0x50 arch/x86/kernel/traps.c:290 > invalid_op+0x14/0x20 arch/x86/entry/entry_64.S:973 > RIP: 0010:refcount_inc_checked lib/refcount.c:153 [inline] > RIP: 0010:refcount_inc_checked+0x61/0x70 lib/refcount.c:151 > Code: 1d 51 63 c8 06 31 ff 89 de e8 eb 1b f2 fd 84 db 75 dd e8 a2 1a f2 fd 48 c7 c7 60 9f 81 88 c6 05 31 63 c8 06 01 e8 af 65 bb fd <0f> 0b eb c1 90 66 2e 0f 1f 84 00 00 00 00 00 55 48 89 e5 41 54 49 > RSP: 0018:ffff8880a0cbf1e8 EFLAGS: 00010282 > RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffc90006113000 > RDX: 000000000001047d RSI: ffffffff81685776 RDI: 0000000000000005 > RBP: ffff8880a0cbf1f8 R08: ffff888097c9e100 R09: ffffed1015ce5021 > R10: ffffed1015ce5020 R11: ffff8880ae728107 R12: ffff8880723c20c0 > R13: ffff8880723c24b0 R14: dffffc0000000000 R15: ffffed1014197e64 > sock_hold include/net/sock.h:647 [inline] > rds_sock_addref+0x19/0x20 net/rds/af_rds.c:675 > rds_find_bound+0x97c/0x1080 net/rds/bind.c:82 > rds_recv_incoming+0x3be/0x1430 net/rds/recv.c:362 > rds_loop_xmit+0xf3/0x2a0 net/rds/loop.c:96 > rds_send_xmit+0x1355/0x2a10 net/rds/send.c:355 > rds_sendmsg+0x323c/0x44e0 net/rds/send.c:1368 > sock_sendmsg_nosec net/socket.c:621 [inline] > sock_sendmsg+0xdd/0x130 net/socket.c:631 > __sys_sendto+0x387/0x5f0 net/socket.c:1788 > __do_sys_sendto net/socket.c:1800 [inline] > __se_sys_sendto net/socket.c:1796 [inline] > __x64_sys_sendto+0xe1/0x1a0 net/socket.c:1796 > do_syscall_64+0x1a3/0x800 arch/x86/entry/common.c:290 > entry_SYSCALL_64_after_hwframe+0x49/0xbe > RIP: 0033:0x458089 > Code: 6d b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 3b b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 > RSP: 002b:00007fc266df8c78 EFLAGS: 00000246 ORIG_RAX: 000000000000002c > RAX: ffffffffffffffda RBX: 0000000000000006 RCX: 0000000000458089 > RDX: 0000000000000000 RSI: 00000000204b3fff RDI: 0000000000000005 > RBP: 000000000073bf00 R08: 00000000202b4000 R09: 0000000000000010 > R10: 0000000000000000 R11: 0000000000000246 R12: 00007fc266df96d4 > R13: 00000000004c56e4 R14: 00000000004d94a8 R15: 00000000ffffffff > > Fixes: cc4dfb7f70a3 ("rds: fix two RCU related problems") > Signed-off-by: Eric Dumazet > Reported-by: syzbot > Cc: Sowmini Varadhan > Cc: Santosh Shilimkar > Cc: rds-devel@oss.oracle.com > Cc: Cong Wang > --- Looks good. Acked-by: Santosh Shilimkar