Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp470942pxj; Thu, 20 May 2021 13:46:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGpABXDnp3KAS5R39kIiuWT0b6IgIu+BprkCGQAAdnSoqAVt9VctwsyjPmWr8uXVcn7TtZ X-Received: by 2002:a05:6602:2407:: with SMTP id s7mr2795426ioa.170.1621543563901; Thu, 20 May 2021 13:46:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621543563; cv=none; d=google.com; s=arc-20160816; b=T3aQdwRtn1sX6GR8ggMuuBF+ImUI0QHYSK6SaOQZ6DhUe08LCPm6gJ8uBXP8a1YqT7 fbEqQacPzq3hdSZfE8GGwjV2MkF5rtEVGsri5FuHP9dvl2fQTMHpG/afXyJYt3SIdKL4 f10pf7KT2/Lc+hxYYyTxaCQmOWsrPHodwUvA7aKK2lRxPWQuFUpQ0lOYiUKwB9M36OG4 u39xYu6kk4BTmR1hHFS4T8odtrw0tsEHWC7+K99eIKX9VjHr3mJA5+OcMv2JILrnK287 CCGaWioZ4jW0qpYFa9DMbQKNQbYPR4uacg5w1FYQlFKpKXs2NEgJ7TNtgQCvDAJ5kGVk KJ7g== 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=pWRmhdolPNs5a8+z/3S7uhPj/pwbmVL/9tQ6bYvqGTI=; b=HwIqH7PPh0iWMOa7yaAyE+R8DX+70pZsS0bkxw4KoO4kgaMnPHARYtXVFki4py+Fo0 VNMvFSuFj8fLi87HyKsMwrpzCFo1w2RfQcrAoNW80r9hSGaPVjF2HrTCmtJ8s15frTBd fK2oh4AANhVmBcF7+24wvH/LOzwvdkXB9LMetFucwm2rGd/ITRWMIJdQqDfKM+d2VNbk rtP7O6SYO3fxMMSOC6aEaLKK7r8qAQOLl83+mOTiOMLGmb/e7u0VDnsh86UvqkS9UHgw EX6WoVWHJz4Oinix31WcbPzTHdGZnEsmtdP8ofiGzBwaf16O7xXuuJ7B8Wi9FDdrcMZe PS+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sXnBZ+7Y; 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 o5si3481664ill.66.2021.05.20.13.45.51; Thu, 20 May 2021 13:46:03 -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=sXnBZ+7Y; 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 S235828AbhETK4s (ORCPT + 99 others); Thu, 20 May 2021 06:56:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:44316 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237471AbhETKlN (ORCPT ); Thu, 20 May 2021 06:41:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 154A661C92; Thu, 20 May 2021 09:55:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504556; bh=4IxgD0hiJfQPHW0PxKbIJSfF9EQv08a8HPBbOHkUzhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sXnBZ+7YJxZpnXq1jwovY8b1MD6FksN7+N0F9rBhZqLo0P+P/xb3MPTW88h4Vf5cT BUONMTvBbu11kepuUpa9Him5QWn3YA93ZB9D7/O89BH1EfPv1qV8bsw9BHsYqZe66G kUuOnVHRN2g8exn1nr4lwPIvPxbIo9uv1acVGJr0= 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.14 299/323] kobject_uevent: remove warning in init_uevent_argv() Date: Thu, 20 May 2021 11:23:11 +0200 Message-Id: <20210520092130.480642883@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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 @@ -271,12 +271,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; }