Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1650027iog; Thu, 16 Jun 2022 10:38:53 -0700 (PDT) X-Google-Smtp-Source: AGRyM1swcRPph+kBoRC54UUY5tZJplABC6M6C1HOAGsNJYE3djSiUcsT+5UDH3td3QhqJ6QhxEmp X-Received: by 2002:a17:907:7213:b0:71a:1dc8:dfd9 with SMTP id dr19-20020a170907721300b0071a1dc8dfd9mr4204830ejc.747.1655401132960; Thu, 16 Jun 2022 10:38:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655401132; cv=none; d=google.com; s=arc-20160816; b=BmhD2eKZY2/SCIjM7PR7EY3e5HhSvmlcGYckwGIdUbM2QiZw2Nca4i5B1fYvCUgR0o sYjqPZ0SgRk941DWi8YhZpTRvVtlVsv/HAI1raH9lKcUUNFdnYbZCHgrf5tWigwl7LgW i+URnlP0mxaTPj/+6Ad/G6lvphaH9kpUk9eOZNdSJQXNfagFm4+H8Y32jo8ECD82Gfy2 OX/Cji1Y+7hfnrgM8C9HqLINXPuDYPB/8mxuC0NTO9UzR7r8HcHNhPD9wIkBwDeMKCcZ 5g5/HyKeimZDJOPUNBPKsocXBSCwb86GIkoNXQyOmp0ZnG1oAYcr/LVtdlLN9+XWXDkR T9EA== 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=bHjV6+d1wPcbJIXXueZ8eXPKto8w1sGcbUP/nhry+Lc=; b=UlGDFHamBF1gSfH48KsBsEj3wi1PrHA0VeQAXt+esHEOZhQyWPJuKZqrmiTPfXnU90 fdJQjLeaaa5HMOpUPhkUWcfzzFhz/LJLhRuC0gzqJv+Nlate1wdA6gpOTBSOA5qMdnza +mqKBgZb5Fs5Phf7Yua7/cOLJ01yyNPXQkq8srll3jduBl+jeihz8KdjmaI6A0B14Kqv 3BxvaGQ4NNj2p6Mzcd0N0TYEej55q0H061f+ljie+ay4EHcH9qtHJ1WRNoFDBKV/SKh9 QVnNdhj+/ioVSlQJvxn/qjnw7Rh+KwoQFE0hVARcmnV4oDsC2sVuhR3iuZnscSPBPMKA RYNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=fZLZmEgX; 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 j14-20020a05640211ce00b0042dbdc55828si46983edw.403.2022.06.16.10.38.27; Thu, 16 Jun 2022 10:38:52 -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=fZLZmEgX; 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 S1378223AbiFPRT7 (ORCPT + 99 others); Thu, 16 Jun 2022 13:19:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378285AbiFPRTz (ORCPT ); Thu, 16 Jun 2022 13:19:55 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 326504CD57 for ; Thu, 16 Jun 2022 10:19:54 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id u12so4002147eja.8 for ; Thu, 16 Jun 2022 10:19:54 -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=bHjV6+d1wPcbJIXXueZ8eXPKto8w1sGcbUP/nhry+Lc=; b=fZLZmEgXFFCbwyUw1zXJ5JL28E/ey7iqcZSqht9lq7kKmvINuMARA0+Ulb4FJDUsty hAgz7ZM0rJIjo1enFtWyVxi8pMFilkYjG+n1yIzkefLHxUTnJEm9Z7JzL0MpVfkVVr0k /IPzEpcZksaPiymRJXKfSMDmYfFX1gnvZoDKU= 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=bHjV6+d1wPcbJIXXueZ8eXPKto8w1sGcbUP/nhry+Lc=; b=Mz4OUlfn7Am621spY6TBAJbdm7Eu3R5LvqmLYXb9YjmTJ8LTtwNiZiAq2TT6LQUbLG Ihc0W55s0d1ty+eVMf2L7miX+p1UofgUYiCISTf46wrSCMVET7qI/7tXpijMCnI41r2u Ut9FA+eN/nl1zhlXR2wm9Dw4xTJzIL/T1mauVsHI3EWwjX5Gr3BVzIyB3RTCfFviTCae IMKnM5OkWY4n73Qk1a45UkcWUo4edIyKIT11MHeIwdY+47rplmxxTLnmBKtQ11XRlEvJ 1H+Z6dkca3xEb4kBS9bnLuY7AZ/Lg4WgOf0CSy6fFv/IhcrBW2GVJ5uiqskyRam/5BO4 wWzA== X-Gm-Message-State: AJIora/2BZ0XU0EMBtWcWww/EU5/BuRR1MehmS76R8GSKNXbShr/6Ddi gWGAKUeHMcq/wTVSRs0qroPWqvrQ81EQG9yV9JTbKQ== X-Received: by 2002:a17:906:4fd6:b0:70c:9284:cc01 with SMTP id i22-20020a1709064fd600b0070c9284cc01mr5513350ejw.553.1655399992619; Thu, 16 Jun 2022 10:19:52 -0700 (PDT) MIME-Version: 1.0 References: <20220613202852.447738-1-mortonm@chromium.org> <202206131643.4FB2340C43@keescook> In-Reply-To: From: Micah Morton Date: Thu, 16 Jun 2022 10:19:41 -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=-2.7 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=ham 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 Tue, Jun 14, 2022 at 10:36 AM Micah Morton wrote: > > 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. Just sent the updated patches and selftest patch. > > Thanks > > > > > -- > > Kees Cook