Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp250678pxb; Mon, 25 Oct 2021 07:37:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsuog5mF1EjnCePCuf0AoBj01xcie4EFR2yq1QUFycQkhFKfQAm5ek8v7LDZWpjdYm+tGh X-Received: by 2002:a17:902:8bc4:b029:12b:8470:e29e with SMTP id r4-20020a1709028bc4b029012b8470e29emr16799712plo.2.1635172669801; Mon, 25 Oct 2021 07:37:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635172669; cv=none; d=google.com; s=arc-20160816; b=u+TyVJjd+tzhcB2q9u5AFa4BonFeKv8HybQSCPA9ltwigXIbTie+h9XrjLSWJc9Fpg t2xHSEpdBkcVgUPXT+pn40kVxnXzqGTFVpSvM+hUu9+Rl8gXrsqOZLHVLL5dUSkrLNmL J5ywpR6jU5jJgliHI+yBZESWZZUXyqBrTfAOup8jpl3MdWSFKJBvvW4vmGaWPemLaXNo OoJJXTGaHT0Y9wribVOH+MVfZY+2GVvNprDGQCOTAxciV6KNsCeu1bCeyj44WQhyAffA Pr6hr7C1VR8uvCT70SgLyFK2fnN2/UI+94bTCnafujUXTCvllToSzFaZ4KsOB9DGvURG eSoA== 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=ecXjdeuJlerx+ehZLpdS9uH72mGz1gRkt8PH2iIoiyc=; b=QVxepH+z5+JAAi0WCoA8uF6mdPEVxeQxJS/SEV+QnjLCQqu1J4QjSbMphUaPoqvTdx qJRjiPtj1V6/GkBk89+IIGHdIowOUCuW9fQTyTsmpPgKOeuYIFPe7TKhyzKJUnbAqPme dQSErSJKZPcgufHgMsWJCCEQ1/52iPXu0PsF+840TJMCZEjWb2nu5SIOH/DY7CV7J4lR Ta6H/qe4uXwayGcofagfE0HYfj5P3N91AtkZvxwdMLmoV/7hpu9ntR6eMsyICcUPzwTN Tw07pbRaOAvRufVSC1NJGN/BUhjzmwO+IQA0ZVAnJQh3Qkx0Sc3/gQSzFIcBlO7+70FU oLBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=fgTudzKr; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o20si23369975pgv.334.2021.10.25.07.37.35; Mon, 25 Oct 2021 07:37: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=pass header.i=@google.com header.s=20210112 header.b=fgTudzKr; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232969AbhJYOcf (ORCPT + 99 others); Mon, 25 Oct 2021 10:32:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232947AbhJYOce (ORCPT ); Mon, 25 Oct 2021 10:32:34 -0400 Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85B32C061745 for ; Mon, 25 Oct 2021 07:30:12 -0700 (PDT) Received: by mail-oi1-x231.google.com with SMTP id t4so15795814oie.5 for ; Mon, 25 Oct 2021 07:30:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ecXjdeuJlerx+ehZLpdS9uH72mGz1gRkt8PH2iIoiyc=; b=fgTudzKro276crsTGJpTyeoaB6sAoJ8XDuI+R0PiyVw/UZkgembqtSpXJruu/I3WdJ GqP3gQPgvpBVg73g5TN4GHQW6RvBpLIMl8SCGRQ0xgarpr39VSGNsobtfOCvJW0TEdiZ dXPMKznjHlCVrLFQr1TLGcn5RTBmRqjCxc0F6P3A7GeTzSiTLApvozJFv4WM7InQVJFv qZrKjSsVMvHiN0s58JzCECwX+Akow+FOWh3ZUUI63jtUhB8QRMNhBO8LTo3HE2XFNmXr oMVywlcPGl3VnRyd+KB9xWKre3utI99r0QMuJxPnk9Kcp23UzZYBMJb5BXPbFkv2sYLM 99yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ecXjdeuJlerx+ehZLpdS9uH72mGz1gRkt8PH2iIoiyc=; b=kHxYOf2/wNnYBnxf+r7pMUYlQ7yUAhT4e4y2XoIeLBlR05GU9w7RsEugjMO7A2A8H5 Ip9vVdA6RT/CB90Ku79CGo64IiAOFGPCyFIc1GNWIXYb6BhdXVEoeucO5TTpVD93qIwk YuR4MT+c3wotTyGo8HICOyekUmvkVEI22S6BIEE942WWSWhlv9oxl9lDV05mtSFS2HWS sfYBY9fxPjIjOpMf3QTZjZxFlRqHKe6mFggA8K6vYL0mBIQ+6fo6FQlMTdtul0KeXtiz Ckrs1DWq7xOm1MDtZps5mBPZsy2MsWy8NCyfU7Gf/DC+bFI+2RdKdqcUCLn6CT+23Smq RLtQ== X-Gm-Message-State: AOAM531QSaayZ3p1ufsoHq4psh4mdo7s3H4WKq5Z3MAdjgsa3dHyIOX8 MwdNu01WZt4y6dfrHObuDJh1l1ChsEwVl+38qUe1b/c3R250QQ== X-Received: by 2002:a05:6808:118c:: with SMTP id j12mr12234154oil.65.1635172209605; Mon, 25 Oct 2021 07:30:09 -0700 (PDT) MIME-Version: 1.0 References: <00000000000089871905cf2b7d09@google.com> In-Reply-To: From: Marco Elver Date: Mon, 25 Oct 2021 16:29:57 +0200 Message-ID: Subject: Re: [syzbot] KCSAN: data-race in sbitmap_queue_clear / sbitmap_queue_clear (3) To: Jens Axboe Cc: syzbot , linux-block@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 On Mon, 25 Oct 2021 at 15:36, Jens Axboe wrote: [...] > > write to 0xffffe8ffffd145b8 of 4 bytes by interrupt on cpu 1: > > sbitmap_queue_clear+0xca/0xf0 lib/sbitmap.c:606 > > blk_mq_put_tag+0x82/0x90 > > __blk_mq_free_request+0x114/0x180 block/blk-mq.c:507 > > blk_mq_free_request+0x2c8/0x340 block/blk-mq.c:541 > > __blk_mq_end_request+0x214/0x230 block/blk-mq.c:565 > > blk_mq_end_request+0x37/0x50 block/blk-mq.c:574 > > lo_complete_rq+0xca/0x170 drivers/block/loop.c:541 > > blk_complete_reqs block/blk-mq.c:584 [inline] > > blk_done_softirq+0x69/0x90 block/blk-mq.c:589 > > __do_softirq+0x12c/0x26e kernel/softirq.c:558 > > run_ksoftirqd+0x13/0x20 kernel/softirq.c:920 > > smpboot_thread_fn+0x22f/0x330 kernel/smpboot.c:164 > > kthread+0x262/0x280 kernel/kthread.c:319 > > ret_from_fork+0x1f/0x30 > > > > write to 0xffffe8ffffd145b8 of 4 bytes by interrupt on cpu 0: > > sbitmap_queue_clear+0xca/0xf0 lib/sbitmap.c:606 > > blk_mq_put_tag+0x82/0x90 > > __blk_mq_free_request+0x114/0x180 block/blk-mq.c:507 > > blk_mq_free_request+0x2c8/0x340 block/blk-mq.c:541 > > __blk_mq_end_request+0x214/0x230 block/blk-mq.c:565 > > blk_mq_end_request+0x37/0x50 block/blk-mq.c:574 > > lo_complete_rq+0xca/0x170 drivers/block/loop.c:541 > > blk_complete_reqs block/blk-mq.c:584 [inline] > > blk_done_softirq+0x69/0x90 block/blk-mq.c:589 > > __do_softirq+0x12c/0x26e kernel/softirq.c:558 > > run_ksoftirqd+0x13/0x20 kernel/softirq.c:920 > > smpboot_thread_fn+0x22f/0x330 kernel/smpboot.c:164 > > kthread+0x262/0x280 kernel/kthread.c:319 > > ret_from_fork+0x1f/0x30 > > This is just a per-cpu alloc hint, it's racy by nature. What's the > preferred way to silence these? That was my guess, but couldn't quite say. We started looking at write/write races as more likely to be harmful (vs. just read/write), and are inclined to let syzbot send out more of such reports. Marking intentional ones would be ideal so we'll be left with the unintentional ones. I would probably use WRITE_ONCE(), just to make sure the compiler doesn't play games here; or if the code is entirely tolerant to even the compiler miscompiling things, wrap the thing in data_race(). [ A summary of a bunch of recommendations currently lives here: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/memory-model/Documentation/access-marking.txt ] Thanks, -- Marco