Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp14224ybg; Thu, 11 Jun 2020 15:44:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpgl7p9+t+3OBpceYb0t4Vg4QvS+4lDvYPVOurZsjxDRSjRUW0qXY7i711oWTRBua3Jxed X-Received: by 2002:a05:6402:c1a:: with SMTP id co26mr8742850edb.207.1591915478911; Thu, 11 Jun 2020 15:44:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591915478; cv=none; d=google.com; s=arc-20160816; b=vJgsHfiB1D76wFTwOWoygsCAhxlPg41MS+8n+M2kztkzOHM0HZcafoInnP+wuMy2az pCKcQfMM8sQULFbcTt+N8Tlc1w9Ca/1Y6UtmkUds7BmY/HoSqGxIsk5KD58dDXwRnqDR 9F8+eXb3MeoB2evPTudOWl0IeR5e0F4FCF1jhsQIssqA+NF+QCjsOMcCTLsBvfi2sLZt lOiWvzdSdgxkwtnByy1TZfUmSSln0XzjZpcgyRo9dcjFqeMstoYmcrC/njNl6vf0uZoN 6Xp0AKEaJ/M4xhmkUhC2phJNCK2CsAMgyT927oTgio0OZJ6IDT1R7JNpDOqf6tGMQocL 2wig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=SDTR+5GttWdXmCNIwTA7d5bDN5WnJR6E3mSy9s64c4U=; b=ntwIcLouWZR0fyLag4ICQs0BBPD6+DoIOIwrMWJpBKo74N9pOPdhtWnueBnKM2h2jy LO6262yAm3ogfr6thgFKNcUAvvKiN1OtiVR9fvz4E+lkPLOPsYYW/vIPcqURNylMmZ4g nNSmQouLGfdfwG7IUIY8B24LfhiGOcRqtecJjUJ6YtUjBhGOp8Sk0cZOPUVle72wh9I8 uofSQSLUrvwTqpztsV3cMKVP95rBspzR0BAtAcQmXwvsB5V07vgNdKcOBYzqLMe0TFP+ t6F0gBbpJ0qYdCPEJcP5rdmmknkiQKWNQqY1Pb47GPnaoADTb4rYNnOWnYO4a54N5GBm TPTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IRen5xnQ; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o22si2514677ejx.725.2020.06.11.15.44.16; Thu, 11 Jun 2020 15:44:38 -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=@redhat.com header.s=mimecast20190719 header.b=IRen5xnQ; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726506AbgFKWlT (ORCPT + 99 others); Thu, 11 Jun 2020 18:41:19 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:35352 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726385AbgFKWlS (ORCPT ); Thu, 11 Jun 2020 18:41:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591915277; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SDTR+5GttWdXmCNIwTA7d5bDN5WnJR6E3mSy9s64c4U=; b=IRen5xnQmr+sREgOu+GfXiItZljowpaV4BwkvHcsuGq1jDXGWgDFykaFlPMhcs/HOrAv9r cZwko+zmLGKOQ4lydqdOuN169Wt2pn5jE20MAMxCunqZYEwGW+V6ZREkPdX1ihaUCOSYZT r6VXgqiX0NDlk0dZJ4s/cRpfEIK6ss8= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-55-1zbjJLW1N8SQ_D2l4IurnA-1; Thu, 11 Jun 2020 18:41:15 -0400 X-MC-Unique: 1zbjJLW1N8SQ_D2l4IurnA-1 Received: by mail-qv1-f71.google.com with SMTP id o1so5535774qvq.14 for ; Thu, 11 Jun 2020 15:41:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=SDTR+5GttWdXmCNIwTA7d5bDN5WnJR6E3mSy9s64c4U=; b=BgStDX2Ki/TPNq2dLLSlqfbTYQR9mtbypuWF1Vm6fXLLShPJddcueLhJEVa/NCKbHP FNHpeh2YShhKwXnZqaMgIBQXj548LKPfOnScA5xUbnvLrWsnJHaw4QWylGh4OQvF0F2W e4MGauTsG69vE7fBd58K4nLrNPWoIULG3cV4GpZBVtI0Be6orxiewfjx9LcBI9BRuoFQ Wv8DRncLvy7RcotftOB1msHfKKs8eea6z4bRdmed6a4h8xOdQeBU7hlVjnbfqiJxGJKT 3NAEv5f1q8B+4p8W6Vip45p5KYsY2v8ES/wLFsPrJD+dNNOErsY0SnjdzU0xTiWLnPQO 00FA== X-Gm-Message-State: AOAM530H9HHKlmayYUm7sW07WcfBwtjqGA59/qEjo1HHhMvO6dj6g1BC pk9Z3K6B3CewXpr6/H/NM6uPvuZcVt5YVw7+Hh/7xeD8YrlOwtpYliIUHT9oikl2ZunrB+t2AwK wW8KmBRdip1O/oL2K9FNts13n X-Received: by 2002:a37:9c55:: with SMTP id f82mr229741qke.225.1591915274508; Thu, 11 Jun 2020 15:41:14 -0700 (PDT) X-Received: by 2002:a37:9c55:: with SMTP id f82mr229726qke.225.1591915274249; Thu, 11 Jun 2020 15:41:14 -0700 (PDT) Received: from trix.remote.csb (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id k6sm3256477qte.52.2020.06.11.15.41.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Jun 2020 15:41:13 -0700 (PDT) Subject: Re: [PATCH v2 1/1] selinux: fix another double free To: Paul Moore Cc: Stephen Smalley , Eric Paris , Ondrej Mosnacek , weiyongjun1@huawei.com, selinux@vger.kernel.org, linux-kernel@vger.kernel.org References: <20200611204746.6370-1-trix@redhat.com> <20200611204746.6370-2-trix@redhat.com> From: Tom Rix Message-ID: Date: Thu, 11 Jun 2020 15:41:11 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/11/20 3:30 PM, Paul Moore wrote: > On Thu, Jun 11, 2020 at 4:48 PM wrote: >> From: Tom Rix >> >> Clang static analysis reports this double free error >> >> security/selinux/ss/conditional.c:139:2: warning: Attempt to free released memory [unix.Malloc] >> kfree(node->expr.nodes); >> ^~~~~~~~~~~~~~~~~~~~~~~ >> >> When cond_read_node fails, it calls cond_node_destroy which frees the >> node but does not poison the entry in the node list. So when it >> returns to its caller cond_read_list, cond_read_list deletes the >> partial list. The latest entry in the list will be deleted twice. >> >> So instead of freeing the node in cond_read_node, let list freeing in >> code_read_list handle the freeing the problem node along with all of the >> earlier nodes. >> >> Because cond_read_node no longer does any error handling, the goto's >> the error case are redundant. Instead just return the error code. >> >> Fixes a problem was introduced by commit >> >> selinux: convert cond_list to array >> >> Signed-off-by: Tom Rix >> --- >> security/selinux/ss/conditional.c | 11 +++-------- >> 1 file changed, 3 insertions(+), 8 deletions(-) > Hi Tom, > > Thanks for the patch! A few more notes, in no particular order: > > * There is no need to send a cover letter for just a single patch. > Typically cover letters are reserved for large patchsets that require > some additional explanation and/or instructions beyond the individual > commit descriptions. I was doing this to carry the repo name and tag info. So how do folks know which repo and commit the change applies to ? > * Thank you for including a changelog with your patch updates, but it > would be helpful if you included them in the patch by using a "---" > delimiter in the commit description after your signoff but before the > diffstat. Here is a recent example: > -> https://lore.kernel.org/selinux/20200611135303.19538-3-cgzones@googlemail.com Ok got it. > > * When referencing a patch which you are "fixing", the proper syntax > is 'Fixes: <12char_commitID> (" 46619b44e431 in Linus' tree to see an example. Ok > If you have any questions, let us know.