Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp662629pxj; Tue, 18 May 2021 11:16:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5z3icErZ2IsdAzQDAWh9Ror5GUaPdB/ktaI9eG6XXfDPof7kFz38KE14ZHXA/e8cD03+U X-Received: by 2002:a05:6402:5244:: with SMTP id t4mr8727262edd.228.1621361811906; Tue, 18 May 2021 11:16:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621361811; cv=none; d=google.com; s=arc-20160816; b=iBkUsojwPVzBmiAoFnbFkT1CqcBUoB10O92TkAWSblmTqVerW7Kz/2XuHFbBQSw7oM C9P2OhxKN/RcO897N/L1DlIdgrZfZ1YryDqmaDVOp56GTxfGyIg3IbQxcLs7VtWV6oU4 krO2tYYL3+W8QTOlJtlaPPaIYQF9IoubVvdlbMQaT1826u5hZSJKOj9siLbQh30aHeSE gmEOWHA7/QbtRWdia5brkScuUfwTRO1QNMylH8iBPNSLQfNBQ21+eefRoXl7o47dlH2+ YHKLSyQ7CXbna0Cuc79rvqoAUytjzZcikNRDwdglgG8EcsB+CvIl31OLUtd+glSAYdx2 hKqg== 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=9SFNJmJCPfJsd6u1p/zyLOqk8l7BbhY6LCe+DxoQRNo=; b=azGkfP+nm24wsp3FtaTQ0NB168pNxIgwqULa9S67MP/7aO0wLsPk087O1SKIOz3Uvp zSI2KV+sISLbl0Q64idCd2cjebRdHMqnAeknekE3eb8pQ4oe9IpteuCbaho1gCIetu8k i3I45Rl12CxUHZ+OFX9IVqARpxKHzoocRMUrwKX+n8uJEFznmJM8XCw3daQdzM12xMnN GsGUkgSGMDPjHX3K/MfAtCkqP7DEjAt93tRi7y1YAWQ4mSQxBobFranIrsHAB/jk9b4J dBBqZbX/x/UWQ+2JkAM2Rx+0L6/M1zhuFWQT+oyG1eCvdBu/PzxcW63bcu4j6P/XDpW1 jBqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jMz7rF7T; 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 y11si18206814edr.305.2021.05.18.11.16.27; Tue, 18 May 2021 11:16:51 -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=jMz7rF7T; 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 S1345309AbhEQQMf (ORCPT + 99 others); Mon, 17 May 2021 12:12:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:36456 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245511AbhEQPsn (ORCPT ); Mon, 17 May 2021 11:48:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 58A8561963; Mon, 17 May 2021 14:45:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262714; bh=LnGGExNcUTjQB6r41cBkpiSRuxFT6a9BFdRTamgqnu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jMz7rF7TFV5rUM0cqXr9EYNf/UHcGdU/a+nb4dHVQkX7WTecZjBtKJHiop1QhXeGM 06qiUh7BmRH+9khWUVe5VmMBqS7u2OyhjiDOPcuvX2kMq0BkUkXuES1ym0CI46eBxH a/1hf3ubPkZ2WgEee14JOYpNQUpEq4VQCI6DbS9k= 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 5.10 276/289] kobject_uevent: remove warning in init_uevent_argv() Date: Mon, 17 May 2021 16:03:21 +0200 Message-Id: <20210517140314.428899107@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@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 @@ -251,12 +251,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; }