From owner-svn-src-head@freebsd.org Mon Jun 29 00:55:42 2020 Return-Path: Delivered-To: svn-src-head@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 9EEF735A4CD; Mon, 29 Jun 2020 00:55:42 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) (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 49w8DZ27Fpz47Jp; Mon, 29 Jun 2020 00:55:42 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-qv1-xf43.google.com with SMTP id e3so637721qvo.10; Sun, 28 Jun 2020 17:55:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=5r054CQPN/H0oJAT5dMqeibmKxzzdMsA8/J10tRWwPo=; b=tkl7cHg1VSWyITWNTclATP3iaQg7FaxuKNGo0Zct9w7oMjFplby1QeUkfxaG9kZfVw ZQob2hHz/AP+vF05i9Jr8aVgtE2WM1e/++55kJvp2nuTWWdHRVWcgzN5a+qfN71Uge+2 4xSVDEloTHCEpjoLdrRlDhyKCjBv4DArh3j/eunwjCH+F6+U50ALxhG6ZBEc+T+pJMkx g4ccb5bdHiBTjIhVaMRcOvLdyVvb0/DeC7GwXtUNdTm1RW2XOXGv00k4B2mk5+btit6k dEafZhJsPjY8Q2xXsbE/IV46B66odoABuru/bH2QSloGujjCfRBE8fGEFavS9WgB2j95 RyfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=5r054CQPN/H0oJAT5dMqeibmKxzzdMsA8/J10tRWwPo=; b=gP6rsPHFE9Csxd4gCBzDVfxG1e9x/DhX1Ggu9ZRnmM9T+PWzy2SJyCLBn9gPbFxedK B3mzJf57UvlvS6A1c5ij728t5Y9b2XFfaAvGxm36RJvu/JsQdAkRark5c4WZG/jmEh2I vx1i4KjIbhS7G0lunOcuUhBJjRTgM8T+XEvJHIqXqQjtx1+WDB2o/vXkIkoiG/saPkxT pBvzQReVamKpmJoTEGQfzN8uBsE/DhBFtin8Fg672ZgLGzAdkltf9d+BEj+oDvbhExF3 Ydkq3gLUXdQcUXot3egVbSCFCb4tIziKG7pdKGjKbCoHcs6ASAtxp4hiPClXYySy2DS3 ZiMA== X-Gm-Message-State: AOAM530JPo2+ujyi9KM8CwY8SDPOGYCxiMnZ1XduwSCvbSgL3siHJrC7 qa0h9SJe1vf9dPxThowNDnwXYCTrCug= X-Google-Smtp-Source: ABdhPJw2QWVn2eED4tUOwJXpzTjNDfvuw4lkd9c3/16oxWHJPHK7xp2L24BOw+ajmVMdLe+3S9fQrA== X-Received: by 2002:a0c:8e8c:: with SMTP id x12mr12856860qvb.55.1593392140873; Sun, 28 Jun 2020 17:55:40 -0700 (PDT) Received: from raichu (bras-base-toroon0560w-grc-20-184-147-206-12.dsl.bell.ca. [184.147.206.12]) by smtp.gmail.com with ESMTPSA id q5sm14436871qtf.12.2020.06.28.17.55.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jun 2020 17:55:40 -0700 (PDT) Sender: Mark Johnston Date: Sun, 28 Jun 2020 20:55:38 -0400 From: Mark Johnston To: Alan Somers Cc: src-committers , svn-src-all , svn-src-head Subject: Re: svn commit: r342699 - head/sbin/savecore Message-ID: <20200629005538.GB7202@raichu> References: <201901021709.x02H9ZPM004185@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 49w8DZ27Fpz47Jp X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Jun 2020 00:55:42 -0000 On Sun, Jun 28, 2020 at 06:40:59PM -0600, Alan Somers wrote: > 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? I'm not sure why Capsicum would change anything. It would be worth testing devel/valgrind-devel with https://reviews.freebsd.org/D25452 applied, to see if it's able to detect that bug.