Received: by 2002:ac8:760c:0:b0:40f:fb00:664b with SMTP id t12csp924480qtq; Thu, 14 Sep 2023 22:37:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJ/jxv3iyUSZ0k63kWhSdE/FAv8v8C0OaE3628oDnKwtylyXKAuPIPbsv86MBD0JfL76IC X-Received: by 2002:a05:6a20:5489:b0:14d:9938:735f with SMTP id i9-20020a056a20548900b0014d9938735fmr1023978pzk.17.1694756230519; Thu, 14 Sep 2023 22:37:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694756230; cv=none; d=google.com; s=arc-20160816; b=SCwgq/vI+ski4y1AnJkNqUcU2wosif0H2INmCU51BvGBQ7T689zoJiCsSS7/YBlu1s YJ50U/L730BzSJWsnEvK73f2xbNuBgDH5DTW3KFpwLSjXA/m9SzALAz4I3+hho/c1Wlq XpW6m0viYVhxEXC7igVep08OeONIMFx+rQWRRLxz6eXR7lgOsM8Y0TFgemUc7DHWHYfc 4ScxuIfuE3+4nbqdn2lML6nCHLNp2/pewXeeC8XYJeUciT+uDe9Ufh7QLvDJSS4sXGKd oUrc8HBY/lSKu4X78VdlmBQOastpFhEZhcayJaZXDxWro7YIJBTvpelc6sRGrPVTN1BB fheg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=I3lVrKOEFS16oa3zNmxYsrE3iBnyZ+tsV6wUnHz2diY=; fh=1+1UUkf0g8nwdqNMe/doC8TkPa6tB0FSDjp4j4oIwL8=; b=q8glS5K6RVZpMtQ4XELZA3cOs4imFiMRspGUyCYn5PhGZPis2b5wpzfdy9sv2WwpQA 82lWo98xVn7pimqjNBM7fdovZy1cY5chOa36fKxGqQL2GjlTNCaUNpMK079P8MTrvOdq fIThpbunL7YVEeM9Rg348WhHLAGxZ/cl+lPzFxqg5LWXTvoAnnuc7HsNegr+ePJHb4Hs PycH8Dg+Mg3/ibcDD9GZ0lxik6El4mMAwnsviDK792WFhEhCRvQESNu31LsUb3+Rvmeg 0lhcX65fL3JHduJYo2LSJdLvYp8XyQr5htEFNANJN8+oeqB65AzdRngkBTJC9T+wBWrV dy7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=nj++XJTK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id a3-20020a056a000c8300b0068fea05ecd7si2791921pfv.164.2023.09.14.22.37.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 22:37:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=nj++XJTK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 34ED9802C65C; Thu, 14 Sep 2023 06:26:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235397AbjINN0b (ORCPT + 99 others); Thu, 14 Sep 2023 09:26:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238492AbjINN03 (ORCPT ); Thu, 14 Sep 2023 09:26:29 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B46E1BEF for ; Thu, 14 Sep 2023 06:26:25 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-501bd6f7d11so1594670e87.1 for ; Thu, 14 Sep 2023 06:26:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694697983; x=1695302783; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=I3lVrKOEFS16oa3zNmxYsrE3iBnyZ+tsV6wUnHz2diY=; b=nj++XJTKTIHaw4JcdNmZsRQBmxOuW8lRmFNuqaUrBwIa1UpDbEx+us2KobBHIzlozT MoiFZRLH7JGqFp7jzZMjib02oab+gV2gvAcDiOlAgxYCGa9I6Euy3haMjOqxO5ZOBzD6 x9s+yDAPyP+jB6r6drEC5Sr7NzucvC77HkNAI7eiGnOe/rD1usCv2ij6fOFDIA9MiXD2 CxoZB5eDE+H5l6//C4RdhSXIO8yC/Np46+EEC9hTTopONjyKWJxcakBq7WmK3jrOfpnQ nngkFQb5CSC0/T0rO3GxHRJjQYMCTVy6JdKAxuQ6yGAqAaXkMDxqMT4JG95YuxNXv2QY fOxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694697983; x=1695302783; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=I3lVrKOEFS16oa3zNmxYsrE3iBnyZ+tsV6wUnHz2diY=; b=lxM3II867iLDfrsvhTenspYgKEutQRII2V1B0uqRolZgXzNZ9+7Y7/l8BW52pz9kqL ABVRRyVzfK1l//HozTHroZdr+fEC/JWw4hoUz8EZYVhM+cjhDxtRgjzlAPtnVwDk95A3 Ca2SroafVNgey4+8GzffmMDepi3SX4SM/CWExSwSp30RmAgyJRRoxjmC71Nu4QrKmOBf dMBz4WZVifd6CT5KhokycoG+k/tCNH00+2oPKVufsUn5EYvZ+uf4cCMX/c2l+bAeOD/q HphDiFTIDVaHWlvF8CZpSkut6ZeT2WC9dftMVnKB7GyWtErc61gBjD8PARt+q4ODSWDc jcuw== X-Gm-Message-State: AOJu0Yy46CSrz9jBaOK+oLih87xtmye07pRpzdWpL/9c4pcH9FIlkzgW nJHw/xG7Hkvu03rjC1epVfZBnBPlDUQHLF/26JCqcA== X-Received: by 2002:a19:2d52:0:b0:500:aaea:1494 with SMTP id t18-20020a192d52000000b00500aaea1494mr3908045lft.41.1694697983468; Thu, 14 Sep 2023 06:26:23 -0700 (PDT) MIME-Version: 1.0 References: <000000000000fc6ba706053be013@google.com> <4e400095-7205-883b-c8fd-4aa95a1b6423@gmail.com> In-Reply-To: From: Marco Elver Date: Thu, 14 Sep 2023 15:25:45 +0200 Message-ID: Subject: Re: [syzbot] [io-uring?] KCSAN: data-race in io_wq_activate_free_worker / io_wq_worker_running To: Pavel Begunkov Cc: syzbot , axboe@kernel.dk, io-uring@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 14 Sep 2023 06:26:33 -0700 (PDT) On Thu, 14 Sept 2023 at 15:11, Pavel Begunkov wrote: > > On 9/13/23 14:07, Marco Elver wrote: > > On Wed, 13 Sept 2023 at 14:13, Pavel Begunkov wrote: > >> > >> On 9/13/23 12:29, syzbot wrote: > >>> Hello, > >>> > >>> syzbot found the following issue on: > >>> > >>> HEAD commit: f97e18a3f2fb Merge tag 'gpio-updates-for-v6.6' of git://gi.. > >>> git tree: upstream > >>> console output: https://syzkaller.appspot.com/x/log.txt?x=12864667a80000 > >>> kernel config: https://syzkaller.appspot.com/x/.config?x=fe440f256d065d3b > >>> dashboard link: https://syzkaller.appspot.com/bug?extid=a36975231499dc24df44 > >>> compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40 > >>> > >>> Unfortunately, I don't have any reproducer for this issue yet. > >>> > >>> Downloadable assets: > >>> disk image: https://storage.googleapis.com/syzbot-assets/b1781aaff038/disk-f97e18a3.raw.xz > >>> vmlinux: https://storage.googleapis.com/syzbot-assets/5b915468fd6d/vmlinux-f97e18a3.xz > >>> kernel image: https://storage.googleapis.com/syzbot-assets/abc8ece931f3/bzImage-f97e18a3.xz > >>> > >>> IMPORTANT: if you fix the issue, please add the following tag to the commit: > >>> Reported-by: syzbot+a36975231499dc24df44@syzkaller.appspotmail.com > >>> > >>> ================================================================== > >>> BUG: KCSAN: data-race in io_wq_activate_free_worker / io_wq_worker_running > >>> > >>> write to 0xffff888127f736c4 of 4 bytes by task 4731 on cpu 1: > >>> io_wq_worker_running+0x64/0xa0 io_uring/io-wq.c:668 > >>> schedule_timeout+0xcc/0x230 kernel/time/timer.c:2167 > >>> io_wq_worker+0x4b2/0x840 io_uring/io-wq.c:633 > >>> ret_from_fork+0x2e/0x40 arch/x86/kernel/process.c:145 > >>> ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304 > >>> > >>> read to 0xffff888127f736c4 of 4 bytes by task 4719 on cpu 0: > >>> io_wq_get_acct io_uring/io-wq.c:168 [inline] > >>> io_wq_activate_free_worker+0xfa/0x280 io_uring/io-wq.c:267 > >>> io_wq_enqueue+0x262/0x450 io_uring/io-wq.c:914 > >> > >> 1) the worst case scenario we'll choose a wrong type of > >> worker, which is inconsequential. > >> > >> 2) we're changing the IO_WORKER_F_RUNNING bit, but checking > >> for IO_WORKER_F_BOUND. The latter one is set at the very > >> beginning, it would require compiler to be super inventive > >> to actually hit the problem. > >> > >> I don't believe it's a problem, but it'll nice to attribute > >> it properly, READ_ONCE?, or split IO_WORKER_F_BOUND out into > >> a separate field. > > > > It's a simple bit flag set & read, I'd go for READ_ONCE() (and > > WRITE_ONCE() - but up to you, these bitflag sets & reads have been ok > > with just the READ_ONCE(), and KCSAN currently doesn't care if there's > > a WRITE_ONCE() or not). > > > >> value changed: 0x0000000d -> 0x0000000b > > > > This is interesting though - it says that it observed 2 bits being > > flipped. We don't see where IO_WORKER_F_FREE was unset though. > > __io_worker_busy() clears it, should be it. I assume syz just > missed another false data race with this one. After init only > the worker thread should be changing the flags AFAIR The data races reported are very real, i.e. it only reports if it actually observes _real_ concurrency. I guess the question is if these are benign or not. If benign, you can choose to annotate with READ/WRITE_ONCE [1], data_race, or leave as is (ignoring this report should not make it re-report any time soon). [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/memory-model/Documentation/access-marking.txt