Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1199715imj; Sat, 16 Feb 2019 23:59:00 -0800 (PST) X-Google-Smtp-Source: AHgI3IZecwyxw601JpgnOhlZ0Ntt8H3glav3t273vl86wcethHfTeHO7ZVI8TxaCRwR/xQbF2Ow7 X-Received: by 2002:a62:3a92:: with SMTP id v18mr18385614pfj.43.1550390339972; Sat, 16 Feb 2019 23:58:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550390339; cv=none; d=google.com; s=arc-20160816; b=zupmE5JX32ZjTJ67woDAqSeERnIesMj0t8QUM11RQOyOxUvwK819Hw6vLNrGPtF2O7 mCsnoH2BjzWOKzM5g+VABzWugZr4JeDQzKvwteUio2VdJm2znszxr6OhcxDocxbD9HO3 wztBNb7uUtukXrJnRsXgmRT2jANeh8Cclmx7lP6YCZL9fWfSvkLFxSupoqQDV1Tb3INo pruSDE9ZSJgm8op+Lg4koo/2sc8XjSskrJyTGDf2LeLc20qdGmhs8TIzT7HSXdwronIQ 4JyyQ24gARutcfs9eNvp/8VvdCF995SCLRuKvxPfC5wdgAgLB2KGuzXWccdQb/WG4+x3 chiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=1qWThAfnp9+tNxxLbQqA2kbdN2QHOtDej2OEnaED8z0=; b=mvOXSzqm+y6I8PMy7Uj3DAoKQai9LTlazGyDajmt4FU40Hymp99rcCfEIwMWmrTxiD ptW77doMfR7omhCw1krESCL9eL24GH7Kp5FQ7thOMirrg1kkm8r1Iwvbmm8GbE7bURDP ELPs9GtRhmp44ty2rPw+8G/IiSANUzLZFklRy0buKijuIyDQOWszYKoLFdy/9txg2OlW 8gpHse7d2PrJopMXgzGJ3KE4cQ36veuUpqSREiV6+0ZnoV/5rTuZ1Ex+p0TC71H1E0Rl h3+SCe2GG/5k3/CcTkyFajXFYm0LeX7JSlp3ln9TOz7+krr1KrqdJWaVhhw57S/oH+R0 6WPQ== 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 z10si9770332pgf.549.2019.02.16.23.58.44; Sat, 16 Feb 2019 23:58:59 -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 S1727569AbfBPXrN (ORCPT + 99 others); Sat, 16 Feb 2019 18:47:13 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:52422 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726896AbfBPXrN (ORCPT ); Sat, 16 Feb 2019 18:47:13 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.91 #2 (Red Hat Linux)) id 1gv9fi-0001hH-3r; Sat, 16 Feb 2019 23:47:02 +0000 Date: Sat, 16 Feb 2019 23:47:02 +0000 From: Al Viro To: Andy Lutomirski Cc: Thomas Gleixner , Jann Horn , baloo@gandi.net, the arch/x86 maintainers , Ingo Molnar , Borislav Petkov , kernel list , Pascal Bouchareine Subject: Re: [PATCH] x86: uaccess: fix regression in unsafe_get_user Message-ID: <20190216234702.GP2217@ZenIV.linux.org.uk> References: <20190215235901.23541-1-baloo@gandi.net> <4F2693EA-1553-4F09-9475-781305540DBC@amacapital.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4F2693EA-1553-4F09-9475-781305540DBC@amacapital.net> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 16, 2019 at 02:50:15PM -0800, Andy Lutomirski wrote: > What is the actual problem? We’re not actually demand-faulting this data, are we? Are we just overrunning the buffer because the from_user helpers are too clever? Can we fix it for real by having the fancy helpers do *aligned* loads so that they don’t overrun the buffer? Heck, this might be faster, too. Unaligned _stores_ are not any cheaper, and you'd get one hell of extra arithmetics from trying to avoid both. Check something like e.g. memcpy() on alpha, where you really have to keep all accesses aligned, both on load and on store side. Can't we just pad the buffers a bit? Making sure that name_buf and symlink_buf are _not_ followed by unmapped pages shouldn't be hard. Both are allocated by kmalloc(), so... What am I missing here?