From owner-svn-src-head@freebsd.org Sun Jun 3 21:24:29 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 74B1EFDDD58 for ; Sun, 3 Jun 2018 21:24:29 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-it0-x22a.google.com (mail-it0-x22a.google.com [IPv6:2607:f8b0:4001:c0b::22a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E93DF7DBF7 for ; Sun, 3 Jun 2018 21:24:28 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-it0-x22a.google.com with SMTP id m194-v6so7766386itg.2 for ; Sun, 03 Jun 2018 14:24:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=kkzU+R7P6O7qxoNzZ7hicVDRC0qbbEBlStc8zyiczlU=; b=tU0WxUG/JEDne5OUvT7uNk8Kp4T7+2iAohTmIMdvpTDNQmRpRpN1lmS8aRUi0YJNAe hhWEJZIYakB7D+BcntmI6XoXwwdkvMfBRs0mBn8cWiEqQEy+1VPMFwQ3W2zo9J6oNsAv E4xa8sKta/FXbNdCQE9DGm637R6vjgUzv6mkAUMZq71Cx8UnIv47OiP2iYoTV1D0l29o vfklDva+aQ7jI8M/Gv7XNsIFDXUhkqrU2idp9D12QYjGpTqsQLf/QkjjGs2QXbMADUsx 1pO7bdKwB+E5T1QPEd58Sd//D+U/MN6oO08c+t7qMYRUGoTsh537uivns4jRoi9XhrM+ LfZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=kkzU+R7P6O7qxoNzZ7hicVDRC0qbbEBlStc8zyiczlU=; b=D0lAZLZokm+lkvE+YK205AA7hEMrH+WQX83cAY3Y3sNMvxxMpyT+B7WKwqBZHpJY9z 4ps7sBISKGmiQd+rGUfXG3aRha0HEzZN4vPGv3OkYivOgJpTFXY6raXmRCG+IOfelJ0G U+6O3V5byVHS9Y30uoYSH92eGzPr89Haci56n5Xsh2PNYq4+Qt/WGGlfvlAZUdpsu1+e PJCsJ2baMyr8OTC1zicBT/R3nKkuoj4lHuFEw2ZXwpTETxtbqIMJJav80CbPq1Pufo4e JEFV2RH9lyzyBnQnRqJ8mLMdD9w3pstEIls74MpexNCtUdFHTeHGaHMwNS9akohrQ4LC b1Ig== X-Gm-Message-State: APt69E2Zt3+fGRWG4Mdht0+lP0ZbhTC9czT9x3935t6jNWwSD1tOEV2G eAgTN2TDAZ/4sfww4Hbb/Jug6eTBeU9wayXqt5X4xg== X-Google-Smtp-Source: ADUXVKLt/r98wDOs5YwNP9ui/28crQDFxHxdOdV+CCXODuXepZ28/QGCz9PQZfQjAk/gzsP3GuyRP0mKOiaKU+LrtWk= X-Received: by 2002:a24:7c8d:: with SMTP id a135-v6mr4402482itd.73.1528061068317; Sun, 03 Jun 2018 14:24:28 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 2002:a4f:d028:0:0:0:0:0 with HTTP; Sun, 3 Jun 2018 14:24:27 -0700 (PDT) X-Originating-IP: [2603:300b:6:5100:1052:acc7:f9de:2b6d] In-Reply-To: References: <201806022206.w52M6S98020830@repo.freebsd.org> <201806022356.w52NuiFK088665@pdx.rh.CN85.dnsmgr.net> From: Warner Losh Date: Sun, 3 Jun 2018 15:24:27 -0600 X-Google-Sender-Auth: LjT7xRYg1q8hNRNgIh6sDDeZYZM Message-ID: Subject: Re: svn commit: r334543 - head/usr.bin/top To: Eitan Adler Cc: "Rodney W. Grimes" , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.26 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 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: Sun, 03 Jun 2018 21:24:29 -0000 On Sat, Jun 2, 2018 at 11:08 PM, Eitan Adler wrote: > On 2 June 2018 at 16:56, Rodney W. Grimes > wrote: > >> Author: eadler > >> Date: Sat Jun 2 22:06:27 2018 > >> New Revision: 334543 > >> URL: https://svnweb.freebsd.org/changeset/base/334543 > >> > >> Log: > >> top(1): chdir to / as init; remove unneeded comment > >> > >> - chdir to / to allow unmounting of wd > >> - remove warning about running top(1) as setuid. If this is a concern > we > >> should just drop privs instead. > >> > >> Modified: > >> head/usr.bin/top/machine.c > >> head/usr.bin/top/top.c > >> > >> Modified: head/usr.bin/top/machine.c > >> ============================================================ > ================== > >> --- head/usr.bin/top/machine.c Sat Jun 2 21:50:00 2018 > (r334542) > >> +++ head/usr.bin/top/machine.c Sat Jun 2 22:06:27 2018 > (r334543) > >> @@ -1613,11 +1613,6 @@ compare_ivcsw(const void *arg1, const void *arg2) > >> /* > >> * proc_owner(pid) - returns the uid that owns process "pid", or -1 if > >> * the process does not exist. > >> - * It is EXTREMELY IMPORTANT that this function work > correctly. > >> - * If top runs setuid root (as in SVR4), then this function > >> - * is the only thing that stands in the way of a serious > >> - * security problem. It validates requests for the "kill" > >> - * and "renice" commands. > >> */ > >> > >> int > >> > >> Modified: head/usr.bin/top/top.c > >> ============================================================ > ================== > >> --- head/usr.bin/top/top.c Sat Jun 2 21:50:00 2018 (r334542) > >> +++ head/usr.bin/top/top.c Sat Jun 2 22:06:27 2018 (r334543) > >> @@ -260,6 +260,15 @@ main(int argc, char *argv[]) > >> #define CMD_order 26 > >> #define CMD_pid 27 > >> > >> + /* > >> + * Since top(1) is often long running and > >> + * doesn't typically care about where its running from > >> + * chdir to the root to allow unmounting of its > >> + * originall wd. Failure is alright as this is > >> + * just a courtesy for users. > >> + */ > >> + chdir("/"); > >> + > > > > Bad side effect of doing that is it is not hard to get a "core" > > from top when run as a user, as it is going to try to write > > to /, and it probably does not have permission for that. > > Another person made the point that other similar applications don't do > this, so I just reverted it. > Actually, it was a good change. I've had issues on other systems where I couldn't unmount a filesystem for reasons unknown. Not being able to take a core dump for top is a secondary concern: that can easily be worked around by rebuilding top. And chdiring to a different location defeats the point of chdir to "/". While we do have forced unmounts, I'm hesitant to use them unless I know for sure why I need to force it. Warner