Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1952304ybl; Sat, 1 Feb 2020 09:59:20 -0800 (PST) X-Google-Smtp-Source: APXvYqwRpcbfAunWzvcRNkRQgz6hVFKWjIKPYZG8+FifVWuKwUjwmf2n/FumBPfmikGC2Tbeh87j X-Received: by 2002:a9d:1284:: with SMTP id g4mr11653322otg.207.1580579960191; Sat, 01 Feb 2020 09:59:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580579960; cv=none; d=google.com; s=arc-20160816; b=rW82Kpi0k6NJEcAbN6Vq384rYGGP/4SjhkOvuXDnZ3LAGSVdLKyrvObbioBPzzfBJx 7/xKcOL/7kKsxM876MVltuC9ZQmOXMcGQeNcTBKrQGB0TZjDurR+LDSBikDZpOEyTDXE asw5DTqwYITzf9UKieMfV8wonU+DpViVXsa2XFKi8e2ZOqwYWn9ejWHT4K5HyjC8VBFE MMBdEO6hB9v3HC1t0P3MrCcGtrSSoqVnT9opIpNhIcIa/a4f2Qtg5ar/oDpNDHS+I5H2 gIVaP64euYUBS0romOw2pxE57kq7woz7U2j10J4hKw4k1Nhgd3dGIiAbLQlXeQkCbvQd StSA== 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=1rxiDiiWyy+RaaD0YllXb5sVbRbHdZvAaLoyASC1RHA=; b=iRLo+SGeMnzZRj7ZHxJjW7weu287LMlj7GSAN5ISCYIaFqINsbqyX/pbYtQW08k8ql mKxebJrZQruX469gPQgDZ2lhuoQsTxNmjE2qMvBxxYwbCNTNAd3kUwq39Unzlvhy/aO1 Z60OGkGXagxQs2AQFatv5dVv3d7IQ3vKDDhhzO3wb7bx/iSp7WNWlEkfGxW2JgdRBoqo wPnfs13q0Y6vVUYA/K7yuStYPXQ9dYthidNhmT2KvFRCdk4t32/80+BDbFQQweuJsyzP Ge+YKm7fL2ovlA/Ae+xXBlntk4bcFhBWO15Owc/Jsg+8alcM9vI/yMxup3EqbQfckxJO jb1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=UbIWczwi; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o18si5728666oic.18.2020.02.01.09.59.08; Sat, 01 Feb 2020 09:59:20 -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; dkim=pass header.i=@chromium.org header.s=google header.b=UbIWczwi; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726731AbgBAR4q (ORCPT + 99 others); Sat, 1 Feb 2020 12:56:46 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:34724 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726469AbgBAR4p (ORCPT ); Sat, 1 Feb 2020 12:56:45 -0500 Received: by mail-pj1-f65.google.com with SMTP id f2so3908699pjq.1 for ; Sat, 01 Feb 2020 09:56:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=1rxiDiiWyy+RaaD0YllXb5sVbRbHdZvAaLoyASC1RHA=; b=UbIWczwiQvzV+o1/R62NbaP1lFCIW4J4I1Znu2jtuEVKVBfSBP0kAK6LdTGJ1ujZps /G0uyRiL+3/xM2Hvkwz1ZQhXsnR97q5ZnjDFj6XXbM/7HbkX4QGvl8Ij1VWRDdoVEVqI D9Ks/1wEw6tLdPvSdLg1Vw6B3NocqQ1gDZwAk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=1rxiDiiWyy+RaaD0YllXb5sVbRbHdZvAaLoyASC1RHA=; b=tUDtmbPHog/TdrEUaNIHO8oOgQTL9jTzoPgdTsUL+HyyFhwjwaFFJDpOixs3ABFMO5 tLJIPvev7x1NBkvsXC4BR4v80gzWPBJPx5LobTLnBqC/R23JQCuNmClCN376RAcxxJgm Z2V74q7a5h7FcYuRDGqDNCt40anVqY4iDa1gYn0AAq5lBeT8XAyrUuX5zHwzEy9alJcJ /HqFMBcyd/bS7LljZoP2h7c7K7UJJXEpIo38Qk3DCT4AHOrTOQ+zDAoFK4OMXedc677Y VNIYceHyDdkSFgGzyCRjs0FXFvMNdQWcbhn0bokQ2sKQnOf+AIwgxdnJnFahxsa7F7+l 11FQ== X-Gm-Message-State: APjAAAXB6BlxU0CKqnRf1grTKudNtBYk6pAwE1pdzMd4vMMbpwbZcAjd xTmbXFlDHYYz+X+nCheB2JUXvA== X-Received: by 2002:a17:902:9b93:: with SMTP id y19mr15780032plp.89.1580579803746; Sat, 01 Feb 2020 09:56:43 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id gc1sm14073972pjb.20.2020.02.01.09.56.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Feb 2020 09:56:42 -0800 (PST) Date: Sat, 1 Feb 2020 09:56:41 -0800 From: Kees Cook To: Jann Horn Cc: Christian Borntraeger , Christoph Hellwig , Christopher Lameter , Jiri Slaby , Julian Wiedmann , Ursula Braun , Alexander Viro , kernel list , David Windsor , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Linux-MM , linux-xfs@vger.kernel.org, Linus Torvalds , Andy Lutomirski , "David S. Miller" , Laura Abbott , Mark Rutland , "Martin K. Petersen" , Paolo Bonzini , Christoffer Dall , Dave Kleikamp , Jan Kara , Luis de Bethencourt , Marc Zyngier , Rik van Riel , Matthew Garrett , linux-fsdevel , linux-arch , Network Development , Kernel Hardening , Vlastimil Babka , Michal Kubecek Subject: Re: [kernel-hardening] [PATCH 09/38] usercopy: Mark kmalloc caches as usercopy caches Message-ID: <202002010952.ACDA7A81@keescook> References: <202001271519.AA6ADEACF0@keescook> <5861936c-1fe1-4c44-d012-26efa0c8b6e7@de.ibm.com> <202001281457.FA11CC313A@keescook> <6844ea47-8e0e-4fb7-d86f-68046995a749@de.ibm.com> <20200129170939.GA4277@infradead.org> <771c5511-c5ab-3dd1-d938-5dbc40396daa@de.ibm.com> <202001300945.7D465B5F5@keescook> 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 Fri, Jan 31, 2020 at 01:03:40PM +0100, Jann Horn wrote: > I think dma-kmalloc slabs should be handled the same way as normal > kmalloc slabs. When a dma-kmalloc allocation is freshly created, it is > just normal kernel memory - even if it might later be used for DMA -, > and it should be perfectly fine to copy_from_user() into such > allocations at that point, and to copy_to_user() out of them at the > end. If you look at the places where such allocations are created, you > can see things like kmemdup(), memcpy() and so on - all normal > operations that shouldn't conceptually be different from usercopy in > any relevant way. I can't find where the address limit for dma-kmalloc is implemented. As to whitelisting all of dma-kmalloc -- I guess I can be talked into it. It still seems like the memory used for direct hardware communication shouldn't be exposed to userspace, but it we're dealing with packet data, etc, then it makes sense not to have to have bounce buffers, etc. -- Kees Cook