Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp549366pxj; Tue, 18 May 2021 09:03:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlvAhZc53glAVgTsAyf2Zw1tEFDZaRzDXoDNAg2dNGBFj5F381JO2rIXC+0mEFnmO3xxHC X-Received: by 2002:a05:6402:5243:: with SMTP id t3mr7983887edd.250.1621353832583; Tue, 18 May 2021 09:03:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621353832; cv=none; d=google.com; s=arc-20160816; b=DVAGxye/9VDtEOvJwTn3HZKxSztqnEc/pMWD9YQ7yE3B8rKXjJ7nqBOxTwDeHW/nmL 0lAKv4EmwrWfZewmQYoYcmiZZPawwt1HD6+owyRw6sbD4MSxaQSgqE8J03p/Vl3YM8Tt XG9ZH9aVV04I0tAD5W6NekhC0Y7cBNkhLowqhGCKUVY9C2Rn0GSDMBsSzs2tl97DVoU+ kUz5/p8oWW81partG1HCVB9aO8gUyU34NObomgxdu2fQH5i/KEVwxiuUu7rNekb/kHRC CQNamfsxgXYbiTR5rQ2wea7jlwkKw+L467dxnWZvp0gIcRTD33EJKNhMGrixNqELZaff KgkA== 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=LEmT1wjbg9th6oTx+WvLmJpz47a6rd0k6OsP648NYtLdZV73ykKuYgYqYGWQoS9f6X 5RLwwBbX44HL+m2FDvybKqUr+FuYSi/VfXryvYMUbzhjSSGCgxUm1N35kkvvLoEBj2xt ufhgqCTslViNtYvVkLilpUbW6zcwpVtJpdmeMFWnfWIO7vYt9KNRPtkugqkB3+nEWSDo h/GE7dK4NNHDve5JSE/q93LjJl3JmE5Cmg/2Ghj2EmHQ/3HPQ82AaGmSwEMak9JV3X1L 3MbVzu43Ebwu8Wbh3bREm53gae28UU85k8cLSYjnRR9LLvlxu/7cdgL3L6GQ572F3xDk RYqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lyiMSfsd; 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 co18si11538072edb.537.2021.05.18.09.03.27; Tue, 18 May 2021 09:03:52 -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=lyiMSfsd; 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 S1345285AbhEQQAU (ORCPT + 99 others); Mon, 17 May 2021 12:00:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:52358 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344050AbhEQPkN (ORCPT ); Mon, 17 May 2021 11:40:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 619DC61D02; Mon, 17 May 2021 14:41:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262509; bh=LnGGExNcUTjQB6r41cBkpiSRuxFT6a9BFdRTamgqnu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lyiMSfsdoWD3j3dIHyTK7HqdhzsV6wzJ3/c9As/TBU5NsC3R7XfBrrGl4mkeJFf1K 8NWLl/IH1EGlKKs0YPHrPqhUBWdimqHK5FqZ2D5ZOTvzMYPsBTRNjxcgnPFuoFOhbW OJZBwQQc5c1UdXdtxVtYMucTsIgxSIiFjnFmtY34= 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.11 310/329] kobject_uevent: remove warning in init_uevent_argv() Date: Mon, 17 May 2021 16:03:41 +0200 Message-Id: <20210517140312.578673376@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.043055203@linuxfoundation.org> References: <20210517140302.043055203@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; }