Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp51746rwl; Thu, 30 Mar 2023 12:01:56 -0700 (PDT) X-Google-Smtp-Source: AK7set9yUXYNDP62ll8qK+jDTyksWwmglPnczkvlxqqM7t4WOVnDHGJ/t6SXVMdz+0kW5YN3DrWk X-Received: by 2002:a05:6a20:ce22:b0:d9:8b07:eb0a with SMTP id ic34-20020a056a20ce2200b000d98b07eb0amr23545645pzb.24.1680202915796; Thu, 30 Mar 2023 12:01:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680202915; cv=none; d=google.com; s=arc-20160816; b=goLED1918wv3LORNWpKg1pwbiHMM0xVo5qYs1d20dBu7W+toeJV7OSFPSY6OpsbBPq 0FbvQBdUsAN/+yW4f+lsfyUMVdJ53uyLK3UyuZJTzwLEURuWyRZJ8fwEDqZdZt2YRKmh WHJIQ5bTpKNobSgqcblSMgnetAtqmWkzzpryqhLZ46ZQeAlld8607FiOHIXwVBaOb2Xn SakpOQflBqB6cexhcnUa1Kf1/kYD/W9gAWKHrTth7wlLEtUZh9xVmC6ooYdp/jkwV/1L RptlnYSwpuswUWW4yoo0mLQySdLuyJPe3+6drMyIERMFRJPytc2xeKtffsAmEP245NeY BSKA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=UO1n6zUp0yobza8InEnn/DM+DTHhGs89/r9k0lucFyo=; b=nKh0EpSXai4NFev3RaqKzmmSig5yIcZWjP8KPBtd9GZUl7BG8eDLSj7BLGHyDiZLJg 033LJ1utk4XB2TWmu2/w1FsAHdctj5/39fvhETEzNDo1XAwGiEtwvBKEqvp28bEQw8jb KgGuBdcVTgLA8DyJIQe7EwJz9gtzKXmj29dFGeqc+/NIWUn2nzHhZ3VtDPwOZIa6IbL/ yzMecWKgE2s5Zp4W42N/Mt3rj/syxY/ShrkGVLvYu7kvkJA3x+FwfKkxZjeNAxyk4OVk JiZ+yXmaVqILPj3zG8EayV2omY6mloD2odKxEWfo/Y3otlQMc8TxReXw/5v5j0NqXr1K ABSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p4vjxyNZ; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r194-20020a632bcb000000b005074cff89b9si355819pgr.250.2023.03.30.12.01.41; Thu, 30 Mar 2023 12:01:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=@kernel.org header.s=k20201202 header.b=p4vjxyNZ; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229505AbjC3S5p (ORCPT + 99 others); Thu, 30 Mar 2023 14:57:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231796AbjC3S5o (ORCPT ); Thu, 30 Mar 2023 14:57:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB4B4EE for ; Thu, 30 Mar 2023 11:57:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6D5E8B829FD for ; Thu, 30 Mar 2023 18:57:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2793C433EF; Thu, 30 Mar 2023 18:57:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680202651; bh=QDXMO2FEUG9Rq0gCBC/aH3GNSlZ95N80wNNvQFm9oDc=; h=From:To:Cc:Subject:Date:From; b=p4vjxyNZHY6N7jK3jmTGzzrlSxRUdj6kU8y8R6DifTrXsmstyAm6HPac84qeSIgri d5/+qdp/8+3IhLwGBY2MmPWBLGAe3WfJxprcqvxmiqAawQQuU8JcymeTLCdGxvExyX YeomJ1CLnwLYV9uUtwjpaA0YIVhhnjS+ovxGpewaZw/Th+Rb43TtR5RnxhJbgvE6Fn cfi6DqbG++aAebAki3kAuviWFuzwN2pYkbOA7ekUgMZQbpDsHcGUButj1ZI07R3qsi mOvtGgHNkeNnAOt7wxgLrIAoBwCjaxPVuRnImg28FXFRneZToVJmzyLX76sbjWrW0o PKppOGESxU8Pg== From: Jeff Layton To: chuck.lever@oracle.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH] nfsd: don't allow OPDESC to walk off the end of nfsd4_ops Date: Thu, 30 Mar 2023 14:57:29 -0400 Message-Id: <20230330185729.22895-1-jlayton@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS 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-nfs@vger.kernel.org Ensure that OPDESC() doesn't return a pointer that doesn't lie within the array. In particular, this is a problem when this funtion is passed OP_ILLEGAL, but let's return NULL for any invalid value. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4proc.c | 2 ++ 1 file changed, 2 insertions(+) This is the patch that I think we want ahead of this one: nfsd: call op_release, even when op_func returns an error If you end up with OP_ILLEGAL, then op->opdesc ends up pointing somewhere far, far away, and the new op_release changes can trip over that. We could add a Fixes tag for this, I suppose: 22b03214962e nfsd4: introduce OPDESC helper ...but that commit is from 2011, so it's probably not worth it. diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 5ae670807449..5e7b4ca7a266 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -2494,6 +2494,8 @@ static __be32 nfs41_check_op_ordering(struct nfsd4_compoundargs *args) const struct nfsd4_operation *OPDESC(struct nfsd4_op *op) { + if (op->opnum < FIRST_NFS4_OP || op->opnum > LAST_NFS42_OP) + return NULL; return &nfsd4_ops[op->opnum]; } -- 2.39.2