From owner-svn-src-all@freebsd.org Mon Jun 29 00:41:12 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E69D935A19D; Mon, 29 Jun 2020 00:41:12 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-ot1-f51.google.com (mail-ot1-f51.google.com [209.85.210.51]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49w7vq6rjpz46DW; Mon, 29 Jun 2020 00:41:11 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-ot1-f51.google.com with SMTP id t18so1141541otq.5; Sun, 28 Jun 2020 17:41:11 -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=RWYOuXaw1MtkZ6zi7huXSZgLxL4j4COiCmO4BkFbcCE=; b=CRm6druXcU0axa5OHFPOxW6tyxSwlhif9zlQhL3ytphvQsOt+pxFQEe4mjC2lxBh67 lOC+V+oMsE+tZ7sAWciS+pEHExmA7u+PC1gmtgWTE6lUxs1lHvbdpp5hYye0zlJKk+ux ZMNkr6TzY27vrQHHpecdkiBMlGJZTJnfrL+qUlMqWPhoxZHjwuKskKuCdmbG153x867X VQbKkLRasppi4RnnT7SCMRwRAv9nQcfQ/ZRXnSiqpo/rgNxr+PrX0sGmSHasbFoQ6why 6nNm0DRe95lCTlglVgPH6CBivJFypDUREZvTgTmrGquW075rd8GJRQQKLSQ0Esf3rFyQ 4DBA== X-Gm-Message-State: AOAM532ToJk4a2U4kEPnXRfu7buu7fNfXVPfdbDZPs0L/j8ZEiLS897U Ko26N6H2ym4M+ISxx1Qa35cV8h4mINvFbrgDl4sVFw== X-Google-Smtp-Source: ABdhPJwYeXRJqqjnVMg1Y4eXIYoa/G52mYjpBxSczJDfBVmkY+h88n4cB1CWJ8cr8kX6jjKnVAwxEXw32MQitvSlnZs= X-Received: by 2002:a9d:523:: with SMTP id 32mr11131971otw.291.1593391270570; Sun, 28 Jun 2020 17:41:10 -0700 (PDT) MIME-Version: 1.0 References: <201901021709.x02H9ZPM004185@repo.freebsd.org> In-Reply-To: <201901021709.x02H9ZPM004185@repo.freebsd.org> From: Alan Somers Date: Sun, 28 Jun 2020 18:40:59 -0600 Message-ID: Subject: Re: svn commit: r342699 - head/sbin/savecore To: Mark Johnston Cc: src-committers , svn-src-all , svn-src-head X-Rspamd-Queue-Id: 49w7vq6rjpz46DW X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of asomers@gmail.com designates 209.85.210.51 as permitted sender) smtp.mailfrom=asomers@gmail.com X-Spamd-Result: default: False [-1.13 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.65)[-0.652]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17:c]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; DMARC_NA(0.00)[freebsd.org]; NEURAL_HAM_LONG(-0.40)[-0.401]; RWL_MAILSPIKE_GOOD(0.00)[209.85.210.51:from]; TO_DN_ALL(0.00)[]; NEURAL_HAM_SHORT(-0.08)[-0.078]; RCVD_IN_DNSWL_NONE(0.00)[209.85.210.51:from]; FORGED_SENDER(0.30)[asomers@freebsd.org,asomers@gmail.com]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; FROM_NEQ_ENVFROM(0.00)[asomers@freebsd.org,asomers@gmail.com]; FREEMAIL_ENVFROM(0.00)[gmail.com]; RCVD_COUNT_TWO(0.00)[2] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.33 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Jun 2020 00:41:13 -0000 On Wed, Jan 2, 2019 at 10:09 AM Mark Johnston wrote: > Author: markj > Date: Wed Jan 2 17:09:35 2019 > New Revision: 342699 > URL: https://svnweb.freebsd.org/changeset/base/342699 > > Log: > Capsicumize savecore(8). > > - Use cap_fileargs(3) to open dump devices after entering capability > mode, and use cap_syslog(3) to log messages. > - Use a relative directory fd to open output files. > - Use zdopen(3) to compress kernel dumps in capability mode. > > Reviewed by: cem, oshogbo > MFC after: 2 months > Sponsored by: The FreeBSD Foundation > Differential Revision: https://reviews.freebsd.org/D18458 > > Modified: > head/sbin/savecore/Makefile > head/sbin/savecore/savecore.c > > Modified: head/sbin/savecore/savecore.c > > ============================================================================== > --- head/sbin/savecore/savecore.c Wed Jan 2 16:42:07 2019 > (r342698) > +++ head/sbin/savecore/savecore.c Wed Jan 2 17:09:35 2019 > (r342699) > > +static char ** > +enum_dumpdevs(int *argcp) > +{ > + struct fstab *fsp; > + char **argv; > + int argc, n; > + > + /* > + * We cannot use getfsent(3) in capability mode, so we must > + * scan /etc/fstab and build up a list of candidate devices > + * before proceeding. > + */ > + argc = 0; > + n = 8; > + argv = malloc(n * sizeof(*argv)); > It looks like the memory allocated here > + if (argv == NULL) { > + logmsg(LOG_ERR, "malloc(): %m"); > + exit(1); > + } > + for (;;) { > + fsp = getfsent(); > + if (fsp == NULL) > + break; > + if (strcmp(fsp->fs_vfstype, "swap") != 0 && > + strcmp(fsp->fs_vfstype, "dump") != 0) > + continue; > + if (argc >= n) { > + n *= 2; > + argv = realloc(argv, n * sizeof(*argv)); > and here > + if (argv == NULL) { > + logmsg(LOG_ERR, "realloc(): %m"); > + exit(1); > + } > + } > + argv[argc] = strdup(fsp->fs_spec); > and here is leaked. I can't find any corresponding free. However, neither Valgrind nor Coverity complains. What am I missing? Does this memory sneakily get freed by a subroutine somewhere, or does Capsicum confuse our tools? -Alan