Received: by 2002:ac0:adb4:0:0:0:0:0 with SMTP id o49-v6csp5677imb; Tue, 10 Jul 2018 19:27:09 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcmLWIPYUA+uyr4ZWwpC2wcF//EBfdMgRKM+5ALjMrGQKXiuZf/U1acxpZyALxDf+svNC7z X-Received: by 2002:a62:6eca:: with SMTP id j193-v6mr28242525pfc.256.1531276029108; Tue, 10 Jul 2018 19:27:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531276029; cv=none; d=google.com; s=arc-20160816; b=PZmjwjvO0QNyQnxyCrxl8kW9FfEB2Q0sEu62OR+uB/TgDWYJruyQVWzd+wYnKOOhzN HpeAkKHXwz+9wo7gvq8z1twSFcb4MUQYwCtIMCYIwSn3JWP3otk+7X4W2DwKE4aK2Huo PWS1TGpKxnb34f5AGStkVZdoVOE9PcxIP0VWwqGUM0CdahREQ2tJ1HLo6npjvPH7qHei DKJ4UN7S7XoU8oIarOMThhf1hKRkeI2s4sp+ooUr0bYhlQ5B2nvP0dga15rFwTISodBP BG/7jC2Rl8dI6ejS1pdAYTYJ+Ma6nIc2F26Ai6WebCa7hkS7EDO2a77BiiVvVy0xlnjx gaWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=TTtvkF5CECir20rMnRk6YI55bRg4CrlTXEz3ClJ9KK8=; b=ADTG6aDc3J81b08SbVgx1PWVDoEtLLyWcJ435Y0os65uu8FQANdmTE7bps7BzMFAZd heXH/+LSPTp33zc8zFB/bWEGpUVpVzX7TntdwdK/UmxuEE3kyfwQuId/kvmQNZMxztaR zkEU/L3+LeEoRvjzl2Y4Df296ComBsPqogWTBinOzuBDhF5LdTsVMbxgrQ4Sn/HrPEEg 8DHVVlPiuVD9tD95igcAgbhXUUli403fOWFBQLVPSt7WwhzIZCVekXf5wAmc0FMO0Et0 edRlA78bDYclSzpo6wlfT1uBKvedOQL3wFlgoTGtEU7mNTBzaDUAY3eHeKZfQ1+oN53z /kpQ== 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 c32-v6si17707282plj.277.2018.07.10.19.26.54; Tue, 10 Jul 2018 19:27:09 -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; 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 S1732882AbeGKC1Y (ORCPT + 99 others); Tue, 10 Jul 2018 22:27:24 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:45522 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732375AbeGKCYE (ORCPT ); Tue, 10 Jul 2018 22:24:04 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1fd4lb-0003I9-18; Wed, 11 Jul 2018 02:22:07 +0000 From: Al Viro To: Linus Torvalds Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Miklos Szeredi Subject: [RFC][PATCH 09/42] pass creds to get_empty_filp(), make sure dentry_open() passes the right creds Date: Wed, 11 Jul 2018 03:21:33 +0100 Message-Id: <20180711022206.12571-9-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180711022206.12571-1-viro@ZenIV.linux.org.uk> References: <20180711021136.GN30522@ZenIV.linux.org.uk> <20180711022206.12571-1-viro@ZenIV.linux.org.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro ... and rename get_empty_filp() to alloc_empty_file(). dentry_open() gets creds as argument, but the only thing that sees those is security_file_open() - file->f_cred still ends up with current_cred(). For almost all callers it's the same thing, but there are several broken cases. Signed-off-by: Al Viro --- fs/file_table.c | 5 ++--- fs/internal.h | 2 +- fs/namei.c | 2 +- fs/open.c | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/fs/file_table.c b/fs/file_table.c index eee7cf629e52..d7a03a47b702 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -101,9 +101,8 @@ int proc_nr_files(struct ctl_table *table, int write, * done, you will imbalance int the mount's writer count * and a warning at __fput() time. */ -struct file *get_empty_filp(void) +struct file *alloc_empty_file(const struct cred *cred) { - const struct cred *cred = current_cred(); static long old_max; struct file *f; int error; @@ -161,7 +160,7 @@ struct file *alloc_file(const struct path *path, fmode_t mode, { struct file *file; - file = get_empty_filp(); + file = alloc_empty_file(current_cred()); if (IS_ERR(file)) return file; diff --git a/fs/internal.h b/fs/internal.h index 5645b4ebf494..66473bf388e4 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -93,7 +93,7 @@ extern void chroot_fs_refs(const struct path *, const struct path *); /* * file_table.c */ -extern struct file *get_empty_filp(void); +extern struct file *alloc_empty_file(const struct cred *); /* * super.c diff --git a/fs/namei.c b/fs/namei.c index 734cef54fdf8..af2ec1803f57 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3513,7 +3513,7 @@ static struct file *path_openat(struct nameidata *nd, int opened = 0; int error; - file = get_empty_filp(); + file = alloc_empty_file(current_cred()); if (IS_ERR(file)) return file; diff --git a/fs/open.c b/fs/open.c index 558802e66e00..c0dbc67c31f1 100644 --- a/fs/open.c +++ b/fs/open.c @@ -923,7 +923,7 @@ struct file *dentry_open(const struct path *path, int flags, /* We must always pass in a valid mount pointer. */ BUG_ON(!path->mnt); - f = get_empty_filp(); + f = alloc_empty_file(cred); if (!IS_ERR(f)) { f->f_flags = flags; error = vfs_open(path, f, cred); -- 2.11.0