From patchwork Mon Apr 11 18:15:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 8804911 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 114D19F3D1 for ; Mon, 11 Apr 2016 18:16:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 03C87202F8 for ; Mon, 11 Apr 2016 18:16:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0DBE520166 for ; Mon, 11 Apr 2016 18:16:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754551AbcDKSQI (ORCPT ); Mon, 11 Apr 2016 14:16:08 -0400 Received: from mail-pa0-f47.google.com ([209.85.220.47]:33899 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753703AbcDKSQG (ORCPT ); Mon, 11 Apr 2016 14:16:06 -0400 Received: by mail-pa0-f47.google.com with SMTP id ot11so42385645pab.1 for ; Mon, 11 Apr 2016 11:16:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=wAQO0ttKBA3srLKVbDE0yacXhtk5sQokUq+2HJ+SW3A=; b=flWii72Z5Vvdl2NgsktHzq0jiu+foLYeEZtBR+zKOJrXqZCHioslPzuv3QQh4L5LYN 418+vfiW+lLMCP5f7bwS2lLlEROh2UOSNv1RMMKezLRVujieND1N6wkIRlsoftsxVvk7 7Ff3ZLeH3GAm4X7/ow96yUaI25njPVJRKjQfwT6YUkwbK6/Nhydg+cl5wyfRLKN/K6bs aysdswabJZps/hUDBmZkEouo71J0r3XTuDB9cpcPOXWB+rYZN4+H0DgHI128dJxq+Nqq Vt+Lx/r0pLmO7Nmlzg/VQNGO0FVA3xR/M+yh449gXPaN/vP006bWJ4cZuwdAgfZKXrO+ 5RiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=wAQO0ttKBA3srLKVbDE0yacXhtk5sQokUq+2HJ+SW3A=; b=eYH9ZR52ucNhbiHpmdctZVo8jW02wLnNX8JExB6Hlv3hOBkzCXZwtDXHnNPBpvl4k6 DW2cyoL1ys63xt46SH/HjMmwQCuPBoIybfuxhgUNG3QvXwB8iwpHkzlrk48PantGFVOC OV7a5qWeMeVGFuNkz/JLkfecuamuMgdH9amYmEPoXk5utMc2BF9kkXsVJrQvqUW/oGZL Wj2CNnmwISSJkEZtsQK465vLq0Ro6Oko5UYYOTdy25W2Dz34ZB20BDAEPYUSoCwl8dYp WNosZj1LnUmMnH+E+STkX35s/Yv1s78ODGn4jQ5uNHd/x28do5PnCbtXYTCjN3Mcy851 LZpw== X-Gm-Message-State: AOPr4FWvouiOw+V61zsltHyGQNmBBt2x9+BnxOflIyt71lVl5NdtoVHMR5dH/B6UftWbAXJ+ X-Received: by 10.66.236.232 with SMTP id ux8mr22400698pac.145.1460398565885; Mon, 11 Apr 2016 11:16:05 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:200::b:2b53]) by smtp.gmail.com with ESMTPSA id u64sm37724709pfa.86.2016.04.11.11.16.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Apr 2016 11:16:05 -0700 (PDT) From: Omar Sandoval X-Google-Original-From: Omar Sandoval To: Al Viro Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, Omar Sandoval Subject: [PATCH v2 1/2] coredump: get rid of coredump_params->written Date: Mon, 11 Apr 2016 11:15:55 -0700 Message-Id: X-Mailer: git-send-email 2.8.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval cprm->written is redundant with cprm->file->f_pos, so use that instead. --- arch/powerpc/platforms/cell/spufs/coredump.c | 5 +++-- fs/binfmt_elf.c | 2 +- fs/binfmt_elf_fdpic.c | 2 +- fs/coredump.c | 8 +++----- include/linux/binfmts.h | 1 - 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/arch/powerpc/platforms/cell/spufs/coredump.c b/arch/powerpc/platforms/cell/spufs/coredump.c index be6212ddbf06..84fb984f29c1 100644 --- a/arch/powerpc/platforms/cell/spufs/coredump.c +++ b/arch/powerpc/platforms/cell/spufs/coredump.c @@ -137,6 +137,7 @@ static int spufs_arch_write_note(struct spu_context *ctx, int i, char *name; char fullname[80], *buf; struct elf_note en; + size_t skip; buf = (void *)get_zeroed_page(GFP_KERNEL); if (!buf) @@ -171,8 +172,8 @@ static int spufs_arch_write_note(struct spu_context *ctx, int i, if (rc < 0) goto out; - if (!dump_skip(cprm, - roundup(cprm->written - total + sz, 4) - cprm->written)) + skip = roundup(cprm->file->f_pos - total + sz, 4) - cprm->file->f_pos; + if (!dump_skip(cprm, skip)) goto Eio; out: free_page((unsigned long)buf); diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 81381cc0dd17..56224ffa94d2 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -2273,7 +2273,7 @@ static int elf_core_dump(struct coredump_params *cprm) goto end_coredump; /* Align to page */ - if (!dump_skip(cprm, dataoff - cprm->written)) + if (!dump_skip(cprm, dataoff - cprm->file->f_pos)) goto end_coredump; for (i = 0, vma = first_vma(current, gate_vma); vma != NULL; diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index 083ea2bc60ab..71ade0e556b7 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c @@ -1787,7 +1787,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) goto end_coredump; } - if (!dump_skip(cprm, dataoff - cprm->written)) + if (!dump_skip(cprm, dataoff - cprm->file->f_pos)) goto end_coredump; if (!elf_fdpic_dump_segments(cprm)) diff --git a/fs/coredump.c b/fs/coredump.c index 47c32c3bfa1d..9db0c514438e 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -782,7 +782,7 @@ int dump_emit(struct coredump_params *cprm, const void *addr, int nr) struct file *file = cprm->file; loff_t pos = file->f_pos; ssize_t n; - if (cprm->written + nr > cprm->limit) + if (pos + nr > cprm->limit) return 0; while (nr) { if (dump_interrupted()) @@ -791,7 +791,6 @@ int dump_emit(struct coredump_params *cprm, const void *addr, int nr) if (n <= 0) return 0; file->f_pos = pos; - cprm->written += n; nr -= n; } return 1; @@ -803,12 +802,11 @@ int dump_skip(struct coredump_params *cprm, size_t nr) static char zeroes[PAGE_SIZE]; struct file *file = cprm->file; if (file->f_op->llseek && file->f_op->llseek != no_llseek) { - if (cprm->written + nr > cprm->limit) + if (file->f_pos + nr > cprm->limit) return 0; if (dump_interrupted() || file->f_op->llseek(file, nr, SEEK_CUR) < 0) return 0; - cprm->written += nr; return 1; } else { while (nr > PAGE_SIZE) { @@ -823,7 +821,7 @@ EXPORT_SYMBOL(dump_skip); int dump_align(struct coredump_params *cprm, int align) { - unsigned mod = cprm->written & (align - 1); + unsigned mod = cprm->file->f_pos & (align - 1); if (align & (align - 1)) return 0; return mod ? dump_skip(cprm, align - mod) : 1; diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h index 576e4639ca60..39c6d6e1234e 100644 --- a/include/linux/binfmts.h +++ b/include/linux/binfmts.h @@ -64,7 +64,6 @@ struct coredump_params { struct file *file; unsigned long limit; unsigned long mm_flags; - loff_t written; }; /*