Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp805751imm; Tue, 5 Jun 2018 04:55:42 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKJRbq68b58Rz8golBa80buh3USMclSdyzfrK+FLx4otxWJ3pI+oesXp4EiHZ43/Voiwpmw X-Received: by 2002:a65:6007:: with SMTP id m7-v6mr19886842pgu.92.1528199742167; Tue, 05 Jun 2018 04:55:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528199742; cv=none; d=google.com; s=arc-20160816; b=EwIXcSlDQPEADXYN9106C0hG6877NqiXgIHBxIWe4IhShr15+ANsCMvh7CxrHsOFB8 56p2etIPMJ84Jj6oIyKg8rkAx3iWcUMAbznq0A+qmyHOsR8BJwT2iQbPRVZbog+gUWiP +0P0ZyktH2vWNtMWEMRf8BYl1T0EKRpSPjYiZzCvknSn0vyeWV3cbvU6oNrQrh86cql/ jeIf8WXw7H8j56DtgN0DF5oAwg9n4TJ0vvz8wR6ADjgW6Pk1qXR+RDzbtqnE83urtFvR vcZSPrx5MaFeahUvS/vX7zEPQZ91kwER6SEKLIuFfJvSCEsg6rw2ntKG2LvVCBF1eHCD 3KrA== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=CX2ULuMp6v9FcIhoefFUrq+qP+vwARX9xUPMEu4cjpo=; b=G5MbSx5PAmV3E5CjYkTzS0lbmGlpAizrLhBA7Io2Y3U6l82IhgYLJoNdTyV7WQUFzL WRGHwGbslpFxcPp4Lf6pE/tT/GhrL37RdKPpOBu08ighpchKRigzCP3m5va2xyv7ifOr b14rU4NWIx2sELNPMZ6hyhaIbOeCJpB03x6KbFefG1r5fBV4UAa+9M3lGdaSNHD16t3S p1pBtBJIvkFGtUOTWMGFFCcdr2i2HPL1GRmj+OOujUNpPrrtCDKL7HuYN8/S4Wbjbhs1 3AOVIaltV7palGU7FN0XQb+FjioMKJSU7XihWRRg5Ka0g+dkq+lxW5yNcQ92uKJWRYhJ zJ1w== 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 e13-v6si35822193pgt.332.2018.06.05.04.55.26; Tue, 05 Jun 2018 04:55:42 -0700 (PDT) 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 S1751788AbeFELxn (ORCPT + 99 others); Tue, 5 Jun 2018 07:53:43 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:60654 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751747AbeFELxm (ORCPT ); Tue, 5 Jun 2018 07:53:42 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1fQAWy-0005H6-OS; Tue, 05 Jun 2018 11:53:40 +0000 Date: Tue, 5 Jun 2018 12:53:40 +0100 From: Al Viro To: Ilya Matveychikov Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH] ksys_mount: check for permissions before resource allocation Message-ID: <20180605115340.GO30522@ZenIV.linux.org.uk> References: <20180605112641.GN30522@ZenIV.linux.org.uk> <1E519BA2-4198-4255-BAE4-3125C59741A3@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1E519BA2-4198-4255-BAE4-3125C59741A3@gmail.com> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 05, 2018 at 03:35:55PM +0400, Ilya Matveychikov wrote: > > > On Jun 5, 2018, at 3:26 PM, Al Viro wrote: > >> > >>> On Jun 5, 2018, at 6:00 AM, Ilya Matveychikov wrote: > >>> > >>> Early check for mount permissions prevents possible allocation of 3 > >>> pages from kmalloc() pool by unpriveledged user which can be used for > >>> spraying the kernel heap. > > > > I'm sorry, but there are arseloads of unpriveleged syscalls that do the same, > > starting with read() from procfs files. So what the hell does it buy? > > Means that if all do the same shit no reason to fix it? Sounds weird... Fix *what*? You do realize that there's no permission checks to stop e.g. stat(2) from copying the pathname in, right? With user-supplied contents, even... If you depend upon preventing kmalloc'ed temporary allocations filled with user-supplied data, you are screwed, plain and simple. It really can't be prevented, in a lot of ways that are much less exotic than mount(2). Most of syscall arguments are copied in, before we get any permission checks. It does happen and it will happen - examining them while they are still in userland is a nightmare in a lot of respects, starting with security.