Merge lp:~swem/ubuntu/trusty/lshw/lp1471983 into lp:ubuntu/trusty-proposed/lshw

Proposed by Chen-Han Hsiao (Stanley)
Status: Needs review
Proposed branch: lp:~swem/ubuntu/trusty/lshw/lp1471983
Merge into: lp:ubuntu/trusty-proposed/lshw
Diff against target: 184 lines (+159/-0)
4 files modified
debian/changelog (+7/-0)
debian/patches/presumably-fix-653.patch (+30/-0)
debian/patches/series (+2/-0)
debian/patches/use-a-different-approach-for-scanning-SCSI-generic-d.patch (+120/-0)
To merge this branch: bzr merge lp:~swem/ubuntu/trusty/lshw/lp1471983
Reviewer Review Type Date Requested Status
Marc Deslauriers Needs Fixing
Review via email: mp+270012@code.launchpad.net

Description of the change

For bug 1471983, I also encounter this issue in Ubuntu OEM project.

This bug is fixed in https://github.com/lyonel/lshw/commit/d048d300b5daeb44887a7fc06ddeb120119cac8a

The issue in upstream: [lshw segfaults, with some 16GB USB-3 sticks from Patriot] http://www.ezix.org/project/ticket/653

I've made a patch to fix it.

To post a comment you must log in.
Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

Hi, thanks for the debdiff!

Two comments:

1- Could you please list both patches in the changelog along with a small description of what they accomplish?
2- While the "use-a-different-approach-for-scanning-SCSI-generic-d.patch" change seems to be included in 2.17 currently in vivid and wily, the "presumably-fix-653.patch" change is not. Could you please prepare debdiffs for Vivid and Wily?

Thanks!

review: Needs Fixing
Revision history for this message
Chen-Han Hsiao (Stanley) (swem) wrote :

@mdeslaur, thanks for review.

1. There are two patches added. I would add this description to changelog.

   [d048d30] presumably-fix-653.patch is for this segmentation fault issue.

   [b79f299] use-a-different-approach-for-scanning-SCSI-generic-d.patch use different approach to scan scsi devices to cover general devices. The functionality is the same. This patch need to be applied before d048d30.

2. I will add debdiff for vivid and wily

33. By Chen-Han Hsiao (Stanley)

