* [PATCH] autofs: Add BUG_ON(1) for non dir/link inode case
@ 2016-07-03 10:29 Tomohiro Kusumi
2016-07-03 22:51 ` Jeff Mahoney
0 siblings, 1 reply; 5+ messages in thread
From: Tomohiro Kusumi @ 2016-07-03 10:29 UTC (permalink / raw)
To: raven; +Cc: autofs, Tomohiro Kusumi
It's invalid if the given mode is neither dir nor link,
so don't let it fallthrough on else case.
Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
---
fs/autofs4/inode.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
index ad0ee93..7f35c82 100644
--- a/fs/autofs4/inode.c
+++ b/fs/autofs4/inode.c
@@ -305,6 +305,7 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
if (autofs_type_trigger(sbi->type))
__managed_dentry_set_managed(root);
+ BUG_ON(!root_inode->i_fop || !root_inode->i_op);
root_inode->i_fop = &autofs4_root_operations;
root_inode->i_op = &autofs4_dir_inode_operations;
@@ -368,7 +369,8 @@ struct inode *autofs4_get_inode(struct super_block *sb, umode_t mode)
inode->i_fop = &autofs4_dir_operations;
} else if (S_ISLNK(mode)) {
inode->i_op = &autofs4_symlink_inode_operations;
- }
+ } else
+ BUG_ON(1);
return inode;
}
--
2.5.5
--
To unsubscribe from this list: send the line "unsubscribe autofs" in
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] autofs: Add BUG_ON(1) for non dir/link inode case
2016-07-03 10:29 [PATCH] autofs: Add BUG_ON(1) for non dir/link inode case Tomohiro Kusumi
@ 2016-07-03 22:51 ` Jeff Mahoney
2016-07-04 2:24 ` Ian Kent
0 siblings, 1 reply; 5+ messages in thread
From: Jeff Mahoney @ 2016-07-03 22:51 UTC (permalink / raw)
To: Tomohiro Kusumi, raven; +Cc: autofs
[-- Attachment #1.1: Type: text/plain, Size: 1358 bytes --]
On 7/3/16 6:29 AM, Tomohiro Kusumi wrote:
> It's invalid if the given mode is neither dir nor link,
> so don't let it fallthrough on else case.
Is this case really worth crashing the entire system?
Wouldn't a WARN_ON + return -EINVAL be sufficient? At the very least it
means that a developer doesn't need to reboot to reload the module if
they hit this.
-Jeff
> Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
> ---
> fs/autofs4/inode.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
> index ad0ee93..7f35c82 100644
> --- a/fs/autofs4/inode.c
> +++ b/fs/autofs4/inode.c
> @@ -305,6 +305,7 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
> if (autofs_type_trigger(sbi->type))
> __managed_dentry_set_managed(root);
>
> + BUG_ON(!root_inode->i_fop || !root_inode->i_op);
> root_inode->i_fop = &autofs4_root_operations;
> root_inode->i_op = &autofs4_dir_inode_operations;
>
> @@ -368,7 +369,8 @@ struct inode *autofs4_get_inode(struct super_block *sb, umode_t mode)
> inode->i_fop = &autofs4_dir_operations;
> } else if (S_ISLNK(mode)) {
> inode->i_op = &autofs4_symlink_inode_operations;
> - }
> + } else
> + BUG_ON(1);
>
> return inode;
> }
>
--
Jeff Mahoney
SUSE Labs
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 881 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] autofs: Add BUG_ON(1) for non dir/link inode case
2016-07-03 22:51 ` Jeff Mahoney
@ 2016-07-04 2:24 ` Ian Kent
2016-07-04 4:04 ` Tomohiro Kusumi
0 siblings, 1 reply; 5+ messages in thread
From: Ian Kent @ 2016-07-04 2:24 UTC (permalink / raw)
To: Jeff Mahoney, Tomohiro Kusumi; +Cc: autofs
On Sun, 2016-07-03 at 18:51 -0400, Jeff Mahoney wrote:
> On 7/3/16 6:29 AM, Tomohiro Kusumi wrote:
> > It's invalid if the given mode is neither dir nor link,
> > so don't let it fallthrough on else case.
>
> Is this case really worth crashing the entire system?
>
> Wouldn't a WARN_ON + return -EINVAL be sufficient? At the very least it
> means that a developer doesn't need to reboot to reload the module if
> they hit this.
That error return should be sufficient to cover this case and the WARN_ON() is
useful too.
And while there is some justification for the BUG_ON() earlier I also think an E
INVAL return would be more sensible there too.
BUG()ing on errors that should be handled is really bad IMHO.
>
> -Jeff
>
> > Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
> > ---
> > fs/autofs4/inode.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
> > index ad0ee93..7f35c82 100644
> > --- a/fs/autofs4/inode.c
> > +++ b/fs/autofs4/inode.c
> > @@ -305,6 +305,7 @@ int autofs4_fill_super(struct super_block *s, void
> > *data, int silent)
> > if (autofs_type_trigger(sbi->type))
> > __managed_dentry_set_managed(root);
> >
> > + BUG_ON(!root_inode->i_fop || !root_inode->i_op);
> > root_inode->i_fop = &autofs4_root_operations;
> > root_inode->i_op = &autofs4_dir_inode_operations;
> >
> > @@ -368,7 +369,8 @@ struct inode *autofs4_get_inode(struct super_block *sb,
> > umode_t mode)
> > inode->i_fop = &autofs4_dir_operations;
> > } else if (S_ISLNK(mode)) {
> > inode->i_op = &autofs4_symlink_inode_operations;
> > - }
> > + } else
> > + BUG_ON(1);
> >
> > return inode;
> > }
> >
>
>
--
To unsubscribe from this list: send the line "unsubscribe autofs" in
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] autofs: Add BUG_ON(1) for non dir/link inode case
2016-07-04 2:24 ` Ian Kent
@ 2016-07-04 4:04 ` Tomohiro Kusumi
2016-07-04 6:08 ` Ian Kent
0 siblings, 1 reply; 5+ messages in thread
From: Tomohiro Kusumi @ 2016-07-04 4:04 UTC (permalink / raw)
To: Ian Kent; +Cc: Jeff Mahoney, autofs
Thanks for your review.
I've submitted the v2 patch which only changed BUG_ON to WARN_ON.
I didn't use a return value of EINVAL as this function returns a pointer.
(and I didn't want to return EINVAL casted to a pointer)
2016-07-04 11:24 GMT+09:00 Ian Kent <raven@themaw.net>:
> On Sun, 2016-07-03 at 18:51 -0400, Jeff Mahoney wrote:
>> On 7/3/16 6:29 AM, Tomohiro Kusumi wrote:
>> > It's invalid if the given mode is neither dir nor link,
>> > so don't let it fallthrough on else case.
>>
>> Is this case really worth crashing the entire system?
>>
>> Wouldn't a WARN_ON + return -EINVAL be sufficient? At the very least it
>> means that a developer doesn't need to reboot to reload the module if
>> they hit this.
>
> That error return should be sufficient to cover this case and the WARN_ON() is
> useful too.
>
> And while there is some justification for the BUG_ON() earlier I also think an E
> INVAL return would be more sensible there too.
>
> BUG()ing on errors that should be handled is really bad IMHO.
>
>>
>> -Jeff
>>
>> > Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
>> > ---
>> > fs/autofs4/inode.c | 4 +++-
>> > 1 file changed, 3 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
>> > index ad0ee93..7f35c82 100644
>> > --- a/fs/autofs4/inode.c
>> > +++ b/fs/autofs4/inode.c
>> > @@ -305,6 +305,7 @@ int autofs4_fill_super(struct super_block *s, void
>> > *data, int silent)
>> > if (autofs_type_trigger(sbi->type))
>> > __managed_dentry_set_managed(root);
>> >
>> > + BUG_ON(!root_inode->i_fop || !root_inode->i_op);
>> > root_inode->i_fop = &autofs4_root_operations;
>> > root_inode->i_op = &autofs4_dir_inode_operations;
>> >
>> > @@ -368,7 +369,8 @@ struct inode *autofs4_get_inode(struct super_block *sb,
>> > umode_t mode)
>> > inode->i_fop = &autofs4_dir_operations;
>> > } else if (S_ISLNK(mode)) {
>> > inode->i_op = &autofs4_symlink_inode_operations;
>> > - }
>> > + } else
>> > + BUG_ON(1);
>> >
>> > return inode;
>> > }
>> >
>>
>>
--
To unsubscribe from this list: send the line "unsubscribe autofs" in
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] autofs: Add BUG_ON(1) for non dir/link inode case
2016-07-04 4:04 ` Tomohiro Kusumi
@ 2016-07-04 6:08 ` Ian Kent
0 siblings, 0 replies; 5+ messages in thread
From: Ian Kent @ 2016-07-04 6:08 UTC (permalink / raw)
To: Tomohiro Kusumi; +Cc: Jeff Mahoney, autofs
On Mon, 2016-07-04 at 13:04 +0900, Tomohiro Kusumi wrote:
> Thanks for your review.
> I've submitted the v2 patch which only changed BUG_ON to WARN_ON.
Yep, it's always called internally and should return something close to sensible
on error.
The case really shouldn't happen so a WARN_ON() is the better way to handle
this.
>
> I didn't use a return value of EINVAL as this function returns a pointer.
> (and I didn't want to return EINVAL casted to a pointer)
>
> 2016-07-04 11:24 GMT+09:00 Ian Kent <raven@themaw.net>:
> > On Sun, 2016-07-03 at 18:51 -0400, Jeff Mahoney wrote:
> > > On 7/3/16 6:29 AM, Tomohiro Kusumi wrote:
> > > > It's invalid if the given mode is neither dir nor link,
> > > > so don't let it fallthrough on else case.
> > >
> > > Is this case really worth crashing the entire system?
> > >
> > > Wouldn't a WARN_ON + return -EINVAL be sufficient? At the very least it
> > > means that a developer doesn't need to reboot to reload the module if
> > > they hit this.
> >
> > That error return should be sufficient to cover this case and the WARN_ON()
> > is
> > useful too.
> >
> > And while there is some justification for the BUG_ON() earlier I also think
> > an E
> > INVAL return would be more sensible there too.
> >
> > BUG()ing on errors that should be handled is really bad IMHO.
> >
> > >
> > > -Jeff
> > >
> > > > Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
> > > > ---
> > > > fs/autofs4/inode.c | 4 +++-
> > > > 1 file changed, 3 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
> > > > index ad0ee93..7f35c82 100644
> > > > --- a/fs/autofs4/inode.c
> > > > +++ b/fs/autofs4/inode.c
> > > > @@ -305,6 +305,7 @@ int autofs4_fill_super(struct super_block *s, void
> > > > *data, int silent)
> > > > if (autofs_type_trigger(sbi->type))
> > > > __managed_dentry_set_managed(root);
> > > >
> > > > + BUG_ON(!root_inode->i_fop || !root_inode->i_op);
> > > > root_inode->i_fop = &autofs4_root_operations;
> > > > root_inode->i_op = &autofs4_dir_inode_operations;
> > > >
> > > > @@ -368,7 +369,8 @@ struct inode *autofs4_get_inode(struct super_block
> > > > *sb,
> > > > umode_t mode)
> > > > inode->i_fop = &autofs4_dir_operations;
> > > > } else if (S_ISLNK(mode)) {
> > > > inode->i_op = &autofs4_symlink_inode_operations;
> > > > - }
> > > > + } else
> > > > + BUG_ON(1);
> > > >
> > > > return inode;
> > > > }
> > > >
> > >
> > >
--
To unsubscribe from this list: send the line "unsubscribe autofs" in
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-07-04 6:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-03 10:29 [PATCH] autofs: Add BUG_ON(1) for non dir/link inode case Tomohiro Kusumi
2016-07-03 22:51 ` Jeff Mahoney
2016-07-04 2:24 ` Ian Kent
2016-07-04 4:04 ` Tomohiro Kusumi
2016-07-04 6:08 ` Ian Kent
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.