From patchwork Sat Apr 23 17:37:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max X-Patchwork-Id: 614071 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by ozlabs.org (Postfix) with ESMTP id 3qsfpM4Nkwz9t3g for ; Sun, 24 Apr 2016 03:38:03 +1000 (AEST) Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id 38635136E3; Sat, 23 Apr 2016 17:38:01 +0000 (UTC) X-Original-To: openbsc@lists.osmocom.org Delivered-To: openbsc@lists.osmocom.org Received: from mail.sysmocom.de (mail.sysmocom.de [IPv6:2a01:4f8:191:444c::2:4]) by lists.osmocom.org (Postfix) with ESMTP id 1C391136DA for ; Sat, 23 Apr 2016 17:37:59 +0000 (UTC) Received: from mail.sysmocom.de (mail.sysmocom.de [144.76.43.93]) by mail.sysmocom.de (Postfix) with ESMTP id 7BC381B200E; Sat, 23 Apr 2016 17:37:59 +0000 (UTC) Received: from pbell.local (unknown [IPv6:2001:bf0:c001:30:d486:e0e6:e192:64d1]) by mail.sysmocom.de (Postfix) with ESMTPSA id 346F71B200D; Sat, 23 Apr 2016 17:37:59 +0000 (UTC) From: msuraev@sysmocom.de To: openbsc@lists.osmocom.org Subject: [PATCH] Fix unaligned access found by addr. sanitizer Date: Sat, 23 Apr 2016 19:37:58 +0200 Message-Id: <1461433078-6799-1-git-send-email-msuraev@sysmocom.de> X-Mailer: git-send-email 2.8.1 X-Virus-Scanned: ClamAV using ClamSMTP X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Development of OpenBSC, OsmoBSC, OsmoNITB, OsmoCSCN" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Max Errors-To: openbsc-bounces@lists.osmocom.org Sender: "OpenBSC" From: Max gprs_bssgp.c:461:9: runtime error: load of misaligned address 0x62100001a66b for type 'uint32_t', which requires 4 byte alignment gprs_ns.c:937:16: runtime error: load of misaligned address 0x61d00002a97f for type 'uint16_t', which requires 2 byte alignment --- src/gb/gprs_bssgp.c | 4 ++-- src/gb/gprs_ns.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c index d9d8ccd..3ad2f29 100644 --- a/src/gb/gprs_bssgp.c +++ b/src/gb/gprs_bssgp.c @@ -416,7 +416,7 @@ static int bssgp_rx_suspend(struct msgb *msg, struct tlv_parsed *tp) return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg); } - tlli = ntohl(*(uint32_t *)TLVP_VAL(tp, BSSGP_IE_TLLI)); + tlli = ntohl(tlvp_val32_unal(tp, BSSGP_IE_TLLI)); DEBUGP(DBSSGP, "BSSGP BVCI=%u TLLI=0x%08x Rx SUSPEND\n", ns_bvci, tlli); @@ -458,7 +458,7 @@ static int bssgp_rx_resume(struct msgb *msg, struct tlv_parsed *tp) return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg); } - tlli = ntohl(*(uint32_t *)TLVP_VAL(tp, BSSGP_IE_TLLI)); + tlli = ntohl(tlvp_val32_unal(tp, BSSGP_IE_TLLI)); suspend_ref = *TLVP_VAL(tp, BSSGP_IE_SUSPEND_REF_NR); DEBUGP(DBSSGP, "BSSGP BVCI=%u TLLI=0x%08x Rx RESUME\n", ns_bvci, tlli); diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c index a29c946..6879c70 100644 --- a/src/gb/gprs_ns.c +++ b/src/gb/gprs_ns.c @@ -934,8 +934,8 @@ static int gprs_ns_rx_reset_ack(struct gprs_nsvc **nsvc, struct msgb *msg) return -EINVAL; } - nsvci = ntohs(*(uint16_t *) TLVP_VAL(&tp, NS_IE_VCI)); - nsei = ntohs(*(uint16_t *) TLVP_VAL(&tp, NS_IE_NSEI)); + nsvci = ntohs(tlvp_val16_unal(&tp, NS_IE_VCI)); + nsei = ntohs(tlvp_val16_unal(&tp, NS_IE_NSEI)); LOGP(DNS, LOGL_INFO, "NSVCI=%u%s Rx NS RESET ACK (NSEI=%u, NSVCI=%u)\n", (*nsvc)->nsvci, (*nsvc)->nsvci_is_valid ? "" : "(invalid)",