Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1439489imm; Tue, 10 Jul 2018 01:39:59 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdD5QNWs0hcfs6yQMExvcyzcGp60DjCo2jOWEc5HMMiPMHKUkCAuVq17CGUpsT0mg25FOcn X-Received: by 2002:a63:941a:: with SMTP id m26-v6mr7133202pge.82.1531211999540; Tue, 10 Jul 2018 01:39:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531211999; cv=none; d=google.com; s=arc-20160816; b=I5Y5sU/ea44aiXr68KvmV/87/6wZyKE/qfP8gVTZH0divZOfKFKb/YMBBq5cuFI5v0 roeosFCelqbAXRpHcwY9q0Vmw+b3PUnxdMMJ2GO9UNPOjlcbT6RyhyEGG4HoDNEfC1+u jBe+FrSNCkO119lyI0q+MXMO/cUMrkaHpqI4g7DijDe56yH/el+X6e0GKY9W4i/UB20o oKl8IZgZMGgN08T4TfAEdPbVdDkWKHq8ooiQaTbxtU831OcxRtARPueS1XCgyONFrIi7 giBEa8DZi9DqTr5DMwVRx1FoNsUoyp6mCW24u4IfsfdL4bTmQVatarlxgQDyzNgYIixv xmaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=5PxA8yF8wzz3lDbVyY5zhH6BV1RjAC7AYMcu5EbH5+Y=; b=WNBjmw2Zri88aQz7MaNpgDZBzIyNsJ5PZk7X7Ig+y0NwMIuSf5kFjopzCMgLsPlYXu bXzuo2jLETEFbpeM6lQBnGO6j65NjKwohwKYD7OmW8XRegFxCuwsH+Adt/lAf9hY6wBF A11yo7GX+nBFa+PKMNq9LehM4SD2NBQach6QNE6/6peiMC+/47JiRA4PulZtCgcmpJDn 09AaEZA0xvxustVOdOX18JtK93hPMeOw2u4IdDCl1Glr2WeKMxuRljcechAS5yPEXVFx HnG8H4tJUUyWT8mXKcAdL/+6cCTMTqIYfzIbf2R/8e0ix1GJgxR/FJIClPKSqsUDX5xH 93Cw== 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 b12-v6si3455604pgh.264.2018.07.10.01.39.44; Tue, 10 Jul 2018 01:39:59 -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 S932659AbeGJIjE (ORCPT + 99 others); Tue, 10 Jul 2018 04:39:04 -0400 Received: from nautica.notk.org ([91.121.71.147]:60195 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751129AbeGJIjB (ORCPT ); Tue, 10 Jul 2018 04:39:01 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id B605BC009; Tue, 10 Jul 2018 10:38:59 +0200 (CEST) Date: Tue, 10 Jul 2018 10:38:44 +0200 From: Dominique Martinet To: Tomas Bortoli 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 Subject: Re: [V9fs-developer] [PATCH] p9_check_errors() validate PDU length Message-ID: <20180710083844.GA23124@nautica> References: <20180709224323.20597-1-tomasbortoli@gmail.com> <20180709235403.GB19917@nautica> <20180710022819.GA19285@nautica> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Tomas Bortoli wrote on Tue, Jul 10, 2018: > > 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. That's precisely the problem, none of the transports actually write in the pdu how much has been read. Instead, we blindly trust how much the client says it has written and p9_parse_header will write pdu->size which is then used as the 'actual' PDU length. With the three lines I added in each file all transports will store the PDU length in pdu->size so my following suggestion would be to just check that in p9_parse_header the length read from the packet match that of the received data and flag any packet where this is wrong as invalid. The only problem with that is that TCP will use p9_parse_header with a partial packet to know how much it needs to read, so that modification needs actual testing (hence my question below) as it is more intrusive than a simple boundary check. I'd suggest implementing some logic like already here with the if (pdu->size == 0) -- only check if pdu->size was previously set, and set it if it wasn't... But feel free to try something else. With that done I don't expect more problems but if I do it there's little point in making you do it as well ;) > > 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. Ok, let's get you a working setup for TCP then. You need to install a 9p server, the two I'm aware of are diod and nfs-ganesha (I'm using ganesha); once you have a working config you can mount with something like this: mount -t 9p -o aname=path,trans=fd Once you have that you should be able to fiddle with things until it works as expected. (for virtio I use qemu, that's probably easy to test as well; for RDMA you can use rxe to setup a virtual interface (with rxe_cfg) and then use either diod or ganesha again but the setup is more complicated so it's OK to leave that aside for now) > 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. There's a saying about giving a fish or teaching how to fish, so let's have you try if you're motivated :) I don't think much is left if you can sew the pieces together, the most difficult part will probably to set the test environment up if you want to do this properly. Please ask if you run into any trouble, -- Dominique Martinet | Asmadeus