Open file with O_CLOEXEC to avoid fd leak

Submitted by mingli.yu@windriver.com on Jan. 19, 2020, 3:50 a.m. | Patch ID: 169143

Details

Message ID 1579405812-336202-1-git-send-email-mingli.yu@windriver.com
State Superseded
Headers show

Commit Message

mingli.yu@windriver.com Jan. 19, 2020, 3:50 a.m.
From: Pavel Modilaynen <pavelmn@axis.com>

Use close-on-exec (O_CLOEXEC) flag when open log file to
make sure its file descriptor is not leaked to parent
process on fork/exec.
---
 pseudo_util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/pseudo_util.c b/pseudo_util.c
index c867ed6..0ec527b 100644
--- a/pseudo_util.c
+++ b/pseudo_util.c
@@ -1594,7 +1594,7 @@  pseudo_logfile(char *filename, char *defname, int prefer_fd) {
 		}
 		free(filename);
 	}	
-	fd = open(pseudo_path, O_WRONLY | O_APPEND | O_CREAT, 0644);
+	fd = open(pseudo_path, O_WRONLY | O_APPEND | O_CREAT | O_CLOEXEC, 0644);
 	if (fd == -1) {
 		pseudo_diag("help: can't open log file %s: %s\n", pseudo_path, strerror(errno));
 	} else {

Comments

mingli.yu@windriver.com Jan. 19, 2020, 5:41 a.m.
On 01/19/20 13:32, Patchwork wrote:
> == Series Details ==
>
> Series: Open file with O_CLOEXEC to avoid fd leak (rev3)
> Revision: 3
> URL   : https://patchwork.openembedded.org/series/22123/
> State : failure
>
> == Summary ==
>
>
> Thank you for submitting this patch series to OpenEmbedded Core. This is
> an automated response. Several tests have been executed on the proposed
> series by patchtest resulting in the following failures:
>
>
>
> * Issue             Series does not apply on top of target branch [test_series_merge_on_head]
>    Suggested fix    Rebase your series on top of targeted branch
>    Targeted branch  master (currently at 9d7a521971)

Have already rebased on the master branch of 
http://git.yoctoproject.org/cgit/cgit.cgi/pseudo/, why still issue out 
the above issue? Any hint?

Thanks,

>
>
>
> If you believe any of these test results are incorrect, please reply to the
> mailing list (openembedded-core@lists.openembedded.org) raising your concerns.
> Otherwise we would appreciate you correcting the issues and submitting a new
> version of the patchset if applicable. Please ensure you add/increment the
> version number when sending the new version (i.e. [PATCH] -> [PATCH v2] ->
> [PATCH v3] -> ...).
>
> ---
> Guidelines:     https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines
> Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
> Test suite:     http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe
>
>
mingli.yu@windriver.com Jan. 19, 2020, 3:12 p.m.
This is a system generated Comment: Patch 169143 was automatically marked as superseded by patch 169144.
Paul Eggleton Jan. 20, 2020, 1:29 a.m.
Hi Mingli

On Sunday, 19 January 2020 6:41:49 PM NZDT Yu, Mingli wrote:
> On 01/19/20 13:32, Patchwork wrote:
> > == Series Details ==
> >
> > Series: Open file with O_CLOEXEC to avoid fd leak (rev3)
> > Revision: 3
> > URL   : https://patchwork.openembedded.org/series/22123/
> > State : failure
> >
> > == Summary ==
> >
> >
> > Thank you for submitting this patch series to OpenEmbedded Core. This is
> > an automated response. Several tests have been executed on the proposed
> > series by patchtest resulting in the following failures:
> >
> >
> >
> > * Issue             Series does not apply on top of target branch [test_series_merge_on_head]
> >    Suggested fix    Rebase your series on top of targeted branch
> >    Targeted branch  master (currently at 9d7a521971)
> 
> Have already rebased on the master branch of 
> http://git.yoctoproject.org/cgit/cgit.cgi/pseudo/, why still issue out 
> the above issue? Any hint?

It's assuming that patches sent to this list are for OE-Core (which they
generally are). I wasn't aware but apparently the documented place to
send pseudo patches is this list, so I think in this case you can just ignore
patchtest.

