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 X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3849CC4742C for ; Tue, 3 Nov 2020 21:33:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F13042236F for ; Tue, 3 Nov 2020 21:33:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604439201; bh=tojmaWMUV3iy/cP86K61ACVA+41ZaEcguQ0S7Wdq04Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=a1PntrNqVvy9x/kv9+pDcXWKbQ8D+19qkZfeH0KjpVB+yEp4uYxjjibWsd7hMo8r4 P+xCZ01hjqUN6z9dJ2jZAnhF+jNYAKbnzcRCU3nnAeqFIs/flCOjijK8U+AVN0dAGW kJak7T1q5PKvA4ZtM+4RcGgLdM3/xFmsg08qpKd4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732009AbgKCVcS (ORCPT ); Tue, 3 Nov 2020 16:32:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:59398 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730386AbgKCU5N (ORCPT ); Tue, 3 Nov 2020 15:57:13 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EDBAE22226; Tue, 3 Nov 2020 20:57:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437032; bh=tojmaWMUV3iy/cP86K61ACVA+41ZaEcguQ0S7Wdq04Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UO6lLcGN8sT4ygLRmb6H+YsGao7ZwghNIxtt/r7iHvfXxUFJIOS9x0KWkSSRcpyMp AMlkOSpu2W883p2ceN2mBfdwAFDJsJpyFyZYY5V2+eWuGgv3vIL4o8HMTs/KDdWXg/ OFsIVxl6nSfm9sotpanade2RZUB0DKZqX2Y352R0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+75d51fe5bf4ebe988518@syzkaller.appspotmail.com, Anant Thazhemadam , Dominique Martinet , Sasha Levin Subject: [PATCH 5.4 079/214] net: 9p: initialize sun_server.sun_path to have addrs value only when addr is valid Date: Tue, 3 Nov 2020 21:35:27 +0100 Message-Id: <20201103203257.770567375@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Anant Thazhemadam [ Upstream commit 7ca1db21ef8e0e6725b4d25deed1ca196f7efb28 ] In p9_fd_create_unix, checking is performed to see if the addr (passed as an argument) is NULL or not. However, no check is performed to see if addr is a valid address, i.e., it doesn't entirely consist of only 0's. The initialization of sun_server.sun_path to be equal to this faulty addr value leads to an uninitialized variable, as detected by KMSAN. Checking for this (faulty addr) and returning a negative error number appropriately, resolves this issue. Link: http://lkml.kernel.org/r/20201012042404.2508-1-anant.thazhemadam@gmail.com Reported-by: syzbot+75d51fe5bf4ebe988518@syzkaller.appspotmail.com Tested-by: syzbot+75d51fe5bf4ebe988518@syzkaller.appspotmail.com Signed-off-by: Anant Thazhemadam Signed-off-by: Dominique Martinet Signed-off-by: Sasha Levin --- net/9p/trans_fd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c index 12ecacf0c55fb..60eb9a2b209be 100644 --- a/net/9p/trans_fd.c +++ b/net/9p/trans_fd.c @@ -1023,7 +1023,7 @@ p9_fd_create_unix(struct p9_client *client, const char *addr, char *args) csocket = NULL; - if (addr == NULL) + if (!addr || !strlen(addr)) return -EINVAL; if (strlen(addr) >= UNIX_PATH_MAX) { -- 2.27.0