* [PATCH v5 0/3] net: tulip: add checks to avoid OOB access
@ 2020-03-19 17:40 P J P
2020-03-19 17:40 ` [PATCH v5 1/3] net: tulip: check frame size and r/w data length P J P
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: P J P @ 2020-03-19 17:40 UTC (permalink / raw)
To: Jason Wang
Cc: Prasad J Pandit, Stefan Hajnoczi, Sven Schnelle, Qemu Developers,
Li Qiang, Philippe Mathieu-Daudé,
Ziming Zhang
From: Prasad J Pandit <pjp@fedoraproject.org>
Hello,
* This series adds checks to avoid potential OOB access and infinite loop
issues while processing rx/tx data.
* Tulip tx descriptors are capped at 128 to avoid infinite loop in
tulip_xmit_list_update(), wrt Tulip kernel driver
-> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/dec/tulip/tulip.h#n319
* Update v3: add .can_receive routine
-> https://lists.gnu.org/archive/html/qemu-devel/2020-02/msg06275.html
* Update v4: flush queued packets once they are received
-> https://lists.gnu.org/archive/html/qemu-devel/2020-03/msg05868.html
* Update v5: fixed a typo in patch commit message
-> https://lists.gnu.org/archive/html/qemu-devel/2020-03/msg06209.html
Thank you.
--
Prasad J Pandit (3):
net: tulip: check frame size and r/w data length
net: tulip: add .can_receive routine
net: tulip: flush queued packets post receive
hw/net/tulip.c | 51 +++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 42 insertions(+), 9 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v5 1/3] net: tulip: check frame size and r/w data length
2020-03-19 17:40 [PATCH v5 0/3] net: tulip: add checks to avoid OOB access P J P
@ 2020-03-19 17:40 ` P J P
2020-03-19 17:40 ` [PATCH v5 2/3] net: tulip: add .can_receive routine P J P
` (2 subsequent siblings)
3 siblings, 0 replies; 12+ messages in thread
From: P J P @ 2020-03-19 17:40 UTC (permalink / raw)
To: Jason Wang
Cc: Prasad J Pandit, Stefan Hajnoczi, Sven Schnelle, Qemu Developers,
Li Qiang, Philippe Mathieu-Daudé,
Ziming Zhang
From: Prasad J Pandit <pjp@fedoraproject.org>
Tulip network driver while copying tx/rx buffers does not check
frame size against r/w data length. This may lead to OOB buffer
access. Add check to avoid it.
Limit iterations over descriptors to avoid potential infinite
loop issue in tulip_xmit_list_update.
Reported-by: Li Qiang <pangpei.lq@antfin.com>
Reported-by: Ziming Zhang <ezrakiez@gmail.com>
Reported-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
hw/net/tulip.c | 36 +++++++++++++++++++++++++++---------
1 file changed, 27 insertions(+), 9 deletions(-)
Update v3: return a value from tulip_copy_tx_buffers() and avoid infinite loop
-> https://lists.gnu.org/archive/html/qemu-devel/2020-02/msg06275.html
diff --git a/hw/net/tulip.c b/hw/net/tulip.c
index cfac2719d3..fbe40095da 100644
--- a/hw/net/tulip.c
+++ b/hw/net/tulip.c
@@ -170,6 +170,10 @@ static void tulip_copy_rx_bytes(TULIPState *s, struct tulip_descriptor *desc)
} else {
len = s->rx_frame_len;
}
+
+ if (s->rx_frame_len + len >= sizeof(s->rx_frame)) {
+ return;
+ }
pci_dma_write(&s->dev, desc->buf_addr1, s->rx_frame +
(s->rx_frame_size - s->rx_frame_len), len);
s->rx_frame_len -= len;
@@ -181,6 +185,10 @@ static void tulip_copy_rx_bytes(TULIPState *s, struct tulip_descriptor *desc)
} else {
len = s->rx_frame_len;
}
+
+ if (s->rx_frame_len + len >= sizeof(s->rx_frame)) {
+ return;
+ }
pci_dma_write(&s->dev, desc->buf_addr2, s->rx_frame +
(s->rx_frame_size - s->rx_frame_len), len);
s->rx_frame_len -= len;
@@ -227,7 +235,8 @@ static ssize_t tulip_receive(TULIPState *s, const uint8_t *buf, size_t size)
trace_tulip_receive(buf, size);
- if (size < 14 || size > 2048 || s->rx_frame_len || tulip_rx_stopped(s)) {
+ if (size < 14 || size > sizeof(s->rx_frame) - 4
+ || s->rx_frame_len || tulip_rx_stopped(s)) {
return 0;
}
@@ -275,7 +284,6 @@ static ssize_t tulip_receive_nc(NetClientState *nc,
return tulip_receive(qemu_get_nic_opaque(nc), buf, size);
}
-
static NetClientInfo net_tulip_info = {
.type = NET_CLIENT_DRIVER_NIC,
.size = sizeof(NICState),
@@ -558,7 +566,7 @@ static void tulip_tx(TULIPState *s, struct tulip_descriptor *desc)
if ((s->csr[6] >> CSR6_OM_SHIFT) & CSR6_OM_MASK) {
/* Internal or external Loopback */
tulip_receive(s, s->tx_frame, s->tx_frame_len);
- } else {
+ } else if (s->tx_frame_len <= sizeof(s->tx_frame)) {
qemu_send_packet(qemu_get_queue(s->nic),
s->tx_frame, s->tx_frame_len);
}
@@ -570,23 +578,31 @@ static void tulip_tx(TULIPState *s, struct tulip_descriptor *desc)
}
}
-static void tulip_copy_tx_buffers(TULIPState *s, struct tulip_descriptor *desc)
+static int tulip_copy_tx_buffers(TULIPState *s, struct tulip_descriptor *desc)
{
int len1 = (desc->control >> TDES1_BUF1_SIZE_SHIFT) & TDES1_BUF1_SIZE_MASK;
int len2 = (desc->control >> TDES1_BUF2_SIZE_SHIFT) & TDES1_BUF2_SIZE_MASK;
+ if (s->tx_frame_len + len1 >= sizeof(s->tx_frame)) {
+ return -1;
+ }
if (len1) {
pci_dma_read(&s->dev, desc->buf_addr1,
s->tx_frame + s->tx_frame_len, len1);
s->tx_frame_len += len1;
}
+ if (s->tx_frame_len + len2 >= sizeof(s->tx_frame)) {
+ return -1;
+ }
if (len2) {
pci_dma_read(&s->dev, desc->buf_addr2,
s->tx_frame + s->tx_frame_len, len2);
s->tx_frame_len += len2;
}
desc->status = (len1 + len2) ? 0 : 0x7fffffff;
+
+ return 0;
}
static void tulip_setup_filter_addr(TULIPState *s, uint8_t *buf, int n)
@@ -651,13 +667,15 @@ static uint32_t tulip_ts(TULIPState *s)
static void tulip_xmit_list_update(TULIPState *s)
{
+#define TULIP_DESC_MAX 128
+ uint8_t i = 0;
struct tulip_descriptor desc;
if (tulip_ts(s) != CSR5_TS_SUSPENDED) {
return;
}
- for (;;) {
+ for (i = 0; i < TULIP_DESC_MAX; i++) {
tulip_desc_read(s, s->current_tx_desc, &desc);
tulip_dump_tx_descriptor(s, &desc);
@@ -675,10 +693,10 @@ static void tulip_xmit_list_update(TULIPState *s)
s->tx_frame_len = 0;
}
- tulip_copy_tx_buffers(s, &desc);
-
- if (desc.control & TDES1_LS) {
- tulip_tx(s, &desc);
+ if (!tulip_copy_tx_buffers(s, &desc)) {
+ if (desc.control & TDES1_LS) {
+ tulip_tx(s, &desc);
+ }
}
}
tulip_desc_write(s, s->current_tx_desc, &desc);
--
2.25.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v5 2/3] net: tulip: add .can_receive routine
2020-03-19 17:40 [PATCH v5 0/3] net: tulip: add checks to avoid OOB access P J P
2020-03-19 17:40 ` [PATCH v5 1/3] net: tulip: check frame size and r/w data length P J P
@ 2020-03-19 17:40 ` P J P
2020-03-19 19:10 ` Philippe Mathieu-Daudé
2020-03-19 17:40 ` [PATCH v5 3/3] net: tulip: flush queued packets post receive P J P
2020-03-23 3:43 ` [PATCH v5 0/3] net: tulip: add checks to avoid OOB access Jason Wang
3 siblings, 1 reply; 12+ messages in thread
From: P J P @ 2020-03-19 17:40 UTC (permalink / raw)
To: Jason Wang
Cc: Prasad J Pandit, Stefan Hajnoczi, Sven Schnelle, Qemu Developers,
Li Qiang, Philippe Mathieu-Daudé,
Ziming Zhang
From: Prasad J Pandit <pjp@fedoraproject.org>
Define .can_receive routine to do sanity checks before receiving
packet data.
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
hw/net/tulip.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
Update v3: define .can_receive routine
-> https://lists.gnu.org/archive/html/qemu-devel/2020-02/msg06275.html
Update v5: fix a typo in commit log message
-> https://lists.gnu.org/archive/html/qemu-devel/2020-03/msg06209.html
diff --git a/hw/net/tulip.c b/hw/net/tulip.c
index fbe40095da..757f12c710 100644
--- a/hw/net/tulip.c
+++ b/hw/net/tulip.c
@@ -229,6 +229,18 @@ static bool tulip_filter_address(TULIPState *s, const uint8_t *addr)
return ret;
}
+static int
+tulip_can_receive(NetClientState *nc)
+{
+ TULIPState *s = qemu_get_nic_opaque(nc);
+
+ if (s->rx_frame_len || tulip_rx_stopped(s)) {
+ return false;
+ }
+
+ return true;
+}
+
static ssize_t tulip_receive(TULIPState *s, const uint8_t *buf, size_t size)
{
struct tulip_descriptor desc;
@@ -236,7 +248,7 @@ static ssize_t tulip_receive(TULIPState *s, const uint8_t *buf, size_t size)
trace_tulip_receive(buf, size);
if (size < 14 || size > sizeof(s->rx_frame) - 4
- || s->rx_frame_len || tulip_rx_stopped(s)) {
+ || !tulip_can_receive(s->nic->ncs)) {
return 0;
}
@@ -288,6 +300,7 @@ static NetClientInfo net_tulip_info = {
.type = NET_CLIENT_DRIVER_NIC,
.size = sizeof(NICState),
.receive = tulip_receive_nc,
+ .can_receive = tulip_can_receive,
};
static const char *tulip_reg_name(const hwaddr addr)
--
2.25.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v5 3/3] net: tulip: flush queued packets post receive
2020-03-19 17:40 [PATCH v5 0/3] net: tulip: add checks to avoid OOB access P J P
2020-03-19 17:40 ` [PATCH v5 1/3] net: tulip: check frame size and r/w data length P J P
2020-03-19 17:40 ` [PATCH v5 2/3] net: tulip: add .can_receive routine P J P
@ 2020-03-19 17:40 ` P J P
2020-03-23 3:43 ` [PATCH v5 0/3] net: tulip: add checks to avoid OOB access Jason Wang
3 siblings, 0 replies; 12+ messages in thread
From: P J P @ 2020-03-19 17:40 UTC (permalink / raw)
To: Jason Wang
Cc: Prasad J Pandit, Stefan Hajnoczi, Sven Schnelle, Qemu Developers,
Li Qiang, Philippe Mathieu-Daudé,
Ziming Zhang
From: Prasad J Pandit <pjp@fedoraproject.org>
Call qemu_flush_queued_packets to flush queued packets once they
are read in tulip_receive().
Suggested-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
hw/net/tulip.c | 2 ++
1 file changed, 2 insertions(+)
Update v4: call qemu_flush_queued_packets()
-> https://lists.gnu.org/archive/html/qemu-devel/2020-03/msg05868.html
diff --git a/hw/net/tulip.c b/hw/net/tulip.c
index 757f12c710..8d8c9519e7 100644
--- a/hw/net/tulip.c
+++ b/hw/net/tulip.c
@@ -287,6 +287,8 @@ static ssize_t tulip_receive(TULIPState *s, const uint8_t *buf, size_t size)
tulip_desc_write(s, s->current_rx_desc, &desc);
tulip_next_rx_descriptor(s, &desc);
} while (s->rx_frame_len);
+
+ qemu_flush_queued_packets(qemu_get_queue(s->nic));
return size;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v5 2/3] net: tulip: add .can_receive routine
2020-03-19 17:40 ` [PATCH v5 2/3] net: tulip: add .can_receive routine P J P
@ 2020-03-19 19:10 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-19 19:10 UTC (permalink / raw)
To: P J P, Jason Wang
Cc: Prasad J Pandit, Stefan Hajnoczi, Qemu Developers, Li Qiang,
Sven Schnelle, Ziming Zhang
On 3/19/20 6:40 PM, P J P wrote:
> From: Prasad J Pandit <pjp@fedoraproject.org>
>
> Define .can_receive routine to do sanity checks before receiving
> packet data.
>
> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
> ---
> hw/net/tulip.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> Update v3: define .can_receive routine
> -> https://lists.gnu.org/archive/html/qemu-devel/2020-02/msg06275.html
>
> Update v5: fix a typo in commit log message
> -> https://lists.gnu.org/archive/html/qemu-devel/2020-03/msg06209.html
>
> diff --git a/hw/net/tulip.c b/hw/net/tulip.c
> index fbe40095da..757f12c710 100644
> --- a/hw/net/tulip.c
> +++ b/hw/net/tulip.c
> @@ -229,6 +229,18 @@ static bool tulip_filter_address(TULIPState *s, const uint8_t *addr)
> return ret;
> }
>
> +static int
> +tulip_can_receive(NetClientState *nc)
> +{
> + TULIPState *s = qemu_get_nic_opaque(nc);
> +
> + if (s->rx_frame_len || tulip_rx_stopped(s)) {
> + return false;
> + }
> +
> + return true;
> +}
> +
> static ssize_t tulip_receive(TULIPState *s, const uint8_t *buf, size_t size)
> {
> struct tulip_descriptor desc;
> @@ -236,7 +248,7 @@ static ssize_t tulip_receive(TULIPState *s, const uint8_t *buf, size_t size)
> trace_tulip_receive(buf, size);
>
> if (size < 14 || size > sizeof(s->rx_frame) - 4
> - || s->rx_frame_len || tulip_rx_stopped(s)) {
> + || !tulip_can_receive(s->nic->ncs)) {
> return 0;
> }
>
> @@ -288,6 +300,7 @@ static NetClientInfo net_tulip_info = {
> .type = NET_CLIENT_DRIVER_NIC,
> .size = sizeof(NICState),
> .receive = tulip_receive_nc,
> + .can_receive = tulip_can_receive,
> };
>
> static const char *tulip_reg_name(const hwaddr addr)
>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v5 0/3] net: tulip: add checks to avoid OOB access
2020-03-19 17:40 [PATCH v5 0/3] net: tulip: add checks to avoid OOB access P J P
` (2 preceding siblings ...)
2020-03-19 17:40 ` [PATCH v5 3/3] net: tulip: flush queued packets post receive P J P
@ 2020-03-23 3:43 ` Jason Wang
2020-03-23 3:56 ` Jason Wang
2020-03-23 6:00 ` Li Qiang
3 siblings, 2 replies; 12+ messages in thread
From: Jason Wang @ 2020-03-23 3:43 UTC (permalink / raw)
To: P J P, Li Qiang
Cc: Prasad J Pandit, Stefan Hajnoczi, Sven Schnelle, Qemu Developers,
Philippe Mathieu-Daudé,
Ziming Zhang
On 2020/3/20 上午1:40, P J P wrote:
> From: Prasad J Pandit <pjp@fedoraproject.org>
>
> Hello,
>
> * This series adds checks to avoid potential OOB access and infinite loop
> issues while processing rx/tx data.
>
> * Tulip tx descriptors are capped at 128 to avoid infinite loop in
> tulip_xmit_list_update(), wrt Tulip kernel driver
> -> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/dec/tulip/tulip.h#n319
>
> * Update v3: add .can_receive routine
> -> https://lists.gnu.org/archive/html/qemu-devel/2020-02/msg06275.html
>
> * Update v4: flush queued packets once they are received
> -> https://lists.gnu.org/archive/html/qemu-devel/2020-03/msg05868.html
>
> * Update v5: fixed a typo in patch commit message
> -> https://lists.gnu.org/archive/html/qemu-devel/2020-03/msg06209.html
>
> Thank you.
Looks good to me.
Qiang, any change to give a test with your reproducer?
Thanks
> --
> Prasad J Pandit (3):
> net: tulip: check frame size and r/w data length
> net: tulip: add .can_receive routine
> net: tulip: flush queued packets post receive
>
> hw/net/tulip.c | 51 +++++++++++++++++++++++++++++++++++++++++---------
> 1 file changed, 42 insertions(+), 9 deletions(-)
>
> --
> 2.25.1
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v5 0/3] net: tulip: add checks to avoid OOB access
2020-03-23 3:43 ` [PATCH v5 0/3] net: tulip: add checks to avoid OOB access Jason Wang
@ 2020-03-23 3:56 ` Jason Wang
2020-03-23 4:40 ` P J P
2020-03-23 12:24 ` P J P
2020-03-23 6:00 ` Li Qiang
1 sibling, 2 replies; 12+ messages in thread
From: Jason Wang @ 2020-03-23 3:56 UTC (permalink / raw)
To: P J P, Li Qiang
Cc: Prasad J Pandit, Stefan Hajnoczi, Sven Schnelle, Qemu Developers,
Philippe Mathieu-Daudé,
Ziming Zhang
On 2020/3/23 上午11:43, Jason Wang wrote:
>
> On 2020/3/20 上午1:40, P J P wrote:
>> From: Prasad J Pandit <pjp@fedoraproject.org>
>>
>> Hello,
>>
>> * This series adds checks to avoid potential OOB access and infinite
>> loop
>> issues while processing rx/tx data.
>>
>> * Tulip tx descriptors are capped at 128 to avoid infinite loop in
>> tulip_xmit_list_update(), wrt Tulip kernel driver
>> ->
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/dec/tulip/tulip.h#n319
>>
>> * Update v3: add .can_receive routine
>> ->
>> https://lists.gnu.org/archive/html/qemu-devel/2020-02/msg06275.html
>>
>> * Update v4: flush queued packets once they are received
>> ->
>> https://lists.gnu.org/archive/html/qemu-devel/2020-03/msg05868.html
>>
>> * Update v5: fixed a typo in patch commit message
>> ->
>> https://lists.gnu.org/archive/html/qemu-devel/2020-03/msg06209.html
>>
>> Thank you.
>
>
> Looks good to me.
>
> Qiang, any change to give a test with your reproducer?
>
> Thanks
Ok, I get this:
hw/net/tulip.c:305:20: error: initialization of ‘_Bool
(*)(NetClientState *)’ {aka ‘_Bool (*)(struct NetClientState *)’} from
incompatible pointer type ‘int (*)(NetClientState *)’ {aka ‘int
(*)(struct NetClientState *)’} [-Werror=incompatible-pointer-types]
.can_receive = tulip_can_receive,
^~~~~~~~~~~~~~~~~
Prasad, please fix this and post a new version.
While at it, I prefer to squash patch 3 into patch 2 since patch 3 fixes
the issue introduced by patch 2.
Thanks
>
>
>> --
>> Prasad J Pandit (3):
>> net: tulip: check frame size and r/w data length
>> net: tulip: add .can_receive routine
>> net: tulip: flush queued packets post receive
>>
>> hw/net/tulip.c | 51 +++++++++++++++++++++++++++++++++++++++++---------
>> 1 file changed, 42 insertions(+), 9 deletions(-)
>>
>> --
>> 2.25.1
>>
>>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v5 0/3] net: tulip: add checks to avoid OOB access
2020-03-23 3:56 ` Jason Wang
@ 2020-03-23 4:40 ` P J P
2020-03-23 5:40 ` P J P
2020-03-23 12:24 ` P J P
1 sibling, 1 reply; 12+ messages in thread
From: P J P @ 2020-03-23 4:40 UTC (permalink / raw)
To: Jason Wang
Cc: Sven Schnelle, Qemu Developers, Stefan Hajnoczi, Li Qiang,
Philippe Mathieu-Daudé,
Ziming Zhang
[-- Attachment #1: Type: text/plain, Size: 789 bytes --]
+-- On Mon, 23 Mar 2020, Jason Wang wrote --+
| hw/net/tulip.c:305:20: error: initialization of ‘_Bool (*)(NetClientState *)’
| {aka ‘_Bool (*)(struct NetClientState *)’} from incompatible pointer type ‘int
| (*)(NetClientState *)’ {aka ‘int (*)(struct NetClientState *)’}
| [-Werror=incompatible-pointer-types]
| .can_receive = tulip_can_receive,
| ^~~~~~~~~~~~~~~~~
Strange, I did not get it.
| Prasad, please fix this and post a new version.
|
| While at it, I prefer to squash patch 3 into patch 2 since patch 3 fixes the
| issue introduced by patch 2.
Okay, sending your way shortly.
Thank you.
--
Prasad J Pandit / Red Hat Product Security Team
8685 545E B54C 486B C6EB 271E E285 8B5A F050 DE8D
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v5 0/3] net: tulip: add checks to avoid OOB access
2020-03-23 4:40 ` P J P
@ 2020-03-23 5:40 ` P J P
2020-03-23 10:28 ` Jason Wang
0 siblings, 1 reply; 12+ messages in thread
From: P J P @ 2020-03-23 5:40 UTC (permalink / raw)
To: Jason Wang
Cc: Sven Schnelle, Qemu Developers, Stefan Hajnoczi, Li Qiang,
Philippe Mathieu-Daudé,
Ziming Zhang
[-- Attachment #1: Type: text/plain, Size: 1425 bytes --]
+-- On Mon, 23 Mar 2020, P J P wrote --+
| +-- On Mon, 23 Mar 2020, Jason Wang wrote --+
| | hw/net/tulip.c:305:20: error: initialization of ‘_Bool (*)(NetClientState *)’
| | {aka ‘_Bool (*)(struct NetClientState *)’} from incompatible pointer type ‘int
| | (*)(NetClientState *)’ {aka ‘int (*)(struct NetClientState *)’}
| | [-Werror=incompatible-pointer-types]
| | .can_receive = tulip_can_receive,
| | ^~~~~~~~~~~~~~~~~
|
| Strange, I did not get it.
qemu/include/net.h:
typedef int (NetCanReceive)(NetClientState *);
typedef struct NetClientInfo {
...
NetCanReceive *can_receive;
...
}
@Jason,
Looking at the definition above, 'NetCanReceive' is returning an 'int' type.
When I change 'tulip_can_receive' to return a 'bool', I get the reverse error
hw/net/tulip.c:305:20: error: initialization of ‘int (*)(NetClientState *)’ {aka ‘int (*)(struct NetClientState *)’} from incompatible pointer type ‘_Bool (*)(NetClientState *)’ {aka ‘_Bool (*)(struct NetClientState *)’}
[-Werror=incompatible-pointer-types]
305 | .can_receive = tulip_can_receive,
| ^~~~~~~~~~~~~~~~~
Maybe because of a stagged local change in your tree? (to confirm)
Thank you.
--
Prasad J Pandit / Red Hat Product Security Team
8685 545E B54C 486B C6EB 271E E285 8B5A F050 DE8D
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v5 0/3] net: tulip: add checks to avoid OOB access
2020-03-23 3:43 ` [PATCH v5 0/3] net: tulip: add checks to avoid OOB access Jason Wang
2020-03-23 3:56 ` Jason Wang
@ 2020-03-23 6:00 ` Li Qiang
1 sibling, 0 replies; 12+ messages in thread
From: Li Qiang @ 2020-03-23 6:00 UTC (permalink / raw)
To: Jason Wang
Cc: Prasad J Pandit, Stefan Hajnoczi, Philippe Mathieu-Daudé,
Qemu Developers, P J P, Li Qiang, Sven Schnelle, Ziming Zhang
[-- Attachment #1: Type: text/plain, Size: 1661 bytes --]
Jason Wang <jasowang@redhat.com> 于2020年3月23日周一 上午11:44写道:
>
> On 2020/3/20 上午1:40, P J P wrote:
> > From: Prasad J Pandit <pjp@fedoraproject.org>
> >
> > Hello,
> >
> > * This series adds checks to avoid potential OOB access and infinite loop
> > issues while processing rx/tx data.
> >
> > * Tulip tx descriptors are capped at 128 to avoid infinite loop in
> > tulip_xmit_list_update(), wrt Tulip kernel driver
> > ->
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/dec/tulip/tulip.h#n319
> >
> > * Update v3: add .can_receive routine
> > ->
> https://lists.gnu.org/archive/html/qemu-devel/2020-02/msg06275.html
> >
> > * Update v4: flush queued packets once they are received
> > ->
> https://lists.gnu.org/archive/html/qemu-devel/2020-03/msg05868.html
> >
> > * Update v5: fixed a typo in patch commit message
> > ->
> https://lists.gnu.org/archive/html/qemu-devel/2020-03/msg06209.html
> >
> > Thank you.
>
>
> Looks good to me.
>
> Qiang, any change to give a test with your reproducer?
>
>
Hi Jason,
Sorry for missing discussing this thread as so busy these days/weeks.
I will try to test this patch asap.
Thanks,
Li Qiang
> Thanks
>
>
> > --
> > Prasad J Pandit (3):
> > net: tulip: check frame size and r/w data length
> > net: tulip: add .can_receive routine
> > net: tulip: flush queued packets post receive
> >
> > hw/net/tulip.c | 51 +++++++++++++++++++++++++++++++++++++++++---------
> > 1 file changed, 42 insertions(+), 9 deletions(-)
> >
> > --
> > 2.25.1
> >
> >
>
>
>
[-- Attachment #2: Type: text/html, Size: 3010 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v5 0/3] net: tulip: add checks to avoid OOB access
2020-03-23 5:40 ` P J P
@ 2020-03-23 10:28 ` Jason Wang
0 siblings, 0 replies; 12+ messages in thread
From: Jason Wang @ 2020-03-23 10:28 UTC (permalink / raw)
To: P J P
Cc: Stefan Hajnoczi, Sven Schnelle, Qemu Developers, Li Qiang,
Philippe Mathieu-Daudé,
Ziming Zhang
On 2020/3/23 下午1:40, P J P wrote:
> +-- On Mon, 23 Mar 2020, P J P wrote --+
> | +-- On Mon, 23 Mar 2020, Jason Wang wrote --+
> | | hw/net/tulip.c:305:20: error: initialization of ‘_Bool (*)(NetClientState *)’
> | | {aka ‘_Bool (*)(struct NetClientState *)’} from incompatible pointer type ‘int
> | | (*)(NetClientState *)’ {aka ‘int (*)(struct NetClientState *)’}
> | | [-Werror=incompatible-pointer-types]
> | | .can_receive = tulip_can_receive,
> | | ^~~~~~~~~~~~~~~~~
> |
> | Strange, I did not get it.
>
> qemu/include/net.h:
>
> typedef int (NetCanReceive)(NetClientState *);
>
> typedef struct NetClientInfo {
> ...
> NetCanReceive *can_receive;
> ...
> }
>
> @Jason,
> Looking at the definition above, 'NetCanReceive' is returning an 'int' type.
> When I change 'tulip_can_receive' to return a 'bool', I get the reverse error
>
> hw/net/tulip.c:305:20: error: initialization of ‘int (*)(NetClientState *)’ {aka ‘int (*)(struct NetClientState *)’} from incompatible pointer type ‘_Bool (*)(NetClientState *)’ {aka ‘_Bool (*)(struct NetClientState *)’}
> [-Werror=incompatible-pointer-types]
> 305 | .can_receive = tulip_can_receive,
> | ^~~~~~~~~~~~~~~~~
>
> Maybe because of a stagged local change in your tree? (to confirm)
Right, it's the conversion from int to bool done by Philippe :)
I will fix the conflict after Qiang tests it.
Thanks
>
> Thank you.
> --
> Prasad J Pandit / Red Hat Product Security Team
> 8685 545E B54C 486B C6EB 271E E285 8B5A F050 DE8D
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v5 0/3] net: tulip: add checks to avoid OOB access
2020-03-23 3:56 ` Jason Wang
2020-03-23 4:40 ` P J P
@ 2020-03-23 12:24 ` P J P
1 sibling, 0 replies; 12+ messages in thread
From: P J P @ 2020-03-23 12:24 UTC (permalink / raw)
To: Jason Wang
Cc: Sven Schnelle, Qemu Developers, Stefan Hajnoczi, Li Qiang,
Philippe Mathieu-Daudé,
Ziming Zhang
+-- On Mon, 23 Mar 2020, Jason Wang wrote --+
| Prasad, please fix this and post a new version.
|
| While at it, I prefer to squash patch 3 into patch 2 since patch 3 fixes the
| issue introduced by patch 2.
Sent patch v6.
Thank you.
--
Prasad J Pandit / Red Hat Product Security Team
8685 545E B54C 486B C6EB 271E E285 8B5A F050 DE8D
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2020-03-23 12:28 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-19 17:40 [PATCH v5 0/3] net: tulip: add checks to avoid OOB access P J P
2020-03-19 17:40 ` [PATCH v5 1/3] net: tulip: check frame size and r/w data length P J P
2020-03-19 17:40 ` [PATCH v5 2/3] net: tulip: add .can_receive routine P J P
2020-03-19 19:10 ` Philippe Mathieu-Daudé
2020-03-19 17:40 ` [PATCH v5 3/3] net: tulip: flush queued packets post receive P J P
2020-03-23 3:43 ` [PATCH v5 0/3] net: tulip: add checks to avoid OOB access Jason Wang
2020-03-23 3:56 ` Jason Wang
2020-03-23 4:40 ` P J P
2020-03-23 5:40 ` P J P
2020-03-23 10:28 ` Jason Wang
2020-03-23 12:24 ` P J P
2020-03-23 6:00 ` Li Qiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).