Cheers,
Paul
mingli.yu@windriver.com Jan. 20, 2020, 1:34 a.m.
On 01/20/20 09:29, Paul Eggleton wrote:
> Hi Mingli
>
> On Sunday, 19 January 2020 6:41:49 PM NZDT Yu, Mingli wrote:
>> On 01/19/20 13:32, Patchwork wrote:
>>> == Series Details ==
>>>
>>> Series: Open file with O_CLOEXEC to avoid fd leak (rev3)
>>> Revision: 3
>>> URL   : https://patchwork.openembedded.org/series/22123/
>>> State : failure
>>>
>>> == Summary ==
>>>
>>>
>>> Thank you for submitting this patch series to OpenEmbedded Core. This is
>>> an automated response. Several tests have been executed on the proposed
>>> series by patchtest resulting in the following failures:
>>>
>>>
>>>
>>> * Issue             Series does not apply on top of target branch [test_series_merge_on_head]
>>>     Suggested fix    Rebase your series on top of targeted branch
>>>     Targeted branch  master (currently at 9d7a521971)
>>
>> Have already rebased on the master branch of
>> http://git.yoctoproject.org/cgit/cgit.cgi/pseudo/, why still issue out
>> the above issue? Any hint?
>
> It's assuming that patches sent to this list are for OE-Core (which they
> generally are). I wasn't aware but apparently the documented place to
> send pseudo patches is this list, so I think in this case you can just ignore
> patchtest.

Okay, many thanks Paul for your hint!

Thanks,

>
> Cheers,
> Paul
>
Peter Kjellerstedt Jan. 20, 2020, 2:28 a.m.
> -----Original Message-----

> From: openembedded-core-bounces@lists.openembedded.org <openembedded-core-

> bounces@lists.openembedded.org> On Behalf Of Yu, Mingli

> Sent: den 20 januari 2020 02:34

> To: Paul Eggleton <paul.eggleton@linux.intel.com>

> Cc: openembedded-core@lists.openembedded.org

> Subject: Re: [OE-core] ✗ patchtest: failure for Open file with O_CLOEXEC

> to avoid fd leak (rev3)

> 

> On 01/20/20 09:29, Paul Eggleton wrote:

> > Hi Mingli

> >

> > On Sunday, 19 January 2020 6:41:49 PM NZDT Yu, Mingli wrote:

> >> On 01/19/20 13:32, Patchwork wrote:

> >>> == Series Details ==

> >>>

> >>> Series: Open file with O_CLOEXEC to avoid fd leak (rev3)

> >>> Revision: 3

> >>> URL   : https://patchwork.openembedded.org/series/22123/

> >>> State : failure

> >>>

> >>> == Summary ==

> >>>

> >>>

> >>> Thank you for submitting this patch series to OpenEmbedded Core. This

> is

> >>> an automated response. Several tests have been executed on the

> proposed

> >>> series by patchtest resulting in the following failures:

> >>>

> >>>

> >>>

> >>> * Issue             Series does not apply on top of target branch

> [test_series_merge_on_head]

> >>>     Suggested fix    Rebase your series on top of targeted branch

> >>>     Targeted branch  master (currently at 9d7a521971)

> >>

> >> Have already rebased on the master branch of

> >> http://git.yoctoproject.org/cgit/cgit.cgi/pseudo/, why still issue out

> >> the above issue? Any hint?

> >

> > It's assuming that patches sent to this list are for OE-Core (which they

> > generally are). I wasn't aware but apparently the documented place to

> > send pseudo patches is this list, so I think in this case you can just

> > ignore patchtest.

> 

> Okay, many thanks Paul for your hint!

> 

> Thanks,

> 

> >

> > Cheers,

> > Paul


But it is probably a good idea to include a "[pseudo]" tag in the subject 
when sending patches related to pseudo to this list, as the expectation 
otherwise is that they are for OE-Core.

//Peter
mingli.yu@windriver.com Jan. 20, 2020, 3:04 a.m.
On 01/20/20 10:28, Peter Kjellerstedt wrote:
>> -----Original Message-----
>> From: openembedded-core-bounces@lists.openembedded.org <openembedded-core-
>> bounces@lists.openembedded.org> On Behalf Of Yu, Mingli
>> Sent: den 20 januari 2020 02:34
>> To: Paul Eggleton <paul.eggleton@linux.intel.com>
>> Cc: openembedded-core@lists.openembedded.org
>> Subject: Re: [OE-core] ✗ patchtest: failure for Open file with O_CLOEXEC
>> to avoid fd leak (rev3)
>>
>> On 01/20/20 09:29, Paul Eggleton wrote:
>>> Hi Mingli
>>>
>>> On Sunday, 19 January 2020 6:41:49 PM NZDT Yu, Mingli wrote:
>>>> On 01/19/20 13:32, Patchwork wrote:
>>>>> == Series Details ==
>>>>>
>>>>> Series: Open file with O_CLOEXEC to avoid fd leak (rev3)
>>>>> Revision: 3
>>>>> URL   : https://patchwork.openembedded.org/series/22123/
>>>>> State : failure
>>>>>
>>>>> == Summary ==
>>>>>
>>>>>
>>>>> Thank you for submitting this patch series to OpenEmbedded Core. This
>> is
>>>>> an automated response. Several tests have been executed on the
>> proposed
>>>>> series by patchtest resulting in the following failures:
>>>>>
>>>>>
>>>>>
>>>>> * Issue             Series does not apply on top of target branch
>> [test_series_merge_on_head]
>>>>>      Suggested fix    Rebase your series on top of targeted branch
>>>>>      Targeted branch  master (currently at 9d7a521971)
>>>>
>>>> Have already rebased on the master branch of
>>>> http://git.yoctoproject.org/cgit/cgit.cgi/pseudo/, why still issue out
>>>> the above issue? Any hint?
>>>
>>> It's assuming that patches sent to this list are for OE-Core (which they
>>> generally are). I wasn't aware but apparently the documented place to
>>> send pseudo patches is this list, so I think in this case you can just
>>> ignore patchtest.
>>
>> Okay, many thanks Paul for your hint!
>>
>> Thanks,
>>
>>>
>>> Cheers,
>>> Paul
>
> But it is probably a good idea to include a "[pseudo]" tag in the subject
> when sending patches related to pseudo to this list, as the expectation
> otherwise is that they are for OE-Core.

