Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1275303imm; Wed, 26 Sep 2018 14:57:44 -0700 (PDT) X-Google-Smtp-Source: ACcGV61ybJCbdJDhPb95xrbo0s5GyLGfPD13LcgnLwKB3HpocPGnEXi3tyQnorUJI7yG7ckTQY6e X-Received: by 2002:a63:920b:: with SMTP id o11-v6mr2582444pgd.141.1537999064306; Wed, 26 Sep 2018 14:57:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537999064; cv=none; d=google.com; s=arc-20160816; b=owZ1h2DSjowmmStZEvleK1BbuaLgzqIf2UgWOFcToyguJbPsvQWIxbtC7JGtbqE81B AJy93e8wtO5F50gC0oN8l7jDW1PdwNtpt24VMBx4XtdlaynY8N+FZKvCHufw1+y4kbP1 R8r+I7T8r0xIUFZln1BbB9uvLe75psQBpOElPLuXZxaMZbyn6UNIhBpkZuT18u8tTkzY r8KBkSnKpENFyhEU5BhOJpHmjJ4ypKbqUZ7jWGvyzLC2B7nh+379Aj13/CZm7HviSH6G 8s8jancWmAOlX2x0WgzCqeh3i7uQTWld2pORXLc5VcZxyet40rBoJvZuheek+tjiMtf6 K6pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:dkim-signature; bh=buh1wpgQyK9cadodumxz/6f8+58oQVM1eQS5F4Ot6M0=; b=h8n2/kIDllgkO/XnoQnDgb2/+Moz/vaHK0UDHHE3zfvV53HmBZaAe5kOAtyodT5cAZ 7Sfbl4wujUHMIIjPcF2eKs1jWMucp2B+HDpEC1lTRAdcSpaoDesqVp4Ndyy97pQcgVYN Ih9o/MQrgvHU1g5iCrIf0o8UJiNUCEaCnDXVIqrRDvrAKXdmevGgreFj5jlt5O6WHkiW Jg1q2xz9coSVH0p2UE4rivfoe6nfQEnTUF9tbOaDjlzg4V7Ggazn4ZweIObVqaoZaxRZ S+nYzPMTU3yGJfbiB3udaXf3ehPP5/Ihb/3VXJUBejel4R33+Ulfs8HEuhF19WqXWSkt Gedw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=QsS66B0L; 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 q16-v6si155357pgn.86.2018.09.26.14.57.29; Wed, 26 Sep 2018 14:57:44 -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; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=QsS66B0L; 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 S1726549AbeI0EMJ (ORCPT + 99 others); Thu, 27 Sep 2018 00:12:09 -0400 Received: from sonic312-28.consmr.mail.gq1.yahoo.com ([98.137.69.209]:42621 "EHLO sonic312-28.consmr.mail.gq1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726084AbeI0EMJ (ORCPT ); Thu, 27 Sep 2018 00:12:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1537999027; bh=buh1wpgQyK9cadodumxz/6f8+58oQVM1eQS5F4Ot6M0=; h=Subject:To:References:From:Date:In-Reply-To:From:Subject; b=QsS66B0L4Jvj1dy8nFXjffJJksY8EfDFVKufc5E6lq4OWjAGRfUWVyFPjmmZXn3nz9dKgiI07+HuZjSPY5o1vPgrkbJptytNw2adlJzjG9luZkssAwNljIhdHt/L03MSR/VgzZ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4ebFYyVB10he05GrHnUMTHCUuRWRkijQL3A8MPPoHMLhuX8DZoA7R_GGIF2 bUeL.lOe_1GjzuP_mwNGpaweAC72MTct4dtprEzm.5miBDrVDLqTXN0vRDdl6kJsg0RY0ZPexw5b LjJkxyHyzNywr7LmVSrUQt1SRhcXodUTWiWj_Bq7bcpbxNJQPVqAQFW8nec2oi2OOPb3CviRYPh_ o5w2K3BJwX4eID9096sGJX2bTEda6TaQMJbM- Received: from sonic.gate.mail.ne1.yahoo.com by sonic312.consmr.mail.gq1.yahoo.com with HTTP; Wed, 26 Sep 2018 21:57:07 +0000 Received: from c-67-169-65-224.hsd1.ca.comcast.net (EHLO [192.168.0.102]) ([67.169.65.224]) by smtp401.mail.gq1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 328016718fb28565db579b7bd63a67d4; Wed, 26 Sep 2018 21:57:03 +0000 (UTC) Subject: [PATCH v4 20/19] LSM: Correct file blob free empty blob check To: LSM , James Morris , SE Linux , LKLM , John Johansen , Kees Cook , Tetsuo Handa , Paul Moore , Stephen Smalley , "linux-fsdevel@vger.kernel.org" , Alexey Dobriyan , =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= , Salvatore Mesoraca References: From: Casey Schaufler Message-ID: <44210861-2830-2321-911d-8783f5f0b172@schaufler-ca.com> Date: Wed, 26 Sep 2018 14:57:03 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of checking if the kmem_cache for file blobs has been initialized check if the blob is NULL. This allows non-blob using modules to do other kinds of clean up in the security_file_free hooks. Signed-off-by: Casey Schaufler --- security/security.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/security/security.c b/security/security.c index e7c8506041f1..76f7dc49b63c 100644 --- a/security/security.c +++ b/security/security.c @@ -1202,14 +1202,13 @@ void security_file_free(struct file *file) { void *blob; - if (!lsm_file_cache) - return; - call_void_hook(file_free_security, file); blob = file->f_security; - file->f_security = NULL; - kmem_cache_free(lsm_file_cache, blob); + if (blob) { + file->f_security = NULL; + kmem_cache_free(lsm_file_cache, blob); + } } int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) -- 2.17.1