From nobody Mon May 6 05:08:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1658258313; cv=none; d=zohomail.com; s=zohoarc; b=n0bMMEBVJJ8RMfe46imsXybotlcMZ60NPl+h9TMizUbCWFPfUicLtKAGPqR89eWoRQ0F7dLSTWJ5Za1KlNwLeU3+Ktzcmh3a90rrm/I9IvDbA2huu1BVwiSUtMYwncDe1OMbudyWpLyA3gaNdm6DVminC+Fnz8HQj0X08OZHXOs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658258313; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=9v21Ix66GTJcQGhQxKIODW8bSYLFeuijiK0JgwHYvl0=; b=h1qOToU85MsrgPx0CbasVy/EeRLDkSiv+x0MOYn//fZ3m1+6mAoa4+bx16XcT5gXcTymEChQhHBQsIyqUnwM7xCuinRdMu58oWLZRhZd/UIYFMkexumOXv2i7UcIA04pG47yTBgAl/+rTDItiuvJw0PbljxcoDTgwCSJ9kkgAzI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1658258313188959.3519029376367; Tue, 19 Jul 2022 12:18:33 -0700 (PDT) Received: from localhost ([::1]:54388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDsjn-0006Rr-Kz for importer@patchew.org; Tue, 19 Jul 2022 15:18:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDsj2-0005g9-NG for qemu-devel@nongnu.org; Tue, 19 Jul 2022 15:17:44 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:43936) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oDsj0-0004oX-Vr for qemu-devel@nongnu.org; Tue, 19 Jul 2022 15:17:44 -0400 Received: by mail-wr1-x433.google.com with SMTP id d16so23023934wrv.10 for ; Tue, 19 Jul 2022 12:17:42 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id d5-20020a5d6445000000b0021bae66362esm14017692wrw.58.2022.07.19.12.17.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jul 2022 12:17:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9v21Ix66GTJcQGhQxKIODW8bSYLFeuijiK0JgwHYvl0=; b=O+1WgJzfE3IiydKBLQUjnh2jLsr9Jhks1X8i6mvrmwwftsJ+8nX63/rR4+UlZ2UP+T JTNz5C+YAGJZkP8dknBWgMisuVO0biUtPg9YXyOwmNY3hfy1OQ0DwxWJDmyVo4JAATrx lb3hMt31GA7QNTOXIRp8bTi7YLgzZ0Y2pRewMKLku2pkjfMgHGnGGmEm85eCUVHFiF/C t9aVpfThoIPHAUmVMpUHo/2D6xs1ZLX4cl9GygWgNDCtyMjprfuZAFMspL8kMIv1lKnh FFP+cFqTyzkF+D25rpTUjIAY/a+EgpMsmzRbzp5Ed4VE8ASn4KTW5o51h321136qtoek W4lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9v21Ix66GTJcQGhQxKIODW8bSYLFeuijiK0JgwHYvl0=; b=EKIwCm2pWeMdRIyZ8WJehgU2YlwdZ+LIUbnY/6xX6TWE6Acrjtw0Kn7oqIk3eIvwRB 0U3qHAqLLtXMomO4xCQtKpZ+0N1yEPbZCoF5+ctSR/psZNa/pR2lOZdYHFHjOY/nsfVl s1TgSKSJzK/aaRamUg7J5M6i/K6etrWFmbfwbLlUi5JSVgHkzh4gxak+cl3UzlNtyrdv 6bwXo0PDtFJzOaiZhrA3h4JtjSUhAddaaVuq4ne6aFyjyv5HjgHqMCun9fHMXYcg1I3e gKjINcg5fZc0ZaVQulegKvV2YzHwmwAR5NShp812VAlUQOsZZdOIzeC3MGzHH8VhKpMH tysw== X-Gm-Message-State: AJIora/RIYY1EVtq25pTadAJgn4c4tgEEuOOAH46AXhfWYroM+R8TMpK Kcir6MVcJ6FaCaTUSkjURtf1HRNCvGkuDg== X-Google-Smtp-Source: AGRyM1vWFiCumi41qFIvXbiA+Tt64VMVaWU7KsXlSP0kFrAU607mKPlCUMFAryHfWQ5y0IruA8ktuQ== X-Received: by 2002:a5d:6502:0:b0:21d:f19e:602b with SMTP id x2-20020a5d6502000000b0021df19e602bmr14031981wru.714.1658258260515; Tue, 19 Jul 2022 12:17:40 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo Subject: [PATCH] target/mips: Handle lock_user() failure in UHI_plog semihosting call Date: Tue, 19 Jul 2022 20:17:37 +0100 Message-Id: <20220719191737.384744-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x433.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1658258315092100001 Content-Type: text/plain; charset="utf-8" Coverity notes that we forgot to check the error return from lock_user() in one place in the handling of the UHI_plog semihosting call. Add the missing error handling. report_fault() is rather brutal in that it will call abort(), but this is the same error-handling used in the rest of this file. Resolves: Coverity CID 1490684 Fixes: ea4210600db3c5 ("target/mips: Avoid qemu_semihosting_log_out for UHI= _plog") Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- NB: only tested with 'make check' and 'make check-tcg', which almost certainly don't actually exercise this codepath. --- target/mips/tcg/sysemu/mips-semi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/mips/tcg/sysemu/mips-semi.c b/target/mips/tcg/sysemu/mi= ps-semi.c index 5fb1ad90920..85f0567a7fa 100644 --- a/target/mips/tcg/sysemu/mips-semi.c +++ b/target/mips/tcg/sysemu/mips-semi.c @@ -321,6 +321,9 @@ void mips_semihosting(CPUMIPSState *env) if (use_gdb_syscalls()) { addr =3D gpr[29] - str->len; p =3D lock_user(VERIFY_WRITE, addr, str->len, 0); + if (!p) { + report_fault(env); + } memcpy(p, str->str, str->len); unlock_user(p, addr, str->len); semihost_sys_write(cs, uhi_cb, 2, addr, str->len); --=20 2.25.1