Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp58517imu; Wed, 2 Jan 2019 14:04:14 -0800 (PST) X-Google-Smtp-Source: ALg8bN4Gs+B/+9jdZ9japteyYj8VGMyqXkHAd0kRU1DEyuDfeNIxDK0bvgxt/50rS8foqJfvAw+A X-Received: by 2002:a63:6d48:: with SMTP id i69mr14442113pgc.215.1546466654064; Wed, 02 Jan 2019 14:04:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546466654; cv=none; d=google.com; s=arc-20160816; b=PmuzzNeNEczPdknIawjnJaP8sQX0xjFWTHD0/SciF3AwsfzTiQKMWSKcmcAHIGH3f9 Z+0RqilQIm+vYQeTOckZkINsGE22mtOIbUk1ca0EETeoIUmbVx65fot4dwZuMYckTbDf MSMpDD0xt2dmJe4KMA/rjPlY+J6vRZ8YZeZTD97pnHTwFYYdhnGGO+LTaknD6ns/ja/a gaqmdSkltXqGYC+ZMCaxhPq3fqYV3IvYmDxoumtSY3MlL0VWgY9GK/2FZQ6DRiQfXjZr ZusSU7QcPvjIWVxK+C5GM8BCiBoJIIDyvX/RDI4feXdcCNz/C43sTniRhyPctoNMKnI9 cNPQ== 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 :in-reply-to:references:mime-version:dkim-signature; bh=ikxVp6zc4xz0kip1YhbhjKbDAlBHVVUMk50g71OLSt8=; b=odmhpgUlksFvKyTSHmWJo+aBOvXSQ5L56FCqE8vI3SexAi/3qqYLbq+LynDLvSpKSD nlZzHyRZBSOfd8nP+0oG/fkw5rgb7Qf6dx8BMGguzKINeX2lIJuuhVL2CsJ4ba2YM74P 773DUsjQr7yMJvJWtG3LomwGpHr4P3S3uqiqShtPUYAUirOBjRrs9XCjwFZDMIJYWKVK GUoGhCpvIe42weYaCoybSiDASCzjU2h1aPGiRMLgcCb0FGdm6EPTQ1sJHar4IshvW4cJ 4aCFE67/1FS2s+726DPIplJd+A8Aei/syHLC/nhTwKLwV7JghF4X1PsIH/cd1QUOv7i2 EjoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=NRmpAgFg; 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 e129si31891936pgc.333.2019.01.02.14.03.58; Wed, 02 Jan 2019 14:04:13 -0800 (PST) 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=@linux-foundation.org header.s=google header.b=NRmpAgFg; 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 S1729762AbfABTxy (ORCPT + 99 others); Wed, 2 Jan 2019 14:53:54 -0500 Received: from mail-lf1-f43.google.com ([209.85.167.43]:44993 "EHLO mail-lf1-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726089AbfABTxy (ORCPT ); Wed, 2 Jan 2019 14:53:54 -0500 Received: by mail-lf1-f43.google.com with SMTP id z13so21719551lfe.11 for ; Wed, 02 Jan 2019 11:53:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ikxVp6zc4xz0kip1YhbhjKbDAlBHVVUMk50g71OLSt8=; b=NRmpAgFg5FPleEA7gDJ7M6EqsD9WTZ19Phyr0npkz5YDxv7xg5bJGeslpPRR3CrJvj bXKfX7MKLKev2zP1o5NzIPVTLqZ6pUX2ab0sJ/hQ/BsFiQjIBgb+1O2aUokp9gTF4XPn MlkRR9UIzozzKIphZMCCDOMI4TWFRkkRDHBhE= 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=ikxVp6zc4xz0kip1YhbhjKbDAlBHVVUMk50g71OLSt8=; b=dw+NJoCPlLppvnzSybuc/WKDb1/epMGutlccqLNIzL6iO3XV9a3RT87RcEGEqeBrZR o/DvWchCfHT9jZHYE1aEh3Bf6dJCmY2I12KEULoXABupuh7EAmVQpHhPY+BvIjLRyZUF 3QQsGPTjcsjdkR1purzUyE3qOayj3rwBvzhANHN/aD7cfcBzjaYFy9daCukoY+c2YZmu MnPvBihufmlG7FlYqvblWsbFznOvCp9DkPi4Cs6KIFliuyCJdrVvNTJT7TTQFi3tNDQJ rJxWoKuhD+0CnO++K2D3z62rl+7XjAJ2grGc/iVy5b97/drZaxrHZyZI+ew5Q/d8AaI1 3EiQ== X-Gm-Message-State: AJcUukd5IFlgbRubUOLdG8V+yLnTJfbte622bMxrJ1Y9xKCPe6kSuBIO 8GrqYVaFc/mIlypu6oriJlCRbnIpX3M= X-Received: by 2002:a19:9b50:: with SMTP id d77mr891794lfe.137.1546458831930; Wed, 02 Jan 2019 11:53:51 -0800 (PST) Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com. [209.85.208.175]) by smtp.gmail.com with ESMTPSA id d10sm10355615lfa.71.2019.01.02.11.53.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Jan 2019 11:53:50 -0800 (PST) Received: by mail-lj1-f175.google.com with SMTP id n18-v6so27938220lji.7 for ; Wed, 02 Jan 2019 11:53:50 -0800 (PST) X-Received: by 2002:a2e:310a:: with SMTP id x10-v6mr27545713ljx.6.1546458830210; Wed, 02 Jan 2019 11:53:50 -0800 (PST) MIME-Version: 1.0 References: <20190102005704.GC17624@shao2-debian> In-Reply-To: <20190102005704.GC17624@shao2-debian> From: Linus Torvalds Date: Wed, 2 Jan 2019 11:53:34 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [LKP] [mtd] c4dfa25ab3: kernel_BUG_at_fs/sysfs/file.c To: kernel test robot , David Woodhouse , Brian Norris , =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= , Richard Weinberger , "Rafael J. Wysocki" Cc: Alban Bedel , Greg Kroah-Hartman , Bartosz Golaszewski , Boris Brezillon , LKML , lkp@01.org 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 Hmm.. Adding a few more mtd people to the cc. On Tue, Jan 1, 2019 at 4:57 PM kernel test robot wrote: > > FYI, we noticed the following commit (built with gcc-7): > > commit: c4dfa25ab307a277eafa7067cd927fbe4d9be4ba ("mtd: add support for reading MTD devices via the nvmem API") > > [ 81.780248] kernel BUG at fs/sysfs/file.c:328! > [ 81.781914] Call Trace: > [ 81.781914] sysfs_create_files+0x60/0x180 > [ 81.781914] mtd_add_partition_attrs+0x14/0x30 > [ 81.781914] add_mtd_partitions+0x11f/0x260 > [ 81.781914] mtd_device_parse_register+0x38d/0x4c0 > [ 81.781914] ns_init_module+0x1033/0x117d > [ 81.781914] do_one_initcall+0x18f/0x39e > [ 81.781914] kernel_init_freeable+0x2b4/0x353 > [ 81.781914] kernel_init+0xa/0x120 This actually looks like a very old bug, just exposed by a new error case. In particular, the mtd code seems to do this in mtd_add_partition(): int ret = 0; ... add_mtd_device(&new->mtd); mtd_add_partition_attrs(new); return ret; where 'ret' is actually never set to anything but that initial zero. And in fact, it looks like it never was used. I _think_ that what's going on is that "add_mtd_device()" historically never really failed (although it *can* fail), and then mtd_add_partition_attrs() is called on something that doesn't really exist. It looks like the error handling for the add_mtd_device() case nmever actually existed, and now the nvmem patch makes that fail in the test-case, and the lack of error handling is exposed. There is another call-site of add_mtd_device() (in add_mtd_partitions() - same pattern, notice the "s" at the end of the function name) that also lacks the error handling. Both cases go back to 2010. Greg, Rafael: it does strike me that the "BUG_ON()" in sysfs_create_file_ns() could easily have been a if (WARN_ON(..)) return -EINVAL; which would have made the machine boot and probably make things easier for normal users to report. The kernel test robot doesn't care, but non-booting kernels are usually not nice to debug or report for normal human beings.. Linus