Thanks Peter! And already add the "pseudo_util.c" tag in the subject in 
the v3, please check the mail with the subject "[OE-core] [PATCH v3] 
pseudo_util.c: Open file with O_CLOEXEC to avoid fd leak".

Thanks,

>
> //Peter
>
Peter Kjellerstedt Jan. 20, 2020, 3:15 a.m.
> -----Original Message-----

> From: Yu, Mingli <mingli.yu@windriver.com>

> Sent: den 20 januari 2020 04:04

> To: Peter Kjellerstedt <peter.kjellerstedt@axis.com>; Paul Eggleton

> <paul.eggleton@linux.intel.com>

> Cc: openembedded-core@lists.openembedded.org

> Subject: Re: [OE-core] ✗ patchtest: failure for Open file with O_CLOEXEC

> to avoid fd leak (rev3)

> 

> On 01/20/20 10:28, Peter Kjellerstedt wrote:

> >> -----Original Message-----

> >> From: openembedded-core-bounces@lists.openembedded.org <openembedded-

> core-

> >> bounces@lists.openembedded.org> On Behalf Of Yu, Mingli

> >> Sent: den 20 januari 2020 02:34

> >> To: Paul Eggleton <paul.eggleton@linux.intel.com>

> >> Cc: openembedded-core@lists.openembedded.org

> >> Subject: Re: [OE-core] ✗ patchtest: failure for Open file with

> O_CLOEXEC

> >> to avoid fd leak (rev3)

> >>

> >> On 01/20/20 09:29, Paul Eggleton wrote:

> >>> Hi Mingli

> >>>

> >>> On Sunday, 19 January 2020 6:41:49 PM NZDT Yu, Mingli wrote:

> >>>> On 01/19/20 13:32, Patchwork wrote:

> >>>>> == Series Details ==

> >>>>>

> >>>>> Series: Open file with O_CLOEXEC to avoid fd leak (rev3)

> >>>>> Revision: 3

> >>>>> URL   : https://patchwork.openembedded.org/series/22123/

> >>>>> State : failure

> >>>>>

> >>>>> == Summary ==

> >>>>>

> >>>>>

> >>>>> Thank you for submitting this patch series to OpenEmbedded Core.

> This

> >> is

> >>>>> an automated response. Several tests have been executed on the

> >> proposed

> >>>>> series by patchtest resulting in the following failures:

> >>>>>

> >>>>>

> >>>>>

> >>>>> * Issue             Series does not apply on top of target branch

> >> [test_series_merge_on_head]

> >>>>>      Suggested fix    Rebase your series on top of targeted branch

> >>>>>      Targeted branch  master (currently at 9d7a521971)

> >>>>

> >>>> Have already rebased on the master branch of

> >>>> http://git.yoctoproject.org/cgit/cgit.cgi/pseudo/, why still issue

> out

> >>>> the above issue? Any hint?

> >>>

> >>> It's assuming that patches sent to this list are for OE-Core (which

> they

> >>> generally are). I wasn't aware but apparently the documented place to

> >>> send pseudo patches is this list, so I think in this case you can just

> >>> ignore patchtest.

> >>

> >> Okay, many thanks Paul for your hint!

> >>

> >> Thanks,

> >>

> >>>

> >>> Cheers,

> >>> Paul

> >

> > But it is probably a good idea to include a "[pseudo]" tag in the

> subject

> > when sending patches related to pseudo to this list, as the expectation

> > otherwise is that they are for OE-Core.

> 

> Thanks Peter! And already add the "pseudo_util.c" tag in the subject in

> the v3, please check the mail with the subject "[OE-core] [PATCH v3]

> pseudo_util.c: Open file with O_CLOEXEC to avoid fd leak".


