Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp13857895pxu; Mon, 4 Jan 2021 06:26:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2imqgYjn/xTqS3sbkRF/1LZBS8Tc/+u5AkBslNQYdRsxjDoqnpy/w+dIZhLNZui0MET6L X-Received: by 2002:aa7:c403:: with SMTP id j3mr69984251edq.217.1609770417975; Mon, 04 Jan 2021 06:26:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609770417; cv=none; d=google.com; s=arc-20160816; b=Csgssux5kVC2o2Am/dQVTxz7dj5HPipzufiUYJE2E2AdwbKAmeUppurGE1hkJ9II/B 21mGLzfPcI72hKvnwGC8FGproyeBsVmylfsg0vpWsNc2ly26Ixa9An+jv8F2UmVPUgJS vhUzBXSE+lM1V5tNOzxwNbm5xQXgin6+07DuqjoulAFLgTqrYOB29+jJxu3nVpveNahQ ORAVwK/ZLkUTiqOy4i7DJm8e81LFN/27v5tFwsvIi3V4VSnZkNjJaKrTTTfkerds9ejt 5vajT680vNQZ6KB3mjGrIem7brUxM4L0gyyi/T7HkcKjY3fpYV126apvXBOrFX8ma9f9 2qDQ== 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=kXTFfeMRZQQpjX/bUjX/VUuqwPxBKyg8TYI+r24zwMc=; b=rAVPQgjZblzEMIvSmDsVDnOJ5Tgmb5J8pECmKtC8JhP4tFSF5kh/J5OhkJ6ImxI1Vg eqvXWkay/XKBdQ9r3YVsg76vrwIf+lRNyNwR/44qbwpqKzxSX6n6HZxJvAO5lMnSqpav af1M0eu3kJB9N7376ERihd4oTW7Mms+qdsJNy9bXTMYQk6PL5sMN8zkLBEdgZHwFE+Kk Oy6eMYZbB6t1RY3bBGkcCsSK2AlVODQUmjDq2Ip5cUqphTZ2xvonP3pyXS5C8GPy2UJI S7vfA97DPC4T/GzuCzgMbmlwQ5R6qj1csScRuHWGnn9vDQR4QlJy3t5ISJq4IERnNRWl dE7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bL9IjbB8; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t6si31969069edq.353.2021.01.04.06.26.35; Mon, 04 Jan 2021 06:26:57 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=bL9IjbB8; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727340AbhADOXP (ORCPT + 99 others); Mon, 4 Jan 2021 09:23:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727136AbhADOXP (ORCPT ); Mon, 4 Jan 2021 09:23:15 -0500 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95745C061793; Mon, 4 Jan 2021 06:22:34 -0800 (PST) Received: by mail-lf1-x131.google.com with SMTP id o13so64720527lfr.3; Mon, 04 Jan 2021 06:22:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kXTFfeMRZQQpjX/bUjX/VUuqwPxBKyg8TYI+r24zwMc=; b=bL9IjbB8aRoM2Bbdkox5AoGHJ7LmMDhG5X87RhacQffOkK4RDKh9GzBDzsLftnPqjg sjV80SnDAn9HsjTEPA9YkwRPxUyVdnQBmUdeKBb/07ve4M5yhoiJkpnkolbCB1bB7yLF 4fIkPhcyWaaJmR3N99kkDhOhqel2j0sPbAgo9zH5cf3zqTnSF3E6HkO8dYrEZDfVrgtX gDhvY0tDgHRPyUCGvBLSvEtKVY+nsdJCQTjGbY4qSfCx/Db8rW+TaQoVlZPjyrkfzeSc n7HoTrR9GUEHLA+Ged8gOt/vkI8SWGZXUvdoC4ZYDH0yQ+Vph9fZX5iKRbus6nq3x+7I EIxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kXTFfeMRZQQpjX/bUjX/VUuqwPxBKyg8TYI+r24zwMc=; b=PCljmN9+XRc/74lw5nDuZN9IyJItbYtakmH3+ACqyXdxWOPSk3XxWybE+iUmy+Vhyp vKSN7m8KmA/GAbZaS8HpZdA4HM09qjBv6P/8ihpU26oltpHJLyRqiX5UYtzgJGSmB6y8 +PyL6XyfFWMNfpUXSJi7hdoB+QBmvqNyxx3/+9uTHRVeagjpVljdcF8dYDje4tLC4Arf TxWln3AGKP9yCQ9SZtXh36M5KL3FAkPJBHDfFJ02MLRtsAX7txbGBpBR4XTNLHY0lr8x lZ9WURDAx2nO/RtS4pY2VA8h2pyPVaG2DKCoT55dmf4dvXeDNTZLkRZ3WgEuBLW2Gzm1 DxBw== X-Gm-Message-State: AOAM531vh05Sv1/5stTvVsV5vl8mGRzAQEeDqh5jMCRYPOCVtZ3wV1Kj UmFzHnoazsGveylUV45Iwx79dtgaPYd9X4euxZ8= X-Received: by 2002:a19:c786:: with SMTP id x128mr35713651lff.323.1609770153039; Mon, 04 Jan 2021 06:22:33 -0800 (PST) MIME-Version: 1.0 References: <20201219000616.197585-1-stephen.s.brennan@oracle.com> <20201219000616.197585-2-stephen.s.brennan@oracle.com> In-Reply-To: From: Stephen Smalley Date: Mon, 4 Jan 2021 09:22:22 -0500 Message-ID: Subject: Re: [PATCH v3 2/2] proc: ensure security hook is called after exec To: Stephen Brennan Cc: Alexey Dobriyan , James Morris , "Serge E. Hallyn" , LSM List , Paul Moore , Eric Paris , SElinux list , Casey Schaufler , Eric Biederman , Alexander Viro , Linux FS Devel , linux-kernel , Matthew Wilcox Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 4, 2021 at 9:16 AM Stephen Smalley wrote: > > On Fri, Dec 18, 2020 at 7:06 PM Stephen Brennan > wrote: > > > > Smack needs its security_task_to_inode() hook to be called when a task > > execs a new executable. Store the self_exec_id of the task and call the > > hook via pid_update_inode() whenever the exec_id changes. > > > > Signed-off-by: Stephen Brennan > > Sorry to be late in responding, but the proc inode security structure > needs to be updated not only upon a context-changing exec but also > upon a setcon(3) aka write to /proc/self/attr/current just like the > uid/gid needs to be updated not only upon a setuid exec but also upon > a setuid(2). I'm also unclear as to why you can't call > security_task_to_inode during RCU lookup; it doesn't block/sleep > AFAICT. > All it does is take a spinlock and update a few fields. You could also optimize this by comparing the sid similar to how the uid/gid are compared and only updating it within the hook if it has not yet been initialized or has changed since it was originally set.