Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3894212iob; Tue, 17 May 2022 09:18:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyexpgE+uoQWvjzKduoG13lOIBVoACa9wXPFkDDtiFYuNt+tjwZOsvQl7Pvos9m/09X1AQI X-Received: by 2002:a05:6a00:e0e:b0:50a:cb86:883c with SMTP id bq14-20020a056a000e0e00b0050acb86883cmr23375147pfb.11.1652804329700; Tue, 17 May 2022 09:18:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652804329; cv=none; d=google.com; s=arc-20160816; b=uxdKMzR/5p62rmuVA+YmKcklB876B5HfXKV/c0muuv7xS9tf67pWvd3rk54Zw1mIqC OT9VJptyoYuPW8sREkBC3//CHAU8+0XLEm1NLXBbTPEzHQ5e+5AjarwZliBpUFKdjG92 Bns1F9E316RoaTpnV3lQWoxJLAfY8depD7yGBTp1RIX2lDjAJmu7DVS5hEHCIQW8FWtp +rSALbPFUaE5KoB7g/1JbQobUpABPFGqhbvu27YVAs/TKL4gtQzRhUulSX4o0WHuPG/U ttpZspdntc9o7Fbpp+wHipHBwT+WK0YJS7XcN6RzKUj0vx6wuf2PA/THksZK4CRf/X3p VB+g== 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=yh9KCD3prrmtE3wT14QIp/KiLRwsEOgLjY+dd/br9aM=; b=UlFrpXBZxqZwUeuVzodtIyq0y32FC6VFhf7fupHSWQWG6A3FRpe26Rri/nGAqXtWH7 aQUIaFGsbPwAiJKbLrJ9pIb38YWJF2kqFEk8uRg87VHclxU8V1v+kekIhsfqx89jQR+D zTzxNBXszcbPi48e1qidRUST6+rg4yLCjAgfTHl+xoFj9RZ0WkQBTM+TAJPEdJjzuUag TGW0C9IBFnLaWQ2GQ9DOScnLdNe6Qhkn0nqR26Yq+93ACBpGHWMKwLzfG1VF1pPGE1cu 42oE9EDtwnstr06QdE5Zdl6D3gJIiRaDcK5JfEfVFRARBA291If0uljfLgdDARD9Fm7p 3pcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u05Y8niq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ot11-20020a17090b3b4b00b001d8f9dac4c4si3665633pjb.150.2022.05.17.09.18.36; Tue, 17 May 2022 09:18:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u05Y8niq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345699AbiEQMgw (ORCPT + 99 others); Tue, 17 May 2022 08:36:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232779AbiEQMgu (ORCPT ); Tue, 17 May 2022 08:36:50 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3CE92F007 for ; Tue, 17 May 2022 05:36:46 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id a5so20780355wrp.7 for ; Tue, 17 May 2022 05:36:46 -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=yh9KCD3prrmtE3wT14QIp/KiLRwsEOgLjY+dd/br9aM=; b=u05Y8niqeoVzLfYO77y8i8hMVDuTewNJJbexl4ODRci2203r1K0fKY9bvVdGOB5mn4 bVMrP0r7GneRcIBIMgJD1BTN62sLCJoi+oea9YFo/9f+Wk4USFY06kuEH3e0bBcWSvnA s5zAgVJ5eW3eI9YDtRlTRW451z/7sZcSTX7FMd0tcr8XF58BIpU+VNjFNNTu1wQKLB8R 3c7Yz9FfDQENoh9AtnPWRQNEosyPPMP2G4Bg2Il3d3N8HEvGVNvUmNVw7t8EDUjp1flv WVslgR3Bi4vqE6pZ7Nvzlkd7Ss/ZlRYMrBXaFsjiqgwKJhD+5LJo09Q723axwUxUqpPa AG5Q== 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=yh9KCD3prrmtE3wT14QIp/KiLRwsEOgLjY+dd/br9aM=; b=LvubYrrwIqkGLA3Yf+9XOYgAlix+Y5g8FO3FvSUI/mP7VvGlLsyOnjZ3O/3d0prGbt tqHVbzelXi15qdklGbbOmiMj1f/tGm3dRIrJIrM8uROvnJopKod4SKV//aR5SueyTXlU YzDWXgMyoY0gIcXPwyS8ZnmSUe2dsRgM+u70dr25hq93TQ3DQekE14a6z3YUV9+k5PkC X55ol4yWcgagozcgThKJgxa1X2yCAgxoppnboyyMTIsv3lfLxvjXuO4pyU6S0QcOv3ax /PVyhrNuTQIlh8XSWi5kqf8YW1r7VqEzPsCKMROX5UtAUZT9B3agu68fg3851n7Q63Eb 7Btw== X-Gm-Message-State: AOAM532wGR041CKhftY2ClVgrIMi/2iR5xWE4LDRmNOM0825UtoXkTbQ R09oEo2OrpeMAT3DNVsUJln3gQ== X-Received: by 2002:a5d:470c:0:b0:20d:135:2fb3 with SMTP id y12-20020a5d470c000000b0020d01352fb3mr12009595wrq.559.1652791005419; Tue, 17 May 2022 05:36:45 -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 g2-20020adfa482000000b0020c5253d8dfsm12328385wrb.43.2022.05.17.05.36.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 05:36:44 -0700 (PDT) Date: Tue, 17 May 2022 13:36:43 +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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,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 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). -- Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog