[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1465847065-3577-10-git-send-email-toiwoton@gmail.com>
Date: Mon, 13 Jun 2016 22:44:16 +0300
From: Topi Miettinen <toiwoton@...il.com>
To: linux-kernel@...r.kernel.org
Cc: Topi Miettinen <toiwoton@...il.com>,
Alexander Viro <viro@...iv.linux.org.uk>,
linux-fsdevel@...r.kernel.org (open list:FILESYSTEMS (VFS and
infrastructure))
Subject: [RFC 09/18] limits: track RLIMIT_CORE actual max
Track maximum size of core dump written, presented in /proc/self/limits.
Signed-off-by: Topi Miettinen <toiwoton@...il.com>
---
fs/coredump.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/fs/coredump.c b/fs/coredump.c
index 281b768..abedc99 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -784,20 +784,25 @@ 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;
+ int r = 0;
+
if (cprm->written + nr > cprm->limit)
return 0;
while (nr) {
if (dump_interrupted())
- return 0;
+ goto err;
n = __kernel_write(file, addr, nr, &pos);
if (n <= 0)
- return 0;
+ goto err;
file->f_pos = pos;
cprm->written += n;
cprm->pos += n;
nr -= n;
}
- return 1;
+ r = 1;
+ err:
+ bump_rlimit(RLIMIT_CORE, cprm->written);
+ return r;
}
EXPORT_SYMBOL(dump_emit);
--
2.8.1
Powered by blists - more mailing lists