Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1632964
| Path | csiph.com!weretis.net!feeder4.news.weretis.net!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Sebastien Buisson <sbuisson.ddn@gmail.com> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 2/3] selinux: add checksum to policydb |
| Date | Fri, 28 Apr 2017 17:20:01 +0200 |
| Message-ID | <tBfQB-HT-3@gated-at.bofh.it> (permalink) |
| References | <tAx3c-46S-13@gated-at.bofh.it> <tAx3c-46S-11@gated-at.bofh.it> <tAzRn-5Yn-5@gated-at.bofh.it> <tANhE-6ta-9@gated-at.bofh.it> <tATn3-2pt-5@gated-at.bofh.it> <tAVfb-3DH-5@gated-at.bofh.it> <tAWEh-4wU-7@gated-at.bofh.it> |
| X-Original-To | Stephen Smalley <sds@tycho.nsa.gov> |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=UVeHii77TtkHIdlhR0FifW494iKgmqQxaiEyX/zp5QM=; b=IFoHnFC9UZ50QMaInmoP9jijZ77PD0V3Yg6EYvw9S2Jpgw65bghSx3JXWBJN+IFayy fFk1LAFJPi9mOqTyKR6hN4n4r8rRC8vf8yIp78tDcZGHzGdPvb9wDGIVIOP8yp7ykU0L OLfW/3EJ81IvZV++rN06UX/OKdyWOGJm1uWToUo/UGphFXYfST1R3DRggNT+X5s4KPmm 4Mfv12sK1+FS+hazDUiHCM3nFfaj0Tg098/Rs2sYJPcaF8fVc+8qIcINvmz0yWuNNUvm Q7FlmLCJLnZQe/moCIn33o1SskHzkVXFzdqLpkuVr4OumMqJ7Sye8pzPx+/R/GrPWpwm jm+Q== |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=UVeHii77TtkHIdlhR0FifW494iKgmqQxaiEyX/zp5QM=; b=ULXrE5WQxt7hzh+8BNvXRCGUXrx7+n5h3MU0Z9m3ZlEvu034tu9RfV/JLmQMuudCqO P8Lg1OLP3x61/ZB1fvRC3wrH/qJTPsGrzIxkJrs78uWEyjWXFRe3aaBNexWDgFSDipMJ qxfhTfiZYZBtMKZ9juJ/ezSFuztU0mQ1plPeh0uV3jL/Ujy32qE3DFc3Fcfv8AJyrH1r 5s0PK2pxlPttZKH0oWtFmB/SyYhoqcxOhTTmv44ged5deYsHUBVafT9eVkkfbvzbKbru t+OZgdlzFsdN+mr0jAzHBAwQHTn41zDWwiaXOWdIBUGew0RnHE4carfbzgJ8hsFFWk+d 0fAA== |
| X-Gm-Message-State | AN3rC/4Z3Q5wqiI3ESMeCt335PRnV1Zeu02R7iM7/OZhIzFWlewhvk4X C64OM5/cX+mWHCeMRQjvN00t3lSsKw== |
| X-Received | by 10.200.1.1 with SMTP id e1mr11224754qtg.3.1493392651181; Fri, 28 Apr 2017 08:17:31 -0700 (PDT) |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 66 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, selinux@tycho.nsa.gov, serge@hallyn.com, james.l.morris@oracle.com, Eric Paris <eparis@parisplace.org>, Paul Moore <paul@paul-moore.com>, Daniel Jurgens <danielj@mellanox.com>, Sebastien Buisson <sbuisson@ddn.com> |
| X-Original-Date | Fri, 28 Apr 2017 17:16:50 +0200 |
| X-Original-Message-ID | <CAPkE-bUyWt8ovJ9pV+EFx9yUq9fVUy_G5yjEw7ZzLY3f3Ey1Aw@mail.gmail.com> |
| X-Original-References | <1493218936-18522-1-git-send-email-sbuisson@ddn.com> <1493218936-18522-2-git-send-email-sbuisson@ddn.com> <1493231426.32540.11.camel@tycho.nsa.gov> <CAPkE-bVPHAGDX2uSt41UanVwiaJ3trCTgkUJiPNKNGKYVPMikw@mail.gmail.com> <1493306283.2524.17.camel@tycho.nsa.gov> <CAPkE-bVo7BO4WypVoeTiNBkbva1touoG2f7KjC3-RgvFXe3FXg@mail.gmail.com> <1493318826.2524.21.camel@tycho.nsa.gov> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1632964 |
Show key headers only | View raw
2017-04-27 20:47 GMT+02:00 Stephen Smalley <sds@tycho.nsa.gov>: >> I just checked, with the method of computing the checksum on a (data, >> len) pair on entry to security_load_policy() the checksum does not >> change after using setsebool. So it seems I would need to call >> security_read_policy() to retrieve the binary representation of the >> policy as currently enforced by the kernel. Unless you can see >> another >> way? > > I don't think that's a viable option, since security_read_policy() is > going to be expensive in order to generate a full policy image, while > security_set_bools() is supposed to be substantially cheaper than a > full policy load. > > Also, the advantage of taking the hash of the original input file is > that you can independently compute a reference hash offline or on the > server from the same policy file and compare them and you can identify > which policy file was loaded based on the hash. > > If you care about the active boolean state, then I'd suggest hashing > the active boolean state separately and storing that after the policy > hash. You can do that in both security_load_policy() and > security_set_bools(). Just iterate through the bools like > security_set_bools() does, write the ->state of each boolean into a > buffer, and then hash that buffer. I just noticed another issue: with the method of computing the checksum on a (data, len) pair on entry to security_load_policy(), the checksum does not change after inserting a new module with semodule. It is a problem as a module can allow actions by certain users on some file contexts. So not detecting that kind of policy tampering defeats the purpose of the checksum as I imagine it. To address this I propose to come back to the idea of the notifier. The checksum would not be stored inside the struct policydb. The checksum would be computed on a (data, len) pair got from security_read_policy() every time someone is asking for it through the security_policy_cksum() hook. The ones that would potentially call security_policy_cksum() are those that would register a callback on lsm_notifier, and the userspace processes reading /sys/fs/selinux/policycksum. So no matter if computing the checksum gets expensive, that would be the caller's responsibility to use it with care. Just like with /sys/fs/selinux/policy today in fact. >> > You needed to get (global) enforcing mode too, didn't you? That's >> > separate from the policy. >> >> Exactly, I also need to rework the patch I proposed about this, in >> light of the comments I received. > > So perhaps what you really want is a hook interface and a selinuxfs > interface that returns a single string that encodes all of the policy > properties that you care about? Rather than separate hooks and > interfaces? You could embed the enforcing status in the string too. > Should probably include checkreqprot as well since that affects > enforcement of mmap/mprotect checks. True, I should build a string of the form: <0 or 1 for enforce>:<0 or 1 for checkreqprot>:<hashalg>=<global checksum> I should probably rename it 'policybrief' instead of 'policycksum'. I realize that the 'SELinux user to UNIX user' assignments are important as well. If for instance a regular user on a given cluster node is mapped to unconfined_u instead of user_u, this user would erroneously have major privileges. I do not know where I should look for this information, and possibly compute another checksum.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 2/3] selinux: add checksum to policydb Sebastien Buisson <sbuisson.ddn@gmail.com> - 2017-04-26 17:30 +0200
Re: [PATCH 2/3] selinux: add checksum to policydb Stephen Smalley <sds@tycho.nsa.gov> - 2017-04-26 20:30 +0200
Re: [PATCH 2/3] selinux: add checksum to policydb Sebastien Buisson <sbuisson.ddn@gmail.com> - 2017-04-27 10:50 +0200
Re: [PATCH 2/3] selinux: add checksum to policydb Stephen Smalley <sds@tycho.nsa.gov> - 2017-04-27 17:20 +0200
Re: [PATCH 2/3] selinux: add checksum to policydb Sebastien Buisson <sbuisson.ddn@gmail.com> - 2017-04-27 19:20 +0200
Re: [PATCH 2/3] selinux: add checksum to policydb Stephen Smalley <sds@tycho.nsa.gov> - 2017-04-27 20:50 +0200
Re: [PATCH 2/3] selinux: add checksum to policydb Sebastien Buisson <sbuisson.ddn@gmail.com> - 2017-04-28 17:20 +0200
Re: [PATCH 2/3] selinux: add checksum to policydb Stephen Smalley <sds@tycho.nsa.gov> - 2017-04-28 17:50 +0200
Re: [PATCH 2/3] selinux: add checksum to policydb Sebastien Buisson <sbuisson.ddn@gmail.com> - 2017-04-28 18:10 +0200
Re: [PATCH 2/3] selinux: add checksum to policydb Stephen Smalley <sds@tycho.nsa.gov> - 2017-04-28 18:40 +0200
csiph-web