Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp291982ybb; Thu, 19 Mar 2020 22:16:29 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsdn8Xaw/16U5uE3MM7UZrS8IL+DKciq8HxZir1F6pj/r5gbD8bB0T9p03bQIgYmMxud6zx X-Received: by 2002:a05:6830:1e25:: with SMTP id t5mr5098213otr.70.1584681389140; Thu, 19 Mar 2020 22:16:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584681389; cv=none; d=google.com; s=arc-20160816; b=0XMfBtRavFT9Qc0mpYnvKnQuUOmQPGpHUbRUc/uwzCCtextB732uSoQad07oKIYCYy VPThhS/CrNb5k9c/HpRvJWYKFQoR+2LPCF+GCD/IV6IF3ywdJTgo6B/cQTQVmuBVnrlH sVQ1NcibRYqsiNCJTH016HahoDhbF/j+N2qfuHfMh4jpfgXWW/zSUeXt59PW3tRcMYI5 jBOZwHtYWrdibXlkyYAZgKMh730EvbXyOeFdCsI7tk6dnCGhs3esWrI9CeNkoLdmfSZ9 3D0WJb0Kuslacu21gMjGz8kFfBvNKr0D5dZnAT61OgxyiJPsXqQX4votArPVhZyZkQlP ubyA== 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=iQ11qACfkZeclFLprsNZvpJpxtw/SpVFitSukJq3LYo=; b=LQ3JUeEflcvZ6X39dkEnRYQFaPwHHklpFrCz4S9oYUtXxrGrmYn9UYsZL1n08sg8yV mSXFrjpSeN28bT0hI5EafN9MwW9fnNIir02KtD2fnfQFoglQAkjjaYvGQFoTBKKY6PfY tZg4JEgkF8ACUNWQS0Bp+/on8EwZ3cby69NCwm5h8Pb7qE8YSO9l66fMx9Wi1fnXa/rM PwpqvFWaQvhNbEUouwdN7TmIB5leosXx/dnLBdUam0YgT7oR/JUGB9zj3ThW9Kea6TB4 9EUeTFoboUZN1g2/kRLZ9Wp6wS/1/h5aH69U7H+gnmU7WOEVJBbZFYZoujcw4fO7dhMN lBmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CS+AMu4L; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u136si2223608oif.197.2020.03.19.22.16.04; Thu, 19 Mar 2020 22:16:29 -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=@kernel.org header.s=default header.b=CS+AMu4L; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726584AbgCTFKw (ORCPT + 99 others); Fri, 20 Mar 2020 01:10:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:59420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725883AbgCTFKw (ORCPT ); Fri, 20 Mar 2020 01:10:52 -0400 Received: from sol.localdomain (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 05DE12072D; Fri, 20 Mar 2020 05:10:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584681051; bh=bHqz/mmjyWz7y2CbYXKF3rlS2vNGxaJf7CYZ9FIl/Hc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CS+AMu4Ldrf5EQrnN3qqOyzcwytupsd2xi8te7S9EclBM61mvUsK4Ty8Ax7mBMCL4 JrRgTSfUZMEg0PH+nsGHFpcp9255sLia17GXV7e0lwLANmIZg5fIe0HcAz1VnEFoNM EZeQ0BASP2vftBfk6DI/UUBTAVFxJ3Wqo5/e0Rkg= Date: Thu, 19 Mar 2020 22:10:49 -0700 From: Eric Biggers To: Jiri Slaby Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, syzkaller-bugs@googlegroups.com, Eric Dumazet , Nicolas Pitre Subject: Re: [PATCH v2 1/2] vt: vt_ioctl: fix VT_DISALLOCATE freeing in-use virtual console Message-ID: <20200320051049.GA1315@sol.localdomain> References: <20200318222704.GC2334@sol.localdomain> <20200318223810.162440-1-ebiggers@kernel.org> <20200318223810.162440-2-ebiggers@kernel.org> <2f762aee-720b-9bec-620f-61129c724de6@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2f762aee-720b-9bec-620f-61129c724de6@suse.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 19, 2020 at 08:36:28AM +0100, Jiri Slaby wrote: > On 18. 03. 20, 23:38, Eric Biggers wrote: > > --- a/drivers/tty/vt/vt.c > > +++ b/drivers/tty/vt/vt.c > > @@ -1102,6 +1102,9 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */ > > tty_port_init(&vc->port); > > INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK); > > > > + /* if this wasn't the case, we'd have to implement port->ops.destruct */ > > + BUILD_BUG_ON(offsetof(struct vc_data, port) != 0); > > + > > This is 3 lines, implementing destruct would be like 4-5 :)? Please > implement destruct instead. > > Otherwise looks good. > Actually implementing destruct would be 12 lines, see below. Remember there is no tty_port_operations defined yet so we'd have to define it just for destruct. Do you still prefer it? diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index ec34f1f5f3bb5..309a39197be0a 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1075,6 +1075,17 @@ static void visual_deinit(struct vc_data *vc) module_put(vc->vc_sw->owner); } +static void vc_port_destruct(struct tty_port *port) +{ + struct vc_data *vc = container_of(port, struct vc_data, port); + + kfree(vc); +} + +static const struct tty_port_operations vc_port_ops = { + .destruct = vc_port_destruct, +}; + int vc_allocate(unsigned int currcons) /* return 0 on success */ { struct vt_notifier_param param; @@ -1100,11 +1111,9 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */ vc_cons[currcons].d = vc; tty_port_init(&vc->port); + vc->port.ops = &vc_port_ops; INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK); - /* if this wasn't the case, we'd have to implement port->ops.destruct */ - BUILD_BUG_ON(offsetof(struct vc_data, port) != 0); - visual_init(vc, currcons, 1); if (!*vc->vc_uni_pagedir_loc)