From patchwork Tue Jul 30 09:40:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 815278 Delivered-To: patch@linaro.org Received: by 2002:a5d:4acf:0:b0:367:895a:4699 with SMTP id y15csp214952wrs; Tue, 30 Jul 2024 02:40:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUt9shaO4sO1Gk3PjeJoOAe1bUfwKXhdiZzY4idhEH7lM0qg1GYWrX9LwkRw8Yo+SlYAxL6/Skqu4U5tNgYjIRF X-Google-Smtp-Source: AGHT+IGjzf2tDvF/l3xSUkq5DsTxjoGhEty6vXto0mynu22hIs9UiXQtDMh0biK/5oPANFNX1jS3 X-Received: by 2002:a05:6358:61c2:b0:1a6:72f2:4d03 with SMTP id e5c5f4694b2df-1adbc2a0707mr1330988355d.9.1722332454826; Tue, 30 Jul 2024 02:40:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722332454; cv=none; d=google.com; s=arc-20160816; b=gABIUFUolmsCyiTC/PquVGhaf1i1ekN+6VvNWSke+TpX76DPIKDCdPLuDe14FpthSE TO1kWSDyd3NDBBUDvJ+XiqRW43xqj4JTH5V7Kjv96BDLemLGRMseeBx/A9Sh6BKuSuC+ EwdbLbgD1058O54aBvxUatnks4StkJ9DzT8Zox10V8s9vABlhz+B44/0EtUhQpu7N3rU vSTRSkBMv7QXZ/OH8Ft32DJI1NU8y6Zs5nyyxVr8mryOuaYrbI8Ta05SeZ9IcgyLs/rW N40A1dVHOARy9Io3r8f0aYir5Ftd2wLllMcXxm8N6MYYtZ5n7mSBChqbGyZyd762NQSU Cb1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=2hTb07T/lHUckLF9pRQZzZ733VhUGgQBsCLUx7kwgYc=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=aqo/8lzvJ5cnanv2fmGDX3taluN/SfDNtmB3jF/5wq2HSpl5zXffb0DmCPtS4cc8YW d3e0VcAF664k438ElyIQbE3ThW/aBUHIrIrZ/DYABZr3Tft/wEnSc56wZtQWmbCHeSAh V4h1V4em1BA+Q2iCVbRtCp/b4PXZWC2A5zPztibDSabNpb0WXpWRJ9B5mltOlKzd9lh5 KbmjdJZXsCv2/LMZKXOZSxso2ZDEs/mxnqkKiYPCKkA8kPxyYHmHF8RcHpLkEnBkoz3g j8HOQltT2pXObUQ7jPAt1NzPsVdEbHiD3u6cqH6Y7fbCJn4uhj0imLBO9G2OJVZITggn kn+g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iqS8Xpws; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a1d74629a1si1229951485a.470.2024.07.30.02.40.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Jul 2024 02:40:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iqS8Xpws; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sYjLM-0003hK-4t; Tue, 30 Jul 2024 05:40:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sYjLI-0003UO-SJ for qemu-devel@nongnu.org; Tue, 30 Jul 2024 05:40:28 -0400 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sYjLF-0000X1-K8 for qemu-devel@nongnu.org; Tue, 30 Jul 2024 05:40:28 -0400 Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2ef2cce8be8so56889371fa.1 for ; Tue, 30 Jul 2024 02:40:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722332424; x=1722937224; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=2hTb07T/lHUckLF9pRQZzZ733VhUGgQBsCLUx7kwgYc=; b=iqS8Xpws2CoA+TwvDX8+LigcHyYvEFkNraE3ZayKDHJT5r8Dklzx2cRQLfEr5vNjaq p02m8CBFrbyup1G5TDUiGZQs9Gtu+YE3OWB4j8y/Ywvc3jwMmRbEtWRQugQGKYf1HUpQ SrlBFUPYZfsMfN31dffih9Vey24CGoRLLS+ScrK6UTj9HpaDsWyO5O+2M5Wr/jDWxqWP UIgLCdwbuX5x/gopL/X2ZCYspnb1ScX9WSEmPaQHi90EJJDasEsM/7JxOJHrweM8gkqZ 7jX1/CrHfehu295kL+PDBvgVCjpogQepTEu/t6XaMtEcCbSHnqfbHvbf1BrvfBafX/ba k/2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722332424; x=1722937224; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2hTb07T/lHUckLF9pRQZzZ733VhUGgQBsCLUx7kwgYc=; b=uZyPmJTZUM3RHQP/wf7bl2i3ec8j1d2yEWQmFV/a5QIBzRl5fSZVACWAvCj+CLGEEW hsYvdIOGVVwhDFuNF6CA95td9M2SgN3M5WcXnFLmtXuISW5BYq1krwMqG2CwNGy5HzX2 Z3W5aWoBokRul+nsF/2n1E0SskSoeei1utWP1opJrPKL7TbMPUJ/Nx3mvxGVyi0ED6jw qCxgYFqYpcm2c/OdCO5JWj9SXCVgHHun6vLZcN5WHdp0KsK28g02e04UWYeiDvqTLEOI vOAjGTV+GfXn8bZqPgllspIrr4sd1+EJ24sJEu5OfHo1oXrBQWsthqOtJfquceafnPdm cUdQ== X-Gm-Message-State: AOJu0YyJBk4RLtdJQU8LNUzM30OobzmqGMKsOSXBIUXaGQgILMPvr6x8 DH+4c1zmZpOMJ37xCmPWlm8wmEQZiZo7/GJwoZQ2T7eU8ez0PwGctz3AKDn8sn/7Ns7K5B1J04t S X-Received: by 2002:a2e:87d5:0:b0:2ef:1c0a:9b97 with SMTP id 38308e7fff4ca-2f12ebcaea9mr74174751fa.3.1722332423812; Tue, 30 Jul 2024 02:40:23 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36862549sm14194974f8f.106.2024.07.30.02.40.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 02:40:23 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 02/21] hw/arm/smmuv3: Assert input to oas2bits() is valid Date: Tue, 30 Jul 2024 10:40:01 +0100 Message-Id: <20240730094020.2758637-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240730094020.2758637-1-peter.maydell@linaro.org> References: <20240730094020.2758637-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::235; envelope-from=peter.maydell@linaro.org; helo=mail-lj1-x235.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Mostafa Saleh Coverity has spotted a possible problem with the OAS handling (CID 1558464), where the error return of oas2bits() -1 is not checked, which can cause an overflow in oas value. oas2bits() is only called with valid inputs, harden the function to assert that. Reported-By: Peter Maydell Signed-off-by: Mostafa Saleh Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Eric Auger Message-id: 20240722103531.2377348-1-smostafa@google.com Link: https://lore.kernel.org/qemu-devel/CAFEAcA-H=n-3mHC+eL6YjfL1m+x+b+Fk3mkgZbN74WNxifFVow@mail.gmail.com/ Signed-off-by: Mostafa Saleh Signed-off-by: Peter Maydell --- hw/arm/smmuv3-internal.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h index 0ebf2eebcff..b6b7399347f 100644 --- a/hw/arm/smmuv3-internal.h +++ b/hw/arm/smmuv3-internal.h @@ -599,7 +599,8 @@ static inline int oas2bits(int oas_field) case 5: return 48; } - return -1; + + g_assert_not_reached(); } /* CD fields */