Received: by 10.192.165.156 with SMTP id m28csp872221imm; Wed, 11 Apr 2018 08:32:11 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/8CNsWc8zRvSlb/nPrzcdX8UmpsWNfMGScTGatbpxl0sP24RRlJZs7DtPQv+vuadm3oK4u X-Received: by 10.99.95.78 with SMTP id t75mr3835167pgb.330.1523460731370; Wed, 11 Apr 2018 08:32:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523460731; cv=none; d=google.com; s=arc-20160816; b=CY/BYUiiRvXjAGqDoUjuIhVEfopOV2wiDtGhgD/kktwojIlFaWximRYFKJCsFAYCHl T8YT11UZ5wB5ZsPRQPYU8CkobrLthc1czyHXzbOpP+HNv8hRTT0Oo93Rvm4aXJuGlzX3 Io3rNEKRCt5Mkafc04MdRq7ZblPVIISEMFkc1mXFw1Na29XxQ/xXU3F20gMuoJj7o8ae NAWgWEi217GrRdavVY4HEJWAZUOs9JqTu/C5j7VLq4O20USL/UfeKE9r+FaBLICL7QtN QIshesVjg7q4rCC90/4Cpb6QNnMwVXsvmZKvJ4TNMAIG7D5GBzQsM4SkI8yRL7iDPPMm vXyg== 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=WeCtUdhiVpP+nq6J9og+CXMVd0XSrdG9T4AwIcH/k68=; b=jNBiLTpULbqFdiEoGUR4/kWQ1b/RwfKgRGeKxnhYKQxOg5lecVdYNCUhvj4sdmTSVA 4EV5oN5lQpwY+JBKubzcwomxMTnHGkk1gRhGO6wjrR+QZ+Oe6eK8bsh/Pzv8iaIyuozz Rtn9hy0XSdjmSRsuV811U4hIzDAI24bdkMJAKASaaEp/prv9EVFGsE2gQKaqtcNYBgnU q3q7hKnTSrTyJ5QcRlf4TJeKC08DpzQh5EK092kLtX7z7bva5k+hra/y7ggMfYHbmzff TxVvF9DNDjdjmWxH+f8+xQCT1Of05OEYoW3FE5jpC94Ru6hjN8IYIxWqE5Z1yvc61HBb 62fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=uwKE5up1; 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 v1-v6si1167060ply.711.2018.04.11.08.31.33; Wed, 11 Apr 2018 08:32:11 -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=uwKE5up1; 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 S1753348AbeDKP2X (ORCPT + 99 others); Wed, 11 Apr 2018 11:28:23 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:46236 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753129AbeDKP2W (ORCPT ); Wed, 11 Apr 2018 11:28:22 -0400 Received: by mail-pl0-f65.google.com with SMTP id 59-v6so1641187plc.13 for ; Wed, 11 Apr 2018 08:28:21 -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=WeCtUdhiVpP+nq6J9og+CXMVd0XSrdG9T4AwIcH/k68=; b=uwKE5up16bCC4PLjpsyjLrBDamDUP4O6yCeQPnnj/iEP2owWpfd3drnZ95ktRSoMzm 97tP9Dw7rnFYKAE2e6XlbhwHTj6Crr+2M0Bsy276Vsb0icoS6zDx9dgoLytXp6LwDMu7 DXZVX3U5TDMZZImfP+XSEj27fMnwzWW5pDrD5rPj+5lke2l4ScPjiRd7mGRR9dd390K6 cQ6Ol8UxIL5tWha7iH26NcGxlBSS73zVobXYYW10d2cmgzUjnGvu49klBOdSPgkYPboc 9MP4paJVEQ7dYNhLbp1G0G/maMyxc+9k+MJwmcHw3a9ltKLyOWgZriD27v6mUPPTLkbj SETw== 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=WeCtUdhiVpP+nq6J9og+CXMVd0XSrdG9T4AwIcH/k68=; b=nvSQsRGsA8Vpc2Nz8kXnrDkgtrx/lfJpWZU24gzegCDRKquf2BQDeCmEnweUQZemKL nyPeyZf6N8L8zc2UMRpxEQVDuqZpiiuUb5aIBrGhL2a88KiMWy+QPIUDxQWetnLBEcet a2gx3y9zJ4cxS5ZAqgZ9nE5jg6Q8LLMSlNpGe3UoSTMfcsaFsEN2UxycPyaOzQlbfwTe N32K/OPCQVPnk6soI8wfG3EO0sZi5R2IundzKwepdE4MkXoleiNUmdI+DXEGFfiHEqwL KgggqsS7nwBSEgCZH2NhRabIM1KS3Jvz8I6Rp204e2tUFSzqqDdLDS+k5f6PSZ9jbwhG JQ8w== X-Gm-Message-State: ALQs6tC8LOlwhZCBotUXxOvabiaVePJIDQVDj4On0YArL48HGr9x7tC4 kOYpsr6uq8k+tEGzBTO0sJ5hOO4NGRaXhkdcrBUBFg== X-Received: by 2002:a17:902:9892:: with SMTP id s18-v6mr5575854plp.95.1523460501371; Wed, 11 Apr 2018 08:28:21 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.182.136 with HTTP; Wed, 11 Apr 2018 08:28:00 -0700 (PDT) In-Reply-To: References: <20180405063444.GA5877@kroah.com> <26e497b0-1e10-d9c6-73eb-e0feed9a60ea@redhat.com> <97ada9f8-93e0-b321-e588-2d3b34b10ef8@redhat.com> <20180405133430.GA21390@kroah.com> <20180405142344.GC29178@kroah.com> From: Dmitry Vyukov Date: Wed, 11 Apr 2018 17:28:00 +0200 Message-ID: Subject: Re: WARNING: kobject bug in sysfs_warn_dup To: Greg KH Cc: Steven Whitehouse , rpeterso@redhat.com, cluster-devel@redhat.com, syzbot , LKML , syzkaller-bugs 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 Wed, Apr 11, 2018 at 5:04 PM, Dmitry Vyukov wrote: > On Thu, Apr 5, 2018 at 4:23 PM, Greg KH wrote: >>> >> 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. >>> > >>> > No, it has been there since at least the 3.13 kernel release (back in >>> > 2013), which is where it got moved to a separate function, but the logic >>> > has been around in the kernel tree for much longer than that as seen in >>> > commit d1c1459e4594 ("sysfs: separate out dup filename warning into a >>> > separate function") >>> > >>> >> 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. >>> > >>> > Don't you have a list of the "names" of the things you are creating >>> > somewhere? Or are you relying on sysfs to do your housekeeping for you? >>> > >>> > Also, why did this trigger a syzbot report? It's only a dump_stack() >>> > reference, one showing that yes, this is something that should not be >>> > done, but the kernel keeps on working afterward. >>> >>> There is a WARN(), not just dump_stack(): >>> >>> WARN(1, "%s failed for %s with " >>> "-EEXIST, don't try to register things with " >>> "the same name in the same directory.\n", >>> __func__, kobject_name(kobj)); >> >> Ah, that's a kobject warning, not a sysfs one. Was looking too far down >> the call chain. We can change this to be dump_stack() as well if you >> think that would help out. Maybe remove it entirely as sysfs already >> does dump the stack? > > > kobject_add is called not only from sysfs, right? Wait, it's the other way around. I've already mailed a patch that does s/WARN/pr_err/. But can remove it entirely, whichever you prefer. > I was just going to send a patch that changes WARN to > pr_err+dump_stack, but noticed that we have 4 active bugs on this > WARNING: > > WARNING: kobject bug in gfs2_sys_fs_add > https://syzkaller.appspot.com/bug?id=057673a56dab61b3a447989b67f10b205111c8f4 > > WARNING: kobject bug in br_add_if > https://syzkaller.appspot.com/bug?id=3e0339080acd6a2a350a900bc6533b03f5498490 > > WARNING: kobject bug in netdev_queue_update_kobjects > https://syzkaller.appspot.com/bug?id=86a8e2ab50527d5a5eb4fad2fc15df609f22d86a > > WARNING: kobject bug in device_add > https://syzkaller.appspot.com/bug?id=57eba87aff7669512fb68e56a932b01805342d13 > > We want to ignore all of them? > As a side signal none of them got any attention, except Eric noting > that, yes, it is noisy: > https://groups.google.com/d/msg/syzkaller-bugs/XDTC7Iv4IKY/Ab_tgZ4HAQAJ > > So I guess I will still mail the patch.