* [d048d30] Fix lshw crash issue on system with some USB-3 sticks (LP: #1471983)
* [b79f299] Use different approach for scanning SCSI generic devices.

Unmerged revisions

33. By Chen-Han Hsiao (Stanley)

* [d048d30] Fix lshw crash issue on system with some USB-3 sticks (LP: #1471983)
* [b79f299] Use different approach for scanning SCSI generic devices.

32. By Chen-Han Hsiao (Stanley)

Fix lshw crash issue on system with some USB-3 sticks (LP: #1471983)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2015-08-28 15:00:23 +0000
3+++ debian/changelog 2015-10-06 02:29:16 +0000
4@@ -1,3 +1,10 @@
5+lshw (02.16-2ubuntu1.4) trusty-proposed; urgency=medium
6+
7+ * [d048d30] Fix lshw crash issue on system with some USB-3 sticks (LP: #1471983)
8+ * [b79f299] Use different approach for scanning SCSI generic devices.
9+
10+ -- Chen-Han Hsiao (Stanley) <stanley.hsiao@canonical.com> Wed, 19 Aug 2015 11:58:11 +0800
11+
12 lshw (02.16-2ubuntu1.3) trusty-proposed; urgency=medium
13
14 * Backport cpuinfo support for aarch64 (LP: #1485086)
15
16=== added file 'debian/patches/presumably-fix-653.patch'
17--- debian/patches/presumably-fix-653.patch 1970-01-01 00:00:00 +0000
18+++ debian/patches/presumably-fix-653.patch 2015-10-06 02:29:16 +0000
19@@ -0,0 +1,30 @@
20+From d048d300b5daeb44887a7fc06ddeb120119cac8a Mon Sep 17 00:00:00 2001
21+From: Lyonel Vincent <lyonel@ezix.org>
22+Date: Sun, 13 Jul 2014 11:21:59 +0000
23+Subject: [PATCH] (presumably) fix #653
24+
25+git-svn-id: http://ezix.org/source/packages/lshw/development@2535 811e2811-9fd9-0310-a116-b6e8ac943c8b
26+---
27+ src/core/scsi.cc | 6 +++---
28+ 1 file changed, 3 insertions(+), 3 deletions(-)
29+
30+diff --git a/src/core/scsi.cc b/src/core/scsi.cc
31+index ed059cb..d85fcc8 100644
32+--- a/src/core/scsi.cc
33++++ b/src/core/scsi.cc
34+@@ -481,9 +481,9 @@ hwNode & node)
35+ memset(rsp_buff, 0, sizeof(rsp_buff));
36+ if (do_inq(sg_fd, 0, 1, 0x80, rsp_buff, MX_ALLOC_LEN, 0))
37+ {
38+- len = rsp_buff[3];
39+- if (len > 0)
40+- node.setSerial(hw::strip(string(rsp_buff + 4, len)));
41++ char _len = rsp_buff[3];
42++ if (_len > 0)
43++ node.setSerial(hw::strip(string(rsp_buff + 4, _len)));
44+ }
45+
46+ memset(rsp_buff, 0, sizeof(rsp_buff));
47+--
48+1.9.1
49+
50
51=== modified file 'debian/patches/series'
52--- debian/patches/series 2015-08-28 15:00:23 +0000
53+++ debian/patches/series 2015-10-06 02:29:16 +0000
54@@ -17,3 +17,5 @@
55 ddr3-device-tree-support.patch
56 Do-not-brutally-merge-NICs-in-the-same-PCI-function-.patch
57 cpuinfo-arm-aarch64-support.patch
58+presumably-fix-653.patch
59+use-a-different-approach-for-scanning-SCSI-generic-d.patch
60
61=== added file 'debian/patches/use-a-different-approach-for-scanning-SCSI-generic-d.patch'
62--- debian/patches/use-a-different-approach-for-scanning-SCSI-generic-d.patch 1970-01-01 00:00:00 +0000
63+++ debian/patches/use-a-different-approach-for-scanning-SCSI-generic-d.patch 2015-10-06 02:29:16 +0000
64@@ -0,0 +1,120 @@
65+From b79f299319f61bc80e8d38e61631cfee7521a729 Mon Sep 17 00:00:00 2001
66+From: lyonel <lyonel@811e2811-9fd9-0310-a116-b6e8ac943c8b>
67+Date: Wed, 13 Mar 2013 20:52:25 +0000
68+Subject: [PATCH] use a different approach for scanning SCSI generic devices
69+ (`/dev/sg*`) to fix #541 (thanks to Wayne Boyer)
70+
71+git-svn-id: http://ezix.org/source/packages/lshw/development@2518 811e2811-9fd9-0310-a116-b6e8ac943c8b
72+---
73+ src/core/scsi.cc | 45 ++++++++++++++++++++++++---------------------
74+ 1 file changed, 24 insertions(+), 21 deletions(-)
75+
76+diff --git a/src/core/scsi.cc b/src/core/scsi.cc
77+index 926ae06..ed059cb 100644
78+--- a/src/core/scsi.cc
79++++ b/src/core/scsi.cc
80+@@ -29,7 +29,7 @@
81+
82+ __ID("@(#) $Id$");
83+
84+-#define SG_X "/dev/sg%d"
85++#define SG_X "/dev/sg*"
86+ #define SG_MAJOR 21
87+
88+ #ifndef SCSI_IOCTL_GET_PCI
89+@@ -653,10 +653,9 @@ static bool atapi(const hwNode & n)
90+ }
91+
92+
93+-static bool scan_sg(int sg,
94+-hwNode & n)
95++static void scan_sg(hwNode & n)
96+ {
97+- char buffer[20];
98++ int sg;
99+ int fd = -1;
100+ My_sg_scsi_id m_id;
101+ char slot_name[64]; // should be 16 but some 2.6 kernels require 32 bytes
102+@@ -665,22 +664,30 @@ hwNode & n)
103+ hwNode *parent = NULL;
104+ int emulated = 0;
105+ bool ghostdeventry = false;
106++ size_t j;
107++ glob_t entries;
108+
109+- snprintf(buffer, sizeof(buffer), SG_X, sg);
110++ if(glob(SG_X, 0, NULL, &entries) == 0)
111++ {
112++ for(j=0; j < entries.gl_pathc; j++)
113++ {
114++ sg = strtol(strpbrk(entries.gl_pathv[j], "0123456789"), NULL, 10);
115+
116+- ghostdeventry = !exists(buffer);
117++ ghostdeventry = !exists(entries.gl_pathv[j]);
118+
119+- if(ghostdeventry) mknod(buffer, (S_IFCHR | S_IREAD), MKDEV(SG_MAJOR, sg));
120+- fd = open(buffer, OPEN_FLAG | O_NONBLOCK);
121+- if(ghostdeventry) unlink(buffer);
122++ if(ghostdeventry)
123++ mknod(entries.gl_pathv[j], (S_IFCHR | S_IREAD), MKDEV(SG_MAJOR, sg));
124++ fd = open(entries.gl_pathv[j], OPEN_FLAG | O_NONBLOCK);
125++ if(ghostdeventry)
126++ unlink(entries.gl_pathv[j]);
127+ if (fd < 0)
128+- return false;
129++ continue;
130+
131+ memset(&m_id, 0, sizeof(m_id));
132+ if (ioctl(fd, SG_GET_SCSI_ID, &m_id) < 0)
133+ {
134+ close(fd);
135+- return true; // we failed to get info but still hope we can continue
136++ continue; // we failed to get info but still hope we can continue
137+ }
138+
139+ emulated = 0;
140+@@ -773,11 +780,8 @@ hwNode & n)
141+ if (!parent)
142+ parent = n.addChild(hwNode("scsi", hw::storage));
143+
144+- if (!parent)
145++ if (parent)
146+ {
147+- close(fd);
148+- return true;
149+- }
150+
151+ if(parent->getBusInfo() == "")
152+ parent->setBusInfo(guessBusInfo(hw::strip(slot_name)));
153+@@ -789,10 +793,12 @@ hwNode & n)
154+ parent->addCapability("emulated", "Emulated device");
155+ }
156+ parent->addChild(device);
157++ }
158+
159+ close(fd);
160+-
161+- return true;
162++ }
163++ globfree(&entries);
164++ }
165+ }
166+
167+
168+@@ -889,12 +895,9 @@ static bool scan_hosts(hwNode & node)
169+
170+ bool scan_scsi(hwNode & n)
171+ {
172+- int i = 0;
173+-
174+ scan_devices();
175+
176+- while (scan_sg(i, n))
177+- i++;
178++ scan_sg(n);
179+
180+ scan_hosts(n);
181+
182+--
183+1.9.1
184+

Subscribers

People subscribed via source and target branches