Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp973007rdh; Sun, 24 Sep 2023 21:51:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGmBjuAKchRdq4CWHQycbWJf5b6NSISnzAR8W0TB++sj7ZnyInjAaYZLG4z4dfccRCOwsSN X-Received: by 2002:a1f:e282:0:b0:495:c10c:ec39 with SMTP id z124-20020a1fe282000000b00495c10cec39mr2538549vkg.2.1695617483540; Sun, 24 Sep 2023 21:51:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695617483; cv=none; d=google.com; s=arc-20160816; b=dPm9rqFoawj9euSKnr7DQN8UACXGY2gsV6/7tDzaMfRt4BMD3/84gmKjkr1kaYBTLW gnhL4GS2vjW7xe4QlUFqe7R0JZJRVSw6irJgMzz8zFTvW4416DG8k/Jo5yNPleECBKv/ 0209pU09ENrSc2qlv5R8+d7IzIarkCSQ5ghcZLglCM3aoHVACT1+7BJ4P4rYN28MPniR 4ZuaO90vk7otcm6RYpP/csdF8Wxmmoa6C198vOS85dgu5eJSdbDQAMizV1Ob8eDR40ev ny7EJt7gXaok+d+PuRWW0Jfxe89BKhBMhCfwP5/MLXqD4yafzZMIbZsJlL2KS1PUVE/e lWmQ== 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=euxyBneGEkl7SN2gRn/2hwS/IQlqBLN70gcSW7aaamY=; fh=ATaqw6dllp58NUNG/WmbAor3ywmvmjrkY8rTs6GNuCc=; b=GKVWG6dF+E0Rw/V4DyLIe7QyAGvTcJzwESvGJ90wcu/53R9hqEJ8JwK/Pk8bVLxhX8 uMirjfLVWyC7+bYqc59+8XFKTB5Y7wt29igBOIdTohpAnc+Kkfx4mT7k/7on5XenjHhw NU76J4MwY6eo8ST8z5of9LIiY/b7AWr7nodsK94b72LT3b1H+A87Ai6iunFtsx7M0kos 9fF0Z218covbekI3PFYrBt74zcZ3M5kv+dQTE4Y1p6/XkmDUtTT7dUIVoRCJXQguz5ub 774aqyN/tO5ceEiV8I5IaNa/rycUbapCoes/HMmCbv51MonsRtIEfMZr4Z35dN6n8gOT 8I9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id e22-20020aa78c56000000b0068fc7938a28si8777124pfd.397.2023.09.24.21.51.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 21:51:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id BF6798028FEE; Sun, 24 Sep 2023 21:51:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231742AbjIYEvW (ORCPT + 99 others); Mon, 25 Sep 2023 00:51:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229578AbjIYEvV (ORCPT ); Mon, 25 Sep 2023 00:51:21 -0400 Received: from mail.nfschina.com (unknown [42.101.60.195]) by lindbergh.monkeyblade.net (Postfix) with SMTP id BD11EC2; Sun, 24 Sep 2023 21:51:14 -0700 (PDT) Received: from localhost.localdomain (unknown [180.167.10.98]) by mail.nfschina.com (Maildata Gateway V2.8.8) with ESMTPA id 62A466047A8C6; Mon, 25 Sep 2023 12:51:12 +0800 (CST) X-MD-Sfrom: suhui@nfschina.com X-MD-SrcIP: 180.167.10.98 From: Su Hui To: miklos@szeredi.hu, amir73il@gmail.com Cc: Su Hui , linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] ovl: avoid possible NULL dereference Date: Mon, 25 Sep 2023 12:51:00 +0800 Message-Id: <20230925045059.92883-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=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sun, 24 Sep 2023 21:51:21 -0700 (PDT) smatch warn: fs/overlayfs/copy_up.c:450 ovl_set_origin() warn: variable dereferenced before check 'fh' (see line 449) If 'fh' is NULL, passing NULL instead of 'fh->buf'. Signed-off-by: Su Hui --- fs/overlayfs/copy_up.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index d1761ec5866a..086f9176b4d4 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -446,7 +446,7 @@ int ovl_set_origin(struct ovl_fs *ofs, struct dentry *lower, /* * Do not fail when upper doesn't support xattrs. */ - err = ovl_check_setxattr(ofs, upper, OVL_XATTR_ORIGIN, fh->buf, + err = ovl_check_setxattr(ofs, upper, OVL_XATTR_ORIGIN, fh ? fh->buf : NULL, fh ? fh->fb.len : 0, 0); kfree(fh); -- 2.30.2