Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1885044imm; Thu, 12 Jul 2018 09:20:37 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdg+qMENb4BnOdZssK/jOhdXpAQla4t8X0VEWeT2oSBEbiswFmgEG+SWhWAoe8w5LNraHPX X-Received: by 2002:a62:9683:: with SMTP id s3-v6mr3071090pfk.191.1531412437586; Thu, 12 Jul 2018 09:20:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531412437; cv=none; d=google.com; s=arc-20160816; b=h09tKex3zRt2wHLtN2q742mqhQ14qEIa77ma4bdNPJXaaAwdADUvhwe7Twa38S9usu 8sGY4lIfaR1bDtnp6VpDxEP0gjcbVTkMybVgNo3gb1K+ugyWpwA/8qDq6khVnkDVADOs LY5beR5br4fC8leJmIzT9fbb4qH68xmoSxCAjyPjl29YDT4jPWm30rbiUbn8VJnyRFke 819/vsCLWZnCXIBPc3AKsPPEGMUHvNrIKNmVU3LxoNMpTpDIvXvgYVCKTtqF/sHXk3Ho DOemtPCS2jJbu8PwRyl10spvIIWIv0D/W4DXuGAVuNMvPFxktJqjiM6rkzPSHXczHOiz fSTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject :dkim-signature:arc-authentication-results; bh=Vyz4XxstOcV8pbG74Qmupu88IRUf9qTh3TTCwU1140Y=; b=eC5zJBEOMn9fQwbJLT1mfh0XW1PkC/4EbW10M2Y8BpegeOIpM2kD6wc7qa8mKCRveu iyhz36XkJDs1Eozz2HmXlLrxsYyyHIy4qYXnJEVFY1qPUZGXR+uKIBozgBjIIta144r3 OWhaKmcAZAFiiadmoQ6e5LUBSQCH4/DJyU47xKmapBJRG+BdNg72eM8gy2E9R1PQcLGO 5rAjJDl7Rr1MA4yFxGx8W5cyrsgGEZgRV+hc+5lZyAcCHzPrFbRNHZDR9rO+8dPhszNY 5keVJkPUdDdk3sYbqii0Rh8l5xNOa2QV1QmT4ll5oLZmBOuenu/gS06Q+Q1ISRMsZw20 MLzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=U9L1V6Tl; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l88-v6si4099293pfi.179.2018.07.12.09.20.21; Thu, 12 Jul 2018 09:20:37 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=U9L1V6Tl; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727084AbeGLQ34 (ORCPT + 99 others); Thu, 12 Jul 2018 12:29:56 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:40760 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726744AbeGLQ3z (ORCPT ); Thu, 12 Jul 2018 12:29:55 -0400 Received: by mail-lf0-f67.google.com with SMTP id y200-v6so24739801lfd.7; Thu, 12 Jul 2018 09:19:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=Vyz4XxstOcV8pbG74Qmupu88IRUf9qTh3TTCwU1140Y=; b=U9L1V6TlGNyyQWynDhjK21uxg3cdBuwc5nkY8atWnrVc3asoAUXwLu+/+Z8aC/vuhx /gHJRK+2RwS0p4LOBtfLbdQo36M6pEiM7UwyTTVGlxIBrKjv1jFMstgFh1vKMZkJeFde 2/NeMxoAh8pR4PfTW7gauUlWdYX6qS7LjIh8tjdTnRPoeJpmBKzOd55HPax2Cu97FAx4 xb0Z73Iblr81CNwYr4hbA5I5n9nijT1zRig2q1q69uSsPG6um5wzIrmjDdi9lbubmUS4 yNfM9sBjOMQGDIyDkRnCEx2+sJw2eHxQD/bRaBjPJaJSK8rW7nRrOWRnIsNvYOukhJnt Udjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-transfer-encoding:content-language; bh=Vyz4XxstOcV8pbG74Qmupu88IRUf9qTh3TTCwU1140Y=; b=PPe3lSOHK2zr9fKdCDIzr/pjyPwskyjt15BhWU6nl6X4uxFApVCXRKC66ndExVa3iY rWeQkj1o/RPtDLiUyljVc8TUBemVoykJ0vtRAprPciSHKIXwrQ0p9fNAu+reN7m43nig /R2I+fBzAYvlpQ6loc3DvgbB7dbalkat/c8dG8uq+ploWMyBqRwM/zWMnFYO1R8qu8Y/ 4pGYQZ+ceTk8U+haIFmvhDCoimLB9rcBzpR0KL/dP4Ni7wU/QXdpCe0ND97Pm6PEYk7m pru/nVo5gPJjJ1FKARZFRnA9yNkYNYYBuo6+HkSrXiPOuWrcCLF+qJxnGZT++5xRim1m 0l5g== X-Gm-Message-State: AOUpUlGCd3mNF99VsAbrkjuVoOCIm2euSER66W/FuCUcHhWqIxsIz0TF uv8tlVa0zw2gn9T+89lscv8= X-Received: by 2002:a19:d44a:: with SMTP id l71-v6mr2213897lfg.28.1531412379056; Thu, 12 Jul 2018 09:19:39 -0700 (PDT) Received: from ?IPv6:2001:2012:22e:1b00:f2e2:9015:9262:3fde? ([2001:2012:22e:1b00:f2e2:9015:9262:3fde]) by smtp.gmail.com with ESMTPSA id y74-v6sm6179292lfi.61.2018.07.12.09.19.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jul 2018 09:19:38 -0700 (PDT) Subject: Re: [V9fs-developer] [PATCH] p9_parse_header() validate PDU length To: Dominique Martinet Cc: ericvh@gmail.com, rminnich@sandia.gov, lucho@ionkov.net, viro@ZenIV.linux.org.uk, davem@davemloft.net, v9fs-developer@lists.sourceforge.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller@googlegroups.com, Andrew Morton References: <20180712110211.25535-1-tomasbortoli@gmail.com> <20180712114304.GB17774@nautica> From: Tomas Bortoli Openpgp: preference=signencrypt Autocrypt: addr=tomasbortoli@gmail.com; prefer-encrypt=mutual; keydata= xsFNBFpCTZMBEADNZ1+Ibh0Z4pgGRcd1aOUMbe/YfHktmajjcoTnKmZZunjoUVAl8waeLITd BC2c8i1wHzHcnthrmb1izs5XlG6PZnl8n5tjysSNbwggzS1NcEK1qgn5VjNlHQ5aRMUwCC51 kicBiNmlQk2UuzzWwdheRGnaf+O1MNhC0GBeEDKQAL5obOU92pzflv6wWNACr+lHxdnpyies mOnRMjH16NjuTkrGbEmJe+MKp0qbjvR3R/dmFC1wczniRMQmV5w3MZ/N9wRappE+Atc1fOM+ wP7AWNuPvrKg4bN5uqKZLDFH7OFpxvjgVdWM40n0cQfqElWY9as+228Sltdd1XyHtUWRF2VW O1l5L0kX0+7+B5k/fpLhXqD3Z7DK7wRXpXmY59pofk7aFdcN97ZK+r6R7mqrwX4W9IpsPhkT kUyg3/Dx/khBZlJKFoUP325/hoH684bSiPEBroel9alB7gTq2ueoFwy6R3q5CMUw3D+CZWHA 3xllu46TRQ/Vt2g0cIHQNPoye2OWYFJ6kSEvaLpymjNDJ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YL NDwDgm9Yzp7Rx0O1QOnQsXTHqk7K38AdSdM2li/I/zegeblInnLi08Gq6mT6RkD6wV9HE5U3 EIU0rDPyJo54MW39wGjfC2+PM5I0xebbxtnuTewRchVVfm7UWgLAy11pV3xM4wMSJOuqVMOz jYpWKYxDTpvsZ0ginUUY993Gb8k/CxjABEMUGVHhQPZ0OzjHIKS6cTzN6ue8bB+CGOLCaQp1 C0NRT5Tn9zpLxtf5nBExFd/zVENY5vAV2ZbKQdemO54O7j6B9DSgVRrm83GCZxbL4d+qTYBF 3tSCWw/6SG1F3q9gR9QrSC2YRjCmhijUVEh6FhZwB58TNZ1sEEttrps8TDa5tUd9 Message-ID: Date: Thu, 12 Jul 2018 18:19:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180712114304.GB17774@nautica> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org + Cc: Andrew Morton On 07/12/2018 01:43 PM, Dominique Martinet wrote: > Tomas Bortoli wrote on Thu, Jul 12, 2018: >> This patch adds checks to the p9_parse_header() function to >> verify that the length found within the header coincides with the actu= al >> length of the PDU. Furthermore, it checks that the length stays within= the >> acceptable range. To do this the patch brings the actual length of the= PDU >> from the different transport layers (rdma and virtio). For TCP (trans_= fd.c) >> the length is not know before, so we get it from the header but we che= ck it >> anyway that it's within the valid range. Still for TCP it you could read "garbage" pre-allocated memory but I don't know how much it is a risk, it might be a good idea to zero it post allocation (I mean pdu->sdata). Allocated at: https://github.com/torvalds/linux/blob/master/net/9p/client.c#L236 > Just a note on transports here, I totally had forgotten about trans_xen= > when we discussed this earlier as it is fairly new, but it looks like i= t > sets the length in the fcall properly so it should work without any > change. > > I however cannot test trans=3Dxen, so if someone could either point me = to > how to set that up (I couldn't find any decent documentation) or do som= e > very basic tests that would be great. >> Signed-off-by: Tomas Bortoli >> Reported-by: syzbot+65c6b72f284a39d416b4@syzkaller.appspotmail.com > Looks good to me, as the rdma/virtio part come from my suggestion: > Signed-off-by: Dominique Martinet True > >> diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c >> index 3d414acb7015..002badbcc9c0 100644 >> --- a/net/9p/trans_rdma.c >> +++ b/net/9p/trans_rdma.c >> @@ -319,7 +319,7 @@ recv_done(struct ib_cq *cq, struct ib_wc *wc) >> =20 >> if (wc->status !=3D IB_WC_SUCCESS) >> goto err_out; >> - >> + c->rc->size =3D wc->byte_len; > (nitpick, I'd keep the empty line here. If you don't mind I'll add it > back in my tree; this doesn't warrant a v2) > Sure, Tomas