]> xenbits.xensource.com Git - xen.git/commitdiff
livepatch: Add limit of 2MB to payload .bss sections.
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tue, 6 Sep 2016 16:45:50 +0000 (12:45 -0400)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Fri, 23 Sep 2016 16:39:43 +0000 (12:39 -0400)
The initial patch: 11ff40fa7bb5fdcc69a58d0fec49c904ffca4793
"xen/xsplice: Hypervisor implementation of XEN_XSPLICE_op" caps the
size of the binary at 2MB. We follow that in capping the size
of the .BSSes to be at maximum 2MB.

We also bubble up the payload limit and this one in one #define
called LIVEPATCH_MAX_SIZE to make it easier to find these
arbitrary limits.

Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
xen/common/livepatch.c
xen/common/livepatch_elf.c
xen/include/xen/livepatch.h

index 912729e96957ba92dc8e596f740c2fcbf6867217..f5ce28c7263acca3be009976933536f0fc260660 100644 (file)
@@ -123,7 +123,7 @@ static int verify_payload(const xen_sysctl_livepatch_upload_t *upload, char *n)
     if ( !upload->size )
         return -EINVAL;
 
-    if ( upload->size > MB(2) )
+    if ( upload->size > LIVEPATCH_MAX_SIZE )
         return -EINVAL;
 
     if ( !guest_handle_okay(upload->payload, upload->size) )
index 6c7773bf75b2df681ea7d753c6974644b353db3a..dec904a48f027bb574dd2ff77635f0a806037b3b 100644 (file)
@@ -86,6 +86,10 @@ static int elf_resolve_sections(struct livepatch_elf *elf, const void *data)
                     delta < sizeof(Elf_Ehdr) ? "at ELF header" : "is past end");
             return -EINVAL;
         }
+        else if ( (sec[i].sec->sh_flags & (SHF_WRITE | SHF_ALLOC)) &&
+                  sec[i].sec->sh_type == SHT_NOBITS &&
+                  sec[i].sec->sh_size > LIVEPATCH_MAX_SIZE )
+            return -EINVAL;
 
         sec[i].data = data + delta;
         /* Name is populated in elf_resolve_section_names. */
index 243e240511cd18110e4d78d44a69f5952bd031ec..29c9b3141b2dd729356f728daaf1dd71cb81304f 100644 (file)
@@ -30,6 +30,8 @@ struct xen_sysctl_livepatch_op;
 #define ELF_LIVEPATCH_FUNC    ".livepatch.funcs"
 #define ELF_LIVEPATCH_DEPENDS ".livepatch.depends"
 #define ELF_BUILD_ID_NOTE      ".note.gnu.build-id"
+/* Arbitrary limit for payload size and .bss section size. */
+#define LIVEPATCH_MAX_SIZE     MB(2)
 
 struct livepatch_symbol {
     const char *name;