Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp281266imu; Mon, 19 Nov 2018 22:27:42 -0800 (PST) X-Google-Smtp-Source: AFSGD/UNI661rR2CRLXnCGQow4IVklss8qjq9wNacfLDYfC/31A2ihVgVW5jf7niXhQrWqTbPwSy X-Received: by 2002:a63:bd51:: with SMTP id d17mr769740pgp.443.1542695262198; Mon, 19 Nov 2018 22:27:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542695262; cv=none; d=google.com; s=arc-20160816; b=lCTmKO2DTxpDgPD7zdIu+MxFsyYYA0Uu2TmOWZLem9imYDya9Szxb5sKKAEZw1ohK2 MQtVTo+PV9XjpPq85rCG/zljqRtCPK72NXq75iMYFVlloYHyXB/+Ece3RBTJCDfTGjlQ wHRF9TGiuQT7EIYfkrE9IoBjQ+bvqyNpEoSDFWif40icfnU9M5ia75if+V54zaDn4PMx Cb1f2LbbivG9LdIt+jnI5iKG57c3PQhobdXLcKixcDf61P29ZX4bfRd5lxqVIxTpjMYO 2LBghRb/tIMsD3HFppIQzTxKACWnRCVB3/QMtvZDvywC9y2z/ZW7knXmmW8LezjMhtc+ /BFw== 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; bh=t5vXHF+JD62imxtCjNExphZtu+SNszpHDfDHrroAr2k=; b=M8pBRLt2XDaLx3rr9lvFLrU8AGXRbyWbtfBXEQ8lZpu2PTQWyKfMV+bUc3ZcWCyTeg NbtTxEqO45ZmxZ39S2m9Q4N6ofzuNh0W3QlMZOpQAMTmFRKG0zuobvPjOzECAiLc3S4f m0JeuPGdldHzLyjO0OFGlz+eQWEVARAi5xEYHrYh2aU7PcnFj1w5mzQBMca5iBguN/vN 5VXnOAoL/HEzE/X8r7HLSpiPCo/nISh0VbIQ++rCyEvbqnbX1zp/3B4UJNSisYCIXvC/ qkGHV3gG9mMiwXBoWiKde8p/0yFz7ononNnE6ozx8l+HiUzgmPZbyBnZATCRdMUX+SZO JXNQ== 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 y191si40679971pgd.4.2018.11.19.22.27.12; Mon, 19 Nov 2018 22:27:42 -0800 (PST) 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 S1732413AbeKTQbK (ORCPT + 99 others); Tue, 20 Nov 2018 11:31:10 -0500 Received: from nautica.notk.org ([91.121.71.147]:60520 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726982AbeKTQbK (ORCPT ); Tue, 20 Nov 2018 11:31:10 -0500 Received: by nautica.notk.org (Postfix, from userid 1001) id 34024C009; Tue, 20 Nov 2018 07:03:46 +0100 (CET) Date: Tue, 20 Nov 2018 07:03:31 +0100 From: Dominique Martinet To: Dominique Martinet Cc: Eric Van Hensbergen , Latchesar Ionkov , syzkaller-bugs@googlegroups.com, v9fs-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH] 9p/net: put a lower bound on msize Message-ID: <20181120060331.GA6675@nautica> References: <20181102223908.GA9565@nautica> <1541407968-31350-1-git-send-email-asmadeus@codewreck.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1541407968-31350-1-git-send-email-asmadeus@codewreck.org> 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 Dominique Martinet wrote on Mon, Nov 05, 2018: > From: Dominique Martinet > > If the requested msize is too small (either from command line argument > or from the server version reply), we won't get any work done. > If it's *really* too small, nothing will work, and this got caught by > syzbot recently (on a new kmem_cache_create_usercopy() call) > > Just set a minimum msize to 4k in both code paths, until someone > complains they have a use-case for a smaller msize. > > We need to check in both mount option and server reply individually > because the msize for the first version request would be unchecked > with just a global check on clnt->msize. > > Reported-by: syzbot+0c1d61e4db7db94102ca@syzkaller.appspotmail.com > Signed-off-by: Dominique Martinet > Cc: Eric Van Hensbergen > Cc: Latchesar Ionkov > --- > net/9p/client.c | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/net/9p/client.c b/net/9p/client.c > index 2c9a17b9b46b..b1163ebdc622 100644 > --- a/net/9p/client.c > +++ b/net/9p/client.c > @@ -181,6 +181,12 @@ static int parse_opts(char *opts, struct p9_client *clnt) > ret = r; > continue; > } > + if (r < 4096) { This should read if (option < 4096), amending what I've put in for -next last week :( Reviews wanted! > + p9_debug(P9_DEBUG_ERROR, > + "msize should be at least 4k\n"); > + ret = -EINVAL; > + continue; > + } > clnt->msize = option; > break; > case Opt_trans: > @@ -983,10 +989,18 @@ static int p9_client_version(struct p9_client *c) > else if (!strncmp(version, "9P2000", 6)) > c->proto_version = p9_proto_legacy; > else { > + p9_debug(P9_DEBUG_ERROR, > + "server returned an unknown version: %s\n", version); > err = -EREMOTEIO; > goto error; > } > > + if (msize < 4096) { > + p9_debug(P9_DEBUG_ERROR, > + "server returned a msize < 4096: %d\n", msize); > + err = -EREMOTEIO; > + goto error; > + } > if (msize < c->msize) > c->msize = msize; > > @@ -1043,6 +1057,13 @@ struct p9_client *p9_client_create(const char *dev_name, char *options) > if (clnt->msize > clnt->trans_mod->maxsize) > clnt->msize = clnt->trans_mod->maxsize; > > + if (clnt->msize < 4096) { > + p9_debug(P9_DEBUG_ERROR, > + "Please specify a msize of at least 4k\n"); > + err = -EINVAL; > + goto free_client; > + } > + > err = p9_client_version(clnt); > if (err) > goto close_trans; -- Dominique