From patchwork Fri Apr 1 18:45:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 8727091 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 724159FC82 for ; Fri, 1 Apr 2016 18:46:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 713872039D for ; Fri, 1 Apr 2016 18:46:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6D02B203A1 for ; Fri, 1 Apr 2016 18:46:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751882AbcDASq3 (ORCPT ); Fri, 1 Apr 2016 14:46:29 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:33607 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751479AbcDASpy (ORCPT ); Fri, 1 Apr 2016 14:45:54 -0400 Received: by mail-pa0-f50.google.com with SMTP id zm5so97360844pac.0 for ; Fri, 01 Apr 2016 11:45:54 -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=toxE2ayzKpe6lZbBNr/jFkFwPL0zCpu5Mr1ct77lk0o=; b=eqc5G0Y4pia3z3zYw4//Uj0MTQVBtMiUMdaMZFaG2YJOxMZDe++E+YVJ2VpwnYUI6E nane4o8hk84oXpBLhqH0vJx8Vl7tM5BsOI59Sqqsa+xlTZCF7zio7f+7PR/WEZ0GRF73 puEBz6G2DaDRpY4EtVaEeviByViMjs9gRQZslV9G0gzXTBph5TCYaYWeJYkuYzBIx9+Y z1RC7ljfPFa0M81Xa8irj9FfTrudmtd9vksB8H4JBdGiFjVrunxCGAgx8qMUBmqNU8yJ CCuXZ6L7iG3guG9S2+CpQxCueCinmB3YOkUma3aEJSdijrRIKRpDn5fLu4qyfOrIg9DN cwyw== 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=toxE2ayzKpe6lZbBNr/jFkFwPL0zCpu5Mr1ct77lk0o=; b=WlCIgwavwJ2LLQNtuEzBfo+FjiOrAhAoZPPlKkypl7Jjd54Jh/SdBaBVnkxBxV0ku0 cf7BPEmFKiDpE4cqVshRoTdu7AWkfW3qWXAytJgIQ/zw9hEzGdfTNPC1A1NXsOdjyKBu XYG6klRPQTY72lAmhE6RkR04Eneu/MgcoPzlLZeRLMjBcvYq7nsY/jZIyPpW4I3u3Khp JlrDbH3OgDEe695wyQ/oaTuUzW2ua7uz23rCp1Y7sggjnGslcp6rLw3HL14VqRjPfhoZ vTYoQt/Ly5xZHQrI3x7TfjWEHtOH2f6MBuVlkvI0ZBvI81gTV+KOEKxVekzEvRxQm2rs p/tg== X-Gm-Message-State: AD7BkJL86pwVdvEJ9U68Ze4IcBEFjpxV1W4iMans7Q8Bc1w1Td2HkLC88iXguRRk80R/3Dzh X-Received: by 10.66.190.229 with SMTP id gt5mr33378387pac.118.1459536353971; Fri, 01 Apr 2016 11:45:53 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:200::8:103a]) by smtp.gmail.com with ESMTPSA id g70sm21627401pfj.13.2016.04.01.11.45.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 01 Apr 2016 11:45:53 -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 RESEND 1/2] coredump: get rid of coredump_params->written Date: Fri, 1 Apr 2016 11:45:15 -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=ham 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 7d914c67a9d0..f5ce8f4e00b0 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 b1adb92e69de..8cfde2482468 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; }; /*