Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp637873pxj; Thu, 20 May 2021 18:38:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTdm+8vguTCyquUdBKYAyfPuXwcS5yIKQ74+pn2M5vmcOLHV3hEC42h1/HnBJUchQHEjiz X-Received: by 2002:a05:6602:2d8f:: with SMTP id k15mr8675250iow.114.1621561088938; Thu, 20 May 2021 18:38:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621561088; cv=none; d=google.com; s=arc-20160816; b=y4+k28wQS+IQMhDgl3lHF28xdvjjHJ/wFubI7t5/AzEDYkM5j9nQXN+egOzBBO1ifq z/fIYWcIEoO+cyFDrmKBoVbYi3JnNYziFcPPSnodAKsCfDp5HCKhcYx7zUMrY2C0MjM+ obze6mjIGO5A3M1U1WHdzqZLsjwVvmvZO4YZGlab/EN+qxplmfBZZqR+CGj1tLTk7wzQ w5BQBZKqBEsHEq+8D8CyjuY/6/6/U4xBeiAz3qR5S4WkNTsDySJcMI6iyg6lBrmlHfpr TPFx/AkrFkRnDEjiYduS3+4sT2EshMXyI/aIGdBqovmg8r+oTLVMpT0kwSxDt+/rF3Kr oLdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=k4ftu/yE80dfGvm4e/sb2FmhlmOZEKdsiBjqOAXGRtA=; b=so+LBIFEvDAFZ46EhiYnBHCvcZVHejcPYaqKzMG5sl/Or2Oo9nLrRPKteIj0vc6MAI NMp0bfs3S53Pp8TlGlv3dFi4sya8DRP3VksNAjmNdWqP2ziYJHhnVcm6pYCUzSgUhqLr YWBnepzxiCP/kP9RzM91AtAuV49+6gAWs/6ZpTpTvBQqatpNT8XT096k+ZkPNXioMscQ iyDkj6t4GiH3ffwdMgpkRJabbwMZNcpp/R6PCvVXDvDxIJ4sTfBVSnzXOJ8HBePYHKWQ 7auBY7y3/emQEXj7mCZYrUDqJDXeB2QDyaX9KMi8AJi5vtBNc/r6af/pr3kqoKvqAFrG Wgmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f5l0SpI6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a13si4374303ilf.41.2021.05.20.18.37.56; Thu, 20 May 2021 18:38:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f5l0SpI6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241216AbhETLnx (ORCPT + 99 others); Thu, 20 May 2021 07:43:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:44410 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239151AbhETLXr (ORCPT ); Thu, 20 May 2021 07:23:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 26E8D61D98; Thu, 20 May 2021 10:12:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505531; bh=ohp7rWeWY5eEJpqoG1zTg90+0OjjATPWPtYVKU5OirU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f5l0SpI69si40RXx7dqL3KaxEy1zO0Yv/4ywXVSxuQsDrdXqKL9LOY6h6RsNc2Ng2 PpwxNL2PbUKqeMSSDbgS9I7U+afLyCC+kNgwLNs0kHbjMSiZfs+0k2rs+DtdE7IiCq vn+yuxHvzQCrTbj/Q6SyLyyFes+3pjhFu38PQ1iI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Rafael J. Wysocki" , syzbot+92340f7b2b4789907fdb@syzkaller.appspotmail.com Subject: [PATCH 4.4 176/190] kobject_uevent: remove warning in init_uevent_argv() Date: Thu, 20 May 2021 11:24:00 +0200 Message-Id: <20210520092107.990440721@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092102.149300807@linuxfoundation.org> References: <20210520092102.149300807@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman commit b4104180a2efb85f55e1ba1407885c9421970338 upstream. syzbot can trigger the WARN() in init_uevent_argv() which isn't the nicest as the code does properly recover and handle the error. So change the WARN() call to pr_warn() and provide some more information on what the buffer size that was needed. Link: https://lore.kernel.org/r/20201107082206.GA19079@kroah.com Cc: "Rafael J. Wysocki" Cc: linux-kernel@vger.kernel.org Reported-by: syzbot+92340f7b2b4789907fdb@syzkaller.appspotmail.com Signed-off-by: Greg Kroah-Hartman Link: https://lore.kernel.org/r/20210405094852.1348499-1-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- lib/kobject_uevent.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/lib/kobject_uevent.c +++ b/lib/kobject_uevent.c @@ -128,12 +128,13 @@ static int kobj_usermode_filter(struct k static int init_uevent_argv(struct kobj_uevent_env *env, const char *subsystem) { + int buffer_size = sizeof(env->buf) - env->buflen; int len; - len = strlcpy(&env->buf[env->buflen], subsystem, - sizeof(env->buf) - env->buflen); - if (len >= (sizeof(env->buf) - env->buflen)) { - WARN(1, KERN_ERR "init_uevent_argv: buffer size too small\n"); + len = strlcpy(&env->buf[env->buflen], subsystem, buffer_size); + if (len >= buffer_size) { + pr_warn("init_uevent_argv: buffer size of %d too small, needed %d\n", + buffer_size, len); return -ENOMEM; }