[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 5/5] libdiskfs: add permission check to file_chflags
From: |
Samuel Thibault |
Subject: |
Re: [PATCH 5/5] libdiskfs: add permission check to file_chflags |
Date: |
Wed, 18 Jun 2014 00:37:26 +0200 |
User-agent: |
Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30) |
Justus Winter, le Mon 16 Jun 2014 19:49:29 +0200, a écrit :
> Only root is allowed to change the high 16 bits. The TODO entry says
> otherwise, but that must be a mistake. For reference, see the glibc
> sources, sysdeps/mach/hurd/bits/stat.h.
>
> * libdiskfs/file-chflags.c (diskfs_S_file_chflags): Add permission
> check.
> * TODO (libdiskfs): Remove entry.
Ack.
> ---
> TODO | 2 --
> libdiskfs/file-chflags.c | 8 ++++++++
> 2 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/TODO b/TODO
> index d2500dc..0387e9f 100644
> --- a/TODO
> +++ b/TODO
> @@ -108,8 +108,6 @@ See `tasks', the exported task list.
> Rename the rest to libhurdutil or somesuch.
>
> ** libdiskfs
> -*** file_chflags does not do proper permission checking (non-root isn't
> - supposed to be able to change the low bits)
> *** Add the short-circuited-but-not-builtin translator startup code from
> dir-lookup to fsys_getroot. Compare and match carefully these two
> routines and then share common code.
> diff --git a/libdiskfs/file-chflags.c b/libdiskfs/file-chflags.c
> index 01dc495..a29ff07 100644
> --- a/libdiskfs/file-chflags.c
> +++ b/libdiskfs/file-chflags.c
> @@ -23,8 +23,15 @@ kern_return_t
> diskfs_S_file_chflags (struct protid *cred,
> int flags)
> {
> +#define HI(X) ((X) & 0xffff0000u)
> CHANGE_NODE_FIELD (cred,
> ({
> + /* Only root is allowed to change the high 16
> + bits. */
> + if ((HI (flags) != HI (np->dn_stat.st_flags))
> + && ! idvec_contains (cred->user->uids, 0))
> + return EPERM;
> +
> err = fshelp_isowner (&np->dn_stat, cred->user);
> if (!err)
> err = diskfs_validate_flags_change (np, flags);
> @@ -37,4 +44,5 @@ diskfs_S_file_chflags (struct protid *cred,
> diskfs_notice_filechange(np, FILE_CHANGED_META,
> 0, 0);
> }));
> +#undef HI
> }
> --
> 2.0.0
>
--
Samuel
<k> faut en profiter, aujourd'hui, les blagues bidon sont à 100 dollars
-+- #sos-bourse -+-
- [PATCH 1/5] ftpfs: fix error handling in refresh_dir, Justus Winter, 2014/06/16
- [PATCH 2/5] libshouldbeinlibc: fix dead initialization in fmt_named_interval, Justus Winter, 2014/06/16
- [PATCH 4/5] libports: avoid realloc(3) corner case, Justus Winter, 2014/06/16
- [PATCH 3/5] trans/fakeroot: fix error handling, Justus Winter, 2014/06/16
- [PATCH 5/5] libdiskfs: add permission check to file_chflags, Justus Winter, 2014/06/16
- Re: [PATCH 5/5] libdiskfs: add permission check to file_chflags,
Samuel Thibault <=
- Re: [PATCH 1/5] ftpfs: fix error handling in refresh_dir, Samuel Thibault, 2014/06/17