Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7119504rwb; Wed, 23 Nov 2022 02:23:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf4nxjxQJWf5ZAGC+Lp7rIsZ9WDfODQ/KSDIRbMfST5XvB4jbXtZ6ZQffgM+tN1k/PSNVdDJ X-Received: by 2002:a17:906:698f:b0:78d:93b1:b3ba with SMTP id i15-20020a170906698f00b0078d93b1b3bamr23779527ejr.66.1669198981550; Wed, 23 Nov 2022 02:23:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669198981; cv=none; d=google.com; s=arc-20160816; b=ORjXNeD/ZTvPpdRPK+1f10SfMNgRHpbgBJl2mP9/PiTyFdJU1HZRhjkL15uDoqq7NE 4NP9Z43YQdJwZfeJTOJEMtbaQ7Hmquibmm2aTosjG+VYlRI6hOLSDujQ0eN7Obco1ljA W9lilrB5y6u/L/2RecG542zpQK2J5jLg1WTwMe+mBt65dUAwagLXcAOCJEtJ2H8K7R29 Sb6b1MhdoT9ou528uGCrfhmPI0/9I5wYFQTEHoq0AJqXf/usAaA8tARA2W0Xe1WLqJZU DApuXTAmM1BF0MwPajDB+vKN0VML/bzRqji4t3KE1LM6Q8OVuyx64ZvEhJEqWkrh9lJF TzMQ== 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; bh=IRW0cBvN4U9nPN5PAZ/O4xIpNzEfvO9CqlVaSGZGxro=; b=b3rltSHjFrLdyU8xPm4bmPD3mxcCvGPQWDD+1dSJXV6v/cuXZBqTLWlKZ2z5U0cfnS z4L0EursXhvE3ad4nY0aSfIUz8jZW1pvcxka/po9d/0FdqwYqbzVGBxeD4rQ8+Ru40+o 1i0PKNcnG7Rplf6DDbCpzw4wpNENt90+oTkJdbswRCW3JUdS9UY4pRZus12kkXzipAxW JeYWgnMLsz4dttCfovgztfl4dJUd3CNNwXCN0g3hfM/XsRNXKWuz1VONcrxNM5GHFOBD qjwtFCtuKJPRvWYBZuRpU0+/kX6PHAn/c0SZGps0nEJsb8oBX+ybaDw8M0hwJmp+jTUf mvqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m9-20020a056402050900b00462e4cbe815si12718052edv.550.2022.11.23.02.22.40; Wed, 23 Nov 2022 02:23:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237200AbiKWKBx (ORCPT + 88 others); Wed, 23 Nov 2022 05:01:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236725AbiKWKAm (ORCPT ); Wed, 23 Nov 2022 05:00:42 -0500 Received: from frasgout11.his.huawei.com (frasgout11.his.huawei.com [14.137.139.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DADE1082; Wed, 23 Nov 2022 01:53:00 -0800 (PST) Received: from mail02.huawei.com (unknown [172.18.147.229]) by frasgout11.his.huawei.com (SkyGuard) with ESMTP id 4NHGTm1Fw7z9v7Vm; Wed, 23 Nov 2022 17:46:04 +0800 (CST) Received: from huaweicloud.com (unknown [10.204.63.22]) by APP1 (Coremail) with SMTP id LxC2BwAH829J7X1jzDqKAA--.13162S3; Wed, 23 Nov 2022 10:52:31 +0100 (CET) From: Roberto Sassu To: mark@fasheh.com, jlbec@evilplan.org, joseph.qi@linux.alibaba.com, zohar@linux.ibm.com, dmitry.kasatkin@gmail.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, stephen.smalley.work@gmail.com, eparis@parisplace.org, casey@schaufler-ca.com Cc: ocfs2-devel@oss.oracle.com, reiserfs-devel@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org, linux-kernel@vger.kernel.org, keescook@chromium.org, nicolas.bouchinet@clip-os.org, Roberto Sassu Subject: [PATCH v5 1/6] reiserfs: Switch to security_inode_init_security() Date: Wed, 23 Nov 2022 10:51:57 +0100 Message-Id: <20221123095202.599252-2-roberto.sassu@huaweicloud.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221123095202.599252-1-roberto.sassu@huaweicloud.com> References: <20221123095202.599252-1-roberto.sassu@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: LxC2BwAH829J7X1jzDqKAA--.13162S3 X-Coremail-Antispam: 1UD129KBjvJXoW7ZF15GF43Aw1UuFyUZr48tFb_yoW8Kr1kpF 47K3W7Grs8JF1xWr1Sya13W3WfKrWfKa17JwsxK34DAanrJw18trW0yw13u34rJrWkJr1I qw4Iyw43Gwn8XwUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPqb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUGw A2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVWUCVW8JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6r4UJVWxJr1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2 WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkE bVWUJVW8JwACjcxG0xvY0x0EwIxGrwACI402YVCY1x02628vn2kIc2xKxwCY1x0262kKe7 AKxVW8ZVWrXwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02 F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_Wr ylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7Cj xVAFwI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI 0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x 07jqYL9UUUUU= X-CM-SenderInfo: purev21wro2thvvxqx5xdzvxpfor3voofrz/1tbiAQAFBF1jj4XF3wAAsu X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Roberto Sassu In preparation for removing security_old_inode_init_security(), switch to security_inode_init_security(). Define the initxattrs callback reiserfs_initxattrs(), to populate the name/value/len triple in the reiserfs_security_handle() with the first xattr provided by LSMs. Multiple xattrs are currently not supported, as the reiserfs_security_handle structure is exported to user space. In reiserfs_initxattrs(), make a copy of the first xattr value, as security_inode_init_security() frees it. After the call to security_inode_init_security(), remove the check for returning -EOPNOTSUPP, as security_inode_init_security() changes it to zero. Signed-off-by: Roberto Sassu --- fs/reiserfs/xattr_security.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/fs/reiserfs/xattr_security.c b/fs/reiserfs/xattr_security.c index 857a65b05726..0ba96757681d 100644 --- a/fs/reiserfs/xattr_security.c +++ b/fs/reiserfs/xattr_security.c @@ -39,6 +39,22 @@ static bool security_list(struct dentry *dentry) return !IS_PRIVATE(d_inode(dentry)); } +static int +reiserfs_initxattrs(struct inode *inode, const struct xattr *xattr_array, + void *fs_info) +{ + struct reiserfs_security_handle *sec = fs_info; + + sec->value = kmemdup(xattr_array->value, xattr_array->value_len, + GFP_KERNEL); + if (!sec->value) + return -ENOMEM; + + sec->name = xattr_array->name; + sec->length = xattr_array->value_len; + return 0; +} + /* Initializes the security context for a new inode and returns the number * of blocks needed for the transaction. If successful, reiserfs_security * must be released using reiserfs_security_free when the caller is done. */ @@ -56,12 +72,9 @@ int reiserfs_security_init(struct inode *dir, struct inode *inode, if (IS_PRIVATE(dir)) return 0; - error = security_old_inode_init_security(inode, dir, qstr, &sec->name, - &sec->value, &sec->length); + error = security_inode_init_security(inode, dir, qstr, + &reiserfs_initxattrs, sec); if (error) { - if (error == -EOPNOTSUPP) - error = 0; - sec->name = NULL; sec->value = NULL; sec->length = 0; -- 2.25.1