Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp1216200ybh; Sat, 3 Aug 2019 20:50:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqypc+wDcQKXsH6cHZ0kdF9LIRjSIFLlnWsW1pMmKens+L/O4Mte3W9UWgj9g7n/e4lodWR0 X-Received: by 2002:a17:902:6a87:: with SMTP id n7mr136145640plk.336.1564890641821; Sat, 03 Aug 2019 20:50:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564890641; cv=none; d=google.com; s=arc-20160816; b=NMD3eusV1PMdpDjTQqLDFYecQM6kgHR8c851Rs/j2bJeP1xvvcKeWorRk7Rxa9g5Bc DJrRdYsayq/n5EEZ9r4a5qSpxezelmS8ULpTYHQxjJ6ulmrBGtzceh/n+ADQK5phVV/J 5jvLmzsvICwVXYtm/TEmG1EBLcRM2KtW9FtrZqsze1JUZlj3hDuu4Nu4EL/AN1xCB4wE DC5a97vyQ4YwkzPjS7CzX4Qe77cdwKGcJjz2fv1EvsB/vpTCnFPvAoCyFekzKjA/ZVXG uro8FCD9U3rLSmiaiRagHx1dF9KZd2hwsUB0hv8D2JrCU4ZhyDXOVC/srguqa2rdSTng GTcg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=YS30pX18B3aa2CR0VFk8ZSOQuGrmZb4Lf3ojhHX1NEw=; b=MzMm7Q/Ne8cGcAge2aEFsWEgIuxXGyjxVmjR/Go5y0IUY+G7xSIBi0Mhyu+ALxiRvX 4gBjRILExVrjBThxaT5cCeDYBs71Sa92/DoM6RnmzQHerM7XUXgGNsSDzRJ8FKyndXBn uWfgHr5SKmNCZontQ8mb5dN+8SaTdvEItBdKLuYjp6ClwBn5ufLT1l8yzgheVh1yXgBw ijHwYYEuE9jJuldAc0GDf2zEKDDaCbLHG2vS8Ym+3ztlEvS/YUBokgn2WRqZMDS00Xhl kfYybISZQTB+oAvPHJDIdVsld9IUR2i6L3txyZr5oxHRiVsMa196g6oKK9aoCT3bFa2+ ZzfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hbfDX9OD; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p8si36476819plq.53.2019.08.03.20.50.28; Sat, 03 Aug 2019 20:50:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-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=@gmail.com header.s=20161025 header.b=hbfDX9OD; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726363AbfHCOp2 (ORCPT + 99 others); Sat, 3 Aug 2019 10:45:28 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:37845 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725844AbfHCOp2 (ORCPT ); Sat, 3 Aug 2019 10:45:28 -0400 Received: by mail-io1-f65.google.com with SMTP id q22so38842981iog.4 for ; Sat, 03 Aug 2019 07:45:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=YS30pX18B3aa2CR0VFk8ZSOQuGrmZb4Lf3ojhHX1NEw=; b=hbfDX9OD/Oc+uxb0gpMxYKUw1N3zzZC6rJ5XEwX8YX6Fy+n9GXpQsA+BkwyTcTJzpM FKQY60B+fwhBBfczqYNdYiT1PDUcaV7PX26rC/lAgkVh/tA8QFWtC0kOYw2wtPo5E5aw SEuo2UmGtgw0mWtnkrmspusXutB/TSW/p8VBT9Vxh+8e+mC3/xCu2g0Q1Rek3SttLIG1 c1sPGBvyYAsWwIY58lOX/k7w+ytHgW9h8hXgEZW76Nwx7zLA51Cb6kMJ/6kKsv2wwGdg m9Vhqp9QabivoYBf0ws9yvV2j1t9PoSh7W3sb1fv2hQGUA2pWYGWG/ZRnAEUbtXjSdZk MTKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=YS30pX18B3aa2CR0VFk8ZSOQuGrmZb4Lf3ojhHX1NEw=; b=abCYx1AHUQV0h5BBVJKtXx2rUdQv8SBj74h/Qpwg60Sbj6683ZNKBWsDnoTJRW6hPj 9Xlp/t2tVXaZkCDwxn8BqrBMjqLClJHVWbED84MPi55nBiNh9AoGX3Ne9IMe5yT76+58 VRYjJpXaa+E8GlLAeFkIrguufSUEGwPGAgfO/oTWsqlkwsbPqjNdSVkjqJQM6XfAlgM+ vTSIKc25tkJmuM3WwJNusOp9EIsxauvlq7EFQhsiZ2TEt4obZaZXUL9b0A9I7zXAb/N+ Dy+UyPtgxHcRP9cBfcXclfXeZjnXV3+scCIWwg91d8i5uyOiIR/6ZbUQI4zDvYYhcbQW LwVg== X-Gm-Message-State: APjAAAVU3E4SAkIoD3qEAl3DGOvCZ71YPpDWoP2luhgtwppCB7ytSH8P 5/umL185vks+KzEH/Y8J3HBdE2w= X-Received: by 2002:a5d:964d:: with SMTP id d13mr7413447ios.224.1564843527460; Sat, 03 Aug 2019 07:45:27 -0700 (PDT) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id n21sm55031059ioh.30.2019.08.03.07.45.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 07:45:26 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Olga Kornievskaia Cc: linux-nfs@vger.kernel.org Subject: [PATCH] NFSv4: Fix an Oops in nfs4_do_setattr Date: Sat, 3 Aug 2019 10:43:20 -0400 Message-Id: <20190803144320.15276-1-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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+ --- fs/nfs/nfs4proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 3e0b93f2b61a..12b2b65ad8a8 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -3214,7 +3214,7 @@ static int _nfs4_do_setattr(struct inode *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; -- 2.21.0