Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5108891pxb; Wed, 26 Jan 2022 05:07:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJws+Tu8iFVsRouHQLSK73UodAiZkkJU9tsBITQmohv2CSTb1Hw163FuBN4ws8PJ2SaBfw57 X-Received: by 2002:a17:907:7f01:: with SMTP id qf1mr11264708ejc.689.1643202446464; Wed, 26 Jan 2022 05:07:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643202446; cv=none; d=google.com; s=arc-20160816; b=nSft/V/B+06cPcD1aOQYT4JOcC5RHsW5IxzdQ/NGjG4h6AeKARL0rvLpq9aI3tjb1K jjamem5q5qU4ydatYtxAoduOlB35ukBCOxgVc20guL4vu2KZGvx2hjl4f2Yrp3Xv4nAM xVRU1U6B5iHo6oFhHHRvo/R3wDbyBIYwa7uhFy7dPSDNhnsvP05BiZJyAO5hydTH9GS5 7WH0cjStd41bbvblEzxo/Rk6hfRnfuau4WeCY/B4rleFMz/6vis22gujrti7gxtLMMMR WGjc9xYhkP6yldDjluI/E95+BNuejZFbfuxKkytUSbqf4Cb5DJEkVvjg/CB5C9YJxl+A MA4g== 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=pYNA1CVJ1M6lrfRYYmGpOXg9P7wsf14wwNEYFVpQGRg=; b=jut9R4LayG/3boGdVOS14Ftp2fhPvC0/DCbcK9uZeUhw8WvI+FRJTH+rouyENvTftg GTkmNErEbczskfhnNyCkhFwpY85mba2Q+piTJNJ+l5kYd0dECwqwiYL8SaKxDq+L7FuC XRA2ajjgyucC4Jj0eag29/SWGUWhB6K9M8uAlVPcYPQDpC+3QzktrzprU6ACywJ9n4iL wfSyPZuMTjrwhrwQC0LTszZJTgv9RmBuzqBDmU2jnGn9f/uSr8cQhdgfQlhJR/6ZuMsZ 8ABujNbOgQhyehN3OjYdmYV6utJpTeeckBCdrVVojQ4YRG0ybAQf6mn51bs+WH+3I5cP xBTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20210112.gappssmtp.com header.s=20210112 header.b="xU6QF2/+"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v21si7993907edc.273.2022.01.26.05.06.58; Wed, 26 Jan 2022 05:07:26 -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=@paul-moore-com.20210112.gappssmtp.com header.s=20210112 header.b="xU6QF2/+"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234877AbiAYXga (ORCPT + 99 others); Tue, 25 Jan 2022 18:36:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234898AbiAYXgV (ORCPT ); Tue, 25 Jan 2022 18:36:21 -0500 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3706C061747 for ; Tue, 25 Jan 2022 15:36:20 -0800 (PST) Received: by mail-ed1-x534.google.com with SMTP id u24so20112174eds.11 for ; Tue, 25 Jan 2022 15:36:20 -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=pYNA1CVJ1M6lrfRYYmGpOXg9P7wsf14wwNEYFVpQGRg=; b=xU6QF2/+7XDapkHCfliHO7u2D33hB0Ch0R0zZzdpTzTPvC1Y047yhrhmDkYlG1ppFH gDW0mIb8aCXFh74WuQjozBdZq/rhW8qM4AQxx9Gc6cVqBnmsb9EmIUcnS26wJDDqHOQE 4RVbKQUT85I+CGWgw00+JSAS9l7zZbLAvWCSkp0DwQEc28JTxoc6BwlKJtyHRa/RVTa6 S+l/jyHJzEXW6dG/nQAPWnAFvDC15uCBPbvWQTLdw3Fa4dbM3ZEkZYQ3dBcqLrLQPlaV ak8bOHgCGnKCoRhPjerDD31SgD47NnYfjU2UmhwWxXlWNCd5yuiuBTidOBnJO35Ij32W gZNg== 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=pYNA1CVJ1M6lrfRYYmGpOXg9P7wsf14wwNEYFVpQGRg=; b=tPcmHyPJlr6rWlJ87JJt7RXJwxajo0UMgvnozHUEK/f5kWupta3c2ZT5jHCS3hjFq5 H+lFQfeZUUJ0nSuissThNld/T/fsjwKr2ES60PNfPrHLdEtZm70h6xuQRPQobMZfrkcI yLV4H5DJcjppu/XhWpwdeeX4taThKLyck50u+y0qSIJQ3kPz+OeMTk/FH55aLHOA+tXY DjUWEtS++i0Fd9zuF820xo1M18qgSJqsVx6pY5Z34aHX943UIVYqSiDbqrr0/rmfESsI PFP5N8sKg7fQ11dJ1zjPr9hM4EOOkZqlyNjZrl7BA6IW3g93Px9+OR9WpH5QyjVLW/+3 3nmw== X-Gm-Message-State: AOAM532yGWZ/0XivjJ5S8cFjZZbpVWboRFlITYdSDwtcF3qc0cQRbvW9 nUBYNJpXLu/Yc2PhUtzop5E7yslsJkJyZ1qSp9yU X-Received: by 2002:aa7:d407:: with SMTP id z7mr22532317edq.331.1643153779366; Tue, 25 Jan 2022 15:36:19 -0800 (PST) MIME-Version: 1.0 References: <018a9bb4-accb-c19a-5b0a-fde22f4bc822.ref@schaufler-ca.com> <018a9bb4-accb-c19a-5b0a-fde22f4bc822@schaufler-ca.com> <20211012103243.xumzerhvhklqrovj@wittgenstein> In-Reply-To: From: Paul Moore Date: Tue, 25 Jan 2022 18:36:08 -0500 Message-ID: Subject: Re: [PATCH] LSM: general protection fault in legacy_parse_param To: Casey Schaufler Cc: Christian Brauner , Christian Brauner , James Morris , Linux Security Module list , LKML , syzbot , David Howells , linux-fsdevel , selinux@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 25, 2022 at 6:30 PM Casey Schaufler wrote: > > On 1/25/2022 2:18 PM, Paul Moore wrote: > > On Tue, Oct 12, 2021 at 10:27 AM Casey Schaufler wrote: > >> On 10/12/2021 3:32 AM, Christian Brauner wrote: > >>> On Mon, Oct 11, 2021 at 03:40:22PM -0700, Casey Schaufler wrote: > >>>> The usual LSM hook "bail on fail" scheme doesn't work for cases where > >>>> a security module may return an error code indicating that it does not > >>>> recognize an input. In this particular case Smack sees a mount option > >>>> that it recognizes, and returns 0. A call to a BPF hook follows, which > >>>> returns -ENOPARAM, which confuses the caller because Smack has processed > >>>> its data. > >>>> > >>>> Reported-by: syzbot+d1e3b1d92d25abf97943@syzkaller.appspotmail.com > >>>> Signed-off-by: Casey Schaufler > >>>> --- > >>> Thanks! > >>> Note, I think that we still have the SELinux issue we discussed in the > >>> other thread: > >>> > >>> rc = selinux_add_opt(opt, param->string, &fc->security); > >>> if (!rc) { > >>> param->string = NULL; > >>> rc = 1; > >>> } > >>> > >>> SELinux returns 1 not the expected 0. Not sure if that got fixed or is > >>> queued-up for -next. In any case, this here seems correct independent of > >>> that: > >> The aforementioned SELinux change depends on this patch. As the SELinux > >> code is today it blocks the problem seen with Smack, but introduces a > >> different issue. It prevents the BPF hook from being called. > >> > >> So the question becomes whether the SELinux change should be included > >> here, or done separately. Without the security_fs_context_parse_param() > >> change the selinux_fs_context_parse_param() change results in messy > >> failures for SELinux mounts. > > FWIW, this patch looks good to me, so: > > > > Acked-by: Paul Moore > > > > ... and with respect to the SELinux hook implementation returning 1 on > > success, I don't have a good answer and looking through my inbox I see > > David Howells hasn't responded either. I see nothing in the original > > commit explaining why, so I'm going to say let's just change it to > > zero and be done with it; the good news is that if we do it now we've > > got almost a full cycle in linux-next to see what falls apart. As far > > as the question of one vs two patches, it might be good to put both > > changes into a single patch just so that folks who do backports don't > > accidentally skip one and create a bad kernel build. Casey, did you > > want to respin this patch or would you prefer me to submit another > > version? > > I can create a single patch. I tried the combination on Fedora > and it worked just fine. I'll rebase and resend. Great, thank you. > >>> Acked-by: Christian Brauner > >>> > >>>> security/security.c | 14 +++++++++++++- > >>>> 1 file changed, 13 insertions(+), 1 deletion(-) > >>>> > >>>> diff --git a/security/security.c b/security/security.c > >>>> index 09533cbb7221..3cf0faaf1c5b 100644 > >>>> --- a/security/security.c > >>>> +++ b/security/security.c > >>>> @@ -885,7 +885,19 @@ int security_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc) > >>>> > >>>> int security_fs_context_parse_param(struct fs_context *fc, struct fs_parameter *param) > >>>> { > >>>> - return call_int_hook(fs_context_parse_param, -ENOPARAM, fc, param); > >>>> + struct security_hook_list *hp; > >>>> + int trc; > >>>> + int rc = -ENOPARAM; > >>>> + > >>>> + hlist_for_each_entry(hp, &security_hook_heads.fs_context_parse_param, > >>>> + list) { > >>>> + trc = hp->hook.fs_context_parse_param(fc, param); > >>>> + if (trc == 0) > >>>> + rc = 0; > >>>> + else if (trc != -ENOPARAM) > >>>> + return trc; > >>>> + } > >>>> + return rc; > >>>> } -- paul-moore.com