From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 809B6C433FF for ; Wed, 14 Aug 2019 17:11:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5579221721 for ; Wed, 14 Aug 2019 17:11:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802709; bh=7nilxyzThzW7Y1VoAFL8BNe89egM2VX6ASzzpL36Dtg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=B/xGlGqYCrr8iyEp7YzkSERfm4GNZPhujgg/HrfszYUKWlCtQN0Pfl8CY3mrKVz1A L/N2GCwgowL4ToZ/uLLsq5xKvIfDJwd/Gt8vxidcjA4bspMaInxLSySQDGRUx/MD3p +WYbEDfXSdgsfeZSboEBLolXNjyXOGcFxRJ1PlUY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730639AbfHNRLs (ORCPT ); Wed, 14 Aug 2019 13:11:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:35242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730630AbfHNRLp (ORCPT ); Wed, 14 Aug 2019 13:11:45 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D11302063F; Wed, 14 Aug 2019 17:11:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802705; bh=7nilxyzThzW7Y1VoAFL8BNe89egM2VX6ASzzpL36Dtg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NGsvPBspsrUJxdC/2TsjnAfM28NLdCO2gj6GfmvWjITJk6x9uqQhUCOErOkimWFzb t7MyFk6sY86dHgki/3oeuPBbik5qEX1j6V6/aMTQDDNlrzjbOMHmRUdsmFCf1pEhd2 z2rop4/EH1VY7phtf0u/1ZSLLR47RPswM8j0AM5U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Olga Kornievskaia , Trond Myklebust Subject: [PATCH 4.19 85/91] NFSv4: Fix an Oops in nfs4_do_setattr Date: Wed, 14 Aug 2019 19:01:48 +0200 Message-Id: <20190814165753.654041844@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165748.991235624@linuxfoundation.org> References: <20190814165748.991235624@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Trond Myklebust commit 09a54f0ebfe263bc27c90bbd80187b9a93283887 upstream. If the user specifies an open mode of 3, then we don't have a NFSv4 state attached to the context, and so we Oops when we try to dereference it. Reported-by: Olga Kornievskaia Fixes: 29b59f9416937 ("NFSv4: change nfs4_do_setattr to take...") Signed-off-by: Trond Myklebust Cc: stable@vger.kernel.org # v4.10: 991eedb1371dc: NFSv4: Only pass the... Cc: stable@vger.kernel.org # v4.10+ Signed-off-by: Greg Kroah-Hartman --- fs/nfs/nfs4proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -3133,7 +3133,7 @@ static int _nfs4_do_setattr(struct inode if (nfs4_copy_delegation_stateid(inode, FMODE_WRITE, &arg->stateid, &delegation_cred)) { /* Use that stateid */ - } else if (ctx != NULL) { + } else if (ctx != NULL && ctx->state) { struct nfs_lock_context *l_ctx; if (!nfs4_valid_open_stateid(ctx->state)) return -EBADF;