Re: [PATCH v2 1/2] util: Check if kernel-provided info is consistent with itself

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Feb 02, 2018 at 15:27:21 +0100, Martin Kletzander wrote:
> Just in case someone re-mounted /sys/fs/resctrl with different mount
> options (cdp), add a check here.
> 
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1540780
> 
> Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
> ---
>  src/util/virresctrl.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
> index ef388757a704..6860e86e649d 100644
> --- a/src/util/virresctrl.c
> +++ b/src/util/virresctrl.c
> @@ -941,6 +941,17 @@ virResctrlAllocParseProcessCache(virResctrlInfoPtr resctrl,
>      if (!mask)
>          return -1;
>  
> +    if (!resctrl ||
> +        level >= resctrl->nlevels ||
> +        !resctrl->levels[level] ||
> +        !resctrl->levels[level]->types[type]) {

The only caller of this function checks the range of type by converting
it from string with 'virResctrlTypeFromString' but the type in this
function is 'virCacheType' and you use 'virCacheTypeToString'.

Given the inconsistency and the fact that C will not validate the passed
type in this case you should also validate that 'type' has the correct
range.

ACK with that check added.

Attachment: signature.asc
Description: PGP signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux