diff mbox series

[05/29] btrfs: move btrfs_xattr_handlers to .rodata

Message ID 20230930050033.41174-6-wedsonaf@gmail.com (mailing list archive)
State New, archived
Headers show
Series const xattr tables | expand

Commit Message

Wedson Almeida Filho Sept. 30, 2023, 5 a.m. UTC
From: Wedson Almeida Filho <walmeida@microsoft.com>

This makes it harder for accidental or malicious changes to
btrfs_xattr_handlers at runtime.

Cc: Chris Mason <clm@fb.com>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: David Sterba <dsterba@suse.com>
Cc: linux-btrfs@vger.kernel.org
Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
---
 fs/btrfs/xattr.c | 2 +-
 fs/btrfs/xattr.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

David Sterba Oct. 2, 2023, 11:28 a.m. UTC | #1
On Sat, Sep 30, 2023 at 02:00:09AM -0300, Wedson Almeida Filho wrote:
> From: Wedson Almeida Filho <walmeida@microsoft.com>
> 
> This makes it harder for accidental or malicious changes to
> btrfs_xattr_handlers at runtime.
> 
> Cc: Chris Mason <clm@fb.com>
> Cc: Josef Bacik <josef@toxicpanda.com>
> Cc: David Sterba <dsterba@suse.com>
> Cc: linux-btrfs@vger.kernel.org
> Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>

With slightly updated changelog added to misc-next, thanks.
David Sterba Oct. 2, 2023, 11:37 a.m. UTC | #2
On Mon, Oct 02, 2023 at 01:28:58PM +0200, David Sterba wrote:
> On Sat, Sep 30, 2023 at 02:00:09AM -0300, Wedson Almeida Filho wrote:
> > From: Wedson Almeida Filho <walmeida@microsoft.com>
> > 
> > This makes it harder for accidental or malicious changes to
> > btrfs_xattr_handlers at runtime.
> > 
> > Cc: Chris Mason <clm@fb.com>
> > Cc: Josef Bacik <josef@toxicpanda.com>
> > Cc: David Sterba <dsterba@suse.com>
> > Cc: linux-btrfs@vger.kernel.org
> > Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
> 
> With slightly updated changelog added to misc-next, thanks.

Removed again. I did not notice first that this is part of a larger
series, please also CC the [PATCH 0/N] patch.

There's a warning:

fs/btrfs/super.c: In function ‘btrfs_fill_super’:
fs/btrfs/super.c:1107:21: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
 1107 |         sb->s_xattr = btrfs_xattr_handlers;
      |                     ^

but the patch changing the type is present in the series.

Please update the changelog of btrfs patch with:

    Add const specifier also to the pointed array members of
    btrfs_xattr_handlers.  This moves the whole structure to the .rodata
    section which makes it harder for accidental or malicious changes to
    btrfs_xattr_handlers at runtime.

or use it for others patches too.
Wedson Almeida Filho Oct. 3, 2023, 1:48 p.m. UTC | #3
On Mon, 2 Oct 2023 at 08:44, David Sterba <dsterba@suse.cz> wrote:
>
> On Mon, Oct 02, 2023 at 01:28:58PM +0200, David Sterba wrote:
> > On Sat, Sep 30, 2023 at 02:00:09AM -0300, Wedson Almeida Filho wrote:
> > > From: Wedson Almeida Filho <walmeida@microsoft.com>
> > >
> > > This makes it harder for accidental or malicious changes to
> > > btrfs_xattr_handlers at runtime.
> > >
> > > Cc: Chris Mason <clm@fb.com>
> > > Cc: Josef Bacik <josef@toxicpanda.com>
> > > Cc: David Sterba <dsterba@suse.com>
> > > Cc: linux-btrfs@vger.kernel.org
> > > Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
> >
> > With slightly updated changelog added to misc-next, thanks.
>
> Removed again. I did not notice first that this is part of a larger
> series, please also CC the [PATCH 0/N] patch.

Sorry for the confusion, I will CC you there too.

> There's a warning:
>
> fs/btrfs/super.c: In function ‘btrfs_fill_super’:
> fs/btrfs/super.c:1107:21: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
>  1107 |         sb->s_xattr = btrfs_xattr_handlers;
>       |                     ^
>
> but the patch changing the type is present in the series.
>
> Please update the changelog of btrfs patch with:
>
>     Add const specifier also to the pointed array members of
>     btrfs_xattr_handlers.  This moves the whole structure to the .rodata
>     section which makes it harder for accidental or malicious changes to
>     btrfs_xattr_handlers at runtime.

Will do. Thanks!

> or use it for others patches too.
diff mbox series

Patch

diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c
index fc4b20c2688a..d82d9545386a 100644
--- a/fs/btrfs/xattr.c
+++ b/fs/btrfs/xattr.c
@@ -442,7 +442,7 @@  static const struct xattr_handler btrfs_btrfs_xattr_handler = {
 	.set = btrfs_xattr_handler_set_prop,
 };
 
-const struct xattr_handler *btrfs_xattr_handlers[] = {
+const struct xattr_handler * const btrfs_xattr_handlers[] = {
 	&btrfs_security_xattr_handler,
 	&btrfs_trusted_xattr_handler,
 	&btrfs_user_xattr_handler,
diff --git a/fs/btrfs/xattr.h b/fs/btrfs/xattr.h
index 1cd3fc0a8f17..118118ca3e1d 100644
--- a/fs/btrfs/xattr.h
+++ b/fs/btrfs/xattr.h
@@ -8,7 +8,7 @@ 
 
 #include <linux/xattr.h>
 
-extern const struct xattr_handler *btrfs_xattr_handlers[];
+extern const struct xattr_handler * const btrfs_xattr_handlers[];
 
 int btrfs_getxattr(struct inode *inode, const char *name,
 		void *buffer, size_t size);