Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3706145imu; Mon, 28 Jan 2019 09:21:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN5K9H3ll6UKZRroldmZXkf3y2hxeHMuAVPCyNAkZPlB9AxepjSDjUmrLjdM1VVz9sff5lB5 X-Received: by 2002:a17:902:1126:: with SMTP id d35mr21243115pla.1.1548696080112; Mon, 28 Jan 2019 09:21:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548696080; cv=none; d=google.com; s=arc-20160816; b=U8hKo2ab0gwi01+rPca+RQ9qSW6z3Sq2+jQyDZsmK2d4lYNtzS89wV+CMiEmtcfIOy 5XpViFyDHrA5Cf4iYx4Cw/ir+0yAMW4K8Iw0bImp7ovhuynEOcB8G0L0AM6Ypc8sQHIy 8PkLjyZYcQVz25ae9+s78Y3VfbDWLwo6c+w0/J1Z9a1Pw7NBo97B4z0Ez1S1qDYuXRIx 1URK/wgDbjQmAhpmIBvtYD2kKPScgdC9GvwBFl5EZsMm5ktwWmGkUfFluWTW7bjZXNKR HhZbuG/lQ3N/DMrtiYPu6oXFOaa3a2Yy/oJOLh6Ab71kbEliLGFSGPAPMLW+TNqW6BF1 54Hw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=C+ygPKmDg7pmB5k+vitYfh4zaQVCRe2t/OsSC5ujSK8=; b=r5ngD41xbnfDQQoqLRZ0zEL1mCVTPlPM8ABT+bn/lHDyPPd4tJvBaT9PTs+h/EFKVc rK4UQhU+cVLycwYtd5Md8QSM3OdQDxKpzhSBNMqAZ+UgJH3fPXvLVZq5XyAX0RBa2qO/ DhMZC9kDZhU4CLwCiyStGh1IZie8AliDfMKQp8DTg+ZvbMAo2aZUvzXZpDyvCZE3X2QH JN5KbyXKa4oT+uECKM3EZzkBkNzSozlZ2U6ZY+iZHKJoPjrokQ8rfA6ie4Ij4fr8+Mgg HvPb89mezZQWZR6uFeINe0EMnk2/Z09/t0p598A/pM7UJVfKa0zawne0QQUO/DQkEMa5 65bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bDu7Tak8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t3si34569915pgo.585.2019.01.28.09.21.04; Mon, 28 Jan 2019 09:21:20 -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=bDu7Tak8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731693AbfA1QEw (ORCPT + 99 others); Mon, 28 Jan 2019 11:04:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:50754 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731223AbfA1QEu (ORCPT ); Mon, 28 Jan 2019 11:04:50 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E91A920989; Mon, 28 Jan 2019 16:04:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691489; bh=QC6pCkMHdSBJyWG+XHJCYH2xeRVFQKj8Ivy+sqeDsq4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bDu7Tak8kM7XT37F4XveQHxalwrbn15C5xL1k+olZ6yTW/2jwi+BdanI+NVC7a/cr +F9aBRWRt+sksbhmN/4OtsM6Q88Dc9yK9ts3KmGqhSyv8PmjTuZC9s+eaRqjkEXE/Z RBYMVjbtTOit6DrA1Jba4AN6ldIrZ7D06F+SKkb0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Peter Rajnoha , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH AUTOSEL 4.19 112/258] kobject: return error code if writing /sys/.../uevent fails Date: Mon, 28 Jan 2019 10:56:58 -0500 Message-Id: <20190128155924.51521-112-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Rajnoha [ 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 @@ static ssize_t uevent_show(struct device *dev, struct device_attribute *attr, 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 6746c85511fe..38bf28b5cc20 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