From patchwork Wed Oct 19 14:50:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Yudaken X-Patchwork-Id: 13011911 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96589C4332F for ; Wed, 19 Oct 2022 14:57:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231446AbiJSO5p (ORCPT ); Wed, 19 Oct 2022 10:57:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231903AbiJSO5c (ORCPT ); Wed, 19 Oct 2022 10:57:32 -0400 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94B487E01D for ; Wed, 19 Oct 2022 07:50:55 -0700 (PDT) Received: from pps.filterd (m0109333.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29JB1NkT030117 for ; Wed, 19 Oct 2022 07:50:55 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=s2048-2021-q4; bh=RSktfQn2G5dATGu5m9h/eD7c/X+AgN2rZL0KAkf+y8M=; b=eoPMdqaSOpz1fxNLWAjJ1oJK+3txInkNtpEBAKz93xfOj1ociCO2Ee0nvDFOIAuvokq9 VJxAiW03bbVymn9CLPalWFMIXNE0VHhNN0vDDlh4CnflnI5bvgoBTi4g4cM6OAb4Cmih GN3v5M6v2Uoo7YL1PXbndzaFs9LGxEiNcIfbRbma3ZIRl7vCmFB4vVjeiEYyTZ8RRnIo e87ll/zvuTpHpf3w9KTMNtnxsySlUzIPaVAxFxet+BVlUfVRz88opXl8hs3zrXcqRw7W f73hnOvrMOegjz0C6hvMIy0buhFNfOD0LMzkXZGn4zs/LWIVcxJKImJT4pfYPx6U2n0V ww== Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3kag05t174-12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 19 Oct 2022 07:50:55 -0700 Received: from twshared9088.05.ash9.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 19 Oct 2022 07:50:51 -0700 Received: by devbig038.lla2.facebook.com (Postfix, from userid 572232) id 785667E52F5B; Wed, 19 Oct 2022 07:50:48 -0700 (PDT) From: Dylan Yudaken To: Jens Axboe , Pavel Begunkov CC: , , Dylan Yudaken Subject: [PATCH liburing 1/2] fix int shortening bug in io_uring_recvmsg_validate Date: Wed, 19 Oct 2022 07:50:41 -0700 Message-ID: <20221019145042.446477-2-dylany@meta.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221019145042.446477-1-dylany@meta.com> References: <20221019145042.446477-1-dylany@meta.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: jEnDwoSbgb_kt346Jjapq6STZpny7jx- X-Proofpoint-GUID: jEnDwoSbgb_kt346Jjapq6STZpny7jx- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-19_09,2022-10-19_03,2022-06-22_01 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Fix for compilers running with -Wshorten-64-to-32 Fixes: 874406f7fb09 ("add multishot recvmsg API") Signed-off-by: Dylan Yudaken --- src/include/liburing.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/include/liburing.h b/src/include/liburing.h index 1d049230ddfb..118bba9eea15 100644 --- a/src/include/liburing.h +++ b/src/include/liburing.h @@ -791,10 +791,9 @@ static inline void io_uring_prep_recv_multishot(struct io_uring_sqe *sqe, static inline struct io_uring_recvmsg_out * io_uring_recvmsg_validate(void *buf, int buf_len, struct msghdr *msgh) { - int header = msgh->msg_controllen + msgh->msg_namelen + + unsigned long header = msgh->msg_controllen + msgh->msg_namelen + sizeof(struct io_uring_recvmsg_out); - - if (buf_len < header) + if (buf_len < 0 || (unsigned long)buf_len < header) return NULL; return (struct io_uring_recvmsg_out *)buf; }