Message ID | 20230901111355.18785-1-ciaranwoodward@xmos.com |
---|---|
State | Committed |
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3F1D63857C66 for <patchwork@sourceware.org>; Fri, 1 Sep 2023 11:14:38 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2113.outbound.protection.outlook.com [40.107.13.113]) by sourceware.org (Postfix) with ESMTPS id 15A6C3858D37 for <gdb-patches@sourceware.org>; Fri, 1 Sep 2023 11:14:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 15A6C3858D37 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=xmos.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xmos.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gywzyjc8ekgeyIxEf9Piie3wB37VqDHPJyMtbMwaBAM86r23I10A+YMvc215AUULASUbYJdpCeTum5JbVzW6fenubcbbF+4UT57dUCTrQbTaFOl2O/R4kflna9znfygpt5Hgz00GZiyGJ19ELakLG6N/Y/RAeJZ9MF+p8oKGhFTkP0friltt01zTJr54mxFhsCTofnm8xzrXvoWzJA7bSCE5foDfCLvPG2q3i6FN7hYxXPyl3hV6D3Rr0lbwkp2E0K3n8DEvDMCDIsiyGwum7nGGYgz/VH0sRWk9cUEcBA9VQ0bNxc3FPT0RqTcUI45Aag4eQigav+Uj6rxz+G+iZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vBs5TJZ4B30P2+SwPhH8ODE6QaHkCTmwz1B0R+HE37U=; b=MFgdF/TAYejdMP706iyGjiFaHhjYS2zfa8eeXJ898XTRpucz2H2PGKj0f/87B0pJ3L/v//zYuTTq9KzS7XD3FcjtEZWRB/k5zvv+3YLZRerUIe1zRiWxgO3NgSoV6qPuyDWkv8jzJPxtDdNUOFSdLZY1OjcJWDE23f0R0CIBtPGPyJhcxLOSWV2xL8BbmIboWQCyW8Fi6jY/O/s3nte0REy84vMudarluYv+W0ZZLkPSDqr8bJ+Xm4lMvGQzA0B7uNQUB91+7zFH0sAFz4bTJJJnV2d1nTa3mrTr8uE2Q3drKCnPjvAwNb/uWA/QNypV7iF8+rEqR2mz5coOaGTUAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=xmos.com; dmarc=pass action=none header.from=xmos.com; dkim=pass header.d=xmos.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xmos1.onmicrosoft.com; s=selector2-xmos1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vBs5TJZ4B30P2+SwPhH8ODE6QaHkCTmwz1B0R+HE37U=; b=Vtfx165Mfv8V3QphUJdG87IpohZihufP0uD4BEHiqNBhh/Xp49jnTJvZeYSuEdUD6TM+/XQy4+US8F3Njsv7y5vV5JcFJmv4gO2ZTTPjlAS6vcBJ1GckAnxIrKenQ+jDY9x30rvHbmqe1Bj9xP2lqPG1MazTBrDTqaSR5mroixg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=xmos.com; Received: from PAXPR09MB5583.eurprd09.prod.outlook.com (2603:10a6:102:280::6) by AM0PR09MB3906.eurprd09.prod.outlook.com (2603:10a6:208:1a2::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.22; Fri, 1 Sep 2023 11:14:16 +0000 Received: from PAXPR09MB5583.eurprd09.prod.outlook.com ([fe80::e0e8:7766:49eb:d856]) by PAXPR09MB5583.eurprd09.prod.outlook.com ([fe80::e0e8:7766:49eb:d856%4]) with mapi id 15.20.6745.021; Fri, 1 Sep 2023 11:14:16 +0000 From: Ciaran Woodward <ciaranwoodward@xmos.com> To: gdb-patches@sourceware.org Subject: [PATCH v2] gdb/riscv: Fix oob memory access when printing info registers Date: Fri, 1 Sep 2023 12:13:55 +0100 Message-Id: <20230901111355.18785-1-ciaranwoodward@xmos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230831112449.3822-1-ciaranwoodward@xmos.com> References: <20230831112449.3822-1-ciaranwoodward@xmos.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: LO3P123CA0028.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:388::20) To PAXPR09MB5583.eurprd09.prod.outlook.com (2603:10a6:102:280::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR09MB5583:EE_|AM0PR09MB3906:EE_ X-MS-Office365-Filtering-Correlation-Id: 9af6d5e4-9974-47b8-cc48-08dbaadc9455 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tT+NazjC5+ntLnFEmX17d+sb6xK5NyCeKfmMwwbWow3793CKf9AmBUhrJDYUx6+rFqbGb6SntPG+9NFACd7laf36kurxOELsx/MGqsEkAdDyKStc9BVlf3d6LMyPgr+w/i+5JXfWCxVG93CROoWhUWOMfOhx7YgU2/Y39z5A1v6pr9U7j0okHR8hiV5nViytz50/QV/FFtYoizXpTsXF+QomQqIff4i/9LIgYSGNhmQskT6fR8yVynZuzTDc3q9rnMJQPbuLIPohDrpjwof2HxtYlDbar06DFnmzx1SGcnbK7pqPc7hSKMKZvSTwTegxnBQJ+Y2pZMTLtKVlPjeDjn23OC+iOnBxbMEtaQ+lAh9JPwYooPq8gsDYwnThkTludoSYblSvnxfcJwpvZnDx0HoeIiacBQQwtQrXV3zxAHVFUmekMzhf4y1zbayoB3CbKp/RZv+J4ejs02nnutLklTFOGtcW6P7kBpH2CXThkIATQ6w9l0IOQS8kZVGMMtLAdiRFrwLmPnnUs7aiDMq1qPr6cLUw1dfnsk13tOxRqPnwbYwTIpf8ZfOwtZa9JCoGr6PE+k79LEB6n+LFoVGagE9MY2SBDwS090uHmT+mFxX8fTX0vN/EjCevzBHJePlQ X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR09MB5583.eurprd09.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(136003)(346002)(366004)(396003)(376002)(39840400004)(451199024)(1800799009)(186009)(6506007)(6666004)(6512007)(6486002)(36756003)(86362001)(38100700002)(38350700002)(107886003)(1076003)(2616005)(26005)(2906002)(4744005)(55236004)(52116002)(83380400001)(478600001)(66946007)(8936002)(8676002)(4326008)(5660300002)(6916009)(41300700001)(316002)(66556008)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XLjqRPZ2llcRfzqc9513pTWUSmBqpKfTDiEadfZNP+tEUFg9KxCEOq6r0AlIMG0qqnSp5lpmKgOiFhySdcP84uqOSoHHoVNeCXp32E5kkJ5t/ZU3BwXsknHH2n+I2pm52bmw9zXOVqKF5/pOokqYu9DqPA1L35wAs0sBEQO2fX97FanXfyzhEvnnG6rMho0PeS9X5NSgJm/s75I72BF3xtdSpejfnFuk/qMymj3OPTLLvUqll1D2eizPOnwKJKy4pJmLhuOt/V+Q//7So2nDcL5zt9qKrn2bYXCvhjtpcV4i3GcbcV5JXjp71W9phItesMhfZ+hEN3RGFyY4SQnsRM+O0nnH/G6JTtmybaDgi44Is3CBbyFwvyhsHSlLFh+iapcC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7UQDTjspFjAtn2eudg7ssDDuVTZadKE0GNC4PXPPhqPdVyIrbXJHF3urzdetnIiigPPe4WL9Uysd4j9Fw2FpGvhqMaQ7W7oF1Z8KQa7/fise+jXAM6 X-OriginatorOrg: xmos.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9af6d5e4-9974-47b8-cc48-08dbaadc9455 X-MS-Exchange-CrossTenant-AuthSource: PAXPR09MB5583.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2023 11:14:16.3382 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 975ecfb1-4080-42d2-a01d-4a4d0707a539 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DxwbNfWb/29qit98Ulgj1H1T7qTrJBZxOoZ+HYZnkLYklbzqhEGFyIyzzVVnsNwZgwYuPTg0X4hppXvWxBvvhw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR09MB3906 X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
[v2] gdb/riscv: Fix oob memory access when printing info registers
|
|
Checks
Context | Check | Description |
---|---|---|
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 | success | Testing passed |
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 | success | Testing passed |
linaro-tcwg-bot/tcwg_gdb_build--master-arm | success | Testing passed |
linaro-tcwg-bot/tcwg_gdb_check--master-arm | warning | Patch is already merged |
Commit Message
Ciaran Woodward
Sept. 1, 2023, 11:13 a.m. UTC
If the length of a register name was greater than 15, print_spaces was called with a negative number, which prints random data from the heap instead of the requested number of spaces. This could happen if a target-description file was used to specify additional long-named registers. Fix is simple - don't ask for fewer than 1 space (since we still want column separation). --- I don't have push privileges, so please can you push this for me! gdb/riscv-tdep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index ae18eb64452..3a2891c2c92 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -1145,7 +1145,7 @@ riscv_print_one_register_info (struct gdbarch *gdbarch, enum tab_stops { value_column_1 = 15 }; gdb_puts (name, file); - print_spaces (value_column_1 - strlen (name), file); + print_spaces (std::max<int> (1, value_column_1 - strlen (name)), file); try {