Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp395187pxj; Thu, 20 May 2021 11:48:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylqk8AVPl8CcpYYDHuIUf1eVANCL6UMrrfsw9ZZ3lINtsXfTrkR9JZ7T7hZ8yReJg+DYpQ X-Received: by 2002:a17:906:7302:: with SMTP id di2mr5968281ejc.409.1621536530909; Thu, 20 May 2021 11:48:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621536530; cv=none; d=google.com; s=arc-20160816; b=l0gbDFr/+bNbPBwpvlltH7icxz/62c1jJuVNgtystJIJQ/EniK32XtXyQ4RWrKiO6u isCu4s9FAqSBhpZWs0Fkfx6LPvG+5NUUjDUi5iX6MKs6nJeBRdaADV9rFDRCtPRPe8js LAxzKaGU9STVDRG+gLRWYw2W9ZWr1Bsxrk8o0qXMWmoLO8YpG4pzHVsGglvq0mm20AhL Fgdz5xMHU4oGDZafxvsFk3qUB+nXjhwWH0lrASQsCMZhKvlVZ8JtI2AuREZuW9d0tyGS JcBR84auXQsFZZqWK82262gQCX+OuD8a5aFKpipqMHjJ7KJxARjibIQ3gSFqzV7VPSLJ Em2A== 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=UYuwAYkOJt5ImsaoyoNje54DyZlJW9ldwnLjNyZGMmI=; b=zNgWP/vkwpOm00p+0ys62X50IBEVIfs7gTUr4TDk9Aw0ZhwWTXuDPJiqcqSDO7cG1J q1lK9ZCnX+k+iRMsKQHqpLPVH5nZF2YCXj94kUynU6kJSPkDq52mj7gC6ZsSCawFwjx3 G81cp5eOzZ6WJ6kJIoRp6ow1NplcNQwvPQ/TC53gashZt2JUlIFU9KiAumlVeR8l9heX 162FXMk8trPjuSVYbcfgS/GNVCiuWpnvEo8HKJ4MNXYxDq/RFDyfhnDQiYqE7w0XEP/A OkfFo7t8TerCvjYgm3R4OeHwpDoApIJnFBLpRfdK9Lg41IeMlzk3BpuSIpfW97Cf+L0j Z2OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f8ani2p6; 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 i26si3265422ejy.283.2021.05.20.11.48.27; Thu, 20 May 2021 11:48:50 -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=f8ani2p6; 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 S236253AbhETKW3 (ORCPT + 99 others); Thu, 20 May 2021 06:22:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:42496 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235245AbhETKLO (ORCPT ); Thu, 20 May 2021 06:11:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4853C61439; Thu, 20 May 2021 09:43:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503811; bh=nWN8Ek/6baufsSyJRUd3zxXlNVoaCE3yUJlGKIix6js=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f8ani2p6tkjbE4Y9krG4nTzTqlWW7NE2GtRAuseo57i5TfdWdWpwA6YR6M6qTHNkc ye4Izx1rtr9MLswAS9d2XpJKcpcbl8wFpJQgRyuSyQewXk6NJ4Fcp/jpEExxC0nQb8 6MNRfyXUPHyQpdqAWDMlutJwA82FIdY1YFHXIqWM= 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.19 390/425] kobject_uevent: remove warning in init_uevent_argv() Date: Thu, 20 May 2021 11:22:39 +0200 Message-Id: <20210520092144.220032626@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@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 @@ -250,12 +250,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; }