Received: by 10.192.165.156 with SMTP id m28csp21072imm; Tue, 10 Apr 2018 15:32:19 -0700 (PDT) X-Google-Smtp-Source: AIpwx490b4Ml4tQEeFOk0W/VlV00WmPuAbZBeWCSInAPgG0X/KdSPtuYbNclWl5x87NV4VVsL2JH X-Received: by 10.99.104.131 with SMTP id d125mr1595521pgc.9.1523399539749; Tue, 10 Apr 2018 15:32:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523399539; cv=none; d=google.com; s=arc-20160816; b=bYf0EOSL3PD2NhTnDdUQlwuJmaGLyeUlBWWwtkReogscD7noDgic3OuiueuGijjJQN d3gyIM9j3MZOwx9W/U9SNbLMLynRNtNyPEyKz8P396NDeuaCbGQ8bLR9WSm5mpywWtNJ sCKBIuoeMR+HWPBUfzlnTTCxZ7XzAlzfVKfOBT5V1+kiSV2XW7325BDK8yuyXHrrYCMN BfGBt4r97OQ6TCA9kDeUnL3lLUggJYXTzyzMU8u7JjwOJIB+yIK3kJb6qT/piRtno8+i uMxR2xNVKuacWS1fFFl2TkI7v6cyE8w4QwQa9qpu9CM8Wx2RhWH//GvCukgg+B8Hy9yj 1tgA== 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=kMidTX5tB7RhQZtrYEdzjHRz0l5ung1M/5+vHx1Vk74=; b=I/lGW7ymYtIgsKE7i+PiO31gI719r7Qedl/aDILfO3kzleodmAAl3S7DXUZ99C/npE t/Qlh3gg8leqdt2eKVId57UdLHCXpTjOBzc/cXe+WRU6BRKshzErZkkXweoIOm0YWePV KbCEn6jnQR+jgYC/NDDLXNyk2YG8hurmSHU3dqJBQ0QIx2FUBZh4zWHKrM4Vl5SQezD8 BxVy+J8HmIfA+7M6YFhHNOiSW/h6OVn3YkgTnbJI/P03bm3YhbQRb2BvEZ9AwK1y0isB XbULBFrqxjMqLkHkpMCSFLahttNpKWg0oFSQkzCMTKghUmTL9+o1q2mfopLeir7g54iZ Lznw== 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 d9si2348479pgo.687.2018.04.10.15.31.43; Tue, 10 Apr 2018 15:32:19 -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 S1753630AbeDJW1U (ORCPT + 99 others); Tue, 10 Apr 2018 18:27:20 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37810 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751882AbeDJW1R (ORCPT ); Tue, 10 Apr 2018 18:27:17 -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 0EC27CC4; Tue, 10 Apr 2018 22:27:16 +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.15 017/168] rds; Reset rs->rs_bound_addr in rds_add_bound() failure path Date: Wed, 11 Apr 2018 00:22:39 +0200 Message-Id: <20180410212800.949934911@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212800.144079021@linuxfoundation.org> References: <20180410212800.144079021@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.15-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;