Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp39160ybg; Thu, 11 Jun 2020 16:31:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6PLRgmmzeSldCbeN2qWkAMom6kVjuitkCEmKTNtohV8iaCI6JzTq4+9ed6PSWZRTNTi79 X-Received: by 2002:a17:906:ce2f:: with SMTP id sd15mr10325962ejb.445.1591918301610; Thu, 11 Jun 2020 16:31:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591918301; cv=none; d=google.com; s=arc-20160816; b=WA/c0fPF1yW0DpBy0rlfA6oMiTBHlZEwIYLNKnJQ3X5qsntWx80eCJmHxZGT/aAhSL aSY7ojoRjWCmbYoJApkq/k8pkcieEyE4ID6MexGm7hlQ26+KSEC+joo8ouKc1KrkzPnS 36gcKUOpML4CkQqbIRgtyMcK5GuKLkaglGVfvMaKCbq1c3GsUZHBvQ3znAvZEUJ4n0tu PrMp6yuBQLCjt/2Rj6XkU2K4LC/MQeRn4LKcCEBbRNApwfXZjyakflr+fa+apbhH15Ql F3KvWYQDX8Q9WTMbo58xDDdI4eBm21OPPJkBsc5RADT6ACC4nmPZVvqjAVM1P0rc/MUF QA8A== 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=hyFEm4+7Wbt8Mmq80/X+KHS7uI1Dwb9CNGXNsovM9X4=; b=UwkP6PAJaDPY0Rsn4d6eINLOS51I46JlEGqOBP6SRlh6KnFMonZ29U0p1aGGS/yN5k Twf9gWSoN/4d1ZjzW9LbmfhE1TE0Ly7X8Hm0dARIbpgcZrJIlQXzbvLfYamzx+Sd/5oN Nr+R6CNfy8Paq+qfPKjjEcUjPVzmApW4lGc+xQOv7J7FrwZ1qRFiDQ6IxQrcQ9z943p4 SWi3vzXUKsICleP0eQYdmyoR1UfM+EwQ87x5b0Z2jX0wqEvNsKcsNQDIzZa+cTAuoDuj fTcEb5GcQqotTe23sZcDSjIaZdzIZhLGrfN0T18Q6dmH+1uL84VL+R9QkSqmwFzY13yj gW1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=mVD8qanY; 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 j28si2480391edy.293.2020.06.11.16.31.17; Thu, 11 Jun 2020 16:31:41 -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=mVD8qanY; 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 S1726331AbgFKX11 (ORCPT + 99 others); Thu, 11 Jun 2020 19:27:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726287AbgFKX10 (ORCPT ); Thu, 11 Jun 2020 19:27:26 -0400 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AFCDC08C5C1 for ; Thu, 11 Jun 2020 16:27:25 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id o26so5148620edq.0 for ; Thu, 11 Jun 2020 16:27:25 -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=hyFEm4+7Wbt8Mmq80/X+KHS7uI1Dwb9CNGXNsovM9X4=; b=mVD8qanYyMWIlYlfuy6lWtTm4E5npt5kmjQ7FrPCuEFjbKUttZOLTTonm5aQ7js1Nx E01R9KCCSEfNzJ/05sNHKihBxNE4bgxmMZppuqrm6ITsIVzQrcqHSNxRXH7AbNv06Rao 3vaJqHTvLResTQA48BiqmPtD4+Qan31jcg3qTjxpEuBlZgy4xlnmxxv4/5v1Oj2/R3KU DRWrKbzKG8d9HiZm3eCLg1y9s7nJ2OCu3xGAm2lMkVFVcTEihWZUrrq66cl59NTBgcy1 myqBg78ntowatx1QDfmv4qHiFWhNmFZR66+gUqqkI1Dfzntka0XR9Pjzk0fw55HDfByl r1mA== 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=hyFEm4+7Wbt8Mmq80/X+KHS7uI1Dwb9CNGXNsovM9X4=; b=Xd5PJm+ruo7Eq29KeZIwVi5Vwo7eWemd8SCQl+7o+iM2plGTSHcxK1wsQN1TButPC7 4cs/mzX7pvrF5pNNAGNOrZbUc5BPL1klOD4C/GJnrnHSGEy8jNItoIgYMGoAefmuEchT ilqPqItuQVgWe5oyzQNUtCOhNFJcmdqOqoHm5LdbrPMhXXUeMdVwaPzvq0KdB034NBvw eATrcE28W+TV3+66O6qzmw+dWGbZcNuJs0bn3RppiO9kkkzYUnLXpGUzqj/Kv4j12Ni7 vlLW9G25DDOcLkAkjVxWEBj0z1A2F3BT4EybrtYIoHD+rLTqwWMc3W6O2UhQkg0wZSnO cvBA== X-Gm-Message-State: AOAM5315wV6Ku9/5wGylSH1mLh5XndJRn4I7huioLGnqb8rEFut9ywy5 NfgyXqB95dxyOfFMa89nDrwmK+oVpNCxu592SbBT X-Received: by 2002:aa7:de08:: with SMTP id h8mr8876666edv.164.1591918043429; Thu, 11 Jun 2020 16:27:23 -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: Thu, 11 Jun 2020 19:27:12 -0400 Message-ID: Subject: Re: [PATCH v2 1/1] selinux: fix another double free To: Tom Rix Cc: Stephen Smalley , Eric Paris , Ondrej Mosnacek , weiyongjun1@huawei.com, selinux@vger.kernel.org, linux-kernel@vger.kernel.org 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 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. -- paul moore www.paul-moore.com