From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755550AbdEHTZU (ORCPT ); Mon, 8 May 2017 15:25:20 -0400 Received: from smtp-sh2.infomaniak.ch ([128.65.195.6]:47628 "EHLO smtp-sh2.infomaniak.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752364AbdEHTZS (ORCPT ); Mon, 8 May 2017 15:25:18 -0400 From: =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= Subject: Re: [PATCH v1] LSM: Enable multiple calls to security_add_hooks() for the same LSM To: James Morris , Casey Schaufler , 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 Message-ID: Date: Mon, 8 May 2017 21:24:38 +0200 User-Agent: MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="2LEElgJagDoa2WoaGgtHI1sCfD3eWpBTt" X-Antivirus: Dr.Web (R) for Unix mail servers drweb plugin ver.6.0.2.8 X-Antivirus-Code: 0x100000 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --2LEElgJagDoa2WoaGgtHI1sCfD3eWpBTt Content-Type: multipart/mixed; boundary="nV3Q79X9uDoHqp3kkSQOu5SowSxhMbScQ"; protected-headers="v1" From: =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= To: James Morris , Casey Schaufler , Tetsuo Handa Cc: linux-kernel@vger.kernel.org, James Morris , Kees Cook , "Serge E . Hallyn" , linux-security-module@vger.kernel.org Message-ID: Subject: Re: [PATCH v1] LSM: Enable multiple calls to security_add_hooks() for the same LSM References: <20170429190257.27137-1-mic@digikod.net> In-Reply-To: --nV3Q79X9uDoHqp3kkSQOu5SowSxhMbScQ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 01/05/2017 01:28, James Morris wrote: > On Sat, 29 Apr 2017, Micka=C3=ABl Sala=C3=BCn wrote: >=20 >> Check if the registering LSM already registered hooks just before. Thi= s >> 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"). >=20 > Please include a detailed rationale for these patches. The above tells= us=20 > 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)? Regards, Micka=C3=ABl --nV3Q79X9uDoHqp3kkSQOu5SowSxhMbScQ-- --2LEElgJagDoa2WoaGgtHI1sCfD3eWpBTt Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEUysCyY8er9Axt7hqIt7+33O9apUFAlkQxfYACgkQIt7+33O9 apXs+QgAnHhylpTkikOt1YCIGbYlhSmv6WZU5BmQsiGj+wxD2OBY0HXj1aN9b6VJ /dcVLs5hYZ3P0OLHrO0kId1Ji1S36ZlKkYw0eRcMCVwSRzXY0CV/jvgcu+k4OZGC QkVj5jL5nbP7qlQo/LfGTiiDKnemvR/jWIXHRNmifbgdhyGrWk4WVhOLPL0ZUYDC vtu6YAEvyK3gg64K0ENhpk9ykNpmkn9ngEOXyAnam+5SBB3Mz5cUn6lfX1feq6Dm dWj1/ZhHEa6qxeQU/u9dEb0SZZDA8tHN7csOzaEWqRpLEsL9VHnUcjfNMyiyWQ/d njugdf+qttV7JddIoNC+YSXHXxj69g== =36Bk -----END PGP SIGNATURE----- --2LEElgJagDoa2WoaGgtHI1sCfD3eWpBTt--