Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp647272rwo; Wed, 2 Aug 2023 01:39:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlEbpzSdUKUATPABgYmcoMIy8wCGXPFKy2IlrVunD7U1XOsunTyvbAwE/kusGdHHD+BQJ7XP X-Received: by 2002:a2e:8643:0:b0:2b6:effd:9a3b with SMTP id i3-20020a2e8643000000b002b6effd9a3bmr4449815ljj.24.1690965576138; Wed, 02 Aug 2023 01:39:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690965576; cv=none; d=google.com; s=arc-20160816; b=d062WCHRd7leq/cch1LISrZ+AHHWIXSTH8m1FI2i1f4qFudEyaWrXIuWj03STbN9rj qu3DZJKsV8WkU64+/pF0QNOtbnOhT3FglbkWzkdBgLuIqNWzPyG3Fatzs3CRF4VxdObi mpze/xS1LrrM8tk8ulSRSi1tjh/XkUxdNstPFC3H7GmIpXUuxAK20UKno+KfnqFH5hK+ DTS6Rf7Go7N8JTSg550RtoquqQm/bTUoL3n95Hau86kh6xridy7K9RWsoQ71NCZP8pVA p1xJoe9wSKCfX053Ha5KNY6FqdevY0WI/paodFn67OcZGK0suyUsCWJ9bA8CenWfpDQK eO9g== 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:from; bh=UjwNXZk3VbSJZWHdItXhGoUHdmXq98BQrqpiFHu8ASc=; fh=EZ0hl8p0yJa/HYmF9VrmlK3W0hs1tZC9UcbJyGq5A7Y=; b=lUj60QZjF3WDGm/0L6HRWua2hlqk3bhjB8TFhsEASSi0SHmh/MEwfW2p+q+sMcygDw 0pFa5SM4byxVYkkM8kns8bXF2m9Gg8TIVmlNxErbFKsOSm7h8e3QUbyKc5ecjgSb8gev zjofBmPh7dR1P+ZmFpPxw32Qt2Z0Yh9RvZI48DiqxyGz3Cnhy1Yhp6lvKgMeG8ryglFf IadfO8Bl/G8RIg7FkPsPfL0NEE0KhtELAf7UHL2p7GkUGSng8N3njsVA6Pfbt50Vi1Ut amVLDmbEY5A15cn0TI/DtsiJEKeXSBdIfTVAIheYy6+Mf2FxKi88/4YV5ZW7cYScGHK6 dXzQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cb23-20020a170906a45700b00993a37afc87si10109041ejb.919.2023.08.02.01.39.05; Wed, 02 Aug 2023 01:39:36 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230517AbjHBIG1 (ORCPT + 99 others); Wed, 2 Aug 2023 04:06:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232756AbjHBIG0 (ORCPT ); Wed, 2 Aug 2023 04:06:26 -0400 Received: from mail.nfschina.com (unknown [42.101.60.195]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 8F516F7; Wed, 2 Aug 2023 01:06:23 -0700 (PDT) Received: from localhost.localdomain (unknown [180.167.10.98]) by mail.nfschina.com (Maildata Gateway V2.8.8) with ESMTPA id A65DE606AC671; Wed, 2 Aug 2023 16:06:10 +0800 (CST) X-MD-Sfrom: suhui@nfschina.com X-MD-SrcIP: 180.167.10.98 From: Su Hui To: chuck.lever@oracle.com, jlayton@kernel.org, neilb@suse.de, kolga@netapp.com, Dai.Ngo@oracle.com, tom@talpey.com, trond.myklebust@hammerspace.com, anna@kernel.org, nathan@kernel.org, ndesaulniers@google.com, trix@redhat.com Cc: bfields@fieldses.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, kernel-janitors@vger.kernel.org, Su Hui Subject: [PATCH] fs: lockd: avoid possible wrong NULL parameter Date: Wed, 2 Aug 2023 16:05:45 +0800 Message-Id: <20230802080544.3239967-1-suhui@nfschina.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_PASS,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 clang's static analysis warning: fs/lockd/mon.c: line 293, column 2: Null pointer passed as 2nd argument to memory copy function. Assuming 'hostname' is NULL and calling 'nsm_create_handle()', this will pass NULL as 2nd argument to memory copy function 'memcpy()'. So return NULL if 'hostname' is invalid. Fixes: 77a3ef33e2de ("NSM: More clean up of nsm_get_handle()") Signed-off-by: Su Hui --- fs/lockd/mon.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c index 1d9488cf0534..eebab013e063 100644 --- a/fs/lockd/mon.c +++ b/fs/lockd/mon.c @@ -358,6 +358,9 @@ struct nsm_handle *nsm_get_handle(const struct net *net, spin_unlock(&nsm_lock); + if (!hostname) + return NULL; + new = nsm_create_handle(sap, salen, hostname, hostname_len); if (unlikely(new == NULL)) return NULL; -- 2.30.2