Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1205657 > unrolled thread
| Started by | Su Kang Yin <cantona@cantona.net> |
|---|---|
| First post | 2015-08-12 09:30 +0200 |
| Last post | 2015-08-12 17:20 +0200 |
| Articles | 4 — 4 participants |
Back to article view | Back to linux.kernel
[PATCH v2] serial: max310x: Fix out of bounds access Su Kang Yin <cantona@cantona.net> - 2015-08-12 09:30 +0200
Re: [PATCH v2] serial: max310x: Fix out of bounds access Alexander Shiyan <shc_work@mail.ru> - 2015-08-12 12:40 +0200
Re: [PATCH v2] serial: max310x: Fix out of bounds access Kang Yin Su <cantona@cantona.net> - 2015-08-12 14:00 +0200
Re: [PATCH v2] serial: max310x: Fix out of bounds access Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-08-12 17:20 +0200
| From | Su Kang Yin <cantona@cantona.net> |
|---|---|
| Date | 2015-08-12 09:30 +0200 |
| Subject | [PATCH v2] serial: max310x: Fix out of bounds access |
| Message-ID | <pWyE1-5X6-7@gated-at.bofh.it> |
Max310x driver supports up to 4 UART devices but array size of
"struct max310x_one" is set to 1. That leads to out of bounds
access on UART port registration.
This patch fixed it by increase the array size to 4 which is
maximum supported UART.
Signed-off-by: Su Kang Yin <cantona@cantona.net>
---
v2: add Signed-off-by: line.
drivers/tty/serial/max310x.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index 182549f..b523552 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -33,6 +33,9 @@
#define MAX310X_MAJOR 204
#define MAX310X_MINOR 209
+/* Maximum supported device */
+#define MAX_DEVICE 4
+
/* MAX310X register definitions */
#define MAX310X_RHR_REG (0x00) /* RX FIFO */
#define MAX310X_THR_REG (0x00) /* TX FIFO */
@@ -273,7 +276,7 @@ struct max310x_port {
#ifdef CONFIG_GPIOLIB
struct gpio_chip gpio;
#endif
- struct max310x_one p[0];
+ struct max310x_one p[MAX_DEVICE];
};
static u8 max310x_port_read(struct uart_port *port, u8 reg)
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Alexander Shiyan <shc_work@mail.ru> |
|---|---|
| Date | 2015-08-12 12:40 +0200 |
| Message-ID | <pWBBU-1Ls-43@gated-at.bofh.it> |
| In reply to | #1205657 |
PiDQodGA0LXQtNCwLCAxMiDQsNCy0LPRg9GB0YLQsCAyMDE1LCAxNTozNiArMDg6MDAg0L7RgiBj YW50b25hIDxjYW50b25hQGNhbnRvbmEubmV0PjoKPiAKPiAKPiBhZGRlZCBBbGV4YW5kZXIgU2hp eWFuIDwgc2hjX3dvcmtAbWFpbC5ydSA+Lgo+IAo+IE9uIDEyIEF1Z3VzdCAyMDE1IGF0IDE1OjIy LCBTdSBLYW5nIFlpbiAgPCBjYW50b25hQGNhbnRvbmEubmV0ID4gd3JvdGU6Cj4gPk1heDMxMHgg ZHJpdmVyIHN1cHBvcnRzIHVwIHRvIDQgVUFSVCBkZXZpY2VzIGJ1dCBhcnJheSBzaXplIG9mCj4g PiJzdHJ1Y3QgbWF4MzEweF9vbmUiIGlzIHNldCB0byAxLiBUaGF0IGxlYWRzIHRvIG91dCBvZiBi b3VuZHMKPiA+YWNjZXNzIG9uIFVBUlQgcG9ydCByZWdpc3RyYXRpb24uCj4gPgo+ID5UaGlzIHBh dGNoIGZpeGVkIGl0IGJ5IGluY3JlYXNlIHRoZSBhcnJheSBzaXplIHRvIDQgd2hpY2ggaXMKPiA+ bWF4aW11bSBzdXBwb3J0ZWQgVUFSVC4KPiA+Cj4gPlNpZ25lZC1vZmYtYnk6IFN1IEthbmcgWWlu IDwgY2FudG9uYUBjYW50b25hLm5ldCA+Cj4gPi0tLQouLi4KClRoaXMgc2VlbXMgaW5jb3JyZWN0 LiBUaGUgbnVtYmVyIG9mIHBvcnRzIGlzIGFsbG9jYXRlZCBkeW5hbWljYWxseSBieToKLi4uCi8q IEFsbG9jIHBvcnQgc3RydWN0dXJlICovCnMgPSBkZXZtX2t6YWxsb2MoZGV2LCBzaXplb2YoKnMp ICsgc2l6ZW9mKHN0cnVjdCBtYXgzMTB4X29uZSkgKiBkZXZ0eXBlLT5uciwgR0ZQX0tFUk5FTCk7 Ci4uLgoKVGhhbmtzLgoKLS0tCgo= -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Kang Yin Su <cantona@cantona.net> |
|---|---|
| Date | 2015-08-12 14:00 +0200 |
| Message-ID | <pWCRk-3tG-33@gated-at.bofh.it> |
| In reply to | #1205931 |
On 12 August 2015 at 17:46, Alexander Shiyan <shc_work@mail.ru> wrote: >> Среда, 12 августа 2015, 15:36 +08:00 от cantona <cantona@cantona.net>: >> >> >> added Alexander Shiyan < shc_work@mail.ru >. >> >> On 12 August 2015 at 15:22, Su Kang Yin < cantona@cantona.net > wrote: >> >Max310x driver supports up to 4 UART devices but array size of >> >"struct max310x_one" is set to 1. That leads to out of bounds >> >access on UART port registration. >> > >> >This patch fixed it by increase the array size to 4 which is >> >maximum supported UART. >> > >> >Signed-off-by: Su Kang Yin < cantona@cantona.net > >> >--- > ... > > This seems incorrect. The number of ports is allocated dynamically by: > ... > /* Alloc port structure */ > s = devm_kzalloc(dev, sizeof(*s) + sizeof(struct max310x_one) * devtype->nr, GFP_KERNEL); > ... > > Thanks. > > --- > Oh, my bad. But it looks confusing. So we must ensure "struct max310x_one p[0]" must the last element of "struct max310x_port". Thanks. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2015-08-12 17:20 +0200 |
| Message-ID | <pWFYS-8aR-9@gated-at.bofh.it> |
| In reply to | #1205991 |
On Wed, Aug 12, 2015 at 07:50:25PM +0800, Kang Yin Su wrote: > On 12 August 2015 at 17:46, Alexander Shiyan <shc_work@mail.ru> wrote: > >> Среда, 12 августа 2015, 15:36 +08:00 от cantona <cantona@cantona.net>: > >> > >> > >> added Alexander Shiyan < shc_work@mail.ru >. > >> > >> On 12 August 2015 at 15:22, Su Kang Yin < cantona@cantona.net > wrote: > >> >Max310x driver supports up to 4 UART devices but array size of > >> >"struct max310x_one" is set to 1. That leads to out of bounds > >> >access on UART port registration. > >> > > >> >This patch fixed it by increase the array size to 4 which is > >> >maximum supported UART. > >> > > >> >Signed-off-by: Su Kang Yin < cantona@cantona.net > > >> >--- > > ... > > > > This seems incorrect. The number of ports is allocated dynamically by: > > ... > > /* Alloc port structure */ > > s = devm_kzalloc(dev, sizeof(*s) + sizeof(struct max310x_one) * devtype->nr, GFP_KERNEL); > > ... > > > > Thanks. > > > > --- > > > > > Oh, my bad. But it looks confusing. So we must ensure "struct > max310x_one p[0]" must the last element of "struct max310x_port". Yes, that is a very common pattern we use in the kernel. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web