From patchwork Sat Dec 2 05:46:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ding Tianhong X-Patchwork-Id: 120411 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2025535qgn; Fri, 1 Dec 2017 21:47:46 -0800 (PST) X-Google-Smtp-Source: AGs4zMYIVC9BHqg2pXIqMAU2sH023l6te7rFiTSwsrWk+G0zbQTUOxfun9BS9c/LpFY05Tdj8IdU X-Received: by 10.99.95.70 with SMTP id t67mr8125887pgb.49.1512193666055; Fri, 01 Dec 2017 21:47:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512193666; cv=none; d=google.com; s=arc-20160816; b=vd3rbW7bwAXOVHE9mr80GgoJLi7BknX62A6ucC7ldGv5GcM0sGnjf8RKCtecarO5/2 801l+C/NrDLoYv04Y7jtAVFLW98dgh+AWpelOAORBAEZZF8dq8kk/TL0k0kUK9RDC53m ecC3nPacGfIXQ/5vkmQEx+BJjT54JaT7JBUKsI3YUpYn6gdouxYiP4t+MLreKn0oWisA 8pz4SuFJZ/zXP6MkNPYaf/yPgcxM6FoaUmJi4ArSf18vCUqHtQ1L9uFIZG85hCsTbB/B /wXIsu6pMSC9uGs6dg7J1z2q9CI/5FBd57gVZ32sLSAdrpUd8uSPKXUIcmPVC8B6Qk/I m+rA== 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:to:subject:from :arc-authentication-results; bh=ayp2GUMVq5ngcKgdYkqEmEJLtZpUtbxQ+ceX+9aQJJk=; b=gUkZ5XHkq7ZTWWDcwRi3TZ7+dyV6tWaqLL/+0xuD+fgG3MTYitPqUaNn3lEvFDQejd z0oiyV+TLnaTsrUJgYtsPJnsRKK+ST7L58K5o40+emQ+zeUV/RmndU2UiPzyC3hCQnrU koDfL8tz5mvlCZjeZqvgykljIIsMz5bqpUOrmYbhL9Strb5yODJ4jyfwhCdY2PT5HFNh mzww46FG9E2wlCVDoMo0Z0MY3JPO0pgKBTw+cLdqIyAOEXPNRC47o4yeL7VQ2M6XEy0K UA8XAQznfNqUxmd0yawn8NkhtXsMtPM7y6xrnAE5IWDLOAm2a67fWUZXU+j4fIyUPNq6 gbVQ== 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 b3si6086106plb.41.2017.12.01.21.47.44; Fri, 01 Dec 2017 21:47:46 -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 S1751555AbdLBFrl (ORCPT + 28 others); Sat, 2 Dec 2017 00:47:41 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:57728 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751441AbdLBFrk (ORCPT ); Sat, 2 Dec 2017 00:47:40 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id CC891FC9754F2; Sat, 2 Dec 2017 13:47:36 +0800 (CST) Received: from [127.0.0.1] (10.177.23.32) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.361.1; Sat, 2 Dec 2017 13:47:27 +0800 From: Ding Tianhong Subject: [PATCH v2] ubsan: don't handle misaligned address when support unaligned access To: , , "linux-kernel@vger.kernel.org" , LinuxArm , David Laight Message-ID: <5b905d56-609e-3822-096a-3b93b3eb7675@huawei.com> Date: Sat, 2 Dec 2017 13:46:33 +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 Signed-off-by: Ding Tianhong Signed-off-by: Andrew Morton diff --git a/lib/ubsan.c b/lib/ubsan.c index fb0409d..9207e65 100644 --- a/lib/ubsan.c +++ b/lib/ubsan.c @@ -322,7 +322,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)) - handle_missaligned_access(data, ptr); + if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)) + handle_missaligned_access(data, ptr); else handle_object_size_mismatch(data, ptr); }