Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp1109619lqo; Thu, 9 May 2024 05:14:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXL54FxICTvsO3qzD6VWK+bDRLLLyroQCxWFsEgCUP2tcaRqO09DcwjHJDUusScMNBRRLYdXVEPsxQ7QiF1e2xnu3pQ7mI9E2+LLPGDuw== X-Google-Smtp-Source: AGHT+IGqowUHkqZ8FbIbRTKFo48Mapc2DOzH8Fmxz29gJ463fEKWhZKLIggwzHlLKKtE0Qf0Juwx X-Received: by 2002:ac8:5a96:0:b0:43c:5d37:5a94 with SMTP id d75a77b69052e-43dbf75490dmr60125451cf.62.1715256876194; Thu, 09 May 2024 05:14:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715256876; cv=pass; d=google.com; s=arc-20160816; b=tV93wSNDmTLpLkA8zUlmIvRUl/M9ebAtzNEBFJk/eVI4QGPoEWXiix6baL3piZ/ezP NrzDto4jMdHJ+L56LixzZc2BakojHbhGIdMQ3pbGIzK0DvBFLYtrglZrak+d6pMCQ1UV NChHwtLnj1w4lG3asvYMTFco2JxzR0bng3vLaILi3Sz1kBwj9rhw6KHbum0Xu5MDwiok XjqP1845aQ/wM7nKhiqQeKyPtp02G+27Dw4uQ77lapGNrvdwXlAr5HQhhMQPd9IYK23r FrNJM5FkSUKkYZpo3lmLdqFpZjkCwVO4NFKHClnuU8xkvlrydxW6FcWqLEsZX4JvUGkf zgFQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=s/L8Sw+C9CH9AHoAkPMdotLn7sOxVFfEx4oTON5PdOU=; fh=qlWg2BIIs7rNNrIT1HCbOJdhF3MmpgK81q7HfL4ahfo=; b=ml27d2BQ5yM4Q87E8/4KnSnqvqy9zSniRxrxeHwz4nHMXRFcgcRWUXI1YS+tTfAqvN ECvgwVnPv/C2iowNjDvXi9rPmFP5eTvQiHudgkzpQk91AqCFqCDqhDJPMBoTXf11siJS IVt1X9VQtkjkM+akBHSmHACtbAuLEyamqTp/014hEgQkc67FuZvVzPAy05Kw3MfQQrdC RF0PePj682ALl1pShtpkjuRf8X+xogfMVDYTtrNsvvg6S2vQTTHh/WGNRBZCU4Vz43R+ /hkenQsl0213R2oE4ttYlwC/c7K/E8oEMReqYQylChMIlzGMTJLy9HOsS2aSDC0ARlew paqA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=GP9L7GMI; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-174484-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174484-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43df549dcacsi12940881cf.107.2024.05.09.05.14.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 05:14:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-174484-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=GP9L7GMI; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-174484-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174484-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E662A1C213D5 for ; Thu, 9 May 2024 12:14:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3609214B947; Thu, 9 May 2024 12:14:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="GP9L7GMI"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="TGYbKxUa" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5F8C14AD1A; Thu, 9 May 2024 12:14:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715256866; cv=none; b=sxbwpRSPTNzNSbw2kfPtE8uGK0PmWwkHrv7Eddx6BCKVL6jtqnd2N5aR07S1/hJQ1XW4bTou9tD+aYRyAQ75YmeWfyQvwbnjAbbJQiTbIKTYRD6fLBR4xypn9BV02pQOpyJAAu4b+YVdg76Ssf7WQXxuUSp5Vks9aFwWMmjCAzg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715256866; c=relaxed/simple; bh=N03P0gKUkMuybGCZFaql5yZdjIx87gfJbseTAmZcAxA=; h=From:To:Cc:Subject:In-Reply-To:Date:Message-ID:MIME-Version: Content-Type; b=JZvW638T6nP7Q1jZL90zJEUdaCtNqWGew4glJbotOPzdqZqZb6+kiBK/v/obmEFu9xojkaBbK+/AoQu58BRgpK26rkosw+TXB/Ol69j25yFP4I+vvMdmjQUKp7TXccm2AGWr6UPpLKQTGR5f5A92R4FZSBlg077lZQCX5o2x6co= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=GP9L7GMI; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=TGYbKxUa; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1715256856; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=s/L8Sw+C9CH9AHoAkPMdotLn7sOxVFfEx4oTON5PdOU=; b=GP9L7GMIRTXDY7VhR2x/RfuFQl194lccTl1bO6dLzJqQmwJZNlojEw5TsoyqYGLH7cw1dU mO20II4WZx0pQS76jsG1KQOkQMueml2xTrvPkZFvw5DSzvtsCEOCIu5dl4pYHXdzZChd+P A/CdVloEGFiVkvCIYxOab7yl1C6mqGfqTNrg830HegWXqci8WyS6WHZNp8fXexsh2cR3qh pwtRfDFaLWY+/aVu4fZ5w6GiuU+fDNLrUdi8vw9+Tb0tpgGk8hpZsoabO0++NVSeQVrIF/ ShHxg66dPvTTsA9VUKRazZ86jpDEmUI3xmfuhW9MO74P8AisoqmCheXiX2uXoA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1715256856; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=s/L8Sw+C9CH9AHoAkPMdotLn7sOxVFfEx4oTON5PdOU=; b=TGYbKxUaRYNlD6biJCoAwiR6babweEwIMvKiTSrMNVLxhFjBAVjfv1RQn64tbqLdKOPhi7 407TJi0ICQhXBCCA== To: Boqun Feng , Miguel Ojeda Cc: John Stultz , Stephen Boyd , Alex Gaynor , Wedson Almeida Filho , Gary Guo , bjorn3_gh@protonmail.com, Benno Lossin , Andreas Hindborg , Alice Ryhl , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Kees Cook Subject: Re: [PATCH 2/2] rust: time: Use wrapping_sub() for Ktime::sub() In-Reply-To: Date: Thu, 09 May 2024 14:14:16 +0200 Message-ID: <87cypvnpwn.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Tue, Apr 23 2024 at 14:11, Boqun Feng wrote: > On Thu, Apr 11, 2024 at 04:08:01PM -0700, Boqun Feng wrote: >> Currently since Rust code is compiled with "-Coverflow-checks=y", so a >> normal substraction may be compiled as an overflow checking and panic >> if overflow happens: >> >> subq %rsi, %rdi >> jo .LBB0_2 >> movq %rdi, %rax >> retq >> .LBB0_2: >> pushq %rax >> leaq str.0(%rip), %rdi >> leaq .L__unnamed_1(%rip), %rdx >> movl $33, %esi >> callq *core::panicking::panic::h59297120e85ea178@GOTPCREL(%rip) >> >> although overflow detection is nice to have, however this makes >> `Ktime::sub()` behave differently than `ktime_sub()`, moreover it's not >> clear that the overflow checking is helpful, since for example, the >> current binder usage[1] doesn't have the checking. > > Ping. Thomas, John and Stepthen. Could you take a look at this, and the > discussion between Miguel and me? The key question is the behavior when > ktime_sub() hits a overflow, I think. Thanks! In principle ktime_sub() should not overflow for regular use cases. If the binder example overflows the substraction, then something is seriously wrong. Though in that case as it's only for debug purposes panicing would be totally counter productive. A warning might be appropriate though. Thanks, tglx