Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp642666ybm; Tue, 21 May 2019 00:41:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxHJgTllT/yqERq+ox7+OYOrC4my/AAaNpq1okfdretcqyL0vWfLmnS1ZjnPezBD/O3Ayhf X-Received: by 2002:a63:1119:: with SMTP id g25mr44470605pgl.380.1558424467946; Tue, 21 May 2019 00:41:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558424467; cv=none; d=google.com; s=arc-20160816; b=c4oOcwKszRRB6PejC3pvwWUoL1burlaIs8A7VJNkBjDfE24utUVwTMIgzIOYuXcNth wlq7d4baRGc6gB1gf4lOKNGRHTMManFYU7H/BzHFmHnCBabD4gnhd1P3nldrM+QKPa+f IPuV2r6pWnnzM6+q28jw+0oGgfAqpwq+4FEJISZ0GEZWyc+LlejVG7Dm0GA1Cv7SKzfL Y4AtWacQbu+HNSaFvt36488T/ORnJnGBDx/NvtM+etGMFAAvK2yHIMr2Ys9vEkRj6jHl zOIV7mNtQryNhuQxZ+m701xQgNA+tTFCRoloF7tbdZtYzdpfL4tsHQuNZuz0Qekw116o e/uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ertU93vLyvZbyhqI5mMBCSgKS6RS62cHiIXJIbfZNjU=; b=V3wpzNqHuK8YpHwuo0JcBtkDwnFgWWgwBSfr8ktIJcg4vZSsJy2wflUEi/60Q5NfKn Quud7g9jjj2E0MVjGhU84kFAv/5wwaEvPSpItnF5Tk72wbcAf/qeU5C8RRMLRUMTTPxw iNkm1HKQZ8L9qv85YMMTyTZnspOfX6aXr7yrORc3NO7iZFIB+bPRQd21laRHZ9QDAfL3 Y3CrMLw8+YLQ1cYt+5sm+uLSxjS71vqsNQ4wutoQUrGzJ7X/P6wwSr2G9BDAUJOiyv6M viq7oiGLjyraL2glPai7HdPmU0SZ8B8N/ZCUxS4Az88+6TDTkLv1YwLRWK0NNE6dbq8A rb7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=O5AMhsix; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 129si11427702pfe.140.2019.05.21.00.40.52; Tue, 21 May 2019 00:41:07 -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=@gmail.com header.s=20161025 header.b=O5AMhsix; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727119AbfEUHjN (ORCPT + 99 others); Tue, 21 May 2019 03:39:13 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:33244 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726059AbfEUHjN (ORCPT ); Tue, 21 May 2019 03:39:13 -0400 Received: by mail-pg1-f196.google.com with SMTP id h17so8157600pgv.0 for ; Tue, 21 May 2019 00:39:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ertU93vLyvZbyhqI5mMBCSgKS6RS62cHiIXJIbfZNjU=; b=O5AMhsixq0BooHonQfVIB2VNXmTe/upfgN0xFMResCgzVpKx7PZuo61IDBt/QfI8Mx h/TTholMO0hFP/jLW2R0GvL5yHsCbPwdDDJyDRsMzUZyIU319q12ERfoxn5kdrRNrm8R Wc5k+PxcNkwpEyVz7LdLXGMPTzZFVe2JHM8nMXgbduYLjfc2lW8ttCewuzVKGl6ZRUcr u2X2AioGajC9HHYWrL3YsQT6NwZFoJ8D2sio2OrLAztRJJbshsjZMm2fDyIh/V+dGGab AKf4SwIl0f5kVzz/Qpd9V+gtHdkW2SevAMnbNC/6tZpvveJ7HqCUJLmlMB36hYOV+ngv LvTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ertU93vLyvZbyhqI5mMBCSgKS6RS62cHiIXJIbfZNjU=; b=gZkQ0xzz0EbTHCX4u9DtghHu1JepasHG+o1RYFcA9PAqoD8aHHkv2yNWWud8g/R+Pn yMlslPsuxZ1O1kGQm537FI4vNHH6t81FWOtz2CTAAdngogAHQ9efMPYv6LOXa9Iza5nE keH1sW6WdicxeOv28bJaQnxmvIhUcx0IEGfmsiKKyp5gXzCAVH628L6sATM5kYKKLAVZ WI7zkj0rZXXn9N/3zenEgXvjkX4PH7PuoSV3UTdYTAd5Q6QQQxsEuA62b1I5185ak7Qx AamVVT+KZKQ8x1D4V4XFjAGu/OGQp/LC1+ojbXxsQ5AIMbsDYm7q3nD36J3GZ4GIUZVC U+Iw== X-Gm-Message-State: APjAAAXpIgER1nQa9+gbE7bU05SVZW3r/2raTAmAm6xaeyXXf3Oooky6 2AiV7/xCRtUkHmZQwgEUQm/LfCTycs0= X-Received: by 2002:a63:2c14:: with SMTP id s20mr62763921pgs.182.1558424352594; Tue, 21 May 2019 00:39:12 -0700 (PDT) Received: from zhanggen-UX430UQ ([66.42.35.75]) by smtp.gmail.com with ESMTPSA id s66sm23940174pfb.37.2019.05.21.00.39.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 May 2019 00:39:12 -0700 (PDT) Date: Tue, 21 May 2019 15:39:01 +0800 From: Gen Zhang To: Nicolas Pitre Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] vt: Fix a missing-check bug in drivers/tty/vt/vt.c Message-ID: <20190521073901.GF5263@zhanggen-UX430UQ> References: <20190521022940.GA4858@zhanggen-UX430UQ> <20190521030905.GB5263@zhanggen-UX430UQ> <20190521040019.GD5263@zhanggen-UX430UQ> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 21, 2019 at 12:30:38AM -0400, Nicolas Pitre wrote: > Now imagine that MIN_NR_CONSOLES is defined to 10 instead of 1. > > What happens with allocated memory if the err_vc condition is met on the > 5th loop? Yes, vc->vc_screenbuf from the last loop is still not freed, right? I don't have idea to solve this one. Could please give some advice? Since we have to consider the err_vc condition. > If err_vc_screenbuf condition is encountered on the 5th loop (curcons = > 4), what is the value of vc_cons[4].d? Isn't it the same as vc that you > just freed? > > > Nicolas Thanks for your explaination! You mean a double free situation may happen, right? But in vc_allocate() there is also such a kfree(vc) and vc_cons[currcons].d = NULL operation. This situation is really confusing me. Thanks Gen