Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1139009pxb; Fri, 27 Aug 2021 02:02:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyRhjuiYzh4Hvie4BBGKav2imNK3ISNAfWNaL8w7EgbpHRnMCpS/BXUujuyAxD0w8S32AE X-Received: by 2002:a6b:e917:: with SMTP id u23mr6727745iof.19.1630054977275; Fri, 27 Aug 2021 02:02:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630054977; cv=none; d=google.com; s=arc-20160816; b=sbRL12TzLGqTFGsBNGt1rzbRmogQ5ZHjmegAxfLP7JHdbI2bdEhpcwtartH+DemVs9 440uTbswS+SgvD8VR3XQxRNI3XAunFvCPT711nCQdA5rNjg+J14bz7tJd4UbVjjGMPN+ sPhxyWUJfeQ+THAkZiKfJAzoTDxOJCfcOLmPh3irpMlpRhrNPAnWzhySUQo8UbtwsKre RpWHfnFa0gu1o08lAMnNKkoD19I2dtnMsA5/ExUCPg2kO5Yi93EqaInoJ1KGaX4QdgiK NWisci0WVffFl3s73L7N8bV2IkC7oF1F8mAsxs10YZpOWqHKVoMWAwor5Zez2lQTzwxd 3QIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LFK4It7XqEloNVslI8hqapwx+tJB/IYUWJuwWYhCGOI=; b=p1UOS02nOX6syDU2Uc5KXfNBzlVH3/v/a8ukyl74s2Y762qY78dsrqLbAv6san3dlf PeL8NbLKE7hDqpfu/rMyXg+WKQIfS8TarVJjSngE210RRA2Z46xAv1UCehKWWaYMnFGg NmqR8WCa250ICt1FeY3FNs84JwP/GU+sl9N0QizPLNVV8aQ38k2HAoFM+y6C7ukG55HX JRdUtv+FWkCJZ5VtU7uQIA436VwjJS/e0rYBOfLyZCwTgHr+8wPUbvulka+vOPqGFDDw 1BTUlG7uXkfV5G090ngUabAMXaKssWMLWkLMUWrvnzZ0MMkPPUgsmiedccs2lseJk71g LGww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A+dBROUY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q8si5584315ilo.162.2021.08.27.02.02.45; Fri, 27 Aug 2021 02:02:57 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A+dBROUY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244548AbhH0JBV (ORCPT + 99 others); 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