From patchwork Mon Oct 4 14:44:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 30897 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp4390718iob; Mon, 4 Oct 2021 07:45:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqst8I+/pYgBrmNCPC4GYReIrwycDxYOU8VUjCL6cD5ZIr3DQUt8J0OuES/j1U212c/DlP X-Received: by 2002:a17:906:a0da:: with SMTP id bh26mr17403177ejb.505.1633358709348; Mon, 04 Oct 2021 07:45:09 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q6si5391285edj.430.2021.10.04.07.45.08; Mon, 04 Oct 2021 07:45:09 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b="pZy2vUN/"; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id ED0BA68A776; Mon, 4 Oct 2021 17:45:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-oln040092067080.outbound.protection.outlook.com [40.92.67.80]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 91A0D68A776 for ; Mon, 4 Oct 2021 17:44:57 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kHG5+f7h97CNM3nrYr0X95OIvIsXImFrCxpqJYo5C3Ef3mCQ88VaqKgNavSzZu/pxgK55S4Ql03LyozLnX0ab44q/WtNsiCz5ivf9ypDCTSuZJW9gVNb79NBX+lajD8gRnaNkll7VdmyDlLs0Ut5CRfKslM4+fGE1dOhq4Kna6z3x3AwU+nEkdS+NriLSIe6muacUEdhzBJ85vO5Rwlz2BfuFwUk1DkXJpEUWP15iLrdxo229uB+VQYKhwGEFiONbB2WLE4UkXjOjIkWq11uBj0q84UnFPnYQt1py40XcHGtkwxyWZ7b81f6iGyeknH+tImEmw8c6ECKr4YhblwYMA== 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=yYwsXj9zijvggVnQDNjNnrocJd7b07cuJ96ZBLhMe5o=; b=VrJtSvt4o+FHRfXX/fGEgrE+yiV3FU9I8MOSIwc1j4hMmPAXz1vCkbEI6sCrHUrGN9cb5bpw457MtxDnHR+kFu4tiFEPcw1pBkbSrwUnUAmg9tZ5rFgzKRel4fWTym5XGY2Jj2Xgb+mAn2XkgIpOVlbKvsPsu2dDSOvYWm/R1Yck3ftieBire8FvW0nycalbsGePKPVcCKinj6blWEYWtNQLfsbIhhuvwJtaG96YHBaQbSY+IBX6A0awSMn3AXuGsz1cTSiLQTAk/cofF895F+3kfFGSS6ooX9lG45onBXYA3q59LM+w2qz3DOysp4ASAr1UMAaaTomYH+lbstGAXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yYwsXj9zijvggVnQDNjNnrocJd7b07cuJ96ZBLhMe5o=; b=pZy2vUN/JofPHuGEzKQ8utWBl69Bem6ztT3m4k/wqGHXoM/H2Hv7kistab5b92+l2ib/UKzaF6Tg0TOPOR4O2BW57aQUQKpF7R1lx8hwlSf+lQ/No6JNMRHcQCKO2Sgg/xsfJKHlWhmlpS4Wt04OgszP1pcR5s2V9OWiz1IeCV91HjdDdvJulyW1UcPsPSSWfGT6tl35EWvWu7KN6EnMgodAHPVDyzi9PWoiRihHuxOmPUf5NiQuFwOjgCXwFM0l/Xyijk/WHf7lQT330KRFG3+Utxhi4DJUKUGXMRp630RdejEti419BkxAlyfs4183ZBeJxTmhSvlYj4ycmS8Q0A== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM6PR03MB5379.eurprd03.prod.outlook.com (2603:10a6:20b:c1::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.19; Mon, 4 Oct 2021 14:44:55 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::700f:d70b:3bb8:4d51]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::700f:d70b:3bb8:4d51%7]) with mapi id 15.20.4566.022; Mon, 4 Oct 2021 14:44:55 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Oct 2021 16:44:46 +0200 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: X-TMN: [LNtVtrp7U79Fn/rwss8z8oWVP8vHm/tK] X-ClientProxiedBy: AM6P191CA0044.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:7f::21) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20211004144447.3984261-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.142.38) by AM6P191CA0044.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:7f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.15 via Frontend Transport; Mon, 4 Oct 2021 14:44:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5c74b7e9-3d9b-4ca1-5932-08d9874587cc X-MS-Exchange-SLBlob-MailProps: EpEO96k6Wond71G3Ekn5Zra0hKkmyBNjf9OwK3zHYZYBP5mnwfbyulCPX4+li14QnHiP9gQdrZy41kdpyz6kFACiIEY67/mTydC78QnQVs/ywrWI7+nqXHYgWFyb/lyxHueGkh2tLkU8oK1cyCj/LFaqdmWk/MvnlCxL6MQEyfx+I4W3/8LmReIKv2DNeJ97UyGNStHhtWJe2ciVnbpwpB3J1Pym/raoz8pAZ3HpCnphkUYYeRR8ciC2/UsBb1tn+3Cf27Xzr5m5J+73T0670CFu5d6Q1GCgRuG6/ESo0xwgTNAUfEqgAmgh5JegcU2BcQn1cFcELkhyWmeZVbYSppzbIw7tZBDszJUUkoKi/x9j+o14uRZCrpbWEy07DgX9x7BtvZnB9zQYxdnKwh0Smim+6qNc2Kcx2/U2ZYo9sH2a4X8MfpJbVwkVtUhf+joRf6eIOOhuv+LZqiqtw7KLBsiLJy9zVlj4EmBwheF+LteQ5UZ0+hkQ7lnAowpirMN77N3PWrYdhOyXv/jHLUsnVPKW45fVrSaJjNKTqsBTahzFEx0P2hp04kI3KWcjbyYapK2hbvZi5FiwriYfOrOZ1YoGW/lnuugMXnI5czUxDqGKgaeYVwEfRIH5zs2I3AS3qje4Y+Mwwph3mYUP+cCEWTQLRbvs/kFsEIkg27dhbnxC/5d7z/zFlyiri1bnKNEpVdYvYXtjVJyI8n6WWyau5bVYnqVjdQjIxLMf/faxqs2719AXuuBNTLRYkxApRmqkVFsoXXJeFaw= X-MS-TrafficTypeDiagnostic: AM6PR03MB5379: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QMigTOrP8dQyafsn6vC+3cVpiAiGxnHcmHQYxHORuUIo+eO8WEWLEwBsmpGk7OAJST/Km2a+KVyqhCf0o7nAq6ppAdPdGgHzmU/jqv+zf5IbPc3588XnLLwZ8LOD2pA2gqVAgJrKGs/uoapxmtXQW2mcarPKFxJS3L3cljN/ZkYX3kBuozq+9qPvM2a29JpBp0axoo0u8lSZtNppABKJ4IfyoFX5P1l41np5RBC3pmfD5G3Thsnh7KkDpjnreHoFA8V7Y0bsdBV3u8XsrWBcjpbAunMfjFUhQblK8WJ/bY1bS4c1dRs+iglJ2MLMZILQGGKUE28aWc81Kwc4es2VAiEekDPdEALju3B9m7/VKl1Scb/av3bHOEJ3KBnWj1B6iqbbyziA1z+Ww5Lp3NOeazG7B0z/uHxDRrgF9NkzzB/GdrDx2HE+kzHjgkf3iJOZ X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Xi/kzaJ5BWtvReHmfGQyFTzR79l1L5q06+HmxGUYuPI0JEuKXJuG44KvKbDZTeql6ugZ7SsEEXJzIjKPETGhrEv1Ii+dhguMSEoOHY7woMQQcjHLly6hrM3Q2+IWuMftGpDxlXTBTytYSs0LEpq2/w== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5c74b7e9-3d9b-4ca1-5932-08d9874587cc X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2021 14:44:55.3193 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB5379 Subject: [FFmpeg-devel] [PATCH 2/3] avutil/buffer: Never poison returned buffers X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: /URezv9VTp5S Poisoning returned buffers is based around the implicit assumption that the contents of said buffers are transient. Yet this is not true for the buffer pools used by the various hardware contexts which store important state in there that needs to be preserved. Furthermore, the current code is also based around the assumption that the complete buffer pointed to by AVBuffer->data coincides with AVBufferRef->data; yet an implementation might store some data of its own before the actual user-visible data (accessible via AVBufferRef) which would be broken by the current code. (This is of course yet more proof that the AVBuffer API is not the right tool for the hardware contexts.) Signed-off-by: Andreas Rheinhardt --- Another thing that our current API is missing is a reset function that is called when a buffer is returned to the pool. If there were such a thing, one could use it for FrameDecodeData. But before this can be addressed the original sin of using AVBuffer for everything needs to be fixed. libavutil/buffer.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavutil/buffer.c b/libavutil/buffer.c index 54590be566..e4562a79b1 100644 --- a/libavutil/buffer.c +++ b/libavutil/buffer.c @@ -341,9 +341,6 @@ static void pool_release_buffer(void *opaque, uint8_t *data) BufferPoolEntry *buf = opaque; AVBufferPool *pool = buf->pool; - if(CONFIG_MEMORY_POISONING) - memset(buf->data, FF_MEMORY_POISON, pool->size); - ff_mutex_lock(&pool->mutex); buf->next = pool->pool; pool->pool = buf;