Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1361003rdb; Mon, 2 Oct 2023 07:21:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF1e8/2Or/y4PqAbvXdrIfosa5J+xPzIU1UZzExgQ29sCFBiwXteD4fPyN/Bht+v6tpLZTg X-Received: by 2002:a05:6e02:1caa:b0:351:4f0c:b95c with SMTP id x10-20020a056e021caa00b003514f0cb95cmr15746836ill.24.1696256516735; Mon, 02 Oct 2023 07:21:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696256516; cv=none; d=google.com; s=arc-20160816; b=qw9Ac7T1MZHV/zQ+2fgTZA2Jo3WMruCimmdohn9zoIq6HVzRWenJFaJpFt6Rbp7EbL 6gI6cVnYN3a2YhYHighSzSQnIldsWcXjMDcDqDzG+8uk2rX7/lqIIZj+UV1nY+U9yyJI CxEcIxgJ5B+X3ASmi78JXy0uKlSNlSjFUHOKGvm3HwqU/9AW20keU0irf9QvpB8bk82W DfocMOErg0i1znH0ENcO8ERIdqmIuJME4zUm4dEsoE1sQ/uuKIPSoUQ15aJYp2Eremj8 mFzhRQq7aNNiFpypYc+SZk3L5geUS+C4e5/nI5CHVcWuWl7xcY53BNwpR7nEKqkBPjRp Ahlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Qb5S/44VgGoPIqqqM89RGn1Y94XsTvczolkG0Tr+ZeA=; fh=sVg3C1J/9umzMNBxRp6M232mUUY4A4+gw5/pHU7tGsU=; b=Oe5tJgWp/3uvh2NK1vHIE6H4pCocxD8AfcSjSixpSf4bh/ydFet0FC1sC4dpvAFy8i hu7Lf/1tSOkqP8rNTbG3ay9vcz3ywPGKCUukMr4BBOfAam4pSjktdmOFbqAjbDYtMcgw v3MJZaTs4hpxXDN+fLx+9EllX4t+kRMIlO+I915wQTUGvYH4yKk65bcP+0XLt37nepGT jzr84NagQTcm9/Xi1GsOpGPHWZxecx1kK/f5hZiHbPjnQJgF8maUct0xw8Dm25LP5WjD /hvgCz6hOSLpyuVilnlei0APDGPNDgSA79L7hCpSW5QWpMOpuFJNJ0/wiLMjQHmnpmpJ gg/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=VbM0R+4x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id u29-20020a63141d000000b00578acf1e8a3si27102766pgl.576.2023.10.02.07.21.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 07:21:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=VbM0R+4x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id DA8F98087267; Mon, 2 Oct 2023 02:59:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236462AbjJBJ7C (ORCPT + 99 others); Mon, 2 Oct 2023 05:59:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236471AbjJBJ6q (ORCPT ); Mon, 2 Oct 2023 05:58:46 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38E631701; Mon, 2 Oct 2023 02:58:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1696240699; bh=0/JUjvNFCrqTLBeZW08iULSeezWaCcDvX52IIMuk8OY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VbM0R+4xbgFaAb/Nj2sUi5FqA2WuSaT4FRA1gudCZOXzDuDGxMWu8IQiFOMSJoaMA ItU+ffnOyrdHSu3RIgmRq6Z/usFV1HcOvMe8F3BOepaF3SmsJeaQSiEj0H4t1okEDN L8NivrXvVG2WNkmHvPDG9jkubnLjLvCiB+pzUVXc= Date: Mon, 2 Oct 2023 11:58:18 +0200 From: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= To: Wedson Almeida Filho Cc: Alexander Viro , Christian Brauner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Wedson Almeida Filho Subject: Re: [PATCH 01/29] xattr: make the xattr array itself const Message-ID: References: <20230930050033.41174-1-wedsonaf@gmail.com> <20230930050033.41174-2-wedsonaf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230930050033.41174-2-wedsonaf@gmail.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 02 Oct 2023 02:59:27 -0700 (PDT) On 2023-09-30 02:00:05-0300, Wedson Almeida Filho wrote: > From: Wedson Almeida Filho > > As it is currently declared, the xattr_handler structs are const but the > array containing their pointers is not. This patch makes it so that fs > modules can place them in .rodata, which makes it harder for > accidental/malicious modifications at runtime. You could also add an entry to scripts/const_structs.checkpatch to make sure newly introduced usages of the struct are const. Could be a single dedicated patch after this patch has been applied. > Signed-off-by: Wedson Almeida Filho > --- > fs/xattr.c | 6 +++--- > include/linux/fs.h | 2 +- > 2 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/fs/xattr.c b/fs/xattr.c > index e7bbb7f57557..1905f8ede13d 100644 > --- a/fs/xattr.c > +++ b/fs/xattr.c > @@ -56,7 +56,7 @@ strcmp_prefix(const char *a, const char *a_prefix) > static const struct xattr_handler * > xattr_resolve_name(struct inode *inode, const char **name) > { > - const struct xattr_handler **handlers = inode->i_sb->s_xattr; > + const struct xattr_handler * const *handlers = inode->i_sb->s_xattr; > const struct xattr_handler *handler; > > if (!(inode->i_opflags & IOP_XATTR)) { > @@ -162,7 +162,7 @@ xattr_permission(struct mnt_idmap *idmap, struct inode *inode, > int > xattr_supports_user_prefix(struct inode *inode) > { > - const struct xattr_handler **handlers = inode->i_sb->s_xattr; > + const struct xattr_handler * const *handlers = inode->i_sb->s_xattr; > const struct xattr_handler *handler; > > if (!(inode->i_opflags & IOP_XATTR)) { > @@ -999,7 +999,7 @@ int xattr_list_one(char **buffer, ssize_t *remaining_size, const char *name) > ssize_t > generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) > { > - const struct xattr_handler *handler, **handlers = dentry->d_sb->s_xattr; > + const struct xattr_handler *handler, * const *handlers = dentry->d_sb->s_xattr; > ssize_t remaining_size = buffer_size; > int err = 0; > > diff --git a/include/linux/fs.h b/include/linux/fs.h > index 562f2623c9c9..4d8003f48216 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -1172,7 +1172,7 @@ struct super_block { > #ifdef CONFIG_SECURITY > void *s_security; > #endif > - const struct xattr_handler **s_xattr; > + const struct xattr_handler * const *s_xattr; > #ifdef CONFIG_FS_ENCRYPTION > const struct fscrypt_operations *s_cop; > struct fscrypt_keyring *s_master_keys; /* master crypto keys in use */ > -- > 2.34.1 >