Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp37495ybz; Fri, 24 Apr 2020 11:24:33 -0700 (PDT) X-Google-Smtp-Source: APiQypKSvKwWxnIf0H7rZeGSjkgiNVFrfzh5ahTZ9Clr+hMZuZ4avSjiFgvvv3nImoWSLwRu5qvw X-Received: by 2002:aa7:cc88:: with SMTP id p8mr8584964edt.387.1587752673677; Fri, 24 Apr 2020 11:24:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587752673; cv=none; d=google.com; s=arc-20160816; b=Yhp0DfApoDM6+43SoO/ymqlvmk22JEV7rCFmprmnN5qgnIRZ3gLC5CWY5sG2Bgh25B uq4YiwsuSEuSbbO0GyRgZfZj1oxWeL7Bn9VHuCSujOtwIrWdNrc5NqsMeGQuS3RcT5RV U8OyqgTlIpT8Q5hrXXnl/0/NeUErzfZstI7h9toMyYxfJNsoMneuIDjuJenvAchluJMu hB7W5PvhShaq1D8m9xh/SwLOMvijMmXcvJp8EaOC1fzf/qUUY3tvz/odMjInGN5mbdfz eH71zyBiFl15FeaWGwaQjiGMTktMuvdWGCJHzImKrTJyMy0nzqgnI/OM0hhqQkQwm7Xm xSWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=lhGTjJMhmPbj8xPe+GsSJUkT3nEa8rLgCXmIyP6n+eg=; b=gofdsMTeUCohaOpdzKiOr3dM+Sr5xtAR0e3Fy9Z03cp3zsmHwflNO1HyjATGbRXumQ RrTDE7bdzNRJNRWTteNN5t6skr6x6xnAgD8/N+8cjuAd0d8W5cB8kQ667YVAOAdJRIkD mL6ENEFKvf8h4jq53VG+kYMpDSwKwBY8aKfTsAnuBpnUavya54DWBXeSYxnuoCLlHrMk 34edRfG6f2A6nmUmDfvPj0oFhJeLBUSd/2H9cr0CkUGBL9blQ3y5ZkPWq45XWBSSIagj s8JzRT4pXSKVbqLU+BpTH5gzRpRInM+VzIonMu0rS734RTDl5K9mnksarRrY8cmRUpsq RFUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=XuG0PscT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cm13si3361195edb.48.2020.04.24.11.24.10; Fri, 24 Apr 2020 11:24:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=XuG0PscT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728542AbgDXSW1 (ORCPT + 99 others); Fri, 24 Apr 2020 14:22:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726793AbgDXSW0 (ORCPT ); Fri, 24 Apr 2020 14:22:26 -0400 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C10CC09B048 for ; Fri, 24 Apr 2020 11:22:26 -0700 (PDT) Received: by mail-qt1-x833.google.com with SMTP id k12so8733784qtm.4 for ; Fri, 24 Apr 2020 11:22:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=lhGTjJMhmPbj8xPe+GsSJUkT3nEa8rLgCXmIyP6n+eg=; b=XuG0PscT5Vy9AhQ07hBkyvEkq2yXGGhb2Q+VNmgpLsuJ7Jn0M2LMPyj9Zzoy9THFPj inYepjqYVMhUVsWfMIxeSxAH4oHv9Z2Ireh79/qdLuYDZPBFB8caEnFzj1vOsAc3MFTZ 0h6zrkRJ1KpObaIj8NBryckJewzgHIdBg+IdtoVSId4RZYqjHjC9iV6QNioSaGyopj7S jZ9EpZZGk96mBAYzKH9wfWbhrZ0qLBUMU3lCSy5JdEmNka9lqA98ds6XqZ73xhM6qVrw DQO/roYYut/HjxGTiISog7JZewLaLSZ5gua4Mcf6kciKsqHoi29saNKxmNrb7k71uyS+ XU5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=lhGTjJMhmPbj8xPe+GsSJUkT3nEa8rLgCXmIyP6n+eg=; b=YhwTP00i+TnuBxKP/98OlzIwfWhskF9ENc8mO7j7MtkR2b7hl4gqXYEMRzrN5gnjhZ hr82OFA8MrI8ZdMuuDajODB8cNFvBP0xaj8EkYRGu4H1yB9ppY2F44934yO3X3TKybsB mYlAwDg4rWhkUhphqlj6oE83OxGMxJRS3OyLIJ41S9vZ7hrVfQeOyua3DmlyBC+PPUfZ d/Q9oDUMhwrOlUelB+4Cm57vk2zRQYfmkkYFHd94k0IiZBp7TJe5983Yy11VKPnymmAf MY5FuUXrsVcnoAxlEAA1mmRV2lhWd2tSnUgSCZXo08iUu7huG95fXq16O/M/fqlEPiIq kn/Q== X-Gm-Message-State: AGi0PuZ7UkfTVDc6Mcf3qWiEXUC13KK2D/WzuTWp9tji4vST/LGBqWqA x4ETn5cuqDfKvmWsC6mR1hDwXQ== X-Received: by 2002:ac8:70c8:: with SMTP id g8mr10918555qtp.385.1587752544732; Fri, 24 Apr 2020 11:22:24 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-68-57-212.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.57.212]) by smtp.gmail.com with ESMTPSA id b10sm4334352qtj.30.2020.04.24.11.22.24 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Apr 2020 11:22:24 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1jS2xz-0004Nd-RG; Fri, 24 Apr 2020 15:22:23 -0300 Date: Fri, 24 Apr 2020 15:22:23 -0300 From: Jason Gunthorpe To: Divya Indi Cc: linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, =?utf-8?B?SMOla29u?= Bugge , Kaike Wan , Doug Ledford , Gerd Rausch , Srinivas Eeda , Rama Nichanamatlu Subject: Re: Request for feedback : Possible use-after-free in routing SA query via netlink Message-ID: <20200424182223.GI26002@ziepe.ca> References: <8fbdf10e-3f08-6407-eb0d-a1bf663873c3@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8fbdf10e-3f08-6407-eb0d-a1bf663873c3@oracle.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 24, 2020 at 08:28:09AM -0700, Divya Indi wrote: > If we look at the query, it does not appear to be a valid ib_sa_query. Instead > looks like a pid struct for a process -> Use-after-free situation. > > We could simulate the crash by explicitly introducing a delay in ib_nl_snd_msg with > a sleep. The timer kicks in before ib_nl_send_msg has even sent out the request > and releases the query. We could reproduce the crash with a similar stack trace. > > To summarize - We have a use-after-free possibility here when the timer(ib_nl_request_timeout) > kicks in before ib_nl_snd_msg has completed sending the query out to ibacm via netlink. The > timeout handler ie ib_nl_request_timeout may result in releasing the query while ib_nl_snd_msg > is still accessing query. > > Appreciate your thoughts on the above issue. Your assesment looks right to me. Fixing it will require being able to clearly explain what the lifetime cycle is for ib_sa_query - and what is there today looks like a mess, so I'm not sure what it should be changed into. There is lots of other stuff there that looks really weird, like ib_sa_cancel_query() keeps going even though there are still timers running.. Jason