Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1148377imm; Mon, 9 Jul 2018 18:32:27 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcMgGiwJcIu+zeWoRIp+5G1JcZmOs4AnTMbeAfMNWH+MWC8T6PbZjrTqEmKSzYfu+Lirk43 X-Received: by 2002:a63:6243:: with SMTP id w64-v6mr16163494pgb.179.1531186347026; Mon, 09 Jul 2018 18:32:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531186346; cv=none; d=google.com; s=arc-20160816; b=ncgiAssqJiXGfN3PzuYffq0Poy7KjeA7EADXUfIeCn4TYpCX5OJ20MSQMyPrjboA8r vGpV3ucoQ7ZKoMcJYAcPmUcO1E9Sapy02Oa8DrXRCqFqoi3ZbJn/+pP+3Dixy4scwibt WMoH/FrXDankJMQgGX4rQbOze0kfBHxLsZK8UEOBJIqbaU0rosTp35UmbxnYIcCweNuv h9fGqqQZvTcrB5FshIdApAHkjZpwnUCMlCokgSgpN5f/pZpAw0+IXHvnm8YxdJABoYRt xImq4F2TxGongbt6AUoox9kqirqGDGp0EQLEw9cHtZFz6uOA33JepSDfbc8lZ3pV7z5D ETuw== 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:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=/Y6/qoJpuBsY9+o0u9gdaFDTmpYw75WorohqbxoraNA=; b=HITedbH7mEheHYuSq+Ueb2WMjRBHgpzKuuhiUGVhLv49iUmttdPA6HntaNNJNcP3Kh NToPMan3AO7QoLrYk2H4gwqpIEm7bRt4T2E4SvbVRLku2fnZ1yQrNTjaezBVWR8iZ7yr Lerw/LgRXJWVT8Piv6r0obb4A9+hIvDY1OyoThN1mh5JWbiBr6bgIjrWw26E4Nv4hLJB 8K269iLXz3YIW/iR8cX76/tqIzqgNzYCX3+d5t+3wy+Enr1csudGvBRaanFG3dcyyyes wMKWiJlmBwYLGLvvalyoUFtyfHMYNJ2627RrKrOiAE2et6vEgO3lDI07XbEhhq418uYw eEpQ== 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 w3-v6si3322031pgp.220.2018.07.09.18.32.11; Mon, 09 Jul 2018 18:32:26 -0700 (PDT) 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 S1754675AbeGJBb2 (ORCPT + 99 others); Mon, 9 Jul 2018 21:31:28 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:46370 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754597AbeGJBbX (ORCPT ); Mon, 9 Jul 2018 21:31:23 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 2FC62943FEBA; Tue, 10 Jul 2018 09:31:20 +0800 (CST) Received: from [10.177.253.249] (10.177.253.249) by smtp.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.382.0; Tue, 10 Jul 2018 09:31:18 +0800 Subject: Re: [V9fs-developer] [PATCH] p9_check_errors() validate PDU length To: Tomas Bortoli , , , References: <20180709224323.20597-1-tomasbortoli@gmail.com> CC: , , , , From: piaojun Message-ID: <5B440C5E.2040909@huawei.com> Date: Tue, 10 Jul 2018 09:31:10 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20180709224323.20597-1-tomasbortoli@gmail.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.253.249] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Tomas, On 2018/7/10 6:43, Tomas Bortoli wrote: > p9_check_errors() does not validate the size of the PDU read > in p9_parse_header(). Any size can be passed, provoking out-of-bound reads. > > Signed-off-by: Tomas Bortoli > Reported-by: syzbot+65c6b72f284a39d416b4@syzkaller.appspotmail.com > --- > As suggested by Dominique: > https://lkml.org/lkml/2018/7/9/688 > Such check is not enough as it will prevent to read more than how it has > been allocated but it won't prevent to read more than how it has been read > So this patch will require some more changes to prevent bad sizes. > > net/9p/client.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/net/9p/client.c b/net/9p/client.c > index 40f7c47f2f74..5b161b576b8a 100644 > --- a/net/9p/client.c > +++ b/net/9p/client.c > @@ -520,10 +520,13 @@ EXPORT_SYMBOL(p9_parse_header); > static int p9_check_errors(struct p9_client *c, struct p9_req_t *req) > { > int8_t type; > + int32_t size; > int err; > int ecode; > > - err = p9_parse_header(req->rc, NULL, &type, NULL, 0); > + err = p9_parse_header(req->rc, &size, &type, NULL, 0); > + if (size > req->rc->capacity) > + return -EINVAL; I think we should print some error logs here to remind uppper users. Thanks, Jun > /* > * dump the response from server > * This should be after check errors which poplulate pdu_fcall. >