From patchwork Wed May 31 15:53:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Casey Schaufler X-Patchwork-Id: 9757489 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 4BC7E60390 for ; Wed, 31 May 2017 15:53:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F994269E2 for ; Wed, 31 May 2017 15:53:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34711284C3; Wed, 31 May 2017 15:53:58 +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 4F554284BF for ; Wed, 31 May 2017 15:53:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751096AbdEaPxq (ORCPT ); Wed, 31 May 2017 11:53:46 -0400 Received: from nm19-vm5.bullet.mail.ne1.yahoo.com ([98.138.91.241]:53728 "EHLO nm19-vm5.bullet.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751024AbdEaPxp (ORCPT ); Wed, 31 May 2017 11:53:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1496246024; bh=Y2gPbGqRSq6Ja6LwB3X3sAy0pF8RY5tUZaa9sjKu2JE=; h=To:Cc:From:Subject:Date:From:Subject; b=kLlMag262R9Oz6owTXSJo+M34pSkGxsbJxDhiktyVzSUmEqyQhhm8MITCrowcUOdgtF9bX/zWlyo5sSinaS+1QQ7Ap+MdFPYL16UnM4OzK7ApMENI4YzMh1TayVzqhSX9PUdKR3IAAYnA8FivvPLk2x232qodXZRY9j+xED3OK0EWPHa7FAcr242NWfvlz187FdhG8ijS4GRDG+LGFhWNH90WQf6XmXopArw1vUavi2bf51epJf8vD4eGM83OKTlkgt4wn+s+xE3caK+3dOl6FwRA487y6xhd5uOvUIZuXU1mHHMfcfyFQ+qLGDXAG5bYTyFegNwECS/yhlovGGXdg== Received: from [98.138.226.179] by nm19.bullet.mail.ne1.yahoo.com with NNFMP; 31 May 2017 15:53:44 -0000 Received: from [98.138.226.131] by tm14.bullet.mail.ne1.yahoo.com with NNFMP; 31 May 2017 15:53:44 -0000 Received: from [127.0.0.1] by smtp218.mail.ne1.yahoo.com with NNFMP; 31 May 2017 15:53:44 -0000 X-Yahoo-Newman-Id: 535330.8249.bm@smtp218.mail.ne1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: ktvotsoVM1mObnbk9tvkwt.zZJiBNEIDqzbP2f1TH1.nKGA 2NIIqVmmvPP2X50OJe7TOTJGvcm8kYlzJsxgDR_Ia1x7_eg6IxErHytNPZSV _x4t6ItR8bjDYTknYznFRJShOfDaHDc56V.ybiln7LGqa.2hgQSrj7GWZ4uZ dAmGrPQeRfDB6FOPqClbvzQmLloDrFkcPkCZmB1RYTkhkFczLUbR0Aadd5z1 cEuJjnUyH_wZSDzEsuRl7FhrvQopdT4TRL9daZDDn.36djcwaxabM1fi3jsU 3hv87YGXHcvOwgpKl4FTIG42M66ZTbnO7dKvUoT6_2PG5ZRvv9Ud0jB9uQxw RwF9AyKj5t_Gvs8CzOCPBCFYyj7FFfMVqRPXdpIr.l._Y3pAeWo65zNaqrAA gNfkYbn1w7XlaUjXa9lyTOZ2Sd4OLPhriMFMDFyZ10NbRuwrDUs3VOqCd0rn gkNYQzPFTgMb5i.cPqybADUuGNThJ48.MI8h1EnazVLXKwReJp0jzkAw5483 G4azHpO0axA5dgSzjj1eCXX3hlqXE2JBfCkv57ZlT4BNMKu3cxSz0gpxqN1F 73Um.hsaUHv1S2w-- X-Yahoo-SMTP: OIJXglSswBDfgLtXluJ6wiAYv6_cnw-- To: LSM , "SMACK-discuss@lists.01.org" Cc: Casey Schaufler From: Casey Schaufler Subject: [PATCH] Smack: Safer check for a socket in file_receive Message-ID: <36cefa8b-3441-91b4-1f8c-51c4d7004141@schaufler-ca.com> Date: Wed, 31 May 2017 08:53:42 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 Content-Language: en-US Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Subject: [PATCH] Smack: Safer check for a socket in file_receive The check of S_ISSOCK() in smack_file_receive() is not appropriate if the passed descriptor is a socket. Reported-by: Stephen Smalley Signed-off-by: Casey Schaufler --- security/smack/smack_lsm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index 658f5d8..463af86 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -1915,7 +1915,7 @@ static int smack_file_receive(struct file *file) smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH); smk_ad_setfield_u_fs_path(&ad, file->f_path); - if (S_ISSOCK(inode->i_mode)) { + if (inode->i_sb->s_magic == SOCKFS_MAGIC) { sock = SOCKET_I(inode); ssp = sock->sk->sk_security; tsp = current_security();