From patchwork Fri Feb 19 00:32:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 8355161 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 41ACFC0554 for ; Fri, 19 Feb 2016 00:33:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6D803203F1 for ; Fri, 19 Feb 2016 00:33:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 769AD203EC for ; Fri, 19 Feb 2016 00:33:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2992554AbcBSAdV (ORCPT ); Thu, 18 Feb 2016 19:33:21 -0500 Received: from mail-pa0-f50.google.com ([209.85.220.50]:33452 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1948907AbcBSAdS (ORCPT ); Thu, 18 Feb 2016 19:33:18 -0500 Received: by mail-pa0-f50.google.com with SMTP id fl4so39990066pad.0 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=p4lcu+Wy2MzUlxXJIyBtBBwGbSYQ1vsqsSAiumPVGOk=; b=Iudx7xfQCe7mIkMYwNJo/HcZzV4RfGfjm+ZFn17IDvNWsmEiwKCBObxUTijCja+9ED fonr1tNXfJvxQiAX5vh+WGLE2h8358kRkRIvGEDCPOnbXnS9nHUtrW/sVxHPUsAmuFYS S/BLYYhp7dvBDGR0ApAuMVty8Rj5esDYwMs4xanbqJrAgsLuEahuRIjaofVGMEdnOFhm dc7mcI0FKq/yy9EtRRMPuGma1eg84ef0Q31VQG64ez7VqJQRwF15e1q2iAFKX8Yi9q4n z4cmsi+fP6XgMm234rmNEhJmf3SYJiL6quSA9pyAMCZ+kHG0YcGRc70kJCHguA8Id7c1 nuVA== 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=p4lcu+Wy2MzUlxXJIyBtBBwGbSYQ1vsqsSAiumPVGOk=; b=O4wUievyDu0n4FXD1cgkJ/vCwUFKQXXuWQ7ge37sof+HC0CT/tVDAB7+H6lWPfHMMQ qxWWvvm7QvWHimUjkhe0wKQmTDuRxI732+7Nb6HQYd9UpJ3Oq4qQDVLinGuiYwRZUSu2 yxzVfCnS0ed1VNz3WNr1te6teit7H3TYnj2GitZnQHOwj+WfA2BlqSoYl4I6DaL7ROJC R1fxZEBJHZ4ftOVZqAtSB9Ts61w4YmUL2VufXzvQpPHtUWiivHuJnsunCqQuBM3WJu/j 7GO9putbJsiA+KX59quGr+v9ve8/Dfks826bYw5fsIi2WuDd6ON+uqubUanUnHDqBcOr DNRw== X-Gm-Message-State: AG10YORMQEoTU7zruyrhlFVgsr1H3zEe4kL4ofjNAvNR76I4h+GHzRiv7WAptfVOR1W7yOCm X-Received: by 10.66.100.196 with SMTP id fa4mr14341922pab.37.1455841997572; Thu, 18 Feb 2016 16:33:17 -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.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Feb 2016 16:33:17 -0800 (PST) From: Omar Sandoval X-Google-Original-From: Omar Sandoval To: Al Viro Cc: linux-fsdevel@vger.kernel.org, Omar Sandoval Subject: [PATCH 2/2] coredump: only charge written data against RLIMIT_CORE Date: Thu, 18 Feb 2016 16:32:54 -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 Commit 9b56d54380ad ("dump_skip(): dump_seek() replacement taking coredump_params") introduced a regression with regard to RLIMIT_CORE. Previously, when a core dump was sparse, only the data that was actually written out would count against the limit. Now, the sparse ranges are also included, which leads to truncated core dumps when the actual disk usage is still well below the limit. Restore the old behavior by only counting what gets emitted and ignoring what gets skipped. Signed-off-by: Omar Sandoval --- fs/coredump.c | 5 ++--- include/linux/binfmts.h | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/coredump.c b/fs/coredump.c index dc9268bbd61b..8272bd511603 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 (pos + nr > cprm->limit) + if (cprm->written + nr > cprm->limit) return 0; while (nr) { if (dump_interrupted()) @@ -769,6 +769,7 @@ int dump_emit(struct coredump_params *cprm, const void *addr, int nr) if (n <= 0) return 0; file->f_pos = pos; + cprm->written += nr; nr -= n; } return 1; @@ -780,8 +781,6 @@ 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 (file->f_pos + nr > cprm->limit) - return 0; if (dump_interrupted() || file->f_op->llseek(file, nr, SEEK_CUR) < 0) return 0; diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h index 39c6d6e1234e..576e4639ca60 100644 --- a/include/linux/binfmts.h +++ b/include/linux/binfmts.h @@ -64,6 +64,7 @@ struct coredump_params { struct file *file; unsigned long limit; unsigned long mm_flags; + loff_t written; }; /*