<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">Erico,</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 21, 2020 at 4:57 PM Erico Nunes <<a href="mailto:ernunes@redhat.com" target="_blank">ernunes@redhat.com</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"><span class="gmail_default" style="font-size:small">...</span><br><br>
> Maybe renaming the function to tst_lockdown_enabled() is better? Then we<br>
> can return 1 if confirm kernel under lockdown mode otherwise 0.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">How do you think about this suggestion? ^^</div></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Another reason to name it as tst_lockdown_enabled() is, we can give more flexible</div><div class="gmail_default" style="font-size:small">to test case, because not all tests need a simple skip in lockdown mode(in future).</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">i.e.</div><div class="gmail_default" style="font-size:small">if (tst_lockdown_enabled()) {</div><div class="gmail_default" style="font-size:small">   // skip or not,</div><div class="gmail_default" style="font-size:small">   // do what they wanted in this mode</div><div class="gmail_default" style="font-size:small">}</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> After thinking over, I guess it's not enough to only check<br>
> /sys/../lockdown file. Seems we need to consider the situation that<br>
> system without supporting this file? <br>
> <br>
> i.e. <br>
>   Test on RHEL8 (no /sys/../lockdown file) with kernel parameter<br>
> "lockdown" and got the restriction error too.<br>
> <br>
> # cat /proc/cmdline <br>
> BOOT_IMAGE=(hd0,msdos1)/vmlinuz-4.18.0-226.el8.x86_64<br>
> root=/dev/mapper/rhel_bootp--73--3--209-root ro console=ttyS0,115200<br>
> ... lockdown<br>
>     <br>
> # ll /sys/kernel/security/lockdown<br>
> ls: cannot access '/sys/kernel/security/lockdown': No such file or directory<br>
<br>
To my understanding, the parameter to enable lockdown through kenrel<br>
parameters is "lockdown={integrity|confidentiality}", not just<br>
"lockdown", at least on upstream kernels:<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Good to know this.</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">
<a href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=aefcf2f4b58155d27340ba5f9ddbe9513da8286d" rel="noreferrer" target="_blank">https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=aefcf2f4b58155d27340ba5f9ddbe9513da8286d</a> </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
If /sys/kernel/security/lockdown doesn't exist, I'm not sure there is<br>
much we can do easily, or that is worth doing now. I think it is ok to<br>
fall back and fail like it has been happening since the feature was<br>
merged upstream.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Yes, it looks a bit tricky.</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">
I can't see a tweak that would enable the feature but not the sysfs file<br>
in the kernel source. Maybe that kernel only had partial support?<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Seems you're right, there are many differences between mainline-kernel</div><div class="gmail_default" style="font-size:small">and some distros in lockdown code. The reason that some distribution</div><div class="gmail_default" style="font-size:small">(i.e RHEL, Ubuntu) partly customizes the LSM feature, it does not support</div><div class="gmail_default" style="font-size:small">lockdown features completely so far.</div></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">But one point we're sure is that the /sys/kernel/../lockdown file was</div><div class="gmail_default" style="font-size:small">introduced from kernel-v5.4.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">So maybe we could simply do detect the /sys/kernel/../loackdown file as your patch,</div><div class="gmail_default" style="font-size:small">but adding an extra warning print when test failed on older than kernel-v5.4.</div><div><br></div><div><div class="gmail_default" style="font-size:small">Or, if others can provide a better way I'd happy to hear.</div></div><div> </div></div>-- <br><div dir="ltr"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>