Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp474560ybg; Fri, 12 Jun 2020 06:34:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHqbaYvG41nmp/xtBj5N5ED8XxMCqniqVWeH1cyifwi1vWxtxif5PmU1kT1ptEZbk7magN X-Received: by 2002:aa7:d0c5:: with SMTP id u5mr11565324edo.51.1591968856750; Fri, 12 Jun 2020 06:34:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591968856; cv=none; d=google.com; s=arc-20160816; b=mF0FR88vBbjHNlTqPgqzr3JVXqgvyNyVcRcL5W7+rjbQq4B5RjwhNUtic79kjbXX61 DCfrgEIaa4+b7gNfyAEenw0qhrlvEuDQb9rKlwnHcjgfZvpNXjuzwxRjIHrKs4Ci0SLf 1Ny0bBoefxMnA967ue8AEbMbZpp3TMMOPynP7KvqLkGu+26kCs6oqhLuyXPI3fdmZo9E samFL3CfbbEo9CPWC/ekjAbmzWBzV0ufcG0N9CTrYMgRGdOmc3B9SXI5QtfvqEQ4VX0G 1ZCGgD7d3EaQlndm75DeV6q8nnrTy/obSBMN082g/dwGOpRRkek2EFUYMpTRyzTPnnCQ Uo1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=d01buqxZYdIU2y12ViZTn0UU3aSbuc7TBEB4RtzP2wo=; b=JEC9daNeqGyNtJasBE/K6wIV959kay8aigoekx5lUgdxNmy/MVkHMRhG9bp5DqERk1 sDuEOp4PbEuWfoVHdttuYsi1n/+oIvwxIPMVdJK78k14MRmfGiBGh9eIHEiVR9Zdvt+3 Jz09Grr2h//1OIOvLY1JpuHgpoCFJt2r6m3iWgGTkv5sPjewD6VqNWiFFrtCwl9ugRC2 XUNSzGxH143za+mvpNW91A8YjydC6AuXFlmuTV2A/oePF7NbiEc+warP+7NiOvIIZBfB 3r3E0q3umV1SEou3+fTwwgri0pCxRADxyt5hzzk2pIWiwM0nT2DQs/LSX1TE0mS3OrZf CbBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=UiLbIo2M; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nr21si4010742ejb.230.2020.06.12.06.33.52; Fri, 12 Jun 2020 06:34:16 -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=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=UiLbIo2M; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726341AbgFLNbg (ORCPT + 99 others); Fri, 12 Jun 2020 09:31:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726327AbgFLNbJ (ORCPT ); Fri, 12 Jun 2020 09:31:09 -0400 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 400E0C03E96F for ; Fri, 12 Jun 2020 06:31:06 -0700 (PDT) Received: by mail-ed1-x544.google.com with SMTP id o26so6430476edq.0 for ; Fri, 12 Jun 2020 06:31:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=d01buqxZYdIU2y12ViZTn0UU3aSbuc7TBEB4RtzP2wo=; b=UiLbIo2MlUzW+ohtKAtNNoB1U6eRB79fOIzs+Q2Jgllzl6LcDbMdd5z429pVr39//N xIQPCQQbiZkqpsgEk/VatF3uEsLtmxF4g7HdeLSEXv7BkTq849GgFeS6tDjn5/nYeQGq wXh4cAvpDeyYjxTiUvKcCS+DWoz9sUT/CEWx6K17uy3L7QeSC/Ehz2nbG4Ges+S0zwv2 ogFtyX0ClcI1EB8Dio4Yo+77XzvvGW2Cbajfrx94/cq5HDp6Pj4ciBct17r1oBozJ3HI y2v6POjwVITB8rYB2F1JMwbuJrlZF1Ivp/Oir19sh2WcoxC0oKzGFnab4i//KKcKLKmL hnjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=d01buqxZYdIU2y12ViZTn0UU3aSbuc7TBEB4RtzP2wo=; b=G+ajoiK7owe4VLys5FfObSS6JvhAcYmVDo3o1tJvrMzqgHbWtl8qHxNEnnput/CYsM DBbe8oeIMqJTknKQLvWwn0yJtrANjDw3XnsvlCY8/D+bJe/X7oQx40CmR7F5IT75imc5 Sv5DIs+DuaNqsHXWYtWp0UtUT/bOXeCSrpfwguUa36iWflbAr4RK2g6H750nNrp5GOPF OMIVB/90iIoV8lJUp6oTIZk4juv5GKw1+q+Nu84/X4aCY1hUYBT2UEyD62fE3wxCzb18 An6+FqtsAJT8C0CLj3Gmg4UpV207PCPAcB39p7HWiiDTs37MofaEkdmF+59H00Oey2y4 8FhA== X-Gm-Message-State: AOAM530Kg7GZsII8Fe6HpUylFYaZWg37eu8wQwLgbDAQswRAjPjeJpRv vnw3k2et6GJEWnRpU/o34ty11Ls1Ff8DPh0gL/Vz X-Received: by 2002:aa7:de08:: with SMTP id h8mr11332863edv.164.1591968664063; Fri, 12 Jun 2020 06:31:04 -0700 (PDT) MIME-Version: 1.0 References: <20200611204746.6370-1-trix@redhat.com> <20200611204746.6370-2-trix@redhat.com> In-Reply-To: From: Paul Moore Date: Fri, 12 Jun 2020 09:30:53 -0400 Message-ID: Subject: Re: [PATCH v2 1/1] selinux: fix another double free To: Ondrej Mosnacek Cc: Tom Rix , Stephen Smalley , Eric Paris , Wei Yongjun , SElinux list , Linux kernel mailing list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 12, 2020 at 4:01 AM Ondrej Mosnacek wrote: > On Fri, Jun 12, 2020 at 1:27 AM Paul Moore wrote: > > On Thu, Jun 11, 2020 at 6:41 PM Tom Rix wrote: > > > 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 ? > > > > We read your mind ;) > > > > Generally it's pretty obvious, and in the rare occasion when it isn't, > > we ask. Most of the time you can deduce the destination repo by the > > files changed and the mailing lists on the To/CC line. From there it > > is then just a matter of -next vs -stable and that is something that > > is usually sorted out based on the context of the patch, and if > > needed, a discussion on-list. > > Yes, it is normally not necessary, but I wouldn't discourage people > from providing the info if they want to / are used to do that. I would discourage adding this info into the commit. It clutters up the commit description and is of little value once the patch has been merged. > It can be really useful in some situations, especially in case of > cross-subsystem changes that are sent to many mailing lists. It has been my experience that those situations are rare enough that in the case where there is some question it is easily resolved over email. It's not something worth worrying about. > But of > course this information belongs either to the cover letter or in case > of single patches to the "informational" section between "---" and > "diff --git [...]". Here is my perspective ... Cover letters for single patches are annoying, either the information should be included in the commit description itself or the information is really not that important anyway. I also tend to like seeing only changelog information in that "informational" section so that it stays relatively clean and uncluttered. This means there really is no *good* place to put the repo information for single patches, which is okay, because as I've said before this really isn't a problem in practice; or at least it hasn't been a significant problem in the roughly seven years I've been maintaining the SELinux repo. If this ever becomes a common issue I'm open to discussing this further, but for right now let's not clutter things up to solve a problem that really isn't a major issue. -- paul moore www.paul-moore.com