From patchwork Fri Dec 1 11:32:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ding Tianhong X-Patchwork-Id: 120315 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1015004qgn; Fri, 1 Dec 2017 03:33:23 -0800 (PST) X-Google-Smtp-Source: AGs4zMaJeFZCddo5PBHOeRwS+v7VP1YpiIW/52rTNTDBydao4l5/LG8RoxHDd4UCuIgTIU38VHHr X-Received: by 10.99.191.69 with SMTP id i5mr5582852pgo.13.1512128003417; Fri, 01 Dec 2017 03:33:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512128003; cv=none; d=google.com; s=arc-20160816; b=nOLWrxcKNZw9C5KBedTGrVKzH+epF2QyerQHpUjIpz2KJXCZWZKx3S+vH0I9woPNfM neYMuEjE3bJ/pxVK2OV/MSdbpfpCLd0cG9Ivh4Nr2VBb46BtnbXZC3lMRKL3WDBvS8cq YA4AZeQCPonYmxUthYDyNoXvCnwFDOMPo5dnL5m9PmcvooYc/Xwl1fgbIdWHR1XR7zZm ZbRMFQsEKNX0KhaHDA661b7RFzNAkmpEB4hjwB6G0HlzcdFoeGzHhNL7Y5g2Iv/UjUgF wuLf4Aqm5f/y9QJ8bfm96qSPVHi1HD1MYLB7NF/RTIJp5wppXJ7WsOvWVPsucHTcRpxE OI/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:date:message-id:subject:from:to :arc-authentication-results; bh=vRpaiq5OITHpEwMiJMG/o79r+4fIdlXviTthb9uwcgo=; b=yZVeNm6SAcbcCfs1Hf4S54cL/d1vet+Rn265CrWwHlVQpnCOnzI2LEONts+Y7dtLzM yhrD65trwFotHi+nMTtzYnj0Fs7p4qOhFf7HHPDEHudfajJUxxS/p+uoi6Eq5dUmHlmm RZJuCCkUYrENCwWFUGY0jjnB9gzSRQfm0pdned0dwQo1X7UmWB/leuHWJjM6RSzR/3Bz HrkjMIL1BjXW2/WKNRHPHQ19/MTVTKS36ZvY6TyHgEltSKxEQHYxpFrcwWoMQKt142Ye pei1nViG87Vz70ChjYaURR6VAeESZhdaPu+EhsDFsLSL1C0Tzr9k5sGjLW3zasjr1EzC Aogw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i9si4695910pgs.523.2017.12.01.03.33.23; Fri, 01 Dec 2017 03:33:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752339AbdLALdV (ORCPT + 28 others); Fri, 1 Dec 2017 06:33:21 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:2193 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752025AbdLALdT (ORCPT ); Fri, 1 Dec 2017 06:33:19 -0500 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id C97C98BF293D4; Fri, 1 Dec 2017 19:32:58 +0800 (CST) Received: from [127.0.0.1] (10.177.23.32) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.361.1; Fri, 1 Dec 2017 19:32:51 +0800 To: , , "linux-kernel@vger.kernel.org" , LinuxArm From: Ding Tianhong Subject: [PATCH] ubsan: don't handle misaligned address when support unaligned access Message-ID: <9cdc75c4-326f-5adb-b32c-c95e1f3211ce@huawei.com> Date: Fri, 1 Dec 2017 19:32:08 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 X-Originating-IP: [10.177.23.32] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ubsan always report Warning just like: UBSAN: Undefined behaviour in ../include/linux/etherdevice.h:386:9 load of misaligned address ffffffc069ba0482 for type 'long unsigned int' which requires 8 byte alignment CPU: 0 PID: 901 Comm: sshd Not tainted 4.xx+ #1 Hardware name: linux,dummy-virt (DT) Call trace: [] dump_backtrace+0x0/0x348 [] show_stack+0x20/0x30 [] dump_stack+0x144/0x1b4 [] ubsan_epilogue+0x18/0x74 [] __ubsan_handle_type_mismatch+0x1a0/0x25c [] dev_gro_receive+0x17d8/0x1830 [] napi_gro_receive+0x30/0x158 [] virtnet_receive+0xad4/0x1fa8 The reason is that when enable the CONFIG_UBSAN_ALIGNMENT, the ubsan will report the unaligned access even if the system support it (CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y), it will produce a lot of noise in the log and cause confusion. This patch will close the detection of unaligned access when the system support unaligned access. Signed-off-by: Ding Tianhong --- lib/ubsan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 1.8.3.1 diff --git a/lib/ubsan.c b/lib/ubsan.c index fb0409d..278b4c3 100644 --- a/lib/ubsan.c +++ b/lib/ubsan.c @@ -321,7 +321,8 @@ void __ubsan_handle_type_mismatch(struct type_mismatch_data *data, if (!ptr) handle_null_ptr_deref(data); - else if (data->alignment && !IS_ALIGNED(ptr, data->alignment)) + else if (data->alignment && !IS_ALIGNED(ptr, data->alignment) && + !IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)) handle_missaligned_access(data, ptr); else handle_object_size_mismatch(data, ptr);