From patchwork Tue Jun 9 17:08:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11596215 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 280DC618 for ; Tue, 9 Jun 2020 17:12:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 09ECD207C3 for ; Tue, 9 Jun 2020 17:12:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="YmbHU39F" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729426AbgFIRMs (ORCPT ); Tue, 9 Jun 2020 13:12:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727021AbgFIRMs (ORCPT ); Tue, 9 Jun 2020 13:12:48 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23FB5C05BD1E; Tue, 9 Jun 2020 10:12:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=Xfx824IqwGWHG7uI7+NTCcQdTS7fjG1Dt9prfSku5nU=; b=YmbHU39F5GanrjWbGmq5ZtjDFA PUsJPiF76e6CY7729gSjHFSTZMFd5qaY6POzgSTBgaQZcmw+qF9ZxxFRvwVqTWu1UUNyLQrqQZVg8 /zNZJ0OpqKzY5cOSh+yj1WnK+9MM9vXVxSKY+tQW1PhDDH1d06/+Ls+Fw/rc/hIGVU7Uwi7S/EOra M4Tg91+LESYmhkpGxQ57QHt9v8ItJopcsltaInb8NlGe5BY5vV9aA5OelFB7Z7V9SsiTZbGO1Ws+a hdTMocoSXEoa2CSxRyAPFrHzG3tFSoAJ09g3fZ4/zc5ZnZdvASJlMLQp0/OTI7C+aKdFmdfcfaU4v /ZTJbpvQ==; Received: from 213-225-38-56.nat.highway.a1.net ([213.225.38.56] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jihnp-0007Oj-C7; Tue, 09 Jun 2020 17:12:45 +0000 From: Christoph Hellwig To: Alexander Viro Cc: Luis Chamberlain , Kees Cook , Iurii Zaikin , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, build test robot Subject: [PATCH 1/2] cdrom: fix an incorrect __user annotation on cdrom_sysctl_info Date: Tue, 9 Jun 2020 19:08:18 +0200 Message-Id: <20200609170819.52353-2-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200609170819.52353-1-hch@lst.de> References: <20200609170819.52353-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org No user pointers for sysctls anymore. Fixes: 32927393dc1c ("sysctl: pass kernel pointers to ->proc_handler") Reported-by: build test robot Signed-off-by: Christoph Hellwig --- drivers/cdrom/cdrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index e3bbe108eb542f..410060812e9dbf 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c @@ -3518,7 +3518,7 @@ static int cdrom_print_info(const char *header, int val, char *info, } static int cdrom_sysctl_info(struct ctl_table *ctl, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) + void *buffer, size_t *lenp, loff_t *ppos) { int pos; char *info = cdrom_sysctl_settings.info; From patchwork Tue Jun 9 17:08:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11596223 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4BA1A618 for ; Tue, 9 Jun 2020 17:15:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 25BD120801 for ; Tue, 9 Jun 2020 17:15:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="LryZXbKu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729817AbgFIRPC (ORCPT ); Tue, 9 Jun 2020 13:15:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727002AbgFIRPC (ORCPT ); Tue, 9 Jun 2020 13:15:02 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C24B3C05BD1E; Tue, 9 Jun 2020 10:15:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=UpZXoNnaIyWKzV6Z6O45sLy0hwoaGi/+8KOaNyXYIhk=; b=LryZXbKuN2eGOYk2BNZevWXRQ2 Vz1L4QBFGOZ7HACvE4sUMqRernCPHCikllguj+wYJHCu0s5VtY6ngnkJJji5lXq44AdeRsWaq0bN7 QSu9A2rvLFuaYkJwrc4JPCvEUVHFFLvWxKhHPacP1AlaZfNW2nByB6c5JGoPwFsz2tdKaSQRYyXNQ WrQUwBlH0Figka6mizQcT9XJzl8VgUmLkERrj6tSlrgFfn4EucxYuPj/qcL/JWrUM8U4KrNqFEcpz Emt78qXrFbIRmZ+neeEhNevfxV/32D04k3HD9YCVuG4lrNOIo63vJGtd9zCcYFq9YgyupkPoKjPB3 2SEBcJtg==; Received: from 213-225-38-56.nat.highway.a1.net ([213.225.38.56] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jihpy-00083s-FN; Tue, 09 Jun 2020 17:14:58 +0000 From: Christoph Hellwig To: Alexander Viro Cc: Luis Chamberlain , Kees Cook , Iurii Zaikin , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Vegard Nossum Subject: [PATCH 2/2] sysctl: reject gigantic reads/write to sysctl files Date: Tue, 9 Jun 2020 19:08:19 +0200 Message-Id: <20200609170819.52353-3-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200609170819.52353-1-hch@lst.de> References: <20200609170819.52353-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Instead of triggering a WARN_ON deep down in the page allocator just give up early on allocations that are way larger than the usual sysctl values. Fixes: 32927393dc1c ("sysctl: pass kernel pointers to ->proc_handler") Reported-by: Vegard Nossum Signed-off-by: Christoph Hellwig --- fs/proc/proc_sysctl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index df2143e05c571e..08c33bd1642dcd 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -564,6 +564,10 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *ubuf, if (!table->proc_handler) goto out; + /* don't even try if the size is too large */ + if (count > KMALLOC_MAX_SIZE) + return -ENOMEM; + if (write) { kbuf = memdup_user_nul(ubuf, count); if (IS_ERR(kbuf)) {