Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp452170iob; Wed, 18 May 2022 05:57:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9grommjXN4ipZ8JERTJD9gvA9z28pGPT3797GTGycsQsjmTIhqN/uCaYG/uMfqQ4M4nn4 X-Received: by 2002:a17:902:cf4a:b0:161:64f4:52d8 with SMTP id e10-20020a170902cf4a00b0016164f452d8mr17441582plg.83.1652878625572; Wed, 18 May 2022 05:57:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652878625; cv=none; d=google.com; s=arc-20160816; b=O6H+S68fqq6PRa/8wjPwJFJmCI6zUMgSYHUKBJkPydJJY55mDxFMEbc62UuvulY+9K k6g2FAHuBCX9xCadWQyhInfk6GajOcqCiruo5N9Eft9MuMe5g5re43klPYt5yNqVipyp cyLCbrDbgHOXfrPb8dzd1YMGxgusnwlP082u1LMlekff0xeQTb9G2iKdZx99IfXujWEY 9cyWMsD1/+UzmdcakzDT6Gy7js/CpZUtT0yO2EU+5l3m20tmuu5izn/O9GJEYS77lQEp Ay+j0vGAE7h/l1wkb/XBHpmSqimIncNSDdC6azH1sCFRx9ypUYQkgk28aaH1f3pWUt6s oxRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=Paq8+juUmf29mMyi5gCCd5Y45Od4vCB9lL+wMXjxOSk=; b=mGoxWkHegae54vmZfVQwDw15zTtILn/oQ7v/KwqEjdls1ygbCf+zn4q/rzLDSpoT/w 8W1ada2YFs1lp4iKxsFCYr4YDWGUm/rPmUKLkbFeU4WnOJwc2EwcgXgGY/AHl0I0gbEZ QY2dYJdNqdM3LqWwg+ZToDizoCXY8ouZ2u2ngjLpcKmVuAd5epqw1FX44j4tMl+g4r2V WdqG7orL3xYGYkeFiBbmcP7neGeLag+IBAhzCOEcB1fZcEIf/CyQWXHltLN5o4l0WsYI 2FABwYG5hrltwfiBB2DMVMI0nWtWBR8kTB3T8bAIP2OBuY0rS0EWxgvpx32NN/aLDqEV PELw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20210112.gappssmtp.com header.s=20210112 header.b=DgEoxygY; 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 Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id jj11-20020a170903048b00b0015827ec0073si2389559plb.452.2022.05.18.05.57.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 05:57:05 -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=@kernel-dk.20210112.gappssmtp.com header.s=20210112 header.b=DgEoxygY; 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A6F622C105; Wed, 18 May 2022 05:52:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236949AbiERMwn (ORCPT + 99 others); Wed, 18 May 2022 08:52:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236970AbiERMwk (ORCPT ); Wed, 18 May 2022 08:52:40 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD6582981C for ; Wed, 18 May 2022 05:52:38 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id fw21-20020a17090b129500b001df9f62edd6so2329008pjb.0 for ; Wed, 18 May 2022 05:52:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=Paq8+juUmf29mMyi5gCCd5Y45Od4vCB9lL+wMXjxOSk=; b=DgEoxygYWB0mUsY9mFozlZTqMN1tuXA5NiYKwrlhiQuoZji9hJBt409DoKhAF3kDZJ XhK87gzl7cRiC/OKg3bnjS3P9aXGhniV4dfTuO8p1hgxlaPYU/an6v1MwybqodxZ1TB+ VfIEsurmvcbIzOHFkvmqtTWFZlcNLBWtgpXV/6JUx4Mt+SALlHXjIcrbmuquugOibRSG 99mHOHZwSf5UwXSJgJK86YpditQ4MsAR/ZoGPAx5J9g5fu8kyHvhkO7K2LQB6GHJc6dC t8/kDDs1rcUtX3N6zw7VVbQxBG8IkIXt5UIzHw0ASt3JdALRRQv9xUBCQLvmnvpqU1Gf bCdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=Paq8+juUmf29mMyi5gCCd5Y45Od4vCB9lL+wMXjxOSk=; b=7W4UvXCM9Oo1VrwG3FWvy3a2rJw80NUM30S7NG8iot7t8M7wuAnivVcte6lJbDpQjA yOn+et/reiDrtW4CAfALDUpAHVFj5dG4KcjdqJ2QMZAMILhO4aEf97WAEb2WoN/Zv2dr PestCajGRcmF9tlj5SrRLTkWEcBSaSmhkKB3IOv189JwpO7AU39TbmopaBMvnEL6r7+L EsXecRdhNiBqcxsC6371355QYyI/0l+8J64Ij3hc3gwv2+SEMp0t+QbW9m+nbOv0UE+m uXYUtmAYJRJU6MkR49ev+Syn2HTnPJ9taeaIof1axPmulbx9AVvSWgQIeuzQXT3lyse9 HPrA== X-Gm-Message-State: AOAM533fauUO/l2OjiSQO6V300W9NP73t5d8w4MkhiZGZqioeImLAuW6 Ef/ndzjYH4SMCCZHIULhRqVTZg== X-Received: by 2002:a17:903:22cd:b0:161:be20:577 with SMTP id y13-20020a17090322cd00b00161be200577mr4312482plg.54.1652878358347; Wed, 18 May 2022 05:52:38 -0700 (PDT) Received: from [192.168.1.100] ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id d13-20020a65620d000000b003f61c311e79sm447063pgv.56.2022.05.18.05.52.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 May 2022 05:52:37 -0700 (PDT) Message-ID: Date: Wed, 18 May 2022 06:52:36 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [REPORT] Use-after-free Read in __fdget_raw in v5.10.y Content-Language: en-US To: Lee Jones Cc: Pavel Begunkov , io-uring@vger.kernel.org, linux-kernel@vger.kernel.org References: <97cba3e1-4ef7-0a17-8456-e0787d6702c6@kernel.dk> <3d271554-9ddc-07ad-3ff8-30aba31f8bf2@kernel.dk> From: Jens Axboe In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 5/18/22 6:50 AM, Lee Jones wrote: > On Tue, 17 May 2022, Jens Axboe wrote: > >> On 5/17/22 7:00 AM, Lee Jones wrote: >>> 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. >> >> Can you see if this helps? Untested... > > What base does this apply against please? > > I tried Mainline and v5.10.116 and both failed. It's against 5.10.116, so that's puzzling. Let me double check I sent the right one... -- Jens Axboe