Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2818291imm; Mon, 24 Sep 2018 10:23:40 -0700 (PDT) X-Google-Smtp-Source: ACcGV63Ge4VGzXW5akWbwuebifoGFddAID70Wz4cwZA7kisXhX0+YmvGiYeotyJLZU0fX6pHxHQz X-Received: by 2002:a17:902:8681:: with SMTP id g1-v6mr11383946plo.302.1537809820261; Mon, 24 Sep 2018 10:23:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537809820; cv=none; d=google.com; s=arc-20160816; b=S3gDyVcQJbTs5mFAv5ZgNXbNc27AfqY4nMhuhMTguI4b2xVMaT6r7hwSJdtrPWLDe4 xd+ub18LeS4b+WOdWMT0fG4T0K2nuCHwnGgNgIdhmsp9KKP5VIOyeMFEip0mqcva13xA iNdlp+7SgbHTsjooaPtnnDpGQrprSNGlOMb6Vzuz+DUFXu60Y3x7PjsBdXOQ0fmDQenp dy1MJvOUOc5FMXXRDfWXtxqkNjCuZvZCjz3X58ztVephAcObE0LjlJDyBvEMjTUCO6aa yjCsNB7ELn+ibGpDMY5H+5PA8J0vUtktn92SZUZKUZbXFyJoT4MhIAYcbbnZOVn5A3Dd ji3g== 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=JYSuBZDrys78m6zD1bAG00BmsOZvIF1eZY8cMsVzDYE=; b=TWnLJ4mwCo53YkUEi0zyJXBpKgywC/BWGec6aq695dGpmMCP1pExLumnp8vdoy4cLD A1IgDGnkSv4UhBEKUywTz7juAgBGw45Yklw214Tq5vI60HOMD9sbeYCLJmMbv72ouVvC 1k1S03YjOcAv+Zoe6zgbJaPk+SnzJe39MCEHo8QK2VwrEGA5htpOS23zxsH9IvzZ+X4I QaFg8qOs38gDv2Q15xOIiXHxhklTFZ6c7LOk9c2d8HuYs992jETpeyR8JDDN5zpfsSlY v6Hv0RJ5Mk26KCo49CRaLyDAltisPR4vvd+Y2XjG5QOX2UWlVDzaw+6ToU/VWEUDuoFc rPxQ== 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 68-v6si36345281pff.55.2018.09.24.10.23.24; Mon, 24 Sep 2018 10:23:40 -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 S1730789AbeIXX0J (ORCPT + 99 others); Mon, 24 Sep 2018 19:26:09 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:41170 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726133AbeIXX0J (ORCPT ); Mon, 24 Sep 2018 19:26:09 -0400 Received: from fsav305.sakura.ne.jp (fsav305.sakura.ne.jp [153.120.85.136]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id w8OHMX41014899; Tue, 25 Sep 2018 02:22:33 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav305.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav305.sakura.ne.jp); Tue, 25 Sep 2018 02:22:33 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav305.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 w8OHMRwf014866 (version=TLSv1.2 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 25 Sep 2018 02:22:33 +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 , Stephen Smalley , Kees Cook Cc: LSM , James Morris , SE Linux , LKLM , John Johansen , Paul Moore , "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> <2a1ceb8c-0288-47ff-a763-d620e904b5b2@schaufler-ca.com> From: Tetsuo Handa Message-ID: Date: Tue, 25 Sep 2018 02:22:28 +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: <2a1ceb8c-0288-47ff-a763-d620e904b5b2@schaufler-ca.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/09/25 1:15, Casey Schaufler wrote: >>>>    Since all free hooks are called when one of init hooks failed, each >>>>    free hook needs to check whether init hook was called. An example is >>>>    inode_free_security() in security/selinux/hooks.c (but not addressed in >>>>    this patch). >>> >>> I *think* that selinux_inode_free_security() is safe in this >>> case because the blob will be zeroed, hence isec->list will >>> be NULL. >> >> That's not safe - look more closely at what list_empty_careful() tests, and then think about what happens when list_del_init() gets called on that isec->list.  selinux_inode_free_security() presumes that selinux_inode_alloc_security() has been called already.  If you are breaking that assumption, you have to fix it. > > Yup. I misread the macro my first time around. Easy fix. Oh, I didn't notice that it is doing !list_empty_careful() than list_empty_careful(). Unsafe indeed. But easy to fix. > >> Is there a reason you can't make inode_alloc_security() return void since you moved the allocation to the framework? > > No reason with any of the existing modules, But I could see someone > doing unnatural things during allocation that might result in a > failure. Currently upstreamed LSM modules and AKARI would be OK. But I can't guarantee it for future / not-yet-upstreamed LSM modules.