Received: by 10.192.165.156 with SMTP id m28csp51636imm; Tue, 10 Apr 2018 16:11:45 -0700 (PDT) X-Google-Smtp-Source: AIpwx49YnpaROPXLmQTMebmagn75PY0bouTpXOf4ytLrr3EW+r+QtTZ9qAYSq6QrWI5utHWSMIXB X-Received: by 2002:a17:902:362:: with SMTP id 89-v6mr2387396pld.270.1523401904988; Tue, 10 Apr 2018 16:11:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523401904; cv=none; d=google.com; s=arc-20160816; b=u94OmdTeEtLvsbHIIG0HJFPmdPMTd9FFFux9oXlPpnxjsB+WbXTayhehYez5zaPxqq 6WFH/+86RimFrzBLs3XswV1kURPu2LaZactdZVn87E3EitHjx4ymkZyB0UeEskTVtbte +Hu6zX9R2rZO0bGHJP3A2x3yqpZbkhA3IdeAE5qGdx91SBdhkwwGcXHK/fdwHBSu7AIc aozD5whK67wL/X+iP0Af++zEiSzi65Uo6ppHufwr8lJsxY4eBNYmCWy3+mBA1+EMUqKC h+TeQsIt3EK0h9bhzxB3KrFWa74juiow/VK/Y7ZXPB7p//qmaAstkZXX8v4u/rI2VPpD s9Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Vt2xzBvWVwBF9k6alg/+OXs1eN6/7o/ZL/alQHXbwt4=; b=RYjOtetRaOc+MUD9Dzb1Id7FA8TrZosJP3qXTS4Wzu/NMNIPiCtZ0MLKHhSh3gZoQc Ba5Fr9KSGS9e+dAT4ACudYNZelQs0Dt6Hb+3pUsHHwiMfgNoG1i9dIF/ODQWPrziYSIC scHqT2DrjQ82L1J9Hw+sPyxUEibaXtL2VoliJ7Sfys86lyuCQk4X8qywwQHh3blyP/4c 6qXwKPg6BB54IbM+WT3bHneK3UX4kt4+V+QtDECZ6KaCYDzwCUioG/1wAl3H6xwW++ie R3+lalcDgepBW3YypMW0bK3EYSIDajLQXTuW6dswzWWe/4QcKcxWk2jBPSmH0QgTC2+1 dfHA== 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 b61-v6si3585592plc.500.2018.04.10.16.11.08; Tue, 10 Apr 2018 16:11:44 -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; 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 S1755402AbeDJWeO (ORCPT + 99 others); Tue, 10 Apr 2018 18:34:14 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:41664 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755349AbeDJWeL (ORCPT ); Tue, 10 Apr 2018 18:34:11 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 27451CDB; Tue, 10 Apr 2018 22:34:11 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sowmini Varadhan , Santosh Shilimkar , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 015/138] rds; Reset rs->rs_bound_addr in rds_add_bound() failure path Date: Wed, 11 Apr 2018 00:23:25 +0200 Message-Id: <20180410212903.899344475@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212902.121524696@linuxfoundation.org> References: <20180410212902.121524696@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sowmini Varadhan [ Upstream commit 7ae0c649c47f1c5d2db8cee6dd75855970af1669 ] If the rds_sock is not added to the bind_hash_table, we must reset rs_bound_addr so that rds_remove_bound will not trip on this rds_sock. rds_add_bound() does a rds_sock_put() in this failure path, so failing to reset rs_bound_addr will result in a socket refcount bug, and will trigger a WARN_ON with the stack shown below when the application subsequently tries to close the PF_RDS socket. WARNING: CPU: 20 PID: 19499 at net/rds/af_rds.c:496 \ rds_sock_destruct+0x15/0x30 [rds] : __sk_destruct+0x21/0x190 rds_remove_bound.part.13+0xb6/0x140 [rds] rds_release+0x71/0x120 [rds] sock_release+0x1a/0x70 sock_close+0xe/0x20 __fput+0xd5/0x210 task_work_run+0x82/0xa0 do_exit+0x2ce/0xb30 ? syscall_trace_enter+0x1cc/0x2b0 do_group_exit+0x39/0xa0 SyS_exit_group+0x10/0x10 do_syscall_64+0x61/0x1a0 Signed-off-by: Sowmini Varadhan Acked-by: Santosh Shilimkar Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- net/rds/bind.c | 1 + 1 file changed, 1 insertion(+) --- a/net/rds/bind.c +++ b/net/rds/bind.c @@ -114,6 +114,7 @@ static int rds_add_bound(struct rds_sock rs, &addr, (int)ntohs(*port)); break; } else { + rs->rs_bound_addr = 0; rds_sock_put(rs); ret = -ENOMEM; break;