Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4597895pxb; Tue, 5 Oct 2021 06:33:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+XfAlsdPXfmRmJIufA15s594WX83IcZge4jR82Ifwf1NottpNYxsHll1FtZ9go8kqM/hW X-Received: by 2002:a17:90a:a513:: with SMTP id a19mr3958168pjq.26.1633440787118; Tue, 05 Oct 2021 06:33:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633440787; cv=none; d=google.com; s=arc-20160816; b=znDgOpYUV+ivTRP1F+3EqfdqGFrTHeWBqBTo+kLB0MW49IF0h00VN9r4tCI/6TqK1g 8VgC9TuqKlfLx+K1lid6Lub0yWSeopKS39nxVwGPIAkAeiqJWiv2ouwgqNEB1AZvVWnC UdMDuQ9Ao05PVKjR8U9/RV8f4Twp4EFRvI1NAl81voEIaXvwkmHI6RQQ294Zvjds666Z 50PvRUYFqZkMm76oRtLnLa3QRfu2oy6YzcHifJ3Z7/VB2UcrDF6Pjh6U/pq83HZJKnoG b5mA03XBYMLMsW105OmTgYMluS5OkCsNt/C4qW3BqEZrY5thsvxYktosSbWUKCzw7cer bxnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=w9BA+pG+7cScWQKkrwF9ICcTK0SeXthJ3lN5TsbRq+k=; b=Jz7fjhtRWyEzkHYHVURQZaIabcVNwx5ZMPV/jRKT6VbS0svPtOzaf2HxxGxpIbtHLf scULrK5a0RFOiZg9vg3O2vup0YnjXgHTVex2g4KeqVTUuag9GjlSj6GunL7ph92LwSbo JDhlPoi9gNdlITf5MDkUXwtwU5buq83/6mhN7TxHnE3B1c5tRqLzmLzDohjujsshk5f7 Rpqf3RtR8M2/UI8WNEuQbaUyXDSlJmDfIjxN2mH1EJlHzaq/GTxe6X/Oe1dBNkbwMf6I Jy42DYX/ImRnHxAtru/ESpgm9sURlc0kz5vY89RXvWItBrPN+HqlY1iCtZS2IUALUddT vMtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=C4p+2jhE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x71si7069607pgd.428.2021.10.05.06.32.51; Tue, 05 Oct 2021 06:33:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=C4p+2jhE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235020AbhJENcy (ORCPT + 99 others); Tue, 5 Oct 2021 09:32:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:52192 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235045AbhJENcx (ORCPT ); Tue, 5 Oct 2021 09:32:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A1BBA61401; Tue, 5 Oct 2021 13:31:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633440663; bh=fGNf6lFeNsKzE8dzg3ltef34M0dC0Pd10/yR6RlZFFU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=C4p+2jhEnb9QTBRus6fMLknmLkI38NEKt2yByvrsNiCUNH08YlVW5pstXr8CFLe/v qMAE/705Qs9RDN0P5G5BxbUt+dYHQF+FsSixW1Da/0AFM0ndmFjVF0+zf/tuMa3OMz JcE6MJgWVJma8Orz7xXBkgzJLuzmxs84Ps8xyWuc= Date: Tue, 5 Oct 2021 15:31:00 +0200 From: Greg KH To: Todd Kjos Cc: arve@android.com, tkjos@android.com, maco@android.com, christian@brauner.io, jmorris@namei.org, serge@hallyn.com, paul@paul-moore.com, stephen.smalley.work@gmail.com, eparis@parisplace.org, keescook@chromium.org, jannh@google.com, jeffv@google.com, zohar@linux.ibm.com, linux-security-module@vger.kernel.org, selinux@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, joel@joelfernandes.org, kernel-team@android.com, stable@vger.kernel.org Subject: Re: [PATCH v2] binder: use cred instead of task for selinux checks Message-ID: References: <20211001175521.3853257-1-tkjos@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211001175521.3853257-1-tkjos@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 01, 2021 at 10:55:21AM -0700, Todd Kjos wrote: > Save the struct cred associated with a binder process > at initial open to avoid potential race conditions > when converting to a security ID. > > Since binder was integrated with selinux, it has passed > 'struct task_struct' associated with the binder_proc > to represent the source and target of transactions. > The conversion of task to SID was then done in the hook > implementations. It turns out that there are race conditions > which can result in an incorrect security context being used. > > Fix by saving the 'struct cred' during binder_open and pass > it to the selinux subsystem. > > Fixes: 79af73079d75 ("Add security hooks to binder and implement the > hooks for SELinux.") > Signed-off-by: Todd Kjos > Cc: stable@vger.kernel.org # 5.14+ (need backport for earlier stables) > --- > v2: updated comments as suggested by Paul Moore > > drivers/android/binder.c | 14 +++++---- > drivers/android/binder_internal.h | 4 +++ > include/linux/lsm_hook_defs.h | 14 ++++----- > include/linux/lsm_hooks.h | 14 ++++----- > include/linux/security.h | 28 +++++++++--------- > security/security.c | 14 ++++----- > security/selinux/hooks.c | 48 +++++++++---------------------- > 7 files changed, 60 insertions(+), 76 deletions(-) Ideally I could get an ack from the security developers before taking this in my tree... thanks, greg k-h