<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Dec 21, 2021 at 9:02 PM Cyril Hrubis <<a href="mailto:chrubis@suse.cz">chrubis@suse.cz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi!<br>
> Firstly, I'm sorry to push the patchset about oom protection cursorily.<br>
<br>
No problem.<br>
<br>
> The GitHub CI complained about the following failures, I feel confused<br>
> when I add a bit of debug code in my private branch then. It gets passed<br>
> in access(score_path, R_OK|W_OK) but failed in closing the file and<br>
> give no EACCESS errno, that's wired.<br>
> <br>
> Did I miss anything?<br>
> <br>
> <a href="https://github.com/wangli5665/ltp/runs/4594473907?check_suite_focus=true" rel="noreferrer" target="_blank">https://github.com/wangli5665/ltp/runs/4594473907?check_suite_focus=true</a><br>
<br>
It does fail the same for me locally when I run the test05 under an<br>
unpriviledged user. I guess that the error when we write negative number<br>
to the file actually manifests when we attempt to close the file because<br>
we use the FILE interface in safe_file_printf(). That way the actuall<br>
write is buffered and deffered until the fclose() call.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Sounds possible.</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
So it looks like writing negative value to the file does return with<br>
error for an unprivileged user.<br>
<br>
I was looking at file_printf() as a potential solution, but that one<br>
does produce warnings. But it looks like we do not actually use the<br>
file_printf() function anywhere in the code so we may as well change it<br>
so that it just returns if the operation was successful or not and make<br>
it silent so that it does not produce any messages at all.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">+1 It makes sense to keep silent when the operation is not successful.</div></div><div class="gmail_default" style="font-size:small">That needs an explicit difference between safe_file_printf() I guess.</div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>