Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp919006ybm; Wed, 22 May 2019 13:57:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqx4FkoKnORYQKAQS7Qgj3QjB+GNdxjuFS+qwpvvggsO3ipfWxhtdLNNSLe5QOvqzBUI5MVG X-Received: by 2002:a63:1a03:: with SMTP id a3mr93556093pga.412.1558558631357; Wed, 22 May 2019 13:57:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558558631; cv=none; d=google.com; s=arc-20160816; b=Am/kbmEgImlFnWm3cHio4CaXZf+wFIr3r/WCg0UuSXFI9Evd9NNPfb3wlTd3ZUN3F4 GKgCmJop/xTJCv/Ez5AUbbzcnqvlouwydpQbBIz7IZFtqPu/nNMb9MKv8hiw7OLCOAwY yAhM3X/jRKUwICJuMbaYWZhLy3nK+pL7+7ILr8UTYxTffraIyMZUeP1BKLuNuPc1KB7p MGCqud4l1fEKJDS88JftG8jYtottGiMTKklb//M7KMQb/d2lUTMrjLF3R+OnJomuwQg5 IqVyQTxN4KPOxVeLergTl0+0UhWW0yfW9bGPZTWeD3SuqX1mE71EB5JwmPWTI4aLAdpr ehcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=wb2xYG/vaqBuTYr8EC9pKNFA50F+MaGFUq5jU06hCpI=; b=bsFr8ISo/ui59hYhdL6Sh3GSRpG/vlfMip4pqMSv8QHHugUFtFQByscN/qZ3HwlD7z 3D8kk1/cC4VxtPDIJ8tn1S++ynqTs5gXbeTmFCLdyUmFU8Gfa4aMssCRPewzHG8sayzm zjiRue7NEgw76pWkzXtNRL7XKCPvt40kofxs7mVfLHCzRWYg0satz+7x5rQhtyfJu9aW 8vwDZKzYcYHuAKAOpb7fPIYhSQhkk0id8mt65zbEYkCuA+xugpxdYTGpIGjwSj1ftSK+ HhmLn/PN+lwKELeN2Npb1NImhXACe9Z85/qWs6To36iFq4skrpecIXCiejRg2XQKh5Ck HsYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ZsWbcteA; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k184si24844772pge.82.2019.05.22.13.56.55; Wed, 22 May 2019 13:57:11 -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=@chromium.org header.s=google header.b=ZsWbcteA; 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=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730259AbfEVUyu (ORCPT + 99 others); Wed, 22 May 2019 16:54:50 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:39210 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729980AbfEVUyu (ORCPT ); Wed, 22 May 2019 16:54:50 -0400 Received: by mail-pl1-f194.google.com with SMTP id g9so1638224plm.6 for ; Wed, 22 May 2019 13:54:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=wb2xYG/vaqBuTYr8EC9pKNFA50F+MaGFUq5jU06hCpI=; b=ZsWbcteAcKvqlbL0XchkDzsiNFbre5iRTaBErI2NbAVs8jKRHtRARU/OqojtisS531 GtdpDIRrtuYX0nWZXcY/9wTvm3k1T1dZRPFRdEODpKDr6ZAvgekbDN04nBo/ftMYfmTs I7EN0j163Jn6QCRWL+EkKxp9pFFGyV/rSz/xk= 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; bh=wb2xYG/vaqBuTYr8EC9pKNFA50F+MaGFUq5jU06hCpI=; b=TpE9V22fCYd/Xc0cIEjddcl8FeVTdSGcVimoCjw6gZ7fPPpj5FmUioCPlIHrQdA9BV EwVia6ZsrKnTdrmQHDMqaLteoJOGXXOH8CsZIP+Fz9OQKYoNiud+OC+BfO8FsKOIIa8b XblXVWuy8hMGFSLNb8psaGSpi5UhZ3D6O+ulaq0xdVFrwrEvDButKJzH/vn5/ER28ZmW j0FmpETwmO/0ooH+XS+Id0WwNirKerqAKocKCUQEcQCAg5uFy1wOMKAjqqd7DOHsuZJ8 OcI7fnJJb+s2WKIf6gOF7ZWQ0okozzq4nI7YeICCGWJTUdQGocnRsxKbcVTTwBatbN/O Qh+w== X-Gm-Message-State: APjAAAXQrbySWHSgVICDUPFizpbdRC85HLGsyEweCEP8lq99GjUx7wJ2 rn4w8qj0UDSBneaqWD045jfNKA== X-Received: by 2002:a17:902:e583:: with SMTP id cl3mr93651928plb.35.1558558490033; Wed, 22 May 2019 13:54:50 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id w4sm28698723pfi.87.2019.05.22.13.54.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 22 May 2019 13:54:48 -0700 (PDT) Date: Wed, 22 May 2019 13:54:47 -0700 From: Kees Cook To: Gen Zhang Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] consolemap: Fix a memory leaking bug in drivers/tty/vt/consolemap.c Message-ID: <201905221353.AD8E585E6D@keescook> References: <20190521092935.GA2297@zhanggen-UX430UQ> <201905211342.DE554F0D@keescook> <20190522015055.GC4093@zhanggen-UX430UQ> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190522015055.GC4093@zhanggen-UX430UQ> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 22, 2019 at 09:50:55AM +0800, Gen Zhang wrote: > On Tue, May 21, 2019 at 01:44:33PM -0700, Kees Cook wrote: > > This doesn't look safe to me: p->uni_pgdir[n] will still have a handle > > to the freed memory, won't it? > > > Thanks for your reply, Kees! > I think you are right. Maybe we should do this: > kfree(p1); > p->uni_pgdir[n] = NULL; > Is this correct? That's what I'm not sure about. I *think* so, from reading the code, but I'd love to have Greg (or someone more familiar with the code) to double-check this. Otherwise, yeah, this looks right. Please send a v2 and we can debate the correctness there, if it turns out to be wrong. :) -- Kees Cook