lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Date:   Tue, 7 Nov 2017 16:02:32 +0100
From:   SF Markus Elfring <elfring@...rs.sourceforge.net>
To:     netdev@...r.kernel.org, "David S. Miller" <davem@...emloft.net>,
        Dmitry Tarnyagin <dmitry.tarnyagin@...kless.no>,
        Sjur Braendeland <sjur.brandeland@...ricsson.com>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        kernel-janitors@...r.kernel.org
Subject: [PATCH RFC v1] caif: Use common error handling code in
 cfdgml_receive()

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Tue, 7 Nov 2017 11:30:25 +0100

* Adjust jump targets so that a bit of exception handling can be better
  reused at the end of this function.

* Adjust two condition checks.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---

v1 - Request for comments:
I can offer another bit of information for a software development discussion. ๐Ÿ’ญ

The affected source file can be compiled for the processor architecture โ€œx86_64โ€
by a tool like โ€œGCC 6.4.1+r251631-1.3โ€ from the software distribution
โ€œopenSUSE Tumbleweedโ€ with the following command example.

my_cc=/usr/bin/gcc-6 \
&& my_module=net/caif/cfdgml.o \
&& for XYZ in 0 s 3; do echo "   _____ $XYZ _____" \
&& my_extra="-O$XYZ" \
&& git checkout next-20171102 \
&& make -j4 CC="${my_cc}" HOSTCC="${my_cc}" EXTRA_CFLAGS="${my_extra}" allmodconfig "${my_module}" \
&& size "${my_module}" \
&& git checkout ':/^caif: Use common error handling code in cfdgml_receive' \
&& make -j4 CC="${my_cc}" HOSTCC="${my_cc}" EXTRA_CFLAGS="${my_extra}" allmodconfig "${my_module}" \
&& size "${my_module}"; done


๐Ÿ”ฎ Do you find the following differences worth for further clarification?

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•—
โ•‘ setting โ”‚ text โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘   O0    โ”‚ -59  โ•‘
โ•‘   Os    โ”‚ +24  โ•‘
โ•‘   O3    โ”‚ +36  โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•


 net/caif/cfdgml.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/net/caif/cfdgml.c b/net/caif/cfdgml.c
index 3bdddb32d55a..cc7b2c944bb2 100644
--- a/net/caif/cfdgml.c
+++ b/net/caif/cfdgml.c
@@ -47,18 +47,13 @@ static int cfdgml_receive(struct cflayer *layr, struct cfpkt *pkt)
 	caif_assert(layr->receive != NULL);
 	caif_assert(layr->ctrlcmd != NULL);
 
-	if (cfpkt_extr_head(pkt, &cmd, 1) < 0) {
-		pr_err("Packet is erroneous!\n");
-		cfpkt_destroy(pkt);
-		return -EPROTO;
-	}
+	if (cfpkt_extr_head(pkt, &cmd, 1))
+		goto report_packet_failure;
 
 	if ((cmd & DGM_CMD_BIT) == 0) {
-		if (cfpkt_extr_head(pkt, &dgmhdr, 3) < 0) {
-			pr_err("Packet is erroneous!\n");
-			cfpkt_destroy(pkt);
-			return -EPROTO;
-		}
+		if (cfpkt_extr_head(pkt, &dgmhdr, 3))
+			goto report_packet_failure;
+
 		ret = layr->up->receive(layr->up, pkt);
 		return ret;
 	}
@@ -66,17 +61,23 @@ static int cfdgml_receive(struct cflayer *layr, struct cfpkt *pkt)
 	switch (cmd) {
 	case DGM_FLOW_OFF:	/* FLOW OFF */
 		layr->ctrlcmd(layr, CAIF_CTRLCMD_FLOW_OFF_IND, 0);
-		cfpkt_destroy(pkt);
-		return 0;
+		ret = 0;
+		goto destroy_packet;
 	case DGM_FLOW_ON:	/* FLOW ON */
 		layr->ctrlcmd(layr, CAIF_CTRLCMD_FLOW_ON_IND, 0);
-		cfpkt_destroy(pkt);
-		return 0;
+		ret = 0;
+		goto destroy_packet;
 	default:
-		cfpkt_destroy(pkt);
 		pr_info("Unknown datagram control %d (0x%x)\n", cmd, cmd);
-		return -EPROTO;
+		goto e_proto;
 	}
+report_packet_failure:
+	pr_err("Packet is erroneous!\n");
+e_proto:
+	ret = -EPROTO;
+destroy_packet:
+	cfpkt_destroy(pkt);
+	return ret;
 }
 
 static int cfdgml_transmit(struct cflayer *layr, struct cfpkt *pkt)
-- 
2.15.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