sandbox: use O_CLOEXEC in os_open()
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Tue, 27 Oct 2020 19:29:24 +0000 (20:29 +0100)
committerSimon Glass <sjg@chromium.org>
Thu, 5 Nov 2020 16:11:30 +0000 (09:11 -0700)
During a cold reset execv() is used to relaunch the U-Boot binary.
We must ensure that all files are closed in this case.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
arch/sandbox/cpu/os.c

index c461fb0..7e474d6 100644 (file)
@@ -80,6 +80,11 @@ int os_open(const char *pathname, int os_flags)
                flags |= O_CREAT;
        if (os_flags & OS_O_TRUNC)
                flags |= O_TRUNC;
+       /*
+        * During a cold reset execv() is used to relaunch the U-Boot binary.
+        * We must ensure that all files are closed in this case.
+        */
+       flags |= O_CLOEXEC;
 
        return open(pathname, flags, 0777);
 }