From patchwork Fri May 18 22:24:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 8820 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 4D03723EB5 for ; Fri, 18 May 2012 22:26:08 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id 1D042A183D8 for ; Fri, 18 May 2012 22:26:08 +0000 (UTC) Received: by mail-yx0-f180.google.com with SMTP id q6so4104355yen.11 for ; Fri, 18 May 2012 15:26:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:date:from :to:cc:subject:message-id:references:mime-version:content-type :content-disposition:in-reply-to:user-agent:x-gm-message-state; bh=LG7V9yV3/wsuvbSN5hH2lJhA5rOAC/IrI08FiTchI/M=; b=pl+OjQUDgHC6mDs9ZN1GmfVnYwSGC3i892JNATbfSjKnZ/Kr0rQsHbA5j1nFblc6Wl 3MkykL3N4OGPtOyJZ+/TZQfdyZacuDqJFFAx1AQwuRfAo0NKNH5e/iSDutF3zdWZdJcD LdmZeOrGcy6Y6jsSWFXt4QhyqG6FaLCez19bmP6Pu+xT3CgbY+Ym0vFBl91MgAQowiwz a2xxCqpcSILX2zA42v0NtEfrOhmTY5652l8uRKd8ZbWx/x1mkmNILWndwxbTqs/DJvj+ tlgVNpkGFeeMTLBBcxLc8AcePNN0pM/ckhw5Pe+VOkFMC3aPw3lKAwF++xK0VpMhRFBL pYIw== Received: by 10.50.203.39 with SMTP id kn7mr1954094igc.53.1337379967605; Fri, 18 May 2012 15:26:07 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.35.72 with SMTP id o8csp135246ibd; Fri, 18 May 2012 15:26:07 -0700 (PDT) Received: by 10.68.201.9 with SMTP id jw9mr42616859pbc.88.1337379967012; Fri, 18 May 2012 15:26:07 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id qa10si17675425pbb.174.2012.05.18.15.26.06 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 18 May 2012 15:26:07 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) smtp.mail=anton.vorontsov@linaro.org Received: by mail-pb0-f50.google.com with SMTP id rr4so5393549pbb.37 for ; Fri, 18 May 2012 15:26:06 -0700 (PDT) Received: by 10.68.221.35 with SMTP id qb3mr43193301pbc.136.1337379966727; Fri, 18 May 2012 15:26:06 -0700 (PDT) Received: from localhost (c-71-204-165-222.hsd1.ca.comcast.net. [71.204.165.222]) by mx.google.com with ESMTPS id wo8sm14146689pbc.9.2012.05.18.15.26.04 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 18 May 2012 15:26:05 -0700 (PDT) Date: Fri, 18 May 2012 15:24:37 -0700 From: Anton Vorontsov To: Greg Kroah-Hartman , Kees Cook , Colin Cross , Tony Luck Cc: Arnd Bergmann , John Stultz , Shuah Khan , arve@android.com, Rebecca Schultz Zavin , Jesper Juhl , Randy Dunlap , Stephen Boyd , Thomas Meyer , Andrew Morton , Marco Stornelli , WANG Cong , linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, linaro-kernel@lists.linaro.org, patches@linaro.org, kernel-team@android.com Subject: [PATCH 04/14] pstore/ram: Should zap persistent zone on unlink Message-ID: <20120518222436.GD23089@lizard> References: <20120518222314.GA9425@lizard> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120518222314.GA9425@lizard> User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQnOZNorvWpNvMoPjDGLe/J/ae7ksaXRlB2qdpR9adXxtQ6Skp0lRWLP0u4U1X7m2r2YYeQ/ Otherwise, unlinked file will reappear on the next boot. Reported-by: Kees Cook Signed-off-by: Anton Vorontsov --- fs/pstore/ram.c | 1 + fs/pstore/ram_core.c | 6 ++++++ include/linux/pstore_ram.h | 1 + 3 files changed, 8 insertions(+) diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index 3a7724b..43d9727 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -186,6 +186,7 @@ static int ramoops_pstore_erase(enum pstore_type_id type, u64 id, return -EINVAL; persistent_ram_free_old(cxt->przs[id]); + persistent_ram_zap(cxt->przs[id]); return 0; } diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c index dff5127..28b6d7f 100644 --- a/fs/pstore/ram_core.c +++ b/fs/pstore/ram_core.c @@ -336,6 +336,12 @@ void persistent_ram_free_old(struct persistent_ram_zone *prz) prz->old_log_size = 0; } +void persistent_ram_zap(struct persistent_ram_zone *prz) +{ + atomic_set(&prz->buffer->size, 0); + persistent_ram_update_header_ecc(prz); +} + static void *persistent_ram_vmap(phys_addr_t start, size_t size) { struct page **pages; diff --git a/include/linux/pstore_ram.h b/include/linux/pstore_ram.h index 07d59b7..085199e 100644 --- a/include/linux/pstore_ram.h +++ b/include/linux/pstore_ram.h @@ -69,6 +69,7 @@ struct persistent_ram_zone * __init persistent_ram_new(phys_addr_t start, size_t size, bool ecc); void persistent_ram_free(struct persistent_ram_zone *prz); +void persistent_ram_zap(struct persistent_ram_zone *prz); struct persistent_ram_zone *persistent_ram_init_ringbuffer(struct device *dev, bool ecc);