Message ID | 20190403095031.11720-1-yuehaibing@huawei.com |
---|---|
State | Not Applicable |
Delegated to: | David Miller |
Headers | show |
Series | iov_iter: Fix build error without CONFIG_CRYPTO | expand |
On Wed, Apr 03, 2019 at 05:50:31PM +0800, Yue Haibing wrote: > From: YueHaibing <yuehaibing@huawei.com> > > If CONFIG_CRYPTO is not set or set to m, > gcc building warn this: > > lib/iov_iter.o: In function `hash_and_copy_to_iter': > iov_iter.c:(.text+0x9129): undefined reference to `crypto_stats_get' > iov_iter.c:(.text+0x9152): undefined reference to `crypto_stats_ahash_update' > > Reported-by: Hulk Robot <hulkci@huawei.com> > Fixes: d05f443554b3 ("iov_iter: introduce hash_and_copy_to_iter helper") > Signed-off-by: YueHaibing <yuehaibing@huawei.com> I'm not sure it's the right fix; might be better to have something like size_t hash_and_copy_to_iter(const void *addr, size_t bytes, void *hashp, struct iov_iter *i) { #ifdef CONFIG_CRYPTO struct ahash_request *hash = hashp; struct scatterlist sg; size_t copied; copied = copy_to_iter(addr, bytes, i); sg_init_one(&sg, addr, copied); ahash_request_set_crypt(hash, &sg, NULL, copied); crypto_ahash_update(hash); return copied; #else return 0; #endif } EXPORT_SYMBOL(hash_and_copy_to_iter); instead. Objections?
>> If CONFIG_CRYPTO is not set or set to m, >> gcc building warn this: >> >> lib/iov_iter.o: In function `hash_and_copy_to_iter': >> iov_iter.c:(.text+0x9129): undefined reference to `crypto_stats_get' >> iov_iter.c:(.text+0x9152): undefined reference to `crypto_stats_ahash_update' >> >> Reported-by: Hulk Robot <hulkci@huawei.com> >> Fixes: d05f443554b3 ("iov_iter: introduce hash_and_copy_to_iter helper") >> Signed-off-by: YueHaibing <yuehaibing@huawei.com> > > I'm not sure it's the right fix; might be better to have something like > > size_t hash_and_copy_to_iter(const void *addr, size_t bytes, void *hashp, > struct iov_iter *i) > { > #ifdef CONFIG_CRYPTO > struct ahash_request *hash = hashp; > struct scatterlist sg; > size_t copied; > > copied = copy_to_iter(addr, bytes, i); > sg_init_one(&sg, addr, copied); > ahash_request_set_crypt(hash, &sg, NULL, copied); > crypto_ahash_update(hash); > return copied; > #else > return 0; > #endif > } > EXPORT_SYMBOL(hash_and_copy_to_iter); > > instead. Objections? Looks better to me.
On 2019/4/4 0:52, Al Viro wrote: > On Wed, Apr 03, 2019 at 05:50:31PM +0800, Yue Haibing wrote: >> From: YueHaibing <yuehaibing@huawei.com> >> >> If CONFIG_CRYPTO is not set or set to m, >> gcc building warn this: >> >> lib/iov_iter.o: In function `hash_and_copy_to_iter': >> iov_iter.c:(.text+0x9129): undefined reference to `crypto_stats_get' >> iov_iter.c:(.text+0x9152): undefined reference to `crypto_stats_ahash_update' >> >> Reported-by: Hulk Robot <hulkci@huawei.com> >> Fixes: d05f443554b3 ("iov_iter: introduce hash_and_copy_to_iter helper") >> Signed-off-by: YueHaibing <yuehaibing@huawei.com> > > I'm not sure it's the right fix; might be better to have something like > > size_t hash_and_copy_to_iter(const void *addr, size_t bytes, void *hashp, > struct iov_iter *i) > { > #ifdef CONFIG_CRYPTO > struct ahash_request *hash = hashp; > struct scatterlist sg; > size_t copied; > > copied = copy_to_iter(addr, bytes, i); > sg_init_one(&sg, addr, copied); > ahash_request_set_crypt(hash, &sg, NULL, copied); > crypto_ahash_update(hash); > return copied; > #else > return 0; > #endif > } > EXPORT_SYMBOL(hash_and_copy_to_iter); > > instead. Objections? Indeed, this seems better. I can post v2 as your suggestion. > > . >
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 9027a8c..3999112 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -3396,9 +3396,11 @@ static inline int skb_copy_datagram_msg(const struct sk_buff *from, int offset, } int skb_copy_and_csum_datagram_msg(struct sk_buff *skb, int hlen, struct msghdr *msg); +#ifdef CONFIG_CRYPTO int skb_copy_and_hash_datagram_iter(const struct sk_buff *skb, int offset, struct iov_iter *to, int len, struct ahash_request *hash); +#endif int skb_copy_datagram_from_iter(struct sk_buff *skb, int offset, struct iov_iter *from, int len); int zerocopy_sg_from_iter(struct sk_buff *skb, struct iov_iter *frm); diff --git a/lib/iov_iter.c b/lib/iov_iter.c index 50e77ec..ed02f74 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -1528,6 +1528,7 @@ size_t csum_and_copy_to_iter(const void *addr, size_t bytes, void *csump, } EXPORT_SYMBOL(csum_and_copy_to_iter); +#ifdef CONFIG_CRYPTO size_t hash_and_copy_to_iter(const void *addr, size_t bytes, void *hashp, struct iov_iter *i) { @@ -1542,6 +1543,7 @@ size_t hash_and_copy_to_iter(const void *addr, size_t bytes, void *hashp, return copied; } EXPORT_SYMBOL(hash_and_copy_to_iter); +#endif int iov_iter_npages(const struct iov_iter *i, int maxpages) { diff --git a/net/core/datagram.c b/net/core/datagram.c index 91bb5a0..8815ec2 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c @@ -494,6 +494,7 @@ static int __skb_datagram_iter(const struct sk_buff *skb, int offset, return 0; } +#ifdef CONFIG_CRYPTO /** * skb_copy_and_hash_datagram_iter - Copy datagram to an iovec iterator * and update a hash. @@ -511,6 +512,7 @@ int skb_copy_and_hash_datagram_iter(const struct sk_buff *skb, int offset, hash_and_copy_to_iter, hash); } EXPORT_SYMBOL(skb_copy_and_hash_datagram_iter); +#endif static size_t simple_copy_to_iter(const void *addr, size_t bytes, void *data __always_unused, struct iov_iter *i)