Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753846AbdLUSGq (ORCPT ); Thu, 21 Dec 2017 13:06:46 -0500 Received: from sonic302-10.consmr.mail.bf2.yahoo.com ([74.6.135.49]:38654 "EHLO sonic302-10.consmr.mail.bf2.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753565AbdLUSGn (ORCPT ); Thu, 21 Dec 2017 13:06:43 -0500 X-YMail-OSG: 6oqhEB8VM1mwMosVKIp7PH4VeUW5P8O2WXd82RKaBwrVtH3LJpS3N1BSuq9cycj _RhOSkxfvuLcow_wHx08dZ8VMTJ8znQWZCEhO.9omQH1p2dBgVTcO.WJNl4Vya7ostJ8iN40gMbq etTmfH1UpDKEQoXP3G5Oc3ZzSoePdvkGODTTzreVcyOEf3ds6UM7DgJnRnsTtgpdkAFGc00J9UDJ BxQn5zu0jX_EUsFJ75ovSl33MNK3.MPiWtW4kReRGNS4kImBmx6IyK0PHd9HIVRUksC23mhDmn5N JuHYFZ.tvAGrHX13U1MwaXKzjMo1WbD8nGWwhrB6IanLcLQYAMIlL0RQc2mKcRQuliMQvjwGlPoi 80JqpK__CWENNoM5svrqKXYm3AylPtj_.aj1qjfDMP7bYsXjM_KGkQ1BscUQyz5tziS3LsvoH54J IFqnpXfnf5trJs2oB2KSgIXmVIDXAvgSt4cG_2YQepkn_sAkgx0j3tbDjLqoajN1iS8auLz3gH_m JR3kUnzH6oXPvNM2BSaiF9hf.s.fG8zClpUVEwXwvZMOVE8rn Subject: Re: [PATCH] Smack: fix dereferenced before check To: Vasyl Gomonovych , james.l.morris@oracle.com, serge@hallyn.com, linux-security-module@vger.kernel.org Cc: linux-kernel@vger.kernel.org References: <1513871872-18759-1-git-send-email-gomonovych@gmail.com> From: Casey Schaufler Message-ID: <4da2b0f6-a2d9-ead0-d573-a75bc78938a7@schaufler-ca.com> Date: Thu, 21 Dec 2017 10:06:35 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <1513871872-18759-1-git-send-email-gomonovych@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1175 Lines: 37 On 12/21/2017 7:57 AM, Vasyl Gomonovych wrote: > This patch fixes the warning reported by smatch: > security/smack/smack_lsm.c:2872 smack_socket_connect() warn: > variable dereferenced before check 'sock->sk' (see line 2869) > > Signed-off-by: Vasyl Gomonovych I will take this into the Smack tree. Thank you. Acked-by: Casey Schaufler > --- > security/smack/smack_lsm.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c > index 14cc7940b36d..30f2c3d1c11c 100644 > --- a/security/smack/smack_lsm.c > +++ b/security/smack/smack_lsm.c > @@ -2866,12 +2866,16 @@ static int smack_socket_connect(struct socket *sock, struct sockaddr *sap, > #endif > #ifdef SMACK_IPV6_SECMARK_LABELING > struct smack_known *rsp; > - struct socket_smack *ssp = sock->sk->sk_security; > + struct socket_smack *ssp; > #endif > > if (sock->sk == NULL) > return 0; > > +#ifdef SMACK_IPV6_SECMARK_LABELING > + ssp = sock->sk->sk_security; > +#endif > + > switch (sock->sk->sk_family) { > case PF_INET: > if (addrlen < sizeof(struct sockaddr_in))