Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp608398pxj; Thu, 20 May 2021 17:44:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzE4wSwzw0CWFZLVqYtEFxAp3htRVQAbk3/69cpQK8t4jt+tE4iOYw+z52HdY9w6zSNeuqQ X-Received: by 2002:a17:907:76b8:: with SMTP id jw24mr7260685ejc.359.1621557857752; Thu, 20 May 2021 17:44:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621557857; cv=none; d=google.com; s=arc-20160816; b=SAQJkw5fxZ7/XmlOLLtwzOHnTmi02/sJHryo+3o9maPwj64F6urt9qKLPMMs/+5oRm e6ihj4suP/kYA79vo9RTUtYKPACtZ3OwrvEghtEL0tHLw2uQduYwBFN1e1cCIq2yQ2i8 uyC4XPSY30+yHMOgJWsPOH3c+5qslc0NC7C4sahMU7pXxJMOxWO228Mjo74+3q3Kj5s0 x6aLr8Ea4J3/oqG4irkcgs9pNAmNzJveANl0Fc44fmJ3fIsriRvMlUg+eF3ekswkSV7L Dt9fk5YbWepGNgHGeYaiTKJ2ltTBMKXUIGQAlrmTJ5O3nGFFeludOoFmrcqE6Vg+fTer oLeQ== 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=Uuw+edvVqsA4McSyaDNG7qKfcoMLw9JCLNXcqJabDpENuy6lbMBZKFyGuB9bm0u38Q TdHFIrR9dtwhD9Dp/m8m6F6dPa7sfxicx2uGomXx7TamEdy+s+W7IfFaHzBsM2eTDB1k lRWkYpIJbop4J1arEnV5tkioGjcF8gxNBCbm6g3Jk3lU4nGZTDx+FC/f9+s3o09lMQdW dPuMfmQ60qhrt1Rm5oWrGgGG+tnqIJkyCb0m6Wy+X5Pyc74flbcjqldcJg7v1BJ6pKSN zmadIEo6awKQ7Oj6Mo4H13BhqZKzr7d9P3fyxZxWTeOTLMcacC0Cs5Z/A+RXPpWAT3u+ AcPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="a/RQ8TOv"; 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 bd11si3430381edb.491.2021.05.20.17.43.54; Thu, 20 May 2021 17:44:17 -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="a/RQ8TOv"; 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 S240716AbhETL05 (ORCPT + 99 others); Thu, 20 May 2021 07:26:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:47890 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240022AbhETLG5 (ORCPT ); Thu, 20 May 2021 07:06:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6B33861D2A; Thu, 20 May 2021 10:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505145; bh=ohp7rWeWY5eEJpqoG1zTg90+0OjjATPWPtYVKU5OirU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a/RQ8TOvu+c0Yj+aJCe5NmywcUDClNduMcWL7BaP7wYfY3WuhnTttdOIGo/s0rawc RgCu0+er5SnmjbmlB58zVG/it7z6DgPh+AJ2O5/kwRTkNwu6Hm+qJnPO7+smuiUpLV bWQlUcF+sRHVRIXGSkVNY4ehvBmtTscIZAJF1wm0= 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.9 221/240] kobject_uevent: remove warning in init_uevent_argv() Date: Thu, 20 May 2021 11:23:33 +0200 Message-Id: <20210520092116.120588012@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092108.587553970@linuxfoundation.org> References: <20210520092108.587553970@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; }