Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5995173pxb; Mon, 14 Feb 2022 12:40:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJyGi/uYy+YqVDMVw5GMzim0xvRV7XCWKbE4ylNAN7Lp4BVQ5Fi1wods+fC4sRdHaQ/5i++K X-Received: by 2002:a63:4813:: with SMTP id v19mr680287pga.115.1644871211317; Mon, 14 Feb 2022 12:40:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644871211; cv=none; d=google.com; s=arc-20160816; b=WSyQiBozHPw0dfXNjD7W5kQ2I6VxisxKMVyFt6aZn+0I6OteOGw9GmeADA+jMOAcPv BvM8g99PqDipA3oDjT9hy7q39SIUzqPDixJXGj4jNJlE9HAwyFxKpxs+IHXD+cFVZUs6 kS0MIwefTgrmWk83wH0ja82FDb9iQT5k3jHuDTMIbrZto1b01dzIw9DlFF3kqowffbM6 fqX2mus+fPFU202sOimfUggZ93y4zxCVcpVO/CWElEJGUnmvrDGB/2zh6qqppj9+q5e5 lJu6WHQ1JJPWBEzsb2ofQ7aHMPnOYaeJOV7rcNBD+2SypmqbIHoqSwg9gYc0ixNU1IIF Hg9Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=K0PS84dap5Y2b1yxhqPhjswud8QvhliRvg6PhwU0U4I=; b=TPKWY7UqoKFQWEDRMN1Mh6PikJK5fur1L0zV4uCKDNSwCInZEXqXG2GhC/gHsxIpAf AXfS38FSG+oC8ouLQkI0npdkCmk8IP8hNBTeKHrfeEvY3+MgPiqsN/KFTXqIlYK3jQnp 48TFeSDKmyWDkiLdLX6kFcAfrv+N547uI0PJPxpaJwyFuv9EuPFWP9sBRR7R92L7StYu CLFmySFct3xFYWCyChaznr770bzsalW9K4mAyuFpIfmwplpmXh7BYU1ZU5mD8QaBNLJs rqdGvzj3npzftefnZxHGE7w3/vVY/WGzCbvlDRy8Glp24nQ/WvkgbVchIC8Usb8/1txn AipA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jFD3f0I+; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id z24si711116pgv.228.2022.02.14.12.40.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 12:40:11 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jFD3f0I+; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D3DB815694E; Mon, 14 Feb 2022 12:08:29 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244075AbiBNJek (ORCPT + 99 others); Mon, 14 Feb 2022 04:34:40 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244012AbiBNJeM (ORCPT ); Mon, 14 Feb 2022 04:34:12 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27AD225E96; Mon, 14 Feb 2022 01:32:23 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5CFDEB80DC6; Mon, 14 Feb 2022 09:32:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8194EC340EF; Mon, 14 Feb 2022 09:32:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644831141; bh=bai/vVg0+Sd0GkjYwKHHvpvysjdO9TLTFG2KhA14s1A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jFD3f0I+rcWgWSa73Hqi1a9KRr84cKBTTv6kAnEBcnoT5Y0sJA/84tUIW+VYlQw0d IrL9SKPaLJKMBaFaXCzkp6PTa8v/nl4pukp+FAu2Ngqjs8w7+BrOd0w3owm+XYQfxK AReAmuH3+25z4cZ/iqv0RMRw0J8KRuenKeZanqdA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, rtm@csail.mit.edu, Trond Myklebust , Anna Schumaker , Sasha Levin Subject: [PATCH 4.19 11/49] NFSv4.1: Fix uninitialised variable in devicenotify Date: Mon, 14 Feb 2022 10:25:37 +0100 Message-Id: <20220214092448.673057752@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220214092448.285381753@linuxfoundation.org> References: <20220214092448.285381753@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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: X-Mailing-List: linux-kernel@vger.kernel.org From: Trond Myklebust [ Upstream commit b05bf5c63b326ce1da84ef42498d8e0e292e694c ] When decode_devicenotify_args() exits with no entries, we need to ensure that the struct cb_devicenotifyargs is initialised to { 0, NULL } in order to avoid problems in nfs4_callback_devicenotify(). Reported-by: Signed-off-by: Trond Myklebust Signed-off-by: Anna Schumaker Signed-off-by: Sasha Levin --- fs/nfs/callback.h | 2 +- fs/nfs/callback_proc.c | 2 +- fs/nfs/callback_xdr.c | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/fs/nfs/callback.h b/fs/nfs/callback.h index 8f34daf85f703..5d5227ce4d91e 100644 --- a/fs/nfs/callback.h +++ b/fs/nfs/callback.h @@ -168,7 +168,7 @@ struct cb_devicenotifyitem { }; struct cb_devicenotifyargs { - int ndevs; + uint32_t ndevs; struct cb_devicenotifyitem *devs; }; diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c index bcc51f131a496..868d66ed8bcf6 100644 --- a/fs/nfs/callback_proc.c +++ b/fs/nfs/callback_proc.c @@ -364,7 +364,7 @@ __be32 nfs4_callback_devicenotify(void *argp, void *resp, struct cb_process_state *cps) { struct cb_devicenotifyargs *args = argp; - int i; + uint32_t i; __be32 res = 0; struct nfs_client *clp = cps->clp; struct nfs_server *server = NULL; diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c index 57558a8d92e9b..76aa1b456c524 100644 --- a/fs/nfs/callback_xdr.c +++ b/fs/nfs/callback_xdr.c @@ -268,11 +268,9 @@ __be32 decode_devicenotify_args(struct svc_rqst *rqstp, void *argp) { struct cb_devicenotifyargs *args = argp; + uint32_t tmp, n, i; __be32 *p; __be32 status = 0; - u32 tmp; - int n, i; - args->ndevs = 0; /* Num of device notifications */ p = read_buf(xdr, sizeof(uint32_t)); @@ -281,7 +279,7 @@ __be32 decode_devicenotify_args(struct svc_rqst *rqstp, goto out; } n = ntohl(*p++); - if (n <= 0) + if (n == 0) goto out; if (n > ULONG_MAX / sizeof(*args->devs)) { status = htonl(NFS4ERR_BADXDR); @@ -339,19 +337,21 @@ __be32 decode_devicenotify_args(struct svc_rqst *rqstp, dev->cbd_immediate = 0; } - args->ndevs++; - dprintk("%s: type %d layout 0x%x immediate %d\n", __func__, dev->cbd_notify_type, dev->cbd_layout_type, dev->cbd_immediate); } + args->ndevs = n; + dprintk("%s: ndevs %d\n", __func__, args->ndevs); + return 0; +err: + kfree(args->devs); out: + args->devs = NULL; + args->ndevs = 0; dprintk("%s: status %d ndevs %d\n", __func__, ntohl(status), args->ndevs); return status; -err: - kfree(args->devs); - goto out; } static __be32 decode_sessionid(struct xdr_stream *xdr, -- 2.34.1