Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2085441ybp; Thu, 10 Oct 2019 01:56:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqyeQBh3YBo+o871gg8e/Y7DrZAJFxcO5y2AkschFOvYYDpoMXdpux92Z2J4Z1Q3rQBV0Mc+ X-Received: by 2002:a17:906:7c57:: with SMTP id g23mr7022847ejp.116.1570697790161; Thu, 10 Oct 2019 01:56:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570697790; cv=none; d=google.com; s=arc-20160816; b=WYif9QA9h9LvGKa1K+pEJVW239ynddiVarznyZH2Dy5Ur1sJys9iEIbZ+EqPnKydHy KQNCATzFy/7OWFvxc/uVke8EiMhF9cHhwethe7qOXy1QMPtjU905CYOeoZ0vigxvntEH s5LRz/1DdFXTV3R7Lk2MC7H/MkNHTAwGoHO1i1yFOmv7hFdzC0qc0rln4R21LExCZphu t/US1j39tst8y6Fk5Q0tckt7dfsxbdBOUhz+GcTylvs1saO+NxXr4c8bpa99ImLAS2Ed mmimaxfzTXh/qc5fdZurmvHNaPCxmir9+xPdBX1lXbGOf0J2Wx11PQ60WrwUVGxce8Yi 4X2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5SQCmBBQRIarirRFkaCsu82KYUYBZif8eGHBeN/ov+k=; b=dDI5qtNR7u9+8L8ZfVM3AxWV0Q+ZcY23QxgDP5Fm+81IuTLA2fNrzBX+5UQcN/6r8u jDefsp7ZShlwpfNuI9Tc4ND9MyTsR2ou3YaN/sXpSZzBN01s32qYKI7rpqp4SDMtHIQf aw8pGOPb9dBINSsO1ucTOU9qhePBq1oOO95NbvViIUhxs+aTJmvHfhS5UBl3BV5P2eGQ hs8t7xgMecr3YbnqhmR/vgDs75lgjG+EoS55B7/tXmRlbT6vJdmtlXQILyhDqVXFFcm8 HLQYClhtGsV6kCNCy6pyGPrGzk60JkptjIA7CwrCaGEPrB+kwIKWjMQ8PEh++8qHqweI wXyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FwpJHG7e; 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 y28si3453397edb.162.2019.10.10.01.56.07; Thu, 10 Oct 2019 01:56:30 -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; dkim=pass header.i=@kernel.org header.s=default header.b=FwpJHG7e; 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 S2389313AbfJJIy0 (ORCPT + 99 others); Thu, 10 Oct 2019 04:54:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:57552 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389979AbfJJIub (ORCPT ); Thu, 10 Oct 2019 04:50:31 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D684E21929; Thu, 10 Oct 2019 08:50:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570697430; bh=OrPEpdqwd733jdhoGK9h+vv1s9G3mOo9wyJbXWHjDiw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FwpJHG7eQHyB/ydKb/o9upqVhOKvNSiS+SgqMAKkK5ToFhArGOeB0T9yeAk2OR7Jl cto3uUALBodFCTEBKlpQ+0ubKqaABpfhHtzdKpJefQO7wdlHDI4pxzhKLrVtX2MHSL IT5DxZNjwVpd/br89T8yKbbAnTLxVv/k3270hG+4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sebastian Ott , Vasily Gorbik Subject: [PATCH 4.14 04/61] s390/cio: avoid calling strlen on null pointer Date: Thu, 10 Oct 2019 10:36:29 +0200 Message-Id: <20191010083452.173115242@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010083449.500442342@linuxfoundation.org> References: <20191010083449.500442342@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vasily Gorbik commit ea298e6ee8b34b3ed4366be7eb799d0650ebe555 upstream. Fix the following kasan finding: BUG: KASAN: global-out-of-bounds in ccwgroup_create_dev+0x850/0x1140 Read of size 1 at addr 0000000000000000 by task systemd-udevd.r/561 CPU: 30 PID: 561 Comm: systemd-udevd.r Tainted: G B Hardware name: IBM 3906 M04 704 (LPAR) Call Trace: ([<0000000231b3db7e>] show_stack+0x14e/0x1a8) [<0000000233826410>] dump_stack+0x1d0/0x218 [<000000023216fac4>] print_address_description+0x64/0x380 [<000000023216f5a8>] __kasan_report+0x138/0x168 [<00000002331b8378>] ccwgroup_create_dev+0x850/0x1140 [<00000002332b618a>] group_store+0x3a/0x50 [<00000002323ac706>] kernfs_fop_write+0x246/0x3b8 [<00000002321d409a>] vfs_write+0x132/0x450 [<00000002321d47da>] ksys_write+0x122/0x208 [<0000000233877102>] system_call+0x2a6/0x2c8 Triggered by: openat(AT_FDCWD, "/sys/bus/ccwgroup/drivers/qeth/group", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0666) = 16 write(16, "0.0.bd00,0.0.bd01,0.0.bd02", 26) = 26 The problem is that __get_next_id in ccwgroup_create_dev might set "buf" buffer pointer to NULL and explicit check for that is required. Cc: stable@vger.kernel.org Reviewed-by: Sebastian Ott Signed-off-by: Vasily Gorbik Signed-off-by: Greg Kroah-Hartman --- drivers/s390/cio/ccwgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/s390/cio/ccwgroup.c +++ b/drivers/s390/cio/ccwgroup.c @@ -369,7 +369,7 @@ int ccwgroup_create_dev(struct device *p goto error; } /* Check for trailing stuff. */ - if (i == num_devices && strlen(buf) > 0) { + if (i == num_devices && buf && strlen(buf) > 0) { rc = -EINVAL; goto error; }