From owner-svn-src-head@freebsd.org Mon Jun 29 00:46:46 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 8F99835A069 for ; Mon, 29 Jun 2020 00:46:46 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) (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 49w82F1LJ3z46RD for ; Mon, 29 Jun 2020 00:46:45 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qk1-x742.google.com with SMTP id z63so13866521qkb.8 for ; Sun, 28 Jun 2020 17:46:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KH559yMG2AHTIPUMqqE8C/XkufDXw/E/lEG+GhV6a7k=; b=EYdETdSJUEiaDifuqdrfhs+v8cBB6MfIergt0t1G5MhEjbQTnQd0IlZ4hhhCKxv/mq 8KjIGHLn76LwjwwEM0LIoLhy+mDlImt6T1oE4GPYzW3x68hFfzr1rOuWIChTOv4lCoNz osdpgXFgKG4+g6Wzo+iB0gN/U+PiPy3N/Xid5h8odLZnRoI8zhxkd6F6zoBE0XRx15fY rVgue8AfWP5L5ldoHuolhV2uACvuDOPTP/5/P0B4+pylYuVNSSy6W/7BKT0ycn+4gjEC Q8zABCBUmPvzpjhKWrH6YPFa4lfkWA+F1kW2AruI3ffS19ixdFt4RuKFuvBh7VG2smyb AOnQ== 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=KH559yMG2AHTIPUMqqE8C/XkufDXw/E/lEG+GhV6a7k=; b=ic0K0igikCpMTNCHGWnXZfguzrzlj1zduhGs+7zqEuGmXlCVUWU8d38Aavwk6eazmb LBG9qG8tFm/zMZ6DiKwYrZN9Im/LQZ89q0C92OVBrBx2OXJVMnn6EjKd1jIqRWY+r0RY 8MNa+mbma7TfQjgx9b2zPBuCUNWQZEioCm5oMv1AHEDuBAM1V9XSgB1DJR/K10hYsdco GkEMDkcC/ZyxF/vQdyz5UNM1nglgHjgAxr4QKZQRdSKI+wvrn5WhW+80XUKhyv8itGR9 bwYd5X6UwSUaP5O4TDquNDPE3PE4BuzFlNtzrKbbq/CoGH9ET2werJ+s96vGeFCLZfZJ n+Lg== X-Gm-Message-State: AOAM530MqD2Y1YYu8nzDSz4pZnkEWBffl80oXLVn5iZXdMnQp4wgFkCO o7nE7yRxsI+Lwf/t/l2w0EtSpLpdMD90HaYx0NKU3Q== X-Google-Smtp-Source: ABdhPJxbxiWkd6hd/U6RFVad+DYMln81EQWwXDdscZCRNkYCZiyZbKgKJ0XbW03iPBDJk9BXiVcCtCAQpMOZbGGBCnY= X-Received: by 2002:a37:67c8:: with SMTP id b191mr13052990qkc.60.1593391604307; Sun, 28 Jun 2020 17:46:44 -0700 (PDT) MIME-Version: 1.0 References: <201901021709.x02H9ZPM004185@repo.freebsd.org> In-Reply-To: From: Warner Losh Date: Sun, 28 Jun 2020 18:46:32 -0600 Message-ID: Subject: Re: svn commit: r342699 - head/sbin/savecore To: Alan Somers Cc: Mark Johnston , src-committers , svn-src-all , svn-src-head X-Rspamd-Queue-Id: 49w82F1LJ3z46RD X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bsdimp-com.20150623.gappssmtp.com header.s=20150623 header.b=EYdETdSJ; dmarc=none; spf=none (mx1.freebsd.org: domain of wlosh@bsdimp.com has no SPF policy when checking 2607:f8b0:4864:20::742) smtp.mailfrom=wlosh@bsdimp.com X-Spamd-Result: default: False [-1.64 / 15.00]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[bsdimp-com.20150623.gappssmtp.com:s=20150623]; NEURAL_HAM_MEDIUM(-0.85)[-0.853]; FROM_HAS_DN(0.00)[]; NEURAL_SPAM_SHORT(0.09)[0.094]; NEURAL_HAM_LONG(-0.88)[-0.885]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[svn-src-head@freebsd.org]; DMARC_NA(0.00)[bsdimp.com]; RCPT_COUNT_FIVE(0.00)[5]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[bsdimp-com.20150623.gappssmtp.com:+]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::742:from]; R_SPF_NA(0.00)[no SPF record]; FORGED_SENDER(0.30)[imp@bsdimp.com,wlosh@bsdimp.com]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; FROM_NEQ_ENVFROM(0.00)[imp@bsdimp.com,wlosh@bsdimp.com] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.33 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:46:46 -0000 On Sun, Jun 28, 2020, 6:41 PM 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? > So the other spots adjusted large, but this one sets one of its elements. Help me understand how that is a leak? I'm sure I'm just confused. Warner >