Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3446242rwb; Mon, 3 Oct 2022 15:24:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM440zmyYZ8jvGO0MisWXnWyjQmWSgj+rgXtEGeMLi9xSndrtk2FDqIwupDdf3EzZm0wJaEX X-Received: by 2002:a17:906:cc0d:b0:77a:c170:3019 with SMTP id ml13-20020a170906cc0d00b0077ac1703019mr16457771ejb.253.1664835870428; Mon, 03 Oct 2022 15:24:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664835870; cv=none; d=google.com; s=arc-20160816; b=WlX+hrysVDxfOqmCuMah97d4N9kwtUHym/XMVgQkDbIeTdOaYjpMrxqqyJQgC183Np DoK9aG4gANFs67QDDC43wr35m4QVEJGpzxNa2Zlk4MaKZOEX+5XMn5ONrsicI6xP17aU EnyI9BncVIzbs2cOjdZMf99nYXUd5ihhj/gvlGSrjPctUOZDLy0G7Npl06uo01zlYC2y UIUcjausCURaz7Zbk3/A19dyDKKrjM2T1rkOK4zc//4xiYxp2e8xrwalz0qeNPOGGCNk JiP9bbWWdmag1GW9TocrvpxmO8ED9JZKtP4ylQfptSH+H1j4DnV7VTxefmVmBDTEdJmN yykw== 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 :dkim-signature; bh=TGwU/N4a47sP6hsnMoQt2nlieeLBUyOBUKzXe25Fmd8=; b=q6oyJCJc4o7Wr3c16o7OKNB6tgUghX1EsVesivVQVEQAmdOoz7TfzqD7SDom8Fg3E+ I724F6+kTbL9pa0hxCgSorx4RKu8rdAIoMKFH/IeD629d+RSuHGqKYc91A22npa7VCMR LNPkQDuLO1G+jgQDnliIErJODbriO9HFPnBzZwnvjtMMVZmDRU1DlH7jx6lfCOyMTMPK aXU/KOIghZ4pI3c0A+n4ouqO4ueVjAw7l3vpjLSz7Hx/nc56bwR+7FmHh0DOOwE9ipVw FoSBubku7kIQq+xXkC/vbnWvMKrO58FNwSf3n5XXyIahI9Cq0qDE3wgfbZV58OQSg1K3 5hdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=fFw+XTHe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q22-20020a170906771600b007807e1ea26csi8833655ejm.637.2022.10.03.15.24.05; Mon, 03 Oct 2022 15:24:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=fFw+XTHe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229522AbiJCWSz (ORCPT + 99 others); Mon, 3 Oct 2022 18:18:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229676AbiJCWSp (ORCPT ); Mon, 3 Oct 2022 18:18:45 -0400 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [IPv6:2a03:a000:7:0:5054:ff:fe1c:15ff]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 887F64DB0A; Mon, 3 Oct 2022 15:18:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=TGwU/N4a47sP6hsnMoQt2nlieeLBUyOBUKzXe25Fmd8=; b=fFw+XTHeOH4hxjGeac0A2pkwHG aYcQ8iZUbeQf54nPaVlUO8rvJH25YaWdqKR2uAc2MOMh4fqA8u5bi3Cj44OjaT+/NgA4mXw0EMdk/ ek4ZPbUfOJebBjTBfjOXarM0Kfcv/SSkCLvf4KBFakesWcezvq7ehClYpSU5Wg4PLqpzpH0/2dsec IAavQe+CifzMQgD628CM50oEhIphcoRiz66pn08uwNfOPrPjaVt5ioXaW+ZBnkOS33TxQ5MCaL1sl +rv94sr4yzPq/FjPOMWqYwOgfOcGjTbwLL4JmmiJOcvCUCyFTKGE3rVYaZUxRjMfSd4ZK1AXNLNGC huGcis7Q==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1ofTll-006clE-2F; Mon, 03 Oct 2022 22:18:37 +0000 Date: Mon, 3 Oct 2022 23:18:37 +0100 From: Al Viro To: Ira Weiny Cc: "J. R. Okajima" , Linus Torvalds , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH][CFT] [coredump] don't use __kernel_write() on kmap_local_page() Message-ID: References: <7714.1664794108@jrobl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 03, 2022 at 12:31:36PM -0700, Ira Weiny wrote: > On Mon, Oct 03, 2022 at 07:48:28PM +0900, J. R. Okajima wrote: > > Ira Weiny: > > > On Wed, Sep 28, 2022 at 07:29:43PM +0100, Al Viro wrote: > > > > On Tue, Sep 27, 2022 at 11:51:17PM +0100, Al Viro wrote: > > > > > [I'm going to send a pull request tomorrow if nobody yells; > > > > > please review and test - it seems to work fine here, but extra > > > > > eyes and extra testing would be very welcome] > > > > I tried gdb backtrace 'bt' command with the new core by v6.0, and it > > doesn't show the call trace correctly. Is it related to this commit? > > > > Are you also getting something like this? > > BFD: warning: /mnt/9p/test-okajima/core is truncated: expected core file size >= 225280, found: 76616 > > I did not see that before. I'm running through this patch vs a fix to > kmap_to_page()[1] and I may have gotten the 2 crossed up. So I'm retesting > with your test below. Argh.... Try this: fix coredump breakage caused by badly tested "[coredump] don't use __kernel_write() on kmap_local_page()" Let me count the ways I'd screwed up: * when emitting a page, handling of gaps in coredump should happen before fetching the current file position. * fix for problem that occurs on rather uncommon setups (and hadn't been observed in the wild) sent very late in the cycle. * ... with badly insufficient testing, introducing an easily reproducable breakage. Without giving it time to soak in -next. Fucked-up-by: Al Viro Fixes: 06bbaa6dc53c "[coredump] don't use __kernel_write() on kmap_local_page()" Signed-off-by: Al Viro --- diff --git a/fs/coredump.c b/fs/coredump.c index 1ab4f5b76a1e..3538f3a63965 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -841,7 +841,7 @@ static int dump_emit_page(struct coredump_params *cprm, struct page *page) }; struct iov_iter iter; struct file *file = cprm->file; - loff_t pos = file->f_pos; + loff_t pos; ssize_t n; if (cprm->to_skip) { @@ -853,6 +853,7 @@ static int dump_emit_page(struct coredump_params *cprm, struct page *page) return 0; if (dump_interrupted()) return 0; + pos = file->f_pos; iov_iter_bvec(&iter, WRITE, &bvec, 1, PAGE_SIZE); n = __kernel_write_iter(cprm->file, &iter, &pos); if (n != PAGE_SIZE)