From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B183CC5479D for ; Tue, 10 Jan 2023 01:34:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0D7CE940008; Mon, 9 Jan 2023 20:34:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 088978E0001; Mon, 9 Jan 2023 20:34:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB8AC940008; Mon, 9 Jan 2023 20:34:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id DD1B78E0001 for ; Mon, 9 Jan 2023 20:34:00 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id AB91CC2107 for ; Tue, 10 Jan 2023 01:34:00 +0000 (UTC) X-FDA: 80337168240.26.F6FAD29 Received: from mail-yb1-f177.google.com (mail-yb1-f177.google.com [209.85.219.177]) by imf06.hostedemail.com (Postfix) with ESMTP id 18B4318000D for ; Tue, 10 Jan 2023 01:33:57 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=UL7JuP9Q; spf=pass (imf06.hostedemail.com: domain of surenb@google.com designates 209.85.219.177 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673314438; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=bCQEHkZFU92catxkBEDSkllxhfGBYSOPJ6bS5OX+np4=; b=mlx2looWRU/6pQQ3EYYcVetSbnHo6RCn8B+JUA9ZtfjkEpAqwoNzbrbpVWQydooxbOfWyx pg6l83ewSMjlOJg12rXaCExkGtZbS7eye8WU2KRtxQ8akaU6iygpI0zfxBWVGRiZHSB6zl oWdqnuGikooir91rwhal5Chysu1HKHA= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=UL7JuP9Q; spf=pass (imf06.hostedemail.com: domain of surenb@google.com designates 209.85.219.177 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673314438; a=rsa-sha256; cv=none; b=BWU3hRS7zc5PXrYaZZA9YHLaXMxrIOI23ny60TyWJCCIED9f/SaimhIpPgbKZGtXP8v1BG ZZL5RywRLDFG3X0JESy4ZEfytEnR5cF87J7jrErnOnpqb9oDxN3oo19+n3Gj9QhiDklKM/ POzBZXUPGEKwUQ4WVaP9P0GuwKfQ7Mo= Received: by mail-yb1-f177.google.com with SMTP id 16so10408202ybc.0 for ; Mon, 09 Jan 2023 17:33:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=bCQEHkZFU92catxkBEDSkllxhfGBYSOPJ6bS5OX+np4=; b=UL7JuP9Qd87W93pYEySBGGXP/+5qmGlzT4yaZBTwaELe4YUCPteNRNGqWjcBOqaHB8 a7C2/rl1S6SS5Ie2sNWnfcszK6rVpC0/po53m5swA3G/l6V+7vWsJF57Gnwr/iqkNqv+ PMBqLoOZf3EpNhSmN2sNYOzl9ciKkCPf/OQ8pvLU4vcbFlDAs0bYiTCI3Mm9S3wWtHpJ BKOMvpKZk1eoiRILLlWV8TXFRRYB3PqdPQuM0ANR7NtwBG0HrvpVqnFpUkH57ivZ6Fn7 gRR5GQ6sJNufqc7C0RXdThcL0HDUOyMtyZj3DbDR9tYCmXT/98nFrSA6O+lM1W0DCSiI vPbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bCQEHkZFU92catxkBEDSkllxhfGBYSOPJ6bS5OX+np4=; b=ccRrOuLM0+pwH1nk+bOLJK9rI5y1/37VqBhuy0IhmqsVke/67Uw7KyMss8EliZkMRD Ce8ScJQcdBhMKvhPfYNyIDLe6ISBAjwe0g8zFj1d3uwExTGiK7PX/NFDQkveZVlfWusp 2Tm/IF1QpS+GxjLLu13bvDJZU3UiO6eZczPuKhSL2VrWmiivhlux3UeuCEYflmYkue4F NG9wC5i9q6miCdHc7n7s9I4wrUiTsNQDj67jA7Rw+bzzi0sK1HPxqrfHz9LkdPsEWuAz hvIWYoJDZt23YVrHnZQqRoAZZ6r96Scq5KG1nsoGg4LmH0BxP5cshiQs45qGkSA6T8cF 0zPg== X-Gm-Message-State: AFqh2krJDI/jNOIBwgB3DfKPgNFGCGoYLlw5hQUGVxNPZgw3Cas+kXsO diYzCLYo+fikt4v3F/A1mU4SUza+gvjVDazzl71leQ== X-Google-Smtp-Source: AMrXdXt604IP28HQikzync7eCkkW92FMRQKCM1QxQopQ9ijz0R4RNvliZGAzq2BK311P684yj86ysH/o4zfSWu3r7ls= X-Received: by 2002:a25:fc1:0:b0:7b9:66ba:4421 with SMTP id 184-20020a250fc1000000b007b966ba4421mr1294503ybp.340.1673314437033; Mon, 09 Jan 2023 17:33:57 -0800 (PST) MIME-Version: 1.0 References: <20230107080702.4907-1-hdanton@sina.com> <20230108222548.698721-1-kamatam@amazon.com> <20230108234917.5322-1-hdanton@sina.com> In-Reply-To: <20230108234917.5322-1-hdanton@sina.com> From: Suren Baghdasaryan Date: Mon, 9 Jan 2023 17:33:45 -0800 Message-ID: Subject: Re: another use-after-free in ep_remove_wait_queue() To: Hillf Danton Cc: Munehisa Kamata , hannes@cmpxchg.org, ebiggers@kernel.org, mengcc@amazon.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: bp4zi57hmz4dun61pg6oydb6zakjak7z X-Rspam-User: X-Rspamd-Queue-Id: 18B4318000D X-Rspamd-Server: rspam06 X-HE-Tag: 1673314437-138969 X-HE-Meta: U2FsdGVkX1+Goc5Zfp4K9aghozpL3jaZECN11hH1A0rrdz19LNjMlQKsvaqcxMtblN1dxWyVR16CHEgb+4i8QW7qjXPgUg4z6zdgxtQUMz5vkCtxxWJ4n/LxT77nfFZlBARVD8f3bAQwOnmPOZOPmGGeSRhUD2nDA8UqKWlYimg92d2MQipLoySKnN/+z/80LkQPah6DnlX6mTdJkLTw5tGqIE3bRHxgilLDf/Ftpwj69PE7cK+9CUg7WQE+85lYJ6jMY7Fy1s1VQhC/7GvlYHxjTk7zTZ1COVj9f6LnMZFvvZDgTEatZjWST+oX5N9RQFN5LM2dPnrgfNqyWpwTW4OB9Z/jI7sr3w5rlhmAaMTRQAdNd2IntvJKewHKxYTTl1and6DIm/cAJw9svSVXraL+VJ6g96IbBh4XnN3mAcUwgXk3EcE9Rld3XuMRB07Rd+OaTL5iIUwY3DXDuzc8nSyyEdgDIOf9OgulDmjuI8eZrlAvheF3P/bZZ0DO7INXGDEmKQ77eOvxzTeX7dNTlIx1JFtR61yTag9xiByMr6T+z+C9AEw7kL6vdBO+jo1H1zbCb5JJqMI6sfBI5UG6HK48CSAr22GVsN/I81vs5hCiybi4Csz+0p1dJQo2AhIsBOY4ZoQuc7FbGZEA3FTO49G2GZEKtuf6dATjW/SLPzLO+fseO5rlojAqdasXcavZFlyUbOMxEEy/W33XM9Bt5FKxWwtr0uULXxNNXxUIGPBuFp3LBHReZKBRoZwIAnWK1RQmz6SEEQcofdABXMWrhmNRCD3nkKow+kYjvvtIqMs+HX9loTAy1gdW5DJ60WDMvGnY/t44ynfbWZwfBfCmtUvz003AAPkakwrajD4Iwz9+9rMlpGEwPBEVyVMgmd9/ZX3FUQx/i8+5BTcceaPHbAeG/cHjbuzojUFxFzDOugHunn8iQZU1TL6GviZF6UVDcgmcGdpxtfmLV1J1wYh t/n9ezXr zUNSVTrgaTOGCEO8VLCK4kKyUwIsNB/cqU7Wg0a02CQIHytfKqZaZ0685DQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.009043, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sun, Jan 8, 2023 at 3:49 PM Hillf Danton wrote: > > On 8 Jan 2023 14:25:48 -0800 PM Munehisa Kamata wrote: > > > > That patch survived the repro in my original post, however, the waker > > (rmdir) was getting stuck until a file descriptor of the epoll instance or > > the pressure file got closed. So, if the following modified repro runs > > with the patch, the waker never returns (unless the sleeper gets killed) > > while holding cgroup_mutex. This doesn't seem to be what you expected to > > see with the patch, does it? Even wake_up_all() does not appear to empty > > the queue, but wake_up_pollfree() does. > > Thanks for your testing. And the debugging completes. > > Mind sending a patch with wake_up_pollfree() folded? I finally had some time to look into this issue. I don't think delaying destruction in psi_trigger_destroy() because there are still users of the trigger as Hillf suggested is a good way to go. Before [1] correct trigger destruction was handled using a psi_trigger.refcount. For some reason I thought it's not needed anymore when we placed one-trigger-per-file restriction in that patch, so I removed it. Obviously that was a wrong move, so I think the cleanest way would be to bring back the refcounting. That way the last user of the trigger (either psi_trigger_poll() or psi_fop_release()) will free the trigger. I'll check once more to make sure I did not miss anything and if there are no objections, will post a fix. [1] https://lore.kernel.org/lkml/20220111232309.1786347-1-surenb@google.com/ Thanks, Suren. > > Hillf