From patchwork Mon Dec 16 11:30:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13909580 X-Patchwork-Delegate: kuba@kernel.org Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 79D1B204592; Mon, 16 Dec 2024 11:30:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734348614; cv=none; b=fwBjfJDQ4JdgNajvOmrZpL+Rr5To66emJ7hYt+fs42pGzRWTNxSbEr6ClIENBN5eZwKmaupznqYXvgH0fo3fOvOLuCnIcr0yxBtUVs1YG53UWy6jeQqE8dluqcBoIUXPHPFpgBtxNI/8soCwfReUgYvSd+XC84PBVkjX+kC9w8M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734348614; c=relaxed/simple; bh=afmiFWmGtDwSvWCLz/Awnrz8rUrbWbV1R/aSyG8z9fk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uOdRgCVVPCLwbLi3h68hKkRqayytgtILVdSEpQYO5HJJi+5PO3etQVFoB83ugMLuQ4OZunK2KBePZ0Tcnbg/Z1jLU4bpUhez8PYnCNEYcvW9U6CWffto9msp9UcOtc5Dz8WTe+dK1zRZq1cwjgRrc5g1Sg2Sw1tkNBFaQcYWHqc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=I/JxaftG; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="I/JxaftG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734348609; bh=afmiFWmGtDwSvWCLz/Awnrz8rUrbWbV1R/aSyG8z9fk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=I/JxaftGswFaQLoUCFKkScDmP2dU8N5jdG1tM+4wpCxbSF4pAashONomOrki33B5G z81jo73OWmnLozhgGg/FgVfHOOfh2xmcN4OEqTW7uYcZvRIdIVep2ua8ovk+d87J/W YTLddRNqVNH4JJpACDSRNltZYESXmYL6p6jNL3ww= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 16 Dec 2024 12:30:08 +0100 Subject: [PATCH net-next 1/5] net: bridge: constify 'struct bin_attribute' Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241216-sysfs-const-bin_attr-net-v1-1-ec460b91f274@weissschuh.net> References: <20241216-sysfs-const-bin_attr-net-v1-0-ec460b91f274@weissschuh.net> In-Reply-To: <20241216-sysfs-const-bin_attr-net-v1-0-ec460b91f274@weissschuh.net> To: Roopa Prabhu , Nikolay Aleksandrov , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn , Heiner Kallweit , Russell King , Kalle Valo , Manish Chopra , Rahul Verma , GR-Linux-NIC-Dev@marvell.com, Andrew Lunn , Shahed Shaikh Cc: bridge@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, =?utf-8?q?Th?= =?utf-8?q?omas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734348609; l=1310; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=afmiFWmGtDwSvWCLz/Awnrz8rUrbWbV1R/aSyG8z9fk=; b=ZPFLEa3BA+fgVFucJJfAvGs4rNA9IdX6Lu/1cW1OkDiGlB5Fcz9l6EXJSQZQgAyYSkvzP1IcI ag0++1bPcO6Cbl8qEcUuCGP/18U/tR/xtp6zInMwvzfx6N0yIiUI2eU X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= X-Patchwork-Delegate: kuba@kernel.org The sysfs core now allows instances of 'struct bin_attribute' to be moved into read-only memory. Make use of that to protect them against accidental or malicious modifications. Signed-off-by: Thomas Weißschuh Reviewed-by: Simon Horman Acked-by: Nikolay Aleksandrov --- net/bridge/br_sysfs_br.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c index ea733542244c7e7feeffef3c993404529ba88559..c1176a5e02c43ce32cb3dc152e9aa08eb535a419 100644 --- a/net/bridge/br_sysfs_br.c +++ b/net/bridge/br_sysfs_br.c @@ -1002,7 +1002,7 @@ static const struct attribute_group bridge_group = { * Returns the number of bytes read. */ static ssize_t brforward_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct device *dev = kobj_to_dev(kobj); @@ -1023,10 +1023,10 @@ static ssize_t brforward_read(struct file *filp, struct kobject *kobj, return n; } -static struct bin_attribute bridge_forward = { +static const struct bin_attribute bridge_forward = { .attr = { .name = SYSFS_BRIDGE_FDB, .mode = 0444, }, - .read = brforward_read, + .read_new = brforward_read, }; /* From patchwork Mon Dec 16 11:30:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13909578 X-Patchwork-Delegate: kuba@kernel.org Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 030E220459A; Mon, 16 Dec 2024 11:30:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734348613; cv=none; b=qjFQWJDvQBdh73QqDlmqOan2INrAOruI6BEmPD5HwkwfQ5GIGDovMy2UqmlGxpcJkzw8NNn65SCKfCPnqMHYYccf31HcUWlocATo8HIp9Hi73oORiQLPg5CTtav07gWP7+NDKtBXOxRxHVELWSpnlw25Nwtj/3HpJ39e0mM46O0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734348613; c=relaxed/simple; bh=Vlj4Bzk6QHgRqF8zYsvEUfDWI8hKCPW8mB6sHzcz4fE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZG5RMa8LzalXJRZEdogFsAfZSYeZ5L2shZGJ1qujFhH9Kh/SeOgXsxpPt5+QB4TsRzeSWIMCCWL4hrDC9fn4h/4I95bh2Cl4tPZK/8i2RY/N9EEF3WaUbqA5sqUAT6c/xhJMSWU3lTy4PnBnXrqj5SBXM92xyuq+Lecbiaz20vA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=Zl78iIUy; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="Zl78iIUy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734348609; bh=Vlj4Bzk6QHgRqF8zYsvEUfDWI8hKCPW8mB6sHzcz4fE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Zl78iIUy2kM4i/AZURTEexE+j65gyMzsUe7LqSVXoQeXojVMFUOPFy7xxnjJhzoqE avBOSIFRdUuo/JXKkbJkNuoYCFYhfeUWNJve9fMpz1RkPdX+zQ4tcvmAlb9zbDCZA8 +HBAPRA9ADxy3/QmWsXM3BlCFpp+F/e8hDibnyV0= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 16 Dec 2024 12:30:09 +0100 Subject: [PATCH net-next 2/5] net: phy: ks8995: constify 'struct bin_attribute' Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241216-sysfs-const-bin_attr-net-v1-2-ec460b91f274@weissschuh.net> References: <20241216-sysfs-const-bin_attr-net-v1-0-ec460b91f274@weissschuh.net> In-Reply-To: <20241216-sysfs-const-bin_attr-net-v1-0-ec460b91f274@weissschuh.net> To: Roopa Prabhu , Nikolay Aleksandrov , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn , Heiner Kallweit , Russell King , Kalle Valo , Manish Chopra , Rahul Verma , GR-Linux-NIC-Dev@marvell.com, Andrew Lunn , Shahed Shaikh Cc: bridge@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, =?utf-8?q?Th?= =?utf-8?q?omas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734348609; l=1744; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=Vlj4Bzk6QHgRqF8zYsvEUfDWI8hKCPW8mB6sHzcz4fE=; b=Dmpso/XTYKpV8ZglwkBLBxSLfKQ/6cMDmBLx+OYY1D4CliYs3tn86ImJEi+9LWSRaky0CZZiU EyPXtCIzFyIDuwiN+tdsJLDVYbbkCqc+E+66tuVrJbzsEKuZJPa+Bfq X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= X-Patchwork-Delegate: kuba@kernel.org The sysfs core now allows instances of 'struct bin_attribute' to be moved into read-only memory. Make use of that to protect them against accidental or malicious modifications. Signed-off-by: Thomas Weißschuh Reviewed-by: Andrew Lunn --- drivers/net/phy/spi_ks8995.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/spi_ks8995.c b/drivers/net/phy/spi_ks8995.c index 7196e927c2cd8bd73ef2492260182d48daac19ef..076a370be849e00c57a3be0bbce83c4665c49593 100644 --- a/drivers/net/phy/spi_ks8995.c +++ b/drivers/net/phy/spi_ks8995.c @@ -289,7 +289,7 @@ static int ks8995_reset(struct ks8995_switch *ks) } static ssize_t ks8995_registers_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct device *dev; struct ks8995_switch *ks8995; @@ -301,7 +301,7 @@ static ssize_t ks8995_registers_read(struct file *filp, struct kobject *kobj, } static ssize_t ks8995_registers_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { struct device *dev; struct ks8995_switch *ks8995; @@ -401,8 +401,8 @@ static const struct bin_attribute ks8995_registers_attr = { .mode = 0600, }, .size = KS8995_REGS_SIZE, - .read = ks8995_registers_read, - .write = ks8995_registers_write, + .read_new = ks8995_registers_read, + .write_new = ks8995_registers_write, }; /* ------------------------------------------------------------------------ */ From patchwork Mon Dec 16 11:30:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13909581 X-Patchwork-Delegate: kuba@kernel.org Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82C8E204F90; Mon, 16 Dec 2024 11:30:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734348616; cv=none; b=BVPKHoAsgqsPvcSzxwoGK4XtBu/Z6Zy77ARIsdu8iWO7exO4uIXx0NFWRCoZ76uXvREMnMcTS3MFBlZye6crd6FnOWIJY4PP7DVh58i9SiYXJNPOU1phvdgJYa3GetFeXiVVCO1j4VHx2ibT2YeB5VN/3Gqc1y3JL61YbXhYllQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734348616; c=relaxed/simple; bh=sKafKTrf9LAdZ9BgdUJ967oC4MBmXTpZpAe5oxO1A/U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XWoLuI0AqOP+IJi/tGkYG9yOxvcbmDcZLRUaHFqE8v23CeKKe1juJkT993uRgelmKYAPXCjLmAEMihpLeV/WVOmIBX4+P7w3b0POXxjnzrEWexTDMjNavzlckEasJiYzPhlkjx6zSfGpmlc+K8Sy3Dyg7CvuSyp6vauKQCbYZ/k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=a/psRVI6; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="a/psRVI6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734348609; bh=sKafKTrf9LAdZ9BgdUJ967oC4MBmXTpZpAe5oxO1A/U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=a/psRVI6dOk0OUmnIK9Bsc5J9v32iRRIq90T3yw3Ny59IeNxuy7crSZH8GxtBRjl4 N/6kHom7mpZsVVf2cDizjbLqQd/nvKcSDr48FSAt2jQRpJJEEMNjDRzzoTYdRKiZMS lPGLesG/MQG0wBoDZFUt+l7adT7GW8g3WnSNDd4Q= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 16 Dec 2024 12:30:10 +0100 Subject: [PATCH net-next 3/5] wlcore: sysfs: constify 'struct bin_attribute' Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241216-sysfs-const-bin_attr-net-v1-3-ec460b91f274@weissschuh.net> References: <20241216-sysfs-const-bin_attr-net-v1-0-ec460b91f274@weissschuh.net> In-Reply-To: <20241216-sysfs-const-bin_attr-net-v1-0-ec460b91f274@weissschuh.net> To: Roopa Prabhu , Nikolay Aleksandrov , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn , Heiner Kallweit , Russell King , Kalle Valo , Manish Chopra , Rahul Verma , GR-Linux-NIC-Dev@marvell.com, Andrew Lunn , Shahed Shaikh Cc: bridge@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, =?utf-8?q?Th?= =?utf-8?q?omas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734348609; l=1358; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=sKafKTrf9LAdZ9BgdUJ967oC4MBmXTpZpAe5oxO1A/U=; b=gGkG+VPJm4mN0LELAZJKMBJ8ArdFEHk8sS8xi184dchQWntIgwDx/kZOUjOe5Mnj6yvFaFFxp AByBciprnLdB7xeNM1W2Q0cwD90cI26jJoekl7UUmV7lA169GNyzfsw X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= X-Patchwork-Delegate: kuba@kernel.org The sysfs core now allows instances of 'struct bin_attribute' to be moved into read-only memory. Make use of that to protect them against accidental or malicious modifications. Signed-off-by: Thomas Weißschuh --- drivers/net/wireless/ti/wlcore/sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ti/wlcore/sysfs.c b/drivers/net/wireless/ti/wlcore/sysfs.c index c07acfcbbd9c8179bd312840efda43e7e9c5e6a0..7c57d4c8744ad5d19f11c5765cc7bf27aadbf740 100644 --- a/drivers/net/wireless/ti/wlcore/sysfs.c +++ b/drivers/net/wireless/ti/wlcore/sysfs.c @@ -88,7 +88,7 @@ static ssize_t hw_pg_ver_show(struct device *dev, static DEVICE_ATTR_RO(hw_pg_ver); static ssize_t wl1271_sysfs_read_fwlog(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, + const struct bin_attribute *bin_attr, char *buffer, loff_t pos, size_t count) { struct device *dev = kobj_to_dev(kobj); @@ -121,7 +121,7 @@ static ssize_t wl1271_sysfs_read_fwlog(struct file *filp, struct kobject *kobj, static const struct bin_attribute fwlog_attr = { .attr = { .name = "fwlog", .mode = 0400 }, - .read = wl1271_sysfs_read_fwlog, + .read_new = wl1271_sysfs_read_fwlog, }; int wlcore_sysfs_init(struct wl1271 *wl) From patchwork Mon Dec 16 11:30:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13909577 X-Patchwork-Delegate: kuba@kernel.org Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C29F12036FB; Mon, 16 Dec 2024 11:30:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734348613; cv=none; b=emAIEJWJ20t/1+8cXvkrqCIpCpBJkcc+Aosv887XJzcolzLxQmrL8Bhb642mftjhva6YDQA9AwxjYZk+ha782eolLX5M6UAAM3MKcr6zK/jBBMu8r/3TtzTPpVQ5aQT7u2X22ifJ0qpXkEjoD9AMpMCO32X3gcE/IQJfTFLNerA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734348613; c=relaxed/simple; bh=LP0tcqhCQKDxykPnUl4J7/vxYNglPUyx52VJJRyK4Uw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Irh9jsC7FF/cxpoapHBBBMMcgJmKraZwqjsBbHLmXLNE/NAGyjzSlqQynHDUXb9LJ2SrymMG7rEKF+5uuhE6pOFv3ZxS/e1OnEC6KODVRcoZWl5hgFqEvwwoncdqLs0WAHEKwcYxXeIhAbs8QhIrAGjUnUaSf2a877sqq16uA4k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=s6aGcSZr; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="s6aGcSZr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734348609; bh=LP0tcqhCQKDxykPnUl4J7/vxYNglPUyx52VJJRyK4Uw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=s6aGcSZrGVqvDrQbcbiGF1LTadRWUQooaVWEpT+ahwjGvuGFl08mWKnUFEJcV7iI8 H/HRPKrgf9wdNTO632BGPRVlKfH5MngclkaVyE91WHP5Oo4EPfSadSdthSc00/0fbV 6lZLtLDLbjVnEeQnEetHrKOt+jHAamJZpXcWWXRY= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 16 Dec 2024 12:30:11 +0100 Subject: [PATCH net-next 4/5] netxen_nic: constify 'struct bin_attribute' Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241216-sysfs-const-bin_attr-net-v1-4-ec460b91f274@weissschuh.net> References: <20241216-sysfs-const-bin_attr-net-v1-0-ec460b91f274@weissschuh.net> In-Reply-To: <20241216-sysfs-const-bin_attr-net-v1-0-ec460b91f274@weissschuh.net> To: Roopa Prabhu , Nikolay Aleksandrov , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn , Heiner Kallweit , Russell King , Kalle Valo , Manish Chopra , Rahul Verma , GR-Linux-NIC-Dev@marvell.com, Andrew Lunn , Shahed Shaikh Cc: bridge@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, =?utf-8?q?Th?= =?utf-8?q?omas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734348609; l=3257; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=LP0tcqhCQKDxykPnUl4J7/vxYNglPUyx52VJJRyK4Uw=; b=xrUP4dfP++DJeELPTbe/WudLHPR9ilyLrf3xKiItMg7i9sug99xl0qxBV6r7A6pa8evklD6BY zTxM6pprabHBolgCpV9RuWhhlN+Lv9RVEowSNER9XN3ojFBBeKUSjQY X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= X-Patchwork-Delegate: kuba@kernel.org The sysfs core now allows instances of 'struct bin_attribute' to be moved into read-only memory. Make use of that to protect them against accidental or malicious modifications. Signed-off-by: Thomas Weißschuh Reviewed-by: Simon Horman --- drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c index 9cff0a8ffb2c55de195983051e4e7f8568528c0f..3383ee1dad14e2cb40062b27f32a7cffb6f3fac2 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c @@ -2832,7 +2832,7 @@ netxen_sysfs_validate_crb(struct netxen_adapter *adapter, static ssize_t netxen_sysfs_read_crb(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, + const struct bin_attribute *attr, char *buf, loff_t offset, size_t size) { struct device *dev = kobj_to_dev(kobj); @@ -2860,7 +2860,7 @@ netxen_sysfs_read_crb(struct file *filp, struct kobject *kobj, static ssize_t netxen_sysfs_write_crb(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, + const struct bin_attribute *attr, char *buf, loff_t offset, size_t size) { struct device *dev = kobj_to_dev(kobj); @@ -2901,7 +2901,7 @@ netxen_sysfs_validate_mem(struct netxen_adapter *adapter, static ssize_t netxen_sysfs_read_mem(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, + const struct bin_attribute *attr, char *buf, loff_t offset, size_t size) { struct device *dev = kobj_to_dev(kobj); @@ -2922,7 +2922,7 @@ netxen_sysfs_read_mem(struct file *filp, struct kobject *kobj, } static ssize_t netxen_sysfs_write_mem(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, char *buf, + const struct bin_attribute *attr, char *buf, loff_t offset, size_t size) { struct device *dev = kobj_to_dev(kobj); @@ -2946,20 +2946,20 @@ static ssize_t netxen_sysfs_write_mem(struct file *filp, struct kobject *kobj, static const struct bin_attribute bin_attr_crb = { .attr = { .name = "crb", .mode = 0644 }, .size = 0, - .read = netxen_sysfs_read_crb, - .write = netxen_sysfs_write_crb, + .read_new = netxen_sysfs_read_crb, + .write_new = netxen_sysfs_write_crb, }; static const struct bin_attribute bin_attr_mem = { .attr = { .name = "mem", .mode = 0644 }, .size = 0, - .read = netxen_sysfs_read_mem, - .write = netxen_sysfs_write_mem, + .read_new = netxen_sysfs_read_mem, + .write_new = netxen_sysfs_write_mem, }; static ssize_t netxen_sysfs_read_dimm(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, + const struct bin_attribute *attr, char *buf, loff_t offset, size_t size) { struct device *dev = kobj_to_dev(kobj); @@ -3082,7 +3082,7 @@ netxen_sysfs_read_dimm(struct file *filp, struct kobject *kobj, static const struct bin_attribute bin_attr_dimm = { .attr = { .name = "dimm", .mode = 0644 }, .size = sizeof(struct netxen_dimm_cfg), - .read = netxen_sysfs_read_dimm, + .read_new = netxen_sysfs_read_dimm, }; From patchwork Mon Dec 16 11:30:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13909579 X-Patchwork-Delegate: kuba@kernel.org Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C5E720458D; Mon, 16 Dec 2024 11:30:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734348614; cv=none; b=eLCHdBQK50itYHkAM2Q15JXeLBbENdpYtQfedSZO8XYZTpyHgcuct3HeoJwK9+1UytdZrTh8X79FV3XyuxFFwYoFioKwaj/aaUoWZ81VF7Q8TbYs0vuQSSXlRHCfse1WYDC/wF3cwXccjLzER/p0ZPr2oQmPWnjw+b9zuP1+FYc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734348614; c=relaxed/simple; bh=4lfzZN5KkAJ2v/7q6O8dM4kEUYnGJIO7Kjt5/WsPqHE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GfJP+bqD9UlkerIZXuC+4sqBbIDi/eyCCgw0c+bn2Ba0hjUy44NGNTI+uBrBmEx81ANsn1fsI9mrk+U0Us7j4z+2jch8cCBgzjxlXVeSaFbeNxUDTqEpivwA2hqLTOB7wp+jwPLkI9G3hxNsR3/m37g5MUYakCgevp7inbLPHqg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=XLON3cxu; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="XLON3cxu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1734348610; bh=4lfzZN5KkAJ2v/7q6O8dM4kEUYnGJIO7Kjt5/WsPqHE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XLON3cxu3FaY+o31XZ0xn7TlD7hbB3VnMtQ1PRgW37NHMhRs8CaNa+HXFqERuhNmc 2v8FMnog2OQ8T5x5W2tWkwDcbkQXpNe4AEeQh6Al13pQOznKZwTOil/kcf3pHkT9v/ e0eogBk4S3H7sZE93vLLnYi+HThfiW+nNX4CtIrk= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 16 Dec 2024 12:30:12 +0100 Subject: [PATCH net-next 5/5] qlcnic: constify 'struct bin_attribute' Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241216-sysfs-const-bin_attr-net-v1-5-ec460b91f274@weissschuh.net> References: <20241216-sysfs-const-bin_attr-net-v1-0-ec460b91f274@weissschuh.net> In-Reply-To: <20241216-sysfs-const-bin_attr-net-v1-0-ec460b91f274@weissschuh.net> To: Roopa Prabhu , Nikolay Aleksandrov , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn , Heiner Kallweit , Russell King , Kalle Valo , Manish Chopra , Rahul Verma , GR-Linux-NIC-Dev@marvell.com, Andrew Lunn , Shahed Shaikh Cc: bridge@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, =?utf-8?q?Th?= =?utf-8?q?omas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734348609; l=9387; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=4lfzZN5KkAJ2v/7q6O8dM4kEUYnGJIO7Kjt5/WsPqHE=; b=T8yR+XsxXRIz+8QU8/PV0YFo+3DvCYwiwBv7Kig360NLswQicPGNHnpkOUgBVFm7NBdkcnVEl YlpbwyaLUAEC/KGwj5SiS6LakzzAKo94Bc8sSuYsJU+AIYQ7ft6tfRj X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= X-Patchwork-Delegate: kuba@kernel.org The sysfs core now allows instances of 'struct bin_attribute' to be moved into read-only memory. Make use of that to protect them against accidental or malicious modifications. Signed-off-by: Thomas Weißschuh Reviewed-by: Simon Horman --- drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c | 70 +++++++++++------------ 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c index 74125188beb82515f57a20ae24dcd526943d05ee..82c357865f19ba8f272426abc09f47b40d6b53da 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c @@ -264,7 +264,7 @@ static int qlcnic_sysfs_validate_crb(struct qlcnic_adapter *adapter, } static ssize_t qlcnic_sysfs_read_crb(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, char *buf, + const struct bin_attribute *attr, char *buf, loff_t offset, size_t size) { struct device *dev = kobj_to_dev(kobj); @@ -281,7 +281,7 @@ static ssize_t qlcnic_sysfs_read_crb(struct file *filp, struct kobject *kobj, } static ssize_t qlcnic_sysfs_write_crb(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, char *buf, + const struct bin_attribute *attr, char *buf, loff_t offset, size_t size) { struct device *dev = kobj_to_dev(kobj); @@ -310,7 +310,7 @@ static int qlcnic_sysfs_validate_mem(struct qlcnic_adapter *adapter, } static ssize_t qlcnic_sysfs_read_mem(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, char *buf, + const struct bin_attribute *attr, char *buf, loff_t offset, size_t size) { struct device *dev = kobj_to_dev(kobj); @@ -332,7 +332,7 @@ static ssize_t qlcnic_sysfs_read_mem(struct file *filp, struct kobject *kobj, } static ssize_t qlcnic_sysfs_write_mem(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, char *buf, + const struct bin_attribute *attr, char *buf, loff_t offset, size_t size) { struct device *dev = kobj_to_dev(kobj); @@ -396,7 +396,7 @@ static int validate_pm_config(struct qlcnic_adapter *adapter, static ssize_t qlcnic_sysfs_write_pm_config(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, + const struct bin_attribute *attr, char *buf, loff_t offset, size_t size) { @@ -446,7 +446,7 @@ static ssize_t qlcnic_sysfs_write_pm_config(struct file *filp, static ssize_t qlcnic_sysfs_read_pm_config(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, + const struct bin_attribute *attr, char *buf, loff_t offset, size_t size) { @@ -539,7 +539,7 @@ static int validate_esw_config(struct qlcnic_adapter *adapter, static ssize_t qlcnic_sysfs_write_esw_config(struct file *file, struct kobject *kobj, - struct bin_attribute *attr, + const struct bin_attribute *attr, char *buf, loff_t offset, size_t size) { @@ -623,7 +623,7 @@ static ssize_t qlcnic_sysfs_write_esw_config(struct file *file, static ssize_t qlcnic_sysfs_read_esw_config(struct file *file, struct kobject *kobj, - struct bin_attribute *attr, + const struct bin_attribute *attr, char *buf, loff_t offset, size_t size) { @@ -675,7 +675,7 @@ static int validate_npar_config(struct qlcnic_adapter *adapter, static ssize_t qlcnic_sysfs_write_npar_config(struct file *file, struct kobject *kobj, - struct bin_attribute *attr, + const struct bin_attribute *attr, char *buf, loff_t offset, size_t size) { @@ -722,7 +722,7 @@ static ssize_t qlcnic_sysfs_write_npar_config(struct file *file, static ssize_t qlcnic_sysfs_read_npar_config(struct file *file, struct kobject *kobj, - struct bin_attribute *attr, + const struct bin_attribute *attr, char *buf, loff_t offset, size_t size) { @@ -769,7 +769,7 @@ static ssize_t qlcnic_sysfs_read_npar_config(struct file *file, static ssize_t qlcnic_sysfs_get_port_stats(struct file *file, struct kobject *kobj, - struct bin_attribute *attr, + const struct bin_attribute *attr, char *buf, loff_t offset, size_t size) { @@ -804,7 +804,7 @@ static ssize_t qlcnic_sysfs_get_port_stats(struct file *file, static ssize_t qlcnic_sysfs_get_esw_stats(struct file *file, struct kobject *kobj, - struct bin_attribute *attr, + const struct bin_attribute *attr, char *buf, loff_t offset, size_t size) { @@ -839,7 +839,7 @@ static ssize_t qlcnic_sysfs_get_esw_stats(struct file *file, static ssize_t qlcnic_sysfs_clear_esw_stats(struct file *file, struct kobject *kobj, - struct bin_attribute *attr, + const struct bin_attribute *attr, char *buf, loff_t offset, size_t size) { @@ -868,7 +868,7 @@ static ssize_t qlcnic_sysfs_clear_esw_stats(struct file *file, static ssize_t qlcnic_sysfs_clear_port_stats(struct file *file, struct kobject *kobj, - struct bin_attribute *attr, + const struct bin_attribute *attr, char *buf, loff_t offset, size_t size) { @@ -898,7 +898,7 @@ static ssize_t qlcnic_sysfs_clear_port_stats(struct file *file, static ssize_t qlcnic_sysfs_read_pci_config(struct file *file, struct kobject *kobj, - struct bin_attribute *attr, + const struct bin_attribute *attr, char *buf, loff_t offset, size_t size) { @@ -938,7 +938,7 @@ static ssize_t qlcnic_sysfs_read_pci_config(struct file *file, static ssize_t qlcnic_83xx_sysfs_flash_read_handler(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, + const struct bin_attribute *attr, char *buf, loff_t offset, size_t size) { @@ -1115,7 +1115,7 @@ static int qlcnic_83xx_sysfs_flash_write(struct qlcnic_adapter *adapter, static ssize_t qlcnic_83xx_sysfs_flash_write_handler(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, + const struct bin_attribute *attr, char *buf, loff_t offset, size_t size) { @@ -1195,64 +1195,64 @@ static const struct device_attribute dev_attr_beacon = { static const struct bin_attribute bin_attr_crb = { .attr = { .name = "crb", .mode = 0644 }, .size = 0, - .read = qlcnic_sysfs_read_crb, - .write = qlcnic_sysfs_write_crb, + .read_new = qlcnic_sysfs_read_crb, + .write_new = qlcnic_sysfs_write_crb, }; static const struct bin_attribute bin_attr_mem = { .attr = { .name = "mem", .mode = 0644 }, .size = 0, - .read = qlcnic_sysfs_read_mem, - .write = qlcnic_sysfs_write_mem, + .read_new = qlcnic_sysfs_read_mem, + .write_new = qlcnic_sysfs_write_mem, }; static const struct bin_attribute bin_attr_npar_config = { .attr = { .name = "npar_config", .mode = 0644 }, .size = 0, - .read = qlcnic_sysfs_read_npar_config, - .write = qlcnic_sysfs_write_npar_config, + .read_new = qlcnic_sysfs_read_npar_config, + .write_new = qlcnic_sysfs_write_npar_config, }; static const struct bin_attribute bin_attr_pci_config = { .attr = { .name = "pci_config", .mode = 0644 }, .size = 0, - .read = qlcnic_sysfs_read_pci_config, - .write = NULL, + .read_new = qlcnic_sysfs_read_pci_config, + .write_new = NULL, }; static const struct bin_attribute bin_attr_port_stats = { .attr = { .name = "port_stats", .mode = 0644 }, .size = 0, - .read = qlcnic_sysfs_get_port_stats, - .write = qlcnic_sysfs_clear_port_stats, + .read_new = qlcnic_sysfs_get_port_stats, + .write_new = qlcnic_sysfs_clear_port_stats, }; static const struct bin_attribute bin_attr_esw_stats = { .attr = { .name = "esw_stats", .mode = 0644 }, .size = 0, - .read = qlcnic_sysfs_get_esw_stats, - .write = qlcnic_sysfs_clear_esw_stats, + .read_new = qlcnic_sysfs_get_esw_stats, + .write_new = qlcnic_sysfs_clear_esw_stats, }; static const struct bin_attribute bin_attr_esw_config = { .attr = { .name = "esw_config", .mode = 0644 }, .size = 0, - .read = qlcnic_sysfs_read_esw_config, - .write = qlcnic_sysfs_write_esw_config, + .read_new = qlcnic_sysfs_read_esw_config, + .write_new = qlcnic_sysfs_write_esw_config, }; static const struct bin_attribute bin_attr_pm_config = { .attr = { .name = "pm_config", .mode = 0644 }, .size = 0, - .read = qlcnic_sysfs_read_pm_config, - .write = qlcnic_sysfs_write_pm_config, + .read_new = qlcnic_sysfs_read_pm_config, + .write_new = qlcnic_sysfs_write_pm_config, }; static const struct bin_attribute bin_attr_flash = { .attr = { .name = "flash", .mode = 0644 }, .size = 0, - .read = qlcnic_83xx_sysfs_flash_read_handler, - .write = qlcnic_83xx_sysfs_flash_write_handler, + .read_new = qlcnic_83xx_sysfs_flash_read_handler, + .write_new = qlcnic_83xx_sysfs_flash_write_handler, }; #ifdef CONFIG_QLCNIC_HWMON