Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp505imm; Tue, 10 Jul 2018 19:29:08 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfSd6Fmi0QRCdMZXM4xdgycJVDK/UT6uDnA2YQBlgIMkR5zMcknpzexImqwPd3tmF3HOzWy X-Received: by 2002:a63:b445:: with SMTP id n5-v6mr20739310pgu.104.1531276148569; Tue, 10 Jul 2018 19:29:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531276148; cv=none; d=google.com; s=arc-20160816; b=ebdsT76NJ9Yq5s8P6TJISbil+2uiBmRuRt9xYwsPTfdeG/wLDBmgXW7b6kKVzox/hH DEANPzIMSye6HccNmECPVKPGVlaQM56vkZSAyuAtbxo0i+ocbBAPifRx9jL2A1hQK/fT MpU5SQph4Qi9AXHPWjzk86AqUmdaG/P/nFus+dcMqJFLsoIUhbYlyvEJV3nsbeaYAcOo RASJoXI4MA4JIig7rmwj7wVuMOGb0L24wk67s22i2H6/QUrcPD+z//7/g3kw1sacBGLx 9viHt5JVUNycTnw926LGAGcjqIwhcUs14GUqlACdBlSfe61v8Qm7l96gwU2OuAXRmvr8 RBAg== 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=mY2i/sP72phJLThaHHkqK/tXaNcGEYqBaaC9VvslWfQ=; b=dthHYWTFZUoS00XdRRg/YPnGit5i0R9br1OaqSbglppd474Wsxs2IT7e0OwjzhNTPw 6NozmgZEclNn3L2qPBr4Ko2wxIUf5+DxjRnouTgDwfVVZpLnNvsuA7RSQnZ1Hdb+mGVd WIKT6ZCj9zP7rQlLu23tbCe3SHT2dG9lEkDSyVnExvy5Ek+J7NbkqkqCYaUxmmAaI4tt g+srXJVA8NUcnxXXYhZZHkA6Ls46Ff7jTuj5DsS2iMy++aMUqHq0o85fISnXUhGgT88e yoLKGESTJKH2IV6W8fsZYkGpyqkW3vr8He68X2T5e2jl0YpsFasxxoewSNNd1MHtwG+0 G+9Q== 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 t66-v6si17824927pgc.6.2018.07.10.19.28.52; Tue, 10 Jul 2018 19:29:08 -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 S1732679AbeGKC3h (ORCPT + 99 others); Tue, 10 Jul 2018 22:29:37 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:9219 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732524AbeGKC3g (ORCPT ); Tue, 10 Jul 2018 22:29:36 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 3C3F5D0F8AA70; Wed, 11 Jul 2018 10:27:25 +0800 (CST) Received: from [127.0.0.1] (10.177.16.168) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.382.0; Wed, 11 Jul 2018 10:27:25 +0800 Subject: Re: [V9fs-developer] [PATCH] p9_check_errors() validate PDU length To: Tomas Bortoli , , , , Andrew Morton References: <20180709224323.20597-1-tomasbortoli@gmail.com> CC: , , , , From: jiangyiwen Message-ID: <5B456B0B.6020301@huawei.com> Date: Wed, 11 Jul 2018 10:27:23 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 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.16.168] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; Yes, currently 9p client is lacking of properly check for data from server. Maybe we should have a bigger patch to solve this problem. > /* > * dump the response from server > * This should be after check errors which poplulate pdu_fcall. >