From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A4A1C43387 for ; Wed, 16 Jan 2019 11:03:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3621620657 for ; Wed, 16 Jan 2019 11:03:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Y256h7F0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389531AbfAPLDk (ORCPT ); Wed, 16 Jan 2019 06:03:40 -0500 Received: from mail-it1-f196.google.com ([209.85.166.196]:55953 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732343AbfAPLDk (ORCPT ); Wed, 16 Jan 2019 06:03:40 -0500 Received: by mail-it1-f196.google.com with SMTP id m62so2304569ith.5 for ; Wed, 16 Jan 2019 03:03:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LzzyD4mQQ6Cb+tMRir6nyjI4FhPiJPjUC/lGtePBSLY=; b=Y256h7F0b/F3hZmACgr3bx2mZcx9jXqb9ajdhvjYlIGhLhjU9huWqBX0bgKl7ijTRr yO/PIK5uJ+j72gdeeiCk4gXab978rtdOHt9U2Yg8NAA30XiVupXug2jrJ/zq3ACEvKHz ERp7FPdSih/OohfLmrAWClBJOh7QUVjizjMN0tmwxNFQ8KB3sc4itEkIbKuD4YKjTXYM QdFGYRYOySr0vptPEUlkt3y9lDO3iLbJ790cVRNrzkYo6UdYbOkxy6HTWvZ18p8MDIl0 bMEvU1AA4Uusr5tOtjE27CJPJC68mVEznsxur6GLrMHOqCObwLN81l9XzMU2WipCUDpr ZzFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LzzyD4mQQ6Cb+tMRir6nyjI4FhPiJPjUC/lGtePBSLY=; b=K0wLQPxM2hjxbIuYV5Is5FEJnTnAaFmdxd4c8aPSBzz254dMyzWGnN0kCST78365iw OTB6sUE42At32y8gfayXsmW5l3EwMnh0iYLZ3yDCtJUbI9UXosZKHrR8CgvOqp/shyze x8MR/+mQdJTFyseAiQRGkABcQfNK6HX/r7WhfDRixKEX1loHi1EByedVKiUnG738kqsr CcEuDg2h7agxDrSXz0sJmldYCW4Ef4J9VDiGjTf1cUI9rJlPqIDZviXuwU9fylYDnRWn GmXP0OKLqFqFA/ODuXSPobehpMvjRA/rBiKo5SrFkCdLu8fiJLlR84i1H3eVx/QdMN9j VFDw== X-Gm-Message-State: AJcUukePIo1nvyMN4O4XNIl6/I+6zfUOgN5wPzUCHrQPEfHnQMqi8Q08 03q/dvJpD3cvfyaej+6L9Tun/ulNUKuQ0gaA3B6lvA== X-Google-Smtp-Source: ALg8bN5rE4F9miAo84HsD4WE5aTBkB6dYFxFuaMtrcU5iozy2+G/j2ZGT9FagGfXa6z/QprtUUxgr7cXoYeud9nCLfg= X-Received: by 2002:a05:660c:f94:: with SMTP id x20mr4606663itl.144.1547636618950; Wed, 16 Jan 2019 03:03:38 -0800 (PST) MIME-Version: 1.0 References: <1547201433-10231-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> <04c6d87c-fc26-b994-3b34-947414984abe@i-love.sakura.ne.jp> <54b68f21-c8b5-7074-74e0-06e3d7ee4003@i-love.sakura.ne.jp> <20190116104308.GC26069@quack2.suse.cz> In-Reply-To: <20190116104308.GC26069@quack2.suse.cz> From: Dmitry Vyukov Date: Wed, 16 Jan 2019 12:03:27 +0100 Message-ID: Subject: Re: [PATCH] fs: ratelimit __find_get_block_slow() failure message. To: Jan Kara Cc: Tetsuo Handa , Al Viro , linux-fsdevel Content-Type: text/plain; charset="UTF-8" Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Wed, Jan 16, 2019 at 11:43 AM Jan Kara wrote: > > On Wed 16-01-19 10:47:56, Dmitry Vyukov wrote: > > On Fri, Jan 11, 2019 at 1:46 PM Tetsuo Handa > > wrote: > > > > > > On 2019/01/11 19:48, Dmitry Vyukov wrote: > > > >> How did you arrive to the conclusion that it is harmless? > > > >> There is only one relevant standard covering this, which is the C > > > >> language standard, and it is very clear on this -- this has Undefined > > > >> Behavior, that is the same as, for example, reading/writing random > > > >> pointers. > > > >> > > > >> Check out this on how any race that you might think is benign can be > > > >> badly miscompiled and lead to arbitrary program behavior: > > > >> https://software.intel.com/en-us/blogs/2013/01/06/benign-data-races-what-could-possibly-go-wrong > > > > > > > > Also there is no other practical definition of data race for automatic > > > > data race detectors than: two conflicting non-atomic concurrent > > > > accesses. Which this code is. Which means that if we continue writing > > > > such code we are not getting data race detection and don't detect > > > > thousands of races in kernel code that one may consider more harmful > > > > than this one the easy way. And instead will spent large amounts of > > > > time to fix some of then the hard way, and leave the rest as just too > > > > hard to debug so let the kernel continue crashing from time to time (I > > > > believe a portion of currently open syzbot bugs that developers just > > > > left as "I don't see how this can happen" are due to such races). > > > > > > > > > > I still cannot catch. Read/write of sizeof(long) bytes at naturally > > > aligned address is atomic, isn't it? > > > > Nobody guarantees this. According to C non-atomic conflicting > > reads/writes of sizeof(long) cause undefined behavior of the whole > > program. > > Yes, but to be fair the kernel has always relied on long accesses to be > atomic pretty heavily so that it is now de-facto standard for the kernel > AFAICT. I understand this makes life for static checkers hard but such is > reality. Yes, but nobody never defined what "a long access" means. And if you see a function that accepts a long argument and stores it into a long field, no, it does not qualify. I bet this will come at surprise to lots of developers. Check out this fix and try to extrapolate how this "function stores long into a long leads to a serious security bug" can actually be applied to whole lot of places after inlining (or when somebody just slightly shuffles code in a way that looks totally safe) that also kinda look safe and atomic: https://lore.kernel.org/patchwork/patch/599779/ So where is the boundary between "a long access" that is atomic and the one that is not necessary atomic?