From patchwork Mon Dec 10 07:53:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shamir Rabinovitch X-Patchwork-Id: 10720793 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1118591E for ; Mon, 10 Dec 2018 07:54:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05DC32851A for ; Mon, 10 Dec 2018 07:54:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE9FF285E5; Mon, 10 Dec 2018 07:54:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95758286AE for ; Mon, 10 Dec 2018 07:54:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726392AbeLJHyF (ORCPT ); Mon, 10 Dec 2018 02:54:05 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:39514 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726278AbeLJHyF (ORCPT ); Mon, 10 Dec 2018 02:54:05 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wBA7igO9163928; Mon, 10 Dec 2018 07:54:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=mM4ANPf9gBDopsToJN6ixyFQeqCLAoggQ5TIO5wJsdo=; b=SKo9oZAYtyG4BEs3LgApMHCL+BgZZquE3rZA/yu5B1i/7U1xEtnYFzg9fqQr0haB8DS4 xsjwwTiBb3W7Q3NA6zMlyd+p0Vk6kJVc6tIxXWM8iHHax4QvM+2woUKBZaU5Qrk2MOYp UaYoxRBRSx2JqnSMGRUUb5POJ4a8zTAqTMFZp/JEh4400GP4NvUVaItMpmFJq1mC81Es q8yaVM/KkFzPmow73ckGZuYLQEQOumHAhTvUSQDTEL908eUNEAozTQYeq3cIsj9wXNww xIaylNMzOcfgJbquMSwSvfB2EktC1Iv+9YW7HIruYZmkA1YQEKWOLtpvFZqj9LAhsvUN Kw== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2p85ctv997-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 10 Dec 2018 07:54:03 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wBA7s1IQ002347 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 10 Dec 2018 07:54:02 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wBA7s1Rt012405; Mon, 10 Dec 2018 07:54:01 GMT Received: from localhost.localdomain (/10.175.0.73) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 09 Dec 2018 23:54:01 -0800 From: Shamir Rabinovitch To: linux-rdma@vger.kernel.org, rds-devel@oss.oracle.com Cc: shamir.rabinovitch@oracle.com, gerd.rausch@oracle.com, santosh.shilimkar@oracle.com, davem@davemloft.net Subject: [PATCH rds linux-next 2/2] net/rds: remove user triggered WARN_ON in rds_sendmsg Date: Mon, 10 Dec 2018 09:53:44 +0200 Message-Id: <20181210075344.16731-3-shamir.rabinovitch@oracle.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181210075344.16731-1-shamir.rabinovitch@oracle.com> References: <20181210075344.16731-1-shamir.rabinovitch@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9102 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812100074 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: shamir rabinovitch per comment from Leon in rdma mailing list https://lkml.org/lkml/2018/10/31/312 : Please don't forget to remove user triggered WARN_ON. https://lwn.net/Articles/769365/ "Greg Kroah-Hartman raised the problem of core kernel API code that will use WARN_ON_ONCE() to complain about bad usage; that will not generate the desired result if WARN_ON_ONCE() is configured to crash the machine. He was told that the code should just call pr_warn() instead, and that the called function should return an error in such situations. It was generally agreed that any WARN_ON() or WARN_ON_ONCE() calls that can be triggered from user space need to be fixed." Suggested-by: Leon Romanovsky Acked-by: Santosh Shilimkar Signed-off-by: shamir rabinovitch --- net/rds/message.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/net/rds/message.c b/net/rds/message.c index 4b00b1152a5f..c28ad4b111af 100644 --- a/net/rds/message.c +++ b/net/rds/message.c @@ -313,11 +313,14 @@ struct scatterlist *rds_message_alloc_sgs(struct rds_message *rm, int nents) struct scatterlist *sg_first = (struct scatterlist *) &rm[1]; struct scatterlist *sg_ret; - WARN_ON(rm->m_used_sgs + nents > rm->m_total_sgs); - WARN_ON(!nents); - - if (rm->m_used_sgs + nents > rm->m_total_sgs) + if (rm->m_used_sgs + nents > rm->m_total_sgs) { + pr_warn("rds: alloc sgs failed! total %d used %d nents %d\n", + rm->m_total_sgs, rm->m_used_sgs, nents); return NULL; + } + + if (!nents) + pr_warn("rds: alloc sgs failed! nents 0\n"); sg_ret = &sg_first[rm->m_used_sgs]; sg_init_table(sg_ret, nents);