Received: by 10.223.176.5 with SMTP id f5csp1102823wra; Wed, 31 Jan 2018 01:08:26 -0800 (PST) X-Google-Smtp-Source: AH8x226Sm0vCf5ga7U1jEtWr6UvZ4QJdmAZkOwfzjuSE8u9sbKiUUQ2pOB0ph+xcUo/AGMyqxNGN X-Received: by 10.98.82.68 with SMTP id g65mr33243161pfb.212.1517389706427; Wed, 31 Jan 2018 01:08:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517389706; cv=none; d=google.com; s=arc-20160816; b=Wavy4Ni2ZX8pnv5LBhGBJ2uFRXkbcmtZF/fbDejGPYV1Tnw0fzKJ1WVkOR/1/JI1FP HnsCrXM6jPnBWBTvT5hHYt7INFlTZiMlPkORfEwEUtnXwzf1JN5Egbl1O408p4hG7/3L ZnjgyuB75u12UgoRX3t0xxE0vkY7HfHhh+l31jDUjp8ULY0eyEqMxhy8ZovgEAAbYS2w n0hclXeIbDrhOyLbdHeH3+3eCPVZlMrzhiSOch+vcF35H0/HFF4pzG6Rw+tF+N+KIGJo AUDzNcHaspL07Ddt5/iyi1S6bEeZVC48/gU0P2huS68oxtKuJ2lVQxW82Pu/Tu4xV594 d4iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=cjruFehqYeYSYjzEHbOqSO2hcZgAUSj7Fpp6ULl1Zn8=; b=ecQv8XcL1ePjhXyOlTBtVCCoyVU+a90DW9pPg2NOZWiGTvfiTKLtRhospIzVr3bAs8 yrC6zfEqrxXCayEIVyhvyofjzMv8YKnSXg/K8zlAVA36iaE2R3lAiU1iB5cBFvYiA2zf i6/lgRlVU4oYyREMZ2y3e5SsBPp13S6qtbDSBh1UsJCXUUOb7qMW24+yJIHcZaDt4XL1 ZibUq7ZbTSYRUfnjYdvMCc+iw9SxkbpgOW6OBn2dPe9stzf5Hw1IYD8UNtZUQjvYeFx2 Zm9eDEECNJJO3ryBRDaKHWsD9bF7XDKimCB/2HCpHFZ9YaPPpLKnaE1iVI0ACPoS3WEL ESSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=VKOPkH4U; 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 q11si10782154pgc.617.2018.01.31.01.08.11; Wed, 31 Jan 2018 01:08:26 -0800 (PST) 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=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=VKOPkH4U; 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 S1752749AbeAaJG6 (ORCPT + 99 others); Wed, 31 Jan 2018 04:06:58 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:33399 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752407AbeAaJGj (ORCPT ); Wed, 31 Jan 2018 04:06:39 -0500 Received: by mail-lf0-f66.google.com with SMTP id t139so19561545lff.0 for ; Wed, 31 Jan 2018 01:06:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=cjruFehqYeYSYjzEHbOqSO2hcZgAUSj7Fpp6ULl1Zn8=; b=VKOPkH4Urb8g9YZJ9iYv9nec5XsddMJ/a7lcewGjZ2am9blqhn1oalWmY+x6l5XDK5 9mb7Qn7r+IwqpyGhytEKu85XBYuocrB4QF////NlM4gG4Dtenz5z9dr74BHV0XhEPI4H FHunYMIgfRXPF6gpl0vJde7Opdc/Q1289nOeeLWQzEO0o8b5QpcXqwWptpnuQx0Kf6Ye HQB6TGJAa+rn1tQKBcxFpmmW2dLx4acwbllX/xyEmt5qRyxEO7CQ/UOmmblUHVjF+aCR FjJBWK1IkP1jLmlc7gXPCbKCimxdl8SKJkZlKDHFAFfytm+tQ2VzjzfJ8gTC7OAclOwK WKKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=cjruFehqYeYSYjzEHbOqSO2hcZgAUSj7Fpp6ULl1Zn8=; b=e0yClCrr3WZy4XcASZBO+I2uoj5jTw0aOHqiRAzf/aNfcWEa/3WYrRT7HnL7qrGx52 lbC7/FppEHJbbtDWeV7yahj/d80T7q4KCsSJCrjA4JVUZAa6op+OfBf6ydUWnUYKaH7M S1i2tdAs42pQq2dT/9Xy+JhbEg3x+eyKSSTew6tJTdnu6MhjxybItdwRI7X3Zzauu3cq Vn6ydwtmpx3rJup42vl/E4Zdu8284Df02to2kwJ+q8W3hjEqY41d/InvvErPXai3akPR X3KxcQPGCn0tUvJyc69oGMf9CFX/X8gp7XlsLBJMdfxotwMa4Kk8VUNU1b0hXGdRAnMq GiQQ== X-Gm-Message-State: AKwxytfi+AxLQVpAFoPfIxdLHfMDNkPE6KmAH1FEWfyd3WI3P9YZUSon cZC3TiPmKLc94JOZJAZ/mh3nY5PCJlv5LUMJubnL X-Received: by 10.25.219.206 with SMTP id t75mr19521924lfi.125.1517389597862; Wed, 31 Jan 2018 01:06:37 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.216.145 with HTTP; Wed, 31 Jan 2018 01:06:37 -0800 (PST) X-Originating-IP: [193.43.158.243] In-Reply-To: <20180130224614.GA13647@kroah.com> References: <20180118215853.228182-1-salyzyn@android.com> <1516382386.2560.11.camel@tycho.nsa.gov> <1516383672.2560.23.camel@tycho.nsa.gov> <99c11fa6-ad9a-830c-467e-6a56e78aecf8@android.com> <20180130224614.GA13647@kroah.com> From: Paul Moore Date: Wed, 31 Jan 2018 04:06:37 -0500 Message-ID: Subject: Re: [PATCH] general protection fault in sock_has_perm To: Greg KH Cc: Mark Salyzyn , Stephen Smalley , linux-kernel@vger.kernel.org, Eric Paris , James Morris , "Serge E. Hallyn" , selinux@tycho.nsa.gov, linux-security-module@vger.kernel.org, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 30, 2018 at 5:46 PM, Greg KH wrote: > On Tue, Jan 30, 2018 at 11:00:04AM -0800, Mark Salyzyn wrote: >> 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; >> > > This looks sane to me as a simple 4.4-only fix. If the SELinux > maintainer acks it, I can easily queue this up. This revision addresses my concerns with Mark's previous patch. Acked-by: Paul Moore -- paul moore www.paul-moore.com