From owner-freebsd-hackers@freebsd.org Sat Oct 17 00:12:19 2020 Return-Path: Delivered-To: freebsd-hackers@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 8E61D44337C for ; Sat, 17 Oct 2020 00:12:19 +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 4CCk3k5nGdz4M79 for ; Sat, 17 Oct 2020 00:12:18 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qk1-x742.google.com with SMTP id 140so3350183qko.2 for ; Fri, 16 Oct 2020 17:12:18 -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=0wqxn9pJHEZGvQK6URxd2UzRAAkWx6hjUiRS4S8DQUQ=; b=HTTL3svxcoNTnXKuhysRXuPRvpX+r8IGxxe49BvalrmsE7lrq/YzAubFNfGr+xwebX IOEmwZ59eDcXgCvMv178z5LWp1fzdO2RNwimg1CQ8XvQEhjexInrtFiPUKH3cMsBCTVx L27vcqegTHBf+j2gAF3KYf4TG8mpZlH+hWQZmK/7+GH6vbLNeH6yYPa+zfOyQEu9Pfsi 2BufcKzGYSaDIDNSCDUTZpcUfs+FxXle5ecf1Vjnz6mb/Js7XyP2BObVJUjlLBCwlN6V CdvWVlOOPfKu9UGZP/VAf2aDdUyYCUQmGVP80LEHfDpWLsod0cKJXn/QJSRKnjaag+YE 1sNQ== 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=0wqxn9pJHEZGvQK6URxd2UzRAAkWx6hjUiRS4S8DQUQ=; b=TXrumgBF5niBZ0i0BSouWI9/x5p0tKV1ceQ4YMq0sCL0NRaPcSYfcegtwn0YiQDeFX XH5GcL0BFqNZu2zw+CpcX6Vs8qiQ00VRvcccyubyfw7Rssyuhok+qxYSH5jH89NK10lJ an0geqXB9yueYpyn9Vdp/LjLw/zgrPVv32bsGMrzak4SZ8vL2uc8xtBjoVPTfDkL/d+V Dy9V61sHBkMNAgu1AJvc63XSabwJNCBC9dffSuyz8GUV/vGQkuTboGMeuxkTxS1FtC1A n39g/q4/5YgE2s+gSuXL6pd9SFxrWH8f8iiULpotmyUJVptbgSFclwOgJD7IZm02D7xS U2fw== X-Gm-Message-State: AOAM5309odT6PQNp/8h59bn8xVnp4fM0OHO0vw8qrwOveuZREXM4l4cq uSPl3eAVMxpRL/s+6RksoQtKbNJDh6j7WSBqFx8rzK6DK4s= X-Google-Smtp-Source: ABdhPJwFXyPfBHwhksuw6rCxw2wtqX2wEfoRBYT/CdpAkgi1qzbisftXTpTlFwsFm53TfrmBdrWRljsypu3m4mfe870= X-Received: by 2002:a37:63c1:: with SMTP id x184mr6286755qkb.195.1602893537826; Fri, 16 Oct 2020 17:12:17 -0700 (PDT) MIME-Version: 1.0 References: <9fa46833-63c2-a77f-98dd-111f6502dc74@rawbw.com> <2886aa43-0145-54e6-b532-18d1865047c6@rawbw.com> In-Reply-To: <2886aa43-0145-54e6-b532-18d1865047c6@rawbw.com> From: Warner Losh Date: Fri, 16 Oct 2020 18:12:05 -0600 Message-ID: Subject: Re: Is it possible to exit the chroot(2) environment? To: Yuri Cc: Kyle Evans , Freebsd hackers list X-Rspamd-Queue-Id: 4CCk3k5nGdz4M79 X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bsdimp-com.20150623.gappssmtp.com header.s=20150623 header.b=HTTL3svx; 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.26 / 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.96)[-0.956]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; NEURAL_HAM_LONG(-1.00)[-1.003]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; DMARC_NA(0.00)[bsdimp.com]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[bsdimp-com.20150623.gappssmtp.com:+]; NEURAL_HAM_SHORT(-0.30)[-0.305]; 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:~]; SUBJECT_ENDS_QUESTION(1.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[imp@bsdimp.com,wlosh@bsdimp.com]; MAILMAN_DEST(0.00)[freebsd-hackers]; RCVD_COUNT_TWO(0.00)[2] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.33 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Oct 2020 00:12:19 -0000 On Fri, Oct 16, 2020, 6:01 PM Yuri wrote: > On 9/27/20 1:25 PM, Kyle Evans wrote: > > +1. I think an additional sentence pointing out that that's the > > traditional behavior would outline that this is perhaps what's needed, > > maybe with a specific EPERM reference. > > > > It's tempting to also propose switching it to the even-more-strict 0 > > at some point, perhaps considering a procctl(2) if we really find some > > scenarios where it's absolutely necessary... we'll leave that battle > > to a different day, though. > > > I have several questions though: > > 1) What does this check really guard against? > kern.chroot_allow_open_directories=0 prevents chroot(2) when there are > open directories, and kern.chroot_allow_open_directories=1 prevents exit > from chrooted environment when there were open directories. But what is > the benefit? The process opened some directories and holds open file > handles. How can this interfere with choot? What could go wrong that is > prevented by this check? > Some users of chroot don't want to exit the chroot environment. It's more or a security thing. This is a very different intended use pattern than your case. That's why it's a knob: it is more secure by default. One might ask if such a default makes sense in a jail world... that's a fair question. 2) Why is there no similar check for open files? Why directories are > special? > Open directories can lead to jailbreak. Special files generally can't. Warner > Thank you, > > Yuri > > >