From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org
Subject: Re: arch/x86/kvm/x86.c:4988 kvm_arch_tsc_set_attr() warn: check for integer overflow 'offset'
Date: Wed, 12 Oct 2022 09:34:18 +0300 [thread overview]
Message-ID: <Y0Zf6g7ahY2b7MBK@kadam> (raw)
In-Reply-To: <2c36799c-af38-fed5-3f31-a8bde25368d7@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1064 bytes --]
On Tue, Oct 11, 2022 at 03:02:28PM +0200, Paolo Bonzini wrote:
> On 10/10/22 20:39, Sean Christopherson wrote:
> > > 828ca89628bfcb Oliver Upton 2021-09-16 @4988 tsc = kvm_scale_tsc(vcpu, rdtsc(), vcpu->arch.l1_tsc_scaling_ratio) + offset;
> > >
> > > Smatch hates obvious user triggerable integer overflows... No checking
> > > on offset.
> >
> > This is ok, and even necessary, e.g. if the host TSC > guest TSC.
>
> (which in fact is the common case). Also this is unsigned which is fine
> according to the C standard, though I understand that static analyzers want
> to be stricter.
>
> > Is there anything
> > we can do in KVM to help Smatch avoid false positives? Or do you/Smatch already
> > maintain a list of known false positives?
>
> Seconded.
Thanks for your feedback.
I could probably make a rule to ignore clock related stuff. That's
honestly been a known source of false positives for a while. I kind of
have the infrastructure so it's not super hard to do actually... I'll do
that.
regards,
dan carpenter
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild-all@lists.01.org
Subject: Re: [kbuild] arch/x86/kvm/x86.c:4988 kvm_arch_tsc_set_attr() warn: check for integer overflow 'offset'
Date: Wed, 12 Oct 2022 09:34:18 +0300 [thread overview]
Message-ID: <Y0Zf6g7ahY2b7MBK@kadam> (raw)
In-Reply-To: <2c36799c-af38-fed5-3f31-a8bde25368d7@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1064 bytes --]
On Tue, Oct 11, 2022 at 03:02:28PM +0200, Paolo Bonzini wrote:
> On 10/10/22 20:39, Sean Christopherson wrote:
> > > 828ca89628bfcb Oliver Upton 2021-09-16 @4988 tsc = kvm_scale_tsc(vcpu, rdtsc(), vcpu->arch.l1_tsc_scaling_ratio) + offset;
> > >
> > > Smatch hates obvious user triggerable integer overflows... No checking
> > > on offset.
> >
> > This is ok, and even necessary, e.g. if the host TSC > guest TSC.
>
> (which in fact is the common case). Also this is unsigned which is fine
> according to the C standard, though I understand that static analyzers want
> to be stricter.
>
> > Is there anything
> > we can do in KVM to help Smatch avoid false positives? Or do you/Smatch already
> > maintain a list of known false positives?
>
> Seconded.
Thanks for your feedback.
I could probably make a rule to ignore clock related stuff. That's
honestly been a known source of false positives for a while. I kind of
have the infrastructure so it's not super hard to do actually... I'll do
that.
regards,
dan carpenter
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Sean Christopherson <seanjc@google.com>,
kbuild@lists.01.org, Oliver Upton <oupton@google.com>,
lkp@intel.com, kbuild-all@lists.01.org,
linux-kernel@vger.kernel.org
Subject: Re: [kbuild] arch/x86/kvm/x86.c:4988 kvm_arch_tsc_set_attr() warn: check for integer overflow 'offset'
Date: Wed, 12 Oct 2022 09:34:18 +0300 [thread overview]
Message-ID: <Y0Zf6g7ahY2b7MBK@kadam> (raw)
In-Reply-To: <2c36799c-af38-fed5-3f31-a8bde25368d7@redhat.com>
On Tue, Oct 11, 2022 at 03:02:28PM +0200, Paolo Bonzini wrote:
> On 10/10/22 20:39, Sean Christopherson wrote:
> > > 828ca89628bfcb Oliver Upton 2021-09-16 @4988 tsc = kvm_scale_tsc(vcpu, rdtsc(), vcpu->arch.l1_tsc_scaling_ratio) + offset;
> > >
> > > Smatch hates obvious user triggerable integer overflows... No checking
> > > on offset.
> >
> > This is ok, and even necessary, e.g. if the host TSC > guest TSC.
>
> (which in fact is the common case). Also this is unsigned which is fine
> according to the C standard, though I understand that static analyzers want
> to be stricter.
>
> > Is there anything
> > we can do in KVM to help Smatch avoid false positives? Or do you/Smatch already
> > maintain a list of known false positives?
>
> Seconded.
Thanks for your feedback.
I could probably make a rule to ignore clock related stuff. That's
honestly been a known source of false positives for a while. I kind of
have the infrastructure so it's not super hard to do actually... I'll do
that.
regards,
dan carpenter
next prev parent reply other threads:[~2022-10-12 6:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-10 13:56 arch/x86/kvm/x86.c:4988 kvm_arch_tsc_set_attr() warn: check for integer overflow 'offset' kernel test robot
2022-10-10 14:15 ` [kbuild] " Dan Carpenter
2022-10-10 14:15 ` Dan Carpenter
2022-10-10 18:39 ` Sean Christopherson
2022-10-10 18:39 ` Sean Christopherson
2022-10-11 13:02 ` Paolo Bonzini
2022-10-11 13:02 ` Paolo Bonzini
2022-10-12 6:34 ` Dan Carpenter [this message]
2022-10-12 6:34 ` Dan Carpenter
2022-10-12 6:34 ` Dan Carpenter
-- strict thread matches above, loose matches on Subject: below --
2022-08-10 6:18 kernel test robot
2022-08-09 3:21 kernel test robot
2022-08-08 14:20 kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y0Zf6g7ahY2b7MBK@kadam \
--to=dan.carpenter@oracle.com \
--cc=kbuild@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.