Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2612160pxb; Tue, 12 Oct 2021 09:55:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDKYZl3qyXelLiJ9IEMYh2Yg7Uz+NYNh4gZ0ElfG6y6/Wl75qS7PxOJJKyP8GTBUQHbZMU X-Received: by 2002:a05:6402:190e:: with SMTP id e14mr1270229edz.20.1634057707051; Tue, 12 Oct 2021 09:55:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634057707; cv=none; d=google.com; s=arc-20160816; b=yCS4vr8Bs+JYPAqHDwgPUSL8DpDGr5GLh9oKb+dkjZ7bL01cyBwsQHQtSzZ1jF6vwj vvAA1NVhBDKhPfoZ5QemLnQF4Avzmjo7KmG9BUxQUGT9iBUK/wilowaOeNXUs3OJBAWL R7ly6lXyqUwPEdqmgsXE+CuLCLYb8Wj1CxlbmpdcO7OyPSY/yvuoTDKSM8CuCHJUt/9N b0cOBICjS+YmALZ3Ii9iVjqMdGiS++bwQH+pVqXDtDh+d7tpRaygtsRCJ5hj57hXWEVj 9XBFqRcuctncQSG8LpdEUTg7E35x6EHx8160HKVUnrm0i3HJCEnasYULrcnfVb1Bngt4 xIUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=xawnIR012Yk1jlMpJVQsdMc2RuzZeUTjtaZq6SPv/vQ=; b=ik/HgSi/KFeJALH1TA7XUiIb+48DsljNhmcYOPdQlqTRL1oIrLoSfUWGWCs//rIrnU FY8o4fpUd71lWOPxNgFhzD3bv9sSsxqfq75AWbDdRAw9W80NpDzaGBSaI3c3XLCPKyRo VKvvJVXa/CJUVHwsopLaQgdvWbz9OlB6ioOaofEV8ZgA+KKNch+TfAhm+dKj8gEtZyK0 0gCgFKDHdSv2SguhUbRTQgKRFqmTsSeLgjNAR61DUPE9eEoXMzaTlSnsQRHKjd/FCCtS mJkLv1Gk3aWO4Fz9Sp8BCv5ZEvWUdpeWktfhNeaYLqpI3sPTm/f9Xva7d0zaDNh8/08D 7g1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=CKhySEFv; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w2si10568666edc.261.2021.10.12.09.54.42; Tue, 12 Oct 2021 09:55: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=@google.com header.s=20210112 header.b=CKhySEFv; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229495AbhJLQyp (ORCPT + 99 others); Tue, 12 Oct 2021 12:54:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229510AbhJLQym (ORCPT ); Tue, 12 Oct 2021 12:54:42 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FEF2C061745 for ; Tue, 12 Oct 2021 09:52:40 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id x27so89965013lfa.9 for ; Tue, 12 Oct 2021 09:52:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xawnIR012Yk1jlMpJVQsdMc2RuzZeUTjtaZq6SPv/vQ=; b=CKhySEFvBmeBz2lcrERZC74hIR/KWwGPXSyIVPq6Td7ba04vZohMLOQL35RLwjANyH tfRgYDWy9nS8fywNgnSJSAzXNkbXoJ8qv+rsx9CVsCqcxvQWM6yTOBwjT6GIxGxTJ309 bdaopyFfF+TiJh1ryg3F2OgcV1MxRjt94pHkqLEqDjFEn71AgZ/T64PwP29o9jxf8FOf JQqiSaU7BsB1x3DmlIPL0UmzMPqNnYAeenGf9Xc0aIPeoz1FxZofoYiGi9sCj348z2MM I5RdGgQMykcHrAo3w2BRDPeuDZh+Mh1f0p5hwizFdVfDfL5rTmqE5UK7aKtZ8hzLJi02 vXYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xawnIR012Yk1jlMpJVQsdMc2RuzZeUTjtaZq6SPv/vQ=; b=wwHr/BWEt1R/4Mw9Fm1KjN8A4v4BCJHUboaplPuAOeYwpm451lDBneBMjW38GWsuci +s11Jhlj6+2wdKNRxyTBAaje+FJTvw3WFOLwR3XMfMxumRLAD0grljKcbyQXdoCnZ5lC +9BFaBZx3dsnzJ8vfHCLZIrqU7LdE8+lMIrOhOWijhtrxTHOoUY2SYOlstzAi5Eb1PfE PGP/vz8wt3wbNk86OjI1l7AWYVDOSl1Y7vnzTel7W7k7He6h3xetpqXEmB+YcrDA5/YZ pIE2/JW9t9MouFEYMEGpTHdfx3Xuy+PkGmkU1LSgsWBVi2IvmfYdFQsuQujmLGbuwB7D PeGQ== X-Gm-Message-State: AOAM531ejQqlZA4g+rVj0hoWVMX6SgWoKw6+yTXR9Q20lHv7xzsFD+88 YG0ZnmcZwWxQWwAeRQQellnqIOj89lYrgJy261F8NQ== X-Received: by 2002:a05:6512:13a5:: with SMTP id p37mr34642679lfa.403.1634057558265; Tue, 12 Oct 2021 09:52:38 -0700 (PDT) MIME-Version: 1.0 References: <20211007004629.1113572-1-tkjos@google.com> <20211007004629.1113572-4-tkjos@google.com> In-Reply-To: From: Todd Kjos Date: Tue, 12 Oct 2021 09:52:26 -0700 Message-ID: Subject: Re: [PATCH v4 3/3] binder: use euid from cred instead of using task To: Stephen Smalley Cc: Paul Moore , Casey Schaufler , Greg Kroah-Hartman , arve@android.com, tkjos@android.com, maco@android.com, christian@brauner.io, James Morris , Serge Hallyn , Eric Paris , Kees Cook , Jann Horn , Jeffrey Vander Stoep , Mimi Zohar , LSM List , SElinux list , devel@driverdev.osuosl.org, linux-kernel , "Joel Fernandes (Google)" , "Cc: Android Kernel" , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 12, 2021 at 5:24 AM Stephen Smalley wrote: > > On Mon, Oct 11, 2021 at 7:39 PM Todd Kjos wrote: > > > > On Mon, Oct 11, 2021 at 2:39 PM Paul Moore wrote: > > > > > > On Fri, Oct 8, 2021 at 5:24 PM Todd Kjos wrote: > > > > > > > > On Fri, Oct 8, 2021 at 2:12 PM Paul Moore wrote: > > > > > > > > > > On Wed, Oct 6, 2021 at 8:46 PM Todd Kjos wrote: > > > > > > > > > > > > Set a transaction's sender_euid from the 'struct cred' > > > > > > saved at binder_open() instead of looking up the euid > > > > > > from the binder proc's 'struct task'. This ensures > > > > > > the euid is associated with the security context that > > > > > > of the task that opened binder. > > > > > > > > > > > > Fixes: 457b9a6f09f0 ("Staging: android: add binder driver") > > > > > > Signed-off-by: Todd Kjos > > > > > > Suggested-by: Stephen Smalley > > > > > > Cc: stable@vger.kernel.org # 4.4+ > > > > > > --- > > > > > > v3: added this patch to series > > > > > > > > > > > > drivers/android/binder.c | 2 +- > > > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > > > This is an interesting ordering of the patches. Unless I'm missing > > > > > something I would have expected patch 3/3 to come first, followed by > > > > > 2/3, with patch 1/3 at the end; basically the reverse of what was > > > > > posted here. > > > > > > > > 2/3 and 3/3 both depend on 1/3 (add "cred" member of struct > > > > binder_proc). I kept that in 1/3 to keep that patch the same as what > > > > had already been reviewed. I didn't think much about the ordering > > > > between 2/3 and 3/3 -- but I agree that it would have been sensible to > > > > reverse their order. > > > > > > > > > > > > > > My reading of the previous thread was that Casey has made his peace > > > > > with these changes so unless anyone has any objections I'll plan on > > > > > merging 2/3 and 3/3 into selinux/stable-5.15 and merging 1/3 into > > > > > selinux/next. > > > > > > > > Thanks Paul. I'm not familiar with the branch structure, but you need > > > > 1/3 in selinux/stable-5.15 to resolve the dependency on proc->cred. > > > > > > Yep, thanks. My eyes kinda skipped over that part when looking at the > > > patchset but that would have fallen out as soon as I merged them. > > > > > > Unfortunately that pretty much defeats the purpose of splitting this > > > into three patches. While I suppose one could backport patches 2/3 > > > and 3/3 individually, both of them have a very small footprint > > > especially considering their patch 1/3 dependency. At the very least > > > it looks like patch 2/3 needs to be respun to address the > > > !CONFIG_SECURITY case and seeing the split patches now I think the > > > smart thing is to just combine them into a single patch. I apologize > > > for the bad recommendation earlier, I should have followed that thread > > > a bit closer after the discussion with Casey and Stephen. > > > > I'm happy to submit a single patch for all of this. Another part of > > the rationale > > for splitting it into 3 patches was correctly identify the patch that introduced > > the patch that introduced the issue -- so each of the 3 had a different > > "Fixes:" tag. Should I cite the oldest (binder introduction) with the "Fixes" > > tag and perhaps mention the other two in the commit message? > > Couldn't you just split patch 1 into the "add cred to binder proc" > part and "use cred in LSM/SELinux hooks" part, combine patch 3 with > the "add cred to binder proc" part to create new patch 1, then "use > cred in LSM/SELinux hooks" part is patch 2, and "switch task_getsecid > to cred_getsecid" to patch 3? Then patch 1 can be cherry-picked/ported > all the way back to the introduction of binder, patch 2 all the way > back to the introduction of binder LSM/SELinux hooks, and patch 3 just > back to where passing the secctx across binder was introduced. Sending a v5 with this refactoring and the !CONFIG_SECURITY fix