Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2090512ybp; Thu, 10 Oct 2019 02:01:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqz34ZGpifbh2Cz7vSxJQoITwO0XEObR5QO6j0t0DZEZFgKN5E1w12e43qiMshhBXmm14OXr X-Received: by 2002:aa7:df86:: with SMTP id b6mr7019817edy.107.1570698110433; Thu, 10 Oct 2019 02:01:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570698110; cv=none; d=google.com; s=arc-20160816; b=nWdVwzvvjIryH/niUmAzynUHg+0ub66rWNaCHVKWamTOIT//SBmmEIPpXmZrwAdA/J bMYDhKxz65zFuExwpDNyiK7V0BHcICWop6YQoDNUz++n2If5YzMIHCUKdqfD9wCVNBAF eBNTjY/gNrKjvXX5UGVeH+uTfkuCM7b0pQ7K1kAj1R8ITpfptd4r/+jrFjah4Bk1g8qC trvQ33zhsVDhjIRtvX1ioOP55yaLWHd8FoOVWhRluvyMwMWWMf2tHIkB9JmjQDoTKBFy VaY0pbos8TfPVaEuEmW2KINgBk6iYkL0jrbATOWd2eYh0jPUS7S5YRC67GUXoRIf7vEI ooqQ== 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=1YinjdZUwY7ad+JRCuG1N/mU6/bGBj2V6FGDvE+E0Hg=; b=of0McQRM/ZiaKQKywlWIQSJdwhR63H22WczYyw/mzFl3YUzfAV4OEbNg5NUV0ZxhP1 okYPym4sJbwUrVsTdOoZycZoFhD4C6N4RIZOlmRy9WISyWP5YohJNBicac/iWbK1PgTH DwjAaNZxb+jUbOsHI/gzlWi7arhpEZe7OJyHp+e/GGFE71kw7/hCGAlD5xqTyyA04sSI D/xI5z7rmpweTWDUvjfF4onGG4otZD1Lk4XeFOj7m4d8W3Y0CH8bIeh/bF8vLWeWCggH 7sjeTN0/PAcyT52u66XGRBix72rBBQRo8jSKFzVwafWtud89WnwTu3JUqQyYFI5jCAW9 Bkyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I2yIbwTV; 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 k7si2939283edb.238.2019.10.10.02.01.27; Thu, 10 Oct 2019 02:01:50 -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=I2yIbwTV; 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 S2387661AbfJJIlc (ORCPT + 99 others); Thu, 10 Oct 2019 04:41:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:45914 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388348AbfJJIla (ORCPT ); Thu, 10 Oct 2019 04:41:30 -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 91ABB2054F; Thu, 10 Oct 2019 08:41:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570696890; bh=iqzG08jXsqIalfCrOb0Aw/LP+MoyhvRy0gqBfWrP+Q8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I2yIbwTVX9/iMileneQxCdgEKfWcOhKGb4QA1MtZrOg6A7AQQWvSkWOpxv2+01qGJ 6UkxVz+fXWRluXjQzkoFdMnDzK7a4/xvSqj4LTbOnKCdyQYq1aSspOVTi8TiVo0/Gi 44LUB3qx20ukzBg7urfEX11aJY8ZjTQDfKbvrkD0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jia-Ju Bai , Anna Schumaker , Sasha Levin Subject: [PATCH 5.3 091/148] fs: nfs: Fix possible null-pointer dereferences in encode_attrs() Date: Thu, 10 Oct 2019 10:35:52 +0200 Message-Id: <20191010083616.838476759@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010083609.660878383@linuxfoundation.org> References: <20191010083609.660878383@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: Jia-Ju Bai [ Upstream commit e2751463eaa6f9fec8fea80abbdc62dbc487b3c5 ] In encode_attrs(), there is an if statement on line 1145 to check whether label is NULL: if (label && (attrmask[2] & FATTR4_WORD2_SECURITY_LABEL)) When label is NULL, it is used on lines 1178-1181: *p++ = cpu_to_be32(label->lfs); *p++ = cpu_to_be32(label->pi); *p++ = cpu_to_be32(label->len); p = xdr_encode_opaque_fixed(p, label->label, label->len); To fix these bugs, label is checked before being used. These bugs are found by a static analysis tool STCheck written by us. Signed-off-by: Jia-Ju Bai Signed-off-by: Anna Schumaker Signed-off-by: Sasha Levin --- fs/nfs/nfs4xdr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 46a8d636d151e..ab07db0f07cde 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -1174,7 +1174,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, } else *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); } - if (bmval[2] & FATTR4_WORD2_SECURITY_LABEL) { + if (label && (bmval[2] & FATTR4_WORD2_SECURITY_LABEL)) { *p++ = cpu_to_be32(label->lfs); *p++ = cpu_to_be32(label->pi); *p++ = cpu_to_be32(label->len); -- 2.20.1