From patchwork Thu Feb 28 22:18:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Casey Schaufler X-Patchwork-Id: 10833867 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B3B0517EF for ; Thu, 28 Feb 2019 22:20:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A00D02F323 for ; Thu, 28 Feb 2019 22:20:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E6422F245; Thu, 28 Feb 2019 22:20:02 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI 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 4EA832F3CC for ; Thu, 28 Feb 2019 22:20:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727920AbfB1WT7 (ORCPT ); Thu, 28 Feb 2019 17:19:59 -0500 Received: from sonic309-27.consmr.mail.gq1.yahoo.com ([98.137.65.153]:40678 "EHLO sonic309-27.consmr.mail.gq1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729478AbfB1WT4 (ORCPT ); Thu, 28 Feb 2019 17:19:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1551392395; bh=vscZ9YAV9EYGaY9d6eksjc998gZocceOZ6hh36Ogb+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject; b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K7UURxKXqxF3mV.mPisXOWCDfIk VUQsQ4h6bwPQek3A.9Rt4TOXSUCrqixRMQDH_92X8F8E9FBV9cjDKXytE719Awp98MJ4m_Gek7oc MM4BORzYnH3NHidyde.EOCXRz7w1bhvzPS1s2FMPTlEdngxNLVzSjelZ7sbGHvNwHm09cRjtyqZC 6LEDFIun52sDU2T_xIAfwBuCpcaUpOtNO7B.CL7Tzlk3oINRN7Pgxf6PauYYbMaZziVDAjrgnWIl ZoyG0UzMk1i07eV4rfGN3AqOU4QBDkSlU2EEiNC1mrKWOMaizLwQEnnKYk2KuG4GHANSfylYa5N8 olcwN3z36_hwOaWNxcFXASUjt87dzOT6XbdsXOsISDk6Om78qbWVP0kb_v0KWzgIzo2eVCqAs98v _IsvnKX7JfrC5YD9RVJdkofEnjJHswz_yIu3wSvuXFAFCFg-- Received: from sonic.gate.mail.ne1.yahoo.com by sonic309.consmr.mail.gq1.yahoo.com with HTTP; Thu, 28 Feb 2019 22:19:55 +0000 Received: from c-67-169-65-224.hsd1.ca.comcast.net (EHLO localhost.localdomain) ([67.169.65.224]) by smtp427.mail.gq1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 0da9962b364e649f4905df2b440bd211; Thu, 28 Feb 2019 22:19:51 +0000 (UTC) From: Casey Schaufler To: jmorris@namei.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org Cc: keescook@chromium.org, john.johansen@canonical.com, penguin-kernel@i-love.sakura.ne.jp, paul@paul-moore.com Subject: [PATCH 14/97] LSM: Fix logical operation in lsm_export checks Date: Thu, 28 Feb 2019 14:18:10 -0800 Message-Id: <20190228221933.2551-15-casey@schaufler-ca.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190228221933.2551-1-casey@schaufler-ca.com> References: <20190228221933.2551-1-casey@schaufler-ca.com> Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Fix the logic in Smack and SELinux when checking to see if the secid is included. Signed-off-by: Casey Schaufler --- security/selinux/include/objsec.h | 2 +- security/smack/smack_lsm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/security/selinux/include/objsec.h b/security/selinux/include/objsec.h index d7efc5f23c1e..59a3b1cd5ba9 100644 --- a/security/selinux/include/objsec.h +++ b/security/selinux/include/objsec.h @@ -61,7 +61,7 @@ static inline void selinux_export_secid(struct lsm_export *l, u32 secid) static inline void selinux_import_secid(struct lsm_export *l, u32 *secid) { - if (l->flags | LSM_EXPORT_SELINUX) + if (l->flags & LSM_EXPORT_SELINUX) *secid = l->selinux; else *secid = SECSID_NULL; diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index d26a5e77a92c..a1a9fdd3f1c7 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -475,7 +475,7 @@ static inline void smack_export_secid(struct lsm_export *l, u32 secid) static inline void smack_import_secid(struct lsm_export *l, u32 *secid) { - if (l->flags | LSM_EXPORT_SMACK) + if (l->flags & LSM_EXPORT_SMACK) *secid = l->smack; else *secid = 0;