From patchwork Mon May 29 23:18:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timofey Titovets X-Patchwork-Id: 9753711 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 600C260390 for ; Mon, 29 May 2017 23:18:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3AC5827853 for ; Mon, 29 May 2017 23:18:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 21E9126E49; Mon, 29 May 2017 23:18:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2B8026E40 for ; Mon, 29 May 2017 23:18:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751146AbdE2XSg (ORCPT ); Mon, 29 May 2017 19:18:36 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35434 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751050AbdE2XSd (ORCPT ); Mon, 29 May 2017 19:18:33 -0400 Received: by mail-wm0-f67.google.com with SMTP id g15so21108750wmc.2 for ; Mon, 29 May 2017 16:18:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cGogOVQUY01HBa8Ih5DGPgBZQklokf0DM0Qdbri58tk=; b=bLYmAbFsK4YcctoPaDRHRuzWZit9lyYz7WvXHaMgklbUkFG29+esmv8qga8LUhc+iQ Hrr6n0dIZT5VPf3BC95HdPQMec3ZeQhhlbvpvNx3Wy8/WgkV1mfo78fOz1W5ZN9Rimax ruRMDf+DebuYfUgpbmXBErgIzmIqFiwLt6iryTNt1INVBuZH1Yfjfv3VyPHWyuRg1rSm CBUb2MDj1pm50qiIF12JVEyRNVtveWpbSmy2DFbZkv8YzmopZekLWcMEEUR4U7KUpe7T urugua8LwlKfwcfDopjBi/aEKlrbELkimEXRKS68zwSK35k6jnoCyFWn2Yuqq4RrqUqs hbkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cGogOVQUY01HBa8Ih5DGPgBZQklokf0DM0Qdbri58tk=; b=smLzRn1A8+AhZWACkoK+5OB5MC6SED+3Wt7iej/mGq1Vv4ToYa9TWZSjJIJP+Yjdas hA1x1YuTH3ev/TzNoic9xInJfSrlnVkuax0Vtj7yfcLHvgSasj05O7XjD3RQLvDrJ/kW cgYW66XOX+J+rPMIAIjp+oNkPELNDzw0DC5P+co7tTDMDHIeWJogRnOwnquYQgev0VBR SGtY/d33dRfF0UytZU0bQsMXKjQ5K7Jo409sRbW23FoI4f7SY/JmrQBrdh26+kYq2XoX j/F2hx8GYSuWbQirWQRfQssX50jEg7o+5/uQMVzy+1XKlR1Q7eTibE3LHuMyqkiP0KjE 004g== X-Gm-Message-State: AODbwcBXSTg9Q+FigJnFOogQfEZfeFH5/d9234BotSzS1wMx+k4Um4R+ DY7GgEsu40/fcfm3 X-Received: by 10.28.182.195 with SMTP id g186mr13752750wmf.51.1496099911810; Mon, 29 May 2017 16:18:31 -0700 (PDT) Received: from localhost.localdomain ([91.215.176.151]) by smtp.gmail.com with ESMTPSA id l190sm15380953wmb.18.2017.05.29.16.18.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 May 2017 16:18:31 -0700 (PDT) From: Timofey Titovets To: linux-btrfs@vger.kernel.org Cc: Timofey Titovets Subject: [PATCH v5 1/2] Btrfs: lzo.c - compressed data size must be less then input size Date: Tue, 30 May 2017 02:18:04 +0300 Message-Id: <20170529231805.4797-2-nefelim4ag@gmail.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170529231805.4797-1-nefelim4ag@gmail.com> References: <20170529231805.4797-1-nefelim4ag@gmail.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Logic already return error if compression make data bigger, let's sync logic with zlib and also return error if compressed size are equal to input size Signed-off-by: Timofey Titovets Reviewed-by: David Sterba --- fs/btrfs/lzo.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.13.0 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c index f48c8c14..f66691e0 100644 --- a/fs/btrfs/lzo.c +++ b/fs/btrfs/lzo.c @@ -229,8 +229,10 @@ static int lzo_compress_pages(struct list_head *ws, in_len = min(bytes_left, PAGE_SIZE); } - if (tot_out > tot_in) + if (tot_out >= tot_in) { + ret = -E2BIG; goto out; + } /* store the size of all chunks of compressed data */ cpage_out = kmap(pages[0]);