From patchwork Fri Feb 19 00:32:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 8355171 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 693A49F399 for ; Fri, 19 Feb 2016 00:33:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 730B6203E9 for ; Fri, 19 Feb 2016 00:33:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6ECF9203F3 for ; Fri, 19 Feb 2016 00:33:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2992556AbcBSAdW (ORCPT ); Thu, 18 Feb 2016 19:33:22 -0500 Received: from mail-pa0-f45.google.com ([209.85.220.45]:34263 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1946981AbcBSAdR (ORCPT ); Thu, 18 Feb 2016 19:33:17 -0500 Received: by mail-pa0-f45.google.com with SMTP id fy10so39895899pac.1 for ; Thu, 18 Feb 2016 16:33:17 -0800 (PST) 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=lvuSPhNkAILmvnvI5U/HiKmW6eHzlsyT6lRGShEhtoM=; b=tZ5aph0+Yf9+gG/+A/Cz1a9Ae5rdJiUs+BmhwDggXKXL/n/jXYrFWmOAF3LkEfTIZF rHzIykazqQIqgA6ZC+CikKh45TnIilLIR0pCYJIXQoDIR07h3JhxHYm1n6SBu8g8pQL0 PuW+zk1ctH3ugPWiwFSNMizJiMMbLF4KAAGlVLIpQ2DBZ+HQaI1fcFjoShSvIC0CrIaa 3NVD2PLhvRvkosEe9KgDrcOOr9JTBEHY7wIRPcn58EDObTfKxXy4Vj2Qy2bO2m/WS0A/ TmaYyewP51WnKga9b9IktexSsqm75zDaCTfceAhW8fRUjCrHNBo63dElgSNO8boPj8nw GUvA== 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=lvuSPhNkAILmvnvI5U/HiKmW6eHzlsyT6lRGShEhtoM=; b=Sgk92n5gyl/x3hdDYSbG9xkfzVyi3zGUADjjOJuX5k0MpnIvho3Bv3zOCsbT27/swg esnK/l/ExkGrl9jCnAGsfS41g4l0M+wBSbxVEoGZ6vGJngX2M/JwVvZstFJG4lJmzdNU RuGAFwOv2oab0M0NZvf9fEOlXHQ74cxKaDkY8vYHxBUWUSiwSAUIggpKWWJ8cvvXywuG cuxOIayJC0guwuYcTp/bAGpSnR0TzKQb880pJjc1MWzC2coomz8PVzoW88I47riH/vsl nROT7LoAumgKVHrZSv8GmAc3Ge7PlKiSbDHGr00VPTI86+oIRn7WJGWWCQ6fZr7cfGFi I/ew== X-Gm-Message-State: AG10YOR+mKOBmvaXP0CJ5u6GpcYfpTsT25I1MJh6/DlBj//pHBGo0zBupPx+Gqy4gAloLXLt X-Received: by 10.66.189.201 with SMTP id gk9mr14261192pac.19.1455841996733; Thu, 18 Feb 2016 16:33:16 -0800 (PST) Received: from vader.thefacebook.com ([2620:10d:c090:200::adf9]) by smtp.gmail.com with ESMTPSA id g25sm13010884pfg.35.2016.02.18.16.33.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Feb 2016 16:33:16 -0800 (PST) From: Omar Sandoval X-Google-Original-From: Omar Sandoval To: Al Viro Cc: linux-fsdevel@vger.kernel.org, Omar Sandoval Subject: [PATCH 1/2] coredump: get rid of coredump_params->written Date: Thu, 18 Feb 2016 16:32:53 -0800 Message-Id: X-Mailer: git-send-email 2.7.1 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=-6.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. Signed-off-by: Omar Sandoval --- 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 051ea4809c14..db2c784bb676 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 9ea87e9fdccf..dc9268bbd61b 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -760,7 +760,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()) @@ -769,7 +769,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; @@ -781,12 +780,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) { @@ -801,7 +799,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; }; /*