Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2650366imj; Mon, 11 Feb 2019 06:28:41 -0800 (PST) X-Google-Smtp-Source: AHgI3IY0BY3SL4V30TXWhZEux8I8YTPZYEqsW2cAg+91AGh6Gnx2ZRKSBL/BEQcXU8ySD78qnYQq X-Received: by 2002:a62:8dd9:: with SMTP id p86mr36535831pfk.143.1549895321240; Mon, 11 Feb 2019 06:28:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549895321; cv=none; d=google.com; s=arc-20160816; b=TWwsztzL7a6H++GisO6DBK/5h3uiH3vNnM2SK1uvoXmdqLoHhY73oUAkJKKTFrj4Tc yppOnDsGgqtSbPFWOEx7Z6fBdjCVpDlOMzN+UtGOPSyapf+i0EEuS3LKoJ6rum39BJMR aMJAXpKXzr7zD5seH680j8CtPKGABzfiMnCI2WQoQTqajQdAzF2AwWhwfitblJYCLCLZ Tyreu2cZzURJt+XkTH3Fv3zkkuj1pfH+lja5TxWB3LchC2nK71kkWaQL77WQjLGuYOEo iNHw5NmVB2ZJ/NXHzFqArNmgEHn+L4EvOTD0rG+Pc9C6FuwoKKeo5/ITXjzpoFj8XIEB F3Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Mv5vEaZJFP4IILYP9yBQMpC3HnUxHwHfD0CNJEBQXus=; b=Lipe87e8CNk2W7KIsBRzHpS6V4dYkNO/zcVkvUnLOQLekvELmjryHxcMzeIjEVPiXE fr1TvRxZhucBfCS+LZQs9uCGbJ+fSP841HBD2HjiNSYGlqcn0SB9SJvgY6eFoyUWEWFr JKBk5E1Xe0cZn8vW7rI6WY5X1vF+CKb6ySwBKgsZlvcpd16V/dhwAGLAXt+02N9/c5u7 NyEh8tKU1CU502vaPbwfkfmsLl/dLmdOgdUI/DZ5zIDo+8lXUYJuFdrSQH0mP8+17I56 +8iqZyO36+xFQnO0etu5nYPGA/zLhqrnyoIG70JwFqsYeCcpTDPkWYyaYU7yl+cTeFO1 uJrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GUe+WCPy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d8si9747386pgh.505.2019.02.11.06.28.25; Mon, 11 Feb 2019 06:28:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GUe+WCPy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729571AbfBKO0d (ORCPT + 99 others); Mon, 11 Feb 2019 09:26:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:60354 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729557AbfBKO0b (ORCPT ); Mon, 11 Feb 2019 09:26:31 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B4CD520821; Mon, 11 Feb 2019 14:26:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895190; bh=Zwp5+TM1/GcRvt2/zZ6mDB5Kl0b8s1GpwdU1Lw0hDPI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GUe+WCPygmZu0SEEkcwv4Mb6fuQ7iOjE8sAsOxW5J+F2o3Ohz5MXVN3Z7lOStokvS y+Ali9ANG1stTbcarT2RZ0qZ/t9KHMsbpWZ6cEqXX504CA7GMe0DRDSvnWlZpNuR86 aR7i+FkP6LV6TqeEQUYmI4JFJsGGcI2KnOlGs0nY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Rajnoha , Sasha Levin Subject: [PATCH 4.20 124/352] kobject: return error code if writing /sys/.../uevent fails Date: Mon, 11 Feb 2019 15:15:51 +0100 Message-Id: <20190211141854.168272182@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit df44b479654f62b478c18ee4d8bc4e9f897a9844 ] Propagate error code back to userspace if writing the /sys/.../uevent file fails. Before, the write operation always returned with success, even if we failed to recognize the input string or if we failed to generate the uevent itself. With the error codes properly propagated back to userspace, we are able to react in userspace accordingly by not assuming and awaiting a uevent that is not delivered. Signed-off-by: Peter Rajnoha Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/base/bus.c | 12 ++++++++---- drivers/base/core.c | 8 +++++++- kernel/module.c | 6 ++++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 585e2e1c9c8f..e06a57936cc9 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -614,8 +614,10 @@ static void remove_probe_files(struct bus_type *bus) static ssize_t uevent_store(struct device_driver *drv, const char *buf, size_t count) { - kobject_synth_uevent(&drv->p->kobj, buf, count); - return count; + int rc; + + rc = kobject_synth_uevent(&drv->p->kobj, buf, count); + return rc ? rc : count; } static DRIVER_ATTR_WO(uevent); @@ -831,8 +833,10 @@ static void klist_devices_put(struct klist_node *n) static ssize_t bus_uevent_store(struct bus_type *bus, const char *buf, size_t count) { - kobject_synth_uevent(&bus->p->subsys.kobj, buf, count); - return count; + int rc; + + rc = kobject_synth_uevent(&bus->p->subsys.kobj, buf, count); + return rc ? rc : count; } static BUS_ATTR(uevent, S_IWUSR, NULL, bus_uevent_store); diff --git a/drivers/base/core.c b/drivers/base/core.c index 04bbcd779e11..92e2c32c2227 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1067,8 +1067,14 @@ out: static ssize_t uevent_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - if (kobject_synth_uevent(&dev->kobj, buf, count)) + int rc; + + rc = kobject_synth_uevent(&dev->kobj, buf, count); + + if (rc) { dev_err(dev, "uevent: failed to send synthetic uevent\n"); + return rc; + } return count; } diff --git a/kernel/module.c b/kernel/module.c index 49a405891587..0812a7f80fa7 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -1207,8 +1207,10 @@ static ssize_t store_uevent(struct module_attribute *mattr, struct module_kobject *mk, const char *buffer, size_t count) { - kobject_synth_uevent(&mk->kobj, buffer, count); - return count; + int rc; + + rc = kobject_synth_uevent(&mk->kobj, buffer, count); + return rc ? rc : count; } struct module_attribute module_uevent = -- 2.19.1