Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4627563pxb; Tue, 5 Oct 2021 07:08:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjbodtnY8SfUODHxFcUs46Mvx/rfRB/ju/f3nO6UCpxSjR3FFKrlTelwrVEzt/llzjPMXp X-Received: by 2002:a17:906:32d6:: with SMTP id k22mr24990385ejk.228.1633442889384; Tue, 05 Oct 2021 07:08:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633442889; cv=none; d=google.com; s=arc-20160816; b=l53x1hTo9pWveGwTzWiczM95Pl87GPURWwT5eFxaKrarMYlcBVnnG5/tv1GZN1eUlP qoS8GtXLnmB456jfWkjS/ZFVu+1ZaUxl0Ruse59fMlZD7ZEGBFHCZapV6K/Yr7MesFwf 7FatRELQSicJgzcXQbC8TllqbOSdjgQqaVZY/GAA48ssiFZviCI/H7vDYv3w5TC6lPbV EDaONHEh/BWgvczt7UA1IUw5cCIKvAzZERUVJjLyle9WSyu2rR5UOni/gVzQajmSayuH 6EJG30wDvKdSG0tdcxjAurMDUw91ge4JDtvqpcfiU5r9PdkrUiS6tADiz4QH58dZbmct cjEw== 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=1DlFL4R3bYWuRvyWOrOTxhjoiIjoMZdFv5TNEXp+kg8=; b=nb9wUng5eZ02NkHUK9ccs+xV7t9aKNrovVcfmxrnPZg7sqMeBEz46AALiS9QsPPEHS IORlOgVL46AzTt6CpmberW1MPHimGb8pbMvG9GYl/bnnwooojdtIa/oBZ1OtIDrK54xz aM9GN00GqjdV1vFSGPKS9lyXjkxeyjPJRz/6tS3zIQ60GBCL5W0E1HLOKsR5k4M545fQ K8GWdzPbDD2cJIoOS0yAlVTavTeb1wQxUwGMNm3VmHn6voN0SKWGNUDkFeLryx2BYsov zpuCrxJv/g7Dgazs4vUFu3n68YsizBlBWxIzKUFEnCMB7QE3vY97Mkxs8WICBYlyoxK7 CBmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=F6TnW11m; 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 a1si21155769edx.506.2021.10.05.07.07.38; Tue, 05 Oct 2021 07:08:09 -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=F6TnW11m; 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 S235519AbhJEOHN (ORCPT + 99 others); Tue, 5 Oct 2021 10:07:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:43574 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235482AbhJEOHK (ORCPT ); Tue, 5 Oct 2021 10:07:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1273A611C0; Tue, 5 Oct 2021 14:05:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633442719; bh=4dCsX/rNf/kYedDGRShwnxsvQ8FZ+zSZBJSVcIJ/3O8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=F6TnW11mlYLD0BcyGkp1owBjC5xVwmDX30sE4HvZ+c+VgyTgMpuU7PXktN2cx9B0j GqdeTc4CKlj+e0A0XGMBs75l+qyO1ybDMK7Tmjf0GS4AIlaoo9DneE7zg6bR1PvyTe jXR1A/tPJA8SByxxjPe4MCLq5IL5JtSR11uyilSs= Date: Tue, 5 Oct 2021 16:05:17 +0200 From: Greg KH To: Paul Moore Cc: Todd Kjos , arve@android.com, tkjos@android.com, maco@android.com, christian@brauner.io, James Morris , Serge Hallyn , Stephen Smalley , Eric Paris , keescook@chromium.org, jannh@google.com, Jeffrey Vander Stoep , 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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 05, 2021 at 09:53:31AM -0400, Paul Moore wrote: > On Tue, Oct 5, 2021 at 9:31 AM Greg KH wrote: > > 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... > > This should probably go in via one of the security trees, e.g. SELinux > or LSM, rather than the binder/driver tree. Fine with me, take it away! Acked-by: Greg Kroah-Hartman