Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp5236332rwb; Wed, 17 Aug 2022 13:45:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR6ZbyKLPmwlZUK2h6J/0i5AAviiqF4k85hMUU7AOGA6V11hTfaPoJ3G0gXq3U58BrLqxgUp X-Received: by 2002:a63:fc50:0:b0:41b:bbb8:ee36 with SMTP id r16-20020a63fc50000000b0041bbbb8ee36mr27271pgk.20.1660769112079; Wed, 17 Aug 2022 13:45:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660769112; cv=none; d=google.com; s=arc-20160816; b=xBAZUvsAqb1QCBFBMI+RWiXQWWfl9dlEOsFXVHowh4wY3rXTtuqIb/SVwOfP3O9Wbf kAFLAnp02zYRg9T0al5bnwWefJEnNgRWq7B7yFKSsH5nxpY4Xl4JBWXK2HtT/VF5TgO7 AbOEOu4NRiEz9lXOkhv/jNpQCINBuG3Irg7G98kgAhTFTW3BUlp5ZGHXtjK5o0whaYzp chSeOYvD6TU1ngf0ulCJ1/mGPuXtmMddAmMtgv/shJa909qKjHTmLg4C4u+22+oOZSm+ EIAW52rHSgMf/CzZ5I6/YjR5DvkbyYG9s/ve2KtV2TYscA6vvQlLfYLoIoox+o0l2nJZ 9kDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+BHAYzDqgDO1dphlleJav81q/W9nIBFp+VkYBEf8vLU=; b=hNpLi3VPyvUaYNqLAlxUdQ/XT6b3Ea5kBOZ90ciRsRYV73vFfa76Wrus5oIphpPOCG tE0Ql8aSPBYPrr3B1DJf+1jsuD14vQjAfW8UiC0k9gU7yD4lMNDS3cYtHs+MFHDwX8T/ lJlHo3VqZK00CeP3Zga0gAzdOzmicXhFCALG/lN222IXz/nycz8WftEKbzJjDjie7zAQ 2cq00x2T7wiyhTOdhkHFctf+rniD7rGe7Ly41/+GSPxawFlvBDUe5aY+DvS+MJG5C+lc Y5Xmu7HNiy686UxIw5/DpqPAkw5OxqxqVXf735toP/i4qvJmV8WS+CmslZcETqO4khXT p3wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jz3fLzw+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b16-20020a656690000000b00415e130eb76si16242315pgw.685.2022.08.17.13.44.38; Wed, 17 Aug 2022 13:45:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jz3fLzw+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241941AbiHQUeb (ORCPT + 99 others); Wed, 17 Aug 2022 16:34:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234720AbiHQUe1 (ORCPT ); Wed, 17 Aug 2022 16:34:27 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2AEBA98D4 for ; Wed, 17 Aug 2022 13:34:22 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id x19so1863159plc.5 for ; Wed, 17 Aug 2022 13:34:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc; bh=+BHAYzDqgDO1dphlleJav81q/W9nIBFp+VkYBEf8vLU=; b=jz3fLzw+fJu0xPnGx+//k5qikpJiVrmGS9ks5o3noNGsc8Uf1MVHQS773VBi7HxOoP MZ6Ip5ai3AKoAuZFpSBu4KsXfgeAKdCvm4aIDXUybYCujl6F8SW9xZaTic3jRc3H2wGA 2kdkepAqif71HE0vPPrNQ6MJhpDbQ0B+3unjI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=+BHAYzDqgDO1dphlleJav81q/W9nIBFp+VkYBEf8vLU=; b=jLFobGh1bPUe7lAYOOXS/8kDhyTaTblxejx3Qy5i0geW+30QRgOqkrS58iM0SlM1Px xs/Zfw9Rti9w7m5dCbpLLec3K4+iJi/Fzm+sE3R8HQ9aH8z514neFiH1HiTJKfEndC5q Li4x0lI+7MfS4Sd7bnAPbt9NQf8r5hWe8NuaD2Ac4zVqEXbHBiRdkwyRoWYF9wyIghUb wpkD6Ul3+Ndg/0r5GllG+Frj5hHLO4B7oRiS8fxHxbUzQThKswZSQ1q2dpQGFHcO5Qg6 sRWSvlbV8E5jumG3s/4Kd8cXWvWZD8IKOBwn+KBf5j+2pIdUzwplL2BfsjeyCJeyoMQq Hblw== X-Gm-Message-State: ACgBeo3jSvfV08yVMwSHrhvXUr/6RKQ1x4kRLjUfYDBF6drx026GwO39 wbXxze1Jq6dKYLRCHW3OEnwZMg== X-Received: by 2002:a17:902:ce11:b0:172:6f2c:a910 with SMTP id k17-20020a170902ce1100b001726f2ca910mr16336467plg.156.1660768462179; Wed, 17 Aug 2022 13:34:22 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id l15-20020a17090aaa8f00b001ef9659d711sm1975601pjq.48.2022.08.17.13.34.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 13:34:21 -0700 (PDT) Date: Wed, 17 Aug 2022 13:34:20 -0700 From: Kees Cook To: Miguel Ojeda Cc: Miguel Ojeda , Linus Torvalds , Greg Kroah-Hartman , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, patches@lists.linux.dev, Jarkko Sakkinen , Alex Gaynor , Geoffrey Thomas , Wedson Almeida Filho , Sven Van Asbroeck , Gary Guo , Boqun Feng , Maciej Falkowski , Wei Liu , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron Subject: Re: [PATCH v9 06/27] rust: add C helpers Message-ID: <202208171331.FAACB5AD8@keescook> References: <20220805154231.31257-1-ojeda@kernel.org> <20220805154231.31257-7-ojeda@kernel.org> <202208171240.8B10053B9D@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 17, 2022 at 10:22:37PM +0200, Miguel Ojeda wrote: > On Wed, Aug 17, 2022 at 9:44 PM Kees Cook wrote: > > Given the distaste for ever using BUG()[1], why does this helper exist? > > We use it exclusively for the Rust panic handler, which does not > return (we use fallible operations as much as possible, of course, but > we need to provide a panic handler nevertheless). Gotcha -- it's for the implicit situations (e.g. -C overflow-checks=on), nothing is expected to explicitly call the Rust panic handler? > Killing the entire machine is definitely too aggressive for some > setups/situations, so at some point last year we discussed potential > alternatives (e.g. `make_task_dead()` or similar) with, if I recall > correctly, Greg. Maybe we want to make it configurable too. We are > open to suggestions! I suffer the same problems trying to fix C and the old "can never fail" interfaces. Mainly we've just been systematically replacing such APIs with APIs that return error codes, allowing the error to bubble back up. (Which I know is exactly what you've already done with the allocator, etc. Yay!) -Kees -- Kees Cook