That is not the same. The "pseudo_util.c:" is part of the commit subject 
and will end up in the Git repository. A "[pseudo]" tag is for anyone 
seeing the mail (possibly including patchwork and patchtest), letting 
them know that this commit is about pseudo, not OE-Core (similar to the 
"[PATCH v3]" tag, which is also information about the commit).

> Thanks,

> 

> > //Peter


//Peter
mingli.yu@windriver.com Jan. 20, 2020, 3:27 a.m.
From: Pavel Modilaynen <pavelmn@axis.com>

Use close-on-exec (O_CLOEXEC) flag when open log file to
make sure its file descriptor is not leaked to parent
process on fork/exec.

Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
---
 pseudo_util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mingli.yu@windriver.com Jan. 20, 2020, 3:27 a.m.
On 01/20/20 11:15, Peter Kjellerstedt wrote:
>> -----Original Message-----
>> From: Yu, Mingli <mingli.yu@windriver.com>
>> Sent: den 20 januari 2020 04:04
>> To: Peter Kjellerstedt <peter.kjellerstedt@axis.com>; Paul Eggleton
>> <paul.eggleton@linux.intel.com>
>> Cc: openembedded-core@lists.openembedded.org
>> Subject: Re: [OE-core] ✗ patchtest: failure for Open file with O_CLOEXEC
>> to avoid fd leak (rev3)
>>
>> On 01/20/20 10:28, Peter Kjellerstedt wrote:
>>>> -----Original Message-----
>>>> From: openembedded-core-bounces@lists.openembedded.org <openembedded-
>> core-
>>>> bounces@lists.openembedded.org> On Behalf Of Yu, Mingli
>>>> Sent: den 20 januari 2020 02:34
>>>> To: Paul Eggleton <paul.eggleton@linux.intel.com>
>>>> Cc: openembedded-core@lists.openembedded.org
>>>> Subject: Re: [OE-core] ✗ patchtest: failure for Open file with
>> O_CLOEXEC
>>>> to avoid fd leak (rev3)
>>>>
>>>> On 01/20/20 09:29, Paul Eggleton wrote:
>>>>> Hi Mingli
>>>>>
>>>>> On Sunday, 19 January 2020 6:41:49 PM NZDT Yu, Mingli wrote:
>>>>>> On 01/19/20 13:32, Patchwork wrote:
>>>>>>> == Series Details ==
>>>>>>>
>>>>>>> Series: Open file with O_CLOEXEC to avoid fd leak (rev3)
>>>>>>> Revision: 3
>>>>>>> URL   : https://patchwork.openembedded.org/series/22123/
>>>>>>> State : failure
>>>>>>>
>>>>>>> == Summary ==
>>>>>>>
>>>>>>>
>>>>>>> Thank you for submitting this patch series to OpenEmbedded Core.
>> This
>>>> is
>>>>>>> an automated response. Several tests have been executed on the
>>>> proposed
>>>>>>> series by patchtest resulting in the following failures:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> * Issue             Series does not apply on top of target branch
>>>> [test_series_merge_on_head]
>>>>>>>       Suggested fix    Rebase your series on top of targeted branch
>>>>>>>       Targeted branch  master (currently at 9d7a521971)
>>>>>>
>>>>>> Have already rebased on the master branch of
>>>>>> http://git.yoctoproject.org/cgit/cgit.cgi/pseudo/, why still issue
>> out
>>>>>> the above issue? Any hint?
>>>>>
>>>>> It's assuming that patches sent to this list are for OE-Core (which
>> they
>>>>> generally are). I wasn't aware but apparently the documented place to
>>>>> send pseudo patches is this list, so I think in this case you can just
>>>>> ignore patchtest.
>>>>
>>>> Okay, many thanks Paul for your hint!
>>>>
>>>> Thanks,
>>>>
>>>>>
>>>>> Cheers,
>>>>> Paul
>>>
>>> But it is probably a good idea to include a "[pseudo]" tag in the
>> subject
>>> when sending patches related to pseudo to this list, as the expectation
>>> otherwise is that they are for OE-Core.
>>
>> Thanks Peter! And already add the "pseudo_util.c" tag in the subject in
>> the v3, please check the mail with the subject "[OE-core] [PATCH v3]
>> pseudo_util.c: Open file with O_CLOEXEC to avoid fd leak".
>
> That is not the same. The "pseudo_util.c:" is part of the commit subject
> and will end up in the Git repository. A "[pseudo]" tag is for anyone
> seeing the mail (possibly including patchwork and patchtest), letting
> them know that this commit is about pseudo, not OE-Core (similar to the
> "[PATCH v3]" tag, which is also information about the commit).

Got it! V4 is incoming.

Thanks,

>
>> Thanks,
>>
>>> //Peter
>
> //Peter
>