[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 4/4] automation/eclair: deviate MISRA C Rule 11.8 for xfree() and vfree()
- To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx>
- Date: Tue, 17 Nov 2026 22:01:49 +0200
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=RRzRUb02wn0dNPPs83iGYBLA70d7sWs6sN9bzdYnSpk=; b=D/nU0j9lT2HzfFrsOnNS8RQaNUs9EkkfwMFqfZ9SyKfe0X1N2T3LW+PXfZUg+wGMoqSB1sLtuDL8NmnQTHOq5y8KuzKwMN++NlT+Qbg+wclH6uilAcE1b2jyPf1WS0yexe911L6bCvr9G77oKTVPOz2SAwyM0L66hqbR2HA4MrhBCJN8D9NdmXaso6AHItFtfE15Eey33rYVKH9191VQn2EtelO5Aozld8EUleUc3KEXzqlepLBkUwYRCmpDbCshs3guWkCDqejr/SuMHyAgetRXwmeuYByd+zZftmR1VLEGuM2yj34oneENbHEGTQMolAQYciVxhISfdjpv9bsI9g==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NOkXDEISLd3jmdunm5muRqVDytgEzIcAanHBMP/Jj9Qx9vb7zlIBrYwAhKP00f9uKpwv+tSH6NqXjQje+fs15d98CYAeS/2/vwAAsPe16bTq3wCHJWreTtpzm++eX7jmQZfvEB0eGRVacWS/3LOi7Oc90oFJC9zfLqHjYA8vcj/XeVJJaIQI1k1x8u0HhwKnFcjJFmQtctmdekzs4dFP7GIjTFHnY2v/SNBcJ4/0K0vXgC9DJoJg4TD3vyhGjUZNL1XxveZ+f++paQJsfu7lA4ynroled94kYoLYNcNm+FVL5sqidh86hSSeybpeUDQYnVmK19t2NvSkN0h7vTWhlQ==
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
- Authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
- Cc: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>, Doug Goldstein <cardoe@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>
- Delivery-date: Tue, 17 Nov 2026 20:02:01 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 11/4/26 13:24, Andrew Cooper wrote:
On 03/11/2026 10:29 am, Dmytro Prokopchuk1 wrote:
Livepatch passes const-qualified pointers from struct payload to xfree()
and vfree(), which take a 'void *' argument. The cast that removes the
const qualifier is a violation of MISRA C Rule 11.8.
Such casts are safe. The deallocation functions neither read nor write
the content of the object being freed, and the object is not accessed
after it has been freed.
I have a very firm objection to this.
It is impossible for any allocation from malloc()/calloc()/etc to point
to read-only memory, which is why free() takes a mutable pointer, not a
const pointer. The same is true of any other heap implementation.
It is impossible to make an object in read-only memory undefined.
Objects in read-only memory by definition have a global lifetime, and it
is absurd to argue that a specific heap implementation ought to permit
making such objects undefined.
The bug here is livepatch storing a heap allocation in a const pointer.
This comes from deeper problem where some contributors/reviewers want
the const keyword to mean something it doesn't.
~Andrew
Jan, Andrew,
thanks for the review. Given the disagreement, I will drop this
deviation for now.
If the preferred fix is to stop storing heap allocations in
const-qualified members of 'struct payload' (so the casts go away), I
can prepare a follow-up patch. Please confirm that is the direction you
want for livepatch.
BR, Dmytro.
|