Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1861529imm; Fri, 7 Sep 2018 07:18:05 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda1uiAMxo5K+pnecSPf73BHkwaoOtQiRPY5CWKJMc6RN2zTjGKYSuswdnNMVPRpOZfIpIwI X-Received: by 2002:a63:dd49:: with SMTP id g9-v6mr8203118pgj.356.1536329885578; Fri, 07 Sep 2018 07:18:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536329885; cv=none; d=google.com; s=arc-20160816; b=ivnVOilov72DkGZW7jq0Fd3gRGLsmj7MlkBX/frJ0JCFkTYoq9DumF5VZTjNRgA6fh emZxLZGRvEyl/JtW6rOMeQgLP7oaYbtOby1ir2lNMyWbiSmaQhKyS34t9ma8KpXwaqD/ 6UfTWcZifjgK/kmslMzVSil3TkO9Km8oyOdMOWJU3kH0+wvfKtK733yJzcLV4HUfNlCW od4rhzBo2drUusTj+QJIu+k65uMbAssRn5/gc0tWHgHQV4b4Tv0CrKUL5LTxuLUE6lHQ tsqUBu5gJZzmc3gNqUqMNWG8B0ALVsppRnidKPUWiCnBs7DPGHIdFMRvNPjqFazxJo6P WcGA== 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; bh=zhuyQ8HeYKQwGbqGYxR7MgP8L6+Ey4T3qmeo2qQiU+g=; b=ubX4TdGVh0R8q++zVk95ET+bgFDRrdFA3EWrq6S3pmEsCHn9JmYZvO/lpCLsjuoGXp bXrdfd+0eXX/ASqgd0LiCy0aoCGQimmzkPkDo7BaOEefLqbi58fAMCEULT7nAFm4CGi8 0zCEN+ga6FVBUrMuNFhK/nnFnM3mq7Eprcm5TXgEkmoJ115zWP/muVGgdEn6pm+yvwQL OCowfSAOPU9DGbt3zXbI7TTIyprszNxLOUETsSiClQlaGUBR1WUi+1018w27abH0NcHN kCBwvvXWt4cTuE7L2rM2WThML2yOnvCWBirTdsME8H+95oeOB8C9gkyQLPXqlWjVdzVf I9Zg== 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 w11-v6si8837557pga.454.2018.09.07.07.17.49; Fri, 07 Sep 2018 07:18:05 -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 S1728551AbeIGPFs (ORCPT + 99 others); Fri, 7 Sep 2018 11:05:48 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:44671 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728227AbeIGPFs (ORCPT ); Fri, 7 Sep 2018 11:05:48 -0400 Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fyDwz-0002EN-A9; Fri, 07 Sep 2018 12:25:17 +0200 Received: from sha by ptx.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1fyDwy-0000sz-NS; Fri, 07 Sep 2018 12:25:16 +0200 Date: Fri, 7 Sep 2018 12:25:16 +0200 From: Sascha Hauer To: Richard Weinberger Cc: linux-mtd@lists.infradead.org, David Gstir , kernel@pengutronix.de, linux-kernel@vger.kernel.org Subject: Re: [PATCH 13/25] ubifs: authentication: Add hashes to index nodes Message-ID: <20180907102516.2dr3x3mevuu2l2mz@pengutronix.de> References: <20180704124137.13396-1-s.hauer@pengutronix.de> <20180704124137.13396-14-s.hauer@pengutronix.de> <2092924.iTNEbfF25J@blindfold> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2092924.iTNEbfF25J@blindfold> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 12:11:05 up 86 days, 19:20, 73 users, load average: 0.30, 0.22, 0.18 User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 27, 2018 at 09:36:56PM +0200, Richard Weinberger wrote: > > diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c > > index a47fced47823..a00809d4fe6f 100644 > > --- a/fs/ubifs/tnc.c > > +++ b/fs/ubifs/tnc.c > > @@ -488,6 +488,12 @@ static int try_read_node(const struct ubifs_info *c, void *buf, int type, > > if (crc != node_crc) > > return 0; > > > > + err = ubifs_node_check_hash(c, buf, zbr->hash); > > + if (err) { > > + ubifs_err(c, "hash mismatch on node at LEB %d:%d", lnum, offs); > > + return 0; > > + } > > Hmm, I think a global "hash is bad" handler would be nice to have. > That way we always report in the same way. I created a function reporting a bad hash, so every failure goes through the same code... > > Maybe also a new file system specific ioctl to query whether a hash > failure was noticed. but I'll leave that for a later excercise if that's ok. I am unsure how useful such an ioctl() is. It's too easy to interpret such a hash mismatch as some kind of security violation when it's more likely just a bug somewhere. > > @@ -868,6 +877,23 @@ static int write_index(struct ubifs_info *c) > > } > > len = ubifs_idx_node_sz(c, znode->child_cnt); > > ubifs_prepare_node(c, idx, len, 0); > > + ubifs_node_calc_hash(c, idx, hash); > > + > > + mutex_lock(&c->tnc_mutex); > > This lock looks correct too me. > Just in case, you did test with lockdep enabled? :-) Yes, I had lockdep enabled in all my tests. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |