Message ID | 20200827114932.3572699-3-jannh@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <SRS0=mJtQ=CF=kvack.org=owner-linux-mm@kernel.org> Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA702722 for <patchwork-linux-mm@patchwork.kernel.org>; Thu, 27 Aug 2020 11:49:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A718322BF3 for <patchwork-linux-mm@patchwork.kernel.org>; Thu, 27 Aug 2020 11:49:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="EKUYAShS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A718322BF3 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C150B8E0010; Thu, 27 Aug 2020 07:49:49 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B78038E0006; Thu, 27 Aug 2020 07:49:49 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A17578E0010; Thu, 27 Aug 2020 07:49:49 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0177.hostedemail.com [216.40.44.177]) by kanga.kvack.org (Postfix) with ESMTP id 8813C8E0006 for <linux-mm@kvack.org>; Thu, 27 Aug 2020 07:49:49 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4CD4F2493 for <linux-mm@kvack.org>; Thu, 27 Aug 2020 11:49:49 +0000 (UTC) X-FDA: 77196179298.18.book20_38166422706c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id 18CC7100EC675 for <linux-mm@kvack.org>; Thu, 27 Aug 2020 11:49:49 +0000 (UTC) X-Spam-Summary: 1,0,0,9a9910d3aabf1838,d41d8cd98f00b204,3251hxwukcdybsffzyggydw.ugedafmp-eecnsuc.gjy@flex--jannh.bounces.google.com,,RULES_HIT:41:69:152:355:379:541:800:960:973:988:989:1260:1277:1313:1314:1345:1359:1437:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3152:3352:3865:3867:3868:3872:3874:4321:5007:6261:6653:7903:9969:10004:10400:11658:11914:12043:12296:12297:12555:12895:13069:13311:13357:14096:14097:14181:14394:14659:14721:21080:21444:21627:21990:30054,0,RBL:209.85.218.74:@flex--jannh.bounces.google.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04yrp4875st6twp4ftbanftejqwh6opmh9stjrzsgx6no5der1j4eaxgo3aoeom.wgjyyf9s81oicmxw3kn9basdjncwmu8fpwoeay7w8rpckzwryq7f6yjqbbx891k.w-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: book20_38166422706c X-Filterd-Recvd-Size: 4193 Received: from mail-ej1-f74.google.com (mail-ej1-f74.google.com [209.85.218.74]) by imf10.hostedemail.com (Postfix) with ESMTP for <linux-mm@kvack.org>; Thu, 27 Aug 2020 11:49:48 +0000 (UTC) Received: by mail-ej1-f74.google.com with SMTP id fy10so2492932ejb.9 for <linux-mm@kvack.org>; Thu, 27 Aug 2020 04:49:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=nVHuYaY9UtfQ5ceDG+IOgNARKDklUVVN28+71pW1fmk=; b=EKUYAShSuw6vIw45vevo+Sy7e72QAp73T544NA5kbUcsd1iV/LN/8R2GxzPOpqGvdX pdndWsVd6Lr3QZFGe4mTnAYNnlEb32APpoNqKM8a2Y00vZHJs04X7m3Rg2VxyGHiu8WB 8/ObYeSz7+0b4daA5rCvUagkfihi0oU2h2O/4pWpaAnFNKDROaYdPONQnUqQY9kfrvGP uKFQPWrcbMbQHbVYb3WZx3sPPDGERlRi8cAKR52YtrWMhsNQhVHjm12Y5jeYEQeQQlti ugA2ZkmaIpOOKUnnVGqvAI0YlxcaE3BBSdIcXjisRZIOt2eBY+4cKnwSl5+8CX5Ld5vK EnZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=nVHuYaY9UtfQ5ceDG+IOgNARKDklUVVN28+71pW1fmk=; b=AvT2OEGCuoUrhuPDKQQNLpylVZWK6OsVNr/bV/dQwzDDTpvH15YZ/Y/9QvC912K5k1 bETveJVM47k7ohG+D7L/4N9My7KtXdd2fIp1W2uEtXqiCzHRoqOPxy0d4oxobcT1uD0M 4z0LiVbJD8qBy31bxfP9tb7chgyHnTxmpdfrGeCuN3dz3mLvH5J9vAvejpUq/RP2R/TY nTkPwwpJ44kx1j8BJUmEfYZot85cLhde9/Ck/G7Za33TPWWH1sli4jVuLUYF+ckCsh/s H/yqo2QRcrGwR3t/Qoo5xb6+ZUBhuVyiBiewj3bQXKWrWmdr2W0SvRxrzCLp9laAgQgb AbYg== X-Gm-Message-State: AOAM532ufu5L/fK+OD6x6QAZrjzf9vL17iDX5v+IA5r5ApcJpCKt1hG2 e6133dj4v4ANW6Nr48KSItf6U812sQ== X-Google-Smtp-Source: ABdhPJy2EioBHl5DQHnC+VEIiLoSJ394iMXy3ZaLk8kxlGOGKXykgo5D+wC/Tp3lDGd7qD4rKXOJxasNpA== X-Received: from jannh2.zrh.corp.google.com ([2a00:79e0:1b:201:1a60:24ff:fea6:bf44]) (user=jannh job=sendgmr) by 2002:a17:906:dc03:: with SMTP id yy3mr21385084ejb.380.1598528987410; Thu, 27 Aug 2020 04:49:47 -0700 (PDT) Date: Thu, 27 Aug 2020 13:49:27 +0200 In-Reply-To: <20200827114932.3572699-1-jannh@google.com> Message-Id: <20200827114932.3572699-3-jannh@google.com> Mime-Version: 1.0 References: <20200827114932.3572699-1-jannh@google.com> X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog Subject: [PATCH v5 2/7] coredump: Let dump_emit() bail out on short writes From: Jann Horn <jannh@google.com> To: Andrew Morton <akpm@linux-foundation.org> Cc: Linus Torvalds <torvalds@linux-foundation.org>, Christoph Hellwig <hch@lst.de>, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Alexander Viro <viro@zeniv.linux.org.uk>, "Eric W . Biederman" <ebiederm@xmission.com>, Oleg Nesterov <oleg@redhat.com> Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 18CC7100EC675 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> |
Series |
Fix ELF / FDPIC ELF core dumping, and use mmap_lock properly in there
|
expand
|
diff --git a/fs/coredump.c b/fs/coredump.c index 76e7c10edfc0..5e24c06092c9 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -840,17 +840,17 @@ int dump_emit(struct coredump_params *cprm, const void *addr, int nr) ssize_t n; if (cprm->written + nr > cprm->limit) return 0; - while (nr) { - if (dump_interrupted()) - return 0; - n = __kernel_write(file, addr, nr, &pos); - if (n <= 0) - return 0; - file->f_pos = pos; - cprm->written += n; - cprm->pos += n; - nr -= n; - } + + + if (dump_interrupted()) + return 0; + n = __kernel_write(file, addr, nr, &pos); + if (n != nr) + return 0; + file->f_pos = pos; + cprm->written += n; + cprm->pos += n; + return 1; } EXPORT_SYMBOL(dump_emit);
dump_emit() has a retry loop, but there seems to be no way for that retry logic to actually be used; and it was also buggy, writing the same data repeatedly after a short write. Let's just bail out on a short write. Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Jann Horn <jannh@google.com> --- fs/coredump.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)