From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-2731802-1517338812-2-11854852908349637719 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.001, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES en, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='US', FromHeader='com', MailFrom='org' X-Spam-charsets: plain='utf-8' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1517338811; b=VUmAApJH73xsuZZC+J+/8EnpBstvIiyybY/DtcJ4Q9rtk+h VZ9nUgmfJqYV14tmW8Af+m6iG5sqo1QXtowwbPrujzg0Ks6PEJDnkxjBBrxubCNj FjoPqGmc1TSeJKmi1xrZdjceoCY1ptMRW9H+u5jINhCCyCoTjI1hw9a5i+vLwhN7 /FEqUt1/YyYhlMXNPjer1YWhEVKIt5f3etQkK3iPMA47Zi6MtIbQ9gK868DPIZNT VHYppRoQgaXSTC19n3mkhcKg40HQHzRiz9u2epx/QIqliJU+xEVP7Y4J6Bv8UAqe hUijUXofU0ewu9OP5ykfxPiXnw74KTt7llg8Gxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=subject:to:cc:references:from:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding:sender:list-id; s=arctest; t= 1517338811; bh=fkLShHbfTfPvkkqRE8iukr+eFugi2dXgm1/xPNpHeXM=; b=P D624tIgE7xqadw/mGOkv2BO4/fT1Pgu5wWhlyiHFjISK/KGQmaZl+1/mjNOAfIYp G+keD1LPXkNcyJjgx14yoAAlGhbYFU541Wz+uQxzoq8apxvurnCZB2w2v7148buw /QMcTpkPx5YX+h9TmBhlSTVJof4MfbTdjPoyvJiXqzYcesqfoaEMh402S+z9f00W PT5j/ljXnqoCwGIBW71SRi7T85uDwb+UUft1cMVHOtjn9+g0AKTaosZ0ChO50ngn VTPgXLUhZBWcv0POJ7SWIKr0XUT1cl035EimH4uWWAaUhC7Zg6UC2qW9U4tr06qj J1g5V7J4X6ziL98nAjswA== ARC-Authentication-Results: i=1; mx1.messagingengine.com; arc=none (no signatures found); dkim=pass (2048-bit rsa key sha256) header.d=android.com header.i=@android.com header.b=iRNt0hML x-bits=2048 x-keytype=rsa x-algorithm=sha256 x-selector=20161025; dmarc=pass (p=none,has-list-id=yes,d=none) header.from=android.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-google-dkim=pass (2048-bit rsa key) header.d=1e100.net header.i=@1e100.net header.b=DBYV5yvt; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=android.com header.result=pass header_is_org_domain=yes Authentication-Results: mx1.messagingengine.com; arc=none (no signatures found); dkim=pass (2048-bit rsa key sha256) header.d=android.com header.i=@android.com header.b=iRNt0hML x-bits=2048 x-keytype=rsa x-algorithm=sha256 x-selector=20161025; dmarc=pass (p=none,has-list-id=yes,d=none) header.from=android.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-google-dkim=pass (2048-bit rsa key) header.d=1e100.net header.i=@1e100.net header.b=DBYV5yvt; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=android.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752216AbeA3TAI (ORCPT ); Tue, 30 Jan 2018 14:00:08 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:35109 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752185AbeA3TAH (ORCPT ); Tue, 30 Jan 2018 14:00:07 -0500 X-Google-Smtp-Source: AH8x225pUKdb4mUlu2qmYyWaVddDN0Nvo1CK64vUKAucT/eKNvAf7tQJpQLsv1t/lucpaeyTxK1/4Q== Subject: Re: [PATCH] general protection fault in sock_has_perm To: Stephen Smalley , linux-kernel@vger.kernel.org Cc: Paul Moore , Eric Paris , James Morris , "Serge E. Hallyn" , selinux@tycho.nsa.gov, linux-security-module@vger.kernel.org, stable@vger.kernel.org References: <20180118215853.228182-1-salyzyn@android.com> <1516382386.2560.11.camel@tycho.nsa.gov> <1516383672.2560.23.camel@tycho.nsa.gov> From: Mark Salyzyn Message-ID: <99c11fa6-ad9a-830c-467e-6a56e78aecf8@android.com> Date: Tue, 30 Jan 2018 11:00:04 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <1516383672.2560.23.camel@tycho.nsa.gov> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: On 01/19/2018 09:41 AM, Stephen Smalley wrote: > If we can't safely dereference the sock in these hooks, then that seems > to point back to the approach used in my original code, where in > ancient history I had sock_has_perm() take the socket and use its inode > i_security field instead of the sock. commit > 253bfae6e0ad97554799affa0266052968a45808 switched them to use the sock > instead. Because of the nature of this problem (hard to duplicate, no clear path), I am understandably not comfortable reverting and submitting for testing in order to prove this point. It is disruptive because it changes several subroutine call signatures. AFAIK this looks like a user request racing in without reference counting or RCU grace period in the callers (could be viewed as not an issue with security code). Effectively fixed in 4.9-stable, but broken in 4.4-stable. hygiene, KISS and small, is all I do feel comfortable to submit to 4.4-stable without pulling in all the infrastructure improvements. -- Mark ---  security/selinux/hooks.c | 2 ++  1 file changed, 2 insertions(+) diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 34427384605d..be68992a28cb 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -4066,6 +4066,8 @@ static int sock_has_perm(struct task_struct *task, struct sock *sk, u32 perms)      struct lsm_network_audit net = {0,};      u32 tsid = task_sid(task); +    if (!sksec) +        return -EFAULT;      if (sksec->sid == SECINITSID_KERNEL)          return 0; From mboxrd@z Thu Jan 1 00:00:00 1970 From: salyzyn@android.com (Mark Salyzyn) Date: Tue, 30 Jan 2018 11:00:04 -0800 Subject: [PATCH] general protection fault in sock_has_perm In-Reply-To: <1516383672.2560.23.camel@tycho.nsa.gov> References: <20180118215853.228182-1-salyzyn@android.com> <1516382386.2560.11.camel@tycho.nsa.gov> <1516383672.2560.23.camel@tycho.nsa.gov> Message-ID: <99c11fa6-ad9a-830c-467e-6a56e78aecf8@android.com> To: linux-security-module@vger.kernel.org List-Id: linux-security-module.vger.kernel.org On 01/19/2018 09:41 AM, Stephen Smalley wrote: > If we can't safely dereference the sock in these hooks, then that seems > to point back to the approach used in my original code, where in > ancient history I had sock_has_perm() take the socket and use its inode > i_security field instead of the sock. commit > 253bfae6e0ad97554799affa0266052968a45808 switched them to use the sock > instead. Because of the nature of this problem (hard to duplicate, no clear path), I am understandably not comfortable reverting and submitting for testing in order to prove this point. It is disruptive because it changes several subroutine call signatures. AFAIK this looks like a user request racing in without reference counting or RCU grace period in the callers (could be viewed as not an issue with security code). Effectively fixed in 4.9-stable, but broken in 4.4-stable. hygiene, KISS and small, is all I do feel comfortable to submit to 4.4-stable without pulling in all the infrastructure improvements. -- Mark --- ?security/selinux/hooks.c | 2 ++ ?1 file changed, 2 insertions(+) diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 34427384605d..be68992a28cb 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -4066,6 +4066,8 @@ static int sock_has_perm(struct task_struct *task, struct sock *sk, u32 perms) ???? struct lsm_network_audit net = {0,}; ???? u32 tsid = task_sid(task); +??? if (!sksec) +??? ??? return -EFAULT; ???? if (sksec->sid == SECINITSID_KERNEL) ???? ??? return 0; -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html