Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp268433pxj; Thu, 13 May 2021 04:38:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyS52OBEyi6aNUVlwipQpmJY3PIMQvv06ZDJk1l+JAGu9GdFejbWxj075qZCreWpxAGtj5/ X-Received: by 2002:a02:3506:: with SMTP id k6mr19547561jaa.39.1620905906551; Thu, 13 May 2021 04:38:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620905906; cv=none; d=google.com; s=arc-20160816; b=UbNbIlr1vqos4VHMwGLOoSjcDmIanbrX9QC2XiJAqNde8leYYCFdOCTeSOHwgPnD+m yUCxIspTARLvaBYl+FFw9j6+sQvIud6cTqCnIS1AoOsZTc0Qqq+k5911vlUB1bVL1IV8 ZwzTsRpg8v0N2boFERjd/ha6cOiCrD3TMHPKIad7o8rH+GG5glrN5iYGBiUK4Q7F2mg4 BNd2T13eXA9F7xfKXAjxkrqtxZhu60XpRb2JVa9ofEDJBvHE+4MjIL1eZEVDBdP1Shca X/2cWljTRu02+1gaVPkaO7ouAn5NefwdJrcned71ZnYLC86lbtaE/Vln1Iek0BRT+Ztq jFwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=KZjY+7yKccnv0bW2ohPonoJwxjb0IjVHZysPu0A8oos=; b=KJs87SIh55MSKM5JMSKlaWDUwN1/TgLbSq4Dr7O3dg7ZjYzv5ADzpv3DW3iaeSVJgN J2K9bjna9hF3ZVEXekHDq2wLofbMB+8krS2cb6XzUs1sm82SGqa5COjbXRbbw/jC+6xv xBJtEXLlyWGj0cEDua05BQNsCip6BFR1uAaWKlLC6V2duS5VxjY6N7ujDIJIz5H7NNN3 92QbE4QAZgfoGrjIzmZkKnJHDVfLGdn9cuDYVmV8CIBojoXwwUFCFns9YCXEbuDgLonl osnkG0yrj4+U2s9h7zWpkpxOaqOXB5W9LTbjDm2ezbj0B8/Sg4KIHc0isxRTGfs6hL4c glrg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x17si2510160jan.67.2021.05.13.04.38.11; Thu, 13 May 2021 04:38:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232148AbhEMKRs (ORCPT + 99 others); Thu, 13 May 2021 06:17:48 -0400 Received: from pegase2.c-s.fr ([93.17.235.10]:56307 "EHLO pegase2.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232063AbhEMKRr (ORCPT ); Thu, 13 May 2021 06:17:47 -0400 Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4Fgncz44FZz9sch; Thu, 13 May 2021 12:16:35 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id elzAeS9dJuuJ; Thu, 13 May 2021 12:16:35 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4Fgncz368bz9scg; Thu, 13 May 2021 12:16:35 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 313FE8B7F3; Thu, 13 May 2021 12:16:35 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id R8jvyF-796Mk; Thu, 13 May 2021 12:16:35 +0200 (CEST) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id B59358B76C; Thu, 13 May 2021 12:16:34 +0200 (CEST) Subject: Re: [PATCH 8/8] xen/hvc: replace BUG_ON() with negative return value To: Juergen Gross , xen-devel@lists.xenproject.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Jiri Slaby References: <20210513100302.22027-1-jgross@suse.com> <20210513100302.22027-9-jgross@suse.com> From: Christophe Leroy Message-ID: <6da4cc91-ccde-fce8-707c-e7544783c2fa@csgroup.eu> Date: Thu, 13 May 2021 12:16:35 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210513100302.22027-9-jgross@suse.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 13/05/2021 à 12:03, Juergen Gross a écrit : > 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 = intf->out_cons; > prod = 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)); Why keep the BUG_ON() ? > > 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 = __write_console(cons, data, len); > - > + > + if (sent < 0) > + return sent; > + > data += sent; > len -= sent; > > @@ -138,7 +146,10 @@ static int domU_read_console(uint32_t vtermno, char *buf, int len) > cons = intf->in_cons; > prod = 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; > > while (cons != prod && recv < len) > buf[recv++] = intf->in[MASK_XENCONS_IDX(cons++, intf->in)]; >