From patchwork Mon Jul 16 18:24:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Casey Schaufler X-Patchwork-Id: 10527509 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5B5C46037E for ; Mon, 16 Jul 2018 18:24:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DAF5219AC for ; Mon, 16 Jul 2018 18:24:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41B2D28795; Mon, 16 Jul 2018 18:24:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2A5B219AC for ; Mon, 16 Jul 2018 18:24:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728359AbeGPSwt (ORCPT ); Mon, 16 Jul 2018 14:52:49 -0400 Received: from sonic308-15.consmr.mail.gq1.yahoo.com ([98.137.68.39]:36775 "EHLO sonic308-15.consmr.mail.gq1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728437AbeGPSws (ORCPT ); Mon, 16 Jul 2018 14:52:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1531765451; bh=MoQJkYuFed509vjRUdFjjE1QBxKzlFFF1OeYh+kznCM=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b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346..FcyZo4QbbPe_Y XaQRQgEGj7iCW9xe0mEA_u8x_kzaDUiNOPrHNi6E1G9fej5vcjmlMrANCYAkyYBHNH_YNeaUkbiw iT9CUM6yka7BkwaQKZ24.kpYmM1Mhkfa_v.txNTYEf673RVy.9oo6URtHXfeMcaNj.61JaOzapex jjy3Q7j3S98.WkPxBPc71EudDZlMVQSDWY.Xhwl6TNk3qzU6wUtu1uKup8b.dCSAgBNa0WHC6NV4 894sQmpOxN2TOoctO7dGzCSDas9bpEstOnDsKWtZFgwuzY8bHTnN7WTG_aoMIB9Q6fGxNTfVgN1z z3DFrEakUJLOLN7tEa55dsIZntEaJZHQ- Received: from sonic.gate.mail.ne1.yahoo.com by sonic308.consmr.mail.gq1.yahoo.com with HTTP; Mon, 16 Jul 2018 18:24:11 +0000 Received: from c-67-169-65-224.hsd1.ca.comcast.net (EHLO [192.168.0.100]) ([67.169.65.224]) by smtp421.mail.gq1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 649367fcb4d1728d37eae30bfa4328e5; Mon, 16 Jul 2018 18:24:10 +0000 (UTC) Subject: [PATCH v1 15/22] LSM: Mark security blob allocation failures as unlikely To: LSM , LKLM , Paul Moore , Stephen Smalley , SE Linux , "SMACK-discuss@lists.01.org" , John Johansen , Kees Cook , Tetsuo Handa , James Morris Cc: "Schaufler, Casey" References: <8a325db8-e7eb-9581-2b77-fc987a165df7@schaufler-ca.com> From: Casey Schaufler Message-ID: Date: Mon, 16 Jul 2018 11:24:07 -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: <8a325db8-e7eb-9581-2b77-fc987a165df7@schaufler-ca.com> Content-Language: en-US Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP LSM: Mark security blob allocation failures as unlikely The allocation of security blobs is unlikely to fail. Mark the checks thus for performance reasons. Signed-off-by: Casey Schaufler --- security/security.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/security/security.c b/security/security.c index b95a151f7347..de5008d6715c 100644 --- a/security/security.c +++ b/security/security.c @@ -1245,7 +1245,7 @@ int security_file_alloc(struct file *file) { int rc = lsm_file_alloc(file); - if (rc) + if (unlikely(rc)) return rc; rc = call_int_hook(file_alloc_security, 0, file); if (unlikely(rc)) @@ -1368,7 +1368,7 @@ int security_task_alloc(struct task_struct *task, unsigned long clone_flags) { int rc = lsm_task_alloc(task); - if (rc) + if (unlikely(rc)) return rc; rc = call_int_hook(task_alloc, 0, task, clone_flags); if (unlikely(rc)) @@ -1388,7 +1388,7 @@ int security_cred_alloc_blank(struct cred *cred, gfp_t gfp) { int rc = lsm_cred_alloc(cred, gfp); - if (rc) + if (unlikely(rc)) return rc; rc = call_int_hook(cred_alloc_blank, 0, cred, gfp); @@ -1409,7 +1409,7 @@ int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp) { int rc = lsm_cred_alloc(new, gfp); - if (rc) + if (unlikely(rc)) return rc; rc = call_int_hook(cred_prepare, 0, new, old, gfp);