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=-10.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 AE77CC433DF for ; Thu, 30 Jul 2020 08:06:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8BAF520672 for ; Thu, 30 Jul 2020 08:06:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596096419; bh=K5aBS55JE6VtwoSOv+SygI2MN+/rTkdczaXYheTbwsY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=qmPImdMM9VuqCZ1eOi6EgN3ToRiBjzo9Qym9STyEkmAwmcRtyi4UOdv7mZCbexS1Y chID9C0dQ4EoyQMwzTFvj5uHaCGbz8pW9Lb86ePwpuXalEbXYTuiWNTZBGdcagq3fW POGn3gL9pW0mJ+NWcl28ur2A/Y1KikIDtiFwsCPM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729124AbgG3IGv (ORCPT ); Thu, 30 Jul 2020 04:06:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:44412 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729268AbgG3IGu (ORCPT ); Thu, 30 Jul 2020 04:06:50 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 1F09820672; Thu, 30 Jul 2020 08:06:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596096409; bh=K5aBS55JE6VtwoSOv+SygI2MN+/rTkdczaXYheTbwsY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TvNJOqWqQ+/uCSOVJgoKt0tMFqZFZodnaqopX7SKFEQUygsSjgCAsoTlOIpkHSj/K agpnfYjK9bl1bW+Z0vwlW10tieQ8KJMig9tGy5GLUE9Cxyry4BgosiPHAlcst8fMaG INwCwSFmQxY/fb0/WYZymVbmj3uOpmYtKhk1SAFE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+c82752228ed975b0a623@syzkaller.appspotmail.com, Peilin Ye , "David S. Miller" Subject: [PATCH 4.19 01/17] AX.25: Fix out-of-bounds read in ax25_connect() Date: Thu, 30 Jul 2020 10:04:27 +0200 Message-Id: <20200730074420.528010553@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200730074420.449233408@linuxfoundation.org> References: <20200730074420.449233408@linuxfoundation.org> User-Agent: quilt/0.66 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Peilin Ye [ Upstream commit 2f2a7ffad5c6cbf3d438e813cfdc88230e185ba6 ] Checks on `addr_len` and `fsa->fsa_ax25.sax25_ndigis` are insufficient. ax25_connect() can go out of bounds when `fsa->fsa_ax25.sax25_ndigis` equals to 7 or 8. Fix it. This issue has been reported as a KMSAN uninit-value bug, because in such a case, ax25_connect() reaches into the uninitialized portion of the `struct sockaddr_storage` statically allocated in __sys_connect(). It is safe to remove `fsa->fsa_ax25.sax25_ndigis > AX25_MAX_DIGIS` because `addr_len` is guaranteed to be less than or equal to `sizeof(struct full_sockaddr_ax25)`. Reported-by: syzbot+c82752228ed975b0a623@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?id=55ef9d629f3b3d7d70b69558015b63b48d01af66 Signed-off-by: Peilin Ye Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ax25/af_ax25.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c @@ -1190,7 +1190,9 @@ static int __must_check ax25_connect(str if (addr_len > sizeof(struct sockaddr_ax25) && fsa->fsa_ax25.sax25_ndigis != 0) { /* Valid number of digipeaters ? */ - if (fsa->fsa_ax25.sax25_ndigis < 1 || fsa->fsa_ax25.sax25_ndigis > AX25_MAX_DIGIS) { + if (fsa->fsa_ax25.sax25_ndigis < 1 || + addr_len < sizeof(struct sockaddr_ax25) + + sizeof(ax25_address) * fsa->fsa_ax25.sax25_ndigis) { err = -EINVAL; goto out_release; }