Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp108157iob; Tue, 17 May 2022 20:27:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpQTsLFuSJHYsZhIbzO0kpKLMRB973sL493fTW2+HsX7/hYGxq2VXNDLFtONjnCf5GPGjY X-Received: by 2002:a17:902:7897:b0:15d:318d:706b with SMTP id q23-20020a170902789700b0015d318d706bmr25014411pll.16.1652844434709; Tue, 17 May 2022 20:27:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652844434; cv=none; d=google.com; s=arc-20160816; b=mQd9CQYPMXJO/IC9iIHnOxE7cT7y+A3KuEVlQpH9b5QlXsd61cjiegYCBqR6cBrHcD ny7QzZi6EiXXksjTj9l5YxqFAB0v09Ttwj55H7yGldCQHnGcbTPjkPgsiaQLSEFHrynq QhNHd9QkdUR9kVxZrJ+qhmbiNmR2+S6PjS3kwh5YzV7JU5AEiH82TQ9PV+BXl0tozjl3 +OiPhuDazGobcspcIlwsKIcuDTDBTJ9wdc8+jrYMlvWx/5xip4OR/3PBoZPcSKl4JmUf 2KTedRJXulHCCpgmmwbeDt2gwWWGaEfFqqMO3TBB2ULDLzGQORQALigmOwUwwFgHMHya CuVw== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=hTDpAt4z3gikC5fIZlVTEXyjKubj5mCSOIyJGV5bOEk=; b=MX7FjlM59CljkcBni/2oCId0vYwAe3t2zu2vi1R9cksACPUjdXcY27ipDWYmsEpZsH fHiQGOHRpUuWfp1h4EGjcP+L3Fn2+9bQ6fW9E/csmJ2aO1sQz0rnCJ9DYGEDuPjK/3VB yUbHf6w5+nQXiYnO+vj4AeyCcM5d4VBwlFw8Jk433St1RoRz/+1ZQexGUibTLZbJD/u+ cWaX2hcWU4fyUuEbGi0ZkZP5RqnX6BXsmWRbn5MwtBa19zfjhdU/leH+MwHc5mVtPsuu XbK922kjALrkMLltJWgPsPT+drazuf+J9/OefvTB/zBNYByhnzbYzDe0GIj+svFC7MwB 0HZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TwKRGMXy; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id y15-20020a17090322cf00b001567a9b37d2si1491919plg.62.2022.05.17.20.27.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 20:27:14 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TwKRGMXy; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 846CF69B6C; Tue, 17 May 2022 20:22:32 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347125AbiEQNCp (ORCPT + 99 others); Tue, 17 May 2022 09:02:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347726AbiEQNBq (ORCPT ); Tue, 17 May 2022 09:01:46 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3539D4EF50 for ; Tue, 17 May 2022 06:00:21 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id o12-20020a1c4d0c000000b00393fbe2973dso1358317wmh.2 for ; Tue, 17 May 2022 06:00:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=hTDpAt4z3gikC5fIZlVTEXyjKubj5mCSOIyJGV5bOEk=; b=TwKRGMXyAsKdMp+OhP41DTK6iodN5iWX+XUimZ2fL7iC4A3XCMFvGEy9/Mu144KfpG ExhbJywxtpWcJskyeb2Mm2lB7C5uxBUojTJpZaGgAPUGIx45cd46zP32S9ikVWfUnKZv mQ85HvydKtt+14xSujVuxAUGqjzHTG09j3CvUmkV0RfMOomKbiI8KPr+uoQj19+LvLk2 OW7FcjaiAgTTUZvuZs5zQW8y2Jy/CZP0ysmj0uiHBKc4GLvLHW/RYg30jMRbB8WX6zN7 cLz2SsEj+UWriGMEZQ2mm9Pkm83vFH99B9l0fIimP8vBRAwncNMpb6uW84WbktUzG/xq 4A5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=hTDpAt4z3gikC5fIZlVTEXyjKubj5mCSOIyJGV5bOEk=; b=j52JGDRQul6/lXACG5n3jFVd6b6DDcandifxePsidO4J4fEBnEl2IwKZ6WAQpohK1s L5Wbn4dF/p7SBLODAcx8JAcFHe5Zj493GTFd8oaM+xZuQDcLnx7LFhLqZHTZ2h0+gXXR obG3SJSXfOxruluSaoQ9Hd+ExAeqSjDEKpQuQFvFnl+Ma2vJZrKzpwY349tLT74OlBQ2 4j1A0ZWo+/oVhQ83TSr26yHF4cHdPj+ibxYo2DMrU3/9G04t7PfGOrzMiQsapUtjSJio IgwkbWVmP6R/8Wps73OyNWbbcNudvhkjutP+/dRD4c0ToC9EJLqyuazR4sPhGZHi2AF4 thng== X-Gm-Message-State: AOAM531TrodWJJC2OK8PqgpN4GmNcW61nzjwnT3yCqZydbruyYZ8py3e huxMlqFM9u1Cod5//lbT38SLEQ== X-Received: by 2002:a05:600c:3798:b0:394:454a:df74 with SMTP id o24-20020a05600c379800b00394454adf74mr32307755wmr.174.1652792419769; Tue, 17 May 2022 06:00:19 -0700 (PDT) Received: from google.com (cpc155339-bagu17-2-0-cust87.1-3.cable.virginm.net. [86.27.177.88]) by smtp.gmail.com with ESMTPSA id n6-20020a05600c500600b00395b809dfd3sm1905650wmr.12.2022.05.17.06.00.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 06:00:19 -0700 (PDT) Date: Tue, 17 May 2022 14:00:17 +0100 From: Lee Jones To: Jens Axboe Cc: Pavel Begunkov , io-uring@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [REPORT] Use-after-free Read in __fdget_raw in v5.10.y Message-ID: References: <97cba3e1-4ef7-0a17-8456-e0787d6702c6@kernel.dk> <3d271554-9ddc-07ad-3ff8-30aba31f8bf2@kernel.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3d271554-9ddc-07ad-3ff8-30aba31f8bf2@kernel.dk> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 17 May 2022, Jens Axboe wrote: > On 5/17/22 6:36 AM, Lee Jones wrote: > > On Tue, 17 May 2022, Jens Axboe wrote: > > > >> On 5/17/22 6:24 AM, Lee Jones wrote: > >>> On Tue, 17 May 2022, Jens Axboe wrote: > >>> > >>>> On 5/17/22 5:41 AM, Lee Jones wrote: > >>>>> Good afternoon Jens, Pavel, et al., > >>>>> > >>>>> Not sure if you are presently aware, but there appears to be a > >>>>> use-after-free issue affecting the io_uring worker driver (fs/io-wq.c) > >>>>> in Stable v5.10.y. > >>>>> > >>>>> The full sysbot report can be seen below [0]. > >>>>> > >>>>> The C-reproducer has been placed below that [1]. > >>>>> > >>>>> I had great success running this reproducer in an infinite loop. > >>>>> > >>>>> My colleague reverse-bisected the fixing commit to: > >>>>> > >>>>> commit fb3a1f6c745ccd896afadf6e2d6f073e871d38ba > >>>>> Author: Jens Axboe > >>>>> Date: Fri Feb 26 09:47:20 2021 -0700 > >>>>> > >>>>> io-wq: have manager wait for all workers to exit > >>>>> > >>>>> Instead of having to wait separately on workers and manager, just have > >>>>> the manager wait on the workers. We use an atomic_t for the reference > >>>>> here, as we need to start at 0 and allow increment from that. Since the > >>>>> number of workers is naturally capped by the allowed nr of processes, > >>>>> and that uses an int, there is no risk of overflow. > >>>>> > >>>>> Signed-off-by: Jens Axboe > >>>>> > >>>>> fs/io-wq.c | 30 ++++++++++++++++++++++-------- > >>>>> 1 file changed, 22 insertions(+), 8 deletions(-) > >>>> > >>>> Does this fix it: > >>>> > >>>> commit 886d0137f104a440d9dfa1d16efc1db06c9a2c02 > >>>> Author: Jens Axboe > >>>> Date: Fri Mar 5 12:59:30 2021 -0700 > >>>> > >>>> io-wq: fix race in freeing 'wq' and worker access > >>>> > >>>> Looks like it didn't make it into 5.10-stable, but we can certainly > >>>> rectify that. > >>> > >>> Thanks for your quick response Jens. > >>> > >>> This patch doesn't apply cleanly to v5.10.y. > >> > >> This is probably why it never made it into 5.10-stable :-/ > > > > Right. It doesn't apply at all unfortunately. > > > >>> I'll have a go at back-porting it. Please bear with me. > >> > >> Let me know if you into issues with that and I can help out. > > > > I think the dependency list is too big. > > > > Too much has changed that was never back-ported. > > > > Actually the list of patches pertaining to fs/io-wq.c alone isn't so > > bad, I did start to back-port them all but some of the big ones have > > fs/io_uring.c changes incorporated and that list is huge (256 patches > > from v5.10 to the fixing patch mentioned above). > > The problem is that 5.12 went to the new worker setup, and this patch > landed after that even though it also applies to the pre-native workers. > Hence the dependency chain isn't really as long as it seems, probably > just a few patches backporting the change references and completions. > > I'll take a look this afternoon. Thanks Jens. I really appreciate it. -- Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog