Message ID | 20230930050033.41174-2-wedsonaf@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp454801vqb; Sat, 30 Sep 2023 08:51:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEoqftZeXs014980wXJfNdSbENRmm9BICqw2RxH0R9YhVoMYXpyZf8fYYktByZKXQo34Wd9 X-Received: by 2002:a17:902:ce92:b0:1be:384:7b29 with SMTP id f18-20020a170902ce9200b001be03847b29mr8920047plg.34.1696089080282; Sat, 30 Sep 2023 08:51:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696089080; cv=none; d=google.com; s=arc-20160816; b=R4PFgxhRwJvhJ11DVkcHqbhAHrew9F/uiOJ5xaKFkxdeZLaIE+HWz7zbA+uHmeUpFY 5hbgKDGkH0GXkfXJCt63EYOwfPjh7+rA8pABm/xX/pNlJUgIPRJTNjhkemQNHKSsV+Ba 6vIGVdYbzgXaEwxfZRB3EAffWV/JXClCXj/ByGNsbCZF6WuRWN1ada6P2bYxt0MX2Y7c cRKOD2NQ4F+KLeHfE1+9ETPf473aYB9fsVZuT7EaNcr1VMXz3zurzLwmlnCgz9+gH3ME 3Wz6Gr0D/WtJrkccsqedCaGfqlsXHDWsOLJgel1R3X6A4/DW29yY6mo/LQy+DrM+KoI2 KQTQ== 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=P+kwTjR+CWDbHNLH7Vi6T+1DkOngNTu95bmWBQQSjqM=; fh=SK2xQ5WvE6tbwSQN9TMkRjbkm0hotbQhx6y1kSOUb0Q=; b=GSOo65FWjOShm3ugFWRr3EVBTbklCpl8dfrrMyfPLZRo2s2xxw00+Njm5NTUzSknd0 lxcTs1gF50O+CFIR1e/CbLOorsj9xgVV52Zp8aWFNLMDw4e/AlBX+bTsAZtL535OF0x2 bx/Gyss+SvQTuTvF7/j19g72oUDjcCaiVirMCknzcleOcwjgvItNmLWtEMgC2QpZR8/z F/MJcKS/yzhIsw9lVmcXTMSGfgmTSPrC6eh8rDMw4RYST7xDVjyJzYP7hGp/SYulogD/ 8GWnO+lKVE5mkDULgt6K2RE1g8yy4pSHA+MGQsVoOKzSQy8BOfZk7LFlMWcI7tsd6pU0 o/IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=S7sYrmck; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id e11-20020a17090301cb00b001bc5a4f56fcsi26748923plh.554.2023.09.30.08.51.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Sep 2023 08:51:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=S7sYrmck; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 7697782848FF; Fri, 29 Sep 2023 22:01:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233998AbjI3FBG (ORCPT <rfc822;pwkd43@gmail.com> + 19 others); Sat, 30 Sep 2023 01:01:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233053AbjI3FA7 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 30 Sep 2023 01:00:59 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BA4EB9; Fri, 29 Sep 2023 22:00:57 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1c3cbfa40d6so133398475ad.1; Fri, 29 Sep 2023 22:00:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696050057; x=1696654857; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=P+kwTjR+CWDbHNLH7Vi6T+1DkOngNTu95bmWBQQSjqM=; b=S7sYrmck40xgfqrsFLnX3leo2dQykimaZ9ibzIv7/8SJX/CovuEHpyX47jhZeLSztM rUWNYvhA+gQP3j3f+/Q/A9TTcwyyNpswjpMiUjb8WYssZA+2nbL+ulQ9dxR/yikDQH6e beZNU9JYKZ/hZ4TLPY0HT40BRC1k3jWs+Z1Kn+7pTLKPxs8w1A2gCNRa8vUe4wqNfGrc isvIJNOAxUahbuw1bm4bpEJNOp7VGbGKBNNTsGIfNnzrWCCwSldeLYKujUu2GqVr51Ag 548GRaKLYo9dqzhWyI9nOIjCrhHVKOJFhxEsTspNJeq/FDM47n8XXdKj5PDgpQ52750s UzyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696050057; x=1696654857; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P+kwTjR+CWDbHNLH7Vi6T+1DkOngNTu95bmWBQQSjqM=; b=adjT2LI56iZkFtzP7pZpKDJw0tenQBFYC3OrGpfrxF29hMU0Qk2nzA22ZFI0x3HNaj bQsKcaBWDN5lhlgSMEhuveEueoSUK2fehAzq7Vj6zKnupbf/rKtIlK5NxNkI+INPo74J bKSowyMsuwjechH/nnUNjZcCylbM49s1Zzu2I4SRhYAXAn2AAg/DLUNOKdSa95KP99iL FNRvRpYDfrqozfUH+vgOHQi/QuUBwbKzA5sdiHCMPReBF1YUKIk5yYyOdaRTe3ynm5Xu NkCILWJndt4IBevOD83f9TIyM9czFpkkaUY165bnCdzqRPgE4QM+rK2OQD1wMoo2Dxtz 3R3w== X-Gm-Message-State: AOJu0YySZcacFIj6LIFh88h3gJElFj39vMSPszuqe+8N3DfsW8ckpHgi 12vYq0+7sUkwhAaDM/K2uVs= X-Received: by 2002:a17:903:2445:b0:1c4:fae:bf4a with SMTP id l5-20020a170903244500b001c40faebf4amr6676418pls.16.1696050056932; Fri, 29 Sep 2023 22:00:56 -0700 (PDT) Received: from wedsonaf-dev.home.lan ([189.124.190.154]) by smtp.googlemail.com with ESMTPSA id y10-20020a17090322ca00b001c322a41188sm392136plg.117.2023.09.29.22.00.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 22:00:56 -0700 (PDT) From: Wedson Almeida Filho <wedsonaf@gmail.com> To: Alexander Viro <viro@zeniv.linux.org.uk>, Christian Brauner <brauner@kernel.org>, linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wedson Almeida Filho <walmeida@microsoft.com> Subject: [PATCH 01/29] xattr: make the xattr array itself const Date: Sat, 30 Sep 2023 02:00:05 -0300 Message-Id: <20230930050033.41174-2-wedsonaf@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230930050033.41174-1-wedsonaf@gmail.com> References: <20230930050033.41174-1-wedsonaf@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 29 Sep 2023 22:01:53 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778445457089568363 X-GMAIL-MSGID: 1778478303253588976 |
Series |
const xattr tables
|
|
Commit Message
Wedson Almeida Filho
Sept. 30, 2023, 5 a.m. UTC
From: Wedson Almeida Filho <walmeida@microsoft.com> 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. Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com> --- fs/xattr.c | 6 +++--- include/linux/fs.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
Comments
On 2023-09-30 02:00:05-0300, Wedson Almeida Filho wrote: > From: Wedson Almeida Filho <walmeida@microsoft.com> > > 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 <walmeida@microsoft.com> > --- > 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 >
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 */