Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3066028imu; Sun, 9 Dec 2018 16:29:41 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vopu+8ljQVsjOmHKtb2vwBTJAeRZ98dOBBeuPpaRdnQaso/+NVya2Xzt8FJu8heq7a1RJs X-Received: by 2002:a63:f552:: with SMTP id e18mr9133581pgk.239.1544401781480; Sun, 09 Dec 2018 16:29:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544401781; cv=none; d=google.com; s=arc-20160816; b=VF565j/Rkkw8r3w19jEn6aQ8nbrRTDi2fYWjtTtyyYlvaQpejnN2FiCnQrk/rfGKCR MpoQ5Qv/tS3tHIDkxYSaKvpk1ZPEusZitM93iix9zOebSTf7DX5AThGos0zTcXPaGXog Cfl85vToHpZej0psKa/i0pdv5otyBVRXG0zWvTQR9DX4O1r4g18kKdnKJzJkBmNRFl+K X9cd53Raxs1L+PxU+rFLpRMWEMf9lN9AuK61LtnZZLQuaIsMfOltSjRw/hAmrWEW3+Uo QEwrwa5o6iLkZNIVSDGjrjZ4sWh9ZERwq+Ow9yszTiAiQUJZLV/eMPq1Zp2TkAJUnlJo HkVA== 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:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=/YjXXUTx74DLDhtl7oIR6g62qO9wtXMfD0WLz7Lgfng=; b=dDEtqUkBAIoMoyf9GwkefkwUqsH+pwcValXAsR6A3upqAYKwQsCnGEfSgSUqnTmbby ivu7XWZMHjtZdn57nD+1EbhSS/ZsSYf7vjTMyBlR/JwYTvjNIUKfV25Qz0ZC0vuDYFH2 PB/8E85PrlL8MCiH7vD4BIFG0ptTpdZUSfW+QVBGSZu2LZHGoh2TpMB7dbXGJPXFO4S8 fCd6wlf0Obri7bwI7mMGs8d+laPLI25Fy3UuAPUYvf2zoursyLvaUYaZbMn2/7o+tETl a3Jmak2hTHSRvaGgS8wNa5kFGBxYxkC85bp20aIT+3RTCajQxsyibXgZjQLA496bjSAb tXMg== 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 z67si9021777pfb.268.2018.12.09.16.29.26; Sun, 09 Dec 2018 16:29:41 -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 S1728098AbeLIWJc (ORCPT + 99 others); Sun, 9 Dec 2018 17:09:32 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:37430 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727045AbeLIWJa (ORCPT ); Sun, 9 Dec 2018 17:09:30 -0500 Received: from pub.yeoldevic.com ([81.174.156.145] helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gW73F-0002ir-H9; Sun, 09 Dec 2018 21:55:49 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gW72d-0003Ns-9S; Sun, 09 Dec 2018 21:55:11 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Dan Carpenter" , "Jun Piao" , "jiangyiwen" , "Dominique Martinet" Date: Sun, 09 Dec 2018 21:50:33 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 132/328] 9p/virtio: fix off-by-one error in sg list bounds check In-Reply-To: X-SA-Exim-Connect-IP: 81.174.156.145 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.62-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: jiangyiwen commit 23cba9cbde0bba05d772b335fe5f66aa82b9ad19 upstream. Because the value of limit is VIRTQUEUE_NUM, if index is equal to limit, it will cause sg array out of bounds, so correct the judgement of BUG_ON. Link: http://lkml.kernel.org/r/5B63D5F6.6080109@huawei.com Signed-off-by: Yiwen Jiang Reported-By: Dan Carpenter Acked-by: Jun Piao Signed-off-by: Dominique Martinet Signed-off-by: Ben Hutchings --- net/9p/trans_virtio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/net/9p/trans_virtio.c +++ b/net/9p/trans_virtio.c @@ -193,7 +193,7 @@ static int pack_sg_list(struct scatterli s = rest_of_page(data); if (s > count) s = count; - BUG_ON(index > limit); + BUG_ON(index >= limit); /* Make sure we don't terminate early. */ sg_unmark_end(&sg[index]); sg_set_buf(&sg[index++], data, s); @@ -239,6 +239,7 @@ pack_sg_list_p(struct scatterlist *sg, i s = rest_of_page(data); if (s > count) s = count; + BUG_ON(index >= limit); /* Make sure we don't terminate early. */ sg_unmark_end(&sg[index]); sg_set_page(&sg[index++], pdata[i++], s, data_off);