Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp281074ybg; Fri, 12 Jun 2020 01:05:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgdYt7P5RVfbbYyonm0tIeQ5YjeYa/wY0LhsB1mYN2MBBSqtWf56FdNC3EFSOQIGju68yS X-Received: by 2002:aa7:d290:: with SMTP id w16mr10756256edq.178.1591949109004; Fri, 12 Jun 2020 01:05:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591949108; cv=none; d=google.com; s=arc-20160816; b=FKkt0uxYwNrmf1hZhlRlp0/Kf393Jv3tjxfdDir4G8AMWO/I19oUFUyd0H2Kmm60AS 2nUaDrlda1l098VYh0hARJX11T+c5ZGlgMbGRgIdmjAjca0eGoG3Sf3R74K+seaLPrNP 8omFEoABTmbjUvAemFDvudjAhur9jivW0RVKZrrrJnN0kIM1RnMFS3uFjFOjXP2U435h psyoqWb2KZWcLF7M066Oluvu+9Qcy1bi4jEV7Sa9nK/F+GH5yxqeO7ZhInvVUp+eLJr2 HlyD/YpHXuNVzTjvOjvVQdc5i3551QkRDIYu26FybddmAZQpkc/xyUC8it2kzSjXnM18 Qa+Q== 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=zFV5q/tNv+oXc5JuBy2ztRIX+iFtdAsbYIzI6VMlHtM=; b=KP5MWqvgcu2kvOHs8UlH+/yunx5Wi5+IFsj+Qz8/8QcKlHd8b7Y8TSjRwlQMzI7ovb E+XgCgiIzpMVh8MuG2YJpoRX4ijHKlpy2Snnmpw2xeKHk8KOuiohKIox5WPYOSPCxBrE DTbIymiOay+VFNkNin7rJBcOghvM5qkOVWdauEJwfctfctWsX2KGr3h5eoreY+RriRd/ Wx1MhAibt0anjHVYz4E6KSAWdVPC6QZRtotq8Ljb8il0VunbY64UMY0NwG7pRE/gTwuw yvcY+RRsi7uV/xABW92b8+Y6lHK2C2TqQuevbegd0Uo4fShdlRv4uatPq/DbLQIk9YdZ eD6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VyleD0Vz; 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 hh22si3578190ejb.85.2020.06.12.01.04.17; Fri, 12 Jun 2020 01:05:08 -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=VyleD0Vz; 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 S1726485AbgFLIB6 (ORCPT + 99 others); Fri, 12 Jun 2020 04:01:58 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:22615 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726262AbgFLIB5 (ORCPT ); Fri, 12 Jun 2020 04:01:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591948916; 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: in-reply-to:in-reply-to:references:references; bh=zFV5q/tNv+oXc5JuBy2ztRIX+iFtdAsbYIzI6VMlHtM=; b=VyleD0Vz3hxhiNG4VGsuHodMhh/nTbSufH7l4/+Vf29+rfogYQBliW1TYpFROqFbF9RK2l V2YiI+pmjlcPOurlObiJUnVdHacxfOKvGpk5lSPGtyzhbDxh+NtkzowblqZ/V1TI4Mzd/9 JsILQjIzmBCTeCPmNJhnmiYm/DpiwXo= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-246-7q7saOrwPTe76YJ6u6_Xgg-1; Fri, 12 Jun 2020 04:01:53 -0400 X-MC-Unique: 7q7saOrwPTe76YJ6u6_Xgg-1 Received: by mail-lf1-f69.google.com with SMTP id j21so2385452lfg.18 for ; Fri, 12 Jun 2020 01:01:53 -0700 (PDT) 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=zFV5q/tNv+oXc5JuBy2ztRIX+iFtdAsbYIzI6VMlHtM=; b=sbn0YZ4PuiGbJTFd1Gss33Y6355zNdDdbnEckng0LZmgeNDrzKNF9XM6vZyHhOUFhp Cij/zueeywqp/7UNO4057FX0C7RfqUoPBBohR8ODnNhHBwaFLfk1n+e8u+iy5XBXIP6X FXLthwBpt+9pjPkxtaLOfRkUFiAbbK3pHKSnvXhvjYoREauR3cdBJqDJzsGSMSSevEpV bnZUysQPm4+zegmWBLXjgwevKSS39s67zyhHMfzNi++f31numsoBqAY+r1W7DIUy2qPy mZH76ovIPCVIfQ5slIrJjT7L/qxnfV2mnd7zh6e4UR0yYLTt8129FzU5c/0NKkk9iK+v zhxg== X-Gm-Message-State: AOAM530TN6UIdhZeyNo8KeQNoWOYqn7NFLsIAyLAh1gEkJ/1pqOoyn79 Htq6CsuaQXVuTo6vot9BdRSVH+cmJ5pWfJZWtW+4bMQaK5ZF75f2vdOObAAhU9Ow48UujlsgrQI WMF+gLg5G5zQsA2ALF08zrPWInFtQ1oO8+Nvv9lFg X-Received: by 2002:a05:651c:1126:: with SMTP id e6mr6205518ljo.123.1591948912217; Fri, 12 Jun 2020 01:01:52 -0700 (PDT) X-Received: by 2002:a05:651c:1126:: with SMTP id e6mr6205500ljo.123.1591948911907; Fri, 12 Jun 2020 01:01:51 -0700 (PDT) MIME-Version: 1.0 References: <20200611204746.6370-1-trix@redhat.com> <20200611204746.6370-2-trix@redhat.com> In-Reply-To: From: Ondrej Mosnacek Date: Fri, 12 Jun 2020 10:01:41 +0200 Message-ID: Subject: Re: [PATCH v2 1/1] selinux: fix another double free To: Paul Moore 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 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. It can be really useful in some situations, especially in case of cross-subsystem changes that are sent to many mailing lists. 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 [...]". -- Ondrej Mosnacek Software Engineer, Platform Security - SELinux kernel Red Hat, Inc.