From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753408AbdBMRIM (ORCPT ); Mon, 13 Feb 2017 12:08:12 -0500 Received: from smtp-out4.electric.net ([192.162.216.182]:56660 "EHLO smtp-out4.electric.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753219AbdBMRIK (ORCPT ); Mon, 13 Feb 2017 12:08:10 -0500 From: David Laight To: "'Arnd Bergmann'" , Scott Bauer CC: "linux-nvme@lists.infradead.org" , "axboe@fb.com" , "keith.busch@intel.com" , "jonathan.derrick@intel.com" , "hch@infradead.org" , "linux-kernel@vger.kernel.org" , "linux-block@vger.kernel.org" Subject: RE: [PATCH V5 3/4] Move stack parameters for sed_ioctl to prevent oversized stack with CONFIG_KASAN Thread-Topic: [PATCH V5 3/4] Move stack parameters for sed_ioctl to prevent oversized stack with CONFIG_KASAN Thread-Index: AQHShhUmx85lCBdFoE2OzVhJwTHuIaFnH7aQgAAA4QCAAAjzAIAAAPyg Date: Mon, 13 Feb 2017 17:07:13 +0000 Message-ID: <063D6719AE5E284EB5DD2968C1650D6DB02851D7@AcuExch.aculab.com> References: <1487002272-17940-1-git-send-email-scott.bauer@intel.com> <1487002272-17940-4-git-send-email-scott.bauer@intel.com> <063D6719AE5E284EB5DD2968C1650D6DB028519B@AcuExch.aculab.com> <20170213162941.GB18913@sbauer-Z170X-UD5> In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.99.200] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-Outbound-IP: 213.249.233.130 X-Env-From: David.Laight@ACULAB.COM X-Proto: esmtps X-Revdns: X-HELO: AcuExch.aculab.com X-TLS: TLSv1:AES128-SHA:128 X-Authenticated_ID: X-PolicySMART: 3396946, 3397078 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id v1DH8Rq8006254 From: Arnd Bergmann > Sent: 13 February 2017 17:02 ... > >> > + ioctl_ptr = memdup_user(arg, _IOC_SIZE(cmd)); > >> > + if (IS_ERR_OR_NULL(ioctl_ptr)) { > >> > + ret = PTR_ERR(ioctl_ptr); > >> > + goto out; > >> ... > >> > + out: > >> > + kfree(ioctl_ptr); > >> > + return ret; ... > >> That error path doesn't look quite right to me. ... > > good god, this is a mess this morning. Thanks for the catch, I'll review these > > more aggressively before sending out. > > memdup_user() never returns NULL, and generally speaking any use of > IS_ERR_OR_NULL() indicates that there is something wrong with the > interface, so aside from passing the right pointer (or NULL) into kfree() > I think using IS_ERR() is the correct solution. You missed the problem entirely. Code needs to be: if (IS_ERR(ioctl_ptr)) return PTR_ERR(ioctl_ptr); David