Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1901193ybv; Thu, 6 Feb 2020 11:56:47 -0800 (PST) X-Google-Smtp-Source: APXvYqyN6t7gmfFEc3RyGkUme7dnnU7ZOhje8pp5zOsn+6ZHpexs8dyDc0FU4i+xkmyjlJZ3Eu4J X-Received: by 2002:aca:d502:: with SMTP id m2mr7828278oig.41.1581019006961; Thu, 06 Feb 2020 11:56:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581019006; cv=none; d=google.com; s=arc-20160816; b=F8f+D0K31WifoA1UyIEVVOGLIgDJM3lYxeDSDaj6BLBC4KXLm4YVypVrX0wOvQFwtN 8dVpM+49xT34Z43YGseUDgNKzsnbfjxKXkMduAXHgugmbA080pzO2s88UUf7VrGK0msG s7hC73ee6c2F4+mpFqRAUH1hdoJcI8776O5N9N2fnCOnsOKDX7qvoDDTcVHJDvFYGBSp ciYUvL49xw1tbrwf111WJYRBOZ2l0rITFy3ys7IWddQZOFgBjUCc9HUv48I9g8bJ/Pxu S5fjG6FcENM2IhAZI+SpAYdlinqZ0+vUzLpBGAvD6Yrd1jTpS/yRfR7jM+5ToXOpNkOM Vx3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:dkim-signature; bh=7EJDgXJItKSHtBqDlGpPXjVpKLFySBu/jYXtj6UBSqk=; b=H/4fr2z+u9JaL9CzzdJ87QCsxUghIYoqxHPYAK7js1EDxzuoi0JoYSS6PKLwW7GIQX TPKUe4FFflo5h+Mk+hPkqC6rwlhJKwfepmq2+rEgrUpprxrALfoKVejdRXvyRxtb9TL3 Pg1oek1cq4oX5ItLD0vquPjjC1b2Tl8oyJdQlmNH/DLC5uYwOX4bBFk6ZlVMmSEXEoMI 6Iv4vzywnhHPZ6BFklzRO8ZFAUvJ+NkgOHz5XCZGs+0pVqrMLbjO6WsplRGTBNi/HBZY N6VBy+NQ7z8eG71sLy2LuBV1vIxeO82wPXU57yzwnKKbZJ7w2Q4oVaRErzmETAD+aH3i 2cPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=o2TJ5na9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i194si2741242oib.73.2020.02.06.11.56.33; Thu, 06 Feb 2020 11:56:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=o2TJ5na9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727831AbgBFTzm (ORCPT + 99 others); Thu, 6 Feb 2020 14:55:42 -0500 Received: from mail-io1-f48.google.com ([209.85.166.48]:43048 "EHLO mail-io1-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727479AbgBFTzl (ORCPT ); Thu, 6 Feb 2020 14:55:41 -0500 Received: by mail-io1-f48.google.com with SMTP id n21so7589659ioo.10 for ; Thu, 06 Feb 2020 11:55:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=7EJDgXJItKSHtBqDlGpPXjVpKLFySBu/jYXtj6UBSqk=; b=o2TJ5na94rRJqPrzLey6UhOyaQeCV+fXbL9oXrunqYSqw1pwJlDwE0G22NET61LtcX 71Y43oiTYDi6ldv8WMbqqKkoHJuW46Sb6CMXM1sgTSxOnwduZanEhmT7m7J/SefDAARM WME4XkeUq+Tjzu58vXSPJcs1J/nt7mk8T/Aw8hZHo5geX6yvkdIN0k4KQ3kFAvgFfJXu Tb0rOVdECcmuDt8vO8Dt+F+UW7zAygiLBmZsp75DS4xfoM8xyfxlrWpA1UfRV2j7EFCG PV/p2CV73wg1i6YzpM2OfI0FqGMDtCvk2tfrTvK17Su/oj8ajn6MIeK5YacgEwzw9kD0 2btg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=7EJDgXJItKSHtBqDlGpPXjVpKLFySBu/jYXtj6UBSqk=; b=dMonPL8eW8+y7Xc63f/y8UHWzRMcKWOr+vGPlSnaOod1tphWtzQVF/7qYKFx/tsqSS A3l21q/yUY9oKO2oeLyzO8yaJvxXzbpaduGY+n/DX7JKRm7Q4qSAE1V5wz3RINQvlGuR 87DjqtejAlOLjT7qili46MXD9Du2jGprcCVKpDsYSirJgEcMKiodz1ucXkb3IDM0+nrC 5VhSRlRsh5XoqRjiqiLFJfdLIsSWNjyiFpTJHkSSno/CsXG4+z3n6pFzqTTIuqp0LZ4S Q8TqS6eyC9AEz2Nsm/13Fhwgq+nIqYpFCpTP97imw22upJU7ZQFiY0rqHmqUiHfXo+Ln di3A== X-Gm-Message-State: APjAAAUE+6l4jsx211Owt6MM6AB9W3fCUQD1cDjaRUF7TB688xsmzy8a LQZSHTsyb84XVi0H32o43t3oRw== X-Received: by 2002:a5e:8b03:: with SMTP id g3mr34012728iok.279.1581018939563; Thu, 06 Feb 2020 11:55:39 -0800 (PST) Received: from [192.168.1.159] ([65.144.74.34]) by smtp.gmail.com with ESMTPSA id u10sm282505ilq.1.2020.02.06.11.55.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 Feb 2020 11:55:39 -0800 (PST) Subject: Re: io_uring: io_grab_files() misses taking files->count? To: Kirill Tkhai , LKML , io-uring@vger.kernel.org References: From: Jens Axboe Message-ID: Date: Thu, 6 Feb 2020 12:55:38 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/6/20 9:32 AM, Kirill Tkhai wrote: > Hi, Jens, > > in io_grab_files() we take pointer to current->files without taking > files->count. Later, this files become attached to worker in > io_worker_handle_work() also without any manipulation with counter. > > But files->count is used for different optimizations. Say, in > expand_fdtable() we avoid synchonize_rcu() in case of there is only > files user. In case of there are more users, missing of > synchronize_rcu() is not safe. > > Is this correct? Or maybe there is some hidden logic in io_uring, > which prevents this problem? Say, IORING_OP_OPENAT/CLOSE/ETC can't be > propagated to worker etc... We track requests that grab files on the side, since we can't safely grab a reference to the file table. We could have our own ring fd in the file table, and thus create a circular reference if we incremented files->count here. Looks like we might need a 2nd way to know if we need to use synchronize_rcu() or not, though I need to look into this particular case. -- Jens Axboe