From patchwork Wed Jul 19 06:33:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jammy Huang X-Patchwork-Id: 13318336 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC2BCEB64DA for ; Wed, 19 Jul 2023 06:33:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230318AbjGSGdY (ORCPT ); Wed, 19 Jul 2023 02:33:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230143AbjGSGdX (ORCPT ); Wed, 19 Jul 2023 02:33:23 -0400 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2118.outbound.protection.outlook.com [40.107.255.118]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A4611FCB; Tue, 18 Jul 2023 23:33:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lFaoU1KckSwsbkAZXevH0XK34kzdsMYq4pQFJL52hdGZLZozdeyjGN9ChmQ5xLJt0emUF42TpP/33cdemZ4stU7ZL+6Az7WqsAKpPS+5Rn0wYeEZABXUl48au1ePw1A62Kw3xSdpN/txFaDBgCldviLGWLhoasie49YVrNvfhChD39MmQ2993OJGaVD14z0xv266XEwVtsbag5kuM6gurkyWmb5qUCRMyesmd+jj2AqcMc0ERyyMYm0jyUMHBc5OXMMaUdlMD/gtCPu+3xLw5cxO0p6GYBB3Yw/jM34i8nL4IrYZhNv0y35zMwPsefUlr6YRqza4OCOD+5jDiAdCcA== 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=pQbB9AeJxrvjKq2Af2sz4lX/ZqNpRW1aGmgojZJpt7E=; b=b+sBq5reIA2kGvfbrIHHRIGxKzn4ebqSAqvNRhNJEI2MC/dkowuHnC0gNPSrf9hUqFYoFOgszEaeucn3fYRoBmfWrLmEhCvvHSsarCZcJ1nKLkDFsY/1y1hf0IlDnzXKXyN7TDtOc5z4Mw/nQQdTbeN0Wu7Y8EPDR6vPnX2OmlOKbgcdgalaYLK/+FUsUIiwuE2ep28zMzqm8ZYZFSRqPxdLtRn2X8L0D5hH7sN2qQALdtaWdalz99jlCMUXVkKnA+JzI5BDwvnFGNo93QO68JyHAsrrdReCli7HN4+L1zeEeZ2rnhkhuN5ThteIPASgWCW426ErCqmsGQQK+9bYwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=aspeedtech.com; dmarc=pass action=none header.from=aspeedtech.com; dkim=pass header.d=aspeedtech.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aspeedtech.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pQbB9AeJxrvjKq2Af2sz4lX/ZqNpRW1aGmgojZJpt7E=; b=cddBzSLcZfykKYNwjserqse2JvLHIds6bWyrFNGJj5drgFy9WFeFOthoRguP3uY/88LuHKGbpOA6AKLKBgnNVKycqFZvnJwE+NIlO3ghplPoZlVa0c1qlTzdXYXw4KWn1JluG1cDJSEczkAaAyz2gwU3tTmZVAy/yv7LUXYMhQS5T1hqsJbbUf4yxmZzJCz+ZJIwJdKur3L6CChSsJwV4TCIo0bIs2xXcFsLv8d0OdhURPFqCnPtehLATAJnblqrobcpowRezxrjX3C+03+O5+hgVldv0m5w6m+diqFiW9ItsUVFCyrwxMjcSLkLmzLXfwEg5hL/mSznWJR8N5nElA== Received: from TYZPR06MB6568.apcprd06.prod.outlook.com (2603:1096:400:45f::6) by SI2PR06MB4410.apcprd06.prod.outlook.com (2603:1096:4:15e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.33; Wed, 19 Jul 2023 06:33:18 +0000 Received: from TYZPR06MB6568.apcprd06.prod.outlook.com ([fe80::72f5:eab8:7757:7c49]) by TYZPR06MB6568.apcprd06.prod.outlook.com ([fe80::72f5:eab8:7757:7c49%6]) with mapi id 15.20.6588.031; Wed, 19 Jul 2023 06:33:18 +0000 From: Jammy Huang To: Hans Verkuil , "eajames@linux.ibm.com" , "mchehab@kernel.org" , "joel@jms.id.au" , "andrew@aj.id.au" , "linux-media@vger.kernel.org" , "openbmc@lists.ozlabs.org" , "linux-arm-kernel@lists.infradead.org" , "linux-aspeed@lists.ozlabs.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH RESEND v2] media: aspeed: Fix memory overwrite if timing is 1600x900 Thread-Topic: [PATCH RESEND v2] media: aspeed: Fix memory overwrite if timing is 1600x900 Thread-Index: AQHZugrnPAu3uBx5akaz+7fGPVJhRg== Date: Wed, 19 Jul 2023 06:33:18 +0000 Message-ID: References: <20230717095111.1957-1-jammy_huang@aspeedtech.com> <21e13f35-5caf-6d60-c388-3386e3540834@xs4all.nl> In-Reply-To: Accept-Language: zh-TW, en-US Content-Language: zh-TW X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=aspeedtech.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: TYZPR06MB6568:EE_|SI2PR06MB4410:EE_ x-ms-office365-filtering-correlation-id: 0642e748-6873-4f04-223b-08db88220a26 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: NjgC0TbLCCTdYVUm7lxRZNtKNBrHAwEsLnpvX57rof3NfzeZsRK+0K+wCfFTGRX3hCFN4H5lsf0VizKrSwfUXkklysO/RvWT082u1W707t9XU3Xdaq1XjE4xeCiWdykRQKoKhToRagbDmnM0XFiAZzOvxEovyFkSPTqzXkfZ0u1DmVXaPn5wigr/hk3S7t3p4jl34rz9Xnl+SLBmBoKa/kzRlSCTE4cMkQhF6K/g28T4CpJEqbd1bRVWxvyBEorPvN6cxMoDVZGRMgeeQxNo2KRep6KCzuTld5sfQ4PGLYFNAZqxEegVXOMKm+wbwJQ4MylbxyXYWehR4BAnoAihgxEFjXRpOVo3DxxYFTEvSvJZw85l+qBCC9o1nUY/E+xeWaNWoiHF/N0xEdB6muFp2OAQrcLglNt9mhzagb6syOoFegd2urJXdVtrdniVyJum4fhR2h8pV2icIbP9UxyxXOsildn+Yo5tHXd1ILnuyRfQQhmP2Id472+FZXI59rwitbEsKca/jGA5Fzr+3V2XKARqeKlxyL3xlPMxPdAyNsywnTFcS71+C3icPZW+asN5bxiEQdIffDgaSnSQdxrwGHg2ugyEe4O85rlgfpl3Ex+ErYxgNaHKeovDjZwJPFxYEF5S+9dpkvZ3JJblEpzokw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYZPR06MB6568.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(366004)(376002)(136003)(39850400004)(396003)(346002)(451199021)(38100700002)(7416002)(8676002)(5660300002)(8936002)(41300700001)(52536014)(7696005)(2906002)(316002)(110136005)(478600001)(71200400001)(83380400001)(2940100002)(186003)(6506007)(26005)(9686003)(76116006)(66556008)(66476007)(64756008)(66946007)(66446008)(55016003)(38070700005)(33656002)(86362001)(921005)(122000001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?GF/xSbi353K4A4/r1WQdlF7Lqhxr?= =?utf-8?q?Kp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?OpWxOq/8DnGSBHSepSu0akY6IajhehZbvdXf2C307EV812lQM1YmmVodbYo1ho8wu?= =?utf-8?q?qq3o74PxBHIlxlxdrt4ml9HgNtWNkRe2y2oCID6OvD7wHzpBXeM0jszv9lZ54eA8H?= =?utf-8?q?pgmeISn5uKT3/0AQgqXCyjI5hQVkzTYHFrxxF+NXZ9/aIdUMtDvDV7C6+7g9+UvR3?= =?utf-8?q?O2oamlm0/22IcULdjX9dz2I5ixTzHV4UsNVYLFjg5fqClyX9vd9p1VXgtOolzCTaO?= =?utf-8?q?PODpg/sLPJZGrPW6jARacaIXABshJXhVKTTtkoIxHd2IW4+Mn2wEMlEtV6vOOxZFE?= =?utf-8?q?ozQqwumGG4pnaA3qEbGb6nDIQTnBF9DzEacIecK20K8g+CUdWKlXGvVJX6m5z4A8s?= =?utf-8?q?QdI8a8hZ9skLpKV9PnFHm1OYfYhk2e8nzLa+bABe5S8AyPo6/9BPWHgcxCJXdLQRc?= =?utf-8?q?LVZiqLIZ0Ud8/uMjyL9DvLJUrA5rrGe7oISusaXtHAvqBu1VY5tewZiQbHsIYpTAf?= =?utf-8?q?k7rw/IJI9tJnxdcWplF98KEn76eQ2py4+6yuctLcyWN5mZoTxZz6pRI5tXdrxE2K/?= =?utf-8?q?ZeCxUec7WYpSUEMNaqzdliqmTUk7g2LnT/kJGRXURSdbTyH0DZN44bcpJa2tvWp7W?= =?utf-8?q?7wbh4mZnBsg+uHrQin48El30dadr59djMA=3D=3D?= MIME-Version: 1.0 X-OriginatorOrg: aspeedtech.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TYZPR06MB6568.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0642e748-6873-4f04-223b-08db88220a26 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jul 2023 06:33:18.3402 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43d4aa98-e35b-4575-8939-080e90d5a249 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: YGLpzfaGfyjJqJIavt8zmKS5P+m/PnumZmX+ij2Q6r23JwvBTI6UFT5fIXgnuFNps0FtF9wmONy5qSrtA3QvIh3T8fdgEfEFNWp+ut4cwiY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR06MB4410 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org When capturing 1600x900, system could crash when system memory usage is tight. The way to reproduce this issue: 1. Use 1600x900 to display on host 2. Mount ISO through 'Virtual media' on OpenBMC's web 3. Run script as below on host to do sha continuously #!/bin/bash while [ [1] ]; do find /media -type f -printf '"%h/%f"\n' | xargs sha256sum done 4. Open KVM on OpenBMC's web The size of macro block captured is 8x8. Therefore, we should make sure the height of src-buf is 8 aligned to fix this issue. Signed-off-by: Jammy Huang --- v2 changes - Add how to reproduce this issue. --- drivers/media/platform/aspeed/aspeed-video.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) base-commit: 2605e80d3438c77190f55b821c6575048c68268e diff --git a/drivers/media/platform/aspeed/aspeed-video.c b/drivers/media/platform/aspeed/aspeed-video.c index 374eb7781936..14594f55a77f 100644 --- a/drivers/media/platform/aspeed/aspeed-video.c +++ b/drivers/media/platform/aspeed/aspeed-video.c @@ -1130,7 +1130,7 @@ static void aspeed_video_get_resolution(struct aspeed_video *video) static void aspeed_video_set_resolution(struct aspeed_video *video) { struct v4l2_bt_timings *act = &video->active_timings; - unsigned int size = act->width * act->height; + unsigned int size = act->width * ALIGN(act->height, 8); /* Set capture/compression frame sizes */ aspeed_video_calc_compressed_size(video, size); @@ -1147,7 +1147,7 @@ static void aspeed_video_set_resolution(struct aspeed_video *video) u32 width = ALIGN(act->width, 64); aspeed_video_write(video, VE_CAP_WINDOW, width << 16 | act->height); - size = width * act->height; + size = width * ALIGN(act->height, 8); } else { aspeed_video_write(video, VE_CAP_WINDOW, act->width << 16 | act->height);