Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1315782yba; Tue, 2 Apr 2019 06:44:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqz+dgpO7TCkc+SLTwP5iubbbr554eQ1vm8uB1ujBBqMMrgBASc1X1dSGkXaDPw/88AftH1H X-Received: by 2002:a63:2208:: with SMTP id i8mr50208568pgi.223.1554212681942; Tue, 02 Apr 2019 06:44:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554212681; cv=none; d=google.com; s=arc-20160816; b=I/XUwOWNwPxcT4YJP2I5cYuMowo69DNe2yzgwt7mpeen/1kawI2G0cxEqppxhRXSr2 LiVjAKqlQXjObJvF5thzIKCxQXzkIwqUlsr3czuLqcSqdMEvvJeeepWsEKjBgHOxAMdS SQHqm1YvjXwB8WhZ6Bj49fsuCT3wqWAbj/IPzdhEYatUUPoPPGNFdA0+qwo+S1Gxc/bk 28V61MtygI/knn3exXaHSUBiC/WZRpTHqYAWS6LdIj2QYZ1B2Vk4pTXjpcIL0zWVQPAi yCAH43xyR7fxUMkXB+ujxuujclIJbJfFVT0hF5iRK6hOtDvF3j3vxPhOllcHJA9P1gMA Uc9w== 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; bh=N9ILLvMjbyZkgjdl89yT78MKcwAqRTM8RcP4m7HSg4w=; b=EvAyZOj/cajI6qYUP+Zggt/XA/rH5NNOyKmOABjb4I7NT+IS+hSKO/qiKd9CGLrQBy OtH/lxdtYtBo+NySfuQsL/l7ua+3faVaSx0yO4lTx+lQDwwgMJ+zicBBDPRwbNSVBo6c TtxNFrN+CuDBqDp129ZHx3yLNYh0jX5FTzXeOtDtoP8sIcgMs1C1MVsNQFk9VFi+6Ysh jrKKs7GKiWsDGxu+pRMgIDt8I5PzEAlcg8E2ky3NHESKGJx1urGwldxzHPz6wsHacX+T Aa3WIJSK3C7PdILpc7K6eupCCJNDkdR6IEXcwKJLf1qGsR4IiMbxRsjY1z2yj651X19X aQgA== 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 140si11197406pga.460.2019.04.02.06.44.26; Tue, 02 Apr 2019 06:44:41 -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 S1731297AbfDBNmC (ORCPT + 99 others); Tue, 2 Apr 2019 09:42:02 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:43784 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731547AbfDBNkN (ORCPT ); Tue, 2 Apr 2019 09:40:13 -0400 Received: from [167.98.27.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hBJe6-0002oY-Rj; Tue, 02 Apr 2019 14:40:11 +0100 Received: from ben by deadeye with local (Exim 4.92) (envelope-from ) id 1hBJdw-0004v7-TO; Tue, 02 Apr 2019 14:40:00 +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, Denis Kirjanov , "Greg Kroah-Hartman" , "Christian Borntraeger" , "Frank Haverkamp" Date: Tue, 02 Apr 2019 14:38:27 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 58/99] genwqe: Fix size check In-Reply-To: X-SA-Exim-Connect-IP: 167.98.27.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.65-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Christian Borntraeger commit fdd669684655c07dacbdb0d753fd13833de69a33 upstream. Calling the test program genwqe_cksum with the default buffer size of 2MB triggers the following kernel warning on s390: WARNING: CPU: 30 PID: 9311 at mm/page_alloc.c:3189 __alloc_pages_nodemask+0x45c/0xbe0 CPU: 30 PID: 9311 Comm: genwqe_cksum Kdump: loaded Not tainted 3.10.0-957.el7.s390x #1 task: 00000005e5d13980 ti: 00000005e7c6c000 task.ti: 00000005e7c6c000 Krnl PSW : 0704c00180000000 00000000002780ac (__alloc_pages_nodemask+0x45c/0xbe0) R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:3 CC:0 PM:0 EA:3 Krnl GPRS: 00000000002932b8 0000000000b73d7c 0000000000000010 0000000000000009 0000000000000041 00000005e7c6f9b8 0000000000000001 00000000000080d0 0000000000000000 0000000000b70500 0000000000000001 0000000000000000 0000000000b70528 00000000007682c0 0000000000277df2 00000005e7c6f9a0 Krnl Code: 000000000027809e: de7195001000 ed 1280(114,%r9),0(%r1) 00000000002780a4: a774fead brc 7,277dfe #00000000002780a8: a7f40001 brc 15,2780aa >00000000002780ac: 92011000 mvi 0(%r1),1 00000000002780b0: a7f4fea7 brc 15,277dfe 00000000002780b4: 9101c6b6 tm 1718(%r12),1 00000000002780b8: a784ff3a brc 8,277f2c 00000000002780bc: a7f4fe2e brc 15,277d18 Call Trace: ([<0000000000277df2>] __alloc_pages_nodemask+0x1a2/0xbe0) [<000000000013afae>] s390_dma_alloc+0xfe/0x310 [<000003ff8065f362>] __genwqe_alloc_consistent+0xfa/0x148 [genwqe_card] [<000003ff80658f7a>] genwqe_mmap+0xca/0x248 [genwqe_card] [<00000000002b2712>] mmap_region+0x4e2/0x778 [<00000000002b2c54>] do_mmap+0x2ac/0x3e0 [<0000000000292d7e>] vm_mmap_pgoff+0xd6/0x118 [<00000000002b081c>] SyS_mmap_pgoff+0xdc/0x268 [<00000000002b0a34>] SyS_old_mmap+0x8c/0xb0 [<000000000074e518>] sysc_tracego+0x14/0x1e [<000003ffacf87dc6>] 0x3ffacf87dc6 turns out the check in __genwqe_alloc_consistent uses "> MAX_ORDER" while the mm code uses ">= MAX_ORDER". Fix genwqe. Signed-off-by: Christian Borntraeger Signed-off-by: Frank Haverkamp Signed-off-by: Greg Kroah-Hartman Signed-off-by: Ben Hutchings --- drivers/misc/genwqe/card_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/misc/genwqe/card_utils.c +++ b/drivers/misc/genwqe/card_utils.c @@ -206,7 +206,7 @@ u32 genwqe_crc32(u8 *buff, size_t len, u void *__genwqe_alloc_consistent(struct genwqe_dev *cd, size_t size, dma_addr_t *dma_handle) { - if (get_order(size) > MAX_ORDER) + if (get_order(size) >= MAX_ORDER) return NULL; return pci_alloc_consistent(cd->pci_dev, size, dma_handle);