From patchwork Sun Jan 5 20:36:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yann Droneaud X-Patchwork-Id: 307017 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 90E732C050B for ; Mon, 6 Jan 2014 07:38:58 +1100 (EST) Received: from smtp5-g21.free.fr (smtp5-g21.free.fr [IPv6:2a01:e0c:1:1599::14]) by ozlabs.org (Postfix) with ESMTP id 0E96C2C01C7; Mon, 6 Jan 2014 07:38:07 +1100 (EST) Received: from localhost.localdomain (unknown [IPv6:2a01:e35:2e9f:6ac0:8e70:5aff:fe2f:2d74]) by smtp5-g21.free.fr (Postfix) with ESMTP id D1EB4D48149; Sun, 5 Jan 2014 21:37:48 +0100 (CET) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.14.7/8.14.7) with ESMTP id s05Kbknh015852; Sun, 5 Jan 2014 21:37:47 +0100 Received: (from ydroneaud@localhost) by localhost.localdomain (8.14.7/8.14.7/Submit) id s05KbjwL015851; Sun, 5 Jan 2014 21:37:45 +0100 From: Yann Droneaud To: Jeremy Kerr , Arnd Bergmann , Benjamin Herrenschmidt , Paul Mackerras Subject: [PATCHv5 2/7] ppc/cell: use get_unused_fd_flags(0) instead of get_unused_fd() Date: Sun, 5 Jan 2014 21:36:29 +0100 Message-Id: X-Mailer: git-send-email 1.8.4.2 In-Reply-To: References: In-Reply-To: References: Cc: Yann Droneaud , cbe-oss-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Al Viro , Andrew Morton , linuxppc-dev@lists.ozlabs.org X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Macro get_unused_fd() is used to allocate a file descriptor with default flags. Those default flags (0) can be "unsafe": O_CLOEXEC must be used by default to not leak file descriptor across exec(). Instead of macro get_unused_fd(), function get_unused_fd_flags() (or anon_inode_getfd()) should be used with flags given by userspace. If not possible, flags should be set to O_CLOEXEC to provide userspace with a default safe behavor. In a further patch, get_unused_fd() will be removed so that new code start using get_unused_fd_flags() (or anon_inode_getfd()) with correct flags. This patch replaces calls to get_unused_fd() with equivalent call to get_unused_fd_flags(0) to preserve current behavor for existing code. The hard coded flag value (0) should be reviewed on a per-subsystem basis, and, if possible, set to O_CLOEXEC. Cc: Al Viro Signed-off-by: Yann Droneaud Link: http://lkml.kernel.org/r/cover.1388952061.git.ydroneaud@opteya.com --- arch/powerpc/platforms/cell/spufs/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c index 87ba7cf99cd7..51effcec30d8 100644 --- a/arch/powerpc/platforms/cell/spufs/inode.c +++ b/arch/powerpc/platforms/cell/spufs/inode.c @@ -301,7 +301,7 @@ static int spufs_context_open(struct path *path) int ret; struct file *filp; - ret = get_unused_fd(); + ret = get_unused_fd_flags(0); if (ret < 0) return ret; @@ -518,7 +518,7 @@ static int spufs_gang_open(struct path *path) int ret; struct file *filp; - ret = get_unused_fd(); + ret = get_unused_fd_flags(0); if (ret < 0) return ret;