Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp6330454imm; Mon, 27 Aug 2018 13:53:28 -0700 (PDT) X-Google-Smtp-Source: ANB0VdanXh+EyyoTNESAjqKD1lfXiHNa3T8lkaWF5UiD9b4qhDlpxVrT5ZLpZ7O0uRZjsR14ctw9 X-Received: by 2002:a62:c4da:: with SMTP id h87-v6mr15870670pfk.39.1535403208321; Mon, 27 Aug 2018 13:53:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535403208; cv=none; d=google.com; s=arc-20160816; b=fIvX2GO8HlPkMmIblaQPY2A1jLRM3XVnNEz2QIKlwLnwA7z4f9UuVTwh0C51cVJwsN t6rSZ3t9hKOHgU9HS9DTxFPvhYOUVezs9SLSXVWKpXrGvFGMB1cS8IdNxjuHCITMtCCe j7nVsVcxa/3rcOesGYbzXU14uVQ/quB/YMGBHvtORHXvk3fUmjHluDqDH/bTm2coSarS lIA7Ox5d1OVCsaAQ8yu41QwWHJMFr424pmVCwYmcxPem/R/oGZhZgn7oiWvllJyYqNm7 8UpUYPF+lDOxlLHBaku4k0uUn/ArY4KvbUZHSO8ap7WDIXm2YO4dXM5+WM68s3FSCr0x 79vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Xr3W9UH+0CpbJME+ClC5ge8vMs8iwNT8Ci2026s9vUA=; b=b09p8J5sX7Pb0qB2f2UE1mfFrBTxBIeFYqrss6vTUz48Si4x8pvw9zX9za5VvAh+UQ kzaj2T6VS3so9MLMwDXnk1DMBdXz9WtWClK290WD0Mtuq4s5XW6UQoY+aNZs6VtYN5c6 0I5eVTumuhfEUhQKuSXPMbIc73rd+27dfeNWojWK/u8h64d+wHN0MFHgm5sYGzlnxDZ9 QUeQwvy4200GFlhKQQHbG2VTj1l08fGQ84iqMBa62cEytiYaKx1ZLaIijzCTlSGLS34O RK66IzT4Zy7UNGBzQIYqvnUMZuRpGRj6N3IV63uH8G/TFoD5LkOocHt9pVBGw34gDlB0 sQMA== 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 o5-v6si249124pgo.250.2018.08.27.13.53.13; Mon, 27 Aug 2018 13:53:28 -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 S1727281AbeH1AkP (ORCPT + 99 others); Mon, 27 Aug 2018 20:40:15 -0400 Received: from lithops.sigma-star.at ([195.201.40.130]:36360 "EHLO lithops.sigma-star.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726958AbeH1AkP (ORCPT ); Mon, 27 Aug 2018 20:40:15 -0400 Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 448BC606D4A7; Mon, 27 Aug 2018 22:51:57 +0200 (CEST) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id cCf3NR-tXWlK; Mon, 27 Aug 2018 22:51:57 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id ED9CC603B655; Mon, 27 Aug 2018 22:51:56 +0200 (CEST) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id G4dGKNsuJqqC; Mon, 27 Aug 2018 22:51:56 +0200 (CEST) Received: from blindfold.localnet (213-47-184-186.cable.dynamic.surfer.at [213.47.184.186]) by lithops.sigma-star.at (Postfix) with ESMTPSA id A33E2608D734; Mon, 27 Aug 2018 22:51:56 +0200 (CEST) From: Richard Weinberger To: Sascha Hauer Cc: linux-mtd@lists.infradead.org, David Gstir , kernel@pengutronix.de, linux-kernel@vger.kernel.org Subject: Re: [PATCH 15/25] ubifs: Add auth nodes to garbage collector journal head Date: Mon, 27 Aug 2018 22:51:56 +0200 Message-ID: <1660996.WYUJqu3I4M@blindfold> In-Reply-To: <20180704124137.13396-16-s.hauer@pengutronix.de> References: <20180704124137.13396-1-s.hauer@pengutronix.de> <20180704124137.13396-16-s.hauer@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am Mittwoch, 4. Juli 2018, 14:41:27 CEST schrieb Sascha Hauer: > To be able to authenticate the garbage collector journal head add > authentication nodes to the buds the garbage collector creates. > > Signed-off-by: Sascha Hauer > --- > fs/ubifs/gc.c | 37 ++++++++++++++++++++++++++++++++++--- > 1 file changed, 34 insertions(+), 3 deletions(-) > > diff --git a/fs/ubifs/gc.c b/fs/ubifs/gc.c > index ac3a3f7c6a6e..8feeeb12b6ed 100644 > --- a/fs/ubifs/gc.c > +++ b/fs/ubifs/gc.c > @@ -365,12 +365,13 @@ static int move_nodes(struct ubifs_info *c, struct ubifs_scan_leb *sleb) > > /* Write nodes to their new location. Use the first-fit strategy */ > while (1) { > - int avail; > + int avail, moved = 0; > struct ubifs_scan_node *snod, *tmp; > > /* Move data nodes */ > list_for_each_entry_safe(snod, tmp, &sleb->nodes, list) { > - avail = c->leb_size - wbuf->offs - wbuf->used; > + avail = c->leb_size - wbuf->offs - wbuf->used - > + ubifs_auth_node_sz(c); > if (snod->len > avail) > /* > * Do not skip data nodes in order to optimize > @@ -378,14 +379,19 @@ static int move_nodes(struct ubifs_info *c, struct ubifs_scan_leb *sleb) > */ > break; > > + ubifs_shash_update(c, c->jheads[GCHD].log_hash, > + snod->node, snod->len); > + > err = move_node(c, sleb, snod, wbuf); > if (err) > goto out; > + moved = 1; > } > > /* Move non-data nodes */ > list_for_each_entry_safe(snod, tmp, &nondata, list) { > - avail = c->leb_size - wbuf->offs - wbuf->used; > + avail = c->leb_size - wbuf->offs - wbuf->used - > + ubifs_auth_node_sz(c); > if (avail < min) > break; > > @@ -403,7 +409,32 @@ static int move_nodes(struct ubifs_info *c, struct ubifs_scan_leb *sleb) > continue; > } > > + ubifs_shash_update(c, c->jheads[GCHD].log_hash, > + snod->node, snod->len); > + > err = move_node(c, sleb, snod, wbuf); > + if (err) > + goto out; > + moved = 1; > + } > + > + if (ubifs_authenticated(c) && moved) { > + struct ubifs_auth_node *auth; > + > + auth = kmalloc(ubifs_auth_node_sz(c), GFP_NOFS); > + if (!auth) { > + err = -ENOMEM; > + goto out; > + } > + > + ubifs_prepare_auth_node(c, auth, > + c->jheads[GCHD].log_hash); ubifs_prepare_auth_node() does a crypto_shash_final(), check. But the overall "hash life cycle" is not 100% clear to me. For example, does move_nodes() assume that the hash is initialized or is it allowed that an crypto_shash_update() happened before? Thanks, //richard