* [PATCH] inotify: Fix fd refcount leak in inotify_add_watch().
@ 2019-01-01 9:54 Tetsuo Handa
2019-01-01 10:50 ` Amir Goldstein
0 siblings, 1 reply; 5+ messages in thread
From: Tetsuo Handa @ 2019-01-01 9:54 UTC (permalink / raw)
To: Amir Goldstein, Henry Wilson, Jan Kara; +Cc: linux-fsdevel, Tetsuo Handa
Commit 4d97f7d53da7dc83 ("inotify: Add flag IN_MASK_CREATE for
inotify_add_watch()") forgot to call fdput() before bailing out.
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
fs/notify/inotify/inotify_user.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index 105576d..798f125 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -724,8 +724,10 @@ static int do_inotify_init(int flags)
return -EBADF;
/* IN_MASK_ADD and IN_MASK_CREATE don't make sense together */
- if (unlikely((mask & IN_MASK_ADD) && (mask & IN_MASK_CREATE)))
- return -EINVAL;
+ if (unlikely((mask & IN_MASK_ADD) && (mask & IN_MASK_CREATE))) {
+ ret = -EINVAL;
+ goto fput_and_out;
+ }
/* verify that this is indeed an inotify instance */
if (unlikely(f.file->f_op != &inotify_fops)) {
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] inotify: Fix fd refcount leak in inotify_add_watch().
2019-01-01 9:54 [PATCH] inotify: Fix fd refcount leak in inotify_add_watch() Tetsuo Handa
@ 2019-01-01 10:50 ` Amir Goldstein
2019-01-02 17:48 ` Jan Kara
0 siblings, 1 reply; 5+ messages in thread
From: Amir Goldstein @ 2019-01-01 10:50 UTC (permalink / raw)
To: Tetsuo Handa; +Cc: Henry Wilson, Jan Kara, linux-fsdevel
On Tue, Jan 1, 2019 at 11:54 AM Tetsuo Handa
<penguin-kernel@i-love.sakura.ne.jp> wrote:
>
> Commit 4d97f7d53da7dc83 ("inotify: Add flag IN_MASK_CREATE for
> inotify_add_watch()") forgot to call fdput() before bailing out.
>
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> ---
> fs/notify/inotify/inotify_user.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
> index 105576d..798f125 100644
> --- a/fs/notify/inotify/inotify_user.c
> +++ b/fs/notify/inotify/inotify_user.c
> @@ -724,8 +724,10 @@ static int do_inotify_init(int flags)
> return -EBADF;
>
> /* IN_MASK_ADD and IN_MASK_CREATE don't make sense together */
> - if (unlikely((mask & IN_MASK_ADD) && (mask & IN_MASK_CREATE)))
> - return -EINVAL;
> + if (unlikely((mask & IN_MASK_ADD) && (mask & IN_MASK_CREATE))) {
> + ret = -EINVAL;
> + goto fput_and_out;
> + }
>
Thanks for the fix.
A matter of personal taste, but for brevity, I would prefer
initializing ret = -EINVAL
once and one liner goto here and in the case below.
Either way, you may add:
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Thanks,
Amir.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] inotify: Fix fd refcount leak in inotify_add_watch().
2019-01-01 10:50 ` Amir Goldstein
@ 2019-01-02 17:48 ` Jan Kara
2019-01-20 2:56 ` Tetsuo Handa
0 siblings, 1 reply; 5+ messages in thread
From: Jan Kara @ 2019-01-02 17:48 UTC (permalink / raw)
To: Amir Goldstein; +Cc: Tetsuo Handa, Henry Wilson, Jan Kara, linux-fsdevel
On Tue 01-01-19 12:50:32, Amir Goldstein wrote:
> On Tue, Jan 1, 2019 at 11:54 AM Tetsuo Handa
> <penguin-kernel@i-love.sakura.ne.jp> wrote:
> >
> > Commit 4d97f7d53da7dc83 ("inotify: Add flag IN_MASK_CREATE for
> > inotify_add_watch()") forgot to call fdput() before bailing out.
> >
> > Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> > ---
> > fs/notify/inotify/inotify_user.c | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
> > index 105576d..798f125 100644
> > --- a/fs/notify/inotify/inotify_user.c
> > +++ b/fs/notify/inotify/inotify_user.c
> > @@ -724,8 +724,10 @@ static int do_inotify_init(int flags)
> > return -EBADF;
> >
> > /* IN_MASK_ADD and IN_MASK_CREATE don't make sense together */
> > - if (unlikely((mask & IN_MASK_ADD) && (mask & IN_MASK_CREATE)))
> > - return -EINVAL;
> > + if (unlikely((mask & IN_MASK_ADD) && (mask & IN_MASK_CREATE))) {
> > + ret = -EINVAL;
> > + goto fput_and_out;
> > + }
> >
>
> Thanks for the fix.
> A matter of personal taste, but for brevity, I would prefer
> initializing ret = -EINVAL
> once and one liner goto here and in the case below.
>
> Either way, you may add:
> Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Thanks for the patch Tetsuo and for the review Amir. I've added the patch
to my tree (added CC to stable) and will push it to Linus for rc2.
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] inotify: Fix fd refcount leak in inotify_add_watch().
2019-01-02 17:48 ` Jan Kara
@ 2019-01-20 2:56 ` Tetsuo Handa
2019-01-21 9:19 ` Jan Kara
0 siblings, 1 reply; 5+ messages in thread
From: Tetsuo Handa @ 2019-01-20 2:56 UTC (permalink / raw)
To: Jan Kara; +Cc: Amir Goldstein, Henry Wilson, linux-fsdevel
Jan, will this fix be sent to linux.git shortly?
I still can't find this fix.
On 2019/01/03 2:48, Jan Kara wrote:
> On Tue 01-01-19 12:50:32, Amir Goldstein wrote:
>> On Tue, Jan 1, 2019 at 11:54 AM Tetsuo Handa
>> <penguin-kernel@i-love.sakura.ne.jp> wrote:
>>>
>>> Commit 4d97f7d53da7dc83 ("inotify: Add flag IN_MASK_CREATE for
>>> inotify_add_watch()") forgot to call fdput() before bailing out.
>>>
>>> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
>>> ---
>>> fs/notify/inotify/inotify_user.c | 6 ++++--
>>> 1 file changed, 4 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
>>> index 105576d..798f125 100644
>>> --- a/fs/notify/inotify/inotify_user.c
>>> +++ b/fs/notify/inotify/inotify_user.c
>>> @@ -724,8 +724,10 @@ static int do_inotify_init(int flags)
>>> return -EBADF;
>>>
>>> /* IN_MASK_ADD and IN_MASK_CREATE don't make sense together */
>>> - if (unlikely((mask & IN_MASK_ADD) && (mask & IN_MASK_CREATE)))
>>> - return -EINVAL;
>>> + if (unlikely((mask & IN_MASK_ADD) && (mask & IN_MASK_CREATE))) {
>>> + ret = -EINVAL;
>>> + goto fput_and_out;
>>> + }
>>>
>>
>> Thanks for the fix.
>> A matter of personal taste, but for brevity, I would prefer
>> initializing ret = -EINVAL
>> once and one liner goto here and in the case below.
>>
>> Either way, you may add:
>> Reviewed-by: Amir Goldstein <amir73il@gmail.com>
>
> Thanks for the patch Tetsuo and for the review Amir. I've added the patch
> to my tree (added CC to stable) and will push it to Linus for rc2.
>
> Honza
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] inotify: Fix fd refcount leak in inotify_add_watch().
2019-01-20 2:56 ` Tetsuo Handa
@ 2019-01-21 9:19 ` Jan Kara
0 siblings, 0 replies; 5+ messages in thread
From: Jan Kara @ 2019-01-21 9:19 UTC (permalink / raw)
To: Tetsuo Handa; +Cc: Jan Kara, Amir Goldstein, Henry Wilson, linux-fsdevel
On Sun 20-01-19 11:56:27, Tetsuo Handa wrote:
> Jan, will this fix be sent to linux.git shortly?
> I still can't find this fix.
Yes, I'll send it this week. But thanks for pinging as I've forgotten to
push it out to my for_next branch.
Honza
> On 2019/01/03 2:48, Jan Kara wrote:
> > On Tue 01-01-19 12:50:32, Amir Goldstein wrote:
> >> On Tue, Jan 1, 2019 at 11:54 AM Tetsuo Handa
> >> <penguin-kernel@i-love.sakura.ne.jp> wrote:
> >>>
> >>> Commit 4d97f7d53da7dc83 ("inotify: Add flag IN_MASK_CREATE for
> >>> inotify_add_watch()") forgot to call fdput() before bailing out.
> >>>
> >>> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> >>> ---
> >>> fs/notify/inotify/inotify_user.c | 6 ++++--
> >>> 1 file changed, 4 insertions(+), 2 deletions(-)
> >>>
> >>> diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
> >>> index 105576d..798f125 100644
> >>> --- a/fs/notify/inotify/inotify_user.c
> >>> +++ b/fs/notify/inotify/inotify_user.c
> >>> @@ -724,8 +724,10 @@ static int do_inotify_init(int flags)
> >>> return -EBADF;
> >>>
> >>> /* IN_MASK_ADD and IN_MASK_CREATE don't make sense together */
> >>> - if (unlikely((mask & IN_MASK_ADD) && (mask & IN_MASK_CREATE)))
> >>> - return -EINVAL;
> >>> + if (unlikely((mask & IN_MASK_ADD) && (mask & IN_MASK_CREATE))) {
> >>> + ret = -EINVAL;
> >>> + goto fput_and_out;
> >>> + }
> >>>
> >>
> >> Thanks for the fix.
> >> A matter of personal taste, but for brevity, I would prefer
> >> initializing ret = -EINVAL
> >> once and one liner goto here and in the case below.
> >>
> >> Either way, you may add:
> >> Reviewed-by: Amir Goldstein <amir73il@gmail.com>
> >
> > Thanks for the patch Tetsuo and for the review Amir. I've added the patch
> > to my tree (added CC to stable) and will push it to Linus for rc2.
> >
> > Honza
> >
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-01-21 9:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-01 9:54 [PATCH] inotify: Fix fd refcount leak in inotify_add_watch() Tetsuo Handa
2019-01-01 10:50 ` Amir Goldstein
2019-01-02 17:48 ` Jan Kara
2019-01-20 2:56 ` Tetsuo Handa
2019-01-21 9:19 ` Jan Kara
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).