Received: by 2002:a05:6520:4211:b029:f4:110d:56bc with SMTP id o17csp1547859lkv; Wed, 19 May 2021 12:29:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdK1XiYdnXv4GNb3h6xZ/JRR88gIsL+fMcx0gnYqKEpD7mGgBKASdHnXGr3dfJLxnvU1cD X-Received: by 2002:a92:cd44:: with SMTP id v4mr764678ilq.12.1621452585511; Wed, 19 May 2021 12:29:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621452585; cv=none; d=google.com; s=arc-20160816; b=IJe4CFC64FA8+3tPnDnPE7gPIcAj2cW5+8uSqns7usVqBwSxRQTBh/n2pQ0W0faqGC 3khic2bUtbbbKK7BvT+7+Z2ra/4JdKaU3fGwRlup4nmwFLaIABlFROTuudZdJPsYz7Az w78hQXbMGh0BVF79mWSTlBcDwbORltv9A6j8qV5xxq3030gSPKv9yBRuPOz07q8HQ8kf TjWvxHKLv1Q+tNFY9gSXWMHR9slOVG2xWfzB8Ww2MWDTMKecjRDLoMyRbJrFCVLfB1Ra +kuIg2veQedhZMtqb0xYDJEH2Dwo5Nc2qxYxikEmVf1GKfTS/Owch+RI3bVSWnQNLZzI fu0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=m+3FZkYhV+WJmv860bclG5Usw9ZdqRUiUz86oyBiOjA=; b=yDa1m1fx3MoFg46Nf95sT8yPp81ZO7tjOmz77EbyYuwgTok2AJrGTnHMHC4Wjdzi80 3b0R+vYlAXpR2gy17JDROceAeBMvQzZczN0jEg7qGalgCCx2Wa1qBl874rbxMPtSyesl avOUSW/o9D/zXpAvxIlzqSyPfHCrIuJmwGIOXAoYpcx+qBik7iAJwglrtujCLQJtpZ8O NCq/sTrrKtg9znRJs4F/tpRDvCbNQAga/CPanYkt78EPyCpaGvR15r0mUA0ESBW5/d4A 4kLu8Y6QX6izT0lZg3EB8Y6k1DW+5z/46YdB3ZCAxuTqQXzAQGy2coTE0Q1Vl1WEMTSG 5akQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PKbpRg6e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d1si627592ilg.93.2021.05.19.12.29.33; Wed, 19 May 2021 12:29:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PKbpRg6e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351347AbhESLi5 (ORCPT + 99 others); Wed, 19 May 2021 07:38:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351097AbhESLiv (ORCPT ); Wed, 19 May 2021 07:38:51 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8C5EC061761; Wed, 19 May 2021 04:37:30 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id i6so2025679plt.4; Wed, 19 May 2021 04:37:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=m+3FZkYhV+WJmv860bclG5Usw9ZdqRUiUz86oyBiOjA=; b=PKbpRg6eszJcyH1upYLpGENRAQ51TgQ7D3Lnd2U9bAs5ehy8ldAcAzmFuemEzjBhvG FQgXuMV3fhkKDAc0NIZUbFDD2i9f1FdrxcrJ6Luo2DfAOtQkmpX9sFaMsc9ZyWBf1xrq A4A/FsNJiOiCPta3+atAA5J6NPtop0Wk5j2HGawm9xRqAdQkPrA8vV1I9hP+XTx5TmrX WeBr3RHKSN9Q1sLW3WwzShhvHfSEKaclUnnwFQ4UgDmE786JDvJV6q7Xswsbjfh1bw4G p/gGHCprzQIs4CLBgfAN3ckKfh+GylsKvTwA2dFNoUNdgCwXWT6jE5QwZuAk6sVm30AV HXMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=m+3FZkYhV+WJmv860bclG5Usw9ZdqRUiUz86oyBiOjA=; b=nMJPOfimA10PeKdHPAt/jfHevuyKZeG/6LWzF7vOyJJbnoJN4+D0mdULV67ypkxBe0 fHk9rslOZLk6Ye8M+gaeimu2UxUCCY/EQCOL9Hae+MxM5/+5wAJbToDCfiKgSSyQ0HbY 1Xiw0uLJgkR++vJBfwMbs0MQOXGYVLC/bqQuzFyDQsCrJkJ23egobVCSlviN/SrkNdIP PQkBnHDRuYscagulcnHFFg0ZhI4DOxaJi2kZgX//oFFz9yNAusUdQ4nXT0uUKQRHwLyM vk3RjYQQUM/owPRJ7TqwELbMLlQECyOKDC6vF/M3ekoRHaeD4alDpAJkLB6I7bE0atJy JSEw== X-Gm-Message-State: AOAM531t/nuHySMmCnuN4ngkxKXWoz0OnyhPzhf/FogVqGDGOJowwTgF BLIzcYq9O1lQz50F+ReYITk3EAJgJn0= X-Received: by 2002:a17:902:f291:b029:f0:ba5b:5c47 with SMTP id k17-20020a170902f291b02900f0ba5b5c47mr10586583plc.41.1621424250139; Wed, 19 May 2021 04:37:30 -0700 (PDT) Received: from localhost ([2402:3a80:11c3:3084:b057:1ac1:910f:3c09]) by smtp.gmail.com with ESMTPSA id ck21sm15131406pjb.24.2021.05.19.04.37.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 May 2021 04:37:29 -0700 (PDT) From: Kumar Kartikeya Dwivedi To: io-uring@vger.kernel.org Cc: Pavel Emelyanov , Kumar Kartikeya Dwivedi , Alexander Viro , Jens Axboe , Pavel Begunkov , Lokesh Gidra , Eric Biggers , Paul Moore , Daniel Colascione , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] fs: anon_inodes: export anon_inode_getfile_secure helper Date: Wed, 19 May 2021 17:00:56 +0530 Message-Id: <20210519113058.1979817-2-memxor@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210519113058.1979817-1-memxor@gmail.com> References: <20210519113058.1979817-1-memxor@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is the non-fd installing analogue of anon_inode_getfd_secure. In addition to allowing LSMs to attach policy to the distinct inode, this is also needed for checkpoint restore of an io_uring instance where a mapped region needs to mapped back to the io_uring fd by CRIU. This is currently not possible as all anon_inodes share a single inode. Signed-off-by: Kumar Kartikeya Dwivedi --- fs/anon_inodes.c | 9 +++++++++ include/linux/anon_inodes.h | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c index a280156138ed..37032786b211 100644 --- a/fs/anon_inodes.c +++ b/fs/anon_inodes.c @@ -148,6 +148,15 @@ struct file *anon_inode_getfile(const char *name, } EXPORT_SYMBOL_GPL(anon_inode_getfile); +struct file *anon_inode_getfile_secure(const char *name, + const struct file_operations *fops, + void *priv, int flags, + const struct inode *context_inode) +{ + return __anon_inode_getfile(name, fops, priv, flags, context_inode, true); +} +EXPORT_SYMBOL_GPL(anon_inode_getfile_secure); + static int __anon_inode_getfd(const char *name, const struct file_operations *fops, void *priv, int flags, diff --git a/include/linux/anon_inodes.h b/include/linux/anon_inodes.h index 71881a2b6f78..5deaddbd7927 100644 --- a/include/linux/anon_inodes.h +++ b/include/linux/anon_inodes.h @@ -15,6 +15,10 @@ struct inode; struct file *anon_inode_getfile(const char *name, const struct file_operations *fops, void *priv, int flags); +struct file *anon_inode_getfile_secure(const char *name, + const struct file_operations *fops, + void *priv, int flags, + const struct inode *context_inode); int anon_inode_getfd(const char *name, const struct file_operations *fops, void *priv, int flags); int anon_inode_getfd_secure(const char *name, -- 2.31.1