Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp6837439rwp; Tue, 18 Jul 2023 06:38:00 -0700 (PDT) X-Google-Smtp-Source: APBJJlGOl49C0/xxHEQ9A0kb+Iim/cuF0MVelkNKLtxgmv/gtSjAA1pxCy7DN+Am22tPGGPVcfYL X-Received: by 2002:a17:906:20a:b0:977:e310:1ce7 with SMTP id 10-20020a170906020a00b00977e3101ce7mr13418397ejd.38.1689687479829; Tue, 18 Jul 2023 06:37:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689687479; cv=none; d=google.com; s=arc-20160816; b=Eu1r5046PhGN6ZorxoLyLHT6wSRZzH3p052tjDLaPnM0lsLRwDE4BLOh8pGF1RhPLQ eTHZu6hZQLIDZWD/twbmwnQ7bg2NdwWAwuTtC9JUyHmjU8iI8JzUkL91YSQz2syLaNTj FZA8/nQxrGQywd4e/fF2MpNTqlRy+jNGB11gC5894QQy0iqwIbnYjKmQHGTYqlIl/PRy 99w+ryrw9oStH3xOh9o+4jvkckdaG/F/rVQkXuxphOQzkvWNVuCWDol4ETTTTl5cKDA+ aImXLlSDsYQg6NpDeuQ0dAVI2g8IhspWywYle253Km+zcRrBxPfAnkX6SaUTorK2EiOK 8+8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=dgledF1WRoLwrfDvjbydZH7nQLxGFefypqZhBkMsdxg=; fh=V/0aM0kjihKxJF66ZgoYqY7NkZwPNmbpT61wVXBKaEQ=; b=HGntoJnuSVPVI+m2HCegIMeE5pAspk4gzS4L4D2Crkzh4KxMEMdAdqvTTJZU0j9A2j KASxFOccXYcMwoUuQV7fCgA5UINAXJrVt/sPUqbvdHQdw2dv2kPkxNaWAGj5LKYkvEJs x/XEShExEsb2mnUfrEi7Yhh7muMEHks2PuV0sbVuOXV8wO9juDF7G17jG6mzz/d5uYdA bPnEssAxrTReIsqYicQpK1oUJY7lLp/LqcT1iCryU5qwXxPt/DEZiaS6pvZ7bDc998jO kP3b4k1Wk3/jrqS2rJfzRHp/kjGV7+ZcefJCNey9CG0rpfrn56CQnjItc+0jQpkPR9Cq aHRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Peet7B3U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x12-20020a1709064a8c00b00992ac91eb76si1148093eju.684.2023.07.18.06.37.36; Tue, 18 Jul 2023 06:37:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Peet7B3U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232332AbjGRNZY (ORCPT + 99 others); Tue, 18 Jul 2023 09:25:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232311AbjGRNZQ (ORCPT ); Tue, 18 Jul 2023 09:25:16 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA191EE for ; Tue, 18 Jul 2023 06:24:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689686674; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=dgledF1WRoLwrfDvjbydZH7nQLxGFefypqZhBkMsdxg=; b=Peet7B3UXXCda/vDPMqkOSWIvLWKHcmJ9k/jcxYGeJLMGMqFce3nmEBMRermOAwnMgx/2a ihVx82TIV6Z4Q6wntHJtCpBzV9O8wpVJUA2gsVWnnRD0xL8bEWB2+uUvTtFVNBNLTEjIBl j9CYADyVYXq/86NEPHzQxzHIb8azgTk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-241-Tkt302CUP3iz11o0VtpMww-1; Tue, 18 Jul 2023 09:24:28 -0400 X-MC-Unique: Tkt302CUP3iz11o0VtpMww-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6965A8D168D; Tue, 18 Jul 2023 13:24:28 +0000 (UTC) Received: from segfault.boston.devel.redhat.com (segfault.boston.devel.redhat.com [10.19.60.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1E9E42166B25; Tue, 18 Jul 2023 13:24:28 +0000 (UTC) From: Jeff Moyer To: Ondrej Mosnacek Cc: Jens Axboe , Pavel Begunkov , io-uring@vger.kernel.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] io_uring: don't audit the capability check in io_uring_create() References: <20230718115607.65652-1-omosnace@redhat.com> X-PGP-KeyID: 1F78E1B4 X-PGP-CertKey: F6FE 280D 8293 F72C 65FD 5A58 1FF8 A7CA 1F78 E1B4 Date: Tue, 18 Jul 2023 09:30:18 -0400 In-Reply-To: <20230718115607.65652-1-omosnace@redhat.com> (Ondrej Mosnacek's message of "Tue, 18 Jul 2023 13:56:07 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Ondrej, Ondrej Mosnacek writes: > The check being unconditional may lead to unwanted denials reported by > LSMs when a process has the capability granted by DAC, but denied by an > LSM. In the case of SELinux such denials are a problem, since they can't > be effectively filtered out via the policy and when not silenced, they > produce noise that may hide a true problem or an attack. > > Since not having the capability merely means that the created io_uring > context will be accounted against the current user's RLIMIT_MEMLOCK > limit, we can disable auditing of denials for this check by using > ns_capable_noaudit() instead of capable(). Could you add a comment, or add some documentation to ns_capable_noaudit() about when it should be used? It wasn't apparent to me, at least, before this explanation. > Fixes: 2b188cc1bb85 ("Add io_uring IO interface") > Link: https://bugzilla.redhat.com/show_bug.cgi?id=2193317 > Signed-off-by: Ondrej Mosnacek > --- > io_uring/io_uring.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c > index 7505de2428e03..a9923676d16d6 100644 > --- a/io_uring/io_uring.c > +++ b/io_uring/io_uring.c > @@ -3870,7 +3870,7 @@ static __cold int io_uring_create(unsigned entries, struct io_uring_params *p, > ctx->syscall_iopoll = 1; > > ctx->compat = in_compat_syscall(); > - if (!capable(CAP_IPC_LOCK)) > + if (!ns_capable_noaudit(&init_user_ns, CAP_IPC_LOCK)) > ctx->user = get_uid(current_user()); > > /* Reviewed-by: Jeff Moyer