Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp647101imu; Fri, 11 Jan 2019 06:45:29 -0800 (PST) X-Google-Smtp-Source: ALg8bN6NiWnC/MSiin6xnJi60sARK8vk6hQEib7fHUfhjXNgWry8iKUfV03y3fiM/bKvm0y+bjJz X-Received: by 2002:a63:d949:: with SMTP id e9mr13731683pgj.24.1547217929775; Fri, 11 Jan 2019 06:45:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547217929; cv=none; d=google.com; s=arc-20160816; b=yeem887BKL3lX48fujv3+RJQ86arV4pO7lxyyS51NPqp5i6jKNiQ9MmVfLpVizG9rw rPfi7aUGycW9wwYXUNJyPFmUIQpWR7Nd1pM7PyD5G+b/prjyyDkBaWdszADkdXRWx5C0 4Y5fQh8r1XvUfPaLsbfuVemPQVTV3bncubHzgb2bA/6zxet+rSoDM+pu7ZVw3wPIUP/K 1wd+IlDNw+Vk77VRUO41IMthphOtvGqJyWtKlG6A2kvpxT73zPSS7aTE7hkY8VB5KODZ 5rKIaWPClPZj7AvEoBMkjkCNeD0b2+sA6bT+YKsh5nxrvqzc6Pbi9laQZBWjn1mEx8id phgA== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=I49LX8cQPX+ZnnbOn56+DXleSWMQJ3Ng9C53HeuU8N0=; b=KO4RJ+TrIrf/xOtfxEVRmymJcplzPXop2uEbk3jzdWewQvNmkgjwExVPaRNmKwFySK BqcVRtIIsK89WmGAZ9nXop6lbizUxkn6WVuXIFr2/dldIq7za9J83rRx4ah171V/09uj 2zoJJMzsolDQ/0pOdZRRZs1ZqjSiQY8gdyRvKJJqgBS3SNMdiMH/RKO8YLxBNDRznLke D1cZxzQXgvh7s2hSAu+HEyiFU6deIA3BSFeJ7ym0SwDWkleYRU+YcfqQYIVCn4u4Jdda KpQ+3tTtHxSkL77ApriZ8O9aJFWLPgs7gps9GQdF4kK0ln9v43fSzIrmGKGDRPYOrhDK FNbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jW81x+d8; 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 m19si9311788pls.437.2019.01.11.06.45.14; Fri, 11 Jan 2019 06:45:29 -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; dkim=pass header.i=@kernel.org header.s=default header.b=jW81x+d8; 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 S2391383AbfAKOnV (ORCPT + 99 others); Fri, 11 Jan 2019 09:43:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:36164 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391057AbfAKOnR (ORCPT ); Fri, 11 Jan 2019 09:43:17 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2B1642184A; Fri, 11 Jan 2019 14:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547217796; bh=J7MLIe9kx4UhEAnsTbN4LubRtANRoAQSk+fo99/988w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jW81x+d8mkoxjhOEcmHBdGJPTV+x9k816IPVQ/71jaj05TkLgvoezDgj0MUTgc46Y zmco15uoeaU9tJUcCb0fvkivFtK5C+Ay9VPAUiS5sXU7KNzkmVFfpkbT2tMJV/b21d ApgQZoOszBHEdpFlmFRyAJgohGXykq6MEDmfDiH0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+0c1d61e4db7db94102ca@syzkaller.appspotmail.com, Dominique Martinet , Eric Van Hensbergen , Latchesar Ionkov Subject: [PATCH 4.20 45/65] 9p/net: put a lower bound on msize Date: Fri, 11 Jan 2019 15:15:31 +0100 Message-Id: <20190111131102.537703599@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190111131055.331350141@linuxfoundation.org> References: <20190111131055.331350141@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dominique Martinet commit 574d356b7a02c7e1b01a1d9cba8a26b3c2888f45 upstream. 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. Link: http://lkml.kernel.org/r/1541407968-31350-1-git-send-email-asmadeus@codewreck.org Reported-by: syzbot+0c1d61e4db7db94102ca@syzkaller.appspotmail.com Signed-off-by: Dominique Martinet Cc: Eric Van Hensbergen Cc: Latchesar Ionkov Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- net/9p/client.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) --- a/net/9p/client.c +++ b/net/9p/client.c @@ -181,6 +181,12 @@ static int parse_opts(char *opts, struct ret = r; continue; } + if (option < 4096) { + 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_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 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;