From patchwork Sun Jun 1 13:58:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yann Droneaud X-Patchwork-Id: 354619 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BF6B01400CF for ; Mon, 2 Jun 2014 00:00:57 +1000 (EST) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id A43891A0B38 for ; Mon, 2 Jun 2014 00:00:57 +1000 (EST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from smtp1-g21.free.fr (smtp1-g21.free.fr [212.27.42.1]) by lists.ozlabs.org (Postfix) with ESMTP id 1BA7D1A05A9; Sun, 1 Jun 2014 23:59:33 +1000 (EST) Received: from localhost.localdomain (unknown [IPv6:2a01:e35:2e9f:6ac0:f08c:4bed:edbf:888d]) by smtp1-g21.free.fr (Postfix) with ESMTP id 09153940146; Sun, 1 Jun 2014 15:57:27 +0200 (CEST) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.14.8/8.14.7) with ESMTP id s51DxEY9026858; Sun, 1 Jun 2014 15:59:14 +0200 Received: (from ydroneaud@localhost) by localhost.localdomain (8.14.8/8.14.8/Submit) id s51DxEWg026857; Sun, 1 Jun 2014 15:59:14 +0200 From: Yann Droneaud To: Jeremy Kerr , Arnd Bergmann , Benjamin Herrenschmidt , Paul Mackerras Subject: [PATCHv7 2/6] ppc/cell: use get_unused_fd_flags(0) instead of get_unused_fd() Date: Sun, 1 Jun 2014 15:58:43 +0200 Message-Id: <51969ab721c420716f994c416184284f903822a5.1401630396.git.ydroneaud@opteya.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: References: In-Reply-To: References: Cc: Yann Droneaud , cbe-oss-dev@lists.ozlabs.org, trivial@kernel.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. Link: http://lkml.kernel.org/r/cover.1401630396.git.ydroneaud@opteya.com Cc: Al Viro Cc: Andrew Morton Signed-off-by: Yann Droneaud --- 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;