Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp626489pxx; Mon, 26 Oct 2020 17:20:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVi1fdJa+iNnB+tUAnu1CT6qJXAQSEJxz4gaNZMETglkOt2C3Gw9UHw4Io/JgTBC8V3QK3 X-Received: by 2002:a17:906:118f:: with SMTP id n15mr19181378eja.394.1603758018983; Mon, 26 Oct 2020 17:20:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603758018; cv=none; d=google.com; s=arc-20160816; b=QNAnlNNxFdMPdNLZKXXUK1qunA8nMMbFvGl4JTAt08vzjvd3RQE236pmluxYQ7aL7w 8lSYbFxQ1eP30M27itVB3wtu+OxEQLVVu9cp+xU8G+ffxEpXXoTWAL8y61hNGHUujLGh olDcC4Dzyt8R+xwawvTAAMMCZWQlZ+zsbKcsakSPmGtZQPJ93m7z2DvcsWcb3PrgbfrV +msgm4iRPN7rk9FajLG32jTKoV23RkapirxvbwHcZzkhQ9UWJFiF5fAwVzYnP5LzUEFL VBNkiNJ7j1632ToUGhOHTYbnDiE6krWcgvUcTYyuNTCtNsjepL8pIWAWiETY+hYO+wGp 6qNw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SVhEBJMT+gi8Vd5Aq+k7ylEVlRV38iWww+oqMrUqzLg=; b=F5Y+z3GmnWRGCleUQwa3ivN9gZZ9Jxj6NF3mjSxorwtHlMqgt5CXQ6Qnu352OEJOc8 iKiF4rm/mh6CTbN3vbaFsb0mq5m0xeRzYtzpZ8VqgyW9lFsMvcS/kj477NeS4zsgSu3G OeT5e3+GHeT8cPK+09UIfbxlU4JP5OHDUKZ7kMJwCTkqL8pkA3clA3ZCjYAwyBi30lCh gSdBA8oLZIF655e8zW5qatZcAXRC/n/jo9Rt3ymoseiAC8oXyE5Vrkrq8M7PFb9pGRG7 K3IyW+927CbSeTsXtXlJ2uVTN6IMVaJs6dbDpkmBYfvSjh7t4fQYQ9ed6q1G6A2NPF09 fKAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sdDY8qBB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t6si8129745edy.233.2020.10.26.17.19.57; Mon, 26 Oct 2020 17:20:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sdDY8qBB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437286AbgJ0AA4 (ORCPT + 99 others); Mon, 26 Oct 2020 20:00:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:36496 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436484AbgJZX4d (ORCPT ); Mon, 26 Oct 2020 19:56:33 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C380220B1F; Mon, 26 Oct 2020 23:56:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756592; bh=SjerEqdv/XdKad4bUN4LsYPOCOZGVRCpnot5rfzuTGU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sdDY8qBB9KnOrvNMkv6tRNAJRQBT2+k50uOJEO5RjmJM8DatBQNMMy/toJLApak4U 1br3scIwG8fIuMwBu8I8pTTAcpZcLy40ALcKkz9+CcyMo7yQbRjHd//44adhTJ2rCv YEZSDNs3MbA23FE4E/g4wzEFW/GKATKECKajSADw= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Anant Thazhemadam , syzbot+75d51fe5bf4ebe988518@syzkaller.appspotmail.com, Dominique Martinet , Sasha Levin , v9fs-developer@lists.sourceforge.net, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 63/80] net: 9p: initialize sun_server.sun_path to have addr's value only when addr is valid Date: Mon, 26 Oct 2020 19:54:59 -0400 Message-Id: <20201026235516.1025100-63-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026235516.1025100-1-sashal@kernel.org> References: <20201026235516.1025100-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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.25.1