From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E202CE79CF for ; Wed, 20 Sep 2023 12:03:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235109AbjITMDL (ORCPT ); Wed, 20 Sep 2023 08:03:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235158AbjITMDI (ORCPT ); Wed, 20 Sep 2023 08:03:08 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60C59AD for ; Wed, 20 Sep 2023 05:03:00 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E2C8C433CB; Wed, 20 Sep 2023 12:02:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1695211379; bh=4+tXXP3sEvaFA3GyL91BA7vL9CptbOMiexoNFf2FRhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pm3ONvm/eRMPuF0j5wSi7GXnUbE763M7JFTRMaTPyIraxAJ9WIU6Ikcw+3WCNimvg +v9QAUbCG5vIm9nwz9niSeD/r9wrhkA5RszjCXW97t2ukFz0jyvcdIe7pF8ltacK3I YmZ+qXWZ3yJGmn9QRAyqIXNEb610pCRIp35NZJhg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Su Hui , Nick Desaulniers , Jeff Layton , Chuck Lever , Sasha Levin Subject: [PATCH 4.14 071/186] fs: lockd: avoid possible wrong NULL parameter Date: Wed, 20 Sep 2023 13:29:34 +0200 Message-ID: <20230920112839.431456302@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230920112836.799946261@linuxfoundation.org> References: <20230920112836.799946261@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Su Hui [ Upstream commit de8d38cf44bac43e83bad28357ba84784c412752 ] 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 Reviewed-by: Nick Desaulniers Reviewed-by: Jeff Layton Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin --- fs/lockd/mon.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c index 9fbbd11f9ecbb..4a2da67fc255c 100644 --- a/fs/lockd/mon.c +++ b/fs/lockd/mon.c @@ -274,6 +274,9 @@ static struct nsm_handle *nsm_create_handle(const struct sockaddr *sap, { struct nsm_handle *new; + if (!hostname) + return NULL; + new = kzalloc(sizeof(*new) + hostname_len + 1, GFP_KERNEL); if (unlikely(new == NULL)) return NULL; -- 2.40.1