diff mbox

[v4,01/11] livepatch: Expand check for safe_for_reapply if livepatch has only .rodata.

Message ID 20170920223148.13137-2-konrad.wilk@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

Konrad Rzeszutek Wilk Sept. 20, 2017, 10:31 p.m. UTC
If the livepatch has only .rodata sections then it is OK to also
apply/revert/apply the livepatch without having to worry about the
unforseen consequences.

See commit 98b728a7b235c67e210f67f789db5d9eb38ca00c
"livepatch: Disallow applying after an revert" for details.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
Cc: Ross Lagerwall <ross.lagerwall@citrix.com>

v3: First posting.
---
 xen/common/livepatch.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Ross Lagerwall Oct. 5, 2017, 1:47 p.m. UTC | #1
On 09/20/2017 11:31 PM, Konrad Rzeszutek Wilk wrote:
> If the livepatch has only .rodata sections then it is OK to also
> apply/revert/apply the livepatch without having to worry about the
> unforseen consequences.
> 
> See commit 98b728a7b235c67e210f67f789db5d9eb38ca00c
> "livepatch: Disallow applying after an revert" for details.
> 
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> ---
> Cc: Ross Lagerwall <ross.lagerwall@citrix.com>
> 

The patch looks OK, but what is the use case for a live patch with only 
.rodata?

Regards,
Konrad Rzeszutek Wilk Oct. 5, 2017, 1:51 p.m. UTC | #2
On Thu, Oct 05, 2017 at 02:47:30PM +0100, Ross Lagerwall wrote:
> On 09/20/2017 11:31 PM, Konrad Rzeszutek Wilk wrote:
> > If the livepatch has only .rodata sections then it is OK to also
> > apply/revert/apply the livepatch without having to worry about the
> > unforseen consequences.
> > 
> > See commit 98b728a7b235c67e210f67f789db5d9eb38ca00c
> > "livepatch: Disallow applying after an revert" for details.
> > 
> > Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> > ---
> > Cc: Ross Lagerwall <ross.lagerwall@citrix.com>
> > 
> 
> The patch looks OK, but what is the use case for a live patch with only
> .rodata?

A NOP one. This hasn't been an issue in the past, but further patches
change the .livepatch_funcs from RW to RO (to be in line with what
livepatch-build-tools.git do) - and then the xen_nop testcase does not
work anymore.


> 
> Regards,
> -- 
> Ross Lagerwall
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> https://lists.xen.org/xen-devel
Ross Lagerwall Oct. 5, 2017, 2:08 p.m. UTC | #3
On 10/05/2017 02:51 PM, Konrad Rzeszutek Wilk wrote:
> On Thu, Oct 05, 2017 at 02:47:30PM +0100, Ross Lagerwall wrote:
>> On 09/20/2017 11:31 PM, Konrad Rzeszutek Wilk wrote:
>>> If the livepatch has only .rodata sections then it is OK to also
>>> apply/revert/apply the livepatch without having to worry about the
>>> unforseen consequences.
>>>
>>> See commit 98b728a7b235c67e210f67f789db5d9eb38ca00c
>>> "livepatch: Disallow applying after an revert" for details.
>>>
>>> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>>> ---
>>> Cc: Ross Lagerwall <ross.lagerwall@citrix.com>
>>>
>>
>> The patch looks OK, but what is the use case for a live patch with only
>> .rodata?
> 
> A NOP one. This hasn't been an issue in the past, but further patches
> change the .livepatch_funcs from RW to RO (to be in line with what
> livepatch-build-tools.git do) - and then the xen_nop testcase does not
> work anymore.
> 


Thanks, that makes sense.

Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
diff mbox

Patch

diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c
index 66167a5573..b0dcd415ba 100644
--- a/xen/common/livepatch.c
+++ b/xen/common/livepatch.c
@@ -417,9 +417,12 @@  static int move_payload(struct payload *payload, struct livepatch_elf *elf)
         }
     }
 
-    /* Only one RW section with non-zero size: .livepatch.funcs */
-    if ( rw_buf_cnt == 1 &&
-         !strcmp(elf->sec[rw_buf_sec].name, ELF_LIVEPATCH_FUNC) )
+    /*
+     * Only one RW section with non-zero size: .livepatch.funcs,
+     * or only RO sections.
+     */
+    if ( !rw_buf_cnt || (rw_buf_cnt == 1 &&
+         !strcmp(elf->sec[rw_buf_sec].name, ELF_LIVEPATCH_FUNC)) )
         payload->safe_to_reapply = true;
  out:
     xfree(offset);