Message ID | 20221206092653.28911-1-arefev@swemel.ru |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2720605wrr; Tue, 6 Dec 2022 01:32:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf5isHfK72CUZ5H8rIheUxb8beVeA8zLll5jhXGe8yibp5eU2IVFQHkOPXvZdX1kogp6qadk X-Received: by 2002:a17:902:c755:b0:189:58a8:862c with SMTP id q21-20020a170902c75500b0018958a8862cmr58721239plq.163.1670319159805; Tue, 06 Dec 2022 01:32:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670319159; cv=none; d=google.com; s=arc-20160816; b=Dot0PVRlODVVyKJ+KxdfT+lSCGkomas52gzcv6XDtqFpJcX5A+yPIui3i3MyLDM8pM exSfXlDDtCHB8xrdM3wfJ+eUpHZ4+ejgRYJD9nTLBrXx+kuL2pvukdd1EmSVs9ZVjxQ/ E+dzh6PN4Vyen1UJYIH7WGK5tW1UWULu0z2JB6Di/hCpO3199BsIiUDNqVy0VSIWRd2b SZxf/1agHOnA3XibP57UW/EsbBUZI0KXvo6hwvfmt7T+sn/KB/q7rQThCY+C2Ps6LBVB 4RSGiAT00lGL2KB55KfCd7iCZD3eo/9wxEzDCkMUQVCQzjwxnKiOk9erUR2mn38iwiu3 rlHA== 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:dkim-signature:from; bh=blRdAMFznuYVK4JcJGOwO8LzBNymOBAcYfVJJpwIUoM=; b=j4Vl7zlAUS1JSHtK0aFn24QYrJ6+ekSCpaLdh/di5JvId+cA2opJq01Wdi3jtT6aML veHt+krPWc2RQQ62hVCl5RuH0umKl9hTjke46cJjkcp8JHNTe4Ljlk6oYXPnQXaEpGC1 1LV6ElAULP1Zoe9Q8PiS7S6il2ieoAFoRyey4MHwBquPBdu0hKjXPYxDhGkhb44qXOhG WV1dTFZQN8Pab5BDUvesUFhhfL3FX6s50fd+sCqgnPPziZhMStzBANSP8hCXxCGYVNza f26R4n3axxHaQ1QFCudVL7FkAJyc5oyDeoyFfCfrDK1p1fPSNXCJvPBcpNqp2xfzgA6b uw9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@swemel.ru header.s=mail header.b=VXgmNDMW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=swemel.ru Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b6-20020a170902d88600b00188b8cf0859si5789459plz.57.2022.12.06.01.32.25; Tue, 06 Dec 2022 01:32:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@swemel.ru header.s=mail header.b=VXgmNDMW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=swemel.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234838AbiLFJ1O (ORCPT <rfc822;jaysivo@gmail.com> + 99 others); Tue, 6 Dec 2022 04:27:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235034AbiLFJ1B (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 6 Dec 2022 04:27:01 -0500 Received: from mx.swemel.ru (mx.swemel.ru [95.143.211.150]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88698120; Tue, 6 Dec 2022 01:27:00 -0800 (PST) From: Denis Arefev <arefev@swemel.ru> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=swemel.ru; s=mail; t=1670318813; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=blRdAMFznuYVK4JcJGOwO8LzBNymOBAcYfVJJpwIUoM=; b=VXgmNDMWuOmrgj7jvL9Yj+s68mG6Zp92jAfTI2AE1eO34LAvR/yCWdKh4Z5eS5eIef7CXR 2Sn+zO/E917BXdMdlRhQ8OdEMoujy5Pylwn4PScPLnrkmKH9eGlLLOZ+4Cp7VXKeqijfE1 RhP5gwJwLw2pRAnmUzKtVheeD6lWbt8= To: Trond Myklebust <trond.myklebust@hammerspace.com> Cc: Anna Schumaker <anna.schumaker@netapp.com>, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, trufanov@swemel.ru, vfh@swemel.ru Subject: [PATCH] fs: nfs: Added pointer check Date: Tue, 6 Dec 2022 12:26:53 +0300 Message-Id: <20221206092653.28911-1-arefev@swemel.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751456582998704659?= X-GMAIL-MSGID: =?utf-8?q?1751456582998704659?= |
Series |
fs: nfs: Added pointer check
|
|
Commit Message
Denis Arefev
Dec. 6, 2022, 9:26 a.m. UTC
Return value of a function 'xdr_inline_decode' is dereferenced at
nfs4xdr.c:5540 without checking for null,
ut it is usually checked for this function
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Denis Arefev <arefev@swemel.ru>
---
fs/nfs/nfs4xdr.c | 2 ++
1 file changed, 2 insertions(+)
Comments
> On Dec 6, 2022, at 04:26, Denis Arefev <arefev@swemel.ru> wrote: > > Return value of a function 'xdr_inline_decode' is dereferenced at > nfs4xdr.c:5540 without checking for null, > ut it is usually checked for this function > > Found by Linux Verification Center (linuxtesting.org) with SVACE. > > Signed-off-by: Denis Arefev <arefev@swemel.ru> > --- > fs/nfs/nfs4xdr.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c > index c6dbfcae7517..571cc63ecb61 100644 > --- a/fs/nfs/nfs4xdr.c > +++ b/fs/nfs/nfs4xdr.c > @@ -5533,6 +5533,8 @@ static int decode_op_map(struct xdr_stream *xdr, struct nfs4_op_map *op_map) > if (bitmap_words > NFS4_OP_MAP_NUM_WORDS) > return -EIO; > p = xdr_inline_decode(xdr, 4 * bitmap_words); > + if (!p) > + return -EIO; > for (i = 0; i < bitmap_words; i++) > op_map->u.words[i] = be32_to_cpup(p++); > > -- > 2.25.1 > Again… What kernel is this for? The current code was introduced in Linux 5.16, and looks like this: static int decode_op_map(struct xdr_stream *xdr, struct nfs4_op_map *op_map) { if (xdr_stream_decode_uint32_array(xdr, op_map->u.words, ARRAY_SIZE(op_map->u.words)) < 0) return -EIO; return 0; } It does not have the problem you keep trying to report, and you patch doesn’t apply. _________________________________ Trond Myklebust Linux NFS client maintainer, Hammerspace trond.myklebust@hammerspace.com
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index c6dbfcae7517..571cc63ecb61 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -5533,6 +5533,8 @@ static int decode_op_map(struct xdr_stream *xdr, struct nfs4_op_map *op_map) if (bitmap_words > NFS4_OP_MAP_NUM_WORDS) return -EIO; p = xdr_inline_decode(xdr, 4 * bitmap_words); + if (!p) + return -EIO; for (i = 0; i < bitmap_words; i++) op_map->u.words[i] = be32_to_cpup(p++);