Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5519678pxu; Tue, 22 Dec 2020 21:09:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJwECsu0bSMVO/K51MAu3e11zgB2v4Z20uO4DYlbT55+CtmuMeFFc90Ep80dXudMju1rn0si X-Received: by 2002:a17:906:52da:: with SMTP id w26mr23106598ejn.347.1608700142834; Tue, 22 Dec 2020 21:09:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608700142; cv=none; d=google.com; s=arc-20160816; b=Kpp9pmz7YgRRbwM9DsM0/7cTLPRNqNIp/wak/nGXMESYh2flS1KqE3QlnJ5rYnP598 poseA0WUASQy1XnHr6I00dIoFl9xxdoat6lZgyQoagnTC+IxMEHlA9f0G1yJh+jz9qER MzousRoaXcw9qEtfhHpGc/mW5TSPgKxZIm+6mX/xtvpRdKQkVPUOycvatLhzKQjCxo2H 6IzIDGG4rDCElDP0KD1LVE9efwSC9DZfRgkwro19/GoDJ040VQdLiwa8reoqX/oNQzvc wi+L/zL1DpSR1HygM2AlrnzfwT+S//HVd+03Vww1mfxMjse9361o8CqyF1caDxq8cxxP pyzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=UpdFfa5ubXWs5+ZAsqLa1UlbVD0Yd2WcynxMVwNQ5W8=; b=IYT5MTELnr67q3F55LS7AhAcTrTFNrxSY0qYAEpMnxC6hAA+HKu370m6xwNFXevOCm hGwxKQgaNulxn1j4k1NfCuXuJRRmGwtnFLWan/70LiZFgOabeF4R/yVv1SXZZrMdQbnI tBjnC3v7IZuacSyCob4etxcZ3953T0xT0j+S6s9A3sWyphrpFwjZWOkqJhwquQjqYXvv 7ZrvNqe/UG0Fhh2vEJBSpqrnVz47hF0rsgmWNGkldAUSWe3blD4NN27Hun3HwSHXHU8r sWMMpkcI3v1BTQZDJaCzyWtg/FWOS9rj9zHKKMDZOMfp5WtS+vNo5RLlFXol2QEkke/Y 7wHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=COyiVQDa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nq4si12204945ejb.68.2020.12.22.21.08.40; Tue, 22 Dec 2020 21:09:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=COyiVQDa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726282AbgLWFHB (ORCPT + 99 others); Wed, 23 Dec 2020 00:07:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:37404 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725923AbgLWFHB (ORCPT ); Wed, 23 Dec 2020 00:07:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608699934; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=UpdFfa5ubXWs5+ZAsqLa1UlbVD0Yd2WcynxMVwNQ5W8=; b=COyiVQDaoN5uOcjuYY+UNI8qAQPvbXpaRiD65R1excrHbF0Pl/Xg+NsA12H+Q+/nJklaad vOxACSYhyvDAzQc3Dmy7JajusD1A2QEk+fnax+uYPHWWrrHE76xozM0OYlR7Ju+31G2xJP 75r1Z9x8UdYepRIIV3x904OzwULObE4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-164-2aaTyyqaMQqykASEZCryfQ-1; Wed, 23 Dec 2020 00:05:32 -0500 X-MC-Unique: 2aaTyyqaMQqykASEZCryfQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9CFA5800D55; Wed, 23 Dec 2020 05:05:31 +0000 (UTC) Received: from treble.redhat.com (ovpn-117-91.rdu2.redhat.com [10.10.117.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1168310013C1; Wed, 23 Dec 2020 05:05:30 +0000 (UTC) From: Josh Poimboeuf To: Alexander Viro Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Randy Dunlap Subject: [PATCH] mm/uaccess: Use 'unsigned long' to placate UBSAN warnings, again Date: Tue, 22 Dec 2020 23:04:54 -0600 Message-Id: <590998aa9cc50f431343f76cae72b2abf8ac1fdd.1608699683.git.jpoimboe@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org GCC 7 has a known bug where UBSAN ignores '-fwrapv' and generates false signed-overflow-UB warnings. The type mismatch between 'i' and 'nr_segs' in copy_compat_iovec_from_user() is causing such a warning, which also happens to violate uaccess rules: lib/iov_iter.o: warning: objtool: iovec_from_user()+0x22d: call to __ubsan_handle_add_overflow() with UACCESS enabled Fix it by making the variable types match. This is similar to a previous commit: 29da93fea3ea ("mm/uaccess: Use 'unsigned long' to placate UBSAN warnings on older GCC versions") Reported-by: Randy Dunlap Signed-off-by: Josh Poimboeuf --- lib/iov_iter.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/iov_iter.c b/lib/iov_iter.c index 1635111c5bd2..2e6a42f5d1df 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -1656,7 +1656,8 @@ static int copy_compat_iovec_from_user(struct iovec *iov, { const struct compat_iovec __user *uiov = (const struct compat_iovec __user *)uvec; - int ret = -EFAULT, i; + int ret = -EFAULT; + unsigned long i; if (!user_access_begin(uvec, nr_segs * sizeof(*uvec))) return -EFAULT; -- 2.29.2