Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2263652imm; Thu, 7 Jun 2018 07:55:02 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI+dXFdE5JolHOAj8HAnpkjDZpKfGudq6435n2Pr46iaAYzWXdXFXqcQnoK4a7MdLDjWIVS X-Received: by 2002:a17:902:7244:: with SMTP id c4-v6mr2385300pll.265.1528383302319; Thu, 07 Jun 2018 07:55:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528383302; cv=none; d=google.com; s=arc-20160816; b=kq9oxPSgXKU1NokYQbG3FqKzSxfy8vmqtHi5dYgXGEEEZ4PFhP9kXpDoUHzQnpKukW sjW92R6ob8mWVN38ubfvZ6hnO/PzJp7JpycTAQ0ZfjcMrgkWv6kh8vcV60cLWmtL+uIX SSjPngSB+OaFkzf0I0DUlYU0cf87k3fzBkGUGXbaCWt8hEG6EjkCtEpIr1nsi2Vpin33 zjVGPOz3R2Q1RX92ji9MXjAMUWdAuKAK+ULG9a6HWu74lAL+O5RfDzh5/myJDZTB7UD0 F/3c30TbqGL4mIwTSpwLZTC2/TWlYts8LPdPe5Wv00BaZfOnaJNQZP5K0RLdnB7Mx6FR g97Q== 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:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=LjAkwTK2CeJAzFR7TmIgBgIaLldU0D87tCfesQ4CxSE=; b=VCo4Qt8Wno+mJhlE5hpt14axsjUJlTArbGBtKNrzgB5NqOmBNI0HBPuVbNvpi3dqpL 85dKHYp51vxvamT3tnK5SvBdnyw1wFku0cC/vKulwsp+9/YZjJShAjICJSfrAUvd1Ulx vPxPz6vYtgFeR6wrrfgTceRGTf15y2T4bHOK8qTBa12Qcm8EbxkgMT8cLCO3QBQjRUmx he+va469M4jCv/YagF9/2z76oJnYbV5/1/6n2La7izKUH5fAAuYh3JWvn03ZyDM7gwYY KrwIpWDbvRlCBkRZGKR9pk5a1wgCpTzsQ9AbLLCTVtohQroOyJomTsgwC885iHAHgtQ2 vacg== 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 32-v6si54215051plc.252.2018.06.07.07.54.47; Thu, 07 Jun 2018 07:55:02 -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 S935204AbeFGOwd (ORCPT + 99 others); Thu, 7 Jun 2018 10:52:33 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:40911 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934263AbeFGOwV (ORCPT ); Thu, 7 Jun 2018 10:52:21 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbY-0005Zs-R4; Thu, 07 Jun 2018 15:09:32 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvb9-00036s-E8; Thu, 07 Jun 2018 15:09:07 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "David Rientjes" , "Linus Torvalds" , "Dan Carpenter" , "Al Viro" , "Dave Jiang" , "Jens Axboe" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 276/410] kernel/relay.c: limit kmalloc size to KMALLOC_MAX_SIZE In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: David Rientjes commit 88913bd8ea2a75d7e460a4bed5f75e1c32660d7e upstream. chan->n_subbufs is set by the user and relay_create_buf() does a kmalloc() of chan->n_subbufs * sizeof(size_t *). kmalloc_slab() will generate a warning when this fails if chan->subbufs * sizeof(size_t *) > KMALLOC_MAX_SIZE. Limit chan->n_subbufs to the maximum allowed kmalloc() size. Link: http://lkml.kernel.org/r/alpine.DEB.2.10.1802061216100.122576@chino.kir.corp.google.com Fixes: f6302f1bcd75 ("relay: prevent integer overflow in relay_open()") Signed-off-by: David Rientjes Reviewed-by: Andrew Morton Cc: Jens Axboe Cc: Dave Jiang Cc: Al Viro Cc: Dan Carpenter Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Ben Hutchings --- kernel/relay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/relay.c +++ b/kernel/relay.c @@ -166,7 +166,7 @@ static struct rchan_buf *relay_create_bu { struct rchan_buf *buf; - if (chan->n_subbufs > UINT_MAX / sizeof(size_t *)) + if (chan->n_subbufs > KMALLOC_MAX_SIZE / sizeof(size_t *)) return NULL; buf = kzalloc(sizeof(struct rchan_buf), GFP_KERNEL);