From patchwork Tue Aug 14 08:40:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 957383 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codewreck.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41qQyr2SWHz9s7c for ; Tue, 14 Aug 2018 18:40:20 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729317AbeHNL01 (ORCPT ); Tue, 14 Aug 2018 07:26:27 -0400 Received: from nautica.notk.org ([91.121.71.147]:33750 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727689AbeHNL01 (ORCPT ); Tue, 14 Aug 2018 07:26:27 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id 8847FC009; Tue, 14 Aug 2018 10:40:16 +0200 (CEST) From: Dominique Martinet To: v9fs-developer@lists.sourceforge.net Cc: Dominique Martinet , netdev@vger.kernel.org, Stefano Stabellini , Eric Van Hensbergen , Latchesar Ionkov Subject: [PATCH] 9p/xen: fix check for xenbus_read error in front_probe Date: Tue, 14 Aug 2018 10:40:07 +0200 Message-Id: <1534236007-10170-1-git-send-email-asmadeus@codewreck.org> X-Mailer: git-send-email 1.7.10.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Dominique Martinet If the xen bus exists but does not expose the proper interface, it is possible to get a non-zero length but still some error, leading to strcmp failing trying to load invalid memory addresses e.g. fffffffffffffffe. There is then no need to check length when there is no error, as the xenbus driver guarantees that the string is nul-terminated. Signed-off-by: Dominique Martinet Cc: Stefano Stabellini Cc: Eric Van Hensbergen Cc: Latchesar Ionkov Reviewed-by: Stefano Stabellini --- This is a trivial bug I stumbled on when setting up xen with p9fs and running the VM in pvm: it had enough in the bus to trigger the probe but then there was no version and it tried to return ENOENT but len was set to the lower-level message size. net/9p/trans_xen.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c index 1a5b38892eb4..f76beadddfc3 100644 --- a/net/9p/trans_xen.c +++ b/net/9p/trans_xen.c @@ -391,9 +391,9 @@ static int xen_9pfs_front_probe(struct xenbus_device *dev, unsigned int max_rings, max_ring_order, len = 0; versions = xenbus_read(XBT_NIL, dev->otherend, "versions", &len); - if (!len) - return -EINVAL; + if (IS_ERR(versions)) + return PTR_ERR(versions); if (strcmp(versions, "1")) { kfree(versions); return -EINVAL; }