Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp478132imu; Thu, 3 Jan 2019 01:17:40 -0800 (PST) X-Google-Smtp-Source: ALg8bN7UZwA612vu+BkiUo/g5W4sVNhYr94xK+x3Z+yuzM+aRU0BI/fqZq10+K6JDD2piKZo5KUD X-Received: by 2002:a62:3adc:: with SMTP id v89mr2988302pfj.109.1546507060106; Thu, 03 Jan 2019 01:17:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546507060; cv=none; d=google.com; s=arc-20160816; b=eqtaez7sL1FKjZcYSHGfC3V98u0CGUMCKiX6EbJtQU9p6hvOZO8HWkF7i+fLFbUOlW nsJNSzF49dLPuqQEM/0v8JCIyUSJziRYuoN9eAI2skSY8b3G4y7SDKyI8mFvzl8Ompx+ ZBpkxI1CPrPnScZqKZWbsOosYBlxh9CIaBCZKs3BZoeCYAbZks0RBFaf5YHOZPNMr9tQ N1fA+FT80j5OOlalLs+L7FjOWBwclb2ATKfkQpQJ+z+F6o4BA1HTFAYWrf/FaaUo8oiE f42FA5AzS3d8IJpA/+XHdKKFE/2fvvGHMg7r1wts1UhFdA09unRnYjso94RY7Om4F7Lo 6ifQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=cJyRGT+C01WgIuSjVx+wXJmR/1tfKSzurT8be3/qBu4=; b=OKS8tiz2hpihlMDfZxhLXusyi9WHtZAY6O9dHeea5xpvlJGmjqquaW58f8WLRpQvw/ YYlN/WKmA9PGP9UrvOCW5haOMjjoXOjm3zl72DsywR7w0bolWAlTCZOQ4LJE1Z1zJ2kL FGNASoJlatN4voUWmkM9cK3Y5wI6L7D14gNj1nXMxxx7hHEHIozLiIoSFdTL/FZ8Uv8Q p2wdVlRTNPmgTS7oXmZgKIGc9RbE/JuG/0UbcxGa8OgRI0Z4Dkc5bFeZGzSNcVufotVy WXjzefIq72X5DpmWHRnpSziGtJ1Dur/jzsEHtSvaEwlZbPX2vu/2qLGD9sI3jP7C5+ab 9k2w== ARC-Authentication-Results: i=1; mx.google.com; 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 d125si17800469pgc.418.2019.01.03.01.17.04; Thu, 03 Jan 2019 01:17:40 -0800 (PST) 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; 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 S1729025AbfACE0t (ORCPT + 99 others); Wed, 2 Jan 2019 23:26:49 -0500 Received: from gate.crashing.org ([63.228.1.57]:47006 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726129AbfACE0t (ORCPT ); Wed, 2 Jan 2019 23:26:49 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id x034QTgZ013652; Wed, 2 Jan 2019 22:26:31 -0600 Message-ID: Subject: Re: [PATCH] fsi:fsi-sbefifo: Fix possible concurrency use-after-free bugs in sbefifo_user_release From: Benjamin Herrenschmidt To: David Howells , Jia-Ju Bai Cc: joel@jms.id.au, eajames@linux.vnet.ibm.com, andrew@aj.id.au, linux-kernel@vger.kernel.org Date: Thu, 03 Jan 2019 15:26:28 +1100 In-Reply-To: References: <20181226135618.12784-1-baijiaju1990@gmail.com> <26864.1546421693@warthog.procyon.org.uk> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.2 (3.30.2-2.fc29) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2019-01-03 at 14:27 +1100, Benjamin Herrenschmidt wrote: > On Wed, 2019-01-02 at 09:34 +0000, David Howells wrote: > > Jia-Ju Bai wrote: > > > > > + mutex_lock(&user->file_lock); > > > sbefifo_release_command(user); > > > free_page((unsigned long)user->cmd_page); > > > + mutex_unlock(&user->file_lock); > > > > It shouldn't be necessary to do the free_page() call inside the locked > > section. > > True. However, I didn't realize read/write could be concurrent with > release so we have another problem. > > I assume when release is called, no new read/write can be issued, I am > correct ? So all we have to protect against is a read/write that has > started prior to release being called, right ? Hrm... looking briefly at the vfs, read/write are wrapped in fdget/fdput, so release shouldn't happen concurrently or am I missing something here ? Cheers, Ben.