Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1317637yba; Tue, 2 Apr 2019 06:46:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJ2muj0PJAL7DsKJRoaf4jwvqX1+eNq11IGzp/DFsBLGkm79WVGKGEEUZNZDyoWQGLWdt/ X-Received: by 2002:a62:1c13:: with SMTP id c19mr29886576pfc.11.1554212795265; Tue, 02 Apr 2019 06:46:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554212795; cv=none; d=google.com; s=arc-20160816; b=feRgN/4ziLw5fVyl4bgmEqMyWELMcDqOxEJ9QkoouHESGcIKTnehYNIaws1RQZL/CA FpJWUBrGkRSmjStDa8ljDY++i6qNgsSyIgw4Y00BJvwIFdHDzTNcsERmd+/1tglV2AGi rvVOFGp6eDwsqmXtgVfMlAx8SH+ayvwl9jrws4ZZh+4z1zmJf0TFocfsCbZiZkBU0OCe MCiVCR9H5wp2sHpKVN/vDwfKSW1GFjHDtOTv8+tnlCVlKiKuP6jxCwxtOW+ovz7zmBd1 SydAWW17tdoBhe3Ec+4KfQXmU7BQFzl0DFRAt0WoutIck0VQ8cdBqEpMCOmq/Y+pBqIB /H1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=q2rKssiKypFJpNB/T9/lnDtTppFcwxxnIIc4FAJye2s=; b=lzVXM4EM7DL/4Clqy+5m8a2cpE2RnVAqUUDgAJy2Gqxt5pXl9UD2W+XQDcgc/lCwMm f+2auoyeNEVtPLas4IUK/6mCYs3rcPMC1m8CdmCDYcw8MaZBdxiOFySIwbu4IqWZwTzl N5UWfBNSv6P0yjtUeyFI9zTAB9QtRNVjuo4VckLOC7jPFZkBEravWjtnfyAiHMAyZIh9 qe3wtZYolNDuje2z/qsjm2DlWGalHnEoS53fjcmNfxM/NcuuJKk2N28uMNvgj52plD7V DkapTiPYdWNmJeQ9mQXwzN6Tt/dYe8Oe6wBgOoxZ9uZ+ldlsJF4B+QRregYvPEDPIj4p mAsA== 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 a22si11044175plm.263.2019.04.02.06.46.20; Tue, 02 Apr 2019 06:46:35 -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 S1732096AbfDBNpH (ORCPT + 99 others); Tue, 2 Apr 2019 09:45:07 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:43406 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731467AbfDBNkI (ORCPT ); Tue, 2 Apr 2019 09:40:08 -0400 Received: from [167.98.27.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hBJe0-0002oo-LH; Tue, 02 Apr 2019 14:40:04 +0100 Received: from ben by deadeye with local (Exim 4.92) (envelope-from ) id 1hBJdx-0004x5-O0; Tue, 02 Apr 2019 14:40:01 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "Dominique Martinet" , syzbot+0c1d61e4db7db94102ca@syzkaller.appspotmail.com, "Eric Van Hensbergen" , "Latchesar Ionkov" Date: Tue, 02 Apr 2019 14:38:28 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 82/99] 9p/net: put a lower bound on msize In-Reply-To: X-SA-Exim-Connect-IP: 167.98.27.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.65-rc1 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 Signed-off-by: Ben Hutchings --- net/9p/client.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) --- a/net/9p/client.c +++ b/net/9p/client.c @@ -155,6 +155,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: @@ -980,10 +986,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; @@ -1048,6 +1062,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;