Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp461987ybm; Mon, 20 May 2019 20:27:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqyHj0hPVwf6idN3a4832c7OsPp6j9rpBVOEbZVsSXrceIMjtVm0X3Ap/KPTO6Pswqya6m0/ X-Received: by 2002:a62:36c1:: with SMTP id d184mr63346178pfa.49.1558409261615; Mon, 20 May 2019 20:27:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558409261; cv=none; d=google.com; s=arc-20160816; b=z47/KM4QvNePlBRVX/xS/fCZVTcp0k2SgAkOCBslBZRmHClekLOXZjKkZyVKo+G2Bl om1jSZC82bvLncjBBn8nMmeG/XjKlvibGSZ2dtKEEdN4qRa3+4lqGNIobxvjlZRueqZ5 9aXfSZ2AOsBPadfS2drqqtnjhCtB5OcdE1IonA6riEdWCbOU7VjmAwXqhKUMrdLHKvyx WihZFoD8tIjNKePlh1WbGIOE2sivDPRk6gkICxrv6OUZLJz+XtcF8obQQabXgCNnP9ml FaR+NiHWzoGjL1uB5raVE79DS7Hf1/Qv1HHwRgNiULTS0MJmMgXqnzPwu+bWar2HoJe1 SXzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=Om9ukXtzqmKixhAwQ8OfHupnm0NnE+N9oZ4p30fBEV4=; b=ZRMun7uKF1QYn5Si+mcqigLcMj7v27k3khS5iAmABxA7txfP4oTbmKOVxvozhq8ZkO er8xoYfPZFDKR9s0PEKk3PmwFUTSbRLoDqs6/ekKWbeWA2WQg7UtpBzg8jlgzhO93gO7 ZPxdSc0QZG8U2hFHQEGGgoAuAOqhSjz5ibhH9A05uHfHVX7ZIgmwGhsGEXq1KoGT57Ew OsnnHAZzf1dpXqJoBvCQCVJawUwPqmOmyiau09U6PLfzsYw/PZP0GtQs5RylC0uItcnF lw7W0Ow2cqYLPUoxL6x9/T08QWbvELSmOOUfBG2Ux8rrSWxjpmSZS0VRqX3+iiL9RmfO HdGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pobox.com header.s=sasl header.b=BgGP1FIV; dkim=temperror (no key for signature) header.i=@fluxnic.net header.s=2016-12.pbsmtp header.b="yZ/D4gWH"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f71si18790011pgc.150.2019.05.20.20.27.26; Mon, 20 May 2019 20:27:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@pobox.com header.s=sasl header.b=BgGP1FIV; dkim=temperror (no key for signature) header.i=@fluxnic.net header.s=2016-12.pbsmtp header.b="yZ/D4gWH"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727371AbfEUD0X (ORCPT + 99 others); Mon, 20 May 2019 23:26:23 -0400 Received: from pb-smtp2.pobox.com ([64.147.108.71]:54430 "EHLO pb-smtp2.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726335AbfEUD0X (ORCPT ); Mon, 20 May 2019 23:26:23 -0400 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 5BCBF151420; Mon, 20 May 2019 23:26:22 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=date:from:to :cc:subject:in-reply-to:message-id:references:mime-version :content-type; s=sasl; bh=LVuPGpXr80mFouDhZEE1IjAN6jw=; b=BgGP1F IVT8K9uI4GkRommMJwMDnWP59DaDWWqxkLFICYYswPxFLn7/Crtvb9zqliN73XtJ 9xAX+GoPwBAT3+BnWd3jIYFy/rCH1F9bVohs7n9Mvj2g9JKOFpdfGAIFHYUM1xVL LjJHF5Y04W3qRYzkSyOR7K9uKKQkzx53mavhI= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 536CD15141E; Mon, 20 May 2019 23:26:22 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=fluxnic.net; h=date:from:to:cc:subject:in-reply-to:message-id:references:mime-version:content-type; s=2016-12.pbsmtp; bh=oVvGLlqFaKaJTDSYhHZSKXhIQqqadHQ/RfPlc0WJLwQ=; b=yZ/D4gWH/UsL7VX9SUehU1p/R22XTdy8vXXXqD7BOCzdXptKZN8knqLe3ncDo86uqCijZwdIVGTUToUwWmpSka1tTitpMIxiDD45cekeVWpNtRnReQbt/FDDwM9zHyIYB2A2ZtwYOu5yDWzNWTgepkoWlEOFJdGkUCicz3/Q59A= Received: from yoda.home (unknown [70.82.130.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id CAEAF15141C; Mon, 20 May 2019 23:26:21 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTPSA id E193C2DA01F4; Mon, 20 May 2019 23:26:20 -0400 (EDT) Date: Mon, 20 May 2019 23:26:20 -0400 (EDT) From: Nicolas Pitre To: Gen Zhang cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] vt: Fix a missing-check bug in drivers/tty/vt/vt.c In-Reply-To: <20190521030905.GB5263@zhanggen-UX430UQ> Message-ID: References: <20190521022940.GA4858@zhanggen-UX430UQ> <20190521030905.GB5263@zhanggen-UX430UQ> User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Pobox-Relay-ID: 347E308E-7B78-11E9-B326-E828E74BB12D-78420484!pb-smtp2.pobox.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 21 May 2019, Gen Zhang wrote: > On Mon, May 20, 2019 at 10:55:40PM -0400, Nicolas Pitre wrote: > > On Tue, 21 May 2019, Gen Zhang wrote: > > > > > In function con_init(), the pointer variable vc_cons[currcons].d, vc and > > > vc->vc_screenbuf is allocated a memory space via kzalloc(). And they are > > > used in the following codes. > > > However, when there is a memory allocation error, kzalloc() can fail. > > > Thus null pointer (vc_cons[currcons].d, vc and vc->vc_screenbuf) > > > dereference may happen. And it will cause the kernel to crash. Therefore, > > > we should check return value and handle the error. > > > Further,the loop condition MIN_NR_CONSOLES is defined as 1 in > > > include/uapi/linux/vt.h. So there is no need to unwind the loop. > > > > But what if someone changes that define? It won't be obvious that some > > code did rely on it to be defined to 1. > I re-examine the source code. MIN_NR_CONSOLES is only defined once and > no other changes to it. Yes, that is true today. But if someone changes that in the future, how will that person know that you relied on it to be 1 for not needing to unwind the loop? Nicolas