Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755935Ab3IYUWk (ORCPT ); Wed, 25 Sep 2013 16:22:40 -0400 Received: from numidia.opendz.org ([98.142.220.152]:41277 "EHLO numidia.opendz.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753727Ab3IYUWj (ORCPT ); Wed, 25 Sep 2013 16:22:39 -0400 From: Djalal Harouni To: "Eric W. Biederman" , Kees Cook , Al Viro , Andrew Morton , Linus Torvalds , Ingo Molnar , "Serge E. Hallyn" , Cyrill Gorcunov , LKML , linux-fsdevel@vger.kernel.org, Cc: tixxdz@gmail.com, Djalal Harouni Subject: [PATCH 05/12] seq_file: set the seq_file->f_cred during seq_open() Date: Wed, 25 Sep 2013 21:14:38 +0100 Message-Id: <1380140085-29712-6-git-send-email-tixxdz@opendz.org> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1380140085-29712-1-git-send-email-tixxdz@opendz.org> References: <1380140085-29712-1-git-send-email-tixxdz@opendz.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1180 Lines: 35 The f_cred field of the file struct contains the cred of current at open time. This field can be used to get the context of open, and track current's cred changes after. The procfs is one of those fs that need to track current cred changes in order to implement proper permission checks on each system call. Set the seq_file->f_cred to file->f_cred during seq_open(). Cc: Kees Cook Cc: Eric W. Biederman Signed-off-by: Djalal Harouni --- fs/seq_file.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/seq_file.c b/fs/seq_file.c index 3135c25..a5e5b98 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c @@ -57,6 +57,7 @@ int seq_open(struct file *file, const struct seq_operations *op) memset(p, 0, sizeof(*p)); mutex_init(&p->lock); p->op = op; + p->f_cred = file->f_cred; #ifdef CONFIG_USER_NS p->user_ns = file->f_cred->user_ns; #endif -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/