Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4498044pxb; Sun, 14 Feb 2021 12:40:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJyclZR9u+o4gKwbt0Opo5hX8PGatVb4ia8vwYwN7iQyo55wSzmXH/SoXmTJVieYiPbMN01M X-Received: by 2002:aa7:c312:: with SMTP id l18mr10216647edq.278.1613335218838; Sun, 14 Feb 2021 12:40:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613335218; cv=none; d=google.com; s=arc-20160816; b=NLFhdMDPgXWLeB/up2ELWsemFZz89YWe2au9f9csx1YdTL0jk2z3JvDSolW5dG8HXn L8n4fmTYR1jy6KJ29M86n1vL6ZSZBmRw96L9LvPYzAhyYN9UxRDZN9qG4EcUdS5HAqHC f+AvKyCyv+eVJc2kr6wZ2mFOrpMsz6WMH13SvFxbz5LZSvv3opHY0LQmwi0obgWpLna4 5FhQoksZTognu/t5Y8eBryGLOPVXmVkkNLjmao5wH/+wipLvz7Ty8FNYP1iig6iRpAIB TSojRxMuk9sMVtI6JeRmJr/Vyb+e7O99EXU/Q7ZsQQv/Pi0yAVdPP3POwZs2sVbvDESF uWMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=63jqwq6fHhNATc3nWcmyOxp5af4ACrljiD5G2XiBHDU=; b=wQOllPD7pGdhYbO0MyQ0Tspt9gde8BouoC+BYcBKjaL8O4rB6Kh2p/JrXqaVfS82G8 2dj2Vjxk42EJuc+fqcRSbYBQxFkqg9+rGb4cT68MpC3opDKpiMr2HqDIao8DLILHUYE0 1bKzmjRJ9yTqNCoe8YJ5cM6Hx3qx1WvUvZUMTMhRenjcEZl4C9VJ+5MYzG5/tHxIclI3 z/zUPRS0WGV7w6evptso2ChlKngzCvjn5C/uMZj5OXd3jv8cUVoetVLilbSPvSDIhN2i ub4uDs4hFkE3oxXAN758EaAsbc5b0sGdeNCa8fnrhLVucqnli9ZYTsE/PEA9Gw5IqPhM c22Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j12si10779926ejt.34.2021.02.14.12.38.43; Sun, 14 Feb 2021 12:40:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229839AbhBNT4b (ORCPT + 99 others); Sun, 14 Feb 2021 14:56:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229772AbhBNT43 (ORCPT ); Sun, 14 Feb 2021 14:56:29 -0500 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 691A8C061574 for ; Sun, 14 Feb 2021 11:55:49 -0800 (PST) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94 #2 (Red Hat Linux)) id 1lBNU0-00DzCn-JC; Sun, 14 Feb 2021 19:55:04 +0000 Date: Sun, 14 Feb 2021 19:55:04 +0000 From: Al Viro To: Naresh Kamboju Cc: Arnd Bergmann , open list , Linux-Next Mailing List , LTP List , lkft-triage@lists.linaro.org, chrubis , Jan Stancek , Stephen Rothwell , Arnd Bergmann , "Eric W. Biederman" , Christian Brauner , Kees Cook , Peter Xu , Andrew Morton , Petr Vorel , Richard Palethorpe , Joerg.Vehlow@aox-tech.de Subject: Re: LTP: madvise08.c:203: TFAIL: No sequence in dump after MADV_DODUMP. Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 25, 2021 at 10:01:48PM +0530, Naresh Kamboju wrote: > commit 8a3cc755b13808eba74846dfd1033fcbc21f9a65 > Author: Al Viro > Date: Sun Mar 8 09:16:37 2020 -0400 > > coredump: don't bother with do_truncate() > > have dump_skip() just remember how much needs to be skipped, > leave actual seeks/writing zeroes to the next dump_emit() > or the end of coredump output, whichever comes first. > And instead of playing with do_truncate() in the end, just > write one NUL at the end of the last gap (if any). > > Signed-off-by: Al Viro > > fs/binfmt_elf.c | 1 - > fs/coredump.c | 56 +++++++++++++++++++++++++++--------------------- > include/linux/binfmts.h | 1 + > include/linux/coredump.h | 1 - > > > Test case output link, > https://lkft.validation.linaro.org/scheduler/job/2184975#L1369 > https://lkft.validation.linaro.org/scheduler/job/2184972#L1358 I think I see what's going on. Could you check if the following fixes your reproducer? diff --git a/arch/powerpc/platforms/cell/spufs/coredump.c b/arch/powerpc/platforms/cell/spufs/coredump.c index 60b5583e9eaf..1a587618015c 100644 --- a/arch/powerpc/platforms/cell/spufs/coredump.c +++ b/arch/powerpc/platforms/cell/spufs/coredump.c @@ -149,8 +149,7 @@ static int spufs_arch_write_note(struct spu_context *ctx, int i, return -EIO; } - if (!dump_skip(cprm, roundup(cprm->pos - ret + sz, 4) - cprm->pos)) - return -EIO; + dump_skip_to(cprm, roundup(cprm->pos - ret + sz, 4)); return 0; } diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 66137d5dca5f..474a3c7dd5ce 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -2267,8 +2267,7 @@ static int elf_core_dump(struct coredump_params *cprm) goto end_coredump; /* Align to page */ - if (!dump_skip(cprm, dataoff - cprm->pos)) - goto end_coredump; + dump_skip_to(cprm, dataoff); for (i = 0; i < vma_count; i++) { struct core_vma_metadata *meta = vma_meta + i; diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index be4062b8ba75..01f043971644 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c @@ -1640,8 +1640,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) goto end_coredump; } - if (!dump_skip(cprm, dataoff - cprm->pos)) - goto end_coredump; + dump_skip_to(cprm, dataoff); if (!elf_fdpic_dump_segments(cprm, vma_meta, vma_count)) goto end_coredump; diff --git a/fs/coredump.c b/fs/coredump.c index 27a93f724251..bfac7422cd14 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -894,7 +894,14 @@ int dump_emit(struct coredump_params *cprm, const void *addr, int nr) } EXPORT_SYMBOL(dump_emit); -int dump_skip(struct coredump_params *cprm, size_t nr) +void dump_skip_to(struct coredump_params *cprm, unsigned long pos) +{ + cprm->to_skip = pos - cprm->pos; + return 0; +} +EXPORT_SYMBOL(dump_skip_to); + +void dump_skip(struct coredump_params *cprm, size_t nr) { cprm->to_skip += nr; return 0; @@ -925,11 +932,11 @@ int dump_user_range(struct coredump_params *cprm, unsigned long start, stop = !dump_emit(cprm, kaddr, PAGE_SIZE); kunmap(page); put_page(page); + if (stop) + return 0; } else { - stop = !dump_skip(cprm, PAGE_SIZE); + dump_skip(cprm, PAGE_SIZE); } - if (stop) - return 0; } return 1; } @@ -940,7 +947,9 @@ int dump_align(struct coredump_params *cprm, int align) unsigned mod = (cprm->pos + cprm->to_skip) & (align - 1); if (align & (align - 1)) return 0; - return mod ? dump_skip(cprm, align - mod) : 1; + if (mod) + cprm->to_skip += align - mod; + return 1; } EXPORT_SYMBOL(dump_align); diff --git a/include/linux/coredump.h b/include/linux/coredump.h index 806d7f87d16a..78fcd776b185 100644 --- a/include/linux/coredump.h +++ b/include/linux/coredump.h @@ -23,7 +23,8 @@ extern unsigned int core_pipe_limit; * functions to write out all the necessary info. */ struct coredump_params; -extern int dump_skip(struct coredump_params *cprm, size_t nr); +extern void dump_skip_to(struct coredump_params *cprm, unsigned long to); +extern void dump_skip(struct coredump_params *cprm, size_t nr); extern int dump_emit(struct coredump_params *cprm, const void *addr, int nr); extern int dump_align(struct coredump_params *cprm, int align); int dump_user_range(struct coredump_params *cprm, unsigned long start,