Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1519858imm; Fri, 11 May 2018 18:22:07 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqdwXDzQn2bdt5FD4yG4nIXS+HobLX6uS3/J4BFIeJKS3ZjGBpCWz8nHYbbOlOujFqJ0zYY X-Received: by 2002:a17:902:da4:: with SMTP id 33-v6mr417541plv.52.1526088127795; Fri, 11 May 2018 18:22:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526088127; cv=none; d=google.com; s=arc-20160816; b=pq8JQhqQ9tpKmHoIGOk4FCk2vAzhR2OFLhzgzvgOqBYd2ee8Pnkme0dad3GGZCXjxm 8+XYJY4mL7IXb8oS4wI5+mLHSag6QTQXPhVn11nqW8I4u1ptBQ02b/AaMFkFKlGSw91T s8D9MiI6TqDPXLEZ836La5rMaBCP4xETGV+v2YS+DOusa+/3ldde8mcBrS5efCeXXdJJ ql7lxn2B63OofpnE+imgPMn7TPNT6vLiBHZ/mjJANAAH1KakhVpjATR0izF4Ge6iO1P5 IUC+F1Fi9iQeMM4y8SWBgKABtd5YtPynB2TmFVwouMtS2U1hkfKAsLN5nmQYppcNnSRR KevA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=aMzablkB7B1FxI6aiy9YIkFagaKyWRSKg/VPopeHQgY=; b=XKMyx/qbEU2LqCXIL7p9JBNk+C/956+4BAK/CjbVOOsWSUCEs3+8wHTZkq/JCXnwHX S+auKSXWSuTWFu4mQBsJBHzbnNp+iF6g6NA5rS1C8EpSOXvSjpliRSkSk2mF6vVeteXy GAHkLnMMOgiBH0Mc7aqQ+k3LlMrCSv/ryHvjzCKNnU91KOb0ODXde/YporFZ7Fv7DxMS 9MqBYTkWcfef0IRhqrLmhJ1pcfiYwBX+KohsAtipnCKuVF7gfsFxUxu24b86YpxM+W3D MrUIbxdJUh6C67Z2/VAZY1mage/kWbAFOwGpv9OXlNTElBiILyCUOukVho1sm6d+7XCR t8qA== ARC-Authentication-Results: i=1; mx.google.com; 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 h90-v6si4022142plb.377.2018.05.11.18.21.31; Fri, 11 May 2018 18:22:07 -0700 (PDT) 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; 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 S1751533AbeELBVV (ORCPT + 99 others); Fri, 11 May 2018 21:21:21 -0400 Received: from ipmail03.adl6.internode.on.net ([150.101.137.143]:63759 "EHLO ipmail03.adl6.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751273AbeELBVU (ORCPT ); Fri, 11 May 2018 21:21:20 -0400 X-Greylist: delayed 303 seconds by postgrey-1.27 at vger.kernel.org; Fri, 11 May 2018 21:21:19 EDT Received: from ppp59-167-129-252.static.internode.on.net (HELO dastard) ([59.167.129.252]) by ipmail03.adl6.internode.on.net with ESMTP; 12 May 2018 10:46:12 +0930 Received: from dave by dastard with local (Exim 4.80) (envelope-from ) id 1fHJ8s-0008Rc-EF; Sat, 12 May 2018 11:16:10 +1000 Date: Sat, 12 May 2018 11:16:10 +1000 From: Dave Chinner To: Dmitry Vyukov Cc: Eric Sandeen , "Darrick J. Wong" , syzbot , LKML , linux-xfs@vger.kernel.org, syzkaller-bugs , Theodore Ts'o , syzkaller Subject: Re: WARNING: bad unlock balance in xfs_iunlock Message-ID: <20180512011610.GB23861@dastard> References: <95c1400b-94f2-1af4-2d5d-c61c274c28ff@sandeen.net> <9f8d657c-7f42-7bd9-4477-6c3addf16dee@sandeen.net> <9adacfed-0de6-cb94-bf14-3e639678a02a@sandeen.net> <20180509232254.GQ10363@dastard> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 11, 2018 at 10:59:53AM +0200, Dmitry Vyukov wrote: > On Thu, May 10, 2018 at 1:22 AM, Dave Chinner wrote: > > On Wed, May 09, 2018 at 10:43:05AM +0200, Dmitry Vyukov wrote: > >> Does "xfstests fuzzing infrastructure" use coverage-guidance? > > > > It's guided manually to fuzz a substantial proportion of the fields > > in the on-disk format that are susceptible to fuzzing bqased > > attacks. It's not complete coverage yet, but it's getting better and > > better, and we're finding more problems from it that random bit > > based fuzzing has ever uncovered. > > > > Also, the xfstests fuzzing defeats the CRC protection now built into > > the metadata, which means it can exercise all the new filesystem > > features that random bit fuzzers cannot exercise. That's the problem > > with fuzzers like syzbot - they can only usefully fuzz the legacy > > filesystem format which doesn't have CRC validation, nor many of the > > other protections that the current filesystem format has to detect > > corruption. This will also allow us to test things like online > > repair of fuzzed structures.... > > syzkaller has 2 techniques to deal with checksums, if you are > interested I can go into more detail. You can if you want, but I'm betting it basically comes down to teaching syzcaller about parts of the on-disk format, similar to AFL. And, like AFL, I doubt any XFS developer has the time to add such support to syzbot. > > Given the results we're getting from our own fuzzers, I don't see > > much point in (XFS developers) investing huge amounts of effort to > > make some other fuzzer equivalent to what we already have. If > > someone else starts fuzzing the current format (v5) XFS filesystems > > and finding problems we haven't, then I'm going to be interested in > > their fuzzing tools. But (guided) random bit perturbation fuzzing > > of legacy filesystem formats is really not that useful or > > interesting to us right now. > > Just asked. > > Note that coverage-guidance does not necessary mean bit flipping. > syzkaller combines coverage-guidance with grammar-awareness and other > smartness. Yup, I assumed that this would be the case - those sorts of "directed fuzzing" techniques were pioneered by the Samba guys for reverse engineering the SMB protocol used by MS servers all those years ago. But at it's most basic level, it's still using bit flipping techniques to perturb the input and provoke responses. > Based on our experience with network testing, main advantage of > syzkaller over just feeding blobs as network packets (even if these > blobs are built in a very smart way) is the following. syzkaller can > build complex interactions between syscalls, external inputs and > blobs. Yup, nothing new there - that's what every other filesystem fuzzer infrastructure does, too. The problem with this is that it doesn't pin-point the actual operation that tripped over the on-disk corruption. It's catching downstream symptoms of an unknown, undetected on-disk format corruption. i.e. it's a poor substitute for explicit testing of structure bounds and data relationships of a known format. That's the fundamental premise of fuzz testing - most software does not have robust validation of it's inputs and so fuzzing those inputs finds problems. We've moved on from the old "trust and don't validate" model of filesystem structure architecture. The on-disk format is very well defined, it is constrained in most cases, and we can validate most individual structures at runtime with relatively little cost. Hence the "structure bounds" exploits that fuzzers tend to exercise are pretty much taken out of the picture, and that leaves us with "data relationships" between structures as the main vector for undetected corruptions. These are mostly detectable, and many are correctable as the current on-disk format has a lot of redundant information. So the space for fuzzers to detect problems is getting smaller and smaller all the time. IOWs, filesystem image fuzzers have their place, but if you want us to take your fuzzing seriously then your fuzzer needs to understand all the mechanisms we now use to detect corruptions to show us where they are deficient. If your fuzzing doesn't expose flaws in our current validation techniques, then it's really not useful to us. > For example, handling of external network packets depend on if > there is an open socket on that port, what setsockopts were called, if > there is a pending receive, what flags were passed to that receive, > were some data sent the other way, etc. For filesystems that would be > various filesystem syscalls executed against the mounted image, > concurrent umount, rebind, switch to read-only mode, etc. > But maybe xfstests do this too, I don't know. Do they? Generally there is no need to do this because we know exactly what syscalls will trigger access and/or modification to on-disk structures. Access to the on-disk structures triggers the built in verifier infrastructure, which then catches the majority of corruptions before the structure is used by anything in the kernel. Cheers, Dave. -- Dave Chinner david@fromorbit.com