From mboxrd@z Thu Jan 1 00:00:00 1970 From: Oleg Nesterov Subject: Re: [RFC PATCH] coredump: fix incomplete core file created when dump_skip was used last Date: Thu, 23 Oct 2014 18:39:34 +0200 Message-ID: <20141023163934.GA31508@redhat.com> References: <1413932228-27642-1-git-send-email-victor.kamensky@linaro.org> <1413932228-27642-2-git-send-email-victor.kamensky@linaro.org> <20141022165530.GA30358@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Alexander Viro , linux-fsdevel@vger.kernel.org, Andrew Morton , Kees Cook , open list To: Victor Kamensky Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On 10/22, Victor Kamensky wrote: > > --- a/fs/coredump.c > +++ b/fs/coredump.c > @@ -664,6 +664,14 @@ void do_coredump(const siginfo_t *siginfo) > if (!dump_interrupted()) { > file_start_write(cprm.file); > core_dumped = binfmt->core_dump(&cprm); > + /* > + * If last operation was dump_skip with llseek, we need to > + * truncate file up to f_pos to match expected size. > + */ > + if (!ispipe && > + (cprm.file->f_pos > i_size_read(file_inode(cprm.file)))) > + do_truncate(cprm.file->f_path.dentry, > + cprm.file->f_pos, 0, cprm.file); > file_end_write(cprm.file); > } > if (ispipe && core_pipe_limit) > > May I use your name with Suggested-by tag? Sure, thanks ;) I'd suggest to add a simple helper, but I won't insist. And perhaps the caller can also check "core_dumped" along with !ispipe, but this is purely cosmetic. Oleg.