Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp220101pxj; Tue, 18 May 2021 01:39:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhksIOtHHGElm3eyNJ5SXDSgelrzJ7hxD54MK12CnL9NLC9JJ97q7/1gIeFa/HJd0005vu X-Received: by 2002:a17:906:c04b:: with SMTP id bm11mr4773396ejb.263.1621327188442; Tue, 18 May 2021 01:39:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621327188; cv=none; d=google.com; s=arc-20160816; b=yEdWDL39NdT0QE4E9qJKbucx8tafqIubEpfm86Ew7ucc5dBgQly49RylcncdK+Ld2K dFDNVv+NJFfv0bRTwUGFQ0+yUbJXMEZ7P6OfTC3d4bd3Blkbe5p8tYfyLMDyWD3HADbZ NAFKAL2FIpuXywZ6fELsHAJa0I7KzWqiW7zQtBYm7r29GWpfh4bsgoHzS3iyoVfboxan P1clLaoufcXofYHgyg8VKsYkFXYYzV6xBqNxX0y7EJsSj/TZ5+EC8MTrLzdCUwEe3wIY MkX2hFZOhR0zAZW68wOlUd/BawcfWN7JRUG6HSm6iBl0pZ+Cbr4H3KrQKck/nBMkbQhm 2fEQ== 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=t2WlQMYFUzLR8u6o83F/YuQi/hjP/nVZ7xBiv+S2LR7DClhYVhdbp84SN7R4i7HjrF xg20PG+okKGlYaLQqyGAC5H9rKkoOnZNyXhU7xysIy4gqYfHkxbE/FkbNYbsGiYg1HJa DrarCwyiHmTzJTYY2aQST/huf24Cpi5Qiol34yjXNRB3Ip6ZAoOXYmwS6pRHdHMXm79K AIlF22zaQ32XycblEFwvUQcsgVi0mbvP2avG3lX5fMquBrXaHBPCjrsT7RIb37IR8wAN lJOCfvg66MBM0yFfbrddfsCg/7k8gvVv92C9hVW2HVUX16SJyrxRJvB0d9iB0ebj9laX WO+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DjtM285u; 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 u19si17563877edo.74.2021.05.18.01.39.22; Tue, 18 May 2021 01:39:48 -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=DjtM285u; 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 S239226AbhEQPA6 (ORCPT + 99 others); Mon, 17 May 2021 11:00:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:40530 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241427AbhEQOvB (ORCPT ); Mon, 17 May 2021 10:51:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 86DC3613C4; Mon, 17 May 2021 14:23:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621261404; bh=LnGGExNcUTjQB6r41cBkpiSRuxFT6a9BFdRTamgqnu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DjtM285uBlU2veIn+PoSs95ku5VwFfDjj0jlou6t5wMl6SyXKI3PyY0tIvFMGdUyu gT0/QYIfNVSXjV1kr0B7nmn3NSL3jCpEyeWYJflowrIIj/J6aVJy2jcd6FstJB6wMs 8fcl3C9X1kUbfmKVsRMlD9n/igQM7SfuOUTIWuRI= 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.12 342/363] kobject_uevent: remove warning in init_uevent_argv() Date: Mon, 17 May 2021 16:03:28 +0200 Message-Id: <20210517140314.171340881@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@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; }