Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2372266imm; Thu, 7 Jun 2018 09:31:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJuLYPy5YKDVlw1WravEdoqSa2Uc9lvoVQWp3/tw2c+YyEzpIszzqpBnsi8Ee4cvjWJRDUo X-Received: by 2002:a63:6c83:: with SMTP id h125-v6mr1090602pgc.46.1528389085034; Thu, 07 Jun 2018 09:31:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528389084; cv=none; d=google.com; s=arc-20160816; b=SxDRGSFqQMy+Td0XzbmhSQhWHPr6dSh+BRYxq1ocnyJ2ub0U5mQnLk4UqTNOk5i9eN rpdT+WgTSNo/jGZQi4Xh4wmJyB+g8P9JRMpdUrrccDlz6JEuokPgGOWR9RxV4n2TqwR2 8N8M1kdYRWhimTET9Jb4LiTsQt6yvLrS/gbCP38kRv2P4Kye2PNez5SuMNjV5aoM6Qv3 aKch/p6/Tpc8Tba8y23pmqCB7rbJ+Q5Xk34MP+CEx7nP807x9SJ0GAFfqFVvLDsMRfMG cWqwK6lOJkIEtz/4/SNsMprfs/3ckY7CXSiny2mDqongpWX7YT5DCUo4VfHhe6iUH/HH +fZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=HWrOZ4Ndv4cbFESGUHKhxXXfLHHUerqwB6zihVCh5uU=; b=vFJlKmjA6bP9DRiCztCBPZKi3/T/NUCpEz8gk8ObEp48e9gTdcVrWfJ15TyywzxRog HWgyxQ80jgE+5h7orKsk/NHsz6KMQmLIw/xV+UIqoi6F0FvYq9pcKaxgj/DLeqq3Bg12 RSda6sXMJuA8SwO95YsIpm3/deqoiiv3blrsZ696zPTU3WTKT9JXJZY05Kp3/mWf05oA 1S0DfSj7hj/54yy/fGdk2v1iji6ZStzTHBsIffAjKM0G1YIV7N4wKbEh+4sK1kvEMC99 y0yx7ZuCHraGyqBMgKzWQSpqH/Qh1heCni1eBuzYqJFi6IPqH3vx3kYh61qenfdlp/7m 2sRA== 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 q79-v6si3942932pfk.268.2018.06.07.09.31.10; Thu, 07 Jun 2018 09:31:24 -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 S933200AbeFGOJs (ORCPT + 99 others); Thu, 7 Jun 2018 10:09:48 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:39449 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932734AbeFGOJg (ORCPT ); Thu, 7 Jun 2018 10:09:36 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbM-0005Zv-SG; Thu, 07 Jun 2018 15:09:21 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvbD-0003HW-VY; Thu, 07 Jun 2018 15:09:11 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Leon Romanovsky" , "Jason Gunthorpe" , "" , "Sean Hefty" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 382/410] RDMA/ucma: Fix use-after-free access in ucma_close In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Leon Romanovsky commit ed65a4dc22083e73bac599ded6a262318cad7baf upstream. The error in ucma_create_id() left ctx in the list of contexts belong to ucma file descriptor. The attempt to close this file descriptor causes to use-after-free accesses while iterating over such list. Fixes: 75216638572f ("RDMA/cma: Export rdma cm interface to userspace") Reported-by: Signed-off-by: Leon Romanovsky Reviewed-by: Sean Hefty Signed-off-by: Jason Gunthorpe Signed-off-by: Ben Hutchings --- drivers/infiniband/core/ucma.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -411,6 +411,9 @@ err1: mutex_lock(&mut); idr_remove(&ctx_idr, ctx->id); mutex_unlock(&mut); + mutex_lock(&file->mut); + list_del(&ctx->list); + mutex_unlock(&file->mut); kfree(ctx); return ret; }