From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756749AbdEHUH4 (ORCPT ); Mon, 8 May 2017 16:07:56 -0400 Received: from nm30-vm6.bullet.mail.ne1.yahoo.com ([98.138.91.123]:43216 "EHLO nm30-vm6.bullet.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753741AbdEHUHx (ORCPT ); Mon, 8 May 2017 16:07:53 -0400 X-Yahoo-Newman-Id: 415856.48079.bm@smtp110.mail.ne1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: d6g_ybUVM1lVlYh0wjEZXGoma.XrUQr4WZE1NIaoP_dyF3o dxS74FpiaLBFG2wwjA_dMffnhKsYZtAWiBM2dJobbIgW6Xac_CQMY59h1NoN gj.ndXtgKipNALj94x7voRqn9A.tPsvV1u.9XPlimuaHPow2e73Rt10H2pg2 bhxOAG1Z87XLSpHd8U8zBrWPg6mO0INHd.XSoU1jUlYRve7AfhlNGCJWzR4R AyOJBqOClUDGPrxWFdnSOZmjfDrEEoKFMbtFcO.WbdPSok2LxR_CWC6hAa05 kxWEzC1WrvzBseclNH7ipTiQeoRWw3ar6wWt2ADTBBWqgr_dyozsYM75mBbC vzqkOW7nzOunKJFc_OAKYqs5kKKCKbmTTz74nPmapZ9dKOf1WZrtbwOgrR6X _Fe_qSbFG9EhvHiaNY.uCXkUf0I6d_Tda1UoQ0BCcpCZJBHG4JPXZemRmLbE rKADFMnTS1qX6jOmXvTRDQ78KyyrJCT6WMtP3i0pO74wwj2WuDiGPdw04oHy GntLtrOaHXWKMPBHgZ6Kr2u.ikz_LO4yTPrCJxtkqWkdbctRdPmTl X-Yahoo-SMTP: OIJXglSswBDfgLtXluJ6wiAYv6_cnw-- Subject: Re: [PATCH v1] LSM: Enable multiple calls to security_add_hooks() for the same LSM To: =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= , James Morris , Tetsuo Handa References: <20170429190257.27137-1-mic@digikod.net> Cc: linux-kernel@vger.kernel.org, James Morris , Kees Cook , "Serge E . Hallyn" , linux-security-module@vger.kernel.org From: Casey Schaufler Message-ID: Date: Mon, 8 May 2017 13:07:50 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/8/2017 12:24 PM, Mickaël Salaün wrote: > On 01/05/2017 01:28, James Morris wrote: >> On Sat, 29 Apr 2017, Mickaël Salaün wrote: >> >>> Check if the registering LSM already registered hooks just before. This >>> enable to split hook declarations into multiple files without >>> registering multiple time the same LSM name, starting from commit >>> d69dece5f5b6 ("LSM: Add /sys/kernel/security/lsm"). >> Please include a detailed rationale for these patches. The above tells us >> very little about why they are needed. > Right, what do you think about that? > > The commit d69dece5f5b6 ("LSM: Add /sys/kernel/security/lsm") extend > security_add_hooks() with a new parameter to register the LSM name, > which may be useful to make the list of currently loaded LSM available > to userspace. However, there is no clean way for an LSM no split its > hook declarations into multiple files, which may reduce the mess with > all the included files (needed for LSM hook argument types) and make the > source code easier to review and maintain. > > This change allows an LSM to register multiple times its hook while > keeping a consistent list of LSM names as described in > Documentation/security/LSM.txt . The list reflects the order in which > checks are made. This patch only check for the last registered LSM, > which should be the only case. If an LSM register multiple times its > hooks, interleaved with other LSM registrations, which should not > happen, its name will still appear in the same order that the hooks are > called, hence multiple times. > > > Casey, Tetsuo, are you OK with this approach or do you want me to handle > the case with interleaved hook registration, i.e. no duplicate name nor > following the current Documentation/security/LSM.txt? > What about the API with the NULL name (which is much simpler)? Initially I thought that the module name should never appear more than once, however I could see a module that would bracket another or another set, so capability,spiffy,selinux might be different behaviorally than capability,spiffy,selinux,spiffy and userspace might care. I still don't see any value in capability,selinux,spiffy,spiffy Passing a NULL name could lead to ambiguity if more than one module did that, so I can't say I approve. > > Regards, > Mickaël >