Received: by 10.213.65.68 with SMTP id h4csp1697821imn; Thu, 5 Apr 2018 02:07:07 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/AqzYfGcp2e9AnJ3P72F4flg3CvEY6RSof5ewYOZtZ+zUPKEvbnwRfq3IB8RpV7qKUkc8Z X-Received: by 2002:a17:902:44c:: with SMTP id 70-v6mr22369466ple.354.1522919227572; Thu, 05 Apr 2018 02:07:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522919227; cv=none; d=google.com; s=arc-20160816; b=cfDpm4IPsc4i/HXQ7cAw1nRVjJJ0FcapsE2dlfm9vdxMRlgXTPjQEox18qlvZrVI8/ ucJKgjnPN6Io7/QRpJOf+tReVnnVOd5V0wc1hpR6fHM5b/S+BYXIXe5FZslvUowF8yjZ QXxE7sqQpZKVofjNYSnIsFi0YF9pigTju27nWvEGboILS3vj1iMTTdgUoUycae709M5a Y6NPhfvO8a5OpGfOMfrf/Wa8CZKjdw8eifZj6EfrGCsqwexO83Pk0hPK1HMbsRG77nEy R9Ax1T2R9i086QscpC2AXjn5zV+Dj6y0IU/0Il2C3r5lI29/1NfgtCa3JiPIU8w9n7s6 9JAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=KDqfwSoU6mnREvK2q/bimhUpUMY0NbHCk0+fELizw0c=; b=oBH57k9JI0CTVnA+C+UQ5izK1+yx5+iyjzbveh8txLHchMS0rcRfr+0grazEkt6KKU lL53dmzDFcsU6ZzDywvhQFwEiq10FkRJsbBxJT7mvXd7A1JAGef+fOSygMgDIPbdjHrf pXtB9ujqNGxI9nvxE/x6Aj9TsVg5866XoxcJpkxM/oZ//qCN1G6yt8KQA/wZp5Mxf6s4 /bMM4ln5vJRNs0/zFluYEdImossXC5KDub5oRwgk45AS2j1VXERq8AGXLC3VUwfLPBOZ aPwREZ0TNqZTclKIMzWIB4brrNsbdv/S2XwDALwMU6c5MMZBXZTDjKgA9FT4Ucq4sX5q e5ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rLjW0wyq; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g8si5110310pgs.69.2018.04.05.02.06.53; Thu, 05 Apr 2018 02:07: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; dkim=pass header.i=@google.com header.s=20161025 header.b=rLjW0wyq; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751591AbeDEJFa (ORCPT + 99 others); Thu, 5 Apr 2018 05:05:30 -0400 Received: from mail-pl0-f53.google.com ([209.85.160.53]:41393 "EHLO mail-pl0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751179AbeDEJF3 (ORCPT ); Thu, 5 Apr 2018 05:05:29 -0400 Received: by mail-pl0-f53.google.com with SMTP id bj1-v6so15798682plb.8 for ; Thu, 05 Apr 2018 02:05:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=KDqfwSoU6mnREvK2q/bimhUpUMY0NbHCk0+fELizw0c=; b=rLjW0wyqOgYYBUDe+NBVXs5wFl8HAcgINLb9l4AhXtbxzm731695jIv9VmTh2BHhR6 rowriltDiIG3N2FYTZQhpDalhPfzwb3BhXl3KIotsZSck8NG7j+wscyBJTo12IORMYjk UHF3SWvP91uaLvczJNyA8XXawBrP32nfNXzvkztejkdTUB7TeuY2JQv81oNQIx5O9xqv ZDRzWE1S/RDd2HAbWLM6u4t9WD1EaDxmPYER2Nsj+KkLPn5i/Bofivuugy4AUU9hPjJk w1Vzbsm0ICWWHHAhm8YmZaIqNi8Gui7x71/cdbUyO20/7ENGu4A4Fa48hL0ACyokf2lw ajoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=KDqfwSoU6mnREvK2q/bimhUpUMY0NbHCk0+fELizw0c=; b=HwaV9zX7ZwblTxWRmPZlSpt9NS7Ut4VkMDudXas9BGAZqYBO5mmCouTD7OIdjHPm2b Nl1WxSfpc/ODwMSlUeE44cVmsYMqhFCDqABSxs4m7EEFFF3BHk90nAvpmtQzQ5RdyXSA ofQxitAot8nAzxHUMXSXMRnQrqlIQwvKTyqfalTOqS41bpRzij102Z/HwUDt6+EnaF4R 4c1IHlwoQIu4gxOisd47ktz2KZoxNPM4Yw9K81Fl5EtRy1O3Q41Eb1krur1Ac1RRrN2F L70UliJAaI+NrSG7qv/WGgQltxjx8xzSj+spXxevgLtuCYFRQKiOMMZpMBKuT0wCQXMf iu8Q== X-Gm-Message-State: AElRT7GM+wtsHIfCDw57qGYC9a0FSLXcHESM6jzcbJfa/QFRdqf1GRWy T/+DyDXq4LZjnbDCLVrRitqkJu7APVnwBl8mdTKVww== X-Received: by 2002:a17:902:8e8b:: with SMTP id bg11-v6mr21981838plb.225.1522919128355; Thu, 05 Apr 2018 02:05:28 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.182.136 with HTTP; Thu, 5 Apr 2018 02:05:07 -0700 (PDT) In-Reply-To: <97ada9f8-93e0-b321-e588-2d3b34b10ef8@redhat.com> References: <20180405063444.GA5877@kroah.com> <26e497b0-1e10-d9c6-73eb-e0feed9a60ea@redhat.com> <97ada9f8-93e0-b321-e588-2d3b34b10ef8@redhat.com> From: Dmitry Vyukov Date: Thu, 5 Apr 2018 11:05:07 +0200 Message-ID: Subject: Re: WARNING: kobject bug in sysfs_warn_dup To: Steven Whitehouse Cc: Greg KH , rpeterso@redhat.com, cluster-devel@redhat.com, syzbot , LKML , syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 5, 2018 at 11:00 AM, Steven Whitehouse wrote: > Hi, > > > > On 05/04/18 09:52, Dmitry Vyukov wrote: >> >> On Thu, Apr 5, 2018 at 10:36 AM, Steven Whitehouse >> wrote: >>> >>> Hi, >>> >>> >>> >>> On 05/04/18 09:19, Dmitry Vyukov wrote: >>>> >>>> On Thu, Apr 5, 2018 at 8:34 AM, Greg KH >>>> wrote: >>>>> >>>>> On Wed, Apr 04, 2018 at 07:02:01PM -0700, syzbot wrote: >>>>>> >>>>>> Hello, >>>>>> >>>>>> syzbot hit the following crash on upstream commit >>>>>> 3e968c9f1401088abc9a19ae6ff571644d37a355 (Wed Apr 4 21:19:24 2018 >>>>>> +0000) >>>>>> Merge tag 'ext4_for_linus' of >>>>>> git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4 >>>>>> syzbot dashboard link: >>>>>> https://syzkaller.appspot.com/bug?extid=ff87a28e665c163aa7f5 >>>>>> >>>>>> C reproducer: >>>>>> https://syzkaller.appspot.com/x/repro.c?id=5104666266304512 >>>>>> syzkaller reproducer: >>>>>> https://syzkaller.appspot.com/x/repro.syz?id=5683447737614336 >>>>>> Raw console output: >>>>>> https://syzkaller.appspot.com/x/log.txt?id=5104818200772608 >>>>>> Kernel config: >>>>>> https://syzkaller.appspot.com/x/.config?id=9118669095563550941 >>>>>> compiler: gcc (GCC) 7.1.1 20170620 >>>>>> >>>>>> IMPORTANT: if you fix the bug, please add the following tag to the >>>>>> commit: >>>>>> Reported-by: syzbot+ff87a28e665c163aa7f5@syzkaller.appspotmail.com >>>>>> It will help syzbot understand when the bug is fixed. See footer for >>>>>> details. >>>>>> If you forward the report, please keep this part and the footer. >>>>>> >>>>>> R10: 0000000000000000 R11: 0000000000000286 R12: 0000000000000003 >>>>>> R13: 0000000000000004 R14: 0000000000000000 R15: 0000000000000000 >>>>>> ------------[ cut here ]------------ >>>>>> kobject_add_internal failed for nodev( with -EEXIST, don't try to >>>>>> register >>>>>> things with the same name in the same directory. >>>>>> sysfs: cannot create duplicate filename '/fs/gfs2/nodev(' >>>>>> WARNING: CPU: 1 PID: 4473 at lib/kobject.c:238 >>>>>> kobject_add_internal+0x8d4/0xbc0 lib/kobject.c:235 >>>>>> CPU: 0 PID: 4474 Comm: syzkaller533472 Not tainted 4.16.0+ #15 >>>>>> Kernel panic - not syncing: panic_on_warn set ... >>>>>> >>>>>> Hardware name: Google Google Compute Engine/Google Compute Engine, >>>>>> BIOS >>>>>> Google 01/01/2011 >>>>>> Call Trace: >>>>>> __dump_stack lib/dump_stack.c:17 [inline] >>>>>> dump_stack+0x1a7/0x27d lib/dump_stack.c:53 >>>>>> sysfs_warn_dup+0x83/0xa0 fs/sysfs/dir.c:30 >>>>>> sysfs_create_dir_ns+0x178/0x1d0 fs/sysfs/dir.c:58 >>>>>> create_dir lib/kobject.c:69 [inline] >>>>>> kobject_add_internal+0x335/0xbc0 lib/kobject.c:227 >>>>>> kobject_add_varg lib/kobject.c:364 [inline] >>>>>> kobject_init_and_add+0xf9/0x150 lib/kobject.c:436 >>>>>> gfs2_sys_fs_add+0x1ff/0x580 fs/gfs2/sys.c:652 >>>>>> fill_super+0x86f/0x1d70 fs/gfs2/ops_fstype.c:1118 >>>>>> gfs2_mount+0x587/0x6e0 fs/gfs2/ops_fstype.c:1321 >>>>> >>>>> gfs2 bug, not a sysfs bug, we are correctly warning about an incorrect >>>>> usage of the api. >>>> >>>> Then +gfs2 maintainers. >>>> >>>>> Now if we should turn this into a non-WARN message, that's a different >>>>> thing, I'll gladly take a patch for that. >>>> >>>> If it's API usage bug in higher level code, then I think WARN is a >>>> proper thing. We already had similar ones and they were fixed. >>> >>> >>> I'm trying to figure out what the test is doing, but it is not very >>> clear. >>> At a guess I'd say that perhaps it is trying to mount multiple >>> filesystems >>> with the same label? If that is the case then it is not allowed, and it >>> should be caught be the sysfs code and result in a refusal to mount, >>> which >>> is what I think I see here. Knowing which sysfs directory is involved >>> would >>> allow us to confirm, but I suspect that the test needs altering to give >>> each >>> gfs2 mount a different label at an initial guess, >> >> >> Hi Steve, >> >> But Greg claims that this is incorrect usage of sysfs API: >> >>> gfs2 bug, not a sysfs bug, we are correctly warning about an incorrect >>> usage of the api. >> >> I think this means that sysfs callers must not try to create the same >> thing twice. >> >> Either way user-space code must not be able to triggers WARNINGs in >> kernel. If it does than this is something to fix in kernel. > > > I guess that this warning was added more recently as I've not seen it > before. My expectation is that it will return -EEXIST and not print a > warning there. To avoid that we would have to create a new list of GFS2 > superblocks, and check the list for each mount I think. We could do that, > but it seems a bit odd to duplicate code that is already there and working. > > So it sounds like a case of differing assumptions about what is a valid use > of the sysfs api. Shouldn't be too hard to fix though, Greg? Should we go with your other option of demoting WARNING to pr_err then? I don't how many real bugs that warning caught versus callers just properly handle EEXIST.