From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 630B7C432BE for ; Fri, 27 Aug 2021 09:00:42 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1340960FDA for ; Fri, 27 Aug 2021 09:00:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1340960FDA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id D5938614FF; Fri, 27 Aug 2021 09:00:41 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id T8MSC_D4wyRo; Fri, 27 Aug 2021 09:00:38 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 7A6DE61518; Fri, 27 Aug 2021 09:00:37 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 532DFC0010; Fri, 27 Aug 2021 09:00:37 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id A31B2C000E for ; Fri, 27 Aug 2021 09:00:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 84BB140227 for ; Fri, 27 Aug 2021 09:00:36 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=linuxfoundation.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CF8YGB3XXDU0 for ; Fri, 27 Aug 2021 09:00:32 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp2.osuosl.org (Postfix) with ESMTPS id 841F74020A for ; Fri, 27 Aug 2021 09:00:32 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 76510608FE; Fri, 27 Aug 2021 09:00:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1630054832; bh=23w14PHSR1S/hXG90KFAr1k9F0viwRPCAvAEd5AX2Mk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=A+dBROUY5Tyvdc12gmi1XyOlgx6WummT6gQ4vLz5paKBD5NxhwDk6mV1as71SGfLk OgvtJn3lgGX4zsCsiGvoLwNcDJn0GXep5Cu24qtXWCJFpzYXxEpkd8gTcvfgbcfGOu efr4J+Nc1V85cP9KQokNqZo8d1GI7Xvz/IlSIugE= Date: Fri, 27 Aug 2021 11:00:21 +0200 From: Greg KH To: Xianting Tian Subject: Re: [RESEND][PATCH] virtio_console: protect max_nr_ports to avoid invalid value Message-ID: References: <20210820075219.202404-1-xianting.tian@linux.alibaba.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210820075219.202404-1-xianting.tian@linux.alibaba.com> Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, arnd@arndb.de, amit@kernel.org X-BeenThere: virtualization@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux virtualization List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" On Fri, Aug 20, 2021 at 03:52:19PM +0800, Xianting Tian wrote: > In theory untrusted remote host can pass a big or overflow value > of max_nr_ports to guest, it may cause guest system consumes > a lot of memory when create vqs and other impacts. How can you have a untrusted host? Can't they do a lot worse things than just this? > > Add the protection to guarantee max_nr_ports to get a safe value. > > Signed-off-by: Xianting Tian > --- > drivers/char/virtio_console.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c > index 7eaf303a7..bba985c81 100644 > --- a/drivers/char/virtio_console.c > +++ b/drivers/char/virtio_console.c > @@ -29,6 +29,8 @@ > > #define is_rproc_enabled IS_ENABLED(CONFIG_REMOTEPROC) > > +#define MAX_NR_PORTS MAX_NR_HVC_CONSOLES How was this value picked? thanks, greg k-h _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25E73C432BE for ; Fri, 27 Aug 2021 09:00:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 000CC60FF2 for ; Fri, 27 Aug 2021 09:00:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244593AbhH0JBV (ORCPT ); Fri, 27 Aug 2021 05:01:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:51330 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232048AbhH0JBU (ORCPT ); Fri, 27 Aug 2021 05:01:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 76510608FE; Fri, 27 Aug 2021 09:00:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1630054832; bh=23w14PHSR1S/hXG90KFAr1k9F0viwRPCAvAEd5AX2Mk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=A+dBROUY5Tyvdc12gmi1XyOlgx6WummT6gQ4vLz5paKBD5NxhwDk6mV1as71SGfLk OgvtJn3lgGX4zsCsiGvoLwNcDJn0GXep5Cu24qtXWCJFpzYXxEpkd8gTcvfgbcfGOu efr4J+Nc1V85cP9KQokNqZo8d1GI7Xvz/IlSIugE= Date: Fri, 27 Aug 2021 11:00:21 +0200 From: Greg KH To: Xianting Tian Cc: amit@kernel.org, arnd@arndb.de, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [RESEND][PATCH] virtio_console: protect max_nr_ports to avoid invalid value Message-ID: References: <20210820075219.202404-1-xianting.tian@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210820075219.202404-1-xianting.tian@linux.alibaba.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 20, 2021 at 03:52:19PM +0800, Xianting Tian wrote: > In theory untrusted remote host can pass a big or overflow value > of max_nr_ports to guest, it may cause guest system consumes > a lot of memory when create vqs and other impacts. How can you have a untrusted host? Can't they do a lot worse things than just this? > > Add the protection to guarantee max_nr_ports to get a safe value. > > Signed-off-by: Xianting Tian > --- > drivers/char/virtio_console.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c > index 7eaf303a7..bba985c81 100644 > --- a/drivers/char/virtio_console.c > +++ b/drivers/char/virtio_console.c > @@ -29,6 +29,8 @@ > > #define is_rproc_enabled IS_ENABLED(CONFIG_REMOTEPROC) > > +#define MAX_NR_PORTS MAX_NR_HVC_CONSOLES How was this value picked? thanks, greg k-h