Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4772601pxb; Tue, 25 Jan 2022 19:10:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwV2YJcLP2RMKOc4p4mUGxRk3/7mlMj6/MqI+1Q9Y5kCRnv5EzCiQnYYYUB2fO1SQ+Maqr1 X-Received: by 2002:a05:6a00:a90:b0:4bd:320a:d579 with SMTP id b16-20020a056a000a9000b004bd320ad579mr21118135pfl.47.1643166639089; Tue, 25 Jan 2022 19:10:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643166639; cv=none; d=google.com; s=arc-20160816; b=GRlWRObgEUH+P/T6uetmr1EgJDVrKNU2IeE4P+SeYpu16+q0EaxUcz1pjqtzEHX2RC THOcYMA9BSWxA5ok03as5gMulIMkwAm7rYXri39DQMwBncmUdWUwiPdxcfZBJSGS1ADu uwAx2/Ym9qzXLkMtG3DJVWexO963c9hYkj0or/K9DOUt0F1TwdoeGibGskmUjzwRypoz aTz1CzyHXdhGQYRj/pka+LP1kZJldcyZKvDyketSp844wv3Qqehni4n+L0GfSeER2hWf mM0ObfTcRFSZNf2bFyU9uBzhkg95fPlgcia8ueD/QAAzJZLj4NwoD+6p4plnHD9PJ5LP eC+A== 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=v+JhCJG7g15hco1FfpnIJUO82hnrd6NkmYcF+6eeLPo=; b=PCTjPJ6d83hPpkSzAMX7JHpnjgSzUvyp5h1q0o2SnWrFtie7y3Hbvtpz8UzBkq0gUr SKXHakkV1I536rHVLApEViOAAWFdjohWKHzsx3odHXwN9kz4IJot9kSnFeqtEL7g8U2r j12SVLIGaSG28zY6wgPeSpedVMecw+hePdFjketBnIJWzwRVzWDpLcc/LImvIuhBVcqo TgW6TVQ5NzUCnoj6kMmYUMomJBMzl3sMBZSOucdBvtXsA7bztJpk7wj1aC0QFdTVNscB Zkle7idpH5iqZAxZjXRY7drgr1k1JLg8cnq5NbgBsonNnTYZpS9Mz55AjCNRW9GHkvmu zz0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20210112.gappssmtp.com header.s=20210112 header.b=a4paAk6X; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x13si578965pfh.105.2022.01.25.19.10.25; Tue, 25 Jan 2022 19:10:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-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=@paul-moore-com.20210112.gappssmtp.com header.s=20210112 header.b=a4paAk6X; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381578AbiAYRp6 (ORCPT + 99 others); Tue, 25 Jan 2022 12:45:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356760AbiAYRpb (ORCPT ); Tue, 25 Jan 2022 12:45:31 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D017C06173B for ; Tue, 25 Jan 2022 09:45:27 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id h7so32210033ejf.1 for ; Tue, 25 Jan 2022 09:45:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=v+JhCJG7g15hco1FfpnIJUO82hnrd6NkmYcF+6eeLPo=; b=a4paAk6X+lXbHgR975FUNAILKJjK+GHIKFby7yE+3igVKbZl+vWP1jtoru30kQmR1l AnMm15z8x2VhASr4KBv8zfBSkUW2NmMli4cYPPjEVrjFc1bRboE1LB/lznV3d9opqJsh nkYefRbIVsKskyxlf4Nvdjdlbmplc6NMEUB7tkrukby40kVSu7b36d6c9tsMKAoZknOi lvYR0N1XEPVDmSj9+2Jjl+sM4jJw3IckOViCWT2bDWYv0BQlS6vhGAKrgF1eGVJRb9/R AwwnBJC2MYqNUg2QVYcbm5+Bhq7wV8CQjpts6Ts3pklfGQIFi9nPtrJZSgKxubd3Ijm4 xO7g== 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=v+JhCJG7g15hco1FfpnIJUO82hnrd6NkmYcF+6eeLPo=; b=GU8DPZupbpUhstTBLc67V2acVi6kY75+ZGTJo5+hunhlsxi5iqnIJ+n0T8RVcFZ2Gt R1tcGKV8wUSBNclYECCfsGPGG5kIN6stSrAhENL9RuAzB9A6wwygIUyz8LhK3OaWbGpA zyIetlqfZv4I+NJ9li1ykSYgHbBEEuCd7zTbOkMy7ecxJurxcdSXY0Z2Lm6yEByvZa/T pHZQSCOX+NmLZ/67D4zJwkqDPrslj44YMp4m33TvXZSA/vfRdh2Cb4rt3pEkSr/3oFHP Z2NCTf6un1yLw5cKp0kUDPobYOh+WRCupkU1B8WmF2ldJDyhWDnq/mpXwc+pJMCAQJqA x+qA== X-Gm-Message-State: AOAM533B66mHBOWI6Rg/pIsfPkuC8PCUDT3sTqR+6vf0uxhBlNXlT6z0 RTRGZSRCqxz1T79/SKg3IJefQMuFOMb3WTE2RlVo X-Received: by 2002:a17:907:6d03:: with SMTP id sa3mr3976554ejc.517.1643132725758; Tue, 25 Jan 2022 09:45:25 -0800 (PST) MIME-Version: 1.0 References: <20220120214948.3637895-1-smayhew@redhat.com> <20220120214948.3637895-2-smayhew@redhat.com> In-Reply-To: From: Paul Moore Date: Tue, 25 Jan 2022 12:45:14 -0500 Message-ID: Subject: Re: [PATCH RFC v2 1/2] selinux: Fix selinux_sb_mnt_opts_compat() To: Scott Mayhew Cc: selinux@vger.kernel.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Tue, Jan 25, 2022 at 12:31 PM Scott Mayhew wrote: > On Mon, 24 Jan 2022, Paul Moore wrote: > > On Thu, Jan 20, 2022 at 4:50 PM Scott Mayhew wrote: > > > > > > selinux_sb_mnt_opts_compat() is called under the sb_lock spinlock and > > > shouldn't be performing any memory allocations. Fix this by parsing the > > > sids at the same time we're chopping up the security mount options > > > string and then using the pre-parsed sids when doing the comparison. > > > > > > Fixes: cc274ae7763d ("selinux: fix sleeping function called from invalid context") > > > Fixes: 69c4a42d72eb ("lsm,selinux: add new hook to compare new mount to an existing mount") > > > Signed-off-by: Scott Mayhew > > > --- > > > security/selinux/hooks.c | 112 ++++++++++++++++++++++++++------------- > > > 1 file changed, 76 insertions(+), 36 deletions(-) ... > > > switch (token) { > > > case Opt_context: > > > if (opts->context || opts->defcontext) > > > goto err; > > > opts->context = s; > > > + if (preparse_sid) { > > > + rc = parse_sid(NULL, s, &sid); > > > + if (rc == 0) { > > > + opts->context_sid = sid; > > > + opts->preparsed |= CONTEXT_MNT; > > > + } > > > + } > > > > Is there a reason why we need a dedicated sid variable as opposed to > > passing opt->context_sid as the parameter? For example: > > > > rc = parse_sid(NULL, s, &opts->context_sid); > > We don't need a dedicated sid variable. Should I make similar changes > in the second patch (get rid of the local sid variable in > selinux_sb_remount() and the *context_sid variables in > selinux_set_mnt_opts())? Yes please, I should have explicitly mentioned that. Thanks. -- paul moore paul-moore.com