Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2847518imm; Mon, 24 Sep 2018 10:54:43 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdanz265wXszUqdj7BcnpGqeZl3VZFq22k/IfrlKvx60Gj5lbrr5UWLeq716KfghQBh+cwm1 X-Received: by 2002:a62:6547:: with SMTP id z68-v6mr11377492pfb.20.1537811683738; Mon, 24 Sep 2018 10:54:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537811683; cv=none; d=google.com; s=arc-20160816; b=ft2CXs2gdcV9zHj3kMpAKTBsLO8yuyEznLVMbKRW1C8ibxcJ2DT8XI0BjkjvoOZgAH 1oYZng5zQeXLIO/iEg9FCAclnkbDMnjFX0yczfbUnZu5uW1gOktLKwidpziX5l6iaExH v8I287Uxn03R+1UO+7alAPHLg/snHhZ2PP5++VO31JVYG2olA/uSuViln192sA7WgX1A ltY2802Ex6y2F44Nw1k56WD0PcazTSdHO/vVP/8JjeQop9vULt6h1IJoMxlIpuac9Q95 SpCgjXMyuUXGj8Xx08iauUQfPvqU2R1d3TMPllZOsm/fhbPmqCWCzLFXP8UtMUH1xooO 0pFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=VFyUGlp6FC8Kc7nb7WDN3b7hqngHNrAw1lNcSe0UHss=; b=do1AqbXbADmGEXHV8u+PxK5m/toUerdaJ3o0UqNrV7R0L5DP357XWPSr/SObOYABFr qsxpJwwWZZRt1BQkFW2e/UoNbc6IfE/K7sjuXXugWVIY3DwmjAS+0Ij0vKTEDd1ZcUNs +YmVufLjtUnnATvtPF7WNMO5dOcCbM0JBxTS0WSImEPwGmHYtgt58ulC2XOOymViZTjG 0gvXPyYJp3/0cU9vrFOiJRhwINF0gHatXPrLcuziJykqVhHZjyg+VYahQV3MZI/c3UGw BjTd8xkchrJlAoctl6w7j5fbgGbiUk3TezTB0/sWOX65K/lJPEZPk5V/0tLVtiffcVKV +6DQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s18-v6si11275457pgv.85.2018.09.24.10.54.27; Mon, 24 Sep 2018 10:54:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731546AbeIXX44 (ORCPT + 99 others); Mon, 24 Sep 2018 19:56:56 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:42373 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728999AbeIXX44 (ORCPT ); Mon, 24 Sep 2018 19:56:56 -0400 Received: from fsav109.sakura.ne.jp (fsav109.sakura.ne.jp [27.133.134.236]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id w8OHrCSC021129; Tue, 25 Sep 2018 02:53:12 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav109.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav109.sakura.ne.jp); Tue, 25 Sep 2018 02:53:12 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav109.sakura.ne.jp) Received: from [192.168.1.8] (softbank060157066051.bbtec.net [60.157.66.51]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id w8OHrC8t021126 (version=TLSv1.2 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 25 Sep 2018 02:53:12 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Subject: Re: [PATCH v4 00/19] LSM: Module stacking for SARA and Landlock To: Casey Schaufler , Kees Cook Cc: LSM , James Morris , SE Linux , LKLM , John Johansen , Paul Moore , Stephen Smalley , "linux-fsdevel@vger.kernel.org" , Alexey Dobriyan , =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= , Salvatore Mesoraca References: <680e6e16-0890-8304-0e8e-6c58966813b5@schaufler-ca.com> <39457e79-3816-824b-6b4d-89d21b03f9ce@i-love.sakura.ne.jp> <3350edec-c233-9428-73b0-58d582d1e3b9@schaufler-ca.com> From: Tetsuo Handa Message-ID: Date: Tue, 25 Sep 2018 02:53:12 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <3350edec-c233-9428-73b0-58d582d1e3b9@schaufler-ca.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/09/25 2:16, Casey Schaufler wrote: >> Not all of LKM-based LSMs use security blobs. And some of LKM-based LSMs >> might use security blobs for only a few objects. For example, AKARI uses >> inode security blob for remembering whether source address/port of an >> accept()ed socket was already checked, only during accept() operation and >> first socket operation on the accept()ed socket. Thus, there is no need >> to waste memory by assigning blobs for all inode objects. > > The first question is why use an inode blob? Shouldn't you > be using a socket blob for this socket based information? Indeed. AKARI can as well use security_sk_free() using address of "struct sock" as a key. > > If you only want information part of the time you can declare > a pointer sized blob and manage what hangs off that as you will. > I personally think that the added complexity of conditional > blob management is more pain than it's worth, but if you want > a really big blob, but only on occasion, I could see doing it. LKM based LSMs are too late for updating blob_sizes.* fields. Even if they could, they after all have to somehow check whether corresponding init hook was called. That's checking for NULL. >> >>>> @@ -1202,11 +1183,11 @@ void security_file_free(struct file *file) >>>> { >>>> void *blob; >>>> >>>> + call_void_hook(file_free_security, file); >>>> + >>>> if (!lsm_file_cache) >>>> return; >>>> >>>> - call_void_hook(file_free_security, file); >>>> - >>> Why does this make sense? If the lsm_file_cache isn't >>> initialized you can't have allocated any file blobs, >>> no module can have initialized a file blob, hence there >>> can be nothing for the module to do. >>> >> For modules (not limited to LKM-based LSMs) which want to use >> file blobs for only a few objects and avoid wasting memory by >> allocating file blobs to all file objects. >> >> Infrastructure based blob management fits well for LSM modules >> which want to assign blobs to all objects (like SELinux). But >> forcing infrastructure based blob management can become a huge >> waste of memory for LSM modules which want to assign blobs to >> only a few objects. Unconditionally calling file_free_security >> hook (as with other hooks) preserves a room for allowing the >> latter type of LSM modules without using infrastructure based >> blob management. > > There is a hypothetical issue here, but that would require abuse > of the infrastructure. Having a file_free_security hook that doesn't > free a security blob allocated by file_alloc_security may coincidentaly > be useful, but that's not the intent of the hook. > The free hook might be used for freeing resources which were not allocated by alloc hook. Yama is using task_free hook without task_alloc hook. Someone might want to use file_free hook without file_alloc hook.