From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ECBF6C46CD2 for ; Wed, 24 Jan 2024 15:14:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References: Cc:To:Subject:MIME-Version:Date:Message-ID:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=a3/5ByMC+qig4avL6bfMwH/uHkxVYXYOLlTF5dqcIfE=; b=sI0aeBFWBRSldQ g7ob8jWVALlAK/438+NPZC/8FjOstRzn/P3u5YLCf7RE4Amg4JWNWeUvwbibzgVD/NMXbHj7cPCS2 6m2jtmfMSAE8rtZATOkg9nv9dKdNGHUcP/mCYCH9e9k4cCZH8subBPqStPpNNlUAXoUcvOrhOdAiB Zd953G53XXus7N/BKUJ8du5Xl2V6WxA/LOKjMVdIMI2FZYKi/5ixDWWBN4urtfpAodTP35jNvb4BT KnpPKGMLZwN0kX6MfeNGHiOy5Lqqfn9KH6X52kK1Ccj5spz/XzV+5N/kC37filS9E4bevM1cwWZC4 lu9tkaqsyAG5EFimvs9w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rSexQ-003swC-2D; Wed, 24 Jan 2024 15:14:28 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rSexN-003suU-1V for linux-arm-kernel@lists.infradead.org; Wed, 24 Jan 2024 15:14:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706109264; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g9OCrAN+UT6ymJtmxhV/6yB5yqd39wFue7pD1+4bFjs=; b=gBBefsS5Y+qnKiXvIqQW0IN+FLvWzULYdfSf681oBvTnF8m9MielvyDJJdPpYbFMPhmoLW PMFxGNhEvRXaG8pat8NmtCZhlvTixaku7tpya+JIsWhy42J0QK3LJkR07s06NWtGmmLVOl 2lLWiBRZuGCS1e7XZFYFuYDETNWAG4I= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-145-lvj0u4F2P6SE3LOm9D-RuA-1; Wed, 24 Jan 2024 10:12:39 -0500 X-MC-Unique: lvj0u4F2P6SE3LOm9D-RuA-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-67ef8bbfe89so109740826d6.0 for ; Wed, 24 Jan 2024 07:12:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706109159; x=1706713959; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:reply-to:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=g9OCrAN+UT6ymJtmxhV/6yB5yqd39wFue7pD1+4bFjs=; b=krqk/lO/16LJ40PCogILuf9UIPt4poBdIgwt/aDANIiwKf16E5ZIxEAe3NyV7QRBw6 vGESn0CPRF0X0Dpv65xh2IVbiN8UxZvHoLFiYm498UNmdX4qa4o13rESjMH5rdblAZwK fN6giconnWeY2sNIUs8m1n/FOO6WlAWdjn0o8H64cTsIUqdRpliGPlhI4JbtOnWmIiJO kljnrIAJnlI2kONygb55w86tqfA+BVaEcgVb1A4QY7AIAvzBQrMozNDWBw+gxQ6RTSKM Pytllb2wVIN1w1wgTy6slA8kKdZc5dE3Ht6EUJ0fg5eMEp0Se1vDQakwiYDEUV+6QX7X TJBg== X-Gm-Message-State: AOJu0YxoYkUMva62Cwo+E0AcTM+8TwEuF0oVZVTPETFW/bvdQsp79Vuu 8U4zS8XcFeJZIOegzD68HjnoehnLDbUIQaLv2D+QXHJtxPLZuG9plRy8ibG/LoNiul//ntd1WmL OIzk+PVBdlCa9vmBoWlj6Dzkb8vmyFRF78Q9V1mMYWwX/VpWhjKhwwF2fvxBMkRQsKg6MPTi7 X-Received: by 2002:a0c:e18b:0:b0:680:b7fd:e3c0 with SMTP id p11-20020a0ce18b000000b00680b7fde3c0mr2602205qvl.130.1706109159387; Wed, 24 Jan 2024 07:12:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IE4YjMHgP4yQO1A1mLPxyYWjKYZXB3p75FsIdtm86FMAXD3LcuTiRkAWk2NCbxXvKHRbEkVxg== X-Received: by 2002:a0c:e18b:0:b0:680:b7fd:e3c0 with SMTP id p11-20020a0ce18b000000b00680b7fde3c0mr2602197qvl.130.1706109159137; Wed, 24 Jan 2024 07:12:39 -0800 (PST) Received: from ?IPV6:2a01:e0a:59e:9d80:527b:9dff:feef:3874? ([2a01:e0a:59e:9d80:527b:9dff:feef:3874]) by smtp.gmail.com with ESMTPSA id z15-20020a0cfc0f000000b0067f2559fd5esm4562012qvo.34.2024.01.24.07.12.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Jan 2024 07:12:38 -0800 (PST) Message-ID: <6efb0e40-a1e8-45d8-8b59-c3e5a90daa4a@redhat.com> Date: Wed, 24 Jan 2024 16:12:33 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 57/82] KVM: arm64: vgic-v3: Refactor intentional wrap-around test To: Kees Cook , linux-hardening@vger.kernel.org Cc: Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, "Gustavo A. R. Silva" , Bill Wendling , Justin Stitt , linux-kernel@vger.kernel.org References: <20240122235208.work.748-kees@kernel.org> <20240123002814.1396804-57-keescook@chromium.org> From: Eric Auger In-Reply-To: <20240123002814.1396804-57-keescook@chromium.org> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240124_071425_737495_FAA30F72 X-CRM114-Status: GOOD ( 22.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: eric.auger@redhat.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 1/23/24 01:27, Kees Cook wrote: > In an effort to separate intentional arithmetic wrap-around from > unexpected wrap-around, we need to refactor places that depend on this > kind of math. One of the most common code patterns of this is: > > VAR + value < VAR > > Notably, this is considered "undefined behavior" for signed and pointer > types, which the kernel works around by using the -fno-strict-overflow > option in the build[1] (which used to just be -fwrapv). Regardless, we > want to get the kernel source to the position where we can meaningfully > instrument arithmetic wrap-around conditions and catch them when they > are unexpected, regardless of whether they are signed[2], unsigned[3], > or pointer[4] types. > > Refactor open-coded wrap-around addition test to use add_would_overflow(). > This paves the way to enabling the wrap-around sanitizers in the future. > > Link: https://git.kernel.org/linus/68df3755e383e6fecf2354a67b08f92f18536594 [1] > Link: https://github.com/KSPP/linux/issues/26 [2] > Link: https://github.com/KSPP/linux/issues/27 [3] > Link: https://github.com/KSPP/linux/issues/344 [4] > Cc: Marc Zyngier > Cc: Oliver Upton > Cc: James Morse > Cc: Suzuki K Poulose > Cc: Zenghui Yu > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Eric Auger > Cc: linux-arm-kernel@lists.infradead.org > Cc: kvmarm@lists.linux.dev > Signed-off-by: Kees Cook Reviewed-by: Eric Auger Eric > --- > arch/arm64/kvm/vgic/vgic-mmio-v3.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/kvm/vgic/vgic-mmio-v3.c b/arch/arm64/kvm/vgic/vgic-mmio-v3.c > index c15ee1df036a..860b774c0c13 100644 > --- a/arch/arm64/kvm/vgic/vgic-mmio-v3.c > +++ b/arch/arm64/kvm/vgic/vgic-mmio-v3.c > @@ -863,7 +863,7 @@ static int vgic_v3_alloc_redist_region(struct kvm *kvm, uint32_t index, > int ret; > > /* cross the end of memory ? */ > - if (base + size < base) > + if (add_would_overflow(base, size)) > return -EINVAL; > > if (list_empty(rd_regions)) { _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel