Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5928689ybp; Tue, 15 Oct 2019 07:09:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXhFIM1/PogzkuPsxvY7/lPcC6ro7s5AJn4lQK4z5CokrH3bLO1KhvDuTIrFOeb4jwBxk7 X-Received: by 2002:aa7:db59:: with SMTP id n25mr10626512edt.288.1571148585534; Tue, 15 Oct 2019 07:09:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571148585; cv=none; d=google.com; s=arc-20160816; b=RPEAjBB0F6vuJtAccUFxwNv/GenWM5V87ZJLp+H74T7XI4nWt7jKDum6KouA6taJUZ W2rqnzSCPja/5MJzXJ6E+RQ2V1KIWvmkPjVSj1PuM0zikwzhcIG6B3T279nsVJ/XDZKi wOpZbqRCo965r8JgO6ye5ziNiJxsTTf7UECXdXAo9eKdDdp0WP3YJsoRlPfMov6xY8Hv IFt5vOvt1dPTIxloZteXhdPFVX/Ay/RJWeJSGZ0A9jeQ7bb7f2ZTb2mtiTCiPCG71JEV Ek0gq5zuUjDh9EEoaaOTpTxgRmt1pHyRnZJV4erPy7wGr1G0S235K93irzCgyHXZpXas sbXw== 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:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=qNZCwssE+agkEqCxaKtKVtylCGvXFSXX5DhiQKaIXpg=; b=TyXB/Uh+r8K1QeuFFGUaQIWaEl5t1bYziFGamat/L5eYTJWJyeL6pMtr1pOXV/fNrg w6GX1FryhECsyPSU4pqTrBBKHVdhZKlphHRY00RB7cWaZv8FC1b8IOU8HzRo903UxhvB q9cBVloKdq1r6m4+iDc1NcGIJtraWFd3TbF4WgckFi/rD+tVpO9YzWBqqV7TaiHPULUa TYq8L/A4WceI4qBOGwQxum/kmehfiHMyAozNO9VwuP/ew28w5sAHWCDrnBD7YRqpRfu5 HslV0x40VOrvFgk3de4fr98DDbRqDIu5git1IvkM6cwLggCUOluOC3pabhv4XjAtHVDX 8h3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=NPijPlHE; 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 a29si15558509eda.246.2019.10.15.07.09.21; Tue, 15 Oct 2019 07:09:45 -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=fail header.i=@ffwll.ch header.s=google header.b=NPijPlHE; 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 S1732474AbfJOOHc (ORCPT + 99 others); Tue, 15 Oct 2019 10:07:32 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:39649 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732292AbfJOOHc (ORCPT ); Tue, 15 Oct 2019 10:07:32 -0400 Received: by mail-ed1-f67.google.com with SMTP id a15so18149083edt.6 for ; Tue, 15 Oct 2019 07:07:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=qNZCwssE+agkEqCxaKtKVtylCGvXFSXX5DhiQKaIXpg=; b=NPijPlHE9mOZETSF+T0qFTrnynppESRm1hPk8m15z6BtFKp/f35nb6fP0AtxA+vICD JOWnOXgGumAnnyCgoxgqcArGuemzJeDfqPdA4LYis0/rmWoNPx8t+Aa38BhPM8yc5J1y jTOJ95BLBFELDrUekBUcpVOI1TGYpw9L5o3bg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=qNZCwssE+agkEqCxaKtKVtylCGvXFSXX5DhiQKaIXpg=; b=ipWIOzCw/uRmubq1B4oZWmXwIlwEeDtehxHJwQoLd8ew6OLciyHyAbZC2/fJ5jIaxT KraQOY5K09gKeeqGG+4OqB5TTAH4t4xN5YM5xVMlH/0OwkmSxRLqeDwwKvs3bNO/qWfO AKsFr4CkM2MuI3xE0uYjMRXQ7pqK0RqpquZZX0AzEBCkq9WUaAXFt2YRxJT52NlDTr5v nb+n0RrzXOl5XEDMnAtxFvIZXArx4ayX31DEOUztMXmJUV3HqD1VAv3Ns4CNwYjdpoUY uCAuZlnNIhkMLgDQlh/0XfM+l89/sot7wKFAChgDnnQqLLMi3OAoY/p0m+d9z7IimZGp Px1g== X-Gm-Message-State: APjAAAWYCWAXQQqBRa3j/sBKy7qBb8cX6Emlj2ZNprPbABNExHQ9IcKY nC9lgo6bUy4qr5iAPKAHXInGDw== X-Received: by 2002:a17:906:6a8e:: with SMTP id p14mr34255737ejr.137.1571148449724; Tue, 15 Oct 2019 07:07:29 -0700 (PDT) Received: from phenom.ffwll.local (212-51-149-96.fiber7.init7.net. [212.51.149.96]) by smtp.gmail.com with ESMTPSA id d2sm3745355eda.20.2019.10.15.07.07.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2019 07:07:28 -0700 (PDT) Date: Tue, 15 Oct 2019 16:07:26 +0200 From: Daniel Vetter To: Johan Hovold Cc: Daniel Vetter , Rob Clark , Sean Paul , Fabien Dessenne , Mauro Carvalho Chehab , Harald Freudenberger , David Airlie , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-s390@vger.kernel.org, Greg Kroah-Hartman , Al Viro Subject: Re: [PATCH 0/4] treewide: fix interrupted release Message-ID: <20191015140726.GN11828@phenom.ffwll.local> Mail-Followup-To: Johan Hovold , Rob Clark , Sean Paul , Fabien Dessenne , Mauro Carvalho Chehab , Harald Freudenberger , David Airlie , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-s390@vger.kernel.org, Greg Kroah-Hartman , Al Viro References: <20191010131333.23635-1-johan@kernel.org> <20191010135043.GA16989@phenom.ffwll.local> <20191011093633.GD27819@localhost> <20191014084847.GD11828@phenom.ffwll.local> <20191014161326.GO13531@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191014161326.GO13531@localhost> X-Operating-System: Linux phenom 5.2.0-2-amd64 User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 14, 2019 at 06:13:26PM +0200, Johan Hovold wrote: > On Mon, Oct 14, 2019 at 10:48:47AM +0200, Daniel Vetter wrote: > > On Fri, Oct 11, 2019 at 11:36:33AM +0200, Johan Hovold wrote: > > > On Thu, Oct 10, 2019 at 03:50:43PM +0200, Daniel Vetter wrote: > > > > On Thu, Oct 10, 2019 at 03:13:29PM +0200, Johan Hovold wrote: > > > > > Two old USB drivers had a bug in them which could lead to memory leaks > > > > > if an interrupted process raced with a disconnect event. > > > > > > > > > > Turns out we had a few more driver in other subsystems with the same > > > > > kind of bug in them. > > > > > > > Random funny idea: Could we do some debug annotations (akin to > > > > might_sleep) that splats when you might_sleep_interruptible somewhere > > > > where interruptible sleeps are generally a bad idea? Like in > > > > fops->release? > > > > > > There's nothing wrong with interruptible sleep in fops->release per se, > > > it's just that drivers cannot return -ERESTARTSYS and friends and expect > > > to be called again later. > > > > Do you have a legit usecase for interruptible sleeps in fops->release? > > The tty layer depends on this for example when waiting for buffered > writes to complete (something which may never happen when using flow > control). > > > I'm not even sure killable is legit in there, since it's an fd, not a > > process context ... > > It will be run in process context in many cases, and for ttys we're good > AFAICT. Huh, read it a bit, all the ->shutdown callbacks have void return type. But there's indeed interruptible sleeps in there. Doesn't this break userspace that expects that a close() actually flushes the tty? Imo if you're ->release callbacks feels like it should do a wait to guaranteed something userspace expects, then doing a wait_interruptible/killable feels like a bug. Or alternatively, the wait isn't really needed in the first place. > > > The return value from release() is ignored by vfs, and adding a splat in > > > __fput() to catch these buggy drivers might be overkill. > > > > Ime once you have a handful of instances of a broken pattern, creating a > > check for it (under a debug option only ofc) is very much justified. > > Otherwise they just come back to life like the undead, all the time. And > > there's a _lot_ of fops->release callbacks in the kernel. > > Yeah, you have a point. > > But take tty again as an example, the close tty operation called from > release() is declared void so there's no propagated return value for vfs > to check. > > It may even be better to fix up the 100 or so callbacks potentially > returning non-zero and make fops->release void so that the compiler > would help us catch any future bugs and also serve as a hint for > developers that returning errnos from fops->release is probably not > what you want to do. > > But that's a lot of churn of course. Hm indeed ->release has int as return type. I guess that's needed for file I/O errno and similar stuff ... Still void return value doesn't catch funny stuff like doing interruptible waits and occasionally failing if you have a process that likes to use signals and also uses some library somewhere to do something. In graphics we have that, with Xorg loving signals for various things. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch