From nobody Sat Nov 30 00:39:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1620900227; cv=none; d=zohomail.com; s=zohoarc; b=Kpb7hVJJ3qQ14Jf/Hf/aVudW5wenyv6mEFjwMQ6s8L9VhQvILTLTldbKP9+zCFv9+FN1dT6hqU82RIWN+Pmn/TaHoDrEHRTRvuz/WccbURpwdf2yuh943yoIhJW6lLCusSTWP273R5ptSXI+pw9Rnx2Qc7Dw8bWWF5ZKCXhjFEs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620900227; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=j+l5tq5M/f1kECXbl74yHxqhOUkbjQkUE4NZC677IzI=; b=Pjcj2H/WlYJ0qrE+Iw3AShkyKIQzIFJodiTW+IsxS5XIZc3wjBl2YLd/uiUiVb+Ek4AS0BhR2Kl53CBlacqqBT3kvf6MRR5LC/RG8A5lR9A2kSbHfMzLr8OeTx2u335TidDVCLkDU+OPYBAGZts+YIdp2M0cTvHgsM5Sq8cPM60= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1620900227808369.2239151010624; Thu, 13 May 2021 03:03:47 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.126817.238369 (Exim 4.92) (envelope-from ) id 1lh8Bq-0007OF-5m; Thu, 13 May 2021 10:03:34 +0000 Received: by outflank-mailman (output) from mailman id 126817.238369; Thu, 13 May 2021 10:03:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lh8Bq-0007O2-10; Thu, 13 May 2021 10:03:34 +0000 Received: by outflank-mailman (input) for mailman id 126817; Thu, 13 May 2021 10:03:32 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lh8Bo-0003vg-3g for xen-devel@lists.xenproject.org; Thu, 13 May 2021 10:03:32 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 70819697-d6d0-4f9d-a70f-64adb0fb8e2a; Thu, 13 May 2021 10:03:08 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 0DC46B15E; Thu, 13 May 2021 10:03:07 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 70819697-d6d0-4f9d-a70f-64adb0fb8e2a X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1620900187; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j+l5tq5M/f1kECXbl74yHxqhOUkbjQkUE4NZC677IzI=; b=muXNug23i8D8WshIzxtjKc3x9GnLaAOKXKGlzsXTDl/23evlPFNCHKHd4a4SVRdSANqXEp icn4g/Bx1ghMjx9o1JXTxQFB4zJLnEvn3Te0fnTR9PVC/fhKkMdndGrcacL/hxHOGrnzad pwoTCoUMnAz3BRbea9XDOTFJf6ozUQ4= From: Juergen Gross To: xen-devel@lists.xenproject.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH 8/8] xen/hvc: replace BUG_ON() with negative return value Date: Thu, 13 May 2021 12:03:02 +0200 Message-Id: <20210513100302.22027-9-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210513100302.22027-1-jgross@suse.com> References: <20210513100302.22027-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" Xen frontends shouldn't BUG() in case of illegal data received from their backends. So replace the BUG_ON()s when reading illegal data from the ring page with negative return values. Signed-off-by: Juergen Gross --- drivers/tty/hvc/hvc_xen.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c index 92c9a476defc..30d7ffb1e04c 100644 --- a/drivers/tty/hvc/hvc_xen.c +++ b/drivers/tty/hvc/hvc_xen.c @@ -86,6 +86,11 @@ static int __write_console(struct xencons_info *xencons, cons =3D intf->out_cons; prod =3D intf->out_prod; mb(); /* update queue values before going on */ + + if (WARN_ONCE((prod - cons) > sizeof(intf->out), + "Illegal ring page indices")) + return -EINVAL; + BUG_ON((prod - cons) > sizeof(intf->out)); =20 while ((sent < len) && ((prod - cons) < sizeof(intf->out))) @@ -114,7 +119,10 @@ static int domU_write_console(uint32_t vtermno, const = char *data, int len) */ while (len) { int sent =3D __write_console(cons, data, len); - =09 + + if (sent < 0) + return sent; + data +=3D sent; len -=3D sent; =20 @@ -138,7 +146,10 @@ static int domU_read_console(uint32_t vtermno, char *b= uf, int len) cons =3D intf->in_cons; prod =3D intf->in_prod; mb(); /* get pointers before reading ring */ - BUG_ON((prod - cons) > sizeof(intf->in)); + + if (WARN_ONCE((prod - cons) > sizeof(intf->in), + "Illegal ring page indices")) + return -EINVAL; =20 while (cons !=3D prod && recv < len) buf[recv++] =3D intf->in[MASK_XENCONS_IDX(cons++, intf->in)]; --=20 2.26.2