Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753428AbdFSSgk (ORCPT + 2 others); Mon, 19 Jun 2017 14:36:40 -0400 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:52346 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753397AbdFSSgg (ORCPT ); Mon, 19 Jun 2017 14:36:36 -0400 From: Willy Tarreau To: linux-kernel@vger.kernel.org, stable@vger.kernel.org, linux@roeck-us.net Cc: Al Viro , Willy Tarreau Subject: [PATCH 3.10 259/268] p9_client_readdir() fix Date: Mon, 19 Jun 2017 20:32:38 +0200 Message-Id: <1497897167-14556-260-git-send-email-w@1wt.eu> X-Mailer: git-send-email 2.8.0.rc2.1.gbe9624a In-Reply-To: <1497897167-14556-1-git-send-email-w@1wt.eu> References: <1497897167-14556-1-git-send-email-w@1wt.eu> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: From: Al Viro commit 71d6ad08379304128e4bdfaf0b4185d54375423e upstream. Don't assume that server is sane and won't return more data than asked for. Signed-off-by: Al Viro Signed-off-by: Willy Tarreau --- net/9p/client.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/9p/client.c b/net/9p/client.c index 853d623..e191aab 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -2080,6 +2080,10 @@ int p9_client_readdir(struct p9_fid *fid, char *data, u32 count, u64 offset) trace_9p_protocol_dump(clnt, req->rc); goto free_and_error; } + if (rsize < count) { + pr_err("bogus RREADDIR count (%d > %d)\n", count, rsize); + count = rsize; + } p9_debug(P9_DEBUG_9P, "<<< RREADDIR count %d\n", count); -- 2.8.0.rc2.1.gbe9624a