Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp639681pxk; Wed, 2 Sep 2020 10:47:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDm4Tr9q2KBxncwukfBBB9lMvRODvovZyehvS1O9FM9SphKfXMzoFxSFxEZ86elXYS22lY X-Received: by 2002:a50:b946:: with SMTP id m64mr1269191ede.92.1599068879306; Wed, 02 Sep 2020 10:47:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599068879; cv=none; d=google.com; s=arc-20160816; b=H0XqOfEdfEVG0Q/HWUDXWvnUeAR0MxH1RnziVGSneJQEUlYcmR9uKVuY7SJGz7mu6J 52rRQHyoxkkZ6+HqAa8cf1705Sb/heBjCj5xgFk8C2L8vLMWD7hrYrTmSRcKRJUnuL6S RwhDDbycU9Cqf6QOrmmdBzT8D1n1zAm1tnBM2uQfx40KWYpC8yN1b4VKpMOAKHb7ecg1 7t1+vDINz73TNKnPsntIGHua+8Xt8QjWTxUh84eusXDzz1mHtoWnTNAQvR2mz4qSKllt JOq9TAsR4O8v83QVeHnBr5dVVac3Wx07Jd9JQr6bX4D35Jnhaf1ka6VDgc0A2gaXncg5 Q91w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=kB3wFkqjGcA1UB0NP0E+74+G35XlWUvsUW8nfr7fh8I=; b=cvuwc59kI01rwPgg48fXoKIYUfDC+YHuBMQEu2KMBLuBgCX1pRHtJfptyLEm0OHda5 Z0rzJblOH6s6RxgPjXJE7fNwd9annClp13E14p29W6I0xWcWE3Jt7W7ywAuCZcthKGAb ZgzjPBHQthIbT0vqAOBG6Q96kqNHa9DQjy1opqgfSya7y33QY3hT4l0xIlWPDj5mYSX6 O8zE6df5crL6QGcHTFbLPBsd9MX00xHqnLpObnlCbltPqk0yykYyDBqScydTouK0U8Gd QhZtPFfJ6JYpfF1j6aSoZXGvftJA3IkPqFoJ6aPoCgAdhDfV9KvjmrZA59c53qHHK1XJ oloA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AA9Y6oFf; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c4si173396ejb.148.2020.09.02.10.47.35; Wed, 02 Sep 2020 10:47:59 -0700 (PDT) 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=@kernel.org header.s=default header.b=AA9Y6oFf; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727827AbgIBRqF (ORCPT + 99 others); Wed, 2 Sep 2020 13:46:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:51066 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726310AbgIBRqF (ORCPT ); Wed, 2 Sep 2020 13:46:05 -0400 Received: from localhost (unknown [213.57.247.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B654C2071B; Wed, 2 Sep 2020 17:46:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599068764; bh=dQfeSH9/3D4Fw7dc4c6EHH61Lfy1xqHV+cPUMjWvzpY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AA9Y6oFf/CF0xKwL6jw2HYolcPLLKopjRauU5YDHgSHXf/sFkJn/JXQ9ii6uS2mur bGdkp22QFbG8vZhk74otc8DdSVpYk5iLRajsmX9ftIJ/11ILvKElfv8DrzvxwwQFCJ 2Ka2hA2JO/Ct80LcR5xPZJmHBEk8PVeXBecjcoek= Date: Wed, 2 Sep 2020 20:46:00 +0300 From: Leon Romanovsky To: Linus Torvalds Cc: Peter Oberparleiter , Linux Kernel Mailing List , Colin Ian King , Andrew Morton Subject: Re: [PATCH rdma-next 1/4] gcov: Open-code kmemdup() to work correctly with kernel and user space pointers Message-ID: <20200902174600.GK59010@unreal> References: <20200902085513.748149-1-leon@kernel.org> <20200902085513.748149-2-leon@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 02, 2020 at 10:38:20AM -0700, Linus Torvalds wrote: > On Wed, Sep 2, 2020 at 1:55 AM Leon Romanovsky wrote: > > > > The kernel with KASAN and GCOV enabled generates the following splat > > due to the situation that gcov_info can be both user and kernel pointer. > > I can't parse the above explanation.. > > > It is triggered by the memcpy() inside kmemdup(), so as a possible solution > > let's copy fields manually. > > .. and I don't see why copying the fields manually makes a difference. > > Can you explain more? Definitely my explanation is wrong, but it was my interpretation of "BUG: KASAN: global-out-of-bounds in kmemdup+0x43/0x70" line. I saw that the failure was in memcpy() inside of kmemdup(), so I changed from memcpy to be copy_from_user() and it solved the KASAN warning. This is why I wrote "both user and kernel pointer". Thanks > > Linus