diff --git a/core/linux-am33x/0001-add-lcd-cape-for-chiliboard.patch b/core/linux-am33x/0001-add-lcd-cape-for-chiliboard.patch index e2e834d0a..350df46b6 100644 --- a/core/linux-am33x/0001-add-lcd-cape-for-chiliboard.patch +++ b/core/linux-am33x/0001-add-lcd-cape-for-chiliboard.patch @@ -1,7 +1,7 @@ -From 81d5fffe14ccafa00b9ea82e4278f759651039ff Mon Sep 17 00:00:00 2001 +From 784abdd117ae0055f0a0207105ba15a5b12cf63d Mon Sep 17 00:00:00 2001 From: Mateusz Salamon Date: Fri, 20 May 2016 14:31:51 +0200 -Subject: [PATCH] add lcd cape for chiliboard +Subject: [PATCH 1/2] add lcd cape for chiliboard --- arch/arm/boot/dts/Makefile | 1 + @@ -10,10 +10,10 @@ Subject: [PATCH] add lcd cape for chiliboard create mode 100644 arch/arm/boot/dts/am335x-chiliboard-lcd.dts diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile -index 63c8f7d..d24887d 100644 +index 8c93312..ebe06e82b 100644 --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile -@@ -567,6 +567,7 @@ dtb-$(CONFIG_SOC_AM33XX) += \ +@@ -568,6 +568,7 @@ dtb-$(CONFIG_SOC_AM33XX) += \ am335x-boneblack-emmc-overlay.dtb \ am335x-bonegreen.dtb \ am335x-chiliboard.dtb \ @@ -171,5 +171,5 @@ index 0000000..bee7d42 + }; +}; -- -2.10.0 +2.10.2 diff --git a/core/linux-am33x/0002-packet-fix-race-condition-in-packet_set_ring.patch b/core/linux-am33x/0002-packet-fix-race-condition-in-packet_set_ring.patch new file mode 100644 index 000000000..f827b498e --- /dev/null +++ b/core/linux-am33x/0002-packet-fix-race-condition-in-packet_set_ring.patch @@ -0,0 +1,92 @@ +From 1892cd7d480b4553acb4dd64691f232f49899b49 Mon Sep 17 00:00:00 2001 +From: Philip Pettersson +Date: Wed, 30 Nov 2016 14:55:36 -0800 +Subject: [PATCH 2/2] packet: fix race condition in packet_set_ring + +When packet_set_ring creates a ring buffer it will initialize a +struct timer_list if the packet version is TPACKET_V3. This value +can then be raced by a different thread calling setsockopt to +set the version to TPACKET_V1 before packet_set_ring has finished. + +This leads to a use-after-free on a function pointer in the +struct timer_list when the socket is closed as the previously +initialized timer will not be deleted. + +The bug is fixed by taking lock_sock(sk) in packet_setsockopt when +changing the packet version while also taking the lock at the start +of packet_set_ring. + +Fixes: f6fb8f100b80 ("af-packet: TPACKET_V3 flexible buffer implementation.") +Signed-off-by: Philip Pettersson +Signed-off-by: Eric Dumazet +Signed-off-by: David S. Miller +--- + net/packet/af_packet.c | 18 ++++++++++++------ + 1 file changed, 12 insertions(+), 6 deletions(-) + +diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c +index 260adb1..f6a703b 100644 +--- a/net/packet/af_packet.c ++++ b/net/packet/af_packet.c +@@ -3649,19 +3649,25 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv + + if (optlen != sizeof(val)) + return -EINVAL; +- if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) +- return -EBUSY; + if (copy_from_user(&val, optval, sizeof(val))) + return -EFAULT; + switch (val) { + case TPACKET_V1: + case TPACKET_V2: + case TPACKET_V3: +- po->tp_version = val; +- return 0; ++ break; + default: + return -EINVAL; + } ++ lock_sock(sk); ++ if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) { ++ ret = -EBUSY; ++ } else { ++ po->tp_version = val; ++ ret = 0; ++ } ++ release_sock(sk); ++ return ret; + } + case PACKET_RESERVE: + { +@@ -4165,6 +4171,7 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, + /* Added to avoid minimal code churn */ + struct tpacket_req *req = &req_u->req; + ++ lock_sock(sk); + /* Opening a Tx-ring is NOT supported in TPACKET_V3 */ + if (!closing && tx_ring && (po->tp_version > TPACKET_V2)) { + net_warn_ratelimited("Tx-ring is not supported.\n"); +@@ -4246,7 +4253,6 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, + goto out; + } + +- lock_sock(sk); + + /* Detach socket from network */ + spin_lock(&po->bind_lock); +@@ -4295,11 +4301,11 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, + if (!tx_ring) + prb_shutdown_retire_blk_timer(po, rb_queue); + } +- release_sock(sk); + + if (pg_vec) + free_pg_vec(pg_vec, order, req->tp_block_nr); + out: ++ release_sock(sk); + return err; + } + +-- +2.10.2 + diff --git a/core/linux-am33x/PKGBUILD b/core/linux-am33x/PKGBUILD index d7f3f152c..1dff8c330 100644 --- a/core/linux-am33x/PKGBUILD +++ b/core/linux-am33x/PKGBUILD @@ -8,7 +8,7 @@ _srcname=linux-4.8 _kernelname=${pkgbase#linux} _desc="TI AM335x Beaglebone (Black)" pkgver=4.8.12 -pkgrel=1 +pkgrel=2 rcnrel=bone2 arch=('armv7h') url="http://www.kernel.org/" @@ -20,12 +20,14 @@ source=("http://www.kernel.org/pub/linux/kernel/v4.x/${_srcname}.tar.xz" "http://rcn-ee.com/deb/sid-armhf/v${pkgver}-${rcnrel}/patch-${pkgver%.0}-${rcnrel}.diff.gz" "git+https://github.com/RobertCNelson/bb.org-overlays.git" '0001-add-lcd-cape-for-chiliboard.patch' + '0002-packet-fix-race-condition-in-packet_set_ring.patch' 'config') md5sums=('c1af0afbd3df35c1ccdc7a5118cd2d07' '9a938fd7a82d8b390f957657947fe673' 'fcb94c25866d1b44cbb279ae358e0eef' 'SKIP' - '0cd56301c128f5ea412ab41bed00dabc' + '8739df9e5a282194b1da69ce21e98934' + 'e1f71b0b82181899e1a8a73dff3695e6' '17a3edfc858c1d8def25e92df95be825') prepare() { @@ -39,6 +41,7 @@ prepare() { # ALARM patches git apply ../0001-add-lcd-cape-for-chiliboard.patch + git apply ../0002-packet-fix-race-condition-in-packet_set_ring.patch cat "${srcdir}/config" > ./.config