Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1707476iog; Tue, 14 Jun 2022 11:23:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2cSfg9gMtRIeTxUInDhedtSplFiSIugl4ORKoytS/DB4k4pgKZlii951X2nd5HKIc5DIe X-Received: by 2002:aa7:db02:0:b0:42d:c3ba:9c86 with SMTP id t2-20020aa7db02000000b0042dc3ba9c86mr7672624eds.337.1655231019977; Tue, 14 Jun 2022 11:23:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655231019; cv=none; d=google.com; s=arc-20160816; b=DEA5JOv8SfB90NVQt8uWLNhfOKF92QjFkqCxWh9onW/a7fPEYmH1+XO3kjyjFPgY/6 WPmMu9cMtdLy3njFFO/rXU7wgnUCIL1DTQN/EUspXL3l+/SbiGRFhITiUJvrK/YglyqK FSecZnQKXL7N+bfZw6SxBQt6I866h8M0XyiLco8NEVYHs3gz8lHoyqtTNgSvxyHpz0xz pQETmP0Xc9qWVFoqCDyQR/1OjpZVxz46yfMfVhnEllmqt1X/5w6pgut2b7DUt8EBQcYb HlPEdAZMJZTWElBBWV32gh7Falw9YTGIjzlAMNUoGzqRzXngz9eHVMeX48/ZZf1ooh5m sLxg== 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=y/o/RV1wuM6nbYpO+7qYN86XKOHWQh2hN8VI/abfDqY=; b=itsNVrXqvR3XDY0Ktc3Yd/xJsSXbcjixjZAIhEAScNDpLQj8f9OfL8qb31Al4qhMPj 5FxtmjOqDsIy/SoVbzNYq20dbXVg+8pPC+GAfkUaPtjtcxGtzQo+/veYfn5iyEIrVUB3 gB9Dr51MIfv3H3Ui2EyorqMNE6lhpCVwVUm7Mv2XOo+IBoiffkr6NQGYCP+trHy7+pqg qpZH31EyUaRD8rMrAnodXUjDN+HPiez4mUPP97twWZboQgpPuZCdMhdNWiIppiOVglxT am7h/5Otfm6CcqMZKXPgTlGsXWq+37es2QPEfTSAA7Ix5YrIgl9lQHVYcvW/jN5KBQO+ Ww8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=UJxaWhDm; 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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b7-20020a056402278700b0042ddc352f85si13163400ede.107.2022.06.14.11.23.13; Tue, 14 Jun 2022 11:23:39 -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=@chromium.org header.s=google header.b=UJxaWhDm; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238047AbiFNRhN (ORCPT + 99 others); Tue, 14 Jun 2022 13:37:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236164AbiFNRhM (ORCPT ); Tue, 14 Jun 2022 13:37:12 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE83C33886 for ; Tue, 14 Jun 2022 10:37:11 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id g7so12667969eda.3 for ; Tue, 14 Jun 2022 10:37:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=y/o/RV1wuM6nbYpO+7qYN86XKOHWQh2hN8VI/abfDqY=; b=UJxaWhDmrHuXP7KTB8VONn/p0WAg1P1msemNJScm0SoQJUhLcLCZJFkvAWGV22KmGT dTfXA5SlP3e4nZ3q52s+wIHCwtJOsdn3t7BDmkibJfyr6sIkvwjL6icoJDNzkLxPSlvz Zoux5qJ8F81p//tB87eH2FMACflqCgXnIEyq4= 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=y/o/RV1wuM6nbYpO+7qYN86XKOHWQh2hN8VI/abfDqY=; b=OdGk5GqeZo5AaaUz4bBvSnATgM+nhTyANelGalFK8Xe9CcPtzZ48zIHMzo8pO/+w8k H/4N1UBji7Zbw+R5vQ3CpsqTeBnU30KXN9ymdG/Hjh/sE3jesGBgf576q+PKX9o26Cem feNfTtWfThDuPx/sp1KrigqKBLdImbjx1Epv+aDNnFvWSoMsSbHZL212UkrqrGB48Vie XhoC6gHLLIeHQxTPTLNoWfXIGa/CCCDeDDI3e68SuWobAwOvSIvU8cY0gPQ1OaFm+1ha svTxdtUqFBJeryqgQmEr2UpX5pmEKbOTB5roQ5Qo0pJOZJeChIG9UgkeOXeowIb3VLWu W7OQ== X-Gm-Message-State: AJIora9K67Jlc1LxkCKWUQ+SVhsukq60SSUcz857PbI9v5ilVCbvV/m3 vaOx6ahse5esrtz21NT5MDAPUcoAtD7lqWSvy2vTpXDjQfFX7Q== X-Received: by 2002:a05:6402:2554:b0:42d:ee79:559d with SMTP id l20-20020a056402255400b0042dee79559dmr7460933edb.175.1655228230349; Tue, 14 Jun 2022 10:37:10 -0700 (PDT) MIME-Version: 1.0 References: <20220613202852.447738-1-mortonm@chromium.org> <202206131643.4FB2340C43@keescook> In-Reply-To: <202206131643.4FB2340C43@keescook> From: Micah Morton Date: Tue, 14 Jun 2022 10:36:59 -0700 Message-ID: Subject: Re: [PATCH 2/2] LSM: SafeSetID: Add setgroups() security policy handling To: Kees Cook Cc: linux-security-module@vger.kernel.org, jmorris@namei.org, serge@hallyn.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,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 On Mon, Jun 13, 2022 at 4:46 PM Kees Cook wrote: > > On Mon, Jun 13, 2022 at 02:00:03PM -0700, Micah Morton wrote: > > On Mon, Jun 13, 2022 at 1:28 PM Micah Morton wrote: > > [...] > > > +static int safesetid_task_fix_setgroups(struct cred *new, const struct cred *old) > > > +{ > > > + int i; > > > + > > > + /* Do nothing if there are no setgid restrictions for our old RGID. */ > > > + if (setid_policy_lookup((kid_t){.gid = old->gid}, INVALID_ID, GID) == SIDPOL_DEFAULT) > > > + return 0; > > > + > > > + get_group_info(new->group_info); > > > + for (i = 0; i < new->group_info->ngroups; i++) { > > > + if (!id_permitted_for_cred(old, (kid_t){.gid = group_info->gid[i]}, GID)) { > > > > Oops, should be: > > > > !id_permitted_for_cred(old, (kid_t){.gid = new->group_info->gid[i]}, GID) > > > > Guess I won't send a whole new patch just for that one line > > This begs the question: are there self-tests for this LSM somewhere? > It'd be really nice to add them to tool/testing/selftests ... There actually is tools/testing/selftests/safesetid/ but I haven't updated it since v1 of SafeSetID that only accommodated UIDs. I've been relying on integration testing we have out of tree on the Chrome OS side but I suppose its reasonable to bring the selftest up to date as well :) Also both patches are a couple lines off from the ones I was finished developing/testing with.. some kind of screw up happened when I copied from my dev machine to another where I could get git-send-email working properly. I'll just resend these 2 patches along with the update to the selftest. Thanks > > -- > Kees Cook