Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1422894imm; Tue, 10 Jul 2018 01:17:44 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeehU2Gnk4yETC/pwMoGCGllpMd3VICO1Z5YTK5QSkoXxSvGPwmdMB59sQHQdrjh2v36mSf X-Received: by 2002:aa7:87d0:: with SMTP id i16-v6mr24545984pfo.82.1531210664265; Tue, 10 Jul 2018 01:17:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531210664; cv=none; d=google.com; s=arc-20160816; b=akU1FQ6BdiFrl4zmCGHfvwBzkOHRUkLVu9W66Hh2e97dtWiTQrVQ4CqNyDS99hb6pE 4UhAqoBWBgw3OXeQPWjR7Wvi7nJutA9WpzWhXYxwjK7vQOd4PhyDSZibakGW5+8SD/O4 QVARQyeaE2igWQ8gy5W3AGaPFIhjzRcnl4crQmTxvS6l+cp1NPpTtOhsjX9EZBYa5vpm EMsQPO6qNPjxVRV+0J31L16OsMGXEH9/f2HEIMJv2ALML7Nz8QtGXYl6hRh7pBY45d5p b+MWiKIBdG4Uwed2YJmKx8ZhpX+xzmR5mzLjbSxM6AQ1Rzc3IM65WdQmMKQF3wGCJX9l 0fkQ== 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=C5hnSiVquI4dMhsZ+/i0zP8ki+Zdst7lNYygFO5AMBk=; b=HLXqzhakxSN0QiG1FZrwIO9Tubp6J2P+csref3qPeL5bkvHCsSCz2WYhNZOAE5YYOE kEoBNEdumfeM3pEjHxL6k6ZzTHPbdum/vytd4he+g+qZk5BV/wnJ07ram3aTiU1swJxy EfisuyNqTiIG+I6X0yMjgn7viV9LjqMlo8O8n5vqfsF3/eYyqRM34x3Miznc3weesc4u r+N+M2GSxUohxSHGnfxq47wVMuK5lUeLXkF8vlzpQ2T83vh+mGfEw3UUy9g+xTtrxldr YBmrO3gYWz2BUdScZDjvtXsTGiV8mUkPDNLCpNWrOjNiw/Xp4E5cbauWICnG9jTTr/+I SlwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=J80ftiHt; 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 t4-v6si15613396pgc.572.2018.07.10.01.17.29; Tue, 10 Jul 2018 01:17:44 -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=J80ftiHt; 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 S933258AbeGJIPK (ORCPT + 99 others); Tue, 10 Jul 2018 04:15:10 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:55995 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751232AbeGJIPE (ORCPT ); Tue, 10 Jul 2018 04:15:04 -0400 Received: by mail-wm0-f66.google.com with SMTP id v128-v6so6082071wme.5; Tue, 10 Jul 2018 01:15:03 -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=C5hnSiVquI4dMhsZ+/i0zP8ki+Zdst7lNYygFO5AMBk=; b=J80ftiHtEp0QqVp5kwI/etolo+7MwjfoIY/zoHK8i11L6w25ZgmWSJylTgX/xLUQqs cX/7c7RsB7I1EHn1ujYBZVVVMoD/qoKJnpjWAKjnCm5QaiBnDxSeZMgb4LIAUC3liZZs cU+p5qgxwitWoN8nHSjiRmJftAJv2joNl1CdSTz3ysPxGUQU5GtJ+xnYqeosJh3qR6Yo iYqutCpI343SCfTg7+Z/JTwZ73K37sNSNtUTBlOsMmChekgo4k+Pienr7rrIBG2sv6+K umN1yDG9XDR/gBeLb4JlbI5bql/rYjVdEYw5/TSL3rSJM5UQvik8B4DF7lDw8vHUjKXc wbTg== 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=C5hnSiVquI4dMhsZ+/i0zP8ki+Zdst7lNYygFO5AMBk=; b=eREOV8I/Oxr6FxYP2z+RoH1hZvoUWSNxxkZWCckSpSGrBX1R5W8v/Oed5ly2+g3UmG IzNFRDh5oEnI2gI8K42dysaACyFv482i7b/xKyVTupwpOBFLA2KdaWv0jLojWLKo9ucl /zZcg5rYsXbfmd4ECfVhcAh0DRkSfjwyN04rlO9D+9hy9qo8+WYZ8/laOuvo51pa+inK LMjzNjYvWcKXBmzNDl7AMSTpf10fg2GyHFKzNoefrW15zT42Fr6wkcA1ksUIM6bSWmtx 1DiPiJtgmEMeDynzdtD2VVXqoIv9rGXexIMRpNy6f9iLTSBzX5a8I7zd0iql0cDsHNHO 3tdA== X-Gm-Message-State: APt69E2BycxyZHkpXoJ5Wsbj+YqzJojw/gVQUQvrrTIX4CNxSsYVqBcv tABoOLpkmqiyzjq5oaMo2LU= X-Received: by 2002:a1c:6709:: with SMTP id b9-v6mr14761581wmc.68.1531210502538; Tue, 10 Jul 2018 01:15:02 -0700 (PDT) Received: from [192.168.8.10] ([185.175.214.210]) by smtp.gmail.com with ESMTPSA id r17-v6sm12798306wrt.44.2018.07.10.01.15.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Jul 2018 01:15:01 -0700 (PDT) Subject: Re: [V9fs-developer] [PATCH] p9_check_errors() validate PDU length To: Dominique Martinet Cc: ericvh@gmail.com, rminnich@sandia.gov, lucho@ionkov.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller@googlegroups.com, v9fs-developer@lists.sourceforge.net, davem@davemloft.net, Al Viro References: <20180709224323.20597-1-tomasbortoli@gmail.com> <20180709235403.GB19917@nautica> <20180710022819.GA19285@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/Vt2g0cIHQNPoye2OWYFJ6kSEvaLpymjNDJ9ph2EuHegonDfOaYSq34ic2BcdB JkCgXRLP5K7KtRNJqq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/zegeblInnLi08Gq6mT6RkD6wV9HE5U3 EIU0rDPyJo54MW39wGjfC2+PM5I0xebbxtnuTewRchVVfm7UWgLAy11pV3xM4wMSJOuqVMOz jYpWKYxDTpvsZ0ginUUY993Gb8k/CxjABEMUGVHhQPZ0OzjHIKS6cTzN6ue8bB+CGOLCaQp1 C0NRT5Tn9zpLxtf5nBExFd/zVENY5vAV2ZbKQdemO54O7j6B9DSgVRrm83GCZxbL4d+qTYBF 3tSCWw/6SG1F3q9gR9QrSC2YRjCmhijUVEh6FhZwB58TNZ1sEEttrps8TDa5tUd9 Message-ID: Date: Tue, 10 Jul 2018 10:15:00 +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: <20180710022819.GA19285@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 On 07/10/2018 04:28 AM, Dominique Martinet wrote: > Tomas Bortoli wrote on Tue, Jul 10, 2018: >> 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 h= as >> 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. > Sorry, I'm the one who suggested to put a note after the commit message= > and I didn't see it. > > Let's get the proper fix right away, it's not much further. I agree. > >> Also, they really need to check against the actual read size, not just= >> capacity. >> For virtio/rdma, something like this ought to fix pdu->size, then >> p9_parse_header can just never overwrite it (untested but it's useless= >> on its own, I'll test the full patch with the parse header change) > I actually took the time to test a bit; I had only suggested something > for virtio/rdma because I had assumed trans_fd (the socket transport > actually used by syzbot) was setting the length in the fcall, but I rea= d > that code too fast this morning and it is not (it only sets the size in= > its private struct) > > Something like that ought to work for trans_fd: > diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c > index 588bf88c3305..9f3ce370c685 100644 > --- a/net/9p/trans_fd.c > +++ b/net/9p/trans_fd.c > @@ -369,6 +370,7 @@ static void p9_read_work(struct work_struct *work) > */ > if ((m->req) && (m->rc.offset =3D=3D m->rc.capacity)) { > p9_debug(P9_DEBUG_TRANS, "got new packet\n"); > + m->req->rc->size =3D m->rc.offset; > spin_lock(&m->client->lock); > if (m->req->status !=3D REQ_STATUS_ERROR) > status =3D REQ_STATUS_RCVD; > --- > > This however gets more complicated once you start factoring in that > change I suggested about p9_parse_header not setting size (and checking= > size) because trans_fd relies on it; so I'm not sure how we should > proceed. Mmh, me neither. I don't see where the *actual* PDU length is stored. > > Do you have a working 9p tcp server to test changes are valid, or are > you only working off the syzbot reproducer? No, I was just using the reproducer to test. > In the first place, are you willing to take the time to do that bigger > fix? Yes. > > At this point I can either help you get a working setup and let you do > the rest, or just finish the bigger patch myself and add you as whateve= r > tag you feel comfortable with (persumably Signed-off-by) > > Thanks again for starting this, For me both ways are good. Signed-off-by will be good. You know for sure more than me about 9p as I started delving it for the first time yesterday. I can also make and test a patch but I'll need to understand more about it. Let me know if you find out more.