Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1164179AbdD1QI4 (ORCPT ); Fri, 28 Apr 2017 12:08:56 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:36192 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932265AbdD1QIt (ORCPT ); Fri, 28 Apr 2017 12:08:49 -0400 MIME-Version: 1.0 In-Reply-To: <1493394641.6177.8.camel@tycho.nsa.gov> 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> <1493306283.2524.17.camel@tycho.nsa.gov> <1493318826.2524.21.camel@tycho.nsa.gov> <1493394641.6177.8.camel@tycho.nsa.gov> From: Sebastien Buisson Date: Fri, 28 Apr 2017 18:08:07 +0200 Message-ID: Subject: Re: [PATCH 2/3] selinux: add checksum to policydb To: Stephen Smalley 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 , Paul Moore , Daniel Jurgens , Sebastien Buisson Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1265 Lines: 24 2017-04-28 17:50 GMT+02:00 Stephen Smalley : > You seem to be conflating kernel policy with userspace policy. > security_load_policy() is provided with the kernel policy image, which > is the result of linking the kernel-relevant portions of all policy > modules together. A hash of that image will change if you insert a > policy module that affects the kernel policy in any way. But a change > that only affects userspace policy isn't ever going to be reflected in > the kernel. It doesn't matter where or when you compute your checksum > within the kernel; it isn't ever going to reflect those userspace > policy changes. Here is the content of the module is used for my tests: #============= user_t ============== allow user_t mnt_t:dir { write add_name }; allow user_t mnt_t:file { write create }; After loading the .pp corresponding to it, I can see that with the method of computing the checksum on the (data, len) pair on entry to security_load_policy(), the checksum does not change. However, when using the (data, len) pair got from security_read_policy(), the checksum changes. And when I remove the module, the checksum is back to its previous value. So this is what makes me think there is a difference. Am I missing something?