Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2722046imj; Mon, 11 Feb 2019 07:30:48 -0800 (PST) X-Google-Smtp-Source: AHgI3IbqCiwGG1L0Kvsn1mo9DJTLjtLz/uF38C62XjFThP69CvyIkQyB/uO0zpJcwgSHl4z3eMc1 X-Received: by 2002:a17:902:b690:: with SMTP id c16mr38560776pls.230.1549899048547; Mon, 11 Feb 2019 07:30:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549899048; cv=none; d=google.com; s=arc-20160816; b=waHSSwsVzijc6Tandf4mcPnhugY1+yel8ATMyLEpG16dvdaOY4IAXlBpIHP5Kdilcy 5Z7kXn763xfVA4bdYX/g/xlLEdnC5jfFcSVKpu1ek6fyCyLDPfuFEsfsGJrZj90mpXe7 j7TkSTHEPizpVfdfTp7PZG88ExeyRsNt0OJFdVk61FHRi2slv+MRhGFp1Uyo/vAC9B2r lWc+Wn/AykxGXhVtb5z/W24Yu1JsmJiHuoe/TAin9Y4igyh7m1pdqdm938cdTARFzUJr BP0/4Dy+0HdpxMQAxQfF7qdbu5dCKFr3B/7WeYASl8nrV4H/gZmQcCDZW+HjmRtM7y84 4iRg== 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=kOUIwBSya1HMqy397gMIvwdsj+BeyTf73Mt7kbndwNU=; b=I6vsPkeZtfDlIEOcG+dSc938sWnhe/yAaIISK3NWOshNfXljZOpT+RayzM+DTxH05H voAoxQZE4HGCVZJRV3XDWR5RInIxlveGO8IRFOcRU6Ee6tgibArJo6BO9wkH+foBcqNG 5+sM4djZRJN3tfgC4aZ6ZYrPrv8ON5W7ucUG0d/4fl2GWX34FklXpnR28/ek5Kt7Tp4c AyagvrwS4u9PdKisUfXmgdWIq8aJ5Zpqag9nMqLL2kJdnmgXaSuu4trHRBa9jdc4sq6o BCxClhZdqnK5+3/CWrwwsg5INUlGhr455KLH6MN7/UneNNQPGBZYr+4ec0eFTKo4r/Nz MpKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zUigxIoj; 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 f4si10894547plf.370.2019.02.11.07.30.32; Mon, 11 Feb 2019 07:30:48 -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=zUigxIoj; 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 S2389311AbfBKO5M (ORCPT + 99 others); Mon, 11 Feb 2019 09:57:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:44510 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389286AbfBKO5K (ORCPT ); Mon, 11 Feb 2019 09:57:10 -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 BC383222AB; Mon, 11 Feb 2019 14:57:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897029; bh=pYU6QX0ofs/59rjzJqR5NjdiQt0xkzBj48gNMVhgClI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zUigxIojYmyVK3MhAR7slmMpfbGhuJ0fTU/4yp6ZNkMqYDw6QzVWvFp6SRP9OKXKW Iy4ixnd/sbXLq19futkOMjYv/RkC0NpGjJhQV4n2XMG5HIfVWjOcTk8Q0X8MVqlqhA 1LY75UBSHo1ffwUZT5zdKMbJKk1ccgBo3l/UPbN8= 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.14 068/205] kobject: return error code if writing /sys/.../uevent fails Date: Mon, 11 Feb 2019 15:17:46 +0100 Message-Id: <20190211141833.203271900@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@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.14-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 1cf1460f8c90..3464c49dad0d 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -616,8 +616,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); @@ -833,8 +835,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 fc5bbb2519fe..1c67bf24bc23 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -991,8 +991,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 2a44c515f0d7..94528b891027 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -1201,8 +1201,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