Message ID | 20231031123207.758655-3-omosnace@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b90f:0:b0:403:3b70:6f57 with SMTP id t15csp201709vqg; Tue, 31 Oct 2023 05:33:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH/aOxJxu3T0wfo7d0QMdB4uKkw7MrzFZIPOzL6T4Yy3IpTNdu0dWZeXdKSWJ+8tk7Hjpwp X-Received: by 2002:a17:903:245:b0:1ca:e05a:93a2 with SMTP id j5-20020a170903024500b001cae05a93a2mr12347577plh.32.1698755614269; Tue, 31 Oct 2023 05:33:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698755614; cv=none; d=google.com; s=arc-20160816; b=vBEHXTQ6S268waU92DZb/T+XxOdWWTqgPbH7QjBAWLT2IERIE0XPs4IyC5a1lMl0vV HJF+fYOzK2ktf1WZ4VrAou52z1ag2+mY1nQfAcWeGSVnABOC47+TsEPq6LGXWZwEj1hx qgbYETLSvMC4Nuf3gXEcHREnd7IqVIy+BLHPGlhYqyQdk6IuMmkRX1LY2oAbcUHruvgI 75lYWcWhKdL0JbJATWMrQJNREfe6jm5DUB+DRsSj3dfuTUDHOwMMWT53d7TC8Tr09rYA dVYFw/ji4rYm6xtFABHd+f8aBVf2o9ub0eactg4XgfRqdXcMG8QdXJsHI+4p2XETBMyI rFqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IwcTumPEA8MXD9aE6NAuiQnpk8SlcZkJMMNjOT52wQs=; fh=3AN7ORKc66AQYSTl23VmdYm3vXIU7gdmsvq6+mhfy+0=; b=xjlAS8tiJzbxDKIhZBwOrigyU3edMaklxsPqXFPQscBX5Q7Ae0tkcRdsUNmlxE7TVM wOESos7hUAFCpU+qKsmYthLA7mKbco11A2VpQaWDI8EjQLTk754lqfxuGcgRIYuq2w6w tJw1sXtwnhFneIahTgs+LdHE5C+Cqt6FUxyRv2YhVWxw8jybdRontp0wjzBCG9Y3ttlo DvAV4AgKCkYO+spA4nx/gM5wgORaTnf4VVrDFAGjlFIYdmaM798j7ZG4JKPhEVxXj2Nz m/1t2fddsGyMj59qTItP+qcAatqpZIVlrWHYG/pwKKNQCsoz0I1SSV9y8QBAlE8TS+iM N7ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fuRhxgrW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id t4-20020a170902d14400b001c7345bc01csi938390plt.450.2023.10.31.05.33.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 05:33:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fuRhxgrW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id A0B418039A06; Tue, 31 Oct 2023 05:33:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344273AbjJaMdH (ORCPT <rfc822;chrisjones.unixmen@gmail.com> + 33 others); Tue, 31 Oct 2023 08:33:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344246AbjJaMdC (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 31 Oct 2023 08:33:02 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9456EB4 for <linux-kernel@vger.kernel.org>; Tue, 31 Oct 2023 05:32:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698755535; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IwcTumPEA8MXD9aE6NAuiQnpk8SlcZkJMMNjOT52wQs=; b=fuRhxgrWOhZPsV40BNQDqO8qj3Ps9RDZD2N6n/ubi+RL0N2gHgEyYyGrc5pRDJsE5DaNxa ny3/dzAwYWOVIP6KTmGLjQYt9f5wrt8OEpEvEAQJD6ulO2BM2yyyCMy+mkBTydw8PHlmbI 5RoBwS+EURlQIZk6WDyjmhG/h72wLms= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-326-Zgn4cCHMNqCT0Mj5o9XBLg-1; Tue, 31 Oct 2023 08:32:14 -0400 X-MC-Unique: Zgn4cCHMNqCT0Mj5o9XBLg-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-778b5354c7bso706482185a.1 for <linux-kernel@vger.kernel.org>; Tue, 31 Oct 2023 05:32:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698755534; x=1699360334; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IwcTumPEA8MXD9aE6NAuiQnpk8SlcZkJMMNjOT52wQs=; b=WT/SyUZX5pUPOvBgfSM4hzfcJHRbZgxEAEAQXehESy4OGek0/rV63/SVuaCmrGG36Y BBtz8s1C7Cnl4/QTnuYngf6i+Kz+Bzv6P3rqNJltylTZkUjpYqjF1LMoksX5rpGVirdJ NvFDo4vN91IKbcvh6KvbqBtmZn6bN/M2Aoxk8L5GKpGVj56vgd13gDw3/qU5rd5FRAMH DzR+es09wannH9lDqHZPINugjut0maO0qInsjNtKcYMbDgVWmcEmu7w+H9NhpNVvYWyb DycF1Ylx1LIvglbdNcui36yJo4hyjxdtsAkZ0o9iPmIMrF4lq3iw1pguUvzsxSmkBSBk Uokg== X-Gm-Message-State: AOJu0Ywkd2JwqumYVKFtOkcybCAAkkWqklcsWaaQ54oBtB8hHv2DIynk BbSKSrEm3WXSg2pnhIakuDO9+af3doiyc//B8mQN9kodKhHWhoJesBDYHrUy4itwEldLkiN3i0U 2ERF3PhHeslFyUWkOviCbxWZW X-Received: by 2002:a05:620a:2408:b0:774:2e8f:2170 with SMTP id d8-20020a05620a240800b007742e8f2170mr15537035qkn.4.1698755533752; Tue, 31 Oct 2023 05:32:13 -0700 (PDT) X-Received: by 2002:a05:620a:2408:b0:774:2e8f:2170 with SMTP id d8-20020a05620a240800b007742e8f2170mr15537013qkn.4.1698755533490; Tue, 31 Oct 2023 05:32:13 -0700 (PDT) Received: from localhost.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id g23-20020a05620a13d700b00777063b89casm457697qkl.5.2023.10.31.05.32.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 05:32:12 -0700 (PDT) From: Ondrej Mosnacek <omosnace@redhat.com> To: Paul Moore <paul@paul-moore.com> Cc: linux-security-module@vger.kernel.org, Benjamin Coddington <bcodding@redhat.com>, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] lsm: fix default return value for inode_getsecctx Date: Tue, 31 Oct 2023 13:32:07 +0100 Message-ID: <20231031123207.758655-3-omosnace@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231031123207.758655-1-omosnace@redhat.com> References: <20231031123207.758655-1-omosnace@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 31 Oct 2023 05:33:24 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781274367444478508 X-GMAIL-MSGID: 1781274367444478508 |
Series |
lsm: fix default return values for some hooks
|
|
Commit Message
Ondrej Mosnacek
Oct. 31, 2023, 12:32 p.m. UTC
-EOPNOTSUPP is the return value that implements a "no-op" hook, not 0.
Without this fix having only the BPF LSM enabled (with no programs
attached) can cause uninitialized variable reads in
nfsd4_encode_fattr(), because the BPF hook returns 0 without touching
the 'ctxlen' variable and the corresponding 'contextlen' variable in
nfsd4_encode_fattr() remains uninitialized, yet being treated as valid
based on the 0 return value.
Reported-by: Benjamin Coddington <bcodding@redhat.com>
Fixes: 98e828a0650f ("security: Refactor declaration of LSM hooks")
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
---
include/linux/lsm_hook_defs.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h index 4dd55fdfec267..ff217a5ce5521 100644 --- a/include/linux/lsm_hook_defs.h +++ b/include/linux/lsm_hook_defs.h @@ -273,7 +273,7 @@ LSM_HOOK(void, LSM_RET_VOID, release_secctx, char *secdata, u32 seclen) LSM_HOOK(void, LSM_RET_VOID, inode_invalidate_secctx, struct inode *inode) LSM_HOOK(int, 0, inode_notifysecctx, struct inode *inode, void *ctx, u32 ctxlen) LSM_HOOK(int, 0, inode_setsecctx, struct dentry *dentry, void *ctx, u32 ctxlen) -LSM_HOOK(int, 0, inode_getsecctx, struct inode *inode, void **ctx, +LSM_HOOK(int, -EOPNOTSUPP, inode_getsecctx, struct inode *inode, void **ctx, u32 *ctxlen) #if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE)