Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751597AbaKZTM2 (ORCPT ); Wed, 26 Nov 2014 14:12:28 -0500 Received: from mail-qc0-f170.google.com ([209.85.216.170]:61393 "EHLO mail-qc0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751199AbaKZTM1 (ORCPT ); Wed, 26 Nov 2014 14:12:27 -0500 MIME-Version: 1.0 In-Reply-To: <547624C7.3020003@oracle.com> References: <1417010419-3827-1-git-send-email-sasha.levin@oracle.com> <1417010419-3827-2-git-send-email-sasha.levin@oracle.com> <54761406.9090602@oracle.com> <547624C7.3020003@oracle.com> Date: Wed, 26 Nov 2014 11:12:26 -0800 X-Google-Sender-Auth: 5R5tEVmfjC-3QWvoACTKSp6V3aI Message-ID: Subject: Re: [RFC 2/2] kvm: eventfd: detect integer overflow using check_*_overflow From: Linus Torvalds To: Sasha Levin Cc: Andrey Ryabinin , mingo , Andrew Morton , LKML Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 26, 2014 at 11:06 AM, Sasha Levin wrote: > > I'm pretty sure that this is something GCC will warn you about in the > compilation stage. It does? I've never seen it, but maybe it's a new thing. The gcc signedness warnings have historically been so wretched that it's just sad, and they have to be turned off. > kernel/time/ntp.c:process_adjtimex_modes(): > > if (txc->modes & ADJ_FREQUENCY) { > time_freq = txc->freq * PPM_SCALE; <=== Undefined overflow > time_freq = min(time_freq, MAXFREQ_SCALED); > time_freq = max(time_freq, -MAXFREQ_SCALED); > /* update pps_freq */ > pps_set_freq(time_freq); > } > > The multiplication is between signed integers, and it overflows (user triggerable). Well, we check that the end result - overflowed or not - is in a sane range. So this might fall under the heading of "user gets what he asks for". Linus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/