Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp849416imu; Sat, 15 Dec 2018 08:27:32 -0800 (PST) X-Google-Smtp-Source: AFSGD/U0sXAw6ltBcO+ZLc0b7gYRzd9jPxRN25uFzqHzQH6xnaUQmevO75qkRmW8ERpsM8k9i3dp X-Received: by 2002:a17:902:76cb:: with SMTP id j11mr7050961plt.179.1544891252850; Sat, 15 Dec 2018 08:27:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544891252; cv=none; d=google.com; s=arc-20160816; b=JjJLYjRHRTu0ppnuDXPxSIs+JnnY12WpUoNHNCmEM5yIWUhVZB8EiYwUsV6WJpJUdO QbeOJ5R8mck9yCIeD0WHv9ONR99hCzRNrB1ZlkMGEtxCk0LbA4xjhWGqfTUJt8s4v3Ve 9JV7Dgznl6X2TmNY61ePLN44LcnqE3XHdm3Wx5/OaszfETh5//e7wBqcsvLnKb7WpyDU V+TO9yN2oNUt5stgIck1u06jSAqqIrSC9EZbMVi5H3g1XkyzHcOfW8NM89wFut7CV+oJ f6xZ0UqlRmKYLrWHobYhbuT4nZtV6kWkxYEUjSrNdcXhj2opO6hihoKeprzq2D7jnmEz +2FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Ll6DKlz+gV9HZcW1/yQogsaTFyd6cGMOxBJQGEG1R48=; b=z4s4dQRRjAkr8fzkR1Iq1Rf6rF3z+p7WNub4jdF6EHiWzRmCy9dGAKeM1YtqclRvHP ey0/tKTKR2vMSyHtJ1BNzm7Y0Yi0iYaai1Olmtjehf503E4rxL5YlyWiDkmWNmpchO16 KNkL2NRVO6afqa7NN3uNtN1VV7nMD3aDkWo+dY9B9Q7sLdvFU6ekAeypwa2XqBOoIjFp 0ASWGsQvZKHnkYQkwzdQZYXLjNIl772oFAa+ORJBzhZmL/GHvjbY3e47nVzH+3Ck350g ZBXiyve4gLcuiRy2j2AfKakOvhV0xvlfqo4r0nkl8aW8VZOI8+3BQ3T2rJWYIZbmoSCs PFGQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b11si6796621pfo.240.2018.12.15.08.26.37; Sat, 15 Dec 2018 08:27:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730539AbeLOQX6 (ORCPT + 99 others); Sat, 15 Dec 2018 11:23:58 -0500 Received: from lilium.sigma-star.at ([109.75.188.150]:47270 "EHLO lilium.sigma-star.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730500AbeLOQX6 (ORCPT ); Sat, 15 Dec 2018 11:23:58 -0500 Received: from localhost (localhost [127.0.0.1]) by lilium.sigma-star.at (Postfix) with ESMTP id 5E03B1801377B; Sat, 15 Dec 2018 17:23:56 +0100 (CET) From: Richard Weinberger To: linux-mtd@lists.infradead.org Cc: linux-kernel@vger.kernel.org, dwmw2@infradead.org, Richard Weinberger , stable@vger.kernel.org Subject: [PATCH] jffs2: Fix integer underflow in jffs2_rtime_compress Date: Sat, 15 Dec 2018 17:23:50 +0100 Message-Id: <20181215162350.12489-1-richard@nod.at> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The rtime compressor assumes that at least two bytes are compressed. If we try to compress just one byte, the loop condition will wrap around and an out-of-bounds write happens. Cc: Signed-off-by: Richard Weinberger --- fs/jffs2/compr_rtime.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/jffs2/compr_rtime.c b/fs/jffs2/compr_rtime.c index 406d9cc84ba8..cbf700001fc9 100644 --- a/fs/jffs2/compr_rtime.c +++ b/fs/jffs2/compr_rtime.c @@ -39,6 +39,9 @@ static int jffs2_rtime_compress(unsigned char *data_in, =20 memset(positions,0,sizeof(positions)); =20 + if (*dstlen < 2) + return -1; + while (pos < (*sourcelen) && outpos <=3D (*dstlen)-2) { int backpos, runlen=3D0; unsigned char value; --=20 2.20.0