Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp733363pxb; Wed, 6 Oct 2021 14:18:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeQ9HDOCkp1iSj2ctwc58yrkh7sxf59HWDntxSUpuGKUOR39NNqGDGXpEHB0xcjwv3lvDl X-Received: by 2002:a50:e044:: with SMTP id g4mr804247edl.46.1633555090679; Wed, 06 Oct 2021 14:18:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633555090; cv=none; d=google.com; s=arc-20160816; b=qlo2FkXOuMvAdFuf/kt+ORtZ6AiiR+1GNkeZ2EVJpYfj1P9SGFY7OVxLNd2icop0E5 yEhBRxjyiGbA4JOhUpNFq6Bg/Gf78n11TV10isxdZkogupC2+SSc14YSxHL7jkoCW93l BEyzKZS7p9Avj101e6kmkBCDzqq1W/4FzBa0/VCKLB0j1Uv1m67DPck2yS0Sva3jzjFa WwIo80sKovBbnLot76UxNNkpIHq2nTo5ZaM58z8us2p/ijvyXB38+vwJIz8F2zv8h/wW 0HY3xYokDLaG18jC2ocT1Ki5rrT5phJ40vx6UMe5lO3tB+GN0OpJPQIQHmPLZJse68i0 8Hdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Tz+lZtgaSv6daEGtIGuviw7PUifFIlwH/kBioJemo6s=; b=qsA0GDhQ3WdPiaRXBjHbkhIF+amixs4kZFRXpu2OJvSXky+o7TELPR82d20lomUl8u nf14HQsoah6l6p7DXP88CkFJZ5zBwjJmNgHH5PuleTNRCxZ8aYquS/UJVgp5QI5gZWxF XQzOhCd7mwuIR8sJ4EMlaf8OXC4uM61sujbkxvyL18k3y9afbRx9fHiAlSnnv1mICfNO 8GdXr6vQm1D8nRKDKOXE5MjKhE/Y4Yln492+wB0S3z/9M9ruvB9sMeXSsvbjE8bzuI6P EVtjqiDHE+PhJ2xowhqm7pfEpHuRJQAfKOVrHoDLDhDVaHTUkNe8cMqo50uIM68ufK+Q p1Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=f6JKHo3U; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c14si2535986eds.48.2021.10.06.14.17.46; Wed, 06 Oct 2021 14:18:10 -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=@kernel.org header.s=k20201202 header.b=f6JKHo3U; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239625AbhJFVRz (ORCPT + 99 others); Wed, 6 Oct 2021 17:17:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:33820 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239547AbhJFVRy (ORCPT ); Wed, 6 Oct 2021 17:17:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7806C61177; Wed, 6 Oct 2021 21:16:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1633554961; bh=d1ydGKbgRYte60NsablLkoqw6nuD33vqUg6Hkbz6qPs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=f6JKHo3UfDf6EZN08ID/hzvMfVpdeMhuAATIxAjhNlUqzum3FYaguWM8rxAtSJxBz crakWpnqKAxcAZgSutghrkrgXMIwLm1WRkYINRF5O+fT4mNlkyKLALKJph2DxnUzKx B4wgXypWer67HUFEnjJOvpz/vTMjrHDLsWVg9l/j3PkHrMzcc9ReVlT33wfrx64LCm bnnxPi18Fm+/T5U+32bBl3o/TRaiAqnYhZ/Sv2pLW07RS5LcSdcAZ601xaunFOoXWy pAal9ieo1d+IjeBwATlscnHfcndsZk9U96A54wjGnowldvGRHNv4U/sUseyeh2T9LR CCBkaBrOXAhhg== Date: Wed, 6 Oct 2021 14:16:00 -0700 From: Eric Biggers To: Ramji Jiyani Cc: arnd@arndb.de, viro@zeniv.linux.org.uk, bcrl@kvack.org, hch@lst.de, kernel-team@android.com, linux-aio@kvack.org, linux-arch@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, oleg@redhat.com, Jeff Moyer Subject: Re: [PATCH v2] aio: Add support for the POLLFREE Message-ID: References: <20211006195029.532034-1-ramjiyani@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211006195029.532034-1-ramjiyani@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 06, 2021 at 07:50:29PM +0000, Ramji Jiyani wrote: > Commit f5cb779ba163 ("ANDROID: binder: remove waitqueue when thread > exits.") fixed the use-after-free in eventpoll but aio still has the > same issue because it doesn't honor the POLLFREE flag. > > Add support for the POLLFREE flag to force complete iocb inline in > aio_poll_wake(). A thread may use it to signal it's exit and/or request > to cleanup while pending poll request. In this case, aio_poll_wake() > needs to make sure it doesn't keep any reference to the queue entry > before returning from wake to avoid possible use after free via > poll_cancel() path. > > The POLLFREE flag is no more exclusive to the epoll and is being > shared with the aio. Remove comment from poll.h to avoid confusion. > > This fixes a use after free issue between binder thread and aio > interactions in certain sequence of events [1]. > > [1] https://lore.kernel.org/all/CAKUd0B_TCXRY4h1hTztfwWbNSFQqsudDLn2S_28csgWZmZAG3Q@mail.gmail.com/ > > Signed-off-by: Ramji Jiyani > Reviewed-by: Jeff Moyer Can you add Fixes and Cc stable tags to ensure that this fix gets backported? Please refer to Documentation/process/submitting-patches.rst. - Eric