Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1210937ybh; Thu, 16 Jul 2020 06:20:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUthKqHJMmTPFydGYILcW+r0OmLlY+ycUaF9TzgkNW4z13ifXPWjgn6B3ywIFV6tOVn6Uv X-Received: by 2002:a50:8a62:: with SMTP id i89mr4556065edi.324.1594905649671; Thu, 16 Jul 2020 06:20:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594905649; cv=none; d=google.com; s=arc-20160816; b=UXQetxSWa7gQTnSuCwZ8HNOjL2dG737CcF0t5IISt90O81d/NYpAPfH8BLmqm5ohcV 6g4msDGlbj8XJSHxybp05eTIgBHYQ5AJKsnAUs3W/mVT2tS55nFla/R/6v76wa+eGn9K eLDgiH1GzK9alVOSYKUaBiHHRWg1NxzBzOB6PEFi3FzjnH3VGpGUf2+LEJR9dwnHUFSy ts0/NGssbPMyDsQNzltkwNzZwPIzSaVmGDZdva9kHMMMsfS+D0kC5AN+rXIvPYV4COib fqallMg9DHBgHiUxGyghAaMGHPjwCrxV2t5WHSYmBlV7LhP2VjdweR1rCLbcwLYBccPi Ggqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=WEQiCBMMUNKEUFHyzcb5Rpc/CbMmuXqhvIERsytx/G8=; b=SjuSFvFP03D8vXXG8xOn6pqDD/ZfqALMg4fozBDwBOnGbZzG3Q5QACdeNzmZooiYnL KLMT/GdWzSIwn/h2ZjpV7yChu+6GIaxs56+7S9NvYa4hj/RisO+x+4cuZiqb8G+/nS2x RPJwmJA2oHJfqDdL+nV6N7D2zsNTd5NuWz3AWrl1AoxYyvyBm84GB6XnyCmudSdwQoAA p+trvXa0OXVGbyKEb82QrOrcTpxwEdj3oj6wPwbrzs+IBS1ikwAXaqg+KgF1mCUZuTH/ kQfNmunxh6o0E7+rzPcaacQQSEI3/MnaDC3Yw146uBafQ5UfSVCkXrE8i55hUqGb1Lyp OFew== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=EkZKARTO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mb18si3359304ejb.384.2020.07.16.06.20.26; Thu, 16 Jul 2020 06:20:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=EkZKARTO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728724AbgGPNTf (ORCPT + 99 others); Thu, 16 Jul 2020 09:19:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726986AbgGPNTf (ORCPT ); Thu, 16 Jul 2020 09:19:35 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE501C061755; Thu, 16 Jul 2020 06:19:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=WEQiCBMMUNKEUFHyzcb5Rpc/CbMmuXqhvIERsytx/G8=; b=EkZKARTO1n+Jc8mgTGW8iuFXhb thHBz9J+4zMmxQpyDabGDoVmIS+aKFLPIgfIr793sfNEChsxhi/PN5y1eigH5phu3iGPFbzJGpeqR oWY7QtkQtoHsfTCa+LyOhMgJBBXOWi1Htd4HpsmzuBTke/S9skePv4Ac7Tw7BVWdbB8XfZeg9HBQT 1zvYZN/DZ42PisgHb9EBnmON5XGdXsQUJlUcQwT09HE1uBcvmxB4orvpi1CAg3ZbVeVzrEKrOWRt6 tnP/Kpk4N0G45HJtUvYoZbiROd/+yKrns8So7a2yQj6IhynArheTfWxH+5ko4nBboUktV8FLikk5X otmiI6GQ==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jw3nN-0003AX-4f; Thu, 16 Jul 2020 13:19:29 +0000 Date: Thu, 16 Jul 2020 14:19:29 +0100 From: Matthew Wilcox To: Eric Biggers Cc: Nicholas Piggin , Dave Chinner , akpm@linux-foundation.org, Marco Elver , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, "Paul E. McKenney" , syzbot , syzkaller-bugs@googlegroups.com, Will Deacon Subject: Re: KCSAN: data-race in generic_file_buffered_read / generic_file_buffered_read Message-ID: <20200716131929.GL12769@casper.infradead.org> References: <0000000000004a4d6505aa7c688a@google.com> <20200715152912.GA2209203@elver.google.com> <20200715163256.GB1167@sol.localdomain> <20200715234203.GK5369@dread.disaster.area> <20200716030357.GE1167@sol.localdomain> <1594880070.49b50i0a1p.astroid@bobo.none> <20200716065454.GI1167@sol.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200716065454.GI1167@sol.localdomain> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 15, 2020 at 11:54:54PM -0700, Eric Biggers wrote: > > >> > Concurrent reads on the same file descriptor are allowed. Not with sys_read(), > > >> > as that implicitly uses the file position. But it's allowed with sys_pread(), > > >> > and also with sys_sendfile() which is the case syzbot is reporting here. > > >> > > >> Concurrent read()s are fine, they'll just read from the same offset. > > >> > > > > > > Actually the VFS serializes concurrent read()'s on the same fd, at least for > > > regular files. > > > > Hmm, where? > > It's serialized by file->f_pos_lock. See fdget_pos(). What if we trylock either f_lock or f_pos_lock for readahead and just skip all the readahead code if it's already taken? I'd suggest that if there are two readers using the same struct file, this is probably not a workload that benefits greatly from readahead.