Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1081902ybl; Wed, 14 Aug 2019 10:24:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqzgGKR8n9+yzMJoIz9f2AEh+ywGlGyLoCTfY+02lmSAUJcnQB8plVOFCROKNzOfvzVRnhcG X-Received: by 2002:a63:ed55:: with SMTP id m21mr212623pgk.343.1565803446203; Wed, 14 Aug 2019 10:24:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565803446; cv=none; d=google.com; s=arc-20160816; b=os/6fpoDZnz+Z+pfAOmBELVgXmJ8u/LracuJPnauzKx8YOC9ydpcoF8ncW+oGBX8AP jMru24yQBTRKcXnJgEYVGoxBXuFZf/bJxC7eaOWyTq5SQZiCQq4DHUUganqao6wXhi1j 2aS0lAxlepUD5x35rZwnejPknZV+AvO8sR7xfEBabuAl2eSw8IBzjjkRe00F6VS5aj/F /QNuPmbsRnGMEnCMmiBFg09kh/BbeshgtRixJC6BncT64bcCg2BGDxLQFeqAyTM0Js7m 7BRG0sUe1kQPfknP2AhzdSCkHpfEtzrdthFZMe0j8bQPxEqAIstYMxvcHobOVpV1kCat Gjvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nGJfkGSKiWXA7Or+fsI2W2MT+myX0B8Azcbbl6k9A9Y=; b=tBbHSykDerYoFPQniK/+WAKrbLmNPZE1GH96pEi7KfaHCtyuNSEM67Tc3feTLdRnRt Obu/kgVbF5KY6Djs1ef3p/nO8hCa+ok77g/1lKQiw9g7IOoReOJj7H59G83bVa/lj/96 gSrUpavf6PodZL/U1zt3U3/wKi6lcKOoonKZE5ykaImlPuMg6GTZXW73RERQZHwGrAVr l9sjb3OdAr6V0dcM0C+HniNH/T5rSpuHkiJ0CXmQL9+3zMRDgVEv77ZvnSEaoRCMytc2 PChP1yyvYsRmLqYnmITdJioLY5UrQaC/1grGskGqo9zm4v6ACv9ARdyWaqTu24LoZlTv AnBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Raoft7+q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b6si218901pge.44.2019.08.14.10.23.49; Wed, 14 Aug 2019 10:24:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Raoft7+q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728892AbfHNRHs (ORCPT + 99 others); Wed, 14 Aug 2019 13:07:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:57400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728899AbfHNRHp (ORCPT ); Wed, 14 Aug 2019 13:07: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 8EA7E214DA; Wed, 14 Aug 2019 17:07:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802465; bh=rhZtCfUqK4UYel8UwCC363nM4+CVBChyfSHBllp7SRU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Raoft7+q/ZHdybDzn1Gb1qKF4KMZw5S1io4D+OmwMpbQ4PTQ3Rbeq1e5GZGWcVhaB NivJr2kNNwyzscKTVQ1k0RZaMnjWtzoLRlp0WC30uiwteeayA4QmA2L9aLmjO/TgVL wH4yrfMrr2yfwCH2H3n0+2lSJlouskNFzZN5kPc4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Olga Kornievskaia , Trond Myklebust Subject: [PATCH 5.2 136/144] NFSv4: Fix an Oops in nfs4_do_setattr Date: Wed, 14 Aug 2019 19:01:32 +0200 Message-Id: <20190814165805.628930185@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165759.466811854@linuxfoundation.org> References: <20190814165759.466811854@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 @@ -3175,7 +3175,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;