On 12/12/2017 11:24 AM, John Crispin wrote:
> 
>  
>  board_config_flush() {
> +     # when calling json_dump with a redirect, the shell will truncate the 
> target
> +     # file and not update it until a close/flush is called. this results in 
> a short
> +     # window where the file is 0 bytes. mitigate the issue by generating 
> the file
> +     # in 2 steps

As Roman correctly noted in his patch, this is not the case. The file is
moved between different filesystems (tmpfs to actual root), which is never
guaranteed to be atomic; internally, rename() can't be used, so mv just
falls back to truncate+write as well. The mv makes the race window shorter,
but does not completely mitigate it.

Either the comment should correctly reflect the situation, or we should
actually fix this by creating the temporary file on the root fs.

Regards,
Matthias

>       json_dump -i > /tmp/.board.json
>       mv /tmp/.board.json ${CFG}
>  }
> 


Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev

Reply via email to