Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3376487ybp; Sun, 6 Oct 2019 10:34:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqw0834cpNu50vX+ew/eZ0+jgYLrtI5yY4BeNn0rUHObY9+v3YXybzatS690aoWtWKveyzJL X-Received: by 2002:aa7:dd8e:: with SMTP id g14mr25474794edv.233.1570383276657; Sun, 06 Oct 2019 10:34:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570383276; cv=none; d=google.com; s=arc-20160816; b=e+7mE0HXxX1pJ40QshUFCil5fwBR8JdM0XFN439DUBGdqmVupnsCG2SBl7lQtQEGNq 1p1tbFxlOdifY0SiLZ25/JuwDtLH0IA7ylbxwyQAZxn/lx2W9Q/lP04bQ2jepvOMreeR z37C1SU/sMRB5bfw4JIFHMGcwk6PNc2thht3dUoXwDD/0OnfLLdDyBHuWNgK3Hcxw5eM QUakgOFZSuma9Y2gr01iBadCKfVfDlLZ2d+Pqp7Bz2bFdtVjNkP5vDIMzIZ0jYl60aVm wKzW59cMRPyGCwyKFLDLvQAQna0gLm54N/caSwZTUStcIPpCQdgCEWxMYUGRizCo/Pan B2Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=K28Y/tszM87S8vUYPQDUJZw3a1a7uUXawv2Usvq6tiM=; b=QQQndWimR5AOklS5a9nhnzSV9Hfr/sej5Ow/1y/MiSOX/pXJrF88aWjFyZkkHbtjXz n37ZlOu0c4p8Zsjl/gPBApfyYUr6AymK1wsbw+ZG/u7LZK1lEMjSLN+Nu4ZmsYBO++DL HjVKJDvMGYRCYkErK5XL1efTzRhrX171yJySxcj1rckxJVqa58wiYknEXQxZTCa6NflF sFD1S9IEi3two+ta/C9E5b2TVdY4PxBafMyzXWK87hxOds7IgLQNjoau31nbnnKzM3lo 8PJjsG3pI64g5T8GwL8CXBBWMeOUmk08hmqg8JZMTRnlrY+1j6eilQVR3xS3jlTzPMqm zFcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QJvk9QCt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o12si7412693edc.279.2019.10.06.10.34.12; Sun, 06 Oct 2019 10:34:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QJvk9QCt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729298AbfJFRar (ORCPT + 99 others); Sun, 6 Oct 2019 13:30:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:56728 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726901AbfJFRao (ORCPT ); Sun, 6 Oct 2019 13:30:44 -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 D858A2080F; Sun, 6 Oct 2019 17:30:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570383043; bh=Rfxn0Jyw9+iChjaphz3c7XHtw/BM1cry81LxMvSeVTo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QJvk9QCtBUzNYF3bRpNu5o1UeEISY3MIxbFaR3QrledK+ZtQB2ffBdzjQx8LKB0eh wg++8nl/Qyh8UuGysSxObSw7WcQOjuFTznxOUOYo/dbQvHj6KdjC1+u/7+dnHVX4XW Ss7+YayGQcdoOgQGvj/eAZnSBdQ2bwri6qnzysMc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jia-Ju Bai , Casey Schaufler , Sasha Levin Subject: [PATCH 4.19 065/106] security: smack: Fix possible null-pointer dereferences in smack_socket_sock_rcv_skb() Date: Sun, 6 Oct 2019 19:21:11 +0200 Message-Id: <20191006171150.857654535@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191006171124.641144086@linuxfoundation.org> References: <20191006171124.641144086@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jia-Ju Bai [ Upstream commit 3f4287e7d98a2954f20bf96c567fdffcd2b63eb9 ] In smack_socket_sock_rcv_skb(), there is an if statement on line 3920 to check whether skb is NULL: if (skb && skb->secmark != 0) This check indicates skb can be NULL in some cases. But on lines 3931 and 3932, skb is used: ad.a.u.net->netif = skb->skb_iif; ipv6_skb_to_auditdata(skb, &ad.a, NULL); Thus, possible null-pointer dereferences may occur when skb is NULL. To fix these possible bugs, an if statement is added to check skb. These bugs are found by a static analysis tool STCheck written by us. Signed-off-by: Jia-Ju Bai Signed-off-by: Casey Schaufler Signed-off-by: Sasha Levin --- security/smack/smack_lsm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index 017c47eb795eb..120bd56e5d89e 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -4005,6 +4005,8 @@ access_check: skp = smack_ipv6host_label(&sadd); if (skp == NULL) skp = smack_net_ambient; + if (skb == NULL) + break; #ifdef CONFIG_AUDIT smk_ad_init_net(&ad, __func__, LSM_AUDIT_DATA_NET, &net); ad.a.u.net->family = family; -- 2.20.1