* [PATCH V2] catch acl==NULL in __jfs_set_acl (fixed null pointer dereference)
@ 2014-04-29 17:59 Marco Munderloh
2014-04-29 18:26 ` Matthew Wilcox
0 siblings, 1 reply; 5+ messages in thread
From: Marco Munderloh @ 2014-04-29 17:59 UTC (permalink / raw)
To: linux-fsdevel
[-- Attachment #1: Type: text/plain, Size: 809 bytes --]
changes V2: I forgot to set rc = 0, leaving it uninitialized if acl was NULL.
--- linux-3.14.2.vanilla/fs/jfs/acl.c 2014-04-28 17:24:55.544597204 +0200
+++ linux-3.14.2/fs/jfs/acl.c 2014-04-29 19:57:27.028465728 +0200
@@ -83,13 +83,16 @@
switch (type) {
case ACL_TYPE_ACCESS:
ea_name = POSIX_ACL_XATTR_ACCESS;
- rc = posix_acl_equiv_mode(acl, &inode->i_mode);
- if (rc < 0)
- return rc;
- inode->i_ctime = CURRENT_TIME;
- mark_inode_dirty(inode);
- if (rc == 0)
- acl = NULL;
+ if( acl ) {
+ rc = posix_acl_equiv_mode(acl, &inode->i_mode);
+ if (rc < 0)
+ return rc;
+ inode->i_ctime = CURRENT_TIME;
+ mark_inode_dirty(inode);
+ if (rc == 0)
+ acl = NULL;
+ }
+ rc = 0;
break;
case ACL_TYPE_DEFAULT:
ea_name = POSIX_ACL_XATTR_DEFAULT;
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4700 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH V2] catch acl==NULL in __jfs_set_acl (fixed null pointer dereference)
2014-04-29 17:59 [PATCH V2] catch acl==NULL in __jfs_set_acl (fixed null pointer dereference) Marco Munderloh
@ 2014-04-29 18:26 ` Matthew Wilcox
2014-04-29 18:28 ` Christoph Hellwig
2014-04-29 18:30 ` Marco Munderloh
0 siblings, 2 replies; 5+ messages in thread
From: Matthew Wilcox @ 2014-04-29 18:26 UTC (permalink / raw)
To: Marco Munderloh; +Cc: linux-fsdevel
On Tue, Apr 29, 2014 at 07:59:51PM +0200, Marco Munderloh wrote:
> changes V2: I forgot to set rc = 0, leaving it uninitialized if acl was NULL.
You don't need to initialise rc here. But why not, more simply:
+++ b/fs/jfs/acl.c
@@ -83,6 +83,8 @@ static int __jfs_set_acl(tid_t tid, struct inode *inode, int t
switch (type) {
case ACL_TYPE_ACCESS:
ea_name = POSIX_ACL_XATTR_ACCESS;
+ if (!acl)
+ break;
rc = posix_acl_equiv_mode(acl, &inode->i_mode);
if (rc < 0)
return rc;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH V2] catch acl==NULL in __jfs_set_acl (fixed null pointer dereference)
2014-04-29 18:26 ` Matthew Wilcox
@ 2014-04-29 18:28 ` Christoph Hellwig
2014-04-29 18:33 ` Marco Munderloh
2014-04-29 18:30 ` Marco Munderloh
1 sibling, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2014-04-29 18:28 UTC (permalink / raw)
To: Matthew Wilcox; +Cc: Marco Munderloh, linux-fsdevel
On Tue, Apr 29, 2014 at 02:26:02PM -0400, Matthew Wilcox wrote:
> On Tue, Apr 29, 2014 at 07:59:51PM +0200, Marco Munderloh wrote:
> > changes V2: I forgot to set rc = 0, leaving it uninitialized if acl was NULL.
>
> You don't need to initialise rc here. But why not, more simply:
I'm pretty sure there's a patch queued up somewhere to make
posix_acl_equiv_mode handle the NULL ACL. I think this was first
reportd on gfs2.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH V2] catch acl==NULL in __jfs_set_acl (fixed null pointer dereference)
2014-04-29 18:26 ` Matthew Wilcox
2014-04-29 18:28 ` Christoph Hellwig
@ 2014-04-29 18:30 ` Marco Munderloh
1 sibling, 0 replies; 5+ messages in thread
From: Marco Munderloh @ 2014-04-29 18:30 UTC (permalink / raw)
To: Matthew Wilcox
[-- Attachment #1: Type: text/plain, Size: 704 bytes --]
> You don't need to initialise rc here.
Yes, you are true. I missed the __jfs_setxattr before the set_cached_acl.
But why not, more simply:
>
> +++ b/fs/jfs/acl.c
> @@ -83,6 +83,8 @@ static int __jfs_set_acl(tid_t tid, struct inode *inode, int t
> switch (type) {
> case ACL_TYPE_ACCESS:
> ea_name = POSIX_ACL_XATTR_ACCESS;
> + if (!acl)
> + break;
> rc = posix_acl_equiv_mode(acl, &inode->i_mode);
> if (rc < 0)
> return rc;
I could have done it like this, but I copied the way it was done in btrfs/acl.c, where the jfs implementation seems to come from.
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4700 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH V2] catch acl==NULL in __jfs_set_acl (fixed null pointer dereference)
2014-04-29 18:28 ` Christoph Hellwig
@ 2014-04-29 18:33 ` Marco Munderloh
0 siblings, 0 replies; 5+ messages in thread
From: Marco Munderloh @ 2014-04-29 18:33 UTC (permalink / raw)
To: Christoph Hellwig
[-- Attachment #1: Type: text/plain, Size: 363 bytes --]
> I'm pretty sure there's a patch queued up somewhere to make
> posix_acl_equiv_mode handle the NULL ACL. I think this was first
> reportd on gfs2.
That might be a better solution, posix_acl_equiv is used at several places (e.g. tmpfs, where the bug is also triggered).
However, in e.g. the ext4 or the btrfs acl implementation, acl == NULL is catched.
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4700 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-04-29 18:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-29 17:59 [PATCH V2] catch acl==NULL in __jfs_set_acl (fixed null pointer dereference) Marco Munderloh
2014-04-29 18:26 ` Matthew Wilcox
2014-04-29 18:28 ` Christoph Hellwig
2014-04-29 18:33 ` Marco Munderloh
2014-04-29 18:30 ` Marco Munderloh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).