Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754555AbbK3Sv4 (ORCPT ); Mon, 30 Nov 2015 13:51:56 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:50499 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753679AbbK3Svy (ORCPT ); Mon, 30 Nov 2015 13:51:54 -0500 Subject: Re: [PATCH v3 2/2] UBSAN: run-time undefined behavior sanity checker To: Andrey Ryabinin , linux-kernel@vger.kernel.org References: <1448899183-8677-1-git-send-email-aryabinin@virtuozzo.com> <1448899183-8677-3-git-send-email-aryabinin@virtuozzo.com> Cc: Andrew Morton , Peter Zijlstra , Randy Dunlap , Rasmus Villemoes , Jonathan Corbet , Michal Marek , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Yury Gribov , Dmitry Vyukov , Konstantin Khlebnikov , Kostya Serebryany , x86@kernel.org, linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org From: Sasha Levin Message-ID: <565C9A8E.4060604@oracle.com> Date: Mon, 30 Nov 2015 13:50:54 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1448899183-8677-3-git-send-email-aryabinin@virtuozzo.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1193 Lines: 36 On 11/30/2015 10:59 AM, Andrey Ryabinin wrote: > +void __ubsan_handle_shift_out_of_bounds(struct shift_out_of_bounds_data *data, > + unsigned long lhs, unsigned long rhs) > +{ > + unsigned long flags; > + struct type_descriptor *rhs_type = data->rhs_type; > + struct type_descriptor *lhs_type = data->lhs_type; > + char rhs_str[VALUE_LENGTH]; > + char lhs_str[VALUE_LENGTH]; > + > + if (suppress_report(&data->location)) > + return; > + > + ubsan_prologue(&data->location, &flags); > + > + val_to_string(rhs_str, sizeof(rhs_str), rhs_type, rhs); > + val_to_string(lhs_str, sizeof(lhs_str), lhs_type, lhs); > + > + if (val_is_negative(rhs_type, rhs)) > + pr_err("shift exponent %s is negative\n", rhs_str); > + > + else if (get_unsigned_val(rhs_type, rhs) >= > + type_bit_width(lhs_type)) > + pr_err("shift exponent %s is to large for %u-bit type %s\n", too Otherwise looks great, I'm running fuzzing with it now. Thanks, Sasha -- 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/