[prev in list] [next in list] [prev in thread] [next in thread] 

List:       seandroid-list
Subject:    Re: I have some question about restorcon_recursive's skipped because of symbolic-link attribute.
From:       심현용 <jonesn5508 () gmail ! com>
Date:       2015-08-26 6:25:10
Message-ID: CA+zkWNVqXkCZKcganr8b44ndd16N5VBx+tAmqhDZBGRUWwHwjQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Thank you for you detail guide.

It is not symlink's restorecon_recursive issue, it is MountService's issue.
I knew, It doesn't work package scan in sdcard when is upgrading L to M.

In this reason, this package doesn't come in PMS's restoreconData.

Thanks, Regard.

2015-08-25 23:57 GMT+09:00 Stephen Smalley <sds@tycho.nsa.gov>:

> Ok, I think I figured it out.  A few points:
>
> - It looks like we haven't been setting the lib symlink context to match
> the rest of the app data directory for some time.  We did that
> originally but it looks like it got dropped at some point (before the
> relocation of installd to frameworks/native).  Not clear that is a
> problem though since those symlinks are also owned by installd rather
> than by the app UID, so it isn't necessarily the case that you want them
> to be accessible beyond read/follow.
>
> - installd now creates the symlinks in response to a separate command
> (linklib) issued by the frameworks rather than upon install or
> make_user_data commands.  If we wanted them to be labeled with the same
> level as the rest of the directory, we would need to add a
> selinux_android_restorecon() call there.
>
> - The symlinks are root-owned in master because installd has reverted to
> running as root in master, whereas they used to be install-owned.
>
> So I don't believe there is any problem with restorecon (restorecon -DRv
> /data/data/<pkgdir> labels the symlinks correctly for me), but merely
> with the fact that installd is creating the symlinks and is not
> explicitly labeling them.  So they inherit the type from the parent
> directory (the usual default) but inherit their level from the creating
> process (also the usual default).
>
> The question is whether this is in fact a problem in any way.  As I
> said, the symlinks should still be readable by the apps, so the only
> impact is that the apps won't be allowed to unlink the symlinks.  But I
> don't see why that would be a problem.  It is arguable that the symlinks
> shouldn't be unlinkable by the apps in the first place.  Is this
> labeling causing you any real problems with M or are you simply noticing
> it as an inconsistency?
>
> On 08/24/2015 07:55 PM, 심현용 wrote:
> > Dear Stephan.
> >
> > Thank you for your kindly reply.
> >
> > Actually, this issue doen't using about forward-locked app.
> > As you guessing, It should be work likes vold deamon's move to SDcard in
> > Setting apk.
> >
> > "Move to sdcard" operation is that apk's user datas likes libs.. can
> > move to asec partition(sdcard).
> >
> > It is possible to occur doessn't perform restorecon of the symlink?
> >
> > I'm very curious about PMS operation during L to M upgrade.
> > As you said that installd handles the restorecon of package directories
> > on upgrade, I think it is also called api
> > selinux_android_restorecon_common in android.c
> >
> > I did logging in selinux_android_restorecon_common's default : (before
> > restorecon_sb) like that.
> >
> > default:
> >             if ( strstr(pathname, "nhn") !=  NULL )
> >                selinux_log(SELINUX_ERROR, "hyunyong.sim : default in
> > path : %s\n", pathname);
> >
> > I couldn't find /data/data/ package log.
> >
> > but when I didn't operation move to sdcard in Setting apk,
> > I could find /data/app/(package name) in
> > selinux_android_restorecon_common like bellow.
> >
> > init: hyunyong.sim :  restorecon_sb path name
> > /data/app/com.nhn.android.search-1.
> > init: hyunyong.sim :  restorecon_sb path name
> > /data/app/com.nhn.android.search-1/base.apk.
> > init: hyunyong.sim :  restorecon_sb path name
> > /data/app/com.nhn.android.search-1/lib.
> > init: hyunyong.sim :  restorecon_sb path name
> > /data/app/com.nhn.android.search-1/lib/arm.
> > init: hyunyong.sim :  restorecon_sb path name
> > /data/app/com.nhn.android.search-1/lib/arm/libafpe2.so.
> > init: hyunyong.sim :  restorecon_sb path name
> > /data/app/com.nhn.android.search-1/lib/arm/libCrashHandler.so.
> > init: hyunyong.sim :  restorecon_sb path name
> > /data/app/com.nhn.android.search-1/lib/arm/libSpeechRecogJNI2.so.
> >
> > It is possible to restorecon_recursive(/data/data) ?
> >
> > I don't know where can I debugging in my source.
> >
> > Please give me a hands.
> >
> > Thanks.
> >
> > 2015-08-25 3:49 GMT+09:00 Stephen Smalley <sds@tycho.nsa.gov
> > <mailto:sds@tycho.nsa.gov>>:
> >
> >     On 08/23/2015 09:29 PM, 심현용 wrote:
> >     > Dear all.
> >     >
> >     > At the booting time, I know restorecon_recursive about /data in
> init.rc
> >     > or restsorecon_recursive(/sys) in init.cpp.
> >     >
> >     > /system/core/rootdir/init.rc
> >     > 369     # Set SELinux security contexts on upgrade or policy
> update.
> >     > 370     restorecon_recursive /data
> >     >
> >     > /system/core/init/init.cpp
> >     > 1208     restorecon_recursive("/sys");
> >     >
> >     > But, it doesn't work well likes bellow file attribute like
> symbolic-link.
> >     >
> >     > /data/data/com.nhn.android.search # ls -Z
> >     > lrwxrwxrwx install  install
> >      *u:object_r:app_data_file:s0* *lib
> >     > -> /mnt/asec/com.nhn.android.search-2/lib/arm*/
> >     >
> >     > When upgrading processing L to M OS, this label
> (/data/data/"pakcage")
> >     > has to change app_data_file:s0:c512,c768, but didn't work about
> symbolic
> >     > link attribute file.
> >     >
> >     > When I execute command restorecon
> /data/data/com.nhn.android.search in
> >     > adb shell.
> >     > It did well like bellow.
> >     > drwxr-x--x u0_a184  u0_a184
> >     > u:object_r:app_data_file:s0:c512,c768 com.nhn.android.search
> >     >
> >     > How can I resolve this issue.
> >
> >     That does appear to be a bug.  It is actually installd that handles
> the
> >     restorecon of package directories on upgrade, triggered by calls from
> >     the PMS.  I reproduced by doing an adb install -l of an apk on L,
> then
> >     upgrading to master.  As you note above, the lib symlink is not
> >     relabeled in that situation.  If you run restorecon -RDv on the
> package
> >     directory from an adb shell, it is then correctly relabeled.  This
> only
> >     appears to occur with forward-locked apps; regular apps have their
> lib
> >     symlink correctly relabeled with categories.  The other interesting
> >     difference in symlinks is that the forward-locked apps have
> root-owned
> >     symlinks while the regular apps have install-owned ones.
> >
> >     I'm not sure of the impact however.  In either case, the symlink
> should
> >     be readable by the app, so following the link should work regardless.
> >     The app won't be able to unlink the symlink in the forward-locked app
> >     case due to this mislabeling, but I don't know why it would want to
> >     do so.
> >
> >     I'm guessing that these symlinks are actually created by something
> other
> >     than installd when the asec container is mounted (vold?), and that
> >     component doesn't perform a restorecon of the symlink.
> >
> >
>
>

[Attachment #5 (text/html)]

<div dir="ltr">Thank you for you detail guide.<div><br></div><div>It is not \
symlink&#39;s restorecon_recursive issue, it is MountService&#39;s issue.</div><div>I \
knew, It doesn&#39;t work package scan in sdcard when is upgrading L to \
M.</div><div><br></div><div>In this reason, this package doesn&#39;t come in \
PMS&#39;s restoreconData.</div><div><br></div><div>Thanks, Regard.</div></div><div \
class="gmail_extra"><br><div class="gmail_quote">2015-08-25 23:57 GMT+09:00 Stephen \
Smalley <span dir="ltr">&lt;<a href="mailto:sds@tycho.nsa.gov" \
target="_blank">sds@tycho.nsa.gov</a>&gt;</span>:<br><blockquote class="gmail_quote" \
style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Ok, I think I \
figured it out.   A few points:<br> <br>
- It looks like we haven&#39;t been setting the lib symlink context to match<br>
the rest of the app data directory for some time.   We did that<br>
originally but it looks like it got dropped at some point (before the<br>
relocation of installd to frameworks/native).   Not clear that is a<br>
problem though since those symlinks are also owned by installd rather<br>
than by the app UID, so it isn&#39;t necessarily the case that you want them<br>
to be accessible beyond read/follow.<br>
<br>
- installd now creates the symlinks in response to a separate command<br>
(linklib) issued by the frameworks rather than upon install or<br>
make_user_data commands.   If we wanted them to be labeled with the same<br>
level as the rest of the directory, we would need to add a<br>
selinux_android_restorecon() call there.<br>
<br>
- The symlinks are root-owned in master because installd has reverted to<br>
running as root in master, whereas they used to be install-owned.<br>
<br>
So I don&#39;t believe there is any problem with restorecon (restorecon -DRv<br>
/data/data/&lt;pkgdir&gt; labels the symlinks correctly for me), but merely<br>
with the fact that installd is creating the symlinks and is not<br>
explicitly labeling them.   So they inherit the type from the parent<br>
directory (the usual default) but inherit their level from the creating<br>
process (also the usual default).<br>
<br>
The question is whether this is in fact a problem in any way.   As I<br>
said, the symlinks should still be readable by the apps, so the only<br>
impact is that the apps won&#39;t be allowed to unlink the symlinks.   But I<br>
don&#39;t see why that would be a problem.   It is arguable that the symlinks<br>
shouldn&#39;t be unlinkable by the apps in the first place.   Is this<br>
labeling causing you any real problems with M or are you simply noticing<br>
it as an inconsistency?<br>
<div><div class="h5"><br>
On 08/24/2015 07:55 PM, 심현용 wrote:<br>
&gt; Dear Stephan.<br>
&gt;<br>
&gt; Thank you for your kindly reply.<br>
&gt;<br>
&gt; Actually, this issue doen&#39;t using about forward-locked app.<br>
&gt; As you guessing, It should be work likes vold deamon&#39;s move to SDcard in<br>
&gt; Setting apk.<br>
&gt;<br>
&gt; &quot;Move to sdcard&quot; operation is that apk&#39;s user datas likes libs.. \
can<br> &gt; move to asec partition(sdcard).<br>
&gt;<br>
&gt; It is possible to occur doessn&#39;t perform restorecon of the symlink?<br>
&gt;<br>
&gt; I&#39;m very curious about PMS operation during L to M upgrade.<br>
&gt; As you said that installd handles the restorecon of package directories<br>
&gt; on upgrade, I think it is also called api<br>
&gt; selinux_android_restorecon_common in android.c<br>
&gt;<br>
&gt; I did logging in selinux_android_restorecon_common&#39;s default : (before<br>
&gt; restorecon_sb) like that.<br>
&gt;<br>
&gt; default:<br>
&gt;                    if ( strstr(pathname, &quot;nhn&quot;) !=   NULL )<br>
&gt;                        selinux_log(SELINUX_ERROR, &quot;hyunyong.sim : default \
in<br> &gt; path : %s\n&quot;, pathname);<br>
&gt;<br>
&gt; I couldn&#39;t find /data/data/ package log.<br>
&gt;<br>
&gt; but when I didn&#39;t operation move to sdcard in Setting apk,<br>
&gt; I could find /data/app/(package name) in<br>
&gt; selinux_android_restorecon_common like bellow.<br>
&gt;<br>
&gt; init: hyunyong.sim :   restorecon_sb path name<br>
&gt; /data/app/com.nhn.android.search-1.<br>
&gt; init: hyunyong.sim :   restorecon_sb path name<br>
&gt; /data/app/com.nhn.android.search-1/base.apk.<br>
&gt; init: hyunyong.sim :   restorecon_sb path name<br>
&gt; /data/app/com.nhn.android.search-1/lib.<br>
&gt; init: hyunyong.sim :   restorecon_sb path name<br>
&gt; /data/app/com.nhn.android.search-1/lib/arm.<br>
&gt; init: hyunyong.sim :   restorecon_sb path name<br>
&gt; /data/app/com.nhn.android.search-1/lib/arm/libafpe2.so.<br>
&gt; init: hyunyong.sim :   restorecon_sb path name<br>
&gt; /data/app/com.nhn.android.search-1/lib/arm/libCrashHandler.so.<br>
&gt; init: hyunyong.sim :   restorecon_sb path name<br>
&gt; /data/app/com.nhn.android.search-1/lib/arm/libSpeechRecogJNI2.so.<br>
&gt;<br>
&gt; It is possible to restorecon_recursive(/data/data) ?<br>
&gt;<br>
&gt; I don&#39;t know where can I debugging in my source.<br>
&gt;<br>
&gt; Please give me a hands.<br>
&gt;<br>
&gt; Thanks.<br>
&gt;<br>
&gt; 2015-08-25 3:49 GMT+09:00 Stephen Smalley &lt;<a \
href="mailto:sds@tycho.nsa.gov">sds@tycho.nsa.gov</a><br> </div></div>&gt; \
&lt;mailto:<a href="mailto:sds@tycho.nsa.gov">sds@tycho.nsa.gov</a>&gt;&gt;:<br> <div \
class="HOEnZb"><div class="h5">&gt;<br> &gt;        On 08/23/2015 09:29 PM, 심현용 \
wrote:<br> &gt;        &gt; Dear all.<br>
&gt;        &gt;<br>
&gt;        &gt; At the booting time, I know restorecon_recursive about /data in \
init.rc<br> &gt;        &gt; or restsorecon_recursive(/sys) in init.cpp.<br>
&gt;        &gt;<br>
&gt;        &gt; /system/core/rootdir/init.rc<br>
&gt;        &gt; 369        # Set SELinux security contexts on upgrade or policy \
update.<br> &gt;        &gt; 370        restorecon_recursive /data<br>
&gt;        &gt;<br>
&gt;        &gt; /system/core/init/init.cpp<br>
&gt;        &gt; 1208        restorecon_recursive(&quot;/sys&quot;);<br>
&gt;        &gt;<br>
&gt;        &gt; But, it doesn&#39;t work well likes bellow file attribute like \
symbolic-link.<br> &gt;        &gt;<br>
&gt;        &gt; /data/data/com.nhn.android.search # ls -Z<br>
&gt;        &gt; lrwxrwxrwx install   install<br>
&gt;         *u:object_r:app_data_file:s0* *lib<br>
&gt;        &gt; -&gt; /mnt/asec/com.nhn.android.search-2/lib/arm*/<br>
&gt;        &gt;<br>
&gt;        &gt; When upgrading processing L to M OS, this label \
(/data/data/&quot;pakcage&quot;)<br> &gt;        &gt; has to change \
app_data_file:s0:c512,c768, but didn&#39;t work about symbolic<br> &gt;        &gt; \
link attribute file.<br> &gt;        &gt;<br>
&gt;        &gt; When I execute command restorecon /data/data/com.nhn.android.search \
in<br> &gt;        &gt; adb shell.<br>
&gt;        &gt; It did well like bellow.<br>
&gt;        &gt; drwxr-x--x u0_a184   u0_a184<br>
&gt;        &gt; u:object_r:app_data_file:s0:c512,c768 com.nhn.android.search<br>
&gt;        &gt;<br>
&gt;        &gt; How can I resolve this issue.<br>
&gt;<br>
&gt;        That does appear to be a bug.   It is actually installd that handles \
the<br> &gt;        restorecon of package directories on upgrade, triggered by calls \
from<br> &gt;        the PMS.   I reproduced by doing an adb install -l of an apk on \
L, then<br> &gt;        upgrading to master.   As you note above, the lib symlink is \
not<br> &gt;        relabeled in that situation.   If you run restorecon -RDv on the \
package<br> &gt;        directory from an adb shell, it is then correctly relabeled.  \
This only<br> &gt;        appears to occur with forward-locked apps; regular apps \
have their lib<br> &gt;        symlink correctly relabeled with categories.   The \
other interesting<br> &gt;        difference in symlinks is that the forward-locked \
apps have root-owned<br> &gt;        symlinks while the regular apps have \
install-owned ones.<br> &gt;<br>
&gt;        I&#39;m not sure of the impact however.   In either case, the symlink \
should<br> &gt;        be readable by the app, so following the link should work \
regardless.<br> &gt;        The app won&#39;t be able to unlink the symlink in the \
forward-locked app<br> &gt;        case due to this mislabeling, but I don&#39;t know \
why it would want to<br> &gt;        do so.<br>
&gt;<br>
&gt;        I&#39;m guessing that these symlinks are actually created by something \
other<br> &gt;        than installd when the asec container is mounted (vold?), and \
that<br> &gt;        component doesn&#39;t perform a restorecon of the symlink.<br>
&gt;<br>
&gt;<br>
<br>
</div></div></blockquote></div><br></div>



_______________________________________________
Seandroid-list mailing list
Seandroid-list@tycho.nsa.gov
To unsubscribe, send email to Seandroid-list-leave@tycho.nsa.gov.
To get help, send an email containing "help" to Seandroid-list-request@tycho.nsa.gov.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic